primitive-functions 0.3.0-alpha.7 → 0.3.0-alpha.9
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 +96 -4
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ export type FunctionTrigger =
|
|
|
114
114
|
*
|
|
115
115
|
* `ctx.user` is the turn's initiator, whose `access` gate the call
|
|
116
116
|
* passed, and `ctx.tool` carries the session's ids, members and
|
|
117
|
-
* variables. `callId` is the same on every attempt of the call, so use
|
|
117
|
+
* variables, and the turn's context, timezone and locale. `callId` is the same on every attempt of the call, so use
|
|
118
118
|
* it as an idempotency key. `toolName` is the declared tool name, which
|
|
119
119
|
* may differ from the function's key.
|
|
120
120
|
*/
|
|
@@ -142,7 +142,11 @@ export type FunctionTriggerKind = FunctionTrigger["kind"];
|
|
|
142
142
|
*/
|
|
143
143
|
export interface FunctionToolContext {
|
|
144
144
|
readonly sessionId: string;
|
|
145
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* The session's document, which holds its messages.
|
|
147
|
+
* @deprecated Use `sessionId` with the session API (`ctx.agents`,
|
|
148
|
+
* `ctx.api.agentSessions`); the field remains until a later breaking release.
|
|
149
|
+
*/
|
|
146
150
|
readonly documentId: string;
|
|
147
151
|
readonly turnId: string;
|
|
148
152
|
/** The call's id, the same on every attempt: an idempotency key. */
|
|
@@ -158,6 +162,24 @@ export interface FunctionToolContext {
|
|
|
158
162
|
};
|
|
159
163
|
/** The session's variables, set when it was created. */
|
|
160
164
|
readonly variables: Record<string, unknown>;
|
|
165
|
+
/**
|
|
166
|
+
* The turn's validated context: the object the member's send carried,
|
|
167
|
+
* checked against the agent's `turnContext.schema`, or the return of the
|
|
168
|
+
* agent's context function. The same values the system prompt rendered as
|
|
169
|
+
* `turn.*`. Null when the turn carried none.
|
|
170
|
+
*/
|
|
171
|
+
readonly context: Record<string, unknown> | null;
|
|
172
|
+
/**
|
|
173
|
+
* The IANA timezone the turn's send carried, such as
|
|
174
|
+
* `"Pacific/Auckland"`; the prompt's `turn.timezone`. Null when it
|
|
175
|
+
* carried none.
|
|
176
|
+
*/
|
|
177
|
+
readonly timezone: string | null;
|
|
178
|
+
/**
|
|
179
|
+
* The BCP 47 locale the turn's send carried, such as `"en-NZ"`; the
|
|
180
|
+
* prompt's `turn.locale`. Null when it carried none.
|
|
181
|
+
*/
|
|
182
|
+
readonly locale: string | null;
|
|
161
183
|
/**
|
|
162
184
|
* Attach an app-only artifact to this call's row, replacing any earlier
|
|
163
185
|
* one. The model never sees it; your app reads it from the call's row —
|
|
@@ -229,6 +251,30 @@ export interface FunctionApi {
|
|
|
229
251
|
"callId": string | number;
|
|
230
252
|
body: unknown;
|
|
231
253
|
}): Promise<any>;
|
|
254
|
+
"attachments": {
|
|
255
|
+
/** `agentSessions.attachments.downloadHeaders` — HEAD /agent-sessions/{sessionId}/attachments/{blobId}/download. Get an agent session attachment's download headers */
|
|
256
|
+
"downloadHeaders"(args: {
|
|
257
|
+
"sessionId": string | number;
|
|
258
|
+
"blobId": string | number;
|
|
259
|
+
"disposition"?: string | number | boolean;
|
|
260
|
+
}): Promise<HeaderResult>;
|
|
261
|
+
/** `agentSessions.attachments.downloadUrl` — GET /agent-sessions/{sessionId}/attachments/{blobId}/download. Download an agent session attachment */
|
|
262
|
+
"downloadUrl"(args: {
|
|
263
|
+
"sessionId": string | number;
|
|
264
|
+
"blobId": string | number;
|
|
265
|
+
"disposition"?: string | number | boolean;
|
|
266
|
+
}): Promise<Uint8Array>;
|
|
267
|
+
/** `agentSessions.attachments.upload` — PUT /agent-sessions/{sessionId}/attachments/{blobId}. Upload an agent session attachment */
|
|
268
|
+
"upload"(args: {
|
|
269
|
+
"sessionId": string | number;
|
|
270
|
+
"blobId": string | number;
|
|
271
|
+
"X-Blob-Filename": string | number;
|
|
272
|
+
"X-Blob-Size": string | number;
|
|
273
|
+
"X-Blob-Sha256": string | number;
|
|
274
|
+
"Content-Type"?: string | number;
|
|
275
|
+
body: ArrayBuffer | Uint8Array | string;
|
|
276
|
+
}): Promise<any>;
|
|
277
|
+
};
|
|
232
278
|
/** `agentSessions.cancel` — POST /agent-sessions/{sessionId}/cancel. Cancel an agent session's active turn */
|
|
233
279
|
"cancel"(args: {
|
|
234
280
|
"sessionId": string | number;
|
|
@@ -838,6 +884,7 @@ export interface FunctionApi {
|
|
|
838
884
|
"X-Blob-Filename": string | number;
|
|
839
885
|
"X-Blob-Size": string | number;
|
|
840
886
|
"X-Blob-Sha256": string | number;
|
|
887
|
+
"Content-Type"?: string | number;
|
|
841
888
|
body: ArrayBuffer | Uint8Array | string;
|
|
842
889
|
}): Promise<any>;
|
|
843
890
|
};
|
|
@@ -1061,6 +1108,7 @@ export interface FunctionApi {
|
|
|
1061
1108
|
"limit"?: string | number | boolean;
|
|
1062
1109
|
"cursor"?: string | number | boolean;
|
|
1063
1110
|
"filter"?: Record<string, unknown> | string;
|
|
1111
|
+
"sort"?: Record<string, unknown> | string;
|
|
1064
1112
|
}): Promise<any>;
|
|
1065
1113
|
/** `documents.records.save` — POST /documents/{documentId}/records/{model}. Create or replace a record in a document model */
|
|
1066
1114
|
"save"(args: {
|
|
@@ -1645,6 +1693,24 @@ export type DocumentModelRow<M extends string> = M extends keyof DocumentSchemas
|
|
|
1645
1693
|
/** The options a document model read takes: a filter object (or its JSON), a page size, a cursor. */
|
|
1646
1694
|
export interface DocumentQueryOptions {
|
|
1647
1695
|
filter?: Record<string, unknown> | string;
|
|
1696
|
+
/**
|
|
1697
|
+
* The order of the rows: each field maps to 1 (ascending) or -1
|
|
1698
|
+
* (descending), and key order is precedence, as in { createdAt: -1 }. `id`
|
|
1699
|
+
* breaks ties unless you name it. `limit` and `cursor` apply to the
|
|
1700
|
+
* ordered rows; pass the same sort with a `cursor`, since a cursor from
|
|
1701
|
+
* another sort is refused with a 400.
|
|
1702
|
+
*/
|
|
1703
|
+
sort?: Record<string, 1 | -1>;
|
|
1704
|
+
/**
|
|
1705
|
+
* Records per page: 100 when omitted, at most 10,000; a larger value is
|
|
1706
|
+
* refused with a 400 naming the maximum, never clamped. A page also ends
|
|
1707
|
+
* before the record that would take it past 8 MiB (the sum of each
|
|
1708
|
+
* record's JSON in UTF-8 bytes; the envelope is not counted), answering
|
|
1709
|
+
* `hasMore: true` and a `nextCursor` that continues from the last record
|
|
1710
|
+
* returned; a single record larger than 8 MiB is answered alone. A page
|
|
1711
|
+
* that fills `limit` exactly also answers `hasMore: true`; loop on
|
|
1712
|
+
* `hasMore` rather than counting rows.
|
|
1713
|
+
*/
|
|
1648
1714
|
limit?: number;
|
|
1649
1715
|
cursor?: string;
|
|
1650
1716
|
/**
|
|
@@ -1693,6 +1759,12 @@ export interface DocumentBulkResult {
|
|
|
1693
1759
|
}
|
|
1694
1760
|
|
|
1695
1761
|
export interface DocumentModelHandle<TRow> {
|
|
1762
|
+
/**
|
|
1763
|
+
* One page of the model's records: 100 by default, up to 10,000 with
|
|
1764
|
+
* `limit`, and at most 8 MiB of record JSON unless a single larger record
|
|
1765
|
+
* is answered alone. Pass `nextCursor` back as `cursor` while
|
|
1766
|
+
* `hasMore` is true.
|
|
1767
|
+
*/
|
|
1696
1768
|
query(options?: DocumentQueryOptions): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;
|
|
1697
1769
|
count(options?: { filter?: Record<string, unknown> | string }): Promise<{ count: number }>;
|
|
1698
1770
|
aggregate(body: Record<string, unknown>): Promise<any>;
|
|
@@ -1846,7 +1918,11 @@ export interface AgentSessionCreateOptions<K extends SessionAgentKeys> {
|
|
|
1846
1918
|
export interface AgentSessionCreateResult {
|
|
1847
1919
|
/** The session: what the app keeps and uses for everything but opening. */
|
|
1848
1920
|
sessionId: string;
|
|
1849
|
-
/**
|
|
1921
|
+
/**
|
|
1922
|
+
* The session's conversation document, opened with the document client.
|
|
1923
|
+
* @deprecated Use `sessionId` with the session API (`ctx.agents`,
|
|
1924
|
+
* `ctx.api.agentSessions`); the field remains until a later breaking release.
|
|
1925
|
+
*/
|
|
1850
1926
|
documentId: string;
|
|
1851
1927
|
}
|
|
1852
1928
|
|
|
@@ -1854,7 +1930,11 @@ export interface AgentSessionCreateResult {
|
|
|
1854
1930
|
export interface AgentSessionInfo {
|
|
1855
1931
|
sessionId: string;
|
|
1856
1932
|
agentKey: string;
|
|
1857
|
-
/**
|
|
1933
|
+
/**
|
|
1934
|
+
* Open this with the document client to read the conversation.
|
|
1935
|
+
* @deprecated Use `sessionId` with the session API (`ctx.agents`,
|
|
1936
|
+
* `ctx.api.agentSessions`); the field remains until a later breaking release.
|
|
1937
|
+
*/
|
|
1858
1938
|
documentId: string;
|
|
1859
1939
|
ownerUserId: string;
|
|
1860
1940
|
/** ISO-8601. */
|
|
@@ -1919,6 +1999,11 @@ export interface AgentSessionListItem {
|
|
|
1919
1999
|
sessionId: string;
|
|
1920
2000
|
agentKey: string;
|
|
1921
2001
|
scope: string | null;
|
|
2002
|
+
/**
|
|
2003
|
+
* The session's conversation document.
|
|
2004
|
+
* @deprecated Use `sessionId` with the session API (`ctx.agents`,
|
|
2005
|
+
* `ctx.api.agentSessions`); the field remains until a later breaking release.
|
|
2006
|
+
*/
|
|
1922
2007
|
documentId: string;
|
|
1923
2008
|
ownerUserId: string;
|
|
1924
2009
|
role: "owner" | "participant" | "viewer";
|
|
@@ -1930,6 +2015,13 @@ export interface AgentSessionListItem {
|
|
|
1930
2015
|
hasUnread: boolean;
|
|
1931
2016
|
/** When the user last marked the session read (ISO-8601), or null. */
|
|
1932
2017
|
lastReadAt: string | null;
|
|
2018
|
+
/**
|
|
2019
|
+
* The session's status as of its last listed activity, or null for an
|
|
2020
|
+
* entry written before the status was listed. It may lag a status change
|
|
2021
|
+
* that came with no activity (a server tool's round); `getSession` reads
|
|
2022
|
+
* the current one.
|
|
2023
|
+
*/
|
|
2024
|
+
status: AgentSessionStatus | null;
|
|
1933
2025
|
}
|
|
1934
2026
|
|
|
1935
2027
|
/** What `ctx.agents.listSessions` takes — #3805. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primitive-functions",
|
|
3
|
-
"version": "0.3.0-alpha.
|
|
3
|
+
"version": "0.3.0-alpha.9",
|
|
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",
|