@codeany/open-agent-sdk 0.2.1 → 0.2.2
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/.env.example +8 -0
- package/examples/01-simple-query.ts +43 -0
- package/examples/02-multi-tool.ts +44 -0
- package/examples/03-multi-turn.ts +39 -0
- package/examples/04-prompt-api.ts +29 -0
- package/examples/05-custom-system-prompt.ts +26 -0
- package/examples/06-mcp-server.ts +49 -0
- package/examples/07-custom-tools.ts +87 -0
- package/examples/08-official-api-compat.ts +38 -0
- package/examples/09-subagents.ts +48 -0
- package/examples/10-permissions.ts +40 -0
- package/examples/11-custom-mcp-tools.ts +101 -0
- package/examples/12-skills.ts +88 -0
- package/examples/13-hooks.ts +88 -0
- package/examples/14-openai-compat.ts +71 -0
- package/examples/web/index.html +365 -0
- package/examples/web/server.ts +157 -0
- package/package.json +1 -7
- package/src/engine.ts +3 -0
- package/tsconfig.json +19 -0
- package/dist/agent.d.ts +0 -113
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js +0 -446
- package/dist/agent.js.map +0 -1
- package/dist/engine.d.ts +0 -62
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -494
- package/dist/engine.js.map +0 -1
- package/dist/hooks.d.ts +0 -111
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js +0 -179
- package/dist/hooks.js.map +0 -1
- package/dist/index.d.ts +0 -66
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -133
- package/dist/index.js.map +0 -1
- package/dist/mcp/client.d.ts +0 -19
- package/dist/mcp/client.d.ts.map +0 -1
- package/dist/mcp/client.js +0 -126
- package/dist/mcp/client.js.map +0 -1
- package/dist/providers/anthropic.d.ts +0 -17
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js +0 -47
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/index.d.ts +0 -20
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -26
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/openai.d.ts +0 -26
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js +0 -212
- package/dist/providers/openai.js.map +0 -1
- package/dist/providers/types.d.ts +0 -84
- package/dist/providers/types.d.ts.map +0 -1
- package/dist/providers/types.js +0 -11
- package/dist/providers/types.js.map +0 -1
- package/dist/sdk-mcp-server.d.ts +0 -52
- package/dist/sdk-mcp-server.d.ts.map +0 -1
- package/dist/sdk-mcp-server.js +0 -57
- package/dist/sdk-mcp-server.js.map +0 -1
- package/dist/session.d.ts +0 -73
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -159
- package/dist/session.js.map +0 -1
- package/dist/skills/bundled/commit.d.ts +0 -7
- package/dist/skills/bundled/commit.d.ts.map +0 -1
- package/dist/skills/bundled/commit.js +0 -35
- package/dist/skills/bundled/commit.js.map +0 -1
- package/dist/skills/bundled/debug.d.ts +0 -7
- package/dist/skills/bundled/debug.d.ts.map +0 -1
- package/dist/skills/bundled/debug.js +0 -46
- package/dist/skills/bundled/debug.js.map +0 -1
- package/dist/skills/bundled/index.d.ts +0 -11
- package/dist/skills/bundled/index.d.ts.map +0 -1
- package/dist/skills/bundled/index.js +0 -26
- package/dist/skills/bundled/index.js.map +0 -1
- package/dist/skills/bundled/review.d.ts +0 -7
- package/dist/skills/bundled/review.d.ts.map +0 -1
- package/dist/skills/bundled/review.js +0 -38
- package/dist/skills/bundled/review.js.map +0 -1
- package/dist/skills/bundled/simplify.d.ts +0 -8
- package/dist/skills/bundled/simplify.d.ts.map +0 -1
- package/dist/skills/bundled/simplify.js +0 -48
- package/dist/skills/bundled/simplify.js.map +0 -1
- package/dist/skills/bundled/test.d.ts +0 -7
- package/dist/skills/bundled/test.d.ts.map +0 -1
- package/dist/skills/bundled/test.js +0 -40
- package/dist/skills/bundled/test.js.map +0 -1
- package/dist/skills/index.d.ts +0 -7
- package/dist/skills/index.d.ts.map +0 -1
- package/dist/skills/index.js +0 -8
- package/dist/skills/index.js.map +0 -1
- package/dist/skills/registry.d.ts +0 -43
- package/dist/skills/registry.d.ts.map +0 -1
- package/dist/skills/registry.js +0 -111
- package/dist/skills/registry.js.map +0 -1
- package/dist/skills/types.d.ts +0 -83
- package/dist/skills/types.d.ts.map +0 -1
- package/dist/skills/types.js +0 -8
- package/dist/skills/types.js.map +0 -1
- package/dist/tool-helper.d.ts +0 -73
- package/dist/tool-helper.d.ts.map +0 -1
- package/dist/tool-helper.js +0 -86
- package/dist/tool-helper.js.map +0 -1
- package/dist/tools/agent-tool.d.ts +0 -17
- package/dist/tools/agent-tool.d.ts.map +0 -1
- package/dist/tools/agent-tool.js +0 -146
- package/dist/tools/agent-tool.js.map +0 -1
- package/dist/tools/ask-user.d.ts +0 -18
- package/dist/tools/ask-user.d.ts.map +0 -1
- package/dist/tools/ask-user.js +0 -72
- package/dist/tools/ask-user.js.map +0 -1
- package/dist/tools/bash.d.ts +0 -5
- package/dist/tools/bash.d.ts.map +0 -1
- package/dist/tools/bash.js +0 -67
- package/dist/tools/bash.js.map +0 -1
- package/dist/tools/config-tool.d.ts +0 -20
- package/dist/tools/config-tool.d.ts.map +0 -1
- package/dist/tools/config-tool.js +0 -83
- package/dist/tools/config-tool.js.map +0 -1
- package/dist/tools/cron-tools.d.ts +0 -33
- package/dist/tools/cron-tools.d.ts.map +0 -1
- package/dist/tools/cron-tools.js +0 -128
- package/dist/tools/cron-tools.js.map +0 -1
- package/dist/tools/edit.d.ts +0 -5
- package/dist/tools/edit.d.ts.map +0 -1
- package/dist/tools/edit.js +0 -70
- package/dist/tools/edit.js.map +0 -1
- package/dist/tools/glob.d.ts +0 -5
- package/dist/tools/glob.d.ts.map +0 -1
- package/dist/tools/glob.js +0 -75
- package/dist/tools/glob.js.map +0 -1
- package/dist/tools/grep.d.ts +0 -5
- package/dist/tools/grep.d.ts.map +0 -1
- package/dist/tools/grep.js +0 -168
- package/dist/tools/grep.js.map +0 -1
- package/dist/tools/index.d.ts +0 -45
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -162
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/lsp-tool.d.ts +0 -9
- package/dist/tools/lsp-tool.d.ts.map +0 -1
- package/dist/tools/lsp-tool.js +0 -137
- package/dist/tools/lsp-tool.js.map +0 -1
- package/dist/tools/mcp-resource-tools.d.ts +0 -14
- package/dist/tools/mcp-resource-tools.d.ts.map +0 -1
- package/dist/tools/mcp-resource-tools.js +0 -117
- package/dist/tools/mcp-resource-tools.js.map +0 -1
- package/dist/tools/notebook-edit.d.ts +0 -5
- package/dist/tools/notebook-edit.d.ts.map +0 -1
- package/dist/tools/notebook-edit.js +0 -85
- package/dist/tools/notebook-edit.js.map +0 -1
- package/dist/tools/plan-tools.d.ts +0 -12
- package/dist/tools/plan-tools.d.ts.map +0 -1
- package/dist/tools/plan-tools.js +0 -77
- package/dist/tools/plan-tools.js.map +0 -1
- package/dist/tools/read.d.ts +0 -5
- package/dist/tools/read.d.ts.map +0 -1
- package/dist/tools/read.js +0 -66
- package/dist/tools/read.js.map +0 -1
- package/dist/tools/send-message.d.ts +0 -31
- package/dist/tools/send-message.d.ts.map +0 -1
- package/dist/tools/send-message.js +0 -77
- package/dist/tools/send-message.js.map +0 -1
- package/dist/tools/skill-tool.d.ts +0 -9
- package/dist/tools/skill-tool.d.ts.map +0 -1
- package/dist/tools/skill-tool.js +0 -115
- package/dist/tools/skill-tool.js.map +0 -1
- package/dist/tools/task-tools.d.ts +0 -48
- package/dist/tools/task-tools.d.ts.map +0 -1
- package/dist/tools/task-tools.js +0 -242
- package/dist/tools/task-tools.js.map +0 -1
- package/dist/tools/team-tools.d.ts +0 -34
- package/dist/tools/team-tools.d.ts.map +0 -1
- package/dist/tools/team-tools.js +0 -103
- package/dist/tools/team-tools.js.map +0 -1
- package/dist/tools/todo-tool.d.ts +0 -22
- package/dist/tools/todo-tool.d.ts.map +0 -1
- package/dist/tools/todo-tool.js +0 -93
- package/dist/tools/todo-tool.js.map +0 -1
- package/dist/tools/tool-search.d.ts +0 -13
- package/dist/tools/tool-search.d.ts.map +0 -1
- package/dist/tools/tool-search.js +0 -76
- package/dist/tools/tool-search.js.map +0 -1
- package/dist/tools/types.d.ts +0 -29
- package/dist/tools/types.d.ts.map +0 -1
- package/dist/tools/types.js +0 -52
- package/dist/tools/types.js.map +0 -1
- package/dist/tools/web-fetch.d.ts +0 -5
- package/dist/tools/web-fetch.d.ts.map +0 -1
- package/dist/tools/web-fetch.js +0 -60
- package/dist/tools/web-fetch.js.map +0 -1
- package/dist/tools/web-search.d.ts +0 -5
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js +0 -77
- package/dist/tools/web-search.js.map +0 -1
- package/dist/tools/worktree-tools.d.ts +0 -10
- package/dist/tools/worktree-tools.d.ts.map +0 -1
- package/dist/tools/worktree-tools.js +0 -130
- package/dist/tools/worktree-tools.js.map +0 -1
- package/dist/tools/write.d.ts +0 -5
- package/dist/tools/write.d.ts.map +0 -1
- package/dist/tools/write.js +0 -40
- package/dist/tools/write.js.map +0 -1
- package/dist/types.d.ts +0 -423
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/dist/utils/compact.d.ts +0 -44
- package/dist/utils/compact.d.ts.map +0 -1
- package/dist/utils/compact.js +0 -162
- package/dist/utils/compact.js.map +0 -1
- package/dist/utils/context.d.ts +0 -35
- package/dist/utils/context.d.ts.map +0 -1
- package/dist/utils/context.js +0 -174
- package/dist/utils/context.js.map +0 -1
- package/dist/utils/fileCache.d.ts +0 -64
- package/dist/utils/fileCache.d.ts.map +0 -1
- package/dist/utils/fileCache.js +0 -117
- package/dist/utils/fileCache.js.map +0 -1
- package/dist/utils/messages.d.ts +0 -57
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js +0 -152
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/retry.d.ts +0 -48
- package/dist/utils/retry.d.ts.map +0 -1
- package/dist/utils/retry.js +0 -111
- package/dist/utils/retry.js.map +0 -1
- package/dist/utils/tokens.d.ts +0 -57
- package/dist/utils/tokens.d.ts.map +0 -1
- package/dist/utils/tokens.js +0 -134
- package/dist/utils/tokens.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../src/skills/bundled/test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuBH,wBAAgB,iBAAiB,IAAI,IAAI,CAexC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bundled Skill: test
|
|
3
|
-
*
|
|
4
|
-
* Run tests and analyze failures.
|
|
5
|
-
*/
|
|
6
|
-
import { registerSkill } from '../registry.js';
|
|
7
|
-
const TEST_PROMPT = `Run the project's test suite and analyze the results:
|
|
8
|
-
|
|
9
|
-
1. **Discover**: Find the test runner configuration
|
|
10
|
-
- Look for package.json scripts, jest.config, vitest.config, pytest.ini, etc.
|
|
11
|
-
- Identify the appropriate test command
|
|
12
|
-
|
|
13
|
-
2. **Execute**: Run the tests
|
|
14
|
-
- Run the full test suite or specific tests if specified
|
|
15
|
-
- Capture output including failures and errors
|
|
16
|
-
|
|
17
|
-
3. **Analyze**: If tests fail:
|
|
18
|
-
- Read the failing test to understand what it expects
|
|
19
|
-
- Read the source code being tested
|
|
20
|
-
- Identify why the test is failing
|
|
21
|
-
- Fix the issue (in tests or source as appropriate)
|
|
22
|
-
|
|
23
|
-
4. **Re-verify**: Run the failing tests again to confirm the fix`;
|
|
24
|
-
export function registerTestSkill() {
|
|
25
|
-
registerSkill({
|
|
26
|
-
name: 'test',
|
|
27
|
-
description: 'Run tests and analyze failures, fixing any issues found.',
|
|
28
|
-
aliases: ['run-tests'],
|
|
29
|
-
allowedTools: ['Bash', 'Read', 'Write', 'Edit', 'Glob', 'Grep'],
|
|
30
|
-
userInvocable: true,
|
|
31
|
-
async getPrompt(args) {
|
|
32
|
-
let prompt = TEST_PROMPT;
|
|
33
|
-
if (args.trim()) {
|
|
34
|
-
prompt += `\n\nSpecific test target: ${args}`;
|
|
35
|
-
}
|
|
36
|
-
return [{ type: 'text', text: prompt }];
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../src/skills/bundled/test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAG9C,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;iEAgB6C,CAAA;AAEjE,MAAM,UAAU,iBAAiB;IAC/B,aAAa,CAAC;QACZ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,0DAA0D;QACvE,OAAO,EAAE,CAAC,WAAW,CAAC;QACtB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAC/D,aAAa,EAAE,IAAI;QACnB,KAAK,CAAC,SAAS,CAAC,IAAI;YAClB,IAAI,MAAM,GAAG,WAAW,CAAA;YACxB,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;gBAChB,MAAM,IAAI,6BAA6B,IAAI,EAAE,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;QACzC,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/skills/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skills Module - Public API
|
|
3
|
-
*/
|
|
4
|
-
export type { SkillDefinition, SkillContentBlock, SkillResult, } from './types.js';
|
|
5
|
-
export { registerSkill, getSkill, getAllSkills, getUserInvocableSkills, hasSkill, unregisterSkill, clearSkills, formatSkillsForPrompt, } from './registry.js';
|
|
6
|
-
export { initBundledSkills } from './bundled/index.js';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,WAAW,GACZ,MAAM,YAAY,CAAA;AAGnB,OAAO,EACL,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,sBAAsB,EACtB,QAAQ,EACR,eAAe,EACf,WAAW,EACX,qBAAqB,GACtB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/skills/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skills Module - Public API
|
|
3
|
-
*/
|
|
4
|
-
// Registry
|
|
5
|
-
export { registerSkill, getSkill, getAllSkills, getUserInvocableSkills, hasSkill, unregisterSkill, clearSkills, formatSkillsForPrompt, } from './registry.js';
|
|
6
|
-
// Bundled skills
|
|
7
|
-
export { initBundledSkills } from './bundled/index.js';
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/dist/skills/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,WAAW;AACX,OAAO,EACL,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,sBAAsB,EACtB,QAAQ,EACR,eAAe,EACf,WAAW,EACX,qBAAqB,GACtB,MAAM,eAAe,CAAA;AAEtB,iBAAiB;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill Registry
|
|
3
|
-
*
|
|
4
|
-
* Central registry for managing skill definitions.
|
|
5
|
-
* Skills can be registered programmatically or loaded from bundled definitions.
|
|
6
|
-
*/
|
|
7
|
-
import type { SkillDefinition } from './types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Register a skill definition.
|
|
10
|
-
*/
|
|
11
|
-
export declare function registerSkill(definition: SkillDefinition): void;
|
|
12
|
-
/**
|
|
13
|
-
* Get a skill by name or alias.
|
|
14
|
-
*/
|
|
15
|
-
export declare function getSkill(name: string): SkillDefinition | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Get all registered skills.
|
|
18
|
-
*/
|
|
19
|
-
export declare function getAllSkills(): SkillDefinition[];
|
|
20
|
-
/**
|
|
21
|
-
* Get all user-invocable skills (for /command listing).
|
|
22
|
-
*/
|
|
23
|
-
export declare function getUserInvocableSkills(): SkillDefinition[];
|
|
24
|
-
/**
|
|
25
|
-
* Check if a skill exists.
|
|
26
|
-
*/
|
|
27
|
-
export declare function hasSkill(name: string): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Remove a skill.
|
|
30
|
-
*/
|
|
31
|
-
export declare function unregisterSkill(name: string): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Clear all skills (for testing).
|
|
34
|
-
*/
|
|
35
|
-
export declare function clearSkills(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Format skills listing for system prompt injection.
|
|
38
|
-
*
|
|
39
|
-
* Uses a budget system: skills listing gets a limited character budget
|
|
40
|
-
* to avoid bloating the context window.
|
|
41
|
-
*/
|
|
42
|
-
export declare function formatSkillsForPrompt(contextWindowTokens?: number): string;
|
|
43
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/skills/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAQjD;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAS/D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAUlE;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,eAAe,EAAE,CAEhD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,eAAe,EAAE,CAI1D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAYrD;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,mBAAmB,CAAC,EAAE,MAAM,GAC3B,MAAM,CAgCR"}
|
package/dist/skills/registry.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill Registry
|
|
3
|
-
*
|
|
4
|
-
* Central registry for managing skill definitions.
|
|
5
|
-
* Skills can be registered programmatically or loaded from bundled definitions.
|
|
6
|
-
*/
|
|
7
|
-
/** Internal skill store */
|
|
8
|
-
const skills = new Map();
|
|
9
|
-
/** Alias -> skill name mapping */
|
|
10
|
-
const aliases = new Map();
|
|
11
|
-
/**
|
|
12
|
-
* Register a skill definition.
|
|
13
|
-
*/
|
|
14
|
-
export function registerSkill(definition) {
|
|
15
|
-
skills.set(definition.name, definition);
|
|
16
|
-
// Register aliases
|
|
17
|
-
if (definition.aliases) {
|
|
18
|
-
for (const alias of definition.aliases) {
|
|
19
|
-
aliases.set(alias, definition.name);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Get a skill by name or alias.
|
|
25
|
-
*/
|
|
26
|
-
export function getSkill(name) {
|
|
27
|
-
// Direct lookup
|
|
28
|
-
const direct = skills.get(name);
|
|
29
|
-
if (direct)
|
|
30
|
-
return direct;
|
|
31
|
-
// Alias lookup
|
|
32
|
-
const resolved = aliases.get(name);
|
|
33
|
-
if (resolved)
|
|
34
|
-
return skills.get(resolved);
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get all registered skills.
|
|
39
|
-
*/
|
|
40
|
-
export function getAllSkills() {
|
|
41
|
-
return Array.from(skills.values());
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get all user-invocable skills (for /command listing).
|
|
45
|
-
*/
|
|
46
|
-
export function getUserInvocableSkills() {
|
|
47
|
-
return getAllSkills().filter((s) => s.userInvocable !== false && (!s.isEnabled || s.isEnabled()));
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Check if a skill exists.
|
|
51
|
-
*/
|
|
52
|
-
export function hasSkill(name) {
|
|
53
|
-
return skills.has(name) || aliases.has(name);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Remove a skill.
|
|
57
|
-
*/
|
|
58
|
-
export function unregisterSkill(name) {
|
|
59
|
-
const skill = skills.get(name);
|
|
60
|
-
if (!skill)
|
|
61
|
-
return false;
|
|
62
|
-
// Remove aliases
|
|
63
|
-
if (skill.aliases) {
|
|
64
|
-
for (const alias of skill.aliases) {
|
|
65
|
-
aliases.delete(alias);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return skills.delete(name);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Clear all skills (for testing).
|
|
72
|
-
*/
|
|
73
|
-
export function clearSkills() {
|
|
74
|
-
skills.clear();
|
|
75
|
-
aliases.clear();
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Format skills listing for system prompt injection.
|
|
79
|
-
*
|
|
80
|
-
* Uses a budget system: skills listing gets a limited character budget
|
|
81
|
-
* to avoid bloating the context window.
|
|
82
|
-
*/
|
|
83
|
-
export function formatSkillsForPrompt(contextWindowTokens) {
|
|
84
|
-
const invocable = getUserInvocableSkills();
|
|
85
|
-
if (invocable.length === 0)
|
|
86
|
-
return '';
|
|
87
|
-
// Budget: 1% of context window in characters (4 chars per token)
|
|
88
|
-
const CHARS_PER_TOKEN = 4;
|
|
89
|
-
const DEFAULT_BUDGET = 8000;
|
|
90
|
-
const MAX_DESC_CHARS = 250;
|
|
91
|
-
const budget = contextWindowTokens
|
|
92
|
-
? Math.floor(contextWindowTokens * 0.01 * CHARS_PER_TOKEN)
|
|
93
|
-
: DEFAULT_BUDGET;
|
|
94
|
-
const lines = [];
|
|
95
|
-
let used = 0;
|
|
96
|
-
for (const skill of invocable) {
|
|
97
|
-
const desc = skill.description.length > MAX_DESC_CHARS
|
|
98
|
-
? skill.description.slice(0, MAX_DESC_CHARS) + '...'
|
|
99
|
-
: skill.description;
|
|
100
|
-
const trigger = skill.whenToUse
|
|
101
|
-
? ` TRIGGER when: ${skill.whenToUse}`
|
|
102
|
-
: '';
|
|
103
|
-
const line = `- ${skill.name}: ${desc}${trigger}`;
|
|
104
|
-
if (used + line.length > budget)
|
|
105
|
-
break;
|
|
106
|
-
lines.push(line);
|
|
107
|
-
used += line.length;
|
|
108
|
-
}
|
|
109
|
-
return lines.join('\n');
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/skills/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,2BAA2B;AAC3B,MAAM,MAAM,GAAiC,IAAI,GAAG,EAAE,CAAA;AAEtD,kCAAkC;AAClC,MAAM,OAAO,GAAwB,IAAI,GAAG,EAAE,CAAA;AAE9C;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,UAA2B;IACvD,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IAEvC,mBAAmB;IACnB,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,KAAK,MAAM,KA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G,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,GAAG,OAAO,EAAE,CAAA;QAEjD,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM;YAAE,MAAK;QACtC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAChB,IAAI,IAAI,IAAI,CAAC,MAAM,CAAA;IACrB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
package/dist/skills/types.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill System Types
|
|
3
|
-
*
|
|
4
|
-
* Skills are reusable prompt templates that extend agent capabilities.
|
|
5
|
-
* They can be invoked by the model via the Skill tool or by users via /skillname.
|
|
6
|
-
*/
|
|
7
|
-
import type { ToolContext } from '../types.js';
|
|
8
|
-
import type { HookConfig } from '../hooks.js';
|
|
9
|
-
/**
|
|
10
|
-
* Content block for skill prompts (compatible with Anthropic API).
|
|
11
|
-
*/
|
|
12
|
-
export type SkillContentBlock = {
|
|
13
|
-
type: 'text';
|
|
14
|
-
text: string;
|
|
15
|
-
} | {
|
|
16
|
-
type: 'image';
|
|
17
|
-
source: {
|
|
18
|
-
type: 'base64';
|
|
19
|
-
media_type: string;
|
|
20
|
-
data: string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Bundled skill definition.
|
|
25
|
-
*
|
|
26
|
-
* Inspired by Claude Code's skill system. Skills provide specialized
|
|
27
|
-
* capabilities by injecting context-specific prompts with optional
|
|
28
|
-
* tool restrictions and model overrides.
|
|
29
|
-
*/
|
|
30
|
-
export interface SkillDefinition {
|
|
31
|
-
/** Unique skill name (e.g., 'simplify', 'commit') */
|
|
32
|
-
name: string;
|
|
33
|
-
/** Human-readable description */
|
|
34
|
-
description: string;
|
|
35
|
-
/** Alternative names for the skill */
|
|
36
|
-
aliases?: string[];
|
|
37
|
-
/** When the model should invoke this skill (used in system prompt) */
|
|
38
|
-
whenToUse?: string;
|
|
39
|
-
/** Hint for expected arguments */
|
|
40
|
-
argumentHint?: string;
|
|
41
|
-
/** Tools the skill is allowed to use (empty = all tools) */
|
|
42
|
-
allowedTools?: string[];
|
|
43
|
-
/** Model override for this skill */
|
|
44
|
-
model?: string;
|
|
45
|
-
/** Whether the skill can be invoked by users via /command */
|
|
46
|
-
userInvocable?: boolean;
|
|
47
|
-
/** Runtime check for availability */
|
|
48
|
-
isEnabled?: () => boolean;
|
|
49
|
-
/** Hook overrides while skill is active */
|
|
50
|
-
hooks?: HookConfig;
|
|
51
|
-
/** Execution context: 'inline' runs in current context, 'fork' spawns a subagent */
|
|
52
|
-
context?: 'inline' | 'fork';
|
|
53
|
-
/** Subagent type for forked execution */
|
|
54
|
-
agent?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Generate the prompt content blocks for this skill.
|
|
57
|
-
*
|
|
58
|
-
* @param args - User-provided arguments (e.g., from "/simplify focus on error handling")
|
|
59
|
-
* @param context - Tool execution context (cwd, etc.)
|
|
60
|
-
* @returns Content blocks to inject into the conversation
|
|
61
|
-
*/
|
|
62
|
-
getPrompt: (args: string, context: ToolContext) => Promise<SkillContentBlock[]>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Result of executing a skill.
|
|
66
|
-
*/
|
|
67
|
-
export interface SkillResult {
|
|
68
|
-
/** Whether execution succeeded */
|
|
69
|
-
success: boolean;
|
|
70
|
-
/** Skill name that was executed */
|
|
71
|
-
skillName: string;
|
|
72
|
-
/** Execution status */
|
|
73
|
-
status: 'inline' | 'forked';
|
|
74
|
-
/** Allowed tools override (for inline execution) */
|
|
75
|
-
allowedTools?: string[];
|
|
76
|
-
/** Model override */
|
|
77
|
-
model?: string;
|
|
78
|
-
/** Result text (for forked execution) */
|
|
79
|
-
result?: string;
|
|
80
|
-
/** Error message */
|
|
81
|
-
error?: string;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=types.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,CACT,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,KACjB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAA;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAA;IAEhB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAA;IAEjB,uBAAuB;IACvB,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAE3B,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IAEvB,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
|
package/dist/skills/types.js
DELETED
package/dist/skills/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/skills/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/dist/tool-helper.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tool() helper - Create tools using Zod schemas
|
|
3
|
-
*
|
|
4
|
-
* Compatible with open-agent-sdk's tool() function.
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* import { tool } from 'open-agent-sdk'
|
|
8
|
-
* import { z } from 'zod'
|
|
9
|
-
*
|
|
10
|
-
* const weatherTool = tool(
|
|
11
|
-
* 'get_weather',
|
|
12
|
-
* 'Get weather for a city',
|
|
13
|
-
* { city: z.string().describe('City name') },
|
|
14
|
-
* async ({ city }) => {
|
|
15
|
-
* return { content: [{ type: 'text', text: `Weather in ${city}: 22°C` }] }
|
|
16
|
-
* }
|
|
17
|
-
* )
|
|
18
|
-
*/
|
|
19
|
-
import { z, type ZodRawShape, type ZodObject } from 'zod';
|
|
20
|
-
import type { ToolDefinition } from './types.js';
|
|
21
|
-
/**
|
|
22
|
-
* Tool annotations (MCP standard).
|
|
23
|
-
*/
|
|
24
|
-
export interface ToolAnnotations {
|
|
25
|
-
readOnlyHint?: boolean;
|
|
26
|
-
destructiveHint?: boolean;
|
|
27
|
-
idempotentHint?: boolean;
|
|
28
|
-
openWorldHint?: boolean;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Tool call result (MCP-compatible).
|
|
32
|
-
*/
|
|
33
|
-
export interface CallToolResult {
|
|
34
|
-
content: Array<{
|
|
35
|
-
type: 'text';
|
|
36
|
-
text: string;
|
|
37
|
-
} | {
|
|
38
|
-
type: 'image';
|
|
39
|
-
data: string;
|
|
40
|
-
mimeType: string;
|
|
41
|
-
} | {
|
|
42
|
-
type: 'resource';
|
|
43
|
-
resource: {
|
|
44
|
-
uri: string;
|
|
45
|
-
text?: string;
|
|
46
|
-
blob?: string;
|
|
47
|
-
};
|
|
48
|
-
}>;
|
|
49
|
-
isError?: boolean;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* SDK MCP tool definition.
|
|
53
|
-
*/
|
|
54
|
-
export interface SdkMcpToolDefinition<T extends ZodRawShape = ZodRawShape> {
|
|
55
|
-
name: string;
|
|
56
|
-
description: string;
|
|
57
|
-
inputSchema: ZodObject<T>;
|
|
58
|
-
handler: (args: z.infer<ZodObject<T>>, extra: unknown) => Promise<CallToolResult>;
|
|
59
|
-
annotations?: ToolAnnotations;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Create a tool using Zod schema.
|
|
63
|
-
*
|
|
64
|
-
* Compatible with open-agent-sdk's tool() function.
|
|
65
|
-
*/
|
|
66
|
-
export declare function tool<T extends ZodRawShape>(name: string, description: string, inputSchema: T, handler: (args: z.infer<ZodObject<T>>, extra: unknown) => Promise<CallToolResult>, extras?: {
|
|
67
|
-
annotations?: ToolAnnotations;
|
|
68
|
-
}): SdkMcpToolDefinition<T>;
|
|
69
|
-
/**
|
|
70
|
-
* Convert an SdkMcpToolDefinition to a ToolDefinition for the engine.
|
|
71
|
-
*/
|
|
72
|
-
export declare function sdkToolToToolDefinition(sdkTool: SdkMcpToolDefinition<any>): ToolDefinition;
|
|
73
|
-
//# sourceMappingURL=tool-helper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-helper.d.ts","sourceRoot":"","sources":["../src/tool-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,KAAK,CAAA;AAEzD,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,YAAY,CAAA;AAEzE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CACV;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAC9B;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GACjD;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAChF,CAAA;IACD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IACvE,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;IACzB,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;IACjF,WAAW,CAAC,EAAE,eAAe,CAAA;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,WAAW,EACxC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,CAAC,EACd,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,EACjF,MAAM,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,eAAe,CAAA;CAAE,GACzC,oBAAoB,CAAC,CAAC,CAAC,CAQzB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,oBAAoB,CAAC,GAAG,CAAC,GAAG,cAAc,CA8C1F"}
|
package/dist/tool-helper.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tool() helper - Create tools using Zod schemas
|
|
3
|
-
*
|
|
4
|
-
* Compatible with open-agent-sdk's tool() function.
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* import { tool } from 'open-agent-sdk'
|
|
8
|
-
* import { z } from 'zod'
|
|
9
|
-
*
|
|
10
|
-
* const weatherTool = tool(
|
|
11
|
-
* 'get_weather',
|
|
12
|
-
* 'Get weather for a city',
|
|
13
|
-
* { city: z.string().describe('City name') },
|
|
14
|
-
* async ({ city }) => {
|
|
15
|
-
* return { content: [{ type: 'text', text: `Weather in ${city}: 22°C` }] }
|
|
16
|
-
* }
|
|
17
|
-
* )
|
|
18
|
-
*/
|
|
19
|
-
import { z } from 'zod';
|
|
20
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
21
|
-
/**
|
|
22
|
-
* Create a tool using Zod schema.
|
|
23
|
-
*
|
|
24
|
-
* Compatible with open-agent-sdk's tool() function.
|
|
25
|
-
*/
|
|
26
|
-
export function tool(name, description, inputSchema, handler, extras) {
|
|
27
|
-
return {
|
|
28
|
-
name,
|
|
29
|
-
description,
|
|
30
|
-
inputSchema: z.object(inputSchema),
|
|
31
|
-
handler,
|
|
32
|
-
annotations: extras?.annotations,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Convert an SdkMcpToolDefinition to a ToolDefinition for the engine.
|
|
37
|
-
*/
|
|
38
|
-
export function sdkToolToToolDefinition(sdkTool) {
|
|
39
|
-
const jsonSchema = zodToJsonSchema(sdkTool.inputSchema, { target: 'openApi3' });
|
|
40
|
-
return {
|
|
41
|
-
name: sdkTool.name,
|
|
42
|
-
description: sdkTool.description,
|
|
43
|
-
inputSchema: {
|
|
44
|
-
type: 'object',
|
|
45
|
-
properties: jsonSchema.properties || {},
|
|
46
|
-
required: jsonSchema.required || [],
|
|
47
|
-
},
|
|
48
|
-
isReadOnly: () => sdkTool.annotations?.readOnlyHint ?? false,
|
|
49
|
-
isConcurrencySafe: () => sdkTool.annotations?.readOnlyHint ?? false,
|
|
50
|
-
isEnabled: () => true,
|
|
51
|
-
async prompt() { return sdkTool.description; },
|
|
52
|
-
async call(input, _context) {
|
|
53
|
-
try {
|
|
54
|
-
const parsed = sdkTool.inputSchema.parse(input);
|
|
55
|
-
const result = await sdkTool.handler(parsed, {});
|
|
56
|
-
// Convert MCP content blocks to string
|
|
57
|
-
const text = result.content
|
|
58
|
-
.map((block) => {
|
|
59
|
-
if (block.type === 'text')
|
|
60
|
-
return block.text;
|
|
61
|
-
if (block.type === 'image')
|
|
62
|
-
return `[Image: ${block.mimeType}]`;
|
|
63
|
-
if (block.type === 'resource')
|
|
64
|
-
return block.resource.text || `[Resource: ${block.resource.uri}]`;
|
|
65
|
-
return JSON.stringify(block);
|
|
66
|
-
})
|
|
67
|
-
.join('\n');
|
|
68
|
-
return {
|
|
69
|
-
type: 'tool_result',
|
|
70
|
-
tool_use_id: '',
|
|
71
|
-
content: text,
|
|
72
|
-
is_error: result.isError || false,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
return {
|
|
77
|
-
type: 'tool_result',
|
|
78
|
-
tool_use_id: '',
|
|
79
|
-
content: `Error: ${err.message}`,
|
|
80
|
-
is_error: true,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=tool-helper.js.map
|
package/dist/tool-helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-helper.js","sourceRoot":"","sources":["../src/tool-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAoC,MAAM,KAAK,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAoCpD;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAClB,IAAY,EACZ,WAAmB,EACnB,WAAc,EACd,OAAiF,EACjF,MAA0C;IAE1C,OAAO;QACL,IAAI;QACJ,WAAW;QACX,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;QAClC,OAAO;QACP,WAAW,EAAE,MAAM,EAAE,WAAW;KACjC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAkC;IACxE,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAQ,CAAA;IAEtF,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,WAA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E,EAAE;oBACf,OAAO,EAAE,IAAI;oBACb,QAAQ,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;iBAClC,CAAA;YACH,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,OAAO;oBACL,IAAI,EAAE,aAAa;oBACnB,WAAW,EAAE,EAAE;oBACf,OAAO,EAAE,UAAU,GAAG,CAAC,OAAO,EAAE;oBAChC,QAAQ,EAAE,IAAI;iBACf,CAAA;YACH,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AgentTool - Spawn subagents for parallel/delegated work
|
|
3
|
-
*
|
|
4
|
-
* Supports built-in agents (Explore, Plan) and custom agent definitions.
|
|
5
|
-
* Agents run as nested query loops with their own context and tool sets.
|
|
6
|
-
*/
|
|
7
|
-
import type { ToolDefinition, AgentDefinition } from '../types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Register agent definitions for the AgentTool to use.
|
|
10
|
-
*/
|
|
11
|
-
export declare function registerAgents(agents: Record<string, AgentDefinition>): void;
|
|
12
|
-
/**
|
|
13
|
-
* Clear registered agents.
|
|
14
|
-
*/
|
|
15
|
-
export declare function clearAgents(): void;
|
|
16
|
-
export declare const AgentTool: ToolDefinition;
|
|
17
|
-
//# sourceMappingURL=agent-tool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-tool.d.ts","sourceRoot":"","sources":["../../src/tools/agent-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAA2B,eAAe,EAAE,MAAM,aAAa,CAAA;AAQ3F;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,IAAI,CAE5E;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAkBD,eAAO,MAAM,SAAS,EAAE,cAsHvB,CAAA"}
|