@guuey/threads 0.27.0 → 0.28.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/dist/fold-rows.d.ts +7 -0
- package/dist/fold-rows.d.ts.map +1 -1
- package/dist/fold-rows.js +26 -5
- package/package.json +3 -3
package/dist/fold-rows.d.ts
CHANGED
|
@@ -53,6 +53,13 @@ export declare function agArtifactToCardRow(art: AgArtifact, ctx: RowCtx, toolNa
|
|
|
53
53
|
* AgMessage in `content`; user/system rows (persisted up-front) store plain
|
|
54
54
|
* `{ kind, text }` — synthesize a single-text-block AgMessage for those so
|
|
55
55
|
* the reassembled transcript is uniform.
|
|
56
|
+
*
|
|
57
|
+
* The stored AgMessage is read with the core's lenient stored-record reader
|
|
58
|
+
* (AgJSON draft.4 §0.2): a content element of an undefined type, or with an
|
|
59
|
+
* undefined value in a closed set, is omitted whole and the rest restores in
|
|
60
|
+
* order; unknown fields pass through untouched. Only a record the reader
|
|
61
|
+
* cannot materialize (no string `id`, an undefined `role`, no `content`
|
|
62
|
+
* array) falls to the text projection.
|
|
56
63
|
*/
|
|
57
64
|
export declare function rowToAgMessage(row: ThreadMessageRow): AgMessage;
|
|
58
65
|
/** Extract the AgArtifact from a kind='card' row, or undefined if malformed. */
|
package/dist/fold-rows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fold-rows.d.ts","sourceRoot":"","sources":["../src/fold-rows.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,YAAY,EAEZ,cAAc,EACd,OAAO,EACP,cAAc,EACd,SAAS,EACV,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,gBAAgB,EAAwC,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG3G,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf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AAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAU5E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,MAAM,GAAG,SAAS,CAQpB;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,gBAAgB,CA0BrG;AAOD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,gBAAgB,GAAG,SAAS,CAY/D;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU,GAAG,SAAS,CAMjF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,gBAAgB,EAAE,EACxB,QAAQ,EAAE,iBAAiB,GAAG,SAAS,GACtC,cAAc,CA2BhB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,SAAS,GAAG,SAAS,EACjC,iBAAiB,EAAE,cAAc,EAAE,GAClC,OAAO,EAAE,CAmBX"}
|
package/dist/fold-rows.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readStoredAgMessage } from "@silverprotocol/core";
|
|
2
2
|
import { asUiResource, scanProviderRawForUiResource, toolResultLocator } from "@guuey/mcp-apps-host/narrowing";
|
|
3
3
|
/** AgRole → the row's coarse authorRole projection (secondary; role of record lives in content). */
|
|
4
4
|
function roleToAuthor(role) {
|
|
@@ -46,10 +46,24 @@ export function agMessageToRow(msg, ctx) {
|
|
|
46
46
|
// reducer seed, so stripping could orphan a paused turn's resume after a
|
|
47
47
|
// reload, and the token authorizes the thread owner's OWN resume (not a
|
|
48
48
|
// cross-trust credential like a render wsToken). Revisit on guuey#122.
|
|
49
|
-
|
|
49
|
+
// The one field it drops is `displayRequired` (turnRecordForStorage).
|
|
50
|
+
...(ctx.turnRecord ? { aiContext: turnRecordForStorage(ctx.turnRecord) } : {}),
|
|
50
51
|
...(ctx.untrustedOrigin === true ? { untrustedOrigin: true } : {}),
|
|
51
52
|
};
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* A turn's `displayRequired` is content a model provider requires the host to
|
|
56
|
+
* show to the person who asked, under that provider's terms, and those terms
|
|
57
|
+
* allow keeping it only as long as the law requires. It belongs to the LIVE
|
|
58
|
+
* turn, so it never persists: the stored turn record is the live one without
|
|
59
|
+
* it, and everything else stays verbatim. Identity when the turn carried none.
|
|
60
|
+
*/
|
|
61
|
+
function turnRecordForStorage(rec) {
|
|
62
|
+
if (rec.displayRequired === undefined)
|
|
63
|
+
return rec;
|
|
64
|
+
const { displayRequired: _dropped, ...rest } = rec;
|
|
65
|
+
return rest;
|
|
66
|
+
}
|
|
53
67
|
/** Strip every tool-result block's `_meta` (guuey#122); identity when none carried one. */
|
|
54
68
|
function messageWithoutToolResultMeta(msg) {
|
|
55
69
|
let changed = false;
|
|
@@ -200,11 +214,18 @@ function isJsonObjectLike(v) {
|
|
|
200
214
|
* AgMessage in `content`; user/system rows (persisted up-front) store plain
|
|
201
215
|
* `{ kind, text }` — synthesize a single-text-block AgMessage for those so
|
|
202
216
|
* the reassembled transcript is uniform.
|
|
217
|
+
*
|
|
218
|
+
* The stored AgMessage is read with the core's lenient stored-record reader
|
|
219
|
+
* (AgJSON draft.4 §0.2): a content element of an undefined type, or with an
|
|
220
|
+
* undefined value in a closed set, is omitted whole and the rest restores in
|
|
221
|
+
* order; unknown fields pass through untouched. Only a record the reader
|
|
222
|
+
* cannot materialize (no string `id`, an undefined `role`, no `content`
|
|
223
|
+
* array) falls to the text projection.
|
|
203
224
|
*/
|
|
204
225
|
export function rowToAgMessage(row) {
|
|
205
|
-
const
|
|
206
|
-
if (
|
|
207
|
-
return
|
|
226
|
+
const stored = readStoredAgMessage(row.content);
|
|
227
|
+
if (stored.value !== undefined)
|
|
228
|
+
return stored.value;
|
|
208
229
|
const role = row.authorRole === "user" ? "user" : row.authorRole === "system" ? "system" : "assistant";
|
|
209
230
|
const text = row.text ?? "";
|
|
210
231
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guuey/threads",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"description": "Universal session/thread persistence for AgJSON agents — the ThreadStore contract (append-fold, history, snapshots), the fold↔row mapping, and an in-memory binding. Guuey's hosted runtime is one binding; implement the port against your own store and run the exported contract suite for the same guarantees.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@silverprotocol/core": "0.
|
|
26
|
-
"@guuey/mcp-apps-host": "0.
|
|
25
|
+
"@silverprotocol/core": "0.7.2",
|
|
26
|
+
"@guuey/mcp-apps-host": "0.28.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^24.0.0",
|