@geminixiang/mikan 1.0.0-beta.62 → 1.0.0-beta.63

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +13 -13
  3. package/dist/adapters/commands/sandbox.d.ts.map +1 -1
  4. package/dist/adapters/commands/sandbox.js +30 -53
  5. package/dist/adapters/commands/sandbox.js.map +1 -1
  6. package/dist/adapters/commands/types.d.ts +3 -3
  7. package/dist/adapters/commands/types.d.ts.map +1 -1
  8. package/dist/adapters/commands/types.js.map +1 -1
  9. package/dist/adapters/slack/bot.d.ts +8 -0
  10. package/dist/adapters/slack/bot.d.ts.map +1 -1
  11. package/dist/adapters/slack/bot.js +32 -2
  12. package/dist/adapters/slack/bot.js.map +1 -1
  13. package/dist/adapters/web/admin/portal.d.ts.map +1 -1
  14. package/dist/adapters/web/admin/portal.js +28 -121
  15. package/dist/adapters/web/admin/portal.js.map +1 -1
  16. package/dist/config.d.ts +13 -10
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/config.js +31 -50
  19. package/dist/config.js.map +1 -1
  20. package/dist/harness/execution-resolver.d.ts.map +1 -1
  21. package/dist/harness/execution-resolver.js +1 -1
  22. package/dist/harness/execution-resolver.js.map +1 -1
  23. package/dist/harness/prompt.d.ts.map +1 -1
  24. package/dist/harness/prompt.js +17 -21
  25. package/dist/harness/prompt.js.map +1 -1
  26. package/dist/harness/runner.d.ts.map +1 -1
  27. package/dist/harness/runner.js +2 -2
  28. package/dist/harness/runner.js.map +1 -1
  29. package/dist/office/projection.d.ts +19 -2
  30. package/dist/office/projection.d.ts.map +1 -1
  31. package/dist/office/projection.js +73 -98
  32. package/dist/office/projection.js.map +1 -1
  33. package/dist/office/types.d.ts +13 -8
  34. package/dist/office/types.d.ts.map +1 -1
  35. package/dist/office/types.js.map +1 -1
  36. package/dist/sandbox/index.d.ts +9 -1
  37. package/dist/sandbox/index.d.ts.map +1 -1
  38. package/dist/sandbox/index.js +16 -12
  39. package/dist/sandbox/index.js.map +1 -1
  40. package/dist/sandbox/provisioner.d.ts +8 -0
  41. package/dist/sandbox/provisioner.d.ts.map +1 -1
  42. package/dist/sandbox/provisioner.js +36 -0
  43. package/dist/sandbox/provisioner.js.map +1 -1
  44. package/dist/settings-mutation.d.ts +5 -29
  45. package/dist/settings-mutation.d.ts.map +1 -1
  46. package/dist/settings-mutation.js +7 -13
  47. package/dist/settings-mutation.js.map +1 -1
  48. package/dist/types.d.ts +5 -23
  49. package/dist/types.d.ts.map +1 -1
  50. package/dist/types.js.map +1 -1
  51. package/package.json +1 -1
package/dist/config.d.ts CHANGED
@@ -2,8 +2,8 @@ export declare class MissingGlobalSettingsError extends Error {
2
2
  readonly settingsPath: string;
3
3
  constructor(settingsPath: string);
4
4
  }
5
- export type { AgentConfig, SandboxSettings, WorkspacePolicyChoice } from "./types.js";
6
- import type { AgentConfig, WorkspacePolicyChoice } from "./types.js";
5
+ export type { AgentConfig, SandboxSettings } from "./types.js";
6
+ import type { AgentConfig } from "./types.js";
7
7
  import type { McpServerConfig } from "./harness/types.js";
8
8
  import type { OnboardLlmChoice } from "./types.js";
9
9
  import type { Office } from "./office/index.js";
@@ -65,13 +65,16 @@ export declare function loadScopeMcpServers(office: Office): {
65
65
  conversation: Record<string, McpServerConfig>;
66
66
  };
67
67
  /**
68
- * The conversation's own door-policy override (legacy `image.workspaceMount`
69
- * included), or null when the office follows the global default. Missing
70
- * `visibility` on a shared-support choice defaults to "public" downstream
71
- * (see resolveEffectiveWorkspace), preserving today's read-write behavior for
72
- * every office that predates this setting.
68
+ * The conversation's own visibility override, or null when it follows the
69
+ * platform. Only "private" can be stored: an operator may narrow a public
70
+ * channel, never widen a private one (see ADR 0008).
73
71
  */
74
- export declare function loadConversationWorkspaceOverride(office: Office): WorkspacePolicyChoice | null;
75
- export declare function setConversationWorkspacePolicy(office: Office, choice: WorkspacePolicyChoice | null): void;
76
- export declare function setGlobalWorkspacePolicy(choice: WorkspacePolicyChoice | null): void;
72
+ export declare function loadOfficeVisibilityOverride(office: Office): "private" | null;
73
+ export declare function setOfficeVisibilityOverride(office: Office, visibility: "private" | null): void;
74
+ /**
75
+ * Legacy door-policy override kept readable only so the observation period
76
+ * can report which offices still declare `full`; it no longer changes the
77
+ * projection (ADR 0008).
78
+ */
79
+ export declare function loadLegacyFullOverride(office: Office): boolean;
77
80
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAUA,qBAAa,0BAA2B,SAAQ,KAAK;aACvB,YAAY,EAAE,MAAM;IAAhD,YAA4B,YAAY,EAAE,MAAM,EAG/C;CACF;AAED,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,KAAK,EAAE,WAAW,EAAmB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAsOhD,wBAAgB,kBAAkB,IAAI,WAAW,CAEhD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA6B/D;AAiBD,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEzE;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAcpF;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAiBvE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GA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,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAE5F;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG;IACnD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC/C,CAKA;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAE7E;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAa9F;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAG9D"}
package/dist/config.js CHANGED
@@ -29,11 +29,8 @@ const ONBOARD_SETTINGS = {
29
29
  cpus: "2",
30
30
  memory: "4g",
31
31
  },
32
- // No pinned workspace door policy: with nothing set, the projection
33
- // follows the platform's own channel vocabulary (public channels share
34
- // workspace memory, private channels read it without writing, DMs stay
35
- // isolated — see workspace-projection platformDerivedWorkspace).
36
- // Deployments that predate this keep their explicit isolated setting.
32
+ // Office visibility is not a setting here: it follows the platform
33
+ // conversation type (see office/projection resolveOfficeVisibility).
37
34
  defaultSharedVault: "",
38
35
  },
39
36
  };
