@anthropic-ai/claude-agent-sdk 0.1.62 → 0.1.65
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/cli.js +1505 -1619
- package/entrypoints/agentSdkTypes.d.ts +1041 -0
- package/entrypoints/sdkControlTypes.d.ts +96 -0
- package/package.json +1 -1
- package/resvg.wasm +0 -0
- package/sdk-tools.d.ts +14 -25
- package/sdk.d.ts +1 -984
- package/sdk.mjs +1453 -1349
- package/transport/processTransportTypes.d.ts +60 -0
- package/transport/transport.d.ts +30 -0
- /package/{sandboxTypes.d.ts → entrypoints/sandboxTypes.d.ts} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Readable, Writable } from 'stream';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a spawned process with stdin/stdout streams and lifecycle management.
|
|
4
|
+
* Implementers provide this interface to abstract the process spawning mechanism.
|
|
5
|
+
* ChildProcess already satisfies this interface.
|
|
6
|
+
*/
|
|
7
|
+
export interface SpawnedProcess {
|
|
8
|
+
/** Writable stream for sending data to the process stdin */
|
|
9
|
+
stdin: Writable;
|
|
10
|
+
/** Readable stream for receiving data from the process stdout */
|
|
11
|
+
stdout: Readable;
|
|
12
|
+
/** Whether the process has been killed */
|
|
13
|
+
readonly killed: boolean;
|
|
14
|
+
/** Exit code if the process has exited, null otherwise */
|
|
15
|
+
readonly exitCode: number | null;
|
|
16
|
+
/**
|
|
17
|
+
* Kill the process with the given signal
|
|
18
|
+
* @param signal - The signal to send (e.g., 'SIGTERM', 'SIGKILL')
|
|
19
|
+
*/
|
|
20
|
+
kill(signal: NodeJS.Signals): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Register a callback for when the process exits
|
|
23
|
+
* @param event - Must be 'exit'
|
|
24
|
+
* @param listener - Callback receiving exit code and signal
|
|
25
|
+
*/
|
|
26
|
+
on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): void;
|
|
27
|
+
/**
|
|
28
|
+
* Register a callback for process errors
|
|
29
|
+
* @param event - Must be 'error'
|
|
30
|
+
* @param listener - Callback receiving the error
|
|
31
|
+
*/
|
|
32
|
+
on(event: 'error', listener: (error: Error) => void): void;
|
|
33
|
+
/**
|
|
34
|
+
* Register a one-time callback for when the process exits
|
|
35
|
+
*/
|
|
36
|
+
once(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): void;
|
|
37
|
+
once(event: 'error', listener: (error: Error) => void): void;
|
|
38
|
+
/**
|
|
39
|
+
* Remove an event listener
|
|
40
|
+
*/
|
|
41
|
+
off(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): void;
|
|
42
|
+
off(event: 'error', listener: (error: Error) => void): void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Options passed to the spawn function.
|
|
46
|
+
*/
|
|
47
|
+
export interface SpawnOptions {
|
|
48
|
+
/** Command to execute */
|
|
49
|
+
command: string;
|
|
50
|
+
/** Arguments to pass to the command */
|
|
51
|
+
args: string[];
|
|
52
|
+
/** Working directory */
|
|
53
|
+
cwd?: string;
|
|
54
|
+
/** Environment variables */
|
|
55
|
+
env: {
|
|
56
|
+
[envVar: string]: string | undefined;
|
|
57
|
+
};
|
|
58
|
+
/** Abort signal for cancellation */
|
|
59
|
+
signal: AbortSignal;
|
|
60
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { StdoutMessage } from '../entrypoints/sdkControlTypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Transport interface for Claude Code SDK communication
|
|
4
|
+
* Abstracts the communication layer to support both process and WebSocket transports
|
|
5
|
+
*/
|
|
6
|
+
export interface Transport {
|
|
7
|
+
/**
|
|
8
|
+
* Write data to the transport
|
|
9
|
+
* May be async for network-based transports
|
|
10
|
+
*/
|
|
11
|
+
write(data: string): void | Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Close the transport connection and clean up resources
|
|
14
|
+
* This also closes stdin if still open (eliminating need for endInput)
|
|
15
|
+
*/
|
|
16
|
+
close(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Check if transport is ready for communication
|
|
19
|
+
*/
|
|
20
|
+
isReady(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Read and parse messages from the transport
|
|
23
|
+
* Each transport handles its own protocol and error checking
|
|
24
|
+
*/
|
|
25
|
+
readMessages(): AsyncGenerator<StdoutMessage, void, unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* End the input stream
|
|
28
|
+
*/
|
|
29
|
+
endInput(): void;
|
|
30
|
+
}
|
|
File without changes
|