@jungjaehoon/mama-os 0.53.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/README.md +62 -259
- package/db/migrations/001-connector-event-index.sql +251 -0
- package/dist/agent/claude-native-tool-policy.d.ts +17 -0
- package/dist/agent/claude-native-tool-policy.d.ts.map +1 -0
- package/dist/agent/claude-native-tool-policy.js +88 -0
- package/dist/agent/claude-native-tool-policy.js.map +1 -0
- package/dist/api/attachment-actions.d.ts +16 -0
- package/dist/api/attachment-actions.d.ts.map +1 -0
- package/dist/api/attachment-actions.js +278 -0
- package/dist/api/attachment-actions.js.map +1 -0
- package/dist/api/auth-middleware.d.ts +15 -55
- package/dist/api/auth-middleware.d.ts.map +1 -1
- package/dist/api/auth-middleware.js +56 -233
- package/dist/api/auth-middleware.js.map +1 -1
- package/dist/api/cf-access.d.ts +6 -0
- package/dist/api/cf-access.d.ts.map +1 -0
- package/dist/api/cf-access.js +121 -0
- package/dist/api/cf-access.js.map +1 -0
- package/dist/api/file-delivery.d.ts +29 -0
- package/dist/api/file-delivery.d.ts.map +1 -0
- package/dist/api/file-delivery.js +90 -0
- package/dist/api/file-delivery.js.map +1 -0
- package/dist/api/owner-timezone-actions.d.ts +10 -0
- package/dist/api/owner-timezone-actions.d.ts.map +1 -0
- package/dist/api/owner-timezone-actions.js +73 -0
- package/dist/api/owner-timezone-actions.js.map +1 -0
- package/dist/api/report-actions.d.ts +22 -0
- package/dist/api/report-actions.d.ts.map +1 -0
- package/dist/api/report-actions.js +137 -0
- package/dist/api/report-actions.js.map +1 -0
- package/dist/api/report-handler.d.ts +15 -11
- package/dist/api/report-handler.d.ts.map +1 -1
- package/dist/api/report-handler.js +48 -120
- package/dist/api/report-handler.js.map +1 -1
- package/dist/api/report-persistence.d.ts +3 -3
- package/dist/api/report-persistence.d.ts.map +1 -1
- package/dist/api/report-persistence.js +35 -10
- package/dist/api/report-persistence.js.map +1 -1
- package/dist/api/report-source-actions.d.ts +11 -0
- package/dist/api/report-source-actions.d.ts.map +1 -0
- package/dist/api/report-source-actions.js +309 -0
- package/dist/api/report-source-actions.js.map +1 -0
- package/dist/api/security-events.d.ts +23 -0
- package/dist/api/security-events.d.ts.map +1 -0
- package/dist/api/security-events.js +71 -0
- package/dist/api/security-events.js.map +1 -0
- package/dist/api/source-actions.d.ts +9 -0
- package/dist/api/source-actions.d.ts.map +1 -0
- package/dist/api/source-actions.js +274 -0
- package/dist/api/source-actions.js.map +1 -0
- package/dist/api/stored-source-reader.d.ts +21 -0
- package/dist/api/stored-source-reader.d.ts.map +1 -0
- package/dist/api/stored-source-reader.js +269 -0
- package/dist/api/stored-source-reader.js.map +1 -0
- package/dist/api/viewer-data.d.ts +143 -0
- package/dist/api/viewer-data.d.ts.map +1 -0
- package/dist/api/viewer-data.js +518 -0
- package/dist/api/viewer-data.js.map +1 -0
- package/dist/api/viewer-request-security.d.ts +12 -0
- package/dist/api/viewer-request-security.d.ts.map +1 -0
- package/dist/api/viewer-request-security.js +217 -0
- package/dist/api/viewer-request-security.js.map +1 -0
- package/dist/api/viewer-server.d.ts +55 -0
- package/dist/api/viewer-server.d.ts.map +1 -0
- package/dist/api/viewer-server.js +933 -0
- package/dist/api/viewer-server.js.map +1 -0
- package/dist/api/wiki-actions.d.ts +20 -0
- package/dist/api/wiki-actions.d.ts.map +1 -0
- package/dist/api/wiki-actions.js +296 -0
- package/dist/api/wiki-actions.js.map +1 -0
- package/dist/api/work-actions.d.ts +109 -0
- package/dist/api/work-actions.d.ts.map +1 -0
- package/dist/api/work-actions.js +987 -0
- package/dist/api/work-actions.js.map +1 -0
- package/dist/cli/commands/daemon.d.ts +90 -0
- package/dist/cli/commands/daemon.d.ts.map +1 -0
- package/dist/cli/commands/daemon.js +620 -0
- package/dist/cli/commands/daemon.js.map +1 -0
- package/dist/cli/commands/init.d.ts +7 -18
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +357 -273
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/replay.d.ts +12 -0
- package/dist/cli/commands/replay.d.ts.map +1 -0
- package/dist/cli/commands/replay.js +145 -0
- package/dist/cli/commands/replay.js.map +1 -0
- package/dist/cli/commands/secret.d.ts +6 -0
- package/dist/cli/commands/secret.d.ts.map +1 -0
- package/dist/cli/commands/secret.js +24 -0
- package/dist/cli/commands/secret.js.map +1 -0
- package/dist/cli/index.d.ts +0 -5
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +52 -95
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/launch-files.d.ts +10 -0
- package/dist/cli/launch-files.d.ts.map +1 -0
- package/dist/cli/launch-files.js +74 -0
- package/dist/cli/launch-files.js.map +1 -0
- package/dist/cli/prompt.d.ts +15 -0
- package/dist/cli/prompt.d.ts.map +1 -0
- package/dist/cli/prompt.js +64 -0
- package/dist/cli/prompt.js.map +1 -0
- package/dist/cli/runtime/action-mcp-config.d.ts +15 -0
- package/dist/cli/runtime/action-mcp-config.d.ts.map +1 -0
- package/dist/cli/runtime/action-mcp-config.js +56 -0
- package/dist/cli/runtime/action-mcp-config.js.map +1 -0
- package/dist/cli/runtime/claude-caller-config.d.ts +4 -0
- package/dist/cli/runtime/claude-caller-config.d.ts.map +1 -0
- package/dist/cli/runtime/claude-caller-config.js +46 -0
- package/dist/cli/runtime/claude-caller-config.js.map +1 -0
- package/dist/cli/secrets.d.ts +9 -0
- package/dist/cli/secrets.d.ts.map +1 -0
- package/dist/cli/secrets.js +94 -0
- package/dist/cli/secrets.js.map +1 -0
- package/dist/connectors/calendar/index.d.ts +11 -10
- package/dist/connectors/calendar/index.d.ts.map +1 -1
- package/dist/connectors/calendar/index.js +171 -97
- package/dist/connectors/calendar/index.js.map +1 -1
- package/dist/connectors/chatwork/index.d.ts +31 -5
- package/dist/connectors/chatwork/index.d.ts.map +1 -1
- package/dist/connectors/chatwork/index.js +184 -20
- package/dist/connectors/chatwork/index.js.map +1 -1
- package/dist/connectors/claude-code/index.d.ts +0 -2
- package/dist/connectors/claude-code/index.d.ts.map +1 -1
- package/dist/connectors/claude-code/index.js +94 -70
- package/dist/connectors/claude-code/index.js.map +1 -1
- package/dist/connectors/config-loader.d.ts +1 -6
- package/dist/connectors/config-loader.d.ts.map +1 -1
- package/dist/connectors/config-loader.js +154 -134
- package/dist/connectors/config-loader.js.map +1 -1
- package/dist/connectors/discord/index.d.ts +8 -1
- package/dist/connectors/discord/index.d.ts.map +1 -1
- package/dist/connectors/discord/index.js +110 -32
- package/dist/connectors/discord/index.js.map +1 -1
- package/dist/connectors/drive/index.d.ts +10 -5
- package/dist/connectors/drive/index.d.ts.map +1 -1
- package/dist/connectors/drive/index.js +145 -88
- package/dist/connectors/drive/index.js.map +1 -1
- package/dist/connectors/framework/attachment-io.d.ts +5 -0
- package/dist/connectors/framework/attachment-io.d.ts.map +1 -0
- package/dist/connectors/framework/attachment-io.js +72 -0
- package/dist/connectors/framework/attachment-io.js.map +1 -0
- package/dist/connectors/framework/attachments.d.ts +32 -0
- package/dist/connectors/framework/attachments.d.ts.map +1 -0
- package/dist/connectors/framework/attachments.js +14 -0
- package/dist/connectors/framework/attachments.js.map +1 -0
- package/dist/connectors/framework/connector-event-types.d.ts +136 -0
- package/dist/connectors/framework/connector-event-types.d.ts.map +1 -0
- package/dist/connectors/framework/connector-event-types.js +3 -0
- package/dist/connectors/framework/connector-event-types.js.map +1 -0
- package/dist/connectors/framework/connector-state.d.ts +3 -0
- package/dist/connectors/framework/connector-state.d.ts.map +1 -0
- package/dist/connectors/framework/connector-state.js +47 -0
- package/dist/connectors/framework/connector-state.js.map +1 -0
- package/dist/connectors/framework/event-index.d.ts +28 -0
- package/dist/connectors/framework/event-index.d.ts.map +1 -0
- package/dist/connectors/framework/event-index.js +354 -0
- package/dist/connectors/framework/event-index.js.map +1 -0
- package/dist/connectors/framework/gws-utils.d.ts +3 -8
- package/dist/connectors/framework/gws-utils.d.ts.map +1 -1
- package/dist/connectors/framework/gws-utils.js +23 -30
- package/dist/connectors/framework/gws-utils.js.map +1 -1
- package/dist/connectors/framework/index.d.ts +4 -2
- package/dist/connectors/framework/index.d.ts.map +1 -1
- package/dist/connectors/framework/index.js +8 -6
- package/dist/connectors/framework/index.js.map +1 -1
- package/dist/connectors/framework/polling-scheduler.d.ts +71 -52
- package/dist/connectors/framework/polling-scheduler.d.ts.map +1 -1
- package/dist/connectors/framework/polling-scheduler.js +227 -168
- package/dist/connectors/framework/polling-scheduler.js.map +1 -1
- package/dist/connectors/framework/raw-query.d.ts +44 -0
- package/dist/connectors/framework/raw-query.d.ts.map +1 -0
- package/dist/connectors/framework/raw-query.js +584 -0
- package/dist/connectors/framework/raw-query.js.map +1 -0
- package/dist/connectors/framework/stored-index-read.d.ts +16 -0
- package/dist/connectors/framework/stored-index-read.d.ts.map +1 -0
- package/dist/connectors/framework/stored-index-read.js +66 -0
- package/dist/connectors/framework/stored-index-read.js.map +1 -0
- package/dist/connectors/framework/types.d.ts +17 -61
- package/dist/connectors/framework/types.d.ts.map +1 -1
- package/dist/connectors/framework/types.js +0 -4
- package/dist/connectors/framework/types.js.map +1 -1
- package/dist/connectors/gmail/index.d.ts +3 -2
- package/dist/connectors/gmail/index.d.ts.map +1 -1
- package/dist/connectors/gmail/index.js +74 -27
- package/dist/connectors/gmail/index.js.map +1 -1
- package/dist/connectors/ical/index.d.ts +29 -0
- package/dist/connectors/ical/index.d.ts.map +1 -0
- package/dist/connectors/ical/index.js +220 -0
- package/dist/connectors/ical/index.js.map +1 -0
- package/dist/connectors/ical/parser.d.ts +13 -0
- package/dist/connectors/ical/parser.d.ts.map +1 -0
- package/dist/connectors/ical/parser.js +117 -0
- package/dist/connectors/ical/parser.js.map +1 -0
- package/dist/connectors/imessage/index.d.ts +3 -1
- package/dist/connectors/imessage/index.d.ts.map +1 -1
- package/dist/connectors/imessage/index.js +31 -16
- package/dist/connectors/imessage/index.js.map +1 -1
- package/dist/connectors/index.d.ts +12 -5
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +67 -18
- package/dist/connectors/index.js.map +1 -1
- package/dist/connectors/kagemusha/index.d.ts +7 -19
- package/dist/connectors/kagemusha/index.d.ts.map +1 -1
- package/dist/connectors/kagemusha/index.js +123 -173
- package/dist/connectors/kagemusha/index.js.map +1 -1
- package/dist/connectors/notion/index.d.ts.map +1 -1
- package/dist/connectors/notion/index.js +79 -36
- package/dist/connectors/notion/index.js.map +1 -1
- package/dist/connectors/obsidian/index.d.ts +1 -1
- package/dist/connectors/obsidian/index.d.ts.map +1 -1
- package/dist/connectors/obsidian/index.js +59 -57
- package/dist/connectors/obsidian/index.js.map +1 -1
- package/dist/connectors/sheets/index.d.ts +8 -4
- package/dist/connectors/sheets/index.d.ts.map +1 -1
- package/dist/connectors/sheets/index.js +155 -143
- package/dist/connectors/sheets/index.js.map +1 -1
- package/dist/connectors/slack/index.d.ts +24 -5
- package/dist/connectors/slack/index.d.ts.map +1 -1
- package/dist/connectors/slack/index.js +177 -39
- package/dist/connectors/slack/index.js.map +1 -1
- package/dist/connectors/telegram/index.d.ts +9 -2
- package/dist/connectors/telegram/index.d.ts.map +1 -1
- package/dist/connectors/telegram/index.js +119 -70
- package/dist/connectors/telegram/index.js.map +1 -1
- package/dist/connectors/trello/index.d.ts +10 -3
- package/dist/connectors/trello/index.d.ts.map +1 -1
- package/dist/connectors/trello/index.js +88 -39
- package/dist/connectors/trello/index.js.map +1 -1
- package/dist/gateways/base-gateway.d.ts +9 -33
- package/dist/gateways/base-gateway.d.ts.map +1 -1
- package/dist/gateways/base-gateway.js +7 -28
- package/dist/gateways/base-gateway.js.map +1 -1
- package/dist/gateways/conversation-record.d.ts +52 -0
- package/dist/gateways/conversation-record.d.ts.map +1 -0
- package/dist/gateways/conversation-record.js +220 -0
- package/dist/gateways/conversation-record.js.map +1 -0
- package/dist/gateways/discord.d.ts +33 -135
- package/dist/gateways/discord.d.ts.map +1 -1
- package/dist/gateways/discord.js +258 -778
- package/dist/gateways/discord.js.map +1 -1
- package/dist/gateways/session-store.d.ts +28 -9
- package/dist/gateways/session-store.d.ts.map +1 -1
- package/dist/gateways/session-store.js +192 -60
- package/dist/gateways/session-store.js.map +1 -1
- package/dist/gateways/slack.d.ts +35 -105
- package/dist/gateways/slack.d.ts.map +1 -1
- package/dist/gateways/slack.js +282 -440
- package/dist/gateways/slack.js.map +1 -1
- package/dist/gateways/telegram-attachments.d.ts +32 -0
- package/dist/gateways/telegram-attachments.d.ts.map +1 -0
- package/dist/gateways/telegram-attachments.js +113 -0
- package/dist/gateways/telegram-attachments.js.map +1 -0
- package/dist/gateways/telegram-errors.d.ts +3 -0
- package/dist/gateways/telegram-errors.d.ts.map +1 -0
- package/dist/gateways/telegram-errors.js +10 -0
- package/dist/gateways/telegram-errors.js.map +1 -0
- package/dist/gateways/telegram-format.d.ts.map +1 -1
- package/dist/gateways/telegram-format.js +9 -1
- package/dist/gateways/telegram-format.js.map +1 -1
- package/dist/gateways/telegram-message-ledger.d.ts +31 -25
- package/dist/gateways/telegram-message-ledger.d.ts.map +1 -1
- package/dist/gateways/telegram-message-ledger.js +122 -146
- package/dist/gateways/telegram-message-ledger.js.map +1 -1
- package/dist/gateways/telegram-response-presenter.d.ts +3 -1
- package/dist/gateways/telegram-response-presenter.d.ts.map +1 -1
- package/dist/gateways/telegram-response-presenter.js +14 -0
- package/dist/gateways/telegram-response-presenter.js.map +1 -1
- package/dist/gateways/telegram-text-entities.d.ts +2 -3
- package/dist/gateways/telegram-text-entities.d.ts.map +1 -1
- package/dist/gateways/telegram-text-entities.js +4 -5
- package/dist/gateways/telegram-text-entities.js.map +1 -1
- package/dist/gateways/telegram.d.ts +39 -101
- package/dist/gateways/telegram.d.ts.map +1 -1
- package/dist/gateways/telegram.js +406 -919
- package/dist/gateways/telegram.js.map +1 -1
- package/dist/gateways/turn-contract.d.ts +27 -87
- package/dist/gateways/turn-contract.d.ts.map +1 -1
- package/dist/gateways/types.d.ts +14 -299
- package/dist/gateways/types.d.ts.map +1 -1
- package/dist/gateways/types.js +0 -3
- package/dist/gateways/types.js.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -23
- package/dist/index.js.map +1 -1
- package/dist/operator/board-read-views.d.ts +8 -10
- package/dist/operator/board-read-views.d.ts.map +1 -1
- package/dist/operator/board-read-views.js +4 -13
- package/dist/operator/board-read-views.js.map +1 -1
- package/dist/operator/board-slot-instructions.d.ts +10 -11
- package/dist/operator/board-slot-instructions.d.ts.map +1 -1
- package/dist/operator/board-slot-instructions.js +22 -21
- package/dist/operator/board-slot-instructions.js.map +1 -1
- package/dist/replay/import-manifest.d.ts +21 -0
- package/dist/replay/import-manifest.d.ts.map +1 -0
- package/dist/replay/import-manifest.js +157 -0
- package/dist/replay/import-manifest.js.map +1 -0
- package/dist/replay/jev-client.d.ts +35 -0
- package/dist/replay/jev-client.d.ts.map +1 -0
- package/dist/replay/jev-client.js +141 -0
- package/dist/replay/jev-client.js.map +1 -0
- package/dist/replay/kagemusha-import.d.ts +35 -0
- package/dist/replay/kagemusha-import.d.ts.map +1 -0
- package/dist/replay/kagemusha-import.js +543 -0
- package/dist/replay/kagemusha-import.js.map +1 -0
- package/dist/replay/replay-cursor.d.ts +31 -0
- package/dist/replay/replay-cursor.d.ts.map +1 -0
- package/dist/replay/replay-cursor.js +189 -0
- package/dist/replay/replay-cursor.js.map +1 -0
- package/dist/replay/replay-feeder.d.ts +55 -0
- package/dist/replay/replay-feeder.d.ts.map +1 -0
- package/dist/replay/replay-feeder.js +214 -0
- package/dist/replay/replay-feeder.js.map +1 -0
- package/dist/replay/replay-ledger.d.ts +32 -0
- package/dist/replay/replay-ledger.d.ts.map +1 -0
- package/dist/replay/replay-ledger.js +91 -0
- package/dist/replay/replay-ledger.js.map +1 -0
- package/dist/replay/replay-source-catalog.d.ts +66 -0
- package/dist/replay/replay-source-catalog.d.ts.map +1 -0
- package/dist/replay/replay-source-catalog.js +332 -0
- package/dist/replay/replay-source-catalog.js.map +1 -0
- package/dist/replay/trello-import.d.ts +33 -0
- package/dist/replay/trello-import.d.ts.map +1 -0
- package/dist/replay/trello-import.js +204 -0
- package/dist/replay/trello-import.js.map +1 -0
- package/dist/replay/window-queue.d.ts +116 -0
- package/dist/replay/window-queue.d.ts.map +1 -0
- package/dist/replay/window-queue.js +497 -0
- package/dist/replay/window-queue.js.map +1 -0
- package/dist/runtime/action-mcp-server.d.ts +30 -0
- package/dist/runtime/action-mcp-server.d.ts.map +1 -0
- package/dist/runtime/action-mcp-server.js +179 -0
- package/dist/runtime/action-mcp-server.js.map +1 -0
- package/dist/runtime/action-surface.d.ts +47 -0
- package/dist/runtime/action-surface.d.ts.map +1 -0
- package/dist/runtime/action-surface.js +182 -0
- package/dist/runtime/action-surface.js.map +1 -0
- package/dist/runtime/backend-security.d.ts +7 -0
- package/dist/runtime/backend-security.d.ts.map +1 -0
- package/dist/runtime/backend-security.js +28 -0
- package/dist/runtime/backend-security.js.map +1 -0
- package/dist/runtime/claude-caller-hook.d.ts +20 -0
- package/dist/runtime/claude-caller-hook.d.ts.map +1 -0
- package/dist/runtime/claude-caller-hook.js +41 -0
- package/dist/runtime/claude-caller-hook.js.map +1 -0
- package/dist/runtime/config.d.ts +84 -0
- package/dist/runtime/config.d.ts.map +1 -0
- package/dist/runtime/config.js +361 -0
- package/dist/runtime/config.js.map +1 -0
- package/dist/runtime/connectors.d.ts +41 -0
- package/dist/runtime/connectors.d.ts.map +1 -0
- package/dist/runtime/connectors.js +187 -0
- package/dist/runtime/connectors.js.map +1 -0
- package/dist/runtime/core-db.d.ts +8 -0
- package/dist/runtime/core-db.d.ts.map +1 -0
- package/dist/runtime/core-db.js +19 -0
- package/dist/runtime/core-db.js.map +1 -0
- package/dist/runtime/model-cache.d.ts +9 -0
- package/dist/runtime/model-cache.d.ts.map +1 -0
- package/dist/runtime/model-cache.js +22 -0
- package/dist/runtime/model-cache.js.map +1 -0
- package/dist/runtime/native-session.d.ts +80 -0
- package/dist/runtime/native-session.d.ts.map +1 -0
- package/dist/runtime/native-session.js +284 -0
- package/dist/runtime/native-session.js.map +1 -0
- package/dist/runtime/owner-policy.d.ts +10 -0
- package/dist/runtime/owner-policy.d.ts.map +1 -0
- package/dist/runtime/owner-policy.js +35 -0
- package/dist/runtime/owner-policy.js.map +1 -0
- package/dist/runtime/owner-runtime.d.ts +78 -0
- package/dist/runtime/owner-runtime.d.ts.map +1 -0
- package/dist/runtime/owner-runtime.js +255 -0
- package/dist/runtime/owner-runtime.js.map +1 -0
- package/dist/runtime/owner-system-prompt.d.ts +17 -0
- package/dist/runtime/owner-system-prompt.d.ts.map +1 -0
- package/dist/runtime/owner-system-prompt.js +122 -0
- package/dist/runtime/owner-system-prompt.js.map +1 -0
- package/dist/runtime/recent-owner-exchanges.d.ts +10 -0
- package/dist/runtime/recent-owner-exchanges.d.ts.map +1 -0
- package/dist/runtime/recent-owner-exchanges.js +53 -0
- package/dist/runtime/recent-owner-exchanges.js.map +1 -0
- package/dist/runtime/report-prompts.d.ts +14 -0
- package/dist/runtime/report-prompts.d.ts.map +1 -0
- package/dist/runtime/report-prompts.js +69 -0
- package/dist/runtime/report-prompts.js.map +1 -0
- package/dist/runtime/report-scheduler.d.ts +24 -0
- package/dist/runtime/report-scheduler.d.ts.map +1 -0
- package/dist/runtime/report-scheduler.js +97 -0
- package/dist/runtime/report-scheduler.js.map +1 -0
- package/dist/runtime/session-credential.d.ts +5 -0
- package/dist/runtime/session-credential.d.ts.map +1 -0
- package/dist/runtime/session-credential.js +19 -0
- package/dist/runtime/session-credential.js.map +1 -0
- package/dist/runtime/stimulus-delivery.d.ts +85 -0
- package/dist/runtime/stimulus-delivery.d.ts.map +1 -0
- package/dist/runtime/stimulus-delivery.js +590 -0
- package/dist/runtime/stimulus-delivery.js.map +1 -0
- package/dist/runtime/timezone.d.ts +13 -0
- package/dist/runtime/timezone.d.ts.map +1 -0
- package/dist/runtime/timezone.js +119 -0
- package/dist/runtime/timezone.js.map +1 -0
- package/dist/sqlite.d.ts +7 -32
- package/dist/sqlite.d.ts.map +1 -1
- package/dist/sqlite.js +10 -48
- package/dist/sqlite.js.map +1 -1
- package/dist/storage/migrations/raw-item-revisions.d.ts +6 -0
- package/dist/storage/migrations/raw-item-revisions.d.ts.map +1 -0
- package/dist/storage/migrations/raw-item-revisions.js +109 -0
- package/dist/storage/migrations/raw-item-revisions.js.map +1 -0
- package/dist/storage/migrations-source.d.ts +5 -0
- package/dist/storage/migrations-source.d.ts.map +1 -0
- package/dist/storage/migrations-source.js +24 -0
- package/dist/storage/migrations-source.js.map +1 -0
- package/dist/storage/source-archive.d.ts +123 -0
- package/dist/storage/source-archive.d.ts.map +1 -0
- package/dist/storage/source-archive.js +595 -0
- package/dist/storage/source-archive.js.map +1 -0
- package/dist/storage-sqlite.d.ts +59 -0
- package/dist/storage-sqlite.d.ts.map +1 -0
- package/dist/storage-sqlite.js +75 -0
- package/dist/storage-sqlite.js.map +1 -0
- package/dist/utils/untrusted-content.d.ts +5 -35
- package/dist/utils/untrusted-content.d.ts.map +1 -1
- package/dist/utils/untrusted-content.js +16 -75
- package/dist/utils/untrusted-content.js.map +1 -1
- package/dist/wiki/obsidian-writer.d.ts +4 -2
- package/dist/wiki/obsidian-writer.d.ts.map +1 -1
- package/dist/wiki/obsidian-writer.js +85 -4
- package/dist/wiki/obsidian-writer.js.map +1 -1
- package/dist/wiki/path-safety.d.ts +2 -0
- package/dist/wiki/path-safety.d.ts.map +1 -1
- package/dist/wiki/path-safety.js +11 -3
- package/dist/wiki/path-safety.js.map +1 -1
- package/dist/wiki/wiki-edits.d.ts +17 -0
- package/dist/wiki/wiki-edits.d.ts.map +1 -0
- package/dist/wiki/wiki-edits.js +75 -0
- package/dist/wiki/wiki-edits.js.map +1 -0
- package/dist/wiki/wiki-read.d.ts +20 -11
- package/dist/wiki/wiki-read.d.ts.map +1 -1
- package/dist/wiki/wiki-read.js +87 -89
- package/dist/wiki/wiki-read.js.map +1 -1
- package/dist/wiki-artifacts/types.d.ts +1 -1
- package/dist/wiki-artifacts/types.d.ts.map +1 -1
- package/dist/wiki-artifacts/wiki-publish-adapter.d.ts.map +1 -1
- package/dist/wiki-artifacts/wiki-publish-adapter.js +13 -9
- package/dist/wiki-artifacts/wiki-publish-adapter.js.map +1 -1
- package/package.json +11 -41
- package/public/viewer/js/modules/graph.js +111 -41
- package/public/viewer/js/modules/memory.js +4 -31
- package/public/viewer/js/modules/wiki.js +0 -37
- package/public/viewer/js/utils/api.js +4 -50
- package/public/viewer/log-viewer.html +46 -0
- package/public/viewer/operator/operator.css +1 -1
- package/public/viewer/operator/operator.js +10835 -8211
- package/public/viewer/src/modules/graph.ts +133 -41
- package/public/viewer/src/modules/memory.ts +4 -31
- package/public/viewer/src/modules/wiki.ts +0 -42
- package/public/viewer/src/types/global.d.ts +1 -1
- package/public/viewer/src/utils/api.ts +7 -83
- package/public/viewer/viewer.html +7 -96
- package/dist/agent/agent-loop.d.ts +0 -289
- package/dist/agent/agent-loop.d.ts.map +0 -1
- package/dist/agent/agent-loop.js +0 -2842
- package/dist/agent/agent-loop.js.map +0 -1
- package/dist/agent/attachment-text-extractor.d.ts +0 -2
- package/dist/agent/attachment-text-extractor.d.ts.map +0 -1
- package/dist/agent/attachment-text-extractor.js +0 -128
- package/dist/agent/attachment-text-extractor.js.map +0 -1
- package/dist/agent/backend-model-policy.d.ts +0 -58
- package/dist/agent/backend-model-policy.d.ts.map +0 -1
- package/dist/agent/backend-model-policy.js +0 -167
- package/dist/agent/backend-model-policy.js.map +0 -1
- package/dist/agent/backend-model-runner-factory.d.ts +0 -27
- package/dist/agent/backend-model-runner-factory.d.ts.map +0 -1
- package/dist/agent/backend-model-runner-factory.js +0 -88
- package/dist/agent/backend-model-runner-factory.js.map +0 -1
- package/dist/agent/claude-cli-wrapper.d.ts +0 -144
- package/dist/agent/claude-cli-wrapper.d.ts.map +0 -1
- package/dist/agent/claude-cli-wrapper.js +0 -382
- package/dist/agent/claude-cli-wrapper.js.map +0 -1
- package/dist/agent/cli-arg-redaction.d.ts +0 -2
- package/dist/agent/cli-arg-redaction.d.ts.map +0 -1
- package/dist/agent/cli-arg-redaction.js +0 -18
- package/dist/agent/cli-arg-redaction.js.map +0 -1
- package/dist/agent/cline-cli-adapter.d.ts +0 -126
- package/dist/agent/cline-cli-adapter.d.ts.map +0 -1
- package/dist/agent/cline-cli-adapter.js +0 -1042
- package/dist/agent/cline-cli-adapter.js.map +0 -1
- package/dist/agent/cline-native-tool-policy.d.ts +0 -9
- package/dist/agent/cline-native-tool-policy.d.ts.map +0 -1
- package/dist/agent/cline-native-tool-policy.js +0 -61
- package/dist/agent/cline-native-tool-policy.js.map +0 -1
- package/dist/agent/code-act/completed-terminal-result.d.ts +0 -5
- package/dist/agent/code-act/completed-terminal-result.d.ts.map +0 -1
- package/dist/agent/code-act/completed-terminal-result.js +0 -83
- package/dist/agent/code-act/completed-terminal-result.js.map +0 -1
- package/dist/agent/code-act/constants.d.ts +0 -11
- package/dist/agent/code-act/constants.d.ts.map +0 -1
- package/dist/agent/code-act/constants.js +0 -64
- package/dist/agent/code-act/constants.js.map +0 -1
- package/dist/agent/code-act/host-bridge.d.ts +0 -50
- package/dist/agent/code-act/host-bridge.d.ts.map +0 -1
- package/dist/agent/code-act/host-bridge.js +0 -1405
- package/dist/agent/code-act/host-bridge.js.map +0 -1
- package/dist/agent/code-act/index.d.ts +0 -10
- package/dist/agent/code-act/index.d.ts.map +0 -1
- package/dist/agent/code-act/index.js +0 -22
- package/dist/agent/code-act/index.js.map +0 -1
- package/dist/agent/code-act/run-context-registry.d.ts +0 -36
- package/dist/agent/code-act/run-context-registry.d.ts.map +0 -1
- package/dist/agent/code-act/run-context-registry.js +0 -143
- package/dist/agent/code-act/run-context-registry.js.map +0 -1
- package/dist/agent/code-act/sandbox.d.ts +0 -25
- package/dist/agent/code-act/sandbox.d.ts.map +0 -1
- package/dist/agent/code-act/sandbox.js +0 -494
- package/dist/agent/code-act/sandbox.js.map +0 -1
- package/dist/agent/code-act/tool-catalog.d.ts +0 -30
- package/dist/agent/code-act/tool-catalog.d.ts.map +0 -1
- package/dist/agent/code-act/tool-catalog.js +0 -185
- package/dist/agent/code-act/tool-catalog.js.map +0 -1
- package/dist/agent/code-act/tool-policy.d.ts +0 -51
- package/dist/agent/code-act/tool-policy.d.ts.map +0 -1
- package/dist/agent/code-act/tool-policy.js +0 -160
- package/dist/agent/code-act/tool-policy.js.map +0 -1
- package/dist/agent/code-act/type-definition-generator.d.ts +0 -19
- package/dist/agent/code-act/type-definition-generator.d.ts.map +0 -1
- package/dist/agent/code-act/type-definition-generator.js +0 -73
- package/dist/agent/code-act/type-definition-generator.js.map +0 -1
- package/dist/agent/code-act/types.d.ts +0 -57
- package/dist/agent/code-act/types.d.ts.map +0 -1
- package/dist/agent/code-act/types.js +0 -14
- package/dist/agent/code-act/types.js.map +0 -1
- package/dist/agent/codex-app-server-process.d.ts +0 -257
- package/dist/agent/codex-app-server-process.d.ts.map +0 -1
- package/dist/agent/codex-app-server-process.js +0 -2084
- package/dist/agent/codex-app-server-process.js.map +0 -1
- package/dist/agent/codex-auth.d.ts +0 -2
- package/dist/agent/codex-auth.d.ts.map +0 -1
- package/dist/agent/codex-auth.js +0 -17
- package/dist/agent/codex-auth.js.map +0 -1
- package/dist/agent/codex-auxiliary-tools.d.ts +0 -17
- package/dist/agent/codex-auxiliary-tools.d.ts.map +0 -1
- package/dist/agent/codex-auxiliary-tools.js +0 -267
- package/dist/agent/codex-auxiliary-tools.js.map +0 -1
- package/dist/agent/codex-home.d.ts +0 -13
- package/dist/agent/codex-home.d.ts.map +0 -1
- package/dist/agent/codex-home.js +0 -644
- package/dist/agent/codex-home.js.map +0 -1
- package/dist/agent/codex-thread-registry.d.ts +0 -63
- package/dist/agent/codex-thread-registry.d.ts.map +0 -1
- package/dist/agent/codex-thread-registry.js +0 -433
- package/dist/agent/codex-thread-registry.js.map +0 -1
- package/dist/agent/content-dedup.d.ts +0 -86
- package/dist/agent/content-dedup.d.ts.map +0 -1
- package/dist/agent/content-dedup.js +0 -114
- package/dist/agent/content-dedup.js.map +0 -1
- package/dist/agent/context-compile-contract.d.ts +0 -5
- package/dist/agent/context-compile-contract.d.ts.map +0 -1
- package/dist/agent/context-compile-contract.js +0 -8
- package/dist/agent/context-compile-contract.js.map +0 -1
- package/dist/agent/context-compile-service.d.ts +0 -60
- package/dist/agent/context-compile-service.d.ts.map +0 -1
- package/dist/agent/context-compile-service.js +0 -481
- package/dist/agent/context-compile-service.js.map +0 -1
- package/dist/agent/context-prompt-builder.d.ts +0 -24
- package/dist/agent/context-prompt-builder.d.ts.map +0 -1
- package/dist/agent/context-prompt-builder.js +0 -61
- package/dist/agent/context-prompt-builder.js.map +0 -1
- package/dist/agent/contract-extractor.d.ts +0 -124
- package/dist/agent/contract-extractor.d.ts.map +0 -1
- package/dist/agent/contract-extractor.js +0 -465
- package/dist/agent/contract-extractor.js.map +0 -1
- package/dist/agent/drive-tools.d.ts +0 -83
- package/dist/agent/drive-tools.d.ts.map +0 -1
- package/dist/agent/drive-tools.js +0 -338
- package/dist/agent/drive-tools.js.map +0 -1
- package/dist/agent/gateway-tool-catalog.d.ts +0 -14
- package/dist/agent/gateway-tool-catalog.d.ts.map +0 -1
- package/dist/agent/gateway-tool-catalog.js +0 -41
- package/dist/agent/gateway-tool-catalog.js.map +0 -1
- package/dist/agent/gateway-tool-executor.d.ts +0 -353
- package/dist/agent/gateway-tool-executor.d.ts.map +0 -1
- package/dist/agent/gateway-tool-executor.js +0 -5448
- package/dist/agent/gateway-tool-executor.js.map +0 -1
- package/dist/agent/gateway-tools.md +0 -166
- package/dist/agent/image-translation-tools.d.ts +0 -48
- package/dist/agent/image-translation-tools.d.ts.map +0 -1
- package/dist/agent/image-translation-tools.js +0 -274
- package/dist/agent/image-translation-tools.js.map +0 -1
- package/dist/agent/index.d.ts +0 -13
- package/dist/agent/index.d.ts.map +0 -1
- package/dist/agent/index.js +0 -18
- package/dist/agent/index.js.map +0 -1
- package/dist/agent/mama-tool-handlers.d.ts +0 -11
- package/dist/agent/mama-tool-handlers.d.ts.map +0 -1
- package/dist/agent/mama-tool-handlers.js +0 -220
- package/dist/agent/mama-tool-handlers.js.map +0 -1
- package/dist/agent/managed-agent-runtime-sync.d.ts +0 -36
- package/dist/agent/managed-agent-runtime-sync.d.ts.map +0 -1
- package/dist/agent/managed-agent-runtime-sync.js +0 -245
- package/dist/agent/managed-agent-runtime-sync.js.map +0 -1
- package/dist/agent/managed-agent-validation.d.ts +0 -4
- package/dist/agent/managed-agent-validation.d.ts.map +0 -1
- package/dist/agent/managed-agent-validation.js +0 -85
- package/dist/agent/managed-agent-validation.js.map +0 -1
- package/dist/agent/model-runner.d.ts +0 -180
- package/dist/agent/model-runner.d.ts.map +0 -1
- package/dist/agent/model-runner.js +0 -54
- package/dist/agent/model-runner.js.map +0 -1
- package/dist/agent/native-effect-observer.d.ts +0 -20
- package/dist/agent/native-effect-observer.d.ts.map +0 -1
- package/dist/agent/native-effect-observer.js +0 -86
- package/dist/agent/native-effect-observer.js.map +0 -1
- package/dist/agent/obsidian-cli-args.d.ts +0 -14
- package/dist/agent/obsidian-cli-args.d.ts.map +0 -1
- package/dist/agent/obsidian-cli-args.js +0 -57
- package/dist/agent/obsidian-cli-args.js.map +0 -1
- package/dist/agent/os-agent-capabilities.md +0 -367
- package/dist/agent/persistent-cli-adapter.d.ts +0 -173
- package/dist/agent/persistent-cli-adapter.d.ts.map +0 -1
- package/dist/agent/persistent-cli-adapter.js +0 -467
- package/dist/agent/persistent-cli-adapter.js.map +0 -1
- package/dist/agent/persistent-cli-process.d.ts +0 -392
- package/dist/agent/persistent-cli-process.d.ts.map +0 -1
- package/dist/agent/persistent-cli-process.js +0 -1568
- package/dist/agent/persistent-cli-process.js.map +0 -1
- package/dist/agent/post-tool-handler.d.ts +0 -27
- package/dist/agent/post-tool-handler.d.ts.map +0 -1
- package/dist/agent/post-tool-handler.js +0 -194
- package/dist/agent/post-tool-handler.js.map +0 -1
- package/dist/agent/pre-compact-handler.d.ts +0 -36
- package/dist/agent/pre-compact-handler.d.ts.map +0 -1
- package/dist/agent/pre-compact-handler.js +0 -162
- package/dist/agent/pre-compact-handler.js.map +0 -1
- package/dist/agent/prompt-enhancer.d.ts +0 -33
- package/dist/agent/prompt-enhancer.d.ts.map +0 -1
- package/dist/agent/prompt-enhancer.js +0 -811
- package/dist/agent/prompt-enhancer.js.map +0 -1
- package/dist/agent/prompt-size-monitor.d.ts +0 -104
- package/dist/agent/prompt-size-monitor.d.ts.map +0 -1
- package/dist/agent/prompt-size-monitor.js +0 -192
- package/dist/agent/prompt-size-monitor.js.map +0 -1
- package/dist/agent/role-manager.d.ts +0 -122
- package/dist/agent/role-manager.d.ts.map +0 -1
- package/dist/agent/role-manager.js +0 -300
- package/dist/agent/role-manager.js.map +0 -1
- package/dist/agent/session-pool.d.ts +0 -176
- package/dist/agent/session-pool.d.ts.map +0 -1
- package/dist/agent/session-pool.js +0 -368
- package/dist/agent/session-pool.js.map +0 -1
- package/dist/agent/skill-loader.d.ts +0 -87
- package/dist/agent/skill-loader.d.ts.map +0 -1
- package/dist/agent/skill-loader.js +0 -461
- package/dist/agent/skill-loader.js.map +0 -1
- package/dist/agent/stop-continuation-handler.d.ts +0 -106
- package/dist/agent/stop-continuation-handler.d.ts.map +0 -1
- package/dist/agent/stop-continuation-handler.js +0 -230
- package/dist/agent/stop-continuation-handler.js.map +0 -1
- package/dist/agent/subagent-run-reconcile.d.ts +0 -23
- package/dist/agent/subagent-run-reconcile.d.ts.map +0 -1
- package/dist/agent/subagent-run-reconcile.js +0 -56
- package/dist/agent/subagent-run-reconcile.js.map +0 -1
- package/dist/agent/temporal-code-act-breaker.d.ts +0 -26
- package/dist/agent/temporal-code-act-breaker.d.ts.map +0 -1
- package/dist/agent/temporal-code-act-breaker.js +0 -94
- package/dist/agent/temporal-code-act-breaker.js.map +0 -1
- package/dist/agent/token-estimator.d.ts +0 -25
- package/dist/agent/token-estimator.d.ts.map +0 -1
- package/dist/agent/token-estimator.js +0 -75
- package/dist/agent/token-estimator.js.map +0 -1
- package/dist/agent/tool-registry.d.ts +0 -81
- package/dist/agent/tool-registry.d.ts.map +0 -1
- package/dist/agent/tool-registry.js +0 -876
- package/dist/agent/tool-registry.js.map +0 -1
- package/dist/agent/types.d.ts +0 -1261
- package/dist/agent/types.d.ts.map +0 -1
- package/dist/agent/types.js +0 -60
- package/dist/agent/types.js.map +0 -1
- package/dist/agent/yaml-frontmatter.d.ts +0 -75
- package/dist/agent/yaml-frontmatter.d.ts.map +0 -1
- package/dist/agent/yaml-frontmatter.js +0 -166
- package/dist/agent/yaml-frontmatter.js.map +0 -1
- package/dist/api/agent-context-handler.d.ts +0 -10
- package/dist/api/agent-context-handler.d.ts.map +0 -1
- package/dist/api/agent-context-handler.js +0 -216
- package/dist/api/agent-context-handler.js.map +0 -1
- package/dist/api/agent-graph-handler.d.ts +0 -18
- package/dist/api/agent-graph-handler.d.ts.map +0 -1
- package/dist/api/agent-graph-handler.js +0 -569
- package/dist/api/agent-graph-handler.js.map +0 -1
- package/dist/api/agent-handler.d.ts +0 -36
- package/dist/api/agent-handler.d.ts.map +0 -1
- package/dist/api/agent-handler.js +0 -223
- package/dist/api/agent-handler.js.map +0 -1
- package/dist/api/agent-raw-handler.d.ts +0 -70
- package/dist/api/agent-raw-handler.d.ts.map +0 -1
- package/dist/api/agent-raw-handler.js +0 -262
- package/dist/api/agent-raw-handler.js.map +0 -1
- package/dist/api/agent-situation-handler.d.ts +0 -14
- package/dist/api/agent-situation-handler.d.ts.map +0 -1
- package/dist/api/agent-situation-handler.js +0 -383
- package/dist/api/agent-situation-handler.js.map +0 -1
- package/dist/api/connector-feed-handler.d.ts +0 -42
- package/dist/api/connector-feed-handler.d.ts.map +0 -1
- package/dist/api/connector-feed-handler.js +0 -180
- package/dist/api/connector-feed-handler.js.map +0 -1
- package/dist/api/cron-handler.d.ts +0 -44
- package/dist/api/cron-handler.d.ts.map +0 -1
- package/dist/api/cron-handler.js +0 -261
- package/dist/api/cron-handler.js.map +0 -1
- package/dist/api/entity-audit-handler.d.ts +0 -12
- package/dist/api/entity-audit-handler.d.ts.map +0 -1
- package/dist/api/entity-audit-handler.js +0 -119
- package/dist/api/entity-audit-handler.js.map +0 -1
- package/dist/api/entity-audit-queue.d.ts +0 -74
- package/dist/api/entity-audit-queue.d.ts.map +0 -1
- package/dist/api/entity-audit-queue.js +0 -123
- package/dist/api/entity-audit-queue.js.map +0 -1
- package/dist/api/entity-audit-runner.d.ts +0 -9
- package/dist/api/entity-audit-runner.d.ts.map +0 -1
- package/dist/api/entity-audit-runner.js +0 -240
- package/dist/api/entity-audit-runner.js.map +0 -1
- package/dist/api/entity-review-handler.d.ts +0 -18
- package/dist/api/entity-review-handler.d.ts.map +0 -1
- package/dist/api/entity-review-handler.js +0 -521
- package/dist/api/entity-review-handler.js.map +0 -1
- package/dist/api/error-handler.d.ts +0 -22
- package/dist/api/error-handler.d.ts.map +0 -1
- package/dist/api/error-handler.js +0 -104
- package/dist/api/error-handler.js.map +0 -1
- package/dist/api/graph-api-types.d.ts +0 -105
- package/dist/api/graph-api-types.d.ts.map +0 -1
- package/dist/api/graph-api-types.js +0 -6
- package/dist/api/graph-api-types.js.map +0 -1
- package/dist/api/graph-api.d.ts +0 -42
- package/dist/api/graph-api.d.ts.map +0 -1
- package/dist/api/graph-api.js +0 -3460
- package/dist/api/graph-api.js.map +0 -1
- package/dist/api/heartbeat-handler.d.ts +0 -49
- package/dist/api/heartbeat-handler.d.ts.map +0 -1
- package/dist/api/heartbeat-handler.js +0 -106
- package/dist/api/heartbeat-handler.js.map +0 -1
- package/dist/api/index.d.ts +0 -145
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -448
- package/dist/api/index.js.map +0 -1
- package/dist/api/intelligence-handler.d.ts +0 -116
- package/dist/api/intelligence-handler.d.ts.map +0 -1
- package/dist/api/intelligence-handler.js +0 -280
- package/dist/api/intelligence-handler.js.map +0 -1
- package/dist/api/memory-provenance-handler.d.ts +0 -3
- package/dist/api/memory-provenance-handler.d.ts.map +0 -1
- package/dist/api/memory-provenance-handler.js +0 -120
- package/dist/api/memory-provenance-handler.js.map +0 -1
- package/dist/api/operator-handler.d.ts +0 -19
- package/dist/api/operator-handler.d.ts.map +0 -1
- package/dist/api/operator-handler.js +0 -106
- package/dist/api/operator-handler.js.map +0 -1
- package/dist/api/operator-summary.d.ts +0 -3
- package/dist/api/operator-summary.d.ts.map +0 -1
- package/dist/api/operator-summary.js +0 -72
- package/dist/api/operator-summary.js.map +0 -1
- package/dist/api/operator-tasks-handler.d.ts +0 -7
- package/dist/api/operator-tasks-handler.d.ts.map +0 -1
- package/dist/api/operator-tasks-handler.js +0 -192
- package/dist/api/operator-tasks-handler.js.map +0 -1
- package/dist/api/runtime-status-handler.d.ts +0 -42
- package/dist/api/runtime-status-handler.d.ts.map +0 -1
- package/dist/api/runtime-status-handler.js +0 -56
- package/dist/api/runtime-status-handler.js.map +0 -1
- package/dist/api/skills-handler.d.ts +0 -12
- package/dist/api/skills-handler.d.ts.map +0 -1
- package/dist/api/skills-handler.js +0 -156
- package/dist/api/skills-handler.js.map +0 -1
- package/dist/api/token-handler.d.ts +0 -33
- package/dist/api/token-handler.d.ts.map +0 -1
- package/dist/api/token-handler.js +0 -118
- package/dist/api/token-handler.js.map +0 -1
- package/dist/api/types.d.ts +0 -155
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -49
- package/dist/api/types.js.map +0 -1
- package/dist/api/ui-command-handler.d.ts +0 -48
- package/dist/api/ui-command-handler.d.ts.map +0 -1
- package/dist/api/ui-command-handler.js +0 -160
- package/dist/api/ui-command-handler.js.map +0 -1
- package/dist/api/upload-handler.d.ts +0 -12
- package/dist/api/upload-handler.d.ts.map +0 -1
- package/dist/api/upload-handler.js +0 -321
- package/dist/api/upload-handler.js.map +0 -1
- package/dist/api/wiki-handler.d.ts +0 -19
- package/dist/api/wiki-handler.d.ts.map +0 -1
- package/dist/api/wiki-handler.js +0 -136
- package/dist/api/wiki-handler.js.map +0 -1
- package/dist/api/worker-envelope.d.ts +0 -26
- package/dist/api/worker-envelope.d.ts.map +0 -1
- package/dist/api/worker-envelope.js +0 -176
- package/dist/api/worker-envelope.js.map +0 -1
- package/dist/auth/claude-client.d.ts +0 -12
- package/dist/auth/claude-client.d.ts.map +0 -1
- package/dist/auth/claude-client.js +0 -36
- package/dist/auth/claude-client.js.map +0 -1
- package/dist/auth/claude-code-auth.d.ts +0 -12
- package/dist/auth/claude-code-auth.d.ts.map +0 -1
- package/dist/auth/claude-code-auth.js +0 -85
- package/dist/auth/claude-code-auth.js.map +0 -1
- package/dist/auth/index.d.ts +0 -9
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -13
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/oauth-manager.d.ts +0 -59
- package/dist/auth/oauth-manager.d.ts.map +0 -1
- package/dist/auth/oauth-manager.js +0 -252
- package/dist/auth/oauth-manager.js.map +0 -1
- package/dist/auth/types.d.ts +0 -92
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js +0 -23
- package/dist/auth/types.js.map +0 -1
- package/dist/cli/commands/connector.d.ts +0 -14
- package/dist/cli/commands/connector.d.ts.map +0 -1
- package/dist/cli/commands/connector.js +0 -174
- package/dist/cli/commands/connector.js.map +0 -1
- package/dist/cli/commands/gateway.d.ts +0 -18
- package/dist/cli/commands/gateway.d.ts.map +0 -1
- package/dist/cli/commands/gateway.js +0 -144
- package/dist/cli/commands/gateway.js.map +0 -1
- package/dist/cli/commands/report.d.ts +0 -14
- package/dist/cli/commands/report.d.ts.map +0 -1
- package/dist/cli/commands/report.js +0 -102
- package/dist/cli/commands/report.js.map +0 -1
- package/dist/cli/commands/run.d.ts +0 -19
- package/dist/cli/commands/run.d.ts.map +0 -1
- package/dist/cli/commands/run.js +0 -123
- package/dist/cli/commands/run.js.map +0 -1
- package/dist/cli/commands/setup.d.ts +0 -3
- package/dist/cli/commands/setup.d.ts.map +0 -1
- package/dist/cli/commands/setup.js +0 -9
- package/dist/cli/commands/setup.js.map +0 -1
- package/dist/cli/commands/start.d.ts +0 -263
- package/dist/cli/commands/start.d.ts.map +0 -1
- package/dist/cli/commands/start.js +0 -2230
- package/dist/cli/commands/start.js.map +0 -1
- package/dist/cli/commands/status.d.ts +0 -18
- package/dist/cli/commands/status.d.ts.map +0 -1
- package/dist/cli/commands/status.js +0 -326
- package/dist/cli/commands/status.js.map +0 -1
- package/dist/cli/commands/stop.d.ts +0 -28
- package/dist/cli/commands/stop.d.ts.map +0 -1
- package/dist/cli/commands/stop.js +0 -597
- package/dist/cli/commands/stop.js.map +0 -1
- package/dist/cli/config/config-manager.d.ts +0 -84
- package/dist/cli/config/config-manager.d.ts.map +0 -1
- package/dist/cli/config/config-manager.js +0 -886
- package/dist/cli/config/config-manager.js.map +0 -1
- package/dist/cli/config/types.d.ts +0 -633
- package/dist/cli/config/types.d.ts.map +0 -1
- package/dist/cli/config/types.js +0 -247
- package/dist/cli/config/types.js.map +0 -1
- package/dist/cli/runtime/agent-loop-init.d.ts +0 -53
- package/dist/cli/runtime/agent-loop-init.d.ts.map +0 -1
- package/dist/cli/runtime/agent-loop-init.js +0 -368
- package/dist/cli/runtime/agent-loop-init.js.map +0 -1
- package/dist/cli/runtime/api-routes-init.d.ts +0 -84
- package/dist/cli/runtime/api-routes-init.d.ts.map +0 -1
- package/dist/cli/runtime/api-routes-init.js +0 -1542
- package/dist/cli/runtime/api-routes-init.js.map +0 -1
- package/dist/cli/runtime/api-server-init.d.ts +0 -59
- package/dist/cli/runtime/api-server-init.d.ts.map +0 -1
- package/dist/cli/runtime/api-server-init.js +0 -159
- package/dist/cli/runtime/api-server-init.js.map +0 -1
- package/dist/cli/runtime/code-act-executor.d.ts +0 -14
- package/dist/cli/runtime/code-act-executor.d.ts.map +0 -1
- package/dist/cli/runtime/code-act-executor.js +0 -108
- package/dist/cli/runtime/code-act-executor.js.map +0 -1
- package/dist/cli/runtime/connector-bootstrap.d.ts +0 -8
- package/dist/cli/runtime/connector-bootstrap.d.ts.map +0 -1
- package/dist/cli/runtime/connector-bootstrap.js +0 -14
- package/dist/cli/runtime/connector-bootstrap.js.map +0 -1
- package/dist/cli/runtime/connector-init.d.ts +0 -64
- package/dist/cli/runtime/connector-init.d.ts.map +0 -1
- package/dist/cli/runtime/connector-init.js +0 -237
- package/dist/cli/runtime/connector-init.js.map +0 -1
- package/dist/cli/runtime/daemon.d.ts +0 -38
- package/dist/cli/runtime/daemon.d.ts.map +0 -1
- package/dist/cli/runtime/daemon.js +0 -263
- package/dist/cli/runtime/daemon.js.map +0 -1
- package/dist/cli/runtime/envelope-bootstrap.d.ts +0 -17
- package/dist/cli/runtime/envelope-bootstrap.d.ts.map +0 -1
- package/dist/cli/runtime/envelope-bootstrap.js +0 -56
- package/dist/cli/runtime/envelope-bootstrap.js.map +0 -1
- package/dist/cli/runtime/gateway-init.d.ts +0 -55
- package/dist/cli/runtime/gateway-init.d.ts.map +0 -1
- package/dist/cli/runtime/gateway-init.js +0 -196
- package/dist/cli/runtime/gateway-init.js.map +0 -1
- package/dist/cli/runtime/gateway-wiring.d.ts +0 -51
- package/dist/cli/runtime/gateway-wiring.d.ts.map +0 -1
- package/dist/cli/runtime/gateway-wiring.js +0 -215
- package/dist/cli/runtime/gateway-wiring.js.map +0 -1
- package/dist/cli/runtime/mama-core-init.d.ts +0 -42
- package/dist/cli/runtime/mama-core-init.d.ts.map +0 -1
- package/dist/cli/runtime/mama-core-init.js +0 -211
- package/dist/cli/runtime/mama-core-init.js.map +0 -1
- package/dist/cli/runtime/message-router-config.d.ts +0 -4
- package/dist/cli/runtime/message-router-config.d.ts.map +0 -1
- package/dist/cli/runtime/message-router-config.js +0 -11
- package/dist/cli/runtime/message-router-config.js.map +0 -1
- package/dist/cli/runtime/metrics-init.d.ts +0 -28
- package/dist/cli/runtime/metrics-init.d.ts.map +0 -1
- package/dist/cli/runtime/metrics-init.js +0 -131
- package/dist/cli/runtime/metrics-init.js.map +0 -1
- package/dist/cli/runtime/owner-backfill.d.ts +0 -24
- package/dist/cli/runtime/owner-backfill.d.ts.map +0 -1
- package/dist/cli/runtime/owner-backfill.js +0 -24
- package/dist/cli/runtime/owner-backfill.js.map +0 -1
- package/dist/cli/runtime/scheduler-init.d.ts +0 -60
- package/dist/cli/runtime/scheduler-init.d.ts.map +0 -1
- package/dist/cli/runtime/scheduler-init.js +0 -173
- package/dist/cli/runtime/scheduler-init.js.map +0 -1
- package/dist/cli/runtime/server-start.d.ts +0 -23
- package/dist/cli/runtime/server-start.d.ts.map +0 -1
- package/dist/cli/runtime/server-start.js +0 -174
- package/dist/cli/runtime/server-start.js.map +0 -1
- package/dist/cli/runtime/shutdown.d.ts +0 -46
- package/dist/cli/runtime/shutdown.d.ts.map +0 -1
- package/dist/cli/runtime/shutdown.js +0 -240
- package/dist/cli/runtime/shutdown.js.map +0 -1
- package/dist/cli/runtime/temporal-init.d.ts +0 -26
- package/dist/cli/runtime/temporal-init.d.ts.map +0 -1
- package/dist/cli/runtime/temporal-init.js +0 -57
- package/dist/cli/runtime/temporal-init.js.map +0 -1
- package/dist/cli/runtime/types.d.ts +0 -127
- package/dist/cli/runtime/types.d.ts.map +0 -1
- package/dist/cli/runtime/types.js +0 -12
- package/dist/cli/runtime/types.js.map +0 -1
- package/dist/cli/runtime/utilities.d.ts +0 -72
- package/dist/cli/runtime/utilities.d.ts.map +0 -1
- package/dist/cli/runtime/utilities.js +0 -472
- package/dist/cli/runtime/utilities.js.map +0 -1
- package/dist/cli/shutdown-utils.d.ts +0 -6
- package/dist/cli/shutdown-utils.d.ts.map +0 -1
- package/dist/cli/shutdown-utils.js +0 -11
- package/dist/cli/shutdown-utils.js.map +0 -1
- package/dist/cli/utils/pid-manager.d.ts +0 -56
- package/dist/cli/utils/pid-manager.d.ts.map +0 -1
- package/dist/cli/utils/pid-manager.js +0 -141
- package/dist/cli/utils/pid-manager.js.map +0 -1
- package/dist/concurrency/index.d.ts +0 -13
- package/dist/concurrency/index.d.ts.map +0 -1
- package/dist/concurrency/index.js +0 -22
- package/dist/concurrency/index.js.map +0 -1
- package/dist/concurrency/lane-manager.d.ts +0 -113
- package/dist/concurrency/lane-manager.d.ts.map +0 -1
- package/dist/concurrency/lane-manager.js +0 -248
- package/dist/concurrency/lane-manager.js.map +0 -1
- package/dist/concurrency/session-key.d.ts +0 -41
- package/dist/concurrency/session-key.d.ts.map +0 -1
- package/dist/concurrency/session-key.js +0 -61
- package/dist/concurrency/session-key.js.map +0 -1
- package/dist/concurrency/types.d.ts +0 -73
- package/dist/concurrency/types.d.ts.map +0 -1
- package/dist/concurrency/types.js +0 -16
- package/dist/concurrency/types.js.map +0 -1
- package/dist/connectors/framework/raw-store.d.ts +0 -63
- package/dist/connectors/framework/raw-store.d.ts.map +0 -1
- package/dist/connectors/framework/raw-store.js +0 -356
- package/dist/connectors/framework/raw-store.js.map +0 -1
- package/dist/connectors/kagemusha/query-tools.d.ts +0 -146
- package/dist/connectors/kagemusha/query-tools.d.ts.map +0 -1
- package/dist/connectors/kagemusha/query-tools.js +0 -467
- package/dist/connectors/kagemusha/query-tools.js.map +0 -1
- package/dist/connectors/private-connector-policy.d.ts +0 -174
- package/dist/connectors/private-connector-policy.d.ts.map +0 -1
- package/dist/connectors/private-connector-policy.js +0 -299
- package/dist/connectors/private-connector-policy.js.map +0 -1
- package/dist/connectors/private-prompt-overlay.d.ts +0 -17
- package/dist/connectors/private-prompt-overlay.d.ts.map +0 -1
- package/dist/connectors/private-prompt-overlay.js +0 -156
- package/dist/connectors/private-prompt-overlay.js.map +0 -1
- package/dist/connectors/trello/query-tools.d.ts +0 -243
- package/dist/connectors/trello/query-tools.d.ts.map +0 -1
- package/dist/connectors/trello/query-tools.js +0 -661
- package/dist/connectors/trello/query-tools.js.map +0 -1
- package/dist/db/agent-store.d.ts +0 -145
- package/dist/db/agent-store.d.ts.map +0 -1
- package/dist/db/agent-store.js +0 -279
- package/dist/db/agent-store.js.map +0 -1
- package/dist/db/migrations/agent-activity-envelope-hash.d.ts +0 -3
- package/dist/db/migrations/agent-activity-envelope-hash.d.ts.map +0 -1
- package/dist/db/migrations/agent-activity-envelope-hash.js +0 -29
- package/dist/db/migrations/agent-activity-envelope-hash.js.map +0 -1
- package/dist/db/migrations/agent-activity-gateway-call-id.d.ts +0 -3
- package/dist/db/migrations/agent-activity-gateway-call-id.d.ts.map +0 -1
- package/dist/db/migrations/agent-activity-gateway-call-id.js +0 -17
- package/dist/db/migrations/agent-activity-gateway-call-id.js.map +0 -1
- package/dist/db/migrations/agent-activity-tool-name.d.ts +0 -8
- package/dist/db/migrations/agent-activity-tool-name.d.ts.map +0 -1
- package/dist/db/migrations/agent-activity-tool-name.js +0 -24
- package/dist/db/migrations/agent-activity-tool-name.js.map +0 -1
- package/dist/db/migrations/agent-activity-validation-columns.d.ts +0 -3
- package/dist/db/migrations/agent-activity-validation-columns.d.ts.map +0 -1
- package/dist/db/migrations/agent-activity-validation-columns.js +0 -22
- package/dist/db/migrations/agent-activity-validation-columns.js.map +0 -1
- package/dist/db/migrations/agent-metrics-response-avg.d.ts +0 -3
- package/dist/db/migrations/agent-metrics-response-avg.d.ts.map +0 -1
- package/dist/db/migrations/agent-metrics-response-avg.js +0 -19
- package/dist/db/migrations/agent-metrics-response-avg.js.map +0 -1
- package/dist/db/migrations/agent-store-tables.d.ts +0 -3
- package/dist/db/migrations/agent-store-tables.d.ts.map +0 -1
- package/dist/db/migrations/agent-store-tables.js +0 -64
- package/dist/db/migrations/agent-store-tables.js.map +0 -1
- package/dist/db/migrations/envelope-tables.d.ts +0 -3
- package/dist/db/migrations/envelope-tables.d.ts.map +0 -1
- package/dist/db/migrations/envelope-tables.js +0 -38
- package/dist/db/migrations/envelope-tables.js.map +0 -1
- package/dist/db/migrations/operator-owner-action-candidates.d.ts +0 -19
- package/dist/db/migrations/operator-owner-action-candidates.d.ts.map +0 -1
- package/dist/db/migrations/operator-owner-action-candidates.js +0 -254
- package/dist/db/migrations/operator-owner-action-candidates.js.map +0 -1
- package/dist/db/migrations/operator-procedures.d.ts +0 -4
- package/dist/db/migrations/operator-procedures.d.ts.map +0 -1
- package/dist/db/migrations/operator-procedures.js +0 -63
- package/dist/db/migrations/operator-procedures.js.map +0 -1
- package/dist/db/migrations/operator-task-classification.d.ts +0 -15
- package/dist/db/migrations/operator-task-classification.d.ts.map +0 -1
- package/dist/db/migrations/operator-task-classification.js +0 -25
- package/dist/db/migrations/operator-task-classification.js.map +0 -1
- package/dist/db/migrations/operator-task-external-lifecycle.d.ts +0 -17
- package/dist/db/migrations/operator-task-external-lifecycle.d.ts.map +0 -1
- package/dist/db/migrations/operator-task-external-lifecycle.js +0 -199
- package/dist/db/migrations/operator-task-external-lifecycle.js.map +0 -1
- package/dist/db/migrations/operator-task-review-lifecycle.d.ts +0 -4
- package/dist/db/migrations/operator-task-review-lifecycle.d.ts.map +0 -1
- package/dist/db/migrations/operator-task-review-lifecycle.js +0 -17
- package/dist/db/migrations/operator-task-review-lifecycle.js.map +0 -1
- package/dist/db/migrations/operator-task-temporal.d.ts +0 -8
- package/dist/db/migrations/operator-task-temporal.d.ts.map +0 -1
- package/dist/db/migrations/operator-task-temporal.js +0 -214
- package/dist/db/migrations/operator-task-temporal.js.map +0 -1
- package/dist/db/migrations/owner-action-effects.d.ts +0 -18
- package/dist/db/migrations/owner-action-effects.d.ts.map +0 -1
- package/dist/db/migrations/owner-action-effects.js +0 -111
- package/dist/db/migrations/owner-action-effects.js.map +0 -1
- package/dist/db/migrations/raw-item-revisions.d.ts +0 -4
- package/dist/db/migrations/raw-item-revisions.d.ts.map +0 -1
- package/dist/db/migrations/raw-item-revisions.js +0 -29
- package/dist/db/migrations/raw-item-revisions.js.map +0 -1
- package/dist/db/migrations/token-usage-agent-version.d.ts +0 -3
- package/dist/db/migrations/token-usage-agent-version.d.ts.map +0 -1
- package/dist/db/migrations/token-usage-agent-version.js +0 -16
- package/dist/db/migrations/token-usage-agent-version.js.map +0 -1
- package/dist/db/migrations/validation-session-tables.d.ts +0 -3
- package/dist/db/migrations/validation-session-tables.d.ts.map +0 -1
- package/dist/db/migrations/validation-session-tables.js +0 -59
- package/dist/db/migrations/validation-session-tables.js.map +0 -1
- package/dist/envelope/authority.d.ts +0 -15
- package/dist/envelope/authority.d.ts.map +0 -1
- package/dist/envelope/authority.js +0 -95
- package/dist/envelope/authority.js.map +0 -1
- package/dist/envelope/canonical.d.ts +0 -14
- package/dist/envelope/canonical.d.ts.map +0 -1
- package/dist/envelope/canonical.js +0 -68
- package/dist/envelope/canonical.js.map +0 -1
- package/dist/envelope/enforcer.d.ts +0 -30
- package/dist/envelope/enforcer.d.ts.map +0 -1
- package/dist/envelope/enforcer.js +0 -286
- package/dist/envelope/enforcer.js.map +0 -1
- package/dist/envelope/expiry.d.ts +0 -2
- package/dist/envelope/expiry.d.ts.map +0 -1
- package/dist/envelope/expiry.js +0 -15
- package/dist/envelope/expiry.js.map +0 -1
- package/dist/envelope/index.d.ts +0 -9
- package/dist/envelope/index.d.ts.map +0 -1
- package/dist/envelope/index.js +0 -25
- package/dist/envelope/index.js.map +0 -1
- package/dist/envelope/key-provider.d.ts +0 -7
- package/dist/envelope/key-provider.d.ts.map +0 -1
- package/dist/envelope/key-provider.js +0 -137
- package/dist/envelope/key-provider.js.map +0 -1
- package/dist/envelope/reactive-config.d.ts +0 -24
- package/dist/envelope/reactive-config.d.ts.map +0 -1
- package/dist/envelope/reactive-config.js +0 -198
- package/dist/envelope/reactive-config.js.map +0 -1
- package/dist/envelope/run-guard.d.ts +0 -10
- package/dist/envelope/run-guard.d.ts.map +0 -1
- package/dist/envelope/run-guard.js +0 -19
- package/dist/envelope/run-guard.js.map +0 -1
- package/dist/envelope/signature.d.ts +0 -15
- package/dist/envelope/signature.d.ts.map +0 -1
- package/dist/envelope/signature.js +0 -75
- package/dist/envelope/signature.js.map +0 -1
- package/dist/envelope/store.d.ts +0 -16
- package/dist/envelope/store.d.ts.map +0 -1
- package/dist/envelope/store.js +0 -118
- package/dist/envelope/store.js.map +0 -1
- package/dist/envelope/tool-connector-scope.d.ts +0 -35
- package/dist/envelope/tool-connector-scope.d.ts.map +0 -1
- package/dist/envelope/tool-connector-scope.js +0 -61
- package/dist/envelope/tool-connector-scope.js.map +0 -1
- package/dist/envelope/types.d.ts +0 -60
- package/dist/envelope/types.d.ts.map +0 -1
- package/dist/envelope/types.js +0 -9
- package/dist/envelope/types.js.map +0 -1
- package/dist/evidence/effects.d.ts +0 -125
- package/dist/evidence/effects.d.ts.map +0 -1
- package/dist/evidence/effects.js +0 -409
- package/dist/evidence/effects.js.map +0 -1
- package/dist/evidence/read.d.ts +0 -130
- package/dist/evidence/read.d.ts.map +0 -1
- package/dist/evidence/read.js +0 -167
- package/dist/evidence/read.js.map +0 -1
- package/dist/gateways/attachment-utils.d.ts +0 -28
- package/dist/gateways/attachment-utils.d.ts.map +0 -1
- package/dist/gateways/attachment-utils.js +0 -489
- package/dist/gateways/attachment-utils.js.map +0 -1
- package/dist/gateways/channel-history.d.ts +0 -148
- package/dist/gateways/channel-history.d.ts.map +0 -1
- package/dist/gateways/channel-history.js +0 -385
- package/dist/gateways/channel-history.js.map +0 -1
- package/dist/gateways/context-injector.d.ts +0 -255
- package/dist/gateways/context-injector.d.ts.map +0 -1
- package/dist/gateways/context-injector.js +0 -285
- package/dist/gateways/context-injector.js.map +0 -1
- package/dist/gateways/image-analyzer.d.ts +0 -28
- package/dist/gateways/image-analyzer.d.ts.map +0 -1
- package/dist/gateways/image-analyzer.js +0 -154
- package/dist/gateways/image-analyzer.js.map +0 -1
- package/dist/gateways/index.d.ts +0 -35
- package/dist/gateways/index.d.ts.map +0 -1
- package/dist/gateways/index.js +0 -55
- package/dist/gateways/index.js.map +0 -1
- package/dist/gateways/member-candidate-store.d.ts +0 -26
- package/dist/gateways/member-candidate-store.d.ts.map +0 -1
- package/dist/gateways/member-candidate-store.js +0 -90
- package/dist/gateways/member-candidate-store.js.map +0 -1
- package/dist/gateways/member-effective-scope.d.ts +0 -25
- package/dist/gateways/member-effective-scope.d.ts.map +0 -1
- package/dist/gateways/member-effective-scope.js +0 -323
- package/dist/gateways/member-effective-scope.js.map +0 -1
- package/dist/gateways/message-router.d.ts +0 -239
- package/dist/gateways/message-router.d.ts.map +0 -1
- package/dist/gateways/message-router.js +0 -1714
- package/dist/gateways/message-router.js.map +0 -1
- package/dist/gateways/plugin-loader.d.ts +0 -80
- package/dist/gateways/plugin-loader.d.ts.map +0 -1
- package/dist/gateways/plugin-loader.js +0 -299
- package/dist/gateways/plugin-loader.js.map +0 -1
- package/dist/gateways/principal.d.ts +0 -37
- package/dist/gateways/principal.d.ts.map +0 -1
- package/dist/gateways/principal.js +0 -95
- package/dist/gateways/principal.js.map +0 -1
- package/dist/gateways/report-projection-v1.d.ts +0 -41
- package/dist/gateways/report-projection-v1.d.ts.map +0 -1
- package/dist/gateways/report-projection-v1.js +0 -160
- package/dist/gateways/report-projection-v1.js.map +0 -1
- package/dist/gateways/telegram-media.d.ts +0 -41
- package/dist/gateways/telegram-media.d.ts.map +0 -1
- package/dist/gateways/telegram-media.js +0 -242
- package/dist/gateways/telegram-media.js.map +0 -1
- package/dist/gateways/telegram-report-context-store.d.ts +0 -131
- package/dist/gateways/telegram-report-context-store.d.ts.map +0 -1
- package/dist/gateways/telegram-report-context-store.js +0 -388
- package/dist/gateways/telegram-report-context-store.js.map +0 -1
- package/dist/gateways/tool-status-tracker.d.ts +0 -87
- package/dist/gateways/tool-status-tracker.d.ts.map +0 -1
- package/dist/gateways/tool-status-tracker.js +0 -284
- package/dist/gateways/tool-status-tracker.js.map +0 -1
- package/dist/mcp/code-act-api-client.d.ts +0 -32
- package/dist/mcp/code-act-api-client.d.ts.map +0 -1
- package/dist/mcp/code-act-api-client.js +0 -80
- package/dist/mcp/code-act-api-client.js.map +0 -1
- package/dist/mcp/code-act-mcp-config.d.ts +0 -49
- package/dist/mcp/code-act-mcp-config.d.ts.map +0 -1
- package/dist/mcp/code-act-mcp-config.js +0 -124
- package/dist/mcp/code-act-mcp-config.js.map +0 -1
- package/dist/mcp/code-act-server.d.ts +0 -14
- package/dist/mcp/code-act-server.d.ts.map +0 -1
- package/dist/mcp/code-act-server.js +0 -204
- package/dist/mcp/code-act-server.js.map +0 -1
- package/dist/mcp/code-act-terminal-transport.d.ts +0 -64
- package/dist/mcp/code-act-terminal-transport.d.ts.map +0 -1
- package/dist/mcp/code-act-terminal-transport.js +0 -176
- package/dist/mcp/code-act-terminal-transport.js.map +0 -1
- package/dist/memory/agent-notice-queue.d.ts +0 -24
- package/dist/memory/agent-notice-queue.d.ts.map +0 -1
- package/dist/memory/agent-notice-queue.js +0 -40
- package/dist/memory/agent-notice-queue.js.map +0 -1
- package/dist/memory/audit-task-queue.d.ts +0 -28
- package/dist/memory/audit-task-queue.d.ts.map +0 -1
- package/dist/memory/audit-task-queue.js +0 -29
- package/dist/memory/audit-task-queue.js.map +0 -1
- package/dist/memory/bootstrap-context.d.ts +0 -12
- package/dist/memory/bootstrap-context.d.ts.map +0 -1
- package/dist/memory/bootstrap-context.js +0 -68
- package/dist/memory/bootstrap-context.js.map +0 -1
- package/dist/memory/history-extractor.d.ts +0 -69
- package/dist/memory/history-extractor.d.ts.map +0 -1
- package/dist/memory/history-extractor.js +0 -210
- package/dist/memory/history-extractor.js.map +0 -1
- package/dist/memory/memory-agent-ack.d.ts +0 -4
- package/dist/memory/memory-agent-ack.d.ts.map +0 -1
- package/dist/memory/memory-agent-ack.js +0 -54
- package/dist/memory/memory-agent-ack.js.map +0 -1
- package/dist/memory/memory-agent-dashboard.d.ts +0 -35
- package/dist/memory/memory-agent-dashboard.d.ts.map +0 -1
- package/dist/memory/memory-agent-dashboard.js +0 -116
- package/dist/memory/memory-agent-dashboard.js.map +0 -1
- package/dist/memory/memory-logger.d.ts +0 -47
- package/dist/memory/memory-logger.d.ts.map +0 -1
- package/dist/memory/memory-logger.js +0 -126
- package/dist/memory/memory-logger.js.map +0 -1
- package/dist/memory/provenance-live.d.ts +0 -111
- package/dist/memory/provenance-live.d.ts.map +0 -1
- package/dist/memory/provenance-live.js +0 -381
- package/dist/memory/provenance-live.js.map +0 -1
- package/dist/memory/provenance-resolver.d.ts +0 -184
- package/dist/memory/provenance-resolver.d.ts.map +0 -1
- package/dist/memory/provenance-resolver.js +0 -152
- package/dist/memory/provenance-resolver.js.map +0 -1
- package/dist/memory/raw-backed-memory-ingest.d.ts +0 -26
- package/dist/memory/raw-backed-memory-ingest.d.ts.map +0 -1
- package/dist/memory/raw-backed-memory-ingest.js +0 -214
- package/dist/memory/raw-backed-memory-ingest.js.map +0 -1
- package/dist/memory/recall-bundle-formatter.d.ts +0 -26
- package/dist/memory/recall-bundle-formatter.d.ts.map +0 -1
- package/dist/memory/recall-bundle-formatter.js +0 -53
- package/dist/memory/recall-bundle-formatter.js.map +0 -1
- package/dist/memory/save-candidate-extractor.d.ts +0 -16
- package/dist/memory/save-candidate-extractor.d.ts.map +0 -1
- package/dist/memory/save-candidate-extractor.js +0 -127
- package/dist/memory/save-candidate-extractor.js.map +0 -1
- package/dist/memory/save-candidate-types.d.ts +0 -16
- package/dist/memory/save-candidate-types.d.ts.map +0 -1
- package/dist/memory/save-candidate-types.js +0 -3
- package/dist/memory/save-candidate-types.js.map +0 -1
- package/dist/memory/scope-context.d.ts +0 -12
- package/dist/memory/scope-context.d.ts.map +0 -1
- package/dist/memory/scope-context.js +0 -18
- package/dist/memory/scope-context.js.map +0 -1
- package/dist/memory/secret-filter.d.ts +0 -23
- package/dist/memory/secret-filter.d.ts.map +0 -1
- package/dist/memory/secret-filter.js +0 -90
- package/dist/memory/secret-filter.js.map +0 -1
- package/dist/multi-agent/agent-event-bus.d.ts +0 -50
- package/dist/multi-agent/agent-event-bus.d.ts.map +0 -1
- package/dist/multi-agent/agent-event-bus.js +0 -101
- package/dist/multi-agent/agent-event-bus.js.map +0 -1
- package/dist/multi-agent/agent-process-manager.d.ts +0 -205
- package/dist/multi-agent/agent-process-manager.d.ts.map +0 -1
- package/dist/multi-agent/agent-process-manager.js +0 -1191
- package/dist/multi-agent/agent-process-manager.js.map +0 -1
- package/dist/multi-agent/bmad-templates.d.ts +0 -49
- package/dist/multi-agent/bmad-templates.d.ts.map +0 -1
- package/dist/multi-agent/bmad-templates.js +0 -121
- package/dist/multi-agent/bmad-templates.js.map +0 -1
- package/dist/multi-agent/runtime-process.d.ts +0 -74
- package/dist/multi-agent/runtime-process.d.ts.map +0 -1
- package/dist/multi-agent/runtime-process.js +0 -160
- package/dist/multi-agent/runtime-process.js.map +0 -1
- package/dist/multi-agent/tool-permission-manager.d.ts +0 -70
- package/dist/multi-agent/tool-permission-manager.d.ts.map +0 -1
- package/dist/multi-agent/tool-permission-manager.js +0 -195
- package/dist/multi-agent/tool-permission-manager.js.map +0 -1
- package/dist/multi-agent/types.d.ts +0 -438
- package/dist/multi-agent/types.d.ts.map +0 -1
- package/dist/multi-agent/types.js +0 -27
- package/dist/multi-agent/types.js.map +0 -1
- package/dist/multi-agent/wiki-agent-persona.d.ts +0 -16
- package/dist/multi-agent/wiki-agent-persona.d.ts.map +0 -1
- package/dist/multi-agent/wiki-agent-persona.js +0 -23
- package/dist/multi-agent/wiki-agent-persona.js.map +0 -1
- package/dist/multi-agent/workflow-types.d.ts +0 -186
- package/dist/multi-agent/workflow-types.d.ts.map +0 -1
- package/dist/multi-agent/workflow-types.js +0 -9
- package/dist/multi-agent/workflow-types.js.map +0 -1
- package/dist/observability/code-audit.d.ts +0 -87
- package/dist/observability/code-audit.d.ts.map +0 -1
- package/dist/observability/code-audit.js +0 -414
- package/dist/observability/code-audit.js.map +0 -1
- package/dist/observability/health-check.d.ts +0 -102
- package/dist/observability/health-check.d.ts.map +0 -1
- package/dist/observability/health-check.js +0 -422
- package/dist/observability/health-check.js.map +0 -1
- package/dist/observability/health-score.d.ts +0 -29
- package/dist/observability/health-score.d.ts.map +0 -1
- package/dist/observability/health-score.js +0 -83
- package/dist/observability/health-score.js.map +0 -1
- package/dist/observability/metrics-cleanup.d.ts +0 -24
- package/dist/observability/metrics-cleanup.d.ts.map +0 -1
- package/dist/observability/metrics-cleanup.js +0 -51
- package/dist/observability/metrics-cleanup.js.map +0 -1
- package/dist/observability/metrics-store.d.ts +0 -52
- package/dist/observability/metrics-store.d.ts.map +0 -1
- package/dist/observability/metrics-store.js +0 -186
- package/dist/observability/metrics-store.js.map +0 -1
- package/dist/observability/operational-issues.d.ts +0 -55
- package/dist/observability/operational-issues.d.ts.map +0 -1
- package/dist/observability/operational-issues.js +0 -170
- package/dist/observability/operational-issues.js.map +0 -1
- package/dist/onboarding/agent-contract.d.ts +0 -42
- package/dist/onboarding/agent-contract.d.ts.map +0 -1
- package/dist/onboarding/agent-contract.js +0 -129
- package/dist/onboarding/agent-contract.js.map +0 -1
- package/dist/onboarding/assess-live.d.ts +0 -22
- package/dist/onboarding/assess-live.d.ts.map +0 -1
- package/dist/onboarding/assess-live.js +0 -200
- package/dist/onboarding/assess-live.js.map +0 -1
- package/dist/onboarding/bootstrap-template.d.ts +0 -5
- package/dist/onboarding/bootstrap-template.d.ts.map +0 -1
- package/dist/onboarding/bootstrap-template.js +0 -34
- package/dist/onboarding/bootstrap-template.js.map +0 -1
- package/dist/operator/action-verifier.d.ts +0 -75
- package/dist/operator/action-verifier.d.ts.map +0 -1
- package/dist/operator/action-verifier.js +0 -149
- package/dist/operator/action-verifier.js.map +0 -1
- package/dist/operator/board-delta-gate.d.ts +0 -131
- package/dist/operator/board-delta-gate.d.ts.map +0 -1
- package/dist/operator/board-delta-gate.js +0 -181
- package/dist/operator/board-delta-gate.js.map +0 -1
- package/dist/operator/board-pipeline-render.d.ts +0 -16
- package/dist/operator/board-pipeline-render.d.ts.map +0 -1
- package/dist/operator/board-pipeline-render.js +0 -69
- package/dist/operator/board-pipeline-render.js.map +0 -1
- package/dist/operator/board-reconcile.d.ts +0 -61
- package/dist/operator/board-reconcile.d.ts.map +0 -1
- package/dist/operator/board-reconcile.js +0 -157
- package/dist/operator/board-reconcile.js.map +0 -1
- package/dist/operator/board-refresh-gate.d.ts +0 -39
- package/dist/operator/board-refresh-gate.d.ts.map +0 -1
- package/dist/operator/board-refresh-gate.js +0 -83
- package/dist/operator/board-refresh-gate.js.map +0 -1
- package/dist/operator/changes-projection.d.ts +0 -72
- package/dist/operator/changes-projection.d.ts.map +0 -1
- package/dist/operator/changes-projection.js +0 -110
- package/dist/operator/changes-projection.js.map +0 -1
- package/dist/operator/connector-delta-repo.d.ts +0 -33
- package/dist/operator/connector-delta-repo.d.ts.map +0 -1
- package/dist/operator/connector-delta-repo.js +0 -0
- package/dist/operator/connector-delta-repo.js.map +0 -1
- package/dist/operator/console-brief.d.ts +0 -40
- package/dist/operator/console-brief.d.ts.map +0 -1
- package/dist/operator/console-brief.js +0 -246
- package/dist/operator/console-brief.js.map +0 -1
- package/dist/operator/experience-evidence.d.ts +0 -18
- package/dist/operator/experience-evidence.d.ts.map +0 -1
- package/dist/operator/experience-evidence.js +0 -82
- package/dist/operator/experience-evidence.js.map +0 -1
- package/dist/operator/experience-hints.d.ts +0 -44
- package/dist/operator/experience-hints.d.ts.map +0 -1
- package/dist/operator/experience-hints.js +0 -98
- package/dist/operator/experience-hints.js.map +0 -1
- package/dist/operator/external-correlation.d.ts +0 -94
- package/dist/operator/external-correlation.d.ts.map +0 -1
- package/dist/operator/external-correlation.js +0 -177
- package/dist/operator/external-correlation.js.map +0 -1
- package/dist/operator/external-lifecycle-candidates.d.ts +0 -70
- package/dist/operator/external-lifecycle-candidates.d.ts.map +0 -1
- package/dist/operator/external-lifecycle-candidates.js +0 -579
- package/dist/operator/external-lifecycle-candidates.js.map +0 -1
- package/dist/operator/external-lifecycle-discovery.d.ts +0 -61
- package/dist/operator/external-lifecycle-discovery.d.ts.map +0 -1
- package/dist/operator/external-lifecycle-discovery.js +0 -103
- package/dist/operator/external-lifecycle-discovery.js.map +0 -1
- package/dist/operator/external-lifecycle.d.ts +0 -105
- package/dist/operator/external-lifecycle.d.ts.map +0 -1
- package/dist/operator/external-lifecycle.js +0 -27
- package/dist/operator/external-lifecycle.js.map +0 -1
- package/dist/operator/file-coordination.d.ts +0 -7
- package/dist/operator/file-coordination.d.ts.map +0 -1
- package/dist/operator/file-coordination.js +0 -84
- package/dist/operator/file-coordination.js.map +0 -1
- package/dist/operator/file-export.d.ts +0 -22
- package/dist/operator/file-export.d.ts.map +0 -1
- package/dist/operator/file-export.js +0 -115
- package/dist/operator/file-export.js.map +0 -1
- package/dist/operator/leg-cadence.d.ts +0 -72
- package/dist/operator/leg-cadence.d.ts.map +0 -1
- package/dist/operator/leg-cadence.js +0 -122
- package/dist/operator/leg-cadence.js.map +0 -1
- package/dist/operator/mama-memory-port.d.ts +0 -13
- package/dist/operator/mama-memory-port.d.ts.map +0 -1
- package/dist/operator/mama-memory-port.js +0 -33
- package/dist/operator/mama-memory-port.js.map +0 -1
- package/dist/operator/operator-interfaces.d.ts +0 -136
- package/dist/operator/operator-interfaces.d.ts.map +0 -1
- package/dist/operator/operator-interfaces.js +0 -15
- package/dist/operator/operator-interfaces.js.map +0 -1
- package/dist/operator/operator-trigger-loop.d.ts +0 -203
- package/dist/operator/operator-trigger-loop.d.ts.map +0 -1
- package/dist/operator/operator-trigger-loop.js +0 -827
- package/dist/operator/operator-trigger-loop.js.map +0 -1
- package/dist/operator/owner-action-effects.d.ts +0 -112
- package/dist/operator/owner-action-effects.d.ts.map +0 -1
- package/dist/operator/owner-action-effects.js +0 -375
- package/dist/operator/owner-action-effects.js.map +0 -1
- package/dist/operator/owner-event-effects.d.ts +0 -65
- package/dist/operator/owner-event-effects.d.ts.map +0 -1
- package/dist/operator/owner-event-effects.js +0 -249
- package/dist/operator/owner-event-effects.js.map +0 -1
- package/dist/operator/owner-event-inbox.d.ts +0 -124
- package/dist/operator/owner-event-inbox.d.ts.map +0 -1
- package/dist/operator/owner-event-inbox.js +0 -440
- package/dist/operator/owner-event-inbox.js.map +0 -1
- package/dist/operator/owner-event-loop.d.ts +0 -99
- package/dist/operator/owner-event-loop.d.ts.map +0 -1
- package/dist/operator/owner-event-loop.js +0 -253
- package/dist/operator/owner-event-loop.js.map +0 -1
- package/dist/operator/owner-event-outcome.d.ts +0 -36
- package/dist/operator/owner-event-outcome.d.ts.map +0 -1
- package/dist/operator/owner-event-outcome.js +0 -174
- package/dist/operator/owner-event-outcome.js.map +0 -1
- package/dist/operator/owner-event-policy.d.ts +0 -40
- package/dist/operator/owner-event-policy.d.ts.map +0 -1
- package/dist/operator/owner-event-policy.js +0 -75
- package/dist/operator/owner-event-policy.js.map +0 -1
- package/dist/operator/owner-event-prompt.d.ts +0 -21
- package/dist/operator/owner-event-prompt.d.ts.map +0 -1
- package/dist/operator/owner-event-prompt.js +0 -69
- package/dist/operator/owner-event-prompt.js.map +0 -1
- package/dist/operator/owner-runtime-journal.d.ts +0 -21
- package/dist/operator/owner-runtime-journal.d.ts.map +0 -1
- package/dist/operator/owner-runtime-journal.js +0 -135
- package/dist/operator/owner-runtime-journal.js.map +0 -1
- package/dist/operator/owner-runtime.d.ts +0 -48
- package/dist/operator/owner-runtime.d.ts.map +0 -1
- package/dist/operator/owner-runtime.js +0 -99
- package/dist/operator/owner-runtime.js.map +0 -1
- package/dist/operator/pending-report-store.d.ts +0 -99
- package/dist/operator/pending-report-store.d.ts.map +0 -1
- package/dist/operator/pending-report-store.js +0 -554
- package/dist/operator/pending-report-store.js.map +0 -1
- package/dist/operator/procedure-activation.d.ts +0 -7
- package/dist/operator/procedure-activation.d.ts.map +0 -1
- package/dist/operator/procedure-activation.js +0 -132
- package/dist/operator/procedure-activation.js.map +0 -1
- package/dist/operator/procedure-projection.d.ts +0 -25
- package/dist/operator/procedure-projection.d.ts.map +0 -1
- package/dist/operator/procedure-projection.js +0 -80
- package/dist/operator/procedure-projection.js.map +0 -1
- package/dist/operator/procedure-runtime.d.ts +0 -45
- package/dist/operator/procedure-runtime.d.ts.map +0 -1
- package/dist/operator/procedure-runtime.js +0 -496
- package/dist/operator/procedure-runtime.js.map +0 -1
- package/dist/operator/procedure-store.d.ts +0 -97
- package/dist/operator/procedure-store.d.ts.map +0 -1
- package/dist/operator/procedure-store.js +0 -368
- package/dist/operator/procedure-store.js.map +0 -1
- package/dist/operator/provenance-lookup.d.ts +0 -18
- package/dist/operator/provenance-lookup.d.ts.map +0 -1
- package/dist/operator/provenance-lookup.js +0 -54
- package/dist/operator/provenance-lookup.js.map +0 -1
- package/dist/operator/repair-request.d.ts +0 -29
- package/dist/operator/repair-request.d.ts.map +0 -1
- package/dist/operator/repair-request.js +0 -115
- package/dist/operator/repair-request.js.map +0 -1
- package/dist/operator/report-carry-delivery.d.ts +0 -35
- package/dist/operator/report-carry-delivery.d.ts.map +0 -1
- package/dist/operator/report-carry-delivery.js +0 -55
- package/dist/operator/report-carry-delivery.js.map +0 -1
- package/dist/operator/report-carry.d.ts +0 -66
- package/dist/operator/report-carry.d.ts.map +0 -1
- package/dist/operator/report-carry.js +0 -352
- package/dist/operator/report-carry.js.map +0 -1
- package/dist/operator/report-delivery-coordinator.d.ts +0 -84
- package/dist/operator/report-delivery-coordinator.d.ts.map +0 -1
- package/dist/operator/report-delivery-coordinator.js +0 -146
- package/dist/operator/report-delivery-coordinator.js.map +0 -1
- package/dist/operator/report-run.d.ts +0 -52
- package/dist/operator/report-run.d.ts.map +0 -1
- package/dist/operator/report-run.js +0 -32
- package/dist/operator/report-run.js.map +0 -1
- package/dist/operator/report-scheduler.d.ts +0 -66
- package/dist/operator/report-scheduler.d.ts.map +0 -1
- package/dist/operator/report-scheduler.js +0 -135
- package/dist/operator/report-scheduler.js.map +0 -1
- package/dist/operator/runtime-config.d.ts +0 -10
- package/dist/operator/runtime-config.d.ts.map +0 -1
- package/dist/operator/runtime-config.js +0 -21
- package/dist/operator/runtime-config.js.map +0 -1
- package/dist/operator/situation-report.d.ts +0 -197
- package/dist/operator/situation-report.d.ts.map +0 -1
- package/dist/operator/situation-report.js +0 -462
- package/dist/operator/situation-report.js.map +0 -1
- package/dist/operator/subagent-stimulus.d.ts +0 -34
- package/dist/operator/subagent-stimulus.d.ts.map +0 -1
- package/dist/operator/subagent-stimulus.js +0 -145
- package/dist/operator/subagent-stimulus.js.map +0 -1
- package/dist/operator/task-ledger.d.ts +0 -879
- package/dist/operator/task-ledger.d.ts.map +0 -1
- package/dist/operator/task-ledger.js +0 -3601
- package/dist/operator/task-ledger.js.map +0 -1
- package/dist/operator/task-list-views.d.ts +0 -91
- package/dist/operator/task-list-views.d.ts.map +0 -1
- package/dist/operator/task-list-views.js +0 -532
- package/dist/operator/task-list-views.js.map +0 -1
- package/dist/operator/task-temporal.d.ts +0 -24
- package/dist/operator/task-temporal.d.ts.map +0 -1
- package/dist/operator/task-temporal.js +0 -123
- package/dist/operator/task-temporal.js.map +0 -1
- package/dist/operator/temporal-effect.d.ts +0 -65
- package/dist/operator/temporal-effect.d.ts.map +0 -1
- package/dist/operator/temporal-effect.js +0 -71
- package/dist/operator/temporal-effect.js.map +0 -1
- package/dist/operator/temporal-reconcile.d.ts +0 -49
- package/dist/operator/temporal-reconcile.d.ts.map +0 -1
- package/dist/operator/temporal-reconcile.js +0 -231
- package/dist/operator/temporal-reconcile.js.map +0 -1
- package/dist/operator/temporal-runtime.d.ts +0 -51
- package/dist/operator/temporal-runtime.d.ts.map +0 -1
- package/dist/operator/temporal-runtime.js +0 -104
- package/dist/operator/temporal-runtime.js.map +0 -1
- package/dist/operator/temporal-worker.d.ts +0 -18
- package/dist/operator/temporal-worker.d.ts.map +0 -1
- package/dist/operator/temporal-worker.js +0 -82
- package/dist/operator/temporal-worker.js.map +0 -1
- package/dist/operator/thread-brief-memory.d.ts +0 -29
- package/dist/operator/thread-brief-memory.d.ts.map +0 -1
- package/dist/operator/thread-brief-memory.js +0 -61
- package/dist/operator/thread-brief-memory.js.map +0 -1
- package/dist/operator/trigger-author.d.ts +0 -63
- package/dist/operator/trigger-author.d.ts.map +0 -1
- package/dist/operator/trigger-author.js +0 -384
- package/dist/operator/trigger-author.js.map +0 -1
- package/dist/operator/trigger-evolve.d.ts +0 -31
- package/dist/operator/trigger-evolve.d.ts.map +0 -1
- package/dist/operator/trigger-evolve.js +0 -51
- package/dist/operator/trigger-evolve.js.map +0 -1
- package/dist/operator/trigger-fire.d.ts +0 -29
- package/dist/operator/trigger-fire.d.ts.map +0 -1
- package/dist/operator/trigger-fire.js +0 -41
- package/dist/operator/trigger-fire.js.map +0 -1
- package/dist/operator/trigger-matcher.d.ts +0 -19
- package/dist/operator/trigger-matcher.d.ts.map +0 -1
- package/dist/operator/trigger-matcher.js +0 -65
- package/dist/operator/trigger-matcher.js.map +0 -1
- package/dist/operator/trigger-registry.d.ts +0 -58
- package/dist/operator/trigger-registry.d.ts.map +0 -1
- package/dist/operator/trigger-registry.js +0 -349
- package/dist/operator/trigger-registry.js.map +0 -1
- package/dist/operator/trigger-review.d.ts +0 -23
- package/dist/operator/trigger-review.d.ts.map +0 -1
- package/dist/operator/trigger-review.js +0 -193
- package/dist/operator/trigger-review.js.map +0 -1
- package/dist/operator/trigger-types.d.ts +0 -95
- package/dist/operator/trigger-types.d.ts.map +0 -1
- package/dist/operator/trigger-types.js +0 -14
- package/dist/operator/trigger-types.js.map +0 -1
- package/dist/operator/wiki-continuity.d.ts +0 -153
- package/dist/operator/wiki-continuity.d.ts.map +0 -1
- package/dist/operator/wiki-continuity.js +0 -221
- package/dist/operator/wiki-continuity.js.map +0 -1
- package/dist/operator/worker-run.d.ts +0 -109
- package/dist/operator/worker-run.d.ts.map +0 -1
- package/dist/operator/worker-run.js +0 -131
- package/dist/operator/worker-run.js.map +0 -1
- package/dist/operator/workorder-consumer.d.ts +0 -294
- package/dist/operator/workorder-consumer.d.ts.map +0 -1
- package/dist/operator/workorder-consumer.js +0 -1108
- package/dist/operator/workorder-consumer.js.map +0 -1
- package/dist/operator/workorder-hooks.d.ts +0 -162
- package/dist/operator/workorder-hooks.d.ts.map +0 -1
- package/dist/operator/workorder-hooks.js +0 -342
- package/dist/operator/workorder-hooks.js.map +0 -1
- package/dist/operator/workorder-publishers.d.ts +0 -117
- package/dist/operator/workorder-publishers.d.ts.map +0 -1
- package/dist/operator/workorder-publishers.js +0 -544
- package/dist/operator/workorder-publishers.js.map +0 -1
- package/dist/runners/cli-runner.d.ts +0 -59
- package/dist/runners/cli-runner.d.ts.map +0 -1
- package/dist/runners/cli-runner.js +0 -191
- package/dist/runners/cli-runner.js.map +0 -1
- package/dist/runners/index.d.ts +0 -11
- package/dist/runners/index.d.ts.map +0 -1
- package/dist/runners/index.js +0 -15
- package/dist/runners/index.js.map +0 -1
- package/dist/runners/types.d.ts +0 -81
- package/dist/runners/types.d.ts.map +0 -1
- package/dist/runners/types.js +0 -31
- package/dist/runners/types.js.map +0 -1
- package/dist/scheduler/cron-result-router.d.ts +0 -24
- package/dist/scheduler/cron-result-router.d.ts.map +0 -1
- package/dist/scheduler/cron-result-router.js +0 -63
- package/dist/scheduler/cron-result-router.js.map +0 -1
- package/dist/scheduler/cron-scheduler.d.ts +0 -115
- package/dist/scheduler/cron-scheduler.d.ts.map +0 -1
- package/dist/scheduler/cron-scheduler.js +0 -336
- package/dist/scheduler/cron-scheduler.js.map +0 -1
- package/dist/scheduler/cron-worker.d.ts +0 -39
- package/dist/scheduler/cron-worker.d.ts.map +0 -1
- package/dist/scheduler/cron-worker.js +0 -94
- package/dist/scheduler/cron-worker.js.map +0 -1
- package/dist/scheduler/heartbeat.d.ts +0 -64
- package/dist/scheduler/heartbeat.d.ts.map +0 -1
- package/dist/scheduler/heartbeat.js +0 -197
- package/dist/scheduler/heartbeat.js.map +0 -1
- package/dist/scheduler/index.d.ts +0 -26
- package/dist/scheduler/index.d.ts.map +0 -1
- package/dist/scheduler/index.js +0 -37
- package/dist/scheduler/index.js.map +0 -1
- package/dist/scheduler/job-lock.d.ts +0 -85
- package/dist/scheduler/job-lock.d.ts.map +0 -1
- package/dist/scheduler/job-lock.js +0 -137
- package/dist/scheduler/job-lock.js.map +0 -1
- package/dist/scheduler/recovery.d.ts +0 -78
- package/dist/scheduler/recovery.d.ts.map +0 -1
- package/dist/scheduler/recovery.js +0 -124
- package/dist/scheduler/recovery.js.map +0 -1
- package/dist/scheduler/schedule-store.d.ts +0 -112
- package/dist/scheduler/schedule-store.d.ts.map +0 -1
- package/dist/scheduler/schedule-store.js +0 -259
- package/dist/scheduler/schedule-store.js.map +0 -1
- package/dist/scheduler/token-keep-alive.d.ts +0 -49
- package/dist/scheduler/token-keep-alive.d.ts.map +0 -1
- package/dist/scheduler/token-keep-alive.js +0 -102
- package/dist/scheduler/token-keep-alive.js.map +0 -1
- package/dist/scheduler/types.d.ts +0 -98
- package/dist/scheduler/types.d.ts.map +0 -1
- package/dist/scheduler/types.js +0 -21
- package/dist/scheduler/types.js.map +0 -1
- package/dist/security/security-monitor.d.ts +0 -56
- package/dist/security/security-monitor.d.ts.map +0 -1
- package/dist/security/security-monitor.js +0 -779
- package/dist/security/security-monitor.js.map +0 -1
- package/dist/security/trusted-proxy.d.ts +0 -9
- package/dist/security/trusted-proxy.d.ts.map +0 -1
- package/dist/security/trusted-proxy.js +0 -36
- package/dist/security/trusted-proxy.js.map +0 -1
- package/dist/skills/index.d.ts +0 -10
- package/dist/skills/index.d.ts.map +0 -1
- package/dist/skills/index.js +0 -26
- package/dist/skills/index.js.map +0 -1
- package/dist/skills/skill-executor.d.ts +0 -48
- package/dist/skills/skill-executor.d.ts.map +0 -1
- package/dist/skills/skill-executor.js +0 -483
- package/dist/skills/skill-executor.js.map +0 -1
- package/dist/skills/skill-loader.d.ts +0 -40
- package/dist/skills/skill-loader.d.ts.map +0 -1
- package/dist/skills/skill-loader.js +0 -233
- package/dist/skills/skill-loader.js.map +0 -1
- package/dist/skills/skill-matcher.d.ts +0 -33
- package/dist/skills/skill-matcher.d.ts.map +0 -1
- package/dist/skills/skill-matcher.js +0 -190
- package/dist/skills/skill-matcher.js.map +0 -1
- package/dist/skills/skill-registry.d.ts +0 -117
- package/dist/skills/skill-registry.d.ts.map +0 -1
- package/dist/skills/skill-registry.js +0 -627
- package/dist/skills/skill-registry.js.map +0 -1
- package/dist/skills/types.d.ts +0 -131
- package/dist/skills/types.d.ts.map +0 -1
- package/dist/skills/types.js +0 -12
- package/dist/skills/types.js.map +0 -1
- package/dist/utils/log-sanitizer.d.ts +0 -79
- package/dist/utils/log-sanitizer.d.ts.map +0 -1
- package/dist/utils/log-sanitizer.js +0 -215
- package/dist/utils/log-sanitizer.js.map +0 -1
- package/dist/validation/session-service.d.ts +0 -72
- package/dist/validation/session-service.d.ts.map +0 -1
- package/dist/validation/session-service.js +0 -298
- package/dist/validation/session-service.js.map +0 -1
- package/dist/validation/store.d.ts +0 -25
- package/dist/validation/store.d.ts.map +0 -1
- package/dist/validation/store.js +0 -200
- package/dist/validation/store.js.map +0 -1
- package/dist/validation/types.d.ts +0 -119
- package/dist/validation/types.d.ts.map +0 -1
- package/dist/validation/types.js +0 -57
- package/dist/validation/types.js.map +0 -1
- package/dist/wiki/wiki-turn-contract.d.ts +0 -19
- package/dist/wiki/wiki-turn-contract.d.ts.map +0 -1
- package/dist/wiki/wiki-turn-contract.js +0 -60
- package/dist/wiki/wiki-turn-contract.js.map +0 -1
- package/public/viewer/js/utils/ui-commands.js +0 -88
- package/public/viewer/src/utils/ui-commands.ts +0 -114
- package/scripts/attachment/extract-office-text.js +0 -179
- package/scripts/attachment/extract-pdf-text.swift +0 -36
- package/scripts/backfill-channel-keys.ts +0 -509
- package/scripts/crack-failure-digests.ts +0 -55
- package/scripts/generate-gateway-tools.ts +0 -131
- package/scripts/image/fb-overlay.py +0 -128
- package/scripts/image/ocr-image.py +0 -38
- package/scripts/postinstall.js +0 -161
- package/scripts/setup-ocr.js +0 -120
- package/templates/AGENTS.claude.md +0 -23
- package/templates/AGENTS.codex.md +0 -11
- package/templates/bmad/LICENSE +0 -28
- package/templates/bmad/architecture.md +0 -343
- package/templates/bmad/bmm-workflow-status.template.yaml +0 -66
- package/templates/bmad/prd.md +0 -198
- package/templates/bmad/product-brief.md +0 -149
- package/templates/bmad/sprint-status.template.yaml +0 -35
- package/templates/bmad/tech-spec.md +0 -151
- package/templates/entity-audit-fixtures/cross-language-aliases.json +0 -28
- package/templates/entity-audit-fixtures/gold-canonical-identities.json +0 -46
- package/templates/skills/danggeun-monitor.md +0 -88
- package/templates/skills/document-analyze.md +0 -63
- package/templates/skills/frontend-design.md +0 -71
- package/templates/skills/image-translate.md +0 -62
- package/templates/skills/multi-agent-collab.md +0 -145
- package/templates/skills/scheduling.md +0 -107
- package/templates/workspace/skill-forge/DESIGN.md +0 -115
- package/templates/workspace/skill-forge/agents/architect.ts +0 -295
- package/templates/workspace/skill-forge/agents/developer.ts +0 -364
- package/templates/workspace/skill-forge/agents/qa.ts +0 -313
- package/templates/workspace/skill-forge/claude-api.ts +0 -353
- package/templates/workspace/skill-forge/discord-ui.ts +0 -580
- package/templates/workspace/skill-forge/error-handler.ts +0 -354
- package/templates/workspace/skill-forge/mama-integration.ts +0 -357
- package/templates/workspace/skill-forge/orchestrator.ts +0 -495
- package/templates/workspace/skill-forge/output/generated-skills/skills/hello-world/README.md +0 -24
- package/templates/workspace/skill-forge/output/generated-skills/skills/hello-world/index.ts +0 -79
- package/templates/workspace/skill-forge/output/generated-skills/skills/hello-world/types.ts +0 -17
- package/templates/workspace/skill-forge/package.json +0 -21
- package/templates/workspace/skill-forge/state/session.json +0 -132
- package/templates/workspace/skill-forge/test-e2e.ts +0 -139
- package/templates/workspace/skill-forge/tsconfig.json +0 -20
- package/templates/workspace/skill-forge/types.ts +0 -159
|
@@ -1,2084 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CodexAppServerProcess = void 0;
|
|
4
|
-
const node_child_process_1 = require("node:child_process");
|
|
5
|
-
const node_crypto_1 = require("node:crypto");
|
|
6
|
-
const node_fs_1 = require("node:fs");
|
|
7
|
-
const node_os_1 = require("node:os");
|
|
8
|
-
const node_path_1 = require("node:path");
|
|
9
|
-
const node_readline_1 = require("node:readline");
|
|
10
|
-
const model_runner_js_1 = require("./model-runner.js");
|
|
11
|
-
const codex_home_js_1 = require("./codex-home.js");
|
|
12
|
-
const codex_thread_registry_js_1 = require("./codex-thread-registry.js");
|
|
13
|
-
const DEFAULT_TIMEOUT = 300_000;
|
|
14
|
-
const STOP_GRACE_MS = 200;
|
|
15
|
-
const STDERR_LIMIT = 4_000;
|
|
16
|
-
const CLIENT_INFO = { name: 'mama-codex-app-server', version: '1.0.0' };
|
|
17
|
-
const TURN_STATUSES = new Set(['completed', 'interrupted', 'failed', 'inProgress']);
|
|
18
|
-
const TURN_ITEM_VIEWS = new Set(['notLoaded', 'summary', 'full']);
|
|
19
|
-
const APPROVAL_REVIEWERS = new Set(['user', 'auto_review', 'guardian_subagent']);
|
|
20
|
-
const OVERLOADED_ERROR_CODE = -32001;
|
|
21
|
-
const OVERLOAD_RETRY_LIMIT = 4;
|
|
22
|
-
const OVERLOAD_RETRY_BASE_MS = 25;
|
|
23
|
-
const TURN_START_RECONCILE_GRACE_MS = 250;
|
|
24
|
-
const SUBAGENT_FINAL_TEXT_LIMIT = 4_000;
|
|
25
|
-
/** Wait for the child's own `turn/completed` after the parent announced it finished. */
|
|
26
|
-
const SUBAGENT_COMPLETION_GRACE_MS = 5_000;
|
|
27
|
-
/** A registered child that never completes is reported failed rather than leaked. */
|
|
28
|
-
const SUBAGENT_TTL_MS = 45 * 60_000;
|
|
29
|
-
/** Bound on remembered finished child threads; identity, not history. */
|
|
30
|
-
const MAX_FINISHED_SUBAGENTS = 200;
|
|
31
|
-
const SUBAGENT_AUTHORITY_UNAVAILABLE = 'subagent authority unavailable';
|
|
32
|
-
const SUBAGENT_AUTHORITY_EXPIRED = 'subagent authority expired';
|
|
33
|
-
/** EnvelopeViolation code prefix the enforcer returns once a grant is past its wall. */
|
|
34
|
-
const ENVELOPE_EXPIRED_MARKER = '[expired]';
|
|
35
|
-
class CodexAppServerRpcError extends Error {
|
|
36
|
-
code;
|
|
37
|
-
constructor(code, message) {
|
|
38
|
-
super(message);
|
|
39
|
-
this.name = 'CodexAppServerRpcError';
|
|
40
|
-
this.code = code;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function object(value) {
|
|
44
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
45
|
-
? value
|
|
46
|
-
: undefined;
|
|
47
|
-
}
|
|
48
|
-
function stableJson(value) {
|
|
49
|
-
if (Array.isArray(value)) {
|
|
50
|
-
return value.map(stableJson);
|
|
51
|
-
}
|
|
52
|
-
const record = object(value);
|
|
53
|
-
if (!record) {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
return Object.fromEntries(Object.keys(record)
|
|
57
|
-
.sort()
|
|
58
|
-
.map((key) => [key, stableJson(record[key])]));
|
|
59
|
-
}
|
|
60
|
-
function deepFreeze(value) {
|
|
61
|
-
if (Array.isArray(value)) {
|
|
62
|
-
for (const item of value) {
|
|
63
|
-
deepFreeze(item);
|
|
64
|
-
}
|
|
65
|
-
Object.freeze(value);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const record = object(value);
|
|
69
|
-
if (record) {
|
|
70
|
-
for (const item of Object.values(record)) {
|
|
71
|
-
deepFreeze(item);
|
|
72
|
-
}
|
|
73
|
-
Object.freeze(record);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function snapshotHostToolBridge(bridge) {
|
|
77
|
-
if (!bridge) {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
const tools = bridge.tools
|
|
81
|
-
.map((tool) => stableJson(tool))
|
|
82
|
-
.sort((left, right) => left.name.localeCompare(right.name));
|
|
83
|
-
deepFreeze(tools);
|
|
84
|
-
const execute = bridge.execute.bind(bridge);
|
|
85
|
-
return Object.freeze({ tools, execute });
|
|
86
|
-
}
|
|
87
|
-
function errorMessage(value, fallback) {
|
|
88
|
-
const record = object(value);
|
|
89
|
-
return typeof record?.message === 'string' && record.message ? record.message : fallback;
|
|
90
|
-
}
|
|
91
|
-
function stringField(record, name, context) {
|
|
92
|
-
const value = record[name];
|
|
93
|
-
if (typeof value !== 'string') {
|
|
94
|
-
throw new Error(`Codex app-server returned malformed ${context}.${name}`);
|
|
95
|
-
}
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
98
|
-
function nullableStringField(record, name, context) {
|
|
99
|
-
const value = record[name];
|
|
100
|
-
if (value !== null && typeof value !== 'string') {
|
|
101
|
-
throw new Error(`Codex app-server returned malformed ${context}.${name}`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function nullableNumberField(record, name, context) {
|
|
105
|
-
const value = record[name];
|
|
106
|
-
if (value !== null && (typeof value !== 'number' || !Number.isFinite(value))) {
|
|
107
|
-
throw new Error(`Codex app-server returned malformed ${context}.${name}`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function validateTurn(value, context) {
|
|
111
|
-
const turn = object(value);
|
|
112
|
-
if (!turn) {
|
|
113
|
-
throw new Error(`Codex app-server returned malformed ${context}`);
|
|
114
|
-
}
|
|
115
|
-
stringField(turn, 'id', context);
|
|
116
|
-
if (!Array.isArray(turn.items) || !TURN_ITEM_VIEWS.has(String(turn.itemsView))) {
|
|
117
|
-
throw new Error(`Codex app-server returned malformed ${context} items`);
|
|
118
|
-
}
|
|
119
|
-
if (!TURN_STATUSES.has(String(turn.status))) {
|
|
120
|
-
throw new Error(`Codex app-server returned malformed ${context}.status`);
|
|
121
|
-
}
|
|
122
|
-
if (turn.error !== null) {
|
|
123
|
-
const error = object(turn.error);
|
|
124
|
-
if (!error ||
|
|
125
|
-
typeof error.message !== 'string' ||
|
|
126
|
-
error.codexErrorInfo === undefined ||
|
|
127
|
-
(error.additionalDetails !== null && typeof error.additionalDetails !== 'string')) {
|
|
128
|
-
throw new Error(`Codex app-server returned malformed ${context}.error`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
nullableNumberField(turn, 'startedAt', context);
|
|
132
|
-
nullableNumberField(turn, 'completedAt', context);
|
|
133
|
-
nullableNumberField(turn, 'durationMs', context);
|
|
134
|
-
return turn;
|
|
135
|
-
}
|
|
136
|
-
function validateThread(value) {
|
|
137
|
-
const thread = object(value);
|
|
138
|
-
if (!thread) {
|
|
139
|
-
throw new Error('Codex app-server returned malformed thread');
|
|
140
|
-
}
|
|
141
|
-
for (const field of ['id', 'sessionId', 'preview', 'modelProvider', 'cwd', 'cliVersion']) {
|
|
142
|
-
stringField(thread, field, 'thread');
|
|
143
|
-
}
|
|
144
|
-
for (const field of [
|
|
145
|
-
'forkedFromId',
|
|
146
|
-
'parentThreadId',
|
|
147
|
-
'path',
|
|
148
|
-
'threadSource',
|
|
149
|
-
'agentNickname',
|
|
150
|
-
'agentRole',
|
|
151
|
-
'name',
|
|
152
|
-
]) {
|
|
153
|
-
nullableStringField(thread, field, 'thread');
|
|
154
|
-
}
|
|
155
|
-
if (typeof thread.ephemeral !== 'boolean') {
|
|
156
|
-
throw new Error('Codex app-server returned malformed thread.ephemeral');
|
|
157
|
-
}
|
|
158
|
-
for (const field of ['createdAt', 'updatedAt']) {
|
|
159
|
-
if (typeof thread[field] !== 'number' || !Number.isFinite(thread[field])) {
|
|
160
|
-
throw new Error(`Codex app-server returned malformed thread.${field}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
nullableNumberField(thread, 'recencyAt', 'thread');
|
|
164
|
-
const status = object(thread.status);
|
|
165
|
-
if (!status ||
|
|
166
|
-
!['notLoaded', 'idle', 'systemError', 'active'].includes(String(status.type)) ||
|
|
167
|
-
(status.type === 'active' && !Array.isArray(status.activeFlags))) {
|
|
168
|
-
throw new Error('Codex app-server returned malformed thread.status');
|
|
169
|
-
}
|
|
170
|
-
const sourceValid = typeof thread.source === 'string' || object(thread.source) !== undefined;
|
|
171
|
-
if (!sourceValid ||
|
|
172
|
-
(thread.gitInfo !== null && !object(thread.gitInfo)) ||
|
|
173
|
-
!Array.isArray(thread.turns)) {
|
|
174
|
-
throw new Error('Codex app-server returned malformed thread metadata');
|
|
175
|
-
}
|
|
176
|
-
for (const turn of thread.turns) {
|
|
177
|
-
validateTurn(turn, 'thread.turns[]');
|
|
178
|
-
}
|
|
179
|
-
return thread;
|
|
180
|
-
}
|
|
181
|
-
function shaFile(path) {
|
|
182
|
-
return (0, node_crypto_1.createHash)('sha256').update((0, node_fs_1.readFileSync)(path)).digest('hex');
|
|
183
|
-
}
|
|
184
|
-
function managedFileSignature(path) {
|
|
185
|
-
if (!(0, node_fs_1.existsSync)(path)) {
|
|
186
|
-
return undefined;
|
|
187
|
-
}
|
|
188
|
-
const stat = (0, node_fs_1.statSync)(path);
|
|
189
|
-
return `${stat.dev}:${stat.ino}:${stat.mode}:${stat.size}:${stat.mtimeMs}:${stat.ctimeMs}`;
|
|
190
|
-
}
|
|
191
|
-
function ensurePrivateDirectory(path) {
|
|
192
|
-
(0, node_fs_1.mkdirSync)(path, { recursive: true, mode: 0o700 });
|
|
193
|
-
(0, node_fs_1.chmodSync)(path, 0o700);
|
|
194
|
-
}
|
|
195
|
-
function atomicPrivateWrite(path, value) {
|
|
196
|
-
ensurePrivateDirectory((0, node_path_1.dirname)(path));
|
|
197
|
-
const temporary = `${path}.${process.pid}.${(0, node_crypto_1.randomUUID)()}.tmp`;
|
|
198
|
-
(0, node_fs_1.writeFileSync)(temporary, value, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
199
|
-
(0, node_fs_1.chmodSync)(temporary, 0o600);
|
|
200
|
-
(0, node_fs_1.renameSync)(temporary, path);
|
|
201
|
-
(0, node_fs_1.chmodSync)(path, 0o600);
|
|
202
|
-
}
|
|
203
|
-
function copyAuthAtomically(source, destination) {
|
|
204
|
-
if (!(0, node_fs_1.existsSync)(source) ||
|
|
205
|
-
(0, node_fs_1.statSync)(source).size === 0 ||
|
|
206
|
-
(0, node_path_1.resolve)(source) === (0, node_path_1.resolve)(destination)) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
ensurePrivateDirectory((0, node_path_1.dirname)(destination));
|
|
210
|
-
const temporary = `${destination}.${process.pid}.${(0, node_crypto_1.randomUUID)()}.tmp`;
|
|
211
|
-
(0, node_fs_1.copyFileSync)(source, temporary);
|
|
212
|
-
(0, node_fs_1.chmodSync)(temporary, 0o600);
|
|
213
|
-
(0, node_fs_1.renameSync)(temporary, destination);
|
|
214
|
-
(0, node_fs_1.chmodSync)(destination, 0o600);
|
|
215
|
-
}
|
|
216
|
-
function configuredSecretValues(launch) {
|
|
217
|
-
const names = new Set();
|
|
218
|
-
const addJsonString = (source) => {
|
|
219
|
-
try {
|
|
220
|
-
const name = JSON.parse(source);
|
|
221
|
-
if (typeof name === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {
|
|
222
|
-
names.add(name);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
catch (error) {
|
|
226
|
-
throw new Error('Codex app-server launch config contained malformed environment quoting', {
|
|
227
|
-
cause: error,
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
for (const argument of launch.args) {
|
|
232
|
-
for (const match of argument.matchAll(/env_vars\s*=\s*\[([^\]]*)\]/g)) {
|
|
233
|
-
for (const quoted of match[1].matchAll(/"(?:\\.|[^"\\])*"/g)) {
|
|
234
|
-
addJsonString(quoted[0]);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
for (const match of argument.matchAll(/bearer_token_env_var\s*=\s*("(?:\\.|[^"\\])*")/g)) {
|
|
238
|
-
addJsonString(match[1]);
|
|
239
|
-
}
|
|
240
|
-
for (const match of argument.matchAll(/env_http_headers\s*=\s*\{([^}]*)\}/g)) {
|
|
241
|
-
for (const binding of match[1].matchAll(/=\s*("(?:\\.|[^"\\])*")/g)) {
|
|
242
|
-
addJsonString(binding[1]);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
const values = new Set();
|
|
247
|
-
for (const name of names) {
|
|
248
|
-
const value = launch.env[name];
|
|
249
|
-
if (typeof value === 'string' && value.length > 0) {
|
|
250
|
-
values.add(value);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return values;
|
|
254
|
-
}
|
|
255
|
-
class CodexAppServerProcess {
|
|
256
|
-
options;
|
|
257
|
-
registry;
|
|
258
|
-
child;
|
|
259
|
-
stdout;
|
|
260
|
-
stderr;
|
|
261
|
-
nextId = 0;
|
|
262
|
-
pending = new Map();
|
|
263
|
-
lateTurnStarts = new Map();
|
|
264
|
-
turnStartReconciliations = new Map();
|
|
265
|
-
turns = new Map();
|
|
266
|
-
subagents = new Map();
|
|
267
|
-
/**
|
|
268
|
-
* Child threads that already reported a terminal status. The SAME `started`
|
|
269
|
-
* announcement arrives as both an item/started and an item/completed view, and the
|
|
270
|
-
* second view can land after the child's own turn/completed - `subagents.has` no longer
|
|
271
|
-
* dedupes it then, so it would mint a second authority and a second completion for a
|
|
272
|
-
* dead child. Bounded FIFO: identity of recent children, not a growing ledger.
|
|
273
|
-
*/
|
|
274
|
-
finishedSubagents = new Set();
|
|
275
|
-
threadContexts = new Map();
|
|
276
|
-
sessions = new Map();
|
|
277
|
-
sessionQueues = new Map();
|
|
278
|
-
connectionQueue = Promise.resolve();
|
|
279
|
-
startPromise;
|
|
280
|
-
shutdownPromise;
|
|
281
|
-
stopped = false;
|
|
282
|
-
stderrTail = '';
|
|
283
|
-
secrets = new Set();
|
|
284
|
-
authFingerprint;
|
|
285
|
-
authFingerprintInitialized = false;
|
|
286
|
-
authSourceSignature;
|
|
287
|
-
managedConfigFingerprint;
|
|
288
|
-
managedConfigSignature;
|
|
289
|
-
secretLaunchFingerprint;
|
|
290
|
-
secretLaunchFingerprintInitialized = false;
|
|
291
|
-
killTimer;
|
|
292
|
-
finalKillTimer;
|
|
293
|
-
constructor(options) {
|
|
294
|
-
const mamaRoot = (0, node_path_1.join)((0, node_os_1.homedir)(), '.mama');
|
|
295
|
-
this.options = {
|
|
296
|
-
...options,
|
|
297
|
-
command: options.command ?? 'codex',
|
|
298
|
-
requestTimeout: options.requestTimeout ?? DEFAULT_TIMEOUT,
|
|
299
|
-
codexHome: (0, node_path_1.resolve)(options.codexHome ?? (0, node_path_1.join)(mamaRoot, '.codex')),
|
|
300
|
-
isolatedHome: (0, node_path_1.resolve)(options.isolatedHome ?? (0, node_path_1.join)(mamaRoot, 'codex-runtime', 'home')),
|
|
301
|
-
registryRoot: (0, node_path_1.resolve)(options.registryRoot ?? (0, node_path_1.join)(mamaRoot, 'codex-runtime', 'threads')),
|
|
302
|
-
cwd: (0, node_path_1.resolve)(options.cwd),
|
|
303
|
-
};
|
|
304
|
-
ensurePrivateDirectory((0, node_path_1.dirname)(this.options.registryRoot));
|
|
305
|
-
this.registry = new codex_thread_registry_js_1.CodexThreadRegistry({ rootDir: this.options.registryRoot });
|
|
306
|
-
}
|
|
307
|
-
async prompt(text, callbacks, overrides = {}) {
|
|
308
|
-
if (this.stopped) {
|
|
309
|
-
throw new Error('Codex app-server process is stopped');
|
|
310
|
-
}
|
|
311
|
-
const session = this.resolveSessionPolicy(overrides);
|
|
312
|
-
return this.enqueueSession(session.sessionKey, async () => {
|
|
313
|
-
try {
|
|
314
|
-
if (this.stopped) {
|
|
315
|
-
throw new Error('Codex app-server process is stopped');
|
|
316
|
-
}
|
|
317
|
-
const launch = (0, codex_home_js_1.buildCodexAppServerLaunchConfig)(this.options.mcpConfigPath, process.env);
|
|
318
|
-
if (overrides.resumeSession === false) {
|
|
319
|
-
this.discardSessionThreadState(session.sessionKey, 'session was restarted');
|
|
320
|
-
this.registry.remove(session.sessionKey);
|
|
321
|
-
this.sessions.delete(session.sessionKey);
|
|
322
|
-
}
|
|
323
|
-
this.assertRegistryPolicy(session, launch);
|
|
324
|
-
await this.prepareConnection(launch, session.requestTimeout);
|
|
325
|
-
let state = this.sessions.get(session.sessionKey);
|
|
326
|
-
if (!state?.threadId) {
|
|
327
|
-
try {
|
|
328
|
-
state = await this.openThread(session, launch);
|
|
329
|
-
}
|
|
330
|
-
catch (error) {
|
|
331
|
-
if (this.child && !this.shutdownPromise) {
|
|
332
|
-
await this.shutdown(this.toError(error));
|
|
333
|
-
}
|
|
334
|
-
throw error;
|
|
335
|
-
}
|
|
336
|
-
this.sessions.set(session.sessionKey, state);
|
|
337
|
-
}
|
|
338
|
-
const reconciliation = this.turnStartReconciliations.get(state.threadId);
|
|
339
|
-
if (reconciliation) {
|
|
340
|
-
await reconciliation.promise;
|
|
341
|
-
await this.prepareConnection(launch, session.requestTimeout);
|
|
342
|
-
state = this.sessions.get(session.sessionKey);
|
|
343
|
-
if (!state?.threadId) {
|
|
344
|
-
state = await this.openThread(session, launch);
|
|
345
|
-
this.sessions.set(session.sessionKey, state);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
const replayReminder = Boolean(state.bootstrapPending && session.systemPrompt);
|
|
349
|
-
const turnText = replayReminder
|
|
350
|
-
? `<system-reminder>\nFresh MAMA runtime context after resuming this durable thread:\n${session.systemPrompt.replace(/<\/system-reminder>/gi, '')}\n</system-reminder>\n\n${text}`
|
|
351
|
-
: text;
|
|
352
|
-
// One line per turn, where the text that actually reaches the model is known.
|
|
353
|
-
// This is what makes "fixed things once, turns carry only deltas" measurable
|
|
354
|
-
// from daemon.log instead of asserted.
|
|
355
|
-
console.log(`[prompt] thread=${state.threadId} kind=${session.promptTelemetry?.kind ?? 'chat'} ` +
|
|
356
|
-
`chars=${turnText.length} brief=${session.promptTelemetry?.brief ?? 'omitted'} ` +
|
|
357
|
-
`reminder=${replayReminder ? 'sent' : 'omitted'}`);
|
|
358
|
-
// A Codex-native child can be announced after this turn resolved, so remember
|
|
359
|
-
// which session the thread belongs to outside the PendingTurn lifetime. The
|
|
360
|
-
// parent's BRIDGE is deliberately not kept: a child gets its own authority.
|
|
361
|
-
// A session that rotated its thread leaves the previous thread's context behind,
|
|
362
|
-
// and a stale entry both leaks and lets a dead thread announce children.
|
|
363
|
-
this.pruneThreadContexts(session.sessionKey, state.threadId);
|
|
364
|
-
this.threadContexts.set(state.threadId, {
|
|
365
|
-
sessionKey: session.sessionKey,
|
|
366
|
-
onToolUse: callbacks?.onToolUse,
|
|
367
|
-
onToolComplete: callbacks?.onToolComplete,
|
|
368
|
-
});
|
|
369
|
-
const result = await this.startTurn(state.threadId, turnText, callbacks, session.requestTimeout, session.hostToolBridge, overrides.runTokenBudget);
|
|
370
|
-
state.bootstrapPending = false;
|
|
371
|
-
return result;
|
|
372
|
-
}
|
|
373
|
-
catch (error) {
|
|
374
|
-
if (error instanceof CodexAppServerRpcError &&
|
|
375
|
-
error.code !== OVERLOADED_ERROR_CODE &&
|
|
376
|
-
this.child &&
|
|
377
|
-
!this.shutdownPromise) {
|
|
378
|
-
await this.shutdown(error);
|
|
379
|
-
}
|
|
380
|
-
if (this.shutdownPromise) {
|
|
381
|
-
await this.shutdownPromise;
|
|
382
|
-
}
|
|
383
|
-
throw error;
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
async reset(sessionKey = this.options.sessionKey) {
|
|
388
|
-
await this.enqueueSession(sessionKey, async () => {
|
|
389
|
-
this.discardSessionThreadState(sessionKey, 'session was reset');
|
|
390
|
-
this.registry.remove(sessionKey);
|
|
391
|
-
this.sessions.delete(sessionKey);
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
getSessionPolicyStatus(overrides = {}) {
|
|
395
|
-
const session = this.resolveSessionPolicy(overrides);
|
|
396
|
-
const record = this.registry.load(session.sessionKey);
|
|
397
|
-
if (!record) {
|
|
398
|
-
return 'missing';
|
|
399
|
-
}
|
|
400
|
-
const launch = (0, codex_home_js_1.buildCodexAppServerLaunchConfig)(this.options.mcpConfigPath, process.env);
|
|
401
|
-
return this.registryPolicyMatches(record, session, launch) ? 'compatible' : 'mismatch';
|
|
402
|
-
}
|
|
403
|
-
async stop() {
|
|
404
|
-
this.stopped = true;
|
|
405
|
-
await this.shutdown(new Error('Codex app-server process stopped'));
|
|
406
|
-
this.terminateSubagents(new Error('Codex app-server process stopped'));
|
|
407
|
-
this.threadContexts.clear();
|
|
408
|
-
}
|
|
409
|
-
async executeSandboxedCommand(command, cwd, roots, signal) {
|
|
410
|
-
signal?.throwIfAborted();
|
|
411
|
-
if (!this.child)
|
|
412
|
-
throw new Error('Codex app-server is not connected');
|
|
413
|
-
const shellCommand = process.platform === 'win32'
|
|
414
|
-
? ['cmd.exe', '/d', '/s', '/c', command]
|
|
415
|
-
: ['/bin/sh', '-c', command];
|
|
416
|
-
const result = object(await this.request('command/exec', {
|
|
417
|
-
command: shellCommand,
|
|
418
|
-
cwd,
|
|
419
|
-
sandboxPolicy: {
|
|
420
|
-
type: 'workspaceWrite',
|
|
421
|
-
writableRoots: [...roots],
|
|
422
|
-
readOnlyAccess: {
|
|
423
|
-
type: 'restricted',
|
|
424
|
-
includePlatformDefaults: true,
|
|
425
|
-
readableRoots: [...roots],
|
|
426
|
-
},
|
|
427
|
-
networkAccess: false,
|
|
428
|
-
},
|
|
429
|
-
timeoutMs: this.options.requestTimeout,
|
|
430
|
-
}, this.options.requestTimeout));
|
|
431
|
-
signal?.throwIfAborted();
|
|
432
|
-
if (typeof result?.exitCode !== 'number' ||
|
|
433
|
-
typeof result.stdout !== 'string' ||
|
|
434
|
-
typeof result.stderr !== 'string') {
|
|
435
|
-
throw new Error('Codex app-server returned a malformed command result');
|
|
436
|
-
}
|
|
437
|
-
return { exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr };
|
|
438
|
-
}
|
|
439
|
-
getThreadId(sessionKey = this.options.sessionKey) {
|
|
440
|
-
return this.sessions.get(sessionKey)?.threadId || undefined;
|
|
441
|
-
}
|
|
442
|
-
getStatus() {
|
|
443
|
-
return {
|
|
444
|
-
running: this.child !== undefined,
|
|
445
|
-
childPid: this.child?.pid,
|
|
446
|
-
pendingRequestCount: this.pending.size,
|
|
447
|
-
hasActiveTurn: this.turns.size > 0,
|
|
448
|
-
stdoutListenerCount: this.stdout?.listenerCount('line') ?? 0,
|
|
449
|
-
stderrListenerCount: this.stderr?.listenerCount('line') ?? 0,
|
|
450
|
-
shutdownTimerActive: this.killTimer !== undefined || this.finalKillTimer !== undefined,
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
resolveSessionPolicy(overrides) {
|
|
454
|
-
const hostToolBridge = snapshotHostToolBridge(overrides.hostToolBridge);
|
|
455
|
-
return {
|
|
456
|
-
sessionKey: overrides.sessionKey ?? this.options.sessionKey,
|
|
457
|
-
model: overrides.model ?? this.options.model,
|
|
458
|
-
systemPrompt: overrides.systemPrompt ?? this.options.systemPrompt,
|
|
459
|
-
cwd: (0, node_path_1.resolve)(overrides.cwd ?? this.options.cwd),
|
|
460
|
-
sandbox: overrides.sandbox ?? this.options.sandbox,
|
|
461
|
-
requestTimeout: overrides.requestTimeout ?? this.options.requestTimeout,
|
|
462
|
-
policyFingerprint: overrides.policyFingerprint ?? this.options.policyFingerprint,
|
|
463
|
-
hostToolBridge,
|
|
464
|
-
resumeInstructions: overrides.resumeInstructions,
|
|
465
|
-
promptTelemetry: overrides.promptTelemetry,
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
enqueueSession(sessionKey, operation) {
|
|
469
|
-
const previous = this.sessionQueues.get(sessionKey) ?? Promise.resolve();
|
|
470
|
-
const result = previous.catch(() => undefined).then(operation);
|
|
471
|
-
const tail = result.then(() => undefined, () => undefined);
|
|
472
|
-
this.sessionQueues.set(sessionKey, tail);
|
|
473
|
-
void tail.finally(() => {
|
|
474
|
-
if (this.sessionQueues.get(sessionKey) === tail) {
|
|
475
|
-
this.sessionQueues.delete(sessionKey);
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
return result;
|
|
479
|
-
}
|
|
480
|
-
async prepareConnection(launch, requestTimeout) {
|
|
481
|
-
const operation = this.connectionQueue.then(async () => {
|
|
482
|
-
if (this.stopped) {
|
|
483
|
-
throw new Error('Codex app-server process is stopped');
|
|
484
|
-
}
|
|
485
|
-
if (this.shutdownPromise) {
|
|
486
|
-
await this.shutdownPromise;
|
|
487
|
-
}
|
|
488
|
-
if (this.stopped) {
|
|
489
|
-
throw new Error('Codex app-server process is stopped');
|
|
490
|
-
}
|
|
491
|
-
const refreshed = this.prepareManagedFiles(launch);
|
|
492
|
-
if (refreshed && this.child) {
|
|
493
|
-
await this.restart();
|
|
494
|
-
}
|
|
495
|
-
try {
|
|
496
|
-
await this.ensureStarted(launch, requestTimeout);
|
|
497
|
-
}
|
|
498
|
-
catch (error) {
|
|
499
|
-
if (this.child && !this.shutdownPromise) {
|
|
500
|
-
await this.shutdown(this.toError(error));
|
|
501
|
-
}
|
|
502
|
-
throw error;
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
this.connectionQueue = operation.catch(() => undefined);
|
|
506
|
-
await operation;
|
|
507
|
-
}
|
|
508
|
-
assertRegistryPolicy(session, launch) {
|
|
509
|
-
const record = this.registry.load(session.sessionKey);
|
|
510
|
-
if (!record) {
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
if (!this.registryPolicyMatches(record, session, launch)) {
|
|
514
|
-
throw new Error('Codex app-server thread policy mismatch; reset the session explicitly');
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
registryPolicyMatches(record, session, launch) {
|
|
518
|
-
return (record.model === session.model &&
|
|
519
|
-
record.cwd === session.cwd &&
|
|
520
|
-
record.systemPromptFingerprint === this.policyFingerprint(session) &&
|
|
521
|
-
record.mcpConfigFingerprint === launch.fingerprint);
|
|
522
|
-
}
|
|
523
|
-
prepareManagedFiles(launch) {
|
|
524
|
-
ensurePrivateDirectory(this.options.codexHome);
|
|
525
|
-
ensurePrivateDirectory(this.options.isolatedHome);
|
|
526
|
-
const configPath = (0, node_path_1.join)(this.options.codexHome, 'config.toml');
|
|
527
|
-
const config = (0, codex_home_js_1.buildMAMACodexAppServerConfig)(this.options.effort);
|
|
528
|
-
const configFingerprint = (0, codex_thread_registry_js_1.fingerprintText)(config);
|
|
529
|
-
const configSignature = managedFileSignature(configPath);
|
|
530
|
-
if (this.managedConfigFingerprint !== configFingerprint ||
|
|
531
|
-
this.managedConfigSignature !== configSignature) {
|
|
532
|
-
if (configSignature === undefined || shaFile(configPath) !== configFingerprint) {
|
|
533
|
-
atomicPrivateWrite(configPath, config);
|
|
534
|
-
}
|
|
535
|
-
this.managedConfigFingerprint = configFingerprint;
|
|
536
|
-
this.managedConfigSignature = managedFileSignature(configPath);
|
|
537
|
-
}
|
|
538
|
-
const sourceAuth = (0, node_path_1.join)((0, node_os_1.homedir)(), '.codex', 'auth.json');
|
|
539
|
-
const destinationAuth = (0, node_path_1.join)(this.options.codexHome, 'auth.json');
|
|
540
|
-
const sourceStat = (0, node_fs_1.existsSync)(sourceAuth) ? (0, node_fs_1.statSync)(sourceAuth) : undefined;
|
|
541
|
-
const sourceSignature = sourceStat && sourceStat.size > 0
|
|
542
|
-
? `${(0, node_fs_1.realpathSync)(sourceAuth)}:${sourceStat.size}:${sourceStat.mtimeMs}:${sourceStat.ctimeMs}`
|
|
543
|
-
: undefined;
|
|
544
|
-
let sourceFingerprint = this.authFingerprint;
|
|
545
|
-
if (!this.authFingerprintInitialized ||
|
|
546
|
-
this.authSourceSignature !== sourceSignature ||
|
|
547
|
-
(sourceSignature !== undefined && !(0, node_fs_1.existsSync)(destinationAuth))) {
|
|
548
|
-
sourceFingerprint = sourceSignature ? shaFile(sourceAuth) : undefined;
|
|
549
|
-
if (sourceFingerprint &&
|
|
550
|
-
(!(0, node_fs_1.existsSync)(destinationAuth) || shaFile(destinationAuth) !== sourceFingerprint)) {
|
|
551
|
-
copyAuthAtomically(sourceAuth, destinationAuth);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
const changed = this.authFingerprintInitialized && this.authFingerprint !== sourceFingerprint;
|
|
555
|
-
this.authFingerprint = sourceFingerprint;
|
|
556
|
-
this.authFingerprintInitialized = true;
|
|
557
|
-
this.authSourceSignature = sourceSignature;
|
|
558
|
-
const secretChanged = this.secretLaunchFingerprintInitialized &&
|
|
559
|
-
this.secretLaunchFingerprint !== launch.secretFingerprint;
|
|
560
|
-
if (!this.secretLaunchFingerprintInitialized ||
|
|
561
|
-
this.secretLaunchFingerprint !== launch.secretFingerprint) {
|
|
562
|
-
this.secrets = configuredSecretValues(launch);
|
|
563
|
-
this.secretLaunchFingerprint = launch.secretFingerprint;
|
|
564
|
-
this.secretLaunchFingerprintInitialized = true;
|
|
565
|
-
}
|
|
566
|
-
return changed || secretChanged;
|
|
567
|
-
}
|
|
568
|
-
async ensureStarted(launch, requestTimeout) {
|
|
569
|
-
if (this.child) {
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
if (!this.startPromise) {
|
|
573
|
-
this.startPromise = this.start(launch, requestTimeout);
|
|
574
|
-
}
|
|
575
|
-
try {
|
|
576
|
-
await this.startPromise;
|
|
577
|
-
}
|
|
578
|
-
finally {
|
|
579
|
-
this.startPromise = undefined;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
async start(launch, requestTimeout) {
|
|
583
|
-
const child = (0, node_child_process_1.spawn)(this.options.command, ['app-server', '--strict-config', '--stdio', ...launch.args], {
|
|
584
|
-
cwd: this.options.cwd,
|
|
585
|
-
env: { ...launch.env, HOME: this.options.isolatedHome, CODEX_HOME: this.options.codexHome },
|
|
586
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
587
|
-
});
|
|
588
|
-
this.child = child;
|
|
589
|
-
this.stdout = (0, node_readline_1.createInterface)({ input: child.stdout, crlfDelay: Infinity });
|
|
590
|
-
this.stderr = (0, node_readline_1.createInterface)({ input: child.stderr, crlfDelay: Infinity });
|
|
591
|
-
this.stdout.on('line', (line) => this.handleLine(child, line));
|
|
592
|
-
this.stderr.on('line', (line) => this.handleStderr(line));
|
|
593
|
-
child.once('error', (error) => this.failProcess(child, error));
|
|
594
|
-
child.once('exit', (code, signal) => this.failProcess(child, new Error(`Codex app-server exited (${code ?? signal ?? 'unknown'})`)));
|
|
595
|
-
const initialized = await this.request('initialize', {
|
|
596
|
-
clientInfo: CLIENT_INFO,
|
|
597
|
-
capabilities: { experimentalApi: true },
|
|
598
|
-
}, requestTimeout);
|
|
599
|
-
const initializeResponse = object(initialized);
|
|
600
|
-
if (!initializeResponse ||
|
|
601
|
-
typeof initializeResponse.userAgent !== 'string' ||
|
|
602
|
-
typeof initializeResponse.codexHome !== 'string' ||
|
|
603
|
-
typeof initializeResponse.platformFamily !== 'string' ||
|
|
604
|
-
typeof initializeResponse.platformOs !== 'string') {
|
|
605
|
-
throw new Error('Codex app-server initialize returned a malformed response');
|
|
606
|
-
}
|
|
607
|
-
if ((0, node_fs_1.realpathSync)(initializeResponse.codexHome) !== (0, node_fs_1.realpathSync)(this.options.codexHome)) {
|
|
608
|
-
throw new Error('Codex app-server initialize returned an unexpected CODEX_HOME');
|
|
609
|
-
}
|
|
610
|
-
this.notify('initialized');
|
|
611
|
-
}
|
|
612
|
-
async openThread(session, launch) {
|
|
613
|
-
const record = this.registry.load(session.sessionKey);
|
|
614
|
-
if (record) {
|
|
615
|
-
// A rehydrated thread carries its original instructions only in the model's own
|
|
616
|
-
// history, where compaction eventually erodes them. ThreadResumeParams accepts
|
|
617
|
-
// baseInstructions, so re-anchor through the protocol when the caller can supply
|
|
618
|
-
// the full text. assertRegistryPolicy already proved the stored policy fingerprint
|
|
619
|
-
// matches this session, and the caller builds these instructions from the same
|
|
620
|
-
// composed-prompt sources that produced that fingerprint - so re-supplying them
|
|
621
|
-
// restates the agreed policy rather than switching to a new one.
|
|
622
|
-
const resumeInstructions = session.resumeInstructions
|
|
623
|
-
? await session.resumeInstructions()
|
|
624
|
-
: undefined;
|
|
625
|
-
if (session.resumeInstructions && !resumeInstructions?.trim()) {
|
|
626
|
-
// No-fallback: silently resuming without instructions is the very failure this
|
|
627
|
-
// path exists to remove.
|
|
628
|
-
throw new Error('Codex app-server resume instructions resolved to empty text');
|
|
629
|
-
}
|
|
630
|
-
const resumeParams = {
|
|
631
|
-
threadId: record.threadId,
|
|
632
|
-
model: session.model,
|
|
633
|
-
cwd: session.cwd,
|
|
634
|
-
approvalPolicy: 'never',
|
|
635
|
-
sandbox: session.sandbox,
|
|
636
|
-
};
|
|
637
|
-
if (resumeInstructions) {
|
|
638
|
-
resumeParams.baseInstructions = resumeInstructions;
|
|
639
|
-
}
|
|
640
|
-
const result = object(await this.request('thread/resume', resumeParams, session.requestTimeout));
|
|
641
|
-
this.validateResponsePolicy(result, session);
|
|
642
|
-
this.validateInstructionMetadata(result, session);
|
|
643
|
-
const resumed = validateThread(result?.thread);
|
|
644
|
-
if (typeof resumed?.id !== 'string' || resumed.id !== record.threadId) {
|
|
645
|
-
throw new Error('Codex app-server resumed an unexpected thread');
|
|
646
|
-
}
|
|
647
|
-
// Instructions delivered through the protocol make the turn-text bootstrap
|
|
648
|
-
// redundant; without them the legacy <system-reminder> replay still applies.
|
|
649
|
-
return { threadId: record.threadId, bootstrapPending: resumeInstructions === undefined };
|
|
650
|
-
}
|
|
651
|
-
const threadStartParams = {
|
|
652
|
-
model: session.model,
|
|
653
|
-
cwd: session.cwd,
|
|
654
|
-
approvalPolicy: 'never',
|
|
655
|
-
sandbox: session.sandbox,
|
|
656
|
-
baseInstructions: session.systemPrompt,
|
|
657
|
-
config: {},
|
|
658
|
-
};
|
|
659
|
-
if (session.hostToolBridge) {
|
|
660
|
-
threadStartParams.dynamicTools = session.hostToolBridge.tools;
|
|
661
|
-
}
|
|
662
|
-
const result = object(await this.request('thread/start', threadStartParams, session.requestTimeout));
|
|
663
|
-
this.validateResponsePolicy(result, session);
|
|
664
|
-
this.validateInstructionMetadata(result, session);
|
|
665
|
-
const thread = validateThread(result?.thread);
|
|
666
|
-
if (typeof thread?.id !== 'string' || !thread.id) {
|
|
667
|
-
throw new Error('Codex app-server thread/start returned no thread id');
|
|
668
|
-
}
|
|
669
|
-
this.registry.save({
|
|
670
|
-
sessionKey: session.sessionKey,
|
|
671
|
-
threadId: thread.id,
|
|
672
|
-
model: session.model,
|
|
673
|
-
cwd: session.cwd,
|
|
674
|
-
systemPromptFingerprint: this.policyFingerprint(session),
|
|
675
|
-
mcpConfigFingerprint: launch.fingerprint,
|
|
676
|
-
});
|
|
677
|
-
return { threadId: thread.id, bootstrapPending: false };
|
|
678
|
-
}
|
|
679
|
-
policyFingerprint(session) {
|
|
680
|
-
const base = session.policyFingerprint ?? (0, codex_thread_registry_js_1.fingerprintText)(session.systemPrompt);
|
|
681
|
-
const tools = session.hostToolBridge?.tools;
|
|
682
|
-
if (!tools?.length) {
|
|
683
|
-
return base;
|
|
684
|
-
}
|
|
685
|
-
return (0, codex_thread_registry_js_1.fingerprintText)(`${base}\n${JSON.stringify(tools)}`);
|
|
686
|
-
}
|
|
687
|
-
validateInstructionMetadata(result, session) {
|
|
688
|
-
const sources = result?.instructionSources;
|
|
689
|
-
if (!Array.isArray(sources)) {
|
|
690
|
-
throw new Error('Codex app-server returned malformed instruction sources');
|
|
691
|
-
}
|
|
692
|
-
const managedRoots = [session.cwd, this.options.codexHome].map((root) => (0, node_fs_1.realpathSync)(root));
|
|
693
|
-
for (const source of sources) {
|
|
694
|
-
if (typeof source !== 'string') {
|
|
695
|
-
throw new Error('Codex app-server returned malformed instruction source');
|
|
696
|
-
}
|
|
697
|
-
let path;
|
|
698
|
-
try {
|
|
699
|
-
path = (0, node_fs_1.realpathSync)((0, node_path_1.resolve)(session.cwd, source));
|
|
700
|
-
}
|
|
701
|
-
catch (error) {
|
|
702
|
-
throw new Error('Codex app-server loaded an instruction source outside managed roots', {
|
|
703
|
-
cause: error,
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
const allowed = managedRoots.some((root) => {
|
|
707
|
-
const childPath = (0, node_path_1.relative)(root, path);
|
|
708
|
-
return (childPath === '' ||
|
|
709
|
-
(childPath !== '..' && !childPath.startsWith(`..${node_path_1.sep}`) && !(0, node_path_1.isAbsolute)(childPath)));
|
|
710
|
-
});
|
|
711
|
-
if (!allowed) {
|
|
712
|
-
throw new Error('Codex app-server loaded an instruction source outside managed roots');
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
validateResponsePolicy(result, session) {
|
|
717
|
-
if (!result) {
|
|
718
|
-
throw new Error('Codex app-server returned a malformed thread response');
|
|
719
|
-
}
|
|
720
|
-
if (typeof result.modelProvider !== 'string' ||
|
|
721
|
-
(result.serviceTier !== null && typeof result.serviceTier !== 'string') ||
|
|
722
|
-
!APPROVAL_REVIEWERS.has(String(result.approvalsReviewer)) ||
|
|
723
|
-
(result.reasoningEffort !== null && typeof result.reasoningEffort !== 'string')) {
|
|
724
|
-
throw new Error('Codex app-server returned malformed thread response metadata');
|
|
725
|
-
}
|
|
726
|
-
if (typeof result.model !== 'string' || result.model !== session.model) {
|
|
727
|
-
throw new Error('Codex app-server response model did not match the requested policy');
|
|
728
|
-
}
|
|
729
|
-
if (typeof result.cwd !== 'string' || (0, node_path_1.resolve)(result.cwd) !== session.cwd) {
|
|
730
|
-
throw new Error('Codex app-server response cwd did not match the requested policy');
|
|
731
|
-
}
|
|
732
|
-
if (result.approvalPolicy !== 'never') {
|
|
733
|
-
throw new Error('Codex app-server response approval policy was not never');
|
|
734
|
-
}
|
|
735
|
-
const sandbox = object(result.sandbox);
|
|
736
|
-
const expectedSandboxType = {
|
|
737
|
-
'read-only': 'readOnly',
|
|
738
|
-
'workspace-write': 'workspaceWrite',
|
|
739
|
-
'danger-full-access': 'dangerFullAccess',
|
|
740
|
-
}[session.sandbox];
|
|
741
|
-
if (typeof sandbox?.type !== 'string' || sandbox.type !== expectedSandboxType) {
|
|
742
|
-
throw new Error('Codex app-server response sandbox did not match the requested policy');
|
|
743
|
-
}
|
|
744
|
-
if (sandbox.type === 'readOnly' && typeof sandbox.networkAccess !== 'boolean') {
|
|
745
|
-
throw new Error('Codex app-server returned a malformed read-only sandbox policy');
|
|
746
|
-
}
|
|
747
|
-
if (sandbox.type === 'workspaceWrite' &&
|
|
748
|
-
(!Array.isArray(sandbox.writableRoots) ||
|
|
749
|
-
typeof sandbox.networkAccess !== 'boolean' ||
|
|
750
|
-
typeof sandbox.excludeTmpdirEnvVar !== 'boolean' ||
|
|
751
|
-
typeof sandbox.excludeSlashTmp !== 'boolean')) {
|
|
752
|
-
throw new Error('Codex app-server returned a malformed workspace-write sandbox policy');
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
startTurn(threadId, text, callbacks, requestTimeout, hostToolBridge, runTokenBudget) {
|
|
756
|
-
return new Promise((resolveTurn, rejectTurn) => {
|
|
757
|
-
const abortController = new AbortController();
|
|
758
|
-
const timer = setTimeout(() => {
|
|
759
|
-
const error = new Error(`Codex app-server turn timed out after ${requestTimeout}ms`);
|
|
760
|
-
this.timeoutTurn(threadId, error, requestTimeout);
|
|
761
|
-
}, requestTimeout);
|
|
762
|
-
timer.unref();
|
|
763
|
-
const pendingTurn = {
|
|
764
|
-
threadId,
|
|
765
|
-
chunks: [],
|
|
766
|
-
usage: { input_tokens: 0, output_tokens: 0 },
|
|
767
|
-
runTokenBudget,
|
|
768
|
-
timer,
|
|
769
|
-
requestTimeout,
|
|
770
|
-
queuedNotifications: [],
|
|
771
|
-
queuedToolRequests: [],
|
|
772
|
-
toolCallQueue: Promise.resolve(),
|
|
773
|
-
toolCallResults: new Map(),
|
|
774
|
-
stoppingCallIds: new Set(),
|
|
775
|
-
hostToolBridge,
|
|
776
|
-
abortController,
|
|
777
|
-
intentionalStop: false,
|
|
778
|
-
onDelta: callbacks?.onDelta,
|
|
779
|
-
onToolUse: callbacks?.onToolUse,
|
|
780
|
-
onToolComplete: callbacks?.onToolComplete,
|
|
781
|
-
onSubagentStart: callbacks?.onSubagentStart,
|
|
782
|
-
nativeItems: new Map(),
|
|
783
|
-
resolve: resolveTurn,
|
|
784
|
-
reject: rejectTurn,
|
|
785
|
-
};
|
|
786
|
-
this.turns.set(threadId, pendingTurn);
|
|
787
|
-
this.request('turn/start', {
|
|
788
|
-
threadId,
|
|
789
|
-
input: [{ type: 'text', text, text_elements: [] }],
|
|
790
|
-
}, requestTimeout)
|
|
791
|
-
.then((value) => {
|
|
792
|
-
const turn = validateTurn(object(value)?.turn, 'turn/start turn');
|
|
793
|
-
if (typeof turn?.id !== 'string' || !turn.id) {
|
|
794
|
-
this.failTurn(threadId, new Error('Codex app-server turn/start returned no turn id'));
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
const activeTurn = this.turns.get(threadId);
|
|
798
|
-
if (activeTurn === pendingTurn) {
|
|
799
|
-
activeTurn.turnId = turn.id;
|
|
800
|
-
const queued = activeTurn.queuedNotifications.splice(0);
|
|
801
|
-
for (const notification of queued) {
|
|
802
|
-
this.handleNotification(notification.method, notification.params);
|
|
803
|
-
}
|
|
804
|
-
const queuedToolRequests = activeTurn.queuedToolRequests.splice(0);
|
|
805
|
-
for (const request of queuedToolRequests) {
|
|
806
|
-
this.handleDynamicToolRequest(request, activeTurn);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
else if (this.turnStartReconciliations.has(threadId)) {
|
|
810
|
-
void this.reconcileAcknowledgedTurn(threadId, turn.id, requestTimeout);
|
|
811
|
-
}
|
|
812
|
-
})
|
|
813
|
-
.catch((error) => {
|
|
814
|
-
if (this.turns.get(threadId) === pendingTurn) {
|
|
815
|
-
this.failTurn(threadId, this.toError(error));
|
|
816
|
-
return;
|
|
817
|
-
}
|
|
818
|
-
const reconciliation = this.turnStartReconciliations.get(threadId);
|
|
819
|
-
if (!reconciliation) {
|
|
820
|
-
return;
|
|
821
|
-
}
|
|
822
|
-
if (error instanceof CodexAppServerRpcError) {
|
|
823
|
-
this.completeTurnStartReconciliation(threadId, reconciliation);
|
|
824
|
-
}
|
|
825
|
-
else if (!reconciliation.recoveryTimer) {
|
|
826
|
-
void this.shutdown(this.toError(error)).finally(() => {
|
|
827
|
-
this.completeTurnStartReconciliation(threadId, reconciliation);
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
});
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
async request(method, params, requestTimeout = this.options.requestTimeout) {
|
|
834
|
-
for (let attempt = 0;; attempt++) {
|
|
835
|
-
try {
|
|
836
|
-
return await this.requestOnce(method, params, requestTimeout);
|
|
837
|
-
}
|
|
838
|
-
catch (error) {
|
|
839
|
-
if (!(error instanceof CodexAppServerRpcError) ||
|
|
840
|
-
error.code !== OVERLOADED_ERROR_CODE ||
|
|
841
|
-
attempt >= OVERLOAD_RETRY_LIMIT - 1) {
|
|
842
|
-
throw error;
|
|
843
|
-
}
|
|
844
|
-
const delay = OVERLOAD_RETRY_BASE_MS * 2 ** attempt + Math.floor(Math.random() * 10);
|
|
845
|
-
await new Promise((resolveDelay) => {
|
|
846
|
-
const timer = setTimeout(resolveDelay, delay);
|
|
847
|
-
timer.unref();
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
requestOnce(method, params, requestTimeout) {
|
|
853
|
-
const child = this.child;
|
|
854
|
-
if (!child?.stdin.writable) {
|
|
855
|
-
return Promise.reject(new Error('Codex app-server stdin is not writable'));
|
|
856
|
-
}
|
|
857
|
-
const id = ++this.nextId;
|
|
858
|
-
return new Promise((resolveRequest, rejectRequest) => {
|
|
859
|
-
const timer = setTimeout(() => {
|
|
860
|
-
this.pending.delete(id);
|
|
861
|
-
const error = new Error(`Codex app-server ${method} timed out after ${requestTimeout}ms`);
|
|
862
|
-
const threadId = method === 'turn/start' ? object(params)?.threadId : undefined;
|
|
863
|
-
if (typeof threadId === 'string' && threadId) {
|
|
864
|
-
const reconciliation = this.getOrCreateTurnStartReconciliation(threadId);
|
|
865
|
-
reconciliation.recoveryTimer = setTimeout(() => {
|
|
866
|
-
this.lateTurnStarts.delete(id);
|
|
867
|
-
void this.shutdown(error).finally(() => {
|
|
868
|
-
this.completeTurnStartReconciliation(threadId, reconciliation);
|
|
869
|
-
});
|
|
870
|
-
}, Math.max(requestTimeout, TURN_START_RECONCILE_GRACE_MS));
|
|
871
|
-
reconciliation.recoveryTimer.unref();
|
|
872
|
-
this.lateTurnStarts.set(id, { threadId, requestTimeout, reconciliation });
|
|
873
|
-
rejectRequest(error);
|
|
874
|
-
return;
|
|
875
|
-
}
|
|
876
|
-
rejectRequest(error);
|
|
877
|
-
void this.shutdown(error);
|
|
878
|
-
}, requestTimeout);
|
|
879
|
-
timer.unref();
|
|
880
|
-
this.pending.set(id, { method, timer, resolve: resolveRequest, reject: rejectRequest });
|
|
881
|
-
child.stdin.write(`${JSON.stringify({ jsonrpc: '2.0', id, method, params })}\n`);
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
notify(method, params) {
|
|
885
|
-
if (!this.child?.stdin.writable) {
|
|
886
|
-
throw new Error('Codex app-server stdin is not writable');
|
|
887
|
-
}
|
|
888
|
-
const message = params === undefined ? { jsonrpc: '2.0', method } : { jsonrpc: '2.0', method, params };
|
|
889
|
-
this.child.stdin.write(`${JSON.stringify(message)}\n`);
|
|
890
|
-
}
|
|
891
|
-
handleLine(child, line) {
|
|
892
|
-
if (child !== this.child || !line.trim()) {
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
let message;
|
|
896
|
-
try {
|
|
897
|
-
const parsed = JSON.parse(line);
|
|
898
|
-
const record = object(parsed);
|
|
899
|
-
if (!record) {
|
|
900
|
-
throw new Error('not an object');
|
|
901
|
-
}
|
|
902
|
-
message = record;
|
|
903
|
-
}
|
|
904
|
-
catch {
|
|
905
|
-
const error = new Error('Codex app-server emitted malformed JSON');
|
|
906
|
-
this.failAll(error);
|
|
907
|
-
void this.shutdown(error);
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
// Codex 0.144 accepts JSON-RPC 2.0 requests but omits the `jsonrpc`
|
|
911
|
-
// member from its responses and notifications on the stdio wire.
|
|
912
|
-
if (message.jsonrpc !== undefined && message.jsonrpc !== '2.0') {
|
|
913
|
-
const error = new Error('Codex app-server emitted a malformed protocol message');
|
|
914
|
-
this.failAll(error);
|
|
915
|
-
void this.shutdown(error);
|
|
916
|
-
return;
|
|
917
|
-
}
|
|
918
|
-
const hasMethod = typeof message.method === 'string';
|
|
919
|
-
const hasResult = Object.hasOwn(message, 'result');
|
|
920
|
-
const hasError = Object.hasOwn(message, 'error');
|
|
921
|
-
const hasRequestId = typeof message.id === 'number' || typeof message.id === 'string';
|
|
922
|
-
const serverRequest = hasMethod && hasRequestId && !hasResult && !hasError;
|
|
923
|
-
const notification = hasMethod && !hasRequestId && !hasResult && !hasError;
|
|
924
|
-
const response = !hasMethod && typeof message.id === 'number' && hasResult !== hasError;
|
|
925
|
-
if ([serverRequest, notification, response].filter(Boolean).length !== 1) {
|
|
926
|
-
const error = new Error('Codex app-server emitted a malformed protocol message');
|
|
927
|
-
this.failAll(error);
|
|
928
|
-
void this.shutdown(error);
|
|
929
|
-
return;
|
|
930
|
-
}
|
|
931
|
-
if (typeof message.method === 'string' &&
|
|
932
|
-
(typeof message.id === 'number' || typeof message.id === 'string')) {
|
|
933
|
-
this.handleServerRequest(child, message.id, message.method, message.params);
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
936
|
-
if (typeof message.id === 'number') {
|
|
937
|
-
const lateTurnStart = this.lateTurnStarts.get(message.id);
|
|
938
|
-
if (lateTurnStart) {
|
|
939
|
-
this.handleLateTurnStartResponse(message.id, lateTurnStart, message);
|
|
940
|
-
return;
|
|
941
|
-
}
|
|
942
|
-
const pending = this.pending.get(message.id);
|
|
943
|
-
if (!pending) {
|
|
944
|
-
const error = new Error('Codex app-server response id did not match a pending request');
|
|
945
|
-
this.failAll(error);
|
|
946
|
-
void this.shutdown(error);
|
|
947
|
-
return;
|
|
948
|
-
}
|
|
949
|
-
clearTimeout(pending.timer);
|
|
950
|
-
this.pending.delete(message.id);
|
|
951
|
-
if (message.error !== undefined) {
|
|
952
|
-
const rpcError = object(message.error);
|
|
953
|
-
const code = typeof rpcError?.code === 'number' ? rpcError.code : 0;
|
|
954
|
-
pending.reject(new CodexAppServerRpcError(code, this.redact(errorMessage(message.error, `${pending.method} failed`))));
|
|
955
|
-
}
|
|
956
|
-
else if (!Object.hasOwn(message, 'result')) {
|
|
957
|
-
pending.reject(new Error(`Codex app-server ${pending.method} returned a malformed response`));
|
|
958
|
-
}
|
|
959
|
-
else {
|
|
960
|
-
pending.resolve(message.result);
|
|
961
|
-
}
|
|
962
|
-
return;
|
|
963
|
-
}
|
|
964
|
-
if (typeof message.method === 'string') {
|
|
965
|
-
this.handleNotification(message.method, message.params);
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
handleNotification(method, params) {
|
|
969
|
-
const data = object(params);
|
|
970
|
-
if (!data || typeof data.threadId !== 'string') {
|
|
971
|
-
return;
|
|
972
|
-
}
|
|
973
|
-
if (this.handleSubagentNotification(method, data.threadId, data)) {
|
|
974
|
-
return;
|
|
975
|
-
}
|
|
976
|
-
const turn = this.turns.get(data.threadId);
|
|
977
|
-
if (!turn) {
|
|
978
|
-
return;
|
|
979
|
-
}
|
|
980
|
-
const completedTurn = method === 'turn/completed' ? object(data.turn) : undefined;
|
|
981
|
-
const eventTurnId = typeof data.turnId === 'string'
|
|
982
|
-
? data.turnId
|
|
983
|
-
: typeof completedTurn?.id === 'string'
|
|
984
|
-
? completedTurn.id
|
|
985
|
-
: undefined;
|
|
986
|
-
if (eventTurnId && !turn.turnId) {
|
|
987
|
-
turn.queuedNotifications.push({ method, params });
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
if (eventTurnId && eventTurnId !== turn.turnId) {
|
|
991
|
-
return;
|
|
992
|
-
}
|
|
993
|
-
// TG-03/04/05/06: these notifications observe native effects; they are not
|
|
994
|
-
// pre-execution hooks. Dynamic/MCP calls retain their existing host bridge.
|
|
995
|
-
if (method === 'item/started' || method === 'item/completed') {
|
|
996
|
-
if (typeof data.turnId !== 'string' || data.turnId !== turn.turnId) {
|
|
997
|
-
return;
|
|
998
|
-
}
|
|
999
|
-
const item = object(data.item);
|
|
1000
|
-
if (!item || typeof item.id !== 'string' || typeof item.type !== 'string') {
|
|
1001
|
-
return;
|
|
1002
|
-
}
|
|
1003
|
-
if (!['commandExecution', 'fileChange', 'collabAgentToolCall'].includes(item.type)) {
|
|
1004
|
-
return;
|
|
1005
|
-
}
|
|
1006
|
-
this.refreshTurnIdleTimeout(turn);
|
|
1007
|
-
try {
|
|
1008
|
-
let observed = turn.nativeItems.get(item.id);
|
|
1009
|
-
if (!observed) {
|
|
1010
|
-
observed = { name: item.type, completed: false };
|
|
1011
|
-
turn.nativeItems.set(item.id, observed);
|
|
1012
|
-
// Persist bounded identity only: command bodies and file diffs can contain secrets.
|
|
1013
|
-
turn.onToolUse?.(item.type, { nativeToolUseId: item.id });
|
|
1014
|
-
}
|
|
1015
|
-
if (method === 'item/completed' && !observed.completed) {
|
|
1016
|
-
observed.completed = true;
|
|
1017
|
-
const isError = item.status !== 'completed' ||
|
|
1018
|
-
(typeof item.exitCode === 'number' && item.exitCode !== 0);
|
|
1019
|
-
turn.onToolComplete?.(observed.name, item.id, isError);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
catch (error) {
|
|
1023
|
-
this.failTurn(turn.threadId, this.toError(error));
|
|
1024
|
-
}
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
if (method === 'item/agentMessage/delta') {
|
|
1028
|
-
if (typeof data.turnId !== 'string' || data.turnId !== turn.turnId) {
|
|
1029
|
-
return;
|
|
1030
|
-
}
|
|
1031
|
-
if (typeof data.delta === 'string') {
|
|
1032
|
-
this.refreshTurnIdleTimeout(turn);
|
|
1033
|
-
turn.chunks.push(data.delta);
|
|
1034
|
-
try {
|
|
1035
|
-
turn.onDelta?.(data.delta);
|
|
1036
|
-
}
|
|
1037
|
-
catch (error) {
|
|
1038
|
-
this.failTurn(turn.threadId, this.toError(error));
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
return;
|
|
1042
|
-
}
|
|
1043
|
-
if (method === 'thread/tokenUsage/updated') {
|
|
1044
|
-
if (typeof data.turnId !== 'string' || data.turnId !== turn.turnId) {
|
|
1045
|
-
return;
|
|
1046
|
-
}
|
|
1047
|
-
const tokenUsage = object(data.tokenUsage);
|
|
1048
|
-
const last = object(tokenUsage?.last);
|
|
1049
|
-
const total = object(tokenUsage?.total);
|
|
1050
|
-
this.refreshTurnIdleTimeout(turn);
|
|
1051
|
-
const num = (value) => (typeof value === 'number' ? value : 0);
|
|
1052
|
-
if (total) {
|
|
1053
|
-
// Turn usage = cumulative-thread delta. The baseline derives from the
|
|
1054
|
-
// first total-bearing event (total minus its own call, minus any usage
|
|
1055
|
-
// already accumulated from total-less events this turn), so a resumed
|
|
1056
|
-
// thread's unseen history is never attributed to this turn, and a
|
|
1057
|
-
// multi-call tool-loop turn keeps its earlier calls (recording only
|
|
1058
|
-
// `last` undercounted ~5x against the rollout ground truth).
|
|
1059
|
-
turn.usageBaseline ??= {
|
|
1060
|
-
input: num(total.inputTokens) - num(last?.inputTokens) - turn.usage.input_tokens,
|
|
1061
|
-
output: num(total.outputTokens) - num(last?.outputTokens) - turn.usage.output_tokens,
|
|
1062
|
-
cached: num(total.cachedInputTokens) -
|
|
1063
|
-
num(last?.cachedInputTokens) -
|
|
1064
|
-
(turn.usage.cache_read_input_tokens ?? 0),
|
|
1065
|
-
};
|
|
1066
|
-
// A total below the baseline (compaction/rollback resetting the thread
|
|
1067
|
-
// counter) must never write negative usage into the metrics DB.
|
|
1068
|
-
const input = num(total.inputTokens) - turn.usageBaseline.input;
|
|
1069
|
-
const output = num(total.outputTokens) - turn.usageBaseline.output;
|
|
1070
|
-
const cached = num(total.cachedInputTokens) - turn.usageBaseline.cached;
|
|
1071
|
-
if ((input < 0 || output < 0 || cached < 0) && !turn.usageShrinkWarned) {
|
|
1072
|
-
turn.usageShrinkWarned = true;
|
|
1073
|
-
console.warn('[CodexAppServer] cumulative token total shrank below the turn baseline; clamping usage to 0');
|
|
1074
|
-
}
|
|
1075
|
-
turn.usage = {
|
|
1076
|
-
input_tokens: Math.max(0, input),
|
|
1077
|
-
output_tokens: Math.max(0, output),
|
|
1078
|
-
cache_read_input_tokens: Math.max(0, cached),
|
|
1079
|
-
};
|
|
1080
|
-
this.enforceTurnBudget(turn.threadId, turn);
|
|
1081
|
-
}
|
|
1082
|
-
else {
|
|
1083
|
-
// No cumulative total on this event: accumulate per-call usage.
|
|
1084
|
-
turn.usage = {
|
|
1085
|
-
input_tokens: turn.usage.input_tokens + num(last?.inputTokens),
|
|
1086
|
-
output_tokens: turn.usage.output_tokens + num(last?.outputTokens),
|
|
1087
|
-
cache_read_input_tokens: (turn.usage.cache_read_input_tokens ?? 0) + num(last?.cachedInputTokens),
|
|
1088
|
-
};
|
|
1089
|
-
this.enforceTurnBudget(turn.threadId, turn);
|
|
1090
|
-
}
|
|
1091
|
-
return;
|
|
1092
|
-
}
|
|
1093
|
-
if (method !== 'turn/completed') {
|
|
1094
|
-
return;
|
|
1095
|
-
}
|
|
1096
|
-
const completed = completedTurn;
|
|
1097
|
-
if (!completed ||
|
|
1098
|
-
typeof completed.id !== 'string' ||
|
|
1099
|
-
(turn.turnId && completed.id !== turn.turnId))
|
|
1100
|
-
return;
|
|
1101
|
-
const status = completed.status;
|
|
1102
|
-
if (status === 'inProgress') {
|
|
1103
|
-
return;
|
|
1104
|
-
}
|
|
1105
|
-
try {
|
|
1106
|
-
validateTurn(completed, 'turn/completed turn');
|
|
1107
|
-
}
|
|
1108
|
-
catch (error) {
|
|
1109
|
-
this.failTurn(turn.threadId, this.toError(error));
|
|
1110
|
-
return;
|
|
1111
|
-
}
|
|
1112
|
-
if (turn.abortError) {
|
|
1113
|
-
this.failTurn(turn.threadId, turn.abortError);
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1116
|
-
if (status === 'failed') {
|
|
1117
|
-
this.failTurn(turn.threadId, new Error(this.redact(errorMessage(completed.error, 'Codex app-server turn failed'))));
|
|
1118
|
-
return;
|
|
1119
|
-
}
|
|
1120
|
-
if (status === 'interrupted') {
|
|
1121
|
-
if (turn.abortError) {
|
|
1122
|
-
this.failTurn(turn.threadId, turn.abortError);
|
|
1123
|
-
}
|
|
1124
|
-
else if (turn.intentionalStop) {
|
|
1125
|
-
this.resolveTurn(turn);
|
|
1126
|
-
}
|
|
1127
|
-
else {
|
|
1128
|
-
this.failTurn(turn.threadId, new Error('Codex app-server turn was interrupted'));
|
|
1129
|
-
}
|
|
1130
|
-
return;
|
|
1131
|
-
}
|
|
1132
|
-
if (status !== 'completed') {
|
|
1133
|
-
this.failTurn(turn.threadId, new Error(`Codex app-server returned unknown turn status: ${String(status)}`));
|
|
1134
|
-
return;
|
|
1135
|
-
}
|
|
1136
|
-
this.resolveTurn(turn);
|
|
1137
|
-
}
|
|
1138
|
-
resolveTurn(turn) {
|
|
1139
|
-
if (this.turns.get(turn.threadId) !== turn) {
|
|
1140
|
-
return;
|
|
1141
|
-
}
|
|
1142
|
-
this.turns.delete(turn.threadId);
|
|
1143
|
-
clearTimeout(turn.timer);
|
|
1144
|
-
this.clearTurnCallbacks(turn);
|
|
1145
|
-
turn.resolve({
|
|
1146
|
-
response: turn.chunks.join(''),
|
|
1147
|
-
usage: turn.usage,
|
|
1148
|
-
session_id: turn.threadId,
|
|
1149
|
-
toolUseBlocks: undefined,
|
|
1150
|
-
hasToolUse: false,
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
// ─── Codex-native subagents ───────────────────────────────────────────────
|
|
1154
|
-
//
|
|
1155
|
-
// Codex announces a child on the PARENT thread as a `subAgentActivity` item and then
|
|
1156
|
-
// drives the child on its OWN thread id, which outlives the parent turn. Nothing here
|
|
1157
|
-
// blocks a run. A child NEVER inherits the parent turn's bridge: the parent's envelope
|
|
1158
|
-
// expires with the parent's wall and the child cannot renew it, so a child that
|
|
1159
|
-
// inherited it would lose every tool mid-run and still report "done". The host issues
|
|
1160
|
-
// the child its own authority instead (`createSubagentBridge`), or the child has none
|
|
1161
|
-
// and its calls are refused loudly.
|
|
1162
|
-
/** Returns true when this notification belongs to the subagent surface and was consumed. */
|
|
1163
|
-
handleSubagentNotification(method, threadId, data) {
|
|
1164
|
-
if (method === 'item/started' || method === 'item/completed') {
|
|
1165
|
-
const item = object(data.item);
|
|
1166
|
-
if (item?.type === 'subAgentActivity') {
|
|
1167
|
-
// Only a thread this process actually drives may announce children.
|
|
1168
|
-
if (!this.subagents.has(threadId) && !this.threadContexts.has(threadId)) {
|
|
1169
|
-
return false;
|
|
1170
|
-
}
|
|
1171
|
-
if (item.kind === 'started') {
|
|
1172
|
-
this.registerSubagent(threadId, item);
|
|
1173
|
-
}
|
|
1174
|
-
else if (item.kind === 'completed') {
|
|
1175
|
-
this.observeParentSideCompletion(threadId, item);
|
|
1176
|
-
}
|
|
1177
|
-
return true;
|
|
1178
|
-
}
|
|
1179
|
-
const child = this.subagents.get(threadId);
|
|
1180
|
-
if (!child) {
|
|
1181
|
-
return false;
|
|
1182
|
-
}
|
|
1183
|
-
this.refreshParentTurnIdleTimeout(child);
|
|
1184
|
-
if (method === 'item/completed' &&
|
|
1185
|
-
item?.type === 'agentMessage' &&
|
|
1186
|
-
item.phase === 'final_answer' &&
|
|
1187
|
-
typeof item.text === 'string') {
|
|
1188
|
-
child.finalText = item.text.slice(0, SUBAGENT_FINAL_TEXT_LIMIT);
|
|
1189
|
-
}
|
|
1190
|
-
return true;
|
|
1191
|
-
}
|
|
1192
|
-
const child = this.subagents.get(threadId);
|
|
1193
|
-
if (!child) {
|
|
1194
|
-
return false;
|
|
1195
|
-
}
|
|
1196
|
-
this.refreshParentTurnIdleTimeout(child);
|
|
1197
|
-
if (method !== 'turn/completed') {
|
|
1198
|
-
return true;
|
|
1199
|
-
}
|
|
1200
|
-
const completed = object(data.turn);
|
|
1201
|
-
const status = completed?.status;
|
|
1202
|
-
if (status === 'inProgress') {
|
|
1203
|
-
return true;
|
|
1204
|
-
}
|
|
1205
|
-
if (status !== 'completed' && status !== 'failed' && status !== 'interrupted') {
|
|
1206
|
-
return true;
|
|
1207
|
-
}
|
|
1208
|
-
if (!child.finalText) {
|
|
1209
|
-
child.finalText = this.subagentFinalText(completed?.items);
|
|
1210
|
-
}
|
|
1211
|
-
// The child's OWN turn/completed is the only completing event: the parent-side
|
|
1212
|
-
// announcement carries neither status nor result.
|
|
1213
|
-
this.finishSubagent(threadId, status, status === 'failed'
|
|
1214
|
-
? this.redact(errorMessage(completed?.error, 'Codex app-server subagent turn failed'))
|
|
1215
|
-
: undefined);
|
|
1216
|
-
return true;
|
|
1217
|
-
}
|
|
1218
|
-
subagentFinalText(items) {
|
|
1219
|
-
if (!Array.isArray(items)) {
|
|
1220
|
-
return '';
|
|
1221
|
-
}
|
|
1222
|
-
let text = '';
|
|
1223
|
-
for (const entry of items) {
|
|
1224
|
-
const item = object(entry);
|
|
1225
|
-
if (item?.type === 'agentMessage' && typeof item.text === 'string') {
|
|
1226
|
-
text = item.text;
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
return text.slice(0, SUBAGENT_FINAL_TEXT_LIMIT);
|
|
1230
|
-
}
|
|
1231
|
-
/** A working child keeps the parent's idle timeout alive (the parent may be in wait_agent). */
|
|
1232
|
-
refreshParentTurnIdleTimeout(child) {
|
|
1233
|
-
const parentTurn = this.turns.get(child.parentThreadId);
|
|
1234
|
-
if (parentTurn) {
|
|
1235
|
-
this.refreshTurnIdleTimeout(parentTurn);
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
/** Drop every thread context this session left behind on a previous thread id. */
|
|
1239
|
-
pruneThreadContexts(sessionKey, currentThreadId) {
|
|
1240
|
-
for (const [threadId, context] of this.threadContexts) {
|
|
1241
|
-
if (context.sessionKey === sessionKey && threadId !== currentThreadId) {
|
|
1242
|
-
this.threadContexts.delete(threadId);
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
knownThreadIds() {
|
|
1247
|
-
const ids = new Set(this.threadContexts.keys());
|
|
1248
|
-
for (const state of this.sessions.values()) {
|
|
1249
|
-
if (state.threadId) {
|
|
1250
|
-
ids.add(state.threadId);
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
for (const threadId of this.turns.keys()) {
|
|
1254
|
-
ids.add(threadId);
|
|
1255
|
-
}
|
|
1256
|
-
return ids;
|
|
1257
|
-
}
|
|
1258
|
-
registerSubagent(parentThreadId, item) {
|
|
1259
|
-
const agentThreadId = typeof item.agentThreadId === 'string' ? item.agentThreadId : '';
|
|
1260
|
-
if (!agentThreadId || this.subagents.has(agentThreadId)) {
|
|
1261
|
-
// The same `started` announcement arrives twice (item/started + item/completed views).
|
|
1262
|
-
return;
|
|
1263
|
-
}
|
|
1264
|
-
if (this.finishedSubagents.has(agentThreadId)) {
|
|
1265
|
-
// The second view of that announcement lost the race with the child's own
|
|
1266
|
-
// turn/completed. Re-registering would resurrect a finished child.
|
|
1267
|
-
console.warn(`[CodexAppServer] subagent announcement ignored: thread=${agentThreadId} already finished`);
|
|
1268
|
-
return;
|
|
1269
|
-
}
|
|
1270
|
-
// A child may never claim a thread this process already drives: that would let one
|
|
1271
|
-
// session's announcement capture another session's live parent thread.
|
|
1272
|
-
if (this.knownThreadIds().has(agentThreadId)) {
|
|
1273
|
-
console.warn(`[CodexAppServer] subagent announcement refused: thread=${agentThreadId} is a live thread`);
|
|
1274
|
-
return;
|
|
1275
|
-
}
|
|
1276
|
-
// A grandchild's session comes from the child that announced it.
|
|
1277
|
-
const parent = this.subagents.get(parentThreadId) ?? this.threadContexts.get(parentThreadId);
|
|
1278
|
-
if (!parent) {
|
|
1279
|
-
return;
|
|
1280
|
-
}
|
|
1281
|
-
const agentPath = typeof item.agentPath === 'string' ? item.agentPath : '';
|
|
1282
|
-
// Observed admission: tell the PARENT'S live turn that this run handed work to a
|
|
1283
|
-
// child. Nothing else on the item stream carries that fact - on codex-cli 0.153.4
|
|
1284
|
-
// a spawn surfaces ONLY as `subAgentActivity`, which this handler consumes before
|
|
1285
|
-
// the native-item path. Never routed through onToolUse (effect ledger, see
|
|
1286
|
-
// PromptCallbacks.onSubagentStart).
|
|
1287
|
-
const parentTurn = this.turns.get(parentThreadId);
|
|
1288
|
-
if (parentTurn?.onSubagentStart) {
|
|
1289
|
-
const itemId = typeof item.id === 'string' ? item.id : '';
|
|
1290
|
-
try {
|
|
1291
|
-
parentTurn.onSubagentStart({ agentThreadId, agentPath, itemId });
|
|
1292
|
-
}
|
|
1293
|
-
catch (error) {
|
|
1294
|
-
console.warn(`[CodexAppServer] onSubagentStart callback failed: ${this.toError(error).message}`);
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
const factory = this.options.createSubagentBridge;
|
|
1298
|
-
const child = {
|
|
1299
|
-
parentThreadId,
|
|
1300
|
-
sessionKey: parent.sessionKey,
|
|
1301
|
-
agentPath,
|
|
1302
|
-
onToolUse: parent.onToolUse,
|
|
1303
|
-
onToolComplete: parent.onToolComplete,
|
|
1304
|
-
finalText: '',
|
|
1305
|
-
startedAt: Date.now(),
|
|
1306
|
-
toolCallQueue: Promise.resolve(),
|
|
1307
|
-
toolCallResults: new Map(),
|
|
1308
|
-
stoppingCallIds: new Set(),
|
|
1309
|
-
abortController: new AbortController(),
|
|
1310
|
-
authorityWarned: false,
|
|
1311
|
-
authority: factory
|
|
1312
|
-
? factory({
|
|
1313
|
-
sessionKey: parent.sessionKey,
|
|
1314
|
-
parentThreadId,
|
|
1315
|
-
agentThreadId,
|
|
1316
|
-
agentPath,
|
|
1317
|
-
})
|
|
1318
|
-
.then((authority) => authority ?? null)
|
|
1319
|
-
.catch((error) => {
|
|
1320
|
-
console.warn(`[CodexAppServer] subagent authority factory failed thread=${agentThreadId}: ${this.toError(error).message}`);
|
|
1321
|
-
return null;
|
|
1322
|
-
})
|
|
1323
|
-
: Promise.resolve(null),
|
|
1324
|
-
};
|
|
1325
|
-
child.ttlTimer = setTimeout(() => {
|
|
1326
|
-
child.ttlTimer = undefined;
|
|
1327
|
-
this.finishSubagent(agentThreadId, 'failed', 'subagent produced no completion');
|
|
1328
|
-
}, this.options.subagentTtlMs ?? SUBAGENT_TTL_MS);
|
|
1329
|
-
child.ttlTimer.unref();
|
|
1330
|
-
this.subagents.set(agentThreadId, child);
|
|
1331
|
-
console.log(`[CodexAppServer] subagent started path=${agentPath} thread=${agentThreadId}`);
|
|
1332
|
-
this.emitSubagentEvent({
|
|
1333
|
-
kind: 'started',
|
|
1334
|
-
sessionKey: parent.sessionKey,
|
|
1335
|
-
parentThreadId,
|
|
1336
|
-
agentThreadId,
|
|
1337
|
-
agentPath,
|
|
1338
|
-
});
|
|
1339
|
-
}
|
|
1340
|
-
/**
|
|
1341
|
-
* The parent says a child finished. That is an announcement, not a result: it can win
|
|
1342
|
-
* the race against the child's own `turn/completed`, which is what carries status and
|
|
1343
|
-
* final text. Wait a bounded grace for the real event, then report `unknown`.
|
|
1344
|
-
*/
|
|
1345
|
-
observeParentSideCompletion(announcingThreadId, item) {
|
|
1346
|
-
const agentThreadId = typeof item.agentThreadId === 'string' ? item.agentThreadId : '';
|
|
1347
|
-
const child = agentThreadId ? this.subagents.get(agentThreadId) : undefined;
|
|
1348
|
-
if (!child) {
|
|
1349
|
-
return;
|
|
1350
|
-
}
|
|
1351
|
-
if (child.parentThreadId !== announcingThreadId) {
|
|
1352
|
-
console.warn(`[CodexAppServer] subagent completion refused: thread=${announcingThreadId} does not own ${agentThreadId}`);
|
|
1353
|
-
return;
|
|
1354
|
-
}
|
|
1355
|
-
if (child.graceTimer) {
|
|
1356
|
-
return;
|
|
1357
|
-
}
|
|
1358
|
-
child.graceTimer = setTimeout(() => {
|
|
1359
|
-
child.graceTimer = undefined;
|
|
1360
|
-
console.warn(`[CodexAppServer] subagent completion unconfirmed path=${child.agentPath} thread=${agentThreadId}`);
|
|
1361
|
-
this.finishSubagent(agentThreadId, 'unknown');
|
|
1362
|
-
}, this.options.subagentGraceMs ?? SUBAGENT_COMPLETION_GRACE_MS);
|
|
1363
|
-
child.graceTimer.unref();
|
|
1364
|
-
}
|
|
1365
|
-
/**
|
|
1366
|
-
* Emits exactly one completion per child thread and releases its authority with the
|
|
1367
|
-
* same terminal status. Grandchildren keep their own entries.
|
|
1368
|
-
*/
|
|
1369
|
-
finishSubagent(agentThreadId, status, error) {
|
|
1370
|
-
const child = this.subagents.get(agentThreadId);
|
|
1371
|
-
if (!child) {
|
|
1372
|
-
return;
|
|
1373
|
-
}
|
|
1374
|
-
this.subagents.delete(agentThreadId);
|
|
1375
|
-
this.rememberFinishedSubagent(agentThreadId);
|
|
1376
|
-
this.clearSubagentTimers(child);
|
|
1377
|
-
console.log(`[CodexAppServer] subagent completed status=${status} path=${child.agentPath} thread=${agentThreadId}`);
|
|
1378
|
-
const finalText = child.finalText ? this.redact(child.finalText) : '';
|
|
1379
|
-
this.emitSubagentEvent({
|
|
1380
|
-
kind: 'completed',
|
|
1381
|
-
sessionKey: child.sessionKey,
|
|
1382
|
-
parentThreadId: child.parentThreadId,
|
|
1383
|
-
agentThreadId,
|
|
1384
|
-
agentPath: child.agentPath,
|
|
1385
|
-
status,
|
|
1386
|
-
...(finalText ? { finalText } : {}),
|
|
1387
|
-
...(error ? { error } : {}),
|
|
1388
|
-
});
|
|
1389
|
-
void child.authority
|
|
1390
|
-
.then(async (authority) => {
|
|
1391
|
-
if (!authority) {
|
|
1392
|
-
return;
|
|
1393
|
-
}
|
|
1394
|
-
await authority.release({ status, ...(error ? { error } : {}) });
|
|
1395
|
-
})
|
|
1396
|
-
.catch((releaseError) => {
|
|
1397
|
-
console.warn(`[CodexAppServer] subagent authority release failed thread=${agentThreadId}: ${this.toError(releaseError).message}`);
|
|
1398
|
-
});
|
|
1399
|
-
}
|
|
1400
|
-
/** FIFO-bounded identity of finished children; the oldest id is forgotten first. */
|
|
1401
|
-
rememberFinishedSubagent(agentThreadId) {
|
|
1402
|
-
this.finishedSubagents.add(agentThreadId);
|
|
1403
|
-
while (this.finishedSubagents.size > MAX_FINISHED_SUBAGENTS) {
|
|
1404
|
-
const oldest = this.finishedSubagents.values().next().value;
|
|
1405
|
-
if (oldest === undefined) {
|
|
1406
|
-
return;
|
|
1407
|
-
}
|
|
1408
|
-
this.finishedSubagents.delete(oldest);
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
clearSubagentTimers(child) {
|
|
1412
|
-
if (child.ttlTimer) {
|
|
1413
|
-
clearTimeout(child.ttlTimer);
|
|
1414
|
-
child.ttlTimer = undefined;
|
|
1415
|
-
}
|
|
1416
|
-
if (child.graceTimer) {
|
|
1417
|
-
clearTimeout(child.graceTimer);
|
|
1418
|
-
child.graceTimer = undefined;
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
emitSubagentEvent(event) {
|
|
1422
|
-
const emit = this.options.onSubagentEvent;
|
|
1423
|
-
if (!emit) {
|
|
1424
|
-
return;
|
|
1425
|
-
}
|
|
1426
|
-
try {
|
|
1427
|
-
emit(event);
|
|
1428
|
-
}
|
|
1429
|
-
catch (error) {
|
|
1430
|
-
console.warn(`[CodexAppServer] subagent event listener failed: ${this.toError(error).message}`);
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
/** Every live child is reported interrupted and its authority released. */
|
|
1434
|
-
terminateSubagents(reason) {
|
|
1435
|
-
const safe = this.toError(reason);
|
|
1436
|
-
for (const agentThreadId of [...this.subagents.keys()]) {
|
|
1437
|
-
const child = this.subagents.get(agentThreadId);
|
|
1438
|
-
if (!child) {
|
|
1439
|
-
continue;
|
|
1440
|
-
}
|
|
1441
|
-
child.abortController.abort(safe);
|
|
1442
|
-
this.finishSubagent(agentThreadId, 'interrupted', safe.message);
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
/** A reset/restart drops the thread's context and interrupts its children. */
|
|
1446
|
-
discardSessionThreadState(sessionKey, reason) {
|
|
1447
|
-
const threadId = this.sessions.get(sessionKey)?.threadId;
|
|
1448
|
-
if (threadId) {
|
|
1449
|
-
this.threadContexts.delete(threadId);
|
|
1450
|
-
}
|
|
1451
|
-
for (const agentThreadId of [...this.subagents.keys()]) {
|
|
1452
|
-
const child = this.subagents.get(agentThreadId);
|
|
1453
|
-
if (!child || child.sessionKey !== sessionKey) {
|
|
1454
|
-
continue;
|
|
1455
|
-
}
|
|
1456
|
-
child.abortController.abort(new Error(`Codex app-server ${reason}`));
|
|
1457
|
-
this.finishSubagent(agentThreadId, 'interrupted', reason);
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
handleSubagentToolRequest(request, agentThreadId, child, data) {
|
|
1461
|
-
this.refreshParentTurnIdleTimeout(child);
|
|
1462
|
-
// The child's authority is host-issued and asynchronous; its calls queue until it
|
|
1463
|
-
// resolves rather than falling back to anything the parent held.
|
|
1464
|
-
void child.authority.then((authority) => {
|
|
1465
|
-
try {
|
|
1466
|
-
const turnId = this.requiredToolString(data, 'turnId');
|
|
1467
|
-
const callId = this.requiredToolString(data, 'callId');
|
|
1468
|
-
const tool = this.requiredToolString(data, 'tool');
|
|
1469
|
-
if (data.namespace !== null && typeof data.namespace !== 'string') {
|
|
1470
|
-
throw new Error('Codex app-server tool call namespace must be null or a string');
|
|
1471
|
-
}
|
|
1472
|
-
const input = object(data.arguments);
|
|
1473
|
-
if (!input) {
|
|
1474
|
-
throw new Error('Codex app-server tool call arguments must be an object');
|
|
1475
|
-
}
|
|
1476
|
-
if (!authority) {
|
|
1477
|
-
if (!child.authorityWarned) {
|
|
1478
|
-
child.authorityWarned = true;
|
|
1479
|
-
console.warn(`[CodexAppServer] ${SUBAGENT_AUTHORITY_UNAVAILABLE} path=${child.agentPath} thread=${agentThreadId}`);
|
|
1480
|
-
}
|
|
1481
|
-
this.replyToolError(request, `${SUBAGENT_AUTHORITY_UNAVAILABLE}: ${tool} was refused`);
|
|
1482
|
-
return;
|
|
1483
|
-
}
|
|
1484
|
-
const bridge = authority.bridge;
|
|
1485
|
-
if (!bridge.tools.some((definition) => definition.name === tool)) {
|
|
1486
|
-
throw new Error(`Codex app-server tool call ${tool} was not advertised`);
|
|
1487
|
-
}
|
|
1488
|
-
this.dispatchSubagentToolCall(request, agentThreadId, child, bridge, {
|
|
1489
|
-
turnId,
|
|
1490
|
-
callId,
|
|
1491
|
-
tool,
|
|
1492
|
-
namespace: data.namespace ?? null,
|
|
1493
|
-
input,
|
|
1494
|
-
});
|
|
1495
|
-
}
|
|
1496
|
-
catch (error) {
|
|
1497
|
-
// A child's protocol error is reported to the child only: the parent turn it was
|
|
1498
|
-
// spawned from may already have resolved, and there is nothing here to fail.
|
|
1499
|
-
this.replyToolError(request, this.toError(error).message);
|
|
1500
|
-
}
|
|
1501
|
-
});
|
|
1502
|
-
}
|
|
1503
|
-
dispatchSubagentToolCall(request, agentThreadId, child, bridge, call) {
|
|
1504
|
-
const { turnId, callId, tool, namespace, input } = call;
|
|
1505
|
-
const identity = JSON.stringify(stableJson({ threadId: agentThreadId, turnId, tool, namespace, arguments: input }));
|
|
1506
|
-
const existing = child.toolCallResults.get(callId);
|
|
1507
|
-
if (existing && existing.identity !== identity) {
|
|
1508
|
-
throw new Error(`Codex app-server callId ${callId} had a conflicting request`);
|
|
1509
|
-
}
|
|
1510
|
-
let execution = existing?.execution;
|
|
1511
|
-
if (!execution) {
|
|
1512
|
-
execution = child.toolCallQueue
|
|
1513
|
-
.then(async () => {
|
|
1514
|
-
if (!this.isSubagentToolActive(request, agentThreadId, child)) {
|
|
1515
|
-
return {
|
|
1516
|
-
result: this.toolResult(false, 'Codex app-server tool call is no longer active'),
|
|
1517
|
-
stop: false,
|
|
1518
|
-
abortError: undefined,
|
|
1519
|
-
};
|
|
1520
|
-
}
|
|
1521
|
-
try {
|
|
1522
|
-
child.onToolUse?.(tool, {
|
|
1523
|
-
nativeToolUseId: callId,
|
|
1524
|
-
subagentThreadId: agentThreadId,
|
|
1525
|
-
agentPath: child.agentPath,
|
|
1526
|
-
});
|
|
1527
|
-
}
|
|
1528
|
-
catch (error) {
|
|
1529
|
-
console.warn(`[CodexAppServer] subagent onToolUse failed: ${this.toError(error).message}`);
|
|
1530
|
-
}
|
|
1531
|
-
let result;
|
|
1532
|
-
try {
|
|
1533
|
-
result = await bridge.execute({
|
|
1534
|
-
callId,
|
|
1535
|
-
name: tool,
|
|
1536
|
-
input,
|
|
1537
|
-
signal: child.abortController.signal,
|
|
1538
|
-
});
|
|
1539
|
-
}
|
|
1540
|
-
catch (error) {
|
|
1541
|
-
result = { content: this.toError(error).message, isError: true };
|
|
1542
|
-
}
|
|
1543
|
-
const resultData = object(result);
|
|
1544
|
-
if (!resultData ||
|
|
1545
|
-
typeof resultData.content !== 'string' ||
|
|
1546
|
-
typeof resultData.isError !== 'boolean') {
|
|
1547
|
-
this.reportSubagentToolComplete(child, tool, callId, true);
|
|
1548
|
-
return {
|
|
1549
|
-
result: this.toolResult(false, 'Host tool returned a malformed result'),
|
|
1550
|
-
stop: false,
|
|
1551
|
-
abortError: undefined,
|
|
1552
|
-
};
|
|
1553
|
-
}
|
|
1554
|
-
this.reportSubagentToolComplete(child, tool, callId, resultData.isError);
|
|
1555
|
-
if (resultData.isError && resultData.content.includes(ENVELOPE_EXPIRED_MARKER)) {
|
|
1556
|
-
// Expired authority is named, never silently downgraded to a plain failure:
|
|
1557
|
-
// a child whose grant ran out must not read as work that merely did not apply.
|
|
1558
|
-
return {
|
|
1559
|
-
result: this.toolResult(false, `${SUBAGENT_AUTHORITY_EXPIRED}: ${resultData.content}`),
|
|
1560
|
-
stop: false,
|
|
1561
|
-
abortError: undefined,
|
|
1562
|
-
};
|
|
1563
|
-
}
|
|
1564
|
-
return {
|
|
1565
|
-
result: this.toolResult(!resultData.isError, resultData.content),
|
|
1566
|
-
stop: resultData.stop === true || resultData.abort === true,
|
|
1567
|
-
abortError: undefined,
|
|
1568
|
-
};
|
|
1569
|
-
})
|
|
1570
|
-
.catch((error) => ({
|
|
1571
|
-
result: this.toolResult(false, this.toError(error).message),
|
|
1572
|
-
stop: false,
|
|
1573
|
-
abortError: undefined,
|
|
1574
|
-
}));
|
|
1575
|
-
child.toolCallResults.set(callId, { identity, execution });
|
|
1576
|
-
child.toolCallQueue = execution.then(() => undefined, () => undefined);
|
|
1577
|
-
}
|
|
1578
|
-
void execution.then(({ result, stop }) => {
|
|
1579
|
-
if (!this.isSubagentToolActive(request, agentThreadId, child)) {
|
|
1580
|
-
if (this.child === request.child) {
|
|
1581
|
-
this.replyToolError(request, 'Codex app-server tool call is no longer active');
|
|
1582
|
-
}
|
|
1583
|
-
return;
|
|
1584
|
-
}
|
|
1585
|
-
this.reply(request.child, { jsonrpc: '2.0', id: request.id, result });
|
|
1586
|
-
if (stop && !child.stoppingCallIds.has(callId)) {
|
|
1587
|
-
child.stoppingCallIds.add(callId);
|
|
1588
|
-
child.abortController.abort(new Error('Codex app-server subagent tool stopped the run'));
|
|
1589
|
-
void this.request('turn/interrupt', { threadId: agentThreadId, turnId }).catch((error) => console.warn(`[CodexAppServer] subagent interrupt failed: ${this.toError(error).message}`));
|
|
1590
|
-
}
|
|
1591
|
-
});
|
|
1592
|
-
}
|
|
1593
|
-
reportSubagentToolComplete(child, tool, callId, isError) {
|
|
1594
|
-
try {
|
|
1595
|
-
child.onToolComplete?.(tool, callId, isError);
|
|
1596
|
-
}
|
|
1597
|
-
catch (error) {
|
|
1598
|
-
console.warn(`[CodexAppServer] subagent onToolComplete failed: ${this.toError(error).message}`);
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
isSubagentToolActive(request, agentThreadId, child) {
|
|
1602
|
-
return (this.child === request.child &&
|
|
1603
|
-
this.subagents.get(agentThreadId) === child &&
|
|
1604
|
-
!child.abortController.signal.aborted);
|
|
1605
|
-
}
|
|
1606
|
-
handleServerRequest(child, id, method, params) {
|
|
1607
|
-
if (method === 'item/tool/call') {
|
|
1608
|
-
this.handleDynamicToolRequest({ child, id, params });
|
|
1609
|
-
return;
|
|
1610
|
-
}
|
|
1611
|
-
const bodies = {
|
|
1612
|
-
'item/tool/requestUserInput': { answers: {} },
|
|
1613
|
-
'mcpServer/elicitation/request': { action: 'decline', content: null, _meta: null },
|
|
1614
|
-
'item/commandExecution/requestApproval': { decision: 'decline' },
|
|
1615
|
-
'item/fileChange/requestApproval': { decision: 'decline' },
|
|
1616
|
-
'item/permissions/requestApproval': {
|
|
1617
|
-
permissions: {},
|
|
1618
|
-
scope: 'turn',
|
|
1619
|
-
strictAutoReview: true,
|
|
1620
|
-
},
|
|
1621
|
-
applyPatchApproval: { decision: 'denied' },
|
|
1622
|
-
execCommandApproval: { decision: 'denied' },
|
|
1623
|
-
};
|
|
1624
|
-
if (Object.hasOwn(bodies, method)) {
|
|
1625
|
-
this.reply(child, { jsonrpc: '2.0', id, result: bodies[method] });
|
|
1626
|
-
}
|
|
1627
|
-
else {
|
|
1628
|
-
this.reply(child, {
|
|
1629
|
-
jsonrpc: '2.0',
|
|
1630
|
-
id,
|
|
1631
|
-
error: { code: -32601, message: `Unsupported app-server request: ${method}` },
|
|
1632
|
-
});
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
handleDynamicToolRequest(request, expectedTurn) {
|
|
1636
|
-
const data = object(request.params);
|
|
1637
|
-
const threadId = typeof data?.threadId === 'string' ? data.threadId : undefined;
|
|
1638
|
-
const turn = threadId ? this.turns.get(threadId) : undefined;
|
|
1639
|
-
if (data && threadId && !turn && !expectedTurn) {
|
|
1640
|
-
// A Codex-native child calls on ITS OWN thread id, which never holds a PendingTurn.
|
|
1641
|
-
const child = this.subagents.get(threadId);
|
|
1642
|
-
if (child) {
|
|
1643
|
-
this.handleSubagentToolRequest(request, threadId, child, data);
|
|
1644
|
-
return;
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
if (!data || !turn || !turn.hostToolBridge || (expectedTurn && turn !== expectedTurn)) {
|
|
1648
|
-
this.replyDisabledTool(request);
|
|
1649
|
-
return;
|
|
1650
|
-
}
|
|
1651
|
-
try {
|
|
1652
|
-
const turnId = this.requiredToolString(data, 'turnId');
|
|
1653
|
-
const callId = this.requiredToolString(data, 'callId');
|
|
1654
|
-
const tool = this.requiredToolString(data, 'tool');
|
|
1655
|
-
if (data.namespace !== null && typeof data.namespace !== 'string') {
|
|
1656
|
-
throw new Error('Codex app-server tool call namespace must be null or a string');
|
|
1657
|
-
}
|
|
1658
|
-
const input = object(data.arguments);
|
|
1659
|
-
if (!input) {
|
|
1660
|
-
throw new Error('Codex app-server tool call arguments must be an object');
|
|
1661
|
-
}
|
|
1662
|
-
if (!turn.hostToolBridge.tools.some((definition) => definition.name === tool)) {
|
|
1663
|
-
throw new Error(`Codex app-server tool call ${tool} was not advertised`);
|
|
1664
|
-
}
|
|
1665
|
-
if (!turn.turnId) {
|
|
1666
|
-
turn.queuedToolRequests.push(request);
|
|
1667
|
-
return;
|
|
1668
|
-
}
|
|
1669
|
-
if (turnId !== turn.turnId) {
|
|
1670
|
-
this.failToolProtocol(request, turn, new Error('Codex app-server tool call did not match the active turn'));
|
|
1671
|
-
return;
|
|
1672
|
-
}
|
|
1673
|
-
this.refreshTurnIdleTimeout(turn);
|
|
1674
|
-
this.dispatchDynamicToolCall(request, turn, callId, tool, data.namespace, input);
|
|
1675
|
-
}
|
|
1676
|
-
catch (error) {
|
|
1677
|
-
this.failToolProtocol(request, turn, this.toError(error));
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
failToolProtocol(request, turn, error) {
|
|
1681
|
-
const failure = this.toError(error);
|
|
1682
|
-
this.replyToolError(request, failure.message);
|
|
1683
|
-
this.failTurn(turn.threadId, failure);
|
|
1684
|
-
if (this.child === request.child && !this.shutdownPromise) {
|
|
1685
|
-
void this.shutdown(failure);
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
requiredToolString(data, field) {
|
|
1689
|
-
const value = data[field];
|
|
1690
|
-
if (typeof value !== 'string' || !value) {
|
|
1691
|
-
throw new Error(`Codex app-server tool call ${field} must be a string`);
|
|
1692
|
-
}
|
|
1693
|
-
return value;
|
|
1694
|
-
}
|
|
1695
|
-
dispatchDynamicToolCall(request, turn, callId, tool, namespace, input) {
|
|
1696
|
-
const identity = JSON.stringify(stableJson({
|
|
1697
|
-
threadId: turn.threadId,
|
|
1698
|
-
turnId: turn.turnId,
|
|
1699
|
-
tool,
|
|
1700
|
-
namespace,
|
|
1701
|
-
arguments: input,
|
|
1702
|
-
}));
|
|
1703
|
-
const existing = turn.toolCallResults.get(callId);
|
|
1704
|
-
if (existing && existing.identity !== identity) {
|
|
1705
|
-
throw new Error(`Codex app-server callId ${callId} had a conflicting request`);
|
|
1706
|
-
}
|
|
1707
|
-
let execution = existing?.execution;
|
|
1708
|
-
if (!execution) {
|
|
1709
|
-
const bridge = turn.hostToolBridge;
|
|
1710
|
-
if (!bridge) {
|
|
1711
|
-
this.replyDisabledTool(request);
|
|
1712
|
-
return;
|
|
1713
|
-
}
|
|
1714
|
-
execution = turn.toolCallQueue
|
|
1715
|
-
.then(async () => {
|
|
1716
|
-
if (!this.isToolTurnActive(request, turn)) {
|
|
1717
|
-
return {
|
|
1718
|
-
result: this.toolResult(false, 'Codex app-server tool call is no longer active'),
|
|
1719
|
-
stop: false,
|
|
1720
|
-
abortError: undefined,
|
|
1721
|
-
};
|
|
1722
|
-
}
|
|
1723
|
-
let result;
|
|
1724
|
-
try {
|
|
1725
|
-
result = await bridge.execute({
|
|
1726
|
-
callId,
|
|
1727
|
-
name: tool,
|
|
1728
|
-
input,
|
|
1729
|
-
signal: turn.abortController.signal,
|
|
1730
|
-
});
|
|
1731
|
-
}
|
|
1732
|
-
catch (error) {
|
|
1733
|
-
result = { content: this.toError(error).message, isError: true };
|
|
1734
|
-
}
|
|
1735
|
-
const resultData = object(result);
|
|
1736
|
-
if (!resultData ||
|
|
1737
|
-
typeof resultData.content !== 'string' ||
|
|
1738
|
-
typeof resultData.isError !== 'boolean') {
|
|
1739
|
-
return {
|
|
1740
|
-
result: this.toolResult(false, 'Host tool returned a malformed result'),
|
|
1741
|
-
stop: false,
|
|
1742
|
-
abortError: undefined,
|
|
1743
|
-
};
|
|
1744
|
-
}
|
|
1745
|
-
const abortError = resultData.abort === true && resultData.isError
|
|
1746
|
-
? (0, model_runner_js_1.isHostToolTerminalCode)(resultData.terminalCode)
|
|
1747
|
-
? new model_runner_js_1.HostToolTerminalError(resultData.terminalCode, resultData.content)
|
|
1748
|
-
: new Error(resultData.content)
|
|
1749
|
-
: undefined;
|
|
1750
|
-
if (abortError instanceof model_runner_js_1.HostToolTerminalError) {
|
|
1751
|
-
turn.settledTerminalError ??= abortError;
|
|
1752
|
-
}
|
|
1753
|
-
return {
|
|
1754
|
-
result: this.toolResult(!resultData.isError, resultData.content),
|
|
1755
|
-
stop: resultData.stop === true && !resultData.isError,
|
|
1756
|
-
abortError,
|
|
1757
|
-
};
|
|
1758
|
-
})
|
|
1759
|
-
.catch((error) => ({
|
|
1760
|
-
result: this.toolResult(false, this.toError(error).message),
|
|
1761
|
-
stop: false,
|
|
1762
|
-
abortError: undefined,
|
|
1763
|
-
}));
|
|
1764
|
-
turn.toolCallResults.set(callId, { identity, execution });
|
|
1765
|
-
turn.toolCallQueue = execution.then(() => undefined, () => undefined);
|
|
1766
|
-
}
|
|
1767
|
-
void execution.then(({ result, stop, abortError }) => {
|
|
1768
|
-
if (!this.isToolTurnActive(request, turn)) {
|
|
1769
|
-
if (this.child === request.child) {
|
|
1770
|
-
this.replyToolError(request, 'Codex app-server tool call is no longer active');
|
|
1771
|
-
}
|
|
1772
|
-
return;
|
|
1773
|
-
}
|
|
1774
|
-
this.refreshTurnIdleTimeout(turn);
|
|
1775
|
-
this.reply(request.child, { jsonrpc: '2.0', id: request.id, result });
|
|
1776
|
-
if (abortError && !turn.stoppingCallIds.has(callId)) {
|
|
1777
|
-
turn.stoppingCallIds.add(callId);
|
|
1778
|
-
turn.abortError = abortError;
|
|
1779
|
-
void this.request('turn/interrupt', { threadId: turn.threadId, turnId: turn.turnId }).catch((error) => this.failTurn(turn.threadId, this.toError(error)));
|
|
1780
|
-
}
|
|
1781
|
-
else if (stop && !turn.stoppingCallIds.has(callId)) {
|
|
1782
|
-
turn.stoppingCallIds.add(callId);
|
|
1783
|
-
turn.intentionalStop = true;
|
|
1784
|
-
void this.request('turn/interrupt', { threadId: turn.threadId, turnId: turn.turnId }).catch((error) => this.failTurn(turn.threadId, this.toError(error)));
|
|
1785
|
-
}
|
|
1786
|
-
});
|
|
1787
|
-
}
|
|
1788
|
-
isToolTurnActive(request, turn) {
|
|
1789
|
-
return (this.child === request.child &&
|
|
1790
|
-
this.turns.get(turn.threadId) === turn &&
|
|
1791
|
-
!turn.intentionalStop &&
|
|
1792
|
-
!turn.abortError &&
|
|
1793
|
-
!turn.abortController.signal.aborted);
|
|
1794
|
-
}
|
|
1795
|
-
toolResult(success, content) {
|
|
1796
|
-
return { success, contentItems: [{ type: 'inputText', text: content }] };
|
|
1797
|
-
}
|
|
1798
|
-
replyDisabledTool(request) {
|
|
1799
|
-
this.reply(request.child, {
|
|
1800
|
-
jsonrpc: '2.0',
|
|
1801
|
-
id: request.id,
|
|
1802
|
-
result: this.toolResult(false, 'Native app-server tools are disabled by MAMA'),
|
|
1803
|
-
});
|
|
1804
|
-
}
|
|
1805
|
-
replyToolError(request, message) {
|
|
1806
|
-
this.reply(request.child, {
|
|
1807
|
-
jsonrpc: '2.0',
|
|
1808
|
-
id: request.id,
|
|
1809
|
-
error: { code: -32602, message },
|
|
1810
|
-
});
|
|
1811
|
-
}
|
|
1812
|
-
reply(child, message) {
|
|
1813
|
-
if (child.stdin.writable) {
|
|
1814
|
-
child.stdin.write(`${JSON.stringify(message)}\n`);
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
handleStderr(line) {
|
|
1818
|
-
this.stderrTail = `${this.stderrTail}${this.redact(line)}\n`.slice(-STDERR_LIMIT);
|
|
1819
|
-
}
|
|
1820
|
-
redact(value) {
|
|
1821
|
-
let result = value;
|
|
1822
|
-
for (const secret of this.secrets) {
|
|
1823
|
-
result = result.split(secret).join('[REDACTED]');
|
|
1824
|
-
}
|
|
1825
|
-
return result;
|
|
1826
|
-
}
|
|
1827
|
-
toError(error) {
|
|
1828
|
-
if (error instanceof model_runner_js_1.HostToolTerminalError) {
|
|
1829
|
-
return new model_runner_js_1.HostToolTerminalError(error.terminalCode, this.redact(error.message));
|
|
1830
|
-
}
|
|
1831
|
-
return error instanceof Error
|
|
1832
|
-
? new Error(this.redact(error.message))
|
|
1833
|
-
: new Error(this.redact(String(error)));
|
|
1834
|
-
}
|
|
1835
|
-
refreshTurnIdleTimeout(turn) {
|
|
1836
|
-
if (this.turns.get(turn.threadId) !== turn) {
|
|
1837
|
-
return;
|
|
1838
|
-
}
|
|
1839
|
-
clearTimeout(turn.timer);
|
|
1840
|
-
turn.timer = setTimeout(() => {
|
|
1841
|
-
const error = new Error(`Codex app-server turn timed out after ${turn.requestTimeout}ms without progress`);
|
|
1842
|
-
this.timeoutTurn(turn.threadId, error, turn.requestTimeout);
|
|
1843
|
-
}, turn.requestTimeout);
|
|
1844
|
-
turn.timer.unref();
|
|
1845
|
-
}
|
|
1846
|
-
failTurn(threadId, error) {
|
|
1847
|
-
const turn = this.turns.get(threadId);
|
|
1848
|
-
if (!turn) {
|
|
1849
|
-
return;
|
|
1850
|
-
}
|
|
1851
|
-
this.turns.delete(threadId);
|
|
1852
|
-
clearTimeout(turn.timer);
|
|
1853
|
-
turn.abortController.abort(error);
|
|
1854
|
-
turn.queuedNotifications.length = 0;
|
|
1855
|
-
turn.queuedToolRequests.length = 0;
|
|
1856
|
-
const safe = this.toError(error);
|
|
1857
|
-
// A gateway mutation that cannot be interrupted must settle before the
|
|
1858
|
-
// caller sees failure. This prevents retries from racing a late mutation.
|
|
1859
|
-
void turn.toolCallQueue.finally(() => {
|
|
1860
|
-
this.clearTurnCallbacks(turn);
|
|
1861
|
-
const terminalError = turn.settledTerminalError ??
|
|
1862
|
-
(turn.abortError instanceof model_runner_js_1.HostToolTerminalError ? turn.abortError : undefined);
|
|
1863
|
-
turn.reject(this.toError(terminalError ?? safe));
|
|
1864
|
-
});
|
|
1865
|
-
}
|
|
1866
|
-
/** Interrupt a turn whose counted usage crossed its run budget; the loop reports stoppedBy. */
|
|
1867
|
-
enforceTurnBudget(threadId, turn) {
|
|
1868
|
-
const budget = turn.runTokenBudget ?? 0;
|
|
1869
|
-
if (budget <= 0 || turn.budgetStopped) {
|
|
1870
|
-
return;
|
|
1871
|
-
}
|
|
1872
|
-
// Codex reports inputTokens INCLUSIVE of cachedInputTokens (OpenAI usage semantics),
|
|
1873
|
-
// so cached is not added again: 0.44.0 counted a 2.8M wiki turn as 5.5M.
|
|
1874
|
-
const counted = turn.usage.input_tokens + turn.usage.output_tokens;
|
|
1875
|
-
if (counted < budget) {
|
|
1876
|
-
return;
|
|
1877
|
-
}
|
|
1878
|
-
turn.budgetStopped = true;
|
|
1879
|
-
const error = new Error(`run budget stop: ${counted} >= ${budget} counted tokens inside one turn`);
|
|
1880
|
-
error.code = 'RUN_BUDGET_STOP';
|
|
1881
|
-
// The interrupted turn's usage rides on the error: the loop's success path never
|
|
1882
|
-
// runs for it, and the most expensive run of the day must not count as zero.
|
|
1883
|
-
error.usage = { ...turn.usage };
|
|
1884
|
-
this.timeoutTurn(threadId, error, DEFAULT_TIMEOUT);
|
|
1885
|
-
}
|
|
1886
|
-
timeoutTurn(threadId, error, requestTimeout) {
|
|
1887
|
-
const turn = this.turns.get(threadId);
|
|
1888
|
-
if (!turn) {
|
|
1889
|
-
return;
|
|
1890
|
-
}
|
|
1891
|
-
const turnId = turn.turnId;
|
|
1892
|
-
if (!turnId) {
|
|
1893
|
-
this.getOrCreateTurnStartReconciliation(threadId);
|
|
1894
|
-
}
|
|
1895
|
-
this.failTurn(threadId, error);
|
|
1896
|
-
if (!turnId) {
|
|
1897
|
-
return;
|
|
1898
|
-
}
|
|
1899
|
-
void this.request('turn/interrupt', { threadId, turnId }, requestTimeout).catch((interruptError) => {
|
|
1900
|
-
if (this.child && !this.shutdownPromise) {
|
|
1901
|
-
void this.shutdown(this.toError(interruptError));
|
|
1902
|
-
}
|
|
1903
|
-
});
|
|
1904
|
-
}
|
|
1905
|
-
getOrCreateTurnStartReconciliation(threadId) {
|
|
1906
|
-
const existing = this.turnStartReconciliations.get(threadId);
|
|
1907
|
-
if (existing) {
|
|
1908
|
-
return existing;
|
|
1909
|
-
}
|
|
1910
|
-
let resolveReconciliation;
|
|
1911
|
-
const promise = new Promise((resolvePromise) => {
|
|
1912
|
-
resolveReconciliation = resolvePromise;
|
|
1913
|
-
});
|
|
1914
|
-
const reconciliation = {
|
|
1915
|
-
promise,
|
|
1916
|
-
resolve: () => resolveReconciliation?.(),
|
|
1917
|
-
};
|
|
1918
|
-
this.turnStartReconciliations.set(threadId, reconciliation);
|
|
1919
|
-
return reconciliation;
|
|
1920
|
-
}
|
|
1921
|
-
completeTurnStartReconciliation(threadId, reconciliation) {
|
|
1922
|
-
if (this.turnStartReconciliations.get(threadId) !== reconciliation) {
|
|
1923
|
-
return;
|
|
1924
|
-
}
|
|
1925
|
-
if (reconciliation.recoveryTimer) {
|
|
1926
|
-
clearTimeout(reconciliation.recoveryTimer);
|
|
1927
|
-
reconciliation.recoveryTimer = undefined;
|
|
1928
|
-
}
|
|
1929
|
-
this.turnStartReconciliations.delete(threadId);
|
|
1930
|
-
reconciliation.resolve();
|
|
1931
|
-
}
|
|
1932
|
-
async reconcileAcknowledgedTurn(threadId, turnId, requestTimeout) {
|
|
1933
|
-
const reconciliation = this.turnStartReconciliations.get(threadId);
|
|
1934
|
-
if (!reconciliation) {
|
|
1935
|
-
return;
|
|
1936
|
-
}
|
|
1937
|
-
try {
|
|
1938
|
-
await this.request('turn/interrupt', { threadId, turnId }, requestTimeout);
|
|
1939
|
-
this.completeTurnStartReconciliation(threadId, reconciliation);
|
|
1940
|
-
}
|
|
1941
|
-
catch (error) {
|
|
1942
|
-
await this.shutdown(this.toError(error));
|
|
1943
|
-
this.completeTurnStartReconciliation(threadId, reconciliation);
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
handleLateTurnStartResponse(id, late, message) {
|
|
1947
|
-
this.lateTurnStarts.delete(id);
|
|
1948
|
-
if (late.reconciliation.recoveryTimer) {
|
|
1949
|
-
clearTimeout(late.reconciliation.recoveryTimer);
|
|
1950
|
-
late.reconciliation.recoveryTimer = undefined;
|
|
1951
|
-
}
|
|
1952
|
-
if (message.error !== undefined) {
|
|
1953
|
-
this.completeTurnStartReconciliation(late.threadId, late.reconciliation);
|
|
1954
|
-
return;
|
|
1955
|
-
}
|
|
1956
|
-
try {
|
|
1957
|
-
const turn = validateTurn(object(message.result)?.turn, 'late turn/start turn');
|
|
1958
|
-
if (typeof turn?.id !== 'string' || !turn.id) {
|
|
1959
|
-
throw new Error('Codex app-server late turn/start returned no turn id');
|
|
1960
|
-
}
|
|
1961
|
-
void this.reconcileAcknowledgedTurn(late.threadId, turn.id, late.requestTimeout);
|
|
1962
|
-
}
|
|
1963
|
-
catch (error) {
|
|
1964
|
-
void this.shutdown(this.toError(error)).finally(() => {
|
|
1965
|
-
this.completeTurnStartReconciliation(late.threadId, late.reconciliation);
|
|
1966
|
-
});
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
clearTurnCallbacks(turn) {
|
|
1970
|
-
turn.queuedNotifications.length = 0;
|
|
1971
|
-
turn.queuedToolRequests.length = 0;
|
|
1972
|
-
turn.toolCallResults.clear();
|
|
1973
|
-
turn.stoppingCallIds.clear();
|
|
1974
|
-
turn.hostToolBridge = undefined;
|
|
1975
|
-
turn.onDelta = undefined;
|
|
1976
|
-
}
|
|
1977
|
-
failAll(error) {
|
|
1978
|
-
const safe = this.toError(error);
|
|
1979
|
-
// Pending child tool calls abort exactly like a parent turn's.
|
|
1980
|
-
for (const child of this.subagents.values()) {
|
|
1981
|
-
child.abortController.abort(safe);
|
|
1982
|
-
}
|
|
1983
|
-
for (const threadId of [...this.turns.keys()]) {
|
|
1984
|
-
this.failTurn(threadId, safe);
|
|
1985
|
-
}
|
|
1986
|
-
for (const [id, pending] of this.pending) {
|
|
1987
|
-
clearTimeout(pending.timer);
|
|
1988
|
-
this.pending.delete(id);
|
|
1989
|
-
pending.reject(safe);
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
failProcess(child, error) {
|
|
1993
|
-
if (child !== this.child) {
|
|
1994
|
-
return;
|
|
1995
|
-
}
|
|
1996
|
-
const suffix = this.stderrTail ? `: ${this.stderrTail}` : '';
|
|
1997
|
-
this.failAll(new Error(this.redact(`${error.message}${suffix}`)));
|
|
1998
|
-
this.detach(child);
|
|
1999
|
-
}
|
|
2000
|
-
async restart() {
|
|
2001
|
-
await this.shutdown(new Error('Codex app-server restarting after auth refresh'));
|
|
2002
|
-
this.sessions.clear();
|
|
2003
|
-
}
|
|
2004
|
-
async shutdown(reason) {
|
|
2005
|
-
if (this.shutdownPromise) {
|
|
2006
|
-
return this.shutdownPromise;
|
|
2007
|
-
}
|
|
2008
|
-
const operation = this.performShutdown(reason);
|
|
2009
|
-
this.shutdownPromise = operation;
|
|
2010
|
-
try {
|
|
2011
|
-
await operation;
|
|
2012
|
-
}
|
|
2013
|
-
finally {
|
|
2014
|
-
if (this.shutdownPromise === operation) {
|
|
2015
|
-
this.shutdownPromise = undefined;
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
async performShutdown(reason) {
|
|
2020
|
-
const child = this.child;
|
|
2021
|
-
if (!child) {
|
|
2022
|
-
return;
|
|
2023
|
-
}
|
|
2024
|
-
this.failAll(reason);
|
|
2025
|
-
await new Promise((resolveStop) => {
|
|
2026
|
-
let settled = false;
|
|
2027
|
-
const finish = () => {
|
|
2028
|
-
if (settled) {
|
|
2029
|
-
return;
|
|
2030
|
-
}
|
|
2031
|
-
settled = true;
|
|
2032
|
-
if (this.killTimer) {
|
|
2033
|
-
clearTimeout(this.killTimer);
|
|
2034
|
-
this.killTimer = undefined;
|
|
2035
|
-
}
|
|
2036
|
-
if (this.finalKillTimer) {
|
|
2037
|
-
clearTimeout(this.finalKillTimer);
|
|
2038
|
-
this.finalKillTimer = undefined;
|
|
2039
|
-
}
|
|
2040
|
-
this.detach(child);
|
|
2041
|
-
resolveStop();
|
|
2042
|
-
};
|
|
2043
|
-
child.once('exit', finish);
|
|
2044
|
-
child.kill('SIGTERM');
|
|
2045
|
-
this.killTimer = setTimeout(() => {
|
|
2046
|
-
if (child.exitCode === null && child.signalCode === null) {
|
|
2047
|
-
child.kill('SIGKILL');
|
|
2048
|
-
}
|
|
2049
|
-
this.killTimer = undefined;
|
|
2050
|
-
this.finalKillTimer = setTimeout(finish, STOP_GRACE_MS);
|
|
2051
|
-
this.finalKillTimer.unref();
|
|
2052
|
-
}, STOP_GRACE_MS);
|
|
2053
|
-
this.killTimer.unref();
|
|
2054
|
-
if (child.exitCode !== null || child.signalCode !== null) {
|
|
2055
|
-
finish();
|
|
2056
|
-
}
|
|
2057
|
-
});
|
|
2058
|
-
}
|
|
2059
|
-
detach(child) {
|
|
2060
|
-
if (this.child !== child) {
|
|
2061
|
-
return;
|
|
2062
|
-
}
|
|
2063
|
-
this.stdout?.close();
|
|
2064
|
-
this.stderr?.close();
|
|
2065
|
-
child.removeAllListeners();
|
|
2066
|
-
child.stdin.removeAllListeners();
|
|
2067
|
-
child.stdout.removeAllListeners();
|
|
2068
|
-
child.stderr.removeAllListeners();
|
|
2069
|
-
this.stdout = undefined;
|
|
2070
|
-
this.stderr = undefined;
|
|
2071
|
-
this.child = undefined;
|
|
2072
|
-
this.sessions.clear();
|
|
2073
|
-
// The connection is gone, so every child is gone with it: say so once per child and
|
|
2074
|
-
// release its authority instead of dropping the registry silently.
|
|
2075
|
-
this.terminateSubagents(new Error('Codex app-server connection closed'));
|
|
2076
|
-
this.threadContexts.clear();
|
|
2077
|
-
this.lateTurnStarts.clear();
|
|
2078
|
-
for (const [threadId, reconciliation] of this.turnStartReconciliations) {
|
|
2079
|
-
this.completeTurnStartReconciliation(threadId, reconciliation);
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
exports.CodexAppServerProcess = CodexAppServerProcess;
|
|
2084
|
-
//# sourceMappingURL=codex-app-server-process.js.map
|