@swifty.js/swifty 0.0.29 → 0.0.31

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.
Files changed (48) hide show
  1. package/README.md +25 -11
  2. package/dist/agent-O6C4FCQY.js +4 -0
  3. package/dist/anthropic-CFM2DXMB.js +4 -0
  4. package/dist/checker-A6PGACKZ.js +4 -0
  5. package/dist/chunk-4ABFUBO4.js +601 -0
  6. package/dist/{chunk-K5ZK27BX.js → chunk-AGJYBJ5M.js} +1 -1
  7. package/dist/chunk-AQ3A5CF4.js +5 -0
  8. package/dist/chunk-MVVSONAE.js +4 -0
  9. package/dist/chunk-OQCEP2F5.js +4 -0
  10. package/dist/{chunk-QFSCPD63.js → chunk-TCQ4EB4G.js} +1 -1
  11. package/dist/chunk-Y2UUXOQA.js +4 -0
  12. package/dist/chunk-YAXZ2OUD.js +150 -0
  13. package/dist/lib/agent-YRTROHXU.js +10 -0
  14. package/dist/lib/{anthropic-KWO3KLNV.js → anthropic-R6DMXE7U.js} +4 -5
  15. package/dist/lib/{checker-AXHPKVBY.js → checker-M7RKMKJQ.js} +2 -3
  16. package/dist/lib/{chunk-KZSBR4FO.js → chunk-4MDCRPVV.js} +76 -40
  17. package/dist/lib/{chunk-DJ6AILPN.js → chunk-A4MXZA5Q.js} +209 -51
  18. package/dist/lib/{chunk-2IVEVG5N.js → chunk-EWE5IWZE.js} +28 -25
  19. package/dist/lib/{chunk-KG4MJGKQ.js → chunk-FZ4Y6MBN.js} +1 -4
  20. package/dist/lib/{chunk-GCY44T7S.js → chunk-J6AV7SIF.js} +221 -351
  21. package/dist/lib/{chunk-3FBS5NB7.js → chunk-OEPCNATU.js} +217 -41
  22. package/dist/lib/{chunk-Z4CYHTII.js → chunk-OQIQOU5S.js} +85 -26
  23. package/dist/lib/{chunk-PIL7M52F.js → chunk-XT67KGWE.js} +16 -3
  24. package/dist/lib/index.d.ts +1212 -932
  25. package/dist/lib/index.js +2836 -1611
  26. package/dist/lib/{openai-PBF7EWNJ.js → openai-5N42ZYIJ.js} +2 -2
  27. package/dist/lib/{tool-filter-R6HDDJHE.js → tool-filter-XG2GXFVN.js} +3 -2
  28. package/dist/main.js +197 -189
  29. package/dist/openai-NQYARTT6.js +34 -0
  30. package/dist/{server-G23HCFLI.js → server-BNT2IIKB.js} +18 -18
  31. package/dist/tool-filter-5NDJMSTD.js +4 -0
  32. package/package.json +4 -3
  33. package/dist/agent-YR6YK26C.js +0 -4
  34. package/dist/anthropic-5GRR5JCT.js +0 -4
  35. package/dist/checker-N5TIJEN5.js +0 -4
  36. package/dist/chunk-D34FUVGU.js +0 -4
  37. package/dist/chunk-E55KH72M.js +0 -4
  38. package/dist/chunk-LIMEBKCY.js +0 -408
  39. package/dist/chunk-POHIQUFP.js +0 -301
  40. package/dist/chunk-QCKJLO6X.js +0 -4
  41. package/dist/chunk-TMEX7RFA.js +0 -4
  42. package/dist/chunk-Y6SQB5FG.js +0 -4
  43. package/dist/glob.wasm +0 -0
  44. package/dist/lib/agent-5WEKVRTD.js +0 -11
  45. package/dist/lib/chunk-GHF2PSEW.js +0 -8
  46. package/dist/lib/glob.wasm +0 -0
  47. package/dist/openai-QQ2K7GPF.js +0 -34
  48. package/dist/tool-filter-VBP6WOGO.js +0 -4
@@ -1,7 +1,7 @@
1
+ import z, { z as z$1 } from 'zod';
1
2
  import Anthropic from '@anthropic-ai/sdk';
2
- import z$1, { z } from 'zod';
3
+ import { BetaToolComputerUse20251124 } from '@anthropic-ai/sdk/resources/beta/messages/messages';
3
4
  import OpenAI from 'openai';
4
- import { FunctionTool } from 'openai/resources/responses/responses';
5
5
  import { Logger } from 'pino';
6
6
  import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
7
7
  import { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
@@ -27,107 +27,41 @@ import { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
27
27
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
28
  * SOFTWARE.
29
29
  */
30
- interface FileReadRecord {
31
- path: string;
32
- content: string;
33
- timestamp: number;
34
- }
35
- interface SkillInvocationRecord {
36
- name: string;
37
- body: string;
38
- timestamp: number;
39
- }
40
- declare class RecoveryState {
41
- private files;
42
- private skills;
43
- recordFileRead(path: string, content: string): void;
44
- recordSkillInvocation(name: string, body: string): void;
45
- snapshotFiles(limit?: number): FileReadRecord[];
46
- snapshotSkills(): SkillInvocationRecord[];
47
- buildRecoveryAttachment(toolSchemaNames: string[]): string;
48
- }
49
-
50
- /**
51
- * Copyright (c) 2026 hangtiancheng
52
- *
53
- * Permission is hereby granted, free of charge, to any person obtaining a copy
54
- * of this software and associated documentation files (the "Software"), to deal
55
- * in the Software without restriction, including without limitation the rights
56
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
57
- * copies of the Software, and to permit persons to whom the Software is
58
- * furnished to do so, subject to the following conditions:
59
- *
60
- * The above copyright notice and this permission notice shall be included in
61
- * all copies or substantial portions of the Software.
62
- *
63
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
69
- * SOFTWARE.
70
- */
71
- type DecisionEffect = "allow" | "deny" | "ask";
72
- type PermissionMode = "default" | "acceptEdits" | "plan" | "bypassPermissions";
73
- interface Decision {
74
- effect: DecisionEffect;
75
- reason: string;
76
- }
77
- type RuleEffect = DecisionEffect;
78
- interface Rule {
79
- tool: string;
80
- pattern: string;
81
- effect: RuleEffect;
82
- }
83
- declare function extractContent(toolName: string, args: Record<string, unknown>): string;
84
- declare class PathSandbox {
85
- private allowedRoots;
86
- private denyWritePaths;
87
- private projectDir;
88
- constructor(projectDir: string);
89
- addRoot(root: string): void;
90
- addDenyWrite(path: string): void;
91
- /**
92
- * Check whether a path is in the deny-write list.
93
- * denyWrite has the highest priority — even if the path is within an allowed root, writes are still denied.
94
- */
95
- checkDenyWrite(filePath: string): Decision | null;
96
- check(filePath: string): Decision | null;
97
- }
98
- declare function evaluateRules(rules: Rule[], toolName: string, content: string): RuleEffect | null;
99
- declare class RuleEngine {
100
- private userPath;
101
- private projectPath;
102
- private localPath;
103
- private cache;
104
- constructor(workDir: string);
105
- private rulesFor;
106
- snapshot(): Rule[];
107
- evaluate(toolName: string, content: string): RuleEffect | null;
108
- appendLocalRule(rule: Rule): void;
109
- }
110
- declare function isSafeCommand(command: string): boolean;
111
- declare class PermissionChecker {
112
- private readonly workDir;
113
- mode: PermissionMode;
114
- planFilePath: string;
115
- sandboxEnabled: boolean;
116
- sandboxAutoAllow: boolean;
117
- private sandbox;
118
- private ruleEngine;
119
- constructor(workDir: string, mode?: PermissionMode);
120
- forWorkDir(workDir: string): PermissionChecker;
121
- check(toolName: string, category: "read" | "write" | "command", args: Record<string, unknown>): Decision;
122
- allowExtraRoot(path: string): void;
123
- allowAlways(toolName: string, args: Record<string, unknown>): void;
124
- /**
125
- * Generate a human-readable description of the tool action for display in HITL confirmation dialogs.
126
- * Prioritizes extracting fields defined in contentFields (e.g., command, file_path);
127
- * falls back to a key:value summary of parameters if no match is found.
128
- */
129
- describeToolAction(toolName: string, args: Record<string, unknown>): string;
30
+ interface UsageInfo {
31
+ inputTokens: number;
32
+ outputTokens: number;
33
+ cacheReadInputTokens: number;
34
+ cacheCreationInputTokens: number;
130
35
  }
36
+ /** Tool use delta: Input partial JSON */
37
+ type StreamEvent = {
38
+ type: "text_delta";
39
+ text: string;
40
+ } | {
41
+ type: "thinking_delta";
42
+ text: string;
43
+ } | {
44
+ type: "thinking_complete";
45
+ thinking: string;
46
+ signature: string;
47
+ } | {
48
+ type: "tool_call_start";
49
+ toolName: string;
50
+ toolId: string;
51
+ } | {
52
+ type: "tool_call_delta";
53
+ text: string;
54
+ } | {
55
+ type: "tool_call_complete";
56
+ toolId: string;
57
+ toolName: string;
58
+ arguments: Record<string, unknown>;
59
+ providerItemId?: string;
60
+ } | {
61
+ type: "stream_end";
62
+ stopReason: string;
63
+ usage: UsageInfo;
64
+ };
131
65
 
132
66
  /**
133
67
  * Copyright (c) 2026 hangtiancheng
@@ -219,6 +153,87 @@ declare class FileHistory {
219
153
  save(): void;
220
154
  }
221
155
 
156
+ /**
157
+ * Copyright (c) 2026 hangtiancheng
158
+ *
159
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
160
+ * of this software and associated documentation files (the "Software"), to deal
161
+ * in the Software without restriction, including without limitation the rights
162
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
163
+ * copies of the Software, and to permit persons to whom the Software is
164
+ * furnished to do so, subject to the following conditions:
165
+ *
166
+ * The above copyright notice and this permission notice shall be included in
167
+ * all copies or substantial portions of the Software.
168
+ *
169
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
170
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
171
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
172
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
173
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
174
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
175
+ * SOFTWARE.
176
+ */
177
+ type DecisionEffect = "allow" | "deny" | "ask";
178
+ type PermissionMode = "default" | "acceptEdits" | "plan" | "bypassPermissions";
179
+ interface Decision {
180
+ effect: DecisionEffect;
181
+ reason: string;
182
+ }
183
+ type RuleEffect = DecisionEffect;
184
+ interface Rule {
185
+ tool: string;
186
+ pattern: string;
187
+ effect: RuleEffect;
188
+ }
189
+ declare function extractContent(toolName: string, args: Record<string, unknown>): string;
190
+ declare class PathSandbox {
191
+ private allowedRoots;
192
+ private denyWritePaths;
193
+ private projectDir;
194
+ constructor(projectDir: string);
195
+ addRoot(root: string): void;
196
+ addDenyWrite(path: string): void;
197
+ /**
198
+ * Check whether a path is in the deny-write list.
199
+ * denyWrite has the highest priority — even if the path is within an allowed root, writes are still denied.
200
+ */
201
+ checkDenyWrite(filePath: string): Decision | null;
202
+ check(filePath: string): Decision | null;
203
+ }
204
+ declare function evaluateRules(rules: Rule[], toolName: string, content: string): RuleEffect | null;
205
+ declare class RuleEngine {
206
+ private userPath;
207
+ private projectPath;
208
+ private cache;
209
+ constructor(workDir: string);
210
+ private rulesFor;
211
+ snapshot(): Rule[];
212
+ evaluate(toolName: string, content: string): RuleEffect | null;
213
+ appendProjectRule(rule: Rule): void;
214
+ }
215
+ declare function isSafeCommand(command: string): boolean;
216
+ declare class PermissionChecker {
217
+ private readonly workDir;
218
+ mode: PermissionMode;
219
+ planFilePath: string;
220
+ sandboxEnabled: boolean;
221
+ sandboxAutoAllow: boolean;
222
+ private sandbox;
223
+ private ruleEngine;
224
+ constructor(workDir: string, mode?: PermissionMode);
225
+ forWorkDir(workDir: string): PermissionChecker;
226
+ check(toolName: string, category: "read" | "write" | "command", args: Record<string, unknown>): Decision;
227
+ allowExtraRoot(path: string): void;
228
+ allowAlways(toolName: string, args: Record<string, unknown>): void;
229
+ /**
230
+ * Generate a human-readable description of the tool action for display in HITL confirmation dialogs.
231
+ * Prioritizes extracting fields defined in contentFields (e.g., command, file_path);
232
+ * falls back to a key:value summary of parameters if no match is found.
233
+ */
234
+ describeToolAction(toolName: string, args: Record<string, unknown>): string;
235
+ }
236
+
222
237
  /**
223
238
  * Copyright (c) 2026 hangtiancheng
224
239
  *
@@ -296,6 +311,7 @@ interface ToolSchema {
296
311
  type: "object";
297
312
  properties: Record<string, object>;
298
313
  required?: string[];
314
+ [keyword: string]: unknown;
299
315
  };
300
316
  allowed_callers?: ("direct" | "code_execution_20250825" | "code_execution_20260120")[];
301
317
  cache_control?: {
@@ -304,6 +320,12 @@ interface ToolSchema {
304
320
  };
305
321
  eager_input_streaming?: boolean;
306
322
  }
323
+ type ToolProtocol = "anthropic" | "openai" | "openai-compat";
324
+ type AnthropicToolSchema = ToolSchema | Anthropic.Tool | BetaToolComputerUse20251124;
325
+ type OpenAIResponsesToolSchema = OpenAI.Responses.FunctionTool | OpenAI.Responses.ComputerTool;
326
+ type OpenAICompatToolSchema = OpenAI.ChatCompletionFunctionTool;
327
+ type ProviderToolSchema = ToolSchema | AnthropicToolSchema | OpenAIResponsesToolSchema | OpenAICompatToolSchema;
328
+ type ProviderNativeToolSchema = BetaToolComputerUse20251124 | OpenAI.Responses.ComputerTool;
307
329
  interface Tool {
308
330
  name: string;
309
331
  description: string;
@@ -322,6 +344,12 @@ interface Tool {
322
344
  * trip, so they are never deferred and always ship their full schema.
323
345
  */
324
346
  deferred?: boolean;
347
+ /**
348
+ * Return a provider-native declaration when the protocol supports this tool
349
+ * natively. Returning undefined lets the registry serialize schema() as a
350
+ * regular custom/function tool.
351
+ */
352
+ providerSchema?(protocol: ToolProtocol): ProviderNativeToolSchema | undefined;
325
353
  /**
326
354
  * Whether this particular invocation can run concurrently with others,
327
355
  * judged by actual arguments rather than just the tool category.
@@ -363,6 +391,7 @@ interface ToolUseBlock {
363
391
  toolUseId: string;
364
392
  toolName: string;
365
393
  arguments: Record<string, unknown>;
394
+ providerItemId?: string;
366
395
  }
367
396
  interface ToolResultBlock {
368
397
  toolUseId: string;
@@ -442,68 +471,394 @@ declare class ConversationManager {
442
471
  * SOFTWARE.
443
472
  */
444
473
 
445
- declare class ConfigError extends Error {
446
- constructor(message: string);
447
- }
448
- /** The single global config file: $HOME/.swifty/config.yaml. */
449
- declare function globalConfigPath(): string;
450
- /**
451
- * PI-equivalent thinking levels. `off` disables reasoning entirely; the rest
452
- * map to a provider-native effort string (openai / openai-compat) or a thinking
453
- * token budget (anthropic).
454
- */
455
- declare const THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
456
- type ThinkingLevel = (typeof THINKING_LEVELS)[number];
457
- declare const ProviderConfigSchema: z.ZodObject<{
458
- name: z.ZodString;
459
- protocol: z.ZodEnum<{
460
- anthropic: "anthropic";
461
- openai: "openai";
462
- "openai-compat": "openai-compat";
463
- }>;
464
- base_url: z.ZodString;
465
- model: z.ZodString;
466
- api_key: z.ZodOptional<z.ZodString>;
467
- thinking: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
468
- off: "off";
469
- minimal: "minimal";
470
- low: "low";
471
- medium: "medium";
472
- high: "high";
473
- xhigh: "xhigh";
474
- max: "max";
475
- }>]>>;
476
- context_window: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
477
- max_output_tokens: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
474
+ declare const COMPACT_BOUNDARY = "compact_boundary";
475
+ /** Persisted form of a tool invocation. Stores a provider-agnostic internal representation rather than
476
+ * any vendor-specific wire format, so sessions can be restored even after switching providers. */
477
+ declare const ToolUseRecordSchema: z.ZodObject<{
478
+ tool_use_id: z.ZodString;
479
+ tool_name: z.ZodString;
480
+ arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
481
+ provider_item_id: z.ZodOptional<z.ZodString>;
478
482
  }, z.core.$strip>;
479
- type ProviderConfig = z.infer<typeof ProviderConfigSchema>;
480
- declare const DEFAULT_THINKING_LEVEL: ThinkingLevel;
481
- declare const DEFAULT_CONTEXT_WINDOW = 1000000;
482
- /**
483
- * Fallback output-token ceiling used when `max_output_tokens` is unset (PI's
484
- * custom-model `maxTokens` default).
485
- */
486
- declare const DEFAULT_MAX_OUTPUT_TOKENS = 128000;
487
- /**
488
- * PI-equivalent thinking token budgets, used by the anthropic budget-based
489
- * thinking path. Must stay below DEFAULT_MAX_OUTPUT_TOKENS so the answer keeps
490
- * room after the thinking budget is reserved.
491
- */
492
- declare const THINKING_BUDGETS: Record<Exclude<ThinkingLevel, "off">, number>;
493
- declare function isValidThinkingLevel(value: string): value is ThinkingLevel;
494
- /**
495
- * Default thinking level per protocol. Anthropic historically enabled extended
496
- * thinking by default; the OpenAI protocols never sent a reasoning parameter
497
- * before, and non-reasoning models reject `reasoning_effort`, so they only opt
498
- * in when `thinking` is configured explicitly.
499
- */
500
- declare function defaultThinkingLevelFor(protocol: ProviderConfig["protocol"]): ThinkingLevel;
501
- /** Normalize the config `thinking` field (level or legacy boolean) to a level. */
483
+ type ToolUseRecord = z.infer<typeof ToolUseRecordSchema>;
484
+ /** Persisted form of a tool result, paired with a ToolUseRecord via tool_use_id. */
485
+ declare const ToolResultRecordSchema: z.ZodObject<{
486
+ tool_use_id: z.ZodString;
487
+ content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>]>;
488
+ content_blocks: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
489
+ is_error: z.ZodOptional<z.ZodBoolean>;
490
+ }, z.core.$strip>;
491
+ type ToolResultRecord = z.infer<typeof ToolResultRecordSchema>;
492
+ declare const SessionMessageSchema: z.ZodObject<{
493
+ role: z.ZodString;
494
+ content: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>]>>;
495
+ timestamp: z.ZodNumber;
496
+ type: z.ZodOptional<z.ZodString>;
497
+ tool_uses: z.ZodOptional<z.ZodArray<z.ZodObject<{
498
+ tool_use_id: z.ZodString;
499
+ tool_name: z.ZodString;
500
+ arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
501
+ provider_item_id: z.ZodOptional<z.ZodString>;
502
+ }, z.core.$strip>>>;
503
+ tool_results: z.ZodOptional<z.ZodArray<z.ZodObject<{
504
+ tool_use_id: z.ZodString;
505
+ content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>]>;
506
+ content_blocks: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
507
+ is_error: z.ZodOptional<z.ZodBoolean>;
508
+ }, z.core.$strip>>>;
509
+ }, z.core.$strip>;
510
+ type SessionMessage = z.infer<typeof SessionMessageSchema>;
511
+ declare const KeptMessageSchema: z.ZodObject<{
512
+ role: z.ZodString;
513
+ content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>]>;
514
+ tool_uses: z.ZodOptional<z.ZodArray<z.ZodObject<{
515
+ tool_use_id: z.ZodString;
516
+ tool_name: z.ZodString;
517
+ arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
518
+ provider_item_id: z.ZodOptional<z.ZodString>;
519
+ }, z.core.$strip>>>;
520
+ tool_results: z.ZodOptional<z.ZodArray<z.ZodObject<{
521
+ tool_use_id: z.ZodString;
522
+ content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>]>;
523
+ content_blocks: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
524
+ is_error: z.ZodOptional<z.ZodBoolean>;
525
+ }, z.core.$strip>>>;
526
+ }, z.core.$strip>;
527
+ type KeptMessage = z.infer<typeof KeptMessageSchema>;
528
+ /** Conversation-layer tool blocks (camelCase) → persisted records (snake_case); empty values are omitted. */
529
+ declare function toolUsesToRecords(toolUses?: {
530
+ toolUseId: string;
531
+ toolName: string;
532
+ arguments?: Record<string, unknown>;
533
+ providerItemId?: string;
534
+ }[]): ToolUseRecord[];
535
+ declare function toolResultsToRecords(toolResults?: ToolResultBlock[]): ToolResultRecord[];
536
+ declare const CompactBoundaryPayloadSchema: z.ZodObject<{
537
+ summary: z.ZodString;
538
+ keep: z.ZodArray<z.ZodObject<{
539
+ role: z.ZodString;
540
+ content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>]>;
541
+ tool_uses: z.ZodOptional<z.ZodArray<z.ZodObject<{
542
+ tool_use_id: z.ZodString;
543
+ tool_name: z.ZodString;
544
+ arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
545
+ provider_item_id: z.ZodOptional<z.ZodString>;
546
+ }, z.core.$strip>>>;
547
+ tool_results: z.ZodOptional<z.ZodArray<z.ZodObject<{
548
+ tool_use_id: z.ZodString;
549
+ content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>]>;
550
+ content_blocks: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
551
+ is_error: z.ZodOptional<z.ZodBoolean>;
552
+ }, z.core.$strip>>>;
553
+ }, z.core.$strip>>;
554
+ }, z.core.$strip>;
555
+ type CompactBoundaryPayload = z.infer<typeof CompactBoundaryPayloadSchema>;
556
+ interface SessionInfo {
557
+ id: string;
558
+ firstMessage: string;
559
+ messageCount: number;
560
+ size: number;
561
+ modTime: Date;
562
+ }
563
+ declare function getSessionFilePath(workDir: string, sessionId: string): string;
564
+ declare function newSessionId(): string;
565
+ declare function saveMessage(workDir: string, sessionId: string, msg: SessionMessage): void;
566
+ declare function saveCompactBoundary(workDir: string, sessionId: string, payload: CompactBoundaryPayload): void;
567
+ declare function loadSession(workDir: string, sessionId: string): SessionMessage[];
568
+ interface RestoredMessage {
569
+ role: "user" | "assistant";
570
+ content: string | Record<string, unknown>[];
571
+ toolUses?: {
572
+ toolUseId: string;
573
+ toolName: string;
574
+ arguments?: Record<string, unknown>;
575
+ providerItemId?: string;
576
+ }[];
577
+ toolResults?: ToolResultBlock[];
578
+ }
579
+ declare function rebuildFromSession(saved: SessionMessage[]): RestoredMessage[];
580
+ declare function listSessions(workDir: string): SessionInfo[];
581
+ /**
582
+ * Cleans up expired sessions: deletes .jsonl files whose last modified time exceeds SESSION_EXPIRY_DAYS.
583
+ * Called during listSessions or on startup to prevent the session directory from growing indefinitely.
584
+ * Silently skips failures (best-effort).
585
+ */
586
+ declare function cleanExpiredSessions(workDir: string): number;
587
+
588
+ /**
589
+ * Copyright (c) 2026 hangtiancheng
590
+ *
591
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
592
+ * of this software and associated documentation files (the "Software"), to deal
593
+ * in the Software without restriction, including without limitation the rights
594
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
595
+ * copies of the Software, and to permit persons to whom the Software is
596
+ * furnished to do so, subject to the following conditions:
597
+ *
598
+ * The above copyright notice and this permission notice shall be included in
599
+ * all copies or substantial portions of the Software.
600
+ *
601
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
602
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
603
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
604
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
605
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
606
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
607
+ * SOFTWARE.
608
+ */
609
+
610
+ type AgentEvent = {
611
+ type: "stream_text";
612
+ text: string;
613
+ } | {
614
+ type: "thinking_text";
615
+ text: string;
616
+ } | {
617
+ type: "thinking_complete";
618
+ thinking: string;
619
+ signature: string;
620
+ } | {
621
+ type: "tool_use";
622
+ toolName: string;
623
+ toolId: string;
624
+ args: Record<string, unknown>;
625
+ } | {
626
+ type: "tool_result";
627
+ toolName: string;
628
+ toolId: string;
629
+ output: string;
630
+ contentBlocks?: ToolResultContentBlock[];
631
+ isError: boolean;
632
+ elapsed: number;
633
+ } | {
634
+ type: "turn_complete";
635
+ } | {
636
+ type: "loop_complete";
637
+ stopReason: string;
638
+ } | {
639
+ type: "usage";
640
+ usage: UsageInfo;
641
+ } | {
642
+ type: "error";
643
+ error: Error;
644
+ } | {
645
+ type: "compact";
646
+ message: string;
647
+ boundary?: CompactBoundaryPayload | undefined;
648
+ } | {
649
+ type: "retry";
650
+ reason: string;
651
+ delay: number;
652
+ } | {
653
+ type: "permission_request";
654
+ toolName: string;
655
+ args: Record<string, unknown>;
656
+ };
657
+
658
+ /**
659
+ * Copyright (c) 2026 hangtiancheng
660
+ *
661
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
662
+ * of this software and associated documentation files (the "Software"), to deal
663
+ * in the Software without restriction, including without limitation the rights
664
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
665
+ * copies of the Software, and to permit persons to whom the Software is
666
+ * furnished to do so, subject to the following conditions:
667
+ *
668
+ * The above copyright notice and this permission notice shall be included in
669
+ * all copies or substantial portions of the Software.
670
+ *
671
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
672
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
673
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
674
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
675
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
676
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
677
+ * SOFTWARE.
678
+ */
679
+ interface FileReadRecord {
680
+ path: string;
681
+ content: string;
682
+ timestamp: number;
683
+ }
684
+ interface SkillInvocationRecord {
685
+ name: string;
686
+ body: string;
687
+ timestamp: number;
688
+ }
689
+ declare class RecoveryState {
690
+ private files;
691
+ private skills;
692
+ recordFileRead(path: string, content: string): void;
693
+ recordSkillInvocation(name: string, body: string): void;
694
+ snapshotFiles(limit?: number): FileReadRecord[];
695
+ snapshotSkills(): SkillInvocationRecord[];
696
+ buildRecoveryAttachment(toolSchemaNames: string[]): string;
697
+ }
698
+
699
+ /**
700
+ * Copyright (c) 2026 hangtiancheng
701
+ *
702
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
703
+ * of this software and associated documentation files (the "Software"), to deal
704
+ * in the Software without restriction, including without limitation the rights
705
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
706
+ * copies of the Software, and to permit persons to whom the Software is
707
+ * furnished to do so, subject to the following conditions:
708
+ *
709
+ * The above copyright notice and this permission notice shall be included in
710
+ * all copies or substantial portions of the Software.
711
+ *
712
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
713
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
714
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
715
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
716
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
717
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
718
+ * SOFTWARE.
719
+ */
720
+
721
+ declare class ConfigError extends Error {
722
+ constructor(message: string);
723
+ }
724
+ /** The single global config file: $HOME/.swifty/config.yaml. */
725
+ declare function globalConfigPath(): string;
726
+ /**
727
+ * PI-equivalent thinking levels. `off` disables reasoning entirely; the rest
728
+ * map to a provider-native effort string (openai / openai-compat) or a thinking
729
+ * token budget (anthropic).
730
+ */
731
+ declare const THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
732
+ type ThinkingLevel = (typeof THINKING_LEVELS)[number];
733
+ declare const ReasoningEffortSchema: z$1.ZodEnum<{
734
+ minimal: "minimal";
735
+ low: "low";
736
+ medium: "medium";
737
+ high: "high";
738
+ xhigh: "xhigh";
739
+ max: "max";
740
+ none: "none";
741
+ }>;
742
+ declare const AnthropicEffortSchema: z$1.ZodEnum<{
743
+ low: "low";
744
+ medium: "medium";
745
+ high: "high";
746
+ xhigh: "xhigh";
747
+ max: "max";
748
+ }>;
749
+ declare const ProviderConfigSchema: z$1.ZodObject<{
750
+ name: z$1.ZodString;
751
+ protocol: z$1.ZodEnum<{
752
+ anthropic: "anthropic";
753
+ openai: "openai";
754
+ "openai-compat": "openai-compat";
755
+ }>;
756
+ base_url: z$1.ZodString;
757
+ model: z$1.ZodString;
758
+ api_key: z$1.ZodOptional<z$1.ZodString>;
759
+ thinking: z$1.ZodOptional<z$1.ZodEnum<{
760
+ off: "off";
761
+ minimal: "minimal";
762
+ low: "low";
763
+ medium: "medium";
764
+ high: "high";
765
+ xhigh: "xhigh";
766
+ max: "max";
767
+ }>>;
768
+ reasoning: z$1.ZodOptional<z$1.ZodBoolean>;
769
+ thinking_level_map: z$1.ZodOptional<z$1.ZodObject<{
770
+ off: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodLiteral<"none">>>;
771
+ minimal: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
772
+ minimal: "minimal";
773
+ low: "low";
774
+ medium: "medium";
775
+ high: "high";
776
+ xhigh: "xhigh";
777
+ max: "max";
778
+ none: "none";
779
+ }>>>;
780
+ low: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
781
+ minimal: "minimal";
782
+ low: "low";
783
+ medium: "medium";
784
+ high: "high";
785
+ xhigh: "xhigh";
786
+ max: "max";
787
+ none: "none";
788
+ }>>>;
789
+ medium: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
790
+ minimal: "minimal";
791
+ low: "low";
792
+ medium: "medium";
793
+ high: "high";
794
+ xhigh: "xhigh";
795
+ max: "max";
796
+ none: "none";
797
+ }>>>;
798
+ high: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
799
+ minimal: "minimal";
800
+ low: "low";
801
+ medium: "medium";
802
+ high: "high";
803
+ xhigh: "xhigh";
804
+ max: "max";
805
+ none: "none";
806
+ }>>>;
807
+ xhigh: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
808
+ minimal: "minimal";
809
+ low: "low";
810
+ medium: "medium";
811
+ high: "high";
812
+ xhigh: "xhigh";
813
+ max: "max";
814
+ none: "none";
815
+ }>>>;
816
+ max: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
817
+ minimal: "minimal";
818
+ low: "low";
819
+ medium: "medium";
820
+ high: "high";
821
+ xhigh: "xhigh";
822
+ max: "max";
823
+ none: "none";
824
+ }>>>;
825
+ }, z$1.core.$strict>>;
826
+ thinking_mode: z$1.ZodOptional<z$1.ZodEnum<{
827
+ budget: "budget";
828
+ adaptive: "adaptive";
829
+ }>>;
830
+ context_window: z$1.ZodOptional<z$1.ZodCoercedNumber<unknown>>;
831
+ max_output_tokens: z$1.ZodOptional<z$1.ZodCoercedNumber<unknown>>;
832
+ }, z$1.core.$loose>;
833
+ type ProviderConfig = z$1.infer<typeof ProviderConfigSchema>;
834
+ declare const DEFAULT_THINKING_LEVEL: ThinkingLevel;
835
+ declare const DEFAULT_CONTEXT_WINDOW = 1000000;
836
+ /**
837
+ * Fallback output-token ceiling used when `max_output_tokens` is unset (PI's
838
+ * custom-model `maxTokens` default).
839
+ */
840
+ declare const DEFAULT_MAX_OUTPUT_TOKENS = 128000;
841
+ /**
842
+ * PI-equivalent thinking token budgets, used by the anthropic budget-based
843
+ * thinking path. Must stay below DEFAULT_MAX_OUTPUT_TOKENS so the answer keeps
844
+ * room after the thinking budget is reserved.
845
+ */
846
+ declare const THINKING_BUDGETS: Record<Exclude<ThinkingLevel, "off">, number>;
847
+ declare const MIN_THINKING_BUDGET_TOKENS = 1024;
848
+ declare const MIN_THINKING_ANSWER_TOKENS = 1024;
849
+ declare function isValidThinkingLevel(value: string): value is ThinkingLevel;
850
+ /** Resolve the effective logical level, including explicit capability limits. */
502
851
  declare function getThinkingLevel(provider: ProviderConfig): ThinkingLevel;
