@serenity-star/sdk 2.7.0 → 2.8.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/dist/index.d.mts +60 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/readme.md +78 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-star/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.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
|
@@ -39,6 +39,7 @@ The Serenity Star JS/TS SDK provides a comprehensive interface for interacting w
|
|
|
39
39
|
- [Download Attached Files](#download-attached-files)
|
|
40
40
|
- [Stop Streaming Response](#stop-streaming-response)
|
|
41
41
|
- [Reasoning (Chain-of-Thought)](#reasoning-chain-of-thought)
|
|
42
|
+
- [Task events](#task-events)
|
|
42
43
|
- [Citations](#citations)
|
|
43
44
|
- [Citations on stored messages](#citations-on-stored-messages)
|
|
44
45
|
- [Upload Files (Volatile Knowledge)](#upload-files-volatile-knowledge)
|
|
@@ -916,6 +917,83 @@ conversation
|
|
|
916
917
|
await conversation.streamMessage("Plan a three-course vegetarian dinner");
|
|
917
918
|
```
|
|
918
919
|
|
|
920
|
+
## Task events
|
|
921
|
+
|
|
922
|
+
While an agent streams, it reports the internal work it performs through the `task_start` / `task_stop` event pair. A **task** is any discrete step the agent runs on its way to an answer — a skill execution, a tool call, and whatever step types the platform adds later. The SDK forwards every task frame it receives without filtering, so new task types reach your handlers as soon as the platform starts emitting them.
|
|
923
|
+
|
|
924
|
+
Use them to reflect the agent's progress in your UI while it works, or to time, trace and log what the agent actually did.
|
|
925
|
+
|
|
926
|
+
These events only exist on **streamed** executions (`streamMessage` / `stream`). A non-streamed call returns the final result only.
|
|
927
|
+
|
|
928
|
+
Each task carries a `task_key` identifying what ran and a `metadata` object describing it. Both are task-type specific: match on `task_key` for the types you care about and ignore the rest, rather than assuming a single shape.
|
|
929
|
+
|
|
930
|
+
```tsx
|
|
931
|
+
import SerenityClient from '@serenity-star/sdk';
|
|
932
|
+
|
|
933
|
+
const client = new SerenityClient({
|
|
934
|
+
apiKey: '<SERENITY_API_KEY>',
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
const conversation = await client.agents.assistants.createConversation("sales-assistant");
|
|
938
|
+
|
|
939
|
+
conversation
|
|
940
|
+
.on("task_start", (task) => console.log("started", task.task, task.task_key))
|
|
941
|
+
.on("task_stop", (task) =>
|
|
942
|
+
console.log("finished", task.task_key, task.duration, task.success)
|
|
943
|
+
)
|
|
944
|
+
.on("content", (chunk) => process.stdout.write(chunk));
|
|
945
|
+
|
|
946
|
+
await conversation.streamMessage("What do we have in stock for vintage guitars?");
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
### `task_start` payload
|
|
950
|
+
|
|
951
|
+
| Field | Type | Description |
|
|
952
|
+
| --- | --- | --- |
|
|
953
|
+
| `type` | `string` | The event name, `task_start`. |
|
|
954
|
+
| `task` | `string` | Human-readable description of the task, safe to show in a UI. |
|
|
955
|
+
| `task_key` | `string` | Identifier of what ran. Its format depends on the task type. |
|
|
956
|
+
| `metadata` | `object` | Extra details about the task. Contents depend on the task type. |
|
|
957
|
+
| `start_time_utc` | `string` | When the task started (UTC). |
|
|
958
|
+
| `input` | `object` | The arguments the task was invoked with. Shape depends on the task. |
|
|
959
|
+
|
|
960
|
+
### `task_stop` payload
|
|
961
|
+
|
|
962
|
+
Same envelope as `task_start`, plus:
|
|
963
|
+
|
|
964
|
+
| Field | Type | Description |
|
|
965
|
+
| --- | --- | --- |
|
|
966
|
+
| `end_time_utc` | `string` | When the task finished (UTC). |
|
|
967
|
+
| `duration` | `string` | Elapsed time as a timespan string, e.g. `00:00:00.0002104`. |
|
|
968
|
+
| `success` | `boolean` | Whether the task completed successfully. |
|
|
969
|
+
| `output` | `any` | The task's result. Shape depends on the task. |
|
|
970
|
+
|
|
971
|
+
Unknown fields the server may add in the future are preserved on the payload — both types carry an index signature.
|
|
972
|
+
|
|
973
|
+
### Recognising a task type
|
|
974
|
+
|
|
975
|
+
Skill executions are one task type. Their `task_key` follows the `skills_<SkillCode>_execute` convention, and the skill is described under `metadata.skill`:
|
|
976
|
+
|
|
977
|
+
```json
|
|
978
|
+
{
|
|
979
|
+
"type": "task_start",
|
|
980
|
+
"task": "Executing Skill: GetProductInfo",
|
|
981
|
+
"task_key": "skills_GetProductInfo_execute",
|
|
982
|
+
"metadata": { "skill": { "type": "Prompt", "code": "GetProductInfo" } },
|
|
983
|
+
"start_time_utc": "2026-08-24T10:22:54.1822224Z",
|
|
984
|
+
"input": { "categoryName": "Music instruments from the 1960s" }
|
|
985
|
+
}
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
```tsx
|
|
989
|
+
conversation.on("task_start", (task) => {
|
|
990
|
+
const skillCode = task.metadata?.skill?.code;
|
|
991
|
+
if (skillCode) {
|
|
992
|
+
showSpinner(`Running ${skillCode}…`);
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
```
|
|
996
|
+
|
|
919
997
|
## Citations
|
|
920
998
|
|
|
921
999
|
When an agent grounds its response in knowledge sources (knowledge files or websites), it returns **citations** that map spans of the generated message back to the source passages they came from. Citations are available across all agent types that support knowledge grounding.
|