claude-code-acp-ts 0.24.3 → 0.38.0-beta.2

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/dist/index.js CHANGED
@@ -1,15 +1,44 @@
1
1
  #!/usr/bin/env node
2
- // Load managed settings and apply environment variables
3
- import { loadManagedSettings, applyEnvironmentSettings } from "./utils.js";
2
+ import { resolveSettings } from "@anthropic-ai/claude-agent-sdk";
4
3
  import { claudeCliPath, runAcp } from "./acp-agent.js";
5
4
  if (process.argv.includes("--cli")) {
6
- process.argv = process.argv.filter((arg) => arg !== "--cli");
7
- await import(await claudeCliPath());
5
+ const { spawn } = await import("node:child_process");
6
+ const args = process.argv.slice(2).filter((arg) => arg !== "--cli");
7
+ const child = spawn(await claudeCliPath(), args, { stdio: "inherit" });
8
+ const signals = process.platform === "win32"
9
+ ? ["SIGINT", "SIGTERM"]
10
+ : ["SIGINT", "SIGTERM", "SIGHUP"];
11
+ for (const sig of signals) {
12
+ process.on(sig, () => {
13
+ if (!child.killed)
14
+ child.kill(sig);
15
+ });
16
+ }
17
+ child.on("exit", (code, signal) => {
18
+ if (signal && process.platform !== "win32") {
19
+ // Remove our listener so re-raising actually terminates instead of
20
+ // re-entering the no-op handler, which would let us exit with code 0
21
+ // instead of the signal's conventional 128+N.
22
+ process.removeAllListeners(signal);
23
+ process.kill(process.pid, signal);
24
+ }
25
+ else {
26
+ process.exit(code ?? 1);
27
+ }
28
+ });
29
+ child.on("error", (err) => {
30
+ console.error(err);
31
+ process.exit(1);
32
+ });
8
33
  }
