@aikdna/kdna-mcp-server 0.8.4 → 0.8.5
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 +19 -15
- package/bin/kdna-mcp.mjs +159 -19
- package/bin/operator-binding.mjs +79 -28
- package/bin/read-session.mjs +2 -2
- package/bin/reading-views.mjs +17 -1
- package/package.json +9 -21
- package/vendor/aikdna-kdna-cli-0.45.2.tgz +0 -0
- package/vendor/aikdna-kdna-core-0.37.11.tgz +0 -0
- package/vendor/aikdna-kdna-read-0.13.5.tgz +0 -0
- package/vendor/ajv-8.20.0.tgz +0 -0
- package/vendor/ajv-formats-3.0.1.tgz +0 -0
- package/vendor/cbor-x-1.6.9.tgz +0 -0
- package/vendor/fast-deep-equal-3.1.3.tgz +0 -0
- package/vendor/fast-uri-3.1.9.tgz +0 -0
- package/vendor/json-schema-traverse-1.0.0.tgz +0 -0
- package/vendor/noble-hashes-1.8.0.tgz +0 -0
- package/vendor/pako-2.1.0.tgz +0 -0
- package/vendor/require-from-string-2.0.2.tgz +0 -0
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
# KDNA MCP 0.8.
|
|
1
|
+
# KDNA MCP 0.8.5 — local stdio Read adapter
|
|
2
2
|
|
|
3
|
-
This local stdio MCP server (`@aikdna/kdna-mcp-server@0.8.
|
|
3
|
+
This local stdio MCP server (`@aikdna/kdna-mcp-server@0.8.5`) delegates native container `0.6.0` admission and scoped Read operations to the exact CLI `0.47.0` / Core `0.37.12` / Read `0.13.6` graph (`kdna.read/0.7.0-candidate`). Historical MCP `0.5.0`–`0.5.1` and CLI `0.36.x` workspace flows are superseded by this operator-bound native `0.6.0` adapter.
|
|
4
4
|
|
|
5
5
|
## Operator-controlled startup
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
node /absolute/installed/mcp-server/bin/kdna-mcp.mjs --asset /absolute/selected.kdna --allow-read
|
|
9
|
-
# Optional
|
|
9
|
+
# Optional multi-asset explicit operator allowlist (repeatable --asset, max 16, zero directory scanning):
|
|
10
|
+
node /absolute/installed/mcp-server/bin/kdna-mcp.mjs --asset /absolute/first.kdna --asset /absolute/second.kdna --allow-read
|
|
11
|
+
# Optional for single password-protected 0.6.0 .kdna files (mode 0600 file or fd >= 3):
|
|
10
12
|
node /absolute/installed/mcp-server/bin/kdna-mcp.mjs --asset /absolute/selected.kdna --allow-read --password-file /absolute/passphrase.txt
|
|
11
13
|
```
|
|
12
14
|
|
|
@@ -91,13 +93,14 @@ argument or method parameter beyond request-level `_meta`.
|
|
|
91
93
|
|
|
92
94
|
| Tool | Arguments | Result |
|
|
93
95
|
| --- | --- | --- |
|
|
94
|
-
| kdna.binding-status | {} | Local binding state, not a public authority receipt |
|
|
95
|
-
| kdna.inspect |
|
|
96
|
-
| kdna.catalog | optional budget_bytes (default 1000000); optional presentation | Complete public catalog within the budget (projected body budget in default body mode; official envelope budget in full/task mode) |
|
|
97
|
-
| kdna.
|
|
98
|
-
| kdna.
|
|
99
|
-
| kdna.
|
|
100
|
-
| kdna.
|
|
96
|
+
| kdna.binding-status | {} | Local binding state (including `bound_asset_count` and `bound_assets`), not a public authority receipt |
|
|
97
|
+
| kdna.inspect | optional `asset_id` | Official CLI technical admission/metadata (all bound assets when omitted in multi-asset mode) |
|
|
98
|
+
| kdna.catalog | optional `asset_id`, optional `budget_bytes` (default 1000000); optional `presentation` | Complete public catalog within the budget (projected body budget in default body mode; official envelope budget in full/task mode) |
|
|
99
|
+
| kdna.catalog_all | optional `budget_bytes` (default 1000000); optional `presentation` | Aggregated public catalogs across all operator-bound assets in one call (fail-closed if any bound asset fails admission or exceeds budget) |
|
|
100
|
+
| kdna.read | `selection`, `budget_bytes`; optional `presentation` | Exact selection and mandatory closure (`selection.asset_id` + `selection.asset_version` routes strictly to the matching bound asset's isolated CLI session in multi-asset mode) |
|
|
101
|
+
| kdna.expand | exactly one of `handle` or `handle_ref`, `budget_bytes`; optional `presentation` | Original issued handle passed to the same official session |
|
|
102
|
+
| kdna.audit | `audit_ref`, `budget_bytes` | Exact original full result of an earlier task delivery |
|
|
103
|
+
| kdna.cancel | {} | Closes every bound asset's session and revokes the entire process binding |
|
|
101
104
|
|
|
102
105
|
For catalog/read/expand, `presentation` is `"body"`, `"full"` or `"task"`.
|
|
103
106
|
Omission means `"body"` whenever the installed Read package provides the body
|
|
@@ -263,7 +266,7 @@ container format is not permission to convert it implicitly or read its raw payl
|
|
|
263
266
|
|
|
264
267
|
For an Agent-led task, begin with the [getting-started guide](https://github.com/aikdna/kdna-skills/blob/main/docs/GETTING_STARTED.md).
|
|
265
268
|
The installer requires Node.js 22 or later, npm, `bash` and `tar`. The current
|
|
266
|
-
CLI 0.
|
|
269
|
+
CLI 0.47.0 / Core 0.37.12 / Read 0.13.6 graph was exercised with Node.js 22.22.3
|
|
267
270
|
and npm 10.9.8. Earlier companion graphs' runtime checks do not verify this
|
|
268
271
|
one on additional Node versions. The CI matrix is a set of required checks,
|
|
269
272
|
not evidence that every run has already passed. From `mcp-server/`:
|
|
@@ -301,17 +304,18 @@ refuses an existing destination. Each runtime archive is an exact root `file:`
|
|
|
301
304
|
dependency, with a matching root override. This lets npm resolve dependencies
|
|
302
305
|
before extracting the MCP package. The MCP manifest uses exact numeric registry dependencies; this explicit companion graph supplies the same checked bytes for offline use without depending on package-relative archive lookup.
|
|
303
306
|
|
|
304
|
-
The MCP tar has
|
|
305
|
-
README, LICENSE, NOTICE
|
|
307
|
+
The MCP tar has ten regular members: bin modules, package metadata,
|
|
308
|
+
README, LICENSE, and NOTICE (offline `vendor/*.tgz` archives stay excluded from
|
|
309
|
+
the published npm tarball). Tests, source tooling and
|
|
306
310
|
package-lock.json are excluded. The companion consumer lock is generated from
|
|
307
311
|
the checked source graph. The packed-consumer test installs with an empty npm
|
|
308
312
|
cache, then runs the same real stdio boundary suite against the installed bin.
|
|
309
313
|
|
|
310
|
-
Canonical npm publication of `@aikdna/kdna-mcp-server@0.8.
|
|
314
|
+
Canonical npm publication of `@aikdna/kdna-mcp-server@0.8.5` runs exclusively via the GitHub Release workflow (`kdna-mcp-server-0.8.5`) after companion packages (`@aikdna/kdna-core@0.37.12`, `@aikdna/kdna-read@0.13.6`, `@aikdna/kdna-cli@0.47.0`) are published on the official registry. Source and installed process tests do not
|
|
311
315
|
establish named Host adoption, human review, authorship or Creation acceptance.
|
|
312
316
|
|
|
313
317
|
## Native section contract boundary
|
|
314
318
|
|
|
315
|
-
The complete CLI public contract binding is pinned by SHA-256 `
|
|
319
|
+
The complete CLI public contract binding is pinned by SHA-256 `ad83927304f7c7f3dece9646c9a73df46af85ddefab68798df7cc9e4d7b4dcdb`. It identifies the native container `0.6.0` and Read `0.7.0-candidate` tuple, exact Core/Read artifacts and route contracts. CLI and Read must resolve the same fixed Core instance; a nested shadow dependency is refused. The adapter delegates native admission and retained section reads to that runtime. Preserve catalog-only status, mandatory closure, native handle origin, diagnostics, absent declarations and explicit empty states. Technical validity, Read and static declarations do not establish live Creation authority, human confirmation or action permission.
|
|
316
320
|
|
|
317
321
|
The public regression corpus is generated from synthetic authored JSON with the fixed CLI. It tests real native containers and one deliberately truncated container; no legacy component-format asset is treated as current native input.
|
package/bin/kdna-mcp.mjs
CHANGED
|
@@ -45,9 +45,10 @@ function selectionIds(selection) {
|
|
|
45
45
|
}
|
|
46
46
|
const tools = [
|
|
47
47
|
{ name: "kdna.binding-status", description: "Report only this process's operator-established local binding. It grants no new permission.", inputSchema: emptySchema },
|
|
48
|
-
{ name: "kdna.inspect", description: "Inspect the bound file through the official CLI; technical facts do not authorize actions or establish authorship.", inputSchema:
|
|
49
|
-
{ name: "kdna.catalog", description: "Read the complete public catalog once. budget_bytes is optional (0..1000000, default 1000000): in the default body presentation it bounds the projected body view (recommended >= 32768; e.g. a 45-judgment catalog is ~8-12 KiB projected vs >200 KiB raw); in presentation:\"full\" or \"task\" it bounds the complete official Read envelope (recommended >= 1000000). The default presentation is the installed Read body view (authored content plus one fingerprint); presentation:\"full\" returns the complete official envelope and an explicit body request is refused when that package cannot project; optional task presentation requires an independent view_budget_bytes.", inputSchema: { type: "object", additionalProperties: false, allOf: presentationRules, properties: { budget_bytes: catalogBudgetSchema, ...presentationProperties } } },
|
|
50
|
-
{ name: "kdna.
|
|
48
|
+
{ name: "kdna.inspect", description: "Inspect the bound file(s) through the official CLI; technical facts do not authorize actions or establish authorship. Optional asset_id selects one asset when multiple assets are operator-bound.", inputSchema: { type: "object", additionalProperties: false, properties: { asset_id: selectionKey } } },
|
|
49
|
+
{ name: "kdna.catalog", description: "Read the complete public catalog once. On a multi-asset operator binding, pass asset_id or use kdna.catalog_all. budget_bytes is optional (0..1000000, default 1000000): in the default body presentation it bounds the projected body view (recommended >= 32768; e.g. a 45-judgment catalog is ~8-12 KiB projected vs >200 KiB raw); in presentation:\"full\" or \"task\" it bounds the complete official Read envelope (recommended >= 1000000). The default presentation is the installed Read body view (authored content plus one fingerprint); presentation:\"full\" returns the complete official envelope and an explicit body request is refused when that package cannot project; optional task presentation requires an independent view_budget_bytes.", inputSchema: { type: "object", additionalProperties: false, allOf: presentationRules, properties: { asset_id: selectionKey, budget_bytes: catalogBudgetSchema, ...presentationProperties } } },
|
|
50
|
+
{ name: "kdna.catalog_all", description: "Read the complete public catalog across all operator-bound assets in one call (explicit OS argv allowlist only; zero directory scanning). budget_bytes is optional (0..1000000, default 1000000) and bounds the complete aggregated projected body response (or each official envelope in full/task presentation).", inputSchema: { type: "object", additionalProperties: false, allOf: presentationRules, properties: { budget_bytes: catalogBudgetSchema, ...presentationProperties } } },
|
|
51
|
+
{ name: "kdna.read", description: "Batch the exact judgments needed for this task with mandatory closure in one snapshot. On multi-asset operator bindings, selection.asset_id and selection.asset_version route strictly to that bound asset's isolated CLI session. The default presentation is the installed Read body view; presentation:\"full\" returns the complete official envelope. Keep the complete result; repeat only for a new need. Optional task is a lossless adapter view, not an official Read envelope.", inputSchema: { type: "object", required: ["selection", "budget_bytes"], additionalProperties: false, allOf: presentationRules, properties: { selection: selectionSchema, budget_bytes: budgetSchema, ...presentationProperties } } },
|
|
51
52
|
{ name: "kdna.expand", description: "Return an original handle or this process's short handle_ref to the same official CLI. The default presentation is the installed Read body view; presentation:\"full\" returns the complete official envelope. A reference grants no permission; Read still validates scope, snapshot, epoch and expiry.", inputSchema: { type: "object", required: ["budget_bytes"], additionalProperties: false, oneOf: [{ required: ["handle"] }, { required: ["handle_ref"] }], allOf: presentationRules, properties: { handle: { type: "object" }, handle_ref: selectionKey, budget_bytes: budgetSchema, ...presentationProperties } } },
|
|
52
53
|
{ name: "kdna.audit", description: "Retrieve the exact past full result for a delivered task audit_ref, within an explicit budget and the same live operator binding. This performs no new verification, reading or authorization.", inputSchema: { type: "object", required: ["audit_ref", "budget_bytes"], additionalProperties: false, properties: { audit_ref: selectionKey, budget_bytes: budgetSchema } } },
|
|
53
54
|
{ name: "kdna.cancel", description: "Cancel local presentation and revoke this process binding. Only a new operator-controlled launch can select again.", inputSchema: emptySchema },
|
|
@@ -58,20 +59,58 @@ try { binding = bindOperatorInput(process.argv.slice(2)); }
|
|
|
58
59
|
catch (error) { process.stderr.write((error instanceof AdapterError ? error.code : "MCP_STARTUP_FAILED") + "\n"); process.exitCode = 2; }
|
|
59
60
|
|
|
60
61
|
if (binding) {
|
|
61
|
-
const
|
|
62
|
-
|
|
62
|
+
const slots = binding.assets.map(assetBinding => {
|
|
63
|
+
const session = new ReadSession(assetBinding);
|
|
64
|
+
return {
|
|
65
|
+
binding: assetBinding,
|
|
66
|
+
session,
|
|
67
|
+
views: new ReadingViews(assetBinding, session),
|
|
68
|
+
asset_id: null,
|
|
69
|
+
asset_version: null,
|
|
70
|
+
identityChecked: false,
|
|
71
|
+
};
|
|
72
|
+
});
|
|
63
73
|
const modelView = loadModelView();
|
|
64
74
|
const defaultPresentation = modelView ? "body" : "full";
|
|
65
75
|
// What the model receives is the official Read projection of the complete
|
|
66
76
|
// result this process already validated; the full result stays available to
|
|
67
77
|
// the same request and to the audit record.
|
|
68
|
-
function
|
|
78
|
+
function presentSlot(slot, value, args) {
|
|
69
79
|
const selected = args.presentation ?? defaultPresentation;
|
|
70
|
-
if (selected === "task") return views.task(value, args.view_budget_bytes);
|
|
80
|
+
if (selected === "task") return slot.views.task(value, args.view_budget_bytes);
|
|
71
81
|
if (selected === "full") return value;
|
|
72
82
|
if (!modelView) throw new AdapterError("MCP_MODEL_VIEW_UNAVAILABLE", "The installed Read package does not provide the body projection. Request full presentation explicitly.");
|
|
73
83
|
return projectBody(modelView, value);
|
|
74
84
|
}
|
|
85
|
+
function observeIdentity(slot, value) {
|
|
86
|
+
const asset = value?.channel === "read_envelope" ? value.envelope?.asset : value?.status === "accepted" ? value.asset : null;
|
|
87
|
+
if (asset && typeof asset.asset_id === "string" && asset.asset_id.length > 0) {
|
|
88
|
+
slot.asset_id = asset.asset_id;
|
|
89
|
+
slot.asset_version = typeof asset.asset_version === "string" ? asset.asset_version : slot.asset_version;
|
|
90
|
+
slot.identityChecked = true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function ensureSlotIdentities(signal) {
|
|
94
|
+
for (const slot of slots) {
|
|
95
|
+
if (slot.identityChecked) continue;
|
|
96
|
+
const inspected = await inspectBoundFile(slot.binding, signal);
|
|
97
|
+
slot.identityChecked = true;
|
|
98
|
+
observeIdentity(slot, inspected);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async function resolveSlotByAsset(assetId, assetVersion, signal) {
|
|
102
|
+
binding.assertReadable();
|
|
103
|
+
await ensureSlotIdentities(signal);
|
|
104
|
+
if (assetVersion) {
|
|
105
|
+
const exactMatches = slots.filter(slot => slot.asset_id === assetId && slot.asset_version === assetVersion);
|
|
106
|
+
if (exactMatches.length === 1) return exactMatches[0];
|
|
107
|
+
if (exactMatches.length > 1) throw new AdapterError("MCP_ASSET_AMBIGUOUS", "Multiple bound files declare the same asset_id and asset_version.");
|
|
108
|
+
}
|
|
109
|
+
const idMatches = slots.filter(slot => slot.asset_id === assetId);
|
|
110
|
+
if (idMatches.length === 1) return idMatches[0];
|
|
111
|
+
if (idMatches.length > 1) throw new AdapterError("MCP_ASSET_AMBIGUOUS", "Multiple bound files declare the same asset_id; specify an unambiguous asset_version or bind distinct assets.");
|
|
112
|
+
throw new AdapterError("MCP_ASSET_NOT_BOUND", "The requested asset_id is not in this process's operator-bound allowlist.");
|
|
113
|
+
}
|
|
75
114
|
let initialized = false, ready = false, active = null, shuttingDown = false, shutdownWork = null, outputFailed = false, writing = Promise.resolve();
|
|
76
115
|
const outstanding = new Set();
|
|
77
116
|
const write = message => {
|
|
@@ -87,24 +126,24 @@ if (binding) {
|
|
|
87
126
|
const text = value => ({ content: [{ type: "text", text: JSON.stringify(value) }] });
|
|
88
127
|
const toolError = cause => ({ ...text({ status: "unavailable", code: cause instanceof AdapterError ? cause.code : "MCP_LOCAL_READ_FAILED", message: cause instanceof AdapterError ? cause.message : "The bounded local read did not complete.", action_authorized: false }), isError: true });
|
|
89
128
|
async function revoke() {
|
|
90
|
-
views.clear();
|
|
129
|
+
for (const slot of slots) slot.views.clear();
|
|
91
130
|
const current = active;
|
|
92
131
|
if (current) { current.cancelled = true; current.controller.abort(); }
|
|
93
|
-
await session.close(false);
|
|
132
|
+
await Promise.allSettled(slots.map(slot => slot.session.close(false)));
|
|
94
133
|
if (current) await Promise.allSettled([current.work]);
|
|
95
134
|
binding.close();
|
|
96
135
|
}
|
|
97
136
|
async function shutdown(graceful) {
|
|
98
|
-
views.clear();
|
|
137
|
+
for (const slot of slots) slot.views.clear();
|
|
99
138
|
if (!graceful) {
|
|
100
139
|
if (active) { active.cancelled = true; active.controller.abort(); }
|
|
101
|
-
void session.close(false);
|
|
140
|
+
for (const slot of slots) void slot.session.close(false);
|
|
102
141
|
}
|
|
103
142
|
if (shutdownWork) return shutdownWork;
|
|
104
143
|
shuttingDown = true;
|
|
105
144
|
shutdownWork = (async () => {
|
|
106
145
|
await Promise.allSettled([...outstanding]);
|
|
107
|
-
await session.close(graceful);
|
|
146
|
+
await Promise.allSettled(slots.map(slot => slot.session.close(graceful)));
|
|
108
147
|
try { binding.close(); } catch { process.stderr.write("MCP_CLEANUP_FAILED\n"); process.exitCode = 1; }
|
|
109
148
|
process.stdin.destroy();
|
|
110
149
|
})();
|
|
@@ -120,8 +159,10 @@ if (binding) {
|
|
|
120
159
|
return args.presentation === "task" ? Object.hasOwn(args, "view_budget_bytes") && validBudget(args.view_budget_bytes) : !Object.hasOwn(args, "view_budget_bytes");
|
|
121
160
|
}
|
|
122
161
|
function validCall(name, args) {
|
|
123
|
-
if (["kdna.binding-status", "kdna.
|
|
124
|
-
if (name === "kdna.
|
|
162
|
+
if (["kdna.binding-status", "kdna.cancel"].includes(name)) return keys(args, []);
|
|
163
|
+
if (name === "kdna.inspect") return object(args) && Object.keys(args).every(key => key === "asset_id") && (!Object.hasOwn(args, "asset_id") || validId(args.asset_id));
|
|
164
|
+
if (name === "kdna.catalog") return validPresentation(args, [], ["asset_id", "budget_bytes"]) && (!Object.hasOwn(args, "budget_bytes") || validBudget(args.budget_bytes)) && (!Object.hasOwn(args, "asset_id") || validId(args.asset_id));
|
|
165
|
+
if (name === "kdna.catalog_all") return validPresentation(args, [], ["budget_bytes"]) && (!Object.hasOwn(args, "budget_bytes") || validBudget(args.budget_bytes));
|
|
125
166
|
if (name === "kdna.read") return validPresentation(args, ["selection", "budget_bytes"]) && validBudget(args.budget_bytes) && validReadSelection(args.selection);
|
|
126
167
|
if (name === "kdna.expand") {
|
|
127
168
|
if (!object(args) || Object.hasOwn(args, "handle") === Object.hasOwn(args, "handle_ref")) return false;
|
|
@@ -137,19 +178,104 @@ if (binding) {
|
|
|
137
178
|
operation.work = (async () => {
|
|
138
179
|
try {
|
|
139
180
|
binding.assertReadable();
|
|
140
|
-
const handle = Object.hasOwn(args, "handle_ref") ? views.expand(args.handle_ref) : args.handle ?? null;
|
|
141
181
|
const selectedPresentation = args.presentation ?? defaultPresentation;
|
|
182
|
+
if (name === "kdna.catalog_all") {
|
|
183
|
+
const callerBudget = Object.hasOwn(args, "budget_bytes") ? args.budget_bytes : DEFAULT_CATALOG_BUDGET_BYTES;
|
|
184
|
+
const isCatalogBody = selectedPresentation === "body" && modelView !== null;
|
|
185
|
+
const officialBudget = isCatalogBody && callerBudget > 0 ? Math.max(callerBudget, CATALOG_BODY_ENVELOPE_BUDGET_BYTES) : callerBudget;
|
|
186
|
+
const entries = [];
|
|
187
|
+
for (const slot of slots) {
|
|
188
|
+
const value = await slot.session.request({ request_id: "mcp:" + randomUUID(), tuple: publicBinding.tuple, budget_bytes: officialBudget, mode: "catalog", selection: null, handle: null });
|
|
189
|
+
if (operation.cancelled) throw new AdapterError("MCP_READ_CANCELLED", "Local read presentation was cancelled; this process binding is closed.");
|
|
190
|
+
slot.views.observe(value);
|
|
191
|
+
observeIdentity(slot, value);
|
|
192
|
+
const ok = value.channel === "read_envelope" && value.envelope.status === "catalog_only";
|
|
193
|
+
const presented = presentSlot(slot, value, args);
|
|
194
|
+
if (!ok) {
|
|
195
|
+
await result(id, { ...text({ status: "rejected", failed_asset: { index: slot.binding.index, file_name: slot.binding.name, local_binding_digest: slot.binding.digest }, official_result: presented, action_authorized: false }), isError: true });
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
entries.push({
|
|
199
|
+
index: slot.binding.index,
|
|
200
|
+
file_name: slot.binding.name,
|
|
201
|
+
local_binding_digest: slot.binding.digest,
|
|
202
|
+
asset_id: slot.asset_id,
|
|
203
|
+
asset_version: slot.asset_version,
|
|
204
|
+
catalog: presented,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const aggregated = {
|
|
208
|
+
status: "catalog_all",
|
|
209
|
+
bound_asset_count: slots.length,
|
|
210
|
+
presentation: selectedPresentation,
|
|
211
|
+
action_authorized: false,
|
|
212
|
+
assets: entries,
|
|
213
|
+
};
|
|
214
|
+
if (isCatalogBody) {
|
|
215
|
+
const projectedBytes = Buffer.byteLength(JSON.stringify(aggregated), "utf8");
|
|
216
|
+
if (projectedBytes > callerBudget) {
|
|
217
|
+
throw new AdapterError("MCP_BODY_VIEW_BUDGET_EXCEEDED", "The complete aggregated catalog body view requires " + projectedBytes + " UTF-8 bytes (limit " + callerBudget + "); no partial result was delivered. Increase budget_bytes or omit it to use the default " + DEFAULT_CATALOG_BUDGET_BYTES + "-byte budget.");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (selectedPresentation === "task") {
|
|
221
|
+
const taskBytes = Buffer.byteLength(JSON.stringify(aggregated), "utf8");
|
|
222
|
+
if (taskBytes > args.view_budget_bytes) {
|
|
223
|
+
for (const slot of slots) slot.views.clear();
|
|
224
|
+
throw new AdapterError("MCP_TASK_VIEW_BUDGET_EXCEEDED", "The complete aggregated task catalog view requires " + taskBytes + " UTF-8 bytes (limit " + args.view_budget_bytes + "); no partial result was delivered.");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
await result(id, text(aggregated));
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (name === "kdna.inspect" && slots.length > 1 && !Object.hasOwn(args, "asset_id")) {
|
|
231
|
+
const assets = [];
|
|
232
|
+
let allAccepted = true;
|
|
233
|
+
for (const slot of slots) {
|
|
234
|
+
const inspected = await inspectBoundFile(slot.binding, operation.controller.signal);
|
|
235
|
+
if (operation.cancelled) throw new AdapterError("MCP_READ_CANCELLED", "Local read presentation was cancelled; this process binding is closed.");
|
|
236
|
+
slot.identityChecked = true;
|
|
237
|
+
observeIdentity(slot, inspected);
|
|
238
|
+
if (inspected.status !== "accepted") allAccepted = false;
|
|
239
|
+
assets.push({ index: slot.binding.index, file_name: slot.binding.name, local_binding_digest: slot.binding.digest, inspection: inspected });
|
|
240
|
+
}
|
|
241
|
+
await result(id, { ...text({ status: allAccepted ? "accepted" : "rejected", bound_asset_count: slots.length, action_authorized: false, assets }), ...(allAccepted ? {} : { isError: true }) });
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
let slot;
|
|
245
|
+
if (name === "kdna.audit") {
|
|
246
|
+
slot = slots.length === 1 ? slots[0] : slots.find(candidate => candidate.views.hasAudit(args.audit_ref));
|
|
247
|
+
if (!slot) throw new AdapterError("MCP_REFERENCE_UNAVAILABLE", "The reference is absent, expired or outside this live operator-bound session. A reference grants no permission.");
|
|
248
|
+
} else if (name === "kdna.expand") {
|
|
249
|
+
if (slots.length === 1) slot = slots[0];
|
|
250
|
+
else if (Object.hasOwn(args, "handle_ref")) {
|
|
251
|
+
slot = slots.find(candidate => candidate.views.hasHandle(args.handle_ref));
|
|
252
|
+
if (!slot) throw new AdapterError("MCP_REFERENCE_UNAVAILABLE", "The reference is absent, expired or outside this live operator-bound session. A reference grants no permission.");
|
|
253
|
+
} else {
|
|
254
|
+
const handleAsset = args.handle?.asset;
|
|
255
|
+
if (!handleAsset || !validId(handleAsset.asset_id)) throw new AdapterError("MCP_ASSET_NOT_BOUND", "The expansion handle does not identify a bound asset.");
|
|
256
|
+
slot = await resolveSlotByAsset(handleAsset.asset_id, validId(handleAsset.asset_version) ? handleAsset.asset_version : null, operation.controller.signal);
|
|
257
|
+
}
|
|
258
|
+
} else if (name === "kdna.read") {
|
|
259
|
+
slot = slots.length === 1 ? slots[0] : await resolveSlotByAsset(args.selection.asset_id, args.selection.asset_version, operation.controller.signal);
|
|
260
|
+
} else if (name === "kdna.catalog") {
|
|
261
|
+
if (Object.hasOwn(args, "asset_id")) slot = await resolveSlotByAsset(args.asset_id, null, operation.controller.signal);
|
|
262
|
+
else if (slots.length === 1) slot = slots[0];
|
|
263
|
+
else throw new AdapterError("MCP_ASSET_SELECTION_REQUIRED", "Multiple assets are bound; call kdna.catalog_all or specify asset_id on kdna.catalog.");
|
|
264
|
+
} else if (name === "kdna.inspect") {
|
|
265
|
+
slot = Object.hasOwn(args, "asset_id") ? await resolveSlotByAsset(args.asset_id, null, operation.controller.signal) : slots[0];
|
|
266
|
+
}
|
|
267
|
+
const handle = Object.hasOwn(args, "handle_ref") ? slot.views.expand(args.handle_ref) : args.handle ?? null;
|
|
142
268
|
const callerBudget = name === "kdna.catalog" && !Object.hasOwn(args, "budget_bytes") ? DEFAULT_CATALOG_BUDGET_BYTES : args.budget_bytes;
|
|
143
269
|
const isCatalogBody = name === "kdna.catalog" && selectedPresentation === "body" && modelView !== null;
|
|
144
270
|
const officialBudget = isCatalogBody && callerBudget > 0 ? Math.max(callerBudget, CATALOG_BODY_ENVELOPE_BUDGET_BYTES) : callerBudget;
|
|
145
271
|
const request = { request_id: "mcp:" + randomUUID(), tuple: publicBinding.tuple, budget_bytes: officialBudget, mode: name === "kdna.catalog" ? "catalog" : name === "kdna.read" ? "exact_selection" : "expand", selection: name === "kdna.read" ? { asset_id: args.selection.asset_id, asset_version: args.selection.asset_version, judgment_ids: selectionIds(args.selection) } : handle?.anchor?.selection ?? null, handle };
|
|
146
|
-
const value = name === "kdna.audit" ? views.audit(args.audit_ref, args.budget_bytes) : name === "kdna.inspect" ? await inspectBoundFile(binding, operation.controller.signal) : await session.request(request);
|
|
272
|
+
const value = name === "kdna.audit" ? slot.views.audit(args.audit_ref, args.budget_bytes) : name === "kdna.inspect" ? await inspectBoundFile(slot.binding, operation.controller.signal) : await slot.session.request(request);
|
|
147
273
|
if (operation.cancelled) throw new AdapterError("MCP_READ_CANCELLED", "Local read presentation was cancelled; this process binding is closed.");
|
|
148
274
|
const success = value.channel === "read_envelope" ? ["ready", "catalog_only"].includes(value.envelope.status) : value.status === "accepted";
|
|
149
|
-
if (name !== "kdna.audit") views.observe(value);
|
|
275
|
+
if (name !== "kdna.audit") { slot.views.observe(value); observeIdentity(slot, value); }
|
|
150
276
|
// kdna.audit returns the exact past full result it stored; the model
|
|
151
277
|
// presentation default applies to new reads, not to the audit record.
|
|
152
|
-
const presentation = name === "kdna.audit" ? value :
|
|
278
|
+
const presentation = name === "kdna.audit" ? value : presentSlot(slot, value, args);
|
|
153
279
|
if (isCatalogBody && success) {
|
|
154
280
|
const projectedBytes = Buffer.byteLength(JSON.stringify(presentation), "utf8");
|
|
155
281
|
if (projectedBytes > callerBudget) {
|
|
@@ -193,7 +319,21 @@ if (binding) {
|
|
|
193
319
|
if (method !== "tools/call") return error(id, -32601, "Method not found");
|
|
194
320
|
if (!keys(params, ["name", "arguments"]) || !names.has(params.name) || !validCall(params.name, params.arguments)) return error(id, -32602, "Invalid tool name or arguments");
|
|
195
321
|
if (active?.id === id) return error(id, -32600, "Request id is already active");
|
|
196
|
-
if (params.name === "kdna.binding-status")
|
|
322
|
+
if (params.name === "kdna.binding-status") {
|
|
323
|
+
return result(id, text({
|
|
324
|
+
state: binding.state,
|
|
325
|
+
file_name: binding.name,
|
|
326
|
+
local_binding_digest: binding.digest,
|
|
327
|
+
bound_asset_count: binding.assets.length,
|
|
328
|
+
bound_assets: binding.assets.map(entry => ({ index: entry.index, file_name: entry.name, local_binding_digest: entry.digest })),
|
|
329
|
+
read_permission: binding.state === "bound" ? "operator_granted_for_this_process" : "not_granted",
|
|
330
|
+
presentation_default: defaultPresentation,
|
|
331
|
+
body_view_contract: modelView?.MODEL_VIEW_CONTRACT ?? null,
|
|
332
|
+
busy: active !== null,
|
|
333
|
+
action_authorized: false,
|
|
334
|
+
creation_accepted: false,
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
197
337
|
if (params.name === "kdna.cancel") { await revoke(); return result(id, text({ state: "cancelled", binding_closed: true, action_authorized: false })); }
|
|
198
338
|
if (active) return result(id, toolError(new AdapterError("MCP_READ_BUSY", "Wait for the current local read or cancel it.")));
|
|
199
339
|
startRead(id, params.name, params.arguments);
|
package/bin/operator-binding.mjs
CHANGED
|
@@ -3,6 +3,8 @@ import os from "node:os";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
|
|
6
|
+
export const MAX_BOUND_ASSETS = 16;
|
|
7
|
+
|
|
6
8
|
export class AdapterError extends Error {
|
|
7
9
|
constructor(code, message) { super(message); this.code = code; }
|
|
8
10
|
}
|
|
@@ -69,27 +71,67 @@ function readPasswordFd(fdNumber) {
|
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
function copyAssetFile(selectedPath, destinationPath) {
|
|
75
|
+
if (!path.isAbsolute(selectedPath) || path.resolve(selectedPath) !== selectedPath || path.extname(selectedPath) !== ".kdna" || selectedPath.length > 4096) throw invalid();
|
|
76
|
+
let descriptor;
|
|
77
|
+
try {
|
|
78
|
+
const before = fs.lstatSync(selectedPath);
|
|
79
|
+
if (!before.isFile() || before.isSymbolicLink() || before.size > 64 * 1024 * 1024 || fs.realpathSync(selectedPath) !== selectedPath) throw invalid();
|
|
80
|
+
descriptor = fs.openSync(selectedPath, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0));
|
|
81
|
+
const opened = fs.fstatSync(descriptor);
|
|
82
|
+
if (!sameFile(before, opened)) throw invalid();
|
|
83
|
+
const bytes = Buffer.alloc(opened.size);
|
|
84
|
+
let count = 0;
|
|
85
|
+
while (count < bytes.length) {
|
|
86
|
+
const read = fs.readSync(descriptor, bytes, count, bytes.length - count, null);
|
|
87
|
+
if (read === 0) throw invalid();
|
|
88
|
+
count += read;
|
|
89
|
+
}
|
|
90
|
+
if (fs.readSync(descriptor, Buffer.alloc(1), 0, 1, null) !== 0 || !sameFile(opened, fs.fstatSync(descriptor))) throw invalid();
|
|
91
|
+
fs.writeFileSync(destinationPath, bytes, { flag: "wx", mode: 0o600 });
|
|
92
|
+
return {
|
|
93
|
+
name: path.basename(selectedPath),
|
|
94
|
+
digest: "sha256:" + createHash("sha256").update(bytes).digest("hex"),
|
|
95
|
+
};
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (error instanceof AdapterError) throw error;
|
|
98
|
+
throw invalid();
|
|
99
|
+
} finally {
|
|
100
|
+
if (descriptor !== undefined) fs.closeSync(descriptor);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
72
104
|
// Only the local operator/trusted launcher supplies argv, never MCP input.
|
|
73
105
|
export function bindOperatorInput(argv) {
|
|
74
|
-
|
|
106
|
+
const selected = [];
|
|
107
|
+
let allowed = false, passwordFile, passwordFd;
|
|
75
108
|
for (let i = 0; i < argv.length; i++) {
|
|
76
|
-
if (argv[i] === "--asset" &&
|
|
109
|
+
if (argv[i] === "--asset" && typeof argv[i + 1] === "string" && argv[i + 1].length > 0) {
|
|
110
|
+
if (selected.length >= MAX_BOUND_ASSETS) throw new AdapterError("MCP_ARGUMENT_INVALID", "At most " + MAX_BOUND_ASSETS + " --asset files may be bound in one process.");
|
|
111
|
+
const next = argv[++i];
|
|
112
|
+
if (selected.includes(next)) throw new AdapterError("MCP_ARGUMENT_INVALID", "Duplicate --asset path in operator startup arguments.");
|
|
113
|
+
selected.push(next);
|
|
114
|
+
}
|
|
77
115
|
else if (argv[i] === "--allow-read" && !allowed) allowed = true;
|
|
78
116
|
else if (argv[i] === "--password-file" && passwordFile === undefined && passwordFd === undefined && typeof argv[i + 1] === "string" && argv[i + 1].length > 0) passwordFile = argv[++i];
|
|
79
117
|
else if (argv[i] === "--password-fd" && passwordFd === undefined && passwordFile === undefined && typeof argv[i + 1] === "string" && /^[1-9][0-9]*$/.test(argv[i + 1]) && Number(argv[i + 1]) >= 3 && Number.isSafeInteger(Number(argv[i + 1]))) passwordFd = Number(argv[++i]);
|
|
80
|
-
else throw new AdapterError("MCP_ARGUMENT_INVALID", "Use --asset /absolute/selected.kdna --allow-read [--password-file /absolute/passphrase | --password-fd <fd>=3..], or start without a binding.");
|
|
118
|
+
else throw new AdapterError("MCP_ARGUMENT_INVALID", "Use --asset /absolute/selected.kdna [--asset ...] --allow-read [--password-file /absolute/passphrase | --password-fd <fd>=3..], or start without a binding.");
|
|
119
|
+
}
|
|
120
|
+
if (allowed && selected.length === 0) throw new AdapterError("MCP_ARGUMENT_INVALID", "An operator-selected file is required.");
|
|
121
|
+
if ((passwordFile !== undefined || passwordFd !== undefined) && (!allowed || selected.length !== 1)) {
|
|
122
|
+
throw new AdapterError("MCP_ARGUMENT_INVALID", "Password options require exactly one --asset /absolute/selected.kdna with --allow-read.");
|
|
81
123
|
}
|
|
82
|
-
if (allowed && selected === undefined) throw new AdapterError("MCP_ARGUMENT_INVALID", "An operator-selected file is required.");
|
|
83
|
-
if ((passwordFile !== undefined || passwordFd !== undefined) && (!allowed || selected === undefined)) throw new AdapterError("MCP_ARGUMENT_INVALID", "Password options require --asset /absolute/selected.kdna --allow-read.");
|
|
84
124
|
let directory = null, identity = null, closed = false;
|
|
85
125
|
const binding = {
|
|
86
|
-
state: "unbound", file: null, passwordFile: null, name: null, digest: null,
|
|
126
|
+
state: "unbound", file: null, passwordFile: null, name: null, digest: null, assets: [],
|
|
87
127
|
assertReadable() {
|
|
88
128
|
if (closed) throw new AdapterError("MCP_BINDING_CANCELLED", "This process binding is closed. The operator must start a new process to select again.");
|
|
89
|
-
if (
|
|
129
|
+
if (this.assets.length === 0) throw new AdapterError("MCP_BINDING_REQUIRED", "The local operator must select at least one file and permit local read before starting this process.");
|
|
90
130
|
},
|
|
91
131
|
close() {
|
|
92
132
|
closed = true; this.state = "cancelled"; this.file = null;
|
|
133
|
+
for (const entry of this.assets) { entry.file = null; entry.passwordFile = null; }
|
|
134
|
+
this.assets = [];
|
|
93
135
|
if (this.passwordFile !== null) {
|
|
94
136
|
try {
|
|
95
137
|
const stat = fs.lstatSync(this.passwordFile);
|
|
@@ -105,40 +147,49 @@ export function bindOperatorInput(argv) {
|
|
|
105
147
|
},
|
|
106
148
|
};
|
|
107
149
|
if (!allowed) return binding;
|
|
108
|
-
if (!path.isAbsolute(selected) || path.resolve(selected) !== selected || path.extname(selected) !== ".kdna" || selected.length > 4096) throw invalid();
|
|
109
|
-
let descriptor;
|
|
110
150
|
try {
|
|
111
|
-
const before = fs.lstatSync(selected);
|
|
112
|
-
if (!before.isFile() || before.isSymbolicLink() || before.size > 64 * 1024 * 1024 || fs.realpathSync(selected) !== selected) throw invalid();
|
|
113
|
-
descriptor = fs.openSync(selected, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0));
|
|
114
|
-
const opened = fs.fstatSync(descriptor);
|
|
115
|
-
if (!sameFile(before, opened)) throw invalid();
|
|
116
|
-
const bytes = Buffer.alloc(opened.size);
|
|
117
|
-
let count = 0;
|
|
118
|
-
while (count < bytes.length) {
|
|
119
|
-
const read = fs.readSync(descriptor, bytes, count, bytes.length - count, null);
|
|
120
|
-
if (read === 0) throw invalid();
|
|
121
|
-
count += read;
|
|
122
|
-
}
|
|
123
|
-
if (fs.readSync(descriptor, Buffer.alloc(1), 0, 1, null) !== 0 || !sameFile(opened, fs.fstatSync(descriptor))) throw invalid();
|
|
124
151
|
const passphraseBytes = passwordFile !== undefined ? readPasswordFile(passwordFile) : passwordFd !== undefined ? readPasswordFd(passwordFd) : null;
|
|
125
152
|
directory = fs.mkdtempSync(path.join(os.tmpdir(), "kdna-mcp-read-"));
|
|
126
153
|
fs.chmodSync(directory, 0o700); identity = fs.lstatSync(directory);
|
|
127
|
-
|
|
128
|
-
fs.writeFileSync(copy, bytes, { flag: "wx", mode: 0o600 });
|
|
154
|
+
let passCopy = null;
|
|
129
155
|
if (passphraseBytes !== null) {
|
|
130
|
-
|
|
156
|
+
passCopy = path.join(directory, "passphrase");
|
|
131
157
|
fs.writeFileSync(passCopy, passphraseBytes, { flag: "wx", mode: 0o600 });
|
|
132
158
|
passphraseBytes.fill(0);
|
|
133
159
|
binding.passwordFile = passCopy;
|
|
134
160
|
}
|
|
135
|
-
|
|
136
|
-
|
|
161
|
+
const boundAssets = [];
|
|
162
|
+
for (let index = 0; index < selected.length; index++) {
|
|
163
|
+
const copy = path.join(directory, selected.length === 1 ? "selected.kdna" : `asset-${index}.kdna`);
|
|
164
|
+
const copied = copyAssetFile(selected[index], copy);
|
|
165
|
+
const assetBinding = {
|
|
166
|
+
index,
|
|
167
|
+
file: copy,
|
|
168
|
+
passwordFile: passCopy,
|
|
169
|
+
name: copied.name,
|
|
170
|
+
digest: copied.digest,
|
|
171
|
+
assertReadable() {
|
|
172
|
+
binding.assertReadable();
|
|
173
|
+
if (!this.file) throw new AdapterError("MCP_BINDING_CANCELLED", "This process binding is closed. The operator must start a new process to select again.");
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
boundAssets.push(assetBinding);
|
|
177
|
+
}
|
|
178
|
+
binding.assets = boundAssets;
|
|
179
|
+
if (boundAssets.length === 1) {
|
|
180
|
+
binding.file = boundAssets[0].file;
|
|
181
|
+
binding.name = boundAssets[0].name;
|
|
182
|
+
binding.digest = boundAssets[0].digest;
|
|
183
|
+
} else {
|
|
184
|
+
binding.file = null;
|
|
185
|
+
binding.name = null;
|
|
186
|
+
binding.digest = "sha256:" + createHash("sha256").update(boundAssets.map(entry => entry.digest).join("\n")).digest("hex");
|
|
187
|
+
}
|
|
137
188
|
binding.state = "bound";
|
|
138
189
|
return binding;
|
|
139
190
|
} catch (error) {
|
|
140
191
|
if (directory !== null) binding.close();
|
|
141
192
|
if (error instanceof AdapterError) throw error;
|
|
142
193
|
throw invalid();
|
|
143
|
-
}
|
|
194
|
+
}
|
|
144
195
|
}
|
package/bin/read-session.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { AdapterError } from "./operator-binding.mjs";
|
|
|
8
8
|
|
|
9
9
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
10
10
|
export const packageInfo = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
11
|
-
const versions = { cli: "0.
|
|
11
|
+
const versions = { cli: "0.47.0", core: "0.37.12", read: "0.13.6" };
|
|
12
12
|
function localPackage(name) {
|
|
13
13
|
const roots = [path.join(root, "node_modules")];
|
|
14
14
|
if (path.basename(path.dirname(root)) === "@aikdna" && path.basename(path.dirname(path.dirname(root))) === "node_modules") roots.push(path.dirname(path.dirname(root)));
|
|
@@ -26,7 +26,7 @@ const cli = localPackage("cli"), core = localPackage("core"), read = localPackag
|
|
|
26
26
|
const cliEntry = path.resolve(cli.directory, cli.value.bin?.kdna || "");
|
|
27
27
|
const bindingBytes = fs.readFileSync(path.join(cli.directory, "public-contract-binding.json"));
|
|
28
28
|
export const publicBinding = JSON.parse(bindingBytes);
|
|
29
|
-
if (packageInfo.kdna_runtime?.cli !== versions.cli || packageInfo.kdna_runtime?.core !== versions.core || packageInfo.kdna_runtime?.read !== versions.read || createHash("sha256").update(bindingBytes).digest("hex") !== "
|
|
29
|
+
if (packageInfo.kdna_runtime?.cli !== versions.cli || packageInfo.kdna_runtime?.core !== versions.core || packageInfo.kdna_runtime?.read !== versions.read || createHash("sha256").update(bindingBytes).digest("hex") !== "ad83927304f7c7f3dece9646c9a73df46af85ddefab68798df7cc9e4d7b4dcdb" || publicBinding.implementation?.version !== versions.cli || publicBinding.tuple?.container !== "0.6.0" || publicBinding.tuple?.read !== "kdna.read/0.7.0-candidate" || publicBinding.accepted_core?.version !== versions.core || publicBinding.accepted_read?.version !== versions.read || packageInfo.kdna_runtime?.read_contract !== "kdna.read/0.7.0-candidate" || !cliEntry.startsWith(cli.directory + path.sep) || !fs.statSync(cliEntry).isFile()) throw new AdapterError("MCP_RUNTIME_INVALID", "The fixed native runtime contract binding is invalid.");
|
|
30
30
|
// Every consumer resolves the same fixed Core/Read instance; nested shadow copies are refused.
|
|
31
31
|
for (const [consumer, dependency] of [[cli, core], [cli, read], [read, core]]) {
|
|
32
32
|
const resolved = createRequire(path.join(consumer.directory, "package.json")).resolve(dependency.value.name + "/package.json");
|
package/bin/reading-views.mjs
CHANGED
|
@@ -8,7 +8,7 @@ const bytes = v => Buffer.byteLength(encode(v));
|
|
|
8
8
|
const digest = v => "sha256:" + createHash("sha256").update(encode(v)).digest("hex");
|
|
9
9
|
const fail = (code, message) => { throw new AdapterError(code, message); };
|
|
10
10
|
const envelopeKeys = ["contract", "mode", "request_id", "status", "tuple", "asset", "snapshot_id", "digests", "content", "states", "diagnostics", "omissions", "assessment", "verification", "receipt", "budget"];
|
|
11
|
-
const contentKeys = ["declarations", "catalog", "selected", "closure", "references", "relationships", "missing", "provenance", "asset_capability", "asset_index", "expansion_handles"];
|
|
11
|
+
const contentKeys = ["declarations", "catalog", "catalog_overview", "selected", "closure", "references", "relationships", "missing", "provenance", "asset_capability", "asset_index", "expansion_handles"];
|
|
12
12
|
const handleKeys = ["binding_kind", "handle_id", "asset", "tuple", "origin", "issuing_operation_id", "issuing_request_digest", "anchor", "target", "scope", "issued_at", "expires_at", "host_id", "host_epoch"];
|
|
13
13
|
const exact = (v, names) => object(v) && Object.keys(v).length === names.length && names.every(k => Object.hasOwn(v, k));
|
|
14
14
|
const byteAdmissionContract = v => exact(v, ["id", "version", "definition_digest"]) && v.id === "kdna.section-bytes-node" && v.version === "0.1.1-candidate" && v.definition_digest === "sha256:8358dfe622117bb88866d7f72ca15e21961a87b37e108978ed05015b102277ef";
|
|
@@ -145,6 +145,22 @@ export class ReadingViews {
|
|
|
145
145
|
this.records = records; this.handles = handles; this.totalBytes = storage;
|
|
146
146
|
return model;
|
|
147
147
|
}
|
|
148
|
+
hasAudit(ref) {
|
|
149
|
+
try { this.binding.assertReadable(); }
|
|
150
|
+
catch (cause) { this.clear(); throw cause; }
|
|
151
|
+
if (this.session.stopped) { this.clear(); return false; }
|
|
152
|
+
this.prune();
|
|
153
|
+
const record = this.records.get(ref);
|
|
154
|
+
return Boolean(record && record.scope === this.scope);
|
|
155
|
+
}
|
|
156
|
+
hasHandle(ref) {
|
|
157
|
+
try { this.binding.assertReadable(); }
|
|
158
|
+
catch (cause) { this.clear(); throw cause; }
|
|
159
|
+
if (this.session.stopped) { this.clear(); return false; }
|
|
160
|
+
this.prune();
|
|
161
|
+
const record = this.handles.get(ref);
|
|
162
|
+
return Boolean(record && record.scope === this.scope);
|
|
163
|
+
}
|
|
148
164
|
audit(ref, budget) {
|
|
149
165
|
this.assertLive(); this.prune();
|
|
150
166
|
const record = this.records.get(ref);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikdna/kdna-mcp-server",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "Local stdio Read adapter for
|
|
3
|
+
"version": "0.8.5",
|
|
4
|
+
"description": "Local stdio Read adapter for operator-bound KDNA assets.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://aikdna.com",
|
|
7
7
|
"repository": {
|
|
@@ -25,19 +25,7 @@
|
|
|
25
25
|
"bin/",
|
|
26
26
|
"README.md",
|
|
27
27
|
"LICENSE",
|
|
28
|
-
"NOTICE"
|
|
29
|
-
"vendor/aikdna-kdna-core-0.37.11.tgz",
|
|
30
|
-
"vendor/aikdna-kdna-read-0.13.5.tgz",
|
|
31
|
-
"vendor/ajv-8.20.0.tgz",
|
|
32
|
-
"vendor/ajv-formats-3.0.1.tgz",
|
|
33
|
-
"vendor/cbor-x-1.6.9.tgz",
|
|
34
|
-
"vendor/fast-deep-equal-3.1.3.tgz",
|
|
35
|
-
"vendor/fast-uri-3.1.9.tgz",
|
|
36
|
-
"vendor/json-schema-traverse-1.0.0.tgz",
|
|
37
|
-
"vendor/noble-hashes-1.8.0.tgz",
|
|
38
|
-
"vendor/pako-2.1.0.tgz",
|
|
39
|
-
"vendor/require-from-string-2.0.2.tgz",
|
|
40
|
-
"vendor/aikdna-kdna-cli-0.45.2.tgz"
|
|
28
|
+
"NOTICE"
|
|
41
29
|
],
|
|
42
30
|
"scripts": {
|
|
43
31
|
"test": "node scripts/verify-runtime-candidates.mjs && node ../scripts/check-current-names.mjs && node --test test/*.test.mjs && npm run check:orphan-lockfile",
|
|
@@ -52,8 +40,8 @@
|
|
|
52
40
|
},
|
|
53
41
|
"license": "Apache-2.0",
|
|
54
42
|
"dependencies": {
|
|
55
|
-
"@aikdna/kdna-core": "0.37.
|
|
56
|
-
"@aikdna/kdna-read": "0.13.
|
|
43
|
+
"@aikdna/kdna-core": "0.37.12",
|
|
44
|
+
"@aikdna/kdna-read": "0.13.6",
|
|
57
45
|
"ajv": "8.20.0",
|
|
58
46
|
"ajv-formats": "3.0.1",
|
|
59
47
|
"cbor-x": "1.6.9",
|
|
@@ -63,12 +51,12 @@
|
|
|
63
51
|
"@noble/hashes": "1.8.0",
|
|
64
52
|
"pako": "2.1.0",
|
|
65
53
|
"require-from-string": "2.0.2",
|
|
66
|
-
"@aikdna/kdna-cli": "0.
|
|
54
|
+
"@aikdna/kdna-cli": "0.47.0"
|
|
67
55
|
},
|
|
68
56
|
"kdna_runtime": {
|
|
69
|
-
"cli": "0.
|
|
70
|
-
"core": "0.37.
|
|
71
|
-
"read": "0.13.
|
|
57
|
+
"cli": "0.47.0",
|
|
58
|
+
"core": "0.37.12",
|
|
59
|
+
"read": "0.13.6",
|
|
72
60
|
"read_contract": "kdna.read/0.7.0-candidate"
|
|
73
61
|
},
|
|
74
62
|
"engines": {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/vendor/ajv-8.20.0.tgz
DELETED
|
Binary file
|
|
Binary file
|
package/vendor/cbor-x-1.6.9.tgz
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/vendor/pako-2.1.0.tgz
DELETED
|
Binary file
|
|
Binary file
|