@serenity-star/sdk 2.6.1 → 2.6.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.
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/package.json +1 -1
- package/readme.md +36 -4
package/dist/index.d.mts
CHANGED
|
@@ -192,6 +192,13 @@ type CitationRes = {
|
|
|
192
192
|
relevance?: number;
|
|
193
193
|
source: CitationSource | null;
|
|
194
194
|
};
|
|
195
|
+
type CitationResWithoutText = {
|
|
196
|
+
citation_index: number;
|
|
197
|
+
start_index: number;
|
|
198
|
+
end_index: number;
|
|
199
|
+
relevance?: number;
|
|
200
|
+
source: CitationSource | null;
|
|
201
|
+
};
|
|
195
202
|
type AgentResult = {
|
|
196
203
|
content: string;
|
|
197
204
|
instance_id: string;
|
|
@@ -573,6 +580,7 @@ type Message = ({
|
|
|
573
580
|
action_results?: {
|
|
574
581
|
[key: string]: PluginExecutionResult;
|
|
575
582
|
};
|
|
583
|
+
citations?: CitationResWithoutText[];
|
|
576
584
|
};
|
|
577
585
|
type PluginExecutionResult = SpeechGenerationResult;
|
|
578
586
|
type SpeechGenerationResult = {
|
package/dist/index.d.ts
CHANGED
|
@@ -192,6 +192,13 @@ type CitationRes = {
|
|
|
192
192
|
relevance?: number;
|
|
193
193
|
source: CitationSource | null;
|
|
194
194
|
};
|
|
195
|
+
type CitationResWithoutText = {
|
|
196
|
+
citation_index: number;
|
|
197
|
+
start_index: number;
|
|
198
|
+
end_index: number;
|
|
199
|
+
relevance?: number;
|
|
200
|
+
source: CitationSource | null;
|
|
201
|
+
};
|
|
195
202
|
type AgentResult = {
|
|
196
203
|
content: string;
|
|
197
204
|
instance_id: string;
|
|
@@ -573,6 +580,7 @@ type Message = ({
|
|
|
573
580
|
action_results?: {
|
|
574
581
|
[key: string]: PluginExecutionResult;
|
|
575
582
|
};
|
|
583
|
+
citations?: CitationResWithoutText[];
|
|
576
584
|
};
|
|
577
585
|
type PluginExecutionResult = SpeechGenerationResult;
|
|
578
586
|
type SpeechGenerationResult = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-star/sdk",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
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
|
- [Citations](#citations)
|
|
42
|
+
- [Citations on stored messages](#citations-on-stored-messages)
|
|
42
43
|
- [Upload Files (Volatile Knowledge)](#upload-files-volatile-knowledge)
|
|
43
44
|
- [Audio Input](#audio-input)
|
|
44
45
|
- [Send Audio Messages (Assistants/Copilots)](#send-audio-messages-assistantscopilots)
|
|
@@ -257,7 +258,7 @@ const conversation = await client.agents.assistants.getConversationById("<agent-
|
|
|
257
258
|
|
|
258
259
|
console.log(
|
|
259
260
|
conversation.id, // "<conversation-id>"
|
|
260
|
-
conversation.messages, // Array of messages
|
|
261
|
+
conversation.messages, // Array of messages (each may include a `citations` array — see Citations)
|
|
261
262
|
conversation.open // Boolean that indicates if the conversation was closed or not
|
|
262
263
|
);
|
|
263
264
|
|
|
@@ -847,10 +848,11 @@ await activity.stream();
|
|
|
847
848
|
|
|
848
849
|
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.
|
|
849
850
|
|
|
850
|
-
Citations are delivered in
|
|
851
|
+
Citations are delivered in three places:
|
|
851
852
|
|
|
852
853
|
1. **Incrementally**, as the second argument of the `content` event during streaming.
|
|
853
854
|
2. **Consolidated**, as the `citations` array on the final result (`response.citations`) — available for both streamed and non-streamed executions.
|
|
855
|
+
3. **Persisted**, on each `Message` loaded from conversation history (`message.citations`) — see [Citations on stored messages](#citations-on-stored-messages) below.
|
|
854
856
|
|
|
855
857
|
```tsx
|
|
856
858
|
import SerenityClient from '@serenity-star/sdk';
|
|
@@ -892,10 +894,10 @@ for (const citation of response.citations ?? []) {
|
|
|
892
894
|
|
|
893
895
|
> **Note:** `start_index` and `end_index` are offsets into the **full accumulated message**, not into the individual chunk delivered by a `content` event. Accumulate the chunks (or use `response.content`) before resolving these offsets.
|
|
894
896
|
|
|
895
|
-
The `CitationRes` and `CitationSource` types are exported from the package:
|
|
897
|
+
The `CitationRes`, `CitationResWithoutText`, and `CitationSource` types are exported from the package:
|
|
896
898
|
|
|
897
899
|
```ts
|
|
898
|
-
import type { CitationRes, CitationSource } from '@serenity-star/sdk';
|
|
900
|
+
import type { CitationRes, CitationResWithoutText, CitationSource } from '@serenity-star/sdk';
|
|
899
901
|
|
|
900
902
|
type CitationSource =
|
|
901
903
|
| {
|
|
@@ -920,6 +922,36 @@ type CitationRes = {
|
|
|
920
922
|
relevance?: number;
|
|
921
923
|
source: CitationSource | null;
|
|
922
924
|
};
|
|
925
|
+
|
|
926
|
+
// Same shape as CitationRes but without `cited_text`. Used for citations on
|
|
927
|
+
// messages loaded from conversation history (see "Get conversation by id").
|
|
928
|
+
type CitationResWithoutText = {
|
|
929
|
+
citation_index: number;
|
|
930
|
+
start_index: number;
|
|
931
|
+
end_index: number;
|
|
932
|
+
relevance?: number;
|
|
933
|
+
source: CitationSource | null;
|
|
934
|
+
};
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
### Citations on stored messages
|
|
938
|
+
|
|
939
|
+
Citations are also persisted on the conversation history. When you load past messages via [Get conversation by id](#get-conversation-by-id) (or read `conversation.messages`), each `Message` may carry a `citations` array of type `CitationResWithoutText[]` — the same shape as `CitationRes` but **without** the `cited_text` field (the verbatim passage is not stored alongside historical messages).
|
|
940
|
+
|
|
941
|
+
```tsx
|
|
942
|
+
const conversation = await client.agents.assistants.getConversationById("policy-assistant", "<conversation-id>");
|
|
943
|
+
|
|
944
|
+
for (const message of conversation.messages) {
|
|
945
|
+
for (const citation of message.citations ?? []) {
|
|
946
|
+
console.log(
|
|
947
|
+
citation.citation_index, // Display number rendered as the superscript (may repeat)
|
|
948
|
+
citation.start_index, // Offset into the message `value` where the cited span starts
|
|
949
|
+
citation.end_index, // Offset into the message `value` where the cited span ends
|
|
950
|
+
citation.relevance, // Optional relevance score
|
|
951
|
+
citation.source // The cited source (knowledge_file / knowledge_website), or null
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
923
955
|
```
|
|
924
956
|
|
|
925
957
|
## Upload Files (Volatile Knowledge)
|