@anthropic-ai/claude-agent-sdk 0.3.168 → 0.3.169
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/assistant.mjs +123 -120
- package/bridge.mjs +65 -65
- package/browser-sdk.d.ts +37 -4
- package/browser-sdk.js +36 -32
- package/manifest.json +19 -19
- package/manifest.zst.json +23 -23
- package/package.json +10 -10
- package/sdk-tools.d.ts +1 -1
- package/sdk.d.ts +257 -7
- package/sdk.mjs +57 -57
package/browser-sdk.d.ts
CHANGED
|
@@ -24,9 +24,25 @@ export type WebSocketOptions = {
|
|
|
24
24
|
headers?: Record<string, string>;
|
|
25
25
|
authMessage?: AuthMessage;
|
|
26
26
|
};
|
|
27
|
-
export type
|
|
27
|
+
export type SSEOptions = {
|
|
28
|
+
/** SSE read endpoint, e.g. `…/v1/code/sessions/{id}/events/stream`. */
|
|
29
|
+
streamUrl: string;
|
|
30
|
+
/** POST write endpoint, e.g. `…/v1/code/sessions/{id}/events`. */
|
|
31
|
+
sendUrl: string;
|
|
32
|
+
/**
|
|
33
|
+
* The CCR session ID — required to build the `AddClientEventFromClient`
|
|
34
|
+
* request body that `sendUrl` expects.
|
|
35
|
+
*/
|
|
36
|
+
sessionId: string;
|
|
37
|
+
/**
|
|
38
|
+
* Headers sent on both the SSE GET and every POST. Set `Authorization` and
|
|
39
|
+
* `anthropic-client-platform` here — the SDK cannot determine the host
|
|
40
|
+
* surface (web / iOS / Android / desktop) itself.
|
|
41
|
+
*/
|
|
42
|
+
headers?: Record<string, string>;
|
|
43
|
+
};
|
|
44
|
+
type BrowserQueryOptionsBase = {
|
|
28
45
|
prompt: AsyncIterable<SDKUserMessage>;
|
|
29
|
-
websocket: WebSocketOptions;
|
|
30
46
|
abortController?: AbortController;
|
|
31
47
|
canUseTool?: CanUseTool;
|
|
32
48
|
hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
|
|
@@ -36,7 +52,20 @@ export type BrowserQueryOptions = {
|
|
|
36
52
|
onUserDialog?: OnUserDialog;
|
|
37
53
|
};
|
|
38
54
|
/**
|
|
39
|
-
*
|
|
55
|
+
* Exactly one of `websocket` | `sse` must be provided. `sse` is the v1alpha2
|
|
56
|
+
* path and is preferred for new integrations; `websocket` remains for
|
|
57
|
+
* existing callers during the migration.
|
|
58
|
+
*/
|
|
59
|
+
export type BrowserQueryOptions = BrowserQueryOptionsBase & ({
|
|
60
|
+
websocket: WebSocketOptions;
|
|
61
|
+
sse?: never;
|
|
62
|
+
} | {
|
|
63
|
+
sse: SSEOptions;
|
|
64
|
+
websocket?: never;
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Create a Claude Code query in the browser over either SSE (preferred) or
|
|
68
|
+
* WebSocket.
|
|
40
69
|
*
|
|
41
70
|
* @example
|
|
42
71
|
* ```typescript
|
|
@@ -44,7 +73,11 @@ export type BrowserQueryOptions = {
|
|
|
44
73
|
*
|
|
45
74
|
* const messages = query({
|
|
46
75
|
* prompt: messageStream,
|
|
47
|
-
*
|
|
76
|
+
* sse: {
|
|
77
|
+
* streamUrl: 'https://api.example.com/v1/code/sessions/ID/events/stream',
|
|
78
|
+
* sendUrl: 'https://api.example.com/v1/code/sessions/ID/events',
|
|
79
|
+
* headers: { Authorization: `Bearer ${token}` },
|
|
80
|
+
* },
|
|
48
81
|
* })
|
|
49
82
|
* for await (const message of messages) {
|
|
50
83
|
* console.log(message)
|