primitive-functions 0.3.0-alpha.0 → 0.3.0-alpha.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 +105 -16
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -138,10 +138,41 @@ export interface PrimitivePlatformError extends Error {
138
138
  */
139
139
  export interface FunctionApi {
140
140
  "agentSessions": {
141
+ /** `agentSessions.addMember` — POST /agent-sessions/{sessionId}/members. Add a member to an agent session, or change their role */
142
+ "addMember"(args: {
143
+ "sessionId": string | number;
144
+ body: unknown;
145
+ }): Promise<any>;
141
146
  /** `agentSessions.create` — POST /agent-sessions. Create an agent session (ctx.agents.createSession) */
142
147
  "create"(args: {
143
148
  body: unknown;
144
149
  }): Promise<any>;
150
+ /** `agentSessions.delete` — DELETE /agent-sessions/{sessionId}. Delete an agent session */
151
+ "delete"(args: {
152
+ "sessionId": string | number;
153
+ }): Promise<any>;
154
+ /** `agentSessions.get` — GET /agent-sessions/{sessionId}. Get an agent session */
155
+ "get"(args: {
156
+ "sessionId": string | number;
157
+ }): Promise<any>;
158
+ /** `agentSessions.list` — GET /agent-sessions. List one user's agent sessions */
159
+ "list"(args?: {
160
+ "userId"?: string | number | boolean;
161
+ "agent"?: string | number | boolean;
162
+ "scope"?: string | number | boolean;
163
+ "limit"?: string | number | boolean;
164
+ "cursor"?: string | number | boolean;
165
+ }): Promise<any>;
166
+ /** `agentSessions.removeMember` — DELETE /agent-sessions/{sessionId}/members/{userId}. Remove a member from an agent session */
167
+ "removeMember"(args: {
168
+ "sessionId": string | number;
169
+ "userId": string | number;
170
+ }): Promise<any>;
171
+ /** `agentSessions.rename` — PATCH /agent-sessions/{sessionId}. Rename an agent session */
172
+ "rename"(args: {
173
+ "sessionId": string | number;
174
+ body: unknown;
175
+ }): Promise<any>;
145
176
  };
146
177
  "analytics": {
147
178
  /** `analytics.cohortRetention` — GET /analytics/cohort-retention. Cohort retention metrics */
@@ -546,13 +577,6 @@ export interface FunctionApi {
546
577
  "get"(args: {
547
578
  "databaseId": string | number;
548
579
  }): Promise<any>;
549
- /**
550
- * `databases.getMetadata` — GET /databases/{databaseId}/metadata. DEPRECATED — get database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)
551
- * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)
552
- */
553
- "getMetadata"(args: {
554
- "databaseId": string | number;
555
- }): Promise<any>;
556
580
  /** `databases.grantGroupPermission` — POST /databases/{databaseId}/group-permissions. Grant a group permission on a database */
557
581
  "grantGroupPermission"(args: {
558
582
  "databaseId": string | number;
@@ -706,14 +730,6 @@ export interface FunctionApi {
706
730
  "databaseId": string | number;
707
731
  body: unknown;
708
732
  }): Promise<any>;
709
- /**
710
- * `databases.updateMetadata` — PATCH /databases/{databaseId}/metadata. DEPRECATED — update database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)
711
- * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)
712
- */
713
- "updateMetadata"(args: {
714
- "databaseId": string | number;
715
- body: unknown;
716
- }): Promise<any>;
717
733
  };
718
734
  "documents": {
719
735
  /** `documents.abortIngest` — POST /documents/{documentId}/ingest/{sessionId}/abort. Abort a bulk-load session before its swap */
@@ -1722,6 +1738,17 @@ export interface AgentSessionCreateOptions<K extends SessionAgentKeys> {
1722
1738
  scope?: string;
1723
1739
  /** 1 to 255 characters; defaults to the agent's display name. */
1724
1740
  title?: string;
1741
+ /**
1742
+ * Initial participants, who send messages and hold a `read-write` grant
1743
+ * on the session's document — #3805. Existing users of this app, not the
1744
+ * caller; with `viewers`, at most 50.
1745
+ */
1746
+ participants?: string[];
1747
+ /**
1748
+ * Initial viewers, who read the session and hold a `reader` grant — #3805.
1749
+ * Existing users of this app, not the caller, in neither list twice.
1750
+ */
1751
+ viewers?: string[];
1725
1752
  }
1726
1753
 
1727
1754
  /** What `ctx.agents.createSession` answers — #3803. */
@@ -1732,6 +1759,58 @@ export interface AgentSessionCreateResult {
1732
1759
  documentId: string;
1733
1760
  }
1734
1761
 
1762
+ /** What `ctx.agents.getSession` answers — #3805. Never the document's rows. */
1763
+ export interface AgentSessionInfo {
1764
+ sessionId: string;
1765
+ agentKey: string;
1766
+ /** Open this with the document client to read the conversation. */
1767
+ documentId: string;
1768
+ ownerUserId: string;
1769
+ /** ISO-8601. */
1770
+ createdAt: string;
1771
+ title: string | null;
1772
+ scope: string | null;
1773
+ /** ISO-8601; null when the session's listing row is missing. */
1774
+ lastActivityAt: string | null;
1775
+ /** The members, in the order they were added. */
1776
+ members: { viewers: string[]; participants: string[] };
1777
+ /** The invoking user's standing on the session. */
1778
+ role: "owner" | "participant" | "viewer" | "admin";
1779
+ }
1780
+
1781
+ /** One session in `ctx.agents.listSessions` — #3805. */
1782
+ export interface AgentSessionListItem {
1783
+ sessionId: string;
1784
+ agentKey: string;
1785
+ scope: string | null;
1786
+ documentId: string;
1787
+ ownerUserId: string;
1788
+ role: "owner" | "participant" | "viewer";
1789
+ title: string | null;
1790
+ /** ISO-8601. */
1791
+ lastActivityAt: string;
1792
+ createdAt: string | null;
1793
+ }
1794
+
1795
+ /** What `ctx.agents.listSessions` takes — #3805. There is no user: it is always the invoking user. */
1796
+ export interface AgentSessionListOptions {
1797
+ /** Only this agent's sessions. */
1798
+ agent?: string;
1799
+ /** Only sessions created with exactly this scope. */
1800
+ scope?: string;
1801
+ /** Page size, at most 100 (default 50). */
1802
+ limit?: number;
1803
+ /** The `nextCursor` of the previous page. */
1804
+ cursor?: string;
1805
+ }
1806
+
1807
+ /** A page of `ctx.agents.listSessions` — #3805. */
1808
+ export interface AgentSessionListPage {
1809
+ items: AgentSessionListItem[];
1810
+ hasMore: boolean;
1811
+ nextCursor?: string;
1812
+ }
1813
+
1735
1814
  /** One agent's client tools, by name: each one's `input` and `output` (#3798). */
1736
1815
  export type AgentClientTools<K extends AgentKeys> = PromptSchemas[K] extends {
1737
1816
  agent: { clientTools: infer T };
@@ -2125,12 +2204,22 @@ export interface FunctionContext {
2125
2204
  * `AGENT_SESSION_VARIABLES_INVALID` and `details.errors`.
2126
2205
  *
2127
2206
  * Once a tree has pushed, a key that is not an agent, and variables the
2128
- * agent's schema refuses, are compile errors.
2207
+ * agent's schema refuses, are compile errors. `participants` and
2208
+ * `viewers` name initial members (#3805).
2209
+ *
2210
+ * `getSession` and `listSessions` (#3805) read the INVOKING user's
2211
+ * sessions — the ones they own or are a member of — and nobody else's,
2212
+ * whoever invoked the function; a session the user is not in answers
2213
+ * `AGENT_SESSION_NOT_FOUND`. Both have the same origin rule as
2214
+ * `createSession`. Renaming, deleting and changing members are the
2215
+ * owner's, from a client.
2129
2216
  */
2130
2217
  agents: {
2131
2218
  createSession<K extends SessionAgentKeys>(
2132
2219
  options: AgentSessionCreateOptions<K>
2133
2220
  ): Promise<AgentSessionCreateResult>;
2221
+ getSession(sessionId: string): Promise<AgentSessionInfo>;
2222
+ listSessions(options?: AgentSessionListOptions): Promise<AgentSessionListPage>;
2134
2223
  };
2135
2224
  /**
2136
2225
  * The value of one app secret, under a `secret:<NAME>` grant (#3183).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primitive-functions",
3
- "version": "0.3.0-alpha.0",
3
+ "version": "0.3.0-alpha.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",