@cheerlyai/agentlib-protocol 0.1.0 → 0.1.1
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/README.md +6 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -41,8 +41,9 @@ identifying anything.
|
|
|
41
41
|
|
|
42
42
|
## Sources
|
|
43
43
|
|
|
44
|
-
Agents with a knowledge base
|
|
45
|
-
section. Split it off so it
|
|
44
|
+
Agents with a data source — a knowledge base, web search, or an MCP server —
|
|
45
|
+
are instructed to end a reply with a `Sources:` section. Split it off so it
|
|
46
|
+
renders as citations rather than trailing prose:
|
|
46
47
|
|
|
47
48
|
```ts
|
|
48
49
|
import { splitReply } from "@cheerlyai/agentlib-protocol";
|
|
@@ -52,9 +53,10 @@ const { body, sources } = splitReply(text);
|
|
|
52
53
|
|
|
53
54
|
`sources` is null when there is none — and also while a heading has arrived
|
|
54
55
|
but its list has not, so a "Sources" label never flashes above an empty box
|
|
55
|
-
mid-stream. Recognises `Sources:`, `**Sources**`, `## Sources`
|
|
56
|
+
mid-stream. Recognises `Sources:`, `**Sources**`, `## Sources`, `Source:`,
|
|
57
|
+
`Références :` and friends, on its own line or with the citation next to it,
|
|
56
58
|
because a model asked for a section in prose writes it differently every few
|
|
57
|
-
runs.
|
|
59
|
+
runs — and translates the heading when it answers in another language.
|
|
58
60
|
|
|
59
61
|
## Parts
|
|
60
62
|
|
package/dist/index.cjs
CHANGED
|
@@ -65,7 +65,7 @@ function parseChartSpec(raw) {
|
|
|
65
65
|
series
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
var SOURCES_HEADING = /(?:^|\n)\s{0,3}(?:#{1,6}\s*)?(?:\*\*)?Sources
|
|
68
|
+
var SOURCES_HEADING = /(?:^|\n)\s{0,3}(?:#{1,6}\s*)?(?:\*\*)?(?:Sources?|R[ée]f[ée]rences?)(?:\s*:(?:\*\*)?[ \t]*|(?:\*\*)?\s*:?[ \t]*(?=\n|$))/gi;
|
|
69
69
|
function splitReply(text) {
|
|
70
70
|
const re = new RegExp(SOURCES_HEADING.source, SOURCES_HEADING.flags);
|
|
71
71
|
let last = null;
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function parseChartSpec(raw) {
|
|
|
35
35
|
series
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
var SOURCES_HEADING = /(?:^|\n)\s{0,3}(?:#{1,6}\s*)?(?:\*\*)?Sources
|
|
38
|
+
var SOURCES_HEADING = /(?:^|\n)\s{0,3}(?:#{1,6}\s*)?(?:\*\*)?(?:Sources?|R[ée]f[ée]rences?)(?:\s*:(?:\*\*)?[ \t]*|(?:\*\*)?\s*:?[ \t]*(?=\n|$))/gi;
|
|
39
39
|
function splitReply(text) {
|
|
40
40
|
const re = new RegExp(SOURCES_HEADING.source, SOURCES_HEADING.flags);
|
|
41
41
|
let last = null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cheerlyai/agentlib-protocol",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Parsers for the conventions agentlib layers on the Vercel AI SDK stream
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Parsers for the conventions agentlib layers on the Vercel AI SDK stream \u2014 chart blocks and source sections. Framework-agnostic, zero dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsup",
|
|
26
|
+
"test": "npm run build && node --test test/",
|
|
26
27
|
"lint": "tsc --noEmit"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|