@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
@@ -0,0 +1,10 @@
1
+ export declare const ONBOARDING_POLICY_URL = "https://cuecue.cn/api/v1/billing/public/onboarding-policy";
2
+ export declare const API_KEY_URL = "https://cuecue.cn/api-key";
3
+ export interface OnboardingPolicy {
4
+ readonly apiKeyUrl: typeof API_KEY_URL;
5
+ readonly firstRegistrationCredits: number;
6
+ readonly freeDailyCredits: number;
7
+ }
8
+ export declare function getOnboardingPolicy(fetchImpl: typeof fetch, signal: AbortSignal): Promise<OnboardingPolicy | undefined>;
9
+ export declare function onboardingGuidance(policy: OnboardingPolicy | undefined): string;
10
+ export declare function getOnboardingPolicyWithTimeout(fetchImpl: typeof fetch, timeoutMs?: number): Promise<OnboardingPolicy | undefined>;
@@ -0,0 +1,58 @@
1
+ export const ONBOARDING_POLICY_URL = "https://cuecue.cn/api/v1/billing/public/onboarding-policy";
2
+ export const API_KEY_URL = "https://cuecue.cn/api-key";
3
+ function isRecord(value) {
4
+ return value !== null && typeof value === "object" && !Array.isArray(value);
5
+ }
6
+ function boundedCredits(value) {
7
+ return Number.isInteger(value) && Number(value) > 0 && Number(value) <= 1_000_000;
8
+ }
9
+ function normalizeOnboardingPolicy(value) {
10
+ if (!isRecord(value))
11
+ return undefined;
12
+ if (value.api_key_url !== API_KEY_URL ||
13
+ !boundedCredits(value.first_registration) ||
14
+ !boundedCredits(value.free_daily))
15
+ return undefined;
16
+ return {
17
+ apiKeyUrl: API_KEY_URL,
18
+ firstRegistrationCredits: value.first_registration,
19
+ freeDailyCredits: value.free_daily,
20
+ };
21
+ }
22
+ export async function getOnboardingPolicy(fetchImpl, signal) {
23
+ try {
24
+ const response = await fetchImpl(ONBOARDING_POLICY_URL, {
25
+ method: "GET",
26
+ headers: { accept: "application/json" },
27
+ signal,
28
+ });
29
+ if (!response.ok)
30
+ return undefined;
31
+ return normalizeOnboardingPolicy(await response.json());
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
36
+ }
37
+ export function onboardingGuidance(policy) {
38
+ const creditLine = policy === undefined
39
+ ? `新账号有免费积分可体验,请前往 ${API_KEY_URL} 注册并创建 API Key。`
40
+ : `新账号首次注册赠送 ${policy.firstRegistrationCredits} 积分,免费账号每日有 ${policy.freeDailyCredits} 积分免费额度,可先体验 Omni,无需预先充值。`;
41
+ return [
42
+ "使用 Omni 需要配置 Cue API Key。",
43
+ `获取 API Key:${API_KEY_URL}`,
44
+ creditLine,
45
+ "创建后,请在 Agent 的安全密钥或环境设置中配置 CUE_API_KEY。请勿把 API Key 粘贴到对话中。",
46
+ ].join("\n");
47
+ }
48
+ export async function getOnboardingPolicyWithTimeout(fetchImpl, timeoutMs = 3_000) {
49
+ const controller = new AbortController();
50
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
51
+ timer.unref?.();
52
+ try {
53
+ return await getOnboardingPolicy(fetchImpl, controller.signal);
54
+ }
55
+ finally {
56
+ clearTimeout(timer);
57
+ }
58
+ }
@@ -1,13 +1,55 @@
1
- export type JournalState = "GRANT_PENDING" | "GRANT_ISSUED";
1
+ export type JournalState = "CREATED" | "GRANT_PENDING" | "GRANT_ISSUED" | "UPLOADING" | "PROCESSING" | "RESULT_READY" | "ACK_PENDING" | "CLEANUP_PENDING" | "COMPLETED" | "FAILED" | "CANCELED" | "EXPIRED";
2
+ export type JournalProgressUnit = "page" | "sheet" | "slide" | "frame" | "segment";
3
+ export type JournalCleanupState = "not_created" | "in_use" | "pending" | "deleted";
4
+ export type JournalDeliveryState = "not_created" | "pending" | "deleted_after_ack";
5
+ export interface JournalProgress {
6
+ readonly unit: JournalProgressUnit;
7
+ readonly completed: number;
8
+ readonly total: number;
9
+ }
2
10
  export interface JournalRecord {
3
11
  readonly clientRequestId: string;
4
12
  readonly requestHash: string;
13
+ readonly sourceLocatorHash: string | null;
14
+ readonly sourceKind: "local" | "url";
5
15
  readonly operationId: string | null;
6
16
  readonly operationToken: string | null;
7
17
  readonly uploadUrl: string | null;
8
18
  readonly state: JournalState;
9
19
  readonly createdAt: string;
20
+ readonly updatedAt: string;
10
21
  readonly expiresAt: string | null;
22
+ readonly stage: string | null;
23
+ readonly progressPercent: number;
24
+ readonly progress: JournalProgress | null;
25
+ readonly fileUploaded: boolean;
26
+ readonly parserStarted: boolean;
27
+ readonly billed: boolean;
28
+ readonly contentReleased: boolean;
29
+ readonly processingCopy: JournalCleanupState;
30
+ readonly temporaryData: JournalCleanupState;
31
+ readonly deliveryResult: JournalDeliveryState;
32
+ readonly resultId: string | null;
33
+ readonly resultExpiresAt: string | null;
34
+ readonly errorCode: string | null;
35
+ }
36
+ export interface JournalPatch {
37
+ readonly operationId?: string | null;
38
+ readonly operationToken?: string | null;
39
+ readonly expiresAt?: string | null;
40
+ readonly stage?: string | null;
41
+ readonly progressPercent?: number;
42
+ readonly progress?: JournalProgress | null;
43
+ readonly fileUploaded?: boolean;
44
+ readonly parserStarted?: boolean;
45
+ readonly billed?: boolean;
46
+ readonly contentReleased?: boolean;
47
+ readonly processingCopy?: JournalCleanupState;
48
+ readonly temporaryData?: JournalCleanupState;
49
+ readonly deliveryResult?: JournalDeliveryState;
50
+ readonly resultId?: string | null;
51
+ readonly resultExpiresAt?: string | null;
52
+ readonly errorCode?: string | null;
11
53
  }
12
54
  export interface IssuedGrantJournalFields {
13
55
  readonly operationId: string;
@@ -22,6 +64,13 @@ export interface OperationJournalOptions {
22
64
  export declare class OperationJournal {
23
65
  #private;
24
66
  constructor(options?: OperationJournalOptions);
67
+ beginIntent(clientRequestId: string, requestHash: string, sourceKind?: "local" | "url", sourceLocatorHash?: string | null): Promise<JournalRecord>;
68
+ transition(clientRequestId: string, expectedState: JournalState, nextState: JournalState, patch: JournalPatch): Promise<JournalRecord>;
69
+ loadByRequestId(clientRequestId: string): Promise<JournalRecord | null>;
70
+ loadByOperationId(operationId: string): Promise<JournalRecord | null>;
71
+ loadLatestByRequestHash(requestHash: string): Promise<JournalRecord | null>;
72
+ loadLatestBySourceLocatorHash(sourceLocatorHash: string): Promise<JournalRecord | null>;
73
+ listRecoverable(): Promise<JournalRecord[]>;
25
74
  begin(clientRequestId: string, requestHash: string): Promise<JournalRecord>;
26
75
  markGrantIssued(clientRequestId: string, fields: IssuedGrantJournalFields): Promise<JournalRecord>;
27
76
  load(clientRequestId: string): Promise<JournalRecord | null>;