@cortex-agent/server 2026.10.15-2 → 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 +70 -31
- package/defaults/board/board.css +140 -62
- package/defaults/board/scaffold.html +36 -13
- 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 +0 -4
- package/dist/agent-adapter/claude/session-options.js +0 -9
- package/dist/agent-adapter/claude/spawn-args.d.ts +0 -3
- package/dist/agent-adapter/claude/spawn-args.js +2 -5
- 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/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/session-options.d.ts +2 -6
- package/dist/agent-adapter/pi/session-options.js +2 -11
- package/dist/agent-adapter/run-events.d.ts +10 -0
- package/dist/agent-adapter/run-events.js +2 -0
- package/dist/agent-adapter/types.d.ts +1 -1
- package/dist/client-bundle/manifest.json +1 -1
- package/dist/core/locales/en.d.ts +1 -0
- package/dist/core/locales/slices/commands.d.ts +1 -0
- package/dist/core/locales/slices/commands.js +2 -0
- package/dist/core/settings-spec.d.ts +25 -0
- package/dist/core/settings-spec.js +34 -0
- package/dist/domain/agents/engine-selection.js +1 -1
- 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.js +0 -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/ui-file.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/builders.d.ts +2 -2
- package/dist/domain/runs/builders.js +2 -3
- package/dist/domain/runs/engine-spec.d.ts +5 -0
- package/dist/domain/runs/engine-spec.js +1 -2
- package/dist/domain/runs/request.d.ts +0 -1
- package/dist/domain/sessions/session-lifecycle.d.ts +0 -4
- package/dist/domain/sessions/session-lifecycle.js +1 -1
- 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 +1 -1
- package/dist/domain/ui-service/app-router.d.ts +17 -6
- package/dist/domain/ui-service/app-router.js +3 -1
- package/dist/domain/ui-service/assistant-snapshots.js +2 -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 +17 -17
- package/dist/domain/ui-service/input-schemas.js +9 -9
- package/dist/domain/ui-service/mutate/models.d.ts +3 -0
- package/dist/domain/ui-service/mutate/models.js +21 -2
- 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.js +1 -4
- package/dist/domain/ui-service/query/sessions.js +1 -1
- package/dist/domain/ui-service/types.d.ts +8 -10
- package/dist/domain/ui-service/ui-service.d.ts +9 -6
- package/dist/domain/ui-service/ui-service.js +4 -1
- package/dist/entry/app.js +23 -0
- 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 +30 -0
- package/dist/entry/cli.js +2 -0
- package/dist/entry/daemon.js +2 -0
- package/dist/entry/path-cli.d.ts +4 -0
- package/dist/entry/path-cli.js +65 -0
- package/dist/entry/shutdown.js +7 -0
- package/dist/entry/start-ui-http.js +8 -0
- package/dist/entry/ui-service-wiring.js +2 -0
- package/dist/events/event-types.d.ts +2 -1
- package/dist/orchestration/agent-runner.d.ts +2 -2
- package/dist/orchestration/agent-runner.js +6 -6
- 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 +4 -7
- package/dist/orchestration/conversation-request.js +1 -2
- package/dist/orchestration/delta-coalescer.d.ts +4 -2
- package/dist/orchestration/delta-coalescer.js +5 -5
- package/dist/orchestration/edit-retry.js +3 -6
- 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/routing/commands/usage-format.js +3 -0
- package/dist/orchestration/routing/webhook.js +4 -0
- 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/transcript-sink.d.ts +6 -0
- package/dist/orchestration/transcript-sink.js +21 -2
- package/dist/orchestration/turn/turn-prep.d.ts +0 -8
- package/dist/orchestration/turn/turn-prep.js +0 -51
- package/dist/orchestration/turn/turn.js +4 -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-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/session-registry-journal.d.ts +0 -8
- package/dist/store/session-registry-journal.js +5 -17
- package/dist/store/session-registry-repo.d.ts +2 -3
- package/dist/store/session-registry-repo.js +0 -2
- package/package.json +4 -2
- 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-DaViXAg-.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/web/dist/assets/index-Cgx3gdHV.css +0 -1
- package/web/dist/assets/index-CpZWBVHr.js +0 -494
|
@@ -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 ?? '' }
|
|
@@ -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;
|
|
@@ -131,9 +128,6 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
131
128
|
projectId: string;
|
|
132
129
|
agentName?: string;
|
|
133
130
|
selection?: import("./types.js").EngineSelection;
|
|
134
|
-
browser?: {
|
|
135
|
-
device: string;
|
|
136
|
-
};
|
|
137
131
|
text: string;
|
|
138
132
|
draftUploadId?: string;
|
|
139
133
|
attachments?: {
|
|
@@ -226,6 +220,15 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
226
220
|
output: import("./types.js").SessionsRewindReturn;
|
|
227
221
|
meta: object;
|
|
228
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
|
+
}>;
|
|
229
232
|
}>>;
|
|
230
233
|
schedules: import("@trpc/server").TRPCBuiltRouter<{
|
|
231
234
|
ctx: object;
|
|
@@ -639,6 +642,14 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
|
|
|
639
642
|
output: import("./types.js").ModelsMutationReturn;
|
|
640
643
|
meta: object;
|
|
641
644
|
}>;
|
|
645
|
+
setThinking: import("@trpc/server").TRPCMutationProcedure<{
|
|
646
|
+
input: {
|
|
647
|
+
ref: import("./types.js").ModelRef;
|
|
648
|
+
thinking: string | null;
|
|
649
|
+
};
|
|
650
|
+
output: import("./types.js").ModelsMutationReturn;
|
|
651
|
+
meta: object;
|
|
652
|
+
}>;
|
|
642
653
|
}>>;
|
|
643
654
|
auth: import("@trpc/server").TRPCBuiltRouter<{
|
|
644
655
|
ctx: object;
|
|
@@ -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, sessionsSetAgentInput, sessionsSetSelectionInput, sessionsCreateAndSendInput, sessionsMarkReadInput, sessionsSetStarredInput, sessionsRenameInput, sessionsMarkManyReadInput, sessionsAnswerQuestionInput, sessionsRespondPlanInput, sessionsRespondDecisionInput, sessionsCancelResumeInput, sessionsRewindInput, 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, 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';
|
|
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()),
|
|
@@ -88,6 +88,7 @@ function sessionsRouter(service) {
|
|
|
88
88
|
respondDecision: makeMutation(service, 'sessions.respondDecision', sessionsRespondDecisionInput),
|
|
89
89
|
cancelResume: makeMutation(service, 'sessions.cancelResume', sessionsCancelResumeInput),
|
|
90
90
|
rewind: makeMutation(service, 'sessions.rewind', sessionsRewindInput),
|
|
91
|
+
resolveMedia: makeMutation(service, 'sessions.resolveMedia', sessionsResolveMediaInput),
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
function schedulesRouter(service) {
|
|
@@ -171,6 +172,7 @@ function modelsRouter(service) {
|
|
|
171
172
|
remove: makeMutation(service, 'models.favorites.remove', modelsFavoriteInput),
|
|
172
173
|
}),
|
|
173
174
|
setDefault: makeMutation(service, 'models.setDefault', modelsSetDefaultInput),
|
|
175
|
+
setThinking: makeMutation(service, 'models.setThinking', modelsSetThinkingInput),
|
|
174
176
|
});
|
|
175
177
|
}
|
|
176
178
|
function authRouter(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,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 {};
|
|
@@ -103,16 +103,8 @@ export declare const authRemoveCustomProviderInput: z.ZodObject<{
|
|
|
103
103
|
export declare const projectsCreateInput: z.ZodObject<{
|
|
104
104
|
name: z.ZodString;
|
|
105
105
|
}, z.core.$strip>;
|
|
106
|
-
/** Per-session browser opt-in. `device` names where Chrome runs; 'server' is the only value until
|
|
107
|
-
* the cortex-client reverse channel exists. Absent → the session gets no browser tools. */
|
|
108
|
-
export declare const sessionBrowserInput: z.ZodObject<{
|
|
109
|
-
device: z.ZodString;
|
|
110
|
-
}, z.core.$strip>;
|
|
111
106
|
export declare const sessionsCreateInput: z.ZodObject<{
|
|
112
107
|
projectId: z.ZodOptional<z.ZodString>;
|
|
113
|
-
browser: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
114
|
-
device: z.ZodString;
|
|
115
|
-
}, z.core.$strip>>>;
|
|
116
108
|
}, z.core.$strip>;
|
|
117
109
|
export declare const sessionsSendInput: z.ZodObject<{
|
|
118
110
|
sessionId: z.ZodString;
|
|
@@ -170,6 +162,12 @@ export declare const sessionsRespondDecisionInput: z.ZodObject<{
|
|
|
170
162
|
}>;
|
|
171
163
|
message: z.ZodOptional<z.ZodString>;
|
|
172
164
|
}, z.core.$strip>;
|
|
165
|
+
/** Message identity keys an immutable snapshot of this media source. */
|
|
166
|
+
export declare const sessionsResolveMediaInput: z.ZodObject<{
|
|
167
|
+
sessionId: z.ZodString;
|
|
168
|
+
ts: z.ZodString;
|
|
169
|
+
src: z.ZodString;
|
|
170
|
+
}, z.core.$strip>;
|
|
173
171
|
/** Args for `sessions.cancelResume`: decline the auto-resume promised when a rate limit
|
|
174
172
|
* interrupted this session's turn. */
|
|
175
173
|
export declare const sessionsCancelResumeInput: z.ZodObject<{
|
|
@@ -188,9 +186,6 @@ export declare const sessionsCreateAndSendInput: z.ZodObject<{
|
|
|
188
186
|
projectId: z.ZodString;
|
|
189
187
|
agentName: z.ZodOptional<z.ZodString>;
|
|
190
188
|
selection: z.ZodOptional<z.ZodType<EngineSelection, EngineSelection, z.core.$ZodTypeInternals<EngineSelection, EngineSelection>>>;
|
|
191
|
-
browser: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
192
|
-
device: z.ZodString;
|
|
193
|
-
}, z.core.$strip>>>;
|
|
194
189
|
text: z.ZodString;
|
|
195
190
|
draftUploadId: z.ZodOptional<z.ZodString>;
|
|
196
191
|
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -327,6 +322,11 @@ export declare const modelsFavoriteInput: z.ZodObject<{
|
|
|
327
322
|
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
328
323
|
model: z.ZodString;
|
|
329
324
|
}, z.core.$strict>;
|
|
325
|
+
type ModelsSetThinkingInput = {
|
|
326
|
+
ref: ModelRef;
|
|
327
|
+
thinking: string | null;
|
|
328
|
+
};
|
|
329
|
+
export declare const modelsSetThinkingInput: z.ZodType<ModelsSetThinkingInput, ModelsSetThinkingInput>;
|
|
330
330
|
export declare const modelsSetDefaultInput: z.ZodObject<{
|
|
331
331
|
selection: z.ZodType<EngineSelection, EngineSelection, z.core.$ZodTypeInternals<EngineSelection, EngineSelection>>;
|
|
332
332
|
}, z.core.$strict>;
|
|
@@ -602,9 +602,6 @@ export declare const mutateInputSchemas: {
|
|
|
602
602
|
}, z.core.$strip>;
|
|
603
603
|
'sessions.create': z.ZodObject<{
|
|
604
604
|
projectId: z.ZodOptional<z.ZodString>;
|
|
605
|
-
browser: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
606
|
-
device: z.ZodString;
|
|
607
|
-
}, z.core.$strip>>>;
|
|
608
605
|
}, z.core.$strip>;
|
|
609
606
|
'sessions.send': z.ZodObject<{
|
|
610
607
|
sessionId: z.ZodString;
|
|
@@ -640,9 +637,6 @@ export declare const mutateInputSchemas: {
|
|
|
640
637
|
projectId: z.ZodString;
|
|
641
638
|
agentName: z.ZodOptional<z.ZodString>;
|
|
642
639
|
selection: z.ZodOptional<z.ZodType<EngineSelection, EngineSelection, z.core.$ZodTypeInternals<EngineSelection, EngineSelection>>>;
|
|
643
|
-
browser: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
644
|
-
device: z.ZodString;
|
|
645
|
-
}, z.core.$strip>>>;
|
|
646
640
|
text: z.ZodString;
|
|
647
641
|
draftUploadId: z.ZodOptional<z.ZodString>;
|
|
648
642
|
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -698,6 +692,11 @@ export declare const mutateInputSchemas: {
|
|
|
698
692
|
turnIndex: z.ZodNumber;
|
|
699
693
|
text: z.ZodString;
|
|
700
694
|
}, z.core.$strip>;
|
|
695
|
+
'sessions.resolveMedia': z.ZodObject<{
|
|
696
|
+
sessionId: z.ZodString;
|
|
697
|
+
ts: z.ZodString;
|
|
698
|
+
src: z.ZodString;
|
|
699
|
+
}, z.core.$strip>;
|
|
701
700
|
'executions.cancel': z.ZodObject<{
|
|
702
701
|
executionId: z.ZodString;
|
|
703
702
|
}, z.core.$strip>;
|
|
@@ -967,6 +966,7 @@ export declare const mutateInputSchemas: {
|
|
|
967
966
|
'models.setDefault': z.ZodObject<{
|
|
968
967
|
selection: z.ZodType<EngineSelection, EngineSelection, z.core.$ZodTypeInternals<EngineSelection, EngineSelection>>;
|
|
969
968
|
}, z.core.$strict>;
|
|
969
|
+
'models.setThinking': z.ZodType<ModelsSetThinkingInput, ModelsSetThinkingInput, z.core.$ZodTypeInternals<ModelsSetThinkingInput, ModelsSetThinkingInput>>;
|
|
970
970
|
'plugins.assign': z.ZodObject<{
|
|
971
971
|
target: z.ZodObject<{
|
|
972
972
|
kind: z.ZodLiteral<"agent">;
|
|
@@ -107,16 +107,9 @@ export const authRemoveCustomProviderInput = z.object({
|
|
|
107
107
|
export const projectsCreateInput = z.object({
|
|
108
108
|
name: z.string(),
|
|
109
109
|
});
|
|
110
|
-
/** Per-session browser opt-in. `device` names where Chrome runs; 'server' is the only value until
|
|
111
|
-
* the cortex-client reverse channel exists. Absent → the session gets no browser tools. */
|
|
112
|
-
export const sessionBrowserInput = z.object({
|
|
113
|
-
device: z.string(),
|
|
114
|
-
});
|
|
115
110
|
export const sessionsCreateInput = z.object({
|
|
116
111
|
/** Project the new session belongs to. Omitted → the default project (handler fallback). */
|
|
117
112
|
projectId: z.string().optional(),
|
|
118
|
-
/** Opt in to browser control for this session. Omitted → no browser tools are loaded. */
|
|
119
|
-
browser: sessionBrowserInput.nullish(),
|
|
120
113
|
});
|
|
121
114
|
export const sessionsSendInput = z.object({
|
|
122
115
|
sessionId: z.string(),
|
|
@@ -186,6 +179,12 @@ export const sessionsRespondDecisionInput = z.object({
|
|
|
186
179
|
/** Required for explain/revise; ignored for approve. */
|
|
187
180
|
message: z.string().optional(),
|
|
188
181
|
});
|
|
182
|
+
/** Message identity keys an immutable snapshot of this media source. */
|
|
183
|
+
export const sessionsResolveMediaInput = z.object({
|
|
184
|
+
sessionId: z.string().regex(/^[\w-]+$/),
|
|
185
|
+
ts: z.string().min(1),
|
|
186
|
+
src: z.string().min(1),
|
|
187
|
+
});
|
|
189
188
|
/** Args for `sessions.cancelResume`: decline the auto-resume promised when a rate limit
|
|
190
189
|
* interrupted this session's turn. */
|
|
191
190
|
export const sessionsCancelResumeInput = z.object({
|
|
@@ -210,8 +209,6 @@ export const sessionsCreateAndSendInput = z.object({
|
|
|
210
209
|
agentName: z.string().min(1).optional(),
|
|
211
210
|
/** Complete engine choice applied before the first turn. Omitted → system default. */
|
|
212
211
|
selection: engineSelectionInput.optional(),
|
|
213
|
-
/** Opt in to browser control for this session. Omitted → no browser tools are loaded. */
|
|
214
|
-
browser: sessionBrowserInput.nullish(),
|
|
215
212
|
/** First user message text. */
|
|
216
213
|
text: z.string(),
|
|
217
214
|
/** Temporary upload directory id (draft mode). Attachments were uploaded under this id
|
|
@@ -417,6 +414,7 @@ export const modelsFavoriteInput = z.object({
|
|
|
417
414
|
provider: z.string().min(1).nullable().optional(),
|
|
418
415
|
model: z.string().min(1),
|
|
419
416
|
}).strict();
|
|
417
|
+
export const modelsSetThinkingInput = z.object({ ref: modelRefInput, thinking: z.string().nullable() }).strict();
|
|
420
418
|
export const modelsSetDefaultInput = z.object({ selection: engineSelectionInput }).strict();
|
|
421
419
|
const componentByteLength = (value) => new TextEncoder().encode(value).byteLength <= 255;
|
|
422
420
|
const isSafeComponent = (value) => value !== '.' && value !== '..'
|
|
@@ -642,6 +640,7 @@ export const mutateInputSchemas = {
|
|
|
642
640
|
'sessions.respondDecision': sessionsRespondDecisionInput,
|
|
643
641
|
'sessions.cancelResume': sessionsCancelResumeInput,
|
|
644
642
|
'sessions.rewind': sessionsRewindInput,
|
|
643
|
+
'sessions.resolveMedia': sessionsResolveMediaInput,
|
|
645
644
|
'executions.cancel': executionsCancelInput,
|
|
646
645
|
'waitpoints.cancel': waitpointsCancelInput,
|
|
647
646
|
'schedules.pause': scheduleActionInput,
|
|
@@ -678,6 +677,7 @@ export const mutateInputSchemas = {
|
|
|
678
677
|
'models.favorites.add': modelsFavoriteInput,
|
|
679
678
|
'models.favorites.remove': modelsFavoriteInput,
|
|
680
679
|
'models.setDefault': modelsSetDefaultInput,
|
|
680
|
+
'models.setThinking': modelsSetThinkingInput,
|
|
681
681
|
'plugins.assign': pluginsAssignInput,
|
|
682
682
|
'plugins.skillWrite': pluginsSkillWriteInput,
|
|
683
683
|
'plugins.skillCreate': pluginsSkillCreateInput,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { readGatewayYaml } from '../../../core/gateway-generator.js';
|
|
2
|
+
import { type EngineSelection, type ModelRef } from '../../agents/engine-selection.js';
|
|
2
3
|
import type { UiServiceDeps, Result, ModelsMutationReturn, MutateArgs } from '../types.js';
|
|
3
4
|
type GatewayReader = () => ReturnType<typeof readGatewayYaml>;
|
|
4
5
|
export declare function addFavorite(configDir: string, args: MutateArgs<'models.favorites.add'>): Promise<boolean>;
|
|
5
6
|
export declare function removeFavorite(configDir: string, args: MutateArgs<'models.favorites.remove'>): Promise<boolean>;
|
|
6
7
|
export declare function setDefaultModel(configDir: string, args: MutateArgs<'models.setDefault'>, readGateway?: GatewayReader): Promise<boolean>;
|
|
8
|
+
export declare function setModelThinking(configDir: string, args: MutateArgs<'models.setThinking'>, resolveSelection?: (ref: ModelRef) => EngineSelection): Promise<boolean>;
|
|
7
9
|
export declare function handleModelsFavoriteAdd(_deps: UiServiceDeps, args: MutateArgs<'models.favorites.add'>): Promise<Result<ModelsMutationReturn>>;
|
|
8
10
|
export declare function handleModelsFavoriteRemove(_deps: UiServiceDeps, args: MutateArgs<'models.favorites.remove'>): Promise<Result<ModelsMutationReturn>>;
|
|
9
11
|
export declare function handleModelsSetDefault(_deps: UiServiceDeps, args: MutateArgs<'models.setDefault'>): Promise<Result<ModelsMutationReturn>>;
|
|
12
|
+
export declare function handleModelsSetThinking(_deps: UiServiceDeps, args: MutateArgs<'models.setThinking'>): Promise<Result<ModelsMutationReturn>>;
|
|
10
13
|
export {};
|
|
@@ -6,8 +6,9 @@ import { readGatewayYaml } from '../../../core/gateway-generator.js';
|
|
|
6
6
|
import { modelKey, validateModelRef, validateEngineSelection, } from '../../agents/engine-selection.js';
|
|
7
7
|
import { GATEWAY_CONFIG_PATH } from '../../pi-providers/gateway-route-store.js';
|
|
8
8
|
import { modelsRepo, modelsWriteLock } from '../../../store/models-repo.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { selectionForModel } from '../../agents/models.js';
|
|
10
|
+
import { getModelMemory, rememberModelSelection } from '../../agents/config.js';
|
|
11
|
+
import { modelsFavoriteInput, modelsSetDefaultInput, modelsSetThinkingInput } from '../input-schemas.js';
|
|
11
12
|
function invalid(message) {
|
|
12
13
|
return Object.assign(new Error(message), { code: 'invalid-args' });
|
|
13
14
|
}
|
|
@@ -95,6 +96,21 @@ export async function setDefaultModel(configDir, args, readGateway = () => readG
|
|
|
95
96
|
return true;
|
|
96
97
|
});
|
|
97
98
|
}
|
|
99
|
+
export async function setModelThinking(configDir, args, resolveSelection = selectionForModel) {
|
|
100
|
+
const { ref, thinking } = validate(() => modelsSetThinkingInput.parse(args));
|
|
101
|
+
validate(() => validateModelRef(ref));
|
|
102
|
+
return modelsWriteLock.run(async () => {
|
|
103
|
+
const raw = await readModelsFile(configDir);
|
|
104
|
+
if (!raw.favorites.some(entry => modelKey(entry) === modelKey(ref)))
|
|
105
|
+
throw invalid('Model is not a favorite');
|
|
106
|
+
const selection = validate(() => ({ ...resolveSelection(ref), thinking }));
|
|
107
|
+
validate(() => validateEngineSelection(selection));
|
|
108
|
+
if (getModelMemory()[modelKey(ref)]?.thinking === thinking)
|
|
109
|
+
return false;
|
|
110
|
+
rememberModelSelection(selection);
|
|
111
|
+
return true;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
98
114
|
async function mutation(write) {
|
|
99
115
|
try {
|
|
100
116
|
return { ok: true, data: { changed: await write() } };
|
|
@@ -116,3 +132,6 @@ export async function handleModelsFavoriteRemove(_deps, args) {
|
|
|
116
132
|
export async function handleModelsSetDefault(_deps, args) {
|
|
117
133
|
return mutation(() => setDefaultModel(CONFIG_DIR, args));
|
|
118
134
|
}
|
|
135
|
+
export async function handleModelsSetThinking(_deps, args) {
|
|
136
|
+
return mutation(() => setModelThinking(CONFIG_DIR, args));
|
|
137
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResolveMediaInput, ResolveMediaResult } from '../inline-media-types.js';
|
|
2
|
+
import type { Result, UiServiceDeps } from '../types.js';
|
|
3
|
+
/** Media failures are successful RPC replies so the UI can translate their stable codes. */
|
|
4
|
+
export declare function handleResolveMedia(deps: UiServiceDeps, args: ResolveMediaInput): Promise<Result<ResolveMediaResult>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { sessionsResolveMediaInput } from '../input-schemas.js';
|
|
2
|
+
/** Media failures are successful RPC replies so the UI can translate their stable codes. */
|
|
3
|
+
export async function handleResolveMedia(deps, args) {
|
|
4
|
+
const parsed = sessionsResolveMediaInput.safeParse(args);
|
|
5
|
+
if (!parsed.success)
|
|
6
|
+
return { ok: false, code: 'invalid-args', message: parsed.error.message };
|
|
7
|
+
try {
|
|
8
|
+
const session = await deps.sessionStore.getById(parsed.data.sessionId);
|
|
9
|
+
if (!session)
|
|
10
|
+
return { ok: true, data: { error: { code: 'not_found', reason: 'Session not found' } } };
|
|
11
|
+
return { ok: true, data: await deps.resolveMedia(parsed.data) };
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
15
|
+
return { ok: true, data: { error: { code: 'load_failed', reason } } };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -15,9 +15,7 @@ function expectedOneOf(allowed) {
|
|
|
15
15
|
}
|
|
16
16
|
export async function handleCreateSession(deps, args) {
|
|
17
17
|
const projectId = args.projectId ?? deps.projectStore.getDefault().id;
|
|
18
|
-
const { sessionId } = await deps.createDirectSession({
|
|
19
|
-
projectId, browser: args.browser ?? null,
|
|
20
|
-
});
|
|
18
|
+
const { sessionId } = await deps.createDirectSession({ projectId });
|
|
21
19
|
return { ok: true, data: { sessionId } };
|
|
22
20
|
}
|
|
23
21
|
export async function handleSendSession(deps, args) {
|
|
@@ -125,7 +123,6 @@ export async function handleCreateAndSend(deps, args) {
|
|
|
125
123
|
agentName: args.agentName ?? null,
|
|
126
124
|
// Apply the complete engine choice before the first turn.
|
|
127
125
|
selection: args.selection,
|
|
128
|
-
browser: args.browser ?? null,
|
|
129
126
|
});
|
|
130
127
|
// If the client uploaded files under a draft upload id, move them to the real
|
|
131
128
|
// session's attachment directory and update path references.
|
|
@@ -149,7 +149,6 @@ export async function handleSessionsList(deps, params) {
|
|
|
149
149
|
selection: s.selection ?? null,
|
|
150
150
|
// The environment half of the same question: which agent template the session runs as.
|
|
151
151
|
agentName: s.agentName ?? null,
|
|
152
|
-
browser: s.browser ?? null,
|
|
153
152
|
contextUsage: s.contextUsage ?? null,
|
|
154
153
|
todos: deps.getSessionTodos(s.sessionId) ?? null,
|
|
155
154
|
contextCompactionSupported: supportsCompaction({ backend: s.backend }),
|
|
@@ -271,6 +270,7 @@ function messageFromEvent(deps, event, elapsedMs) {
|
|
|
271
270
|
...(event.type === 'tool' && event.teamAction ? { teamAction: event.teamAction } : {}),
|
|
272
271
|
...(event.type === 'tool' && event.boardAction ? { boardAction: event.boardAction } : {}),
|
|
273
272
|
...(event.type === 'worker-progress' && event.worker ? { worker: event.worker } : {}),
|
|
273
|
+
...(event.type === 'thinking' && event.blockId ? { blockId: event.blockId } : {}),
|
|
274
274
|
ts: event.ts,
|
|
275
275
|
elapsedMs,
|
|
276
276
|
// Tool rows carry the images the call returned (see `appendToolImages`).
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PlatformSettingsSnapshot } from '../../core/platform-settings-spec.js';
|
|
2
2
|
export type { PlatformSettingsPatch, PlatformSettingsSnapshot, PlatformFieldSnapshot, PlatformFieldKey } from '../../core/platform-settings-spec.js';
|
|
3
|
+
import type { ResolveMediaInput, ResolveMediaResult } from './inline-media-types.js';
|
|
4
|
+
export type { InlineMediaErrorCode, ResolveMediaInput, ResolveMediaResult } from './inline-media-types.js';
|
|
3
5
|
import type { SessionsSetStarredReturn, SessionsRenameReturn } from './session-metadata-schemas.js';
|
|
4
6
|
export type { SessionsSetStarredArgs, SessionsSetStarredReturn, SessionsRenameArgs, SessionsRenameReturn, } from './session-metadata-schemas.js';
|
|
5
7
|
import type { z } from 'zod';
|
|
@@ -203,12 +205,6 @@ export interface SessionInfo {
|
|
|
203
205
|
* other half of "what will the next turn be". Null when the session follows its channel's
|
|
204
206
|
* selection and, beneath that, the global default. Kept in sync by the agent-switch rule. */
|
|
205
207
|
agentName?: string | null;
|
|
206
|
-
/** Browser control this session opted into at creation, or null. Fixed for the session's life:
|
|
207
|
-
* the agent's tool set is decided when its process spawns, so this is a fact to display, not a
|
|
208
|
-
* setting to flip. */
|
|
209
|
-
browser?: {
|
|
210
|
-
device: string;
|
|
211
|
-
} | null;
|
|
212
208
|
/** Latest backend context occupancy, or null until a supported backend reports one. Optional only
|
|
213
209
|
* for rolling compatibility with older servers/fixtures; current sessions.list always supplies it. */
|
|
214
210
|
contextUsage?: SessionContextUsage | null;
|
|
@@ -335,7 +331,8 @@ export interface TranscriptMessage {
|
|
|
335
331
|
/** `worker-progress`: a team worker's final reply for a turn that ended while it still had work
|
|
336
332
|
* pending (queued message, background task, open waitpoint or interaction). Recorded in the
|
|
337
333
|
* LEAD's history for display only: it never reaches the lead model and is not a user turn. */
|
|
338
|
-
type: 'user' | 'assistant' | 'tool' | 'interaction' | 'worker-progress';
|
|
334
|
+
type: 'user' | 'assistant' | 'thinking' | 'tool' | 'interaction' | 'worker-progress';
|
|
335
|
+
blockId?: string;
|
|
339
336
|
/** user / assistant / interaction / worker-progress text; null for tool events. */
|
|
340
337
|
text: string | null;
|
|
341
338
|
/** tool name (tool events only). */
|
|
@@ -1413,6 +1410,7 @@ export interface MutateReturnMap {
|
|
|
1413
1410
|
'sessions.respondDecision': SessionsRespondDecisionReturn;
|
|
1414
1411
|
'sessions.cancelResume': SessionsCancelResumeReturn;
|
|
1415
1412
|
'sessions.rewind': SessionsRewindReturn;
|
|
1413
|
+
'sessions.resolveMedia': ResolveMediaResult;
|
|
1416
1414
|
'executions.cancel': ExecutionsCancelReturn;
|
|
1417
1415
|
'waitpoints.cancel': WaitpointsCancelReturn;
|
|
1418
1416
|
'schedules.pause': void;
|
|
@@ -1452,6 +1450,7 @@ export interface MutateReturnMap {
|
|
|
1452
1450
|
'models.favorites.add': ModelsMutationReturn;
|
|
1453
1451
|
'models.favorites.remove': ModelsMutationReturn;
|
|
1454
1452
|
'models.setDefault': ModelsMutationReturn;
|
|
1453
|
+
'models.setThinking': ModelsMutationReturn;
|
|
1455
1454
|
'plugins.assign': PluginsAssignReturn;
|
|
1456
1455
|
'plugins.skillWrite': PluginsSkillWriteReturn;
|
|
1457
1456
|
'plugins.skillCreate': PluginsSkillReturn;
|
|
@@ -1486,6 +1485,8 @@ export interface UiService {
|
|
|
1486
1485
|
};
|
|
1487
1486
|
}
|
|
1488
1487
|
export interface UiServiceDeps {
|
|
1488
|
+
/** Entry-layer callback: domain handlers never import orchestration. */
|
|
1489
|
+
resolveMedia: (input: ResolveMediaInput) => Promise<ResolveMediaResult>;
|
|
1489
1490
|
/** Shared with background timers; bounded discovery, never waits for update consent. */
|
|
1490
1491
|
checkServerUpdate: () => Promise<SystemUpdateCheckResult>;
|
|
1491
1492
|
/** Optional seams for deterministic authentication dispatch tests. */
|
|
@@ -1621,9 +1622,6 @@ export interface UiServiceDeps {
|
|
|
1621
1622
|
sessionId?: string;
|
|
1622
1623
|
agentName?: string | null;
|
|
1623
1624
|
selection?: EngineSelection;
|
|
1624
|
-
browser?: {
|
|
1625
|
-
device: string;
|
|
1626
|
-
} | null;
|
|
1627
1625
|
}) => Promise<{
|
|
1628
1626
|
sessionId: string;
|
|
1629
1627
|
channel: string;
|
|
@@ -118,9 +118,6 @@ export declare const mutateHandlers: {
|
|
|
118
118
|
}) => Promise<Result<import("./types.js").ProjectCreateReturn>>;
|
|
119
119
|
'sessions.create': (deps: UiServiceDeps, args: {
|
|
120
120
|
projectId?: string;
|
|
121
|
-
browser?: {
|
|
122
|
-
device: string;
|
|
123
|
-
};
|
|
124
121
|
}) => Promise<Result<import("./types.js").SessionsCreateReturn>>;
|
|
125
122
|
'sessions.send': (deps: UiServiceDeps, args: {
|
|
126
123
|
sessionId: string;
|
|
@@ -151,9 +148,6 @@ export declare const mutateHandlers: {
|
|
|
151
148
|
projectId: string;
|
|
152
149
|
agentName?: string;
|
|
153
150
|
selection?: import("./types.js").EngineSelection;
|
|
154
|
-
browser?: {
|
|
155
|
-
device: string;
|
|
156
|
-
};
|
|
157
151
|
text: string;
|
|
158
152
|
draftUploadId?: string;
|
|
159
153
|
attachments?: {
|
|
@@ -207,6 +201,11 @@ export declare const mutateHandlers: {
|
|
|
207
201
|
turnIndex: number;
|
|
208
202
|
text: string;
|
|
209
203
|
}) => Promise<Result<import("./types.js").SessionsRewindReturn>>;
|
|
204
|
+
'sessions.resolveMedia': (deps: UiServiceDeps, args: {
|
|
205
|
+
sessionId: string;
|
|
206
|
+
ts: string;
|
|
207
|
+
src: string;
|
|
208
|
+
}) => Promise<Result<import("./inline-media-types.js").ResolveMediaResult>>;
|
|
210
209
|
'executions.cancel': (deps: UiServiceDeps, args: {
|
|
211
210
|
executionId: string;
|
|
212
211
|
}) => Promise<Result<import("./types.js").ExecutionsCancelReturn>>;
|
|
@@ -417,6 +416,10 @@ export declare const mutateHandlers: {
|
|
|
417
416
|
'models.setDefault': (deps: UiServiceDeps, args: {
|
|
418
417
|
selection: import("./types.js").EngineSelection;
|
|
419
418
|
}) => Promise<Result<import("./types.js").ModelsMutationReturn>>;
|
|
419
|
+
'models.setThinking': (deps: UiServiceDeps, args: {
|
|
420
|
+
ref: import("./types.js").ModelRef;
|
|
421
|
+
thinking: string | null;
|
|
422
|
+
}) => Promise<Result<import("./types.js").ModelsMutationReturn>>;
|
|
420
423
|
'plugins.assign': (deps: UiServiceDeps, args: {
|
|
421
424
|
target: {
|
|
422
425
|
kind: "agent";
|
|
@@ -26,7 +26,7 @@ import { handleEnvironmentsList, handleEnvironmentsGet } from './query/environme
|
|
|
26
26
|
import { handleSystemDaemonStatus, handleSystemRateLimitStatus, handleSystemUsageStatus, handleSystemNotices, handleSystemUpdateStatus, } from './query/system.js';
|
|
27
27
|
import { handleConfigSet, handleConfigSetProviderRateLimitPolicy, } from './mutate/config.js';
|
|
28
28
|
import { handleHooksCreate, handleHooksUpdate, handleHooksSetEnabled, handleHooksRemove, handleHooksTest, } from './mutate/hooks.js';
|
|
29
|
-
import { handleModelsFavoriteAdd, handleModelsFavoriteRemove, handleModelsSetDefault, } from './mutate/models.js';
|
|
29
|
+
import { handleModelsFavoriteAdd, handleModelsFavoriteRemove, handleModelsSetDefault, handleModelsSetThinking, } from './mutate/models.js';
|
|
30
30
|
import { handleEnvironmentsValidate, handleEnvironmentsSave, handleEnvironmentsDelete, handleEnvironmentsSavePrompt, } from './mutate/environments.js';
|
|
31
31
|
import { handlePluginsAssign } from './mutate/plugins.js';
|
|
32
32
|
import { handlePluginsSkillWrite, handlePluginsSkillCreate, handlePluginsSkillMove, handlePluginsSkillRemove, handlePluginsSkillRevert, handlePluginsCreate, handlePluginsRemove, handlePluginsConvertToPortable, handlePluginsMcpWrite, } from './mutate/plugin-packages.js';
|
|
@@ -44,6 +44,7 @@ import { handleCustomProviderRemove, handleCustomProviderUpsert, } from './mutat
|
|
|
44
44
|
import { handleUsageSharingSet } from './mutate/usage-sharing.js';
|
|
45
45
|
import { createSubscription } from './subscribe.js';
|
|
46
46
|
import { AssistantSnapshots } from './assistant-snapshots.js';
|
|
47
|
+
import { handleResolveMedia } from './mutate/resolve-media.js';
|
|
47
48
|
export const queryHandlers = {
|
|
48
49
|
'projects.list': (deps) => handleProjectsList(deps),
|
|
49
50
|
'sessions.list': (deps, params) => handleSessionsList(deps, params),
|
|
@@ -105,6 +106,7 @@ export const mutateHandlers = {
|
|
|
105
106
|
'sessions.respondDecision': (deps, args) => handleRespondDecision(deps, args),
|
|
106
107
|
'sessions.cancelResume': (_deps, args) => handleCancelResume(args),
|
|
107
108
|
'sessions.rewind': (deps, args) => handleRewindSession(deps, args),
|
|
109
|
+
'sessions.resolveMedia': (deps, args) => handleResolveMedia(deps, args),
|
|
108
110
|
'executions.cancel': (deps, args) => handleCancelExecution(deps, args),
|
|
109
111
|
'waitpoints.cancel': (deps, args) => handleCancelWaitpoint(deps, args),
|
|
110
112
|
'schedules.pause': (deps, args) => handlePauseSchedule(deps, args),
|
|
@@ -141,6 +143,7 @@ export const mutateHandlers = {
|
|
|
141
143
|
'models.favorites.add': (deps, args) => handleModelsFavoriteAdd(deps, args),
|
|
142
144
|
'models.favorites.remove': (deps, args) => handleModelsFavoriteRemove(deps, args),
|
|
143
145
|
'models.setDefault': (deps, args) => handleModelsSetDefault(deps, args),
|
|
146
|
+
'models.setThinking': (deps, args) => handleModelsSetThinking(deps, args),
|
|
144
147
|
'plugins.assign': (deps, args) => handlePluginsAssign(deps, args),
|
|
145
148
|
'plugins.skillWrite': (deps, args) => handlePluginsSkillWrite(deps, args),
|
|
146
149
|
'plugins.skillCreate': (deps, args) => handlePluginsSkillCreate(deps, args),
|