primitive-functions 0.2.0-alpha.11 → 0.2.0-alpha.13
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.
- package/index.d.ts +179 -50
- 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,
|
|
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
|
*
|
|
@@ -510,32 +510,50 @@ export interface FunctionApi {
|
|
|
510
510
|
body: unknown;
|
|
511
511
|
}): Promise<any>;
|
|
512
512
|
"adminData": {
|
|
513
|
-
/**
|
|
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
|
+
*/
|
|
514
517
|
"batch"(args: {
|
|
515
518
|
"databaseId": string | number;
|
|
516
519
|
body: unknown;
|
|
517
520
|
}): Promise<any>;
|
|
518
|
-
/**
|
|
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
|
+
*/
|
|
519
525
|
"count"(args: {
|
|
520
526
|
"databaseId": string | number;
|
|
521
527
|
body: unknown;
|
|
522
528
|
}): Promise<any>;
|
|
523
|
-
/**
|
|
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
|
+
*/
|
|
524
533
|
"delete"(args: {
|
|
525
534
|
"databaseId": string | number;
|
|
526
535
|
body: unknown;
|
|
527
536
|
}): Promise<any>;
|
|
528
|
-
/**
|
|
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
|
+
*/
|
|
529
541
|
"patch"(args: {
|
|
530
542
|
"databaseId": string | number;
|
|
531
543
|
body: unknown;
|
|
532
544
|
}): Promise<any>;
|
|
533
|
-
/**
|
|
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
|
+
*/
|
|
534
549
|
"query"(args: {
|
|
535
550
|
"databaseId": string | number;
|
|
536
551
|
body: unknown;
|
|
537
552
|
}): Promise<any>;
|
|
538
|
-
/**
|
|
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
|
+
*/
|
|
539
557
|
"save"(args: {
|
|
540
558
|
"databaseId": string | number;
|
|
541
559
|
body: unknown;
|
|
@@ -566,7 +584,10 @@ export interface FunctionApi {
|
|
|
566
584
|
"get"(args: {
|
|
567
585
|
"databaseId": string | number;
|
|
568
586
|
}): Promise<any>;
|
|
569
|
-
/**
|
|
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
|
+
*/
|
|
570
591
|
"getMetadata"(args: {
|
|
571
592
|
"databaseId": string | number;
|
|
572
593
|
}): Promise<any>;
|
|
@@ -723,7 +744,10 @@ export interface FunctionApi {
|
|
|
723
744
|
"databaseId": string | number;
|
|
724
745
|
body: unknown;
|
|
725
746
|
}): Promise<any>;
|
|
726
|
-
/**
|
|
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
|
+
*/
|
|
727
751
|
"updateMetadata"(args: {
|
|
728
752
|
"databaseId": string | number;
|
|
729
753
|
body: unknown;
|
|
@@ -746,6 +770,7 @@ export interface FunctionApi {
|
|
|
746
770
|
"delete"(args: {
|
|
747
771
|
"scope": string | number;
|
|
748
772
|
"aliasKey": string | number;
|
|
773
|
+
"userId"?: string | number | boolean;
|
|
749
774
|
}): Promise<any>;
|
|
750
775
|
/** `documents.aliases.listForDocument` — GET /documents/{documentId}/aliases. List aliases bound to a document */
|
|
751
776
|
"listForDocument"(args: {
|
|
@@ -755,6 +780,7 @@ export interface FunctionApi {
|
|
|
755
780
|
"resolve"(args: {
|
|
756
781
|
"scope": string | number;
|
|
757
782
|
"aliasKey": string | number;
|
|
783
|
+
"userId"?: string | number | boolean;
|
|
758
784
|
}): Promise<any>;
|
|
759
785
|
/** `documents.aliases.set` — PUT /document-aliases/{scope}/{aliasKey}. Bind a (scope, aliasKey) alias to a document */
|
|
760
786
|
"set"(args: {
|
|
@@ -804,7 +830,10 @@ export interface FunctionApi {
|
|
|
804
830
|
"X-Blob-Sha256": string | number;
|
|
805
831
|
body: ArrayBuffer | Uint8Array | string;
|
|
806
832
|
}): Promise<any>;
|
|
807
|
-
/**
|
|
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
|
+
*/
|
|
808
837
|
"uploadWithoutId"(args: {
|
|
809
838
|
"documentId": string | number;
|
|
810
839
|
}): Promise<any>;
|
|
@@ -973,17 +1002,20 @@ export interface FunctionApi {
|
|
|
973
1002
|
"aggregate"(args: {
|
|
974
1003
|
"documentId": string | number;
|
|
975
1004
|
"model": string | number;
|
|
1005
|
+
"documentFormat"?: string | number | boolean;
|
|
976
1006
|
body: unknown;
|
|
977
1007
|
}): Promise<any>;
|
|
978
1008
|
/** `documents.records.bulk` — POST /documents/{documentId}/records/bulk. Apply an atomic multi-model record blob to a document (create/patch/delete) */
|
|
979
1009
|
"bulk"(args: {
|
|
980
1010
|
"documentId": string | number;
|
|
1011
|
+
"documentFormat"?: string | number | boolean;
|
|
981
1012
|
body: unknown;
|
|
982
1013
|
}): Promise<any>;
|
|
983
1014
|
/** `documents.records.count` — GET /documents/{documentId}/records/{model}/count. Count records in a document model */
|
|
984
1015
|
"count"(args: {
|
|
985
1016
|
"documentId": string | number;
|
|
986
1017
|
"model": string | number;
|
|
1018
|
+
"documentFormat"?: string | number | boolean;
|
|
987
1019
|
"filter"?: Record<string, unknown> | string;
|
|
988
1020
|
}): Promise<any>;
|
|
989
1021
|
/** `documents.records.delete` — DELETE /documents/{documentId}/records/{model}/{recordId}. Delete a record from a document model */
|
|
@@ -991,18 +1023,21 @@ export interface FunctionApi {
|
|
|
991
1023
|
"documentId": string | number;
|
|
992
1024
|
"model": string | number;
|
|
993
1025
|
"recordId": string | number;
|
|
1026
|
+
"documentFormat"?: string | number | boolean;
|
|
994
1027
|
}): Promise<any>;
|
|
995
1028
|
/** `documents.records.patch` — PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */
|
|
996
1029
|
"patch"(args: {
|
|
997
1030
|
"documentId": string | number;
|
|
998
1031
|
"model": string | number;
|
|
999
1032
|
"recordId": string | number;
|
|
1033
|
+
"documentFormat"?: string | number | boolean;
|
|
1000
1034
|
body: unknown;
|
|
1001
1035
|
}): Promise<any>;
|
|
1002
1036
|
/** `documents.records.query` — GET /documents/{documentId}/records/{model}. Query records in a document model */
|
|
1003
1037
|
"query"(args: {
|
|
1004
1038
|
"documentId": string | number;
|
|
1005
1039
|
"model": string | number;
|
|
1040
|
+
"documentFormat"?: string | number | boolean;
|
|
1006
1041
|
"limit"?: string | number | boolean;
|
|
1007
1042
|
"cursor"?: string | number | boolean;
|
|
1008
1043
|
"filter"?: Record<string, unknown> | string;
|
|
@@ -1011,6 +1046,7 @@ export interface FunctionApi {
|
|
|
1011
1046
|
"save"(args: {
|
|
1012
1047
|
"documentId": string | number;
|
|
1013
1048
|
"model": string | number;
|
|
1049
|
+
"documentFormat"?: string | number | boolean;
|
|
1014
1050
|
body: unknown;
|
|
1015
1051
|
}): Promise<any>;
|
|
1016
1052
|
};
|
|
@@ -1071,9 +1107,10 @@ export interface FunctionApi {
|
|
|
1071
1107
|
"sessionId": string | number;
|
|
1072
1108
|
body: FormData | ArrayBuffer | Uint8Array | string;
|
|
1073
1109
|
}): Promise<any>;
|
|
1074
|
-
/** `documents.validateAccess` — POST /documents/{documentId}/validate-access. Resolve
|
|
1110
|
+
/** `documents.validateAccess` — POST /documents/{documentId}/validate-access. Resolve effective access to a document, for the caller or a named user */
|
|
1075
1111
|
"validateAccess"(args: {
|
|
1076
1112
|
"documentId": string | number;
|
|
1113
|
+
body?: unknown;
|
|
1077
1114
|
}): Promise<any>;
|
|
1078
1115
|
};
|
|
1079
1116
|
"email": {
|
|
@@ -1106,23 +1143,6 @@ export interface FunctionApi {
|
|
|
1106
1143
|
body?: unknown;
|
|
1107
1144
|
}): Promise<any>;
|
|
1108
1145
|
};
|
|
1109
|
-
"gemini": {
|
|
1110
|
-
/** `gemini.countTokens` — POST /gemini/count-tokens. Count tokens for a Gemini request */
|
|
1111
|
-
"countTokens"(args: {
|
|
1112
|
-
body: unknown;
|
|
1113
|
-
}): Promise<any>;
|
|
1114
|
-
/** `gemini.generate` — POST /gemini/generate. Generate content with Gemini */
|
|
1115
|
-
"generate"(args: {
|
|
1116
|
-
body: unknown;
|
|
1117
|
-
}): Promise<any>;
|
|
1118
|
-
/** `gemini.generateRaw` — POST /gemini/generate-raw. Generate content with Gemini (raw passthrough) */
|
|
1119
|
-
"generateRaw"(args: {
|
|
1120
|
-
"model"?: string | number | boolean;
|
|
1121
|
-
body: unknown;
|
|
1122
|
-
}): Promise<any>;
|
|
1123
|
-
/** `gemini.models` — GET /gemini/models. List available Gemini models */
|
|
1124
|
-
"models"(args?: Record<string, never>): Promise<any>;
|
|
1125
|
-
};
|
|
1126
1146
|
"groups": {
|
|
1127
1147
|
/** `groups.addMember` — POST /groups/{groupType}/{groupId}/members. Add a member to a group */
|
|
1128
1148
|
"addMember"(args: {
|
|
@@ -1212,14 +1232,6 @@ export interface FunctionApi {
|
|
|
1212
1232
|
"integrationKey": string | number;
|
|
1213
1233
|
}): Promise<any>;
|
|
1214
1234
|
};
|
|
1215
|
-
"llm": {
|
|
1216
|
-
/** `llm.chat` — POST /llm/chat. Run an LLM chat completion */
|
|
1217
|
-
"chat"(args: {
|
|
1218
|
-
body: unknown;
|
|
1219
|
-
}): Promise<any>;
|
|
1220
|
-
/** `llm.models` — GET /llm/models. List available LLM models */
|
|
1221
|
-
"models"(args?: Record<string, never>): Promise<any>;
|
|
1222
|
-
};
|
|
1223
1235
|
"locks": {
|
|
1224
1236
|
/** `locks.list` — GET /locks. List all currently-held named locks in the app */
|
|
1225
1237
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
@@ -1330,6 +1342,10 @@ export interface FunctionApi {
|
|
|
1330
1342
|
"getProfiles"(args: {
|
|
1331
1343
|
body: unknown;
|
|
1332
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>;
|
|
1333
1349
|
/** `users.list` — GET /users. List app users */
|
|
1334
1350
|
"list"(args?: {
|
|
1335
1351
|
"email"?: string | number | boolean;
|
|
@@ -1342,7 +1358,10 @@ export interface FunctionApi {
|
|
|
1342
1358
|
"lookup"(args?: {
|
|
1343
1359
|
"email"?: string | number | boolean;
|
|
1344
1360
|
}): Promise<any>;
|
|
1345
|
-
/**
|
|
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
|
+
*/
|
|
1346
1365
|
"remove"(args: {
|
|
1347
1366
|
"userId": string | number;
|
|
1348
1367
|
}): Promise<any>;
|
|
@@ -1583,6 +1602,14 @@ export interface DocumentQueryOptions {
|
|
|
1583
1602
|
filter?: Record<string, unknown> | string;
|
|
1584
1603
|
limit?: number;
|
|
1585
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;
|
|
1586
1613
|
}
|
|
1587
1614
|
|
|
1588
1615
|
/**
|
|
@@ -1667,6 +1694,13 @@ export interface IntegrationCallResult {
|
|
|
1667
1694
|
|
|
1668
1695
|
/** What a prompt run is given — the member execute route's own body. */
|
|
1669
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
|
+
*/
|
|
1670
1704
|
variables?: Record<string, unknown>;
|
|
1671
1705
|
/** Run against a different model for this call only. */
|
|
1672
1706
|
modelOverride?: string;
|
|
@@ -1684,10 +1718,45 @@ export interface PromptRunArgs {
|
|
|
1684
1718
|
*/
|
|
1685
1719
|
export interface PromptSchemas {}
|
|
1686
1720
|
|
|
1687
|
-
/**
|
|
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
|
+
*/
|
|
1688
1736
|
export type PromptKeys = [keyof PromptSchemas] extends [never]
|
|
1689
1737
|
? string
|
|
1690
|
-
: 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;
|
|
1691
1760
|
|
|
1692
1761
|
/** One prompt's declared output type, or `unknown` where none is declared. */
|
|
1693
1762
|
export type PromptOutput<K extends string> = K extends keyof PromptSchemas
|
|
@@ -1705,6 +1774,29 @@ export type PromptOutputErrorCode =
|
|
|
1705
1774
|
| "PROMPT_OUTPUT_NOT_JSON"
|
|
1706
1775
|
| "PROMPT_OUTPUT_SCHEMA_VIOLATION";
|
|
1707
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
|
+
|
|
1708
1800
|
/** A prompt that declares an output shape, when the answer matched it. */
|
|
1709
1801
|
export interface PromptRunSuccess<TParsed> {
|
|
1710
1802
|
success: true;
|
|
@@ -1718,19 +1810,31 @@ export interface PromptRunSuccess<TParsed> {
|
|
|
1718
1810
|
}
|
|
1719
1811
|
|
|
1720
1812
|
/**
|
|
1721
|
-
* The failure arm, whichever failed. `errorCode` is set for a SHAPE failure
|
|
1722
|
-
*
|
|
1723
|
-
*
|
|
1724
|
-
*
|
|
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.
|
|
1725
1818
|
*/
|
|
1726
1819
|
export interface PromptRunFailure {
|
|
1727
1820
|
success: false;
|
|
1728
1821
|
output: string;
|
|
1729
1822
|
error: string | null;
|
|
1730
|
-
errorCode?:
|
|
1823
|
+
errorCode?: PromptRunErrorCode | null;
|
|
1731
1824
|
parsed?: undefined;
|
|
1732
1825
|
metrics?: Record<string, unknown>;
|
|
1733
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;
|
|
1734
1838
|
}
|
|
1735
1839
|
|
|
1736
1840
|
/** The envelope for a key whose declaration says nothing about its output. */
|
|
@@ -1743,9 +1847,11 @@ export interface PromptRunOpenResult {
|
|
|
1743
1847
|
*/
|
|
1744
1848
|
parsed?: unknown;
|
|
1745
1849
|
error?: string | null;
|
|
1746
|
-
errorCode?:
|
|
1850
|
+
errorCode?: PromptRunErrorCode | null;
|
|
1747
1851
|
metrics?: Record<string, unknown>;
|
|
1748
1852
|
configId: string;
|
|
1853
|
+
/** The upstream provider's HTTP status on a provider failure — #3663. */
|
|
1854
|
+
upstreamStatus?: number;
|
|
1749
1855
|
}
|
|
1750
1856
|
|
|
1751
1857
|
/**
|
|
@@ -1907,7 +2013,7 @@ export interface FunctionContext {
|
|
|
1907
2013
|
* confers nothing: every call is a `documents.records.*` operation on the
|
|
1908
2014
|
* same authority.
|
|
1909
2015
|
*/
|
|
1910
|
-
doc(documentId: string): DocumentHandle;
|
|
2016
|
+
doc(documentId: string, options?: { documentFormat?: 1 | 2 }): DocumentHandle;
|
|
1911
2017
|
/**
|
|
1912
2018
|
* Outbound HTTP, through a granted integration and nowhere else (#3183).
|
|
1913
2019
|
*
|
|
@@ -2040,6 +2146,29 @@ export interface FunctionContext {
|
|
|
2040
2146
|
};
|
|
2041
2147
|
}
|
|
2042
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
|
+
|
|
2043
2172
|
/**
|
|
2044
2173
|
* The step handle. `step` is the third argument under BOTH runners, so the
|
|
2045
2174
|
* same body runs either way — which is what `mode = "any"` is for (#3454).
|
|
@@ -2062,7 +2191,7 @@ export interface FunctionStep {
|
|
|
2062
2191
|
do<T>(name: string, body: () => T | Promise<T>): Promise<T>;
|
|
2063
2192
|
do<T>(
|
|
2064
2193
|
name: string,
|
|
2065
|
-
config:
|
|
2194
|
+
config: StepConfig,
|
|
2066
2195
|
body: () => T | Promise<T>
|
|
2067
2196
|
): Promise<T>;
|
|
2068
2197
|
sleep(name: string, duration: number | string): Promise<void>;
|
|
@@ -2326,9 +2455,9 @@ export declare const PMAP_DEFAULT_CONCURRENCY: number;
|
|
|
2326
2455
|
*/
|
|
2327
2456
|
export declare function ulid(): string;
|
|
2328
2457
|
|
|
2329
|
-
/** One family's durable `step.do` configuration. */
|
|
2330
|
-
export interface StepPolicy {
|
|
2331
|
-
retries: { limit: number; delay: string; backoff:
|
|
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 };
|
|
2332
2461
|
timeout: string;
|
|
2333
2462
|
}
|
|
2334
2463
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primitive-functions",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.13",
|
|
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",
|