@chibitek/chibi 0.1.209 → 0.1.211

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 (155) hide show
  1. package/dist/assets/{TerminalPanel-CHGq3udb.js → TerminalPanel-Dro3aeVy.js} +1 -1
  2. package/dist/assets/{abnfDiagram-O67JEVCF-BMaKhJ-b.js → abnfDiagram-O67JEVCF-kzAr7vQ8.js} +1 -1
  3. package/dist/assets/{arc-CYAiNWN8.js → arc-DKMhcYud.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-CxJFFlbO.js → architectureDiagram-NJMV4G6O-_XDnZ7Jz.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-C7AbPjRB.js → blockDiagram-BEXU5L5S-D5MoWro9.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-DfVnCJmT.js → c4Diagram-YGBWAQC7-CGvTMpGE.js} +1 -1
  7. package/dist/assets/channel-YcZdlysP.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-CzAUFkgv.js → chunk-2Q5K7J3B-pjTwr5y0.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-BgeBXphm.js → chunk-3FUC2YCW-BR6zkd-l.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-DPRdTAXc.js → chunk-5VM5RSS4-CfVFFBeH.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-BS-_dIVl.js → chunk-GTNCS2PH-TIoAkccw.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-D6I7xMmd.js → chunk-GWA4HPMP-BNFBgzbt.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-BKSKe7C9.js → chunk-JWPE2WC7-B_3QFchU.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-R48UYTRN.js → chunk-NETBCI7D-Cj9q80P-.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-C8z4mL-2.js → chunk-WEXAMYUT-DFZPGo9K.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-Bml3ZRJ5.js → chunk-XXDRQBXY-CekDrT9T.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-w5wo22FO.js → classDiagram-v2-NBCMYWYE-C3R6Z4Qe.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-Cum9v--4.js → cose-bilkent-JH36ORCC-C1CKyj0L.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-BzN0-KsP.js → cynefin-OW5HDTMX-Deh9QGb0.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-CkOpm32D.js → cynefinDiagram-VND7K2PF-BIlWyG_M.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-BItQkKZD.js → dagre-6A5THRUB-Dx4bWOog.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-BI0zDn7c.js → diagram-22UHCM2B-DPxb-FUO.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-jwcDxsu6.js → diagram-3UASUU5V-BLPCNc4m.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-2RnY9egJ.js → diagram-ATOU4E4O-DOCbp2Dw.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-eVdEZmEF.js → diagram-CDSNMT55-62uSG-tn.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-BCDGCJJ0.js → diagram-MLGK6HIB-De1ZAWVZ.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-DtN5uO5w.js → diagram-MPIPVDR6-CIGX9tku.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-B9GpXSEs.js → ebnfDiagram-ZINNZB2B-CegjStdk.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-Bk_eaK4T.js → elk-276RUBZZ-ClI52Pqm.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-BiGoW6C6.js → erDiagram-OPXOYQCR-BQuzjt2-.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-ZW5w0BaJ.js → flowDiagram-KWPJA3E3-D1xbKgbB.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-yyrKgsx1.js → ganttDiagram-FUAMR5RP-CH1jGSZz.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-CeiDikzD.js → gitGraphDiagram-X574FWY7-BvAUPEmQ.js} +1 -1
  34. package/dist/assets/{index-CZGnshrJ.js → index-BcXDfnlQ.js} +197 -197
  35. package/dist/assets/{index-DUFlRZuA.js → index-DbkR_erP.js} +1 -1
  36. package/dist/assets/index-H8vkXbLq.css +1 -0
  37. package/dist/assets/{infoDiagram-VRGFBTTK-q2B-KJFm.js → infoDiagram-VRGFBTTK-CyMmMbMv.js} +1 -1
  38. package/dist/assets/{ishikawaDiagram-OU5B5YK6-D8gXFuc0.js → ishikawaDiagram-OU5B5YK6-Uw-hE1tO.js} +1 -1
  39. package/dist/assets/{journeyDiagram-ZHPQQLJL-BmHL2mbq.js → journeyDiagram-ZHPQQLJL-ClEDnNRB.js} +1 -1
  40. package/dist/assets/{kanban-definition-PNTS6WVX-B9Ll2WkA.js → kanban-definition-PNTS6WVX-erx0BEal.js} +1 -1
  41. package/dist/assets/{linear-CMVGYrKx.js → linear-CSSxpyL0.js} +1 -1
  42. package/dist/assets/{mermaid.core-qO11n1kV.js → mermaid.core-n13K6vlC.js} +5 -5
  43. package/dist/assets/{mindmap-definition-NLK3R4M7-CxLGFX45.js → mindmap-definition-NLK3R4M7-BcTEIqpD.js} +1 -1
  44. package/dist/assets/{pegDiagram-GJSIUBJH-CxK1MJG4.js → pegDiagram-GJSIUBJH-CJdsm3en.js} +1 -1
  45. package/dist/assets/{pieDiagram-5QR66LMP-H5jiF5Eu.js → pieDiagram-5QR66LMP-C7rk-ash.js} +1 -1
  46. package/dist/assets/{quadrantDiagram-O4NWA36T-CKaqCruv.js → quadrantDiagram-O4NWA36T-BSXOYov0.js} +1 -1
  47. package/dist/assets/{railroadDiagram-XR7U4H2S-BCzKiQOd.js → railroadDiagram-XR7U4H2S-Cmg_FtZY.js} +1 -1
  48. package/dist/assets/{requirementDiagram-PLB6GJNP-Cqtr43DT.js → requirementDiagram-PLB6GJNP-B_9aE6Mg.js} +1 -1
  49. package/dist/assets/{sankeyDiagram-IPEJSGJF-B2tQewX8.js → sankeyDiagram-IPEJSGJF-DyxaQPy3.js} +1 -1
  50. package/dist/assets/{sequenceDiagram-PO4LG4MO-nggwQyrw.js → sequenceDiagram-PO4LG4MO-D5CJeESq.js} +1 -1
  51. package/dist/assets/{sizeCapture-INFHLROL-qSPXJBv2.js → sizeCapture-INFHLROL-9-Q4eosQ.js} +1 -1
  52. package/dist/assets/{stateDiagram-v2-GCMORJYK-DraPbL2T.js → stateDiagram-v2-GCMORJYK-jgsHnEQl.js} +1 -1
  53. package/dist/assets/{swimlanes-2SLR337P-C6HVkIDA.js → swimlanes-2SLR337P-MIVacUbv.js} +1 -1
  54. package/dist/assets/swimlanesDiagram-TC7HE7FX-Dekwo1KL.js +8 -0
  55. package/dist/assets/{timeline-definition-EJHVYXUP-DZmPRTsx.js → timeline-definition-EJHVYXUP-Ch8ins-D.js} +1 -1
  56. package/dist/assets/{usecaseDiagram-POWQR4AR-CsVuROW_.js → usecaseDiagram-POWQR4AR-BDwBIuhZ.js} +1 -1
  57. package/dist/assets/{vennDiagram-UO4OBE2U-B9IRbuhp.js → vennDiagram-UO4OBE2U-BiiDxcHO.js} +1 -1
  58. package/dist/assets/{wardleyDiagram-VNRHLVJA-CGmVK53n.js → wardleyDiagram-VNRHLVJA-D79CK2__.js} +1 -1
  59. package/dist/assets/{xychartDiagram-PMCCYNJV-BAw-x9Y1.js → xychartDiagram-PMCCYNJV-CI7S0o-6.js} +1 -1
  60. package/dist/index.html +4 -2
  61. package/dist-server/accounts-proxy.js +19 -12
  62. package/dist-server/browser-proxy.js +19 -14
  63. package/dist-server/container-mcp.js +165 -93
  64. package/dist-server/drivers/agents-proxy.js +109 -94
  65. package/dist-server/drivers/phone-proxy.js +21 -13
  66. package/dist-server/index.js +6487 -4926
  67. package/dist-server/local-computer-proxy.js +77 -11
  68. package/dist-server/local-computer.js +2 -1
  69. package/dist-server/mcp-gate.js +53 -4
  70. package/dist-server/mcp-server.js +1 -1
  71. package/dist-server/openmausbot.js +1068 -642
  72. package/dist-server/pair-cli.js +1068 -642
  73. package/dist-server/server/accounts-proxy.js +3 -17
  74. package/dist-server/server/atomic-engine-release.js +7 -0
  75. package/dist-server/server/auto-approve.js +12 -0
  76. package/dist-server/server/browser-proxy.js +3 -17
  77. package/dist-server/server/child-env.js +79 -0
  78. package/dist-server/server/config.js +11 -5
  79. package/dist-server/server/container-computer.js +1 -1
  80. package/dist-server/server/container-mcp.js +3 -2
  81. package/dist-server/server/control-client.js +7 -6
  82. package/dist-server/server/delegated-full-access.js +98 -0
  83. package/dist-server/server/desktop-loopback-gate.js +57 -0
  84. package/dist-server/server/drivers/acp/core.js +4 -4
  85. package/dist-server/server/drivers/acp/custom.js +3 -1
  86. package/dist-server/server/drivers/acp/hermes.js +2 -1
  87. package/dist-server/server/drivers/acp/session-key.js +8 -0
  88. package/dist-server/server/drivers/agents-client.js +2 -14
  89. package/dist-server/server/drivers/gcloud-token.js +28 -0
  90. package/dist-server/server/drivers/github-copilot.js +152 -0
  91. package/dist-server/server/drivers/hermes-context-floor.js +68 -0
  92. package/dist-server/server/drivers/openai-chat-protocol.js +8 -0
  93. package/dist-server/server/drivers/openai-chat.js +10 -8
  94. package/dist-server/server/drivers/openai-compat.js +44 -9
  95. package/dist-server/server/drivers/phone-proxy.js +5 -18
  96. package/dist-server/server/engine-tiers.js +9 -9
  97. package/dist-server/server/god-mode-goal.js +78 -0
  98. package/dist-server/server/god-mode-run-host.js +69 -0
  99. package/dist-server/server/harness/http.js +47 -1
  100. package/dist-server/server/index.js +86 -86
  101. package/dist-server/server/ladder-pick.js +18 -0
  102. package/dist-server/server/local-computer-proxy.js +3 -2
  103. package/dist-server/server/local-computer.js +1 -0
  104. package/dist-server/server/mcp-bridge.js +3 -2
  105. package/dist-server/server/mcp-gate.js +2 -1
  106. package/dist-server/server/mcp-registry.js +5 -1
  107. package/dist-server/server/model-fallback-repair.js +20 -0
  108. package/dist-server/server/model-gateway/failover.js +4 -1
  109. package/dist-server/server/model-gateway/route.js +64 -14
  110. package/dist-server/server/model-gateway/usage.js +66 -0
  111. package/dist-server/server/model-levels/aa-scale.js +42 -0
  112. package/dist-server/server/model-levels/aliases.js +16 -3
  113. package/dist-server/server/model-levels/index.js +8 -3
  114. package/dist-server/server/model-levels/rankings-build.js +76 -0
  115. package/dist-server/server/model-prices.js +6 -0
  116. package/dist-server/server/nexus-memory/index.js +5 -13
  117. package/dist-server/server/nexus-memory/policy.js +5 -17
  118. package/dist-server/server/oauth-account-vault.js +7 -2
  119. package/dist-server/server/personal-goal-runtime.js +29 -3
  120. package/dist-server/server/personal-goal-turn.js +2 -1
  121. package/dist-server/server/personal-goals.js +20 -2
  122. package/dist-server/server/provider-accounts.js +20 -1
  123. package/dist-server/server/provider-key-check.js +31 -1
  124. package/dist-server/server/registry-load.js +88 -0
  125. package/dist-server/server/request-auth.js +6 -28
  126. package/dist-server/server/routes/provider-accounts.js +124 -6
  127. package/dist-server/server/routine-daily-schedule.js +20 -0
  128. package/dist-server/server/routine-prompt-escape.js +18 -0
  129. package/dist-server/server/routine-tick-guard.js +16 -0
  130. package/dist-server/server/routine-tool-problems.js +36 -0
  131. package/dist-server/server/routines.js +36 -38
  132. package/dist-server/server/shutdown-triggers.js +18 -0
  133. package/dist-server/server/spend.js +23 -13
  134. package/dist-server/server/store.js +4 -13
  135. package/dist-server/server/terminal.js +2 -1
  136. package/dist-server/server/turn-token-file.js +79 -0
  137. package/dist-server/server/turn-token.js +23 -0
  138. package/dist-server/server/vps-container-mcp.js +3 -2
  139. package/dist-server/server/webhook-ingress.js +11 -1
  140. package/dist-server/server/webhook-prompt.js +82 -0
  141. package/dist-server/server/webhooks.js +8 -65
  142. package/dist-server/server/workspace-backup-policy.js +3 -3
  143. package/dist-server/server/workspace-backup.js +1 -1
  144. package/dist-server/server/workspace-time-zone.js +47 -0
  145. package/dist-server/shared/engine-choices.js +12 -1
  146. package/dist-server/shared/god-mode-run.js +173 -0
  147. package/dist-server/shared/personal-goal.js +42 -0
  148. package/dist-server/shared/provider-accounts.js +114 -2
  149. package/dist-server/shared/zoned-time.js +55 -0
  150. package/dist-server/vps-container-mcp.js +165 -93
  151. package/package.json +1 -1
  152. package/dist/assets/channel-DxL_mLhm.js +0 -1
  153. package/dist/assets/index-Bi3hprmz.css +0 -1
  154. package/dist/assets/swimlanesDiagram-TC7HE7FX-gQUGsELo.js +0 -8
  155. package/dist-server/server/agents-token-file.js +0 -26
