@serenity-star/sdk 2.6.6 → 2.7.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serenity-star/sdk",
3
- "version": "2.6.6",
3
+ "version": "2.7.0",
4
4
  "description": "The Serenity Star JavaScript SDK provides a convenient way to interact with the Serenity Star API, enabling you to build custom applications.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/readme.md CHANGED
@@ -485,6 +485,53 @@ const newResponse = await conversation.sendMessage("I need a summary of my lates
485
485
  console.log(newResponse.content); // Summary of the meeting notes
486
486
  ```
487
487
 
488
+ ## Tool approvals
489
+
490
+ When a skill is configured as *Requires approval*, the run pauses instead of invoking it. The result
491
+ carries an `approval` pending action, and the conversation stays blocked until you send a decision:
492
+ any further message on it returns HTTP 400 with `errors["tool_approval_pending"]`.
493
+
494
+ Detect the request on the result (or on the `stop` payload when streaming) and resolve it with
495
+ `streamToolApprovals` / `sendToolApprovals`. The resume turn carries **no user message** — the
496
+ decision is the whole turn — and continues the same conversation, so the answer arrives as the rest
497
+ of the same assistant response.
498
+
499
+ ```tsx
500
+ import SerenityClient from '@serenity-star/sdk';
501
+
502
+ const client = new SerenityClient({
503
+ apiKey: '<SERENITY_API_KEY>',
504
+ });
505
+
506
+ const conversation = await client.agents.assistants.createConversation("chef-assistant");
507
+
508
+ const response = await conversation.streamMessage("What are the trending recipes this week?");
509
+
510
+ const approval = response.pending_actions?.find((action) => action.type === "approval");
511
+
512
+ if (approval) {
513
+ console.log(approval.skill_code); // "web-search" — the skill awaiting approval
514
+
515
+ // Ask the user, then echo the request id back with their decision.
516
+ const continuation = await conversation.streamToolApprovals([
517
+ { requestId: approval.request_id, approved: true },
518
+ ]);
519
+
520
+ console.log(continuation.content); // the rest of the answer
521
+ }
522
+ ```
523
+
524
+ Notes:
525
+
526
+ - `request_id` is the only value that must be echoed back. `call_id`, `skill_type`, `tool` and
527
+ `arguments` are informational.
528
+ - Decision members are camelCase (`requestId`, `approved`, `reason?`). `reason` is optional and
529
+ omitted from the request when empty.
530
+ - Approvals can only be resolved on an existing conversation — both methods throw when
531
+ `conversation.conversationId` is not set yet. It is populated as soon as the first execution
532
+ finishes, so an approval raised on the very first turn is resolvable.
533
+ - A resumed turn can itself raise another approval; keep handling `pending_actions` until it is empty.
534
+
488
535
  ---
489
536
 
490
537
  # Activities