primitive-admin 1.1.0 → 1.2.0-alpha.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 (62) hide show
  1. package/README.md +11 -11
  2. package/assets/skill/skills/primitive-platform/SKILL.md +6 -0
  3. package/dist/src/commands/collections.js +20 -17
  4. package/dist/src/commands/collections.js.map +1 -1
  5. package/dist/src/commands/database-types.js +13 -313
  6. package/dist/src/commands/database-types.js.map +1 -1
  7. package/dist/src/commands/databases.js +0 -19
  8. package/dist/src/commands/databases.js.map +1 -1
  9. package/dist/src/commands/groups.js +16 -0
  10. package/dist/src/commands/groups.js.map +1 -1
  11. package/dist/src/commands/llm.js +9 -6
  12. package/dist/src/commands/llm.js.map +1 -1
  13. package/dist/src/commands/settings.d.ts +18 -0
  14. package/dist/src/commands/settings.js +54 -0
  15. package/dist/src/commands/settings.js.map +1 -0
  16. package/dist/src/commands/sync.d.ts +1 -4
  17. package/dist/src/commands/sync.js +42 -45
  18. package/dist/src/commands/sync.js.map +1 -1
  19. package/dist/src/commands/workflows.js +3 -3
  20. package/dist/src/commands/workflows.js.map +1 -1
  21. package/dist/src/lib/api-client.d.ts +3 -40
  22. package/dist/src/lib/api-client.js +20 -69
  23. package/dist/src/lib/api-client.js.map +1 -1
  24. package/dist/src/lib/app-match-guard.d.ts +44 -0
  25. package/dist/src/lib/app-match-guard.js +72 -0
  26. package/dist/src/lib/app-match-guard.js.map +1 -0
  27. package/dist/src/lib/collection-export.d.ts +37 -9
  28. package/dist/src/lib/collection-export.js +48 -12
  29. package/dist/src/lib/collection-export.js.map +1 -1
  30. package/dist/src/lib/function-triggers.d.ts +66 -0
  31. package/dist/src/lib/function-triggers.js +285 -0
  32. package/dist/src/lib/function-triggers.js.map +1 -0
  33. package/dist/src/lib/generated-allowlist.js +0 -1
  34. package/dist/src/lib/generated-allowlist.js.map +1 -1
  35. package/dist/src/lib/generated-config-surfaces.js +56 -32
  36. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  37. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  38. package/dist/src/lib/generated-sdk-types.js +1 -1
  39. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  40. package/dist/src/lib/generated-workflow-model-fields.d.ts +20 -0
  41. package/dist/src/lib/generated-workflow-model-fields.js +53 -0
  42. package/dist/src/lib/generated-workflow-model-fields.js.map +1 -0
  43. package/dist/src/lib/google-client-secret-status.d.ts +35 -0
  44. package/dist/src/lib/google-client-secret-status.js +56 -0
  45. package/dist/src/lib/google-client-secret-status.js.map +1 -0
  46. package/dist/src/lib/log-inspection.d.ts +1 -6
  47. package/dist/src/lib/log-inspection.js +5 -7
  48. package/dist/src/lib/log-inspection.js.map +1 -1
  49. package/dist/src/lib/migration-nag.d.ts +2 -2
  50. package/dist/src/lib/migration-nag.js +4 -3
  51. package/dist/src/lib/migration-nag.js.map +1 -1
  52. package/dist/src/lib/paginate.d.ts +8 -24
  53. package/dist/src/lib/paginate.js +8 -21
  54. package/dist/src/lib/paginate.js.map +1 -1
  55. package/dist/src/lib/sync-dir-selector.d.ts +1 -1
  56. package/dist/src/lib/sync-dir-selector.js +1 -1
  57. package/dist/src/lib/toml-database-config.js +2 -2
  58. package/dist/src/lib/toml-database-config.js.map +1 -1
  59. package/dist/src/lib/workflow-field-descriptor.d.ts +91 -0
  60. package/dist/src/lib/workflow-field-descriptor.js +153 -0
  61. package/dist/src/lib/workflow-field-descriptor.js.map +1 -0
  62. package/package.json +2 -2
@@ -9,4 +9,4 @@
9
9
  * Regenerate with:
10
10
  * node cli/scripts/gen-sdk-types.mjs
11
11
  */