@@ -57,6 +54,14 @@ const SettingsFileSchema = Type.Object({
57
54
  slack: Type.Optional(Type.Object({
58
55
  replyMode: Type.Optional(Type.Union([Type.Literal("top-level"), Type.Literal("thread")])),
59
56
  })),
57
+ /**
58
+ * Conversation-only office policy. `visibility: "private"` marks a
59
+ * platform-public conversation as private; nothing can widen visibility
60
+ * beyond what the platform grants, so "public" is never stored here.
61
+ */
62
+ office: Type.Optional(Type.Object({
63
+ visibility: Type.Optional(Type.Literal("private")),
64
+ })),
60
65
  sandbox: Type.Optional(Type.Object({
61
66
  cpus: Type.Optional(Type.String()),
62
67
  memory: Type.Optional(Type.String()),
@@ -369,6 +374,7 @@ function compactSettingsConfig(config) {
369
374
  ...(hasDefinedValue(config.sentry) ? { sentry: config.sentry } : {}),
370
375
  ...(hasDefinedValue(config.sandbox) ? { sandbox: config.sandbox } : {}),
371
376
  ...(hasDefinedValue(config.slack) ? { slack: config.slack } : {}),
377
+ ...(hasDefinedValue(config.office) ? { office: config.office } : {}),
372
378
  // An empty map means "all servers removed".
373
379
  ...(config.mcpServers !== undefined ? { mcpServers: config.mcpServers } : {}),
374
380
  };
@@ -394,6 +400,9 @@ function patchSettingsConfig(existing, config) {
394
400
  ...existing.slack,
395
401
  ...config.slack,
396
402
  },
403
+ // Office visibility has its own writer (setOfficeVisibilityOverride); the
404
+ // generic patch must not drop it.
405
+ ...(existing.office !== undefined ? { office: existing.office } : {}),
397
406
  // The portal edits the full MCP map, and
398
407
  // a merge would make removing a server impossible.
399
408
  ...(config.mcpServers !== undefined ? { mcpServers: config.mcpServers } : {}),
@@ -437,55 +446,27 @@ export function loadScopeMcpServers(office) {
437
446
  };
438
447
  }
439
448
  /**
440
- * The conversation's own door-policy override (legacy `image.workspaceMount`
441
- * included), or null when the office follows the global default. Missing
442
- * `visibility` on a shared-support choice defaults to "public" downstream
443
- * (see resolveEffectiveWorkspace), preserving today's read-write behavior for
444
- * every office that predates this setting.
449
+ * The conversation's own visibility override, or null when it follows the
450
+ * platform. Only "private" can be stored: an operator may narrow a public
451
+ * channel, never widen a private one (see ADR 0008).
445
452
  */
446
- export function loadConversationWorkspaceOverride(office) {
447
- const file = loadSettingsFile(conversationSettingsPath(office));
448
- const sandbox = file?.sandbox;
449
- if (sandbox?.workspace?.doorPolicy === "isolated")
450
- return { doorPolicy: "isolated" };
451
- if (sandbox?.workspace?.doorPolicy === "trusted") {
452
- if (sandbox.workspace.layout === "full")
453
- return { doorPolicy: "trusted", layout: "full" };
454
- return {
455
- doorPolicy: "trusted",
456
- layout: "shared-support",
457
- ...(sandbox.workspace.visibility ? { visibility: sandbox.workspace.visibility } : {}),
458
- };
459
- }
460
- if (sandbox?.image?.workspaceMount === "full")
461
- return { doorPolicy: "trusted", layout: "full" };
462
- if (sandbox?.image?.workspaceMount === "private") {
463
- return { doorPolicy: "trusted", layout: "shared-support" };
464
- }
465
- return null;
453
+ export function loadOfficeVisibilityOverride(office) {
454
+ return loadSettingsFile(conversationSettingsPath(office))?.office?.visibility ?? null;
466
455
  }
467
- export function setConversationWorkspacePolicy(office, choice) {
468
- writeWorkspacePolicy(conversationSettingsPath(office), choice, {});
469
- }
470
- export function setGlobalWorkspacePolicy(choice) {
471
- writeWorkspacePolicy(getSettingsPath(), choice, ONBOARD_SETTINGS);
456
+ export function setOfficeVisibilityOverride(office, visibility) {
457
+ const settingsPath = conversationSettingsPath(office);
458
+ const existing = loadSettingsFileForUpdate(settingsPath, {});
459
+ const { office: _previous, ...rest } = existing;
460
+ ensureDirExists(dirname(settingsPath));
461
+ atomicWritePrivateFile(settingsPath, JSON.stringify(compactSettingsConfig({ ...rest, ...(visibility ? { office: { visibility } } : {}) }), null, 2));
472
462
  }
473
463
  /**
474
- * The generic settings patch merges leaves and cannot remove keys, so the
475
- * door-policy writer edits the file shape directly: it always drops the
476
- * legacy `image.workspaceMount` (the explicit choice replaces it) and either
477
- * sets or removes the `workspace` group.
464
+ * Legacy door-policy override kept readable only so the observation period
465
+ * can report which offices still declare `full`; it no longer changes the
466
+ * projection (ADR 0008).
478
467
  */
479
- function writeWorkspacePolicy(settingsPath, choice, defaultSettings) {
480
- const existing = loadSettingsFileForUpdate(settingsPath, defaultSettings);
481
- const { workspaceMount: _legacy, ...image } = existing.sandbox?.image ?? {};
482
- const { workspace: _previous, image: _image, ...sandboxRest } = existing.sandbox ?? {};
483
- const sandbox = {
484
- ...sandboxRest,
485
- ...(hasDefinedValue(image) ? { image } : {}),
486
- ...(choice ? { workspace: choice } : {}),
487
- };
488
- ensureDirExists(dirname(settingsPath));
489
- atomicWritePrivateFile(settingsPath, JSON.stringify(compactSettingsConfig({ ...existing, sandbox }), null, 2));
468
+ export function loadLegacyFullOverride(office) {
469
+ const sandbox = loadSettingsFile(conversationSettingsPath(office))?.sandbox;
470
+ return sandbox?.workspace?.layout === "full" || sandbox?.image?.workspaceMount === "full";
490
471
  }
491
472
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACnD,YAA4B,YAAoB;QAC9C,KAAK,CAAC,mCAAmC,YAAY,EAAE,CAAC,CAAC;4BAD/B,YAAY;QAEtC,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF;AAQD,MAAM,gBAAgB,GAAuB;IAC3C,GAAG,EAAE;QACH,QAAQ,EAAE,WAAW;QACrB,KAAK,EAAE,mBAAmB;QAC1B,aAAa,EAAE,KAAK;KACrB;IACD,KAAK,EAAE;QACL,SAAS,EAAE,WAAW;KACvB;IACD,OAAO,EAAE;QACP,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE;YACL,IAAI,EAAE,GAAG;YACT,MAAM,EA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BAAgB,CAAC,CAAC;AACpE,CAAC;AAED;;;;;GAKG;AACH,SAAS,oBAAoB,CAC3B,YAAoB,EACpB,MAAoC,EACpC,eAAmC;IAEnC,MAAM,QAAQ,GAAG,yBAAyB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IAC1E,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;IAC5E,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,GAAG,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;IACvF,MAAM,OAAO,GAAoB;QAC/B,GAAG,WAAW;QACd,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzC,CAAC;IACF,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IACvC,sBAAsB,CACpB,YAAY,EACZ,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CACzE,CAAC;AACJ,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport { Type, type Static } from \"@sinclair/typebox\";\nimport { existsSync, lstatSync, readFileSync, renameSync, rmSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { effectiveStateDir } from \"./cli/arg-grammar.js\";\nimport { readEnv } from \"./env-manifest.js\";\nimport { ensureDirExists, readJsonSchemaFileIfExists } from \"./file-guards.js\";\nimport { atomicWritePrivateFile } from \"./file-guards.js\";\nimport * as log from \"./log.js\";\n\nexport class MissingGlobalSettingsError extends Error {\n constructor(public readonly settingsPath: string) {\n super(`Missing global settings file at ${settingsPath}`);\n this.name = \"MissingGlobalSettingsError\";\n }\n}\n\nexport type { AgentConfig, SandboxSettings, WorkspacePolicyChoice } from \"./types.js\";\nimport type { AgentConfig, SandboxSettings, WorkspacePolicyChoice } from \"./types.js\";\nimport type { McpServerConfig } from \"./harness/types.js\";\nimport type { OnboardLlmChoice } from \"./types.js\";\nimport type { Office } from \"./office/index.js\";\n\nconst ONBOARD_SETTINGS: SettingsFileConfig = {\n llm: {\n provider: \"anthropic\",\n model: \"claude-sonnet-4-6\",\n thinkingLevel: \"off\",\n },\n slack: {\n replyMode: \"top-level\",\n },\n sandbox: {\n cpus: \"0.5\",\n memory: \"1g\",\n boost: {\n cpus: \"2\",\n memory: \"4g\",\n },\n // No pinned workspace door policy: with nothing set, the projection\n // follows the platform's own channel vocabulary (public channels share\n // workspace memory, private channels read it without writing, DMs stay\n // isolated — see workspace-projection platformDerivedWorkspace).\n // Deployments that predate this keep their explicit isolated setting.\n defaultSharedVault: \"\",\n },\n};\n\nconst SettingsFileSchema = Type.Object({\n llm: Type.Optional(\n Type.Object({\n provider: Type.Optional(Type.String()),\n model: Type.Optional(Type.String()),\n thinkingLevel: Type.Optional(\n Type.Union([\n Type.Literal(\"off\"),\n Type.Literal(\"minimal\"),\n Type.Literal(\"low\"),\n Type.Literal(\"medium\"),\n Type.Literal(\"high\"),\n Type.Literal(\"xhigh\"),\n Type.Literal(\"max\"),\n ]),\n ),\n }),\n ),\n sentry: Type.Optional(\n Type.Object({\n dsn: Type.Optional(Type.String()),\n }),\n ),\n slack: Type.Optional(\n Type.Object({\n replyMode: Type.Optional(Type.Union([Type.Literal(\"top-level\"), Type.Literal(\"thread\")])),\n }),\n ),\n sandbox: Type.Optional(\n Type.Object({\n cpus: Type.Optional(Type.String()),\n memory: Type.Optional(Type.String()),\n boost: Type.Optional(\n Type.Object({\n cpus: Type.Optional(Type.String()),\n memory: Type.Optional(Type.String()),\n }),\n ),\n image: Type.Optional(\n Type.Object({\n workspaceMount: Type.Optional(\n Type.Union([Type.Literal(\"private\"), Type.Literal(\"full\")]),\n ),\n }),\n ),\n workspace: Type.Optional(\n Type.Object({\n doorPolicy: Type.Optional(\n Type.Union([Type.Literal(\"isolated\"), Type.Literal(\"trusted\")]),\n ),\n layout: Type.Optional(\n Type.Union([\n Type.Literal(\"conversation\"),\n Type.Literal(\"shared-support\"),\n Type.Literal(\"full\"),\n ]),\n ),\n visibility: Type.Optional(Type.Union([Type.Literal(\"public\"), Type.Literal(\"private\")])),\n }),\n ),\n defaultSharedVault: Type.Optional(Type.String()),\n }),\n ),\n /**\n * MCP servers, keyed by name. Merged per key across scopes: a conversation\n * entry overrides (or, with `disabled: true`, turns off) the same-name\n * global entry; other global entries stay available. `open-connector` is an\n * ordinary entry that the host fills in from `OPENCONNECTOR_ENDPOINT` when\n * neither scope declares it (see `src/harness/open-connector.ts`).\n */\n mcpServers: Type.Optional(\n Type.Record(\n Type.String(),\n Type.Object({\n command: Type.Optional(Type.String()),\n args: Type.Optional(Type.Array(Type.String())),\n env: Type.Optional(Type.Record(Type.String(), Type.String())),\n url: Type.Optional(Type.String()),\n headers: Type.Optional(Type.Record(Type.String(), Type.String())),\n disabled: Type.Optional(Type.Boolean()),\n }),\n ),\n ),\n});\n\ntype SettingsFileConfig = Static<typeof SettingsFileSchema>;\n\nfunction loadSettingsFile(settingsPath: string): SettingsFileConfig | undefined {\n return readJsonSchemaFileIfExists(settingsPath, SettingsFileSchema, (detail) =>\n detail === \"unexpected JSON shape\"\n ? `Malformed settings file at ${settingsPath}: expected a JSON object at the top level`\n : `Malformed settings file at ${settingsPath}: ${detail}`,\n );\n}\n\nfunction normalizeSettingsConfig(config: SettingsFileConfig): Partial<AgentConfig> {\n return {\n ...(config.llm?.provider !== undefined ? { provider: config.llm.provider } : {}),\n ...(config.llm?.model !== undefined ? { model: config.llm.model } : {}),\n ...(config.llm?.thinkingLevel !== undefined ? { thinkingLevel: config.llm.thinkingLevel } : {}),\n ...(config.sentry?.dsn !== undefined ? { sentryDsn: config.sentry.dsn } : {}),\n ...(config.sandbox !== undefined ? { sandbox: normalizeSandboxSettings(config.sandbox) } : {}),\n ...(config.slack !== undefined ? { slack: config.slack } : {}),\n ...(config.mcpServers !== undefined ? { mcpServers: config.mcpServers } : {}),\n };\n}\n\n/**\n * File shape → in-memory shape for the sandbox group. An empty or\n * whitespace-only `defaultSharedVault` means \"no default\" and is dropped;\n * non-empty values are trimmed. Everything else passes through as-is.\n */\nfunction normalizeSandboxSettings(sandbox: SandboxSettings): SandboxSettings {\n const defaultSharedVault = sandbox.defaultSharedVault?.trim();\n const legacyWorkspace =\n sandbox.image?.workspaceMount === \"private\"\n ? { doorPolicy: \"trusted\" as const, layout: \"shared-support\" as const }\n : sandbox.image?.workspaceMount === \"full\"\n ? { doorPolicy: \"trusted\" as const, layout: \"full\" as const }\n : undefined;\n const workspace = legacyWorkspace\n ? { ...legacyWorkspace, ...sandbox.workspace }\n : sandbox.workspace;\n return {\n ...(sandbox.cpus !== undefined ? { cpus: sandbox.cpus } : {}),\n ...(sandbox.memory !== undefined ? { memory: sandbox.memory } : {}),\n ...(sandbox.boost !== undefined ? { boost: sandbox.boost } : {}),\n ...(sandbox.image !== undefined ? { image: sandbox.image } : {}),\n ...(workspace !== undefined ? { workspace } : {}),\n ...(defaultSharedVault ? { defaultSharedVault } : {}),\n };\n}\n\n/**\n * Merge two sandbox settings groups. The merge invariant is LEAF-LEVEL:\n * an override that only sets `sandbox.memory` keeps the base `sandbox.cpus`,\n * and an override that only sets `boost.memory` keeps the base `boost.cpus`\n * (same for `image`). This mirrors how the fields merged when they were\n * flat top-level keys; a group-level spread would silently drop base leaves.\n */\nfunction mergeSandboxSettings(\n base: SandboxSettings | undefined,\n override: SandboxSettings | undefined,\n): SandboxSettings | undefined {\n if (!base) return override;\n if (!override) return base;\n return {\n ...base,\n ...override,\n ...(base.boost || override.boost ? { boost: { ...base.boost, ...override.boost } } : {}),\n ...(base.image || override.image ? { image: { ...base.image, ...override.image } } : {}),\n ...(base.workspace || override.workspace\n ? { workspace: { ...base.workspace, ...override.workspace } }\n : {}),\n };\n}\n\nfunction getSettingsPath(): string {\n return join(effectiveStateDir(), \"settings.json\");\n}\n\nfunction requireGlobalSettings(): SettingsFileConfig {\n const settingsPath = getSettingsPath();\n const config = loadSettingsFile(settingsPath);\n if (!config) {\n throw new MissingGlobalSettingsError(settingsPath);\n }\n return config;\n}\n\nfunction requireString(value: string | undefined, path: string): string {\n if (!value) {\n throw new Error(\n `Missing required global setting: ${path}. Run \\`mikan --onboard\\` to create settings.json.`,\n );\n }\n return value;\n}\n\nfunction toAgentConfig(fromFile: Partial<AgentConfig>): AgentConfig {\n const provider = requireString(fromFile.provider, \"llm.provider\");\n const model = requireString(fromFile.model, \"llm.model\");\n const thinkingLevel = requireString(fromFile.thinkingLevel, \"llm.thinkingLevel\") as ThinkingLevel;\n const sentryDsn = sentryDsnFrom(fromFile.sentryDsn);\n const sandbox = fromFile.sandbox;\n const slack = fromFile.slack;\n const mcpServers = fromFile.mcpServers;\n\n return {\n provider,\n model,\n thinkingLevel,\n sentryDsn,\n sandbox,\n slack,\n mcpServers,\n };\n}\n\nfunction loadRawGlobalSettings(): Partial<AgentConfig> {\n return normalizeSettingsConfig(requireGlobalSettings());\n}\n\nexport function loadGlobalSettings(): AgentConfig {\n return toAgentConfig(loadRawGlobalSettings());\n}\n\n/**\n * Host-authoritative location of a conversation's settings file:\n * `<office state dir>/settings.json`. The Office value names both the\n * state-dir key and the legacy pre-host-migration location (its workspace\n * dir) — the key is never inferred from a directory basename.\n *\n * Conversation settings used to live at `<conversationDir>/settings.json`,\n * but conversation dirs are bind-mounted read-write into sandbox containers\n * in image mode — code inside the sandbox could edit its own settings.json\n * and flip `sandbox.image.workspaceMount` to \"full\", remounting the entire\n * workspace into its container (cross-conversation access). Settings are an\n * administrator surface, so they live under the host-only state dir.\n *\n * Migration: on first access per conversation, a legacy\n * `<conversationDir>/settings.json` is moved here. The new file's existence\n * (an empty `{}` is written when there is nothing to migrate) is the\n * migration marker — a legacy file (re)appearing later, e.g. planted from\n * inside the sandbox, is never read again.\n */\nexport function conversationSettingsPath(office: Office): string {\n const hostPath = join(office.stateDir, \"settings.json\");\n if (existsSync(hostPath)) {\n assertSettingsFile(hostPath, \"Host conversation settings\");\n return hostPath;\n }\n\n ensureDirExists(dirname(hostPath));\n const legacyPath = join(office.dir, \"settings.json\");\n let content = \"{}\\n\";\n let migrated = false;\n if (existsSync(legacyPath)) {\n assertSettingsFile(legacyPath, \"Legacy conversation settings\");\n content = readFileSync(legacyPath, \"utf-8\");\n // Validate before moving the file. A malformed legacy file must fail\n // closed and remain available for an operator to repair.\n loadSettingsFile(legacyPath);\n migrated = true;\n }\n atomicWritePrivateFile(hostPath, content);\n if (migrated) {\n try {\n rmSync(legacyPath);\n } catch (err) {\n log.logWarning(`Could not remove legacy conversation settings: ${legacyPath}`, String(err));\n }\n log.logInfo(`Migrated conversation settings to host-only path: ${hostPath}`);\n }\n return hostPath;\n}\n\nfunction assertSettingsFile(path: string, label: string): void {\n let stats;\n try {\n stats = lstatSync(path);\n } catch (err) {\n throw new Error(`${label} cannot be inspected: ${path}`, { cause: err });\n }\n if (stats.isSymbolicLink() || !stats.isFile()) {\n throw new Error(`${label} must be a regular non-symlink file: ${path}`);\n }\n}\n\nconst AUTO_REPLY_FILE = \"auto-reply\";\nconst AUTO_REPLY_DISABLED_FILE = \"auto-reply.disabled\";\n\nexport function slackConversationAutoReplyEnabled(office: Office): boolean {\n return existsSync(join(office.dir, AUTO_REPLY_FILE));\n}\n\nexport function setSlackConversationAutoReply(office: Office, enabled: boolean): void {\n ensureDirExists(office.dir);\n const enabledPath = join(office.dir, AUTO_REPLY_FILE);\n const disabledPath = join(office.dir, AUTO_REPLY_DISABLED_FILE);\n const targetPath = enabled ? enabledPath : disabledPath;\n const otherPath = enabled ? disabledPath : enabledPath;\n\n if (existsSync(otherPath)) {\n renameSync(otherPath, targetPath);\n return;\n }\n if (enabled && !existsSync(targetPath)) {\n atomicWritePrivateFile(targetPath, \"\");\n }\n}\n\nexport function resolveConversationSettings(office: Office): AgentConfig {\n const globalConfig = loadRawGlobalSettings();\n const conversationConfig = normalizeSettingsConfig(\n loadSettingsFile(conversationSettingsPath(office)) ?? {},\n );\n // MCP servers merge per key: a conversation redefines or disables individual\n // servers without losing the rest of the global set.\n const mcpServers = { ...globalConfig.mcpServers, ...conversationConfig.mcpServers };\n // The sandbox group merges at the leaf level (see mergeSandboxSettings):\n // a conversation that only sets sandbox.memory keeps the global sandbox.cpus.\n const sandbox = mergeSandboxSettings(globalConfig.sandbox, conversationConfig.sandbox);\n return toAgentConfig({\n ...globalConfig,\n ...conversationConfig,\n ...(sandbox ? { sandbox } : {}),\n ...(Object.keys(mcpServers).length > 0 ? { mcpServers } : {}),\n });\n}\n\n/**\n * True when `child` is `parent` or a path inside it. Purely lexical (no\n * symlink resolution) — used for configuration sanity checks, not as the\n * final security boundary.\n */\nexport function isPathInside(child: string, parent: string): boolean {\n const parentPath = resolve(parent);\n const childPath = resolve(child);\n return childPath === parentPath || childPath.startsWith(parentPath + \"/\");\n}\n\n/**\n * The state dir (settings, office records, vaults) must never live inside\n * the working dir: conversation opt-in \"full\" mode mounts the entire working\n * dir read-write into sandbox containers, which would expose host-authoritative\n * state and credentials. Fatal under sandboxed modes; host mode has no mounts,\n * so only warn about the bad hygiene.\n */\nexport function assertStateDirOutsideWorkspace(\n stateDir: string,\n workingDir: string,\n sandboxType: string,\n): void {\n if (!isPathInside(stateDir, workingDir)) return;\n const message =\n `--state-dir (${stateDir}) must not be inside the working directory (${workingDir}): ` +\n `sandbox containers mount the working directory, and a mounted state dir ` +\n `would expose settings, office records, vaults, and credentials to sandboxed code.`;\n if (sandboxType === \"host\") {\n log.logWarning(\"Insecure state dir location\", message);\n return;\n }\n throw new Error(message);\n}\n\n/** Settings-file DSN wins over SENTRY_DSN env — the rule lives only here. */\nfunction sentryDsnFrom(fromFile: string | undefined): string | undefined {\n return fromFile || readEnv(\"SENTRY_DSN\");\n}\n\nexport function resolveSentryDsn(): string | undefined {\n const fromFile = normalizeSettingsConfig(loadSettingsFile(getSettingsPath()) ?? {});\n return sentryDsnFrom(fromFile.sentryDsn);\n}\n\nexport function createGlobalSettingsFile(stateDir: string, llm?: OnboardLlmChoice): string {\n const settingsPath = join(stateDir, \"settings.json\");\n if (existsSync(settingsPath)) {\n throw new Error(`Global settings already exists at ${settingsPath}`);\n }\n ensureDirExists(stateDir);\n const settings: SettingsFileConfig = llm\n ? {\n ...ONBOARD_SETTINGS,\n llm: {\n ...ONBOARD_SETTINGS.llm,\n provider: llm.provider,\n model: llm.model,\n },\n }\n : ONBOARD_SETTINGS;\n atomicWritePrivateFile(settingsPath, JSON.stringify(settings, null, 2));\n return settingsPath;\n}\n\n/**\n * Externally-visible base URL of the link/OAuth server, e.g.\n * `https://mikan.example.com` (no trailing slash). Read from `LINK_URL` or\n * `MIKAN_LINK_URL`, the same env var the bot uses to build credential onboarding links.\n */\nexport function resolveLinkBaseUrl(): string | undefined {\n const raw = readEnv(\"LINK_URL\");\n if (!raw) return undefined;\n return raw.replace(/\\/+$/, \"\");\n}\n\nfunction hasDefinedValue(values: Record<string, unknown> | undefined): boolean {\n return values !== undefined && Object.values(values).some((value) => value !== undefined);\n}\n\nfunction compactSettingsConfig(config: SettingsFileConfig): SettingsFileConfig {\n return {\n ...(hasDefinedValue(config.llm) ? { llm: config.llm } : {}),\n ...(hasDefinedValue(config.sentry) ? { sentry: config.sentry } : {}),\n ...(hasDefinedValue(config.sandbox) ? { sandbox: config.sandbox } : {}),\n ...(hasDefinedValue(config.slack) ? { slack: config.slack } : {}),\n // An empty map means \"all servers removed\".\n ...(config.mcpServers !== undefined ? { mcpServers: config.mcpServers } : {}),\n };\n}\n\nfunction patchSettingsConfig(\n existing: SettingsFileConfig,\n config: Partial<AgentConfig>,\n): SettingsFileConfig {\n const patched: SettingsFileConfig = {\n ...existing,\n llm: {\n ...existing.llm,\n ...(config.provider !== undefined ? { provider: config.provider } : {}),\n ...(config.model !== undefined ? { model: config.model } : {}),\n ...(config.thinkingLevel !== undefined ? { thinkingLevel: config.thinkingLevel } : {}),\n },\n sentry: {\n ...existing.sentry,\n ...(config.sentryDsn !== undefined ? { dsn: config.sentryDsn } : {}),\n },\n // Leaf-level merge: a patch that only sets sandbox.boost.memory keeps the\n // existing boost.cpus (and every other existing leaf). compactSettingsConfig\n // drops the group entirely when it ends up with no defined values.\n sandbox: mergeSandboxSettings(existing.sandbox, config.sandbox) ?? {},\n slack: {\n ...existing.slack,\n ...config.slack,\n },\n // The portal edits the full MCP map, and\n // a merge would make removing a server impossible.\n ...(config.mcpServers !== undefined ? { mcpServers: config.mcpServers } : {}),\n };\n return compactSettingsConfig(patched);\n}\n\nfunction loadSettingsFileForUpdate(\n settingsPath: string,\n defaultSettings: SettingsFileConfig,\n): SettingsFileConfig {\n if (!existsSync(settingsPath)) return defaultSettings;\n try {\n return loadSettingsFile(settingsPath) ?? {};\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err);\n const message = detail.startsWith(\"Malformed settings file\")\n ? detail.replace(\"Malformed settings file\", \"Refusing to overwrite malformed settings file\")\n : detail;\n throw new Error(message, { cause: err });\n }\n}\n\nfunction updateSettingsFile(\n settingsPath: string,\n patch: Partial<AgentConfig>,\n defaultSettings: SettingsFileConfig,\n): void {\n const existing = loadSettingsFileForUpdate(settingsPath, defaultSettings);\n ensureDirExists(dirname(settingsPath));\n atomicWritePrivateFile(\n settingsPath,\n JSON.stringify(patchSettingsConfig(existing, patch), null, 2),\n );\n}\n\nexport function updateGlobalSettings(patch: Partial<AgentConfig>): void {\n updateSettingsFile(getSettingsPath(), patch, ONBOARD_SETTINGS);\n}\n\nexport function updateConversationSettings(office: Office, patch: Partial<AgentConfig>): void {\n updateSettingsFile(conversationSettingsPath(office), patch, {});\n}\n\n/**\n * The two scope-level MCP server maps, unmerged: the portal edits each scope's\n * own file, so it needs the raw per-scope values, not the effective merge\n * (`resolveConversationSettings` owns that).\n */\nexport function loadScopeMcpServers(office: Office): {\n global: Record<string, McpServerConfig>;\n conversation: Record<string, McpServerConfig>;\n} {\n return {\n global: loadRawGlobalSettings().mcpServers ?? {},\n conversation: loadSettingsFile(conversationSettingsPath(office))?.mcpServers ?? {},\n };\n}\n\n/**\n * The conversation's own door-policy override (legacy `image.workspaceMount`\n * included), or null when the office follows the global default. Missing\n * `visibility` on a shared-support choice defaults to \"public\" downstream\n * (see resolveEffectiveWorkspace), preserving today's read-write behavior for\n * every office that predates this setting.\n */\nexport function loadConversationWorkspaceOverride(office: Office): WorkspacePolicyChoice | null {\n const file = loadSettingsFile(conversationSettingsPath(office));\n const sandbox = file?.sandbox;\n if (sandbox?.workspace?.doorPolicy === \"isolated\") return { doorPolicy: \"isolated\" };\n if (sandbox?.workspace?.doorPolicy === \"trusted\") {\n if (sandbox.workspace.layout === \"full\") return { doorPolicy: \"trusted\", layout: \"full\" };\n return {\n doorPolicy: \"trusted\",\n layout: \"shared-support\",\n ...(sandbox.workspace.visibility ? { visibility: sandbox.workspace.visibility } : {}),\n };\n }\n if (sandbox?.image?.workspaceMount === \"full\") return { doorPolicy: \"trusted\", layout: \"full\" };\n if (sandbox?.image?.workspaceMount === \"private\") {\n return { doorPolicy: \"trusted\", layout: \"shared-support\" };\n }\n return null;\n}\n\nexport function setConversationWorkspacePolicy(\n office: Office,\n choice: WorkspacePolicyChoice | null,\n): void {\n writeWorkspacePolicy(conversationSettingsPath(office), choice, {});\n}\n\nexport function setGlobalWorkspacePolicy(choice: WorkspacePolicyChoice | null): void {\n writeWorkspacePolicy(getSettingsPath(), choice, ONBOARD_SETTINGS);\n}\n\n/**\n * The generic settings patch merges leaves and cannot remove keys, so the\n * door-policy writer edits the file shape directly: it always drops the\n * legacy `image.workspaceMount` (the explicit choice replaces it) and either\n * sets or removes the `workspace` group.\n */\nfunction writeWorkspacePolicy(\n settingsPath: string,\n choice: WorkspacePolicyChoice | null,\n defaultSettings: SettingsFileConfig,\n): void {\n const existing = loadSettingsFileForUpdate(settingsPath, defaultSettings);\n const { workspaceMount: _legacy, ...image } = existing.sandbox?.image ?? {};\n const { workspace: _previous, image: _image, ...sandboxRest } = existing.sandbox ?? {};\n const sandbox: SandboxSettings = {\n ...sandboxRest,\n ...(hasDefinedValue(image) ? { image } : {}),\n ...(choice ? { workspace: choice } : {}),\n };\n ensureDirExists(dirname(settingsPath));\n atomicWritePrivateFile(\n settingsPath,\n JSON.stringify(compactSettingsConfig({ ...existing, sandbox }), null, 2),\n );\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACnD,YAA4B,YAAoB;QAC9C,KAAK,CAAC,mCAAmC,YAAY,EAAE,CAAC,CAAC;4BAD/B,YAAY;QAEtC,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF;AAQD,MAAM,gBAAgB,GAAuB;IAC3C,GAAG,EAAE;QACH,QAAQ,EAAE,WAAW;QACrB,KAAK,EAAE,mBAAmB;QAC1B,aAA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AE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACrF,IAAI,EACJ,CAAC,CACF,CACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,MAAM,OAAO,GAAG,gBAAgB,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;IAC5E,OAAO,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,IAAI,OAAO,EAAE,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;AAC5F,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport { Type, type Static } from \"@sinclair/typebox\";\nimport { existsSync, lstatSync, readFileSync, renameSync, rmSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { effectiveStateDir } from \"./cli/arg-grammar.js\";\nimport { readEnv } from \"./env-manifest.js\";\nimport { ensureDirExists, readJsonSchemaFileIfExists } from \"./file-guards.js\";\nimport { atomicWritePrivateFile } from \"./file-guards.js\";\nimport * as log from \"./log.js\";\n\nexport class MissingGlobalSettingsError extends Error {\n constructor(public readonly settingsPath: string) {\n super(`Missing global settings file at ${settingsPath}`);\n this.name = \"MissingGlobalSettingsError\";\n }\n}\n\nexport type { AgentConfig, SandboxSettings } from \"./types.js\";\nimport type { AgentConfig, SandboxSettings } from \"./types.js\";\nimport type { McpServerConfig } from \"./harness/types.js\";\nimport type { OnboardLlmChoice } from \"./types.js\";\nimport type { Office } from \"./office/index.js\";\n\nconst ONBOARD_SETTINGS: SettingsFileConfig = {\n llm: {\n provider: \"anthropic\",\n model: \"claude-sonnet-4-6\",\n thinkingLevel: \"off\",\n },\n slack: {\n replyMode: \"top-level\",\n },\n sandbox: {\n cpus: \"0.5\",\n memory: \"1g\",\n boost: {\n cpus: \"2\",\n memory: \"4g\",\n },\n // Office visibility is not a setting here: it follows the platform\n // conversation type (see office/projection resolveOfficeVisibility).\n defaultSharedVault: \"\",\n },\n};\n\nconst SettingsFileSchema = Type.Object({\n llm: Type.Optional(\n Type.Object({\n provider: Type.Optional(Type.String()),\n model: Type.Optional(Type.String()),\n thinkingLevel: Type.Optional(\n Type.Union([\n Type.Literal(\"off\"),\n Type.Literal(\"minimal\"),\n Type.Literal(\"low\"),\n Type.Literal(\"medium\"),\n Type.Literal(\"high\"),\n Type.Literal(\"xhigh\"),\n Type.Literal(\"max\"),\n ]),\n ),\n }),\n ),\n sentry: Type.Optional(\n Type.Object({\n dsn: Type.Optional(Type.String()),\n }),\n ),\n slack: Type.Optional(\n Type.Object({\n replyMode: Type.Optional(Type.Union([Type.Literal(\"top-level\"), Type.Literal(\"thread\")])),\n }),\n ),\n /**\n * Conversation-only office policy. `visibility: \"private\"` marks a\n * platform-public conversation as private; nothing can widen visibility\n * beyond what the platform grants, so \"public\" is never stored here.\n */\n office: Type.Optional(\n Type.Object({\n visibility: Type.Optional(Type.Literal(\"private\")),\n }),\n ),\n sandbox: Type.Optional(\n Type.Object({\n cpus: Type.Optional(Type.String()),\n memory: Type.Optional(Type.String()),\n boost: Type.Optional(\n Type.Object({\n cpus: Type.Optional(Type.String()),\n memory: Type.Optional(Type.String()),\n }),\n ),\n image: Type.Optional(\n Type.Object({\n workspaceMount: Type.Optional(\n Type.Union([Type.Literal(\"private\"), Type.Literal(\"full\")]),\n ),\n }),\n ),\n workspace: Type.Optional(\n Type.Object({\n doorPolicy: Type.Optional(\n Type.Union([Type.Literal(\"isolated\"), Type.Literal(\"trusted\")]),\n ),\n layout: Type.Optional(\n Type.Union([\n Type.Literal(\"conversation\"),\n Type.Literal(\"shared-support\"),\n Type.Literal(\"full\"),\n ]),\n ),\n visibility: Type.Optional(Type.Union([Type.Literal(\"public\"), Type.Literal(\"private\")])),\n }),\n ),\n defaultSharedVault: Type.Optional(Type.String()),\n }),\n ),\n /**\n * MCP servers, keyed by name. Merged per key across scopes: a conversation\n * entry overrides (or, with `disabled: true`, turns off) the same-name\n * global entry; other global entries stay available. `open-connector` is an\n * ordinary entry that the host fills in from `OPENCONNECTOR_ENDPOINT` when\n * neither scope declares it (see `src/harness/open-connector.ts`).\n */\n mcpServers: Type.Optional(\n Type.Record(\n Type.String(),\n Type.Object({\n command: Type.Optional(Type.String()),\n args: Type.Optional(Type.Array(Type.String())),\n env: Type.Optional(Type.Record(Type.String(), Type.String())),\n url: Type.Optional(Type.String()),\n headers: Type.Optional(Type.Record(Type.String(), Type.String())),\n disabled: Type.Optional(Type.Boolean()),\n }),\n ),\n ),\n});\n\ntype SettingsFileConfig = Static<typeof SettingsFileSchema>;\n\nfunction loadSettingsFile(settingsPath: string): SettingsFileConfig | undefined {\n return readJsonSchemaFileIfExists(settingsPath, SettingsFileSchema, (detail) =>\n detail === \"unexpected JSON shape\"\n ? `Malformed settings file at ${settingsPath}: expected a JSON object at the top level`\n : `Malformed settings file at ${settingsPath}: ${detail}`,\n );\n}\n\nfunction normalizeSettingsConfig(config: SettingsFileConfig): Partial<AgentConfig> {\n return {\n ...(config.llm?.provider !== undefined ? { provider: config.llm.provider } : {}),\n ...(config.llm?.model !== undefined ? { model: config.llm.model } : {}),\n ...(config.llm?.thinkingLevel !== undefined ? { thinkingLevel: config.llm.thinkingLevel } : {}),\n ...(config.sentry?.dsn !== undefined ? { sentryDsn: config.sentry.dsn } : {}),\n ...(config.sandbox !== undefined ? { sandbox: normalizeSandboxSettings(config.sandbox) } : {}),\n ...(config.slack !== undefined ? { slack: config.slack } : {}),\n ...(config.mcpServers !== undefined ? { mcpServers: config.mcpServers } : {}),\n };\n}\n\n/**\n * File shape → in-memory shape for the sandbox group. An empty or\n * whitespace-only `defaultSharedVault` means \"no default\" and is dropped;\n * non-empty values are trimmed. Everything else passes through as-is.\n */\nfunction normalizeSandboxSettings(sandbox: SandboxSettings): SandboxSettings {\n const defaultSharedVault = sandbox.defaultSharedVault?.trim();\n const legacyWorkspace =\n sandbox.image?.workspaceMount === \"private\"\n ? { doorPolicy: \"trusted\" as const, layout: \"shared-support\" as const }\n : sandbox.image?.workspaceMount === \"full\"\n ? { doorPolicy: \"trusted\" as const, layout: \"full\" as const }\n : undefined;\n const workspace = legacyWorkspace\n ? { ...legacyWorkspace, ...sandbox.workspace }\n : sandbox.workspace;\n return {\n ...(sandbox.cpus !== undefined ? { cpus: sandbox.cpus } : {}),\n ...(sandbox.memory !== undefined ? { memory: sandbox.memory } : {}),\n ...(sandbox.boost !== undefined ? { boost: sandbox.boost } : {}),\n ...(sandbox.image !== undefined ? { image: sandbox.image } : {}),\n ...(workspace !== undefined ? { workspace } : {}),\n ...(defaultSharedVault ? { defaultSharedVault } : {}),\n };\n}\n\n/**\n * Merge two sandbox settings groups. The merge invariant is LEAF-LEVEL:\n * an override that only sets `sandbox.memory` keeps the base `sandbox.cpus`,\n * and an override that only sets `boost.memory` keeps the base `boost.cpus`\n * (same for `image`). This mirrors how the fields merged when they were\n * flat top-level keys; a group-level spread would silently drop base leaves.\n */\nfunction mergeSandboxSettings(\n base: SandboxSettings | undefined,\n override: SandboxSettings | undefined,\n): SandboxSettings | undefined {\n if (!base) return override;\n if (!override) return base;\n return {\n ...base,\n ...override,\n ...(base.boost || override.boost ? { boost: { ...base.boost, ...override.boost } } : {}),\n ...(base.image || override.image ? { image: { ...base.image, ...override.image } } : {}),\n ...(base.workspace || override.workspace\n ? { workspace: { ...base.workspace, ...override.workspace } }\n : {}),\n };\n}\n\nfunction getSettingsPath(): string {\n return join(effectiveStateDir(), \"settings.json\");\n}\n\nfunction requireGlobalSettings(): SettingsFileConfig {\n const settingsPath = getSettingsPath();\n const config = loadSettingsFile(settingsPath);\n if (!config) {\n throw new MissingGlobalSettingsError(settingsPath);\n }\n return config;\n}\n\nfunction requireString(value: string | undefined, path: string): string {\n if (!value) {\n throw new Error(\n `Missing required global setting: ${path}. Run \\`mikan --onboard\\` to create settings.json.`,\n );\n }\n return value;\n}\n\nfunction toAgentConfig(fromFile: Partial<AgentConfig>): AgentConfig {\n const provider = requireString(fromFile.provider, \"llm.provider\");\n const model = requireString(fromFile.model, \"llm.model\");\n const thinkingLevel = requireString(fromFile.thinkingLevel, \"llm.thinkingLevel\") as ThinkingLevel;\n const sentryDsn = sentryDsnFrom(fromFile.sentryDsn);\n const sandbox = fromFile.sandbox;\n const slack = fromFile.slack;\n const mcpServers = fromFile.mcpServers;\n\n return {\n provider,\n model,\n thinkingLevel,\n sentryDsn,\n sandbox,\n slack,\n mcpServers,\n };\n}\n\nfunction loadRawGlobalSettings(): Partial<AgentConfig> {\n return normalizeSettingsConfig(requireGlobalSettings());\n}\n\nexport function loadGlobalSettings(): AgentConfig {\n return toAgentConfig(loadRawGlobalSettings());\n}\n\n/**\n * Host-authoritative location of a conversation's settings file:\n * `<office state dir>/settings.json`. The Office value names both the\n * state-dir key and the legacy pre-host-migration location (its workspace\n * dir) — the key is never inferred from a directory basename.\n *\n * Conversation settings used to live at `<conversationDir>/settings.json`,\n * but conversation dirs are bind-mounted read-write into sandbox containers\n * in image mode — code inside the sandbox could edit its own settings.json\n * and flip `sandbox.image.workspaceMount` to \"full\", remounting the entire\n * workspace into its container (cross-conversation access). Settings are an\n * administrator surface, so they live under the host-only state dir.\n *\n * Migration: on first access per conversation, a legacy\n * `<conversationDir>/settings.json` is moved here. The new file's existence\n * (an empty `{}` is written when there is nothing to migrate) is the\n * migration marker — a legacy file (re)appearing later, e.g. planted from\n * inside the sandbox, is never read again.\n */\nexport function conversationSettingsPath(office: Office): string {\n const hostPath = join(office.stateDir, \"settings.json\");\n if (existsSync(hostPath)) {\n assertSettingsFile(hostPath, \"Host conversation settings\");\n return hostPath;\n }\n\n ensureDirExists(dirname(hostPath));\n const legacyPath = join(office.dir, \"settings.json\");\n let content = \"{}\\n\";\n let migrated = false;\n if (existsSync(legacyPath)) {\n assertSettingsFile(legacyPath, \"Legacy conversation settings\");\n content = readFileSync(legacyPath, \"utf-8\");\n // Validate before moving the file. A malformed legacy file must fail\n // closed and remain available for an operator to repair.\n loadSettingsFile(legacyPath);\n migrated = true;\n }\n atomicWritePrivateFile(hostPath, content);\n if (migrated) {\n try {\n rmSync(legacyPath);\n } catch (err) {\n log.logWarning(`Could not remove legacy conversation settings: ${legacyPath}`, String(err));\n }\n log.logInfo(`Migrated conversation settings to host-only path: ${hostPath}`);\n }\n return hostPath;\n}\n\nfunction assertSettingsFile(path: string, label: string): void {\n let stats;\n try {\n stats = lstatSync(path);\n } catch (err) {\n throw new Error(`${label} cannot be inspected: ${path}`, { cause: err });\n }\n if (stats.isSymbolicLink() || !stats.isFile()) {\n throw new Error(`${label} must be a regular non-symlink file: ${path}`);\n }\n}\n\nconst AUTO_REPLY_FILE = \"auto-reply\";\nconst AUTO_REPLY_DISABLED_FILE = \"auto-reply.disabled\";\n\nexport function slackConversationAutoReplyEnabled(office: Office): boolean {\n return existsSync(join(office.dir, AUTO_REPLY_FILE));\n}\n\nexport function setSlackConversationAutoReply(office: Office, enabled: boolean): void {\n ensureDirExists(office.dir);\n const enabledPath = join(office.dir, AUTO_REPLY_FILE);\n const disabledPath = join(office.dir, AUTO_REPLY_DISABLED_FILE);\n const targetPath = enabled ? enabledPath : disabledPath;\n const otherPath = enabled ? disabledPath : enabledPath;\n\n if (existsSync(otherPath)) {\n renameSync(otherPath, targetPath);\n return;\n }\n if (enabled && !existsSync(targetPath)) {\n atomicWritePrivateFile(targetPath, \"\");\n }\n}\n\nexport function resolveConversationSettings(office: Office): AgentConfig {\n const globalConfig = loadRawGlobalSettings();\n const conversationConfig = normalizeSettingsConfig(\n loadSettingsFile(conversationSettingsPath(office)) ?? {},\n );\n // MCP servers merge per key: a conversation redefines or disables individual\n // servers without losing the rest of the global set.\n const mcpServers = { ...globalConfig.mcpServers, ...conversationConfig.mcpServers };\n // The sandbox group merges at the leaf level (see mergeSandboxSettings):\n // a conversation that only sets sandbox.memory keeps the global sandbox.cpus.\n const sandbox = mergeSandboxSettings(globalConfig.sandbox, conversationConfig.sandbox);\n return toAgentConfig({\n ...globalConfig,\n ...conversationConfig,\n ...(sandbox ? { sandbox } : {}),\n ...(Object.keys(mcpServers).length > 0 ? { mcpServers } : {}),\n });\n}\n\n/**\n * True when `child` is `parent` or a path inside it. Purely lexical (no\n * symlink resolution) — used for configuration sanity checks, not as the\n * final security boundary.\n */\nexport function isPathInside(child: string, parent: string): boolean {\n const parentPath = resolve(parent);\n const childPath = resolve(child);\n return childPath === parentPath || childPath.startsWith(parentPath + \"/\");\n}\n\n/**\n * The state dir (settings, office records, vaults) must never live inside\n * the working dir: conversation opt-in \"full\" mode mounts the entire working\n * dir read-write into sandbox containers, which would expose host-authoritative\n * state and credentials. Fatal under sandboxed modes; host mode has no mounts,\n * so only warn about the bad hygiene.\n */\nexport function assertStateDirOutsideWorkspace(\n stateDir: string,\n workingDir: string,\n sandboxType: string,\n): void {\n if (!isPathInside(stateDir, workingDir)) return;\n const message =\n `--state-dir (${stateDir}) must not be inside the working directory (${workingDir}): ` +\n `sandbox containers mount the working directory, and a mounted state dir ` +\n `would expose settings, office records, vaults, and credentials to sandboxed code.`;\n if (sandboxType === \"host\") {\n log.logWarning(\"Insecure state dir location\", message);\n return;\n }\n throw new Error(message);\n}\n\n/** Settings-file DSN wins over SENTRY_DSN env — the rule lives only here. */\nfunction sentryDsnFrom(fromFile: string | undefined): string | undefined {\n return fromFile || readEnv(\"SENTRY_DSN\");\n}\n\nexport function resolveSentryDsn(): string | undefined {\n const fromFile = normalizeSettingsConfig(loadSettingsFile(getSettingsPath()) ?? {});\n return sentryDsnFrom(fromFile.sentryDsn);\n}\n\nexport function createGlobalSettingsFile(stateDir: string, llm?: OnboardLlmChoice): string {\n const settingsPath = join(stateDir, \"settings.json\");\n if (existsSync(settingsPath)) {\n throw new Error(`Global settings already exists at ${settingsPath}`);\n }\n ensureDirExists(stateDir);\n const settings: SettingsFileConfig = llm\n ? {\n ...ONBOARD_SETTINGS,\n llm: {\n ...ONBOARD_SETTINGS.llm,\n provider: llm.provider,\n model: llm.model,\n },\n }\n : ONBOARD_SETTINGS;\n atomicWritePrivateFile(settingsPath, JSON.stringify(settings, null, 2));\n return settingsPath;\n}\n\n/**\n * Externally-visible base URL of the link/OAuth server, e.g.\n * `https://mikan.example.com` (no trailing slash). Read from `LINK_URL` or\n * `MIKAN_LINK_URL`, the same env var the bot uses to build credential onboarding links.\n */\nexport function resolveLinkBaseUrl(): string | undefined {\n const raw = readEnv(\"LINK_URL\");\n if (!raw) return undefined;\n return raw.replace(/\\/+$/, \"\");\n}\n\nfunction hasDefinedValue(values: Record<string, unknown> | undefined): boolean {\n return values !== undefined && Object.values(values).some((value) => value !== undefined);\n}\n\nfunction compactSettingsConfig(config: SettingsFileConfig): SettingsFileConfig {\n return {\n ...(hasDefinedValue(config.llm) ? { llm: config.llm } : {}),\n ...(hasDefinedValue(config.sentry) ? { sentry: config.sentry } : {}),\n ...(hasDefinedValue(config.sandbox) ? { sandbox: config.sandbox } : {}),\n ...(hasDefinedValue(config.slack) ? { slack: config.slack } : {}),\n ...(hasDefinedValue(config.office) ? { office: config.office } : {}),\n // An empty map means \"all servers removed\".\n ...(config.mcpServers !== undefined ? { mcpServers: config.mcpServers } : {}),\n };\n}\n\nfunction patchSettingsConfig(\n existing: SettingsFileConfig,\n config: Partial<AgentConfig>,\n): SettingsFileConfig {\n const patched: SettingsFileConfig = {\n ...existing,\n llm: {\n ...existing.llm,\n ...(config.provider !== undefined ? { provider: config.provider } : {}),\n ...(config.model !== undefined ? { model: config.model } : {}),\n ...(config.thinkingLevel !== undefined ? { thinkingLevel: config.thinkingLevel } : {}),\n },\n sentry: {\n ...existing.sentry,\n ...(config.sentryDsn !== undefined ? { dsn: config.sentryDsn } : {}),\n },\n // Leaf-level merge: a patch that only sets sandbox.boost.memory keeps the\n // existing boost.cpus (and every other existing leaf). compactSettingsConfig\n // drops the group entirely when it ends up with no defined values.\n sandbox: mergeSandboxSettings(existing.sandbox, config.sandbox) ?? {},\n slack: {\n ...existing.slack,\n ...config.slack,\n },\n // Office visibility has its own writer (setOfficeVisibilityOverride); the\n // generic patch must not drop it.\n ...(existing.office !== undefined ? { office: existing.office } : {}),\n // The portal edits the full MCP map, and\n // a merge would make removing a server impossible.\n ...(config.mcpServers !== undefined ? { mcpServers: config.mcpServers } : {}),\n };\n return compactSettingsConfig(patched);\n}\n\nfunction loadSettingsFileForUpdate(\n settingsPath: string,\n defaultSettings: SettingsFileConfig,\n): SettingsFileConfig {\n if (!existsSync(settingsPath)) return defaultSettings;\n try {\n return loadSettingsFile(settingsPath) ?? {};\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err);\n const message = detail.startsWith(\"Malformed settings file\")\n ? detail.replace(\"Malformed settings file\", \"Refusing to overwrite malformed settings file\")\n : detail;\n throw new Error(message, { cause: err });\n }\n}\n\nfunction updateSettingsFile(\n settingsPath: string,\n patch: Partial<AgentConfig>,\n defaultSettings: SettingsFileConfig,\n): void {\n const existing = loadSettingsFileForUpdate(settingsPath, defaultSettings);\n ensureDirExists(dirname(settingsPath));\n atomicWritePrivateFile(\n settingsPath,\n JSON.stringify(patchSettingsConfig(existing, patch), null, 2),\n );\n}\n\nexport function updateGlobalSettings(patch: Partial<AgentConfig>): void {\n updateSettingsFile(getSettingsPath(), patch, ONBOARD_SETTINGS);\n}\n\nexport function updateConversationSettings(office: Office, patch: Partial<AgentConfig>): void {\n updateSettingsFile(conversationSettingsPath(office), patch, {});\n}\n\n/**\n * The two scope-level MCP server maps, unmerged: the portal edits each scope's\n * own file, so it needs the raw per-scope values, not the effective merge\n * (`resolveConversationSettings` owns that).\n */\nexport function loadScopeMcpServers(office: Office): {\n global: Record<string, McpServerConfig>;\n conversation: Record<string, McpServerConfig>;\n} {\n return {\n global: loadRawGlobalSettings().mcpServers ?? {},\n conversation: loadSettingsFile(conversationSettingsPath(office))?.mcpServers ?? {},\n };\n}\n\n/**\n * The conversation's own visibility override, or null when it follows the\n * platform. Only \"private\" can be stored: an operator may narrow a public\n * channel, never widen a private one (see ADR 0008).\n */\nexport function loadOfficeVisibilityOverride(office: Office): \"private\" | null {\n return loadSettingsFile(conversationSettingsPath(office))?.office?.visibility ?? null;\n}\n\nexport function setOfficeVisibilityOverride(office: Office, visibility: \"private\" | null): void {\n const settingsPath = conversationSettingsPath(office);\n const existing = loadSettingsFileForUpdate(settingsPath, {});\n const { office: _previous, ...rest } = existing;\n ensureDirExists(dirname(settingsPath));\n atomicWritePrivateFile(\n settingsPath,\n JSON.stringify(\n compactSettingsConfig({ ...rest, ...(visibility ? { office: { visibility } } : {}) }),\n null,\n 2,\n ),\n );\n}\n\n/**\n * Legacy door-policy override kept readable only so the observation period\n * can report which offices still declare `full`; it no longer changes the\n * projection (ADR 0008).\n */\nexport function loadLegacyFullOverride(office: Office): boolean {\n const sandbox = loadSettingsFile(conversationSettingsPath(office))?.sandbox;\n return sandbox?.workspace?.layout === \"full\" || sandbox?.image?.workspaceMount === \"full\";\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"execution-resolver.d.ts","sourceRoot":"","sources":["../../src/harness/execution-resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAAuB,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAShF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,aAAa,CAAC;AAE/D,qBAAa,sBAAsB;IAE/B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,SAAS;IAJnB,YACU,UAAU,EAAE,aAAa,EACzB,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,sBAAsB,GAAG,SAAS,EAC/C,SAAS,EAAE,SAAS,EAC1B;IAEE,OAAO,CAAC,OAAO,EAAE,YAAY;;;;OAYlC;IAED,OAAO,CAAC,WAAW;IA2CnB,OAAO,CAAC,wBAAwB;IAuBhC,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,wBAAwB;IA0ChC,OAAO,CAAC,aAAa;CA4BtB"}
1
+ {"version":3,"file":"execution-resolver.d.ts","sourceRoot":"","sources":["../../src/harness/execution-resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAAuB,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAShF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,aAAa,CAAC;AAE/D,qBAAa,sBAAsB;IAE/B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,SAAS;IAJnB,YACU,UAAU,EAAE,aAAa,EACzB,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,sBAAsB,GAAG,SAAS,EAC/C,SAAS,EAAE,SAAS,EAC1B;IAEE,OAAO,CAAC,OAAO,EAAE,YAAY;;;;OAYlC;IAED,OAAO,CAAC,WAAW;IAuCnB,OAAO,CAAC,wBAAwB;IAuBhC,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,wBAAwB;IA0ChC,OAAO,CAAC,aAAa;CA4BtB"}
@@ -44,7 +44,7 @@ export class ActorExecutionResolver {
44
44
  address: office.address,
45
45
  });
46
46
  const mounts = this.resolveMounts(injection.mounts, projection);
47
- assertSandboxSupportsWorkspacePolicy(this.baseConfig, projection.doorPolicy, projection.promptSources.globalMemoryReadOnly === true);
47
+ assertSandboxSupportsWorkspacePolicy(this.baseConfig, projection.visibility, office.key);
48
48
  return {
49
49
  plan: {
50
50
  credentialKey,
@@ -1 +1 @@
1
- {"version":3,"file":"execution-resolver.js","sourceRoot":"","sources":["../../src/harness/execution-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAuB,MAAM,2BAA2B,CAAC;AACxF,OAAO,EACL,oCAAoC,EACpC,cAAc,EACd,gCAAgC,GAEjC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAqB,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EACL,0BAA0B,EAC1B,qCAAqC,EACrC,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAMrE,MAAM,OAAO,sBAAsB;IACjC,YACU,UAAyB,EACzB,YAA0B,EAC1B,WAA+C,EAC/C,SAAoB;0BAHpB,UAAU;4BACV,YAAY;2BACZ,WAAW;yBACX,SAAS;IAChB,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,OAAqB;QACjC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACvD,MAAM,QAAQ,GAAG,cAAc,CAC7B,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO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;YACpE,IAAI,cAAc,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CACb,uBAAuB,UAAU,CAAC,MAAM,4BAA4B,cAAc,CAAC,MAAM,GAAG,CAC7F,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,CAAC,GAAG,eAAe,EAAE,GAAG,WAAW,CAAC,CAAC;IAC9C,CAAC;CACF;AAED,SAAS,cAAc,CAAC,IAAY,EAAE,KAAa;IACjD,MAAM,CAAC,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;AAC/C,CAAC","sourcesContent":["import { posix } from \"node:path\";\nimport type { Workspace } from \"../office/index.js\";\nimport { loadGlobalSettings } from \"../config.js\";\nimport { DockerContainerManager, type ContainerMount } from \"../sandbox/provisioner.js\";\nimport {\n assertSandboxSupportsWorkspacePolicy,\n createExecutor,\n getSandboxCredentialCapabilities,\n type SandboxConfig,\n} from \"../sandbox/index.js\";\nimport { reportUserFacingError } from \"../observability/index.js\";\nimport { normalizeSharedVaultName, type VaultManager } from \"../vault/index.js\";\nimport { allowsAmbientDefaultSharedVault, resolveVaultInjection } from \"../vault/index.js\";\nimport {\n credentialAuthorizationKey,\n legacyExactCredentialAuthorizationKey,\n runtimeResourceKey,\n scopeCloudflareSandboxId,\n} from \"../sandbox/identity.js\";\nimport { resolveWorkspaceProjection } from \"../office/projection.js\";\nimport type { WorkspaceProjection } from \"../office/types.js\";\n\nexport type { ActorContext } from \"../types.js\";\nimport type { ActorContext, ExecutionPlan } from \"../types.js\";\n\nexport class ActorExecutionResolver {\n constructor(\n private baseConfig: SandboxConfig,\n private vaultManager: VaultManager,\n private provisioner: DockerContainerManager | undefined,\n private workspace: Workspace,\n ) {}\n\n async resolve(context: ActorContext) {\n const { plan, projection } = this.resolvePlan(context);\n const executor = createExecutor(\n plan.sandboxConfig,\n plan.env,\n this.buildEnsureReadyCallback(plan, context.address.conversationId),\n );\n return {\n executor,\n pathContext: executor.getPathContext(this.workspace.root),\n projection,\n };\n }\n\n private resolvePlan(context: ActorContext): {\n plan: ExecutionPlan;\n projection: WorkspaceProjection;\n } {\n const scope = { userId: context.userId, address: context.address };\n const credentialKey = credentialAuthorizationKey(this.baseConfig, scope);\n const legacyCredentialKey = legacyExactCredentialAuthorizationKey(this.baseConfig, scope);\n const resourceKey = runtimeResourceKey(this.baseConfig, {\n userId: context.userId,\n address: context.address,\n });\n this.ensureDefaultSharedVault(credentialKey, legacyCredentialKey, context.trustModel);\n\n const vault =\n this.vaultManager.resolve(credentialKey) ??\n (legacyCredentialKey ? this.vaultManager.resolve(legacyCredentialKey) : undefined);\n const capabilities = getSandboxCredentialCapabilities(this.baseConfig.type);\n const office = this.workspace.office(context.address);\n const projection = resolveWorkspaceProjection(office);\n const injection = resolveVaultInjection({\n vault,\n capabilities,\n sandboxType: this.baseConfig.type,\n address: office.address,\n });\n const mounts = this.resolveMounts(injection.mounts, projection);\n assertSandboxSupportsWorkspacePolicy(\n this.baseConfig,\n projection.doorPolicy,\n projection.promptSources.globalMemoryReadOnly === true,\n );\n return {\n plan: {\n credentialKey,\n resourceKey,\n sandboxConfig: this.resolveSandboxConfig(resourceKey),\n env: injection.env,\n mounts,\n },\n projection,\n };\n }\n\n private ensureDefaultSharedVault(\n credentialKey: string,\n legacyCredentialKey: string | undefined,\n trustModel: ActorContext[\"trustModel\"],\n ): void {\n if (!allowsAmbientDefaultSharedVault({ trustModel, sandboxType: this.baseConfig.type })) return;\n if (\n this.vaultManager.hasEntry(credentialKey) ||\n (legacyCredentialKey && this.vaultManager.hasEntry(legacyCredentialKey))\n ) {\n return;\n }\n\n let profile: string | undefined;\n try {\n profile = loadGlobalSettings().sandbox?.defaultSharedVault;\n } catch {\n return;\n }\n if (!profile || normalizeSharedVaultName(profile) !== profile) return;\n this.vaultManager.copySharedVaultTo(profile, credentialKey);\n }\n\n private resolveSandboxConfig(resourceKey: string): SandboxConfig {\n if (this.baseConfig.type === \"cloudflare\") {\n return {\n type: \"cloudflare\",\n sandboxId: scopeCloudflareSandboxId(this.baseConfig.sandboxId, resourceKey),\n };\n }\n if (this.baseConfig.type !== \"image\") return this.baseConfig;\n return {\n type: \"container\",\n container: DockerContainerManager.containerName(resourceKey),\n };\n }\n\n private buildEnsureReadyCallback(\n plan: ExecutionPlan,\n conversationId: string,\n ): (() => Promise<void>) | undefined {\n if (this.baseConfig.type !== \"image\" || plan.sandboxConfig.type !== \"container\") {\n return undefined;\n }\n\n return async () => {\n const expected = plan.sandboxConfig.type === \"container\" ? plan.sandboxConfig.container : \"\";\n let actual: string | undefined;\n try {\n actual = await this.provisioner?.provision(plan.resourceKey, {\n containerName: expected,\n mounts: plan.mounts,\n conversationId,\n });\n } catch (err) {\n reportUserFacingError(err, {\n domain: \"sandbox\",\n surface: \"sandbox_provision\",\n operation: \"ensure_image_container_ready\",\n severity: \"error\",\n context: {\n sandboxType: \"image\",\n conversationId,\n credentialKey: plan.credentialKey,\n resourceKey: plan.resourceKey,\n expectedContainer: expected,\n hasVault: Boolean(plan.env || plan.mounts.length > 0),\n },\n });\n throw err;\n }\n if (actual && actual !== expected) {\n throw new Error(\n `Provisioner returned container \"${actual}\" for resource key \"${plan.resourceKey}\", expected \"${expected}\"`,\n );\n }\n };\n }\n\n private resolveMounts(\n vaultMounts: ContainerMount[],\n projection: WorkspaceProjection,\n ): ContainerMount[] {\n const protectedMounts = projection.mounts;\n for (let index = 0; index < vaultMounts.length; index += 1) {\n const vaultMount = vaultMounts[index];\n if (vaultMount === undefined) continue;\n const workspaceCollision = protectedMounts.find((protectedMount) =>\n targetsOverlap(protectedMount.target, vaultMount.target),\n );\n if (workspaceCollision) {\n throw new Error(\n `Vault mount target \"${vaultMount.target}\" overlaps protected workspace target \"${workspaceCollision.target}\"`,\n );\n }\n\n const vaultCollision = vaultMounts\n .slice(0, index)\n .find((other) => targetsOverlap(other.target, vaultMount.target));\n if (vaultCollision) {\n throw new Error(\n `Vault mount target \"${vaultMount.target}\" overlaps vault target \"${vaultCollision.target}\"`,\n );\n }\n }\n return [...protectedMounts, ...vaultMounts];\n }\n}\n\nfunction targetsOverlap(left: string, right: string): boolean {\n const a = normalizeMountTarget(left);\n const b = normalizeMountTarget(right);\n return a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);\n}\n\nfunction normalizeMountTarget(value: string): string {\n const normalized = posix.normalize(value);\n return normalized.replace(/\\/+$/, \"\") || \"/\";\n}\n"]}
1
+ {"version":3,"file":"execution-resolver.js","sourceRoot":"","sources":["../../src/harness/execution-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAuB,MAAM,2BAA2B,CAAC;AACxF,OAAO,EACL,oCAAoC,EACpC,cAAc,EACd,gCAAgC,GAEjC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAqB,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EACL,0BAA0B,EAC1B,qCAAqC,EACrC,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,0BAA0B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EAAE,CACjE,cAAc,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CACzD,CAAC;YACF,IAAI,kBAAkB,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CACb,uBAAuB,UAAU,CAAC,MAAM,0CAA0C,kBAAkB,CAAC,MAAM,GAAG,CAC/G,CAAC;YACJ,CAAC;YAED,MAAM,cAAc,GAAG,WAAW;iBAC/B,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;iBACf,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACpE,IAAI,cAAc,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CACb,uBAAuB,UAAU,CAAC,MAAM,4BAA4B,cAAc,CAAC,MAAM,GAAG,CAC7F,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,CAAC,GAAG,eAAe,EAAE,GAAG,WAAW,CAAC,CAAC;IAC9C,CAAC;CACF;AAED,SAAS,cAAc,CAAC,IAAY,EAAE,KAAa;IACjD,MAAM,CAAC,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;AAC/C,CAAC","sourcesContent":["import { posix } from \"node:path\";\nimport type { Workspace } from \"../office/index.js\";\nimport { loadGlobalSettings } from \"../config.js\";\nimport { DockerContainerManager, type ContainerMount } from \"../sandbox/provisioner.js\";\nimport {\n assertSandboxSupportsWorkspacePolicy,\n createExecutor,\n getSandboxCredentialCapabilities,\n type SandboxConfig,\n} from \"../sandbox/index.js\";\nimport { reportUserFacingError } from \"../observability/index.js\";\nimport { normalizeSharedVaultName, type VaultManager } from \"../vault/index.js\";\nimport { allowsAmbientDefaultSharedVault, resolveVaultInjection } from \"../vault/index.js\";\nimport {\n credentialAuthorizationKey,\n legacyExactCredentialAuthorizationKey,\n runtimeResourceKey,\n scopeCloudflareSandboxId,\n} from \"../sandbox/identity.js\";\nimport { resolveWorkspaceProjection } from \"../office/projection.js\";\nimport type { WorkspaceProjection } from \"../office/types.js\";\n\nexport type { ActorContext } from \"../types.js\";\nimport type { ActorContext, ExecutionPlan } from \"../types.js\";\n\nexport class ActorExecutionResolver {\n constructor(\n private baseConfig: SandboxConfig,\n private vaultManager: VaultManager,\n private provisioner: DockerContainerManager | undefined,\n private workspace: Workspace,\n ) {}\n\n async resolve(context: ActorContext) {\n const { plan, projection } = this.resolvePlan(context);\n const executor = createExecutor(\n plan.sandboxConfig,\n plan.env,\n this.buildEnsureReadyCallback(plan, context.address.conversationId),\n );\n return {\n executor,\n pathContext: executor.getPathContext(this.workspace.root),\n projection,\n };\n }\n\n private resolvePlan(context: ActorContext): {\n plan: ExecutionPlan;\n projection: WorkspaceProjection;\n } {\n const scope = { userId: context.userId, address: context.address };\n const credentialKey = credentialAuthorizationKey(this.baseConfig, scope);\n const legacyCredentialKey = legacyExactCredentialAuthorizationKey(this.baseConfig, scope);\n const resourceKey = runtimeResourceKey(this.baseConfig, {\n userId: context.userId,\n address: context.address,\n });\n this.ensureDefaultSharedVault(credentialKey, legacyCredentialKey, context.trustModel);\n\n const vault =\n this.vaultManager.resolve(credentialKey) ??\n (legacyCredentialKey ? this.vaultManager.resolve(legacyCredentialKey) : undefined);\n const capabilities = getSandboxCredentialCapabilities(this.baseConfig.type);\n const office = this.workspace.office(context.address);\n const projection = resolveWorkspaceProjection(office);\n const injection = resolveVaultInjection({\n vault,\n capabilities,\n sandboxType: this.baseConfig.type,\n address: office.address,\n });\n const mounts = this.resolveMounts(injection.mounts, projection);\n assertSandboxSupportsWorkspacePolicy(this.baseConfig, projection.visibility, office.key);\n return {\n plan: {\n credentialKey,\n resourceKey,\n sandboxConfig: this.resolveSandboxConfig(resourceKey),\n env: injection.env,\n mounts,\n },\n projection,\n };\n }\n\n private ensureDefaultSharedVault(\n credentialKey: string,\n legacyCredentialKey: string | undefined,\n trustModel: ActorContext[\"trustModel\"],\n ): void {\n if (!allowsAmbientDefaultSharedVault({ trustModel, sandboxType: this.baseConfig.type })) return;\n if (\n this.vaultManager.hasEntry(credentialKey) ||\n (legacyCredentialKey && this.vaultManager.hasEntry(legacyCredentialKey))\n ) {\n return;\n }\n\n let profile: string | undefined;\n try {\n profile = loadGlobalSettings().sandbox?.defaultSharedVault;\n } catch {\n return;\n }\n if (!profile || normalizeSharedVaultName(profile) !== profile) return;\n this.vaultManager.copySharedVaultTo(profile, credentialKey);\n }\n\n private resolveSandboxConfig(resourceKey: string): SandboxConfig {\n if (this.baseConfig.type === \"cloudflare\") {\n return {\n type: \"cloudflare\",\n sandboxId: scopeCloudflareSandboxId(this.baseConfig.sandboxId, resourceKey),\n };\n }\n if (this.baseConfig.type !== \"image\") return this.baseConfig;\n return {\n type: \"container\",\n container: DockerContainerManager.containerName(resourceKey),\n };\n }\n\n private buildEnsureReadyCallback(\n plan: ExecutionPlan,\n conversationId: string,\n ): (() => Promise<void>) | undefined {\n if (this.baseConfig.type !== \"image\" || plan.sandboxConfig.type !== \"container\") {\n return undefined;\n }\n\n return async () => {\n const expected = plan.sandboxConfig.type === \"container\" ? plan.sandboxConfig.container : \"\";\n let actual: string | undefined;\n try {\n actual = await this.provisioner?.provision(plan.resourceKey, {\n containerName: expected,\n mounts: plan.mounts,\n conversationId,\n });\n } catch (err) {\n reportUserFacingError(err, {\n domain: \"sandbox\",\n surface: \"sandbox_provision\",\n operation: \"ensure_image_container_ready\",\n severity: \"error\",\n context: {\n sandboxType: \"image\",\n conversationId,\n credentialKey: plan.credentialKey,\n resourceKey: plan.resourceKey,\n expectedContainer: expected,\n hasVault: Boolean(plan.env || plan.mounts.length > 0),\n },\n });\n throw err;\n }\n if (actual && actual !== expected) {\n throw new Error(\n `Provisioner returned container \"${actual}\" for resource key \"${plan.resourceKey}\", expected \"${expected}\"`,\n );\n }\n };\n }\n\n private resolveMounts(\n vaultMounts: ContainerMount[],\n projection: WorkspaceProjection,\n ): ContainerMount[] {\n const protectedMounts = projection.mounts;\n for (let index = 0; index < vaultMounts.length; index += 1) {\n const vaultMount = vaultMounts[index];\n if (vaultMount === undefined) continue;\n const workspaceCollision = protectedMounts.find((protectedMount) =>\n targetsOverlap(protectedMount.target, vaultMount.target),\n );\n if (workspaceCollision) {\n throw new Error(\n `Vault mount target \"${vaultMount.target}\" overlaps protected workspace target \"${workspaceCollision.target}\"`,\n );\n }\n\n const vaultCollision = vaultMounts\n .slice(0, index)\n .find((other) => targetsOverlap(other.target, vaultMount.target));\n if (vaultCollision) {\n throw new Error(\n `Vault mount target \"${vaultMount.target}\" overlaps vault target \"${vaultCollision.target}\"`,\n );\n }\n }\n return [...protectedMounts, ...vaultMounts];\n }\n}\n\nfunction targetsOverlap(left: string, right: string): boolean {\n const a = normalizeMountTarget(left);\n const b = normalizeMountTarget(right);\n return a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);\n}\n\nfunction normalizeMountTarget(value: string): string {\n const normalized = posix.normalize(value);\n return normalized.replace(/\\/+$/, \"\") || \"/\";\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/harness/prompt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAK1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,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MAAM,CAAC,GACxD,OAAO,CAAC;IACT,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,YAAY,EAAE,CAAC;CAClC,CAAC,CAmBD;AAkBD,wBAAsB,SAAS,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQhF;AAuCD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC,GAC7D,MAAM,GAAG,SAAS,CAOpB;AA+MD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM,CAKzE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,OAAO,EACvB,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,YAAY,EAAE,MAAM,GACnB,MAAM,CAkBR;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAYR"}
@@ -244,22 +244,20 @@ ${envDescription}
244
244
  function buildWorkspaceSkillsPrompt(input, paths) {
245
245
  const { office, projection, skills, skippedSkillLinks = [] } = input;
246
246
  const { workspaceRoot, conversationPath, scratchPath } = paths;
247
- const workspaceLayout = projection.layout === "full"
248
- ? `${workspaceRoot}/ contains the complete trusted workspace.`
249
- : projection.layout === "shared-support"
250
- ? `${workspaceRoot}/ contains shared MEMORY.md, skills/, and this conversation's directory.`
251
- : `${conversationPath}/ is the only conversation workspace mounted; global memory and skills are not available.`;
252
- const skillStorageGuidance = projection.doorPolicy === "trusted"
253
- ? `Store shared skills in \`${workspaceRoot}/skills/<name>/\` or conversation-specific skills in \`${conversationPath}/skills/<name>/\`.`
254
- : `Store skills in \`${conversationPath}/skills/<name>/\`; this office cannot access workspace-global skills.`;
247
+ const knowledgeReadOnly = projection.promptSources.globalKnowledgeReadOnly === true;
248
+ const workspaceLayout = knowledgeReadOnly
249
+ ? `${workspaceRoot}/ contains this private conversation's directory, read-only shared MEMORY.md and skills/, and read-only public/ with every public channel's office.`
250
+ : `${workspaceRoot}/ contains this public conversation's directory, shared MEMORY.md and skills/, and read-only public/ with every public channel's office.`;
251
+ const skillStorageGuidance = knowledgeReadOnly
252
+ ? `Store skills in \`${conversationPath}/skills/<name>/\`; shared \`${workspaceRoot}/skills/\` is read-only for this private office.`
253
+ : `Store shared skills in \`${workspaceRoot}/skills/<name>/\` or conversation-specific skills in \`${conversationPath}/skills/<name>/\`.`;
255
254
  return `## Workspace Layout
256
255
  ${workspaceLayout}
257
- ${projection.layout === "conversation"
258
- ? `${conversationPath}/ # This conversation`
259
- : `${workspaceRoot}/
260
- ├── MEMORY.md # Global memory (all conversations)
261
- ├── skills/ # Global CLI tools you create
262
- └── ${office.key}/ # This conversation`}
256
+ ${workspaceRoot}/
257
+ ├── MEMORY.md # Shared memory${knowledgeReadOnly ? " (read-only here)" : " (all public conversations)"}
258
+ ├── skills/ # Shared CLI tools${knowledgeReadOnly ? " (read-only here)" : " you create"}
259
+ ├── public/<office-key>/ # Other public channels' offices (read-only)
260
+ └── ${office.key}/ # This conversation
263
261
  ├── MEMORY.md # Conversation-specific memory
264
262
  ├── log.jsonl # Human-readable message history (no tool results)
265
263
  ├── sessions/ # Structured session history used for context reconstruction
@@ -300,13 +298,11 @@ function buildOperatingPrompt(input, paths) {
300
298
  const { memory, projection, sandboxConfig } = input;
301
299
  const { workspaceRoot, conversationPath } = paths;
302
300
  const isContainerLike = sandboxConfig.type === "container" || sandboxConfig.type === "image";
303
- const globalMemoryReadOnly = projection.promptSources.globalMemoryReadOnly === true;
304
- const memoryGuidance = projection.doorPolicy === "trusted"
305
- ? globalMemoryReadOnly
306
- ? `\`${workspaceRoot}/MEMORY.md\` is shared workspace memory mounted read-only for this office (private visibility): you can read what other offices have learned, but writes to it are rejected. Write everything you learn here to \`${conversationPath}/MEMORY.md\` instead; it never leaves this conversation.`
307
- : `Write important shared knowledge to \`${workspaceRoot}/MEMORY.md\` and conversation-specific knowledge to \`${conversationPath}/MEMORY.md\`.`
308
- : `Write durable knowledge only to \`${conversationPath}/MEMORY.md\`; this office cannot access workspace-global memory.`;
309
- const systemLogPath = projection.layout === "conversation"
301
+ const globalMemoryReadOnly = projection.promptSources.globalKnowledgeReadOnly === true;
302
+ const memoryGuidance = globalMemoryReadOnly
303
+ ? `\`${workspaceRoot}/MEMORY.md\` is shared workspace memory mounted read-only for this private office: you can read what public channels have learned, but writes to it are rejected. Write everything you learn here to \`${conversationPath}/MEMORY.md\` instead; it never leaves this conversation.`
304
+ : `Write important shared knowledge to \`${workspaceRoot}/MEMORY.md\` and conversation-specific knowledge to \`${conversationPath}/MEMORY.md\`.`;
305
+ const systemLogPath = globalMemoryReadOnly
310
306
  ? `${conversationPath}/SYSTEM.md`
311
307
  : `${workspaceRoot}/SYSTEM.md`;
312
308
  return `## Events