@@ -9,6 +9,7 @@ import { createModelExpectation, ModelEvidenceLedger, standInReason } from "./mo
9
9
  import { reactToMessage } from "./message-reactions.js";
10
10
  import { hasUnboundGoalGuard, goalGuardForEvent, addGoalGuard, removeGoalGuard, runPersonalGoalTurn, updatePersonalGoalReceipt } from "./personal-goal-turn.js";
11
11
  import { PersonalGoalRuntime, receiveGoalCommand } from "./personal-goal-runtime.js";
12
+ import { godModeRunOn, godModeRunOutPolicy, godModeRunOverrides, handleGodModeRunRequest } from "./god-mode-run-host.js";
12
13
  import { personalGoalInstructions } from "./personal-goals.js";
13
14
  import { parseGoalCommand } from "../shared/personal-goal.js";
14
15
  // OpenMausBot server — the harness host. Clients hold no transports
@@ -91,8 +92,8 @@ import { accountBilling } from "./plan-credit.js";
91
92
  import { appendUsage, isUsageOwnerFilter, parseUsageRange, readUsage, summarizeUsage, usageCsv, usageForOwner, USAGE_GROUPINGS, flushUsageLedger } from "./usage-ledger.js";
92
93
  import { GroupUsageReader } from "./group-thread-usage.js";
93
94
  import { ledgerCost } from "./model-prices.js";
94
- import { checkProviderKey, openAiTeamHeaders, PROVIDER_KEY_KINDS } from "./provider-key-check.js";
95
- import { assertWithinBudget, noteSpend, spendAlertText, spendState, takeSpendAlert } from "./spend.js";
95
+ import { checkProviderKey, configuredProviderUrls, openAiTeamHeaders, pastedKeyTestUrl, PROVIDER_KEY_KINDS } from "./provider-key-check.js";
96
+ import { assertWithinBudget, noteSpend, spendAlertText, spendState, takeSpendAlert, workspaceTimeZone, workspaceTimeZoneStatus } from "./spend.js";
96
97
  import { fleetAvailable, fleetRequest, fleetSocketPath } from "./fleet-client.js";
97
98
  import { HOSTED_CONTRACT_HEADER, HOSTED_CONTRACT_METADATA, HOSTED_CONTRACT_VERSION } from "./hosted-contract.js";
98
99
  import { describeSpawnFailure, execCli } from "./procs.js";
@@ -118,6 +119,7 @@ import { exchangeChannel, mirrorActivity, mirrorExchange, mirrorReply } from "./
118
119
  import { findMessageInThreads, readMessageText, recallMessages, recentMessages, searchMessages, closeMessageDb, chatFollowups, cancelledChatFollowup, settleChatFollowups, threadsReferencing, readCommandReceipt, withCommandReceipt } from "./message-db.js";
119
120
  import { briefCrossingLabel, claimRecallCrossings, recallCrossingLabel } from "./recall-disclosure.js";
120
121
  import { parseSince, parseUntil, recentWork, recentWorkPrompt, turnOutcomeLine } from "./recent-work.js";
122
+ import { refusedModelLine, repairRefusedModel } from "./model-fallback-repair.js";
121
123
  import { chiefForBot, INCIDENTS_THREAD_TITLE, IncidentLedger, incidentChip, incidentText, runWentOn } from "./incidents.js";
