@cueai/omni-reader-mcp 1.1.2 → 1.2.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.
@@ -102,13 +102,13 @@ export declare const stableErrorSchema: z.ZodObject<{
102
102
  supported_extensions?: string[] | undefined;
103
103
  }>>;
104
104
  }, "strict", z.ZodTypeAny, {
105
+ code: string;
106
+ message: string;
105
107
  billed: boolean;
106
108
  retryable: boolean;
107
- code: string;
108
109
  file_uploaded: boolean;
109
110
  content_released: boolean;
110
111
  parser_started: boolean;
111
- message: string;
112
112
  ok: false;
113
113
  operation_created: boolean;
114
114
  failure_scope?: "source" | "local_capability" | "authentication" | "billing" | "service" | "parser" | "operation" | "cleanup" | "bridge" | undefined;
@@ -121,13 +121,13 @@ export declare const stableErrorSchema: z.ZodObject<{
121
121
  supported_extensions?: string[] | undefined;
122
122
  } | undefined;
123
123
  }, {
124
+ code: string;
125
+ message: string;
124
126
  billed: boolean;
125
127
  retryable: boolean;
126
- code: string;
127
128
  file_uploaded: boolean;
128
129
  content_released: boolean;
129
130
  parser_started: boolean;
130
- message: string;
131
131
  ok: false;
132
132
  operation_created: boolean;
133
133
  failure_scope?: "source" | "local_capability" | "authentication" | "billing" | "service" | "parser" | "operation" | "cleanup" | "bridge" | undefined;
@@ -190,7 +190,401 @@ export declare const progressDetailSchema: z.ZodEffects<z.ZodObject<{
190
190
  total: number;
191
191
  completed: number;
192
192
  }>;
193
+ export declare const bundleDescriptorSchema: z.ZodObject<{
194
+ kind: z.ZodLiteral<"bundle">;
195
+ result_id: z.ZodString;
196
+ detail: z.ZodEnum<["grounded", "layout"]>;
197
+ bundle_protocol_version: z.ZodLiteral<"omni.result_bundle.v1">;
198
+ bundle_digest: z.ZodString;
199
+ bundle_bytes: z.ZodNumber;
200
+ expires_at: z.ZodString;
201
+ parts: z.ZodObject<{
202
+ content: z.ZodObject<{
203
+ part: z.ZodLiteral<"content">;
204
+ media_type: z.ZodLiteral<"text/markdown; charset=utf-8">;
205
+ result_bytes: z.ZodNumber;
206
+ digest: z.ZodString;
207
+ storage: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
208
+ kind: z.ZodLiteral<"inline">;
209
+ text: z.ZodString;
210
+ }, "strict", z.ZodTypeAny, {
211
+ text: string;
212
+ kind: "inline";
213
+ }, {
214
+ text: string;
215
+ kind: "inline";
216
+ }>, z.ZodObject<{
217
+ kind: z.ZodLiteral<"artifact">;
218
+ next_cursor: z.ZodString;
219
+ preview: z.ZodOptional<z.ZodString>;
220
+ }, "strict", z.ZodTypeAny, {
221
+ kind: "artifact";
222
+ next_cursor: string;
223
+ preview?: string | undefined;
224
+ }, {
225
+ kind: "artifact";
226
+ next_cursor: string;
227
+ preview?: string | undefined;
228
+ }>]>;
229
+ }, "strict", z.ZodTypeAny, {
230
+ part: "content";
231
+ result_bytes: number;
232
+ media_type: "text/markdown; charset=utf-8";
233
+ digest: string;
234
+ storage: {
235
+ text: string;
236
+ kind: "inline";
237
+ } | {
238
+ kind: "artifact";
239
+ next_cursor: string;
240
+ preview?: string | undefined;
241
+ };
242
+ }, {
243
+ part: "content";
244
+ result_bytes: number;
245
+ media_type: "text/markdown; charset=utf-8";
246
+ digest: string;
247
+ storage: {
248
+ text: string;
249
+ kind: "inline";
250
+ } | {
251
+ kind: "artifact";
252
+ next_cursor: string;
253
+ preview?: string | undefined;
254
+ };
255
+ }>;
256
+ grounding: z.ZodObject<{
257
+ part: z.ZodLiteral<"grounding">;
258
+ media_type: z.ZodLiteral<"application/vnd.cue.omni-grounding+json; version=1">;
259
+ result_bytes: z.ZodNumber;
260
+ digest: z.ZodString;
261
+ storage: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
262
+ kind: z.ZodLiteral<"inline">;
263
+ value: z.ZodUnknown;
264
+ }, "strict", z.ZodTypeAny, {
265
+ kind: "inline";
266
+ value?: unknown;
267
+ }, {
268
+ kind: "inline";
269
+ value?: unknown;
270
+ }>, z.ZodObject<{
271
+ kind: z.ZodLiteral<"artifact">;
272
+ next_cursor: z.ZodString;
273
+ }, "strict", z.ZodTypeAny, {
274
+ kind: "artifact";
275
+ next_cursor: string;
276
+ }, {
277
+ kind: "artifact";
278
+ next_cursor: string;
279
+ }>]>;
280
+ }, "strict", z.ZodTypeAny, {
281
+ part: "grounding";
282
+ result_bytes: number;
283
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
284
+ digest: string;
285
+ storage: {
286
+ kind: "inline";
287
+ value?: unknown;
288
+ } | {
289
+ kind: "artifact";
290
+ next_cursor: string;
291
+ };
292
+ }, {
293
+ part: "grounding";
294
+ result_bytes: number;
295
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
296
+ digest: string;
297
+ storage: {
298
+ kind: "inline";
299
+ value?: unknown;
300
+ } | {
301
+ kind: "artifact";
302
+ next_cursor: string;
303
+ };
304
+ }>;
305
+ }, "strict", z.ZodTypeAny, {
306
+ content: {
307
+ part: "content";
308
+ result_bytes: number;
309
+ media_type: "text/markdown; charset=utf-8";
310
+ digest: string;
311
+ storage: {
312
+ text: string;
313
+ kind: "inline";
314
+ } | {
315
+ kind: "artifact";
316
+ next_cursor: string;
317
+ preview?: string | undefined;
318
+ };
319
+ };
320
+ grounding: {
321
+ part: "grounding";
322
+ result_bytes: number;
323
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
324
+ digest: string;
325
+ storage: {
326
+ kind: "inline";
327
+ value?: unknown;
328
+ } | {
329
+ kind: "artifact";
330
+ next_cursor: string;
331
+ };
332
+ };
333
+ }, {
334
+ content: {
335
+ part: "content";
336
+ result_bytes: number;
337
+ media_type: "text/markdown; charset=utf-8";
338
+ digest: string;
339
+ storage: {
340
+ text: string;
341
+ kind: "inline";
342
+ } | {
343
+ kind: "artifact";
344
+ next_cursor: string;
345
+ preview?: string | undefined;
346
+ };
347
+ };
348
+ grounding: {
349
+ part: "grounding";
350
+ result_bytes: number;
351
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
352
+ digest: string;
353
+ storage: {
354
+ kind: "inline";
355
+ value?: unknown;
356
+ } | {
357
+ kind: "artifact";
358
+ next_cursor: string;
359
+ };
360
+ };
361
+ }>;
362
+ }, "strict", z.ZodTypeAny, {
363
+ detail: "grounded" | "layout";
364
+ result_id: string;
365
+ expires_at: string;
366
+ kind: "bundle";
367
+ bundle_protocol_version: "omni.result_bundle.v1";
368
+ bundle_digest: string;
369
+ bundle_bytes: number;
370
+ parts: {
371
+ content: {
372
+ part: "content";
373
+ result_bytes: number;
374
+ media_type: "text/markdown; charset=utf-8";
375
+ digest: string;
376
+ storage: {
377
+ text: string;
378
+ kind: "inline";
379
+ } | {
380
+ kind: "artifact";
381
+ next_cursor: string;
382
+ preview?: string | undefined;
383
+ };
384
+ };
385
+ grounding: {
386
+ part: "grounding";
387
+ result_bytes: number;
388
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
389
+ digest: string;
390
+ storage: {
391
+ kind: "inline";
392
+ value?: unknown;
393
+ } | {
394
+ kind: "artifact";
395
+ next_cursor: string;
396
+ };
397
+ };
398
+ };
399
+ }, {
400
+ detail: "grounded" | "layout";
401
+ result_id: string;
402
+ expires_at: string;
403
+ kind: "bundle";
404
+ bundle_protocol_version: "omni.result_bundle.v1";
405
+ bundle_digest: string;
406
+ bundle_bytes: number;
407
+ parts: {
408
+ content: {
409
+ part: "content";
410
+ result_bytes: number;
411
+ media_type: "text/markdown; charset=utf-8";
412
+ digest: string;
413
+ storage: {
414
+ text: string;
415
+ kind: "inline";
416
+ } | {
417
+ kind: "artifact";
418
+ next_cursor: string;
419
+ preview?: string | undefined;
420
+ };
421
+ };
422
+ grounding: {
423
+ part: "grounding";
424
+ result_bytes: number;
425
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
426
+ digest: string;
427
+ storage: {
428
+ kind: "inline";
429
+ value?: unknown;
430
+ } | {
431
+ kind: "artifact";
432
+ next_cursor: string;
433
+ };
434
+ };
435
+ };
436
+ }>;
193
437
  export declare const parseResultSchema: z.ZodTypeAny;
