@cueai/omni-reader-mcp 1.5.5 → 1.7.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.
Files changed (42) hide show
  1. package/README.md +106 -46
  2. package/dist/artifact-store.d.ts +2 -0
  3. package/dist/artifact-store.js +45 -10
  4. package/dist/capabilities.d.ts +129 -2
  5. package/dist/capabilities.js +122 -19
  6. package/dist/cli/agent-config.js +2 -2
  7. package/dist/cli/arguments.d.ts +8 -4
  8. package/dist/cli/arguments.js +62 -7
  9. package/dist/cli/config-inspection.d.ts +59 -0
  10. package/dist/cli/config-inspection.js +307 -0
  11. package/dist/cli/doctor.d.ts +7 -0
  12. package/dist/cli/doctor.js +37 -2
  13. package/dist/cli/setup.js +13 -2
  14. package/dist/constants.d.ts +6 -1
  15. package/dist/constants.js +9 -4
  16. package/dist/cube-client.d.ts +4 -1
  17. package/dist/cube-client.js +286 -32
  18. package/dist/cursor.d.ts +4 -0
  19. package/dist/cursor.js +11 -13
  20. package/dist/errors.d.ts +1 -0
  21. package/dist/errors.js +15 -0
  22. package/dist/iiis-client.d.ts +33 -2
  23. package/dist/iiis-client.js +368 -40
  24. package/dist/index.js +10 -1
  25. package/dist/operation-journal.d.ts +17 -1
  26. package/dist/operation-journal.js +260 -15
  27. package/dist/operation-manager.d.ts +6 -2
  28. package/dist/operation-manager.js +448 -89
  29. package/dist/path-normalization.d.ts +5 -0
  30. package/dist/path-normalization.js +25 -0
  31. package/dist/path-security.d.ts +2 -1
  32. package/dist/path-security.js +49 -28
  33. package/dist/protocol.d.ts +10 -2
  34. package/dist/protocol.js +23 -7
  35. package/dist/remote-client.js +3 -13
  36. package/dist/result-contract.d.ts +76 -32
  37. package/dist/result-contract.js +121 -5
  38. package/dist/task-runtime.d.ts +3 -2
  39. package/dist/task-runtime.js +2 -2
  40. package/dist/tools.d.ts +4 -0
  41. package/dist/tools.js +41 -31
  42. package/package.json +1 -1
package/dist/tools.js CHANGED
@@ -2,12 +2,12 @@ import { createHash } from "node:crypto";
2
2
  import { CallToolRequestSchema, CancelTaskRequestSchema, ErrorCode, McpError, } from "@modelcontextprotocol/sdk/types.js";
3
3
  import { selectDirectProfile, selectUrlProfile, } from "./capabilities.js";
4
4
  import { createClientRequestId as newClientRequestId, } from "./cube-client.js";
5
- import { OmniBridgeError } from "./errors.js";
5
+ import { OmniBridgeError, unsupportedDetailError } from "./errors.js";
6
6
  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) {
@@ -127,29 +129,35 @@ async function parseLocal(args, clientRequestId, signal, progress, dependencies)
127
129
  async function preflightNonTextRepresentation(detail, sourceKind, signal, dependencies) {
128
130
  if (sourceKind === "local") {
129
131
  const capabilities = await dependencies.cubeClient.getCapabilities(signal);
130
- selectDirectProfile(capabilities, detail);
132
+ selectDirectProfile(capabilities, detail, "local");
131
133
  }
132
134
  else {
133
135
  if (dependencies.remoteClient === undefined) {
134
136
  throw bridgeError("REMOTE_PARSE_UNAVAILABLE", "Remote URL parsing is not available in this Bridge build.", { retryable: true });
135
137
  }
136
138
  const capabilities = await dependencies.remoteClient.initializeCapabilities(signal);
137
- selectUrlProfile(capabilities, detail);
139
+ selectUrlProfile(capabilities, detail, "url");
138
140
  }
139
141
  if (dependencies.operationManager === undefined) {
140
- throw new OmniBridgeError({
141
- code: "UNSUPPORTED_DETAIL",
142
- message: "This Bridge build cannot deliver the requested output detail.",
143
- failureScope: "bridge",
144
- userAction: "Use plain Markdown output for this source.",
145
- operationCreated: false,
146
- fileUploaded: false,
147
- parserStarted: false,
148
- billed: false,
149
- contentReleased: false,
150
- retryable: false,
151
- });
142
+ throw unsupportedDetailError(sourceKind);
143
+ }
144
+ }
145
+ async function preflightArtifactDelivery(args, dependencies) {
146
+ if (args.resultDelivery !== "artifact")
147
+ return;
148
+ if (dependencies.artifactStore.preflightWrite === undefined
149
+ || dependencies.artifactStore.mintReadCursor === undefined) {
150
+ throw bridgeError("ARTIFACT_PREFLIGHT_FAILED", "The local result store cannot provide artifact delivery.");
152
151
  }
152
+ await dependencies.artifactStore.preflightWrite();
153
+ }
154
+ async function presentParseResult(result, args, dependencies) {
155
+ return presentRetainedResult(result, args.resultDelivery, async (resultId, byteOffset) => {
156
+ if (dependencies.artifactStore.mintReadCursor === undefined) {
157
+ throw bridgeError("LOCAL_RESULT_INTEGRITY_FAILED", "The retained result cursor capability is unavailable.");
158
+ }
159
+ return dependencies.artifactStore.mintReadCursor(resultId, byteOffset);
160
+ });
153
161
  }
154
162
  async function parseValue(args, signal, progress, dependencies) {
155
163
  try {
@@ -198,19 +206,23 @@ async function parseValue(args, signal, progress, dependencies) {
198
206
  },
199
207
  clientRequestId,
200
208
  signal,
209
+ resultDelivery: args.resultDelivery,
201
210
  context: source.kind === "local"
202
211
  ? { source: source.source, progress }
203
212
  : { source: source.source },
204
213
  });
205
214
  }
