@cueai/omni-reader-mcp 1.0.2 → 1.1.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 +115 -26
- package/dist/artifact-store.d.ts +11 -0
- package/dist/artifact-store.js +94 -48
- package/dist/cli/agent-config.d.ts +29 -4
- package/dist/cli/agent-config.js +910 -107
- package/dist/cli/arguments.d.ts +32 -0
- package/dist/cli/arguments.js +120 -0
- package/dist/cli/doctor.d.ts +42 -1
- package/dist/cli/doctor.js +109 -36
- package/dist/cli/setup.d.ts +3 -0
- package/dist/cli/setup.js +103 -18
- package/dist/cli/uninstall.d.ts +6 -0
- package/dist/cli/uninstall.js +37 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +7 -0
- package/dist/cube-client.d.ts +5 -3
- package/dist/cube-client.js +16 -11
- package/dist/cursor.js +2 -0
- package/dist/errors.d.ts +32 -1
- package/dist/errors.js +26 -1
- package/dist/iiis-client.d.ts +18 -4
- package/dist/iiis-client.js +194 -40
- package/dist/index.d.ts +3 -0
- package/dist/index.js +93 -32
- package/dist/multipart-body.js +2 -0
- package/dist/onboarding-policy.d.ts +10 -0
- package/dist/onboarding-policy.js +58 -0
- package/dist/operation-journal.d.ts +50 -1
- package/dist/operation-journal.js +473 -114
- package/dist/operation-manager.d.ts +75 -0
- package/dist/operation-manager.js +1311 -0
- package/dist/path-security.d.ts +1 -0
- package/dist/path-security.js +26 -6
- package/dist/progress.d.ts +6 -1
- package/dist/protocol.d.ts +26 -13
- package/dist/protocol.js +34 -10
- package/dist/remote-client.d.ts +17 -0
- package/dist/remote-client.js +233 -0
- package/dist/result-contract.d.ts +199 -0
- package/dist/result-contract.js +235 -0
- package/dist/server.js +21 -4
- package/dist/source.d.ts +8 -0
- package/dist/source.js +37 -0
- package/dist/task-runtime.d.ts +13 -0
- package/dist/task-runtime.js +94 -0
- package/dist/tools.d.ts +19 -1
- package/dist/tools.js +317 -112
- package/package.json +3 -3
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const operationIdSchema = z.string().min(1).max(128);
|
|
3
|
+
const resultIdSchema = z.string().regex(/^result_[A-Za-z0-9_-]{16,64}$/u);
|
|
4
|
+
const constraintsSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
max_bytes: z.number().int().nonnegative().optional(),
|
|
7
|
+
supported_extensions: z.array(z.string().regex(/^[a-z0-9]{1,10}$/u)).optional(),
|
|
8
|
+
})
|
|
9
|
+
.strict();
|
|
10
|
+
export const stableErrorSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
ok: z.literal(false),
|
|
13
|
+
code: z.string().min(1).max(128),
|
|
14
|
+
failure_scope: z
|
|
15
|
+
.enum([
|
|
16
|
+
"source",
|
|
17
|
+
"local_capability",
|
|
18
|
+
"authentication",
|
|
19
|
+
"billing",
|
|
20
|
+
"service",
|
|
21
|
+
"parser",
|
|
22
|
+
"operation",
|
|
23
|
+
"cleanup",
|
|
24
|
+
"bridge",
|
|
25
|
+
])
|
|
26
|
+
.optional(),
|
|
27
|
+
source_kind: z.enum(["local", "url"]).optional(),
|
|
28
|
+
retryable: z.boolean(),
|
|
29
|
+
message: z.string().min(1).max(2048),
|
|
30
|
+
user_action: z.string().min(1).max(2048).optional(),
|
|
31
|
+
request_id: z.string().min(1).max(128).optional(),
|
|
32
|
+
operation_created: z.boolean(),
|
|
33
|
+
file_uploaded: z.boolean(),
|
|
34
|
+
parser_started: z.boolean(),
|
|
35
|
+
billed: z.boolean(),
|
|
36
|
+
content_released: z.boolean(),
|
|
37
|
+
retry_after: z.number().int().nonnegative().optional(),
|
|
38
|
+
constraints: constraintsSchema.optional(),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
export const dataHandlingSchema = z
|
|
42
|
+
.object({
|
|
43
|
+
processing_copy: z.enum(["in_use", "pending", "deleted"]),
|
|
44
|
+
temporary_data: z.enum(["in_use", "pending", "deleted"]),
|
|
45
|
+
delivery_result: z.union([
|
|
46
|
+
z.literal("not_created"),
|
|
47
|
+
z.literal("pending"),
|
|
48
|
+
z.literal("deleted_after_ack"),
|
|
49
|
+
z.object({ expires_at: z.string().datetime({ offset: true }) }).strict(),
|
|
50
|
+
]),
|
|
51
|
+
original_source: z.literal("unchanged"),
|
|
52
|
+
remote_content_retained: z.literal(false).optional(),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
export const progressDetailSchema = z
|
|
56
|
+
.object({
|
|
57
|
+
unit: z.enum(["page", "sheet", "slide", "frame", "segment"]),
|
|
58
|
+
completed: z.number().int().nonnegative(),
|
|
59
|
+
total: z.number().int().positive(),
|
|
60
|
+
})
|
|
61
|
+
.strict()
|
|
62
|
+
.refine((value) => value.completed <= value.total, {
|
|
63
|
+
message: "completed must not exceed total",
|
|
64
|
+
});
|
|
65
|
+
const inlineResultSchema = z
|
|
66
|
+
.object({
|
|
67
|
+
kind: z.literal("inline"),
|
|
68
|
+
text: z.string(),
|
|
69
|
+
})
|
|
70
|
+
.strict();
|
|
71
|
+
const artifactResultSchema = z
|
|
72
|
+
.object({
|
|
73
|
+
kind: z.literal("artifact"),
|
|
74
|
+
result_id: resultIdSchema,
|
|
75
|
+
result_bytes: z.number().int().nonnegative(),
|
|
76
|
+
expires_at: z.string().datetime({ offset: true }),
|
|
77
|
+
preview: z.string(),
|
|
78
|
+
next_cursor: z.string().min(1).max(2048),
|
|
79
|
+
})
|
|
80
|
+
.strict();
|
|
81
|
+
const billingSchema = z
|
|
82
|
+
.object({
|
|
83
|
+
credits_charged: z.number().nonnegative(),
|
|
84
|
+
credits_remaining: z.number().nonnegative(),
|
|
85
|
+
})
|
|
86
|
+
.strict();
|
|
87
|
+
const localResultCacheSchema = z
|
|
88
|
+
.object({
|
|
89
|
+
expires_at: z.string().datetime({ offset: true }),
|
|
90
|
+
discard_action: z.literal("discard_result"),
|
|
91
|
+
})
|
|
92
|
+
.strict();
|
|
93
|
+
const failedResultSchema = z
|
|
94
|
+
.object({
|
|
95
|
+
status: z.literal("failed"),
|
|
96
|
+
error: stableErrorSchema,
|
|
97
|
+
})
|
|
98
|
+
.strict();
|
|
99
|
+
export const parseResultSchema = z.discriminatedUnion("status", [
|
|
100
|
+
z
|
|
101
|
+
.object({
|
|
102
|
+
status: z.literal("processing"),
|
|
103
|
+
operation_id: operationIdSchema,
|
|
104
|
+
stage: z.string().min(1).max(128),
|
|
105
|
+
progress: z.number().min(0).max(100),
|
|
106
|
+
progress_detail: progressDetailSchema.optional(),
|
|
107
|
+
next_action: z.literal("check_status"),
|
|
108
|
+
poll_after_seconds: z.number().int().positive(),
|
|
109
|
+
can_cancel: z.boolean(),
|
|
110
|
+
data_handling: dataHandlingSchema,
|
|
111
|
+
})
|
|
112
|
+
.strict(),
|
|
113
|
+
z
|
|
114
|
+
.object({
|
|
115
|
+
status: z.literal("completed"),
|
|
116
|
+
operation_id: operationIdSchema,
|
|
117
|
+
result: z.union([inlineResultSchema, artifactResultSchema]),
|
|
118
|
+
billing: billingSchema.optional(),
|
|
119
|
+
data_handling: dataHandlingSchema,
|
|
120
|
+
local_result_cache: localResultCacheSchema.optional(),
|
|
121
|
+
})
|
|
122
|
+
.strict(),
|
|
123
|
+
z
|
|
124
|
+
.object({
|
|
125
|
+
status: z.literal("cleanup_pending"),
|
|
126
|
+
operation_id: operationIdSchema,
|
|
127
|
+
result: z.union([inlineResultSchema, artifactResultSchema]).optional(),
|
|
128
|
+
cleanup_deadline: z.string().datetime({ offset: true }),
|
|
129
|
+
data_handling: dataHandlingSchema,
|
|
130
|
+
})
|
|
131
|
+
.strict(),
|
|
132
|
+
failedResultSchema,
|
|
133
|
+
z
|
|
134
|
+
.object({
|
|
135
|
+
status: z.literal("canceled"),
|
|
136
|
+
operation_id: operationIdSchema,
|
|
137
|
+
cleanup_deadline: z.string().datetime({ offset: true }).optional(),
|
|
138
|
+
data_handling: dataHandlingSchema,
|
|
139
|
+
})
|
|
140
|
+
.strict(),
|
|
141
|
+
z
|
|
142
|
+
.object({
|
|
143
|
+
status: z.literal("expired"),
|
|
144
|
+
operation_id: operationIdSchema,
|
|
145
|
+
requires_user_confirmation: z.literal(true),
|
|
146
|
+
})
|
|
147
|
+
.strict(),
|
|
148
|
+
]);
|
|
149
|
+
const resultChunkSchema = z
|
|
150
|
+
.object({
|
|
151
|
+
result_id: resultIdSchema,
|
|
152
|
+
result_bytes: z.number().int().nonnegative(),
|
|
153
|
+
expires_at: z.string().datetime({ offset: true }),
|
|
154
|
+
text: z.string(),
|
|
155
|
+
next_cursor: z.string().min(1).max(2048).optional(),
|
|
156
|
+
})
|
|
157
|
+
.strict();
|
|
158
|
+
export const readResultOutputSchema = z.discriminatedUnion("status", [
|
|
159
|
+
z.object({ status: z.literal("completed"), result: resultChunkSchema }).strict(),
|
|
160
|
+
failedResultSchema,
|
|
161
|
+
]);
|
|
162
|
+
export const discardResultOutputSchema = z.discriminatedUnion("status", [
|
|
163
|
+
z
|
|
164
|
+
.object({
|
|
165
|
+
status: z.literal("completed"),
|
|
166
|
+
result_id: resultIdSchema,
|
|
167
|
+
discarded: z.boolean(),
|
|
168
|
+
})
|
|
169
|
+
.strict(),
|
|
170
|
+
failedResultSchema,
|
|
171
|
+
]);
|
|
172
|
+
export const parseToolOutputSchema = z
|
|
173
|
+
.object({
|
|
174
|
+
status: z.enum([
|
|
175
|
+
"processing",
|
|
176
|
+
"completed",
|
|
177
|
+
"cleanup_pending",
|
|
178
|
+
"failed",
|
|
179
|
+
"canceled",
|
|
180
|
+
"expired",
|
|
181
|
+
]),
|
|
182
|
+
operation_id: operationIdSchema.optional(),
|
|
183
|
+
stage: z.string().min(1).max(128).optional(),
|
|
184
|
+
progress: z.number().min(0).max(100).optional(),
|
|
185
|
+
progress_detail: progressDetailSchema.optional(),
|
|
186
|
+
next_action: z.literal("check_status").optional(),
|
|
187
|
+
poll_after_seconds: z.number().int().positive().optional(),
|
|
188
|
+
can_cancel: z.boolean().optional(),
|
|
189
|
+
result: z.union([inlineResultSchema, artifactResultSchema]).optional(),
|
|
190
|
+
billing: billingSchema.optional(),
|
|
191
|
+
data_handling: dataHandlingSchema.optional(),
|
|
192
|
+
local_result_cache: localResultCacheSchema.optional(),
|
|
193
|
+
cleanup_deadline: z.string().datetime({ offset: true }).optional(),
|
|
194
|
+
error: stableErrorSchema.optional(),
|
|
195
|
+
requires_user_confirmation: z.literal(true).optional(),
|
|
196
|
+
})
|
|
197
|
+
.strict();
|
|
198
|
+
export const readResultToolOutputSchema = z
|
|
199
|
+
.object({
|
|
200
|
+
status: z.enum(["completed", "failed"]),
|
|
201
|
+
result: resultChunkSchema.optional(),
|
|
202
|
+
error: stableErrorSchema.optional(),
|
|
203
|
+
})
|
|
204
|
+
.strict();
|
|
205
|
+
export const discardResultToolOutputSchema = z
|
|
206
|
+
.object({
|
|
207
|
+
status: z.enum(["completed", "failed"]),
|
|
208
|
+
result_id: resultIdSchema.optional(),
|
|
209
|
+
discarded: z.boolean().optional(),
|
|
210
|
+
error: stableErrorSchema.optional(),
|
|
211
|
+
})
|
|
212
|
+
.strict();
|
|
213
|
+
function summarizeForTextFallback(value) {
|
|
214
|
+
if (value.status === "failed") {
|
|
215
|
+
const error = value.error;
|
|
216
|
+
return `Omni failed: ${typeof error?.code === "string" ? error.code : "UNKNOWN"}.`;
|
|
217
|
+
}
|
|
218
|
+
if (value.status === "processing")
|
|
219
|
+
return "Omni processing.";
|
|
220
|
+
if (value.status === "cleanup_pending")
|
|
221
|
+
return "Omni cleanup pending.";
|
|
222
|
+
if (value.status === "canceled")
|
|
223
|
+
return "Omni canceled.";
|
|
224
|
+
if (value.status === "expired")
|
|
225
|
+
return "Omni result expired.";
|
|
226
|
+
return "Omni completed.";
|
|
227
|
+
}
|
|
228
|
+
export function structuredResult(schema, value) {
|
|
229
|
+
const structuredContent = schema.parse(value);
|
|
230
|
+
return {
|
|
231
|
+
...(structuredContent.status === "failed" ? { isError: true } : {}),
|
|
232
|
+
structuredContent,
|
|
233
|
+
content: [{ type: "text", text: summarizeForTextFallback(structuredContent) }],
|
|
234
|
+
};
|
|
235
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
import { InMemoryTaskStore } from "@modelcontextprotocol/sdk/experimental/tasks/stores/in-memory.js";
|
|
1
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import {
|
|
3
|
+
import { BRIDGE_RELEASE_VERSION } from "./constants.js";
|
|
4
|
+
import { MACHINE_INSTRUCTIONS } from "./protocol.js";
|
|
3
5
|
import { registerOmniTools } from "./tools.js";
|
|
4
6
|
const SERVER_NAME = "omni-reader-mcp";
|
|
5
|
-
const SERVER_VERSION = "1.0.2";
|
|
6
7
|
export function createOmniMcpServer(dependencies) {
|
|
7
|
-
const
|
|
8
|
-
|
|
8
|
+
const taskStore = new InMemoryTaskStore();
|
|
9
|
+
const server = new McpServer({ name: SERVER_NAME, version: BRIDGE_RELEASE_VERSION }, {
|
|
10
|
+
instructions: MACHINE_INSTRUCTIONS,
|
|
11
|
+
taskStore,
|
|
12
|
+
capabilities: {
|
|
13
|
+
tasks: {
|
|
14
|
+
list: {},
|
|
15
|
+
cancel: {},
|
|
16
|
+
requests: { tools: { call: {} } },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
registerOmniTools(server, dependencies, taskStore);
|
|
21
|
+
const close = server.close.bind(server);
|
|
22
|
+
server.close = async () => {
|
|
23
|
+
taskStore.cleanup();
|
|
24
|
+
await close();
|
|
25
|
+
};
|
|
9
26
|
return server;
|
|
10
27
|
}
|
package/dist/source.d.ts
ADDED
package/dist/source.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { OmniBridgeError } from "./errors.js";
|
|
2
|
+
function unsupportedSource() {
|
|
3
|
+
return new OmniBridgeError({
|
|
4
|
+
code: "UNSUPPORTED_SOURCE",
|
|
5
|
+
failureScope: "source",
|
|
6
|
+
message: "The source is not supported.",
|
|
7
|
+
userAction: "Provide an HTTP(S) URL or an ordinary local path.",
|
|
8
|
+
operationCreated: false,
|
|
9
|
+
fileUploaded: false,
|
|
10
|
+
parserStarted: false,
|
|
11
|
+
billed: false,
|
|
12
|
+
contentReleased: false,
|
|
13
|
+
retryable: false,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export function classifySource(source) {
|
|
17
|
+
if (source.includes("\0"))
|
|
18
|
+
throw unsupportedSource();
|
|
19
|
+
const scheme = /^([A-Za-z][A-Za-z0-9+.-]*):/u.exec(source)?.[1]?.toLowerCase();
|
|
20
|
+
if (scheme === undefined)
|
|
21
|
+
return { kind: "local", source };
|
|
22
|
+
if (/^[A-Za-z]$/u.test(scheme) && /^[A-Za-z]:[\\/]/u.test(source)) {
|
|
23
|
+
return { kind: "local", source };
|
|
24
|
+
}
|
|
25
|
+
if (scheme !== "http" && scheme !== "https")
|
|
26
|
+
throw unsupportedSource();
|
|
27
|
+
let url;
|
|
28
|
+
try {
|
|
29
|
+
url = new URL(source);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
throw unsupportedSource();
|
|
33
|
+
}
|
|
34
|
+
if (url.username !== "" || url.password !== "")
|
|
35
|
+
throw unsupportedSource();
|
|
36
|
+
return { kind: "url", source };
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RequestTaskStore } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
2
|
+
import { type ParseResult } from "./result-contract.js";
|
|
3
|
+
export interface TaskRuntimeOperations {
|
|
4
|
+
parse(source: string, signal: AbortSignal): Promise<ParseResult>;
|
|
5
|
+
status(operationId: string, waitMs: number, signal: AbortSignal): Promise<ParseResult>;
|
|
6
|
+
cancel(operationId: string, signal: AbortSignal): Promise<ParseResult>;
|
|
7
|
+
}
|
|
8
|
+
export declare class TaskRuntime {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(operations: TaskRuntimeOperations);
|
|
11
|
+
start(taskId: string, source: string, store: RequestTaskStore): Promise<void>;
|
|
12
|
+
cancel(taskId: string): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { STATUS_LONG_POLL_MAX_MS } from "./constants.js";
|
|
2
|
+
import { OmniBridgeError } from "./errors.js";
|
|
3
|
+
import { parseResultSchema, structuredResult, } from "./result-contract.js";
|
|
4
|
+
function taskFailure(operationCreated) {
|
|
5
|
+
const error = new OmniBridgeError({
|
|
6
|
+
code: "TASK_RUNTIME_FAILED",
|
|
7
|
+
failureScope: "bridge",
|
|
8
|
+
message: "The Omni task could not complete.",
|
|
9
|
+
operationCreated,
|
|
10
|
+
fileUploaded: false,
|
|
11
|
+
parserStarted: false,
|
|
12
|
+
billed: false,
|
|
13
|
+
contentReleased: false,
|
|
14
|
+
retryable: true,
|
|
15
|
+
});
|
|
16
|
+
return { status: "failed", error: error.toJSON() };
|
|
17
|
+
}
|
|
18
|
+
function taskStatusMessage(result) {
|
|
19
|
+
return JSON.stringify({
|
|
20
|
+
operation_id: result.operation_id,
|
|
21
|
+
stage: result.stage,
|
|
22
|
+
progress: result.progress,
|
|
23
|
+
...(result.progress_detail === undefined
|
|
24
|
+
? {}
|
|
25
|
+
: { progress_detail: result.progress_detail }),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async function isCancelled(store, taskId) {
|
|
29
|
+
try {
|
|
30
|
+
return (await store.getTask(taskId)).status === "cancelled";
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class TaskRuntime {
|
|
37
|
+
#operations;
|
|
38
|
+
#running = new Map();
|
|
39
|
+
constructor(operations) {
|
|
40
|
+
this.#operations = operations;
|
|
41
|
+
}
|
|
42
|
+
async start(taskId, source, store) {
|
|
43
|
+
if (this.#running.has(taskId)) {
|
|
44
|
+
throw new Error(`Task ${taskId} is already running.`);
|
|
45
|
+
}
|
|
46
|
+
const running = {
|
|
47
|
+
controller: new AbortController(),
|
|
48
|
+
};
|
|
49
|
+
this.#running.set(taskId, running);
|
|
50
|
+
try {
|
|
51
|
+
let result = await this.#operations.parse(source, running.controller.signal);
|
|
52
|
+
while (result.status === "processing") {
|
|
53
|
+
running.operationId = result.operation_id;
|
|
54
|
+
if (await isCancelled(store, taskId)) {
|
|
55
|
+
await this.#cancelRunning(running);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
await store.updateTaskStatus(taskId, "working", taskStatusMessage(result));
|
|
59
|
+
result = await this.#operations.status(result.operation_id, STATUS_LONG_POLL_MAX_MS, running.controller.signal);
|
|
60
|
+
}
|
|
61
|
+
if (await isCancelled(store, taskId))
|
|
62
|
+
return;
|
|
63
|
+
if (result.status === "canceled") {
|
|
64
|
+
await store.updateTaskStatus(taskId, "cancelled", "Omni parse canceled.");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
await store.storeTaskResult(taskId, result.status === "failed" ? "failed" : "completed", structuredResult(parseResultSchema, result));
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
if (!await isCancelled(store, taskId)) {
|
|
71
|
+
const failed = taskFailure(running.operationId !== undefined);
|
|
72
|
+
await store.storeTaskResult(taskId, "failed", structuredResult(parseResultSchema, failed));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
this.#running.delete(taskId);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async cancel(taskId) {
|
|
80
|
+
const running = this.#running.get(taskId);
|
|
81
|
+
if (running === undefined)
|
|
82
|
+
return;
|
|
83
|
+
await this.#cancelRunning(running);
|
|
84
|
+
}
|
|
85
|
+
async #cancelRunning(running) {
|
|
86
|
+
if (running.cancelRequested === true)
|
|
87
|
+
return;
|
|
88
|
+
running.cancelRequested = true;
|
|
89
|
+
running.controller.abort();
|
|
90
|
+
if (running.operationId === undefined)
|
|
91
|
+
return;
|
|
92
|
+
await this.#operations.cancel(running.operationId, new AbortController().signal);
|
|
93
|
+
}
|
|
94
|
+
}
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { TaskStore } from "@modelcontextprotocol/sdk/experimental/tasks/interfaces.js";
|
|
2
3
|
import type { ArtifactReadResult, LocalResult } from "./artifact-store.js";
|
|
3
4
|
import { type CubeGrantClient } from "./cube-client.js";
|
|
4
5
|
import type { IiisClient, ResultRetentionSink } from "./iiis-client.js";
|
|
5
6
|
import { type OpenAllowedFileOptions, type OpenedAllowedFile } from "./path-security.js";
|
|
7
|
+
import type { RemoteOmniClient } from "./remote-client.js";
|
|
8
|
+
import { type ParseResult } from "./result-contract.js";
|
|
6
9
|
interface ToolRetention extends ResultRetentionSink {
|
|
7
10
|
result(): LocalResult;
|
|
8
11
|
}
|
|
@@ -11,6 +14,17 @@ interface ToolArtifactStore {
|
|
|
11
14
|
read(resultId: string, cursor?: string, maxBytes?: number): Promise<ArtifactReadResult>;
|
|
12
15
|
discard(resultId: string): Promise<boolean>;
|
|
13
16
|
}
|
|
17
|
+
export interface ParseOperationController {
|
|
18
|
+
submitResult(input: {
|
|
19
|
+
sourceKind: "local" | "url";
|
|
20
|
+
sourceFacts: Readonly<Record<string, unknown>>;
|
|
21
|
+
clientRequestId: string;
|
|
22
|
+
signal: AbortSignal;
|
|
23
|
+
context: unknown;
|
|
24
|
+
}): Promise<ParseResult>;
|
|
25
|
+
statusResult(operationId: string, waitMs: number | undefined, signal: AbortSignal): Promise<ParseResult>;
|
|
26
|
+
cancelResult(operationId: string, signal: AbortSignal): Promise<ParseResult>;
|
|
27
|
+
}
|
|
14
28
|
export interface OmniToolDependencies {
|
|
15
29
|
readonly workspace: string;
|
|
16
30
|
readonly extraRoots?: readonly string[];
|
|
@@ -18,7 +32,11 @@ export interface OmniToolDependencies {
|
|
|
18
32
|
readonly iiisClient: Pick<IiisClient, "uploadAndWait" | "ack">;
|
|
19
33
|
readonly artifactStore: ToolArtifactStore;
|
|
20
34
|
readonly createClientRequestId?: () => string;
|
|
35
|
+
readonly remoteClient?: RemoteOmniClient;
|
|
36
|
+
readonly operationManager?: ParseOperationController;
|
|
21
37
|
readonly openFile?: (localPath: string, options: OpenAllowedFileOptions) => Promise<OpenedAllowedFile>;
|
|
38
|
+
readonly statusOperation?: (operationId: string, waitMs: number | undefined, signal: AbortSignal) => Promise<ParseResult>;
|
|
39
|
+
readonly cancelOperation?: (operationId: string, signal: AbortSignal) => Promise<ParseResult>;
|
|
22
40
|
}
|
|
23
|
-
export declare function registerOmniTools(server: McpServer, dependencies: OmniToolDependencies): void;
|
|
41
|
+
export declare function registerOmniTools(server: McpServer, dependencies: OmniToolDependencies, taskStore: TaskStore): void;
|
|
24
42
|
export {};
|