@anthropic-ai/claude-agent-sdk 0.3.143 → 0.3.145
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/README.md +21 -0
- package/assistant.mjs +81 -81
- package/bridge.mjs +63 -63
- package/browser-sdk.js +25 -25
- package/extractFromBunfs.d.ts +1 -0
- package/extractFromBunfs.js +156 -0
- package/manifest.json +19 -19
- package/manifest.zst.json +23 -23
- package/package.json +20 -10
- package/sdk-tools.d.ts +4 -0
- package/sdk.d.ts +78 -3
- package/sdk.mjs +46 -46
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function extractFromBunfs(embeddedPath: string): string
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/* eslint-disable custom-rules/no-sync-fs */
|
|
2
|
+
// Extracts a file from Bun's $bunfs virtual filesystem to a real temp directory
|
|
3
|
+
// so it can be spawned as a subprocess (child processes cannot access $bunfs).
|
|
4
|
+
//
|
|
5
|
+
// Ships verbatim (unbundled) as the @anthropic-ai/claude-agent-sdk `./extract`
|
|
6
|
+
// export — keep it standalone and Node-importable (no Bun globals, no
|
|
7
|
+
// local-relative imports).
|
|
8
|
+
|
|
9
|
+
import { createHash } from 'crypto'
|
|
10
|
+
import {
|
|
11
|
+
chmodSync,
|
|
12
|
+
existsSync,
|
|
13
|
+
lstatSync,
|
|
14
|
+
mkdirSync,
|
|
15
|
+
readFileSync,
|
|
16
|
+
renameSync,
|
|
17
|
+
unlinkSync,
|
|
18
|
+
writeFileSync,
|
|
19
|
+
} from 'fs'
|
|
20
|
+
import { tmpdir as osTmpdir } from 'os'
|
|
21
|
+
import { basename, join } from 'path'
|
|
22
|
+
|
|
23
|
+
// Inlined from src/utils/tempfile.ts — this file ships verbatim (unbundled) as
|
|
24
|
+
// the @anthropic-ai/claude-agent-sdk/extract export, so it must have zero
|
|
25
|
+
// local-relative imports. Keep behavior in sync with tempfile.ts#tmpdir.
|
|
26
|
+
function tmpdir() {
|
|
27
|
+
if (process.env.CLAUDE_CODE_TMPDIR) {
|
|
28
|
+
return process.env.CLAUDE_CODE_TMPDIR
|
|
29
|
+
}
|
|
30
|
+
if (process.platform === 'darwin') {
|
|
31
|
+
// eslint-disable-next-line custom-rules/no-hardcoded-tmp -- mirrors tempfile.ts: macOS /tmp works fine; os.tmpdir() below is for Android-on-Linux where /tmp isn't writable.
|
|
32
|
+
return '/tmp'
|
|
33
|
+
}
|
|
34
|
+
return osTmpdir()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Inlined from src/utils/tempfile.ts#claudeTempDir + verifyTempDirOwnership —
|
|
38
|
+
// keep behavior in sync. Per-UID Claude temp directory: `{tmpdir()}/claude-{uid}`
|
|
39
|
+
// on Unix, `{tmpdir()}/claude` on Windows (where %TEMP% is already per-user).
|
|
40
|
+
//
|
|
41
|
+
// Defense-in-depth against a local attacker pre-creating the extraction dir
|
|
42
|
+
// before the victim's first run: the content-hash dir name is fully predictable
|
|
43
|
+
// (sha256 of a public npm binary) under shared `/tmp`, and
|
|
44
|
+
// `mkdirSync({recursive:true})` is a silent no-op on a pre-existing dir without
|
|
45
|
+
// enforcing owner or mode. Without this check an attacker-owned directory would
|
|
46
|
+
// be used as-is, letting them swap the binary the SDK later spawns.
|
|
47
|
+
function safeTempBase() {
|
|
48
|
+
const dir = join(
|
|
49
|
+
tmpdir(),
|
|
50
|
+
process.platform === 'win32'
|
|
51
|
+
? 'claude'
|
|
52
|
+
: `claude-${process.getuid?.() ?? 0}`,
|
|
53
|
+
)
|
|
54
|
+
// Gate on getuid (POSIX-only) rather than process.platform: getuid presence
|
|
55
|
+
// reflects the real OS. No-op on Windows where %TEMP% is already per-user.
|
|
56
|
+
if (typeof process.getuid === 'function') {
|
|
57
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 })
|
|
58
|
+
const uid = process.getuid()
|
|
59
|
+
const st = lstatSync(dir)
|
|
60
|
+
if (!st.isDirectory()) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
`Temp directory ${dir} is not a directory (may be an attacker-planted symlink). Refusing to use it.`,
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
if (st.uid !== uid) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`Temp directory ${dir} is owned by uid ${st.uid}, expected ${uid}. Refusing to use it — another user may have pre-created it.`,
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
if ((st.mode & 0o777) !== 0o700) {
|
|
71
|
+
// Owner matches, so this is our own dir from a prior run with a looser
|
|
72
|
+
// umask rather than an attacker pre-create. Tighten it.
|
|
73
|
+
chmodSync(dir, 0o700)
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
// Windows: best-effort create; verification is skipped (%TEMP% is per-user).
|
|
77
|
+
try {
|
|
78
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 })
|
|
79
|
+
} catch {
|
|
80
|
+
// best-effort; see comment above
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return dir
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* If `embeddedPath` is inside Bun's $bunfs virtual filesystem, extract it to a
|
|
88
|
+
* temp directory and return the real path. Otherwise return the path unchanged.
|
|
89
|
+
*
|
|
90
|
+
* Uses a content hash for the directory name so that:
|
|
91
|
+
* - Same binary version reuses the same extracted file (no accumulation)
|
|
92
|
+
* - Different versions get separate directories (no collision)
|
|
93
|
+
* - Concurrent instances are safe (atomic write via temp file + rename)
|
|
94
|
+
*
|
|
95
|
+
* @param {string} embeddedPath — path returned by `import ... with { type: 'file' }`
|
|
96
|
+
* @returns {string} — a real filesystem path that can be spawned as a subprocess
|
|
97
|
+
*/
|
|
98
|
+
export function extractFromBunfs(embeddedPath) {
|
|
99
|
+
// Bun single-file embed: `/$bunfs/root/...` (POSIX) or `B:\~BUN\root\...`
|
|
100
|
+
// (Windows — Bun's StandaloneModuleGraph uses `~BUN`, not `$bunfs`, on Windows).
|
|
101
|
+
if (!embeddedPath.includes('$bunfs') && !embeddedPath.includes('~BUN')) {
|
|
102
|
+
return embeddedPath
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const content = readFileSync(embeddedPath)
|
|
107
|
+
const hash = createHash('sha256').update(content).digest('hex').slice(0, 16)
|
|
108
|
+
const tmpDir = join(safeTempBase(), `claude-agent-sdk-${hash}`)
|
|
109
|
+
// Preserve the embedded file's basename — ProcessTransport.isNativeBinary()
|
|
110
|
+
// decides whether to spawn directly or via node/bun based on extension, so
|
|
111
|
+
// a native binary must not come out named cli.js.
|
|
112
|
+
const fileName = basename(embeddedPath)
|
|
113
|
+
const tmpPath = join(tmpDir, fileName)
|
|
114
|
+
mkdirSync(tmpDir, { recursive: true, mode: 0o700 })
|
|
115
|
+
// The directory is content-hash-keyed, so an existing tmpPath is byte-
|
|
116
|
+
// identical to what we would write — short-circuit. This is a write
|
|
117
|
+
// idempotency check on a content-addressed path, not a read TOCTOU
|
|
118
|
+
// (the existence IS the contract). Without it, a second call (or a
|
|
119
|
+
// concurrent app instance) on Windows would hit EPERM/EBUSY renaming over
|
|
120
|
+
// the memory-mapped running .exe and fall back to the unspawnable $bunfs
|
|
121
|
+
// path. It also skips a redundant write+chmod on every call.
|
|
122
|
+
if (existsSync(tmpPath)) {
|
|
123
|
+
return tmpPath
|
|
124
|
+
}
|
|
125
|
+
// Write to a temp file and atomically rename to avoid truncation races —
|
|
126
|
+
// concurrent readers always see either the old complete file or the new one.
|
|
127
|
+
const tmpFile = join(tmpDir, `${fileName}.tmp.${process.pid}`)
|
|
128
|
+
writeFileSync(tmpFile, content)
|
|
129
|
+
chmodSync(tmpFile, 0o755)
|
|
130
|
+
try {
|
|
131
|
+
renameSync(tmpFile, tmpPath)
|
|
132
|
+
} catch (e) {
|
|
133
|
+
if ((e.code === 'EPERM' || e.code === 'EBUSY') && existsSync(tmpPath)) {
|
|
134
|
+
// Lost a concurrent first-time-extraction race on Windows: the winner's
|
|
135
|
+
// child holds tmpPath memory-mapped, so the loser's rename over it fails.
|
|
136
|
+
// The content-hash dir guarantees byte-identity, so the winner's file is
|
|
137
|
+
// exactly what we'd have written — use it.
|
|
138
|
+
try {
|
|
139
|
+
unlinkSync(tmpFile)
|
|
140
|
+
} catch {
|
|
141
|
+
// best-effort cleanup of our orphaned .tmp.{pid} file
|
|
142
|
+
}
|
|
143
|
+
return tmpPath
|
|
144
|
+
}
|
|
145
|
+
throw e
|
|
146
|
+
}
|
|
147
|
+
return tmpPath
|
|
148
|
+
} catch (err) {
|
|
149
|
+
// biome-ignore lint/suspicious/noConsole: intentional user-facing warning in standalone SDK helper
|
|
150
|
+
console.warn(
|
|
151
|
+
`[claude-agent-sdk] Failed to extract CLI from $bunfs: ${err.message}. ` +
|
|
152
|
+
`Child processes cannot access $bunfs paths — the CLI will likely fail to start.`,
|
|
153
|
+
)
|
|
154
|
+
return embeddedPath
|
|
155
|
+
}
|
|
156
|
+
}
|
package/manifest.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.1.
|
|
3
|
-
"commit": "
|
|
4
|
-
"buildDate": "2026-05-
|
|
2
|
+
"version": "2.1.145",
|
|
3
|
+
"commit": "daa4c3755d45ab0cf97bb41db8c03bd2dfd2ff5f",
|
|
4
|
+
"buildDate": "2026-05-19T01:56:17Z",
|
|
5
5
|
"platforms": {
|
|
6
6
|
"darwin-arm64": {
|
|
7
7
|
"binary": "claude",
|
|
8
|
-
"checksum": "
|
|
9
|
-
"size":
|
|
8
|
+
"checksum": "368dcd9709c85534f673071e7cc8eb5422bcff367fb9bdf5ce25d9619aab7ef5",
|
|
9
|
+
"size": 208546464
|
|
10
10
|
},
|
|
11
11
|
"darwin-x64": {
|
|
12
12
|
"binary": "claude",
|
|
13
|
-
"checksum": "
|
|
14
|
-
"size":
|
|
13
|
+
"checksum": "c23dc566214279d0708f4212261f023d8e63d5af5aef91638ebfdc090b3e33de",
|
|
14
|
+
"size": 211044112
|
|
15
15
|
},
|
|
16
16
|
"linux-arm64": {
|
|
17
17
|
"binary": "claude",
|
|
18
|
-
"checksum": "
|
|
19
|
-
"size":
|
|
18
|
+
"checksum": "75ad61d690d79440c82b5841444e1b42caae55736af37c97dd0e068ef20ce390",
|
|
19
|
+
"size": 233944712
|
|
20
20
|
},
|
|
21
21
|
"linux-x64": {
|
|
22
22
|
"binary": "claude",
|
|
23
|
-
"checksum": "
|
|
24
|
-
"size":
|
|
23
|
+
"checksum": "b3ffbc12689bfe81389d6577787fcea4cab81bd3b6bba9b719e73770b62d720e",
|
|
24
|
+
"size": 234022608
|
|
25
25
|
},
|
|
26
26
|
"linux-arm64-musl": {
|
|
27
27
|
"binary": "claude",
|
|
28
|
-
"checksum": "
|
|
29
|
-
"size":
|
|
28
|
+
"checksum": "3a73f058b2225a4210931362bc9c98e486e3362ca28b339281755737fb375c7c",
|
|
29
|
+
"size": 226799448
|
|
30
30
|
},
|
|
31
31
|
"linux-x64-musl": {
|
|
32
32
|
"binary": "claude",
|
|
33
|
-
"checksum": "
|
|
34
|
-
"size":
|
|
33
|
+
"checksum": "cfc95961a41329204405c4b0e257cb467821133eb7bdb1ca0866dfe789d5d442",
|
|
34
|
+
"size": 228416560
|
|
35
35
|
},
|
|
36
36
|
"win32-x64": {
|
|
37
37
|
"binary": "claude.exe",
|
|
38
|
-
"checksum": "
|
|
39
|
-
"size":
|
|
38
|
+
"checksum": "1da511cee5d3a4968634174498e9148635a5908d7f6ea5ec91b04d531c20c3bc",
|
|
39
|
+
"size": 229910176
|
|
40
40
|
},
|
|
41
41
|
"win32-arm64": {
|
|
42
42
|
"binary": "claude.exe",
|
|
43
|
-
"checksum": "
|
|
44
|
-
"size":
|
|
43
|
+
"checksum": "b6b920c757e08ff3e4f0dc211360ad7815db539d4915bb691e57ee4d34db31e5",
|
|
44
|
+
"size": 225875616
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
package/manifest.zst.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.1.
|
|
3
|
-
"commit": "
|
|
4
|
-
"buildDate": "2026-05-
|
|
2
|
+
"version": "2.1.145",
|
|
3
|
+
"commit": "daa4c3755d45ab0cf97bb41db8c03bd2dfd2ff5f",
|
|
4
|
+
"buildDate": "2026-05-19T02:03:37Z",
|
|
5
5
|
"platforms": {
|
|
6
6
|
"darwin-arm64": {
|
|
7
7
|
"binary": "claude.zst",
|
|
8
|
-
"checksum": "
|
|
9
|
-
"size":
|
|
8
|
+
"checksum": "7bedcf3a0a6e2f79b3b0008e7a056984a47a30747cc4ef988dd6d7095cff5c2c",
|
|
9
|
+
"size": 43195831,
|
|
10
10
|
"bundle": {
|
|
11
|
-
"checksum": "
|
|
12
|
-
"size":
|
|
11
|
+
"checksum": "815e4f3505e2b005a9510a9427846b5fe55cf0702aa838eb293315133ea3376f",
|
|
12
|
+
"size": 43200202
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"darwin-x64": {
|
|
16
16
|
"binary": "claude.zst",
|
|
17
|
-
"checksum": "
|
|
18
|
-
"size":
|
|
17
|
+
"checksum": "3ba937418f3f2e2155b45e330d2f5d75f09bceb6e3cefc3a6b314e6c806f05e6",
|
|
18
|
+
"size": 45109754,
|
|
19
19
|
"bundle": {
|
|
20
|
-
"checksum": "
|
|
21
|
-
"size":
|
|
20
|
+
"checksum": "c936efab1b00100fb114c2a82c79ac23b9948610adc26b99579ef65606a717ef",
|
|
21
|
+
"size": 45119954
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"linux-arm64": {
|
|
25
25
|
"binary": "claude.zst",
|
|
26
|
-
"checksum": "
|
|
27
|
-
"size":
|
|
26
|
+
"checksum": "7bffc295920723dd531ff9937f6dd6e953ac52051d643df69d5aa29cd7d87584",
|
|
27
|
+
"size": 50982967
|
|
28
28
|
},
|
|
29
29
|
"linux-x64": {
|
|
30
30
|
"binary": "claude.zst",
|
|
31
|
-
"checksum": "
|
|
32
|
-
"size":
|
|
31
|
+
"checksum": "5ba6f8e411bd4aa8a967818a5deece65e74ea2c99bb08adf20554070ebdff6db",
|
|
32
|
+
"size": 51607210
|
|
33
33
|
},
|
|
34
34
|
"linux-arm64-musl": {
|
|
35
35
|
"binary": "claude.zst",
|
|
36
|
-
"checksum": "
|
|
37
|
-
"size":
|
|
36
|
+
"checksum": "1e6e9ddba6e57144b3700a318f944308bfe0887db7c50445e2dc4c912a7b1c20",
|
|
37
|
+
"size": 49605775
|
|
38
38
|
},
|
|
39
39
|
"linux-x64-musl": {
|
|
40
40
|
"binary": "claude.zst",
|
|
41
|
-
"checksum": "
|
|
42
|
-
"size":
|
|
41
|
+
"checksum": "a14758fa127cc8d02df3f63146e8e6b819252ee3f8618095ab26e6b703b3042e",
|
|
42
|
+
"size": 50320268
|
|
43
43
|
},
|
|
44
44
|
"win32-x64": {
|
|
45
45
|
"binary": "claude.exe.zst",
|
|
46
|
-
"checksum": "
|
|
47
|
-
"size":
|
|
46
|
+
"checksum": "2e359b72a4e8a74e6c2059bd469fb9a7ecc73427f3666ad3b748fd86e01e58a4",
|
|
47
|
+
"size": 52313300
|
|
48
48
|
},
|
|
49
49
|
"win32-arm64": {
|
|
50
50
|
"binary": "claude.exe.zst",
|
|
51
|
-
"checksum": "
|
|
52
|
-
"size":
|
|
51
|
+
"checksum": "86c1464594dafb9126204a9d853610ba67d85cecdcdbee222e76ec6e8f01c070",
|
|
52
|
+
"size": 50612912
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anthropic-ai/claude-agent-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.145",
|
|
4
4
|
"main": "sdk.mjs",
|
|
5
5
|
"types": "sdk.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"types": "./sdk.d.ts",
|
|
9
9
|
"default": "./sdk.mjs"
|
|
10
10
|
},
|
|
11
|
+
"./extract": {
|
|
12
|
+
"types": "./extractFromBunfs.d.ts",
|
|
13
|
+
"default": "./extractFromBunfs.js"
|
|
14
|
+
},
|
|
11
15
|
"./browser": {
|
|
12
16
|
"types": "./browser-sdk.d.ts",
|
|
13
17
|
"default": "./browser-sdk.js"
|
|
@@ -35,6 +39,10 @@
|
|
|
35
39
|
"license": "SEE LICENSE IN README.md",
|
|
36
40
|
"description": "SDK for building AI agents with Claude Code's capabilities. Programmatically interact with Claude to build autonomous agents that can understand codebases, edit files, and execute workflows.",
|
|
37
41
|
"homepage": "https://github.com/anthropics/claude-agent-sdk-typescript",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/anthropics/claude-agent-sdk-typescript.git"
|
|
45
|
+
},
|
|
38
46
|
"bugs": {
|
|
39
47
|
"url": "https://github.com/anthropics/claude-agent-sdk-typescript/issues"
|
|
40
48
|
},
|
|
@@ -53,14 +61,14 @@
|
|
|
53
61
|
"zod": "^4.0.0"
|
|
54
62
|
},
|
|
55
63
|
"optionalDependencies": {
|
|
56
|
-
"@anthropic-ai/claude-agent-sdk-linux-x64": "0.3.
|
|
57
|
-
"@anthropic-ai/claude-agent-sdk-linux-arm64": "0.3.
|
|
58
|
-
"@anthropic-ai/claude-agent-sdk-linux-x64-musl": "0.3.
|
|
59
|
-
"@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "0.3.
|
|
60
|
-
"@anthropic-ai/claude-agent-sdk-darwin-x64": "0.3.
|
|
61
|
-
"@anthropic-ai/claude-agent-sdk-darwin-arm64": "0.3.
|
|
62
|
-
"@anthropic-ai/claude-agent-sdk-win32-x64": "0.3.
|
|
63
|
-
"@anthropic-ai/claude-agent-sdk-win32-arm64": "0.3.
|
|
64
|
+
"@anthropic-ai/claude-agent-sdk-linux-x64": "0.3.145",
|
|
65
|
+
"@anthropic-ai/claude-agent-sdk-linux-arm64": "0.3.145",
|
|
66
|
+
"@anthropic-ai/claude-agent-sdk-linux-x64-musl": "0.3.145",
|
|
67
|
+
"@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "0.3.145",
|
|
68
|
+
"@anthropic-ai/claude-agent-sdk-darwin-x64": "0.3.145",
|
|
69
|
+
"@anthropic-ai/claude-agent-sdk-darwin-arm64": "0.3.145",
|
|
70
|
+
"@anthropic-ai/claude-agent-sdk-win32-x64": "0.3.145",
|
|
71
|
+
"@anthropic-ai/claude-agent-sdk-win32-arm64": "0.3.145"
|
|
64
72
|
},
|
|
65
73
|
"files": [
|
|
66
74
|
"sdk.mjs",
|
|
@@ -73,8 +81,10 @@
|
|
|
73
81
|
"assistant.d.ts",
|
|
74
82
|
"browser-sdk.js",
|
|
75
83
|
"browser-sdk.d.ts",
|
|
84
|
+
"extractFromBunfs.js",
|
|
85
|
+
"extractFromBunfs.d.ts",
|
|
76
86
|
"manifest.json",
|
|
77
87
|
"manifest.zst.json"
|
|
78
88
|
],
|
|
79
|
-
"claudeCodeVersion": "2.1.
|
|
89
|
+
"claudeCodeVersion": "2.1.145"
|
|
80
90
|
}
|
package/sdk-tools.d.ts
CHANGED
|
@@ -143,6 +143,10 @@ export type FileReadOutput =
|
|
|
143
143
|
* Total number of lines in the file
|
|
144
144
|
*/
|
|
145
145
|
totalLines: number;
|
|
146
|
+
/**
|
|
147
|
+
* True when a whole-file read was auto-paginated because it exceeded the token cap (the content is a partial first page). A programmatic signal for internal consumers; survives output reconstruction (unlike the render-time banner).
|
|
148
|
+
*/
|
|
149
|
+
truncatedByTokenCap?: boolean;
|
|
146
150
|
};
|
|
147
151
|
}
|
|
148
152
|
| {
|
package/sdk.d.ts
CHANGED
|
@@ -120,6 +120,39 @@ export declare type AsyncHookJSONOutput = {
|
|
|
120
120
|
asyncTimeout?: number;
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
+
export declare type BackgroundTaskSummary = {
|
|
124
|
+
id: string;
|
|
125
|
+
/**
|
|
126
|
+
* Friendly task-type label (e.g. 'shell', 'subagent', 'monitor', 'workflow'). Falls back to the raw discriminant for unknown types.
|
|
127
|
+
*/
|
|
128
|
+
type: string;
|
|
129
|
+
status: string;
|
|
130
|
+
/**
|
|
131
|
+
* Free-text description. Capped at 1000 chars; clipped values append an in-string "… [+N chars]" marker.
|
|
132
|
+
*/
|
|
133
|
+
description: string;
|
|
134
|
+
/**
|
|
135
|
+
* Shell command line. Only present for 'shell' tasks. Capped at 1000 chars with the same "… [+N chars]" marker.
|
|
136
|
+
*/
|
|
137
|
+
command?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Subagent type name. Only present for 'subagent' tasks.
|
|
140
|
+
*/
|
|
141
|
+
agent_type?: string;
|
|
142
|
+
/**
|
|
143
|
+
* MCP server name. Only present for 'monitor' / 'MCP task' tasks.
|
|
144
|
+
*/
|
|
145
|
+
server?: string;
|
|
146
|
+
/**
|
|
147
|
+
* MCP tool name. Only present for 'monitor' / 'MCP task' tasks.
|
|
148
|
+
*/
|
|
149
|
+
tool?: string;
|
|
150
|
+
/**
|
|
151
|
+
* Workflow name. Only present for 'workflow' tasks.
|
|
152
|
+
*/
|
|
153
|
+
name?: string;
|
|
154
|
+
};
|
|
155
|
+
|
|
123
156
|
export declare type BaseHookInput = {
|
|
124
157
|
session_id: string;
|
|
125
158
|
transcript_path: string;
|
|
@@ -286,6 +319,7 @@ declare namespace coreTypes {
|
|
|
286
319
|
AgentMcpServerSpec,
|
|
287
320
|
ApiKeySource,
|
|
288
321
|
AsyncHookJSONOutput,
|
|
322
|
+
BackgroundTaskSummary,
|
|
289
323
|
BaseHookInput,
|
|
290
324
|
BaseOutputFormat,
|
|
291
325
|
ConfigChangeHookInput,
|
|
@@ -388,6 +422,7 @@ declare namespace coreTypes {
|
|
|
388
422
|
SDKUserMessage,
|
|
389
423
|
SdkBeta,
|
|
390
424
|
SdkPluginConfig,
|
|
425
|
+
SessionCronSummary,
|
|
391
426
|
SessionEndHookInput,
|
|
392
427
|
SessionStartHookInput,
|
|
393
428
|
SessionStartHookSpecificOutput,
|
|
@@ -430,6 +465,13 @@ export declare function createSdkMcpServer(_options: CreateSdkMcpServerOptions):
|
|
|
430
465
|
declare type CreateSdkMcpServerOptions = {
|
|
431
466
|
name: string;
|
|
432
467
|
version?: string;
|
|
468
|
+
/**
|
|
469
|
+
* Server instructions returned from `initialize` and surfaced to the model
|
|
470
|
+
* as an MCP instructions block. When proxying a real MCP server through the
|
|
471
|
+
* SDK transport, pass the underlying server's `getInstructions()` here so
|
|
472
|
+
* it isn't dropped.
|
|
473
|
+
*/
|
|
474
|
+
instructions?: string;
|
|
433
475
|
tools?: Array<SdkMcpToolDefinition<any>>;
|
|
434
476
|
/**
|
|
435
477
|
* When true, all tools from this server are always included in the prompt
|
|
@@ -1563,6 +1605,7 @@ export declare type Options = {
|
|
|
1563
1605
|
|
|
1564
1606
|
|
|
1565
1607
|
|
|
1608
|
+
|
|
1566
1609
|
/**
|
|
1567
1610
|
* Enable prompt suggestions. When true, the agent emits a `prompt_suggestion`
|
|
1568
1611
|
* message after each turn with a predicted next user prompt.
|
|
@@ -2505,7 +2548,7 @@ export declare type SDKAssistantMessage = {
|
|
|
2505
2548
|
task_description?: string;
|
|
2506
2549
|
};
|
|
2507
2550
|
|
|
2508
|
-
export declare type SDKAssistantMessageError = 'authentication_failed' | 'oauth_org_not_allowed' | 'billing_error' | 'rate_limit' | 'invalid_request' | 'server_error' | 'unknown' | 'max_output_tokens';
|
|
2551
|
+
export declare type SDKAssistantMessageError = 'authentication_failed' | 'oauth_org_not_allowed' | 'billing_error' | 'rate_limit' | 'invalid_request' | 'model_not_found' | 'server_error' | 'unknown' | 'max_output_tokens';
|
|
2509
2552
|
|
|
2510
2553
|
export declare type SDKAuthStatusMessage = {
|
|
2511
2554
|
type: 'auth_status';
|
|
@@ -2939,7 +2982,7 @@ export declare type SDKControlRequest = {
|
|
|
2939
2982
|
request: SDKControlRequestInner;
|
|
2940
2983
|
};
|
|
2941
2984
|
|
|
2942
|
-
declare type SDKControlRequestInner = SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlRenameSessionRequest | SDKControlSetColorRequest | SDKControlMcpStatusRequest | SDKControlGetContextUsageRequest | SDKControlGetSessionCostRequest | SDKControlGetBinaryVersionRequest | SDKControlMcpCallRequest | SDKControlFileSuggestionsRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest | SDKControlCancelAsyncMessageRequest | SDKControlReadFileRequest | SDKControlSeedReadStateRequest | SDKControlMcpSetServersRequest | SDKControlReloadPluginsRequest | SDKControlMcpReconnectRequest | SDKControlMcpToggleRequest | SDKControlChannelEnableRequest | SDKControlEndSessionRequest | SDKControlMcpAuthenticateRequest | SDKControlMcpClearAuthRequest | SDKControlMcpOAuthCallbackUrlRequest | SDKControlClaudeAuthenticateRequest | SDKControlClaudeOAuthCallbackRequest | SDKControlClaudeOAuthWaitForCompletionRequest | SDKControlRemoteControlRequest | SDKControlGenerateSessionTitleRequest | SDKControlSideQuestionRequest | SDKControlUltrareviewLaunchRequest | SDKControlMessageRatedRequest | SDKControlOAuthTokenRefreshRequest | SDKControlStopTaskRequest | SDKControlBackgroundTasksRequest | SDKControlApplyFlagSettingsRequest | SDKControlGetSettingsRequest | SDKControlElicitationRequest | SDKControlRequestUserDialogRequest | SDKControlSubmitFeedbackRequest;
|
|
2985
|
+
declare type SDKControlRequestInner = SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlRenameSessionRequest | SDKControlSetColorRequest | SDKControlMcpStatusRequest | SDKControlGetContextUsageRequest | SDKControlGetSessionCostRequest | SDKControlGetBinaryVersionRequest | SDKControlMcpCallRequest | SDKControlFileSuggestionsRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest | SDKControlCancelAsyncMessageRequest | SDKControlReadFileRequest | SDKControlSeedReadStateRequest | SDKControlMcpSetServersRequest | SDKControlReloadPluginsRequest | SDKControlMcpReconnectRequest | SDKControlMcpToggleRequest | SDKControlChannelEnableRequest | SDKControlEndSessionRequest | SDKControlMcpAuthenticateRequest | SDKControlMcpClearAuthRequest | SDKControlMcpOAuthCallbackUrlRequest | SDKControlClaudeAuthenticateRequest | SDKControlClaudeOAuthCallbackRequest | SDKControlClaudeOAuthWaitForCompletionRequest | SDKControlRemoteControlRequest | SDKControlGenerateSessionTitleRequest | SDKControlSideQuestionRequest | SDKControlUltrareviewLaunchRequest | SDKControlMessageRatedRequest | SDKControlOAuthTokenRefreshRequest | SDKControlHostAuthTokenRefreshRequest | SDKControlStopTaskRequest | SDKControlBackgroundTasksRequest | SDKControlApplyFlagSettingsRequest | SDKControlGetSettingsRequest | SDKControlElicitationRequest | SDKControlRequestUserDialogRequest | SDKControlSubmitFeedbackRequest;
|
|
2943
2986
|
|
|
2944
2987
|
/**
|
|
2945
2988
|
* Requests the SDK consumer to render a tool-driven blocking dialog and return the user choice. Used by tools that previously rendered Ink JSX via setToolJSX with an onDone callback.
|
|
@@ -3654,6 +3697,22 @@ export declare type SDKUserMessageReplay = {
|
|
|
3654
3697
|
file_attachments?: unknown[];
|
|
3655
3698
|
};
|
|
3656
3699
|
|
|
3700
|
+
export declare type SessionCronSummary = {
|
|
3701
|
+
id: string;
|
|
3702
|
+
/**
|
|
3703
|
+
* Cron expression, e.g. "0 9 * * 1-5".
|
|
3704
|
+
*/
|
|
3705
|
+
schedule: string;
|
|
3706
|
+
/**
|
|
3707
|
+
* False for one-shot wakeups whose cron field encodes a single fire time; true for tasks that re-fire on every match.
|
|
3708
|
+
*/
|
|
3709
|
+
recurring: boolean;
|
|
3710
|
+
/**
|
|
3711
|
+
* Prompt text submitted when the cron fires. Capped at 1000 chars; clipped values append an in-string "… [+N chars]" marker.
|
|
3712
|
+
*/
|
|
3713
|
+
prompt: string;
|
|
3714
|
+
};
|
|
3715
|
+
|
|
3657
3716
|
export declare type SessionEndHookInput = BaseHookInput & {
|
|
3658
3717
|
hook_event_name: 'SessionEnd';
|
|
3659
3718
|
reason: ExitReason;
|
|
@@ -3687,7 +3746,7 @@ export declare type SessionMessage = {
|
|
|
3687
3746
|
uuid: string;
|
|
3688
3747
|
session_id: string;
|
|
3689
3748
|
message: unknown;
|
|
3690
|
-
parent_tool_use_id: null;
|
|
3749
|
+
parent_tool_use_id: string | null;
|
|
3691
3750
|
};
|
|
3692
3751
|
|
|
3693
3752
|
/**
|
|
@@ -5468,6 +5527,14 @@ export declare type StopHookInput = BaseHookInput & {
|
|
|
5468
5527
|
* Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.
|
|
5469
5528
|
*/
|
|
5470
5529
|
last_assistant_message?: string;
|
|
5530
|
+
/**
|
|
5531
|
+
* In-flight background work (running/pending + backgrounded) registered in this session. Lets hooks distinguish "session is done" from "session is paused waiting for background work to wake it". Empty array when nothing is in flight.
|
|
5532
|
+
*/
|
|
5533
|
+
background_tasks?: BackgroundTaskSummary[];
|
|
5534
|
+
/**
|
|
5535
|
+
* Session-scoped cron tasks (CronCreate, ScheduleWakeup, /loop) that will wake this session later. Empty array when none are scheduled.
|
|
5536
|
+
*/
|
|
5537
|
+
session_crons?: SessionCronSummary[];
|
|
5471
5538
|
|
|
5472
5539
|
|
|
5473
5540
|
};
|
|
@@ -5493,6 +5560,14 @@ export declare type SubagentStopHookInput = BaseHookInput & {
|
|
|
5493
5560
|
* Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.
|
|
5494
5561
|
*/
|
|
5495
5562
|
last_assistant_message?: string;
|
|
5563
|
+
/**
|
|
5564
|
+
* In-flight background work (running/pending + backgrounded) registered in this session. Lets hooks distinguish "session is done" from "session is paused waiting for background work to wake it". Empty array when nothing is in flight.
|
|
5565
|
+
*/
|
|
5566
|
+
background_tasks?: BackgroundTaskSummary[];
|
|
5567
|
+
/**
|
|
5568
|
+
* Session-scoped cron tasks (CronCreate, ScheduleWakeup, /loop) that will wake this session later. Empty array when none are scheduled.
|
|
5569
|
+
*/
|
|
5570
|
+
session_crons?: SessionCronSummary[];
|
|
5496
5571
|
|
|
5497
5572
|
|
|
5498
5573
|
};
|