9
34
  else {
10
- const managedSettings = loadManagedSettings();
11
- if (managedSettings) {
12
- applyEnvironmentSettings(managedSettings);
35
+ // Apply env vars from the managed-policy tier before any SDK call so the
36
+ // SDK subprocess inherits them. Going through resolveSettings (vs. a raw
37
+ // read of managed-settings.json) also picks up MDM sources on macOS and
38
+ // HKLM/HKCU on Windows.
39
+ const policy = await resolveSettings({ settingSources: [] });
40
+ for (const [key, value] of Object.entries(policy.effective.env ?? {})) {
41
+ process.env[key] = value;
13
42
  }
14
43
  // stdout is used to send messages to the client
15
44
  // we redirect everything else to stderr to make sure it doesn't interfere with ACP
@@ -20,7 +49,19 @@ else {
20
49
  process.on("unhandledRejection", (reason, promise) => {
21
50
  console.error("Unhandled Rejection at:", promise, "reason:", reason);
22
51
  });
23
- runAcp();
24
- // Keep process alive
52
+ const { connection, agent } = runAcp();
53
+ async function shutdown() {
54
+ await agent.dispose().catch((err) => {
55
+ console.error("Error during cleanup:", err);
56
+ });
57
+ process.exit(0);
58
+ }
59
+ // Exit cleanly when the ACP connection closes (e.g. stdin EOF, transport
60
+ // error). Without this, `process.stdin.resume()` keeps the event loop
61
+ // alive indefinitely, causing orphan process accumulation in oneshot mode.
62
+ connection.closed.then(shutdown);
63
+ process.on("SIGTERM", shutdown);
64
+ process.on("SIGINT", shutdown);
65
+ // Keep process alive while connection is open
25
66
  process.stdin.resume();
26
67
  }
package/dist/lib.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { ClaudeAcpAgent, runAcp, toAcpNotifications, streamEventToAcpNotifications, type ToolUpdateMeta, type NewSessionMeta, } from "./acp-agent.js";
2
- export { loadManagedSettings, applyEnvironmentSettings, nodeToWebReadable, nodeToWebWritable, Pushable, unreachable, } from "./utils.js";
1
+ export { ClaudeAcpAgent, isLocalCommandMetadata, stripLocalCommandMetadata, runAcp, toAcpNotifications, streamEventToAcpNotifications, type ToolUpdateMeta, type NewSessionMeta, type SDKMessageFilter, } from "./acp-agent.js";
2
+ export { nodeToWebReadable, nodeToWebWritable, Pushable, unreachable } from "./utils.js";
3
3
  export { toolInfoFromToolUse, toDisplayPath, planEntries, toolUpdateFromToolResult, } from "./tools.js";
4
- export { SettingsManager, type ClaudeCodeSettings, type SettingsManagerOptions, } from "./settings.js";
4
+ export { SettingsManager, type SettingsManagerOptions } from "./settings.js";
5
5
  export type { ClaudePlanEntry } from "./tools.js";
6
6
  //# sourceMappingURL=lib.d.ts.map
package/dist/lib.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,MAAM,EACN,kBAAkB,EAClB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAG7E,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
package/dist/lib.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Export the main agent class and utilities for library usage
2
- export { ClaudeAcpAgent, runAcp, toAcpNotifications, streamEventToAcpNotifications, } from "./acp-agent.js";
3
- export { loadManagedSettings, applyEnvironmentSettings, nodeToWebReadable, nodeToWebWritable, Pushable, unreachable, } from "./utils.js";
2
+ export { ClaudeAcpAgent, isLocalCommandMetadata, stripLocalCommandMetadata, runAcp, toAcpNotifications, streamEventToAcpNotifications, } from "./acp-agent.js";
3
+ export { nodeToWebReadable, nodeToWebWritable, Pushable, unreachable } from "./utils.js";
4
4
  export { toolInfoFromToolUse, toDisplayPath, planEntries, toolUpdateFromToolResult, } from "./tools.js";
5
- export { SettingsManager, } from "./settings.js";
5
+ export { SettingsManager } from "./settings.js";
@@ -1,26 +1,4 @@
1
- /**
2
- * Permission rule format examples:
3
- * - "Read" - matches all Read tool calls
4
- * - "Read(./.env)" - matches specific path
5
- * - "Read(./.env.*)" - glob pattern
6
- * - "Read(./secrets/**)" - recursive glob
7
- * - "Bash(npm run lint)" - exact command prefix
8
- * - "Bash(npm run:*)" - command prefix with wildcard
9
- *
10
- * Docs: https://code.claude.com/docs/en/iam#tool-specific-permission-rules
11
- */
12
- export interface PermissionSettings {
13
- defaultMode?: string;
14
- }
15
- export interface ClaudeCodeSettings {
16
- permissions?: PermissionSettings;
17
- env?: Record<string, string>;
18
- model?: string;
19
- }
20
- /**
21
- * Gets the enterprise settings path based on the current platform
22
- */
23
- export declare function getManagedSettingsPath(): string;
1
+ import { type Settings } from "@anthropic-ai/claude-agent-sdk";
24
2
  export interface SettingsManagerOptions {
25
3
  onChange?: () => void;
26
4
  logger?: {
@@ -29,23 +7,17 @@ export interface SettingsManagerOptions {
29
7
  };
30
8
  }
31
9
  /**
32
- * Manages Claude Code settings from multiple sources with proper precedence.
10
+ * Manages Claude Code settings using the SDK's `resolveSettings` merge engine
11
+ * so the values we see match what `query()` would observe.
33
12
  *
34
- * Settings are loaded from (in order of increasing precedence):
35
- * 1. User settings (~/.claude/settings.json)
36
- * 2. Project settings (<cwd>/.claude/settings.json)
37
- * 3. Local project settings (<cwd>/.claude/settings.local.json)
38
- * 4. Enterprise managed settings (platform-specific path)
39
- *
40
- * The manager watches all settings files for changes and automatically reloads.
13
+ * Watches the user/project/local/managed settings files for changes and
14
+ * re-resolves through the SDK on update. Escalating `permissions.defaultMode`
15
+ * values from repo-committed sources are filtered out via
16
+ * `filterEscalatingDefaultMode`, matching the CLI's trust policy.
41
17
  */
42
18
  export declare class SettingsManager {
43
19
  private cwd;
44
- private userSettings;
45
- private projectSettings;
46
- private localSettings;
47
- private enterpriseSettings;
48
- private mergedSettings;
20
+ private effective;
49
21
  private watchers;
50
22
  private onChange?;
51
23
  private logger;
@@ -59,27 +31,15 @@ export declare class SettingsManager {
59
31
  */
60
32
  initialize(): Promise<void>;
61
33
  /**
62
- * Returns the path to the user settings file
63
- */
64
- private getUserSettingsPath;
65
- /**
66
- * Returns the path to the project settings file
34
+ * Paths the SDK reads when resolving settings for this cwd. Watching the
35
+ * containing directories means we pick up file creation as well as edits.
67
36
  */
68
- private getProjectSettingsPath;
37
+ private getWatchedPaths;
69
38
  /**
70
- * Returns the path to the local project settings file
71
- */
72
- private getLocalSettingsPath;
73
- /**
74
- * Loads settings from all sources
39
+ * Resolves the effective settings via the SDK and applies the CLI's trust
40
+ * filter for escalating `permissions.defaultMode` values.
75
41
  */
76
42
  private loadAllSettings;
77
- /**
78
- * Merges all settings sources with proper precedence.
79
- * For permissions, rules from all sources are combined.
80
- * Deny rules always take precedence during permission checks.
81
- */
82
- private mergeSettings;
83
43
  /**
84
44
  * Sets up file watchers for all settings files
85
45
  */
@@ -91,7 +51,7 @@ export declare class SettingsManager {
91
51
  /**
92
52
  * Returns the current merged settings
93
53
  */
94
- getSettings(): ClaudeCodeSettings;
54
+ getSettings(): Settings;
95
55
  /**
96
56
  * Returns the current working directory
97
57
  */
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB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OAEG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;OAEG;IACH,WAAW,IAAI,QAAQ;IAIvB;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxC;;OAEG;IACH,OAAO,IAAI,IAAI;CAehB"}
package/dist/settings.js CHANGED
@@ -1,36 +1,24 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
+ // resolveSettings and filterEscalatingDefaultMode are marked @alpha in the
4
+ // SDK; API may shift in a future release.
5
+ import { filterEscalatingDefaultMode, resolveSettings, } from "@anthropic-ai/claude-agent-sdk";
3
6
  import { CLAUDE_CONFIG_DIR } from "./acp-agent.js";
4
7
  /**
5
- * Reads and parses a JSON settings file, returning an empty object if not found or invalid.
6
- * Silently ignores missing files (ENOENT) but logs warnings for other errors
7
- * (malformed JSON, permission errors, etc.) to aid debugging.
8
- */
9
- async function loadSettingsFile(filePath, logger) {
10
- if (!filePath) {
11
- return {};
12
- }
13
- try {
14
- const content = await fs.promises.readFile(filePath, "utf-8");
15
- return JSON.parse(content);
16
- }
17
- catch (error) {
18
- if (error instanceof Error && "code" in error && error.code === "ENOENT") {
19
- return {};
20
- }
21
- logger?.error(`Failed to load settings from ${filePath}:`, error);
22
- return {};
23
- }
24
- }
25
- /**
26
- * Gets the enterprise settings path based on the current platform
8
+ * Permission rule format examples:
9
+ * - "Read" - matches all Read tool calls
10
+ * - "Read(./.env)" - matches specific path
11
+ * - "Read(./.env.*)" - glob pattern
12
+ * - "Read(./secrets/**)" - recursive glob
13
+ * - "Bash(npm run lint)" - exact command prefix
14
+ * - "Bash(npm run:*)" - command prefix with wildcard
15
+ *
16
+ * Docs: https://code.claude.com/docs/en/iam#tool-specific-permission-rules
27
17
  */
28
- export function getManagedSettingsPath() {
18
+ function getManagedSettingsPath() {
29
19
  switch (process.platform) {
30
20
  case "darwin":
31
21
  return "/Library/Application Support/ClaudeCode/managed-settings.json";
32
- case "linux":
33
- return "/etc/claude-code/managed-settings.json";
34
22
  case "win32":
35
23
  return "C:\\Program Files\\ClaudeCode\\managed-settings.json";
36
24
  default:
@@ -38,23 +26,17 @@ export function getManagedSettingsPath() {
38
26
  }
39
27
  }
40
28
  /**
41
- * Manages Claude Code settings from multiple sources with proper precedence.
29
+ * Manages Claude Code settings using the SDK's `resolveSettings` merge engine
30
+ * so the values we see match what `query()` would observe.
42
31
  *
43
- * Settings are loaded from (in order of increasing precedence):
44
- * 1. User settings (~/.claude/settings.json)
45
- * 2. Project settings (<cwd>/.claude/settings.json)
46
- * 3. Local project settings (<cwd>/.claude/settings.local.json)
47
- * 4. Enterprise managed settings (platform-specific path)
48
- *
49
- * The manager watches all settings files for changes and automatically reloads.
32
+ * Watches the user/project/local/managed settings files for changes and
33
+ * re-resolves through the SDK on update. Escalating `permissions.defaultMode`
34
+ * values from repo-committed sources are filtered out via
35
+ * `filterEscalatingDefaultMode`, matching the CLI's trust policy.
50
36
  */
51
37
  export class SettingsManager {
52
38
  constructor(cwd, options) {
53
- this.userSettings = {};
54
- this.projectSettings = {};
55
- this.localSettings = {};
56
- this.enterpriseSettings = {};
57
- this.mergedSettings = {};
39
+ this.effective = {};
58
40
  this.watchers = [];
59
41
  this.initialized = false;
60
42
  this.disposed = false;
@@ -85,81 +67,36 @@ export class SettingsManager {
85
67
  return this.initPromise;
86
68
  }
87
69
  /**
88
- * Returns the path to the user settings file
89
- */
90
- getUserSettingsPath() {
91
- return path.join(CLAUDE_CONFIG_DIR, "settings.json");
92
- }
93
- /**
94
- * Returns the path to the project settings file
95
- */
96
- getProjectSettingsPath() {
97
- return path.join(this.cwd, ".claude", "settings.json");
98
- }
99
- /**
100
- * Returns the path to the local project settings file
70
+ * Paths the SDK reads when resolving settings for this cwd. Watching the
71
+ * containing directories means we pick up file creation as well as edits.
101
72
  */
102
- getLocalSettingsPath() {
103
- return path.join(this.cwd, ".claude", "settings.local.json");
73
+ getWatchedPaths() {
74
+ return [
75
+ path.join(CLAUDE_CONFIG_DIR, "settings.json"),
76
+ path.join(this.cwd, ".claude", "settings.json"),
77
+ path.join(this.cwd, ".claude", "settings.local.json"),
78
+ getManagedSettingsPath(),
79
+ ];
104
80
  }
105
81
  /**
106
- * Loads settings from all sources
82
+ * Resolves the effective settings via the SDK and applies the CLI's trust
83
+ * filter for escalating `permissions.defaultMode` values.
107
84
  */
108
85
  async loadAllSettings() {
109
- const [userSettings, projectSettings, localSettings, enterpriseSettings] = await Promise.all([
110
- loadSettingsFile(this.getUserSettingsPath(), this.logger),
111
- loadSettingsFile(this.getProjectSettingsPath(), this.logger),
112
- loadSettingsFile(this.getLocalSettingsPath(), this.logger),
113
- loadSettingsFile(getManagedSettingsPath(), this.logger),
114
- ]);
115
- this.userSettings = userSettings;
116
- this.projectSettings = projectSettings;
117
- this.localSettings = localSettings;
118
- this.enterpriseSettings = enterpriseSettings;
119
- this.mergeSettings();
120
- }
121
- /**
122
- * Merges all settings sources with proper precedence.
123
- * For permissions, rules from all sources are combined.
124
- * Deny rules always take precedence during permission checks.
125
- */
126
- mergeSettings() {
127
- const allSettings = [
128
- this.userSettings,
129
- this.projectSettings,
130
- this.localSettings,
131
- this.enterpriseSettings,
132
- ];
133
- const merged = {};
134
- for (const settings of allSettings) {
135
- if (settings.env) {
136
- merged.env = { ...merged.env, ...settings.env };
137
- }
138
- if (settings.model) {
139
- merged.model = settings.model;
140
- }
141
- if (settings.permissions?.defaultMode !== undefined) {
142
- merged.permissions = {
143
- ...merged.permissions,
144
- defaultMode: settings.permissions.defaultMode,
145
- };
146
- }
86
+ try {
87
+ const resolved = await resolveSettings({ cwd: this.cwd });
88
+ this.effective = filterEscalatingDefaultMode(resolved);
89
+ }
90
+ catch (error) {
91
+ this.logger.error("Failed to resolve settings:", error);
92
+ this.effective = {};
147
93
  }
148
- this.mergedSettings = merged;
149
94
  }
150
95
  /**
151
96
  * Sets up file watchers for all settings files
152
97
  */
153
98
  setupWatchers() {
154
- const paths = [
155
- this.getUserSettingsPath(),
156
- this.getProjectSettingsPath(),
157
- this.getLocalSettingsPath(),
158
- getManagedSettingsPath(),
159
- ];
160
- for (const filePath of paths) {
161
- if (!filePath)
162
- continue;
99
+ for (const filePath of this.getWatchedPaths()) {
163
100
  try {
164
101
  const dir = path.dirname(filePath);
165
102
  const filename = path.basename(filePath);
@@ -207,7 +144,7 @@ export class SettingsManager {
207
144
  * Returns the current merged settings
208
145
  */
209
146
  getSettings() {
210
- return this.mergedSettings;
147
+ return this.effective;
211
148
  }
212
149
  /**
213
150
  * Returns the current working directory
package/dist/tools.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { PlanEntry, ToolCallContent, ToolCallLocation, ToolKind } from "@agentclientprotocol/sdk";
2
2
  import { HookCallback } from "@anthropic-ai/claude-agent-sdk";
3
+ import { TaskCreateInput, TaskCreateOutput, TaskUpdateInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
3
4
  import { ToolResultBlockParam, WebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources";
4
5
  import { BetaBashCodeExecutionToolResultBlockParam, BetaCodeExecutionToolResultBlockParam, BetaRequestMCPToolResultBlockParam, BetaTextEditorCodeExecutionToolResultBlockParam, BetaToolResultBlockParam, BetaToolSearchToolResultBlockParam, BetaWebFetchToolResultBlockParam, BetaWebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources/beta.mjs";
5
6
  import { Logger } from "./acp-agent.js";
@@ -42,15 +43,39 @@ export type ClaudePlanEntry = {
42
43
  };
43
44
  export declare function planEntries(input: {
44
45
  todos: ClaudePlanEntry[];
45
- }): PlanEntry[];
46
+ } | undefined): PlanEntry[];
47
+ /**
48
+ * Per-session task list accumulated from Task* tool calls (TaskCreate /
49
+ * TaskUpdate). The headless/SDK session emits these as incremental tool
50
+ * calls keyed by task ID, replacing the snapshot-style TodoWrite tool.
51
+ * Iteration order is insertion order (Map semantics), matching the order
52
+ * tasks are created.
53
+ */
54
+ export type TaskEntry = {
55
+ subject: string;
56
+ status: "pending" | "in_progress" | "completed";
57
+ activeForm?: string;
58
+ description?: string;
59
+ };
60
+ export type TaskState = Map<string, TaskEntry>;
61
+ /**
62
+ * Best-effort parse of a TaskCreate tool_result content into the structured
63
+ * TaskCreateOutput. The SDK delivers tool outputs either as a string or as
64
+ * an array of TextBlockParam-like blocks containing JSON text; try both.
65
+ */
66
+ export declare function parseTaskCreateOutput(content: unknown): TaskCreateOutput | undefined;
67
+ export declare function applyTaskCreate(state: TaskState, input: TaskCreateInput | undefined, output: TaskCreateOutput | undefined): void;
68
+ export declare function applyTaskUpdate(state: TaskState, input: TaskUpdateInput | undefined): void;
69
+ export declare function taskStateToPlanEntries(state: TaskState): PlanEntry[];
46
70
  export declare function markdownEscape(text: string): string;
47
71
  /**
48
- * Builds diff ToolUpdate content from the structured Edit toolResponse provided
49
- * by the PostToolUse hook. Unlike parsing the plain unified diff string, this uses
50
- * the pre-parsed structuredPatch which supports multiple replacement sites (replaceAll)
51
- * and always includes context lines for better readability.
72
+ * Builds diff ToolUpdate content from the structured toolResponse provided by
73
+ * the PostToolUse hook for diff-producing tools (Edit, Write). Unlike parsing
74
+ * the plain unified diff string, this uses the pre-parsed structuredPatch
75
+ * which supports multiple replacement sites (replaceAll) and always includes
76
+ * context lines for better readability.
52
77
  */
53
- export declare function toolUpdateFromEditToolResponse(toolResponse: unknown): {
78
+ export declare function toolUpdateFromDiffToolResponse(toolResponse: unknown): {
54
79
  content?: ToolCallContent[];
55
80
  locations?: ToolCallLocation[];
56
81
  };
@@ -60,5 +85,19 @@ export declare const registerHookCallback: (toolUseID: string, { onPostToolUseHo
60
85
  export declare const createPostToolUseHook: (logger?: Logger, options?: {
61
86
  onEnterPlanMode?: () => Promise<void>;
62
87
  }) => HookCallback;
88
+ /**
89
+ * Hook callback for `TaskCreated` / `TaskCompleted` events. The SDK fires
90
+ * these for both user-facing TaskCreate tool calls and subagent task
91
+ * creation, giving us `task_id` + `task_subject` without having to parse
92
+ * tool_result payloads.
93
+ *
94
+ * Populating `taskState` from the hook means a later `TaskUpdate` (which
95
+ * typically only carries `taskId` + `status`) finds an existing entry with
96
+ * a real subject, instead of synthesizing a placeholder with empty content.
97
+ */
98
+ export declare const createTaskHook: (options: {
99
+ taskState: TaskState;
100
+ onChange?: () => Promise<void>;
101
+ }) => HookCallback;
63
102
  export {};
64
103
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAa9D,OAAO,EAGL,oBAAoB,EAEpB,6BAA6B,EAE9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,yCAAyC,EAGzC,qCAAqC,EAGrC,kCAAkC,EAGlC,+CAA+C,EAI/C,wBAAwB,EACxB,kCAAkC,EAIlC,gCAAgC,EAEhC,iCAAiC,EAClC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AA0BxC,UAAU,QAAQ;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE;QACN,aAAa,CAAC,EAAE;YACd,WAAW,EAAE,MAAM,CAAC;SACrB,CAAC;QACF,eAAe,CAAC,EAAE;YAChB,WAAW,EAAE,MAAM,CAAC;YACpB,IAAI,EAA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