@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.
- package/README.md +106 -46
- package/dist/artifact-store.d.ts +2 -0
- package/dist/artifact-store.js +45 -10
- package/dist/capabilities.d.ts +129 -2
- package/dist/capabilities.js +122 -19
- package/dist/cli/agent-config.js +2 -2
- package/dist/cli/arguments.d.ts +8 -4
- package/dist/cli/arguments.js +62 -7
- package/dist/cli/config-inspection.d.ts +59 -0
- package/dist/cli/config-inspection.js +307 -0
- package/dist/cli/doctor.d.ts +7 -0
- package/dist/cli/doctor.js +37 -2
- package/dist/cli/setup.js +13 -2
- package/dist/constants.d.ts +6 -1
- package/dist/constants.js +9 -4
- package/dist/cube-client.d.ts +4 -1
- package/dist/cube-client.js +286 -32
- package/dist/cursor.d.ts +4 -0
- package/dist/cursor.js +11 -13
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +15 -0
- package/dist/iiis-client.d.ts +33 -2
- package/dist/iiis-client.js +368 -40
- package/dist/index.js +10 -1
- package/dist/operation-journal.d.ts +17 -1
- package/dist/operation-journal.js +260 -15
- package/dist/operation-manager.d.ts +6 -2
- package/dist/operation-manager.js +448 -89
- package/dist/path-normalization.d.ts +5 -0
- package/dist/path-normalization.js +25 -0
- package/dist/path-security.d.ts +2 -1
- package/dist/path-security.js +49 -28
- package/dist/protocol.d.ts +10 -2
- package/dist/protocol.js +23 -7
- package/dist/remote-client.js +3 -13
- package/dist/result-contract.d.ts +76 -32
- package/dist/result-contract.js +121 -5
- package/dist/task-runtime.d.ts +3 -2
- package/dist/task-runtime.js +2 -2
- package/dist/tools.d.ts +4 -0
- package/dist/tools.js +41 -31
- 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
|
-
|
|
62
|
-
|
|
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
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
221
|
+
const hydrated = await hydrateInlineUrlResultSafely(remoteResult, dependencies.artifactStore);
|
|
222
|
+
return presentParseResult(hydrated, args, dependencies);
|
|
212
223
|
}
|
|
213
|
-
|
|
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
|
|
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: (
|
|
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
|
|
479
|
+
void taskRuntime.start(task.taskId, normalized, extra.taskStore)
|
|
470
480
|
.catch(() => undefined);
|
|
471
481
|
return { task };
|
|
472
482
|
};
|