@cuylabs/agent-core 0.6.0 → 0.8.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/README.md +5 -1
- package/dist/{builder-BKkipazh.d.ts → builder-UpOWQMW3.d.ts} +2 -2
- package/dist/{chunk-3C4VKG4P.js → chunk-4BDA7DQY.js} +273 -807
- package/dist/chunk-7VKQ4WPB.js +73 -0
- package/dist/chunk-BFM2YHNM.js +222 -0
- package/dist/chunk-CAA7FHIH.js +280 -0
- package/dist/chunk-KUVSERLJ.js +50 -0
- package/dist/chunk-N6HWIEEA.js +423 -0
- package/dist/chunk-N7P4PN3O.js +84 -0
- package/dist/{chunk-QWFMX226.js → chunk-RFEKJKTO.js} +252 -13
- package/dist/chunk-RZITT45F.js +202 -0
- package/dist/{chunk-X635CM2F.js → chunk-SQU2AJHO.js} +1 -1
- package/dist/chunk-VNQBHPCT.js +398 -0
- package/dist/{chunk-QAQADS4X.js → chunk-WWYYNWEW.js} +2 -1
- package/dist/{chunk-O2ZCFQL6.js → chunk-YSLSEQ6B.js} +105 -220
- package/dist/context/index.js +1 -1
- package/dist/errors/index.d.ts +11 -0
- package/dist/errors/index.js +16 -0
- package/dist/events-CE72w8W4.d.ts +149 -0
- package/dist/host/index.d.ts +45 -0
- package/dist/host/index.js +8 -0
- package/dist/{index-DZQJD_hp.d.ts → index-CWSchSql.d.ts} +42 -51
- package/dist/index.d.ts +98 -190
- package/dist/index.js +476 -939
- package/dist/inference/index.d.ts +62 -0
- package/dist/inference/index.js +27 -0
- package/dist/llm-error-D93FNNLY.d.ts +32 -0
- package/dist/middleware/index.d.ts +246 -5
- package/dist/middleware/index.js +7 -3
- package/dist/models/index.d.ts +226 -3
- package/dist/models/index.js +41 -3
- package/dist/presets/index.d.ts +53 -0
- package/dist/presets/index.js +28 -0
- package/dist/prompt/index.d.ts +12 -7
- package/dist/reasoning/index.d.ts +53 -8
- package/dist/reasoning/index.js +2 -7
- package/dist/{registry-CuRWWtcT.d.ts → registry-DwYqsQkX.d.ts} +1 -1
- package/dist/{runner-G1wxEgac.d.ts → runner-e2YRcUoX.d.ts} +82 -148
- package/dist/runtime/index.d.ts +44 -7
- package/dist/runtime/index.js +16 -5
- package/dist/safety/index.d.ts +38 -0
- package/dist/safety/index.js +12 -0
- package/dist/scope/index.d.ts +10 -0
- package/dist/scope/index.js +14 -0
- package/dist/{session-manager-Uawm2Le7.d.ts → session-manager-B_CWGTsl.d.ts} +1 -1
- package/dist/signal/index.d.ts +28 -0
- package/dist/signal/index.js +6 -0
- package/dist/skill/index.d.ts +8 -5
- package/dist/storage/index.d.ts +2 -2
- package/dist/sub-agent/index.d.ts +17 -8
- package/dist/tool/index.d.ts +9 -4
- package/dist/tool/index.js +4 -3
- package/dist/tool-BHbyUAy3.d.ts +150 -0
- package/dist/{tool-DYp6-cC3.d.ts → tool-DLXAR9Ce.d.ts} +5 -99
- package/dist/tracking/index.d.ts +3 -1
- package/dist/{tool-pFAnJc5Y.d.ts → types-BfNpU8NS.d.ts} +1 -150
- package/dist/types-BnpEOYV-.d.ts +50 -0
- package/dist/types-CHiPh8U2.d.ts +100 -0
- package/dist/types-CQL-SvTn.d.ts +29 -0
- package/dist/types-CWm-7rvB.d.ts +55 -0
- package/dist/types-KKDrdU9Y.d.ts +325 -0
- package/dist/{resolver-DOfZ-xuk.d.ts → types-QA4WhEfz.d.ts} +1 -117
- package/dist/types-QKHHQLLq.d.ts +336 -0
- package/dist/types-YuWV4ag7.d.ts +72 -0
- package/package.json +74 -8
- package/dist/capabilities/index.d.ts +0 -97
- package/dist/capabilities/index.js +0 -46
- package/dist/chunk-6TDTQJ4P.js +0 -116
- package/dist/chunk-FG4MD5MU.js +0 -54
- package/dist/config-D2xeGEHK.d.ts +0 -52
- package/dist/identifiers-BLUxFqV_.d.ts +0 -12
- package/dist/index-ipP3_ztp.d.ts +0 -198
- package/dist/network-D76DS5ot.d.ts +0 -5
- package/dist/types-BWo810L_.d.ts +0 -648
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { P as Preset, A as AppliedPreset } from '../types-BnpEOYV-.js';
|
|
2
|
+
import { T as Tool } from '../tool-BHbyUAy3.js';
|
|
3
|
+
import 'ai';
|
|
4
|
+
import '../types-CQaXbRsS.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../tool-DLXAR9Ce.js';
|
|
7
|
+
import '../types-CHiPh8U2.js';
|
|
8
|
+
import '../types-CQL-SvTn.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Filter tools using preset allow/deny patterns.
|
|
12
|
+
*
|
|
13
|
+
* Explicit allow matches win over deny matches. This lets presets define a
|
|
14
|
+
* broad deny rule like `"*"` and then carve out a safe allow-list.
|
|
15
|
+
*/
|
|
16
|
+
declare function filterTools(tools: Tool.AnyInfo[], options: {
|
|
17
|
+
allow?: string[];
|
|
18
|
+
deny?: string[];
|
|
19
|
+
}): Tool.AnyInfo[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Apply a preset to available tools and a parent system prompt.
|
|
23
|
+
*/
|
|
24
|
+
declare function applyPreset(preset: Preset, availableTools: Tool.AnyInfo[], baseSystemPrompt?: string): AppliedPreset;
|
|
25
|
+
/**
|
|
26
|
+
* Merge multiple presets. Later presets override earlier scalar values.
|
|
27
|
+
*/
|
|
28
|
+
declare function mergePresets(...presets: Preset[]): Preset;
|
|
29
|
+
/**
|
|
30
|
+
* Create a custom preset with sensible defaults.
|
|
31
|
+
*/
|
|
32
|
+
declare function createPreset(options: Partial<Preset> & {
|
|
33
|
+
name: string;
|
|
34
|
+
}): Preset;
|
|
35
|
+
|
|
36
|
+
declare const explore: Preset;
|
|
37
|
+
declare const plan: Preset;
|
|
38
|
+
declare const review: Preset;
|
|
39
|
+
declare const quick: Preset;
|
|
40
|
+
declare const careful: Preset;
|
|
41
|
+
declare const code: Preset;
|
|
42
|
+
declare const watch: Preset;
|
|
43
|
+
declare const Presets: {
|
|
44
|
+
readonly explore: Preset;
|
|
45
|
+
readonly plan: Preset;
|
|
46
|
+
readonly review: Preset;
|
|
47
|
+
readonly quick: Preset;
|
|
48
|
+
readonly careful: Preset;
|
|
49
|
+
readonly code: Preset;
|
|
50
|
+
readonly watch: Preset;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { AppliedPreset, Preset, Presets, applyPreset, careful, code, createPreset, explore, filterTools, mergePresets, plan, quick, review, watch };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Presets,
|
|
3
|
+
applyPreset,
|
|
4
|
+
careful,
|
|
5
|
+
code,
|
|
6
|
+
createPreset,
|
|
7
|
+
explore,
|
|
8
|
+
filterTools,
|
|
9
|
+
mergePresets,
|
|
10
|
+
plan,
|
|
11
|
+
quick,
|
|
12
|
+
review,
|
|
13
|
+
watch
|
|
14
|
+
} from "../chunk-CAA7FHIH.js";
|
|
15
|
+
export {
|
|
16
|
+
Presets,
|
|
17
|
+
applyPreset,
|
|
18
|
+
careful,
|
|
19
|
+
code,
|
|
20
|
+
createPreset,
|
|
21
|
+
explore,
|
|
22
|
+
filterTools,
|
|
23
|
+
mergePresets,
|
|
24
|
+
plan,
|
|
25
|
+
quick,
|
|
26
|
+
review,
|
|
27
|
+
watch
|
|
28
|
+
};
|
package/dist/prompt/index.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { c as ModelFamily,
|
|
2
|
-
export { a as PromptBuildContext, P as PromptConfig, b as PromptSection } from '../runner-
|
|
1
|
+
import { c as ModelFamily, g as EnvironmentInfo, I as InstructionFile } from '../runner-e2YRcUoX.js';
|
|
2
|
+
export { a as PromptBuildContext, P as PromptConfig, b as PromptSection } from '../runner-e2YRcUoX.js';
|
|
3
3
|
import { LanguageModel } from 'ai';
|
|
4
|
-
export { P as PromptBuilder, c as createPromptBuilder } from '../builder-
|
|
5
|
-
export { d as SkillConfig } from '../
|
|
4
|
+
export { P as PromptBuilder, c as createPromptBuilder } from '../builder-UpOWQMW3.js';
|
|
5
|
+
export { d as SkillConfig } from '../types-BfNpU8NS.js';
|
|
6
|
+
import '@ai-sdk/provider-utils';
|
|
7
|
+
import '../events-CE72w8W4.js';
|
|
6
8
|
import '../messages-BYWGn8TY.js';
|
|
7
|
-
import '../
|
|
8
|
-
import '../
|
|
9
|
-
import '../
|
|
9
|
+
import '../types-CQL-SvTn.js';
|
|
10
|
+
import '../tool-DLXAR9Ce.js';
|
|
11
|
+
import '../types-CHiPh8U2.js';
|
|
12
|
+
import '../tool-BHbyUAy3.js';
|
|
10
13
|
import 'zod';
|
|
14
|
+
import '../types-CQaXbRsS.js';
|
|
15
|
+
import '../registry-DwYqsQkX.js';
|
|
11
16
|
|
|
12
17
|
/**
|
|
13
18
|
* Prompt Templates — Base system prompts per model family
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { R as ReasoningLevel } from '../types-CQaXbRsS.js';
|
|
2
|
-
export { E as EXTENDED_LEVELS, F as FIXED_LEVELS,
|
|
3
|
-
import { P as ProviderCompatibility } from '../
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import 'ai';
|
|
7
|
-
import '@ai-sdk/provider-utils';
|
|
1
|
+
import { R as ReasoningLevel, a as ReasoningConfig } from '../types-CQaXbRsS.js';
|
|
2
|
+
export { E as EXTENDED_LEVELS, F as FIXED_LEVELS, S as STANDARD_LEVELS, s as shouldIncludeReasoningSummary } from '../types-CQaXbRsS.js';
|
|
3
|
+
import { P as ProviderCompatibility } from '../types-QA4WhEfz.js';
|
|
4
|
+
import { LanguageModel } from 'ai';
|
|
5
|
+
import { ProviderOptions } from '@ai-sdk/provider-utils';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Provider-Specific Reasoning Option Builders
|
|
@@ -68,4 +66,51 @@ declare function buildOpenRouterOptions(level: ReasoningLevel): Record<string, u
|
|
|
68
66
|
*/
|
|
69
67
|
declare function getProviderOptionsKey(provider: string): string;
|
|
70
68
|
|
|
71
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Reasoning Configuration & Option Builders
|
|
71
|
+
*
|
|
72
|
+
* Orchestrates capability detection and provider-specific option
|
|
73
|
+
* building to produce ready-to-use `providerOptions` for the
|
|
74
|
+
* Vercel AI SDK.
|
|
75
|
+
*
|
|
76
|
+
* Two flavours of every function are provided:
|
|
77
|
+
* - **Async** (`getReasoningConfig`, `buildReasoningOptions`) —
|
|
78
|
+
* uses the full capability resolver (network + cache).
|
|
79
|
+
* - **Sync** (`getReasoningConfigSync`, `buildReasoningOptionsSync`) —
|
|
80
|
+
* uses fast pattern-matching only (no network).
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get the reasoning configuration for a model.
|
|
85
|
+
*
|
|
86
|
+
* Uses the full capability resolver (including network lookups)
|
|
87
|
+
* for the most accurate result.
|
|
88
|
+
*/
|
|
89
|
+
declare function getReasoningConfig(model: LanguageModel): Promise<ReasoningConfig>;
|
|
90
|
+
/**
|
|
91
|
+
* Synchronous reasoning config using pattern-matching only.
|
|
92
|
+
*
|
|
93
|
+
* Faster but less accurate than {@link getReasoningConfig}.
|
|
94
|
+
* Good for hot paths where async is impractical.
|
|
95
|
+
*/
|
|
96
|
+
declare function getReasoningConfigSync(model: LanguageModel): ReasoningConfig;
|
|
97
|
+
/**
|
|
98
|
+
* Build `providerOptions` for a reasoning level (async).
|
|
99
|
+
*
|
|
100
|
+
* Returns `undefined` when reasoning is off or unsupported.
|
|
101
|
+
*/
|
|
102
|
+
declare function buildReasoningOptions(model: LanguageModel, level: ReasoningLevel): Promise<ProviderOptions | undefined>;
|
|
103
|
+
/**
|
|
104
|
+
* Build `providerOptions` for a reasoning level (sync / pattern-only).
|
|
105
|
+
*/
|
|
106
|
+
declare function buildReasoningOptionsSync(model: LanguageModel, level: ReasoningLevel): ProviderOptions | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Check whether a model supports reasoning (async, full resolver).
|
|
109
|
+
*/
|
|
110
|
+
declare function supportsReasoning(model: LanguageModel): Promise<boolean>;
|
|
111
|
+
/**
|
|
112
|
+
* Synchronous check using pattern-matching only.
|
|
113
|
+
*/
|
|
114
|
+
declare function supportsReasoningSync(model: LanguageModel): boolean;
|
|
115
|
+
|
|
116
|
+
export { ReasoningConfig, ReasoningLevel, buildAnthropicOptions, buildBedrockOptions, buildGoogleOptions, buildGroqOptions, buildOpenAIOptions, buildOpenRouterOptions, buildReasoningOptions, buildReasoningOptionsSync, buildXAIOptions, getProviderOptionsKey, getReasoningConfig, getReasoningConfigSync, supportsReasoning, supportsReasoningSync };
|
package/dist/reasoning/index.js
CHANGED
|
@@ -17,11 +17,8 @@ import {
|
|
|
17
17
|
shouldIncludeReasoningSummary,
|
|
18
18
|
supportsReasoning,
|
|
19
19
|
supportsReasoningSync
|
|
20
|
-
} from "../chunk-
|
|
21
|
-
import
|
|
22
|
-
extractModelId,
|
|
23
|
-
extractProvider
|
|
24
|
-
} from "../chunk-QWFMX226.js";
|
|
20
|
+
} from "../chunk-SQU2AJHO.js";
|
|
21
|
+
import "../chunk-RFEKJKTO.js";
|
|
25
22
|
import "../chunk-DWYX7ASF.js";
|
|
26
23
|
export {
|
|
27
24
|
EXTENDED_LEVELS,
|
|
@@ -36,8 +33,6 @@ export {
|
|
|
36
33
|
buildReasoningOptions,
|
|
37
34
|
buildReasoningOptionsSync,
|
|
38
35
|
buildXAIOptions,
|
|
39
|
-
extractModelId,
|
|
40
|
-
extractProvider,
|
|
41
36
|
getProviderOptionsKey,
|
|
42
37
|
getReasoningConfig,
|
|
43
38
|
getReasoningConfigSync,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SkillDiscoveryResult, a as SkillMetadata, b as SkillContent, c as SkillResource, d as SkillConfig } from './
|
|
1
|
+
import { S as SkillDiscoveryResult, a as SkillMetadata, b as SkillContent, c as SkillResource, d as SkillConfig } from './types-BfNpU8NS.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Skill Registry — in-memory store for discovered skills
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { d as SkillConfig
|
|
5
|
-
import {
|
|
1
|
+
import { LanguageModel, ModelMessage, TelemetrySettings, SystemModelMessage } from 'ai';
|
|
2
|
+
import { ProviderOptions } from '@ai-sdk/provider-utils';
|
|
3
|
+
import { A as AgentEvent } from './events-CE72w8W4.js';
|
|
4
|
+
import { d as SkillConfig } from './types-BfNpU8NS.js';
|
|
5
|
+
import { T as TokenUsage } from './messages-BYWGn8TY.js';
|
|
6
|
+
import { S as ScopeSnapshot } from './types-CQL-SvTn.js';
|
|
7
|
+
import { b as ToolContext } from './tool-DLXAR9Ce.js';
|
|
8
|
+
import { T as Tool } from './tool-BHbyUAy3.js';
|
|
6
9
|
import { R as ReasoningLevel } from './types-CQaXbRsS.js';
|
|
7
10
|
|
|
8
11
|
/**
|
|
@@ -89,7 +92,7 @@ type StreamChunk = {
|
|
|
89
92
|
/**
|
|
90
93
|
* Custom stream provider function type.
|
|
91
94
|
*
|
|
92
|
-
* This matches the signature needed for agent-core's
|
|
95
|
+
* This matches the signature needed for agent-core's inference module,
|
|
93
96
|
* returning a StreamProviderResult-compatible object.
|
|
94
97
|
*/
|
|
95
98
|
type StreamProvider = (input: StreamProviderInput) => Promise<StreamProviderResult>;
|
|
@@ -171,147 +174,6 @@ interface EnhancedTools extends Array<unknown> {
|
|
|
171
174
|
__customStreamModels?: string[];
|
|
172
175
|
}
|
|
173
176
|
|
|
174
|
-
/** Agent status for UI display */
|
|
175
|
-
type AgentStatus = "idle" | "processing" | "thinking" | "reasoning" | "calling-tool" | "waiting-approval" | "error";
|
|
176
|
-
/** Approval request for UI */
|
|
177
|
-
interface ApprovalEvent {
|
|
178
|
-
id: string;
|
|
179
|
-
tool: string;
|
|
180
|
-
args: unknown;
|
|
181
|
-
description: string;
|
|
182
|
-
risk: "safe" | "moderate" | "dangerous";
|
|
183
|
-
}
|
|
184
|
-
/** Neutral turn-commit boundaries for runtime/durability integrations */
|
|
185
|
-
type AgentTurnBoundaryKind = "input-commit-start" | "input-commit-finish" | "intervention-commit-start" | "intervention-commit-finish" | "step-commit-start" | "step-commit-finish" | "output-commit-start" | "output-commit-finish";
|
|
186
|
-
/**
|
|
187
|
-
* Events emitted during agent execution
|
|
188
|
-
*
|
|
189
|
-
* These events are designed for UI consumption:
|
|
190
|
-
* - status: Overall agent state for status indicators
|
|
191
|
-
* - approval-request: User confirmation needed
|
|
192
|
-
* - progress: Step counts for progress bars
|
|
193
|
-
*/
|
|
194
|
-
type AgentEvent = {
|
|
195
|
-
type: "status";
|
|
196
|
-
status: AgentStatus;
|
|
197
|
-
} | {
|
|
198
|
-
type: "approval-request";
|
|
199
|
-
request: ApprovalEvent;
|
|
200
|
-
} | {
|
|
201
|
-
type: "approval-resolved";
|
|
202
|
-
id: string;
|
|
203
|
-
action: "allow" | "deny" | "remember";
|
|
204
|
-
} | {
|
|
205
|
-
type: "step-start";
|
|
206
|
-
step: number;
|
|
207
|
-
maxSteps: number;
|
|
208
|
-
} | {
|
|
209
|
-
type: "step-finish";
|
|
210
|
-
step: number;
|
|
211
|
-
usage?: TokenUsage;
|
|
212
|
-
finishReason?: string;
|
|
213
|
-
} | {
|
|
214
|
-
type: "turn-boundary";
|
|
215
|
-
boundary: AgentTurnBoundaryKind;
|
|
216
|
-
step?: number;
|
|
217
|
-
messageRole?: Message["role"];
|
|
218
|
-
pendingToolCallCount?: number;
|
|
219
|
-
} | {
|
|
220
|
-
type: "message";
|
|
221
|
-
message: Message;
|
|
222
|
-
} | {
|
|
223
|
-
type: "text-start";
|
|
224
|
-
} | {
|
|
225
|
-
type: "text-delta";
|
|
226
|
-
text: string;
|
|
227
|
-
} | {
|
|
228
|
-
type: "text-end";
|
|
229
|
-
} | {
|
|
230
|
-
type: "reasoning-start";
|
|
231
|
-
id: string;
|
|
232
|
-
} | {
|
|
233
|
-
type: "reasoning-delta";
|
|
234
|
-
id: string;
|
|
235
|
-
text: string;
|
|
236
|
-
} | {
|
|
237
|
-
type: "reasoning-end";
|
|
238
|
-
id: string;
|
|
239
|
-
} | {
|
|
240
|
-
type: "tool-start";
|
|
241
|
-
toolName: string;
|
|
242
|
-
toolCallId: string;
|
|
243
|
-
input: unknown;
|
|
244
|
-
} | {
|
|
245
|
-
type: "tool-result";
|
|
246
|
-
toolName: string;
|
|
247
|
-
toolCallId: string;
|
|
248
|
-
result: unknown;
|
|
249
|
-
} | {
|
|
250
|
-
type: "tool-error";
|
|
251
|
-
toolName: string;
|
|
252
|
-
toolCallId: string;
|
|
253
|
-
error: string;
|
|
254
|
-
} | {
|
|
255
|
-
type: "computer-call";
|
|
256
|
-
callId: string;
|
|
257
|
-
action: unknown;
|
|
258
|
-
pendingSafetyChecks?: unknown[];
|
|
259
|
-
} | {
|
|
260
|
-
type: "computer-result";
|
|
261
|
-
callId: string;
|
|
262
|
-
result: unknown;
|
|
263
|
-
} | {
|
|
264
|
-
type: "intervention-applied";
|
|
265
|
-
id: string;
|
|
266
|
-
message: string;
|
|
267
|
-
} | {
|
|
268
|
-
type: "doom-loop";
|
|
269
|
-
toolName: string;
|
|
270
|
-
repeatCount: number;
|
|
271
|
-
} | {
|
|
272
|
-
type: "context-overflow";
|
|
273
|
-
inputTokens: number;
|
|
274
|
-
limit: number;
|
|
275
|
-
} | {
|
|
276
|
-
type: "turn-summary";
|
|
277
|
-
turnId: string;
|
|
278
|
-
files: Array<{
|
|
279
|
-
path: string;
|
|
280
|
-
type: "created" | "modified" | "deleted" | "unchanged";
|
|
281
|
-
additions: number;
|
|
282
|
-
deletions: number;
|
|
283
|
-
}>;
|
|
284
|
-
additions: number;
|
|
285
|
-
deletions: number;
|
|
286
|
-
} | {
|
|
287
|
-
type: "retry";
|
|
288
|
-
attempt: number;
|
|
289
|
-
delayMs: number;
|
|
290
|
-
error: Error;
|
|
291
|
-
} | {
|
|
292
|
-
type: "error";
|
|
293
|
-
error: Error;
|
|
294
|
-
} | {
|
|
295
|
-
type: "complete";
|
|
296
|
-
usage?: TokenUsage;
|
|
297
|
-
output?: string;
|
|
298
|
-
};
|
|
299
|
-
/**
|
|
300
|
-
* Processor result - what happens after processing a turn
|
|
301
|
-
*/
|
|
302
|
-
type ProcessorResult = "continue" | "stop" | "compact";
|
|
303
|
-
/**
|
|
304
|
-
* Stream input for the LLM
|
|
305
|
-
*/
|
|
306
|
-
interface StreamInput {
|
|
307
|
-
sessionID: string;
|
|
308
|
-
model: ai.LanguageModel;
|
|
309
|
-
system: string[];
|
|
310
|
-
messages: ai.ModelMessage[];
|
|
311
|
-
abort: AbortSignal;
|
|
312
|
-
tools: Record<string, unknown>;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
177
|
/**
|
|
316
178
|
* Prompt Pipeline Types
|
|
317
179
|
*
|
|
@@ -572,6 +434,26 @@ interface ModelCallInput {
|
|
|
572
434
|
telemetry?: TelemetrySettings;
|
|
573
435
|
customStreamProvider?: StreamProvider;
|
|
574
436
|
toolExecutionMode?: "auto" | "plan";
|
|
437
|
+
/**
|
|
438
|
+
* Provider-specific options passed through to `streamText()`.
|
|
439
|
+
*
|
|
440
|
+
* Middleware can set these to enable provider features like Anthropic
|
|
441
|
+
* prompt caching (`{ anthropic: { cacheControl: { type: "ephemeral" } } }`).
|
|
442
|
+
*
|
|
443
|
+
* When multiple sources set providerOptions (e.g. middleware + reasoning),
|
|
444
|
+
* they are shallow-merged before the LLM call.
|
|
445
|
+
*/
|
|
446
|
+
providerOptions?: ProviderOptions;
|
|
447
|
+
/**
|
|
448
|
+
* System messages with provider-specific options.
|
|
449
|
+
*
|
|
450
|
+
* When set, these take precedence over the plain `system` strings.
|
|
451
|
+
* This allows middleware to attach per-message metadata such as
|
|
452
|
+
* Anthropic `cacheControl` breakpoints on system content.
|
|
453
|
+
*
|
|
454
|
+
* Leave undefined to use the plain `system` string array.
|
|
455
|
+
*/
|
|
456
|
+
systemMessages?: SystemModelMessage[];
|
|
575
457
|
}
|
|
576
458
|
/**
|
|
577
459
|
* Context shared across model middleware hooks for a single step.
|
|
@@ -584,6 +466,7 @@ interface ModelCallContext {
|
|
|
584
466
|
model: LanguageModel;
|
|
585
467
|
toolNames: string[];
|
|
586
468
|
mcpToolNames: string[];
|
|
469
|
+
scope?: ScopeSnapshot;
|
|
587
470
|
}
|
|
588
471
|
/**
|
|
589
472
|
* Return this from `model.input(...)` to stop an LLM call entirely.
|
|
@@ -764,6 +647,57 @@ interface AgentMiddleware {
|
|
|
764
647
|
*/
|
|
765
648
|
getOtelContext?(sessionId: string): unknown;
|
|
766
649
|
}
|
|
650
|
+
/**
|
|
651
|
+
* A user-facing command a plugin can register.
|
|
652
|
+
*
|
|
653
|
+
* How commands surface depends on the host:
|
|
654
|
+
* - CLI/TUI → slash commands (e.g. `/deploy`)
|
|
655
|
+
* - HTTP → could be API routes
|
|
656
|
+
* - Chatbot → chat commands
|
|
657
|
+
*
|
|
658
|
+
* Hosts that don't support commands can silently ignore them.
|
|
659
|
+
*/
|
|
660
|
+
interface PluginCommand {
|
|
661
|
+
/** Command name (without leading slash) */
|
|
662
|
+
name: string;
|
|
663
|
+
/** Optional aliases */
|
|
664
|
+
alias?: string[];
|
|
665
|
+
/** One-line description shown in help */
|
|
666
|
+
summary: string;
|
|
667
|
+
/** Execute the command. Return the text to display, or null for silent. */
|
|
668
|
+
execute: (args: string) => Promise<string | null>;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* The context object passed to a plugin's default export.
|
|
672
|
+
*
|
|
673
|
+
* Through the context, plugins contribute tools, middleware, and
|
|
674
|
+
* (optionally) host-specific commands.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```ts
|
|
678
|
+
* import { Tool, z, type PluginContext } from "@cuylabs/agent-code";
|
|
679
|
+
*
|
|
680
|
+
* export default function (ctx: PluginContext) {
|
|
681
|
+
* ctx.addTool(Tool.define("ping", {
|
|
682
|
+
* description: "Pong!",
|
|
683
|
+
* parameters: z.object({}),
|
|
684
|
+
* execute: async () => ({ title: "pong", output: "pong", metadata: {} }),
|
|
685
|
+
* }));
|
|
686
|
+
* }
|
|
687
|
+
* ```
|
|
688
|
+
*/
|
|
689
|
+
interface PluginContext {
|
|
690
|
+
/** Working directory of the agent (project root) */
|
|
691
|
+
cwd: string;
|
|
692
|
+
/** Register a tool the LLM can call */
|
|
693
|
+
addTool(tool: Tool.AnyInfo): void;
|
|
694
|
+
/** Register middleware (model hooks, tool guards, prompt sections) */
|
|
695
|
+
addMiddleware(mw: AgentMiddleware): void;
|
|
696
|
+
/** Register a user-facing command (host-dependent) */
|
|
697
|
+
addCommand(cmd: PluginCommand): void;
|
|
698
|
+
}
|
|
699
|
+
/** The function shape a plugin file must default-export. */
|
|
700
|
+
type PluginInit = (ctx: PluginContext) => void | Promise<void>;
|
|
767
701
|
|
|
768
702
|
/**
|
|
769
703
|
* Middleware Runner
|
|
@@ -849,4 +783,4 @@ declare class MiddlewareRunner {
|
|
|
849
783
|
}): Promise<void>;
|
|
850
784
|
}
|
|
851
785
|
|
|
852
|
-
export { type
|
|
786
|
+
export { type AgentMiddleware as A, type BlockedModelCall as B, type EnhancedTools as E, type InstructionFile as I, MiddlewareRunner as M, type PromptConfig as P, type StreamChunk as S, type ToolCallDecision as T, type PromptBuildContext as a, type PromptSection as b, type ModelFamily as c, type StreamProvider as d, type ModelCallInput as e, type AgentModelHooks as f, type EnvironmentInfo as g, type ModelCallContext as h, type ModelCallOutput as i, type PluginCommand as j, type PluginContext as k, type PluginInit as l, type StreamProviderConfig as m, type StreamProviderFactory as n, type StreamProviderInput as o, type StreamProviderResult as p };
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,12 +1,47 @@
|
|
|
1
|
-
import { A as AgentEvent } from '../
|
|
1
|
+
import { A as AgentEvent } from '../events-CE72w8W4.js';
|
|
2
2
|
import { T as TokenUsage, M as Message } from '../messages-BYWGn8TY.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { S as ScopeSnapshot } from '../types-CQL-SvTn.js';
|
|
4
|
+
import { S as StepProcessingOptions, z as StepProcessingOutput, l as AgentTurnStepCommitSnapshot, r as CreateAgentTurnStepCommitBatchOptions, d as AgentTurnCommitBatch, P as PrepareModelStepOptions, u as PreparedAgentModelStep, R as RunModelStepOptions, x as RunToolBatchOptions, y as RunToolBatchResult, C as CommitOutputOptions, p as CommitStepOptions, j as AgentTurnState, n as AgentTurnStepCommitToolResult, m as AgentTurnStepCommitToolCall } from '../types-QKHHQLLq.js';
|
|
5
|
+
export { A as AgentTurnActiveToolCall, a as AgentTurnBoundaryMetadata, b as AgentTurnBoundarySnapshot, c as AgentTurnCommitApplier, e as AgentTurnCommitOptions, f as AgentTurnEngine, g as AgentTurnEngineOptions, h as AgentTurnPhase, i as AgentTurnResolvedToolCall, k as AgentTurnStateAdvanceOptions, o as AgentTurnStepRuntimeConfig, q as CreateAgentTurnStateOptions, v as ProcessorOptions, w as ProcessorOutput, B as advanceAgentTurnState, E as createAgentTurnEngine, F as createAgentTurnState, G as failAgentTurnState } from '../types-QKHHQLLq.js';
|
|
6
|
+
import { A as AnyInferenceResult } from '../types-KKDrdU9Y.js';
|
|
5
7
|
import { ModelMessage } from 'ai';
|
|
6
|
-
import '../tool-
|
|
8
|
+
import '../tool-BHbyUAy3.js';
|
|
7
9
|
import 'zod';
|
|
8
|
-
import '../tool-
|
|
10
|
+
import '../tool-DLXAR9Ce.js';
|
|
11
|
+
import '../types-CHiPh8U2.js';
|
|
12
|
+
import '../runner-e2YRcUoX.js';
|
|
13
|
+
import '@ai-sdk/provider-utils';
|
|
14
|
+
import '../types-BfNpU8NS.js';
|
|
9
15
|
import '../types-CQaXbRsS.js';
|
|
16
|
+
import '../llm-error-D93FNNLY.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Doom loop error thrown when repeated tool calls are detected.
|
|
20
|
+
*/
|
|
21
|
+
declare class DoomLoopError extends Error {
|
|
22
|
+
readonly toolName: string;
|
|
23
|
+
readonly repeatCount: number;
|
|
24
|
+
readonly input: unknown;
|
|
25
|
+
constructor(toolName: string, repeatCount: number, input: unknown);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Context overflow error.
|
|
30
|
+
*/
|
|
31
|
+
declare class ContextOverflowError extends Error {
|
|
32
|
+
readonly inputTokens: number;
|
|
33
|
+
readonly limit: number;
|
|
34
|
+
constructor(inputTokens: number, limit: number);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Process an inference stream into runtime step events.
|
|
39
|
+
*/
|
|
40
|
+
declare function processStepStream(stream: AnyInferenceResult, options: StepProcessingOptions): Promise<StepProcessingOutput>;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use `processStepStream`.
|
|
43
|
+
*/
|
|
44
|
+
declare const processStream: typeof processStepStream;
|
|
10
45
|
|
|
11
46
|
declare function createAgentTurnStepCommitBatch(step: number, snapshot: AgentTurnStepCommitSnapshot, options?: CreateAgentTurnStepCommitBatchOptions): AgentTurnCommitBatch | undefined;
|
|
12
47
|
|
|
@@ -18,7 +53,7 @@ declare function prepareModelStep(options: PrepareModelStepOptions): PreparedAge
|
|
|
18
53
|
/**
|
|
19
54
|
* Execute exactly one model/tool step and stream its events.
|
|
20
55
|
*/
|
|
21
|
-
declare function runModelStep(options: RunModelStepOptions): AsyncGenerator<AgentEvent,
|
|
56
|
+
declare function runModelStep(options: RunModelStepOptions): AsyncGenerator<AgentEvent, StepProcessingOutput>;
|
|
22
57
|
|
|
23
58
|
/**
|
|
24
59
|
* Execute planned tool calls outside the AI SDK loop.
|
|
@@ -82,6 +117,7 @@ interface AgentTaskExecutionRun<TPayload extends AgentTaskPayload = AgentTaskPay
|
|
|
82
117
|
context: Readonly<AgentTaskExecutionContext>;
|
|
83
118
|
sessionId: string;
|
|
84
119
|
startedAt: string;
|
|
120
|
+
scope?: ScopeSnapshot;
|
|
85
121
|
}
|
|
86
122
|
interface AgentTaskExecutionSnapshot {
|
|
87
123
|
sessionId: string;
|
|
@@ -98,6 +134,7 @@ interface AgentTaskExecutionSnapshot {
|
|
|
98
134
|
startedAt: string;
|
|
99
135
|
updatedAt: string;
|
|
100
136
|
turnState: AgentTurnState;
|
|
137
|
+
scope?: ScopeSnapshot;
|
|
101
138
|
}
|
|
102
139
|
interface AgentTaskExecutionCheckpoint<TPayload extends AgentTaskPayload = AgentTaskPayload> {
|
|
103
140
|
run: AgentTaskExecutionRun<TPayload>;
|
|
@@ -354,4 +391,4 @@ declare function failAgentWorkflowTurnState(state: AgentWorkflowTurnState, error
|
|
|
354
391
|
*/
|
|
355
392
|
declare function convertAgentMessagesToModelMessages(messages: Message[]): ModelMessage[];
|
|
356
393
|
|
|
357
|
-
export { type AgentTaskChatAdapter, type AgentTaskCheckpointReason, type AgentTaskCheckpointStrategy, type AgentTaskCheckpointStrategyInput, type AgentTaskExecutionCheckpoint, type AgentTaskExecutionContext, type AgentTaskExecutionRun, type AgentTaskExecutionSnapshot, type AgentTaskObserver, type AgentTaskPayload, type AgentTaskResult, type AgentTaskRunner, type AgentTaskRunnerOptions, AgentTurnCommitBatch, AgentTurnState, AgentTurnStepCommitSnapshot, AgentTurnStepCommitToolCall, AgentTurnStepCommitToolResult, type AgentWorkflowAssistantMessageSnapshot, type AgentWorkflowCommitResult, type AgentWorkflowMessageSnapshot, type AgentWorkflowModelStepPlan, type AgentWorkflowModelStepResult, type AgentWorkflowOperationPlan, type AgentWorkflowOutputCommitPlan, type AgentWorkflowReplayDecision, type AgentWorkflowStepCommitPlan, type AgentWorkflowSystemMessageSnapshot, type AgentWorkflowToolBatchResult, type AgentWorkflowToolCallPlan, type AgentWorkflowToolCallResult, type AgentWorkflowToolCallSnapshot, type AgentWorkflowToolMessageSnapshot, type AgentWorkflowTurnPhase, type AgentWorkflowTurnState, type AgentWorkflowUserMessageSnapshot, CommitOutputOptions, CommitStepOptions, CreateAgentTurnStepCommitBatchOptions, type CreateAgentWorkflowTurnStateOptions, PrepareModelStepOptions, PreparedAgentModelStep, RunModelStepOptions, RunToolBatchOptions, RunToolBatchResult, applyAgentWorkflowCommitResult, applyAgentWorkflowModelStepResult, applyAgentWorkflowToolBatchResult, applyAgentWorkflowToolCallResult, cloneAgentWorkflowTurnState, commitOutput, commitStep, convertAgentMessagesToModelMessages, createAgentTaskRunner, createAgentTurnStepCommitBatch, createAgentWorkflowTurnState, defaultAgentTaskCheckpointStrategy, failAgentWorkflowTurnState, planNextAgentWorkflowOperation, prepareModelStep, recordAgentWorkflowReplayDecision, restoreAgentWorkflowMessage, restoreAgentWorkflowMessages, runModelStep, runToolBatch, snapshotAgentWorkflowMessage, snapshotAgentWorkflowMessages };
|
|
394
|
+
export { type AgentTaskChatAdapter, type AgentTaskCheckpointReason, type AgentTaskCheckpointStrategy, type AgentTaskCheckpointStrategyInput, type AgentTaskExecutionCheckpoint, type AgentTaskExecutionContext, type AgentTaskExecutionRun, type AgentTaskExecutionSnapshot, type AgentTaskObserver, type AgentTaskPayload, type AgentTaskResult, type AgentTaskRunner, type AgentTaskRunnerOptions, AgentTurnCommitBatch, AgentTurnState, AgentTurnStepCommitSnapshot, AgentTurnStepCommitToolCall, AgentTurnStepCommitToolResult, type AgentWorkflowAssistantMessageSnapshot, type AgentWorkflowCommitResult, type AgentWorkflowMessageSnapshot, type AgentWorkflowModelStepPlan, type AgentWorkflowModelStepResult, type AgentWorkflowOperationPlan, type AgentWorkflowOutputCommitPlan, type AgentWorkflowReplayDecision, type AgentWorkflowStepCommitPlan, type AgentWorkflowSystemMessageSnapshot, type AgentWorkflowToolBatchResult, type AgentWorkflowToolCallPlan, type AgentWorkflowToolCallResult, type AgentWorkflowToolCallSnapshot, type AgentWorkflowToolMessageSnapshot, type AgentWorkflowTurnPhase, type AgentWorkflowTurnState, type AgentWorkflowUserMessageSnapshot, CommitOutputOptions, CommitStepOptions, ContextOverflowError, CreateAgentTurnStepCommitBatchOptions, type CreateAgentWorkflowTurnStateOptions, DoomLoopError, PrepareModelStepOptions, PreparedAgentModelStep, RunModelStepOptions, RunToolBatchOptions, RunToolBatchResult, StepProcessingOptions, StepProcessingOutput, applyAgentWorkflowCommitResult, applyAgentWorkflowModelStepResult, applyAgentWorkflowToolBatchResult, applyAgentWorkflowToolCallResult, cloneAgentWorkflowTurnState, commitOutput, commitStep, convertAgentMessagesToModelMessages, createAgentTaskRunner, createAgentTurnStepCommitBatch, createAgentWorkflowTurnState, defaultAgentTaskCheckpointStrategy, failAgentWorkflowTurnState, planNextAgentWorkflowOperation, prepareModelStep, processStepStream, processStream, recordAgentWorkflowReplayDecision, restoreAgentWorkflowMessage, restoreAgentWorkflowMessages, runModelStep, runToolBatch, snapshotAgentWorkflowMessage, snapshotAgentWorkflowMessages };
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentTurnEngine,
|
|
3
|
+
ContextOverflowError,
|
|
4
|
+
DoomLoopError,
|
|
3
5
|
advanceAgentTurnState,
|
|
4
6
|
applyAgentWorkflowCommitResult,
|
|
5
7
|
applyAgentWorkflowModelStepResult,
|
|
@@ -19,6 +21,8 @@ import {
|
|
|
19
21
|
failAgentWorkflowTurnState,
|
|
20
22
|
planNextAgentWorkflowOperation,
|
|
21
23
|
prepareModelStep,
|
|
24
|
+
processStepStream,
|
|
25
|
+
processStream,
|
|
22
26
|
recordAgentWorkflowReplayDecision,
|
|
23
27
|
restoreAgentWorkflowMessage,
|
|
24
28
|
restoreAgentWorkflowMessages,
|
|
@@ -26,15 +30,20 @@ import {
|
|
|
26
30
|
runToolBatch,
|
|
27
31
|
snapshotAgentWorkflowMessage,
|
|
28
32
|
snapshotAgentWorkflowMessages
|
|
29
|
-
} from "../chunk-
|
|
30
|
-
import "../chunk-
|
|
33
|
+
} from "../chunk-4BDA7DQY.js";
|
|
34
|
+
import "../chunk-WWYYNWEW.js";
|
|
35
|
+
import "../chunk-N6HWIEEA.js";
|
|
36
|
+
import "../chunk-7VKQ4WPB.js";
|
|
31
37
|
import "../chunk-VEKUXUVF.js";
|
|
32
|
-
import "../chunk-
|
|
33
|
-
import "../chunk-
|
|
34
|
-
import "../chunk-
|
|
38
|
+
import "../chunk-SQU2AJHO.js";
|
|
39
|
+
import "../chunk-N7P4PN3O.js";
|
|
40
|
+
import "../chunk-RZITT45F.js";
|
|
41
|
+
import "../chunk-RFEKJKTO.js";
|
|
35
42
|
import "../chunk-DWYX7ASF.js";
|
|
36
43
|
export {
|
|
37
44
|
AgentTurnEngine,
|
|
45
|
+
ContextOverflowError,
|
|
46
|
+
DoomLoopError,
|
|
38
47
|
advanceAgentTurnState,
|
|
39
48
|
applyAgentWorkflowCommitResult,
|
|
40
49
|
applyAgentWorkflowModelStepResult,
|
|
@@ -54,6 +63,8 @@ export {
|
|
|
54
63
|
failAgentWorkflowTurnState,
|
|
55
64
|
planNextAgentWorkflowOperation,
|
|
56
65
|
prepareModelStep,
|
|
66
|
+
processStepStream,
|
|
67
|
+
processStream,
|
|
57
68
|
recordAgentWorkflowReplayDecision,
|
|
58
69
|
restoreAgentWorkflowMessage,
|
|
59
70
|
restoreAgentWorkflowMessages,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { R as RiskLevel, a as ApprovalConfig, c as ApprovalRule } from '../types-CWm-7rvB.js';
|
|
2
|
+
export { A as ApprovalAction, b as ApprovalRequest } from '../types-CWm-7rvB.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the risk level for a tool.
|
|
6
|
+
*/
|
|
7
|
+
declare function getToolRisk(tool: string, customRisks?: Record<string, RiskLevel>): RiskLevel;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Thrown when a user or rule denies an operation.
|
|
11
|
+
*/
|
|
12
|
+
declare class ApprovalDeniedError extends Error {
|
|
13
|
+
readonly tool: string;
|
|
14
|
+
readonly args: unknown;
|
|
15
|
+
constructor(tool: string, args: unknown, message?: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Thrown when an approval request times out.
|
|
19
|
+
*/
|
|
20
|
+
declare class ApprovalTimeoutError extends Error {
|
|
21
|
+
readonly tool: string;
|
|
22
|
+
readonly timeoutMs: number;
|
|
23
|
+
constructor(tool: string, timeoutMs: number);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Creates an approval handler for managing tool execution permissions.
|
|
28
|
+
*/
|
|
29
|
+
declare function createApprovalHandler(config?: ApprovalConfig): {
|
|
30
|
+
request: (sessionId: string, tool: string, args: unknown, customRisks?: Record<string, RiskLevel>) => Promise<void>;
|
|
31
|
+
cancelAll: (reason?: string) => void;
|
|
32
|
+
addRule: (rule: ApprovalRule) => void;
|
|
33
|
+
getRules: () => readonly ApprovalRule[];
|
|
34
|
+
clearSessionRules: () => void;
|
|
35
|
+
};
|
|
36
|
+
type ApprovalHandler = ReturnType<typeof createApprovalHandler>;
|
|
37
|
+
|
|
38
|
+
export { ApprovalConfig, ApprovalDeniedError, type ApprovalHandler, ApprovalRule, ApprovalTimeoutError, RiskLevel, createApprovalHandler, getToolRisk };
|