@nuvin/agent-core 0.1.0-rc.1 → 0.1.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.
@@ -6,7 +6,7 @@ export interface MockModelOptions {
6
6
  }
7
7
  export declare class MockModel implements EngineChatModel {
8
8
  readonly model: string;
9
- readonly maxTokens: number;
9
+ readonly maxTokens?: number;
10
10
  readonly requests: ChatRequest[];
11
11
  private readonly reasoning?;
12
12
  constructor(options?: MockModelOptions);
@@ -33,7 +33,6 @@ export interface ResolvedModelProfile {
33
33
  export declare function getProviderProfile(provider: string): ProviderProfile | undefined;
34
34
  export declare function getModelProfile(provider: string, model: string): ModelProfile | undefined;
35
35
  export declare function resolveModelProfile(provider: string, model: string): ResolvedModelProfile | undefined;
36
- export declare function getDefaultMaxTokens(): number;
37
36
  export declare function getDefaultModel(): string;
38
37
  export declare function getCliDefaultModel(): string;
39
38
  export declare function getProviderLabel(provider: string): string | undefined;
@@ -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 {};
@@ -42,7 +42,7 @@ export interface RoutedModelOptions {
42
42
  }
43
43
  export declare class RoutedModel implements EngineChatModel {
44
44
  readonly model: string;
45
- readonly maxTokens: number;
45
+ readonly maxTokens?: number;
46
46
  protected readonly reasoning?: ReasoningConfig;
47
47
  protected readonly apiKey?: string;
48
48
  protected readonly baseUrl: string;
@@ -1 +1 @@
1
- (function(_0x516650,_0xa1311a){var _0x3b7553={_0x12490f:0x248,_0x4cf33c:0x24e,_0xa5c352:0x249,_0x32d3ef:0x24a,_0xfd935b:0x250,_0x6e161:0x243,_0x454059:0x237,_0x3be5c6:0x236,_0x4dc97d:0x236,_0x363110:0x238,_0x9b2505:0x244,_0x46bffc:0x247,_0x5a0662:0x247,_0x312419:0x237,_0x4c7cd1:0x245,_0x37ba09:0x242},_0x43943b={_0x1aa851:0x3e4};function _0x3657be(_0x516416,_0x37af82,_0x4983ae,_0x4330cd){return _0x35f3(_0x516416-0x93,_0x37af82);}var _0x1d3c8c=_0x516650();function _0x355e3f(_0x4f7964,_0x186616,_0x510366,_0x7ed936){return _0x35f3(_0x510366- -_0x43943b._0x1aa851,_0x4f7964);}while(!![]){try{var _0x520bbe=parseInt(_0x3657be(_0x3b7553._0x12490f,0x24c,_0x3b7553._0x4cf33c,_0x3b7553._0xa5c352))/0x1*(parseInt(_0x3657be(_0x3b7553._0x32d3ef,0x24f,_0x3b7553._0xfd935b,0x24d))/0x2)+-parseInt(_0x3657be(0x240,_0x3b7553._0x6e161,0x245,0x246))/0x3*(parseInt(_0x355e3f(-_0x3b7553._0x454059,-0x230,-0x231,-0x235))/0x4)+-parseInt(_0x355e3f(-0x235,-0x238,-0x232,-0x238))/0x5+parseInt(_0x355e3f(-0x237,-_0x3b7553._0x3be5c6,-_0x3b7553._0x4dc97d,-_0x3b7553._0x363110))/0x6*(-parseInt(_0x3657be(0x249,_0x3b7553._0x9b2505,0x24a,_0x3b7553._0x4cf33c))/0x7)+parseInt(_0x3657be(_0x3b7553._0x46bffc,_0x3b7553._0x5a0662,0x246,0x24c))/0x8*(-parseInt(_0x355e3f(-0x238,-0x22f,-0x233,-_0x3b7553._0x312419))/0x9)+parseInt(_0x355e3f(-0x238,-0x233,-0x234,-0x235))/0xa+parseInt(_0x3657be(0x24b,0x24c,0x245,_0x3b7553._0x4c7cd1))/0xb*(parseInt(_0x3657be(_0x3b7553._0x37ba09,0x243,0x240,0x23c))/0xc);if(_0x520bbe===_0xa1311a)break;else _0x1d3c8c['push'](_0x1d3c8c['shift']());}catch(_0x15f642){_0x1d3c8c['push'](_0x1d3c8c['shift']());}}}(_0x4bb5,0xde206));import{mapAutoReasoningEffortToBudgetTokens,resolveAnthropicThinkingConfig,resolveOpenAiReasoningConfig}from'../chunk-NYZR4XKO.js';function _0x4bb5(){var _0x462858=['mJGYmZm0mhvtAuLqtq','mteYmtCZmMXmzxDZDW','oti5nK9HwvHXza','mMDZq0nSDG','mZyWmtvRAfzhq1e','mtq3nZCYnMjzs2rtqW','mti2mtDjCxrSANC','mtjmruvPrw4','odr2AxbVrNu','mJe1mJHZvK5bzLm','ndaYodGYmfbnv3rtDa','otGZn3bfELjQza'];_0x4bb5=function(){return _0x462858;};return _0x4bb5();}import{TurnFailedError}from'../chunk-FFIZ6TKW.js';import{OperationAbortedError,addAbortListener,isAbortError,throwIfAborted,toAbortError}from'../chunk-X7VAACWY.js';function _0x35f3(_0x3bc35e,_0x1a5460){_0x3bc35e=_0x3bc35e-0x1ad;var _0x4bb599=_0x4bb5();var _0x35f373=_0x4bb599[_0x3bc35e];if(_0x35f3['dlcxFU']===undefined){var _0x29b7cd=function(_0x10fd95){var _0x16b1f5='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x55d045='',_0x566873='';for(var _0x124bf7=0x0,_0x20e49b,_0x2dcd18,_0xe68fa8=0x0;_0x2dcd18=_0x10fd95['charAt'](_0xe68fa8++);~_0x2dcd18&&(_0x20e49b=_0x124bf7%0x4?_0x20e49b*0x40+_0x2dcd18:_0x2dcd18,_0x124bf7++%0x4)?_0x55d045+=String['fromCharCode'](0xff&_0x20e49b>>(-0x2*_0x124bf7&0x6)):0x0){_0x2dcd18=_0x16b1f5['indexOf'](_0x2dcd18);}for(var _0x3a3eae=0x0,_0x5ca88c=_0x55d045['length'];_0x3a3eae<_0x5ca88c;_0x3a3eae++){_0x566873+='%'+('00'+_0x55d045['charCodeAt'](_0x3a3eae)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x566873);};_0x35f3['SDieXY']=_0x29b7cd,_0x35f3['KcVGYK']={},_0x35f3['dlcxFU']=!![];}var _0x15d7d6=_0x4bb599[0x0],_0x1cf5ad=_0x3bc35e+_0x15d7d6,_0x54212c=_0x35f3['KcVGYK'][_0x1cf5ad];return!_0x54212c?(_0x35f373=_0x35f3['SDieXY'](_0x35f373),_0x35f3['KcVGYK'][_0x1cf5ad]=_0x35f373):_0x35f373=_0x54212c,_0x35f373;}export{OperationAbortedError,TurnFailedError,addAbortListener,isAbortError,mapAutoReasoningEffortToBudgetTokens,resolveAnthropicThinkingConfig,resolveOpenAiReasoningConfig,throwIfAborted,toAbortError};
1
+ (function(_0x449cff,_0x34b35e){var _0x1abe19={_0x3022b4:0x19e,_0x39e9f8:0x19a,_0x51f1fe:0x19c,_0x3006e8:0x19c,_0x2243b1:0x198,_0x14ec78:0x19d,_0xb66913:0x1b3,_0x275a85:0x1b5,_0x4900f9:0x1b7,_0x46f519:0x1b2,_0x36085f:0x1b0,_0x4a718d:0x1b6,_0x57f630:0x1b4,_0x30fa89:0x1b1},_0x4f78ce=_0x449cff();function _0x53ee4e(_0x250ec3,_0x57edb6,_0x3c3583,_0x40070b){return _0xabc5(_0x3c3583-0x95,_0x250ec3);}function _0x19a654(_0x47e954,_0x35a031,_0x30dd2c,_0x1d334d){return _0xabc5(_0x35a031-0xaa,_0x47e954);}while(!![]){try{var _0x33d6c7=-parseInt(_0x53ee4e(0x196,_0x1abe19._0x3022b4,_0x1abe19._0x39e9f8,_0x1abe19._0x51f1fe))/0x1+-parseInt(_0x53ee4e(_0x1abe19._0x3006e8,_0x1abe19._0x2243b1,_0x1abe19._0x14ec78,0x198))/0x2+parseInt(_0x19a654(0x1b4,_0x1abe19._0xb66913,_0x1abe19._0x275a85,_0x1abe19._0x4900f9))/0x3*(parseInt(_0x19a654(_0x1abe19._0x46f519,0x1ad,0x1aa,0x1b2))/0x4)+parseInt(_0x19a654(0x1b4,_0x1abe19._0x36085f,0x1b0,0x1af))/0x5+-parseInt(_0x19a654(0x1b1,0x1b5,0x1b8,0x1b5))/0x6*(parseInt(_0x19a654(_0x1abe19._0x4a718d,_0x1abe19._0x57f630,0x1b5,0x1b4))/0x7)+parseInt(_0x19a654(_0x1abe19._0x30fa89,0x1ae,0x1ab,0x1ae))/0x8+parseInt(_0x53ee4e(0x198,0x19b,0x19c,0x19a))/0x9;if(_0x33d6c7===_0x34b35e)break;else _0x4f78ce['push'](_0x4f78ce['shift']());}catch(_0x3f61c1){_0x4f78ce['push'](_0x4f78ce['shift']());}}}(_0x5992,0xce5f7));function _0x5992(){var _0x5addfd=['mtrNEgfNAvC','mteWndqYrMHWyLbA','nJCYmdG4DevTCLbQ','ntiYnJmXmKDLyw5ysq','mtu4mJC2m2zJzKLAEq','nJG3mdG3nwT3DKLLEG','mtqWnJK2muH5wwfjwa','nZGYmdaYsMrID0z6','mtjqsvLOAKy'];_0x5992=function(){return _0x5addfd;};return _0x5992();}import{mapAutoReasoningEffortToBudgetTokens,resolveAnthropicThinkingConfig,resolveOpenAiReasoningConfig}from'../chunk-NYZR4XKO.js';import{TurnFailedError}from'../chunk-FFIZ6TKW.js';function _0xabc5(_0x49f003,_0x4417ee){_0x49f003=_0x49f003-0x103;var _0x599292=_0x5992();var _0xabc545=_0x599292[_0x49f003];if(_0xabc5['wKfiBV']===undefined){var _0x5863e1=function(_0x97c989){var _0x38d313='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x4efa0d='',_0x30d0c3='';for(var _0x24a94e=0x0,_0x42a495,_0x56717f,_0x2ea677=0x0;_0x56717f=_0x97c989['charAt'](_0x2ea677++);~_0x56717f&&(_0x42a495=_0x24a94e%0x4?_0x42a495*0x40+_0x56717f:_0x56717f,_0x24a94e++%0x4)?_0x4efa0d+=String['fromCharCode'](0xff&_0x42a495>>(-0x2*_0x24a94e&0x6)):0x0){_0x56717f=_0x38d313['indexOf'](_0x56717f);}for(var _0x421cdb=0x0,_0xc0345d=_0x4efa0d['length'];_0x421cdb<_0xc0345d;_0x421cdb++){_0x30d0c3+='%'+('00'+_0x4efa0d['charCodeAt'](_0x421cdb)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x30d0c3);};_0xabc5['eCTcNX']=_0x5863e1,_0xabc5['uOcKyq']={},_0xabc5['wKfiBV']=!![];}var _0x412cda=_0x599292[0x0],_0x1812dd=_0x49f003+_0x412cda,_0x3341b5=_0xabc5['uOcKyq'][_0x1812dd];return!_0x3341b5?(_0xabc545=_0xabc5['eCTcNX'](_0xabc545),_0xabc5['uOcKyq'][_0x1812dd]=_0xabc545):_0xabc545=_0x3341b5,_0xabc545;}import{OperationAbortedError,addAbortListener,isAbortError,throwIfAborted,toAbortError}from'../chunk-X7VAACWY.js';export{OperationAbortedError,TurnFailedError,addAbortListener,isAbortError,mapAutoReasoningEffortToBudgetTokens,resolveAnthropicThinkingConfig,resolveOpenAiReasoningConfig,throwIfAborted,toAbortError};
@@ -6,6 +6,7 @@ export type JsonValue = JsonObject | JsonPrimitive | JsonValue[];
6
6
  export type JsonSchemaType = "array" | "boolean" | "number" | "object" | "string";
7
7
  export interface JsonSchemaString {
8
8
  type: "string";
9
+ description?: string;
9
10
  }
10
11
  export interface JsonSchemaNumber {
11
12
  type: "number";
@@ -159,7 +160,7 @@ export interface OutputFormat {
159
160
  }
160
161
  export interface ModelRequest {
161
162
  model: string;
162
- max_tokens: number;
163
+ max_tokens?: number;
163
164
  reasoning?: ReasoningConfig;
164
165
  system: TextBlock[];
165
166
  messages: Message[];
@@ -182,7 +183,7 @@ export interface ModelResponse {
182
183
  }
183
184
  export interface ChatRequest {
184
185
  model: string;
185
- maxTokens: number;
186
+ maxTokens?: number;
186
187
  reasoning?: ReasoningConfig;
187
188
  system: TextBlock[];
188
189
  messages: Message[];
@@ -334,6 +335,12 @@ export interface ResolvedProviderSession {
334
335
  }
335
336
  export interface ProviderSessionResolver {
336
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;
337
344
  }
338
345
  export interface PrepareRequestInput {
339
346
  sessionId: string;
@@ -502,6 +509,15 @@ export type ToolRuntimeDispatchDecision = {
502
509
  reason?: string;
503
510
  } | {
504
511
  action: "run";
512
+ /**
513
+ * Present when the user granted directory access as part of approving
514
+ * this call (dir-access prompt). Applied by the dispatcher that owns
515
+ * the live allowedDirs array; the tool runtime itself ignores it.
516
+ */
517
+ grantDir?: {
518
+ dir: string;
519
+ persist: boolean;
520
+ };
505
521
  };
506
522
  export type ToolRuntimeToolCallHandler = (toolCall: ToolUseBlock, ctx: ToolExecutionContext) => Promise<ToolRuntimeDispatchDecision | undefined> | ToolRuntimeDispatchDecision | undefined;
507
523
  export type ToolRuntimeEventHandler = (event: ToolRuntimeEvent, ctx: ToolExecutionContext) => Promise<void> | void;
@@ -4,8 +4,8 @@ export declare function createAskUserTool(): import("../shared/types.ts").ToolDe
4
4
  question: string;
5
5
  topic: string;
6
6
  options: {
7
- label: string;
8
7
  description: string;
8
+ label: string;
9
9
  }[];
10
10
  multiSelect: boolean;
11
11
  }[];
@@ -1,6 +1,7 @@
1
1
  import type { BackgroundProcessRegistry } from "./background-process-registry.ts";
2
2
  export interface BashToolInput {
3
3
  command: string;
4
+ description: string;
4
5
  cwd?: string;
5
6
  timeoutMs?: number;
6
7
  ignoreOutput?: boolean;
@@ -19,6 +20,7 @@ export interface BashToolOptions {
19
20
  backgroundRegistry?: BackgroundProcessRegistry;
20
21
  }
21
22
  export declare function createBashTool(options?: BashToolOptions): import("../shared/types.ts").ToolDefinition<{
23
+ description: string;
22
24
  command: string;
23
25
  timeoutMs?: number | undefined;
24
26
  cwd?: string | undefined;
@@ -30,6 +32,10 @@ export declare function createBashTool(options?: BashToolOptions): import("../sh
30
32
  command: {
31
33
  type: "string";
32
34
  };
35
+ description: {
36
+ type: "string";
37
+ description: string;
38
+ };
33
39
  cwd: {
34
40
  type: "string";
35
41
  };
@@ -43,9 +49,10 @@ export declare function createBashTool(options?: BashToolOptions): import("../sh
43
49
  type: "boolean";
44
50
  };
45
51
  };
46
- required: readonly ["command"];
52
+ required: readonly ["command", "description"];
47
53
  }>;
48
54
  export declare function createShellExecTool(options?: BashToolOptions): import("../shared/types.ts").ToolDefinition<{
55
+ description: string;
49
56
  command: string;
50
57
  timeoutMs?: number | undefined;
51
58
  cwd?: string | undefined;
@@ -57,6 +64,10 @@ export declare function createShellExecTool(options?: BashToolOptions): import("
57
64
  command: {
58
65
  type: "string";
59
66
  };
67
+ description: {
68
+ type: "string";
69
+ description: string;
70
+ };
60
71
  cwd: {
61
72
  type: "string";
62
73
  };
@@ -70,6 +81,6 @@ export declare function createShellExecTool(options?: BashToolOptions): import("
70
81
  type: "boolean";
71
82
  };
72
83
  };
73
- required: readonly ["command"];
84
+ required: readonly ["command", "description"];
74
85
  }>;
75
86
  //# sourceMappingURL=bash-tool.d.ts.map
@@ -7,6 +7,7 @@ export declare function createFileEditTool(options?: FileEditToolOptions): impor
7
7
  filePath: string;
8
8
  oldText: string;
9
9
  newText: string;
10
+ description?: string | undefined;
10
11
  dryRun?: boolean | undefined;
11
12
  }, import("../shared/types.ts").ToolOutputEnvelope, undefined, {
12
13
  type: "object";
@@ -14,6 +15,10 @@ export declare function createFileEditTool(options?: FileEditToolOptions): impor
14
15
  filePath: {
15
16
  type: "string";
16
17
  };
18
+ description: {
19
+ type: "string";
20
+ description: string;
21
+ };
17
22
  oldText: {
18
23
  type: "string";
19
24
  };