@sanqianx/claude-ai-workbench 0.13.2 → 0.13.4
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 +652 -613
- package/apps/agent-terminal/app.js +143 -67
- package/apps/agent-terminal/conversation-composer.js +44 -0
- package/apps/agent-terminal/index.html +172 -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 +189 -159
- package/apps/agent-terminal/right-workspace-dock.js +652 -521
- package/apps/agent-terminal/user-question-card.js +68 -0
- 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 +15 -13
- package/docs/sdk/openapi.yaml +16 -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 +1461 -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/user-questions.js +67 -0
- 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 +2408 -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,29 +1,29 @@
|
|
|
1
|
-
# @claude-ai-workbench/client
|
|
2
|
-
|
|
3
|
-
浏览器和 Node.js 使用的 HTTP/SSE Client SDK。
|
|
4
|
-
|
|
5
|
-
```js
|
|
6
|
-
const { createClaudeWorkbenchClient } = require("@claude-ai-workbench/client");
|
|
7
|
-
const client = createClaudeWorkbenchClient({ apiBase: "http://127.0.0.1:5760/api/claude-workbench/v1" });
|
|
8
|
-
const profiles = await client.listProfiles();
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
浏览器也可直接加载 `index.js`,然后使用全局函数 `createClaudeWorkbenchClient`。
|
|
12
|
-
|
|
13
|
-
## 原生任务历史(只读)
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
const page = await client.listNativeTasks(sessionId, { storeScope, contextId });
|
|
17
|
-
const ref = page.tasks.find((t) => t.taskRef)?.taskRef; // null = 尚未建立归属
|
|
18
|
-
if (ref) {
|
|
19
|
-
let events = await client.loadNativeTaskHistory(sessionId, { taskRef: ref });
|
|
20
|
-
while (events.hasMore) {
|
|
21
|
-
events = await client.loadNativeTaskHistory(sessionId, { taskRef: ref, cursor: events.nextCursor });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
- `listNativeTasks` 必须传服务端身份(health 的 `taskIdentity.storeScope`)与该会话真实 `contextId`,逐项比对不符即 409。
|
|
27
|
-
- `loadNativeTaskHistory` 需要列表页返回的完整 `NativeTaskRef`(含全部身份字段),不能缩成 taskId;cursor 只回传上一页的 `nextCursor`,不得自行构造。
|
|
28
|
-
- 两个方法均为纯读取:不派发输入、不停止任务、不自动重试。响应中的 `incomplete`/`diagnostics` 如实反映日志扫描的已知缺口。
|
|
29
|
-
- 失败抛出的 Error 带 `status` 与 `body`,服务器提供时还带 `code`(如 `SCOPE_MISMATCH`、`HISTORY_NOT_FOUND`、写失败闩锁的具体原因)与 `resync: true`(409:从任务列表重新同步);503 表示历史暂不可读或写失败已闩锁,原文件保持不动。
|
|
1
|
+
# @claude-ai-workbench/client
|
|
2
|
+
|
|
3
|
+
浏览器和 Node.js 使用的 HTTP/SSE Client SDK。
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
const { createClaudeWorkbenchClient } = require("@claude-ai-workbench/client");
|
|
7
|
+
const client = createClaudeWorkbenchClient({ apiBase: "http://127.0.0.1:5760/api/claude-workbench/v1" });
|
|
8
|
+
const profiles = await client.listProfiles();
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
浏览器也可直接加载 `index.js`,然后使用全局函数 `createClaudeWorkbenchClient`。
|
|
12
|
+
|
|
13
|
+
## 原生任务历史(只读)
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
const page = await client.listNativeTasks(sessionId, { storeScope, contextId });
|
|
17
|
+
const ref = page.tasks.find((t) => t.taskRef)?.taskRef; // null = 尚未建立归属
|
|
18
|
+
if (ref) {
|
|
19
|
+
let events = await client.loadNativeTaskHistory(sessionId, { taskRef: ref });
|
|
20
|
+
while (events.hasMore) {
|
|
21
|
+
events = await client.loadNativeTaskHistory(sessionId, { taskRef: ref, cursor: events.nextCursor });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- `listNativeTasks` 必须传服务端身份(health 的 `taskIdentity.storeScope`)与该会话真实 `contextId`,逐项比对不符即 409。
|
|
27
|
+
- `loadNativeTaskHistory` 需要列表页返回的完整 `NativeTaskRef`(含全部身份字段),不能缩成 taskId;cursor 只回传上一页的 `nextCursor`,不得自行构造。
|
|
28
|
+
- 两个方法均为纯读取:不派发输入、不停止任务、不自动重试。响应中的 `incomplete`/`diagnostics` 如实反映日志扫描的已知缺口。
|
|
29
|
+
- 失败抛出的 Error 带 `status` 与 `body`,服务器提供时还带 `code`(如 `SCOPE_MISMATCH`、`HISTORY_NOT_FOUND`、写失败闩锁的具体原因)与 `resync: true`(409:从任务列表重新同步);503 表示历史暂不可读或写失败已闩锁,原文件保持不动。
|
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AgentId,
|
|
3
|
-
AgentStatus,
|
|
4
|
-
AiProfile,
|
|
5
|
-
AiProfileInput,
|
|
6
|
-
CredentialInput,
|
|
7
|
-
DelegationAcceptResult,
|
|
8
|
-
DelegationCommandInput,
|
|
9
|
-
DelegationListPage,
|
|
10
|
-
EffortLevel,
|
|
11
|
-
HealthResult,
|
|
12
|
-
PermissionMode,
|
|
13
|
-
ProfileTestResult,
|
|
14
|
-
Project,
|
|
15
|
-
ProjectInput,
|
|
16
|
-
ProjectPatch,
|
|
17
|
-
RuntimeInfo,
|
|
18
|
-
NativeTaskEventsPage,
|
|
19
|
-
NativeTaskListPage,
|
|
20
|
-
NativeTaskRef,
|
|
21
|
-
AttachmentInput,
|
|
22
|
-
SlashCommand,
|
|
23
|
-
SessionSnapshot,
|
|
24
|
-
SessionHistoryPage,
|
|
25
|
-
SessionSummary,
|
|
26
|
-
SessionChangeEvent,
|
|
27
|
-
WorkbenchContext,
|
|
28
|
-
WorkbenchEvent,
|
|
29
|
-
} from "@claude-ai-workbench/contracts";
|
|
30
|
-
|
|
31
|
-
export interface RequestOptions { signal?: AbortSignal; [key: string]: unknown; }
|
|
32
|
-
export interface StartSessionOptions extends RequestOptions {
|
|
33
|
-
permissionMode?: PermissionMode;
|
|
34
|
-
agentId?: AgentId;
|
|
35
|
-
effort?: EffortLevel;
|
|
36
|
-
aiProfileId?: string | null;
|
|
37
|
-
model?: string | null;
|
|
38
|
-
inputOrigin?: 'human' | 'agent-delegation' | 'unknown';
|
|
39
|
-
}
|
|
40
|
-
export interface ListSessionsOptions extends RequestOptions { archived?: boolean; includeArchived?: boolean; }
|
|
41
|
-
export interface SendOptions { permissionMode?: PermissionMode; [key: string]: unknown; }
|
|
42
|
-
// Scope echo the server compares against its own frozen identity: exactly
|
|
43
|
-
// the fields from the trusted task scope, never client-invented ones.
|
|
44
|
-
export interface NativeTaskScopeQuery { storeScope: string; contextId: string; }
|
|
45
|
-
// One task's durable history page request. taskRef must be the full
|
|
46
|
-
// reference echoed from a list result - reducing it to taskId cannot address
|
|
47
|
-
// the task.
|
|
48
|
-
export interface LoadNativeTaskHistoryOptions extends RequestOptions {
|
|
49
|
-
taskRef: NativeTaskRef;
|
|
50
|
-
cursor?: string | null;
|
|
51
|
-
limit?: number;
|
|
52
|
-
}
|
|
53
|
-
// Scope echo the server compares against its own frozen identity for
|
|
54
|
-
// delegation reads; same contract as NativeTaskScopeQuery.
|
|
55
|
-
export interface DelegationScopeQuery { storeScope: string; contextId: string; }
|
|
56
|
-
// Thrown for every non-2xx response; status/body always carry the raw HTTP
|
|
57
|
-
// truth, code/resync mirror the structured server verdict when present
|
|
58
|
-
// (e.g. 409 SCOPE_MISMATCH with resync, or a 503 latched write-failure code).
|
|
59
|
-
export interface WorkbenchRequestError extends Error {
|
|
60
|
-
status: number;
|
|
61
|
-
body: Record<string, unknown> | null;
|
|
62
|
-
code?: string;
|
|
63
|
-
resync?: boolean;
|
|
64
|
-
}
|
|
65
|
-
export interface StreamHandlers {
|
|
66
|
-
onEvent?: (event: WorkbenchEvent) => void;
|
|
67
|
-
onError?: (error: Error) => void;
|
|
68
|
-
onOpen?: () => void;
|
|
69
|
-
afterSequence?: number;
|
|
70
|
-
}
|
|
71
|
-
export interface ClientResourceCounts { streams: number; requests: number; reconnects: number; }
|
|
72
|
-
export interface ClaudeWorkbenchClientOptions {
|
|
73
|
-
apiBase?: string;
|
|
74
|
-
fetch?: typeof fetch;
|
|
75
|
-
EventSource?: typeof EventSource;
|
|
76
|
-
readTimeoutMs?: number;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface ClaudeWorkbenchClient {
|
|
80
|
-
health(): Promise<HealthResult>;
|
|
81
|
-
runtime(): Promise<RuntimeInfo>;
|
|
82
|
-
listAgents(): Promise<AgentStatus[]>;
|
|
83
|
-
agentStatus(): Promise<{ agents: AgentStatus[]; scan?: { state: string; generation: number; updatedAt: string | null } }>;
|
|
84
|
-
refreshAgents(): ReturnType<ClaudeWorkbenchClient['agentStatus']>;
|
|
85
|
-
listProjects(): Promise<Project[]>;
|
|
86
|
-
createProject(project: ProjectInput): Promise<Project>;
|
|
87
|
-
getProject(id: string): Promise<Project>;
|
|
88
|
-
renameProject(id: string, name: string): Promise<Project>;
|
|
89
|
-
updateProject(id: string, patch: ProjectPatch): Promise<Project>;
|
|
90
|
-
removeProject(id: string): Promise<void>;
|
|
91
|
-
listProfiles(): Promise<AiProfile[]>;
|
|
92
|
-
saveProfile(profile: AiProfileInput): Promise<AiProfile>;
|
|
93
|
-
deleteProfile(id: string): Promise<void>;
|
|
94
|
-
setCredential(id: string, credential: string | CredentialInput): Promise<void>;
|
|
95
|
-
testProfile(id: string): Promise<ProfileTestResult>;
|
|
96
|
-
testProfileDraft(profile: AiProfileInput, credential?: string): Promise<ProfileTestResult>;
|
|
97
|
-
listSessions(context: WorkbenchContext | string, options?: ListSessionsOptions): Promise<SessionSummary[]>;
|
|
98
|
-
startSession(context: WorkbenchContext, options?: StartSessionOptions): Promise<SessionSummary>;
|
|
99
|
-
loadSession(id: string, options?: RequestOptions): Promise<SessionSnapshot>;
|
|
100
|
-
loadHistory(id: string, options?: RequestOptions & { before?: string; limit?: number }): Promise<SessionHistoryPage>;
|
|
101
|
-
listNativeTasks(id: string, scope: NativeTaskScopeQuery, options?: RequestOptions): Promise<NativeTaskListPage>;
|
|
102
|
-
loadNativeTaskHistory(id: string, options: LoadNativeTaskHistoryOptions): Promise<NativeTaskEventsPage>;
|
|
103
|
-
createDelegation(id: string, payload: DelegationCommandInput, options?: RequestOptions): Promise<DelegationAcceptResult>;
|
|
104
|
-
listDelegations(id: string, scope: DelegationScopeQuery, options?: RequestOptions): Promise<DelegationListPage>;
|
|
105
|
-
listCommands(id: string, options?: RequestOptions): Promise<SlashCommand[]>;
|
|
106
|
-
subscribe(id: string, handlers: StreamHandlers | ((event: WorkbenchEvent) => void), onError?: (error: Error) => void, options?: {afterSequence?: number}): () => void;
|
|
107
|
-
subscribeSessionChanges(contextId: string, handlers: ((event: SessionChangeEvent) => void), onError?: (error: Error) => void, options?: {afterRevision?: number; onOpen?: () => void}): () => void;
|
|
108
|
-
send(sessionId: string, text: string, options?: SendOptions): Promise<unknown>;
|
|
109
|
-
send(args: {sessionId: string; text?: string; attachments?: AttachmentInput[]; options?: SendOptions}): Promise<unknown>;
|
|
110
|
-
resolvePermission(sessionId: string, requestId: string, allow: boolean, message?: string): Promise<unknown>;
|
|
111
|
-
resolvePermission(args: {sessionId: string; requestId: string; allow: boolean; message?: string}): Promise<unknown>;
|
|
112
|
-
abort(sessionId: string | {sessionId: string}): Promise<unknown>;
|
|
113
|
-
setPermissionMode(sessionId: string, mode: PermissionMode): Promise<unknown>;
|
|
114
|
-
setPermissionMode(args: {sessionId: string; mode: PermissionMode}): Promise<unknown>;
|
|
115
|
-
archiveSession(sessionId: string | {sessionId: string}): Promise<{sessionId: string; archivedAt: string}>;
|
|
116
|
-
restoreSession(sessionId: string | {sessionId: string}): Promise<void>;
|
|
117
|
-
resourceCounts(): ClientResourceCounts;
|
|
118
|
-
destroy(): void;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export declare const EVENT_TYPES: readonly string[];
|
|
122
|
-
export declare function createClaudeWorkbenchClient(options?: ClaudeWorkbenchClientOptions): ClaudeWorkbenchClient;
|
|
1
|
+
import type {
|
|
2
|
+
AgentId,
|
|
3
|
+
AgentStatus,
|
|
4
|
+
AiProfile,
|
|
5
|
+
AiProfileInput,
|
|
6
|
+
CredentialInput,
|
|
7
|
+
DelegationAcceptResult,
|
|
8
|
+
DelegationCommandInput,
|
|
9
|
+
DelegationListPage,
|
|
10
|
+
EffortLevel,
|
|
11
|
+
HealthResult,
|
|
12
|
+
PermissionMode,
|
|
13
|
+
ProfileTestResult,
|
|
14
|
+
Project,
|
|
15
|
+
ProjectInput,
|
|
16
|
+
ProjectPatch,
|
|
17
|
+
RuntimeInfo,
|
|
18
|
+
NativeTaskEventsPage,
|
|
19
|
+
NativeTaskListPage,
|
|
20
|
+
NativeTaskRef,
|
|
21
|
+
AttachmentInput,
|
|
22
|
+
SlashCommand,
|
|
23
|
+
SessionSnapshot,
|
|
24
|
+
SessionHistoryPage,
|
|
25
|
+
SessionSummary,
|
|
26
|
+
SessionChangeEvent,
|
|
27
|
+
WorkbenchContext,
|
|
28
|
+
WorkbenchEvent,
|
|
29
|
+
} from "@claude-ai-workbench/contracts";
|
|
30
|
+
|
|
31
|
+
export interface RequestOptions { signal?: AbortSignal; [key: string]: unknown; }
|
|
32
|
+
export interface StartSessionOptions extends RequestOptions {
|
|
33
|
+
permissionMode?: PermissionMode;
|
|
34
|
+
agentId?: AgentId;
|
|
35
|
+
effort?: EffortLevel;
|
|
36
|
+
aiProfileId?: string | null;
|
|
37
|
+
model?: string | null;
|
|
38
|
+
inputOrigin?: 'human' | 'agent-delegation' | 'unknown';
|
|
39
|
+
}
|
|
40
|
+
export interface ListSessionsOptions extends RequestOptions { archived?: boolean; includeArchived?: boolean; }
|
|
41
|
+
export interface SendOptions { permissionMode?: PermissionMode; [key: string]: unknown; }
|
|
42
|
+
// Scope echo the server compares against its own frozen identity: exactly
|
|
43
|
+
// the fields from the trusted task scope, never client-invented ones.
|
|
44
|
+
export interface NativeTaskScopeQuery { storeScope: string; contextId: string; }
|
|
45
|
+
// One task's durable history page request. taskRef must be the full
|
|
46
|
+
// reference echoed from a list result - reducing it to taskId cannot address
|
|
47
|
+
// the task.
|
|
48
|
+
export interface LoadNativeTaskHistoryOptions extends RequestOptions {
|
|
49
|
+
taskRef: NativeTaskRef;
|
|
50
|
+
cursor?: string | null;
|
|
51
|
+
limit?: number;
|
|
52
|
+
}
|
|
53
|
+
// Scope echo the server compares against its own frozen identity for
|
|
54
|
+
// delegation reads; same contract as NativeTaskScopeQuery.
|
|
55
|
+
export interface DelegationScopeQuery { storeScope: string; contextId: string; }
|
|
56
|
+
// Thrown for every non-2xx response; status/body always carry the raw HTTP
|
|
57
|
+
// truth, code/resync mirror the structured server verdict when present
|
|
58
|
+
// (e.g. 409 SCOPE_MISMATCH with resync, or a 503 latched write-failure code).
|
|
59
|
+
export interface WorkbenchRequestError extends Error {
|
|
60
|
+
status: number;
|
|
61
|
+
body: Record<string, unknown> | null;
|
|
62
|
+
code?: string;
|
|
63
|
+
resync?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface StreamHandlers {
|
|
66
|
+
onEvent?: (event: WorkbenchEvent) => void;
|
|
67
|
+
onError?: (error: Error) => void;
|
|
68
|
+
onOpen?: () => void;
|
|
69
|
+
afterSequence?: number;
|
|
70
|
+
}
|
|
71
|
+
export interface ClientResourceCounts { streams: number; requests: number; reconnects: number; }
|
|
72
|
+
export interface ClaudeWorkbenchClientOptions {
|
|
73
|
+
apiBase?: string;
|
|
74
|
+
fetch?: typeof fetch;
|
|
75
|
+
EventSource?: typeof EventSource;
|
|
76
|
+
readTimeoutMs?: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface ClaudeWorkbenchClient {
|
|
80
|
+
health(): Promise<HealthResult>;
|
|
81
|
+
runtime(): Promise<RuntimeInfo>;
|
|
82
|
+
listAgents(): Promise<AgentStatus[]>;
|
|
83
|
+
agentStatus(): Promise<{ agents: AgentStatus[]; scan?: { state: string; generation: number; updatedAt: string | null } }>;
|
|
84
|
+
refreshAgents(): ReturnType<ClaudeWorkbenchClient['agentStatus']>;
|
|
85
|
+
listProjects(): Promise<Project[]>;
|
|
86
|
+
createProject(project: ProjectInput): Promise<Project>;
|
|
87
|
+
getProject(id: string): Promise<Project>;
|
|
88
|
+
renameProject(id: string, name: string): Promise<Project>;
|
|
89
|
+
updateProject(id: string, patch: ProjectPatch): Promise<Project>;
|
|
90
|
+
removeProject(id: string): Promise<void>;
|
|
91
|
+
listProfiles(): Promise<AiProfile[]>;
|
|
92
|
+
saveProfile(profile: AiProfileInput): Promise<AiProfile>;
|
|
93
|
+
deleteProfile(id: string): Promise<void>;
|
|
94
|
+
setCredential(id: string, credential: string | CredentialInput): Promise<void>;
|
|
95
|
+
testProfile(id: string): Promise<ProfileTestResult>;
|
|
96
|
+
testProfileDraft(profile: AiProfileInput, credential?: string): Promise<ProfileTestResult>;
|
|
97
|
+
listSessions(context: WorkbenchContext | string, options?: ListSessionsOptions): Promise<SessionSummary[]>;
|
|
98
|
+
startSession(context: WorkbenchContext, options?: StartSessionOptions): Promise<SessionSummary>;
|
|
99
|
+
loadSession(id: string, options?: RequestOptions): Promise<SessionSnapshot>;
|
|
100
|
+
loadHistory(id: string, options?: RequestOptions & { before?: string; limit?: number }): Promise<SessionHistoryPage>;
|
|
101
|
+
listNativeTasks(id: string, scope: NativeTaskScopeQuery, options?: RequestOptions): Promise<NativeTaskListPage>;
|
|
102
|
+
loadNativeTaskHistory(id: string, options: LoadNativeTaskHistoryOptions): Promise<NativeTaskEventsPage>;
|
|
103
|
+
createDelegation(id: string, payload: DelegationCommandInput, options?: RequestOptions): Promise<DelegationAcceptResult>;
|
|
104
|
+
listDelegations(id: string, scope: DelegationScopeQuery, options?: RequestOptions): Promise<DelegationListPage>;
|
|
105
|
+
listCommands(id: string, options?: RequestOptions): Promise<SlashCommand[]>;
|
|
106
|
+
subscribe(id: string, handlers: StreamHandlers | ((event: WorkbenchEvent) => void), onError?: (error: Error) => void, options?: {afterSequence?: number; onOpen?: () => void}): () => void;
|
|
107
|
+
subscribeSessionChanges(contextId: string, handlers: ((event: SessionChangeEvent) => void), onError?: (error: Error) => void, options?: {afterRevision?: number; onOpen?: () => void}): () => void;
|
|
108
|
+
send(sessionId: string, text: string, options?: SendOptions): Promise<unknown>;
|
|
109
|
+
send(args: {sessionId: string; text?: string; attachments?: AttachmentInput[]; options?: SendOptions}): Promise<unknown>;
|
|
110
|
+
resolvePermission(sessionId: string, requestId: string, allow: boolean, message?: string): Promise<unknown>;
|
|
111
|
+
resolvePermission(args: {sessionId: string; requestId: string; allow: boolean; message?: string; answers?: Record<string, string[]>}): Promise<unknown>;
|
|
112
|
+
abort(sessionId: string | {sessionId: string}): Promise<unknown>;
|
|
113
|
+
setPermissionMode(sessionId: string, mode: PermissionMode): Promise<unknown>;
|
|
114
|
+
setPermissionMode(args: {sessionId: string; mode: PermissionMode}): Promise<unknown>;
|
|
115
|
+
archiveSession(sessionId: string | {sessionId: string}): Promise<{sessionId: string; archivedAt: string}>;
|
|
116
|
+
restoreSession(sessionId: string | {sessionId: string}): Promise<void>;
|
|
117
|
+
resourceCounts(): ClientResourceCounts;
|
|
118
|
+
destroy(): void;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export declare const EVENT_TYPES: readonly string[];
|
|
122
|
+
export declare function createClaudeWorkbenchClient(options?: ClaudeWorkbenchClientOptions): ClaudeWorkbenchClient;
|