@cueai/omni-reader-mcp 1.5.5 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tools.js CHANGED
@@ -7,7 +7,7 @@ import { hydrateInlineUrlResultSafely } from "./operation-manager.js";
7
7
  import { openAllowedFile, } from "./path-security.js";
8
8
  import { NOOP_PROGRESS } from "./progress.js";
9
9
  import { MACHINE_INSTRUCTIONS, cancelParseSchema, discardResultSchema, getParseStatusSchema, normalizeParseArguments, normalizeRepresentation, parseSchema, parseSchemaShape, readOutlineSchema, readResultSchema, saveResultSchema, } from "./protocol.js";
10
- import { discardResultOutputSchema, discardResultToolOutputSchema, localResultToResultField, parseResultSchema, parseToolOutputSchema, readOutlineOutputSchema, readOutlineToolOutputSchema, readResultOutputSchema, readResultToolOutputSchema, saveResultOutputSchema, saveResultToolOutputSchema, structuredResult, } from "./result-contract.js";
10
+ import { createFlatLocalResultCache, discardResultOutputSchema, discardResultToolOutputSchema, localResultToResultField, parseResultSchema, parseToolOutputSchema, presentRetainedResult, readOutlineOutputSchema, readOutlineToolOutputSchema, readResultOutputSchema, readResultToolOutputSchema, saveResultOutputSchema, saveResultToolOutputSchema, structuredResult, } from "./result-contract.js";
11
11
  import { classifySource } from "./source.js";
12
12
  import { TaskRuntime } from "./task-runtime.js";
13
13
  function bridgeError(code, message, facts = {}) {
@@ -58,9 +58,11 @@ function completedLocalResult(local) {
58
58
  operation_id: local.operationId,
59
59
  result,
60
60
  data_handling: dataHandling,
61
- ...(result.kind === "artifact"
62
- ? { local_result_cache: { expires_at: local.expiresAt, discard_action: "discard_result" } }
63
- : {}),
61
+ local_result_cache: createFlatLocalResultCache({
62
+ resultId: local.resultId,
63
+ resultBytes: local.resultBytes,
64
+ expiresAt: local.expiresAt,
65
+ }),
64
66
  };
65
67
  }
66
68
  async function parseLocal(args, clientRequestId, signal, progress, dependencies) {
@@ -151,6 +153,23 @@ async function preflightNonTextRepresentation(detail, sourceKind, signal, depend
151
153
  });
152
154
  }
153
155
  }
156
+ async function preflightArtifactDelivery(args, dependencies) {
157
+ if (args.resultDelivery !== "artifact")
158
+ return;
159
+ if (dependencies.artifactStore.preflightWrite === undefined
160
+ || dependencies.artifactStore.mintReadCursor === undefined) {
161
+ throw bridgeError("ARTIFACT_PREFLIGHT_FAILED", "The local result store cannot provide artifact delivery.");
162
+ }
163
+ await dependencies.artifactStore.preflightWrite();
164
+ }
165
+ async function presentParseResult(result, args, dependencies) {
166
+ return presentRetainedResult(result, args.resultDelivery, async (resultId, byteOffset) => {
167
+ if (dependencies.artifactStore.mintReadCursor === undefined) {
168
+ throw bridgeError("LOCAL_RESULT_INTEGRITY_FAILED", "The retained result cursor capability is unavailable.");
169
+ }
170
+ return dependencies.artifactStore.mintReadCursor(resultId, byteOffset);
171
+ });
172
+ }
154
173
  async function parseValue(args, signal, progress, dependencies) {
155
174
  try {
156
175
  const source = classifySource(args.source);
@@ -198,19 +217,23 @@ async function parseValue(args, signal, progress, dependencies) {
198
217
  },
199
218
  clientRequestId,
200
219
  signal,
220
+ resultDelivery: args.resultDelivery,
201
221
  context: source.kind === "local"
202
222
  ? { source: source.source, progress }
203
223
  : { source: source.source },
204
224
  });
205
225
  }