122
124
  /** A session_read answer competes with the transcript for the context
123
125
  * window; a computer-use turn's output can run to hundreds of KB. */
@@ -236,6 +238,7 @@ import { modelContextWindow } from "./model-context-window.js";
236
238
  import { autoPinMayYield, autoPinMovedLine, parseSurface, resolveSurface, surfaceLabel, surfaceOfComputerKind, surfacePrompt } from "./surface.js";
237
239
  import { PendingTurnCancellations, ProviderTurnGenerationRegistry, RetiredTurnRegistry, guardTurnDispatch, isTurnAdmissionBlocked, isTurnEventQuarantined, } from "./turn-dispatch-guard.js";
238
240
  import { createGracefulShutdown } from "./graceful-shutdown.js";
241
+ import { installShutdownTriggers } from "./shutdown-triggers.js";
239
242
  import { acquireDataDirLeaseForProcess } from "./data-dir-lease.js";
240
243
  import { createWorkspaceAccess, describeEdition, entitled, editionStatus, hostedWorkspaceConfiguration, hostedWorkspaceConfigured, editionForMembers, LICENSE_WARN_DAYS, licenseWarning, sharedWorkspaceFullAccessConfigured, loadEnterpriseLayer, workspaceMembership } from "./enterprise.js";
241
244
  import { environmentDescriptor, loadEnvironmentId, serverVersion } from "./environment.js";
@@ -247,7 +250,7 @@ import { allowedScopes, createEmailSignIn, parseAllowList } from "./account-sign
247
250
  import { ProviderAuthSessions } from "./provider-auth-sessions.js";
248
251
  import { clearSessionCookie, clientBotPatchViolation, bearerToken, clientGroupPatchViolation, clientTaskPatchViolation, isLoopbackHost, isProxied, labelFromUserAgent, requestOrigin, requestSource, requiredScope, resolveLoopbackTrust, resolveRequestAuth, parseCookies, serializeSessionCookie, sessionCookieName, } from "./request-auth.js";
249
252
  import { cookieMaxAgeSeconds, formatPairingCode, SessionRegistry } from "./sessions.js";
250
- import { writeAgentsTokenFile } from "./agents-token-file.js";
253
+ import { controlTurnToken, forgetThreadTurnTokens, turnTokenEnv, writeAgentsTokenFile } from "./turn-token-file.js";
251
254
  import { editorHasEntry, editorInstalled, editorTarget, editorTargets, registerWithEditor, unregisterFromEditor } from "./editor-connect.js";
252
255
  import { claudeCodeHasEntry, claudeCodeMcpEntry, registerWithClaudeCode, unregisterFromClaudeCode } from "./claude-code-connect.js";
253
256
  import { appendAssistantAudit, ASSISTANT_TOKEN_PREFIX, assistantSenderId, ConnectedAssistants, isAssistantSender, withAssistantProvenance, recentAssistantAudit, removeAssistantToken, writeAssistantToken } from "./connected-assistants.js";
@@ -260,7 +263,8 @@ import { DeviceRouteRegistry, removeStream } from "./device-routing.js";
260
263
  import { PHONE_SECRET_PROTOCOL_VERSION, PhoneSecretBridge, PhoneSecretError, PhoneSecretSubmissionRegistry, assertPhoneSecretRequestMatches, phoneSecretOperationId, } from "./phone-secret.js";
261
264
  // Keep these two last: a route module may import any server module, and
262
265
  // loading the table after everything above leaves module start-up order as is.
263
- import { json, onJsonBody, parsedBodyOf, readBody } from "./harness/http.js";
266
+ import { crossSiteMutation, json, onJsonBody, parsedBodyOf, readBody, staticHeaders } from "./harness/http.js";
267
+ import { DelegatedFullAccess, delegatedFullAccessActive, delegatedFullAccessLabel } from "./delegated-full-access.js";
264
268
  import { BotWorkModes, createBotWorkModeRoutes, ownBotApprovalMode, legacyGodModeCovers, dispatchWorkMode, trustedPlanChangeForStore, invalidAllThreadScope } from "./bot-work-modes.js";
265
269
  import { ROUTES, dispatchRoutes } from "./routes/table.js";
266
270
  import { createThreadStopRoutes } from "./routes/thread-stop.js";
@@ -279,7 +283,7 @@ import { totalmem } from "node:os";
279
283
  import { loadInstanceKeys } from "./instance-keys.js";
280
284
  import { createProviderAccountRoutes } from "./routes/provider-accounts.js";
281
285
  import { accountStops, failureRestScope, injectedModel, modelScope, restScope } from "./injected-model-rest.js";
282
- import { accountProvider } from "../shared/provider-accounts.js";
286
+ import { accountProvider, keylessAccount } from "../shared/provider-accounts.js";
283
287
  import { createAccountRoutes } from "./routes/accounts.js";
284
288
  import { installNativeVault } from "./vault/runtime.js";
285
289
  import { installWorkspaceSecrets } from "./workspace-backup-secrets.js";
@@ -300,7 +304,7 @@ import { createEngineTierRoutes } from "./routes/engine-tiers.js";
300
304
  import { createModelGatewayRoutes } from "./model-gateway/route.js";
301
305
  import { applyChibiDefaults, chibiDefaultSelection } from "./chibi-defaults.js";
302
306
  import { createPrimaryBotRoutes } from "./routes/primary-bot.js";
303
- import { EngineSnapshotCache, botTier, canDriveComputer, classLadder, engineAccount, engineHealth, engineLabel, engineTierClasses, engineTierLadders, failoverClassOrder, engineTiersIncludeFree, generateLadders, handlesClientData, ladderForClass, keyBased, needsDelegation, resolveFailover, resolveLadder } from "./engine-tiers.js";
307
+ import { EngineSnapshotCache, botTier, canDriveComputer, classLadder, engineAccount, engineHealth, engineLabel, engineTierClasses, engineTierLadders, failoverClassOrder, engineTiersIncludeFree, generateLadders, handlesClientData, ladderForClass, keyBased, needsDelegation, needsWiderWalk, resolveFailover, takeWider, resolveLadder } from "./engine-tiers.js";
304
308
  import { PRIMARY_BOT_THREAD_TITLE, PRIMARY_BOT_TRIGGER, PrimaryBotStore, routesAsSweep, PrimaryBotSweeper } from "./primary-bot.js";
305
309
  import { PRIMARY_BOT_LOCKED, primaryBotChoiceField, isPrimaryBot } from "../shared/primary-bot.js";
306
310
  import { moveIntoChibi } from "./move-into-chibi.js";
@@ -328,7 +332,7 @@ import { createBoardRoutes } from "./routes/board.js";
328
332
  import { readBoardFromNexus } from "./board/nexus-board.js";
329
333
  import { LocalModelInventory, localModePlacement, machineMemory } from "./local-models-mode.js";
330
334
  import { eventBase, restTime, FailoverGate, triesSpent, continuationNote, restingLine, restingOnRoute, sameRoute } from "./engine-failover.js";
331
- import { connectionRunOutPolicy, finalizeConnectionCapPick, finalizeNewTurnPlacement, pauseKeyBandForRunOut } from "./connection-cap-failover.js";
335
+ import { finalizeConnectionCapPick, finalizeNewTurnPlacement, pauseKeyBandForRunOut } from "./connection-cap-failover.js";
332
336
  import { TURN_ERROR_CATEGORIES } from "../shared/runtime-events.js";
333
337
  import { EngineProbes, PROBE_PROMPT, isProbeThread, probeThreadId } from "./engine-probe.js";
334
338
  // [jev-verifier] opt-in Jev answer checks after a model switch (server/jev).
@@ -1580,8 +1584,7 @@ function agentsIntegration(botId, threadId, depth, skillAuthoring, generation, r
1580
1584
  roomCoordination,
1581
1585
  ownThreadCreation,
1582
1586
  });
1583
- // Also on disk, read per call: an engine keeps the proxy process across
1584
- // turns, so the spawn environment alone goes stale (agents-token-file.ts).
1587
+ // An engine keeps the proxy across turns: spawn env goes stale (turn-token-file.ts).
1585
1588
  const tokenFile = writeAgentsTokenFile(botId, threadId, token);
1586
1589
  return {
1587
1590
  command: process.execPath,
@@ -2094,7 +2097,7 @@ async function browserIntegration(botId, profile, turn) {
2094
2097
  kind: "browser", depth: 0, skillAuthoring: false, createdBots: 0, openedThreads: 0 });
