@yaks/context 0.0.0-stage → 0.2.36
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/LICENSE +202 -0
- package/README.md +85 -2
- package/_dist/host.d.ts +4 -0
- package/_dist/host.d.ts.map +1 -0
- package/_dist/mod.d.ts +13 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/output.d.ts +6 -0
- package/_dist/output.d.ts.map +1 -0
- package/_dist/result.d.ts +34 -0
- package/_dist/result.d.ts.map +1 -0
- package/_dist/vocab.d.ts +6 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/deno.json +1 -0
- package/host.js +34 -0
- package/host.js.map +1 -0
- package/host.ts +37 -0
- package/mod.js +34 -0
- package/mod.js.map +1 -0
- package/mod.ts +46 -0
- package/output.js +74 -0
- package/output.js.map +1 -0
- package/output.ts +68 -0
- package/package.json +32 -4
- package/result.js +272 -0
- package/result.js.map +1 -0
- package/result.ts +321 -0
- package/vocab.js +16 -0
- package/vocab.js.map +1 -0
- package/vocab.json +57 -0
- package/vocab.ts +17 -0
package/output.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Model-facing views of complete tool results. Programs keep their full answers. */
|
|
2
|
+
import type { Bundle, Comp, Graph } from 'jsr:@yaks/graph@0.2.36'
|
|
3
|
+
import { snapshot } from './mod.js'
|
|
4
|
+
import { derivedEid } from '@yaks/graph/identity'
|
|
5
|
+
import { resultBytes, resultSummary } from './result.js'
|
|
6
|
+
|
|
7
|
+
export const OUTPUT_LIMIT = 16_384
|
|
8
|
+
export type KeepOutput = (value: unknown, source: Bundle) => Promise<unknown>
|
|
9
|
+
|
|
10
|
+
/** JSON answers retain their structure; ordinary tool prose remains text. */
|
|
11
|
+
export let outputValue = (text: string): unknown => {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(text)
|
|
14
|
+
} catch {
|
|
15
|
+
return text
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// A result's `result` with its value, read by name where the line was read
|
|
20
|
+
// without it.
|
|
21
|
+
let valued = async (g: Graph, entry: Bundle): Promise<Comp> => {
|
|
22
|
+
let result = entry.result as Comp | undefined
|
|
23
|
+
if (!result || 'value' in result) return result ?? {}
|
|
24
|
+
let [row] = await g.get([entry.entity.eid], ['result'])
|
|
25
|
+
return (row?.result as Comp | undefined) ?? result
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The source entry remains unchanged. Hosts may supply a scoped snapshot store. */
|
|
29
|
+
export const outputView = async (
|
|
30
|
+
g: Graph,
|
|
31
|
+
entry: Bundle,
|
|
32
|
+
limit = OUTPUT_LIMIT,
|
|
33
|
+
keep?: KeepOutput,
|
|
34
|
+
): Promise<string> => {
|
|
35
|
+
if (!Number.isSafeInteger(limit) || limit < 512) {
|
|
36
|
+
throw new Error('output limit must be an integer >= 512')
|
|
37
|
+
}
|
|
38
|
+
let text = String((entry.content as Comp | undefined)?.body ?? '')
|
|
39
|
+
// The model receives the tool's prose. A concise view (search hits, for
|
|
40
|
+
// example) stays useful even when its backing rows carry large bodies, so
|
|
41
|
+
// the value is read only where there is no prose or too much of it: a
|
|
42
|
+
// transcript is read without its results' values (@yaks/session `reach`).
|
|
43
|
+
let fits = new TextEncoder().encode(text).length <= limit
|
|
44
|
+
if (fits && text.length > 0) return text
|
|
45
|
+
// A result keeps its tool's answer as data in `result{value}`; an answer
|
|
46
|
+
// not yet landed carries it in `output{value}`.
|
|
47
|
+
let kept = (await valued(g, entry)).value ??
|
|
48
|
+
(entry.output as Comp | undefined)?.value
|
|
49
|
+
let value = kept ?? outputValue(text)
|
|
50
|
+
if (fits && resultBytes(value) <= limit) return text
|
|
51
|
+
if (keep) return JSON.stringify(await keep(value, entry))
|
|
52
|
+
let body = kept == null ? text : JSON.stringify(value)
|
|
53
|
+
let revision = (await snapshot(body, entry.entity.eid)).revision
|
|
54
|
+
let handle = derivedEid('output:' + entry.entity.eid + ':' + revision)
|
|
55
|
+
let [existing] = await g.get([handle], ['context_output'])
|
|
56
|
+
if (!existing?.context_output) {
|
|
57
|
+
await g.apply([{
|
|
58
|
+
entity: { eid: handle },
|
|
59
|
+
context_output: { source: entry.entity.eid, revision, body },
|
|
60
|
+
}], { trusted: true })
|
|
61
|
+
} else if ((existing.context_output as Comp).body !== body) {
|
|
62
|
+
throw new Error('Stored output snapshot does not match its revision')
|
|
63
|
+
}
|
|
64
|
+
let summary = resultSummary(handle, value)
|
|
65
|
+
summary.message =
|
|
66
|
+
'The complete result is kept in the graph. Use result_query({id, query}) with jq syntax, or graph_value_read and graph_value_search with entity=id, component=context_output, property=body. The preview is abbreviated.'
|
|
67
|
+
return JSON.stringify({ ...summary, revision })
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaks/context",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.36",
|
|
4
|
+
"homepage": "https://jsr.io/@yaks/context",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./_dist/mod.d.ts",
|
|
9
|
+
"default": "./mod.js"
|
|
10
|
+
},
|
|
11
|
+
"./host": {
|
|
12
|
+
"types": "./_dist/host.d.ts",
|
|
13
|
+
"default": "./host.js"
|
|
14
|
+
},
|
|
15
|
+
"./result": {
|
|
16
|
+
"types": "./_dist/result.d.ts",
|
|
17
|
+
"default": "./result.js"
|
|
18
|
+
},
|
|
19
|
+
"./vocab": {
|
|
20
|
+
"types": "./_dist/vocab.d.ts",
|
|
21
|
+
"default": "./vocab.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@gabrielbryk/jq-ts": "1.7.0",
|
|
27
|
+
"@yaks/file": "0.2.36",
|
|
28
|
+
"@yaks/graph": "0.2.36",
|
|
29
|
+
"@yaks/process": "0.2.36",
|
|
30
|
+
"@yaks/vocab": "0.2.36"
|
|
31
|
+
},
|
|
32
|
+
"description": "Constructs instruction snapshots and prompt entries for graph transcripts, leaving admission, storage, and execution to the caller.",
|
|
33
|
+
"repository": "https://github.com/yak-sh/yak.git"
|
|
34
|
+
}
|
package/result.js
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/** Small model-facing descriptions of JSON values kept whole in the graph. */ import { LexError, parse, ParseError, run, RuntimeError } from "@gabrielbryk/jq-ts";
|
|
2
|
+
export let RESULT_LIMIT = 16_384;
|
|
3
|
+
export let RESULT_MAX = 33_554_432;
|
|
4
|
+
let BAD_ESCAPE = /^Invalid escape sequence "(\\[\s\S])"$/;
|
|
5
|
+
let LIMITS = {
|
|
6
|
+
maxSteps: 1_000_000,
|
|
7
|
+
maxDepth: 128
|
|
8
|
+
};
|
|
9
|
+
/** Regex escaping as it appears in a result_query JSON argument. */ export let jqRegex = 'For a literal question mark or dot in a regex, use test("[?]") or test("[.]").';
|
|
10
|
+
let object = (value)=>!!value && typeof value == 'object' && !Array.isArray(value);
|
|
11
|
+
let names = (value)=>Object.keys(value).slice(0, 16).map((key)=>key.slice(0, 48));
|
|
12
|
+
let typeOf = (value)=>value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value;
|
|
13
|
+
let withArticle = (type)=>(type == 'array' || type == 'object' || type == 'undefined' ? 'an ' : 'a ') + type;
|
|
14
|
+
let root = (value)=>{
|
|
15
|
+
let type = withArticle(typeOf(value));
|
|
16
|
+
if (object(value)) return type + ' with keys ' + JSON.stringify(names(value));
|
|
17
|
+
if (Array.isArray(value)) return type + ' of length ' + value.length;
|
|
18
|
+
return type;
|
|
19
|
+
};
|
|
20
|
+
// The lexer ends its span just after the bad escape. Repair that one string
|
|
21
|
+
// at a time so comments, interpolation, and existing escapes keep their text.
|
|
22
|
+
let escaped = (filter, error)=>{
|
|
23
|
+
for(let i = 0; i < 16; i++){
|
|
24
|
+
if (!(error instanceof LexError)) return;
|
|
25
|
+
let escape = error.message.match(BAD_ESCAPE)?.[1];
|
|
26
|
+
let at = error.span.end - 2;
|
|
27
|
+
if (!escape || filter.slice(at, at + 2) != escape) return;
|
|
28
|
+
filter = filter.slice(0, at) + '\\' + filter.slice(at);
|
|
29
|
+
try {
|
|
30
|
+
parse(filter);
|
|
31
|
+
return filter;
|
|
32
|
+
} catch (next) {
|
|
33
|
+
error = next;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
let nullOperand = (filter, error)=>{
|
|
38
|
+
let left = /^Cannot subtract \w+ from null$/.test(error.message);
|
|
39
|
+
let right = /^Cannot subtract null from \w+$/.test(error.message);
|
|
40
|
+
if (!left && !right) return;
|
|
41
|
+
let expr = filter.slice(error.span.start, error.span.end);
|
|
42
|
+
try {
|
|
43
|
+
let node = parse(expr);
|
|
44
|
+
if (node.kind != 'Binary' || node.op != '-') return;
|
|
45
|
+
let { start, end } = (left ? node.left : node.right).span;
|
|
46
|
+
return expr.slice(start, end);
|
|
47
|
+
} catch {
|
|
48
|
+
// A span in a compound assignment may name the assignment itself.
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
// Follow the slice's input. An as-binding passes its original input to
|
|
52
|
+
// the body and can supply variables used by the slice's bounds.
|
|
53
|
+
let slicePath = (filter, { start, end })=>{
|
|
54
|
+
let node = parse(filter);
|
|
55
|
+
let path = [];
|
|
56
|
+
while(node.kind == 'Pipe' || node.kind == 'As'){
|
|
57
|
+
if (node.kind == 'As') {
|
|
58
|
+
node = end <= node.bind.span.end ? node.bind : node.body;
|
|
59
|
+
} else if (end <= node.left.span.end) {
|
|
60
|
+
node = node.left;
|
|
61
|
+
} else {
|
|
62
|
+
path.push(filter.slice(node.left.span.start, node.left.span.end));
|
|
63
|
+
node = node.right;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (node.kind != 'Slice' || node.span.start != start || node.span.end != end) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let target = filter.slice(node.target.span.start, node.target.span.end);
|
|
70
|
+
let atRoot = target == '.' && !path.length;
|
|
71
|
+
if (target != '.' || atRoot) path.push(target);
|
|
72
|
+
return {
|
|
73
|
+
path: path.join(' | '),
|
|
74
|
+
root: atRoot ? node.target.span : null
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
let sliceHint = (filter, value, error)=>{
|
|
78
|
+
if (error.message != 'Slice expected string or array') return '';
|
|
79
|
+
try {
|
|
80
|
+
let source = slicePath(filter, error.span);
|
|
81
|
+
if (source) {
|
|
82
|
+
let { path, root: target } = source;
|
|
83
|
+
let table = target && object(value) && rows(value);
|
|
84
|
+
if (target && table) {
|
|
85
|
+
let { start, end } = target;
|
|
86
|
+
let query = filter.slice(0, start) + table.path + filter.slice(end);
|
|
87
|
+
return ` Slice target . has type object. Slice the rows at ${table.path}: ` + 'retry with the same id and ' + JSON.stringify({
|
|
88
|
+
query
|
|
89
|
+
}) + '.';
|
|
90
|
+
}
|
|
91
|
+
let [type] = run('first((' + path + ') | type | select(. != "array" and . != "string"))', value, {
|
|
92
|
+
limits: {
|
|
93
|
+
...LIMITS,
|
|
94
|
+
maxOutputs: RESULT_MAX
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
if (typeof type == 'string') {
|
|
98
|
+
let next = type == 'object' ? path + ' | keys' : path;
|
|
99
|
+
return ' Slice target ' + path + ' has type ' + type + '. ' + (type == 'object' ? 'To list its keys, ' : 'To read that value without slicing, ') + 'retry with the same id and ' + JSON.stringify({
|
|
100
|
+
query: next
|
|
101
|
+
}) + '.';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} catch {
|
|
105
|
+
// The diagnostic is bounded by the same evaluation limits.
|
|
106
|
+
}
|
|
107
|
+
let { start, end } = error.span;
|
|
108
|
+
return ' Failing slice: ' + filter.slice(start, end) + '.';
|
|
109
|
+
};
|
|
110
|
+
let caseHint = (value, error)=>{
|
|
111
|
+
if (!/^ascii_(?:down|up)case expects string$/.test(error.message)) return '';
|
|
112
|
+
let [fn] = error.message.split(' ');
|
|
113
|
+
let table = rows(value);
|
|
114
|
+
let example = table ? `${table.path}[] | .. | strings | ${fn}` : `.. | strings | ${fn}`;
|
|
115
|
+
return ` Select a string field before ${fn}. To change case of all strings in ${table ? 'the result rows' : 'the input'}, retry with the same id and ${JSON.stringify({
|
|
116
|
+
query: example
|
|
117
|
+
})}.`;
|
|
118
|
+
};
|
|
119
|
+
let jqFailure = (error, filter, value)=>{
|
|
120
|
+
if (error instanceof ParseError || error instanceof LexError && !BAD_ESCAPE.test(error.message)) {
|
|
121
|
+
let before = filter.slice(0, error.span.start).split('\n');
|
|
122
|
+
let path = rows(value)?.path;
|
|
123
|
+
let query = path ? `${path}[:3]` : '.';
|
|
124
|
+
return new Error(`jq syntax error at line ${before.length}, column ${before.at(-1).length + 1}: ` + `${error.message}. ` + (error.message == 'Unterminated string literal' ? 'Close the string with a double quote. ' : '') + `Try ${JSON.stringify({
|
|
125
|
+
query
|
|
126
|
+
})}. Input root is ${root(value)}.`);
|
|
127
|
+
}
|
|
128
|
+
let said = 'jq query failed: ' + error.message + '. Input root is ' + root(value) + '.';
|
|
129
|
+
if (error instanceof LexError && BAD_ESCAPE.test(error.message)) {
|
|
130
|
+
return new Error(said + ' ' + jqRegex);
|
|
131
|
+
}
|
|
132
|
+
let operand = error instanceof RuntimeError && nullOperand(filter, error);
|
|
133
|
+
return new Error(operand ? said + ' The operand ' + operand + ' evaluated to null. ' + 'If missing should count as zero, use (' + operand + ' // 0) in the subtraction.' : said + (error instanceof RuntimeError ? sliceHint(filter, value, error) + caseHint(value, error) : ''));
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* The values a jq filter makes of a kept result, with bounded work even for
|
|
137
|
+
* a recursive filter. Preserve backslashes in escapes jq does not recognize,
|
|
138
|
+
* so regex escapes can be entered directly. Refusals describe the root and
|
|
139
|
+
* can point to an offending expression or give a query the caller can retry.
|
|
140
|
+
*
|
|
141
|
+
* ```ts
|
|
142
|
+
* import { equal } from '@yaks/testing'
|
|
143
|
+
* equal(jqOver('.a', { a: 1 }), [1])
|
|
144
|
+
* ```
|
|
145
|
+
*/ export let jqOver = (filter, value, outputs = RESULT_MAX)=>{
|
|
146
|
+
let options = {
|
|
147
|
+
limits: {
|
|
148
|
+
...LIMITS,
|
|
149
|
+
maxOutputs: outputs
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
try {
|
|
153
|
+
return run(filter, value, options);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
let fixed = escaped(filter, error);
|
|
156
|
+
if (!fixed) throw jqFailure(error, filter, value);
|
|
157
|
+
try {
|
|
158
|
+
return run(fixed, value, options);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
throw jqFailure(error, fixed, value);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
export let resultBytes = (value)=>new TextEncoder().encode(JSON.stringify(value) ?? 'null').length;
|
|
165
|
+
let rows = (value, path = '.', depth = 0)=>{
|
|
166
|
+
if (Array.isArray(value)) return {
|
|
167
|
+
value,
|
|
168
|
+
path
|
|
169
|
+
};
|
|
170
|
+
if (!object(value)) return;
|
|
171
|
+
for (let key of [
|
|
172
|
+
'result',
|
|
173
|
+
'rows',
|
|
174
|
+
'data',
|
|
175
|
+
'values'
|
|
176
|
+
]){
|
|
177
|
+
if (Array.isArray(value[key])) {
|
|
178
|
+
return {
|
|
179
|
+
value: value[key],
|
|
180
|
+
path: path == '.' ? '.' + key : path + '.' + key
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (depth >= 4) return;
|
|
185
|
+
for (let key of [
|
|
186
|
+
'structuredContent',
|
|
187
|
+
'value'
|
|
188
|
+
]){
|
|
189
|
+
let table = rows(value[key], path == '.' ? '.' + key : path + '.' + key, depth + 1);
|
|
190
|
+
if (table) return table;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
let shape = (value)=>{
|
|
194
|
+
let table = rows(value);
|
|
195
|
+
return {
|
|
196
|
+
type: typeOf(value),
|
|
197
|
+
...object(value) ? {
|
|
198
|
+
keys: names(value)
|
|
199
|
+
} : {},
|
|
200
|
+
...typeof value == 'string' ? {
|
|
201
|
+
characters: value.length
|
|
202
|
+
} : {},
|
|
203
|
+
...table ? {
|
|
204
|
+
rows: table.value.length,
|
|
205
|
+
path: table.path,
|
|
206
|
+
columns: [
|
|
207
|
+
...new Set(table.value.slice(0, 3).flatMap((row)=>object(row) ? names(row) : []))
|
|
208
|
+
].slice(0, 16)
|
|
209
|
+
} : {}
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
let sample = (value, depth = 0)=>{
|
|
213
|
+
if (typeof value == 'string') {
|
|
214
|
+
return value.length > 256 ? value.slice(0, 256) + '…' : value;
|
|
215
|
+
}
|
|
216
|
+
if (depth >= 4 && value && typeof value == 'object') return '[…]';
|
|
217
|
+
if (Array.isArray(value)) {
|
|
218
|
+
return value.slice(0, 3).map((v)=>sample(v, depth + 1));
|
|
219
|
+
}
|
|
220
|
+
if (!object(value)) return value;
|
|
221
|
+
return Object.fromEntries(Object.entries(value).slice(0, 8).map(([k, v])=>[
|
|
222
|
+
k.slice(0, 80),
|
|
223
|
+
sample(v, depth + 1)
|
|
224
|
+
]));
|
|
225
|
+
};
|
|
226
|
+
let preview = (value)=>{
|
|
227
|
+
let out = sample(value);
|
|
228
|
+
let text = JSON.stringify(out) ?? 'null';
|
|
229
|
+
return resultBytes(out) > 4096 ? text.slice(0, 1000) + '…' : out;
|
|
230
|
+
};
|
|
231
|
+
export let resultSummary = (id, value, bytes = resultBytes(value))=>({
|
|
232
|
+
id,
|
|
233
|
+
bytes,
|
|
234
|
+
shape: shape(value),
|
|
235
|
+
preview: preview(value),
|
|
236
|
+
message: 'The complete result is kept in this space’s graph. ' + 'Use result_query({id, query}) with jq syntax to narrow it, or ' + 'await results.read(id) inside code_mode. The preview is abbreviated.'
|
|
237
|
+
});
|
|
238
|
+
export let RESULT_SCHEMA = {
|
|
239
|
+
type: 'object',
|
|
240
|
+
properties: {
|
|
241
|
+
id: {
|
|
242
|
+
type: 'string'
|
|
243
|
+
},
|
|
244
|
+
bytes: {
|
|
245
|
+
type: 'number'
|
|
246
|
+
},
|
|
247
|
+
shape: {
|
|
248
|
+
type: 'object'
|
|
249
|
+
},
|
|
250
|
+
preview: {},
|
|
251
|
+
message: {
|
|
252
|
+
type: 'string'
|
|
253
|
+
},
|
|
254
|
+
space: {
|
|
255
|
+
type: 'string'
|
|
256
|
+
},
|
|
257
|
+
app: {
|
|
258
|
+
type: 'string'
|
|
259
|
+
},
|
|
260
|
+
scope: {
|
|
261
|
+
type: 'string'
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
required: [
|
|
265
|
+
'id',
|
|
266
|
+
'bytes',
|
|
267
|
+
'shape',
|
|
268
|
+
'preview',
|
|
269
|
+
'message'
|
|
270
|
+
]
|
|
271
|
+
};
|
|
272
|
+
//# sourceMappingURL=result.js.map
|
package/result.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sources":["./result.ts"],"names":[],"mappings":"AAAA,4EAA4E,GAC5E,SACE,QAAQ,EACR,KAAK,EACL,UAAU,EACV,GAAG,EACH,YAAY,6BAEuB;AAErC,OAAO,IAAI,eAAuB,OAAM;AACxC,OAAO,IAAI,aAAqB,WAAU;AAE1C,IAAI,aAAa;AACjB,IAAI,SAAS;EAAE,UAAU;EAAW,UAAU;AAAI;AAElD,kEAAkE,GAClE,OAAO,IAAI,UACT,iFAAgF;AAElF,IAAI,SAAS,CAAC,QACZ,CAAC,CAAC,SAAS,OAAO,SAAS,YAAY,CAAC,MAAM,OAAO,CAAC;AACxD,IAAI,QAAQ,CAAC,QACX,OAAO,IAAI,CAAC,OAAO,KAAK,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,MAAQ,IAAI,KA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