primitive-functions 0.3.0-alpha.7 → 0.3.0-alpha.8

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 +44 -1
  2. 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
  */
@@ -158,6 +158,24 @@ export interface FunctionToolContext {
158
158
  };
159
159
  /** The session's variables, set when it was created. */
160
160
  readonly variables: Record<string, unknown>;
161
+ /**
162
+ * The turn's validated context: the object the member's send carried,
163
+ * checked against the agent's `turnContext.schema`, or the return of the
164
+ * agent's context function. The same values the system prompt rendered as
165
+ * `turn.*`. Null when the turn carried none.
166
+ */
167
+ readonly context: Record<string, unknown> | null;
168
+ /**
169
+ * The IANA timezone the turn's send carried, such as
170
+ * `"Pacific/Auckland"`; the prompt's `turn.timezone`. Null when it
171
+ * carried none.
172
+ */
173
+ readonly timezone: string | null;
174
+ /**
175
+ * The BCP 47 locale the turn's send carried, such as `"en-NZ"`; the
176
+ * prompt's `turn.locale`. Null when it carried none.
177
+ */
178
+ readonly locale: string | null;
161
179
  /**
162
180
  * Attach an app-only artifact to this call's row, replacing any earlier
163
181
  * one. The model never sees it; your app reads it from the call's row —
@@ -1061,6 +1079,7 @@ export interface FunctionApi {
1061
1079
  "limit"?: string | number | boolean;
1062
1080
  "cursor"?: string | number | boolean;
1063
1081
  "filter"?: Record<string, unknown> | string;
1082
+ "sort"?: Record<string, unknown> | string;
1064
1083
  }): Promise<any>;
1065
1084
  /** `documents.records.save` — POST /documents/{documentId}/records/{model}. Create or replace a record in a document model */
1066
1085
  "save"(args: {
@@ -1645,6 +1664,24 @@ export type DocumentModelRow<M extends string> = M extends keyof DocumentSchemas
1645
1664
  /** The options a document model read takes: a filter object (or its JSON), a page size, a cursor. */
1646
1665
  export interface DocumentQueryOptions {
1647
1666
  filter?: Record<string, unknown> | string;
1667
+ /**
1668
+ * The order of the rows: each field maps to 1 (ascending) or -1
1669
+ * (descending), and key order is precedence, as in { createdAt: -1 }. `id`
1670
+ * breaks ties unless you name it. `limit` and `cursor` apply to the
1671
+ * ordered rows; pass the same sort with a `cursor`, since a cursor from
1672
+ * another sort is refused with a 400.
1673
+ */
1674
+ sort?: Record<string, 1 | -1>;
1675
+ /**
1676
+ * Records per page: 100 when omitted, at most 10,000; a larger value is
1677
+ * refused with a 400 naming the maximum, never clamped. A page also ends
1678
+ * before the record that would take it past 8 MiB (the sum of each
1679
+ * record's JSON in UTF-8 bytes; the envelope is not counted), answering
1680
+ * `hasMore: true` and a `nextCursor` that continues from the last record
1681
+ * returned; a single record larger than 8 MiB is answered alone. A page
1682
+ * that fills `limit` exactly also answers `hasMore: true`; loop on
1683
+ * `hasMore` rather than counting rows.
1684
+ */
1648
1685
  limit?: number;
1649
1686
  cursor?: string;
1650
1687
  /**
@@ -1693,6 +1730,12 @@ export interface DocumentBulkResult {
1693
1730
  }
1694
1731
 
1695
1732
  export interface DocumentModelHandle<TRow> {
1733
+ /**
1734
+ * One page of the model's records: 100 by default, up to 10,000 with
1735
+ * `limit`, and at most 8 MiB of record JSON unless a single larger record
1736
+ * is answered alone. Pass `nextCursor` back as `cursor` while
1737
+ * `hasMore` is true.
1738
+ */
1696
1739
  query(options?: DocumentQueryOptions): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;
1697
1740
  count(options?: { filter?: Record<string, unknown> | string }): Promise<{ count: number }>;
1698
1741
  aggregate(body: Record<string, unknown>): Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primitive-functions",
3
- "version": "0.3.0-alpha.7",
3
+ "version": "0.3.0-alpha.8",
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",