primitive-functions 0.2.0-alpha.9 → 0.2.1

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 (2) hide show
  1. package/index.d.ts +186 -50
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -114,7 +114,7 @@ export interface PrimitivePlatformError extends Error {
114
114
 
115
115
  /**
116
116
  * The typed HTTP profile, generated from the platform's OpenAPI document. Its
117
- * namespaces mirror the operation ids: analytics, blobBuckets, channels, collections, configVars, connections, databaseTypeConfigs, databases, documents, email, functions, gemini, groups, integrations, llm, locks, notifications, prompts, resourceMetadata, secrets, users.
117
+ * namespaces mirror the operation ids: analytics, blobBuckets, channels, collections, configVars, connections, databaseTypeConfigs, databases, documents, email, functions, groups, integrations, locks, notifications, prompts, resourceMetadata, secrets, users.
118
118
  * Methods take one options object carrying the operation's path parameters,
119
119
  * query parameters, request headers (under their wire names) and `body`.
120
120
  *
@@ -369,6 +369,8 @@ export interface FunctionApi {
369
369
  /** `collections.listCollectionsForDocument` — GET /documents/{documentId}/collections. List collections a document belongs to (reverse lookup) */
370
370
  "listCollectionsForDocument"(args: {
371
371
  "documentId": string | number;
372
+ "limit"?: string | number | boolean;
373
+ "cursor"?: string | number | boolean;
372
374
  }): Promise<any>;
373
375
  /** `collections.listDocuments` — GET /collections/{collectionId}/documents. List documents in a collection */
374
376
  "listDocuments"(args: {
@@ -508,32 +510,50 @@ export interface FunctionApi {
508
510
  body: unknown;
509
511
  }): Promise<any>;
510
512
  "adminData": {
511
- /** `databases.adminData.batch` — POST /databases/{databaseId}/admin-data/batch. DEPRECATED — direct database batch; use databases/{databaseId}/records/batch */
513
+ /**
514
+ * `databases.adminData.batch` — POST /databases/{databaseId}/admin-data/batch. DEPRECATED — direct database batch; use databases/{databaseId}/records/batch
515
+ * @deprecated Use databases/{databaseId}/records/batch
516
+ */
512
517
  "batch"(args: {
513
518
  "databaseId": string | number;
514
519
  body: unknown;
515
520
  }): Promise<any>;
516
- /** `databases.adminData.count` — POST /databases/{databaseId}/admin-data/count. DEPRECATED — direct database count; use databases/{databaseId}/records/count */
521
+ /**
522
+ * `databases.adminData.count` — POST /databases/{databaseId}/admin-data/count. DEPRECATED — direct database count; use databases/{databaseId}/records/count
523
+ * @deprecated Use databases/{databaseId}/records/count
524
+ */
517
525
  "count"(args: {
518
526
  "databaseId": string | number;
519
527
  body: unknown;
520
528
  }): Promise<any>;
521
- /** `databases.adminData.delete` — POST /databases/{databaseId}/admin-data/delete. DEPRECATED — direct database delete; use databases/{databaseId}/records/delete */
529
+ /**
530
+ * `databases.adminData.delete` — POST /databases/{databaseId}/admin-data/delete. DEPRECATED — direct database delete; use databases/{databaseId}/records/delete
531
+ * @deprecated Use databases/{databaseId}/records/delete
532
+ */
522
533
  "delete"(args: {
523
534
  "databaseId": string | number;
524
535
  body: unknown;
525
536
  }): Promise<any>;
526
- /** `databases.adminData.patch` — POST /databases/{databaseId}/admin-data/patch. DEPRECATED — direct database patch; use databases/{databaseId}/records/patch */
537
+ /**
538
+ * `databases.adminData.patch` — POST /databases/{databaseId}/admin-data/patch. DEPRECATED — direct database patch; use databases/{databaseId}/records/patch
539
+ * @deprecated Use databases/{databaseId}/records/patch
540
+ */
527
541
  "patch"(args: {
528
542
  "databaseId": string | number;
529
543
  body: unknown;
530
544
  }): Promise<any>;
531
- /** `databases.adminData.query` — POST /databases/{databaseId}/admin-data/query. DEPRECATED — direct database query; use databases/{databaseId}/records/query */
545
+ /**
546
+ * `databases.adminData.query` — POST /databases/{databaseId}/admin-data/query. DEPRECATED — direct database query; use databases/{databaseId}/records/query
547
+ * @deprecated Use databases/{databaseId}/records/query
548
+ */
532
549
  "query"(args: {
533
550
  "databaseId": string | number;
534
551
  body: unknown;
535
552
  }): Promise<any>;
536
- /** `databases.adminData.save` — POST /databases/{databaseId}/admin-data/save. DEPRECATED — direct database save; use databases/{databaseId}/records/save */
553
+ /**
554
+ * `databases.adminData.save` — POST /databases/{databaseId}/admin-data/save. DEPRECATED — direct database save; use databases/{databaseId}/records/save
555
+ * @deprecated Use databases/{databaseId}/records/save
556
+ */
537
557
  "save"(args: {
538
558
  "databaseId": string | number;
539
559
  body: unknown;
@@ -564,7 +584,10 @@ export interface FunctionApi {
564
584
  "get"(args: {
565
585
  "databaseId": string | number;
566
586
  }): Promise<any>;
567
- /** `databases.getMetadata` — GET /databases/{databaseId}/metadata. Get database metadata */
587
+ /**
588
+ * `databases.getMetadata` — GET /databases/{databaseId}/metadata. DEPRECATED — get database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)
589
+ * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)
590
+ */
568
591
  "getMetadata"(args: {
569
592
  "databaseId": string | number;
570
593
  }): Promise<any>;
@@ -721,7 +744,10 @@ export interface FunctionApi {
721
744
  "databaseId": string | number;
722
745
  body: unknown;
723
746
  }): Promise<any>;
724
- /** `databases.updateMetadata` — PATCH /databases/{databaseId}/metadata. Update database metadata */
747
+ /**
748
+ * `databases.updateMetadata` — PATCH /databases/{databaseId}/metadata. DEPRECATED — update database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)
749
+ * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)
750
+ */
725
751
  "updateMetadata"(args: {
726
752
  "databaseId": string | number;
727
753
  body: unknown;
@@ -744,6 +770,7 @@ export interface FunctionApi {
744
770
  "delete"(args: {
745
771
  "scope": string | number;
746
772
  "aliasKey": string | number;
773
+ "userId"?: string | number | boolean;
747
774
  }): Promise<any>;
748
775
  /** `documents.aliases.listForDocument` — GET /documents/{documentId}/aliases. List aliases bound to a document */
749
776
  "listForDocument"(args: {
@@ -753,6 +780,7 @@ export interface FunctionApi {
753
780
  "resolve"(args: {
754
781
  "scope": string | number;
755
782
  "aliasKey": string | number;
783
+ "userId"?: string | number | boolean;
756
784
  }): Promise<any>;
757
785
  /** `documents.aliases.set` — PUT /document-aliases/{scope}/{aliasKey}. Bind a (scope, aliasKey) alias to a document */
758
786
  "set"(args: {
@@ -802,7 +830,10 @@ export interface FunctionApi {
802
830
  "X-Blob-Sha256": string | number;
803
831
  body: ArrayBuffer | Uint8Array | string;
804
832
  }): Promise<any>;
805
- /** `documents.blobs.uploadWithoutId` — PUT /documents/{documentId}/blobs. Deprecated: upload a document blob without a client-specified id */
833
+ /**
834
+ * `documents.blobs.uploadWithoutId` — PUT /documents/{documentId}/blobs. Deprecated: upload a document blob without a client-specified id
835
+ * @deprecated Deprecated in the app API spec; see its description.
836
+ */
806
837
  "uploadWithoutId"(args: {
807
838
  "documentId": string | number;
808
839
  }): Promise<any>;
@@ -971,17 +1002,20 @@ export interface FunctionApi {
971
1002
  "aggregate"(args: {
972
1003
  "documentId": string | number;
973
1004
  "model": string | number;
1005
+ "documentFormat"?: string | number | boolean;
974
1006
  body: unknown;
975
1007
  }): Promise<any>;
976
1008
  /** `documents.records.bulk` — POST /documents/{documentId}/records/bulk. Apply an atomic multi-model record blob to a document (create/patch/delete) */
977
1009
  "bulk"(args: {
978
1010
  "documentId": string | number;
1011
+ "documentFormat"?: string | number | boolean;
979
1012
  body: unknown;
980
1013
  }): Promise<any>;
981
1014
  /** `documents.records.count` — GET /documents/{documentId}/records/{model}/count. Count records in a document model */
982
1015
  "count"(args: {
983
1016
  "documentId": string | number;
984
1017
  "model": string | number;
1018
+ "documentFormat"?: string | number | boolean;
985
1019
  "filter"?: Record<string, unknown> | string;
986
1020
  }): Promise<any>;
987
1021
  /** `documents.records.delete` — DELETE /documents/{documentId}/records/{model}/{recordId}. Delete a record from a document model */
@@ -989,18 +1023,21 @@ export interface FunctionApi {
989
1023
  "documentId": string | number;
990
1024
  "model": string | number;
991
1025
  "recordId": string | number;
1026
+ "documentFormat"?: string | number | boolean;
992
1027
  }): Promise<any>;
993
1028
  /** `documents.records.patch` — PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */
994
1029
  "patch"(args: {
995
1030
  "documentId": string | number;
996
1031
  "model": string | number;
997
1032
  "recordId": string | number;
1033
+ "documentFormat"?: string | number | boolean;
998
1034
  body: unknown;
999
1035
  }): Promise<any>;
1000
1036
  /** `documents.records.query` — GET /documents/{documentId}/records/{model}. Query records in a document model */
1001
1037
  "query"(args: {
1002
1038
  "documentId": string | number;
1003
1039
  "model": string | number;
1040
+ "documentFormat"?: string | number | boolean;
1004
1041
  "limit"?: string | number | boolean;
1005
1042
  "cursor"?: string | number | boolean;
1006
1043
  "filter"?: Record<string, unknown> | string;
@@ -1009,6 +1046,7 @@ export interface FunctionApi {
1009
1046
  "save"(args: {
1010
1047
  "documentId": string | number;
1011
1048
  "model": string | number;
1049
+ "documentFormat"?: string | number | boolean;
1012
1050
  body: unknown;
1013
1051
  }): Promise<any>;
1014
1052
  };
@@ -1032,6 +1070,11 @@ export interface FunctionApi {
1032
1070
  "documentId": string | number;
1033
1071
  body: unknown;
1034
1072
  }): Promise<any>;
1073
+ /** `documents.requestSnapshot` — POST /documents/{documentId}/snapshots. Snapshot a large document now: seal the open epoch and build a base */
1074
+ "requestSnapshot"(args: {
1075
+ "documentId": string | number;
1076
+ body: unknown;
1077
+ }): Promise<any>;
1035
1078
  /** `documents.revokeGroupPermission` — DELETE /documents/{documentId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a document */
1036
1079
  "revokeGroupPermission"(args: {
1037
1080
  "documentId": string | number;
@@ -1064,9 +1107,10 @@ export interface FunctionApi {
1064
1107
  "sessionId": string | number;
1065
1108
  body: FormData | ArrayBuffer | Uint8Array | string;
1066
1109
  }): Promise<any>;
1067
- /** `documents.validateAccess` — POST /documents/{documentId}/validate-access. Resolve the caller's effective access level for a document */
1110
+ /** `documents.validateAccess` — POST /documents/{documentId}/validate-access. Resolve effective access to a document, for the caller or a named user */
1068
1111
  "validateAccess"(args: {
1069
1112
  "documentId": string | number;
1113
+ body?: unknown;
1070
1114
  }): Promise<any>;
1071
1115
  };
1072
1116
  "email": {
@@ -1099,23 +1143,6 @@ export interface FunctionApi {
1099
1143
  body?: unknown;
1100
1144
  }): Promise<any>;
1101
1145
  };
1102
- "gemini": {
1103
- /** `gemini.countTokens` — POST /gemini/count-tokens. Count tokens for a Gemini request */
1104
- "countTokens"(args: {
1105
- body: unknown;
1106
- }): Promise<any>;
1107
- /** `gemini.generate` — POST /gemini/generate. Generate content with Gemini */
1108
- "generate"(args: {
1109
- body: unknown;
1110
- }): Promise<any>;
1111
- /** `gemini.generateRaw` — POST /gemini/generate-raw. Generate content with Gemini (raw passthrough) */
1112
- "generateRaw"(args: {
1113
- "model"?: string | number | boolean;
1114
- body: unknown;
1115
- }): Promise<any>;
1116
- /** `gemini.models` — GET /gemini/models. List available Gemini models */
1117
- "models"(args?: Record<string, never>): Promise<any>;
1118
- };
1119
1146
  "groups": {
1120
1147
  /** `groups.addMember` — POST /groups/{groupType}/{groupId}/members. Add a member to a group */
1121
1148
  "addMember"(args: {
@@ -1205,14 +1232,6 @@ export interface FunctionApi {
1205
1232
  "integrationKey": string | number;
1206
1233
  }): Promise<any>;
1207
1234
  };
1208
- "llm": {
1209
- /** `llm.chat` — POST /llm/chat. Run an LLM chat completion */
1210
- "chat"(args: {
1211
- body: unknown;
1212
- }): Promise<any>;
1213
- /** `llm.models` — GET /llm/models. List available LLM models */
1214
- "models"(args?: Record<string, never>): Promise<any>;
1215
- };
1216
1235
  "locks": {
1217
1236
  /** `locks.list` — GET /locks. List all currently-held named locks in the app */
1218
1237
  "list"(args?: Record<string, never>): Promise<any>;
@@ -1323,6 +1342,10 @@ export interface FunctionApi {
1323
1342
  "getProfiles"(args: {
1324
1343
  body: unknown;
1325
1344
  }): Promise<any>;
1345
+ /** `users.getRootDocument` — GET /users/{userId}/root-document. Get an app user's root document id */
1346
+ "getRootDocument"(args: {
1347
+ "userId": string | number;
1348
+ }): Promise<any>;
1326
1349
  /** `users.list` — GET /users. List app users */
1327
1350
  "list"(args?: {
1328
1351
  "email"?: string | number | boolean;
@@ -1335,7 +1358,10 @@ export interface FunctionApi {
1335
1358
  "lookup"(args?: {
1336
1359
  "email"?: string | number | boolean;
1337
1360
  }): Promise<any>;
1338
- /** `users.remove` — DELETE /users/{userId}. Remove a user from the app */
1361
+ /**
1362
+ * `users.remove` — DELETE /users/{userId}. DEPRECATED — remove a user from the app; use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)
1363
+ * @deprecated Use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)
1364
+ */
1339
1365
  "remove"(args: {
1340
1366
  "userId": string | number;
1341
1367
  }): Promise<any>;
@@ -1576,6 +1602,14 @@ export interface DocumentQueryOptions {
1576
1602
  filter?: Record<string, unknown> | string;
1577
1603
  limit?: number;
1578
1604
  cursor?: string;
1605
+ /**
1606
+ * The document format you expect (#3764). When it disagrees with the format
1607
+ * the platform resolved, the call is refused with a 409
1608
+ * DOCUMENT_FORMAT_MISMATCH rather than answered out of the wrong tables.
1609
+ * Usually stated once on the handle, as ctx.doc(id, { documentFormat: 2 }),
1610
+ * rather than per read.
1611
+ */
1612
+ documentFormat?: 1 | 2;
1579
1613
  }
1580
1614
 
1581
1615
  /**
@@ -1660,6 +1694,13 @@ export interface IntegrationCallResult {
1660
1694
 
1661
1695
  /** What a prompt run is given — the member execute route's own body. */
1662
1696
  export interface PromptRunArgs {
1697
+ /**
1698
+ * The prompt's variables. A `kind = "decisions"` prompt takes
1699
+ * `{ state, criteria? }`: `state` is the value its questions are asked
1700
+ * about, and `criteria.<question>` supplies this run's options for each
1701
+ * choice question declared `criteriaSource = "dynamic"` — a table of option
1702
+ * key = description (a string or a JSON object), at least two entries (#3813).
1703
+ */
1663
1704
  variables?: Record<string, unknown>;
1664
1705
  /** Run against a different model for this call only. */
1665
1706
  modelOverride?: string;
@@ -1677,10 +1718,45 @@ export interface PromptRunArgs {
1677
1718
  */
1678
1719
  export interface PromptSchemas {}
1679
1720
 
1680
- /** The keys `ctx.prompts.run` accepts — every declared one, or `string` before a push. */
1721
+ /**
1722
+ * The keys whose declaration is an AGENT (`kind = "agent"`, #3798): entries
1723
+ * carrying `{ agent: … }` instead of an output. An agent runs turn by turn in
1724
+ * a session and never single-shot, so these are the keys `PromptKeys` leaves
1725
+ * out.
1726
+ */
1727
+ export type AgentKeys = {
1728
+ [K in keyof PromptSchemas]: PromptSchemas[K] extends { agent: unknown } ? K : never;
1729
+ }[keyof PromptSchemas] &
1730
+ string;
1731
+
1732
+ /**
1733
+ * The keys `ctx.prompts.run` accepts — every declared one that is not an
1734
+ * agent, or `string` before a push.
1735
+ */
1681
1736
  export type PromptKeys = [keyof PromptSchemas] extends [never]
1682
1737
  ? string
1683
- : keyof PromptSchemas & string;
1738
+ : Exclude<keyof PromptSchemas & string, AgentKeys>;
1739
+
1740
+ /** One agent's session variables, typed from its `inputSchema` (#3798). */
1741
+ export type AgentVariables<K extends AgentKeys> = PromptSchemas[K] extends {
1742
+ agent: { variables: infer V };
1743
+ }
1744
+ ? V
1745
+ : never;
1746
+
1747
+ /** One agent's client tools, by name: each one's `input` and `output` (#3798). */
1748
+ export type AgentClientTools<K extends AgentKeys> = PromptSchemas[K] extends {
1749
+ agent: { clientTools: infer T };
1750
+ }
1751
+ ? T
1752
+ : never;
1753
+
1754
+ /** One agent's event kinds, by name: each one's payload (#3798). */
1755
+ export type AgentEvents<K extends AgentKeys> = PromptSchemas[K] extends {
1756
+ agent: { events: infer E };
1757
+ }
1758
+ ? E
1759
+ : never;
1684
1760
 
1685
1761
  /** One prompt's declared output type, or `unknown` where none is declared. */
1686
1762
  export type PromptOutput<K extends string> = K extends keyof PromptSchemas
@@ -1698,6 +1774,29 @@ export type PromptOutputErrorCode =
1698
1774
  | "PROMPT_OUTPUT_NOT_JSON"
1699
1775
  | "PROMPT_OUTPUT_SCHEMA_VIOLATION";
1700
1776
 
1777
+ /**
1778
+ * Every code the envelope's `errorCode` can carry — #3663, #3813.
1779
+ *
1780
+ * `PROMPT_UPSTREAM_TIMEOUT` is the one that is NOT about the prompt's own
1781
+ * answer: the provider ran out of time, so there was no answer to refuse. It
1782
+ * is the only provider failure that sets `errorCode` at all, which is what
1783
+ * leaves "the model returned the wrong shape" distinguishable from "the model
1784
+ * failed" while still letting a caller retry the one failure worth retrying.
1785
+ *
1786
+ * `PROMPT_CRITERIA_INVALID` is the run that never reached a provider: a
1787
+ * decisions run's `variables.criteria` was refused before the call, so
1788
+ * nothing was billed (#3813).
1789
+ *
1790
+ * `PROMPT_STRICT_OUTPUT_SCHEMA_MISSING` never reached one either: the config
1791
+ * sets `strictOutput = true` and the prompt has no usable `outputSchema` to
1792
+ * send as the strict `json_schema` (#3801).
1793
+ */
1794
+ export type PromptRunErrorCode =
1795
+ | PromptOutputErrorCode
1796
+ | "PROMPT_UPSTREAM_TIMEOUT"
1797
+ | "PROMPT_CRITERIA_INVALID"
1798
+ | "PROMPT_STRICT_OUTPUT_SCHEMA_MISSING";
1799
+
1701
1800
  /** A prompt that declares an output shape, when the answer matched it. */
1702
1801
  export interface PromptRunSuccess<TParsed> {
1703
1802
  success: true;
@@ -1711,19 +1810,31 @@ export interface PromptRunSuccess<TParsed> {
1711
1810
  }
1712
1811
 
1713
1812
  /**
1714
- * The failure arm, whichever failed. `errorCode` is set for a SHAPE failure
1715
- * and absent for a provider one; `output` carries the text either way, which
1716
- * is where the model's own value lives — a validation `error` names paths and
1717
- * schema constraints only.
1813
+ * The failure arm, whichever failed. `errorCode` is set for a SHAPE failure,
1814
+ * for a refused run (`PROMPT_CRITERIA_INVALID`, #3813), and for a provider
1815
+ * one only when the upstream TIMED OUT (#3663); `output` carries the text
1816
+ * either way, which is where the model's own value lives — a validation
1817
+ * `error` names paths and schema constraints only.
1718
1818
  */
1719
1819
  export interface PromptRunFailure {
1720
1820
  success: false;
1721
1821
  output: string;
1722
1822
  error: string | null;
1723
- errorCode?: PromptOutputErrorCode | null;
1823
+ errorCode?: PromptRunErrorCode | null;
1724
1824
  parsed?: undefined;
1725
1825
  metrics?: Record<string, unknown>;
1726
1826
  configId: string;
1827
+ /**
1828
+ * The upstream provider's HTTP status, when the call reached a provider and
1829
+ * it answered — #3663. This is what a retry decision is made on: a 504 or a
1830
+ * 503 is worth another attempt, a 400 on a refused payload is not.
1831
+ *
1832
+ * It does not depend on which provider the config named: Gemini and
1833
+ * OpenRouter report it identically. It is absent when no provider answer was
1834
+ * observed — an unset key, an oversized payload, a completion that came back
1835
+ * empty — so a number here is always the provider's own.
1836
+ */
1837
+ upstreamStatus?: number;
1727
1838
  }
1728
1839
 
1729
1840
  /** The envelope for a key whose declaration says nothing about its output. */
@@ -1736,9 +1847,11 @@ export interface PromptRunOpenResult {
1736
1847
  */
1737
1848
  parsed?: unknown;
1738
1849
  error?: string | null;
1739
- errorCode?: PromptOutputErrorCode | null;
1850
+ errorCode?: PromptRunErrorCode | null;
1740
1851
  metrics?: Record<string, unknown>;
1741
1852
  configId: string;
1853
+ /** The upstream provider's HTTP status on a provider failure — #3663. */
1854
+ upstreamStatus?: number;
1742
1855
  }
1743
1856
 
1744
1857
  /**
@@ -1900,7 +2013,7 @@ export interface FunctionContext {
1900
2013
  * confers nothing: every call is a `documents.records.*` operation on the
1901
2014
  * same authority.
1902
2015
  */
1903
- doc(documentId: string): DocumentHandle;
2016
+ doc(documentId: string, options?: { documentFormat?: 1 | 2 }): DocumentHandle;
1904
2017
  /**
1905
2018
  * Outbound HTTP, through a granted integration and nowhere else (#3183).
1906
2019
  *
@@ -2033,6 +2146,29 @@ export interface FunctionContext {
2033
2146
  };
2034
2147
  }
2035
2148
 
2149
+ /** How the wait between one step's retries grows. */
2150
+ export type StepBackoff = "constant" | "linear" | "exponential";
2151
+
2152
+ /**
2153
+ * The retry and timeout policy for ONE `step.do` — Cloudflare Workflows' own
2154
+ * step config.
2155
+ *
2156
+ * Under the TASK runner the platform forwards this object to Workflows
2157
+ * untouched, so these are its fields and its spellings: a duration is either a
2158
+ * number of milliseconds or a string Workflows parses (`"10 seconds"`,
2159
+ * `"5 minutes"`). Under the REQUEST runner `step.do` accepts a config and
2160
+ * ignores it — the body runs inline, and there is nothing to retry into.
2161
+ *
2162
+ * `stepPolicy.<family>` IS a `StepConfig`, so the platform's own defaults
2163
+ * hand straight to `step.do` (#3657). The shape is closed on purpose: a key
2164
+ * outside it — `retry` for `retries`, `timeoutMs` for `timeout` — is a
2165
+ * refusal at `config push` rather than an option the engine silently drops.
2166
+ */
2167
+ export interface StepConfig {
2168
+ retries?: { limit: number; delay: string | number; backoff?: StepBackoff };
2169
+ timeout?: string | number;
2170
+ }
2171
+
2036
2172
  /**
2037
2173
  * The step handle. `step` is the third argument under BOTH runners, so the
2038
2174
  * same body runs either way — which is what `mode = "any"` is for (#3454).
@@ -2055,7 +2191,7 @@ export interface FunctionStep {
2055
2191
  do<T>(name: string, body: () => T | Promise<T>): Promise<T>;
2056
2192
  do<T>(
2057
2193
  name: string,
2058
- config: Record<string, unknown>,
2194
+ config: StepConfig,
2059
2195
  body: () => T | Promise<T>
2060
2196
  ): Promise<T>;
2061
2197
  sleep(name: string, duration: number | string): Promise<void>;
@@ -2319,9 +2455,9 @@ export declare const PMAP_DEFAULT_CONCURRENCY: number;
2319
2455
  */
2320
2456
  export declare function ulid(): string;
2321
2457
 
2322
- /** One family's durable `step.do` configuration. */
2323
- export interface StepPolicy {
2324
- retries: { limit: number; delay: string; backoff: string };
2458
+ /** One family's durable `step.do` configuration — a `StepConfig` with every field decided. */
2459
+ export interface StepPolicy extends StepConfig {
2460
+ retries: { limit: number; delay: string; backoff: StepBackoff };
2325
2461
  timeout: string;
2326
2462
  }
2327
2463
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primitive-functions",
3
- "version": "0.2.0-alpha.9",
3
+ "version": "0.2.1",
4
4
  "description": "The module a Primitive server function imports. Supplied by the platform at invoke time; reserved here so the name is ours before the runtime lands.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Primitive LLC",