@daex-dev/sdk 0.0.0-stage → 0.7.1
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 +21 -0
- package/README.md +417 -3
- package/dist/client-C0KQKP8O.d.cts +2621 -0
- package/dist/client-C0KQKP8O.d.ts +2621 -0
- package/dist/electron/global.cjs +18 -0
- package/dist/electron/global.d.cts +35 -0
- package/dist/electron/global.d.ts +35 -0
- package/dist/electron/global.js +0 -0
- package/dist/electron/index.cjs +1133 -0
- package/dist/electron/index.d.cts +510 -0
- package/dist/electron/index.d.ts +510 -0
- package/dist/electron/index.js +1073 -0
- package/dist/electron/preload-auto.cjs +38 -0
- package/dist/electron/preload.cjs +66 -0
- package/dist/electron/preload.d.cts +46 -0
- package/dist/electron/preload.d.ts +46 -0
- package/dist/electron/preload.js +43 -0
- package/dist/electron/protocol-DXRtliy3.d.cts +904 -0
- package/dist/electron/protocol-DXRtliy3.d.ts +904 -0
- package/dist/electron/renderer.cjs +631 -0
- package/dist/electron/renderer.d.cts +508 -0
- package/dist/electron/renderer.d.ts +508 -0
- package/dist/electron/renderer.global.js +634 -0
- package/dist/electron/renderer.js +608 -0
- package/dist/index.cjs +6681 -0
- package/dist/index.d.cts +313 -0
- package/dist/index.d.ts +313 -0
- package/dist/index.js +6611 -0
- package/dist/server.cjs +1019 -0
- package/dist/server.d.cts +118 -0
- package/dist/server.d.ts +118 -0
- package/dist/server.js +989 -0
- package/dist/testing.cjs +815 -0
- package/dist/testing.d.cts +29 -0
- package/dist/testing.d.ts +29 -0
- package/dist/testing.js +787 -0
- package/package.json +93 -6
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { P as PendingInputKind, e as DaexProvider, f as PendingInputRequest, g as AgentChatFileRef, h as AgentChatStopMode, i as AgentChatRespondToInputArgs, T as ThreadModelSelection, j as ThreadCapabilities, k as ProviderStatus, l as ProviderCapabilities, U as Unsubscribe, M as ModelCatalogEntry, m as McpCapabilityReport, n as InstructionsCapability, S as SettingSourcesCapability, o as PermissionCapability, p as AgentChatSlashCommand, q as AgentChatRecoverTurnResult, r as AgentChatResolveUnprocessedMessageResult, s as AgentChatUsageLimitResult, t as AgentChatSwitchAccountResult, u as AgentChatEventEnvelope, v as ThreadHistoryPage, w as ThreadSummary, x as DoctorReport, y as DaexClientEvent, z as DaexClientEventMap, D as DaexBridge } from './protocol-DXRtliy3.cjs';
|
|
2
|
+
export { A as AdeBridge, B as compareEnvelopes, E as envelopeDedupeKey, F as mergeHistoryWithBuffer } from './protocol-DXRtliy3.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The approval half of the pending-input surface.
|
|
6
|
+
*
|
|
7
|
+
* A provider that wants a decision emits `approval_request` and then BLOCKS.
|
|
8
|
+
* There is no timeout in the runtime, so the turn stays parked until something
|
|
9
|
+
* answers it. `thread.approve()` is the answer; `thread.interrupt()` is the
|
|
10
|
+
* abort. A host that renders neither has a chat that looks frozen.
|
|
11
|
+
*/
|
|
12
|
+
/** What a host can say about a pending approval. */
|
|
13
|
+
type ApprovalDecision = "accept" | "accept_always" | "reject";
|
|
14
|
+
/** One request a host has to answer before its turn can continue. */
|
|
15
|
+
type ApprovalRequest = {
|
|
16
|
+
/** The id to pass to `approve()`. */
|
|
17
|
+
itemId: string;
|
|
18
|
+
/** Groups retries of one logical action, when the provider reports one. */
|
|
19
|
+
logicalItemId?: string;
|
|
20
|
+
/** The shape of the thing being confirmed. */
|
|
21
|
+
kind: "command" | "file_change" | "tool_call";
|
|
22
|
+
/**
|
|
23
|
+
* The finer-grained kind.
|
|
24
|
+
*
|
|
25
|
+
* `"approval"` and `"permissions"` are answerable with `approve()`. Use
|
|
26
|
+
* `respond()` for `"question"` and `"structured_question"` requests, with
|
|
27
|
+
* answers keyed by question id, and for `"plan_approval"` with an explicit
|
|
28
|
+
* decision. A runtime may leave other request kinds read-only.
|
|
29
|
+
*/
|
|
30
|
+
requestKind?: PendingInputKind;
|
|
31
|
+
/** Human-readable and provider-supplied. Safe to render. */
|
|
32
|
+
description: string;
|
|
33
|
+
turnId?: string;
|
|
34
|
+
/** Provider payload: the command string, the patch, the tool input. */
|
|
35
|
+
detail?: unknown;
|
|
36
|
+
/** Which provider raised it. */
|
|
37
|
+
provider: DaexProvider;
|
|
38
|
+
/** The original prompts for requests answered through `respond()`. */
|
|
39
|
+
questions?: PendingInputRequest["questions"];
|
|
40
|
+
/** False when the runtime cannot answer this request through the SDK. */
|
|
41
|
+
answerable?: boolean;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type AccountUsage = {
|
|
45
|
+
state: "ok" | "stale" | "expired" | "signed_out" | "no_reading" | "error";
|
|
46
|
+
readAt: string | null;
|
|
47
|
+
note: string | null;
|
|
48
|
+
windows: Array<{
|
|
49
|
+
type: string;
|
|
50
|
+
label: string;
|
|
51
|
+
percentLeft: number;
|
|
52
|
+
resetsAt: string | null;
|
|
53
|
+
unlimited?: true;
|
|
54
|
+
countLeft?: number;
|
|
55
|
+
countTotal?: number;
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
58
|
+
type AccountInfo = {
|
|
59
|
+
id: string;
|
|
60
|
+
provider: string;
|
|
61
|
+
label: string;
|
|
62
|
+
email?: string;
|
|
63
|
+
plan?: string;
|
|
64
|
+
signedIn: boolean;
|
|
65
|
+
isDefault: boolean;
|
|
66
|
+
loginBroken?: boolean;
|
|
67
|
+
accentColor?: string;
|
|
68
|
+
createdAt?: string;
|
|
69
|
+
usage?: AccountUsage;
|
|
70
|
+
};
|
|
71
|
+
type ApiCredentialInfo = {
|
|
72
|
+
provider: string;
|
|
73
|
+
credentialId: string;
|
|
74
|
+
label: string;
|
|
75
|
+
envVar?: string;
|
|
76
|
+
baseUrl?: string;
|
|
77
|
+
protocol?: "openai-compatible" | "openai-responses" | "anthropic";
|
|
78
|
+
models?: string[];
|
|
79
|
+
source: "store" | "env" | "config";
|
|
80
|
+
createdAt: string;
|
|
81
|
+
updatedAt: string;
|
|
82
|
+
maskedTail?: string;
|
|
83
|
+
};
|
|
84
|
+
type SignInStatus = {
|
|
85
|
+
loginId: string;
|
|
86
|
+
instanceId: string;
|
|
87
|
+
provider: string;
|
|
88
|
+
state: "running" | "verifying" | "succeeded" | "failed" | "cancelled" | "expired";
|
|
89
|
+
url: string | null;
|
|
90
|
+
awaitingCode: boolean;
|
|
91
|
+
deviceCode?: string;
|
|
92
|
+
email?: string;
|
|
93
|
+
message?: string;
|
|
94
|
+
startedAt: string;
|
|
95
|
+
endedAt?: string;
|
|
96
|
+
};
|
|
97
|
+
type SignInHandle = {
|
|
98
|
+
on(event: "update", listener: (status: SignInStatus) => void): () => void;
|
|
99
|
+
submitCode(code: string): Promise<void>;
|
|
100
|
+
cancel(): Promise<void>;
|
|
101
|
+
done: Promise<AccountInfo>;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Every error this package throws carries a stable machine-readable code.
|
|
106
|
+
*
|
|
107
|
+
* Kept as its own union rather than derived from {@link ADE_ERROR_CODES} so
|
|
108
|
+
* each member can carry its own doc comment; a test asserts the two agree.
|
|
109
|
+
*/
|
|
110
|
+
type DaexErrorCode = "binary_not_found" | "download_failed" | "checksum_mismatch" | "spawn_failed" | "connect_failed" | "handshake_failed" | "rpc_error" | "rpc_timeout" | "transport_closed" | "protocol_error" | "thread_not_found" | "invalid_option"
|
|
111
|
+
/**
|
|
112
|
+
* No runtime could be resolved and `allowDownload: false` forbade fetching
|
|
113
|
+
* one. A packaging mistake must fail here, loudly, rather than work on the
|
|
114
|
+
* developer's machine through a silent download and fail on a locked-down
|
|
115
|
+
* user's.
|
|
116
|
+
*/
|
|
117
|
+
| "runtime_unavailable"
|
|
118
|
+
/**
|
|
119
|
+
* `approve()` named an item that is not pending. A stop, a teardown, or an
|
|
120
|
+
* earlier call already settled it; the engine settles unknown items silently,
|
|
121
|
+
* so the SDK checks first and says so rather than letting a no-op look like
|
|
122
|
+
* a success.
|
|
123
|
+
*/
|
|
124
|
+
| "approval_not_found"
|
|
125
|
+
/**
|
|
126
|
+
* A bridge refused the call before it reached the SDK — the host's
|
|
127
|
+
* `authorize` hook said no. Used by `@daex-dev/sdk/electron`.
|
|
128
|
+
*/
|
|
129
|
+
| "unauthorized" | "disposed"
|
|
130
|
+
/**
|
|
131
|
+
* The runtime's version is outside `SUPPORTED_RUNTIME_RANGE` and the host
|
|
132
|
+
* asked `createDaexChat` to refuse it (`requireCompatibleRuntime: true`).
|
|
133
|
+
* Without that option an unsupported runtime connects with a logged warning.
|
|
134
|
+
*/
|
|
135
|
+
| "runtime_incompatible"
|
|
136
|
+
/**
|
|
137
|
+
* The call was refused only because a turn is running on the thread:
|
|
138
|
+
* `setModel`, a reasoning `update`, `retry`, `editLast`, or a runtime action
|
|
139
|
+
* that must wait for the turn to end. Nothing changed. Wait for the turn to
|
|
140
|
+
* finish (or `interrupt()` it), then call again. `setModel` and `update`
|
|
141
|
+
* also accept `{ force: true }`. Before SDK 0.4 these refusals used
|
|
142
|
+
* `invalid_option`.
|
|
143
|
+
*/
|
|
144
|
+
| "turn_in_flight"
|
|
145
|
+
/**
|
|
146
|
+
* The thread's provider, or the runtime, cannot do what was asked. Nothing
|
|
147
|
+
* changed. `retry` and `editLast` throw it for a provider other than Claude
|
|
148
|
+
* or Codex, and for a runtime older than the `rerunLastTurn` action.
|
|
149
|
+
*/
|
|
150
|
+
| "unsupported" | "invalid_output"
|
|
151
|
+
/**
|
|
152
|
+
* A provider sign-in ended without signing in: it failed, was cancelled, or
|
|
153
|
+
* expired. The handle's last status says which (`state`) and why (`message`).
|
|
154
|
+
*/
|
|
155
|
+
| "sign_in_failed";
|
|
156
|
+
declare class DaexError extends Error {
|
|
157
|
+
readonly code: DaexErrorCode;
|
|
158
|
+
readonly cause?: unknown;
|
|
159
|
+
constructor(code: DaexErrorCode, message: string, options?: {
|
|
160
|
+
cause?: unknown;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/** @deprecated Use {@link DaexError}. */
|
|
164
|
+
declare const AdeError: typeof DaexError;
|
|
165
|
+
/** @deprecated Use {@link DaexError}. */
|
|
166
|
+
type AdeError = DaexError;
|
|
167
|
+
/** @deprecated Use {@link DaexErrorCode}. */
|
|
168
|
+
type AdeErrorCode = DaexErrorCode;
|
|
169
|
+
|
|
170
|
+
/** One message waiting in a thread's queue. */
|
|
171
|
+
type ThreadQueueItem = {
|
|
172
|
+
id: string;
|
|
173
|
+
text: string;
|
|
174
|
+
attachments?: AgentChatFileRef[];
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/** Options for `historyPage`. */
|
|
178
|
+
type HistoryPageOptions = {
|
|
179
|
+
/**
|
|
180
|
+
* Return events strictly older than this `sequence`. Omit for the newest
|
|
181
|
+
* page. Pass the previous page's `nextBeforeSequence` to walk backwards.
|
|
182
|
+
*/
|
|
183
|
+
beforeSequence?: number;
|
|
184
|
+
/**
|
|
185
|
+
* At most this many events. The runtime pages by bytes, so a page can hold
|
|
186
|
+
* fewer; when it holds more, the SDK keeps the newest `limit` and moves the
|
|
187
|
+
* cursor so nothing is skipped. Defaults to 200.
|
|
188
|
+
*/
|
|
189
|
+
limit?: number;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
type ThreadEventChannel = "event" | "usage" | "status";
|
|
193
|
+
type SetModelOptions = {
|
|
194
|
+
/**
|
|
195
|
+
* Switch even with a turn in flight, accepting that the turn ends with no
|
|
196
|
+
* completion event. Only meaningful mid-turn; ignored on an idle thread.
|
|
197
|
+
*/
|
|
198
|
+
force?: boolean;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* What `setModel` returns: the resolved model, plus the four capability
|
|
202
|
+
* reports as they stand on the new provider.
|
|
203
|
+
*
|
|
204
|
+
* A switch across providers can quietly lower a guarantee — a policy Claude
|
|
205
|
+
* enforced is best-effort on Codex — so the reports come back with the answer
|
|
206
|
+
* rather than leaving the caller to re-read four fields and notice. The same
|
|
207
|
+
* object is emitted as `capabilities_changed` on the thread's `status`
|
|
208
|
+
* channel, for subscribers that did not make the call.
|
|
209
|
+
*/
|
|
210
|
+
type SetModelResult = ThreadModelSelection & {
|
|
211
|
+
capabilities: ThreadCapabilities;
|
|
212
|
+
};
|
|
213
|
+
type SendOptions = {
|
|
214
|
+
/** Files to attach. `type` is inferred when absent; see `AgentChatFileRef`. */
|
|
215
|
+
attachments?: AgentChatFileRef[];
|
|
216
|
+
/** Text shown to the user when it differs from what the agent receives. */
|
|
217
|
+
displayText?: string;
|
|
218
|
+
reasoningEffort?: string | null;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
type ThreadInterruptOptions = {
|
|
222
|
+
/** Keep queued messages, or remove them along with the active turn. */
|
|
223
|
+
queue?: "keep" | "drop";
|
|
224
|
+
/** Full DAEX stop semantics. When set, this takes precedence over `queue`. */
|
|
225
|
+
mode?: AgentChatStopMode;
|
|
226
|
+
};
|
|
227
|
+
/** The response fields accepted by the runtime's `respondToInput` action. */
|
|
228
|
+
type ThreadRespondOptions = Pick<AgentChatRespondToInputArgs, "answers" | "decision" | "responseText">;
|
|
229
|
+
/** Options for `steer`. */
|
|
230
|
+
type SteerOptions = {
|
|
231
|
+
/**
|
|
232
|
+
* Files to hand the running turn. Same shape and inference as
|
|
233
|
+
* `SendOptions.attachments`. A steer with attachments may have empty text.
|
|
234
|
+
*/
|
|
235
|
+
attachments?: AgentChatFileRef[];
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* What `update` may change on a live thread.
|
|
239
|
+
*
|
|
240
|
+
* `title` is a rename and is safe at any time. `reasoningEffort` and
|
|
241
|
+
* `fastMode` reconfigure the provider, which on some providers restarts it —
|
|
242
|
+
* so they follow the same mid-turn rule `setModel` does.
|
|
243
|
+
*/
|
|
244
|
+
type ThreadUpdate = {
|
|
245
|
+
/**
|
|
246
|
+
* New title. Persisted in the thread store as well. A host title marks the
|
|
247
|
+
* chat as named: the runtime's automatic title never replaces it.
|
|
248
|
+
*
|
|
249
|
+
* `null` clears the host title. The chat then shows the provider's
|
|
250
|
+
* placeholder title ("Claude Chat", "Codex Chat"), so `thread.title` reads
|
|
251
|
+
* that string, not null, and the automatic title may name the chat again
|
|
252
|
+
* after its next message (runtime >= 1.2.82; before, `null` set the
|
|
253
|
+
* placeholder and still counted as named).
|
|
254
|
+
*/
|
|
255
|
+
title?: string | null;
|
|
256
|
+
/** Reasoning effort for later turns. `null` returns to the model default. */
|
|
257
|
+
reasoningEffort?: string | null;
|
|
258
|
+
/** Provider fast mode, where the provider has one. */
|
|
259
|
+
fastMode?: boolean;
|
|
260
|
+
};
|
|
261
|
+
/** Options for `update`. */
|
|
262
|
+
type ThreadUpdateOptions = {
|
|
263
|
+
/**
|
|
264
|
+
* Apply `reasoningEffort` / `fastMode` even with a turn in flight, accepting
|
|
265
|
+
* that some providers end that turn without a completion event. Ignored for
|
|
266
|
+
* a title-only update, which never needs it.
|
|
267
|
+
*/
|
|
268
|
+
force?: boolean;
|
|
269
|
+
};
|
|
270
|
+
/** What `update` returns: the thread's title and model after the change. */
|
|
271
|
+
type ThreadUpdateResult = {
|
|
272
|
+
title: string | null;
|
|
273
|
+
model: ThreadModelSelection | null;
|
|
274
|
+
};
|
|
275
|
+
/** Options for `editLast`. */
|
|
276
|
+
type EditLastOptions = {
|
|
277
|
+
/** Text shown to the user when it differs from what the agent receives. */
|
|
278
|
+
displayText?: string;
|
|
279
|
+
/**
|
|
280
|
+
* Files for the edited message, replacing the original's. Omit to keep the
|
|
281
|
+
* original message's attachments; pass `[]` to drop them.
|
|
282
|
+
*/
|
|
283
|
+
attachments?: AgentChatFileRef[];
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* What `retry` and `editLast` return, once the runtime has cut the old turn
|
|
287
|
+
* out and dispatched the new one. The new turn's events follow on the stream.
|
|
288
|
+
*
|
|
289
|
+
* The rollback is the CONVERSATION only. Files the old turn wrote stay on
|
|
290
|
+
* disk, and this result does not report them (see `retry`).
|
|
291
|
+
*/
|
|
292
|
+
type ThreadRerunResult = {
|
|
293
|
+
/**
|
|
294
|
+
* The first history `sequence` removed. Every event at or after it is gone
|
|
295
|
+
* from the runtime's history; drop the same events from any copy you keep —
|
|
296
|
+
* and inspect them there if you want to warn about files the old turn wrote.
|
|
297
|
+
*/
|
|
298
|
+
retractedFromSequence: number;
|
|
299
|
+
/**
|
|
300
|
+
* The thread's history generation after the cut. The runtime also emits a
|
|
301
|
+
* `session_meta_updated` event with `historyInvalidated: true` and this
|
|
302
|
+
* generation, before the new turn's first event.
|
|
303
|
+
*/
|
|
304
|
+
historyGeneration: number;
|
|
305
|
+
/**
|
|
306
|
+
* How the provider conversation went back: `claude_fork` (the Claude session
|
|
307
|
+
* was copied up to the entry before the turn), `claude_new_session` (the
|
|
308
|
+
* turn was the first, so a new Claude session starts), `codex_thread` (the
|
|
309
|
+
* Codex thread was reverted or forked before the turn), or `not_delivered`
|
|
310
|
+
* (the turn never reached the provider, so only the history changed).
|
|
311
|
+
*/
|
|
312
|
+
conversationRollback: "claude_fork" | "claude_new_session" | "codex_thread" | "not_delivered";
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* `@daex-dev/sdk/electron/renderer` — the renderer half of the Electron bridge.
|
|
317
|
+
*
|
|
318
|
+
* Turns `window.ade` (what the preload exposed) back into an object shaped like
|
|
319
|
+
* an SDK client, so it drops straight into `adaptSdkClient` with no host glue
|
|
320
|
+
* and no `as any`:
|
|
321
|
+
*
|
|
322
|
+
* import { createDaexIpcClient } from "@daex-dev/sdk/electron/renderer";
|
|
323
|
+
* import { adaptSdkClient, DaexChat } from "@daex-dev/chat-ui";
|
|
324
|
+
*
|
|
325
|
+
* const sdkLike = createDaexIpcClient(window.ade);
|
|
326
|
+
* const client = adaptSdkClient(sdkLike, { providerFilter: ["claude", "codex"] });
|
|
327
|
+
*
|
|
328
|
+
* BROWSER ONLY. Nothing here touches Node: no `node:` import, no `process`, no
|
|
329
|
+
* `Buffer`. It is bundled for the browser platform and runs inside a strict CSP
|
|
330
|
+
* with no `eval` and no remote fetch.
|
|
331
|
+
*
|
|
332
|
+
* TWO RULES THIS FILE OWNS SO EMBEDDERS DO NOT HAVE TO.
|
|
333
|
+
*
|
|
334
|
+
* 1. ONE MAIN-SIDE LISTENER PER THREAD. `on()` is refcounted here: the first
|
|
335
|
+
* listener for a key subscribes across IPC, the last one to leave
|
|
336
|
+
* unsubscribes. A React tree with twelve components watching one thread
|
|
337
|
+
* costs the main process one subscription, and closing them all leaves
|
|
338
|
+
* none behind.
|
|
339
|
+
* 2. HISTORY AND LIVE EVENTS DO NOT RACE. `history()` subscribes first, then
|
|
340
|
+
* asks, then merges — so an envelope emitted while the request was in
|
|
341
|
+
* flight is delivered exactly once, in envelope order, whether it arrived
|
|
342
|
+
* live or in the page.
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* A thread handle over IPC.
|
|
347
|
+
*
|
|
348
|
+
* Every member is typed with the SDK's own type, not a loosened copy, so this
|
|
349
|
+
* interface satisfies `SdkLikeThread` from `@daex-dev/chat-ui` structurally and
|
|
350
|
+
* `adaptSdkClient` takes it with no cast. The capability reports, `title` and
|
|
351
|
+
* `model` are snapshots taken at open and refreshed by this handle's own
|
|
352
|
+
* `setModel` and `update` calls; a change made by another renderer or by the
|
|
353
|
+
* main process is seen at the next `threads.open` of the key, which always
|
|
354
|
+
* asks main.
|
|
355
|
+
*/
|
|
356
|
+
interface DaexIpcThread {
|
|
357
|
+
readonly id: string;
|
|
358
|
+
readonly key: string;
|
|
359
|
+
/** See `DaexThread.title`. */
|
|
360
|
+
readonly title: string | null;
|
|
361
|
+
/** See `DaexThread.model`. */
|
|
362
|
+
readonly model: ThreadModelSelection | null;
|
|
363
|
+
readonly mcpCapability: McpCapabilityReport | null;
|
|
364
|
+
readonly instructionsCapability: InstructionsCapability | null;
|
|
365
|
+
readonly settingSourcesCapability: SettingSourcesCapability | null;
|
|
366
|
+
readonly permissionCapability: PermissionCapability | null;
|
|
367
|
+
send(text: string, opts?: SendOptions): Promise<void>;
|
|
368
|
+
/** See `DaexThread.steer`. Attachments cross as path refs, like `send`. */
|
|
369
|
+
steer(text: string, opts?: SteerOptions): Promise<void>;
|
|
370
|
+
interrupt(options?: ThreadInterruptOptions): Promise<void>;
|
|
371
|
+
respond(requestId: string, response: ThreadRespondOptions): Promise<void>;
|
|
372
|
+
queue: {
|
|
373
|
+
list(): Promise<ThreadQueueItem[]>;
|
|
374
|
+
cancel(id: string): Promise<void>;
|
|
375
|
+
edit(id: string, text: string): Promise<void>;
|
|
376
|
+
move(id: string, index: number): Promise<void>;
|
|
377
|
+
dispatch(id: string): Promise<void>;
|
|
378
|
+
cancelDispatched(id: string): Promise<void>;
|
|
379
|
+
restore(): Promise<void>;
|
|
380
|
+
};
|
|
381
|
+
stopTask(taskId: string): Promise<void>;
|
|
382
|
+
slashCommands(): Promise<AgentChatSlashCommand[]>;
|
|
383
|
+
recover(options?: {
|
|
384
|
+
turnId?: string;
|
|
385
|
+
action?: "wait" | "nudge" | "retry_same_runtime" | "restart_resume";
|
|
386
|
+
}): Promise<AgentChatRecoverTurnResult>;
|
|
387
|
+
resolveUnprocessed(args: {
|
|
388
|
+
steerId: string;
|
|
389
|
+
action: "run_next" | "dismiss";
|
|
390
|
+
}): Promise<AgentChatResolveUnprocessedMessageResult>;
|
|
391
|
+
usageLimit: {
|
|
392
|
+
resumeNow(): Promise<AgentChatUsageLimitResult>;
|
|
393
|
+
continueOnAlternate(): Promise<AgentChatUsageLimitResult>;
|
|
394
|
+
};
|
|
395
|
+
switchAccount(instanceId: string): Promise<AgentChatSwitchAccountResult>;
|
|
396
|
+
/**
|
|
397
|
+
* See `DaexThread.setModel`. Refused with `unauthorized` when the host's
|
|
398
|
+
* `allowModel` hook says no. Refreshes this handle's `model` and capability
|
|
399
|
+
* reports from the answer.
|
|
400
|
+
*/
|
|
401
|
+
setModel(modelId: string, opts?: SetModelOptions): Promise<SetModelResult>;
|
|
402
|
+
/** See `DaexThread.update`. Refreshes this handle's `title` and `model`. */
|
|
403
|
+
update(patch: ThreadUpdate, opts?: ThreadUpdateOptions): Promise<ThreadUpdateResult>;
|
|
404
|
+
/** See `DaexThread.retry`. */
|
|
405
|
+
retry(): Promise<ThreadRerunResult>;
|
|
406
|
+
/** See `DaexThread.editLast`. */
|
|
407
|
+
editLast(text: string, opts?: EditLastOptions): Promise<ThreadRerunResult>;
|
|
408
|
+
history(opts?: {
|
|
409
|
+
limit?: number;
|
|
410
|
+
}): Promise<AgentChatEventEnvelope[]>;
|
|
411
|
+
/**
|
|
412
|
+
* See `DaexThread.historyPage`. The newest page (no `beforeSequence`) is
|
|
413
|
+
* merged with live envelopes the same way `history()` is, so nothing that
|
|
414
|
+
* streams in while it loads is lost or doubled.
|
|
415
|
+
*/
|
|
416
|
+
historyPage(opts?: HistoryPageOptions): Promise<ThreadHistoryPage>;
|
|
417
|
+
approve(itemId: string, decision: ApprovalDecision, responseText?: string): Promise<void>;
|
|
418
|
+
pendingApprovals(): Promise<ApprovalRequest[]>;
|
|
419
|
+
on(channel: ThreadEventChannel, cb: (envelope: AgentChatEventEnvelope) => void): Unsubscribe;
|
|
420
|
+
}
|
|
421
|
+
/** A client over IPC. Satisfies `SdkLikeChatClient` from `@daex-dev/chat-ui`. */
|
|
422
|
+
interface DaexIpcClient {
|
|
423
|
+
providers: {
|
|
424
|
+
status(): Promise<Record<string, ProviderStatus>>;
|
|
425
|
+
refresh(): Promise<Record<string, ProviderStatus>>;
|
|
426
|
+
capabilities(provider: string): Promise<ProviderCapabilities>;
|
|
427
|
+
onChange(cb: (statuses: Record<string, ProviderStatus>) => void): Unsubscribe;
|
|
428
|
+
};
|
|
429
|
+
accounts: {
|
|
430
|
+
list(provider?: string): Promise<AccountInfo[]>;
|
|
431
|
+
add(provider: string, options?: {
|
|
432
|
+
label?: string;
|
|
433
|
+
}): Promise<AccountInfo>;
|
|
434
|
+
remove(id: string): Promise<unknown>;
|
|
435
|
+
rename(id: string, label: string): Promise<AccountInfo>;
|
|
436
|
+
setDefault(id: string): Promise<unknown>;
|
|
437
|
+
signOut(id: string): Promise<unknown>;
|
|
438
|
+
refresh(): Promise<AccountInfo[]>;
|
|
439
|
+
signIn(id: string, options?: {
|
|
440
|
+
deviceAuth?: boolean;
|
|
441
|
+
}): Promise<SignInHandle>;
|
|
442
|
+
};
|
|
443
|
+
credentials: {
|
|
444
|
+
list(provider?: string): Promise<ApiCredentialInfo[]>;
|
|
445
|
+
add(input: {
|
|
446
|
+
provider: string;
|
|
447
|
+
key: string;
|
|
448
|
+
label: string;
|
|
449
|
+
}): Promise<ApiCredentialInfo>;
|
|
450
|
+
remove(id: string, provider?: string): Promise<unknown>;
|
|
451
|
+
verify(provider: string): Promise<unknown>;
|
|
452
|
+
};
|
|
453
|
+
presets: {
|
|
454
|
+
list(): Promise<Record<string, unknown>[]>;
|
|
455
|
+
add(input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
456
|
+
update(id: string, patch: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
457
|
+
remove(id: string): Promise<unknown>;
|
|
458
|
+
};
|
|
459
|
+
models: {
|
|
460
|
+
list(): Promise<ModelCatalogEntry[]>;
|
|
461
|
+
};
|
|
462
|
+
threads: {
|
|
463
|
+
/**
|
|
464
|
+
* Open a key. What the SDK opens it WITH is the host's decision: with an
|
|
465
|
+
* `openOptions` hook the options passed here are ignored, and without one
|
|
466
|
+
* only `provider`, `model`, `title` and `reasoningEffort` cross.
|
|
467
|
+
*/
|
|
468
|
+
open(key: string, opts?: Record<string, unknown>): Promise<DaexIpcThread>;
|
|
469
|
+
/** Every thread the host lets this renderer name (`allowThreadKey`). */
|
|
470
|
+
list(): Promise<ThreadSummary[]>;
|
|
471
|
+
/** See `DaexChatClient.threads.get`. Gated by `allowThreadKey`. SDK >= 0.4. */
|
|
472
|
+
get(key: string): Promise<ThreadSummary | null>;
|
|
473
|
+
/** See `DaexChatClient.threads.delete`. Drops this renderer's handle for the key. */
|
|
474
|
+
delete(key: string): Promise<void>;
|
|
475
|
+
/** See `DaexChatClient.threads.archive`. */
|
|
476
|
+
archive(key: string): Promise<void>;
|
|
477
|
+
/** See `DaexChatClient.threads.unarchive`. */
|
|
478
|
+
unarchive(key: string): Promise<void>;
|
|
479
|
+
};
|
|
480
|
+
/** See `DaexChatClient.doctor`. Gated by `authorize` only. */
|
|
481
|
+
doctor(): Promise<DoctorReport>;
|
|
482
|
+
/** See `DaexChatClient.exportThread`. Gated by `allowThreadKey`. */
|
|
483
|
+
exportThread(key: string): Promise<string>;
|
|
484
|
+
/**
|
|
485
|
+
* Runtime lifecycle events from the main process: `"exit"`, `"transport"`,
|
|
486
|
+
* `"restart"`, `"threadLifecycle"`, with the payloads `DaexClientEventMap`
|
|
487
|
+
* documents. One IPC
|
|
488
|
+
* subscription serves every listener in this renderer.
|
|
489
|
+
*/
|
|
490
|
+
on<E extends DaexClientEvent>(event: E, cb: (payload: DaexClientEventMap[E]) => void): Unsubscribe;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Build an SDK-shaped client on top of the preload bridge.
|
|
494
|
+
*
|
|
495
|
+
* `bridge` is whatever `exposeDaexBridge` put on `window` — `window.ade` by
|
|
496
|
+
* default. Nothing else is required of the host. A missing bridge (undefined,
|
|
497
|
+
* because the preload did not run) throws `invalid_option`.
|
|
498
|
+
*/
|
|
499
|
+
declare function createDaexIpcClient(bridgeInput: DaexBridge | null | undefined): DaexIpcClient;
|
|
500
|
+
|
|
501
|
+
/** @deprecated Use {@link createDaexIpcClient}. */
|
|
502
|
+
declare const createAdeIpcClient: typeof createDaexIpcClient;
|
|
503
|
+
/** @deprecated Use {@link DaexIpcClient}. */
|
|
504
|
+
type AdeIpcClient = DaexIpcClient;
|
|
505
|
+
/** @deprecated Use {@link DaexIpcThread}. */
|
|
506
|
+
type AdeIpcThread = DaexIpcThread;
|
|
507
|
+
|
|
508
|
+
export { AdeError, type AdeErrorCode, type AdeIpcClient, type AdeIpcThread, DaexBridge, DaexError, type DaexErrorCode, type DaexIpcClient, type DaexIpcThread, createAdeIpcClient, createDaexIpcClient };
|