@cortex-agent/server 2026.10.15 → 2026.10.25
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 +81 -51
- package/defaults/board/board.css +140 -62
- package/defaults/board/scaffold.html +36 -13
- package/defaults/config/environments/creative.json +0 -1
- package/defaults/config/environments/main.json +1 -2
- package/defaults/context/projects/AGENTS.md +1 -1
- package/defaults/gitignore +3 -3
- package/defaults/hooks/new-session-hook.mjs +1 -1
- package/defaults/hooks/status-md-guard.mjs +6 -6
- package/defaults/plugins/cortex-board/skills/board/SKILL.md +30 -22
- package/defaults/plugins/cortex-system/plugin.json +2 -2
- package/defaults/plugins/cortex-system/skills/browser/SKILL.md +56 -0
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +16 -9
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +2 -2
- package/defaults/rules/agents-md.md +1 -1
- package/defaults/rules/issues-md.md +1 -1
- package/defaults/rules/meta-conventions.md +3 -3
- package/defaults/rules/mission-md.md +1 -1
- package/defaults/rules/status-md.md +1 -1
- package/dist/agent-adapter/claude/adapter.d.ts +2 -5
- package/dist/agent-adapter/claude/adapter.js +6 -5
- package/dist/agent-adapter/claude/assistant-blocks.d.ts +5 -0
- package/dist/agent-adapter/claude/assistant-blocks.js +61 -0
- package/dist/agent-adapter/claude/bg-task-tracker.d.ts +3 -1
- package/dist/agent-adapter/claude/bg-task-tracker.js +6 -2
- package/dist/agent-adapter/claude/cache-refresh.d.ts +58 -0
- package/dist/agent-adapter/claude/cache-refresh.js +145 -0
- package/dist/agent-adapter/claude/cache-touch.d.ts +12 -0
- package/dist/agent-adapter/claude/cache-touch.js +75 -0
- package/dist/agent-adapter/claude/event-parser.d.ts +8 -3
- package/dist/agent-adapter/claude/event-parser.js +33 -17
- package/dist/agent-adapter/claude/event-translator.d.ts +2 -0
- package/dist/agent-adapter/claude/event-translator.js +2 -0
- package/dist/agent-adapter/claude/mcp-config.js +11 -0
- package/dist/agent-adapter/claude/session-options.d.ts +6 -13
- package/dist/agent-adapter/claude/session-options.js +2 -13
- package/dist/agent-adapter/claude/spawn-args.d.ts +4 -21
- package/dist/agent-adapter/claude/spawn-args.js +17 -24
- package/dist/agent-adapter/claude/transcript-clear.d.ts +42 -0
- package/dist/agent-adapter/claude/transcript-clear.js +217 -0
- package/dist/agent-adapter/claude/turn-machine.d.ts +5 -3
- package/dist/agent-adapter/claude/turn-machine.js +29 -73
- package/dist/agent-adapter/claude/window-warmup.d.ts +13 -0
- package/dist/agent-adapter/claude/window-warmup.js +38 -0
- package/dist/agent-adapter/continuation-phase.d.ts +6 -3
- package/dist/agent-adapter/continuation-phase.js +11 -3
- package/dist/agent-adapter/normalize/event-types.d.ts +8 -0
- package/dist/agent-adapter/pi/adapter.d.ts +0 -1
- package/dist/agent-adapter/pi/adapter.js +5 -13
- package/dist/agent-adapter/pi/event-parser.d.ts +1 -1
- package/dist/agent-adapter/pi/event-parser.js +43 -27
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +1 -1
- package/dist/agent-adapter/pi/pi-session.d.ts +2 -0
- package/dist/agent-adapter/pi/pi-session.js +15 -0
- package/dist/agent-adapter/pi/providers-config.d.ts +2 -2
- package/dist/agent-adapter/pi/providers-config.js +1 -1
- package/dist/agent-adapter/pi/quota-sink.d.ts +3 -3
- package/dist/agent-adapter/pi/quota-sink.js +3 -3
- package/dist/agent-adapter/pi/runtime.js +6 -1
- package/dist/agent-adapter/pi/session-options.d.ts +9 -13
- package/dist/agent-adapter/pi/session-options.js +12 -25
- package/dist/agent-adapter/run-events.d.ts +15 -10
- package/dist/agent-adapter/run-events.js +2 -0
- package/dist/agent-adapter/types.d.ts +14 -6
- package/dist/build-info.json +1 -0
- package/dist/client-bundle/client.mjs +10 -5
- package/dist/client-bundle/manifest.json +3 -3
- package/dist/core/claude-credentials.d.ts +6 -0
- package/dist/core/claude-credentials.js +11 -0
- package/dist/core/codex-quota.d.ts +1 -1
- package/dist/core/codex-quota.js +1 -1
- package/dist/core/gateway-generator.d.ts +26 -11
- package/dist/core/gateway-generator.js +73 -62
- package/dist/core/hook-bus.d.ts +1 -1
- package/dist/core/hook-bus.js +1 -8
- package/dist/core/locales/en.d.ts +52 -77
- package/dist/core/locales/slices/commands.d.ts +26 -31
- package/dist/core/locales/slices/commands.js +54 -64
- package/dist/core/locales/slices/init.d.ts +9 -19
- package/dist/core/locales/slices/init.js +19 -53
- package/dist/core/locales/slices/interactions.d.ts +3 -3
- package/dist/core/locales/slices/interactions.js +6 -6
- package/dist/core/locales/slices/notices.d.ts +1 -3
- package/dist/core/locales/slices/notices.js +2 -6
- package/dist/core/locales/slices/scheduling.d.ts +9 -9
- package/dist/core/locales/slices/scheduling.js +18 -18
- package/dist/core/locales/slices/status.d.ts +0 -4
- package/dist/core/locales/slices/status.js +0 -8
- package/dist/core/locales/slices/tui.d.ts +0 -1
- package/dist/core/locales/slices/tui.js +0 -2
- package/dist/core/locales/slices/uimsg.d.ts +4 -7
- package/dist/core/locales/slices/uimsg.js +9 -15
- package/dist/core/log.d.ts +3 -0
- package/dist/core/log.js +18 -1
- package/dist/core/models-generator.d.ts +29 -0
- package/dist/core/models-generator.js +82 -0
- package/dist/core/paths.d.ts +1 -1
- package/dist/core/paths.js +1 -1
- package/dist/core/settings-spec.d.ts +30 -0
- package/dist/core/settings-spec.js +38 -0
- package/dist/core/status-format.d.ts +3 -2
- package/dist/core/status-format.js +2 -2
- package/dist/core/types/agent-types.d.ts +3 -1
- package/dist/core/types/environment-types.d.ts +1 -8
- package/dist/domain/agents/agent-state.d.ts +11 -56
- package/dist/domain/agents/agent-state.js +48 -115
- package/dist/domain/agents/agent-switch.d.ts +2 -24
- package/dist/domain/agents/agent-switch.js +9 -72
- package/dist/domain/agents/config.d.ts +11 -61
- package/dist/domain/agents/config.js +47 -154
- package/dist/domain/agents/engine-selection.d.ts +21 -0
- package/dist/domain/agents/engine-selection.js +37 -0
- package/dist/domain/agents/environments/registry.js +4 -2
- package/dist/domain/agents/environments/resolve.js +0 -1
- package/dist/domain/agents/environments/schema.d.ts +3 -3
- package/dist/domain/agents/environments/schema.js +4 -4
- package/dist/domain/agents/index.d.ts +2 -1
- package/dist/domain/agents/index.js +3 -7
- package/dist/domain/agents/model-selection.d.ts +18 -70
- package/dist/domain/agents/model-selection.js +100 -150
- package/dist/domain/agents/models.d.ts +12 -0
- package/dist/domain/agents/models.js +94 -0
- package/dist/domain/agents/subagent/registry.d.ts +2 -0
- package/dist/domain/agents/subagent/registry.js +8 -0
- package/dist/domain/agents/subagent/runner.d.ts +5 -5
- package/dist/domain/agents/subagent/runner.js +12 -35
- package/dist/domain/auth/auth-status.d.ts +4 -4
- package/dist/domain/auth/auth-status.js +17 -28
- package/dist/domain/auth/auth-watch.js +48 -18
- package/dist/domain/auth/gateway-sync.d.ts +6 -26
- package/dist/domain/auth/gateway-sync.js +31 -75
- package/dist/domain/benchmark/identity.d.ts +3 -5
- package/dist/domain/benchmark/identity.js +0 -1
- package/dist/domain/benchmark/production-attempt-identity.d.ts +6 -5
- package/dist/domain/benchmark/production-attempt-identity.js +32 -35
- package/dist/domain/benchmark/session-evidence.d.ts +2 -1
- package/dist/domain/benchmark/session-evidence.js +8 -1
- package/dist/domain/browser/broker.d.ts +99 -0
- package/dist/domain/browser/broker.js +487 -0
- package/dist/domain/costs/claude-account.js +21 -0
- package/dist/domain/costs/rate-limit-throttle.js +3 -1
- package/dist/domain/costs/reset-account.d.ts +2 -0
- package/dist/domain/costs/usage-service.d.ts +1 -1
- package/dist/domain/costs/usage-service.js +20 -7
- package/dist/domain/mcp/tools/context.d.ts +5 -7
- package/dist/domain/mcp/tools/context.js +17 -4
- package/dist/domain/mcp/tools/subagent.js +1 -1
- package/dist/domain/mcp/tools/ui-file.js +1 -1
- package/dist/domain/monitor/event-loop-monitor.d.ts +2 -0
- package/dist/domain/monitor/event-loop-monitor.js +5 -1
- package/dist/domain/pi-providers/custom-provider-model.d.ts +1 -1
- package/dist/domain/pi-providers/custom-provider-model.js +1 -1
- package/dist/domain/plugins/authoring.d.ts +8 -1
- package/dist/domain/plugins/authoring.js +24 -9
- package/dist/domain/plugins/runtime-gc.d.ts +7 -0
- package/dist/domain/plugins/runtime-gc.js +52 -19
- package/dist/domain/plugins/runtime.js +2 -1
- package/dist/domain/remote/client-bootstrap.js +1 -1
- package/dist/domain/remote/client-manager.js +6 -1
- package/dist/domain/remote/device-browser.js +1 -1
- package/dist/domain/remote/device-chrome-commands.js +2 -0
- package/dist/domain/remote/device-port.js +2 -2
- package/dist/domain/runs/attempt.d.ts +3 -3
- package/dist/domain/runs/attempt.js +2 -3
- package/dist/domain/runs/builders.d.ts +4 -4
- package/dist/domain/runs/builders.js +4 -5
- package/dist/domain/runs/compact.d.ts +4 -17
- package/dist/domain/runs/compact.js +14 -56
- package/dist/domain/runs/config-resolver.d.ts +15 -83
- package/dist/domain/runs/config-resolver.js +24 -150
- package/dist/domain/runs/engine-spec.d.ts +8 -8
- package/dist/domain/runs/engine-spec.js +15 -31
- package/dist/domain/runs/events.d.ts +1 -1
- package/dist/domain/runs/fallback.d.ts +6 -38
- package/dist/domain/runs/fallback.js +10 -72
- package/dist/domain/runs/notices.d.ts +1 -11
- package/dist/domain/runs/notices.js +3 -30
- package/dist/domain/runs/request.d.ts +4 -3
- package/dist/domain/runs/retryable-errors.d.ts +0 -13
- package/dist/domain/runs/retryable-errors.js +3 -18
- package/dist/domain/runs/run.d.ts +12 -42
- package/dist/domain/runs/run.js +40 -147
- package/dist/domain/runs/service.d.ts +0 -9
- package/dist/domain/runs/service.js +33 -14
- package/dist/domain/runs/spec-loader.d.ts +1 -1
- package/dist/domain/runs/spend.d.ts +1 -1
- package/dist/domain/runs/spend.js +1 -1
- package/dist/domain/scheduling/builtin-job-controller.d.ts +3 -1
- package/dist/domain/scheduling/builtin-job-controller.js +5 -2
- package/dist/domain/scheduling/builtin-jobs.js +7 -0
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +3 -2
- package/dist/domain/scheduling/jobs/scheduled-task.js +25 -19
- package/dist/domain/scheduling/schedule-ops.d.ts +0 -1
- package/dist/domain/scheduling/schedule-ops.js +2 -5
- package/dist/domain/scheduling/schedule-selection.d.ts +3 -0
- package/dist/domain/scheduling/schedule-selection.js +16 -0
- package/dist/domain/scheduling/schedule-spec.d.ts +6 -5
- package/dist/domain/scheduling/schedule-spec.js +6 -6
- package/dist/domain/scheduling/scheduler.d.ts +3 -1
- package/dist/domain/scheduling/scheduler.js +36 -26
- package/dist/domain/sessions/session-hooks.d.ts +5 -4
- package/dist/domain/sessions/session-hooks.js +15 -33
- package/dist/domain/sessions/session-lifecycle.d.ts +19 -51
- package/dist/domain/sessions/session-lifecycle.js +34 -96
- package/dist/domain/system/doctor.d.ts +3 -3
- package/dist/domain/system/doctor.js +22 -26
- package/dist/domain/system/own-bin-path.d.ts +13 -0
- package/dist/domain/system/own-bin-path.js +36 -0
- package/dist/domain/system/server-update-check.js +2 -1
- package/dist/domain/system/terminal-cli/index.d.ts +58 -0
- package/dist/domain/system/terminal-cli/index.js +100 -0
- package/dist/domain/system/terminal-cli/posix-profiles.d.ts +23 -0
- package/dist/domain/system/terminal-cli/posix-profiles.js +74 -0
- package/dist/domain/system/terminal-cli/registrar.d.ts +12 -0
- package/dist/domain/system/terminal-cli/registrar.js +1 -0
- package/dist/domain/system/terminal-cli/shims.d.ts +27 -0
- package/dist/domain/system/terminal-cli/shims.js +108 -0
- package/dist/domain/system/terminal-cli/state.d.ts +7 -0
- package/dist/domain/system/terminal-cli/state.js +36 -0
- package/dist/domain/system/terminal-cli/windows-user-path.d.ts +13 -0
- package/dist/domain/system/terminal-cli/windows-user-path.js +67 -0
- package/dist/domain/telemetry/bus-collector.d.ts +3 -0
- package/dist/domain/telemetry/bus-collector.js +22 -0
- package/dist/domain/telemetry/child-exit.d.ts +11 -0
- package/dist/domain/telemetry/child-exit.js +36 -0
- package/dist/domain/telemetry/client-kind.d.ts +4 -0
- package/dist/domain/telemetry/client-kind.js +7 -0
- package/dist/domain/telemetry/crash-limits.d.ts +15 -0
- package/dist/domain/telemetry/crash-limits.js +50 -0
- package/dist/domain/telemetry/crash.d.ts +25 -0
- package/dist/domain/telemetry/crash.js +70 -0
- package/dist/domain/telemetry/daily-upload.d.ts +5 -0
- package/dist/domain/telemetry/daily-upload.js +20 -0
- package/dist/domain/telemetry/daily.d.ts +5 -0
- package/dist/domain/telemetry/daily.js +104 -0
- package/dist/domain/telemetry/endpoint.d.ts +7 -0
- package/dist/domain/telemetry/endpoint.js +40 -0
- package/dist/domain/telemetry/envelope.d.ts +6 -0
- package/dist/domain/telemetry/envelope.js +35 -0
- package/dist/domain/telemetry/error-digest.d.ts +7 -0
- package/dist/domain/telemetry/error-digest.js +43 -0
- package/dist/domain/telemetry/funnel.d.ts +6 -0
- package/dist/domain/telemetry/funnel.js +22 -0
- package/dist/domain/telemetry/gate.d.ts +19 -0
- package/dist/domain/telemetry/gate.js +67 -0
- package/dist/domain/telemetry/heartbeat.d.ts +17 -0
- package/dist/domain/telemetry/heartbeat.js +49 -0
- package/dist/domain/telemetry/info.d.ts +9 -0
- package/dist/domain/telemetry/info.js +12 -0
- package/dist/domain/telemetry/init-answer.d.ts +12 -0
- package/dist/domain/telemetry/init-answer.js +42 -0
- package/dist/domain/telemetry/install-id.d.ts +5 -0
- package/dist/domain/telemetry/install-id.js +42 -0
- package/dist/domain/telemetry/normalize.d.ts +33 -0
- package/dist/domain/telemetry/normalize.js +88 -0
- package/dist/domain/telemetry/outbox.d.ts +18 -0
- package/dist/domain/telemetry/outbox.js +93 -0
- package/dist/domain/telemetry/panic-group.d.ts +4 -0
- package/dist/domain/telemetry/panic-group.js +51 -0
- package/dist/domain/telemetry/paths.d.ts +7 -0
- package/dist/domain/telemetry/paths.js +11 -0
- package/dist/domain/telemetry/redact.d.ts +18 -0
- package/dist/domain/telemetry/redact.js +109 -0
- package/dist/domain/telemetry/rollup-types.d.ts +81 -0
- package/dist/domain/telemetry/rollup-types.js +31 -0
- package/dist/domain/telemetry/rollup.d.ts +16 -0
- package/dist/domain/telemetry/rollup.js +102 -0
- package/dist/domain/telemetry/schema.d.ts +931 -0
- package/dist/domain/telemetry/schema.js +275 -0
- package/dist/domain/telemetry/service.d.ts +34 -0
- package/dist/domain/telemetry/service.js +146 -0
- package/dist/domain/telemetry/state.d.ts +17 -0
- package/dist/domain/telemetry/state.js +29 -0
- package/dist/domain/telemetry/turns.d.ts +17 -0
- package/dist/domain/telemetry/turns.js +176 -0
- package/dist/domain/telemetry/upgrade.d.ts +14 -0
- package/dist/domain/telemetry/upgrade.js +87 -0
- package/dist/domain/telemetry/uploader.d.ts +21 -0
- package/dist/domain/telemetry/uploader.js +82 -0
- package/dist/domain/telemetry/usage.d.ts +25 -0
- package/dist/domain/telemetry/usage.js +153 -0
- package/dist/domain/telemetry/web-report.d.ts +8 -0
- package/dist/domain/telemetry/web-report.js +15 -0
- package/dist/domain/tui-session/tui-session-service.js +1 -1
- package/dist/domain/tui-session/types.d.ts +2 -2
- package/dist/domain/ui-service/app-router.d.ts +117 -95
- package/dist/domain/ui-service/app-router.js +17 -14
- package/dist/domain/ui-service/assistant-snapshots.js +2 -0
- package/dist/domain/ui-service/contract.parity.d.ts +19 -0
- package/dist/domain/ui-service/contract.parity.js +1 -0
- package/dist/domain/ui-service/inline-media-types.d.ts +18 -0
- package/dist/domain/ui-service/inline-media-types.js +1 -0
- package/dist/domain/ui-service/input-schemas.d.ts +120 -119
- package/dist/domain/ui-service/input-schemas.js +47 -85
- package/dist/domain/ui-service/mutate/approvals.d.ts +3 -2
- package/dist/domain/ui-service/mutate/approvals.js +3 -2
- package/dist/domain/ui-service/mutate/auth.d.ts +1 -1
- package/dist/domain/ui-service/mutate/auth.js +3 -2
- package/dist/domain/ui-service/mutate/config.d.ts +0 -8
- package/dist/domain/ui-service/mutate/config.js +0 -22
- package/dist/domain/ui-service/mutate/models.d.ts +13 -0
- package/dist/domain/ui-service/mutate/models.js +137 -0
- package/dist/domain/ui-service/mutate/plugin-packages.js +1 -1
- package/dist/domain/ui-service/mutate/resolve-media.d.ts +4 -0
- package/dist/domain/ui-service/mutate/resolve-media.js +17 -0
- package/dist/domain/ui-service/mutate/sessions.d.ts +2 -2
- package/dist/domain/ui-service/mutate/sessions.js +29 -126
- package/dist/domain/ui-service/mutate/telemetry.d.ts +5 -0
- package/dist/domain/ui-service/mutate/telemetry.js +6 -0
- package/dist/domain/ui-service/query/approvals.js +4 -3
- package/dist/domain/ui-service/query/config.js +22 -42
- package/dist/domain/ui-service/query/machine-probe.d.ts +1 -1
- package/dist/domain/ui-service/query/machine-probe.js +3 -2
- package/dist/domain/ui-service/query/models.d.ts +3 -0
- package/dist/domain/ui-service/query/models.js +49 -32
- package/dist/domain/ui-service/query/plugin-source.js +4 -3
- package/dist/domain/ui-service/query/schedules.js +1 -1
- package/dist/domain/ui-service/query/sessions.js +8 -13
- package/dist/domain/ui-service/query/telemetry.d.ts +3 -0
- package/dist/domain/ui-service/query/telemetry.js +4 -0
- package/dist/domain/ui-service/trpc.d.ts +8 -3
- package/dist/domain/ui-service/trpc.js +1 -1
- package/dist/domain/ui-service/types.d.ts +71 -179
- package/dist/domain/ui-service/ui-service.d.ts +56 -53
- package/dist/domain/ui-service/ui-service.js +27 -24
- package/dist/entry/app.js +62 -21
- package/dist/entry/browser-cli.d.ts +39 -0
- package/dist/entry/browser-cli.js +317 -0
- package/dist/entry/cli-help.d.ts +1 -0
- package/dist/entry/cli-help.js +64 -20
- package/dist/entry/cli.js +16 -14
- package/dist/entry/daemon.d.ts +1 -1
- package/dist/entry/daemon.js +88 -72
- package/dist/entry/init-auth.js +1 -1
- package/dist/entry/init.d.ts +10 -8
- package/dist/entry/init.js +138 -276
- package/dist/entry/path-cli.d.ts +4 -0
- package/dist/entry/path-cli.js +65 -0
- package/dist/entry/schedule-cli.js +13 -6
- package/dist/entry/shutdown.d.ts +1 -1
- package/dist/entry/shutdown.js +11 -1
- package/dist/entry/signal-cli.js +8 -11
- package/dist/entry/start-ui-http.js +48 -18
- package/dist/entry/telemetry-wiring.d.ts +12 -0
- package/dist/entry/telemetry-wiring.js +56 -0
- package/dist/entry/ui-cli.d.ts +0 -11
- package/dist/entry/ui-cli.js +42 -33
- package/dist/entry/ui-service-wiring.js +8 -10
- package/dist/events/event-types.d.ts +4 -6
- package/dist/orchestration/agent-runner.d.ts +2 -2
- package/dist/orchestration/agent-runner.js +10 -9
- package/dist/orchestration/benchmark-session-webhook.js +13 -1
- package/dist/orchestration/browser-webhook.d.ts +11 -0
- package/dist/orchestration/browser-webhook.js +28 -0
- package/dist/orchestration/cache-keep-warm.d.ts +77 -0
- package/dist/orchestration/cache-keep-warm.js +213 -0
- package/dist/orchestration/claude-window-warmup.d.ts +40 -0
- package/dist/orchestration/claude-window-warmup.js +126 -0
- package/dist/orchestration/conversation-request.d.ts +6 -10
- package/dist/orchestration/conversation-request.js +5 -23
- package/dist/orchestration/delta-coalescer.d.ts +4 -2
- package/dist/orchestration/delta-coalescer.js +5 -5
- package/dist/orchestration/edit-retry.js +9 -11
- package/dist/orchestration/inline-media-eager.d.ts +13 -0
- package/dist/orchestration/inline-media-eager.js +58 -0
- package/dist/orchestration/inline-media.d.ts +22 -0
- package/dist/orchestration/inline-media.js +151 -0
- package/dist/orchestration/interactions/ask-user-resume.js +3 -7
- package/dist/orchestration/interactions/interaction-handlers.js +6 -6
- package/dist/orchestration/mid-turn-inject.d.ts +2 -1
- package/dist/orchestration/mid-turn-inject.js +1 -1
- package/dist/orchestration/pending-injection-recovery.d.ts +2 -1
- package/dist/orchestration/pending-injection-recovery.js +1 -1
- package/dist/orchestration/routing/commands/index.js +4 -4
- package/dist/orchestration/routing/commands/mode.d.ts +5 -44
- package/dist/orchestration/routing/commands/mode.js +98 -272
- package/dist/orchestration/routing/commands/schedule.js +29 -18
- package/dist/orchestration/routing/commands/session.js +9 -9
- package/dist/orchestration/routing/commands/status.js +1 -1
- package/dist/orchestration/routing/commands/usage-format.js +3 -0
- package/dist/orchestration/routing/message-router.js +2 -0
- package/dist/orchestration/routing/webhook.js +6 -0
- package/dist/orchestration/session-compact.d.ts +0 -1
- package/dist/orchestration/session-compact.js +5 -7
- package/dist/orchestration/session-events.d.ts +2 -1
- package/dist/orchestration/session-events.js +1 -0
- package/dist/orchestration/status-helpers.d.ts +0 -4
- package/dist/orchestration/status-helpers.js +0 -18
- package/dist/orchestration/subagent-webhook.js +9 -34
- package/dist/orchestration/team-webhook.d.ts +8 -9
- package/dist/orchestration/team-webhook.js +16 -42
- package/dist/orchestration/transcript-sink.d.ts +12 -0
- package/dist/orchestration/transcript-sink.js +38 -2
- package/dist/orchestration/turn/terminal.js +7 -7
- package/dist/orchestration/turn/turn-prep.d.ts +0 -8
- package/dist/orchestration/turn/turn-prep.js +0 -51
- package/dist/orchestration/turn/turn-tracking.d.ts +2 -2
- package/dist/orchestration/turn/turn-tracking.js +8 -5
- package/dist/orchestration/turn/turn.d.ts +0 -2
- package/dist/orchestration/turn/turn.js +13 -15
- package/dist/orchestration/waitpoint-ingress.js +3 -0
- package/dist/platform/adapters/tui/ports.d.ts +1 -1
- package/dist/platform/adapters/tui/tui-transcript.js +2 -0
- package/dist/platform/browser/agent-browser.d.ts +50 -0
- package/dist/platform/browser/agent-browser.js +165 -0
- package/dist/platform/browser/managed-browser.d.ts +1 -11
- package/dist/platform/browser/managed-browser.js +4 -12
- package/dist/platform/ui-http/browser-stream.d.ts +110 -0
- package/dist/platform/ui-http/browser-stream.js +447 -0
- package/dist/platform/ui-http/ui-auth-routes.d.ts +2 -0
- package/dist/platform/ui-http/ui-auth-routes.js +9 -2
- package/dist/platform/ui-http/ui-device-routes.d.ts +13 -0
- package/dist/platform/ui-http/ui-device-routes.js +81 -0
- package/dist/platform/ui-http/ui-devices.d.ts +24 -0
- package/dist/platform/ui-http/ui-devices.js +107 -0
- package/dist/platform/ui-http/ui-http-server.d.ts +22 -3
- package/dist/platform/ui-http/ui-http-server.js +33 -12
- package/dist/platform/ui-http/ui-pairing.d.ts +25 -0
- package/dist/platform/ui-http/ui-pairing.js +98 -0
- package/dist/store/conversation-history-reader.js +8 -0
- package/dist/store/conversation-history-repo.d.ts +8 -1
- package/dist/store/conversation-history-repo.js +5 -0
- package/dist/store/conversation-ledger-repo.d.ts +6 -6
- package/dist/store/conversation-ledger-repo.js +4 -4
- package/dist/store/gitignore-migration.d.ts +2 -0
- package/dist/store/gitignore-migration.js +16 -0
- package/dist/store/hook-registry.d.ts +1 -1
- package/dist/store/hook-registry.js +11 -6
- package/dist/store/models-repo.d.ts +18 -0
- package/dist/store/models-repo.js +74 -0
- package/dist/store/pending-injection-repo.d.ts +2 -1
- package/dist/store/pending-injection-repo.js +3 -1
- package/dist/store/retire-profiles-migration.d.ts +28 -0
- package/dist/store/retire-profiles-migration.js +335 -0
- package/dist/store/schedule-repo.d.ts +2 -1
- package/dist/store/session-registry-import.js +3 -2
- package/dist/store/session-registry-journal.d.ts +10 -13
- package/dist/store/session-registry-journal.js +51 -25
- package/dist/store/session-registry-repo.d.ts +4 -4
- package/dist/store/session-registry-repo.js +4 -5
- package/dist/store/version-migrations.d.ts +7 -3
- package/dist/store/version-migrations.js +133 -80
- package/dist/tui/components/Dashboard.js +4 -3
- package/dist/tui/hooks/useDashboardData.js +1 -1
- package/dist/tui/slash-commands.js +2 -2
- package/dist/tui/turn-status.js +1 -1
- package/package.json +6 -4
- package/web/dist/assets/board-math-css-spk7yR6n.js +2 -0
- package/web/dist/assets/index-BQ69u-92.css +1 -0
- package/web/dist/assets/{index-CndZZ1IQ.js → index-CKNLatCd.js} +1 -1
- package/web/dist/assets/index-CkzWfC98.js +525 -0
- package/web/dist/index.html +3 -2
- package/web/dist/theme.css +6 -0
- package/dist/agent-adapter/browser-mcp-server.d.ts +0 -13
- package/dist/agent-adapter/browser-mcp-server.js +0 -28
- package/dist/agent-adapter/claude/browser-mcp.d.ts +0 -9
- package/dist/agent-adapter/claude/browser-mcp.js +0 -10
- package/dist/core/profile-generator.d.ts +0 -79
- package/dist/core/profile-generator.js +0 -215
- package/dist/domain/agents/profile-manager.d.ts +0 -103
- package/dist/domain/agents/profile-manager.js +0 -286
- package/dist/domain/agents/profile-switch.d.ts +0 -49
- package/dist/domain/agents/profile-switch.js +0 -62
- package/dist/domain/ui-service/mutate/profiles.d.ts +0 -36
- package/dist/domain/ui-service/mutate/profiles.js +0 -151
- package/dist/store/profile-repo.d.ts +0 -20
- package/dist/store/profile-repo.js +0 -97
- package/web/dist/assets/index-B76ueW3q.js +0 -494
- package/web/dist/assets/index-C8O0yxg8.css +0 -1
|
@@ -8,6 +8,7 @@ export interface DeltaFlush {
|
|
|
8
8
|
text: string;
|
|
9
9
|
/** 0 for a block's first published event, +1 per event after that. Lets a consumer detect gaps. */
|
|
10
10
|
seq: number;
|
|
11
|
+
kind?: 'thinking';
|
|
11
12
|
}
|
|
12
13
|
export interface DeltaCoalescerOptions {
|
|
13
14
|
onFlush: (flush: DeltaFlush) => void;
|
|
@@ -16,7 +17,7 @@ export interface DeltaCoalescerOptions {
|
|
|
16
17
|
}
|
|
17
18
|
export interface DeltaCoalescer {
|
|
18
19
|
/** Accumulate one incremental chunk. Empty chunks are ignored. */
|
|
19
|
-
push(blockId: string, text: string): void;
|
|
20
|
+
push(blockId: string, text: string, kind?: 'thinking'): void;
|
|
20
21
|
/** Publish what is pending for `blockId` (or for every block when omitted) right now. Callers
|
|
21
22
|
* MUST do this before the block's complete message goes out, so the preview never trails the
|
|
22
23
|
* authoritative text. */
|
|
@@ -32,7 +33,7 @@ export declare function resolveFlushMs(env: Record<string, string | undefined>):
|
|
|
32
33
|
export declare function createDeltaCoalescer(opts: DeltaCoalescerOptions): DeltaCoalescer;
|
|
33
34
|
export interface SessionDeltaStream {
|
|
34
35
|
/** Feed one incremental chunk from the adapter. */
|
|
35
|
-
onDelta(text: string, blockId: string): void;
|
|
36
|
+
onDelta(text: string, blockId: string, kind?: 'thinking'): void;
|
|
36
37
|
/** Publish what is pending — call this immediately before the block's complete message. */
|
|
37
38
|
flush(blockId?: string): void;
|
|
38
39
|
/** End of turn: cancel timers, drop anything unpublished. */
|
|
@@ -62,6 +63,7 @@ export declare function createSessionDeltaStream(args: {
|
|
|
62
63
|
blockId: string;
|
|
63
64
|
text: string;
|
|
64
65
|
seq: number;
|
|
66
|
+
kind?: 'thinking';
|
|
65
67
|
}) => void;
|
|
66
68
|
flushMs?: number;
|
|
67
69
|
}): SessionDeltaStream | null;
|
|
@@ -29,7 +29,7 @@ export function createDeltaCoalescer(opts) {
|
|
|
29
29
|
}
|
|
30
30
|
if (state.pending.length === 0)
|
|
31
31
|
return;
|
|
32
|
-
const flush = { blockId, text: state.pending, seq: state.seq };
|
|
32
|
+
const flush = { blockId, text: state.pending, seq: state.seq, ...(state.kind ? { kind: state.kind } : {}) };
|
|
33
33
|
state.pending = '';
|
|
34
34
|
state.seq += 1;
|
|
35
35
|
// A failing sink is not the streaming path's problem: the block keeps accumulating and the
|
|
@@ -40,12 +40,12 @@ export function createDeltaCoalescer(opts) {
|
|
|
40
40
|
catch { /* contained on purpose */ }
|
|
41
41
|
}
|
|
42
42
|
return {
|
|
43
|
-
push(blockId, text) {
|
|
43
|
+
push(blockId, text, kind) {
|
|
44
44
|
if (disposed || !text)
|
|
45
45
|
return;
|
|
46
46
|
let state = blocks.get(blockId);
|
|
47
47
|
if (!state) {
|
|
48
|
-
state = { pending: '', seq: 0, timer: null };
|
|
48
|
+
state = { pending: '', seq: 0, timer: null, kind };
|
|
49
49
|
blocks.set(blockId, state);
|
|
50
50
|
}
|
|
51
51
|
state.pending += text;
|
|
@@ -110,10 +110,10 @@ export function createSessionDeltaStream(args) {
|
|
|
110
110
|
const publish = args.publish ?? publishSessionMessageDelta;
|
|
111
111
|
const coalescer = createDeltaCoalescer({
|
|
112
112
|
flushMs: args.flushMs,
|
|
113
|
-
onFlush: (
|
|
113
|
+
onFlush: (flush) => publish({ sessionId, channel, ...flush }),
|
|
114
114
|
});
|
|
115
115
|
return {
|
|
116
|
-
onDelta: (text, blockId) => coalescer.push(blockId, text),
|
|
116
|
+
onDelta: (text, blockId, kind) => coalescer.push(blockId, text, kind),
|
|
117
117
|
flush: (blockId) => coalescer.flush(blockId),
|
|
118
118
|
dispose: () => coalescer.dispose(),
|
|
119
119
|
};
|
|
@@ -5,12 +5,11 @@ import { enqueue } from './conduit-queue.js';
|
|
|
5
5
|
import { getSessionAsync } from '../domain/sessions/session.js';
|
|
6
6
|
import { acquireSessionUse } from '../domain/sessions/session-use.js';
|
|
7
7
|
import { sessionStore, effectiveBackendSessionId } from '../store/session-registry-repo.js';
|
|
8
|
-
import {
|
|
8
|
+
import { resolveRunSelection } from '../domain/runs/config-resolver.js';
|
|
9
9
|
import { buildUserProcessingMessage, writeStatus, buildStatusActionBlocks, initStatusBlocks, } from './status-helpers.js';
|
|
10
10
|
import { initTurnTracking, finishTurnTracking, consumePendingTurnSupersession, } from './turn/turn-tracking.js';
|
|
11
11
|
import { handleAgentError } from './turn/terminal.js';
|
|
12
12
|
import { openTurn } from './turn/turn.js';
|
|
13
|
-
import { withTurnBrowser } from './turn/turn-prep.js';
|
|
14
13
|
import { prepareConversationRequest } from './conversation-request.js';
|
|
15
14
|
export function reprocessMessage(channel, text, adapter, opts) {
|
|
16
15
|
trackPendingTask(+1);
|
|
@@ -32,14 +31,15 @@ async function executeRetry(channel, text, adapter, opts) {
|
|
|
32
31
|
const userMessageTs = opts.originalTs;
|
|
33
32
|
const retryDest = { type: 'interactive-reply', conduit: channel, sessionId: sessionId ?? '' };
|
|
34
33
|
const retryPrefix = `${Icons.refresh} ${t('status.retry')} (${t('status.retryEdited')}) | `;
|
|
35
|
-
const
|
|
34
|
+
const selection = resolveRunSelection({ channel, session });
|
|
35
|
+
const retryStatusText = retryPrefix + buildUserProcessingMessage({ startTime, selection, sessionId });
|
|
36
36
|
const retryBlocksTemplate = { channel, sessionId, isDm: true };
|
|
37
37
|
const statusMsg = await adapter.postMessage(retryDest, {
|
|
38
38
|
text: retryStatusText,
|
|
39
39
|
richBlocks: buildStatusActionBlocks(retryStatusText, retryBlocksTemplate),
|
|
40
40
|
});
|
|
41
41
|
initStatusBlocks(statusMsg, retryBlocksTemplate);
|
|
42
|
-
updateRetryPermalinks(adapter, channel, userMessageTs, statusMsg, opts.supersededStatusTimestamps, retryPrefix, startTime, sessionId);
|
|
42
|
+
updateRetryPermalinks(adapter, channel, userMessageTs, statusMsg, opts.supersededStatusTimestamps, retryPrefix, startTime, sessionId, selection);
|
|
43
43
|
const turnTrackingToken = await initTurnTracking(channel, sessionId, backendSessionId, userMessageTs, text, statusMsg.messageId);
|
|
44
44
|
if (consumePendingTurnSupersession(channel, turnTrackingToken)) {
|
|
45
45
|
finishTurnTracking(channel, turnTrackingToken);
|
|
@@ -69,8 +69,7 @@ export async function runRetryAgent(args) {
|
|
|
69
69
|
return;
|
|
70
70
|
const backendSessionId = session ? effectiveBackendSessionId(session) : null;
|
|
71
71
|
const projectId = session?.projectId ?? 'general';
|
|
72
|
-
|
|
73
|
-
await withTurnBrowser({ backend, browser: session?.browser ?? null }, (cdpEndpoint) => openTurn({
|
|
72
|
+
await openTurn({
|
|
74
73
|
channel, adapter, threadAnchorId: null,
|
|
75
74
|
session: { sessionId, backendSessionId, projectId, lease: leased.lease },
|
|
76
75
|
// RAW text: what the ledger recorded and what an auto-resume would replay.
|
|
@@ -82,10 +81,9 @@ export async function runRetryAgent(args) {
|
|
|
82
81
|
startTime,
|
|
83
82
|
// The retry replays a message a human wrote, on the session's live engine: a user turn.
|
|
84
83
|
prepareRequest: (ids) => prepareConversationRequest({
|
|
85
|
-
ids, channel, session, userMessage: text || '',
|
|
86
|
-
browserCdpEndpoint: cdpEndpoint, trigger: 'edit-retry',
|
|
84
|
+
ids, channel, session, userMessage: text || '', trigger: 'edit-retry',
|
|
87
85
|
}),
|
|
88
|
-
})
|
|
86
|
+
});
|
|
89
87
|
}
|
|
90
88
|
/** The retry's session lease (none for a channel without a session), or null when it could not be
|
|
91
89
|
* taken — in which case the failure is already rendered and the ledger turn closed. */
|
|
@@ -111,14 +109,14 @@ async function leaseRetrySession(args) {
|
|
|
111
109
|
return null;
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
|
-
function updateRetryPermalinks(adapter, channel, userMessageTs, statusMsg, supersededTimestamps, retryPrefix, startTime, sessionId) {
|
|
112
|
+
function updateRetryPermalinks(adapter, channel, userMessageTs, statusMsg, supersededTimestamps, retryPrefix, startTime, sessionId, selection) {
|
|
115
113
|
const userPermalinkP = adapter.getPermalink({ conduit: channel, messageId: userMessageTs }).catch(() => null);
|
|
116
114
|
const statusPermalinkP = supersededTimestamps?.length
|
|
117
115
|
? adapter.getPermalink(statusMsg).catch(() => null)
|
|
118
116
|
: Promise.resolve(null);
|
|
119
117
|
Promise.all([userPermalinkP, statusPermalinkP]).then(([userPermalink, statusPermalink]) => {
|
|
120
118
|
if (userPermalink) {
|
|
121
|
-
writeStatus(adapter, statusMsg, `${Icons.refresh} ${t('status.retry')} (<${userPermalink}|${t('status.retryEdited')}>) | ` + buildUserProcessingMessage({ startTime,
|
|
119
|
+
writeStatus(adapter, statusMsg, `${Icons.refresh} ${t('status.retry')} (<${userPermalink}|${t('status.retryEdited')}>) | ` + buildUserProcessingMessage({ startTime, selection, sessionId }));
|
|
122
120
|
}
|
|
123
121
|
if (statusPermalink && supersededTimestamps?.length) {
|
|
124
122
|
for (const oldTs of supersededTimestamps) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { snapshotInlineMedia } from './inline-media.js';
|
|
2
|
+
import type { ResolveMediaInput } from '../domain/ui-service/inline-media-types.js';
|
|
3
|
+
type MessageMedia = Omit<ResolveMediaInput, 'src'> & {
|
|
4
|
+
text: string;
|
|
5
|
+
};
|
|
6
|
+
interface EagerDeps {
|
|
7
|
+
snapshot: typeof snapshotInlineMedia;
|
|
8
|
+
warn: (message: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function extractMediaSources(markdown: string): string[];
|
|
11
|
+
/** Called after the row is durable; an unavailable image must never fail the assistant turn. */
|
|
12
|
+
export declare function eagerSnapshotInlineMedia(message: MessageMedia, deps?: EagerDeps): Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createLogger } from '../core/log.js';
|
|
2
|
+
import { parseMediaSrc, snapshotInlineMedia } from './inline-media.js';
|
|
3
|
+
const log = createLogger('inline-media');
|
|
4
|
+
const defaults = { snapshot: snapshotInlineMedia, warn: message => log.warn(message) };
|
|
5
|
+
// Match web/src/lib/markdown.ts: destinations are verbatim, not CommonMark-normalized.
|
|
6
|
+
const TARGET = String.raw `(?:[^()]|\((?:[^()]|\([^()]*\))*\))+`;
|
|
7
|
+
const INLINE_MEDIA = new RegExp([
|
|
8
|
+
String.raw `\*\*[^*]+\*\*`,
|
|
9
|
+
String.raw `(?<ticks>\x60+).*?\k<ticks>`,
|
|
10
|
+
String.raw `!\[[^\]]*\]\((?<src>${TARGET})\)`,
|
|
11
|
+
String.raw `\[[^\]]+\]\(${TARGET}\)`,
|
|
12
|
+
String.raw `\*[^*]+\*`,
|
|
13
|
+
String.raw `_[^_]+_`,
|
|
14
|
+
].join('|'), 'g');
|
|
15
|
+
function withoutFencedCode(markdown) {
|
|
16
|
+
const body = [];
|
|
17
|
+
let fence;
|
|
18
|
+
for (const line of markdown.replace(/\r\n/g, '\n').split('\n')) {
|
|
19
|
+
if (fence) {
|
|
20
|
+
const trimmed = line.trim();
|
|
21
|
+
if (trimmed.length >= fence.length && [...trimmed].every(char => char === fence.marker))
|
|
22
|
+
fence = undefined;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const opening = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);
|
|
26
|
+
if (opening && !(opening[1][0] === '`' && opening[2].includes('`'))) {
|
|
27
|
+
fence = { marker: opening[1][0], length: opening[1].length };
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
body.push(line);
|
|
31
|
+
}
|
|
32
|
+
return body.join('\n');
|
|
33
|
+
}
|
|
34
|
+
export function extractMediaSources(markdown) {
|
|
35
|
+
const sources = new Set();
|
|
36
|
+
for (const match of withoutFencedCode(markdown).matchAll(INLINE_MEDIA)) {
|
|
37
|
+
if (match.groups?.src)
|
|
38
|
+
sources.add(match.groups.src);
|
|
39
|
+
}
|
|
40
|
+
return [...sources];
|
|
41
|
+
}
|
|
42
|
+
async function snapshotReference(message, src, deps) {
|
|
43
|
+
try {
|
|
44
|
+
const source = parseMediaSrc(src);
|
|
45
|
+
if (source.type !== 'local' && source.type !== 'device')
|
|
46
|
+
return;
|
|
47
|
+
const result = await deps.snapshot({ sessionId: message.sessionId, ts: message.ts, src });
|
|
48
|
+
if ('error' in result)
|
|
49
|
+
deps.warn(`Inline media snapshot failed (${result.error.code}): ${src}: ${result.error.reason}`);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
deps.warn(`Inline media snapshot failed: ${src}: ${String(error)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Called after the row is durable; an unavailable image must never fail the assistant turn. */
|
|
56
|
+
export async function eagerSnapshotInlineMedia(message, deps = defaults) {
|
|
57
|
+
await Promise.all(extractMediaSources(message.text).map(src => snapshotReference(message, src, deps)));
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ResolveMediaInput, ResolveMediaResult } from '../domain/ui-service/inline-media-types.js';
|
|
2
|
+
export declare const MAX_INLINE_MEDIA_BYTES: number;
|
|
3
|
+
type FileSource = {
|
|
4
|
+
type: 'local';
|
|
5
|
+
filePath: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'device';
|
|
8
|
+
device: string;
|
|
9
|
+
filePath: string;
|
|
10
|
+
};
|
|
11
|
+
export type MediaSource = FileSource | {
|
|
12
|
+
type: 'workspace';
|
|
13
|
+
path: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'https';
|
|
16
|
+
url: string;
|
|
17
|
+
};
|
|
18
|
+
/** Device names are configuration keys, not arbitrary URI schemes or currently-online devices. */
|
|
19
|
+
export declare function parseMediaSrc(src: string): MediaSource;
|
|
20
|
+
/** First successful snapshot wins for this message/source; failures are retryable. */
|
|
21
|
+
export declare function snapshotInlineMedia(input: ResolveMediaInput): Promise<ResolveMediaResult>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { DATA_DIR, resolveWorkspaceRelPath } from '../core/paths.js';
|
|
6
|
+
import { getMachineRegistry } from '../domain/remote/machine-registry.js';
|
|
7
|
+
import { fetchRemoteFile, prepareRemoteFetch } from '../domain/remote/device-file.js';
|
|
8
|
+
export const MAX_INLINE_MEDIA_BYTES = 200 * 1024 * 1024;
|
|
9
|
+
const IMAGE_EXTENSIONS = new Set(['.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg', '.bmp', '.ico', '.avif']);
|
|
10
|
+
const VIDEO_EXTENSIONS = new Set(['.mp4', '.webm', '.mov', '.m4v']);
|
|
11
|
+
const inFlight = new Map();
|
|
12
|
+
class MediaError extends Error {
|
|
13
|
+
code;
|
|
14
|
+
constructor(code, reason) {
|
|
15
|
+
super(reason);
|
|
16
|
+
this.code = code;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Device names are configuration keys, not arbitrary URI schemes or currently-online devices. */
|
|
20
|
+
export function parseMediaSrc(src) {
|
|
21
|
+
if (!src || src.includes('\0'))
|
|
22
|
+
throw new MediaError('unsupported', 'Invalid media source');
|
|
23
|
+
if (/^https:\/\//i.test(src))
|
|
24
|
+
return { type: 'https', url: new URL(src).href };
|
|
25
|
+
if (src.startsWith('workspace/')) {
|
|
26
|
+
if (!resolveWorkspaceRelPath(src))
|
|
27
|
+
throw new MediaError('unsupported', 'Invalid workspace path');
|
|
28
|
+
return { type: 'workspace', path: src };
|
|
29
|
+
}
|
|
30
|
+
return parseFileSource(src);
|
|
31
|
+
}
|
|
32
|
+
function parseFileSource(src) {
|
|
33
|
+
if (src.startsWith('~/'))
|
|
34
|
+
return { type: 'local', filePath: path.join(os.homedir(), src.slice(2)) };
|
|
35
|
+
if (path.isAbsolute(src))
|
|
36
|
+
return { type: 'local', filePath: src };
|
|
37
|
+
const device = /^([^:/\\]+):(.*)$/s.exec(src);
|
|
38
|
+
if (!device)
|
|
39
|
+
return { type: 'local', filePath: path.resolve(DATA_DIR, src) };
|
|
40
|
+
return parseDeviceSource(device[1], device[2]);
|
|
41
|
+
}
|
|
42
|
+
function parseDeviceSource(device, filePath) {
|
|
43
|
+
const registered = Object.hasOwn(getMachineRegistry(), device);
|
|
44
|
+
const absolute = path.posix.isAbsolute(filePath) || path.win32.isAbsolute(filePath);
|
|
45
|
+
if (!registered || !absolute)
|
|
46
|
+
throw new MediaError('unsupported', 'Unknown device or non-absolute device path');
|
|
47
|
+
return { type: 'device', device, filePath };
|
|
48
|
+
}
|
|
49
|
+
function mediaKind(ext) {
|
|
50
|
+
if (VIDEO_EXTENSIONS.has(ext))
|
|
51
|
+
return 'video';
|
|
52
|
+
if (IMAGE_EXTENSIONS.has(ext))
|
|
53
|
+
return 'image';
|
|
54
|
+
throw new MediaError('unsupported', 'Unsupported image or video extension');
|
|
55
|
+
}
|
|
56
|
+
/** Remote transport predates structured errors; translate its boundary messages in one place. */
|
|
57
|
+
function mediaFailure(error) {
|
|
58
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
59
|
+
if (error instanceof MediaError)
|
|
60
|
+
return { error: { code: error.code, reason } };
|
|
61
|
+
const codes = [
|
|
62
|
+
[/not online|disconnected|offline/i, 'offline'],
|
|
63
|
+
[/ENOENT|ENOTDIR|File not found|Not a file/i, 'not_found'],
|
|
64
|
+
[/over the \d+-byte limit/i, 'too_large'],
|
|
65
|
+
[/client too old/i, 'unsupported'],
|
|
66
|
+
];
|
|
67
|
+
const code = codes.find(([pattern]) => pattern.test(reason))?.[1] ?? 'load_failed';
|
|
68
|
+
return { error: { code, reason } };
|
|
69
|
+
}
|
|
70
|
+
async function assertMediaFile(filePath) {
|
|
71
|
+
const stat = await fs.stat(filePath);
|
|
72
|
+
if (!stat.isFile())
|
|
73
|
+
throw new MediaError('not_found', 'Not a file');
|
|
74
|
+
if (stat.size > MAX_INLINE_MEDIA_BYTES)
|
|
75
|
+
throw new MediaError('too_large', 'Media exceeds the 200 MiB limit');
|
|
76
|
+
}
|
|
77
|
+
/** First successful snapshot wins for this message/source; failures are retryable. */
|
|
78
|
+
export async function snapshotInlineMedia(input) {
|
|
79
|
+
try {
|
|
80
|
+
if (!/^[\w-]+$/.test(input.sessionId))
|
|
81
|
+
throw new MediaError('unsupported', 'Invalid session ID');
|
|
82
|
+
const source = parseMediaSrc(input.src);
|
|
83
|
+
if (source.type === 'https')
|
|
84
|
+
throw new MediaError('unsupported', 'HTTPS media must be loaded directly by the browser');
|
|
85
|
+
return await resolveSource(input, source);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
return mediaFailure(error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function resolveSource(input, source) {
|
|
92
|
+
const filePath = source.type === 'workspace' ? source.path : source.filePath;
|
|
93
|
+
const name = filePath.split(/[/\\]/).pop();
|
|
94
|
+
const ext = path.extname(name).toLowerCase();
|
|
95
|
+
const kind = mediaKind(ext);
|
|
96
|
+
if (source.type === 'workspace') {
|
|
97
|
+
await assertMediaFile(resolveWorkspaceRelPath(source.path));
|
|
98
|
+
return { path: source.path, name, kind };
|
|
99
|
+
}
|
|
100
|
+
const hash = createHash('sha1').update(input.ts + input.src).digest('hex').slice(0, 16);
|
|
101
|
+
const relPath = `workspace/outputs/${input.sessionId}/inline/${hash}${ext}`;
|
|
102
|
+
const pending = inFlight.get(relPath);
|
|
103
|
+
if (pending)
|
|
104
|
+
return pending;
|
|
105
|
+
const result = landSnapshot(source, relPath).then(() => ({ path: relPath, name, kind }));
|
|
106
|
+
inFlight.set(relPath, result);
|
|
107
|
+
try {
|
|
108
|
+
return await result;
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
inFlight.delete(relPath);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function exists(filePath) {
|
|
115
|
+
try {
|
|
116
|
+
await assertMediaFile(filePath);
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
if (error.code === 'ENOENT')
|
|
121
|
+
return false;
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Like outputs-store's local copy, but deterministic naming and staging preserve message versions. */
|
|
126
|
+
async function landSnapshot(source, relPath) {
|
|
127
|
+
const destPath = resolveWorkspaceRelPath(relPath);
|
|
128
|
+
if (await exists(destPath))
|
|
129
|
+
return;
|
|
130
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
131
|
+
const partial = `${destPath}.part`;
|
|
132
|
+
try {
|
|
133
|
+
await receiveSource(source, partial);
|
|
134
|
+
// A local producer may have grown the file between stat and copy.
|
|
135
|
+
await assertMediaFile(partial);
|
|
136
|
+
await fs.rename(partial, destPath);
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
await fs.rm(partial, { force: true }).catch(() => { });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async function receiveSource(source, destPath) {
|
|
143
|
+
if (source.type === 'local') {
|
|
144
|
+
await assertMediaFile(source.filePath);
|
|
145
|
+
await fs.copyFile(source.filePath, destPath);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const args = { device: source.device, filePath: source.filePath, maxBytes: MAX_INLINE_MEDIA_BYTES };
|
|
149
|
+
const stat = await prepareRemoteFetch(args);
|
|
150
|
+
await fetchRemoteFile({ ...args, destPath, stat });
|
|
151
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { createLogger } from '../../core/log.js';
|
|
2
2
|
import { sessionStore, effectiveBackendSessionId } from '../../store/session-registry-repo.js';
|
|
3
3
|
import { acquireSessionUse } from '../../domain/sessions/session-use.js';
|
|
4
|
-
import { resolveBackendForChannel } from '../../domain/agents/index.js';
|
|
5
4
|
import { openTurn } from '../turn/turn.js';
|
|
6
|
-
import { withTurnBrowser } from '../turn/turn-prep.js';
|
|
7
5
|
import { prepareConversationRequest } from '../conversation-request.js';
|
|
8
6
|
import * as askUserQuestion from './ask-user-question.js';
|
|
9
7
|
const log = createLogger('ask-user-resume');
|
|
@@ -41,8 +39,7 @@ async function openAnswerTurn(adapter, group, responseText, lease) {
|
|
|
41
39
|
const { channel } = group;
|
|
42
40
|
// Cost/execution attribution uses the session's bound project, NOT a re-derivation from the text.
|
|
43
41
|
const session = await sessionStore.getById(group.sessionId);
|
|
44
|
-
|
|
45
|
-
await withTurnBrowser({ backend, browser: session?.browser ?? null }, (cdpEndpoint) => openTurn({
|
|
42
|
+
await openTurn({
|
|
46
43
|
channel, adapter, threadAnchorId: null,
|
|
47
44
|
session: {
|
|
48
45
|
sessionId: group.sessionId,
|
|
@@ -54,8 +51,7 @@ async function openAnswerTurn(adapter, group, responseText, lease) {
|
|
|
54
51
|
ledger: null,
|
|
55
52
|
trigger: 'ask-user-question',
|
|
56
53
|
prepareRequest: (ids) => prepareConversationRequest({
|
|
57
|
-
ids, channel, session, userMessage: responseText,
|
|
58
|
-
browserCdpEndpoint: cdpEndpoint, trigger: 'ask-user-question',
|
|
54
|
+
ids, channel, session, userMessage: responseText, trigger: 'ask-user-question',
|
|
59
55
|
}),
|
|
60
|
-
})
|
|
56
|
+
});
|
|
61
57
|
}
|
|
@@ -11,7 +11,7 @@ import { conduitQueues } from '../conduit-queue.js';
|
|
|
11
11
|
import { setSessionAsync, deleteSessionAsync } from '../../domain/sessions/session.js';
|
|
12
12
|
import { sessionStore } from '../../store/session-registry-repo.js';
|
|
13
13
|
import { conversationLedger } from '../../store/conversation-ledger-repo.js';
|
|
14
|
-
import {
|
|
14
|
+
import { resolveRunSelection } from '../../domain/runs/config-resolver.js';
|
|
15
15
|
import { engines } from '../../domain/runs/engines.js';
|
|
16
16
|
import { fireAndForgetPreCloseHook } from '../../domain/sessions/session-hooks.js';
|
|
17
17
|
import { attachExistingSession } from '../../domain/sessions/session-lifecycle.js';
|
|
@@ -245,12 +245,12 @@ async function handleStatusResume(ctx) {
|
|
|
245
245
|
if (!record)
|
|
246
246
|
return;
|
|
247
247
|
await attachExistingSession(ctx.channelId, {
|
|
248
|
-
sessionId: record.sessionId, backend: record.backend,
|
|
248
|
+
sessionId: record.sessionId, backend: record.backend, selection: record.selection,
|
|
249
249
|
});
|
|
250
|
-
const
|
|
250
|
+
const selectionNote = record.selection ? ` (${record.selection.backend} · ${record.selection.model})` : '';
|
|
251
251
|
const resumeDest = { type: 'interactive-reply', conduit: ctx.channelId, sessionId: record.sessionId ?? '' };
|
|
252
252
|
await _adapter.postMessage(resumeDest, {
|
|
253
|
-
text: `${Icons.refresh} ${t('interaction.sessionActive', { sessionId: shortSessionId(sessionId),
|
|
253
|
+
text: `${Icons.refresh} ${t('interaction.sessionActive', { sessionId: shortSessionId(sessionId), selectionNote })}`,
|
|
254
254
|
}).catch(() => { });
|
|
255
255
|
}
|
|
256
256
|
// "New" button (=!new): close the session and run the pre-close hook.
|
|
@@ -274,7 +274,7 @@ async function resetChannelFromStatusButton(ctx, opts) {
|
|
|
274
274
|
void fireAndForgetPreCloseHook(channel, _adapter, threadAnchorId);
|
|
275
275
|
void engines.close(channel);
|
|
276
276
|
const conv = await conversationLedger.getConversation(channel);
|
|
277
|
-
const
|
|
277
|
+
const selection = resolveRunSelection({ channel });
|
|
278
278
|
if (conv) {
|
|
279
279
|
sessionBackup.cleanupAllBackups(conv.sessionId);
|
|
280
280
|
await conversationLedger.clearConversation(channel);
|
|
@@ -283,6 +283,6 @@ async function resetChannelFromStatusButton(ctx, opts) {
|
|
|
283
283
|
planApprovals.clearByChannel(channel);
|
|
284
284
|
const newDest = { type: 'interactive-reply', conduit: ctx.channelId, sessionId: '' };
|
|
285
285
|
await _adapter.postMessage(newDest, {
|
|
286
|
-
text: t('interaction.newConversation', {
|
|
286
|
+
text: t('interaction.newConversation', { selection: `${selection.backend} · ${selection.model}` }),
|
|
287
287
|
}).catch(() => { });
|
|
288
288
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* then it hands the message to the run and registers the pending record with the ledger. Every
|
|
9
9
|
* refusal leaves no trace so the caller falls through to the normal queue.
|
|
10
10
|
*/
|
|
11
|
+
import type { EngineSelection } from '../domain/agents/engine-selection.js';
|
|
11
12
|
import type { UserMessage } from '../agent-adapter/types.js';
|
|
12
13
|
import type { SystemTurnOrigin } from '../core/types/agent-types.js';
|
|
13
14
|
import type { AttachmentMeta } from '../domain/ui-service/types.js';
|
|
@@ -30,7 +31,7 @@ export interface MidTurnInjectCtx {
|
|
|
30
31
|
channel: string;
|
|
31
32
|
/** Stable Cortex track session id. Null (never-used channel) ⇒ nothing to surface against. */
|
|
32
33
|
sessionId: string | null;
|
|
33
|
-
|
|
34
|
+
selection?: EngineSelection | null;
|
|
34
35
|
text: string;
|
|
35
36
|
senderId: string;
|
|
36
37
|
/** Set when Cortex authored this turn rather than a human (see `SystemTurnOrigin`). Only
|
|
@@ -46,7 +46,7 @@ function buildPendingRecord(deps, ctx, message, sessionId, backend, ts) {
|
|
|
46
46
|
channel: ctx.channel,
|
|
47
47
|
messageId: ctx.messageId,
|
|
48
48
|
backend,
|
|
49
|
-
|
|
49
|
+
selection: ctx.selection ?? null,
|
|
50
50
|
text: ctx.text,
|
|
51
51
|
attachments: ctx.attachments,
|
|
52
52
|
...(ctx.systemOrigin ? { systemOrigin: ctx.systemOrigin } : {}),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EngineSelection } from '../domain/agents/engine-selection.js';
|
|
1
2
|
import { type PendingInjectionRecord } from '../store/pending-injection-repo.js';
|
|
2
3
|
export interface PendingInjectionCommitDeps {
|
|
3
4
|
pendingRepo: {
|
|
@@ -20,7 +21,7 @@ export interface PendingInjectionCommitDeps {
|
|
|
20
21
|
initAndBeginTurn(channel: string, opts: {
|
|
21
22
|
sessionId: string;
|
|
22
23
|
backend: string;
|
|
23
|
-
|
|
24
|
+
selection: EngineSelection | null;
|
|
24
25
|
userMessageTs: string;
|
|
25
26
|
userMessageText: string;
|
|
26
27
|
statusMessageTs: string;
|
|
@@ -24,7 +24,7 @@ async function ensureLedgerTurn(record, deps) {
|
|
|
24
24
|
await deps.ledger.initAndBeginTurn(record.channel, {
|
|
25
25
|
sessionId: record.sessionId,
|
|
26
26
|
backend: record.backend,
|
|
27
|
-
|
|
27
|
+
selection: record.selection,
|
|
28
28
|
userMessageTs: record.messageId,
|
|
29
29
|
userMessageText: record.text,
|
|
30
30
|
statusMessageTs: '',
|
|
@@ -4,7 +4,7 @@ import { t } from '../../../core/i18n.js';
|
|
|
4
4
|
import { handleOrientCmd } from './orient.js';
|
|
5
5
|
import { createScheduleHandler } from './schedule.js';
|
|
6
6
|
import { handleCostCmd, handleBudgetCmd } from './cost.js';
|
|
7
|
-
import { handleModeCmd, handleBackendCmd,
|
|
7
|
+
import { handleModeCmd, handleBackendCmd, handleThinkingCmd, createModelHandler, handleSkillsCmd, createAgentHandler } from './mode.js';
|
|
8
8
|
import { createStatusHandler, createHelpHandler } from './status.js';
|
|
9
9
|
import { createCancelHandler } from './cancel.js';
|
|
10
10
|
import { createCompactHandler } from './compact.js';
|
|
@@ -67,7 +67,7 @@ function createHandlerSet(deps) {
|
|
|
67
67
|
help: createHelpHandler(router),
|
|
68
68
|
devices: createDevicesHandler(router),
|
|
69
69
|
resume: createResumeHandler(router),
|
|
70
|
-
|
|
70
|
+
model: createModelHandler(router),
|
|
71
71
|
agent: createAgentHandler(router),
|
|
72
72
|
register: createRegisterHandler(router),
|
|
73
73
|
projectDir: createProjectDirHandler(router),
|
|
@@ -108,9 +108,9 @@ function createPrefixCommands(h) {
|
|
|
108
108
|
return [
|
|
109
109
|
{ prefix: '!cancel', handler: h.cancel },
|
|
110
110
|
{ prefix: '!backend', handler: handleBackendCmd },
|
|
111
|
-
{ prefix: '!model', handler:
|
|
111
|
+
{ prefix: '!model', handler: h.model },
|
|
112
112
|
{ prefix: '!thinking', handler: handleThinkingCmd },
|
|
113
|
-
{ prefix: '!
|
|
113
|
+
{ prefix: '!mode ', handler: handleModeCmd },
|
|
114
114
|
{ prefix: '!usage ', handler: h.usage },
|
|
115
115
|
{ prefix: '!cost', handler: handleCostCmd },
|
|
116
116
|
{ prefix: '!budget', handler: handleBudgetCmd },
|
|
@@ -1,49 +1,10 @@
|
|
|
1
1
|
import type { PlatformAdapter } from '../../../platform/index.js';
|
|
2
2
|
import type { CommandResult } from './command-context.js';
|
|
3
3
|
import type { CommandActionRouter } from '../../interactions/command-action-router.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* from `config.mode`, which is the profile's, so the toggle moved a field nobody read. Rather than
|
|
10
|
-
* keep a control that silently does nothing, the command now says where the value comes from.
|
|
11
|
-
*/
|
|
12
|
-
export declare function handleModeCmd(channel: string, adapter: PlatformAdapter): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* `!backend <claude|pi>` — move THIS CHANNEL to that backend's default profile (D5).
|
|
15
|
-
*
|
|
16
|
-
* Before D5 this flipped a daemon-wide `backend` field that the run path then contradicted with
|
|
17
|
-
* the channel's own profile. There is no such field any more: a backend is a property of a
|
|
18
|
-
* profile, so switching backend means switching profile, and it goes through exactly the rule
|
|
19
|
-
* `!profile` uses — including the refusal to move a conversation that already has history, which
|
|
20
|
-
* no backend can resume on the other side.
|
|
21
|
-
*/
|
|
22
|
-
export declare function handleBackendCmd(channel: string, adapter: PlatformAdapter, trimmedMessage: string): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* `!thinking` — show, set or clear THIS CHANNEL's thinking level (the composer picker's chat twin).
|
|
25
|
-
*
|
|
26
|
-
* The same channel-scoped override the picker writes, one field over. The level IS validated (by
|
|
27
|
-
* the selection rule), unlike the model: an id the backend does not know is the backend's business
|
|
28
|
-
* to refuse, but an effort word it does not know is rejected by the CLI before the turn starts,
|
|
29
|
-
* which reads as the agent dying. Clearing drops only the level.
|
|
30
|
-
*/
|
|
31
|
-
export declare function handleThinkingCmd(channel: string, adapter: PlatformAdapter, trimmedMessage: string): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* `!model` — show, set or clear THIS CHANNEL's model override (D5).
|
|
34
|
-
*
|
|
35
|
-
* The override is stored per channel and layered on top of whatever profile the channel resolves
|
|
36
|
-
* to; the profile keeps its own model, so `!model reset` is a real undo. It replaces a global
|
|
37
|
-
* `claudeModel` that only ever applied to Claude and that the profile silently outranked.
|
|
38
|
-
*
|
|
39
|
-
* The value is not validated here: which ids a backend accepts is the backend's business, and its
|
|
40
|
-
* own rejection names the problem better than a guess would.
|
|
41
|
-
*
|
|
42
|
-
* `!model` and `!thinking` write through `applyChannelSelection`, the rule every selection surface
|
|
43
|
-
* shares, with `seedDefault: false`: a channel-scoped command does not decide what the next new
|
|
44
|
-
* Web conversation opens on.
|
|
45
|
-
*/
|
|
46
|
-
export declare function handleModelCmd(channel: string, adapter: PlatformAdapter, trimmedMessage: string): Promise<void>;
|
|
47
|
-
export declare function createProfileHandler(router?: CommandActionRouter): (channel: string, adapter: PlatformAdapter, trimmedMessage: string) => Promise<CommandResult | void>;
|
|
4
|
+
export declare function handleModeCmd(channel: string, adapter: PlatformAdapter, message?: string): Promise<void>;
|
|
5
|
+
export declare function handleBackendCmd(channel: string, adapter: PlatformAdapter, message: string): Promise<void>;
|
|
6
|
+
export declare function handleThinkingCmd(channel: string, adapter: PlatformAdapter, message: string): Promise<void>;
|
|
7
|
+
export declare function handleModelCmd(channel: string, adapter: PlatformAdapter, message: string): Promise<void>;
|
|
8
|
+
export declare function createModelHandler(router?: CommandActionRouter): (channel: string, adapter: PlatformAdapter, message: string) => Promise<CommandResult | void>;
|
|
48
9
|
export declare function handleSkillsCmd(channel: string, adapter: PlatformAdapter): Promise<void>;
|
|
49
10
|
export declare function createAgentHandler(router?: CommandActionRouter): (channel: string, adapter: PlatformAdapter, trimmedMessage: string) => Promise<CommandResult | void>;
|