@guuey/threads 0.28.0 → 0.29.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/fold-rows.d.ts +26 -0
- package/dist/fold-rows.d.ts.map +1 -1
- package/dist/fold-rows.js +49 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/rows.d.ts +14 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/store.d.ts +7 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +3 -0
- package/dist/testing/contract-suite.d.ts.map +1 -1
- package/dist/testing/contract-suite.js +22 -0
- package/package.json +3 -3
package/dist/fold-rows.d.ts
CHANGED
|
@@ -76,6 +76,32 @@ export declare function cardRowToAgArtifact(row: ThreadMessageRow): AgArtifact |
|
|
|
76
76
|
* artifactIds there.
|
|
77
77
|
*/
|
|
78
78
|
export declare function reassembleFold(rows: ThreadMessageRow[], snapshot: ThreadSnapshotRow | undefined): AgReduceResult;
|
|
79
|
+
/**
|
|
80
|
+
* Split a snapshot's STORED thread-memory array (what a binding reads back)
|
|
81
|
+
* into the view this runtime reads and the elements it carries (AgJSON
|
|
82
|
+
* draft.4 §0.2's stored-record reader). Stored data is a wire across a rolling
|
|
83
|
+
* release, so it is never taken as `AgMemoryRecord[]`:
|
|
84
|
+
* - `threadMemory`: the records the reader materializes with scope `thread`;
|
|
85
|
+
* the view a fold is seeded with and a prompt recalls;
|
|
86
|
+
* - `carriedThreadMemory`: every other stored element, verbatim and in stored
|
|
87
|
+
* order: a record the reader cannot materialize (an undefined `scope`, a
|
|
88
|
+
* missing `value`) and a readable record of another scope.
|
|
89
|
+
* The reader either materializes an element or reports it at `[i]`. If a core
|
|
90
|
+
* version ever did both for one element (a partial report), pairing the view
|
|
91
|
+
* back to the stored elements would desync, so then EVERY element is carried
|
|
92
|
+
* and nothing is seeded: safe at rest, and visible as a full carry.
|
|
93
|
+
*/
|
|
94
|
+
export declare function splitStoredThreadMemory(stored: readonly JsonValue[]): Pick<ThreadSnapshotRow, "threadMemory"> & {
|
|
95
|
+
carriedThreadMemory: JsonValue[];
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The one stored thread-memory array a binding writes: the carried elements
|
|
99
|
+
* FIRST, then this runtime's thread records. Stored order is precedence for a
|
|
100
|
+
* reader that seeds every record (the reducer keys memory by scope and key, and
|
|
101
|
+
* the last write wins), and the carried elements were written before this
|
|
102
|
+
* turn, so write order stays time order.
|
|
103
|
+
*/
|
|
104
|
+
export declare function joinStoredThreadMemory(row: Pick<ThreadSnapshotRow, "threadMemory" | "carriedThreadMemory">): JsonValue[];
|
|
79
105
|
/**
|
|
80
106
|
* Synthetic events that seed a reducer with prior latest-replace state before
|
|
81
107
|
* folding a turn (design §8.1). Seeds state + thread-memory ONLY — never
|
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,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AASD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAMlD;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,SA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AAgB,cAAc,CAC5B,IAAI,EAAE,gBAAgB,EAAE,EACxB,QAAQ,EAAE,iBAAiB,GAAG,SAAS,GACtC,cAAc,CA2BhB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC,GAAG;IAC/G,mBAAmB,EAAE,SAAS,EAAE,CAAC;CAClC,CAoBA;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,EAAE,cAAc,GAAG,qBAAqB,CAAC,GAAG,SAAS,EAAE,CAExH;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 { readStoredAgMessage } from "@silverprotocol/core";
|
|
1
|
+
import { readStoredAgMemoryRecords, 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) {
|
|
@@ -282,6 +282,54 @@ export function reassembleFold(rows, snapshot) {
|
|
|
282
282
|
...(snapshot?.workingState !== undefined ? { state: snapshot.workingState } : {}),
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Split a snapshot's STORED thread-memory array (what a binding reads back)
|
|
287
|
+
* into the view this runtime reads and the elements it carries (AgJSON
|
|
288
|
+
* draft.4 §0.2's stored-record reader). Stored data is a wire across a rolling
|
|
289
|
+
* release, so it is never taken as `AgMemoryRecord[]`:
|
|
290
|
+
* - `threadMemory`: the records the reader materializes with scope `thread`;
|
|
291
|
+
* the view a fold is seeded with and a prompt recalls;
|
|
292
|
+
* - `carriedThreadMemory`: every other stored element, verbatim and in stored
|
|
293
|
+
* order: a record the reader cannot materialize (an undefined `scope`, a
|
|
294
|
+
* missing `value`) and a readable record of another scope.
|
|
295
|
+
* The reader either materializes an element or reports it at `[i]`. If a core
|
|
296
|
+
* version ever did both for one element (a partial report), pairing the view
|
|
297
|
+
* back to the stored elements would desync, so then EVERY element is carried
|
|
298
|
+
* and nothing is seeded: safe at rest, and visible as a full carry.
|
|
299
|
+
*/
|
|
300
|
+
export function splitStoredThreadMemory(stored) {
|
|
301
|
+
const read = readStoredAgMemoryRecords(stored);
|
|
302
|
+
const omitted = new Set(read.reports.flatMap((r) => (r.path.length === 1 && typeof r.path[0] === "number" ? [r.path[0]] : [])));
|
|
303
|
+
if (omitted.size !== read.reports.length || read.value.length + omitted.size !== stored.length) {
|
|
304
|
+
return { threadMemory: [], carriedThreadMemory: [...stored] };
|
|
305
|
+
}
|
|
306
|
+
const threadMemory = [];
|
|
307
|
+
const carriedThreadMemory = [];
|
|
308
|
+
// Readable elements come back in stored order, so the k-th one not omitted is `read.value[k]`.
|
|
309
|
+
let k = 0;
|
|
310
|
+
stored.forEach((element, i) => {
|
|
311
|
+
if (omitted.has(i)) {
|
|
312
|
+
carriedThreadMemory.push(element);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const rec = read.value[k++];
|
|
316
|
+
if (rec !== undefined && rec.scope === "thread")
|
|
317
|
+
threadMemory.push(rec);
|
|
318
|
+
else
|
|
319
|
+
carriedThreadMemory.push(element);
|
|
320
|
+
});
|
|
321
|
+
return { threadMemory, carriedThreadMemory };
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* The one stored thread-memory array a binding writes: the carried elements
|
|
325
|
+
* FIRST, then this runtime's thread records. Stored order is precedence for a
|
|
326
|
+
* reader that seeds every record (the reducer keys memory by scope and key, and
|
|
327
|
+
* the last write wins), and the carried elements were written before this
|
|
328
|
+
* turn, so write order stays time order.
|
|
329
|
+
*/
|
|
330
|
+
export function joinStoredThreadMemory(row) {
|
|
331
|
+
return [...(row.carriedThreadMemory ?? []), ...row.threadMemory];
|
|
332
|
+
}
|
|
285
333
|
/**
|
|
286
334
|
* Synthetic events that seed a reducer with prior latest-replace state before
|
|
287
335
|
* folding a turn (design §8.1). Seeds state + thread-memory ONLY — never
|
package/dist/index.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ export type { HandoffEvent, ReportEvent, StoredHistoryMessage, ThreadMessageEven
|
|
|
21
21
|
export { ThreadStore, type AppendFoldInput, type AppendFoldResult, type AppendMessageInput, type AppendMessageResult, type EnsureThreadInput, } from "./store.js";
|
|
22
22
|
export { InMemoryThreadPersistence } from "./in-memory.js";
|
|
23
23
|
export { HttpThreadPersistence, HttpThreadStoreError, type HttpThreadPersistenceOptions, type ThreadScope, } from "./http.js";
|
|
24
|
-
export { agArtifactToCardRow, agMessageToRow, cardRowToAgArtifact, messageText, producingToolName, reassembleFold, rowToAgMessage, seedEventsForReducer, toolNamesByCallId, uiCardArtifactsFromMessages, type RowCtx, } from "./fold-rows.js";
|
|
24
|
+
export { agArtifactToCardRow, agMessageToRow, cardRowToAgArtifact, messageText, producingToolName, joinStoredThreadMemory, reassembleFold, rowToAgMessage, seedEventsForReducer, splitStoredThreadMemory, toolNamesByCallId, uiCardArtifactsFromMessages, type RowCtx, } from "./fold-rows.js";
|
|
25
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,YAAY,EACV,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,SAAS,EACT,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,4BAA4B,EACjC,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,KAAK,MAAM,GACZ,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,YAAY,EACV,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,SAAS,EACT,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,4BAA4B,EACjC,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,2BAA2B,EAC3B,KAAK,MAAM,GACZ,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { ThreadStore, } from "./store.js";
|
|
2
2
|
export { InMemoryThreadPersistence } from "./in-memory.js";
|
|
3
3
|
export { HttpThreadPersistence, HttpThreadStoreError, } from "./http.js";
|
|
4
|
-
export { agArtifactToCardRow, agMessageToRow, cardRowToAgArtifact, messageText, producingToolName, reassembleFold, rowToAgMessage, seedEventsForReducer, toolNamesByCallId, uiCardArtifactsFromMessages, } from "./fold-rows.js";
|
|
4
|
+
export { agArtifactToCardRow, agMessageToRow, cardRowToAgArtifact, messageText, producingToolName, joinStoredThreadMemory, reassembleFold, rowToAgMessage, seedEventsForReducer, splitStoredThreadMemory, toolNamesByCallId, uiCardArtifactsFromMessages, } from "./fold-rows.js";
|
package/dist/rows.d.ts
CHANGED
|
@@ -123,8 +123,21 @@ export interface ThreadSnapshotRow {
|
|
|
123
123
|
userId: string;
|
|
124
124
|
/** AgReduceResult.state — opaque working blob. */
|
|
125
125
|
workingState?: JsonValue;
|
|
126
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* The thread's memory records this runtime reads: `AgReduceResult.memory`
|
|
128
|
+
* filtered to scope='thread'. A binding returns the readable view here, and
|
|
129
|
+
* stored elements it could not read travel in {@link carriedThreadMemory}.
|
|
130
|
+
*/
|
|
127
131
|
threadMemory: AgMemoryRecord[];
|
|
132
|
+
/**
|
|
133
|
+
* Stored thread-memory elements this runtime does not read or own: a record
|
|
134
|
+
* written in a newer vocabulary (an unknown scope, a missing value) or of
|
|
135
|
+
* another scope, verbatim and in stored order. A binding splits them off on
|
|
136
|
+
* read (`splitStoredThreadMemory`) and joins them back into the one stored
|
|
137
|
+
* array on write (`joinStoredThreadMemory`), so they are never dropped at
|
|
138
|
+
* rest by a runtime that cannot read them. Absent = none.
|
|
139
|
+
*/
|
|
140
|
+
carriedThreadMemory?: JsonValue[];
|
|
128
141
|
lastTurnId?: string;
|
|
129
142
|
updatedAt: string;
|
|
130
143
|
}
|
package/dist/rows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtE,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAC5D,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1D,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW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;;;;;OAMG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvF,2EAA2E;IAC3E,UAAU,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,+EAA+E;IAC/E,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACjF,6EAA6E;IAC7E,qBAAqB,CACnB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;IACzC,iEAAiE;IACjE,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;IACtE,uDAAuD;IACvD,WAAW,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD"}
|
package/dist/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgReduceResult } from "@silverprotocol/core";
|
|
1
|
+
import type { AgReduceResult, JsonValue } from "@silverprotocol/core";
|
|
2
2
|
import type { ThreadMessageEvent, StoredHistoryMessage, ThreadMessageKind, ThreadMessageRole, ThreadPersistencePort, ThreadSnapshotRow } from "./rows.js";
|
|
3
3
|
export interface EnsureThreadInput {
|
|
4
4
|
/** Client-supplied thread id (localStorage). Absent on first contact. */
|
|
@@ -58,6 +58,12 @@ export interface AppendFoldInput {
|
|
|
58
58
|
* {absent, true} vocabulary as {@link AppendMessageInput.untrustedOrigin}.
|
|
59
59
|
*/
|
|
60
60
|
untrustedOrigin?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The prior snapshot's `carriedThreadMemory`: stored thread-memory elements
|
|
63
|
+
* this runtime did not read or own. Written back unchanged beside the fold's
|
|
64
|
+
* own thread records, so they are never dropped at rest. Absent = none.
|
|
65
|
+
*/
|
|
66
|
+
carriedThreadMemory?: readonly JsonValue[];
|
|
61
67
|
}
|
|
62
68
|
export interface AppendFoldResult {
|
|
63
69
|
messageSeqs: number[];
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAQtE,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EAEjB,qBAAqB,EAErB,iBAAiB,EAClB,MAAM,WAAW,CAAC;AAOnB,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,yEAAyE;IACzE,OAAO,EAAE,OAAO,CAAC;IACjB,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAA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SAAS,CAAC;IAI3E;;;;;;;;;;;;;;;;;OAiBG;IACG,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAoGpE"}
|
package/dist/store.js
CHANGED
|
@@ -218,6 +218,9 @@ export class ThreadStore {
|
|
|
218
218
|
threadId,
|
|
219
219
|
userId,
|
|
220
220
|
threadMemory,
|
|
221
|
+
...(input.carriedThreadMemory !== undefined && input.carriedThreadMemory.length > 0
|
|
222
|
+
? { carriedThreadMemory: [...input.carriedThreadMemory] }
|
|
223
|
+
: {}),
|
|
221
224
|
updatedAt: new Date().toISOString(),
|
|
222
225
|
...(fold.state !== undefined ? { workingState: fold.state } : {}),
|
|
223
226
|
...(lastTurnId ? { lastTurnId } : {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-suite.d.ts","sourceRoot":"","sources":["../../src/testing/contract-suite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contract-suite.d.ts","sourceRoot":"","sources":["../../src/testing/contract-suite.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAa,MAAM,YAAY,CAAC;AAEnE,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAiCD;;;GAGG;AACH,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,OAAO,CAAC,wBAAwB,CAAC,GAC5C,IAAI,CA0KN"}
|
|
@@ -174,5 +174,27 @@ export function runThreadPersistenceContractSuite(name, make) {
|
|
|
174
174
|
expect(snap?.workingState).toBeUndefined();
|
|
175
175
|
});
|
|
176
176
|
});
|
|
177
|
+
it("carried thread memory round-trips unchanged beside the readable records", async () => {
|
|
178
|
+
await withHarness(make, async (port) => {
|
|
179
|
+
await port.createThread(threadRow("t1"));
|
|
180
|
+
// Elements this runtime cannot read or does not own: an unknown scope,
|
|
181
|
+
// a record with no value, a readable record of another scope.
|
|
182
|
+
const carried = [
|
|
183
|
+
{ scope: "team", key: "plan", value: { tier: "pro" } },
|
|
184
|
+
{ scope: "thread", key: "orphan" },
|
|
185
|
+
{ scope: "user", key: "name", value: "Ada" },
|
|
186
|
+
];
|
|
187
|
+
await port.putSnapshot({
|
|
188
|
+
threadId: "t1",
|
|
189
|
+
userId: "g_contract",
|
|
190
|
+
threadMemory: [{ scope: "thread", key: "k", value: "v1" }],
|
|
191
|
+
carriedThreadMemory: carried,
|
|
192
|
+
updatedAt: "2026-08-07T00:00:03.000Z",
|
|
193
|
+
});
|
|
194
|
+
const snap = await port.getSnapshot("t1");
|
|
195
|
+
expect(snap?.threadMemory).toEqual([{ scope: "thread", key: "k", value: "v1" }]);
|
|
196
|
+
expect(JSON.stringify(snap?.carriedThreadMemory)).toBe(JSON.stringify(carried));
|
|
197
|
+
});
|
|
198
|
+
});
|
|
177
199
|
});
|
|
178
200
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guuey/threads",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
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.9.0",
|
|
26
|
+
"@guuey/mcp-apps-host": "0.29.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^24.0.0",
|