@0xmaxma/claude-gateway 2.1.1 → 2.1.3

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 (172) hide show
  1. package/README.md +1 -1
  2. package/config.template.json +1 -1
  3. package/dist/agent/dreaming/index.d.ts +6 -0
  4. package/dist/agent/dreaming/index.d.ts.map +1 -1
  5. package/dist/agent/dreaming/index.js +3 -3
  6. package/dist/agent/dreaming/index.js.map +1 -1
  7. package/dist/agent/runner.d.ts +1 -1
  8. package/dist/agent/runner.d.ts.map +1 -1
  9. package/dist/agent/runner.js +9 -4
  10. package/dist/agent/runner.js.map +1 -1
  11. package/dist/agent/workspace-loader.d.ts +12 -0
  12. package/dist/agent/workspace-loader.d.ts.map +1 -1
  13. package/dist/agent/workspace-loader.js +34 -4
  14. package/dist/agent/workspace-loader.js.map +1 -1
  15. package/dist/api/cron-router.d.ts.map +1 -1
  16. package/dist/api/cron-router.js +3 -2
  17. package/dist/api/cron-router.js.map +1 -1
  18. package/dist/api/gateway-router.d.ts.map +1 -1
  19. package/dist/api/gateway-router.js +1 -1
  20. package/dist/api/gateway-router.js.map +1 -1
  21. package/dist/api/router.d.ts.map +1 -1
  22. package/dist/api/router.js +40 -5
  23. package/dist/api/router.js.map +1 -1
  24. package/dist/api/share-router.d.ts +1 -1
  25. package/dist/api/share-router.d.ts.map +1 -1
  26. package/dist/api/share-router.js +14 -5
  27. package/dist/api/share-router.js.map +1 -1
  28. package/dist/api/voice-call-router.d.ts.map +1 -1
  29. package/dist/api/voice-call-router.js +8 -5
  30. package/dist/api/voice-call-router.js.map +1 -1
  31. package/dist/api/voice-router.js +1 -1
  32. package/dist/api/voice-router.js.map +1 -1
  33. package/dist/api/voice-settings-router.d.ts.map +1 -1
  34. package/dist/api/voice-settings-router.js +15 -0
  35. package/dist/api/voice-settings-router.js.map +1 -1
  36. package/dist/apps/agent-manager.d.ts +17 -2
  37. package/dist/apps/agent-manager.d.ts.map +1 -1
  38. package/dist/apps/agent-manager.js +78 -4
  39. package/dist/apps/agent-manager.js.map +1 -1
  40. package/dist/apps/compose-generator.d.ts +8 -0
  41. package/dist/apps/compose-generator.d.ts.map +1 -1
  42. package/dist/apps/compose-generator.js +22 -3
  43. package/dist/apps/compose-generator.js.map +1 -1
  44. package/dist/apps/conversation-sandbox.d.ts +78 -0
  45. package/dist/apps/conversation-sandbox.d.ts.map +1 -0
  46. package/dist/apps/conversation-sandbox.js +357 -0
  47. package/dist/apps/conversation-sandbox.js.map +1 -0
  48. package/dist/apps/installer.d.ts +8 -3
  49. package/dist/apps/installer.d.ts.map +1 -1
  50. package/dist/apps/installer.js +89 -18
  51. package/dist/apps/installer.js.map +1 -1
  52. package/dist/apps/registry.d.ts +2 -0
  53. package/dist/apps/registry.d.ts.map +1 -1
  54. package/dist/build-provenance.json +4 -4
  55. package/dist/config/loader.d.ts.map +1 -1
  56. package/dist/config/loader.js +3 -0
  57. package/dist/config/loader.js.map +1 -1
  58. package/dist/config/migrator.d.ts +2 -0
  59. package/dist/config/migrator.d.ts.map +1 -1
  60. package/dist/config/migrator.js +37 -1
  61. package/dist/config/migrator.js.map +1 -1
  62. package/dist/config/reload-policy.d.ts.map +1 -1
  63. package/dist/config/reload-policy.js +2 -0
  64. package/dist/config/reload-policy.js.map +1 -1
  65. package/dist/cron/manager.d.ts +15 -0
  66. package/dist/cron/manager.d.ts.map +1 -1
  67. package/dist/cron/manager.js +53 -1
  68. package/dist/cron/manager.js.map +1 -1
  69. package/dist/index.js +21 -9
  70. package/dist/index.js.map +1 -1
  71. package/dist/orchestration/bridge.d.ts +4 -0
  72. package/dist/orchestration/bridge.d.ts.map +1 -1
  73. package/dist/orchestration/bridge.js +25 -6
  74. package/dist/orchestration/bridge.js.map +1 -1
  75. package/dist/orchestration/capabilities.d.ts.map +1 -1
  76. package/dist/orchestration/capabilities.js +1 -0
  77. package/dist/orchestration/capabilities.js.map +1 -1
  78. package/dist/orchestration/config.js +1 -1
  79. package/dist/orchestration/config.js.map +1 -1
  80. package/dist/orchestration/container.d.ts.map +1 -1
  81. package/dist/orchestration/container.js +48 -1
  82. package/dist/orchestration/container.js.map +1 -1
  83. package/dist/orchestration/context-footprint.d.ts.map +1 -1
  84. package/dist/orchestration/context-footprint.js +1 -1
  85. package/dist/orchestration/context-footprint.js.map +1 -1
  86. package/dist/orchestration/delivery.d.ts.map +1 -1
  87. package/dist/orchestration/delivery.js +17 -8
  88. package/dist/orchestration/delivery.js.map +1 -1
  89. package/dist/orchestration/recovery.d.ts.map +1 -1
  90. package/dist/orchestration/recovery.js +27 -0
  91. package/dist/orchestration/recovery.js.map +1 -1
  92. package/dist/orchestration/report-promise.d.ts +9 -0
  93. package/dist/orchestration/report-promise.d.ts.map +1 -0
  94. package/dist/orchestration/report-promise.js +39 -0
  95. package/dist/orchestration/report-promise.js.map +1 -0
  96. package/dist/orchestration/restart-resume.d.ts +7 -1
  97. package/dist/orchestration/restart-resume.d.ts.map +1 -1
  98. package/dist/orchestration/restart-resume.js +22 -1
  99. package/dist/orchestration/restart-resume.js.map +1 -1
  100. package/dist/orchestration/runtime.d.ts +3 -0
  101. package/dist/orchestration/runtime.d.ts.map +1 -1
  102. package/dist/orchestration/runtime.js +53 -18
  103. package/dist/orchestration/runtime.js.map +1 -1
  104. package/dist/orchestration/store.d.ts +9 -0
  105. package/dist/orchestration/store.d.ts.map +1 -1
  106. package/dist/orchestration/store.js +13 -1
  107. package/dist/orchestration/store.js.map +1 -1
  108. package/dist/orchestration/tasks/driver.d.ts +1 -0
  109. package/dist/orchestration/tasks/driver.d.ts.map +1 -1
  110. package/dist/orchestration/tasks/driver.js +23 -3
  111. package/dist/orchestration/tasks/driver.js.map +1 -1
  112. package/dist/orchestration/tasks/service.d.ts +1 -3
  113. package/dist/orchestration/tasks/service.d.ts.map +1 -1
  114. package/dist/orchestration/tasks/service.js +5 -17
  115. package/dist/orchestration/tasks/service.js.map +1 -1
  116. package/dist/orchestration/telegram-speech.d.ts.map +1 -1
  117. package/dist/orchestration/telegram-speech.js +0 -2
  118. package/dist/orchestration/telegram-speech.js.map +1 -1
  119. package/dist/session/process.d.ts +15 -1
  120. package/dist/session/process.d.ts.map +1 -1
  121. package/dist/session/process.js +101 -15
  122. package/dist/session/process.js.map +1 -1
  123. package/dist/share/share-store.d.ts +10 -1
  124. package/dist/share/share-store.d.ts.map +1 -1
  125. package/dist/share/share-store.js +42 -1
  126. package/dist/share/share-store.js.map +1 -1
  127. package/dist/types.d.ts +7 -0
  128. package/dist/types.d.ts.map +1 -1
  129. package/dist/ui/voice-call-client.d.ts +27 -14
  130. package/dist/ui/voice-call-client.d.ts.map +1 -1
  131. package/dist/ui/voice-call-client.js +80 -24
  132. package/dist/ui/voice-call-client.js.map +1 -1
  133. package/dist/ui/voice-call-ui.d.ts +4 -1
  134. package/dist/ui/voice-call-ui.d.ts.map +1 -1
  135. package/dist/ui/voice-call-ui.js +65 -21
  136. package/dist/ui/voice-call-ui.js.map +1 -1
  137. package/dist/voice/errors.d.ts +1 -3
  138. package/dist/voice/errors.d.ts.map +1 -1
  139. package/dist/voice/errors.js +9 -4
  140. package/dist/voice/errors.js.map +1 -1
  141. package/dist/voice/notes.d.ts +4 -3
  142. package/dist/voice/notes.d.ts.map +1 -1
  143. package/dist/voice/notes.js +15 -11
  144. package/dist/voice/notes.js.map +1 -1
  145. package/dist/voice/telegram-avatar.d.ts +6 -2
  146. package/dist/voice/telegram-avatar.d.ts.map +1 -1
  147. package/dist/voice/telegram-avatar.js +23 -10
  148. package/dist/voice/telegram-avatar.js.map +1 -1
  149. package/dist/voice/turn-manager.d.ts.map +1 -1
  150. package/dist/voice/turn-manager.js +1 -1
  151. package/dist/voice/turn-manager.js.map +1 -1
  152. package/dist/voice/types.d.ts +3 -0
  153. package/dist/voice/types.d.ts.map +1 -1
  154. package/dist/voice/types.js +4 -0
  155. package/dist/voice/types.js.map +1 -1
  156. package/mcp/modules.ts +13 -1
  157. package/mcp/tools/api/module.ts +9 -1
  158. package/mcp/tools/apps/skills/create-app-yaml/SKILL.md +1 -1
  159. package/mcp/tools/discord/module.ts +44 -11
  160. package/mcp/tools/line/module.ts +11 -0
  161. package/mcp/tools/memory/disable-archive.test.ts +47 -0
  162. package/mcp/tools/memory/module.ts +2 -1
  163. package/mcp/tools/shared/isolate.ts +77 -0
  164. package/mcp/tools/shared/share-client.ts +15 -1
  165. package/mcp/tools/slack/module.ts +12 -5
  166. package/mcp/tools/telegram/attachment-log.ts +39 -0
  167. package/mcp/tools/telegram/module.ts +27 -11
  168. package/mcp/tools/telegram/receiver-server.ts +8 -0
  169. package/mcp/tools/wechat/module.ts +2 -0
  170. package/mcp/tools/whatsapp/module.ts +8 -1
  171. package/mcp/tools/whatsapp-cloud/module.ts +14 -7
  172. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/session/process.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAAsB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,OAAO,EAA4D,cAAc,EAAsB,MAAM,mBAAmB,CAAC;AAOjI,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAItD,OAAO,EAAmC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAevC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAqHvC,eAAO,MAAM,yBAAyB,oDAAoD,CAAC;AAE3F;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAMR;AAqDD,qBAAa,cAAe,SAAQ,YAAY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B;IAOpC;;;;;;;;OAQG;IACH,4BAA4B,IAAI,OAAO;IA8BvC,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAwCpC,SAAS,IAAI,OAAO;IAYpB;;;;;;OAMG;IACH,oBAAoB,IAAI,OAAO;IAM/B,kBAAkB,IAAI,IAAI;IAQ1B;;;;;;OAMG;IACH,iBAAiB,IAAI,OAAO;IAI5B;;;;;;;;;OASG;IACH,kBAAkB,IAAI,OAAO;IAI7B,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI/B;;;;;;;;OAQG;IACH,kCAAkC,IAAI,OAAO;IAK7C,SAAS,IAAI,OAAO;IAOpB,OAAO,CAAC,WAAW,CAAC,CAAqB;IACnC,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAEvE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAkF5B"}
