@agenticforge/skills 1.1.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.
Files changed (41) hide show
  1. package/dist/cjs/index.cjs +1 -0
  2. package/dist/esm/index.js +1 -0
  3. package/dist/types/core/src/agent.d.ts +50 -0
  4. package/dist/types/core/src/agent.d.ts.map +1 -0
  5. package/dist/types/core/src/config.d.ts +11 -0
  6. package/dist/types/core/src/config.d.ts.map +1 -0
  7. package/dist/types/core/src/index.d.ts +6 -0
  8. package/dist/types/core/src/index.d.ts.map +1 -0
  9. package/dist/types/core/src/llm.d.ts +9 -0
  10. package/dist/types/core/src/llm.d.ts.map +1 -0
  11. package/dist/types/core/src/message.d.ts +23 -0
  12. package/dist/types/core/src/message.d.ts.map +1 -0
  13. package/dist/types/core/src/types.d.ts +18 -0
  14. package/dist/types/core/src/types.d.ts.map +1 -0
  15. package/dist/types/skills/src/AgentSkill.d.ts +63 -0
  16. package/dist/types/skills/src/AgentSkill.d.ts.map +1 -0
  17. package/dist/types/skills/src/MarkdownSkill.d.ts +81 -0
  18. package/dist/types/skills/src/MarkdownSkill.d.ts.map +1 -0
  19. package/dist/types/skills/src/SkillLoader.d.ts +69 -0
  20. package/dist/types/skills/src/SkillLoader.d.ts.map +1 -0
  21. package/dist/types/skills/src/SkillRegistry.d.ts +32 -0
  22. package/dist/types/skills/src/SkillRegistry.d.ts.map +1 -0
  23. package/dist/types/skills/src/SkillRunner.d.ts +73 -0
  24. package/dist/types/skills/src/SkillRunner.d.ts.map +1 -0
  25. package/dist/types/skills/src/index.d.ts +7 -0
  26. package/dist/types/skills/src/index.d.ts.map +1 -0
  27. package/dist/types/skills/src/types.d.ts +64 -0
  28. package/dist/types/skills/src/types.d.ts.map +1 -0
  29. package/dist/types/tools/src/AsyncToolExecutor.d.ts +30 -0
  30. package/dist/types/tools/src/AsyncToolExecutor.d.ts.map +1 -0
  31. package/dist/types/tools/src/Tool.d.ts +74 -0
  32. package/dist/types/tools/src/Tool.d.ts.map +1 -0
  33. package/dist/types/tools/src/ToolChain.d.ts +47 -0
  34. package/dist/types/tools/src/ToolChain.d.ts.map +1 -0
  35. package/dist/types/tools/src/ToolRegistry.d.ts +22 -0
  36. package/dist/types/tools/src/ToolRegistry.d.ts.map +1 -0
  37. package/dist/types/tools/src/index.d.ts +6 -0
  38. package/dist/types/tools/src/index.d.ts.map +1 -0
  39. package/dist/types/tools/src/types.d.ts +13 -0
  40. package/dist/types/tools/src/types.d.ts.map +1 -0
  41. package/package.json +65 -0