503
852
  /** Thinking token budget for a level; 0 when thinking is off. */
504
853
  declare function thinkingBudgetForLevel(level: ThinkingLevel): number;
505
- /** Map a PI thinking level to an OpenAI reasoning effort string. */
506
- declare function toReasoningEffort(level: ThinkingLevel): "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
854
+ /** Map a logical level using configured capabilities, not model-name guesses. */
855
+ declare function toReasoningEffort(level: ThinkingLevel, provider?: ProviderConfig): z$1.infer<typeof ReasoningEffortSchema> | null;
856
+ /** Narrow adaptive efforts to the Anthropic SDK's legal values. */
857
+ declare function toAnthropicThinkingEffort(level: ThinkingLevel, provider: ProviderConfig): z$1.infer<typeof AnthropicEffortSchema> | null;
858
+ /** Available logical levels; missing metadata preserves the existing defaults. */
859
+ declare function getSupportedThinkingLevels(provider: ProviderConfig): readonly ThinkingLevel[];
860
+ /** Lower unsupported requests to the nearest available level, never higher. */
861
+ declare function clampThinkingLevel(provider: ProviderConfig, level: ThinkingLevel): ThinkingLevel;
507
862
  declare function withProviderDefaults(provider: ProviderConfig): ProviderConfig;
508
863
  declare function getContextWindow(provider: ProviderConfig): number;
509
864
  /**
@@ -514,51 +869,51 @@ declare function getContextWindow(provider: ProviderConfig): number;
514
869
  */
515
870
  declare function getMaxOutputTokens(provider: ProviderConfig): number;
516
871
  declare function resolveAPIKey(p: ProviderConfig): string;