@@ -44,6 +44,7 @@ const process_diagnostics_1 = require("./process-diagnostics");
44
44
  const managed_connectors_1 = require("./managed-connectors");
45
45
  const request_tool_capture_1 = require("./request-tool-capture");
46
46
  const container_1 = require("../orchestration/container");
47
+ const conversation_sandbox_1 = require("../apps/conversation-sandbox");
47
48
  const child_process_1 = require("child_process");
48
49
  const crypto_1 = require("crypto");
49
50
  const events_1 = require("events");
@@ -735,6 +736,33 @@ class SessionProcess extends events_1.EventEmitter {
735
736
  isContainerAgent() {
736
737
  return this.agentConfig.type === 'app-agent' && !!this.agentConfig.container;
737
738
  }
739
+ /** Isolate mode for an app agent (#609): this session executes in its conversation's
740
+ * own sandbox container, never in the shared app container. */
741
+ sandboxed() {
742
+ return (0, conversation_sandbox_1.usesConversationSandbox)(this.agentConfig);
743
+ }
744
+ /** The container this spawn executes in. A worker's driver already resolved its
745
+ * conversation's sandbox; anything else resolves its own conversation's here. */
746
+ async executionContainer(held) {
747
+ if (!this.sandboxed())
748
+ return this.agentConfig.container;
749
+ if (this.runtimeProfile?.role === 'worker') {
750
+ if (!(0, conversation_sandbox_1.isSandboxContainerName)(this.agentConfig.container))
751
+ throw Object.assign(new Error('Isolated worker has no conversation sandbox'), { code: 'CONTAINER_ISOLATION_REQUIRED' });
752
+ return this.agentConfig.container;
753
+ }
754
+ // Held until this spawn's process exits, so the sandbox is never reaped or replaced
755
+ // under it; a spawn that starts no process lets go of it (see spawnProcess).
756
+ held.lease = await conversation_sandbox_1.sandboxPool.acquire(this.agentConfig, { source: this.source, chatId: this.memoryChatId ?? this.chatId, sessionId: this.sessionId });
757
+ return held.lease.container;
758
+ }
759
+ /** Outside orchestration a sandbox has no `.sessions/` to read, so its conversation's
760
+ * memory is written into the sandbox's own /tmp, which no other conversation shares. */
761
+ async writeSandboxChatMemory(container) {
762
+ const file = `/tmp/gateway-session-${this.sessionId.replace(/[^\w.-]/g, '_')}/chat-memory.md`;
763
+ await (0, container_1.containerNode)(container, "const fs=require('fs'),path=require('path');let s='';process.stdin.on('data',b=>s+=b);process.stdin.on('end',()=>{fs.mkdirSync(path.dirname(process.argv[1]),{recursive:true,mode:448});fs.writeFileSync(process.argv[1],s,{mode:384});});", [file], this.chatMemory());
764
+ return file;
765
+ }
738
766
  /** A host path under the workspace as the app container sees it. */
739
767
  toContainerPath(hostPath) {
740
768
  return `/workspace/${path.relative(this.agentConfig.workspace, hostPath)}`;
@@ -770,7 +798,8 @@ class SessionProcess extends events_1.EventEmitter {
770
798
  // Orchestrators dispatch execution; only eligible workers receive connectors.
771
799
  // App and isolated workers must never receive host connector credentials
772
800
  // or start host-configured stdio servers inside their execution boundary.
773
- if (this.runtimeProfile.role === 'agent' || this.agentConfig.allow_tools === false || this.runtimeProfile.connectorsAllowed === false || this.agentConfig.type === 'app-agent' || (this.runtimeProfile.role === 'worker' && !this.runtimeProfile.hostExecution))
801
+ // Isolate mode (#609) is default-deny: connectors are agent-wide accounts.
802
+ if (this.runtimeProfile.role === 'agent' || this.agentConfig.allow_tools === false || this.runtimeProfile.connectorsAllowed === false || this.agentConfig.type === 'app-agent' || this.agentConfig.isolateMemory || (this.runtimeProfile.role === 'worker' && !this.runtimeProfile.hostExecution))
774
803
  return this.runtimeProfile.mcpConfigPath;
775
804
  const ticket = JSON.parse(fs.readFileSync(this.runtimeProfile.mcpConfigPath, 'utf8'));
776
805
  const { servers, connectors } = (0, managed_connectors_1.prepareManagedConnectors)(this.agentConfig, this.gatewayConfig, this.runtimeProfile, this.managedConnectorPaths);
@@ -787,14 +816,21 @@ class SessionProcess extends events_1.EventEmitter {
787
816
  }
788
817
  if (this.source === 'api' && !this.agentConfig.allow_tools)
789
818
  return null;
819
+ // A conversation sandbox (#609) gets no gateway MCP config at all: the config carries
820
+ // channel tokens and an API key, and the gateway server cannot run in the container.
821
+ if (this.sandboxed())
822
+ return null;
790
823
  const stateDir = path.join(this.agentConfig.workspace, '.telegram-state');
791
824
  const sessionDir = this.ensureSessionDir();
792
825
  const mcpServerPath = path.resolve(__dirname, '..', '..', 'mcp', 'server.ts');
793
826
  // Merge stdio servers from Claude Code user + project configs (project overrides user).
794
827
  // Skip the gateway's own server names from both — gateway always generates its own
795
828
  // config below (RESERVED_CONNECTOR_IDS; connector ids can no longer land here at all).
796
- const userServers = this.readUserScopedMcp();
797
- const projectServers = this.readProjectScopedMcp();
829
+ // Isolate mode (#609) is default-deny: the operator's own MCP servers and the
830
+ // agent's connectors act for every conversation, so none are injected.
831
+ const isolated = this.agentConfig.isolateMemory === true;
832
+ const userServers = isolated ? {} : this.readUserScopedMcp();
833
+ const projectServers = isolated ? {} : this.readProjectScopedMcp();
798
834
  const extraServers = {};
799
835
  for (const [name, server] of Object.entries({ ...userServers, ...projectServers })) {
800
836
  if (!(0, custom_1.isReservedConnectorId)(name))
@@ -803,7 +839,7 @@ class SessionProcess extends events_1.EventEmitter {
803
839
  // Connectors enabled for THIS agent AND connected (every secret present in
804
840
  // mcp-token.env). Resolved fresh each spawn so a web "connect" is picked up
805
841
  // without a daemon restart. Secrets land only in this 0600 mcp-config.json.
806
- const connectorServers = (0, resolve_1.resolveEnabledConnectors)(this.agentConfig, this.gatewayConfig.gateway.customConnectors, this.gatewayConfig.gateway.connectorsDefaultEnabled ?? true);
842
+ const connectorServers = isolated ? {} : (0, resolve_1.resolveEnabledConnectors)(this.agentConfig, this.gatewayConfig.gateway.customConnectors, this.gatewayConfig.gateway.connectorsDefaultEnabled ?? true);
807
843
  const spawnedConnectors = new Map();
808
844
  for (const [name, server] of Object.entries(connectorServers)) {
809
845
  // Defence in depth: slugify() and /oauth/receive both refuse these ids now,
@@ -884,10 +920,13 @@ class SessionProcess extends events_1.EventEmitter {
884
920
  GATEWAY_API_URL: process.env.GATEWAY_API_URL ?? `http://127.0.0.1:${process.env.PORT ?? '10850'}`,
885
921
  GATEWAY_API_KEY: this.findApiKeyForAgent(this.agentConfig.id),
886
922
  GATEWAY_ORIGIN_CHANNEL: this.source,
923
+ // Isolate mode (#609): channel tools refuse every chat but this one.
924
+ GATEWAY_ORIGIN_CHAT_ID: this.source === 'api' ? '' : this.chatId,
887
925
  GATEWAY_WORKSPACE_DIR: this.agentConfig.workspace,
888
926
  // Isolate mode (#601): the archive is one index for every conversation, so
889
927
  // the memory module turns its tools off instead of filtering them.
890
928
  GATEWAY_ISOLATE_MEMORY: this.agentConfig.isolateMemory ? '1' : '',
929
+ GATEWAY_DISABLE_ARCHIVE: this.agentConfig.disableArchive ? '1' : '',
891
930
  GATEWAY_SHARED_SKILLS_DIR: path.join(os.homedir(), '.claude-gateway', 'shared-skills'),
892
931
  // Shared KB vault dir (planning-64 K3), so memory_search corpus:"shared"
893
932
  // can reach the cross-agent vault. Empty when shared KB is disabled.
@@ -905,9 +944,11 @@ class SessionProcess extends events_1.EventEmitter {
905
944
  GATEWAY_RECORD_RETRIEVALS: this.resolveRecordRetrievals(),
906
945
  GATEWAY_SESSION_ID: this.sessionId,
907
946
  // For API sessions: absolute path to session media dir so browser screenshots land there
947
+ // Isolate mode (#609) confines a channel session's files to its own chat's
948
+ // media directory too (named like MediaStore.copyToMedia's).
908
949
  GATEWAY_SESSION_MEDIA_DIR: this.source === 'api'
909
950
  ? path.resolve(this.agentConfig.workspace, '..', 'media', `api-${this.sessionId}`)
910
- : '',
951
+ : isolated ? path.resolve(this.agentConfig.workspace, '..', 'media', `${this.source}-${this.chatId}`) : '',
911
952
  // Image-generation tool (generate_image) — targets an image provider that
912
953
  // may differ from the LLM: IMAGE_BASE_URL/IMAGE_API_KEY override, falling
913
954
  // back to ANTHROPIC_BASE_URL/ANTHROPIC_AUTH_TOKEN when they share a provider.
@@ -945,11 +986,19 @@ class SessionProcess extends events_1.EventEmitter {
945
986
  this.logger.debug('MCP config written', { sessionId: this.sessionId, servers: serverNames });
946
987
  return configPath;
947
988
  }
948
- /** Find the first API key that has access to this agent (agents: '*' or includes agentId). */
989
+ /** Find the first API key that has access to this agent (agents: '*' or includes agentId).
990
+ * An isolated agent (#609) only gets a non-admin key naming it: a wildcard or admin
991
+ * key reaches every conversation of every agent. */
949
992
  findApiKeyForAgent(agentId) {
950
993
  const keys = this.gatewayConfig.gateway.api?.keys;
951
994
  if (!keys?.length)
952
995
  return '';
996
+ if (this.agentConfig.isolateMemory) {
997
+ const scoped = keys.find(k => Array.isArray(k.agents) && k.agents.includes(agentId) && !k.admin)?.key;
998
+ if (!scoped)
999
+ this.logger.warn('Isolated agent has no non-admin API key naming it: gateway-API tools (api_reply, share_file, image/video, WhatsApp and WeChat replies) are unavailable', { agentId });
1000
+ return scoped ?? '';
1001
+ }
953
1002
  // Prefer a key scoped to this agent; fall back to wildcard or admin key.
954
1003
  const match = keys.find(k => (Array.isArray(k.agents) && k.agents.includes(agentId)) ||
955
1004
  k.agents === '*' ||
@@ -1021,7 +1070,7 @@ class SessionProcess extends events_1.EventEmitter {
1021
1070
  // workspace CLAUDE.md itself; this conversation's own USER.md/MEMORY.md
1022
1071
  // ride alongside it (see writeChatMemoryFile).
1023
1072
  if (this.chatMemoryPath)
1024
- args.push('--append-system-prompt-file', this.isContainerAgent() ? this.toContainerPath(this.chatMemoryPath) : this.chatMemoryPath);
1073
+ args.push('--append-system-prompt-file', this.isContainerAgent() && !this.sandboxed() ? this.toContainerPath(this.chatMemoryPath) : this.chatMemoryPath);
1025
1074
  // Enforce allow_tools:false as a real boundary. Gated on the SAME condition as
1026
1075
  // writeMcpConfig() (source==='api' && !allow_tools): those sessions get no MCP
1027
1076
  // server, but built-in tools would still run and could exfil owner secrets.
@@ -1049,6 +1098,20 @@ class SessionProcess extends events_1.EventEmitter {
1049
1098
  /** Resolves false when a stop() during its awaits abandoned the spawn: nothing was
1050
1099
  * started, and a container attempt it prepared is already cleaned up. */
1051
1100
  async spawnProcess() {
1101
+ // A sandbox lease this spawn took and has not handed to a process.
1102
+ const held = {};
1103
+ try {
1104
+ const started = await this.spawnProcessOnce(held);
1105
+ if (!started)
1106
+ held.lease?.release();
1107
+ return started;
1108
+ }
1109
+ catch (error) {
1110
+ held.lease?.release();
1111
+ throw error;
1112
+ }
1113
+ }
1114
+ async spawnProcessOnce(held) {
1052
1115
  const epoch = this.spawnEpoch;
1053
1116
  const { historyPrompt, loadedAtSpawn, archivedCount, messageCountAtSpawn } = await this.buildInitialPrompt();
1054
1117
  if (epoch !== this.spawnEpoch)
@@ -1057,11 +1120,23 @@ class SessionProcess extends events_1.EventEmitter {
1057
1120
  // Determine if this is a docker-exec app-agent before computing paths
1058
1121
  (0, container_1.assertContainerBinding)(this.agentConfig, this.runtimeProfile);
1059
1122
  const isAppAgent = this.isContainerAgent();
1123
+ let execContainer;
1124
+ try {
1125
+ execContainer = isAppAgent ? await this.executionContainer(held) : undefined;
1126
+ }
1127
+ catch (error) {
1128
+ if (epoch !== this.spawnEpoch)
1129
+ return false;
1130
+ throw error;
1131
+ }
1132
+ if (epoch !== this.spawnEpoch)
1133
+ return false;
1134
+ this.execContainer = execContainer;
1060
1135
  const freshModel = this.readFreshModel();
1061
1136
  let containerArgs;
1062
1137
  if (isAppAgent && this.runtimeProfile) {
1063
- const profile = this.runtimeProfile, container = this.agentConfig.container;
1064
- const attempt = await (0, container_1.prepareContainerProfile)(this.agentConfig, profile, async (directory) => {
1138
+ const profile = this.runtimeProfile, container = execContainer;
1139
+ const attempt = await (0, container_1.prepareContainerProfile)({ ...this.agentConfig, container }, profile, async (directory) => {
1065
1140
  // A worker's context arrives composed by its task driver, with the task's
1066
1141
  // own conversation's memory; only the Agent's is read from the container.
1067
1142
  if (this.composedContext === undefined) {
@@ -1082,7 +1157,9 @@ class SessionProcess extends events_1.EventEmitter {
1082
1157
  this.containerAttempt = attempt;
1083
1158
  }
1084
1159
  const mcpConfigPath = this.writeMcpConfig();
1085
- this.chatMemoryPath = this.writeChatMemoryFile();
1160
+ this.chatMemoryPath = this.sandboxed() && !this.runtimeProfile ? await this.writeSandboxChatMemory(execContainer) : this.writeChatMemoryFile();
1161
+ if (epoch !== this.spawnEpoch)
1162
+ return false;
1086
1163
  const effectiveMcpPath = (isAppAgent && mcpConfigPath) ? this.toContainerPath(mcpConfigPath) : mcpConfigPath;
1087
1164
  const containerRestartPath = isAppAgent ? this.toContainerPath(this.restartSignalPath) : this.restartSignalPath;
1088
1165
  const args = containerArgs ?? this.writeSystemPromptFile(this.buildArgs(effectiveMcpPath, freshModel), mcpConfigPath);
@@ -1190,7 +1267,10 @@ class SessionProcess extends events_1.EventEmitter {
1190
1267
  ...isolateEnvironment,
1191
1268
  GATEWAY_RESTART_SIGNAL_PATH: containerRestartPath,
1192
1269
  };
1193
- if (!this.runtimeProfile && process.env.GATEWAY_API_URL)
1270
+ // A conversation sandbox (#609) gets no gateway address or channel token: either
1271
+ // reaches past this conversation.
1272
+ const sandboxed = this.sandboxed();
1273
+ if (!this.runtimeProfile && !sandboxed && process.env.GATEWAY_API_URL)
1194
1274
  containerEnv.GATEWAY_API_URL = process.env.GATEWAY_API_URL;
1195
1275
  // Secrets are forwarded by NAME only (`-e KEY`, no `=value`), which makes
1196
1276
  // Docker read the value from this process's own environment (set on the spawn
@@ -1202,7 +1282,7 @@ class SessionProcess extends events_1.EventEmitter {
1202
1282
  // Claude credentials — it is a bearer token for the agent's whole bot
1203
1283
  // account. It is already placed in the spawn env below, unconditionally.
1204
1284
  const containerAuthEnv = isAppAgent || (this.runtimeProfile?.checkpointCommand && !this.runtimeProfile.hostExecution) ? this.resolveContainerAuthEnv() : {};
1205
- const byNameKeys = [...(this.runtimeProfile ? [] : ['TELEGRAM_BOT_TOKEN']), ...Object.keys(containerAuthEnv), ...Object.keys(configuredWorkerEnvironment)];
1285
+ const byNameKeys = [...(this.runtimeProfile || sandboxed ? [] : ['TELEGRAM_BOT_TOKEN']), ...Object.keys(containerAuthEnv), ...Object.keys(configuredWorkerEnvironment)];
1206
1286
  const dockerEnvFlags = [
1207
1287
  ...Object.entries(containerEnv).flatMap(([k, v]) => ['-e', `${k}=${v}`]),
1208
1288
  ...byNameKeys.flatMap((k) => ['-e', k]),
@@ -1213,7 +1293,7 @@ class SessionProcess extends events_1.EventEmitter {
1213
1293
  ? [
1214
1294
  'exec', '--workdir', '/workspace', '--user', String(containerUid), '-i',
1215
1295
  ...dockerEnvFlags,
1216
- this.agentConfig.container,
1296
+ execContainer,
1217
1297
  ...(this.containerAttempt ? ['node', '-e', container_1.CONTAINER_SUPERVISOR, this.containerAttempt.directory, this.agentConfig.claudeBin ?? claudeBin] : [this.agentConfig.claudeBin ?? claudeBin]),
1218
1298
  ...allArgs,
1219
1299
  ]
@@ -1286,6 +1366,12 @@ class SessionProcess extends events_1.EventEmitter {
1286
1366
  this.process = proc;
1287
1367
  const startsAtSpawn = this.starts;
1288
1368
  proc.once('exit', releaseCapacity);
1369
+ const lease = held.lease;
1370
+ held.lease = undefined;
1371
+ if (lease) {
1372
+ proc.once('exit', () => lease.release());
1373
+ proc.once('error', () => lease.release());
1374
+ }
1289
1375
  proc.once('exit', () => { setTimeout(() => toolCapture?.close(), 200).unref(); });
1290
1376
  proc.once('error', () => toolCapture?.close());
1291
1377
  proc.once('error', releaseCapacity);
@@ -2160,8 +2246,8 @@ class SessionProcess extends events_1.EventEmitter {
2160
2246
  let exited = false;
2161
2247
  const exit = proc ? new Promise(resolve => proc.once('exit', () => { exited = true; resolve(); })) : undefined;
2162
2248
  this.resetBackgroundDispatchState();
2163
- if (attempt && this.agentConfig.container) {
2164
- this.managedGroupStopped = await (0, container_1.stopContainerProfile)(this.agentConfig.container, attempt.directory);
2249
+ if (attempt && this.execContainer) {
2250
+ this.managedGroupStopped = await (0, container_1.stopContainerProfile)(this.execContainer, attempt.directory);
2165
2251
  if (this.containerAttempt === attempt)
2166
2252
  this.containerAttempt = undefined;
2167
2253
  }