@loomwork/conversation 0.0.0-stage → 0.1.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.
Files changed (83) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +117 -2
  4. package/dist/access.d.ts +59 -0
  5. package/dist/access.d.ts.map +1 -0
  6. package/dist/access.js +178 -0
  7. package/dist/access.js.map +1 -0
  8. package/dist/bargeIn.d.ts +62 -0
  9. package/dist/bargeIn.d.ts.map +1 -0
  10. package/dist/bargeIn.js +110 -0
  11. package/dist/bargeIn.js.map +1 -0
  12. package/dist/budget.d.ts +82 -0
  13. package/dist/budget.d.ts.map +1 -0
  14. package/dist/budget.js +134 -0
  15. package/dist/budget.js.map +1 -0
  16. package/dist/conversation.d.ts +59 -0
  17. package/dist/conversation.d.ts.map +1 -0
  18. package/dist/conversation.js +786 -0
  19. package/dist/conversation.js.map +1 -0
  20. package/dist/conversations.d.ts +149 -0
  21. package/dist/conversations.d.ts.map +1 -0
  22. package/dist/conversations.js +498 -0
  23. package/dist/conversations.js.map +1 -0
  24. package/dist/feed.d.ts +32 -0
  25. package/dist/feed.d.ts.map +1 -0
  26. package/dist/feed.js +83 -0
  27. package/dist/feed.js.map +1 -0
  28. package/dist/hub.d.ts +119 -0
  29. package/dist/hub.d.ts.map +1 -0
  30. package/dist/hub.js +257 -0
  31. package/dist/hub.js.map +1 -0
  32. package/dist/ids.d.ts +9 -0
  33. package/dist/ids.d.ts.map +1 -0
  34. package/dist/ids.js +29 -0
  35. package/dist/ids.js.map +1 -0
  36. package/dist/index.d.ts +27 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +65 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/providerError.d.ts +10 -0
  41. package/dist/providerError.d.ts.map +1 -0
  42. package/dist/providerError.js +16 -0
  43. package/dist/providerError.js.map +1 -0
  44. package/dist/reader.d.ts +53 -0
  45. package/dist/reader.d.ts.map +1 -0
  46. package/dist/reader.js +217 -0
  47. package/dist/reader.js.map +1 -0
  48. package/dist/settled.d.ts +49 -0
  49. package/dist/settled.d.ts.map +1 -0
  50. package/dist/settled.js +51 -0
  51. package/dist/settled.js.map +1 -0
  52. package/dist/signEnvelope.d.ts +51 -0
  53. package/dist/signEnvelope.d.ts.map +1 -0
  54. package/dist/signEnvelope.js +55 -0
  55. package/dist/signEnvelope.js.map +1 -0
  56. package/dist/summarizerText.d.ts +2 -0
  57. package/dist/summarizerText.d.ts.map +1 -0
  58. package/dist/summarizerText.js +9 -0
  59. package/dist/summarizerText.js.map +1 -0
  60. package/dist/turn.d.ts +67 -0
  61. package/dist/turn.d.ts.map +1 -0
  62. package/dist/turn.js +213 -0
  63. package/dist/turn.js.map +1 -0
  64. package/dist/types.d.ts +267 -0
  65. package/dist/types.d.ts.map +1 -0
  66. package/dist/types.js +18 -0
  67. package/dist/types.js.map +1 -0
  68. package/package.json +61 -3
  69. package/src/access.ts +221 -0
  70. package/src/bargeIn.ts +172 -0
  71. package/src/budget.ts +170 -0
  72. package/src/conversation.ts +961 -0
  73. package/src/conversations.ts +690 -0
  74. package/src/feed.ts +112 -0
  75. package/src/hub.ts +336 -0
  76. package/src/ids.ts +25 -0
  77. package/src/index.ts +75 -0
  78. package/src/reader.ts +274 -0
  79. package/src/settled.ts +80 -0
  80. package/src/signEnvelope.ts +76 -0
  81. package/src/summarizerText.ts +3 -0
  82. package/src/turn.ts +344 -0
  83. package/src/types.ts +271 -0