517
- declare const MCPServerConfigSchema: z.ZodObject<{
518
- name: z.ZodString;
519
- command: z.ZodOptional<z.ZodString>;
520
- args: z.ZodOptional<z.ZodArray<z.ZodString>>;
521
- url: z.ZodOptional<z.ZodString>;
522
- transport: z.ZodOptional<z.ZodString>;
523
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
524
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
525
- }, z.core.$strip>;
526
- type MCPServerConfig = z.infer<typeof MCPServerConfigSchema>;
527
- declare const HookConfigSchema: z.ZodObject<{
528
- id: z.ZodOptional<z.ZodString>;
529
- event: z.ZodString;
530
- condition: z.ZodOptional<z.ZodString>;
531
- action: z.ZodObject<{
532
- type: z.ZodString;
533
- command: z.ZodOptional<z.ZodString>;
534
- url: z.ZodOptional<z.ZodString>;
535
- method: z.ZodOptional<z.ZodString>;
536
- prompt: z.ZodOptional<z.ZodString>;
537
- }, z.core.$strip>;
538
- reject: z.ZodOptional<z.ZodBoolean>;
539
- once: z.ZodOptional<z.ZodBoolean>;
540
- async: z.ZodOptional<z.ZodBoolean>;
541
- on_error: z.ZodOptional<z.ZodString>;
542
- }, z.core.$strip>;
543
- type HookConfig = z.infer<typeof HookConfigSchema>;
544
- declare const SandboxYamlConfigSchema: z.ZodObject<{
545
- enabled: z.ZodOptional<z.ZodBoolean>;
546
- auto_allow: z.ZodOptional<z.ZodBoolean>;
547
- network_enabled: z.ZodOptional<z.ZodBoolean>;
548
- }, z.core.$strip>;
549
- type SandboxYamlConfig = z.infer<typeof SandboxYamlConfigSchema>;
550
- declare const AppConfigSchema: z.ZodObject<{
551
- providers: z.ZodArray<z.ZodObject<{
552
- name: z.ZodString;
553
- protocol: z.ZodEnum<{
872
+ declare const MCPServerConfigSchema: z$1.ZodObject<{
873
+ name: z$1.ZodString;
874
+ command: z$1.ZodOptional<z$1.ZodString>;
875
+ args: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
876
+ url: z$1.ZodOptional<z$1.ZodString>;
877
+ transport: z$1.ZodOptional<z$1.ZodString>;
878
+ headers: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
879
+ env: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
880
+ }, z$1.core.$strip>;
881
+ type MCPServerConfig = z$1.infer<typeof MCPServerConfigSchema>;
882
+ declare const HookConfigSchema: z$1.ZodObject<{
883
+ id: z$1.ZodOptional<z$1.ZodString>;
884
+ event: z$1.ZodString;
885
+ condition: z$1.ZodOptional<z$1.ZodString>;
886
+ action: z$1.ZodObject<{
887
+ type: z$1.ZodString;
888
+ command: z$1.ZodOptional<z$1.ZodString>;
889
+ url: z$1.ZodOptional<z$1.ZodString>;
890
+ method: z$1.ZodOptional<z$1.ZodString>;
891
+ prompt: z$1.ZodOptional<z$1.ZodString>;
892
+ }, z$1.core.$strip>;
893
+ reject: z$1.ZodOptional<z$1.ZodBoolean>;
894
+ once: z$1.ZodOptional<z$1.ZodBoolean>;
895
+ async: z$1.ZodOptional<z$1.ZodBoolean>;
896
+ on_error: z$1.ZodOptional<z$1.ZodString>;
897
+ }, z$1.core.$strip>;
898
+ type HookConfig = z$1.infer<typeof HookConfigSchema>;
899
+ declare const SandboxYamlConfigSchema: z$1.ZodObject<{
900
+ enabled: z$1.ZodOptional<z$1.ZodBoolean>;
901
+ auto_allow: z$1.ZodOptional<z$1.ZodBoolean>;
902
+ network_enabled: z$1.ZodOptional<z$1.ZodBoolean>;
903
+ }, z$1.core.$strip>;
904
+ type SandboxYamlConfig = z$1.infer<typeof SandboxYamlConfigSchema>;
905
+ declare const AppConfigSchema: z$1.ZodObject<{
906
+ providers: z$1.ZodArray<z$1.ZodObject<{
907
+ name: z$1.ZodString;
908
+ protocol: z$1.ZodEnum<{
554
909
  anthropic: "anthropic";
555
910
  openai: "openai";
556
911
  "openai-compat": "openai-compat";
557
912
  }>;
558
- base_url: z.ZodString;
559
- model: z.ZodString;
560
- api_key: z.ZodOptional<z.ZodString>;
561
- thinking: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
913
+ base_url: z$1.ZodString;
914
+ model: z$1.ZodString;
915
+ api_key: z$1.ZodOptional<z$1.ZodString>;
916
+ thinking: z$1.ZodOptional<z$1.ZodEnum<{
562
917
  off: "off";
563
918
  minimal: "minimal";
564
919
  low: "low";
@@ -566,47 +921,109 @@ declare const AppConfigSchema: z.ZodObject<{
566
921
  high: "high";
567
922
  xhigh: "xhigh";
568
923
  max: "max";
569
- }>]>>;
570
- context_window: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
571
- max_output_tokens: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
572
- }, z.core.$strip>>;
573
- permission_mode: z.ZodOptional<z.ZodString>;
574
- mcp_servers: z.ZodDefault<z.ZodArray<z.ZodObject<{
575
- name: z.ZodString;
576
- command: z.ZodOptional<z.ZodString>;
577
- args: z.ZodOptional<z.ZodArray<z.ZodString>>;
578
- url: z.ZodOptional<z.ZodString>;
579
- transport: z.ZodOptional<z.ZodString>;
580
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
581
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
582
- }, z.core.$strip>>>;
583
- hooks: z.ZodDefault<z.ZodArray<z.ZodObject<{
584
- id: z.ZodOptional<z.ZodString>;
585
- event: z.ZodString;
586
- condition: z.ZodOptional<z.ZodString>;
587
- action: z.ZodObject<{
588
- type: z.ZodString;
589
- command: z.ZodOptional<z.ZodString>;
590
- url: z.ZodOptional<z.ZodString>;
591
- method: z.ZodOptional<z.ZodString>;
592
- prompt: z.ZodOptional<z.ZodString>;
593
- }, z.core.$strip>;
594
- reject: z.ZodOptional<z.ZodBoolean>;
595
- once: z.ZodOptional<z.ZodBoolean>;
596
- async: z.ZodOptional<z.ZodBoolean>;
597
- on_error: z.ZodOptional<z.ZodString>;
598
- }, z.core.$strip>>>;
599
- sandbox: z.ZodOptional<z.ZodObject<{
600
- enabled: z.ZodOptional<z.ZodBoolean>;
601
- auto_allow: z.ZodOptional<z.ZodBoolean>;
602
- network_enabled: z.ZodOptional<z.ZodBoolean>;
603
- }, z.core.$strip>>;
604
- enable_coordinator_mode: z.ZodOptional<z.ZodBoolean>;
605
- enable_fork: z.ZodOptional<z.ZodBoolean>;
606
- }, z.core.$loose>;
924
+ }>>;
925
+ reasoning: z$1.ZodOptional<z$1.ZodBoolean>;
926
+ thinking_level_map: z$1.ZodOptional<z$1.ZodObject<{
927
+ off: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodLiteral<"none">>>;
928
+ minimal: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
929
+ minimal: "minimal";
930
+ low: "low";
931
+ medium: "medium";
932
+ high: "high";
933
+ xhigh: "xhigh";
934
+ max: "max";
935
+ none: "none";
936
+ }>>>;
937
+ low: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
938
+ minimal: "minimal";
939
+ low: "low";
940
+ medium: "medium";
941
+ high: "high";
942
+ xhigh: "xhigh";
943
+ max: "max";
944
+ none: "none";
945
+ }>>>;
946
+ medium: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
947
+ minimal: "minimal";
948
+ low: "low";
949
+ medium: "medium";
950
+ high: "high";
951
+ xhigh: "xhigh";
952
+ max: "max";
953
+ none: "none";
954
+ }>>>;
955
+ high: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
956
+ minimal: "minimal";
957
+ low: "low";
958
+ medium: "medium";
959
+ high: "high";
960
+ xhigh: "xhigh";
961
+ max: "max";
962
+ none: "none";
963
+ }>>>;
964
+ xhigh: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
965
+ minimal: "minimal";
966
+ low: "low";
967
+ medium: "medium";
968
+ high: "high";
969
+ xhigh: "xhigh";
970
+ max: "max";
971
+ none: "none";
972
+ }>>>;
973
+ max: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
974
+ minimal: "minimal";
975
+ low: "low";
976
+ medium: "medium";
977
+ high: "high";
978
+ xhigh: "xhigh";
979
+ max: "max";
980
+ none: "none";
981
+ }>>>;
982
+ }, z$1.core.$strict>>;
983
+ thinking_mode: z$1.ZodOptional<z$1.ZodEnum<{
984
+ budget: "budget";
985
+ adaptive: "adaptive";
986
+ }>>;
987
+ context_window: z$1.ZodOptional<z$1.ZodCoercedNumber<unknown>>;
988
+ max_output_tokens: z$1.ZodOptional<z$1.ZodCoercedNumber<unknown>>;
989
+ }, z$1.core.$loose>>;
990
+ permission_mode: z$1.ZodOptional<z$1.ZodString>;
991
+ mcp_servers: z$1.ZodDefault<z$1.ZodArray<z$1.ZodObject<{
992
+ name: z$1.ZodString;
993
+ command: z$1.ZodOptional<z$1.ZodString>;
994
+ args: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
995
+ url: z$1.ZodOptional<z$1.ZodString>;
996
+ transport: z$1.ZodOptional<z$1.ZodString>;
997
+ headers: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
998
+ env: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
999
+ }, z$1.core.$strip>>>;
1000
+ hooks: z$1.ZodDefault<z$1.ZodArray<z$1.ZodObject<{
1001
+ id: z$1.ZodOptional<z$1.ZodString>;
1002
+ event: z$1.ZodString;
1003
+ condition: z$1.ZodOptional<z$1.ZodString>;
1004
+ action: z$1.ZodObject<{
1005
+ type: z$1.ZodString;
1006
+ command: z$1.ZodOptional<z$1.ZodString>;
1007
+ url: z$1.ZodOptional<z$1.ZodString>;
1008
+ method: z$1.ZodOptional<z$1.ZodString>;
1009
+ prompt: z$1.ZodOptional<z$1.ZodString>;
1010
+ }, z$1.core.$strip>;
1011
+ reject: z$1.ZodOptional<z$1.ZodBoolean>;
1012
+ once: z$1.ZodOptional<z$1.ZodBoolean>;
1013
+ async: z$1.ZodOptional<z$1.ZodBoolean>;
1014
+ on_error: z$1.ZodOptional<z$1.ZodString>;
1015
+ }, z$1.core.$strip>>>;
1016
+ sandbox: z$1.ZodOptional<z$1.ZodObject<{
1017
+ enabled: z$1.ZodOptional<z$1.ZodBoolean>;
1018
+ auto_allow: z$1.ZodOptional<z$1.ZodBoolean>;
1019
+ network_enabled: z$1.ZodOptional<z$1.ZodBoolean>;
1020
+ }, z$1.core.$strip>>;
1021
+ enable_coordinator_mode: z$1.ZodOptional<z$1.ZodBoolean>;
1022
+ enable_fork: z$1.ZodOptional<z$1.ZodBoolean>;
1023
+ }, z$1.core.$loose>;
607
1024
  /** Whether fork is available. Defaults to enabled when not specified in config. */
608
1025
  declare function forkEnabled(cfg: AppConfig): boolean;
609
- type AppConfig = z.infer<typeof AppConfigSchema>;
1026
+ type AppConfig = z$1.infer<typeof AppConfigSchema>;
610
1027
  declare function loadConfig(path?: string, options?: {
611
1028
  allowEmptyProviders?: boolean;
612
1029
  }): AppConfig;
@@ -667,62 +1084,6 @@ declare class HookEngine {
667
1084
  }
668
1085
  declare function validate(hooks: HookConfig[]): Error | null;
669
1086
 
670
- /**
671
- * Copyright (c) 2026 hangtiancheng
672
- *
673
- * Permission is hereby granted, free of charge, to any person obtaining a copy
674
- * of this software and associated documentation files (the "Software"), to deal
675
- * in the Software without restriction, including without limitation the rights
676
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
677
- * copies of the Software, and to permit persons to whom the Software is
678
- * furnished to do so, subject to the following conditions:
679
- *
680
- * The above copyright notice and this permission notice shall be included in
681
- * all copies or substantial portions of the Software.
682
- *
683
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
684
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
685
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
686
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
687
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
688
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
689
- * SOFTWARE.
690
- */
691
- interface UsageInfo {
692
- inputTokens: number;
693
- outputTokens: number;
694
- cacheReadInputTokens: number;
695
- cacheCreationInputTokens: number;
696
- }
697
- /** Tool use delta: Input partial JSON */
698
- type StreamEvent = {
699
- type: "text_delta";
700
- text: string;
701
- } | {
702
- type: "thinking_delta";
703
- text: string;
704
- } | {
705
- type: "thinking_complete";
706
- thinking: string;
707
- signature: string;
708
- } | {
709
- type: "tool_call_start";
710
- toolName: string;
711
- toolId: string;
712
- } | {
713
- type: "tool_call_delta";
714
- text: string;
715
- } | {
716
- type: "tool_call_complete";
717
- toolId: string;
718
- toolName: string;
719
- arguments: Record<string, unknown>;
720
- } | {
721
- type: "stream_end";
722
- stopReason: string;
723
- usage: UsageInfo;
724
- };
725
-
726
1087
  /**
727
1088
  * Copyright (c) 2026 hangtiancheng
728
1089
  *
@@ -746,32 +1107,38 @@ type StreamEvent = {
746
1107
  */
747
1108
 
748
1109
  declare class OpenAIClient implements LLMClient {
1110
+ readonly protocol: "openai";
749
1111
  private client;
750
1112
  private model;
751
1113
  private systemPrompt;
752
1114
  private maxOutputTokens;
753
1115
  private thinkingLevel;
1116
+ private config;
754
1117
  constructor(config: ProviderConfig, systemPrompt: string);
755
- stream(conversation: ConversationManager, toolSchemas: ToolSchema[], abortSignal?: AbortSignal): AsyncGenerator<StreamEvent>;
1118
+ stream(conversation: ConversationManager, toolSchemas: ProviderToolSchema[], abortSignal?: AbortSignal): AsyncGenerator<StreamEvent>;
756
1119
  setSystemPrompt(prompt: string): void;
757
1120
  setMaxOutputTokens(maxTokens: number): void;
758
- setThinkingLevel(level: ThinkingLevel): void;
1121
+ setThinkingLevel(level: ThinkingLevel): ThinkingLevel;
759
1122
  getThinkingLevel(): ThinkingLevel;
1123
+ getSupportedThinkingLevels(): readonly ThinkingLevel[];
760
1124
  }
761
- type OpenAIMessageParam = OpenAI.Responses.EasyInputMessage | OpenAI.Responses.ResponseFunctionToolCall | OpenAI.Responses.ResponseInputItem.FunctionCallOutput | OpenAI.Responses.ResponseReasoningItem;
1125
+ type OpenAIMessageParam = OpenAI.Responses.EasyInputMessage | OpenAI.Responses.ResponseComputerToolCall | OpenAI.Responses.ResponseInputItem.ComputerCallOutput | OpenAI.Responses.ResponseFunctionToolCall | OpenAI.Responses.ResponseInputItem.FunctionCallOutput | OpenAI.Responses.ResponseReasoningItem;
762
1126
  declare function buildOpenAIInput(messages: Message[]): OpenAIMessageParam[];
763
1127
  declare class OpenAICompatClient implements LLMClient {
1128
+ readonly protocol: "openai-compat";
764
1129
  private client;
765
1130
  private model;
766
1131
  private systemPrompt;
767
1132
  private maxOutputTokens;
768
1133
  private thinkingLevel;
1134
+ private config;
769
1135
  constructor(config: ProviderConfig, systemPrompt: string);
770
1136
  setSystemPrompt(prompt: string): void;
771
1137
  setMaxOutputTokens(maxTokens: number): void;
772
- setThinkingLevel(level: ThinkingLevel): void;
1138
+ setThinkingLevel(level: ThinkingLevel): ThinkingLevel;
773
1139
  getThinkingLevel(): ThinkingLevel;
774
- stream(conversation: ConversationManager, toolSchemas: ToolSchema[], abortSignal?: AbortSignal): AsyncGenerator<StreamEvent>;
1140
+ getSupportedThinkingLevels(): readonly ThinkingLevel[];
1141
+ stream(conversation: ConversationManager, toolSchemas: ProviderToolSchema[], abortSignal?: AbortSignal): AsyncGenerator<StreamEvent>;
775
1142
  }
776
1143
  declare function buildChatCompletionMessages(messages: Message[]): OpenAI.ChatCompletionMessageParam[];
777
1144
 
@@ -807,7 +1174,10 @@ declare function buildChatCompletionMessages(messages: Message[]): OpenAI.ChatCo
807
1174
  * built-in tools, so the array tail is often a deferred tool — we must scan
808
1175
  * backwards. Built-in tools are never deferred, so a valid slot always exists.
809
1176
  */
810
- declare function markToolsForCache(tools: ToolSchema[]): void;
1177
+ declare function markToolsForCache(tools: {
1178
+ defer_loading?: boolean;
1179
+ cache_control?: Anthropic.CacheControlEphemeral | null;
1180
+ }[]): void;
811
1181
  /**
812
1182
  * Whether any tool in this batch has defer_loading set.
813
1183
  *
@@ -815,25 +1185,25 @@ declare function markToolsForCache(tools: ToolSchema[]): void;
815
1185
  * recognize it reject the request outright, and the dispatch / eager paths do not
816
1186
  * use it at all.
817
1187
  */
818
- declare function needsToolSearchBeta(toolSchemas: ToolSchema[]): boolean;
1188
+ declare function needsToolSearchBeta(toolSchemas: ProviderToolSchema[]): boolean;
819
1189
  declare function fetchModelContextWindow(config: ProviderConfig): Promise<number>;
820
1190
  declare function buildAnthropicMessages(messages: Message[]): Anthropic.MessageParam[];
821
1191
  declare class AnthropicClient implements LLMClient {
1192
+ readonly protocol: "anthropic";
822
1193
  private client;
823
1194
  private model;
824
- /**
825
- * PI-equivalent thinking level; maps to a thinking token budget.
826
- */
1195
+ /** Effective logical level for budget or explicitly configured adaptive mode. */
827
1196
  private thinkingLevel;
828
1197
  private systemPrompt;
829
1198
  private maxOutputTokens;
830
- /** Currently not used */
1199
+ private config;
831
1200
  constructor(config: ProviderConfig, systemPrompt: string);
832
1201
  setSystemPrompt(prompt: string): void;
833
1202
  setMaxOutputTokens(maxTokens: number): void;
834
- setThinkingLevel(level: ThinkingLevel): void;
1203
+ setThinkingLevel(level: ThinkingLevel): ThinkingLevel;
835
1204
  getThinkingLevel(): ThinkingLevel;
836
- stream(conversation: ConversationManager, toolSchemas: ToolSchema[], abortSignal?: AbortSignal): AsyncGenerator<StreamEvent>;
1205
+ getSupportedThinkingLevels(): readonly ThinkingLevel[];
1206
+ stream(conversation: ConversationManager, toolSchemas: ProviderToolSchema[], abortSignal?: AbortSignal): AsyncGenerator<StreamEvent>;
837
1207
  }
838
1208
  /**
839
1209
  * @param messages
@@ -841,16 +1211,19 @@ declare class AnthropicClient implements LLMClient {
841
1211
  declare function markLastUserTailForCache(messages: Anthropic.Messages.MessageParam[]): void;
842
1212
 
843
1213
  interface LLMClient extends Partial<MaxTokensSetter>, Partial<ThinkingLevelControl> {
844
- stream(conversationManager: ConversationManager, toolSchemas: ToolSchema[], abortSignal?: AbortSignal): AsyncGenerator<StreamEvent>;
1214
+ readonly protocol?: ToolProtocol;
1215
+ stream(conversationManager: ConversationManager, toolSchemas: ProviderToolSchema[], abortSignal?: AbortSignal): AsyncGenerator<StreamEvent>;
845
1216
  setSystemPrompt(prompt: string): void;
846
1217
  }
847
1218
  interface MaxTokensSetter {
848
1219
  setMaxOutputTokens(maxTokens: number): void;
849
1220
  }
850
- /** Runtime control of the PI-equivalent thinking level. */
1221
+ /** Runtime control of the effective logical thinking level. */
851
1222
  interface ThinkingLevelControl {
852
- setThinkingLevel(level: ThinkingLevel): void;
1223
+ /** Applies the level and returns the effective one, which may be clamped by the provider. */
1224
+ setThinkingLevel(level: ThinkingLevel): ThinkingLevel;
853
1225
  getThinkingLevel(): ThinkingLevel;
1226
+ getSupportedThinkingLevels?(): readonly ThinkingLevel[];
854
1227
  }
855
1228
  declare function createClient(config: ProviderConfig, systemPrompt: string): Promise<AnthropicClient | OpenAIClient | OpenAICompatClient>;
856
1229
 
