@lotics/app-sdk 0.131.7 → 0.131.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.
@@ -6,6 +6,7 @@
6
6
  * before `finish`); until it arrives, `submit_result`'s input — never a part.
7
7
  */
8
8
  import type { UIMessagePart, UIDataTypes, UITools } from "ai";
9
+ import type { AgentRunRecord } from "./hooks.js";
9
10
  /** An ai-sdk message part — the render model, tool-set-agnostic. */
10
11
  export type AgentUIPart = UIMessagePart<UIDataTypes, UITools>;
11
12
  /** Mirrors the server's `INTERACTIVE_APP_TOOLS`; a call parks the run as `awaiting_input`. */
@@ -17,17 +18,8 @@ export interface AgentRunState {
17
18
  output?: unknown;
18
19
  error?: string;
19
20
  }
20
- export interface SettledAgentRun {
21
- status: string;
22
- output?: unknown;
23
- error_message?: string | null;
24
- /** On an `awaiting_input` row: rebuilds the ask for a client that lost the stream. */
25
- pending_interactive?: {
26
- tool_call_id: string;
27
- tool_name: string;
28
- input: unknown;
29
- } | null;
30
- }
21
+ /** The part of a polled row the stream's state adopts. */
22
+ export type SettledAgentRun = Pick<AgentRunRecord, "status"> & Partial<Pick<AgentRunRecord, "output" | "error_message" | "pending_interactive">>;
31
23
  /**
32
24
  * Fold a polled row into the stream's state, for a dropped or truncated stream.
33
25
  * The row owns status and structured output; a free-text row's string output
package/dist/hooks.d.ts CHANGED
@@ -4,6 +4,7 @@ import { type AiContextValue } from "./rpc.js";
4
4
  import { type AgentUIPart, type PendingChoice, type AgentRunLanding } from "./agent_stream.js";
5
5
  import type { AppWorkflows, AppWorkflowResults, AppAgents, AppAgentResults } from "./types.js";
6
6
  import type { PhotoPlace, ResolvedMember } from "./shared_types.js";
7
+ import type { AppAgentRunStatus } from "./shared_types.js";
7
8
  export type { AgentRunState, AgentUIPart, PendingChoice, ChoiceQuestion, ChoiceOption, AskUserChoiceOutput, AgentRunLanding } from "./agent_stream.js";
8
9
  export { buildChoiceOutput } from "./agent_stream.js";
9
10
  /**
@@ -214,7 +215,8 @@ export interface AgentRunRecord {
214
215
  id: string;
215
216
  agent_alias: string;
216
217
  session_id: string;
217
- status: string;
218
+ /** `running` until the run ends; `awaiting_input` while it waits on an answer; `error` carries `error_message`; `aborted` (cancelled) leaves it null. */
219
+ status: AppAgentRunStatus;
218
220
  input: Record<string, unknown> | null;
219
221
  output: unknown;
220
222
  error_message: string | null;