226
+ await preflightArtifactDelivery(args, dependencies);
206
227
  if (source.kind === "url") {
207
228
  if (dependencies.remoteClient === undefined) {
208
229
  throw bridgeError("REMOTE_PARSE_UNAVAILABLE", "Remote URL parsing is not available in this Bridge build.", { retryable: true });
209
230
  }
210
231
  const remoteResult = await dependencies.remoteClient.parse(source.source, clientRequestId, signal);
211
- return await hydrateInlineUrlResultSafely(remoteResult, dependencies.artifactStore);
232
+ const hydrated = await hydrateInlineUrlResultSafely(remoteResult, dependencies.artifactStore);
233
+ return presentParseResult(hydrated, args, dependencies);
212
234
  }
213
- return await parseLocal(args, clientRequestId, signal, progress, dependencies);
235
+ const localResult = await parseLocal(args, clientRequestId, signal, progress, dependencies);
236
+ return presentParseResult(localResult, args, dependencies);
214
237
  }
215
238
  catch (error) {
216
239
  return failed(error);
@@ -325,10 +348,14 @@ async function callReadResult(resultId, cursor, maxBytes, dependencies) {
325
348
  }
326
349
  async function callDiscardResult(resultId, dependencies) {
327
350
  try {
351
+ const discarded = await dependencies.artifactStore.discard(resultId);
352
+ if (!discarded) {
353
+ throw bridgeError("RESULT_NOT_FOUND", "The requested local result was not found.");
354
+ }
328
355
  return structuredResult(discardResultOutputSchema, {
329
356
  status: "completed",
330
357
  result_id: resultId,
331
- discarded: await dependencies.artifactStore.discard(resultId),
358
+ discarded,
332
359
  });
333
360
  }
334
361
  catch (error) {
@@ -361,13 +388,7 @@ async function callReadOutline(resultId, nodeId, dependencies) {
361
388
  }
362
389
  const node = outline.nodes.find((candidate) => candidate.id === nodeId);
363
390
  if (node === undefined) {
364
- throw bridgeError("OUTLINE_NODE_NOT_FOUND", "The requested outline node does not exist.", {
365
- operationCreated: true,
366
- fileUploaded: true,
367
- parserStarted: true,
368
- billed: true,
369
- contentReleased: true,
370
- });
391
+ throw bridgeError("OUTLINE_NODE_NOT_FOUND", "The requested outline node does not exist.");
371
392
  }
372
393
  const cursor = await dependencies.artifactStore.mintOutlineCursor(resultId, node.byteOffset);
373
394
  return structuredResult(readOutlineOutputSchema, { status: "cursor", cursor });
@@ -455,7 +476,7 @@ async function dispatchTool(name, rawArguments, extra, dependencies) {
455
476
  }
456
477
  export function registerOmniTools(server, dependencies, taskStore) {
457
478
  const taskRuntime = new TaskRuntime({
458
- parse: (source, signal) => parseValue({ source }, signal, NOOP_PROGRESS, dependencies),
479
+ parse: (args, signal) => parseValue(args, signal, NOOP_PROGRESS, dependencies),
459
480
  status: (operationId, waitMs, signal) => statusValue(operationId, waitMs, signal, dependencies),
460
481
  cancel: (operationId, signal) => cancelValue(operationId, signal, dependencies),
461
482
  });
@@ -466,7 +487,7 @@ export function registerOmniTools(server, dependencies, taskStore) {
466
487
  ttl: Math.min(600_000, Math.max(1_000, requestedTtl)),
467
488
  pollInterval: 1_000,
468
489
  });
469
- void taskRuntime.start(task.taskId, normalized.source, extra.taskStore)
490
+ void taskRuntime.start(task.taskId, normalized, extra.taskStore)
470
491
  .catch(() => undefined);
471
492
  return { task };
472
493
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cueai/omni-reader-mcp",
3
- "version": "1.5.5",
3
+ "version": "1.6.0",
4
4
  "description": "Local stdio MCP bridge for direct Omni document parsing",
5
5
  "keywords": [
6
6
  "mcp",