@@ -953,257 +1326,60 @@ declare class MemoryManager {
953
1326
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
954
1327
  * copies of the Software, and to permit persons to whom the Software is
955
1328
  * furnished to do so, subject to the following conditions:
956
- *
957
- * The above copyright notice and this permission notice shall be included in
958
- * all copies or substantial portions of the Software.
959
- *
960
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
961
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
962
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
963
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
964
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
965
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
966
- * SOFTWARE.
967
- */
968
-
969
- declare class ToolRegistry {
970
- private tools;
971
- private discovered;
972
- /**
973
- * How MCP tools are loaded, written by mcp/strategy after connecting to the
974
- * server. ToolSearch relies on it to decide what to return, and the client
975
- * relies on it to decide whether to send defer_loading. It stays eager when
976
- * there is no MCP, which behaves the same as no deferral.
977
- */
978
- mcpLoadingMode: McpLoadingMode;
979
- /**
980
- * Whether to expose the search and dispatch tools to the model is computed once
981
- * by applyMode in mcp/strategy at session start. It is not recomputed each turn
982
- * based on "are there still deferred tools": tools may be disabled at runtime,
983
- * and recomputing would drop one from tools[] mid-session — that's an array
984
- * change, which breaks the cache prefix just the same.
985
- */
986
- exposeToolSearch: boolean;
987
- exposeMcpCall: boolean;
988
- register(tool: Tool): void;
989
- get(name: string): Tool | undefined;
990
- listTools(): Tool[];
991
- getAllSchemas(protocol?: "anthropic"): Anthropic.Tool[];
992
- getAllSchemas(protocol: "openai" | "openai-compat"): FunctionTool[];
993
- /**
994
- * Names of deferred tools not yet discovered, in lexicographic order.
995
- *
996
- * Sorting is not cosmetic: callers compare this list to detect pool changes;
997
- * unstable ordering would produce different text for the same set of tools
998
- * and break the comparison.
999
- */
1000
- getDeferredToolNames(): string[];
1001
- getDeferredTools(): Tool[];
1002
- searchDeferred(query: string, maxResults?: number): Tool[];
1003
- findDeferredByNames(names: string[]): Tool[];
1004
- markDiscovered(name: string): void;
1005
- isDiscovered(name: string): boolean;
1006
- }
1007
-
1008
- /**
1009
- * Copyright (c) 2026 hangtiancheng
1010
- *
1011
- * Permission is hereby granted, free of charge, to any person obtaining a copy
1012
- * of this software and associated documentation files (the "Software"), to deal
1013
- * in the Software without restriction, including without limitation the rights
1014
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1015
- * copies of the Software, and to permit persons to whom the Software is
1016
- * furnished to do so, subject to the following conditions:
1017
- *
1018
- * The above copyright notice and this permission notice shall be included in
1019
- * all copies or substantial portions of the Software.
1020
- *
1021
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1022
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1023
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1024
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1025
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1026
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1027
- * SOFTWARE.
1028
- */
1029
-
1030
- declare const COMPACT_BOUNDARY = "compact_boundary";
1031
- /** Persisted form of a tool invocation. Stores a provider-agnostic internal representation rather than
1032
- * any vendor-specific wire format, so sessions can be restored even after switching providers. */
1033
- declare const ToolUseRecordSchema: z$1.ZodObject<{
1034
- tool_use_id: z$1.ZodString;
1035
- tool_name: z$1.ZodString;
1036
- arguments: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
1037
- }, z$1.core.$strip>;
1038
- type ToolUseRecord = z$1.infer<typeof ToolUseRecordSchema>;
1039
- /** Persisted form of a tool result, paired with a ToolUseRecord via tool_use_id. */
1040
- declare const ToolResultRecordSchema: z$1.ZodObject<{
1041
- tool_use_id: z$1.ZodString;
1042
- content: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>]>;
1043
- content_blocks: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnknown>>;
1044
- is_error: z$1.ZodOptional<z$1.ZodBoolean>;
1045
- }, z$1.core.$strip>;
1046
- type ToolResultRecord = z$1.infer<typeof ToolResultRecordSchema>;
1047
- declare const SessionMessageSchema: z$1.ZodObject<{
1048
- role: z$1.ZodString;
1049
- content: z$1.ZodDefault<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>]>>;
1050
- timestamp: z$1.ZodNumber;
1051
- type: z$1.ZodOptional<z$1.ZodString>;
1052
- tool_uses: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1053
- tool_use_id: z$1.ZodString;
1054
- tool_name: z$1.ZodString;
1055
- arguments: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
1056
- }, z$1.core.$strip>>>;
1057
- tool_results: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1058
- tool_use_id: z$1.ZodString;
1059
- content: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>]>;
1060
- content_blocks: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnknown>>;
1061
- is_error: z$1.ZodOptional<z$1.ZodBoolean>;
1062
- }, z$1.core.$strip>>>;
1063
- }, z$1.core.$strip>;
1064
- type SessionMessage = z$1.infer<typeof SessionMessageSchema>;
1065
- declare const KeptMessageSchema: z$1.ZodObject<{
1066
- role: z$1.ZodString;
1067
- content: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>]>;
1068
- tool_uses: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1069
- tool_use_id: z$1.ZodString;
1070
- tool_name: z$1.ZodString;
1071
- arguments: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
1072
- }, z$1.core.$strip>>>;
1073
- tool_results: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1074
- tool_use_id: z$1.ZodString;
1075
- content: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>]>;
1076
- content_blocks: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnknown>>;
1077
- is_error: z$1.ZodOptional<z$1.ZodBoolean>;
1078
- }, z$1.core.$strip>>>;
1079
- }, z$1.core.$strip>;
1080
- type KeptMessage = z$1.infer<typeof KeptMessageSchema>;
1081
- /** Conversation-layer tool blocks (camelCase) → persisted records (snake_case); empty values are omitted. */
1082
- declare function toolUsesToRecords(toolUses?: {
1083
- toolUseId: string;
1084
- toolName: string;
1085
- arguments?: Record<string, unknown>;
1086
- }[]): ToolUseRecord[];
1087
- declare function toolResultsToRecords(toolResults?: ToolResultBlock[]): ToolResultRecord[];
1088
- declare const CompactBoundaryPayloadSchema: z$1.ZodObject<{
1089
- summary: z$1.ZodString;
1090
- keep: z$1.ZodArray<z$1.ZodObject<{
1091
- role: z$1.ZodString;
1092
- content: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>]>;
1093
- tool_uses: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1094
- tool_use_id: z$1.ZodString;
1095
- tool_name: z$1.ZodString;
1096
- arguments: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
1097
- }, z$1.core.$strip>>>;
1098
- tool_results: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1099
- tool_use_id: z$1.ZodString;
1100
- content: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>]>;
1101
- content_blocks: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnknown>>;
1102
- is_error: z$1.ZodOptional<z$1.ZodBoolean>;
1103
- }, z$1.core.$strip>>>;
1104
- }, z$1.core.$strip>>;
1105
- }, z$1.core.$strip>;
1106
- type CompactBoundaryPayload = z$1.infer<typeof CompactBoundaryPayloadSchema>;
1107
- interface SessionInfo {
1108
- id: string;
1109
- firstMessage: string;
1110
- messageCount: number;
1111
- size: number;
1112
- modTime: Date;
1113
- }
1114
- declare function getSessionFilePath(workDir: string, sessionId: string): string;
1115
- declare function newSessionId(): string;
1116
- declare function saveMessage(workDir: string, sessionId: string, msg: SessionMessage): void;
1117
- declare function saveCompactBoundary(workDir: string, sessionId: string, payload: CompactBoundaryPayload): void;
1118
- declare function loadSession(workDir: string, sessionId: string): SessionMessage[];
1119
- interface RestoredMessage {
1120
- role: "user" | "assistant";
1121
- content: string | Record<string, unknown>[];
1122
- toolUses?: {
1123
- toolUseId: string;
1124
- toolName: string;
1125
- arguments?: Record<string, unknown>;
1126
- }[];
1127
- toolResults?: ToolResultBlock[];
1128
- }
1129
- declare function rebuildFromSession(saved: SessionMessage[]): RestoredMessage[];
1130
- declare function listSessions(workDir: string): SessionInfo[];
1131
- /**
1132
- * Cleans up expired sessions: deletes .jsonl files whose last modified time exceeds SESSION_EXPIRY_DAYS.
1133
- * Called during listSessions or on startup to prevent the session directory from growing indefinitely.
1134
- * Silently skips failures (best-effort).
1135
- */
1136
- declare function cleanExpiredSessions(workDir: string): number;
1137
-
1138
- /**
1139
- * Copyright (c) 2026 hangtiancheng
1140
- *
1141
- * Permission is hereby granted, free of charge, to any person obtaining a copy
1142
- * of this software and associated documentation files (the "Software"), to deal
1143
- * in the Software without restriction, including without limitation the rights
1144
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1145
- * copies of the Software, and to permit persons to whom the Software is
1146
- * furnished to do so, subject to the following conditions:
1147
- *
1148
- * The above copyright notice and this permission notice shall be included in
1149
- * all copies or substantial portions of the Software.
1150
- *
1151
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1152
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1153
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1154
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1155
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1156
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1157
- * SOFTWARE.
1158
- */
1159
-
1160
- type AgentEvent = {
1161
- type: "stream_text";
1162
- text: string;
1163
- } | {
1164
- type: "thinking_text";
1165
- text: string;
1166
- } | {
1167
- type: "thinking_complete";
1168
- thinking: string;
1169
- signature: string;
1170
- } | {
1171
- type: "tool_use";
1172
- toolName: string;
1173
- toolId: string;
1174
- args: Record<string, unknown>;
1175
- } | {
1176
- type: "tool_result";
1177
- toolName: string;
1178
- toolId: string;
1179
- output: string;
1180
- contentBlocks?: ToolResultContentBlock[];
1181
- isError: boolean;
1182
- elapsed: number;
1183
- } | {
1184
- type: "turn_complete";
1185
- } | {
1186
- type: "loop_complete";
1187
- stopReason: string;
1188
- } | {
1189
- type: "usage";
1190
- usage: UsageInfo;
1191
- } | {
1192
- type: "error";
1193
- error: Error;
1194
- } | {
1195
- type: "compact";
1196
- message: string;
1197
- boundary?: CompactBoundaryPayload | undefined;
1198
- } | {
1199
- type: "retry";
1200
- reason: string;
1201
- delay: number;
1202
- } | {
1203
- type: "permission_request";
1204
- toolName: string;
1205
- args: Record<string, unknown>;
1206
- };
1329
+ *
1330
+ * The above copyright notice and this permission notice shall be included in
1331
+ * all copies or substantial portions of the Software.
1332
+ *
1333
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1334
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1335
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1336
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1337
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1338
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1339
+ * SOFTWARE.
1340
+ */
1341
+
1342
+ declare class ToolRegistry {
1343
+ private tools;
1344
+ private discovered;
1345
+ /**
1346
+ * How MCP tools are loaded, written by mcp/strategy after connecting to the
1347
+ * server. ToolSearch relies on it to decide what to return, and the client
1348
+ * relies on it to decide whether to send defer_loading. It stays eager when
1349
+ * there is no MCP, which behaves the same as no deferral.
1350
+ */
1351
+ mcpLoadingMode: McpLoadingMode;
1352
+ /**
1353
+ * Whether to expose the search and dispatch tools to the model is computed once
1354
+ * by applyMode in mcp/strategy at session start. It is not recomputed each turn
1355
+ * based on "are there still deferred tools": tools may be disabled at runtime,
1356
+ * and recomputing would drop one from tools[] mid-session — that's an array
1357
+ * change, which breaks the cache prefix just the same.
1358
+ */
1359
+ exposeToolSearch: boolean;
1360
+ exposeMcpCall: boolean;
1361
+ register(tool: Tool): void;
1362
+ get(name: string): Tool | undefined;
1363
+ listTools(): Tool[];
1364
+ getAllSchemas(): ToolSchema[];
1365
+ getAllSchemas(protocol: "anthropic", filter?: (name: string) => boolean): AnthropicToolSchema[];
1366
+ getAllSchemas(protocol: "openai", filter?: (name: string) => boolean): OpenAIResponsesToolSchema[];
1367
+ getAllSchemas(protocol: "openai-compat", filter?: (name: string) => boolean): OpenAICompatToolSchema[];
1368
+ getAllSchemas(protocol: ToolProtocol, filter?: (name: string) => boolean): ProviderToolSchema[];
1369
+ /**
1370
+ * Names of deferred tools not yet discovered, in lexicographic order.
1371
+ *
1372
+ * Sorting is not cosmetic: callers compare this list to detect pool changes;
1373
+ * unstable ordering would produce different text for the same set of tools
1374
+ * and break the comparison.
1375
+ */
1376
+ getDeferredToolNames(): string[];
1377
+ getDeferredTools(): Tool[];
1378
+ searchDeferred(query: string, maxResults?: number): Tool[];
1379
+ findDeferredByNames(names: string[]): Tool[];
1380
+ markDiscovered(name: string): void;
1381
+ isDiscovered(name: string): boolean;
1382
+ }
1207
1383
 
1208
1384
  /**
1209
1385
  * Copyright (c) 2026 hangtiancheng
@@ -1376,98 +1552,16 @@ declare class StreamingExecutor {
1376
1552
  * SOFTWARE.
1377
1553
  */
1378
1554
 
