@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,10 @@
|
|
|
1
|
+
import { e as ScopeOptions, a as Scope, S as ScopeSnapshot } from '../types-CQL-SvTn.js';
|
|
2
|
+
export { b as ScopeAttributeValue, c as ScopeAttributes, d as ScopeKind } from '../types-CQL-SvTn.js';
|
|
3
|
+
|
|
4
|
+
declare function currentScope(): Scope | undefined;
|
|
5
|
+
declare function snapshotScope(scope?: Scope | undefined): ScopeSnapshot | undefined;
|
|
6
|
+
declare function createScope(options: ScopeOptions): Scope;
|
|
7
|
+
declare function withinScope<T>(options: ScopeOptions, fn: () => T | Promise<T>): Promise<T>;
|
|
8
|
+
declare function restoreScope<T>(snapshot: ScopeSnapshot | undefined, fn: () => T | Promise<T>): Promise<T>;
|
|
9
|
+
|
|
10
|
+
export { Scope, ScopeOptions, ScopeSnapshot, createScope, currentScope, restoreScope, snapshotScope, withinScope };
|
|
@@ -271,4 +271,4 @@ declare class SessionManager {
|
|
|
271
271
|
getStorage(): SessionStorage;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
export { type BranchEntry as B, type CompactionEntry as C, type EntryBase as E, type FileEntry as F, type MessageEntry as M,
|
|
274
|
+
export { type BranchEntry as B, type CompactionEntry as C, type EntryBase as E, type FileEntry as F, type MessageEntry as M, SessionManager as S, type ConfigChangeEntry as a, type CreateSessionOptions as b, type MetadataEntry as c, STORAGE_VERSION as d, type SerializedMessage as e, type SessionContext as f, type SessionEntry as g, type SessionHeader as h, type SessionInfo as i, type SessionStorage as j };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { A as AgentSignal, T as TypedHandler, U as Unsubscribe, W as WildcardHandler } from '../types-YuWV4ag7.js';
|
|
2
|
+
export { E as EventOf } from '../types-YuWV4ag7.js';
|
|
3
|
+
import { A as AgentEvent } from '../events-CE72w8W4.js';
|
|
4
|
+
import 'ai';
|
|
5
|
+
import '../messages-BYWGn8TY.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* LocalSignal — in-process event dispatch.
|
|
9
|
+
*
|
|
10
|
+
* Dispatches events synchronously via direct function calls.
|
|
11
|
+
* Zero dependencies, zero serialization, zero network.
|
|
12
|
+
*
|
|
13
|
+
* Handler errors are caught silently — a broken listener must never
|
|
14
|
+
* interrupt the agent's streaming pipeline.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
declare class LocalSignal implements AgentSignal {
|
|
18
|
+
/** type → Set<handler> for typed subscriptions */
|
|
19
|
+
private readonly typed;
|
|
20
|
+
/** handlers that receive every event */
|
|
21
|
+
private readonly wildcard;
|
|
22
|
+
on<T extends AgentEvent["type"]>(type: T, handler: TypedHandler<T>): Unsubscribe;
|
|
23
|
+
onAny(handler: WildcardHandler): Unsubscribe;
|
|
24
|
+
emit(event: AgentEvent): void;
|
|
25
|
+
clear(): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { AgentSignal, LocalSignal, TypedHandler, Unsubscribe, WildcardHandler };
|
package/dist/skill/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { h as SkillScope, i as SkillSource, a as SkillMetadata, g as SkillResourceType, c as SkillResource, b as SkillContent, d as SkillConfig, S as SkillDiscoveryResult
|
|
2
|
-
export { R as RemoteSkillEntry, e as RemoteSkillIndex, f as SkillDiscoveryError, j as SkillSourceType } from '../
|
|
3
|
-
import { S as SkillRegistry } from '../registry-
|
|
4
|
-
export { c as createSkillRegistry, e as emptySkillRegistry } from '../registry-
|
|
1
|
+
import { h as SkillScope, i as SkillSource, a as SkillMetadata, g as SkillResourceType, c as SkillResource, b as SkillContent, d as SkillConfig, S as SkillDiscoveryResult } from '../types-BfNpU8NS.js';
|
|
2
|
+
export { R as RemoteSkillEntry, e as RemoteSkillIndex, f as SkillDiscoveryError, j as SkillSourceType } from '../types-BfNpU8NS.js';
|
|
3
|
+
import { S as SkillRegistry } from '../registry-DwYqsQkX.js';
|
|
4
|
+
export { c as createSkillRegistry, e as emptySkillRegistry } from '../registry-DwYqsQkX.js';
|
|
5
|
+
import { T as Tool } from '../tool-BHbyUAy3.js';
|
|
5
6
|
import 'zod';
|
|
6
|
-
import '../tool-
|
|
7
|
+
import '../tool-DLXAR9Ce.js';
|
|
8
|
+
import '../types-CHiPh8U2.js';
|
|
9
|
+
import '../types-CQL-SvTn.js';
|
|
7
10
|
|
|
8
11
|
declare const SKILL_FILENAME = "SKILL.md";
|
|
9
12
|
declare const DEFAULT_SKILL_MAX_SIZE = 102400;
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FileEntry,
|
|
2
|
-
export { B as BranchEntry, C as CompactionEntry,
|
|
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-B_CWGTsl.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-B_CWGTsl.js';
|
|
3
3
|
import { M as Message } from '../messages-BYWGn8TY.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { b as AgentProfile, D as DEFAULT_MAX_CONCURRENT, c as DEFAULT_MAX_SPAWN_DEPTH, d as DEFAULT_SESSION_TITLE_PREFIX, S as SubAgentCompletedResult, e as SubAgentHandle, f as SubAgentStatus, g as SubAgentToolConfig, h as SubAgentTracker, i as SubAgentUsage, k as createSubAgentTools } from '../index-CWSchSql.js';
|
|
2
2
|
import 'ai';
|
|
3
|
+
import '../types-BnpEOYV-.js';
|
|
3
4
|
import '../types-CQaXbRsS.js';
|
|
4
|
-
import '../tool-
|
|
5
|
+
import '../tool-BHbyUAy3.js';
|
|
5
6
|
import 'zod';
|
|
6
|
-
import '../tool-
|
|
7
|
-
import '../
|
|
7
|
+
import '../tool-DLXAR9Ce.js';
|
|
8
|
+
import '../types-CHiPh8U2.js';
|
|
9
|
+
import '../types-CQL-SvTn.js';
|
|
10
|
+
import '../runner-e2YRcUoX.js';
|
|
11
|
+
import '@ai-sdk/provider-utils';
|
|
12
|
+
import '../events-CE72w8W4.js';
|
|
8
13
|
import '../messages-BYWGn8TY.js';
|
|
9
|
-
import '../
|
|
14
|
+
import '../types-BfNpU8NS.js';
|
|
15
|
+
import '../session-manager-B_CWGTsl.js';
|
|
10
16
|
import '../types-VQgymC1N.js';
|
|
17
|
+
import '../types-YuWV4ag7.js';
|
|
11
18
|
import '../tracker-DClqYqTj.js';
|
|
12
|
-
import '../builder-
|
|
13
|
-
import '../registry-
|
|
14
|
-
import '../types-
|
|
19
|
+
import '../builder-UpOWQMW3.js';
|
|
20
|
+
import '../registry-DwYqsQkX.js';
|
|
21
|
+
import '../types-KKDrdU9Y.js';
|
|
22
|
+
import '../llm-error-D93FNNLY.js';
|
|
23
|
+
import '../types-QKHHQLLq.js';
|
package/dist/tool/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { T as Tool } from '../tool-
|
|
2
|
-
export { C as CompatibleSchema, I as InferSchemaOutput,
|
|
3
|
-
import { a as ToolReplayPolicy, F as FileOperationMeta, N as NormalizedToolReplayPolicy, d as
|
|
4
|
-
import {
|
|
1
|
+
import { T as Tool } from '../tool-BHbyUAy3.js';
|
|
2
|
+
export { C as CompatibleSchema, I as InferSchemaOutput, d as defineTool } from '../tool-BHbyUAy3.js';
|
|
3
|
+
import { a as ToolReplayPolicy, F as FileOperationMeta, N as NormalizedToolReplayPolicy, d as TurnTrackerContext } from '../tool-DLXAR9Ce.js';
|
|
4
|
+
import { T as ToolHost } from '../types-CHiPh8U2.js';
|
|
5
|
+
import { M as MiddlewareRunner } from '../runner-e2YRcUoX.js';
|
|
5
6
|
import 'zod';
|
|
7
|
+
import '../types-CQL-SvTn.js';
|
|
6
8
|
import 'ai';
|
|
9
|
+
import '@ai-sdk/provider-utils';
|
|
10
|
+
import '../events-CE72w8W4.js';
|
|
7
11
|
import '../messages-BYWGn8TY.js';
|
|
12
|
+
import '../types-BfNpU8NS.js';
|
|
8
13
|
import '../types-CQaXbRsS.js';
|
|
9
14
|
|
|
10
15
|
/**
|
package/dist/tool/index.js
CHANGED
|
@@ -2,9 +2,6 @@ import {
|
|
|
2
2
|
ToolRegistry,
|
|
3
3
|
defaultRegistry
|
|
4
4
|
} from "../chunk-SDSBEQXG.js";
|
|
5
|
-
import {
|
|
6
|
-
executeAgentToolCall
|
|
7
|
-
} from "../chunk-FG4MD5MU.js";
|
|
8
5
|
import {
|
|
9
6
|
MAX_BYTES,
|
|
10
7
|
MAX_LINES,
|
|
@@ -16,7 +13,11 @@ import {
|
|
|
16
13
|
normalizeToolReplayPolicy,
|
|
17
14
|
truncateOutput
|
|
18
15
|
} from "../chunk-P6YF7USR.js";
|
|
16
|
+
import {
|
|
17
|
+
executeAgentToolCall
|
|
18
|
+
} from "../chunk-7VKQ4WPB.js";
|
|
19
19
|
import "../chunk-VEKUXUVF.js";
|
|
20
|
+
import "../chunk-N7P4PN3O.js";
|
|
20
21
|
export {
|
|
21
22
|
MAX_BYTES,
|
|
22
23
|
MAX_LINES,
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { T as ToolMetadata, a as ToolReplayPolicy, b as ToolContext, F as FileOperationMeta, c as ToolResult } from './tool-DLXAR9Ce.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Tool definition namespace for @cuylabs/agent-core
|
|
6
|
+
*
|
|
7
|
+
* Provides consistent tool creation via Tool.define.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A schema type compatible with both Zod 3 and Zod 4.
|
|
12
|
+
*
|
|
13
|
+
* Uses structural typing so that schemas from either Zod version satisfy
|
|
14
|
+
* the constraint. This avoids the problem where Zod 3's `ZodType` class
|
|
15
|
+
* and Zod 4's `ZodType` class have incompatible internal shapes, causing
|
|
16
|
+
* type errors when a library compiled against one version is consumed with
|
|
17
|
+
* the other.
|
|
18
|
+
*
|
|
19
|
+
* Both Zod 3 and Zod 4 (classic API) schemas have `parse()` and `_output`.
|
|
20
|
+
*/
|
|
21
|
+
interface CompatibleSchema<T = any> {
|
|
22
|
+
/** Parse and validate input data. Present in both Zod 3 and Zod 4. */
|
|
23
|
+
parse(data: unknown): T;
|
|
24
|
+
/**
|
|
25
|
+
* Type-level output marker used by both Zod versions:
|
|
26
|
+
* - Zod 3: `readonly _output!: T` (definite assignment assertion)
|
|
27
|
+
* - Zod 4 classic: `get _output(): T` (getter)
|
|
28
|
+
*/
|
|
29
|
+
readonly _output: T;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Infer the output type from a compatible schema.
|
|
33
|
+
* Equivalent to `z.infer<T>` but works with both Zod 3 and Zod 4 schemas.
|
|
34
|
+
*/
|
|
35
|
+
type InferSchemaOutput<T extends CompatibleSchema> = T["_output"];
|
|
36
|
+
/**
|
|
37
|
+
* Tool namespace - tool definition utilities
|
|
38
|
+
*/
|
|
39
|
+
declare namespace Tool {
|
|
40
|
+
/**
|
|
41
|
+
* Tool info interface - the shape of a defined tool
|
|
42
|
+
*/
|
|
43
|
+
interface Info<TParams extends CompatibleSchema = any, TMeta extends ToolMetadata = ToolMetadata> {
|
|
44
|
+
/** Unique tool identifier */
|
|
45
|
+
id: string;
|
|
46
|
+
/** Recovery semantics for resume-capable runtimes. */
|
|
47
|
+
replayPolicy?: ToolReplayPolicy;
|
|
48
|
+
/** Initialize the tool (can be async for dynamic descriptions) */
|
|
49
|
+
init: (ctx?: InitContext) => Promise<InitResult<TParams, TMeta>> | InitResult<TParams, TMeta>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Any tool info - for use in arrays and collections where generic types vary
|
|
53
|
+
*/
|
|
54
|
+
type AnyInfo = Info<any, any>;
|
|
55
|
+
/**
|
|
56
|
+
* Context passed during tool initialization
|
|
57
|
+
*/
|
|
58
|
+
interface InitContext {
|
|
59
|
+
/** Working directory */
|
|
60
|
+
cwd?: string;
|
|
61
|
+
/** Agent name (if known) */
|
|
62
|
+
agent?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Result of tool initialization
|
|
66
|
+
*/
|
|
67
|
+
interface InitResult<TParams extends CompatibleSchema = any, TMeta extends ToolMetadata = ToolMetadata> {
|
|
68
|
+
/** Tool description for the LLM */
|
|
69
|
+
description: string;
|
|
70
|
+
/** Zod schema for parameters */
|
|
71
|
+
parameters: TParams;
|
|
72
|
+
/** Execute the tool */
|
|
73
|
+
execute: (params: InferSchemaOutput<TParams>, ctx: ToolContext) => Promise<ExecuteResult<TMeta>>;
|
|
74
|
+
/** Optional custom validation error formatter */
|
|
75
|
+
formatValidationError?: (error: z.ZodError) => string;
|
|
76
|
+
/**
|
|
77
|
+
* File operation metadata for automatic turn tracking.
|
|
78
|
+
* When set, the agent will automatically capture file baselines
|
|
79
|
+
* before tool execution for undo/diff capabilities.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* // For a write tool
|
|
84
|
+
* fileOps: {
|
|
85
|
+
* pathArgs: ['path'],
|
|
86
|
+
* operationType: 'write'
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
fileOps?: FileOperationMeta;
|
|
91
|
+
/** Optional replay metadata for resume-capable runtimes. */
|
|
92
|
+
replayPolicy?: ToolReplayPolicy;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Result of tool execution
|
|
96
|
+
*/
|
|
97
|
+
interface ExecuteResult<TMeta extends ToolMetadata = ToolMetadata> {
|
|
98
|
+
/** Short title for display */
|
|
99
|
+
title: string;
|
|
100
|
+
/** Main output text */
|
|
101
|
+
output: string;
|
|
102
|
+
/** Metadata */
|
|
103
|
+
metadata: TMeta;
|
|
104
|
+
}
|
|
105
|
+
interface DefineOptions {
|
|
106
|
+
/** Static replay metadata exposed to higher-level runtimes. */
|
|
107
|
+
replayPolicy?: ToolReplayPolicy;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Define a tool with standard patterns
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const myTool = Tool.define("my_tool", {
|
|
115
|
+
* description: "Does something useful",
|
|
116
|
+
* parameters: z.object({
|
|
117
|
+
* input: z.string().describe("The input to process"),
|
|
118
|
+
* }),
|
|
119
|
+
* execute: async (params, ctx) => ({
|
|
120
|
+
* title: "Processed",
|
|
121
|
+
* output: `Result: ${params.input}`,
|
|
122
|
+
* metadata: {},
|
|
123
|
+
* }),
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
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
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Legacy helper - wraps to Tool.Info format
|
|
140
|
+
*
|
|
141
|
+
* @deprecated Use Tool.define instead
|
|
142
|
+
*/
|
|
143
|
+
declare function defineTool<TParams extends CompatibleSchema>(definition: {
|
|
144
|
+
id: string;
|
|
145
|
+
description: string;
|
|
146
|
+
parameters: TParams;
|
|
147
|
+
execute: (params: InferSchemaOutput<TParams>, ctx: ToolContext) => Promise<ToolResult>;
|
|
148
|
+
}): Tool.Info<TParams>;
|
|
149
|
+
|
|
150
|
+
export { type CompatibleSchema as C, type InferSchemaOutput as I, Tool as T, defineTool as d };
|
|
@@ -1,101 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* A ToolHost defines *where* tools execute: local machine, Docker container,
|
|
5
|
-
* SSH remote, etc. Every host provides two surfaces:
|
|
6
|
-
*
|
|
7
|
-
* 1. **File system** — read, write, stat, list, check existence
|
|
8
|
-
* 2. **Process execution** — spawn commands, kill processes
|
|
9
|
-
*
|
|
10
|
-
* Tools call `ctx.host.readFile()` / `ctx.host.exec()` instead of importing
|
|
11
|
-
* `fs` and `child_process` directly. The host implementation handles the rest.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // Default: runs everything locally
|
|
16
|
-
* const agent = createAgent({ host: localHost() });
|
|
17
|
-
*
|
|
18
|
-
* // Future: run tools inside a Docker container
|
|
19
|
-
* const agent = createAgent({ host: dockerHost("my-container") });
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
/** Options for spawning a process. */
|
|
23
|
-
interface ExecOptions {
|
|
24
|
-
/** Working directory for the command. */
|
|
25
|
-
cwd?: string;
|
|
26
|
-
/** Environment variables (merged with host defaults). */
|
|
27
|
-
env?: Record<string, string | undefined>;
|
|
28
|
-
/** Abort signal for cancellation. */
|
|
29
|
-
signal?: AbortSignal;
|
|
30
|
-
/** Timeout in milliseconds. 0 = no timeout. */
|
|
31
|
-
timeout?: number;
|
|
32
|
-
/** Callback for stdout data as it arrives. */
|
|
33
|
-
onStdout?: (data: Buffer) => void;
|
|
34
|
-
/** Callback for stderr data as it arrives. */
|
|
35
|
-
onStderr?: (data: Buffer) => void;
|
|
36
|
-
}
|
|
37
|
-
/** Result of a process execution. */
|
|
38
|
-
interface ExecResult {
|
|
39
|
-
/** Combined stdout output. */
|
|
40
|
-
stdout: string;
|
|
41
|
-
/** Combined stderr output. */
|
|
42
|
-
stderr: string;
|
|
43
|
-
/** Exit code (null if killed by signal). */
|
|
44
|
-
exitCode: number | null;
|
|
45
|
-
/** Whether the process was killed due to timeout. */
|
|
46
|
-
timedOut: boolean;
|
|
47
|
-
}
|
|
48
|
-
/** Minimal stat result — only the fields tools actually need. */
|
|
49
|
-
interface FileStat {
|
|
50
|
-
/** File size in bytes. */
|
|
51
|
-
size: number;
|
|
52
|
-
/** Last modification time. */
|
|
53
|
-
mtime: Date;
|
|
54
|
-
/** Whether this entry is a directory. */
|
|
55
|
-
isDirectory: boolean;
|
|
56
|
-
/** Whether this entry is a regular file. */
|
|
57
|
-
isFile: boolean;
|
|
58
|
-
}
|
|
59
|
-
/** A directory entry returned by `readdir`. */
|
|
60
|
-
interface DirEntry {
|
|
61
|
-
/** Entry name (not full path). */
|
|
62
|
-
name: string;
|
|
63
|
-
/** Whether this entry is a directory. */
|
|
64
|
-
isDirectory: boolean;
|
|
65
|
-
/** Whether this entry is a regular file. */
|
|
66
|
-
isFile: boolean;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* The execution environment for agent tools.
|
|
70
|
-
*
|
|
71
|
-
* Abstracts filesystem and process operations so tools work identically
|
|
72
|
-
* whether running locally, in Docker, over SSH, or in any other environment.
|
|
73
|
-
*/
|
|
74
|
-
interface ToolHost {
|
|
75
|
-
/** Human-readable host identifier (e.g. "local", "docker:my-container"). */
|
|
76
|
-
readonly name: string;
|
|
77
|
-
/** Read a file as a UTF-8 string. Throws if the file doesn't exist. */
|
|
78
|
-
readFile(path: string): Promise<string>;
|
|
79
|
-
/** Read raw bytes from a file. Throws if the file doesn't exist. */
|
|
80
|
-
readBytes(path: string, offset: number, length: number): Promise<Buffer>;
|
|
81
|
-
/** Write a UTF-8 string to a file. Creates parent directories as needed. */
|
|
82
|
-
writeFile(path: string, content: string): Promise<void>;
|
|
83
|
-
/** Check if a path exists. Never throws. */
|
|
84
|
-
exists(path: string): Promise<boolean>;
|
|
85
|
-
/** Get file metadata. Throws if the path doesn't exist. */
|
|
86
|
-
stat(path: string): Promise<FileStat>;
|
|
87
|
-
/** List directory entries. Throws if the path is not a directory. */
|
|
88
|
-
readdir(path: string): Promise<DirEntry[]>;
|
|
89
|
-
/** Create directories recursively. No-op if they already exist. */
|
|
90
|
-
mkdir(path: string): Promise<void>;
|
|
91
|
-
/**
|
|
92
|
-
* Execute a shell command.
|
|
93
|
-
*
|
|
94
|
-
* The host decides which shell to use (e.g. local host uses the user's
|
|
95
|
-
* `$SHELL`, Docker host uses `docker exec`, SSH host uses remote shell).
|
|
96
|
-
*/
|
|
97
|
-
exec(command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
98
|
-
}
|
|
1
|
+
import { T as ToolHost } from './types-CHiPh8U2.js';
|
|
2
|
+
import { S as ScopeSnapshot } from './types-CQL-SvTn.js';
|
|
99
3
|
|
|
100
4
|
/**
|
|
101
5
|
* Tool-related types for @cuylabs/agent-core
|
|
@@ -128,6 +32,8 @@ interface ToolContext {
|
|
|
128
32
|
messageID: string;
|
|
129
33
|
/** Agent name */
|
|
130
34
|
agent: string;
|
|
35
|
+
/** Active execution scope snapshot for this tool call. */
|
|
36
|
+
scope?: ScopeSnapshot;
|
|
131
37
|
/**
|
|
132
38
|
* Execution environment for file and process operations.
|
|
133
39
|
*
|
|
@@ -236,4 +142,4 @@ interface ToolMetadata {
|
|
|
236
142
|
[key: string]: unknown;
|
|
237
143
|
}
|
|
238
144
|
|
|
239
|
-
export type {
|
|
145
|
+
export type { FileOperationMeta as F, NormalizedToolReplayPolicy as N, ToolMetadata as T, ToolReplayPolicy as a, ToolContext as b, ToolResult as c, TurnTrackerContext as d, ToolReplayMode as e, ToolSideEffectLevel as f };
|
package/dist/tracking/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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-DLXAR9Ce.js';
|
|
4
|
+
import '../types-CHiPh8U2.js';
|
|
5
|
+
import '../types-CQL-SvTn.js';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Checkpoint system contracts for @cuylabs/agent-core.
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { T as ToolMetadata, a as ToolReplayPolicy, b as ToolContext, F as FileOperationMeta, c as ToolResult } from './tool-DYp6-cC3.js';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Skill System Types
|
|
6
3
|
*
|
|
@@ -270,150 +267,4 @@ interface SkillDiscoveryError {
|
|
|
270
267
|
reason: string;
|
|
271
268
|
}
|
|
272
269
|
|
|
273
|
-
|
|
274
|
-
* Tool definition namespace for @cuylabs/agent-core
|
|
275
|
-
*
|
|
276
|
-
* Provides consistent tool creation via Tool.define.
|
|
277
|
-
*/
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* A schema type compatible with both Zod 3 and Zod 4.
|
|
281
|
-
*
|
|
282
|
-
* Uses structural typing so that schemas from either Zod version satisfy
|
|
283
|
-
* the constraint. This avoids the problem where Zod 3's `ZodType` class
|
|
284
|
-
* and Zod 4's `ZodType` class have incompatible internal shapes, causing
|
|
285
|
-
* type errors when a library compiled against one version is consumed with
|
|
286
|
-
* the other.
|
|
287
|
-
*
|
|
288
|
-
* Both Zod 3 and Zod 4 (classic API) schemas have `parse()` and `_output`.
|
|
289
|
-
*/
|
|
290
|
-
interface CompatibleSchema<T = any> {
|
|
291
|
-
/** Parse and validate input data. Present in both Zod 3 and Zod 4. */
|
|
292
|
-
parse(data: unknown): T;
|
|
293
|
-
/**
|
|
294
|
-
* Type-level output marker used by both Zod versions:
|
|
295
|
-
* - Zod 3: `readonly _output!: T` (definite assignment assertion)
|
|
296
|
-
* - Zod 4 classic: `get _output(): T` (getter)
|
|
297
|
-
*/
|
|
298
|
-
readonly _output: T;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Infer the output type from a compatible schema.
|
|
302
|
-
* Equivalent to `z.infer<T>` but works with both Zod 3 and Zod 4 schemas.
|
|
303
|
-
*/
|
|
304
|
-
type InferSchemaOutput<T extends CompatibleSchema> = T["_output"];
|
|
305
|
-
/**
|
|
306
|
-
* Tool namespace - tool definition utilities
|
|
307
|
-
*/
|
|
308
|
-
declare namespace Tool {
|
|
309
|
-
/**
|
|
310
|
-
* Tool info interface - the shape of a defined tool
|
|
311
|
-
*/
|
|
312
|
-
interface Info<TParams extends CompatibleSchema = any, TMeta extends ToolMetadata = ToolMetadata> {
|
|
313
|
-
/** Unique tool identifier */
|
|
314
|
-
id: string;
|
|
315
|
-
/** Recovery semantics for resume-capable runtimes. */
|
|
316
|
-
replayPolicy?: ToolReplayPolicy;
|
|
317
|
-
/** Initialize the tool (can be async for dynamic descriptions) */
|
|
318
|
-
init: (ctx?: InitContext) => Promise<InitResult<TParams, TMeta>> | InitResult<TParams, TMeta>;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Any tool info - for use in arrays and collections where generic types vary
|
|
322
|
-
*/
|
|
323
|
-
type AnyInfo = Info<any, any>;
|
|
324
|
-
/**
|
|
325
|
-
* Context passed during tool initialization
|
|
326
|
-
*/
|
|
327
|
-
interface InitContext {
|
|
328
|
-
/** Working directory */
|
|
329
|
-
cwd?: string;
|
|
330
|
-
/** Agent name (if known) */
|
|
331
|
-
agent?: string;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Result of tool initialization
|
|
335
|
-
*/
|
|
336
|
-
interface InitResult<TParams extends CompatibleSchema = any, TMeta extends ToolMetadata = ToolMetadata> {
|
|
337
|
-
/** Tool description for the LLM */
|
|
338
|
-
description: string;
|
|
339
|
-
/** Zod schema for parameters */
|
|
340
|
-
parameters: TParams;
|
|
341
|
-
/** Execute the tool */
|
|
342
|
-
execute: (params: InferSchemaOutput<TParams>, ctx: ToolContext) => Promise<ExecuteResult<TMeta>>;
|
|
343
|
-
/** Optional custom validation error formatter */
|
|
344
|
-
formatValidationError?: (error: z.ZodError) => string;
|
|
345
|
-
/**
|
|
346
|
-
* File operation metadata for automatic turn tracking.
|
|
347
|
-
* When set, the agent will automatically capture file baselines
|
|
348
|
-
* before tool execution for undo/diff capabilities.
|
|
349
|
-
*
|
|
350
|
-
* @example
|
|
351
|
-
* ```typescript
|
|
352
|
-
* // For a write tool
|
|
353
|
-
* fileOps: {
|
|
354
|
-
* pathArgs: ['path'],
|
|
355
|
-
* operationType: 'write'
|
|
356
|
-
* }
|
|
357
|
-
* ```
|
|
358
|
-
*/
|
|
359
|
-
fileOps?: FileOperationMeta;
|
|
360
|
-
/** Optional replay metadata for resume-capable runtimes. */
|
|
361
|
-
replayPolicy?: ToolReplayPolicy;
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Result of tool execution
|
|
365
|
-
*/
|
|
366
|
-
interface ExecuteResult<TMeta extends ToolMetadata = ToolMetadata> {
|
|
367
|
-
/** Short title for display */
|
|
368
|
-
title: string;
|
|
369
|
-
/** Main output text */
|
|
370
|
-
output: string;
|
|
371
|
-
/** Metadata */
|
|
372
|
-
metadata: TMeta;
|
|
373
|
-
}
|
|
374
|
-
interface DefineOptions {
|
|
375
|
-
/** Static replay metadata exposed to higher-level runtimes. */
|
|
376
|
-
replayPolicy?: ToolReplayPolicy;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Define a tool with standard patterns
|
|
380
|
-
*
|
|
381
|
-
* @example
|
|
382
|
-
* ```typescript
|
|
383
|
-
* const myTool = Tool.define("my_tool", {
|
|
384
|
-
* description: "Does something useful",
|
|
385
|
-
* parameters: z.object({
|
|
386
|
-
* input: z.string().describe("The input to process"),
|
|
387
|
-
* }),
|
|
388
|
-
* execute: async (params, ctx) => ({
|
|
389
|
-
* title: "Processed",
|
|
390
|
-
* output: `Result: ${params.input}`,
|
|
391
|
-
* metadata: {},
|
|
392
|
-
* }),
|
|
393
|
-
* });
|
|
394
|
-
* ```
|
|
395
|
-
*/
|
|
396
|
-
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>;
|
|
397
|
-
/**
|
|
398
|
-
* Simple define for static tools (no async init)
|
|
399
|
-
*/
|
|
400
|
-
function defineSimple<TParams extends CompatibleSchema, TMeta extends ToolMetadata = ToolMetadata>(id: string, config: {
|
|
401
|
-
description: string;
|
|
402
|
-
parameters: TParams;
|
|
403
|
-
execute: (params: InferSchemaOutput<TParams>, ctx: ToolContext) => Promise<ExecuteResult<TMeta>>;
|
|
404
|
-
replayPolicy?: ToolReplayPolicy;
|
|
405
|
-
}): Info<TParams, TMeta>;
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Legacy helper - wraps to Tool.Info format
|
|
409
|
-
*
|
|
410
|
-
* @deprecated Use Tool.define instead
|
|
411
|
-
*/
|
|
412
|
-
declare function defineTool<TParams extends CompatibleSchema>(definition: {
|
|
413
|
-
id: string;
|
|
414
|
-
description: string;
|
|
415
|
-
parameters: TParams;
|
|
416
|
-
execute: (params: InferSchemaOutput<TParams>, ctx: ToolContext) => Promise<ToolResult>;
|
|
417
|
-
}): Tool.Info<TParams>;
|
|
418
|
-
|
|
419
|
-
export { type CompatibleSchema as C, type InferSchemaOutput as I, type RemoteSkillEntry as R, type SkillDiscoveryResult as S, Tool as T, type SkillMetadata as a, type SkillContent as b, type SkillResource as c, type SkillConfig as d, type RemoteSkillIndex as e, type SkillDiscoveryError as f, type SkillResourceType as g, type SkillScope as h, type SkillSource as i, type SkillSourceType as j, defineTool as k };
|
|
270
|
+
export type { RemoteSkillEntry as R, SkillDiscoveryResult as S, SkillMetadata as a, SkillContent as b, SkillResource as c, SkillConfig as d, RemoteSkillIndex as e, SkillDiscoveryError as f, SkillResourceType as g, SkillScope as h, SkillSource as i, SkillSourceType as j };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LanguageModel } from 'ai';
|
|
2
|
+
import { R as ReasoningLevel } from './types-CQaXbRsS.js';
|
|
3
|
+
import { T as Tool } from './tool-BHbyUAy3.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Agent preset - a reusable configuration profile.
|
|
7
|
+
*/
|
|
8
|
+
interface Preset {
|
|
9
|
+
/** Unique identifier for this preset */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Human-readable description */
|
|
12
|
+
description: string;
|
|
13
|
+
/**
|
|
14
|
+
* Tool allow patterns (glob-like).
|
|
15
|
+
* If provided, only tools matching these patterns are candidates.
|
|
16
|
+
*/
|
|
17
|
+
allowTools?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Tool deny patterns (glob-like).
|
|
20
|
+
* Deny patterns apply only after allow matching, so explicit allows win.
|
|
21
|
+
*/
|
|
22
|
+
denyTools?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Override system prompt.
|
|
25
|
+
* Use `{basePrompt}` to include the parent's system prompt.
|
|
26
|
+
*/
|
|
27
|
+
systemPrompt?: string;
|
|
28
|
+
/** Override temperature (0-1). */
|
|
29
|
+
temperature?: number;
|
|
30
|
+
/** Override max steps. */
|
|
31
|
+
maxSteps?: number;
|
|
32
|
+
/** Override reasoning level. */
|
|
33
|
+
reasoningLevel?: ReasoningLevel;
|
|
34
|
+
/** Override model. */
|
|
35
|
+
model?: LanguageModel;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Result of applying a preset - ready for `fork()`.
|
|
39
|
+
*/
|
|
40
|
+
interface AppliedPreset {
|
|
41
|
+
name: string;
|
|
42
|
+
systemPrompt?: string;
|
|
43
|
+
tools?: Tool.AnyInfo[];
|
|
44
|
+
temperature?: number;
|
|
45
|
+
maxSteps?: number;
|
|
46
|
+
reasoningLevel?: ReasoningLevel;
|
|
47
|
+
model?: LanguageModel;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type { AppliedPreset as A, Preset as P };
|