hankweave 0.6.2 → 0.7.1

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.
@@ -9,6 +9,17 @@ import type { Logger } from "./utils.js";
9
9
  export declare class ClaudeExecutableNotFoundError extends Error {
10
10
  constructor(message: string);
11
11
  }
12
+ /**
13
+ * Whether lenient ("legacy") Claude auth is enabled via HW_INTERNAL_CLAUDE_LEGACY_AUTH.
14
+ *
15
+ * When enabled, the pre-flight self-test does NOT hard-require ANTHROPIC_API_KEY and instead
16
+ * trusts the Agent SDK to resolve credentials itself — including the SDK's fallback to a local
17
+ * Claude Code login (macOS Keychain `Claude Code-credentials` / `~/.claude/.credentials.json`).
18
+ *
19
+ * Intended for local/dev use on a machine already logged in via `claude login`. CI and
20
+ * production should still set ANTHROPIC_API_KEY (the supported, ToS-compliant path).
21
+ */
22
+ export declare function isLegacyClaudeAuthEnabled(): boolean;
12
23
  /**
13
24
  * Detect an installed Claude executable.
14
25
  * Checks common installation locations and falls back to `which claude`.
@@ -1,73 +1,63 @@
1
1
  /**
2
2
  * Claude Runtime Extractor
3
3
  *
4
- * This module handles the extraction of bundled Claude Agent SDK files
5
- * at runtime for standalone executables. When compiled with Bun, the CLI
6
- * files are embedded in the executable and need to be extracted to disk
7
- * before they can be spawned as subprocesses.
4
+ * Handles locating/extracting the Claude Agent SDK's native CLI binary.
8
5
  *
9
- * The extraction is done to a versioned directory to avoid re-extraction
10
- * on every run and to handle SDK updates cleanly.
6
+ * As of @anthropic-ai/claude-agent-sdk 0.3.x, the agent runtime ships as a native,
7
+ * per-platform compiled binary delivered through optionalDependencies
8
+ * (`@anthropic-ai/claude-agent-sdk-<platform>-<arch>/claude[.exe]`) — there is no longer a
9
+ * bundled `cli.js` + wasm + ripgrep vendor tree.
11
10
  *
12
- * Build Process:
13
- * The build script (scripts/build-executable.ts) embeds the SDK files using:
14
- * bun build --compile --embed node_modules/@anthropic-ai/claude-agent-sdk/cli.js ...
11
+ * Execution contexts:
12
+ * 1. Source / npm / npx mode: the SDK resolves the native binary itself via the optional
13
+ * dependency, so no extraction is needed (ensureSdkAvailable returns null).
14
+ * 2. Compiled executable (`bun build --compile`): the native binary is embedded at build
15
+ * time (scripts/build-executable.ts) and extracted to disk here on first run, because the
16
+ * SDK's own `require.resolve` cannot reach into Bun's `$bunfs` virtual filesystem.
15
17
  *
16
- * At runtime, these embedded files are accessible via Bun.file() using their
17
- * original paths.
18
+ * Extraction targets a versioned directory to avoid re-extraction and to handle SDK updates.
18
19
  */
19
- export declare const CLAUDE_SDK_VERSION = "0.1.70";
20
+ export declare const CLAUDE_SDK_VERSION = "0.3.156";
20
21
  /**
21
- * Get the extraction directory path.
22
- * Uses ~/.hankweave/claude-sdk/<version>/ by default.
22
+ * Resolve the platform/arch suffix used by the SDK's native binary packages,
23
+ * e.g. "darwin-arm64", "linux-x64", "win32-x64".
24
+ *
25
+ * @param target - Optional build target ("linux-x64", "darwin-arm64", "windows-x64", …).
26
+ * When omitted, uses the current platform.
23
27
  */
24
- export declare function getExtractionDir(): string;
28
+ export declare function getClaudePlatformSuffix(target?: string): string;
25
29
  /**
26
- * Get the path to the extracted cli.js file.
30
+ * The native CLI binary filename for the given target (or current platform).
27
31
  */
28
- export declare function getExtractedCliPath(): string;
32
+ export declare function getClaudeBinaryName(target?: string): string;
29
33
  /**
30
- * Check if embedded files are available (async check).
31
- * This actually tries to access an embedded file to verify.
34
+ * The node_modules directory of the platform-specific binary package, e.g.
35
+ * `node_modules/@anthropic-ai/claude-agent-sdk-darwin-arm64`.
36
+ *
37
+ * On Linux the package may be the glibc (`-x64`) or musl (`-x64-musl`) variant; callers that
38
+ * need the on-disk path (the build script) should fall back to the `-musl` suffix when the
39
+ * primary directory is absent.
32
40
  */
33
- export declare function hasEmbeddedFiles(): Promise<boolean>;
41
+ export declare function getClaudePackageDir(target?: string): string;
34
42
  /**
35
- * Check if extraction is needed.
36
- * Returns true if the files don't exist or are outdated.
43
+ * Get the extraction directory (e.g. ~/.hankweave/claude-sdk/<version>/).
37
44
  */
