@economic/agents 0.0.1-alpha.3 → 0.0.1-alpha.4
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/index.d.mts +8 -20
- package/dist/index.mjs +4 -14
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -75,27 +75,15 @@ declare global {
|
|
|
75
75
|
}
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/features/skills/types.d.ts
|
|
78
|
-
/**
|
|
79
|
-
* A single tool with a name, JSON Schema parameters, and an execute function.
|
|
80
|
-
*
|
|
81
|
-
* Tools are defined in this SDK-agnostic format and converted to the
|
|
82
|
-
* target SDK's format by the adapter layer (createSkills).
|
|
83
|
-
*/
|
|
84
|
-
interface Tool {
|
|
85
|
-
name: string;
|
|
86
|
-
description: string;
|
|
87
|
-
/** JSON Schema object describing the tool's input parameters */
|
|
88
|
-
parameters: Record<string, unknown>;
|
|
89
|
-
execute(args: Record<string, unknown>, options: {
|
|
90
|
-
toolCallId: string;
|
|
91
|
-
}): Promise<string>;
|
|
92
|
-
}
|
|
93
78
|
/**
|
|
94
79
|
* A named group of related tools that can be loaded together on demand.
|
|
95
80
|
*
|
|
96
81
|
* The agent starts with only its always-on tools active. When the LLM calls
|
|
97
82
|
* activate_skill with a skill name, that skill's tools become available for
|
|
98
83
|
* the rest of the conversation.
|
|
84
|
+
*
|
|
85
|
+
* Define tools using the AI SDK's `tool()` helper — Zod schemas are supported
|
|
86
|
+
* natively via the `parameters` field.
|
|
99
87
|
*/
|
|
100
88
|
interface Skill {
|
|
101
89
|
name: string;
|
|
@@ -107,14 +95,14 @@ interface Skill {
|
|
|
107
95
|
* skill that is loaded, keeping the `system` prompt static and cacheable.
|
|
108
96
|
*/
|
|
109
97
|
guidance?: string;
|
|
110
|
-
tools:
|
|
98
|
+
tools: ToolSet;
|
|
111
99
|
}
|
|
112
100
|
/**
|
|
113
101
|
* Configuration passed to createSkills().
|
|
114
102
|
*/
|
|
115
103
|
interface SkillsConfig {
|
|
116
104
|
/** Tools that are always active regardless of loaded skills */
|
|
117
|
-
tools:
|
|
105
|
+
tools: ToolSet;
|
|
118
106
|
/** All available skills that can be loaded on demand */
|
|
119
107
|
skills: Skill[];
|
|
120
108
|
/**
|
|
@@ -240,7 +228,7 @@ declare abstract class AIChatAgentBase<Env extends Cloudflare.Env = Cloudflare.E
|
|
|
240
228
|
*/
|
|
241
229
|
maxPersistedMessages: number;
|
|
242
230
|
/** Tools that are always active regardless of loaded skills */
|
|
243
|
-
abstract getTools():
|
|
231
|
+
abstract getTools(): ToolSet;
|
|
244
232
|
/** All skills available for on-demand loading */
|
|
245
233
|
abstract getSkills(): Skill[];
|
|
246
234
|
/**
|
|
@@ -417,7 +405,7 @@ declare abstract class AIChatAgent<Env extends Cloudflare.Env = Cloudflare.Env>
|
|
|
417
405
|
/** Return the Vercel AI SDK LanguageModel to use for this agent */
|
|
418
406
|
abstract getModel(): LanguageModel;
|
|
419
407
|
/** Tools that are always active regardless of loaded skills */
|
|
420
|
-
abstract getTools():
|
|
408
|
+
abstract getTools(): ToolSet;
|
|
421
409
|
/** All skills available for on-demand loading */
|
|
422
410
|
abstract getSkills(): Skill[];
|
|
423
411
|
/**
|
|
@@ -558,4 +546,4 @@ declare function compactMessages(messages: UIMessage[], model: LanguageModel, ta
|
|
|
558
546
|
*/
|
|
559
547
|
declare function compactIfNeeded(messages: UIMessage[], model: LanguageModel | undefined, tailSize: number): Promise<UIMessage[]>;
|
|
560
548
|
//#endregion
|
|
561
|
-
export { AIChatAgent, AIChatAgentBase, COMPACT_TOKEN_THRESHOLD, type Skill, type SkillContext, type SkillsConfig, type SkillsResult,
|
|
549
|
+
export { AIChatAgent, AIChatAgentBase, COMPACT_TOKEN_THRESHOLD, type Skill, type SkillContext, type SkillsConfig, type SkillsResult, compactIfNeeded, compactMessages, createSkills, estimateMessagesTokens, filterEphemeralMessages, injectGuidance, withSkills };
|
package/dist/index.mjs
CHANGED
|
@@ -62,28 +62,18 @@ function createSkills(config) {
|
|
|
62
62
|
const loadedSkills = new Set(config.initialLoadedSkills ?? []);
|
|
63
63
|
const skillMap = new Map(skills.map((s) => [s.name, s]));
|
|
64
64
|
const allTools = {};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (registeredNames.has(t.name)) return;
|
|
68
|
-
allTools[t.name] = tool({
|
|
69
|
-
description: t.description,
|
|
70
|
-
inputSchema: jsonSchema(t.parameters),
|
|
71
|
-
execute: async (args, options) => t.execute(args, { toolCallId: options.toolCallId })
|
|
72
|
-
});
|
|
73
|
-
registeredNames.add(t.name);
|
|
74
|
-
}
|
|
75
|
-
for (const t of alwaysOnTools) registerTool(t);
|
|
76
|
-
for (const skill of skills) for (const t of skill.tools) registerTool(t);
|
|
65
|
+
Object.assign(allTools, alwaysOnTools);
|
|
66
|
+
for (const skill of skills) Object.assign(allTools, skill.tools);
|
|
77
67
|
function getActiveToolNames() {
|
|
78
68
|
const names = [
|
|
79
69
|
ACTIVATE_SKILL,
|
|
80
70
|
LIST_CAPABILITIES,
|
|
81
|
-
...
|
|
71
|
+
...Object.keys(alwaysOnTools)
|
|
82
72
|
];
|
|
83
73
|
for (const skillName of loadedSkills) {
|
|
84
74
|
const skill = skillMap.get(skillName);
|
|
85
75
|
if (!skill) continue;
|
|
86
|
-
for (const
|
|
76
|
+
for (const toolName of Object.keys(skill.tools)) if (!names.includes(toolName)) names.push(toolName);
|
|
87
77
|
}
|
|
88
78
|
return names;
|
|
89
79
|
}
|