@cuylabs/agent-capability-pack 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +67 -0
- package/dist/bridge/index.d.ts +77 -0
- package/dist/bridge/index.js +7 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/chunk-2TICMDUA.js +25 -0
- package/dist/chunk-2TICMDUA.js.map +1 -0
- package/dist/chunk-5E66GFAI.js +290 -0
- package/dist/chunk-5E66GFAI.js.map +1 -0
- package/dist/chunk-IUGGMU63.js +220 -0
- package/dist/chunk-IUGGMU63.js.map +1 -0
- package/dist/chunk-LDYHPSNE.js +168 -0
- package/dist/chunk-LDYHPSNE.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/pack/index.d.ts +207 -0
- package/dist/pack/index.js +15 -0
- package/dist/pack/index.js.map +1 -0
- package/dist/sources/index.d.ts +20 -0
- package/dist/sources/index.js +19 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/types-BdapSdPT.d.ts +325 -0
- package/docs/README.md +17 -0
- package/docs/authoring.md +85 -0
- package/docs/mcp-bridge.md +49 -0
- package/docs/sources.md +52 -0
- package/package.json +83 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { b as CapabilityPack, d as PackRef } from '../types-BdapSdPT.js';
|
|
2
|
+
export { C as CAPABILITY_PACK_KIND, a as CAPABILITY_PACK_SCHEMA_VERSION, P as PackAuthor, c as PackMeta, e as PackSkill, f as PackSkillResource, h as PackSkillResourceType } from '../types-BdapSdPT.js';
|
|
3
|
+
import { MCPConfig } from '@cuylabs/agent-core/mcp';
|
|
4
|
+
import { SkillRegistry } from '@cuylabs/agent-core/skill';
|
|
5
|
+
import { PluginRegistry } from '@cuylabs/agent-core/plugin';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* defineCapabilityPack — ergonomic authoring helper.
|
|
9
|
+
*
|
|
10
|
+
* Returns the pack with default manifest metadata filled in. The value lies in
|
|
11
|
+
* IDE completion, type narrowing, and the ability to statically inspect packs
|
|
12
|
+
* without executing them.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Define a capability pack with full type checking.
|
|
17
|
+
*
|
|
18
|
+
* This is the canonical way to author a pack inline or in an npm package.
|
|
19
|
+
* The function preserves your pack shape and fills default manifest metadata
|
|
20
|
+
* when `kind` or `schemaVersion` are omitted.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* // my-pack.ts
|
|
25
|
+
* import { defineCapabilityPack } from "@cuylabs/agent-capability-pack"
|
|
26
|
+
*
|
|
27
|
+
* export default defineCapabilityPack({
|
|
28
|
+
* id: "my-pack",
|
|
29
|
+
* name: "My Pack",
|
|
30
|
+
* version: "1.0.0",
|
|
31
|
+
* skills: [{
|
|
32
|
+
* name: "my-skill",
|
|
33
|
+
* description: "Handles X when the task involves Y.",
|
|
34
|
+
* body: "# My Skill\n\nInstructions...",
|
|
35
|
+
* }],
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function defineCapabilityPack(pack: CapabilityPack): CapabilityPack;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Pack load result types.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Outcome of loading a single `CapabilityPack`.
|
|
47
|
+
*/
|
|
48
|
+
interface PackItemResult {
|
|
49
|
+
/** Pack ID from the pack's metadata. */
|
|
50
|
+
packId: string;
|
|
51
|
+
/** Number of skills successfully registered or updated in the SkillRegistry. */
|
|
52
|
+
skillsRegistered: number;
|
|
53
|
+
/**
|
|
54
|
+
* Names of MCP servers contributed by this pack.
|
|
55
|
+
*
|
|
56
|
+
* The actual configs are aggregated in `PackLoadResult.mcpServers`.
|
|
57
|
+
*/
|
|
58
|
+
mcpServerNames: string[];
|
|
59
|
+
/** Whether a plugin from this pack was loaded into the PluginRegistry. */
|
|
60
|
+
pluginLoaded: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Error message if this pack failed to load.
|
|
63
|
+
*
|
|
64
|
+
* A failed pack does not block other packs — the loader continues.
|
|
65
|
+
* Check `PackLoadResult.failed` to surface errors to the user.
|
|
66
|
+
*/
|
|
67
|
+
error?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Aggregate result of loading all packs via `PackLoader.loadAll()`.
|
|
71
|
+
*/
|
|
72
|
+
interface PackLoadResult {
|
|
73
|
+
/** Packs that were loaded without errors. */
|
|
74
|
+
loaded: PackItemResult[];
|
|
75
|
+
/**
|
|
76
|
+
* Packs that failed to resolve or load.
|
|
77
|
+
*
|
|
78
|
+
* Each entry includes the error message. The host can decide whether to
|
|
79
|
+
* surface these as warnings or treat them as fatal.
|
|
80
|
+
*/
|
|
81
|
+
failed: PackItemResult[];
|
|
82
|
+
/**
|
|
83
|
+
* All MCP server configurations aggregated from every successfully loaded pack.
|
|
84
|
+
*
|
|
85
|
+
* Merge this into your own `MCPConfig` before constructing the `MCPManager`:
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* const result = await loader.loadAll(packs)
|
|
89
|
+
* const mcpManager = createMCPManager({
|
|
90
|
+
* ...myServers,
|
|
91
|
+
* ...result.mcpServers,
|
|
92
|
+
* })
|
|
93
|
+
* await mcpManager.connect()
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* When multiple packs contribute a server with the same name, the last
|
|
97
|
+
* pack in load order wins (same behavior as `Object.assign`).
|
|
98
|
+
*/
|
|
99
|
+
mcpServers: MCPConfig;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* PackLoader — bridges CapabilityPacks into agent-core subsystems.
|
|
104
|
+
*
|
|
105
|
+
* The loader is the orchestration layer between the pack distribution
|
|
106
|
+
* format and the three runtime systems it feeds:
|
|
107
|
+
*
|
|
108
|
+
* pack.skills → SkillRegistry.register()
|
|
109
|
+
* pack.mcpServers → returned in PackLoadResult for host to merge
|
|
110
|
+
* pack.plugin → PluginRegistry.loadOne()
|
|
111
|
+
*
|
|
112
|
+
* MCP server configs are not applied directly to an MCPManager because
|
|
113
|
+
* the manager must receive all its server configs before `connect()` is
|
|
114
|
+
* called. The host merges `result.mcpServers` into its own config and
|
|
115
|
+
* constructs the manager — this preserves the manager's contract.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* import { PackLoader } from "@cuylabs/agent-capability-pack"
|
|
120
|
+
* import { createSkillRegistry } from "@cuylabs/agent-core"
|
|
121
|
+
* import { createMCPManager } from "@cuylabs/agent-core/mcp"
|
|
122
|
+
* import { PluginRegistry } from "@cuylabs/agent-core/plugin"
|
|
123
|
+
*
|
|
124
|
+
* const skillRegistry = await createSkillRegistry(cwd)
|
|
125
|
+
* const pluginRegistry = new PluginRegistry()
|
|
126
|
+
*
|
|
127
|
+
* const loader = new PackLoader({ skillRegistry, pluginRegistry, cwd })
|
|
128
|
+
* const result = await loader.loadAll([
|
|
129
|
+
* { source: "inline", pack: myPack },
|
|
130
|
+
* { source: "npm", package: "@myorg/agent-pack" },
|
|
131
|
+
* { source: "local", path: "./packs/company-tools" },
|
|
132
|
+
* ])
|
|
133
|
+
*
|
|
134
|
+
* // Merge pack-contributed servers with your own before connecting
|
|
135
|
+
* const mcpManager = createMCPManager({ ...myServers, ...result.mcpServers })
|
|
136
|
+
* await mcpManager.connect()
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
interface PackLoaderOptions {
|
|
141
|
+
/**
|
|
142
|
+
* The skill registry that pack skills are registered into.
|
|
143
|
+
*
|
|
144
|
+
* Skills contributed by a pack have "global" scope and lose to any
|
|
145
|
+
* project- or user-scoped skill with the same name (scoped skills win).
|
|
146
|
+
*/
|
|
147
|
+
skillRegistry: SkillRegistry;
|
|
148
|
+
/**
|
|
149
|
+
* Optional plugin registry for loading pack plugin contributions.
|
|
150
|
+
*
|
|
151
|
+
* When omitted, plugin contributions from packs are silently ignored.
|
|
152
|
+
* Provide a `PluginRegistry` instance if your agent uses the plugin system.
|
|
153
|
+
*/
|
|
154
|
+
pluginRegistry?: PluginRegistry;
|
|
155
|
+
/**
|
|
156
|
+
* Working directory passed to the plugin registry when loading pack plugins.
|
|
157
|
+
*
|
|
158
|
+
* Defaults to `process.cwd()`.
|
|
159
|
+
*/
|
|
160
|
+
cwd?: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Loads capability packs into agent-core subsystems.
|
|
164
|
+
*
|
|
165
|
+
* Accepts both resolved `CapabilityPack` objects and unresolved `PackRef`
|
|
166
|
+
* references. Refs are resolved before loading; resolution errors are
|
|
167
|
+
* reported in `PackLoadResult.failed` rather than throwing.
|
|
168
|
+
*
|
|
169
|
+
* The loader is non-throwing by default: individual pack failures are
|
|
170
|
+
* collected and returned so the agent can start with whatever capabilities
|
|
171
|
+
* loaded successfully.
|
|
172
|
+
*/
|
|
173
|
+
declare class PackLoader {
|
|
174
|
+
private readonly skillRegistry;
|
|
175
|
+
private readonly pluginRegistry;
|
|
176
|
+
private readonly cwd;
|
|
177
|
+
constructor(options: PackLoaderOptions);
|
|
178
|
+
/**
|
|
179
|
+
* Load multiple packs in order.
|
|
180
|
+
*
|
|
181
|
+
* Accepts a mix of resolved `CapabilityPack` objects and `PackRef`
|
|
182
|
+
* references. Each item is processed sequentially; one failure does not
|
|
183
|
+
* block the rest.
|
|
184
|
+
*
|
|
185
|
+
* @returns Aggregate result with per-pack outcomes and collected MCP configs.
|
|
186
|
+
*/
|
|
187
|
+
loadAll(items: ReadonlyArray<CapabilityPack | PackRef>): Promise<PackLoadResult>;
|
|
188
|
+
/**
|
|
189
|
+
* Load a single resolved `CapabilityPack`.
|
|
190
|
+
*
|
|
191
|
+
* Stages pack content before mutating the runtime registries. Plugins are
|
|
192
|
+
* loaded first; only successful packs contribute skills and MCP configs.
|
|
193
|
+
*/
|
|
194
|
+
loadOne(pack: CapabilityPack): Promise<PackItemResult>;
|
|
195
|
+
/**
|
|
196
|
+
* Convert a `PackSkill` into `SkillMetadata` + `SkillContent` and register
|
|
197
|
+
* both in the skill registry so the agent can discover (L1) and load (L2)
|
|
198
|
+
* the skill without any file reads.
|
|
199
|
+
*
|
|
200
|
+
* Discovered skills (project / user scope) always win if a skill with the
|
|
201
|
+
* same name already exists — see `SkillRegistry.register()`.
|
|
202
|
+
*/
|
|
203
|
+
private preparePackSkill;
|
|
204
|
+
private loadPluginContribution;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export { CapabilityPack, type PackItemResult, type PackLoadResult, PackLoader, type PackLoaderOptions, defineCapabilityPack };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PackLoader,
|
|
3
|
+
defineCapabilityPack
|
|
4
|
+
} from "../chunk-IUGGMU63.js";
|
|
5
|
+
import {
|
|
6
|
+
CAPABILITY_PACK_KIND,
|
|
7
|
+
CAPABILITY_PACK_SCHEMA_VERSION
|
|
8
|
+
} from "../chunk-5E66GFAI.js";
|
|
9
|
+
export {
|
|
10
|
+
CAPABILITY_PACK_KIND,
|
|
11
|
+
CAPABILITY_PACK_SCHEMA_VERSION,
|
|
12
|
+
PackLoader,
|
|
13
|
+
defineCapabilityPack
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { d as PackRef, b as CapabilityPack } from '../types-BdapSdPT.js';
|
|
2
|
+
export { G as GitPackRef, I as InlinePackRef, L as LocalPackRef, N as NpmPackRef, U as UrlPackRef, g as gitPack, i as inlinePack, l as localPack, n as npmPack, u as urlPack } from '../types-BdapSdPT.js';
|
|
3
|
+
import '@cuylabs/agent-core/mcp';
|
|
4
|
+
import '@cuylabs/agent-core/plugin';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* resolvePackRef — unified entry point for resolving any PackRef.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a `PackRef` to a `CapabilityPack`.
|
|
12
|
+
*
|
|
13
|
+
* Dispatches to the appropriate resolver based on `ref.source`.
|
|
14
|
+
* Throws if resolution fails (network error, missing file, bad manifest, etc.).
|
|
15
|
+
*
|
|
16
|
+
* @throws {Error} Resolution failed — details in the error message.
|
|
17
|
+
*/
|
|
18
|
+
declare function resolvePackRef(ref: PackRef): Promise<CapabilityPack>;
|
|
19
|
+
|
|
20
|
+
export { PackRef, resolvePackRef };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
gitPack,
|
|
3
|
+
inlinePack,
|
|
4
|
+
localPack,
|
|
5
|
+
npmPack,
|
|
6
|
+
urlPack
|
|
7
|
+
} from "../chunk-2TICMDUA.js";
|
|
8
|
+
import {
|
|
9
|
+
resolvePackRef
|
|
10
|
+
} from "../chunk-5E66GFAI.js";
|
|
11
|
+
export {
|
|
12
|
+
gitPack,
|
|
13
|
+
inlinePack,
|
|
14
|
+
localPack,
|
|
15
|
+
npmPack,
|
|
16
|
+
resolvePackRef,
|
|
17
|
+
urlPack
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { MCPServerConfig } from '@cuylabs/agent-core/mcp';
|
|
2
|
+
import { PluginDefinition, PluginInit } from '@cuylabs/agent-core/plugin';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Capability Pack — core types.
|
|
6
|
+
*
|
|
7
|
+
* A CapabilityPack is the distributable unit of agent capabilities.
|
|
8
|
+
* It bundles any combination of skills, MCP server configurations,
|
|
9
|
+
* and plugin contributions into a single, composable object.
|
|
10
|
+
*
|
|
11
|
+
* Packs are source-agnostic by design: whether a pack was authored
|
|
12
|
+
* inline, loaded from an npm package, fetched from a URL, or read
|
|
13
|
+
* from a local directory, it always resolves to this same shape.
|
|
14
|
+
* The PackLoader feeds it into the agent-core subsystems.
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Marker value for JSON-backed pack manifests. */
|
|
20
|
+
declare const CAPABILITY_PACK_KIND = "agent-capability-pack";
|
|
21
|
+
/** Current JSON manifest schema version for capability packs. */
|
|
22
|
+
declare const CAPABILITY_PACK_SCHEMA_VERSION = 1;
|
|
23
|
+
/** Author information for a capability pack. */
|
|
24
|
+
interface PackAuthor {
|
|
25
|
+
/** Display name of the author or organization. */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Author website or GitHub profile URL. */
|
|
28
|
+
url?: string;
|
|
29
|
+
/** Contact email. */
|
|
30
|
+
email?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Identifying metadata for a capability pack.
|
|
34
|
+
*
|
|
35
|
+
* These fields are shared by both `CapabilityPack` and pack manifest
|
|
36
|
+
* files on disk (`pack.json`).
|
|
37
|
+
*/
|
|
38
|
+
interface PackMeta {
|
|
39
|
+
/** Optional manifest kind marker for JSON-backed packs. */
|
|
40
|
+
kind?: typeof CAPABILITY_PACK_KIND;
|
|
41
|
+
/** Optional manifest schema version for JSON-backed packs. */
|
|
42
|
+
schemaVersion?: typeof CAPABILITY_PACK_SCHEMA_VERSION;
|
|
43
|
+
/**
|
|
44
|
+
* Unique pack identifier. Used for namespacing, deduplication, and logging.
|
|
45
|
+
* Should be kebab-case (e.g. "my-company-tools").
|
|
46
|
+
*/
|
|
47
|
+
id: string;
|
|
48
|
+
/** Human-readable display name. */
|
|
49
|
+
name?: string;
|
|
50
|
+
/** Brief description of what this pack provides. */
|
|
51
|
+
description?: string;
|
|
52
|
+
/** SemVer version string. */
|
|
53
|
+
version?: string;
|
|
54
|
+
/** Author or owning organization. */
|
|
55
|
+
author?: PackAuthor;
|
|
56
|
+
}
|
|
57
|
+
/** Resource type classification — mirrors `SkillResourceType` from agent-core. */
|
|
58
|
+
type PackSkillResourceType = "script" | "reference" | "asset" | "example";
|
|
59
|
+
/**
|
|
60
|
+
* A bundled resource included with a pack skill.
|
|
61
|
+
*
|
|
62
|
+
* Resources are listed in L2 (skill content) so the agent knows
|
|
63
|
+
* what is available, and loaded on demand in L3 via the `skill_resource` tool.
|
|
64
|
+
*
|
|
65
|
+
* For programmatically defined packs, provide `content` directly.
|
|
66
|
+
* For local packs resolved from disk, `absolutePath` is set by the resolver.
|
|
67
|
+
* At least one of `content` or `absolutePath` must be set.
|
|
68
|
+
*/
|
|
69
|
+
interface PackSkillResource {
|
|
70
|
+
/** Path relative to the skill directory. Used by the agent to request the resource. */
|
|
71
|
+
relativePath: string;
|
|
72
|
+
/** Resource classification. */
|
|
73
|
+
type: PackSkillResourceType;
|
|
74
|
+
/**
|
|
75
|
+
* Inline resource content.
|
|
76
|
+
*
|
|
77
|
+
* Takes precedence over `absolutePath` when both are present.
|
|
78
|
+
* Use this for programmatically defined packs.
|
|
79
|
+
*/
|
|
80
|
+
content?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Absolute filesystem path to the resource file.
|
|
83
|
+
*
|
|
84
|
+
* Set by the local pack resolver for on-disk resources.
|
|
85
|
+
* The content is loaded lazily when the agent calls `skill_resource`.
|
|
86
|
+
*/
|
|
87
|
+
absolutePath?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* An inline skill definition inside a CapabilityPack.
|
|
91
|
+
*
|
|
92
|
+
* Carries the skill's name, description (L1), and full instruction body (L2)
|
|
93
|
+
* so no file read is needed at runtime. When registered via `PackLoader`,
|
|
94
|
+
* both the metadata and content are available immediately.
|
|
95
|
+
*
|
|
96
|
+
* ## Authoring
|
|
97
|
+
*
|
|
98
|
+
* The `description` field is the most important: the agent reads it to decide
|
|
99
|
+
* whether to activate this skill. Write it as trigger phrases for task types,
|
|
100
|
+
* not as prose for humans.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* {
|
|
105
|
+
* name: "api-integration",
|
|
106
|
+
* description: "Connect to external REST APIs with auth, retries, and typed responses.",
|
|
107
|
+
* body: "# API Integration\n\nAlways use the `apiClient` helper...",
|
|
108
|
+
* version: "1.0.0",
|
|
109
|
+
* tags: ["api", "http", "typescript"],
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
interface PackSkill {
|
|
114
|
+
/** Unique skill name. Must not conflict with project or user skills (project/user win). */
|
|
115
|
+
name: string;
|
|
116
|
+
/**
|
|
117
|
+
* When-to-use description. The agent reads this at L1 to decide whether to
|
|
118
|
+
* activate the skill. Written for LLM consumption, not humans.
|
|
119
|
+
*/
|
|
120
|
+
description: string;
|
|
121
|
+
/**
|
|
122
|
+
* Full SKILL.md markdown body (everything below the frontmatter block).
|
|
123
|
+
* This becomes the L2 content loaded when the agent calls the `skill` tool.
|
|
124
|
+
*/
|
|
125
|
+
body: string;
|
|
126
|
+
/** SemVer version string. */
|
|
127
|
+
version?: string;
|
|
128
|
+
/** Categorization tags for filtering and discovery. */
|
|
129
|
+
tags?: string[];
|
|
130
|
+
/** Names of skills this skill works best alongside. Suggested at L2 load time. */
|
|
131
|
+
dependencies?: string[];
|
|
132
|
+
/**
|
|
133
|
+
* Bundled reference material, scripts, templates, and examples (L3).
|
|
134
|
+
*
|
|
135
|
+
* The agent sees these listed after loading the skill (L2) and can
|
|
136
|
+
* read individual resources via the `skill_resource` tool.
|
|
137
|
+
*/
|
|
138
|
+
resources?: PackSkillResource[];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* A capability pack — the distributable unit of agent capabilities.
|
|
142
|
+
*
|
|
143
|
+
* A pack bundles any combination of:
|
|
144
|
+
* - **Skills**: on-demand instructions loaded by the agent via the `skill` tool.
|
|
145
|
+
* - **MCP servers**: external tool and resource providers connected via the MCP protocol.
|
|
146
|
+
* - **Plugin**: tools, middleware, commands, and prompt sections contributed as code.
|
|
147
|
+
*
|
|
148
|
+
* Packs are designed to be:
|
|
149
|
+
* - **Authored inline** in your agent code with `defineCapabilityPack()`
|
|
150
|
+
* - **Published as npm packages** that default-export a `CapabilityPack`
|
|
151
|
+
* - **Hosted at a URL** serving the JSON representation
|
|
152
|
+
* - **Stored in a local directory** with a `pack.json` manifest
|
|
153
|
+
*
|
|
154
|
+
* The `PackLoader` feeds a pack's contributions into the agent-core subsystems
|
|
155
|
+
* (`SkillRegistry`, `PluginRegistry`, and the `MCPConfig` for `MCPManager`).
|
|
156
|
+
*
|
|
157
|
+
* @example Inline pack with everything
|
|
158
|
+
* ```ts
|
|
159
|
+
* import { defineCapabilityPack } from "@cuylabs/agent-capability-pack"
|
|
160
|
+
* import { definePlugin, stdioServer } from "@cuylabs/agent-core"
|
|
161
|
+
*
|
|
162
|
+
* export default defineCapabilityPack({
|
|
163
|
+
* id: "my-company-tools",
|
|
164
|
+
* name: "My Company Tools",
|
|
165
|
+
* version: "1.0.0",
|
|
166
|
+
*
|
|
167
|
+
* skills: [{
|
|
168
|
+
* name: "api-integration",
|
|
169
|
+
* description: "Connect to My Company internal APIs with auth and retry logic.",
|
|
170
|
+
* body: "# API Integration\n\nAlways use the Bearer token from...",
|
|
171
|
+
* }],
|
|
172
|
+
*
|
|
173
|
+
* mcpServers: {
|
|
174
|
+
* "company-mcp": stdioServer("npx", ["-y", "@mycompany/mcp-server"]),
|
|
175
|
+
* },
|
|
176
|
+
*
|
|
177
|
+
* plugin: definePlugin({
|
|
178
|
+
* id: "my-company-tools",
|
|
179
|
+
* tools: [myCustomTool],
|
|
180
|
+
* }),
|
|
181
|
+
* })
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
interface CapabilityPack extends PackMeta {
|
|
185
|
+
/**
|
|
186
|
+
* Skills contributed to the agent's `SkillRegistry`.
|
|
187
|
+
*
|
|
188
|
+
* Skills use progressive disclosure: name and description (L1) are always
|
|
189
|
+
* visible to the agent in the system prompt; full body (L2) is loaded when
|
|
190
|
+
* the agent calls the `skill` tool.
|
|
191
|
+
*/
|
|
192
|
+
skills?: PackSkill[];
|
|
193
|
+
/**
|
|
194
|
+
* MCP server configurations to add to the agent's `MCPManager`.
|
|
195
|
+
*
|
|
196
|
+
* These are collected by `PackLoader` and returned in `PackLoadResult.mcpServers`
|
|
197
|
+
* for the host to merge into its MCPConfig before calling `mcpManager.connect()`.
|
|
198
|
+
*
|
|
199
|
+
* Use the `stdioServer()`, `httpServer()`, and `sseServer()` helpers from
|
|
200
|
+
* `@cuylabs/agent-core/mcp` to build configs ergonomically.
|
|
201
|
+
*/
|
|
202
|
+
mcpServers?: Record<string, MCPServerConfig>;
|
|
203
|
+
/**
|
|
204
|
+
* Plugin contributions: tools, middleware, commands, and prompt sections.
|
|
205
|
+
*
|
|
206
|
+
* Accepts either:
|
|
207
|
+
* - A `PluginDefinition` object (from `definePlugin()` in agent-core)
|
|
208
|
+
* - A raw `PluginInit` function
|
|
209
|
+
*
|
|
210
|
+
* The plugin is loaded into the host's `PluginRegistry` if one is provided
|
|
211
|
+
* to `PackLoader`. The pack's `id` is used as the plugin ID if the plugin
|
|
212
|
+
* definition does not specify one.
|
|
213
|
+
*/
|
|
214
|
+
plugin?: PluginDefinition | PluginInit;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* PackRef — typed references to capability packs from external sources.
|
|
219
|
+
*
|
|
220
|
+
* A `PackRef` tells the resolver WHERE to get a pack.
|
|
221
|
+
* Every ref resolves to the same `CapabilityPack` shape, regardless of origin.
|
|
222
|
+
*
|
|
223
|
+
* Use the helper constructors below rather than building refs by hand:
|
|
224
|
+
*
|
|
225
|
+
* inlinePack(pack) — already-constructed CapabilityPack
|
|
226
|
+
* localPack("./path") — directory on disk with a pack.json
|
|
227
|
+
* npmPack("@org/my-pack") — npm package exporting a CapabilityPack
|
|
228
|
+
* urlPack("https://...") — URL serving a pack JSON manifest
|
|
229
|
+
* gitPack("https://...") — Git repository containing a pack
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
/** A pack that is already constructed — no resolution needed. */
|
|
233
|
+
interface InlinePackRef {
|
|
234
|
+
source: "inline";
|
|
235
|
+
pack: CapabilityPack;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* A pack stored in a local directory.
|
|
239
|
+
*
|
|
240
|
+
* The directory must contain a `pack.json` manifest. Skills are discovered
|
|
241
|
+
* from a `skills/` subdirectory using the SKILL.md convention. MCP server
|
|
242
|
+
* configs and plugin entry paths are read from `pack.json`.
|
|
243
|
+
*/
|
|
244
|
+
interface LocalPackRef {
|
|
245
|
+
source: "local";
|
|
246
|
+
/** Absolute or cwd-relative path to the pack directory. */
|
|
247
|
+
path: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* A pack published as an npm package.
|
|
251
|
+
*
|
|
252
|
+
* The package must have a default export or a named export that is a
|
|
253
|
+
* `CapabilityPack`. The resolver uses a dynamic `import()`.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```ts
|
|
257
|
+
* npmPack("@mycompany/agent-pack")
|
|
258
|
+
* npmPack("@mycompany/agent-pack", { export: "dataPack" })
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
interface NpmPackRef {
|
|
262
|
+
source: "npm";
|
|
263
|
+
/** npm package specifier (e.g. "@mycompany/agent-pack" or "agent-pack@1.2.0"). */
|
|
264
|
+
package: string;
|
|
265
|
+
/**
|
|
266
|
+
* Named export to use as the pack.
|
|
267
|
+
*
|
|
268
|
+
* When omitted, the default export is used.
|
|
269
|
+
*/
|
|
270
|
+
export?: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* A pack served as JSON at a URL.
|
|
274
|
+
*
|
|
275
|
+
* The URL must return a JSON object matching `CapabilityPack`.
|
|
276
|
+
* Only the pack metadata, skills, and MCP server configs are supported
|
|
277
|
+
* via URL packs — plugin code cannot be loaded from a URL for security.
|
|
278
|
+
*/
|
|
279
|
+
interface UrlPackRef {
|
|
280
|
+
source: "url";
|
|
281
|
+
/** HTTPS URL serving the pack JSON. */
|
|
282
|
+
url: string;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* A pack stored in a Git repository.
|
|
286
|
+
*
|
|
287
|
+
* The repository root must contain a `pack.json` manifest.
|
|
288
|
+
* The resolver clones (or fetches) the repository to a local cache
|
|
289
|
+
* before reading the pack.
|
|
290
|
+
*
|
|
291
|
+
* Requires `git` to be available on PATH.
|
|
292
|
+
*/
|
|
293
|
+
interface GitPackRef {
|
|
294
|
+
source: "git";
|
|
295
|
+
/** Git-cloneable URL (HTTPS or SSH). */
|
|
296
|
+
url: string;
|
|
297
|
+
/** Branch, tag, or commit SHA to check out. Defaults to the default branch. */
|
|
298
|
+
ref?: string;
|
|
299
|
+
}
|
|
300
|
+
/** Union of all pack reference types. */
|
|
301
|
+
type PackRef = InlinePackRef | LocalPackRef | NpmPackRef | UrlPackRef | GitPackRef;
|
|
302
|
+
/** Reference to an already-constructed CapabilityPack. */
|
|
303
|
+
declare function inlinePack(pack: CapabilityPack): InlinePackRef;
|
|
304
|
+
/** Reference to a pack stored in a local directory. */
|
|
305
|
+
declare function localPack(path: string): LocalPackRef;
|
|
306
|
+
/**
|
|
307
|
+
* Reference to a pack published as an npm package.
|
|
308
|
+
*
|
|
309
|
+
* @param pkg Package specifier (e.g. `"@mycompany/agent-pack"`).
|
|
310
|
+
* @param options.export Named export to use instead of the default export.
|
|
311
|
+
*/
|
|
312
|
+
declare function npmPack(pkg: string, options?: {
|
|
313
|
+
export?: string;
|
|
314
|
+
}): NpmPackRef;
|
|
315
|
+
/** Reference to a pack served as JSON at a URL. */
|
|
316
|
+
declare function urlPack(url: string): UrlPackRef;
|
|
317
|
+
/**
|
|
318
|
+
* Reference to a pack in a Git repository.
|
|
319
|
+
*
|
|
320
|
+
* @param url Git URL (HTTPS or SSH).
|
|
321
|
+
* @param ref Branch, tag, or commit. Defaults to the default branch.
|
|
322
|
+
*/
|
|
323
|
+
declare function gitPack(url: string, ref?: string): GitPackRef;
|
|
324
|
+
|
|
325
|
+
export { CAPABILITY_PACK_KIND as C, type GitPackRef as G, type InlinePackRef as I, type LocalPackRef as L, type NpmPackRef as N, type PackAuthor as P, type UrlPackRef as U, CAPABILITY_PACK_SCHEMA_VERSION as a, type CapabilityPack as b, type PackMeta as c, type PackRef as d, type PackSkill as e, type PackSkillResource as f, gitPack as g, type PackSkillResourceType as h, inlinePack as i, localPack as l, npmPack as n, urlPack as u };
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# agent-capability-pack Docs
|
|
2
|
+
|
|
3
|
+
`@cuylabs/agent-capability-pack` makes skills, MCP configs, and plugin
|
|
4
|
+
contributions load through one source-agnostic unit: a `CapabilityPack`.
|
|
5
|
+
|
|
6
|
+
## Concepts
|
|
7
|
+
|
|
8
|
+
- `CapabilityPack`: resolved runtime unit
|
|
9
|
+
- `PackRef`: where a pack comes from
|
|
10
|
+
- `PackLoader`: feeds a pack into `agent-core`
|
|
11
|
+
- `MCPSkillBridge`: turns MCP prompts into loadable skills
|
|
12
|
+
|
|
13
|
+
## Reading Order
|
|
14
|
+
|
|
15
|
+
- [authoring.md](./authoring.md): how to define packs and `pack.json`
|
|
16
|
+
- [sources.md](./sources.md): inline, local, npm, URL, and git source behavior
|
|
17
|
+
- [mcp-bridge.md](./mcp-bridge.md): how MCP prompt bridging works
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Authoring Packs
|
|
2
|
+
|
|
3
|
+
## Inline Packs
|
|
4
|
+
|
|
5
|
+
Use `defineCapabilityPack()` for packs authored directly in code:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { defineCapabilityPack } from "@cuylabs/agent-capability-pack";
|
|
9
|
+
|
|
10
|
+
export default defineCapabilityPack({
|
|
11
|
+
id: "company-tools",
|
|
12
|
+
name: "Company Tools",
|
|
13
|
+
skills: [
|
|
14
|
+
{
|
|
15
|
+
name: "internal-api",
|
|
16
|
+
description: "Use for tasks involving the internal company API.",
|
|
17
|
+
body: "# Internal API\n\nUse the authenticated client first.",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`defineCapabilityPack()` fills in:
|
|
24
|
+
|
|
25
|
+
- `kind: "agent-capability-pack"`
|
|
26
|
+
- `schemaVersion: 1`
|
|
27
|
+
|
|
28
|
+
## Local `pack.json`
|
|
29
|
+
|
|
30
|
+
Local and git-backed packs use `pack.json` plus an optional `skills/` folder.
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"kind": "agent-capability-pack",
|
|
35
|
+
"schemaVersion": 1,
|
|
36
|
+
"id": "company-tools",
|
|
37
|
+
"name": "Company Tools",
|
|
38
|
+
"description": "Internal skills and MCP connections",
|
|
39
|
+
"version": "1.0.0",
|
|
40
|
+
"plugin": "./plugin.ts",
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"company-api": {
|
|
43
|
+
"transport": "http",
|
|
44
|
+
"url": "https://mcp.example.com/mcp"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Directory layout:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
company-tools/
|
|
54
|
+
pack.json
|
|
55
|
+
plugin.ts
|
|
56
|
+
skills/
|
|
57
|
+
internal-api/
|
|
58
|
+
SKILL.md
|
|
59
|
+
references/
|
|
60
|
+
scripts/
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Notes:
|
|
64
|
+
|
|
65
|
+
- `plugin` is a relative module path. Use `.js` for production builds or `.ts` when running with `tsx` or `jiti` (plugin loading is jiti-powered and handles TypeScript directly).
|
|
66
|
+
- The plugin module must default-export a `PluginInit` function, usually created with `definePlugin()` from `@cuylabs/agent-core/plugin`.
|
|
67
|
+
- Local skills are discovered from `skills/` using the normal `SKILL.md` format.
|
|
68
|
+
|
|
69
|
+
## Load Semantics
|
|
70
|
+
|
|
71
|
+
`PackLoader` stages pack content before mutating the runtime registries:
|
|
72
|
+
|
|
73
|
+
- pack plugin is validated and loaded first
|
|
74
|
+
- pack skills are registered only after plugin loading succeeds
|
|
75
|
+
- MCP server configs are returned to the host only for successful packs
|
|
76
|
+
|
|
77
|
+
That keeps pack loading coherent instead of partially applying a failed pack.
|
|
78
|
+
|
|
79
|
+
## Examples
|
|
80
|
+
|
|
81
|
+
See the runnable examples in [`examples/`](../examples/):
|
|
82
|
+
|
|
83
|
+
- [01-inline-pack.ts](../examples/01-inline-pack.ts) — define and load an inline pack
|
|
84
|
+
- [02-local-pack.ts](../examples/02-local-pack.ts) — load from a directory on disk
|
|
85
|
+
- [04-full-setup.ts](../examples/04-full-setup.ts) — full integration with MCP and an agent
|