438
+ export declare const bundlePartReadSchema: z.ZodObject<{
439
+ status: z.ZodLiteral<"completed">;
440
+ result: z.ZodEffects<z.ZodDiscriminatedUnion<"part", [z.ZodObject<{
441
+ part: z.ZodLiteral<"content">;
442
+ media_type: z.ZodLiteral<"text/markdown; charset=utf-8">;
443
+ result_id: z.ZodString;
444
+ result_bytes: z.ZodNumber;
445
+ offset: z.ZodNumber;
446
+ decoded_bytes: z.ZodNumber;
447
+ text: z.ZodString;
448
+ next_cursor: z.ZodOptional<z.ZodString>;
449
+ expires_at: z.ZodString;
450
+ }, "strict", z.ZodTypeAny, {
451
+ text: string;
452
+ result_id: string;
453
+ offset: number;
454
+ part: "content";
455
+ expires_at: string;
456
+ result_bytes: number;
457
+ media_type: "text/markdown; charset=utf-8";
458
+ decoded_bytes: number;
459
+ next_cursor?: string | undefined;
460
+ }, {
461
+ text: string;
462
+ result_id: string;
463
+ offset: number;
464
+ part: "content";
465
+ expires_at: string;
466
+ result_bytes: number;
467
+ media_type: "text/markdown; charset=utf-8";
468
+ decoded_bytes: number;
469
+ next_cursor?: string | undefined;
470
+ }>, z.ZodObject<{
471
+ part: z.ZodLiteral<"grounding">;
472
+ media_type: z.ZodLiteral<"application/vnd.cue.omni-grounding+json; version=1">;
473
+ result_id: z.ZodString;
474
+ result_bytes: z.ZodNumber;
475
+ offset: z.ZodNumber;
476
+ decoded_bytes: z.ZodNumber;
477
+ text: z.ZodString;
478
+ next_cursor: z.ZodOptional<z.ZodString>;
479
+ expires_at: z.ZodString;
480
+ }, "strict", z.ZodTypeAny, {
481
+ text: string;
482
+ result_id: string;
483
+ offset: number;
484
+ part: "grounding";
485
+ expires_at: string;
486
+ result_bytes: number;
487
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
488
+ decoded_bytes: number;
489
+ next_cursor?: string | undefined;
490
+ }, {
491
+ text: string;
492
+ result_id: string;
493
+ offset: number;
494
+ part: "grounding";
495
+ expires_at: string;
496
+ result_bytes: number;
497
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
498
+ decoded_bytes: number;
499
+ next_cursor?: string | undefined;
500
+ }>]>, {
501
+ text: string;
502
+ result_id: string;
503
+ offset: number;
504
+ part: "content";
505
+ expires_at: string;
506
+ result_bytes: number;
507
+ media_type: "text/markdown; charset=utf-8";
508
+ decoded_bytes: number;
509
+ next_cursor?: string | undefined;
510
+ } | {
511
+ text: string;
512
+ result_id: string;
513
+ offset: number;
514
+ part: "grounding";
515
+ expires_at: string;
516
+ result_bytes: number;
517
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
518
+ decoded_bytes: number;
519
+ next_cursor?: string | undefined;
520
+ }, {
521
+ text: string;
522
+ result_id: string;
523
+ offset: number;
524
+ part: "content";
525
+ expires_at: string;
526
+ result_bytes: number;
527
+ media_type: "text/markdown; charset=utf-8";
528
+ decoded_bytes: number;
529
+ next_cursor?: string | undefined;
530
+ } | {
531
+ text: string;
532
+ result_id: string;
533
+ offset: number;
534
+ part: "grounding";
535
+ expires_at: string;
536
+ result_bytes: number;
537
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
538
+ decoded_bytes: number;
539
+ next_cursor?: string | undefined;
540
+ }>;
541
+ }, "strict", z.ZodTypeAny, {
542
+ status: "completed";
543
+ result: {
544
+ text: string;
545
+ result_id: string;
546
+ offset: number;
547
+ part: "content";
548
+ expires_at: string;
549
+ result_bytes: number;
550
+ media_type: "text/markdown; charset=utf-8";
551
+ decoded_bytes: number;
552
+ next_cursor?: string | undefined;
553
+ } | {
554
+ text: string;
555
+ result_id: string;
556
+ offset: number;
557
+ part: "grounding";
558
+ expires_at: string;
559
+ result_bytes: number;
560
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
561
+ decoded_bytes: number;
562
+ next_cursor?: string | undefined;
563
+ };
564
+ }, {
565
+ status: "completed";
566
+ result: {
567
+ text: string;
568
+ result_id: string;
569
+ offset: number;
570
+ part: "content";
571
+ expires_at: string;
572
+ result_bytes: number;
573
+ media_type: "text/markdown; charset=utf-8";
574
+ decoded_bytes: number;
575
+ next_cursor?: string | undefined;
576
+ } | {
577
+ text: string;
578
+ result_id: string;
579
+ offset: number;
580
+ part: "grounding";
581
+ expires_at: string;
582
+ result_bytes: number;
583
+ media_type: "application/vnd.cue.omni-grounding+json; version=1";
584
+ decoded_bytes: number;
585
+ next_cursor?: string | undefined;
586
+ };
587
+ }>;
194
588
  export declare const readResultOutputSchema: z.ZodTypeAny;
