@supen-ai/cli 0.1.6
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/README.md +235 -0
- package/daemon/dist/acp-client.d.ts +42 -0
- package/daemon/dist/acp-client.d.ts.map +1 -0
- package/daemon/dist/acp-client.js +149 -0
- package/daemon/dist/acp-client.js.map +1 -0
- package/daemon/dist/acp-types.d.ts +98 -0
- package/daemon/dist/acp-types.d.ts.map +1 -0
- package/daemon/dist/acp-types.js +2 -0
- package/daemon/dist/acp-types.js.map +1 -0
- package/daemon/dist/agent-sdk/app-server-approvals.d.ts +24 -0
- package/daemon/dist/agent-sdk/app-server-approvals.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/app-server-approvals.js +99 -0
- package/daemon/dist/agent-sdk/app-server-approvals.js.map +1 -0
- package/daemon/dist/agent-sdk/app-server-stream.d.ts +8 -0
- package/daemon/dist/agent-sdk/app-server-stream.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/app-server-stream.js +328 -0
- package/daemon/dist/agent-sdk/app-server-stream.js.map +1 -0
- package/daemon/dist/agent-sdk/driver-output-ui.d.ts +9 -0
- package/daemon/dist/agent-sdk/driver-output-ui.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/driver-output-ui.js +290 -0
- package/daemon/dist/agent-sdk/driver-output-ui.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/acpx-driver.d.ts +21 -0
- package/daemon/dist/agent-sdk/drivers/acpx-driver.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/acpx-driver.js +488 -0
- package/daemon/dist/agent-sdk/drivers/acpx-driver.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/claude-acpx-driver.d.ts +5 -0
- package/daemon/dist/agent-sdk/drivers/claude-acpx-driver.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/claude-acpx-driver.js +7 -0
- package/daemon/dist/agent-sdk/drivers/claude-acpx-driver.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/claude-cli-direct-driver.d.ts +20 -0
- package/daemon/dist/agent-sdk/drivers/claude-cli-direct-driver.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/claude-cli-direct-driver.js +264 -0
- package/daemon/dist/agent-sdk/drivers/claude-cli-direct-driver.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-driver.d.ts +29 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-driver.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-driver.js +24 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-driver.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-events.d.ts +25 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-events.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-events.js +58 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-events.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-items.d.ts +41 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-items.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-items.js +77 -0
- package/daemon/dist/agent-sdk/drivers/claude-code-items.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/codex-acpx-driver.d.ts +5 -0
- package/daemon/dist/agent-sdk/drivers/codex-acpx-driver.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/codex-acpx-driver.js +7 -0
- package/daemon/dist/agent-sdk/drivers/codex-acpx-driver.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/codex-app-server-driver.d.ts +12 -0
- package/daemon/dist/agent-sdk/drivers/codex-app-server-driver.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/codex-app-server-driver.js +484 -0
- package/daemon/dist/agent-sdk/drivers/codex-app-server-driver.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-driver.d.ts +28 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-driver.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-driver.js +219 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-driver.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-events.d.ts +9 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-events.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-events.js +82 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-events.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-items.d.ts +9 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-items.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-items.js +86 -0
- package/daemon/dist/agent-sdk/drivers/codex-exec-items.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/driver.d.ts +60 -0
- package/daemon/dist/agent-sdk/drivers/driver.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/driver.js +2 -0
- package/daemon/dist/agent-sdk/drivers/driver.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/gemini-cli-driver.d.ts +17 -0
- package/daemon/dist/agent-sdk/drivers/gemini-cli-driver.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/gemini-cli-driver.js +255 -0
- package/daemon/dist/agent-sdk/drivers/gemini-cli-driver.js.map +1 -0
- package/daemon/dist/agent-sdk/drivers/registry.d.ts +21 -0
- package/daemon/dist/agent-sdk/drivers/registry.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/drivers/registry.js +167 -0
- package/daemon/dist/agent-sdk/drivers/registry.js.map +1 -0
- package/daemon/dist/agent-sdk/index.d.ts +24 -0
- package/daemon/dist/agent-sdk/index.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/index.js +19 -0
- package/daemon/dist/agent-sdk/index.js.map +1 -0
- package/daemon/dist/agent-sdk/intelligence/contracts.d.ts +17 -0
- package/daemon/dist/agent-sdk/intelligence/contracts.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/intelligence/contracts.js +2 -0
- package/daemon/dist/agent-sdk/intelligence/contracts.js.map +1 -0
- package/daemon/dist/agent-sdk/memory/filesystem.d.ts +7 -0
- package/daemon/dist/agent-sdk/memory/filesystem.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/memory/filesystem.js +133 -0
- package/daemon/dist/agent-sdk/memory/filesystem.js.map +1 -0
- package/daemon/dist/agent-sdk/memory/subsystem.d.ts +54 -0
- package/daemon/dist/agent-sdk/memory/subsystem.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/memory/subsystem.js +106 -0
- package/daemon/dist/agent-sdk/memory/subsystem.js.map +1 -0
- package/daemon/dist/agent-sdk/session-events.d.ts +59 -0
- package/daemon/dist/agent-sdk/session-events.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/session-events.js +104 -0
- package/daemon/dist/agent-sdk/session-events.js.map +1 -0
- package/daemon/dist/agent-sdk/session-manager.d.ts +28 -0
- package/daemon/dist/agent-sdk/session-manager.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/session-manager.js +54 -0
- package/daemon/dist/agent-sdk/session-manager.js.map +1 -0
- package/daemon/dist/agent-sdk/types.d.ts +110 -0
- package/daemon/dist/agent-sdk/types.d.ts.map +1 -0
- package/daemon/dist/agent-sdk/types.js +2 -0
- package/daemon/dist/agent-sdk/types.js.map +1 -0
- package/daemon/dist/automation-event-listener.d.ts +27 -0
- package/daemon/dist/automation-event-listener.d.ts.map +1 -0
- package/daemon/dist/automation-event-listener.js +342 -0
- package/daemon/dist/automation-event-listener.js.map +1 -0
- package/daemon/dist/automation-runner.d.ts +17 -0
- package/daemon/dist/automation-runner.d.ts.map +1 -0
- package/daemon/dist/automation-runner.js +592 -0
- package/daemon/dist/automation-runner.js.map +1 -0
- package/daemon/dist/autonomy/feedback-memory.d.ts +8 -0
- package/daemon/dist/autonomy/feedback-memory.d.ts.map +1 -0
- package/daemon/dist/autonomy/feedback-memory.js +23 -0
- package/daemon/dist/autonomy/feedback-memory.js.map +1 -0
- package/daemon/dist/autonomy/intent-router.d.ts +10 -0
- package/daemon/dist/autonomy/intent-router.d.ts.map +1 -0
- package/daemon/dist/autonomy/intent-router.js +72 -0
- package/daemon/dist/autonomy/intent-router.js.map +1 -0
- package/daemon/dist/autonomy/memory-rules.d.ts +35 -0
- package/daemon/dist/autonomy/memory-rules.d.ts.map +1 -0
- package/daemon/dist/autonomy/memory-rules.js +117 -0
- package/daemon/dist/autonomy/memory-rules.js.map +1 -0
- package/daemon/dist/autonomy/proof-packet.d.ts +17 -0
- package/daemon/dist/autonomy/proof-packet.d.ts.map +1 -0
- package/daemon/dist/autonomy/proof-packet.js +28 -0
- package/daemon/dist/autonomy/proof-packet.js.map +1 -0
- package/daemon/dist/autonomy/session-autonomy.d.ts +18 -0
- package/daemon/dist/autonomy/session-autonomy.d.ts.map +1 -0
- package/daemon/dist/autonomy/session-autonomy.js +71 -0
- package/daemon/dist/autonomy/session-autonomy.js.map +1 -0
- package/daemon/dist/autonomy/source-inventory.d.ts +3 -0
- package/daemon/dist/autonomy/source-inventory.d.ts.map +1 -0
- package/daemon/dist/autonomy/source-inventory.js +84 -0
- package/daemon/dist/autonomy/source-inventory.js.map +1 -0
- package/daemon/dist/autonomy/types.d.ts +20 -0
- package/daemon/dist/autonomy/types.d.ts.map +1 -0
- package/daemon/dist/autonomy/types.js +2 -0
- package/daemon/dist/autonomy/types.js.map +1 -0
- package/daemon/dist/bin/mcp-os.d.ts +3 -0
- package/daemon/dist/bin/mcp-os.d.ts.map +1 -0
- package/daemon/dist/bin/mcp-os.js +63 -0
- package/daemon/dist/bin/mcp-os.js.map +1 -0
- package/daemon/dist/bin/mcp-scheduler.d.ts +3 -0
- package/daemon/dist/bin/mcp-scheduler.d.ts.map +1 -0
- package/daemon/dist/bin/mcp-scheduler.js +90 -0
- package/daemon/dist/bin/mcp-scheduler.js.map +1 -0
- package/daemon/dist/bin/supen-sys.d.ts +3 -0
- package/daemon/dist/bin/supen-sys.d.ts.map +1 -0
- package/daemon/dist/bin/supen-sys.js +38 -0
- package/daemon/dist/bin/supen-sys.js.map +1 -0
- package/daemon/dist/bootstrap/hub-bootstrap.d.ts +2 -0
- package/daemon/dist/bootstrap/hub-bootstrap.d.ts.map +1 -0
- package/daemon/dist/bootstrap/hub-bootstrap.js +409 -0
- package/daemon/dist/bootstrap/hub-bootstrap.js.map +1 -0
- package/daemon/dist/bootstrap/skill-bootstrap.d.ts +2 -0
- package/daemon/dist/bootstrap/skill-bootstrap.d.ts.map +1 -0
- package/daemon/dist/bootstrap/skill-bootstrap.js +92 -0
- package/daemon/dist/bootstrap/skill-bootstrap.js.map +1 -0
- package/daemon/dist/channels/acp.d.ts +23 -0
- package/daemon/dist/channels/acp.d.ts.map +1 -0
- package/daemon/dist/channels/acp.js +916 -0
- package/daemon/dist/channels/acp.js.map +1 -0
- package/daemon/dist/channels/base.d.ts +38 -0
- package/daemon/dist/channels/base.d.ts.map +1 -0
- package/daemon/dist/channels/base.js +56 -0
- package/daemon/dist/channels/base.js.map +1 -0
- package/daemon/dist/channels/http-routes.d.ts +44 -0
- package/daemon/dist/channels/http-routes.d.ts.map +1 -0
- package/daemon/dist/channels/http-routes.js +688 -0
- package/daemon/dist/channels/http-routes.js.map +1 -0
- package/daemon/dist/channels/http.d.ts +16 -0
- package/daemon/dist/channels/http.d.ts.map +1 -0
- package/daemon/dist/channels/http.js +84 -0
- package/daemon/dist/channels/http.js.map +1 -0
- package/daemon/dist/channels/index.d.ts +3 -0
- package/daemon/dist/channels/index.d.ts.map +1 -0
- package/daemon/dist/channels/index.js +7 -0
- package/daemon/dist/channels/index.js.map +1 -0
- package/daemon/dist/channels/registry.d.ts +18 -0
- package/daemon/dist/channels/registry.d.ts.map +1 -0
- package/daemon/dist/channels/registry.js +11 -0
- package/daemon/dist/channels/registry.js.map +1 -0
- package/daemon/dist/commands/builtin.d.ts +7 -0
- package/daemon/dist/commands/builtin.d.ts.map +1 -0
- package/daemon/dist/commands/builtin.js +111 -0
- package/daemon/dist/commands/builtin.js.map +1 -0
- package/daemon/dist/commands/catalog.d.ts +47 -0
- package/daemon/dist/commands/catalog.d.ts.map +1 -0
- package/daemon/dist/commands/catalog.js +487 -0
- package/daemon/dist/commands/catalog.js.map +1 -0
- package/daemon/dist/core/app.d.ts +18 -0
- package/daemon/dist/core/app.d.ts.map +1 -0
- package/daemon/dist/core/app.js +49 -0
- package/daemon/dist/core/app.js.map +1 -0
- package/daemon/dist/core/automation-timing.d.ts +10 -0
- package/daemon/dist/core/automation-timing.d.ts.map +1 -0
- package/daemon/dist/core/automation-timing.js +211 -0
- package/daemon/dist/core/automation-timing.js.map +1 -0
- package/daemon/dist/core/codex-subscription.d.ts +8 -0
- package/daemon/dist/core/codex-subscription.d.ts.map +1 -0
- package/daemon/dist/core/codex-subscription.js +150 -0
- package/daemon/dist/core/codex-subscription.js.map +1 -0
- package/daemon/dist/core/command-hub.d.ts +22 -0
- package/daemon/dist/core/command-hub.d.ts.map +1 -0
- package/daemon/dist/core/command-hub.js +59 -0
- package/daemon/dist/core/command-hub.js.map +1 -0
- package/daemon/dist/core/config.d.ts +146 -0
- package/daemon/dist/core/config.d.ts.map +1 -0
- package/daemon/dist/core/config.js +663 -0
- package/daemon/dist/core/config.js.map +1 -0
- package/daemon/dist/core/control-commands.d.ts +17 -0
- package/daemon/dist/core/control-commands.d.ts.map +1 -0
- package/daemon/dist/core/control-commands.js +35 -0
- package/daemon/dist/core/control-commands.js.map +1 -0
- package/daemon/dist/core/control-log.d.ts +17 -0
- package/daemon/dist/core/control-log.d.ts.map +1 -0
- package/daemon/dist/core/control-log.js +67 -0
- package/daemon/dist/core/control-log.js.map +1 -0
- package/daemon/dist/core/cortex.d.ts +53 -0
- package/daemon/dist/core/cortex.d.ts.map +1 -0
- package/daemon/dist/core/cortex.js +1690 -0
- package/daemon/dist/core/cortex.js.map +1 -0
- package/daemon/dist/core/daemon-lock.d.ts +16 -0
- package/daemon/dist/core/daemon-lock.d.ts.map +1 -0
- package/daemon/dist/core/daemon-lock.js +285 -0
- package/daemon/dist/core/daemon-lock.js.map +1 -0
- package/daemon/dist/core/dispatcher.d.ts +42 -0
- package/daemon/dist/core/dispatcher.d.ts.map +1 -0
- package/daemon/dist/core/dispatcher.js +173 -0
- package/daemon/dist/core/dispatcher.js.map +1 -0
- package/daemon/dist/core/enrollment.d.ts +41 -0
- package/daemon/dist/core/enrollment.d.ts.map +1 -0
- package/daemon/dist/core/enrollment.js +195 -0
- package/daemon/dist/core/enrollment.js.map +1 -0
- package/daemon/dist/core/env.d.ts +109 -0
- package/daemon/dist/core/env.d.ts.map +1 -0
- package/daemon/dist/core/env.js +329 -0
- package/daemon/dist/core/env.js.map +1 -0
- package/daemon/dist/core/gateway-config.d.ts +16 -0
- package/daemon/dist/core/gateway-config.d.ts.map +1 -0
- package/daemon/dist/core/gateway-config.js +103 -0
- package/daemon/dist/core/gateway-config.js.map +1 -0
- package/daemon/dist/core/gateway-protocol.d.ts +80 -0
- package/daemon/dist/core/gateway-protocol.d.ts.map +1 -0
- package/daemon/dist/core/gateway-protocol.js +2 -0
- package/daemon/dist/core/gateway-protocol.js.map +1 -0
- package/daemon/dist/core/gateway-routing-config.d.ts +21 -0
- package/daemon/dist/core/gateway-routing-config.d.ts.map +1 -0
- package/daemon/dist/core/gateway-routing-config.js +56 -0
- package/daemon/dist/core/gateway-routing-config.js.map +1 -0
- package/daemon/dist/core/gateway.d.ts +124 -0
- package/daemon/dist/core/gateway.d.ts.map +1 -0
- package/daemon/dist/core/gateway.js +887 -0
- package/daemon/dist/core/gateway.js.map +1 -0
- package/daemon/dist/core/hub-snapshot.d.ts +42 -0
- package/daemon/dist/core/hub-snapshot.d.ts.map +1 -0
- package/daemon/dist/core/hub-snapshot.js +125 -0
- package/daemon/dist/core/hub-snapshot.js.map +1 -0
- package/daemon/dist/core/interrupts.d.ts +7 -0
- package/daemon/dist/core/interrupts.d.ts.map +1 -0
- package/daemon/dist/core/interrupts.js +28 -0
- package/daemon/dist/core/interrupts.js.map +1 -0
- package/daemon/dist/core/logger.d.ts +3 -0
- package/daemon/dist/core/logger.d.ts.map +1 -0
- package/daemon/dist/core/logger.js +91 -0
- package/daemon/dist/core/logger.js.map +1 -0
- package/daemon/dist/core/loop-guard.d.ts +27 -0
- package/daemon/dist/core/loop-guard.d.ts.map +1 -0
- package/daemon/dist/core/loop-guard.js +47 -0
- package/daemon/dist/core/loop-guard.js.map +1 -0
- package/daemon/dist/core/observable-logging.d.ts +43 -0
- package/daemon/dist/core/observable-logging.d.ts.map +1 -0
- package/daemon/dist/core/observable-logging.js +77 -0
- package/daemon/dist/core/observable-logging.js.map +1 -0
- package/daemon/dist/core/pairing.d.ts +51 -0
- package/daemon/dist/core/pairing.d.ts.map +1 -0
- package/daemon/dist/core/pairing.js +207 -0
- package/daemon/dist/core/pairing.js.map +1 -0
- package/daemon/dist/core/progress.d.ts +32 -0
- package/daemon/dist/core/progress.d.ts.map +1 -0
- package/daemon/dist/core/progress.js +145 -0
- package/daemon/dist/core/progress.js.map +1 -0
- package/daemon/dist/core/protocol-adapter.d.ts +14 -0
- package/daemon/dist/core/protocol-adapter.d.ts.map +1 -0
- package/daemon/dist/core/protocol-adapter.js +472 -0
- package/daemon/dist/core/protocol-adapter.js.map +1 -0
- package/daemon/dist/core/sdk-wrapper.d.ts +36 -0
- package/daemon/dist/core/sdk-wrapper.d.ts.map +1 -0
- package/daemon/dist/core/sdk-wrapper.js +533 -0
- package/daemon/dist/core/sdk-wrapper.js.map +1 -0
- package/daemon/dist/core/security.d.ts +10 -0
- package/daemon/dist/core/security.d.ts.map +1 -0
- package/daemon/dist/core/security.js +95 -0
- package/daemon/dist/core/security.js.map +1 -0
- package/daemon/dist/core/space-env.d.ts +15 -0
- package/daemon/dist/core/space-env.d.ts.map +1 -0
- package/daemon/dist/core/space-env.js +182 -0
- package/daemon/dist/core/space-env.js.map +1 -0
- package/daemon/dist/core/status-inspector.d.ts +31 -0
- package/daemon/dist/core/status-inspector.d.ts.map +1 -0
- package/daemon/dist/core/status-inspector.js +35 -0
- package/daemon/dist/core/status-inspector.js.map +1 -0
- package/daemon/dist/core/storage-paths.d.ts +30 -0
- package/daemon/dist/core/storage-paths.d.ts.map +1 -0
- package/daemon/dist/core/storage-paths.js +84 -0
- package/daemon/dist/core/storage-paths.js.map +1 -0
- package/daemon/dist/core/store.d.ts +256 -0
- package/daemon/dist/core/store.d.ts.map +1 -0
- package/daemon/dist/core/store.js +2956 -0
- package/daemon/dist/core/store.js.map +1 -0
- package/daemon/dist/core/streaming.d.ts +24 -0
- package/daemon/dist/core/streaming.d.ts.map +1 -0
- package/daemon/dist/core/streaming.js +57 -0
- package/daemon/dist/core/streaming.js.map +1 -0
- package/daemon/dist/core/task-artifacts.d.ts +17 -0
- package/daemon/dist/core/task-artifacts.d.ts.map +1 -0
- package/daemon/dist/core/task-artifacts.js +104 -0
- package/daemon/dist/core/task-artifacts.js.map +1 -0
- package/daemon/dist/core/thread-event-log.d.ts +54 -0
- package/daemon/dist/core/thread-event-log.d.ts.map +1 -0
- package/daemon/dist/core/thread-event-log.js +218 -0
- package/daemon/dist/core/thread-event-log.js.map +1 -0
- package/daemon/dist/core/thread-runtime-state.d.ts +53 -0
- package/daemon/dist/core/thread-runtime-state.d.ts.map +1 -0
- package/daemon/dist/core/thread-runtime-state.js +271 -0
- package/daemon/dist/core/thread-runtime-state.js.map +1 -0
- package/daemon/dist/core/types.d.ts +552 -0
- package/daemon/dist/core/types.d.ts.map +1 -0
- package/daemon/dist/core/types.js +2 -0
- package/daemon/dist/core/types.js.map +1 -0
- package/daemon/dist/core/utils.d.ts +5 -0
- package/daemon/dist/core/utils.d.ts.map +1 -0
- package/daemon/dist/core/utils.js +35 -0
- package/daemon/dist/core/utils.js.map +1 -0
- package/daemon/dist/http/command-catalog.d.ts +3 -0
- package/daemon/dist/http/command-catalog.d.ts.map +1 -0
- package/daemon/dist/http/command-catalog.js +2 -0
- package/daemon/dist/http/command-catalog.js.map +1 -0
- package/daemon/dist/http/context.d.ts +18 -0
- package/daemon/dist/http/context.d.ts.map +1 -0
- package/daemon/dist/http/context.js +121 -0
- package/daemon/dist/http/context.js.map +1 -0
- package/daemon/dist/http/office-preview.d.ts +10 -0
- package/daemon/dist/http/office-preview.d.ts.map +1 -0
- package/daemon/dist/http/office-preview.js +234 -0
- package/daemon/dist/http/office-preview.js.map +1 -0
- package/daemon/dist/http/response.d.ts +5 -0
- package/daemon/dist/http/response.d.ts.map +1 -0
- package/daemon/dist/http/response.js +37 -0
- package/daemon/dist/http/response.js.map +1 -0
- package/daemon/dist/http/router.d.ts +4 -0
- package/daemon/dist/http/router.d.ts.map +1 -0
- package/daemon/dist/http/router.js +57 -0
- package/daemon/dist/http/router.js.map +1 -0
- package/daemon/dist/http/routes/agents.d.ts +4 -0
- package/daemon/dist/http/routes/agents.d.ts.map +1 -0
- package/daemon/dist/http/routes/agents.js +747 -0
- package/daemon/dist/http/routes/agents.js.map +1 -0
- package/daemon/dist/http/routes/automations.d.ts +6 -0
- package/daemon/dist/http/routes/automations.d.ts.map +1 -0
- package/daemon/dist/http/routes/automations.js +530 -0
- package/daemon/dist/http/routes/automations.js.map +1 -0
- package/daemon/dist/http/routes/autonomy.d.ts +4 -0
- package/daemon/dist/http/routes/autonomy.d.ts.map +1 -0
- package/daemon/dist/http/routes/autonomy.js +78 -0
- package/daemon/dist/http/routes/autonomy.js.map +1 -0
- package/daemon/dist/http/routes/chat-input.d.ts +18 -0
- package/daemon/dist/http/routes/chat-input.d.ts.map +1 -0
- package/daemon/dist/http/routes/chat-input.js +122 -0
- package/daemon/dist/http/routes/chat-input.js.map +1 -0
- package/daemon/dist/http/routes/plugins.d.ts +5 -0
- package/daemon/dist/http/routes/plugins.d.ts.map +1 -0
- package/daemon/dist/http/routes/plugins.js +221 -0
- package/daemon/dist/http/routes/plugins.js.map +1 -0
- package/daemon/dist/http/routes/rpc.d.ts +28 -0
- package/daemon/dist/http/routes/rpc.d.ts.map +1 -0
- package/daemon/dist/http/routes/rpc.js +790 -0
- package/daemon/dist/http/routes/rpc.js.map +1 -0
- package/daemon/dist/http/routes/sessions.d.ts +11 -0
- package/daemon/dist/http/routes/sessions.d.ts.map +1 -0
- package/daemon/dist/http/routes/sessions.js +963 -0
- package/daemon/dist/http/routes/sessions.js.map +1 -0
- package/daemon/dist/http/routes/skills.d.ts +5 -0
- package/daemon/dist/http/routes/skills.d.ts.map +1 -0
- package/daemon/dist/http/routes/skills.js +420 -0
- package/daemon/dist/http/routes/skills.js.map +1 -0
- package/daemon/dist/http/routes/system.d.ts +64 -0
- package/daemon/dist/http/routes/system.d.ts.map +1 -0
- package/daemon/dist/http/routes/system.js +2676 -0
- package/daemon/dist/http/routes/system.js.map +1 -0
- package/daemon/dist/http/stream.d.ts +11 -0
- package/daemon/dist/http/stream.d.ts.map +1 -0
- package/daemon/dist/http/stream.js +100 -0
- package/daemon/dist/http/stream.js.map +1 -0
- package/daemon/dist/http/thread-stream.d.ts +10 -0
- package/daemon/dist/http/thread-stream.d.ts.map +1 -0
- package/daemon/dist/http/thread-stream.js +50 -0
- package/daemon/dist/http/thread-stream.js.map +1 -0
- package/daemon/dist/http/thread-title.d.ts +12 -0
- package/daemon/dist/http/thread-title.d.ts.map +1 -0
- package/daemon/dist/http/thread-title.js +122 -0
- package/daemon/dist/http/thread-title.js.map +1 -0
- package/daemon/dist/http/utils.d.ts +2 -0
- package/daemon/dist/http/utils.d.ts.map +1 -0
- package/daemon/dist/http/utils.js +18 -0
- package/daemon/dist/http/utils.js.map +1 -0
- package/daemon/dist/http/websocket.d.ts +5 -0
- package/daemon/dist/http/websocket.d.ts.map +1 -0
- package/daemon/dist/http/websocket.js +100 -0
- package/daemon/dist/http/websocket.js.map +1 -0
- package/daemon/dist/index.d.ts +35 -0
- package/daemon/dist/index.d.ts.map +1 -0
- package/daemon/dist/index.js +1582 -0
- package/daemon/dist/index.js.map +1 -0
- package/daemon/dist/mcp/aggregate-config.d.ts +16 -0
- package/daemon/dist/mcp/aggregate-config.d.ts.map +1 -0
- package/daemon/dist/mcp/aggregate-config.js +97 -0
- package/daemon/dist/mcp/aggregate-config.js.map +1 -0
- package/daemon/dist/mcp/client.d.ts +94 -0
- package/daemon/dist/mcp/client.d.ts.map +1 -0
- package/daemon/dist/mcp/client.js +207 -0
- package/daemon/dist/mcp/client.js.map +1 -0
- package/daemon/dist/mcp/default-servers.d.ts +35 -0
- package/daemon/dist/mcp/default-servers.d.ts.map +1 -0
- package/daemon/dist/mcp/default-servers.js +209 -0
- package/daemon/dist/mcp/default-servers.js.map +1 -0
- package/daemon/dist/mcp/gateway-client.d.ts +58 -0
- package/daemon/dist/mcp/gateway-client.d.ts.map +1 -0
- package/daemon/dist/mcp/gateway-client.js +181 -0
- package/daemon/dist/mcp/gateway-client.js.map +1 -0
- package/daemon/dist/mcp/index.d.ts +26 -0
- package/daemon/dist/mcp/index.d.ts.map +1 -0
- package/daemon/dist/mcp/index.js +50 -0
- package/daemon/dist/mcp/index.js.map +1 -0
- package/daemon/dist/mcp/settings.d.ts +3 -0
- package/daemon/dist/mcp/settings.d.ts.map +1 -0
- package/daemon/dist/mcp/settings.js +60 -0
- package/daemon/dist/mcp/settings.js.map +1 -0
- package/daemon/dist/mcp/tools.d.ts +21 -0
- package/daemon/dist/mcp/tools.d.ts.map +1 -0
- package/daemon/dist/mcp/tools.js +136 -0
- package/daemon/dist/mcp/tools.js.map +1 -0
- package/daemon/dist/plugins/catalog.d.ts +10 -0
- package/daemon/dist/plugins/catalog.d.ts.map +1 -0
- package/daemon/dist/plugins/catalog.js +304 -0
- package/daemon/dist/plugins/catalog.js.map +1 -0
- package/daemon/dist/plugins/hub.d.ts +42 -0
- package/daemon/dist/plugins/hub.d.ts.map +1 -0
- package/daemon/dist/plugins/hub.js +812 -0
- package/daemon/dist/plugins/hub.js.map +1 -0
- package/daemon/dist/plugins/types.d.ts +144 -0
- package/daemon/dist/plugins/types.d.ts.map +1 -0
- package/daemon/dist/plugins/types.js +2 -0
- package/daemon/dist/plugins/types.js.map +1 -0
- package/daemon/dist/router.d.ts +13 -0
- package/daemon/dist/router.d.ts.map +1 -0
- package/daemon/dist/router.js +43 -0
- package/daemon/dist/router.js.map +1 -0
- package/daemon/dist/skills/adapter.d.ts +4 -0
- package/daemon/dist/skills/adapter.d.ts.map +1 -0
- package/daemon/dist/skills/adapter.js +141 -0
- package/daemon/dist/skills/adapter.js.map +1 -0
- package/daemon/dist/skills/allowlist.d.ts +20 -0
- package/daemon/dist/skills/allowlist.d.ts.map +1 -0
- package/daemon/dist/skills/allowlist.js +52 -0
- package/daemon/dist/skills/allowlist.js.map +1 -0
- package/daemon/dist/skills/catalog.d.ts +26 -0
- package/daemon/dist/skills/catalog.d.ts.map +1 -0
- package/daemon/dist/skills/catalog.js +274 -0
- package/daemon/dist/skills/catalog.js.map +1 -0
- package/daemon/dist/skills/claude_code.d.ts +25 -0
- package/daemon/dist/skills/claude_code.d.ts.map +1 -0
- package/daemon/dist/skills/claude_code.js +49 -0
- package/daemon/dist/skills/claude_code.js.map +1 -0
- package/daemon/dist/skills/commands.d.ts +3 -0
- package/daemon/dist/skills/commands.d.ts.map +1 -0
- package/daemon/dist/skills/commands.js +689 -0
- package/daemon/dist/skills/commands.js.map +1 -0
- package/daemon/dist/skills/enabled.d.ts +7 -0
- package/daemon/dist/skills/enabled.d.ts.map +1 -0
- package/daemon/dist/skills/enabled.js +37 -0
- package/daemon/dist/skills/enabled.js.map +1 -0
- package/daemon/dist/skills/hub.d.ts +35 -0
- package/daemon/dist/skills/hub.d.ts.map +1 -0
- package/daemon/dist/skills/hub.js +574 -0
- package/daemon/dist/skills/hub.js.map +1 -0
- package/daemon/dist/skills/loader.d.ts +24 -0
- package/daemon/dist/skills/loader.d.ts.map +1 -0
- package/daemon/dist/skills/loader.js +693 -0
- package/daemon/dist/skills/loader.js.map +1 -0
- package/daemon/dist/skills/mcp-config.d.ts +8 -0
- package/daemon/dist/skills/mcp-config.d.ts.map +1 -0
- package/daemon/dist/skills/mcp-config.js +110 -0
- package/daemon/dist/skills/mcp-config.js.map +1 -0
- package/daemon/dist/skills/parser.d.ts +3 -0
- package/daemon/dist/skills/parser.d.ts.map +1 -0
- package/daemon/dist/skills/parser.js +279 -0
- package/daemon/dist/skills/parser.js.map +1 -0
- package/daemon/dist/skills/registry.d.ts +2 -0
- package/daemon/dist/skills/registry.d.ts.map +1 -0
- package/daemon/dist/skills/registry.js +2 -0
- package/daemon/dist/skills/registry.js.map +1 -0
- package/daemon/dist/skills/runtime-contract.d.ts +3 -0
- package/daemon/dist/skills/runtime-contract.d.ts.map +1 -0
- package/daemon/dist/skills/runtime-contract.js +92 -0
- package/daemon/dist/skills/runtime-contract.js.map +1 -0
- package/daemon/dist/skills/runtime.d.ts +28 -0
- package/daemon/dist/skills/runtime.d.ts.map +1 -0
- package/daemon/dist/skills/runtime.js +286 -0
- package/daemon/dist/skills/runtime.js.map +1 -0
- package/daemon/dist/skills/types.d.ts +228 -0
- package/daemon/dist/skills/types.d.ts.map +1 -0
- package/daemon/dist/skills/types.js +2 -0
- package/daemon/dist/skills/types.js.map +1 -0
- package/daemon/dist/start.d.ts +6 -0
- package/daemon/dist/start.d.ts.map +1 -0
- package/daemon/dist/start.js +19 -0
- package/daemon/dist/start.js.map +1 -0
- package/daemon/dist/sub-agent.d.ts +46 -0
- package/daemon/dist/sub-agent.d.ts.map +1 -0
- package/daemon/dist/sub-agent.js +120 -0
- package/daemon/dist/sub-agent.js.map +1 -0
- package/daemon/dist/sync/supabase-sync.d.ts +16 -0
- package/daemon/dist/sync/supabase-sync.d.ts.map +1 -0
- package/daemon/dist/sync/supabase-sync.js +240 -0
- package/daemon/dist/sync/supabase-sync.js.map +1 -0
- package/daemon/dist/task-executor.d.ts +6 -0
- package/daemon/dist/task-executor.d.ts.map +1 -0
- package/daemon/dist/task-executor.js +31 -0
- package/daemon/dist/task-executor.js.map +1 -0
- package/daemon/dist/tools/automations.d.ts +57 -0
- package/daemon/dist/tools/automations.d.ts.map +1 -0
- package/daemon/dist/tools/automations.js +94 -0
- package/daemon/dist/tools/automations.js.map +1 -0
- package/daemon/dist/tools/built-ins.d.ts +112 -0
- package/daemon/dist/tools/built-ins.d.ts.map +1 -0
- package/daemon/dist/tools/built-ins.js +251 -0
- package/daemon/dist/tools/built-ins.js.map +1 -0
- package/daemon/dist/tools/index.d.ts +287 -0
- package/daemon/dist/tools/index.d.ts.map +1 -0
- package/daemon/dist/tools/index.js +86 -0
- package/daemon/dist/tools/index.js.map +1 -0
- package/daemon/dist/tools/shell.d.ts +15 -0
- package/daemon/dist/tools/shell.d.ts.map +1 -0
- package/daemon/dist/tools/shell.js +46 -0
- package/daemon/dist/tools/shell.js.map +1 -0
- package/daemon/dist/tools/skill-tools.d.ts +23 -0
- package/daemon/dist/tools/skill-tools.d.ts.map +1 -0
- package/daemon/dist/tools/skill-tools.js +64 -0
- package/daemon/dist/tools/skill-tools.js.map +1 -0
- package/daemon/dist/tools/system.d.ts +36 -0
- package/daemon/dist/tools/system.d.ts.map +1 -0
- package/daemon/dist/tools/system.js +54 -0
- package/daemon/dist/tools/system.js.map +1 -0
- package/daemon/dist/tools/types.d.ts +11 -0
- package/daemon/dist/tools/types.d.ts.map +1 -0
- package/daemon/dist/tools/types.js +2 -0
- package/daemon/dist/tools/types.js.map +1 -0
- package/daemon/scripts/browser-smoke.mjs +125 -0
- package/daemon/scripts/supen-daemon.js +15 -0
- package/dist/agent.d.ts +11 -0
- package/dist/agent.js +159 -0
- package/dist/agent.js.map +1 -0
- package/dist/auth/login.d.ts +20 -0
- package/dist/auth/login.js +151 -0
- package/dist/auth/login.js.map +1 -0
- package/dist/auth/logout.d.ts +5 -0
- package/dist/auth/logout.js +19 -0
- package/dist/auth/logout.js.map +1 -0
- package/dist/auth/store.d.ts +37 -0
- package/dist/auth/store.js +80 -0
- package/dist/auth/store.js.map +1 -0
- package/dist/auth/whoami.d.ts +5 -0
- package/dist/auth/whoami.js +24 -0
- package/dist/auth/whoami.js.map +1 -0
- package/dist/backend.d.ts +8 -0
- package/dist/backend.js +148 -0
- package/dist/backend.js.map +1 -0
- package/dist/bootstrap.d.ts +13 -0
- package/dist/bootstrap.js +230 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/chat.d.ts +13 -0
- package/dist/chat.js +255 -0
- package/dist/chat.js.map +1 -0
- package/dist/commands.d.ts +48 -0
- package/dist/commands.js +273 -0
- package/dist/commands.js.map +1 -0
- package/dist/computer.d.ts +2 -0
- package/dist/computer.js +510 -0
- package/dist/computer.js.map +1 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.js +149 -0
- package/dist/config.js.map +1 -0
- package/dist/daemon-manage.d.ts +29 -0
- package/dist/daemon-manage.js +255 -0
- package/dist/daemon-manage.js.map +1 -0
- package/dist/daemon.d.ts +15 -0
- package/dist/daemon.js +205 -0
- package/dist/daemon.js.map +1 -0
- package/dist/doctor.d.ts +13 -0
- package/dist/doctor.js +323 -0
- package/dist/doctor.js.map +1 -0
- package/dist/enroll.d.ts +7 -0
- package/dist/enroll.js +154 -0
- package/dist/enroll.js.map +1 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.js +363 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +141 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge.d.ts +3 -0
- package/dist/knowledge.js +1581 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/mcp.d.ts +11 -0
- package/dist/mcp.js +137 -0
- package/dist/mcp.js.map +1 -0
- package/dist/model.d.ts +8 -0
- package/dist/model.js +192 -0
- package/dist/model.js.map +1 -0
- package/dist/pairing.d.ts +21 -0
- package/dist/pairing.js +376 -0
- package/dist/pairing.js.map +1 -0
- package/dist/repl-events.d.ts +60 -0
- package/dist/repl-events.js +89 -0
- package/dist/repl-events.js.map +1 -0
- package/dist/repl-renderer.d.ts +37 -0
- package/dist/repl-renderer.js +140 -0
- package/dist/repl-renderer.js.map +1 -0
- package/dist/repl.d.ts +52 -0
- package/dist/repl.js +624 -0
- package/dist/repl.js.map +1 -0
- package/dist/service.d.ts +8 -0
- package/dist/service.js +238 -0
- package/dist/service.js.map +1 -0
- package/dist/skills.d.ts +14 -0
- package/dist/skills.js +423 -0
- package/dist/skills.js.map +1 -0
- package/dist/sse.d.ts +15 -0
- package/dist/sse.js +166 -0
- package/dist/sse.js.map +1 -0
- package/dist/thread.d.ts +9 -0
- package/dist/thread.js +152 -0
- package/dist/thread.js.map +1 -0
- package/dist/transport/computer-api.d.ts +1 -0
- package/dist/transport/computer-api.js +20 -0
- package/dist/transport/computer-api.js.map +1 -0
- package/dist/transport/gateway.d.ts +23 -0
- package/dist/transport/gateway.js +161 -0
- package/dist/transport/gateway.js.map +1 -0
- package/dist/transport/index.d.ts +27 -0
- package/dist/transport/index.js +77 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/local.d.ts +20 -0
- package/dist/transport/local.js +138 -0
- package/dist/transport/local.js.map +1 -0
- package/dist/transport/types.d.ts +42 -0
- package/dist/transport/types.js +11 -0
- package/dist/transport/types.js.map +1 -0
- package/dist/ui/app.d.ts +7 -0
- package/dist/ui/app.js +192 -0
- package/dist/ui/app.js.map +1 -0
- package/dist/ui/history-item.d.ts +9 -0
- package/dist/ui/history-item.js +35 -0
- package/dist/ui/history-item.js.map +1 -0
- package/dist/ui/input-bar.d.ts +17 -0
- package/dist/ui/input-bar.js +67 -0
- package/dist/ui/input-bar.js.map +1 -0
- package/dist/ui/streaming-view.d.ts +6 -0
- package/dist/ui/streaming-view.js +6 -0
- package/dist/ui/streaming-view.js.map +1 -0
- package/dist/ui/thread-input-history.d.ts +18 -0
- package/dist/ui/thread-input-history.js +67 -0
- package/dist/ui/thread-input-history.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.js +80 -0
- package/dist/utils.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { ensureSession, getAllSessions, getSessionForAgent, getSessionUiEvents, getSessionsForAgent, } from '../../core/store.js';
|
|
6
|
+
import { recordSessionControlCommand } from '../../core/control-commands.js';
|
|
7
|
+
import { listControlLogEntries } from '../../core/control-log.js';
|
|
8
|
+
import { resolveLocalWorkspaceFolder } from '../../core/task-artifacts.js';
|
|
9
|
+
import { projectThreadRuntimeState } from '../../core/thread-runtime-state.js';
|
|
10
|
+
import { respondAppServerApproval } from '../../agent-sdk/app-server-approvals.js';
|
|
11
|
+
import { writeJson, readJsonBody } from '../response.js';
|
|
12
|
+
import { buildHttpSessionId } from '../stream.js';
|
|
13
|
+
import { readCodexThreadHistory } from './system.js';
|
|
14
|
+
function success(id, result) {
|
|
15
|
+
return { jsonrpc: '2.0', id, result };
|
|
16
|
+
}
|
|
17
|
+
function rpcError(id, code, message, data) {
|
|
18
|
+
return {
|
|
19
|
+
jsonrpc: '2.0',
|
|
20
|
+
id,
|
|
21
|
+
error: {
|
|
22
|
+
code,
|
|
23
|
+
message,
|
|
24
|
+
...(data ? { data } : {}),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function readString(value) {
|
|
29
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
30
|
+
}
|
|
31
|
+
function readBoolean(value) {
|
|
32
|
+
return value === true;
|
|
33
|
+
}
|
|
34
|
+
function readRuntimeEffort(value) {
|
|
35
|
+
const text = readString(value).toLowerCase();
|
|
36
|
+
if (text === 'low' || text === 'medium' || text === 'high' || text === 'xhigh')
|
|
37
|
+
return text;
|
|
38
|
+
if (text === 'extra-high' || text === 'extra_high' || text === 'extra high')
|
|
39
|
+
return 'xhigh';
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
function readRuntimePermissionMode(value) {
|
|
43
|
+
const text = readString(value);
|
|
44
|
+
if (text === 'default' ||
|
|
45
|
+
text === 'read-only' ||
|
|
46
|
+
text === 'workspace-write' ||
|
|
47
|
+
text === 'full-access' ||
|
|
48
|
+
text === 'custom') {
|
|
49
|
+
return text;
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
function optionalAgentIdFromParams(params) {
|
|
54
|
+
return readString(params?.agentId) || readString(params?.agent_id) || null;
|
|
55
|
+
}
|
|
56
|
+
function threadIdFromParams(params) {
|
|
57
|
+
return (readString(params?.taskId) ||
|
|
58
|
+
readString(params?.task_id) ||
|
|
59
|
+
readString(params?.threadId) ||
|
|
60
|
+
readString(params?.thread_id) ||
|
|
61
|
+
readString(params?.sessionId));
|
|
62
|
+
}
|
|
63
|
+
function actorFromContext(context) {
|
|
64
|
+
return context?.actor || 'http';
|
|
65
|
+
}
|
|
66
|
+
function hasPendingApproval(session) {
|
|
67
|
+
const pendingToolCallIds = new Set();
|
|
68
|
+
for (const event of getSessionUiEvents(session.agent_id, session.session_id, 200)) {
|
|
69
|
+
const chunk = event.chunk && typeof event.chunk === 'object'
|
|
70
|
+
? event.chunk
|
|
71
|
+
: {};
|
|
72
|
+
const type = typeof chunk.type === 'string' ? chunk.type : '';
|
|
73
|
+
const toolCallId = typeof chunk.toolCallId === 'string' ? chunk.toolCallId : '';
|
|
74
|
+
if (!toolCallId)
|
|
75
|
+
continue;
|
|
76
|
+
if (type === 'tool-approval-request') {
|
|
77
|
+
pendingToolCallIds.add(toolCallId);
|
|
78
|
+
}
|
|
79
|
+
else if (type === 'tool-output-available' ||
|
|
80
|
+
type === 'tool-output-error' ||
|
|
81
|
+
type === 'tool-output-denied') {
|
|
82
|
+
pendingToolCallIds.delete(toolCallId);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return pendingToolCallIds.size > 0;
|
|
86
|
+
}
|
|
87
|
+
function serializeThread(session) {
|
|
88
|
+
return {
|
|
89
|
+
id: session.session_id,
|
|
90
|
+
taskId: session.session_id,
|
|
91
|
+
agentId: session.agent_id,
|
|
92
|
+
status: session.status,
|
|
93
|
+
pendingApproval: hasPendingApproval(session),
|
|
94
|
+
title: session.title,
|
|
95
|
+
createdAt: session.created_at,
|
|
96
|
+
updatedAt: session.updated_at,
|
|
97
|
+
supen: {
|
|
98
|
+
spaceId: session.space_id,
|
|
99
|
+
channel: session.channel,
|
|
100
|
+
sourceRef: session.source_ref,
|
|
101
|
+
knowledgeId: session.knowledge_id,
|
|
102
|
+
knowledgeName: session.knowledge_name,
|
|
103
|
+
environmentId: session.environment_id,
|
|
104
|
+
environmentSnapshot: session.environment_snapshot,
|
|
105
|
+
taskWorkspaceFolder: session.task_workspace_folder,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function readStringRecord(value) {
|
|
110
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
111
|
+
return {};
|
|
112
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
|
|
113
|
+
key,
|
|
114
|
+
entry == null ? '' : String(entry),
|
|
115
|
+
]));
|
|
116
|
+
}
|
|
117
|
+
function readStringArray(value) {
|
|
118
|
+
if (!Array.isArray(value))
|
|
119
|
+
return [];
|
|
120
|
+
return value.map((entry) => String(entry).trim()).filter(Boolean);
|
|
121
|
+
}
|
|
122
|
+
function normalizeEnvironmentSnapshot(value) {
|
|
123
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
124
|
+
return {
|
|
125
|
+
id: 'default',
|
|
126
|
+
name: 'Default Environment',
|
|
127
|
+
github_repo: null,
|
|
128
|
+
environment_variables: {},
|
|
129
|
+
secret_names: [],
|
|
130
|
+
task_network_access: false,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const record = value;
|
|
134
|
+
const githubRepo = readString(record.github_repo ?? record.githubRepo);
|
|
135
|
+
return {
|
|
136
|
+
id: readString(record.id) || 'default',
|
|
137
|
+
name: readString(record.name) || 'Default Environment',
|
|
138
|
+
description: readString(record.description),
|
|
139
|
+
github_repo: githubRepo || null,
|
|
140
|
+
environment_variables: readStringRecord(record.environment_variables ?? record.environmentVariables),
|
|
141
|
+
secret_names: readStringArray(record.secret_names ?? record.secretNames),
|
|
142
|
+
task_network_access: readBoolean(record.task_network_access ?? record.taskNetworkAccess),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function normalizeTaskWorkspaceFolder(value) {
|
|
146
|
+
const folder = readString(value);
|
|
147
|
+
return folder || null;
|
|
148
|
+
}
|
|
149
|
+
function validateTaskWorkspaceFolder(folder) {
|
|
150
|
+
if (!folder)
|
|
151
|
+
return null;
|
|
152
|
+
const resolved = resolveLocalWorkspaceFolder(folder);
|
|
153
|
+
try {
|
|
154
|
+
const stat = fs.statSync(resolved);
|
|
155
|
+
if (!stat.isDirectory()) {
|
|
156
|
+
return `Task local folder is not a directory: ${resolved}`;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return `Task local folder is not accessible: ${resolved}`;
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
function displayLocalPath(absolutePath) {
|
|
165
|
+
const resolved = path.resolve(absolutePath);
|
|
166
|
+
const home = path.resolve(os.homedir());
|
|
167
|
+
if (resolved === home)
|
|
168
|
+
return '~';
|
|
169
|
+
if (resolved.startsWith(`${home}${path.sep}`)) {
|
|
170
|
+
return `~/${path.relative(home, resolved).replace(/\\/g, '/')}`;
|
|
171
|
+
}
|
|
172
|
+
return resolved;
|
|
173
|
+
}
|
|
174
|
+
function listHostDirectories(folder) {
|
|
175
|
+
const resolved = resolveLocalWorkspaceFolder(folder || '~');
|
|
176
|
+
const stat = fs.statSync(resolved);
|
|
177
|
+
if (!stat.isDirectory()) {
|
|
178
|
+
throw new Error(`Not a directory: ${resolved}`);
|
|
179
|
+
}
|
|
180
|
+
const entries = fs
|
|
181
|
+
.readdirSync(resolved, { withFileTypes: true })
|
|
182
|
+
.filter((entry) => entry.isDirectory())
|
|
183
|
+
.map((entry) => {
|
|
184
|
+
const entryPath = path.join(resolved, entry.name);
|
|
185
|
+
return {
|
|
186
|
+
name: entry.name,
|
|
187
|
+
path: entryPath,
|
|
188
|
+
displayPath: displayLocalPath(entryPath),
|
|
189
|
+
};
|
|
190
|
+
})
|
|
191
|
+
.sort((a, b) => {
|
|
192
|
+
const aHidden = a.name.startsWith('.');
|
|
193
|
+
const bHidden = b.name.startsWith('.');
|
|
194
|
+
if (aHidden !== bHidden)
|
|
195
|
+
return aHidden ? 1 : -1;
|
|
196
|
+
return a.name.localeCompare(b.name);
|
|
197
|
+
});
|
|
198
|
+
const parent = path.dirname(resolved);
|
|
199
|
+
return {
|
|
200
|
+
path: resolved,
|
|
201
|
+
displayPath: displayLocalPath(resolved),
|
|
202
|
+
parentPath: parent === resolved ? null : parent,
|
|
203
|
+
parentDisplayPath: parent === resolved ? null : displayLocalPath(parent),
|
|
204
|
+
entries,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function contentPartToText(part) {
|
|
208
|
+
if (typeof part === 'string')
|
|
209
|
+
return part;
|
|
210
|
+
if (!part || typeof part !== 'object')
|
|
211
|
+
return '';
|
|
212
|
+
const record = part;
|
|
213
|
+
return readString(record.text) || readString(record.content);
|
|
214
|
+
}
|
|
215
|
+
function inputItemToText(item) {
|
|
216
|
+
if (typeof item === 'string')
|
|
217
|
+
return item;
|
|
218
|
+
if (!item || typeof item !== 'object')
|
|
219
|
+
return '';
|
|
220
|
+
const record = item;
|
|
221
|
+
if (typeof record.content === 'string')
|
|
222
|
+
return record.content;
|
|
223
|
+
if (Array.isArray(record.content)) {
|
|
224
|
+
return record.content.map(contentPartToText).filter(Boolean).join('\n');
|
|
225
|
+
}
|
|
226
|
+
return readString(record.text);
|
|
227
|
+
}
|
|
228
|
+
function extractInputText(params) {
|
|
229
|
+
if (!params)
|
|
230
|
+
return '';
|
|
231
|
+
if (typeof params.input === 'string')
|
|
232
|
+
return params.input.trim();
|
|
233
|
+
if (Array.isArray(params.input)) {
|
|
234
|
+
return params.input.map(inputItemToText).filter(Boolean).join('\n').trim();
|
|
235
|
+
}
|
|
236
|
+
if (typeof params.message === 'string')
|
|
237
|
+
return params.message.trim();
|
|
238
|
+
if (Array.isArray(params.messages)) {
|
|
239
|
+
return params.messages.map(inputItemToText).filter(Boolean).join('\n').trim();
|
|
240
|
+
}
|
|
241
|
+
return '';
|
|
242
|
+
}
|
|
243
|
+
const THREAD_READ_MESSAGE_TEXT_LIMIT = 8_000;
|
|
244
|
+
const THREAD_READ_PAYLOAD_TEXT_LIMIT = 2_000;
|
|
245
|
+
const THREAD_READ_ARRAY_LIMIT = 100;
|
|
246
|
+
const THREAD_READ_OBJECT_ENTRY_LIMIT = 100;
|
|
247
|
+
const THREAD_READ_DEPTH_LIMIT = 8;
|
|
248
|
+
const THREAD_READ_ATTACHMENT_LIMIT = 20;
|
|
249
|
+
function truncateThreadReadText(value, limit = THREAD_READ_MESSAGE_TEXT_LIMIT) {
|
|
250
|
+
if (value.length <= limit)
|
|
251
|
+
return value;
|
|
252
|
+
const omitted = value.length - limit;
|
|
253
|
+
return `${value.slice(0, limit)}\n\n[Truncated ${omitted} characters for chat history.]`;
|
|
254
|
+
}
|
|
255
|
+
function sanitizeThreadReadValue(value, depth = 0, textLimit = THREAD_READ_PAYLOAD_TEXT_LIMIT) {
|
|
256
|
+
if (typeof value === 'string')
|
|
257
|
+
return truncateThreadReadText(value, textLimit);
|
|
258
|
+
if (value == null || typeof value === 'number' || typeof value === 'boolean')
|
|
259
|
+
return value;
|
|
260
|
+
if (Array.isArray(value)) {
|
|
261
|
+
return value
|
|
262
|
+
.slice(0, THREAD_READ_ARRAY_LIMIT)
|
|
263
|
+
.map((entry) => sanitizeThreadReadValue(entry, depth + 1, textLimit));
|
|
264
|
+
}
|
|
265
|
+
if (typeof value !== 'object')
|
|
266
|
+
return undefined;
|
|
267
|
+
if (depth >= THREAD_READ_DEPTH_LIMIT)
|
|
268
|
+
return '[Omitted nested data for chat history.]';
|
|
269
|
+
const record = value;
|
|
270
|
+
const compact = {};
|
|
271
|
+
for (const [key, entry] of Object.entries(record).slice(0, THREAD_READ_OBJECT_ENTRY_LIMIT)) {
|
|
272
|
+
const normalizedKey = key.trim().toLowerCase();
|
|
273
|
+
if (normalizedKey === 'metadata' ||
|
|
274
|
+
normalizedKey === 'base64' ||
|
|
275
|
+
normalizedKey === 'binary' ||
|
|
276
|
+
normalizedKey === 'bytes') {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const compactEntry = sanitizeThreadReadValue(entry, depth + 1, textLimit);
|
|
280
|
+
if (compactEntry !== undefined)
|
|
281
|
+
compact[key] = compactEntry;
|
|
282
|
+
}
|
|
283
|
+
return compact;
|
|
284
|
+
}
|
|
285
|
+
function sanitizeThreadReadAttachments(attachments) {
|
|
286
|
+
if (!attachments?.length)
|
|
287
|
+
return undefined;
|
|
288
|
+
const compact = attachments.slice(0, THREAD_READ_ATTACHMENT_LIMIT).map((attachment) => {
|
|
289
|
+
const next = { type: attachment.type };
|
|
290
|
+
if (attachment.url)
|
|
291
|
+
next.url = truncateThreadReadText(attachment.url, THREAD_READ_PAYLOAD_TEXT_LIMIT);
|
|
292
|
+
if (attachment.mime_type)
|
|
293
|
+
next.mime_type = truncateThreadReadText(attachment.mime_type, THREAD_READ_PAYLOAD_TEXT_LIMIT);
|
|
294
|
+
if (attachment.filename)
|
|
295
|
+
next.filename = truncateThreadReadText(attachment.filename, THREAD_READ_PAYLOAD_TEXT_LIMIT);
|
|
296
|
+
if (typeof attachment.size === 'number')
|
|
297
|
+
next.size = attachment.size;
|
|
298
|
+
return next;
|
|
299
|
+
});
|
|
300
|
+
return compact.length > 0 ? compact : undefined;
|
|
301
|
+
}
|
|
302
|
+
function sanitizeThreadReadMessage(message) {
|
|
303
|
+
const { metadata: _metadata, attachments, content, ...rest } = message;
|
|
304
|
+
const compactAttachments = sanitizeThreadReadAttachments(attachments);
|
|
305
|
+
return {
|
|
306
|
+
...rest,
|
|
307
|
+
content: truncateThreadReadText(content),
|
|
308
|
+
...(compactAttachments ? { attachments: compactAttachments } : {}),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function sanitizeProjectedThreadMessage(message) {
|
|
312
|
+
return sanitizeThreadReadMessage(message);
|
|
313
|
+
}
|
|
314
|
+
function sanitizeThreadReadEvent(event) {
|
|
315
|
+
return {
|
|
316
|
+
...event,
|
|
317
|
+
chunk: sanitizeThreadReadValue(event.chunk),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function messagesToItems(messages) {
|
|
321
|
+
return messages.map((message) => ({
|
|
322
|
+
id: message.id,
|
|
323
|
+
type: 'message',
|
|
324
|
+
role: message.role === 'bot' ? 'assistant' : message.role,
|
|
325
|
+
content: message.content,
|
|
326
|
+
createdAt: message.timestamp,
|
|
327
|
+
supen: {
|
|
328
|
+
taskId: message.task_id,
|
|
329
|
+
},
|
|
330
|
+
}));
|
|
331
|
+
}
|
|
332
|
+
function projectedMessagesToItems(messages) {
|
|
333
|
+
return messages.map((message) => ({
|
|
334
|
+
id: message.id,
|
|
335
|
+
type: 'message',
|
|
336
|
+
role: message.role === 'bot' ? 'assistant' : message.role,
|
|
337
|
+
content: message.content,
|
|
338
|
+
createdAt: message.timestamp,
|
|
339
|
+
supen: {
|
|
340
|
+
taskId: message.task_id,
|
|
341
|
+
},
|
|
342
|
+
}));
|
|
343
|
+
}
|
|
344
|
+
function runtimeStateForThread(threadId, session) {
|
|
345
|
+
const projection = projectThreadRuntimeState(threadId);
|
|
346
|
+
if (session &&
|
|
347
|
+
(session.channel === 'automation' || session.source_ref?.startsWith('automation:')) &&
|
|
348
|
+
session.status !== 'running' &&
|
|
349
|
+
projection.runtime.status === 'running' &&
|
|
350
|
+
projection.runtime.pending_approvals.length === 0) {
|
|
351
|
+
return {
|
|
352
|
+
...projection,
|
|
353
|
+
runtime: {
|
|
354
|
+
...projection.runtime,
|
|
355
|
+
status: session.status === 'error' ? 'failed' : 'idle',
|
|
356
|
+
updated_at: session.updated_at || projection.runtime.updated_at,
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
return projection;
|
|
361
|
+
}
|
|
362
|
+
function resolveThreadSession(agentId, threadId) {
|
|
363
|
+
if (agentId) {
|
|
364
|
+
const session = getSessionForAgent(agentId, threadId);
|
|
365
|
+
if (session)
|
|
366
|
+
return session;
|
|
367
|
+
}
|
|
368
|
+
return getAllSessions().find((candidate) => candidate.session_id === threadId) ?? null;
|
|
369
|
+
}
|
|
370
|
+
function runtimeStateSummary(projection) {
|
|
371
|
+
return {
|
|
372
|
+
event_log_head: projection.event_log_head,
|
|
373
|
+
projection_version: projection.projection_version,
|
|
374
|
+
event_log: projection.event_log,
|
|
375
|
+
runtime: projection.runtime,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function compactRuntimeStateSummary(projection) {
|
|
379
|
+
return sanitizeThreadReadValue(runtimeStateSummary(projection));
|
|
380
|
+
}
|
|
381
|
+
function compactCodexRuntimeStateSummary(runtimeState) {
|
|
382
|
+
const summary = {
|
|
383
|
+
event_log_head: runtimeState.event_log_head,
|
|
384
|
+
projection_version: runtimeState.projection_version,
|
|
385
|
+
event_log: runtimeState.event_log,
|
|
386
|
+
runtime: runtimeState.runtime,
|
|
387
|
+
};
|
|
388
|
+
return sanitizeThreadReadValue(summary);
|
|
389
|
+
}
|
|
390
|
+
function serializeCodexTaskThread(threadId, runtimeState, session) {
|
|
391
|
+
const runtimeStatus = runtimeState.runtime.status;
|
|
392
|
+
const pendingApprovals = Array.isArray(runtimeState.runtime.pending_approvals)
|
|
393
|
+
? runtimeState.runtime.pending_approvals
|
|
394
|
+
: [];
|
|
395
|
+
return {
|
|
396
|
+
id: threadId,
|
|
397
|
+
taskId: threadId,
|
|
398
|
+
agentId: 'automation-task',
|
|
399
|
+
status: runtimeStatus === 'running' || runtimeStatus === 'blocked' || runtimeStatus === 'failed'
|
|
400
|
+
? runtimeStatus
|
|
401
|
+
: 'idle',
|
|
402
|
+
pendingApproval: pendingApprovals.length > 0,
|
|
403
|
+
title: session?.title || threadId,
|
|
404
|
+
updatedAt: runtimeState.runtime.updated_at,
|
|
405
|
+
workspaceFolder: session?.task_workspace_folder || undefined,
|
|
406
|
+
supen: {
|
|
407
|
+
channel: 'automation',
|
|
408
|
+
sourceRef: `codex:${threadId}`,
|
|
409
|
+
},
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
async function handleRpcRequest(request, context) {
|
|
413
|
+
const id = request.id ?? null;
|
|
414
|
+
const method = readString(request.method);
|
|
415
|
+
const params = request.params && typeof request.params === 'object' && !Array.isArray(request.params)
|
|
416
|
+
? request.params
|
|
417
|
+
: {};
|
|
418
|
+
if (request.jsonrpc && request.jsonrpc !== '2.0') {
|
|
419
|
+
return rpcError(id, -32600, 'Invalid JSON-RPC version');
|
|
420
|
+
}
|
|
421
|
+
if (!method) {
|
|
422
|
+
return rpcError(id, -32600, 'JSON-RPC method is required');
|
|
423
|
+
}
|
|
424
|
+
if (method === 'initialize') {
|
|
425
|
+
return success(id, {
|
|
426
|
+
protocolVersion: 'supen-jsonrpc',
|
|
427
|
+
serverInfo: {
|
|
428
|
+
name: 'supen-rpc',
|
|
429
|
+
version: '0.1.0',
|
|
430
|
+
},
|
|
431
|
+
capabilities: {
|
|
432
|
+
threads: true,
|
|
433
|
+
turns: true,
|
|
434
|
+
longConnection: true,
|
|
435
|
+
transparentProxy: true,
|
|
436
|
+
supenExtensions: true,
|
|
437
|
+
},
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
if (method === 'taskWorkspace/listDirectories') {
|
|
441
|
+
try {
|
|
442
|
+
return success(id, listHostDirectories(normalizeTaskWorkspaceFolder(params.path)));
|
|
443
|
+
}
|
|
444
|
+
catch (error) {
|
|
445
|
+
return rpcError(id, -32602, error instanceof Error ? error.message : 'Failed to list directories.');
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if (method === 'thread/start') {
|
|
449
|
+
const agentId = optionalAgentIdFromParams(params);
|
|
450
|
+
if (!agentId)
|
|
451
|
+
return rpcError(id, -32602, 'agentId is required');
|
|
452
|
+
let threadId = threadIdFromParams(params);
|
|
453
|
+
if (!threadId) {
|
|
454
|
+
do {
|
|
455
|
+
threadId = `thread-${Date.now().toString(36)}-${randomUUID().slice(0, 8)}`;
|
|
456
|
+
} while (getSessionForAgent(agentId, threadId));
|
|
457
|
+
}
|
|
458
|
+
const environmentSnapshot = normalizeEnvironmentSnapshot(params.environmentSnapshot ?? params.environment_snapshot);
|
|
459
|
+
const taskWorkspaceFolder = normalizeTaskWorkspaceFolder(params.taskWorkspaceFolder ?? params.task_workspace_folder);
|
|
460
|
+
const taskWorkspaceError = validateTaskWorkspaceFolder(taskWorkspaceFolder);
|
|
461
|
+
if (taskWorkspaceError)
|
|
462
|
+
return rpcError(id, -32602, taskWorkspaceError);
|
|
463
|
+
const environmentId = readString(params.environmentId) ||
|
|
464
|
+
readString(params.environment_id) ||
|
|
465
|
+
environmentSnapshot.id ||
|
|
466
|
+
'default';
|
|
467
|
+
const session = ensureSession({
|
|
468
|
+
agent_id: agentId,
|
|
469
|
+
session_id: threadId,
|
|
470
|
+
channel: 'http',
|
|
471
|
+
agent_name: agentId,
|
|
472
|
+
source_ref: buildHttpSessionId(agentId, threadId),
|
|
473
|
+
knowledge_id: readString(params.knowledgeId) || readString(params.knowledge_id) || undefined,
|
|
474
|
+
knowledge_name: readString(params.knowledgeName) || readString(params.knowledge_name) || undefined,
|
|
475
|
+
environment_id: environmentId,
|
|
476
|
+
environment_snapshot: environmentSnapshot,
|
|
477
|
+
task_workspace_folder: taskWorkspaceFolder,
|
|
478
|
+
title: readString(params.title) || undefined,
|
|
479
|
+
});
|
|
480
|
+
recordSessionControlCommand({
|
|
481
|
+
agentId,
|
|
482
|
+
sessionId: threadId,
|
|
483
|
+
surface: context.surface || 'web',
|
|
484
|
+
commandType: 'session.start',
|
|
485
|
+
method,
|
|
486
|
+
actor: actorFromContext(context.adminContext),
|
|
487
|
+
status: 'completed',
|
|
488
|
+
params,
|
|
489
|
+
payload: {
|
|
490
|
+
requested_thread_id: threadId,
|
|
491
|
+
title: readString(params.title) || null,
|
|
492
|
+
},
|
|
493
|
+
});
|
|
494
|
+
return success(id, { thread: serializeThread(session) });
|
|
495
|
+
}
|
|
496
|
+
if (method === 'thread/resume') {
|
|
497
|
+
const agentId = optionalAgentIdFromParams(params);
|
|
498
|
+
const threadId = threadIdFromParams(params);
|
|
499
|
+
const session = threadId ? resolveThreadSession(agentId, threadId) : null;
|
|
500
|
+
if (!session)
|
|
501
|
+
return rpcError(id, -32004, 'Thread not found', { agentId, threadId });
|
|
502
|
+
recordSessionControlCommand({
|
|
503
|
+
agentId: session.agent_id,
|
|
504
|
+
sessionId: threadId,
|
|
505
|
+
surface: context.surface || 'web',
|
|
506
|
+
commandType: 'session.resume',
|
|
507
|
+
method,
|
|
508
|
+
actor: actorFromContext(context.adminContext),
|
|
509
|
+
status: 'completed',
|
|
510
|
+
params,
|
|
511
|
+
payload: {},
|
|
512
|
+
});
|
|
513
|
+
return success(id, { thread: serializeThread(session) });
|
|
514
|
+
}
|
|
515
|
+
if (method === 'thread/list') {
|
|
516
|
+
const agentId = optionalAgentIdFromParams(params);
|
|
517
|
+
if (!agentId)
|
|
518
|
+
return rpcError(id, -32602, 'agentId is required');
|
|
519
|
+
return success(id, {
|
|
520
|
+
threads: getSessionsForAgent(agentId).map(serializeThread),
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
if (method === 'thread/read') {
|
|
524
|
+
const agentId = optionalAgentIdFromParams(params);
|
|
525
|
+
const threadId = threadIdFromParams(params);
|
|
526
|
+
if (!threadId)
|
|
527
|
+
return rpcError(id, -32004, 'Thread not found', { agentId, threadId });
|
|
528
|
+
const rawLimit = Number(params.limit);
|
|
529
|
+
const limit = Number.isFinite(rawLimit) && rawLimit > 0 ? Math.min(Math.floor(rawLimit), 500) : 100;
|
|
530
|
+
const rawEventLimit = Number(params.eventLimit ?? params.event_limit);
|
|
531
|
+
const eventLimit = Number.isFinite(rawEventLimit) && rawEventLimit > 0
|
|
532
|
+
? Math.min(Math.floor(rawEventLimit), 500)
|
|
533
|
+
: limit;
|
|
534
|
+
const includeEvents = params.includeEvents !== false && params.include_events !== false;
|
|
535
|
+
const controlLog = listControlLogEntries(threadId, limit);
|
|
536
|
+
const taskSession = resolveThreadSession(agentId, threadId);
|
|
537
|
+
const codexThreadId = taskSession && typeof taskSession.sdk_session_id === 'string' && taskSession.sdk_session_id.trim()
|
|
538
|
+
? taskSession.sdk_session_id.trim()
|
|
539
|
+
: threadId;
|
|
540
|
+
const codexHistory = readCodexThreadHistory(codexThreadId, limit, {
|
|
541
|
+
eventLogThreadId: threadId,
|
|
542
|
+
});
|
|
543
|
+
if (codexHistory) {
|
|
544
|
+
const history = codexHistory;
|
|
545
|
+
const responseMessages = history.messages
|
|
546
|
+
.slice(-limit)
|
|
547
|
+
.map((message) => sanitizeProjectedThreadMessage({ ...message, task_id: threadId }));
|
|
548
|
+
const runtimeState = history.runtimeState;
|
|
549
|
+
const responseEvents = includeEvents
|
|
550
|
+
? history.events.slice(-eventLimit).map(sanitizeThreadReadEvent)
|
|
551
|
+
: [];
|
|
552
|
+
const responseRuntimeState = {
|
|
553
|
+
...runtimeState,
|
|
554
|
+
runtime: sanitizeThreadReadValue(runtimeState.runtime),
|
|
555
|
+
messages: responseMessages,
|
|
556
|
+
events: responseEvents,
|
|
557
|
+
};
|
|
558
|
+
return success(id, {
|
|
559
|
+
thread: serializeCodexTaskThread(threadId, runtimeState, {
|
|
560
|
+
title: history.session?.title || taskSession?.title,
|
|
561
|
+
task_workspace_folder: history.session?.task_workspace_folder || taskSession?.task_workspace_folder,
|
|
562
|
+
}),
|
|
563
|
+
messages: responseMessages,
|
|
564
|
+
events: responseEvents,
|
|
565
|
+
goal_context: history.goal_context,
|
|
566
|
+
control_log: controlLog,
|
|
567
|
+
items: messagesToItems(responseMessages),
|
|
568
|
+
runtimeState: compactCodexRuntimeStateSummary(runtimeState),
|
|
569
|
+
supen: {
|
|
570
|
+
events: responseEvents,
|
|
571
|
+
controlLog,
|
|
572
|
+
runtimeState: responseRuntimeState,
|
|
573
|
+
},
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
const session = taskSession;
|
|
577
|
+
if (!session)
|
|
578
|
+
return rpcError(id, -32004, 'Thread not found', { agentId, threadId });
|
|
579
|
+
const runtimeState = runtimeStateForThread(threadId, session);
|
|
580
|
+
const responseMessages = runtimeState.messages.slice(-limit).map(sanitizeProjectedThreadMessage);
|
|
581
|
+
const responseEvents = includeEvents
|
|
582
|
+
? runtimeState.events.slice(-eventLimit).map(sanitizeThreadReadEvent)
|
|
583
|
+
: [];
|
|
584
|
+
const responseRuntimeState = {
|
|
585
|
+
...runtimeState,
|
|
586
|
+
runtime: sanitizeThreadReadValue(runtimeState.runtime),
|
|
587
|
+
messages: responseMessages,
|
|
588
|
+
events: responseEvents,
|
|
589
|
+
};
|
|
590
|
+
return success(id, {
|
|
591
|
+
thread: serializeThread(session),
|
|
592
|
+
session,
|
|
593
|
+
messages: responseMessages,
|
|
594
|
+
events: responseEvents,
|
|
595
|
+
control_log: controlLog,
|
|
596
|
+
items: projectedMessagesToItems(responseMessages),
|
|
597
|
+
runtimeState: compactRuntimeStateSummary(runtimeState),
|
|
598
|
+
supen: {
|
|
599
|
+
events: responseEvents,
|
|
600
|
+
controlLog,
|
|
601
|
+
runtimeState: responseRuntimeState,
|
|
602
|
+
},
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
if (method === 'thread/approval/respond') {
|
|
606
|
+
const approvalId = readString(params.approvalId) || readString(params.approval_id);
|
|
607
|
+
if (!approvalId)
|
|
608
|
+
return rpcError(id, -32602, 'approvalId is required');
|
|
609
|
+
try {
|
|
610
|
+
const approval = respondAppServerApproval({
|
|
611
|
+
approvalId,
|
|
612
|
+
approved: params.approved === true,
|
|
613
|
+
});
|
|
614
|
+
const threadId = threadIdFromParams(params);
|
|
615
|
+
const requestedAgentId = optionalAgentIdFromParams(params);
|
|
616
|
+
const session = threadId ? resolveThreadSession(requestedAgentId, threadId) : null;
|
|
617
|
+
const agentId = session?.agent_id || requestedAgentId;
|
|
618
|
+
if (agentId && threadId) {
|
|
619
|
+
recordSessionControlCommand({
|
|
620
|
+
agentId,
|
|
621
|
+
sessionId: threadId,
|
|
622
|
+
surface: context.surface || 'web',
|
|
623
|
+
commandType: 'approval.respond',
|
|
624
|
+
method,
|
|
625
|
+
actor: actorFromContext(context.adminContext),
|
|
626
|
+
status: 'completed',
|
|
627
|
+
params,
|
|
628
|
+
payload: {
|
|
629
|
+
approval_id: approvalId,
|
|
630
|
+
approved: params.approved === true,
|
|
631
|
+
tool_call_id: approval.toolCallId,
|
|
632
|
+
tool_name: approval.toolName,
|
|
633
|
+
},
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
return success(id, {
|
|
637
|
+
ok: true,
|
|
638
|
+
approvalId,
|
|
639
|
+
approved: params.approved === true,
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
catch (error) {
|
|
643
|
+
return rpcError(id, -32004, error instanceof Error ? error.message : 'Approval request not found');
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
if (method === 'turn/start' || method === 'turn/steer') {
|
|
647
|
+
const agentId = optionalAgentIdFromParams(params);
|
|
648
|
+
if (!agentId)
|
|
649
|
+
return rpcError(id, -32602, 'agentId is required');
|
|
650
|
+
const threadId = threadIdFromParams(params);
|
|
651
|
+
if (!threadId)
|
|
652
|
+
return rpcError(id, -32602, 'threadId is required');
|
|
653
|
+
const text = extractInputText(params);
|
|
654
|
+
if (!text)
|
|
655
|
+
return rpcError(id, -32602, 'turn input is required');
|
|
656
|
+
const model = readString(params.model);
|
|
657
|
+
const effort = readRuntimeEffort(params.effort ?? params.reasoningEffort ?? params.reasoning_effort);
|
|
658
|
+
const permissionMode = readRuntimePermissionMode(params.permissionMode ?? params.permission_mode);
|
|
659
|
+
const speedMode = readString(params.speedMode ?? params.speed_mode);
|
|
660
|
+
const runtimeOptions = {
|
|
661
|
+
...(model ? { model } : {}),
|
|
662
|
+
...(effort ? { effort } : {}),
|
|
663
|
+
...(permissionMode ? { permissionMode } : {}),
|
|
664
|
+
...(speedMode === 'standard' || speedMode === 'fast' ? { speedMode } : {}),
|
|
665
|
+
};
|
|
666
|
+
ensureSession({
|
|
667
|
+
agent_id: agentId,
|
|
668
|
+
session_id: threadId,
|
|
669
|
+
channel: 'http',
|
|
670
|
+
agent_name: agentId,
|
|
671
|
+
source_ref: buildHttpSessionId(agentId, threadId),
|
|
672
|
+
});
|
|
673
|
+
const turnId = readString(params.turnId) || readString(params.turn_id) || randomUUID();
|
|
674
|
+
const actor = actorFromContext(context.adminContext);
|
|
675
|
+
const msg = {
|
|
676
|
+
id: `supen-rpc-${turnId}`,
|
|
677
|
+
chat_jid: buildHttpSessionId(agentId, threadId),
|
|
678
|
+
sender: actor,
|
|
679
|
+
sender_name: actor,
|
|
680
|
+
content: text,
|
|
681
|
+
timestamp: new Date().toISOString(),
|
|
682
|
+
is_from_me: false,
|
|
683
|
+
agent_id: agentId,
|
|
684
|
+
session_id: threadId,
|
|
685
|
+
task_id: turnId,
|
|
686
|
+
...(model ? { model } : {}),
|
|
687
|
+
metadata: {
|
|
688
|
+
source: 'rpc-turn',
|
|
689
|
+
runtime_options: runtimeOptions,
|
|
690
|
+
},
|
|
691
|
+
};
|
|
692
|
+
context.onMessage(msg.chat_jid, msg);
|
|
693
|
+
recordSessionControlCommand({
|
|
694
|
+
agentId,
|
|
695
|
+
sessionId: threadId,
|
|
696
|
+
turnId,
|
|
697
|
+
surface: context.surface || 'web',
|
|
698
|
+
commandType: 'session.instruct',
|
|
699
|
+
method,
|
|
700
|
+
actor,
|
|
701
|
+
status: 'dispatched',
|
|
702
|
+
params,
|
|
703
|
+
payload: {
|
|
704
|
+
message_excerpt: text.slice(0, 240),
|
|
705
|
+
runtime_options: runtimeOptions,
|
|
706
|
+
},
|
|
707
|
+
});
|
|
708
|
+
return success(id, {
|
|
709
|
+
turn: {
|
|
710
|
+
id: turnId,
|
|
711
|
+
threadId,
|
|
712
|
+
status: 'accepted',
|
|
713
|
+
},
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
if (method === 'turn/interrupt') {
|
|
717
|
+
const requestedAgentId = optionalAgentIdFromParams(params);
|
|
718
|
+
const threadId = threadIdFromParams(params);
|
|
719
|
+
if (!threadId)
|
|
720
|
+
return rpcError(id, -32602, 'threadId is required');
|
|
721
|
+
if (!context.onSessionStop)
|
|
722
|
+
return rpcError(id, -32001, 'Turn interruption is not supported');
|
|
723
|
+
const session = resolveThreadSession(requestedAgentId, threadId);
|
|
724
|
+
const agentId = session?.agent_id || requestedAgentId;
|
|
725
|
+
if (!agentId)
|
|
726
|
+
return rpcError(id, -32004, 'Thread not found', { agentId: requestedAgentId, threadId });
|
|
727
|
+
const actor = actorFromContext(context.adminContext);
|
|
728
|
+
const result = context.onSessionStop(agentId, threadId, actor);
|
|
729
|
+
recordSessionControlCommand({
|
|
730
|
+
agentId,
|
|
731
|
+
sessionId: threadId,
|
|
732
|
+
surface: context.surface || 'web',
|
|
733
|
+
commandType: 'session.interrupt',
|
|
734
|
+
method,
|
|
735
|
+
actor,
|
|
736
|
+
status: result.ok || result.code === 'session_not_running' ? 'completed' : 'failed',
|
|
737
|
+
params,
|
|
738
|
+
payload: {
|
|
739
|
+
code: result.code,
|
|
740
|
+
message: result.message,
|
|
741
|
+
},
|
|
742
|
+
});
|
|
743
|
+
if (!result.ok && result.code !== 'session_not_running') {
|
|
744
|
+
return rpcError(id, -32002, result.message, { code: result.code });
|
|
745
|
+
}
|
|
746
|
+
return success(id, { ok: true, ...result });
|
|
747
|
+
}
|
|
748
|
+
return rpcError(id, -32601, `Method not found: ${method}`);
|
|
749
|
+
}
|
|
750
|
+
export async function executeSupenRpc(request, context) {
|
|
751
|
+
if (!request || typeof request !== 'object' || Array.isArray(request)) {
|
|
752
|
+
return rpcError(null, -32600, 'Invalid JSON-RPC request');
|
|
753
|
+
}
|
|
754
|
+
const rpcRequest = request;
|
|
755
|
+
try {
|
|
756
|
+
return await handleRpcRequest(rpcRequest, context);
|
|
757
|
+
}
|
|
758
|
+
catch (error) {
|
|
759
|
+
return rpcError(rpcRequest.id ?? null, -32603, error instanceof Error ? error.message : 'Internal error');
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
export async function handleRpcRoutes(req, res, pathname, method, adminContext, onMessage, onSessionStop) {
|
|
763
|
+
if (pathname !== '/api/rpc' && pathname !== '/api/computer/rpc') {
|
|
764
|
+
return false;
|
|
765
|
+
}
|
|
766
|
+
if (method !== 'POST') {
|
|
767
|
+
writeJson(res, 405, rpcError(null, -32600, 'JSON-RPC endpoint requires POST'));
|
|
768
|
+
return true;
|
|
769
|
+
}
|
|
770
|
+
const body = await readJsonBody(req);
|
|
771
|
+
if (Array.isArray(body)) {
|
|
772
|
+
const batch = await Promise.all(body.map((entry) => executeSupenRpc(entry, {
|
|
773
|
+
adminContext,
|
|
774
|
+
onMessage,
|
|
775
|
+
onSessionStop,
|
|
776
|
+
surface: 'web',
|
|
777
|
+
})));
|
|
778
|
+
writeJson(res, 200, batch);
|
|
779
|
+
return true;
|
|
780
|
+
}
|
|
781
|
+
const response = await executeSupenRpc(body, {
|
|
782
|
+
adminContext,
|
|
783
|
+
onMessage,
|
|
784
|
+
onSessionStop,
|
|
785
|
+
surface: 'web',
|
|
786
|
+
});
|
|
787
|
+
writeJson(res, 200, response);
|
|
788
|
+
return true;
|
|
789
|
+
}
|
|
790
|
+
//# sourceMappingURL=rpc.js.map
|