@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/embed.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const cliPath: string
2
- export default cliPath
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)
@@ -1 +0,0 @@
1
- export function extractFromBunfs(embeddedPath: string): string
@@ -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
- }
@@ -1,3 +0,0 @@
1
- This project is dual-licensed under the Unlicense and MIT licenses.
2
-
3
- You may use this code under the terms of either license.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file