@modootoday/pmcp 0.9.2 → 0.11.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/README.md +308 -2
- package/dist/attachment-tU5FZrgZ.d.ts +17 -0
- package/dist/cli.js +8378 -1674
- package/dist/config-CJ43_oBS.d.ts +49 -0
- package/dist/embed-BBhv3y5x.d.ts +53 -0
- package/dist/encoder-DGRy9skC.d.ts +36 -0
- package/dist/hook-spec-PRSnYGLV.d.ts +10 -0
- package/dist/http.d.ts +7 -38
- package/dist/http.js +2115 -14
- package/dist/index.d.ts +44 -46
- package/dist/index.js +4550 -74
- package/dist/mailbox/index.d.ts +44 -0
- package/dist/mailbox/index.js +1896 -0
- package/dist/project/hook-adapter.d.ts +11 -0
- package/dist/project/hook-adapter.js +191 -0
- package/dist/{server-C9eO6LMI.d.ts → server-CwWcRjqz.d.ts} +122 -2
- package/dist/service-qpCsOXkQ.d.ts +116 -0
- package/dist/stdio.d.ts +10 -4
- package/dist/stdio.js +3052 -6
- package/package.json +5 -1
- package/dist/catalog-BU5VLLyd.d.ts +0 -121
- package/dist/chunk-A5NOHVHN.js +0 -1805
- package/dist/chunk-CMZ7OTQD.js +0 -134
- package/dist/chunk-D3OZVMHN.js +0 -1142
- package/dist/chunk-EIHMCKY5.js +0 -41
- package/dist/chunk-KYW3VP3L.js +0 -160
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { S as ShellHookSpec, H as HookTool } from '../hook-spec-PRSnYGLV.js';
|
|
2
|
+
|
|
3
|
+
type Decision = {
|
|
4
|
+
readonly decision: "allow" | "deny";
|
|
5
|
+
readonly reason?: string;
|
|
6
|
+
};
|
|
7
|
+
declare function guardPath(root: string, command: readonly string[]): string;
|
|
8
|
+
declare function evaluateShellHook(root: string, policy: ShellHookSpec, tool: HookTool, payload: unknown): Decision;
|
|
9
|
+
declare function nativeHookDecision(tool: HookTool, decision: Decision): object;
|
|
10
|
+
|
|
11
|
+
export { evaluateShellHook, guardPath, nativeHookDecision };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// src/project/hook-adapter.ts
|
|
2
|
+
import { spawnSync } from "child_process";
|
|
3
|
+
import { createHash } from "crypto";
|
|
4
|
+
import { existsSync, readFileSync, realpathSync, statSync } from "fs";
|
|
5
|
+
import { dirname, isAbsolute, relative, resolve } from "path";
|
|
6
|
+
var denied = () => ({
|
|
7
|
+
decision: "deny",
|
|
8
|
+
reason: "Shell guard failed validation or execution"
|
|
9
|
+
});
|
|
10
|
+
function guardPath(root, command) {
|
|
11
|
+
const script = command[0]?.startsWith(".agents/guards/") ? command[0] : command[1];
|
|
12
|
+
if (!script?.startsWith(".agents/guards/")) {
|
|
13
|
+
throw new Error("Hook command must execute a script under .agents/guards/");
|
|
14
|
+
}
|
|
15
|
+
const absolute = resolve(root, script);
|
|
16
|
+
const base = resolve(root, ".agents/guards");
|
|
17
|
+
const inside = relative(base, absolute);
|
|
18
|
+
if (isAbsolute(inside) || inside === ".." || inside.startsWith("../") || inside.startsWith("..\\")) {
|
|
19
|
+
throw new Error("Hook guard must stay under .agents/guards/");
|
|
20
|
+
}
|
|
21
|
+
if (!existsSync(absolute) || !statSync(absolute).isFile()) {
|
|
22
|
+
throw new Error("Hook guard script must exist");
|
|
23
|
+
}
|
|
24
|
+
const actual = relative(base, realpathSync(absolute));
|
|
25
|
+
if (isAbsolute(actual) || actual === ".." || actual.startsWith("../") || actual.startsWith("..\\")) {
|
|
26
|
+
throw new Error("Hook guard cannot resolve outside .agents/guards/");
|
|
27
|
+
}
|
|
28
|
+
return absolute;
|
|
29
|
+
}
|
|
30
|
+
function object(value) {
|
|
31
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
function scalar(value) {
|
|
37
|
+
if (typeof value !== "string") {
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
if (value.startsWith('"')) {
|
|
41
|
+
try {
|
|
42
|
+
const parsed = JSON.parse(value);
|
|
43
|
+
if (typeof parsed === "string") {
|
|
44
|
+
return parsed;
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
function evaluateShellHook(root, policy, tool, payload) {
|
|
53
|
+
try {
|
|
54
|
+
const value = object(payload);
|
|
55
|
+
const call = object(value["toolCall"]);
|
|
56
|
+
const input = tool === "antigravity" ? object(call["args"]) : object(value["tool_input"]);
|
|
57
|
+
const name = tool === "antigravity" ? call["name"] : value["tool_name"];
|
|
58
|
+
const shellNames = {
|
|
59
|
+
codex: ["Bash", "exec_command", "shell", "shell_command"],
|
|
60
|
+
gemini: ["run_shell_command"],
|
|
61
|
+
antigravity: ["run_command"]
|
|
62
|
+
};
|
|
63
|
+
if (typeof name !== "string") {
|
|
64
|
+
return denied();
|
|
65
|
+
}
|
|
66
|
+
if (!shellNames[tool].includes(name)) {
|
|
67
|
+
return { decision: "allow" };
|
|
68
|
+
}
|
|
69
|
+
const command = scalar(
|
|
70
|
+
input[tool === "antigravity" ? "CommandLine" : "command"]
|
|
71
|
+
);
|
|
72
|
+
if (command === void 0 || command.length > 65536) {
|
|
73
|
+
return denied();
|
|
74
|
+
}
|
|
75
|
+
const cwd = scalar(input["Cwd"]) ?? scalar(value["cwd"]) ?? root;
|
|
76
|
+
const args = [...policy.command];
|
|
77
|
+
const script = guardPath(root, args);
|
|
78
|
+
if (args[0]?.startsWith(".agents/guards/")) {
|
|
79
|
+
args[0] = script;
|
|
80
|
+
} else {
|
|
81
|
+
args[1] = script;
|
|
82
|
+
}
|
|
83
|
+
const executable = args.shift();
|
|
84
|
+
if (!executable) {
|
|
85
|
+
return denied();
|
|
86
|
+
}
|
|
87
|
+
const result = spawnSync(executable, args, {
|
|
88
|
+
cwd: root,
|
|
89
|
+
env: { PATH: process.env["PATH"], LANG: "C.UTF-8" },
|
|
90
|
+
input: JSON.stringify({
|
|
91
|
+
runtime: tool,
|
|
92
|
+
event: "before_shell",
|
|
93
|
+
command,
|
|
94
|
+
cwd
|
|
95
|
+
}),
|
|
96
|
+
encoding: "utf8",
|
|
97
|
+
timeout: policy.timeoutMs,
|
|
98
|
+
killSignal: "SIGKILL",
|
|
99
|
+
maxBuffer: 65536
|
|
100
|
+
});
|
|
101
|
+
if (result.status !== 0 || result.error) {
|
|
102
|
+
return denied();
|
|
103
|
+
}
|
|
104
|
+
const response = object(JSON.parse(result.stdout));
|
|
105
|
+
if (Object.keys(response).some(
|
|
106
|
+
(key) => !["decision", "reason"].includes(key)
|
|
107
|
+
) || !["allow", "deny"].includes(String(response["decision"])) || response["reason"] !== void 0 && typeof response["reason"] !== "string") {
|
|
108
|
+
return denied();
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
decision: response["decision"],
|
|
112
|
+
...typeof response["reason"] === "string" ? { reason: response["reason"].slice(0, 2e3) } : {}
|
|
113
|
+
};
|
|
114
|
+
} catch {
|
|
115
|
+
return denied();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function nativeHookDecision(tool, decision) {
|
|
119
|
+
if (tool === "codex") {
|
|
120
|
+
return {
|
|
121
|
+
hookSpecificOutput: {
|
|
122
|
+
hookEventName: "PreToolUse",
|
|
123
|
+
permissionDecision: decision.decision,
|
|
124
|
+
...decision.reason ? { permissionDecisionReason: decision.reason } : {}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return decision;
|
|
129
|
+
}
|
|
130
|
+
async function main() {
|
|
131
|
+
const [, , , tool, file, integrity] = process.argv;
|
|
132
|
+
const supported = tool === "codex" || tool === "gemini" || tool === "antigravity";
|
|
133
|
+
if (!supported) {
|
|
134
|
+
process.exitCode = 2;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
let decision = denied();
|
|
138
|
+
try {
|
|
139
|
+
if (!file) {
|
|
140
|
+
throw new Error("Missing hook policy");
|
|
141
|
+
}
|
|
142
|
+
const bytes = readFileSync(file);
|
|
143
|
+
const adapter = readFileSync(process.argv[1]);
|
|
144
|
+
const actual = createHash("sha256").update(adapter).update(bytes).digest("hex");
|
|
145
|
+
if (actual !== integrity) {
|
|
146
|
+
throw new Error("Hook integrity mismatch");
|
|
147
|
+
}
|
|
148
|
+
const policy = JSON.parse(bytes.toString("utf8"));
|
|
149
|
+
if (!policy.targets.includes(tool)) {
|
|
150
|
+
throw new Error("Hook target mismatch");
|
|
151
|
+
}
|
|
152
|
+
const chunks = [];
|
|
153
|
+
let size = 0;
|
|
154
|
+
for await (const chunk of process.stdin) {
|
|
155
|
+
const bytes2 = Buffer.from(chunk);
|
|
156
|
+
size += bytes2.length;
|
|
157
|
+
if (size > 131072) {
|
|
158
|
+
throw new Error("Hook input too large");
|
|
159
|
+
}
|
|
160
|
+
chunks.push(bytes2);
|
|
161
|
+
}
|
|
162
|
+
const root = resolve(dirname(file), "../..");
|
|
163
|
+
const guardSha256 = createHash("sha256").update(readFileSync(guardPath(root, policy.command))).digest("hex");
|
|
164
|
+
if (policy.contractVersion !== 1 || guardSha256 !== policy.guardSha256) {
|
|
165
|
+
throw new Error(
|
|
166
|
+
"Hook guard source changed; reproject and review native trust"
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
decision = evaluateShellHook(
|
|
170
|
+
root,
|
|
171
|
+
policy,
|
|
172
|
+
tool,
|
|
173
|
+
JSON.parse(Buffer.concat(chunks).toString("utf8"))
|
|
174
|
+
);
|
|
175
|
+
} catch {
|
|
176
|
+
decision = denied();
|
|
177
|
+
}
|
|
178
|
+
process.stdout.write(
|
|
179
|
+
`${JSON.stringify(nativeHookDecision(tool, decision))}
|
|
180
|
+
`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
if (process.argv[2] === "--pmcp-shell-hook") {
|
|
184
|
+
await main();
|
|
185
|
+
}
|
|
186
|
+
export {
|
|
187
|
+
evaluateShellHook,
|
|
188
|
+
guardPath,
|
|
189
|
+
nativeHookDecision
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=hook-adapter.js.map
|
|
@@ -1,6 +1,125 @@
|
|
|
1
|
-
import { S as SkillEntry, M as MetadataValue, C as CatalogOptions, A as AssetKind } from './catalog-BU5VLLyd.js';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
|
|
3
|
+
/**
|
|
4
|
+
* SKILL.md frontmatter, read as YAML the way a host reads it, and checked against
|
|
5
|
+
* the Agent Skills specification (https://agentskills.io/specification).
|
|
6
|
+
*/
|
|
7
|
+
type MetadataLeaf = string | readonly string[];
|
|
8
|
+
/** A metadata value: a leaf, or a map of leaves one level below the metadata key. */
|
|
9
|
+
type MetadataValue = MetadataLeaf | {
|
|
10
|
+
readonly [key: string]: MetadataLeaf;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Parsed frontmatter. A value with an unquoted ": " is a common authoring slip
|
|
14
|
+
* the client guide says to recover from by quoting it, so that is retried once.
|
|
15
|
+
*/
|
|
16
|
+
declare function frontmatterObject(source: string): Record<string, unknown> | null;
|
|
17
|
+
declare const NAME_MAX = 64;
|
|
18
|
+
declare const DESCRIPTION_MAX = 1024;
|
|
19
|
+
declare const COMPATIBILITY_MAX = 500;
|
|
20
|
+
/**
|
|
21
|
+
* What the specification requires of one SKILL.md, as messages; empty when valid.
|
|
22
|
+
* directory is the name of the folder holding it.
|
|
23
|
+
*/
|
|
24
|
+
declare function specProblems(front: Record<string, unknown> | null, directory: string): string[];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The skills the installed packages brought with them.
|
|
28
|
+
*
|
|
29
|
+
* Derived from `node_modules` at read time rather than from a list somebody
|
|
30
|
+
* maintains: installing a package is how its skill arrives and uninstalling it
|
|
31
|
+
* is how the skill leaves, so the catalog is always true of the project.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
interface SkillEntry {
|
|
35
|
+
/** `<package>/<slug>`. Unique, and stable while the package is installed. */
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly package: string;
|
|
38
|
+
readonly slug: string;
|
|
39
|
+
/** Frontmatter description. The only text `find` ranks against. */
|
|
40
|
+
readonly description: string;
|
|
41
|
+
/** Absolute path to the SKILL.md. `call` reads the body from here. */
|
|
42
|
+
readonly path: string;
|
|
43
|
+
/** open, free or paid. Set for marketplace skills, absent for packages. */
|
|
44
|
+
readonly tier?: string;
|
|
45
|
+
/** The frontmatter `metadata:` block; maps such as `requires` are kept one level down. */
|
|
46
|
+
readonly metadata?: Readonly<Record<string, MetadataValue>>;
|
|
47
|
+
/** Extra search terms. Ranked with the description, never used as triggers. */
|
|
48
|
+
readonly keywords?: readonly string[];
|
|
49
|
+
/** What the entry is. Absent means a skill. */
|
|
50
|
+
readonly kind?: AssetKind;
|
|
51
|
+
/**
|
|
52
|
+
* What describe and read may open: a directory, or one file for an asset
|
|
53
|
+
* that is a single file. Absent means the directory holding `path`.
|
|
54
|
+
*/
|
|
55
|
+
readonly root?: string;
|
|
56
|
+
}
|
|
57
|
+
/** Everything the catalog serves. Commands are skills; workflows have no kind of their own. */
|
|
58
|
+
declare const ASSET_KINDS: readonly ["skill", "agent", "hook", "mcp"];
|
|
59
|
+
type AssetKind = (typeof ASSET_KINDS)[number];
|
|
60
|
+
declare const kindOf: (entry: Pick<SkillEntry, "kind">) => AssetKind;
|
|
61
|
+
interface CatalogOptions {
|
|
62
|
+
/** Directories to walk. Each is a `node_modules` root, not a package root. */
|
|
63
|
+
readonly roots: readonly string[];
|
|
64
|
+
/** Package name prefixes to consider. Empty means every package. */
|
|
65
|
+
readonly scopes?: readonly string[];
|
|
66
|
+
/** Marketplace directories, each holding .claude-plugin/marketplace.json. */
|
|
67
|
+
readonly marketplaces?: readonly string[];
|
|
68
|
+
/** Package directories read directly, for a package no node_modules links. */
|
|
69
|
+
readonly packages?: readonly string[];
|
|
70
|
+
/** Workspace roots: the root and every member its workspaces globs name. */
|
|
71
|
+
readonly workspaces?: readonly string[];
|
|
72
|
+
/** Told about every marketplace skill left out, and why. */
|
|
73
|
+
readonly onReject?: (rejection: {
|
|
74
|
+
path: string;
|
|
75
|
+
reason: string;
|
|
76
|
+
}) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Told about a skill that is served but breaks the Agent Skills specification,
|
|
79
|
+
* or that lost a name collision. Loading stays lenient, as the client guide asks.
|
|
80
|
+
*/
|
|
81
|
+
readonly onWarning?: (warning: {
|
|
82
|
+
path: string;
|
|
83
|
+
reason: string;
|
|
84
|
+
}) => void;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Directories a walk does not enter. Kept as short as the evidence allows: a
|
|
88
|
+
* name here is a package whose skill will never be found, and the cost of one
|
|
89
|
+
* extra readdir is far below the cost of missing a skill. Measured 20260906 --
|
|
90
|
+
* `lib` was on this list and hid playwright's `lib/skill/SKILL.md`, which is
|
|
91
|
+
* the most widely installed skill in the real world.
|
|
92
|
+
*/
|
|
93
|
+
declare const SKIPPED_DIRS: ReadonlySet<string>;
|
|
94
|
+
/**
|
|
95
|
+
* How deep below a package root a SKILL.md is looked for. Three reaches every
|
|
96
|
+
* convention in use (skills, .agent/skills, .claude/skills, .gemini/skills,
|
|
97
|
+
* .codex/skills); four was measured to find nothing more.
|
|
98
|
+
*/
|
|
99
|
+
declare const MAX_SKILL_DEPTH = 3;
|
|
100
|
+
/**
|
|
101
|
+
* Top-level scalar fields of a SKILL.md frontmatter, parsed as YAML, so a folded
|
|
102
|
+
* `description: >-` arrives as its text rather than as the indicator.
|
|
103
|
+
*/
|
|
104
|
+
declare function readFrontmatter(source: string): Record<string, string>;
|
|
105
|
+
/** The body after the frontmatter, or the whole file when there is none. */
|
|
106
|
+
declare function readBody(source: string): string;
|
|
107
|
+
/**
|
|
108
|
+
* Every skill reachable from the given roots, sorted by name.
|
|
109
|
+
*
|
|
110
|
+
* A package with no skills directory contributes nothing and costs one
|
|
111
|
+
* `existsSync` per convention. A skill with no description is skipped rather
|
|
112
|
+
* than listed:
|
|
113
|
+
* `find` ranks descriptions, so one without a description can only ever be
|
|
114
|
+
* found by already knowing its name, and listing it would spend a session's
|
|
115
|
+
* tokens on an entry that cannot answer.
|
|
116
|
+
*/
|
|
117
|
+
declare function readCatalog(options: CatalogOptions): SkillEntry[];
|
|
118
|
+
/** A catalog entry without its body, which is what `catalog` returns. */
|
|
119
|
+
declare function withoutBody({ path, ...rest }: SkillEntry): Omit<SkillEntry, "path">;
|
|
120
|
+
/** Path relative to a root, for a message a reader can act on. */
|
|
121
|
+
declare function displayPath(root: string, entry: SkillEntry): string;
|
|
122
|
+
|
|
4
123
|
/**
|
|
5
124
|
* The intent key and the cache contract.
|
|
6
125
|
*
|
|
@@ -56,6 +175,7 @@ interface FindResult {
|
|
|
56
175
|
*/
|
|
57
176
|
interface Embedder {
|
|
58
177
|
readonly modelId: string;
|
|
178
|
+
readonly indexKey?: string;
|
|
59
179
|
readonly dims: number;
|
|
60
180
|
/** Encodes an intent, the query side. */
|
|
61
181
|
embed(text: string): Promise<Float32Array>;
|
|
@@ -421,4 +541,4 @@ declare function createSkillTools(options: SkillServerOptions): {
|
|
|
421
541
|
};
|
|
422
542
|
type SkillTools = ReturnType<typeof createSkillTools>;
|
|
423
543
|
|
|
424
|
-
export {
|
|
544
|
+
export { lexicalScore as $, ASSET_KINDS as A, type BundleFile as B, type CatalogOptions as C, DEFAULT_FIND_LIMIT as D, type Embedder as E, type FileKind as F, type SkillFileListing as G, type SkillFilters as H, type IntentCache as I, bundleResponseSchema as J, type KindFilter as K, bundleSkill as L, type MetadataValue as M, NAME_MAX as N, catalogResponseSchema as O, classify as P, cosine as Q, type Ranking as R, type SkillServerOptions as S, createSkillTools as T, describeResponseSchema as U, detectRuntime as V, displayPath as W, find as X, findResultSchema as Y, isUtf8Text as Z, kindOf as _, type SkillEntry as a, listSkillFiles as a0, mimeOf as a1, normaliseIntent as a2, frontmatterObject as a3, readBody as a4, readCatalog as a5, readFrontmatter as a6, readSkillFile as a7, runtimeOfClient as a8, specProblems as a9, verifiedRuntimesOf as aa, withoutBody as ab, type SkillTools as b, type AssetKind as c, CATALOG_PAGE_MAX as d, CATALOG_PAGE_SIZE as e, COMPATIBILITY_MAX as f, type CallResponse as g, type CatalogItem as h, type CatalogResponse as i, type Classified as j, DESCRIBE_FILE_LIMIT as k, DESCRIPTION_MAX as l, type FindOptions as m, type FindResult as n, type IntentCacheStats as o, MAX_SKILL_DEPTH as p, type Match as q, type MetadataLeaf as r, READ_BUDGET_BYTES as s, RUNTIMES as t, type ReadResult as u, type Runtime as v, SKIPPED_DIRS as w, type SkillBundle as x, type SkillFile as y, type SkillFileContent as z };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const operationSchema: z.ZodEnum<{
|
|
4
|
+
read: "read";
|
|
5
|
+
send: "send";
|
|
6
|
+
inbox: "inbox";
|
|
7
|
+
ack: "ack";
|
|
8
|
+
sessions: "sessions";
|
|
9
|
+
}>;
|
|
10
|
+
type MailboxOperation = z.output<typeof operationSchema>;
|
|
11
|
+
declare const sessionsSchema: z.ZodObject<{}, z.core.$strict>;
|
|
12
|
+
declare const sendSchema: z.ZodObject<{
|
|
13
|
+
recipients: z.ZodArray<z.ZodObject<{
|
|
14
|
+
actorId: z.ZodString;
|
|
15
|
+
sessionId: z.ZodOptional<z.ZodUUID>;
|
|
16
|
+
}, z.core.$strict>>;
|
|
17
|
+
body: z.ZodString;
|
|
18
|
+
idempotencyKey: z.ZodString;
|
|
19
|
+
replyToId: z.ZodOptional<z.ZodUUID>;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
declare const inboxSchema: z.ZodObject<{
|
|
22
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
state: z.ZodDefault<z.ZodEnum<{
|
|
24
|
+
all: "all";
|
|
25
|
+
unread: "unread";
|
|
26
|
+
unacknowledged: "unacknowledged";
|
|
27
|
+
}>>;
|
|
28
|
+
threadId: z.ZodOptional<z.ZodUUID>;
|
|
29
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
declare const messageSchema: z.ZodObject<{
|
|
32
|
+
messageId: z.ZodUUID;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
|
|
35
|
+
type SqlValue = string | number | null;
|
|
36
|
+
type Row = Record<string, unknown>;
|
|
37
|
+
interface Database {
|
|
38
|
+
exec(sql: string): void;
|
|
39
|
+
get(sql: string, ...values: SqlValue[]): Row | undefined;
|
|
40
|
+
all(sql: string, ...values: SqlValue[]): Row[];
|
|
41
|
+
run(sql: string, ...values: SqlValue[]): void;
|
|
42
|
+
close(): void;
|
|
43
|
+
}
|
|
44
|
+
interface ActorCredential {
|
|
45
|
+
projectId: string;
|
|
46
|
+
actorId: string;
|
|
47
|
+
secret: string;
|
|
48
|
+
}
|
|
49
|
+
interface Binding {
|
|
50
|
+
projectId: string;
|
|
51
|
+
actorId: string;
|
|
52
|
+
sessionId: string;
|
|
53
|
+
generation: number;
|
|
54
|
+
secret: string;
|
|
55
|
+
}
|
|
56
|
+
interface MailboxConfig {
|
|
57
|
+
projectId: string;
|
|
58
|
+
databasePath: string;
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
}
|
|
61
|
+
type Result<T> = {
|
|
62
|
+
ok: true;
|
|
63
|
+
data: T;
|
|
64
|
+
} | {
|
|
65
|
+
ok: false;
|
|
66
|
+
error: {
|
|
67
|
+
code: string;
|
|
68
|
+
message: string;
|
|
69
|
+
retryable: boolean;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
declare class MailboxError extends Error {
|
|
73
|
+
readonly code: string;
|
|
74
|
+
readonly retryable: boolean;
|
|
75
|
+
constructor(code: string, message: string, retryable?: boolean);
|
|
76
|
+
}
|
|
77
|
+
declare function failure(error: unknown): Result<never>;
|
|
78
|
+
|
|
79
|
+
declare const PRESENCE_TTL_MS = 120000;
|
|
80
|
+
declare const HEARTBEAT_INTERVAL_MS = 30000;
|
|
81
|
+
declare class MailboxStore {
|
|
82
|
+
private pending;
|
|
83
|
+
private closed;
|
|
84
|
+
readonly config: MailboxConfig;
|
|
85
|
+
readonly database: Database;
|
|
86
|
+
readonly now: () => number;
|
|
87
|
+
private constructor();
|
|
88
|
+
static open(config: MailboxConfig, now?: () => number): Promise<MailboxStore>;
|
|
89
|
+
checkSchema(): void;
|
|
90
|
+
run<T>(operation: () => T, write?: boolean): Promise<T>;
|
|
91
|
+
registerActor(actorId: string, parentActorId?: string, persist?: (credential: ActorCredential) => void, authorityTtlMs?: number, parentBinding?: Binding): Promise<ActorCredential>;
|
|
92
|
+
registerChild(parent: Binding, actorId: string, ttlMs?: number): Promise<ActorCredential>;
|
|
93
|
+
attach(credential: ActorCredential, runtime: string, replaceSessionId?: string, nativeSessionId?: string): Promise<Binding>;
|
|
94
|
+
assertBinding(binding: Binding): Row;
|
|
95
|
+
rotateActor(actorId: string, persist?: (credential: ActorCredential) => void): Promise<ActorCredential>;
|
|
96
|
+
heartbeat(binding: Binding): Promise<void>;
|
|
97
|
+
detach(binding: Binding): Promise<void>;
|
|
98
|
+
exportRecords(actorId?: string): Promise<object[]>;
|
|
99
|
+
backup(destination: string): Promise<void>;
|
|
100
|
+
close(): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
declare function restoreBackup(source: string, config: MailboxConfig): Promise<void>;
|
|
103
|
+
|
|
104
|
+
declare class MailboxService {
|
|
105
|
+
readonly store: MailboxStore;
|
|
106
|
+
readonly binding: Binding;
|
|
107
|
+
constructor(store: MailboxStore, binding: Binding);
|
|
108
|
+
call(operation: MailboxOperation, input: unknown): Promise<Result<object>>;
|
|
109
|
+
private send;
|
|
110
|
+
private visibleMessage;
|
|
111
|
+
private inbox;
|
|
112
|
+
private receipt;
|
|
113
|
+
private sessions;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { type ActorCredential as A, type Binding as B, HEARTBEAT_INTERVAL_MS as H, MailboxService as M, PRESENCE_TTL_MS as P, type Row as R, type MailboxConfig as a, MailboxStore as b, MailboxError as c, type MailboxOperation as d, type Result as e, failure as f, sessionsSchema as g, inboxSchema as i, messageSchema as m, operationSchema as o, restoreBackup as r, sendSchema as s };
|
package/dist/stdio.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { serveStdio } from '@modelcontextprotocol/server/stdio';
|
|
3
|
+
import { S as SkillServerOptions, C as CatalogOptions } from './server-CwWcRjqz.js';
|
|
4
|
+
import { M as MailboxService } from './service-qpCsOXkQ.js';
|
|
5
|
+
import { M as MailboxAttachmentOptions } from './attachment-tU5FZrgZ.js';
|
|
6
|
+
import 'zod';
|
|
3
7
|
|
|
4
8
|
/**
|
|
5
9
|
* The stdio entry a host launches.
|
|
@@ -11,11 +15,13 @@ import { C as CatalogOptions } from './catalog-BU5VLLyd.js';
|
|
|
11
15
|
|
|
12
16
|
/** `node_modules` roots to walk, from argv or from the working directory. */
|
|
13
17
|
declare function resolveRoots(argv: readonly string[], cwd: string): string[];
|
|
14
|
-
interface ServeOptions {
|
|
18
|
+
interface ServeOptions extends Pick<SkillServerOptions, "embedder" | "vectors" | "loadCatalog"> {
|
|
19
|
+
readonly mailbox?: MailboxService;
|
|
15
20
|
/** One prompt per skill, for hosts that offer prompts as commands. */
|
|
16
21
|
readonly prompts?: boolean;
|
|
17
22
|
}
|
|
18
|
-
declare function serve(catalog: CatalogOptions, serving?: ServeOptions):
|
|
23
|
+
declare function serve(catalog: CatalogOptions, serving?: ServeOptions): ReturnType<typeof serveStdio>;
|
|
24
|
+
declare function serveWithMailbox(catalog: CatalogOptions, mailbox: MailboxAttachmentOptions, serving?: ServeOptions): Promise<() => Promise<void>>;
|
|
19
25
|
declare function main(argv?: readonly string[]): void;
|
|
20
26
|
|
|
21
|
-
export { type ServeOptions, main, resolveRoots, serve };
|
|
27
|
+
export { type ServeOptions, main, resolveRoots, serve, serveWithMailbox };
|