@namzu/sdk 56.0.1 → 56.2.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/CHANGELOG.md +27 -0
- package/dist/compaction/context-breakdown.d.ts +1 -1
- package/dist/compaction/context-breakdown.d.ts.map +1 -1
- package/dist/compaction/context-breakdown.js +9 -2
- package/dist/compaction/context-breakdown.js.map +1 -1
- package/dist/compaction/verifier.d.ts.map +1 -1
- package/dist/compaction/verifier.js +3 -1
- package/dist/compaction/verifier.js.map +1 -1
- package/dist/public-runtime.d.ts +1 -1
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +1 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +17 -1
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +73 -5
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/file-evidence-context.d.ts +21 -4
- package/dist/runtime/query/file-evidence-context.d.ts.map +1 -1
- package/dist/runtime/query/file-evidence-context.js +70 -8
- package/dist/runtime/query/file-evidence-context.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +2 -11
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +1 -2
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +30 -19
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/recorded-context.d.ts +18 -0
- package/dist/runtime/query/iteration/recorded-context.d.ts.map +1 -0
- package/dist/runtime/query/iteration/recorded-context.js +37 -0
- package/dist/runtime/query/iteration/recorded-context.js.map +1 -0
- package/dist/runtime/query/iteration/step-context.d.ts +15 -51
- package/dist/runtime/query/iteration/step-context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/step-context.js +24 -134
- package/dist/runtime/query/iteration/step-context.js.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.d.ts +20 -8
- package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.js +52 -26
- package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
- package/dist/scheduler/completion-inbox.d.ts +27 -0
- package/dist/scheduler/completion-inbox.d.ts.map +1 -1
- package/dist/scheduler/completion-inbox.js +88 -21
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/store/session-index/fts.d.ts.map +1 -1
- package/dist/store/session-index/fts.js +6 -0
- package/dist/store/session-index/fts.js.map +1 -1
- package/dist/test-support/file-evidence-held.d.ts +11 -0
- package/dist/test-support/file-evidence-held.d.ts.map +1 -0
- package/dist/test-support/file-evidence-held.js +28 -0
- package/dist/test-support/file-evidence-held.js.map +1 -0
- package/dist/test-support/request-only.d.ts +10 -0
- package/dist/test-support/request-only.d.ts.map +1 -0
- package/dist/test-support/request-only.js +15 -0
- package/dist/test-support/request-only.js.map +1 -0
- package/dist/tools/builtins/content-fingerprint.d.ts +12 -0
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
- package/dist/tools/builtins/content-fingerprint.js +14 -0
- package/dist/tools/builtins/content-fingerprint.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +19 -16
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/stale-before-review.d.ts +18 -0
- package/dist/tools/builtins/stale-before-review.d.ts.map +1 -0
- package/dist/tools/builtins/stale-before-review.js +42 -0
- package/dist/tools/builtins/stale-before-review.js.map +1 -0
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +4 -0
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/defineTool.d.ts +2 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +1 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/untrusted-envelope.d.ts +7 -0
- package/dist/tools/untrusted-envelope.d.ts.map +1 -1
- package/dist/tools/untrusted-envelope.js +3 -1
- package/dist/tools/untrusted-envelope.js.map +1 -1
- package/dist/turn/evidence-recall.d.ts +19 -8
- package/dist/turn/evidence-recall.d.ts.map +1 -1
- package/dist/turn/evidence-recall.js +134 -53
- package/dist/turn/evidence-recall.js.map +1 -1
- package/dist/turn/memory-recall.d.ts +18 -0
- package/dist/turn/memory-recall.d.ts.map +1 -1
- package/dist/turn/memory-recall.js +43 -4
- package/dist/turn/memory-recall.js.map +1 -1
- package/dist/types/message/index.d.ts +46 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +78 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/session/prepare-step.d.ts +24 -0
- package/dist/types/session/prepare-step.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +16 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/package.json +1 -1
- package/src/compaction/context-breakdown.ts +11 -3
- package/src/compaction/verifier.ts +3 -1
- package/src/public-runtime.ts +7 -0
- package/src/runtime/query/executor.ts +84 -5
- package/src/runtime/query/file-evidence-context.ts +79 -11
- package/src/runtime/query/index.ts +2 -10
- package/src/runtime/query/iteration/index.ts +32 -26
- package/src/runtime/query/iteration/recorded-context.ts +48 -0
- package/src/runtime/query/iteration/step-context.ts +27 -155
- package/src/runtime/query/iteration/step-shaping.ts +64 -40
- package/src/scheduler/completion-inbox.ts +87 -20
- package/src/store/session-index/fts.ts +5 -0
- package/src/test-support/file-evidence-held.ts +27 -0
- package/src/test-support/request-only.ts +19 -0
- package/src/tools/builtins/content-fingerprint.ts +20 -0
- package/src/tools/builtins/edit.ts +18 -15
- package/src/tools/builtins/stale-before-review.ts +45 -0
- package/src/tools/builtins/write-file.ts +5 -0
- package/src/tools/defineTool.ts +3 -0
- package/src/tools/untrusted-envelope.ts +10 -1
- package/src/turn/evidence-recall.ts +189 -58
- package/src/turn/memory-recall.ts +59 -5
- package/src/types/message/index.ts +108 -1
- package/src/types/session/prepare-step.ts +26 -0
- package/src/types/tool/index.ts +18 -0
|
@@ -10,58 +10,22 @@ import type { Message } from '../../../types/message/index.js';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function stepContextMessage(content: string): import("../../../types/message/index.js").UserMessage;
|
|
12
12
|
/**
|
|
13
|
-
* Put
|
|
14
|
-
*
|
|
15
|
-
* reads and the longest data comes before it. Only the reminders and other
|
|
16
|
-
* request-only context may follow that message: once the turn has an
|
|
17
|
-
* assistant or tool message after it, the blocks stay at the end of the
|
|
18
|
-
* history, where a caching driver ends its breakpoint before them, so the
|
|
19
|
-
* tool loop of a long turn is not re-read at full price on every step.
|
|
13
|
+
* Put a request's own data into it: after everything the history holds, in
|
|
14
|
+
* the order offered, each distinct text once.
|
|
20
15
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
/** How many superseded versions of a replaceable block still go with the latest. */
|
|
31
|
-
export declare const EARLIER_VERSIONS_KEPT = 2;
|
|
32
|
-
/**
|
|
33
|
-
* Where a turn's request-only data sits, so it stays put from call to call.
|
|
34
|
-
*
|
|
35
|
-
* What a block says is the step's own business: a block it offers again with
|
|
36
|
-
* the same text is the same block, and it keeps the place it first had; a
|
|
37
|
-
* block it no longer offers is withdrawn, so corrected data never lingers.
|
|
38
|
-
* A block seen for the first time goes before the operator's message when that
|
|
39
|
-
* message is what the model is answering, and otherwise after the history of
|
|
40
|
-
* that moment. So the requests of a turn share their opening up to the first
|
|
41
|
-
* block that changed, and a caching driver keeps reading the same prefix
|
|
42
|
-
* instead of re-reading the turn from the operator's message on.
|
|
43
|
-
*
|
|
44
|
-
* A block that says of itself that a later one replaces it (the file
|
|
45
|
-
* evidence) is never taken back. When its text changes, the earlier text stays
|
|
46
|
-
* where it went and the new text follows the history of that moment, which is
|
|
47
|
-
* how the block itself tells the model to read it; when it stops holding, a
|
|
48
|
-
* short block says so. Only the latest version and the last
|
|
49
|
-
* `EARLIER_VERSIONS_KEPT` before it are carried, and an earlier version whose
|
|
50
|
-
* place a compaction rewrote is dropped, so the stale text stays small. Until
|
|
51
|
-
* a version is dropped no request of the turn rewrites the one before it.
|
|
16
|
+
* Request-only data is what the model needs for this request alone (a note
|
|
17
|
+
* that something is unavailable, the work still running). It is re-placed on
|
|
18
|
+
* every call and always last, so the history before it never changes shape
|
|
19
|
+
* from one call to the next and a caching driver, which ends its breakpoint
|
|
20
|
+
* before the first such block, covers the whole history on every call. What
|
|
21
|
+
* the model should keep reading in later requests is recorded as turn context
|
|
22
|
+
* instead (`PrepareStepResult.recordedContext`), and the loop records what it
|
|
23
|
+
* learns about files and finished work the same way.
|
|
52
24
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
25
|
+
* `request` is the projected history. `recorded` are entries the loop has just
|
|
26
|
+
* recorded: they join the history at the end of this call, so they go ahead
|
|
27
|
+
* of the first request-only block already in `request` (`tail` of them, at the
|
|
28
|
+
* end), which is where the next request will find them.
|
|
55
29
|
*/
|
|
56
|
-
export declare
|
|
57
|
-
private placed;
|
|
58
|
-
private readonly versions;
|
|
59
|
-
/**
|
|
60
|
-
* Put `blocks` and the `replaceable` ones into `request`, the projected copy
|
|
61
|
-
* of `history` (same length and order). `end` is the last message of the
|
|
62
|
-
* turn's own history. `retractions` says, per replaceable key, what to
|
|
63
|
-
* write when an earlier block of that key no longer holds.
|
|
64
|
-
*/
|
|
65
|
-
place(request: Message[], history: readonly Message[], end: Message | undefined, blocks: readonly Message[], replaceable?: readonly ReplaceableBlock[], retractions?: Readonly<Record<string, Message>>): void;
|
|
66
|
-
}
|
|
30
|
+
export declare function placeRequestContext(request: Message[], recorded: readonly Message[], tail: number, blocks: readonly Message[]): void;
|
|
67
31
|
//# sourceMappingURL=step-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-context.d.ts","sourceRoot":"","sources":["../../../../src/runtime/query/iteration/step-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"step-context.d.ts","sourceRoot":"","sources":["../../../../src/runtime/query/iteration/step-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;AAE9D;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,yDAKjD;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,OAAO,EAAE,EAClB,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,OAAO,EAAE,GACxB,IAAI,CASN"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createRuntimeContextMessage } from '../../../types/message/index.js';
|
|
2
|
-
import { isOperatorUserMessage } from '../steering.js';
|
|
3
2
|
/**
|
|
4
3
|
* Request-only context, as the model reads it: a runtime-context user
|
|
5
4
|
* message of kind `step-context`, labelled so the model does not take it
|
|
@@ -12,146 +11,37 @@ import { isOperatorUserMessage } from '../steering.js';
|
|
|
12
11
|
export function stepContextMessage(content) {
|
|
13
12
|
return createRuntimeContextMessage(`Current step context (runtime-generated; not a new user request):\n${content}`, 'step-context');
|
|
14
13
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Put `blocks` in front of the operator's new message when that message is
|
|
17
|
-
* what the model is about to answer, so the request is the last thing it
|
|
18
|
-
* reads and the longest data comes before it. Only the reminders and other
|
|
19
|
-
* request-only context may follow that message: once the turn has an
|
|
20
|
-
* assistant or tool message after it, the blocks stay at the end of the
|
|
21
|
-
* history, where a caching driver ends its breakpoint before them, so the
|
|
22
|
-
* tool loop of a long turn is not re-read at full price on every step.
|
|
23
|
-
*
|
|
24
|
-
* Reminders and notices that follow the operator's message stay where they
|
|
25
|
-
* are: they are short, and the edge after the request is where they are read.
|
|
26
|
-
*/
|
|
27
|
-
export function placeBeforeLatestOperatorMessage(history, blocks) {
|
|
28
|
-
if (blocks.length === 0)
|
|
29
|
-
return;
|
|
30
|
-
let at = history.length;
|
|
31
|
-
for (let i = history.length - 1; i >= 0; i--) {
|
|
32
|
-
const message = history[i];
|
|
33
|
-
if (isOperatorUserMessage(message)) {
|
|
34
|
-
at = i;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
// A reply or a tool result after the message: the model has moved on.
|
|
38
|
-
if (message.role === 'assistant' || message.role === 'tool')
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
history.splice(at, 0, ...blocks);
|
|
42
|
-
}
|
|
43
14
|
function textOf(message) {
|
|
44
15
|
return typeof message.content === 'string' ? message.content : JSON.stringify(message.content);
|
|
45
16
|
}
|
|
46
|
-
/** The operator message the model is about to answer, when there is one. */
|
|
47
|
-
function pendingOperatorMessage(history) {
|
|
48
|
-
for (let i = history.length - 1; i >= 0; i--) {
|
|
49
|
-
const message = history[i];
|
|
50
|
-
if (isOperatorUserMessage(message))
|
|
51
|
-
return message;
|
|
52
|
-
if (message.role === 'assistant' || message.role === 'tool')
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
/** How many superseded versions of a replaceable block still go with the latest. */
|
|
58
|
-
export const EARLIER_VERSIONS_KEPT = 2;
|
|
59
17
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* What a block says is the step's own business: a block it offers again with
|
|
63
|
-
* the same text is the same block, and it keeps the place it first had; a
|
|
64
|
-
* block it no longer offers is withdrawn, so corrected data never lingers.
|
|
65
|
-
* A block seen for the first time goes before the operator's message when that
|
|
66
|
-
* message is what the model is answering, and otherwise after the history of
|
|
67
|
-
* that moment. So the requests of a turn share their opening up to the first
|
|
68
|
-
* block that changed, and a caching driver keeps reading the same prefix
|
|
69
|
-
* instead of re-reading the turn from the operator's message on.
|
|
18
|
+
* Put a request's own data into it: after everything the history holds, in
|
|
19
|
+
* the order offered, each distinct text once.
|
|
70
20
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
21
|
+
* Request-only data is what the model needs for this request alone (a note
|
|
22
|
+
* that something is unavailable, the work still running). It is re-placed on
|
|
23
|
+
* every call and always last, so the history before it never changes shape
|
|
24
|
+
* from one call to the next and a caching driver, which ends its breakpoint
|
|
25
|
+
* before the first such block, covers the whole history on every call. What
|
|
26
|
+
* the model should keep reading in later requests is recorded as turn context
|
|
27
|
+
* instead (`PrepareStepResult.recordedContext`), and the loop records what it
|
|
28
|
+
* learns about files and finished work the same way.
|
|
79
29
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
30
|
+
* `request` is the projected history. `recorded` are entries the loop has just
|
|
31
|
+
* recorded: they join the history at the end of this call, so they go ahead
|
|
32
|
+
* of the first request-only block already in `request` (`tail` of them, at the
|
|
33
|
+
* end), which is where the next request will find them.
|
|
82
34
|
*/
|
|
83
|
-
export
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const index = (message) => message ? history.lastIndexOf(message) : history.length - 1;
|
|
94
|
-
const operator = pendingOperatorMessage(history);
|
|
95
|
-
const positionOf = (slot) => 'before' in slot.at ? index(slot.at.before) : index(slot.at.after) + 1;
|
|
96
|
-
const anchorOf = (slot) => ('before' in slot.at ? slot.at.before : slot.at.after);
|
|
97
|
-
const next = new Map();
|
|
98
|
-
const inserts = [];
|
|
99
|
-
for (const message of blocks) {
|
|
100
|
-
const text = textOf(message);
|
|
101
|
-
if (next.has(text))
|
|
102
|
-
continue;
|
|
103
|
-
let slot = this.placed.get(text);
|
|
104
|
-
if (slot) {
|
|
105
|
-
const anchor = anchorOf(slot);
|
|
106
|
-
if (anchor && index(anchor) < 0)
|
|
107
|
-
slot = { text, at: { after: end } };
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
slot = { text, at: operator ? { before: operator } : { after: end } };
|
|
111
|
-
}
|
|
112
|
-
next.set(text, slot);
|
|
113
|
-
inserts.push({ at: positionOf(slot), message });
|
|
114
|
-
}
|
|
115
|
-
this.placed = next;
|
|
116
|
-
const offered = new Map(replaceable.map((block) => [block.key, block.message]));
|
|
117
|
-
for (const key of new Set([...this.versions.keys(), ...offered.keys()])) {
|
|
118
|
-
const held = this.versions.get(key) ?? [];
|
|
119
|
-
const wanted = offered.get(key) ?? retractions[key];
|
|
120
|
-
const last = held.at(-1);
|
|
121
|
-
if (wanted !== undefined && (last === undefined || last.text !== textOf(wanted)))
|
|
122
|
-
held.push({
|
|
123
|
-
text: textOf(wanted),
|
|
124
|
-
message: wanted,
|
|
125
|
-
// The first version goes where the other blocks go; a later one
|
|
126
|
-
// follows the history, after the one it replaces.
|
|
127
|
-
at: last === undefined && operator ? { before: operator } : { after: end },
|
|
128
|
-
});
|
|
129
|
-
// An earlier version whose place a compaction rewrote is given up: the
|
|
130
|
-
// request is rewritten at that point anyway, and stacking stale copies
|
|
131
|
-
// at the end would only add bulk. The latest version is never given up.
|
|
132
|
-
const kept = held.filter((version, i) => {
|
|
133
|
-
if (i === held.length - 1)
|
|
134
|
-
return true;
|
|
135
|
-
const anchor = anchorOf(version);
|
|
136
|
-
return !anchor || index(anchor) >= 0;
|
|
137
|
-
});
|
|
138
|
-
// Only the latest and a few earlier versions are carried, so a long turn
|
|
139
|
-
// does not grow by a full copy per change.
|
|
140
|
-
kept.splice(0, Math.max(0, kept.length - (EARLIER_VERSIONS_KEPT + 1)));
|
|
141
|
-
this.versions.set(key, kept);
|
|
142
|
-
for (const version of kept) {
|
|
143
|
-
const anchor = anchorOf(version);
|
|
144
|
-
if (anchor && index(anchor) < 0)
|
|
145
|
-
version.at = { after: end };
|
|
146
|
-
inserts.push({ at: positionOf(version), message: version.message });
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
// Back to front, so an earlier position is not shifted by a later one;
|
|
150
|
-
// blocks at one position keep the order they were offered in.
|
|
151
|
-
const order = inserts.map((entry, position) => ({ ...entry, position }));
|
|
152
|
-
order.sort((a, b) => b.at - a.at || b.position - a.position);
|
|
153
|
-
for (const entry of order)
|
|
154
|
-
request.splice(entry.at, 0, entry.message);
|
|
35
|
+
export function placeRequestContext(request, recorded, tail, blocks) {
|
|
36
|
+
if (recorded.length > 0)
|
|
37
|
+
request.splice(request.length - tail, 0, ...recorded);
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
for (const message of blocks) {
|
|
40
|
+
const text = textOf(message);
|
|
41
|
+
if (seen.has(text))
|
|
42
|
+
continue;
|
|
43
|
+
seen.add(text);
|
|
44
|
+
request.push(message);
|
|
155
45
|
}
|
|
156
46
|
}
|
|
157
47
|
//# sourceMappingURL=step-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-context.js","sourceRoot":"","sources":["../../../../src/runtime/query/iteration/step-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"step-context.js","sourceRoot":"","sources":["../../../../src/runtime/query/iteration/step-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAA;AAG7E;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IACjD,OAAO,2BAA2B,CACjC,sEAAsE,OAAO,EAAE,EAC/E,cAAc,CACd,CAAA;AACF,CAAC;AAED,SAAS,MAAM,CAAC,OAAgB;IAC/B,OAAO,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;AAC/F,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,mBAAmB,CAClC,OAAkB,EAClB,QAA4B,EAC5B,IAAY,EACZ,MAA0B;IAE1B,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAA;IAC9E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,KAAK,MAAM,OAAO,IAAI,MAAM,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;QAC5B,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAQ;QAC5B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACd,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACtB,CAAC;AACF,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Message, type UserMessage } from '../../../types/message/index.js';
|
|
2
2
|
import type { ToolChoice } from '../../../types/provider/chat.js';
|
|
3
|
-
import type { PrepareStepContext, PrepareStepResult, StepResult, StepVeto } from '../../../types/session/index.js';
|
|
3
|
+
import type { PrepareStepContext, PrepareStepResult, RecordedContextItem, StepResult, StepVeto } from '../../../types/session/index.js';
|
|
4
4
|
import type { Skill } from '../../../types/skills/index.js';
|
|
5
5
|
import type { IterationContext } from './phases/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { stepContextMessage } from './step-context.js';
|
|
7
7
|
/**
|
|
8
8
|
* How the next request is shaped: admission, preparation, and the context
|
|
9
9
|
* budget handed to both.
|
|
@@ -24,16 +24,27 @@ export interface StepShaping {
|
|
|
24
24
|
readonly requestContextTokens?: number;
|
|
25
25
|
}
|
|
26
26
|
export { stepContextMessage };
|
|
27
|
-
/**
|
|
28
|
-
export declare function appendWorkContext(shaping: StepShaping, messages: Message[], stepNumber: number, prepared: PrepareStepResult): void;
|
|
29
|
-
/** What the two work-context blocks report; each tells the model a later one replaces it. */
|
|
27
|
+
/** The names the two kinds of recorded work context are filed under. */
|
|
30
28
|
export declare const OWNED_WORK_KEY = "owned-work";
|
|
31
29
|
export declare const FILE_EVIDENCE_KEY = "file-evidence";
|
|
30
|
+
/** What the work context says for one request. */
|
|
31
|
+
export interface WorkContext {
|
|
32
|
+
/** Facts that do not change once true, to be kept in the conversation. */
|
|
33
|
+
readonly recorded: RecordedContextItem[];
|
|
34
|
+
/** Facts about now, shown with this request only. */
|
|
35
|
+
readonly requestOnly: Message[];
|
|
36
|
+
}
|
|
32
37
|
/**
|
|
33
|
-
* The work
|
|
34
|
-
*
|
|
38
|
+
* The work context for a request whose projected messages are `messages`.
|
|
39
|
+
*
|
|
40
|
+
* Two kinds of fact, each where it belongs. What holds until something
|
|
41
|
+
* changes it, or never changes, is recorded: the file entries that are new or
|
|
42
|
+
* changed since the last record (with the paths whose entry no longer holds),
|
|
43
|
+
* and each owned task once it has finished. What is true only now, the tasks
|
|
44
|
+
* still running, goes with this request alone. Each text is admitted whole or
|
|
45
|
+
* not at all, within the room the request has left.
|
|
35
46
|
*/
|
|
36
|
-
export declare function
|
|
47
|
+
export declare function workContext(shaping: StepShaping, messages: readonly Message[], stepNumber: number, prepared: PrepareStepResult): WorkContext;
|
|
37
48
|
export declare function stepContext(shaping: StepShaping, stepNumber: number, prepared: PrepareStepResult): PrepareStepContext;
|
|
38
49
|
/** Refuse the next call on a veto or hook error; do not skip a failed admission check. */
|
|
39
50
|
export declare function beforeStep(shaping: StepShaping, stepNumber: number): Promise<StepVeto | undefined>;
|
|
@@ -44,6 +55,7 @@ export declare function prepareStep(shaping: StepShaping, stepNumber: number): P
|
|
|
44
55
|
model?: string;
|
|
45
56
|
system?: string;
|
|
46
57
|
context?: string;
|
|
58
|
+
recordedContext?: readonly RecordedContextItem[];
|
|
47
59
|
skills?: readonly Skill[];
|
|
48
60
|
temperature?: number;
|
|
49
61
|
maxResponseTokens?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-shaping.d.ts","sourceRoot":"","sources":["../../../../src/runtime/query/iteration/step-shaping.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"step-shaping.d.ts","sourceRoot":"","sources":["../../../../src/runtime/query/iteration/step-shaping.ts"],"names":[],"mappings":"AAMA,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,WAAW,EAGhB,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,KAAK,EACX,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,QAAQ,EACR,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAA;AAK3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAA;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,WAAW,GAAG,SAAS,CAAA;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,SAAS,UAAU,EAAE,CAAA;IAC3C,uEAAuE;IACvE,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAA;CACtC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAE7B,wEAAwE;AACxE,eAAO,MAAM,cAAc,eAAe,CAAA;AAC1C,eAAO,MAAM,iBAAiB,kBAAkB,CAAA;AAEhD,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IACxC,qDAAqD;IACrD,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,CAAA;CAC/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAC1B,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,iBAAiB,GACzB,WAAW,CAmCb;AAED,wBAAgB,WAAW,CAC1B,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,iBAAiB,GACzB,kBAAkB,CAgDpB;AAED,0FAA0F;AAC1F,wBAAsB,UAAU,CAC/B,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAU/B;AAED,iGAAiG;AACjG,wBAAsB,WAAW,CAChC,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC;IACV,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAA;IAChD,MAAM,CAAC,EAAE,SAAS,KAAK,EAAE,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAC,CAkHD;AAED,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,MAAM,GAAG,SAAS,GACvB,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
|
@@ -1,51 +1,66 @@
|
|
|
1
1
|
import { resolveContextWindow } from '../../../compaction/context-window.js';
|
|
2
|
-
import { estimateMessageTokens } from '../../../compaction/token-estimate.js';
|
|
2
|
+
import { estimateMessageTokens, estimateTextTokens } from '../../../compaction/token-estimate.js';
|
|
3
3
|
import { NAMZU } from '../../../constants/telemetry/index.js';
|
|
4
4
|
import { renderSkillsSection } from '../../../persona/assembler.js';
|
|
5
|
+
import { recordedOwnedTaskIds } from '../../../scheduler/completion-inbox.js';
|
|
5
6
|
import { PreparationContextError } from '../../../turn/preparation-context-error.js';
|
|
6
|
-
import { createSystemMessage, } from '../../../types/message/index.js';
|
|
7
|
+
import { createSystemMessage, turnContextEntries, } from '../../../types/message/index.js';
|
|
7
8
|
import { toErrorMessage } from '../../../utils/error.js';
|
|
8
9
|
import { createCallbackInference } from '../callback-inference.js';
|
|
10
|
+
import { recordFileEvidence } from '../file-evidence-context.js';
|
|
9
11
|
import { measureContext } from './phases/compaction.js';
|
|
10
|
-
import {
|
|
12
|
+
import { stepContextMessage } from './step-context.js';
|
|
11
13
|
export { stepContextMessage };
|
|
12
|
-
/**
|
|
13
|
-
export function appendWorkContext(shaping, messages, stepNumber, prepared) {
|
|
14
|
-
// Per-turn data goes in front of the operator's new message while that is
|
|
15
|
-
// what the model is answering, like the other blocks of request-only data.
|
|
16
|
-
placeBeforeLatestOperatorMessage(messages, workContextBlocks(shaping, messages, stepNumber, prepared).map((block) => block.message));
|
|
17
|
-
}
|
|
18
|
-
/** What the two work-context blocks report; each tells the model a later one replaces it. */
|
|
14
|
+
/** The names the two kinds of recorded work context are filed under. */
|
|
19
15
|
export const OWNED_WORK_KEY = 'owned-work';
|
|
20
16
|
export const FILE_EVIDENCE_KEY = 'file-evidence';
|
|
21
17
|
/**
|
|
22
|
-
* The work
|
|
23
|
-
*
|
|
18
|
+
* The work context for a request whose projected messages are `messages`.
|
|
19
|
+
*
|
|
20
|
+
* Two kinds of fact, each where it belongs. What holds until something
|
|
21
|
+
* changes it, or never changes, is recorded: the file entries that are new or
|
|
22
|
+
* changed since the last record (with the paths whose entry no longer holds),
|
|
23
|
+
* and each owned task once it has finished. What is true only now, the tasks
|
|
24
|
+
* still running, goes with this request alone. Each text is admitted whole or
|
|
25
|
+
* not at all, within the room the request has left.
|
|
24
26
|
*/
|
|
25
|
-
export function
|
|
27
|
+
export function workContext(shaping, messages, stepNumber, prepared) {
|
|
26
28
|
const { ctx } = shaping;
|
|
29
|
+
const held = (key) => turnContextEntries(ctx.recorder.messages, key);
|
|
30
|
+
const inbox = ctx.completionInbox;
|
|
27
31
|
const contributions = [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
{ content: inbox?.describeRunningWork() },
|
|
33
|
+
{
|
|
34
|
+
content: inbox?.describeSettledWork(recordedOwnedTaskIds(held(OWNED_WORK_KEY))),
|
|
35
|
+
key: OWNED_WORK_KEY,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
content: recordFileEvidence(ctx.toolExecutor.fileEvidenceEntries(messages), held(FILE_EVIDENCE_KEY)),
|
|
39
|
+
key: FILE_EVIDENCE_KEY,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
const present = contributions.filter((entry) => Boolean(entry.content));
|
|
43
|
+
const work = { recorded: [], requestOnly: [] };
|
|
44
|
+
if (present.length === 0)
|
|
45
|
+
return work;
|
|
34
46
|
let room = stepContext(shaping, stepNumber, prepared).contextBudget?.remainingTokens ?? 0;
|
|
35
47
|
// Leave room for the actual task; admit whole contributions, never dangling partial references.
|
|
36
48
|
if (room < 1_500)
|
|
37
|
-
return
|
|
38
|
-
for (const
|
|
49
|
+
return work;
|
|
50
|
+
for (const { content, key } of present) {
|
|
39
51
|
if (!content || content.length > 8_000)
|
|
40
52
|
continue;
|
|
41
53
|
const message = stepContextMessage(content);
|
|
42
54
|
const tokens = estimateMessageTokens(message);
|
|
43
55
|
if (tokens > Math.min(2_000, room - 1_000))
|
|
44
56
|
continue;
|
|
45
|
-
|
|
57
|
+
if (key)
|
|
58
|
+
work.recorded.push({ key, text: content });
|
|
59
|
+
else
|
|
60
|
+
work.requestOnly.push(message);
|
|
46
61
|
room -= tokens;
|
|
47
62
|
}
|
|
48
|
-
return
|
|
63
|
+
return work;
|
|
49
64
|
}
|
|
50
65
|
export function stepContext(shaping, stepNumber, prepared) {
|
|
51
66
|
const { ctx, latestUserMessage, steps } = shaping;
|
|
@@ -58,7 +73,8 @@ export function stepContext(shaping, stepNumber, prepared) {
|
|
|
58
73
|
const skills = prepared.skills ? renderSkillsSection([...prepared.skills]) : null;
|
|
59
74
|
const preamble = [prepared.system, skills].filter(Boolean).join('\n\n');
|
|
60
75
|
const preparedTokens = (preamble ? estimateMessageTokens(createSystemMessage(preamble)) : 0) +
|
|
61
|
-
(prepared.context ? estimateMessageTokens(stepContextMessage(prepared.context)) : 0)
|
|
76
|
+
(prepared.context ? estimateMessageTokens(stepContextMessage(prepared.context)) : 0) +
|
|
77
|
+
(prepared.recordedContext ?? []).reduce((sum, item) => sum + estimateTextTokens(item.text), 0);
|
|
62
78
|
const responseReserve = Math.min(prepared.maxResponseTokens ?? ctx.turnConfig.maxResponseTokens ?? Math.floor(window.tokens / 4), Math.floor(window.tokens / 4));
|
|
63
79
|
return {
|
|
64
80
|
sessionId: ctx.recorder.sessionId,
|
|
@@ -113,8 +129,16 @@ export async function prepareStep(shaping, stepNumber) {
|
|
|
113
129
|
...stepContext(shaping, stepNumber, result),
|
|
114
130
|
generateText: inference.generateText,
|
|
115
131
|
});
|
|
116
|
-
if (decided)
|
|
117
|
-
|
|
132
|
+
if (decided) {
|
|
133
|
+
// Recorded context adds up across stages: each stage files its own
|
|
134
|
+
// keys, and one stage must not erase what an earlier one recorded.
|
|
135
|
+
const recorded = [...(result.recordedContext ?? []), ...(decided.recordedContext ?? [])];
|
|
136
|
+
result = {
|
|
137
|
+
...result,
|
|
138
|
+
...decided,
|
|
139
|
+
...(recorded.length > 0 ? { recordedContext: recorded } : {}),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
118
142
|
await selectContextModel(shaping, result.model ?? ctx.turnConfig.model);
|
|
119
143
|
}
|
|
120
144
|
catch (err) {
|
|
@@ -179,6 +203,8 @@ export async function prepareStep(shaping, stepNumber) {
|
|
|
179
203
|
prepared.system = result.system;
|
|
180
204
|
if (result.context !== undefined)
|
|
181
205
|
prepared.context = result.context;
|
|
206
|
+
if (result.recordedContext !== undefined)
|
|
207
|
+
prepared.recordedContext = result.recordedContext;
|
|
182
208
|
if (result.skills !== undefined)
|
|
183
209
|
prepared.skills = result.skills;
|
|
184
210
|
if (result.temperature !== undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-shaping.js","sourceRoot":"","sources":["../../../../src/runtime/query/iteration/step-shaping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;
|
|
1
|
+
{"version":3,"file":"step-shaping.js","sourceRoot":"","sources":["../../../../src/runtime/query/iteration/step-shaping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAC5E,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,uCAAuC,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAA;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAA;AACpF,OAAO,EAGN,mBAAmB,EACnB,kBAAkB,GAClB,MAAM,iCAAiC,CAAA;AAUxC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,cAAc,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,11 @@
|
|
|
1
1
|
import type { TaskHandle, TaskScheduler } from '../types/agent/scheduler.js';
|
|
2
2
|
import type { TaskId } from '../types/ids/index.js';
|
|
3
3
|
import { type Logger } from '../utils/logger.js';
|
|
4
|
+
/**
|
|
5
|
+
* The ids of the tasks that earlier recorded entries name, read from the
|
|
6
|
+
* entries' text, so what is recorded is known from the conversation alone.
|
|
7
|
+
*/
|
|
8
|
+
export declare function recordedOwnedTaskIds(entries: readonly string[]): Set<string>;
|
|
4
9
|
export interface CompletionInboxOptions {
|
|
5
10
|
/** See {@link CompletionInbox.holdsTurnOpen}. Default `true`. */
|
|
6
11
|
readonly holdsTurnOpen?: boolean;
|
|
@@ -235,8 +240,30 @@ export declare class CompletionInbox {
|
|
|
235
240
|
* model once — but a RUNNING task that does not fit is: the preamble
|
|
236
241
|
* says exactly how many, so the model never mistakes the cap for the
|
|
237
242
|
* task having ended.
|
|
243
|
+
*
|
|
244
|
+
* @deprecated The query loop reads {@link describeRunningWork} for the
|
|
245
|
+
* request and {@link describeSettledWork} for what it records. This single
|
|
246
|
+
* snapshot is kept for hosts that read it themselves.
|
|
238
247
|
*/
|
|
239
248
|
describeOwnedWork(): string | undefined;
|
|
249
|
+
/**
|
|
250
|
+
* The tasks this turn launched that are still going, for the request that
|
|
251
|
+
* is about to be sent and for no other: running state changes, so it is
|
|
252
|
+
* never recorded. Most recently launched first; a task that does not fit
|
|
253
|
+
* is counted, so the model never mistakes the cap for the task having
|
|
254
|
+
* ended. Undefined when nothing is running.
|
|
255
|
+
*/
|
|
256
|
+
describeRunningWork(): string | undefined;
|
|
257
|
+
/**
|
|
258
|
+
* The tasks this turn launched that have reached a terminal state and are
|
|
259
|
+
* not yet in `recorded` (the ids earlier entries name), oldest first, as
|
|
260
|
+
* text to record. A terminal state does not change, so an entry is never
|
|
261
|
+
* out of date and is written once per task. Tasks that settled and fell
|
|
262
|
+
* out of the bounded list before they were recorded are counted. Undefined
|
|
263
|
+
* when no task has newly settled.
|
|
264
|
+
*/
|
|
265
|
+
describeSettledWork(recorded: ReadonlySet<string>): string | undefined;
|
|
266
|
+
private observe;
|
|
240
267
|
/**
|
|
241
268
|
* Tasks this turn launched that are still running.
|
|
242
269
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion-inbox.d.ts","sourceRoot":"","sources":["../../src/scheduler/completion-inbox.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"completion-inbox.d.ts","sourceRoot":"","sources":["../../src/scheduler/completion-inbox.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,oBAAoB,CAAA;AA6C/D;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAe5E;AAED,MAAM,WAAW,sBAAsB;IACtC,iEAAiE;IACjE,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,eAAe;IA8E1B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;IA7EtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAG3B;IACH,gEAAgE;IAChE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA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