package/dist/index.js CHANGED
@@ -295,27 +295,38 @@ function useAttachmentQueue(upload, options) {
295
295
  var INTERACTIVE_TOOLS = /* @__PURE__ */ new Set(["ask_user_choice"]);
296
296
  var SUBMIT_TOOL = "submit_result";
297
297
  function adoptSettledRun(state, settled) {
298
- if (settled.status === "completed") {
299
- const structured = settled.output !== null && typeof settled.output === "object" ? settled.output : void 0;
300
- return { ...state, status: "completed", output: structured ?? state.output };
301
- }
302
- if (settled.status === "awaiting_input") {
303
- const next = { ...state, status: "awaiting_input" };
304
- if (pendingInteractiveCall(next)) return next;
305
- const p = settled.pending_interactive;
306
- const alreadyPresent = p && state.parts.some((part) => part.type === "dynamic-tool" && part.toolCallId === p.tool_call_id);
307
- if (p && INTERACTIVE_TOOLS.has(p.tool_name) && !alreadyPresent) {
308
- return {
309
- ...next,
310
- parts: [
311
- ...state.parts,
312
- { type: "dynamic-tool", toolName: p.tool_name, toolCallId: p.tool_call_id, state: "input-available", input: p.input }
313
- ]
314
- };
298
+ switch (settled.status) {
299
+ case "running":
300
+ return state;
301
+ case "completed": {
302
+ const structured = settled.output !== null && typeof settled.output === "object" ? settled.output : void 0;
303
+ return { ...state, status: "completed", output: structured ?? state.output };
304
+ }
305
+ // A parked row is resumable; rebuild the ask part if the stream never delivered it.
306
+ case "awaiting_input": {
307
+ const next = { ...state, status: "awaiting_input" };
308
+ if (pendingInteractiveCall(next)) return next;
309
+ const p = settled.pending_interactive;
310
+ const alreadyPresent = p && state.parts.some((part) => part.type === "dynamic-tool" && part.toolCallId === p.tool_call_id);
311
+ if (p && INTERACTIVE_TOOLS.has(p.tool_name) && !alreadyPresent) {
312
+ return {
313
+ ...next,
314
+ parts: [
315
+ ...state.parts,
316
+ { type: "dynamic-tool", toolName: p.tool_name, toolCallId: p.tool_call_id, state: "input-available", input: p.input }
317
+ ]
318
+ };
319
+ }
320
+ return next;
321
+ }
322
+ case "error":
323
+ case "aborted":
324
+ return { ...state, status: "error", error: settled.error_message ?? "The run was stopped." };
325
+ default: {
326
+ const unknown = settled.status;
327
+ return { ...state, status: "error", error: `The run ended in a state this version of the app does not know: ${String(unknown)}.` };
315
328
  }
316
- return next;
317
329
  }
318
- return { ...state, status: "error", error: settled.error_message ?? "The run was stopped." };
319
330
  }
320
331
  function decodeJson(raw) {
321
332
  try {
@@ -8158,6 +8169,8 @@ var TOOL_INPUT_SEMANTICS = {
8158
8169
  record_ids: { kind: "record_refs" },
8159
8170
  filters: { kind: "filter_tree", table_from: "table_id" },
8160
8171
  cascade: { kind: "scalar" },
8172
+ // Deletes the rows already in the trash for good: it names no field.
8173
+ permanent: { kind: "scalar" },
8161
8174
  dry_run: { kind: "scalar" },
8162
8175
  as_member: { kind: "scalar" },
8163
8176
  removal: { kind: "table_field_array" }
@@ -4,6 +4,7 @@
4
4
  * tarball. Written at every build, never edited.
5
5
  */
6
6
  export type AppAbsence = { member: { id: string; name: string; }; stand_in: { id: string; name: string; }; starts_on: string; ends_on: string; group_ids: string[]; };
7
+ export type AppAgentRunStatus = "aborted" | "awaiting_input" | "completed" | "error" | "running";
7
8
  /** A files cell entry; `url`/`thumbnail_url` are presigned (24h) and load from the sandboxed frame. */
8
9
  export interface AppFile {
9
10
  id: string;
package/docs/ai.md CHANGED
@@ -199,7 +199,7 @@ that reads its own input never gains the ability to read *other* files in the wo
199
199
 
200
200
  ## `useAgentRuns(sessionId, opts?)` — session history
201
201
 
202
- Reads a session's persisted run history, oldest-first: `{ runs, loading, error, refetch }`, where each `AgentRunRecord` carries `id`, `agent_alias`, `session_id`, `status`, `input`, `output`, `error_message`, `started_at`, `completed_at`. `opts` takes `{ enabled?, revalidateOnFocus? }`. A persisted record's `output` is the validated structured object for a structured agent and the **final answer string** for a free-text agent.
202
+ Reads a session's persisted run history, oldest-first: `{ runs, loading, error, refetch }`, where each `AgentRunRecord` carries `id`, `agent_alias`, `session_id`, `status`, `input`, `output`, `error_message`, `started_at`, `completed_at`. `status` is `running`, `awaiting_input` (parked on an answer), `completed`, `error` (with `error_message`) or `aborted` (cancelled; `error_message` stays null). `opts` takes `{ enabled?, revalidateOnFocus? }`. A persisted record's `output` is the validated structured object for a structured agent and the **final answer string** for a free-text agent.
203
203
 
204
204
  **Limitation:** the embedded product host implements no history op — `useAgentRuns` errors with "Unknown RPC op: agentRuns" in an embedded app, and a standalone caller is anonymous, so it is refused. The history *exists* server-side (it is what feeds session context), but this hook reads it from no transport. Do not build a session-log UI on it; keep the visible log in app state from the live `useAgentRun` results instead.
205
205
 
package/docs/workflows.md CHANGED
@@ -256,6 +256,8 @@ be written before its declaration. A key outside its row is refused when the bod
256
256
  `wait` and `wait_for_event` carry no payload and are statement-only. `wait.duration_in_minutes`
257
257
  and every `timeout_in_minutes` must be a **positive number literal**, not an expression, and
258
258
  `wait_for_event.event_type` is a string literal from a closed set — `"payment"` or `"webhook"`.
259
+ A `"payment"` wait resumes with `event_data.payment_status` set to `"paid"`, `"failed"` or `"expired"`; `"expired"`
260
+ arrives once the payment link has expired, within about half an hour of its expiry.
259
261
 
260
262
  ### `agent` — LLM reasoning as one step
261
263
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.131.7",
3
+ "version": "0.131.9",
4
4
  "description": "The SDK a Lotics custom-code app reads and writes through — typed hooks over the host bridge, cell readers, mount() and AppRouter",
5
5
  "type": "module",
6
6
  "exports": {