215
+ await preflightArtifactDelivery(args, dependencies);
206
216
  if (source.kind === "url") {
207
217
  if (dependencies.remoteClient === undefined) {
208
218
  throw bridgeError("REMOTE_PARSE_UNAVAILABLE", "Remote URL parsing is not available in this Bridge build.", { retryable: true });
209
219
  }
210
220
  const remoteResult = await dependencies.remoteClient.parse(source.source, clientRequestId, signal);
211
- return await hydrateInlineUrlResultSafely(remoteResult, dependencies.artifactStore);
221
+ const hydrated = await hydrateInlineUrlResultSafely(remoteResult, dependencies.artifactStore);
222
+ return presentParseResult(hydrated, args, dependencies);
212
223
  }
213
- return await parseLocal(args, clientRequestId, signal, progress, dependencies);
224
+ const localResult = await parseLocal(args, clientRequestId, signal, progress, dependencies);
225
+ return presentParseResult(localResult, args, dependencies);
214
226
  }
215
227
  catch (error) {
216
228
  return failed(error);
@@ -325,10 +337,14 @@ async function callReadResult(resultId, cursor, maxBytes, dependencies) {
325
337
  }
326
338
  async function callDiscardResult(resultId, dependencies) {
327
339
  try {
340
+ const discarded = await dependencies.artifactStore.discard(resultId);
341
+ if (!discarded) {
342
+ throw bridgeError("RESULT_NOT_FOUND", "The requested local result was not found.");
343
+ }
328
344
  return structuredResult(discardResultOutputSchema, {
329
345
  status: "completed",
330
346
  result_id: resultId,
331
- discarded: await dependencies.artifactStore.discard(resultId),
347
+ discarded,
332
348
  });
333
349
  }
334
350
  catch (error) {
@@ -361,13 +377,7 @@ async function callReadOutline(resultId, nodeId, dependencies) {
361
377
  }
362
378
  const node = outline.nodes.find((candidate) => candidate.id === nodeId);
363
379
  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
- });
380
+ throw bridgeError("OUTLINE_NODE_NOT_FOUND", "The requested outline node does not exist.");
371
381
  }
372
382
  const cursor = await dependencies.artifactStore.mintOutlineCursor(resultId, node.byteOffset);
373
383
  return structuredResult(readOutlineOutputSchema, { status: "cursor", cursor });
@@ -455,7 +465,7 @@ async function dispatchTool(name, rawArguments, extra, dependencies) {
455
465
  }
456
466
  export function registerOmniTools(server, dependencies, taskStore) {
457
467
  const taskRuntime = new TaskRuntime({
458
- parse: (source, signal) => parseValue({ source }, signal, NOOP_PROGRESS, dependencies),
468
+ parse: (args, signal) => parseValue(args, signal, NOOP_PROGRESS, dependencies),
459
469
  status: (operationId, waitMs, signal) => statusValue(operationId, waitMs, signal, dependencies),
460
470
  cancel: (operationId, signal) => cancelValue(operationId, signal, dependencies),
461
471
  });
@@ -466,7 +476,7 @@ export function registerOmniTools(server, dependencies, taskStore) {
466
476
  ttl: Math.min(600_000, Math.max(1_000, requestedTtl)),
467
477
  pollInterval: 1_000,
468
478
  });
469
- void taskRuntime.start(task.taskId, normalized.source, extra.taskStore)
479
+ void taskRuntime.start(task.taskId, normalized, extra.taskStore)
470
480
  .catch(() => undefined);
471
481
  return { task };
472
482
  };
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.7.0",
4
4
  "description": "Local stdio MCP bridge for direct Omni document parsing",
5
5
  "keywords": [
6
6
  "mcp",