@nuvin/agent-core 0.1.1-rc.0 → 0.2.0-rc.10

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 (97) hide show
  1. package/dist/VERSION +2 -2
  2. package/dist/agent/index.js +1 -1
  3. package/dist/agent/metrics.d.ts +17 -1
  4. package/dist/chunk-D5IVWJHX.js +1 -1
  5. package/dist/chunk-FFIZ6TKW.js +1 -1
  6. package/dist/chunk-GAZGO6N7.js +1 -0
  7. package/dist/chunk-IUZALP6K.js +1 -0
  8. package/dist/chunk-LIE76IJA.js +1 -0
  9. package/dist/chunk-X7VAACWY.js +1 -1
  10. package/dist/chunk-YNOIG4FD.js +1 -0
  11. package/dist/chunk-ZHE3E26D.js +1 -0
  12. package/dist/formats/index.js +1 -1
  13. package/dist/formats/message-format.d.ts +1 -0
  14. package/dist/hooks/index.js +1 -1
  15. package/dist/lsp/client.d.ts +4 -0
  16. package/dist/models/chat-model.d.ts +1 -0
  17. package/dist/models/github-model.d.ts +2 -0
  18. package/dist/models/index.d.ts +3 -0
  19. package/dist/models/index.js +1 -1
  20. package/dist/models/mock-model.d.ts +2 -0
  21. package/dist/models/model-cost.d.ts +5 -0
  22. package/dist/models/model-pricing-generator.d.ts +9 -0
  23. package/dist/models/model-pricing-products.d.ts +45 -0
  24. package/dist/models/model-pricing-types.d.ts +33 -0
  25. package/dist/models/model-pricing.d.ts +13 -0
  26. package/dist/models/model-pricing.generated.d.ts +23147 -0
  27. package/dist/models/model-registry.d.ts +8 -0
  28. package/dist/models/openai-surfaces.d.ts +4 -1
  29. package/dist/models/routed-model.d.ts +3 -0
  30. package/dist/shared/abort-aware-semaphore.d.ts +5 -0
  31. package/dist/shared/index.d.ts +1 -0
  32. package/dist/shared/index.js +1 -1
  33. package/dist/shared/reasoning-config.d.ts +3 -4
  34. package/dist/shared/types.d.ts +98 -22
  35. package/dist/tools/{internal-tool-runtime.d.ts → core/internal-tool-runtime.d.ts} +1 -1
  36. package/dist/tools/core/mock-tool-runtime.d.ts +3 -0
  37. package/dist/tools/core/runtime-manager-tools.d.ts +87 -0
  38. package/dist/tools/{tool-output-offload.d.ts → core/tool-output-offload.d.ts} +1 -1
  39. package/dist/tools/{tools.d.ts → core/tools.d.ts} +4 -1
  40. package/dist/tools/file-editing/anchored-file-edit.d.ts +53 -0
  41. package/dist/tools/file-editing/anchored-file-errors.d.ts +5 -0
  42. package/dist/tools/file-editing/anchored-file-operations.d.ts +38 -0
  43. package/dist/tools/file-editing/anchored-file-read.d.ts +37 -0
  44. package/dist/tools/file-editing/atomic-file-write.d.ts +19 -0
  45. package/dist/tools/file-editing/file-edit-tool.d.ts +166 -0
  46. package/dist/tools/file-editing/file-mutation-coordinator.d.ts +13 -0
  47. package/dist/tools/file-editing/file-mutation.d.ts +15 -0
  48. package/dist/tools/{file-new-tool.d.ts → file-editing/file-new-tool.d.ts} +5 -2
  49. package/dist/tools/file-editing/file-observation-store.d.ts +40 -0
  50. package/dist/tools/{file-read-tool.d.ts → file-editing/file-read-tool.d.ts} +8 -2
  51. package/dist/tools/file-editing/file-snapshot.d.ts +16 -0
  52. package/dist/tools/file-editing/hashline-file-edit-adapter.d.ts +19 -0
  53. package/dist/tools/file-editing/structured-file-edit-adapter.d.ts +94 -0
  54. package/dist/tools/file-editing/workspace-paths.d.ts +20 -0
  55. package/dist/tools/index.d.ts +43 -29
  56. package/dist/tools/index.js +1 -1
  57. package/dist/tools/mcp/mcp-connection-generation.d.ts +59 -0
  58. package/dist/tools/mcp/mcp-safe-error-provenance.d.ts +4 -0
  59. package/dist/tools/mcp/mcp-safe-error.d.ts +14 -0
  60. package/dist/tools/mcp/mcp-server-manager.d.ts +16 -0
  61. package/dist/tools/mcp/mcp-tool-adapter.d.ts +72 -0
  62. package/dist/tools/{glob-tool.d.ts → search/glob-tool.d.ts} +2 -2
  63. package/dist/tools/search/grep-engine.d.ts +22 -0
  64. package/dist/tools/{grep-tool.d.ts → search/grep-tool.d.ts} +3 -3
  65. package/dist/tools/{ls-tool.d.ts → search/ls-tool.d.ts} +2 -2
  66. package/dist/tools/{ripgrep.d.ts → search/ripgrep.d.ts} +1 -0
  67. package/dist/tools/{view-file-tool.d.ts → search/view-file-tool.d.ts} +2 -2
  68. package/dist/tools/{ask-user-tool.d.ts → session/ask-user-tool.d.ts} +2 -2
  69. package/dist/tools/{lsp-tool.d.ts → session/lsp-tool.d.ts} +5 -5
  70. package/dist/tools/{skill-tool.d.ts → session/skill-tool.d.ts} +2 -2
  71. package/dist/tools/{todo-write-tool.d.ts → session/todo-write-tool.d.ts} +2 -2
  72. package/dist/tools/session/update-topic-tool.d.ts +12 -0
  73. package/dist/tools/shell/background-process-registry.d.ts +116 -0
  74. package/dist/tools/{bash-output-tool.d.ts → shell/bash-output-tool.d.ts} +2 -2
  75. package/dist/tools/{bash-tool.d.ts → shell/bash-tool.d.ts} +10 -6
  76. package/dist/tools/{command-tool.d.ts → shell/command-tool.d.ts} +2 -2
  77. package/dist/tools/{kill-shell-tool.d.ts → shell/kill-shell-tool.d.ts} +2 -2
  78. package/dist/tools/shell/process-tree-termination.d.ts +25 -0
  79. package/dist/tools/shell/terminal-output-normalizer.d.ts +6 -0
  80. package/dist/tools/{web-fetch-tool.d.ts → web/web-fetch-tool.d.ts} +2 -2
  81. package/dist/tools/{web-search-tool.d.ts → web/web-search-tool.d.ts} +2 -2
  82. package/package.json +4 -3
  83. package/dist/chunk-BLGBVFVX.js +0 -1
  84. package/dist/chunk-NYZR4XKO.js +0 -1
  85. package/dist/chunk-UIXQPCSN.js +0 -1
  86. package/dist/chunk-YWQXXHHU.js +0 -1
  87. package/dist/tools/background-process-registry.d.ts +0 -64
  88. package/dist/tools/file-edit-tool.d.ts +0 -34
  89. package/dist/tools/mcp-server-manager.d.ts +0 -60
  90. package/dist/tools/mcp-tool-adapter.d.ts +0 -47
  91. package/dist/tools/mock-tool-runtime.d.ts +0 -3
  92. package/dist/tools/runtime-manager-tools.d.ts +0 -58
  93. package/dist/tools/update-topic-tool.d.ts +0 -12
  94. package/dist/tools/workspace-paths.d.ts +0 -5
  95. /package/dist/tools/{mcp-oauth-provider.d.ts → mcp/mcp-oauth-provider.d.ts} +0 -0
  96. /package/dist/tools/{bash-internals.d.ts → shell/bash-internals.d.ts} +0 -0
  97. /package/dist/tools/{safe-fetch.d.ts → web/safe-fetch.d.ts} +0 -0
@@ -1,7 +1,9 @@
1
+ import type { ModelReasoningConfig } from "@nuvin/config";
1
2
  import type { ChatModelAuthScheme, ChatModelSurface } from "./chat-model.ts";
