@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,2230 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* mama start command — thin orchestrator.
|
|
4
|
-
*
|
|
5
|
-
* This file contains two functions:
|
|
6
|
-
* - startCommand() — CLI entry point (config load, foreground/daemon decision)
|
|
7
|
-
* - runAgentLoop() — linear orchestrator that calls all init functions in order
|
|
8
|
-
*
|
|
9
|
-
* All heavy lifting is delegated to modules in ../runtime/.
|
|
10
|
-
*/
|
|
11
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
-
}
|
|
17
|
-
Object.defineProperty(o, k2, desc);
|
|
18
|
-
}) : (function(o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
}));
|
|
22
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
-
}) : function(o, v) {
|
|
25
|
-
o["default"] = v;
|
|
26
|
-
});
|
|
27
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
-
var ownKeys = function(o) {
|
|
29
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
-
var ar = [];
|
|
31
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
-
return ar;
|
|
33
|
-
};
|
|
34
|
-
return ownKeys(o);
|
|
35
|
-
};
|
|
36
|
-
return function (mod) {
|
|
37
|
-
if (mod && mod.__esModule) return mod;
|
|
38
|
-
var result = {};
|
|
39
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
-
__setModuleDefault(result, mod);
|
|
41
|
-
return result;
|
|
42
|
-
};
|
|
43
|
-
})();
|
|
44
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.OPERATOR_REPORT_TOOL_POLICY = exports.TURN_KIND_BLOCKED_TOOLS = exports.SCHEDULED_TURN_BLOCKED_TOOLS = exports.TURN_KIND_REQUIRED_TOOLS = exports.ADMINISTRATION_TOOLS = exports.ONE_AGENT_TURN_POLICY = void 0;
|
|
49
|
-
exports.workOrderActivityDetails = workOrderActivityDetails;
|
|
50
|
-
exports.createCorePrincipalRegistry = createCorePrincipalRegistry;
|
|
51
|
-
exports.createCorePrincipalResolver = createCorePrincipalResolver;
|
|
52
|
-
exports.createRuntimeMemberScopeResolver = createRuntimeMemberScopeResolver;
|
|
53
|
-
exports.createRuntimeMessageRouter = createRuntimeMessageRouter;
|
|
54
|
-
exports.requireRuntimeBackend = requireRuntimeBackend;
|
|
55
|
-
exports.serializeCodeActExecutionResult = serializeCodeActExecutionResult;
|
|
56
|
-
exports.deriveCodeActToolPolicy = deriveCodeActToolPolicy;
|
|
57
|
-
exports.resolveCodeActAgentPolicy = resolveCodeActAgentPolicy;
|
|
58
|
-
exports.resolveCodeActRawConnectors = resolveCodeActRawConnectors;
|
|
59
|
-
exports.causeEventIdsFromPayload = causeEventIdsFromPayload;
|
|
60
|
-
exports.workOrderEnvelopeScope = workOrderEnvelopeScope;
|
|
61
|
-
exports.temporalTaskBinding = temporalTaskBinding;
|
|
62
|
-
exports.buildOperatorReportAgentPolicy = buildOperatorReportAgentPolicy;
|
|
63
|
-
exports.isOutboundToolName = isOutboundToolName;
|
|
64
|
-
exports.buildTurnAgentPolicy = buildTurnAgentPolicy;
|
|
65
|
-
exports.bindCodeActParentModelRun = bindCodeActParentModelRun;
|
|
66
|
-
exports.finalizeCodeActParentModelRun = finalizeCodeActParentModelRun;
|
|
67
|
-
exports.failCodeActParentModelRun = failCodeActParentModelRun;
|
|
68
|
-
exports.resolveOwnerEventTerminalReceipt = resolveOwnerEventTerminalReceipt;
|
|
69
|
-
exports.startCommand = startCommand;
|
|
70
|
-
exports.buildStartOnboardingOutput = buildStartOnboardingOutput;
|
|
71
|
-
exports.runAgentLoop = runAgentLoop;
|
|
72
|
-
const config_manager_js_1 = require("../config/config-manager.js");
|
|
73
|
-
const pid_manager_js_1 = require("../utils/pid-manager.js");
|
|
74
|
-
const stop_js_1 = require("./stop.js");
|
|
75
|
-
const index_js_1 = require("../../auth/index.js");
|
|
76
|
-
const gateway_tool_executor_js_1 = require("../../agent/gateway-tool-executor.js");
|
|
77
|
-
const context_compile_service_js_1 = require("../../agent/context-compile-service.js");
|
|
78
|
-
const read_js_1 = require("../../evidence/read.js");
|
|
79
|
-
const tool_registry_js_1 = require("../../agent/tool-registry.js");
|
|
80
|
-
const gateway_tool_catalog_js_1 = require("../../agent/gateway-tool-catalog.js");
|
|
81
|
-
const tool_policy_js_1 = require("../../agent/code-act/tool-policy.js");
|
|
82
|
-
const run_context_registry_js_1 = require("../../agent/code-act/run-context-registry.js");
|
|
83
|
-
const index_js_2 = require("../../gateways/index.js");
|
|
84
|
-
const member_effective_scope_js_1 = require("../../gateways/member-effective-scope.js");
|
|
85
|
-
const telegram_report_context_store_js_1 = require("../../gateways/telegram-report-context-store.js");
|
|
86
|
-
const report_delivery_coordinator_js_1 = require("../../operator/report-delivery-coordinator.js");
|
|
87
|
-
const graph_api_js_1 = require("../../api/graph-api.js");
|
|
88
|
-
const sqlite_js_1 = __importDefault(require("../../sqlite.js"));
|
|
89
|
-
const node_fs_1 = require("node:fs");
|
|
90
|
-
const node_path_1 = require("node:path");
|
|
91
|
-
const minimatch_1 = require("minimatch");
|
|
92
|
-
const untrusted_content_js_1 = require("../../utils/untrusted-content.js");
|
|
93
|
-
const ui_command_handler_js_1 = require("../../api/ui-command-handler.js");
|
|
94
|
-
const agent_store_js_1 = require("../../db/agent-store.js");
|
|
95
|
-
const store_js_1 = require("../../validation/store.js");
|
|
96
|
-
const session_service_js_1 = require("../../validation/session-service.js");
|
|
97
|
-
const utilities_js_1 = require("../runtime/utilities.js");
|
|
98
|
-
const agent_contract_js_1 = require("../../onboarding/agent-contract.js");
|
|
99
|
-
const assess_live_js_1 = require("../../onboarding/assess-live.js");
|
|
100
|
-
const daemon_js_1 = require("../runtime/daemon.js");
|
|
101
|
-
const metrics_init_js_1 = require("../runtime/metrics-init.js");
|
|
102
|
-
const mama_core_init_js_1 = require("../runtime/mama-core-init.js");
|
|
103
|
-
const agent_loop_init_js_1 = require("../runtime/agent-loop-init.js");
|
|
104
|
-
const gateway_init_js_1 = require("../runtime/gateway-init.js");
|
|
105
|
-
const gateway_wiring_js_1 = require("../runtime/gateway-wiring.js");
|
|
106
|
-
const scheduler_init_js_1 = require("../runtime/scheduler-init.js");
|
|
107
|
-
const connector_init_js_1 = require("../runtime/connector-init.js");
|
|
108
|
-
const api_server_init_js_1 = require("../runtime/api-server-init.js");
|
|
109
|
-
const api_routes_init_js_1 = require("../runtime/api-routes-init.js");
|
|
110
|
-
const server_start_js_1 = require("../runtime/server-start.js");
|
|
111
|
-
const shutdown_js_1 = require("../runtime/shutdown.js");
|
|
112
|
-
const envelope_bootstrap_js_1 = require("../runtime/envelope-bootstrap.js");
|
|
113
|
-
const config_loader_js_1 = require("../../connectors/config-loader.js");
|
|
114
|
-
const connector_bootstrap_js_1 = require("../runtime/connector-bootstrap.js");
|
|
115
|
-
const message_router_config_js_1 = require("../runtime/message-router-config.js");
|
|
116
|
-
const reactive_config_js_1 = require("../../envelope/reactive-config.js");
|
|
117
|
-
const scope_context_js_1 = require("../../memory/scope-context.js");
|
|
118
|
-
const types_js_1 = require("../config/types.js");
|
|
119
|
-
const role_manager_js_1 = require("../../agent/role-manager.js");
|
|
120
|
-
const node_crypto_1 = require("node:crypto");
|
|
121
|
-
const debugLogger = __importStar(require("@jungjaehoon/mama-core/debug-logger"));
|
|
122
|
-
const mama_core_1 = require("@jungjaehoon/mama-core");
|
|
123
|
-
const mamaCore = __importStar(require("@jungjaehoon/mama-core"));
|
|
124
|
-
const owner_runtime_js_1 = require("../../operator/owner-runtime.js");
|
|
125
|
-
const subagent_stimulus_js_1 = require("../../operator/subagent-stimulus.js");
|
|
126
|
-
const console_brief_js_1 = require("../../operator/console-brief.js");
|
|
127
|
-
const task_ledger_js_1 = require("../../operator/task-ledger.js");
|
|
128
|
-
const board_refresh_gate_js_1 = require("../../operator/board-refresh-gate.js");
|
|
129
|
-
const owner_event_inbox_js_1 = require("../../operator/owner-event-inbox.js");
|
|
130
|
-
const operational_issues_js_1 = require("../../observability/operational-issues.js");
|
|
131
|
-
const repair_request_js_1 = require("../../operator/repair-request.js");
|
|
132
|
-
const agent_loop_init_js_2 = require("../runtime/agent-loop-init.js");
|
|
133
|
-
const workorder_publishers_js_1 = require("../../operator/workorder-publishers.js");
|
|
134
|
-
const owner_action_effects_js_1 = require("../../operator/owner-action-effects.js");
|
|
135
|
-
const owner_event_effects_js_1 = require("../../operator/owner-event-effects.js");
|
|
136
|
-
const owner_event_loop_js_1 = require("../../operator/owner-event-loop.js");
|
|
137
|
-
const board_pipeline_render_js_1 = require("../../operator/board-pipeline-render.js");
|
|
138
|
-
const procedure_store_js_1 = require("../../operator/procedure-store.js");
|
|
139
|
-
const procedure_activation_js_1 = require("../../operator/procedure-activation.js");
|
|
140
|
-
const owner_event_prompt_js_1 = require("../../operator/owner-event-prompt.js");
|
|
141
|
-
const thread_brief_memory_js_1 = require("../../operator/thread-brief-memory.js");
|
|
142
|
-
/**
|
|
143
|
-
* One in-process memory of the console brief already delivered on the owner:runtime
|
|
144
|
-
* thread. Both owner-event batches and scheduled work orders submit to that one thread,
|
|
145
|
-
* so a single memory keeps the standing brief there once instead of once per turn.
|
|
146
|
-
* A daemon restart clears it, which is correct: a resumed thread is fresh for this.
|
|
147
|
-
*/
|
|
148
|
-
const ownerBriefMemory = new thread_brief_memory_js_1.ThreadBriefMemory();
|
|
149
|
-
/**
|
|
150
|
-
* The owner-event loop builds a batch's prompt twice (once to size the run, once in
|
|
151
|
-
* prepareContent, which is the text actually sent). The brief decision must be the same
|
|
152
|
-
* both times, so it is decided once per batch. The loop is serial: one entry suffices.
|
|
153
|
-
*/
|
|
154
|
-
let lastOwnerEventBriefDecision = null;
|
|
155
|
-
const subagent_run_reconcile_js_1 = require("../../agent/subagent-run-reconcile.js");
|
|
156
|
-
const owner_event_policy_js_1 = require("../../operator/owner-event-policy.js");
|
|
157
|
-
Object.defineProperty(exports, "ADMINISTRATION_TOOLS", { enumerable: true, get: function () { return owner_event_policy_js_1.ADMINISTRATION_TOOLS; } });
|
|
158
|
-
const leg_cadence_js_1 = require("../../operator/leg-cadence.js");
|
|
159
|
-
const temporal_worker_js_1 = require("../../operator/temporal-worker.js");
|
|
160
|
-
const temporal_runtime_js_1 = require("../../operator/temporal-runtime.js");
|
|
161
|
-
const temporal_init_js_1 = require("../runtime/temporal-init.js");
|
|
162
|
-
const code_act_executor_js_1 = require("../runtime/code-act-executor.js");
|
|
163
|
-
const workorder_consumer_js_1 = require("../../operator/workorder-consumer.js");
|
|
164
|
-
const owner_backfill_js_1 = require("../runtime/owner-backfill.js");
|
|
165
|
-
const { DebugLogger } = debugLogger;
|
|
166
|
-
const codeActLogger = new DebugLogger('CodeAct');
|
|
167
|
-
const temporalLogger = new DebugLogger('TemporalReconcile');
|
|
168
|
-
const principalRegistryLogger = new DebugLogger('PrincipalRegistry');
|
|
169
|
-
function workOrderActivityDetails(event) {
|
|
170
|
-
return event.briefHash ? { brief_hash: event.briefHash } : undefined;
|
|
171
|
-
}
|
|
172
|
-
function createCorePrincipalRegistry(adapter) {
|
|
173
|
-
const { createPrincipalRepository } = mamaCore;
|
|
174
|
-
return createPrincipalRepository(adapter);
|
|
175
|
-
}
|
|
176
|
-
function createCorePrincipalResolver(adapter) {
|
|
177
|
-
const repository = createCorePrincipalRegistry(adapter);
|
|
178
|
-
return repository.resolveByExternal.bind(repository);
|
|
179
|
-
}
|
|
180
|
-
function createRuntimeMemberScopeResolver(repository, configuredGrant = read_js_1.liveBoundaryChannels) {
|
|
181
|
-
return ({ principal, current }) => {
|
|
182
|
-
if (!principal.principalId) {
|
|
183
|
-
throw new Error('Active member principal is missing its durable principal id');
|
|
184
|
-
}
|
|
185
|
-
return (0, member_effective_scope_js_1.resolveMemberEffectiveScope)({
|
|
186
|
-
principal,
|
|
187
|
-
current,
|
|
188
|
-
configuredGrant: configuredGrant(),
|
|
189
|
-
principalGrants: repository.listActiveGrants(principal.principalId),
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
function createRuntimeMessageRouter(input) {
|
|
194
|
-
return new index_js_2.MessageRouter(input.sessionStore, input.agentLoopClient, input.mamaApiClient, input.config, input.envelopeConfig, input.envelopeAuthority, {
|
|
195
|
-
...input.dependencies,
|
|
196
|
-
memberScopeResolver: createRuntimeMemberScopeResolver(input.memberGrantReader, input.configuredGrant),
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
function requireRuntimeBackend(value) {
|
|
200
|
-
if (value === 'claude' || value === 'codex' || value === 'cline') {
|
|
201
|
-
return value;
|
|
202
|
-
}
|
|
203
|
-
throw new Error(`Unsupported agent backend: ${String(value)}`);
|
|
204
|
-
}
|
|
205
|
-
function serializeCodeActExecutionResult(result, toolCalls, hostToolExecutions = []) {
|
|
206
|
-
const hostToolsInvoked = [
|
|
207
|
-
...new Set(hostToolExecutions.filter((execution) => execution.success).map((execution) => execution.name)),
|
|
208
|
-
];
|
|
209
|
-
return {
|
|
210
|
-
success: result.success,
|
|
211
|
-
value: result.value,
|
|
212
|
-
logs: result.logs,
|
|
213
|
-
error: result.error?.message,
|
|
214
|
-
...(result.error?.code
|
|
215
|
-
? { terminalCode: result.error.code, retryable: false, abort: true }
|
|
216
|
-
: {}),
|
|
217
|
-
metrics: result.metrics,
|
|
218
|
-
toolCalls,
|
|
219
|
-
hostToolExecutions,
|
|
220
|
-
hostToolsInvoked,
|
|
221
|
-
...(toolCalls.some((call) => (0, untrusted_content_js_1.isUntrustedExternalEvidenceTool)(call.name))
|
|
222
|
-
? { untrustedExternalEvidence: true }
|
|
223
|
-
: {}),
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
const TRUTHY_ENV_VALUES = new Set(['1', 'true', 'yes', 'on']);
|
|
227
|
-
const CODE_ACT_MUTATION_TOOLS = new Set([
|
|
228
|
-
'procedure_update',
|
|
229
|
-
'procedure_retire',
|
|
230
|
-
'procedure_observe',
|
|
231
|
-
'console_brief_update',
|
|
232
|
-
'mama_save',
|
|
233
|
-
'context_compile',
|
|
234
|
-
'mama_update',
|
|
235
|
-
'report_publish',
|
|
236
|
-
'wiki_publish',
|
|
237
|
-
'task_create',
|
|
238
|
-
'task_update',
|
|
239
|
-
'task_reclassify',
|
|
240
|
-
'task_temporal_reconcile',
|
|
241
|
-
'contract_no_update',
|
|
242
|
-
]);
|
|
243
|
-
function isTruthyEnvValue(value) {
|
|
244
|
-
return value !== undefined && TRUTHY_ENV_VALUES.has(value.trim().toLowerCase());
|
|
245
|
-
}
|
|
246
|
-
function uniqueToolList(values) {
|
|
247
|
-
return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
|
|
248
|
-
}
|
|
249
|
-
function isWildcardToolList(values) {
|
|
250
|
-
return Boolean(values?.includes('*'));
|
|
251
|
-
}
|
|
252
|
-
function isGlobToolPattern(value) {
|
|
253
|
-
return /[*?[{]/.test(value);
|
|
254
|
-
}
|
|
255
|
-
function toolPatternAllows(pattern, toolName) {
|
|
256
|
-
return (0, minimatch_1.minimatch)(toolName, pattern);
|
|
257
|
-
}
|
|
258
|
-
function intersectAllowedToolPolicies(configuredAllowed, requestedAllowed) {
|
|
259
|
-
const configured = configuredAllowed !== undefined ? uniqueToolList(configuredAllowed) : undefined;
|
|
260
|
-
const requested = requestedAllowed !== undefined ? uniqueToolList(requestedAllowed) : undefined;
|
|
261
|
-
// Treat explicit empty arrays as deny-all so a caller cannot widen a fully
|
|
262
|
-
// restricted policy by sending a wildcard. Only an undefined (truly absent)
|
|
263
|
-
// policy falls back to the other side.
|
|
264
|
-
if (configured === undefined) {
|
|
265
|
-
return requested;
|
|
266
|
-
}
|
|
267
|
-
if (requested === undefined) {
|
|
268
|
-
return configured;
|
|
269
|
-
}
|
|
270
|
-
if (isWildcardToolList(configured)) {
|
|
271
|
-
return requested;
|
|
272
|
-
}
|
|
273
|
-
if (isWildcardToolList(requested)) {
|
|
274
|
-
return configured;
|
|
275
|
-
}
|
|
276
|
-
const narrowed = [];
|
|
277
|
-
for (const requestedPattern of requested) {
|
|
278
|
-
for (const configuredPattern of configured) {
|
|
279
|
-
if (requestedPattern === configuredPattern) {
|
|
280
|
-
narrowed.push(requestedPattern);
|
|
281
|
-
}
|
|
282
|
-
else if (!isGlobToolPattern(requestedPattern) &&
|
|
283
|
-
toolPatternAllows(configuredPattern, requestedPattern)) {
|
|
284
|
-
narrowed.push(requestedPattern);
|
|
285
|
-
}
|
|
286
|
-
else if (!isGlobToolPattern(configuredPattern) &&
|
|
287
|
-
toolPatternAllows(requestedPattern, configuredPattern)) {
|
|
288
|
-
narrowed.push(configuredPattern);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return uniqueToolList(narrowed);
|
|
293
|
-
}
|
|
294
|
-
function mergeBlockedToolPolicies(configuredBlocked, requestedBlocked) {
|
|
295
|
-
const merged = uniqueToolList([...(configuredBlocked ?? []), ...(requestedBlocked ?? [])]);
|
|
296
|
-
return merged.length > 0 ? merged : undefined;
|
|
297
|
-
}
|
|
298
|
-
function deriveCodeActToolPolicy(requestContext, agentConfig) {
|
|
299
|
-
const configuredAllowed = agentConfig?.gateway_tool_permissions?.allowed ?? agentConfig?.tool_permissions?.allowed;
|
|
300
|
-
const configuredBlocked = agentConfig?.gateway_tool_permissions?.blocked ?? agentConfig?.tool_permissions?.blocked;
|
|
301
|
-
const allowedTools = intersectAllowedToolPolicies(configuredAllowed, requestContext?.allowedTools);
|
|
302
|
-
const blockedTools = mergeBlockedToolPolicies(configuredBlocked, requestContext?.blockedTools);
|
|
303
|
-
return { allowedTools, blockedTools };
|
|
304
|
-
}
|
|
305
|
-
function resolveCodeActAgentPolicy(requestContext, agents, defaultAgentId) {
|
|
306
|
-
const agentId = requestContext?.agentId || defaultAgentId;
|
|
307
|
-
const agentConfig = agents?.[agentId];
|
|
308
|
-
if (!agentConfig) {
|
|
309
|
-
return { agentId, error: `Unknown Code-Act agent: ${agentId}` };
|
|
310
|
-
}
|
|
311
|
-
if (agentConfig.useCodeAct !== true) {
|
|
312
|
-
return { agentId, error: `Agent is not configured for Code-Act: ${agentId}` };
|
|
313
|
-
}
|
|
314
|
-
const policy = deriveCodeActToolPolicy(requestContext, agentConfig);
|
|
315
|
-
if (!policy.allowedTools || policy.allowedTools.length === 0) {
|
|
316
|
-
// Fail closed: an agent that resolves to no allowed tools must be rejected
|
|
317
|
-
// rather than silently widened to wildcard access.
|
|
318
|
-
return {
|
|
319
|
-
agentId,
|
|
320
|
-
agentConfig,
|
|
321
|
-
policy,
|
|
322
|
-
error: `Agent has no allowed Code-Act tools: ${agentId}`,
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
return {
|
|
326
|
-
agentId,
|
|
327
|
-
agentConfig,
|
|
328
|
-
policy,
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
function resolveCodeActRawConnectors(enabledConnectorNames) {
|
|
332
|
-
return [...new Set((enabledConnectorNames ?? []).map((name) => name.trim()).filter(Boolean))];
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* READS ARE NOT GATED (2026-07-30, owner rules "observability over
|
|
336
|
-
* restriction" + "answers read direct, gates guard writes only"). The
|
|
337
|
-
* per-principal trello filter this replaced (#199) collided with the 07-28
|
|
338
|
-
* code-act transport switch: owner chat's tool calls moved onto the
|
|
339
|
-
* api-code-act envelope and its board questions died 100%
|
|
340
|
-
* connector_out_of_scope, while the board drifted 3 weeks undetected
|
|
341
|
-
* (7 delivered items shown overdue - operator lesson 07-30). Kagemusha's
|
|
342
|
-
* model - reads free, actions receipted, sends confirmed - is the standard.
|
|
343
|
-
* Every daemon envelope still grants allowed_destinations: [] (the real,
|
|
344
|
-
* irreversible-side-effect gate) and every read lands in tool traces.
|
|
345
|
-
*/
|
|
346
|
-
function uniqueMemoryScopes(scopes) {
|
|
347
|
-
const seen = new Set();
|
|
348
|
-
const unique = [];
|
|
349
|
-
for (const scope of scopes) {
|
|
350
|
-
const id = scope.id.trim();
|
|
351
|
-
if (!id) {
|
|
352
|
-
continue;
|
|
353
|
-
}
|
|
354
|
-
const key = `${scope.kind}:${id}`;
|
|
355
|
-
if (seen.has(key)) {
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
seen.add(key);
|
|
359
|
-
unique.push({ kind: scope.kind, id });
|
|
360
|
-
}
|
|
361
|
-
return unique;
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* The connector and channel a temporal task is bound to, as plain values.
|
|
365
|
-
*
|
|
366
|
-
* The workorder payload carries only HASHED source identifiers (they are compared, never
|
|
367
|
-
* read), so the binding has to come from the owner task row. Split on the FIRST colon:
|
|
368
|
-
* `source_channel` is `<connector>:<channelId>` and channel ids contain colons of their own.
|
|
369
|
-
*
|
|
370
|
-
* Returns null when the task names no channel - which is not a failure, it is a task whose
|
|
371
|
-
* reconcile may rest on no raw evidence at all.
|
|
372
|
-
*/
|
|
373
|
-
/**
|
|
374
|
-
* The scope a workorder envelope carries.
|
|
375
|
-
*
|
|
376
|
-
* Extracted so the binding can be asserted directly. Composed inline, the only way to test
|
|
377
|
-
* it was to re-compose it in the test - which tests the copy, and a copy of a scope
|
|
378
|
-
* construction is how this subsystem's authority drifts from what it claims.
|
|
379
|
-
*/
|
|
380
|
-
/**
|
|
381
|
-
* What the scheduled full report is INSTRUCTED to gather with.
|
|
382
|
-
*
|
|
383
|
-
* Exported so a test can hold it against the lane's tool grant. Every defect this session
|
|
384
|
-
* found was a wiring defect - a tool granted and never instructed, a lane wired zero times,
|
|
385
|
-
* a binder that never bound - and all of them live in this file and its neighbour, the two
|
|
386
|
-
* directories the suite covers at a third. An instruction list that cannot be read by a
|
|
387
|
-
* test is one nobody can check against the grant it depends on.
|
|
388
|
-
*/
|
|
389
|
-
/**
|
|
390
|
-
* The batch a work order carries, as the run's cause.
|
|
391
|
-
*
|
|
392
|
-
* Exported because it was an inline closure and therefore untestable, while being the ONE
|
|
393
|
-
* hop that carries this branch's whole claim: the system knew the batch before the run
|
|
394
|
-
* began, so the agent never has to restate it. Review pointed out that `causeEventIds`
|
|
395
|
-
* appeared in exactly two test files and both called the ledger directly - a rename or a
|
|
396
|
-
* payload-shape drift here would have returned attribution to 32% with the suite green.
|
|
397
|
-
*
|
|
398
|
-
* Only per-channel reconcile work orders carry `eventIds`; `board:full`, wiki and
|
|
399
|
-
* memory-curation do not, and get an empty batch rather than an invented one.
|
|
400
|
-
*/
|
|
401
|
-
function causeEventIdsFromPayload(payload) {
|
|
402
|
-
if (payload === null || typeof payload !== 'object')
|
|
403
|
-
return [];
|
|
404
|
-
const batch = payload.eventIds;
|
|
405
|
-
if (!Array.isArray(batch))
|
|
406
|
-
return [];
|
|
407
|
-
return batch.filter((id) => typeof id === 'string' && id.trim().length > 0);
|
|
408
|
-
}
|
|
409
|
-
function workOrderEnvelopeScope(input) {
|
|
410
|
-
// The trusted owner grant decides readable connectors. Work kind and temporal binding
|
|
411
|
-
// remain selection and receipt metadata; neither attenuates ordinary read authority.
|
|
412
|
-
const surface = exports.ONE_AGENT_TURN_POLICY.roleName;
|
|
413
|
-
const candidateConnectors = input.laneConnectors;
|
|
414
|
-
return {
|
|
415
|
-
project_refs: [{ kind: 'project', id: input.projectId }],
|
|
416
|
-
// A temporal run reads its task's connector or nothing. Every other lane keeps the
|
|
417
|
-
// connectors it was configured with.
|
|
418
|
-
raw_connectors: [
|
|
419
|
-
...input.privateConnectorPolicy.projectRawConnectors(surface, candidateConnectors),
|
|
420
|
-
],
|
|
421
|
-
memory_scopes: [
|
|
422
|
-
...(0, scope_context_js_1.deriveMemoryScopes)({
|
|
423
|
-
source: 'operator',
|
|
424
|
-
channelId: `worker:${input.workKind}`,
|
|
425
|
-
projectId: input.projectId,
|
|
426
|
-
}),
|
|
427
|
-
// Identity scopes ONLY. Wider memory READ visibility (the grant mirror)
|
|
428
|
-
// is granted at the enforcement layer, never issued into the envelope:
|
|
429
|
-
// envelope channel scopes double as the raw-narrowing input AND as
|
|
430
|
-
// mama_save's write binding, so issuing the mirror here re-opened
|
|
431
|
-
// per-channel raw isolation and bound every saved memory to every
|
|
432
|
-
// granted channel (PR #217 review, blocking #2/#3).
|
|
433
|
-
],
|
|
434
|
-
allowed_destinations: [],
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
function temporalTaskBinding(ledger, taskId) {
|
|
438
|
-
const task = ledger.getById(taskId);
|
|
439
|
-
const sourceChannel = task?.status === 'review'
|
|
440
|
-
? (task.reviewAnchorSourceChannel ?? task.sourceChannel)
|
|
441
|
-
: task?.sourceChannel;
|
|
442
|
-
if (typeof sourceChannel !== 'string')
|
|
443
|
-
return null;
|
|
444
|
-
const separator = sourceChannel.indexOf(':');
|
|
445
|
-
if (separator <= 0 || separator === sourceChannel.length - 1)
|
|
446
|
-
return null;
|
|
447
|
-
return {
|
|
448
|
-
connector: sourceChannel.slice(0, separator),
|
|
449
|
-
channel: sourceChannel.slice(separator + 1),
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
function buildCodeActRole(policy) {
|
|
453
|
-
// Caller (resolveCodeActAgentPolicy) rejects empty/undefined allowedTools, so
|
|
454
|
-
// here we honor the resolved policy verbatim instead of widening to wildcard.
|
|
455
|
-
return {
|
|
456
|
-
allowedTools: policy.allowedTools ?? [],
|
|
457
|
-
blockedTools: policy.blockedTools,
|
|
458
|
-
allowedPaths: [],
|
|
459
|
-
systemControl: false,
|
|
460
|
-
sensitiveAccess: false,
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* One MAMA: every scheduled turn runs as the SAME principal the owner console and the
|
|
465
|
-
* event turn use. `roleName` is not a label - resolvePrivatePrincipalSurface switches on
|
|
466
|
-
* it and falls through to 'multi-agent-generic' for anything it does not know, which
|
|
467
|
-
* splits the advertised catalog from the execution envelope.
|
|
468
|
-
*/
|
|
469
|
-
exports.ONE_AGENT_TURN_POLICY = { roleName: 'owner_console' };
|
|
470
|
-
/**
|
|
471
|
-
* Per-turn-kind artifact tools, projected by the HOST. These exist only for scheduled
|
|
472
|
-
* turns and are deliberately absent from the chat grant: a chat turn never publishes a
|
|
473
|
-
* board slot or a wiki page and never files a temporal receipt. They are the tools the
|
|
474
|
-
* turn-kind section instructs the turn to use, so grant and instruction cannot drift.
|
|
475
|
-
*/
|
|
476
|
-
exports.TURN_KIND_REQUIRED_TOOLS = {
|
|
477
|
-
board: [
|
|
478
|
-
'agent_notices',
|
|
479
|
-
'contract_no_update',
|
|
480
|
-
'report_publish',
|
|
481
|
-
'task_external_correlation',
|
|
482
|
-
'task_external_bind',
|
|
483
|
-
'task_lifecycle_reconcile',
|
|
484
|
-
// The board RECORRECTS rows it can no longer create: a connector item with no
|
|
485
|
-
// ledger row stays evidence, and an existing row gets a named disposition.
|
|
486
|
-
'task_reclassify',
|
|
487
|
-
],
|
|
488
|
-
wiki: ['agent_notices', 'contract_no_update', 'wiki_read', 'wiki_publish'],
|
|
489
|
-
'memory-curation': ['agent_notices', 'contract_no_update'],
|
|
490
|
-
temporal: ['agent_notices', 'contract_no_update', 'task_temporal_reconcile'],
|
|
491
|
-
'self-check': ['agent_notices', 'contract_no_update', 'repair_request', 'issue_close'],
|
|
492
|
-
};
|
|
493
|
-
/**
|
|
494
|
-
* Blocked on EVERY unattended turn: administration plus the workspace shell and file
|
|
495
|
-
* writer. ONE list with the owner-event turn and native subagents
|
|
496
|
-
* (UNATTENDED_BLOCKED_TOOLS, owner-event-policy.ts) - this used to equal
|
|
497
|
-
* ADMINISTRATION_TOOLS alone, so a scheduled turn still held Bash/Write while both
|
|
498
|
-
* CLAUDE.md and the role comment said it did not.
|
|
499
|
-
*/
|
|
500
|
-
exports.SCHEDULED_TURN_BLOCKED_TOOLS = owner_event_policy_js_1.UNATTENDED_BLOCKED_TOOLS;
|
|
501
|
-
/**
|
|
502
|
-
* Per-turn-kind blocked lists, projected by the HOST. One principal and one brief do
|
|
503
|
-
* not mean one grant for every trigger: an unattended board or wiki turn has no owner
|
|
504
|
-
* in the loop, so it never holds a send, an upload, or a mutation outside its own
|
|
505
|
-
* artifact. Each entry names the artifact it protects.
|
|
506
|
-
*/
|
|
507
|
-
exports.TURN_KIND_BLOCKED_TOOLS = {
|
|
508
|
-
board: new Set(),
|
|
509
|
-
wiki: new Set(),
|
|
510
|
-
'memory-curation': new Set(),
|
|
511
|
-
'self-check': new Set(),
|
|
512
|
-
temporal: new Set(),
|
|
513
|
-
};
|
|
514
|
-
/** Progressive evidence primitives for a scheduled owner-runtime report turn. */
|
|
515
|
-
exports.OPERATOR_REPORT_TOOL_POLICY = {
|
|
516
|
-
roleName: 'owner_console',
|
|
517
|
-
allowedTools: [
|
|
518
|
-
'code_act',
|
|
519
|
-
'task_list',
|
|
520
|
-
'changes_read',
|
|
521
|
-
'board_read',
|
|
522
|
-
'report_publish',
|
|
523
|
-
'audit_findings_read',
|
|
524
|
-
'schedule_upcoming',
|
|
525
|
-
'context_compile',
|
|
526
|
-
'mama_recall',
|
|
527
|
-
'mama_provenance',
|
|
528
|
-
'trello_search',
|
|
529
|
-
'trello_card',
|
|
530
|
-
'trello_kanban',
|
|
531
|
-
],
|
|
532
|
-
};
|
|
533
|
-
function requirePrivateConnectorPolicy(privateConnectorPolicy) {
|
|
534
|
-
if (!privateConnectorPolicy) {
|
|
535
|
-
throw new Error('privateConnectorPolicy is required');
|
|
536
|
-
}
|
|
537
|
-
return privateConnectorPolicy;
|
|
538
|
-
}
|
|
539
|
-
function buildProjectedLaneRole(surface, allowedTools, privateConnectorPolicy) {
|
|
540
|
-
return privateConnectorPolicy.projectRole(surface, {
|
|
541
|
-
allowedTools: [...allowedTools],
|
|
542
|
-
blockedTools: [],
|
|
543
|
-
allowedPaths: [],
|
|
544
|
-
systemControl: false,
|
|
545
|
-
sensitiveAccess: false,
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
function buildProjectedLanePrompt(innerTools, surface, privateConnectorPolicy) {
|
|
549
|
-
return (0, gateway_tool_catalog_js_1.buildGatewayToolCatalog)({
|
|
550
|
-
surface,
|
|
551
|
-
allowedTools: innerTools,
|
|
552
|
-
privateConnectorPolicy,
|
|
553
|
-
}).prompt;
|
|
554
|
-
}
|
|
555
|
-
/**
|
|
556
|
-
* Build the execution role for one progressive report stimulus. The durable
|
|
557
|
-
* session catalog comes from the full owner role; this role narrows effects.
|
|
558
|
-
*/
|
|
559
|
-
function buildOperatorReportAgentPolicy(model, backend, privateConnectorPolicy, ownerRole = types_js_1.DEFAULT_ROLES.definitions.owner_console) {
|
|
560
|
-
const requiredPrivatePolicy = requirePrivateConnectorPolicy(privateConnectorPolicy);
|
|
561
|
-
const blockedSet = new Set([
|
|
562
|
-
...owner_event_policy_js_1.ADMINISTRATION_TOOLS,
|
|
563
|
-
...exports.SCHEDULED_TURN_BLOCKED_TOOLS,
|
|
564
|
-
...(ownerRole.blockedTools ?? []),
|
|
565
|
-
]);
|
|
566
|
-
const projectedRole = requiredPrivatePolicy.projectRole('owner_console', {
|
|
567
|
-
...ownerRole,
|
|
568
|
-
model,
|
|
569
|
-
allowedTools: uniqueToolList([
|
|
570
|
-
...ownerRole.allowedTools,
|
|
571
|
-
...exports.OPERATOR_REPORT_TOOL_POLICY.allowedTools,
|
|
572
|
-
]).filter((tool) => !blockedSet.has(tool)),
|
|
573
|
-
blockedTools: [...blockedSet],
|
|
574
|
-
allowedPaths: [...(ownerRole.allowedPaths ?? [])],
|
|
575
|
-
});
|
|
576
|
-
const blockedTools = [...new Set([...(projectedRole.blockedTools ?? []), ...blockedSet])];
|
|
577
|
-
const innerTools = uniqueToolList(projectedRole.allowedTools).filter((tool) => tool !== 'code_act' && !blockedSet.has(tool));
|
|
578
|
-
const allowedTools = uniqueToolList(['code_act', ...innerTools]);
|
|
579
|
-
const agentContext = {
|
|
580
|
-
source: 'operator',
|
|
581
|
-
platform: 'cli',
|
|
582
|
-
roleName: exports.ONE_AGENT_TURN_POLICY.roleName,
|
|
583
|
-
role: { ...projectedRole, allowedTools, blockedTools, model },
|
|
584
|
-
session: {
|
|
585
|
-
sessionId: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
586
|
-
channelId: 'report',
|
|
587
|
-
startedAt: new Date(),
|
|
588
|
-
},
|
|
589
|
-
capabilities: allowedTools,
|
|
590
|
-
limitations: blockedTools.map((tool) => `Cannot use ${tool}`),
|
|
591
|
-
tier: 1,
|
|
592
|
-
backend,
|
|
593
|
-
};
|
|
594
|
-
return {
|
|
595
|
-
agentContext,
|
|
596
|
-
gatewayToolsPrompt: buildProjectedLanePrompt(innerTools, 'owner_console', requiredPrivatePolicy),
|
|
597
|
-
briefProjectionPolicy: requiredPrivatePolicy,
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
/** Outbound effect by name: sends to a channel or uploads to a shared store. */
|
|
601
|
-
function isOutboundToolName(tool) {
|
|
602
|
-
return /(^|_)(send|upload)(_|$)/.test(tool);
|
|
603
|
-
}
|
|
604
|
-
function buildTurnAgentPolicy(kind, model, backend, privateConnectorPolicy, rawConnectorScope, ownerRole = types_js_1.DEFAULT_ROLES.definitions.owner_console) {
|
|
605
|
-
const requiredPrivatePolicy = requirePrivateConnectorPolicy(privateConnectorPolicy);
|
|
606
|
-
if (!rawConnectorScope) {
|
|
607
|
-
throw new Error('rawConnectorScope is required');
|
|
608
|
-
}
|
|
609
|
-
const kindBlocked = exports.TURN_KIND_BLOCKED_TOOLS[kind];
|
|
610
|
-
if (!kindBlocked) {
|
|
611
|
-
throw new Error(`Missing turn-kind blocked list for '${kind}'`);
|
|
612
|
-
}
|
|
613
|
-
// Same downgrade the event turn applies: a run with no private binding advertises
|
|
614
|
-
// no private connector tools and gets the disabled brief projection.
|
|
615
|
-
const scopedSurface = exports.ONE_AGENT_TURN_POLICY.roleName;
|
|
616
|
-
const blockedSet = new Set([
|
|
617
|
-
...owner_event_policy_js_1.ADMINISTRATION_TOOLS,
|
|
618
|
-
...exports.SCHEDULED_TURN_BLOCKED_TOOLS,
|
|
619
|
-
...kindBlocked,
|
|
620
|
-
...(ownerRole.blockedTools ?? []),
|
|
621
|
-
]);
|
|
622
|
-
const projectedRole = buildProjectedLaneRole(scopedSurface, uniqueToolList([...ownerRole.allowedTools, ...exports.TURN_KIND_REQUIRED_TOOLS[kind]]).filter((tool) => !blockedSet.has(tool)), requiredPrivatePolicy);
|
|
623
|
-
const blockedTools = [...new Set([...(projectedRole.blockedTools ?? []), ...blockedSet])];
|
|
624
|
-
// code_act is the transport, re-added at the front below; it is never an inner tool.
|
|
625
|
-
const innerTools = uniqueToolList(projectedRole.allowedTools).filter((tool) => !blockedSet.has(tool) && tool !== 'code_act');
|
|
626
|
-
const allowedTools = uniqueToolList(['code_act', ...innerTools]);
|
|
627
|
-
const agentContext = {
|
|
628
|
-
source: 'operator',
|
|
629
|
-
platform: 'cli',
|
|
630
|
-
roleName: exports.ONE_AGENT_TURN_POLICY.roleName,
|
|
631
|
-
role: { ...projectedRole, allowedTools, blockedTools, model },
|
|
632
|
-
session: {
|
|
633
|
-
sessionId: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
634
|
-
channelId: `worker:${kind}`,
|
|
635
|
-
startedAt: new Date(),
|
|
636
|
-
},
|
|
637
|
-
capabilities: allowedTools,
|
|
638
|
-
limitations: blockedTools.map((tool) => `Cannot use ${tool}`),
|
|
639
|
-
tier: 1,
|
|
640
|
-
backend,
|
|
641
|
-
};
|
|
642
|
-
return {
|
|
643
|
-
agentContext,
|
|
644
|
-
gatewayToolsPrompt: buildProjectedLanePrompt(innerTools, scopedSurface, requiredPrivatePolicy),
|
|
645
|
-
briefProjectionPolicy: requiredPrivatePolicy,
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
function bindCodeActParentModelRun(adapter, executionContext, options) {
|
|
649
|
-
if (!executionContext?.envelope) {
|
|
650
|
-
return { executionContext, modelRunId: null };
|
|
651
|
-
}
|
|
652
|
-
const run = (0, mama_core_1.beginModelRunInAdapter)(adapter, {
|
|
653
|
-
agent_id: executionContext.agentId,
|
|
654
|
-
instance_id: executionContext.envelope.instance_id,
|
|
655
|
-
envelope_hash: executionContext.envelope.envelope_hash,
|
|
656
|
-
input_snapshot_ref: options.inputSnapshotRef,
|
|
657
|
-
input_refs: options.inputRefs,
|
|
658
|
-
});
|
|
659
|
-
return {
|
|
660
|
-
executionContext: {
|
|
661
|
-
...executionContext,
|
|
662
|
-
modelRunId: run.model_run_id,
|
|
663
|
-
},
|
|
664
|
-
modelRunId: run.model_run_id,
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
function codeActErrorSummary(error) {
|
|
668
|
-
if (error instanceof Error) {
|
|
669
|
-
return error.message;
|
|
670
|
-
}
|
|
671
|
-
return String(error);
|
|
672
|
-
}
|
|
673
|
-
function resultErrorSummary(result) {
|
|
674
|
-
if (typeof result.error === 'string') {
|
|
675
|
-
return result.error;
|
|
676
|
-
}
|
|
677
|
-
return result.error?.message ?? 'Code-Act execution failed';
|
|
678
|
-
}
|
|
679
|
-
function finalizeCodeActParentModelRun(adapter, modelRunId, result) {
|
|
680
|
-
if (!modelRunId) {
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
if (result.success === false) {
|
|
684
|
-
(0, mama_core_1.failModelRunInAdapter)(adapter, modelRunId, resultErrorSummary(result));
|
|
685
|
-
return;
|
|
686
|
-
}
|
|
687
|
-
(0, mama_core_1.commitModelRunInAdapter)(adapter, modelRunId, 'code-act completed');
|
|
688
|
-
}
|
|
689
|
-
function failCodeActParentModelRun(adapter, modelRunId, error) {
|
|
690
|
-
if (!modelRunId) {
|
|
691
|
-
return;
|
|
692
|
-
}
|
|
693
|
-
(0, mama_core_1.failModelRunInAdapter)(adapter, modelRunId, codeActErrorSummary(error));
|
|
694
|
-
}
|
|
695
|
-
function resolveOwnerEventTerminalReceipt(batch, deps) {
|
|
696
|
-
// Crash-recovery mirror of classifyOwnerEventOutcome. A ledger write that
|
|
697
|
-
// named this batch's events as its cause (evidence_effects) or a confirmed
|
|
698
|
-
// deliverable (drive_upload) is a durable outcome even if the run died after
|
|
699
|
-
// it - without this, a task created before a transport error is created again
|
|
700
|
-
// on retry. A confirmed telegram_send alone is not a receipt, and the effect
|
|
701
|
-
// ledger's (batch, action_key) idempotency makes that retry safe from a second
|
|
702
|
-
// send. A persisted Board acceptance is no longer a receipt.
|
|
703
|
-
const ledgerEffects = deps.taskLedger.effectsCausedBy(batch.eventIds, batch.createdAt);
|
|
704
|
-
const confirmedEffects = deps.ownerEventEffectLedger
|
|
705
|
-
.confirmedKinds(batch.id)
|
|
706
|
-
.filter((kind) => kind !== 'telegram_send');
|
|
707
|
-
const genericEffects = deps.ownerActionEffectLedger?.confirmedKindsForOccurrence(`owner-event:${batch.id}`) ?? [];
|
|
708
|
-
const durable = [...new Set([...ledgerEffects, ...confirmedEffects, ...genericEffects])];
|
|
709
|
-
if (durable.length > 0) {
|
|
710
|
-
return { status: 'acted', tools: durable, ownerDecisionRequested: false };
|
|
711
|
-
}
|
|
712
|
-
if (deps.taskLedger.maxNoUpdateId(`owner-event:${batch.id}`) > 0) {
|
|
713
|
-
return { status: 'no_update', tools: [] };
|
|
714
|
-
}
|
|
715
|
-
return null;
|
|
716
|
-
}
|
|
717
|
-
/**
|
|
718
|
-
* Execute start command
|
|
719
|
-
*/
|
|
720
|
-
async function startCommand(options = {}) {
|
|
721
|
-
console.log('\n🚀 Starting MAMA Standalone\n');
|
|
722
|
-
// Check if already running
|
|
723
|
-
const runningInfo = await (0, pid_manager_js_1.isDaemonRunning)();
|
|
724
|
-
if (runningInfo) {
|
|
725
|
-
console.log(`⚠️ MAMA is already running. (PID: ${runningInfo.pid})`);
|
|
726
|
-
console.log(' To stop it: mama stop\n');
|
|
727
|
-
process.exit(1);
|
|
728
|
-
}
|
|
729
|
-
// Clean up ALL stale mama daemon processes (not just port holders).
|
|
730
|
-
// Zombie daemons may stay alive via Slack Socket Mode without holding any port.
|
|
731
|
-
await (0, stop_js_1.killAllMamaWatchdogs)();
|
|
732
|
-
await (0, stop_js_1.killAllMamaDaemons)();
|
|
733
|
-
await (0, stop_js_1.killProcessesOnPorts)([3847, 3849]);
|
|
734
|
-
// Check config exists
|
|
735
|
-
if (!(0, config_manager_js_1.configExists)()) {
|
|
736
|
-
console.log('⚠️ Config file not found.');
|
|
737
|
-
console.log(' Initialize first: mama init\n');
|
|
738
|
-
process.exit(1);
|
|
739
|
-
}
|
|
740
|
-
// Load config
|
|
741
|
-
let config;
|
|
742
|
-
try {
|
|
743
|
-
config = await (0, config_manager_js_1.initConfig)();
|
|
744
|
-
}
|
|
745
|
-
catch (error) {
|
|
746
|
-
console.error(`Failed to load config: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
747
|
-
process.exit(1);
|
|
748
|
-
}
|
|
749
|
-
const backend = requireRuntimeBackend(config.agent.backend);
|
|
750
|
-
process.env.MAMA_BACKEND = backend;
|
|
751
|
-
if (backend === 'codex') {
|
|
752
|
-
console.log('✓ Codex app-server backend (authentication handled by Codex login)');
|
|
753
|
-
}
|
|
754
|
-
else if (backend === 'cline') {
|
|
755
|
-
console.log('✓ Cline CLI backend (authentication handled by Cline)');
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
758
|
-
console.log('✓ Claude CLI mode (OAuth token not needed)');
|
|
759
|
-
}
|
|
760
|
-
if (options.foreground) {
|
|
761
|
-
// Run in foreground
|
|
762
|
-
console.log('Starting agent loop (foreground)... ✓\n');
|
|
763
|
-
console.log('MAMA is running in foreground.');
|
|
764
|
-
console.log('Press Ctrl+C to stop.\n');
|
|
765
|
-
await (0, pid_manager_js_1.writePid)(process.pid);
|
|
766
|
-
await printStartOnboardingStatus();
|
|
767
|
-
await runAgentLoop(config);
|
|
768
|
-
}
|
|
769
|
-
else {
|
|
770
|
-
// Run as daemon
|
|
771
|
-
process.stdout.write('Starting agent loop... ');
|
|
772
|
-
try {
|
|
773
|
-
const daemonPid = await (0, daemon_js_1.startDaemon)();
|
|
774
|
-
console.log('✓');
|
|
775
|
-
console.log(`\nMAMA is running in the background.`);
|
|
776
|
-
console.log(`PID: ${daemonPid}\n`);
|
|
777
|
-
console.log('Check status: mama status');
|
|
778
|
-
console.log('Stop: mama stop\n');
|
|
779
|
-
await printStartOnboardingStatus();
|
|
780
|
-
}
|
|
781
|
-
catch (error) {
|
|
782
|
-
console.log('❌');
|
|
783
|
-
console.error(`\nFailed to start daemon: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
784
|
-
process.exit(1);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
function buildStartOnboardingOutput(state) {
|
|
789
|
-
return state.complete ? null : (0, agent_contract_js_1.renderContractStatus)(state);
|
|
790
|
-
}
|
|
791
|
-
async function printStartOnboardingStatus() {
|
|
792
|
-
try {
|
|
793
|
-
const output = buildStartOnboardingOutput((0, agent_contract_js_1.assessOnboarding)(await (0, assess_live_js_1.collectAssessDeps)()));
|
|
794
|
-
if (output) {
|
|
795
|
-
process.stdout.write(`${output}\n\n`);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
catch (error) {
|
|
799
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
800
|
-
process.stdout.write(`Onboarding: unavailable\n ${message}\n\n`);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
/**
|
|
804
|
-
* Run agent loop (for foreground and daemon mode).
|
|
805
|
-
*
|
|
806
|
-
* This is the linear orchestrator — each phase calls one or more
|
|
807
|
-
* init functions and threads their results into the next phase.
|
|
808
|
-
*
|
|
809
|
-
* Phase 1: Foundation (config, db, oauth, metrics)
|
|
810
|
-
* Phase 2: Session + Tool + Agent Loop
|
|
811
|
-
* Phase 3: MAMA Core API
|
|
812
|
-
* Phase 4: MessageRouter
|
|
813
|
-
* Phase 5: Graph Handler + Embedding
|
|
814
|
-
* Phase 6: Cron Scheduler
|
|
815
|
-
* Phase 7: Gateways
|
|
816
|
-
* Phase 8: Gateway Wiring
|
|
817
|
-
* Phase 9: Heartbeat + Connectors
|
|
818
|
-
* Phase 10: API Server + Routes
|
|
819
|
-
* Phase 11: Server Start + Shutdown
|
|
820
|
-
*/
|
|
821
|
-
async function runAgentLoop(config, options = {}) {
|
|
822
|
-
// ── Phase 1: Foundation ───────────────────────────────────────────────────
|
|
823
|
-
// Fails the boot on the retired MAMA_STAGE2_WORKORDERS legacy pin
|
|
824
|
-
// (workorders are the only run path since v0.28.0).
|
|
825
|
-
const temporalStartup = (0, temporal_runtime_js_1.preflightTemporalStartup)(process.env);
|
|
826
|
-
const runtimeBackend = requireRuntimeBackend(config.agent.backend);
|
|
827
|
-
const { connectorConfigLoadResult, privateConnectorPolicy } = (0, connector_bootstrap_js_1.resolveRuntimeConnectorBootstrap)((0, config_loader_js_1.loadConnectorConfig)());
|
|
828
|
-
// ONE owner role for every model turn: chat, event, and scheduled.
|
|
829
|
-
const ownerRole = (0, owner_runtime_js_1.projectOwnerRuntimeRole)(config.roles?.definitions.owner_console ?? types_js_1.DEFAULT_ROLES.definitions.owner_console);
|
|
830
|
-
const temporalPolicy = temporalStartup.temporalFlag === 'on'
|
|
831
|
-
? buildTurnAgentPolicy('temporal', config.agent.model, runtimeBackend, privateConnectorPolicy, [], ownerRole)
|
|
832
|
-
: null;
|
|
833
|
-
const temporalEffectiveTools = temporalPolicy
|
|
834
|
-
? (0, tool_policy_js_1.projectCodeActToolPolicy)({
|
|
835
|
-
tier: (0, tool_policy_js_1.requireCodeActTier)(temporalPolicy.agentContext.tier),
|
|
836
|
-
role: temporalPolicy.agentContext.role,
|
|
837
|
-
}).names
|
|
838
|
-
: [];
|
|
839
|
-
const temporalAvailableTools = tool_registry_js_1.ToolRegistry.getValidToolNames();
|
|
840
|
-
if (temporalStartup.temporalFlag === 'on' &&
|
|
841
|
-
(!temporalEffectiveTools.includes('task_temporal_reconcile') ||
|
|
842
|
-
!temporalAvailableTools.includes('task_temporal_reconcile'))) {
|
|
843
|
-
throw new Error('temporal reconciliation tool policy or transport registry is incompatible');
|
|
844
|
-
}
|
|
845
|
-
const startupBackend = runtimeBackend;
|
|
846
|
-
const usesCodexBackend = startupBackend === 'codex' || (0, utilities_js_1.hasCodexBackendConfigured)(config);
|
|
847
|
-
if (usesCodexBackend) {
|
|
848
|
-
const codexCommand = (0, utilities_js_1.resolveCodexCommandForStartup)();
|
|
849
|
-
process.env.MAMA_CODEX_COMMAND = codexCommand;
|
|
850
|
-
console.log(`✓ Codex CLI backend (command: ${codexCommand})`);
|
|
851
|
-
}
|
|
852
|
-
const usesClineBackend = startupBackend === 'cline' || (0, utilities_js_1.hasClineBackendConfigured)(config);
|
|
853
|
-
if (usesClineBackend) {
|
|
854
|
-
const clineCommand = (0, utilities_js_1.resolveClineCommandForStartup)(config.agent.cline_command);
|
|
855
|
-
process.env.MAMA_CLINE_COMMAND = clineCommand;
|
|
856
|
-
console.log(`✓ Cline CLI backend (command: ${clineCommand})`);
|
|
857
|
-
}
|
|
858
|
-
if (startupBackend === 'claude') {
|
|
859
|
-
console.log('✓ Claude CLI mode (ToS compliance)');
|
|
860
|
-
}
|
|
861
|
-
// Provision default persona templates and multi-agent config on first start
|
|
862
|
-
try {
|
|
863
|
-
await (0, config_manager_js_1.provisionDefaults)();
|
|
864
|
-
}
|
|
865
|
-
catch (error) {
|
|
866
|
-
console.warn(`[Provision] Warning: ${error instanceof Error ? error.message : String(error)}`);
|
|
867
|
-
}
|
|
868
|
-
const oauthManager = new index_js_1.OAuthManager();
|
|
869
|
-
// Initialize database for session storage
|
|
870
|
-
const dbPath = (0, config_manager_js_1.expandPath)(config.database.path).replace('mama-memory.db', 'mama-sessions.db');
|
|
871
|
-
const db = new sqlite_js_1.default(dbPath);
|
|
872
|
-
// Initialize metrics store, health score service, and health check service
|
|
873
|
-
const { metricsStore, metricsCleanup, healthService, healthCheckService, metricsInterval } = await (0, metrics_init_js_1.initMetrics)(config, db, utilities_js_1.EMBEDDING_PORT);
|
|
874
|
-
// ── Phase 2: Session + Tool + Agent Loop ──────────────────────────────────
|
|
875
|
-
const sessionStore = new index_js_2.SessionStore(db);
|
|
876
|
-
// TG-05/TG-06: durable report delivery ledger. Conversation continuity is
|
|
877
|
-
// owned by the standing owner runtime, so this store never injects reports.
|
|
878
|
-
const reportContextStore = new telegram_report_context_store_js_1.TelegramReportContextStore(db);
|
|
879
|
-
// Establish one canonical private workspace for gateway files, OCR, Drive,
|
|
880
|
-
// Telegram media, and the persona runtime. An explicit environment override
|
|
881
|
-
// remains authoritative; otherwise honor config.workspace.path.
|
|
882
|
-
const workspaceRoot = (0, config_manager_js_1.expandPath)(process.env.MAMA_WORKSPACE || config.workspace?.path || '~/.mama/workspace');
|
|
883
|
-
process.env.MAMA_WORKSPACE = workspaceRoot;
|
|
884
|
-
// Initialize channel history with SQLite persistence (Sprint 3 F5)
|
|
885
|
-
(0, index_js_2.initChannelHistory)(db);
|
|
886
|
-
const envelopeBootstrap = (0, envelope_bootstrap_js_1.buildRuntimeEnvelopeBootstrap)(db, config, process.env, connectorConfigLoadResult);
|
|
887
|
-
const mamaDbPath = (0, config_manager_js_1.expandPath)(config.database.path);
|
|
888
|
-
const toolExecutor = new gateway_tool_executor_js_1.GatewayToolExecutor({
|
|
889
|
-
mamaDbPath: mamaDbPath,
|
|
890
|
-
sessionStore: sessionStore,
|
|
891
|
-
rolesConfig: config.roles, // Pass roles from config.yaml
|
|
892
|
-
envelopeIssuanceMode: envelopeBootstrap.metadata.issuance,
|
|
893
|
-
metricsStore,
|
|
894
|
-
privateConnectorPolicy,
|
|
895
|
-
});
|
|
896
|
-
process.env.MAMA_BACKEND = runtimeBackend;
|
|
897
|
-
const agentLoopBackend = runtimeBackend;
|
|
898
|
-
// Initialize main agent loop + client (reasoning state is closure-scoped inside)
|
|
899
|
-
const { agentLoop, agentLoopClient } = (0, agent_loop_init_js_1.initMainAgentLoop)(config, oauthManager, db, metricsStore, agentLoopBackend, toolExecutor, {
|
|
900
|
-
...options,
|
|
901
|
-
envelopeIssuanceMode: envelopeBootstrap.metadata.issuance,
|
|
902
|
-
});
|
|
903
|
-
// ── Phase 3: MAMA Core API ────────────────────────────────────────────────
|
|
904
|
-
const { mamaApi, mamaApiClient, connectorExtractionFn, stopExtraction } = await (0, mama_core_init_js_1.initMamaCore)(config);
|
|
905
|
-
// Wire the boot MAMA API onto the shared executor so it never lazily builds a
|
|
906
|
-
// SECOND API/adapter stack against the same DB (initializeMAMAApi). This also
|
|
907
|
-
// lets the memory agent fold into the shared executor (Task 7) instead of
|
|
908
|
-
// carrying its own private instance just for this API.
|
|
909
|
-
toolExecutor.setMamaApi(mamaApi);
|
|
910
|
-
// getAdapter is still used directly in this file for DB queries after initDB has run
|
|
911
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
912
|
-
const { getAdapter } = require('@jungjaehoon/mama-core/db-manager');
|
|
913
|
-
const coreAdapter = getAdapter();
|
|
914
|
-
// A native child's model run is closed by the child's own terminal status, which a hard
|
|
915
|
-
// process death never delivers. Nothing at boot can confirm what such a child did, so
|
|
916
|
-
// its run is failed by name rather than left reading as work still in flight.
|
|
917
|
-
const orphanedSubagentRuns = (0, subagent_run_reconcile_js_1.failOrphanedSubagentModelRuns)(coreAdapter);
|
|
918
|
-
if (orphanedSubagentRuns > 0) {
|
|
919
|
-
console.warn(`[subagent] failed ${orphanedSubagentRuns} model run(s) left running by a previous process`);
|
|
920
|
-
}
|
|
921
|
-
const principalRegistry = createCorePrincipalRegistry(coreAdapter);
|
|
922
|
-
toolExecutor.setPrincipalRepository(principalRegistry);
|
|
923
|
-
(0, owner_backfill_js_1.backfillTelegramOwner)({
|
|
924
|
-
telegram: config.telegram,
|
|
925
|
-
registry: principalRegistry,
|
|
926
|
-
now: Date.now(),
|
|
927
|
-
logger: principalRegistryLogger,
|
|
928
|
-
});
|
|
929
|
-
const principalResolver = principalRegistry.resolveByExternal.bind(principalRegistry);
|
|
930
|
-
const contextCompileService = (0, context_compile_service_js_1.createContextCompileService)({
|
|
931
|
-
memoryAdapter: coreAdapter,
|
|
932
|
-
// Raw visibility comes from the owner's connector config, not from the derived scope
|
|
933
|
-
// columns. Without this the compile reads nothing: measured on the live index, the
|
|
934
|
-
// scope-based predicate returns 0 of 30,671 events for the input shape sent here.
|
|
935
|
-
channelGrant: read_js_1.liveBoundaryChannels,
|
|
936
|
-
});
|
|
937
|
-
toolExecutor.setContextCompileService(contextCompileService);
|
|
938
|
-
agentLoop.setContextCompileService(contextCompileService);
|
|
939
|
-
// ── Phase 4: Memory Agent + MessageRouter ─────────────────────────────────
|
|
940
|
-
const messageRouter = createRuntimeMessageRouter({
|
|
941
|
-
sessionStore,
|
|
942
|
-
agentLoopClient,
|
|
943
|
-
mamaApiClient,
|
|
944
|
-
config: (0, message_router_config_js_1.resolveMessageRouterConfig)(config, runtimeBackend),
|
|
945
|
-
envelopeConfig: envelopeBootstrap.envelopeConfig,
|
|
946
|
-
envelopeAuthority: envelopeBootstrap.envelopeAuthority,
|
|
947
|
-
memberGrantReader: principalRegistry,
|
|
948
|
-
dependencies: {
|
|
949
|
-
privateConnectorPolicy,
|
|
950
|
-
// Report delivery is receipted by the delivery ledger. Conversation
|
|
951
|
-
// recovery belongs only to the owner-runtime journal.
|
|
952
|
-
},
|
|
953
|
-
});
|
|
954
|
-
messageRouter.setSessionsDb(db);
|
|
955
|
-
// validationService wired after creation (Phase 5 below)
|
|
956
|
-
// One MAMA: memory judgment stays in the owner turn through mama_save and
|
|
957
|
-
// deterministic owner-policy observation. Do not boot a second model identity
|
|
958
|
-
// that re-reads every conversation after the owner agent has answered.
|
|
959
|
-
// ── Phase 5: Graph Handler + Embedding ────────────────────────────────────
|
|
960
|
-
// Create singleton UI command queue for Agent↔Viewer communication
|
|
961
|
-
const uiCommandQueue = new ui_command_handler_js_1.UICommandQueue();
|
|
962
|
-
// Prepare graph handler options (will be populated after gateways init)
|
|
963
|
-
const graphHandlerOptions = {
|
|
964
|
-
healthService: healthService ?? undefined,
|
|
965
|
-
healthCheckService,
|
|
966
|
-
sessionsDb: db,
|
|
967
|
-
uiCommandQueue,
|
|
968
|
-
};
|
|
969
|
-
const codeActRawConnectors = resolveCodeActRawConnectors(connectorConfigLoadResult.enabledNames);
|
|
970
|
-
// Wire uiCommandQueue into messageRouter for page context awareness
|
|
971
|
-
messageRouter.setUICommandQueue(uiCommandQueue);
|
|
972
|
-
// Wire sessionsDb into gateway tool executor
|
|
973
|
-
toolExecutor.setSessionsDb(db);
|
|
974
|
-
agentLoop.setSessionsDb(db);
|
|
975
|
-
// Wire up Code-Act executor for POST /api/code-act endpoint
|
|
976
|
-
// Always register: Dashboard/Wiki agents use code-act via MCP → HTTP proxy
|
|
977
|
-
const executeLegacyCodeAct = async (code, codeActContext) => {
|
|
978
|
-
const { CodeActSandbox, HostBridge } = await import('../../agent/code-act/index.js');
|
|
979
|
-
const sandbox = new CodeActSandbox();
|
|
980
|
-
const legacyRequestContext = codeActContext
|
|
981
|
-
? { ...codeActContext, agentId: undefined }
|
|
982
|
-
: undefined;
|
|
983
|
-
const resolvedCodeActPolicy = resolveCodeActAgentPolicy(legacyRequestContext, config.multi_agent?.agents, config.multi_agent?.default_agent || 'conductor');
|
|
984
|
-
if (resolvedCodeActPolicy.error) {
|
|
985
|
-
return { success: false, error: resolvedCodeActPolicy.error };
|
|
986
|
-
}
|
|
987
|
-
const codeActAgentId = resolvedCodeActPolicy.agentId;
|
|
988
|
-
const codeActPolicy = resolvedCodeActPolicy.policy ?? {};
|
|
989
|
-
const codeActRole = privateConnectorPolicy.projectRole('legacy-unbound', buildCodeActRole(codeActPolicy));
|
|
990
|
-
const codeActReadOnly = isTruthyEnvValue(process.env.MAMA_CODE_ACT_READ_ONLY);
|
|
991
|
-
const codeActTier = codeActReadOnly ? 3 : 2;
|
|
992
|
-
const instanceId = (0, node_crypto_1.randomUUID)();
|
|
993
|
-
let executionContext = null;
|
|
994
|
-
if (envelopeBootstrap.envelopeAuthority && envelopeBootstrap.metadata.issuance !== 'off') {
|
|
995
|
-
const projectId = (0, reactive_config_js_1.resolveReactiveProjectRoot)(config, process.env);
|
|
996
|
-
const projectRef = { kind: 'project', id: projectId };
|
|
997
|
-
const memoryScopes = uniqueMemoryScopes((0, scope_context_js_1.deriveMemoryScopes)({
|
|
998
|
-
source: 'watch',
|
|
999
|
-
channelId: 'api:code-act',
|
|
1000
|
-
userId: 'api',
|
|
1001
|
-
projectId,
|
|
1002
|
-
}));
|
|
1003
|
-
const wallSeconds = Math.min(Math.max(Math.floor((config.timeouts?.agent_ms ?? 300_000) / 1000), 1), 300);
|
|
1004
|
-
const envelope = envelopeBootstrap.envelopeAuthority.buildAndPersist({
|
|
1005
|
-
agent_id: codeActAgentId,
|
|
1006
|
-
instance_id: instanceId,
|
|
1007
|
-
source: 'watch',
|
|
1008
|
-
channel_id: 'api:code-act',
|
|
1009
|
-
trigger_context: { user_text: '<api-code-act invocation>' },
|
|
1010
|
-
scope: {
|
|
1011
|
-
project_refs: [projectRef],
|
|
1012
|
-
raw_connectors: [
|
|
1013
|
-
...privateConnectorPolicy.projectRawConnectors('legacy-unbound', codeActRawConnectors),
|
|
1014
|
-
],
|
|
1015
|
-
memory_scopes: memoryScopes,
|
|
1016
|
-
allowed_destinations: [],
|
|
1017
|
-
},
|
|
1018
|
-
tier: codeActTier,
|
|
1019
|
-
budget: { wall_seconds: wallSeconds },
|
|
1020
|
-
expires_at: new Date(Date.now() + wallSeconds * 1000 + 30_000).toISOString(),
|
|
1021
|
-
});
|
|
1022
|
-
const roleName = `code_act_${codeActAgentId}`;
|
|
1023
|
-
const role = codeActRole;
|
|
1024
|
-
const agentContext = {
|
|
1025
|
-
source: 'watch',
|
|
1026
|
-
platform: 'cli',
|
|
1027
|
-
roleName,
|
|
1028
|
-
role,
|
|
1029
|
-
session: {
|
|
1030
|
-
sessionId: `api:code-act:${instanceId}`,
|
|
1031
|
-
channelId: 'api:code-act',
|
|
1032
|
-
startedAt: new Date(),
|
|
1033
|
-
},
|
|
1034
|
-
capabilities: ['code_act'],
|
|
1035
|
-
limitations: codeActReadOnly ? ['Code-Act read-only mode: memory writes disabled'] : [],
|
|
1036
|
-
tier: codeActTier,
|
|
1037
|
-
backend: runtimeBackend,
|
|
1038
|
-
};
|
|
1039
|
-
executionContext = {
|
|
1040
|
-
agentContext,
|
|
1041
|
-
agentId: codeActAgentId,
|
|
1042
|
-
source: 'watch',
|
|
1043
|
-
channelId: 'api:code-act',
|
|
1044
|
-
envelope,
|
|
1045
|
-
executionSurface: 'code_act',
|
|
1046
|
-
};
|
|
1047
|
-
}
|
|
1048
|
-
const parentRun = bindCodeActParentModelRun(getAdapter(), executionContext, {
|
|
1049
|
-
inputSnapshotRef: `code-act:${instanceId}`,
|
|
1050
|
-
inputRefs: {
|
|
1051
|
-
tool: 'code_act',
|
|
1052
|
-
source: 'api',
|
|
1053
|
-
channel_id: 'api:code-act',
|
|
1054
|
-
read_only: codeActReadOnly,
|
|
1055
|
-
},
|
|
1056
|
-
});
|
|
1057
|
-
executionContext = parentRun.executionContext;
|
|
1058
|
-
const bridge = new HostBridge(toolExecutor, new role_manager_js_1.RoleManager({ rolesConfig: config.roles ?? types_js_1.DEFAULT_ROLES }), executionContext);
|
|
1059
|
-
const toolCalls = [];
|
|
1060
|
-
const hostToolExecutions = [];
|
|
1061
|
-
bridge.onToolUse = (toolName, input, result) => {
|
|
1062
|
-
if (result !== undefined) {
|
|
1063
|
-
toolCalls.push({ name: toolName, input });
|
|
1064
|
-
const resultRecord = result;
|
|
1065
|
-
hostToolExecutions.push({
|
|
1066
|
-
name: toolName,
|
|
1067
|
-
success: resultRecord.success === true,
|
|
1068
|
-
...(typeof resultRecord.code === 'string' ? { code: resultRecord.code } : {}),
|
|
1069
|
-
});
|
|
1070
|
-
if (CODE_ACT_MUTATION_TOOLS.has(toolName)) {
|
|
1071
|
-
codeActLogger.warn('[CodeAct] mutation tool call', {
|
|
1072
|
-
toolName,
|
|
1073
|
-
success: Boolean(result.success),
|
|
1074
|
-
readOnly: codeActReadOnly,
|
|
1075
|
-
envelopeHash: executionContext?.envelope?.envelope_hash ?? null,
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
};
|
|
1080
|
-
const previousRoutingContext = toolExecutor.getCurrentAgentRoutingContext();
|
|
1081
|
-
try {
|
|
1082
|
-
// Set default agent context for /api/code-act calls (Conductor, tiered sandbox).
|
|
1083
|
-
// Per-request executionContext carries envelope data; this routing context is legacy fallback.
|
|
1084
|
-
toolExecutor.setCurrentAgentContext(codeActAgentId, 'api', 'code-act');
|
|
1085
|
-
// Tier+role injection is unchanged; the bridge derives tool_search/tool_describe from
|
|
1086
|
-
// exactly the functions it registers here, so this route gains discovery without any
|
|
1087
|
-
// change to which gateway functions it authorizes.
|
|
1088
|
-
bridge.injectInto(sandbox, codeActTier, codeActRole);
|
|
1089
|
-
const result = await sandbox.execute(code, { signal: executionContext?.signal });
|
|
1090
|
-
finalizeCodeActParentModelRun(getAdapter(), parentRun.modelRunId, result);
|
|
1091
|
-
return serializeCodeActExecutionResult(result, toolCalls, hostToolExecutions);
|
|
1092
|
-
}
|
|
1093
|
-
catch (error) {
|
|
1094
|
-
failCodeActParentModelRun(getAdapter(), parentRun.modelRunId, error);
|
|
1095
|
-
throw error;
|
|
1096
|
-
}
|
|
1097
|
-
finally {
|
|
1098
|
-
toolExecutor.restoreCurrentAgentRoutingContext(previousRoutingContext);
|
|
1099
|
-
}
|
|
1100
|
-
};
|
|
1101
|
-
graphHandlerOptions.executeCodeAct = (0, code_act_executor_js_1.createCodeActExecutor)({
|
|
1102
|
-
registry: run_context_registry_js_1.runContextRegistry,
|
|
1103
|
-
gatewayToolExecutor: toolExecutor,
|
|
1104
|
-
executeLegacy: executeLegacyCodeAct,
|
|
1105
|
-
});
|
|
1106
|
-
// Pre-warm Code-Act WASM module for fast first execution
|
|
1107
|
-
(async () => {
|
|
1108
|
-
try {
|
|
1109
|
-
const { CodeActSandbox } = await import('../../agent/code-act/index.js');
|
|
1110
|
-
await CodeActSandbox.warmup();
|
|
1111
|
-
}
|
|
1112
|
-
catch (err) {
|
|
1113
|
-
console.warn('[CodeAct] WASM warmup failed (non-fatal):', err);
|
|
1114
|
-
}
|
|
1115
|
-
})();
|
|
1116
|
-
const graphHandler = (0, graph_api_js_1.createGraphHandler)(graphHandlerOptions);
|
|
1117
|
-
// Seed initial agent versions from config (version 1 for new agents)
|
|
1118
|
-
// initAgentTables is idempotent (CREATE IF NOT EXISTS) — safe to call before apiServer
|
|
1119
|
-
(0, agent_store_js_1.initAgentTables)(db);
|
|
1120
|
-
(0, store_js_1.initValidationTables)(db);
|
|
1121
|
-
// Wire validation session service into tool executor + message router
|
|
1122
|
-
const validationService = new session_service_js_1.ValidationSessionService(db);
|
|
1123
|
-
toolExecutor.setValidationService(validationService);
|
|
1124
|
-
messageRouter.setValidationService(validationService);
|
|
1125
|
-
agentLoop.setValidationService(validationService);
|
|
1126
|
-
// Ensure current primary system agents exist in config. Legacy self-paced
|
|
1127
|
-
// dashboard/wiki agents are opt-in and must not be backfilled here.
|
|
1128
|
-
if (!config.multi_agent) {
|
|
1129
|
-
config.multi_agent = (0, config_manager_js_1.getDefaultMultiAgentConfig)();
|
|
1130
|
-
}
|
|
1131
|
-
if (!config.multi_agent.agents) {
|
|
1132
|
-
config.multi_agent.agents = {};
|
|
1133
|
-
}
|
|
1134
|
-
const osAgents = {
|
|
1135
|
-
'os-agent': {
|
|
1136
|
-
name: 'OS Agent',
|
|
1137
|
-
display_name: '🖥️ OS Agent',
|
|
1138
|
-
trigger_prefix: '!os',
|
|
1139
|
-
persona_file: '~/.mama/personas/os-agent.md',
|
|
1140
|
-
tier: 1,
|
|
1141
|
-
backend: runtimeBackend,
|
|
1142
|
-
model: config.agent.model,
|
|
1143
|
-
can_delegate: true,
|
|
1144
|
-
enabled: true,
|
|
1145
|
-
},
|
|
1146
|
-
memory: {
|
|
1147
|
-
name: 'Memory Agent',
|
|
1148
|
-
display_name: '🧠 Memory',
|
|
1149
|
-
trigger_prefix: '!memory',
|
|
1150
|
-
persona_file: '~/.mama/personas/memory.md',
|
|
1151
|
-
tier: 3,
|
|
1152
|
-
backend: runtimeBackend,
|
|
1153
|
-
model: config.agent.model,
|
|
1154
|
-
can_delegate: false,
|
|
1155
|
-
enabled: true,
|
|
1156
|
-
},
|
|
1157
|
-
};
|
|
1158
|
-
let osAgentsAdded = false;
|
|
1159
|
-
for (const [id, cfg] of Object.entries(osAgents)) {
|
|
1160
|
-
if (!config.multi_agent.agents[id]) {
|
|
1161
|
-
config.multi_agent.agents[id] = cfg;
|
|
1162
|
-
osAgentsAdded = true;
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
// Persist to config.yaml so /api/agents sees them too
|
|
1166
|
-
if (osAgentsAdded) {
|
|
1167
|
-
try {
|
|
1168
|
-
const { saveConfig } = await import('../config/config-manager.js');
|
|
1169
|
-
await saveConfig(config);
|
|
1170
|
-
console.log('✓ OS agents added to config.yaml');
|
|
1171
|
-
}
|
|
1172
|
-
catch {
|
|
1173
|
-
/* non-fatal — runtime config still has them */
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
// Agent version rows belong to the legacy multi-agent persona layer. With
|
|
1177
|
-
// multi_agent disabled (the owner-runtime default) nothing is seeded, so boot
|
|
1178
|
-
// neither reads nor requires any ~/.mama/personas file.
|
|
1179
|
-
if (config.multi_agent.enabled) {
|
|
1180
|
-
const agents = config.multi_agent.agents;
|
|
1181
|
-
for (const [id, cfg] of Object.entries(agents)) {
|
|
1182
|
-
if (!(0, agent_store_js_1.getLatestVersion)(db, id)) {
|
|
1183
|
-
let personaText = null;
|
|
1184
|
-
try {
|
|
1185
|
-
const pPath = (0, config_manager_js_1.expandPath)(cfg.persona_file);
|
|
1186
|
-
if ((0, node_fs_1.existsSync)(pPath))
|
|
1187
|
-
personaText = (0, node_fs_1.readFileSync)(pPath, 'utf-8');
|
|
1188
|
-
}
|
|
1189
|
-
catch {
|
|
1190
|
-
/* ignore */
|
|
1191
|
-
}
|
|
1192
|
-
(0, agent_store_js_1.createAgentVersion)(db, {
|
|
1193
|
-
agent_id: id,
|
|
1194
|
-
snapshot: { model: cfg.model, tier: cfg.tier, backend: cfg.backend },
|
|
1195
|
-
persona_text: personaText,
|
|
1196
|
-
change_note: 'Initial version (migrated from config.yaml)',
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
console.log(`✓ Agent versions seeded (${Object.keys(agents).length} agents)`);
|
|
1201
|
-
}
|
|
1202
|
-
await (0, utilities_js_1.startEmbeddingServerIfAvailable)(messageRouter, sessionStore, graphHandler);
|
|
1203
|
-
// ── Phase 6: Cron Scheduler ───────────────────────────────────────────────
|
|
1204
|
-
const backgroundOwnerContext = (0, owner_event_policy_js_1.buildOwnerEventAgentContext)({
|
|
1205
|
-
backend: runtimeBackend,
|
|
1206
|
-
model: config.agent.model,
|
|
1207
|
-
ownerRole,
|
|
1208
|
-
privateConnectorPolicy,
|
|
1209
|
-
});
|
|
1210
|
-
const issueOwnerRuntimeEnvelope = async (channelId, wallSeconds) => {
|
|
1211
|
-
if (!envelopeBootstrap.envelopeAuthority || envelopeBootstrap.metadata.issuance === 'off') {
|
|
1212
|
-
return undefined;
|
|
1213
|
-
}
|
|
1214
|
-
const projectId = (0, reactive_config_js_1.resolveReactiveProjectRoot)(config, process.env);
|
|
1215
|
-
return envelopeBootstrap.envelopeAuthority.buildAndPersist({
|
|
1216
|
-
agent_id: 'mama-owner',
|
|
1217
|
-
instance_id: (0, node_crypto_1.randomUUID)(),
|
|
1218
|
-
source: 'cron',
|
|
1219
|
-
channel_id: channelId,
|
|
1220
|
-
trigger_context: { user_text: `<owner runtime ${channelId} stimulus>` },
|
|
1221
|
-
scope: {
|
|
1222
|
-
project_refs: [{ kind: 'project', id: projectId }],
|
|
1223
|
-
raw_connectors: [
|
|
1224
|
-
...privateConnectorPolicy.projectRawConnectors('owner_console', codeActRawConnectors),
|
|
1225
|
-
],
|
|
1226
|
-
memory_scopes: uniqueMemoryScopes((0, scope_context_js_1.deriveMemoryScopes)({ source: 'operator', channelId, projectId })),
|
|
1227
|
-
allowed_destinations: [],
|
|
1228
|
-
},
|
|
1229
|
-
tier: 1,
|
|
1230
|
-
budget: { wall_seconds: wallSeconds },
|
|
1231
|
-
expires_at: new Date(Date.now() + wallSeconds * 1000 + 30_000).toISOString(),
|
|
1232
|
-
});
|
|
1233
|
-
};
|
|
1234
|
-
// A native child the owner delegated to keeps working after the parent turn ended, so it
|
|
1235
|
-
// gets its OWN grant with its own wall. The parent's 300-600s envelope, which the child
|
|
1236
|
-
// cannot renew, would refuse every call it made past the parent's clock.
|
|
1237
|
-
//
|
|
1238
|
-
// It keeps the PARENT's channel, not a literal 'subagent': the grant's memory scopes are
|
|
1239
|
-
// derived from the channel (deriveMemoryScopes below), so a hardcoded channel gave the
|
|
1240
|
-
// child a channel scope nobody reads and dropped the parent's channel binding.
|
|
1241
|
-
const issueOwnerSubagentEnvelope = (channelId) => issueOwnerRuntimeEnvelope(channelId, 1800);
|
|
1242
|
-
/** Owner runtime paths must never run unauthorised: no envelope is a loud failure. */
|
|
1243
|
-
const requireOwnerRuntimeEnvelope = async (channelId, wallSeconds) => {
|
|
1244
|
-
const envelope = await issueOwnerRuntimeEnvelope(channelId, wallSeconds);
|
|
1245
|
-
if (!envelope) {
|
|
1246
|
-
throw new Error(`Owner runtime stimulus ${channelId} requires envelope authority`);
|
|
1247
|
-
}
|
|
1248
|
-
return envelope;
|
|
1249
|
-
};
|
|
1250
|
-
const runOwnerStimulus = async (content, channelId) => {
|
|
1251
|
-
return await agentLoop.run(content, {
|
|
1252
|
-
sessionKey: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
1253
|
-
source: 'operator',
|
|
1254
|
-
channelId,
|
|
1255
|
-
sourceMessageRef: `owner-stimulus:${channelId}:${(0, node_crypto_1.randomUUID)()}`,
|
|
1256
|
-
agentContext: backgroundOwnerContext,
|
|
1257
|
-
sessionPolicyRole: ownerRole,
|
|
1258
|
-
prepareEnvelope: () => requireOwnerRuntimeEnvelope(channelId, 600),
|
|
1259
|
-
prepareSubagentEnvelope: () => issueOwnerSubagentEnvelope(channelId),
|
|
1260
|
-
requestTimeoutMs: 600_000,
|
|
1261
|
-
});
|
|
1262
|
-
};
|
|
1263
|
-
// A native subagent the owner delegated to finishes AFTER the owner's turn ended.
|
|
1264
|
-
// Its completion re-enters the one owner subject as a host stimulus, on the same
|
|
1265
|
-
// path heartbeat and cron use, so the owner conversation never waits on long work.
|
|
1266
|
-
const detachSubagentWake = (0, subagent_stimulus_js_1.attachSubagentWake)(agentLoop.getModelRunner(), async (event) => {
|
|
1267
|
-
return await agentLoop.run((0, subagent_stimulus_js_1.buildSubagentStimulus)(event), {
|
|
1268
|
-
sessionKey: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
1269
|
-
source: 'operator',
|
|
1270
|
-
channelId: 'subagent',
|
|
1271
|
-
agentContext: backgroundOwnerContext,
|
|
1272
|
-
sessionPolicyRole: ownerRole,
|
|
1273
|
-
// Same fail-loud rule as every sibling owner path: issuance off must stop the turn,
|
|
1274
|
-
// never let it run unauthorised.
|
|
1275
|
-
prepareEnvelope: () => requireOwnerRuntimeEnvelope('subagent', 300),
|
|
1276
|
-
prepareSubagentEnvelope: () => issueOwnerSubagentEnvelope('subagent'),
|
|
1277
|
-
sourceMessageRef: (0, subagent_stimulus_js_1.subagentStimulusSourceRef)(event),
|
|
1278
|
-
ownerJournalPrompt: (0, subagent_stimulus_js_1.buildSubagentStimulusBlock)(event),
|
|
1279
|
-
lanePriority: 10,
|
|
1280
|
-
});
|
|
1281
|
-
});
|
|
1282
|
-
const cronOwnerRunner = {
|
|
1283
|
-
backendType: runtimeBackend,
|
|
1284
|
-
// A facade over agentLoop.run: whether a native subagent can be spawned is decided by
|
|
1285
|
-
// the real runner underneath, not by this shim.
|
|
1286
|
-
supportsNativeSubagents: agentLoop.supportsNativeSubagents,
|
|
1287
|
-
prompt: async (content) => {
|
|
1288
|
-
const result = await runOwnerStimulus(content, 'cron');
|
|
1289
|
-
return {
|
|
1290
|
-
response: result.response,
|
|
1291
|
-
usage: result.totalUsage,
|
|
1292
|
-
session_id: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
1293
|
-
};
|
|
1294
|
-
},
|
|
1295
|
-
setSessionId: () => { },
|
|
1296
|
-
setSystemPrompt: () => { },
|
|
1297
|
-
isHealthy: () => true,
|
|
1298
|
-
getMetrics: () => ({
|
|
1299
|
-
requestCount: 0,
|
|
1300
|
-
failureCount: 0,
|
|
1301
|
-
avgLatencyMs: 0,
|
|
1302
|
-
lastRequestAt: null,
|
|
1303
|
-
}),
|
|
1304
|
-
stop: () => { },
|
|
1305
|
-
};
|
|
1306
|
-
const { scheduler, cronWorker, cronEmitter } = (0, scheduler_init_js_1.initCronScheduler)(config, () => cronOwnerRunner);
|
|
1307
|
-
// ── Phase 7: Gateways ────────────────────────────────────────────────────
|
|
1308
|
-
const gatewayInit = await (0, gateway_init_js_1.initGateways)(config, messageRouter, toolExecutor, agentLoop, runtimeBackend, db, principalResolver);
|
|
1309
|
-
const { discordGateway, slackGateway, telegramGateway, gateways } = gatewayInit;
|
|
1310
|
-
// The wake subscription is a live listener on the runner; shutdown detaches it.
|
|
1311
|
-
gateways.push({ stop: async () => detachSubagentWake() });
|
|
1312
|
-
// ── Phase 8: Gateway Wiring ──────────────────────────────────────────────
|
|
1313
|
-
const { pluginLoader } = await (0, gateway_wiring_js_1.wireGateways)({
|
|
1314
|
-
config,
|
|
1315
|
-
messageRouter,
|
|
1316
|
-
healthCheckService,
|
|
1317
|
-
graphHandlerOptions,
|
|
1318
|
-
db,
|
|
1319
|
-
discordGateway,
|
|
1320
|
-
slackGateway,
|
|
1321
|
-
telegramGateway,
|
|
1322
|
-
gateways,
|
|
1323
|
-
agentLoop,
|
|
1324
|
-
cronEmitter,
|
|
1325
|
-
});
|
|
1326
|
-
// ── Phase 9: Heartbeat + Connectors ──────────────────────────────────────
|
|
1327
|
-
const { heartbeatScheduler, tokenKeepAlive, healthWarningInterval } = (0, scheduler_init_js_1.initHeartbeat)(config, agentLoop, discordGateway, scheduler, healthCheckService, async () => {
|
|
1328
|
-
return {
|
|
1329
|
-
agentContext: backgroundOwnerContext,
|
|
1330
|
-
sessionPolicyRole: ownerRole,
|
|
1331
|
-
prepareEnvelope: () => issueOwnerRuntimeEnvelope('heartbeat', 300),
|
|
1332
|
-
prepareSubagentEnvelope: () => issueOwnerSubagentEnvelope('heartbeat'),
|
|
1333
|
-
};
|
|
1334
|
-
});
|
|
1335
|
-
// M2.4 freshness: the connector sink nudges the trigger loop when a poll indexes new rows. The
|
|
1336
|
-
// loop is constructed AFTER initConnectors (below), so hand initConnectors a stable forwarder now
|
|
1337
|
-
// and point it at the loop once it exists. Null until then -> nudge no-ops (no loop = nothing to
|
|
1338
|
-
// wake), which remains safe while the trigger loop is still booting or explicitly disabled.
|
|
1339
|
-
const triggerLoopNudge = { current: null };
|
|
1340
|
-
const triggerLoopFullReport = { current: null };
|
|
1341
|
-
// Operator DB + native task ledger (M8): wired UNCONDITIONALLY -- the task
|
|
1342
|
-
// tools are standard gateway tools and must work even when the trigger loop
|
|
1343
|
-
// is off (review finding on #142). Single handle, closed once at shutdown.
|
|
1344
|
-
const operatorDbPath = (0, config_manager_js_1.expandPath)('~/.mama/operator/triggers.db');
|
|
1345
|
-
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(operatorDbPath), { recursive: true });
|
|
1346
|
-
const operatorDb = new sqlite_js_1.default(operatorDbPath);
|
|
1347
|
-
const procedureStore = new procedure_store_js_1.ProcedureStore(operatorDb);
|
|
1348
|
-
toolExecutor.setProcedureStore(procedureStore);
|
|
1349
|
-
messageRouter.setProcedureStore(procedureStore);
|
|
1350
|
-
const readCanonicalOwnerBrief = () => (0, console_brief_js_1.modernizeLegacyBriefMechanism)(procedureStore.read('owner-console-brief', {
|
|
1351
|
-
ownerScope: 'owner:runtime',
|
|
1352
|
-
projectId: (0, reactive_config_js_1.resolveReactiveProjectRoot)(config, process.env),
|
|
1353
|
-
})?.body ?? (0, console_brief_js_1.loadConsoleBrief)());
|
|
1354
|
-
let taskLedger;
|
|
1355
|
-
const refreshTaskBoard = { current: null };
|
|
1356
|
-
try {
|
|
1357
|
-
taskLedger = new task_ledger_js_1.TaskLedger(operatorDb, {
|
|
1358
|
-
onOwnerTaskChangeCommitted: () => refreshTaskBoard.current?.(),
|
|
1359
|
-
});
|
|
1360
|
-
toolExecutor.setTaskLedger(taskLedger);
|
|
1361
|
-
}
|
|
1362
|
-
catch (err) {
|
|
1363
|
-
// Fail loud, but do not leak the handle on a failed boot.
|
|
1364
|
-
operatorDb.close();
|
|
1365
|
-
throw err;
|
|
1366
|
-
}
|
|
1367
|
-
// Durable MAMA owner-event journal. It uses new tables rather than replaying
|
|
1368
|
-
// the legacy default-off Conductor shadow backlog on cutover.
|
|
1369
|
-
const ownerEventInbox = new owner_event_inbox_js_1.OwnerEventInbox(operatorDb);
|
|
1370
|
-
// The host-owned gate is always present. MAMA_BOARD_RECONCILE controls only
|
|
1371
|
-
// delta reconcile scheduling; exact owner-event Board acceptance, boot
|
|
1372
|
-
// recovery, manual refresh, and full verification share this runtime in all
|
|
1373
|
-
// configurations.
|
|
1374
|
-
// Host-owned Board repair gate. Generations are wall time: with the owner-event
|
|
1375
|
-
// intent ledger gone there is no persisted pending generation to seed above.
|
|
1376
|
-
const boardRefreshGate = new board_refresh_gate_js_1.BoardRefreshGate({ initialGeneration: Date.now() });
|
|
1377
|
-
const ownerEventEffectLedger = new owner_event_effects_js_1.OwnerEventEffectLedger(operatorDb);
|
|
1378
|
-
toolExecutor.setOwnerEventEffectLedger(ownerEventEffectLedger);
|
|
1379
|
-
const ownerActionEffectLedger = new owner_action_effects_js_1.OwnerActionEffectLedger(operatorDb);
|
|
1380
|
-
toolExecutor.setOwnerActionEffectLedger(ownerActionEffectLedger);
|
|
1381
|
-
let stopOwnerEventRuntime = null;
|
|
1382
|
-
// S2: leg cadence watchdog - its OWN timer, deliberately outside the
|
|
1383
|
-
// trigger loop (a watchdog inside the thing it watches dies with it).
|
|
1384
|
-
// Legs declare+beat at their own tick sites via the singleton; pages ride
|
|
1385
|
-
// the owner-alert targets registered in gateway wiring. Alarm, never
|
|
1386
|
-
// enforcement; quiet hours honored inside check().
|
|
1387
|
-
const legCadence = (0, leg_cadence_js_1.initLegCadence)(operatorDb);
|
|
1388
|
-
legCadence.declare('workorder-consumer', workorder_consumer_js_1.DEFAULT_TICK_MS);
|
|
1389
|
-
// Declared HERE, not in HeartbeatScheduler.start(): the heartbeat starts
|
|
1390
|
-
// 47 lines before this singleton exists, so a declare there hit null and
|
|
1391
|
-
// the leg was silently unwatched (review, blocking). The scheduler owns
|
|
1392
|
-
// the number; boot owns the ordering.
|
|
1393
|
-
const heartbeatCadenceMs = heartbeatScheduler.declaredCadence();
|
|
1394
|
-
if (heartbeatCadenceMs !== null) {
|
|
1395
|
-
legCadence.declare('heartbeat', heartbeatCadenceMs);
|
|
1396
|
-
}
|
|
1397
|
-
// Failures become evidence (One MAMA Phase 3): one sink over the mama-core database.
|
|
1398
|
-
const issueDb = { prepare: (sql) => mamaCore.getAdapter().prepare(sql) };
|
|
1399
|
-
(0, operational_issues_js_1.ensureOperationalIssuesTable)(issueDb);
|
|
1400
|
-
const recordIssue = (input) => {
|
|
1401
|
-
try {
|
|
1402
|
-
(0, operational_issues_js_1.recordOperationalIssue)(issueDb, input);
|
|
1403
|
-
}
|
|
1404
|
-
catch (error) {
|
|
1405
|
-
console.error(`[operational-issue] record failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1406
|
-
}
|
|
1407
|
-
};
|
|
1408
|
-
toolExecutor.setOperationalIssueSink(recordIssue);
|
|
1409
|
-
// Ledger stagnation probe: deltas keep arriving while no owner task is created for 24h.
|
|
1410
|
-
// Cross-database on purpose (tasks in triggers.db, deltas in mama-memory.db); at most one
|
|
1411
|
-
// record per 12h so occurrences count days, not ticks.
|
|
1412
|
-
let lastStagnationRecordAt = 0;
|
|
1413
|
-
const probeLedgerStagnation = () => {
|
|
1414
|
-
const now = Date.now();
|
|
1415
|
-
if (now - lastStagnationRecordAt < 12 * 60 * 60 * 1000) {
|
|
1416
|
-
return;
|
|
1417
|
-
}
|
|
1418
|
-
try {
|
|
1419
|
-
const dayAgo = now - 24 * 60 * 60 * 1000;
|
|
1420
|
-
const created = taskLedger.countOwnerTasksCreatedSince(dayAgo);
|
|
1421
|
-
const deltas = mamaCore
|
|
1422
|
-
.getAdapter()
|
|
1423
|
-
// indexed_at is ISO text (migration 030); an integer would compare below every row.
|
|
1424
|
-
.prepare(`SELECT count(*) AS n FROM connector_event_index WHERE indexed_at >= ?`)
|
|
1425
|
-
.get(new Date(dayAgo).toISOString())?.n;
|
|
1426
|
-
if (created === 0 && typeof deltas === 'number' && deltas > 0) {
|
|
1427
|
-
lastStagnationRecordAt = now;
|
|
1428
|
-
recordIssue({
|
|
1429
|
-
surface: 'ledger',
|
|
1430
|
-
signature: 'no_task_created_24h',
|
|
1431
|
-
severity: 'error',
|
|
1432
|
-
error: `${deltas} connector deltas indexed in 24h, zero owner tasks created`,
|
|
1433
|
-
nowMs: now,
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
catch (error) {
|
|
1438
|
-
console.error(`[operational-issue] stagnation probe failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1439
|
-
}
|
|
1440
|
-
};
|
|
1441
|
-
// One self-check turn per local day (idempotent on the date key), enqueued from the
|
|
1442
|
-
// watchdog interval so it needs no timer of its own.
|
|
1443
|
-
const enqueueDailySelfCheck = () => {
|
|
1444
|
-
try {
|
|
1445
|
-
const localDate = new Date().toLocaleDateString('sv-SE'); // YYYY-MM-DD in local time
|
|
1446
|
-
// A terminal work order frees its idempotency slot (the unique index excludes terminal
|
|
1447
|
-
// rows), so "one per day" must be checked here: without this, 0.43.0 re-enqueued a
|
|
1448
|
-
// self-check every minute after each completion (8 runs in 26 minutes, live).
|
|
1449
|
-
const prior = taskLedger.findWorkOrderByOccurrence('self-check', (0, workorder_publishers_js_1.selfCheckKey)(localDate));
|
|
1450
|
-
if (prior && prior.status !== 'failed' && prior.status !== 'cancelled') {
|
|
1451
|
-
return; // failed/cancelled rows are dead and stay retryable (task-ledger.ts)
|
|
1452
|
-
}
|
|
1453
|
-
taskLedger.enqueueWorkOrder({
|
|
1454
|
-
workKind: 'self-check',
|
|
1455
|
-
idempotencyKey: (0, workorder_publishers_js_1.selfCheckKey)(localDate),
|
|
1456
|
-
input: { scheduledFor: localDate },
|
|
1457
|
-
});
|
|
1458
|
-
}
|
|
1459
|
-
catch (error) {
|
|
1460
|
-
console.error(`[self-check] enqueue failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1461
|
-
}
|
|
1462
|
-
};
|
|
1463
|
-
agent_loop_init_js_2.budgetStopSink.current = (info) => {
|
|
1464
|
-
try {
|
|
1465
|
-
taskLedger.recordBudgetStop(info);
|
|
1466
|
-
}
|
|
1467
|
-
catch (error) {
|
|
1468
|
-
console.error(`[budget] receipt failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1469
|
-
}
|
|
1470
|
-
recordIssue({
|
|
1471
|
-
surface: 'budget',
|
|
1472
|
-
signature: `run_budget_stop:${info.agentId ?? 'unknown'}`,
|
|
1473
|
-
severity: 'warn',
|
|
1474
|
-
error: `run ${info.modelRunId ?? '(no run id)'} stopped at ${info.budgetTokens} of ${info.runTokenBudget} tokens after ${info.turns} turns`,
|
|
1475
|
-
sourceRef: info.channelKey,
|
|
1476
|
-
ownerAgent: info.agentId,
|
|
1477
|
-
});
|
|
1478
|
-
};
|
|
1479
|
-
toolExecutor.setRepairControls({
|
|
1480
|
-
issueExists: (issueId) => (0, operational_issues_js_1.getOperationalIssue)(issueDb, issueId) !== null,
|
|
1481
|
-
setIssueStatus: (issueId, status) => (0, operational_issues_js_1.setOperationalIssueStatus)(issueDb, issueId, status),
|
|
1482
|
-
notifyOwner: async (line) => {
|
|
1483
|
-
const notify = (0, leg_cadence_js_1.getLegPageNotifier)();
|
|
1484
|
-
if (!notify) {
|
|
1485
|
-
throw new Error('owner notice channel is not configured');
|
|
1486
|
-
}
|
|
1487
|
-
await notify(line);
|
|
1488
|
-
},
|
|
1489
|
-
repairRoot: () => (0, repair_request_js_1.resolveRepairRoot)(),
|
|
1490
|
-
});
|
|
1491
|
-
const legWatchdog = setInterval(() => {
|
|
1492
|
-
probeLedgerStagnation();
|
|
1493
|
-
enqueueDailySelfCheck();
|
|
1494
|
-
try {
|
|
1495
|
-
const { pages, recoveries } = legCadence.check();
|
|
1496
|
-
for (const page of pages) {
|
|
1497
|
-
const minutes = Math.round(page.silentForMs / 60_000);
|
|
1498
|
-
const message = `[leg-watchdog] '${page.name}' has been silent ${minutes}min (declared ${Math.round(page.declaredCadenceMs / 60_000)}min cadence)`;
|
|
1499
|
-
console.error(message);
|
|
1500
|
-
void (0, leg_cadence_js_1.getLegPageNotifier)()?.(message).catch(() => { });
|
|
1501
|
-
}
|
|
1502
|
-
for (const name of recoveries) {
|
|
1503
|
-
const message = `[leg-watchdog] '${name}' recovered`;
|
|
1504
|
-
console.log(message);
|
|
1505
|
-
void (0, leg_cadence_js_1.getLegPageNotifier)()?.(message).catch(() => { });
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1508
|
-
catch (err) {
|
|
1509
|
-
console.error('[leg-watchdog] check failed:', err);
|
|
1510
|
-
}
|
|
1511
|
-
}, 60_000);
|
|
1512
|
-
// ── Stage-2 workorder consumer (plan S2-T3): the only system run path.
|
|
1513
|
-
// Constructed before production runtime assembly registers per-kind
|
|
1514
|
-
// completion hooks, and started only after route registration and recovery
|
|
1515
|
-
// complete.
|
|
1516
|
-
const { temporalFlag } = temporalStartup;
|
|
1517
|
-
// Validate the worker-run timeout override at boot (no-fallback): a malformed
|
|
1518
|
-
// MAMA_WORKER_TIMEOUT_SECONDS must crash the daemon loudly, not silently
|
|
1519
|
-
// revert worker runs to the 300s bound. Mirrors readStage2Flag above.
|
|
1520
|
-
const { resolveWorkerRequestTimeoutMs, attachWorkOrderAttemptContext } = await import('../../operator/worker-run.js');
|
|
1521
|
-
resolveWorkerRequestTimeoutMs();
|
|
1522
|
-
let workOrderConsumer = null;
|
|
1523
|
-
const boardRepairNudge = { current: null };
|
|
1524
|
-
let temporalRuntime = null;
|
|
1525
|
-
gateways.push({
|
|
1526
|
-
stop: async () => {
|
|
1527
|
-
clearInterval(legWatchdog);
|
|
1528
|
-
// All users of the shared operator DB stop inside this one gateway.
|
|
1529
|
-
// Shutdown invokes gateways in parallel, so a separate owner-event
|
|
1530
|
-
// gateway would race its final ACK against this close.
|
|
1531
|
-
await (0, owner_event_loop_js_1.closeOwnerEventBeforeDatabase)(async () => {
|
|
1532
|
-
await stopOwnerEventRuntime?.();
|
|
1533
|
-
stopOwnerEventRuntime = null;
|
|
1534
|
-
}, () => (0, temporal_runtime_js_1.closeTemporalRuntimeBeforeDatabase)(temporalRuntime, workOrderConsumer, () => {
|
|
1535
|
-
try {
|
|
1536
|
-
operatorDb.close();
|
|
1537
|
-
}
|
|
1538
|
-
catch {
|
|
1539
|
-
/* already closed */
|
|
1540
|
-
}
|
|
1541
|
-
})).catch(() => { });
|
|
1542
|
-
},
|
|
1543
|
-
});
|
|
1544
|
-
{
|
|
1545
|
-
const { WorkOrderConsumer } = await import('../../operator/workorder-consumer.js');
|
|
1546
|
-
// Seed the ONE operating brief (user edits win) BEFORE the consumer exists -
|
|
1547
|
-
// a normal install must never hit the brief-missing fail path.
|
|
1548
|
-
(0, console_brief_js_1.ensureConsoleBrief)();
|
|
1549
|
-
const { logActivity: logWorkOrderActivity } = await import('../../db/agent-store.js');
|
|
1550
|
-
// Ops alarm sink (plan D4/E1/G8): constructed OUTSIDE any trigger-loop
|
|
1551
|
-
// block - the consumer runs with the loop off, so its terminal alarms
|
|
1552
|
-
// must too. Chat id: MAMA_OPS_ALERT_CHAT, falling back to the loop's
|
|
1553
|
-
// report chat var.
|
|
1554
|
-
const opsAlertChat = process.env.MAMA_OPS_ALERT_CHAT || process.env.MAMA_TRIGGER_LOOP_REPORT_CHAT || '';
|
|
1555
|
-
const opsAlarm = {
|
|
1556
|
-
configured: Boolean(opsAlertChat && telegramGateway),
|
|
1557
|
-
send: async (line) => {
|
|
1558
|
-
if (telegramGateway && opsAlertChat)
|
|
1559
|
-
await telegramGateway.sendMessage(opsAlertChat, line);
|
|
1560
|
-
},
|
|
1561
|
-
};
|
|
1562
|
-
if (!opsAlarm.configured) {
|
|
1563
|
-
console.log('[stage2] ops alarm sink unconfigured - terminal workorder alarms are LOG-ONLY ' +
|
|
1564
|
-
'(set MAMA_OPS_ALERT_CHAT or MAMA_TRIGGER_LOOP_REPORT_CHAT)');
|
|
1565
|
-
}
|
|
1566
|
-
// AgentLoopClient.runWithContent is optional in its type; a missing method
|
|
1567
|
-
// is a boot-order fault and must throw, not no-op (WorkerRunner adapter).
|
|
1568
|
-
const workerRunner = {
|
|
1569
|
-
// The scheduled contract's delegated shape and the `delegated` attempt state both
|
|
1570
|
-
// follow the ACTIVE runner, not the configured backend name.
|
|
1571
|
-
supportsNativeSubagents: agentLoopClient.supportsNativeSubagents === true,
|
|
1572
|
-
runWithContent: async (content, options) => {
|
|
1573
|
-
if (!agentLoopClient.runWithContent) {
|
|
1574
|
-
throw new Error('[stage2] agentLoopClient.runWithContent unavailable');
|
|
1575
|
-
}
|
|
1576
|
-
const workorderAttemptId = options.workorderAttemptId;
|
|
1577
|
-
const isWikiAttempt = options.wikiTaskRange !== undefined;
|
|
1578
|
-
try {
|
|
1579
|
-
return await agentLoopClient.runWithContent(content, options);
|
|
1580
|
-
}
|
|
1581
|
-
finally {
|
|
1582
|
-
if (isWikiAttempt && typeof workorderAttemptId === 'number') {
|
|
1583
|
-
toolExecutor.releaseWikiAttemptCoverage(workorderAttemptId);
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
},
|
|
1587
|
-
};
|
|
1588
|
-
workOrderConsumer = new WorkOrderConsumer({
|
|
1589
|
-
hasUnsettledEffects: (wo) => ownerActionEffectLedger.hasUnsettledEffects(`workorder:${wo.idempotencyKey}`),
|
|
1590
|
-
hasUnsafeReplayEffects: (wo) => ownerActionEffectLedger.hasUnsafeReplayEffects(`workorder:${wo.idempotencyKey}`),
|
|
1591
|
-
ledger: taskLedger,
|
|
1592
|
-
runner: workerRunner,
|
|
1593
|
-
loadOwnerBrief: readCanonicalOwnerBrief,
|
|
1594
|
-
// One memory for the one owner:runtime thread: whichever lane sends the brief
|
|
1595
|
-
// first satisfies the other, so a correction reaches the thread exactly once.
|
|
1596
|
-
admitOwnerBrief: (brief) => ownerBriefMemory.admit(owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY, brief),
|
|
1597
|
-
retractOwnerBrief: () => ownerBriefMemory.forget(owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY),
|
|
1598
|
-
// Host-rendered pipeline: the ledger's own deadline_priority page, published through
|
|
1599
|
-
// the SAME report publisher report_publish uses (bound after the API routes exist).
|
|
1600
|
-
selfCheckInput: () => ({
|
|
1601
|
-
openIssues: (0, operational_issues_js_1.listOpenOperationalIssues)(issueDb, 20, 'warn').map((issue) => ({
|
|
1602
|
-
issueId: issue.issueId,
|
|
1603
|
-
surface: issue.surface,
|
|
1604
|
-
severity: issue.severity,
|
|
1605
|
-
signature: issue.signature,
|
|
1606
|
-
occurrences: issue.occurrences,
|
|
1607
|
-
firstSeenAt: new Date(issue.firstSeenAt).toISOString(),
|
|
1608
|
-
lastSeenAt: new Date(issue.lastSeenAt).toISOString(),
|
|
1609
|
-
lastError: issue.lastError,
|
|
1610
|
-
})),
|
|
1611
|
-
noUpdateScope: `self-check:${new Date().toLocaleDateString('sv-SE')}`,
|
|
1612
|
-
}),
|
|
1613
|
-
publishPipelineSlot: () => {
|
|
1614
|
-
const refresh = refreshTaskBoard.current;
|
|
1615
|
-
if (!refresh) {
|
|
1616
|
-
throw new Error('task board projection is not bound yet');
|
|
1617
|
-
}
|
|
1618
|
-
refresh();
|
|
1619
|
-
},
|
|
1620
|
-
noticeOwner: (summary) => messageRouter.enqueueOperatorNotice(summary),
|
|
1621
|
-
opsAlarm,
|
|
1622
|
-
runOptionsFor: async (wo) => {
|
|
1623
|
-
// Resolve the run's raw binding before constructing either backend's
|
|
1624
|
-
// role/catalog. The catalog and execution envelope must use the same
|
|
1625
|
-
// projection so an unbound or non-private run never advertises private
|
|
1626
|
-
// connector tools it cannot execute.
|
|
1627
|
-
const workOrderBatch = causeEventIdsFromPayload(wo.payload);
|
|
1628
|
-
let temporalContext;
|
|
1629
|
-
let temporalBinding = null;
|
|
1630
|
-
if (wo.workKind === 'temporal') {
|
|
1631
|
-
temporalContext = (0, temporal_worker_js_1.buildTemporalWorkerContext)(taskLedger, wo);
|
|
1632
|
-
temporalBinding = temporalTaskBinding(taskLedger, temporalContext.taskId);
|
|
1633
|
-
}
|
|
1634
|
-
const projectId = (0, reactive_config_js_1.resolveReactiveProjectRoot)(config, process.env);
|
|
1635
|
-
const reconcileChannelKey = wo.workKind === 'board' &&
|
|
1636
|
-
wo.payload.mode === 'reconcile' &&
|
|
1637
|
-
typeof wo.payload.channelKey === 'string'
|
|
1638
|
-
? wo.payload.channelKey
|
|
1639
|
-
: null;
|
|
1640
|
-
const workOrderScope = workOrderEnvelopeScope({
|
|
1641
|
-
workKind: wo.workKind,
|
|
1642
|
-
projectId,
|
|
1643
|
-
laneConnectors: codeActRawConnectors,
|
|
1644
|
-
temporalBinding,
|
|
1645
|
-
reconcileChannelKey,
|
|
1646
|
-
privateConnectorPolicy,
|
|
1647
|
-
});
|
|
1648
|
-
const workOrderPolicy = buildTurnAgentPolicy(wo.workKind, config.agent.model, runtimeBackend, privateConnectorPolicy, workOrderScope.raw_connectors, ownerRole);
|
|
1649
|
-
const runOptions = attachWorkOrderAttemptContext({
|
|
1650
|
-
gatewayToolsPrompt: workOrderPolicy.gatewayToolsPrompt,
|
|
1651
|
-
agentContext: workOrderPolicy.agentContext,
|
|
1652
|
-
sessionPolicyRole: ownerRole,
|
|
1653
|
-
workOrderBriefProjectionPolicy: workOrderPolicy.briefProjectionPolicy,
|
|
1654
|
-
}, wo.id);
|
|
1655
|
-
// Temporal identity and the required review anchor remain host-bound. Additional
|
|
1656
|
-
// corroboration is selected by the owner and checked against current exact grants.
|
|
1657
|
-
// A reconcile carries the channel's delta batch. Handing it to the run makes every
|
|
1658
|
-
// durable change the run produces rest on it WITHOUT the agent restating anything -
|
|
1659
|
-
// the system knew the batch before the run began. This is the whole difference
|
|
1660
|
-
// between a bounded run and an unbounded one.
|
|
1661
|
-
if (workOrderBatch.length > 0) {
|
|
1662
|
-
runOptions.causeEventIds = workOrderBatch;
|
|
1663
|
-
}
|
|
1664
|
-
if (temporalContext) {
|
|
1665
|
-
runOptions.temporalWorkContext = temporalContext;
|
|
1666
|
-
}
|
|
1667
|
-
if (wo.workKind === 'wiki') {
|
|
1668
|
-
const wikiRange = typeof wo.payload.range === 'object' && wo.payload.range !== null
|
|
1669
|
-
? wo.payload.range
|
|
1670
|
-
: null;
|
|
1671
|
-
runOptions.wikiTaskRange = {
|
|
1672
|
-
ownerDate: typeof wo.payload.ownerDate === 'string' ? wo.payload.ownerDate : null,
|
|
1673
|
-
rangeStartMs: typeof wikiRange?.start_ms === 'number' ? wikiRange.start_ms : null,
|
|
1674
|
-
rangeEndMs: typeof wikiRange?.end_ms === 'number' ? wikiRange.end_ms : null,
|
|
1675
|
-
connectors: Array.isArray(wo.payload.connectors) &&
|
|
1676
|
-
wo.payload.connectors.every((connector) => typeof connector === 'string')
|
|
1677
|
-
? [...wo.payload.connectors]
|
|
1678
|
-
: null,
|
|
1679
|
-
updatedSince: typeof wo.payload.taskUpdatedSince === 'string' ? wo.payload.taskUpdatedSince : null,
|
|
1680
|
-
updatedBefore: typeof wo.payload.taskUpdatedBefore === 'string'
|
|
1681
|
-
? wo.payload.taskUpdatedBefore
|
|
1682
|
-
: null,
|
|
1683
|
-
noUpdateScope: typeof wo.payload.noUpdateScope === 'string' ? wo.payload.noUpdateScope : null,
|
|
1684
|
-
};
|
|
1685
|
-
}
|
|
1686
|
-
// Per-run scoped envelope (live-gate finding, 2026-07-18): gateway
|
|
1687
|
-
// 'model_tool' executions are envelope-gated, and workerRun is a new
|
|
1688
|
-
// caller class with no issuer - without this, every worker tool call
|
|
1689
|
-
// (incl. report_publish) dies 'envelope_missing'. Mirrors the report
|
|
1690
|
-
// lane's issuance (createPersonaReportAsk wiring below); issuance
|
|
1691
|
-
// failure rejects -> failWorkOrder (no envelope-less fallback run).
|
|
1692
|
-
if (envelopeBootstrap.envelopeAuthority && envelopeBootstrap.metadata.issuance !== 'off') {
|
|
1693
|
-
const wallSeconds = Math.min(Math.max(Number(process.env.MAMA_REPORT_WALL_SECONDS) || 900, 60), 1800);
|
|
1694
|
-
const workOrderEnvelopeAuthority = envelopeBootstrap.envelopeAuthority;
|
|
1695
|
-
runOptions.prepareEnvelope = () => workOrderEnvelopeAuthority.buildAndPersist({
|
|
1696
|
-
agent_id: 'mama-owner',
|
|
1697
|
-
instance_id: (0, node_crypto_1.randomUUID)(),
|
|
1698
|
-
// 'watch' = daemon-internal issuing source (closed EnvelopeSource
|
|
1699
|
-
// union; enforcement authorizes on scope, never on source).
|
|
1700
|
-
source: 'watch',
|
|
1701
|
-
channel_id: `worker:${wo.workKind}`,
|
|
1702
|
-
trigger_context: { user_text: `<stage2 workorder ${wo.workKind}#${wo.id}>` },
|
|
1703
|
-
// Identity scopes only - the read mirror is enforcement-layer.
|
|
1704
|
-
scope: workOrderScope,
|
|
1705
|
-
tier: 2,
|
|
1706
|
-
budget: { wall_seconds: wallSeconds },
|
|
1707
|
-
expires_at: new Date(Date.now() + wallSeconds * 1000 + 30_000).toISOString(),
|
|
1708
|
-
});
|
|
1709
|
-
// A native child the turn delegates long maintenance work to keeps working after
|
|
1710
|
-
// the parent attempt returned, so it needs its OWN grant on the SAME scope with a
|
|
1711
|
-
// wall it can actually finish inside. The parent's 900s envelope, which the child
|
|
1712
|
-
// cannot renew, would refuse every call it made past the parent's clock - the same
|
|
1713
|
-
// reason issueOwnerSubagentEnvelope exists for owner turns.
|
|
1714
|
-
const subagentWallSeconds = 1800;
|
|
1715
|
-
runOptions.prepareSubagentEnvelope = () => workOrderEnvelopeAuthority.buildAndPersist({
|
|
1716
|
-
agent_id: 'mama-owner',
|
|
1717
|
-
instance_id: (0, node_crypto_1.randomUUID)(),
|
|
1718
|
-
source: 'watch',
|
|
1719
|
-
channel_id: `worker:${wo.workKind}`,
|
|
1720
|
-
trigger_context: {
|
|
1721
|
-
user_text: `<stage2 workorder subagent ${wo.workKind}#${wo.id}>`,
|
|
1722
|
-
},
|
|
1723
|
-
scope: workOrderScope,
|
|
1724
|
-
tier: 2,
|
|
1725
|
-
budget: { wall_seconds: subagentWallSeconds },
|
|
1726
|
-
expires_at: new Date(Date.now() + subagentWallSeconds * 1000 + 30_000).toISOString(),
|
|
1727
|
-
});
|
|
1728
|
-
}
|
|
1729
|
-
return Object.keys(runOptions).length > 0 ? runOptions : undefined;
|
|
1730
|
-
},
|
|
1731
|
-
onEvent: (event) => {
|
|
1732
|
-
// Telemetry replacement for executeValidatedRun's task_start/complete
|
|
1733
|
-
// rows (plan E4): the ledger row is the durable record; agent_activity
|
|
1734
|
-
// keeps the operational trace queryable.
|
|
1735
|
-
try {
|
|
1736
|
-
logWorkOrderActivity(db, {
|
|
1737
|
-
agent_id: 'mama-owner',
|
|
1738
|
-
agent_version: 0,
|
|
1739
|
-
type: `workorder_${event.type}`,
|
|
1740
|
-
input_summary: `#${event.workOrderId}`,
|
|
1741
|
-
output_summary: event.reason ?? '',
|
|
1742
|
-
// Token telemetry continuity: the legacy persona path recorded
|
|
1743
|
-
// tokens_used via executeValidatedRun; the Stage-2 cutover
|
|
1744
|
-
// (2026-07-21) silently zeroed it, blinding all cost measurement.
|
|
1745
|
-
tokens_used: event.tokensUsed,
|
|
1746
|
-
details: workOrderActivityDetails(event),
|
|
1747
|
-
execution_status: 'completed',
|
|
1748
|
-
trigger_reason: 'workorder-consumer',
|
|
1749
|
-
});
|
|
1750
|
-
}
|
|
1751
|
-
catch {
|
|
1752
|
-
/* telemetry only */
|
|
1753
|
-
}
|
|
1754
|
-
},
|
|
1755
|
-
});
|
|
1756
|
-
// (Consumer stop is folded into the operator-DB gateway above - ordering.)
|
|
1757
|
-
}
|
|
1758
|
-
const temporalTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1759
|
-
const temporalAssembly = (0, temporal_init_js_1.assembleDaemonTemporalRuntime)({
|
|
1760
|
-
flag: temporalFlag,
|
|
1761
|
-
backend: runtimeBackend,
|
|
1762
|
-
envelopeIssuanceMode: envelopeBootstrap.metadata.issuance,
|
|
1763
|
-
effectiveTools: temporalEffectiveTools,
|
|
1764
|
-
availableTools: temporalAvailableTools,
|
|
1765
|
-
transportReady: Boolean(agentLoopClient.runWithContent),
|
|
1766
|
-
timeZone: temporalTimeZone,
|
|
1767
|
-
ledger: taskLedger,
|
|
1768
|
-
consumer: workOrderConsumer,
|
|
1769
|
-
log: (line) => temporalLogger.info(line),
|
|
1770
|
-
});
|
|
1771
|
-
temporalRuntime = temporalAssembly.runtime;
|
|
1772
|
-
const { rawStoreForApi, enabledConnectorNames, connectorSchedulerStop } = await (0, connector_init_js_1.initConnectors)(connectorExtractionFn, {
|
|
1773
|
-
connectorConfigLoadResult,
|
|
1774
|
-
nudge: () => triggerLoopNudge.current?.(),
|
|
1775
|
-
});
|
|
1776
|
-
// Inject rawStore into tool executor for agent_test connector data access
|
|
1777
|
-
if (rawStoreForApi) {
|
|
1778
|
-
toolExecutor.setRawStore(rawStoreForApi);
|
|
1779
|
-
agentLoop.setRawStore(rawStoreForApi);
|
|
1780
|
-
}
|
|
1781
|
-
// Add connector scheduler to graceful shutdown if active
|
|
1782
|
-
if (connectorSchedulerStop) {
|
|
1783
|
-
gateways.push({ stop: () => Promise.resolve(connectorSchedulerStop()) });
|
|
1784
|
-
}
|
|
1785
|
-
// ── Trigger loop (M1, default-on): agent-evolved triggers on the live stream ──
|
|
1786
|
-
// MAMA_TRIGGER_LOOP=0 is the explicit opt-out. Placed after initConnectors (which feeds
|
|
1787
|
-
// connector_event_index) and after mama-core initDB. Read-only: recall/surface/log.
|
|
1788
|
-
const { isOperatorTriggerLoopEnabled, resolveOperatorReportChatId } = await import('../../operator/runtime-config.js');
|
|
1789
|
-
if (isOperatorTriggerLoopEnabled(process.env)) {
|
|
1790
|
-
// Component isolation (PR #119 review): a trigger-loop bootstrap failure (bad import,
|
|
1791
|
-
// DB permission, registry constructor) must not abort the whole daemon before Phase
|
|
1792
|
-
// 10/11 - the gateways/viewer/agent serve independently of this optional leg. The
|
|
1793
|
-
// failure is still surfaced LOUDLY below (console.error), never swallowed silently.
|
|
1794
|
-
try {
|
|
1795
|
-
const { OperatorTriggerLoop } = await import('../../operator/operator-trigger-loop.js');
|
|
1796
|
-
const { ConnectorDeltaRepo } = await import('../../operator/connector-delta-repo.js');
|
|
1797
|
-
const { TriggerRegistry } = await import('../../operator/trigger-registry.js');
|
|
1798
|
-
const { createMamaMemoryPort } = await import('../../operator/mama-memory-port.js');
|
|
1799
|
-
const { reviewTriggerCLI } = await import('../../operator/trigger-review.js');
|
|
1800
|
-
const { ReportScheduler, FileReportScheduleStore, parseReportHours } = await import('../../operator/report-scheduler.js');
|
|
1801
|
-
// Set when a report is composed, read when that same report is delivered. Safe
|
|
1802
|
-
// because ALL operator work serializes on the operator lane (SOURCE_GLOBAL_LANES),
|
|
1803
|
-
// so compose and deliver cannot interleave with another report - stated here
|
|
1804
|
-
// because the safety comes from the lane, not from this file.
|
|
1805
|
-
let lastReportProvenance = {
|
|
1806
|
-
status: 'unavailable',
|
|
1807
|
-
reason: 'no_run_handle',
|
|
1808
|
-
};
|
|
1809
|
-
const { createPersonaReportAsk } = await import('../../operator/report-run.js');
|
|
1810
|
-
const { FilePendingReportStore } = await import('../../operator/pending-report-store.js');
|
|
1811
|
-
const triggerRegistry = new TriggerRegistry(operatorDb);
|
|
1812
|
-
// Owner-report leg (M1.5): destination chat comes from env (~/.mama/start.sh),
|
|
1813
|
-
// never source. No chat configured or no telegram gateway -> loop stays read-only.
|
|
1814
|
-
const reportChatId = resolveOperatorReportChatId(process.env, config.telegram?.allowed_chats);
|
|
1815
|
-
// TG-05/TG-06: one durable production boundary for every report mode.
|
|
1816
|
-
// The delivery ledger reserves exact output and the coordinator owns
|
|
1817
|
-
// every Telegram send; no report text is copied into another model.
|
|
1818
|
-
let reportDelivery;
|
|
1819
|
-
const reportTarget = reportChatId && telegramGateway
|
|
1820
|
-
? { source: 'telegram', channelId: reportChatId }
|
|
1821
|
-
: undefined;
|
|
1822
|
-
if (reportChatId && telegramGateway && reportTarget) {
|
|
1823
|
-
const reportControl = telegramGateway.createReportDeliveryControl();
|
|
1824
|
-
const coordinator = new report_delivery_coordinator_js_1.ReportDeliveryCoordinator({
|
|
1825
|
-
store: reportContextStore,
|
|
1826
|
-
control: reportControl,
|
|
1827
|
-
ownerTarget: reportTarget,
|
|
1828
|
-
executorId: `daemon:${process.pid}`,
|
|
1829
|
-
});
|
|
1830
|
-
// Startup reconciliation: every nonterminal SQLite row keeps its
|
|
1831
|
-
// Telegram-ledger pin; every terminal row releases it (Decision 2).
|
|
1832
|
-
const pinState = reportContextStore.listPinReconciliation();
|
|
1833
|
-
await reportControl.reconcilePins(pinState.nonterminal, pinState.terminal);
|
|
1834
|
-
reportDelivery = {
|
|
1835
|
-
deliverPrepared: async (report) => {
|
|
1836
|
-
const outcome = await coordinator.deliverPrepared(report);
|
|
1837
|
-
if (outcome.status === 'delivered' && report.mode === 'full') {
|
|
1838
|
-
// The full-report leg liveness beat moves from the removed V2
|
|
1839
|
-
// carry callback to the delivered outcome.
|
|
1840
|
-
(0, leg_cadence_js_1.getLegCadence)()?.beat('full-report');
|
|
1841
|
-
}
|
|
1842
|
-
return outcome;
|
|
1843
|
-
},
|
|
1844
|
-
};
|
|
1845
|
-
}
|
|
1846
|
-
// Scheduled full-report leg (M2): local hours from env (~/.mama/start.sh), never source.
|
|
1847
|
-
// Empty/absent -> [] -> leg off. Requires the same telegram sink as the digest leg.
|
|
1848
|
-
const fullReportHours = parseReportHours(process.env.MAMA_TRIGGER_LOOP_FULL_REPORT_HOURS || '');
|
|
1849
|
-
// Constructed whenever the report SINK exists, even with no scheduled
|
|
1850
|
-
// hours (empty hours -> shouldFire never fires): on-demand reports
|
|
1851
|
-
// API-triggered reports need the persistent anchor state regardless of
|
|
1852
|
-
// whether scheduled hours are configured.
|
|
1853
|
-
const reportScheduler = reportDelivery
|
|
1854
|
-
? new ReportScheduler(fullReportHours, new FileReportScheduleStore((0, config_manager_js_1.expandPath)('~/.mama/operator/report-schedule-state.json')))
|
|
1855
|
-
: undefined;
|
|
1856
|
-
const ownerEventEnvelopeAuthority = envelopeBootstrap.envelopeAuthority;
|
|
1857
|
-
const ownerEventExecution = (0, owner_event_policy_js_1.resolveOwnerEventExecution)({
|
|
1858
|
-
issuance: envelopeBootstrap.metadata.issuance,
|
|
1859
|
-
hasAuthority: ownerEventEnvelopeAuthority !== undefined,
|
|
1860
|
-
});
|
|
1861
|
-
const ownerMaintenanceAsk = async (prompt) => {
|
|
1862
|
-
const result = await agentLoop.run(prompt, {
|
|
1863
|
-
sessionKey: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
1864
|
-
source: 'operator',
|
|
1865
|
-
channelId: 'trigger-maintenance',
|
|
1866
|
-
agentContext: backgroundOwnerContext,
|
|
1867
|
-
sessionPolicyRole: ownerRole,
|
|
1868
|
-
prepareEnvelope: async () => {
|
|
1869
|
-
const envelope = await issueOwnerRuntimeEnvelope('trigger-maintenance', 600);
|
|
1870
|
-
if (!envelope)
|
|
1871
|
-
throw new Error('Owner maintenance requires envelope authority');
|
|
1872
|
-
return envelope;
|
|
1873
|
-
},
|
|
1874
|
-
prepareSubagentEnvelope: () => issueOwnerSubagentEnvelope('trigger-maintenance'),
|
|
1875
|
-
requestTimeoutMs: 600_000,
|
|
1876
|
-
});
|
|
1877
|
-
return result.response;
|
|
1878
|
-
};
|
|
1879
|
-
const triggerLoop = new OperatorTriggerLoop({
|
|
1880
|
-
backend: runtimeBackend,
|
|
1881
|
-
delta: new ConnectorDeltaRepo(getAdapter(), (0, config_manager_js_1.expandPath)('~/.mama/operator/trigger-loop-cursors.json')),
|
|
1882
|
-
memory: createMamaMemoryPort(),
|
|
1883
|
-
registry: triggerRegistry,
|
|
1884
|
-
...(ownerEventExecution.enabled ? { ownerEventInbox } : {}),
|
|
1885
|
-
askAgent: ownerMaintenanceAsk,
|
|
1886
|
-
// TG-03/TG-04/TG-05: a report is another stimulus for the standing
|
|
1887
|
-
// owner subject. It keeps the same backend thread and progressive tool
|
|
1888
|
-
// catalog while the current envelope narrows effects for this delivery.
|
|
1889
|
-
reportAsk: createPersonaReportAsk({
|
|
1890
|
-
run: async (prompt, sourceMessageRef, reportOptions) => {
|
|
1891
|
-
const reportAgentPolicy = buildOperatorReportAgentPolicy(config.agent.model, runtimeBackend, privateConnectorPolicy, ownerRole);
|
|
1892
|
-
const result = await agentLoop.runWithContent([{ type: 'text', text: prompt }], {
|
|
1893
|
-
sessionKey: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
1894
|
-
source: 'operator',
|
|
1895
|
-
channelId: 'report',
|
|
1896
|
-
lanePriority: reportOptions.lanePriority,
|
|
1897
|
-
// The current report role narrows effect authority; the stable
|
|
1898
|
-
// sessionPolicyRole keeps the owner thread compatible.
|
|
1899
|
-
agentContext: reportAgentPolicy.agentContext,
|
|
1900
|
-
sessionPolicyRole: ownerRole,
|
|
1901
|
-
gatewayToolsPrompt: reportAgentPolicy.gatewayToolsPrompt,
|
|
1902
|
-
prepareEnvelope: async () => {
|
|
1903
|
-
const envelope = await issueOwnerRuntimeEnvelope('report', 600);
|
|
1904
|
-
if (!envelope)
|
|
1905
|
-
throw new Error('Owner report requires envelope authority');
|
|
1906
|
-
return envelope;
|
|
1907
|
-
},
|
|
1908
|
-
prepareSubagentEnvelope: () => issueOwnerSubagentEnvelope('report'),
|
|
1909
|
-
requestTimeoutMs: 600_000,
|
|
1910
|
-
ownerJournalPrompt: `Report stimulus: ${sourceMessageRef}`,
|
|
1911
|
-
sourceMessageRef,
|
|
1912
|
-
});
|
|
1913
|
-
return {
|
|
1914
|
-
response: result.response,
|
|
1915
|
-
history: result.history,
|
|
1916
|
-
turns: result.turns,
|
|
1917
|
-
// Dropped here until now: the loop already resolves a run handle, and
|
|
1918
|
-
// discarding it meant a delivered report could not be traced to the run
|
|
1919
|
-
// that wrote it.
|
|
1920
|
-
modelRunId: result.modelRunId,
|
|
1921
|
-
...(result.modelRunProvenance === undefined
|
|
1922
|
-
? {}
|
|
1923
|
-
: { modelRunProvenance: result.modelRunProvenance }),
|
|
1924
|
-
...(result.ownerJournalProvenance === undefined
|
|
1925
|
-
? {}
|
|
1926
|
-
: { ownerJournalProvenance: result.ownerJournalProvenance }),
|
|
1927
|
-
};
|
|
1928
|
-
},
|
|
1929
|
-
log: (line) => console.log(line),
|
|
1930
|
-
onRunProvenance: (provenance) => {
|
|
1931
|
-
lastReportProvenance = provenance;
|
|
1932
|
-
},
|
|
1933
|
-
onRecoveryFailure: () => {
|
|
1934
|
-
recordIssue({
|
|
1935
|
-
surface: 'delivery',
|
|
1936
|
-
signature: 'journal_commit_failed',
|
|
1937
|
-
severity: 'error',
|
|
1938
|
-
error: 'Report completed but owner runtime recovery journal did not persist',
|
|
1939
|
-
});
|
|
1940
|
-
},
|
|
1941
|
-
}),
|
|
1942
|
-
review: (trigger, context) => reviewTriggerCLI(trigger, context, ownerMaintenanceAsk),
|
|
1943
|
-
reportDelivery,
|
|
1944
|
-
reportTarget,
|
|
1945
|
-
reportScheduler,
|
|
1946
|
-
// TG-06: composition supplies provenance immediately to the prepared
|
|
1947
|
-
// delivery; this callback receives that durable artifact only after send success.
|
|
1948
|
-
fullReportProvenance: () => lastReportProvenance,
|
|
1949
|
-
pendingReportStore: new FilePendingReportStore((0, config_manager_js_1.expandPath)('~/.mama/operator/pending-owner-reports.json'), (line) => console.error(line)),
|
|
1950
|
-
config: {
|
|
1951
|
-
tickMs: Number(process.env.MAMA_TRIGGER_LOOP_TICK_MS || 60_000),
|
|
1952
|
-
drainLimit: Number(process.env.MAMA_TRIGGER_LOOP_DRAIN_LIMIT || 200),
|
|
1953
|
-
authorEveryNTicks: Number(process.env.MAMA_TRIGGER_LOOP_AUTHOR_EVERY || 30),
|
|
1954
|
-
reviewEveryNTicks: Number(process.env.MAMA_TRIGGER_LOOP_REVIEW_EVERY || 240),
|
|
1955
|
-
authorWindowSize: 50,
|
|
1956
|
-
reportEveryNTicks: Number(process.env.MAMA_TRIGGER_LOOP_REPORT_EVERY || 15),
|
|
1957
|
-
nudgeDebounceMs: Number(process.env.MAMA_TRIGGER_LOOP_NUDGE_DEBOUNCE_MS || 15_000),
|
|
1958
|
-
},
|
|
1959
|
-
log: (line) => console.log(line),
|
|
1960
|
-
});
|
|
1961
|
-
if (reportDelivery) {
|
|
1962
|
-
console.log('[trigger-loop] owner-report leg enabled (telegram, coordinator)');
|
|
1963
|
-
}
|
|
1964
|
-
if (reportScheduler) {
|
|
1965
|
-
console.log(`✓ Trigger loop scheduled full-report leg enabled (local hours: ${fullReportHours.join(', ')})`);
|
|
1966
|
-
}
|
|
1967
|
-
// Watched only when actually started, at its REAL tick (review: an
|
|
1968
|
-
// unconditional 60s declare pages forever when the loop is opted out
|
|
1969
|
-
// or the env raises the tick). Cadence covers a long full-report tick
|
|
1970
|
-
// (the re-entrancy guard skips beats while one runs).
|
|
1971
|
-
// A non-numeric env value yields NaN, and silentFor > NaN*2 is always
|
|
1972
|
-
// false - the watchdog would silently disable itself, which is the one
|
|
1973
|
-
// thing a watchdog must not do. Unparseable falls back to the default.
|
|
1974
|
-
const trigTickRaw = Number(process.env.MAMA_TRIGGER_LOOP_TICK_MS || 60_000);
|
|
1975
|
-
(0, leg_cadence_js_1.getLegCadence)()?.declare('trigger-loop', Math.max(Number.isFinite(trigTickRaw) ? trigTickRaw : 60_000, 15 * 60_000));
|
|
1976
|
-
if (reportScheduler && fullReportHours.length > 0) {
|
|
1977
|
-
// Hours alone are not a leg: without the report sink the scheduler
|
|
1978
|
-
// is undefined, the leg could never beat, and the only outcome is a
|
|
1979
|
-
// false page 52 hours in.
|
|
1980
|
-
// Declared at BOOT, not on first success - a report leg that never
|
|
1981
|
-
// fires is exactly what this watches. 26h covers the daily schedule.
|
|
1982
|
-
(0, leg_cadence_js_1.getLegCadence)()?.declare('full-report', 26 * 60 * 60 * 1000);
|
|
1983
|
-
}
|
|
1984
|
-
const stopTriggerLoop = triggerLoop.start();
|
|
1985
|
-
stopOwnerEventRuntime = async () => {
|
|
1986
|
-
await stopTriggerLoop();
|
|
1987
|
-
};
|
|
1988
|
-
// M2.4: point the connector sink's forwarder at this loop now that it exists.
|
|
1989
|
-
triggerLoopNudge.current = () => triggerLoop.nudge();
|
|
1990
|
-
triggerLoopFullReport.current = () => triggerLoop.startFullReport();
|
|
1991
|
-
if (ownerEventExecution.enabled && ownerEventEnvelopeAuthority) {
|
|
1992
|
-
// MAMA itself owns connector events. This is the same AgentLoop and
|
|
1993
|
-
// owner operating policy as the owner console, on a durable per-channel
|
|
1994
|
-
// background session. There is no separate Conductor persona.
|
|
1995
|
-
const ownerEventContext = (0, owner_event_policy_js_1.buildOwnerEventAgentContext)({
|
|
1996
|
-
backend: runtimeBackend,
|
|
1997
|
-
model: config.agent.model,
|
|
1998
|
-
ownerRole,
|
|
1999
|
-
privateConnectorPolicy,
|
|
2000
|
-
});
|
|
2001
|
-
// ONE expression for what an event turn may read: the envelope and the
|
|
2002
|
-
// packet are both built from it, so they can never disagree.
|
|
2003
|
-
const ownerEventReadScope = (batch) => {
|
|
2004
|
-
const projectId = (0, reactive_config_js_1.resolveReactiveProjectRoot)(config, process.env);
|
|
2005
|
-
return {
|
|
2006
|
-
projectRefs: [{ kind: 'project', id: projectId }],
|
|
2007
|
-
rawConnectors: [
|
|
2008
|
-
...privateConnectorPolicy.projectRawConnectors('owner_console', codeActRawConnectors),
|
|
2009
|
-
],
|
|
2010
|
-
memoryScopes: uniqueMemoryScopes((0, scope_context_js_1.deriveMemoryScopes)({
|
|
2011
|
-
source: 'owner-event',
|
|
2012
|
-
channelId: batch.channelKey,
|
|
2013
|
-
projectId,
|
|
2014
|
-
})),
|
|
2015
|
-
};
|
|
2016
|
-
};
|
|
2017
|
-
const ownerEventIssueEnvelope = async (batch) => {
|
|
2018
|
-
const readScope = ownerEventReadScope(batch);
|
|
2019
|
-
const wallSeconds = 300;
|
|
2020
|
-
return ownerEventEnvelopeAuthority.buildAndPersist({
|
|
2021
|
-
agent_id: 'mama-owner',
|
|
2022
|
-
instance_id: (0, node_crypto_1.randomUUID)(),
|
|
2023
|
-
source: 'watch',
|
|
2024
|
-
channel_id: batch.channelKey,
|
|
2025
|
-
trigger_context: { user_text: '<MAMA owner event turn>' },
|
|
2026
|
-
scope: {
|
|
2027
|
-
project_refs: readScope.projectRefs,
|
|
2028
|
-
raw_connectors: readScope.rawConnectors,
|
|
2029
|
-
memory_scopes: readScope.memoryScopes,
|
|
2030
|
-
allowed_destinations: reportChatId
|
|
2031
|
-
? [{ kind: 'telegram', id: reportChatId }]
|
|
2032
|
-
: [],
|
|
2033
|
-
},
|
|
2034
|
-
tier: 1,
|
|
2035
|
-
budget: { wall_seconds: wallSeconds },
|
|
2036
|
-
expires_at: new Date(Date.now() + wallSeconds * 1000 + 30_000).toISOString(),
|
|
2037
|
-
});
|
|
2038
|
-
};
|
|
2039
|
-
const ownerEventLoop = new owner_event_loop_js_1.OwnerEventLoop({
|
|
2040
|
-
inbox: ownerEventInbox,
|
|
2041
|
-
runner: agentLoop,
|
|
2042
|
-
agentContext: ownerEventContext,
|
|
2043
|
-
ownerRuntimeRole: ownerRole,
|
|
2044
|
-
resolveActivation: (activation, batch) => (0, procedure_activation_js_1.resolveProcedureActivation)(procedureStore, {
|
|
2045
|
-
ownerScope: 'owner:runtime',
|
|
2046
|
-
projectId: ownerEventReadScope(batch).projectRefs[0].id,
|
|
2047
|
-
channelId: ownerEventReadScope(batch).memoryScopes.find((s) => s.kind === 'channel')
|
|
2048
|
-
?.id,
|
|
2049
|
-
}, activation),
|
|
2050
|
-
assertActiveActivations: (batch) => (0, procedure_activation_js_1.assertActiveProcedureActivations)(procedureStore, {
|
|
2051
|
-
ownerScope: 'owner:runtime',
|
|
2052
|
-
projectId: ownerEventReadScope(batch).projectRefs[0].id,
|
|
2053
|
-
channelId: ownerEventReadScope(batch).memoryScopes.find((s) => s.kind === 'channel')
|
|
2054
|
-
?.id,
|
|
2055
|
-
}, batch),
|
|
2056
|
-
buildPrompt: async (batch) => {
|
|
2057
|
-
const projectedBrief = (0, console_brief_js_1.projectConsoleBriefForPrompt)(readCanonicalOwnerBrief(), privateConnectorPolicy);
|
|
2058
|
-
const batchId = String(batch.id);
|
|
2059
|
-
const carryBrief = lastOwnerEventBriefDecision?.batchId === batchId
|
|
2060
|
-
? lastOwnerEventBriefDecision.carry
|
|
2061
|
-
: ownerBriefMemory.admit(owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY, projectedBrief);
|
|
2062
|
-
lastOwnerEventBriefDecision = { batchId, carry: carryBrief };
|
|
2063
|
-
return (0, owner_event_prompt_js_1.buildOwnerEventPrompt)({
|
|
2064
|
-
batch,
|
|
2065
|
-
// Standing policy goes on the thread once; an owner correction to the brief
|
|
2066
|
-
// changes its hash and is carried on the next turn.
|
|
2067
|
-
ownerBrief: carryBrief ? projectedBrief : null,
|
|
2068
|
-
ownerTelegramChatId: reportChatId,
|
|
2069
|
-
});
|
|
2070
|
-
},
|
|
2071
|
-
promptBriefState: (batch) => lastOwnerEventBriefDecision?.batchId === String(batch.id) &&
|
|
2072
|
-
lastOwnerEventBriefDecision.carry
|
|
2073
|
-
? 'sent'
|
|
2074
|
-
: 'omitted',
|
|
2075
|
-
// No model turn ran, so the brief this batch admitted was never delivered on the
|
|
2076
|
-
// owner thread: forget it so the retry carries it again.
|
|
2077
|
-
retractBrief: (batch) => {
|
|
2078
|
-
if (lastOwnerEventBriefDecision?.batchId !== String(batch.id))
|
|
2079
|
-
return;
|
|
2080
|
-
if (lastOwnerEventBriefDecision.carry) {
|
|
2081
|
-
ownerBriefMemory.forget(owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY);
|
|
2082
|
-
}
|
|
2083
|
-
lastOwnerEventBriefDecision = null;
|
|
2084
|
-
},
|
|
2085
|
-
issueEnvelope: ownerEventIssueEnvelope,
|
|
2086
|
-
getNoUpdateMaxId: (scope) => taskLedger.maxNoUpdateId(scope),
|
|
2087
|
-
hasUnsafeReplayEffects: (batch) => ownerActionEffectLedger.hasUnsafeReplayEffects(`owner-event:${batch.id}`),
|
|
2088
|
-
hasUnsettledEffects: (batch) => ownerActionEffectLedger.hasUnsettledEffects(`owner-event:${batch.id}`),
|
|
2089
|
-
getTerminalReceipt: (batch) => resolveOwnerEventTerminalReceipt(batch, {
|
|
2090
|
-
ownerEventEffectLedger,
|
|
2091
|
-
ownerActionEffectLedger,
|
|
2092
|
-
taskLedger,
|
|
2093
|
-
}),
|
|
2094
|
-
recordTriggerOutcome: (triggerId, outcome, receiptId) => triggerRegistry.recordOutcome(triggerId, outcome, receiptId),
|
|
2095
|
-
onDead: async (message) => {
|
|
2096
|
-
console.error(message);
|
|
2097
|
-
await (0, leg_cadence_js_1.getLegPageNotifier)()?.(message);
|
|
2098
|
-
},
|
|
2099
|
-
recordIssue: ({ channelKey, reason }) => recordIssue({
|
|
2100
|
-
surface: 'inbox',
|
|
2101
|
-
signature: 'dead_batch',
|
|
2102
|
-
severity: 'error',
|
|
2103
|
-
error: reason,
|
|
2104
|
-
sourceRef: channelKey,
|
|
2105
|
-
}),
|
|
2106
|
-
log: (line) => console.log(line),
|
|
2107
|
-
});
|
|
2108
|
-
let ownerEventTickPromise = null;
|
|
2109
|
-
const runOwnerEventTick = () => {
|
|
2110
|
-
if (ownerEventTickPromise)
|
|
2111
|
-
return;
|
|
2112
|
-
ownerEventTickPromise = ownerEventLoop
|
|
2113
|
-
.tick()
|
|
2114
|
-
.catch((err) => console.error(`[owner-event] tick failed: ${err instanceof Error ? err.message : String(err)}`))
|
|
2115
|
-
.finally(() => {
|
|
2116
|
-
ownerEventTickPromise = null;
|
|
2117
|
-
});
|
|
2118
|
-
};
|
|
2119
|
-
const ownerEventTimer = setInterval(runOwnerEventTick, 5_000);
|
|
2120
|
-
ownerEventTimer.unref?.();
|
|
2121
|
-
runOwnerEventTick();
|
|
2122
|
-
console.log('✓ MAMA owner-event agent enabled');
|
|
2123
|
-
stopOwnerEventRuntime = async () => {
|
|
2124
|
-
triggerLoopNudge.current = null;
|
|
2125
|
-
triggerLoopFullReport.current = null;
|
|
2126
|
-
clearInterval(ownerEventTimer);
|
|
2127
|
-
// Let an in-flight effect reach its durable ACK before the shared
|
|
2128
|
-
// operator DB closes.
|
|
2129
|
-
if (ownerEventTickPromise)
|
|
2130
|
-
await ownerEventTickPromise;
|
|
2131
|
-
await stopTriggerLoop();
|
|
2132
|
-
};
|
|
2133
|
-
}
|
|
2134
|
-
else {
|
|
2135
|
-
const reason = ownerEventExecution.enabled
|
|
2136
|
-
? 'owner-event envelope authority unavailable'
|
|
2137
|
-
: ownerEventExecution.reason;
|
|
2138
|
-
console.error(`[owner-event] disabled: ${reason}`);
|
|
2139
|
-
}
|
|
2140
|
-
temporalLogger.info('Trigger loop enabled (MAMA owner-event intake + report mode)');
|
|
2141
|
-
}
|
|
2142
|
-
catch (error) {
|
|
2143
|
-
await stopOwnerEventRuntime?.().catch(() => { });
|
|
2144
|
-
stopOwnerEventRuntime = null;
|
|
2145
|
-
console.error('[trigger-loop] FAILED to start - daemon continues WITHOUT the trigger loop. Fix and restart:', error);
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
// ── Phase 10: API Server + Routes ────────────────────────────────────────
|
|
2149
|
-
const { apiServer, eventBus } = await (0, api_server_init_js_1.initApiServer)({
|
|
2150
|
-
config,
|
|
2151
|
-
scheduler,
|
|
2152
|
-
db,
|
|
2153
|
-
healthService,
|
|
2154
|
-
healthCheckService,
|
|
2155
|
-
rawStore: rawStoreForApi,
|
|
2156
|
-
enabledConnectors: enabledConnectorNames,
|
|
2157
|
-
getAdapter,
|
|
2158
|
-
envelopeMetadata: envelopeBootstrap.metadata,
|
|
2159
|
-
envelopeAuthority: envelopeBootstrap.envelopeAuthority,
|
|
2160
|
-
contextCompileService,
|
|
2161
|
-
connectorConfigLoadResult,
|
|
2162
|
-
privateConnectorPolicy,
|
|
2163
|
-
runOwnerStimulus,
|
|
2164
|
-
});
|
|
2165
|
-
const apiRoutesHandle = await (0, api_routes_init_js_1.registerApiRoutes)({
|
|
2166
|
-
config,
|
|
2167
|
-
apiServer,
|
|
2168
|
-
eventBus,
|
|
2169
|
-
oauthManager,
|
|
2170
|
-
mamaApi,
|
|
2171
|
-
messageRouter,
|
|
2172
|
-
reportContextStore,
|
|
2173
|
-
toolExecutor,
|
|
2174
|
-
discordGateway,
|
|
2175
|
-
slackGateway,
|
|
2176
|
-
graphHandler,
|
|
2177
|
-
getAdapter,
|
|
2178
|
-
privateConnectorPolicy,
|
|
2179
|
-
rawConnectorScope: [
|
|
2180
|
-
...privateConnectorPolicy.projectRawConnectors(exports.ONE_AGENT_TURN_POLICY.roleName, codeActRawConnectors),
|
|
2181
|
-
],
|
|
2182
|
-
sessionsDb: db,
|
|
2183
|
-
workOrderConsumer: workOrderConsumer ?? undefined,
|
|
2184
|
-
boardRefreshGate,
|
|
2185
|
-
requestFullReport: () => triggerLoopFullReport.current?.() ?? { accepted: false, reason: 'unavailable' },
|
|
2186
|
-
});
|
|
2187
|
-
boardRepairNudge.current = apiRoutesHandle.requestBoardRepair;
|
|
2188
|
-
{
|
|
2189
|
-
const { broadcastReportUpdate } = await import('../../api/report-handler.js');
|
|
2190
|
-
apiServer.reportStore.setTaskProjectionProvider(() => operatorDb.transaction(() => {
|
|
2191
|
-
const page = taskLedger.listPage({ includeTerminal: false, order: 'deadline_priority' });
|
|
2192
|
-
return {
|
|
2193
|
-
basisRevision: taskLedger.readGeneration(),
|
|
2194
|
-
html: (0, board_pipeline_render_js_1.renderPipelineSlot)(page.tasks, Date.now(), page.total),
|
|
2195
|
-
};
|
|
2196
|
-
})(), (slots) => broadcastReportUpdate(apiServer.reportSseClients, { slots }));
|
|
2197
|
-
refreshTaskBoard.current = () => {
|
|
2198
|
-
apiServer.reportStore.refreshTaskProjection();
|
|
2199
|
-
};
|
|
2200
|
-
}
|
|
2201
|
-
gateways.push({ stop: async () => apiRoutesHandle.stop() });
|
|
2202
|
-
// ── Stage-2 boot pass (plan S2-T3): runtime assembly registered hooks;
|
|
2203
|
-
// recovery/cleanup run after routes are ready, then the consumer starts.
|
|
2204
|
-
const temporalBoot = temporalAssembly.bootAfterRoutes();
|
|
2205
|
-
if (temporalBoot.paused > 0) {
|
|
2206
|
-
temporalLogger.info(`paused ${temporalBoot.paused} open workorder(s)`);
|
|
2207
|
-
}
|
|
2208
|
-
if (temporalBoot.enabled && (temporalBoot.resumed > 0 || temporalBoot.enqueued > 0)) {
|
|
2209
|
-
temporalLogger.info(`resumed ${temporalBoot.resumed}, enqueued ${temporalBoot.enqueued}`);
|
|
2210
|
-
}
|
|
2211
|
-
// ── Phase 11: Server Start + Shutdown ────────────────────────────────────
|
|
2212
|
-
await (0, server_start_js_1.startServer)({ apiServer, gateways });
|
|
2213
|
-
(0, shutdown_js_1.installShutdownHandlers)({
|
|
2214
|
-
metricsInterval,
|
|
2215
|
-
healthWarningInterval,
|
|
2216
|
-
scheduler,
|
|
2217
|
-
cronWorker,
|
|
2218
|
-
heartbeatScheduler,
|
|
2219
|
-
tokenKeepAlive,
|
|
2220
|
-
gateways,
|
|
2221
|
-
pluginLoader,
|
|
2222
|
-
agentLoop,
|
|
2223
|
-
stopExtraction,
|
|
2224
|
-
sessionStore,
|
|
2225
|
-
db,
|
|
2226
|
-
metricsStore,
|
|
2227
|
-
metricsCleanup,
|
|
2228
|
-
});
|
|
2229
|
-
}
|
|
2230
|
-
//# sourceMappingURL=start.js.map
|