-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathstructured_output_schemas.ts
More file actions
716 lines (686 loc) · 29.2 KB
/
Copy pathstructured_output_schemas.ts
File metadata and controls
716 lines (686 loc) · 29.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
/**
* Shared JSON schema definitions for structured output across tools.
* These schemas define the format of structured data returned by various tools.
*
* The `type: '...' as const` assertions throughout narrow the string to a literal,
* which the MCP SDK's schema types require (a plain `string` won't type-check).
*/
/**
* Schema for developer information
*/
const developerSchema = {
type: 'object' as const,
properties: {
username: { type: 'string', description: 'Developer username' },
isOfficialApify: { type: 'boolean', description: 'Whether the actor is developed by Apify' },
url: { type: 'string', description: 'Developer profile URL' },
},
required: ['username', 'isOfficialApify', 'url'],
};
/**
* Schema for tiered pricing within an event
*/
const eventTieredPricingSchema = {
type: 'array' as const,
items: {
type: 'object' as const,
properties: {
tier: { type: 'string' },
priceUsd: { type: 'number' },
},
},
};
/**
* Schema for pricing events (PAY_PER_EVENT model)
*/
const pricingEventsSchema = {
type: 'array' as const,
items: {
type: 'object' as const,
properties: {
title: { type: 'string', description: 'Event title' },
description: { type: 'string', description: 'Event description' },
priceUsd: { type: 'number', description: 'Price in USD' },
tieredPricing: eventTieredPricingSchema,
},
},
description: 'Event-based pricing information',
};
/**
* Schema for tiered pricing (general)
*/
const tieredPricingSchema = {
type: 'array' as const,
items: {
type: 'object' as const,
properties: {
tier: { type: 'string', description: 'Tier name' },
pricePerUnit: { type: 'number', description: 'Price per unit for this tier' },
},
},
description: 'Tiered pricing information',
};
/**
* Schema for pricing information
*/
export const pricingSchema = {
type: 'object' as const,
properties: {
model: {
type: 'string',
description: 'Pricing model (FREE, PRICE_PER_DATASET_ITEM, FLAT_PRICE_PER_MONTH, PAY_PER_EVENT)',
},
userTier: {
type: 'string',
enum: ['FREE', 'BRONZE', 'SILVER', 'GOLD', 'PLATINUM', 'DIAMOND'],
description:
"The user's plan tier used to resolve pricing (always the user's tier, even if a different tier was used as fallback)",
},
pricePerUnit: { type: 'number', description: 'Price per unit (for non-free models)' },
unitName: { type: 'string', description: 'Unit name for pricing' },
trialMinutes: { type: 'number', description: 'Trial period in minutes' },
tieredPricing: tieredPricingSchema,
events: pricingEventsSchema,
pricingNote: {
type: 'string',
description:
'Note naming the resolved tier; only emitted in simplified mode ' +
'when the actor has multiple tiers and they resolve consistently',
},
eventDescriptionsOmitted: {
type: 'boolean',
description: 'Whether event descriptions were omitted because the actor has many pricing events',
},
eventDescriptionsNote: {
type: 'string',
description:
'Note explaining that event descriptions were omitted and full details are available via fetch-actor-details',
},
},
// `userTier` is optional: `search-actors` returns it once at the response top level
// (it is a session constant), so per-Actor pricing omits it. `fetch-actor-details`
// returns a single Actor and keeps `userTier` in the pricing block.
required: ['model'],
};
/**
* Schema for Actor statistics
*/
export const statsSchema = {
type: 'object' as const,
properties: {
totalUsers: { type: 'number', description: 'Total users' },
monthlyUsers: { type: 'number', description: 'Monthly active users' },
successRate: { type: 'number', description: 'Success rate percentage' },
bookmarks: { type: 'number', description: 'Number of bookmarks' },
},
};
/**
* Schema for Actor information (card)
* Used in both search results and detailed Actor info
*/
export const actorInfoSchema = {
type: 'object' as const,
properties: {
title: { type: 'string', description: 'Actor title' },
url: { type: 'string', description: 'Actor URL' },
id: { type: 'string', description: 'Actor ID' },
fullName: { type: 'string', description: 'Full Actor name (username/name)' },
pictureUrl: { type: 'string', description: 'Actor picture URL' },
developer: developerSchema,
description: { type: 'string', description: 'Actor description' },
categories: {
type: 'array' as const,
items: { type: 'string' },
description: 'Actor categories',
},
pricing: pricingSchema,
stats: statsSchema,
rating: {
type: 'object' as const,
properties: {
average: { type: 'number', description: 'Average rating' },
count: { type: 'number', description: 'Number of ratings' },
},
},
modifiedAt: { type: 'string', description: 'Last modification date' },
isDeprecated: { type: 'boolean', description: 'Whether the Actor is deprecated' },
// Mirrors `ActorStoreInputSchema` in src/types.ts; only `type` is preserved per
// field by apify-core's `trimInputSchema`, so the per-field shape stays minimal.
inputFields: {
type: 'object' as const,
description:
'Compact JSON-Schema-shaped descriptor of the Actor input; only `type` is preserved per field.',
properties: {
type: { type: 'string', description: 'Always `"object"`.' },
properties: {
type: 'object' as const,
description: 'Map of input field name to its type descriptor.',
additionalProperties: {
type: 'object' as const,
properties: {
type: { description: 'JSON Schema field type — string or array of strings.' },
},
required: ['type'],
},
},
required: {
type: 'array' as const,
items: { type: 'string' },
description: 'Names of required input fields.',
},
},
required: ['type', 'properties'],
},
inputFieldsTruncated: {
type: 'boolean',
description:
'Present and `true` when `inputFields` was truncated; fetch the full schema via `fetch-actor-details`.',
},
inputFieldsTotalCount: {
type: 'number',
description:
'Total number of input fields before truncation; present only when `inputFields` was truncated.',
},
},
required: ['url', 'id', 'fullName', 'developer', 'description', 'categories', 'isDeprecated'],
};
/**
* Schema for Actor details output (fetch-actor-details tool)
* All fields are optional since the tool supports selective output via the 'output' parameter
*
* NOTE on `readme`: This field contains the abridged README summary when the Actor has one,
* falling back to the full README otherwise. The field is named `readme` (not `readmeSummary`)
* to stay consistent with the widget UI contract. Most Actors should have a summary defined,
* so the full README fallback is only expected in niche cases.
*/
export const actorDetailsOutputSchema = {
type: 'object' as const,
properties: {
actorInfo: actorInfoSchema,
readme: {
type: 'string',
description: 'Actor README summary when available, otherwise the full README documentation.',
},
inputSchema: { type: 'object' as const, description: 'Actor input schema.' },
outputSchema: { type: 'object' as const, description: 'Output schema inferred from successful runs.' },
mcpTools: {
type: 'string',
description:
'Markdown listing of MCP tools exposed by the Actor (only present when `output.mcpTools` is requested).',
},
},
};
/**
* Schema for fetch-actor-details-widget output.
* Widget-only; renders as an interactive UI element in apps mode.
* `actorInfo` is the widget-shaped actor (from `formatActorForWidget`), kept as a loose
* object because it doesn't align with `actorInfoSchema` (adds `currentPricingInfo` etc.).
*/
export const actorDetailsWidgetOutputSchema = {
type: 'object' as const,
properties: {
actorDetails: {
type: 'object' as const,
properties: {
actorInfo: {
type: 'object' as const,
description: 'Widget-formatted Actor info (tier-aware pricing, widget display fields).',
},
actorCard: { type: 'string', description: 'Rendered Actor card markdown for widget display.' },
readme: { type: 'string', description: 'Formatted Actor README for widget display.' },
},
required: ['actorInfo', 'actorCard', 'readme'],
additionalProperties: false,
},
},
required: ['actorDetails'],
additionalProperties: false,
};
/**
* Schema for search results output (store-search tool)
*/
export const actorSearchOutputSchema = {
type: 'object' as const,
properties: {
actors: {
type: 'array' as const,
items: actorInfoSchema,
description: 'List of Actor cards matching the search query',
},
query: { type: 'string', description: 'The search query used' },
count: { type: 'number', description: 'Number of Actors returned' },
userTier: {
type: 'string',
enum: ['FREE', 'BRONZE', 'SILVER', 'GOLD', 'PLATINUM', 'DIAMOND'],
description: "The user's plan tier used to resolve the per-Actor pricing shown in the results",
},
instructions: {
type: 'string',
description: 'Additional instructions for the LLM to follow when processing the search results.',
},
},
required: ['actors', 'query', 'count'],
};
/**
* Schema for widget search results (search-actors-widget tool).
* `actors` mirrors the non-widget `actorSearchOutputSchema` shape (StructuredActorCard),
* `widgetActors` is the widget-formatted list (from `formatActorForWidget`), kept loose
* for the same reason `actorDetailsWidgetOutputSchema.actorInfo` is loose.
*/
export const actorSearchWidgetOutputSchema = {
type: 'object' as const,
properties: {
actors: {
type: 'array' as const,
items: actorInfoSchema,
description: 'List of Actor cards matching the search query',
},
query: { type: 'string', description: 'The search query used' },
count: { type: 'number', description: 'Number of Actors returned' },
userTier: {
type: 'string',
enum: ['FREE', 'BRONZE', 'SILVER', 'GOLD', 'PLATINUM', 'DIAMOND'],
description: "The user's plan tier used to resolve the per-Actor pricing shown in the results",
},
widgetActors: {
type: 'array' as const,
items: {
type: 'object' as const,
description: 'Widget-formatted Actor (tier-aware pricing, widget display fields).',
},
description: 'Widget-formatted Actor list for UI rendering',
},
},
required: ['actors', 'query', 'count', 'widgetActors'],
};
export const searchApifyDocsToolOutputSchema = {
type: 'object' as const,
properties: {
results: {
type: 'array' as const,
items: {
type: 'object' as const,
properties: {
url: {
type: 'string',
description: 'URL of the documentation page, may include anchor (e.g., #section-name).',
},
content: {
type: 'string',
description: 'A limited piece of content that matches the search query.',
},
},
required: ['url'],
},
},
instructions: {
type: 'string',
description: 'Additional instructions for the LLM to follow when processing the search results.',
},
},
required: ['results'],
};
export const fetchApifyDocsToolOutputSchema = {
type: 'object' as const,
properties: {
url: { type: 'string', description: 'The documentation URL that was fetched' },
content: { type: 'string', description: 'The full markdown content of the documentation page' },
},
required: ['url', 'content'],
};
/**
* Schema for the fixed acknowledgement returned by report-problem.
*/
export const reportProblemToolOutputSchema = {
type: 'object' as const,
properties: {
reported: { type: 'boolean', description: 'Always true; the problem report was submitted' },
},
required: ['reported'],
};
/**
* Schema for get-actor-log. The log API returns plain text, so the schema wraps it in a single field.
*/
export const getActorRunLogToolOutputSchema = {
type: 'object' as const,
properties: {
log: { type: 'string', description: 'The last N lines of the run log, as plain text' },
},
required: ['log'],
};
// Per-storage entry shapes. Factories (not shared constants) because `structuredClone` preserves
// object identity: if `default` and `additionalProperties` referenced the same object, cloning
// `actorRunOutputSchema` would keep them as the same object, and injecting `itemsSchema` into
// `default` via `buildEnrichedDirectActorOutputSchema` would silently leak it into aliases too.
const buildDatasetEntrySchema = () => ({
type: 'object' as const,
properties: {
id: { type: 'string', description: 'Dataset ID' },
apifyConsoleUrl: {
type: 'string',
description: 'Personalized Apify Console link to the dataset; present only for Console sessions',
},
name: { type: 'string' },
title: { type: 'string' },
itemCount: { type: 'number' },
inflatedBytes: {
type: 'number',
description:
'Approximate uncompressed byte size of the dataset. Use with itemCount to pick limit/fields before fetching.',
},
fields: {
type: 'array' as const,
items: { type: 'string' },
description: 'Dataset field paths in dot notation (e.g. ["metadata.url"])',
},
},
required: ['id'],
});
const buildKeyValueStoreEntrySchema = () => ({
type: 'object' as const,
properties: {
id: { type: 'string', description: 'Key-value store ID' },
apifyConsoleUrl: {
type: 'string',
description: 'Personalized Apify Console link to the store; present only for Console sessions',
},
name: { type: 'string' },
title: { type: 'string' },
keyCount: { type: 'number', description: 'Total number of keys (omitted when truncated)' },
keys: {
type: 'array' as const,
items: { type: 'string' },
description: 'Up to 50 key names',
},
},
required: ['id'],
});
/** Schema for get-actor-run tool output. */
export const actorRunOutputSchema = {
type: 'object' as const,
properties: {
runId: { type: 'string', description: 'Actor run ID' },
apifyConsoleUrl: {
type: 'string',
description: 'Personalized Apify Console link to the run; present only for Console sessions',
},
actorId: { type: 'string', description: 'Stable Apify Actor ID from the run record' },
actorName: { type: 'string', description: '"username/actor-name"' },
status: {
type: 'string',
description:
'Run status: READY | RUNNING | TIMING-OUT | TIMED-OUT | ABORTING | ABORTED | SUCCEEDED | FAILED',
},
statusMessage: { type: 'string', description: 'Pass-through from Apify run.statusMessage' },
exitCode: {
type: 'number',
description: 'Actor process exit code; populated for terminal states (especially FAILED)',
},
startedAt: { type: 'string', description: 'ISO timestamp when the run started' },
finishedAt: { type: 'string', description: 'ISO timestamp when the run finished (terminal states only)' },
stats: {
type: 'object' as const,
description: 'Run statistics',
properties: {
runTimeSecs: { type: 'number' },
computeUnits: { type: 'number' },
memMaxBytes: { type: 'number' },
},
},
storages: {
type: 'object' as const,
// Alias-map shape mirrors ActorRunStorageIds from the Apify client.
// `datasets.default` / `keyValueStores.default` are the primary entries;
// named Actor storages (e.g. datasets.results) occupy additional alias keys.
description: 'Dataset and key-value store metadata, keyed by alias. "default" is always the primary entry.',
properties: {
datasets: {
type: 'object' as const,
description: 'Map of dataset alias → metadata. Key "default" is always the run\'s primary dataset.',
properties: {
default: buildDatasetEntrySchema(),
},
additionalProperties: buildDatasetEntrySchema(),
},
keyValueStores: {
type: 'object' as const,
description:
'Map of key-value store alias → metadata. Key "default" is always the run\'s primary store.',
properties: {
default: buildKeyValueStoreEntrySchema(),
},
additionalProperties: buildKeyValueStoreEntrySchema(),
},
},
},
summary: { type: 'string', description: 'Past-tense summary of the run state' },
nextStep: { type: 'string', description: 'One primary follow-up action with identifiers interpolated' },
},
required: ['runId', 'actorId', 'status', 'storages', 'summary', 'nextStep'],
};
/**
* Returns a per-tool clone of {@link actorRunOutputSchema} with `storages.datasets.default.itemsSchema`
* declared as a JSON Schema describing each dataset row, inferred from historical successful runs.
*
* Used for direct actor tools (e.g. `apify--rag-web-browser`) where the target Actor is known
* at `tools/list` time, so the LLM can plan field projection before calling the tool. The same
* shape is injected into `structuredContent.storages.datasets.default.itemsSchema` by the direct
* actor executors so the declared schema matches the runtime response.
*
* `call-actor` and `get-actor-run` cannot use this because their target Actor is dynamic.
*
* @param itemProperties - JSON Schema properties for dataset item fields
* (e.g. `{ url: { type: 'string' }, price: { type: 'number' } }`).
*/
export function buildEnrichedDirectActorOutputSchema(itemProperties: Record<string, unknown>) {
const itemsSchema = {
type: 'object' as const,
description:
'JSON Schema for rows in the dataset at `storages.datasets.default.id` — describes row ' +
'shape only; the rows themselves are NOT returned inline in this response. Inferred from this ' +
"Actor's historical successful runs. To fetch actual rows, call `get-dataset-items` with the " +
'dataset id and a `fields` projection drawn from this schema.',
properties: itemProperties,
};
const clone = structuredClone(actorRunOutputSchema);
const datasetDefaultProps = clone.properties.storages.properties.datasets.properties.default.properties as Record<
string,
unknown
>;
datasetDefaultProps.itemsSchema = itemsSchema;
return clone;
}
/** Past-tense state summary; emitted by every storage tool. */
export const summaryProperty = {
type: 'string' as const,
description: 'Summary of the result',
};
/** One primary follow-up action; emitted by every non-terminal storage tool. */
export const nextStepProperty = {
type: 'string' as const,
description: 'One follow-up action with tool name',
};
/**
* Builds the Apify `PaginatedList` envelope schema (offset-based pagination) shared by the
* run and storage list tools. `itemsSchema` describes one array element; mirrors `PaginatedList`
* from apify-client (api.apify.com `*-get` collection endpoints).
*/
function paginatedListOutputSchema(itemsSchema: object, itemsDescription: string) {
return {
type: 'object' as const,
properties: {
total: { type: 'number', description: 'Total number of items across all pages.' },
count: { type: 'number', description: 'Number of items returned in this page.' },
offset: { type: 'number', description: 'Number of items skipped from the start.' },
limit: { type: 'number', description: 'Maximum number of items requested.' },
desc: { type: 'boolean', description: 'Whether items are sorted in descending order.' },
items: { type: 'array' as const, items: itemsSchema, description: itemsDescription },
},
required: ['total', 'offset', 'limit', 'count', 'items'],
};
}
/** Schema for one run in get-actor-run-list (apify-client `ActorRunListItem`). */
const actorRunListItemSchema = {
type: 'object' as const,
properties: {
id: { type: 'string', description: 'Run ID.' },
actId: { type: 'string', description: 'ID of the Actor that produced the run.' },
actorTaskId: { type: 'string', description: 'ID of the Actor task, when the run was started from one.' },
status: {
type: 'string',
description:
'Run status: READY | RUNNING | SUCCEEDED | FAILED | TIMING-OUT | TIMED-OUT | ABORTING | ABORTED.',
},
startedAt: { type: ['string', 'null'], description: 'ISO timestamp when the run started.' },
finishedAt: {
type: ['string', 'null'],
description: 'ISO timestamp when the run finished; null while still running.',
},
buildId: { type: 'string', description: 'ID of the Actor build used for the run.' },
buildNumber: { type: 'string', description: 'Build number used for the run.' },
defaultDatasetId: { type: 'string', description: "ID of the run's default dataset." },
defaultKeyValueStoreId: { type: 'string', description: "ID of the run's default key-value store." },
defaultRequestQueueId: { type: 'string', description: "ID of the run's default request queue." },
usageTotalUsd: { type: 'number', description: 'Total run cost in USD.' },
},
required: ['id', 'actId', 'status', 'defaultDatasetId', 'defaultKeyValueStoreId'],
};
/** Schema for get-actor-run-list output (paginated list of runs). */
export const actorRunListOutputSchema = paginatedListOutputSchema(actorRunListItemSchema, 'Actor runs.');
/**
* Schema for dataset items retrieval tools (get-dataset-items).
* Contains dataset items with pagination and count information.
*/
export const datasetItemsOutputSchema = {
type: 'object' as const,
properties: {
datasetId: { type: 'string', description: 'Dataset ID' },
apifyConsoleUrl: {
type: 'string',
description: 'Personalized Apify Console link to the dataset; present only for Console sessions',
},
items: { type: 'array' as const, items: { type: 'object' as const }, description: 'Dataset items' },
itemCount: { type: 'number', description: 'Number of items returned' },
totalItemCount: { type: 'number', description: 'Total items in dataset' },
offset: { type: 'number', description: 'Offset used for pagination' },
limit: { type: 'number', description: 'Limit used for pagination' },
summary: summaryProperty,
nextStep: nextStepProperty,
},
// offset/limit/totalItemCount and summary/nextStep are always emitted by the tool.
required: ['datasetId', 'items', 'itemCount', 'totalItemCount', 'offset', 'limit', 'summary', 'nextStep'],
};
/**
* Schema for dataset metadata (get-dataset). Documents the fields the LLM acts on; the raw API
* response carries more keys (stats, access settings), allowed as additional properties.
* The raw `schema` key is stripped by the tool — get-dataset-schema owns schema output (#882).
*/
export const datasetMetadataOutputSchema = {
type: 'object' as const,
properties: {
id: { type: 'string', description: 'Dataset ID' },
name: { type: ['string', 'null'], description: 'Dataset name (null for unnamed datasets)' },
itemCount: { type: 'number', description: 'Number of items in the dataset' },
fields: {
type: 'array' as const,
items: { type: 'string' },
description: 'Field paths in dot notation (e.g. ["metadata.url"])',
},
summary: summaryProperty,
nextStep: nextStepProperty,
},
required: ['id', 'summary', 'nextStep'],
};
/**
* Schema for dataset schema inference (get-dataset-schema).
*/
export const datasetSchemaOutputSchema = {
type: 'object' as const,
properties: {
datasetId: { type: 'string', description: 'Dataset ID' },
schema: { type: 'object' as const, description: 'Inferred JSON schema describing dataset item structure' },
summary: summaryProperty,
nextStep: nextStepProperty,
},
required: ['datasetId', 'schema', 'summary', 'nextStep'],
};
/**
* Schema for storage collection listings (get-dataset-list, get-key-value-store-list).
* Mirrors the Apify paginated-list response shape plus the narrative fields. `items` is an opaque
* object since item shape varies by storage type; per-item fields pass through from the API.
*/
export const storageListOutputSchema = {
type: 'object' as const,
properties: {
total: { type: 'number', description: 'Total number of items available for the user' },
count: { type: 'number', description: 'Number of items returned in this page' },
offset: { type: 'number', description: 'Offset used for pagination' },
limit: { type: 'number', description: 'Limit used for pagination' },
items: {
type: 'array' as const,
items: { type: 'object' as const },
description: 'Storage metadata objects',
},
summary: summaryProperty,
nextStep: nextStepProperty,
},
required: ['items', 'total', 'count', 'offset', 'limit', 'summary', 'nextStep'],
};
/**
* Schema for key-value store metadata (get-key-value-store). The raw API response carries more
* keys (stats, access settings), allowed as additional properties.
*/
export const keyValueStoreOutputSchema = {
type: 'object' as const,
properties: {
id: { type: 'string', description: 'Key-value store ID' },
name: { type: ['string', 'null'], description: 'Store name (null for unnamed stores)' },
summary: summaryProperty,
nextStep: nextStepProperty,
},
required: ['id', 'summary', 'nextStep'],
};
/**
* Schema for key listing (get-key-value-store-keys).
*/
export const keyValueStoreKeysOutputSchema = {
type: 'object' as const,
properties: {
keyValueStoreId: { type: 'string', description: 'Key-value store ID' },
items: {
type: 'array' as const,
items: {
type: 'object' as const,
properties: {
key: { type: 'string', description: 'Record key' },
size: { type: 'number', description: 'Value size in bytes' },
},
required: ['key', 'size'],
},
description: 'Keys with value sizes',
},
count: { type: 'number', description: 'Number of keys returned' },
isTruncated: { type: 'boolean', description: 'Whether more keys are available' },
nextExclusiveStartKey: {
type: ['string', 'null'],
description: 'Pass as exclusiveStartKey to fetch the next page of keys; null when not truncated',
},
summary: summaryProperty,
nextStep: nextStepProperty,
},
required: ['keyValueStoreId', 'items', 'count', 'isTruncated', 'nextExclusiveStartKey', 'summary', 'nextStep'],
};
/**
* Schema for a single record (get-key-value-store-record). Terminal: no nextStep.
*/
export const keyValueStoreRecordOutputSchema = {
type: 'object' as const,
properties: {
keyValueStoreId: { type: 'string', description: 'Key-value store ID' },
key: { type: 'string', description: 'Record key' },
value: { description: 'The stored value (JSON, text, or binary)' },
contentType: { type: 'string', description: 'MIME type of the stored value' },
summary: summaryProperty,
},
required: ['keyValueStoreId', 'key', 'value', 'summary'],
};