@cleocode/adapters 2026.11.1-canary.9 → 2026.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.source-stamp.json +1 -1
- package/dist/index.js +1691 -1354
- package/dist/index.js.map +3 -3
- package/dist/orca-execution.d.ts +90 -0
- package/dist/orca-execution.d.ts.map +1 -0
- package/dist/orca-execution.js +843 -0
- package/dist/orca-execution.js.map +6 -0
- package/dist/providers/claude-code/index.js +1689 -1357
- package/dist/providers/claude-code/index.js.map +3 -3
- package/dist/providers/claude-code/lead-session.d.ts +8 -5
- package/dist/providers/claude-code/lead-session.d.ts.map +1 -1
- package/dist/providers/claude-sdk/index.js +1674 -1352
- package/dist/providers/claude-sdk/index.js.map +3 -3
- package/dist/providers/claude-sdk/spawn.d.ts.map +1 -1
- package/dist/providers/codex/index.js +1540 -1233
- package/dist/providers/codex/index.js.map +3 -3
- package/dist/providers/gemini-cli/index.js +1540 -1233
- package/dist/providers/gemini-cli/index.js.map +3 -3
- package/dist/providers/kimi/index.js +1540 -1233
- package/dist/providers/kimi/index.js.map +3 -3
- package/dist/providers/openai-sdk/index.js +1660 -1353
- package/dist/providers/openai-sdk/index.js.map +3 -3
- package/dist/providers/opencode/index.js +1540 -1233
- package/dist/providers/opencode/index.js.map +3 -3
- package/dist/providers/pi/index.js +1540 -1233
- package/dist/providers/pi/index.js.map +3 -3
- package/package.json +10 -6
- package/src/__tests__/orca-execution-fixture.ts +422 -0
- package/src/__tests__/orca-execution.test.ts +1357 -0
- package/src/__tests__/orca-plugin-panel.test.ts +661 -0
- package/src/__tests__/orca-plugin.test.ts +660 -0
- package/src/orca-execution.ts +1193 -0
- package/src/providers/claude-code/__tests__/lead-mcp.test.ts +27 -2
- package/src/providers/claude-code/lead-session.ts +21 -8
- package/src/providers/claude-sdk/__tests__/spawn.test.ts +19 -0
- package/src/providers/claude-sdk/spawn.ts +14 -0
- package/src/providers/shared/__tests__/lead-tool-strip.test.ts +1 -1
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
LEAD_KICKOFF_PROMPT,
|
|
38
38
|
leadSessionSettings,
|
|
39
39
|
resolveAbsoluteBinary,
|
|
40
|
+
runInteractiveLead,
|
|
40
41
|
} from '../lead-session.js';
|
|
41
42
|
import { buildClaudeArgs, ClaudeCodeSpawnProvider } from '../spawn.js';
|
|
42
43
|
|
|
@@ -94,12 +95,12 @@ describe('lead isolation on claude-code (T14363, T14423)', () => {
|
|
|
94
95
|
'--allowedTools',
|
|
95
96
|
allowed,
|
|
96
97
|
'--disallowedTools',
|
|
97
|
-
|
|
98
|
+
'Bash,Edit,Write,NotebookEdit,WebFetch,WebSearch',
|
|
98
99
|
'--mcp-config',
|
|
99
100
|
join(spawnDir, LEAD_MCP_FILE),
|
|
100
101
|
'--strict-mcp-config',
|
|
101
102
|
'--permission-mode',
|
|
102
|
-
'dontAsk',
|
|
103
|
+
tools === 'AskUserQuestion' ? 'default' : 'dontAsk',
|
|
103
104
|
'--setting-sources',
|
|
104
105
|
'',
|
|
105
106
|
'--session-id',
|
|
@@ -122,6 +123,8 @@ describe('lead isolation on claude-code (T14363, T14423)', () => {
|
|
|
122
123
|
]);
|
|
123
124
|
expect(args).not.toContain('--print');
|
|
124
125
|
expect(args).not.toContain('--dangerously-skip-permissions');
|
|
126
|
+
expect(args).not.toContain('dontAsk');
|
|
127
|
+
expect(args.join(',')).not.toContain('MultiEdit');
|
|
125
128
|
}
|
|
126
129
|
});
|
|
127
130
|
|
|
@@ -144,6 +147,27 @@ describe('lead isolation on claude-code (T14363, T14423)', () => {
|
|
|
144
147
|
expect(args.join(' ')).not.toContain('AskUserQuestion');
|
|
145
148
|
});
|
|
146
149
|
|
|
150
|
+
it.each([
|
|
151
|
+
[false, true],
|
|
152
|
+
[true, false],
|
|
153
|
+
[undefined, undefined],
|
|
154
|
+
])('refuses interactive stdin=%s, stdout=%s before spawning, naming --detached', async (stdin, stdout) => {
|
|
155
|
+
const original = { stdin: process.stdin.isTTY, stdout: process.stdout.isTTY };
|
|
156
|
+
Object.defineProperty(process.stdin, 'isTTY', { value: stdin, configurable: true });
|
|
157
|
+
Object.defineProperty(process.stdout, 'isTTY', { value: stdout, configurable: true });
|
|
158
|
+
try {
|
|
159
|
+
await expect(runInteractiveLead('/nonexistent/claude', [], {})).rejects.toThrow(
|
|
160
|
+
`${E_LEAD_NO_OWNER_CHANNEL}: interactive AskUserQuestion needs terminal stdin and stdout; use --detached`,
|
|
161
|
+
);
|
|
162
|
+
} finally {
|
|
163
|
+
Object.defineProperty(process.stdin, 'isTTY', { value: original.stdin, configurable: true });
|
|
164
|
+
Object.defineProperty(process.stdout, 'isTTY', {
|
|
165
|
+
value: original.stdout,
|
|
166
|
+
configurable: true,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
147
171
|
it('the config holds exactly the runner (lead identity, given cleo) and mbx; no other user server', async () => {
|
|
148
172
|
writeFileSync(
|
|
149
173
|
claudeJson,
|
|
@@ -271,6 +295,7 @@ describe('lead isolation on claude-code (T14363, T14423)', () => {
|
|
|
271
295
|
binaries: { cleo: join(bin, 'cleo'), agentmbx: join(bin, 'agentmbx') },
|
|
272
296
|
}),
|
|
273
297
|
);
|
|
298
|
+
expect(Object.keys(settings)).toEqual(['hooks']);
|
|
274
299
|
const run = (event: 'SessionStart' | 'SessionEnd') =>
|
|
275
300
|
execFileSync('/bin/sh', ['-c', settings.hooks[event][0].hooks[0].command], {
|
|
276
301
|
env: { PATH: '/usr/bin:/bin' },
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* owner's AgentMBX mailbox (the prompt says how).
|
|
10
10
|
*
|
|
11
11
|
* In both, tools are an allow list (T14423): only the runner, mbx and (when
|
|
12
|
-
* interactive) `AskUserQuestion`;
|
|
13
|
-
* denied tools as a second layer.
|
|
12
|
+
* interactive) `AskUserQuestion`; Manual mode for interactive owner answers,
|
|
13
|
+
* `dontAsk` for detached runs, no settings sources, and denied tools as a second layer.
|
|
14
14
|
*
|
|
15
15
|
* `cleo` and `agentmbx` in hooks and the runner entry are absolute paths
|
|
16
16
|
* resolved at spawn time from the absolute entries of PATH, never relative
|
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
import { spawn as nodeSpawn } from 'node:child_process';
|
|
24
24
|
import { isAbsolute } from 'node:path';
|
|
25
25
|
import type { LeadMode, SpawnContext } from '@cleocode/contracts';
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
E_LEAD_NO_OWNER_CHANNEL,
|
|
28
|
+
LEAD_ASK_TOOL,
|
|
29
|
+
} from '@cleocode/contracts/operations/orchestrate.js';
|
|
27
30
|
import { findOnPath, pathDelimiterFor, pathEnvKey, splitPathEnv } from '@cleocode/paths';
|
|
28
31
|
import { type LeadMcpSetup, leadAllowedTools } from './lead-mcp.js';
|
|
29
32
|
|
|
@@ -135,9 +138,11 @@ export function leadSessionSettings(input: {
|
|
|
135
138
|
* only; detached gets no built-in tool at all;
|
|
136
139
|
* - `--mcp-config <file> --strict-mcp-config`: only the runner and a
|
|
137
140
|
* validated mbx; `--allowedTools` names exactly the allowed tools;
|
|
138
|
-
* -
|
|
139
|
-
*
|
|
140
|
-
* - `--
|
|
141
|
+
* - Manual (`default`) permission mode permits interactive owner answers;
|
|
142
|
+
* `dontAsk` denies them even when `AskUserQuestion` is explicitly allowed;
|
|
143
|
+
* - `--setting-sources ""` excludes user/project permission settings;
|
|
144
|
+
* - `--disallowedTools <denied>` as a second layer, excluding the retired
|
|
145
|
+
* `MultiEdit` name (already absent under `--tools`).
|
|
141
146
|
*
|
|
142
147
|
* Interactive drops `--print` and `--output-format`; detached keeps both.
|
|
143
148
|
* The prompt file is the appended system prompt (the lead cannot Read
|
|
@@ -169,12 +174,12 @@ export function buildLeadArgs(input: {
|
|
|
169
174
|
'--allowedTools',
|
|
170
175
|
allowed.join(','),
|
|
171
176
|
'--disallowedTools',
|
|
172
|
-
input.denied.join(','),
|
|
177
|
+
input.denied.filter((tool) => tool !== 'MultiEdit').join(','),
|
|
173
178
|
'--mcp-config',
|
|
174
179
|
input.leadMcp.config,
|
|
175
180
|
'--strict-mcp-config',
|
|
176
181
|
'--permission-mode',
|
|
177
|
-
'dontAsk',
|
|
182
|
+
interactive ? 'default' : 'dontAsk',
|
|
178
183
|
'--setting-sources',
|
|
179
184
|
'',
|
|
180
185
|
...(input.sessionId !== undefined ? ['--session-id', input.sessionId] : []),
|
|
@@ -202,6 +207,7 @@ export interface InteractiveLeadExit {
|
|
|
202
207
|
* @param args - From {@link buildLeadArgs} with mode `interactive`.
|
|
203
208
|
* @param opts - Working directory, environment and a started-pid callback.
|
|
204
209
|
* @returns The pid and exit code once the session ends.
|
|
210
|
+
* @throws When stdin or stdout is not a terminal; use `--detached` instead.
|
|
205
211
|
* @task T14363
|
|
206
212
|
*/
|
|
207
213
|
export function runInteractiveLead(
|
|
@@ -214,6 +220,13 @@ export function runInteractiveLead(
|
|
|
214
220
|
readonly onStart?: (pid: number) => void;
|
|
215
221
|
},
|
|
216
222
|
): Promise<InteractiveLeadExit> {
|
|
223
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
224
|
+
return Promise.reject(
|
|
225
|
+
new Error(
|
|
226
|
+
`${E_LEAD_NO_OWNER_CHANNEL}: interactive AskUserQuestion needs terminal stdin and stdout; use --detached with --adapter claude-code and a configured mbx MCP server`,
|
|
227
|
+
),
|
|
228
|
+
);
|
|
229
|
+
}
|
|
217
230
|
return new Promise((resolve, reject) => {
|
|
218
231
|
const child = nodeSpawn(command, [...args], {
|
|
219
232
|
stdio: 'inherit',
|
|
@@ -232,11 +232,30 @@ describe('ClaudeSDKSpawnProvider', () => {
|
|
|
232
232
|
expect(provider.leadToolStrip).toBe('enforced');
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
+
it.each([
|
|
236
|
+
undefined,
|
|
237
|
+
'interactive',
|
|
238
|
+
])('refuses an interactive lead (%s) before generation, naming --detached', async (leadMode) => {
|
|
239
|
+
const result = await provider.spawn({
|
|
240
|
+
taskId: 'T005',
|
|
241
|
+
prompt: 'Plan only.',
|
|
242
|
+
leadDeniedTools: ['Bash', 'Edit', 'Write'],
|
|
243
|
+
options: { leadMode },
|
|
244
|
+
});
|
|
245
|
+
expect(result.status).toBe('failed');
|
|
246
|
+
expect(result.error).toContain('E_LEAD_NO_OWNER_CHANNEL');
|
|
247
|
+
expect(result.error).toContain('--detached');
|
|
248
|
+
expect(result.error).toContain('--adapter claude-code');
|
|
249
|
+
expect(mockState.lastCall).toBeNull();
|
|
250
|
+
expect(await provider.listRunning()).toEqual([]);
|
|
251
|
+
});
|
|
252
|
+
|
|
235
253
|
it('lead spawn: passes no tools and drops denied tools from the allowlist (T14357)', async () => {
|
|
236
254
|
const result = await provider.spawn({
|
|
237
255
|
taskId: 'T005',
|
|
238
256
|
prompt: 'Plan only.',
|
|
239
257
|
leadDeniedTools: ['Bash', 'Edit', 'Write'],
|
|
258
|
+
options: { leadMode: 'detached' },
|
|
240
259
|
});
|
|
241
260
|
|
|
242
261
|
expect(result.status).toBe('completed');
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
import type { AdapterSpawnProvider, SpawnContext, SpawnResult } from '@cleocode/contracts';
|
|
27
27
|
import { getErrorMessage } from '@cleocode/contracts';
|
|
28
|
+
import { E_LEAD_NO_OWNER_CHANNEL } from '@cleocode/contracts/operations/orchestrate.js';
|
|
28
29
|
import { resolveCredentials } from '../shared/credentials.js';
|
|
29
30
|
import { leadDeniedTools } from '../shared/lead-tool-strip.js';
|
|
30
31
|
import { SessionStore } from './session-store.js';
|
|
@@ -87,6 +88,19 @@ export class ClaudeSDKSpawnProvider implements AdapterSpawnProvider {
|
|
|
87
88
|
const sessionId = `cleo-${instanceId}`;
|
|
88
89
|
const startTime = new Date().toISOString();
|
|
89
90
|
|
|
91
|
+
if (leadDeniedTools(context) !== null && context.options?.leadMode !== 'detached') {
|
|
92
|
+
return {
|
|
93
|
+
instanceId,
|
|
94
|
+
taskId: context.taskId,
|
|
95
|
+
providerId: 'claude-sdk',
|
|
96
|
+
status: 'failed',
|
|
97
|
+
startTime,
|
|
98
|
+
endTime: new Date().toISOString(),
|
|
99
|
+
exitCode: 1,
|
|
100
|
+
error: `${E_LEAD_NO_OWNER_CHANNEL}: claude-sdk cannot deliver interactive AskUserQuestion answers; use --detached with --adapter claude-code and a configured mbx MCP server`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
90
104
|
// Register in session store immediately so listRunning() reflects it
|
|
91
105
|
// before the async generation starts.
|
|
92
106
|
this.sessions.add({
|
|
@@ -46,7 +46,7 @@ describe('claude-code lead tool strip', () => {
|
|
|
46
46
|
expect(flag).toBeGreaterThanOrEqual(0);
|
|
47
47
|
const denied = (args[flag + 1] ?? '').split(',');
|
|
48
48
|
expect(denied).toEqual(expect.arrayContaining(['Bash', 'Edit', 'Write']));
|
|
49
|
-
expect(denied).toEqual([
|
|
49
|
+
expect(denied).toEqual(['Bash', 'Edit', 'Write', 'NotebookEdit', 'WebFetch', 'WebSearch']);
|
|
50
50
|
// The prompt file is the appended system prompt; the lead cannot Read files.
|
|
51
51
|
expect(args[args.indexOf('--append-system-prompt-file') + 1]).toBe('/tmp/prompt.md');
|
|
52
52
|
});
|