@myagentroam/agent 0.10.42 → 0.10.43
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { parseMarkupAttributes } from '../prompts/markup.js';
|
|
2
1
|
import { createHash } from 'node:crypto';
|
|
3
2
|
import { posix, win32 } from 'node:path';
|
|
4
3
|
import { isDeepStrictEqual } from 'node:util';
|
|
@@ -402,30 +401,36 @@ function staleReadReplacementFormatVersion(value) {
|
|
|
402
401
|
function applyPatchReplacementFormatVersion(value) {
|
|
403
402
|
return typeof value === 'string' && value.includes(' formatVersion="2"') ? 2 : 1;
|
|
404
403
|
}
|
|
405
|
-
function
|
|
406
|
-
const header = /^<mar_context_gc([^<>]*)>/u.exec(value);
|
|
407
|
-
if (!header)
|
|
408
|
-
return 1;
|
|
404
|
+
function subagentReplacementFormatVersion(value) {
|
|
409
405
|
try {
|
|
410
|
-
const
|
|
411
|
-
return
|
|
406
|
+
const parsed = JSON.parse(value);
|
|
407
|
+
return isRecord(parsed) && isRecord(parsed.contextGc) && parsed.contextGc.formatVersion === 2
|
|
408
|
+
? 2
|
|
409
|
+
: 1;
|
|
412
410
|
}
|
|
413
411
|
catch {
|
|
414
412
|
return 1;
|
|
415
413
|
}
|
|
416
414
|
}
|
|
417
|
-
function subagentReplacementFormatVersion(value) {
|
|
418
|
-
return gcMarkupFormatVersion(value) === 2 ? 2 : 1;
|
|
419
|
-
}
|
|
420
415
|
function execInputReplacementFormatVersion(value) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
416
|
+
if (typeof value === 'string' && value.includes(' formatVersion="3"'))
|
|
417
|
+
return 3;
|
|
418
|
+
if (!isRecord(value) || !isRecord(value.contextGc))
|
|
419
|
+
return 1;
|
|
420
|
+
return value.contextGc.formatVersion === 3 ? 3 : value.contextGc.formatVersion === 2 ? 2 : 1;
|
|
426
421
|
}
|
|
427
422
|
function execOutputReplacementFormatVersion(value) {
|
|
428
|
-
|
|
423
|
+
try {
|
|
424
|
+
const parsed = JSON.parse(value);
|
|
425
|
+
return isRecord(parsed) && parsed.contextGcFormatVersion === 3
|
|
426
|
+
? 3
|
|
427
|
+
: isRecord(parsed) && parsed.contextGcFormatVersion === 2
|
|
428
|
+
? 2
|
|
429
|
+
: 1;
|
|
430
|
+
}
|
|
431
|
+
catch {
|
|
432
|
+
return 1;
|
|
433
|
+
}
|
|
429
434
|
}
|
|
430
435
|
function toolNameForCallId(records, callId, beforeSequence) {
|
|
431
436
|
const call = modelToolCallForCallId(records, callId, beforeSequence);
|
|
@@ -1,41 +1,19 @@
|
|
|
1
1
|
import { markupAttributes, markupText } from '../prompts/markup.js';
|
|
2
|
-
//
|
|
2
|
+
// Render message placeholders only; structured GC records keep their JSON shape.
|
|
3
3
|
export function contextGcMarkup(kind, fields) {
|
|
4
4
|
const attributes = { kind };
|
|
5
5
|
const children = [];
|
|
6
|
-
const textFields = {
|
|
7
|
-
contextGc: 'instruction',
|
|
8
|
-
note: 'instruction',
|
|
9
|
-
preview: 'preview',
|
|
10
|
-
stdoutPreview: 'stdout_preview',
|
|
11
|
-
stderrPreview: 'stderr_preview',
|
|
12
|
-
modelContextPreview: 'model_context_preview',
|
|
13
|
-
description: 'description'
|
|
14
|
-
};
|
|
15
6
|
for (const [key, value] of Object.entries(fields)) {
|
|
16
7
|
if (value === undefined)
|
|
17
8
|
continue;
|
|
18
|
-
if (key === '
|
|
19
|
-
for (const [name, item] of Object.entries(value)) {
|
|
20
|
-
if (name === 'kind')
|
|
21
|
-
continue;
|
|
22
|
-
if (name === 'note')
|
|
23
|
-
children.push(markupText('instruction', String(item)));
|
|
24
|
-
else
|
|
25
|
-
attributes[name] = item;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else if (key === 'retainedInputs' && Array.isArray(value)) {
|
|
9
|
+
if (key === 'retainedInputs' && Array.isArray(value)) {
|
|
29
10
|
for (const input of value)
|
|
30
11
|
children.push(markupText('retained_input', typeof input === 'string' ? input : JSON.stringify(input)));
|
|
31
12
|
}
|
|
32
|
-
else if (key === '
|
|
33
|
-
children.push(
|
|
34
|
-
}
|
|
35
|
-
else if (Object.hasOwn(textFields, key))
|
|
36
|
-
children.push(markupText(textFields[key], String(value)));
|
|
13
|
+
else if (key === 'contextGc')
|
|
14
|
+
children.push(markupText('instruction', String(value)));
|
|
37
15
|
else
|
|
38
|
-
attributes[key
|
|
16
|
+
attributes[key] = value;
|
|
39
17
|
}
|
|
40
18
|
const opening = `<mar_context_gc${markupAttributes(attributes)}`;
|
|
41
19
|
return children.length
|
|
@@ -28,7 +28,7 @@ export function contextGcCodeModeInputReplacement(input, retainedInputs = []) {
|
|
|
28
28
|
}
|
|
29
29
|
export function contextGcCodeModeOutputReplacement(originalContent, truncated) {
|
|
30
30
|
const preview = unicodeHeadTail(originalContent, CODE_MODE_OUTPUT_PREVIEW_CHARACTERS);
|
|
31
|
-
return
|
|
31
|
+
return JSON.stringify({
|
|
32
32
|
originalBytes: Buffer.byteLength(originalContent),
|
|
33
33
|
lines: lineCount(originalContent),
|
|
34
34
|
truncated,
|
|
@@ -82,7 +82,7 @@ export function contextGcStaleReadReplacement(input) {
|
|
|
82
82
|
}
|
|
83
83
|
export function contextGcWebOutputReplacement(toolName, originalContent, truncated) {
|
|
84
84
|
const preview = unicodeHeadTail(originalContent, EXEC_OUTPUT_PREVIEW_CHARACTERS);
|
|
85
|
-
return
|
|
85
|
+
return JSON.stringify({
|
|
86
86
|
toolName,
|
|
87
87
|
originalBytes: Buffer.byteLength(originalContent),
|
|
88
88
|
lines: lineCount(originalContent),
|
|
@@ -123,12 +123,11 @@ export function contextGcExecInputReplacement(arguments_, formatVersion = 3, too
|
|
|
123
123
|
retainExecText(retained, 'command', arguments_.command, formatVersion);
|
|
124
124
|
if (typeof arguments_.data === 'string')
|
|
125
125
|
retainExecText(retained, 'data', arguments_.data, formatVersion);
|
|
126
|
-
retained.contextGc = contextGcMarkup('terminal_exec_input', retained.contextGc);
|
|
127
126
|
return retained;
|
|
128
127
|
}
|
|
129
128
|
export function contextGcExecOutputReplacement(result, formatVersion = 3) {
|
|
130
129
|
if (result.source === 'MODEL_CONTEXT_TRUNCATED')
|
|
131
|
-
return
|
|
130
|
+
return JSON.stringify({
|
|
132
131
|
status: result.status,
|
|
133
132
|
...(result.processId === undefined ? {} : { processId: result.processId }),
|
|
134
133
|
...(result.exitCode === undefined ? {} : { exitCode: result.exitCode }),
|
|
@@ -148,7 +147,7 @@ export function contextGcExecOutputReplacement(result, formatVersion = 3) {
|
|
|
148
147
|
const stderr = result.stderr;
|
|
149
148
|
const stdoutPreview = unicodeHeadTail(stdout, EXEC_OUTPUT_PREVIEW_CHARACTERS);
|
|
150
149
|
const stderrPreview = unicodeHeadTail(stderr, EXEC_OUTPUT_PREVIEW_CHARACTERS);
|
|
151
|
-
return
|
|
150
|
+
return JSON.stringify({
|
|
152
151
|
status: result.status,
|
|
153
152
|
...(result.processId === undefined ? {} : { processId: result.processId }),
|
|
154
153
|
...(result.exitCode === undefined ? {} : { exitCode: result.exitCode }),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { contextGcMarkup } from './context-gc-markup.js';
|
|
2
1
|
import { createHash } from 'node:crypto';
|
|
3
2
|
export function normalizeContextGcSubagentSnapshot(modelContent, completedPayload, toolName) {
|
|
4
3
|
if (typeof modelContent !== 'string' ||
|
|
@@ -94,7 +93,7 @@ export function contextGcSubagentSnapshotIsPreciselyCovered(source, retained) {
|
|
|
94
93
|
export function contextGcSubagentOutputReplacement(input) {
|
|
95
94
|
const latestMessage = input.source.latestMessage;
|
|
96
95
|
const formatVersion = input.formatVersion ?? 2;
|
|
97
|
-
return
|
|
96
|
+
return JSON.stringify({
|
|
98
97
|
agentId: input.source.agentId,
|
|
99
98
|
description: input.source.description,
|
|
100
99
|
status: input.source.status,
|