2095
2098
  return { profile: partitionId, session, spec, integration: {
2096
2099
  command: process.execPath, args: [SPAWNED_PROXIES.browser], env: {
2097
- ...AGENTS_NODE_FLAG, OMB_BROWSER_TOKEN: token, OMB_BROWSER_TOKEN_FILE: writeAgentsTokenFile(botId, turn.threadId, token, undefined, "browser"), OMB_HARNESS_URL: `http://127.0.0.1:${PORT}`,
2100
+ ...AGENTS_NODE_FLAG, ...turnTokenEnv("browser", "OMB_BROWSER_TOKEN", botId, turn.threadId, token), OMB_HARNESS_URL: `http://127.0.0.1:${PORT}`,
2098
2101
  },
2099
2102
  } };
2100
2103
  }
@@ -2125,7 +2128,7 @@ function phoneIntegration(botId, threadId, generation) {
2125
2128
  });
2126
2129
  const env = {
2127
2130
  ...AGENTS_NODE_FLAG,
2128
- OMB_PHONE_TOKEN: token, OMB_PHONE_TOKEN_FILE: writeAgentsTokenFile(botId, threadId, token, undefined, "phone"),
2131
+ ...turnTokenEnv("phone", "OMB_PHONE_TOKEN", botId, threadId, token),
2129
2132
  OMB_HARNESS_URL: `http://127.0.0.1:${PORT}`,
2130
2133
  };
2131
2134
  if (process.env.OMB_ADB_PATH)