12
- export declare const SDK_TYPES_SOURCE = "// GENERATED by scripts/generate-function-profile.mjs from openapi.json.\n// DO NOT EDIT. Run `pnpm functions:profile` and commit the result; the\n// freshness guard in tests/api/spec/function-profile.test.ts fails when this\n// file and a fresh generation diverge.\n\n/**\n * Type surface of `primitive-functions` \u2014 what a server function's author writes\n * against (#3180). The published package's RUNTIME is a stub that throws from\n * every export on purpose: the platform substitutes its own copy at invoke\n * time, and reaching the stub means it did not.\n */\n\n/**\n * The signed-in user who invoked the function over HTTP.\n *\n * Attribution, never authority (#3279): function code acts as the system\n * whoever called it, so this says WHO asked, and the rows the function writes\n * are attributed to them. A trigger fire has no caller and `ctx.user` is\n * null.\n */\nexport interface FunctionUser {\n userId: string;\n email: string | null;\n}\n\n/**\n * What started this invocation. Narrow on `kind`.\n *\n * The same union the runtime builds (`src/server-functions/trigger-descriptor.ts`),\n * held identical by `tests/api/spec/function-trigger-declarations-3281.test.ts`:\n * a field the fire path sets is declared here, and nothing is declared here\n * that the fire path does not set.\n */\nexport type FunctionTrigger =\n /**\n * An HTTP invocation: the caller is `ctx.user`.\n *\n * `runKey` is the key a `start` was coalesced by (#3562) \u2014 what you\n * passed as `runKey` to make the run a singleton \u2014 and null when the\n * start named none, or when the call was an `invoke`, which coalesces\n * nothing.\n */\n | { kind: \"http\"; runKey: string | null }\n /** A verified webhook delivery to the function's own key. */\n | {\n kind: \"webhook\";\n /** The webhook key, which is the function key. */\n webhookKey: string;\n /** The platform's webhook row the delivery log lives under. */\n webhookId: string;\n /** The provider's event id (`X-Webhook-Event-Id`), when it sent one. */\n externalEventId: string | null;\n }\n /** A cron entry firing, scheduled or from the `cron-triggers test` diagnostic. */\n | {\n kind: \"cron\";\n /** The `[[function.triggers.cron]]` entry's `name`. */\n name: string;\n /** The platform's cron row. */\n triggerId: string;\n /** ISO 8601. The instant the fire was scheduled for; a diagnostic fire's is \"now\". */\n scheduledFor: string;\n /** Present, and true, only on the diagnostic fire: nothing was scheduled. */\n manual?: true;\n }\n /**\n * A DSL workflow's `workflow.call` step reached this function (#3288).\n *\n * TRANSITIONAL: the bridge exists so a workflow tree can migrate leaf-first\n * during the transition, and it retires with the workflow engine in phase 7,\n * taking this variant with it. `workflowKey` names the PARENT workflow, and\n * `runId`/`stepId` locate the step inside its run.\n */\n | { kind: \"workflow\"; workflowKey: string; runId: string; stepId: string }\n /**\n * Another function started this one with `ctx.functions.start` (#3280).\n *\n * `functionKey` names the PARENT, and `runId` its run \u2014 null when the\n * parent was a request invocation over HTTP, which writes no run row.\n * `runKey` is the key the parent's start named, or null (#3562).\n */\n | {\n kind: \"function\";\n functionKey: string;\n runId: string | null;\n runKey: string | null;\n }\n /**\n * An admin ran this function as the SYSTEM, from outside any trigger\n * (#3448) \u2014 `primitive functions invoke --as system`.\n *\n * `ctx.user` is null and the code runs with the app's system authority, as\n * it does for a cron or webhook fire. `userId` names the admin who asked:\n * attribution, never the principal the code runs as. `runKey` is the key\n * the admin's start named, or null (#3562).\n */\n | { kind: \"manual\"; userId: string; runKey: string | null };\n\n/** The result shape of an operation that answers in response headers. */\nexport interface HeaderResult {\n status: number;\n headers: Record<string, string>;\n}\n\n/**\n * A platform call that was refused. `errorCode` carries the gateway's own\n * codes (`FUNCTION_ROUTE_NOT_ALLOWED`, `FUNCTION_EGRESS_DENIED`, \u2026) as well\n * as the route's.\n */\nexport interface PrimitivePlatformError extends Error {\n status: number;\n errorCode: string | null;\n}\n\n/**\n * The typed HTTP profile, generated from the platform's OpenAPI document. Its\n * namespaces mirror the operation ids: analytics, blobBuckets, channels, collections, configVars, connections, databaseTypeConfigs, databases, documents, email, functions, groups, integrations, locks, notifications, prompts, resourceMetadata, secrets, users.\n * Methods take one options object carrying the operation's path parameters,\n * query parameters, request headers (under their wire names) and `body`.\n *\n * Generated from the same operations as the runtime profile, so a method that\n * type-checks is a method the platform publishes \u2014 and a missing path\n * parameter or a missing required header is a compile error rather than a\n * `TypeError` at invoke time. Every call runs with the app's own SYSTEM\n * authority (#3279): the invocation gate was the authorization. The two\n * namespaces the gateway does not admit are still declared: they exist, they\n * answer the gateway's structured denial, and hiding them would make a route's\n * availability look like a typo. Those are `databaseTypeConfigs` whole, and\n * `functions` except for `functions.start` \u2014 the nested-start door #3280\n * admits by name, which `ctx.functions.start` calls. `functions.invoke`\n * stays refused: same-run composition is an import.\n */\nexport interface FunctionApi {\n \"analytics\": {\n /** `analytics.cohortRetention` \u2014 GET /analytics/cohort-retention. Cohort retention metrics */\n \"cohortRetention\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.dailyActive` \u2014 GET /analytics/daily-active. Daily active user time series */\n \"dailyActive\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.errorGroups` \u2014 GET /analytics/errors/groups. Group failure events by fingerprint with per-day count buckets */\n \"errorGroups\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.integrationUsage` \u2014 GET /analytics/integrations. Integration usage metrics */\n \"integrationUsage\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.listEvents` \u2014 GET /analytics/events. List analytics events */\n \"listEvents\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"page\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.listEventsGrouped` \u2014 GET /analytics/events/grouped. List analytics events grouped by dimension */\n \"listEventsGrouped\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"groupBy\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.overviewDau` \u2014 GET /analytics/overview/dau. Daily active users overview */\n \"overviewDau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewGrowth` \u2014 GET /analytics/overview/growth. User growth overview */\n \"overviewGrowth\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewMau` \u2014 GET /analytics/overview/mau. Monthly active users overview */\n \"overviewMau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewWau` \u2014 GET /analytics/overview/wau. Weekly active users overview */\n \"overviewWau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.rollingActive` \u2014 GET /analytics/rolling-active. Rolling active user time series */\n \"rollingActive\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.searchUsers` \u2014 GET /analytics/users/search. Search app users for analytics */\n \"searchUsers\"(args?: {\n \"q\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"signupDay\"?: string | number | boolean;\n \"signupStartDay\"?: string | number | boolean;\n \"signupEndDay\"?: string | number | boolean;\n \"offset\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topPrompts` \u2014 GET /analytics/prompts/top. List the most-executed prompts */\n \"topPrompts\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topUsers` \u2014 GET /analytics/users/top. List the most active users */\n \"topUsers\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topWorkflows` \u2014 GET /analytics/workflows/top. List the most-run workflows */\n \"topWorkflows\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.userDetail` \u2014 GET /analytics/users/{userUlid}/detail. Detailed analytics for a single user */\n \"userDetail\"(args: {\n \"userUlid\": string | number;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.userSnapshot` \u2014 GET /analytics/users/{userUlid}/snapshot. Activity snapshot for a single user */\n \"userSnapshot\"(args: {\n \"userUlid\": string | number;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.writeForUser` \u2014 POST /analytics/write-for-user. Write an analytics event for a subject user under a grant */\n \"writeForUser\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"blobBuckets\": {\n /** `blobBuckets.createBucket` \u2014 POST /blob-buckets. Create a blob bucket */\n \"createBucket\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.delete` \u2014 DELETE /blob-buckets/{bucketId}/blobs/{blobId}. Delete a blob */\n \"delete\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.deleteBatch` \u2014 POST /blob-buckets/{bucketId}/blobs/delete. Batch delete blobs from a bucket */\n \"deleteBatch\"(args: {\n \"bucketId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.deleteBucket` \u2014 DELETE /blob-buckets/{bucketId}. Delete a blob bucket */\n \"deleteBucket\"(args: {\n \"bucketId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.download` \u2014 GET /blob-buckets/{bucketId}/blobs/{blobId}. Download a blob (anonymous allowed for public buckets) */\n \"download\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n \"disposition\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `blobBuckets.downloadSigned` \u2014 GET /blob-buckets/{bucketId}/blobs/{blobId}/signed. Download a blob via a signed URL token */\n \"downloadSigned\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n \"token\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `blobBuckets.getBucket` \u2014 GET /blob-buckets/{bucketId}. Get a blob bucket by id */\n \"getBucket\"(args: {\n \"bucketId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.getMetadata` \u2014 GET /blob-buckets/{bucketId}/blobs/{blobId}/metadata. Get blob metadata (anonymous allowed for public buckets) */\n \"getMetadata\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.getSignedUrl` \u2014 POST /blob-buckets/{bucketId}/blobs/{blobId}/signed-url. Create a signed download URL for a blob */\n \"getSignedUrl\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `blobBuckets.list` \u2014 GET /blob-buckets/{bucketId}/blobs. List blobs in a bucket (anonymous allowed for public buckets) */\n \"list\"(args: {\n \"bucketId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `blobBuckets.listBuckets` \u2014 GET /blob-buckets. List blob buckets */\n \"listBuckets\"(args?: Record<string, never>): Promise<any>;\n /** `blobBuckets.updateBucket` \u2014 PATCH /blob-buckets/{bucketId}. Update a blob bucket */\n \"updateBucket\"(args: {\n \"bucketId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.upload` \u2014 POST /blob-buckets/{bucketId}/blobs. Upload a blob to a bucket */\n \"upload\"(args: {\n \"bucketId\": string | number;\n \"X-Blob-Filename\": string | number;\n \"X-Blob-Tags\"?: string | number;\n \"Content-Type\"?: string | number;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n };\n \"channels\": {\n /** `channels.authorize` \u2014 POST /channels/{channel}/grants. Issue a channel grant under a server function's grant */\n \"authorize\"(args: {\n \"channel\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `channels.publish` \u2014 POST /channels/{channel}/publish. Publish a message to a channel under a server function's grant */\n \"publish\"(args: {\n \"channel\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"collections\": {\n /** `collections.addDocument` \u2014 POST /collections/{collectionId}/documents. Add a document to a collection */\n \"addDocument\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.addMember` \u2014 POST /collections/{collectionId}/members. Add a member to a collection */\n \"addMember\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.create` \u2014 POST /collections. Create a collection */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `collections.delete` \u2014 DELETE /collections/{collectionId}. Delete a collection */\n \"delete\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.get` \u2014 GET /collections/{collectionId}. Get a collection by id */\n \"get\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.getAccess` \u2014 GET /collections/{collectionId}/access. Get a collection's access summary */\n \"getAccess\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.grantGroupPermission` \u2014 POST /collections/{collectionId}/group-permissions. Grant a group permission on a collection */\n \"grantGroupPermission\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.list` \u2014 GET /collections. List collections */\n \"list\"(args?: {\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listCollectionsForDocument` \u2014 GET /documents/{documentId}/collections. List collections a document belongs to (reverse lookup) */\n \"listCollectionsForDocument\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listDocuments` \u2014 GET /collections/{collectionId}/documents. List documents in a collection */\n \"listDocuments\"(args: {\n \"collectionId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listPendingInvitations` \u2014 GET /collections/{collectionId}/pending-invitations. List a collection's pending invitations */\n \"listPendingInvitations\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.removeDocument` \u2014 DELETE /collections/{collectionId}/documents/{documentId}. Remove a document from a collection */\n \"removeDocument\"(args: {\n \"collectionId\": string | number;\n \"documentId\": string | number;\n }): Promise<any>;\n /** `collections.removeMember` \u2014 DELETE /collections/{collectionId}/members/{userId}. Remove a member from a collection */\n \"removeMember\"(args: {\n \"collectionId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `collections.revokeGroupPermission` \u2014 DELETE /collections/{collectionId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a collection */\n \"revokeGroupPermission\"(args: {\n \"collectionId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `collections.update` \u2014 PATCH /collections/{collectionId}. Update a collection */\n \"update\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"configVars\": {\n /** `configVars.get` \u2014 GET /config-vars/{name}. Read an app config var under a server function's grants */\n \"get\"(args: {\n \"name\": string | number;\n }): Promise<any>;\n };\n \"connections\": {\n /** `connections.send` \u2014 POST /connections/{connectionId}/send. Send a realtime message to one connection of this app */\n \"send\"(args: {\n \"connectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"databaseTypeConfigs\": {\n /** `databaseTypeConfigs.create` \u2014 POST /databases/types. Create a database type */\n \"create\"(args: {\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.createOperation` \u2014 POST /databases/types/{databaseType}/operations. Create an operation for a database type */\n \"createOperation\"(args: {\n \"databaseType\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.delete` \u2014 DELETE /databases/types/{databaseType}. Delete a database type */\n \"delete\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.deleteOperation` \u2014 DELETE /databases/types/{databaseType}/operations/{name}. Delete an operation for a database type */\n \"deleteOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.get` \u2014 GET /databases/types/{databaseType}. Get a database type */\n \"get\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.getOperation` \u2014 GET /databases/types/{databaseType}/operations/{name}. Get an operation for a database type */\n \"getOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.getReindexStatus` \u2014 GET /databases/types/{databaseType}/reindex-status. Status of the index back-provision fan-out for a type */\n \"getReindexStatus\"(args: {\n \"databaseType\": string | number;\n \"runId\"?: string | number | boolean;\n }): Promise<any>;\n /** `databaseTypeConfigs.list` \u2014 GET /databases/types. List database types */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `databaseTypeConfigs.listOperations` \u2014 GET /databases/types/{databaseType}/operations. List operations for a database type */\n \"listOperations\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.scaffoldSchema` \u2014 POST /databases/types/{databaseType}/schema:scaffold. Scaffold a starter schema for a database type */\n \"scaffoldSchema\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n \"subscriptions\": {\n /** `databaseTypeConfigs.subscriptions.create` \u2014 POST /databases/types/{databaseType}/subscriptions. Create a subscription for a database type */\n \"create\"(args: {\n \"databaseType\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.delete` \u2014 DELETE /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Delete a database type subscription */\n \"delete\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.get` \u2014 GET /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Get a database type subscription */\n \"get\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.list` \u2014 GET /databases/types/{databaseType}/subscriptions. List subscriptions for a database type */\n \"list\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.update` \u2014 PUT /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Update a database type subscription */\n \"update\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databaseTypeConfigs.update` \u2014 PATCH /databases/types/{databaseType}. Update a database type */\n \"update\"(args: {\n \"databaseType\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.updateOperation` \u2014 PATCH /databases/types/{databaseType}/operations/{name}. Update an operation for a database type */\n \"updateOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n };\n \"databases\": {\n /** `databases.addManager` \u2014 PUT /databases/{databaseId}/permissions. Set a user's database permission */\n \"addManager\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n \"adminData\": {\n /**\n * `databases.adminData.batch` \u2014 POST /databases/{databaseId}/admin-data/batch. DEPRECATED \u2014 direct database batch; use databases/{databaseId}/records/batch\n * @deprecated Use databases/{databaseId}/records/batch\n */\n \"batch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.count` \u2014 POST /databases/{databaseId}/admin-data/count. DEPRECATED \u2014 direct database count; use databases/{databaseId}/records/count\n * @deprecated Use databases/{databaseId}/records/count\n */\n \"count\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.delete` \u2014 POST /databases/{databaseId}/admin-data/delete. DEPRECATED \u2014 direct database delete; use databases/{databaseId}/records/delete\n * @deprecated Use databases/{databaseId}/records/delete\n */\n \"delete\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.patch` \u2014 POST /databases/{databaseId}/admin-data/patch. DEPRECATED \u2014 direct database patch; use databases/{databaseId}/records/patch\n * @deprecated Use databases/{databaseId}/records/patch\n */\n \"patch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.query` \u2014 POST /databases/{databaseId}/admin-data/query. DEPRECATED \u2014 direct database query; use databases/{databaseId}/records/query\n * @deprecated Use databases/{databaseId}/records/query\n */\n \"query\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.save` \u2014 POST /databases/{databaseId}/admin-data/save. DEPRECATED \u2014 direct database save; use databases/{databaseId}/records/save\n * @deprecated Use databases/{databaseId}/records/save\n */\n \"save\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databases.create` \u2014 POST /databases. Create a database */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `databases.delete` \u2014 DELETE /databases/{databaseId}. Delete a database */\n \"delete\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.executeBatch` \u2014 POST /databases/{databaseId}/operations/{name}/batch. Execute a database operation in batch */\n \"executeBatch\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.executeOperation` \u2014 POST /databases/{databaseId}/operations/{name}/execute. Execute a database operation */\n \"executeOperation\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n \"dryRun\"?: string | number | boolean;\n body?: unknown;\n }): Promise<any>;\n /** `databases.get` \u2014 GET /databases/{databaseId}. Get a database by id */\n \"get\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /**\n * `databases.getMetadata` \u2014 GET /databases/{databaseId}/metadata. DEPRECATED \u2014 get database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)\n * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)\n */\n \"getMetadata\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.grantGroupPermission` \u2014 POST /databases/{databaseId}/group-permissions. Grant a group permission on a database */\n \"grantGroupPermission\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.importBulk` \u2014 POST /databases/{databaseId}/operations/{name}/import-bulk. Bulk-import records via a database operation */\n \"importBulk\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.list` \u2014 GET /databases. List databases */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `databases.listGroupPermissions` \u2014 GET /databases/{databaseId}/group-permissions. List a database's group permissions */\n \"listGroupPermissions\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.listOperations` \u2014 GET /databases/{databaseId}/operations. List operations runnable on a database */\n \"listOperations\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.listPermissions` \u2014 GET /databases/{databaseId}/permissions. List a database's user permissions */\n \"listPermissions\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n \"records\": {\n /** `databases.records.addToSet` \u2014 POST /databases/{databaseId}/records/stringset/add. Database records: stringset/add (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"addToSet\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.aggregate` \u2014 POST /databases/{databaseId}/records/aggregate. Database records: aggregate (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"aggregate\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.batch` \u2014 POST /databases/{databaseId}/records/batch. Database records: batch (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"batch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.count` \u2014 POST /databases/{databaseId}/records/count. Database records: count (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"count\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.delete` \u2014 POST /databases/{databaseId}/records/delete. Database records: delete (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"delete\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.describe` \u2014 GET /databases/{databaseId}/records/describe. Database records: describe (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"describe\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.dropIndex` \u2014 POST /databases/{databaseId}/records/index/drop. Database records: index/drop (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"dropIndex\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.dropUniqueConstraint` \u2014 POST /databases/{databaseId}/records/unique-constraint/drop. Database records: unique-constraint/drop (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"dropUniqueConstraint\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.increment` \u2014 POST /databases/{databaseId}/records/increment. Database records: increment (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"increment\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.listIndexes` \u2014 GET /databases/{databaseId}/records/indexes. Database records: indexes (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"listIndexes\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.listUniqueConstraints` \u2014 GET /databases/{databaseId}/records/unique-constraints. Database records: unique-constraints (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"listUniqueConstraints\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.models` \u2014 GET /databases/{databaseId}/records/models. Database records: models (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"models\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.patch` \u2014 POST /databases/{databaseId}/records/patch. Database records: patch (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"patch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.query` \u2014 POST /databases/{databaseId}/records/query. Database records: query (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"query\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<{ items: any[]; hasMore: boolean; nextCursor?: string; prevCursor?: string }>;\n /** `databases.records.registerIndex` \u2014 POST /databases/{databaseId}/records/index/register. Database records: index/register (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"registerIndex\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.registerUniqueConstraint` \u2014 POST /databases/{databaseId}/records/unique-constraint/register. Database records: unique-constraint/register (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"registerUniqueConstraint\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.removeFromSet` \u2014 POST /databases/{databaseId}/records/stringset/remove. Database records: stringset/remove (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"removeFromSet\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.save` \u2014 POST /databases/{databaseId}/records/save. Database records: save (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"save\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.syncIndexes` \u2014 POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"syncIndexes\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databases.reindex` \u2014 POST /databases/{databaseId}/reindex. Reindex a database */\n \"reindex\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.revokeGroupPermission` \u2014 DELETE /databases/{databaseId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a database */\n \"revokeGroupPermission\"(args: {\n \"databaseId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `databases.revokePermission` \u2014 DELETE /databases/{databaseId}/permissions/{userId}. Remove a user's database permission */\n \"revokePermission\"(args: {\n \"databaseId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `databases.runOperation` \u2014 POST /databases/{databaseId}/operations/{name}/run. Run a database operation under a server function's grants */\n \"runOperation\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `databases.transferOwnership` \u2014 POST /databases/{databaseId}/permissions/transfer. Transfer database ownership */\n \"transferOwnership\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.update` \u2014 PATCH /databases/{databaseId}. Update a database */\n \"update\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.updateMetadata` \u2014 PATCH /databases/{databaseId}/metadata. DEPRECATED \u2014 update database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)\n * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)\n */\n \"updateMetadata\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"documents\": {\n /** `documents.abortIngest` \u2014 POST /documents/{documentId}/ingest/{sessionId}/abort. Abort a bulk-load session before its swap */\n \"abortIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.addTag` \u2014 POST /documents/{documentId}/tags. Add a tag to a document */\n \"addTag\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n \"aliases\": {\n /** `documents.aliases.delete` \u2014 DELETE /document-aliases/{scope}/{aliasKey}. Delete a (scope, aliasKey) document alias binding */\n \"delete\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n \"userId\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.aliases.listForDocument` \u2014 GET /documents/{documentId}/aliases. List aliases bound to a document */\n \"listForDocument\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.aliases.resolve` \u2014 GET /document-aliases/{scope}/{aliasKey}. Resolve the document bound to a (scope, aliasKey) alias */\n \"resolve\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n \"userId\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.aliases.set` \u2014 PUT /document-aliases/{scope}/{aliasKey}. Bind a (scope, aliasKey) alias to a document */\n \"set\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `documents.approveAccessRequest` \u2014 POST /documents/{documentId}/access-requests/{requestId}/approve. Approve a document access request */\n \"approveAccessRequest\"(args: {\n \"documentId\": string | number;\n \"requestId\": string | number;\n body?: unknown;\n }): Promise<any>;\n \"blobs\": {\n /** `documents.blobs.delete` \u2014 DELETE /documents/{documentId}/blobs/{blobId}. Delete a document blob */\n \"delete\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.downloadHeaders` \u2014 HEAD /documents/{documentId}/blobs/{blobId}/download. Get document blob download headers (ETag/304 support) */\n \"downloadHeaders\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<HeaderResult>;\n /** `documents.blobs.downloadUrl` \u2014 GET /documents/{documentId}/blobs/{blobId}/download. Download a document blob's bytes */\n \"downloadUrl\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n \"disposition\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `documents.blobs.get` \u2014 GET /documents/{documentId}/blobs/{blobId}. Get a document blob's metadata */\n \"get\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.list` \u2014 GET /documents/{documentId}/blobs. List blobs attached to a document */\n \"list\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.upload` \u2014 PUT /documents/{documentId}/blobs/{blobId}. Upload a document blob with a client-specified id (immutable + idempotent) */\n \"upload\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n \"X-Blob-Filename\": string | number;\n \"X-Blob-Size\": string | number;\n \"X-Blob-Sha256\": string | number;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /**\n * `documents.blobs.uploadWithoutId` \u2014 PUT /documents/{documentId}/blobs. Deprecated: upload a document blob without a client-specified id\n * @deprecated Deprecated in the app API spec; see its description.\n */\n \"uploadWithoutId\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n };\n /** `documents.clearLinkAccess` \u2014 DELETE /documents/{documentId}/link-access. Turn off the document's link access */\n \"clearLinkAccess\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.commitIngest` \u2014 POST /documents/{documentId}/ingest/{sessionId}/commit. Commit a bulk-load session: freeze its manifest and apply it */\n \"commitIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.create` \u2014 POST /documents. Create a new document */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.createIngest` \u2014 POST /documents/{documentId}/ingest. Open a bulk-load session on a large document */\n \"createIngest\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.createWithAlias` \u2014 POST /documents/create-with-alias. Create a document and bind it to an alias */\n \"createWithAlias\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.debugDumpUpdates` \u2014 POST /documents/{documentId}/debug/dump-updates. Dump a document's raw CRDT update log (debug) */\n \"debugDumpUpdates\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"offset\"?: string | number | boolean;\n \"includeData\"?: string | number | boolean;\n \"includeR2Data\"?: string | number | boolean;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugMerge` \u2014 POST /documents/{documentId}/debug/merge. Force-merge a document's pending updates (debug) */\n \"debugMerge\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugMergeBlock` \u2014 POST /documents/{documentId}/debug/merge-block. Merge a specific update block of a document (debug) */\n \"debugMergeBlock\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugRestore` \u2014 POST /documents/debug/restore. Restore a document from a prior state snapshot (debug) */\n \"debugRestore\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.debugStats` \u2014 GET /documents/{documentId}/debug/stats. Get document storage/update stats (debug) */\n \"debugStats\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.delete` \u2014 DELETE /documents/{documentId}. Delete a document */\n \"delete\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.denyAccessRequest` \u2014 POST /documents/{documentId}/access-requests/{requestId}/deny. Deny a document access request */\n \"denyAccessRequest\"(args: {\n \"documentId\": string | number;\n \"requestId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.exportChain` \u2014 GET /documents/{documentId}/export/chain. Export chain of a large document (snapshot + sealed overlays + open epoch) */\n \"exportChain\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.exportState` \u2014 GET /documents/{documentId}/export/state. Export a document's encoded CRDT state */\n \"exportState\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.get` \u2014 GET /documents/{documentId}. Get a single document by id */\n \"get\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getImportChainStatus` \u2014 GET /documents/{documentId}/import/chain. How far a large document's chain import has got */\n \"getImportChainStatus\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getIngest` \u2014 GET /documents/{documentId}/ingest/{sessionId}. One bulk-load session's status */\n \"getIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n }): Promise<any>;\n /** `documents.getLinkAccess` \u2014 GET /documents/{documentId}/link-access. Get the document's \"anyone with the link\" access level */\n \"getLinkAccess\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getOrCreateWithAlias` \u2014 POST /documents/get-or-create-with-alias. Get the document bound to an alias, creating it if absent (idempotent) */\n \"getOrCreateWithAlias\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.getPermissions` \u2014 GET /documents/{documentId}/permissions. List a document's user permissions */\n \"getPermissions\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getSchema` \u2014 GET /documents/{documentId}/schema. Introspect a document's model schema */\n \"getSchema\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getSnapshot` \u2014 GET /documents/{documentId}/snapshots/{buildId}. One snapshot build with its verification result */\n \"getSnapshot\"(args: {\n \"documentId\": string | number;\n \"buildId\": string | number;\n }): Promise<any>;\n /** `documents.getStats` \u2014 GET /documents/{documentId}/stats. Document statistics (record/model/blob counts, approximate size) */\n \"getStats\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.grantGroupPermission` \u2014 POST /documents/{documentId}/group-permissions. Grant a group permission on a document */\n \"grantGroupPermission\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.importChain` \u2014 POST /documents/{documentId}/import/chain. Install an uploaded chain into a large document */\n \"importChain\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.importChainArtifact` \u2014 POST /documents/{documentId}/import/chain/artifact. Upload one artifact of a large document's import chain */\n \"importChainArtifact\"(args: {\n \"documentId\": string | number;\n \"kind\"?: string | number | boolean;\n \"epoch\"?: string | number | boolean;\n \"buildId\"?: string | number | boolean;\n \"model\"?: string | number | boolean;\n \"index\"?: string | number | boolean;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /** `documents.importState` \u2014 POST /documents/{documentId}/import/state. Import encoded CRDT state into a document */\n \"importState\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.listAccessRequests` \u2014 GET /documents/{documentId}/access-requests. List access requests for a document */\n \"listAccessRequests\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listGroupPermissions` \u2014 GET /documents/{documentId}/group-permissions. List a document's group permissions */\n \"listGroupPermissions\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listIngests` \u2014 GET /documents/{documentId}/ingest. List a large document's bulk-load sessions, newest first */\n \"listIngests\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.listPendingInvitations` \u2014 GET /documents/{documentId}/pending-invitations. List a document's pending (deferred) invitations */\n \"listPendingInvitations\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listSnapshots` \u2014 GET /documents/{documentId}/snapshots. List a large document's snapshot builds, newest first */\n \"listSnapshots\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.open` \u2014 POST /documents/open. Open a document for collaboration (resolves access + alias) */\n \"open\"(args: {\n body: unknown;\n }): Promise<any>;\n \"records\": {\n /** `documents.records.aggregate` \u2014 POST /documents/{documentId}/records/{model}/aggregate. Aggregate records in a document model (count/sum/avg/min/max, optional grouping) */\n \"aggregate\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.bulk` \u2014 POST /documents/{documentId}/records/bulk. Apply an atomic multi-model record blob to a document (create/patch/delete) */\n \"bulk\"(args: {\n \"documentId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.count` \u2014 GET /documents/{documentId}/records/{model}/count. Count records in a document model */\n \"count\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n \"filter\"?: Record<string, unknown> | string;\n }): Promise<any>;\n /** `documents.records.delete` \u2014 DELETE /documents/{documentId}/records/{model}/{recordId}. Delete a record from a document model */\n \"delete\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"recordId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.records.patch` \u2014 PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */\n \"patch\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"recordId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.query` \u2014 GET /documents/{documentId}/records/{model}. Query records in a document model */\n \"query\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"filter\"?: Record<string, unknown> | string;\n }): Promise<any>;\n /** `documents.records.save` \u2014 POST /documents/{documentId}/records/{model}. Create or replace a record in a document model */\n \"save\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n };\n /** `documents.removePermissionByEmail` \u2014 DELETE /documents/{documentId}/permissions. Revoke a user's permission on a document by email (?email=) */\n \"removePermissionByEmail\"(args: {\n \"documentId\": string | number;\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.removePermissionByUserId` \u2014 DELETE /documents/{documentId}/permissions/{userId}. Revoke a user's permission on a document by user id */\n \"removePermissionByUserId\"(args: {\n \"documentId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `documents.removeTag` \u2014 DELETE /documents/{documentId}/tags/{tag}. Remove a tag from a document */\n \"removeTag\"(args: {\n \"documentId\": string | number;\n \"tag\": string | number;\n }): Promise<any>;\n /** `documents.requestAccess` \u2014 POST /documents/{documentId}/access-requests. Request access to a document */\n \"requestAccess\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.requestSnapshot` \u2014 POST /documents/{documentId}/snapshots. Snapshot a large document now: seal the open epoch and build a base */\n \"requestSnapshot\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.revokeGroupPermission` \u2014 DELETE /documents/{documentId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a document */\n \"revokeGroupPermission\"(args: {\n \"documentId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `documents.setLinkAccess` \u2014 PUT /documents/{documentId}/link-access. Set the document's \"anyone with the link\" access level */\n \"setLinkAccess\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.transferOwnership` \u2014 POST /documents/{documentId}/permissions/transfer. Transfer ownership of a document to another user */\n \"transferOwnership\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.update` \u2014 PUT /documents/{documentId}. Update a document's metadata */\n \"update\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.updatePermissions` \u2014 PUT /documents/{documentId}/permissions. Grant or update a user's permission on a document */\n \"updatePermissions\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.uploadIngestChunk` \u2014 POST /documents/{documentId}/ingest/{sessionId}/chunks. Upload one chunk of a bulk-load session's artifact */\n \"uploadIngestChunk\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: FormData | ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /** `documents.validateAccess` \u2014 POST /documents/{documentId}/validate-access. Resolve effective access to a document, for the caller or a named user */\n \"validateAccess\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"email\": {\n /** `email.send` \u2014 POST /emails/send. Send an application email under a server function's grant */\n \"send\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"functions\": {\n /** `functions.invoke` \u2014 POST /functions/{functionKey}. Invoke a server function: a request function returns its result, a task function starts a run */\n \"invoke\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `functions.invokeAsSystem` \u2014 POST /functions/{functionKey}/invoke-as-system. Invoke a server function as the system, with no caller */\n \"invokeAsSystem\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `functions.logs` \u2014 GET /functions/{functionKey}/logs. List a server function's invocation logs, newest first */\n \"logs\"(args: {\n \"functionKey\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"runId\"?: string | number | boolean;\n }): Promise<any>;\n /** `functions.start` \u2014 POST /functions/{functionKey}/start. Start a server function as a task run */\n \"start\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"groups\": {\n /** `groups.addMember` \u2014 POST /groups/{groupType}/{groupId}/members. Add a member to a group */\n \"addMember\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `groups.create` \u2014 POST /groups. Create a group */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `groups.delete` \u2014 DELETE /groups/{groupType}/{groupId}. Delete a group */\n \"delete\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.get` \u2014 GET /groups/{groupType}/{groupId}. Get a group by type and id */\n \"get\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.list` \u2014 GET /groups. List groups */\n \"list\"(args?: {\n \"type\"?: string | number | boolean;\n \"includeSystem\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.listDatabases` \u2014 GET /groups/{groupType}/{groupId}/databases. List databases shared with a group */\n \"listDatabases\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listDocuments` \u2014 GET /groups/{groupType}/{groupId}/documents. List documents shared with a group */\n \"listDocuments\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listMembers` \u2014 GET /groups/{groupType}/{groupId}/members. List a group's members */\n \"listMembers\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"include\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.listPendingInvitations` \u2014 GET /groups/{groupType}/{groupId}/pending-invitations. List a group's pending invitations */\n \"listPendingInvitations\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listUserMemberships` \u2014 GET /users/{userId}/memberships. List a user's group memberships */\n \"listUserMemberships\"(args: {\n \"userId\": string | number;\n \"includeSystem\"?: string | number | boolean;\n \"type\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.removeMember` \u2014 DELETE /groups/{groupType}/{groupId}/members/{userId}. Remove a specific member from a group */\n \"removeMember\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `groups.removeMemberByEmail` \u2014 DELETE /groups/{groupType}/{groupId}/members. Remove a group member or pending invitation by email */\n \"removeMemberByEmail\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.update` \u2014 PATCH /groups/{groupType}/{groupId}. Update a group */\n \"update\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"integrations\": {\n /** `integrations.call` \u2014 POST /integrations/{integrationKey}/call. Call an integration under a server function's grants */\n \"call\"(args: {\n \"integrationKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `integrations.list` \u2014 GET /integrations. List integrations configured for the app */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `integrations.proxy` \u2014 POST /integrations/{integrationKey}/proxy. Proxy a request through a configured integration */\n \"proxy\"(args: {\n \"integrationKey\": string | number;\n }): Promise<any>;\n };\n \"locks\": {\n /** `locks.list` \u2014 GET /locks. List all currently-held named locks in the app */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `locks.release` \u2014 POST /locks/release. Release a held named lock (requires the acquire handle) */\n \"release\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.renew` \u2014 POST /locks/renew. Extend the lease on a held named lock */\n \"renew\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.status` \u2014 POST /locks/status. Report the current holder of a named lock */\n \"status\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.tryAcquire` \u2014 POST /locks/acquire. Attempt to acquire a named lock (single non-blocking attempt) */\n \"tryAcquire\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"notifications\": {\n /** `notifications.list` \u2014 GET /notifications. List the caller's in-app notification inbox (newest first) */\n \"list\"(args?: {\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `notifications.listDevices` \u2014 GET /me/push-tokens. List the caller's registered push devices */\n \"listDevices\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.markAllRead` \u2014 POST /notifications/read-all. Mark all of the caller's notifications as read */\n \"markAllRead\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.markRead` \u2014 PATCH /notifications/{notificationId}/read. Mark one of the caller's notifications as read */\n \"markRead\"(args: {\n \"notificationId\": string | number;\n }): Promise<any>;\n /** `notifications.registerDevice` \u2014 POST /me/push-tokens. Register (upsert) the caller's device push token */\n \"registerDevice\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `notifications.send` \u2014 POST /notifications/send. Send a notification to an app user (durable in-app inbox row + live WS frame) */\n \"send\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `notifications.unreadCount` \u2014 GET /notifications/unread-count. Count the caller's unread notifications */\n \"unreadCount\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.unregisterDevice` \u2014 DELETE /me/push-tokens/{token}. Unregister one of the caller's device push tokens */\n \"unregisterDevice\"(args: {\n \"token\": string | number;\n }): Promise<any>;\n };\n \"prompts\": {\n /** `prompts.execute` \u2014 POST /prompts/{promptKey}/execute. Execute a saved prompt */\n \"execute\"(args: {\n \"promptKey\": string | number;\n }): Promise<any>;\n /** `prompts.run` \u2014 POST /prompts/{promptKey}/run. Run a prompt under a server function's grants */\n \"run\"(args: {\n \"promptKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"resourceMetadata\": {\n /** `resourceMetadata.delete` \u2014 DELETE /resources/{resourceType}/{resourceId}/metadata/{category}. Delete a resource's metadata for a category (idempotent) */\n \"delete\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.get` \u2014 GET /resources/{resourceType}/{resourceId}/metadata/{category}. Read a resource's metadata for a category */\n \"get\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.getBatch` \u2014 POST /resources/metadata/batch. Batch-read resource metadata (partial success) */\n \"getBatch\"(args: {\n \"debug\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `resourceMetadata.list` \u2014 GET /resources/{resourceType}/{resourceId}/metadata. List all metadata categories on a resource */\n \"list\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.resolve` \u2014 POST /metadata/resolve. Resolve a resource by a category's unique metadata value */\n \"resolve\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `resourceMetadata.set` \u2014 PUT /resources/{resourceType}/{resourceId}/metadata/{category}. Write a resource's metadata for a category */\n \"set\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"secrets\": {\n /** `secrets.get` \u2014 GET /secrets/{name}. Read an app secret under a server function's grants */\n \"get\"(args: {\n \"name\": string | number;\n }): Promise<any>;\n };\n \"users\": {\n /** `users.getBasic` \u2014 GET /users/{userId}/basic. Get a user's basic public profile */\n \"getBasic\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.getProfiles` \u2014 POST /users/profiles. Look up user profiles in bulk */\n \"getProfiles\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `users.getRootDocument` \u2014 GET /users/{userId}/root-document. Get an app user's root document id */\n \"getRootDocument\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.list` \u2014 GET /users. List app users */\n \"list\"(args?: {\n \"email\"?: string | number | boolean;\n \"userId\"?: string | number | boolean;\n \"name\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `users.lookup` \u2014 GET /users/lookup. Look up a user by identifier */\n \"lookup\"(args?: {\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /**\n * `users.remove` \u2014 DELETE /users/{userId}. DEPRECATED \u2014 remove a user from the app; use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)\n * @deprecated Use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)\n */\n \"remove\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.send` \u2014 POST /users/{userId}/send. Send a realtime message to a member of this app */\n \"send\"(args: {\n \"userId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `users.setRole` \u2014 PUT /users/{userId}/role. Set a user's app role */\n \"setRole\"(args: {\n \"userId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n}\n\n/**\n * The app's database types, model by model \u2014 EMPTY here and filled by the\n * declaration `primitive config push` writes into the config tree's\n * `functions/` directory (#3182). A tree that has pushed once therefore types\n * `ctx.db` against its own schemas; one that has not gets the open form and\n * still compiles.\n */\nexport interface DatabaseSchemas {}\n\n/**\n * The type keys `ctx.db` accepts.\n *\n * Every key the augmentation declares, and NOTHING else, once a tree has\n * pushed: naming a type the app does not have is a compile error. Before that\n * \u2014 an unaugmented tree, a function written before the first push \u2014\n * `DatabaseSchemas` is empty and `keyof` it is `never`, which would make the\n * argument unwritable rather than open. So the empty case widens to `string`\n * and the handle is untyped instead of unusable.\n */\nexport type DatabaseTypeKeys = [keyof DatabaseSchemas] extends [never]\n ? string\n : keyof DatabaseSchemas & string;\n\n/** A model's row shape, or an open record for a type with no schema. */\nexport type DatabaseModels<K extends string> = K extends keyof DatabaseSchemas\n ? DatabaseSchemas[K]\n : Record<string, Record<string, unknown>>;\n\n/**\n * The app's functions, key by key \u2014 EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/`\n * directory (`primitive-function-types.d.ts`): each key's declared input and\n * output types, from its `inputSchema` and `outputSchema`. It is what types\n * `defineFunction(\"<key>\", handler)`.\n */\nexport interface FunctionSchemas {}\n\n/**\n * The keys `defineFunction(key, handler)` accepts: every key the augmentation\n * declares once a tree has pushed, so a key the tree does not declare is a\n * compile error \u2014 and `string` before that, the `DatabaseTypeKeys` rule, so an\n * unaugmented tree keeps compiling.\n */\nexport type FunctionKeys = [keyof FunctionSchemas] extends [never]\n ? string\n : keyof FunctionSchemas & string;\n\n/** A declared function's input type, or `any` when nothing is declared. */\nexport type FunctionInput<K extends string> = K extends keyof FunctionSchemas\n ? FunctionSchemas[K] extends { input: infer I }\n ? I\n : any\n : any;\n\n/** A declared function's output type, or `any` when nothing is declared. */\nexport type FunctionOutput<K extends string> = K extends keyof FunctionSchemas\n ? FunctionSchemas[K] extends { output: infer O }\n ? O\n : any\n : any;\n\n/**\n * The model names one database type addresses \u2014 its own, or any name at all\n * for a type that declares no schema (the DO is schemaless, so a grant on such\n * a type is legal and there is simply nothing to narrow to).\n */\nexport type DatabaseModelNames<TModels> = [keyof TModels] extends [never]\n ? string\n : keyof TModels & string;\n\n/**\n * A row as the platform HANDS IT BACK: whatever the schema declared, plus the\n * record identity the platform owns (#3450).\n *\n * Every stored record has an `id`. A save that arrives without one is given a\n * ULID, a projection always keeps it, and `delete` and `patch` take nothing\n * else \u2014 so a function that queries a model and then moves one of its rows\n * needs the id of the row it just read. A schema is free to say nothing about\n * that field, and most do; the identity is the platform's, not the schema's,\n * so it is added here rather than rendered into each declaration.\n *\n * A declared `id` is REPLACED, never intersected: one declared optional would\n * stay optional on a read row it is always present on, and one declared with\n * some other type would intersect to `never` and be unusable. The platform\n * stamps a string whatever the schema says.\n *\n * An `any` row stays `any` \u2014 `DatabaseHandle<any>` is `defineQuery`'s default\n * handle, and turning its rows into an object with one known member would\n * narrow code that was deliberately left open.\n *\n * Writes are untouched: every one of them takes `Partial<TRow>`, so a row a\n * function BUILDS still needs no id.\n */\nexport type PlatformRow<TRow> = 0 extends 1 & TRow\n ? TRow\n : Omit<TRow, \"id\"> & { id: string };\n\n/** One model's row shape, open when the type declares no schema. */\nexport type DatabaseModelRow<TModels, M extends string> =\n M extends keyof TModels\n ? PlatformRow<TModels[M]>\n : Record<string, unknown> & { id: string };\n\n/**\n * One model of one database, scoped: the `modelName` every records call needs\n * is bound once, so a call names an operation and its own arguments.\n *\n * Filters and options are ordinary objects. Inline filter typing arrives with\n * unified schemas \u2014 the intent's decision, not an omission \u2014 so what is typed\n * today is the model name and the row shape a read hands back.\n */\nexport type ModelScopedBody<TBody = Record<string, unknown>> = TBody & {\n /**\n * Bound by the handle. Reserved so a body cannot look like a second way to\n * choose a model: the runtime assigns the handle's own model last, and a row\n * type that said otherwise would be a lie about what came back.\n */\n modelName?: never;\n};\n\n/**\n * One write inside a model-scoped batch. Every batch verb is a write, so a\n * batch on a model needs that model's write grant whatever the ops are.\n */\nexport type ModelBatchOperation<TRow> = {\n op: \"save\" | \"patch\" | \"delete\" | \"increment\" | \"addToSet\" | \"removeFromSet\";\n id?: string;\n data?: Partial<TRow>;\n /** Bound by the handle, for the same reason every other call's is. */\n modelName?: never;\n [key: string]: unknown;\n};\n\nexport interface DatabaseModelHandle<TRow> {\n /**\n * One page of this model's rows, in the decided envelope \u2014 `{ items,\n * hasMore, nextCursor? }` (#3287), the same shape `ctx.doc(...)`,\n * `ctx.users.list` and the client library answer. The route's own wire\n * shape is unchanged; the SDK is where the one name lives, so shared paging\n * code can be written once.\n */\n query(body?: ModelScopedBody): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;\n count(body?: ModelScopedBody): Promise<any>;\n aggregate(body: ModelScopedBody): Promise<any>;\n save(body: ModelScopedBody<{ id?: string; data: Partial<TRow>; [key: string]: unknown }>): Promise<any>;\n /**\n * Change some fields of ONE row \u2014 `databases.records.patch`, with this\n * handle's model bound (#3450).\n *\n * The record id is positional and the body may not carry another, for the\n * same reason it may not name another model: the runtime assigns both LAST,\n * so a body that appeared to choose either would be a lie about which row\n * moved. `condition`, `stringSets` and the rest of the operation's own keys\n * pass through untouched.\n */\n patch(\n recordId: string,\n body: ModelScopedBody<{ data: Partial<TRow>; id?: never; [key: string]: unknown }>\n ): Promise<any>;\n /**\n * Remove ONE row by the id a read handed back \u2014 `databases.records.delete`,\n * with this handle's model bound (#3450). An optional `condition` makes it\n * conditional, and travels untouched.\n */\n delete(\n recordId: string,\n body?: ModelScopedBody<{ condition?: Record<string, unknown>; id?: never }>\n ): Promise<any>;\n /** Several writes to THIS model in one request; the binding is per item. */\n batch(body: {\n operations: Array<ModelBatchOperation<TRow>>;\n atomic?: boolean;\n }): Promise<any>;\n}\n\n/** One database, typed by the database TYPE key its grant names. */\nexport interface DatabaseHandle<TModels> {\n /** The database this handle addresses \u2014 part of every query cache key. */\n databaseId: string;\n /** The type key this handle was opened with. */\n databaseType: string;\n model<M extends DatabaseModelNames<TModels>>(\n modelName: M\n ): DatabaseModelHandle<DatabaseModelRow<TModels, M>>;\n /**\n * A batch may also SPAN models, and then it names each one itself \u2014 the\n * model-scoped form above is the typed way to write the common case.\n */\n batch(body: {\n operations: Array<Record<string, unknown>>;\n atomic?: boolean;\n }): Promise<any>;\n /** Run one of the database type's prepared operations under this function's grants. */\n runOperation(name: string, params?: Record<string, unknown>): Promise<any>;\n}\n\n/**\n * The app's DOCUMENT models \u2014 EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/` directory\n * (`primitive-document-types.d.ts`, from the project's `models/models.toml`).\n * A project with no document schema gets the open form and still compiles.\n */\nexport interface DocumentSchemas {}\n\n/** The model names `ctx.doc(id).model()` accepts \u2014 every declared one, or `string` before a push. */\nexport type DocumentModelNames = [keyof DocumentSchemas] extends [never]\n ? string\n : keyof DocumentSchemas & string;\n\n/**\n * A document model's row shape, or an open record for an undeclared schema \u2014\n * carrying the platform's record identity either way (#3450), by the same rule\n * and for the same reason as a database row: the records DO is one\n * implementation, and `patch` and `delete` here take an id too.\n */\nexport type DocumentModelRow<M extends string> = M extends keyof DocumentSchemas\n ? PlatformRow<DocumentSchemas[M]>\n : Record<string, unknown> & { id: string };\n\n/** The options a document model read takes: a filter object (or its JSON), a page size, a cursor. */\nexport interface DocumentQueryOptions {\n filter?: Record<string, unknown> | string;\n limit?: number;\n cursor?: string;\n /**\n * The document format you expect (#3764). When it disagrees with the format\n * the platform resolved, the call is refused with a 409\n * DOCUMENT_FORMAT_MISMATCH rather than answered out of the wrong tables.\n * Usually stated once on the handle, as ctx.doc(id, { documentFormat: 2 }),\n * rather than per read.\n */\n documentFormat?: 1 | 2;\n}\n\n/**\n * One document model, bound to its document and its model name \u2014 a thin\n * binding over `ctx.api.documents.records.*` with the route's own shapes.\n */\n/**\n * One op of a document `batch` \u2014 the `documents.records.bulk` blob's shape,\n * typed to this handle's model (#3455).\n *\n * `model` is NOT a member: the handle already names it and assigns it last, so\n * a multi-model blob stays on the raw `ctx.api.documents.records.bulk`\n * operation rather than becoming a second way to say the same thing.\n */\nexport type DocumentBatchOp<TRow> =\n | { action: \"create\" | \"patch\"; id: string; data: Partial<TRow>; precondition?: Record<string, unknown> }\n | { action: \"delete\"; id: string; precondition?: Record<string, unknown> };\n\n/** What `documents.records.bulk` answers: the blob's aggregate effect. */\nexport interface DocumentBulkResult {\n applied: number;\n added: Array<{ model: string; id: string }>;\n updated: Array<{ model: string; id: string }>;\n deleted: number;\n}\n\nexport interface DocumentModelHandle<TRow> {\n query(options?: DocumentQueryOptions): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;\n count(options?: { filter?: Record<string, unknown> | string }): Promise<{ count: number }>;\n aggregate(body: Record<string, unknown>): Promise<any>;\n save(body: { id: string; data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;\n patch(recordId: string, body: { data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;\n delete(recordId: string): Promise<{ deleted: boolean }>;\n /**\n * Apply an ordered blob of this model's ops in ONE transaction \u2014 all of it\n * commits or none of it does, and connected clients see one update.\n *\n * One model's ops, by construction: every op's `model` is this handle's.\n * A blob that spans models is the raw `ctx.api.documents.records.bulk`\n * operation's job.\n */\n batch(ops: Array<DocumentBatchOp<TRow>>): Promise<DocumentBulkResult>;\n}\n\n/** A document, addressed once; its models are typed from `DocumentSchemas`. */\nexport interface DocumentHandle {\n documentId: string;\n model<M extends DocumentModelNames>(modelName: M): DocumentModelHandle<DocumentModelRow<M>>;\n}\n\n/**\n * One call through a granted integration \u2014 #3183.\n *\n * `path` is RELATIVE to the integration's `baseUrl`, and the host is the\n * integration's: the platform resolves and normalizes the path before checking\n * it against `allowedPaths`, so a protocol-relative path or a `..` segment is\n * refused rather than silently sending the request somewhere else.\n */\nexport interface IntegrationCallRequest {\n /** Must be in the integration's `allowedMethods`. Defaults to its own default. */\n method?: string;\n /** Relative to the integration's `baseUrl`. */\n path?: string;\n query?: Record<string, unknown>;\n headers?: Record<string, string>;\n body?: unknown;\n /** form-urlencoded body; not combinable with `body`. */\n form?: Record<string, unknown>;\n bodyMode?: \"json\" | \"raw\" | \"multipart\";\n}\n\n/** What the upstream answered, as the platform saw it. */\nexport interface IntegrationCallResult {\n status: number;\n headers: Record<string, string>;\n body: unknown;\n durationMs: number;\n traceId: string;\n /** Set when the platform or the upstream refused; absent on success. */\n errorCode?: string;\n}\n\n/** What a prompt run is given \u2014 the member execute route's own body. */\nexport interface PromptRunArgs {\n /**\n * The prompt's variables. A `kind = \"decisions\"` prompt takes\n * `{ state, criteria? }`: `state` is the value its questions are asked\n * about, and `criteria.<question>` supplies this run's options for each\n * choice question declared `criteriaSource = \"dynamic\"` \u2014 a table of option\n * key = description (a string or a JSON object), at least two entries (#3813).\n */\n variables?: Record<string, unknown>;\n /** Run against a different model for this call only. */\n modelOverride?: string;\n /** Pin a specific config OF THIS PROMPT; defaults to its active one. */\n configId?: string;\n}\n\n/**\n * The app's PROMPTS \u2014 EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/` directory\n * (`primitive-prompt-types.d.ts`, from the tree's `prompts/*.toml`). A prompt\n * that declares an `outputSchema` carries `{ output: <Key>PromptOutput }`; one\n * that declares none carries `{}`, so reading `parsed.field` on it is a\n * compile error rather than a runtime `undefined`.\n */\nexport interface PromptSchemas {}\n\n/**\n * The keys whose declaration is an AGENT (`kind = \"agent\"`, #3798): entries\n * carrying `{ agent: \u2026 }` instead of an output. An agent runs turn by turn in\n * a session and never single-shot, so these are the keys `PromptKeys` leaves\n * out.\n */\nexport type AgentKeys = {\n [K in keyof PromptSchemas]: PromptSchemas[K] extends { agent: unknown } ? K : never;\n}[keyof PromptSchemas] &\n string;\n\n/**\n * The keys `ctx.prompts.run` accepts \u2014 every declared one that is not an\n * agent, or `string` before a push.\n */\nexport type PromptKeys = [keyof PromptSchemas] extends [never]\n ? string\n : Exclude<keyof PromptSchemas & string, AgentKeys>;\n\n/** One agent's session variables, typed from its `inputSchema` (#3798). */\nexport type AgentVariables<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { variables: infer V };\n}\n ? V\n : never;\n\n/** One agent's client tools, by name: each one's `input` and `output` (#3798). */\nexport type AgentClientTools<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { clientTools: infer T };\n}\n ? T\n : never;\n\n/** One agent's event kinds, by name: each one's payload (#3798). */\nexport type AgentEvents<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { events: infer E };\n}\n ? E\n : never;\n\n/** One prompt's declared output type, or `unknown` where none is declared. */\nexport type PromptOutput<K extends string> = K extends keyof PromptSchemas\n ? PromptSchemas[K] extends { output: infer O }\n ? O\n : unknown\n : unknown;\n\n/**\n * Why a prompt's own answer was refused \u2014 #3330. Never set on a PROVIDER\n * failure, which is what makes \"the model returned the wrong shape\"\n * distinguishable from \"the model failed\".\n */\nexport type PromptOutputErrorCode =\n | \"PROMPT_OUTPUT_NOT_JSON\"\n | \"PROMPT_OUTPUT_SCHEMA_VIOLATION\";\n\n/**\n * Every code the envelope's `errorCode` can carry \u2014 #3663, #3813.\n *\n * `PROMPT_UPSTREAM_TIMEOUT` is the one that is NOT about the prompt's own\n * answer: the provider ran out of time, so there was no answer to refuse. It\n * is the only provider failure that sets `errorCode` at all, which is what\n * leaves \"the model returned the wrong shape\" distinguishable from \"the model\n * failed\" while still letting a caller retry the one failure worth retrying.\n *\n * `PROMPT_CRITERIA_INVALID` is the run that never reached a provider: a\n * decisions run's `variables.criteria` was refused before the call, so\n * nothing was billed (#3813).\n *\n * `PROMPT_STRICT_OUTPUT_SCHEMA_MISSING` never reached one either: the config\n * sets `strictOutput = true` and the prompt has no usable `outputSchema` to\n * send as the strict `json_schema` (#3801).\n */\nexport type PromptRunErrorCode =\n | PromptOutputErrorCode\n | \"PROMPT_UPSTREAM_TIMEOUT\"\n | \"PROMPT_CRITERIA_INVALID\"\n | \"PROMPT_STRICT_OUTPUT_SCHEMA_MISSING\";\n\n/** A prompt that declares an output shape, when the answer matched it. */\nexport interface PromptRunSuccess<TParsed> {\n success: true;\n output: string;\n /** The parsed, validated answer \u2014 no caller-side `JSON.parse` (#3330). */\n parsed: TParsed;\n error?: null;\n errorCode?: null;\n metrics?: Record<string, unknown>;\n configId: string;\n}\n\n/**\n * The failure arm, whichever failed. `errorCode` is set for a SHAPE failure,\n * for a refused run (`PROMPT_CRITERIA_INVALID`, #3813), and for a provider\n * one only when the upstream TIMED OUT (#3663); `output` carries the text\n * either way, which is where the model's own value lives \u2014 a validation\n * `error` names paths and schema constraints only.\n */\nexport interface PromptRunFailure {\n success: false;\n output: string;\n error: string | null;\n errorCode?: PromptRunErrorCode | null;\n parsed?: undefined;\n metrics?: Record<string, unknown>;\n configId: string;\n /**\n * The upstream provider's HTTP status, when the call reached a provider and\n * it answered \u2014 #3663. This is what a retry decision is made on: a 504 or a\n * 503 is worth another attempt, a 400 on a refused payload is not.\n *\n * It does not depend on which provider the config named: Gemini and\n * OpenRouter report it identically. It is absent when no provider answer was\n * observed \u2014 an unset key, an oversized payload, a completion that came back\n * empty \u2014 so a number here is always the provider's own.\n */\n upstreamStatus?: number;\n}\n\n/** The envelope for a key whose declaration says nothing about its output. */\nexport interface PromptRunOpenResult {\n success: boolean;\n output: string;\n /**\n * Present when the config that ran declares `outputFormat = \"json\"` and the\n * text parsed. Untyped: nothing declared its shape.\n */\n parsed?: unknown;\n error?: string | null;\n errorCode?: PromptRunErrorCode | null;\n metrics?: Record<string, unknown>;\n configId: string;\n /** The upstream provider's HTTP status on a provider failure \u2014 #3663. */\n upstreamStatus?: number;\n}\n\n/**\n * The member execute envelope, plus what the prompt's own declaration adds.\n *\n * For a key whose `prompts/<key>.toml` declares an `outputSchema`, this is a\n * discriminated union: narrow on `success` and `parsed` is the declared type,\n * required. For every other key \u2014 and in a tree that has not pushed \u2014 it is\n * the open shape, with `parsed` optional and `unknown`.\n */\nexport type PromptRunResult<K extends string = string> = K extends keyof PromptSchemas\n ? PromptSchemas[K] extends { output: infer O }\n ? PromptRunSuccess<O> | PromptRunFailure\n : PromptRunOpenResult\n : PromptRunOpenResult;\n\n/** What a send delivered to. */\nexport interface SendResult {\n /** Unique live connections the frame was sent to. Zero is a success. */\n connections: number;\n /** True when the per-user connection ceiling stopped the fanout. */\n truncated: boolean;\n}\n\n/** Who a channel grant is for, and for how long \u2014 #3184. */\nexport interface ChannelAuthorizeOptions {\n /**\n * The member the grant names. Caller mode defaults to the invoking caller;\n * system mode has no caller and must say.\n */\n userId?: string;\n /** Default 300 s, clamped to the platform ceiling of 900 s. */\n ttlSeconds?: number;\n}\n\n/** The credential a client presents on the WebSocket it already has. */\nexport interface ChannelGrantResult {\n channel: string;\n /** The signed grant. Hand it to the client; it is not readable here. */\n grant: string;\n /** Epoch milliseconds. Expiry is the only revocation a channel has. */\n expiresAt: number;\n}\n\n/** Where to start and how big a page to take \u2014 #3280. */\nexport interface UserPageOptions {\n /** Page size. Capped by the route at 100. */\n limit?: number;\n /** The `nextCursor` of the page before this one. */\n cursor?: string;\n}\n\n/** One user on the roster, as the platform's own users route reports them. */\nexport interface UserPageItem {\n userId: string;\n email: string | null;\n name: string | null;\n avatarUrl: string | null;\n role: string;\n addedAt: string | null;\n status: string;\n disabledAt: string | null;\n [key: string]: unknown;\n}\n\n/** The decided paged envelope, the same shape every paged read answers. */\nexport interface UserPage {\n items: UserPageItem[];\n hasMore: boolean;\n /** Absent on the last page. */\n nextCursor?: string;\n}\n\n/** How a nested start is keyed and labelled \u2014 #3280. */\nexport interface FunctionStartOptions {\n /**\n * Idempotency key, scoped to the tree's root initiator and the resolved\n * context document: a repeat replays the run that already exists rather than\n * starting a second. At most 100 characters.\n */\n runKey?: string;\n /**\n * The document the child's run is keyed under. Defaults through the\n * inheritance rule: the parent run's context, else the root caller's root\n * document, else `fn:<the root function's id>`. At most 100 characters.\n */\n contextDocId?: string;\n /** Caller metadata, at most 1 KB encoded. */\n meta?: Record<string, unknown>;\n}\n\n/** The start envelope, the same one a workflow start answers with \u2014 #3280. */\nexport interface FunctionStartResult {\n /** Poll this on the platform's run-status route. */\n runId: string;\n runKey: string;\n instanceId: string;\n status: string;\n /**\n * True when `runKey` already named a run in this tree, which this envelope\n * describes. That is what makes a run key a singleton.\n */\n existing?: boolean;\n}\n\nexport interface FunctionContext {\n /** The HTTP caller, or null for a webhook or cron fire. */\n user: FunctionUser | null;\n trigger: FunctionTrigger;\n /**\n * Which RUNTIME is hosting this code \u2014 #3482.\n *\n * Beside `trigger`, which says which DOOR fired, and they are different\n * questions: an HTTP call is whichever runtime the caller chose\n * (`invoke` or `start`), a cron fire is always a task and a webhook\n * delivery is always a request.\n *\n * To REFUSE a runtime rather than branch on it, call\n * `assertRuntime(\"task\")` \u2014 at module scope to refuse it outright, or in\n * the handler to refuse one call.\n */\n runtime: \"request\" | \"task\";\n /**\n * The RUN this invocation belongs to, or null \u2014 #3562.\n *\n * Set under the task runtime (every slice of the run, the first and every\n * resume) and for a webhook-fired request run, which writes a row. Null for\n * an HTTP `invoke`, which writes no run row at all.\n *\n * It is the deterministic OWNER a task run presents to re-take its own\n * lease: `ctx.api.locks.tryAcquire({ body: { key, ttlMs, owner: ctx.runId } })`\n * succeeds for the run that already holds the key, with a fresh handle.\n */\n runId: string | null;\n /**\n * The SLICE of the run this code is running in, or null \u2014 #3562.\n *\n * The same identifier `primitive functions runs` and the run-status\n * route's `slice.sliceId` report. A task run is a sequence of slices: it\n * changes when the run hibernates and wakes, which is how a handler can tell\n * a resume from a first pass.\n *\n * Null under the request runtime: a request invocation is not a slice.\n */\n sliceId: string | null;\n api: FunctionApi;\n /**\n * A typed handle over one database. The second argument is the database TYPE\n * key \u2014 the same key a `database:<type>/<model>:read|write` grant names \u2014\n * and it is what selects the models this handle knows (#3182).\n */\n db<K extends DatabaseTypeKeys>(\n databaseId: string,\n databaseType: K\n ): DatabaseHandle<DatabaseModels<K>>;\n /**\n * A typed handle over one document's record models, typed from the\n * project's `models/models.toml` \u2014 `ctx.db`'s shape for documents. It\n * confers nothing: every call is a `documents.records.*` operation on the\n * same authority.\n */\n doc(documentId: string, options?: { documentFormat?: 1 | 2 }): DocumentHandle;\n /**\n * Outbound HTTP, through a granted integration and nowhere else (#3183).\n *\n * A function has no raw network access: every `fetch` to a host that is not\n * the platform answers `FUNCTION_EGRESS_DENIED`, grant or no grant. What an\n * `integration:<key>` grant buys is this call, which the MAIN WORKER makes on\n * the function's behalf \u2014 which is why the integration's `{{secrets.*}}`\n * credentials can be injected into the request without ever being visible to\n * the code that asked for it.\n */\n integrations: {\n call(\n integrationKey: string,\n request?: IntegrationCallRequest\n ): Promise<IntegrationCallResult>;\n };\n /**\n * Start a TASK function from inside this one \u2014 #3280.\n *\n * The one nested door, and it is a START. A request function is code and\n * code composes by being IMPORTED, so there is no synchronous nested\n * invocation to reach for; a request-mode callee answers\n * `FUNCTION_MODE_MISMATCH`.\n *\n * The callee's `access` gate is not consulted \u2014 this function's own gate was\n * the authorization \u2014 and every run in the tree is keyed by whoever started\n * it, so the member who invoked the root polls and terminates them all.\n * Nesting is bounded at four levels.\n */\n functions: {\n start(\n functionKey: string,\n input?: unknown,\n options?: FunctionStartOptions\n ): Promise<FunctionStartResult>;\n };\n /**\n * Run one of the app's prompts, with nothing to declare (#3183, #3279).\n *\n * The prompt's `accessRule` is not consulted \u2014 it states which MEMBERS may\n * execute the prompt from a client, and the invocation gate is what\n * authorized this call. The provider request is bounded by the invocation's\n * own deadline.\n *\n * TYPED BY KEY (#3330). Where `prompts/<key>.toml` declares an\n * `outputSchema`, the platform parses the answer, validates it against that\n * schema and hands it back as `parsed`, typed \u2014 so the shape is written once\n * in TOML instead of restated as a `JSON.parse` at every call site. Where\n * only the config that ran declares `outputFormat = \"json\"`, `parsed` is\n * present but `unknown`. Where neither is declared the envelope is exactly\n * what it has always been.\n *\n * A shape the declaration refuses is `success: false` with an `errorCode`\n * (`PROMPT_OUTPUT_NOT_JSON` or `PROMPT_OUTPUT_SCHEMA_VIOLATION`) and the\n * text still in `output`; a PROVIDER failure has `error` and no\n * `errorCode`, so the two are told apart without guessing.\n *\n * Once a tree has pushed, a key it does not declare is a compile error.\n */\n prompts: {\n run<K extends PromptKeys>(\n promptKey: K,\n args?: PromptRunArgs\n ): Promise<PromptRunResult<K>>;\n };\n /**\n * The value of one app secret, under a `secret:<NAME>` grant (#3183).\n *\n * Prefer `ctx.integrations.call` when the secret is a credential FOR an\n * integration: there the value is injected by the platform and never enters\n * the sandbox at all. This is for the cases an integration cannot express.\n *\n * Rejects with `FUNCTION_SECRET_NOT_FOUND` when the grant names a value\n * this environment has not been given \u2014 secrets are provisioned per\n * environment, out of band from the push.\n */\n secret(name: string): Promise<string>;\n /** The value of one app config var, under a `var:<NAME>` grant (#3183). */\n configVar(name: string): Promise<string>;\n /**\n * Realtime messages to this app's clients, under a `users:send` grant\n * (#3183).\n *\n * The recipient's client receives a `direct.message` frame carrying this\n * payload and the sending function's key. Presence is not guaranteed: a\n * member with no live socket answers `{ connections: 0 }` rather than an\n * error.\n */\n users: {\n /**\n * One page of the app's users \u2014 #3280.\n *\n * On the APP's system authority, whoever invoked the function: a member\n * who passes this function's gate reads whatever roster it chooses to\n * expose, so say who may in the function's own `access` expression.\n * `limit` is capped by the route at 100.\n */\n list(options?: UserPageOptions): Promise<UserPage>;\n /**\n * Every page of the app's users, in order \u2014 #3280.\n *\n * FOR A REQUEST FUNCTION AND A SINGLE-SLICE LOOP. A durable loop must take\n * its pages inside `step.do` with an EXPLICIT cursor: a memoized step does\n * not advance an iterator on resume, so an iteration across a sleep would\n * replay pages it had already taken.\n */\n iterate(options?: UserPageOptions): AsyncIterable<UserPage>;\n send(userId: string, payload: unknown): Promise<SendResult>;\n };\n /** The same frame to ONE connection, under a `connections:send` grant. */\n connections: {\n send(connectionId: string, payload: unknown): Promise<SendResult>;\n };\n /**\n * Realtime channels, under a `channel:<namespace>` grant that COVERS the\n * channel \u2014 #3184.\n *\n * `authorize` hands back a short-lived grant for ONE member to present on\n * the socket it already has; `publish` delivers a `channel.message` frame to\n * every connection that has joined and whose grant has not expired. Expiry is\n * the only revocation, so `expiresAt` comes back for the client to renew\n * ahead of \u2014 a renewal is another authorize and another subscribe.\n */\n channels: {\n authorize(\n channel: string,\n options?: ChannelAuthorizeOptions\n ): Promise<ChannelGrantResult>;\n publish(channel: string, payload: unknown): Promise<SendResult>;\n };\n}\n\n/** How the wait between one step's retries grows. */\nexport type StepBackoff = \"constant\" | \"linear\" | \"exponential\";\n\n/**\n * The retry and timeout policy for ONE `step.do` \u2014 Cloudflare Workflows' own\n * step config.\n *\n * Under the TASK runner the platform forwards this object to Workflows\n * untouched, so these are its fields and its spellings: a duration is either a\n * number of milliseconds or a string Workflows parses (`\"10 seconds\"`,\n * `\"5 minutes\"`). Under the REQUEST runner `step.do` accepts a config and\n * ignores it \u2014 the body runs inline, and there is nothing to retry into.\n *\n * `stepPolicy.<family>` IS a `StepConfig`, so the platform's own defaults\n * hand straight to `step.do` (#3657). The shape is closed on purpose: a key\n * outside it \u2014 `retry` for `retries`, `timeoutMs` for `timeout` \u2014 is a\n * refusal at `config push` rather than an option the engine silently drops.\n */\nexport interface StepConfig {\n retries?: { limit: number; delay: string | number; backoff?: StepBackoff };\n timeout?: string | number;\n}\n\n/**\n * The step handle. `step` is the third argument under BOTH runners, so the\n * same body runs either way \u2014 which is what `mode = \"any\"` is for (#3454).\n *\n * Under the TASK runner it is Cloudflare Workflows' `WorkflowStep`, forwarded\n * untouched: `step.do` results are memoized and replayed, and `step.sleep`\n * hibernates.\n *\n * Under the REQUEST runner it is the platform's own, bounded by the request's\n * clock: `do` executes the body inline (there is no engine to memoize into,\n * and nothing is replayed); `sleep` and `sleepUntil` REALLY wait when the\n * remaining request budget covers the duration, and otherwise fail the\n * invocation with `errorCode: \"FUNCTION_RUNTIME_REFUSED\"` saying to start the\n * function as a task; `waitForEvent` fails the same way, because nothing can\n * deliver an event to an invocation that has to return now. The thrown error's\n * `name` is `STEP_NOT_AVAILABLE` in every case, so a body that catches it\n * keeps catching it.\n */\nexport interface FunctionStep {\n do<T>(name: string, body: () => T | Promise<T>): Promise<T>;\n do<T>(\n name: string,\n config: StepConfig,\n body: () => T | Promise<T>\n ): Promise<T>;\n sleep(name: string, duration: number | string): Promise<void>;\n sleepUntil(name: string, timestamp: Date | number): Promise<void>;\n waitForEvent<T = unknown>(\n name: string,\n options: Record<string, unknown>\n ): Promise<T>;\n}\n\nexport declare const SDK_STUB_VERSION: string;\n\n/**\n * Thrown by `assertRuntime` when this function is running under the other\n * runtime \u2014 #3482.\n *\n * The platform settles it as `status: \"failed\"` with\n * `errorCode: \"FUNCTION_RUNTIME_REFUSED\"`, on a request invocation's\n * envelope and on a task run's row and record alike.\n */\nexport declare class FunctionRuntimeError extends Error {\n name: \"FUNCTION_RUNTIME_REFUSED\";\n /** The runtime this invocation is actually running under. */\n runtime: \"request\" | \"task\";\n /** The runtime the function asked for. */\n required: \"request\" | \"task\";\n}\n\n/**\n * Refuse the runtime this function was not written for \u2014 #3482.\n *\n * A function is a function and the caller picks the runtime at each call, so\n * nothing in config says which one a function may run under. This is the lock,\n * and it lives in the one place that can always be right about the code:\n *\n * ```ts\n * import { assertRuntime } from \"primitive-functions\";\n *\n * // At module scope: this function is never runnable inside a request.\n * assertRuntime(\"task\");\n *\n * export default async function (input, ctx, step) {\n * await step.sleep(\"cool-off\", \"1 hour\");\n * return { ok: true };\n * }\n * ```\n *\n * Returns when the runtimes match; otherwise throws\n * {@link FunctionRuntimeError}, which the platform settles as\n * `status: \"failed\"` with `errorCode: \"FUNCTION_RUNTIME_REFUSED\"` and a\n * message naming both runtimes and the verb that takes the one required.\n */\nexport declare function assertRuntime(required: \"request\" | \"task\"): void;\n\n/**\n * The handler a function exports, typed for one declared key.\n *\n * `step` is the third argument under BOTH runners (#3186, #3454). A task run\n * gets the engine's live `WorkflowStep`; a request invocation gets the\n * platform's own, where `do` runs the body inline and a wait the request\n * budget cannot cover fails the invocation naming the task runner \u2014 so a\n * task-authored body can be exercised as a request, and the one place the two\n * genuinely differ says so rather than pretending.\n */\nexport type FunctionHandler<TInput, TOutput> = (\n input: TInput,\n ctx: FunctionContext,\n step: FunctionStep\n) => Promise<TOutput>;\n\n/**\n * Declare a server function's handler, typed from its declaration.\n *\n * The KEYED form, `defineFunction(\"<key>\", handler)`, is typed from the\n * `FunctionSchemas` augmentation `primitive config push` writes beside the\n * sources: `input` is the key's declared input, the return is checked against\n * its declared output, and a key the tree does not declare is a compile error.\n * `config push` also refuses an entry whose key names another file's. In a\n * tree that has not pushed yet the key is any string and both types are `any`.\n *\n * The UNKEYED form is what it always was: author-declared generics. Both\n * styles reach the platform bootstrap identically \u2014 a plain default export\n * taking `(input, ctx, step)` runs exactly as a wrapped one does \u2014 so this is\n * a typing and intent marker, not a different calling convention.\n */\nexport declare function defineFunction<K extends FunctionKeys>(\n key: K,\n handler: (\n input: FunctionInput<K>,\n ctx: FunctionContext,\n step: FunctionStep\n ) => FunctionOutput<K> | Promise<FunctionOutput<K>>\n): FunctionHandler<FunctionInput<K>, FunctionOutput<K>> & { functionKey: K };\nexport declare function defineFunction<TInput = unknown, TOutput = unknown>(\n handler: (\n input: TInput,\n ctx: FunctionContext,\n step: FunctionStep\n ) => TOutput | Promise<TOutput>\n): FunctionHandler<TInput, TOutput>;\n\n/**\n * One declared parameter of a registered query.\n *\n * `caller: true` (or `type: \"$caller\"`) is the intent's IMMUTABLE binding:\n * the platform injects the invocation's user and refuses a call that supplies\n * the parameter itself.\n */\n/** The scalar parameter types, and an array parameter's element types. */\nexport type QueryScalarParamType = \"string\" | \"number\" | \"boolean\" | \"any\";\n\nexport interface QueryParamSpec {\n type?: QueryScalarParamType | \"$caller\" | \"array\";\n /** For `type: \"array\"` \u2014 the element type; absent means any element. */\n items?: { type: QueryScalarParamType };\n caller?: boolean;\n optional?: boolean;\n default?: unknown;\n}\n\n/** A scalar parameter type's TypeScript type. */\nexport type QueryScalarValue<T> = T extends \"string\"\n ? string\n : T extends \"number\"\n ? number\n : T extends \"boolean\"\n ? boolean\n : T extends \"$caller\"\n ? string\n : any;\n\n/** The value `run` receives for one declared parameter. */\nexport type QueryParamValue<S> = S extends { caller: true }\n ? string\n : S extends { type: \"array\"; items: { type: infer I } }\n ? QueryScalarValue<I>[]\n : S extends { type: \"array\" }\n ? unknown[]\n : S extends { type: infer T }\n ? QueryScalarValue<T>\n : any;\n\ntype QueryOptionalKeys<P> = {\n [K in keyof P]: P[K] extends { optional: true } ? K : never;\n}[keyof P];\n\n/**\n * `run`'s `params`, typed from the declaration: scalars as their scalar,\n * `$caller` as a string, an array as `T[]`, an `optional: true` parameter\n * as an optional key (a parameter with a default is always present). An\n * undeclared name is a compile error.\n */\nexport type QueryParams<P> = {\n [K in Exclude<keyof P, QueryOptionalKeys<P>>]: QueryParamValue<P[K]>;\n} & {\n [K in QueryOptionalKeys<P>]?: QueryParamValue<P[K]>;\n};\n\n/** A registration's definition with its parameters DECLARED, so `run` is typed from them. */\nexport interface TypedQueryDefinition<TDb, TSpec extends Record<string, QueryParamSpec>, TResult> {\n models: string[];\n params?: TSpec;\n cache?: { ttlMs: number };\n run: (db: TDb, params: QueryParams<TSpec>) => TResult | Promise<TResult>;\n}\n\nexport interface QueryDefinition<TDb, TParams, TResult> {\n /** The models this query touches. Caching is off unless the run matches. */\n models: string[];\n params?: Record<string, QueryParamSpec>;\n /**\n * Cache the answer for `ttlMs` \u2014 capped by the platform, and applied ONLY\n * when the run is verified: every model the body touched was declared, and\n * no prepared operation was used. A write through the handle drops the\n * entries that read the written model.\n */\n cache?: { ttlMs: number };\n run: (db: TDb, params: TParams) => TResult | Promise<TResult>;\n}\n\n/**\n * Register a named query over a database handle (#3187).\n *\n * A registration helper, not a language: `run` is ordinary code over the same\n * typed handle, and what registration adds is a name, declared parameters\n * (validated, coerced and defaulted), the `$caller` binding, and a cache the\n * platform may use when it can verify what the run touched.\n *\n * Register at MODULE scope: a registration made inside the handler still works\n * for direct calls but is invisible to `config push`'s manifest.\n *\n * `run`'s `params` are TYPED from the declaration (the first overload,\n * inferred with a `const` type parameter): a scalar as its scalar, `$caller`\n * as a string, `{ type: \"array\", items: { type: \"string\" } }` as `string[]`,\n * an `optional: true` parameter as an optional key; an undeclared name inside\n * `run` is a compile error. A declared default is coerced to the declared\n * type at registration, so `run` receives what the declaration promises. The\n * second overload keeps an explicit `TParams`.\n */\nexport declare function defineQuery<\n const TSpec extends Record<string, QueryParamSpec>,\n TDb = DatabaseHandle<any>,\n TResult = any\n>(\n name: string,\n definition: TypedQueryDefinition<TDb, TSpec, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\nexport declare function defineQuery<\n TDb = DatabaseHandle<any>,\n TParams = Record<string, any>,\n TResult = any\n>(\n name: string,\n definition: QueryDefinition<TDb, TParams, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\n\n/** The same, for a registration that writes. A mutation is never cached. */\nexport declare function defineMutation<\n const TSpec extends Record<string, QueryParamSpec>,\n TDb = DatabaseHandle<any>,\n TResult = any\n>(\n name: string,\n definition: TypedQueryDefinition<TDb, TSpec, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\nexport declare function defineMutation<\n TDb = DatabaseHandle<any>,\n TParams = Record<string, any>,\n TResult = any\n>(\n name: string,\n definition: QueryDefinition<TDb, TParams, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\n\n/** The platform's cap on a registered query's cache TTL, in milliseconds. */\nexport declare const MAX_QUERY_CACHE_TTL_MS: number;\n\n/**\n * Map over items with BOUNDED concurrency (#3187). Results come back in the\n * input's order; the first rejection wins and nothing new is started after it.\n *\n * The bound matters inside a sandbox: an unbounded fan-out over a page of rows\n * spends the whole subrequest ceiling in one line.\n */\nexport declare function pMap<T, R>(\n items: Iterable<T>,\n mapper: (item: T, index: number) => R | Promise<R>,\n options?: { concurrency?: number }\n): Promise<R[]>;\n\n/** The default concurrency `pMap` applies when none is given. */\nexport declare const PMAP_DEFAULT_CONCURRENCY: number;\n\n/**\n * A time-ordered ULID.\n *\n * GENERATE IT INSIDE `step.do`. A durable run re-executes its handler on\n * every resume and memoizes only what a step returned, so an id minted at the\n * top of a handler is a different id after a sleep \u2014 and whatever it was\n * written into is orphaned.\n */\nexport declare function ulid(): string;\n\n/** One family's durable `step.do` configuration \u2014 a `StepConfig` with every field decided. */\nexport interface StepPolicy extends StepConfig {\n retries: { limit: number; delay: string; backoff: StepBackoff };\n timeout: string;\n}\n\n/**\n * The per-family step policies the DSL runners use, generated from their own\n * timeout module (#3187):\n *\n * await step.do(\"send-receipt\", stepPolicy.email, () =>\n * ctx.api.email.send({ body: { to, subject, htmlBody } }));\n *\n * `retries: 0` on email and the AI families is deliberate \u2014 a retried timeout\n * would send the same email twice or bill the same generation twice.\n */\nexport declare const stepPolicy: {\n email: StepPolicy;\n llm: StepPolicy;\n gemini: StepPolicy;\n database: StepPolicy;\n};\n\n// Every member the three runtime copies put on their own default export \u2014 the\n// platform's `sdk-core.ts`, the published stub and the CLI's collect stub \u2014\n// and nothing else. A helper the module hands a default import but does not\n// declare here is one an author cannot call without the compiler refusing it\n// (#3482 CR3482-002); `tests/api/spec/function-profile.test.ts` holds the four\n// lists equal and compiles a default import against them.\ndeclare const _default: {\n SDK_STUB_VERSION: string;\n defineFunction: typeof defineFunction;\n defineQuery: typeof defineQuery;\n defineMutation: typeof defineMutation;\n pMap: typeof pMap;\n ulid: typeof ulid;\n assertRuntime: typeof assertRuntime;\n FunctionRuntimeError: typeof FunctionRuntimeError;\n};\nexport default _default;\n";
12
+ export declare const SDK_TYPES_SOURCE = "// GENERATED by scripts/generate-function-profile.mjs from openapi.json.\n// DO NOT EDIT. Run `pnpm functions:profile` and commit the result; the\n// freshness guard in tests/api/spec/function-profile.test.ts fails when this\n// file and a fresh generation diverge.\n\n/**\n * Type surface of `primitive-functions` \u2014 what a server function's author writes\n * against (#3180). The published package's RUNTIME is a stub that throws from\n * every export on purpose: the platform substitutes its own copy at invoke\n * time, and reaching the stub means it did not.\n */\n\n/**\n * The signed-in user who invoked the function over HTTP.\n *\n * Attribution, never authority (#3279): function code acts as the system\n * whoever called it, so this says WHO asked, and the rows the function writes\n * are attributed to them. A trigger fire has no caller and `ctx.user` is\n * null.\n */\nexport interface FunctionUser {\n userId: string;\n email: string | null;\n}\n\n/**\n * What started this invocation. Narrow on `kind`.\n *\n * The same union the runtime builds (`src/server-functions/trigger-descriptor.ts`),\n * held identical by `tests/api/spec/function-trigger-declarations-3281.test.ts`:\n * a field the fire path sets is declared here, and nothing is declared here\n * that the fire path does not set.\n */\nexport type FunctionTrigger =\n /**\n * An HTTP invocation: the caller is `ctx.user`.\n *\n * `runKey` is the key a `start` was coalesced by (#3562) \u2014 what you\n * passed as `runKey` to make the run a singleton \u2014 and null when the\n * start named none, or when the call was an `invoke`, which coalesces\n * nothing.\n */\n | { kind: \"http\"; runKey: string | null }\n /** A verified webhook delivery to the function's own key. */\n | {\n kind: \"webhook\";\n /** The webhook key, which is the function key. */\n webhookKey: string;\n /** The platform's webhook row the delivery log lives under. */\n webhookId: string;\n /** The provider's event id (`X-Webhook-Event-Id`), when it sent one. */\n externalEventId: string | null;\n }\n /** A cron entry firing, scheduled or from the `cron-triggers test` diagnostic. */\n | {\n kind: \"cron\";\n /** The `[[function.triggers.cron]]` entry's `name`. */\n name: string;\n /** The platform's cron row. */\n triggerId: string;\n /** ISO 8601. The instant the fire was scheduled for; a diagnostic fire's is \"now\". */\n scheduledFor: string;\n /** Present, and true, only on the diagnostic fire: nothing was scheduled. */\n manual?: true;\n }\n /**\n * A DSL workflow's `workflow.call` step reached this function (#3288).\n *\n * TRANSITIONAL: the bridge exists so a workflow tree can migrate leaf-first\n * during the transition, and it retires with the workflow engine in phase 7,\n * taking this variant with it. `workflowKey` names the PARENT workflow, and\n * `runId`/`stepId` locate the step inside its run.\n */\n | { kind: \"workflow\"; workflowKey: string; runId: string; stepId: string }\n /**\n * Another function started this one with `ctx.functions.start` (#3280).\n *\n * `functionKey` names the PARENT, and `runId` its run \u2014 null when the\n * parent was a request invocation over HTTP, which writes no run row.\n * `runKey` is the key the parent's start named, or null (#3562).\n */\n | {\n kind: \"function\";\n functionKey: string;\n runId: string | null;\n runKey: string | null;\n }\n /**\n * An admin ran this function as the SYSTEM, from outside any trigger\n * (#3448) \u2014 `primitive functions invoke --as system`.\n *\n * `ctx.user` is null and the code runs with the app's system authority, as\n * it does for a cron or webhook fire. `userId` names the admin who asked:\n * attribution, never the principal the code runs as. `runKey` is the key\n * the admin's start named, or null (#3562).\n */\n | { kind: \"manual\"; userId: string; runKey: string | null };\n\n/** The result shape of an operation that answers in response headers. */\nexport interface HeaderResult {\n status: number;\n headers: Record<string, string>;\n}\n\n/**\n * A platform call that was refused. `errorCode` carries the gateway's own\n * codes (`FUNCTION_ROUTE_NOT_ALLOWED`, `FUNCTION_EGRESS_DENIED`, \u2026) as well\n * as the route's.\n */\nexport interface PrimitivePlatformError extends Error {\n status: number;\n errorCode: string | null;\n /**\n * The route's structured `details`, or null when its refusal carries none\n * (#3803). `AGENT_SESSION_VARIABLES_INVALID` lists `errors` as\n * `{ path, message }`; `AGENT_SESSION_ORIGIN_REFUSED` names `origin`.\n */\n details: unknown;\n}\n\n/**\n * The typed HTTP profile, generated from the platform's OpenAPI document. Its\n * namespaces mirror the operation ids: agentSessions, analytics, blobBuckets, channels, collections, configVars, connections, databaseTypeConfigs, databases, documents, email, functions, groups, integrations, locks, notifications, prompts, resourceMetadata, secrets, users.\n * Methods take one options object carrying the operation's path parameters,\n * query parameters, request headers (under their wire names) and `body`.\n *\n * Generated from the same operations as the runtime profile, so a method that\n * type-checks is a method the platform publishes \u2014 and a missing path\n * parameter or a missing required header is a compile error rather than a\n * `TypeError` at invoke time. Every call runs with the app's own SYSTEM\n * authority (#3279): the invocation gate was the authorization. The two\n * namespaces the gateway does not admit are still declared: they exist, they\n * answer the gateway's structured denial, and hiding them would make a route's\n * availability look like a typo. Those are `databaseTypeConfigs` whole, and\n * `functions` except for `functions.start` \u2014 the nested-start door #3280\n * admits by name, which `ctx.functions.start` calls. `functions.invoke`\n * stays refused: same-run composition is an import.\n */\nexport interface FunctionApi {\n \"agentSessions\": {\n /** `agentSessions.create` \u2014 POST /agent-sessions. Create an agent session (ctx.agents.createSession) */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"analytics\": {\n /** `analytics.cohortRetention` \u2014 GET /analytics/cohort-retention. Cohort retention metrics */\n \"cohortRetention\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.dailyActive` \u2014 GET /analytics/daily-active. Daily active user time series */\n \"dailyActive\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.errorGroups` \u2014 GET /analytics/errors/groups. Group failure events by fingerprint with per-day count buckets */\n \"errorGroups\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.integrationUsage` \u2014 GET /analytics/integrations. Integration usage metrics */\n \"integrationUsage\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.listEvents` \u2014 GET /analytics/events. List analytics events */\n \"listEvents\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"page\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.listEventsGrouped` \u2014 GET /analytics/events/grouped. List analytics events grouped by dimension */\n \"listEventsGrouped\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"groupBy\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.overviewDau` \u2014 GET /analytics/overview/dau. Daily active users overview */\n \"overviewDau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewGrowth` \u2014 GET /analytics/overview/growth. User growth overview */\n \"overviewGrowth\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewMau` \u2014 GET /analytics/overview/mau. Monthly active users overview */\n \"overviewMau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewWau` \u2014 GET /analytics/overview/wau. Weekly active users overview */\n \"overviewWau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.rollingActive` \u2014 GET /analytics/rolling-active. Rolling active user time series */\n \"rollingActive\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.searchUsers` \u2014 GET /analytics/users/search. Search app users for analytics */\n \"searchUsers\"(args?: {\n \"q\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"signupDay\"?: string | number | boolean;\n \"signupStartDay\"?: string | number | boolean;\n \"signupEndDay\"?: string | number | boolean;\n \"offset\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topPrompts` \u2014 GET /analytics/prompts/top. List the most-executed prompts */\n \"topPrompts\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topUsers` \u2014 GET /analytics/users/top. List the most active users */\n \"topUsers\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topWorkflows` \u2014 GET /analytics/workflows/top. List the most-run workflows */\n \"topWorkflows\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.userDetail` \u2014 GET /analytics/users/{userUlid}/detail. Detailed analytics for a single user */\n \"userDetail\"(args: {\n \"userUlid\": string | number;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.userSnapshot` \u2014 GET /analytics/users/{userUlid}/snapshot. Activity snapshot for a single user */\n \"userSnapshot\"(args: {\n \"userUlid\": string | number;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.writeForUser` \u2014 POST /analytics/write-for-user. Write an analytics event for a subject user under a grant */\n \"writeForUser\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"blobBuckets\": {\n /** `blobBuckets.createBucket` \u2014 POST /blob-buckets. Create a blob bucket */\n \"createBucket\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.delete` \u2014 DELETE /blob-buckets/{bucketId}/blobs/{blobId}. Delete a blob */\n \"delete\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.deleteBatch` \u2014 POST /blob-buckets/{bucketId}/blobs/delete. Batch delete blobs from a bucket */\n \"deleteBatch\"(args: {\n \"bucketId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.deleteBucket` \u2014 DELETE /blob-buckets/{bucketId}. Delete a blob bucket */\n \"deleteBucket\"(args: {\n \"bucketId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.download` \u2014 GET /blob-buckets/{bucketId}/blobs/{blobId}. Download a blob (anonymous allowed for public buckets) */\n \"download\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n \"disposition\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `blobBuckets.downloadSigned` \u2014 GET /blob-buckets/{bucketId}/blobs/{blobId}/signed. Download a blob via a signed URL token */\n \"downloadSigned\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n \"token\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `blobBuckets.getBucket` \u2014 GET /blob-buckets/{bucketId}. Get a blob bucket by id */\n \"getBucket\"(args: {\n \"bucketId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.getMetadata` \u2014 GET /blob-buckets/{bucketId}/blobs/{blobId}/metadata. Get blob metadata (anonymous allowed for public buckets) */\n \"getMetadata\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.getSignedUrl` \u2014 POST /blob-buckets/{bucketId}/blobs/{blobId}/signed-url. Create a signed download URL for a blob */\n \"getSignedUrl\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `blobBuckets.list` \u2014 GET /blob-buckets/{bucketId}/blobs. List blobs in a bucket (anonymous allowed for public buckets) */\n \"list\"(args: {\n \"bucketId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `blobBuckets.listBuckets` \u2014 GET /blob-buckets. List blob buckets */\n \"listBuckets\"(args?: Record<string, never>): Promise<any>;\n /** `blobBuckets.updateBucket` \u2014 PATCH /blob-buckets/{bucketId}. Update a blob bucket */\n \"updateBucket\"(args: {\n \"bucketId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.upload` \u2014 POST /blob-buckets/{bucketId}/blobs. Upload a blob to a bucket */\n \"upload\"(args: {\n \"bucketId\": string | number;\n \"X-Blob-Filename\": string | number;\n \"X-Blob-Tags\"?: string | number;\n \"Content-Type\"?: string | number;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n };\n \"channels\": {\n /** `channels.authorize` \u2014 POST /channels/{channel}/grants. Issue a channel grant under a server function's grant */\n \"authorize\"(args: {\n \"channel\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `channels.publish` \u2014 POST /channels/{channel}/publish. Publish a message to a channel under a server function's grant */\n \"publish\"(args: {\n \"channel\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"collections\": {\n /** `collections.addDocument` \u2014 POST /collections/{collectionId}/documents. Add a document to a collection */\n \"addDocument\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.addMember` \u2014 POST /collections/{collectionId}/members. Add a member to a collection */\n \"addMember\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.create` \u2014 POST /collections. Create a collection */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `collections.delete` \u2014 DELETE /collections/{collectionId}. Delete a collection */\n \"delete\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.get` \u2014 GET /collections/{collectionId}. Get a collection by id */\n \"get\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.getAccess` \u2014 GET /collections/{collectionId}/access. Get a collection's access summary */\n \"getAccess\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.grantGroupPermission` \u2014 POST /collections/{collectionId}/group-permissions. Grant a group permission on a collection */\n \"grantGroupPermission\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.list` \u2014 GET /collections. List collections */\n \"list\"(args?: {\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listCollectionsForDocument` \u2014 GET /documents/{documentId}/collections. List collections a document belongs to (reverse lookup) */\n \"listCollectionsForDocument\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listDocuments` \u2014 GET /collections/{collectionId}/documents. List documents in a collection */\n \"listDocuments\"(args: {\n \"collectionId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listPendingInvitations` \u2014 GET /collections/{collectionId}/pending-invitations. List a collection's pending invitations */\n \"listPendingInvitations\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.removeDocument` \u2014 DELETE /collections/{collectionId}/documents/{documentId}. Remove a document from a collection */\n \"removeDocument\"(args: {\n \"collectionId\": string | number;\n \"documentId\": string | number;\n }): Promise<any>;\n /** `collections.removeMember` \u2014 DELETE /collections/{collectionId}/members/{userId}. Remove a member from a collection */\n \"removeMember\"(args: {\n \"collectionId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `collections.revokeGroupPermission` \u2014 DELETE /collections/{collectionId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a collection */\n \"revokeGroupPermission\"(args: {\n \"collectionId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `collections.update` \u2014 PATCH /collections/{collectionId}. Update a collection */\n \"update\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"configVars\": {\n /** `configVars.get` \u2014 GET /config-vars/{name}. Read an app config var under a server function's grants */\n \"get\"(args: {\n \"name\": string | number;\n }): Promise<any>;\n };\n \"connections\": {\n /** `connections.send` \u2014 POST /connections/{connectionId}/send. Send a realtime message to one connection of this app */\n \"send\"(args: {\n \"connectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"databaseTypeConfigs\": {\n /** `databaseTypeConfigs.create` \u2014 POST /databases/types. Create a database type */\n \"create\"(args: {\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.createOperation` \u2014 POST /databases/types/{databaseType}/operations. Create an operation for a database type */\n \"createOperation\"(args: {\n \"databaseType\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.delete` \u2014 DELETE /databases/types/{databaseType}. Delete a database type */\n \"delete\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.deleteOperation` \u2014 DELETE /databases/types/{databaseType}/operations/{name}. Delete an operation for a database type */\n \"deleteOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.get` \u2014 GET /databases/types/{databaseType}. Get a database type */\n \"get\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.getOperation` \u2014 GET /databases/types/{databaseType}/operations/{name}. Get an operation for a database type */\n \"getOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.getReindexStatus` \u2014 GET /databases/types/{databaseType}/reindex-status. Status of the index back-provision fan-out for a type */\n \"getReindexStatus\"(args: {\n \"databaseType\": string | number;\n \"runId\"?: string | number | boolean;\n }): Promise<any>;\n /** `databaseTypeConfigs.list` \u2014 GET /databases/types. List database types */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `databaseTypeConfigs.listOperations` \u2014 GET /databases/types/{databaseType}/operations. List operations for a database type */\n \"listOperations\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.scaffoldSchema` \u2014 POST /databases/types/{databaseType}/schema:scaffold. Scaffold a starter schema for a database type */\n \"scaffoldSchema\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n \"subscriptions\": {\n /** `databaseTypeConfigs.subscriptions.create` \u2014 POST /databases/types/{databaseType}/subscriptions. Create a subscription for a database type */\n \"create\"(args: {\n \"databaseType\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.delete` \u2014 DELETE /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Delete a database type subscription */\n \"delete\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.get` \u2014 GET /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Get a database type subscription */\n \"get\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.list` \u2014 GET /databases/types/{databaseType}/subscriptions. List subscriptions for a database type */\n \"list\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.update` \u2014 PUT /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Update a database type subscription */\n \"update\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databaseTypeConfigs.update` \u2014 PATCH /databases/types/{databaseType}. Update a database type */\n \"update\"(args: {\n \"databaseType\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.updateOperation` \u2014 PATCH /databases/types/{databaseType}/operations/{name}. Update an operation for a database type */\n \"updateOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n };\n \"databases\": {\n /** `databases.addManager` \u2014 PUT /databases/{databaseId}/permissions. Set a user's database permission */\n \"addManager\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.create` \u2014 POST /databases. Create a database */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `databases.delete` \u2014 DELETE /databases/{databaseId}. Delete a database */\n \"delete\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.executeBatch` \u2014 POST /databases/{databaseId}/operations/{name}/batch. Execute a database operation in batch */\n \"executeBatch\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.executeOperation` \u2014 POST /databases/{databaseId}/operations/{name}/execute. Execute a database operation */\n \"executeOperation\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n \"dryRun\"?: string | number | boolean;\n body?: unknown;\n }): Promise<any>;\n /** `databases.get` \u2014 GET /databases/{databaseId}. Get a database by id */\n \"get\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /**\n * `databases.getMetadata` \u2014 GET /databases/{databaseId}/metadata. DEPRECATED \u2014 get database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)\n * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)\n */\n \"getMetadata\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.grantGroupPermission` \u2014 POST /databases/{databaseId}/group-permissions. Grant a group permission on a database */\n \"grantGroupPermission\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.importBulk` \u2014 POST /databases/{databaseId}/operations/{name}/import-bulk. Bulk-import records via a database operation */\n \"importBulk\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.list` \u2014 GET /databases. List databases */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `databases.listGroupPermissions` \u2014 GET /databases/{databaseId}/group-permissions. List a database's group permissions */\n \"listGroupPermissions\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.listOperations` \u2014 GET /databases/{databaseId}/operations. List operations runnable on a database */\n \"listOperations\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.listPermissions` \u2014 GET /databases/{databaseId}/permissions. List a database's user permissions */\n \"listPermissions\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n \"records\": {\n /** `databases.records.addToSet` \u2014 POST /databases/{databaseId}/records/stringset/add. Database records: stringset/add (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"addToSet\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.aggregate` \u2014 POST /databases/{databaseId}/records/aggregate. Database records: aggregate (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"aggregate\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.batch` \u2014 POST /databases/{databaseId}/records/batch. Database records: batch (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"batch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.count` \u2014 POST /databases/{databaseId}/records/count. Database records: count (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"count\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.delete` \u2014 POST /databases/{databaseId}/records/delete. Database records: delete (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"delete\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.describe` \u2014 GET /databases/{databaseId}/records/describe. Database records: describe (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"describe\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.dropIndex` \u2014 POST /databases/{databaseId}/records/index/drop. Database records: index/drop (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"dropIndex\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.dropUniqueConstraint` \u2014 POST /databases/{databaseId}/records/unique-constraint/drop. Database records: unique-constraint/drop (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"dropUniqueConstraint\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.increment` \u2014 POST /databases/{databaseId}/records/increment. Database records: increment (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"increment\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.listIndexes` \u2014 GET /databases/{databaseId}/records/indexes. Database records: indexes (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"listIndexes\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.listUniqueConstraints` \u2014 GET /databases/{databaseId}/records/unique-constraints. Database records: unique-constraints (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"listUniqueConstraints\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.models` \u2014 GET /databases/{databaseId}/records/models. Database records: models (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"models\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.patch` \u2014 POST /databases/{databaseId}/records/patch. Database records: patch (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"patch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.query` \u2014 POST /databases/{databaseId}/records/query. Database records: query (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"query\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<{ items: any[]; hasMore: boolean; nextCursor?: string; prevCursor?: string }>;\n /** `databases.records.registerIndex` \u2014 POST /databases/{databaseId}/records/index/register. Database records: index/register (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"registerIndex\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.registerUniqueConstraint` \u2014 POST /databases/{databaseId}/records/unique-constraint/register. Database records: unique-constraint/register (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"registerUniqueConstraint\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.removeFromSet` \u2014 POST /databases/{databaseId}/records/stringset/remove. Database records: stringset/remove (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"removeFromSet\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.save` \u2014 POST /databases/{databaseId}/records/save. Database records: save (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"save\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.syncIndexes` \u2014 POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"syncIndexes\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databases.reindex` \u2014 POST /databases/{databaseId}/reindex. Reindex a database */\n \"reindex\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.revokeGroupPermission` \u2014 DELETE /databases/{databaseId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a database */\n \"revokeGroupPermission\"(args: {\n \"databaseId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `databases.revokePermission` \u2014 DELETE /databases/{databaseId}/permissions/{userId}. Remove a user's database permission */\n \"revokePermission\"(args: {\n \"databaseId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `databases.runOperation` \u2014 POST /databases/{databaseId}/operations/{name}/run. Run a database operation under a server function's grants */\n \"runOperation\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `databases.transferOwnership` \u2014 POST /databases/{databaseId}/permissions/transfer. Transfer database ownership */\n \"transferOwnership\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.update` \u2014 PATCH /databases/{databaseId}. Update a database */\n \"update\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.updateMetadata` \u2014 PATCH /databases/{databaseId}/metadata. DEPRECATED \u2014 update database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)\n * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)\n */\n \"updateMetadata\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"documents\": {\n /** `documents.abortIngest` \u2014 POST /documents/{documentId}/ingest/{sessionId}/abort. Abort a bulk-load session before its swap */\n \"abortIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.addTag` \u2014 POST /documents/{documentId}/tags. Add a tag to a document */\n \"addTag\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n \"aliases\": {\n /** `documents.aliases.delete` \u2014 DELETE /document-aliases/{scope}/{aliasKey}. Delete a (scope, aliasKey) document alias binding */\n \"delete\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n \"userId\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.aliases.listForDocument` \u2014 GET /documents/{documentId}/aliases. List aliases bound to a document */\n \"listForDocument\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.aliases.resolve` \u2014 GET /document-aliases/{scope}/{aliasKey}. Resolve the document bound to a (scope, aliasKey) alias */\n \"resolve\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n \"userId\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.aliases.set` \u2014 PUT /document-aliases/{scope}/{aliasKey}. Bind a (scope, aliasKey) alias to a document */\n \"set\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `documents.approveAccessRequest` \u2014 POST /documents/{documentId}/access-requests/{requestId}/approve. Approve a document access request */\n \"approveAccessRequest\"(args: {\n \"documentId\": string | number;\n \"requestId\": string | number;\n body?: unknown;\n }): Promise<any>;\n \"blobs\": {\n /** `documents.blobs.delete` \u2014 DELETE /documents/{documentId}/blobs/{blobId}. Delete a document blob */\n \"delete\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.downloadHeaders` \u2014 HEAD /documents/{documentId}/blobs/{blobId}/download. Get document blob download headers (ETag/304 support) */\n \"downloadHeaders\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<HeaderResult>;\n /** `documents.blobs.downloadUrl` \u2014 GET /documents/{documentId}/blobs/{blobId}/download. Download a document blob's bytes */\n \"downloadUrl\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n \"disposition\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `documents.blobs.get` \u2014 GET /documents/{documentId}/blobs/{blobId}. Get a document blob's metadata */\n \"get\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.list` \u2014 GET /documents/{documentId}/blobs. List blobs attached to a document */\n \"list\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.upload` \u2014 PUT /documents/{documentId}/blobs/{blobId}. Upload a document blob with a client-specified id (immutable + idempotent) */\n \"upload\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n \"X-Blob-Filename\": string | number;\n \"X-Blob-Size\": string | number;\n \"X-Blob-Sha256\": string | number;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n };\n /** `documents.clearLinkAccess` \u2014 DELETE /documents/{documentId}/link-access. Turn off the document's link access */\n \"clearLinkAccess\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.commitIngest` \u2014 POST /documents/{documentId}/ingest/{sessionId}/commit. Commit a bulk-load session: freeze its manifest and apply it */\n \"commitIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.create` \u2014 POST /documents. Create a new document */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.createIngest` \u2014 POST /documents/{documentId}/ingest. Open a bulk-load session on a large document */\n \"createIngest\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.createWithAlias` \u2014 POST /documents/create-with-alias. Create a document and bind it to an alias */\n \"createWithAlias\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.debugDumpUpdates` \u2014 POST /documents/{documentId}/debug/dump-updates. Dump a document's raw CRDT update log (debug) */\n \"debugDumpUpdates\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"offset\"?: string | number | boolean;\n \"includeData\"?: string | number | boolean;\n \"includeR2Data\"?: string | number | boolean;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugMerge` \u2014 POST /documents/{documentId}/debug/merge. Force-merge a document's pending updates (debug) */\n \"debugMerge\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugMergeBlock` \u2014 POST /documents/{documentId}/debug/merge-block. Merge a specific update block of a document (debug) */\n \"debugMergeBlock\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugRestore` \u2014 POST /documents/debug/restore. Restore a document from a prior state snapshot (debug) */\n \"debugRestore\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.debugStats` \u2014 GET /documents/{documentId}/debug/stats. Get document storage/update stats (debug) */\n \"debugStats\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.delete` \u2014 DELETE /documents/{documentId}. Delete a document */\n \"delete\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.denyAccessRequest` \u2014 POST /documents/{documentId}/access-requests/{requestId}/deny. Deny a document access request */\n \"denyAccessRequest\"(args: {\n \"documentId\": string | number;\n \"requestId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.exportChain` \u2014 GET /documents/{documentId}/export/chain. Export chain of a large document (snapshot + sealed overlays + open epoch) */\n \"exportChain\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.exportState` \u2014 GET /documents/{documentId}/export/state. Export a document's encoded CRDT state */\n \"exportState\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.get` \u2014 GET /documents/{documentId}. Get a single document by id */\n \"get\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getImportChainStatus` \u2014 GET /documents/{documentId}/import/chain. How far a large document's chain import has got */\n \"getImportChainStatus\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getIngest` \u2014 GET /documents/{documentId}/ingest/{sessionId}. One bulk-load session's status */\n \"getIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n }): Promise<any>;\n /** `documents.getLinkAccess` \u2014 GET /documents/{documentId}/link-access. Get the document's \"anyone with the link\" access level */\n \"getLinkAccess\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getOrCreateWithAlias` \u2014 POST /documents/get-or-create-with-alias. Get the document bound to an alias, creating it if absent (idempotent) */\n \"getOrCreateWithAlias\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.getPermissions` \u2014 GET /documents/{documentId}/permissions. List a document's user permissions */\n \"getPermissions\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getSchema` \u2014 GET /documents/{documentId}/schema. Introspect a document's model schema */\n \"getSchema\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getSnapshot` \u2014 GET /documents/{documentId}/snapshots/{buildId}. One snapshot build with its verification result */\n \"getSnapshot\"(args: {\n \"documentId\": string | number;\n \"buildId\": string | number;\n }): Promise<any>;\n /** `documents.getStats` \u2014 GET /documents/{documentId}/stats. Document statistics (record/model/blob counts, approximate size) */\n \"getStats\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.grantGroupPermission` \u2014 POST /documents/{documentId}/group-permissions. Grant a group permission on a document */\n \"grantGroupPermission\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.importChain` \u2014 POST /documents/{documentId}/import/chain. Install an uploaded chain into a large document */\n \"importChain\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.importChainArtifact` \u2014 POST /documents/{documentId}/import/chain/artifact. Upload one artifact of a large document's import chain */\n \"importChainArtifact\"(args: {\n \"documentId\": string | number;\n \"kind\"?: string | number | boolean;\n \"epoch\"?: string | number | boolean;\n \"buildId\"?: string | number | boolean;\n \"model\"?: string | number | boolean;\n \"index\"?: string | number | boolean;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /** `documents.importState` \u2014 POST /documents/{documentId}/import/state. Import encoded CRDT state into a document */\n \"importState\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.listAccessRequests` \u2014 GET /documents/{documentId}/access-requests. List access requests for a document */\n \"listAccessRequests\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listGroupPermissions` \u2014 GET /documents/{documentId}/group-permissions. List a document's group permissions */\n \"listGroupPermissions\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listIngests` \u2014 GET /documents/{documentId}/ingest. List a large document's bulk-load sessions, newest first */\n \"listIngests\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.listPendingInvitations` \u2014 GET /documents/{documentId}/pending-invitations. List a document's pending (deferred) invitations */\n \"listPendingInvitations\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listSnapshots` \u2014 GET /documents/{documentId}/snapshots. List a large document's snapshot builds, newest first */\n \"listSnapshots\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.open` \u2014 POST /documents/open. Open a document for collaboration (resolves access + alias) */\n \"open\"(args: {\n body: unknown;\n }): Promise<any>;\n \"records\": {\n /** `documents.records.aggregate` \u2014 POST /documents/{documentId}/records/{model}/aggregate. Aggregate records in a document model (count/sum/avg/min/max, optional grouping) */\n \"aggregate\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.bulk` \u2014 POST /documents/{documentId}/records/bulk. Apply an atomic multi-model record blob to a document (create/patch/delete) */\n \"bulk\"(args: {\n \"documentId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.count` \u2014 GET /documents/{documentId}/records/{model}/count. Count records in a document model */\n \"count\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n \"filter\"?: Record<string, unknown> | string;\n }): Promise<any>;\n /** `documents.records.delete` \u2014 DELETE /documents/{documentId}/records/{model}/{recordId}. Delete a record from a document model */\n \"delete\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"recordId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.records.patch` \u2014 PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */\n \"patch\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"recordId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.query` \u2014 GET /documents/{documentId}/records/{model}. Query records in a document model */\n \"query\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"filter\"?: Record<string, unknown> | string;\n }): Promise<any>;\n /** `documents.records.save` \u2014 POST /documents/{documentId}/records/{model}. Create or replace a record in a document model */\n \"save\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n };\n /** `documents.removePermissionByEmail` \u2014 DELETE /documents/{documentId}/permissions. Revoke a user's permission on a document by email (?email=) */\n \"removePermissionByEmail\"(args: {\n \"documentId\": string | number;\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.removePermissionByUserId` \u2014 DELETE /documents/{documentId}/permissions/{userId}. Revoke a user's permission on a document by user id */\n \"removePermissionByUserId\"(args: {\n \"documentId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `documents.removeTag` \u2014 DELETE /documents/{documentId}/tags/{tag}. Remove a tag from a document */\n \"removeTag\"(args: {\n \"documentId\": string | number;\n \"tag\": string | number;\n }): Promise<any>;\n /** `documents.requestAccess` \u2014 POST /documents/{documentId}/access-requests. Request access to a document */\n \"requestAccess\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.requestSnapshot` \u2014 POST /documents/{documentId}/snapshots. Snapshot a large document now: seal the open epoch and build a base */\n \"requestSnapshot\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.revokeGroupPermission` \u2014 DELETE /documents/{documentId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a document */\n \"revokeGroupPermission\"(args: {\n \"documentId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `documents.setLinkAccess` \u2014 PUT /documents/{documentId}/link-access. Set the document's \"anyone with the link\" access level */\n \"setLinkAccess\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.transferOwnership` \u2014 POST /documents/{documentId}/permissions/transfer. Transfer ownership of a document to another user */\n \"transferOwnership\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.update` \u2014 PUT /documents/{documentId}. Update a document's metadata */\n \"update\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.updatePermissions` \u2014 PUT /documents/{documentId}/permissions. Grant or update a user's permission on a document */\n \"updatePermissions\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.uploadIngestChunk` \u2014 POST /documents/{documentId}/ingest/{sessionId}/chunks. Upload one chunk of a bulk-load session's artifact */\n \"uploadIngestChunk\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: FormData | ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /** `documents.validateAccess` \u2014 POST /documents/{documentId}/validate-access. Resolve effective access to a document, for the caller or a named user */\n \"validateAccess\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"email\": {\n /** `email.send` \u2014 POST /emails/send. Send an application email under a server function's grant */\n \"send\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"functions\": {\n /** `functions.invoke` \u2014 POST /functions/{functionKey}. Invoke a server function: a request function returns its result, a task function starts a run */\n \"invoke\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `functions.invokeAsSystem` \u2014 POST /functions/{functionKey}/invoke-as-system. Invoke a server function as the system, with no caller */\n \"invokeAsSystem\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `functions.logs` \u2014 GET /functions/{functionKey}/logs. List a server function's invocation logs, newest first */\n \"logs\"(args: {\n \"functionKey\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"runId\"?: string | number | boolean;\n }): Promise<any>;\n /** `functions.start` \u2014 POST /functions/{functionKey}/start. Start a server function as a task run */\n \"start\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"groups\": {\n /** `groups.addMember` \u2014 POST /groups/{groupType}/{groupId}/members. Add a member to a group */\n \"addMember\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `groups.create` \u2014 POST /groups. Create a group */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `groups.delete` \u2014 DELETE /groups/{groupType}/{groupId}. Delete a group */\n \"delete\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.get` \u2014 GET /groups/{groupType}/{groupId}. Get a group by type and id */\n \"get\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.list` \u2014 GET /groups. List groups */\n \"list\"(args?: {\n \"type\"?: string | number | boolean;\n \"includeSystem\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.listDatabases` \u2014 GET /groups/{groupType}/{groupId}/databases. List databases shared with a group */\n \"listDatabases\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listDocuments` \u2014 GET /groups/{groupType}/{groupId}/documents. List documents shared with a group */\n \"listDocuments\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listMembers` \u2014 GET /groups/{groupType}/{groupId}/members. List a group's members */\n \"listMembers\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"include\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.listPendingInvitations` \u2014 GET /groups/{groupType}/{groupId}/pending-invitations. List a group's pending invitations */\n \"listPendingInvitations\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listUserMemberships` \u2014 GET /users/{userId}/memberships. List a user's group memberships */\n \"listUserMemberships\"(args: {\n \"userId\": string | number;\n \"includeSystem\"?: string | number | boolean;\n \"type\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.removeMember` \u2014 DELETE /groups/{groupType}/{groupId}/members/{userId}. Remove a specific member from a group */\n \"removeMember\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `groups.removeMemberByEmail` \u2014 DELETE /groups/{groupType}/{groupId}/members. Remove a group member or pending invitation by email */\n \"removeMemberByEmail\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.update` \u2014 PATCH /groups/{groupType}/{groupId}. Update a group */\n \"update\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"integrations\": {\n /** `integrations.call` \u2014 POST /integrations/{integrationKey}/call. Call an integration under a server function's grants */\n \"call\"(args: {\n \"integrationKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `integrations.list` \u2014 GET /integrations. List integrations configured for the app */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `integrations.proxy` \u2014 POST /integrations/{integrationKey}/proxy. Proxy a request through a configured integration */\n \"proxy\"(args: {\n \"integrationKey\": string | number;\n }): Promise<any>;\n };\n \"locks\": {\n /** `locks.list` \u2014 GET /locks. List all currently-held named locks in the app */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `locks.release` \u2014 POST /locks/release. Release a held named lock (requires the acquire handle) */\n \"release\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.renew` \u2014 POST /locks/renew. Extend the lease on a held named lock */\n \"renew\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.status` \u2014 POST /locks/status. Report the current holder of a named lock */\n \"status\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.tryAcquire` \u2014 POST /locks/acquire. Attempt to acquire a named lock (one attempt, or with waitMs a bounded server-side wait) */\n \"tryAcquire\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"notifications\": {\n /** `notifications.list` \u2014 GET /notifications. List the caller's in-app notification inbox (newest first) */\n \"list\"(args?: {\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `notifications.listDevices` \u2014 GET /me/push-tokens. List the caller's registered push devices */\n \"listDevices\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.markAllRead` \u2014 POST /notifications/read-all. Mark all of the caller's notifications as read */\n \"markAllRead\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.markRead` \u2014 PATCH /notifications/{notificationId}/read. Mark one of the caller's notifications as read */\n \"markRead\"(args: {\n \"notificationId\": string | number;\n }): Promise<any>;\n /** `notifications.registerDevice` \u2014 POST /me/push-tokens. Register (upsert) the caller's device push token */\n \"registerDevice\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `notifications.send` \u2014 POST /notifications/send. Send a notification to an app user (durable in-app inbox row + live WS frame) */\n \"send\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `notifications.unreadCount` \u2014 GET /notifications/unread-count. Count the caller's unread notifications */\n \"unreadCount\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.unregisterDevice` \u2014 DELETE /me/push-tokens/{token}. Unregister one of the caller's device push tokens */\n \"unregisterDevice\"(args: {\n \"token\": string | number;\n }): Promise<any>;\n };\n \"prompts\": {\n /** `prompts.execute` \u2014 POST /prompts/{promptKey}/execute. Execute a saved prompt */\n \"execute\"(args: {\n \"promptKey\": string | number;\n }): Promise<any>;\n /** `prompts.run` \u2014 POST /prompts/{promptKey}/run. Run a prompt under a server function's grants */\n \"run\"(args: {\n \"promptKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"resourceMetadata\": {\n /** `resourceMetadata.delete` \u2014 DELETE /resources/{resourceType}/{resourceId}/metadata/{category}. Delete a resource's metadata for a category (idempotent) */\n \"delete\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.get` \u2014 GET /resources/{resourceType}/{resourceId}/metadata/{category}. Read a resource's metadata for a category */\n \"get\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.getBatch` \u2014 POST /resources/metadata/batch. Batch-read resource metadata (partial success) */\n \"getBatch\"(args: {\n \"debug\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `resourceMetadata.list` \u2014 GET /resources/{resourceType}/{resourceId}/metadata. List all metadata categories on a resource */\n \"list\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.resolve` \u2014 POST /metadata/resolve. Resolve a resource by a category's unique metadata value */\n \"resolve\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `resourceMetadata.set` \u2014 PUT /resources/{resourceType}/{resourceId}/metadata/{category}. Write a resource's metadata for a category */\n \"set\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"secrets\": {\n /** `secrets.get` \u2014 GET /secrets/{name}. Read an app secret under a server function's grants */\n \"get\"(args: {\n \"name\": string | number;\n }): Promise<any>;\n };\n \"users\": {\n /** `users.getBasic` \u2014 GET /users/{userId}/basic. Get a user's basic public profile */\n \"getBasic\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.getProfiles` \u2014 POST /users/profiles. Look up user profiles in bulk */\n \"getProfiles\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `users.getRootDocument` \u2014 GET /users/{userId}/root-document. Get an app user's root document id */\n \"getRootDocument\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.list` \u2014 GET /users. List app users */\n \"list\"(args?: {\n \"email\"?: string | number | boolean;\n \"userId\"?: string | number | boolean;\n \"name\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `users.lookup` \u2014 GET /users/lookup. Look up a user by identifier */\n \"lookup\"(args?: {\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /**\n * `users.remove` \u2014 DELETE /users/{userId}. DEPRECATED \u2014 remove a user from the app; use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)\n * @deprecated Use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)\n */\n \"remove\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.send` \u2014 POST /users/{userId}/send. Send a realtime message to a member of this app */\n \"send\"(args: {\n \"userId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `users.setRole` \u2014 PUT /users/{userId}/role. Set a user's app role */\n \"setRole\"(args: {\n \"userId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n}\n\n/**\n * The app's database types, model by model \u2014 EMPTY here and filled by the\n * declaration `primitive config push` writes into the config tree's\n * `functions/` directory (#3182). A tree that has pushed once therefore types\n * `ctx.db` against its own schemas; one that has not gets the open form and\n * still compiles.\n */\nexport interface DatabaseSchemas {}\n\n/**\n * The type keys `ctx.db` accepts.\n *\n * Every key the augmentation declares, and NOTHING else, once a tree has\n * pushed: naming a type the app does not have is a compile error. Before that\n * \u2014 an unaugmented tree, a function written before the first push \u2014\n * `DatabaseSchemas` is empty and `keyof` it is `never`, which would make the\n * argument unwritable rather than open. So the empty case widens to `string`\n * and the handle is untyped instead of unusable.\n */\nexport type DatabaseTypeKeys = [keyof DatabaseSchemas] extends [never]\n ? string\n : keyof DatabaseSchemas & string;\n\n/** A model's row shape, or an open record for a type with no schema. */\nexport type DatabaseModels<K extends string> = K extends keyof DatabaseSchemas\n ? DatabaseSchemas[K]\n : Record<string, Record<string, unknown>>;\n\n/**\n * The app's functions, key by key \u2014 EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/`\n * directory (`primitive-function-types.d.ts`): each key's declared input and\n * output types, from its `inputSchema` and `outputSchema`. It is what types\n * `defineFunction(\"<key>\", handler)`.\n */\nexport interface FunctionSchemas {}\n\n/**\n * The keys `defineFunction(key, handler)` accepts: every key the augmentation\n * declares once a tree has pushed, so a key the tree does not declare is a\n * compile error \u2014 and `string` before that, the `DatabaseTypeKeys` rule, so an\n * unaugmented tree keeps compiling.\n */\nexport type FunctionKeys = [keyof FunctionSchemas] extends [never]\n ? string\n : keyof FunctionSchemas & string;\n\n/** A declared function's input type, or `any` when nothing is declared. */\nexport type FunctionInput<K extends string> = K extends keyof FunctionSchemas\n ? FunctionSchemas[K] extends { input: infer I }\n ? I\n : any\n : any;\n\n/** A declared function's output type, or `any` when nothing is declared. */\nexport type FunctionOutput<K extends string> = K extends keyof FunctionSchemas\n ? FunctionSchemas[K] extends { output: infer O }\n ? O\n : any\n : any;\n\n/**\n * The model names one database type addresses \u2014 its own, or any name at all\n * for a type that declares no schema (the DO is schemaless, so a grant on such\n * a type is legal and there is simply nothing to narrow to).\n */\nexport type DatabaseModelNames<TModels> = [keyof TModels] extends [never]\n ? string\n : keyof TModels & string;\n\n/**\n * A row as the platform HANDS IT BACK: whatever the schema declared, plus the\n * record identity the platform owns (#3450).\n *\n * Every stored record has an `id`. A save that arrives without one is given a\n * ULID, a projection always keeps it, and `delete` and `patch` take nothing\n * else \u2014 so a function that queries a model and then moves one of its rows\n * needs the id of the row it just read. A schema is free to say nothing about\n * that field, and most do; the identity is the platform's, not the schema's,\n * so it is added here rather than rendered into each declaration.\n *\n * A declared `id` is REPLACED, never intersected: one declared optional would\n * stay optional on a read row it is always present on, and one declared with\n * some other type would intersect to `never` and be unusable. The platform\n * stamps a string whatever the schema says.\n *\n * An `any` row stays `any` \u2014 `DatabaseHandle<any>` is `defineQuery`'s default\n * handle, and turning its rows into an object with one known member would\n * narrow code that was deliberately left open.\n *\n * Writes are untouched: every one of them takes `Partial<TRow>`, so a row a\n * function BUILDS still needs no id.\n */\nexport type PlatformRow<TRow> = 0 extends 1 & TRow\n ? TRow\n : Omit<TRow, \"id\"> & { id: string };\n\n/** One model's row shape, open when the type declares no schema. */\nexport type DatabaseModelRow<TModels, M extends string> =\n M extends keyof TModels\n ? PlatformRow<TModels[M]>\n : Record<string, unknown> & { id: string };\n\n/**\n * One model of one database, scoped: the `modelName` every records call needs\n * is bound once, so a call names an operation and its own arguments.\n *\n * Filters and options are ordinary objects. Inline filter typing arrives with\n * unified schemas \u2014 the intent's decision, not an omission \u2014 so what is typed\n * today is the model name and the row shape a read hands back.\n */\nexport type ModelScopedBody<TBody = Record<string, unknown>> = TBody & {\n /**\n * Bound by the handle. Reserved so a body cannot look like a second way to\n * choose a model: the runtime assigns the handle's own model last, and a row\n * type that said otherwise would be a lie about what came back.\n */\n modelName?: never;\n};\n\n/**\n * One write inside a model-scoped batch. Every batch verb is a write, so a\n * batch on a model needs that model's write grant whatever the ops are.\n */\nexport type ModelBatchOperation<TRow> = {\n op: \"save\" | \"patch\" | \"delete\" | \"increment\" | \"addToSet\" | \"removeFromSet\";\n id?: string;\n data?: Partial<TRow>;\n /** Bound by the handle, for the same reason every other call's is. */\n modelName?: never;\n [key: string]: unknown;\n};\n\nexport interface DatabaseModelHandle<TRow> {\n /**\n * One page of this model's rows, in the decided envelope \u2014 `{ items,\n * hasMore, nextCursor? }` (#3287), the same shape `ctx.doc(...)`,\n * `ctx.users.list` and the client library answer. The route's own wire\n * shape is unchanged; the SDK is where the one name lives, so shared paging\n * code can be written once.\n */\n query(body?: ModelScopedBody): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;\n count(body?: ModelScopedBody): Promise<any>;\n aggregate(body: ModelScopedBody): Promise<any>;\n save(body: ModelScopedBody<{ id?: string; data: Partial<TRow>; [key: string]: unknown }>): Promise<any>;\n /**\n * Change some fields of ONE row \u2014 `databases.records.patch`, with this\n * handle's model bound (#3450).\n *\n * The record id is positional and the body may not carry another, for the\n * same reason it may not name another model: the runtime assigns both LAST,\n * so a body that appeared to choose either would be a lie about which row\n * moved. `condition`, `stringSets` and the rest of the operation's own keys\n * pass through untouched.\n */\n patch(\n recordId: string,\n body: ModelScopedBody<{ data: Partial<TRow>; id?: never; [key: string]: unknown }>\n ): Promise<any>;\n /**\n * Remove ONE row by the id a read handed back \u2014 `databases.records.delete`,\n * with this handle's model bound (#3450). An optional `condition` makes it\n * conditional, and travels untouched.\n */\n delete(\n recordId: string,\n body?: ModelScopedBody<{ condition?: Record<string, unknown>; id?: never }>\n ): Promise<any>;\n /** Several writes to THIS model in one request; the binding is per item. */\n batch(body: {\n operations: Array<ModelBatchOperation<TRow>>;\n atomic?: boolean;\n }): Promise<any>;\n}\n\n/** One database, typed by the database TYPE key its grant names. */\nexport interface DatabaseHandle<TModels> {\n /** The database this handle addresses \u2014 part of every query cache key. */\n databaseId: string;\n /** The type key this handle was opened with. */\n databaseType: string;\n model<M extends DatabaseModelNames<TModels>>(\n modelName: M\n ): DatabaseModelHandle<DatabaseModelRow<TModels, M>>;\n /**\n * A batch may also SPAN models, and then it names each one itself \u2014 the\n * model-scoped form above is the typed way to write the common case.\n */\n batch(body: {\n operations: Array<Record<string, unknown>>;\n atomic?: boolean;\n }): Promise<any>;\n /** Run one of the database type's prepared operations under this function's grants. */\n runOperation(name: string, params?: Record<string, unknown>): Promise<any>;\n}\n\n/**\n * The app's DOCUMENT models \u2014 EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/` directory\n * (`primitive-document-types.d.ts`, from the project's `models/models.toml`).\n * A project with no document schema gets the open form and still compiles.\n */\nexport interface DocumentSchemas {}\n\n/** The model names `ctx.doc(id).model()` accepts \u2014 every declared one, or `string` before a push. */\nexport type DocumentModelNames = [keyof DocumentSchemas] extends [never]\n ? string\n : keyof DocumentSchemas & string;\n\n/**\n * A document model's row shape, or an open record for an undeclared schema \u2014\n * carrying the platform's record identity either way (#3450), by the same rule\n * and for the same reason as a database row: the records DO is one\n * implementation, and `patch` and `delete` here take an id too.\n */\nexport type DocumentModelRow<M extends string> = M extends keyof DocumentSchemas\n ? PlatformRow<DocumentSchemas[M]>\n : Record<string, unknown> & { id: string };\n\n/** The options a document model read takes: a filter object (or its JSON), a page size, a cursor. */\nexport interface DocumentQueryOptions {\n filter?: Record<string, unknown> | string;\n limit?: number;\n cursor?: string;\n /**\n * The document format you expect (#3764). When it disagrees with the format\n * the platform resolved, the call is refused with a 409\n * DOCUMENT_FORMAT_MISMATCH rather than answered out of the wrong tables.\n * Usually stated once on the handle, as ctx.doc(id, { documentFormat: 2 }),\n * rather than per read.\n */\n documentFormat?: 1 | 2;\n}\n\n/**\n * One document model, bound to its document and its model name \u2014 a thin\n * binding over `ctx.api.documents.records.*` with the route's own shapes.\n */\n/**\n * One op of a document `batch` \u2014 the `documents.records.bulk` blob's shape,\n * typed to this handle's model (#3455).\n *\n * `model` is NOT a member: the handle already names it and assigns it last, so\n * a multi-model blob stays on the raw `ctx.api.documents.records.bulk`\n * operation rather than becoming a second way to say the same thing.\n */\nexport type DocumentBatchOp<TRow> =\n | { action: \"create\" | \"patch\"; id: string; data: Partial<TRow>; precondition?: Record<string, unknown> }\n | { action: \"delete\"; id: string; precondition?: Record<string, unknown> };\n\n/** What `documents.records.bulk` answers: the blob's aggregate effect. */\nexport interface DocumentBulkResult {\n applied: number;\n added: Array<{ model: string; id: string }>;\n updated: Array<{ model: string; id: string }>;\n deleted: number;\n}\n\nexport interface DocumentModelHandle<TRow> {\n query(options?: DocumentQueryOptions): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;\n count(options?: { filter?: Record<string, unknown> | string }): Promise<{ count: number }>;\n aggregate(body: Record<string, unknown>): Promise<any>;\n save(body: { id: string; data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;\n patch(recordId: string, body: { data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;\n delete(recordId: string): Promise<{ deleted: boolean }>;\n /**\n * Apply an ordered blob of this model's ops in ONE transaction \u2014 all of it\n * commits or none of it does, and connected clients see one update.\n *\n * One model's ops, by construction: every op's `model` is this handle's.\n * A blob that spans models is the raw `ctx.api.documents.records.bulk`\n * operation's job.\n */\n batch(ops: Array<DocumentBatchOp<TRow>>): Promise<DocumentBulkResult>;\n}\n\n/** A document, addressed once; its models are typed from `DocumentSchemas`. */\nexport interface DocumentHandle {\n documentId: string;\n model<M extends DocumentModelNames>(modelName: M): DocumentModelHandle<DocumentModelRow<M>>;\n}\n\n/**\n * One call through a granted integration \u2014 #3183.\n *\n * `path` is RELATIVE to the integration's `baseUrl`, and the host is the\n * integration's: the platform resolves and normalizes the path before checking\n * it against `allowedPaths`, so a protocol-relative path or a `..` segment is\n * refused rather than silently sending the request somewhere else.\n */\nexport interface IntegrationCallRequest {\n /** Must be in the integration's `allowedMethods`. Defaults to its own default. */\n method?: string;\n /** Relative to the integration's `baseUrl`. */\n path?: string;\n query?: Record<string, unknown>;\n headers?: Record<string, string>;\n body?: unknown;\n /** form-urlencoded body; not combinable with `body`. */\n form?: Record<string, unknown>;\n bodyMode?: \"json\" | \"raw\" | \"multipart\";\n}\n\n/** What the upstream answered, as the platform saw it. */\nexport interface IntegrationCallResult {\n status: number;\n headers: Record<string, string>;\n body: unknown;\n durationMs: number;\n traceId: string;\n /** Set when the platform or the upstream refused; absent on success. */\n errorCode?: string;\n}\n\n/** What a prompt run is given \u2014 the member execute route's own body. */\nexport interface PromptRunArgs {\n /**\n * The prompt's variables. A `kind = \"decisions\"` prompt takes\n * `{ state, criteria? }`: `state` is the value its questions are asked\n * about, and `criteria.<question>` supplies this run's options for each\n * choice question declared `criteriaSource = \"dynamic\"` \u2014 a table of option\n * key = description (a string or a JSON object), at least two entries (#3813).\n */\n variables?: Record<string, unknown>;\n /** Run against a different model for this call only. */\n modelOverride?: string;\n /** Pin a specific config OF THIS PROMPT; defaults to its active one. */\n configId?: string;\n}\n\n/**\n * The app's PROMPTS \u2014 EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/` directory\n * (`primitive-prompt-types.d.ts`, from the tree's `prompts/*.toml`). A prompt\n * that declares an `outputSchema` carries `{ output: <Key>PromptOutput }`; one\n * that declares none carries `{}`, so reading `parsed.field` on it is a\n * compile error rather than a runtime `undefined`.\n */\nexport interface PromptSchemas {}\n\n/**\n * The keys whose declaration is an AGENT (`kind = \"agent\"`, #3798): entries\n * carrying `{ agent: \u2026 }` instead of an output. An agent runs turn by turn in\n * a session and never single-shot, so these are the keys `PromptKeys` leaves\n * out.\n */\nexport type AgentKeys = {\n [K in keyof PromptSchemas]: PromptSchemas[K] extends { agent: unknown } ? K : never;\n}[keyof PromptSchemas] &\n string;\n\n/**\n * The keys `ctx.prompts.run` accepts \u2014 every declared one that is not an\n * agent, or `string` before a push.\n */\nexport type PromptKeys = [keyof PromptSchemas] extends [never]\n ? string\n : Exclude<keyof PromptSchemas & string, AgentKeys>;\n\n/** One agent's session variables, typed from its `inputSchema` (#3798). */\nexport type AgentVariables<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { variables: infer V };\n}\n ? V\n : never;\n\n/**\n * The keys `ctx.agents.createSession` accepts \u2014 #3803: every declared agent,\n * or `string` before the tree has pushed any prompt (the `PromptKeys`\n * rule).\n */\nexport type SessionAgentKeys = [keyof PromptSchemas] extends [never]\n ? string\n : AgentKeys;\n\n/**\n * What `ctx.agents.createSession` takes \u2014 #3803. Typed by the agent's key:\n * `variables` is that agent's `inputSchema` (any object before a push),\n * and the platform validates it again against the schema as pushed.\n */\nexport interface AgentSessionCreateOptions<K extends SessionAgentKeys> {\n /** The key of an agent prompt (`kind = \"agent\"`). */\n agent: K;\n /** The session's variables; at most 16 KiB of JSON. */\n variables?: K extends AgentKeys ? AgentVariables<K> : Record<string, unknown>;\n /** Free text the app groups sessions by, 1 to 256 characters. */\n scope?: string;\n /** 1 to 255 characters; defaults to the agent's display name. */\n title?: string;\n}\n\n/** What `ctx.agents.createSession` answers \u2014 #3803. */\nexport interface AgentSessionCreateResult {\n /** The session: what the app keeps and uses for everything but opening. */\n sessionId: string;\n /** The session's conversation document, opened with the document client. */\n documentId: string;\n}\n\n/** One agent's client tools, by name: each one's `input` and `output` (#3798). */\nexport type AgentClientTools<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { clientTools: infer T };\n}\n ? T\n : never;\n\n/** One agent's event kinds, by name: each one's payload (#3798). */\nexport type AgentEvents<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { events: infer E };\n}\n ? E\n : never;\n\n/** One prompt's declared output type, or `unknown` where none is declared. */\nexport type PromptOutput<K extends string> = K extends keyof PromptSchemas\n ? PromptSchemas[K] extends { output: infer O }\n ? O\n : unknown\n : unknown;\n\n/**\n * Why a prompt's own answer was refused \u2014 #3330. Never set on a PROVIDER\n * failure, which is what makes \"the model returned the wrong shape\"\n * distinguishable from \"the model failed\".\n */\nexport type PromptOutputErrorCode =\n | \"PROMPT_OUTPUT_NOT_JSON\"\n | \"PROMPT_OUTPUT_SCHEMA_VIOLATION\";\n\n/**\n * Every code the envelope's `errorCode` can carry \u2014 #3663, #3813.\n *\n * `PROMPT_UPSTREAM_TIMEOUT` is the one that is NOT about the prompt's own\n * answer: the provider ran out of time, so there was no answer to refuse. It\n * is the only provider failure that sets `errorCode` at all, which is what\n * leaves \"the model returned the wrong shape\" distinguishable from \"the model\n * failed\" while still letting a caller retry the one failure worth retrying.\n *\n * `PROMPT_CRITERIA_INVALID` is the run that never reached a provider: a\n * decisions run's `variables.criteria` was refused before the call, so\n * nothing was billed (#3813).\n *\n * `PROMPT_STRICT_OUTPUT_SCHEMA_MISSING` never reached one either: the config\n * sets `strictOutput = true` and the prompt has no usable `outputSchema` to\n * send as the strict `json_schema` (#3801).\n */\nexport type PromptRunErrorCode =\n | PromptOutputErrorCode\n | \"PROMPT_UPSTREAM_TIMEOUT\"\n | \"PROMPT_CRITERIA_INVALID\"\n | \"PROMPT_STRICT_OUTPUT_SCHEMA_MISSING\";\n\n/** A prompt that declares an output shape, when the answer matched it. */\nexport interface PromptRunSuccess<TParsed> {\n success: true;\n output: string;\n /** The parsed, validated answer \u2014 no caller-side `JSON.parse` (#3330). */\n parsed: TParsed;\n error?: null;\n errorCode?: null;\n metrics?: Record<string, unknown>;\n configId: string;\n}\n\n/**\n * The failure arm, whichever failed. `errorCode` is set for a SHAPE failure,\n * for a refused run (`PROMPT_CRITERIA_INVALID`, #3813), and for a provider\n * one only when the upstream TIMED OUT (#3663); `output` carries the text\n * either way, which is where the model's own value lives \u2014 a validation\n * `error` names paths and schema constraints only.\n */\nexport interface PromptRunFailure {\n success: false;\n output: string;\n error: string | null;\n errorCode?: PromptRunErrorCode | null;\n parsed?: undefined;\n metrics?: Record<string, unknown>;\n configId: string;\n /**\n * The upstream provider's HTTP status, when the call reached a provider and\n * it answered \u2014 #3663. This is what a retry decision is made on: a 504 or a\n * 503 is worth another attempt, a 400 on a refused payload is not.\n *\n * It does not depend on which provider the config named: Gemini and\n * OpenRouter report it identically. It is absent when no provider answer was\n * observed \u2014 an unset key, an oversized payload, a completion that came back\n * empty \u2014 so a number here is always the provider's own.\n */\n upstreamStatus?: number;\n}\n\n/** The envelope for a key whose declaration says nothing about its output. */\nexport interface PromptRunOpenResult {\n success: boolean;\n output: string;\n /**\n * Present when the config that ran declares `outputFormat = \"json\"` and the\n * text parsed. Untyped: nothing declared its shape.\n */\n parsed?: unknown;\n error?: string | null;\n errorCode?: PromptRunErrorCode | null;\n metrics?: Record<string, unknown>;\n configId: string;\n /** The upstream provider's HTTP status on a provider failure \u2014 #3663. */\n upstreamStatus?: number;\n}\n\n/**\n * The member execute envelope, plus what the prompt's own declaration adds.\n *\n * For a key whose `prompts/<key>.toml` declares an `outputSchema`, this is a\n * discriminated union: narrow on `success` and `parsed` is the declared type,\n * required. For every other key \u2014 and in a tree that has not pushed \u2014 it is\n * the open shape, with `parsed` optional and `unknown`.\n */\nexport type PromptRunResult<K extends string = string> = K extends keyof PromptSchemas\n ? PromptSchemas[K] extends { output: infer O }\n ? PromptRunSuccess<O> | PromptRunFailure\n : PromptRunOpenResult\n : PromptRunOpenResult;\n\n/** What a send delivered to. */\nexport interface SendResult {\n /** Unique live connections the frame was sent to. Zero is a success. */\n connections: number;\n /** True when the per-user connection ceiling stopped the fanout. */\n truncated: boolean;\n}\n\n/** Who a channel grant is for, and for how long \u2014 #3184. */\nexport interface ChannelAuthorizeOptions {\n /**\n * The member the grant names. Caller mode defaults to the invoking caller;\n * system mode has no caller and must say.\n */\n userId?: string;\n /** Default 300 s, clamped to the platform ceiling of 900 s. */\n ttlSeconds?: number;\n}\n\n/** The credential a client presents on the WebSocket it already has. */\nexport interface ChannelGrantResult {\n channel: string;\n /** The signed grant. Hand it to the client; it is not readable here. */\n grant: string;\n /** Epoch milliseconds. Expiry is the only revocation a channel has. */\n expiresAt: number;\n}\n\n/** Where to start and how big a page to take \u2014 #3280. */\nexport interface UserPageOptions {\n /** Page size. Capped by the route at 100. */\n limit?: number;\n /** The `nextCursor` of the page before this one. */\n cursor?: string;\n}\n\n/** One user on the roster, as the platform's own users route reports them. */\nexport interface UserPageItem {\n userId: string;\n email: string | null;\n name: string | null;\n avatarUrl: string | null;\n role: string;\n addedAt: string | null;\n status: string;\n disabledAt: string | null;\n [key: string]: unknown;\n}\n\n/** The decided paged envelope, the same shape every paged read answers. */\nexport interface UserPage {\n items: UserPageItem[];\n hasMore: boolean;\n /** Absent on the last page. */\n nextCursor?: string;\n}\n\n/** How a nested start is keyed and labelled \u2014 #3280. */\nexport interface FunctionStartOptions {\n /**\n * Idempotency key, scoped to the tree's root initiator and the resolved\n * context document: a repeat replays the run that already exists rather than\n * starting a second. At most 100 characters.\n */\n runKey?: string;\n /**\n * The document the child's run is keyed under. Defaults through the\n * inheritance rule: the parent run's context, else the root caller's root\n * document, else `fn:<the root function's id>`. At most 100 characters.\n */\n contextDocId?: string;\n /** Caller metadata, at most 1 KB encoded. */\n meta?: Record<string, unknown>;\n}\n\n/** The start envelope, the same one a workflow start answers with \u2014 #3280. */\nexport interface FunctionStartResult {\n /** Poll this on the platform's run-status route. */\n runId: string;\n runKey: string;\n instanceId: string;\n status: string;\n /**\n * True when `runKey` already named a run in this tree, which this envelope\n * describes. That is what makes a run key a singleton.\n */\n existing?: boolean;\n}\n\n/** A held named lock, as `ctx.locks.acquire` hands it back \u2014 #3930. */\nexport interface LockHandle {\n key: string;\n handleId: string;\n leaseExpiresAt: string;\n}\n\n/** How long to hold, and how long to wait \u2014 #3930. */\nexport interface LockAcquireOptions {\n /** The lease, in milliseconds (at most 24 h). Renew or release before it lapses. */\n ttlMs: number;\n /**\n * How long to wait for the key, in milliseconds, at most one hour. Under the\n * request runtime it must also fit the invocation's remaining budget.\n */\n timeoutMs: number;\n /**\n * Who this hold belongs to. Defaults to `ctx.runId` when the invocation\n * has a run, so a resumed slice re-takes its own hold with a fresh handle\n * rather than waiting on it.\n */\n owner?: string;\n}\n\n/**\n * The answer to a blocking acquire \u2014 #3930. Never a throw for \"not acquired\":\n * a refusal carries the last contention seen, and `rateLimited` says the\n * last attempt was refused by the acquire rate limit rather than by a holder.\n */\nexport type LockAcquireResult =\n | { acquired: true; handle: LockHandle }\n | {\n acquired: false;\n timedOut: true;\n rateLimited: boolean;\n heldBy: string | null;\n holderKind: string | null;\n owner: string | null;\n leaseExpiresAt: string | null;\n };\n\n/** The answer to `ctx.locks.release`. */\nexport type LockReleaseResult =\n | { released: true }\n | { released: false; reason: \"not_holder\" | \"not_held\" };\n\nexport interface FunctionContext {\n /** The HTTP caller, or null for a webhook or cron fire. */\n user: FunctionUser | null;\n trigger: FunctionTrigger;\n /**\n * Which RUNTIME is hosting this code \u2014 #3482.\n *\n * Beside `trigger`, which says which DOOR fired, and they are different\n * questions: an HTTP call is whichever runtime the caller chose\n * (`invoke` or `start`), a cron fire is always a task and a webhook\n * delivery is always a request.\n *\n * To REFUSE a runtime rather than branch on it, call\n * `assertRuntime(\"task\")` \u2014 at module scope to refuse it outright, or in\n * the handler to refuse one call.\n */\n runtime: \"request\" | \"task\";\n /**\n * The RUN this invocation belongs to, or null \u2014 #3562.\n *\n * Set under the task runtime (every slice of the run, the first and every\n * resume) and for a webhook-fired request run, which writes a row. Null for\n * an HTTP `invoke`, which writes no run row at all.\n *\n * It is the deterministic OWNER a task run presents to re-take its own\n * lease: `ctx.api.locks.tryAcquire({ body: { key, ttlMs, owner: ctx.runId } })`\n * succeeds for the run that already holds the key, with a fresh handle.\n */\n runId: string | null;\n /**\n * The SLICE of the run this code is running in, or null \u2014 #3562.\n *\n * The same identifier `primitive functions runs` and the run-status\n * route's `slice.sliceId` report. A task run is a sequence of slices: it\n * changes when the run hibernates and wakes, which is how a handler can tell\n * a resume from a first pass.\n *\n * Null under the request runtime: a request invocation is not a slice.\n */\n sliceId: string | null;\n api: FunctionApi;\n /**\n * A typed handle over one database. The second argument is the database TYPE\n * key \u2014 the same key a `database:<type>/<model>:read|write` grant names \u2014\n * and it is what selects the models this handle knows (#3182).\n */\n db<K extends DatabaseTypeKeys>(\n databaseId: string,\n databaseType: K\n ): DatabaseHandle<DatabaseModels<K>>;\n /**\n * A typed handle over one document's record models, typed from the\n * project's `models/models.toml` \u2014 `ctx.db`'s shape for documents. It\n * confers nothing: every call is a `documents.records.*` operation on the\n * same authority.\n */\n doc(documentId: string, options?: { documentFormat?: 1 | 2 }): DocumentHandle;\n /**\n * Outbound HTTP, through a granted integration and nowhere else (#3183).\n *\n * A function has no raw network access: every `fetch` to a host that is not\n * the platform answers `FUNCTION_EGRESS_DENIED`, grant or no grant. What an\n * `integration:<key>` grant buys is this call, which the MAIN WORKER makes on\n * the function's behalf \u2014 which is why the integration's `{{secrets.*}}`\n * credentials can be injected into the request without ever being visible to\n * the code that asked for it.\n */\n integrations: {\n call(\n integrationKey: string,\n request?: IntegrationCallRequest\n ): Promise<IntegrationCallResult>;\n };\n /**\n * Start a TASK function from inside this one \u2014 #3280.\n *\n * The one nested door, and it is a START. A request function is code and\n * code composes by being IMPORTED, so there is no synchronous nested\n * invocation to reach for; a request-mode callee answers\n * `FUNCTION_MODE_MISMATCH`.\n *\n * The callee's `access` gate is not consulted \u2014 this function's own gate was\n * the authorization \u2014 and every run in the tree is keyed by whoever started\n * it, so the member who invoked the root polls and terminates them all.\n * Nesting is bounded at four levels.\n */\n functions: {\n start(\n functionKey: string,\n input?: unknown,\n options?: FunctionStartOptions\n ): Promise<FunctionStartResult>;\n };\n /**\n * Run one of the app's prompts, with nothing to declare (#3183, #3279).\n *\n * The prompt's `accessRule` is not consulted \u2014 it states which MEMBERS may\n * execute the prompt from a client, and the invocation gate is what\n * authorized this call. The provider request is bounded by the invocation's\n * own deadline.\n *\n * TYPED BY KEY (#3330). Where `prompts/<key>.toml` declares an\n * `outputSchema`, the platform parses the answer, validates it against that\n * schema and hands it back as `parsed`, typed \u2014 so the shape is written once\n * in TOML instead of restated as a `JSON.parse` at every call site. Where\n * only the config that ran declares `outputFormat = \"json\"`, `parsed` is\n * present but `unknown`. Where neither is declared the envelope is exactly\n * what it has always been.\n *\n * A shape the declaration refuses is `success: false` with an `errorCode`\n * (`PROMPT_OUTPUT_NOT_JSON` or `PROMPT_OUTPUT_SCHEMA_VIOLATION`) and the\n * text still in `output`; a PROVIDER failure has `error` and no\n * `errorCode`, so the two are told apart without guessing.\n *\n * Once a tree has pushed, a key it does not declare is a compile error.\n */\n prompts: {\n run<K extends PromptKeys>(\n promptKey: K,\n args?: PromptRunArgs\n ): Promise<PromptRunResult<K>>;\n };\n /**\n * Agent sessions (#3803, project `agents`).\n *\n * `createSession` creates a session owned by this invocation's caller and\n * answers `{ sessionId, documentId }`. It is allowed only in a run fired\n * over HTTP (`invoke`, or a `start` task) by a signed-in user; from a\n * manual run, a nested start, a workflow step, cron or a webhook it\n * rejects with `AGENT_SESSION_ORIGIN_REFUSED`, `details.origin` naming\n * it. Variables failing the agent's `inputSchema` reject with\n * `AGENT_SESSION_VARIABLES_INVALID` and `details.errors`.\n *\n * Once a tree has pushed, a key that is not an agent, and variables the\n * agent's schema refuses, are compile errors.\n */\n agents: {\n createSession<K extends SessionAgentKeys>(\n options: AgentSessionCreateOptions<K>\n ): Promise<AgentSessionCreateResult>;\n };\n /**\n * The value of one app secret, under a `secret:<NAME>` grant (#3183).\n *\n * Prefer `ctx.integrations.call` when the secret is a credential FOR an\n * integration: there the value is injected by the platform and never enters\n * the sandbox at all. This is for the cases an integration cannot express.\n *\n * Rejects with `FUNCTION_SECRET_NOT_FOUND` when the grant names a value\n * this environment has not been given \u2014 secrets are provisioned per\n * environment, out of band from the push.\n */\n secret(name: string): Promise<string>;\n /** The value of one app config var, under a `var:<NAME>` grant (#3183). */\n configVar(name: string): Promise<string>;\n /**\n * Realtime messages to this app's clients, under a `users:send` grant\n * (#3183).\n *\n * The recipient's client receives a `direct.message` frame carrying this\n * payload and the sending function's key. Presence is not guaranteed: a\n * member with no live socket answers `{ connections: 0 }` rather than an\n * error.\n */\n users: {\n /**\n * One page of the app's users \u2014 #3280.\n *\n * On the APP's system authority, whoever invoked the function: a member\n * who passes this function's gate reads whatever roster it chooses to\n * expose, so say who may in the function's own `access` expression.\n * `limit` is capped by the route at 100.\n */\n list(options?: UserPageOptions): Promise<UserPage>;\n /**\n * Every page of the app's users, in order \u2014 #3280.\n *\n * FOR A REQUEST FUNCTION AND A SINGLE-SLICE LOOP. A durable loop must take\n * its pages inside `step.do` with an EXPLICIT cursor: a memoized step does\n * not advance an iterator on resume, so an iteration across a sleep would\n * replay pages it had already taken.\n */\n iterate(options?: UserPageOptions): AsyncIterable<UserPage>;\n send(userId: string, payload: unknown): Promise<SendResult>;\n };\n /** The same frame to ONE connection, under a `connections:send` grant. */\n connections: {\n send(connectionId: string, payload: unknown): Promise<SendResult>;\n };\n /**\n * Realtime channels, under a `channel:<namespace>` grant that COVERS the\n * channel \u2014 #3184.\n *\n * `authorize` hands back a short-lived grant for ONE member to present on\n * the socket it already has; `publish` delivers a `channel.message` frame to\n * every connection that has joined and whose grant has not expired. Expiry is\n * the only revocation, so `expiresAt` comes back for the client to renew\n * ahead of \u2014 a renewal is another authorize and another subscribe.\n */\n channels: {\n authorize(\n channel: string,\n options?: ChannelAuthorizeOptions\n ): Promise<ChannelGrantResult>;\n publish(channel: string, payload: unknown): Promise<SendResult>;\n };\n /**\n * Named locks that WAIT \u2014 #3930. `ctx.api.locks.tryAcquire` is one attempt;\n * these wait for the key, up to `timeoutMs` (at most one hour).\n *\n * The owner defaults to `ctx.runId`, so a run never waits on its own hold:\n * a resumed slice, or a second call on a key the run already holds, re-takes\n * it at once with a fresh handle.\n *\n * Under the TASK runtime the wait is durable: each attempt is a step that\n * asks the platform to wait server-side for up to 30 s, so a wait costs one\n * platform call and one acquire slot per half-minute, no CPU, and the\n * slice's budget is refreshed at every attempt. It is not a suspension \u2014 the\n * engine does not hibernate a wait shorter than five minutes. Under the\n * REQUEST runtime the whole wait must fit the invocation's remaining budget,\n * or the call fails `FUNCTION_RUNTIME_REFUSED` before any attempt (a\n * webhook delivery has 5 s): hand longer waits to a task with\n * `ctx.functions.start`.\n */\n locks: {\n /**\n * Wait for `key`. Answers `acquired: true` with the handle, or\n * `acquired: false, timedOut: true` with the last contention seen.\n */\n acquire(key: string, options: LockAcquireOptions): Promise<LockAcquireResult>;\n /** Release a handle `acquire` handed back. */\n release(handle: LockHandle): Promise<LockReleaseResult>;\n /**\n * Acquire, run `fn`, and release in `finally` \u2014 on a return and on a\n * throw. Answers `fn`'s value; `fn`'s own error propagates after the\n * release. Throws an error named `LOCK_TIMEOUT` (`code` the same, the\n * contention in `details`) without running `fn` when the key is not\n * acquired within `timeoutMs`. A nested `withLock` on the same key in\n * one run re-enters, and its release frees the outer hold: use distinct\n * keys, or one wrapper.\n */\n withLock<T>(\n key: string,\n options: LockAcquireOptions,\n fn: (handle: LockHandle) => Promise<T>\n ): Promise<T>;\n };\n}\n\n/** How the wait between one step's retries grows. */\nexport type StepBackoff = \"constant\" | \"linear\" | \"exponential\";\n\n/**\n * The retry and timeout policy for ONE `step.do` \u2014 Cloudflare Workflows' own\n * step config.\n *\n * Under the TASK runner the platform forwards this object to Workflows\n * untouched, so these are its fields and its spellings: a duration is either a\n * number of milliseconds or a string Workflows parses (`\"10 seconds\"`,\n * `\"5 minutes\"`). Under the REQUEST runner `step.do` accepts a config and\n * ignores it \u2014 the body runs inline, and there is nothing to retry into.\n *\n * `stepPolicy.<family>` IS a `StepConfig`, so the platform's own defaults\n * hand straight to `step.do` (#3657). The shape is closed on purpose: a key\n * outside it \u2014 `retry` for `retries`, `timeoutMs` for `timeout` \u2014 is a\n * refusal at `config push` rather than an option the engine silently drops.\n */\nexport interface StepConfig {\n retries?: { limit: number; delay: string | number; backoff?: StepBackoff };\n timeout?: string | number;\n}\n\n/**\n * The step handle. `step` is the third argument under BOTH runners, so the\n * same body runs either way \u2014 which is what `mode = \"any\"` is for (#3454).\n *\n * Under the TASK runner it is Cloudflare Workflows' `WorkflowStep`, forwarded\n * untouched: `step.do` results are memoized and replayed, and `step.sleep`\n * hibernates.\n *\n * Under the REQUEST runner it is the platform's own, bounded by the request's\n * clock: `do` executes the body inline (there is no engine to memoize into,\n * and nothing is replayed); `sleep` and `sleepUntil` REALLY wait when the\n * remaining request budget covers the duration, and otherwise fail the\n * invocation with `errorCode: \"FUNCTION_RUNTIME_REFUSED\"` saying to start the\n * function as a task; `waitForEvent` fails the same way, because nothing can\n * deliver an event to an invocation that has to return now. The thrown error's\n * `name` is `STEP_NOT_AVAILABLE` in every case, so a body that catches it\n * keeps catching it.\n */\nexport interface FunctionStep {\n do<T>(name: string, body: () => T | Promise<T>): Promise<T>;\n do<T>(\n name: string,\n config: StepConfig,\n body: () => T | Promise<T>\n ): Promise<T>;\n sleep(name: string, duration: number | string): Promise<void>;\n sleepUntil(name: string, timestamp: Date | number): Promise<void>;\n waitForEvent<T = unknown>(\n name: string,\n options: Record<string, unknown>\n ): Promise<T>;\n}\n\nexport declare const SDK_STUB_VERSION: string;\n\n/**\n * Thrown by `assertRuntime` when this function is running under the other\n * runtime \u2014 #3482.\n *\n * The platform settles it as `status: \"failed\"` with\n * `errorCode: \"FUNCTION_RUNTIME_REFUSED\"`, on a request invocation's\n * envelope and on a task run's row and record alike.\n */\nexport declare class FunctionRuntimeError extends Error {\n name: \"FUNCTION_RUNTIME_REFUSED\";\n /** The runtime this invocation is actually running under. */\n runtime: \"request\" | \"task\";\n /** The runtime the function asked for. */\n required: \"request\" | \"task\";\n}\n\n/**\n * Refuse the runtime this function was not written for \u2014 #3482.\n *\n * A function is a function and the caller picks the runtime at each call, so\n * nothing in config says which one a function may run under. This is the lock,\n * and it lives in the one place that can always be right about the code:\n *\n * ```ts\n * import { assertRuntime } from \"primitive-functions\";\n *\n * // At module scope: this function is never runnable inside a request.\n * assertRuntime(\"task\");\n *\n * export default async function (input, ctx, step) {\n * await step.sleep(\"cool-off\", \"1 hour\");\n * return { ok: true };\n * }\n * ```\n *\n * Returns when the runtimes match; otherwise throws\n * {@link FunctionRuntimeError}, which the platform settles as\n * `status: \"failed\"` with `errorCode: \"FUNCTION_RUNTIME_REFUSED\"` and a\n * message naming both runtimes and the verb that takes the one required.\n */\nexport declare function assertRuntime(required: \"request\" | \"task\"): void;\n\n/**\n * The handler a function exports, typed for one declared key.\n *\n * `step` is the third argument under BOTH runners (#3186, #3454). A task run\n * gets the engine's live `WorkflowStep`; a request invocation gets the\n * platform's own, where `do` runs the body inline and a wait the request\n * budget cannot cover fails the invocation naming the task runner \u2014 so a\n * task-authored body can be exercised as a request, and the one place the two\n * genuinely differ says so rather than pretending.\n */\nexport type FunctionHandler<TInput, TOutput> = (\n input: TInput,\n ctx: FunctionContext,\n step: FunctionStep\n) => Promise<TOutput>;\n\n/**\n * Declare a server function's handler, typed from its declaration.\n *\n * The KEYED form, `defineFunction(\"<key>\", handler)`, is typed from the\n * `FunctionSchemas` augmentation `primitive config push` writes beside the\n * sources: `input` is the key's declared input, the return is checked against\n * its declared output, and a key the tree does not declare is a compile error.\n * `config push` also refuses an entry whose key names another file's. In a\n * tree that has not pushed yet the key is any string and both types are `any`.\n *\n * The UNKEYED form is what it always was: author-declared generics. Both\n * styles reach the platform bootstrap identically \u2014 a plain default export\n * taking `(input, ctx, step)` runs exactly as a wrapped one does \u2014 so this is\n * a typing and intent marker, not a different calling convention.\n */\nexport declare function defineFunction<K extends FunctionKeys>(\n key: K,\n handler: (\n input: FunctionInput<K>,\n ctx: FunctionContext,\n step: FunctionStep\n ) => FunctionOutput<K> | Promise<FunctionOutput<K>>\n): FunctionHandler<FunctionInput<K>, FunctionOutput<K>> & { functionKey: K };\nexport declare function defineFunction<TInput = unknown, TOutput = unknown>(\n handler: (\n input: TInput,\n ctx: FunctionContext,\n step: FunctionStep\n ) => TOutput | Promise<TOutput>\n): FunctionHandler<TInput, TOutput>;\n\n/**\n * One declared parameter of a registered query.\n *\n * `caller: true` (or `type: \"$caller\"`) is the intent's IMMUTABLE binding:\n * the platform injects the invocation's user and refuses a call that supplies\n * the parameter itself.\n */\n/** The scalar parameter types, and an array parameter's element types. */\nexport type QueryScalarParamType = \"string\" | \"number\" | \"boolean\" | \"any\";\n\nexport interface QueryParamSpec {\n type?: QueryScalarParamType | \"$caller\" | \"array\";\n /** For `type: \"array\"` \u2014 the element type; absent means any element. */\n items?: { type: QueryScalarParamType };\n caller?: boolean;\n optional?: boolean;\n default?: unknown;\n}\n\n/** A scalar parameter type's TypeScript type. */\nexport type QueryScalarValue<T> = T extends \"string\"\n ? string\n : T extends \"number\"\n ? number\n : T extends \"boolean\"\n ? boolean\n : T extends \"$caller\"\n ? string\n : any;\n\n/** The value `run` receives for one declared parameter. */\nexport type QueryParamValue<S> = S extends { caller: true }\n ? string\n : S extends { type: \"array\"; items: { type: infer I } }\n ? QueryScalarValue<I>[]\n : S extends { type: \"array\" }\n ? unknown[]\n : S extends { type: infer T }\n ? QueryScalarValue<T>\n : any;\n\ntype QueryOptionalKeys<P> = {\n [K in keyof P]: P[K] extends { optional: true } ? K : never;\n}[keyof P];\n\n/**\n * `run`'s `params`, typed from the declaration: scalars as their scalar,\n * `$caller` as a string, an array as `T[]`, an `optional: true` parameter\n * as an optional key (a parameter with a default is always present). An\n * undeclared name is a compile error.\n */\nexport type QueryParams<P> = {\n [K in Exclude<keyof P, QueryOptionalKeys<P>>]: QueryParamValue<P[K]>;\n} & {\n [K in QueryOptionalKeys<P>]?: QueryParamValue<P[K]>;\n};\n\n/** A registration's definition with its parameters DECLARED, so `run` is typed from them. */\nexport interface TypedQueryDefinition<TDb, TSpec extends Record<string, QueryParamSpec>, TResult> {\n models: string[];\n params?: TSpec;\n cache?: { ttlMs: number };\n run: (db: TDb, params: QueryParams<TSpec>) => TResult | Promise<TResult>;\n}\n\nexport interface QueryDefinition<TDb, TParams, TResult> {\n /** The models this query touches. Caching is off unless the run matches. */\n models: string[];\n params?: Record<string, QueryParamSpec>;\n /**\n * Cache the answer for `ttlMs` \u2014 capped by the platform, and applied ONLY\n * when the run is verified: every model the body touched was declared, and\n * no prepared operation was used. A write through the handle drops the\n * entries that read the written model.\n */\n cache?: { ttlMs: number };\n run: (db: TDb, params: TParams) => TResult | Promise<TResult>;\n}\n\n/**\n * Register a named query over a database handle (#3187).\n *\n * A registration helper, not a language: `run` is ordinary code over the same\n * typed handle, and what registration adds is a name, declared parameters\n * (validated, coerced and defaulted), the `$caller` binding, and a cache the\n * platform may use when it can verify what the run touched.\n *\n * Register at MODULE scope: a registration made inside the handler still works\n * for direct calls but is invisible to `config push`'s manifest.\n *\n * `run`'s `params` are TYPED from the declaration (the first overload,\n * inferred with a `const` type parameter): a scalar as its scalar, `$caller`\n * as a string, `{ type: \"array\", items: { type: \"string\" } }` as `string[]`,\n * an `optional: true` parameter as an optional key; an undeclared name inside\n * `run` is a compile error. A declared default is coerced to the declared\n * type at registration, so `run` receives what the declaration promises. The\n * second overload keeps an explicit `TParams`.\n */\nexport declare function defineQuery<\n const TSpec extends Record<string, QueryParamSpec>,\n TDb = DatabaseHandle<any>,\n TResult = any\n>(\n name: string,\n definition: TypedQueryDefinition<TDb, TSpec, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\nexport declare function defineQuery<\n TDb = DatabaseHandle<any>,\n TParams = Record<string, any>,\n TResult = any\n>(\n name: string,\n definition: QueryDefinition<TDb, TParams, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\n\n/** The same, for a registration that writes. A mutation is never cached. */\nexport declare function defineMutation<\n const TSpec extends Record<string, QueryParamSpec>,\n TDb = DatabaseHandle<any>,\n TResult = any\n>(\n name: string,\n definition: TypedQueryDefinition<TDb, TSpec, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\nexport declare function defineMutation<\n TDb = DatabaseHandle<any>,\n TParams = Record<string, any>,\n TResult = any\n>(\n name: string,\n definition: QueryDefinition<TDb, TParams, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\n\n/** The platform's cap on a registered query's cache TTL, in milliseconds. */\nexport declare const MAX_QUERY_CACHE_TTL_MS: number;\n\n/**\n * Map over items with BOUNDED concurrency (#3187). Results come back in the\n * input's order; the first rejection wins and nothing new is started after it.\n *\n * The bound matters inside a sandbox: an unbounded fan-out over a page of rows\n * spends the whole subrequest ceiling in one line.\n */\nexport declare function pMap<T, R>(\n items: Iterable<T>,\n mapper: (item: T, index: number) => R | Promise<R>,\n options?: { concurrency?: number }\n): Promise<R[]>;\n\n/** The default concurrency `pMap` applies when none is given. */\nexport declare const PMAP_DEFAULT_CONCURRENCY: number;\n\n/**\n * A time-ordered ULID.\n *\n * GENERATE IT INSIDE `step.do`. A durable run re-executes its handler on\n * every resume and memoizes only what a step returned, so an id minted at the\n * top of a handler is a different id after a sleep \u2014 and whatever it was\n * written into is orphaned.\n */\nexport declare function ulid(): string;\n\n/** One family's durable `step.do` configuration \u2014 a `StepConfig` with every field decided. */\nexport interface StepPolicy extends StepConfig {\n retries: { limit: number; delay: string; backoff: StepBackoff };\n timeout: string;\n}\n\n/**\n * The per-family step policies the DSL runners use, generated from their own\n * timeout module (#3187):\n *\n * await step.do(\"send-receipt\", stepPolicy.email, () =>\n * ctx.api.email.send({ body: { to, subject, htmlBody } }));\n *\n * `retries: 0` on email and the AI families is deliberate \u2014 a retried timeout\n * would send the same email twice or bill the same generation twice.\n */\nexport declare const stepPolicy: {\n email: StepPolicy;\n llm: StepPolicy;\n gemini: StepPolicy;\n database: StepPolicy;\n};\n\n// Every member the three runtime copies put on their own default export \u2014 the\n// platform's `sdk-core.ts`, the published stub and the CLI's collect stub \u2014\n// and nothing else. A helper the module hands a default import but does not\n// declare here is one an author cannot call without the compiler refusing it\n// (#3482 CR3482-002); `tests/api/spec/function-profile.test.ts` holds the four\n// lists equal and compiles a default import against them.\ndeclare const _default: {\n SDK_STUB_VERSION: string;\n defineFunction: typeof defineFunction;\n defineQuery: typeof defineQuery;\n defineMutation: typeof defineMutation;\n pMap: typeof pMap;\n ulid: typeof ulid;\n assertRuntime: typeof assertRuntime;\n FunctionRuntimeError: typeof FunctionRuntimeError;\n};\nexport default _default;\n";