@dudko.dev/agent 0.0.37 → 0.0.39
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/README.md +76 -7
- package/dist/cli.js +111 -85
- package/dist/index.cjs +79 -62
- package/dist/index.d.cts +149 -2
- package/dist/index.d.ts +149 -2
- package/dist/index.js +79 -62
- package/dist/subagent-worker.js +67 -56
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -54,6 +54,51 @@ interface RunControl {
|
|
|
54
54
|
}
|
|
55
55
|
declare const createRunControl: () => RunControl;
|
|
56
56
|
|
|
57
|
+
type EgressErrorCode = 'disabled' | 'bad-url' | 'bad-protocol' | 'bad-port' | 'bad-method' | 'credentials-in-url' | 'denied-host' | 'not-allowed-host' | 'denied-address' | 'dns' | 'bad-redirect' | 'too-many-redirects' | 'too-large' | 'timeout';
|
|
58
|
+
declare class EgressError extends Error {
|
|
59
|
+
readonly code: EgressErrorCode;
|
|
60
|
+
constructor(code: EgressErrorCode, message: string);
|
|
61
|
+
toJSON(): string;
|
|
62
|
+
}
|
|
63
|
+
interface IResolvedAddress {
|
|
64
|
+
address: string;
|
|
65
|
+
family: 4 | 6;
|
|
66
|
+
}
|
|
67
|
+
interface IEgressPolicy {
|
|
68
|
+
allow?: string[];
|
|
69
|
+
deny?: string[];
|
|
70
|
+
allowPrivateNetwork?: boolean;
|
|
71
|
+
protocols?: ('https' | 'http')[];
|
|
72
|
+
ports?: number[];
|
|
73
|
+
methods?: string[];
|
|
74
|
+
maxRedirects?: number;
|
|
75
|
+
maxResponseBytes?: number;
|
|
76
|
+
timeoutMs?: number;
|
|
77
|
+
ca?: string | string[];
|
|
78
|
+
lookup?: (hostname: string) => Promise<IResolvedAddress[]>;
|
|
79
|
+
}
|
|
80
|
+
interface IResolvedEgressPolicy {
|
|
81
|
+
allow: string[];
|
|
82
|
+
deny: string[];
|
|
83
|
+
allowPrivateNetwork: boolean;
|
|
84
|
+
protocols: ('https' | 'http')[];
|
|
85
|
+
ports: number[];
|
|
86
|
+
methods: string[];
|
|
87
|
+
maxRedirects: number;
|
|
88
|
+
maxResponseBytes: number;
|
|
89
|
+
timeoutMs: number;
|
|
90
|
+
ca?: string | string[];
|
|
91
|
+
lookup: (hostname: string) => Promise<IResolvedAddress[]>;
|
|
92
|
+
}
|
|
93
|
+
declare const resolveEgressPolicy: (policy?: IEgressPolicy) => IResolvedEgressPolicy;
|
|
94
|
+
type AddressClass = 'public' | 'private' | 'never';
|
|
95
|
+
declare const classifyAddress: (address: string) => AddressClass;
|
|
96
|
+
declare const hostMatches: (host: string, pattern: string) => boolean;
|
|
97
|
+
declare const checkEgressUrl: (url: URL, policy: IResolvedEgressPolicy, method?: string) => void;
|
|
98
|
+
declare const checkRedirect: (from: URL, to: URL) => void;
|
|
99
|
+
type SafeFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
100
|
+
declare const createSafeFetch: (policy?: IEgressPolicy) => SafeFetch;
|
|
101
|
+
|
|
57
102
|
type ProviderType = 'openai' | 'anthropic' | 'openai-compatible' | 'google' | 'xai' | 'azure' | 'amazon-bedrock' | 'google-vertex' | 'deepseek' | 'gateway' | 'cloudflare';
|
|
58
103
|
type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
59
104
|
type ToolSelectionStrategy = 'all' | 'plan-narrowed' | 'search' | 'auto';
|
|
@@ -89,6 +134,7 @@ interface ICompactionConfig {
|
|
|
89
134
|
auto?: boolean;
|
|
90
135
|
contextWindowTokens?: number;
|
|
91
136
|
thresholdTokens?: number;
|
|
137
|
+
thresholdRatio?: number;
|
|
92
138
|
keepRecentTurns?: number;
|
|
93
139
|
keepRecentSteps?: number;
|
|
94
140
|
summaryMaxTokens?: number;
|
|
@@ -104,6 +150,26 @@ interface ISkill {
|
|
|
104
150
|
path: string;
|
|
105
151
|
content: string;
|
|
106
152
|
}[];
|
|
153
|
+
origin?: ISkillOrigin;
|
|
154
|
+
}
|
|
155
|
+
interface ISkillOrigin {
|
|
156
|
+
kind: 'learned';
|
|
157
|
+
at: number;
|
|
158
|
+
revision: number;
|
|
159
|
+
runId?: string;
|
|
160
|
+
sources?: string[];
|
|
161
|
+
fetched?: string[];
|
|
162
|
+
}
|
|
163
|
+
interface ISkillStore {
|
|
164
|
+
list: () => ISkill[] | Promise<ISkill[]>;
|
|
165
|
+
save: (skill: ISkill) => void | Promise<void>;
|
|
166
|
+
remove: (name: string) => boolean | Promise<boolean>;
|
|
167
|
+
}
|
|
168
|
+
interface ILearningConfig {
|
|
169
|
+
store?: ISkillStore;
|
|
170
|
+
maxSkills?: number;
|
|
171
|
+
maxSkillChars?: number;
|
|
172
|
+
nudge?: boolean;
|
|
107
173
|
}
|
|
108
174
|
type ToolApprovalMode = 'autopilot' | 'ask-writes' | 'ask-all' | 'read-only';
|
|
109
175
|
type ToolPermission = 'allow' | 'ask' | 'deny';
|
|
@@ -173,6 +239,8 @@ interface IAgentConfig {
|
|
|
173
239
|
/** @deprecated use `synthesizer: { model }` */
|
|
174
240
|
synthesizerModel?: string;
|
|
175
241
|
mcpServers: Record<string, IMcpServerConfig>;
|
|
242
|
+
egress?: boolean | IEgressPolicy;
|
|
243
|
+
learning?: boolean | ILearningConfig;
|
|
176
244
|
tools?: ToolSet;
|
|
177
245
|
availableTools?: string[];
|
|
178
246
|
excludedTools?: string[];
|
|
@@ -377,6 +445,22 @@ type AgentEventBody = {
|
|
|
377
445
|
id: string;
|
|
378
446
|
text: string;
|
|
379
447
|
at: 'round' | 'step' | 'final';
|
|
448
|
+
} | {
|
|
449
|
+
type: 'egress.request';
|
|
450
|
+
url: string;
|
|
451
|
+
allowed: boolean;
|
|
452
|
+
status?: number;
|
|
453
|
+
reason?: string;
|
|
454
|
+
} | {
|
|
455
|
+
type: 'skill.learned';
|
|
456
|
+
name: string;
|
|
457
|
+
description: string;
|
|
458
|
+
update: boolean;
|
|
459
|
+
chars: number;
|
|
460
|
+
sources: string[];
|
|
461
|
+
} | {
|
|
462
|
+
type: 'skill.forgotten';
|
|
463
|
+
name: string;
|
|
380
464
|
} | {
|
|
381
465
|
type: 'revisions.exceeded';
|
|
382
466
|
cap: number;
|
|
@@ -462,10 +546,15 @@ interface ICompactResult {
|
|
|
462
546
|
interface IAgent {
|
|
463
547
|
run: (options: IAgentRunOptions) => Promise<IAgentRunResult>;
|
|
464
548
|
listTools: () => IToolCatalogEntry[];
|
|
549
|
+
readonly usage: IUsage;
|
|
550
|
+
resetUsage: () => void;
|
|
465
551
|
listSkills: () => {
|
|
466
552
|
name: string;
|
|
467
553
|
description: string;
|
|
554
|
+
learned?: true;
|
|
468
555
|
}[];
|
|
556
|
+
listLearnedSkills: () => ISkill[];
|
|
557
|
+
forgetSkill: (name: string) => Promise<boolean>;
|
|
469
558
|
compact: (options: ICompactOptions) => Promise<ICompactResult>;
|
|
470
559
|
setToolApprovalMode: (mode: ToolApprovalMode) => void;
|
|
471
560
|
getToolApprovalMode: () => ToolApprovalMode;
|
|
@@ -706,12 +795,28 @@ declare const resolveLimits: (config: Pick<IAgentConfig, "limits" | "maxTotalTok
|
|
|
706
795
|
*/
|
|
707
796
|
declare const checkLimits: (usage: IUsage, limits: ITokenLimits | undefined) => ILimitBreach | undefined;
|
|
708
797
|
|
|
798
|
+
declare const DEFAULT_COMPACTION_THRESHOLD_RATIO = 0.85;
|
|
799
|
+
interface IResolvedCompaction {
|
|
800
|
+
auto: boolean;
|
|
801
|
+
contextWindowTokens: number;
|
|
802
|
+
thresholdTokens: number;
|
|
803
|
+
thresholdRatio: number;
|
|
804
|
+
keepRecentTurns: number;
|
|
805
|
+
keepRecentSteps: number;
|
|
806
|
+
summaryMaxTokens: number;
|
|
807
|
+
maxToolOutputChars: number;
|
|
808
|
+
clearToolResultsAfterTokens: number;
|
|
809
|
+
keepToolResults: number;
|
|
810
|
+
}
|
|
811
|
+
declare const resolveCompaction: (cfg: ICompactionConfig | undefined) => IResolvedCompaction;
|
|
709
812
|
declare const estimateTokens: (text: string) => number;
|
|
710
813
|
declare const SUMMARY_PREFIX = "[Summary of earlier conversation]";
|
|
711
814
|
interface ICompactHistoryOptions {
|
|
712
815
|
thresholdTokens?: number;
|
|
816
|
+
overheadTokens?: number;
|
|
713
817
|
keepRecentTurns?: number;
|
|
714
818
|
summaryMaxTokens?: number;
|
|
819
|
+
maxInputTokens?: number;
|
|
715
820
|
force?: boolean;
|
|
716
821
|
signal?: AbortSignal;
|
|
717
822
|
timeoutMs?: number;
|
|
@@ -832,6 +937,48 @@ interface IClearedInfo {
|
|
|
832
937
|
}
|
|
833
938
|
declare const createToolResultClearer: (opts: IToolResultClearing, onCleared?: (info: IClearedInfo) => void) => ((messages: ModelMessage[]) => ModelMessage[]);
|
|
834
939
|
|
|
940
|
+
declare const SAVE_SKILL_TOOL = "save_skill";
|
|
941
|
+
declare const FORGET_SKILL_TOOL = "forget_skill";
|
|
942
|
+
declare const findSecret: (text: string) => string | undefined;
|
|
943
|
+
declare const normalizeSkillName: (raw: string) => string | undefined;
|
|
944
|
+
declare class MemorySkillStore implements ISkillStore {
|
|
945
|
+
private readonly skills;
|
|
946
|
+
list(): ISkill[];
|
|
947
|
+
save(skill: ISkill): void;
|
|
948
|
+
remove(name: string): boolean;
|
|
949
|
+
}
|
|
950
|
+
declare class DirSkillStore implements ISkillStore {
|
|
951
|
+
private readonly dir;
|
|
952
|
+
constructor(dir: string);
|
|
953
|
+
list(): Promise<ISkill[]>;
|
|
954
|
+
save(skill: ISkill): Promise<void>;
|
|
955
|
+
remove(name: string): Promise<boolean>;
|
|
956
|
+
}
|
|
957
|
+
interface ILearning {
|
|
958
|
+
tools: ToolSet;
|
|
959
|
+
learned: () => ISkill[];
|
|
960
|
+
forget: (name: string) => Promise<boolean>;
|
|
961
|
+
}
|
|
962
|
+
interface ISaveSkillInput {
|
|
963
|
+
name: string;
|
|
964
|
+
description: string;
|
|
965
|
+
instructions: string;
|
|
966
|
+
sources?: string[];
|
|
967
|
+
}
|
|
968
|
+
declare const createLearning: (cfg: ILearningConfig, skills: ISkill[], emit: EventHandler, warn: (message: string) => void) => Promise<ILearning>;
|
|
969
|
+
|
|
970
|
+
declare const WEB_FETCH_TOOL = "web_fetch";
|
|
971
|
+
declare const htmlToText: (html: string) => {
|
|
972
|
+
title?: string;
|
|
973
|
+
text: string;
|
|
974
|
+
};
|
|
975
|
+
interface IWebFetchOptions {
|
|
976
|
+
policy?: IEgressPolicy;
|
|
977
|
+
fetch?: SafeFetch;
|
|
978
|
+
}
|
|
979
|
+
declare const createWebFetchTool: (options?: IWebFetchOptions) => Tool;
|
|
980
|
+
declare const createEgressTools: (egress: boolean | IEgressPolicy | undefined) => ToolSet | undefined;
|
|
981
|
+
|
|
835
982
|
type SubagentIsolation = 'worker' | 'in-process';
|
|
836
983
|
interface ISubagentProfile {
|
|
837
984
|
description: string;
|
|
@@ -858,5 +1005,5 @@ interface ISubagentToolOptions {
|
|
|
858
1005
|
*/
|
|
859
1006
|
declare const createSubagentTool: (opts: ISubagentToolOptions) => Tool;
|
|
860
1007
|
|
|
861
|
-
export { FileOAuthStore, MemoryOAuthStore, NodeOAuthProvider, SUMMARY_PREFIX, ToolBudgetError, ToolDeniedError, addUsage, beginMcpOAuth, buildInstructions, checkLimits, compactHistory, createAgent, createNodeOAuthProvider, createRunControl, createSubagentTool, createToolResultClearer, decideToolPermission, defineSkill, estimateTokens, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, isReadOnlyTool, loadSkillsFromDir, markReadOnly, matchToolRule, mergeProviderOptions, normalizeUsage, parseSkillMarkdown, redactHeaders, resolveLimits, resolvePromptCaching, resolveThinking, searchTools, truncateToolModelOutput, withRollingBreakpoint, withToolOutputLimit };
|
|
862
|
-
export type { AgentEvent, AgentStage, BudgetKind, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, ILimitBreach, IMcpHttpServerConfig, IMcpServerConfig, IMcpStdioServerConfig, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedThinking, IRunSnapshot, ISearchToolsOptions, ISkill, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, IUsage, LogLevel, PromptCachingSetting, ProviderType, ReplanCause, ReplanTrigger, RunControl, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };
|
|
1008
|
+
export { DEFAULT_COMPACTION_THRESHOLD_RATIO, DirSkillStore, EgressError, FORGET_SKILL_TOOL, FileOAuthStore, MemoryOAuthStore, MemorySkillStore, NodeOAuthProvider, SAVE_SKILL_TOOL, SUMMARY_PREFIX, ToolBudgetError, ToolDeniedError, WEB_FETCH_TOOL, addUsage, beginMcpOAuth, buildInstructions, checkEgressUrl, checkLimits, checkRedirect, classifyAddress, compactHistory, createAgent, createEgressTools, createLearning, createNodeOAuthProvider, createRunControl, createSafeFetch, createSubagentTool, createToolResultClearer, createWebFetchTool, decideToolPermission, defineSkill, estimateTokens, findSecret, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, isReadOnlyTool, loadSkillsFromDir, markReadOnly, matchToolRule, mergeProviderOptions, normalizeSkillName, normalizeUsage, parseSkillMarkdown, redactHeaders, resolveCompaction, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveThinking, searchTools, truncateToolModelOutput, withRollingBreakpoint, withToolOutputLimit };
|
|
1009
|
+
export type { AgentEvent, AgentStage, BudgetKind, EgressErrorCode, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, IEgressPolicy, ILearning, ILearningConfig, ILimitBreach, IMcpHttpServerConfig, IMcpServerConfig, IMcpStdioServerConfig, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedAddress, IResolvedThinking, IRunSnapshot, ISaveSkillInput, ISearchToolsOptions, ISkill, ISkillOrigin, ISkillStore, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, IUsage, LogLevel, PromptCachingSetting, ProviderType, ReplanCause, ReplanTrigger, RunControl, SafeFetch, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,51 @@ interface RunControl {
|
|
|
54
54
|
}
|
|
55
55
|
declare const createRunControl: () => RunControl;
|
|
56
56
|
|
|
57
|
+
type EgressErrorCode = 'disabled' | 'bad-url' | 'bad-protocol' | 'bad-port' | 'bad-method' | 'credentials-in-url' | 'denied-host' | 'not-allowed-host' | 'denied-address' | 'dns' | 'bad-redirect' | 'too-many-redirects' | 'too-large' | 'timeout';
|
|
58
|
+
declare class EgressError extends Error {
|
|
59
|
+
readonly code: EgressErrorCode;
|
|
60
|
+
constructor(code: EgressErrorCode, message: string);
|
|
61
|
+
toJSON(): string;
|
|
62
|
+
}
|
|
63
|
+
interface IResolvedAddress {
|
|
64
|
+
address: string;
|
|
65
|
+
family: 4 | 6;
|
|
66
|
+
}
|
|
67
|
+
interface IEgressPolicy {
|
|
68
|
+
allow?: string[];
|
|
69
|
+
deny?: string[];
|
|
70
|
+
allowPrivateNetwork?: boolean;
|
|
71
|
+
protocols?: ('https' | 'http')[];
|
|
72
|
+
ports?: number[];
|
|
73
|
+
methods?: string[];
|
|
74
|
+
maxRedirects?: number;
|
|
75
|
+
maxResponseBytes?: number;
|
|
76
|
+
timeoutMs?: number;
|
|
77
|
+
ca?: string | string[];
|
|
78
|
+
lookup?: (hostname: string) => Promise<IResolvedAddress[]>;
|
|
79
|
+
}
|
|
80
|
+
interface IResolvedEgressPolicy {
|
|
81
|
+
allow: string[];
|
|
82
|
+
deny: string[];
|
|
83
|
+
allowPrivateNetwork: boolean;
|
|
84
|
+
protocols: ('https' | 'http')[];
|
|
85
|
+
ports: number[];
|
|
86
|
+
methods: string[];
|
|
87
|
+
maxRedirects: number;
|
|
88
|
+
maxResponseBytes: number;
|
|
89
|
+
timeoutMs: number;
|
|
90
|
+
ca?: string | string[];
|
|
91
|
+
lookup: (hostname: string) => Promise<IResolvedAddress[]>;
|
|
92
|
+
}
|
|
93
|
+
declare const resolveEgressPolicy: (policy?: IEgressPolicy) => IResolvedEgressPolicy;
|
|
94
|
+
type AddressClass = 'public' | 'private' | 'never';
|
|
95
|
+
declare const classifyAddress: (address: string) => AddressClass;
|
|
96
|
+
declare const hostMatches: (host: string, pattern: string) => boolean;
|
|
97
|
+
declare const checkEgressUrl: (url: URL, policy: IResolvedEgressPolicy, method?: string) => void;
|
|
98
|
+
declare const checkRedirect: (from: URL, to: URL) => void;
|
|
99
|
+
type SafeFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
100
|
+
declare const createSafeFetch: (policy?: IEgressPolicy) => SafeFetch;
|
|
101
|
+
|
|
57
102
|
type ProviderType = 'openai' | 'anthropic' | 'openai-compatible' | 'google' | 'xai' | 'azure' | 'amazon-bedrock' | 'google-vertex' | 'deepseek' | 'gateway' | 'cloudflare';
|
|
58
103
|
type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
59
104
|
type ToolSelectionStrategy = 'all' | 'plan-narrowed' | 'search' | 'auto';
|
|
@@ -89,6 +134,7 @@ interface ICompactionConfig {
|
|
|
89
134
|
auto?: boolean;
|
|
90
135
|
contextWindowTokens?: number;
|
|
91
136
|
thresholdTokens?: number;
|
|
137
|
+
thresholdRatio?: number;
|
|
92
138
|
keepRecentTurns?: number;
|
|
93
139
|
keepRecentSteps?: number;
|
|
94
140
|
summaryMaxTokens?: number;
|
|
@@ -104,6 +150,26 @@ interface ISkill {
|
|
|
104
150
|
path: string;
|
|
105
151
|
content: string;
|
|
106
152
|
}[];
|
|
153
|
+
origin?: ISkillOrigin;
|
|
154
|
+
}
|
|
155
|
+
interface ISkillOrigin {
|
|
156
|
+
kind: 'learned';
|
|
157
|
+
at: number;
|
|
158
|
+
revision: number;
|
|
159
|
+
runId?: string;
|
|
160
|
+
sources?: string[];
|
|
161
|
+
fetched?: string[];
|
|
162
|
+
}
|
|
163
|
+
interface ISkillStore {
|
|
164
|
+
list: () => ISkill[] | Promise<ISkill[]>;
|
|
165
|
+
save: (skill: ISkill) => void | Promise<void>;
|
|
166
|
+
remove: (name: string) => boolean | Promise<boolean>;
|
|
167
|
+
}
|
|
168
|
+
interface ILearningConfig {
|
|
169
|
+
store?: ISkillStore;
|
|
170
|
+
maxSkills?: number;
|
|
171
|
+
maxSkillChars?: number;
|
|
172
|
+
nudge?: boolean;
|
|
107
173
|
}
|
|
108
174
|
type ToolApprovalMode = 'autopilot' | 'ask-writes' | 'ask-all' | 'read-only';
|
|
109
175
|
type ToolPermission = 'allow' | 'ask' | 'deny';
|
|
@@ -173,6 +239,8 @@ interface IAgentConfig {
|
|
|
173
239
|
/** @deprecated use `synthesizer: { model }` */
|
|
174
240
|
synthesizerModel?: string;
|
|
175
241
|
mcpServers: Record<string, IMcpServerConfig>;
|
|
242
|
+
egress?: boolean | IEgressPolicy;
|
|
243
|
+
learning?: boolean | ILearningConfig;
|
|
176
244
|
tools?: ToolSet;
|
|
177
245
|
availableTools?: string[];
|
|
178
246
|
excludedTools?: string[];
|
|
@@ -377,6 +445,22 @@ type AgentEventBody = {
|
|
|
377
445
|
id: string;
|
|
378
446
|
text: string;
|
|
379
447
|
at: 'round' | 'step' | 'final';
|
|
448
|
+
} | {
|
|
449
|
+
type: 'egress.request';
|
|
450
|
+
url: string;
|
|
451
|
+
allowed: boolean;
|
|
452
|
+
status?: number;
|
|
453
|
+
reason?: string;
|
|
454
|
+
} | {
|
|
455
|
+
type: 'skill.learned';
|
|
456
|
+
name: string;
|
|
457
|
+
description: string;
|
|
458
|
+
update: boolean;
|
|
459
|
+
chars: number;
|
|
460
|
+
sources: string[];
|
|
461
|
+
} | {
|
|
462
|
+
type: 'skill.forgotten';
|
|
463
|
+
name: string;
|
|
380
464
|
} | {
|
|
381
465
|
type: 'revisions.exceeded';
|
|
382
466
|
cap: number;
|
|
@@ -462,10 +546,15 @@ interface ICompactResult {
|
|
|
462
546
|
interface IAgent {
|
|
463
547
|
run: (options: IAgentRunOptions) => Promise<IAgentRunResult>;
|
|
464
548
|
listTools: () => IToolCatalogEntry[];
|
|
549
|
+
readonly usage: IUsage;
|
|
550
|
+
resetUsage: () => void;
|
|
465
551
|
listSkills: () => {
|
|
466
552
|
name: string;
|
|
467
553
|
description: string;
|
|
554
|
+
learned?: true;
|
|
468
555
|
}[];
|
|
556
|
+
listLearnedSkills: () => ISkill[];
|
|
557
|
+
forgetSkill: (name: string) => Promise<boolean>;
|
|
469
558
|
compact: (options: ICompactOptions) => Promise<ICompactResult>;
|
|
470
559
|
setToolApprovalMode: (mode: ToolApprovalMode) => void;
|
|
471
560
|
getToolApprovalMode: () => ToolApprovalMode;
|
|
@@ -706,12 +795,28 @@ declare const resolveLimits: (config: Pick<IAgentConfig, "limits" | "maxTotalTok
|
|
|
706
795
|
*/
|
|
707
796
|
declare const checkLimits: (usage: IUsage, limits: ITokenLimits | undefined) => ILimitBreach | undefined;
|
|
708
797
|
|
|
798
|
+
declare const DEFAULT_COMPACTION_THRESHOLD_RATIO = 0.85;
|
|
799
|
+
interface IResolvedCompaction {
|
|
800
|
+
auto: boolean;
|
|
801
|
+
contextWindowTokens: number;
|
|
802
|
+
thresholdTokens: number;
|
|
803
|
+
thresholdRatio: number;
|
|
804
|
+
keepRecentTurns: number;
|
|
805
|
+
keepRecentSteps: number;
|
|
806
|
+
summaryMaxTokens: number;
|
|
807
|
+
maxToolOutputChars: number;
|
|
808
|
+
clearToolResultsAfterTokens: number;
|
|
809
|
+
keepToolResults: number;
|
|
810
|
+
}
|
|
811
|
+
declare const resolveCompaction: (cfg: ICompactionConfig | undefined) => IResolvedCompaction;
|
|
709
812
|
declare const estimateTokens: (text: string) => number;
|
|
710
813
|
declare const SUMMARY_PREFIX = "[Summary of earlier conversation]";
|
|
711
814
|
interface ICompactHistoryOptions {
|
|
712
815
|
thresholdTokens?: number;
|
|
816
|
+
overheadTokens?: number;
|
|
713
817
|
keepRecentTurns?: number;
|
|
714
818
|
summaryMaxTokens?: number;
|
|
819
|
+
maxInputTokens?: number;
|
|
715
820
|
force?: boolean;
|
|
716
821
|
signal?: AbortSignal;
|
|
717
822
|
timeoutMs?: number;
|
|
@@ -832,6 +937,48 @@ interface IClearedInfo {
|
|
|
832
937
|
}
|
|
833
938
|
declare const createToolResultClearer: (opts: IToolResultClearing, onCleared?: (info: IClearedInfo) => void) => ((messages: ModelMessage[]) => ModelMessage[]);
|
|
834
939
|
|
|
940
|
+
declare const SAVE_SKILL_TOOL = "save_skill";
|
|
941
|
+
declare const FORGET_SKILL_TOOL = "forget_skill";
|
|
942
|
+
declare const findSecret: (text: string) => string | undefined;
|
|
943
|
+
declare const normalizeSkillName: (raw: string) => string | undefined;
|
|
944
|
+
declare class MemorySkillStore implements ISkillStore {
|
|
945
|
+
private readonly skills;
|
|
946
|
+
list(): ISkill[];
|
|
947
|
+
save(skill: ISkill): void;
|
|
948
|
+
remove(name: string): boolean;
|
|
949
|
+
}
|
|
950
|
+
declare class DirSkillStore implements ISkillStore {
|
|
951
|
+
private readonly dir;
|
|
952
|
+
constructor(dir: string);
|
|
953
|
+
list(): Promise<ISkill[]>;
|
|
954
|
+
save(skill: ISkill): Promise<void>;
|
|
955
|
+
remove(name: string): Promise<boolean>;
|
|
956
|
+
}
|
|
957
|
+
interface ILearning {
|
|
958
|
+
tools: ToolSet;
|
|
959
|
+
learned: () => ISkill[];
|
|
960
|
+
forget: (name: string) => Promise<boolean>;
|
|
961
|
+
}
|
|
962
|
+
interface ISaveSkillInput {
|
|
963
|
+
name: string;
|
|
964
|
+
description: string;
|
|
965
|
+
instructions: string;
|
|
966
|
+
sources?: string[];
|
|
967
|
+
}
|
|
968
|
+
declare const createLearning: (cfg: ILearningConfig, skills: ISkill[], emit: EventHandler, warn: (message: string) => void) => Promise<ILearning>;
|
|
969
|
+
|
|
970
|
+
declare const WEB_FETCH_TOOL = "web_fetch";
|
|
971
|
+
declare const htmlToText: (html: string) => {
|
|
972
|
+
title?: string;
|
|
973
|
+
text: string;
|
|
974
|
+
};
|
|
975
|
+
interface IWebFetchOptions {
|
|
976
|
+
policy?: IEgressPolicy;
|
|
977
|
+
fetch?: SafeFetch;
|
|
978
|
+
}
|
|
979
|
+
declare const createWebFetchTool: (options?: IWebFetchOptions) => Tool;
|
|
980
|
+
declare const createEgressTools: (egress: boolean | IEgressPolicy | undefined) => ToolSet | undefined;
|
|
981
|
+
|
|
835
982
|
type SubagentIsolation = 'worker' | 'in-process';
|
|
836
983
|
interface ISubagentProfile {
|
|
837
984
|
description: string;
|
|
@@ -858,5 +1005,5 @@ interface ISubagentToolOptions {
|
|
|
858
1005
|
*/
|
|
859
1006
|
declare const createSubagentTool: (opts: ISubagentToolOptions) => Tool;
|
|
860
1007
|
|
|
861
|
-
export { FileOAuthStore, MemoryOAuthStore, NodeOAuthProvider, SUMMARY_PREFIX, ToolBudgetError, ToolDeniedError, addUsage, beginMcpOAuth, buildInstructions, checkLimits, compactHistory, createAgent, createNodeOAuthProvider, createRunControl, createSubagentTool, createToolResultClearer, decideToolPermission, defineSkill, estimateTokens, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, isReadOnlyTool, loadSkillsFromDir, markReadOnly, matchToolRule, mergeProviderOptions, normalizeUsage, parseSkillMarkdown, redactHeaders, resolveLimits, resolvePromptCaching, resolveThinking, searchTools, truncateToolModelOutput, withRollingBreakpoint, withToolOutputLimit };
|
|
862
|
-
export type { AgentEvent, AgentStage, BudgetKind, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, ILimitBreach, IMcpHttpServerConfig, IMcpServerConfig, IMcpStdioServerConfig, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedThinking, IRunSnapshot, ISearchToolsOptions, ISkill, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, IUsage, LogLevel, PromptCachingSetting, ProviderType, ReplanCause, ReplanTrigger, RunControl, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };
|
|
1008
|
+
export { DEFAULT_COMPACTION_THRESHOLD_RATIO, DirSkillStore, EgressError, FORGET_SKILL_TOOL, FileOAuthStore, MemoryOAuthStore, MemorySkillStore, NodeOAuthProvider, SAVE_SKILL_TOOL, SUMMARY_PREFIX, ToolBudgetError, ToolDeniedError, WEB_FETCH_TOOL, addUsage, beginMcpOAuth, buildInstructions, checkEgressUrl, checkLimits, checkRedirect, classifyAddress, compactHistory, createAgent, createEgressTools, createLearning, createNodeOAuthProvider, createRunControl, createSafeFetch, createSubagentTool, createToolResultClearer, createWebFetchTool, decideToolPermission, defineSkill, estimateTokens, findSecret, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, isReadOnlyTool, loadSkillsFromDir, markReadOnly, matchToolRule, mergeProviderOptions, normalizeSkillName, normalizeUsage, parseSkillMarkdown, redactHeaders, resolveCompaction, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveThinking, searchTools, truncateToolModelOutput, withRollingBreakpoint, withToolOutputLimit };
|
|
1009
|
+
export type { AgentEvent, AgentStage, BudgetKind, EgressErrorCode, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, IEgressPolicy, ILearning, ILearningConfig, ILimitBreach, IMcpHttpServerConfig, IMcpServerConfig, IMcpStdioServerConfig, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedAddress, IResolvedThinking, IRunSnapshot, ISaveSkillInput, ISearchToolsOptions, ISkill, ISkillOrigin, ISkillStore, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, IUsage, LogLevel, PromptCachingSetting, ProviderType, ReplanCause, ReplanTrigger, RunControl, SafeFetch, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };
|