@cuylabs/agent-core 0.8.0 → 0.9.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/{builder-UpOWQMW3.d.ts → builder-BgZ_j4Vs.d.ts} +2 -1
- package/dist/{chunk-RZITT45F.js → chunk-4QFNWPIF.js} +4 -4
- package/dist/{chunk-BFM2YHNM.js → chunk-5ARZJWD2.js} +74 -37
- package/dist/{chunk-KUVSERLJ.js → chunk-DXFBQMXP.js} +5 -2
- package/dist/{chunk-CAA7FHIH.js → chunk-EKR6PKXU.js} +0 -100
- package/dist/{chunk-IVUJDISU.js → chunk-GFTW23FV.js} +5 -14
- package/dist/{chunk-7VKQ4WPB.js → chunk-H3FUYU52.js} +11 -3
- package/dist/chunk-I6PKJ7XQ.js +292 -0
- package/dist/chunk-IYWQOJMQ.js +102 -0
- package/dist/{chunk-4BDA7DQY.js → chunk-J4QDGZIA.js} +19 -3
- package/dist/{chunk-7MUFEN4K.js → chunk-JLXG2SH7.js} +349 -3
- package/dist/{chunk-YSLSEQ6B.js → chunk-MAZ5DY5B.js} +18 -30
- package/dist/{chunk-P6YF7USR.js → chunk-MHKK374K.js} +12 -11
- package/dist/{chunk-VBWWUHWI.js → chunk-OFDKHNCX.js} +4 -1
- package/dist/{chunk-YUUJK53A.js → chunk-RKEW5WXI.js} +1 -1
- package/dist/{chunk-LRHOS4ZN.js → chunk-SPILYYDF.js} +3 -2
- package/dist/{chunk-RFEKJKTO.js → chunk-UDCZ673N.js} +321 -275
- package/dist/{chunk-BDBZ3SLK.js → chunk-UHCJEM2E.js} +39 -2
- package/dist/chunk-WGZAPU6N.js +929 -0
- package/dist/{chunk-N6HWIEEA.js → chunk-WKHDSSXG.js} +140 -23
- package/dist/index-BCqEGzBj.d.ts +251 -0
- package/dist/{index-CWSchSql.d.ts → index-DQuTZ8xL.d.ts} +290 -13
- package/dist/index.d.ts +23 -29
- package/dist/index.js +776 -490
- package/dist/{errors → inference/errors}/index.d.ts +2 -2
- package/dist/{errors → inference/errors}/index.js +1 -1
- package/dist/inference/index.d.ts +10 -9
- package/dist/inference/index.js +34 -8
- package/dist/middleware/index.d.ts +5 -4
- package/dist/middleware/index.js +3 -3
- package/dist/models/index.d.ts +18 -16
- package/dist/models/index.js +47 -11
- package/dist/models/reasoning/index.d.ts +4 -0
- package/dist/{reasoning → models/reasoning}/index.js +2 -3
- package/dist/plugin/index.d.ts +414 -0
- package/dist/plugin/index.js +32 -0
- package/dist/presets/index.d.ts +3 -3
- package/dist/presets/index.js +7 -5
- package/dist/prompt/index.d.ts +6 -5
- package/dist/prompt/index.js +3 -2
- package/dist/runner-CI-XeR16.d.ts +91 -0
- package/dist/runtime/index.d.ts +7 -6
- package/dist/runtime/index.js +6 -7
- package/dist/safety/index.d.ts +1 -1
- package/dist/safety/index.js +1 -1
- package/dist/{session-manager-B_CWGTsl.d.ts → session-manager-KbYt2WUh.d.ts} +8 -0
- package/dist/signal/index.js +1 -1
- package/dist/skill/index.d.ts +2 -2
- package/dist/skill/index.js +3 -3
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +1 -1
- package/dist/sub-agent/index.d.ts +10 -9
- package/dist/sub-agent/index.js +21 -4
- package/dist/tool/index.d.ts +19 -5
- package/dist/tool/index.js +2 -2
- package/dist/{tool-BHbyUAy3.d.ts → tool-CZWN3KbO.d.ts} +1 -10
- package/dist/{tool-DLXAR9Ce.d.ts → tool-DkhSCV2Y.d.ts} +1 -1
- package/dist/tracking/index.d.ts +1 -1
- package/dist/tracking/index.js +1 -1
- package/dist/{types-KKDrdU9Y.d.ts → types-BlOKk-Bb.d.ts} +9 -4
- package/dist/{types-BnpEOYV-.d.ts → types-BlZwmnuW.d.ts} +1 -1
- package/dist/{runner-e2YRcUoX.d.ts → types-DTSkxakL.d.ts} +3 -138
- package/dist/{types-QKHHQLLq.d.ts → types-DmDwi2zI.d.ts} +7 -4
- package/package.json +15 -9
- package/dist/chunk-DWYX7ASF.js +0 -26
- package/dist/chunk-SQU2AJHO.js +0 -305
- package/dist/reasoning/index.d.ts +0 -116
- package/dist/types-QA4WhEfz.d.ts +0 -138
package/dist/safety/index.js
CHANGED
|
@@ -256,6 +256,14 @@ declare class SessionManager {
|
|
|
256
256
|
readFiles?: string[];
|
|
257
257
|
modifiedFiles?: string[];
|
|
258
258
|
}): Promise<string>;
|
|
259
|
+
replaceWithCompaction(options: {
|
|
260
|
+
summary: string;
|
|
261
|
+
messages: Message[];
|
|
262
|
+
tokensBefore: number;
|
|
263
|
+
tokensAfter: number;
|
|
264
|
+
readFiles?: string[];
|
|
265
|
+
modifiedFiles?: string[];
|
|
266
|
+
}): Promise<string>;
|
|
259
267
|
branch(fromEntryId: string, summary?: string): Promise<string>;
|
|
260
268
|
switchToLeaf(leafId: string): void;
|
|
261
269
|
updateMetadata(updates: {
|
package/dist/signal/index.js
CHANGED
package/dist/skill/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { h as SkillScope, i as SkillSource, a as SkillMetadata, g as SkillResour
|
|
|
2
2
|
export { R as RemoteSkillEntry, e as RemoteSkillIndex, f as SkillDiscoveryError, j as SkillSourceType } from '../types-BfNpU8NS.js';
|
|
3
3
|
import { S as SkillRegistry } from '../registry-DwYqsQkX.js';
|
|
4
4
|
export { c as createSkillRegistry, e as emptySkillRegistry } from '../registry-DwYqsQkX.js';
|
|
5
|
-
import { T as Tool } from '../tool-
|
|
5
|
+
import { T as Tool } from '../tool-CZWN3KbO.js';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../tool-
|
|
7
|
+
import '../tool-DkhSCV2Y.js';
|
|
8
8
|
import '../types-CHiPh8U2.js';
|
|
9
9
|
import '../types-CQL-SvTn.js';
|
|
10
10
|
|
package/dist/skill/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
createSkillResourceTool,
|
|
3
3
|
createSkillTool,
|
|
4
4
|
createSkillTools
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-RKEW5WXI.js";
|
|
6
|
+
import "../chunk-MHKK374K.js";
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_EXTERNAL_DIRS,
|
|
9
9
|
DEFAULT_MAX_SCAN_DEPTH,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
loadSkillContent,
|
|
19
19
|
loadSkillMetadata,
|
|
20
20
|
parseFrontmatter
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-SPILYYDF.js";
|
|
22
22
|
export {
|
|
23
23
|
DEFAULT_EXTERNAL_DIRS,
|
|
24
24
|
DEFAULT_MAX_SCAN_DEPTH,
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FileEntry, g as SessionEntry, M as MessageEntry, c as MetadataEntry, e as SerializedMessage, i as SessionInfo, j as SessionStorage, h as SessionHeader, S as SessionManager } from '../session-manager-
|
|
2
|
-
export { B as BranchEntry, C as CompactionEntry, a as ConfigChangeEntry, b as CreateSessionOptions, E as EntryBase, d as STORAGE_VERSION, f as SessionContext } from '../session-manager-
|
|
1
|
+
import { F as FileEntry, g as SessionEntry, M as MessageEntry, c as MetadataEntry, e as SerializedMessage, i as SessionInfo, j as SessionStorage, h as SessionHeader, S as SessionManager } from '../session-manager-KbYt2WUh.js';
|
|
2
|
+
export { B as BranchEntry, C as CompactionEntry, a as ConfigChangeEntry, b as CreateSessionOptions, E as EntryBase, d as STORAGE_VERSION, f as SessionContext } from '../session-manager-KbYt2WUh.js';
|
|
3
3
|
import { M as Message } from '../messages-BYWGn8TY.js';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/storage/index.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
export { b as AgentProfile, D as DEFAULT_MAX_CONCURRENT,
|
|
1
|
+
export { b as AgentDiscoveryOptions, c as AgentDiscoveryResult, d as AgentProfile, e as AgentSource, D as DEFAULT_MAX_CONCURRENT, f as DEFAULT_MAX_SPAWN_DEPTH, g as DEFAULT_SESSION_TITLE_PREFIX, h as DiscoveredProfile, M as MarkdownAgentFrontmatter, i as MarkdownAgentProfile, j as ParsedMarkdownAgent, k as ParsedToolSpec, l as ProfileResolvers, S as SubAgentCompletedResult, m as SubAgentHandle, n as SubAgentStatus, o as SubAgentToolConfig, p as SubAgentTracker, q as SubAgentUsage, T as ToolModifier, t as createSubAgentTools, u as discoverAgentProfiles, v as getProjectAgentsDir, w as getUserAgentsDir, x as isMarkdownProfile, y as parseAgentFrontmatter, z as parseMarkdownAgent, B as parseToolSpec, E as toAgentProfile } from '../index-DQuTZ8xL.js';
|
|
2
2
|
import 'ai';
|
|
3
|
-
import '../types-
|
|
3
|
+
import '../types-BlZwmnuW.js';
|
|
4
4
|
import '../types-CQaXbRsS.js';
|
|
5
|
-
import '../tool-
|
|
5
|
+
import '../tool-CZWN3KbO.js';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../tool-
|
|
7
|
+
import '../tool-DkhSCV2Y.js';
|
|
8
8
|
import '../types-CHiPh8U2.js';
|
|
9
9
|
import '../types-CQL-SvTn.js';
|
|
10
|
-
import '../
|
|
10
|
+
import '../types-DTSkxakL.js';
|
|
11
11
|
import '@ai-sdk/provider-utils';
|
|
12
12
|
import '../events-CE72w8W4.js';
|
|
13
13
|
import '../messages-BYWGn8TY.js';
|
|
14
14
|
import '../types-BfNpU8NS.js';
|
|
15
|
-
import '../session-manager-
|
|
15
|
+
import '../session-manager-KbYt2WUh.js';
|
|
16
16
|
import '../types-VQgymC1N.js';
|
|
17
17
|
import '../types-YuWV4ag7.js';
|
|
18
18
|
import '../tracker-DClqYqTj.js';
|
|
19
|
-
import '../builder-
|
|
19
|
+
import '../builder-BgZ_j4Vs.js';
|
|
20
20
|
import '../registry-DwYqsQkX.js';
|
|
21
|
-
import '../
|
|
21
|
+
import '../runner-CI-XeR16.js';
|
|
22
|
+
import '../types-BlOKk-Bb.js';
|
|
22
23
|
import '../llm-error-D93FNNLY.js';
|
|
23
|
-
import '../types-
|
|
24
|
+
import '../types-DmDwi2zI.js';
|
package/dist/sub-agent/index.js
CHANGED
|
@@ -3,13 +3,30 @@ import {
|
|
|
3
3
|
DEFAULT_MAX_SPAWN_DEPTH,
|
|
4
4
|
DEFAULT_SESSION_TITLE_PREFIX,
|
|
5
5
|
SubAgentTracker,
|
|
6
|
-
createSubAgentTools
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
createSubAgentTools,
|
|
7
|
+
discoverAgentProfiles,
|
|
8
|
+
getProjectAgentsDir,
|
|
9
|
+
getUserAgentsDir,
|
|
10
|
+
isMarkdownProfile,
|
|
11
|
+
parseAgentFrontmatter,
|
|
12
|
+
parseMarkdownAgent,
|
|
13
|
+
parseToolSpec,
|
|
14
|
+
toAgentProfile
|
|
15
|
+
} from "../chunk-JLXG2SH7.js";
|
|
16
|
+
import "../chunk-EKR6PKXU.js";
|
|
17
|
+
import "../chunk-MHKK374K.js";
|
|
9
18
|
export {
|
|
10
19
|
DEFAULT_MAX_CONCURRENT,
|
|
11
20
|
DEFAULT_MAX_SPAWN_DEPTH,
|
|
12
21
|
DEFAULT_SESSION_TITLE_PREFIX,
|
|
13
22
|
SubAgentTracker,
|
|
14
|
-
createSubAgentTools
|
|
23
|
+
createSubAgentTools,
|
|
24
|
+
discoverAgentProfiles,
|
|
25
|
+
getProjectAgentsDir,
|
|
26
|
+
getUserAgentsDir,
|
|
27
|
+
isMarkdownProfile,
|
|
28
|
+
parseAgentFrontmatter,
|
|
29
|
+
parseMarkdownAgent,
|
|
30
|
+
parseToolSpec,
|
|
31
|
+
toAgentProfile
|
|
15
32
|
};
|
package/dist/tool/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { T as Tool } from '../tool-
|
|
2
|
-
export { C as CompatibleSchema, I as InferSchemaOutput, d as defineTool } from '../tool-
|
|
3
|
-
import {
|
|
1
|
+
import { T as Tool } from '../tool-CZWN3KbO.js';
|
|
2
|
+
export { C as CompatibleSchema, I as InferSchemaOutput, d as defineTool } from '../tool-CZWN3KbO.js';
|
|
3
|
+
import { b as ToolReplayPolicy, F as FileOperationMeta, N as NormalizedToolReplayPolicy, d as TurnTrackerContext, a as ToolMetadata } from '../tool-DkhSCV2Y.js';
|
|
4
4
|
import { T as ToolHost } from '../types-CHiPh8U2.js';
|
|
5
|
-
import { M as MiddlewareRunner } from '../runner-
|
|
5
|
+
import { M as MiddlewareRunner } from '../runner-CI-XeR16.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import '../types-CQL-SvTn.js';
|
|
8
|
+
import '../types-DTSkxakL.js';
|
|
8
9
|
import 'ai';
|
|
9
10
|
import '@ai-sdk/provider-utils';
|
|
10
11
|
import '../events-CE72w8W4.js';
|
|
@@ -141,7 +142,10 @@ interface TruncateResult {
|
|
|
141
142
|
outputPath?: string;
|
|
142
143
|
}
|
|
143
144
|
/**
|
|
144
|
-
* Truncate output if it exceeds limits
|
|
145
|
+
* Truncate output if it exceeds limits.
|
|
146
|
+
*
|
|
147
|
+
* When truncation occurs the full output is written to a temp file
|
|
148
|
+
* **synchronously** so the path is valid immediately.
|
|
145
149
|
*/
|
|
146
150
|
declare function truncateOutput(output: string, options?: {
|
|
147
151
|
maxLines?: number;
|
|
@@ -164,9 +168,19 @@ interface ExecuteAgentToolCallOptions {
|
|
|
164
168
|
host?: ToolHost;
|
|
165
169
|
turnTracker?: TurnTrackerContext;
|
|
166
170
|
middleware?: MiddlewareRunner;
|
|
171
|
+
/**
|
|
172
|
+
* Pre-initialized tool result. When provided the executor skips
|
|
173
|
+
* `tool.init()` and uses this directly, avoiding double-init when
|
|
174
|
+
* the caller (e.g. `buildToolSet`) has already initialized the tool.
|
|
175
|
+
*/
|
|
176
|
+
initialized?: Awaited<ReturnType<Tool.Info["init"]>>;
|
|
167
177
|
}
|
|
168
178
|
interface ExecuteAgentToolCallResult {
|
|
169
179
|
output: string;
|
|
180
|
+
/** Short title for display (populated when middleware preserves it). */
|
|
181
|
+
title?: string;
|
|
182
|
+
/** Tool metadata (populated when middleware preserves it). */
|
|
183
|
+
metadata?: ToolMetadata;
|
|
170
184
|
}
|
|
171
185
|
/**
|
|
172
186
|
* Execute one initialized framework tool with the same semantics used by the
|
package/dist/tool/index.js
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
formatSize,
|
|
13
13
|
normalizeToolReplayPolicy,
|
|
14
14
|
truncateOutput
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-MHKK374K.js";
|
|
16
16
|
import {
|
|
17
17
|
executeAgentToolCall
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-H3FUYU52.js";
|
|
19
19
|
import "../chunk-VEKUXUVF.js";
|
|
20
20
|
import "../chunk-N7P4PN3O.js";
|
|
21
21
|
export {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { a as ToolMetadata, b as ToolReplayPolicy, T as ToolContext, F as FileOperationMeta, c as ToolResult } from './tool-DkhSCV2Y.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Tool definition namespace for @cuylabs/agent-core
|
|
@@ -125,15 +125,6 @@ declare namespace Tool {
|
|
|
125
125
|
* ```
|
|
126
126
|
*/
|
|
127
127
|
function define<TParams extends CompatibleSchema, TMeta extends ToolMetadata = ToolMetadata>(id: string, init: Info<TParams, TMeta>["init"] | Awaited<ReturnType<Info<TParams, TMeta>["init"]>>, options?: DefineOptions): Info<TParams, TMeta>;
|
|
128
|
-
/**
|
|
129
|
-
* Simple define for static tools (no async init)
|
|
130
|
-
*/
|
|
131
|
-
function defineSimple<TParams extends CompatibleSchema, TMeta extends ToolMetadata = ToolMetadata>(id: string, config: {
|
|
132
|
-
description: string;
|
|
133
|
-
parameters: TParams;
|
|
134
|
-
execute: (params: InferSchemaOutput<TParams>, ctx: ToolContext) => Promise<ExecuteResult<TMeta>>;
|
|
135
|
-
replayPolicy?: ToolReplayPolicy;
|
|
136
|
-
}): Info<TParams, TMeta>;
|
|
137
128
|
}
|
|
138
129
|
/**
|
|
139
130
|
* Legacy helper - wraps to Tool.Info format
|
|
@@ -142,4 +142,4 @@ interface ToolMetadata {
|
|
|
142
142
|
[key: string]: unknown;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
export type { FileOperationMeta as F, NormalizedToolReplayPolicy as N,
|
|
145
|
+
export type { FileOperationMeta as F, NormalizedToolReplayPolicy as N, ToolContext as T, ToolMetadata as a, ToolReplayPolicy as b, ToolResult as c, TurnTrackerContext as d, ToolReplayMode as e, ToolSideEffectLevel as f };
|
package/dist/tracking/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { T as TurnChangeTracker } from '../tracker-DClqYqTj.js';
|
|
2
2
|
export { F as FileBaseline, a as TurnFileChange, b as TurnSummary, c as TurnTrackerConfig, U as UndoResult, d as createTurnTracker } from '../tracker-DClqYqTj.js';
|
|
3
|
-
import { F as FileOperationMeta } from '../tool-
|
|
3
|
+
import { F as FileOperationMeta } from '../tool-DkhSCV2Y.js';
|
|
4
4
|
import '../types-CHiPh8U2.js';
|
|
5
5
|
import '../types-CQL-SvTn.js';
|
|
6
6
|
|
package/dist/tracking/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { StreamTextResult, ToolSet, Output, LanguageModel, ModelMessage, TelemetrySettings } from 'ai';
|
|
2
|
-
import { T as Tool } from './tool-
|
|
2
|
+
import { T as Tool } from './tool-CZWN3KbO.js';
|
|
3
3
|
import { T as ToolHost } from './types-CHiPh8U2.js';
|
|
4
|
-
import {
|
|
4
|
+
import { M as MiddlewareRunner } from './runner-CI-XeR16.js';
|
|
5
|
+
import { S as StreamChunk, f as StreamProvider, M as ModelCallInput } from './types-DTSkxakL.js';
|
|
5
6
|
import { R as ReasoningLevel } from './types-CQaXbRsS.js';
|
|
6
|
-
import { d as TurnTrackerContext } from './tool-
|
|
7
|
+
import { d as TurnTrackerContext } from './tool-DkhSCV2Y.js';
|
|
7
8
|
import { L as LLMError } from './llm-error-D93FNNLY.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -98,6 +99,8 @@ declare class InterventionController {
|
|
|
98
99
|
* @internal Called by the LLM stream's `prepareStep` hook
|
|
99
100
|
*/
|
|
100
101
|
drainImmediate(): PendingIntervention[];
|
|
102
|
+
/** Adopt existing immediate interventions without changing their IDs. */
|
|
103
|
+
adoptImmediate(items: PendingIntervention[]): void;
|
|
101
104
|
/** Whether there are pending immediate interventions */
|
|
102
105
|
get hasPending(): boolean;
|
|
103
106
|
/** Number of pending immediate interventions */
|
|
@@ -119,6 +122,8 @@ declare class InterventionController {
|
|
|
119
122
|
* The internal queue is cleared atomically.
|
|
120
123
|
*/
|
|
121
124
|
drainDeferred(): PendingIntervention[];
|
|
125
|
+
/** Adopt existing deferred interventions without changing their IDs. */
|
|
126
|
+
adoptDeferred(items: PendingIntervention[]): void;
|
|
122
127
|
/** Whether there are deferred messages */
|
|
123
128
|
get hasDeferred(): boolean;
|
|
124
129
|
/** Number of deferred messages */
|
|
@@ -322,4 +327,4 @@ type LLMStreamInput = InferenceStreamInput;
|
|
|
322
327
|
*/
|
|
323
328
|
type StepInfo = InferenceStepInfo;
|
|
324
329
|
|
|
325
|
-
export { type AnyInferenceResult as A, type CustomStreamProvider as C, DEFAULT_MAX_OUTPUT_TOKENS as D, type InferenceStreamInput as I, type LLMStreamInput as L, OUTPUT_TOKEN_MAX as O, type PendingIntervention as P, type RetryConfig as R, type StepInfo as S, type ToolExecutionMode as T, type AnyStreamResult as a, type CustomStreamResult as b,
|
|
330
|
+
export { type AnyInferenceResult as A, type CustomStreamProvider as C, DEFAULT_MAX_OUTPUT_TOKENS as D, type InferenceStreamInput as I, type LLMStreamInput as L, OUTPUT_TOKEN_MAX as O, type PendingIntervention as P, type RetryConfig as R, type StepInfo as S, type ToolExecutionMode as T, type AnyStreamResult as a, type CustomStreamResult as b, DEFAULT_RETRY_CONFIG as c, type InferenceCustomResult as d, type InferenceStepInfo as e, type InferenceStreamResult as f, type LLMStreamResult as g, type RetryHandlerOptions as h, type RetryState as i, calculateDelay as j, createRetryHandler as k, createRetryState as l, sleep as m, InterventionController as n, type OnInterventionApplied as o, shouldRetry as s, withRetry as w };
|
|
@@ -4,8 +4,8 @@ import { A as AgentEvent } from './events-CE72w8W4.js';
|
|
|
4
4
|
import { d as SkillConfig } from './types-BfNpU8NS.js';
|
|
5
5
|
import { T as TokenUsage } from './messages-BYWGn8TY.js';
|
|
6
6
|
import { S as ScopeSnapshot } from './types-CQL-SvTn.js';
|
|
7
|
-
import {
|
|
8
|
-
import { T as Tool } from './tool-
|
|
7
|
+
import { T as ToolContext } from './tool-DkhSCV2Y.js';
|
|
8
|
+
import { T as Tool } from './tool-CZWN3KbO.js';
|
|
9
9
|
import { R as ReasoningLevel } from './types-CQaXbRsS.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -647,140 +647,5 @@ interface AgentMiddleware {
|
|
|
647
647
|
*/
|
|
648
648
|
getOtelContext?(sessionId: string): unknown;
|
|
649
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>;
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* Middleware Runner
|
|
704
|
-
*
|
|
705
|
-
* Executes middleware hooks in the correct order with proper
|
|
706
|
-
* error handling and short-circuit semantics.
|
|
707
|
-
*
|
|
708
|
-
* This is the internal engine — consumers never see it.
|
|
709
|
-
* They interact with middleware through AgentConfig.middleware.
|
|
710
|
-
*/
|
|
711
|
-
|
|
712
|
-
/**
|
|
713
|
-
* Middleware runner — holds an ordered list of middleware and
|
|
714
|
-
* exposes methods to run each hook type with correct semantics.
|
|
715
|
-
*
|
|
716
|
-
* Immutable after construction. Fork creates a new runner
|
|
717
|
-
* (with inherited + additional middleware).
|
|
718
|
-
*/
|
|
719
|
-
declare class MiddlewareRunner {
|
|
720
|
-
private readonly stack;
|
|
721
|
-
constructor(middleware?: AgentMiddleware[]);
|
|
722
|
-
/** Number of registered middleware */
|
|
723
|
-
get count(): number;
|
|
724
|
-
/** Whether any middleware is registered */
|
|
725
|
-
get hasMiddleware(): boolean;
|
|
726
|
-
/** Get the middleware list (for fork inheritance) */
|
|
727
|
-
getMiddleware(): readonly AgentMiddleware[];
|
|
728
|
-
runModelInput(input: ModelCallInput, ctx: ModelCallContext): Promise<ModelCallInput | BlockedModelCall>;
|
|
729
|
-
runModelChunk(chunk: StreamChunk, ctx: ModelCallContext): Promise<StreamChunk | undefined>;
|
|
730
|
-
runModelOutput(output: ModelCallOutput, ctx: ModelCallContext): Promise<ModelCallOutput>;
|
|
731
|
-
/**
|
|
732
|
-
* Run all `beforeToolCall` hooks in order.
|
|
733
|
-
*
|
|
734
|
-
* Returns `{ action: "allow" }` if all middleware allow (or have no hook).
|
|
735
|
-
* Returns `{ action: "deny", reason }` on first denial — remaining
|
|
736
|
-
* middleware are skipped.
|
|
737
|
-
*/
|
|
738
|
-
runBeforeToolCall(tool: string, args: unknown, ctx: ToolContext): Promise<ToolCallDecision>;
|
|
739
|
-
/**
|
|
740
|
-
* Run all `afterToolCall` hooks in reverse order.
|
|
741
|
-
*
|
|
742
|
-
* Each hook receives the result from the previous hook (or the
|
|
743
|
-
* original tool result for the first hook). Errors are caught
|
|
744
|
-
* and logged — the original result passes through.
|
|
745
|
-
*/
|
|
746
|
-
runAfterToolCall(tool: string, args: unknown, result: Tool.ExecuteResult, ctx: ToolContext): Promise<Tool.ExecuteResult>;
|
|
747
|
-
/**
|
|
748
|
-
* Collect prompt sections from all middleware.
|
|
749
|
-
*
|
|
750
|
-
* Returns a flat array of sections. Each middleware can return a single
|
|
751
|
-
* section, an array of sections, or undefined/empty.
|
|
752
|
-
*/
|
|
753
|
-
collectPromptSections(ctx: PromptBuildContext): PromptSection[];
|
|
754
|
-
/**
|
|
755
|
-
* Broadcast an event to all middleware observers.
|
|
756
|
-
*
|
|
757
|
-
* Non-blocking — errors are caught and logged. This never
|
|
758
|
-
* slows down the streaming pipeline.
|
|
759
|
-
*/
|
|
760
|
-
emitEvent(event: AgentEvent): void;
|
|
761
|
-
/**
|
|
762
|
-
* Get the OTel context for a session from the telemetry middleware.
|
|
763
|
-
* Returns undefined if no telemetry middleware is registered.
|
|
764
|
-
*/
|
|
765
|
-
getOtelContext(sessionId: string): unknown | undefined;
|
|
766
|
-
/**
|
|
767
|
-
* Run all `onChatStart` hooks in order.
|
|
768
|
-
*
|
|
769
|
-
* Errors are caught and logged — a broken logger should not
|
|
770
|
-
* prevent the chat from starting.
|
|
771
|
-
*/
|
|
772
|
-
runChatStart(sessionId: string, message: string): Promise<void>;
|
|
773
|
-
/**
|
|
774
|
-
* Run all `onChatEnd` hooks in order.
|
|
775
|
-
*
|
|
776
|
-
* Always called, even when the stream errored. Errors in handlers
|
|
777
|
-
* are caught and logged.
|
|
778
|
-
*/
|
|
779
|
-
runChatEnd(sessionId: string, result: {
|
|
780
|
-
usage?: TokenUsage;
|
|
781
|
-
error?: Error;
|
|
782
|
-
output?: string;
|
|
783
|
-
}): Promise<void>;
|
|
784
|
-
}
|
|
785
650
|
|
|
786
|
-
export {
|
|
651
|
+
export type { AgentMiddleware as A, BlockedModelCall as B, EnhancedTools as E, InstructionFile as I, ModelCallInput as M, PromptBuildContext as P, StreamChunk as S, ToolCallDecision as T, ModelCallContext as a, ModelCallOutput as b, PromptSection as c, PromptConfig as d, ModelFamily as e, StreamProvider as f, AgentModelHooks as g, EnvironmentInfo as h, StreamProviderConfig as i, StreamProviderFactory as j, StreamProviderInput as k, StreamProviderResult as l };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { LanguageModel, TelemetrySettings, ModelMessage, ToolSet } from 'ai';
|
|
2
|
-
import { T as Tool } from './tool-
|
|
2
|
+
import { T as Tool } from './tool-CZWN3KbO.js';
|
|
3
3
|
import { T as ToolHost } from './types-CHiPh8U2.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { M as MiddlewareRunner } from './runner-CI-XeR16.js';
|
|
5
|
+
import { n as InterventionController, T as ToolExecutionMode, I as InferenceStreamInput } from './types-BlOKk-Bb.js';
|
|
6
6
|
import { R as ReasoningLevel } from './types-CQaXbRsS.js';
|
|
7
|
-
import { N as NormalizedToolReplayPolicy, d as TurnTrackerContext } from './tool-
|
|
7
|
+
import { N as NormalizedToolReplayPolicy, d as TurnTrackerContext } from './tool-DkhSCV2Y.js';
|
|
8
8
|
import { T as TokenUsage, M as Message } from './messages-BYWGn8TY.js';
|
|
9
|
+
import { f as StreamProvider } from './types-DTSkxakL.js';
|
|
9
10
|
import { S as StepProcessingResult, A as AgentEvent, b as AgentTurnBoundaryKind } from './events-CE72w8W4.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -41,6 +42,8 @@ interface StepProcessingOptions {
|
|
|
41
42
|
sessionID?: string;
|
|
42
43
|
/** Abort signal */
|
|
43
44
|
abort: AbortSignal;
|
|
45
|
+
/** Normalize provider/runtime errors before emitting them as events */
|
|
46
|
+
normalizeError?: (error: unknown) => Error;
|
|
44
47
|
/** Event callback */
|
|
45
48
|
onEvent: (event: AgentEvent) => void | Promise<void>;
|
|
46
49
|
/** Doom loop threshold (default: 3) */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuylabs/agent-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Embeddable AI agent infrastructure — execution, sessions, tools, skills, sub-agents, tracing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"default": "./dist/context/index.js"
|
|
63
63
|
},
|
|
64
64
|
"./reasoning": {
|
|
65
|
-
"types": "./dist/reasoning/index.d.ts",
|
|
66
|
-
"import": "./dist/reasoning/index.js",
|
|
67
|
-
"default": "./dist/reasoning/index.js"
|
|
65
|
+
"types": "./dist/models/reasoning/index.d.ts",
|
|
66
|
+
"import": "./dist/models/reasoning/index.js",
|
|
67
|
+
"default": "./dist/models/reasoning/index.js"
|
|
68
68
|
},
|
|
69
69
|
"./models": {
|
|
70
70
|
"types": "./dist/models/index.d.ts",
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
"default": "./dist/signal/index.js"
|
|
93
93
|
},
|
|
94
94
|
"./errors": {
|
|
95
|
-
"types": "./dist/errors/index.d.ts",
|
|
96
|
-
"import": "./dist/errors/index.js",
|
|
97
|
-
"default": "./dist/errors/index.js"
|
|
95
|
+
"types": "./dist/inference/errors/index.d.ts",
|
|
96
|
+
"import": "./dist/inference/errors/index.js",
|
|
97
|
+
"default": "./dist/inference/errors/index.js"
|
|
98
98
|
},
|
|
99
99
|
"./presets": {
|
|
100
100
|
"types": "./dist/presets/index.d.ts",
|
|
@@ -105,6 +105,11 @@
|
|
|
105
105
|
"types": "./dist/safety/index.d.ts",
|
|
106
106
|
"import": "./dist/safety/index.js",
|
|
107
107
|
"default": "./dist/safety/index.js"
|
|
108
|
+
},
|
|
109
|
+
"./plugin": {
|
|
110
|
+
"types": "./dist/plugin/index.d.ts",
|
|
111
|
+
"import": "./dist/plugin/index.js",
|
|
112
|
+
"default": "./dist/plugin/index.js"
|
|
108
113
|
}
|
|
109
114
|
},
|
|
110
115
|
"files": [
|
|
@@ -114,6 +119,7 @@
|
|
|
114
119
|
"dependencies": {
|
|
115
120
|
"@ai-sdk/provider": "^3.0.7",
|
|
116
121
|
"ai": "^6.0.67",
|
|
122
|
+
"jiti": "^2.6.1",
|
|
117
123
|
"zod": "^3.25.76 || ^4.1.8"
|
|
118
124
|
},
|
|
119
125
|
"peerDependencies": {
|
|
@@ -244,8 +250,8 @@
|
|
|
244
250
|
"access": "public"
|
|
245
251
|
},
|
|
246
252
|
"scripts": {
|
|
247
|
-
"build": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/inference/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/
|
|
248
|
-
"dev": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/inference/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/
|
|
253
|
+
"build": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/inference/index.ts src/inference/errors/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/models/index.ts src/models/reasoning/index.ts src/mcp/index.ts src/host/index.ts src/scope/index.ts src/signal/index.ts src/presets/index.ts src/safety/index.ts src/plugin/index.ts --format esm --dts --clean",
|
|
254
|
+
"dev": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/inference/index.ts src/inference/errors/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/models/index.ts src/models/reasoning/index.ts src/mcp/index.ts src/host/index.ts src/scope/index.ts src/signal/index.ts src/presets/index.ts src/safety/index.ts src/plugin/index.ts --format esm --dts --watch",
|
|
249
255
|
"test": "vitest run",
|
|
250
256
|
"test:watch": "vitest",
|
|
251
257
|
"lint": "eslint src/",
|
package/dist/chunk-DWYX7ASF.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// src/models/identifiers.ts
|
|
2
|
-
function getModelId(model) {
|
|
3
|
-
if (typeof model === "string") return model;
|
|
4
|
-
if (typeof model === "object" && model !== null && "modelId" in model) {
|
|
5
|
-
return String(model.modelId);
|
|
6
|
-
}
|
|
7
|
-
return String(model);
|
|
8
|
-
}
|
|
9
|
-
function getProviderId(model) {
|
|
10
|
-
if (typeof model === "string") {
|
|
11
|
-
if (model.includes("/")) {
|
|
12
|
-
return model.split("/")[0];
|
|
13
|
-
}
|
|
14
|
-
return void 0;
|
|
15
|
-
}
|
|
16
|
-
if (typeof model === "object" && model !== null && "provider" in model) {
|
|
17
|
-
const provider = String(model.provider);
|
|
18
|
-
return provider.split(".")[0];
|
|
19
|
-
}
|
|
20
|
-
return void 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
getModelId,
|
|
25
|
-
getProviderId
|
|
26
|
-
};
|