2
3
  export interface ModelProfile {
3
4
  contextWindow?: number;
4
5
  maxOutput?: number;
6
+ reasoning?: ModelReasoningConfig;
5
7
  surface?: ChatModelSurface;
6
8
  baseUrl?: string;
7
9
  }
@@ -29,7 +31,13 @@ export interface ResolvedModelProfile {
29
31
  supportsModelFetch?: boolean;
30
32
  contextWindow?: number;
31
33
  maxOutput?: number;
34
+ reasoning?: ModelReasoningConfig;
32
35
  }
36
+ export declare const REASONING_METADATA_VERSIONS: {
37
+ readonly anthropic: "2026-07-22";
38
+ readonly openai: "2026-07-22";
39
+ readonly codex: "0.145.0+25af12f7e61572b0bc18ddb1008be543b91519b0";
40
+ };
33
41
  export declare function getProviderProfile(provider: string): ProviderProfile | undefined;
34
42
  export declare function getModelProfile(provider: string, model: string): ModelProfile | undefined;
35
43
  export declare function resolveModelProfile(provider: string, model: string): ResolvedModelProfile | undefined;
@@ -43,8 +43,11 @@ interface OpenAiChatCompletionsRequest {
43
43
  messages: OpenAiChatCompletionMessage[];
44
44
  max_completion_tokens?: number;
45
45
  max_tokens?: number;
46
- reasoning_effort?: "high" | "low" | "medium" | "minimal" | "none" | "xhigh";
46
+ reasoning_effort?: "high" | "low" | "max" | "medium" | "minimal" | "none" | "xhigh";
47
47
  stream: boolean;
48
+ stream_options?: {
49
+ include_usage: true;
50
+ };
48
51
  tools?: OpenAiChatCompletionToolDefinition[];
49
52
  response_format?: {
50
53
  type: "json_schema";
@@ -32,6 +32,7 @@ export interface RoutedModelOptions {
32
32
  model: string;
33
33
  modelIdentity?: string;
34
34
  maxTokens?: number;
35
+ pricingProviderId?: string;
35
36
  reasoning?: ReasoningConfig;
36
37
  providerAdapter: ProviderAdapter;
37
38
  providerSessionResolver?: ProviderSessionResolver;
@@ -45,6 +46,7 @@ export declare class RoutedModel implements EngineChatModel {
45
46
  readonly model: string;
46
47
  readonly modelIdentity: string;
47
48
  readonly maxTokens?: number;
49
+ readonly pricingProviderId?: string;
48
50
  protected readonly reasoning?: ReasoningConfig;
49
51
  protected readonly apiKey?: string;
50
52
  protected readonly baseUrl: string;
@@ -83,6 +85,7 @@ export declare class RoutedModel implements EngineChatModel {
83
85
  protected mapApiError(error: Error): Error;
84
86
  protected toApiError(response: Response): Promise<Error>;
85
87
  private getSurface;
88
+ protected withPricingProviderId(request: ChatRequest): ChatRequest;
86
89
  private prepareChatRequest;
87
90
  protected applyModelDefaults(request: ChatRequest): ChatRequest;
88
91
  private sendHttpSurfaceRequest;
@@ -0,0 +1,5 @@
1
+ export interface AbortAwareSemaphore {
2
+ acquire(signal?: AbortSignal): Promise<() => void>;
3
+ }
4
+ export declare function createAbortAwareSemaphore(maxConcurrency: number): AbortAwareSemaphore;
5
+ //# sourceMappingURL=abort-aware-semaphore.d.ts.map
@@ -1,4 +1,5 @@
1
1
  export * from "./abort.ts";
2
+ export * from "./abort-aware-semaphore.ts";
2
3
  export * from "./model-identity.ts";
3
4
  export * from "./reasoning-config.ts";
4
5
  export * from "./turn-failed.ts";
@@ -1 +1 @@
1
- (function(_0x28b6cf,_0x313690){var _0x38bbe6={_0x10a28a:0x49b,_0x19a2ed:0x49f,_0x43e27e:0x2fd,_0x497508:0x2f5,_0x7d2cac:0x2ef,_0x4b4c9c:0x2f6,_0xe80ea9:0x2f2,_0x36c5dc:0x2f4,_0x18244b:0x2f8,_0x210343:0x2f2,_0x3d5d26:0x496,_0x5724a5:0x497,_0x2a0e1a:0x49e,_0x35e477:0x4a2,_0x3526f5:0x49d,_0x4a53b5:0x2ee,_0x32dec5:0x2f3,_0x9260f3:0x2fc,_0x12505d:0x2f9},_0x28bebd={_0x3f354a:0x17a},_0xc060d4={_0x3bca37:0x31c};function _0x3f19f4(_0x440d31,_0x2703a6,_0x12d843,_0x1c8ef5){return _0xe757(_0x440d31-_0xc060d4._0x3bca37,_0x2703a6);}function _0x364ee1(_0x14ff6d,_0x32366e,_0x4c4683,_0x569d52){return _0xe757(_0x4c4683-_0x28bebd._0x3f354a,_0x14ff6d);}var _0x595bd5=_0x28b6cf();while(!![]){try{var _0x4a9229=parseInt(_0x3f19f4(_0x38bbe6._0x10a28a,_0x38bbe6._0x19a2ed,_0x38bbe6._0x19a2ed,0x4a0))/0x1*(parseInt(_0x364ee1(_0x38bbe6._0x43e27e,0x2f5,0x2fb,_0x38bbe6._0x497508))/0x2)+-parseInt(_0x364ee1(_0x38bbe6._0x7d2cac,_0x38bbe6._0x4b4c9c,_0x38bbe6._0xe80ea9,0x2f0))/0x3*(parseInt(_0x364ee1(0x2f0,0x2f8,_0x38bbe6._0x36c5dc,0x2f8))/0x4)+-parseInt(_0x364ee1(0x2f7,0x2f5,0x2fa,_0x38bbe6._0x18244b))/0x5*(-parseInt(_0x364ee1(0x300,0x301,0x2fd,0x2fd))/0x6)+parseInt(_0x364ee1(0x2f6,_0x38bbe6._0x210343,0x2f8,0x2f6))/0x7+-parseInt(_0x3f19f4(0x499,_0x38bbe6._0x19a2ed,0x49c,0x498))/0x8*(-parseInt(_0x3f19f4(0x497,_0x38bbe6._0x3d5d26,0x495,_0x38bbe6._0x5724a5))/0x9)+parseInt(_0x3f19f4(_0x38bbe6._0x2a0e1a,_0x38bbe6._0x35e477,0x49c,_0x38bbe6._0x3526f5))/0xa+parseInt(_0x364ee1(_0x38bbe6._0x4a53b5,_0x38bbe6._0xe80ea9,_0x38bbe6._0x32dec5,0x2ef))/0xb*(-parseInt(_0x364ee1(_0x38bbe6._0x9260f3,_0x38bbe6._0x12505d,0x2f6,0x2f4))/0xc);if(_0x4a9229===_0x313690)break;else _0x595bd5['push'](_0x595bd5['shift']());}catch(_0x4800f7){_0x595bd5['push'](_0x595bd5['shift']());}}}(_0x2f30,0x76c45));function _0xe757(_0x55bbf4,_0x44a331){_0x55bbf4=_0x55bbf4-0x178;var _0x2f3055=_0x2f30();var _0xe757dc=_0x2f3055[_0x55bbf4];if(_0xe757['cPLpok']===undefined){var _0x2f47c5=function(_0x29e67b){var _0x321903='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x28f50b='',_0x3f0394='';for(var _0x1f89e0=0x0,_0x4582eb,_0x4ed472,_0x32c798=0x0;_0x4ed472=_0x29e67b['charAt'](_0x32c798++);~_0x4ed472&&(_0x4582eb=_0x1f89e0%0x4?_0x4582eb*0x40+_0x4ed472:_0x4ed472,_0x1f89e0++%0x4)?_0x28f50b+=String['fromCharCode'](0xff&_0x4582eb>>(-0x2*_0x1f89e0&0x6)):0x0){_0x4ed472=_0x321903['indexOf'](_0x4ed472);}for(var _0x3e670f=0x0,_0x37e678=_0x28f50b['length'];_0x3e670f<_0x37e678;_0x3e670f++){_0x3f0394+='%'+('00'+_0x28f50b['charCodeAt'](_0x3e670f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3f0394);};_0xe757['GdDsmh']=_0x2f47c5,_0xe757['XhpQrj']={},_0xe757['cPLpok']=!![];}var _0x3788ea=_0x2f3055[0x0],_0x28db43=_0x55bbf4+_0x3788ea,_0x2b2057=_0xe757['XhpQrj'][_0x28db43];return!_0x2b2057?(_0xe757dc=_0xe757['GdDsmh'](_0xe757dc),_0xe757['XhpQrj'][_0x28db43]=_0xe757dc):_0xe757dc=_0x2b2057,_0xe757dc;}function _0x2f30(){var _0x2576de=['mJy3mtKXnhzMEu9LBa','mJG1Du16sLDl','nZDcsfHTAhO','mtm4nZzhthDxs2m','nty3nZeXBfvVBxjU','mtyXmJG2mhvwzvvwCW','oenzvhr6vq','ndq0odmWnhvnCNLLBa','mZeYnZmZs1HiChn2','nuL3EvDfzW','mKHpAfrvAG','mZaWmJu2mfHWA3Hwzq'];_0x2f30=function(){return _0x2576de;};return _0x2f30();}import{modelIdentityFromParts}from'../chunk-D5IVWJHX.js';import{mapAutoReasoningEffortToBudgetTokens,resolveAnthropicThinkingConfig,resolveOpenAiReasoningConfig}from'../chunk-NYZR4XKO.js';import{TurnFailedError}from'../chunk-FFIZ6TKW.js';import{OperationAbortedError,addAbortListener,isAbortError,throwIfAborted,toAbortError}from'../chunk-X7VAACWY.js';export{OperationAbortedError,TurnFailedError,addAbortListener,isAbortError,mapAutoReasoningEffortToBudgetTokens,modelIdentityFromParts,resolveAnthropicThinkingConfig,resolveOpenAiReasoningConfig,throwIfAborted,toAbortError};
1
+ (function(_0x356b53,_0x590795){const _0x182b95={_0x51b9c8:0x2b8,_0x3f8af4:0x2a2,_0x20785e:0x2a5,_0x5beef7:0x230,_0x3b4e67:0x231,_0x1304d9:0x22f,_0x95eae0:0x29f,_0x2a3425:0x2a5,_0xd2555c:0x2ae,_0x43a158:0x298,_0x55f665:0x22c,_0x5e4002:0x23f,_0xe0cc01:0x234,_0xf2d517:0x29e,_0x3c0fef:0x2a5,_0x45cca0:0x2a0,_0x480483:0x21c,_0x35f696:0x225,_0xdf073d:0x29d,_0xbec305:0x2a4,_0xdf221c:0x29c,_0x14db03:0x2a1},_0x56871c={_0x741b31:0x227},_0x42bfb2=_0x356b53();function _0x48bd76(_0x2c6b55,_0x123d16,_0x546033,_0x1c6d8b){return _0x1a7b(_0x1c6d8b-0x1b3,_0x546033);}function _0x4f3684(_0x4091af,_0x2f25db,_0x382484,_0x41ec51){return _0x1a7b(_0x41ec51-_0x56871c._0x741b31,_0x2f25db);}while(!![]){try{const _0x38b8c3=-parseInt(_0x4f3684(0x2a9,0x2ab,_0x182b95._0x51b9c8,0x2ad))/0x1*(parseInt(_0x4f3684(_0x182b95._0x3f8af4,_0x182b95._0x20785e,0x29b,0x2a2))/0x2)+parseInt(_0x48bd76(_0x182b95._0x5beef7,_0x182b95._0x3b4e67,0x23b,_0x182b95._0x1304d9))/0x3+parseInt(_0x4f3684(_0x182b95._0x95eae0,_0x182b95._0x2a3425,_0x182b95._0xd2555c,0x2a7))/0x4*(parseInt(_0x4f3684(0x293,0x2a0,0x29e,_0x182b95._0x43a158))/0x5)+parseInt(_0x48bd76(_0x182b95._0x55f665,_0x182b95._0x5e4002,0x23f,_0x182b95._0xe0cc01))/0x6*(-parseInt(_0x4f3684(_0x182b95._0xf2d517,0x2a3,_0x182b95._0x3c0fef,_0x182b95._0x45cca0))/0x7)+-parseInt(_0x48bd76(_0x182b95._0x480483,_0x182b95._0x35f696,0x22b,0x227))/0x8+parseInt(_0x4f3684(0x29d,_0x182b95._0xdf073d,0x299,0x29a))/0x9*(parseInt(_0x4f3684(_0x182b95._0xbec305,0x29e,0x29d,_0x182b95._0xdf221c))/0xa)+-parseInt(_0x4f3684(0x298,_0x182b95._0x14db03,_0x182b95._0x95eae0,0x29d))/0xb;if(_0x38b8c3===_0x590795)break;else _0x42bfb2['push'](_0x42bfb2['shift']());}catch(_0x3b8b28){_0x42bfb2['push'](_0x42bfb2['shift']());}}}(_0x56be,0x5f63c));import{modelIdentityFromParts}from'../chunk-D5IVWJHX.js';function _0x56be(){const _0x150b55=['C3bSAwnL','ndK0ogfQEwnyuq','mty2mMzQwMLMBW','ChvZAa','Bwf4q29Uy3vYCMvUy3KGBxvZDcbIzsbHigzPBML0zsbWB3nPDgL2zsbPBNrLz2vY','AxngAw5PDgu','ywjVCNrLza','n1HhyvPVDG','y2fUy2vSBgvK','mZe0mfvHA2DKzG','AxnjBNrLz2vY','mJu0nZLlzLHdtLa','mJG2ndG2ngXQsMrjzq','mZmWzhjlCxjK','nZuWndq2ngXdB3bLvq','CMvTB3zLqwjVCNrmAxn0zw5LCG','CMvHC29U','mZCXExnnr2Th','CMvZB2X2zq','ndeYodHPquLUue0','mJe1otKZnensy2jlzW','BgvUz3rO','CMvQzwn0'];_0x56be=function(){return _0x150b55;};return _0x56be();}import{resolveAnthropicReasoningConfig,resolveOpenAiReasoningConfig}from'../chunk-IUZALP6K.js';function _0x1a7b(_0x1d1df3,_0x3cc141){_0x1d1df3=_0x1d1df3-0x70;const _0x56be5b=_0x56be();let _0x1a7bd8=_0x56be5b[_0x1d1df3];if(_0x1a7b['xJhRoT']===undefined){var _0x77f554=function(_0x165bf4){const _0x534a62='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x23b13b='',_0x5a9669='';for(let _0x5af117=0x0,_0x5d35fb,_0x9dad85,_0x508b06=0x0;_0x9dad85=_0x165bf4['charAt'](_0x508b06++);~_0x9dad85&&(_0x5d35fb=_0x5af117%0x4?_0x5d35fb*0x40+_0x9dad85:_0x9dad85,_0x5af117++%0x4)?_0x23b13b+=String['fromCharCode'](0xff&_0x5d35fb>>(-0x2*_0x5af117&0x6)):0x0){_0x9dad85=_0x534a62['indexOf'](_0x9dad85);}for(let _0x4d6e27=0x0,_0x4981ba=_0x23b13b['length'];_0x4d6e27<_0x4981ba;_0x4d6e27++){_0x5a9669+='%'+('00'+_0x23b13b['charCodeAt'](_0x4d6e27)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5a9669);};_0x1a7b['UdLlbN']=_0x77f554,_0x1a7b['tyIuMS']={},_0x1a7b['xJhRoT']=!![];}const _0x19ab5a=_0x56be5b[0x0],_0x23fc70=_0x1d1df3+_0x19ab5a,_0x541a36=_0x1a7b['tyIuMS'][_0x23fc70];return!_0x541a36?(_0x1a7bd8=_0x1a7b['UdLlbN'](_0x1a7bd8),_0x1a7b['tyIuMS'][_0x23fc70]=_0x1a7bd8):_0x1a7bd8=_0x541a36,_0x1a7bd8;}import{TurnFailedError}from'../chunk-FFIZ6TKW.js';import{OperationAbortedError,addAbortListener,isAbortError,throwIfAborted,toAbortError}from'../chunk-X7VAACWY.js';function createAbortAwareSemaphore(_0x23b13b){const _0x22a76e={_0x469a34:0x1a8,_0x570fc1:0x194,_0x324c8e:0x284,_0x403bf8:0x28e,_0x510799:0x28b},_0x1763eb={_0x58c201:0x2c0,_0x1c8f47:0x2c0,_0x21d6ef:0x2c6,_0x1326a8:0x2c8,_0x5743bc:0x18f,_0x370b07:0x18d,_0x37590d:0x18e,_0x4dc52c:0x2c1},_0x4e0546={_0x45950a:0x66,_0x3c0141:0x85,_0x2ed82c:0x87,_0x579a74:0x7d,_0x2b3ca0:0x75,_0x27f9cc:0x71,_0x30564e:0x7d,_0x1121c4:0x71,_0x3762ff:0x76},_0xac4afe={_0x367bce:0x1c4,_0x42ad18:0x5f9},_0x387a46={_0x5d0319:0x11c};if(!Number[_0x63ad76(_0x22a76e._0x469a34,0x196,0x1a0,_0x22a76e._0x570fc1)](_0x23b13b)||!Number[_0x1d0522(-_0x22a76e._0x324c8e,-0x28c,-_0x22a76e._0x403bf8,-_0x22a76e._0x510799)](_0x23b13b)||_0x23b13b<=0x0)throw new Error(_0x63ad76(0x195,0x19c,0x19f,0x1a7));let _0x5a9669=0x0;const _0x5af117=[],_0x5d35fb=()=>{let _0x508b06=![];return()=>{if(_0x508b06)return;_0x508b06=!![],_0x5a9669-=0x1,_0x9dad85();};};function _0x63ad76(_0x5aef93,_0x699e1c,_0x30c53b,_0x330c11){return _0x1a7b(_0x30c53b-_0x387a46._0x5d0319,_0x330c11);}const _0x9dad85=()=>{const _0x5c1663={_0x133fe8:0xa4};function _0x412f85(_0x218c0b,_0x23a791,_0x59f72b,_0x285af0){return _0x1d0522(_0x218c0b-_0xac4afe._0x367bce,_0x285af0-_0xac4afe._0x42ad18,_0x59f72b-0xc2,_0x23a791);}function _0x4321f2(_0xbbfc80,_0x34f378,_0x52debf,_0x25c282){return _0x63ad76(_0xbbfc80-_0x5c1663._0x133fe8,_0x34f378-0x1d8,_0x25c282- -0x209,_0x34f378);}while(_0x5af117[_0x4321f2(-0x6c,-0x71,-_0x4e0546._0x45950a,-0x70)]>0x0){const _0x4d6e27=_0x5af117['shift']();if(!_0x4d6e27||_0x4d6e27[_0x4321f2(-_0x4e0546._0x3c0141,-0x7c,-_0x4e0546._0x2ed82c,-_0x4e0546._0x579a74)])continue;_0x4d6e27[_0x4321f2(-_0x4e0546._0x2b3ca0,-0x81,-_0x4e0546._0x27f9cc,-_0x4e0546._0x30564e)]=!![],_0x4d6e27[_0x4321f2(-0x7b,-0x77,-_0x4e0546._0x1121c4,-_0x4e0546._0x3762ff)](),_0x5a9669+=0x1,_0x4d6e27['resolve'](_0x5d35fb());return;}};function _0x1d0522(_0x2f91bb,_0x4f962e,_0x198457,_0x23b4f4){return _0x1a7b(_0x4f962e- -0x2fe,_0x23b4f4);}return{'acquire'(_0x4981ba){const _0x2f17b4={_0xed0692:0x128,_0x249629:0x124},_0x138c10={_0xc21bba:0xc,_0x380654:0xb,_0x45c40f:0x0,_0x4ebb58:0x202,_0x7b61dd:0x10,_0x5c4476:0x6,_0x47dfb3:0x3,_0x5e5d8e:0xd,_0x3a2dca:0x3,_0x4b3e46:0x8},_0x235efc={_0x299b20:0x179,_0x45bee1:0xc},_0x5b7356={_0x48d2f9:0xab,_0x131c72:0x47,_0x14c728:0x28};function _0x1a3d9c(_0x478b18,_0x5a0adb,_0x3e900e,_0x557be2){return _0x1d0522(_0x478b18-_0x5b7356._0x48d2f9,_0x478b18- -_0x5b7356._0x131c72,_0x3e900e-_0x5b7356._0x14c728,_0x557be2);}if(_0x4981ba?.[_0x1a3d9c(-_0x1763eb._0x58c201,-0x2c7,-_0x1763eb._0x1c8f47,-_0x1763eb._0x21d6ef)])return Promise[_0x1a3d9c(-0x2c7,-_0x1763eb._0x1326a8,-0x2bd,-0x2c4)](toAbortError(_0x4981ba[_0x2d310d(0x188,_0x1763eb._0x5743bc,_0x1763eb._0x370b07,_0x1763eb._0x37590d)]));if(_0x5a9669<_0x23b13b)return _0x5a9669+=0x1,Promise[_0x1a3d9c(-0x2cb,-0x2ce,-_0x1763eb._0x4dc52c,-0x2c8)](_0x5d35fb());function _0x2d310d(_0x228691,_0x48e8bb,_0x3bd1b9,_0x2a62fc){return _0x63ad76(_0x228691-_0x235efc._0x299b20,_0x48e8bb-0x61,_0x228691- -_0x235efc._0x45bee1,_0x3bd1b9);}return new Promise((_0x64d9e6,_0x12dc6b)=>{const _0x4fcd95={_0x2d34aa:0x124},_0x7c80d8={_0xdaf987:0x1c5,_0x213fe5:0x116},_0x46ce52={_0x2d64cd:0x20c,_0x516b14:0x1aa};function _0x10d58b(_0x579113,_0x5a9f4c,_0x28d6f2,_0x153b36){return _0x1a3d9c(_0x28d6f2-0x3eb,_0x5a9f4c-0x1dd,_0x28d6f2-0x139,_0x153b36);}function _0x1fcdba(_0x3061c3,_0x178a86,_0x326b96,_0x4e601d){return _0x1a3d9c(_0x3061c3-_0x46ce52._0x2d64cd,_0x178a86-0x16b,_0x326b96-_0x46ce52._0x516b14,_0x178a86);}const _0x3c72c8={'resolve':_0x64d9e6,'reject':_0x12dc6b,'cancelled':![],'removeAbortListener':()=>{}};_0x5af117[_0x10d58b(0x12b,0x125,_0x2f17b4._0xed0692,0x131)](_0x3c72c8),_0x3c72c8[_0x10d58b(_0x2f17b4._0x249629,0x128,0x11d,0x116)]=addAbortListener(_0x4981ba,()=>{if(_0x3c72c8[_0x241e9e(_0x138c10._0xc21bba,-_0x138c10._0x380654,0xb,_0x138c10._0x45c40f)])return;_0x3c72c8[_0x146b4b(0x20a,0x201,_0x138c10._0x4ebb58,_0x138c10._0x4ebb58)]=!![],_0x3c72c8[_0x146b4b(0x207,0x204,0x205,0x209)]();function _0x241e9e(_0x2cbaba,_0x5cca14,_0x323388,_0x451f2f){return _0x10d58b(_0x2cbaba-_0x7c80d8._0xdaf987,_0x5cca14-0x38,_0x451f2f- -_0x7c80d8._0x213fe5,_0x323388);}const _0x30859c=_0x5af117['indexOf'](_0x3c72c8);if(_0x30859c>=0x0)_0x5af117[_0x241e9e(_0x138c10._0x7b61dd,0x9,_0x138c10._0x5c4476,0xf)](_0x30859c,0x1);function _0x146b4b(_0x399cd7,_0x2f1717,_0x2458f4,_0x5ea300){return _0x1fcdba(_0x5ea300-0x2cb,_0x2458f4,_0x2458f4-_0x4fcd95._0x2d34aa,_0x5ea300-0x104);}_0x3c72c8[_0x241e9e(_0x138c10._0x47dfb3,0x3,0xd,0xe)](toAbortError(_0x4981ba?.[_0x241e9e(_0x138c10._0x5e5d8e,_0x138c10._0xc21bba,-_0x138c10._0x3a2dca,_0x138c10._0x4b3e46)]));});});}};}export{OperationAbortedError,TurnFailedError,addAbortListener,createAbortAwareSemaphore,isAbortError,modelIdentityFromParts,resolveAnthropicReasoningConfig,resolveOpenAiReasoningConfig,throwIfAborted,toAbortError};
@@ -1,5 +1,4 @@
1
- import type { AnthropicThinkingConfig, AutoReasoningEffort, OpenAiReasoningConfig, ReasoningConfig } from "./types.ts";
2
- export declare function mapAutoReasoningEffortToBudgetTokens(effort: AutoReasoningEffort): number;
3
- export declare function resolveAnthropicThinkingConfig(reasoning: ReasoningConfig | undefined): AnthropicThinkingConfig | undefined;
4
- export declare function resolveOpenAiReasoningConfig(reasoning: ReasoningConfig | undefined): OpenAiReasoningConfig | undefined;
1
+ import type { AnthropicReasoningConfig, CodexReasoningConfig, OpenAiReasoningConfig, ReasoningConfig } from "./types.ts";
2
+ export declare function resolveAnthropicReasoningConfig(reasoning: ReasoningConfig | undefined): AnthropicReasoningConfig | undefined;
3
+ export declare function resolveOpenAiReasoningConfig(reasoning: ReasoningConfig | undefined): CodexReasoningConfig | OpenAiReasoningConfig | undefined;
5
4
  //# sourceMappingURL=reasoning-config.d.ts.map
@@ -4,9 +4,10 @@ export interface JsonObject {
4
4
  }
5
5
  export type JsonValue = JsonObject | JsonPrimitive | JsonValue[];
6
6
  export type JsonSchemaType = "array" | "boolean" | "number" | "object" | "string";
7
- export interface JsonSchemaString {
7
+ export interface JsonSchemaString<TEnum extends readonly string[] | undefined = readonly string[] | undefined> {
8
8
  type: "string";
9
9
  description?: string;
10
+ enum?: TEnum;
10
11
  }
11
12
  export interface JsonSchemaNumber {
12
13
  type: "number";
@@ -22,8 +23,12 @@ export interface JsonSchemaObject<TProperties extends Record<string, JsonSchema>
22
23
  type: "object";
23
24
  properties: TProperties;
24
25
  required?: TRequired;
26
+ additionalProperties?: boolean;
25
27
  }
26
- export type JsonSchema = JsonSchemaArray | JsonSchemaBoolean | JsonSchemaNumber | JsonSchemaObject | JsonSchemaString;
28
+ export interface JsonSchemaAnyOf<TVariants extends readonly JsonSchema[] = readonly JsonSchema[]> {
29
+ anyOf: TVariants;
30
+ }
31
+ export type JsonSchema = JsonSchemaAnyOf | JsonSchemaArray | JsonSchemaBoolean | JsonSchemaNumber | JsonSchemaObject | JsonSchemaString;
27
32
  export interface TextBlock {
28
33
  type: "text";
29
34
  text: string;
@@ -82,12 +87,8 @@ export interface AnthropicRedactedThinkingWireBlock {
82
87
  }
83
88
  export type AnthropicAssistantContentBlock = AnthropicRedactedThinkingWireBlock | AnthropicThinkingWireBlock | TextBlock | ToolUseBlock;
84
89
  export type ReasoningVisibility = "continuity-only" | "user-visible";
85
- export type AutoReasoningEffort = "low" | "medium" | "high";
86
- export interface AutoReasoningConfig {
87
- effort: AutoReasoningEffort;
88
- }
89
90
  export type AnthropicThinkingDisplay = "omitted" | "summarized";
90
- export type AnthropicThinkingEffort = "low" | "medium" | "high";
91
+ export type AnthropicThinkingEffort = "low" | "medium" | "high" | "xhigh" | "max";
91
92
  export interface AnthropicEnabledThinkingConfig {
92
93
  type: "enabled";
93
94
  budgetTokens: number;
@@ -97,23 +98,29 @@ export interface AnthropicEnabledThinkingConfig {
97
98
  export interface AnthropicAdaptiveThinkingConfig {
98
99
  type: "adaptive";
99
100
  display?: AnthropicThinkingDisplay;
100
- effort?: AnthropicThinkingEffort;
101
101
  interleaved?: boolean;
102
102
  }
103
103
  export interface AnthropicDisabledThinkingConfig {
104
104
  type: "disabled";
105
105
  }
106
106
  export type AnthropicThinkingConfig = AnthropicAdaptiveThinkingConfig | AnthropicDisabledThinkingConfig | AnthropicEnabledThinkingConfig;
107
- export type OpenAiReasoningEffort = "high" | "low" | "medium" | "minimal" | "none" | "xhigh";
107
+ export interface AnthropicReasoningConfig {
108
+ thinking: AnthropicThinkingConfig;
109
+ effort?: AnthropicThinkingEffort;
110
+ }
111
+ export type OpenAiReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
108
112
  export type OpenAiReasoningSummary = "auto" | "concise" | "detailed";
109
113
  export interface OpenAiReasoningConfig {
110
114
  effort?: OpenAiReasoningEffort;
111
115
  includeEncryptedContent?: boolean;
112
116
  summary?: OpenAiReasoningSummary;
113
117
  }
118
+ export interface CodexReasoningConfig {
119
+ effort: string;
120
+ }
114
121
  export interface ReasoningConfig {
115
- auto?: AutoReasoningConfig;
116
- anthropic?: AnthropicThinkingConfig;
122
+ anthropic?: AnthropicReasoningConfig;
123
+ codex?: CodexReasoningConfig;
117
124
  openai?: OpenAiReasoningConfig;
118
125
  visibility?: ReasoningVisibility;
119
126
  }
@@ -121,6 +128,7 @@ export interface MessageProviderState {
121
128
  anthropicAssistantContent?: AnthropicAssistantContentBlock[];
122
129
  openaiResponsesOutput?: OpenAiResponsesOutputItem[];
123
130
  openaiResponsesResponseId?: string;
131
+ originModelIdentity?: string;
124
132
  }
125
133
  export type AssistantContentBlock = AnthropicRedactedThinkingBlock | AnthropicThinkingBlock | OpenAiReasoningBlock | TextBlock | ToolUseBlock;
126
134
  export type ContentBlock = AssistantContentBlock | ImageBlock | ToolResultBlock;
@@ -168,6 +176,8 @@ export interface ModelRequest {
168
176
  metadata: {
169
177
  session_id: string;
170
178
  turn_id: string;
179
+ model_identity?: string;
180
+ pricing_provider_id?: string;
171
181
  };
172
182
  outputFormat?: OutputFormat;
173
183
  }
@@ -191,20 +201,44 @@ export interface ChatRequest {
191
201
  metadata: {
192
202
  sessionId: string;
193
203
  turnId: string;
204
+ modelIdentity?: string;
205
+ pricingProviderId?: string;
194
206
  };
195
207
  outputFormat?: OutputFormat;
196
208
  }
209
+ export interface ReportedModelCost {
210
+ amountUsdTicks: number;
211
+ source: "openrouter" | "xai";
212
+ }
213
+ export interface EstimatedModelCost {
214
+ amountUsdTicks: number;
215
+ source: "models.dev";
216
+ pricingSnapshotId: string;
217
+ pricingProviderIds: readonly string[];
218
+ pricingModelId: string;
219
+ matchKind: "provider-model" | "model-unique" | "model-identical";
220
+ }
221
+ export interface ChatResponseUsage {
222
+ inputTokens: number;
223
+ outputTokens: number;
224
+ reasoningTokens?: number;
225
+ cacheReadInputTokens?: number;
226
+ cacheCreationInputTokens?: number;
227
+ reportedCost?: ReportedModelCost;
228
+ estimatedCost?: EstimatedModelCost;
229
+ }
230
+ export interface PersistedModelCallMetricsV1 {
231
+ version: 1;
232
+ usage: ChatResponseUsage;
233
+ modelTimeMs: number;
234
+ completesRequest: boolean;
235
+ }
236
+ export type PersistedModelCallMetrics = PersistedModelCallMetricsV1;
197
237
  export interface ChatResponse {
198
238
  id: string;
199
239
  content: AssistantContentBlock[];
200
240
  stopReason: "end_turn" | "tool_use";
201
- usage: {
202
- inputTokens: number;
203
- outputTokens: number;
204
- reasoningTokens?: number;
205
- cacheReadInputTokens?: number;
206
- cacheCreationInputTokens?: number;
207
- };
241
+ usage: ChatResponseUsage;
208
242
  providerState?: MessageProviderState;
209
243
  }
210
244
  export interface ContentDeltaChunk {
@@ -300,6 +334,7 @@ export interface TurnInput {
300
334
  system?: SystemInput;
301
335
  messages?: MessageInput[];
302
336
  message: MessageInput;
337
+ drainSteering?: () => Promise<MessageInput[]>;
303
338
  }
304
339
  export interface TurnState {
305
340
  sessionId: string;
@@ -366,6 +401,8 @@ export interface ModelExecutionOptions {
366
401
  export interface TurnMessageMeta {
367
402
  provider?: string;
368
403
  model?: string;
404
+ modelIdentity?: string;
405
+ metrics?: PersistedModelCallMetrics;
369
406
  /** ms epoch — provider request sent. */
370
407
  turnStartedAt?: number;
371
408
  /** ms epoch — response fully received. */
@@ -380,6 +417,7 @@ export interface EngineChatModel {
380
417
  modelIdentity: string;
381
418
  provider?: string;
382
419
  maxTokens?: number;
420
+ readonly pricingProviderId?: string;
383
421
  complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
384
422
  stream?(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
385
423
  getModels?(signal?: AbortSignal): Promise<ModelInfo[]>;
@@ -388,6 +426,7 @@ export interface BaseChatModelOptions {
388
426
  model: string;
389
427
  modelIdentity?: string;
390
428
  maxTokens?: number;
429
+ pricingProviderId?: string;
391
430
  reasoning?: ReasoningConfig;
392
431
  providerSessionResolver?: ProviderSessionResolver;
393
432
  requestMutators?: ProviderRequestMutator[];
@@ -413,12 +452,22 @@ export type AskUserQuestionRequest = {
413
452
  questionId: string;
414
453
  questions: AskUserQuestion[];
415
454
  };
455
+ export type ToolPermissionClass = "read" | "write" | "always-confirm";
416
456
  export interface ToolExecutionContext extends AgentEventContext {
417
457
  signal: AbortSignal;
418
458
  toolCallId?: string;
459
+ permissionClass?: ToolPermissionClass;
460
+ executionAuthorization?: unknown;
419
461
  askUser?: (request: AskUserQuestionRequest) => Promise<AskUserAnswers>;
420
462
  setTopic?: (topic: string) => void;
421
463
  }
464
+ export interface BashExecutionTarget {
465
+ command: string;
466
+ cwd: string;
467
+ shellPath: string;
468
+ dialect: "bash" | "posix" | "windows" | "unknown";
469
+ background: boolean;
470
+ }
422
471
  export interface ToolRuntimeStartedEvent {
423
472
  type: "tool_started";
424
473
  toolCall: ToolUseBlock;
@@ -449,6 +498,8 @@ export interface AgentModelRequestEvent {
449
498
  }
450
499
  export interface AgentModelResponseEvent {
451
500
  type: "model_response";
501
+ /** Exact provider/model-call duration measured by the turn engine. */
502
+ modelTimeMs?: number;
452
503
  response: ChatResponse;
453
504
  }
454
505
  export interface AgentAssistantMessageEvent {
@@ -520,6 +571,9 @@ export type ToolRuntimeDispatchDecision = {
520
571
  dir: string;
521
572
  persist: boolean;
522
573
  };
574
+ executionAuthorization?: unknown;
575
+ approvalDecision?: "y" | "a" | "t";
576
+ approvalSource?: "policy" | "remembered" | "sudo" | "user";
523
577
  };
524
578
  export type ToolRuntimeToolCallHandler = (toolCall: ToolUseBlock, ctx: ToolExecutionContext) => Promise<ToolRuntimeDispatchDecision | undefined> | ToolRuntimeDispatchDecision | undefined;
525
579
  export type ToolRuntimeEventHandler = (event: ToolRuntimeEvent, ctx: ToolExecutionContext) => Promise<void> | void;
@@ -530,10 +584,14 @@ export interface ToolRuntime {
530
584
  executeCalls(toolCalls: ToolUseBlock[], ctx: ToolExecutionContext): Promise<ToolResult[]>;
531
585
  execute(toolCall: ToolUseBlock, ctx: ToolExecutionContext): Promise<ToolResult>;
532
586
  }
533
- export type InferJsonSchema<TSchema extends JsonSchema> = TSchema extends JsonSchemaString ? string : TSchema extends JsonSchemaNumber ? number : TSchema extends JsonSchemaBoolean ? boolean : TSchema extends JsonSchemaArray<infer TItem> ? InferJsonSchema<TItem>[] : TSchema extends JsonSchemaObject<infer TProperties, infer TRequired> ? Expand<RequiredProperties<TProperties, TRequired> & OptionalProperties<TProperties, TRequired>> : never;
587
+ export type InferJsonSchema<TSchema extends JsonSchema> = TSchema extends JsonSchemaAnyOf<infer TVariants> ? JsonSchema extends TVariants[number] ? JsonValue : InferJsonSchemaAnyOf<TVariants> : TSchema extends JsonSchemaString<infer TEnum> ? TEnum extends readonly string[] ? TEnum[number] : string : TSchema extends JsonSchemaNumber ? number : TSchema extends JsonSchemaBoolean ? boolean : TSchema extends JsonSchemaArray<infer TItem> ? InferJsonSchema<TItem>[] : TSchema extends JsonSchemaObject<infer TProperties, infer TRequired> ? Expand<RequiredProperties<TProperties, TRequired> & OptionalProperties<TProperties, TRequired>> : never;
534
588
  type Expand<TValue> = TValue extends infer TObject ? {
535
589
  [TKey in keyof TObject]: TObject[TKey];
536
590
  } : never;
591
+ type JsonSchemaObjectPropertyKeys<TSchema extends JsonSchema> = TSchema extends JsonSchemaObject<infer TProperties> ? Extract<keyof TProperties, string> : never;
592
+ type InferJsonSchemaAnyOfVariant<TVariant extends JsonSchema, TAllVariants extends JsonSchema> = TVariant extends JsonSchemaObject<infer TProperties, infer TRequired> ? Expand<RequiredProperties<TProperties, TRequired> & OptionalProperties<TProperties, TRequired> & (TVariant["additionalProperties"] extends false ? Partial<Record<Exclude<JsonSchemaObjectPropertyKeys<TAllVariants>, keyof TProperties>, never>> : Record<never, never>)> : InferJsonSchema<TVariant>;
593
+ type InferJsonSchemaAnyOfVariants<TVariant extends JsonSchema, TAllVariants extends JsonSchema> = TVariant extends JsonSchema ? InferJsonSchemaAnyOfVariant<TVariant, TAllVariants> : never;
594
+ type InferJsonSchemaAnyOf<TVariants extends readonly JsonSchema[]> = InferJsonSchemaAnyOfVariants<TVariants[number], TVariants[number]>;
537
595
  type RequiredKeyUnion<TRequired extends readonly string[] | undefined> = TRequired extends readonly string[] ? TRequired[number] : never;
538
596
  type OptionalKeyUnion<TProperties extends Record<string, JsonSchema>, TRequired extends readonly string[] | undefined> = Exclude<keyof TProperties, RequiredKeyUnion<TRequired>>;
539
597
  type RequiredProperties<TProperties extends Record<string, JsonSchema>, TRequired extends readonly string[] | undefined> = {
@@ -544,13 +602,19 @@ type OptionalProperties<TProperties extends Record<string, JsonSchema>, TRequire
544
602
  };
545
603
  export type ToolOutputValue = JsonValue | ToolOutputEnvelope;
546
604
  export type ToolGenerator<TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined> = AsyncGenerator<TYield, TReturn, void>;
547
- export interface ToolDefinition<TInput extends JsonObject = JsonObject, TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined, TSchema extends JsonSchemaObject = JsonSchemaObject> {
605
+ /** Internal resource lifetime contract; omitted from model-facing tool schemas and messages. */
606
+ export interface ToolDefinitionLifecycle {
607
+ acquire(): () => void;
608
+ }
609
+ export interface ToolDefinition<TInput extends object = JsonObject, TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined, TSchema extends JsonSchemaObject = JsonSchemaObject> {
548
610
  name: string;
549
611
  description: string;
550
612
  inputSchema: TSchema;
613
+ permissionClass?: ToolPermissionClass;
614
+ internalLifecycle?: ToolDefinitionLifecycle;
551
615
  execute(input: TInput, ctx: ToolExecutionContext): ToolGenerator<TYield, TReturn>;
552
616
  }
553
- export type AnyToolDefinition = ToolDefinition<JsonObject, ToolOutputValue, ToolOutputValue | undefined, JsonSchemaObject>;
617
+ export type AnyToolDefinition = ToolDefinition<object, ToolOutputValue, ToolOutputValue | undefined, JsonSchemaObject>;
554
618
  export type TransformableStage = "afterModelResponse" | "afterToolResult" | "beforeAssistantAppend" | "beforeFinalOutput" | "beforeModelRequest" | "beforeToolExecution" | "beforeToolResultAppend" | "onUserMessage";
555
619
  export type ObserverOnlyStage = "afterMessageAppend" | "afterTurnComplete";
556
620
  export type Stage = ObserverOnlyStage | TransformableStage;
@@ -587,6 +651,8 @@ export interface ObserverExtensionRegistration<S extends Stage = Stage> {
587
651
  kind: "observer";
588
652
  order: number;
589
653
  enabled: boolean;
654
+ /** Runs after every enabled non-terminal observer registered for this stage. */
655
+ terminal?: boolean;
590
656
  run: Observer<S>;
591
657
  }
592
658
  export type AnyExtensionRegistration = {
@@ -610,9 +676,19 @@ export interface RunTurnDeps {
610
676
  outputFormat?: OutputFormat;
611
677
  }
612
678
  export type AgentInput = MessageInput | string;
679
+ export type SteeringInputDrain = () => Promise<AgentInput[]>;
680
+ /** Immutable ownership metadata for the exact agent submission being sent. */
681
+ export type AgentSubmission = Readonly<{
682
+ origin: "user";
683
+ }> | Readonly<{
684
+ origin: "coordinator";
685
+ token: string;
686
+ }>;
613
687
  export interface AgentSendOptions {
614
688
  streaming?: boolean;
615
689
  signal?: AbortSignal;
690
+ drainSteering?: SteeringInputDrain;
691
+ submission?: AgentSubmission;
616
692
  }
617
693
  export interface AgentOptions {
618
694
  sessionId?: string;
@@ -747,7 +823,7 @@ export interface OpenAiReasoningOutputItem {
747
823
  }
748
824
  export type OpenAiResponsesOutputItem = JsonObject | OpenAiFunctionCall | OpenAiOutputMessage | OpenAiReasoningOutputItem;
749
825
  export interface OpenAiResponsesReasoningParam {
750
- effort?: OpenAiReasoningEffort;
826
+ effort?: string;
751
827
  generate_summary?: OpenAiReasoningSummary;
752
828
  summary?: OpenAiReasoningSummary;
753
829
  }
@@ -1,4 +1,4 @@
1
- import type { AnyToolDefinition, ToolRuntime, ToolRuntimeEventHandler, ToolRuntimeToolCallHandler } from "../shared/types.ts";
1
+ import type { AnyToolDefinition, ToolRuntime, ToolRuntimeEventHandler, ToolRuntimeToolCallHandler } from "../../shared/types.ts";
2
2
  interface InternalToolRuntimeOptions {
3
3
  onEvent?: ToolRuntimeEventHandler;
4
4
  onToolCall?: ToolRuntimeToolCallHandler;
@@ -0,0 +1,3 @@
1
+ import type { ToolRuntime } from "../../shared/types.ts";
2
+ export declare function createMockToolRuntime(): ToolRuntime;
3
+ //# sourceMappingURL=mock-tool-runtime.d.ts.map
@@ -0,0 +1,87 @@
1
+ import { Agent } from "../../agent/agent.ts";
2
+ import type { AbortAwareSemaphore } from "../../shared/abort-aware-semaphore.ts";
3
+ import type { AgentDefinitionFactoryContext, AgentOptions } from "../../shared/types.ts";
4
+ export interface DelegatedAgentFactoryContext extends AgentDefinitionFactoryContext {
5
+ parentSessionId: string;
6
+ runId: string;
7
+ signal: AbortSignal;
8
+ }
9
+ export type DelegatedAgentDefinition = AgentOptions | ((ctx: DelegatedAgentFactoryContext) => AgentOptions | Promise<AgentOptions>);
10
+ export interface CreateDelegationToolsOptions {
11
+ agents?: Record<string, DelegatedAgentDefinition>;
12
+ semaphore?: AbortAwareSemaphore;
13
+ /** Register an active child for shared tool refresh; returns its cleanup callback. */
14
+ registerActiveAgent?: (agent: Agent, context: DelegatedAgentFactoryContext) => () => void;
15
+ registerActiveRun?: (entry: {
16
+ runId: string;
17
+ abortController: AbortController;
18
+ completion: Promise<void>;
19
+ }) => () => void;
20
+ /** Render a resolved child prompt immediately before constructing its Agent. */
21
+ renderSystemPrompt?: (systemPrompt: string) => string;
22
+ /**
23
+ * Idempotent delegated-resource release (e.g. the run's observation store),
24
+ * invoked from the outer `finally` on EVERY terminal path: success, abort,
25
+ * factory rejection, `Agent` construction failure, and registration failure.
26
+ * The runtime wires this to its idempotent per-run store release, so the
27
+ * delegation factory's own failure-release may safely converge here.
28
+ */
29
+ releaseAgentResources?: (context: DelegatedAgentFactoryContext) => void;
30
+ }
31
+ export declare function resolveDelegatedAgentOptions(definition: DelegatedAgentDefinition, ctx: DelegatedAgentFactoryContext): Promise<AgentOptions>;
32
+ export declare function createAssignTaskTool(options: CreateDelegationToolsOptions): import("../../shared/types.ts").ToolDefinition<{
33
+ description: string;
34
+ agentId: string;
35
+ nickname: string;
36
+ task: string;
37
+ }, import("../../shared/types.ts").ToolOutputEnvelope, import("../../shared/types.ts").ToolOutputEnvelope, {
38
+ type: "object";
39
+ properties: {
40
+ agentId: {
41
+ type: "string";
42
+ description: string;
43
+ };
44
+ description: {
45
+ type: "string";
46
+ description: string;
47
+ };
48
+ nickname: {
49
+ type: "string";
50
+ description: string;
51
+ };
52
+ task: {
53
+ type: "string";
54
+ description: string;
55
+ };
56
+ };
57
+ required: string[];
58
+ }>;
59
+ export declare const createDelegateToAgentTool: typeof createAssignTaskTool;
60
+ export declare function createDelegationTools(options: CreateDelegationToolsOptions): import("../../shared/types.ts").ToolDefinition<{
61
+ description: string;
62
+ agentId: string;
63
+ nickname: string;
64
+ task: string;
65
+ }, import("../../shared/types.ts").ToolOutputEnvelope, import("../../shared/types.ts").ToolOutputEnvelope, {
66
+ type: "object";
67
+ properties: {
68
+ agentId: {
69
+ type: "string";
70
+ description: string;
71
+ };
72
+ description: {
73
+ type: "string";
74
+ description: string;
75
+ };
76
+ nickname: {
77
+ type: "string";
78
+ description: string;
79
+ };
80
+ task: {
81
+ type: "string";
82
+ description: string;
83
+ };
84
+ };
85
+ required: string[];
86
+ }>[];
87
+ //# sourceMappingURL=runtime-manager-tools.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { ToolResult } from "../shared/types.ts";
1
+ import type { ToolResult } from "../../shared/types.ts";
2
2
  export interface ToolOutputOffloadOptions {
3
3
  maxBytes: number;
4
4
  sessionDir?: string;
@@ -1,4 +1,4 @@
1
- import type { AnyToolDefinition, InferJsonSchema, JsonObject, JsonSchemaObject, JsonValue, ToolDefinition, ToolExecutionContext, ToolOutputEnvelope, ToolOutputValue, ToolResultChunk, ToolResultContent, ToolSchema } from "../shared/types.ts";
1
+ import type { AnyToolDefinition, InferJsonSchema, JsonObject, JsonSchemaObject, JsonValue, ToolDefinition, ToolDefinitionLifecycle, ToolExecutionContext, ToolOutputEnvelope, ToolOutputValue, ToolPermissionClass, ToolResultChunk, ToolResultContent, ToolSchema } from "../../shared/types.ts";
2
2
  export declare function normalizeToolOutputValue(output: ToolOutputValue): ToolResultChunk;
3
3
  export declare function createToolOutput(output: string, structured?: JsonObject, content?: ToolResultContent): ToolOutputEnvelope;
4
4
  export declare class ToolExecutionError extends Error {
@@ -9,8 +9,11 @@ export declare function defineTool<TSchema extends JsonSchemaObject, TYield exte
9
9
  name: string;
10
10
  description: string;
11
11
  inputSchema: TSchema;
12
+ permissionClass: ToolPermissionClass;
13
+ internalLifecycle?: ToolDefinitionLifecycle;
12
14
  execute(input: InferJsonSchema<TSchema>, ctx: ToolExecutionContext): AsyncGenerator<TYield, TReturn, void>;
13
15
  }): ToolDefinition<InferJsonSchema<TSchema>, TYield, TReturn, TSchema>;
16
+ export declare function resolveToolPermissionClass(tool: AnyToolDefinition | undefined): ToolPermissionClass;
14
17
  export declare class ToolRegistry {
15
18
  private readonly toolsByName;
16
19
  constructor(tools?: AnyToolDefinition[]);
@@ -0,0 +1,53 @@
1
+ import type { Stats } from "node:fs";
2
+ import type { ToolExecutionContext, ToolOutputEnvelope } from "../../shared/types.ts";
3
+ import { type CanonicalFileEditBlock, type CanonicalFileOperation } from "./anchored-file-operations.ts";
4
+ import type { FileMutationCoordinator } from "./file-mutation-coordinator.ts";
5
+ import type { FileObservationStore } from "./file-observation-store.ts";
6
+ import { type AnchoredFileEditMode } from "./structured-file-edit-adapter.ts";
7
+ /**
8
+ * Upper bound on the canonical preview text an edit may produce. Authored
9
+ * replacement content is already bounded by the adapters; this bound also
10
+ * caps source-derived `oldText` when a huge range is deleted/replaced so the
11
+ * approval preview stays small enough to audit.
12
+ */
13
+ export declare const MAX_ANCHORED_PREVIEW_BYTES: number;
14
+ export interface CanonicalFileEditPreview {
15
+ mode: AnchoredFileEditMode;
16
+ filePath: string;
17
+ canonicalPath: string;
18
+ tag: string;
19
+ digest: string;
20
+ operationCount: number;
21
+ operations: readonly CanonicalFileOperation[];
22
+ blocks: readonly CanonicalFileEditBlock[];
23
+ }
24
+ export interface AnchoredFileEditEnvironment {
25
+ defaultCwd: string;
26
+ allowedDirs: readonly string[];
27
+ observations: FileObservationStore;
28
+ mutations: FileMutationCoordinator;
29
+ outputBudgetBytes: number;
30
+ }
31
+ export interface AnchoredFileEditStructuredResult {
32
+ preview: CanonicalFileEditPreview;
33
+ beforeDigest: string;
34
+ afterDigest: string;
35
+ beforeTag: string;
36
+ afterTag: string;
37
+ bytesWritten: number;
38
+ dryRun: boolean;
39
+ operationCount: number;
40
+ tokenClassification: "edit";
41
+ }
42
+ /**
43
+ * Filesystem seams for under-lock execution tests. Production callers omit the
44
+ * argument and receive the default Node filesystem backed by `atomicReplaceFile`.
45
+ */
46
+ export interface AnchoredFileEditFileSystem {
47
+ readFile(path: string): Promise<Buffer>;
48
+ stat(path: string): Promise<Stats>;
49
+ atomicWrite(target: string, bytes: Uint8Array, mode: number): Promise<void>;
50
+ }
51
+ export declare function prepareAnchoredFileEditApproval(mode: AnchoredFileEditMode, input: unknown, sessionId: string, environment: Omit<AnchoredFileEditEnvironment, "mutations">): Promise<CanonicalFileEditPreview>;
52
+ export declare function executeAnchoredFileEdit(mode: AnchoredFileEditMode, input: unknown, context: ToolExecutionContext, environment: AnchoredFileEditEnvironment, fileSystem?: AnchoredFileEditFileSystem): Promise<ToolOutputEnvelope>;
53
+ //# sourceMappingURL=anchored-file-edit.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { JsonValue } from "../../shared/types.ts";
2
+ import { ToolExecutionError } from "../core/tools.ts";
3
+ export type AnchoredFileErrorCode = "invalid_patch" | "unknown_snapshot" | "ambiguous_snapshot_tag" | "stale_snapshot" | "unseen_lines" | "invalid_range" | "overlapping_operations" | "no_change" | "write_failed" | "post_write_drift";
4
+ export declare function createAnchoredFileError(code: AnchoredFileErrorCode, message: string, structured?: Record<string, JsonValue>): ToolExecutionError;
5
+ //# sourceMappingURL=anchored-file-errors.d.ts.map
@@ -0,0 +1,38 @@
1
+ import type { NormalizedFileSnapshot } from "./file-snapshot.ts";
2
+ export type CanonicalFileOperation = {
3
+ operation: "replace";
4
+ startLine: number;
5
+ endLine: number;
6
+ content: string;
7
+ } | {
8
+ operation: "delete";
9
+ startLine: number;
10
+ endLine: number;
11
+ } | {
12
+ operation: "insert";
13
+ position: "before" | "after";
14
+ line: number;
15
+ content: string;
16
+ };
17
+ export interface FileEditLineNumbers {
18
+ oldStartLine: number;
19
+ oldEndLine: number;
20
+ newStartLine: number;
21
+ newEndLine: number;
22
+ oldLineCount: number;
23
+ newLineCount: number;
24
+ }
25
+ export interface CanonicalFileEditBlock {
26
+ oldText: string;
27
+ newText: string;
28
+ lineNumbers: FileEditLineNumbers;
29
+ }
30
+ export interface PreparedCanonicalFileEdit {
31
+ afterText: string;
32
+ operations: readonly CanonicalFileOperation[];
33
+ blocks: readonly CanonicalFileEditBlock[];
34
+ requiredLines: readonly number[];
35
+ payloadDigest: string;
36
+ }
37
+ export declare function prepareCanonicalFileEdit(snapshot: NormalizedFileSnapshot, observedLines: ReadonlySet<number>, operations: readonly CanonicalFileOperation[]): PreparedCanonicalFileEdit;
38
+ //# sourceMappingURL=anchored-file-operations.d.ts.map