195
589
  export declare const discardResultOutputSchema: z.ZodTypeAny;
196
590
  export declare const parseToolOutputSchema: z.ZodTypeAny;
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { RESULT_BUNDLE_PROTOCOL_VERSION } from "./protocol.js";
2
3
  const operationIdSchema = z.string().min(1).max(128);
3
4
  const resultIdSchema = z.string().regex(/^result_[A-Za-z0-9_-]{16,64}$/u);
4
5
  const constraintsSchema = z
@@ -84,6 +85,80 @@ const billingSchema = z
84
85
  credits_remaining: z.number().nonnegative(),
85
86
  })
86
87
  .strict();
88
+ // v3 bundle descriptor (D2-D item 7): closed keyed-parts object. Top-level and
89
+ // nested objects are all additionalProperties=false; `parts` must have exact
90
+ // keys `content` and `grounding`. Storage is a closed discriminated union:
91
+ // content inline exact keys {kind,text}; grounding inline exact keys
92
+ // {kind,value}; content artifact exact keys {kind,next_cursor} plus optional
93
+ // preview; grounding artifact exact keys {kind,next_cursor} with
94
+ // preview/text/value forbidden.
95
+ const sha256DigestSchema = z.string().regex(/^sha256:[0-9a-f]{64}$/u);
96
+ const contentMediaTypeSchema = z.literal("text/markdown; charset=utf-8");
97
+ const groundingMediaTypeSchema = z.literal("application/vnd.cue.omni-grounding+json; version=1");
98
+ const contentStorageSchema = z.discriminatedUnion("kind", [
99
+ z
100
+ .object({
101
+ kind: z.literal("inline"),
102
+ text: z.string(),
103
+ })
104
+ .strict(),
105
+ z
106
+ .object({
107
+ kind: z.literal("artifact"),
108
+ next_cursor: z.string().min(1).max(2048),
109
+ preview: z.string().optional(),
110
+ })
111
+ .strict(),
112
+ ]);
113
+ const groundingStorageSchema = z.discriminatedUnion("kind", [
114
+ z
115
+ .object({
116
+ kind: z.literal("inline"),
117
+ value: z.unknown(),
118
+ })
119
+ .strict(),
120
+ z
121
+ .object({
122
+ kind: z.literal("artifact"),
123
+ next_cursor: z.string().min(1).max(2048),
124
+ })
125
+ .strict(),
126
+ ]);
127
+ const contentPartDescriptorSchema = z
128
+ .object({
129
+ part: z.literal("content"),
130
+ media_type: contentMediaTypeSchema,
131
+ result_bytes: z.number().int().nonnegative(),
132
+ digest: sha256DigestSchema,
133
+ storage: contentStorageSchema,
134
+ })
135
+ .strict();
136
+ const groundingPartDescriptorSchema = z
137
+ .object({
138
+ part: z.literal("grounding"),
139
+ media_type: groundingMediaTypeSchema,
140
+ result_bytes: z.number().int().nonnegative(),
141
+ digest: sha256DigestSchema,
142
+ storage: groundingStorageSchema,
143
+ })
144
+ .strict();
145
+ export const bundleDescriptorSchema = z
146
+ .object({
147
+ kind: z.literal("bundle"),
148
+ result_id: resultIdSchema,
149
+ detail: z.enum(["grounded", "layout"]),
150
+ bundle_protocol_version: z.literal(RESULT_BUNDLE_PROTOCOL_VERSION),
151
+ bundle_digest: sha256DigestSchema,
152
+ bundle_bytes: z.number().int().nonnegative(),
153
+ expires_at: z.string().datetime({ offset: true }),
154
+ parts: z
155
+ .object({
156
+ content: contentPartDescriptorSchema,
157
+ grounding: groundingPartDescriptorSchema,
158
+ })
159
+ .strict(),
160
+ })
161
+ .strict();
87
162
  const localResultCacheSchema = z
