@cueai/omni-reader-mcp 1.0.1 → 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.
Files changed (48) hide show
  1. package/README.md +115 -26
  2. package/dist/artifact-store.d.ts +11 -0
  3. package/dist/artifact-store.js +94 -48
  4. package/dist/cli/agent-config.d.ts +29 -4
  5. package/dist/cli/agent-config.js +910 -107
  6. package/dist/cli/arguments.d.ts +32 -0
  7. package/dist/cli/arguments.js +120 -0
  8. package/dist/cli/doctor.d.ts +42 -1
  9. package/dist/cli/doctor.js +110 -37
  10. package/dist/cli/setup.d.ts +3 -0
  11. package/dist/cli/setup.js +103 -18
  12. package/dist/cli/uninstall.d.ts +6 -0
  13. package/dist/cli/uninstall.js +37 -0
  14. package/dist/constants.d.ts +8 -1
  15. package/dist/constants.js +8 -1
  16. package/dist/cube-client.d.ts +5 -3
  17. package/dist/cube-client.js +17 -12
  18. package/dist/cursor.js +2 -0
  19. package/dist/errors.d.ts +32 -1
  20. package/dist/errors.js +26 -1
  21. package/dist/iiis-client.d.ts +19 -5
  22. package/dist/iiis-client.js +206 -49
  23. package/dist/index.d.ts +3 -0
  24. package/dist/index.js +93 -32
  25. package/dist/multipart-body.js +2 -0
  26. package/dist/onboarding-policy.d.ts +10 -0
  27. package/dist/onboarding-policy.js +58 -0
  28. package/dist/operation-journal.d.ts +50 -1
  29. package/dist/operation-journal.js +473 -114
  30. package/dist/operation-manager.d.ts +75 -0
  31. package/dist/operation-manager.js +1311 -0
  32. package/dist/path-security.d.ts +1 -0
  33. package/dist/path-security.js +26 -6
  34. package/dist/progress.d.ts +6 -1
  35. package/dist/protocol.d.ts +26 -13
  36. package/dist/protocol.js +34 -10
  37. package/dist/remote-client.d.ts +17 -0
  38. package/dist/remote-client.js +233 -0
  39. package/dist/result-contract.d.ts +199 -0
  40. package/dist/result-contract.js +235 -0
  41. package/dist/server.js +21 -4
  42. package/dist/source.d.ts +8 -0
  43. package/dist/source.js +37 -0
  44. package/dist/task-runtime.d.ts +13 -0
  45. package/dist/task-runtime.js +94 -0
  46. package/dist/tools.d.ts +19 -1
  47. package/dist/tools.js +317 -112
  48. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
+ import { BRIDGE_RELEASE_VERSION } from "./constants.js";
1
2
  import { OperationJournal } from "./operation-journal.js";
2
3
  declare const BRIDGE_PACKAGE = "@cueai/omni-reader-mcp";
