@ashx-j/lunr-dev 0.2.21-dev.12.1 → 0.2.25-dev.13.1
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 +25 -2
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +2 -2
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- 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 +9 -0
- package/dist/builtin-extensions/lunr-browser.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-browser.js +169 -0
- package/dist/builtin-extensions/lunr-browser.js.map +1 -0
- package/dist/builtin-extensions/lunr-computer-use.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-computer-use.js +3 -3
- package/dist/builtin-extensions/lunr-computer-use.js.map +1 -1
- package/dist/builtin-extensions/lunr-plan-tools.d.ts +7 -7
- package/dist/builtin-extensions/lunr-plan-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-plan-tools.js +12 -12
- package/dist/builtin-extensions/lunr-plan-tools.js.map +1 -1
- 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 +5 -0
- package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/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/schemas.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.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 +8 -3
- 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 +2 -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 +10 -14
- 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 +167 -53
- 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/async-execution.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +4 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.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-runner.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +3 -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 +11 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +41 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +5 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +3 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +23 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +2 -0
- 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 +20 -15
- 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 +4 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +2 -2
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +2 -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 +48 -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 +23 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +255 -109
- 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/catalog-cache-scope.d.ts.map +1 -1
- package/dist/core/catalog-cache-scope.js +3 -1
- package/dist/core/catalog-cache-scope.js.map +1 -1
- package/dist/core/computer-use/image.d.ts +1 -0
- package/dist/core/computer-use/image.d.ts.map +1 -1
- package/dist/core/computer-use/image.js +8 -0
- package/dist/core/computer-use/image.js.map +1 -1
- package/dist/core/computer-use/schemas.d.ts +1 -0
- package/dist/core/computer-use/schemas.d.ts.map +1 -1
- package/dist/core/computer-use/schemas.js +2 -1
- package/dist/core/computer-use/schemas.js.map +1 -1
- package/dist/core/computer-use/workflow.d.ts.map +1 -1
- package/dist/core/computer-use/workflow.js +89 -23
- package/dist/core/computer-use/workflow.js.map +1 -1
- 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/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +4 -0
- package/dist/core/extensions/loader.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-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +3 -2
- package/dist/core/model-runtime.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 +16 -23
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +71 -142
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts +10 -12
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +20 -19
- 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-bridges.d.ts.map +1 -1
- package/dist/core/runtime-bridges.js +2 -0
- package/dist/core/runtime-bridges.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 +26 -6
- 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 +191 -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 +20 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +67 -1
- 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 +6 -4
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/subagent-permission-inherit.d.ts +6 -10
- package/dist/core/subagent-permission-inherit.d.ts.map +1 -1
- package/dist/core/subagent-permission-inherit.js +14 -14
- package/dist/core/subagent-permission-inherit.js.map +1 -1
- package/dist/core/subagent-wait-interruption.d.ts +11 -0
- package/dist/core/subagent-wait-interruption.d.ts.map +1 -0
- package/dist/core/subagent-wait-interruption.js +19 -0
- package/dist/core/subagent-wait-interruption.js.map +1 -0
- package/dist/core/system-prompt.d.ts +2 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +14 -4
- 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 +14 -5
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +34 -7
- 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 +114 -24
- 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 +41 -11
- package/dist/gateway/adapters/telegram.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts +18 -4
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +305 -73
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/approval.d.ts +3 -6
- package/dist/gateway/approval.d.ts.map +1 -1
- package/dist/gateway/approval.js +62 -24
- 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 +45 -20
- 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 +2 -0
- package/dist/gateway/commands.d.ts.map +1 -1
- package/dist/gateway/commands.js +52 -16
- package/dist/gateway/commands.js.map +1 -1
- package/dist/gateway/config.d.ts +6 -0
- package/dist/gateway/config.d.ts.map +1 -1
- package/dist/gateway/config.js +7 -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/cron.d.ts +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +2 -2
- package/dist/gateway/cron.js.map +1 -1
- 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 +106 -47
- 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 +423 -0
- package/dist/gateway/mobile-commands.js.map +1 -0
- package/dist/gateway/presenter.d.ts +27 -0
- package/dist/gateway/presenter.d.ts.map +1 -0
- package/dist/gateway/presenter.js +308 -0
- package/dist/gateway/presenter.js.map +1 -0
- package/dist/gateway/router.d.ts +6 -5
- package/dist/gateway/router.d.ts.map +1 -1
- package/dist/gateway/router.js +126 -43
- 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 +404 -0
- package/dist/gateway/service.js.map +1 -0
- package/dist/gateway/setup.d.ts +9 -0
- package/dist/gateway/setup.d.ts.map +1 -0
- package/dist/gateway/setup.js +202 -0
- package/dist/gateway/setup.js.map +1 -0
- package/dist/gateway/stream.d.ts +6 -5
- package/dist/gateway/stream.d.ts.map +1 -1
- package/dist/gateway/stream.js +24 -11
- package/dist/gateway/stream.js.map +1 -1
- 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 +3 -3
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +19 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +78 -17
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/copyable-text.d.ts +27 -0
- package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/copyable-text.js +156 -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 +12 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +74 -3
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-tail.d.ts +9 -2
- package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-tail.js +43 -1
- package/dist/modes/interactive/components/thinking-tail.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +5 -3
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +44 -45
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +10 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +342 -133
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +23 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/node-runtime/agent-session-services-MQUPZSIN.js +51 -0
- package/dist/node-runtime/{builtin-extensions-SRCYQPZ6.js → builtin-extensions-4GNDR6U3.js} +7 -6
- package/dist/node-runtime/{chunk-LTXUQJI4.js → chunk-24C5IAJ4.js} +1 -6
- package/dist/node-runtime/chunk-2BLXLDJR.js +144 -0
- package/dist/node-runtime/{chunk-RQ5DNUNG.js → chunk-2CMV4L24.js} +21 -124
- 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-GT5F3OKM.js → chunk-33SIKK3Y.js} +38 -164
- package/dist/node-runtime/{chunk-GZQHMEWL.js → chunk-3DKIWPKN.js} +19 -4
- package/dist/node-runtime/{chunk-3GHXVUAK.js → chunk-3VEY2IYY.js} +1 -1
- package/dist/node-runtime/chunk-4ER2ZV4Z.js +537 -0
- package/dist/node-runtime/chunk-4EULYYR4.js +62 -0
- package/dist/node-runtime/{chunk-LOYUC2ID.js → chunk-4SBQAI4T.js} +27 -27
- package/dist/node-runtime/{chunk-CZUBYPFP.js → chunk-53ARRUHA.js} +674 -257
- package/dist/node-runtime/{chunk-VTPM5V35.js → chunk-5Q4A37RB.js} +10 -4
- package/dist/node-runtime/{chunk-SWSN6HAB.js → chunk-5UZOPGE3.js} +1 -1
- package/dist/node-runtime/{chunk-XSRCAQK2.js → chunk-5Z5PCXGY.js} +263 -222
- package/dist/node-runtime/chunk-7JIYPIQU.js +356 -0
- package/dist/node-runtime/{chunk-D466UAID.js → chunk-AJ6R5VTV.js} +60 -88
- package/dist/node-runtime/chunk-ATIF3RX5.js +352 -0
- package/dist/node-runtime/{chunk-A3KMVBZV.js → chunk-BBUVIEZB.js} +1 -10
- package/dist/node-runtime/chunk-CCCN2UCX.js +14 -0
- package/dist/node-runtime/chunk-CJS4KQFI.js +3412 -0
- package/dist/node-runtime/chunk-DO6PALE2.js +205 -0
- package/dist/node-runtime/{chunk-N3PNL74S.js → chunk-DRJI7ZSC.js} +63 -163
- package/dist/node-runtime/{chunk-VTGEKB7R.js → chunk-E75WFZ33.js} +1 -1
- package/dist/node-runtime/{chunk-MJQDX3BA.js → chunk-EBB4BJW4.js} +3 -3
- package/dist/node-runtime/{chunk-VQ4UBWSA.js → chunk-EOEAQIJV.js} +63 -6
- package/dist/node-runtime/chunk-EOPL2HMM.js +117 -0
- package/dist/node-runtime/chunk-H4K3JDRB.js +47 -0
- package/dist/node-runtime/{chunk-HRS4HMDX.js → chunk-HT2XEJNP.js} +19 -3
- package/dist/node-runtime/chunk-IMLCWLPI.js +9 -0
- package/dist/node-runtime/{chunk-BJ6H7DPI.js → chunk-JJWZB7S3.js} +62 -50
- package/dist/node-runtime/chunk-KFFOQR4G.js +672 -0
- package/dist/node-runtime/chunk-L5LZUGT7.js +40 -0
- package/dist/node-runtime/chunk-LV6CEFW2.js +97 -0
- package/dist/node-runtime/{chunk-VSELYKWU.js → chunk-LWYIVUGV.js} +2 -1
- package/dist/node-runtime/{chunk-BYQ2MOFI.js → chunk-MFV2LOOX.js} +184 -2192
- package/dist/node-runtime/{chunk-5SQDLSZJ.js → chunk-MNRO3UCV.js} +2 -2
- package/dist/node-runtime/{chunk-JHYKXIMM.js → chunk-MPKSOJBT.js} +1 -1
- package/dist/node-runtime/{chunk-C4O2RSQQ.js → chunk-N4TUWAGA.js} +1 -1
- package/dist/node-runtime/{chunk-7NBZ5P7I.js → chunk-NAY6UUQZ.js} +1 -1
- package/dist/node-runtime/chunk-NKH2QBKF.js +773 -0
- package/dist/node-runtime/chunk-O2AT4MEU.js +124 -0
- package/dist/node-runtime/chunk-OAR4TYZE.js +146 -0
- package/dist/node-runtime/{chunk-DDGMHUOW.js → chunk-OGJN3OZV.js} +2 -1
- package/dist/node-runtime/{chunk-MX3GJNXJ.js → chunk-PLGA743X.js} +23 -0
- package/dist/node-runtime/chunk-Q3FEOEDA.js +1364 -0
- package/dist/node-runtime/{chunk-H2BI7G7T.js → chunk-QFADHUQV.js} +2 -1
- package/dist/node-runtime/{chunk-W3SILANP.js → chunk-RBZQU6TJ.js} +12 -9
- package/dist/node-runtime/{chunk-ZVSORYRM.js → chunk-RVOQBXTA.js} +10 -6
- package/dist/node-runtime/{chunk-HXJS2PJM.js → chunk-RW4PYFNE.js} +14 -94
- package/dist/node-runtime/chunk-TP7K7YWS.js +2830 -0
- package/dist/node-runtime/{chunk-ZOIIMEN6.js → chunk-TVLBDVTR.js} +32 -21
- package/dist/node-runtime/chunk-UAEOTO52.js +119 -0
- package/dist/node-runtime/{chunk-MGWCVY6Y.js → chunk-UDKX3PFN.js} +3 -3
- package/dist/node-runtime/{chunk-AY6CAJSL.js → chunk-UJOCPOMX.js} +6 -3
- package/dist/node-runtime/{chunk-WJVFOIB5.js → chunk-UQUCFAJ3.js} +1 -1
- package/dist/node-runtime/chunk-US544NN6.js +13 -0
- package/dist/node-runtime/{chunk-7AFOFSDY.js → chunk-V3HK3FE7.js} +1 -1
- package/dist/node-runtime/{chunk-6UB6NKA3.js → chunk-VIVYOI7C.js} +130 -27
- package/dist/node-runtime/{chunk-MW2XJZIK.js → chunk-XHIRAZ26.js} +1 -1
- package/dist/node-runtime/chunk-YPHAIRZT.js +10 -0
- package/dist/node-runtime/{chunk-3RCWXWAY.js → chunk-YRUY57IN.js} +1 -1
- package/dist/node-runtime/cli-runtime.js +2 -2
- package/dist/node-runtime/command-PYBNGLPP.js +45 -0
- package/dist/node-runtime/{commands-BZGSLIP7.js → commands-EMBQQVVT.js} +13 -13
- package/dist/node-runtime/commands-Y2OUC2T7.js +37 -0
- package/dist/node-runtime/config-7DYMNJUO.js +20 -0
- package/dist/node-runtime/{customize-LF5VST47.js → customize-VFJV3U6A.js} +2 -1
- package/dist/node-runtime/{direct-tool-executor-BSZDHIYR.js → direct-tool-executor-4D7UXYU4.js} +10 -10
- package/dist/node-runtime/{export-html-E4DT6ZJQ.js → export-html-ETFOKW3M.js} +4 -3
- package/dist/node-runtime/{extension-input-RV5N6APL.js → extension-input-7QODTFAS.js} +4 -4
- package/dist/node-runtime/{extension-selector-CPD5LWDD.js → extension-selector-T65JEDJ5.js} +4 -4
- package/dist/node-runtime/{extract-XLQSJN4V.js → extract-EQJE7FZZ.js} +2 -2
- package/dist/node-runtime/gateway-QENRQA5X.js +1476 -0
- 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 +113 -73
- package/dist/node-runtime/{init-DVJUAOUO.js → init-P5AUV77I.js} +5 -5
- package/dist/node-runtime/{install-cli-TH7IJJQQ.js → install-cli-KHAXYBOO.js} +21 -82
- package/dist/node-runtime/interactive-mode-IN77GQGX.js +74 -0
- package/dist/node-runtime/{interactive-view-N6F4KUIT.js → interactive-view-OMWDFGUQ.js} +10 -10
- package/dist/node-runtime/lunr-browser-VVPRWC3F.js +174 -0
- package/dist/node-runtime/{lunr-computer-use-TJNDAMWM.js → lunr-computer-use-IAUNXSXH.js} +11 -8
- package/dist/node-runtime/{lunr-cron-J64I72C6.js → lunr-cron-P6ZJGVEF.js} +21 -7
- package/dist/node-runtime/main.js +47 -34
- package/dist/node-runtime/{mcp-auth-flow-YL6RWPYG.js → mcp-auth-flow-QVLFVLEO.js} +2 -2
- package/dist/node-runtime/{memory-cap-3S4XRLNP.js → memory-cap-EL3KL4JJ.js} +2 -1
- package/dist/node-runtime/mobile-commands-WKFSFACZ.js +33 -0
- package/dist/node-runtime/model-runtime-YXGJS5OJ.js +16 -0
- package/dist/node-runtime/{model-tiers-NJLHUEGK.js → model-tiers-OU3U5CZG.js} +2 -1
- package/dist/node-runtime/{package-manager-cli-VMYX4Y2S.js → package-manager-cli-J337RKTI.js} +25 -17
- package/dist/node-runtime/{pi-intercom-NV2LW6X7.js → pi-intercom-QM53RLTS.js} +6 -1
- package/dist/node-runtime/{pi-mcp-adapter-JLB5YL2F.js → pi-mcp-adapter-3PHF4KZ4.js} +8 -7
- package/dist/node-runtime/{pi-subagents-WEHV3W7H.js → pi-subagents-RCHPB6UK.js} +255 -88
- package/dist/node-runtime/{pi-web-access-FN5YC5T6.js → pi-web-access-PNG35XW7.js} +15 -15
- package/dist/node-runtime/process-registry-PVJ44F7H.js +31 -0
- package/dist/node-runtime/{proxy-modes-OR7ISBXK.js → proxy-modes-5FAPSZEZ.js} +11 -11
- package/dist/node-runtime/rpc-entry.js +47 -34
- package/dist/node-runtime/{rpc-mode-SJNSOA4G.js → rpc-mode-SH7VB4RH.js} +2 -2
- package/dist/node-runtime/runtime-4VA6JKNF.js +373 -0
- package/dist/node-runtime/runtime-bridges-3CQHWVVY.js +21 -0
- package/dist/node-runtime/service-HGGU3STY.js +36 -0
- package/dist/node-runtime/session-handoff-IAFIK7QP.js +33 -0
- package/dist/node-runtime/{session-manager-QEMZBMTM.js → session-manager-TCEFDKBL.js} +2 -1
- package/dist/node-runtime/{session-selector-URVJLOTK.js → session-selector-HG5J4BDZ.js} +5 -4
- package/dist/node-runtime/{settings-manager-3CCU326G.js → settings-manager-HIBIUNBK.js} +12 -5
- package/dist/node-runtime/setup-JBKOLJ6F.js +18 -0
- package/dist/node-runtime/setup-YU5LKRL3.js +215 -0
- package/dist/node-runtime/{subagent-executor-CXKXQDHH.js → subagent-executor-2BH76MMS.js} +64 -23
- package/dist/node-runtime/theme-WTJWZSGD.js +68 -0
- package/dist/node-runtime/trust-manager-6ZQANSBX.js +17 -0
- package/dist/node-runtime/{update-cli-NM7B4CKL.js → update-cli-TVTPVUNM.js} +6 -3
- 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/{workflow-C26QCUTW.js → workflow-TVJNKKQP.js} +80 -39
- package/dist/node-runtime/{youtube-extract-TQYKGFGS.js → youtube-extract-FNPAUNHU.js} +6 -6
- package/dist/startup/interactive-view.d.ts.map +1 -1
- package/dist/startup/interactive-view.js +5 -1
- package/dist/startup/interactive-view.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts +2 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +10 -0
- package/dist/utils/image-resize-core.js.map +1 -1
- package/docs/browser.md +86 -0
- package/docs/computer-use.md +134 -48
- package/docs/extensions.md +2 -0
- package/docs/features.md +108 -27
- package/docs/index.md +1 -1
- package/docs/interactive-startup.md +2 -1
- package/docs/keybindings.md +1 -1
- package/docs/providers.md +6 -2
- package/docs/quickstart.md +2 -2
- package/docs/sessions.md +10 -0
- package/docs/settings.md +3 -1
- package/docs/tui.md +2 -0
- package/docs/usage.md +20 -4
- 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/plan-mode/README.md +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/install-lock/package-lock.json +39 -25
- package/install-lock/package.json +2 -2
- package/npm-shrinkwrap.json +36 -22
- package/package.json +10 -7
- package/scripts/install-browser.mjs +20 -0
- package/dist/node-runtime/agent-session-services-QANFGM2V.js +0 -40
- package/dist/node-runtime/chunk-LISUTZS3.js +0 -19
- package/dist/node-runtime/chunk-VGYZ3APQ.js +0 -59
- package/dist/node-runtime/chunk-XAUQOKYK.js +0 -6011
- package/dist/node-runtime/command-ZURZJDXF.js +0 -13
- package/dist/node-runtime/gateway-FWHRIBK5.js +0 -2139
- package/dist/node-runtime/interactive-mode-BBASNWHN.js +0 -62
- package/dist/node-runtime/runtime-bridges-2VQTLPOZ.js +0 -12
- package/dist/node-runtime/{chunk-U6C7VTR5.js → chunk-7IQGBKBJ.js} +3 -3
- 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
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
createPairingStore
|
|
4
|
+
} from "./chunk-EOPL2HMM.js";
|
|
5
|
+
import {
|
|
6
|
+
atomicJson
|
|
7
|
+
} from "./chunk-ATIF3RX5.js";
|
|
8
|
+
import {
|
|
9
|
+
noOpUIContext
|
|
10
|
+
} from "./chunk-KFFOQR4G.js";
|
|
11
|
+
import {
|
|
12
|
+
NO_HANDLER_REASON,
|
|
13
|
+
registerApprovalHandler,
|
|
14
|
+
setPermissionMode
|
|
15
|
+
} from "./chunk-AJ6R5VTV.js";
|
|
16
|
+
import {
|
|
17
|
+
gatewayConfigPath,
|
|
18
|
+
loadGatewayConfig,
|
|
19
|
+
platformConfigFor,
|
|
20
|
+
saveGatewayConfig
|
|
21
|
+
} from "./chunk-O2AT4MEU.js";
|
|
22
|
+
import {
|
|
23
|
+
getAgentDir
|
|
24
|
+
} from "./chunk-PCIGF2XK.js";
|
|
25
|
+
|
|
26
|
+
// packages/coding-agent/dist/gateway/authz.js
|
|
27
|
+
function envFlagEnabled(name) {
|
|
28
|
+
let raw = process.env[name];
|
|
29
|
+
return raw === void 0 ? !1 : ["1", "true", "yes", "on"].includes(raw.toLowerCase());
|
|
30
|
+
}
|
|
31
|
+
function globalAllowedUsers() {
|
|
32
|
+
let raw = process.env.LUNR_GATEWAY_ALLOWED_USERS;
|
|
33
|
+
return raw ? raw.split(",").map((u) => u.trim()).filter((u) => u.length > 0) : [];
|
|
34
|
+
}
|
|
35
|
+
function isGatewayOwner(source, cfg) {
|
|
36
|
+
return source.chatType !== "dm" || source.platform !== "telegram" && source.platform !== "discord" ? !1 : cfg.owners?.[source.platform].includes(source.userId) ?? !1;
|
|
37
|
+
}
|
|
38
|
+
function requireGatewayOwner(source, cfg = loadGatewayConfig()) {
|
|
39
|
+
if (!isGatewayOwner(source, cfg))
|
|
40
|
+
throw new Error("This command is available only to the configured owner in a private chat. Use lunr gateway setup to configure owner access.");
|
|
41
|
+
}
|
|
42
|
+
function isAuthorized(source, cfg, pairing) {
|
|
43
|
+
if (isGatewayOwner(source, cfg) || envFlagEnabled("LUNR_GATEWAY_ALLOW_ALL_USERS"))
|
|
44
|
+
return !0;
|
|
45
|
+
let platformCfg = platformConfigFor(cfg, source.platform);
|
|
46
|
+
return !!(platformCfg?.allowedChats.includes(source.chatId) || source.roleAuthorized === !0 || source.userId && pairing.isPaired(source.platform, source.userId) || source.userId && (platformCfg?.allowedUsers.includes(source.userId) || globalAllowedUsers().includes(source.userId)));
|
|
47
|
+
}
|
|
48
|
+
function addAllowedUser(platform, userId) {
|
|
49
|
+
let cfg = loadGatewayConfig(), platformCfg = platformConfigFor(cfg, platform);
|
|
50
|
+
if (!platformCfg)
|
|
51
|
+
throw new Error(`Unknown platform "${platform}"`);
|
|
52
|
+
platformCfg.allowedUsers.includes(userId) || (platformCfg.allowedUsers.push(userId), saveGatewayConfig(cfg));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// packages/coding-agent/dist/gateway/conversations.js
|
|
56
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
57
|
+
import { join } from "node:path";
|
|
58
|
+
var path = () => join(getAgentDir(), "gateway-conversations.json");
|
|
59
|
+
function conversationBindings() {
|
|
60
|
+
if (!existsSync(path()))
|
|
61
|
+
return {};
|
|
62
|
+
let raw = JSON.parse(readFileSync(path(), "utf8"));
|
|
63
|
+
if (!raw || typeof raw != "object" || Array.isArray(raw))
|
|
64
|
+
throw new Error("Invalid gateway conversation store. Restore it before continuing.");
|
|
65
|
+
return raw;
|
|
66
|
+
}
|
|
67
|
+
function conversationBinding(key) {
|
|
68
|
+
return conversationBindings()[key];
|
|
69
|
+
}
|
|
70
|
+
function bindConversation(key, source, options = {}) {
|
|
71
|
+
let all = conversationBindings(), old = all[key];
|
|
72
|
+
all[key] = {
|
|
73
|
+
...old,
|
|
74
|
+
...options,
|
|
75
|
+
source,
|
|
76
|
+
recentProjects: options.cwd ? [.../* @__PURE__ */ new Set([options.cwd, ...old?.recentProjects ?? []])].slice(0, 12) : old?.recentProjects ?? []
|
|
77
|
+
}, atomicJson(path(), all);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// packages/coding-agent/dist/gateway/store.js
|
|
81
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, renameSync, writeFileSync } from "node:fs";
|
|
82
|
+
import { dirname, join as join2 } from "node:path";
|
|
83
|
+
var storePathOverride;
|
|
84
|
+
function storePath() {
|
|
85
|
+
return storePathOverride ?? join2(getAgentDir(), "gateway-sessions.json");
|
|
86
|
+
}
|
|
87
|
+
function readStore() {
|
|
88
|
+
let path3 = storePath();
|
|
89
|
+
if (!existsSync2(path3))
|
|
90
|
+
return {};
|
|
91
|
+
try {
|
|
92
|
+
let parsed = JSON.parse(readFileSync2(path3, "utf-8"));
|
|
93
|
+
if (parsed == null || typeof parsed != "object" || Array.isArray(parsed))
|
|
94
|
+
return {};
|
|
95
|
+
let out = {};
|
|
96
|
+
for (let [key, value] of Object.entries(parsed)) {
|
|
97
|
+
if (value == null || typeof value != "object")
|
|
98
|
+
continue;
|
|
99
|
+
let v = value;
|
|
100
|
+
typeof v.sessionId != "string" || typeof v.sessionFile != "string" || (out[key] = {
|
|
101
|
+
sessionId: v.sessionId,
|
|
102
|
+
sessionFile: v.sessionFile,
|
|
103
|
+
createdAt: typeof v.createdAt == "string" ? v.createdAt : (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
104
|
+
lastActiveAt: typeof v.lastActiveAt == "string" ? v.lastActiveAt : (/* @__PURE__ */ new Date(0)).toISOString()
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
} catch {
|
|
109
|
+
return {};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function writeStore(data) {
|
|
113
|
+
let path3 = storePath(), dir = dirname(path3);
|
|
114
|
+
existsSync2(dir) || mkdirSync(dir, { recursive: !0 });
|
|
115
|
+
let tmp = `${path3}.tmp-${process.pid}`;
|
|
116
|
+
writeFileSync(tmp, `${JSON.stringify(data, null, 2)}
|
|
117
|
+
`, "utf-8"), renameSync(tmp, path3);
|
|
118
|
+
}
|
|
119
|
+
function getSession(key) {
|
|
120
|
+
return readStore()[key];
|
|
121
|
+
}
|
|
122
|
+
function putSession(key, entry) {
|
|
123
|
+
let data = readStore(), existing = data[key], stored = {
|
|
124
|
+
sessionId: entry.sessionId,
|
|
125
|
+
sessionFile: entry.sessionFile,
|
|
126
|
+
createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
127
|
+
lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
128
|
+
};
|
|
129
|
+
return data[key] = stored, writeStore(data), stored;
|
|
130
|
+
}
|
|
131
|
+
function touchSession(key) {
|
|
132
|
+
let data = readStore(), existing = data[key];
|
|
133
|
+
existing && (existing.lastActiveAt = (/* @__PURE__ */ new Date()).toISOString(), writeStore(data));
|
|
134
|
+
}
|
|
135
|
+
function removeSession(key) {
|
|
136
|
+
let data = readStore();
|
|
137
|
+
return key in data ? (delete data[key], writeStore(data), !0) : !1;
|
|
138
|
+
}
|
|
139
|
+
function listSessions() {
|
|
140
|
+
return readStore();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// packages/coding-agent/dist/gateway/approval.js
|
|
144
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
145
|
+
import { randomBytes } from "node:crypto";
|
|
146
|
+
var CALLBACK_PREFIX = "ap:", ID_LENGTH = 8, CODE_ALPHABET = "ABCDEFGHJKMNPQRSTUVWXYZ23456789", DEFAULT_TIMEOUT_MS = 300 * 1e3, approvalContext = new AsyncLocalStorage(), pending = /* @__PURE__ */ new Map();
|
|
147
|
+
function generateId() {
|
|
148
|
+
let id = "", bytes = randomBytes(ID_LENGTH);
|
|
149
|
+
for (let i = 0; i < ID_LENGTH; i++)
|
|
150
|
+
id += CODE_ALPHABET[bytes[i] % CODE_ALPHABET.length];
|
|
151
|
+
return id;
|
|
152
|
+
}
|
|
153
|
+
function makeCallbackData(id, action) {
|
|
154
|
+
return `${CALLBACK_PREFIX}${id}:${action}`;
|
|
155
|
+
}
|
|
156
|
+
function parseCallbackData(data) {
|
|
157
|
+
if (!data.startsWith(CALLBACK_PREFIX))
|
|
158
|
+
return null;
|
|
159
|
+
let rest = data.slice(CALLBACK_PREFIX.length), colon = rest.indexOf(":");
|
|
160
|
+
if (colon === -1)
|
|
161
|
+
return null;
|
|
162
|
+
let id = rest.slice(0, colon), action = rest.slice(colon + 1);
|
|
163
|
+
return action === "once" || action === "session" || action === "reject" || action === "cancel" ? { id, action } : null;
|
|
164
|
+
}
|
|
165
|
+
function runWithApprovalContext(ctx, fn) {
|
|
166
|
+
return approvalContext.run(ctx, fn);
|
|
167
|
+
}
|
|
168
|
+
async function createApprovalPrompt(adapter, source, req, timeoutMs = DEFAULT_TIMEOUT_MS, key) {
|
|
169
|
+
let id = generateId(), title = req.kind === "large-subagent-launch" ? `Approve large subagent launch?
|
|
170
|
+
${req.detail}` : `Approve ${req.toolName}?
|
|
171
|
+
${req.detail}`, rows = [
|
|
172
|
+
[
|
|
173
|
+
{ label: "\u2713 Approve once", data: makeCallbackData(id, "once") },
|
|
174
|
+
{ label: "\u2713 Approve session", data: makeCallbackData(id, "session") }
|
|
175
|
+
],
|
|
176
|
+
[{ label: "\u2717 Reject", data: makeCallbackData(id, "reject") }]
|
|
177
|
+
];
|
|
178
|
+
return new Promise((resolve, reject) => {
|
|
179
|
+
let messageId, timeout = setTimeout(() => {
|
|
180
|
+
pending.delete(id), reject(new Error("Approval request timed out")), messageId && adapter.editMessage(source.chatId, messageId, "\u23F1 Approval expired.", []).catch(() => {
|
|
181
|
+
});
|
|
182
|
+
}, timeoutMs), entry = {
|
|
183
|
+
key,
|
|
184
|
+
source,
|
|
185
|
+
plan: req.kind === "plan",
|
|
186
|
+
resolve,
|
|
187
|
+
reject,
|
|
188
|
+
timeout,
|
|
189
|
+
adapter,
|
|
190
|
+
chatId: source.chatId,
|
|
191
|
+
threadId: source.threadId,
|
|
192
|
+
userId: source.userId
|
|
193
|
+
};
|
|
194
|
+
pending.set(id, entry), (async () => {
|
|
195
|
+
try {
|
|
196
|
+
let result = await adapter.sendButtons(source.chatId, title, rows, { threadId: source.threadId });
|
|
197
|
+
if (!result.success || !result.messageId)
|
|
198
|
+
throw new Error(result.error ?? "Failed to send approval prompt");
|
|
199
|
+
if (messageId = result.messageId, pending.get(id) !== entry) {
|
|
200
|
+
await adapter.editMessage(source.chatId, messageId, "Approval cancelled or expired.", []).catch(() => {
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
entry.messageId = messageId;
|
|
205
|
+
} catch (err) {
|
|
206
|
+
clearTimeout(timeout), pending.delete(id), reject(err);
|
|
207
|
+
}
|
|
208
|
+
})();
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
async function createGatewayApprovalRequest(req) {
|
|
212
|
+
let ctx = approvalContext.getStore();
|
|
213
|
+
if (!ctx)
|
|
214
|
+
throw new Error(NO_HANDLER_REASON);
|
|
215
|
+
return createApprovalPrompt(ctx.adapter, ctx.source, req, ctx.timeoutMs, ctx.key);
|
|
216
|
+
}
|
|
217
|
+
function registerGatewayApprovalHandler() {
|
|
218
|
+
registerApprovalHandler(createGatewayApprovalRequest);
|
|
219
|
+
}
|
|
220
|
+
async function handleApprovalCallback(event, adapter) {
|
|
221
|
+
let parsed = parseCallbackData(event.data);
|
|
222
|
+
if (!parsed)
|
|
223
|
+
return !1;
|
|
224
|
+
let entry = pending.get(parsed.id);
|
|
225
|
+
if (!entry)
|
|
226
|
+
return await adapter?.answerCallback(event.id, "Approval expired.").catch(() => {
|
|
227
|
+
}), !0;
|
|
228
|
+
if (event.userId !== entry.userId || event.chatId !== entry.chatId || event.threadId !== entry.threadId || adapter && adapter.platform !== entry.adapter.platform)
|
|
229
|
+
return await entry.adapter.answerCallback(event.id, "\u26D4 Not your approval.").catch(() => {
|
|
230
|
+
}), !0;
|
|
231
|
+
clearTimeout(entry.timeout), pending.delete(parsed.id);
|
|
232
|
+
let response = parsed.action === "reject" || parsed.action === "cancel" ? "reject" : parsed.action, binding = entry.key ? conversationBinding(entry.key) : void 0;
|
|
233
|
+
if (binding?.owner && (!isGatewayOwner(entry.source, loadGatewayConfig()) || binding.owner !== event.userId))
|
|
234
|
+
return entry.resolve("reject"), await entry.adapter.answerCallback(event.id, "Owner access was removed.").catch(() => {
|
|
235
|
+
}), !0;
|
|
236
|
+
if (binding && !isAuthorized(entry.source, loadGatewayConfig(), createPairingStore()))
|
|
237
|
+
return entry.resolve("reject"), !0;
|
|
238
|
+
if (entry.plan && response !== "reject" && entry.key) {
|
|
239
|
+
let sessionId = getSession(entry.key)?.sessionId;
|
|
240
|
+
sessionId && setPermissionMode("yolo", sessionId);
|
|
241
|
+
}
|
|
242
|
+
entry.resolve(response);
|
|
243
|
+
let label = parsed.action === "reject" || parsed.action === "cancel" ? "Rejected." : `Approved (${parsed.action}).`;
|
|
244
|
+
return await entry.adapter.editMessage(entry.chatId, entry.messageId ?? "", label, []).catch(() => {
|
|
245
|
+
}), await entry.adapter.answerCallback(event.id).catch(() => {
|
|
246
|
+
}), !0;
|
|
247
|
+
}
|
|
248
|
+
function cancelGatewayApprovals(key) {
|
|
249
|
+
for (let [id, entry] of pending)
|
|
250
|
+
entry.key === key && (clearTimeout(entry.timeout), pending.delete(id), entry.resolve("reject"), entry.messageId && entry.adapter.editMessage(entry.chatId, entry.messageId, "Approval cancelled.", []).catch(() => {
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// packages/coding-agent/dist/gateway/buttons.js
|
|
255
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
256
|
+
var PICKER_TTL_MS = 900 * 1e3, SWEEP_INTERVAL_MS = 60 * 1e3, DEFAULT_PER_PAGE = 8, BUTTONS_PER_ROW = 2, CODE_ALPHABET2 = "ABCDEFGHJKMNPQRSTUVWXYZ23456789", CODE_LENGTH = 8, CALLBACK_PREFIX2 = "cp:", registry = /* @__PURE__ */ new Map(), sweeper;
|
|
257
|
+
function generatePickerId() {
|
|
258
|
+
let id = "", bytes = randomBytes2(CODE_LENGTH);
|
|
259
|
+
for (let i = 0; i < CODE_LENGTH; i++)
|
|
260
|
+
id += CODE_ALPHABET2[bytes[i] % CODE_ALPHABET2.length];
|
|
261
|
+
return id;
|
|
262
|
+
}
|
|
263
|
+
function makeCallbackData2(id, action, payload) {
|
|
264
|
+
return action === "noop" ? `${CALLBACK_PREFIX2}${id}:` : action === "cancel" ? `${CALLBACK_PREFIX2}${id}:x` : action === "page" ? `${CALLBACK_PREFIX2}${id}:p${payload ?? "0"}` : `${CALLBACK_PREFIX2}${id}:${payload ?? ""}`;
|
|
265
|
+
}
|
|
266
|
+
function parseCallbackData2(data) {
|
|
267
|
+
if (!data.startsWith(CALLBACK_PREFIX2))
|
|
268
|
+
return null;
|
|
269
|
+
let rest = data.slice(CALLBACK_PREFIX2.length), colon = rest.indexOf(":");
|
|
270
|
+
if (colon === -1)
|
|
271
|
+
return null;
|
|
272
|
+
let id = rest.slice(0, colon), tail = rest.slice(colon + 1);
|
|
273
|
+
return tail === "" ? { id, action: "noop" } : tail === "x" ? { id, action: "cancel" } : tail.startsWith("p") ? { id, action: "page", payload: tail.slice(1) } : { id, action: "select", payload: tail };
|
|
274
|
+
}
|
|
275
|
+
function isSameChat(a, b) {
|
|
276
|
+
return a.platform === b.platform && a.chatId === b.chatId && a.threadId === b.threadId;
|
|
277
|
+
}
|
|
278
|
+
function sourceForAuth(picker, cb) {
|
|
279
|
+
return {
|
|
280
|
+
platform: picker.source.platform,
|
|
281
|
+
chatId: cb.chatId,
|
|
282
|
+
chatType: picker.source.chatType,
|
|
283
|
+
userId: cb.userId,
|
|
284
|
+
userName: cb.userName,
|
|
285
|
+
threadId: cb.threadId,
|
|
286
|
+
// Do NOT inherit the original invoker's role authorization.
|
|
287
|
+
roleAuthorized: void 0
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function renderPage(picker) {
|
|
291
|
+
let { id, title, breadcrumbs, items, page, perPage } = picker, totalPages = Math.max(1, Math.ceil(items.length / perPage)), clampedPage = Math.max(0, Math.min(page, totalPages - 1)), start = clampedPage * perPage, pageItems = items.slice(start, start + perPage), rows = [];
|
|
292
|
+
for (let i = 0; i < pageItems.length; i += BUTTONS_PER_ROW) {
|
|
293
|
+
let row = [];
|
|
294
|
+
for (let j = 0; j < BUTTONS_PER_ROW && i + j < pageItems.length; j++) {
|
|
295
|
+
let index = start + i + j;
|
|
296
|
+
row.push({ label: pageItems[i + j].label, data: makeCallbackData2(id, "select", String(index)) });
|
|
297
|
+
}
|
|
298
|
+
rows.push(row);
|
|
299
|
+
}
|
|
300
|
+
if (totalPages > 1) {
|
|
301
|
+
let nav = [];
|
|
302
|
+
clampedPage > 0 && nav.push({ label: "\u25C0 Prev", data: makeCallbackData2(id, "page", String(clampedPage - 1)) }), nav.push({ label: `${clampedPage + 1}/${totalPages}`, data: makeCallbackData2(id, "noop") }), clampedPage < totalPages - 1 && nav.push({ label: "Next \u25B6", data: makeCallbackData2(id, "page", String(clampedPage + 1)) }), rows.push(nav);
|
|
303
|
+
}
|
|
304
|
+
rows.push([{ label: "\u2717 Cancel", data: makeCallbackData2(id, "cancel") }]);
|
|
305
|
+
let header = breadcrumbs ? `${title} \xB7 ${breadcrumbs}` : title;
|
|
306
|
+
return { text: items.length === 0 ? `${header}
|
|
307
|
+
|
|
308
|
+
No options available.` : `${header} (${clampedPage + 1}/${totalPages}):`, buttons: rows };
|
|
309
|
+
}
|
|
310
|
+
async function createPicker(adapter, source, spec, opts) {
|
|
311
|
+
let id = generatePickerId(), pending2 = {
|
|
312
|
+
...spec,
|
|
313
|
+
id,
|
|
314
|
+
chatId: source.chatId,
|
|
315
|
+
source,
|
|
316
|
+
adapter,
|
|
317
|
+
messageId: "",
|
|
318
|
+
page: 0,
|
|
319
|
+
perPage: spec.perPage ?? DEFAULT_PER_PAGE,
|
|
320
|
+
createdAt: Date.now()
|
|
321
|
+
}, { text, buttons } = renderPage(pending2), result = await adapter.sendButtons(source.chatId, text, buttons, opts);
|
|
322
|
+
return result.success && result.messageId && (pending2.messageId = result.messageId, registry.set(id, pending2)), result;
|
|
323
|
+
}
|
|
324
|
+
async function answerExpired(adapter, cb) {
|
|
325
|
+
await adapter.answerCallback(cb.id, "Picker expired \u2014 run the command again.").catch(() => {
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
async function answerUnauthorized(adapter, cb) {
|
|
329
|
+
await adapter.answerCallback(cb.id, "\u26D4 Not authorized.").catch(() => {
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
async function answerNotYourPicker(adapter, cb) {
|
|
333
|
+
await adapter.answerCallback(cb.id, "\u26D4 Not your picker.").catch(() => {
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
async function handleCallback(cb, deps) {
|
|
337
|
+
let { adapter, cfg, pairing } = deps, parsed = parseCallbackData2(cb.data);
|
|
338
|
+
if (!parsed)
|
|
339
|
+
return;
|
|
340
|
+
let picker = registry.get(parsed.id);
|
|
341
|
+
if (!picker) {
|
|
342
|
+
await answerExpired(adapter, cb);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (!picker.completed && picker.validate && !picker.validate()) {
|
|
346
|
+
registry.delete(parsed.id), picker.onCancel?.(), await answerExpired(adapter, cb);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (Date.now() > picker.createdAt + PICKER_TTL_MS) {
|
|
350
|
+
picker.completed || picker.onCancel?.(), registry.delete(parsed.id);
|
|
351
|
+
try {
|
|
352
|
+
await picker.adapter.editMessage(picker.chatId, picker.messageId, "\u23F1 Expired \u2014 run the command again.", []);
|
|
353
|
+
} catch {
|
|
354
|
+
}
|
|
355
|
+
await answerExpired(adapter, cb);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (!isSameChat(picker.source, sourceForAuth(picker, cb))) {
|
|
359
|
+
await answerExpired(adapter, cb);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (cb.userId !== picker.invokerId) {
|
|
363
|
+
await answerNotYourPicker(adapter, cb);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
if (!isAuthorized(sourceForAuth(picker, cb), cfg, pairing)) {
|
|
367
|
+
await answerUnauthorized(adapter, cb);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (picker.completed !== void 0) {
|
|
371
|
+
await adapter.answerCallback(cb.id, "Already completed.").catch(() => {
|
|
372
|
+
});
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (parsed.action === "cancel") {
|
|
376
|
+
registry.delete(parsed.id), picker.onCancel?.();
|
|
377
|
+
try {
|
|
378
|
+
await picker.adapter.editMessage(picker.chatId, picker.messageId, "Cancelled.", []);
|
|
379
|
+
} catch {
|
|
380
|
+
}
|
|
381
|
+
await adapter.answerCallback(cb.id).catch(() => {
|
|
382
|
+
});
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
if (parsed.action === "noop") {
|
|
386
|
+
await adapter.answerCallback(cb.id).catch(() => {
|
|
387
|
+
});
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
if (parsed.action === "page") {
|
|
391
|
+
let page = Number.parseInt(parsed.payload ?? "0", 10), totalPages = Math.max(1, Math.ceil(picker.items.length / picker.perPage));
|
|
392
|
+
picker.page = Math.max(0, Math.min(page, totalPages - 1));
|
|
393
|
+
let { text, buttons } = renderPage(picker);
|
|
394
|
+
try {
|
|
395
|
+
await picker.adapter.editMessage(picker.chatId, picker.messageId, text, buttons);
|
|
396
|
+
} catch {
|
|
397
|
+
}
|
|
398
|
+
await adapter.answerCallback(cb.id).catch(() => {
|
|
399
|
+
});
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
let index = Number.parseInt(parsed.payload ?? "", 10), item = picker.items[index];
|
|
403
|
+
if (!item) {
|
|
404
|
+
await adapter.answerCallback(cb.id, "Invalid selection.").catch(() => {
|
|
405
|
+
});
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (picker.resolving) {
|
|
409
|
+
await adapter.answerCallback(cb.id, "Selection is still running.").catch(() => {
|
|
410
|
+
});
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
picker.resolving = !0, await adapter.answerCallback(cb.id).catch(() => {
|
|
414
|
+
});
|
|
415
|
+
try {
|
|
416
|
+
let result = await picker.resolve(item);
|
|
417
|
+
if (!result.done) {
|
|
418
|
+
picker.items = result.items, picker.title = result.title, picker.breadcrumbs = result.breadcrumbs, picker.page = 0;
|
|
419
|
+
let { text, buttons } = renderPage(picker);
|
|
420
|
+
try {
|
|
421
|
+
await picker.adapter.editMessage(picker.chatId, picker.messageId, text, buttons);
|
|
422
|
+
} catch {
|
|
423
|
+
}
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
picker.completed = result.text, await confirmPicker(picker, result.text);
|
|
427
|
+
} catch (err) {
|
|
428
|
+
let message = err instanceof Error ? err.message : String(err);
|
|
429
|
+
picker.completed = `\u26A0 ${message}`, await confirmPicker(picker, picker.completed);
|
|
430
|
+
} finally {
|
|
431
|
+
picker.resolving = !1;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
async function confirmPicker(picker, text) {
|
|
435
|
+
if ((await picker.adapter.editMessage(picker.chatId, picker.messageId, text, []).catch(() => ({ success: !1 }))).success)
|
|
436
|
+
return;
|
|
437
|
+
(await picker.adapter.send(picker.chatId, text, { threadId: picker.source.threadId }).catch(() => ({ success: !1 }))).success || console.error(`[gateway] picker confirmation failed on ${picker.adapter.platform}`);
|
|
438
|
+
}
|
|
439
|
+
function startButtonSweeper() {
|
|
440
|
+
sweeper || (sweeper = setInterval(() => {
|
|
441
|
+
let cutoff = Date.now() - PICKER_TTL_MS;
|
|
442
|
+
for (let [id, entry] of registry)
|
|
443
|
+
entry.createdAt > cutoff || (registry.delete(id), !entry.completed && (entry.onCancel?.(), entry.adapter.editMessage(entry.chatId, entry.messageId, "\u23F1 Expired \u2014 run the command again.", []).catch(() => {
|
|
444
|
+
})));
|
|
445
|
+
}, SWEEP_INTERVAL_MS), sweeper.unref?.());
|
|
446
|
+
}
|
|
447
|
+
function stopButtonSweeper() {
|
|
448
|
+
sweeper && (clearInterval(sweeper), sweeper = void 0);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// packages/coding-agent/dist/gateway/presenter.js
|
|
452
|
+
import { randomUUID } from "node:crypto";
|
|
453
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
454
|
+
import { join as join3 } from "node:path";
|
|
455
|
+
|
|
456
|
+
// packages/coding-agent/dist/gateway/text.js
|
|
457
|
+
function utf16Len(s) {
|
|
458
|
+
return s.length;
|
|
459
|
+
}
|
|
460
|
+
var graphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
461
|
+
function surrogateSafeCut(s, cut) {
|
|
462
|
+
if (cut > 0) {
|
|
463
|
+
let code = s.charCodeAt(cut - 1);
|
|
464
|
+
if (code >= 55296 && code <= 56319)
|
|
465
|
+
return cut - 1;
|
|
466
|
+
}
|
|
467
|
+
return cut;
|
|
468
|
+
}
|
|
469
|
+
function graphemeSafeCut(s, maxIndex) {
|
|
470
|
+
if (maxIndex <= 0)
|
|
471
|
+
return 0;
|
|
472
|
+
let end = 0;
|
|
473
|
+
for (let segment of graphemeSegmenter.segment(s)) {
|
|
474
|
+
let nextEnd = segment.index + segment.segment.length;
|
|
475
|
+
if (nextEnd > maxIndex)
|
|
476
|
+
break;
|
|
477
|
+
end = nextEnd;
|
|
478
|
+
}
|
|
479
|
+
return surrogateSafeCut(s, end);
|
|
480
|
+
}
|
|
481
|
+
function findSplitPoint(window, limit) {
|
|
482
|
+
let blank = window.lastIndexOf(`
|
|
483
|
+
|
|
484
|
+
`);
|
|
485
|
+
if (blank > 0)
|
|
486
|
+
return blank + 1;
|
|
487
|
+
let newline = window.lastIndexOf(`
|
|
488
|
+
`);
|
|
489
|
+
if (newline > 0)
|
|
490
|
+
return newline + 1;
|
|
491
|
+
let space = window.lastIndexOf(" ");
|
|
492
|
+
return space > 0 ? space + 1 : graphemeSafeCut(window, limit);
|
|
493
|
+
}
|
|
494
|
+
var FENCE_RE = /^\s*```/;
|
|
495
|
+
function openFenceAtEnd(chunk) {
|
|
496
|
+
let opener;
|
|
497
|
+
for (let line of chunk.split(`
|
|
498
|
+
`))
|
|
499
|
+
FENCE_RE.test(line) && (opener = opener === void 0 ? line.trim() : void 0);
|
|
500
|
+
return opener;
|
|
501
|
+
}
|
|
502
|
+
var FENCE_CLOSE = "\n```";
|
|
503
|
+
function splitRaw(text, limit) {
|
|
504
|
+
let chunks = [], rest = text;
|
|
505
|
+
for (; utf16Len(rest) > limit; ) {
|
|
506
|
+
let cut = findSplitPoint(rest.slice(0, limit), limit), chunk = rest.slice(0, cut).replace(/\s+$/, ""), opener = openFenceAtEnd(chunk);
|
|
507
|
+
for (; opener !== void 0 && chunk.length + FENCE_CLOSE.length > limit; )
|
|
508
|
+
cut = findSplitPoint(rest.slice(0, limit - FENCE_CLOSE.length), limit - FENCE_CLOSE.length), chunk = rest.slice(0, cut).replace(/\s+$/, ""), opener = openFenceAtEnd(chunk);
|
|
509
|
+
opener !== void 0 && chunk === opener && (cut = graphemeSafeCut(rest, Math.max(1, limit - FENCE_CLOSE.length)), chunk = rest.slice(0, cut), opener = openFenceAtEnd(chunk), opener !== void 0 && chunk === opener && (cut = graphemeSafeCut(rest, limit), chunk = rest.slice(0, cut), opener = void 0)), rest = rest.slice(cut).replace(/^\n+/, ""), opener !== void 0 && (chunk += FENCE_CLOSE, rest = `${opener}
|
|
510
|
+
${rest}`), chunk.length > 0 && chunks.push(chunk);
|
|
511
|
+
}
|
|
512
|
+
return rest.length > 0 && chunks.push(rest), chunks;
|
|
513
|
+
}
|
|
514
|
+
function indicatorReserve(m) {
|
|
515
|
+
return 4 + 2 * String(m).length;
|
|
516
|
+
}
|
|
517
|
+
function splitMessage(text, max) {
|
|
518
|
+
if (max < 1)
|
|
519
|
+
throw new RangeError("max must be >= 1");
|
|
520
|
+
if (utf16Len(text) <= max)
|
|
521
|
+
return [text];
|
|
522
|
+
let chunks = splitRaw(text, max);
|
|
523
|
+
if (chunks.length > 1 && max - indicatorReserve(chunks.length) >= 1) {
|
|
524
|
+
let reserve = indicatorReserve(chunks.length), adjusted = splitRaw(text, max - reserve);
|
|
525
|
+
chunks = indicatorReserve(adjusted.length) === reserve ? adjusted : splitRaw(text, max - indicatorReserve(adjusted.length));
|
|
526
|
+
}
|
|
527
|
+
return chunks.length <= 1 ? chunks : chunks.map((chunk, i) => `${chunk} (${i + 1}/${chunks.length})`);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// packages/coding-agent/dist/gateway/presenter.js
|
|
531
|
+
var epochs = /* @__PURE__ */ new Map(), inputs = /* @__PURE__ */ new Map(), dialogs = /* @__PURE__ */ new Map(), adapters = /* @__PURE__ */ new Map(), deliveryConfigs = /* @__PURE__ */ new Map(), roleGrants = /* @__PURE__ */ new Map(), timer, activeDeliveries = /* @__PURE__ */ new Map(), MAX_ATTEMPTS = 5, path2 = () => join3(getAgentDir(), "gateway-outbox.json"), outbox = [];
|
|
532
|
+
function sourceWithCurrentRole(key, source) {
|
|
533
|
+
let grant = roleGrants.get(key);
|
|
534
|
+
return {
|
|
535
|
+
...source,
|
|
536
|
+
roleAuthorized: grant?.userId === source.userId && grant.chatId === source.chatId && grant.threadId === source.threadId
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function rememberGatewayRole(key, source) {
|
|
540
|
+
source.roleAuthorized === !0 ? roleGrants.set(key, { userId: source.userId, chatId: source.chatId, threadId: source.threadId }) : roleGrants.delete(key);
|
|
541
|
+
}
|
|
542
|
+
function canDeliver(key) {
|
|
543
|
+
let binding = conversationBinding(key);
|
|
544
|
+
if (!binding)
|
|
545
|
+
return !1;
|
|
546
|
+
let cfg = loadGatewayConfig();
|
|
547
|
+
return binding.owner && (binding.owner !== binding.source.userId || !isGatewayOwner(binding.source, cfg)) ? !1 : isAuthorized(sourceWithCurrentRole(key, binding.source), cfg, createPairingStore());
|
|
548
|
+
}
|
|
549
|
+
function gatewayDestination(key) {
|
|
550
|
+
let binding = conversationBinding(key), adapter = binding && adapters.get(binding.source.platform);
|
|
551
|
+
if (!binding || !adapter || !canDeliver(key))
|
|
552
|
+
throw new Error("This chat is no longer authorized or its platform is disconnected.");
|
|
553
|
+
return { adapter, source: binding.source };
|
|
554
|
+
}
|
|
555
|
+
function withGatewayPresentation(key, run) {
|
|
556
|
+
let { adapter, source } = gatewayDestination(key);
|
|
557
|
+
return runWithApprovalContext({ adapter, source, key }, run);
|
|
558
|
+
}
|
|
559
|
+
function startGatewayPresenter(connected) {
|
|
560
|
+
if (adapters = connected, existsSync3(path2()))
|
|
561
|
+
try {
|
|
562
|
+
let raw = JSON.parse(readFileSync3(path2(), "utf8"));
|
|
563
|
+
if (!Array.isArray(raw) || !raw.every((item) => item && typeof item.id == "string" && typeof item.key == "string" && typeof item.text == "string"))
|
|
564
|
+
throw new Error("Invalid outbox");
|
|
565
|
+
outbox = raw;
|
|
566
|
+
} catch {
|
|
567
|
+
throw new Error("Gateway outbox is invalid. Restore it before starting.");
|
|
568
|
+
}
|
|
569
|
+
else
|
|
570
|
+
outbox = [];
|
|
571
|
+
for (let item of outbox)
|
|
572
|
+
item.kind === "notice" && epochs.set(item.key, Math.max(epochs.get(item.key) ?? 0, item.epoch ?? 0));
|
|
573
|
+
timer && clearInterval(timer), timer = setInterval(() => {
|
|
574
|
+
flushOutbox().catch((error) => console.error("[gateway] outbox flush failed:", error));
|
|
575
|
+
}, 3e3), timer.unref(), flushOutbox().catch((error) => console.error("[gateway] outbox flush failed:", error));
|
|
576
|
+
}
|
|
577
|
+
function stopGatewayPresenter() {
|
|
578
|
+
timer && clearInterval(timer), timer = void 0;
|
|
579
|
+
for (let key of dialogs.keys())
|
|
580
|
+
invalidateGatewayDialogs(key);
|
|
581
|
+
adapters = /* @__PURE__ */ new Map(), deliveryConfigs.clear(), roleGrants.clear();
|
|
582
|
+
}
|
|
583
|
+
function gatewayEpoch(key) {
|
|
584
|
+
return epochs.get(key) ?? 0;
|
|
585
|
+
}
|
|
586
|
+
async function sendGatewayNotice(key, text, kind = "notice", epoch = gatewayEpoch(key)) {
|
|
587
|
+
let clean = text.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
588
|
+
if (!clean || !canDeliver(key))
|
|
589
|
+
return;
|
|
590
|
+
let { adapter, source } = gatewayDestination(key);
|
|
591
|
+
await queueGatewayText(key, source, adapter, clean, { kind, epoch });
|
|
592
|
+
}
|
|
593
|
+
async function queueGatewayText(key, source, adapter, text, options) {
|
|
594
|
+
if (!text || options.kind === "notice" && options.epoch !== void 0 && options.epoch !== gatewayEpoch(key))
|
|
595
|
+
return;
|
|
596
|
+
adapters.set(source.platform, adapter), options.cfg && deliveryConfigs.set(key, options.cfg);
|
|
597
|
+
let chunks = options.chunks ?? splitMessage(text, adapter.maxMessageLength), batchId = randomUUID();
|
|
598
|
+
for (let [index, chunk] of chunks.entries())
|
|
599
|
+
outbox.push({
|
|
600
|
+
id: randomUUID(),
|
|
601
|
+
batchId,
|
|
602
|
+
key,
|
|
603
|
+
source: { ...source, roleAuthorized: void 0 },
|
|
604
|
+
epoch: options.epoch ?? gatewayEpoch(key),
|
|
605
|
+
text: chunk,
|
|
606
|
+
kind: options.kind,
|
|
607
|
+
replyTo: index === 0 ? options.replyTo : void 0
|
|
608
|
+
});
|
|
609
|
+
atomicJson(path2(), outbox), activeDeliveries.has(key) && await activeDeliveries.get(key), await flushKey(key);
|
|
610
|
+
}
|
|
611
|
+
function flushOutbox() {
|
|
612
|
+
return Promise.all([...new Set(outbox.map((item) => item.key))].map(flushKey)).then(() => {
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
function flushKey(key) {
|
|
616
|
+
let current = activeDeliveries.get(key);
|
|
617
|
+
if (current)
|
|
618
|
+
return current;
|
|
619
|
+
let running = drainKey(key).finally(() => {
|
|
620
|
+
activeDeliveries.delete(key);
|
|
621
|
+
});
|
|
622
|
+
return activeDeliveries.set(key, running), running;
|
|
623
|
+
}
|
|
624
|
+
async function drainKey(key) {
|
|
625
|
+
let failedBatches = new Set(outbox.filter((item) => item.failed && item.batchId).map((item) => item.batchId));
|
|
626
|
+
for (let item of [...outbox].filter((item2) => item2.key === key)) {
|
|
627
|
+
if (item.failed || item.batchId && failedBatches.has(item.batchId))
|
|
628
|
+
continue;
|
|
629
|
+
if (item.kind === "notice" && item.epoch !== (epochs.get(item.key) ?? 0)) {
|
|
630
|
+
outbox = outbox.filter((v) => v.id !== item.id), atomicJson(path2(), outbox);
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
let binding = conversationBinding(item.key), source = item.source ?? binding?.source;
|
|
634
|
+
if (!source)
|
|
635
|
+
break;
|
|
636
|
+
let cfg = existsSync3(gatewayConfigPath()) ? loadGatewayConfig() : deliveryConfigs.get(item.key) ?? loadGatewayConfig();
|
|
637
|
+
if (binding && (binding.source.platform !== source.platform || binding.source.chatId !== source.chatId || binding.source.userId !== source.userId || binding.source.threadId !== source.threadId) || !isAuthorized(sourceWithCurrentRole(key, source), cfg, createPairingStore()) || binding?.owner && (binding.owner !== source.userId || !isGatewayOwner(source, cfg))) {
|
|
638
|
+
outbox = outbox.filter((v) => v.id !== item.id), atomicJson(path2(), outbox);
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
let adapter = adapters.get(source.platform);
|
|
642
|
+
if (!adapter || (item.nextAttempt ?? 0) > Date.now())
|
|
643
|
+
break;
|
|
644
|
+
let opts = { threadId: source.threadId, replyTo: item.replyTo }, result = await adapter.send(source.chatId, item.text, opts).catch((error) => ({ success: !1, error: String(error), retryable: !0 }));
|
|
645
|
+
if (result.success)
|
|
646
|
+
outbox = outbox.filter((v) => v.id !== item.id), atomicJson(path2(), outbox);
|
|
647
|
+
else {
|
|
648
|
+
if (item.attempts = (item.attempts ?? 0) + 1, item.failed = result.retryable === !1 || item.attempts >= MAX_ATTEMPTS, item.nextAttempt = Date.now() + Math.min(6e4, 3e3 * 2 ** (item.attempts - 1)), item.failed && item.batchId) {
|
|
649
|
+
failedBatches.add(item.batchId);
|
|
650
|
+
for (let pending2 of outbox)
|
|
651
|
+
pending2.batchId === item.batchId && (pending2.failed = !0);
|
|
652
|
+
}
|
|
653
|
+
atomicJson(path2(), outbox), console.error(`[gateway] delivery ${item.failed ? "failed permanently" : "retry scheduled"} for ${source.platform}: ${result.error ?? "unknown error"}`);
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
function invalidateGatewayDialogs(key) {
|
|
659
|
+
epochs.set(key, (epochs.get(key) ?? 0) + 1);
|
|
660
|
+
let remaining = outbox.filter((item) => item.key !== key || item.kind !== "notice");
|
|
661
|
+
remaining.length !== outbox.length && (outbox = remaining, atomicJson(path2(), outbox));
|
|
662
|
+
for (let cancel of dialogs.get(key) ?? [])
|
|
663
|
+
cancel();
|
|
664
|
+
dialogs.delete(key), inputs.delete(key);
|
|
665
|
+
}
|
|
666
|
+
function acceptGatewayInput(key, event) {
|
|
667
|
+
let input = inputs.get(key);
|
|
668
|
+
return !input || input.userId !== event.source.userId || !canDeliver(key) || event.text.startsWith("/") && event.text !== "/cancel" ? !1 : (input.resolve(event.text === "/cancel" ? void 0 : event.text), !0);
|
|
669
|
+
}
|
|
670
|
+
function dialog(key, opts, show) {
|
|
671
|
+
let epoch = epochs.get(key) ?? 0;
|
|
672
|
+
return new Promise((resolve, reject) => {
|
|
673
|
+
let settled = !1, finish = (value, error) => {
|
|
674
|
+
settled || (settled = !0, clearTimeout(timeout), opts?.signal?.removeEventListener("abort", cancel), inputs.delete(key), dialogs.get(key)?.delete(cancel), error !== void 0 ? reject(error) : resolve(value));
|
|
675
|
+
}, done = (value) => finish(value), cancel = () => done(void 0), timeout = setTimeout(cancel, opts?.timeout ?? 3e5), set = dialogs.get(key) ?? /* @__PURE__ */ new Set();
|
|
676
|
+
if (set.add(cancel), dialogs.set(key, set), opts?.signal?.addEventListener("abort", cancel, { once: !0 }), opts?.signal?.aborted) {
|
|
677
|
+
cancel();
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
show(done, () => !settled && (epochs.get(key) ?? 0) === epoch && canDeliver(key)).catch((error) => {
|
|
681
|
+
finish(void 0, error);
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
function gatewaySelect(key, title, options, opts) {
|
|
686
|
+
return dialog(key, opts, async (done, valid) => {
|
|
687
|
+
let { adapter, source } = gatewayDestination(key), result = await createPicker(adapter, source, {
|
|
688
|
+
kind: "dialog",
|
|
689
|
+
sessionKey: key,
|
|
690
|
+
invokerId: source.userId,
|
|
691
|
+
title,
|
|
692
|
+
items: options.map((value) => ({ label: value, value })),
|
|
693
|
+
validate: valid,
|
|
694
|
+
onCancel: () => done(void 0),
|
|
695
|
+
resolve: async (item) => (done(item.value), { done: !0, text: `${title}
|
|
696
|
+
${item.value}` })
|
|
697
|
+
}, { threadId: source.threadId });
|
|
698
|
+
if (!result.success)
|
|
699
|
+
throw new Error(result.error ?? "Could not send picker.");
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
function gatewayInput(key, title, placeholder, opts) {
|
|
703
|
+
if (inputs.has(key))
|
|
704
|
+
return Promise.reject(new Error("Answer or cancel the existing question first."));
|
|
705
|
+
let epoch = gatewayEpoch(key);
|
|
706
|
+
return dialog(key, opts, async (done) => {
|
|
707
|
+
let { source } = gatewayDestination(key);
|
|
708
|
+
inputs.set(key, { userId: source.userId, resolve: done }), await sendGatewayNotice(key, `${title}${placeholder ? `
|
|
709
|
+
${placeholder}` : ""}
|
|
710
|
+
Reply with text, or /cancel.`, "notice", epoch);
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
function createGatewayUI(key) {
|
|
714
|
+
let epoch = gatewayEpoch(key);
|
|
715
|
+
return {
|
|
716
|
+
...noOpUIContext,
|
|
717
|
+
select: (title, options, opts) => gatewayEpoch(key) === epoch ? gatewaySelect(key, title, options, opts) : Promise.resolve(void 0),
|
|
718
|
+
confirm: async (title, message, opts) => gatewayEpoch(key) === epoch && await gatewaySelect(key, `${title}
|
|
719
|
+
${message}`, ["Approve", "Decline"], opts) === "Approve",
|
|
720
|
+
input: (title, placeholder, opts) => gatewayEpoch(key) === epoch ? gatewayInput(key, title, placeholder, opts) : Promise.resolve(void 0),
|
|
721
|
+
editor: (title, prefill) => gatewayEpoch(key) === epoch ? gatewayInput(key, title, prefill) : Promise.resolve(void 0),
|
|
722
|
+
notify: (message) => {
|
|
723
|
+
sendGatewayNotice(key, message, "notice", epoch).catch(() => {
|
|
724
|
+
});
|
|
725
|
+
},
|
|
726
|
+
custom: async () => {
|
|
727
|
+
throw new Error("This command requires the terminal interface. Use the gateway's text commands or button pickers.");
|
|
728
|
+
},
|
|
729
|
+
pasteToEditor: (text) => {
|
|
730
|
+
sendGatewayNotice(key, text, "notice", epoch).catch(() => {
|
|
731
|
+
});
|
|
732
|
+
},
|
|
733
|
+
setEditorText: (text) => {
|
|
734
|
+
sendGatewayNotice(key, text, "notice", epoch).catch(() => {
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
export {
|
|
741
|
+
isGatewayOwner,
|
|
742
|
+
requireGatewayOwner,
|
|
743
|
+
isAuthorized,
|
|
744
|
+
addAllowedUser,
|
|
745
|
+
conversationBinding,
|
|
746
|
+
bindConversation,
|
|
747
|
+
getSession,
|
|
748
|
+
putSession,
|
|
749
|
+
touchSession,
|
|
750
|
+
removeSession,
|
|
751
|
+
listSessions,
|
|
752
|
+
runWithApprovalContext,
|
|
753
|
+
registerGatewayApprovalHandler,
|
|
754
|
+
handleApprovalCallback,
|
|
755
|
+
cancelGatewayApprovals,
|
|
756
|
+
createPicker,
|
|
757
|
+
handleCallback,
|
|
758
|
+
startButtonSweeper,
|
|
759
|
+
stopButtonSweeper,
|
|
760
|
+
splitMessage,
|
|
761
|
+
rememberGatewayRole,
|
|
762
|
+
withGatewayPresentation,
|
|
763
|
+
startGatewayPresenter,
|
|
764
|
+
stopGatewayPresenter,
|
|
765
|
+
gatewayEpoch,
|
|
766
|
+
sendGatewayNotice,
|
|
767
|
+
queueGatewayText,
|
|
768
|
+
invalidateGatewayDialogs,
|
|
769
|
+
acceptGatewayInput,
|
|
770
|
+
gatewaySelect,
|
|
771
|
+
gatewayInput,
|
|
772
|
+
createGatewayUI
|
|
773
|
+
};
|