88
163
  .object({
89
164
  expires_at: z.string().datetime({ offset: true }),
@@ -114,7 +189,11 @@ export const parseResultSchema = z.discriminatedUnion("status", [
114
189
  .object({
115
190
  status: z.literal("completed"),
116
191
  operation_id: operationIdSchema,
117
- result: z.union([inlineResultSchema, artifactResultSchema]),
192
+ result: z.union([
193
+ inlineResultSchema,
194
+ artifactResultSchema,
195
+ bundleDescriptorSchema,
196
+ ]),
118
197
  billing: billingSchema.optional(),
119
198
  data_handling: dataHandlingSchema,
120
199
  local_result_cache: localResultCacheSchema.optional(),
@@ -124,7 +203,11 @@ export const parseResultSchema = z.discriminatedUnion("status", [
124
203
  .object({
125
204
  status: z.literal("cleanup_pending"),
126
205
  operation_id: operationIdSchema,
127
- result: z.union([inlineResultSchema, artifactResultSchema]).optional(),
206
+ result: z.union([
207
+ inlineResultSchema,
208
+ artifactResultSchema,
209
+ bundleDescriptorSchema,
210
+ ]).optional(),
128
211
  cleanup_deadline: z.string().datetime({ offset: true }),
129
212
  data_handling: dataHandlingSchema,
130
213
  })
@@ -155,8 +238,53 @@ const resultChunkSchema = z
155
238
  next_cursor: z.string().min(1).max(2048).optional(),
156
239
  })
157
240
  .strict();
241
+ // v3 part read (D2-D item 9): closed chunk with part/media type/offset/
242
+ // decoded bytes. Content always carries the Markdown media type, grounding
243
+ // always the grounding media type; `decoded_bytes` equals the UTF-8 byte
244
+ // length of `text`. `next_cursor` appears only on non-final chunks.
245
+ const bundlePartReadChunkSchema = z
246
+ .discriminatedUnion("part", [
247
+ z
248
+ .object({
249
+ part: z.literal("content"),
250
+ media_type: contentMediaTypeSchema,
251
+ result_id: resultIdSchema,
252
+ result_bytes: z.number().int().nonnegative(),
253
+ offset: z.number().int().nonnegative(),
254
+ decoded_bytes: z.number().int().nonnegative(),
255
+ text: z.string(),
256
+ next_cursor: z.string().min(1).max(2048).optional(),
257
+ expires_at: z.string().datetime({ offset: true }),
258
+ })
259
+ .strict(),
260
+ z
261
+ .object({
262
+ part: z.literal("grounding"),
263
+ media_type: groundingMediaTypeSchema,
264
+ result_id: resultIdSchema,
265
+ result_bytes: z.number().int().nonnegative(),
266
+ offset: z.number().int().nonnegative(),
267
+ decoded_bytes: z.number().int().nonnegative(),
268
+ text: z.string(),
269
+ next_cursor: z.string().min(1).max(2048).optional(),
270
+ expires_at: z.string().datetime({ offset: true }),
271
+ })
272
+ .strict(),
273
+ ])
274
+ .refine((value) => Buffer.byteLength(value.text, "utf8") === value.decoded_bytes, { message: "decoded_bytes must equal the UTF-8 byte length of text" });
275
+ export const bundlePartReadSchema = z
276
+ .object({
277
+ status: z.literal("completed"),
278
+ result: bundlePartReadChunkSchema,
279
+ })
280
+ .strict();
158
281
  export const readResultOutputSchema = z.discriminatedUnion("status", [
159
- z.object({ status: z.literal("completed"), result: resultChunkSchema }).strict(),
282
+ z
283
+ .object({
284
+ status: z.literal("completed"),
285
+ result: z.union([resultChunkSchema, bundlePartReadChunkSchema]),
286
+ })
287
+ .strict(),
160
288
  failedResultSchema,
161
289
  ]);
162
290
  export const discardResultOutputSchema = z.discriminatedUnion("status", [
@@ -186,7 +314,11 @@ export const parseToolOutputSchema = z
186
314
  next_action: z.literal("check_status").optional(),
187
315
  poll_after_seconds: z.number().int().positive().optional(),
188
316
  can_cancel: z.boolean().optional(),
189
- result: z.union([inlineResultSchema, artifactResultSchema]).optional(),
317
+ result: z.union([
318
+ inlineResultSchema,
319
+ artifactResultSchema,
320
+ bundleDescriptorSchema,
321
+ ]).optional(),
190
322
  billing: billingSchema.optional(),
191
323
  data_handling: dataHandlingSchema.optional(),
192
324
  local_result_cache: localResultCacheSchema.optional(),
@@ -198,7 +330,7 @@ export const parseToolOutputSchema = z
198
330
  export const readResultToolOutputSchema = z
199
331
  .object({
200
332
  status: z.enum(["completed", "failed"]),
201
- result: resultChunkSchema.optional(),
333
+ result: z.union([resultChunkSchema, bundlePartReadChunkSchema]).optional(),
202
334
  error: stableErrorSchema.optional(),
203
335
  })
204
336
  .strict();
@@ -210,26 +342,50 @@ export const discardResultToolOutputSchema = z
210
342
  error: stableErrorSchema.optional(),
211
343
  })
212
344
  .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"}.`;
345
+ function storageText(result) {
346
+ const parts = result.parts;
347
+ if (parts === null || typeof parts !== "object" || Array.isArray(parts)) {
348
+ return undefined;
349
+ }
350
+ const content = parts.content;
351
+ if (content === null || typeof content !== "object" || Array.isArray(content)) {
352
+ return undefined;
353
+ }
354
+ const storage = content.storage;
355
+ if (storage === null || typeof storage !== "object" || Array.isArray(storage)) {
356
+ return undefined;
357
+ }
358
+ const record = storage;
359
+ if (record.kind !== "inline" || typeof record.text !== "string") {
360
+ return undefined;
361
+ }
362
+ return record.text;
363
+ }
364
+ // Content-only fallback (D2-D item 17): inline bundle content falls back to
365
+ // the exact Markdown bytes only; artifact content falls back to the complete
366
+ // compact descriptor JSON. Grounding JSON is never appended to plain Markdown.
367
+ function textFallback(value) {
368
+ if (value.status === "completed") {
369
+ const result = value.result;
370
+ if (result !== null && typeof result === "object" && !Array.isArray(result)) {
371
+ const record = result;
372
+ if (record.kind === "inline" && typeof record.text === "string") {
373
+ return record.text;
374
+ }
375
+ if (record.kind === "bundle") {
376
+ const inlineText = storageText(record);
377
+ if (inlineText !== undefined)
378
+ return inlineText;
379
+ }
380
+ }
217
381
  }
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.";
382
+ return JSON.stringify(value);
227
383
  }
228
384
  export function structuredResult(schema, value) {
229
385
  const structuredContent = schema.parse(value);
230
386
  return {
231
387
  ...(structuredContent.status === "failed" ? { isError: true } : {}),
232
388
  structuredContent,
233
- content: [{ type: "text", text: summarizeForTextFallback(structuredContent) }],
389
+ content: [{ type: "text", text: textFallback(structuredContent) }],
234
390
  };
235
391
  }