chainlesschain 0.166.145 → 0.166.146
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/README.md +55 -10
- package/package.json +2 -2
- package/src/assets/linux-subreaper/linux-arm64/manifest.json +1 -1
- package/src/assets/linux-subreaper/linux-x64/manifest.json +1 -1
- package/src/command-help-index.json +2 -2
- package/src/commands/agent.js +20 -1
- package/src/commands/mcp-tasks.js +37 -4
- package/src/commands/mcp.js +24 -0
- package/src/commands/memory.js +131 -7
- package/src/data/changelog.json +13 -0
- package/src/generated/cc-agent-protocol.schema.json +175 -69
- package/src/harness/jsonl-session-store.js +4 -0
- package/src/harness/mcp-client.js +273 -48
- package/src/harness/prompt-compressor.js +1 -0
- package/src/harness/session-index.js +8 -0
- package/src/harness/session-list-index.js +2 -0
- package/src/lib/agent-session-export.js +19 -0
- package/src/lib/app-server/context-memory-notifications.js +11 -2
- package/src/lib/app-server/server.js +1 -0
- package/src/lib/background-launch-profile.js +38 -6
- package/src/lib/context-memory-kernel/local-semantic-source.js +426 -0
- package/src/lib/context-memory-kernel/local-semantic-worker.py +109 -0
- package/src/lib/context-memory-kernel/memory-service.js +35 -2
- package/src/lib/context-memory-kernel/provider-context.js +1 -1
- package/src/lib/context-memory-kernel/runtime.js +40 -0
- package/src/lib/evolution/evolution-artifact-ports.js +36 -1
- package/src/lib/formal-budget-authority.js +56 -3
- package/src/lib/formal-budget-contract.js +90 -5
- package/src/lib/mcp-client.js +1 -0
- package/src/lib/mcp-stateless-protocol.js +158 -0
- package/src/lib/mcp-task-continuation-contract.js +129 -0
- package/src/lib/mcp-task-continuation.js +147 -0
- package/src/lib/mcp-task-journal-projection.js +49 -4
- package/src/lib/mcp-task-runtime.js +148 -1
- package/src/lib/mcp-tasks.js +24 -0
- package/src/lib/session-host-snapshot.js +31 -0
- package/src/lib/session-input-lifecycle.js +147 -0
- package/src/lib/session-input-receipt.js +64 -0
- package/src/lib/session-message-provenance.js +6 -5
- package/src/lib/session-model-usage-recovery.js +115 -0
- package/src/lib/session-transcript-history.js +3 -0
- package/src/lib/session-transcript-structure.js +8 -1
- package/src/lib/storage-failure-cause-codes.js +79 -0
- package/src/repl/agent-repl.js +348 -23
- package/src/runtime/agent-core.js +29 -11
- package/src/runtime/headless-runner.js +1 -0
- package/src/runtime/headless-stream.js +40 -33
- package/src/runtime/mcp-config.js +5 -3
- package/src/runtime/policies/agent-policy.js +1 -0
package/src/commands/memory.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
import chalk from "chalk";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { logger } from "../lib/logger.js";
|
|
9
|
+
import { numericOption } from "../lib/cli-numeric.js";
|
|
9
10
|
import { bootstrap, shutdown } from "../runtime/bootstrap.js";
|
|
11
|
+
import { withQuietStdout } from "../runtime/quiet-stdout.js";
|
|
10
12
|
import { parseEditorCommand } from "./config.js";
|
|
11
13
|
import { executionBroker } from "../lib/process-execution-broker/index.js";
|
|
12
14
|
import {
|
|
@@ -69,17 +71,30 @@ export function openMemoryEditor(editor, filePath, deps = _deps) {
|
|
|
69
71
|
});
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
async function resolveCanonicalMemory(ctx) {
|
|
74
|
+
async function resolveCanonicalMemory(ctx, { migrateLegacy = true } = {}) {
|
|
73
75
|
const { createCliCanonicalMemoryService } =
|
|
74
76
|
await import("../lib/context-memory-kernel/index.js");
|
|
75
77
|
const legacyDb = ctx?.db?.getDatabase?.() || null;
|
|
76
78
|
const service = createCliCanonicalMemoryService({ legacyDb });
|
|
77
|
-
if (service.decision.canonical && ctx?.db) {
|
|
79
|
+
if (migrateLegacy && service.decision.canonical && ctx?.db) {
|
|
78
80
|
await service.migrateLegacyEntries(exportMemory(ctx.db.getDatabase()));
|
|
79
81
|
}
|
|
80
82
|
return service;
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
async function prepareMemoryCommand(program, options, resolution) {
|
|
86
|
+
const setup = async () => {
|
|
87
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
88
|
+
return { ctx, service: await resolveCanonicalMemory(ctx, resolution) };
|
|
89
|
+
};
|
|
90
|
+
return options.json ? withQuietStdout(setup) : setup();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function shutdownMemoryCommand(options) {
|
|
94
|
+
if (options.json) await withQuietStdout(shutdown);
|
|
95
|
+
else await shutdown();
|
|
96
|
+
}
|
|
97
|
+
|
|
83
98
|
async function resolveScopedMemory() {
|
|
84
99
|
const [{ createCliCanonicalMemoryService }, { getMemoryStore }] =
|
|
85
100
|
await Promise.all([
|
|
@@ -323,8 +338,7 @@ export function registerMemoryCommand(program) {
|
|
|
323
338
|
.option("--json", "Output as JSON")
|
|
324
339
|
.action(async (text, options) => {
|
|
325
340
|
try {
|
|
326
|
-
const ctx = await
|
|
327
|
-
const service = await resolveCanonicalMemory(ctx);
|
|
341
|
+
const { ctx, service } = await prepareMemoryCommand(program, options);
|
|
328
342
|
if (!ctx.db && !service.decision.canonical) {
|
|
329
343
|
logger.error("Database not available");
|
|
330
344
|
process.exit(1);
|
|
@@ -353,11 +367,121 @@ export function registerMemoryCommand(program) {
|
|
|
353
367
|
`Memory added: ${chalk.gray(entry.id.slice(0, 12))} [${chalk.cyan(entry.category)}]`,
|
|
354
368
|
);
|
|
355
369
|
}
|
|
356
|
-
|
|
357
|
-
await shutdown();
|
|
358
370
|
} catch (err) {
|
|
359
371
|
logger.error(`Failed: ${err.message}`);
|
|
360
|
-
process.
|
|
372
|
+
process.exitCode = 1;
|
|
373
|
+
} finally {
|
|
374
|
+
await shutdownMemoryCommand(options);
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
memory
|
|
379
|
+
.command("inspect")
|
|
380
|
+
.description(
|
|
381
|
+
"Read one canonical memory's current content, revision and digest",
|
|
382
|
+
)
|
|
383
|
+
.argument("<id>", "Exact canonical memory ID")
|
|
384
|
+
.option("--json", "Output as JSON")
|
|
385
|
+
.action(async (id, options) => {
|
|
386
|
+
try {
|
|
387
|
+
const { service } = await prepareMemoryCommand(program, options, {
|
|
388
|
+
migrateLegacy: false,
|
|
389
|
+
});
|
|
390
|
+
if (!service.decision.canonical)
|
|
391
|
+
throw new Error("Memory inspection requires canonical memory mode");
|
|
392
|
+
const entry = await service.inspect(id);
|
|
393
|
+
if (!entry)
|
|
394
|
+
throw Object.assign(new Error("Memory entry not found"), {
|
|
395
|
+
code: "CONTEXT_MEMORY_NOT_FOUND",
|
|
396
|
+
});
|
|
397
|
+
if (options.json) console.log(JSON.stringify(entry, null, 2));
|
|
398
|
+
else {
|
|
399
|
+
logger.log(`${entry.id} revision ${entry.revision} [${entry.state}]`);
|
|
400
|
+
logger.log(entry.digest);
|
|
401
|
+
logger.log(entry.content);
|
|
402
|
+
}
|
|
403
|
+
} catch (error) {
|
|
404
|
+
if (options.json)
|
|
405
|
+
console.log(
|
|
406
|
+
JSON.stringify({
|
|
407
|
+
error: {
|
|
408
|
+
code: error.code || "MEMORY_INSPECTION_FAILED",
|
|
409
|
+
message: error.message,
|
|
410
|
+
},
|
|
411
|
+
}),
|
|
412
|
+
);
|
|
413
|
+
else logger.error(`Failed: ${error.message}`);
|
|
414
|
+
process.exitCode = 1;
|
|
415
|
+
} finally {
|
|
416
|
+
await shutdownMemoryCommand(options);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
memory
|
|
421
|
+
.command("correct")
|
|
422
|
+
.description(
|
|
423
|
+
"Replace one canonical memory's content at the inspected revision",
|
|
424
|
+
)
|
|
425
|
+
.argument("<id>", "Exact canonical memory ID")
|
|
426
|
+
.argument("<text>", "Corrected content")
|
|
427
|
+
.requiredOption(
|
|
428
|
+
"--expected-revision <n>",
|
|
429
|
+
"Revision returned by memory inspect",
|
|
430
|
+
)
|
|
431
|
+
.option("--reason <text>", "Reason for the correction")
|
|
432
|
+
.option("--json", "Output as JSON")
|
|
433
|
+
.action(async (id, text, options) => {
|
|
434
|
+
try {
|
|
435
|
+
const expectedRevision = numericOption(options.expectedRevision, {
|
|
436
|
+
name: "--expected-revision",
|
|
437
|
+
integer: true,
|
|
438
|
+
min: 1,
|
|
439
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
440
|
+
});
|
|
441
|
+
const { service } = await prepareMemoryCommand(program, options, {
|
|
442
|
+
migrateLegacy: false,
|
|
443
|
+
});
|
|
444
|
+
if (!service.decision.canonical)
|
|
445
|
+
throw new Error("Memory correction requires canonical memory mode");
|
|
446
|
+
const entry = await service.correct(id, {
|
|
447
|
+
content: text,
|
|
448
|
+
expectedRevision,
|
|
449
|
+
reason: options.reason,
|
|
450
|
+
});
|
|
451
|
+
if (options.json) console.log(JSON.stringify(entry, null, 2));
|
|
452
|
+
else
|
|
453
|
+
logger.success(
|
|
454
|
+
`Memory corrected: ${entry.id} revision ${entry.revision}`,
|
|
455
|
+
);
|
|
456
|
+
} catch (error) {
|
|
457
|
+
const published = error.code === "CONTEXT_MEMORY_COMMIT_PUBLISHED";
|
|
458
|
+
if (options.json)
|
|
459
|
+
console.log(
|
|
460
|
+
JSON.stringify({
|
|
461
|
+
error: {
|
|
462
|
+
code: error.code || "MEMORY_CORRECTION_FAILED",
|
|
463
|
+
message: error.message,
|
|
464
|
+
},
|
|
465
|
+
noAutomaticReplay: true,
|
|
466
|
+
...(published
|
|
467
|
+
? {
|
|
468
|
+
committed: true,
|
|
469
|
+
storeRevision: error.storeRevision,
|
|
470
|
+
durability: error.durability,
|
|
471
|
+
cleanupComplete: error.cleanupComplete,
|
|
472
|
+
}
|
|
473
|
+
: {}),
|
|
474
|
+
}),
|
|
475
|
+
);
|
|
476
|
+
else {
|
|
477
|
+
logger.error(`Failed: ${error.message}`);
|
|
478
|
+
logger.info(
|
|
479
|
+
"Read the current memory with memory inspect before deciding whether to submit another correction.",
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
process.exitCode = published ? 2 : 1;
|
|
483
|
+
} finally {
|
|
484
|
+
await shutdownMemoryCommand(options);
|
|
361
485
|
}
|
|
362
486
|
});
|
|
363
487
|
|
package/src/data/changelog.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"source": "CHANGELOG.md",
|
|
3
3
|
"releases": [
|
|
4
|
+
{
|
|
5
|
+
"productVersion": null,
|
|
6
|
+
"cliVersion": "0.166.146",
|
|
7
|
+
"cliVersions": ["0.166.146"],
|
|
8
|
+
"date": "2026-11-09",
|
|
9
|
+
"title": "",
|
|
10
|
+
"sections": [
|
|
11
|
+
{
|
|
12
|
+
"heading": "Added - cc CLI 0.166.146: canonical Memory corrections and retained diagnostics (candidate, 2026-11-09)",
|
|
13
|
+
"body": "- Add `memory inspect <id>` and `memory correct <id> <text> --expected-revision <n>` for canonical Memory. Corrections retain record identity and scope, reject stale revisions, clear obsolete summaries/references, and report durable-publication failures without automatic replay.\n- Add body-free correction notifications and invalidate stale Memory projections in VS Code, JetBrains and desktop. Pair CLI 0.166.146 with VS Code/Open VSX 0.37.184 and JetBrains 0.4.199, after Agent Protocol 0.1.13, Agent SDK 0.2.18 and Context/Memory Kernel 0.1.12 publication/readback; Session Core remains 0.3.27.\n- Persist stream-session model-input diagnostics and retain JetBrains restored tool traces. Carry the reviewed MCP Tasks continuation, REPL recovery, explicit output-token caps and durable billing-window changes with their documented limits.\n- Require exact-source Linux/Windows/macOS CLI CI and Strict Sandbox before OIDC publication, then IDE host matrices and public download verification. The candidates are not yet public. Full lifecycle, multilingual quality, invoice reconciliation and paid admission remain incomplete; PC/mobile clients remain v5.0.3.145."
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
4
17
|
{
|
|
5
18
|
"productVersion": null,
|
|
6
19
|
"cliVersion": "0.166.145",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"contextMemory": {
|
|
25
25
|
"schemaId": "https://chainlesschain.com/schemas/context-memory-kernel/v1",
|
|
26
26
|
"schemaVersion": 1,
|
|
27
|
-
"sourceDigest": "sha256:
|
|
27
|
+
"sourceDigest": "sha256:8ae3b0d30f638d789ac509f1e0105552fa927bd1b22537415041337744be5e72",
|
|
28
28
|
"methods": {
|
|
29
29
|
"context/plan": {
|
|
30
30
|
"request": "ContextPlanRequest",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"memory.candidate.created",
|
|
66
66
|
"memory.activated",
|
|
67
67
|
"memory.reinforced",
|
|
68
|
+
"memory.corrected",
|
|
68
69
|
"memory.superseded",
|
|
69
70
|
"memory.expired",
|
|
70
71
|
"memory.deleted",
|
|
@@ -1952,7 +1953,8 @@
|
|
|
1952
1953
|
"memory.expired",
|
|
1953
1954
|
"memory.deleted",
|
|
1954
1955
|
"memory.purged",
|
|
1955
|
-
"memory.recalled"
|
|
1956
|
+
"memory.recalled",
|
|
1957
|
+
"memory.corrected"
|
|
1956
1958
|
]
|
|
1957
1959
|
},
|
|
1958
1960
|
"AgentStreamEventEnvelope": {
|
|
@@ -3601,6 +3603,9 @@
|
|
|
3601
3603
|
},
|
|
3602
3604
|
{
|
|
3603
3605
|
"$ref": "#/$defs/AgentMemoryRecalledStreamEvent"
|
|
3606
|
+
},
|
|
3607
|
+
{
|
|
3608
|
+
"$ref": "#/$defs/AgentMemoryCorrectedStreamEvent"
|
|
3604
3609
|
}
|
|
3605
3610
|
]
|
|
3606
3611
|
},
|
|
@@ -5058,75 +5063,14 @@
|
|
|
5058
5063
|
}
|
|
5059
5064
|
},
|
|
5060
5065
|
"MemoryDecisionRequest": {
|
|
5061
|
-
"
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
"memoryId",
|
|
5065
|
-
"type",
|
|
5066
|
-
"expectedRevision"
|
|
5067
|
-
],
|
|
5068
|
-
"properties": {
|
|
5069
|
-
"memoryId": {
|
|
5070
|
-
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
5071
|
-
},
|
|
5072
|
-
"type": {
|
|
5073
|
-
"enum": [
|
|
5074
|
-
"activate",
|
|
5075
|
-
"reinforce",
|
|
5076
|
-
"supersede",
|
|
5077
|
-
"archive",
|
|
5078
|
-
"expire"
|
|
5079
|
-
]
|
|
5080
|
-
},
|
|
5081
|
-
"expectedRevision": {
|
|
5082
|
-
"type": "integer",
|
|
5083
|
-
"minimum": 1
|
|
5084
|
-
},
|
|
5085
|
-
"confidenceDelta": {
|
|
5086
|
-
"type": "number",
|
|
5087
|
-
"minimum": 0,
|
|
5088
|
-
"maximum": 1
|
|
5089
|
-
},
|
|
5090
|
-
"importance": {
|
|
5091
|
-
"type": "number",
|
|
5092
|
-
"minimum": 0,
|
|
5093
|
-
"maximum": 1
|
|
5094
|
-
},
|
|
5095
|
-
"evidenceRefs": {
|
|
5096
|
-
"type": "array",
|
|
5097
|
-
"maxItems": 128,
|
|
5098
|
-
"items": {
|
|
5099
|
-
"$ref": "#/$defs/ContextMemorySourceRef"
|
|
5100
|
-
}
|
|
5101
|
-
},
|
|
5102
|
-
"tags": {
|
|
5103
|
-
"type": "array",
|
|
5104
|
-
"maxItems": 128,
|
|
5105
|
-
"items": {
|
|
5106
|
-
"type": "string",
|
|
5107
|
-
"maxLength": 128
|
|
5108
|
-
}
|
|
5109
|
-
},
|
|
5110
|
-
"summary": {
|
|
5111
|
-
"type": "string",
|
|
5112
|
-
"minLength": 1,
|
|
5113
|
-
"maxLength": 16384
|
|
5114
|
-
},
|
|
5115
|
-
"successorMemoryId": {
|
|
5116
|
-
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
5117
|
-
},
|
|
5118
|
-
"reason": {
|
|
5119
|
-
"type": "string",
|
|
5120
|
-
"minLength": 1,
|
|
5121
|
-
"maxLength": 2048
|
|
5122
|
-
},
|
|
5123
|
-
"authority": {
|
|
5124
|
-
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
5066
|
+
"oneOf": [
|
|
5067
|
+
{
|
|
5068
|
+
"$ref": "#/$defs/MemoryLifecycleDecisionRequest"
|
|
5125
5069
|
},
|
|
5126
|
-
|
|
5127
|
-
"$ref": "#/$defs/
|
|
5070
|
+
{
|
|
5071
|
+
"$ref": "#/$defs/MemoryCorrectionRequest"
|
|
5128
5072
|
}
|
|
5129
|
-
|
|
5073
|
+
]
|
|
5130
5074
|
},
|
|
5131
5075
|
"MemoryDeletionRequest": {
|
|
5132
5076
|
"type": "object",
|
|
@@ -5946,6 +5890,168 @@
|
|
|
5946
5890
|
"$ref": "#/$defs/ContextMemoryDigest"
|
|
5947
5891
|
}
|
|
5948
5892
|
}
|
|
5893
|
+
},
|
|
5894
|
+
"MemoryCorrectionRequest": {
|
|
5895
|
+
"type": "object",
|
|
5896
|
+
"additionalProperties": false,
|
|
5897
|
+
"required": [
|
|
5898
|
+
"memoryId",
|
|
5899
|
+
"type",
|
|
5900
|
+
"expectedRevision",
|
|
5901
|
+
"content"
|
|
5902
|
+
],
|
|
5903
|
+
"properties": {
|
|
5904
|
+
"memoryId": {
|
|
5905
|
+
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
5906
|
+
},
|
|
5907
|
+
"type": {
|
|
5908
|
+
"const": "correct"
|
|
5909
|
+
},
|
|
5910
|
+
"expectedRevision": {
|
|
5911
|
+
"type": "integer",
|
|
5912
|
+
"minimum": 1
|
|
5913
|
+
},
|
|
5914
|
+
"content": {
|
|
5915
|
+
"type": "string",
|
|
5916
|
+
"minLength": 1,
|
|
5917
|
+
"maxLength": 4194304
|
|
5918
|
+
},
|
|
5919
|
+
"reason": {
|
|
5920
|
+
"type": "string",
|
|
5921
|
+
"minLength": 1,
|
|
5922
|
+
"maxLength": 2048
|
|
5923
|
+
},
|
|
5924
|
+
"authority": {
|
|
5925
|
+
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
5926
|
+
},
|
|
5927
|
+
"at": {
|
|
5928
|
+
"$ref": "#/$defs/ContextMemoryTimestamp"
|
|
5929
|
+
}
|
|
5930
|
+
}
|
|
5931
|
+
},
|
|
5932
|
+
"MemoryLifecycleDecisionRequest": {
|
|
5933
|
+
"type": "object",
|
|
5934
|
+
"additionalProperties": false,
|
|
5935
|
+
"required": [
|
|
5936
|
+
"memoryId",
|
|
5937
|
+
"type",
|
|
5938
|
+
"expectedRevision"
|
|
5939
|
+
],
|
|
5940
|
+
"properties": {
|
|
5941
|
+
"memoryId": {
|
|
5942
|
+
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
5943
|
+
},
|
|
5944
|
+
"type": {
|
|
5945
|
+
"enum": [
|
|
5946
|
+
"activate",
|
|
5947
|
+
"reinforce",
|
|
5948
|
+
"supersede",
|
|
5949
|
+
"archive",
|
|
5950
|
+
"expire"
|
|
5951
|
+
]
|
|
5952
|
+
},
|
|
5953
|
+
"expectedRevision": {
|
|
5954
|
+
"type": "integer",
|
|
5955
|
+
"minimum": 1
|
|
5956
|
+
},
|
|
5957
|
+
"confidenceDelta": {
|
|
5958
|
+
"type": "number",
|
|
5959
|
+
"minimum": 0,
|
|
5960
|
+
"maximum": 1
|
|
5961
|
+
},
|
|
5962
|
+
"importance": {
|
|
5963
|
+
"type": "number",
|
|
5964
|
+
"minimum": 0,
|
|
5965
|
+
"maximum": 1
|
|
5966
|
+
},
|
|
5967
|
+
"evidenceRefs": {
|
|
5968
|
+
"type": "array",
|
|
5969
|
+
"maxItems": 128,
|
|
5970
|
+
"items": {
|
|
5971
|
+
"$ref": "#/$defs/ContextMemorySourceRef"
|
|
5972
|
+
}
|
|
5973
|
+
},
|
|
5974
|
+
"tags": {
|
|
5975
|
+
"type": "array",
|
|
5976
|
+
"maxItems": 128,
|
|
5977
|
+
"items": {
|
|
5978
|
+
"type": "string",
|
|
5979
|
+
"maxLength": 128
|
|
5980
|
+
}
|
|
5981
|
+
},
|
|
5982
|
+
"summary": {
|
|
5983
|
+
"type": "string",
|
|
5984
|
+
"minLength": 1,
|
|
5985
|
+
"maxLength": 16384
|
|
5986
|
+
},
|
|
5987
|
+
"successorMemoryId": {
|
|
5988
|
+
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
5989
|
+
},
|
|
5990
|
+
"reason": {
|
|
5991
|
+
"type": "string",
|
|
5992
|
+
"minLength": 1,
|
|
5993
|
+
"maxLength": 2048
|
|
5994
|
+
},
|
|
5995
|
+
"authority": {
|
|
5996
|
+
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
5997
|
+
},
|
|
5998
|
+
"at": {
|
|
5999
|
+
"$ref": "#/$defs/ContextMemoryTimestamp"
|
|
6000
|
+
}
|
|
6001
|
+
}
|
|
6002
|
+
},
|
|
6003
|
+
"AgentMemoryCorrectedStreamEvent": {
|
|
6004
|
+
"type": "object",
|
|
6005
|
+
"required": [
|
|
6006
|
+
"type",
|
|
6007
|
+
"memory_id",
|
|
6008
|
+
"revision",
|
|
6009
|
+
"record_digest",
|
|
6010
|
+
"previous_revision",
|
|
6011
|
+
"previous_record_digest"
|
|
6012
|
+
],
|
|
6013
|
+
"properties": {
|
|
6014
|
+
"type": {
|
|
6015
|
+
"const": "memory.corrected"
|
|
6016
|
+
},
|
|
6017
|
+
"operation_id": {
|
|
6018
|
+
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
6019
|
+
},
|
|
6020
|
+
"request_id": {
|
|
6021
|
+
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
6022
|
+
},
|
|
6023
|
+
"session_id": {
|
|
6024
|
+
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
6025
|
+
},
|
|
6026
|
+
"memory_id": {
|
|
6027
|
+
"$ref": "#/$defs/ContextMemoryIdentifier"
|
|
6028
|
+
},
|
|
6029
|
+
"revision": {
|
|
6030
|
+
"type": "integer",
|
|
6031
|
+
"minimum": 1
|
|
6032
|
+
},
|
|
6033
|
+
"record_digest": {
|
|
6034
|
+
"$ref": "#/$defs/ContextMemoryDigest"
|
|
6035
|
+
},
|
|
6036
|
+
"previous_revision": {
|
|
6037
|
+
"type": "integer",
|
|
6038
|
+
"minimum": 1
|
|
6039
|
+
},
|
|
6040
|
+
"previous_record_digest": {
|
|
6041
|
+
"$ref": "#/$defs/ContextMemoryDigest"
|
|
6042
|
+
},
|
|
6043
|
+
"seq": {
|
|
6044
|
+
"type": "integer",
|
|
6045
|
+
"minimum": 1
|
|
6046
|
+
},
|
|
6047
|
+
"trace_id": {
|
|
6048
|
+
"type": "string",
|
|
6049
|
+
"minLength": 1,
|
|
6050
|
+
"maxLength": 128,
|
|
6051
|
+
"pattern": "^[A-Za-z0-9._:-]+$"
|
|
6052
|
+
}
|
|
6053
|
+
},
|
|
6054
|
+
"additionalProperties": false
|
|
5949
6055
|
}
|
|
5950
6056
|
}
|
|
5951
6057
|
}
|
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
sanitizeConversationMessage,
|
|
48
48
|
SESSION_FORK_AUTHORITY_FIELD,
|
|
49
49
|
} from "../lib/session-message-provenance.js";
|
|
50
|
+
import { projectSessionInputMessages } from "../lib/session-input-lifecycle.js";
|
|
50
51
|
import {
|
|
51
52
|
assertFileLineByteLength,
|
|
52
53
|
DEFAULT_MAX_FILE_LINE_BYTES,
|
|
@@ -5986,6 +5987,9 @@ function rebuildMessagesFromFile(
|
|
|
5986
5987
|
// final suffix.reverse() restores user → assistant atomically.
|
|
5987
5988
|
suffix.push(turn.assistant, turn.user);
|
|
5988
5989
|
}
|
|
5990
|
+
} else if (event?.type === "session_input_settled") {
|
|
5991
|
+
const turn = projectSessionInputMessages(event);
|
|
5992
|
+
if (turn) suffix.push(turn[1], turn[0]);
|
|
5989
5993
|
}
|
|
5990
5994
|
}
|
|
5991
5995
|
suffix.reverse();
|