@nuvin/agent-core 0.2.0-rc.1 → 0.2.0-rc.11

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 (95) 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-KIIEBXJF.js +1 -0
  9. package/dist/chunk-LIE76IJA.js +1 -0
  10. package/dist/chunk-X7VAACWY.js +1 -1
  11. package/dist/chunk-YNOIG4FD.js +1 -0
  12. package/dist/formats/index.js +1 -1
  13. package/dist/hooks/index.js +1 -1
  14. package/dist/lsp/client.d.ts +4 -0
  15. package/dist/models/chat-model.d.ts +1 -0
  16. package/dist/models/index.d.ts +3 -0
  17. package/dist/models/index.js +1 -1
  18. package/dist/models/mock-model.d.ts +2 -0
  19. package/dist/models/model-cost.d.ts +5 -0
  20. package/dist/models/model-pricing-generator.d.ts +9 -0
  21. package/dist/models/model-pricing-products.d.ts +45 -0
  22. package/dist/models/model-pricing-types.d.ts +33 -0
  23. package/dist/models/model-pricing.d.ts +13 -0
  24. package/dist/models/model-pricing.generated.d.ts +23147 -0
  25. package/dist/models/model-registry.d.ts +8 -0
  26. package/dist/models/openai-surfaces.d.ts +4 -1
  27. package/dist/models/routed-model.d.ts +3 -0
  28. package/dist/shared/abort-aware-semaphore.d.ts +5 -0
  29. package/dist/shared/index.d.ts +1 -0
  30. package/dist/shared/index.js +1 -1
  31. package/dist/shared/reasoning-config.d.ts +3 -4
  32. package/dist/shared/types.d.ts +105 -24
  33. package/dist/tools/{internal-tool-runtime.d.ts → core/internal-tool-runtime.d.ts} +1 -1
  34. package/dist/tools/core/mock-tool-runtime.d.ts +3 -0
  35. package/dist/tools/core/runtime-manager-tools.d.ts +87 -0
  36. package/dist/tools/{tool-output-offload.d.ts → core/tool-output-offload.d.ts} +1 -1
  37. package/dist/tools/{tools.d.ts → core/tools.d.ts} +4 -1
  38. package/dist/tools/file-editing/anchored-file-edit.d.ts +53 -0
  39. package/dist/tools/file-editing/anchored-file-errors.d.ts +5 -0
  40. package/dist/tools/file-editing/anchored-file-operations.d.ts +38 -0
  41. package/dist/tools/file-editing/anchored-file-read.d.ts +37 -0
  42. package/dist/tools/file-editing/atomic-file-write.d.ts +19 -0
  43. package/dist/tools/file-editing/file-edit-tool.d.ts +166 -0
  44. package/dist/tools/file-editing/file-mutation-coordinator.d.ts +13 -0
  45. package/dist/tools/file-editing/file-mutation.d.ts +15 -0
  46. package/dist/tools/{file-new-tool.d.ts → file-editing/file-new-tool.d.ts} +5 -2
  47. package/dist/tools/file-editing/file-observation-store.d.ts +40 -0
  48. package/dist/tools/{file-read-tool.d.ts → file-editing/file-read-tool.d.ts} +8 -2
  49. package/dist/tools/file-editing/file-snapshot.d.ts +16 -0
  50. package/dist/tools/file-editing/hashline-file-edit-adapter.d.ts +19 -0
  51. package/dist/tools/file-editing/structured-file-edit-adapter.d.ts +94 -0
  52. package/dist/tools/file-editing/workspace-paths.d.ts +20 -0
  53. package/dist/tools/index.d.ts +43 -29
  54. package/dist/tools/index.js +1 -1
  55. package/dist/tools/mcp/mcp-connection-generation.d.ts +59 -0
  56. package/dist/tools/mcp/mcp-safe-error-provenance.d.ts +4 -0
  57. package/dist/tools/mcp/mcp-safe-error.d.ts +14 -0
  58. package/dist/tools/mcp/mcp-server-manager.d.ts +16 -0
  59. package/dist/tools/mcp/mcp-tool-adapter.d.ts +72 -0
  60. package/dist/tools/{glob-tool.d.ts → search/glob-tool.d.ts} +2 -2
  61. package/dist/tools/search/grep-engine.d.ts +22 -0
  62. package/dist/tools/{grep-tool.d.ts → search/grep-tool.d.ts} +3 -3
  63. package/dist/tools/{ls-tool.d.ts → search/ls-tool.d.ts} +2 -2
  64. package/dist/tools/{ripgrep.d.ts → search/ripgrep.d.ts} +1 -0
  65. package/dist/tools/{view-file-tool.d.ts → search/view-file-tool.d.ts} +2 -2
  66. package/dist/tools/{ask-user-tool.d.ts → session/ask-user-tool.d.ts} +2 -2
  67. package/dist/tools/{lsp-tool.d.ts → session/lsp-tool.d.ts} +5 -5
  68. package/dist/tools/{skill-tool.d.ts → session/skill-tool.d.ts} +2 -2
  69. package/dist/tools/{todo-write-tool.d.ts → session/todo-write-tool.d.ts} +2 -2
  70. package/dist/tools/session/update-topic-tool.d.ts +12 -0
  71. package/dist/tools/shell/background-process-registry.d.ts +116 -0
  72. package/dist/tools/{bash-output-tool.d.ts → shell/bash-output-tool.d.ts} +2 -2
  73. package/dist/tools/{bash-tool.d.ts → shell/bash-tool.d.ts} +10 -6
  74. package/dist/tools/{command-tool.d.ts → shell/command-tool.d.ts} +2 -2
  75. package/dist/tools/{kill-shell-tool.d.ts → shell/kill-shell-tool.d.ts} +2 -2
  76. package/dist/tools/shell/process-tree-termination.d.ts +25 -0
  77. package/dist/tools/shell/terminal-output-normalizer.d.ts +6 -0
  78. package/dist/tools/{web-fetch-tool.d.ts → web/web-fetch-tool.d.ts} +2 -2
  79. package/dist/tools/{web-search-tool.d.ts → web/web-search-tool.d.ts} +2 -2
  80. package/package.json +4 -3
  81. package/dist/chunk-E4R6CEFK.js +0 -1
  82. package/dist/chunk-NYZR4XKO.js +0 -1
  83. package/dist/chunk-RABU4RC2.js +0 -1
  84. package/dist/chunk-RTDLM6FU.js +0 -1
  85. package/dist/tools/background-process-registry.d.ts +0 -64
  86. package/dist/tools/file-edit-tool.d.ts +0 -34
  87. package/dist/tools/mcp-server-manager.d.ts +0 -60
  88. package/dist/tools/mcp-tool-adapter.d.ts +0 -47
  89. package/dist/tools/mock-tool-runtime.d.ts +0 -3
  90. package/dist/tools/runtime-manager-tools.d.ts +0 -58
  91. package/dist/tools/update-topic-tool.d.ts +0 -12
  92. package/dist/tools/workspace-paths.d.ts +0 -5
  93. /package/dist/tools/{mcp-oauth-provider.d.ts → mcp/mcp-oauth-provider.d.ts} +0 -0
  94. /package/dist/tools/{bash-internals.d.ts → shell/bash-internals.d.ts} +0 -0
  95. /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(_0x1a44ae,_0x4b642c){var _0x1769c9={_0x2059bc:0x263,_0x38ba40:0x267,_0xf31b37:0x26b,_0x29ef54:0x26a,_0x42fa9f:0x269,_0x3c7788:0x262,_0x120428:0x261,_0xc4fb5d:0x224,_0x19adf5:0x21f,_0x2f92dd:0x21e,_0x2b2d28:0x266,_0x59f9ca:0x265,_0x4f2921:0x264,_0x38a5ed:0x227,_0x47f7a3:0x21d,_0x210ff3:0x222,_0x49b3aa:0x228,_0x48b494:0x223,_0x661105:0x272,_0x1c67da:0x26c,_0x212a38:0x21c,_0x56f2d4:0x21a,_0x417d50:0x220,_0x108f40:0x268},_0x13548a={_0x32b835:0x395},_0x524750=_0x1a44ae();function _0x2612ef(_0x507809,_0x3168d3,_0x388964,_0x8067bf){return _0x4438(_0x388964-0xf3,_0x8067bf);}function _0x4d3df5(_0x1461e6,_0xc32b9f,_0x5c9ca0,_0x58377a){return _0x4438(_0x5c9ca0- -_0x13548a._0x32b835,_0x1461e6);}while(!![]){try{var _0x501036=parseInt(_0x4d3df5(-0x26c,-_0x1769c9._0x2059bc,-_0x1769c9._0x38ba40,-_0x1769c9._0xf31b37))/0x1+parseInt(_0x4d3df5(-0x26d,-_0x1769c9._0x29ef54,-0x26b,-_0x1769c9._0x42fa9f))/0x2+-parseInt(_0x4d3df5(-_0x1769c9._0x3c7788,-_0x1769c9._0x120428,-0x262,-0x265))/0x3*(parseInt(_0x2612ef(0x220,_0x1769c9._0xc4fb5d,_0x1769c9._0x19adf5,_0x1769c9._0x2f92dd))/0x4)+parseInt(_0x4d3df5(-0x260,-_0x1769c9._0x2b2d28,-_0x1769c9._0x59f9ca,-_0x1769c9._0x4f2921))/0x5+-parseInt(_0x2612ef(_0x1769c9._0x38a5ed,_0x1769c9._0x47f7a3,_0x1769c9._0x210ff3,0x228))/0x6*(parseInt(_0x2612ef(_0x1769c9._0x49b3aa,0x223,0x225,_0x1769c9._0x48b494))/0x7)+-parseInt(_0x4d3df5(-0x269,-_0x1769c9._0x661105,-_0x1769c9._0x1c67da,-0x26a))/0x8*(-parseInt(_0x2612ef(_0x1769c9._0x212a38,_0x1769c9._0x56f2d4,_0x1769c9._0x417d50,0x224))/0x9)+-parseInt(_0x2612ef(0x221,0x222,0x224,0x227))/0xa*(parseInt(_0x4d3df5(-_0x1769c9._0x108f40,-0x26f,-0x26a,-0x26e))/0xb);if(_0x501036===_0x4b642c)break;else _0x524750['push'](_0x524750['shift']());}catch(_0x440116){_0x524750['push'](_0x524750['shift']());}}}(_0x212a,0x20f04));import{modelIdentityFromParts}from'../chunk-D5IVWJHX.js';function _0x212a(){var _0x47964d=['mZG1ntv2tvzXtwy','mJb6wurgDhm','mtHrzKj1vMC','mty2mdK5vgretMzs','nZj6yKLzr2q','mti3ndu0mhnWwfzNuW','ntiWsMzitvff','mteYnZKXB2rfzgje','nJC5odLdCurzqwq','mJq2ndmYDgfVs01j','mJGYndy0D0Loz21q'];_0x212a=function(){return _0x47964d;};return _0x212a();}import{mapAutoReasoningEffortToBudgetTokens,resolveAnthropicThinkingConfig,resolveOpenAiReasoningConfig}from'../chunk-NYZR4XKO.js';function _0x4438(_0x2c8eb2,_0x4df041){_0x2c8eb2=_0x2c8eb2-0x129;var _0x212a73=_0x212a();var _0x4438d8=_0x212a73[_0x2c8eb2];if(_0x4438['FKnJEj']===undefined){var _0x348666=function(_0x1469e8){var _0x2177cf='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x3b5833='',_0x4d09b2='';for(var _0x48a4d9=0x0,_0x1baa76,_0x5cbaf4,_0xd85d51=0x0;_0x5cbaf4=_0x1469e8['charAt'](_0xd85d51++);~_0x5cbaf4&&(_0x1baa76=_0x48a4d9%0x4?_0x1baa76*0x40+_0x5cbaf4:_0x5cbaf4,_0x48a4d9++%0x4)?_0x3b5833+=String['fromCharCode'](0xff&_0x1baa76>>(-0x2*_0x48a4d9&0x6)):0x0){_0x5cbaf4=_0x2177cf['indexOf'](_0x5cbaf4);}for(var _0x3a9311=0x0,_0x1c0456=_0x3b5833['length'];_0x3a9311<_0x1c0456;_0x3a9311++){_0x4d09b2+='%'+('00'+_0x3b5833['charCodeAt'](_0x3a9311)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4d09b2);};_0x4438['ixrnln']=_0x348666,_0x4438['JwTCHQ']={},_0x4438['FKnJEj']=!![];}var _0x2498ea=_0x212a73[0x0],_0x59c234=_0x2c8eb2+_0x2498ea,_0x331644=_0x4438['JwTCHQ'][_0x59c234];return!_0x331644?(_0x4438d8=_0x4438['ixrnln'](_0x4438d8),_0x4438['JwTCHQ'][_0x59c234]=_0x4438d8):_0x4438d8=_0x331644,_0x4438d8;}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 _0x21f6(_0x3bea76,_0x3e0418){_0x3bea76=_0x3bea76-0x19d;const _0x85ebce=_0x85eb();let _0x21f642=_0x85ebce[_0x3bea76];if(_0x21f6['hYrEOG']===undefined){var _0x48126a=function(_0x395bd2){const _0x4d625d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x159f2e='',_0x42344f='';for(let _0x5e384a=0x0,_0x5e0fe8,_0x3d87be,_0x2815a9=0x0;_0x3d87be=_0x395bd2['charAt'](_0x2815a9++);~_0x3d87be&&(_0x5e0fe8=_0x5e384a%0x4?_0x5e0fe8*0x40+_0x3d87be:_0x3d87be,_0x5e384a++%0x4)?_0x159f2e+=String['fromCharCode'](0xff&_0x5e0fe8>>(-0x2*_0x5e384a&0x6)):0x0){_0x3d87be=_0x4d625d['indexOf'](_0x3d87be);}for(let _0x1390ad=0x0,_0xacb231=_0x159f2e['length'];_0x1390ad<_0xacb231;_0x1390ad++){_0x42344f+='%'+('00'+_0x159f2e['charCodeAt'](_0x1390ad)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x42344f);};_0x21f6['YLFJWV']=_0x48126a,_0x21f6['QIGThW']={},_0x21f6['hYrEOG']=!![];}const _0x34bc75=_0x85ebce[0x0],_0x35aae3=_0x3bea76+_0x34bc75,_0x313f1f=_0x21f6['QIGThW'][_0x35aae3];return!_0x313f1f?(_0x21f642=_0x21f6['YLFJWV'](_0x21f642),_0x21f6['QIGThW'][_0x35aae3]=_0x21f642):_0x21f642=_0x313f1f,_0x21f642;}(function(_0x2bfd99,_0x15717c){const _0x2da93b={_0x54e9ce:0xe4,_0x365578:0xdc,_0x1e3d40:0xca,_0x4b6685:0xcf,_0x203ef1:0xcd,_0x40c126:0x42c,_0x2c39ab:0x418,_0x26293d:0x425,_0x104a07:0x42a,_0x4bb110:0x429,_0x3fc6bc:0x424,_0x338cb0:0x413,_0x28e0d3:0x412,_0x59f92f:0xd5,_0x50e32f:0xdd,_0x14de79:0x417},_0x264a7c={_0x10e0b1:0xd8},_0x2625b6={_0x1f13c6:0x26f};function _0x26eaa7(_0x4e8fc7,_0xe9230d,_0x36c1e2,_0x3643c1){return _0x21f6(_0x3643c1-_0x2625b6._0x1f13c6,_0x4e8fc7);}const _0x40ceea=_0x2bfd99();function _0x19cced(_0x3e0e2c,_0x53e49c,_0x384124,_0x335c20){return _0x21f6(_0x335c20- -_0x264a7c._0x10e0b1,_0x384124);}while(!![]){try{const _0x5479a1=parseInt(_0x19cced(0xc2,0xcb,0xce,0xc7))/0x1*(-parseInt(_0x19cced(_0x2da93b._0x54e9ce,0xe7,0xde,_0x2da93b._0x365578))/0x2)+-parseInt(_0x19cced(_0x2da93b._0x1e3d40,_0x2da93b._0x4b6685,0xc8,0xd2))/0x3+-parseInt(_0x19cced(0xd2,_0x2da93b._0x203ef1,0xcc,0xd7))/0x4*(-parseInt(_0x19cced(0xcf,0xc6,0xc5,0xcd))/0x5)+-parseInt(_0x26eaa7(_0x2da93b._0x40c126,_0x2da93b._0x2c39ab,_0x2da93b._0x26293d,0x421))/0x6*(parseInt(_0x26eaa7(_0x2da93b._0x104a07,_0x2da93b._0x4bb110,0x42f,_0x2da93b._0x3fc6bc))/0x7)+-parseInt(_0x19cced(0xc8,0xc6,0xd3,_0x2da93b._0x1e3d40))/0x8+-parseInt(_0x26eaa7(0x418,0x413,_0x2da93b._0x338cb0,_0x2da93b._0x28e0d3))/0x9*(parseInt(_0x26eaa7(0x417,0x423,0x41c,0x41a))/0xa)+-parseInt(_0x19cced(_0x2da93b._0x59f92f,0xe7,_0x2da93b._0x50e32f,0xdb))/0xb*(-parseInt(_0x26eaa7(0x419,0x40f,_0x2da93b._0x14de79,0x415))/0xc);if(_0x5479a1===_0x15717c)break;else _0x40ceea['push'](_0x40ceea['shift']());}catch(_0x41314e){_0x40ceea['push'](_0x40ceea['shift']());}}}(_0x85eb,0x2ccf2));import{modelIdentityFromParts}from'../chunk-D5IVWJHX.js';import{resolveAnthropicReasoningConfig,resolveOpenAiReasoningConfig}from'../chunk-IUZALP6K.js';import{TurnFailedError}from'../chunk-FFIZ6TKW.js';function _0x85eb(){const _0x27065e=['mMPWCfHhua','mZC4ntGXDfrfwKDz','AxngAw5PDgu','Aw5KzxHpzG','mta5mdC3serRuNLq','Bwf4q29Uy3vYCMvUy3KGBxvZDcbIzsbHigzPBML0zsbWB3nPDgL2zsbPBNrLz2vY','CMvTB3zLqwjVCNrmAxn0zw5LCG','odG5mZKYBhrmwePz','mZyWqMnXDKfs','y2fUy2vSBgvK','nxPjALn4yW','ndmWnJHqEeHkqKK','ywjVCNrLza','AxnjBNrLz2vY','C2HPzNq','ndiYmZeWy1vgyxPo','mJC4nZbxquviChq','CMvZB2X2zq','ChvZAa','BgvUz3rO','mZmXmty0wvHdsgXQ','CMvQzwn0','CMvHC29U','mJr5AMLms1G','mJqYmhjHALfKrW'];_0x85eb=function(){return _0x27065e;};return _0x85eb();}import{OperationAbortedError,addAbortListener,isAbortError,throwIfAborted,toAbortError}from'../chunk-X7VAACWY.js';function createAbortAwareSemaphore(_0x159f2e){const _0x5116df={_0x52bd9e:0x513,_0x4640d5:0x50b,_0x20d093:0x51c,_0x142810:0x318,_0x5467e3:0x306,_0x42ee64:0x307,_0x1d7c65:0x305,_0x18c0ec:0x305},_0xad800b={_0x1f896e:0x69,_0x1e59df:0xe1,_0x528fe3:0xeb,_0x1ae8b9:0xea,_0x541020:0xe6},_0x557b18={_0x1a549b:0x1f4,_0x2ff18e:0x1ef,_0x4c5876:0x107,_0x9426e:0x109,_0xb6d125:0x106},_0x5cbccd={_0x36cbd8:0x441},_0x433fd0={_0x5f01d7:0xa8,_0x1ce750:0x1ea,_0xe665d6:0x1f6,_0x15f5c3:0x1f3,_0x2413cd:0x1f0,_0x3ac0e3:0x95,_0x1fb895:0x9a,_0x568824:0x8a,_0x47117c:0x1ed,_0x47113f:0x1ec},_0x23491b={_0x521549:0x181,_0x107090:0x274,_0xbb772a:0x42},_0x4e652c={_0x277ebb:0x165};if(!Number[_0x310b87(_0x5116df._0x52bd9e,_0x5116df._0x52bd9e,_0x5116df._0x4640d5,_0x5116df._0x20d093)](_0x159f2e)||!Number[_0x319ca3(0x319,_0x5116df._0x142810,0x30d,_0x5116df._0x5467e3)](_0x159f2e)||_0x159f2e<=0x0)throw new Error(_0x319ca3(_0x5116df._0x42ee64,0x309,_0x5116df._0x1d7c65,_0x5116df._0x18c0ec));let _0x42344f=0x0;const _0x5e384a=[];function _0x310b87(_0x1e573b,_0x310c5f,_0x13b431,_0x175478){return _0x21f6(_0x1e573b-0x376,_0x175478);}function _0x319ca3(_0x52cd38,_0x20544b,_0x533fbe,_0x5ad669){return _0x21f6(_0x533fbe-_0x4e652c._0x277ebb,_0x20544b);}const _0x5e0fe8=()=>{let _0x2815a9=![];return()=>{if(_0x2815a9)return;_0x2815a9=!![],_0x42344f-=0x1,_0x3d87be();};},_0x3d87be=()=>{const _0x1fae54={_0x1cd051:0x335,_0x20a516:0x1bd};function _0x2eeead(_0x3d1572,_0x36be8d,_0x261d40,_0x33f1b1){return _0x310b87(_0x3d1572- -_0x1fae54._0x1cd051,_0x36be8d-_0x1fae54._0x20a516,_0x261d40-0x89,_0x33f1b1);}function _0x59251e(_0x19010e,_0x5567c5,_0x1d9acd,_0x3e694a){return _0x319ca3(_0x19010e-_0x23491b._0x521549,_0x5567c5,_0x19010e- -_0x23491b._0x107090,_0x3e694a-_0x23491b._0xbb772a);}while(_0x5e384a[_0x59251e(0x9f,0x98,_0x433fd0._0x5f01d7,0x97)]>0x0){const _0x1390ad=_0x5e384a[_0x2eeead(_0x433fd0._0x1ce750,_0x433fd0._0xe665d6,0x1f5,_0x433fd0._0x15f5c3)]();if(!_0x1390ad||_0x1390ad[_0x2eeead(0x1e5,_0x433fd0._0x2413cd,_0x433fd0._0x1ce750,0x1dc)])continue;_0x1390ad[_0x59251e(_0x433fd0._0x3ac0e3,_0x433fd0._0x1fb895,_0x433fd0._0x568824,0x8c)]=!![],_0x1390ad[_0x2eeead(0x1e2,0x1de,0x1db,_0x433fd0._0x47117c)](),_0x42344f+=0x1,_0x1390ad[_0x2eeead(_0x433fd0._0x47117c,_0x433fd0._0x47113f,0x1ed,0x1e8)](_0x5e0fe8());return;}};return{'acquire'(_0xacb231){const _0x174f16={_0x114af4:0xb0,_0x159a75:0xa6,_0x33c0f9:0x223,_0x94854f:0x227,_0x4f4d38:0xbd,_0x514e2e:0xc9},_0x52235d={_0x59002a:0x170,_0x16c4de:0x12f},_0x590b8b={_0x2d1889:0x4b4,_0x330ba4:0xb6};function _0x35638(_0x15ee00,_0x276d9a,_0x409435,_0x5f5b25){return _0x310b87(_0x15ee00- -_0x5cbccd._0x36cbd8,_0x276d9a-0x4f,_0x409435-0x152,_0x409435);}if(_0xacb231?.[_0x5cc8bc(0x5d,_0xad800b._0x1f896e,0x67,0x65)])return Promise[_0x35638(0xe5,0xef,_0xad800b._0x1e59df,_0xad800b._0x528fe3)](toAbortError(_0xacb231['reason']));function _0x5cc8bc(_0x37cd80,_0x44916c,_0x5ea631,_0x26d780){return _0x310b87(_0x44916c- -_0x590b8b._0x2d1889,_0x44916c-_0x590b8b._0x330ba4,_0x5ea631-0x11a,_0x26d780);}if(_0x42344f<_0x159f2e)return _0x42344f+=0x1,Promise[_0x35638(0xe1,_0xad800b._0x1e59df,_0xad800b._0x1ae8b9,_0xad800b._0x541020)](_0x5e0fe8());return new Promise((_0x3d4735,_0x279b0b)=>{const _0xcf2c92={_0x19dd82:0xd5,_0x5718d0:0x180};function _0x55ff3c(_0x40d500,_0x1aaaf3,_0x1e535b,_0x5aa2c0){return _0x5cc8bc(_0x40d500-_0xcf2c92._0x19dd82,_0x5aa2c0-_0xcf2c92._0x5718d0,_0x1e535b-0x34,_0x1aaaf3);}const _0x279ab1={'resolve':_0x3d4735,'reject':_0x279b0b,'cancelled':![],'removeAbortListener':()=>{}};_0x5e384a[_0x55ff3c(0x1e2,_0x557b18._0x1a549b,0x1f9,_0x557b18._0x2ff18e)](_0x279ab1);function _0x2aae1a(_0x1aeb8c,_0x4a80a0,_0x40abdd,_0x257aa7){return _0x35638(_0x1aeb8c-0x35,_0x4a80a0-_0x52235d._0x59002a,_0x40abdd,_0x257aa7-_0x52235d._0x16c4de);}_0x279ab1[_0x2aae1a(0x10b,_0x557b18._0x4c5876,_0x557b18._0x9426e,_0x557b18._0xb6d125)]=addAbortListener(_0xacb231,()=>{const _0x18f9a5={_0x332c3b:0x11d,_0x91f1f7:0x134},_0x2916df={_0x18b137:0x136};if(_0x279ab1[_0x3c7486(_0x174f16._0x114af4,_0x174f16._0x159a75,0xbb,0xa7)])return;_0x279ab1[_0x540950(0x233,0x22d,0x22b,_0x174f16._0x33c0f9)]=!![];function _0x3c7486(_0x4929f8,_0x40020f,_0x3edc1f,_0x41a978){return _0x55ff3c(_0x4929f8-0x141,_0x3edc1f,_0x3edc1f-0xf0,_0x4929f8- -_0x2916df._0x18b137);}function _0x540950(_0x52f145,_0x546201,_0x396388,_0x5e0790){return _0x2aae1a(_0x396388-_0x18f9a5._0x332c3b,_0x546201-_0x18f9a5._0x91f1f7,_0x5e0790,_0x5e0790-_0x18f9a5._0x91f1f7);}_0x279ab1['removeAbortListener']();const _0x1e7b56=_0x5e384a[_0x540950(0x21c,_0x174f16._0x94854f,0x225,_0x174f16._0x94854f)](_0x279ab1);if(_0x1e7b56>=0x0)_0x5e384a['splice'](_0x1e7b56,0x1);_0x279ab1['reject'](toAbortError(_0xacb231?.[_0x3c7486(_0x174f16._0x4f4d38,0xc4,_0x174f16._0x514e2e,0xb2)]));});});}};}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
  }
@@ -170,6 +177,7 @@ export interface ModelRequest {
170
177
  session_id: string;
171
178
  turn_id: string;
172
179
  model_identity?: string;
180
+ pricing_provider_id?: string;
173
181
  };
174
182
  outputFormat?: OutputFormat;
175
183
  }
@@ -194,20 +202,43 @@ export interface ChatRequest {
194
202
  sessionId: string;
195
203
  turnId: string;
196
204
  modelIdentity?: string;
205
+ pricingProviderId?: string;
197
206
  };
198
207
  outputFormat?: OutputFormat;
199
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;
200
237
  export interface ChatResponse {
201
238
  id: string;
202
239
  content: AssistantContentBlock[];
203
240
  stopReason: "end_turn" | "tool_use";
204
- usage: {
205
- inputTokens: number;
206
- outputTokens: number;
207
- reasoningTokens?: number;
208
- cacheReadInputTokens?: number;
209
- cacheCreationInputTokens?: number;
210
- };
241
+ usage: ChatResponseUsage;
211
242
  providerState?: MessageProviderState;
212
243
  }
213
244
  export interface ContentDeltaChunk {
@@ -246,6 +277,9 @@ export interface OpenAiReasoningSummaryDeltaChunk {
246
277
  outputIndex: number;
247
278
  summaryIndex: number;
248
279
  }
280
+ export interface ProviderStreamResetChunk {
281
+ type: "provider_stream_reset";
282
+ }
249
283
  export interface ProviderRetryChunk {
250
284
  type: "provider_retry";
251
285
  attempt: number;
@@ -259,7 +293,7 @@ export interface DoneChunk {
259
293
  type: "done";
260
294
  response: ChatResponse;
261
295
  }
262
- export type ChatResponseChunk = AnthropicSignatureDeltaChunk | AnthropicThinkingDeltaChunk | ContentDeltaChunk | DoneChunk | OpenAiReasoningDeltaChunk | OpenAiReasoningSummaryDeltaChunk | ProviderRetryChunk | ToolUseDeltaChunk;
296
+ export type ChatResponseChunk = AnthropicSignatureDeltaChunk | AnthropicThinkingDeltaChunk | ContentDeltaChunk | DoneChunk | OpenAiReasoningDeltaChunk | OpenAiReasoningSummaryDeltaChunk | ProviderStreamResetChunk | ProviderRetryChunk | ToolUseDeltaChunk;
263
297
  export interface ModelLimits {
264
298
  contextWindow?: number;
265
299
  maxOutput?: number;
@@ -303,6 +337,7 @@ export interface TurnInput {
303
337
  system?: SystemInput;
304
338
  messages?: MessageInput[];
305
339
  message: MessageInput;
340
+ drainSteering?: () => Promise<MessageInput[]>;
306
341
  }
307
342
  export interface TurnState {
308
343
  sessionId: string;
@@ -370,6 +405,7 @@ export interface TurnMessageMeta {
370
405
  provider?: string;
371
406
  model?: string;
372
407
  modelIdentity?: string;
408
+ metrics?: PersistedModelCallMetrics;
373
409
  /** ms epoch — provider request sent. */
374
410
  turnStartedAt?: number;
375
411
  /** ms epoch — response fully received. */
@@ -384,6 +420,7 @@ export interface EngineChatModel {
384
420
  modelIdentity: string;
385
421
  provider?: string;
386
422
  maxTokens?: number;
423
+ readonly pricingProviderId?: string;
387
424
  complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
388
425
  stream?(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
389
426
  getModels?(signal?: AbortSignal): Promise<ModelInfo[]>;
@@ -392,6 +429,7 @@ export interface BaseChatModelOptions {
392
429
  model: string;
393
430
  modelIdentity?: string;
394
431
  maxTokens?: number;
432
+ pricingProviderId?: string;
395
433
  reasoning?: ReasoningConfig;
396
434
  providerSessionResolver?: ProviderSessionResolver;
397
435
  requestMutators?: ProviderRequestMutator[];
@@ -417,12 +455,22 @@ export type AskUserQuestionRequest = {
417
455
  questionId: string;
418
456
  questions: AskUserQuestion[];
419
457
  };
458
+ export type ToolPermissionClass = "read" | "write" | "always-confirm";
420
459
  export interface ToolExecutionContext extends AgentEventContext {
421
460
  signal: AbortSignal;
422
461
  toolCallId?: string;
462
+ permissionClass?: ToolPermissionClass;
463
+ executionAuthorization?: unknown;
423
464
  askUser?: (request: AskUserQuestionRequest) => Promise<AskUserAnswers>;
424
465
  setTopic?: (topic: string) => void;
425
466
  }
467
+ export interface BashExecutionTarget {
468
+ command: string;
469
+ cwd: string;
470
+ shellPath: string;
471
+ dialect: "bash" | "posix" | "windows" | "unknown";
472
+ background: boolean;
473
+ }
426
474
  export interface ToolRuntimeStartedEvent {
427
475
  type: "tool_started";
428
476
  toolCall: ToolUseBlock;
@@ -453,6 +501,8 @@ export interface AgentModelRequestEvent {
453
501
  }
454
502
  export interface AgentModelResponseEvent {
455
503
  type: "model_response";
504
+ /** Exact provider/model-call duration measured by the turn engine. */
505
+ modelTimeMs?: number;
456
506
  response: ChatResponse;
457
507
  }
458
508
  export interface AgentAssistantMessageEvent {
@@ -507,8 +557,14 @@ export interface AgentTurnCompleteEvent {
507
557
  state: TurnState;
508
558
  }
509
559
  export interface AgentProviderRetryEvent extends ProviderRetryChunk {
560
+ assistantMessageId: string;
510
561
  }
511
- export type AgentLifecycleEvent = AgentAssistantChunkEvent | AgentAssistantMessageEvent | AgentFinalMessageEvent | AgentModelRequestEvent | AgentModelResponseEvent | AgentProviderRetryEvent | AgentReasoningChunkEvent | AgentReasoningMessageEvent | AgentToolCallEvent | AgentToolUseChunkEvent | AgentToolUseMessageEvent | AgentToolResultEvent | AgentToolResultMessageEvent | AgentTurnCompleteEvent | AgentUserMessageEvent;
562
+ export interface AgentProviderStreamResetEvent {
563
+ type: "provider_stream_reset";
564
+ assistantMessageId: string;
565
+ reasoningMessageId: string;
566
+ }
567
+ export type AgentLifecycleEvent = AgentAssistantChunkEvent | AgentAssistantMessageEvent | AgentFinalMessageEvent | AgentModelRequestEvent | AgentModelResponseEvent | AgentProviderRetryEvent | AgentProviderStreamResetEvent | AgentReasoningChunkEvent | AgentReasoningMessageEvent | AgentToolCallEvent | AgentToolUseChunkEvent | AgentToolUseMessageEvent | AgentToolResultEvent | AgentToolResultMessageEvent | AgentTurnCompleteEvent | AgentUserMessageEvent;
512
568
  export type AgentEvent = AgentLifecycleEvent | ToolRuntimeEvent;
513
569
  export type ToolRuntimeDispatchDecision = {
514
570
  action: "reject";
@@ -524,6 +580,9 @@ export type ToolRuntimeDispatchDecision = {
524
580
  dir: string;
525
581
  persist: boolean;
526
582
  };
583
+ executionAuthorization?: unknown;
584
+ approvalDecision?: "y" | "a" | "t";
585
+ approvalSource?: "policy" | "remembered" | "sudo" | "user";
527
586
  };
528
587
  export type ToolRuntimeToolCallHandler = (toolCall: ToolUseBlock, ctx: ToolExecutionContext) => Promise<ToolRuntimeDispatchDecision | undefined> | ToolRuntimeDispatchDecision | undefined;
529
588
  export type ToolRuntimeEventHandler = (event: ToolRuntimeEvent, ctx: ToolExecutionContext) => Promise<void> | void;
@@ -534,10 +593,14 @@ export interface ToolRuntime {
534
593
  executeCalls(toolCalls: ToolUseBlock[], ctx: ToolExecutionContext): Promise<ToolResult[]>;
535
594
  execute(toolCall: ToolUseBlock, ctx: ToolExecutionContext): Promise<ToolResult>;
536
595
  }
537
- 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;
596
+ 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;
538
597
  type Expand<TValue> = TValue extends infer TObject ? {
539
598
  [TKey in keyof TObject]: TObject[TKey];
540
599
  } : never;
600
+ type JsonSchemaObjectPropertyKeys<TSchema extends JsonSchema> = TSchema extends JsonSchemaObject<infer TProperties> ? Extract<keyof TProperties, string> : never;
601
+ 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>;
602
+ type InferJsonSchemaAnyOfVariants<TVariant extends JsonSchema, TAllVariants extends JsonSchema> = TVariant extends JsonSchema ? InferJsonSchemaAnyOfVariant<TVariant, TAllVariants> : never;
603
+ type InferJsonSchemaAnyOf<TVariants extends readonly JsonSchema[]> = InferJsonSchemaAnyOfVariants<TVariants[number], TVariants[number]>;
541
604
  type RequiredKeyUnion<TRequired extends readonly string[] | undefined> = TRequired extends readonly string[] ? TRequired[number] : never;
542
605
  type OptionalKeyUnion<TProperties extends Record<string, JsonSchema>, TRequired extends readonly string[] | undefined> = Exclude<keyof TProperties, RequiredKeyUnion<TRequired>>;
543
606
  type RequiredProperties<TProperties extends Record<string, JsonSchema>, TRequired extends readonly string[] | undefined> = {
@@ -548,13 +611,19 @@ type OptionalProperties<TProperties extends Record<string, JsonSchema>, TRequire
548
611
  };
549
612
  export type ToolOutputValue = JsonValue | ToolOutputEnvelope;
550
613
  export type ToolGenerator<TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined> = AsyncGenerator<TYield, TReturn, void>;
551
- export interface ToolDefinition<TInput extends JsonObject = JsonObject, TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined, TSchema extends JsonSchemaObject = JsonSchemaObject> {
614
+ /** Internal resource lifetime contract; omitted from model-facing tool schemas and messages. */
615
+ export interface ToolDefinitionLifecycle {
616
+ acquire(): () => void;
617
+ }
618
+ export interface ToolDefinition<TInput extends object = JsonObject, TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined, TSchema extends JsonSchemaObject = JsonSchemaObject> {
552
619
  name: string;
553
620
  description: string;
554
621
  inputSchema: TSchema;
622
+ permissionClass?: ToolPermissionClass;
623
+ internalLifecycle?: ToolDefinitionLifecycle;
555
624
  execute(input: TInput, ctx: ToolExecutionContext): ToolGenerator<TYield, TReturn>;
556
625
  }
557
- export type AnyToolDefinition = ToolDefinition<JsonObject, ToolOutputValue, ToolOutputValue | undefined, JsonSchemaObject>;
626
+ export type AnyToolDefinition = ToolDefinition<object, ToolOutputValue, ToolOutputValue | undefined, JsonSchemaObject>;
558
627
  export type TransformableStage = "afterModelResponse" | "afterToolResult" | "beforeAssistantAppend" | "beforeFinalOutput" | "beforeModelRequest" | "beforeToolExecution" | "beforeToolResultAppend" | "onUserMessage";
559
628
  export type ObserverOnlyStage = "afterMessageAppend" | "afterTurnComplete";
560
629
  export type Stage = ObserverOnlyStage | TransformableStage;
@@ -591,6 +660,8 @@ export interface ObserverExtensionRegistration<S extends Stage = Stage> {
591
660
  kind: "observer";
592
661
  order: number;
593
662
  enabled: boolean;
663
+ /** Runs after every enabled non-terminal observer registered for this stage. */
664
+ terminal?: boolean;
594
665
  run: Observer<S>;
595
666
  }
596
667
  export type AnyExtensionRegistration = {
@@ -614,9 +685,19 @@ export interface RunTurnDeps {
614
685
  outputFormat?: OutputFormat;
615
686
  }
616
687
  export type AgentInput = MessageInput | string;
688
+ export type SteeringInputDrain = () => Promise<AgentInput[]>;
689
+ /** Immutable ownership metadata for the exact agent submission being sent. */
690
+ export type AgentSubmission = Readonly<{
691
+ origin: "user";
692
+ }> | Readonly<{
693
+ origin: "coordinator";
694
+ token: string;
695
+ }>;
617
696
  export interface AgentSendOptions {
618
697
  streaming?: boolean;
619
698
  signal?: AbortSignal;
699
+ drainSteering?: SteeringInputDrain;
700
+ submission?: AgentSubmission;
620
701
  }
621
702
  export interface AgentOptions {
622
703
  sessionId?: string;
@@ -751,7 +832,7 @@ export interface OpenAiReasoningOutputItem {
751
832
  }
752
833
  export type OpenAiResponsesOutputItem = JsonObject | OpenAiFunctionCall | OpenAiOutputMessage | OpenAiReasoningOutputItem;
753
834
  export interface OpenAiResponsesReasoningParam {
754
- effort?: OpenAiReasoningEffort;
835
+ effort?: string;
755
836
  generate_summary?: OpenAiReasoningSummary;
756
837
  summary?: OpenAiReasoningSummary;
757
838
  }
@@ -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