Skip to content

Commit 7aba2c2

Browse files
committed
mothership agent-cli: engines consolidated to the settled surface
- The request carries invocation + sink + curate only; slicing happens on the worker. A stdout invocation lands worker-held text through the sink. jq-wasm removed from apps/sim; pipeline.ts gone. - Engines: docs search, grep, logs query, workflows deps, workflows lint. The universal grep gains files (content via the v2 text read) and integrations (the viewer's gateway projection) scopes; files-grep, workflow(s) grep, workflow views and trace engines are folded or dropped. Claude-Session: https://claude.ai/code/session_01HFVhPDtRZuCgupPco633w8
1 parent 12fe89a commit 7aba2c2

19 files changed

Lines changed: 121 additions & 952 deletions

apps/sim/lib/mothership/agent-cli/engines.test.ts

Lines changed: 3 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -54,125 +54,10 @@ function runtimeWith(responses: Record<string, unknown>): AgentCliRuntime {
5454
const EXPORT_PATH = '/api/v2/workflows/wf-1/export'
5555
const exportResponse = { data: { state: WORKFLOW_STATE } }
5656

57-
describe('workflow views', () => {
58-
it('projects just the blocks', async () => {
59-
const result = await runEngine(
60-
'workflow blocks',
61-
['wf-1'],
62-
runtimeWith({ [EXPORT_PATH]: exportResponse }),
63-
{}
64-
)
65-
expect(result.exitCode).toBe(0)
66-
const blocks = JSON.parse(result.stdout)
67-
expect(blocks).toEqual([
68-
{ id: 'block-1', type: 'starter', name: 'Start', enabled: true },
69-
{ id: 'block-2', type: 'agent', name: 'Summarize emails', enabled: true },
70-
])
71-
})
72-
73-
it('projects just the edges', async () => {
74-
const result = await runEngine(
75-
'workflow edges',
76-
['wf-1'],
77-
runtimeWith({ [EXPORT_PATH]: exportResponse }),
78-
{}
79-
)
80-
expect(result.exitCode).toBe(0)
81-
expect(JSON.parse(result.stdout)).toEqual([
82-
{ source: 'block-1', target: 'block-2', sourceHandle: 'source' },
83-
])
84-
})
85-
86-
it('fails usefully without a workflow id', async () => {
87-
const result = await runEngine('workflow blocks', [], runtimeWith({}), {})
88-
expect(result.exitCode).toBe(1)
89-
expect(result.stderr).toContain('Usage:')
90-
})
91-
})
92-
93-
describe('files grep', () => {
94-
const FILES_LIST = {
95-
data: [
96-
{ id: 'f1', name: 'report.md', folderPath: 'docs' },
97-
{ id: 'f2', name: 'logo.png', folderPath: '' },
98-
],
99-
nextCursor: null,
100-
}
101-
const readText = (text: string, degraded = false) => ({
102-
data: { text, degraded },
103-
})
104-
105-
it('greps file contents with line numbers, skipping non-text files', async () => {
106-
const result = await runEngine(
107-
'files grep',
108-
['quarterly'],
109-
runtimeWith({
110-
'/api/v2/files': FILES_LIST,
111-
'/api/v2/files/f1/text': readText('# Report\nQuarterly revenue was up.\n'),
112-
'/api/v2/files/f2/text': readText('', true),
113-
}),
114-
{}
115-
)
116-
expect(result.exitCode).toBe(0)
117-
expect(result.stdout).toContain('docs/report.md:2: Quarterly revenue was up.')
118-
expect(result.stdout).not.toContain('logo.png')
119-
})
120-
121-
it('filters by folder prefix', async () => {
122-
const result = await runEngine(
123-
'files grep',
124-
['Quarterly', 'other'],
125-
runtimeWith({ '/api/v2/files': FILES_LIST }),
126-
{}
127-
)
128-
expect(result.exitCode).toBe(0)
129-
expect(result.stdout).toContain('No matches')
130-
})
131-
})
132-
133-
describe('workflow grep', () => {
134-
it('reports matches as path: value lines', async () => {
135-
const result = await runEngine(
136-
'workflow grep',
137-
['wf-1', 'Summarize'],
138-
runtimeWith({ [EXPORT_PATH]: exportResponse }),
139-
{}
140-
)
141-
expect(result.exitCode).toBe(0)
142-
expect(result.stdout).toContain('.blocks.block-2.name: Summarize emails')
143-
})
144-
145-
it('falls back to literal search on an invalid regex', async () => {
146-
const result = await runEngine(
147-
'workflow grep',
148-
['wf-1', 'api.example.com['],
149-
runtimeWith({ [EXPORT_PATH]: exportResponse }),
150-
{}
151-
)
152-
expect(result.exitCode).toBe(0)
153-
expect(result.stdout).toBe('No matches.')
154-
})
155-
156-
it('searches across all workspace workflows', async () => {
157-
const result = await runEngine(
158-
'workflows grep',
159-
['Summarize'],
160-
runtimeWith({
161-
'/api/v2/workflows': {
162-
data: [{ id: 'wf-1', name: 'Email digest' }],
163-
nextCursor: null,
164-
},
165-
[EXPORT_PATH]: exportResponse,
166-
}),
167-
{}
168-
)
169-
expect(result.exitCode).toBe(0)
170-
expect(result.stdout).toContain('Email digest (wf-1).blocks.block-2.name: Summarize emails')
171-
})
172-
57+
describe('workflows lint', () => {
17358
it('lints a workflow through the shared engine with the caller scoped as subject', async () => {
17459
const result = await runEngine(
175-
'workflow lint',
60+
'workflows lint',
17661
['wf-1'],
17762
runtimeWith({ [EXPORT_PATH]: exportResponse }),
17863
{}
@@ -190,7 +75,7 @@ describe('workflow grep', () => {
19075
})
19176

19277
it('surfaces execution errors as a failed result, never a throw', async () => {
193-
const result = await runEngine('workflow grep', ['wf-missing', 'x'], runtimeWith({}), {})
78+
const result = await runEngine('workflows lint', ['wf-missing'], runtimeWith({}), {})
19479
expect(result.exitCode).toBe(1)
19580
expect(result.stderr).toContain('Unexpected request')
19681
})

apps/sim/lib/mothership/agent-cli/engines/deps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fetchWorkflowState } from '@/lib/mothership/agent-cli/engines/workflow-views'
1+
import { fetchWorkflowState } from '@/lib/mothership/agent-cli/engines/workflow-state'
22
import { type AgentCliEngine, agentCliFail, agentCliOk } from '@/lib/mothership/agent-cli/types'
33
import { normalizeName, SPECIAL_REFERENCE_PREFIXES } from '@/executor/constants'
44
import {

apps/sim/lib/mothership/agent-cli/engines/files-grep.ts

Lines changed: 0 additions & 107 deletions
This file was deleted.

apps/sim/lib/mothership/agent-cli/engines/grep.ts

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)