@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.
- package/dist/VERSION +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/agent/metrics.d.ts +8 -0
- package/dist/chunk-D5IVWJHX.js +1 -1
- package/dist/chunk-FFIZ6TKW.js +1 -1
- package/dist/chunk-JQLCZGQ7.js +1 -0
- package/dist/chunk-NYZR4XKO.js +1 -1
- package/dist/chunk-WDPOWIJR.js +1 -0
- package/dist/chunk-X7VAACWY.js +1 -1
- package/dist/chunk-YNOIG4FD.js +1 -0
- package/dist/formats/index.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/models/chat-model.d.ts +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +1 -1
- package/dist/models/mock-model.d.ts +2 -0
- package/dist/models/model-cost.d.ts +5 -0
- package/dist/models/model-pricing-generator.d.ts +9 -0
- package/dist/models/model-pricing-products.d.ts +45 -0
- package/dist/models/model-pricing-types.d.ts +33 -0
- package/dist/models/model-pricing.d.ts +13 -0
- package/dist/models/model-pricing.generated.d.ts +23147 -0
- package/dist/models/openai-surfaces.d.ts +3 -0
- package/dist/models/routed-model.d.ts +3 -0
- package/dist/shared/index.js +1 -1
- package/dist/shared/types.d.ts +34 -7
- package/dist/tools/index.js +1 -1
- package/dist/tools/mcp-server-manager.d.ts +9 -4
- package/dist/tools/mcp-tool-adapter.d.ts +6 -1
- package/dist/tools/runtime-manager-tools.d.ts +11 -0
- package/dist/tools/tools.d.ts +4 -1
- package/package.json +2 -2
- package/dist/chunk-E4R6CEFK.js +0 -1
- package/dist/chunk-RABU4RC2.js +0 -1
- package/dist/chunk-RTDLM6FU.js +0 -1
|
@@ -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;
|
package/dist/shared/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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};
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -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>;
|