@useago/sdk 1.5.0 → 1.5.2

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 (50) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/AgoClient-5VGybmvz.cjs +8 -0
  3. package/dist/AgoClient-DXrH2AMi.js +964 -0
  4. package/dist/angular.cjs +1 -1
  5. package/dist/angular.d.cts +79 -2
  6. package/dist/angular.d.ts +79 -2
  7. package/dist/angular.js +2 -2
  8. package/dist/{createConversationSession-BBYfQLLS.cjs → createConversationSession-0WTqcCLK.cjs} +1 -1
  9. package/dist/{createConversationSession-DCSWShaW.js → createConversationSession-DPrrr70o.js} +1 -1
  10. package/dist/createFormCollector-1GKKwQV_.cjs +1 -0
  11. package/dist/{createFormCollector-sB6rMccD.js → createFormCollector-DYh90kiG.js} +97 -91
  12. package/dist/devtools.d.cts +79 -2
  13. package/dist/devtools.d.ts +79 -2
  14. package/dist/functions-CPs7omgM.cjs +1 -0
  15. package/dist/helpers.cjs +1 -1
  16. package/dist/helpers.d.cts +5 -0
  17. package/dist/helpers.d.ts +5 -0
  18. package/dist/helpers.js +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +95 -4
  21. package/dist/index.d.ts +95 -4
  22. package/dist/index.js +6 -6
  23. package/dist/react.cjs +3 -3
  24. package/dist/react.d.cts +186 -4
  25. package/dist/react.d.ts +186 -4
  26. package/dist/react.js +670 -475
  27. package/dist/testing.cjs +1 -1
  28. package/dist/testing.d.cts +79 -2
  29. package/dist/testing.d.ts +79 -2
  30. package/dist/testing.js +1 -1
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.d.cts +79 -2
  33. package/dist/vue.d.ts +79 -2
  34. package/dist/vue.js +1 -1
  35. package/dist/widget.cjs +4 -4
  36. package/dist/widget.d.cts +79 -2
  37. package/dist/widget.d.ts +79 -2
  38. package/dist/widget.js +437 -423
  39. package/llms-full.txt +74 -2
  40. package/package.json +1 -1
  41. package/dist/AgoClient-q39FIjSC.js +0 -912
  42. package/dist/AgoClient-wcPRaIMs.cjs +0 -8
  43. package/dist/createFormCollector-eimwwWEi.cjs +0 -1
  44. package/dist/functions-IGSjjvF4.cjs +0 -1
  45. package/dist/rolldown-runtime-16Nf8qvH.cjs +0 -1
  46. /package/dist/{autoContinue-D3Mmaaca.js → autoContinue-CC8K9mBU.js} +0 -0
  47. /package/dist/{autoContinue-CcCTva-D.cjs → autoContinue-CP9pJR-V.cjs} +0 -0
  48. /package/dist/{createMockClient-CjdCqixj.cjs → createMockClient-C-wrjb2C.cjs} +0 -0
  49. /package/dist/{createMockClient-BUc9PSbo.js → createMockClient-we-XoPom.js} +0 -0
  50. /package/dist/{functions-CApuQZ2b.js → functions-tzyOZNp6.js} +0 -0
package/llms-full.txt CHANGED
@@ -1304,6 +1304,17 @@ Per framework:
1304
1304
  | Vue | `useAgoFunction(name, options)` (auto-cleanup) |
1305
1305
  | Angular | `agoService.registerFunction(def)` |
1306
1306
 
1307
+ ### Keep the number of functions low
1308
+
1309
+ You can send up to **30** client functions with a message. Above that, the
1310
+ request is rejected.
1311
+
1312
+ Stay well under the limit whenever you can. The more functions the agent has to
1313
+ choose from, the harder it becomes to pick the right one: past **10** functions
1314
+ in a single message, expect the agent to call the wrong function or miss the
1315
+ right one more often. Register only the functions relevant to the current page
1316
+ or state, and unregister the ones that no longer apply.
1317
+
1307
1318
  ### Navigation shortcut
1308
1319
 
1309
1320
  A common case (letting the agent move the user around) has a dedicated helper
@@ -1426,8 +1437,11 @@ How the gap is bridged depends on the client-functions mode:
1426
1437
 
1427
1438
  A paused turn also survives a full page reload: after `getConversation(...)`,
1428
1439
  call `client.resumePendingClientFunctions(conversation)` to re-run the waiting
1429
- functions, submit their results, and resume the turn (opt-in — re-running a
1430
- navigation on reload navigates again).
1440
+ functions, submit their results, and resume the turn (opt-in, re-running a
1441
+ navigation on reload navigates again). A call gated by the approval policy (see
1442
+ below) is not re-run on reload either: `resumePendingClientFunctions` holds it
1443
+ for `approveFunction` / `rejectFunction` and keeps the turn paused, exactly as on
1444
+ the live stream.
1431
1445
 
1432
1446
  ### Observe invocations
1433
1447
 
