@commonlyai/cli 0.1.325 → 0.1.326

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.325",
3
+ "version": "0.1.326",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -96,6 +96,7 @@ import {
96
96
  withDefaultSandbox,
97
97
  } from '../lib/default-environment.js';
98
98
  import { mergeGrantBrokers, withholdGrantBroker } from '../lib/grant-broker-guard.js';
99
+ import { withPublicSeatMcpFlag } from '../lib/public-seat-mcp-flag.js';
99
100
  import {
100
101
  OUTSIDER_GRANT_MCP_UNCONFINED, outsiderGrantMcpRefusal, seatIsConfined, unshippedMcpEntries,
101
102
  } from '../lib/outsider-grant-mcp.js';
@@ -3137,7 +3138,9 @@ export const performRun = ({
3137
3138
  commitAttributionEnv: commitAttribution?.sandboxEnv || null,
3138
3139
  memoryLongTerm,
3139
3140
  memoryWithheld,
3140
- environment: placement.environment,
3141
+ // A public seat's Commonly server writes nothing once Commonly is
3142
+ // unreachable in its process (lib/public-seat-mcp-flag.js).
3143
+ environment: publicSeat ? withPublicSeatMcpFlag(placement.environment) : placement.environment,
3141
3144
  // Only when set, so every other spawn context stays as it was.
3142
3145
  ...(hostUnconfined === true ? { hostUnconfined: true } : {}),
3143
3146
  ...(publicSeat && !memoryWithheld && opened.ownerWoken === true ? { ownerWoken: true } : {}),
@@ -189,7 +189,9 @@ export const extensionArgs = (servers, ctx) => {
189
189
  }
190
190
  const env = Object.entries(delivery.env).map(([name, value]) => {
191
191
  if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new Error('goose adapter: invalid MCP environment key');
192
- if (!['COMMONLY_TOKEN_FILE', 'COMMONLY_API_URL', 'COMMONLY_INSTANCE_URL'].includes(name)) {
192
+ // COMMONLY_MCP_PUBLIC_SEAT is the constant '1' (public-seat-mcp-flag.js),
193
+ // never a secret, so it may ride either path.
194
+ if (!['COMMONLY_TOKEN_FILE', 'COMMONLY_API_URL', 'COMMONLY_INSTANCE_URL', 'COMMONLY_MCP_PUBLIC_SEAT'].includes(name)) {
193
195
  throw new Error(`goose adapter: MCP server ${server.name} has ${name}, which cannot safely ride a CLI flag`);
194
196
  }
195
197
  const resolved = substitute(value, ctx);
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Tell a public seat's Commonly MCP server that it serves a public seat.
3
+ *
4
+ * The server then writes nothing once Commonly has been unreachable in that
5
+ * process (commonly-mcp/src/public-seat-gate.js), which closes the post a model
6
+ * makes through the tool before the CLI's own witness withholds the reply
7
+ * (public-tool-error.js, TASK-256). Only the shipped Commonly server is
8
+ * flagged. Every adapter carries a declared literal env key through to the
9
+ * server's process (`deliverSeatCredential` copies the declaration's env), so
10
+ * one copy here reaches all of them. A server that predates the gate ignores
11
+ * the key.
12
+ *
13
+ * Set at spawn, on a copy: the record and the guards (`auditDeclaredMcp`,
14
+ * `isShippedCommonlyMcpEntry`) still see the declaration as written.
15
+ */
16
+ import { isShippedCommonlyMcpCommand } from './declared-mcp-guard.js';
17
+ import { describeMcpCommand } from './mcp-server-version.js';
18
+
19
+ export const PUBLIC_SEAT_MCP_ENV = 'COMMONLY_MCP_PUBLIC_SEAT';
20
+
21
+ // The npx form, or a recorded local checkout of the same package (the form
22
+ // goose's public check and `auditDeclaredMcp` also admit).
23
+ const isCommonlyServer = (server, describe) => isShippedCommonlyMcpCommand(server?.command)
24
+ || Boolean(describe(server?.command)?.isCommonly);
25
+
26
+ export const withPublicSeatMcpFlag = (environment, { describe = describeMcpCommand } = {}) => {
27
+ const servers = Array.isArray(environment?.mcp) ? environment.mcp : null;
28
+ const flagged = servers ? servers.map((server) => isCommonlyServer(server, describe)) : [];
29
+ if (!flagged.some(Boolean)) return environment;
30
+ return {
31
+ ...environment,
32
+ mcp: servers.map((server, i) => (flagged[i]
33
+ ? { ...server, env: { ...(server.env || {}), [PUBLIC_SEAT_MCP_ENV]: '1' } }
34
+ : server)),
35
+ };
36
+ };