Skip to content

Commit 42c6a3b

Browse files
committed
feat(mothership): inspect configured workflow tool bindings
1 parent 947f720 commit 42c6a3b

10 files changed

Lines changed: 1103 additions & 39 deletions

File tree

‎apps/sim/lib/mothership/agent-cli/engines/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { logsQueryCommand } from '@/lib/mothership/agent-cli/engines/query'
88
import { universalGrepCommand } from '@/lib/mothership/agent-cli/engines/universal-grep'
99
import { workflowApiCommand } from '@/lib/mothership/agent-cli/engines/workflow-api'
1010
import { workflowInputsCommand } from '@/lib/mothership/agent-cli/engines/workflow-inputs'
11+
import { workflowToolsCommand } from '@/lib/mothership/agent-cli/engines/workflow-tools'
1112
import {
1213
type AgentCliEngine,
1314
type AgentCliFlags,
@@ -32,6 +33,7 @@ export const AUGMENTATION_ENGINES: Readonly<Record<string, AgentCliEngine>> = {
3233
'workflows lint': workflowLintCommand,
3334
'workflows api': workflowApiCommand,
3435
'workflows inputs': workflowInputsCommand,
36+
'workflows tools': workflowToolsCommand,
3537
}
3638

3739
/** Runs one engine by the worker's name; an engine that throws yields a failed result, never a throw. */
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { enginePrincipal } from '@/lib/mothership/agent-cli/engine-principal'
2+
import { type AgentCliEngine, agentCliFail, agentCliOk } from '@/lib/mothership/agent-cli/types'
3+
import { messageForCopilotApplicationError } from '@/lib/mothership/application/error'
4+
import { inspectWorkflowTools } from '@/lib/workflows/application/inspect-workflow-tools'
5+
6+
export const workflowToolsCommand: AgentCliEngine = {
7+
async execute([workflowId], runtime, flags) {
8+
if (!workflowId || typeof flags.block !== 'string' || !flags.block.trim())
9+
return agentCliFail('Usage: sim workflows tools <workflowId> --block <blockId>')
10+
const principal = enginePrincipal(runtime, inspectWorkflowTools)
11+
if (!principal) return agentCliFail('Workspace authentication is unavailable.')
12+
try {
13+
const report = await inspectWorkflowTools.execute({
14+
principal,
15+
input: {
16+
workflowId,
17+
blockId: flags.block,
18+
assertedWorkspaceId: runtime.workspaceId,
19+
...(typeof flags.query === 'string' ? { query: flags.query } : {}),
20+
...(typeof flags.limit === 'string' ? { limit: Number(flags.limit) } : {}),
21+
signal: runtime.signal,
22+
},
23+
})
24+
return agentCliOk(JSON.stringify(report, null, 2))
25+
} catch (error) {
26+
if (runtime.signal?.aborted) return agentCliFail('Tool inspection was cancelled.')
27+
return agentCliFail(
28+
messageForCopilotApplicationError(
29+
error,
30+
'Tool inspection could not complete. Retry before relying on this report.'
31+
)
32+
)
33+
}
34+
},
35+
}

‎apps/sim/lib/mothership/agent-cli/tool-binding-hints.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export function withToolBindingHints(detail: MothershipBlockDetail): MothershipB
1919
toolBinding: {
2020
selectionMode: isMothership ? 'additive' : 'explicit',
2121
discovery: [
22+
'workflows tools <workflowId> --block <blockId>',
2223
...(!isMothership
2324
? [
2425
'blocks get <type> --operation <operation>',

‎apps/sim/lib/mothership/tools/cli-tool-display.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ export const CLI_TOOL_TITLES: Record<string, string> = {
243243
cli_workflows_deps: 'Tracing workflow inputs',
244244
cli_workflows_api: 'Reading workflow API details',
245245
cli_workflows_lint: 'Validating workflow',
246+
cli_workflows_tools: 'Inspecting workflow tools',
246247
// Non-CLI copilot worker tools
247248
cli_help: 'Checking CLI reference',
248249
sim_cli: 'Running CLI command',

0 commit comments

Comments
 (0)