@sanqianx/claude-ai-workbench 0.13.2 → 0.13.3
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/LICENSE +201 -201
- package/README.md +156 -156
- package/apps/agent-terminal/app.css +636 -613
- package/apps/agent-terminal/app.js +125 -65
- package/apps/agent-terminal/conversation-composer.js +44 -0
- package/apps/agent-terminal/index.html +171 -170
- package/apps/agent-terminal/panel-host-proof.html +152 -152
- package/apps/agent-terminal/panel-proof-content.html +41 -41
- package/apps/agent-terminal/right-workspace-dock.css +187 -159
- package/apps/agent-terminal/right-workspace-dock.js +623 -519
- package/apps/ai-profile-settings-host/index.html +25 -25
- package/apps/ai-profile-settings-host/page.css +1 -1
- package/apps/ai-profile-settings-host/page.js +113 -113
- package/apps/minimal-test-host/README.md +15 -15
- package/apps/minimal-test-host/host.css +2 -2
- package/apps/minimal-test-host/host.js +35 -35
- package/apps/minimal-test-host/index.html +58 -58
- package/apps/minimal-test-host/optional-mock/fault-injection.js +15 -15
- package/docs/sdk/FILE_LAYOUT.md +31 -31
- package/docs/sdk/INTEGRATION.md +126 -126
- package/docs/sdk/README.md +21 -21
- package/docs/sdk/SESSION_EVENTS.md +13 -13
- package/docs/sdk/openapi.yaml +8 -1
- package/package.json +1 -1
- package/packages/client/README.md +29 -29
- package/packages/client/index.d.ts +122 -122
- package/packages/client/index.js +260 -260
- package/packages/client/package.json +2 -2
- package/packages/contracts/README.md +9 -9
- package/packages/contracts/index.d.ts +519 -517
- package/packages/contracts/index.js +312 -312
- package/packages/contracts/package.json +1 -1
- package/packages/core/README.md +8 -8
- package/packages/core/index.d.ts +76 -76
- package/packages/core/index.js +222 -222
- package/packages/core/package.json +2 -2
- package/packages/server/README.md +17 -17
- package/packages/server/bin/agent-terminal-server.js +42 -42
- package/packages/server/bin/claude-workbench.js +225 -225
- package/packages/server/index.d.ts +171 -171
- package/packages/server/index.js +230 -230
- package/packages/server/lib/agent-discovery.js +133 -133
- package/packages/server/lib/agent-registry.js +143 -143
- package/packages/server/lib/agent-spawn-env.js +17 -17
- package/packages/server/lib/attachment-store.js +78 -78
- package/packages/server/lib/bridges/app-server-bridge.js +373 -373
- package/packages/server/lib/bridges/opencode-server-bridge.js +506 -506
- package/packages/server/lib/capture-settings-store.js +35 -35
- package/packages/server/lib/claude-history-recovery.js +87 -87
- package/packages/server/lib/cli-session-recovery.js +28 -28
- package/packages/server/lib/context-resolver.js +55 -55
- package/packages/server/lib/conversation-capture.js +51 -51
- package/packages/server/lib/delegation-phase-store.js +357 -357
- package/packages/server/lib/delegation-store.js +474 -468
- package/packages/server/lib/diagnostics.js +32 -32
- package/packages/server/lib/drivers/cli-json-runner.js +974 -974
- package/packages/server/lib/drivers/codex-driver.js +1442 -1442
- package/packages/server/lib/drivers/opencode-driver.js +1554 -1554
- package/packages/server/lib/drivers/zcode-driver.js +1250 -1250
- package/packages/server/lib/drivers/zcode-profile-runtime.js +71 -71
- package/packages/server/lib/event-stream.js +138 -138
- package/packages/server/lib/folder-picker.js +623 -623
- package/packages/server/lib/http-handler.js +339 -339
- package/packages/server/lib/json-file.js +26 -26
- package/packages/server/lib/knowledge-context.js +33 -33
- package/packages/server/lib/model-detection.js +295 -295
- package/packages/server/lib/parent-context.js +44 -0
- package/packages/server/lib/profile-store.js +283 -283
- package/packages/server/lib/project-store.js +102 -102
- package/packages/server/lib/runtime-loader.js +120 -120
- package/packages/server/lib/session-archive-store.js +53 -53
- package/packages/server/lib/session-history.js +612 -612
- package/packages/server/lib/system-doctor.js +125 -125
- package/packages/server/lib/ui-preferences-store.js +48 -48
- package/packages/server/lib/workbench-service.js +1696 -1675
- package/packages/server/package.json +2 -2
- package/packages/ui/README.md +30 -30
- package/packages/ui/ai-profile-settings.d.ts +45 -45
- package/packages/ui/ai-profile-settings.js +283 -283
- package/packages/ui/claude-terminal.d.ts +31 -31
- package/packages/ui/claude-terminal.js +343 -343
- package/packages/ui/index.d.ts +18 -18
- package/packages/ui/index.js +51 -51
- package/packages/ui/package.json +2 -2
- package/packages/ui/theme.css +13 -13
- package/src/assets/claude-prompts.json +21 -21
- package/src/backend/http/ai-profile-routes.js +61 -61
- package/src/backend/http/claude-routes.js +170 -170
- package/src/backend/http/node-helpers.js +45 -45
- package/src/backend/index.js +21 -21
- package/src/backend/lib/ai-adapter.js +144 -144
- package/src/backend/lib/ai-profile-store.js +259 -259
- package/src/backend/lib/ai-vendor-presets.js +83 -83
- package/src/backend/lib/ai-workspace.js +140 -140
- package/src/backend/lib/automation-config.js +253 -253
- package/src/backend/lib/claude-cli-runner.js +2392 -2392
- package/src/backend/lib/data-dir.js +169 -169
- package/src/backend/lib/llm-client.js +176 -176
- package/src/backend/lib/model-context-windows.js +82 -82
- package/src/backend/lib/native-task-control.js +217 -217
- package/src/backend/lib/native-task-history-index.js +475 -475
- package/src/backend/lib/native-task-history-reader.js +526 -526
- package/src/backend/lib/native-task-messages.js +457 -457
- package/src/backend/lib/native-task-registry.js +325 -325
- package/src/backend/lib/native-task-runtime.js +242 -242
- package/src/backend/lib/native-task-trace.js +440 -440
- package/src/backend/lib/native-task-transcript.js +393 -393
- package/src/backend/lib/prompt-registry.js +166 -166
- package/src/backend/lib/runtime-config.js +121 -121
- package/src/backend/lib/sdk-session-stream.js +143 -143
- package/src/backend/lib/sdk-turn-stream.js +16 -16
- package/src/backend/lib/store-scope.js +131 -131
- package/src/backend/lib/task-identity.js +104 -104
- package/src/backend/lib/task-state-projection.js +58 -58
- package/src/index.js +7 -7
- package/src/sdk-wave-a.ts +1 -1
- package/src/sdk-wave-b.ts +1 -1
- package/src/sdk-wave-c.ts +1 -1
- package/src/sdk-wave-d.ts +1 -1
- package/src/sdk-wave-e.ts +1 -1
|
@@ -1,517 +1,519 @@
|
|
|
1
|
-
export type PermissionMode = "default" | "acceptEdits" | "plan" | "bypassPermissions";
|
|
2
|
-
export type ProfileProtocol = "anthropic-compatible" | "openai-compatible" | string;
|
|
3
|
-
export type AgentId = "claude-code" | "codex" | "opencode" | "zcode";
|
|
4
|
-
export type EffortLevel = "low" | "medium" | "high" | "max";
|
|
5
|
-
|
|
6
|
-
export interface AgentCapabilities {
|
|
7
|
-
backgroundTasks?: boolean;
|
|
8
|
-
thinking: boolean;
|
|
9
|
-
permissions: boolean;
|
|
10
|
-
toolStream: boolean;
|
|
11
|
-
images: boolean;
|
|
12
|
-
resume: true;
|
|
13
|
-
modelOverride: boolean;
|
|
14
|
-
generationParams: readonly string[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface AgentDefinition {
|
|
18
|
-
id: AgentId;
|
|
19
|
-
label: string;
|
|
20
|
-
transport: string;
|
|
21
|
-
authModes: readonly string[];
|
|
22
|
-
capabilities: AgentCapabilities;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface AgentStatus extends AgentDefinition {
|
|
26
|
-
scanState?: 'unknown' | 'ready' | 'error';
|
|
27
|
-
checkedAt?: string;
|
|
28
|
-
errorCode?: string | null;
|
|
29
|
-
capabilities: { generationParams: string[] } & Omit<AgentCapabilities, "generationParams">;
|
|
30
|
-
available: boolean;
|
|
31
|
-
version: string | null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface Project {
|
|
35
|
-
id: string;
|
|
36
|
-
name: string;
|
|
37
|
-
rootPath: string;
|
|
38
|
-
createdAt: string;
|
|
39
|
-
updatedAt: string;
|
|
40
|
-
defaultAiProfileId?: string | null;
|
|
41
|
-
defaultModel?: string | null;
|
|
42
|
-
defaultAgentId?: AgentId;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface ProjectInput {
|
|
46
|
-
name: string;
|
|
47
|
-
rootPath: string;
|
|
48
|
-
defaultAiProfileId?: string | null;
|
|
49
|
-
defaultModel?: string | null;
|
|
50
|
-
defaultAgentId?: AgentId;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type ProjectPatch = Partial<Omit<ProjectInput, "rootPath">>;
|
|
54
|
-
|
|
55
|
-
export interface ModelListEntry {
|
|
56
|
-
id: string;
|
|
57
|
-
openaiId?: string;
|
|
58
|
-
label: string;
|
|
59
|
-
tags: string[];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface WorkbenchContext {
|
|
63
|
-
contextId: string;
|
|
64
|
-
contextType?: string;
|
|
65
|
-
displayName?: string;
|
|
66
|
-
workspaceRef?: string;
|
|
67
|
-
aiProfileId?: string | null;
|
|
68
|
-
model?: string | null;
|
|
69
|
-
metadata?: Record<string, unknown>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface AiProfileModels {
|
|
73
|
-
default: string;
|
|
74
|
-
fast?: string;
|
|
75
|
-
reasoning?: string;
|
|
76
|
-
coding?: string;
|
|
77
|
-
largeContext?: string;
|
|
78
|
-
list?: ModelListEntry[];
|
|
79
|
-
[role: string]: string | undefined | ModelListEntry[];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface AiProfileInput {
|
|
83
|
-
id: string;
|
|
84
|
-
name?: string;
|
|
85
|
-
provider: string;
|
|
86
|
-
protocol?: ProfileProtocol;
|
|
87
|
-
runtime?: "claude-code";
|
|
88
|
-
baseUrl: string;
|
|
89
|
-
openaiBaseUrl?: string;
|
|
90
|
-
credentialRef?: string;
|
|
91
|
-
models: AiProfileModels;
|
|
92
|
-
contextWindow?: number;
|
|
93
|
-
timeoutMs?: number;
|
|
94
|
-
permissionMode?: PermissionMode;
|
|
95
|
-
systemPrompt?: Record<string, unknown> | string;
|
|
96
|
-
enabled?: boolean;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface AiProfile extends AiProfileInput {
|
|
100
|
-
name: string;
|
|
101
|
-
protocol: ProfileProtocol;
|
|
102
|
-
runtime: "claude-code";
|
|
103
|
-
credentialRef: string;
|
|
104
|
-
contextWindow: number;
|
|
105
|
-
timeoutMs: number;
|
|
106
|
-
permissionMode: PermissionMode;
|
|
107
|
-
systemPrompt: Record<string, unknown>;
|
|
108
|
-
enabled: boolean;
|
|
109
|
-
credentialConfigured?: boolean;
|
|
110
|
-
credentialMasked?: string;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface CredentialInput { secret: string; }
|
|
114
|
-
|
|
115
|
-
export interface ProfileTestResult {
|
|
116
|
-
ok: true;
|
|
117
|
-
runtime: "claude-code";
|
|
118
|
-
runtimeVerified: true;
|
|
119
|
-
profileId: string;
|
|
120
|
-
model: string;
|
|
121
|
-
firstEventMs: number;
|
|
122
|
-
durationMs: number;
|
|
123
|
-
resultPreview: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface HealthResult {
|
|
127
|
-
status: "ok";
|
|
128
|
-
version: string;
|
|
129
|
-
apiVersion: string;
|
|
130
|
-
activeProcesses: number;
|
|
131
|
-
sessions: number;
|
|
132
|
-
time: string;
|
|
133
|
-
/** Absent on servers built before task identity existed. */
|
|
134
|
-
taskIdentity?: TaskRuntimeIdentity;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Task identity reported via /health. storeScope is the persistent store id
|
|
138
|
-
// (null when the store file could not be established); runtimeEpoch is a
|
|
139
|
-
// per-service-instance generation that is never persisted.
|
|
140
|
-
export interface TaskRuntimeIdentity {
|
|
141
|
-
storeScope: string | null;
|
|
142
|
-
runtimeEpoch: string;
|
|
143
|
-
available: boolean;
|
|
144
|
-
errorCode: string | null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface RuntimeInfo {
|
|
148
|
-
runtime: "claude-code";
|
|
149
|
-
available: boolean;
|
|
150
|
-
executable: string | null;
|
|
151
|
-
transport: string;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export interface SessionSummary {
|
|
155
|
-
tasks?: BackgroundTask[];
|
|
156
|
-
backgroundTaskCount?: number;
|
|
157
|
-
sessionId: string;
|
|
158
|
-
contextId: string;
|
|
159
|
-
projectId: string;
|
|
160
|
-
agentId: AgentId;
|
|
161
|
-
title: string;
|
|
162
|
-
active: boolean;
|
|
163
|
-
state: string;
|
|
164
|
-
model: string | null;
|
|
165
|
-
aiProfileId: string | null;
|
|
166
|
-
providerName?: string | null;
|
|
167
|
-
authSource?: "profile-injected" | "agent-owned";
|
|
168
|
-
selectedModel?: string | null;
|
|
169
|
-
permissionMode: PermissionMode;
|
|
170
|
-
archived: boolean;
|
|
171
|
-
turns: number;
|
|
172
|
-
startedAt: string;
|
|
173
|
-
updatedAt: string;
|
|
174
|
-
connectionState: string;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export type ResyncReason = "stale-cursor" | "history-gap";
|
|
178
|
-
|
|
179
|
-
export interface BackgroundTask {
|
|
180
|
-
taskId: string;
|
|
181
|
-
parentSessionId: string;
|
|
182
|
-
toolUseId?: string;
|
|
183
|
-
status: 'pending' | 'running' | 'completed' | 'failed' | 'stopped';
|
|
184
|
-
description?: string;
|
|
185
|
-
summary?: string;
|
|
186
|
-
lastToolName?: string;
|
|
187
|
-
usage?: {total_tokens?: number; tool_uses?: number; duration_ms?: number};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Task identity: opaque, already-resolved ids. storeScope is the stable storage
|
|
191
|
-
// identity - never a port, PID or runtime epoch.
|
|
192
|
-
export interface TaskScope {
|
|
193
|
-
storeScope: string;
|
|
194
|
-
contextId: string;
|
|
195
|
-
parentSessionId: string;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export interface NativeTaskRef extends TaskScope {
|
|
199
|
-
kind: "native-task";
|
|
200
|
-
ownerRunId: string;
|
|
201
|
-
taskId: string;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// Native task-history reads (GET /sessions/:id/native-tasks and POST
|
|
205
|
-
// /sessions/:id/native-tasks/history). Every field mirrors what the reviewed
|
|
206
|
-
// reader actually returns; null means "not observed in the journal", never a
|
|
207
|
-
// fabricated placeholder.
|
|
208
|
-
export type NativeTaskAssociation = "bound" | "main-command" | "unassigned";
|
|
209
|
-
export type NativeTaskStatus = "pending" | "running" | "completed" | "failed" | "stopped";
|
|
210
|
-
|
|
211
|
-
export interface NativeTaskDiagnosticItem {
|
|
212
|
-
code: string;
|
|
213
|
-
source: "reader" | "index" | "service";
|
|
214
|
-
[key: string]: unknown;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export interface NativeTaskDiagnostics {
|
|
218
|
-
items: NativeTaskDiagnosticItem[];
|
|
219
|
-
total: number;
|
|
220
|
-
truncated: boolean;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// One task out of the session's durable journal. taskRef is null until a
|
|
224
|
-
// bound state row established ownership; status/statusSource are null until
|
|
225
|
-
// a lifecycle row was observed. firstOffset/lastOffset are byte offsets into
|
|
226
|
-
// the history file, useful only for diagnostics.
|
|
227
|
-
export interface NativeTaskSummary {
|
|
228
|
-
sdkSessionId: string;
|
|
229
|
-
taskId: string;
|
|
230
|
-
taskKind: string | null;
|
|
231
|
-
taskType: string | null;
|
|
232
|
-
typeConflict: boolean;
|
|
233
|
-
status: NativeTaskStatus | null;
|
|
234
|
-
statusSource: string | null;
|
|
235
|
-
association: NativeTaskAssociation;
|
|
236
|
-
taskRef: NativeTaskRef | null;
|
|
237
|
-
ownerRunId: string | null;
|
|
238
|
-
owner: Record<string, unknown> | null;
|
|
239
|
-
mainToolUseId: string | null;
|
|
240
|
-
rowCount: number;
|
|
241
|
-
firstOffset: number;
|
|
242
|
-
lastOffset: number;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// Verbatim journal row: type plus whatever the collector stamped. Row bodies
|
|
246
|
-
// are not normalized by the read path. Observed row types: claude/task-*,
|
|
247
|
-
// claude/native-trace, claude/native-task-state and
|
|
248
|
-
// claude/native-task-transcript (see NativeTaskTranscriptRow).
|
|
249
|
-
export interface NativeTaskHistoryRow {
|
|
250
|
-
type: string;
|
|
251
|
-
sequence?: number;
|
|
252
|
-
at?: string;
|
|
253
|
-
[key: string]: unknown;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// One claude/native-task-transcript journal row: a snapshot of a bound
|
|
257
|
-
// agent's transcript read through the SDK's public getSubagentMessages at a
|
|
258
|
-
// real terminal signal (SubagentStop, an SDK terminal task event, or the
|
|
259
|
-
// bounded turn-end sweep). entries/toolSteps/usage/diagnostics carry the
|
|
260
|
-
// normalized, redacted content; read.status carries fixed codes
|
|
261
|
-
// ('ok' | 'unavailable' | 'failed') with content-free reason codes instead
|
|
262
|
-
// of SDK error text; chunk marks byte-bounded slicing and whether the
|
|
263
|
-
// snapshot read completed. source is always 'sdk-public-read'. This is a
|
|
264
|
-
// snapshot read, never a claim of per-token streaming, and the row attaches
|
|
265
|
-
// to the bound agent task only - never to the main reply.
|
|
266
|
-
export interface NativeTaskTranscriptRow {
|
|
267
|
-
type: "claude/native-task-transcript";
|
|
268
|
-
source: "sdk-public-read";
|
|
269
|
-
scope: TaskScope;
|
|
270
|
-
sdkSessionId: string;
|
|
271
|
-
taskId: string;
|
|
272
|
-
taskRef: NativeTaskRef | null;
|
|
273
|
-
ownerRunId: string | null;
|
|
274
|
-
capture: string;
|
|
275
|
-
read: { status: "ok" | "unavailable" | "failed"; reason?: string; at: string };
|
|
276
|
-
entries: unknown[];
|
|
277
|
-
toolSteps: unknown[];
|
|
278
|
-
usage: { records: unknown[]; summary: unknown | null };
|
|
279
|
-
diagnostics: unknown[];
|
|
280
|
-
stats: unknown | null;
|
|
281
|
-
chunk: { index: number; count: number; complete: boolean };
|
|
282
|
-
sequence?: number;
|
|
283
|
-
at?: string;
|
|
284
|
-
[key: string]: unknown;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export interface NativeTaskListPage {
|
|
288
|
-
fileId: string;
|
|
289
|
-
tasks: NativeTaskSummary[];
|
|
290
|
-
incomplete: string[];
|
|
291
|
-
diagnostics: NativeTaskDiagnostics;
|
|
292
|
-
scope: TaskScope;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
export interface NativeTaskEventsPage {
|
|
296
|
-
events: NativeTaskHistoryRow[];
|
|
297
|
-
nextCursor: string | null;
|
|
298
|
-
hasMore: boolean;
|
|
299
|
-
fileId: string;
|
|
300
|
-
incomplete: string[];
|
|
301
|
-
diagnostics: NativeTaskDiagnostics;
|
|
302
|
-
taskRef: NativeTaskRef;
|
|
303
|
-
scope: TaskScope;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Delegated sessions (POST/GET /sessions/:id/delegations). delegationId is a
|
|
307
|
-
// Workbench server-command identity - it is NOT an SDK ownerRunId and implies
|
|
308
|
-
// no SDK tool causality (sdkRunIdClaimed/inputCausalityClaimed stay false).
|
|
309
|
-
// initiator states the honestly observed origin of the command; it is never
|
|
310
|
-
// an authentication claim about a model or leader.
|
|
311
|
-
export type DelegationPhase =
|
|
312
|
-
| "reserved"
|
|
313
|
-
| "child-created"
|
|
314
|
-
| "child-create-failed"
|
|
315
|
-
| "dispatching"
|
|
316
|
-
| "dispatched"
|
|
317
|
-
| "dispatch-unknown";
|
|
318
|
-
|
|
319
|
-
export type DelegationOutcome =
|
|
320
|
-
| "not-started"
|
|
321
|
-
| "not-dispatched"
|
|
322
|
-
| "pending"
|
|
323
|
-
| "dispatched"
|
|
324
|
-
| "unknown";
|
|
325
|
-
|
|
326
|
-
export interface DelegatedSessionRef {
|
|
327
|
-
kind: "delegated-session";
|
|
328
|
-
storeScope: string;
|
|
329
|
-
contextId: string;
|
|
330
|
-
parentSessionId: string;
|
|
331
|
-
delegationId: string;
|
|
332
|
-
childSessionId: string;
|
|
333
|
-
workspaceRef: string;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
export interface DelegationCommandRecord extends DelegatedSessionRef {
|
|
337
|
-
requestId: string;
|
|
338
|
-
issuedAt: string;
|
|
339
|
-
source: "workbench-delegation-command";
|
|
340
|
-
basis: "server-command";
|
|
341
|
-
sdkRunIdClaimed: false;
|
|
342
|
-
inputCausalityClaimed: false;
|
|
343
|
-
initiator: {type: "external-api"; authenticatedAs: string | null};
|
|
344
|
-
selection: {profileId: string | null; model: string | null};
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
export interface DelegationDispatchState {
|
|
348
|
-
state: "not-dispatched" | "awaiting-dispatch" | "dispatching" | "dispatched" | "dispatch-unknown";
|
|
349
|
-
attemptId?: string;
|
|
350
|
-
at?: string;
|
|
351
|
-
reason?: string;
|
|
352
|
-
code?: string;
|
|
353
|
-
errorCode?: string;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
export interface DelegationChildStatus {
|
|
357
|
-
sessionId: string;
|
|
358
|
-
present: boolean;
|
|
359
|
-
state: string;
|
|
360
|
-
agentId?: string;
|
|
361
|
-
model?: string | null;
|
|
362
|
-
active?: boolean;
|
|
363
|
-
turns?: number;
|
|
364
|
-
archived?: boolean;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
export interface DelegationView {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
//
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
export
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
export declare const
|
|
490
|
-
export declare const
|
|
491
|
-
export declare const
|
|
492
|
-
export declare const
|
|
493
|
-
export declare const
|
|
494
|
-
export declare const
|
|
495
|
-
export declare const
|
|
496
|
-
export declare const
|
|
497
|
-
export declare const
|
|
498
|
-
export declare const
|
|
499
|
-
export declare const
|
|
500
|
-
export declare const
|
|
501
|
-
export declare const
|
|
502
|
-
export declare const
|
|
503
|
-
export declare const
|
|
504
|
-
export declare const
|
|
505
|
-
export declare
|
|
506
|
-
export declare
|
|
507
|
-
export declare function
|
|
508
|
-
export declare function
|
|
509
|
-
export declare function
|
|
510
|
-
export declare function
|
|
511
|
-
export declare function
|
|
512
|
-
export declare function
|
|
513
|
-
export declare function
|
|
514
|
-
export declare function
|
|
515
|
-
export declare function
|
|
516
|
-
export declare function
|
|
517
|
-
export declare function
|
|
1
|
+
export type PermissionMode = "default" | "acceptEdits" | "plan" | "bypassPermissions";
|
|
2
|
+
export type ProfileProtocol = "anthropic-compatible" | "openai-compatible" | string;
|
|
3
|
+
export type AgentId = "claude-code" | "codex" | "opencode" | "zcode";
|
|
4
|
+
export type EffortLevel = "low" | "medium" | "high" | "max";
|
|
5
|
+
|
|
6
|
+
export interface AgentCapabilities {
|
|
7
|
+
backgroundTasks?: boolean;
|
|
8
|
+
thinking: boolean;
|
|
9
|
+
permissions: boolean;
|
|
10
|
+
toolStream: boolean;
|
|
11
|
+
images: boolean;
|
|
12
|
+
resume: true;
|
|
13
|
+
modelOverride: boolean;
|
|
14
|
+
generationParams: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AgentDefinition {
|
|
18
|
+
id: AgentId;
|
|
19
|
+
label: string;
|
|
20
|
+
transport: string;
|
|
21
|
+
authModes: readonly string[];
|
|
22
|
+
capabilities: AgentCapabilities;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AgentStatus extends AgentDefinition {
|
|
26
|
+
scanState?: 'unknown' | 'ready' | 'error';
|
|
27
|
+
checkedAt?: string;
|
|
28
|
+
errorCode?: string | null;
|
|
29
|
+
capabilities: { generationParams: string[] } & Omit<AgentCapabilities, "generationParams">;
|
|
30
|
+
available: boolean;
|
|
31
|
+
version: string | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Project {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
rootPath: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
defaultAiProfileId?: string | null;
|
|
41
|
+
defaultModel?: string | null;
|
|
42
|
+
defaultAgentId?: AgentId;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ProjectInput {
|
|
46
|
+
name: string;
|
|
47
|
+
rootPath: string;
|
|
48
|
+
defaultAiProfileId?: string | null;
|
|
49
|
+
defaultModel?: string | null;
|
|
50
|
+
defaultAgentId?: AgentId;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type ProjectPatch = Partial<Omit<ProjectInput, "rootPath">>;
|
|
54
|
+
|
|
55
|
+
export interface ModelListEntry {
|
|
56
|
+
id: string;
|
|
57
|
+
openaiId?: string;
|
|
58
|
+
label: string;
|
|
59
|
+
tags: string[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface WorkbenchContext {
|
|
63
|
+
contextId: string;
|
|
64
|
+
contextType?: string;
|
|
65
|
+
displayName?: string;
|
|
66
|
+
workspaceRef?: string;
|
|
67
|
+
aiProfileId?: string | null;
|
|
68
|
+
model?: string | null;
|
|
69
|
+
metadata?: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface AiProfileModels {
|
|
73
|
+
default: string;
|
|
74
|
+
fast?: string;
|
|
75
|
+
reasoning?: string;
|
|
76
|
+
coding?: string;
|
|
77
|
+
largeContext?: string;
|
|
78
|
+
list?: ModelListEntry[];
|
|
79
|
+
[role: string]: string | undefined | ModelListEntry[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface AiProfileInput {
|
|
83
|
+
id: string;
|
|
84
|
+
name?: string;
|
|
85
|
+
provider: string;
|
|
86
|
+
protocol?: ProfileProtocol;
|
|
87
|
+
runtime?: "claude-code";
|
|
88
|
+
baseUrl: string;
|
|
89
|
+
openaiBaseUrl?: string;
|
|
90
|
+
credentialRef?: string;
|
|
91
|
+
models: AiProfileModels;
|
|
92
|
+
contextWindow?: number;
|
|
93
|
+
timeoutMs?: number;
|
|
94
|
+
permissionMode?: PermissionMode;
|
|
95
|
+
systemPrompt?: Record<string, unknown> | string;
|
|
96
|
+
enabled?: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface AiProfile extends AiProfileInput {
|
|
100
|
+
name: string;
|
|
101
|
+
protocol: ProfileProtocol;
|
|
102
|
+
runtime: "claude-code";
|
|
103
|
+
credentialRef: string;
|
|
104
|
+
contextWindow: number;
|
|
105
|
+
timeoutMs: number;
|
|
106
|
+
permissionMode: PermissionMode;
|
|
107
|
+
systemPrompt: Record<string, unknown>;
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
credentialConfigured?: boolean;
|
|
110
|
+
credentialMasked?: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface CredentialInput { secret: string; }
|
|
114
|
+
|
|
115
|
+
export interface ProfileTestResult {
|
|
116
|
+
ok: true;
|
|
117
|
+
runtime: "claude-code";
|
|
118
|
+
runtimeVerified: true;
|
|
119
|
+
profileId: string;
|
|
120
|
+
model: string;
|
|
121
|
+
firstEventMs: number;
|
|
122
|
+
durationMs: number;
|
|
123
|
+
resultPreview: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface HealthResult {
|
|
127
|
+
status: "ok";
|
|
128
|
+
version: string;
|
|
129
|
+
apiVersion: string;
|
|
130
|
+
activeProcesses: number;
|
|
131
|
+
sessions: number;
|
|
132
|
+
time: string;
|
|
133
|
+
/** Absent on servers built before task identity existed. */
|
|
134
|
+
taskIdentity?: TaskRuntimeIdentity;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Task identity reported via /health. storeScope is the persistent store id
|
|
138
|
+
// (null when the store file could not be established); runtimeEpoch is a
|
|
139
|
+
// per-service-instance generation that is never persisted.
|
|
140
|
+
export interface TaskRuntimeIdentity {
|
|
141
|
+
storeScope: string | null;
|
|
142
|
+
runtimeEpoch: string;
|
|
143
|
+
available: boolean;
|
|
144
|
+
errorCode: string | null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface RuntimeInfo {
|
|
148
|
+
runtime: "claude-code";
|
|
149
|
+
available: boolean;
|
|
150
|
+
executable: string | null;
|
|
151
|
+
transport: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface SessionSummary {
|
|
155
|
+
tasks?: BackgroundTask[];
|
|
156
|
+
backgroundTaskCount?: number;
|
|
157
|
+
sessionId: string;
|
|
158
|
+
contextId: string;
|
|
159
|
+
projectId: string;
|
|
160
|
+
agentId: AgentId;
|
|
161
|
+
title: string;
|
|
162
|
+
active: boolean;
|
|
163
|
+
state: string;
|
|
164
|
+
model: string | null;
|
|
165
|
+
aiProfileId: string | null;
|
|
166
|
+
providerName?: string | null;
|
|
167
|
+
authSource?: "profile-injected" | "agent-owned";
|
|
168
|
+
selectedModel?: string | null;
|
|
169
|
+
permissionMode: PermissionMode;
|
|
170
|
+
archived: boolean;
|
|
171
|
+
turns: number;
|
|
172
|
+
startedAt: string;
|
|
173
|
+
updatedAt: string;
|
|
174
|
+
connectionState: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export type ResyncReason = "stale-cursor" | "history-gap";
|
|
178
|
+
|
|
179
|
+
export interface BackgroundTask {
|
|
180
|
+
taskId: string;
|
|
181
|
+
parentSessionId: string;
|
|
182
|
+
toolUseId?: string;
|
|
183
|
+
status: 'pending' | 'running' | 'completed' | 'failed' | 'stopped';
|
|
184
|
+
description?: string;
|
|
185
|
+
summary?: string;
|
|
186
|
+
lastToolName?: string;
|
|
187
|
+
usage?: {total_tokens?: number; tool_uses?: number; duration_ms?: number};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Task identity: opaque, already-resolved ids. storeScope is the stable storage
|
|
191
|
+
// identity - never a port, PID or runtime epoch.
|
|
192
|
+
export interface TaskScope {
|
|
193
|
+
storeScope: string;
|
|
194
|
+
contextId: string;
|
|
195
|
+
parentSessionId: string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface NativeTaskRef extends TaskScope {
|
|
199
|
+
kind: "native-task";
|
|
200
|
+
ownerRunId: string;
|
|
201
|
+
taskId: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Native task-history reads (GET /sessions/:id/native-tasks and POST
|
|
205
|
+
// /sessions/:id/native-tasks/history). Every field mirrors what the reviewed
|
|
206
|
+
// reader actually returns; null means "not observed in the journal", never a
|
|
207
|
+
// fabricated placeholder.
|
|
208
|
+
export type NativeTaskAssociation = "bound" | "main-command" | "unassigned";
|
|
209
|
+
export type NativeTaskStatus = "pending" | "running" | "completed" | "failed" | "stopped";
|
|
210
|
+
|
|
211
|
+
export interface NativeTaskDiagnosticItem {
|
|
212
|
+
code: string;
|
|
213
|
+
source: "reader" | "index" | "service";
|
|
214
|
+
[key: string]: unknown;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface NativeTaskDiagnostics {
|
|
218
|
+
items: NativeTaskDiagnosticItem[];
|
|
219
|
+
total: number;
|
|
220
|
+
truncated: boolean;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// One task out of the session's durable journal. taskRef is null until a
|
|
224
|
+
// bound state row established ownership; status/statusSource are null until
|
|
225
|
+
// a lifecycle row was observed. firstOffset/lastOffset are byte offsets into
|
|
226
|
+
// the history file, useful only for diagnostics.
|
|
227
|
+
export interface NativeTaskSummary {
|
|
228
|
+
sdkSessionId: string;
|
|
229
|
+
taskId: string;
|
|
230
|
+
taskKind: string | null;
|
|
231
|
+
taskType: string | null;
|
|
232
|
+
typeConflict: boolean;
|
|
233
|
+
status: NativeTaskStatus | null;
|
|
234
|
+
statusSource: string | null;
|
|
235
|
+
association: NativeTaskAssociation;
|
|
236
|
+
taskRef: NativeTaskRef | null;
|
|
237
|
+
ownerRunId: string | null;
|
|
238
|
+
owner: Record<string, unknown> | null;
|
|
239
|
+
mainToolUseId: string | null;
|
|
240
|
+
rowCount: number;
|
|
241
|
+
firstOffset: number;
|
|
242
|
+
lastOffset: number;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Verbatim journal row: type plus whatever the collector stamped. Row bodies
|
|
246
|
+
// are not normalized by the read path. Observed row types: claude/task-*,
|
|
247
|
+
// claude/native-trace, claude/native-task-state and
|
|
248
|
+
// claude/native-task-transcript (see NativeTaskTranscriptRow).
|
|
249
|
+
export interface NativeTaskHistoryRow {
|
|
250
|
+
type: string;
|
|
251
|
+
sequence?: number;
|
|
252
|
+
at?: string;
|
|
253
|
+
[key: string]: unknown;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// One claude/native-task-transcript journal row: a snapshot of a bound
|
|
257
|
+
// agent's transcript read through the SDK's public getSubagentMessages at a
|
|
258
|
+
// real terminal signal (SubagentStop, an SDK terminal task event, or the
|
|
259
|
+
// bounded turn-end sweep). entries/toolSteps/usage/diagnostics carry the
|
|
260
|
+
// normalized, redacted content; read.status carries fixed codes
|
|
261
|
+
// ('ok' | 'unavailable' | 'failed') with content-free reason codes instead
|
|
262
|
+
// of SDK error text; chunk marks byte-bounded slicing and whether the
|
|
263
|
+
// snapshot read completed. source is always 'sdk-public-read'. This is a
|
|
264
|
+
// snapshot read, never a claim of per-token streaming, and the row attaches
|
|
265
|
+
// to the bound agent task only - never to the main reply.
|
|
266
|
+
export interface NativeTaskTranscriptRow {
|
|
267
|
+
type: "claude/native-task-transcript";
|
|
268
|
+
source: "sdk-public-read";
|
|
269
|
+
scope: TaskScope;
|
|
270
|
+
sdkSessionId: string;
|
|
271
|
+
taskId: string;
|
|
272
|
+
taskRef: NativeTaskRef | null;
|
|
273
|
+
ownerRunId: string | null;
|
|
274
|
+
capture: string;
|
|
275
|
+
read: { status: "ok" | "unavailable" | "failed"; reason?: string; at: string };
|
|
276
|
+
entries: unknown[];
|
|
277
|
+
toolSteps: unknown[];
|
|
278
|
+
usage: { records: unknown[]; summary: unknown | null };
|
|
279
|
+
diagnostics: unknown[];
|
|
280
|
+
stats: unknown | null;
|
|
281
|
+
chunk: { index: number; count: number; complete: boolean };
|
|
282
|
+
sequence?: number;
|
|
283
|
+
at?: string;
|
|
284
|
+
[key: string]: unknown;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface NativeTaskListPage {
|
|
288
|
+
fileId: string;
|
|
289
|
+
tasks: NativeTaskSummary[];
|
|
290
|
+
incomplete: string[];
|
|
291
|
+
diagnostics: NativeTaskDiagnostics;
|
|
292
|
+
scope: TaskScope;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface NativeTaskEventsPage {
|
|
296
|
+
events: NativeTaskHistoryRow[];
|
|
297
|
+
nextCursor: string | null;
|
|
298
|
+
hasMore: boolean;
|
|
299
|
+
fileId: string;
|
|
300
|
+
incomplete: string[];
|
|
301
|
+
diagnostics: NativeTaskDiagnostics;
|
|
302
|
+
taskRef: NativeTaskRef;
|
|
303
|
+
scope: TaskScope;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Delegated sessions (POST/GET /sessions/:id/delegations). delegationId is a
|
|
307
|
+
// Workbench server-command identity - it is NOT an SDK ownerRunId and implies
|
|
308
|
+
// no SDK tool causality (sdkRunIdClaimed/inputCausalityClaimed stay false).
|
|
309
|
+
// initiator states the honestly observed origin of the command; it is never
|
|
310
|
+
// an authentication claim about a model or leader.
|
|
311
|
+
export type DelegationPhase =
|
|
312
|
+
| "reserved"
|
|
313
|
+
| "child-created"
|
|
314
|
+
| "child-create-failed"
|
|
315
|
+
| "dispatching"
|
|
316
|
+
| "dispatched"
|
|
317
|
+
| "dispatch-unknown";
|
|
318
|
+
|
|
319
|
+
export type DelegationOutcome =
|
|
320
|
+
| "not-started"
|
|
321
|
+
| "not-dispatched"
|
|
322
|
+
| "pending"
|
|
323
|
+
| "dispatched"
|
|
324
|
+
| "unknown";
|
|
325
|
+
|
|
326
|
+
export interface DelegatedSessionRef {
|
|
327
|
+
kind: "delegated-session";
|
|
328
|
+
storeScope: string;
|
|
329
|
+
contextId: string;
|
|
330
|
+
parentSessionId: string;
|
|
331
|
+
delegationId: string;
|
|
332
|
+
childSessionId: string;
|
|
333
|
+
workspaceRef: string;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface DelegationCommandRecord extends DelegatedSessionRef {
|
|
337
|
+
requestId: string;
|
|
338
|
+
issuedAt: string;
|
|
339
|
+
source: "workbench-delegation-command";
|
|
340
|
+
basis: "server-command";
|
|
341
|
+
sdkRunIdClaimed: false;
|
|
342
|
+
inputCausalityClaimed: false;
|
|
343
|
+
initiator: {type: "external-api"; authenticatedAs: string | null};
|
|
344
|
+
selection: {profileId: string | null; model: string | null};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface DelegationDispatchState {
|
|
348
|
+
state: "not-dispatched" | "awaiting-dispatch" | "dispatching" | "dispatched" | "dispatch-unknown";
|
|
349
|
+
attemptId?: string;
|
|
350
|
+
at?: string;
|
|
351
|
+
reason?: string;
|
|
352
|
+
code?: string;
|
|
353
|
+
errorCode?: string;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface DelegationChildStatus {
|
|
357
|
+
sessionId: string;
|
|
358
|
+
present: boolean;
|
|
359
|
+
state: string;
|
|
360
|
+
agentId?: string;
|
|
361
|
+
model?: string | null;
|
|
362
|
+
active?: boolean;
|
|
363
|
+
turns?: number;
|
|
364
|
+
archived?: boolean;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface DelegationView {
|
|
368
|
+
context?: { mode: 'parent-snapshot'; truncated: boolean };
|
|
369
|
+
delegation: DelegationCommandRecord;
|
|
370
|
+
phase: DelegationPhase;
|
|
371
|
+
outcome: DelegationOutcome;
|
|
372
|
+
dispatch: DelegationDispatchState;
|
|
373
|
+
child: DelegationChildStatus;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface DelegationAcceptResult extends DelegationView {
|
|
377
|
+
accepted: boolean;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export interface DelegationListPage {
|
|
381
|
+
scope: TaskScope;
|
|
382
|
+
delegations: DelegationView[];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// POST /sessions/:id/delegations request body. parentSessionId comes from the
|
|
386
|
+
// route only; delegationId/childSessionId/workspaceRef are server-generated.
|
|
387
|
+
export interface DelegationCommandInput {
|
|
388
|
+
contextMode?: 'parent-snapshot';
|
|
389
|
+
scope: {storeScope: string; contextId: string};
|
|
390
|
+
requestId: string;
|
|
391
|
+
text: string;
|
|
392
|
+
agentId?: string;
|
|
393
|
+
aiProfileId?: string | null;
|
|
394
|
+
model?: string | null;
|
|
395
|
+
permissionMode?: PermissionMode;
|
|
396
|
+
effort?: EffortLevel;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export interface SessionChangeEvent {
|
|
400
|
+
type: 'workbench/session-changed' | 'workbench/sessions-snapshot' | 'workbench/resync';
|
|
401
|
+
revision: number;
|
|
402
|
+
contextId?: string;
|
|
403
|
+
session?: SessionSummary;
|
|
404
|
+
sessions?: SessionSummary[];
|
|
405
|
+
deleted?: boolean;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export interface WorkbenchResyncEvent {
|
|
409
|
+
type: "workbench/resync";
|
|
410
|
+
sessionId: string;
|
|
411
|
+
contextId: string;
|
|
412
|
+
at?: string;
|
|
413
|
+
reason: ResyncReason;
|
|
414
|
+
from: number;
|
|
415
|
+
highWater: number;
|
|
416
|
+
firstSequence: number;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export interface WorkbenchEvent {
|
|
420
|
+
type: string;
|
|
421
|
+
sessionId: string;
|
|
422
|
+
contextId: string;
|
|
423
|
+
sequence?: number;
|
|
424
|
+
at: string;
|
|
425
|
+
[key: string]: unknown;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
export interface ImageAttachmentInput {
|
|
429
|
+
id?: string;
|
|
430
|
+
name: string;
|
|
431
|
+
mediaType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
|
|
432
|
+
data: string;
|
|
433
|
+
size?: number;
|
|
434
|
+
width?: number;
|
|
435
|
+
height?: number;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export interface ImageAttachment {
|
|
439
|
+
id: string;
|
|
440
|
+
name: string;
|
|
441
|
+
mediaType: ImageAttachmentInput["mediaType"];
|
|
442
|
+
size: number;
|
|
443
|
+
width?: number;
|
|
444
|
+
height?: number;
|
|
445
|
+
url: string;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface TextAttachmentInput {
|
|
449
|
+
id?: string;
|
|
450
|
+
name: string;
|
|
451
|
+
mediaType: "text/plain" | "text/markdown" | "application/json" | "text/csv";
|
|
452
|
+
data: string;
|
|
453
|
+
size?: number;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export type AttachmentInput = ImageAttachmentInput | TextAttachmentInput;
|
|
457
|
+
export interface TextAttachment {
|
|
458
|
+
id: string;
|
|
459
|
+
name: string;
|
|
460
|
+
mediaType: TextAttachmentInput["mediaType"];
|
|
461
|
+
size: number;
|
|
462
|
+
url: string;
|
|
463
|
+
}
|
|
464
|
+
export type Attachment = ImageAttachment | TextAttachment;
|
|
465
|
+
|
|
466
|
+
export interface SlashCommand {
|
|
467
|
+
name: string;
|
|
468
|
+
description: string;
|
|
469
|
+
argumentHint?: string;
|
|
470
|
+
aliases?: string[];
|
|
471
|
+
source?: string;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export interface SessionSnapshot {
|
|
475
|
+
session: SessionSummary;
|
|
476
|
+
events: WorkbenchEvent[];
|
|
477
|
+
permission: Record<string, unknown> | null;
|
|
478
|
+
permissionMode: PermissionMode;
|
|
479
|
+
tokenUsage: Record<string, unknown>;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export interface SessionHistoryPage {
|
|
483
|
+
events: WorkbenchEvent[];
|
|
484
|
+
nextCursor: string | null;
|
|
485
|
+
incomplete: boolean;
|
|
486
|
+
highWater: number;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export declare const API_VERSION: "v1";
|
|
490
|
+
export declare const DEFAULT_API_PREFIX: "/api/claude-workbench/v1";
|
|
491
|
+
export declare const RUNTIME: "claude-code";
|
|
492
|
+
export declare const DEFAULT_AGENT: AgentId;
|
|
493
|
+
export declare const AGENT_IDS: readonly AgentId[];
|
|
494
|
+
export declare const EFFORT_LEVELS: readonly EffortLevel[];
|
|
495
|
+
export declare const AGENTS: Record<AgentId, AgentDefinition>;
|
|
496
|
+
export declare const PERMISSION_MODES: readonly PermissionMode[];
|
|
497
|
+
export declare const IMAGE_MEDIA_TYPES: readonly ImageAttachmentInput["mediaType"][];
|
|
498
|
+
export declare const TEXT_MEDIA_TYPES: readonly TextAttachmentInput["mediaType"][];
|
|
499
|
+
export declare const TEXT_FILE_TYPES: Readonly<Record<string, TextAttachmentInput["mediaType"]>>;
|
|
500
|
+
export declare const MAX_IMAGE_BYTES: number;
|
|
501
|
+
export declare const MAX_IMAGES_PER_MESSAGE: number;
|
|
502
|
+
export declare const MAX_IMAGE_MESSAGE_BYTES: number;
|
|
503
|
+
export declare const MAX_TEXT_BYTES: number;
|
|
504
|
+
export declare const MAX_ATTACHMENTS_PER_MESSAGE: number;
|
|
505
|
+
export declare const MAX_ATTACHMENT_MESSAGE_BYTES: number;
|
|
506
|
+
export declare const EVENT_TYPES: readonly string[];
|
|
507
|
+
export declare function cleanId(value: unknown, field?: string): string;
|
|
508
|
+
export declare function normalizeContext(input: unknown): WorkbenchContext;
|
|
509
|
+
export declare function normalizeProfile(input: unknown, idOverride?: string): AiProfile;
|
|
510
|
+
export declare function normalizeProject(input: unknown, idOverride?: string): Project;
|
|
511
|
+
export declare function normalizeAgentId(value: unknown): AgentId;
|
|
512
|
+
export declare function normalizeEffort(value: unknown): EffortLevel | undefined;
|
|
513
|
+
export declare function normalizeModelEntries(input: unknown): ModelListEntry[];
|
|
514
|
+
export declare function normalizeImageAttachments(input: unknown): Array<ImageAttachmentInput & { size: number }>;
|
|
515
|
+
export declare function normalizeAttachments(input: unknown): Array<AttachmentInput & { size: number }>;
|
|
516
|
+
export declare function appendTextAttachments(text: string, attachments?: AttachmentInput[]): string;
|
|
517
|
+
export declare function resolveOpenAIBaseUrl(profile?: Partial<AiProfileInput>): string;
|
|
518
|
+
export declare function resolveOpenAIModel(profile?: Partial<AiProfileInput> & { mainModel?: string }, model?: string): string;
|
|
519
|
+
export declare function positiveInt(value: unknown, fallback: number): number;
|