38
- export declare function needsExtraction(): boolean;
45
+ export declare function getClaudeExtractionDir(): string;
39
46
  /**
40
- * Extract embedded Claude SDK files to disk.
41
- *
42
- * This function reads files that were embedded during compilation using Bun's
43
- * --embed flag, then extracts them to a versioned directory on first run.
44
- *
45
- * The embedded files are accessed using their original paths that were
46
- * specified during build (e.g., "node_modules/@anthropic-ai/claude-agent-sdk/cli.js").
47
- *
48
- * Files extracted:
49
- * - cli.js - The main Claude Code CLI
50
- * - resvg.wasm - SVG rendering WASM module
51
- * - tree-sitter.wasm - Syntax parsing WASM module
52
- * - tree-sitter-bash.wasm - Bash syntax WASM module
53
- * - vendor/ripgrep/<platform>/ - Platform-specific ripgrep binaries
47
+ * Path to the extracted native CLI binary. Named `getExtractedCliPath` for backward
48
+ * compatibility with ClaudeAgentSDKManager.ensureSdkAvailable().
54
49
  */
55
- export declare function extractClaudeSdkFiles(): Promise<string>;
50
+ export declare function getExtractedCliPath(): string;
56
51
  /**
57
- * Ensure Claude SDK files are available, extracting if necessary.
58
- *
59
- * @deprecated Use ClaudeAgentSDKManager.ensureSdkAvailable() instead.
60
- * This function is kept for backward compatibility.
61
- *
62
- * @returns SDK info object with path, version, and cached status
63
- * @throws Error if extraction fails or extracted file doesn't exist
52
+ * Whether the embedded binary still needs to be extracted (missing or outdated cache).
64
53
  */
65
- export declare function ensureClaudeSdkAvailable(): Promise<{
66
- path: string | null;
67
- version: string;
68
- cached: boolean;
69
- }>;
54
+ export declare function needsExtraction(): boolean;
70
55
  /**
71
- * Validate the extracted cli.js works by running a simple command.
56
+ * Extract the embedded native CLI binary to disk.
57
+ *
58
+ * Reads the binary embedded at build time via Bun's --embed flag and writes it to the
59
+ * versioned extraction directory, marking it executable.
60
+ *
61
+ * @returns Path to the extracted binary.
72
62
  */
73
- export declare function validateExtractedCli(cliPath: string): Promise<boolean>;
63
+ export declare function extractClaudeSdkFiles(): Promise<string>;
@@ -12,7 +12,7 @@
12
12
  * The extraction is done to a versioned directory to avoid re-extraction
13
13
  * on every run and to handle SDK updates cleanly.
14
14
  */
15
- export declare const CODEX_SDK_VERSION = "0.104.0";
15
+ export declare const CODEX_SDK_VERSION = "0.135.0";
16
16
  /**
17
17
  * Platform identifier matching @openai/codex-sdk vendor directory structure
18
18
  */
package/dist/config.d.ts CHANGED
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import type { ModelInfo } from "./llm/models-dev-schema.js";
3
3
  import { type TelemetryConfig } from "./telemetry/telemetry-types.js";
4
4
  import type { AllocationMode, OnExceededPolicy } from "./types/budget-types.js";
5
- import type { ModelName, ShimSelfTestResult } from "./types/types.js";
5
+ import type { ModelName, SelfTestFailureCategory, ShimSelfTestResult } from "./types/types.js";
6
6
  import { type Logger } from "./utils.js";
7
7
  export declare const TIMEOUTS: {
8
8
  readonly RESULT_MESSAGE_MS: 30000;
@@ -40774,6 +40774,8 @@ export interface ValidationResult {
40774
40774
  provider: string;
40775
40775
  passed: boolean;
40776
40776
  result: ShimSelfTestResult;
40777
+ /** Failure classification, present when `passed` is false. Routes guidance. */
40778
+ category?: SelfTestFailureCategory;
40777
40779
  }>;
40778
40780
  /** Hank-level budget config for display in the budget resolution table */
40779
40781
  hankBudget?: {
@@ -40793,6 +40795,33 @@ export declare function validateRequiredEnv(requiredEnv: string[] | undefined):
40793
40795
  valid: boolean;
40794
40796
  missing: string[];
40795
40797
  };
40798
+ /**
40799
+ * Classify an in-band (harness ran and returned a result) self-test failure so
40800
+ * the final error can route the user to the right fix instead of always blaming
40801
+ * API keys. Launch failures are classified separately at the throw site.
40802
+ */
40803
+ export declare function classifyInBandSelfTest(result: ShimSelfTestResult): SelfTestFailureCategory;
40804
+ /**
40805
+ * Build the guidance line(s) appended to the self-test failure error, tailored
40806
+ * to the set of failure categories actually present. A launch/runtime crash must
40807
+ * never be reported as an API-key problem.
40808
+ */
40809
+ export declare function buildSelfTestGuidance(categories: Set<SelfTestFailureCategory>): string;
40810
+ /**
40811
+ * Render a failed self-test as a per-model bullet for the aggregate error.
40812
+ *
40813
+ * The header is the model identity + the shim's `overall.message`. For in-band
40814
+ * failures that message is generic ("One or more checks failed"), so we append
40815
+ * each FAILED check's specific message (e.g. the `agent_found` check that names
40816
+ * where the binary was searched). Launch failures carry no checks — their
40817
+ * `overall.message` already holds the actionable detail — so only the header shows.
40818
+ */
40819
+ export declare function formatFailedSelfTest(test: {
40820
+ modelName: string;
40821
+ provider: string;
40822
+ modelId: string;
40823
+ result: ShimSelfTestResult;
40824
+ }): string;
40796
40825
  /**
40797
40826
  * Validate hank configuration with enhanced checks.
40798
40827
  *