@unbrained/pm-cli 2026.8.25 → 2026.8.27
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/.agents/skills/HARNESS_COMPATIBILITY.md +32 -0
- package/.agents/skills/README.md +47 -0
- package/.agents/skills/pm-developer/SKILL.md +117 -0
- package/.agents/skills/pm-developer/references/COMMAND_PLAYBOOK.md +49 -0
- package/.agents/skills/pm-developer/references/GRAPH_AND_RELATIONSHIPS.md +91 -0
- package/.agents/skills/pm-developer/references/MULTI_AGENT_MERGE.md +72 -0
- package/.agents/skills/pm-developer/references/PROMPTS.md +17 -0
- package/.agents/skills/pm-developer/references/SCRIPTING_COMPOSITION.md +82 -0
- package/.agents/skills/pm-developer/references/TOKEN_BUDGETS.md +85 -0
- package/.agents/skills/pm-extensions/SKILL.md +106 -0
- package/.agents/skills/pm-extensions/references/AUTHORING.md +95 -0
- package/.agents/skills/pm-extensions/references/LIFECYCLE.md +40 -0
- package/.agents/skills/pm-extensions/references/TROUBLESHOOTING.md +25 -0
- package/.agents/skills/pm-sdk/SKILL.md +107 -0
- package/.agents/skills/pm-sdk/references/DOMAIN_MODELING.md +78 -0
- package/.agents/skills/pm-sdk/references/INTEGRATION_CHECKLIST.md +31 -0
- package/.agents/skills/pm-sdk/references/PROMPTS.md +13 -0
- package/.agents/skills/pm-sdk/references/SURFACE_MAP.md +82 -0
- package/.agents/skills/pm-user/SKILL.md +111 -0
- package/.agents/skills/pm-user/references/BACKLOG_SHAPING.md +105 -0
- package/.agents/skills/pm-user/references/PROMPTS.md +17 -0
- package/.agents/skills/pm-user/references/WORKFLOWS.md +35 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +58 -3
- package/README.md +8 -5
- package/dist/cli/commander-usage.js +11 -7
- package/dist/cli/error-guidance.js +3 -3
- package/dist/cli/help-content.d.ts +2 -0
- package/dist/cli/help-content.js +53 -17
- package/dist/cli/help-json-payload.d.ts +8 -2
- package/dist/cli/help-json-payload.js +46 -12
- package/dist/cli/main.js +52 -74
- package/dist/cli/register-annotations.js +27 -21
- package/dist/cli/register-setup.js +98 -57
- package/dist/cli-bundle/bundle-manifest.json +156 -156
- package/dist/cli-bundle/chunks/chunk-3OO3W6FW.js +202 -0
- package/dist/cli-bundle/chunks/chunk-52EKTW6V.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-QLUORNIB.js → chunk-CVBBGWW5.js} +62 -44
- package/dist/cli-bundle/chunks/chunk-MFNTKMTI.js +13 -0
- package/dist/cli-bundle/chunks/chunk-OS27HHBN.js +35 -0
- package/dist/cli-bundle/chunks/chunk-QTO7USTH.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-5I5RWIJC.js → chunk-R4ETAOJC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OWHNAR2B.js → chunk-SH6P7FXI.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-SHMDY36D.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-244MI4GS.js → chunk-SKXLJIEK.js} +60 -60
- package/dist/cli-bundle/chunks/chunk-TNX6HC54.js +3 -0
- package/dist/cli-bundle/chunks/{register-list-query-XVN2ZLI7.js → register-list-query-EUWM6VII.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-QCKAEGIJ.js → register-mutation-FD4HSAVU.js} +4 -4
- package/dist/cli-bundle/chunks/{register-operations-SDEAXE7E.js → register-operations-HRMNFEC3.js} +2 -2
- package/dist/cli-bundle/chunks/register-setup-33GNICLX.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IBZZZGK3.js → chunk-2AGZ5BRT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-4BR5UU52.js +50 -0
- package/dist/cli-bundle/focused-chunks/{chunk-OHIHZ7HS.js → chunk-6GCRSLPG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OVJL6NZE.js → chunk-AD6ULRAF.js} +4 -4
- package/dist/cli-bundle/focused-chunks/{chunk-7YCDTCBC.js → chunk-AQ5IYEZZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YO3ZF3FI.js → chunk-EKX37ZHA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-N7W67YIG.js → chunk-FC2AXLB5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-H5JZEIQV.js → chunk-HC7ODMH3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NOOZGIXP.js → chunk-HVQ22RC4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-A644DUFQ.js → chunk-MEASX544.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RAFKLNZX.js → chunk-MXTYGECH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2UIWOP3O.js → chunk-SUBSWYW3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VXWATRFL.js → chunk-XDPYBQCF.js} +9 -9
- package/dist/cli-bundle/focused-chunks/{chunk-XUQPEKRN.js → chunk-Y3JJXRVK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GQR3WH3F.js → chunk-Y5A7SJJ7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-YHWHX6YY.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-ONYQCALA.js → chunk-YVVZ3LQ6.js} +6 -6
- package/dist/cli-bundle/focused-chunks/chunk-Z2USIBR2.js +5 -0
- package/dist/cli-bundle/main.js +15 -14
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +31 -31
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +31 -31
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +32 -6
- package/dist/core/extensions/manifest-schema.d.ts +20 -0
- package/dist/core/extensions/manifest-schema.js +28 -10
- package/dist/core/governance/issue-codes.d.ts +11 -2
- package/dist/core/governance/issue-codes.js +29 -10
- package/dist/core/item/item-format.js +3 -3
- package/dist/core/store/item-store.js +12 -5
- package/dist/mcp/http-server.d.ts +60 -0
- package/dist/mcp/http-server.js +451 -0
- package/dist/mcp/legacy-adapter.d.ts +50 -0
- package/dist/mcp/legacy-adapter.js +64 -0
- package/dist/mcp/server.d.ts +42 -9
- package/dist/mcp/server.js +572 -59
- package/dist/mcp/tool-definitions.d.ts +2 -0
- package/dist/mcp/tool-definitions.js +2 -2
- package/dist/sdk/agent/closed-domain-contracts.d.ts +1 -1
- package/dist/sdk/agent/closed-domain-contracts.js +24 -2
- package/dist/sdk/agent/refusal-closure-census.d.ts +6 -2
- package/dist/sdk/agent/refusal-closure-census.js +16 -8
- package/dist/sdk/agent-capability-contracts.js +6 -2
- package/dist/sdk/cli-bootstrap.js +3 -2
- package/dist/sdk/cli-contracts/command-aliases.js +15 -2
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +7 -2
- package/dist/sdk/cli-contracts/flag-contracts.js +9 -5
- package/dist/sdk/cli-contracts/grammar-contracts.d.ts +3 -3
- package/dist/sdk/cli-contracts/grammar-contracts.js +24 -17
- package/dist/sdk/cli-contracts/runtime-contracts.js +13 -11
- package/dist/sdk/cli-contracts/tool-schema.js +18 -15
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +3 -3
- package/dist/sdk/cli-program.js +3 -2
- package/dist/sdk/completion.js +40 -13
- package/dist/sdk/compose.d.ts +4 -1
- package/dist/sdk/compose.js +23 -36
- package/dist/sdk/extension/author-manifest.d.ts +22 -0
- package/dist/sdk/extension/author-manifest.js +93 -0
- package/dist/sdk/extension.js +6 -3
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +20 -5
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +18 -3
- package/dist/sdk/governance/health.js +7 -2
- package/dist/sdk/governance/upgrade.d.ts +2 -0
- package/dist/sdk/governance/upgrade.js +30 -8
- package/dist/sdk/governance/validate.js +8 -6
- package/dist/sdk/guide-topics.js +6 -6
- package/dist/sdk/index.d.ts +10 -2
- package/dist/sdk/index.js +11 -3
- package/dist/sdk/mcp/apps.d.ts +70 -0
- package/dist/sdk/mcp/apps.js +154 -0
- package/dist/sdk/mcp/authorization.d.ts +134 -0
- package/dist/sdk/mcp/authorization.js +405 -0
- package/dist/sdk/mcp/interactions.d.ts +118 -0
- package/dist/sdk/mcp/interactions.js +337 -0
- package/dist/sdk/mcp/protocol.d.ts +142 -0
- package/dist/sdk/mcp/protocol.js +174 -0
- package/dist/sdk/mcp/skills.d.ts +127 -0
- package/dist/sdk/mcp/skills.js +390 -0
- package/dist/sdk/mcp/subscriptions.d.ts +65 -0
- package/dist/sdk/mcp/subscriptions.js +212 -0
- package/dist/sdk/mcp/tasks.d.ts +107 -0
- package/dist/sdk/mcp/tasks.js +431 -0
- package/dist/sdk/mcp/transport.d.ts +30 -0
- package/dist/sdk/mcp/transport.js +261 -0
- package/dist/sdk/merge/receipts.d.ts +16 -0
- package/dist/sdk/merge/receipts.js +9 -8
- package/dist/sdk/read-output-contracts.js +16 -3
- package/dist/sdk/runtime-action-aliases.js +7 -3
- package/dist/sdk/runtime-input.js +12 -4
- package/dist/sdk/runtime-primitives.d.ts +2 -2
- package/dist/sdk/runtime-primitives.js +4 -4
- package/dist/sdk/test/execution.d.ts +6 -0
- package/dist/sdk/test/execution.js +32 -3
- package/docs/AGENT_PROVENANCE_ADR.md +6 -4
- package/docs/AGENT_RUNTIME_PRIMITIVES.md +6 -5
- package/docs/CLAUDE_CODE_PLUGIN.md +12 -5
- package/docs/CLI_GRAMMAR.md +7 -1
- package/docs/COMMANDS.md +2 -2
- package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +8 -0
- package/docs/EXTENSIONS.md +36 -36
- package/docs/MCP_2026_07_28.md +160 -0
- package/docs/MCP_2026_07_28_CONFORMANCE.md +30 -0
- package/docs/MCP_REMOTE_TRANSPORT_SECURITY.md +180 -0
- package/docs/MCP_SKILLS_AND_APPS.md +107 -0
- package/docs/QUICKSTART.md +15 -15
- package/docs/README.md +5 -0
- package/docs/RELEASING.md +12 -3
- package/docs/SDK.md +22 -1
- package/docs/SDK_AGENT_SESSION_CONTEXT.md +18 -13
- package/docs/SDK_CONTEXT_INTEGRITY.md +6 -0
- package/docs/SDK_EVIDENCE_TRACEABILITY.md +9 -1
- package/docs/SDK_MCP_INTERACTIONS.md +227 -0
- package/docs/TESTING.md +4 -0
- package/docs/generated/AGENT_CAPABILITY_ROUTING.md +1 -1
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +13 -11
- package/marketplace.json +2 -2
- package/package.json +15 -11
- package/packages/pm-beads/README.md +12 -6
- package/packages/pm-beads/docs/MIGRATION.md +53 -0
- package/packages/pm-beads/extensions/beads/index.ts +8 -0
- package/packages/pm-beads/extensions/beads/runtime.ts +671 -112
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/scripts/finalize-build.mjs +1 -0
- package/sdk/public-surface.json +902 -54
- package/dist/cli-bundle/chunks/chunk-2F3LUFMW.js +0 -8
- package/dist/cli-bundle/chunks/chunk-65MHLHAA.js +0 -2
- package/dist/cli-bundle/chunks/chunk-6C7GIMIL.js +0 -13
- package/dist/cli-bundle/chunks/chunk-QKGMHGEI.js +0 -202
- package/dist/cli-bundle/chunks/chunk-T2ENPRXF.js +0 -3
- package/dist/cli-bundle/chunks/chunk-TPQIBSL2.js +0 -3
- package/dist/cli-bundle/chunks/chunk-YQMYF3YD.js +0 -35
- package/dist/cli-bundle/chunks/register-setup-LXVBRCJ3.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-42S3GGZ7.js +0 -50
- package/dist/cli-bundle/focused-chunks/chunk-7I23XGWO.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-LMKG3DFE.js +0 -5
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { PM_MCP_PROTOCOL_VERSION, type PmMcpRequestContext } from "./protocol.js";
|
|
2
|
+
/** Draft extension identifier proposed by SEP-2640. */
|
|
3
|
+
export declare const PM_MCP_SKILLS_EXTENSION: "io.modelcontextprotocol/skills";
|
|
4
|
+
/** Exact draft proposal revision implemented by pm. */
|
|
5
|
+
export declare const PM_MCP_SKILLS_DRAFT_REVISION: "SEP-2640@a3e147ca2710f68214247aecc729731ee1ae8d03";
|
|
6
|
+
/** Server-side draft capability advertised through discovery. */
|
|
7
|
+
export declare const PM_MCP_SKILLS_SERVER_CAPABILITY: Readonly<{
|
|
8
|
+
revision: "SEP-2640@a3e147ca2710f68214247aecc729731ee1ae8d03";
|
|
9
|
+
status: "draft";
|
|
10
|
+
directoryRead: true;
|
|
11
|
+
}>;
|
|
12
|
+
/** Require exact draft negotiation for a skills method. */
|
|
13
|
+
export declare function assertPmMcpSkillsCapability(context: PmMcpRequestContext, directoryRead?: boolean): void;
|
|
14
|
+
/** Security and context limits applied independently to every skill origin. */
|
|
15
|
+
export declare const PM_MCP_SKILL_LIMITS: Readonly<{
|
|
16
|
+
maxFilesPerSkill: 512;
|
|
17
|
+
maxFileBytes: number;
|
|
18
|
+
maxSkillBytes: number;
|
|
19
|
+
defaultPageSize: 20;
|
|
20
|
+
maxPageSize: 100;
|
|
21
|
+
}>;
|
|
22
|
+
/** Origin from which a skill was loaded. */
|
|
23
|
+
export type PmMcpSkillOrigin = "package" | "workspace";
|
|
24
|
+
/** One immutable file advertised by a skill. */
|
|
25
|
+
export interface PmMcpSkillResource {
|
|
26
|
+
/** Addressable skill resource URI. */
|
|
27
|
+
uri: string;
|
|
28
|
+
/** SEP-2640 SHA-256 digest of the exact bytes returned by reads. */
|
|
29
|
+
digest: string;
|
|
30
|
+
/** Exact byte length. */
|
|
31
|
+
size: number;
|
|
32
|
+
}
|
|
33
|
+
/** Discoverable skill descriptor from the current SEP draft. */
|
|
34
|
+
export interface PmMcpSkillDescriptor {
|
|
35
|
+
/** URI of the skill's mandatory SKILL.md. */
|
|
36
|
+
uri: string;
|
|
37
|
+
/** Parsed, verbatim frontmatter object. */
|
|
38
|
+
frontmatter: Record<string, unknown>;
|
|
39
|
+
/** Every bounded file in the skill directory. */
|
|
40
|
+
resources: PmMcpSkillResource[];
|
|
41
|
+
/** pm-specific compatibility and trust provenance. */
|
|
42
|
+
_meta: {
|
|
43
|
+
contractVersion: 1;
|
|
44
|
+
extensionRevision: typeof PM_MCP_SKILLS_DRAFT_REVISION;
|
|
45
|
+
origin: PmMcpSkillOrigin;
|
|
46
|
+
packageVersion: string;
|
|
47
|
+
protocolVersion: typeof PM_MCP_PROTOCOL_VERSION;
|
|
48
|
+
trust: "untrusted";
|
|
49
|
+
estimatedTokens: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Inputs for loading the canonical package skills plus repository overrides. */
|
|
53
|
+
export interface LoadPmMcpSkillsOptions {
|
|
54
|
+
/** pm package root containing `.agents/skills`. */
|
|
55
|
+
packageRoot: string;
|
|
56
|
+
/** Workspace root whose `.agents/skills` override package skills by name. */
|
|
57
|
+
workspaceRoot?: string;
|
|
58
|
+
/** Exact package version included in compatibility metadata. */
|
|
59
|
+
packageVersion: string;
|
|
60
|
+
}
|
|
61
|
+
/** List request inputs with opaque cursor pagination. */
|
|
62
|
+
export interface ListPmMcpSkillsOptions {
|
|
63
|
+
/** Opaque cursor returned by a previous page. */
|
|
64
|
+
cursor?: string;
|
|
65
|
+
/** Requested page size, bounded to 100. */
|
|
66
|
+
limit?: number;
|
|
67
|
+
}
|
|
68
|
+
/** One deterministic list page. */
|
|
69
|
+
export interface ListPmMcpSkillsResult {
|
|
70
|
+
/** Skills in lexical URI order. */
|
|
71
|
+
skills: PmMcpSkillDescriptor[];
|
|
72
|
+
/** Opaque continuation cursor when more skills exist. */
|
|
73
|
+
nextCursor?: string;
|
|
74
|
+
/** Explicit completeness signal. */
|
|
75
|
+
hasMore: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** Exact read result for one skill resource. */
|
|
78
|
+
export interface ReadPmMcpSkillResourceResult {
|
|
79
|
+
/** Resource content returned as UTF-8 text or lossless Base64 bytes. */
|
|
80
|
+
contents: Array<{
|
|
81
|
+
uri: string;
|
|
82
|
+
mimeType: "text/markdown" | "text/plain";
|
|
83
|
+
text: string;
|
|
84
|
+
_meta: {
|
|
85
|
+
digest: string;
|
|
86
|
+
origin: PmMcpSkillOrigin;
|
|
87
|
+
trust: "untrusted";
|
|
88
|
+
};
|
|
89
|
+
} | {
|
|
90
|
+
uri: string;
|
|
91
|
+
mimeType: "application/octet-stream";
|
|
92
|
+
blob: string;
|
|
93
|
+
_meta: {
|
|
94
|
+
digest: string;
|
|
95
|
+
origin: PmMcpSkillOrigin;
|
|
96
|
+
trust: "untrusted";
|
|
97
|
+
};
|
|
98
|
+
}>;
|
|
99
|
+
}
|
|
100
|
+
/** Direct-child directory listing defined by the current SEP draft. */
|
|
101
|
+
export interface ReadPmMcpSkillDirectoryResult {
|
|
102
|
+
/** Direct child file and directory resources in lexical URI order. */
|
|
103
|
+
resources: Array<{
|
|
104
|
+
uri: string;
|
|
105
|
+
name: string;
|
|
106
|
+
mimeType: "application/octet-stream" | "inode/directory" | "text/markdown" | "text/plain";
|
|
107
|
+
}>;
|
|
108
|
+
/** Opaque continuation cursor when more direct children exist. */
|
|
109
|
+
nextCursor?: string;
|
|
110
|
+
/** Explicit completeness signal for this directory page. */
|
|
111
|
+
hasMore: boolean;
|
|
112
|
+
}
|
|
113
|
+
/** Immutable in-memory registry for one request's package/workspace origins. */
|
|
114
|
+
export declare class PmMcpSkillRegistry {
|
|
115
|
+
#private;
|
|
116
|
+
private constructor();
|
|
117
|
+
/** Load package skills and apply validated workspace overrides by name. */
|
|
118
|
+
static load(options: LoadPmMcpSkillsOptions): Promise<PmMcpSkillRegistry>;
|
|
119
|
+
/** List skills in deterministic pages without loading file bodies. */
|
|
120
|
+
list(options?: ListPmMcpSkillsOptions): ListPmMcpSkillsResult;
|
|
121
|
+
/** Get one skill descriptor by its SKILL.md URI. */
|
|
122
|
+
get(uri: string): PmMcpSkillDescriptor;
|
|
123
|
+
/** Read one digest-bound skill resource without following filesystem links. */
|
|
124
|
+
read(uri: string): ReadPmMcpSkillResourceResult;
|
|
125
|
+
/** List one directory's direct children with opaque cursor pagination. */
|
|
126
|
+
readDirectory(uri: string, options?: ListPmMcpSkillsOptions): ReadPmMcpSkillDirectoryResult;
|
|
127
|
+
}
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/mcp/skills
|
|
3
|
+
*
|
|
4
|
+
* Implements pm's draft Skills over MCP registry with bounded filesystem
|
|
5
|
+
* discovery, per-file digests, origin provenance, pagination, and fail-closed
|
|
6
|
+
* revision negotiation.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5f60bc89-c81b-57ee-a8f2-0d0b18d0af1b")}catch(e){}}();
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
import { lstat, readdir, readFile } from "node:fs/promises";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { parseDocument } from "yaml";
|
|
14
|
+
import { isFileAbsentError } from "../../core/fs/fs-utils.js";
|
|
15
|
+
import { PM_MCP_ERROR_CODES, PM_MCP_PROTOCOL_VERSION, PmMcpProtocolError, isMcpRecord, } from "./protocol.js";
|
|
16
|
+
/** Draft extension identifier proposed by SEP-2640. */
|
|
17
|
+
export const PM_MCP_SKILLS_EXTENSION = "io.modelcontextprotocol/skills";
|
|
18
|
+
/** Exact draft proposal revision implemented by pm. */
|
|
19
|
+
export const PM_MCP_SKILLS_DRAFT_REVISION = "SEP-2640@a3e147ca2710f68214247aecc729731ee1ae8d03";
|
|
20
|
+
/** Server-side draft capability advertised through discovery. */
|
|
21
|
+
export const PM_MCP_SKILLS_SERVER_CAPABILITY = Object.freeze({
|
|
22
|
+
revision: PM_MCP_SKILLS_DRAFT_REVISION,
|
|
23
|
+
status: "draft",
|
|
24
|
+
directoryRead: true,
|
|
25
|
+
});
|
|
26
|
+
/** Require exact draft negotiation for a skills method. */
|
|
27
|
+
export function assertPmMcpSkillsCapability(context, directoryRead = false) {
|
|
28
|
+
const extensions = context.clientCapabilities.extensions;
|
|
29
|
+
const declaration = isMcpRecord(extensions)
|
|
30
|
+
? extensions[PM_MCP_SKILLS_EXTENSION]
|
|
31
|
+
: undefined;
|
|
32
|
+
if (!isMcpRecord(declaration) ||
|
|
33
|
+
declaration.revision !== PM_MCP_SKILLS_DRAFT_REVISION ||
|
|
34
|
+
(directoryRead && declaration.directoryRead !== true)) {
|
|
35
|
+
throw new PmMcpProtocolError("Missing or incompatible Skills over MCP draft capability", PM_MCP_ERROR_CODES.missingRequiredClientCapability, {
|
|
36
|
+
requiredCapabilities: {
|
|
37
|
+
extensions: {
|
|
38
|
+
[PM_MCP_SKILLS_EXTENSION]: PM_MCP_SKILLS_SERVER_CAPABILITY,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Security and context limits applied independently to every skill origin. */
|
|
45
|
+
export const PM_MCP_SKILL_LIMITS = Object.freeze({
|
|
46
|
+
maxFilesPerSkill: 512,
|
|
47
|
+
maxFileBytes: 16 * 1024 * 1024,
|
|
48
|
+
maxSkillBytes: 16 * 1024 * 1024,
|
|
49
|
+
defaultPageSize: 20,
|
|
50
|
+
maxPageSize: 100,
|
|
51
|
+
});
|
|
52
|
+
const MAX_MCP_SKILLS_PER_ORIGIN = 100;
|
|
53
|
+
const MAX_MCP_SKILL_ORIGIN_BYTES = 32 * 1024 * 1024;
|
|
54
|
+
const SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
55
|
+
const SKILL_PAGE_SIZES = new Set(Array.from({ length: PM_MCP_SKILL_LIMITS.maxPageSize }, (_, index) => index + 1));
|
|
56
|
+
function skillError(message, data) {
|
|
57
|
+
throw new PmMcpProtocolError(message, -32602, data);
|
|
58
|
+
}
|
|
59
|
+
function skillFileMimeType(name, bytes) {
|
|
60
|
+
try {
|
|
61
|
+
new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
62
|
+
return name.endsWith(".md") ? "text/markdown" : "text/plain";
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return "application/octet-stream";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function parseSkillFrontmatter(content, source) {
|
|
69
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/u.exec(content);
|
|
70
|
+
if (!match)
|
|
71
|
+
skillError(`Skill ${source} is missing YAML frontmatter.`);
|
|
72
|
+
const document = parseDocument(match[1], {
|
|
73
|
+
prettyErrors: false,
|
|
74
|
+
strict: true,
|
|
75
|
+
uniqueKeys: true,
|
|
76
|
+
});
|
|
77
|
+
if (document.errors.length > 0) {
|
|
78
|
+
skillError(`Skill ${source} has invalid YAML frontmatter.`, {
|
|
79
|
+
errors: document.errors.map((error) => error.message),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
let value;
|
|
83
|
+
try {
|
|
84
|
+
value = document.toJS({ maxAliasCount: 0 });
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
skillError(`Skill ${source} has unsupported YAML aliases.`, {
|
|
88
|
+
error: String(error),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
92
|
+
skillError(`Skill ${source} frontmatter must be an object.`);
|
|
93
|
+
}
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
async function readBoundedSkillFile(filePath, relative, size, budget) {
|
|
97
|
+
if (size > PM_MCP_SKILL_LIMITS.maxFileBytes) {
|
|
98
|
+
skillError(`Skill resource exceeds the per-file limit: ${relative}.`);
|
|
99
|
+
}
|
|
100
|
+
budget.files += 1;
|
|
101
|
+
if (budget.files > PM_MCP_SKILL_LIMITS.maxFilesPerSkill) {
|
|
102
|
+
skillError(`Skill exceeds ${PM_MCP_SKILL_LIMITS.maxFilesPerSkill} files.`);
|
|
103
|
+
}
|
|
104
|
+
budget.skillBytes += size;
|
|
105
|
+
if (budget.skillBytes > PM_MCP_SKILL_LIMITS.maxSkillBytes) {
|
|
106
|
+
skillError(`Skill exceeds the aggregate byte limit: ${relative}.`);
|
|
107
|
+
}
|
|
108
|
+
budget.originBytes.value += size;
|
|
109
|
+
if (budget.originBytes.value > MAX_MCP_SKILL_ORIGIN_BYTES) {
|
|
110
|
+
skillError(`Skill origin exceeds the aggregate byte limit: ${relative}.`);
|
|
111
|
+
}
|
|
112
|
+
return readFile(filePath);
|
|
113
|
+
}
|
|
114
|
+
async function collectSkillFiles(root, relative, budget) {
|
|
115
|
+
const directory = path.join(root, relative);
|
|
116
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
117
|
+
const files = [];
|
|
118
|
+
for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
|
|
119
|
+
const childRelative = path.posix.join(relative.split(path.sep).join("/"), entry.name);
|
|
120
|
+
const childPath = path.join(root, ...childRelative.split("/"));
|
|
121
|
+
const stats = await lstat(childPath);
|
|
122
|
+
if (stats.isSymbolicLink()) {
|
|
123
|
+
skillError(`Skill resource must not be a symbolic link: ${childRelative}.`);
|
|
124
|
+
}
|
|
125
|
+
if (stats.isDirectory()) {
|
|
126
|
+
files.push(...(await collectSkillFiles(root, childRelative, budget)));
|
|
127
|
+
}
|
|
128
|
+
else if (stats.isFile()) {
|
|
129
|
+
files.push({
|
|
130
|
+
relative: childRelative,
|
|
131
|
+
bytes: await readBoundedSkillFile(childPath, childRelative, stats.size, budget),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
skillError(`Skill resource must be a regular file or directory: ${childRelative}.`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return files;
|
|
139
|
+
}
|
|
140
|
+
async function loadSkillOrigin(skillsRoot, origin, packageVersion) {
|
|
141
|
+
const skills = new Map();
|
|
142
|
+
let entries;
|
|
143
|
+
try {
|
|
144
|
+
entries = await readdir(skillsRoot, { withFileTypes: true });
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (isFileAbsentError(error)) {
|
|
148
|
+
return skills;
|
|
149
|
+
}
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
const skillEntries = entries
|
|
153
|
+
.filter((entry) => entry.isDirectory() && SKILL_NAME_PATTERN.test(entry.name))
|
|
154
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
155
|
+
if (skillEntries.length > MAX_MCP_SKILLS_PER_ORIGIN) {
|
|
156
|
+
skillError(`Skill origin exceeds ${MAX_MCP_SKILLS_PER_ORIGIN} directories.`);
|
|
157
|
+
}
|
|
158
|
+
const originBytes = { value: 0 };
|
|
159
|
+
for (const entry of skillEntries) {
|
|
160
|
+
const files = await collectSkillFiles(path.join(skillsRoot, entry.name), "", {
|
|
161
|
+
files: 0,
|
|
162
|
+
skillBytes: 0,
|
|
163
|
+
originBytes,
|
|
164
|
+
});
|
|
165
|
+
const totalBytes = files.reduce((sum, file) => sum + file.bytes.byteLength, 0);
|
|
166
|
+
const main = files.find((file) => file.relative === "SKILL.md");
|
|
167
|
+
if (!main)
|
|
168
|
+
continue;
|
|
169
|
+
const frontmatter = parseSkillFrontmatter(main.bytes.toString("utf8"), entry.name);
|
|
170
|
+
if (frontmatter.name !== entry.name) {
|
|
171
|
+
skillError(`Skill directory ${entry.name} must match frontmatter name.`, {
|
|
172
|
+
actual: frontmatter.name ?? null,
|
|
173
|
+
expected: entry.name,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
if (typeof frontmatter.description !== "string" ||
|
|
177
|
+
frontmatter.description.trim().length === 0) {
|
|
178
|
+
skillError(`Skill ${entry.name} requires a non-empty frontmatter description.`, {
|
|
179
|
+
required: ["description"],
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const resources = files.map((file) => ({
|
|
183
|
+
uri: `skill://${entry.name}/${file.relative}`,
|
|
184
|
+
digest: `sha256:${createHash("sha256").update(file.bytes).digest("hex")}`,
|
|
185
|
+
size: file.bytes.byteLength,
|
|
186
|
+
}));
|
|
187
|
+
const fingerprint = createHash("sha256")
|
|
188
|
+
.update(resources
|
|
189
|
+
.map((resource) => `${resource.uri}:${resource.digest}`)
|
|
190
|
+
.join("\n"))
|
|
191
|
+
.digest("hex");
|
|
192
|
+
skills.set(entry.name, {
|
|
193
|
+
uri: `skill://${entry.name}/SKILL.md`,
|
|
194
|
+
frontmatter,
|
|
195
|
+
resources,
|
|
196
|
+
_meta: {
|
|
197
|
+
contractVersion: 1,
|
|
198
|
+
extensionRevision: PM_MCP_SKILLS_DRAFT_REVISION,
|
|
199
|
+
origin,
|
|
200
|
+
packageVersion,
|
|
201
|
+
protocolVersion: PM_MCP_PROTOCOL_VERSION,
|
|
202
|
+
trust: "untrusted",
|
|
203
|
+
estimatedTokens: Math.ceil(totalBytes / 4),
|
|
204
|
+
},
|
|
205
|
+
files: new Map(files.map((file) => [file.relative, file.bytes])),
|
|
206
|
+
fingerprint,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return skills;
|
|
210
|
+
}
|
|
211
|
+
function projectSkill(skill) {
|
|
212
|
+
const { files: _files, fingerprint: _fingerprint, ...descriptor } = skill;
|
|
213
|
+
return descriptor;
|
|
214
|
+
}
|
|
215
|
+
/** Immutable in-memory registry for one request's package/workspace origins. */
|
|
216
|
+
export class PmMcpSkillRegistry {
|
|
217
|
+
#skills;
|
|
218
|
+
#fingerprint;
|
|
219
|
+
constructor(skills) {
|
|
220
|
+
this.#skills = skills;
|
|
221
|
+
this.#fingerprint = createHash("sha256")
|
|
222
|
+
.update([...skills.entries()]
|
|
223
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
224
|
+
.map(([name, skill]) => `${name}:${skill.fingerprint}`)
|
|
225
|
+
.join("\n"))
|
|
226
|
+
.digest("hex")
|
|
227
|
+
.slice(0, 16);
|
|
228
|
+
}
|
|
229
|
+
/** Decode one registry-bound cursor for a list or directory scope. */
|
|
230
|
+
#decodeCursor(cursor, scope) {
|
|
231
|
+
if (!cursor)
|
|
232
|
+
return 0;
|
|
233
|
+
try {
|
|
234
|
+
const parsed = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
235
|
+
if (typeof parsed !== "object" ||
|
|
236
|
+
parsed === null ||
|
|
237
|
+
!("fingerprint" in parsed) ||
|
|
238
|
+
parsed.fingerprint !== this.#fingerprint ||
|
|
239
|
+
!("scope" in parsed) ||
|
|
240
|
+
parsed.scope !== scope ||
|
|
241
|
+
!("offset" in parsed) ||
|
|
242
|
+
!Number.isInteger(parsed.offset) ||
|
|
243
|
+
Number(parsed.offset) < 0) {
|
|
244
|
+
skillError("Skill cursor is invalid or stale.");
|
|
245
|
+
}
|
|
246
|
+
return Number(parsed.offset);
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
if (error instanceof PmMcpProtocolError)
|
|
250
|
+
throw error;
|
|
251
|
+
return skillError("Skill cursor is invalid or stale.");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/** Encode one registry-bound continuation cursor. */
|
|
255
|
+
#encodeCursor(offset, scope) {
|
|
256
|
+
return Buffer.from(JSON.stringify({ fingerprint: this.#fingerprint, offset, scope })).toString("base64url");
|
|
257
|
+
}
|
|
258
|
+
/** Load package skills and apply validated workspace overrides by name. */
|
|
259
|
+
static async load(options) {
|
|
260
|
+
const packaged = await loadSkillOrigin(path.join(options.packageRoot, ".agents", "skills"), "package", options.packageVersion);
|
|
261
|
+
if (options.workspaceRoot) {
|
|
262
|
+
const packageSkillsRoot = path.resolve(options.packageRoot, ".agents", "skills");
|
|
263
|
+
const workspaceSkillsRoot = path.resolve(options.workspaceRoot, ".agents", "skills");
|
|
264
|
+
if (workspaceSkillsRoot !== packageSkillsRoot) {
|
|
265
|
+
const overrides = await loadSkillOrigin(workspaceSkillsRoot, "workspace", options.packageVersion);
|
|
266
|
+
for (const [name, skill] of overrides)
|
|
267
|
+
packaged.set(name, skill);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return new PmMcpSkillRegistry(packaged);
|
|
271
|
+
}
|
|
272
|
+
/** List skills in deterministic pages without loading file bodies. */
|
|
273
|
+
list(options = {}) {
|
|
274
|
+
const limit = options.limit ?? PM_MCP_SKILL_LIMITS.defaultPageSize;
|
|
275
|
+
if (!SKILL_PAGE_SIZES.has(limit)) {
|
|
276
|
+
skillError(`Skill list limit must be an integer from 1 to ${PM_MCP_SKILL_LIMITS.maxPageSize}.`);
|
|
277
|
+
}
|
|
278
|
+
const offset = this.#decodeCursor(options.cursor, "skills/list");
|
|
279
|
+
const ordered = [...this.#skills.values()].sort((left, right) => left.uri.localeCompare(right.uri));
|
|
280
|
+
const page = ordered.slice(offset, offset + limit);
|
|
281
|
+
const nextOffset = offset + page.length;
|
|
282
|
+
const hasMore = nextOffset < ordered.length;
|
|
283
|
+
return {
|
|
284
|
+
skills: page.map(projectSkill),
|
|
285
|
+
hasMore,
|
|
286
|
+
...(hasMore
|
|
287
|
+
? {
|
|
288
|
+
nextCursor: this.#encodeCursor(nextOffset, "skills/list"),
|
|
289
|
+
}
|
|
290
|
+
: {}),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/** Get one skill descriptor by its SKILL.md URI. */
|
|
294
|
+
get(uri) {
|
|
295
|
+
const match = /^skill:\/\/([a-z0-9]+(?:-[a-z0-9]+)*)\/SKILL\.md$/u.exec(uri);
|
|
296
|
+
const skill = match ? this.#skills.get(match[1]) : undefined;
|
|
297
|
+
if (!skill)
|
|
298
|
+
skillError(`Unknown pm MCP skill: ${uri}.`, { field: "uri" });
|
|
299
|
+
return projectSkill(skill);
|
|
300
|
+
}
|
|
301
|
+
/** Read one digest-bound skill resource without following filesystem links. */
|
|
302
|
+
read(uri) {
|
|
303
|
+
const match = /^skill:\/\/([a-z0-9]+(?:-[a-z0-9]+)*)\/(.+)$/u.exec(uri);
|
|
304
|
+
const skill = match ? this.#skills.get(match[1]) : undefined;
|
|
305
|
+
const relative = match?.[2] ?? "";
|
|
306
|
+
const bytes = skill && relative ? skill.files.get(relative) : undefined;
|
|
307
|
+
const resource = skill?.resources.find((candidate) => candidate.uri === uri);
|
|
308
|
+
if (!skill || !bytes || !resource) {
|
|
309
|
+
skillError(`Unknown pm MCP skill resource: ${uri}.`, { field: "uri" });
|
|
310
|
+
}
|
|
311
|
+
const metadata = {
|
|
312
|
+
digest: resource.digest,
|
|
313
|
+
origin: skill._meta.origin,
|
|
314
|
+
trust: "untrusted",
|
|
315
|
+
};
|
|
316
|
+
const mimeType = skillFileMimeType(relative, bytes);
|
|
317
|
+
if (mimeType !== "application/octet-stream") {
|
|
318
|
+
return {
|
|
319
|
+
contents: [
|
|
320
|
+
{
|
|
321
|
+
uri,
|
|
322
|
+
mimeType,
|
|
323
|
+
text: bytes.toString("utf8"),
|
|
324
|
+
_meta: metadata,
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
contents: [
|
|
331
|
+
{
|
|
332
|
+
uri,
|
|
333
|
+
mimeType,
|
|
334
|
+
blob: bytes.toString("base64"),
|
|
335
|
+
_meta: metadata,
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
/** List one directory's direct children with opaque cursor pagination. */
|
|
341
|
+
readDirectory(uri, options = {}) {
|
|
342
|
+
const match = /^skill:\/\/([a-z0-9]+(?:-[a-z0-9]+)*)(?:\/(.+))?$/u.exec(uri);
|
|
343
|
+
const skill = match ? this.#skills.get(match[1]) : undefined;
|
|
344
|
+
if (!skill)
|
|
345
|
+
skillError(`Unknown pm MCP skill directory: ${uri}.`, { field: "uri" });
|
|
346
|
+
const directory = (match?.[2] ?? "").replace(/\/$/u, "");
|
|
347
|
+
const prefix = directory.length > 0 ? `${directory}/` : "";
|
|
348
|
+
const base = `skill://${match[1]}`;
|
|
349
|
+
const children = new Map();
|
|
350
|
+
for (const resource of skill.resources) {
|
|
351
|
+
const relative = resource.uri.slice(`${base}/`.length);
|
|
352
|
+
if (!relative.startsWith(prefix))
|
|
353
|
+
continue;
|
|
354
|
+
const remainder = relative.slice(prefix.length);
|
|
355
|
+
const [name, ...descendants] = remainder.split("/");
|
|
356
|
+
const childUri = `${base}/${prefix}${name}`;
|
|
357
|
+
const childBytes = skill.files.get(`${prefix}${name}`);
|
|
358
|
+
children.set(name, {
|
|
359
|
+
uri: childUri,
|
|
360
|
+
name,
|
|
361
|
+
mimeType: descendants.length > 0
|
|
362
|
+
? "inode/directory"
|
|
363
|
+
: skillFileMimeType(name, childBytes),
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
if (directory.length > 0 && children.size === 0) {
|
|
367
|
+
skillError(`Unknown pm MCP skill directory: ${uri}.`, { field: "uri" });
|
|
368
|
+
}
|
|
369
|
+
const limit = options.limit ?? PM_MCP_SKILL_LIMITS.maxPageSize;
|
|
370
|
+
if (!SKILL_PAGE_SIZES.has(limit)) {
|
|
371
|
+
skillError(`Skill directory limit must be an integer from 1 to ${PM_MCP_SKILL_LIMITS.maxPageSize}.`);
|
|
372
|
+
}
|
|
373
|
+
const offset = this.#decodeCursor(options.cursor, uri);
|
|
374
|
+
const ordered = [...children.values()].sort((left, right) => left.uri.localeCompare(right.uri));
|
|
375
|
+
const resources = ordered.slice(offset, offset + limit);
|
|
376
|
+
const nextOffset = offset + resources.length;
|
|
377
|
+
const hasMore = nextOffset < ordered.length;
|
|
378
|
+
return {
|
|
379
|
+
resources,
|
|
380
|
+
hasMore,
|
|
381
|
+
...(hasMore
|
|
382
|
+
? {
|
|
383
|
+
nextCursor: this.#encodeCursor(nextOffset, uri),
|
|
384
|
+
}
|
|
385
|
+
: {}),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=skills.js.map
|
|
390
|
+
//# debugId=5f60bc89-c81b-57ee-a8f2-0d0b18d0af1b
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/mcp/subscriptions
|
|
3
|
+
*
|
|
4
|
+
* Implements transport-neutral MCP 2026-07-28 subscription filtering,
|
|
5
|
+
* acknowledgment, notification correlation, and graceful closure.
|
|
6
|
+
*/
|
|
7
|
+
import { type PmMcpImplementation, type PmMcpServerCapabilities } from "./protocol.js";
|
|
8
|
+
/** Notification/result metadata key that correlates a subscription stream. */
|
|
9
|
+
export declare const PM_MCP_SUBSCRIPTION_ID_META_KEY = "io.modelcontextprotocol/subscriptionId";
|
|
10
|
+
/** JSON-RPC identifiers permitted for long-lived subscription requests. */
|
|
11
|
+
export type PmMcpSubscriptionId = string | number;
|
|
12
|
+
/** Notification families a client may opt into on one listen stream. */
|
|
13
|
+
export interface PmMcpSubscriptionFilter {
|
|
14
|
+
/** Receive notifications when the tool list changes. */
|
|
15
|
+
toolsListChanged?: boolean;
|
|
16
|
+
/** Receive notifications when the prompt list changes. */
|
|
17
|
+
promptsListChanged?: boolean;
|
|
18
|
+
/** Receive notifications when the resource list changes. */
|
|
19
|
+
resourcesListChanged?: boolean;
|
|
20
|
+
/** Receive updates for these exact resource URIs. */
|
|
21
|
+
resourceSubscriptions?: string[];
|
|
22
|
+
}
|
|
23
|
+
/** One JSON-RPC notification emitted by a subscription. */
|
|
24
|
+
export interface PmMcpSubscriptionNotification {
|
|
25
|
+
/** JSON-RPC revision. */
|
|
26
|
+
jsonrpc: "2.0";
|
|
27
|
+
/** Notification method. */
|
|
28
|
+
method: string;
|
|
29
|
+
/** Correlated notification parameters. */
|
|
30
|
+
params: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
/** Sink used by stdio and HTTP adapters to write subscription messages. */
|
|
33
|
+
export type PmMcpSubscriptionSink = (notification: PmMcpSubscriptionNotification) => void | Promise<void>;
|
|
34
|
+
/** Validate and clone one subscription notification filter. */
|
|
35
|
+
export declare function parseMcpSubscriptionFilter(value: unknown): PmMcpSubscriptionFilter;
|
|
36
|
+
/** Intersect a requested filter with notification capabilities the server advertises. */
|
|
37
|
+
export declare function resolveMcpAcknowledgedSubscriptionFilter(requested: PmMcpSubscriptionFilter, capabilities: PmMcpServerCapabilities): PmMcpSubscriptionFilter;
|
|
38
|
+
/** Manage concurrent stateless subscriptions without retaining client sessions. */
|
|
39
|
+
export declare class PmMcpSubscriptionRegistry {
|
|
40
|
+
#private;
|
|
41
|
+
/** Create a registry shared by one concrete transport process. */
|
|
42
|
+
constructor(input: {
|
|
43
|
+
capabilities: PmMcpServerCapabilities;
|
|
44
|
+
serverInfo: PmMcpImplementation;
|
|
45
|
+
});
|
|
46
|
+
/** Number of currently open request-scoped subscription streams. */
|
|
47
|
+
get size(): number;
|
|
48
|
+
/** Open a subscription and emit its required first acknowledgment. */
|
|
49
|
+
open(input: {
|
|
50
|
+
id: PmMcpSubscriptionId;
|
|
51
|
+
notifications: unknown;
|
|
52
|
+
sink: PmMcpSubscriptionSink;
|
|
53
|
+
}): Promise<PmMcpSubscriptionFilter>;
|
|
54
|
+
/** Emit one list-change notification only to streams that opted into it. */
|
|
55
|
+
emitListChanged(family: "tools" | "prompts" | "resources"): Promise<number>;
|
|
56
|
+
/** Emit a resource update only to streams that opted into the exact URI. */
|
|
57
|
+
emitResourceUpdated(uri: string): Promise<number>;
|
|
58
|
+
/** Gracefully close one subscription and return its final modern result. */
|
|
59
|
+
close(id: PmMcpSubscriptionId): Record<string, unknown> | undefined;
|
|
60
|
+
/** Gracefully close every stream and preserve stable creation order. */
|
|
61
|
+
closeAll(): Array<{
|
|
62
|
+
id: PmMcpSubscriptionId;
|
|
63
|
+
result: Record<string, unknown>;
|
|
64
|
+
}>;
|
|
65
|
+
}
|