@nuvin/agent-core 0.1.0-rc.9 → 0.1.1-rc.0
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/chunk-BLGBVFVX.js +1 -0
- package/dist/chunk-D5IVWJHX.js +1 -0
- package/dist/chunk-FFIZ6TKW.js +1 -1
- package/dist/chunk-NYZR4XKO.js +1 -1
- package/dist/chunk-UIXQPCSN.js +1 -0
- package/dist/chunk-X7VAACWY.js +1 -1
- package/dist/chunk-YWQXXHHU.js +1 -1
- package/dist/formats/index.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/models/chat-model.d.ts +3 -1
- package/dist/models/index.js +1 -1
- package/dist/models/mock-model.d.ts +2 -0
- package/dist/models/openai-model.d.ts +4 -0
- package/dist/models/openai-surfaces.d.ts +3 -0
- package/dist/models/routed-model.d.ts +2 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +1 -1
- package/dist/shared/model-identity.d.ts +2 -0
- package/dist/shared/types.d.ts +8 -0
- package/dist/tools/bash-tool.d.ts +11 -0
- package/dist/tools/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-LIJXXCAA.js +0 -1
- package/dist/chunk-MO47BDD7.js +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ChatRequest, ChatResponse, EngineChatModel, ModelExecutionOptions, ReasoningConfig } from "../shared/types.ts";
|
|
2
2
|
export interface MockModelOptions {
|
|
3
3
|
model?: string;
|
|
4
|
+
modelIdentity?: string;
|
|
4
5
|
maxTokens?: number;
|
|
5
6
|
reasoning?: ReasoningConfig;
|
|
6
7
|
}
|
|
7
8
|
export declare class MockModel implements EngineChatModel {
|
|
8
9
|
readonly model: string;
|
|
10
|
+
readonly modelIdentity: string;
|
|
9
11
|
readonly maxTokens?: number;
|
|
10
12
|
readonly requests: ChatRequest[];
|
|
11
13
|
private readonly reasoning?;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { BaseChatModelOptions, ChatRequest, ChatResponse, ChatResponseChunk, ModelExecutionOptions, ProviderCredential } from "../shared/types.ts";
|
|
2
2
|
import type { WebSocketFactory } from "./model-transports.ts";
|
|
3
|
+
import type { OpenAiPromptCacheKeyResolver } from "./openai-surfaces.ts";
|
|
3
4
|
import { OpenAiApiError } from "./openai-surfaces.ts";
|
|
4
5
|
import type { ProviderRequestMutator, ProviderSessionResolver, ResolvedProviderSession } from "./provider-session.ts";
|
|
5
6
|
import { type ProviderSessionManager } from "./provider-session.ts";
|
|
6
7
|
import { RoutedModel } from "./routed-model.ts";
|
|
7
8
|
export type { WebSocketFactory } from "./model-transports.ts";
|
|
9
|
+
export type { OpenAiPromptCacheKeyResolver } from "./openai-surfaces.ts";
|
|
8
10
|
export { OpenAiApiError };
|
|
9
11
|
export interface OpenAiRequestHeadersContext {
|
|
10
12
|
request?: ChatRequest;
|
|
@@ -21,6 +23,7 @@ export interface OpenAiModelOptions extends Partial<BaseChatModelOptions> {
|
|
|
21
23
|
responsesPath?: string;
|
|
22
24
|
fetch?: typeof globalThis.fetch;
|
|
23
25
|
providerSessionResolver?: ProviderSessionResolver;
|
|
26
|
+
promptCacheKeyResolver?: OpenAiPromptCacheKeyResolver;
|
|
24
27
|
requestMutators?: ProviderRequestMutator[];
|
|
25
28
|
headerResolver?: OpenAiHeaderResolver;
|
|
26
29
|
sessionManager?: ProviderSessionManager;
|
|
@@ -28,6 +31,7 @@ export interface OpenAiModelOptions extends Partial<BaseChatModelOptions> {
|
|
|
28
31
|
}
|
|
29
32
|
export declare class OpenAiModel extends RoutedModel {
|
|
30
33
|
private readonly responsesSocketSessions;
|
|
34
|
+
private readonly promptCacheKeyResolver?;
|
|
31
35
|
protected readonly chatCompletionsPath: string;
|
|
32
36
|
protected readonly responsesPath: string;
|
|
33
37
|
constructor(options?: OpenAiModelOptions);
|
|
@@ -6,6 +6,7 @@ export declare const OPENAI_CHAT_COMPLETIONS_STREAM_SURFACE = "openai-chat-compl
|
|
|
6
6
|
export declare const OPENAI_RESPONSES_SURFACE = "openai-responses";
|
|
7
7
|
export declare const OPENAI_RESPONSES_STREAM_SURFACE = "openai-responses-stream";
|
|
8
8
|
export declare const OPENAI_RESPONSES_WEBSOCKET_SURFACE = "openai-responses-ws";
|
|
9
|
+
export type OpenAiPromptCacheKeyResolver = (request: ChatRequest) => string | undefined;
|
|
9
10
|
interface OpenAiChatCompletionToolCall {
|
|
10
11
|
id: string;
|
|
11
12
|
type: "function";
|
|
@@ -62,12 +63,14 @@ export declare class OpenAiApiError extends Error {
|
|
|
62
63
|
export declare function createChatRequestBody(request: ChatRequest, stream: boolean): OpenAiChatCompletionsRequest;
|
|
63
64
|
export declare function createOpenAiResponsesWebSocketEvent(request: ChatRequest, options?: {
|
|
64
65
|
input?: ReturnType<typeof toOpenAiResponsesRequest>["input"];
|
|
66
|
+
promptCacheKey?: string;
|
|
65
67
|
previousResponseId?: string;
|
|
66
68
|
}): Record<string, unknown>;
|
|
67
69
|
export declare function createOpenAiApiError(response: Response): Promise<OpenAiApiError>;
|
|
68
70
|
export declare function createOpenAiResponsesStreamParser(request: ChatRequest): RoutedModelStreamParser;
|
|
69
71
|
export declare function createOpenAiSurfaces(options?: {
|
|
70
72
|
chatCompletionsPath?: string;
|
|
73
|
+
promptCacheKeyResolver?: OpenAiPromptCacheKeyResolver;
|
|
71
74
|
responsesPath?: string;
|
|
72
75
|
}): RoutedModelSurface[];
|
|
73
76
|
export {};
|
|
@@ -30,6 +30,7 @@ export interface RoutedModelOptions {
|
|
|
30
30
|
baseUrl: string;
|
|
31
31
|
fetch?: typeof globalThis.fetch;
|
|
32
32
|
model: string;
|
|
33
|
+
modelIdentity?: string;
|
|
33
34
|
maxTokens?: number;
|
|
34
35
|
reasoning?: ReasoningConfig;
|
|
35
36
|
providerAdapter: ProviderAdapter;
|
|
@@ -42,6 +43,7 @@ export interface RoutedModelOptions {
|
|
|
42
43
|
}
|
|
43
44
|
export declare class RoutedModel implements EngineChatModel {
|
|
44
45
|
readonly model: string;
|
|
46
|
+
readonly modelIdentity: string;
|
|
45
47
|
readonly maxTokens?: number;
|
|
46
48
|
protected readonly reasoning?: ReasoningConfig;
|
|
47
49
|
protected readonly apiKey?: string;
|
package/dist/shared/index.d.ts
CHANGED
package/dist/shared/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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};
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -335,6 +335,12 @@ export interface ResolvedProviderSession {
|
|
|
335
335
|
}
|
|
336
336
|
export interface ProviderSessionResolver {
|
|
337
337
|
resolve(signal?: AbortSignal): Promise<ResolvedProviderSession>;
|
|
338
|
+
/**
|
|
339
|
+
* Optional hook invoked by {@link ProviderSessionManager.invalidate} before
|
|
340
|
+
* the cached session is dropped. Used by resolvers that must force a token
|
|
341
|
+
* refresh on the next resolve (e.g. ChatGPT OAuth after a provider 401).
|
|
342
|
+
*/
|
|
343
|
+
invalidate?(): void;
|
|
338
344
|
}
|
|
339
345
|
export interface PrepareRequestInput {
|
|
340
346
|
sessionId: string;
|
|
@@ -371,6 +377,7 @@ export interface TurnMessageMeta {
|
|
|
371
377
|
}
|
|
372
378
|
export interface EngineChatModel {
|
|
373
379
|
model: string;
|
|
380
|
+
modelIdentity: string;
|
|
374
381
|
provider?: string;
|
|
375
382
|
maxTokens?: number;
|
|
376
383
|
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
@@ -379,6 +386,7 @@ export interface EngineChatModel {
|
|
|
379
386
|
}
|
|
380
387
|
export interface BaseChatModelOptions {
|
|
381
388
|
model: string;
|
|
389
|
+
modelIdentity?: string;
|
|
382
390
|
maxTokens?: number;
|
|
383
391
|
reasoning?: ReasoningConfig;
|
|
384
392
|
providerSessionResolver?: ProviderSessionResolver;
|
|
@@ -5,6 +5,7 @@ export interface BashToolInput {
|
|
|
5
5
|
cwd?: string;
|
|
6
6
|
timeoutMs?: number;
|
|
7
7
|
ignoreOutput?: boolean;
|
|
8
|
+
outputRegex?: string;
|
|
8
9
|
runInBackground?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export interface BashToolOptions {
|
|
@@ -25,6 +26,7 @@ export declare function createBashTool(options?: BashToolOptions): import("../sh
|
|
|
25
26
|
timeoutMs?: number | undefined;
|
|
26
27
|
cwd?: string | undefined;
|
|
27
28
|
ignoreOutput?: boolean | undefined;
|
|
29
|
+
outputRegex?: string | undefined;
|
|
28
30
|
runInBackground?: boolean | undefined;
|
|
29
31
|
}, string, import("../shared/types.ts").ToolOutputEnvelope, {
|
|
30
32
|
type: "object";
|
|
@@ -45,6 +47,10 @@ export declare function createBashTool(options?: BashToolOptions): import("../sh
|
|
|
45
47
|
ignoreOutput: {
|
|
46
48
|
type: "boolean";
|
|
47
49
|
};
|
|
50
|
+
outputRegex: {
|
|
51
|
+
type: "string";
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
48
54
|
runInBackground: {
|
|
49
55
|
type: "boolean";
|
|
50
56
|
};
|
|
@@ -57,6 +63,7 @@ export declare function createShellExecTool(options?: BashToolOptions): import("
|
|
|
57
63
|
timeoutMs?: number | undefined;
|
|
58
64
|
cwd?: string | undefined;
|
|
59
65
|
ignoreOutput?: boolean | undefined;
|
|
66
|
+
outputRegex?: string | undefined;
|
|
60
67
|
runInBackground?: boolean | undefined;
|
|
61
68
|
}, string, import("../shared/types.ts").ToolOutputEnvelope, {
|
|
62
69
|
type: "object";
|
|
@@ -77,6 +84,10 @@ export declare function createShellExecTool(options?: BashToolOptions): import("
|
|
|
77
84
|
ignoreOutput: {
|
|
78
85
|
type: "boolean";
|
|
79
86
|
};
|
|
87
|
+
outputRegex: {
|
|
88
|
+
type: "string";
|
|
89
|
+
description: string;
|
|
90
|
+
};
|
|
80
91
|
runInBackground: {
|
|
81
92
|
type: "boolean";
|
|
82
93
|
};
|