@cuylabs/agent-core 0.7.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-BRvqCcIk.d.ts → builder-BgZ_j4Vs.d.ts} +3 -2
- package/dist/chunk-4QFNWPIF.js +202 -0
- package/dist/chunk-5ARZJWD2.js +259 -0
- package/dist/chunk-DXFBQMXP.js +53 -0
- package/dist/chunk-EKR6PKXU.js +180 -0
- package/dist/{chunk-IVUJDISU.js → chunk-GFTW23FV.js} +5 -14
- package/dist/{chunk-IEFIQENH.js → chunk-H3FUYU52.js} +15 -7
- package/dist/chunk-I6PKJ7XQ.js +292 -0
- package/dist/chunk-IYWQOJMQ.js +102 -0
- package/dist/{chunk-3HNO5SVI.js → chunk-J4QDGZIA.js} +20 -4
- package/dist/{chunk-7MUFEN4K.js → chunk-JLXG2SH7.js} +349 -3
- package/dist/{chunk-CDTV2UYU.js → chunk-MAZ5DY5B.js} +64 -276
- 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-QGOGIP7T.js → chunk-UDCZ673N.js} +385 -233
- package/dist/{chunk-BDBZ3SLK.js → chunk-UHCJEM2E.js} +39 -2
- package/dist/chunk-WGZAPU6N.js +929 -0
- package/dist/{chunk-5K7AQVOU.js → chunk-WKHDSSXG.js} +130 -209
- package/dist/{chunk-BNSHUWCV.js → chunk-WWYYNWEW.js} +1 -1
- package/dist/context/index.js +1 -1
- package/dist/events-CE72w8W4.d.ts +149 -0
- package/dist/index-BCqEGzBj.d.ts +251 -0
- package/dist/{index-C33hlD6H.d.ts → index-DQuTZ8xL.d.ts} +319 -56
- package/dist/index.d.ts +42 -121
- package/dist/index.js +951 -848
- package/dist/inference/errors/index.d.ts +11 -0
- package/dist/inference/errors/index.js +16 -0
- package/dist/inference/index.d.ts +12 -8
- package/dist/inference/index.js +35 -7
- package/dist/llm-error-D93FNNLY.d.ts +32 -0
- package/dist/middleware/index.d.ts +246 -7
- package/dist/middleware/index.js +3 -1
- package/dist/models/index.d.ts +132 -9
- package/dist/models/index.js +48 -8
- package/dist/models/reasoning/index.d.ts +4 -0
- package/dist/{reasoning → models/reasoning}/index.js +2 -7
- package/dist/plugin/index.d.ts +414 -0
- package/dist/plugin/index.js +32 -0
- package/dist/presets/index.d.ts +53 -0
- package/dist/presets/index.js +30 -0
- package/dist/prompt/index.d.ts +11 -8
- package/dist/prompt/index.js +3 -2
- package/dist/{registry-BDLIHOQB.d.ts → registry-DwYqsQkX.d.ts} +1 -1
- package/dist/runner-CI-XeR16.d.ts +91 -0
- package/dist/runtime/index.d.ts +12 -8
- package/dist/runtime/index.js +8 -7
- package/dist/safety/index.d.ts +38 -0
- package/dist/safety/index.js +12 -0
- package/dist/scope/index.d.ts +2 -2
- package/dist/{session-manager-B_CWGTsl.d.ts → session-manager-KbYt2WUh.d.ts} +8 -0
- package/dist/signal/index.d.ts +28 -0
- package/dist/signal/index.js +6 -0
- package/dist/skill/index.d.ts +7 -6
- 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 +16 -10
- package/dist/sub-agent/index.js +21 -4
- package/dist/tool/index.d.ts +22 -6
- package/dist/tool/index.js +3 -3
- package/dist/tool-CZWN3KbO.d.ts +141 -0
- package/dist/{tool-HUtkiVBx.d.ts → tool-DkhSCV2Y.d.ts} +2 -2
- package/dist/tracking/index.d.ts +2 -2
- package/dist/tracking/index.js +1 -1
- package/dist/{tool-Db1Ue-1U.d.ts → types-BfNpU8NS.d.ts} +1 -150
- package/dist/{types-FRpzzg_9.d.ts → types-BlOKk-Bb.d.ts} +10 -35
- package/dist/types-BlZwmnuW.d.ts +50 -0
- package/dist/{types-9jGQUjqW.d.ts → types-CQL-SvTn.d.ts} +1 -1
- package/dist/types-CWm-7rvB.d.ts +55 -0
- package/dist/{runner-DSKaEz3z.d.ts → types-DTSkxakL.d.ts} +7 -235
- package/dist/{types-CqDZTh4d.d.ts → types-DmDwi2zI.d.ts} +8 -4
- package/dist/types-YuWV4ag7.d.ts +72 -0
- package/package.json +67 -6
- package/dist/capability-resolver-CgRGsWVX.d.ts +0 -254
- package/dist/chunk-ZPMACVZK.js +0 -305
- package/dist/index-CfBGYrpd.d.ts +0 -317
- package/dist/reasoning/index.d.ts +0 -117
package/dist/models/index.js
CHANGED
|
@@ -1,36 +1,69 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CacheCapabilitySource,
|
|
3
3
|
CapabilityCache,
|
|
4
|
-
|
|
4
|
+
EXTENDED_LEVELS,
|
|
5
|
+
FIXED_LEVELS,
|
|
5
6
|
ModelCapabilityResolver,
|
|
6
|
-
PatternCapabilitySource,
|
|
7
7
|
RemoteCapabilityFetcher,
|
|
8
8
|
RemoteCapabilitySource,
|
|
9
|
-
|
|
9
|
+
STANDARD_LEVELS,
|
|
10
10
|
applyCapabilityOverride,
|
|
11
|
+
buildAnthropicOptions,
|
|
12
|
+
buildBedrockOptions,
|
|
13
|
+
buildGoogleOptions,
|
|
14
|
+
buildGroqOptions,
|
|
15
|
+
buildOpenAIOptions,
|
|
16
|
+
buildOpenRouterOptions,
|
|
17
|
+
buildReasoningOptions,
|
|
18
|
+
buildReasoningOptionsSync,
|
|
19
|
+
buildXAIOptions,
|
|
11
20
|
configureResolver,
|
|
12
21
|
createResolver,
|
|
13
|
-
extractModelId,
|
|
14
|
-
extractProvider,
|
|
15
22
|
findCapabilityOverride,
|
|
16
23
|
getDefaultResolver,
|
|
17
|
-
getModelId,
|
|
18
24
|
getNetworkStatus,
|
|
25
|
+
getProviderOptionsKey,
|
|
26
|
+
getReasoningConfig,
|
|
27
|
+
getReasoningConfigSync,
|
|
28
|
+
shouldIncludeReasoningSummary,
|
|
29
|
+
supportsReasoning,
|
|
30
|
+
supportsReasoningSync
|
|
31
|
+
} from "../chunk-UDCZ673N.js";
|
|
32
|
+
import {
|
|
33
|
+
DEFAULT_RESOLVER_OPTIONS,
|
|
34
|
+
PatternCapabilitySource,
|
|
35
|
+
SourcePriority,
|
|
36
|
+
extractModelId,
|
|
37
|
+
extractProvider,
|
|
38
|
+
getModelId,
|
|
19
39
|
getProviderCompatibility,
|
|
20
40
|
getProviderId,
|
|
41
|
+
inferContextWindow,
|
|
21
42
|
inferProvider,
|
|
22
43
|
likelySupportsReasoning
|
|
23
|
-
} from "../chunk-
|
|
44
|
+
} from "../chunk-I6PKJ7XQ.js";
|
|
24
45
|
export {
|
|
25
46
|
CacheCapabilitySource,
|
|
26
47
|
CapabilityCache,
|
|
27
48
|
DEFAULT_RESOLVER_OPTIONS,
|
|
49
|
+
EXTENDED_LEVELS,
|
|
50
|
+
FIXED_LEVELS,
|
|
28
51
|
ModelCapabilityResolver,
|
|
29
52
|
PatternCapabilitySource,
|
|
30
53
|
RemoteCapabilityFetcher,
|
|
31
54
|
RemoteCapabilitySource,
|
|
55
|
+
STANDARD_LEVELS,
|
|
32
56
|
SourcePriority,
|
|
33
57
|
applyCapabilityOverride,
|
|
58
|
+
buildAnthropicOptions,
|
|
59
|
+
buildBedrockOptions,
|
|
60
|
+
buildGoogleOptions,
|
|
61
|
+
buildGroqOptions,
|
|
62
|
+
buildOpenAIOptions,
|
|
63
|
+
buildOpenRouterOptions,
|
|
64
|
+
buildReasoningOptions,
|
|
65
|
+
buildReasoningOptionsSync,
|
|
66
|
+
buildXAIOptions,
|
|
34
67
|
configureResolver,
|
|
35
68
|
createResolver,
|
|
36
69
|
extractModelId,
|
|
@@ -41,6 +74,13 @@ export {
|
|
|
41
74
|
getNetworkStatus,
|
|
42
75
|
getProviderCompatibility,
|
|
43
76
|
getProviderId,
|
|
77
|
+
getProviderOptionsKey,
|
|
78
|
+
getReasoningConfig,
|
|
79
|
+
getReasoningConfigSync,
|
|
80
|
+
inferContextWindow,
|
|
44
81
|
inferProvider,
|
|
45
|
-
likelySupportsReasoning
|
|
82
|
+
likelySupportsReasoning,
|
|
83
|
+
shouldIncludeReasoningSummary,
|
|
84
|
+
supportsReasoning,
|
|
85
|
+
supportsReasoningSync
|
|
46
86
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { E as EXTENDED_LEVELS, F as FIXED_LEVELS, a as ReasoningConfig, R as ReasoningLevel, S as STANDARD_LEVELS, s as shouldIncludeReasoningSummary } from '../../types-CQaXbRsS.js';
|
|
2
|
+
export { c as buildAnthropicOptions, d as buildBedrockOptions, e as buildGoogleOptions, f as buildGroqOptions, g as buildOpenAIOptions, h as buildOpenRouterOptions, i as buildReasoningOptions, j as buildReasoningOptionsSync, k as buildXAIOptions, l as getProviderOptionsKey, m as getReasoningConfig, n as getReasoningConfigSync, s as supportsReasoning, o as supportsReasoningSync } from '../../index-BCqEGzBj.js';
|
|
3
|
+
import 'ai';
|
|
4
|
+
import '@ai-sdk/provider-utils';
|
|
@@ -17,11 +17,8 @@ import {
|
|
|
17
17
|
shouldIncludeReasoningSummary,
|
|
18
18
|
supportsReasoning,
|
|
19
19
|
supportsReasoningSync
|
|
20
|
-
} from "
|
|
21
|
-
import
|
|
22
|
-
extractModelId,
|
|
23
|
-
extractProvider
|
|
24
|
-
} from "../chunk-QGOGIP7T.js";
|
|
20
|
+
} from "../../chunk-UDCZ673N.js";
|
|
21
|
+
import "../../chunk-I6PKJ7XQ.js";
|
|
25
22
|
export {
|
|
26
23
|
EXTENDED_LEVELS,
|
|
27
24
|
FIXED_LEVELS,
|
|
@@ -35,8 +32,6 @@ export {
|
|
|
35
32
|
buildReasoningOptions,
|
|
36
33
|
buildReasoningOptionsSync,
|
|
37
34
|
buildXAIOptions,
|
|
38
|
-
extractModelId,
|
|
39
|
-
extractProvider,
|
|
40
35
|
getProviderOptionsKey,
|
|
41
36
|
getReasoningConfig,
|
|
42
37
|
getReasoningConfigSync,
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { A as AgentMiddleware, c as PromptSection } from '../types-DTSkxakL.js';
|
|
2
|
+
import { T as Tool } from '../tool-CZWN3KbO.js';
|
|
3
|
+
import { ZodType } from 'zod';
|
|
4
|
+
import { Jiti } from 'jiti';
|
|
5
|
+
import 'ai';
|
|
6
|
+
import '@ai-sdk/provider-utils';
|
|
7
|
+
import '../events-CE72w8W4.js';
|
|
8
|
+
import '../messages-BYWGn8TY.js';
|
|
9
|
+
import '../types-BfNpU8NS.js';
|
|
10
|
+
import '../types-CQL-SvTn.js';
|
|
11
|
+
import '../tool-DkhSCV2Y.js';
|
|
12
|
+
import '../types-CHiPh8U2.js';
|
|
13
|
+
import '../types-CQaXbRsS.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* PluginEventBus — string-keyed pub/sub for inter-plugin communication.
|
|
17
|
+
*
|
|
18
|
+
* Channel names are namespaced by convention:
|
|
19
|
+
* "finance:transaction-created", "crm:contact-updated".
|
|
20
|
+
*/
|
|
21
|
+
/** Remove a previously registered listener. */
|
|
22
|
+
type PluginUnsubscribe = () => void;
|
|
23
|
+
/** Listener function for a specific channel. */
|
|
24
|
+
type PluginEventHandler = (data: unknown) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Minimal event bus interface. Plugins depend only on this.
|
|
27
|
+
*/
|
|
28
|
+
interface PluginEventBusAPI {
|
|
29
|
+
emit(channel: string, data: unknown): void;
|
|
30
|
+
on(channel: string, handler: PluginEventHandler): PluginUnsubscribe;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* In-process event bus. Dispatches synchronously.
|
|
34
|
+
* Listener errors are caught silently.
|
|
35
|
+
*/
|
|
36
|
+
declare class PluginEventBus implements PluginEventBusAPI {
|
|
37
|
+
private readonly channels;
|
|
38
|
+
emit(channel: string, data: unknown): void;
|
|
39
|
+
on(channel: string, handler: PluginEventHandler): PluginUnsubscribe;
|
|
40
|
+
/** Number of active channels. */
|
|
41
|
+
get size(): number;
|
|
42
|
+
/** Remove all listeners. */
|
|
43
|
+
clear(): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Plugin types — contracts for the extension system.
|
|
48
|
+
*
|
|
49
|
+
* Plugins contribute tools, middleware, commands, prompt sections,
|
|
50
|
+
* and lifecycle hooks to an agent without coupling to a specific host.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/** Static metadata about a plugin (from package.json or inline). */
|
|
54
|
+
interface PluginCompatibility {
|
|
55
|
+
/** Expected plugin API version supported by the host (exact match). */
|
|
56
|
+
apiVersion?: string;
|
|
57
|
+
/** Supported Node.js version range (supports exact or comparator syntax). */
|
|
58
|
+
node?: string;
|
|
59
|
+
}
|
|
60
|
+
interface PluginManifest {
|
|
61
|
+
/** Unique plugin identifier (e.g. "brave-search", "finance") */
|
|
62
|
+
id: string;
|
|
63
|
+
/** Human-readable display name */
|
|
64
|
+
name?: string;
|
|
65
|
+
/** Short description */
|
|
66
|
+
description?: string;
|
|
67
|
+
/** SemVer string */
|
|
68
|
+
version?: string;
|
|
69
|
+
/** Compatibility requirements validated by the host at load time. */
|
|
70
|
+
compatibility?: PluginCompatibility;
|
|
71
|
+
}
|
|
72
|
+
/** A user-facing command registered by a plugin. Host-dependent surfacing. */
|
|
73
|
+
interface PluginCommand {
|
|
74
|
+
/** Command name (without leading slash) */
|
|
75
|
+
name: string;
|
|
76
|
+
/** Optional aliases */
|
|
77
|
+
alias?: string[];
|
|
78
|
+
/** One-line description shown in help */
|
|
79
|
+
summary: string;
|
|
80
|
+
/** Execute the command. Return the text to display, or null for silent. */
|
|
81
|
+
execute: (args: string) => Promise<string | null>;
|
|
82
|
+
}
|
|
83
|
+
type PluginSettingsSchema<T = unknown> = ZodType<T>;
|
|
84
|
+
interface PluginSettingsDefinition<T = unknown> {
|
|
85
|
+
/** Settings namespace. Defaults to the plugin ID. */
|
|
86
|
+
namespace?: string;
|
|
87
|
+
/** Whether missing settings are allowed. Defaults to true. */
|
|
88
|
+
optional?: boolean;
|
|
89
|
+
/** Zod schema used to validate the resolved settings object. */
|
|
90
|
+
schema: PluginSettingsSchema<T>;
|
|
91
|
+
}
|
|
92
|
+
/** Namespace-isolated config access. The host injects the implementation. */
|
|
93
|
+
interface PluginSettingsProvider {
|
|
94
|
+
/**
|
|
95
|
+
* Read the config value for a given namespace.
|
|
96
|
+
*
|
|
97
|
+
* @param namespace Plugin's config key (e.g. "brave-search")
|
|
98
|
+
* @returns The config object, or undefined if not configured.
|
|
99
|
+
*/
|
|
100
|
+
get<T = unknown>(namespace: string): T | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Read and validate a namespace with a schema.
|
|
103
|
+
*
|
|
104
|
+
* Returns undefined when the namespace is not configured.
|
|
105
|
+
*/
|
|
106
|
+
parse<T>(namespace: string, schema: PluginSettingsSchema<T>): T | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Read and validate a namespace with a schema.
|
|
109
|
+
*
|
|
110
|
+
* Throws when the namespace is missing or invalid.
|
|
111
|
+
*/
|
|
112
|
+
require<T>(namespace: string, schema: PluginSettingsSchema<T>): T;
|
|
113
|
+
}
|
|
114
|
+
/** Session lifecycle hooks a plugin can register. */
|
|
115
|
+
interface PluginLifecycleHooks {
|
|
116
|
+
activate?: (ctx: PluginSessionContext) => Promise<void> | void;
|
|
117
|
+
deactivate?: () => Promise<void> | void;
|
|
118
|
+
}
|
|
119
|
+
/** Context available during plugin activation. */
|
|
120
|
+
interface PluginSessionContext {
|
|
121
|
+
/** Agent's working directory */
|
|
122
|
+
cwd: string;
|
|
123
|
+
/** Session ID (if session-based) */
|
|
124
|
+
sessionId?: string;
|
|
125
|
+
}
|
|
126
|
+
/** The API surface passed to a plugin's entry function. */
|
|
127
|
+
interface PluginContext {
|
|
128
|
+
/** Working directory of the agent (project root) */
|
|
129
|
+
cwd: string;
|
|
130
|
+
/** Plugin's own manifest (id, name, version). Read-only. */
|
|
131
|
+
manifest: Readonly<PluginManifest>;
|
|
132
|
+
/** Register a tool the LLM can call */
|
|
133
|
+
addTool(tool: Tool.AnyInfo): void;
|
|
134
|
+
/** Register middleware (model hooks, tool guards, prompt sections) */
|
|
135
|
+
addMiddleware(mw: AgentMiddleware): void;
|
|
136
|
+
/** Register a user-facing command (host-dependent) */
|
|
137
|
+
addCommand(cmd: PluginCommand): void;
|
|
138
|
+
/** Add a dynamic prompt section injected at system-prompt build time. */
|
|
139
|
+
addPromptSection(section: PromptSection): void;
|
|
140
|
+
/** Inter-plugin event bus (string-keyed pub/sub). */
|
|
141
|
+
events: PluginEventBus;
|
|
142
|
+
/** Plugin-namespaced settings from the host. */
|
|
143
|
+
settings: PluginSettingsProvider;
|
|
144
|
+
/** Register an activation hook (fires when the agent session starts). */
|
|
145
|
+
onActivate(fn: (ctx: PluginSessionContext) => Promise<void> | void): void;
|
|
146
|
+
/** Register a deactivation hook (fires when the agent session ends). */
|
|
147
|
+
onDeactivate(fn: () => Promise<void> | void): void;
|
|
148
|
+
}
|
|
149
|
+
/** The function shape a plugin file must default-export. */
|
|
150
|
+
type PluginInit = (ctx: PluginContext) => void | Promise<void>;
|
|
151
|
+
/** Aggregated contributions from all loaded plugins. */
|
|
152
|
+
interface PluginContributions {
|
|
153
|
+
/** Tools to add to the agent's tool set */
|
|
154
|
+
tools: Tool.AnyInfo[];
|
|
155
|
+
/** Middleware to prepend to the agent's middleware stack */
|
|
156
|
+
middleware: AgentMiddleware[];
|
|
157
|
+
/** User-facing commands (host-dependent surfacing) */
|
|
158
|
+
commands: PluginCommand[];
|
|
159
|
+
/** Dynamic prompt sections */
|
|
160
|
+
promptSections: PromptSection[];
|
|
161
|
+
/** Loader / plugin errors (non-fatal — the rest of the system keeps working) */
|
|
162
|
+
errors: Array<{
|
|
163
|
+
pluginId: string;
|
|
164
|
+
error: string;
|
|
165
|
+
}>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Plugin settings — namespace-isolated layered configuration.
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/** Settings provider that always returns undefined. */
|
|
173
|
+
declare class NullSettings implements PluginSettingsProvider {
|
|
174
|
+
get<T = unknown>(_namespace: string): T | undefined;
|
|
175
|
+
parse<T>(_namespace: string, _schema: PluginSettingsSchema<T>): T | undefined;
|
|
176
|
+
require<T>(namespace: string, _schema: PluginSettingsSchema<T>): T;
|
|
177
|
+
}
|
|
178
|
+
/** Settings provider backed by a plain object. Top-level keys are plugin namespaces. */
|
|
179
|
+
declare class StaticSettings implements PluginSettingsProvider {
|
|
180
|
+
private readonly data;
|
|
181
|
+
constructor(data: Record<string, unknown>);
|
|
182
|
+
get<T = unknown>(namespace: string): T | undefined;
|
|
183
|
+
parse<T>(namespace: string, schema: PluginSettingsSchema<T>): T | undefined;
|
|
184
|
+
require<T>(namespace: string, schema: PluginSettingsSchema<T>): T;
|
|
185
|
+
}
|
|
186
|
+
/** Merges multiple settings sources in priority order (later layers win). */
|
|
187
|
+
declare class LayeredSettings implements PluginSettingsProvider {
|
|
188
|
+
private readonly layers;
|
|
189
|
+
constructor(layers: PluginSettingsProvider[]);
|
|
190
|
+
get<T = unknown>(namespace: string): T | undefined;
|
|
191
|
+
parse<T>(namespace: string, schema: PluginSettingsSchema<T>): T | undefined;
|
|
192
|
+
require<T>(namespace: string, schema: PluginSettingsSchema<T>): T;
|
|
193
|
+
}
|
|
194
|
+
/** Wraps a provider with validated overrides for specific namespaces. */
|
|
195
|
+
declare class ValidatedSettings implements PluginSettingsProvider {
|
|
196
|
+
private readonly base;
|
|
197
|
+
private readonly overrides;
|
|
198
|
+
constructor(base: PluginSettingsProvider, overrides: Record<string, unknown>);
|
|
199
|
+
get<T = unknown>(namespace: string): T | undefined;
|
|
200
|
+
parse<T>(namespace: string, schema: PluginSettingsSchema<T>): T | undefined;
|
|
201
|
+
require<T>(namespace: string, schema: PluginSettingsSchema<T>): T;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Plugin loader — filesystem discovery and dynamic import via jiti.
|
|
206
|
+
*
|
|
207
|
+
* Scans `.cuylabs/plugins/` and explicit paths for plugin entries.
|
|
208
|
+
* Files starting with `_` are ignored. Each plugin must default-export
|
|
209
|
+
* a PluginInit function.
|
|
210
|
+
*
|
|
211
|
+
* Uses jiti for TypeScript-native loading — users drop raw `.ts` files
|
|
212
|
+
* and they work without a build step. Transpiled output is cached to
|
|
213
|
+
* disk for fast subsequent loads.
|
|
214
|
+
*
|
|
215
|
+
* Framework packages (`@cuylabs/*`) are auto-aliased so plugins can
|
|
216
|
+
* `import { ... } from "@cuylabs/agent-core"` without any user config.
|
|
217
|
+
* Resolution uses `import.meta.resolve` (ESM standard) with a monorepo
|
|
218
|
+
* workspace fallback for development.
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
/** Options for configuring the plugin loader's jiti instance. */
|
|
222
|
+
interface PluginLoaderOptions {
|
|
223
|
+
/** Extra module aliases (e.g. `{ "@my-lib": "./src/lib" }`). */
|
|
224
|
+
alias?: Record<string, string>;
|
|
225
|
+
/** Modules to skip transforming (already compiled). */
|
|
226
|
+
nativeModules?: string[];
|
|
227
|
+
/** Enable source maps in error stacks (default: true). */
|
|
228
|
+
sourceMaps?: boolean;
|
|
229
|
+
/** Enable jiti debug logging (default: false). */
|
|
230
|
+
debug?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Disable automatic `@cuylabs/*` alias resolution.
|
|
233
|
+
* When false, plugins must resolve framework packages on their own.
|
|
234
|
+
* @default true
|
|
235
|
+
*/
|
|
236
|
+
autoAlias?: boolean;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Auto-resolve `@cuylabs/*` packages to their filesystem paths.
|
|
240
|
+
*
|
|
241
|
+
* Uses two strategies in order:
|
|
242
|
+
* 1. `import.meta.resolve(specifier)` — standard ESM resolution.
|
|
243
|
+
* Works when packages are in node_modules (installed via npm/pnpm).
|
|
244
|
+
* 2. Monorepo workspace fallback — walk up from this file to find
|
|
245
|
+
* the workspace root, then check `packages/<name>/dist/index.js`.
|
|
246
|
+
*
|
|
247
|
+
* Results are cached for the process lifetime.
|
|
248
|
+
*/
|
|
249
|
+
declare function resolveFrameworkAliases(): Record<string, string>;
|
|
250
|
+
/** Reset cached framework aliases (for testing). */
|
|
251
|
+
declare function resetFrameworkAliases(): void;
|
|
252
|
+
/** Get or create a shared jiti instance for plugin loading. */
|
|
253
|
+
declare function getPluginLoader(options?: PluginLoaderOptions): Jiti;
|
|
254
|
+
/** Reset the shared jiti instance (for testing). */
|
|
255
|
+
declare function resetPluginLoader(): void;
|
|
256
|
+
/** A discovered plugin file with its resolved entry path and manifest. */
|
|
257
|
+
interface DiscoveredPlugin {
|
|
258
|
+
entryPath: string;
|
|
259
|
+
manifest: PluginManifest;
|
|
260
|
+
}
|
|
261
|
+
/** Discover plugin files on disk from convention dir and explicit paths. */
|
|
262
|
+
declare function discoverPlugins(cwd: string, extraPaths?: string[]): Promise<DiscoveredPlugin[]>;
|
|
263
|
+
/** Dynamically import a plugin file and extract its init function. */
|
|
264
|
+
declare function loadPluginModule(entryPath: string, options?: PluginLoaderOptions): Promise<PluginInit>;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Declarative plugin authoring — `definePlugin()`.
|
|
268
|
+
*
|
|
269
|
+
* Converts a static plugin definition into a `PluginInit` function.
|
|
270
|
+
* The registry and imperative layer stay unchanged; this is sugar
|
|
271
|
+
* that makes plugins inspectable, type-safe, and easier to author.
|
|
272
|
+
*/
|
|
273
|
+
|
|
274
|
+
/** Declarative plugin definition passed to `definePlugin()`. */
|
|
275
|
+
interface PluginDefinition {
|
|
276
|
+
/** Unique plugin identifier. */
|
|
277
|
+
id: string;
|
|
278
|
+
/** Human-readable display name. */
|
|
279
|
+
name?: string;
|
|
280
|
+
/** Short description. */
|
|
281
|
+
description?: string;
|
|
282
|
+
/** SemVer string. */
|
|
283
|
+
version?: string;
|
|
284
|
+
/** Host/runtime compatibility validated before the plugin is committed. */
|
|
285
|
+
compatibility?: PluginCompatibility;
|
|
286
|
+
/** Optional settings schema to validate before the plugin is committed. */
|
|
287
|
+
settings?: PluginSettingsDefinition;
|
|
288
|
+
/** Tools the LLM can call. Statically declared — inspectable without execution. */
|
|
289
|
+
tools?: Tool.AnyInfo[];
|
|
290
|
+
/** Middleware hooks (model I/O, tool guards, prompt sections). */
|
|
291
|
+
middleware?: AgentMiddleware[];
|
|
292
|
+
/** User-facing commands. */
|
|
293
|
+
commands?: PluginCommand[];
|
|
294
|
+
/** Dynamic prompt sections injected at system-prompt build time. */
|
|
295
|
+
promptSections?: PromptSection[];
|
|
296
|
+
/**
|
|
297
|
+
* Imperative activation hook — runs when the agent session starts.
|
|
298
|
+
* Use for dynamic setup that can't be expressed declaratively
|
|
299
|
+
* (starting servers, loading config, managing state).
|
|
300
|
+
*/
|
|
301
|
+
activate?: (ctx: PluginActivateContext) => Promise<void> | void;
|
|
302
|
+
/**
|
|
303
|
+
* Imperative deactivation hook — runs when the agent session ends.
|
|
304
|
+
*/
|
|
305
|
+
deactivate?: () => Promise<void> | void;
|
|
306
|
+
/**
|
|
307
|
+
* Full imperative escape hatch — runs during plugin loading.
|
|
308
|
+
* Receives the raw PluginContext for anything the declarative
|
|
309
|
+
* fields can't express. Runs after all declarative contributions
|
|
310
|
+
* have been registered.
|
|
311
|
+
*/
|
|
312
|
+
setup?: (ctx: PluginContext) => void | Promise<void>;
|
|
313
|
+
}
|
|
314
|
+
/** Context passed to the declarative `activate` hook. */
|
|
315
|
+
interface PluginActivateContext extends PluginSessionContext {
|
|
316
|
+
/** The plugin's own event bus. */
|
|
317
|
+
events: PluginContext["events"];
|
|
318
|
+
/** The plugin's settings provider. */
|
|
319
|
+
settings: PluginContext["settings"];
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Create a plugin from a declarative definition.
|
|
323
|
+
*
|
|
324
|
+
* Returns a `PluginInit` function that the registry executes normally.
|
|
325
|
+
* The definition object is attached as `init.__definition` so the
|
|
326
|
+
* registry can inspect it without running the plugin.
|
|
327
|
+
*/
|
|
328
|
+
declare function definePlugin(def: PluginDefinition): PluginInit;
|
|
329
|
+
/** A PluginInit created by `definePlugin()` — carries the static definition. */
|
|
330
|
+
interface DefinePluginInit extends PluginInit {
|
|
331
|
+
__definition: PluginDefinition;
|
|
332
|
+
}
|
|
333
|
+
/** Type guard: check if a PluginInit was created by `definePlugin()`. */
|
|
334
|
+
declare function isDefinedPlugin(init: PluginInit): init is DefinePluginInit;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* PluginRegistry — orchestrates the full plugin lifecycle.
|
|
338
|
+
*
|
|
339
|
+
* `loadAll` → `activate` → (agent runs) → `deactivate`.
|
|
340
|
+
* Owns the shared PluginEventBus and wires isolated PluginContext per plugin.
|
|
341
|
+
*/
|
|
342
|
+
|
|
343
|
+
interface PluginRegistryCompatibilityOptions {
|
|
344
|
+
/** Supported plugin API version (exact match). */
|
|
345
|
+
apiVersion?: string;
|
|
346
|
+
/** Runtime Node.js version. Defaults to the current process version. */
|
|
347
|
+
nodeVersion?: string;
|
|
348
|
+
}
|
|
349
|
+
interface PluginRegistryTimeoutOptions {
|
|
350
|
+
/** Maximum time allowed for a plugin init function. */
|
|
351
|
+
load?: number | false;
|
|
352
|
+
/** Maximum time allowed per activation hook. */
|
|
353
|
+
activate?: number | false;
|
|
354
|
+
/** Maximum time allowed per deactivation hook. */
|
|
355
|
+
deactivate?: number | false;
|
|
356
|
+
}
|
|
357
|
+
interface PluginRegistryOptions {
|
|
358
|
+
/** Settings provider. Defaults to NullSettings (no config). */
|
|
359
|
+
settings?: PluginSettingsProvider;
|
|
360
|
+
/** Shared event bus. A fresh one is created if omitted. */
|
|
361
|
+
events?: PluginEventBus;
|
|
362
|
+
/** Options for the jiti-powered plugin loader. */
|
|
363
|
+
loader?: PluginLoaderOptions;
|
|
364
|
+
/** Host compatibility context used to reject incompatible plugins. */
|
|
365
|
+
compatibility?: PluginRegistryCompatibilityOptions;
|
|
366
|
+
/** Timeouts applied to init and lifecycle hooks. */
|
|
367
|
+
timeouts?: PluginRegistryTimeoutOptions;
|
|
368
|
+
}
|
|
369
|
+
declare class PluginRegistry {
|
|
370
|
+
private readonly settings;
|
|
371
|
+
private readonly eventBus;
|
|
372
|
+
private readonly loaderOptions;
|
|
373
|
+
private readonly compatibilityContext;
|
|
374
|
+
private readonly timeouts;
|
|
375
|
+
private readonly plugins;
|
|
376
|
+
private readonly pluginIds;
|
|
377
|
+
private readonly commandOwners;
|
|
378
|
+
private readonly commandTokens;
|
|
379
|
+
private readonly _contributions;
|
|
380
|
+
private activated;
|
|
381
|
+
private activeSessionContext?;
|
|
382
|
+
constructor(options?: PluginRegistryOptions);
|
|
383
|
+
/** The shared event bus wired to all loaded plugins. */
|
|
384
|
+
get events(): PluginEventBus;
|
|
385
|
+
/** Read-only view of everything plugins have contributed. */
|
|
386
|
+
get contributions(): Readonly<PluginContributions>;
|
|
387
|
+
/** Number of successfully loaded plugins. */
|
|
388
|
+
get pluginCount(): number;
|
|
389
|
+
/** Get the static definition for a plugin (if it used `definePlugin()`). */
|
|
390
|
+
getDefinition(pluginId: string): PluginDefinition | undefined;
|
|
391
|
+
/** Get all static definitions (only for declarative plugins). */
|
|
392
|
+
get definitions(): ReadonlyArray<Readonly<PluginDefinition>>;
|
|
393
|
+
/** Get the plugin ID that contributed a command. */
|
|
394
|
+
getCommandOwner(command: PluginCommand): string | undefined;
|
|
395
|
+
/** Record a host-level plugin error without throwing. */
|
|
396
|
+
recordError(pluginId: string, error: string): void;
|
|
397
|
+
/** Discover, load, and execute all plugins. */
|
|
398
|
+
loadAll(cwd: string, extraPaths?: string[]): Promise<void>;
|
|
399
|
+
/** Load a single plugin from its init function (programmatic / tests). */
|
|
400
|
+
loadOne(init: PluginInit, manifest: PluginManifest, cwd: string, entryPath?: string): Promise<void>;
|
|
401
|
+
/** Fire `onActivate` hooks sequentially in load order. */
|
|
402
|
+
activate(ctx: PluginSessionContext): Promise<void>;
|
|
403
|
+
/** Fire `onDeactivate` hooks in reverse load order. */
|
|
404
|
+
deactivate(): Promise<void>;
|
|
405
|
+
private executePlugin;
|
|
406
|
+
private resolvePluginSettings;
|
|
407
|
+
private findCommandConflict;
|
|
408
|
+
private checkCommandTokenConflict;
|
|
409
|
+
private commitPlugin;
|
|
410
|
+
private runActivateHooks;
|
|
411
|
+
private runDeactivateHooks;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export { type DefinePluginInit, type DiscoveredPlugin, LayeredSettings, NullSettings, type PluginActivateContext, type PluginCommand, type PluginCompatibility, type PluginContext, type PluginContributions, type PluginDefinition, PluginEventBus, type PluginEventBusAPI, type PluginEventHandler, type PluginInit, type PluginLifecycleHooks, type PluginLoaderOptions, type PluginManifest, PluginRegistry, type PluginRegistryCompatibilityOptions, type PluginRegistryOptions, type PluginRegistryTimeoutOptions, type PluginSessionContext, type PluginSettingsDefinition, type PluginSettingsProvider, type PluginSettingsSchema, type PluginUnsubscribe, StaticSettings, ValidatedSettings, definePlugin, discoverPlugins, getPluginLoader, isDefinedPlugin, loadPluginModule, resetFrameworkAliases, resetPluginLoader, resolveFrameworkAliases };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LayeredSettings,
|
|
3
|
+
NullSettings,
|
|
4
|
+
PluginEventBus,
|
|
5
|
+
PluginRegistry,
|
|
6
|
+
StaticSettings,
|
|
7
|
+
ValidatedSettings,
|
|
8
|
+
definePlugin,
|
|
9
|
+
discoverPlugins,
|
|
10
|
+
getPluginLoader,
|
|
11
|
+
isDefinedPlugin,
|
|
12
|
+
loadPluginModule,
|
|
13
|
+
resetFrameworkAliases,
|
|
14
|
+
resetPluginLoader,
|
|
15
|
+
resolveFrameworkAliases
|
|
16
|
+
} from "../chunk-WGZAPU6N.js";
|
|
17
|
+
export {
|
|
18
|
+
LayeredSettings,
|
|
19
|
+
NullSettings,
|
|
20
|
+
PluginEventBus,
|
|
21
|
+
PluginRegistry,
|
|
22
|
+
StaticSettings,
|
|
23
|
+
ValidatedSettings,
|
|
24
|
+
definePlugin,
|
|
25
|
+
discoverPlugins,
|
|
26
|
+
getPluginLoader,
|
|
27
|
+
isDefinedPlugin,
|
|
28
|
+
loadPluginModule,
|
|
29
|
+
resetFrameworkAliases,
|
|
30
|
+
resetPluginLoader,
|
|
31
|
+
resolveFrameworkAliases
|
|
32
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { P as Preset, A as AppliedPreset } from '../types-BlZwmnuW.js';
|
|
2
|
+
import { T as Tool } from '../tool-CZWN3KbO.js';
|
|
3
|
+
import 'ai';
|
|
4
|
+
import '../types-CQaXbRsS.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../tool-DkhSCV2Y.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,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyPreset,
|
|
3
|
+
createPreset,
|
|
4
|
+
filterTools,
|
|
5
|
+
mergePresets
|
|
6
|
+
} from "../chunk-IYWQOJMQ.js";
|
|
7
|
+
import {
|
|
8
|
+
Presets,
|
|
9
|
+
careful,
|
|
10
|
+
code,
|
|
11
|
+
explore,
|
|
12
|
+
plan,
|
|
13
|
+
quick,
|
|
14
|
+
review,
|
|
15
|
+
watch
|
|
16
|
+
} from "../chunk-EKR6PKXU.js";
|
|
17
|
+
export {
|
|
18
|
+
Presets,
|
|
19
|
+
applyPreset,
|
|
20
|
+
careful,
|
|
21
|
+
code,
|
|
22
|
+
createPreset,
|
|
23
|
+
explore,
|
|
24
|
+
filterTools,
|
|
25
|
+
mergePresets,
|
|
26
|
+
plan,
|
|
27
|
+
quick,
|
|
28
|
+
review,
|
|
29
|
+
watch
|
|
30
|
+
};
|
package/dist/prompt/index.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { e as ModelFamily, h as EnvironmentInfo, I as InstructionFile } from '../types-DTSkxakL.js';
|
|
2
|
+
export { P as PromptBuildContext, d as PromptConfig, c as PromptSection } from '../types-DTSkxakL.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-BgZ_j4Vs.js';
|
|
5
|
+
export { d as SkillConfig } from '../types-BfNpU8NS.js';
|
|
6
6
|
import '@ai-sdk/provider-utils';
|
|
7
|
+
import '../events-CE72w8W4.js';
|
|
7
8
|
import '../messages-BYWGn8TY.js';
|
|
8
|
-
import '../types-
|
|
9
|
-
import '../tool-
|
|
9
|
+
import '../types-CQL-SvTn.js';
|
|
10
|
+
import '../tool-DkhSCV2Y.js';
|
|
10
11
|
import '../types-CHiPh8U2.js';
|
|
11
|
-
import '../
|
|
12
|
-
import '../registry-BDLIHOQB.js';
|
|
12
|
+
import '../tool-CZWN3KbO.js';
|
|
13
13
|
import 'zod';
|
|
14
|
+
import '../types-CQaXbRsS.js';
|
|
15
|
+
import '../registry-DwYqsQkX.js';
|
|
16
|
+
import '../runner-CI-XeR16.js';
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
19
|
* Prompt Templates — Base system prompts per model family
|