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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,6 +45,9 @@ interface OpenAiChatCompletionsRequest {
45
45
  max_tokens?: number;
46
46
  reasoning_effort?: "high" | "low" | "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;
@@ -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(_0x231ab8,_0x347ff9){var _0xdbfbf2={_0x53e11f:0x22,_0x35f21b:0x1f,_0x1ce949:0x418,_0x34f7f5:0x41d,_0x6d0e3d:0x41a,_0x1467c6:0x1f,_0x2b6163:0x1a,_0x3e4e88:0x15,_0x9bbc2b:0x421,_0x1d01e5:0x12,_0x3d5118:0x17,_0x55c0ff:0x14,_0xfe3c2f:0x17,_0x5ca0b1:0x40c,_0x4cf0f3:0x17,_0x4a05cb:0x1c,_0x3b5c6f:0x19,_0x191289:0x410,_0xe921ad:0x13,_0x57e031:0x18,_0x5dec03:0x417,_0x443113:0x417,_0x5aedaf:0x413},_0x4f2f33={_0x42d435:0x179},_0x279f30={_0x4f7326:0x283};function _0x5de123(_0x5d12ab,_0x2feb84,_0x46ab7a,_0xd51d2a){return _0x494c(_0x46ab7a-_0x279f30._0x4f7326,_0x5d12ab);}var _0x513984=_0x231ab8();function _0x12a96c(_0x1caa54,_0x48adcb,_0x3a0ef6,_0x123d1d){return _0x494c(_0x48adcb- -_0x4f2f33._0x42d435,_0x123d1d);}while(!![]){try{var _0x164269=-parseInt(_0x12a96c(_0xdbfbf2._0x53e11f,_0xdbfbf2._0x35f21b,0x21,0x21))/0x1*(parseInt(_0x5de123(_0xdbfbf2._0x1ce949,_0xdbfbf2._0x34f7f5,0x419,_0xdbfbf2._0x6d0e3d))/0x2)+parseInt(_0x12a96c(_0xdbfbf2._0x1467c6,_0xdbfbf2._0x2b6163,_0xdbfbf2._0x3e4e88,_0xdbfbf2._0x2b6163))/0x3*(-parseInt(_0x5de123(0x422,0x41a,0x41c,_0xdbfbf2._0x9bbc2b))/0x4)+parseInt(_0x12a96c(_0xdbfbf2._0x1d01e5,_0xdbfbf2._0x3d5118,_0xdbfbf2._0x55c0ff,_0xdbfbf2._0xfe3c2f))/0x5+parseInt(_0x5de123(_0xdbfbf2._0x5ca0b1,0x411,0x411,0x415))/0x6+parseInt(_0x12a96c(_0xdbfbf2._0x4cf0f3,_0xdbfbf2._0x4a05cb,0x21,0x20))/0x7*(parseInt(_0x12a96c(0x20,0x1e,0x1d,0x23))/0x8)+parseInt(_0x12a96c(0x17,_0xdbfbf2._0x3b5c6f,_0xdbfbf2._0x3e4e88,_0xdbfbf2._0x3b5c6f))/0x9*(parseInt(_0x5de123(0x413,0x40c,0x412,_0xdbfbf2._0x191289))/0xa)+parseInt(_0x12a96c(_0xdbfbf2._0xe921ad,_0xdbfbf2._0x57e031,0x16,_0xdbfbf2._0x1d01e5))/0xb*(-parseInt(_0x5de123(0x41b,_0xdbfbf2._0x5dec03,_0xdbfbf2._0x443113,_0xdbfbf2._0x5aedaf))/0xc);if(_0x164269===_0x347ff9)break;else _0x513984['push'](_0x513984['shift']());}catch(_0x56176f){_0x513984['push'](_0x513984['shift']());}}}(_0x5c28,0xe86fe));import{modelIdentityFromParts}from'../chunk-D5IVWJHX.js';import{mapAutoReasoningEffortToBudgetTokens,resolveAnthropicThinkingConfig,resolveOpenAiReasoningConfig}from'../chunk-NYZR4XKO.js';function _0x5c28(){var _0x4bd20a=['mJbHzezAA3i','mtq0mdq1zwjouwnN','mtfHqK5ju1a','mZe4mtuWovftugzXqq','mte1mtyXDfDxyNHp','nJq4ndGXmMHAuffQEG','nJK2mdCZwwf6y2jY','mKzXwLztwq','mtm2EfPoueLw','mtqZnZCXm0L5CLPMDq','mtz1zxnPuKG','mZK0ndCWmhH1zKvlwG'];_0x5c28=function(){return _0x4bd20a;};return _0x5c28();}import{TurnFailedError}from'../chunk-FFIZ6TKW.js';function _0x494c(_0x29c78f,_0x4d2400){_0x29c78f=_0x29c78f-0x18e;var _0x5c28f6=_0x5c28();var _0x494c58=_0x5c28f6[_0x29c78f];if(_0x494c['PhmulH']===undefined){var _0x367384=function(_0x4b9098){var _0x160e42='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x5a49c6='',_0xbb03a6='';for(var _0x2bd7fa=0x0,_0x3068ec,_0x4026a2,_0x5a0472=0x0;_0x4026a2=_0x4b9098['charAt'](_0x5a0472++);~_0x4026a2&&(_0x3068ec=_0x2bd7fa%0x4?_0x3068ec*0x40+_0x4026a2:_0x4026a2,_0x2bd7fa++%0x4)?_0x5a49c6+=String['fromCharCode'](0xff&_0x3068ec>>(-0x2*_0x2bd7fa&0x6)):0x0){_0x4026a2=_0x160e42['indexOf'](_0x4026a2);}for(var _0x416446=0x0,_0x586afb=_0x5a49c6['length'];_0x416446<_0x586afb;_0x416446++){_0xbb03a6+='%'+('00'+_0x5a49c6['charCodeAt'](_0x416446)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xbb03a6);};_0x494c['IKnZDM']=_0x367384,_0x494c['rqCLNx']={},_0x494c['PhmulH']=!![];}var _0x480f41=_0x5c28f6[0x0],_0x2c35c8=_0x29c78f+_0x480f41,_0x3f885e=_0x494c['rqCLNx'][_0x2c35c8];return!_0x3f885e?(_0x494c58=_0x494c['IKnZDM'](_0x494c58),_0x494c['rqCLNx'][_0x2c35c8]=_0x494c58):_0x494c58=_0x3f885e,_0x494c58;}import{OperationAbortedError,addAbortListener,isAbortError,throwIfAborted,toAbortError}from'../chunk-X7VAACWY.js';export{OperationAbortedError,TurnFailedError,addAbortListener,isAbortError,mapAutoReasoningEffortToBudgetTokens,modelIdentityFromParts,resolveAnthropicThinkingConfig,resolveOpenAiReasoningConfig,throwIfAborted,toAbortError};
@@ -170,6 +170,7 @@ export interface ModelRequest {
170
170
  session_id: string;
171
171
  turn_id: string;
172
172
  model_identity?: string;
173
+ pricing_provider_id?: string;
173
174
  };
174
175
  outputFormat?: OutputFormat;
175
176
  }
@@ -194,20 +195,36 @@ export interface ChatRequest {
194
195
  sessionId: string;
195
196
  turnId: string;
196
197
  modelIdentity?: string;
198
+ pricingProviderId?: string;
197
199
  };
198
200
  outputFormat?: OutputFormat;
199
201
  }
202
+ export interface ReportedModelCost {
203
+ amountUsdTicks: number;
204
+ source: "openrouter" | "xai";
205
+ }
206
+ export interface EstimatedModelCost {
207
+ amountUsdTicks: number;
208
+ source: "models.dev";
209
+ pricingSnapshotId: string;
210
+ pricingProviderIds: readonly string[];
211
+ pricingModelId: string;
212
+ matchKind: "provider-model" | "model-unique" | "model-identical";
213
+ }
214
+ export interface ChatResponseUsage {
215
+ inputTokens: number;
216
+ outputTokens: number;
217
+ reasoningTokens?: number;
218
+ cacheReadInputTokens?: number;
219
+ cacheCreationInputTokens?: number;
220
+ reportedCost?: ReportedModelCost;
221
+ estimatedCost?: EstimatedModelCost;
222
+ }
200
223
  export interface ChatResponse {
201
224
  id: string;
202
225
  content: AssistantContentBlock[];
203
226
  stopReason: "end_turn" | "tool_use";
204
- usage: {
205
- inputTokens: number;
206
- outputTokens: number;
207
- reasoningTokens?: number;
208
- cacheReadInputTokens?: number;
209
- cacheCreationInputTokens?: number;
210
- };
227
+ usage: ChatResponseUsage;
211
228
  providerState?: MessageProviderState;
212
229
  }
213
230
  export interface ContentDeltaChunk {
@@ -384,6 +401,7 @@ export interface EngineChatModel {
384
401
  modelIdentity: string;
385
402
  provider?: string;
386
403
  maxTokens?: number;
404
+ readonly pricingProviderId?: string;
387
405
  complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
388
406
  stream?(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
389
407
  getModels?(signal?: AbortSignal): Promise<ModelInfo[]>;
@@ -392,6 +410,7 @@ export interface BaseChatModelOptions {
392
410
  model: string;
393
411
  modelIdentity?: string;
394
412
  maxTokens?: number;
413
+ pricingProviderId?: string;
395
414
  reasoning?: ReasoningConfig;
396
415
  providerSessionResolver?: ProviderSessionResolver;
397
416
  requestMutators?: ProviderRequestMutator[];
@@ -417,9 +436,11 @@ export type AskUserQuestionRequest = {
417
436
  questionId: string;
418
437
  questions: AskUserQuestion[];
419
438
  };
439
+ export type ToolPermissionClass = "read" | "write" | "always-confirm";
420
440
  export interface ToolExecutionContext extends AgentEventContext {
421
441
  signal: AbortSignal;
422
442
  toolCallId?: string;
443
+ permissionClass?: ToolPermissionClass;
423
444
  askUser?: (request: AskUserQuestionRequest) => Promise<AskUserAnswers>;
424
445
  setTopic?: (topic: string) => void;
425
446
  }
@@ -548,10 +569,16 @@ type OptionalProperties<TProperties extends Record<string, JsonSchema>, TRequire
548
569
  };
549
570
  export type ToolOutputValue = JsonValue | ToolOutputEnvelope;
550
571
  export type ToolGenerator<TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined> = AsyncGenerator<TYield, TReturn, void>;
572
+ /** Internal resource lifetime contract; omitted from model-facing tool schemas and messages. */
573
+ export interface ToolDefinitionLifecycle {
574
+ acquire(): () => void;
575
+ }
551
576
  export interface ToolDefinition<TInput extends JsonObject = JsonObject, TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined, TSchema extends JsonSchemaObject = JsonSchemaObject> {
552
577
  name: string;
553
578
  description: string;
554
579
  inputSchema: TSchema;
580
+ permissionClass?: ToolPermissionClass;
581
+ internalLifecycle?: ToolDefinitionLifecycle;
555
582
  execute(input: TInput, ctx: ToolExecutionContext): ToolGenerator<TYield, TReturn>;
556
583
  }
557
584
  export type AnyToolDefinition = ToolDefinition<JsonObject, ToolOutputValue, ToolOutputValue | undefined, JsonSchemaObject>;