@ashx-j/lunr 0.2.21 → 0.2.22
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 +1 -1
- package/README.md +20 -4
- package/dist/builtin-extensions/index.d.ts.map +1 -1
- package/dist/builtin-extensions/index.js +1 -0
- package/dist/builtin-extensions/index.js.map +1 -1
- package/dist/builtin-extensions/lunr-browser.d.ts +3 -0
- package/dist/builtin-extensions/lunr-browser.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-browser.js +56 -0
- package/dist/builtin-extensions/lunr-browser.js.map +1 -0
- package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-todos.js +15 -0
- package/dist/builtin-extensions/lunr-todos.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.js +3 -0
- package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js +5 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +18 -5
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +4 -3
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +3 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/communication.d.ts +17 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/communication.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/communication.js +45 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/communication.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js +4 -11
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +4 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +160 -51
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js +5 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js +3 -2
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js +2 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +3 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js +3 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts +18 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/communication.js +47 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/communication.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +11 -7
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +2 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/install-cli.d.ts.map +1 -1
- package/dist/cli/install-cli.js +15 -45
- package/dist/cli/install-cli.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +9 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +126 -29
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +20 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/browser/network.d.ts +9 -0
- package/dist/core/browser/network.d.ts.map +1 -0
- package/dist/core/browser/network.js +146 -0
- package/dist/core/browser/network.js.map +1 -0
- package/dist/core/browser/runtime.d.ts +24 -0
- package/dist/core/browser/runtime.d.ts.map +1 -0
- package/dist/core/browser/runtime.js +289 -0
- package/dist/core/browser/runtime.js.map +1 -0
- package/dist/core/browser/schema.d.ts +16 -0
- package/dist/core/browser/schema.d.ts.map +1 -0
- package/dist/core/browser/schema.js +36 -0
- package/dist/core/browser/schema.js.map +1 -0
- package/dist/core/browser/settings.d.ts +8 -0
- package/dist/core/browser/settings.d.ts.map +1 -0
- package/dist/core/browser/settings.js +30 -0
- package/dist/core/browser/settings.js.map +1 -0
- package/dist/core/browser/setup.d.ts +2 -0
- package/dist/core/browser/setup.d.ts.map +1 -0
- package/dist/core/browser/setup.js +16 -0
- package/dist/core/browser/setup.js.map +1 -0
- package/dist/core/customize.d.ts.map +1 -1
- package/dist/core/customize.js +15 -14
- package/dist/core/customize.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +1 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/install-features.d.ts.map +1 -1
- package/dist/core/install-features.js +10 -8
- package/dist/core/install-features.js.map +1 -1
- package/dist/core/memory-cap.d.ts.map +1 -1
- package/dist/core/memory-cap.js +5 -3
- package/dist/core/memory-cap.js.map +1 -1
- package/dist/core/model-tiers.d.ts.map +1 -1
- package/dist/core/model-tiers.js +9 -6
- package/dist/core/model-tiers.js.map +1 -1
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +9 -0
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +3 -0
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/process-registry.d.ts.map +1 -1
- package/dist/core/process-registry.js +6 -4
- package/dist/core/process-registry.js.map +1 -1
- package/dist/core/runtime-scope.d.ts +11 -0
- package/dist/core/runtime-scope.d.ts.map +1 -0
- package/dist/core/runtime-scope.js +3 -0
- package/dist/core/runtime-scope.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +13 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-handoff.d.ts +35 -0
- package/dist/core/session-handoff.d.ts.map +1 -0
- package/dist/core/session-handoff.js +214 -0
- package/dist/core/session-handoff.js.map +1 -0
- package/dist/core/session-manager.d.ts +20 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +184 -22
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-ownership.d.ts +28 -0
- package/dist/core/session-ownership.d.ts.map +1 -0
- package/dist/core/session-ownership.js +138 -0
- package/dist/core/session-ownership.js.map +1 -0
- package/dist/core/session-retention.d.ts.map +1 -1
- package/dist/core/session-retention.js +11 -2
- package/dist/core/session-retention.js.map +1 -1
- package/dist/core/settings-manager.d.ts +7 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +18 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +5 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/todo-settings.d.ts +5 -0
- package/dist/core/todo-settings.d.ts.map +1 -0
- package/dist/core/todo-settings.js +7 -0
- package/dist/core/todo-settings.js.map +1 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +4 -4
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +5 -3
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +4 -4
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +4 -4
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +4 -4
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -4
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +11 -2
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +31 -4
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +4 -4
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/usage-service.d.ts.map +1 -1
- package/dist/core/usage-service.js +5 -3
- package/dist/core/usage-service.js.map +1 -1
- package/dist/gateway/adapters/discord.d.ts +12 -1
- package/dist/gateway/adapters/discord.d.ts.map +1 -1
- package/dist/gateway/adapters/discord.js +112 -17
- package/dist/gateway/adapters/discord.js.map +1 -1
- package/dist/gateway/adapters/telegram.d.ts +4 -2
- package/dist/gateway/adapters/telegram.d.ts.map +1 -1
- package/dist/gateway/adapters/telegram.js +34 -11
- package/dist/gateway/adapters/telegram.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts +14 -3
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +252 -60
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/approval.d.ts +1 -0
- package/dist/gateway/approval.d.ts.map +1 -1
- package/dist/gateway/approval.js +60 -18
- package/dist/gateway/approval.js.map +1 -1
- package/dist/gateway/authz.d.ts +2 -0
- package/dist/gateway/authz.d.ts.map +1 -1
- package/dist/gateway/authz.js +13 -0
- package/dist/gateway/authz.js.map +1 -1
- package/dist/gateway/buttons.d.ts +3 -1
- package/dist/gateway/buttons.d.ts.map +1 -1
- package/dist/gateway/buttons.js +18 -3
- package/dist/gateway/buttons.js.map +1 -1
- package/dist/gateway/command.d.ts.map +1 -1
- package/dist/gateway/command.js +49 -4
- package/dist/gateway/command.js.map +1 -1
- package/dist/gateway/commands.d.ts.map +1 -1
- package/dist/gateway/commands.js +18 -3
- package/dist/gateway/commands.js.map +1 -1
- package/dist/gateway/config.d.ts +5 -0
- package/dist/gateway/config.d.ts.map +1 -1
- package/dist/gateway/config.js +5 -0
- package/dist/gateway/config.js.map +1 -1
- package/dist/gateway/conversations.d.ts +14 -0
- package/dist/gateway/conversations.d.ts.map +1 -0
- package/dist/gateway/conversations.js +30 -0
- package/dist/gateway/conversations.js.map +1 -0
- package/dist/gateway/download.d.ts +2 -0
- package/dist/gateway/download.d.ts.map +1 -0
- package/dist/gateway/download.js +36 -0
- package/dist/gateway/download.js.map +1 -0
- package/dist/gateway/index.d.ts.map +1 -1
- package/dist/gateway/index.js +85 -26
- package/dist/gateway/index.js.map +1 -1
- package/dist/gateway/mobile-commands.d.ts +24 -0
- package/dist/gateway/mobile-commands.d.ts.map +1 -0
- package/dist/gateway/mobile-commands.js +422 -0
- package/dist/gateway/mobile-commands.js.map +1 -0
- package/dist/gateway/presenter.d.ts +16 -0
- package/dist/gateway/presenter.d.ts.map +1 -0
- package/dist/gateway/presenter.js +210 -0
- package/dist/gateway/presenter.js.map +1 -0
- package/dist/gateway/router.d.ts +1 -0
- package/dist/gateway/router.d.ts.map +1 -1
- package/dist/gateway/router.js +32 -3
- package/dist/gateway/router.js.map +1 -1
- package/dist/gateway/service.d.ts +46 -0
- package/dist/gateway/service.d.ts.map +1 -0
- package/dist/gateway/service.js +395 -0
- package/dist/gateway/service.js.map +1 -0
- package/dist/gateway/setup.d.ts +4 -0
- package/dist/gateway/setup.d.ts.map +1 -0
- package/dist/gateway/setup.js +146 -0
- package/dist/gateway/setup.js.map +1 -0
- package/dist/gateway/types.d.ts +4 -2
- package/dist/gateway/types.d.ts.map +1 -1
- package/dist/gateway/types.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +11 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +53 -16
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/copyable-text.d.ts +31 -0
- package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/copyable-text.js +165 -0
- package/dist/modes/interactive/components/copyable-text.js.map +1 -0
- package/dist/modes/interactive/components/custom-entry.d.ts +1 -0
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +8 -0
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +8 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +16 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +5 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +38 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +151 -7
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/node-runtime/agent-session-services-NQ6GKOIK.js +49 -0
- package/dist/node-runtime/{builtin-extensions-JCOPAAB5.js → builtin-extensions-GVC6IFDU.js} +6 -5
- package/dist/node-runtime/{chunk-LTYWTR3V.js → chunk-2MI5OPMN.js} +17 -2
- package/dist/node-runtime/{chunk-W3CVH5RX.js → chunk-2TKODGBZ.js} +11 -6
- package/dist/node-runtime/chunk-4EULYYR4.js +62 -0
- package/dist/node-runtime/chunk-5BNJ4JUH.js +672 -0
- package/dist/node-runtime/{chunk-6N22HULO.js → chunk-5D7LC2ZQ.js} +7 -2
- package/dist/node-runtime/{chunk-KBKMCJDU.js → chunk-5ZQXRPMC.js} +19 -4
- package/dist/node-runtime/{chunk-6KDIOJL3.js → chunk-6427XAWG.js} +3 -3
- package/dist/node-runtime/{chunk-BOHIDQT4.js → chunk-6B2POMK7.js} +1 -1
- package/dist/node-runtime/{chunk-RNBHABBA.js → chunk-7QWNYZDI.js} +7 -0
- package/dist/node-runtime/chunk-AZJHNQKQ.js +205 -0
- package/dist/node-runtime/{chunk-A3KMVBZV.js → chunk-BBUVIEZB.js} +1 -10
- package/dist/node-runtime/chunk-BFNXONG3.js +521 -0
- package/dist/node-runtime/{chunk-IRPJXI6U.js → chunk-BX2RB477.js} +1 -1
- package/dist/node-runtime/chunk-CCCN2UCX.js +14 -0
- package/dist/node-runtime/{chunk-25I2BHAA.js → chunk-CSUZVNYE.js} +1 -1
- package/dist/node-runtime/{chunk-QZMODZQ2.js → chunk-E24EO34J.js} +2 -1
- package/dist/node-runtime/{chunk-2BUAYZ7K.js → chunk-EQ63ANHL.js} +422 -123
- package/dist/node-runtime/{chunk-GB2MGFLI.js → chunk-GJSAD4AB.js} +216 -201
- package/dist/node-runtime/{chunk-W3SILANP.js → chunk-GMHJCCEN.js} +8 -8
- package/dist/node-runtime/{chunk-DDWHZ633.js → chunk-GNN7H3B7.js} +1 -1
- package/dist/node-runtime/chunk-GS66LV4M.js +2830 -0
- package/dist/node-runtime/{chunk-6BEIBLQ3.js → chunk-H3XF4UVQ.js} +1 -1
- package/dist/node-runtime/chunk-H4K3JDRB.js +47 -0
- package/dist/node-runtime/{chunk-YMEAYRBE.js → chunk-HTFRRDSF.js} +2 -7
- package/dist/node-runtime/chunk-IMLCWLPI.js +9 -0
- package/dist/node-runtime/{chunk-Y5KOEMBH.js → chunk-IQIEU7SB.js} +9 -674
- package/dist/node-runtime/{chunk-OPEK5RRY.js → chunk-IVXYUAJE.js} +1 -1
- package/dist/node-runtime/{chunk-PDNXVXMD.js → chunk-IWOWXRWU.js} +58 -48
- package/dist/node-runtime/chunk-KKUTQQV7.js +144 -0
- package/dist/node-runtime/{chunk-AWVD5IEY.js → chunk-LMBNLFXQ.js} +23 -12
- package/dist/node-runtime/{chunk-7NBZ5P7I.js → chunk-NAY6UUQZ.js} +1 -1
- package/dist/node-runtime/chunk-OAR4TYZE.js +146 -0
- package/dist/node-runtime/{chunk-STERBGUB.js → chunk-OFKSVRV7.js} +2 -2
- package/dist/node-runtime/{chunk-JZQ7F36T.js → chunk-ORH324EP.js} +19 -3
- package/dist/node-runtime/{chunk-2SJB2AWP.js → chunk-PC2Z5TKZ.js} +3 -3
- package/dist/node-runtime/{chunk-SY2TFMLO.js → chunk-QDGKKKUM.js} +46 -151
- package/dist/node-runtime/chunk-R3K2F5GI.js +122 -0
- package/dist/node-runtime/chunk-RMQZU2YU.js +117 -0
- package/dist/node-runtime/{chunk-XI77KVKA.js → chunk-TDL7UWJ7.js} +283 -2999
- package/dist/node-runtime/{chunk-G6LRAP36.js → chunk-TQGPP4SC.js} +1 -1
- package/dist/node-runtime/chunk-UAEOTO52.js +119 -0
- package/dist/node-runtime/{chunk-VZR3NCM7.js → chunk-UAFLNHSH.js} +18 -14
- package/dist/node-runtime/{chunk-AY6CAJSL.js → chunk-UJOCPOMX.js} +6 -3
- package/dist/node-runtime/chunk-UP2XBVH5.js +40 -0
- package/dist/node-runtime/{chunk-WJVFOIB5.js → chunk-UQUCFAJ3.js} +1 -1
- package/dist/node-runtime/chunk-URD2SLIT.js +1019 -0
- package/dist/node-runtime/chunk-US544NN6.js +13 -0
- package/dist/node-runtime/chunk-UWPJL22I.js +341 -0
- package/dist/node-runtime/chunk-V2A7CEXK.js +355 -0
- package/dist/node-runtime/chunk-VJPTNWAP.js +708 -0
- package/dist/node-runtime/{chunk-WKDK4C5P.js → chunk-VSSXXL36.js} +38 -164
- package/dist/node-runtime/{chunk-4I23VTC4.js → chunk-VWCE2HSZ.js} +21 -124
- package/dist/node-runtime/{chunk-WLLDXJRT.js → chunk-WADV2VDS.js} +22 -1014
- package/dist/node-runtime/{chunk-GKLEQ3I4.js → chunk-XLTL257W.js} +126 -27
- package/dist/node-runtime/chunk-YPHAIRZT.js +10 -0
- package/dist/node-runtime/cli-runtime.js +2 -2
- package/dist/node-runtime/command-3JHHXOPX.js +45 -0
- package/dist/node-runtime/commands-2JVNFGMQ.js +36 -0
- package/dist/node-runtime/{commands-MV5KOZ64.js → commands-KAMO2T6P.js} +10 -10
- package/dist/node-runtime/config-RORQUQFG.js +20 -0
- package/dist/node-runtime/{customize-LF5VST47.js → customize-VFJV3U6A.js} +2 -1
- package/dist/node-runtime/{direct-tool-executor-BK7CLEBX.js → direct-tool-executor-YAVOLDFY.js} +8 -8
- package/dist/node-runtime/{export-html-TEXVV5RP.js → export-html-KBFVV63J.js} +4 -3
- package/dist/node-runtime/{extension-input-O4HSAEM4.js → extension-input-K24TVKVW.js} +4 -4
- package/dist/node-runtime/{extension-selector-X5FCX43D.js → extension-selector-SPNF7EDR.js} +4 -4
- package/dist/node-runtime/{extract-XLQSJN4V.js → extract-EQJE7FZZ.js} +2 -2
- package/dist/node-runtime/{gateway-BM6NLOH4.js → gateway-VFO6SFKK.js} +275 -994
- package/dist/node-runtime/{gemini-search-U7SUMPQA.js → gemini-search-35OCRFLN.js} +1 -1
- package/dist/node-runtime/{gemini-url-context-PXWCBQHK.js → gemini-url-context-UQY3PHHW.js} +2 -2
- package/dist/node-runtime/index.js +104 -65
- package/dist/node-runtime/{init-3C7Z24OI.js → init-X2LIUB2H.js} +3 -3
- package/dist/node-runtime/{install-cli-EXMJQESX.js → install-cli-C3CF7O7N.js} +21 -82
- package/dist/node-runtime/interactive-mode-LOM6AIF6.js +72 -0
- package/dist/node-runtime/{interactive-view-ILS6TAN5.js → interactive-view-IDSCPPK7.js} +8 -8
- package/dist/node-runtime/lunr-browser-YNW7FTYX.js +87 -0
- package/dist/node-runtime/{lunr-cron-4VHP4E4B.js → lunr-cron-BKHGNBKT.js} +19 -5
- package/dist/node-runtime/main.js +44 -31
- package/dist/node-runtime/{memory-cap-3S4XRLNP.js → memory-cap-EL3KL4JJ.js} +2 -1
- package/dist/node-runtime/mobile-commands-HMP25WBC.js +32 -0
- package/dist/node-runtime/model-runtime-PLQKAG4B.js +16 -0
- package/dist/node-runtime/{model-tiers-NJLHUEGK.js → model-tiers-OU3U5CZG.js} +2 -1
- package/dist/node-runtime/{package-manager-cli-N37546V5.js → package-manager-cli-VCK4E2RC.js} +22 -15
- package/dist/node-runtime/{pi-intercom-NV2LW6X7.js → pi-intercom-HBPK5HSJ.js} +4 -1
- package/dist/node-runtime/{pi-mcp-adapter-GUFZWW54.js → pi-mcp-adapter-E6WULBKF.js} +4 -4
- package/dist/node-runtime/{pi-subagents-6MUIFNDM.js → pi-subagents-FEUDLJOE.js} +201 -78
- package/dist/node-runtime/{pi-web-access-2CQGFLT2.js → pi-web-access-WTGMNZ32.js} +15 -15
- package/dist/node-runtime/process-registry-4FAKZQOL.js +31 -0
- package/dist/node-runtime/{proxy-modes-V6YVFH3C.js → proxy-modes-OSQCWRBI.js} +9 -9
- package/dist/node-runtime/rpc-entry.js +44 -31
- package/dist/node-runtime/{rpc-mode-W5ZTLTMZ.js → rpc-mode-P5ODXPEG.js} +2 -2
- package/dist/node-runtime/runtime-4VA6JKNF.js +373 -0
- package/dist/node-runtime/{runtime-bridges-2VQTLPOZ.js → runtime-bridges-3XUQ46XW.js} +6 -5
- package/dist/node-runtime/service-ISSP6VHE.js +36 -0
- package/dist/node-runtime/session-handoff-HC7R5E24.js +33 -0
- package/dist/node-runtime/{session-manager-E7AREDTV.js → session-manager-CFN4UFM2.js} +2 -1
- package/dist/node-runtime/{session-selector-FJ7M2AIX.js → session-selector-LHRMJOKT.js} +5 -4
- package/dist/node-runtime/{settings-manager-CUGAZWAB.js → settings-manager-UUZ6NUXI.js} +7 -2
- package/dist/node-runtime/setup-JBKOLJ6F.js +18 -0
- package/dist/node-runtime/setup-NRXVZBLJ.js +155 -0
- package/dist/node-runtime/{subagent-executor-MH4A7CCF.js → subagent-executor-MLUMBWCP.js} +22 -18
- package/dist/node-runtime/theme-U7IGOA7O.js +68 -0
- package/dist/node-runtime/trust-manager-MMISNCYO.js +17 -0
- package/dist/node-runtime/{update-cli-XTZMZGOL.js → update-cli-4TP25CNW.js} +7 -2
- package/dist/node-runtime/usage-service-LFB2SWYV.js +37 -0
- package/dist/node-runtime/{video-extract-OYT5WKS5.js → video-extract-OOZHR7SU.js} +2 -2
- package/dist/node-runtime/{youtube-extract-TQYKGFGS.js → youtube-extract-FNPAUNHU.js} +6 -6
- package/docs/browser.md +86 -0
- package/docs/extensions.md +2 -0
- package/docs/features.md +94 -16
- package/docs/interactive-startup.md +2 -1
- package/docs/sessions.md +10 -0
- package/docs/settings.md +1 -0
- package/docs/tui.md +2 -0
- package/docs/usage.md +16 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +7 -4
- package/scripts/install-browser.mjs +20 -0
- package/dist/node-runtime/agent-session-services-C743TYQE.js +0 -37
- package/dist/node-runtime/chunk-VGYZ3APQ.js +0 -59
- package/dist/node-runtime/command-P4NYCJ2M.js +0 -13
- package/dist/node-runtime/interactive-mode-EVVBA64D.js +0 -59
- package/dist/node-runtime/{chunk-UWQYRSYQ.js → chunk-YJMMG7C6.js} +25 -25
- package/dist/node-runtime/{mcp-panel-IIGMXQGP.js → mcp-panel-KTTFXJZ4.js} +3 -3
- package/dist/node-runtime/{src-BPQFJR76.js → src-IVPNZ2BX.js} +9 -9
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
SessionOwnership
|
|
4
|
+
} from "./chunk-UAEOTO52.js";
|
|
2
5
|
import {
|
|
3
6
|
KeybindingsManager
|
|
4
7
|
} from "./chunk-5EFIU3OM.js";
|
|
5
8
|
import {
|
|
6
9
|
DynamicBorder
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6B2POMK7.js";
|
|
8
11
|
import {
|
|
9
12
|
keyHint,
|
|
10
13
|
keyText
|
|
11
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-GNN7H3B7.js";
|
|
12
15
|
import {
|
|
13
16
|
theme
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-7QWNYZDI.js";
|
|
15
18
|
import {
|
|
16
19
|
canonicalizePath
|
|
17
20
|
} from "./chunk-FQMM2EZ2.js";
|
|
@@ -432,6 +435,19 @@ var SessionList = class {
|
|
|
432
435
|
}
|
|
433
436
|
};
|
|
434
437
|
async function deleteSessionFile(sessionPath) {
|
|
438
|
+
let ownership;
|
|
439
|
+
try {
|
|
440
|
+
ownership = new SessionOwnership(sessionPath);
|
|
441
|
+
} catch (error) {
|
|
442
|
+
return { ok: !1, method: "unlink", error: error instanceof Error ? error.message : String(error) };
|
|
443
|
+
}
|
|
444
|
+
try {
|
|
445
|
+
return await deleteOwnedSessionFile(sessionPath);
|
|
446
|
+
} finally {
|
|
447
|
+
ownership.release();
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
async function deleteOwnedSessionFile(sessionPath) {
|
|
435
451
|
let trashArgs = sessionPath.startsWith("-") ? ["--", sessionPath] : [sessionPath], trashResult = spawnSync("trash", trashArgs, { encoding: "utf-8" }), getTrashErrorHint = () => {
|
|
436
452
|
let parts = [];
|
|
437
453
|
trashResult.error && parts.push(trashResult.error.message);
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
} from "./chunk-I6R76AG7.js";
|
|
5
5
|
import {
|
|
6
6
|
DynamicBorder
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-6B2POMK7.js";
|
|
8
8
|
import {
|
|
9
9
|
keyHint
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GNN7H3B7.js";
|
|
11
11
|
import {
|
|
12
12
|
theme
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-7QWNYZDI.js";
|
|
14
14
|
|
|
15
15
|
// packages/coding-agent/dist/modes/interactive/components/extension-input.js
|
|
16
16
|
import { Container, getKeybindings, Input, Spacer, Text } from "@ashx-j/lunr-tui";
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
controlNotificationKey,
|
|
4
|
+
formatControlNoticeMessage,
|
|
5
|
+
isDiagnosticControlEvent
|
|
6
|
+
} from "./chunk-OAR4TYZE.js";
|
|
2
7
|
import {
|
|
3
8
|
PLAN_MODE_WRITE_SPAWN_ERROR,
|
|
4
9
|
resolveChildPermissions
|
|
5
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CSUZVNYE.js";
|
|
6
11
|
import {
|
|
7
12
|
createReadOnlyTools
|
|
8
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VSSXXL36.js";
|
|
9
14
|
import {
|
|
10
15
|
convertToLlm
|
|
11
16
|
} from "./chunk-FVDOXRUD.js";
|
|
@@ -1921,6 +1926,30 @@ function resolveWaitToolConfig(config, env = process.env) {
|
|
|
1921
1926
|
};
|
|
1922
1927
|
}
|
|
1923
1928
|
|
|
1929
|
+
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/intercom/communication.js
|
|
1930
|
+
var SUPERVISOR_PROTOCOL_ENV = "PI_SUBAGENT_SUPERVISOR_PROTOCOL", CHILD_DESCRIPTION_ENV = "PI_SUBAGENT_CHILD_DESCRIPTION";
|
|
1931
|
+
var SUPERVISOR_REQUEST_TYPE = "subagent_supervisor_request", SUPERVISOR_PROGRESS_TYPE = "subagent_supervisor_progress";
|
|
1932
|
+
function readCommunication(value) {
|
|
1933
|
+
if (!value || typeof value != "object")
|
|
1934
|
+
return;
|
|
1935
|
+
let input = value;
|
|
1936
|
+
if (!(input.direction !== "from" && input.direction !== "to") && !(typeof input.peer != "string" || typeof input.message != "string") && ["request", "interview", "progress", "handoff", "question", "reply", "answer", "steer"].includes(input.kind ?? ""))
|
|
1937
|
+
return input;
|
|
1938
|
+
}
|
|
1939
|
+
function resolveCommunicationPeer(state, runId, childIndex, childId, fallback) {
|
|
1940
|
+
let job = state.asyncJobs.get(runId) ?? state.fleetJobs?.get(runId), step = job?.steps?.find((candidate, index) => (candidate.index ?? index) === childIndex && (!childId || (candidate.childId ?? candidate.agent) === childId)), label = step?.description ?? (step?.agent !== childId ? step?.agent : void 0);
|
|
1941
|
+
if (label)
|
|
1942
|
+
return (job?.steps?.filter((candidate) => (candidate.description ?? candidate.agent) === label).length ?? 0) > 1 ? `${label} \xB7 ${childIndex + 1}` : label;
|
|
1943
|
+
let foreground = state.foregroundControls.get(runId);
|
|
1944
|
+
if (foreground?.currentIndex === childIndex && (!childId || foreground.currentChildId === childId) && foreground.currentAgent && foreground.currentAgent !== childId)
|
|
1945
|
+
return foreground.currentAgent;
|
|
1946
|
+
let remembered = state.foregroundRuns?.get(runId)?.children.find((child) => child.index === childIndex);
|
|
1947
|
+
return remembered?.agent && remembered.agent !== childId ? remembered.agent : fallback?.trim() || `Subagent ${childIndex + 1}`;
|
|
1948
|
+
}
|
|
1949
|
+
function legacySupervisorBody(content) {
|
|
1950
|
+
return content.replace(/^Subagent (?:progress update\.|needs a supervisor decision\.|requests a structured supervisor interview\.)\r?\nRun: [^\n]*\r?\nAgent: [^\n]*\r?\nChild index: [^\n]*\r?\n(?:Child intercom target: [^\n]*\r?\n)?\r?\n/, "").replace(/^Subagent answer \([^\n]*\)\r?\nRun: [^\n]*\r?\nChild: [^\n]*\r?\nDecision: [^\n]*\r?\n\r?\n/, "").replace(/\r?\n\r?\nReply with: subagent_supervisor\([^\n]*\)\s*$/, "");
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1924
1953
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js
|
|
1925
1954
|
var TASK_ARG_LIMIT = 8e3;
|
|
1926
1955
|
function resolveRuntimeScriptPath(basePathWithoutExt) {
|
|
@@ -1984,7 +2013,7 @@ function buildPiArgs(input) {
|
|
|
1984
2013
|
...input.childAgentName ? { agent: input.childAgentName } : {}
|
|
1985
2014
|
}] : []
|
|
1986
2015
|
];
|
|
1987
|
-
if (env[SUBAGENT_PARENT_EVENT_SINK_ENV] = fanoutAuthorized ? input.parentEventSink ?? process.env[SUBAGENT_PARENT_EVENT_SINK_ENV] ?? "" : "", env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] = fanoutAuthorized ? input.parentControlInbox ?? process.env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] ?? "" : "", env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] = fanoutAuthorized ? input.parentRootRunId ?? process.env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] ?? input.runId ?? "" : "", env[SUBAGENT_PARENT_RUN_ID_ENV] = fanoutAuthorized ? parentRunId : "", env[SUBAGENT_PARENT_CHILD_INDEX_ENV] = fanoutAuthorized ? parentChildIndex : "", env[SUBAGENT_PARENT_DEPTH_ENV] = fanoutAuthorized ? String(parentDepth) : "", env[SUBAGENT_PARENT_PATH_ENV] = fanoutAuthorized ? encodeNestedPathEnv(parentPath) : "", env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] = fanoutAuthorized ? input.parentCapabilityToken ?? process.env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] ?? "" : "", env.PI_SUBAGENT_INHERIT_PROJECT_CONTEXT = input.inheritProjectContext ? "1" : "0", env.PI_SUBAGENT_INHERIT_SKILLS = input.inheritSkills ? "1" : "0", input.intercomSessionName && (env.PI_SUBAGENT_INTERCOM_SESSION_NAME = input.intercomSessionName), input.orchestratorIntercomTarget && (env[SUBAGENT_ORCHESTRATOR_TARGET_ENV] = input.orchestratorIntercomTarget), input.parentSessionId && (env[SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV] = input.parentSessionId), env[SUBAGENT_SUPERVISOR_SESSION_ID_ENV] = input.supervisorSessionId ?? "", input.parentSessionId && input.runId && (input.childId || input.childAgentName)) {
|
|
2016
|
+
if (env[SUBAGENT_PARENT_EVENT_SINK_ENV] = fanoutAuthorized ? input.parentEventSink ?? process.env[SUBAGENT_PARENT_EVENT_SINK_ENV] ?? "" : "", env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] = fanoutAuthorized ? input.parentControlInbox ?? process.env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] ?? "" : "", env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] = fanoutAuthorized ? input.parentRootRunId ?? process.env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] ?? input.runId ?? "" : "", env[SUBAGENT_PARENT_RUN_ID_ENV] = fanoutAuthorized ? parentRunId : "", env[SUBAGENT_PARENT_CHILD_INDEX_ENV] = fanoutAuthorized ? parentChildIndex : "", env[SUBAGENT_PARENT_DEPTH_ENV] = fanoutAuthorized ? String(parentDepth) : "", env[SUBAGENT_PARENT_PATH_ENV] = fanoutAuthorized ? encodeNestedPathEnv(parentPath) : "", env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] = fanoutAuthorized ? input.parentCapabilityToken ?? process.env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] ?? "" : "", env.PI_SUBAGENT_INHERIT_PROJECT_CONTEXT = input.inheritProjectContext ? "1" : "0", env.PI_SUBAGENT_INHERIT_SKILLS = input.inheritSkills ? "1" : "0", input.intercomSessionName && (env.PI_SUBAGENT_INTERCOM_SESSION_NAME = input.intercomSessionName), input.orchestratorIntercomTarget && (env[SUBAGENT_ORCHESTRATOR_TARGET_ENV] = input.orchestratorIntercomTarget), input.parentSessionId && (env[SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV] = input.parentSessionId), env[SUBAGENT_SUPERVISOR_SESSION_ID_ENV] = input.supervisorSessionId ?? "", env[SUPERVISOR_PROTOCOL_ENV] = String(2), env[CHILD_DESCRIPTION_ENV] = input.childDescription ?? input.childAgentName ?? "", input.parentSessionId && input.runId && (input.childId || input.childAgentName)) {
|
|
1988
2017
|
let childIndex = input.childIndex ?? 0, channelAgent = input.childId ?? input.childAgentName, channelDir = supervisorChannelDir(input.runId, channelAgent, childIndex);
|
|
1989
2018
|
fs9.mkdirSync(path10.join(channelDir, "requests"), { recursive: !0 }), fs9.mkdirSync(path10.join(channelDir, "replies"), { recursive: !0 }), fs9.mkdirSync(path10.join(channelDir, "questions"), { recursive: !0 }), env[SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV] = channelDir, env[SUBAGENT_CHILD_INDEX_ENV] = String(childIndex);
|
|
1990
2019
|
}
|
|
@@ -2531,135 +2560,6 @@ function resolveSubagentRequestParams(params) {
|
|
|
2531
2560
|
return omitConflictingControlAction(omitExecutionModeActionAlias(params));
|
|
2532
2561
|
}
|
|
2533
2562
|
|
|
2534
|
-
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js
|
|
2535
|
-
var CONTROL_EVENT_TYPES = ["active_long_running", "needs_attention"], CONTROL_NOTIFICATION_CHANNELS = ["event", "async", "intercom"], DEFAULT_NOTIFY_ON = ["active_long_running", "needs_attention"], DEFAULT_CONTROL_CONFIG = {
|
|
2536
|
-
enabled: !0,
|
|
2537
|
-
needsAttentionAfterMs: 6e4,
|
|
2538
|
-
activeNoticeAfterMs: 24e4,
|
|
2539
|
-
failedToolAttemptsBeforeAttention: 3,
|
|
2540
|
-
notifyOn: DEFAULT_NOTIFY_ON,
|
|
2541
|
-
notifyChannels: CONTROL_NOTIFICATION_CHANNELS
|
|
2542
|
-
};
|
|
2543
|
-
function parsePositiveInt(value) {
|
|
2544
|
-
if (typeof value == "number" && !(!Number.isFinite(value) || !Number.isInteger(value) || value < 1))
|
|
2545
|
-
return value;
|
|
2546
|
-
}
|
|
2547
|
-
function parseControlList(value, allowed) {
|
|
2548
|
-
if (!Array.isArray(value))
|
|
2549
|
-
return;
|
|
2550
|
-
if (value.length === 0)
|
|
2551
|
-
return [];
|
|
2552
|
-
let allowedSet = new Set(allowed), parsed = value.filter((entry) => typeof entry == "string" && allowedSet.has(entry));
|
|
2553
|
-
return parsed.length > 0 ? Array.from(new Set(parsed)) : void 0;
|
|
2554
|
-
}
|
|
2555
|
-
function resolveControlConfig(globalConfig, override) {
|
|
2556
|
-
let enabled = override?.enabled ?? globalConfig?.enabled ?? DEFAULT_CONTROL_CONFIG.enabled, needsAttentionAfterMs = parsePositiveInt(override?.needsAttentionAfterMs) ?? parsePositiveInt(globalConfig?.needsAttentionAfterMs) ?? DEFAULT_CONTROL_CONFIG.needsAttentionAfterMs, activeNoticeAfterMs = parsePositiveInt(override?.activeNoticeAfterMs) ?? parsePositiveInt(globalConfig?.activeNoticeAfterMs) ?? DEFAULT_CONTROL_CONFIG.activeNoticeAfterMs, activeNoticeAfterTurns = parsePositiveInt(override?.activeNoticeAfterTurns) ?? parsePositiveInt(globalConfig?.activeNoticeAfterTurns), activeNoticeAfterTokens = parsePositiveInt(override?.activeNoticeAfterTokens) ?? parsePositiveInt(globalConfig?.activeNoticeAfterTokens), failedToolAttemptsBeforeAttention = parsePositiveInt(override?.failedToolAttemptsBeforeAttention) ?? parsePositiveInt(globalConfig?.failedToolAttemptsBeforeAttention) ?? DEFAULT_CONTROL_CONFIG.failedToolAttemptsBeforeAttention, notifyOn = parseControlList(override?.notifyOn, CONTROL_EVENT_TYPES) ?? parseControlList(globalConfig?.notifyOn, CONTROL_EVENT_TYPES) ?? DEFAULT_CONTROL_CONFIG.notifyOn, notifyChannels = parseControlList(override?.notifyChannels, CONTROL_NOTIFICATION_CHANNELS) ?? parseControlList(globalConfig?.notifyChannels, CONTROL_NOTIFICATION_CHANNELS) ?? DEFAULT_CONTROL_CONFIG.notifyChannels;
|
|
2557
|
-
return {
|
|
2558
|
-
enabled,
|
|
2559
|
-
needsAttentionAfterMs,
|
|
2560
|
-
activeNoticeAfterMs,
|
|
2561
|
-
activeNoticeAfterTurns,
|
|
2562
|
-
activeNoticeAfterTokens,
|
|
2563
|
-
failedToolAttemptsBeforeAttention,
|
|
2564
|
-
notifyOn: [...notifyOn],
|
|
2565
|
-
notifyChannels: [...notifyChannels]
|
|
2566
|
-
};
|
|
2567
|
-
}
|
|
2568
|
-
function deriveActivityState(input) {
|
|
2569
|
-
if (!input.config.enabled)
|
|
2570
|
-
return;
|
|
2571
|
-
let now = input.now ?? Date.now(), lastActivity = input.lastActivityAt ?? input.startedAt;
|
|
2572
|
-
return Math.max(0, now - lastActivity) > input.config.needsAttentionAfterMs ? "needs_attention" : void 0;
|
|
2573
|
-
}
|
|
2574
|
-
function buildControlEvent(input) {
|
|
2575
|
-
let ts = input.ts ?? Date.now(), type = input.type ?? (input.to === "active_long_running" ? "active_long_running" : "needs_attention"), elapsedMs = input.elapsedMs ?? (input.lastActivityAt ? Math.max(0, ts - input.lastActivityAt) : void 0), elapsedSeconds = elapsedMs !== void 0 ? Math.floor(elapsedMs / 1e3) : void 0, message = input.message ?? (type === "active_long_running" ? `${input.agent} is still active but long-running` : elapsedSeconds !== void 0 ? `${input.agent} needs attention (no observed activity for ${elapsedSeconds}s)` : `${input.agent} needs attention`);
|
|
2576
|
-
return {
|
|
2577
|
-
type,
|
|
2578
|
-
...input.from ? { from: input.from } : {},
|
|
2579
|
-
to: input.to,
|
|
2580
|
-
ts,
|
|
2581
|
-
runId: input.runId,
|
|
2582
|
-
agent: input.agent,
|
|
2583
|
-
...input.index !== void 0 ? { index: input.index } : {},
|
|
2584
|
-
message,
|
|
2585
|
-
reason: input.reason ?? (type === "active_long_running" ? "active_long_running" : "idle"),
|
|
2586
|
-
...input.turns !== void 0 ? { turns: input.turns } : {},
|
|
2587
|
-
...input.tokens !== void 0 ? { tokens: input.tokens } : {},
|
|
2588
|
-
...input.toolCount !== void 0 ? { toolCount: input.toolCount } : {},
|
|
2589
|
-
...input.currentTool ? { currentTool: input.currentTool } : {},
|
|
2590
|
-
...input.currentToolDurationMs !== void 0 ? { currentToolDurationMs: input.currentToolDurationMs } : {},
|
|
2591
|
-
...input.currentPath ? { currentPath: input.currentPath } : {},
|
|
2592
|
-
...elapsedMs !== void 0 ? { elapsedMs } : {},
|
|
2593
|
-
...input.recentFailureSummary ? { recentFailureSummary: input.recentFailureSummary } : {}
|
|
2594
|
-
};
|
|
2595
|
-
}
|
|
2596
|
-
function shouldNotifyControlEvent(config, event) {
|
|
2597
|
-
return config.enabled && config.notifyOn.includes(event.type);
|
|
2598
|
-
}
|
|
2599
|
-
function controlNotificationKey(event, childIntercomTarget) {
|
|
2600
|
-
return `${childIntercomTarget ?? (event.index !== void 0 ? `${event.runId}:${event.index}` : event.runId)}:${event.type}:${event.reason ?? "idle"}`;
|
|
2601
|
-
}
|
|
2602
|
-
function claimControlNotification(config, event, seenKeys, childIntercomTarget) {
|
|
2603
|
-
if (!shouldNotifyControlEvent(config, event))
|
|
2604
|
-
return !1;
|
|
2605
|
-
let key = controlNotificationKey(event, childIntercomTarget);
|
|
2606
|
-
return seenKeys.has(key) ? !1 : (seenKeys.add(key), !0);
|
|
2607
|
-
}
|
|
2608
|
-
function formatLongRunningFacts(event) {
|
|
2609
|
-
let facts = [];
|
|
2610
|
-
return event.elapsedMs !== void 0 && facts.push(`elapsed ${Math.floor(Math.max(0, event.elapsedMs) / 1e3)}s`), event.turns !== void 0 && facts.push(`${event.turns} turns`), event.tokens !== void 0 && facts.push(`${event.tokens} tokens`), event.toolCount !== void 0 && facts.push(`${event.toolCount} tools`), event.currentTool && facts.push(`tool ${event.currentTool}${event.currentToolDurationMs !== void 0 ? ` ${Math.floor(Math.max(0, event.currentToolDurationMs) / 1e3)}s` : ""}`), event.currentPath && facts.push(`path ${event.currentPath}`), facts.length > 0 ? facts.join(" | ") : void 0;
|
|
2611
|
-
}
|
|
2612
|
-
function formatControlNoticeMessage(event, childIntercomTarget) {
|
|
2613
|
-
let runTarget = event.runId;
|
|
2614
|
-
if (event.reason === "completion_guard")
|
|
2615
|
-
return [
|
|
2616
|
-
`Subagent failed: ${event.agent}`,
|
|
2617
|
-
`Run: ${runTarget}${event.index !== void 0 ? ` step ${event.index + 1}` : ""}`,
|
|
2618
|
-
`Signal: ${event.message}`,
|
|
2619
|
-
"Next: read the output artifact or session from the subagent result, then retry with a more explicit implementation prompt or handle the fix directly.",
|
|
2620
|
-
childIntercomTarget ? `Run intercom target (may be inactive): ${childIntercomTarget}` : void 0
|
|
2621
|
-
].filter((line) => !!line).join(`
|
|
2622
|
-
`);
|
|
2623
|
-
let nudgeCommand = `subagent({ action: "resume", id: "${runTarget}", ${event.index !== void 0 ? `index: ${event.index}, ` : ""}message: "What are you blocked on? Reply with the smallest next step or ask for a decision." })`;
|
|
2624
|
-
if (event.type === "active_long_running") {
|
|
2625
|
-
let facts = formatLongRunningFacts(event);
|
|
2626
|
-
return [
|
|
2627
|
-
`Subagent active but long-running: ${event.agent}`,
|
|
2628
|
-
`Run: ${runTarget}${event.index !== void 0 ? ` step ${event.index + 1}` : ""}`,
|
|
2629
|
-
`Signal: ${event.message}`,
|
|
2630
|
-
facts ? `Facts: ${facts}` : void 0,
|
|
2631
|
-
"Hint: Inspect status, then nudge if the work seems stuck. Live async nudges interrupt the child before sending the follow-up.",
|
|
2632
|
-
`Nudge: ${nudgeCommand}`,
|
|
2633
|
-
childIntercomTarget ? `Direct intercom target: ${childIntercomTarget}` : void 0,
|
|
2634
|
-
`Status: subagent({ action: "status", id: "${runTarget}" })`,
|
|
2635
|
-
`Interrupt: subagent({ action: "interrupt", id: "${runTarget}" })`
|
|
2636
|
-
].filter((line) => !!line).join(`
|
|
2637
|
-
`);
|
|
2638
|
-
}
|
|
2639
|
-
return [
|
|
2640
|
-
`Subagent needs attention: ${event.agent}`,
|
|
2641
|
-
`Run: ${runTarget}${event.index !== void 0 ? ` step ${event.index + 1}` : ""}`,
|
|
2642
|
-
`Signal: ${event.message}`,
|
|
2643
|
-
event.recentFailureSummary ? `Recent failures: ${event.recentFailureSummary}` : void 0,
|
|
2644
|
-
"Hint: Inspect status first unless the run is clearly blocked. Live async nudges interrupt the child before sending the follow-up.",
|
|
2645
|
-
`Nudge: ${nudgeCommand}`,
|
|
2646
|
-
childIntercomTarget ? `Direct intercom target: ${childIntercomTarget}` : void 0,
|
|
2647
|
-
`Status: subagent({ action: "status", id: "${runTarget}" })`,
|
|
2648
|
-
`Interrupt: subagent({ action: "interrupt", id: "${runTarget}" })`
|
|
2649
|
-
].filter((line) => !!line).join(`
|
|
2650
|
-
`);
|
|
2651
|
-
}
|
|
2652
|
-
function formatControlIntercomMessage(event, childIntercomTarget) {
|
|
2653
|
-
return [
|
|
2654
|
-
event.reason === "completion_guard" ? "subagent failed" : event.type === "active_long_running" ? "subagent active but long-running" : "subagent needs attention",
|
|
2655
|
-
"",
|
|
2656
|
-
event.reason === "completion_guard" ? `${event.agent} failed in run ${event.runId}.` : event.type === "active_long_running" ? `${event.agent} is still active but long-running in run ${event.runId}.` : `${event.agent} needs attention in run ${event.runId}.`,
|
|
2657
|
-
"",
|
|
2658
|
-
formatControlNoticeMessage(event, childIntercomTarget)
|
|
2659
|
-
].join(`
|
|
2660
|
-
`);
|
|
2661
|
-
}
|
|
2662
|
-
|
|
2663
2563
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-events.js
|
|
2664
2564
|
import { randomUUID } from "node:crypto";
|
|
2665
2565
|
import * as fs11 from "node:fs";
|
|
@@ -4980,17 +4880,10 @@ function defaultAgentDir() {
|
|
|
4980
4880
|
function defaultSubagentConfigDir(agentDir = defaultAgentDir()) {
|
|
4981
4881
|
return path16.join(agentDir, "extensions", "subagent");
|
|
4982
4882
|
}
|
|
4983
|
-
var DEFAULT_INTERCOM_TARGET_PREFIX = "subagent-chat", INTERCOM_BRIDGE_MARKER = "Intercom orchestration channel:", DEFAULT_INTERCOM_BRIDGE_TEMPLATE = `
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
-
|
|
4987
|
-
- Need structured supervisor input rather than a freeform reply: contact_supervisor({ reason: "interview_request", message: "<what input is needed>", interview: { title: "...", questions: [] } })
|
|
4988
|
-
- After contact_supervisor with reason "need_decision" or "interview_request", stay alive and continue only after the reply arrives. Do not finish your final response with a choose-one question.
|
|
4989
|
-
- Do not ask for clarification when the only conflict is review-only/no-edit versus progress-writing or artifact-writing instructions. If an output path is configured but no write-capable tool is available, return the complete artifact in your final response; the runtime will persist it. Do not contact the supervisor merely because you cannot write that output path directly.
|
|
4990
|
-
- Meaningful progress or unexpected discoveries that change the plan: contact_supervisor({ reason: "progress_update", message: "UPDATE: <summary>" })
|
|
4991
|
-
- Generic intercom is lower-level plumbing/fallback only: intercom({ action: "ask", to: "{orchestratorTarget}", message: "<question>" })
|
|
4992
|
-
|
|
4993
|
-
Do not use contact_supervisor or intercom for routine completion handoffs. If no coordination is needed, return a focused task result.`;
|
|
4883
|
+
var DEFAULT_INTERCOM_TARGET_PREFIX = "subagent-chat", INTERCOM_BRIDGE_MARKER = "Intercom orchestration channel:", DEFAULT_INTERCOM_BRIDGE_TEMPLATE = `You own reversible implementation decisions within your assigned scope. Use contact_supervisor for coordination with "{orchestratorTarget}"; its tool description defines delivery and reply behavior.
|
|
4884
|
+
Consolidate dependency findings into one handoff when another task needs them before completion. Escalate permission, safety, scope changes, or a blocked decision with evidence and your recommended choice. Continue independent work before opening a blocking request.
|
|
4885
|
+
Native intercom reaches only the supervisor, not siblings. Use the supplied contracts and artifacts instead of discovering sibling sessions.
|
|
4886
|
+
Return one self-contained final result; the runtime delivers it. If you cannot write a configured output artifact with your available tools, return its complete contents for the runtime to persist.`;
|
|
4994
4887
|
function resolveIntercomSessionTarget(sessionName, sessionId) {
|
|
4995
4888
|
let trimmedName = sessionName?.trim();
|
|
4996
4889
|
if (trimmedName)
|
|
@@ -5645,6 +5538,10 @@ function deliverControlNotice(input) {
|
|
|
5645
5538
|
return;
|
|
5646
5539
|
input.visibleControlNotices.add(key);
|
|
5647
5540
|
let noticeText = input.details.noticeText ?? formatControlNoticeMessage(input.details.event, childIntercomTarget);
|
|
5541
|
+
if (isDiagnosticControlEvent(input.details.event)) {
|
|
5542
|
+
input.pi.appendEntry(SUBAGENT_CONTROL_MESSAGE_TYPE, { ...input.details, childIntercomTarget, noticeText });
|
|
5543
|
+
return;
|
|
5544
|
+
}
|
|
5648
5545
|
input.pi.sendMessage({
|
|
5649
5546
|
customType: SUBAGENT_CONTROL_MESSAGE_TYPE,
|
|
5650
5547
|
content: noticeText,
|
|
@@ -8540,6 +8437,11 @@ export {
|
|
|
8540
8437
|
childWatchdogIsActive,
|
|
8541
8438
|
acceptChildWatchdogEvent,
|
|
8542
8439
|
resolveWaitToolConfig,
|
|
8440
|
+
SUPERVISOR_REQUEST_TYPE,
|
|
8441
|
+
SUPERVISOR_PROGRESS_TYPE,
|
|
8442
|
+
readCommunication,
|
|
8443
|
+
resolveCommunicationPeer,
|
|
8444
|
+
legacySupervisorBody,
|
|
8543
8445
|
SUBAGENT_CHILD_ENV,
|
|
8544
8446
|
SUBAGENT_FANOUT_CHILD_ENV,
|
|
8545
8447
|
SUBAGENT_PARENT_SESSION_ENV,
|
|
@@ -8564,14 +8466,6 @@ export {
|
|
|
8564
8466
|
formatNestedAggregate,
|
|
8565
8467
|
formatNestedRunStatusLines,
|
|
8566
8468
|
resolveSubagentRequestParams,
|
|
8567
|
-
DEFAULT_CONTROL_CONFIG,
|
|
8568
|
-
resolveControlConfig,
|
|
8569
|
-
deriveActivityState,
|
|
8570
|
-
buildControlEvent,
|
|
8571
|
-
shouldNotifyControlEvent,
|
|
8572
|
-
claimControlNotification,
|
|
8573
|
-
formatControlNoticeMessage,
|
|
8574
|
-
formatControlIntercomMessage,
|
|
8575
8469
|
writeAtomicJson,
|
|
8576
8470
|
writePrivateAtomicJson,
|
|
8577
8471
|
createNestedRoute,
|
|
@@ -8636,6 +8530,7 @@ export {
|
|
|
8636
8530
|
resolveWatchdogConfig,
|
|
8637
8531
|
buildWatchdogStatus,
|
|
8638
8532
|
registerMainWatchdog,
|
|
8533
|
+
stopRequestPath,
|
|
8639
8534
|
requestAsyncSteer,
|
|
8640
8535
|
readSteerCapability,
|
|
8641
8536
|
consumeSteerAcks,
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
getAgentDir
|
|
4
|
+
} from "./chunk-FQMM2EZ2.js";
|
|
5
|
+
|
|
6
|
+
// packages/coding-agent/dist/gateway/config.js
|
|
7
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
function gatewayConfigPath() {
|
|
10
|
+
return join(getAgentDir(), "gateway.json");
|
|
11
|
+
}
|
|
12
|
+
function defaultPlatformConfig(requireMention) {
|
|
13
|
+
return {
|
|
14
|
+
enabled: !1,
|
|
15
|
+
allowedUsers: [],
|
|
16
|
+
allowedChats: [],
|
|
17
|
+
requireMention,
|
|
18
|
+
freeResponseChats: []
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function defaultGatewayConfig() {
|
|
22
|
+
return {
|
|
23
|
+
owners: { telegram: [], discord: [] },
|
|
24
|
+
projectRoots: [],
|
|
25
|
+
telegram: defaultPlatformConfig(!1),
|
|
26
|
+
discord: { ...defaultPlatformConfig(!0), ignoredChannels: [], autoThread: !0 },
|
|
27
|
+
groupSessionsPerUser: !0,
|
|
28
|
+
unauthorizedDmBehavior: "pair",
|
|
29
|
+
streaming: { enabled: !0, editIntervalMs: 800, bufferThreshold: 24 }
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function asStringArray(value) {
|
|
33
|
+
if (Array.isArray(value))
|
|
34
|
+
return value.every((v) => typeof v == "string") ? value : void 0;
|
|
35
|
+
}
|
|
36
|
+
function asBoolean(value) {
|
|
37
|
+
return typeof value == "boolean" ? value : void 0;
|
|
38
|
+
}
|
|
39
|
+
function asNumber(value) {
|
|
40
|
+
return typeof value == "number" && Number.isFinite(value) ? value : void 0;
|
|
41
|
+
}
|
|
42
|
+
function sanitizePlatform(raw, base) {
|
|
43
|
+
if (raw == null || typeof raw != "object" || Array.isArray(raw))
|
|
44
|
+
return base;
|
|
45
|
+
let r = raw;
|
|
46
|
+
return {
|
|
47
|
+
enabled: asBoolean(r.enabled) ?? base.enabled,
|
|
48
|
+
token: typeof r.token == "string" ? r.token : base.token,
|
|
49
|
+
allowedUsers: asStringArray(r.allowedUsers) ?? base.allowedUsers,
|
|
50
|
+
allowedChats: asStringArray(r.allowedChats) ?? base.allowedChats,
|
|
51
|
+
requireMention: asBoolean(r.requireMention) ?? base.requireMention,
|
|
52
|
+
freeResponseChats: asStringArray(r.freeResponseChats) ?? base.freeResponseChats,
|
|
53
|
+
homeChannel: typeof r.homeChannel == "string" ? r.homeChannel : base.homeChannel
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function sanitizeDiscord(raw, base) {
|
|
57
|
+
let platform = sanitizePlatform(raw, base), r = raw != null && typeof raw == "object" && !Array.isArray(raw) ? raw : {};
|
|
58
|
+
return {
|
|
59
|
+
...platform,
|
|
60
|
+
ignoredChannels: asStringArray(r.ignoredChannels) ?? base.ignoredChannels,
|
|
61
|
+
autoThread: asBoolean(r.autoThread) ?? base.autoThread
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function sanitizeConfig(raw) {
|
|
65
|
+
let base = defaultGatewayConfig();
|
|
66
|
+
if (raw == null || typeof raw != "object" || Array.isArray(raw))
|
|
67
|
+
return base;
|
|
68
|
+
let r = raw, streamingRaw = r.streaming != null && typeof r.streaming == "object" && !Array.isArray(r.streaming) ? r.streaming : {}, owners = r.owners && typeof r.owners == "object" ? r.owners : {};
|
|
69
|
+
return {
|
|
70
|
+
owners: { telegram: asStringArray(owners.telegram) ?? [], discord: asStringArray(owners.discord) ?? [] },
|
|
71
|
+
projectRoots: asStringArray(r.projectRoots) ?? [],
|
|
72
|
+
telegram: sanitizePlatform(r.telegram, base.telegram),
|
|
73
|
+
discord: sanitizeDiscord(r.discord, base.discord),
|
|
74
|
+
groupSessionsPerUser: asBoolean(r.groupSessionsPerUser) ?? base.groupSessionsPerUser,
|
|
75
|
+
unauthorizedDmBehavior: r.unauthorizedDmBehavior === "ignore" ? "ignore" : "pair",
|
|
76
|
+
streaming: {
|
|
77
|
+
enabled: asBoolean(streamingRaw.enabled) ?? base.streaming.enabled,
|
|
78
|
+
editIntervalMs: asNumber(streamingRaw.editIntervalMs) ?? base.streaming.editIntervalMs,
|
|
79
|
+
bufferThreshold: asNumber(streamingRaw.bufferThreshold) ?? base.streaming.bufferThreshold
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function loadGatewayConfig() {
|
|
84
|
+
let path = gatewayConfigPath();
|
|
85
|
+
if (!existsSync(path))
|
|
86
|
+
return defaultGatewayConfig();
|
|
87
|
+
try {
|
|
88
|
+
return sanitizeConfig(JSON.parse(readFileSync(path, "utf-8")));
|
|
89
|
+
} catch (err) {
|
|
90
|
+
return console.error(`[gateway] Failed to load config from ${path}: ${err}`), defaultGatewayConfig();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function saveGatewayConfig(config) {
|
|
94
|
+
let path = gatewayConfigPath(), dir = getAgentDir();
|
|
95
|
+
existsSync(dir) || mkdirSync(dir, { recursive: !0 });
|
|
96
|
+
let tmp = `${path}.tmp-${process.pid}`;
|
|
97
|
+
writeFileSync(tmp, `${JSON.stringify(config, null, 2)}
|
|
98
|
+
`, "utf-8"), renameSync(tmp, path);
|
|
99
|
+
try {
|
|
100
|
+
chmodSync(path, 384);
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function resolvePlatformToken(platform, platformCfg) {
|
|
105
|
+
let upper = platform.toUpperCase();
|
|
106
|
+
return process.env[`LUNR_${upper}_BOT_TOKEN`] ?? process.env[`${upper}_BOT_TOKEN`] ?? platformCfg.token;
|
|
107
|
+
}
|
|
108
|
+
function platformConfigFor(cfg, platform) {
|
|
109
|
+
if (platform === "telegram")
|
|
110
|
+
return cfg.telegram;
|
|
111
|
+
if (platform === "discord")
|
|
112
|
+
return cfg.discord;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
gatewayConfigPath,
|
|
117
|
+
defaultGatewayConfig,
|
|
118
|
+
loadGatewayConfig,
|
|
119
|
+
saveGatewayConfig,
|
|
120
|
+
resolvePlatformToken,
|
|
121
|
+
platformConfigFor
|
|
122
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
getAgentDir
|
|
4
|
+
} from "./chunk-FQMM2EZ2.js";
|
|
5
|
+
|
|
6
|
+
// packages/coding-agent/dist/gateway/pairing.js
|
|
7
|
+
import { randomInt } from "node:crypto";
|
|
8
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
var CODE_ALPHABET = "ABCDEFGHJKMNPQRSTUVWXYZ23456789", CODE_LENGTH = 8, DEFAULT_TTL_MS = 3600 * 1e3, DEFAULT_RATE_LIMIT_MS = 600 * 1e3, DEFAULT_MAX_PENDING = 3, DEFAULT_MAX_FAILS = 5, DEFAULT_LOCKOUT_MS = 3600 * 1e3;
|
|
11
|
+
function normalizeCode(code) {
|
|
12
|
+
return code.replace(/-/g, "").trim().toUpperCase();
|
|
13
|
+
}
|
|
14
|
+
function generateCode() {
|
|
15
|
+
let code = "";
|
|
16
|
+
for (let i = 0; i < CODE_LENGTH; i++)
|
|
17
|
+
code += CODE_ALPHABET[randomInt(0, CODE_ALPHABET.length)];
|
|
18
|
+
return code;
|
|
19
|
+
}
|
|
20
|
+
function createPairingStore(options = {}) {
|
|
21
|
+
let dir = options.dir ?? join(getAgentDir(), "pairing"), ttlMs = options.ttlMs ?? DEFAULT_TTL_MS, rateLimitMs = options.rateLimitMs ?? DEFAULT_RATE_LIMIT_MS, maxPending = options.maxPending ?? DEFAULT_MAX_PENDING, maxFails = options.maxFails ?? DEFAULT_MAX_FAILS, lockoutMs = options.lockoutMs ?? DEFAULT_LOCKOUT_MS, now = options.now ?? (() => Date.now());
|
|
22
|
+
function storeFile() {
|
|
23
|
+
return join(dir, "store.json");
|
|
24
|
+
}
|
|
25
|
+
function read() {
|
|
26
|
+
let path = storeFile();
|
|
27
|
+
if (!existsSync(path))
|
|
28
|
+
return { pending: [], approved: [] };
|
|
29
|
+
try {
|
|
30
|
+
let parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
31
|
+
if (parsed == null || typeof parsed != "object" || Array.isArray(parsed))
|
|
32
|
+
return { pending: [], approved: [] };
|
|
33
|
+
let p = parsed, pending = Array.isArray(p.pending) ? p.pending : [], approved = Array.isArray(p.approved) ? p.approved : [];
|
|
34
|
+
return {
|
|
35
|
+
pending: pending.filter((c) => typeof c?.code == "string" && typeof c?.platform == "string" && typeof c?.userId == "string"),
|
|
36
|
+
approved: approved.filter((u) => typeof u?.platform == "string" && typeof u?.userId == "string"),
|
|
37
|
+
failedAttempts: typeof p.failedAttempts == "object" && p.failedAttempts !== null && !Array.isArray(p.failedAttempts) ? p.failedAttempts : void 0,
|
|
38
|
+
lockedOutUntil: typeof p.lockedOutUntil == "object" && p.lockedOutUntil !== null && !Array.isArray(p.lockedOutUntil) ? p.lockedOutUntil : void 0
|
|
39
|
+
};
|
|
40
|
+
} catch {
|
|
41
|
+
return { pending: [], approved: [] };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function write(data) {
|
|
45
|
+
existsSync(dir) || mkdirSync(dir, { recursive: !0 });
|
|
46
|
+
let path = storeFile(), tmp = `${path}.tmp-${process.pid}`;
|
|
47
|
+
writeFileSync(tmp, `${JSON.stringify(data, null, 2)}
|
|
48
|
+
`, "utf-8"), renameSync(tmp, path);
|
|
49
|
+
try {
|
|
50
|
+
chmodSync(path, 384);
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function isLockedOut(platform) {
|
|
55
|
+
let until = read().lockedOutUntil?.[platform] ?? 0;
|
|
56
|
+
return now() < until;
|
|
57
|
+
}
|
|
58
|
+
function recordFailedAttempt(platform) {
|
|
59
|
+
let data = read(), failed = data.failedAttempts ?? {};
|
|
60
|
+
if (failed[platform] = (failed[platform] ?? 0) + 1, failed[platform] >= maxFails) {
|
|
61
|
+
let locked = data.lockedOutUntil ?? {};
|
|
62
|
+
locked[platform] = now() + lockoutMs, failed[platform] = 0, data.lockedOutUntil = locked;
|
|
63
|
+
}
|
|
64
|
+
data.failedAttempts = failed, write(data);
|
|
65
|
+
}
|
|
66
|
+
function livePending(data) {
|
|
67
|
+
let cutoff = now() - ttlMs;
|
|
68
|
+
return data.pending.filter((c) => c.issuedAt >= cutoff);
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
issueCode(platform, userId) {
|
|
72
|
+
if (isLockedOut(platform))
|
|
73
|
+
return null;
|
|
74
|
+
let data = read(), lastIssued = data.pending.filter((c) => c.platform === platform && c.userId === userId).reduce((max, c) => Math.max(max, c.issuedAt), 0);
|
|
75
|
+
if (lastIssued > 0 && now() - lastIssued < rateLimitMs)
|
|
76
|
+
return null;
|
|
77
|
+
let live = livePending(data);
|
|
78
|
+
if (live.filter((c) => c.platform === platform).length >= maxPending)
|
|
79
|
+
return null;
|
|
80
|
+
let entry = {
|
|
81
|
+
code: generateCode(),
|
|
82
|
+
platform,
|
|
83
|
+
userId,
|
|
84
|
+
issuedAt: now()
|
|
85
|
+
};
|
|
86
|
+
return data.pending = [...live, entry], write(data), entry.code;
|
|
87
|
+
},
|
|
88
|
+
approve(platform, code) {
|
|
89
|
+
if (isLockedOut(platform))
|
|
90
|
+
return null;
|
|
91
|
+
let data = read(), live = livePending(data), normalized = normalizeCode(code), match = live.find((c) => c.platform === platform && c.code === normalized);
|
|
92
|
+
return match ? (data.pending = live.filter((c) => c !== match), data.approved = [
|
|
93
|
+
...data.approved.filter((u) => !(u.platform === platform && u.userId === match.userId)),
|
|
94
|
+
{ platform, userId: match.userId, approvedAt: now() }
|
|
95
|
+
], write(data), match.userId) : (recordFailedAttempt(platform), null);
|
|
96
|
+
},
|
|
97
|
+
isPaired(platform, userId) {
|
|
98
|
+
return read().approved.some((u) => u.platform === platform && u.userId === userId);
|
|
99
|
+
},
|
|
100
|
+
listPending() {
|
|
101
|
+
let data = read();
|
|
102
|
+
return livePending(data).map((c) => ({
|
|
103
|
+
code: c.code,
|
|
104
|
+
platform: c.platform,
|
|
105
|
+
userId: c.userId,
|
|
106
|
+
expiresAt: c.issuedAt + ttlMs
|
|
107
|
+
}));
|
|
108
|
+
},
|
|
109
|
+
listApproved() {
|
|
110
|
+
return read().approved.map((u) => ({ platform: u.platform, userId: u.userId, approvedAt: u.approvedAt }));
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
createPairingStore
|
|
117
|
+
};
|