@@ -0,0 +1,53 @@
1
+ import type { EventEnvelope } from "@loomwork/core";
2
+ import { type EventStore } from "@loomwork/event-runtime";
3
+ import { type HistoryEntry, type MessageRecord } from "./types";
4
+ /** `<generation>.<sequence>`: a position in the chain's log. */
5
+ export interface Position {
6
+ g: number;
7
+ seq: number;
8
+ }
9
+ export declare function formatCursor(p: Position): string;
10
+ export declare function parseCursor(cursor: string | undefined): Position | undefined;
11
+ /** A malformed cursor is a caller error, not "start over". */
12
+ export declare class InvalidCursorError extends Error {
13
+ readonly code = "INVALID_CURSOR";
14
+ constructor();
15
+ }
16
+ export interface ReadOptions {
17
+ /** Messages to return at most. Default 50, capped at 500. */
18
+ limit?: number;
19
+ /**
20
+ * Events to SCAN at most (the cost bound). Default 2 000. A page may return fewer than `limit`
21
+ * messages with `done: false`: call again with `nextCursor`.
22
+ */
23
+ maxScan?: number;
24
+ /** Where to continue: forward = after this position, backward = before it. */
25
+ cursor?: string;
26
+ /** `"forward"` (oldest first, default) or `"backward"` (newest first). */
27
+ direction?: "forward" | "backward";
28
+ /** Stop reading (the caller went away): the call returns what it has with `done: false`. */
29
+ signal?: AbortSignal;
30
+ }
31
+ export interface ReadResult {
32
+ entries: HistoryEntry[];
33
+ /** Pass back as `cursor` to continue in the same direction. Absent when nothing was scanned. */
34
+ nextCursor?: string;
35
+ /** True when the scan reached the end of the log in its direction (forward: the live tip; backward: the start). */
36
+ done: boolean;
37
+ /** True when the conversation has a `conversation.closed` event (forward scans only). */
38
+ closed?: boolean;
39
+ }
40
+ /** The message record a `conversation.message` decision event carries, or `undefined` if it is not one. */
41
+ export declare function recordOf(ev: EventEnvelope): MessageRecord | undefined;
42
+ /**
43
+ * The newest generation of a chain, by galloping then bisecting over `exists` (generations are
44
+ * consecutive from 0): O(log G) point reads, not a walk. `hint` is a generation known to exist.
45
+ */
46
+ export declare function findHeadGeneration(store: EventStore, conversationId: string, hint?: number): Promise<number | undefined>;
47
+ export interface ConversationReader {
48
+ read(conversationId: string, options?: ReadOptions): Promise<ReadResult>;
49
+ /** The newest generation that has events, or `undefined` when the conversation has none. */
50
+ headGeneration(conversationId: string, hint?: number): Promise<number | undefined>;
51
+ }
52
+ export declare function createConversationReader(store: EventStore): ConversationReader;
53
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gB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,CAAC,CAmB7B;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACzE,4FAA4F;IAC5F,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACpF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB,CAyG9E"}
package/dist/reader.js ADDED
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvalidCursorError = void 0;
4
+ exports.formatCursor = formatCursor;
5
+ exports.parseCursor = parseCursor;
6
+ exports.recordOf = recordOf;
7
+ exports.findHeadGeneration = findHeadGeneration;
8
+ exports.createConversationReader = createConversationReader;
9
+ const event_runtime_1 = require("@loomwork/event-runtime");
10
+ const access_1 = require("./access");
11
+ const ids_1 = require("./ids");
12
+ const types_1 = require("./types");
13
+ const CURSOR = /^(\d{1,9})\.(\d{1,15})$/;
14
+ function formatCursor(p) {
15
+ return `${p.g}.${p.seq}`;
16
+ }
17
+ function parseCursor(cursor) {
18
+ if (cursor === undefined)
19
+ return undefined;
20
+ const m = CURSOR.exec(cursor);
21
+ if (m === null)
22
+ return undefined;
23
+ return { g: Number(m[1]), seq: Number(m[2]) };
24
+ }
25
+ /** A malformed cursor is a caller error, not "start over". */
26
+ class InvalidCursorError extends Error {
27
+ code = "INVALID_CURSOR";
28
+ constructor() {
29
+ super("invalid cursor");
30
+ this.name = "InvalidCursorError";
31
+ }
32
+ }
33
+ exports.InvalidCursorError = InvalidCursorError;
34
+ const DEFAULT_LIMIT = 50;
35
+ const MAX_LIMIT = 500;
36
+ const DEFAULT_MAX_SCAN = 2000;
37
+ const BLOCK = 256;
38
+ /** The conversation fact a `DECISION_RECORDED` carries, if it is one of ours. */
39
+ function factOf(ev) {
40
+ if (ev.eventType !== "DECISION_RECORDED")
41
+ return undefined;
42
+ const d = ev.payload;
43
+ return d !== null && typeof d === "object" && d.source === types_1.RECORD_SOURCE ? d.choice : undefined;
44
+ }
45
+ const isOrd = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 1;
46
+ /** The message record a `conversation.message` decision event carries, or `undefined` if it is not one. */
47
+ function recordOf(ev) {
48
+ const p = factOf(ev);
49
+ if (p === undefined)
50
+ return undefined;
51
+ if (typeof p !== "object" ||
52
+ p === null ||
53
+ typeof p.turn !== "number" ||
54
+ (p.role !== "user" && p.role !== "assistant") ||
55
+ typeof p.text !== "string" ||
56
+ typeof p.status !== "string") {
57
+ return undefined;
58
+ }
59
+ return {
60
+ turn: p.turn,
61
+ ...(isOrd(p.ord) && { ord: p.ord }),
62
+ ...(isOrd(p.editOf) && { editOf: p.editOf }),
63
+ ...(isOrd(p.editOfTurn) && { editOfTurn: p.editOfTurn }),
64
+ role: p.role,
65
+ text: p.text,
66
+ status: p.status,
67
+ ...(typeof p.reason === "string" && { reason: p.reason }),
68
+ ...(typeof p.errorId === "string" && { errorId: p.errorId }),
69
+ ...((0, access_1.parseIdentity)(p.asker) !== undefined && { asker: (0, access_1.parseIdentity)(p.asker) }),
70
+ ...(Array.isArray(p.classes) &&
71
+ p.classes.length > 0 && {
72
+ classes: p.classes.filter((x) => typeof x === "string"),
73
+ }),
74
+ ...(typeof p.turnExecutionId === "string" && { turnExecutionId: p.turnExecutionId }),
75
+ };
76
+ }
77
+ function entryOf(g, ev, rec) {
78
+ return {
79
+ ...rec,
80
+ cursor: formatCursor({ g, seq: ev.sequence }),
81
+ executionId: ev.executionId,
82
+ at: ev.timestamp,
83
+ };
84
+ }
85
+ /** Whether an execution (generation) has any events. One indexed point read. */
86
+ async function exists(store, id) {
87
+ return (await (0, event_runtime_1.headOf)(store, id)) !== null;
88
+ }
89
+ /**
90
+ * The newest generation of a chain, by galloping then bisecting over `exists` (generations are
91
+ * consecutive from 0): O(log G) point reads, not a walk. `hint` is a generation known to exist.
92
+ */
93
+ async function findHeadGeneration(store, conversationId, hint = 0) {
94
+ if (!(await exists(store, (0, ids_1.generationId)(conversationId, hint)))) {
95
+ if (hint === 0)
96
+ return undefined;
97
+ return findHeadGeneration(store, conversationId, 0);
98
+ }
99
+ let lo = hint; // exists
100
+ let step = 1;
101
+ let hi = lo + step; // find a missing one
102
+ while (await exists(store, (0, ids_1.generationId)(conversationId, hi))) {
103
+ lo = hi;
104
+ step *= 2;
105
+ hi = lo + step;
106
+ }
107
+ while (hi - lo > 1) {
108
+ const mid = lo + Math.floor((hi - lo) / 2);
109
+ if (await exists(store, (0, ids_1.generationId)(conversationId, mid)))
110
+ lo = mid;
111
+ else
112
+ hi = mid;
113
+ }
114
+ return lo;
115
+ }
116
+ function createConversationReader(store) {
117
+ async function forward(conversationId, opts) {
118
+ const limit = Math.min(Math.max(1, opts.limit ?? DEFAULT_LIMIT), MAX_LIMIT);
119
+ const maxScan = Math.max(1, opts.maxScan ?? DEFAULT_MAX_SCAN);
120
+ const after = parseCursor(opts.cursor);
121
+ if (opts.cursor !== undefined && after === undefined)
122
+ throw new InvalidCursorError();
123
+ let g = after?.g ?? 0;
124
+ let next = after !== undefined ? after.seq + 1 : 0;
125
+ let last = after;
126
+ let scanned = 0;
127
+ let closed = false;
128
+ const entries = [];
129
+ for (;;) {
130
+ if (entries.length >= limit || scanned >= maxScan || opts.signal?.aborted === true) {
131
+ return { entries, ...(last && { nextCursor: formatCursor(last) }), done: false, closed };
132
+ }
133
+ const evs = await (0, event_runtime_1.readRangeOf)(store, (0, ids_1.generationId)(conversationId, g), next, next + Math.min(BLOCK, maxScan - scanned) - 1);
134
+ if (evs.length === 0) {
135
+ // This generation has nothing more: a successor means keep going, none means we are at the tip.
136
+ if (await exists(store, (0, ids_1.generationId)(conversationId, g + 1))) {
137
+ g++;
138
+ next = 0;
139
+ scanned++; // a generation hop is work: it counts against the scan budget
140
+ continue;
141
+ }
142
+ return { entries, ...(last && { nextCursor: formatCursor(last) }), done: true, closed };
143
+ }
144
+ for (const ev of evs) {
145
+ scanned++;
146
+ last = { g, seq: ev.sequence };
147
+ if (factOf(ev)?.kind === "closed")
148
+ closed = true;
149
+ const rec = recordOf(ev);
150
+ if (rec !== undefined)
151
+ entries.push(entryOf(g, ev, rec));
152
+ if (entries.length >= limit)
153
+ break;
154
+ }
155
+ next = last.seq + 1;
156
+ }
157
+ }
158
+ async function backward(conversationId, opts) {
159
+ const limit = Math.min(Math.max(1, opts.limit ?? DEFAULT_LIMIT), MAX_LIMIT);
160
+ const maxScan = Math.max(1, opts.maxScan ?? DEFAULT_MAX_SCAN);
161
+ const before = parseCursor(opts.cursor);
162
+ if (opts.cursor !== undefined && before === undefined)
163
+ throw new InvalidCursorError();
164
+ // The cursor is UNTRUSTED input: it is clamped to what exists. A generation past the head, or a
165
+ // sequence past a generation's tip, means "from the end", never a walk through nothing.
166
+ const head = await findHeadGeneration(store, conversationId);
167
+ if (head === undefined)
168
+ return { entries: [], done: true };
169
+ const tipOf = async (gen) => ((await (0, event_runtime_1.headOf)(store, (0, ids_1.generationId)(conversationId, gen))) ?? -1) + 1;
170
+ let g = before === undefined ? head : Math.min(before.g, head);
171
+ let upper = await tipOf(g); // exclusive upper bound within generation g
172
+ if (before !== undefined && before.g <= head)
173
+ upper = Math.min(before.seq, upper);
174
+ let last = before;
175
+ let scanned = 0;
176
+ const entries = [];
177
+ for (;;) {
178
+ if (entries.length >= limit || scanned >= maxScan || opts.signal?.aborted === true) {
179
+ return { entries, ...(last && { nextCursor: formatCursor(last) }), done: false };
180
+ }
181
+ if (upper <= 0) {
182
+ if (g === 0)
183
+ return { entries, ...(last && { nextCursor: formatCursor(last) }), done: true };
184
+ g--;
185
+ upper = await tipOf(g);
186
+ scanned++; // a generation hop is work: it counts against the scan budget
187
+ last = { g, seq: upper };
188
+ continue;
189
+ }
190
+ const take = Math.min(BLOCK, maxScan - scanned, upper);
191
+ const evs = await (0, event_runtime_1.readRangeOf)(store, (0, ids_1.generationId)(conversationId, g), upper - take, upper - 1);
192
+ if (evs.length === 0) {
193
+ // The range is gone (retention): treat the rest of this generation as exhausted.
194
+ upper = 0;
195
+ continue;
196
+ }
197
+ for (let i = evs.length - 1; i >= 0; i--) {
198
+ const ev = evs[i];
199
+ scanned++;
200
+ last = { g, seq: ev.sequence };
201
+ const rec = recordOf(ev);
202
+ if (rec !== undefined)
203
+ entries.push(entryOf(g, ev, rec));
204
+ if (entries.length >= limit)
205
+ break;
206
+ }
207
+ upper = last.seq;
208
+ }
209
+ }
210
+ return {
211
+ read: (conversationId, options = {}) => (options.direction ?? "forward") === "backward"
212
+ ? backward(conversationId, options)
213
+ : forward(conversationId, options),
214
+ headGeneration: (conversationId, hint) => findHeadGeneration(store, conversationId, hint),
215
+ };
216
+ }
217
+ //# sourceMappingURL=reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.js","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":";;;AAyBA,oCAEC;AAED,kCAKC;AAqDD,4BA8BC;AAoBD,gDAuBC;AAQD,4DAyGC;AAhRD,2DAA+E;AAC/E,qCAAwD;AACxD,+BAAqC;AACrC,mCAA+E;AAmB/E,MAAM,MAAM,GAAG,yBAAyB,CAAC;AAEzC,SAAgB,YAAY,CAAC,CAAW;IACtC,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;AAC3B,CAAC;AAED,SAAgB,WAAW,CAAC,MAA0B;IACpD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3C,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACjC,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CA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Ac,EAAE,OAAO,CAAC;QACtC,cAAc,EAAE,CAAC,cAAc,EAAE,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC;KAC1F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { EventEnvelope } from "@loomwork/core";
2
+ import type { Identity } from "./access";
3
+ /** A turn of a conversation whose closing record is in the log. Ids and status only, never text. */
4
+ export interface TurnSettledEvent {
5
+ conversationId: string;
6
+ /** The generation that wrote the record (`<conversationId>` or `<conversationId>~<n>`). */
7
+ executionId: string;
8
+ /** The turn number. A rejected message belongs to no turn and carries `0`. */
9
+ turn: number;
10
+ /** The closing record's `ord`: unique within the conversation, so a good idempotency key. */
11
+ ord: number;
12
+ /**
13
+ * `complete`, `interrupted` (a barge-in) or `failed` close an answered turn (the assistant record);
14
+ * `rejected` is a user message refused before any model call (the user record).
15
+ */
16
+ status: "complete" | "interrupted" | "failed" | "rejected";
17
+ /** Shared mode only: who asked. */
18
+ asker?: Identity;
19
+ }
20
+ export type TurnSettledListener = (event: TurnSettledEvent) => void | Promise<void>;
21
+ /**
22
+ * An `onDurableEvent` observer that calls `listener` once for each turn of `flow` whose closing
23
+ * record has been written: the assistant reply (`complete` / `interrupted` / `failed`), or a user
24
+ * message recorded as `rejected`. A read made from the listener sees the record.
25
+ *
26
+ * ```ts
27
+ * new WorkflowRuntime({ ..., onDurableEvent: turnSettledObserver(flow, (e) => queue.push(e)) });
28
+ * // or: defineConfig({ observability: { onDurableEvent: turnSettledObserver(flow, listener) } })
29
+ * ```
30
+ *
31
+ * The guarantees are `onDurableEvent`'s:
32
+ * - **After the write, at most once.** Replay and recovery serve the record from the log and append
33
+ * nothing, so they do not call it again. A process that dies after the write but before the call
34
+ * never makes it: if the work must happen, keep a recovery path (read `history` from your last
35
+ * handled `ord`). A fork of a conversation execution copies its prefix through the runtime, and those
36
+ * copies can be reported again under the fork's id: key idempotent work by `conversationId` + `ord`.
37
+ * - **Isolated.** A throw or a rejected promise is reported through the runtime's `onWarn` and never
38
+ * reaches the turn. An async listener is not awaited. Its SYNCHRONOUS part runs on the write chain,
39
+ * though, and delays the next write: start the work and return, do not do it inline.
40
+ * - **Only this runtime's writes.** A turn answered by another process is reported there.
41
+ *
42
+ * One runtime has one `onDurableEvent`: to observe several things, call each observer from one function.
43
+ */
44
+ export declare function turnSettledObserver(flow: {
45
+ readonly definition: {
46
+ readonly id: string;
47
+ };
48
+ }, listener: TurnSettledListener): (event: EventEnvelope) => void | Promise<void>;
49
+ //# sourceMappingURL=settled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settled.d.ts","sourceRoot":"","sources":["../src/settled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAazC,oGAAoG;AACpG,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,2FAA2F;IAC3F,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,6FAA6F;IAC7F,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC3D,mCAAmC;IACnC,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAIpF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE;IAAE,QAAQ,CAAC,UAAU,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACtD,QAAQ,EAAE,mBAAmB,GAC5B,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBhD"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.turnSettledObserver = turnSettledObserver;
4
+ const ids_1 = require("./ids");
5
+ const reader_1 = require("./reader");
6
+ const SETTLED = new Set(["complete", "interrupted", "failed"]);
7
+ /**
8
+ * An `onDurableEvent` observer that calls `listener` once for each turn of `flow` whose closing
9
+ * record has been written: the assistant reply (`complete` / `interrupted` / `failed`), or a user
10
+ * message recorded as `rejected`. A read made from the listener sees the record.
11
+ *
12
+ * ```ts
13
+ * new WorkflowRuntime({ ..., onDurableEvent: turnSettledObserver(flow, (e) => queue.push(e)) });
14
+ * // or: defineConfig({ observability: { onDurableEvent: turnSettledObserver(flow, listener) } })
15
+ * ```
16
+ *
17
+ * The guarantees are `onDurableEvent`'s:
18
+ * - **After the write, at most once.** Replay and recovery serve the record from the log and append
19
+ * nothing, so they do not call it again. A process that dies after the write but before the call
20
+ * never makes it: if the work must happen, keep a recovery path (read `history` from your last
21
+ * handled `ord`). A fork of a conversation execution copies its prefix through the runtime, and those
22
+ * copies can be reported again under the fork's id: key idempotent work by `conversationId` + `ord`.
23
+ * - **Isolated.** A throw or a rejected promise is reported through the runtime's `onWarn` and never
24
+ * reaches the turn. An async listener is not awaited. Its SYNCHRONOUS part runs on the write chain,
25
+ * though, and delays the next write: start the work and return, do not do it inline.
26
+ * - **Only this runtime's writes.** A turn answered by another process is reported there.
27
+ *
28
+ * One runtime has one `onDurableEvent`: to observe several things, call each observer from one function.
29
+ */
30
+ function turnSettledObserver(flow, listener) {
31
+ const flowId = flow.definition.id;
32
+ return (event) => {
33
+ if (event.workflowId !== flowId)
34
+ return;
35
+ const rec = (0, reader_1.recordOf)(event);
36
+ if (rec === undefined || rec.ord === undefined)
37
+ return;
38
+ const settled = rec.role === "assistant" ? SETTLED.has(rec.status) : rec.status === "rejected";
39
+ if (!settled)
40
+ return;
41
+ return listener({
42
+ conversationId: (0, ids_1.conversationIdOf)(event.executionId),
43
+ executionId: event.executionId,
44
+ turn: rec.turn,
45
+ ord: rec.ord,
46
+ status: rec.status,
47
+ ...(rec.asker !== undefined && { asker: rec.asker }),
48
+ });
49
+ };
50
+ }
51
+ //# sourceMappingURL=settled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settled.js","sourceRoot":"","sources":["../src/settled.ts"],"names":[],"mappings":";;AA2DA,kDAoBC;AA7ED,+BAAyC;AACzC,qCAAoC;AA+BpC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAS,CAAC,UAAU,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,mBAAmB,CACjC,IAAsD,EACtD,QAA6B;IAE7B,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;IAClC,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,IAAI,KAAK,CAAC,UAAU,KAAK,MAAM;YAAE,OAAO;QACxC,MAAM,GAAG,GAAG,IAAA,iBAAQ,EAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK,SAAS;YAAE,OAAO;QACvD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,UAAU,CAAC;QAC/F,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,OAAO,QAAQ,CAAC;YACd,cAAc,EAAE,IAAA,sBAAgB,EAAC,KAAK,CAAC,WAAW,CAAC;YACnD,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,MAAM,EAAE,GAAG,CAAC,MAAoC;YAChD,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;SACrD,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { Identity } from "./access";
2
+ /** What a host-signed inbox envelope says (the signature is added by {@link signInboxEnvelope}). */
3
+ export interface InboxEnvelopeBody {
4
+ /** The conversation this message is for. A signature for one conversation is refused by any other. */
5
+ conversationId: string;
6
+ /** `"user"` is a turn (needs `text`); `"close"` closes the conversation. */
7
+ kind: "user" | "close";
8
+ /** The replay-set key: unique per message. Re-using an id is refused as `replayed`. */
9
+ id: string;
10
+ /** Issue time, ms since epoch. An envelope at or before the conversation's staleness floor is refused as `stale`. */
11
+ iat: number;
12
+ /** The user text (kind `"user"`). */
13
+ text?: string;
14
+ /** Whose voice this is. Owner mode accepts only the owner's; shared mode needs a participant. */
15
+ asker?: Identity;
16
+ /** Shared mode: the `ord` of the asker's earlier user turn this one replaces. */
17
+ editOf?: number;
18
+ }
19
+ /** Thrown by {@link signInboxEnvelope} when the body is not an envelope the conversation would accept the SHAPE of. */
20
+ export declare class InvalidEnvelopeError extends Error {
21
+ constructor(message: string);
22
+ }
23
+ /**
24
+ * Sign an inbox envelope the way a host's own client does, so a test, a script or a TRUSTED bridge can write
25
+ * to a conversation's inbox directly (`runtime.send(id, { topic: CONVERSATION_TOPIC, payload })`).
26
+ *
27
+ * - It needs the conversation's envelope key (`ConversationFlowOptions.key`). The key is the authority of a
28
+ * TRUSTED bridge: keep it server-side, never ship it to a browser, and rotate it via `previousKeys`.
29
+ * - The body is checked up front with the same shape rules the conversation applies (a non-empty `id` of
30
+ * at most 256 chars, a finite `iat`, a valid `asker`, non-blank `text` for `"user"`, a positive integer
31
+ * `editOf`); a body that would be refused as malformed throws {@link InvalidEnvelopeError} instead of
32
+ * being signed. `maxTurnChars` is NOT checked here (the signer does not know the flow's limit): the
33
+ * conversation enforces it on the body.
34
+ * - A signature is NOT "nothing". A holder of the key can: (1) in SHARED mode, speak as ANY participant (the
35
+ * body checks only that the named `asker` is a participant); (2) edit that asker's earlier turns (`editOf`
36
+ * is checked against the signed `asker`, so it is only as strong as (1)); (3) bypass the client-only
37
+ * checks: the per-asker queue cap (`maxQueuedPerAsker`), and the "delegated sender needs `principalFor`"
38
+ * rule; (4) in OWNER mode the `asker` = owner comparison is a consistency check, not authentication: the
39
+ * runtime's access policy on `send` decides who may write at all; (5) write to EVERY conversation the
40
+ * runtime's `send` policy admits, because the key is per flow, not per tenant; (6) skew the staleness
41
+ * floor: an `iat` up to 60 s in the future is accepted, and once that id is evicted from the replay set
42
+ * the floor moves forward, making legitimate envelopes issued in the following ~60 s `stale`.
43
+ * - What still holds against a key holder: the conversation binding, replayed ids, the staleness floor and
44
+ * age window, the owner-mode voice, the shared-mode participant check for user turns, a shared-mode
45
+ * close needing the owner, the service principal or a `manageParticipants` manager, `maxTurnChars`, and
46
+ * the shape checks above.
47
+ * - Intended users: tests and trusted server-side bridges. An application normally calls
48
+ * `conversations.sendTurn`, which builds and signs the envelope itself.
49
+ */
50
+ export declare function signInboxEnvelope(key: string, body: InboxEnvelopeBody): Record<string, unknown>;
51
+ //# sourceMappingURL=signEnvelope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signEnvelope.d.ts","sourceRoot":"","sources":["../src/signEnvelope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,oGAAoG;AACpG,MAAM,WAAW,iBAAiB;IAChC,sGAAsG;IACtG,cAAc,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,uFAAuF;IACvF,EAAE,EAAE,MAAM,CAAC;IACX,qHAAqH;IACrH,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iGAAiG;IACjG,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,uHAAuH;AACvH,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmB/F"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvalidEnvelopeError = void 0;
4
+ exports.signInboxEnvelope = signInboxEnvelope;
5
+ const conversation_1 = require("./conversation");
6
+ /** Thrown by {@link signInboxEnvelope} when the body is not an envelope the conversation would accept the SHAPE of. */
7
+ class InvalidEnvelopeError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = "InvalidEnvelopeError";
11
+ }
12
+ }
13
+ exports.InvalidEnvelopeError = InvalidEnvelopeError;
14
+ /**
15
+ * Sign an inbox envelope the way a host's own client does, so a test, a script or a TRUSTED bridge can write
16
+ * to a conversation's inbox directly (`runtime.send(id, { topic: CONVERSATION_TOPIC, payload })`).
17
+ *
18
+ * - It needs the conversation's envelope key (`ConversationFlowOptions.key`). The key is the authority of a
19
+ * TRUSTED bridge: keep it server-side, never ship it to a browser, and rotate it via `previousKeys`.
20
+ * - The body is checked up front with the same shape rules the conversation applies (a non-empty `id` of
21
+ * at most 256 chars, a finite `iat`, a valid `asker`, non-blank `text` for `"user"`, a positive integer
22
+ * `editOf`); a body that would be refused as malformed throws {@link InvalidEnvelopeError} instead of
23
+ * being signed. `maxTurnChars` is NOT checked here (the signer does not know the flow's limit): the
24
+ * conversation enforces it on the body.
25
+ * - A signature is NOT "nothing". A holder of the key can: (1) in SHARED mode, speak as ANY participant (the
26
+ * body checks only that the named `asker` is a participant); (2) edit that asker's earlier turns (`editOf`
27
+ * is checked against the signed `asker`, so it is only as strong as (1)); (3) bypass the client-only
28
+ * checks: the per-asker queue cap (`maxQueuedPerAsker`), and the "delegated sender needs `principalFor`"
29
+ * rule; (4) in OWNER mode the `asker` = owner comparison is a consistency check, not authentication: the
30
+ * runtime's access policy on `send` decides who may write at all; (5) write to EVERY conversation the
31
+ * runtime's `send` policy admits, because the key is per flow, not per tenant; (6) skew the staleness
32
+ * floor: an `iat` up to 60 s in the future is accepted, and once that id is evicted from the replay set
33
+ * the floor moves forward, making legitimate envelopes issued in the following ~60 s `stale`.
34
+ * - What still holds against a key holder: the conversation binding, replayed ids, the staleness floor and
35
+ * age window, the owner-mode voice, the shared-mode participant check for user turns, a shared-mode
36
+ * close needing the owner, the service principal or a `manageParticipants` manager, `maxTurnChars`, and
37
+ * the shape checks above.
38
+ * - Intended users: tests and trusted server-side bridges. An application normally calls
39
+ * `conversations.sendTurn`, which builds and signs the envelope itself.
40
+ */
41
+ function signInboxEnvelope(key, body) {
42
+ if (typeof key !== "string" || key.length === 0) {
43
+ throw new TypeError("signInboxEnvelope: `key` must be the conversation's non-empty envelope key");
44
+ }
45
+ if (body.kind === "user" && typeof body.text === "string" && body.text.trim() === "") {
46
+ throw new InvalidEnvelopeError("signInboxEnvelope: a `user` envelope needs non-blank `text` (the conversation refuses it as malformed)");
47
+ }
48
+ const signed = (0, conversation_1.signedEnvelope)(key, { ...body });
49
+ const { reason } = (0, conversation_1.parseSignedEnvelope)(signed, key, body.conversationId);
50
+ if (reason !== undefined) {
51
+ throw new InvalidEnvelopeError(`signInboxEnvelope: the body would be refused as ${reason} (check conversationId, kind, id, iat, text, asker, editOf)`);
52
+ }
53
+ return signed;
54
+ }
55
+ //# sourceMappingURL=signEnvelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signEnvelope.js","sourceRoot":"","sources":["../src/signEnvelope.ts"],"names":[],"mappings":";;;AAwDA,8CAmBC;AA1ED,iDAAqE;AAoBrE,uHAAuH;AACvH,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AALD,oDAKC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,iBAAiB,CAAC,GAAW,EAAE,IAAuB;IACpE,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,SAAS,CACjB,4EAA4E,CAC7E,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrF,MAAM,IAAI,oBAAoB,CAC5B,wGAAwG,CACzG,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,IAAA,6BAAc,EAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kCAAmB,EAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IACzE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,oBAAoB,CAC5B,mDAAmD,MAAM,6DAA6D,CACvH,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { SUMMARIZER_TEXT_TRUNCATED, summarizerText } from "@loomwork/agent";
2
+ //# sourceMappingURL=summarizerText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizerText.d.ts","sourceRoot":"","sources":["../src/summarizerText.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.summarizerText = exports.SUMMARIZER_TEXT_TRUNCATED = void 0;
4
+ // The walker moved down to @loomwork/agent so the built-in compaction summarizer can use it
5
+ // (ADR 0137); this re-export keeps `@loomwork/conversation`'s public surface and imports unchanged.
6
+ var agent_1 = require("@loomwork/agent");
7
+ Object.defineProperty(exports, "SUMMARIZER_TEXT_TRUNCATED", { enumerable: true, get: function () { return agent_1.SUMMARIZER_TEXT_TRUNCATED; } });
8
+ Object.defineProperty(exports, "summarizerText", { enumerable: true, get: function () { return agent_1.summarizerText; } });
9
+ //# sourceMappingURL=summarizerText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizerText.js","sourceRoot":"","sources":["../src/summarizerText.ts"],"names":[],"mappings":";;;AAAA,4FAA4F;AAC5F,oGAAoG;AACpG,yCAA4E;AAAnE,kHAAA,yBAAyB,OAAA;AAAE,uGAAA,cAAc,OAAA"}
package/dist/turn.d.ts ADDED
@@ -0,0 +1,67 @@
1
+ import { type AgentHistoryMessage } from "@loomwork/agent";
2
+ import { ToolEffect } from "@loomwork/effect-runtime";
3
+ import type { EffectRuntime, PrincipalChain } from "@loomwork/effect-runtime";
4
+ import type { EventStore } from "@loomwork/event-runtime";
5
+ import type { RegisteredFlow, WorkflowRuntime } from "@loomwork/workflow-runtime";
6
+ import { type Identity } from "./access";
7
+ import type { BargeInSource } from "./bargeIn";
8
+ import { type ConversationConfig } from "./types";
9
+ /** What the coordinator hands the turn. */
10
+ export interface TurnInput {
11
+ conversationId: string;
12
+ turn: number;
13
+ ord: number;
14
+ asker: Identity;
15
+ text: string;
16
+ /** The key the message was sent under (the barge-in watcher's retry test). */
17
+ id?: string;
18
+ history: AgentHistoryMessage[];
19
+ /** Idempotency keys of recent turns (the watcher must not treat a retry as an interruption). */
20
+ known: string[];
21
+ }
22
+ export interface TurnResult {
23
+ status: "complete" | "interrupted" | "failed";
24
+ content: string;
25
+ /** Names of the tools the turn called (for classification). */
26
+ tools: string[];
27
+ /** A fixed, user-safe reason for `failed`. */
28
+ reason?: "denied" | "model-error" | "rate-limited" | "quota" | "tool-error" | "turn-failed" | "cancelled";
29
+ errorId?: string;
30
+ /** The memory scope this turn recalled from / wrote to, when the agent has a memory. */
31
+ memoryScope?: string;
32
+ /** The execution that ran the turn. */
33
+ turnExecutionId: string;
34
+ }
35
+ /**
36
+ * The turn execution's id: deterministic (a recovery finds the same execution) and UNGUESSABLE: the tail is
37
+ * an HMAC of the conversation and ordinal under the host's key. A predictable id let anyone who can start an
38
+ * execution plant one first and have the conversation adopt it (a forged answer, or a refusal to run).
39
+ */
40
+ export declare const turnExecutionId: (conversationId: string, ord: number, key: string) => string;
41
+ /** The flow a shared turn runs as (one `agentLoop$`), with the abort signals the effect registers. */
42
+ export declare function sharedTurnFlow(config: ConversationConfig, signals: Map<string, AbortSignal>, flowId: string): RegisteredFlow<TurnInput, Omit<TurnResult, "turnExecutionId">>;
43
+ export interface TurnEffectDeps {
44
+ runtime: WorkflowRuntime;
45
+ /** Where the turn execution's recorded start is verified before it is adopted. */
46
+ eventStore: EventStore;
47
+ /** The host's log of the real error behind a failed turn. */
48
+ onError?: ConversationConfig["onError"];
49
+ turnFlow: RegisteredFlow<TurnInput, Omit<TurnResult, "turnExecutionId">>;
50
+ signals: Map<string, AbortSignal>;
51
+ key: string;
52
+ /** Keys still accepted for VERIFICATION during a rotation window. */
53
+ previousKeys?: readonly string[];
54
+ bargeIn?: BargeInSource;
55
+ /** The principal a turn runs as for an asker identity. Default: the identity itself (tenant, actor, onBehalfOf). */
56
+ principalFor?: (asker: Identity) => PrincipalChain | Promise<PrincipalChain>;
57
+ }
58
+ /**
59
+ * The effect the coordinator runs a turn through. Idempotent by construction: the turn execution has a
60
+ * deterministic id, a re-run after a crash finds it (finished: use its output; unfinished: continue it).
61
+ */
62
+ export declare function sharedTurnEffect(deps: TurnEffectDeps): ToolEffect<TurnInput & {
63
+ ownerExecutionId: string;
64
+ }, TurnResult>;
65
+ /** Register the turn effect on `effects` under `effectId`. */
66
+ export declare function registerSharedTurnEffect(effects: EffectRuntime, effectId: string, deps: TurnEffectDeps): void;
67
+ //# sourceMappingURL=turn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../src/turn.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EAIzB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElF,OAAO,EAEL,KAAK,QAAQ,EAOd,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,WAAW,CAAC;AAEnE,OAAO,EAAE,KAAK,kBAAkB,EAAe,MAAM,SAAS,CAAC;AAU/D,2CAA2C;AAC3C,MAAM,WAAW,SAAS;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,gGAAgG;IAChG,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAC;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,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