@@ -0,0 +1 @@
1
+ "use strict";var t=require("@agenticforge/tools");class e{name;description;triggerHint;systemPrompt;tools;visible;constructor(t){this.name=t.name,this.description=t.description,this.triggerHint=t.triggerHint,this.systemPrompt=t.systemPrompt,this.tools=t.tools??[],this.visible=t.visible??!0}_registry;get toolRegistry(){if(!this._registry){this._registry=new t.ToolRegistry;for(const e of this.tools)e instanceof t.Tool?this._registry.registerTool(e):this._registry.registerFunction(e.name,e.description,e.func,e.schema)}return this._registry}async execute(t,e){const s=[{role:"system",content:this.systemPrompt??`你是专门负责"${this.description}"的助理。`},...t.history??[],{role:"user",content:t.query}];if(0===this.tools.length)return{output:await e.think(s)};const i=[],r=s.map(t=>({...t})),o=this.toolRegistry.getOpenAISchemas(),n=e.client,l=e.model;if(!n||!l)return{output:await e.think(s)};let a="";for(let t=0;t<3;t++){const t=await n.chat.completions.create({model:l,messages:r,tools:o,tool_choice:"auto",stream:!1}),e=t.choices?.[0]?.message,s=e?.content??"",c=e?.tool_calls??[];if(0===c.length){a=s;break}r.push({role:"assistant",content:s,tool_calls:c});for(const t of c){i.push(t.function.name);let e={};try{e=JSON.parse(t.function.arguments)}catch{}let s="";try{s=await this.toolRegistry.execute(t.function.name,e)}catch(t){s=`Error: ${t instanceof Error?t.message:String(t)}`}r.push({role:"tool",tool_call_id:t.id,name:t.function.name,content:s})}}if(!a){const t=await n.chat.completions.create({model:l,messages:r,tools:o,tool_choice:"none",stream:!1});a=t.choices?.[0]?.message?.content??""}return{output:a,toolsUsed:i}}describe(){const t=[`- **${this.name}**: ${this.description}`];return this.triggerHint&&t.push(` 触发条件:${this.triggerHint}`),t.join("\n")}}class s{skills=new Map;register(t){this.skills.set(t.name,t)}unregister(t){return this.skills.delete(t)}get(t){return this.skills.get(t)}has(t){return this.skills.has(t)}list(){return Array.from(this.skills.keys())}all(){return Array.from(this.skills.values())}visible(){return this.all().filter(t=>!1!==t.visible)}size(){return this.skills.size}describeAll(){const t=this.visible();return 0===t.length?"(暂无可用 Skill)":t.map(t=>t instanceof e?t.describe():`- **${t.name}**: ${t.description}${t.triggerHint?`\n 触发条件:${t.triggerHint}`:""}`).join("\n")}}function i(t){const e=t.trim().match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!e){const e=t.match(/^#\s+(.+)$/m);return{frontmatter:{name:e?r(e[1]):"unknown-skill",description:e?e[1]:"Unnamed skill"},body:t}}const[,s,i]=e,o={};for(const t of s.split(/\r?\n/)){const e=t.match(/^([\w-]+):\s*(.*)$/);if(!e)continue;const[,s,i]=e;o[s]="true"===i||"false"!==i&&i.replace(/^"|"$/g,"").replace(/^'|'$/g,"").trim()}if(!o.name){const t=i.match(/^#\s+(.+)$/m);o.name=t?r(t[1]):"unknown-skill"}return o.description||(o.description=o.name),{frontmatter:o,body:i.trim()}}function r(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}class o{name;description;triggerHint;visible;tools=[];systemPrompt;frontmatter;filePath;constructor(t,e,s){this.frontmatter=t,this.name=t.name,this.description=t.description,this.triggerHint=t.triggerHint,this.visible=!1!==t.visible,this.systemPrompt=e,this.filePath=s}static fromSource(t,e){const{frontmatter:s,body:r}=i(t);return new o(s,r,e)}static async fromFile(t){const{readFile:e}=await import("node:fs/promises"),s=await e(t,"utf8");return o.fromSource(s,t)}async execute(t,e){const s=[{role:"system",content:this.systemPrompt},...t.history??[],{role:"user",content:t.query}];return{output:await e.think(s)}}describe(){const t=[`- **${this.name}**: ${this.description}`];return this.triggerHint&&t.push(` 触发条件:${this.triggerHint}`),t.join("\n")}}class n{static async fromDirectory(t,e={}){const{readdir:s,stat:i}=await import("node:fs/promises"),{join:r,resolve:n}=await import("node:path"),a=e.recursive??!0,c=[],m=n(t);return await async function t(e){let n;try{n=await s(e)}catch{return}for(const s of n){const n=r(e,s);let m;try{m=await i(n)}catch{continue}if(m.isDirectory())a&&await t(n);else if(l(s))try{c.push(await o.fromFile(n))}catch(t){console.warn(`[SkillLoader] Failed to load ${n}: ${String(t)}`)}}}(m),c}static async fromFiles(t){const{resolve:e}=await import("node:path"),s=[];for(const i of t)try{s.push(await o.fromFile(e(i)))}catch(t){console.warn(`[SkillLoader] Failed to load ${i}: ${String(t)}`)}return s}static fromSources(t){return t.map(({source:t,filePath:e})=>o.fromSource(t,e))}static toRegistry(t,e){const i=e??new s;for(const e of t)i.register(e);return i}static async registryFromDirectory(t,e){const s=await n.fromDirectory(t,e);return n.toRegistry(s)}}function l(t){const e=t.toLowerCase();return"skill.md"===e||e.endsWith(".skill.md")}exports.AgentSkill=e,exports.MarkdownSkill=o,exports.SkillLoader=n,exports.SkillRegistry=s,exports.SkillRunner=class{skillRegistry;llm;fallbackPrompt;routerPromptTemplate;constructor(t){this.llm=t.llm,this.fallbackPrompt=t.fallbackPrompt??"你是一个通用AI助理,请回答用户的问题。",this.routerPromptTemplate=t.routerPromptTemplate??["你是一个意图路由器。根据用户输入,从下面的 Skill 列表中选出最合适的一个。","只回答 Skill 的名称(name 字段),不要包含任何解释或标点。","","## 可用 Skills","{skills}","","## 用户输入","{query}","","## 你的选择(只填 Skill name):"].join("\n"),this.skillRegistry=new s;for(const e of t.skills??[])this.skillRegistry.register(e)}addSkill(t){this.skillRegistry.register(t)}removeSkill(t){return this.skillRegistry.unregister(t)}listSkills(){return this.skillRegistry.list()}async routeToSkill(t){const e=this.skillRegistry.visible();if(0===e.length)return;if(1===e.length)return e[0];const s=this.routerPromptTemplate.replace("{skills}",this.skillRegistry.describeAll()).replace("{query}",t),i=(await this.llm.think([{role:"user",content:s}])).trim().toLowerCase();return this.skillRegistry.get(i)??e.find(t=>t.name.toLowerCase().startsWith(i))??e.find(t=>i.includes(t.name.toLowerCase()))}async run(t,e){let s;if(e?.skillName){if(s=this.skillRegistry.get(e.skillName),!s)throw new Error(`Skill "${e.skillName}" not found. Available: ${this.skillRegistry.list().join(", ")}`)}else s=await this.routeToSkill(t);if(!s)return{output:await this.llm.think([{role:"system",content:this.fallbackPrompt},...e?.history??[],{role:"user",content:t}])};const i={query:t,metadata:e?.metadata,history:e?.history};return s.execute(i,this.llm)}async runSkill(t,e,s){return this.run(e,{skillName:t,...s})}},exports.parseFrontmatter=i;
@@ -0,0 +1 @@
1
+ import{ToolRegistry as t,Tool as e}from"@agenticforge/tools";class s{name;description;triggerHint;systemPrompt;tools;visible;constructor(t){this.name=t.name,this.description=t.description,this.triggerHint=t.triggerHint,this.systemPrompt=t.systemPrompt,this.tools=t.tools??[],this.visible=t.visible??!0}_registry;get toolRegistry(){if(!this._registry){this._registry=new t;for(const t of this.tools)t instanceof e?this._registry.registerTool(t):this._registry.registerFunction(t.name,t.description,t.func,t.schema)}return this._registry}async execute(t,e){const s=[{role:"system",content:this.systemPrompt??`你是专门负责"${this.description}"的助理。`},...t.history??[],{role:"user",content:t.query}];if(0===this.tools.length)return{output:await e.think(s)};const i=[],r=s.map(t=>({...t})),o=this.toolRegistry.getOpenAISchemas(),n=e.client,l=e.model;if(!n||!l)return{output:await e.think(s)};let a="";for(let t=0;t<3;t++){const t=await n.chat.completions.create({model:l,messages:r,tools:o,tool_choice:"auto",stream:!1}),e=t.choices?.[0]?.message,s=e?.content??"",c=e?.tool_calls??[];if(0===c.length){a=s;break}r.push({role:"assistant",content:s,tool_calls:c});for(const t of c){i.push(t.function.name);let e={};try{e=JSON.parse(t.function.arguments)}catch{}let s="";try{s=await this.toolRegistry.execute(t.function.name,e)}catch(t){s=`Error: ${t instanceof Error?t.message:String(t)}`}r.push({role:"tool",tool_call_id:t.id,name:t.function.name,content:s})}}if(!a){const t=await n.chat.completions.create({model:l,messages:r,tools:o,tool_choice:"none",stream:!1});a=t.choices?.[0]?.message?.content??""}return{output:a,toolsUsed:i}}describe(){const t=[`- **${this.name}**: ${this.description}`];return this.triggerHint&&t.push(` 触发条件:${this.triggerHint}`),t.join("\n")}}class i{skills=new Map;register(t){this.skills.set(t.name,t)}unregister(t){return this.skills.delete(t)}get(t){return this.skills.get(t)}has(t){return this.skills.has(t)}list(){return Array.from(this.skills.keys())}all(){return Array.from(this.skills.values())}visible(){return this.all().filter(t=>!1!==t.visible)}size(){return this.skills.size}describeAll(){const t=this.visible();return 0===t.length?"(暂无可用 Skill)":t.map(t=>t instanceof s?t.describe():`- **${t.name}**: ${t.description}${t.triggerHint?`\n 触发条件:${t.triggerHint}`:""}`).join("\n")}}class r{skillRegistry;llm;fallbackPrompt;routerPromptTemplate;constructor(t){this.llm=t.llm,this.fallbackPrompt=t.fallbackPrompt??"你是一个通用AI助理,请回答用户的问题。",this.routerPromptTemplate=t.routerPromptTemplate??["你是一个意图路由器。根据用户输入,从下面的 Skill 列表中选出最合适的一个。","只回答 Skill 的名称(name 字段),不要包含任何解释或标点。","","## 可用 Skills","{skills}","","## 用户输入","{query}","","## 你的选择(只填 Skill name):"].join("\n"),this.skillRegistry=new i;for(const e of t.skills??[])this.skillRegistry.register(e)}addSkill(t){this.skillRegistry.register(t)}removeSkill(t){return this.skillRegistry.unregister(t)}listSkills(){return this.skillRegistry.list()}async routeToSkill(t){const e=this.skillRegistry.visible();if(0===e.length)return;if(1===e.length)return e[0];const s=this.routerPromptTemplate.replace("{skills}",this.skillRegistry.describeAll()).replace("{query}",t),i=(await this.llm.think([{role:"user",content:s}])).trim().toLowerCase();return this.skillRegistry.get(i)??e.find(t=>t.name.toLowerCase().startsWith(i))??e.find(t=>i.includes(t.name.toLowerCase()))}async run(t,e){let s;if(e?.skillName){if(s=this.skillRegistry.get(e.skillName),!s)throw new Error(`Skill "${e.skillName}" not found. Available: ${this.skillRegistry.list().join(", ")}`)}else s=await this.routeToSkill(t);if(!s)return{output:await this.llm.think([{role:"system",content:this.fallbackPrompt},...e?.history??[],{role:"user",content:t}])};const i={query:t,metadata:e?.metadata,history:e?.history};return s.execute(i,this.llm)}async runSkill(t,e,s){return this.run(e,{skillName:t,...s})}}function o(t){const e=t.trim().match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!e){const e=t.match(/^#\s+(.+)$/m);return{frontmatter:{name:e?n(e[1]):"unknown-skill",description:e?e[1]:"Unnamed skill"},body:t}}const[,s,i]=e,r={};for(const t of s.split(/\r?\n/)){const e=t.match(/^([\w-]+):\s*(.*)$/);if(!e)continue;const[,s,i]=e;r[s]="true"===i||"false"!==i&&i.replace(/^"|"$/g,"").replace(/^'|'$/g,"").trim()}if(!r.name){const t=i.match(/^#\s+(.+)$/m);r.name=t?n(t[1]):"unknown-skill"}return r.description||(r.description=r.name),{frontmatter:r,body:i.trim()}}function n(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}class l{name;description;triggerHint;visible;tools=[];systemPrompt;frontmatter;filePath;constructor(t,e,s){this.frontmatter=t,this.name=t.name,this.description=t.description,this.triggerHint=t.triggerHint,this.visible=!1!==t.visible,this.systemPrompt=e,this.filePath=s}static fromSource(t,e){const{frontmatter:s,body:i}=o(t);return new l(s,i,e)}static async fromFile(t){const{readFile:e}=await import("node:fs/promises"),s=await e(t,"utf8");return l.fromSource(s,t)}async execute(t,e){const s=[{role:"system",content:this.systemPrompt},...t.history??[],{role:"user",content:t.query}];return{output:await e.think(s)}}describe(){const t=[`- **${this.name}**: ${this.description}`];return this.triggerHint&&t.push(` 触发条件:${this.triggerHint}`),t.join("\n")}}class a{static async fromDirectory(t,e={}){const{readdir:s,stat:i}=await import("node:fs/promises"),{join:r,resolve:o}=await import("node:path"),n=e.recursive??!0,a=[],m=o(t);return await async function t(e){let o;try{o=await s(e)}catch{return}for(const s of o){const o=r(e,s);let m;try{m=await i(o)}catch{continue}if(m.isDirectory())n&&await t(o);else if(c(s))try{a.push(await l.fromFile(o))}catch(t){console.warn(`[SkillLoader] Failed to load ${o}: ${String(t)}`)}}}(m),a}static async fromFiles(t){const{resolve:e}=await import("node:path"),s=[];for(const i of t)try{s.push(await l.fromFile(e(i)))}catch(t){console.warn(`[SkillLoader] Failed to load ${i}: ${String(t)}`)}return s}static fromSources(t){return t.map(({source:t,filePath:e})=>l.fromSource(t,e))}static toRegistry(t,e){const s=e??new i;for(const e of t)s.register(e);return s}static async registryFromDirectory(t,e){const s=await a.fromDirectory(t,e);return a.toRegistry(s)}}function c(t){const e=t.toLowerCase();return"skill.md"===e||e.endsWith(".skill.md")}export{s as AgentSkill,l as MarkdownSkill,a as SkillLoader,i as SkillRegistry,r as SkillRunner,o as parseFrontmatter};
@@ -0,0 +1,50 @@
1
+ import { Message } from "./message";
2
+ import { LLMClient } from "./llm";
3
+ import { Config } from "./config";
4
+ import { type ZodType } from "zod";
5
+ /** Agent 基类 */
6
+ export declare abstract class Agent {
7
+ protected readonly name: string;
8
+ protected readonly llm: LLMClient;
9
+ protected readonly systemPrompt?: string;
10
+ protected readonly config: Config;
11
+ protected readonly history: Message[];
12
+ constructor(params: {
13
+ name: string;
14
+ llm: LLMClient;
15
+ systemPrompt?: string;
16
+ config?: Config;
17
+ });
18
+ /** 运行 Agent */
19
+ abstract run(inputText: string, ...args: unknown[]): Promise<string> | string;
20
+ /** 添加消息到历史记录 */
21
+ addMessage(message: Message): void;
22
+ /** 清空历史记录 */
23
+ clearHistory(): void;
24
+ /** 获取历史记录 */
25
+ getHistory(): Message[];
26
+ /**
27
+ * 结构化输出入口:
28
+ * - 通过 schema 约束模型返回 JSON
29
+ * - 自动从回复中提取 JSON 并进行校验
30
+ */
31
+ runStructured<T>(params: {
32
+ inputText: string;
33
+ schema: ZodType<T>;
34
+ instruction?: string;
35
+ maxRetries?: number;
36
+ options?: unknown;
37
+ }): Promise<T>;
38
+ /**
39
+ * 根据 Zod schema 自动生成结构化输出提示词。
40
+ */
41
+ protected buildStructuredInstructionFromSchema<T>(schema: ZodType<T>): string;
42
+ /**
43
+ * 从文本中提取 JSON 主体:
44
+ * - 支持 ```json ... ``` 包裹
45
+ * - 支持纯 JSON 文本
46
+ */
47
+ protected extractJsonBlock(text: string): string;
48
+ toString(): string;
49
+ }
50
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../../../core/src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAI,KAAK,OAAO,EAAC,MAAM,KAAK,CAAC;AAEpC,eAAe;AACf,8BAAsB,KAAK;IACzB,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAClC,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACzC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,CAAM;gBAE/B,MAAM,EAAE;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,SAAS,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAOD,eAAe;IACf,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM;IAE7E,gBAAgB;IAChB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIlC,aAAa;IACb,YAAY,IAAI,IAAI;IAIpB,aAAa;IACb,UAAU,IAAI,OAAO,EAAE;IAIvB;;;;OAIG;IACG,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE;QAC7B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GAAG,OAAO,CAAC,CAAC,CAAC;IA+Dd;;OAEG;IACH,SAAS,CAAC,oCAAoC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM;IAU7E;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IA8BhD,QAAQ,IAAI,MAAM;CAInB"}
@@ -0,0 +1,11 @@
1
+ import type { Provider, ProviderConfig } from "./types";
2
+ export interface RuntimeConfig {
3
+ defaultProvider: Provider;
4
+ providers: Record<string, ProviderConfig>;
5
+ }
6
+ export declare class Config {
7
+ defaultProvider: Provider;
8
+ providers: Record<string, ProviderConfig>;
9
+ constructor(overrides?: Partial<RuntimeConfig>);
10
+ }
11
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../core/src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,QAAQ,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC3C;AAED,qBAAa,MAAM;IACV,eAAe,EAAE,QAAQ,CAAY;IACrC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAM;gBAE1C,SAAS,GAAE,OAAO,CAAC,aAAa,CAAM;CAInD"}
@@ -0,0 +1,6 @@
1
+ export * from "./agent";
2
+ export * from "./config";
3
+ export * from "./llm";
4
+ export * from "./message";
5
+ export * from "./types";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { LLMMessage, LLMOptions } from "./types";
2
+ export declare class LLMClient {
3
+ private readonly client;
4
+ private readonly model;
5
+ constructor(options?: LLMOptions);
6
+ think(messages: LLMMessage[], temperature?: number): Promise<string>;
7
+ streamThink(messages: LLMMessage[], temperature?: number): AsyncGenerator<string>;
8
+ }
9
+ //# sourceMappingURL=llm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../../../../core/src/llm.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AAkBpD,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,OAAO,GAAE,UAAe;IAqB9B,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,WAAW,SAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ9D,WAAW,CAChB,QAAQ,EAAE,UAAU,EAAE,EACtB,WAAW,SAAI,GACd,cAAc,CAAC,MAAM,CAAC;CAe1B"}
@@ -0,0 +1,23 @@
1
+ export type MessageRole = "user" | "assistant" | "system" | "tool";
2
+ export interface MessageMetadata {
3
+ [key: string]: unknown;
4
+ }
5
+ export declare class Message {
6
+ readonly content: string;
7
+ readonly role: MessageRole;
8
+ readonly timestamp: Date;
9
+ readonly metadata: MessageMetadata;
10
+ constructor(params: {
11
+ content: string;
12
+ role: MessageRole;
13
+ timestamp?: Date;
14
+ metadata?: MessageMetadata;
15
+ });
16
+ /** 转换为字典格式(OpenAI API 格式) */
17
+ toDict(): {
18
+ role: MessageRole;
19
+ content: string;
20
+ };
21
+ toString(): string;
22
+ }
23
+ //# sourceMappingURL=message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../../core/src/message.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEnE,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qBAAa,OAAO;IAClB,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,IAAI,EAAE,WAAW,CAAC;IAClC,SAAgB,SAAS,EAAE,IAAI,CAAC;IAChC,SAAgB,QAAQ,EAAE,eAAe,CAAC;gBAE9B,MAAM,EAAE;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,WAAW,CAAC;QAClB,SAAS,CAAC,EAAE,IAAI,CAAC;QACjB,QAAQ,CAAC,EAAE,eAAe,CAAC;KAC5B;IAOD,6BAA6B;IAC7B,MAAM,IAAI;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC;IAO9C,QAAQ,IAAI,MAAM;CAGnB"}
@@ -0,0 +1,18 @@
1
+ export type Provider = "openai" | "anthropic" | "local";
2
+ export interface ProviderConfig {
3
+ apiKey?: string;
4
+ baseURL?: string;
5
+ model?: string;
6
+ timeoutMs?: number;
7
+ }
8
+ export interface LLMOptions {
9
+ apiKey?: string;
10
+ baseURL?: string;
11
+ model?: string;
12
+ timeoutMs?: number;
13
+ }
14
+ export interface LLMMessage {
15
+ role: "system" | "user" | "assistant" | "tool";
16
+ content: string;
17
+ }
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../core/src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,63 @@
1
+ import { Tool, type FunctionTool, ToolRegistry } from "@agenticforge/tools";
2
+ import type { LLMClient } from "@agenticforge/core";
3
+ import type { IAgentSkill, SkillContext, SkillDefinition, SkillResult } from "./types";
4
+ /**
5
+ * AgentSkill 是一个可复用的 Agent 能力单元。
6
+ *
7
+ * 类比:
8
+ * - Semantic Kernel 的 `KernelPlugin`
9
+ * - Copilot Studio 的 `Skill`
10
+ * - AutoGen 的 `AssistantAgent` with specific tools
11
+ *
12
+ * 每个 Skill 封装了:
13
+ * - 一个明确的业务语义(name + description)
14
+ * - 专属的 System Prompt
15
+ * - 专属的工具集(只有这个 Skill 能用的工具)
16
+ * - 独立的 execute() 执行逻辑
17
+ *
18
+ * 使用方式 A — 直接实例化(适合简单场景):
19
+ * ```ts
20
+ * const weatherSkill = new AgentSkill({
21
+ * name: "weather",
22
+ * description: "获取城市实时天气,回答关于温度、降雨、风速的问题",
23
+ * triggerHint: "当用户询问天气、温度、是否下雨时",
24
+ * systemPrompt: "你是天气助理,只回答天气相关问题,用简洁中文回答。",
25
+ * tools: [weatherApiTool],
26
+ * });
27
+ * ```
28
+ *
29
+ * 使用方式 B — 继承扩展(适合复杂场景):
30
+ * ```ts
31
+ * class StockSkill extends AgentSkill {
32
+ * constructor() {
33
+ * super({ name: "stock", description: "查询股票实时价格", tools: [stockTool] });
34
+ * }
35
+ *
36
+ * override async execute(ctx, llm): Promise<SkillResult> {
37
+ * const price = await fetchStockPrice(ctx.query);
38
+ * return { output: `当前股价:${price}` };
39
+ * }
40
+ * }
41
+ * ```
42
+ */
43
+ export declare class AgentSkill implements IAgentSkill {
44
+ readonly name: string;
45
+ readonly description: string;
46
+ readonly triggerHint?: string;
47
+ readonly systemPrompt?: string;
48
+ readonly tools: Array<Tool | FunctionTool<Record<string, unknown>>>;
49
+ readonly visible: boolean;
50
+ constructor(definition: SkillDefinition);
51
+ private _registry?;
52
+ protected get toolRegistry(): ToolRegistry;
53
+ /**
54
+ * Default implementation: builds messages from context + systemPrompt,
55
+ * appends tool schemas if tools are configured, calls the LLM,
56
+ * and runs a tool-call loop (up to 3 iterations).
57
+ *
58
+ * Override this method for fully custom Skill logic.
59
+ */
60
+ execute(context: SkillContext, llm: LLMClient): Promise<SkillResult>;
61
+ describe(): string;
62
+ }
63
+ //# sourceMappingURL=AgentSkill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentSkill.d.ts","sourceRoot":"","sources":["../../../../src/AgentSkill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,KAAK,YAAY,EAAE,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAC,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAMrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBAAa,UAAW,YAAW,WAAW;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBAEd,UAAU,EAAE,eAAe;IAavC,OAAO,CAAC,SAAS,CAAC,CAAe;IAEjC,SAAS,KAAK,YAAY,IAAI,YAAY,CAiBzC;IAMD;;;;;;OAMG;IACG,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAsG1E,QAAQ,IAAI,MAAM;CAKnB"}
@@ -0,0 +1,81 @@
1
+ import type { LLMClient } from "@agenticforge/core";
2
+ import type { IAgentSkill, SkillContext, SkillResult } from "./types";
3
+ export interface SkillFrontmatter {
4
+ name: string;
5
+ description: string;
6
+ triggerHint?: string;
7
+ visible?: boolean;
8
+ /** Any extra frontmatter fields are preserved here */
9
+ [key: string]: unknown;
10
+ }
11
+ /**
12
+ * Parse YAML-like frontmatter from a markdown string.
13
+ * Supports only simple key: value pairs (no nesting, no arrays).
14
+ * Delimited by `---` at the top of the file.
15
+ */
16
+ export declare function parseFrontmatter(source: string): {
17
+ frontmatter: SkillFrontmatter;
18
+ body: string;
19
+ };
20
+ /**
21
+ * A Skill defined entirely in a Markdown file.
22
+ *
23
+ * The markdown body is injected as the system prompt when the Skill executes,
24
+ * so the LLM "becomes" whatever persona/rules the markdown describes.
25
+ *
26
+ * File format:
27
+ * ```markdown
28
+ * ---
29
+ * name: weather-assistant
30
+ * description: Get real-time weather for any city
31
+ * triggerHint: 当用户询问天气、温度、降雨、风速时
32
+ * ---
33
+ *
34
+ * # Weather Assistant
35
+ *
36
+ * ## Role
37
+ * You are a concise weather assistant. Answer only weather-related questions.
38
+ *
39
+ * ## Rules
40
+ * - Always state the city and date in your answer.
41
+ * - If weather data is unavailable, say so clearly.
42
+ * - Do NOT answer non-weather questions.
43
+ * ```
44
+ *
45
+ * Usage:
46
+ * ```ts
47
+ * const skill = MarkdownSkill.fromSource(markdownText);
48
+ * // or
49
+ * const skill = await MarkdownSkill.fromFile("/path/to/skill.md");
50
+ * ```
51
+ */
52
+ export declare class MarkdownSkill implements IAgentSkill {
53
+ readonly name: string;
54
+ readonly description: string;
55
+ readonly triggerHint?: string;
56
+ readonly visible: boolean;
57
+ readonly tools: never[];
58
+ /** The full markdown body used as the system prompt */
59
+ readonly systemPrompt: string;
60
+ /** Raw parsed frontmatter (for inspection) */
61
+ readonly frontmatter: SkillFrontmatter;
62
+ /** Original source file path (if loaded from disk) */
63
+ readonly filePath?: string;
64
+ private constructor();
65
+ /**
66
+ * Create a MarkdownSkill from a raw markdown string.
67
+ */
68
+ static fromSource(source: string, filePath?: string): MarkdownSkill;
69
+ /**
70
+ * Load a MarkdownSkill from a file path.
71
+ * Uses Node.js `fs/promises` — only available in Node environments.
72
+ */
73
+ static fromFile(filePath: string): Promise<MarkdownSkill>;
74
+ /**
75
+ * Execute the skill: inject the markdown body as system prompt,
76
+ * prepend conversation history, then call the LLM.
77
+ */
78
+ execute(context: SkillContext, llm: LLMClient): Promise<SkillResult>;
79
+ describe(): string;
80
+ }
81
+ //# sourceMappingURL=MarkdownSkill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownSkill.d.ts","sourceRoot":"","sources":["../../../../src/MarkdownSkill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAMpE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sDAAsD;IACtD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IAChD,WAAW,EAAE,gBAAgB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd,CA0CA;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,aAAc,YAAW,WAAW;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAS,KAAK,EAAE,CAAC;IAE/B,uDAAuD;IACvD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,8CAA8C;IAC9C,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IAEvC,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B,OAAO;IAkBP;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,aAAa;IAKnE;;;OAGG;WACU,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAU/D;;;OAGG;IACG,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAe1E,QAAQ,IAAI,MAAM;CAKnB"}
@@ -0,0 +1,69 @@
1
+ import { MarkdownSkill } from "./MarkdownSkill";
2
+ import type { IAgentSkill } from "./types";
3
+ import { SkillRegistry } from "./SkillRegistry";
4
+ /**
5
+ * Scans a directory (or list of paths) for `SKILL.md` / `*.skill.md` files
6
+ * and loads them as `MarkdownSkill` instances.
7
+ *
8
+ * Convention (mirrors Cursor / Claude skills layout):
9
+ * ```
10
+ * skills/
11
+ * weather/
12
+ * SKILL.md ← loaded
13
+ * stock-query/
14
+ * SKILL.md ← loaded
15
+ * examples.md ← ignored
16
+ * my-tool.skill.md ← loaded (flat layout)
17
+ * ```
18
+ *
19
+ * Example:
20
+ * ```ts
21
+ * // Load all skills from a directory
22
+ * const skills = await SkillLoader.fromDirectory(".cursor/skills");
23
+ *
24
+ * // Or load from explicit file paths
25
+ * const skills = await SkillLoader.fromFiles([
26
+ * "./skills/weather/SKILL.md",
27
+ * "./skills/stock/SKILL.md",
28
+ * ]);
29
+ *
30
+ * // Populate a SkillRegistry
31
+ * const registry = SkillLoader.toRegistry(skills);
32
+ * ```
33
+ */
34
+ export declare class SkillLoader {
35
+ /**
36
+ * Load all skills from a directory tree.
37
+ * Matches files named `SKILL.md` or ending with `.skill.md`.
38
+ *
39
+ * @param dir Absolute or relative path to the skills directory.
40
+ * @param options `recursive` (default true) — whether to walk subdirectories.
41
+ */
42
+ static fromDirectory(dir: string, options?: {
43
+ recursive?: boolean;
44
+ }): Promise<MarkdownSkill[]>;
45
+ /**
46
+ * Load skills from an explicit list of file paths.
47
+ */
48
+ static fromFiles(filePaths: string[]): Promise<MarkdownSkill[]>;
49
+ /**
50
+ * Load skills from raw markdown source strings.
51
+ * Useful for testing or browser environments where `fs` is unavailable.
52
+ */
53
+ static fromSources(sources: Array<{
54
+ source: string;
55
+ filePath?: string;
56
+ }>): MarkdownSkill[];
57
+ /**
58
+ * Create a SkillRegistry populated with the given skills.
59
+ * If `existingRegistry` is provided, skills are added to it.
60
+ */
61
+ static toRegistry(skills: IAgentSkill[], existingRegistry?: SkillRegistry): SkillRegistry;
62
+ /**
63
+ * Convenience: load all skills from a directory AND return a ready registry.
64
+ */
65
+ static registryFromDirectory(dir: string, options?: {
66
+ recursive?: boolean;
67
+ }): Promise<SkillRegistry>;
68
+ }
69
+ //# sourceMappingURL=SkillLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SkillLoader.d.ts","sourceRoot":"","sources":["../../../../src/SkillLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAM9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,WAAW;IACtB;;;;;;OAMG;WACU,aAAa,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAM,GAClC,OAAO,CAAC,aAAa,EAAE,CAAC;IAwC3B;;OAEG;WACU,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAerE;;;OAGG;IACH,MAAM,CAAC,WAAW,CAChB,OAAO,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC,GAClD,aAAa,EAAE;IAMlB;;;OAGG;IACH,MAAM,CAAC,UAAU,CACf,MAAM,EAAE,WAAW,EAAE,EACrB,gBAAgB,CAAC,EAAE,aAAa,GAC/B,aAAa;IAQhB;;OAEG;WACU,qBAAqB,CAChC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAC,GAC9B,OAAO,CAAC,aAAa,CAAC;CAI1B"}
@@ -0,0 +1,32 @@
1
+ import type { IAgentSkill } from "./types";
2
+ /**
3
+ * Manages a collection of AgentSkills.
4
+ *
5
+ * ```ts
6
+ * const registry = new SkillRegistry();
7
+ * registry.register(weatherSkill);
8
+ * registry.register(stockSkill);
9
+ *
10
+ * registry.get("weather"); // => AgentSkill
11
+ * registry.list(); // => ["weather", "stock"]
12
+ * registry.describeAll(); // markdown bullet list for LLM prompt
13
+ * ```
14
+ */
15
+ export declare class SkillRegistry {
16
+ private readonly skills;
17
+ register(skill: IAgentSkill): void;
18
+ unregister(name: string): boolean;
19
+ get(name: string): IAgentSkill | undefined;
20
+ has(name: string): boolean;
21
+ list(): string[];
22
+ all(): IAgentSkill[];
23
+ /** Return only Skills that are visible for LLM routing */
24
+ visible(): IAgentSkill[];
25
+ size(): number;
26
+ /**
27
+ * Produce a markdown bullet list of all visible Skills.
28
+ * Used by SkillAgent to build the routing system prompt.
29
+ */
30
+ describeAll(): string;
31
+ }
32
+ //# sourceMappingURL=SkillRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SkillRegistry.d.ts","sourceRoot":"","sources":["../../../../src/SkillRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAGzC;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkC;IAEzD,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAIlC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI1C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,IAAI,IAAI,MAAM,EAAE;IAIhB,GAAG,IAAI,WAAW,EAAE;IAIpB,0DAA0D;IAC1D,OAAO,IAAI,WAAW,EAAE;IAIxB,IAAI,IAAI,MAAM;IAId;;;OAGG;IACH,WAAW,IAAI,MAAM;CAatB"}
@@ -0,0 +1,73 @@
1
+ import type { LLMClient } from "@agenticforge/core";
2
+ import type { IAgentSkill, SkillResult } from "./types";
3
+ import { SkillRegistry } from "./SkillRegistry";
4
+ /**
5
+ * A lightweight, framework-independent Skill runner.
6
+ *
7
+ * Unlike the `SkillAgent` in `@agenticforge/agents` (which extends `Agent`),
8
+ * this class is a standalone orchestrator that does NOT depend on the agents
9
+ * package — making it usable in any context.
10
+ *
11
+ * Architecture:
12
+ * ```
13
+ * User query
14
+ * │
15
+ * ▼
16
+ * SkillRunner.run()
17
+ * │
18
+ * ├─ skillName provided ──► execute named Skill directly
19
+ * ├─ 1 Skill registered ──► execute that Skill directly
20
+ * └─ N Skills ──► LLM routing → execute matched Skill
21
+ * ```
22
+ *
23
+ * Example:
24
+ * ```ts
25
+ * import { SkillRunner, AgentSkill } from "@agenticforge/skills";
26
+ *
27
+ * const runner = new SkillRunner({
28
+ * llm: myLLMClient,
29
+ * skills: [weatherSkill, stockSkill],
30
+ * });
31
+ *
32
+ * const result = await runner.run("东京今天下雨吗?");
33
+ * console.log(result.output);
34
+ * ```
35
+ */
36
+ export declare class SkillRunner {
37
+ readonly skillRegistry: SkillRegistry;
38
+ private readonly llm;
39
+ private readonly fallbackPrompt;
40
+ private readonly routerPromptTemplate;
41
+ constructor(params: {
42
+ llm: LLMClient;
43
+ skills?: IAgentSkill[];
44
+ fallbackPrompt?: string;
45
+ routerPromptTemplate?: string;
46
+ });
47
+ addSkill(skill: IAgentSkill): void;
48
+ removeSkill(name: string): boolean;
49
+ listSkills(): string[];
50
+ private routeToSkill;
51
+ /**
52
+ * Run: auto-route to the best Skill and execute it.
53
+ */
54
+ run(query: string, options?: {
55
+ skillName?: string;
56
+ metadata?: Record<string, unknown>;
57
+ history?: Array<{
58
+ role: "user" | "assistant" | "system";
59
+ content: string;
60
+ }>;
61
+ }): Promise<SkillResult>;
62
+ /**
63
+ * Directly invoke a named Skill and return the full SkillResult.
64
+ */
65
+ runSkill(skillName: string, query: string, options?: {
66
+ metadata?: Record<string, unknown>;
67
+ history?: Array<{
68
+ role: "user" | "assistant" | "system";
69
+ content: string;
70
+ }>;
71
+ }): Promise<SkillResult>;
72
+ }
73
+ //# sourceMappingURL=SkillRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SkillRunner.d.ts","sourceRoot":"","sources":["../../../../src/SkillRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAS,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAC,WAAW,EAAgB,WAAW,EAAC,MAAM,SAAS,CAAC;AACpE,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAM9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,WAAW;IACtB,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;gBAElC,MAAM,EAAE;QAClB,GAAG,EAAE,SAAS,CAAC;QACf,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC/B;IA4BD,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAIlC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC,UAAU,IAAI,MAAM,EAAE;YAQR,YAAY;IAsB1B;;OAEG;IACG,GAAG,CACP,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,OAAO,CAAC,EAAE,KAAK,CAAC;YAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAC,CAAC,CAAC;KAC3E,GACA,OAAO,CAAC,WAAW,CAAC;IAgCvB;;OAEG;IACG,QAAQ,CACZ,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,OAAO,CAAC,EAAE,KAAK,CAAC;YAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAC,CAAC,CAAC;KAC3E,GACA,OAAO,CAAC,WAAW,CAAC;CAGxB"}
@@ -0,0 +1,7 @@
1
+ export * from "./types";
2
+ export * from "./AgentSkill";
3
+ export * from "./SkillRegistry";
4
+ export * from "./SkillRunner";
5
+ export * from "./MarkdownSkill";
6
+ export * from "./SkillLoader";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { LLMClient } from "@agenticforge/core";
2
+ import type { Tool, FunctionTool } from "@agenticforge/tools";
3
+ export interface SkillContext {
4
+ /** 当前用户输入 */
5
+ query: string;
6
+ /** 调用方传入的任意元数据(权限、用户身份、会话 ID 等) */
7
+ metadata?: Record<string, unknown>;
8
+ /** 可选:对话历史(转发给 Skill 内部 LLM 调用) */
9
+ history?: Array<{
10
+ role: "user" | "assistant" | "system";
11
+ content: string;
12
+ }>;
13
+ }
14
+ export interface SkillResult {
15
+ /** Skill 最终产出的文本 */
16
+ output: string;
17
+ /** 执行过程中调用的工具名列表(可选,用于可观测性) */
18
+ toolsUsed?: string[];
19
+ /** Skill 自定义的附加数据 */
20
+ data?: Record<string, unknown>;
21
+ }
22
+ export interface SkillDefinition {
23
+ /**
24
+ * Skill 唯一标识名,用于注册与路由。
25
+ * 建议使用 kebab-case,例如 "stock-query"、"email-composer"。
26
+ */
27
+ name: string;
28
+ /**
29
+ * 一句话描述该 Skill 能做什么。
30
+ * SkillAgent 会把所有 Skill 的描述展示给 LLM,
31
+ * 让它选择最合适的 Skill。
32
+ */
33
+ description: string;
34
+ /**
35
+ * 触发条件(可选)。
36
+ * 描述什么样的用户输入应该触发这个 Skill。
37
+ * 例如:"当用户询问股票价格、K线图或市值时"
38
+ */
39
+ triggerHint?: string;
40
+ /**
41
+ * 该 Skill 专属的 System Prompt(可选)。
42
+ */
43
+ systemPrompt?: string;
44
+ /**
45
+ * 该 Skill 可用的工具(可选)。
46
+ * 只有这些工具会在该 Skill 的执行上下文中出现。
47
+ */
48
+ tools?: Array<Tool | FunctionTool<Record<string, unknown>>>;
49
+ /**
50
+ * 是否在 SkillAgent 路由时对外可见(默认 true)。
51
+ * 设为 false 则只能通过 runSkill(name) 直接调用。
52
+ */
53
+ visible?: boolean;
54
+ }
55
+ export interface IAgentSkill extends SkillDefinition {
56
+ /**
57
+ * 执行该 Skill。
58
+ * @param context 包含 query、history、metadata 的调用上下文
59
+ * @param llm 由 SkillAgent 注入的 LLM 客户端
60
+ * @returns SkillResult
61
+ */
62
+ execute(context: SkillContext, llm: LLMClient): Promise<SkillResult>;
63
+ }
64
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAC,IAAI,EAAE,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAM5D,MAAM,WAAW,YAAY;IAC3B,aAAa;IACb,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,mCAAmC;IACnC,OAAO,CAAC,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;CAC3E;AAMD,MAAM,WAAW,WAAW;IAC1B,oBAAoB;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,qBAAqB;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAMD,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE5D;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD;;;;;OAKG;IACH,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACtE"}
@@ -0,0 +1,30 @@
1
+ import { ToolRegistry } from "./ToolRegistry";
2
+ export interface ToolCallRequest {
3
+ id: string;
4
+ toolName: string;
5
+ parameters: Record<string, unknown>;
6
+ }
7
+ export interface ToolCallResult {
8
+ id: string;
9
+ toolName: string;
10
+ output: string;
11
+ error?: string;
12
+ durationMs: number;
13
+ }
14
+ /**
15
+ * Executes multiple tool calls concurrently and collects results.
16
+ */
17
+ export declare class AsyncToolExecutor {
18
+ private readonly registry;
19
+ private readonly concurrency;
20
+ constructor(registry: ToolRegistry, concurrency?: number);
21
+ /**
22
+ * Execute a batch of tool calls with bounded concurrency.
23
+ */
24
+ executeBatch(requests: ToolCallRequest[]): Promise<ToolCallResult[]>;
25
+ /**
26
+ * Execute a single tool call.
27
+ */
28
+ executeSingle(request: ToolCallRequest): Promise<ToolCallResult>;
29
+ }
30
+ //# sourceMappingURL=AsyncToolExecutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsyncToolExecutor.d.ts","sourceRoot":"","sources":["../../../../../tools/src/AsyncToolExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,QAAQ,EAAE,YAAY,EAAE,WAAW,SAAI;IAKnD;;OAEG;IACG,YAAY,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAgB1E;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;CAoBvE"}
@@ -0,0 +1,74 @@
1
+ import "reflect-metadata";
2
+ import { z, type ZodType } from "zod";
3
+ import type { ToolParameter } from "./types";
4
+ export type { ToolParameter };
5
+ export interface OpenAIFunctionSchema {
6
+ type: "function";
7
+ function: {
8
+ name: string;
9
+ description: string;
10
+ parameters: Record<string, unknown>;
11
+ };
12
+ }
13
+ export interface ToolActionMeta {
14
+ key: string;
15
+ description: string;
16
+ method: string;
17
+ }
18
+ /**
19
+ * Decorator that registers a method as a named tool action.
20
+ * Usage: @toolAction("action_key", "Description")
21
+ */
22
+ export declare function toolAction(key: string, description: string): (target: object, propertyKey: string, _descriptor: PropertyDescriptor) => void;
23
+ export declare abstract class Tool {
24
+ readonly name: string;
25
+ readonly description: string;
26
+ readonly expandable: boolean;
27
+ constructor(name: string, description: string, expandable?: boolean);
28
+ abstract run(parameters: Record<string, unknown>): Promise<string> | string;
29
+ abstract getParameters(): ToolParameter[];
30
+ /**
31
+ * Validate that required parameters are present and have basic types.
32
+ * Returns true if valid.
33
+ */
34
+ validateParameters(parameters: Record<string, unknown>): boolean;
35
+ /**
36
+ * Validate and coerce parameters, returning a Result object.
37
+ */
38
+ validateAndNormalizeParameters(parameters: Record<string, unknown>): {
39
+ success: true;
40
+ data: Record<string, unknown>;
41
+ } | {
42
+ success: false;
43
+ error: string;
44
+ };
45
+ /**
46
+ * Convert this Tool to an OpenAI function-calling schema.
47
+ */
48
+ toOpenAISchema(): OpenAIFunctionSchema;
49
+ /**
50
+ * Return a formatted description of all available tool actions (for system prompt).
51
+ */
52
+ describe(): string;
53
+ }
54
+ export interface FunctionTool<TArgs = Record<string, unknown>> {
55
+ name: string;
56
+ description: string;
57
+ func: (args: TArgs) => string | Promise<string>;
58
+ schema?: ZodType<TArgs>;
59
+ }
60
+ /**
61
+ * Convenience factory for creating type-safe function tools.
62
+ *
63
+ * ```ts
64
+ * const myTool = defineFunctionTool({
65
+ * name: "myTool",
66
+ * description: "...",
67
+ * schema: z.object({ input: z.string() }),
68
+ * func: ({ input }) => input.toUpperCase(),
69
+ * });
70
+ * ```
71
+ */
72
+ export declare function defineFunctionTool<TArgs extends Record<string, unknown>>(options: FunctionTool<TArgs>): FunctionTool<TArgs>;
73
+ export { z };
74
+ //# sourceMappingURL=Tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tool.d.ts","sourceRoot":"","sources":["../../../../../tools/src/Tool.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAC,CAAC,EAAE,KAAK,OAAO,EAAC,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAE3C,YAAY,EAAC,aAAa,EAAC,CAAC;AAM5B,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC;CACH;AAQD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,IAEvD,QAAQ,MAAM,EACd,aAAa,MAAM,EACnB,aAAa,kBAAkB,KAC9B,IAAI,CAMR;AAMD,8BAAsB,IAAI;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;gBAEjB,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,UAAQ;IAMjE,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM;IAC3E,QAAQ,CAAC,aAAa,IAAI,aAAa,EAAE;IAEzC;;;OAGG;IACH,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO;IAUhE;;OAEG;IACH,8BAA8B,CAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC;QAAC,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAC,GAAG;QAAC,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC;IAwBnF;;OAEG;IACH,cAAc,IAAI,oBAAoB;IA8BtC;;OAEG;IACH,QAAQ,IAAI,MAAM;CAUnB;AAcD,MAAM,WAAW,YAAY,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtE,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,GAC3B,YAAY,CAAC,KAAK,CAAC,CAErB;AAED,OAAO,EAAC,CAAC,EAAC,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { ToolRegistry } from "./ToolRegistry";
2
+ export interface ToolChainStep {
3
+ /** Name of the tool/function to call */
4
+ toolName: string;
5
+ /** Input template string; use {variableName} to reference context variables */
6
+ inputTemplate: string;
7
+ /** Key under which the step output is stored in context */
8
+ outputKey: string;
9
+ }
10
+ /**
11
+ * A sequential chain of tool steps.
12
+ * Each step can reference outputs of prior steps via `{key}` placeholders.
13
+ *
14
+ * ```ts
15
+ * const chain = new ToolChain("my_chain", "Does X then Y");
16
+ * chain.addStep("search", "{input}", "search_result");
17
+ * chain.addStep("summarize", "{search_result}", "summary");
18
+ * ```
19
+ */
20
+ export declare class ToolChain {
21
+ readonly name: string;
22
+ readonly description: string;
23
+ private readonly steps;
24
+ constructor(name: string, description: string);
25
+ addStep(toolName: string, inputTemplate: string, outputKey: string): this;
26
+ getSteps(): ToolChainStep[];
27
+ /**
28
+ * Execute the chain against a registry.
29
+ * @param registry ToolRegistry that holds the referenced tools.
30
+ * @param input Initial `{input}` value.
31
+ * @returns The value stored under the last step's outputKey.
32
+ */
33
+ execute(registry: ToolRegistry, input: string): Promise<string>;
34
+ }
35
+ /**
36
+ * Manages multiple named ToolChains and executes them against a shared registry.
37
+ */
38
+ export declare class ToolChainManager {
39
+ private readonly chains;
40
+ private readonly registry;
41
+ constructor(registry: ToolRegistry);
42
+ registerChain(chain: ToolChain): void;
43
+ getChain(name: string): ToolChain | undefined;
44
+ listChains(): string[];
45
+ executeChain(chainName: string, input: string): Promise<string>;
46
+ }
47
+ //# sourceMappingURL=ToolChain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolChain.d.ts","sourceRoot":"","sources":["../../../../../tools/src/ToolChain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAM5C,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,aAAa,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;;;;;GASG;AACH,qBAAa,SAAS;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;gBAEjC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAK7C,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAKzE,QAAQ,IAAI,aAAa,EAAE;IAI3B;;;;;OAKG;IACG,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAatE;AAMD;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;gBAE5B,QAAQ,EAAE,YAAY;IAIlC,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAIrC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI7C,UAAU,IAAI,MAAM,EAAE;IAIhB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAKtE"}
@@ -0,0 +1,22 @@
1
+ import { Tool, type FunctionTool, type OpenAIFunctionSchema } from "./Tool";
2
+ /**
3
+ * Central registry that manages Tool instances and raw FunctionTools.
4
+ * Supports registration, lookup, and execution.
5
+ */
6
+ export declare class ToolRegistry {
7
+ private readonly tools;
8
+ private readonly functions;
9
+ registerTool(tool: Tool): void;
10
+ unregisterTool(name: string): boolean;
11
+ registerFunction<TArgs extends Record<string, unknown>>(name: string, description: string, func: (args: TArgs) => string | Promise<string>, schema?: FunctionTool<TArgs>["schema"]): void;
12
+ unregisterFunction(name: string): boolean;
13
+ getTool(name: string): Tool | undefined;
14
+ getFunction(name: string): FunctionTool<Record<string, unknown>> | undefined;
15
+ getAllTools(): Tool[];
16
+ listTools(): string[];
17
+ hasTool(name: string): boolean;
18
+ execute(name: string, parameters: Record<string, unknown>): Promise<string>;
19
+ getAvailableTools(): string;
20
+ getOpenAISchemas(): Array<OpenAIFunctionSchema | Record<string, unknown>>;
21
+ }
22
+ //# sourceMappingURL=ToolRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolRegistry.d.ts","sourceRoot":"","sources":["../../../../../tools/src/ToolRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,KAAK,YAAY,EAAE,KAAK,oBAAoB,EAAC,MAAM,QAAQ,CAAC;AAE1E;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;IACjD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4D;IAMtF,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAI9B,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIrC,gBAAgB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpD,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,EAC/C,MAAM,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,GACrC,IAAI;IASP,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQzC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAIvC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS;IAI5E,WAAW,IAAI,IAAI,EAAE;IAIrB,SAAS,IAAI,MAAM,EAAE;IAOrB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQxB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBjF,iBAAiB,IAAI,MAAM;IAe3B,gBAAgB,IAAI,KAAK,CAAC,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAyB1E"}
@@ -0,0 +1,6 @@
1
+ export * from "./Tool";
2
+ export * from "./ToolChain";
3
+ export * from "./ToolRegistry";
4
+ export * from "./AsyncToolExecutor";
5
+ export * from "./types";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../tools/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface ToolParameter {
2
+ name: string;
3
+ type: string;
4
+ description: string;
5
+ required: boolean;
6
+ default: unknown;
7
+ }
8
+ export interface ToolResult {
9
+ success: boolean;
10
+ output: string;
11
+ error?: string;
12
+ }
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../tools/src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@agenticforge/skills",
3
+ "version": "1.1.0",
4
+ "description": "Agent Skills system for AgenticFORGE — composable, routable agent capability units",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./dist/cjs/index.cjs",
8
+ "module": "./dist/esm/index.js",
9
+ "types": "./dist/types/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/types/index.d.ts",
13
+ "import": "./dist/esm/index.js",
14
+ "require": "./dist/cjs/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "clean": "rimraf dist",
22
+ "typecheck": "tsc -p tsconfig.json --noEmit",
23
+ "build:types": "tsc -p tsconfig.build.json",
24
+ "build:js": "rollup -c",
25
+ "build": "pnpm run clean && pnpm run typecheck && pnpm run build:types && pnpm run build:js"
26
+ },
27
+ "dependencies": {
28
+ "@agenticforge/core": "workspace:^",
29
+ "@agenticforge/tools": "workspace:^"
30
+ },
31
+ "devDependencies": {
32
+ "@rollup/plugin-commonjs": "^28.0.8",
33
+ "@rollup/plugin-json": "^6.1.0",
34
+ "@rollup/plugin-node-resolve": "^16.0.1",
35
+ "@rollup/plugin-terser": "^0.4.4",
36
+ "@types/node": "^25.3.3",
37
+ "rimraf": "^6.0.1",
38
+ "rollup": "^4.50.1",
39
+ "rollup-plugin-esbuild": "^6.2.1",
40
+ "tsx": "^4.21.0",
41
+ "typescript": "~5.9.3"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "https://github.com/LittleBlacky/AgenticFORGE.git",
46
+ "directory": "packages/skills"
47
+ },
48
+ "homepage": "https://github.com/LittleBlacky/AgenticFORGE/tree/main/packages/skills#readme",
49
+ "bugs": {
50
+ "url": "https://github.com/LittleBlacky/AgenticFORGE/issues"
51
+ },
52
+ "license": "CC-BY-NC-SA-4.0",
53
+ "keywords": [
54
+ "agenticforge",
55
+ "agent",
56
+ "ai",
57
+ "llm",
58
+ "typescript",
59
+ "skills",
60
+ "agent-skills",
61
+ "skill-agent",
62
+ "plugin",
63
+ "semantic-kernel"
64
+ ]
65
+ }