3
- declare const BRIDGE_VERSION = "1.0.1";
4
4
  export interface GrantRequestInput {
5
5
  readonly contentLength: number;
6
6
  readonly contentType: string;
@@ -35,7 +35,7 @@ interface GrantRequestBody {
35
35
  readonly output: "markdown";
36
36
  readonly bridge: {
37
37
  readonly package: typeof BRIDGE_PACKAGE;
38
- readonly version: typeof BRIDGE_VERSION;
38
+ readonly version: typeof BRIDGE_RELEASE_VERSION;
39
39
  };
40
40
  }
41
41
  export declare function grantRequestHash(body: GrantRequestBody): string;
@@ -43,6 +43,8 @@ export declare function createClientRequestId(): string;
43
43
  export declare class CubeGrantClient {
44
44
  #private;
45
45
  constructor(options: CubeGrantClientOptions);
46
- createGrant(input: GrantRequestInput, clientRequestId: string, signal?: AbortSignal): Promise<GrantedOperation>;
46
+ createGrant(input: GrantRequestInput, clientRequestId: string, signal?: AbortSignal, options?: {
47
+ journal?: boolean;
48
+ }): Promise<GrantedOperation>;
47
49
  }
48
50
  export {};
@@ -1,10 +1,9 @@
1
1
  import { createHash, randomUUID } from "node:crypto";
2
2
  import { z } from "zod";
3
- import { DEFAULT_CUBE_BASE_URL, MAX_FILE_BYTES, PROTOCOL_VERSION, } from "./constants.js";
3
+ import { BRIDGE_RELEASE_VERSION, CUBE_GRANT_PROTOCOL_VERSION, DEFAULT_CUBE_BASE_URL, MAX_FILE_BYTES, } from "./constants.js";
4
4
  import { OmniBridgeError } from "./errors.js";
5
5
  const GRANT_PATH = "/api/omni-reader/direct-upload/v1/parse-grants";
6
6
  const BRIDGE_PACKAGE = "@cueai/omni-reader-mcp";
7
- const BRIDGE_VERSION = "1.0.1";
8
7
  const grantResponseSchema = z
9
8
  .object({
10
9
  grant_id: z.string().min(1),
@@ -17,14 +16,16 @@ const grantResponseSchema = z
17
16
  .refine((value) => new URL(value).protocol === "https:"),
18
17
  expires_at: z.string().datetime({ offset: true }),
19
18
  max_bytes: z.literal(MAX_FILE_BYTES),
20
- protocol_version: z.literal(PROTOCOL_VERSION),
19
+ protocol_version: z.literal(CUBE_GRANT_PROTOCOL_VERSION),
21
20
  })
22
21
  .strict();
23
22
  function bridgeError(code, message, retryable) {
24
23
  return new OmniBridgeError({
25
24
  code,
26
25
  message,
26
+ operationCreated: false,
27
27
  fileUploaded: false,
28
+ parserStarted: false,
28
29
  billed: false,
29
30
  contentReleased: false,
30
31
  retryable,
@@ -48,7 +49,7 @@ function grantRequestBody(input) {
48
49
  output: input.output,
49
50
  bridge: {
50
51
  package: BRIDGE_PACKAGE,
51
- version: BRIDGE_VERSION,
52
+ version: BRIDGE_RELEASE_VERSION,
52
53
  },
53
54
  };
54
55
  }
@@ -102,14 +103,16 @@ export class CubeGrantClient {
102
103
  this.#grantUrl = new URL(GRANT_PATH, baseUrl).toString();
103
104
  this.#fetch = options.fetchImpl ?? fetch;
104
105
  }
105
- async createGrant(input, clientRequestId, signal) {
106
+ async createGrant(input, clientRequestId, signal, options = {}) {
106
107
  if (this.#apiKey.length === 0) {
107
108
  throw bridgeError("MISSING_CUE_API_KEY", "Set CUE_API_KEY before using local Omni document parsing.", false);
108
109
  }
109
110
  const body = grantRequestBody(input);
110
111
  const serializedBody = JSON.stringify(body);
111
112
  const requestHash = grantRequestHash(body);
112
- await this.#journal.begin(clientRequestId, requestHash);
113
+ if (options.journal !== false) {
114
+ await this.#journal.begin(clientRequestId, requestHash);
115
+ }
113
116
  let response;
114
117
  try {
115
118
  response = await this.#fetch(this.#grantUrl, {
@@ -139,12 +142,14 @@ export class CubeGrantClient {
139
142
  catch {
140
143
  throw bridgeError("CUBE_PROTOCOL_ERROR", "Cube returned an invalid parse grant response.", false);
141
144
  }
142
- await this.#journal.markGrantIssued(clientRequestId, {
143
- operationId: parsed.operation_id,
144
- operationToken: parsed.operation_token,
145
- uploadUrl: parsed.upload_url,
146
- expiresAt: parsed.expires_at,
147
- });
145
+ if (options.journal !== false) {
146
+ await this.#journal.markGrantIssued(clientRequestId, {
147
+ operationId: parsed.operation_id,
148
+ operationToken: parsed.operation_token,
149
+ uploadUrl: parsed.upload_url,
150
+ expiresAt: parsed.expires_at,
151
+ });
152
+ }
148
153
  return {
149
154
  clientRequestId,
150
155
  requestHash,
package/dist/cursor.js CHANGED
@@ -7,7 +7,9 @@ function cursorError(code, message) {
7
7
  return new OmniBridgeError({
8
8
  code,
9
9
  message,
10
+ operationCreated: true,
10
11
  fileUploaded: true,
12
+ parserStarted: true,
11
13
  billed: true,
12
14
  contentReleased: true,
13
15
  retryable: false,
package/dist/errors.d.ts CHANGED
@@ -1,25 +1,56 @@
1
+ export type OmniFailureScope = "source" | "local_capability" | "authentication" | "billing" | "service" | "parser" | "operation" | "cleanup" | "bridge";
2
+ export type OmniSourceKind = "local" | "url";
3
+ export interface OmniErrorConstraints {
4
+ readonly max_bytes?: number;
5
+ readonly supported_extensions?: string[];
6
+ }
1
7
  export interface OmniBridgeErrorInit {
2
8
  code: string;
3
9
  message: string;
10
+ failureScope?: OmniFailureScope;
11
+ sourceKind?: OmniSourceKind;
12
+ userAction?: string;
13
+ requestId?: string;
14
+ operationCreated: boolean;
4
15
  fileUploaded: boolean;
16
+ parserStarted: boolean;
5
17
  billed: boolean;
6
18
  contentReleased: boolean;
7
19
  retryable: boolean;
20
+ retryAfter?: number;
21
+ constraints?: OmniErrorConstraints;
8
22
  }
9
23
  export interface OmniBridgeErrorPayload {
24
+ ok: false;
10
25
  code: string;
26
+ failure_scope?: OmniFailureScope;
27
+ source_kind?: OmniSourceKind;
28
+ retryable: boolean;
11
29
  message: string;
30
+ user_action?: string;
31
+ request_id?: string;
32
+ operation_created: boolean;
12
33
  file_uploaded: boolean;
34
+ parser_started: boolean;
13
35
  billed: boolean;
14
36
  content_released: boolean;
15
- retryable: boolean;
37
+ retry_after?: number;
38
+ constraints?: OmniErrorConstraints;
16
39
  }
17
40
  export declare class OmniBridgeError extends Error {
18
41
  readonly code: string;
42
+ readonly failureScope?: OmniFailureScope;
43
+ readonly sourceKind?: OmniSourceKind;
44
+ readonly userAction?: string;
45
+ readonly requestId?: string;
46
+ readonly operationCreated: boolean;
19
47
  readonly fileUploaded: boolean;
48
+ readonly parserStarted: boolean;
20
49
  readonly billed: boolean;
21
50
  readonly contentReleased: boolean;
22
51
  readonly retryable: boolean;
52
+ readonly retryAfter?: number;
53
+ readonly constraints?: OmniErrorConstraints;
23
54
  constructor(init: OmniBridgeErrorInit);
24
55
  toJSON(): OmniBridgeErrorPayload;
25
56
  }
package/dist/errors.js CHANGED
@@ -1,26 +1,51 @@
1
1
  export class OmniBridgeError extends Error {
2
2
  code;
3
+ failureScope;
4
+ sourceKind;
5
+ userAction;
6
+ requestId;
7
+ operationCreated;
3
8
  fileUploaded;
9
+ parserStarted;
4
10
  billed;
5
11
  contentReleased;
6
12
  retryable;
13
+ retryAfter;
14
+ constraints;
7
15
  constructor(init) {
8
16
  super(init.message);
9
17
  this.name = "OmniBridgeError";
10
18
  this.code = init.code;
19
+ this.failureScope = init.failureScope;
20
+ this.sourceKind = init.sourceKind;
21
+ this.userAction = init.userAction;
22
+ this.requestId = init.requestId;
23
+ this.operationCreated = init.operationCreated;
11
24
  this.fileUploaded = init.fileUploaded;
25
+ this.parserStarted = init.parserStarted;
12
26
  this.billed = init.billed;
13
27
  this.contentReleased = init.contentReleased;
14
28
  this.retryable = init.retryable;
29
+ this.retryAfter = init.retryAfter;
30
+ this.constraints = init.constraints;
15
31
  }
16
32
  toJSON() {
17
33
  return {
34
+ ok: false,
18
35
  code: this.code,
36
+ ...(this.failureScope === undefined ? {} : { failure_scope: this.failureScope }),
37
+ ...(this.sourceKind === undefined ? {} : { source_kind: this.sourceKind }),
38
+ retryable: this.retryable,
19
39
  message: this.message,
40
+ ...(this.userAction === undefined ? {} : { user_action: this.userAction }),
41
+ ...(this.requestId === undefined ? {} : { request_id: this.requestId }),
42
+ operation_created: this.operationCreated,
20
43
  file_uploaded: this.fileUploaded,
44
+ parser_started: this.parserStarted,
21
45
  billed: this.billed,
22
46
  content_released: this.contentReleased,
23
- retryable: this.retryable,
47
+ ...(this.retryAfter === undefined ? {} : { retry_after: this.retryAfter }),
48
+ ...(this.constraints === undefined ? {} : { constraints: this.constraints }),
24
49
  };
25
50
  }
26
51
  }
@@ -17,27 +17,41 @@ export interface ResultRetentionSink {
17
17
  abort(): Promise<void>;
18
18
  }
19
19
  export interface IiisOperationInput {
20
- readonly parseGrant: string;
20
+ readonly parseGrant?: string;
21
21
  readonly operationId: string;
22
22
  readonly operationToken: string;
23
- readonly uploadUrl: string;
24
- readonly expiresAt: string;
25
- readonly openedFile: OpenedAllowedFile;
23
+ readonly uploadUrl?: string;
24
+ readonly expiresAt?: string;
25
+ readonly openedFile?: OpenedAllowedFile;
26
26
  readonly retention: ResultRetentionSink;
27
27
  readonly progress?: ProgressSink;
28
28
  readonly signal?: AbortSignal;
29
29
  }
30
30
  export interface ReleasedResult extends ReleasedMetadata {
31
31
  }
32
+ export type IiisOperationStatus = "ISSUED" | "CLAIMED" | "UPLOADING" | "PROCESSING" | "SETTLING" | "RELEASED" | "EXPIRED" | "SETTLEMENT_DENIED" | "FAILED" | "CANCELED" | "DELIVERY_EXPIRED" | "DELIVERED";
33
+ export interface IiisOperationSnapshot {
34
+ readonly status: IiisOperationStatus;
35
+ readonly parserStarted: boolean;
36
+ readonly fileUploaded: boolean;
37
+ readonly billed: boolean;
38
+ readonly contentReleased: boolean;
39
+ readonly retryable: boolean;
40
+ readonly expiresAt: string | null;
41
+ }
32
42
  export interface IiisClientOptions {
33
43
  readonly fetchImpl?: typeof fetch;
34
44
  readonly pollIntervalMs?: number;
35
45
  readonly maxPolls?: number;
46
+ readonly operationBaseUrl?: string;
36
47
  }
37
48
  export declare class IiisClient {
38
49
  #private;
39
50
  constructor(options?: IiisClientOptions);
40
51
  uploadAndWait(input: IiisOperationInput): Promise<ReleasedResult>;
41
- downloadResult(input: IiisOperationInput): Promise<ReleasedResult>;
52
+ recoverAndWait(input: IiisOperationInput): Promise<ReleasedResult>;
53
+ inspectOperation(input: IiisOperationInput): Promise<IiisOperationSnapshot>;
54
+ cancelOperation(input: IiisOperationInput): Promise<IiisOperationSnapshot>;
55
+ downloadResult(input: IiisOperationInput, progress?: ProgressSink): Promise<ReleasedResult>;
42
56
  ack(input: IiisOperationInput): Promise<void>;
43
57
  }