1379
- type CommandType = "local" | "local_ui" | "prompt" | "skill_fork";
1380
- interface CommandContext {
1381
- workDir: string;
1382
- args: string;
1383
- conversation?: unknown;
1384
- registry?: unknown;
1385
- /** Returns the current permission mode */
1386
- permissionMode?: () => string;
1387
- /** Returns token usage [input, output] */
1388
- tokenCount?: () => [number, number];
1389
- /** Returns the number of currently enabled tools */
1390
- toolCount?: () => number;
1391
- /** Returns the list of memories */
1392
- memoryList?: () => string[];
1393
- /** Clears all memories */
1394
- memoryClear?: () => void;
1395
- /** Returns the current model name */
1396
- model?: string;
1397
- /** Returns the current thinking level */
1398
- thinkingLevel?: () => ThinkingLevel;
1399
- /** Sets the thinking level for the active client */
1400
- setThinkingLevel?: (level: ThinkingLevel) => void;
1401
- /** Persists the thinking level to the global config; throws on failure */
1402
- persistThinkingLevel?: (level: ThinkingLevel) => void;
1403
- }
1404
- interface Command {
1405
- name: string;
1406
- aliases: string[];
1407
- type: CommandType;
1408
- description: string;
1409
- handler: (ctx: CommandContext) => string;
1410
- }
1411
- declare class CommandRegistry {
1412
- private commands;
1413
- /** Alias to command name */
1414
- private aliasMap;
1415
- /**
1416
- * Registers a command, checking for name and alias conflicts.
1417
- * The name must not conflict with existing command names or aliases;
1418
- * aliases must not conflict with existing command names or other aliases.
1419
- */
1420
- register(cmd: Command): void;
1421
- /**
1422
- * Checks if a command would conflict with already registered commands.
1423
- * Dynamic loaders (e.g., for user-defined commands) should call this method
1424
- * before `register` to filter out conflicting entries, as `register` throws
1425
- * an exception on conflict.
1426
- */
1427
- hasConflict(cmd: Command): boolean;
1428
- find(name: string): Command | undefined;
1429
- complete(prefix: string): Command[];
1430
- listCommands(): Command[];
1431
- }
1432
- interface Parsed {
1433
- name: string;
1434
- args: string;
1435
- }
1436
- declare function parse(input: string): Parsed | null;
1437
- declare function createDefaultRegistry(): CommandRegistry;
1438
-
1439
- /**
1440
- * Copyright (c) 2026 hangtiancheng
1441
- *
1442
- * Permission is hereby granted, free of charge, to any person obtaining a copy
1443
- * of this software and associated documentation files (the "Software"), to deal
1444
- * in the Software without restriction, including without limitation the rights
1445
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1446
- * copies of the Software, and to permit persons to whom the Software is
1447
- * furnished to do so, subject to the following conditions:
1448
- *
1449
- * The above copyright notice and this permission notice shall be included in
1450
- * all copies or substantial portions of the Software.
1451
- *
1452
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1453
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1454
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1455
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1456
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1457
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1458
- * SOFTWARE.
1459
- */
1460
-
1461
- declare const FileMailMessageSchema: z$1.ZodObject<{
1462
- from: z$1.ZodString;
1463
- text: z$1.ZodString;
1464
- timestamp: z$1.ZodString;
1465
- read: z$1.ZodOptional<z$1.ZodBoolean>;
1466
- type: z$1.ZodOptional<z$1.ZodString>;
1467
- requestId: z$1.ZodOptional<z$1.ZodString>;
1468
- approve: z$1.ZodOptional<z$1.ZodBoolean>;
1469
- }, z$1.core.$strip>;
1470
- type FileMailMessage = z$1.infer<typeof FileMailMessageSchema>;
1555
+ declare const FileMailMessageSchema: z.ZodObject<{
1556
+ from: z.ZodString;
1557
+ text: z.ZodString;
1558
+ timestamp: z.ZodString;
1559
+ read: z.ZodOptional<z.ZodBoolean>;
1560
+ type: z.ZodOptional<z.ZodString>;
1561
+ requestId: z.ZodOptional<z.ZodString>;
1562
+ approve: z.ZodOptional<z.ZodBoolean>;
1563
+ }, z.core.$strip>;
1564
+ type FileMailMessage = z.infer<typeof FileMailMessageSchema>;
1471
1565
  declare class FileMailbox {
1472
1566
  private filePath;
1473
1567
  constructor(dir: string, memberName: string);
@@ -1507,56 +1601,56 @@ declare class FileMailbox {
1507
1601
  * SOFTWARE.
1508
1602
  */
1509
1603
 
1510
- declare const ToolActivitySchema: z.ZodObject<{
1511
- toolName: z.ZodString;
1512
- input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1513
- activityDescription: z.ZodString;
1514
- }, z.core.$strip>;
1515
- type ToolActivity = z.infer<typeof ToolActivitySchema>;
1516
- declare const AgentProgressSchema: z.ZodObject<{
1517
- toolUseCount: z.ZodNumber;
1518
- tokenCount: z.ZodNumber;
1519
- lastActivity: z.ZodOptional<z.ZodObject<{
1520
- toolName: z.ZodString;
1521
- input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1522
- activityDescription: z.ZodString;
1523
- }, z.core.$strip>>;
1524
- recentActivities: z.ZodArray<z.ZodObject<{
1525
- toolName: z.ZodString;
1526
- input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1527
- activityDescription: z.ZodString;
1528
- }, z.core.$strip>>;
1529
- }, z.core.$strip>;
1530
- type AgentProgress = z.infer<typeof AgentProgressSchema>;
1531
- declare const TeammateUIStateSchema: z.ZodObject<{
1532
- name: z.ZodString;
1533
- teamName: z.ZodString;
1534
- status: z.ZodEnum<{
1604
+ declare const ToolActivitySchema: z$1.ZodObject<{
1605
+ toolName: z$1.ZodString;
1606
+ input: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
1607
+ activityDescription: z$1.ZodString;
1608
+ }, z$1.core.$strip>;
1609
+ type ToolActivity = z$1.infer<typeof ToolActivitySchema>;
1610
+ declare const AgentProgressSchema: z$1.ZodObject<{
1611
+ toolUseCount: z$1.ZodNumber;
1612
+ tokenCount: z$1.ZodNumber;
1613
+ lastActivity: z$1.ZodOptional<z$1.ZodObject<{
1614
+ toolName: z$1.ZodString;
1615
+ input: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
1616
+ activityDescription: z$1.ZodString;
1617
+ }, z$1.core.$strip>>;
1618
+ recentActivities: z$1.ZodArray<z$1.ZodObject<{
1619
+ toolName: z$1.ZodString;
1620
+ input: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
1621
+ activityDescription: z$1.ZodString;
1622
+ }, z$1.core.$strip>>;
1623
+ }, z$1.core.$strip>;
1624
+ type AgentProgress = z$1.infer<typeof AgentProgressSchema>;
1625
+ declare const TeammateUIStateSchema: z$1.ZodObject<{
1626
+ name: z$1.ZodString;
1627
+ teamName: z$1.ZodString;
1628
+ status: z$1.ZodEnum<{
1535
1629
  completed: "completed";
1536
1630
  failed: "failed";
1537
1631
  running: "running";
1538
1632
  idle: "idle";
1539
1633
  stopped: "stopped";
1540
1634
  }>;
1541
- progress: z.ZodObject<{
1542
- toolUseCount: z.ZodNumber;
1543
- tokenCount: z.ZodNumber;
1544
- lastActivity: z.ZodOptional<z.ZodObject<{
1545
- toolName: z.ZodString;
1546
- input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1547
- activityDescription: z.ZodString;
1548
- }, z.core.$strip>>;
1549
- recentActivities: z.ZodArray<z.ZodObject<{
1550
- toolName: z.ZodString;
1551
- input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1552
- activityDescription: z.ZodString;
1553
- }, z.core.$strip>>;
1554
- }, z.core.$strip>;
1555
- startTime: z.ZodNumber;
1556
- spinnerVerb: z.ZodString;
1557
- lastMessage: z.ZodOptional<z.ZodString>;
1558
- }, z.core.$strip>;
1559
- type TeammateUIState = z.infer<typeof TeammateUIStateSchema>;
1635
+ progress: z$1.ZodObject<{
1636
+ toolUseCount: z$1.ZodNumber;
1637
+ tokenCount: z$1.ZodNumber;
1638
+ lastActivity: z$1.ZodOptional<z$1.ZodObject<{
1639
+ toolName: z$1.ZodString;
1640
+ input: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
1641
+ activityDescription: z$1.ZodString;
1642
+ }, z$1.core.$strip>>;
1643
+ recentActivities: z$1.ZodArray<z$1.ZodObject<{
1644
+ toolName: z$1.ZodString;
1645
+ input: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
1646
+ activityDescription: z$1.ZodString;
1647
+ }, z$1.core.$strip>>;
1648
+ }, z$1.core.$strip>;
1649
+ startTime: z$1.ZodNumber;
1650
+ spinnerVerb: z$1.ZodString;
1651
+ lastMessage: z$1.ZodOptional<z$1.ZodString>;
1652
+ }, z$1.core.$strip>;
1653
+ type TeammateUIState = z$1.infer<typeof TeammateUIStateSchema>;
1560
1654
  declare function createProgress(): AgentProgress;
1561
1655
  declare function recordToolUse(p: AgentProgress, toolName: string, input: Record<string, unknown>): void;
1562
1656
  declare function recordTokens(p: AgentProgress, inputTokens: number, outputTokens: number): void;
@@ -1655,17 +1749,17 @@ declare class SharedTaskStore {
1655
1749
  * three-state semantics: absent means just registered and not yet started,
1656
1750
  * true means actively running, false means idle.
1657
1751
  */
1658
- declare const TeamMemberEntrySchema: z$1.ZodObject<{
1659
- agentId: z$1.ZodString;
1660
- name: z$1.ZodString;
1661
- agentType: z$1.ZodOptional<z$1.ZodString>;
1662
- model: z$1.ZodOptional<z$1.ZodString>;
1663
- joinedAt: z$1.ZodNumber;
1664
- worktreePath: z$1.ZodOptional<z$1.ZodString>;
1665
- backendType: z$1.ZodOptional<z$1.ZodString>;
1666
- isActive: z$1.ZodOptional<z$1.ZodBoolean>;
1667
- }, z$1.core.$strip>;
1668
- type TeamMemberEntry = z$1.infer<typeof TeamMemberEntrySchema>;
1752
+ declare const TeamMemberEntrySchema: z.ZodObject<{
1753
+ agentId: z.ZodString;
1754
+ name: z.ZodString;
1755
+ agentType: z.ZodOptional<z.ZodString>;
1756
+ model: z.ZodOptional<z.ZodString>;
1757
+ joinedAt: z.ZodNumber;
1758
+ worktreePath: z.ZodOptional<z.ZodString>;
1759
+ backendType: z.ZodOptional<z.ZodString>;
1760
+ isActive: z.ZodOptional<z.ZodBoolean>;
1761
+ }, z.core.$strip>;
1762
+ type TeamMemberEntry = z.infer<typeof TeamMemberEntrySchema>;
1669
1763
  /**
1670
1764
  * On-disk representation of team configuration, stored at <teamsBaseDir>/<slug>/config.json.
1671
1765
  *
@@ -1677,23 +1771,23 @@ type TeamMemberEntry = z$1.infer<typeof TeamMemberEntrySchema>;
1677
1771
  * independent processes that need to know which team they belong to and who their
1678
1772
  * peers are after startup; users restarting Swifty must be able to resume prior teams.
1679
1773
  */
1680
- declare const TeamFileSchema: z$1.ZodObject<{
1681
- name: z$1.ZodString;
1682
- description: z$1.ZodOptional<z$1.ZodString>;
1683
- createdAt: z$1.ZodNumber;
1684
- leadAgentId: z$1.ZodString;
1685
- members: z$1.ZodArray<z$1.ZodObject<{
1686
- agentId: z$1.ZodString;
1687
- name: z$1.ZodString;
1688
- agentType: z$1.ZodOptional<z$1.ZodString>;
1689
- model: z$1.ZodOptional<z$1.ZodString>;
1690
- joinedAt: z$1.ZodNumber;
1691
- worktreePath: z$1.ZodOptional<z$1.ZodString>;
1692
- backendType: z$1.ZodOptional<z$1.ZodString>;
1693
- isActive: z$1.ZodOptional<z$1.ZodBoolean>;
1694
- }, z$1.core.$strip>>;
1695
- }, z$1.core.$strip>;
1696
- type TeamFile = z$1.infer<typeof TeamFileSchema>;
1774
+ declare const TeamFileSchema: z.ZodObject<{
1775
+ name: z.ZodString;
1776
+ description: z.ZodOptional<z.ZodString>;
1777
+ createdAt: z.ZodNumber;
1778
+ leadAgentId: z.ZodString;
1779
+ members: z.ZodArray<z.ZodObject<{
1780
+ agentId: z.ZodString;
1781
+ name: z.ZodString;
1782
+ agentType: z.ZodOptional<z.ZodString>;
1783
+ model: z.ZodOptional<z.ZodString>;
1784
+ joinedAt: z.ZodNumber;
1785
+ worktreePath: z.ZodOptional<z.ZodString>;
1786
+ backendType: z.ZodOptional<z.ZodString>;
1787
+ isActive: z.ZodOptional<z.ZodBoolean>;
1788
+ }, z.core.$strip>>;
1789
+ }, z.core.$strip>;
1790
+ type TeamFile = z.infer<typeof TeamFileSchema>;
1697
1791
  /**
1698
1792
  * Root directory for all team data. Placed under the user's home directory rather than
1699
1793
  * the project directory because pane teammates are independent processes whose working
@@ -1916,37 +2010,37 @@ declare class TeamManager {
1916
2010
  * SOFTWARE.
1917
2011
  */
1918
2012
 
1919
- declare const CodeReviewMemberSchema: z$1.ZodObject<{
1920
- name: z$1.ZodString;
1921
- email: z$1.ZodString;
1922
- role: z$1.ZodEnum<{
2013
+ declare const CodeReviewMemberSchema: z.ZodObject<{
2014
+ name: z.ZodString;
2015
+ email: z.ZodString;
2016
+ role: z.ZodEnum<{
1923
2017
  lead: "lead";
1924
2018
  reviewer: "reviewer";
1925
2019
  junior: "junior";
1926
2020
  critic: "critic";
1927
2021
  }>;
1928
- expertise: z$1.ZodArray<z$1.ZodString>;
1929
- active: z$1.ZodBoolean;
1930
- }, z$1.core.$strip>;
1931
- type CodeReviewMember = z$1.infer<typeof CodeReviewMemberSchema>;
1932
- declare const CodeReviewTeamSchema: z$1.ZodObject<{
1933
- name: z$1.ZodString;
1934
- members: z$1.ZodArray<z$1.ZodObject<{
1935
- name: z$1.ZodString;
1936
- email: z$1.ZodString;
1937
- role: z$1.ZodEnum<{
2022
+ expertise: z.ZodArray<z.ZodString>;
2023
+ active: z.ZodBoolean;
2024
+ }, z.core.$strip>;
2025
+ type CodeReviewMember = z.infer<typeof CodeReviewMemberSchema>;
2026
+ declare const CodeReviewTeamSchema: z.ZodObject<{
2027
+ name: z.ZodString;
2028
+ members: z.ZodArray<z.ZodObject<{
2029
+ name: z.ZodString;
2030
+ email: z.ZodString;
2031
+ role: z.ZodEnum<{
1938
2032
  lead: "lead";
1939
2033
  reviewer: "reviewer";
1940
2034
  junior: "junior";
1941
2035
  critic: "critic";
1942
2036
  }>;
1943
- expertise: z$1.ZodArray<z$1.ZodString>;
1944
- active: z$1.ZodBoolean;
1945
- }, z$1.core.$strip>>;
1946
- createdAt: z$1.ZodString;
1947
- lastActive: z$1.ZodString;
1948
- }, z$1.core.$strip>;
1949
- type CodeReviewTeam = z$1.infer<typeof CodeReviewTeamSchema>;
2037
+ expertise: z.ZodArray<z.ZodString>;
2038
+ active: z.ZodBoolean;
2039
+ }, z.core.$strip>>;
2040
+ createdAt: z.ZodString;
2041
+ lastActive: z.ZodString;
2042
+ }, z.core.$strip>;
2043
+ type CodeReviewTeam = z.infer<typeof CodeReviewTeamSchema>;
1950
2044
  declare class CodeReviewManager {
1951
2045
  private teams;
1952
2046
  private configPath;
@@ -2058,29 +2152,115 @@ interface CommentIssue {
2058
2152
  resolution: CommentResolution;
2059
2153
  authorResponse?: string;
2060
2154
  }
2061
- declare class ReviewSession {
2062
- private requests;
2063
- private manager;
2064
- private workDir;
2065
- private commentCounter;
2066
- constructor(workDir: string, manager: CodeReviewManager);
2067
- private getCritics;
2068
- private loadRequests;
2069
- createReviewRequest(teamName: string, title: string, description: string, author: string, branch: string, files: string[]): ReviewRequest;
2070
- getRequest(id: string): ReviewRequest | undefined;
2071
- updateRequestStatus(id: string, status: ReviewRequest["status"]): void;
2072
- addComment(requestId: string, reviewer: string, content: string, file?: string, line?: number): ReviewComment;
2073
- resolveComment(requestId: string, commentId: string): void;
2074
- acceptComment(requestId: string, commentId: string, authorResponse?: string): void;
2075
- rejectComment(requestId: string, commentId: string, authorResponse?: string): void;
2076
- addCriticAssessment(requestId: string, commentId: string, critic: string, evaluation: CriticEvaluation, reasoning: string): CriticAssessment;
2077
- evaluateCommentByCritic(requestId: string, commentId: string, criticName: string, isReasonable: boolean, reasoning: string): CriticAssessment;
2078
- getCriticSummary(requestId: string): string;
2079
- generateFinalReport(requestId: string): ReviewSummary;
2080
- formatFinalReport(summary: ReviewSummary): string;
2081
- getPendingRequests(): ReviewRequest[];
2082
- getRequestSummary(id: string): string;
2155
+ declare class ReviewSession {
2156
+ private requests;
2157
+ private manager;
2158
+ private workDir;
2159
+ private commentCounter;
2160
+ constructor(workDir: string, manager: CodeReviewManager);
2161
+ private getCritics;
2162
+ private loadRequests;
2163
+ createReviewRequest(teamName: string, title: string, description: string, author: string, branch: string, files: string[]): ReviewRequest;
2164
+ getRequest(id: string): ReviewRequest | undefined;
2165
+ updateRequestStatus(id: string, status: ReviewRequest["status"]): void;
2166
+ addComment(requestId: string, reviewer: string, content: string, file?: string, line?: number): ReviewComment;
2167
+ resolveComment(requestId: string, commentId: string): void;
2168
+ acceptComment(requestId: string, commentId: string, authorResponse?: string): void;
2169
+ rejectComment(requestId: string, commentId: string, authorResponse?: string): void;
2170
+ addCriticAssessment(requestId: string, commentId: string, critic: string, evaluation: CriticEvaluation, reasoning: string): CriticAssessment;
2171
+ evaluateCommentByCritic(requestId: string, commentId: string, criticName: string, isReasonable: boolean, reasoning: string): CriticAssessment;
2172
+ getCriticSummary(requestId: string): string;
2173
+ generateFinalReport(requestId: string): ReviewSummary;
2174
+ formatFinalReport(summary: ReviewSummary): string;
2175
+ getPendingRequests(): ReviewRequest[];
2176
+ getRequestSummary(id: string): string;
2177
+ }
2178
+
2179
+ /**
2180
+ * Copyright (c) 2026 hangtiancheng
2181
+ *
2182
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
2183
+ * of this software and associated documentation files (the "Software"), to deal
2184
+ * in the Software without restriction, including without limitation the rights
2185
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2186
+ * copies of the Software, and to permit persons to whom the Software is
2187
+ * furnished to do so, subject to the following conditions:
2188
+ *
2189
+ * The above copyright notice and this permission notice shall be included in
2190
+ * all copies or substantial portions of the Software.
2191
+ *
2192
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2193
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2194
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2195
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2196
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2197
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2198
+ * SOFTWARE.
2199
+ */
2200
+
2201
+ type CommandType = "local" | "local_ui" | "prompt" | "skill_fork";
2202
+ interface CommandContext {
2203
+ workDir: string;
2204
+ args: string;
2205
+ conversation?: unknown;
2206
+ registry?: unknown;
2207
+ /** Returns the current permission mode */
2208
+ permissionMode?: () => string;
2209
+ /** Returns token usage [input, output] */
2210
+ tokenCount?: () => [number, number];
2211
+ /** Returns the number of currently enabled tools */
2212
+ toolCount?: () => number;
2213
+ /** Returns the list of memories */
2214
+ memoryList?: () => string[];
2215
+ /** Clears all memories */
2216
+ memoryClear?: () => void;
2217
+ /** Returns the current model name */
2218
+ model?: string;
2219
+ /** Returns the current effective thinking level */
2220
+ thinkingLevel?: () => ThinkingLevel;
2221
+ /** Returns the active client's available logical thinking levels */
2222
+ availableThinkingLevels?: () => readonly ThinkingLevel[];
2223
+ /** Sets the thinking level for the active client */
2224
+ setThinkingLevel?: (level: ThinkingLevel) => void;
2225
+ /** Persists the thinking level to the global config; throws on failure */
2226
+ persistThinkingLevel?: (level: ThinkingLevel) => void;
2227
+ }
2228
+ interface Command {
2229
+ name: string;
2230
+ aliases: string[];
2231
+ type: CommandType;
2232
+ description: string;
2233
+ handler: (ctx: CommandContext) => string;
2234
+ /** Skill-derived commands; excluded from the /help listing (see /skills). */
2235
+ isSkill?: boolean;
2236
+ }
2237
+ declare class CommandRegistry {
2238
+ private commands;
2239
+ /** Alias to command name */
2240
+ private aliasMap;
2241
+ /**
2242
+ * Registers a command, checking for name and alias conflicts.
2243
+ * The name must not conflict with existing command names or aliases;
2244
+ * aliases must not conflict with existing command names or other aliases.
2245
+ */
2246
+ register(cmd: Command): void;
2247
+ /**
2248
+ * Checks if a command would conflict with already registered commands.
2249
+ * Dynamic loaders (e.g., for user-defined commands) should call this method
2250
+ * before `register` to filter out conflicting entries, as `register` throws
2251
+ * an exception on conflict.
2252
+ */
2253
+ hasConflict(cmd: Command): boolean;
2254
+ find(name: string): Command | undefined;
2255
+ complete(prefix: string): Command[];
2256
+ listCommands(): Command[];
2257
+ }
2258
+ interface Parsed {
2259
+ name: string;
2260
+ args: string;
2083
2261
  }
2262
+ declare function parse(input: string): Parsed | null;
2263
+ declare function createDefaultRegistry(): CommandRegistry;
2084
2264
 
2085
2265
  /**
2086
2266
  * Copyright (c) 2026 hangtiancheng
@@ -2202,8 +2382,8 @@ declare function estimateMessages(messages: Message[]): number;
2202
2382
  declare function estimateTokens(conv: ConversationManager): number;
2203
2383
  declare function computeKeepStartIndex(messages: Message[]): number;
2204
2384
  declare function currentContextTokens(conv: ConversationManager, anchor?: UsageAnchor): number;
2205
- declare function manageContext(conv: ConversationManager, client: LLMClient, contextWindow: number, maxOutput: number, trackingState: AutoCompactTrackingState, recoveryState: RecoveryState | null, toolSchemaNames: string[], toolSchemas: ToolSchema[], sessionFilePath?: string, abortSignal?: AbortSignal): Promise<CompactResult>;
2206
- declare function forceCompact(conv: ConversationManager, client: LLMClient, recoveryState: RecoveryState | null, toolSchemaNames: string[], toolSchemas: ToolSchema[], sessionFilePath?: string, abortSignal?: AbortSignal): Promise<CompactResult>;
2385
+ declare function manageContext(conv: ConversationManager, client: LLMClient, contextWindow: number, maxOutput: number, trackingState: AutoCompactTrackingState, recoveryState: RecoveryState | null, toolSchemaNames: string[], toolSchemas: ProviderToolSchema[], sessionFilePath?: string, abortSignal?: AbortSignal): Promise<CompactResult>;
2386
+ declare function forceCompact(conv: ConversationManager, client: LLMClient, recoveryState: RecoveryState | null, toolSchemaNames: string[], toolSchemas: ProviderToolSchema[], sessionFilePath?: string, abortSignal?: AbortSignal, customInstructions?: string): Promise<CompactResult>;
2207
2387
 
2208
2388
  /**
2209
2389
  * Copyright (c) 2026 hangtiancheng
@@ -2296,6 +2476,27 @@ declare const MAX_HISTORY_ENTRIES = 200;
2296
2476
  declare function load(dir: string): string[];
2297
2477
  declare function append(dir: string, text: string): string[];
2298
2478
 
2479
+ /**
2480
+ * Copyright (c) 2026 hangtiancheng
2481
+ *
2482
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
2483
+ * of this software and associated documentation files (the "Software"), to deal
2484
+ * in the Software without restriction, including without limitation the rights
2485
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2486
+ * copies of the Software, and to permit persons to whom the Software is
2487
+ * furnished to do so, subject to the following conditions:
2488
+ *
2489
+ * The above copyright notice and this permission notice shall be included in
2490
+ * all copies or substantial portions of the Software.
2491
+ *
2492
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2493
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2494
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2495
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2496
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2497
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2498
+ * SOFTWARE.
2499
+ */
2299
2500
  type SaveClipboardImageResult = {
2300
2501
  ok: true;
2301
2502
  value: string;
@@ -2480,7 +2681,7 @@ declare function closeLogger(): void;
2480
2681
  /**
2481
2682
  * Global logger export. Modules can import and use it at file top level:
2482
2683
  * ```ts
2483
- * import { logger } from "../logger/logger.js";
2684
+ * import { logger } from "@/logger/logger.js";
2484
2685
  * logger.warn({ module: "app" }, "something looks off");
2485
2686
  * ```
2486
2687
  * Before initLogger(), calls fall back to the silent target (pre-init logs
@@ -2617,25 +2818,6 @@ declare class MCPManager {
2617
2818
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2618
2819
  * SOFTWARE.
2619
2820
  */
2620
- /**
2621
- * Decides how MCP tools enter the context. Three modes, chosen once at session start
2622
- * right after MCP connects:
2623
- *
2624
- * eager Total schema size is under one tenth of the context window, so load
2625
- * everything into tools[] with no deferral. The context saved is not worth
2626
- * taking on any extra risk for.
2627
- * native Official Anthropic endpoints. Tools stay in tools[] with defer_loading but
2628
- * the server hides them from the model; ToolSearch returns tool_reference and
2629
- * the server expands the schema.
2630
- * dispatch Other endpoints (domestic vendors, various proxy gateways) support neither
2631
- * of the above, so we simulate it ourselves: MCP tools never enter tools[] and
2632
- * everything goes through the single McpCall entry point.
2633
- *
2634
- * Why three modes: tools is rendered after system and before messages, so any change to
2635
- * the array invalidates the prompt cache for the entire conversation history that follows.
2636
- * Measured with a 20k-token history, appending one tool to the end of tools drops the
2637
- * cache hit rate from 99.4% to 9.5%, effectively recomputing the whole history.
2638
- */
2639
2821
 
2640
2822
  /** Below this share of the context window, skip deferral and load everything eagerly. */
2641
2823
  declare const DEFAULT_EAGER_THRESHOLD_PERCENT = 10;
@@ -2985,6 +3167,27 @@ declare function parsePrintFlags(args: string[]): PrintArgs | null;
2985
3167
  */
2986
3168
  declare function runPrintMode(args: PrintArgs): Promise<void>;
2987
3169
 
3170
+ /**
3171
+ * Copyright (c) 2026 hangtiancheng
3172
+ *
3173
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
3174
+ * of this software and associated documentation files (the "Software"), to deal
3175
+ * in the Software without restriction, including without limitation the rights
3176
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3177
+ * copies of the Software, and to permit persons to whom the Software is
3178
+ * furnished to do so, subject to the following conditions:
3179
+ *
3180
+ * The above copyright notice and this permission notice shall be included in
3181
+ * all copies or substantial portions of the Software.
3182
+ *
3183
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3184
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3185
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3186
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3187
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3188
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3189
+ * SOFTWARE.
3190
+ */
2988
3191
  /**
2989
3192
  * Appends a timestamped entry to the crash log.
2990
3193
  * Write failures are silently ignored so diagnostics never crash the process.
@@ -3143,11 +3346,8 @@ declare function parseSkillFile(content: string): {
3143
3346
  body: string;
3144
3347
  frontmatter: Record<string, unknown>;
3145
3348
  } | null;
3146
- /**
3147
- * Build the Skill listing for the system prompt: only names and one-line
3148
- * descriptions are included; the full SOP is fetched on demand via LoadSkill.
3149
- * Returns an empty string when the catalog is empty so callers can skip this section.
3150
- */
3349
+ declare function escapeSkillXml(text: string): string;
3350
+ /** Metadata-only conversation reminder; bodies load on demand without changing the system prefix. */
3151
3351
  declare function buildSkillSection(catalog: SkillCatalog, workDir: string): string;
3152
3352
 
3153
3353
  /**
@@ -3172,21 +3372,21 @@ declare function buildSkillSection(catalog: SkillCatalog, workDir: string): stri
3172
3372
  * SOFTWARE.
3173
3373
  */
3174
3374
 
3175
- declare const QuestionOptionSchema: z.ZodObject<{
3176
- label: z.ZodString;
3177
- description: z.ZodOptional<z.ZodString>;
3178
- }, z.core.$strip>;
3179
- type QuestionOption = z.infer<typeof QuestionOptionSchema>;
3180
- declare const QuestionSchema: z.ZodObject<{
3181
- question: z.ZodString;
3182
- header: z.ZodString;
3183
- options: z.ZodArray<z.ZodObject<{
3184
- label: z.ZodString;
3185
- description: z.ZodOptional<z.ZodString>;
3186
- }, z.core.$strip>>;
3187
- multiSelect: z.ZodBoolean;
3188
- }, z.core.$strip>;
3189
- type Question = z.infer<typeof QuestionSchema>;
3375
+ declare const QuestionOptionSchema: z$1.ZodObject<{
3376
+ label: z$1.ZodString;
3377
+ description: z$1.ZodOptional<z$1.ZodString>;
3378
+ }, z$1.core.$strip>;
3379
+ type QuestionOption = z$1.infer<typeof QuestionOptionSchema>;
3380
+ declare const QuestionSchema: z$1.ZodObject<{
3381
+ question: z$1.ZodString;
3382
+ header: z$1.ZodString;
3383
+ options: z$1.ZodArray<z$1.ZodObject<{
3384
+ label: z$1.ZodString;
3385
+ description: z$1.ZodOptional<z$1.ZodString>;
3386
+ }, z$1.core.$strip>>;
3387
+ multiSelect: z$1.ZodBoolean;
3388
+ }, z$1.core.$strip>;
3389
+ type Question = z$1.infer<typeof QuestionSchema>;
3190
3390
  type Asker = (questions: Question[]) => Promise<Record<string /** question text */, string /** user chosen answer */>>;
3191
3391
  declare class AskUserQuestionTool implements Tool {
3192
3392
  private ask;
@@ -3490,19 +3690,7 @@ declare function buildSystemPrompt(env: EnvironmentContext): string;
3490
3690
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3491
3691
  * SOFTWARE.
3492
3692
  */
3493
- /**
3494
- * Returns the coordinator-mode orchestration guidance, injected as a system-reminder each turn.
3495
- * The first turn sends the full text; subsequent turns send the condensed version: this guidance
3496
- * is just over 8 KB, and system-reminders are appended incrementally — re-sending the full text
3497
- * every turn would fill back up the context window that this mode is designed to save.
3498
- *
3499
- * There are two reasons this is not made a system-prompt paragraph: first, the model drifts in
3500
- * long conversations — the system prompt appears only once at the beginning, and by turn twenty
3501
- * those hard constraints are long buried; appending once per turn is what pulls them back.
3502
- * Second, the system prompt belongs to the cached prefix — modifying it invalidates billing for
3503
- * all subsequent content, whereas a system-reminder is a plain message appended at the end of
3504
- * the conversation.
3505
- */
3693
+ /** Periodic conversation reminders preserve guidance without changing the cached system prefix. */
3506
3694
  declare function coordinatorReminder(iteration?: number): string;
3507
3695
 
3508
3696
  /**
@@ -3676,13 +3864,15 @@ declare class SeatbeltSandbox implements Sandbox {
3676
3864
  * SOFTWARE.
3677
3865
  */
3678
3866
 
3679
- /**
3680
- * Runs a skill in inline mode: injects the skill body into the current conversation context.
3681
- */
3867
+ declare function parseSkillPrompt(prompt: string): {
3868
+ name: string;
3869
+ directory: string;
3870
+ body: string;
3871
+ args: string;
3872
+ } | undefined;
3873
+ /** Activate once through the host so its existing skill cache and permissions remain authoritative. */
3682
3874
  declare function runInline(skill: Skill, args: string, host: SkillHost): string;
3683
- /**
3684
- * Runs a skill in fork mode: executes it in an isolated subagent.
3685
- */
3875
+ /** Runs a skill in an isolated subagent and returns its result unchanged. */
3686
3876
  declare function runFork(skill: Skill, args: string, host: SkillForkHost): Promise<string>;
3687
3877
 
3688
3878
  /**
@@ -3997,7 +4187,8 @@ declare class TaskManager {
3997
4187
  * SOFTWARE.
3998
4188
  */
3999
4189
 
4000
- type AllTools = "InstallSkill" | "LoadSkill" | "Agent" | "TaskStop" | "TaskCreate" | "TaskGet" | "TaskList" | "TaskUpdate" | "TeamCreate" | "SpawnTeammate" | "SendMessage" | "ListTeams" | "TeamDelete" | "SyntheticOutput" | "AskUserQuestion" | "Bash" | "PowerShell" | "EditFile" | "EnterWorktree" | "ExitPlanMode" | "ExitWorktree" | "ReadFile" | "ToolSearch" | "WriteFile" | "Glob" | "Grep" | "McpCall";
4190
+ type AllTools = "InstallSkill" | "LoadSkill" | "Agent" | "TaskStop" | "TaskCreate" | "TaskGet" | "TaskList" | "TaskUpdate" | "TeamCreate" | "SpawnTeammate" | "SendMessage" | "ListTeams" | "TeamDelete" | "SyntheticOutput" | "AskUserQuestion" | "Bash" | "PowerShell" | "ComputerUse" | "EditFile" | "EnterWorktree" | "ExitPlanMode" | "ExitWorktree" | "ReadFile" | "ToolSearch" | "WriteFile" | "Glob" | "Grep" | "McpCall";
4191
+ declare const MAIN_AGENT_ONLY_TOOLS: Set<AllTools>;
4001
4192
  declare const SUBAGENT_DISALLOWED_TOOLS: Set<AllTools>;
4002
4193
  declare const TEAMMATE_DISALLOWED_TOOLS: Set<AllTools>;
4003
4194
  declare const CUSTOM_AGENT_DISALLOWED_TOOLS: Set<AllTools>;
@@ -4358,21 +4549,21 @@ declare class TeamDeleteTool implements Tool {
4358
4549
  * SOFTWARE.
4359
4550
  */
4360
4551
 
4361
- declare const TranscriptEntrySchema: z$1.ZodObject<{
4362
- role: z$1.ZodString;
4363
- content: z$1.ZodOptional<z$1.ZodString>;
4364
- tool_uses: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
4365
- tool_use_id: z$1.ZodString;
4366
- tool_name: z$1.ZodString;
4367
- arguments: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
4368
- }, z$1.core.$strip>>>;
4369
- tool_results: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
4370
- tool_use_id: z$1.ZodString;
4371
- content: z$1.ZodString;
4372
- is_error: z$1.ZodOptional<z$1.ZodBoolean>;
4373
- }, z$1.core.$strip>>>;
4374
- }, z$1.core.$strip>;
4375
- type TranscriptEntry = z$1.infer<typeof TranscriptEntrySchema>;
4552
+ declare const TranscriptEntrySchema: z.ZodObject<{
4553
+ role: z.ZodString;
4554
+ content: z.ZodOptional<z.ZodString>;
4555
+ tool_uses: z.ZodOptional<z.ZodArray<z.ZodObject<{
4556
+ tool_use_id: z.ZodString;
4557
+ tool_name: z.ZodString;
4558
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4559
+ }, z.core.$strip>>>;
4560
+ tool_results: z.ZodOptional<z.ZodArray<z.ZodObject<{
4561
+ tool_use_id: z.ZodString;
4562
+ content: z.ZodString;
4563
+ is_error: z.ZodOptional<z.ZodBoolean>;
4564
+ }, z.core.$strip>>>;
4565
+ }, z.core.$strip>;
4566
+ type TranscriptEntry = z.infer<typeof TranscriptEntrySchema>;
4376
4567
  /**
4377
4568
  * Persists a teammate's conversation history to disk for debugging and troubleshooting.
4378
4569
  * File path: .swifty/teams/{team}/transcripts/{agentId}.json
@@ -4482,6 +4673,69 @@ declare class BashTool implements Tool {
4482
4673
  execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
4483
4674
  }
4484
4675
 
4676
+ type ComputerUseEnvironment = "windows" | "mac" | "browser" | "linux" | "ubuntu";
4677
+ interface CommandResult {
4678
+ code: number;
4679
+ stdout: Buffer;
4680
+ stderr: string;
4681
+ }
4682
+ interface CommandOptions {
4683
+ env?: NodeJS.ProcessEnv;
4684
+ maxOutputBytes?: number;
4685
+ signal?: AbortSignal;
4686
+ timeoutMs?: number;
4687
+ }
4688
+ type CommandRunner = (command: string, args: readonly string[], options?: CommandOptions) => Promise<CommandResult>;
4689
+ interface ComputerUseToolOptions {
4690
+ displayHeightPx?: number;
4691
+ displayNumber?: number;
4692
+ displayWidthPx?: number;
4693
+ enableZoom?: boolean;
4694
+ environment?: ComputerUseEnvironment;
4695
+ platform?: NodeJS.Platform;
4696
+ runCommand?: CommandRunner;
4697
+ }
4698
+ declare class ComputerUseTool implements Tool {
4699
+ name: string;
4700
+ description: string;
4701
+ category: ToolCategory;
4702
+ deferred: boolean;
4703
+ private readonly displayHeightPx;
4704
+ private readonly displayNumber?;
4705
+ private readonly displayWidthPx;
4706
+ private readonly enableZoom;
4707
+ private readonly environment;
4708
+ private readonly platform;
4709
+ private readonly run;
4710
+ private coordinateScaleX;
4711
+ private coordinateScaleY;
4712
+ private macHelperPromise?;
4713
+ constructor(options?: ComputerUseToolOptions);
4714
+ isConcurrencySafe(_args: Record<string, unknown>): boolean;
4715
+ providerSchema(protocol: ToolProtocol): ProviderNativeToolSchema | undefined;
4716
+ schema(): ToolSchema;
4717
+ execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
4718
+ /** Execute one Anthropic-style action (also the per-item path for batches). */
4719
+ private runSingle;
4720
+ /**
4721
+ * Execute an OpenAI-style ordered action batch. Per the OpenAI computer
4722
+ * output contract, the result always carries the screenshot taken after the
4723
+ * batch ran, and status / safety checks are echoed so the model can continue.
4724
+ */
4725
+ private executeBatch;
4726
+ private toNativeCoordinates;
4727
+ private executeNative;
4728
+ private executeMac;
4729
+ private runMacPayload;
4730
+ private getMacHelper;
4731
+ private compileMacHelper;
4732
+ private executeWindows;
4733
+ private executeLinux;
4734
+ private screenshot;
4735
+ private imageResult;
4736
+ private captureScreenshot;
4737
+ }
4738
+
4485
4739
  /**
4486
4740
  * Copyright (c) 2026 hangtiancheng
4487
4741
  *
@@ -4503,13 +4757,13 @@ declare class BashTool implements Tool {
4503
4757
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4504
4758
  * SOFTWARE.
4505
4759
  */
4506
- declare const BASH_DESCRIPTION = "\nExecute a shell command and return stdout and stderr.\n\nOn Windows, prefer the PowerShell tool over Bash for shell commands.\n\nIMPORTANT: Avoid using this tool to run cat, head, tail, sed, awk or echo commands. Instead use the dedicated ReadFile, EditFile, or WriteFile tools which provide a better experience.\n\nUsage Notes\n\n- Each call starts in the Agent's working directory with a fresh shell. Changes made by cd, variables, functions, and shell options do not persist to the next call.\n- Always quote file paths containing spaces with double quotes.\n- To run in a subdirectory, use cd with a quoted path followed by && and the command in the same call.\n- Optional timeout in seconds (max 600s). Default 120s.\n- When issuing multiple independent commands, make separate tool calls instead of chaining with &&.\n- Use && to chain sequential dependent commands. Use ; only when you don't care if earlier commands failed.\n\nGit Safety Protocol\n\n- NEVER run destructive git commands (push --force, reset --hard, checkout ., clean -f, branch -D) unless the user explicitly requests it.\n- NEVER skip hooks (--no-verify) unless the user explicitly requests it.\n- Prefer creating a new commit rather than amending an existing one.\n- Commit identity: adds a header: Co-Authored-By: Swifty <usr161043261@outlook.com>\n\nAvoiding unnecessary sleep commands. Do NOT retry failing commands in a sleep loop -- diagnose the root cause instead.\nWhen using find, search from \".\" or a specific path, not \"/\" -- scanning the full filesystem is too expensive.\n";
4507
- declare const POWERSHELL_DESCRIPTION = "\nExecute a PowerShell command and return stdout and stderr.\n\nThis is the RECOMMENDED shell tool on Windows -- prefer it over Bash there. It runs powershell.exe on Windows and pwsh (PowerShell Core) on other platforms.\n\nIMPORTANT: Avoid using this tool to run Get-Content, Select-String, or Write-Output/echo commands. Instead use the dedicated ReadFile, EditFile, or WriteFile tools which provide a better experience.\n\nUsage Notes\n\n- Each call starts in the Agent's working directory with a fresh shell. Set-Location, variables, and shell options do not persist to the next call.\n- Always quote file paths containing spaces with double quotes.\n- To run in a subdirectory, use Set-Location -LiteralPath with a quoted path in the same call.\n- Optional timeout in seconds (max 600s). Default 120s.\n- When issuing multiple independent commands, make separate tool calls instead of chaining with ;.\n- A semicolon does not stop after failure. Check $LASTEXITCODE after native commands and use -ErrorAction Stop for dependent cmdlets. Do not assume PowerShell 7 syntax is available on Windows PowerShell.\n\nGit Safety Protocol\n\n- NEVER run destructive git commands (push --force, reset --hard, checkout ., clean -f, branch -D) unless the user explicitly requests it.\n- NEVER skip hooks (--no-verify) unless the user explicitly requests it.\n- Prefer creating a new commit rather than amending an existing one.\n- Commit identity: adds a header: Co-Authored-By: Swifty <usr161043261@outlook.com>\n\nAvoiding unnecessary Start-Sleep commands. Do NOT retry failing commands in a sleep loop -- diagnose the root cause instead.\nWhen using Get-ChildItem -Recurse, search from \".\" or a specific path, not the drive root -- scanning the full filesystem is too expensive.\n";
4508
- declare const READ_FILE_DESCRIPTION = "\nRead a file and return its contents with line numbers.\n\nUsage Notes\n\n- file_path may be absolute or relative to the Agent's working directory.\n- By default reads up to 2000 lines from the beginning of the file.\n- offset is the number of lines to skip (0-based); limit is the maximum number of lines to return. To start at displayed line 101, use offset=100. Only read what you need.\n- Results are returned with line numbers (1-based) for easy reference.\n- This tool reads files, not directories. Use Glob to find files and Grep to locate relevant lines.\n- Large output may be saved to a readback file. Follow the returned path or request a narrower range when more content is needed.\n- A successful read refreshes the file state used by EditFile and WriteFile. If a write reports that a file changed externally, read it again before retrying.\n- This tool can read image files (png, jpg, jpeg, gif, webp). Image contents are returned as visual content for multimodal analysis. Line numbers and offset/limit parameters do NOT apply to image files.\n";
4509
- declare const EDIT_FILE_DESCRIPTION = "\nReplace an exact text string in an existing file and return a diff of the change.\n\nUsage Notes\n\n- You MUST read the file with ReadFile before editing, this tool will fail otherwise.\n- Preserve exact whitespace and indentation from the file; exclude ReadFile's line-number prefixes.\n- Always prefer editing existing files over creating new ones.\n- By default old_string must occur exactly once. Include more surrounding context to disambiguate, or set replace_all=true only when every occurrence should change.\n- Use the smallest old_string that is clearly unique -- 2-4 adjacent lines is usually sufficient.\n- old_string must be non-empty. new_string must differ from old_string and may be empty to delete the matched text.\n- file_path may be absolute or relative to the Agent's working directory. A stale-file error requires another ReadFile and a revised edit.\n";
4510
- declare const WRITE_FILE_DESCRIPTION = "\nWrite content to a file, creating parent directories if needed. Overwrites existing files.\n\nUsage Notes\n\n- If modifying an existing file, prefer EditFile over WriteFile -- it only sends the diff.\n- Use this tool only to create new files or for complete rewrites.\n- You MUST read existing files with ReadFile before overwriting them.\n- file_path may be absolute or relative to the Agent's working directory. content is the complete UTF-8 text, including any desired trailing newline; an empty string creates or truncates an empty file.\n- Create documentation when the requested task or active workflow requires it; avoid unrelated files.\n";
4511
- declare const GLOB_DESCRIPTION = "\nFind files matching a glob pattern, returning paths relative to the search base, sorted by modification time (newest first).\n\nUsage Notes\n\n- Supports patterns like \"**/*.ts\", \"src/js/*.js\", \"*.{ts,tsx}\".\n- Search from \".\" or a specific path, never from \"/\".\n- Hidden (dot) files and directories are included.\n- Automatically skips .git, node_modules, __pycache__, and similar directories.\n- Returns at most 1000 matches. When limited, narrow the search; the result is not an exhaustive listing.\n- Use this instead of find or ls command via Bash.\n";
4512
- declare const GREP_DESCRIPTION = "\nSearch file content using a regex pattern (case-insensitive), returning file:line:content matches.\n\nUsage Notes\n\n- Searches one line at a time using JavaScript-style regular expressions (e.g., \"log.*Error\"). Escape backslashes in JSON strings. Multiline matches and every PCRE extension are not supported.\n- Filter files with the include parameter (e.g., \"*.ts\", \"*.{ts,tsx}\", \"src/**/*.js\").\n- Include patterns containing \"/\" match the path relative to the working directory; bare patterns like \"*.ts\" match file names at any depth.\n- Search from \".\" or a specific path, never from \"/\".\n- Automatically skips .git, node_modules, __pycache__, and similar directories.\n- Use this instead of grep or rg commands via Bash.\n- Returns at most 500 matching lines. Narrow the search if the result limit is reached. Use ReadFile for surrounding context.\n";
4760
+ declare const BASH_DESCRIPTION = "Execute command in Bash; return stdout and stderr. Prefer PowerShell on Windows.\n- timeout is in seconds: default 120, maximum 600. Each call starts a fresh, independent shell in the Agent's working directory; cd, variables, functions, and options do not persist.\n- Quote paths with spaces. To change directory, use cd \"path\" && command in the same call. Separate independent commands; chain dependent commands with &&, not ;.\n- Prefer dedicated file/search tools over cat, head, tail, sed, awk, echo, or find. Scope searches to a directory, never the filesystem root. Diagnose failures rather than retrying in sleep loops.\nGit: commit or push only when requested. Destructive operations (push --force, reset --hard, checkout ., clean -f, branch -D), amending, or skipping hooks/signing require explicit authorization; never bypass permission/hook denials. Prefer new commits. When committing, include Co-Authored-By: Swifty <usr161043261@outlook.com>.";
4761
+ declare const POWERSHELL_DESCRIPTION = "Execute command in PowerShell; return stdout and stderr. Recommended on Windows (powershell.exe); uses pwsh elsewhere.\n- timeout is in seconds: default 120, maximum 600. Each call starts a fresh, independent shell in the Agent's working directory; location, variables, and options do not persist.\n- Quote paths with spaces; use Set-Location -LiteralPath \"path\" in the same call. Separate independent commands. For dependencies, check $LASTEXITCODE for native commands and use -ErrorAction Stop for cmdlets; ; does not stop on failure. Do not assume PowerShell 7 syntax.\n- Prefer dedicated file/search tools over Get-Content, Select-String, or Write-Output. Scope recursion to a directory, not a drive root. Diagnose failures rather than retrying in Start-Sleep loops.\nGit: commit or push only when requested. Destructive operations (push --force, reset --hard, checkout ., clean -f, branch -D), amending, or skipping hooks/signing require explicit authorization; never bypass permission/hook denials. Prefer new commits. When committing, include Co-Authored-By: Swifty <usr161043261@outlook.com>.";
4762
+ declare const READ_FILE_DESCRIPTION = "Read text with 1-based display line numbers, or images (png, jpg, jpeg, gif, webp) as visual content; not directories.\n- file_path is absolute or relative to the Agent's working directory. offset skips lines (0-based, default 0); limit defaults to 2000 lines, with a 50KB text output cap. Displayed line 101 starts at offset=100. Follow continuation/readback instructions for partial output.\n- Images ignore offset/limit. A successful read refreshes the file-state cache used by EditFile/WriteFile; re-read after an external-change error.";
4763
+ declare const EDIT_FILE_DESCRIPTION = "Replace exact text in an existing file and return a diff. Prefer this over whole-file rewrites.\n- file_path is absolute or relative to the Agent's working directory. ReadFile is required first; stale file-state errors require a fresh read and revised edit.\n- old_string must be non-empty and unique unless replace_all=true (default false). Use enough context to disambiguate; preserve whitespace and exclude display line numbers.\n- new_string must differ from old_string; an empty string deletes the match.";
4764
+ declare const WRITE_FILE_DESCRIPTION = "Write complete UTF-8 content to file_path, creating parent directories and overwriting existing content. Use for new files or complete rewrites; prefer EditFile for targeted changes.\n- file_path is absolute or relative to the Agent's working directory. Existing files require ReadFile first; re-read if the cached state is stale.\n- content includes any desired trailing newline; an empty string creates or truncates an empty file. Avoid unrelated files or unsolicited documentation.";
4765
+ declare const GLOB_DESCRIPTION = "Find files by glob pattern (e.g. \"**/*.ts\", \"*.{ts,tsx}\"). Return paths relative to path, sorted newest modification first.\n- path is absolute or relative to the Agent's working directory (default \".\"); never search the filesystem root.\n- Includes dotfiles; traversal skips fixed directories such as .git, .agents, .swifty, node_modules, dist, and __pycache__, not rules from .gitignore.\n- At most 1000 matches; narrow limited searches rather than treating them as exhaustive. Prefer this over shell find/ls.";
4766
+ declare const GREP_DESCRIPTION = "Search file content with a case-insensitive, line-by-line JavaScript-style regex pattern; return file:line:content with 1-based lines and working-directory-relative paths.\n- path is a file or directory, absolute or relative to the Agent's working directory (default \".\"). Escape regex backslashes in JSON. No multiline matching or general PCRE support.\n- include is an optional glob: \"*.ts\" matches names at any depth; patterns with \"/\" match working-directory-relative paths. A direct file path is searched without this filter.\n- Traversal includes dotfiles but skips fixed directories such as .git, .agents, .swifty, node_modules, dist, and __pycache__, not .gitignore rules. Binary/unreadable files are skipped; directory symlinks are not traversed.\n- At most 500 matching lines. Narrow searches; never search the filesystem root. Use ReadFile for context and this tool instead of shell grep/rg.";
4513
4767
 
4514
4768
  /**
4515
4769
  * Copyright (c) 2026 hangtiancheng
@@ -4692,8 +4946,44 @@ declare class ExitWorktreeTool implements Tool {
4692
4946
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4693
4947
  * SOFTWARE.
4694
4948
  */
4695
- /** EditFile output is structured diff text; other tools return plain strings */
4696
- declare function isDiffTool(toolName: string): boolean;
4949
+
4950
+ declare class GlobTool implements Tool {
4951
+ name: string;
4952
+ description: string;
4953
+ category: ToolCategory;
4954
+ schema(): ToolSchema;
4955
+ execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
4956
+ }
4957
+
4958
+ /**
4959
+ * Copyright (c) 2026 hangtiancheng
4960
+ *
4961
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4962
+ * of this software and associated documentation files (the "Software"), to deal
4963
+ * in the Software without restriction, including without limitation the rights
4964
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4965
+ * copies of the Software, and to permit persons to whom the Software is
4966
+ * furnished to do so, subject to the following conditions:
4967
+ *
4968
+ * The above copyright notice and this permission notice shall be included in
4969
+ * all copies or substantial portions of the Software.
4970
+ *
4971
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4972
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4973
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4974
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4975
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4976
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4977
+ * SOFTWARE.
4978
+ */
4979
+
4980
+ declare class GrepTool implements Tool {
4981
+ name: string;
4982
+ description: string;
4983
+ category: ToolCategory;
4984
+ schema(): ToolSchema;
4985
+ execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
4986
+ }
4697
4987
 
4698
4988
  /**
4699
4989
  * Copyright (c) 2026 hangtiancheng
@@ -4716,8 +5006,8 @@ declare function isDiffTool(toolName: string): boolean;
4716
5006
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4717
5007
  * SOFTWARE.
4718
5008
  */
4719
- declare const TOOL_SEARCH_TOOL_NAME = "ToolSearch";
4720
- declare const MCP_CALL_TOOL_NAME = "McpCall";
5009
+ /** EditFile output is structured diff text; other tools return plain strings */
5010
+ declare function isDiffTool(toolName: string): boolean;
4721
5011
 
4722
5012
  /**
4723
5013
  * Copyright (c) 2026 hangtiancheng
@@ -4740,6 +5030,33 @@ declare const MCP_CALL_TOOL_NAME = "McpCall";
4740
5030
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4741
5031
  * SOFTWARE.
4742
5032
  */
5033
+ /**
5034
+ * Unified call entry point for MCP tools.
5035
+ *
5036
+ * MCP tools never enter tools[]. The model first reads the schema via ToolSearch,
5037
+ * then passes the tool name and arguments through McpCall. This keeps the tools
5038
+ * array byte-identical throughout the whole session, so the prompt cache prefix is
5039
+ * never broken — tools render after system and before messages, so any change to
5040
+ * the array forces the entire trailing history to be recomputed.
5041
+ *
5042
+ * The trade-off is that arguments are generated freely by the model with no schema
5043
+ * constraint at the interface level, so the JSON type is occasionally wrong.
5044
+ * coerceBySchema fixes values level by level against the target tool's full schema.
5045
+ * The fix-up rules must be identical, item by item, across all four languages:
5046
+ *
5047
+ * schema declares model provides coerced to
5048
+ * string number (not boolean) "8891"
5049
+ * integer / number numeric-looking string 5 / 5.0
5050
+ * boolean "true" / "false" true / false
5051
+ * array single-key obj, array val unwrap the inner array
5052
+ * array comma-separated string split on commas, trim spaces
5053
+ * object object recurse over properties
5054
+ * array array recurse each element via items
5055
+ *
5056
+ * Values that can't be fixed are passed through as-is, letting the MCP server
5057
+ * report its own error — a server-side domain error is more instructive to the
5058
+ * model than a local type error.
5059
+ */
4743
5060
 
4744
5061
  declare function coerceBySchema(value: unknown, schema: unknown): unknown;
4745
5062
  /**
@@ -4770,14 +5087,6 @@ declare class McpCallTool implements Tool {
4770
5087
  execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
4771
5088
  }
4772
5089
 
4773
- declare class PowerShellTool implements Tool {
4774
- name: string;
4775
- description: string;
4776
- category: ToolCategory;
4777
- schema(): ToolSchema;
4778
- execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
4779
- }
4780
-
4781
5090
  /**
4782
5091
  * Copyright (c) 2026 hangtiancheng
4783
5092
  *
@@ -4800,13 +5109,12 @@ declare class PowerShellTool implements Tool {
4800
5109
  * SOFTWARE.
4801
5110
  */
4802
5111
 
4803
- declare class ReadFileTool implements Tool {
5112
+ declare class PowerShellTool implements Tool {
4804
5113
  name: string;
4805
5114
  description: string;
4806
5115
  category: ToolCategory;
4807
5116
  schema(): ToolSchema;
4808
5117
  execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
4809
- private readImage;
4810
5118
  }
4811
5119
 
4812
5120
  /**
@@ -4831,26 +5139,13 @@ declare class ReadFileTool implements Tool {
4831
5139
  * SOFTWARE.
4832
5140
  */
4833
5141
 
4834
- /**
4835
- * Lets the Agent deliver its final result as structured data. In
4836
- * non-interactive mode and coordinator mode, callers want JSON they can parse
4837
- * directly, not a snippet of text buried inside natural language.
4838
- */
4839
- declare class SyntheticOutputTool implements Tool {
4840
- private jsonSchema?;
5142
+ declare class ReadFileTool implements Tool {
4841
5143
  name: string;
4842
5144
  description: string;
4843
5145
  category: ToolCategory;
4844
- /** jsonSchema is optional; when set, output is validated against the structure agreed with the caller. */
4845
- constructor(jsonSchema?: Record<string, unknown> | undefined);
4846
5146
  schema(): ToolSchema;
4847
- execute(_ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
4848
- /**
4849
- * Only covers top-level type and required fields; an empty return string
4850
- * means it passed. Full JSON Schema validation is unnecessary here — what
4851
- * we guard against is the model delivering a structurally malformed result.
4852
- */
4853
- private validateSchema;
5147
+ execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
5148
+ private readImage;
4854
5149
  }
4855
5150
 
4856
5151
  /**
@@ -4875,44 +5170,26 @@ declare class SyntheticOutputTool implements Tool {
4875
5170
  * SOFTWARE.
4876
5171
  */
4877
5172
 
4878
- declare class ToolSearchTool implements Tool {
4879
- name: string;
4880
- description: string;
4881
- category: ToolCategory;
4882
- private registry;
4883
- constructor(registry: ToolRegistry);
4884
- schema(): ToolSchema;
4885
- execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
4886
- }
4887
-
4888
5173
  /**
4889
- * Copyright (c) 2026 hangtiancheng
4890
- *
4891
- * Permission is hereby granted, free of charge, to any person obtaining a copy
4892
- * of this software and associated documentation files (the "Software"), to deal
4893
- * in the Software without restriction, including without limitation the rights
4894
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4895
- * copies of the Software, and to permit persons to whom the Software is
4896
- * furnished to do so, subject to the following conditions:
4897
- *
4898
- * The above copyright notice and this permission notice shall be included in
4899
- * all copies or substantial portions of the Software.
4900
- *
4901
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4902
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4903
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4904
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4905
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4906
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4907
- * SOFTWARE.
5174
+ * Lets the Agent deliver its final result as structured data. In
5175
+ * non-interactive mode and coordinator mode, callers want JSON they can parse
5176
+ * directly, not a snippet of text buried inside natural language.
4908
5177
  */
4909
-
4910
- declare class GlobTool implements Tool {
5178
+ declare class SyntheticOutputTool implements Tool {
5179
+ private jsonSchema?;
4911
5180
  name: string;
4912
5181
  description: string;
4913
5182
  category: ToolCategory;
5183
+ /** jsonSchema is optional; when set, output is validated against the structure agreed with the caller. */
5184
+ constructor(jsonSchema?: Record<string, unknown> | undefined);
4914
5185
  schema(): ToolSchema;
4915
- execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
5186
+ execute(_ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
5187
+ /**
5188
+ * Only covers top-level type and required fields; an empty return string
5189
+ * means it passed. Full JSON Schema validation is unnecessary here — what
5190
+ * we guard against is the model delivering a structurally malformed result.
5191
+ */
5192
+ private validateSchema;
4916
5193
  }
4917
5194
 
4918
5195
  /**
@@ -4937,10 +5214,12 @@ declare class GlobTool implements Tool {
4937
5214
  * SOFTWARE.
4938
5215
  */
4939
5216
 
4940
- declare class GrepTool implements Tool {
5217
+ declare class ToolSearchTool implements Tool {
4941
5218
  name: string;
4942
5219
  description: string;
4943
5220
  category: ToolCategory;
5221
+ private registry;
5222
+ constructor(registry: ToolRegistry);
4944
5223
  schema(): ToolSchema;
4945
5224
  execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
4946
5225
  }
@@ -5095,6 +5374,7 @@ declare function connectToIde(opts: {
5095
5374
  cwd: string;
5096
5375
  onAtMentioned: (mention: IdeAtMention) => void;
5097
5376
  onDisconnect?: () => void;
5377
+ signal?: AbortSignal;
5098
5378
  }): Promise<IdeConnection | null>;
5099
5379
 
5100
5380
  /**
@@ -5238,28 +5518,28 @@ declare function buildWorktreeNotice(parentCwd: string, wtPath: string): string;
5238
5518
  * SOFTWARE.
5239
5519
  */
5240
5520
 
5241
- declare const TaskStatusSchema: z$1.ZodEnum<{
5521
+ declare const TaskStatusSchema: z.ZodEnum<{
5242
5522
  completed: "completed";
5243
5523
  in_progress: "in_progress";
5244
5524
  pending: "pending";
5245
5525
  }>;
5246
- type TaskStatus = z$1.infer<typeof TaskStatusSchema>;
5247
- declare const TaskSchema: z$1.ZodObject<{
5248
- id: z$1.ZodString;
5249
- subject: z$1.ZodString;
5250
- description: z$1.ZodString;
5251
- status: z$1.ZodEnum<{
5526
+ type TaskStatus = z.infer<typeof TaskStatusSchema>;
5527
+ declare const TaskSchema: z.ZodObject<{
5528
+ id: z.ZodString;
5529
+ subject: z.ZodString;
5530
+ description: z.ZodString;
5531
+ status: z.ZodEnum<{
5252
5532
  completed: "completed";
5253
5533
  in_progress: "in_progress";
5254
5534
  pending: "pending";
5255
5535
  }>;
5256
- owner: z$1.ZodOptional<z$1.ZodString>;
5257
- activeForm: z$1.ZodOptional<z$1.ZodString>;
5258
- blocks: z$1.ZodArray<z$1.ZodString>;
5259
- blockedBy: z$1.ZodArray<z$1.ZodString>;
5260
- metadata: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
5261
- }, z$1.core.$strip>;
5262
- type Task$1 = z$1.infer<typeof TaskSchema>;
5536
+ owner: z.ZodOptional<z.ZodString>;
5537
+ activeForm: z.ZodOptional<z.ZodString>;
5538
+ blocks: z.ZodArray<z.ZodString>;
5539
+ blockedBy: z.ZodArray<z.ZodString>;
5540
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
5541
+ }, z.core.$strip>;
5542
+ type Task$1 = z.infer<typeof TaskSchema>;
5263
5543
  declare class TaskStore {
5264
5544
  private filePath;
5265
5545
  constructor(workDir: string, listId: string);
@@ -5439,4 +5719,4 @@ declare class TaskUpdateTool implements Tool {
5439
5719
  execute(ctx: ToolContext, args: Record<string, unknown>): Promise<ToolResult>;
5440
5720
  }
5441
5721
 
5442
- export { ASYNC_AGENT_ALLOWED_TOOLS, Agent, type AgentConfig, type AgentDefinition, type AgentEvent, type AgentEventCallback, AgentEventLogger, type AgentEventSink, type AgentProgress, AgentProgressSchema, type AgentTask, AgentTool, AnthropicClient, type AppConfig, AskUserQuestionTool, type Asker, AuthenticationError, AutoCompactTrackingState, BASH_DESCRIPTION, BUILTIN_AGENTS, type Backup, BashTool, BwrapSandbox, CHARS_PER_TOKEN, COMPACT_BOUNDARY, CUSTOM_AGENT_DISALLOWED_TOOLS, CodeReviewManager, type CodeReviewMember, type CodeReviewTeam, type Command, type CommandContext, CommandRegistry, type CommandType, CommandUsageTracker, type CommentIssue, type CommentResolution, type CompactBoundaryPayload, type CompactResult, ConfigError, type ConnectResult, ContextTooLongError, ConversationManager, type CriticAssessment, type CriticEvaluation, DEFAULT_CONTEXT_WINDOW, DEFAULT_EAGER_THRESHOLD_PERCENT, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_THINKING_LEVEL, type Decision, type DecisionEffect, type DetectedIde, type DiffResult, EDIT_FILE_DESCRIPTION, EditFileTool, EnterWorktreeTool, type EnvironmentContext, type EventLogger, type EventName, ExitPlanModeTool, ExitWorktreeTool, FORK_QUERY_SOURCE, type FileFeedback, FileHistory, type FileMailMessage, FileMailbox, FileStateCache, GLOB_DESCRIPTION, GREP_DESCRIPTION, GlobTool, GrepTool, type HookConfig, HookConfigSchema, type HookContext, HookEngine, type HookResult, type HookRuntimeOptions, INTERRUPTED_TOOL_RESULT, type IdeAtMention, type IdeConnection, ImageTooLargeError, InstallSkillTool, type InstructionSource, type KeptMessage, type LLMClient, LLMError, ListTeamsTool, LoadSkillTool, MAX_DIMENSION_PX, MAX_HISTORY_ENTRIES, MAX_IMAGES_PER_MESSAGE, MAX_IMAGE_BYTES_PASSTHROUGH, MCPClient, MCPManager, type MCPServerConfig, type MCPTool, type MCPToolLike, MCPToolWrapper, MCP_CALL_TOOL_NAME, MCP_NAME_SEP, MCP_TOOL_PREFIX, MSG_PLAN_APPROVAL_REQUEST, MSG_PLAN_APPROVAL_RESPONSE, MSG_SHUTDOWN_REQUEST, MSG_SHUTDOWN_RESPONSE, MSG_TEXT, type MaxTokensSetter, McpCallTool, type McpLoadingMode, type Member, MemoryConsolidator, MemoryExtractor, type MemoryFile, type MemoryHeader, MemoryManager, type Message, NATIVE_TOOL_USE_BETA, NameRegistry, NetworkError, OpenAIClient, OpenAICompatClient, type OpenAIMessageParam, POWERSHELL_DESCRIPTION, PathSandbox, PermissionChecker, type PermissionMode, PowerShellTool, type PrintArgs, PromptBuilder, type ProviderConfig, ProviderConfigSchema, type Question, type QuestionOption, READ_FILE_DESCRIPTION, REJECTED_TOOL_RESULT, RateLimitError, ReadFileTool, type RecallResult, RecoveryState, type RelevantMemory, type RemoteAgentHandle, RemoteServer, type RestoredMessage, type ReviewComment, type ReviewRequest, ReviewSession, type ReviewSummary, RuleEngine, type RunAgent, type RunCallbacks, SHUTDOWN_PREFIX, SKIP_DIRS, SUBAGENT_DISALLOWED_TOOLS, type Sandbox, type SandboxConfig, type SandboxYamlConfig, type SaveClipboardImageResult, SeatbeltSandbox, type Section, SendMessageTool, type SessionInfo, type SessionMessage, type SharedTask, SharedTaskStore, type Skill, SkillCatalog, type SkillForkHost, type SkillHost, type SkillMeta, type Snapshot, type SpawnConfig, SpawnTeammateTool, type Task$1 as StoredTask, type StreamEvent, StreamingExecutor, type SubagentRunOptions, SyntheticOutputTool, TEAMMATE_DISALLOWED_TOOLS, THINKING_BUDGETS, THINKING_LEVELS, TOOL_RESULT_PREVIEW_CHARS, TOOL_SEARCH_TOOL_NAME, type Task, TaskCreateTool$1 as TaskCreateTool, TaskGetTool$1 as TaskGetTool, TaskList, TaskListTool$1 as TaskListTool, TaskManager, type TaskStatus, TaskStopTool, TaskStore, type TaskUpdateFields, TaskUpdateTool$1 as TaskUpdateTool, Team, TeamCreateTool, TeamDeleteTool, type TeamFile, TeamManager, type TeamMemberEntry, TeamMemberEntrySchema, type TeamMode, TaskCreateTool as TeamTaskCreateTool, TaskGetTool as TeamTaskGetTool, TaskListTool as TeamTaskListTool, TaskUpdateTool as TeamTaskUpdateTool, type TeammateUIState, TeammateUIStateSchema, type ThinkingBlock, type ThinkingLevel, type ThinkingLevelControl, type Tool, type ToolActivity, ToolActivitySchema, type ToolCategory, type ToolContext, ToolRegistry, type ToolResult, type ToolResultBlock, type ToolResultContentBlock, type ToolResultRecord, type ToolSchema, ToolSearchTool, type ToolUseBlock, type ToolUseRecord, type TranscriptEntry, type UsageAnchor, type UsageInfo, WRITE_FILE_DESCRIPTION, WebSocketTransport, type WorktreeResult, WriteFileTool, append, applyBudget, applyMode, approved, asCriticEvaluation, asError, asErrorString, asImageMediaType, asRecord, asString, boolArg, buildAnthropicMessages, buildChatCompletionMessages, buildDiff, buildMcpToolName, buildOpenAIInput, buildPlanModeExitReminder, buildPlanModeReentryReminder, buildPlanModeReminder, buildSkillSection, buildSystemPrompt, buildTeammateRegistry, buildWorktreeNotice, cleanExpiredSessions, clipboardImageFileName, cloneRegistryForFork, closeLogger, coerceBySchema, computeCompactThreshold, computeKeepStartIndex, connectToIde, contentToText, coordinatorActive, coordinatorReminder, coordinatorToolFilter, createAgentWorktree, createChildLogger, createClient, createDefaultCodeReviewTeam, createDefaultRegistry, createModelResolver, createProgress, createRemoteAgent, createSandbox, currentContextTokens, decideAndApply, decideMode, defaultThinkingLevelFor, detectBackend, detectBackendFromEnv, detectEnvironment, detectIde, discoverInstructions, doingTasksSection, ensureToolPairing, environmentSection, estimateMessages, estimateSchemaTokens, estimateTokens, evaluateRules, executingActionsSection, expandAtRefs, expandAtRefsWithImages, extractContent, fetchModelContextWindow, fileHistoryDir, filterToolsForAgent, forceCompact, forkEnabled, formatTokens, getContextWindow, getCurrentBranch, getCurrentPlanPath, getMaxOutputTokens, getMediaType, getNameRegistry, getOrCreatePlanPath, getSessionFilePath, getThinkingLevel, globalConfigPath, handleCodeReviewCommand, hasWorktreeChanges, identitySection, initLogger, intArg, isCoordinatorTool, isCriticEvaluation, isDiffTool, isImagePath, isMcpToolLike, isObject, isOfficialAnthropicEndpoint, isPngBuffer, isRecord, isSafeCommand, isShutdownRequest, isSpillReadback, isToolResultContentBlock, isValidThinkingLevel, listSessions, load, loadAgentDefinitions, loadConfig, loadImageAttachment, loadInstructions, loadPlan, loadSession, loadTranscript, loadUserCommands, logger, manageContext, markLastUserTailForCache, markToolsForCache, maybeResizeAndDownsampleImage, mcpCallPermissionContent, mcpContentToToolOutput, mcpToolNamePrefix, measureSchemaChars, memoryAge, memoryAgeDays, memoryFreshnessText, needsToolSearchBeta, newRequestId, newSessionId, normalizeToolResultContentBlock, outputEfficiencySection, parse, parsePrintFlags, parseSkillFile, parseTeammateFlags, persistLargeResult, planApprovalRequest, planApprovalResponse, planExists, quickSort, randomCompletionVerb, randomVerb, readTeamFile, readWorktreeHeadSha, rebuildFromSession, record, recordError, recordExit, recordTokens, recordToolUse, recover, removeAgentWorktree, renderBody, replaceToolResultContent, resetPlanPath, resolveAPIKey, resolveGitDir, resolveModelId, runFork, runInline, runPrintMode, runTeammate, safeJSONParse, sanitizeNameSegment, sanitizeSegment, sanitizeTeamName, saveClipboardImage, saveCompactBoundary, saveMessage, savePlan, saveTranscript, shutdownRequest, shutdownResponse, sniffMediaType, spawnSubagent, spawnTeammate, storeClipboardImage, strArg, strList, summarizeActivities, systemSection, teamConfigPath, teamDir, teamsBaseDir, thinkingBudgetForLevel, toDisplayPreview, toReasoningEffort, toTry, toneStyleSection, toolResultsToRecords, toolUsesToRecords, usingToolsSection, validate, version, withProviderDefaults, writeTeamFile };
5722
+ export { ASYNC_AGENT_ALLOWED_TOOLS, Agent, type AgentConfig, type AgentDefinition, type AgentEvent, type AgentEventCallback, AgentEventLogger, type AgentEventSink, type AgentProgress, AgentProgressSchema, type AgentTask, AgentTool, AnthropicClient, type AnthropicToolSchema, type AppConfig, AskUserQuestionTool, type Asker, AuthenticationError, AutoCompactTrackingState, BASH_DESCRIPTION, BUILTIN_AGENTS, type Backup, BashTool, BwrapSandbox, CHARS_PER_TOKEN, COMPACT_BOUNDARY, CUSTOM_AGENT_DISALLOWED_TOOLS, CodeReviewManager, type CodeReviewMember, type CodeReviewTeam, type Command, type CommandContext, CommandRegistry, type CommandType, CommandUsageTracker, type CommentIssue, type CommentResolution, type CompactBoundaryPayload, type CompactResult, ComputerUseTool, type ComputerUseToolOptions, ConfigError, type ConnectResult, ContextTooLongError, ConversationManager, type CriticAssessment, type CriticEvaluation, DEFAULT_CONTEXT_WINDOW, DEFAULT_EAGER_THRESHOLD_PERCENT, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_THINKING_LEVEL, type Decision, type DecisionEffect, type DetectedIde, type DiffResult, EDIT_FILE_DESCRIPTION, EditFileTool, EnterWorktreeTool, type EnvironmentContext, type EventLogger, type EventName, ExitPlanModeTool, ExitWorktreeTool, FORK_QUERY_SOURCE, type FileFeedback, FileHistory, type FileMailMessage, FileMailbox, FileStateCache, GLOB_DESCRIPTION, GREP_DESCRIPTION, GlobTool, GrepTool, type HookConfig, HookConfigSchema, type HookContext, HookEngine, type HookResult, type HookRuntimeOptions, INTERRUPTED_TOOL_RESULT, type IdeAtMention, type IdeConnection, ImageTooLargeError, InstallSkillTool, type InstructionSource, type KeptMessage, type LLMClient, LLMError, ListTeamsTool, LoadSkillTool, MAIN_AGENT_ONLY_TOOLS, MAX_DIMENSION_PX, MAX_HISTORY_ENTRIES, MAX_IMAGES_PER_MESSAGE, MAX_IMAGE_BYTES_PASSTHROUGH, MCPClient, MCPManager, type MCPServerConfig, type MCPTool, type MCPToolLike, MCPToolWrapper, MCP_NAME_SEP, MCP_TOOL_PREFIX, MIN_THINKING_ANSWER_TOKENS, MIN_THINKING_BUDGET_TOKENS, MSG_PLAN_APPROVAL_REQUEST, MSG_PLAN_APPROVAL_RESPONSE, MSG_SHUTDOWN_REQUEST, MSG_SHUTDOWN_RESPONSE, MSG_TEXT, type MaxTokensSetter, McpCallTool, type McpLoadingMode, type Member, MemoryConsolidator, MemoryExtractor, type MemoryFile, type MemoryHeader, MemoryManager, type Message, NATIVE_TOOL_USE_BETA, NameRegistry, NetworkError, OpenAIClient, OpenAICompatClient, type OpenAICompatToolSchema, type OpenAIMessageParam, type OpenAIResponsesToolSchema, POWERSHELL_DESCRIPTION, PathSandbox, PermissionChecker, type PermissionMode, PowerShellTool, type PrintArgs, PromptBuilder, type ProviderConfig, ProviderConfigSchema, type ProviderNativeToolSchema, type ProviderToolSchema, type Question, type QuestionOption, READ_FILE_DESCRIPTION, REJECTED_TOOL_RESULT, RateLimitError, ReadFileTool, type RecallResult, RecoveryState, type RelevantMemory, type RemoteAgentHandle, RemoteServer, type RestoredMessage, type ReviewComment, type ReviewRequest, ReviewSession, type ReviewSummary, RuleEngine, type RunAgent, type RunCallbacks, SHUTDOWN_PREFIX, SKIP_DIRS, SUBAGENT_DISALLOWED_TOOLS, type Sandbox, type SandboxConfig, type SandboxYamlConfig, type SaveClipboardImageResult, SeatbeltSandbox, type Section, SendMessageTool, type SessionInfo, type SessionMessage, type SharedTask, SharedTaskStore, type Skill, SkillCatalog, type SkillForkHost, type SkillHost, type SkillMeta, type Snapshot, type SpawnConfig, SpawnTeammateTool, type Task$1 as StoredTask, type StreamEvent, StreamingExecutor, type SubagentRunOptions, SyntheticOutputTool, TEAMMATE_DISALLOWED_TOOLS, THINKING_BUDGETS, THINKING_LEVELS, TOOL_RESULT_PREVIEW_CHARS, type Task, TaskCreateTool$1 as TaskCreateTool, TaskGetTool$1 as TaskGetTool, TaskList, TaskListTool$1 as TaskListTool, TaskManager, type TaskStatus, TaskStopTool, TaskStore, type TaskUpdateFields, TaskUpdateTool$1 as TaskUpdateTool, Team, TeamCreateTool, TeamDeleteTool, type TeamFile, TeamManager, type TeamMemberEntry, TeamMemberEntrySchema, type TeamMode, TaskCreateTool as TeamTaskCreateTool, TaskGetTool as TeamTaskGetTool, TaskListTool as TeamTaskListTool, TaskUpdateTool as TeamTaskUpdateTool, type TeammateUIState, TeammateUIStateSchema, type ThinkingBlock, type ThinkingLevel, type ThinkingLevelControl, type Tool, type ToolActivity, ToolActivitySchema, type ToolCategory, type ToolContext, type ToolProtocol, ToolRegistry, type ToolResult, type ToolResultBlock, type ToolResultContentBlock, type ToolResultRecord, type ToolSchema, ToolSearchTool, type ToolUseBlock, type ToolUseRecord, type TranscriptEntry, type UsageAnchor, type UsageInfo, WRITE_FILE_DESCRIPTION, WebSocketTransport, type WorktreeResult, WriteFileTool, append, applyBudget, applyMode, approved, asCriticEvaluation, asError, asErrorString, asImageMediaType, asRecord, asString, boolArg, buildAnthropicMessages, buildChatCompletionMessages, buildDiff, buildMcpToolName, buildOpenAIInput, buildPlanModeExitReminder, buildPlanModeReentryReminder, buildPlanModeReminder, buildSkillSection, buildSystemPrompt, buildTeammateRegistry, buildWorktreeNotice, clampThinkingLevel, cleanExpiredSessions, clipboardImageFileName, cloneRegistryForFork, closeLogger, coerceBySchema, computeCompactThreshold, computeKeepStartIndex, connectToIde, contentToText, coordinatorActive, coordinatorReminder, coordinatorToolFilter, createAgentWorktree, createChildLogger, createClient, createDefaultCodeReviewTeam, createDefaultRegistry, createModelResolver, createProgress, createRemoteAgent, createSandbox, currentContextTokens, decideAndApply, decideMode, detectBackend, detectBackendFromEnv, detectEnvironment, detectIde, discoverInstructions, doingTasksSection, ensureToolPairing, environmentSection, escapeSkillXml, estimateMessages, estimateSchemaTokens, estimateTokens, evaluateRules, executingActionsSection, expandAtRefs, expandAtRefsWithImages, extractContent, fetchModelContextWindow, fileHistoryDir, filterToolsForAgent, forceCompact, forkEnabled, formatTokens, getContextWindow, getCurrentBranch, getCurrentPlanPath, getMaxOutputTokens, getMediaType, getNameRegistry, getOrCreatePlanPath, getSessionFilePath, getSupportedThinkingLevels, getThinkingLevel, globalConfigPath, handleCodeReviewCommand, hasWorktreeChanges, identitySection, initLogger, intArg, isCoordinatorTool, isCriticEvaluation, isDiffTool, isImagePath, isMcpToolLike, isObject, isOfficialAnthropicEndpoint, isPngBuffer, isRecord, isSafeCommand, isShutdownRequest, isSpillReadback, isToolResultContentBlock, isValidThinkingLevel, listSessions, load, loadAgentDefinitions, loadConfig, loadImageAttachment, loadInstructions, loadPlan, loadSession, loadTranscript, loadUserCommands, logger, manageContext, markLastUserTailForCache, markToolsForCache, maybeResizeAndDownsampleImage, mcpCallPermissionContent, mcpContentToToolOutput, mcpToolNamePrefix, measureSchemaChars, memoryAge, memoryAgeDays, memoryFreshnessText, needsToolSearchBeta, newRequestId, newSessionId, normalizeToolResultContentBlock, outputEfficiencySection, parse, parsePrintFlags, parseSkillFile, parseSkillPrompt, parseTeammateFlags, persistLargeResult, planApprovalRequest, planApprovalResponse, planExists, quickSort, randomCompletionVerb, randomVerb, readTeamFile, readWorktreeHeadSha, rebuildFromSession, record, recordError, recordExit, recordTokens, recordToolUse, recover, removeAgentWorktree, renderBody, replaceToolResultContent, resetPlanPath, resolveAPIKey, resolveGitDir, resolveModelId, runFork, runInline, runPrintMode, runTeammate, safeJSONParse, sanitizeNameSegment, sanitizeSegment, sanitizeTeamName, saveClipboardImage, saveCompactBoundary, saveMessage, savePlan, saveTranscript, shutdownRequest, shutdownResponse, sniffMediaType, spawnSubagent, spawnTeammate, storeClipboardImage, strArg, strList, summarizeActivities, systemSection, teamConfigPath, teamDir, teamsBaseDir, thinkingBudgetForLevel, toAnthropicThinkingEffort, toDisplayPreview, toReasoningEffort, toTry, toneStyleSection, toolResultsToRecords, toolUsesToRecords, usingToolsSection, validate, version, withProviderDefaults, writeTeamFile };