@go-hare/claude-agent-sdk 0.3.177
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.md +1 -0
- package/README.md +64 -0
- package/agentSdkTypes.d.ts +1 -0
- package/assistant.d.ts +135 -0
- package/assistant.mjs +193 -0
- package/bridge.d.ts +237 -0
- package/bridge.mjs +166 -0
- package/browser-sdk.d.ts +87 -0
- package/browser-sdk.js +97 -0
- package/extractFromBunfs.d.ts +1 -0
- package/extractFromBunfs.js +156 -0
- package/manifest.json +47 -0
- package/package.json +89 -0
- package/sdk-tools.d.ts +3324 -0
- package/sdk.d.ts +6508 -0
- package/sdk.mjs +119 -0
package/browser-sdk.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API surface definition for @anthropic-ai/claude-agent-sdk/browser.
|
|
3
|
+
*
|
|
4
|
+
* This file is the source of truth for the browser export's public types.
|
|
5
|
+
* It imports ONLY from agentSdkTypes.ts so the compiled .d.ts has exactly
|
|
6
|
+
* one import to rewrite (./agentSdkTypes → ./sdk) for the flat package layout.
|
|
7
|
+
*
|
|
8
|
+
* Compiled by scripts/build-ant-sdk-typings.sh; see build-agent-sdk.sh for the
|
|
9
|
+
* path rewrite and copy into the package.
|
|
10
|
+
*/
|
|
11
|
+
import type { CanUseTool, HookCallbackMatcher, HookEvent, McpServerConfig, OnElicitation, OnUserDialog, Query, SDKUserMessage } from './agentSdkTypes.js';
|
|
12
|
+
export type { CanUseTool, ElicitationRequest, ElicitationResult, HookCallbackMatcher, HookEvent, McpSdkServerConfigWithInstance, McpServerConfig, OnElicitation, OnUserDialog, Query, SDKAssistantMessage, SDKMessage, SDKResultMessage, SDKSystemMessage, SDKUserMessage, UserDialogRequest, UserDialogResult, } from './agentSdkTypes.js';
|
|
13
|
+
export { createSdkMcpServer, tool } from './agentSdkTypes.js';
|
|
14
|
+
export type OAuthCredential = {
|
|
15
|
+
type: 'oauth';
|
|
16
|
+
token: string;
|
|
17
|
+
};
|
|
18
|
+
export type AuthMessage = {
|
|
19
|
+
type: 'auth';
|
|
20
|
+
credential: OAuthCredential;
|
|
21
|
+
};
|
|
22
|
+
export type WebSocketOptions = {
|
|
23
|
+
url: string;
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
authMessage?: AuthMessage;
|
|
26
|
+
};
|
|
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 = {
|
|
45
|
+
prompt: AsyncIterable<SDKUserMessage>;
|
|
46
|
+
abortController?: AbortController;
|
|
47
|
+
canUseTool?: CanUseTool;
|
|
48
|
+
hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
|
|
49
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
50
|
+
jsonSchema?: Record<string, unknown>;
|
|
51
|
+
onElicitation?: OnElicitation;
|
|
52
|
+
onUserDialog?: OnUserDialog;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
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.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { query } from '@anthropic-ai/claude-agent-sdk/browser'
|
|
73
|
+
*
|
|
74
|
+
* const messages = query({
|
|
75
|
+
* prompt: messageStream,
|
|
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
|
+
* },
|
|
81
|
+
* })
|
|
82
|
+
* for await (const message of messages) {
|
|
83
|
+
* console.log(message)
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function query(options: BrowserQueryOptions): Query;
|