@anthropic-ai/claude-agent-sdk 0.2.112 → 0.2.113
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 +106 -106
- package/bridge.mjs +21 -21
- package/browser-sdk.js +26 -26
- package/manifest.json +18 -18
- package/manifest.zst.json +22 -22
- package/package.json +11 -23
- package/sdk.d.ts +298 -21
- package/sdk.mjs +59 -59
- package/cli.js +0 -18412
- package/embed.d.ts +0 -2
- package/embed.js +0 -26
- package/extractFromBunfs.d.ts +0 -1
- package/extractFromBunfs.js +0 -57
- package/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
- package/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
- package/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
- package/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
- package/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
- package/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
- package/vendor/ripgrep/COPYING +0 -3
- package/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/vendor/ripgrep/arm64-linux/rg +0 -0
- package/vendor/ripgrep/arm64-win32/rg.exe +0 -0
- package/vendor/ripgrep/x64-darwin/rg +0 -0
- package/vendor/ripgrep/x64-linux/rg +0 -0
- package/vendor/ripgrep/x64-win32/rg.exe +0 -0
package/embed.d.ts
DELETED
package/embed.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* eslint-disable custom-rules/no-top-level-side-effects */
|
|
2
|
-
// This file ships UNBUNDLED alongside sdk.mjs in the npm package.
|
|
3
|
-
// It is NOT pre-compiled — the user's bundler processes it directly.
|
|
4
|
-
//
|
|
5
|
-
// Usage for compiled Bun binaries (`bun build --compile`):
|
|
6
|
-
//
|
|
7
|
-
// import cliPath from '@anthropic-ai/claude-agent-sdk/embed'
|
|
8
|
-
// import { query } from '@anthropic-ai/claude-agent-sdk'
|
|
9
|
-
//
|
|
10
|
-
// for await (const msg of query({
|
|
11
|
-
// prompt: "hello",
|
|
12
|
-
// options: { pathToClaudeCodeExecutable: cliPath },
|
|
13
|
-
// })) {
|
|
14
|
-
// console.log(msg)
|
|
15
|
-
// }
|
|
16
|
-
//
|
|
17
|
-
// How it works:
|
|
18
|
-
// 1. The `import ... with { type: 'file' }` tells Bun's bundler to embed cli.js
|
|
19
|
-
// into the compiled binary's $bunfs virtual filesystem
|
|
20
|
-
// 2. At runtime, extractFromBunfs() copies it to a temp directory so it can be
|
|
21
|
-
// spawned as a subprocess (child processes cannot access the parent's $bunfs)
|
|
22
|
-
|
|
23
|
-
import embeddedCliPath from './cli.js' with { type: 'file' }
|
|
24
|
-
import { extractFromBunfs } from './extractFromBunfs.js'
|
|
25
|
-
|
|
26
|
-
export default extractFromBunfs(embeddedCliPath)
|
package/extractFromBunfs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function extractFromBunfs(embeddedPath: string): string
|
package/extractFromBunfs.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
// Separated from embed.js so the logic is testable without Bun-specific
|
|
6
|
-
// `import ... with { type: 'file' }` syntax.
|
|
7
|
-
|
|
8
|
-
import { createHash } from 'crypto'
|
|
9
|
-
import {
|
|
10
|
-
chmodSync,
|
|
11
|
-
mkdirSync,
|
|
12
|
-
readFileSync,
|
|
13
|
-
renameSync,
|
|
14
|
-
writeFileSync,
|
|
15
|
-
} from 'fs'
|
|
16
|
-
import { join } from 'path'
|
|
17
|
-
import { tmpdir } from './tempfile.js'
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* If `embeddedPath` is inside Bun's $bunfs virtual filesystem, extract it to a
|
|
21
|
-
* temp directory and return the real path. Otherwise return the path unchanged.
|
|
22
|
-
*
|
|
23
|
-
* Uses a content hash for the directory name so that:
|
|
24
|
-
* - Same binary version reuses the same extracted file (no accumulation)
|
|
25
|
-
* - Different versions get separate directories (no collision)
|
|
26
|
-
* - Concurrent instances are safe (atomic write via temp file + rename)
|
|
27
|
-
*
|
|
28
|
-
* @param {string} embeddedPath — path returned by `import ... with { type: 'file' }`
|
|
29
|
-
* @returns {string} — a real filesystem path that can be spawned as a subprocess
|
|
30
|
-
*/
|
|
31
|
-
export function extractFromBunfs(embeddedPath) {
|
|
32
|
-
if (!embeddedPath.includes('$bunfs')) {
|
|
33
|
-
return embeddedPath
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
const content = readFileSync(embeddedPath)
|
|
38
|
-
const hash = createHash('sha256').update(content).digest('hex').slice(0, 16)
|
|
39
|
-
const tmpDir = join(tmpdir(), `claude-agent-sdk-${hash}`)
|
|
40
|
-
const tmpPath = join(tmpDir, 'cli.js')
|
|
41
|
-
mkdirSync(tmpDir, { recursive: true })
|
|
42
|
-
// Write to a temp file and atomically rename to avoid truncation races —
|
|
43
|
-
// concurrent readers always see either the old complete file or the new one.
|
|
44
|
-
const tmpFile = join(tmpDir, `cli.js.tmp.${process.pid}`)
|
|
45
|
-
writeFileSync(tmpFile, content)
|
|
46
|
-
chmodSync(tmpFile, 0o755)
|
|
47
|
-
renameSync(tmpFile, tmpPath)
|
|
48
|
-
return tmpPath
|
|
49
|
-
} catch (err) {
|
|
50
|
-
// biome-ignore lint/suspicious/noConsole: intentional user-facing warning in standalone SDK helper
|
|
51
|
-
console.warn(
|
|
52
|
-
`[claude-agent-sdk] Failed to extract CLI from $bunfs: ${err.message}. ` +
|
|
53
|
-
`Child processes cannot access $bunfs paths — the CLI will likely fail to start.`,
|
|
54
|
-
)
|
|
55
|
-
return embeddedPath
|
|
56
|
-
}
|
|
57
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/vendor/ripgrep/COPYING
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|