@aikdna/kdna-mcp-server 0.8.3 → 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 CHANGED
@@ -1,12 +1,14 @@
1
- # KDNA MCP 0.8.3 — local stdio Read adapter
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`) delegates native container `0.6.0` admission and scoped Read operations to the exact CLI `0.45.2` / Core `0.37.11` / Read `0.13.5` 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 single-asset native `0.6.0` adapter.
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 for password-protected 0.6.0 .kdna files (mode 0600 file or fd >= 3):
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
 
@@ -55,11 +57,18 @@ One server process serves one selected artifact for its whole lifetime.
55
57
  the current local read or cancel it.") instead of being queued: wait for the
56
58
  current result, or end it through `kdna.cancel` or the client's request
57
59
  cancellation — cancelling closes the process binding.
58
- - **Every read call carries its own budget.** `kdna.catalog`, `kdna.read`,
59
- `kdna.expand` and `kdna.audit` each require an explicit integer
60
- `budget_bytes` (0 through 1000000); there is no default budget, and a request
61
- whose budget cannot hold its result is refused with a named error rather than
62
- returning a partial view.
60
+ - **Every read call enforces a byte budget.** `kdna.catalog` accepts an
61
+ optional integer `budget_bytes` (0 through 1000000, defaulting to `1000000`):
62
+ in the default `body` presentation it bounds the projected body response
63
+ (using an internal `4000000`-byte official envelope ceiling when `budget_bytes > 0`
64
+ so large multi-judgment catalogs whose raw envelope exceeds `200000` bytes
65
+ still project cleanly into their compact body view, failing closed with
66
+ `MCP_BODY_VIEW_BUDGET_EXCEEDED` if the projected body exceeds `budget_bytes`);
67
+ in `presentation: "full"` or `"task"` it bounds the complete official Read
68
+ envelope (`recommended >= 1000000`). `kdna.read`, `kdna.expand`, and
69
+ `kdna.audit` each require an explicit integer `budget_bytes` (0 through
70
+ 1000000); a request whose budget cannot hold its result is refused with a
71
+ named error rather than returning a partial view.
63
72
 
64
73
  ## MCP transport and tools
65
74
 
@@ -84,13 +93,14 @@ argument or method parameter beyond request-level `_meta`.
84
93
 
85
94
  | Tool | Arguments | Result |
86
95
  | --- | --- | --- |
87
- | kdna.binding-status | {} | Local binding state, not a public authority receipt |
88
- | kdna.inspect | {} | Official CLI technical admission/metadata |
89
- | kdna.catalog | budget_bytes; optional presentation | Complete public catalog within the budget |
90
- | kdna.read | selection, budget_bytes; optional presentation | Exact selection and mandatory closure |
91
- | kdna.expand | exactly one of handle or handle_ref, budget_bytes; optional presentation | Original issued handle passed to the same official session |
92
- | kdna.audit | audit_ref, budget_bytes | Exact original full result of an earlier task delivery |
93
- | kdna.cancel | {} | Closes binding and current session |
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 |
94
104
 
95
105
  For catalog/read/expand, `presentation` is `"body"`, `"full"` or `"task"`.
96
106
  Omission means `"body"` whenever the installed Read package provides the body
@@ -256,7 +266,7 @@ container format is not permission to convert it implicitly or read its raw payl
256
266
 
257
267
  For an Agent-led task, begin with the [getting-started guide](https://github.com/aikdna/kdna-skills/blob/main/docs/GETTING_STARTED.md).
258
268
  The installer requires Node.js 22 or later, npm, `bash` and `tar`. The current
259
- CLI 0.45.2 / Core 0.37.11 / Read 0.13.5 graph was exercised with Node.js 22.22.3
269
+ CLI 0.47.0 / Core 0.37.12 / Read 0.13.6 graph was exercised with Node.js 22.22.3
260
270
  and npm 10.9.8. Earlier companion graphs' runtime checks do not verify this
261
271
  one on additional Node versions. The CI matrix is a set of required checks,
262
272
  not evidence that every run has already passed. From `mcp-server/`:
@@ -294,17 +304,18 @@ refuses an existing destination. Each runtime archive is an exact root `file:`
294
304
  dependency, with a matching root override. This lets npm resolve dependencies
295
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.
296
306
 
297
- The MCP tar has twenty-one regular members: bin modules, package metadata,
298
- README, LICENSE, NOTICE and twelve runtime archives. Tests, source tooling and
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
299
310
  package-lock.json are excluded. The companion consumer lock is generated from
300
311
  the checked source graph. The packed-consumer test installs with an empty npm
301
312
  cache, then runs the same real stdio boundary suite against the installed bin.
302
313
 
303
- Canonical npm publication of `@aikdna/kdna-mcp-server@0.8.3` runs exclusively via the GitHub Release workflow (`kdna-mcp-server-0.8.3`) after companion packages (`@aikdna/kdna-core@0.37.11`, `@aikdna/kdna-read@0.13.5`, `@aikdna/kdna-cli@0.45.2`) are published on the official registry. Source and installed process tests do not
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
304
315
  establish named Host adoption, human review, authorship or Creation acceptance.
305
316
 
306
317
  ## Native section contract boundary
307
318
 
308
- The complete CLI public contract binding is pinned by SHA-256 `6c91bc8b10abdb1a0cfa23cae3904a11075200b03011d8a7e3772ea9a40ae6c8`. 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.
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.
309
320
 
310
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
@@ -7,7 +7,10 @@ import { loadModelView, projectBody } from "./model-view.mjs";
7
7
 
8
8
  const object = value => value !== null && typeof value === "object" && !Array.isArray(value);
9
9
  const keys = (value, expected) => object(value) && Object.keys(value).length === expected.length && expected.every(key => Object.hasOwn(value, key));
10
+ const DEFAULT_CATALOG_BUDGET_BYTES = 1000000;
11
+ const CATALOG_BODY_ENVELOPE_BUDGET_BYTES = 4000000;
10
12
  const budgetSchema = { type: "integer", minimum: 0, maximum: 1000000 };
13
+ const catalogBudgetSchema = { type: "integer", minimum: 0, maximum: 1000000, default: DEFAULT_CATALOG_BUDGET_BYTES, description: "Optional UTF-8 byte budget (0..1000000, default 1000000). For the default body presentation, bounds the projected body response (recommended >= 32768; large 45-judgment catalogs are ~8-12 KiB projected vs >200 KiB raw). For presentation:\"full\" or \"task\", bounds the complete official Read envelope (recommended >= 1000000)." };
11
14
  const presentationProperties = { presentation: { type: "string", enum: ["body", "full", "task"] }, view_budget_bytes: budgetSchema };
12
15
  const presentationRules = [{ if: { required: ["presentation"], properties: { presentation: { const: "task" } } }, then: { required: ["view_budget_bytes"] }, else: { not: { required: ["view_budget_bytes"] } } }];
13
16
  const emptySchema = { type: "object", properties: {}, additionalProperties: false };
@@ -42,9 +45,10 @@ function selectionIds(selection) {
42
45
  }
43
46
  const tools = [
44
47
  { name: "kdna.binding-status", description: "Report only this process's operator-established local binding. It grants no new permission.", inputSchema: emptySchema },
45
- { name: "kdna.inspect", description: "Inspect the bound file through the official CLI; technical facts do not authorize actions or establish authorship.", inputSchema: emptySchema },
46
- { name: "kdna.catalog", description: "Read the complete public catalog once. 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", required: ["budget_bytes"], additionalProperties: false, allOf: presentationRules, properties: { budget_bytes: budgetSchema, ...presentationProperties } } },
47
- { name: "kdna.read", description: "Batch the exact judgments needed for this task with mandatory closure in one snapshot. 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 } } },
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 } } },
48
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 } } },
49
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 } } },
50
54
  { name: "kdna.cancel", description: "Cancel local presentation and revoke this process binding. Only a new operator-controlled launch can select again.", inputSchema: emptySchema },
@@ -55,20 +59,58 @@ try { binding = bindOperatorInput(process.argv.slice(2)); }
55
59
  catch (error) { process.stderr.write((error instanceof AdapterError ? error.code : "MCP_STARTUP_FAILED") + "\n"); process.exitCode = 2; }
56
60
 
57
61
  if (binding) {
58
- const session = new ReadSession(binding);
59
- const views = new ReadingViews(binding, session);
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
+ });
60
73
  const modelView = loadModelView();
61
74
  const defaultPresentation = modelView ? "body" : "full";
62
75
  // What the model receives is the official Read projection of the complete
63
76
  // result this process already validated; the full result stays available to
64
77
  // the same request and to the audit record.
65
- function present(value, args) {
78
+ function presentSlot(slot, value, args) {
66
79
  const selected = args.presentation ?? defaultPresentation;
67
- if (selected === "task") return views.task(value, args.view_budget_bytes);
80
+ if (selected === "task") return slot.views.task(value, args.view_budget_bytes);
68
81
  if (selected === "full") return value;
69
82
  if (!modelView) throw new AdapterError("MCP_MODEL_VIEW_UNAVAILABLE", "The installed Read package does not provide the body projection. Request full presentation explicitly.");
70
83
  return projectBody(modelView, value);
71
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
+ }
72
114
  let initialized = false, ready = false, active = null, shuttingDown = false, shutdownWork = null, outputFailed = false, writing = Promise.resolve();
73
115
  const outstanding = new Set();
74
116
  const write = message => {
@@ -84,24 +126,24 @@ if (binding) {
84
126
  const text = value => ({ content: [{ type: "text", text: JSON.stringify(value) }] });
85
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 });
86
128
  async function revoke() {
87
- views.clear();
129
+ for (const slot of slots) slot.views.clear();
88
130
  const current = active;
89
131
  if (current) { current.cancelled = true; current.controller.abort(); }
90
- await session.close(false);
132
+ await Promise.allSettled(slots.map(slot => slot.session.close(false)));
91
133
  if (current) await Promise.allSettled([current.work]);
92
134
  binding.close();
93
135
  }
94
136
  async function shutdown(graceful) {
95
- views.clear();
137
+ for (const slot of slots) slot.views.clear();
96
138
  if (!graceful) {
97
139
  if (active) { active.cancelled = true; active.controller.abort(); }
98
- void session.close(false);
140
+ for (const slot of slots) void slot.session.close(false);
99
141
  }
100
142
  if (shutdownWork) return shutdownWork;
101
143
  shuttingDown = true;
102
144
  shutdownWork = (async () => {
103
145
  await Promise.allSettled([...outstanding]);
104
- await session.close(graceful);
146
+ await Promise.allSettled(slots.map(slot => slot.session.close(graceful)));
105
147
  try { binding.close(); } catch { process.stderr.write("MCP_CLEANUP_FAILED\n"); process.exitCode = 1; }
106
148
  process.stdin.destroy();
107
149
  })();
@@ -111,14 +153,16 @@ if (binding) {
111
153
  process.stdout.on("close", () => { outputFailed = true; void shutdown(false); });
112
154
  for (const signal of ["SIGTERM", "SIGINT"]) process.once(signal, () => { void shutdown(false); });
113
155
  const validBudget = value => Number.isSafeInteger(value) && value >= 0 && value <= 1000000;
114
- function validPresentation(args, required) {
115
- if (!object(args) || Object.keys(args).some(key => ![...required, "presentation", "view_budget_bytes"].includes(key)) || !required.every(key => Object.hasOwn(args, key))) return false;
156
+ function validPresentation(args, required, optional = []) {
157
+ if (!object(args) || Object.keys(args).some(key => ![...required, ...optional, "presentation", "view_budget_bytes"].includes(key)) || !required.every(key => Object.hasOwn(args, key))) return false;
116
158
  if (Object.hasOwn(args, "presentation") && !["body", "full", "task"].includes(args.presentation)) return false;
117
159
  return args.presentation === "task" ? Object.hasOwn(args, "view_budget_bytes") && validBudget(args.view_budget_bytes) : !Object.hasOwn(args, "view_budget_bytes");
118
160
  }
119
161
  function validCall(name, args) {
120
- if (["kdna.binding-status", "kdna.inspect", "kdna.cancel"].includes(name)) return keys(args, []);
121
- if (name === "kdna.catalog") return validPresentation(args, ["budget_bytes"]) && validBudget(args.budget_bytes);
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));
122
166
  if (name === "kdna.read") return validPresentation(args, ["selection", "budget_bytes"]) && validBudget(args.budget_bytes) && validReadSelection(args.selection);
123
167
  if (name === "kdna.expand") {
124
168
  if (!object(args) || Object.hasOwn(args, "handle") === Object.hasOwn(args, "handle_ref")) return false;
@@ -134,15 +178,110 @@ if (binding) {
134
178
  operation.work = (async () => {
135
179
  try {
136
180
  binding.assertReadable();
137
- const handle = Object.hasOwn(args, "handle_ref") ? views.expand(args.handle_ref) : args.handle ?? null;
138
- const request = { request_id: "mcp:" + randomUUID(), tuple: publicBinding.tuple, budget_bytes: args.budget_bytes, 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 };
139
- 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);
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;
268
+ const callerBudget = name === "kdna.catalog" && !Object.hasOwn(args, "budget_bytes") ? DEFAULT_CATALOG_BUDGET_BYTES : args.budget_bytes;
269
+ const isCatalogBody = name === "kdna.catalog" && selectedPresentation === "body" && modelView !== null;
270
+ const officialBudget = isCatalogBody && callerBudget > 0 ? Math.max(callerBudget, CATALOG_BODY_ENVELOPE_BUDGET_BYTES) : callerBudget;
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 };
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);
140
273
  if (operation.cancelled) throw new AdapterError("MCP_READ_CANCELLED", "Local read presentation was cancelled; this process binding is closed.");
141
274
  const success = value.channel === "read_envelope" ? ["ready", "catalog_only"].includes(value.envelope.status) : value.status === "accepted";
142
- if (name !== "kdna.audit") views.observe(value);
275
+ if (name !== "kdna.audit") { slot.views.observe(value); observeIdentity(slot, value); }
143
276
  // kdna.audit returns the exact past full result it stored; the model
144
277
  // presentation default applies to new reads, not to the audit record.
145
- const presentation = name === "kdna.audit" ? value : present(value, args);
278
+ const presentation = name === "kdna.audit" ? value : presentSlot(slot, value, args);
279
+ if (isCatalogBody && success) {
280
+ const projectedBytes = Buffer.byteLength(JSON.stringify(presentation), "utf8");
281
+ if (projectedBytes > callerBudget) {
282
+ throw new AdapterError("MCP_BODY_VIEW_BUDGET_EXCEEDED", "The complete projected 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.");
283
+ }
284
+ }
146
285
  await result(id, { ...text(presentation), ...(success ? {} : { isError: true }) });
147
286
  } catch (cause) {
148
287
  if (!outputFailed) await result(id, toolError(cause));
@@ -180,7 +319,21 @@ if (binding) {
180
319
  if (method !== "tools/call") return error(id, -32601, "Method not found");
181
320
  if (!keys(params, ["name", "arguments"]) || !names.has(params.name) || !validCall(params.name, params.arguments)) return error(id, -32602, "Invalid tool name or arguments");
182
321
  if (active?.id === id) return error(id, -32600, "Request id is already active");
183
- if (params.name === "kdna.binding-status") return result(id, text({ state: binding.state, file_name: binding.name, local_binding_digest: binding.digest, read_permission: binding.state === "bound" ? "operator_granted_for_this_process" : "not_granted", presentation_default: defaultPresentation, body_view_contract: modelView?.MODEL_VIEW_CONTRACT ?? null, busy: active !== null, action_authorized: false, creation_accepted: false }));
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
+ }
184
337
  if (params.name === "kdna.cancel") { await revoke(); return result(id, text({ state: "cancelled", binding_closed: true, action_authorized: false })); }
185
338
  if (active) return result(id, toolError(new AdapterError("MCP_READ_BUSY", "Wait for the current local read or cancel it.")));
186
339
  startRead(id, params.name, params.arguments);
@@ -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
- let selected, allowed = false, passwordFile, passwordFd;
106
+ const selected = [];
107
+ let allowed = false, passwordFile, passwordFd;
75
108
  for (let i = 0; i < argv.length; i++) {
76
- if (argv[i] === "--asset" && selected === undefined && typeof argv[i + 1] === "string") selected = argv[++i];
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 (!this.file) throw new AdapterError("MCP_BINDING_REQUIRED", "The local operator must select one file and permit local read before starting this process.");
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
- const copy = path.join(directory, "selected.kdna");
128
- fs.writeFileSync(copy, bytes, { flag: "wx", mode: 0o600 });
154
+ let passCopy = null;
129
155
  if (passphraseBytes !== null) {
130
- const passCopy = path.join(directory, "passphrase");
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
- binding.file = copy; binding.name = path.basename(selected);
136
- binding.digest = "sha256:" + createHash("sha256").update(bytes).digest("hex");
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
- } finally { if (descriptor !== undefined) fs.closeSync(descriptor); }
194
+ }
144
195
  }
@@ -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.45.2", core: "0.37.11", read: "0.13.5" };
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") !== "29a3b8531f3c18aa0f9d86448ea29fead88e69de78aa248e9fbda3db1fa00186" || 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.");
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");
@@ -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.3",
4
- "description": "Local stdio Read adapter for one operator-bound KDNA asset.",
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.11",
56
- "@aikdna/kdna-read": "0.13.5",
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.45.2"
54
+ "@aikdna/kdna-cli": "0.47.0"
67
55
  },
68
56
  "kdna_runtime": {
69
- "cli": "0.45.2",
70
- "core": "0.37.11",
71
- "read": "0.13.5",
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
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file