@@ -2153,7 +2156,7 @@ function accountsIntegration(botId, threadId, generation) {
2153
2156
  return {
2154
2157
  command: process.execPath,
2155
2158
  args: [SPAWNED_PROXIES.accounts],
2156
- env: { ...AGENTS_NODE_FLAG, OMB_ACCOUNTS_TOKEN: token, OMB_ACCOUNTS_TOKEN_FILE: writeAgentsTokenFile(botId, threadId, token, undefined, "accounts"), OMB_HARNESS_URL: `http://127.0.0.1:${PORT}` },
2159
+ env: { ...AGENTS_NODE_FLAG, ...turnTokenEnv("accounts", "OMB_ACCOUNTS_TOKEN", botId, threadId, token), OMB_HARNESS_URL: `http://127.0.0.1:${PORT}` },
2157
2160
  readOnlyTools: ACCOUNT_TOOLS.filter((tool) => isReadOnlyAccountTool(tool.name)).map((tool) => tool.name),
2158
2161
  askTools: ACCOUNT_TOOLS.filter((tool) => !isReadOnlyAccountTool(tool.name)).map((tool) => tool.name),
2159
2162
  };
@@ -2222,7 +2225,7 @@ const routineRequestEnvelopeSchema = z.discriminatedUnion("action", [
2222
2225
  function controlIntegration(botId, threadId, generation, localVmTarget) {
2223
2226
  return {
2224
2227
  url: `http://127.0.0.1:${PORT}/api/internal/computer-control?botId=${encodeURIComponent(botId)}`,
2225
- token: mintInternalCapability({
2228
+ ...controlTurnToken(botId, threadId, localVmTarget, mintInternalCapability({
2226
2229
  botId,
2227
2230
  threadId,
2228
2231
  generation,
@@ -2233,7 +2236,7 @@ function controlIntegration(botId, threadId, generation, localVmTarget) {
2233
2236
  skillAuthoring: false,
2234
2237
  createdBots: 0,
2235
2238
  openedThreads: 0,
2236
- }),
2239
+ })),
2237
2240
  };
2238
2241
  }
2239
2242
  function askBotAndWait(targetBotId, message, depth, fromBotId, fromThreadId, targetThreadId) {
@@ -2351,7 +2354,7 @@ const tierCandidates = (described) => {
2351
2354
  // flat plan used through a key (the Qwen Coding Plan) is a subscription.
2352
2355
  // Ollama Team's included credit decides while it lasts (server/plan-credit.ts).
2353
2356
  const billing = accountBilling(instance.instanceId, configs[instance.instanceId], DATA_DIR);
2354
- return billing ? { ...instance, billing } : instance;
2357
+ return billing ? { ...instance, billing, ...(keylessAccount(configs[instance.instanceId]?.account) ? { keyless: true } : {}) } : instance;
2355
2358
  });
2356
2359
  };
2357
2360
  /** Engine tiers choose a turn's engine synchronously, from the engines as
@@ -3080,9 +3083,8 @@ function turnEngineChoice(botId, threadId, needs, runOn) {
3080
3083
  const task = store.taskByThread(botId, threadId);
3081
3084
  if (hostedModels || !profile || !task)
3082
3085
  return undefined;
3083
- // A subscription bot runs only on its own provider: with no account of it
3084
- // free the turn stops with its one line (Erick, 2026-11-13).
3085
- if (isSubscriptionBot(profile))
3086
+ // A subscription bot runs only on its own provider (Erick, 2026-11-13); a GOD MODE run may leave it when it is blocked.
3087
+ if (isSubscriptionBot(profile) && !godModeRunOverrides(personalGoals.goals, threadId, "provider-restriction", "left the bot's own provider for another engine."))
3086
3088
  return subscriptionTurnEngineChoice(profile, threadId);
3087
3089
  if (isPersonalBot(profile))
3088
3090
  return personalTurnEngineChoice(profile, threadId, needs, runOn);
@@ -3128,15 +3130,15 @@ function ladderTurnEngineChoice(profile, projected, threadId, needs, runOn, subs
3128
3130
  // unless that engine is resting.
3129
3131
  // An own engine that cannot drive the turn's computer is as good as resting.
3130
3132
  const ownOut = Boolean(own && (engineResting(own, projected.modelSelection.model) || !canDriveComputer(own, computer)));
3131
- if (resolution.choice?.band === "key" || (!resolution.choice && ownOut)) {
3133
+ if (needsWiderWalk(resolution.choice, ownOut)) {
3132
3134
  const across = wider(new Set(), plan.modelClass);
3133
- if (across.choice?.band === "subscription" || !resolution.choice)
3135
+ if (takeWider(resolution.choice, across.choice))
3134
3136
  resolution = across;
3135
3137
  }
3136
3138
  if (!resolution.choice && own && ownOut && !resolution.skipped.some((skip) => skip.reason === "paused")) {
3137
3139
  throw restingStop(candidates, resolution.skipped, own.instanceId, computer);
3138
3140
  }
3139
- return placedTurn(local(resolution), true);
3141
+ return placedTurn(local(resolution), true, threadId);
3140
3142
  }
3141
3143
  // A pinned engine the last registry refresh reports signed out is treated
3142
3144
  // as a failed sign-in up front, rather than spawned only to fail.
@@ -3166,7 +3168,7 @@ function ladderTurnEngineChoice(profile, projected, threadId, needs, runOn, subs
3166
3168
  if (!resolution.choice && engineResting(own, projected.modelSelection.model) && !resolution.skipped.some((skip) => skip.reason === "paused")) {
3167
3169
  throw restingStop(candidates, resolution.skipped, own.instanceId, computer);
3168
3170
  }
3169
- return placedTurn(local(resolution), false);
3171
+ return placedTurn(local(resolution), false, threadId);
3170
3172
  }
3171
3173
  /** An engine that is unavailable because its command-line program is not on
3172
3174
  * this computer: Atomic Engine on a PC that never had `atomic`, a CLI since
@@ -3269,7 +3271,7 @@ function dictationSubscription() {
3269
3271
  /** The key band is closed to a sweep unless the person chose "Keep going"
3270
3272
  * (or local mode, which turns a key choice into a local model). */
3271
3273
  function keyBandPausedFor(threadId) {
3272
- return pauseKeyBandForRunOut({ policy: connectionRunOutPolicy(cfg.engineTiers), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
3274
+ return pauseKeyBandForRunOut({ policy: runOutPolicy(threadId), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
3273
3275
  pausedUntil: payPerUse.pausedUntil(), localUntil: payPerUse.localUntil(), sweep: isSweepTurn(threadId) });
3274
3276
  }
3275
3277
  /** The sweep turn's engine, or null when nothing it may use is free. `note`
@@ -3303,7 +3305,7 @@ function sweepEngineChoice(botId, threadId, note, runOn) {
3303
3305
  return { selection: projected.modelSelection, persist: false };
3304
3306
  }
3305
3307
  // Nothing on a subscription: a local model in local mode, a key only after "Keep going".
3306
- const keysAllowed = payPerUse.current()?.keptGoingAt !== undefined && payPerUse.pausedUntil() === undefined;
3308
+ const keysAllowed = (payPerUse.current()?.keptGoingAt !== undefined || godModeRunOn(personalGoals.goals, threadId)) && payPerUse.pausedUntil() === undefined;
3307
3309
  if (payPerUse.localUntil() === undefined && !keysAllowed)
3308
3310
  return null;
3309
3311
  const context = { ...base, keyBandPaused: payPerUse.pausedUntil() !== undefined };
@@ -3316,16 +3318,17 @@ function sweepEngineChoice(botId, threadId, note, runOn) {
3316
3318
  }
3317
3319
  /** A turn start's ladder walk, as startTurn uses it: noted for pay-per-use,
3318
3320
  * refused before an unapproved paid key, or when pay-per-use is paused. */
3319
- function placedTurn(resolution, persist) {
3321
+ function placedTurn(resolution, persist, threadId) {
3320
3322
  return finalizeNewTurnPlacement({
3321
- policy: connectionRunOutPolicy(cfg.engineTiers), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
3323
+ policy: runOutPolicy(threadId), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
3322
3324
  local: resolution.local, choice: resolution.choice, skipped: resolution.skipped, pausedUntil: payPerUse.pausedUntil(),
3323
3325
  currentLabel: "A subscription", formatTime: restTime, persist, pausedLine: payPerUsePausedLine,
3324
3326
  announceWaiting: () => notePayPerUse({ skipped: resolution.skipped, local: true, choice: { band: "key", selection: { instanceId: "", model: "" }, candidate: { instanceId: "" }, step: 0 } }),
3325
3327
  book: () => notePayPerUse(resolution),
3326
3328
  });
3327
3329
  }
3328
- // ── pay-per-use (docs/chibitek/engine-tiers.md, "Pay-per-use notice") ────
3330
+ // ── pay-per-use (docs/chibitek/engine-tiers.md, "Pay-per-use notice"); a GOD MODE run is Keep going for its conversation ──
3331
+ const runOutPolicy = (threadId) => godModeRunOutPolicy(personalGoals.goals, threadId, cfg.engineTiers);
3329
3332
  // The one thing about engines and billing the person hears of: a paid key is used only after stored approval
3330
3333
  // when every subscription is resting, signed out or unavailable. That opens an episode, announced once;
3331
3334
  // a turn a subscription answers ends it (noteEngineBack). Ollama Cloud is a subscription.
@@ -3618,8 +3621,8 @@ bus.setGate((published) => {
3618
3621
  noteEngineBack(out);
3619
3622
  return delivered;
3620
3623
  });
3621
- /** An engine finished a turn: a rest of it that has ended is marked back
3622
- * (the rest history's `backAt`, docs/chibitek/engine-tiers.md). */
3624
+ /** An engine finished a turn: a rest of it that has ended is marked back (the rest history's `backAt`,
3625
+ * docs/chibitek/engine-tiers.md). A local-mode turn on a subscription engine is not that subscription back. */
3623
3626
  function noteEngineBack(event) {
3624
3627
  const instanceId = event.providerInstanceId;
3625
3628
  if (!instanceId)
@@ -3629,7 +3632,7 @@ function noteEngineBack(event) {
3629
3632
  const model = selection?.instanceId === instanceId ? selection.model : undefined;
3630
3633
  for (const scope of new Set([candidate ? restScope(candidate, model) : undefined, modelScope(model)]))
3631
3634
  engineRests.noteBack(instanceId, candidate ? engineAccount(candidate) : undefined, scope);
3632
- if (candidate && !keyBased(candidate) && !freeCandidate(candidate) && !(model && perTokenModel(candidate, model)))
3635
+ if (candidate && !keyBased(candidate) && !freeCandidate(candidate) && !(model && (perTokenModel(candidate, model) || injectedModel(model) || isLocalModel(candidate, model))))
3633
3636
  (instanceOwner(instanceId) === "personal" ? personalPayPerUse : payPerUse).subscriptionAnswered();
3634
3637
  }
3635
3638
  /** Rest a refused engine and continue on an eligible engine, or show an actionable line. */
@@ -3851,7 +3854,7 @@ function failoverPick(turn, profile, projected, candidates, failedCandidate, res
3851
3854
  // A subscription bot fails over only to another account of its own
3852
3855
  // provider on its side of the personal line; with none left it stops with
3853
3856
  // its one line.
3854
- const subscriptionMove = isSubscriptionBot(profile)
3857
+ const subscriptionMove = isSubscriptionBot(profile) && !godModeRunOverrides(personalGoals.goals, turn.threadId, "provider-restriction", "left the bot's own provider for another engine.")
3855
3858
  ? triesSpent(tried) || !projected
3856
3859
  ? { line: subscriptionLine(profile, candidates) }
3857
3860
  : subscriptionPlacement({ profile, projected, candidates, tried: new Set([...tried, turn.instanceId]), auto: attempt.persist, modelClass: neededClass })
@@ -3899,7 +3902,7 @@ function failoverPick(turn, profile, projected, candidates, failedCandidate, res
3899
3902
  pausedUntil: payPerUse.pausedUntil(), skipped: resolution.skipped, payPerUsePausedLine, restingNamed,
3900
3903
  failedInstanceId: turn.instanceId, alreadyTried: attempt.tried, triedCount: tried.size,
3901
3904
  cannotDrive: cannotDriveNamed(candidates, resolution.skipped, computer),
3902
- policy: connectionRunOutPolicy(cfg.engineTiers), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
3905
+ policy: runOutPolicy(turn.threadId), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
3903
3906
  local: Boolean(placed.local), currentLabel: engineLabel(candidates, attempt.selection),
3904
3907
  nextLabel: choice ? engineLabel(candidates, choice.selection) : undefined,
3905
3908
  nextBand: choice && "band" in choice ? choice.band : undefined, resetAt: turn.failure?.resetAt, formatTime: restTime,
@@ -4075,7 +4078,7 @@ function engineTierRefusal(bot, options = {}) {
4075
4078
  if (!options.ignoreOwner && !ownerAllows(bot, ownerCheck(candidate), false))
4076
4079
  return "owner";
4077
4080
  // A subscription bot never leaves its provider (server/subscription-bots.ts).
4078
- if (!providerAllows(bot, candidate, subscriptionFacts))
4081
+ if (!providerAllows(bot, candidate, subscriptionFacts) && !godModeRunOn(personalGoals.goals, bot.threadId))
4079
4082
  return "provider";
4080
4083
  if (candidate.instanceId !== bot.modelSelection.instanceId && modelSwitchNeedsAsk(mode, from, candidate.driverKind, godModeCovers(bot)))
4081
4084
  return "approval";
@@ -4435,7 +4438,7 @@ function previewSystemPrompt(bot, opts = {}) {
4435
4438
  async function botOverview(bot) {
4436
4439
  const engine = registry.get(bot.modelSelection.instanceId)?.adapter.capabilities ?? null;
4437
4440
  const sectionPeers = reachablePeers(store.bots, bot).filter((peer) => !isPersonalBot(peer)).length;
4438
- const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
4441
+ const timeZone = workspaceTimeZone();
4439
4442
  // Same flush as GET /history: profile-change rows queue in
4440
4443
  // profile-versions.ts and land asynchronously, so a client checking the
4441
4444
  // overview right after causing a change must see its own row.
@@ -4496,11 +4499,16 @@ async function botOverview(bot) {
4496
4499
  const botWorkModes = new BotWorkModes(join(DATA_DIR, "bot-work-modes.json"));
4497
4500
  for (const id of botWorkModes.expired(id => sessions.isLive(id)))
4498
4501
  store.setAllThreadApprovalMode(id, "ask", true);
4499
- const approvalModeForTurn = (bot, peerInitiated = false) => godModeElevates(bot) ? "full" : ownApprovalModeForTurn(bot, peerInitiated);
4500
- /** The bot's (or thread's) own level for a turn, GOD MODE aside. */
4501
- const ownApprovalModeForTurn = (bot, peerInitiated = false) => ownBotApprovalMode(bot, registry.cliTarget(bot.modelSelection.instanceId)?.driverKind, peerInitiated, botWorkModes.permits(approvalModeFor(bot)));
4502
+ const delegatedFull = new DelegatedFullAccess(join(DATA_DIR, "delegated-full-access.json"));
4503
+ for (const stale of delegatedFull.reconcile(store.bots, id => store.messagesFor(id)))
4504
+ store.patchTask(stale.botId, stale.threadId, { approvalMode: "ask", autoApprove: false, alwaysAllow: [] });
4505
+ const approvalModeForTurn = (bot, peerInitiated = false) => godModeRunOn(personalGoals.goals, bot.threadId) ? "ask" : godModeElevates(bot) ? "full" : ownApprovalModeForTurn(bot, peerInitiated); // a run's every call reaches the harness, which approves it unless a hard limit applies
4506
+ /** The bot's (or thread's) own level for a turn, GOD MODE aside. A thread a
4507
+ * Chief delegated into is Full only while that Chief's conversation still is
4508
+ * (`derived`); nothing is saved on the thread, so it ends when the source does. */
4509
+ const ownApprovalModeForTurn = (bot, peerInitiated = false, derived = true) => derived && botWorkModes.permits("full") && delegatedFullAccessActive(bot.threadId, { source: id => delegatedFull.source(id), stillGrants: source => Boolean(store.bot(source.botId) && delegatedFullAccess(store.bot(source.botId), source.threadId, bot)) }) ? "full" : ownBotApprovalMode(bot, registry.cliTarget(bot.modelSelection.instanceId)?.driverKind, peerInitiated, botWorkModes.permits(approvalModeFor(bot)));
4502
4510
  function godModeCovers(bot) {
4503
- return legacyGodModeCovers(bot, godModeActive() && botWorkModes.permits("full"), botWorkModes.selected(bot.id) !== undefined);
4511
+ return legacyGodModeCovers(bot, godModeActive() && botWorkModes.permits("full"), botWorkModes.selected(bot.id) !== undefined && !godModeRunOn(personalGoals.goals, bot.threadId));
4504
4512
  }
4505
4513
  /** GOD MODE runs this bot or thread at Full, whatever its own level says:
4506
4514
  * it is covered (godModeCovers) and its engine implements Full. */
@@ -4537,7 +4545,7 @@ function fullAccessForSource(botId, threadId, { ownLevel = false } = {}) {
4537
4545
  return false;
4538
4546
  const bot = store.projectBotForTask(botId, threadId) ?? owner.bot;
4539
4547
  // Origin changes Custom to Auto, never Full; no live-turn state is needed.
4540
- return (ownLevel ? ownApprovalModeForTurn(bot) : approvalModeForTurn(bot)) === "full";
4548
+ return (ownLevel ? ownApprovalModeForTurn(bot, false, false) : approvalModeForTurn(bot)) === "full";
4541
4549
  }
4542
4550
  function peerReviewRequired(bot, threadId) {
4543
4551
  return Boolean(bot.approvePeerComms && !peerApprovalWaived(bot.id, threadId));
@@ -4569,19 +4577,15 @@ function delegatedFullAccess(from, fromThreadId, target) {
4569
4577
  recipientDriverKind: registry.cliTarget(target.modelSelection.instanceId)?.driverKind,
4570
4578
  });
4571
4579
  }
4572
- /** Make a delegated thread Full and say so in it once, so the level the
4573
- * chip shows and the level the turns run at agree, and the person can see
4574
- * where the access came from. Idempotent: a pair conversation is reused
4575
- * across delegations and must not collect a chip per request. */
4576
- function grantDelegatedFullAccess(from, target, threadId) {
4577
- if (store.taskByThread(target.id, threadId)?.approvalMode === "full")
4580
+ /** Note the newest delegation into a thread: where its Full access comes
4581
+ * from, or that it has none. Nothing is written to the thread's own level.
4582
+ * The thread says where the access came from once per Chief. */
4583
+ function noteDelegatedFullAccess(from, fromThreadId, target, threadId) {
4584
+ if (!delegatedFullAccess(from, fromThreadId, target))
4585
+ return delegatedFull.clear(threadId);
4586
+ if (!delegatedFull.record(threadId, { botId: from.id, threadId: fromThreadId }))
4578
4587
  return;
4579
- store.patchTask(target.id, threadId, { approvalMode: "full", autoApprove: false, alwaysAllow: [] });
4580
- store.appendMessage(threadId, {
4581
- role: "bot",
4582
- kind: "activity",
4583
- tool: { name: `GOD MODE: delegated by ${from.name}, a Chief of Staff with GOD MODE`, ok: true },
4584
- });
4588
+ store.appendMessage(threadId, { role: "bot", kind: "activity", tool: { name: delegatedFullAccessLabel(from.name), ok: true } });
4585
4589
  }
4586
4590
  /** The person a conversation is working for, by the name their messages
4587
4591
  * carry; the owner's profile name when the line names nobody. */
@@ -5050,7 +5054,7 @@ const personalGoals = new PersonalGoalRuntime(join(DATA_DIR, "personal-goals.jso
5050
5054
  if (owns)
5051
5055
  await interruptDirectThread(botId, threadId);
5052
5056
  },
5053
- changed: (goal) => updatePersonalGoalReceipt(goal, store),
5057
+ changed: (goal) => updatePersonalGoalReceipt(goal, store), godMode: (botId) => Boolean(store.bot(botId) && godModeActive() && botWorkModes.permits("full")),
5054
5058
  run: (goal) => runPersonalGoalTurn(goal, { store, addGuard: addGroupGoalCoordinatorTurn, removeGuard: removeGroupGoalCoordinatorTurn,
5055
5059
  subscribe: (listener) => bus.subscribe(listener), ignore: shouldIgnoreProviderEvent, busy: threadBusy, start: startTurn }),
5056
5060
  });
@@ -5851,6 +5855,7 @@ store.onChange((change) => {
5851
5855
  break;
5852
5856
  case "thread.deleted":
5853
5857
  directRequestOwners.delete(change.threadId);
5858
+ forgetThreadTurnTokens(change.threadId);
5854
5859
  routines?.forgetRoutineRequestReceiptsForThread(change.threadId);
5855
5860
  // A deleted destination must not strand an approval in an internal
5856
5861
  // task. Keep each run's snapshot and expose its execution as fallback.
@@ -7238,7 +7243,7 @@ async function mountBotVps(bot, owner, opts) {
7238
7243
  return {
7239
7244
  integration: {
7240
7245
  ...vpsMcp,
7241
- env: { ...vpsMcp.env, OMB_CONTROL_URL: vpsControl.url, OMB_CONTROL_TOKEN: vpsControl.token },
7246
+ env: { ...vpsMcp.env, OMB_CONTROL_URL: vpsControl.url, OMB_CONTROL_TOKEN: vpsControl.token, OMB_CONTROL_TOKEN_FILE: vpsControl.tokenFile },
7242
7247
  },
7243
7248
  };
7244
7249
  }
@@ -7819,15 +7824,12 @@ bus.subscribe((event) => {
7819
7824
  sessionModelByThread.set(event.threadId, event.model);
7820
7825
  break;
7821
7826
  case "session.model-fallback":
7822
- // The engine refused the thread's model and the turn went on with
7823
- // another (drivers/acp/core.ts). One quiet line here; the Chief hears
7824
- // about it so the setting gets fixed, and the person is not buzzed.
7825
- pushMessage({
7826
- role: "bot",
7827
- kind: "activity",
7828
- tool: { name: `model ${event.requested} is not offered by this engine any more: continuing on ${event.model}`, ok: true },
7829
- });
7827
+ // The engine refused the thread's model and the turn went on with another (drivers/acp/core.ts); the
7828
+ // thread keeps the one that ran, so it is not refused every turn. One quiet line; the Chief hears of it.
7829
+ pushMessage({ role: "bot", kind: "activity", tool: { name: refusedModelLine(event), ok: true } });
7830
7830
  if (bot) {
7831
+ if (event.providerInstanceId)
7832
+ repairRefusedModel(store, bot.id, event.threadId, { ...event, instanceId: event.providerInstanceId });
7831
7833
  reportIncident({
7832
7834
  kind: "model-fallback", bot, threadId: event.threadId,
7833
7835
  detail: `asked for ${event.requested}, the engine answered "${event.reason.slice(0, 160)}"; the turn ran on ${event.model}`,
@@ -7936,7 +7938,7 @@ bus.subscribe((event) => {
7936
7938
  // engine) whose turn therefore still runs at the bot's own level. It
7937
7939
  // is logged as `god-mode` unless the bot's own level is Full anyway.
7938
7940
  const godModeAnswers = !othersAsked && Boolean(permission && asker && godModeCovers(asker)) &&
7939
- ownApprovalModeForTurn(asker, isInternalTurn(event.threadId)) !== "full";
7941
+ (ownApprovalModeForTurn(asker, isInternalTurn(event.threadId)) !== "full" || godModeRunOn(personalGoals.goals, event.threadId));
7940
7942
  // A read-only tool of one of the person's own MCP servers, by that
7941
7943
  // server's own annotation, on a server whose switch is on. Never for
7942
7944
  // host-computer control, which stays one approval at a time.
@@ -7956,7 +7958,7 @@ bus.subscribe((event) => {
7956
7958
  destructive: event.mcpTool?.annotations?.destructiveHint === true,
7957
7959
  };
7958
7960
  const ownVerdict = permission && asker && event.requestId
7959
- ? autoVerdict(effectiveApprovalMode, event.tool, { requiresExplicitApproval: event.requiresExplicitApproval, readOnlyMcpTool, godMode: godModeAnswers })
7961
+ ? autoVerdict(effectiveApprovalMode, event.tool, { requiresExplicitApproval: event.requiresExplicitApproval, readOnlyMcpTool, godMode: godModeAnswers, godModeLimits: !othersAsked && godModeCovers(asker) ? { summary: event.summary } : undefined })
7960
7962
  : null;
7961
7963
  // An approval the person gave in the Chief of Staff's conversation,
7962
7964
  // carried into this delegated turn. Only what the turn's own level
@@ -7973,8 +7975,7 @@ bus.subscribe((event) => {
7973
7975
  source: "delegated-grant",
7974
7976
  }
7975
7977
  : ownVerdict;
7976
- // The room shows "Waiting for <owner> to approve" while the owner's
7977
- // card is open (on this desktop or the paired iPhone).
7978
+ // The room shows "Waiting for <owner> to approve" while the owner's card is open (desktop or paired iPhone).
7978
7979
  if (roomAsk && permission && event.requestId && !verdict?.approve) {
7979
7980
  const actionHash = createHash("sha256").update(JSON.stringify([event.threadId, event.requestId, event.tool, event.summary])).digest("hex");
7980
7981
  teamRoomsHost?.approvalOpened(event.threadId, event.requestId, event.summary || event.tool, actionHash);
@@ -7999,6 +8000,8 @@ bus.subscribe((event) => {
7999
8000
  },
8000
8001
  });
8001
8002
  }
8003
+ if (!othersAsked && handleGodModeRunRequest({ goals: personalGoals.goals, dataDir: DATA_DIR, threadId: event.threadId, requestId: event.requestId, permission, tool: event.tool, summary: event.summary, verdict, bot: asker, adapter: (event.providerInstanceId ? registry.get(event.providerInstanceId) : asker && registry.get(asker.modelSelection.instanceId))?.adapter, note: (name, ok) => pushMessage({ role: "bot", kind: "activity", tool: { name, ok } }) }))
8004
+ break;
8002
8005
  if (verdict?.approve && asker && event.requestId) {
8003
8006
  const settled = verdict.approve;
8004
8007
  const instance = event.providerInstanceId
@@ -8241,7 +8244,7 @@ bus.subscribe((event) => {
8241
8244
  // keeps the same failure from reporting a second incident.
8242
8245
  const lazyClaimAlreadyReported = event.stopReason === "exit_before_result" &&
8243
8246
  turnResourceOwners.get(event.threadId)?.lazyClaimFailureReported === true;
8244
- if (!event.ok && event.stopReason !== "interrupted" && !lazyClaimAlreadyReported && !routines?.runForThread(event.threadId)) {
8247
+ if (!event.ok && event.stopReason !== "interrupted" && !lazyClaimAlreadyReported && !routines?.runForThread(event.threadId) && !godModeRunOn(personalGoals.goals, event.threadId)) {
8245
8248
  const broken = bot ?? (speaker ? store.bot(speaker.botId) : undefined);
8246
8249
  if (broken)
8247
8250
  reportIncident({ kind: "failed", bot: broken, threadId: event.threadId, detail: failedRunDetail(event.stopReason, turnError), notifyChief: event.stopReason === "auth_required" });
@@ -11202,7 +11205,7 @@ const commsBus = {
11202
11205
  };
11203
11206
  _loadPending();
11204
11207
  routines = new RoutineManager({
11205
- emit: broadcast,
11208
+ emit: broadcast, beforeSettle: () => syncMcpAuthState(),
11206
11209
  hasPendingDelegations: (threadId) => pendingThreads().includes(threadId) ||
11207
11210
  [...delegationWatch.values()].some((watch) => watch.sourceThreadId === threadId) ||
11208
11211
  pendingDelegationWakes.has(threadId),
@@ -11782,7 +11785,7 @@ async function resolveAndSendTeamSetup(res, args, ownerReview) {
11782
11785
  return true;
11783
11786
  }
11784
11787
  const ROUTINE_WEEKDAY_NAMES = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
11785
- const routineTimeZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
11788
+ const routineTimeZone = () => workspaceTimeZone();
11786
11789
  const routineTimestamp = (value) => value !== undefined && Number.isFinite(value) ? new Date(value).toISOString() : null;
11787
11790
  const agentRoutine = (routine, latestRun) => {
11788
11791
  // Routines created in the calendar predate chat-card redaction and may
@@ -13657,7 +13660,7 @@ function botInterviewContext(mode) {
13657
13660
  }
13658
13661
  }
13659
13662
  return {
13660
- timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC",
13663
+ timeZone: workspaceTimeZone(),
13661
13664
  takenNames: store.bots.filter((bot) => !bot.hidden).map((bot) => bot.name),
13662
13665
  tools,
13663
13666
  accountProviders: accounts.storage === "unavailable" ? [] : accounts.providers.flatMap((provider) => provider.configured && provider.id !== "apple" ? [provider.id] : []),
@@ -14486,7 +14489,7 @@ function configStatus() {
14486
14489
  // whether this person sees Watch-Along (server/watch-along/access.ts)
14487
14490
  watchAlong: { access: watchAccess().allowed },
14488
14491
  // not a secret — the settings picker shows it; "" = follow the system
14489
- language: cfg.language ?? "",
14492
+ language: cfg.language ?? "", timeZone: workspaceTimeZoneStatus(),
14490
14493
  rooms: { turnTimeoutMinutes: roomTurnTimeoutMinutes(cfg) },
14491
14494
  // absent effort = no level is sent, so clients can tell it from any level
14492
14495
  newBots: cfg.newBots?.effort ? { effort: cfg.newBots.effort } : {},
@@ -14783,7 +14786,7 @@ function warmMcpToolHints(custom) {
14783
14786
  const mcpAuthState = new McpAuthStateStore(join(DATA_DIR, "mcp-auth-state.json"));
14784
14787
  const mcpHealth = new McpHealthStore();
14785
14788
  const mcpTurn = mcpTurnPolicy({ auth: mcpAuthState, health: mcpHealth, signalDir: mcpAuthSignalDir, specs: () => customMcpServers(cfg), credentialRefused: (name, spec) => mcpSignIn.refused(name, spec),
14786
- reportUnavailable: (threadId, detail) => { const bot = store.botByThread(threadId); if (bot)
14789
+ reportUnavailable: (threadId, detail) => { routines?.noteToolProblem(threadId, detail); const bot = store.botByThread(threadId); if (bot)
14787
14790
  reportIncident({ kind: "mcp-unavailable", bot, threadId, detail }); } });
14788
14791
  function syncMcpAuthState() { mcpTurn.sync(); }
14789
14792
  /** How a start runs an mcp-remote bridge: background starts never open a
@@ -15067,11 +15070,10 @@ const claudeUpdatesInFlight = new Set();
15067
15070
  function serveStatic(res, path) {
15068
15071
  if (!STATIC_DIR)
15069
15072
  return false;
15070
- const safe = path === "/" ? "/index.html" : path.replace(/\.\./g, "");
15071
- const file = join(STATIC_DIR, safe);
15073
+ const file = join(STATIC_DIR, path === "/" ? "/index.html" : path.replace(/\.\./g, ""));
15072
15074
  try {
15073
15075
  const data = readFileSync(file);
15074
- res.writeHead(200, { "content-type": MIME[extname(file)] ?? "application/octet-stream" });
15076
+ res.writeHead(200, staticHeaders(MIME[extname(file)] ?? "application/octet-stream"));
15075
15077
  res.end(data);
15076
15078
  return true;
15077
15079
  }
@@ -15079,7 +15081,7 @@ function serveStatic(res, path) {
15079
15081
  // SPA fallback
15080
15082
  try {
15081
15083
  const data = readFileSync(join(STATIC_DIR, "index.html"));
15082
- res.writeHead(200, { "content-type": "text/html" });
15084
+ res.writeHead(200, staticHeaders("text/html"));
15083
15085
  res.end(data);
15084
15086
  return true;
15085
15087
  }
@@ -16198,7 +16200,7 @@ const deliverableAccess = (senderId, auth) => sharedDeliverableAccess(sharedDeli
16198
16200
  canSeeGroup: auth ? (id) => visibleTo(viewerFor(auth)).group(id) : () => true,
16199
16201
  });
16200
16202
  ROUTES.push(createSharedDeliverablesRoutes(sharedDeliverables, () => deliverableAccess(undefined).sharedBlockedRoots ?? []));
16201
- ROUTES.push(createMessageFileRoutes({ store, attachments: ATTACHMENTS_DIR, workspaceDir, access: deliverableAccess }), createModelGatewayRoutes());
16203
+ ROUTES.push(createMessageFileRoutes({ store, attachments: ATTACHMENTS_DIR, workspaceDir, access: deliverableAccess }), createModelGatewayRoutes({ withinBudget: () => assertWithinBudget(cfg, DATA_DIR), book: bookTurnUsage }));
16202
16204
  ROUTES.push(createPinOrderRoutes({ store, visible: (auth) => visibleTo(viewerFor(auth)), personalHidden: personalBotHidden, fromBot: (req) => authorizedInternalCapability(req.headers.authorization) !== null }));
16203
16205
  // Linked repos: Settings > Repos, per-thread links and worktrees. See
16204
16206
  // server/routes/repos.ts for the routes and docs/chibitek/README.md.
@@ -16245,6 +16247,8 @@ const handleRequest = async (req, res) => {
16245
16247
  let m = null;
16246
16248
  let releaseWorkspaceRequest;
16247
16249
  try {
16250
+ if (crossSiteMutation(req))
16251
+ return json(res, 403, { error: "forbidden: cross-site request" });
16248
16252
  // Unlike the legacy reachability probe, this attests the running
16249
16253
  // server's portal-membership capability, including live entitlement.
16250
16254
  if (method === "GET" && path === "/api/health/hosted") {
@@ -18121,9 +18125,7 @@ const handleRequest = async (req, res) => {
18121
18125
  // shared by every assignment between two bots, so it names nobody.
18122
18126
  if (resolved.created && resolved.task.openedBy?.kind === "work")
18123
18127
  threadStarters.set(resolved.task.threadId, threadPersonKey(address.threadId));
18124
- if (delegatedFullAccess(internalSender, internalCapability.threadId, store.bot(target.botId))) {
18125
- grantDelegatedFullAccess(internalSender, store.bot(target.botId), target.threadId);
18126
- }
18128
+ noteDelegatedFullAccess(internalSender, internalCapability.threadId, store.bot(target.botId), target.threadId);
18127
18129
  }
18128
18130
  // A teammate's conversation gets the delegator's repos; a room
18129
18131
  // thread keeps the room's own links.
@@ -18413,8 +18415,7 @@ const handleRequest = async (req, res) => {
18413
18415
  applyDelegatedRepos(task.threadId, repos.ids);
18414
18416
  // The work is still for the person whose request the opener is on.
18415
18417
  threadStarters.set(task.threadId, threadPersonKey(fromThreadId));
18416
- if (delegatedFullAccess(from, fromThreadId, target))
18417
- grantDelegatedFullAccess(from, target, task.threadId);
18418
+ noteDelegatedFullAccess(from, fromThreadId, target, task.threadId);
18418
18419
  const queued = queueDelegation(commsBus, from, { toBotId: target.id, message, depth, targetThreadId: task.threadId, ...(verified.authorizations.length ? { authorizations: verified.authorizations } : {}) }, MAX_COMMS_DEPTH, fromThreadId);
18419
18420
  if (queued.result !== "ok" || !queued.id) {
18420
18421
  // nothing will ever run there: take the row back before the person
@@ -23520,10 +23521,10 @@ const handleRequest = async (req, res) => {
23520
23521
  return json(res, 400, { error: "No key to test. Paste one or save one first." });
23521
23522
  if (key.length > 512)
23522
23523
  return json(res, 400, { error: "That does not look like an API key." });
23523
- const url = typeof body?.url === "string" && body.url.trim() ? body.url.trim() : (saved && "url" in saved ? saved.url : undefined);
23524
+ const asked = pastedKeyTestUrl(body, configuredProviderUrls(cfg)), url = asked ?? (saved && "url" in saved ? saved.url : undefined);
23524
23525
  // The workspace connection's OpenAI organization and project go along,
23525
23526
  // so a team key is checked the way turns will use it.
23526
- const headers = kind === "openaiCompat" && !body?.url ? openAiTeamHeaders(cfg.openaiCompat ?? {}) : undefined;
23527
+ const headers = kind === "openaiCompat" && !asked ? openAiTeamHeaders(cfg.openaiCompat ?? {}) : undefined;
23527
23528
  res.setHeader("cache-control", "no-store");
23528
23529
  return json(res, 200, await checkProviderKey({ provider: kind, key, url, ...(headers ? { headers } : {}) }));
23529
23530
  }
@@ -25484,9 +25485,8 @@ const gracefulShutdown = createGracefulShutdown({
25484
25485
  process.exit(code);
25485
25486
  },
25486
25487
  });
25487
- for (const signal of ["SIGINT", "SIGTERM"]) {
25488
- process.on(signal, gracefulShutdown);
25489
- }
25488
+ // The desktop asks over the parent port: Windows delivers no signal to a child.
25489
+ installShutdownTriggers(process, utilityParentPort, gracefulShutdown);
25490
25490
  // Last line of defence for every exit, including an uncaught exception, which
25491
25491
  // skips gracefulShutdown entirely: an orphaned browser daemon keeps running
25492
25492
  // from the app bundle and (on macOS) blocks the next update's install.
@@ -0,0 +1,18 @@
1
+ /** Whether the class-aware walk is worth running: the ladder found no
2
+ * subscription (a free model, a key, or nothing while the thread's own
3
+ * engine is out). */
4
+ export function needsWiderWalk(first, ownOut) {
5
+ return first ? first.band !== "subscription" : ownOut;
6
+ }
7
+ /** Whether the class-aware pick replaces the ladder's: always when the ladder
8
+ * found nothing; a subscription always beats a free model or a key; a free
9
+ * model picked in class order beats one picked by the order it was added. */
10
+ export function takeWider(first, wider) {
11
+ if (!first)
12
+ return true;
13
+ if (first.band === "subscription" || !wider)
14
+ return false;
15
+ if (wider.band === "subscription")
16
+ return true;
17
+ return first.band === "free" && wider.band === "free";
18
+ }
@@ -2,7 +2,8 @@
2
2
  // travel in environment variables, never command-line arguments or logs.
3
3
  import { runMcpBridge } from "./mcp-bridge.js";
4
4
  import { augmentedPath } from "./env-path.js";
5
- const { OMB_CUA_COMMAND: command, OMB_CUA_ARGS: encodedArgs, OMB_CONTROL_URL: url, OMB_CONTROL_TOKEN: token, ...childEnv } = process.env;
5
+ import { turnTokenReader } from "./turn-token.js";
6
+ const { OMB_CUA_COMMAND: command, OMB_CUA_ARGS: encodedArgs, OMB_CONTROL_URL: url, OMB_CONTROL_TOKEN: token, OMB_CONTROL_TOKEN_FILE: _tokenFile, ...childEnv } = process.env;
6
7
  let args;
7
8
  try {
8
9
  const parsed = JSON.parse(encodedArgs ?? "");
@@ -24,5 +25,5 @@ runMcpBridge({
24
25
  args,
25
26
  env: { ...childEnv, PATH: augmentedPath() },
26
27
  label: "Local Cua Driver",
27
- gate: { url: url, token: token },
28
+ gate: { url: url, token: turnTokenReader(process.env, "OMB_CONTROL_TOKEN") },
28
29
  });
@@ -32,6 +32,7 @@ export function gatedLocalComputer(connection, control) {
32
32
  OMB_CUA_ARGS: JSON.stringify(connection.args),
33
33
  OMB_CONTROL_URL: control.url,
34
34
  OMB_CONTROL_TOKEN: control.token,
35
+ ...(control.tokenFile ? { OMB_CONTROL_TOKEN_FILE: control.tokenFile } : {}),
35
36
  },
36
37
  };
37
38
  }