@cortex-agent/server 2026.10.15 → 2026.10.21
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 +76 -50
- 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/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/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/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/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 +3 -2
- package/dist/agent-adapter/claude/turn-machine.js +21 -68
- 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.js +3 -0
- 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 +11 -10
- package/dist/agent-adapter/run-events.js +2 -0
- package/dist/agent-adapter/types.d.ts +5 -4
- package/dist/client-bundle/manifest.json +2 -2
- package/dist/core/codex-quota.d.ts +1 -1
- package/dist/core/codex-quota.js +1 -1
- package/dist/core/gateway-generator.d.ts +9 -11
- package/dist/core/gateway-generator.js +31 -58
- package/dist/core/locales/en.d.ts +51 -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 +8 -19
- package/dist/core/locales/slices/init.js +17 -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/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 +25 -0
- package/dist/core/settings-spec.js +34 -0
- package/dist/core/status-format.d.ts +3 -2
- package/dist/core/status-format.js +2 -2
- package/dist/core/types/environment-types.d.ts +0 -2
- 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 +2 -1
- package/dist/domain/agents/environments/resolve.js +0 -1
- package/dist/domain/agents/environments/schema.d.ts +0 -1
- package/dist/domain/agents/environments/schema.js +0 -1
- 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/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 -6
- package/dist/domain/mcp/tools/context.js +17 -3
- package/dist/domain/mcp/tools/subagent.js +1 -1
- package/dist/domain/mcp/tools/ui-file.js +1 -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/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 +0 -17
- package/dist/domain/runs/run.d.ts +12 -42
- package/dist/domain/runs/run.js +40 -147
- package/dist/domain/runs/service.d.ts +1 -1
- package/dist/domain/runs/service.js +8 -3
- 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/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 +22 -21
- 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/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/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 +49 -71
- package/dist/domain/ui-service/app-router.js +9 -13
- 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 +52 -115
- package/dist/domain/ui-service/input-schemas.js +38 -84
- 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/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/query/config.js +22 -42
- package/dist/domain/ui-service/query/models.js +2 -2
- package/dist/domain/ui-service/query/schedules.js +1 -1
- package/dist/domain/ui-service/query/sessions.js +7 -13
- package/dist/domain/ui-service/types.d.ts +51 -177
- package/dist/domain/ui-service/ui-service.d.ts +23 -49
- package/dist/domain/ui-service/ui-service.js +8 -6
- package/dist/entry/app.js +42 -19
- 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 +37 -6
- package/dist/entry/cli.js +16 -14
- package/dist/entry/daemon.js +2 -0
- package/dist/entry/init-auth.js +1 -1
- package/dist/entry/init.d.ts +7 -8
- package/dist/entry/init.js +89 -249
- 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 +8 -1
- package/dist/entry/start-ui-http.js +8 -0
- package/dist/entry/ui-service-wiring.js +8 -10
- package/dist/events/event-types.d.ts +3 -2
- 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/webhook.js +4 -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 +6 -0
- package/dist/orchestration/transcript-sink.js +21 -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/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-http-server.d.ts +12 -0
- package/dist/platform/ui-http/ui-http-server.js +23 -6
- 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/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 +48 -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 +2 -3
- package/dist/store/version-migrations.js +19 -3
- 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-CB4GJ6qO.js +2 -0
- package/web/dist/assets/index-CaSZPg_H.css +1 -0
- package/web/dist/assets/index-CzOR7Edh.js +522 -0
- package/web/dist/assets/{index-CndZZ1IQ.js → index-cIGFv27z.js} +1 -1
- 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
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
/** Marks files this module owns; remove and refresh never touch a file without it. */
|
|
4
|
+
export const SHIM_MARKER = 'cortex-managed-shim';
|
|
5
|
+
const HEADER = `${SHIM_MARKER}: written by \`cortex path install\`, refreshed when the daemon starts.`;
|
|
6
|
+
export function shimDir(home) {
|
|
7
|
+
return path.join(home, 'runtime', 'bin');
|
|
8
|
+
}
|
|
9
|
+
/** The package's `bin` map as absolute entry paths. */
|
|
10
|
+
export function packageBins(installRoot) {
|
|
11
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(installRoot, 'package.json'), 'utf8'));
|
|
12
|
+
return Object.entries(manifest.bin ?? {}).map(([name, rel]) => ({ name, entry: path.join(installRoot, rel) }));
|
|
13
|
+
}
|
|
14
|
+
const shQuote = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
15
|
+
function posixShim(node, entry, home, nodeDirOnPath) {
|
|
16
|
+
return [
|
|
17
|
+
'#!/bin/sh',
|
|
18
|
+
`# ${HEADER}`,
|
|
19
|
+
`if [ -z "\${CORTEX_HOME:-}" ]; then CORTEX_HOME=${shQuote(home)}; fi`,
|
|
20
|
+
'export CORTEX_HOME',
|
|
21
|
+
`PATH=${shQuote(nodeDirOnPath)}:"$PATH"; export PATH`,
|
|
22
|
+
`exec ${shQuote(node)} ${shQuote(entry)} "$@"`,
|
|
23
|
+
'',
|
|
24
|
+
].join('\n');
|
|
25
|
+
}
|
|
26
|
+
function cmdShim(node, entry, home) {
|
|
27
|
+
const esc = (value) => value.replace(/%/g, '%%');
|
|
28
|
+
return [
|
|
29
|
+
'@echo off',
|
|
30
|
+
`rem ${HEADER}`,
|
|
31
|
+
'setlocal',
|
|
32
|
+
`if not defined CORTEX_HOME set "CORTEX_HOME=${esc(home)}"`,
|
|
33
|
+
`set "PATH=${esc(path.win32.dirname(node))};%PATH%"`,
|
|
34
|
+
`"${esc(node)}" "${esc(entry)}" %*`,
|
|
35
|
+
'',
|
|
36
|
+
].join('\r\n');
|
|
37
|
+
}
|
|
38
|
+
/** `C:\x\y` → `C:/x/y` (native programs) and `/c/x/y` (Git Bash PATH entries). */
|
|
39
|
+
const forward = (winPath) => winPath.replace(/\\/g, '/');
|
|
40
|
+
const msys = (winPath) => forward(winPath).replace(/^([A-Za-z]):/, (_, drive) => `/${drive.toLowerCase()}`);
|
|
41
|
+
export function renderShims(target, platform = process.platform) {
|
|
42
|
+
if (platform !== 'win32') {
|
|
43
|
+
const nodeDir = path.posix.dirname(target.node);
|
|
44
|
+
return target.bins.map(({ name, entry }) => ({ file: name, content: posixShim(target.node, entry, target.home, nodeDir) }));
|
|
45
|
+
}
|
|
46
|
+
return target.bins.flatMap(({ name, entry }) => [
|
|
47
|
+
{ file: `${name}.cmd`, content: cmdShim(target.node, entry, target.home) },
|
|
48
|
+
{
|
|
49
|
+
file: name,
|
|
50
|
+
content: posixShim(forward(target.node), forward(entry), forward(target.home), msys(path.win32.dirname(target.node))),
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
function readIfExists(file) {
|
|
55
|
+
try {
|
|
56
|
+
return fs.readFileSync(file, 'utf8');
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function listManagedShims(dir) {
|
|
63
|
+
let names;
|
|
64
|
+
try {
|
|
65
|
+
names = fs.readdirSync(dir);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
return names.filter((name) => readIfExists(path.join(dir, name))?.includes(SHIM_MARKER)).sort();
|
|
71
|
+
}
|
|
72
|
+
/** Shims whose on-disk content differs from `rendered` (missing ones included). */
|
|
73
|
+
export function staleShims(dir, rendered) {
|
|
74
|
+
return rendered.filter((shim) => readIfExists(path.join(dir, shim.file)) !== shim.content).map((shim) => shim.file);
|
|
75
|
+
}
|
|
76
|
+
/** Write changed shims and drop managed ones no longer rendered; returns files written. */
|
|
77
|
+
export function writeShims(dir, rendered) {
|
|
78
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
79
|
+
const written = staleShims(dir, rendered);
|
|
80
|
+
for (const file of written) {
|
|
81
|
+
const shim = rendered.find((candidate) => candidate.file === file);
|
|
82
|
+
fs.writeFileSync(path.join(dir, file), shim.content, { mode: 0o755 });
|
|
83
|
+
fs.chmodSync(path.join(dir, file), 0o755);
|
|
84
|
+
}
|
|
85
|
+
const keep = new Set(rendered.map((shim) => shim.file));
|
|
86
|
+
for (const name of listManagedShims(dir))
|
|
87
|
+
if (!keep.has(name))
|
|
88
|
+
fs.unlinkSync(path.join(dir, name));
|
|
89
|
+
return written;
|
|
90
|
+
}
|
|
91
|
+
/** Delete managed shims, then the directory if nothing else is in it; returns files removed. */
|
|
92
|
+
export function removeShims(dir) {
|
|
93
|
+
const removed = listManagedShims(dir);
|
|
94
|
+
for (const name of removed)
|
|
95
|
+
fs.unlinkSync(path.join(dir, name));
|
|
96
|
+
try {
|
|
97
|
+
if (fs.readdirSync(dir).length === 0)
|
|
98
|
+
fs.rmdirSync(dir);
|
|
99
|
+
}
|
|
100
|
+
catch { /* already gone */ }
|
|
101
|
+
return removed;
|
|
102
|
+
}
|
|
103
|
+
/** Re-point existing shims at the running node and entry (e.g. after a bundled Node upgrade). */
|
|
104
|
+
export function refreshShims(dir, rendered) {
|
|
105
|
+
if (listManagedShims(dir).length === 0)
|
|
106
|
+
return [];
|
|
107
|
+
return writeShims(dir, rendered);
|
|
108
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The user's last explicit choice; `removed` keeps the server from adding the command back. */
|
|
2
|
+
export type TerminalCliState = 'installed' | 'removed';
|
|
3
|
+
export declare const terminalCliStateFile: (home: string) => string;
|
|
4
|
+
export declare function readTerminalCliState(home: string): TerminalCliState | null;
|
|
5
|
+
export declare function writeTerminalCliState(home: string, state: TerminalCliState): void;
|
|
6
|
+
/** The desktop app's private install: the server package lives in `<home>/runtime/prefix`. */
|
|
7
|
+
export declare function isManagedRuntimeInstall(home: string, installRoot: string, platform: NodeJS.Platform): boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { npmPrefixFromInstallRoot } from '../../../core/utils.js';
|
|
4
|
+
export const terminalCliStateFile = (home) => path.join(home, 'runtime', 'terminal-cli.json');
|
|
5
|
+
export function readTerminalCliState(home) {
|
|
6
|
+
try {
|
|
7
|
+
const state = JSON.parse(fs.readFileSync(terminalCliStateFile(home), 'utf8'))?.state;
|
|
8
|
+
return state === 'installed' || state === 'removed' ? state : null;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function writeTerminalCliState(home, state) {
|
|
15
|
+
const file = terminalCliStateFile(home);
|
|
16
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
17
|
+
fs.writeFileSync(file, `${JSON.stringify({ state, updated_at: new Date().toISOString() }, null, 2)}\n`);
|
|
18
|
+
}
|
|
19
|
+
function canonical(dir, platform) {
|
|
20
|
+
let resolved = dir;
|
|
21
|
+
try {
|
|
22
|
+
resolved = fs.realpathSync(dir);
|
|
23
|
+
}
|
|
24
|
+
catch { /* compare the literal path */ }
|
|
25
|
+
const p = platform === 'win32' ? path.win32 : path.posix;
|
|
26
|
+
const normalized = p.normalize(resolved).replace(/[\\/]+$/, '');
|
|
27
|
+
return platform === 'win32' ? normalized.toLowerCase() : normalized;
|
|
28
|
+
}
|
|
29
|
+
/** The desktop app's private install: the server package lives in `<home>/runtime/prefix`. */
|
|
30
|
+
export function isManagedRuntimeInstall(home, installRoot, platform) {
|
|
31
|
+
const prefix = npmPrefixFromInstallRoot(installRoot, '@cortex-agent/server', platform);
|
|
32
|
+
if (!prefix)
|
|
33
|
+
return false;
|
|
34
|
+
const p = platform === 'win32' ? path.win32 : path.posix;
|
|
35
|
+
return canonical(prefix, platform) === canonical(p.join(home, 'runtime', 'prefix'), platform);
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PathRegistrar } from './registrar.js';
|
|
2
|
+
export declare const USER_PATH_TARGET = "HKCU\\Environment\\Path";
|
|
3
|
+
/** Prepend `dir` unless an equivalent entry exists; `null` means the value is absent. */
|
|
4
|
+
export declare function addUserPathEntry(raw: string | null, dir: string): string;
|
|
5
|
+
/** Drop `dir`, leaving every other byte of the value as it was. */
|
|
6
|
+
export declare function removeUserPathEntry(raw: string | null, dir: string): string | null;
|
|
7
|
+
/** Null when the user Path value does not exist. */
|
|
8
|
+
export declare function readUserPath(): string | null;
|
|
9
|
+
export declare function writeUserPath(value: string | null): void;
|
|
10
|
+
export declare function windowsRegistrar(io?: {
|
|
11
|
+
read: typeof readUserPath;
|
|
12
|
+
write: typeof writeUserPath;
|
|
13
|
+
}): PathRegistrar;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { isChanged } from './registrar.js';
|
|
4
|
+
export const USER_PATH_TARGET = 'HKCU\\Environment\\Path';
|
|
5
|
+
const entryKey = (entry) => path.win32.normalize(entry.trim()).replace(/\\+$/, '').toLowerCase();
|
|
6
|
+
const matches = (entry, dir) => entry.trim() !== '' && entryKey(entry) === entryKey(dir);
|
|
7
|
+
/** Prepend `dir` unless an equivalent entry exists; `null` means the value is absent. */
|
|
8
|
+
export function addUserPathEntry(raw, dir) {
|
|
9
|
+
if (!raw)
|
|
10
|
+
return dir;
|
|
11
|
+
if (raw.split(';').some((entry) => matches(entry, dir)))
|
|
12
|
+
return raw;
|
|
13
|
+
return `${dir};${raw}`;
|
|
14
|
+
}
|
|
15
|
+
/** Drop `dir`, leaving every other byte of the value as it was. */
|
|
16
|
+
export function removeUserPathEntry(raw, dir) {
|
|
17
|
+
if (raw === null)
|
|
18
|
+
return null;
|
|
19
|
+
const entries = raw.split(';');
|
|
20
|
+
const kept = entries.filter((entry) => !matches(entry, dir));
|
|
21
|
+
return kept.length === entries.length ? raw : kept.join(';');
|
|
22
|
+
}
|
|
23
|
+
// Read and write the raw (unexpanded) value and keep its registry kind, so `%USERPROFILE%`-style
|
|
24
|
+
// entries survive; then broadcast WM_SETTINGCHANGE so new terminals pick the change up.
|
|
25
|
+
const READ_SCRIPT = `
|
|
26
|
+
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
|
27
|
+
$k = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey('Environment')
|
|
28
|
+
if ($k -and ($k.GetValueNames() -contains 'Path')) { [Console]::Out.Write('=' + $k.GetValue('Path', '', 'DoNotExpandEnvironmentNames')) }`;
|
|
29
|
+
const WRITE_SCRIPT = `
|
|
30
|
+
$k = [Microsoft.Win32.Registry]::CurrentUser.CreateSubKey('Environment')
|
|
31
|
+
$kind = [Microsoft.Win32.RegistryValueKind]::ExpandString
|
|
32
|
+
if ($k.GetValueNames() -contains 'Path') { $kind = $k.GetValueKind('Path') }
|
|
33
|
+
if ($env:CORTEX_USER_PATH) { $k.SetValue('Path', $env:CORTEX_USER_PATH, $kind) } else { $k.DeleteValue('Path', $false) }
|
|
34
|
+
Add-Type -Namespace CortexEnv -Name Native -MemberDefinition '[DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr SendMessageTimeout(IntPtr h, uint m, UIntPtr w, string l, uint f, uint t, out UIntPtr r);'
|
|
35
|
+
$r = [UIntPtr]::Zero
|
|
36
|
+
[void][CortexEnv.Native]::SendMessageTimeout([IntPtr]0xffff, 0x1A, [UIntPtr]::Zero, 'Environment', 2, 5000, [ref]$r)`;
|
|
37
|
+
function powershell(script, extraEnv = {}) {
|
|
38
|
+
const result = spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', script], {
|
|
39
|
+
encoding: 'utf8',
|
|
40
|
+
windowsHide: true,
|
|
41
|
+
env: { ...process.env, ...extraEnv },
|
|
42
|
+
});
|
|
43
|
+
if (result.status !== 0)
|
|
44
|
+
throw new Error(`powershell failed: ${(result.stderr || String(result.error ?? '')).trim()}`);
|
|
45
|
+
return result.stdout;
|
|
46
|
+
}
|
|
47
|
+
/** Null when the user Path value does not exist. */
|
|
48
|
+
export function readUserPath() {
|
|
49
|
+
const out = powershell(READ_SCRIPT);
|
|
50
|
+
return out.startsWith('=') ? out.slice(1) : null;
|
|
51
|
+
}
|
|
52
|
+
export function writeUserPath(value) {
|
|
53
|
+
powershell(WRITE_SCRIPT, { CORTEX_USER_PATH: value ?? '' });
|
|
54
|
+
}
|
|
55
|
+
export function windowsRegistrar(io = { read: readUserPath, write: writeUserPath }) {
|
|
56
|
+
return {
|
|
57
|
+
plan: (dir, mode) => {
|
|
58
|
+
const before = io.read();
|
|
59
|
+
const after = mode === 'add' ? addUserPathEntry(before, dir) : removeUserPathEntry(before, dir);
|
|
60
|
+
return [{ target: USER_PATH_TARGET, before, after }];
|
|
61
|
+
},
|
|
62
|
+
apply: (changes) => {
|
|
63
|
+
for (const change of changes.filter(isChanged))
|
|
64
|
+
io.write(change.after);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -24,7 +24,7 @@ async function assembleTranscript(deps, sessionId) {
|
|
|
24
24
|
return null;
|
|
25
25
|
// A worker's interim reply is shown in its lead's web chat only; the TUI replays the turns.
|
|
26
26
|
const messages = hist.events.flatMap((e) => {
|
|
27
|
-
if (e.type === 'worker-progress')
|
|
27
|
+
if (e.type === 'worker-progress' || e.type === 'thinking')
|
|
28
28
|
return [];
|
|
29
29
|
return [e.type === 'tool'
|
|
30
30
|
? { role: 'tool', text: '', toolName: e.toolName ?? '', toolInput: e.toolInput ?? '' }
|
|
@@ -12,7 +12,7 @@ export interface TuiSessionDeps {
|
|
|
12
12
|
kind: 'local' | 'scheduled';
|
|
13
13
|
projectId: string;
|
|
14
14
|
label?: string | null;
|
|
15
|
-
|
|
15
|
+
selection?: import('../agents/engine-selection.js').EngineSelection | null;
|
|
16
16
|
}): Promise<void>;
|
|
17
17
|
};
|
|
18
18
|
conversationLedger: {
|
|
@@ -30,7 +30,7 @@ export interface TuiSessionDeps {
|
|
|
30
30
|
conversationHistory: {
|
|
31
31
|
getHistory(sessionId: string): Promise<{
|
|
32
32
|
events: Array<{
|
|
33
|
-
type: 'user' | 'assistant' | 'tool' | 'interaction' | 'worker-progress';
|
|
33
|
+
type: 'user' | 'assistant' | 'thinking' | 'tool' | 'interaction' | 'worker-progress';
|
|
34
34
|
text?: string;
|
|
35
35
|
toolName?: string;
|
|
36
36
|
toolInput?: string;
|
|
@@ -74,9 +74,6 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
74
74
|
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
75
75
|
input: {
|
|
76
76
|
projectId?: string;
|
|
77
|
-
browser?: {
|
|
78
|
-
device: string;
|
|
79
|
-
};
|
|
80
77
|
};
|
|
81
78
|
output: import("./types.js").SessionsCreateReturn;
|
|
82
79
|
meta: object;
|
|
@@ -110,14 +107,6 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
110
107
|
output: import("./types.js").SessionsCompactReturn;
|
|
111
108
|
meta: object;
|
|
112
109
|
}>;
|
|
113
|
-
setProfile: import("@trpc/server").TRPCMutationProcedure<{
|
|
114
|
-
input: {
|
|
115
|
-
sessionId: string;
|
|
116
|
-
profileName: string;
|
|
117
|
-
};
|
|
118
|
-
output: import("./types.js").SessionsSetProfileReturn;
|
|
119
|
-
meta: object;
|
|
120
|
-
}>;
|
|
121
110
|
setAgent: import("@trpc/server").TRPCMutationProcedure<{
|
|
122
111
|
input: {
|
|
123
112
|
sessionId: string;
|
|
@@ -129,13 +118,7 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
129
118
|
setSelection: import("@trpc/server").TRPCMutationProcedure<{
|
|
130
119
|
input: {
|
|
131
120
|
sessionId: string;
|
|
132
|
-
|
|
133
|
-
selection?: {
|
|
134
|
-
model?: string;
|
|
135
|
-
provider?: string;
|
|
136
|
-
thinking?: string;
|
|
137
|
-
mode?: string;
|
|
138
|
-
};
|
|
121
|
+
selection: import("./types.js").EngineSelection;
|
|
139
122
|
};
|
|
140
123
|
output: import("./types.js").SessionsSetSelectionReturn;
|
|
141
124
|
meta: object;
|
|
@@ -143,17 +126,8 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
143
126
|
createAndSend: import("@trpc/server").TRPCMutationProcedure<{
|
|
144
127
|
input: {
|
|
145
128
|
projectId: string;
|
|
146
|
-
profileName?: string;
|
|
147
129
|
agentName?: string;
|
|
148
|
-
selection?:
|
|
149
|
-
model?: string;
|
|
150
|
-
provider?: string;
|
|
151
|
-
thinking?: string;
|
|
152
|
-
mode?: string;
|
|
153
|
-
};
|
|
154
|
-
browser?: {
|
|
155
|
-
device: string;
|
|
156
|
-
};
|
|
130
|
+
selection?: import("./types.js").EngineSelection;
|
|
157
131
|
text: string;
|
|
158
132
|
draftUploadId?: string;
|
|
159
133
|
attachments?: {
|
|
@@ -246,6 +220,15 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
246
220
|
output: import("./types.js").SessionsRewindReturn;
|
|
247
221
|
meta: object;
|
|
248
222
|
}>;
|
|
223
|
+
resolveMedia: import("@trpc/server").TRPCMutationProcedure<{
|
|
224
|
+
input: {
|
|
225
|
+
sessionId: string;
|
|
226
|
+
ts: string;
|
|
227
|
+
src: string;
|
|
228
|
+
};
|
|
229
|
+
output: import("./inline-media-types.js").ResolveMediaResult;
|
|
230
|
+
meta: object;
|
|
231
|
+
}>;
|
|
249
232
|
}>>;
|
|
250
233
|
schedules: import("@trpc/server").TRPCBuiltRouter<{
|
|
251
234
|
ctx: object;
|
|
@@ -287,7 +270,7 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
287
270
|
type: "daily" | "interval" | "once" | "weekly";
|
|
288
271
|
message: string;
|
|
289
272
|
projectId?: string;
|
|
290
|
-
|
|
273
|
+
selection?: import("./types.js").EngineSelection;
|
|
291
274
|
intervalMs?: number;
|
|
292
275
|
time?: string;
|
|
293
276
|
dayOfWeek?: number;
|
|
@@ -301,7 +284,7 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
301
284
|
scheduleId: string;
|
|
302
285
|
message?: string;
|
|
303
286
|
projectId?: string;
|
|
304
|
-
|
|
287
|
+
selection?: import("./types.js").EngineSelection;
|
|
305
288
|
intervalMs?: number;
|
|
306
289
|
time?: string;
|
|
307
290
|
dayOfWeek?: number;
|
|
@@ -571,11 +554,6 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
571
554
|
daily_usd: number;
|
|
572
555
|
monthly_usd: number;
|
|
573
556
|
};
|
|
574
|
-
} | {
|
|
575
|
-
section: "profiles";
|
|
576
|
-
value: {
|
|
577
|
-
defaultProfile: string;
|
|
578
|
-
};
|
|
579
557
|
} | {
|
|
580
558
|
section: "settings";
|
|
581
559
|
value: Record<string, string | number | boolean | string[]>;
|
|
@@ -621,55 +599,55 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
621
599
|
meta: object;
|
|
622
600
|
}>;
|
|
623
601
|
}>>;
|
|
624
|
-
|
|
602
|
+
models: import("@trpc/server").TRPCBuiltRouter<{
|
|
625
603
|
ctx: object;
|
|
626
604
|
meta: object;
|
|
627
605
|
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
628
606
|
transformer: false;
|
|
629
607
|
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
630
|
-
|
|
631
|
-
input:
|
|
632
|
-
|
|
633
|
-
backend?: "claude" | "pi";
|
|
634
|
-
mode?: string;
|
|
635
|
-
provider?: string;
|
|
636
|
-
thinking?: string;
|
|
637
|
-
extraOption?: Record<string, string>;
|
|
638
|
-
name: string;
|
|
639
|
-
};
|
|
640
|
-
output: import("./types.js").ProfilesCreateReturn;
|
|
608
|
+
catalog: import("@trpc/server").TRPCQueryProcedure<{
|
|
609
|
+
input: Record<string, never>;
|
|
610
|
+
output: import("./types.js").ModelCatalogSnapshot;
|
|
641
611
|
meta: object;
|
|
642
612
|
}>;
|
|
643
|
-
|
|
613
|
+
favorites: import("@trpc/server").TRPCBuiltRouter<{
|
|
614
|
+
ctx: object;
|
|
615
|
+
meta: object;
|
|
616
|
+
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
617
|
+
transformer: false;
|
|
618
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
619
|
+
add: import("@trpc/server").TRPCMutationProcedure<{
|
|
620
|
+
input: {
|
|
621
|
+
backend: "claude" | "pi";
|
|
622
|
+
provider?: string;
|
|
623
|
+
model: string;
|
|
624
|
+
};
|
|
625
|
+
output: import("./types.js").ModelsMutationReturn;
|
|
626
|
+
meta: object;
|
|
627
|
+
}>;
|
|
628
|
+
remove: import("@trpc/server").TRPCMutationProcedure<{
|
|
629
|
+
input: {
|
|
630
|
+
backend: "claude" | "pi";
|
|
631
|
+
provider?: string;
|
|
632
|
+
model: string;
|
|
633
|
+
};
|
|
634
|
+
output: import("./types.js").ModelsMutationReturn;
|
|
635
|
+
meta: object;
|
|
636
|
+
}>;
|
|
637
|
+
}>>;
|
|
638
|
+
setDefault: import("@trpc/server").TRPCMutationProcedure<{
|
|
644
639
|
input: {
|
|
645
|
-
|
|
646
|
-
backend?: "claude" | "pi";
|
|
647
|
-
mode?: string;
|
|
648
|
-
provider?: string;
|
|
649
|
-
thinking?: string;
|
|
650
|
-
extraOption?: Record<string, string>;
|
|
651
|
-
name: string;
|
|
640
|
+
selection: import("./types.js").EngineSelection;
|
|
652
641
|
};
|
|
653
|
-
output: import("./types.js").
|
|
642
|
+
output: import("./types.js").ModelsMutationReturn;
|
|
654
643
|
meta: object;
|
|
655
644
|
}>;
|
|
656
|
-
|
|
645
|
+
setThinking: import("@trpc/server").TRPCMutationProcedure<{
|
|
657
646
|
input: {
|
|
658
|
-
|
|
647
|
+
ref: import("./types.js").ModelRef;
|
|
648
|
+
thinking: string | null;
|
|
659
649
|
};
|
|
660
|
-
output: import("./types.js").
|
|
661
|
-
meta: object;
|
|
662
|
-
}>;
|
|
663
|
-
}>>;
|
|
664
|
-
models: import("@trpc/server").TRPCBuiltRouter<{
|
|
665
|
-
ctx: object;
|
|
666
|
-
meta: object;
|
|
667
|
-
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
668
|
-
transformer: false;
|
|
669
|
-
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
670
|
-
catalog: import("@trpc/server").TRPCQueryProcedure<{
|
|
671
|
-
input: Record<string, never>;
|
|
672
|
-
output: import("./types.js").ModelCatalogSnapshot;
|
|
650
|
+
output: import("./types.js").ModelsMutationReturn;
|
|
673
651
|
meta: object;
|
|
674
652
|
}>;
|
|
675
653
|
}>>;
|
|
@@ -2,7 +2,7 @@ import { platformSettingsInput } from '../../core/platform-settings-spec.js';
|
|
|
2
2
|
import { TRPCError } from '@trpc/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { router, publicProcedure } from './trpc.js';
|
|
5
|
-
import { projectsListInput, projectsCreateInput, sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsCreateInput, sessionsSendInput, sessionsCancelInput, sessionsCompactInput,
|
|
5
|
+
import { projectsListInput, projectsCreateInput, sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsCreateInput, sessionsSendInput, sessionsCancelInput, sessionsCompactInput, sessionsSetAgentInput, sessionsSetSelectionInput, sessionsCreateAndSendInput, sessionsMarkReadInput, sessionsSetStarredInput, sessionsRenameInput, sessionsMarkManyReadInput, sessionsAnswerQuestionInput, sessionsRespondPlanInput, sessionsRespondDecisionInput, sessionsCancelResumeInput, sessionsRewindInput, sessionsResolveMediaInput, sessionsPendingInteractionInput, schedulesListInput, boardsListInput, boardsGetInput, boardsDecisionsInput, boardsStyleInput, executionsListInput, waitpointsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, approvalsApproveInput, approvalsRejectInput, approvalsRequestInput, issuesListInput, issueActionInput, notesListInput, noteAddInput, noteUpdateInput, noteSetCompletedInput, noteActionInput, notesClearCompletedInput, costSummaryInput, executionsCancelInput, waitpointsCancelInput, scheduleActionInput, scheduleAddInput, scheduleUpdateInput, configGetInput, configSetInput, configSetProviderRateLimitPolicyInput, authStatusInput, authFlowStateInput, authStartLoginInput, authRespondPromptInput, authCancelFlowInput, authLogoutInput, authSyncGatewayInput, authCustomProvidersInput, authUpsertCustomProviderInput, authRemoveCustomProviderInput, usageSharingGetInput, usageSharingSetInput, hooksListInput, hooksCreateInput, hooksUpdateInput, hooksSetEnabledInput, hooksRemoveInput, hooksTestInput, modelsFavoriteInput, modelsSetDefaultInput, modelsSetThinkingInput, modelsCatalogInput, machinesListInput, machineDetailInput, skillsListInput, skillsSessionInput, pluginsListInput, pluginsAssignInput, pluginsSkillFileInput, pluginsSkillWriteInput, pluginsSkillCreateInput, pluginsSkillMoveInput, pluginsSkillRemoveInput, pluginsSkillRevertInput, pluginsCreateInput, pluginsRemoveInput, pluginsConvertInput, pluginsMcpReadInput, pluginsMcpWriteInput, environmentsListInput, environmentsGetInput, environmentsValidateInput, environmentsSaveInput, environmentsDeleteInput, environmentsSavePromptInput, systemDaemonStatusInput, systemRateLimitStatusInput, systemUsageStatusInput, systemNoticesInput, systemRestartInput, systemClearRateLimitInput, systemRefreshUsageInput, systemRedeemUsageResetInput, systemUpdateStatusInput, systemCheckUpdateInput, systemApplyUpdateInput, systemSkipUpdateInput, } from './input-schemas.js';
|
|
6
6
|
// ── Subscribe filter input (no keyed schema for subscribe; router-local) ──
|
|
7
7
|
const subscribeFilterInput = z.object({
|
|
8
8
|
events: z.array(z.string()),
|
|
@@ -76,7 +76,6 @@ function sessionsRouter(service) {
|
|
|
76
76
|
send: makeMutation(service, 'sessions.send', sessionsSendInput),
|
|
77
77
|
cancel: makeMutation(service, 'sessions.cancel', sessionsCancelInput),
|
|
78
78
|
compact: makeMutation(service, 'sessions.compact', sessionsCompactInput),
|
|
79
|
-
setProfile: makeMutation(service, 'sessions.setProfile', sessionsSetProfileInput),
|
|
80
79
|
setAgent: makeMutation(service, 'sessions.setAgent', sessionsSetAgentInput),
|
|
81
80
|
setSelection: makeMutation(service, 'sessions.setSelection', sessionsSetSelectionInput),
|
|
82
81
|
createAndSend: makeMutation(service, 'sessions.createAndSend', sessionsCreateAndSendInput),
|
|
@@ -89,6 +88,7 @@ function sessionsRouter(service) {
|
|
|
89
88
|
respondDecision: makeMutation(service, 'sessions.respondDecision', sessionsRespondDecisionInput),
|
|
90
89
|
cancelResume: makeMutation(service, 'sessions.cancelResume', sessionsCancelResumeInput),
|
|
91
90
|
rewind: makeMutation(service, 'sessions.rewind', sessionsRewindInput),
|
|
91
|
+
resolveMedia: makeMutation(service, 'sessions.resolveMedia', sessionsResolveMediaInput),
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
function schedulesRouter(service) {
|
|
@@ -163,19 +163,16 @@ function hooksRouter(service) {
|
|
|
163
163
|
test: makeMutation(service, 'hooks.test', hooksTestInput),
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
//
|
|
167
|
-
function profilesRouter(service) {
|
|
168
|
-
return router({
|
|
169
|
-
create: makeMutation(service, 'profiles.create', profilesCreateInput),
|
|
170
|
-
update: makeMutation(service, 'profiles.update', profilesUpdateInput),
|
|
171
|
-
remove: makeMutation(service, 'profiles.remove', profilesRemoveInput),
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
// The engine catalog the profile editor picks from. Read-only and host-wide, so it is its own
|
|
175
|
-
// router rather than a field of config.get — see query/models.ts for why the cost is isolated.
|
|
166
|
+
// Model catalog, favorites and the default engine choice.
|
|
176
167
|
function modelsRouter(service) {
|
|
177
168
|
return router({
|
|
178
169
|
catalog: makeQuery(service, 'models.catalog', modelsCatalogInput),
|
|
170
|
+
favorites: router({
|
|
171
|
+
add: makeMutation(service, 'models.favorites.add', modelsFavoriteInput),
|
|
172
|
+
remove: makeMutation(service, 'models.favorites.remove', modelsFavoriteInput),
|
|
173
|
+
}),
|
|
174
|
+
setDefault: makeMutation(service, 'models.setDefault', modelsSetDefaultInput),
|
|
175
|
+
setThinking: makeMutation(service, 'models.setThinking', modelsSetThinkingInput),
|
|
179
176
|
});
|
|
180
177
|
}
|
|
181
178
|
function authRouter(service) {
|
|
@@ -294,7 +291,6 @@ export function createAppRouter(service) {
|
|
|
294
291
|
notes: notesRouter(service),
|
|
295
292
|
cost: costRouter(service),
|
|
296
293
|
config: configRouter(service),
|
|
297
|
-
profiles: profilesRouter(service),
|
|
298
294
|
models: modelsRouter(service),
|
|
299
295
|
auth: authRouter(service),
|
|
300
296
|
usageSharing: usageSharingRouter(service),
|
|
@@ -18,6 +18,8 @@ export class AssistantSnapshots {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
append(event) {
|
|
21
|
+
if (event.kind === 'thinking')
|
|
22
|
+
return;
|
|
21
23
|
const previous = this.active.get(event.sessionId);
|
|
22
24
|
const sameBlock = previous?.blockId === event.blockId;
|
|
23
25
|
if (sameBlock && event.seq <= previous.seq)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { EngineSelection, ModelRef } from '../agents/engine-selection.js';
|
|
3
|
+
import type { engineSelectionInput, modelRefInput, mutateInputSchemas, queryInputSchemas } from './input-schemas.js';
|
|
4
|
+
import type { MutateArgs, MutateReturnMap, QueryReturnMap } from './types.js';
|
|
5
|
+
type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
|
|
6
|
+
type Assert<T extends true> = T;
|
|
7
|
+
export type EngineSelectionInputParity = Assert<Equal<z.input<typeof engineSelectionInput>, EngineSelection>>;
|
|
8
|
+
export type EngineSelectionOutputParity = Assert<Equal<z.output<typeof engineSelectionInput>, EngineSelection>>;
|
|
9
|
+
export type ModelRefParity = Assert<Equal<z.output<typeof modelRefInput>, ModelRef>>;
|
|
10
|
+
export type SelectionMutationParity = Assert<Equal<MutateArgs<'sessions.setSelection'>, {
|
|
11
|
+
sessionId: string;
|
|
12
|
+
selection: EngineSelection;
|
|
13
|
+
}>>;
|
|
14
|
+
export type DefaultMutationParity = Assert<Equal<MutateArgs<'models.setDefault'>, {
|
|
15
|
+
selection: EngineSelection;
|
|
16
|
+
}>>;
|
|
17
|
+
export type QueryParity = Assert<Equal<keyof typeof queryInputSchemas, keyof QueryReturnMap>>;
|
|
18
|
+
export type MutationParity = Assert<Equal<keyof typeof mutateInputSchemas, keyof MutateReturnMap>>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Expected media failures stay in the mutation payload, not the tRPC transport error. */
|
|
2
|
+
export type InlineMediaErrorCode = 'offline' | 'not_found' | 'unsupported' | 'too_large' | 'load_failed';
|
|
3
|
+
export interface ResolveMediaInput {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
/** Exact timestamp shared by the persisted assistant row and its live event. */
|
|
6
|
+
ts: string;
|
|
7
|
+
src: string;
|
|
8
|
+
}
|
|
9
|
+
export type ResolveMediaResult = {
|
|
10
|
+
path: string;
|
|
11
|
+
name: string;
|
|
12
|
+
kind: 'image' | 'video';
|
|
13
|
+
} | {
|
|
14
|
+
error: {
|
|
15
|
+
code: InlineMediaErrorCode;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|