@@ -1440,6 +1454,37 @@ client.on("function:result", ({ result, error }) =>
1440
1454
  );
1441
1455
  ```
1442
1456
 
1457
+ ### Approval gate (ask before running)
1458
+
1459
+ In pause mode you can hold a client function call until the user approves it.
1460
+ Set `approvalPolicy` on the config to gate calls by name (or anything on the
1461
+ invocation), or mark a single function with `requiresApproval: true`. The two OR
1462
+ together.
1463
+
1464
+ ```ts
1465
+ const client = new AgoClient({
1466
+ baseUrl: "https://playground.api.useago.com",
1467
+ agent: "your-agent",
1468
+ // Return true for calls the user must approve first.
1469
+ approvalPolicy: (inv) => inv.functionName === "deleteAccount",
1470
+ });
1471
+
1472
+ client.on("function:awaiting-approval", ({ invocationId, functionName }) => {
1473
+ // Show your UI, then decide:
1474
+ if (userSaidYes) client.approveFunction(invocationId); // runs it, resumes the turn
1475
+ else client.rejectFunction(invocationId); // submits a rejection, agent sees the decline
1476
+ });
1477
+ ```
1478
+
1479
+ A gated call stays at `WAITING_CLIENT`: the handler does not run and nothing is
1480
+ submitted until `approveFunction(invocationId)`. `rejectFunction(invocationId)`
1481
+ submits `{ approved: false, reason: "user_rejected" }` so the agent knows the
1482
+ user declined, then lets the turn resume. This is a no-op in placeholder mode
1483
+ (there is no paused turn to hold onto), so the call runs normally.
1484
+
1485
+ In React, `useAgoActivity` surfaces awaiting items with ready-made `approve` /
1486
+ `reject` controls (see the [React guide](../frameworks/react.md)).
1487
+
1443
1488
  ---
1444
1489
 
1445
1490
  ## Pre-built helpers
@@ -1518,9 +1563,35 @@ interface ContextEntry {
1518
1563
  name?: string; // human label, e.g. "Order detail"
1519
1564
  description?: string; // what this context represents
1520
1565
  data?: Record<string, unknown>; // structured data for the AI
1566
+ stable?: boolean; // constant for the whole conversation (see below)
1521
1567
  }
1522
1568
  ```
1523
1569
 
1570
+ ### Stable context (prompt caching)
1571
+
1572
+ By default an entry is re-sent next to every new user message, which is right
1573
+ for data that changes as the user acts (a cart, the current page). If an
1574
+ entry's content never changes during a conversation (a schema, a capability
1575
+ list, static instructions), mark it `stable: true`: the backend pins it right
1576
+ after the system prompt, where LLM providers cache it across turns instead of
1577
+ re-processing it on every message.
1578
+
1579
+ ```ts
1580
+ client.setContext("catalog", {
1581
+ name: "Product catalog",
1582
+ description: "The products the agent can talk about",
1583
+ data: { products: PRODUCTS },
1584
+ stable: true, // content is identical on every message
1585
+ });
1586
+ ```
1587
+
1588
+ Only mark an entry stable when its content is byte-identical on every message.
1589
+ A "stable" entry that changes between messages invalidates the provider's
1590
+ cache for the whole conversation history, which costs more than leaving the
1591
+ flag off. Form collectors do this automatically: the form's schema is
1592
+ registered as a stable entry and only the live values/missing state is sent
1593
+ per message.
1594
+
1524
1595
  ### Dynamic context
1525
1596
 
1526
1597
  A function evaluated on every send, perfect for data outside your render state
@@ -1608,6 +1679,7 @@ const final = await client.waitFor("message:complete", { timeout: 10_000 });
1608
1679
  | `toolCall:received` | `ToolCallData` |
1609
1680
  | `toolCall:form` | `ToolCallData` (only when the tool call is a form) |
1610
1681
  | `function:invoke` | `{ invocationId, functionName, arguments, conversationId }` |
1682
+ | `function:awaiting-approval` | `{ invocationId, functionName, arguments, conversationId }`: a client function call is held pending user approval (pause mode + an `approvalPolicy`/`requiresApproval` match). The turn stays at `WAITING_CLIENT`; call `approveFunction(invocationId)` to run it and resume, or `rejectFunction(invocationId)` to decline. See [Approval gate](functions-and-context.md#approval-gate-ask-before-running) |
1611
1683
  | `function:result` | `{ invocationId, result, error? }` |
1612
1684
  | `form:submitted` | `{ name, values, result }`: a form collector submitted successfully; `result` is the submit response (the third-party API's answer) |
1613
1685
  | `form:error` | `{ name, values, error }`: a form collector submit failed at the network/server level (HTTP non-2xx or a thrown handler/fetch). Validation pre-checks (missing fields, no submit target) do not fire this |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useago/sdk",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Create In-APP AI agents that answers question and performs actions. Works with React, Vue, Angular and vanilla JS/TS.",
5
5
  "type": "module",
6
6
  "sideEffects": false,