@commonlyai/cli 0.1.103 → 0.1.104
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/package.json
CHANGED
|
@@ -75,7 +75,9 @@ import {
|
|
|
75
75
|
import { CREDENTIAL_FILE_VAR, CREDENTIAL_KEY, writeCredentialFile } from '../credential-file.js';
|
|
76
76
|
import { supportedGitHooks } from '../commit-attribution.js';
|
|
77
77
|
import { deliverSeatCredential, withholdRuntimeCredential } from '../mcp-credential-delivery.js';
|
|
78
|
-
import {
|
|
78
|
+
import {
|
|
79
|
+
prepareMcpSpawn, PUBLIC_MCP_UNAVAILABLE_CODE, publicMcpUnavailableError, selectedMcpVersionDir,
|
|
80
|
+
} from '../mcp-home.js';
|
|
79
81
|
import { buildMemoryPreamble } from '../memory-bridge.js';
|
|
80
82
|
import { adapterFailure, spawnCredentials } from '../upstream-refusal.js';
|
|
81
83
|
|
|
@@ -788,7 +790,12 @@ export default {
|
|
|
788
790
|
let mcpConfig = null;
|
|
789
791
|
let publicClaudeState = null;
|
|
790
792
|
try {
|
|
791
|
-
|
|
793
|
+
// Trust is normalized at entry (legacy `internal` reads as public). The
|
|
794
|
+
// MCP policy follows trust alone, whatever confines the seat: a public
|
|
795
|
+
// bwrap seat needs a host-prepared build exactly as a Seatbelt one does
|
|
796
|
+
// (Rhea on #2247).
|
|
797
|
+
const publicTrust = ctx.environment?.sandbox?.trust === 'public';
|
|
798
|
+
const publicNativeSandbox = publicTrust
|
|
792
799
|
&& PUBLIC_SANDBOX_MODES.has(resolvePublicSandboxMode(ctx.environment?.sandbox));
|
|
793
800
|
if (publicNativeSandbox) {
|
|
794
801
|
publicClaudeState = await preparePublicClaudeState(ctx);
|
|
@@ -798,12 +805,10 @@ export default {
|
|
|
798
805
|
runtimeToken: ctx.runtimeToken,
|
|
799
806
|
instanceUrl: ctx.instanceUrl,
|
|
800
807
|
agentName: ctx.agentName,
|
|
801
|
-
publicSeat:
|
|
808
|
+
publicSeat: publicTrust,
|
|
802
809
|
});
|
|
803
810
|
}
|
|
804
|
-
if (mcpConfig?.unavailableMcp.length)
|
|
805
|
-
baseArgs[1] = `${fullPrompt}\n\n${PUBLIC_MCP_UNAVAILABLE_NOTICE}`;
|
|
806
|
-
}
|
|
811
|
+
if (mcpConfig?.unavailableMcp.length) throw publicMcpUnavailableError(mcpConfig.unavailableMcp);
|
|
807
812
|
const claudeEnv = buildClaudeEnv(
|
|
808
813
|
ctx.env,
|
|
809
814
|
publicClaudeState,
|
|
@@ -837,6 +842,10 @@ export default {
|
|
|
837
842
|
});
|
|
838
843
|
return { text: stdout.trim(), newSessionId: sessionId };
|
|
839
844
|
} catch (err) {
|
|
845
|
+
// A public seat's refusal is not a session-store failure, whatever its
|
|
846
|
+
// message happens to contain: it must reach the run loop, never the
|
|
847
|
+
// fresh-session retry below (Rhea on #2247).
|
|
848
|
+
if (err?.code === PUBLIC_MCP_UNAVAILABLE_CODE) throw err;
|
|
840
849
|
// Self-heal against a corrupted session store. If the persisted id is
|
|
841
850
|
// already in use (or claude has forgotten about it), discard it and
|
|
842
851
|
// restart the turn with a fresh UUID. Without this, a single bad
|
|
@@ -847,8 +856,7 @@ export default {
|
|
|
847
856
|
// as fresh too: otherwise a session-recovery path is the one fresh
|
|
848
857
|
// session that misses the durable-state cue.
|
|
849
858
|
const freshPrompt = buildPrompt(prompt, ctx.memoryLongTerm, { freshSession: true });
|
|
850
|
-
const retryBase = ['-p',
|
|
851
|
-
? `${freshPrompt}\n\n${PUBLIC_MCP_UNAVAILABLE_NOTICE}` : freshPrompt,
|
|
859
|
+
const retryBase = ['-p', freshPrompt,
|
|
852
860
|
'--output-format', 'text', '--session-id', freshId, ...modelArgs];
|
|
853
861
|
const retryCtx = {
|
|
854
862
|
...ctx,
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
import { CREDENTIAL_KEY, writeCredentialFile } from '../credential-file.js';
|
|
61
61
|
import { supportedGitHooks } from '../commit-attribution.js';
|
|
62
62
|
import { deliverSeatCredential, withholdRuntimeCredential } from '../mcp-credential-delivery.js';
|
|
63
|
-
import { prepareMcpSpawn,
|
|
63
|
+
import { prepareMcpSpawn, publicMcpUnavailableError, selectedMcpVersionDir } from '../mcp-home.js';
|
|
64
64
|
import { buildMemoryPreamble } from '../memory-bridge.js';
|
|
65
65
|
import { isLegacySandboxTrust, normalizeSandboxTrust } from '../environment.js';
|
|
66
66
|
import { adapterFailure, spawnCredentials } from '../upstream-refusal.js';
|
|
@@ -609,6 +609,7 @@ export default {
|
|
|
609
609
|
credentialFile: credential?.path || null,
|
|
610
610
|
publicSeat: sandbox?.trust === 'public',
|
|
611
611
|
});
|
|
612
|
+
if (mcp.unavailableMcp.length) throw publicMcpUnavailableError(mcp.unavailableMcp);
|
|
612
613
|
// A derived record stores `trust: 'public'` and no mode (the block is
|
|
613
614
|
// platform-independent; see cli/src/lib/default-environment.js). Codex's
|
|
614
615
|
// mode only selects read vs write access — its permission profiles run on
|
|
@@ -628,8 +629,7 @@ export default {
|
|
|
628
629
|
: null;
|
|
629
630
|
const args = buildArgs({
|
|
630
631
|
sessionId: ctx.sessionId || null,
|
|
631
|
-
prompt:
|
|
632
|
-
? `${fullPrompt}\n\n${PUBLIC_MCP_UNAVAILABLE_NOTICE}` : fullPrompt,
|
|
632
|
+
prompt: fullPrompt,
|
|
633
633
|
outputFile,
|
|
634
634
|
mcpFlags: mcp.flags,
|
|
635
635
|
mcpReadDirectories: mcp.mcpReadDirectories,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
} from 'path';
|
|
40
40
|
import { writeCredentialFile } from '../credential-file.js';
|
|
41
41
|
import { deliverSeatCredential, withholdRuntimeCredential } from '../mcp-credential-delivery.js';
|
|
42
|
-
import { prepareMcpSpawn,
|
|
42
|
+
import { prepareMcpSpawn, publicMcpUnavailableError, selectedMcpVersionDir } from '../mcp-home.js';
|
|
43
43
|
import { buildMemoryPreamble } from '../memory-bridge.js';
|
|
44
44
|
import {
|
|
45
45
|
isLegacySandboxTrust,
|
|
@@ -685,6 +685,7 @@ export default {
|
|
|
685
685
|
unavailableMcp,
|
|
686
686
|
mcpReadDirectories,
|
|
687
687
|
});
|
|
688
|
+
if (unavailableMcp.length) throw publicMcpUnavailableError(unavailableMcp);
|
|
688
689
|
const config = {
|
|
689
690
|
permission: isPublic
|
|
690
691
|
? publicPermissions(sandboxMode, Object.keys(mcp))
|
|
@@ -717,8 +718,7 @@ export default {
|
|
|
717
718
|
credentialFile: credential?.path || null,
|
|
718
719
|
});
|
|
719
720
|
const args = buildArgs({
|
|
720
|
-
prompt:
|
|
721
|
-
? `${fullPrompt}\n\n${PUBLIC_MCP_UNAVAILABLE_NOTICE}` : fullPrompt,
|
|
721
|
+
prompt: fullPrompt,
|
|
722
722
|
sessionId: ctx.sessionId,
|
|
723
723
|
cwd: ctx.cwd,
|
|
724
724
|
model: qualifiedProviderModel(provider, ctx.environment?.model),
|
package/src/lib/adapters/qwen.js
CHANGED
|
@@ -6,7 +6,7 @@ import { tmpdir } from 'os';
|
|
|
6
6
|
import { basename, dirname, isAbsolute, join } from 'path';
|
|
7
7
|
import { buildMemoryPreamble } from '../memory-bridge.js';
|
|
8
8
|
import { deliverSeatCredential } from '../mcp-credential-delivery.js';
|
|
9
|
-
import { prepareMcpSpawn,
|
|
9
|
+
import { prepareMcpSpawn, publicMcpUnavailableError, selectedMcpVersionDir } from '../mcp-home.js';
|
|
10
10
|
import { writeCredentialFile } from '../credential-file.js';
|
|
11
11
|
import { normalizeSandboxTrust, validateEnvironmentSpec } from '../environment.js';
|
|
12
12
|
import { resolvePublicSandboxMode } from '../sandbox/mode.js';
|
|
@@ -289,6 +289,7 @@ export default {
|
|
|
289
289
|
unavailableMcp,
|
|
290
290
|
mcpReadDirectories,
|
|
291
291
|
});
|
|
292
|
+
if (unavailableMcp.length) throw publicMcpUnavailableError(unavailableMcp);
|
|
292
293
|
await Promise.all([
|
|
293
294
|
writeFile(settingsPath, JSON.stringify({
|
|
294
295
|
privacy: { usageStatisticsEnabled: false },
|
|
@@ -307,8 +308,7 @@ export default {
|
|
|
307
308
|
'--mcp-config', mcpPath, '--exclude-tools', [
|
|
308
309
|
...EXCLUDED_TOOLS, ...(isPublic ? PUBLIC_READ_TOOLS : []),
|
|
309
310
|
].join(','),
|
|
310
|
-
'-o', 'stream-json', '-p',
|
|
311
|
-
? `${fullPrompt}\n\n${PUBLIC_MCP_UNAVAILABLE_NOTICE}` : fullPrompt,
|
|
311
|
+
'-o', 'stream-json', '-p', fullPrompt,
|
|
312
312
|
];
|
|
313
313
|
let cmd = executable;
|
|
314
314
|
let spawnArgs = args;
|
package/src/lib/mcp-home.js
CHANGED
|
@@ -52,7 +52,24 @@ import { MCP_PACKAGE, exactVersion, parseVersion } from './mcp-server-version.js
|
|
|
52
52
|
|
|
53
53
|
/** The env override, so tests (and an operator) can point the home elsewhere. */
|
|
54
54
|
export const MCP_HOME_ENV = 'COMMONLY_MCP_HOME';
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* TASK-273: a public seat whose MCP server has no host-prepared build does not
|
|
57
|
+
* run the turn. Spawning without its tools left the model nothing to do but
|
|
58
|
+
* narrate the failure, and the run loop posted that narration to a stranger
|
|
59
|
+
* (Commonly HQ, 2026-10-15: "The commonly MCP server failed to connect… check
|
|
60
|
+
* the MCP server config"). Refusing before the model call posts nothing: the
|
|
61
|
+
* turn fails, the event stays unacked and is retried once the warm finishes,
|
|
62
|
+
* and the seat log names the reason. Every adapter raises this one error.
|
|
63
|
+
*/
|
|
64
|
+
export const PUBLIC_MCP_UNAVAILABLE_CODE = 'public_mcp_unavailable';
|
|
65
|
+
export const publicMcpUnavailableError = (names) => {
|
|
66
|
+
const error = new Error(
|
|
67
|
+
`public seat refused this turn: MCP server ${names.join(', ')} has no host-prepared build yet, `
|
|
68
|
+
+ 'so the model was not run and nothing was posted',
|
|
69
|
+
);
|
|
70
|
+
error.code = PUBLIC_MCP_UNAVAILABLE_CODE;
|
|
71
|
+
return error;
|
|
72
|
+
};
|
|
56
73
|
|
|
57
74
|
export const WARM_LOCK_NAME = '.warm.lock';
|
|
58
75
|
export const REGISTRY_CACHE_NAME = '.registry.json';
|