omp-fabric 1.26.14 → 1.27.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 +46 -0
- package/README.md +0 -27
- package/dist/agents/handoff.d.ts +2 -3
- package/dist/agents/handoff.d.ts.map +1 -1
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents/types.d.ts +0 -7
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/chunks/{chunk-5EZWERJY.js → chunk-2BOZMRT5.js} +25 -8
- package/dist/chunks/{chunk-5EZWERJY.js.map → chunk-2BOZMRT5.js.map} +3 -3
- package/dist/chunks/{chunk-TF3MK3TH.js → chunk-4PQDZ3AY.js} +13 -13
- package/dist/chunks/{chunk-5U6HKMJV.js → chunk-4XLJPEI4.js} +3 -5
- package/dist/chunks/{chunk-5U6HKMJV.js.map → chunk-4XLJPEI4.js.map} +1 -1
- package/dist/chunks/{chunk-O5SZML2M.js → chunk-5MH37C4Y.js} +14 -7
- package/dist/chunks/chunk-5MH37C4Y.js.map +7 -0
- package/dist/chunks/{chunk-YWEXP724.js → chunk-7OZDA7YP.js} +5 -5
- package/dist/chunks/{chunk-673LUJCK.js → chunk-7QKSPNXQ.js} +7 -7
- package/dist/chunks/{chunk-PTYCFQEH.js → chunk-ABFK2RPI.js} +2 -2
- package/dist/chunks/{chunk-S3URDR4K.js → chunk-ANHZ3SWB.js} +8 -9
- package/dist/chunks/chunk-ANHZ3SWB.js.map +7 -0
- package/dist/chunks/{chunk-YLMDFMXM.js → chunk-BQ2U44IL.js} +2 -2
- package/dist/chunks/{chunk-RGE6MBYP.js → chunk-CNCRWY4Q.js} +27 -69
- package/dist/chunks/chunk-CNCRWY4Q.js.map +7 -0
- package/dist/chunks/{chunk-HWOL2YVU.js → chunk-CT23CX67.js} +48 -7
- package/dist/chunks/chunk-CT23CX67.js.map +7 -0
- package/dist/chunks/{chunk-3QPIB3H2.js → chunk-EV36BIIO.js} +8 -690
- package/dist/chunks/chunk-EV36BIIO.js.map +7 -0
- package/dist/chunks/{chunk-CA2P7NLW.js → chunk-FA7TNLOV.js} +2 -88
- package/dist/chunks/chunk-FA7TNLOV.js.map +7 -0
- package/dist/chunks/{chunk-BV3EDWSX.js → chunk-FVGI5PSL.js} +4 -1
- package/dist/chunks/chunk-FVGI5PSL.js.map +7 -0
- package/dist/chunks/{chunk-6IPXBDCA.js → chunk-FWFET65L.js} +211 -4
- package/dist/chunks/chunk-FWFET65L.js.map +7 -0
- package/dist/chunks/{chunk-ESPCTYVX.js → chunk-IPI4UOTC.js} +352 -1
- package/dist/chunks/chunk-IPI4UOTC.js.map +7 -0
- package/dist/chunks/{chunk-HCUDF34P.js → chunk-K7IN6FTM.js} +17 -17
- package/dist/chunks/chunk-K7IN6FTM.js.map +7 -0
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/compaction/branch-details.d.ts +3 -9
- package/dist/compaction/branch-details.d.ts.map +1 -1
- package/dist/compaction/instructions.d.ts +4 -29
- package/dist/compaction/instructions.d.ts.map +1 -1
- package/dist/compaction/trace-events.d.ts +1 -1
- package/dist/compaction/trace-events.d.ts.map +1 -1
- package/dist/config-migrations.d.ts +1 -1
- package/dist/config-migrations.d.ts.map +1 -1
- package/dist/config.d.ts +0 -18
- package/dist/config.d.ts.map +1 -1
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +3 -3
- package/dist/core/action-repair.d.ts +1 -0
- package/dist/core/action-repair.d.ts.map +1 -1
- package/dist/core/compact-controller.d.ts +0 -7
- package/dist/core/compact-controller.d.ts.map +1 -1
- package/dist/entropy/index.js +6 -7
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts +0 -64
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +260 -141
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/fabric-state.d.ts +0 -3
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +131 -247
- package/dist/index.js.map +3 -3
- package/dist/memory/discovery.js +2 -3
- package/dist/memory/normalize.js +1 -2
- package/dist/memory/search.js +2 -3
- package/dist/providers/agents-actions.d.ts.map +1 -1
- package/dist/providers/agents-provider.d.ts.map +1 -1
- package/dist/providers/compact-provider.d.ts.map +1 -1
- package/dist/providers/image-provider.d.ts +1 -0
- package/dist/providers/image-provider.d.ts.map +1 -1
- package/dist/providers/memory-provider.d.ts +0 -11
- package/dist/providers/memory-provider.d.ts.map +1 -1
- package/dist/providers/memory-provider.js +4 -7
- package/dist/residency/host.js +6 -14
- package/dist/residency/omp-entry.js +6 -14
- package/dist/residency/omp-entry.js.map +1 -1
- package/dist/runtime/core-override-guest-types.js +1 -1
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/node-process-runtime.js +8 -8
- package/dist/runtime/quickjs-runtime.d.ts +1 -1
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +2 -2
- package/dist/runtime/type-checker.js +1 -1
- package/dist/type-error-guidance.d.ts.map +1 -1
- package/dist/ui/controller.d.ts +0 -1
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/conversation.js +5 -5
- package/dist/ui/dashboard.d.ts.map +1 -1
- package/dist/ui/dashboard.js +13 -18
- package/dist/ui/dashboard.js.map +2 -2
- package/dist/ui/settings.d.ts.map +1 -1
- package/dist/ui/settings.js +9 -203
- package/dist/ui/settings.js.map +2 -2
- package/docs/agents.md +1 -3
- package/docs/audit-trace.md +3 -3
- package/docs/configuration.md +14 -6
- package/docs/entropy.md +1 -2
- package/docs/image.md +24 -3
- package/docs/interface.md +0 -35
- package/docs/memory-recall.md +6 -11
- package/docs/programmatic-compaction.md +14 -32
- package/package.json +8 -11
- package/dist/chunks/chunk-3J7BKUNG.js +0 -354
- package/dist/chunks/chunk-3J7BKUNG.js.map +0 -7
- package/dist/chunks/chunk-3QPIB3H2.js.map +0 -7
- package/dist/chunks/chunk-6IPXBDCA.js.map +0 -7
- package/dist/chunks/chunk-BV3EDWSX.js.map +0 -7
- package/dist/chunks/chunk-CA2P7NLW.js.map +0 -7
- package/dist/chunks/chunk-ESPCTYVX.js.map +0 -7
- package/dist/chunks/chunk-G3VKU6GZ.js +0 -1681
- package/dist/chunks/chunk-G3VKU6GZ.js.map +0 -7
- package/dist/chunks/chunk-HCUDF34P.js.map +0 -7
- package/dist/chunks/chunk-HWOL2YVU.js.map +0 -7
- package/dist/chunks/chunk-JL3KVPFJ.js +0 -291
- package/dist/chunks/chunk-JL3KVPFJ.js.map +0 -7
- package/dist/chunks/chunk-O5SZML2M.js.map +0 -7
- package/dist/chunks/chunk-QD2B5FUE.js +0 -15
- package/dist/chunks/chunk-QD2B5FUE.js.map +0 -7
- package/dist/chunks/chunk-QSRTEINF.js +0 -469
- package/dist/chunks/chunk-QSRTEINF.js.map +0 -7
- package/dist/chunks/chunk-QZJB7QTM.js +0 -248
- package/dist/chunks/chunk-QZJB7QTM.js.map +0 -7
- package/dist/chunks/chunk-RGE6MBYP.js.map +0 -7
- package/dist/chunks/chunk-S3URDR4K.js.map +0 -7
- package/dist/chunks/chunk-SMNOQLKU.js +0 -53
- package/dist/chunks/chunk-SMNOQLKU.js.map +0 -7
- package/dist/chunks/chunk-TQQPXV3I.js +0 -58
- package/dist/chunks/chunk-TQQPXV3I.js.map +0 -7
- package/dist/chunks/chunk-UAP6IQIR.js +0 -76
- package/dist/chunks/chunk-UAP6IQIR.js.map +0 -7
- package/dist/chunks/chunk-VE3FWDRH.js +0 -221
- package/dist/chunks/chunk-VE3FWDRH.js.map +0 -7
- package/dist/chunks/chunk-ZHDN5ESL.js +0 -130
- package/dist/chunks/chunk-ZHDN5ESL.js.map +0 -7
- package/dist/compaction/bounds.d.ts +0 -25
- package/dist/compaction/bounds.d.ts.map +0 -1
- package/dist/compaction/branch-summary.d.ts +0 -9
- package/dist/compaction/branch-summary.d.ts.map +0 -1
- package/dist/compaction/enrichers.d.ts +0 -10
- package/dist/compaction/enrichers.d.ts.map +0 -1
- package/dist/compaction/hook.d.ts +0 -117
- package/dist/compaction/hook.d.ts.map +0 -1
- package/dist/compaction/hook.js +0 -21
- package/dist/compaction/hook.js.map +0 -7
- package/dist/compaction/lcm-addresses.d.ts +0 -10
- package/dist/compaction/lcm-addresses.d.ts.map +0 -1
- package/dist/compaction/lcm-doctor.d.ts +0 -60
- package/dist/compaction/lcm-doctor.d.ts.map +0 -1
- package/dist/compaction/lcm-loader.d.ts +0 -12
- package/dist/compaction/lcm-loader.d.ts.map +0 -1
- package/dist/compaction/lcm-maintenance.d.ts +0 -152
- package/dist/compaction/lcm-maintenance.d.ts.map +0 -1
- package/dist/compaction/lcm-model.d.ts +0 -44
- package/dist/compaction/lcm-model.d.ts.map +0 -1
- package/dist/compaction/lcm-recovery.d.ts +0 -7
- package/dist/compaction/lcm-recovery.d.ts.map +0 -1
- package/dist/compaction/lcm-runtime.d.ts +0 -233
- package/dist/compaction/lcm-runtime.d.ts.map +0 -1
- package/dist/compaction/lcm-runtime.js +0 -2863
- package/dist/compaction/lcm-runtime.js.map +0 -7
- package/dist/compaction/lcm-status.d.ts +0 -5
- package/dist/compaction/lcm-status.d.ts.map +0 -1
- package/dist/compaction/normalize.d.ts +0 -83
- package/dist/compaction/normalize.d.ts.map +0 -1
- package/dist/compaction/projections.d.ts +0 -26
- package/dist/compaction/projections.d.ts.map +0 -1
- package/dist/compaction/render.d.ts +0 -11
- package/dist/compaction/render.d.ts.map +0 -1
- package/dist/core/event-loop-slice.d.ts +0 -11
- package/dist/core/event-loop-slice.d.ts.map +0 -1
- package/dist/memory/lcm-adapter.d.ts +0 -111
- package/dist/memory/lcm-adapter.d.ts.map +0 -1
- package/dist/storage/lcm-directory.d.ts +0 -17
- package/dist/storage/lcm-directory.d.ts.map +0 -1
- package/dist/storage/lcm-identity.d.ts +0 -48
- package/dist/storage/lcm-identity.d.ts.map +0 -1
- package/dist/storage/lcm-ledger.d.ts +0 -159
- package/dist/storage/lcm-ledger.d.ts.map +0 -1
- package/dist/storage/lcm-migration.d.ts +0 -87
- package/dist/storage/lcm-migration.d.ts.map +0 -1
- package/dist/storage/lcm-offthread.d.ts +0 -9
- package/dist/storage/lcm-offthread.d.ts.map +0 -1
- package/dist/storage/sqlite.d.ts +0 -19
- package/dist/storage/sqlite.d.ts.map +0 -1
- package/dist/ui/frame.d.ts +0 -7
- package/dist/ui/frame.d.ts.map +0 -1
- package/dist/ui/lcm-dashboard.d.ts +0 -43
- package/dist/ui/lcm-dashboard.d.ts.map +0 -1
- package/dist/ui/lcm-dashboard.js +0 -395
- package/dist/ui/lcm-dashboard.js.map +0 -7
- package/dist/ui/lcm-panel.d.ts +0 -37
- package/dist/ui/lcm-panel.d.ts.map +0 -1
- package/dist/ui/lcm-panel.js +0 -23
- package/dist/ui/lcm-panel.js.map +0 -7
- package/docs/adr/0001-lcm-durable-context-ledger.md +0 -6
- package/docs/certification.md +0 -134
- package/docs/compaction.md +0 -188
- /package/dist/chunks/{chunk-TF3MK3TH.js.map → chunk-4PQDZ3AY.js.map} +0 -0
- /package/dist/chunks/{chunk-YWEXP724.js.map → chunk-7OZDA7YP.js.map} +0 -0
- /package/dist/chunks/{chunk-673LUJCK.js.map → chunk-7QKSPNXQ.js.map} +0 -0
- /package/dist/chunks/{chunk-PTYCFQEH.js.map → chunk-ABFK2RPI.js.map} +0 -0
- /package/dist/chunks/{chunk-YLMDFMXM.js.map → chunk-BQ2U44IL.js.map} +0 -0
|
@@ -1,469 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MAX_SUMMARY_BYTES,
|
|
3
|
-
canonicalizeText,
|
|
4
|
-
clipUtf8,
|
|
5
|
-
utf8Bytes
|
|
6
|
-
} from "./chunk-UAP6IQIR.js";
|
|
7
|
-
|
|
8
|
-
// src/compaction/instructions.ts
|
|
9
|
-
var FABRIC_COMPACTION_REQUEST_PREFIX = "__omp_fabric_compact_request_v1__:";
|
|
10
|
-
var MAX_COMPACTION_INSTRUCTIONS_CHARS = 8 * 1024;
|
|
11
|
-
var MAX_COMPACTION_INSTRUCTIONS_BYTES = 8 * 1024;
|
|
12
|
-
var MAX_PRESERVE_ITEMS = 16;
|
|
13
|
-
var MAX_PRESERVE_ITEM_CHARS = 2 * 1024;
|
|
14
|
-
var MAX_PRESERVE_ITEM_BYTES = 2 * 1024;
|
|
15
|
-
var MAX_TYPED_COMPACTION_SOURCE_BYTES = 16 * 1024;
|
|
16
|
-
var rejection = (code, message, sourceBytes) => ({
|
|
17
|
-
ok: false,
|
|
18
|
-
requestLines: [],
|
|
19
|
-
error: { code, message, sourceBytes }
|
|
20
|
-
});
|
|
21
|
-
var isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
22
|
-
var hasPairedSurrogates = (value) => {
|
|
23
|
-
for (let index = 0; index < value.length; index++) {
|
|
24
|
-
const unit = value.charCodeAt(index);
|
|
25
|
-
if (unit >= 55296 && unit <= 56319) {
|
|
26
|
-
const next = value.charCodeAt(index + 1);
|
|
27
|
-
if (!(next >= 56320 && next <= 57343)) return false;
|
|
28
|
-
index += 1;
|
|
29
|
-
} else if (unit >= 56320 && unit <= 57343) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
};
|
|
35
|
-
var compactionRequestBoundsError = (request) => {
|
|
36
|
-
if (request.instructions !== void 0) {
|
|
37
|
-
if (!hasPairedSurrogates(request.instructions)) {
|
|
38
|
-
return {
|
|
39
|
-
code: "invalid-unicode",
|
|
40
|
-
message: "typed compaction instructions contain an unpaired UTF-16 surrogate"
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
if (request.instructions.length > MAX_COMPACTION_INSTRUCTIONS_CHARS || utf8Bytes(request.instructions) > MAX_COMPACTION_INSTRUCTIONS_BYTES) {
|
|
44
|
-
return {
|
|
45
|
-
code: "instructions-too-large",
|
|
46
|
-
message: `typed compaction instructions exceed ${MAX_COMPACTION_INSTRUCTIONS_CHARS} characters or ${MAX_COMPACTION_INSTRUCTIONS_BYTES} UTF-8 bytes`
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (request.preserve !== void 0) {
|
|
51
|
-
if (request.preserve.length > MAX_PRESERVE_ITEMS) {
|
|
52
|
-
return {
|
|
53
|
-
code: "preserve-too-many",
|
|
54
|
-
message: `typed compaction preserve exceeds ${MAX_PRESERVE_ITEMS} items`
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
for (const item of request.preserve) {
|
|
58
|
-
if (!hasPairedSurrogates(item)) {
|
|
59
|
-
return {
|
|
60
|
-
code: "invalid-unicode",
|
|
61
|
-
message: "typed compaction preserve item contains an unpaired UTF-16 surrogate"
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
if (item.length > MAX_PRESERVE_ITEM_CHARS || utf8Bytes(item) > MAX_PRESERVE_ITEM_BYTES) {
|
|
65
|
-
return {
|
|
66
|
-
code: "preserve-item-too-large",
|
|
67
|
-
message: `typed compaction preserve item exceeds ${MAX_PRESERVE_ITEM_CHARS} characters or ${MAX_PRESERVE_ITEM_BYTES} UTF-8 bytes`
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return void 0;
|
|
73
|
-
};
|
|
74
|
-
var encodeCompactionRequest = (request) => {
|
|
75
|
-
const boundsError = compactionRequestBoundsError(request);
|
|
76
|
-
if (boundsError) throw new Error(boundsError.message);
|
|
77
|
-
const payload = {
|
|
78
|
-
version: 1,
|
|
79
|
-
...request.instructions !== void 0 ? { instructions: request.instructions } : {},
|
|
80
|
-
...request.preserve !== void 0 ? { preserve: request.preserve } : {}
|
|
81
|
-
};
|
|
82
|
-
const encoded = `${FABRIC_COMPACTION_REQUEST_PREFIX}${JSON.stringify(payload)}`;
|
|
83
|
-
if (utf8Bytes(encoded) > MAX_TYPED_COMPACTION_SOURCE_BYTES) {
|
|
84
|
-
throw new Error(`typed compaction request exceeds ${MAX_TYPED_COMPACTION_SOURCE_BYTES} encoded UTF-8 bytes`);
|
|
85
|
-
}
|
|
86
|
-
return encoded;
|
|
87
|
-
};
|
|
88
|
-
var plainInstructions = (source) => {
|
|
89
|
-
const canonical = canonicalizeText(source);
|
|
90
|
-
return {
|
|
91
|
-
ok: true,
|
|
92
|
-
requestLines: canonical.text ? [canonical.text] : [],
|
|
93
|
-
policy: {
|
|
94
|
-
mode: "plain",
|
|
95
|
-
canonicalized: canonical.text !== source,
|
|
96
|
-
sourceBytes: canonical.sourceBytes,
|
|
97
|
-
truncated: canonical.truncated,
|
|
98
|
-
preserveCount: 0,
|
|
99
|
-
omittedPreserveCount: 0
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
var StrictJsonError = class extends Error {
|
|
104
|
-
constructor(code, message) {
|
|
105
|
-
super(message);
|
|
106
|
-
this.code = code;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var MAX_TYPED_JSON_DEPTH = 32;
|
|
110
|
-
var MAX_TYPED_JSON_NODES = 4096;
|
|
111
|
-
var StrictJsonParser = class {
|
|
112
|
-
constructor(source) {
|
|
113
|
-
this.source = source;
|
|
114
|
-
}
|
|
115
|
-
index = 0;
|
|
116
|
-
nodes = 0;
|
|
117
|
-
parse() {
|
|
118
|
-
this.skipWhitespace();
|
|
119
|
-
const value = this.parseValue(0);
|
|
120
|
-
this.skipWhitespace();
|
|
121
|
-
if (this.index !== this.source.length) this.malformed();
|
|
122
|
-
return value;
|
|
123
|
-
}
|
|
124
|
-
parseValue(depth) {
|
|
125
|
-
if (depth > MAX_TYPED_JSON_DEPTH) {
|
|
126
|
-
throw new StrictJsonError("structure-too-complex", "typed compaction JSON exceeds the structural depth limit");
|
|
127
|
-
}
|
|
128
|
-
this.nodes += 1;
|
|
129
|
-
if (this.nodes > MAX_TYPED_JSON_NODES) {
|
|
130
|
-
throw new StrictJsonError("structure-too-complex", "typed compaction JSON exceeds the structural node limit");
|
|
131
|
-
}
|
|
132
|
-
const character = this.source[this.index];
|
|
133
|
-
if (character === "{") return this.parseObject(depth + 1);
|
|
134
|
-
if (character === "[") return this.parseArray(depth + 1);
|
|
135
|
-
if (character === '"') return this.parseString();
|
|
136
|
-
if (character === "t") return this.parseLiteral("true", true);
|
|
137
|
-
if (character === "f") return this.parseLiteral("false", false);
|
|
138
|
-
if (character === "n") return this.parseLiteral("null", null);
|
|
139
|
-
if (character === "-" || character !== void 0 && character >= "0" && character <= "9") {
|
|
140
|
-
return this.parseNumber();
|
|
141
|
-
}
|
|
142
|
-
return this.malformed();
|
|
143
|
-
}
|
|
144
|
-
parseObject(depth) {
|
|
145
|
-
this.index += 1;
|
|
146
|
-
this.skipWhitespace();
|
|
147
|
-
const output = /* @__PURE__ */ Object.create(null);
|
|
148
|
-
const keys = /* @__PURE__ */ new Set();
|
|
149
|
-
if (this.source[this.index] === "}") {
|
|
150
|
-
this.index += 1;
|
|
151
|
-
return output;
|
|
152
|
-
}
|
|
153
|
-
while (this.index < this.source.length) {
|
|
154
|
-
if (this.source[this.index] !== '"') this.malformed();
|
|
155
|
-
const key = this.parseString();
|
|
156
|
-
if (keys.has(key)) {
|
|
157
|
-
throw new StrictJsonError("duplicate-field", `typed compaction request contains duplicate field ${JSON.stringify(key)}`);
|
|
158
|
-
}
|
|
159
|
-
keys.add(key);
|
|
160
|
-
this.skipWhitespace();
|
|
161
|
-
if (this.source[this.index] !== ":") this.malformed();
|
|
162
|
-
this.index += 1;
|
|
163
|
-
this.skipWhitespace();
|
|
164
|
-
output[key] = this.parseValue(depth);
|
|
165
|
-
this.skipWhitespace();
|
|
166
|
-
const delimiter = this.source[this.index];
|
|
167
|
-
if (delimiter === "}") {
|
|
168
|
-
this.index += 1;
|
|
169
|
-
return output;
|
|
170
|
-
}
|
|
171
|
-
if (delimiter !== ",") this.malformed();
|
|
172
|
-
this.index += 1;
|
|
173
|
-
this.skipWhitespace();
|
|
174
|
-
}
|
|
175
|
-
return this.malformed();
|
|
176
|
-
}
|
|
177
|
-
parseArray(depth) {
|
|
178
|
-
this.index += 1;
|
|
179
|
-
this.skipWhitespace();
|
|
180
|
-
const output = [];
|
|
181
|
-
if (this.source[this.index] === "]") {
|
|
182
|
-
this.index += 1;
|
|
183
|
-
return output;
|
|
184
|
-
}
|
|
185
|
-
while (this.index < this.source.length) {
|
|
186
|
-
output.push(this.parseValue(depth));
|
|
187
|
-
this.skipWhitespace();
|
|
188
|
-
const delimiter = this.source[this.index];
|
|
189
|
-
if (delimiter === "]") {
|
|
190
|
-
this.index += 1;
|
|
191
|
-
return output;
|
|
192
|
-
}
|
|
193
|
-
if (delimiter !== ",") this.malformed();
|
|
194
|
-
this.index += 1;
|
|
195
|
-
this.skipWhitespace();
|
|
196
|
-
}
|
|
197
|
-
return this.malformed();
|
|
198
|
-
}
|
|
199
|
-
parseString() {
|
|
200
|
-
this.index += 1;
|
|
201
|
-
let output = "";
|
|
202
|
-
while (this.index < this.source.length) {
|
|
203
|
-
const unit = this.source.charCodeAt(this.index);
|
|
204
|
-
if (unit === 34) {
|
|
205
|
-
this.index += 1;
|
|
206
|
-
if (!hasPairedSurrogates(output)) {
|
|
207
|
-
throw new StrictJsonError("invalid-unicode", "typed compaction JSON string contains an unpaired UTF-16 surrogate");
|
|
208
|
-
}
|
|
209
|
-
return output;
|
|
210
|
-
}
|
|
211
|
-
if (unit <= 31) this.malformed();
|
|
212
|
-
if (unit !== 92) {
|
|
213
|
-
output += this.source[this.index];
|
|
214
|
-
this.index += 1;
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
this.index += 1;
|
|
218
|
-
const escape = this.source[this.index];
|
|
219
|
-
this.index += 1;
|
|
220
|
-
if (escape === '"' || escape === "\\" || escape === "/") output += escape;
|
|
221
|
-
else if (escape === "b") output += "\b";
|
|
222
|
-
else if (escape === "f") output += "\f";
|
|
223
|
-
else if (escape === "n") output += "\n";
|
|
224
|
-
else if (escape === "r") output += "\r";
|
|
225
|
-
else if (escape === "t") output += " ";
|
|
226
|
-
else if (escape === "u") {
|
|
227
|
-
let value = 0;
|
|
228
|
-
for (let offset = 0; offset < 4; offset++) {
|
|
229
|
-
const digit = this.hexValue(this.source.charCodeAt(this.index + offset));
|
|
230
|
-
if (digit < 0) this.malformed();
|
|
231
|
-
value = value * 16 + digit;
|
|
232
|
-
}
|
|
233
|
-
this.index += 4;
|
|
234
|
-
output += String.fromCharCode(value);
|
|
235
|
-
} else {
|
|
236
|
-
this.malformed();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return this.malformed();
|
|
240
|
-
}
|
|
241
|
-
parseNumber() {
|
|
242
|
-
const start = this.index;
|
|
243
|
-
if (this.source[this.index] === "-") this.index += 1;
|
|
244
|
-
if (this.source[this.index] === "0") {
|
|
245
|
-
this.index += 1;
|
|
246
|
-
if (this.isDigit(this.source.charCodeAt(this.index))) this.malformed();
|
|
247
|
-
} else {
|
|
248
|
-
if (!this.isDigitOneToNine(this.source.charCodeAt(this.index))) this.malformed();
|
|
249
|
-
while (this.isDigit(this.source.charCodeAt(this.index))) this.index += 1;
|
|
250
|
-
}
|
|
251
|
-
if (this.source[this.index] === ".") {
|
|
252
|
-
this.index += 1;
|
|
253
|
-
if (!this.isDigit(this.source.charCodeAt(this.index))) this.malformed();
|
|
254
|
-
while (this.isDigit(this.source.charCodeAt(this.index))) this.index += 1;
|
|
255
|
-
}
|
|
256
|
-
const exponent = this.source[this.index];
|
|
257
|
-
if (exponent === "e" || exponent === "E") {
|
|
258
|
-
this.index += 1;
|
|
259
|
-
const sign = this.source[this.index];
|
|
260
|
-
if (sign === "+" || sign === "-") this.index += 1;
|
|
261
|
-
if (!this.isDigit(this.source.charCodeAt(this.index))) this.malformed();
|
|
262
|
-
while (this.isDigit(this.source.charCodeAt(this.index))) this.index += 1;
|
|
263
|
-
}
|
|
264
|
-
const value = Number(this.source.slice(start, this.index));
|
|
265
|
-
if (!Number.isFinite(value)) this.malformed();
|
|
266
|
-
return value;
|
|
267
|
-
}
|
|
268
|
-
parseLiteral(literal, value) {
|
|
269
|
-
if (!this.source.startsWith(literal, this.index)) this.malformed();
|
|
270
|
-
this.index += literal.length;
|
|
271
|
-
return value;
|
|
272
|
-
}
|
|
273
|
-
skipWhitespace() {
|
|
274
|
-
while (this.index < this.source.length) {
|
|
275
|
-
const unit = this.source.charCodeAt(this.index);
|
|
276
|
-
if (unit !== 32 && unit !== 9 && unit !== 10 && unit !== 13) return;
|
|
277
|
-
this.index += 1;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
hexValue(unit) {
|
|
281
|
-
if (unit >= 48 && unit <= 57) return unit - 48;
|
|
282
|
-
if (unit >= 65 && unit <= 70) return unit - 65 + 10;
|
|
283
|
-
if (unit >= 97 && unit <= 102) return unit - 97 + 10;
|
|
284
|
-
return -1;
|
|
285
|
-
}
|
|
286
|
-
isDigit(unit) {
|
|
287
|
-
return unit >= 48 && unit <= 57;
|
|
288
|
-
}
|
|
289
|
-
isDigitOneToNine(unit) {
|
|
290
|
-
return unit >= 49 && unit <= 57;
|
|
291
|
-
}
|
|
292
|
-
malformed() {
|
|
293
|
-
throw new StrictJsonError("malformed-json", "typed compaction request contains malformed JSON");
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
var decodeCompactionInstructions = (source) => {
|
|
297
|
-
if (source === void 0 || source === "") {
|
|
298
|
-
return {
|
|
299
|
-
ok: true,
|
|
300
|
-
requestLines: [],
|
|
301
|
-
policy: {
|
|
302
|
-
mode: "none",
|
|
303
|
-
canonicalized: false,
|
|
304
|
-
sourceBytes: 0,
|
|
305
|
-
truncated: false,
|
|
306
|
-
preserveCount: 0,
|
|
307
|
-
omittedPreserveCount: 0
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
if (!source.startsWith(FABRIC_COMPACTION_REQUEST_PREFIX)) return plainInstructions(source);
|
|
312
|
-
const encodedSourceBytes = utf8Bytes(source);
|
|
313
|
-
if (encodedSourceBytes > MAX_TYPED_COMPACTION_SOURCE_BYTES) {
|
|
314
|
-
return rejection(
|
|
315
|
-
"encoded-source-too-large",
|
|
316
|
-
`typed compaction request exceeds ${MAX_TYPED_COMPACTION_SOURCE_BYTES} encoded UTF-8 bytes`,
|
|
317
|
-
encodedSourceBytes
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
let parsed;
|
|
321
|
-
try {
|
|
322
|
-
parsed = new StrictJsonParser(source.slice(FABRIC_COMPACTION_REQUEST_PREFIX.length)).parse();
|
|
323
|
-
} catch (error) {
|
|
324
|
-
if (error instanceof StrictJsonError) {
|
|
325
|
-
return rejection(error.code, error.message, encodedSourceBytes);
|
|
326
|
-
}
|
|
327
|
-
return rejection("malformed-json", "typed compaction request contains malformed JSON", encodedSourceBytes);
|
|
328
|
-
}
|
|
329
|
-
if (!isRecord(parsed)) {
|
|
330
|
-
return rejection("invalid-object", "typed compaction request must be a JSON object", encodedSourceBytes);
|
|
331
|
-
}
|
|
332
|
-
const keys = Object.keys(parsed);
|
|
333
|
-
const unknownField = keys.find((key) => key !== "version" && key !== "instructions" && key !== "preserve");
|
|
334
|
-
if (unknownField !== void 0) {
|
|
335
|
-
return rejection("unknown-field", `typed compaction request contains unknown field ${JSON.stringify(unknownField)}`, encodedSourceBytes);
|
|
336
|
-
}
|
|
337
|
-
if (parsed.version !== 1) {
|
|
338
|
-
return rejection("unsupported-version", "typed compaction request version must be 1", encodedSourceBytes);
|
|
339
|
-
}
|
|
340
|
-
if (parsed.instructions !== void 0 && typeof parsed.instructions !== "string") {
|
|
341
|
-
return rejection("invalid-type", "typed compaction request instructions must be a string", encodedSourceBytes);
|
|
342
|
-
}
|
|
343
|
-
if (parsed.preserve !== void 0 && !Array.isArray(parsed.preserve)) {
|
|
344
|
-
return rejection("invalid-type", "typed compaction request preserve must be an array", encodedSourceBytes);
|
|
345
|
-
}
|
|
346
|
-
const preserve = parsed.preserve;
|
|
347
|
-
if (preserve !== void 0 && preserve.length > MAX_PRESERVE_ITEMS) {
|
|
348
|
-
return rejection(
|
|
349
|
-
"preserve-too-many",
|
|
350
|
-
`typed compaction preserve exceeds ${MAX_PRESERVE_ITEMS} items`,
|
|
351
|
-
encodedSourceBytes
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
if (preserve !== void 0 && !preserve.every((item) => typeof item === "string")) {
|
|
355
|
-
return rejection("invalid-type", "typed compaction preserve items must be strings", encodedSourceBytes);
|
|
356
|
-
}
|
|
357
|
-
const request = {
|
|
358
|
-
...parsed.instructions !== void 0 ? { instructions: parsed.instructions } : {},
|
|
359
|
-
...preserve !== void 0 ? { preserve } : {}
|
|
360
|
-
};
|
|
361
|
-
const boundsError = compactionRequestBoundsError(request);
|
|
362
|
-
if (boundsError) return rejection(boundsError.code, boundsError.message, encodedSourceBytes);
|
|
363
|
-
const requestLines = [];
|
|
364
|
-
let valueSourceBytes = 0;
|
|
365
|
-
let truncated = false;
|
|
366
|
-
let canonicalized = false;
|
|
367
|
-
if (request.instructions !== void 0) {
|
|
368
|
-
const instructions = canonicalizeText(request.instructions, MAX_COMPACTION_INSTRUCTIONS_BYTES);
|
|
369
|
-
valueSourceBytes += instructions.sourceBytes;
|
|
370
|
-
truncated ||= instructions.truncated;
|
|
371
|
-
canonicalized ||= instructions.text !== request.instructions;
|
|
372
|
-
if (instructions.text) requestLines.push(instructions.text);
|
|
373
|
-
}
|
|
374
|
-
for (let index = 0; index < (request.preserve?.length ?? 0); index++) {
|
|
375
|
-
const sourceItem = request.preserve[index];
|
|
376
|
-
const item = canonicalizeText(sourceItem, MAX_PRESERVE_ITEM_BYTES);
|
|
377
|
-
valueSourceBytes += item.sourceBytes;
|
|
378
|
-
truncated ||= item.truncated;
|
|
379
|
-
canonicalized ||= item.text !== sourceItem;
|
|
380
|
-
if (item.text) requestLines.push(`- ${item.text} [preserve:${index}]`);
|
|
381
|
-
}
|
|
382
|
-
return {
|
|
383
|
-
ok: true,
|
|
384
|
-
requestLines,
|
|
385
|
-
policy: {
|
|
386
|
-
mode: "typed-v1",
|
|
387
|
-
canonicalized,
|
|
388
|
-
sourceBytes: valueSourceBytes,
|
|
389
|
-
truncated,
|
|
390
|
-
preserveCount: request.preserve?.length ?? 0,
|
|
391
|
-
omittedPreserveCount: 0
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
// src/compaction/render.ts
|
|
397
|
-
var SECTION_ORDER = [
|
|
398
|
-
{ key: "goal", header: "[Session Goal]", maxBytes: 4096 },
|
|
399
|
-
{ key: "files", header: "[Files And Changes]", maxBytes: 4608 },
|
|
400
|
-
{ key: "activity", header: "[Fabric Activity]", maxBytes: 2048 },
|
|
401
|
-
{ key: "outstanding", header: "[Outstanding Context]", maxBytes: 4608 },
|
|
402
|
-
{ key: "earlierTurns", header: "[Earlier Turns]", maxBytes: 3072 },
|
|
403
|
-
{ key: "status", header: "[Current Status]", maxBytes: 2048 }
|
|
404
|
-
];
|
|
405
|
-
var REQUEST_MAX_BYTES = 3072;
|
|
406
|
-
var TRANSCRIPT_MAX_BYTES = 5120;
|
|
407
|
-
var FOOTER_MAX_BYTES = 1536;
|
|
408
|
-
var MAX_INPUT_LINES_PER_SECTION = 128;
|
|
409
|
-
var MAX_RENDERED_LINE_BYTES = 1024;
|
|
410
|
-
var LCM_RECOVERY_POINTER = "For exact pre-summary history, use memory.recall on this range, then memory.expand by stable entry or operation address.";
|
|
411
|
-
var POINTER_LINE = LCM_RECOVERY_POINTER;
|
|
412
|
-
var sampledLines = (lines, keep) => {
|
|
413
|
-
if (lines.length <= keep) return [...lines];
|
|
414
|
-
const earliest = Math.ceil(keep / 2);
|
|
415
|
-
const latest = Math.floor(keep / 2);
|
|
416
|
-
return [
|
|
417
|
-
...lines.slice(0, earliest),
|
|
418
|
-
`\u2026 omitted ${lines.length - keep} rendered lines`,
|
|
419
|
-
...lines.slice(lines.length - latest)
|
|
420
|
-
];
|
|
421
|
-
};
|
|
422
|
-
var boundedBlock = (header, sourceLines, maxBytes) => {
|
|
423
|
-
const clipped = sourceLines.map((line) => clipUtf8(line, MAX_RENDERED_LINE_BYTES));
|
|
424
|
-
const capped = sampledLines(clipped, Math.min(clipped.length, MAX_INPUT_LINES_PER_SECTION));
|
|
425
|
-
for (let keep = capped.length; keep >= 0; keep--) {
|
|
426
|
-
const lines = sampledLines(capped, keep);
|
|
427
|
-
const block = [header, ...lines].join("\n");
|
|
428
|
-
if (utf8Bytes(block) <= maxBytes) return block;
|
|
429
|
-
}
|
|
430
|
-
return clipUtf8(header, maxBytes);
|
|
431
|
-
};
|
|
432
|
-
var renderSummary = (sections, options) => {
|
|
433
|
-
const blocks = [];
|
|
434
|
-
for (const { key, header, maxBytes } of SECTION_ORDER) {
|
|
435
|
-
const lines = sections[key];
|
|
436
|
-
if (lines.length === 0) continue;
|
|
437
|
-
blocks.push(boundedBlock(header, lines, maxBytes));
|
|
438
|
-
if (key === "goal" && options.requestLines && options.requestLines.length > 0) {
|
|
439
|
-
blocks.push(boundedBlock("[Compaction Request]", options.requestLines, REQUEST_MAX_BYTES));
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
if (sections.goal.length === 0 && options.requestLines && options.requestLines.length > 0) {
|
|
443
|
-
blocks.unshift(boundedBlock("[Compaction Request]", options.requestLines, REQUEST_MAX_BYTES));
|
|
444
|
-
}
|
|
445
|
-
if (sections.transcript.length > 0) {
|
|
446
|
-
blocks.push(boundedBlock("---", sections.transcript, TRANSCRIPT_MAX_BYTES));
|
|
447
|
-
}
|
|
448
|
-
const timestamp = options.lastTimestamp || "(unknown time)";
|
|
449
|
-
const range = options.firstEntryId || options.lastEntryId ? `${options.firstEntryId || "(start)"} \u2192 ${options.lastEntryId || "(end)"}` : "(no entries)";
|
|
450
|
-
const footer = options.summaryKind === "branch" ? `[branch summarized ${timestamp}; structural source entries ${range}]` : `[compacted ${timestamp}; cumulative source entries ${range}]`;
|
|
451
|
-
blocks.push(boundedBlock("---", [footer, POINTER_LINE], FOOTER_MAX_BYTES));
|
|
452
|
-
const summary = `${blocks.join("\n\n")}
|
|
453
|
-
`;
|
|
454
|
-
if (utf8Bytes(summary) <= MAX_SUMMARY_BYTES) return summary;
|
|
455
|
-
return `${clipUtf8(summary, MAX_SUMMARY_BYTES - 1, "")}
|
|
456
|
-
`;
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
export {
|
|
460
|
-
MAX_COMPACTION_INSTRUCTIONS_CHARS,
|
|
461
|
-
MAX_PRESERVE_ITEMS,
|
|
462
|
-
MAX_PRESERVE_ITEM_CHARS,
|
|
463
|
-
compactionRequestBoundsError,
|
|
464
|
-
encodeCompactionRequest,
|
|
465
|
-
decodeCompactionInstructions,
|
|
466
|
-
LCM_RECOVERY_POINTER,
|
|
467
|
-
renderSummary
|
|
468
|
-
};
|
|
469
|
-
//# sourceMappingURL=chunk-QSRTEINF.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/compaction/instructions.ts", "../../src/compaction/render.ts"],
|
|
4
|
-
"sourcesContent": ["import { canonicalizeText, utf8Bytes } from \"./bounds.js\";\n\nexport const FABRIC_COMPACTION_REQUEST_PREFIX = \"__omp_fabric_compact_request_v1__:\";\nexport const MAX_COMPACTION_INSTRUCTIONS_CHARS = 8 * 1024;\nconst MAX_COMPACTION_INSTRUCTIONS_BYTES = 8 * 1024;\nexport const MAX_PRESERVE_ITEMS = 16;\nexport const MAX_PRESERVE_ITEM_CHARS = 2 * 1024;\nconst MAX_PRESERVE_ITEM_BYTES = 2 * 1024;\nexport const MAX_TYPED_COMPACTION_SOURCE_BYTES = 16 * 1024;\n\nexport interface TypedCompactionRequest {\n version: 1;\n instructions?: string;\n preserve?: string[];\n}\n\nexport interface CompactionInstructionPolicy {\n mode: \"none\" | \"plain\" | \"typed-v1\";\n canonicalized: boolean;\n sourceBytes: number;\n truncated: boolean;\n preserveCount: number;\n omittedPreserveCount: number;\n}\n\ntype CompactionInstructionErrorCode =\n | \"encoded-source-too-large\"\n | \"malformed-json\"\n | \"duplicate-field\"\n | \"invalid-unicode\"\n | \"structure-too-complex\"\n | \"invalid-object\"\n | \"unknown-field\"\n | \"unsupported-version\"\n | \"invalid-type\"\n | \"instructions-too-large\"\n | \"preserve-too-many\"\n | \"preserve-item-too-large\";\n\nexport interface CompactionInstructionDecodeError {\n code: CompactionInstructionErrorCode;\n message: string;\n sourceBytes: number;\n}\n\nexport type DecodedCompactionInstructions =\n | {\n ok: true;\n requestLines: string[];\n policy: CompactionInstructionPolicy;\n }\n | {\n ok: false;\n requestLines: [];\n error: CompactionInstructionDecodeError;\n };\n\nconst rejection = (\n code: CompactionInstructionErrorCode,\n message: string,\n sourceBytes: number,\n): DecodedCompactionInstructions => ({\n ok: false,\n requestLines: [],\n error: { code, message, sourceBytes },\n});\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nconst hasPairedSurrogates = (value: string): boolean => {\n for (let index = 0; index < value.length; index++) {\n const unit = value.charCodeAt(index);\n if (unit >= 0xd800 && unit <= 0xdbff) {\n const next = value.charCodeAt(index + 1);\n if (!(next >= 0xdc00 && next <= 0xdfff)) return false;\n index += 1;\n } else if (unit >= 0xdc00 && unit <= 0xdfff) {\n return false;\n }\n }\n return true;\n};\n\nexport const compactionRequestBoundsError = (\n request: Omit<TypedCompactionRequest, \"version\">,\n): Omit<CompactionInstructionDecodeError, \"sourceBytes\"> | undefined => {\n if (request.instructions !== undefined) {\n if (!hasPairedSurrogates(request.instructions)) {\n return {\n code: \"invalid-unicode\",\n message: \"typed compaction instructions contain an unpaired UTF-16 surrogate\",\n };\n }\n if (request.instructions.length > MAX_COMPACTION_INSTRUCTIONS_CHARS\n || utf8Bytes(request.instructions) > MAX_COMPACTION_INSTRUCTIONS_BYTES) {\n return {\n code: \"instructions-too-large\",\n message: `typed compaction instructions exceed ${MAX_COMPACTION_INSTRUCTIONS_CHARS} characters or ${MAX_COMPACTION_INSTRUCTIONS_BYTES} UTF-8 bytes`,\n };\n }\n }\n if (request.preserve !== undefined) {\n if (request.preserve.length > MAX_PRESERVE_ITEMS) {\n return {\n code: \"preserve-too-many\",\n message: `typed compaction preserve exceeds ${MAX_PRESERVE_ITEMS} items`,\n };\n }\n for (const item of request.preserve) {\n if (!hasPairedSurrogates(item)) {\n return {\n code: \"invalid-unicode\",\n message: \"typed compaction preserve item contains an unpaired UTF-16 surrogate\",\n };\n }\n if (item.length > MAX_PRESERVE_ITEM_CHARS || utf8Bytes(item) > MAX_PRESERVE_ITEM_BYTES) {\n return {\n code: \"preserve-item-too-large\",\n message: `typed compaction preserve item exceeds ${MAX_PRESERVE_ITEM_CHARS} characters or ${MAX_PRESERVE_ITEM_BYTES} UTF-8 bytes`,\n };\n }\n }\n }\n return undefined;\n};\n\nexport const encodeCompactionRequest = (request: Omit<TypedCompactionRequest, \"version\">): string => {\n const boundsError = compactionRequestBoundsError(request);\n if (boundsError) throw new Error(boundsError.message);\n const payload: TypedCompactionRequest = {\n version: 1,\n ...(request.instructions !== undefined ? { instructions: request.instructions } : {}),\n ...(request.preserve !== undefined ? { preserve: request.preserve } : {}),\n };\n const encoded = `${FABRIC_COMPACTION_REQUEST_PREFIX}${JSON.stringify(payload)}`;\n if (utf8Bytes(encoded) > MAX_TYPED_COMPACTION_SOURCE_BYTES) {\n throw new Error(`typed compaction request exceeds ${MAX_TYPED_COMPACTION_SOURCE_BYTES} encoded UTF-8 bytes`);\n }\n return encoded;\n};\n\nconst plainInstructions = (source: string): DecodedCompactionInstructions => {\n const canonical = canonicalizeText(source);\n return {\n ok: true,\n requestLines: canonical.text ? [canonical.text] : [],\n policy: {\n mode: \"plain\",\n canonicalized: canonical.text !== source,\n sourceBytes: canonical.sourceBytes,\n truncated: canonical.truncated,\n preserveCount: 0,\n omittedPreserveCount: 0,\n },\n };\n};\n\nclass StrictJsonError extends Error {\n constructor(\n readonly code: \"malformed-json\" | \"duplicate-field\" | \"invalid-unicode\" | \"structure-too-complex\",\n message: string,\n ) {\n super(message);\n }\n}\n\nconst MAX_TYPED_JSON_DEPTH = 32;\nconst MAX_TYPED_JSON_NODES = 4096;\n\nclass StrictJsonParser {\n private index = 0;\n private nodes = 0;\n\n constructor(private readonly source: string) {}\n\n parse(): unknown {\n this.skipWhitespace();\n const value = this.parseValue(0);\n this.skipWhitespace();\n if (this.index !== this.source.length) this.malformed();\n return value;\n }\n\n private parseValue(depth: number): unknown {\n if (depth > MAX_TYPED_JSON_DEPTH) {\n throw new StrictJsonError(\"structure-too-complex\", \"typed compaction JSON exceeds the structural depth limit\");\n }\n this.nodes += 1;\n if (this.nodes > MAX_TYPED_JSON_NODES) {\n throw new StrictJsonError(\"structure-too-complex\", \"typed compaction JSON exceeds the structural node limit\");\n }\n const character = this.source[this.index];\n if (character === \"{\") return this.parseObject(depth + 1);\n if (character === \"[\") return this.parseArray(depth + 1);\n if (character === \"\\\"\") return this.parseString();\n if (character === \"t\") return this.parseLiteral(\"true\", true);\n if (character === \"f\") return this.parseLiteral(\"false\", false);\n if (character === \"n\") return this.parseLiteral(\"null\", null);\n if (character === \"-\" || (character !== undefined && character >= \"0\" && character <= \"9\")) {\n return this.parseNumber();\n }\n return this.malformed();\n }\n\n private parseObject(depth: number): Record<string, unknown> {\n this.index += 1;\n this.skipWhitespace();\n const output = Object.create(null) as Record<string, unknown>;\n const keys = new Set<string>();\n if (this.source[this.index] === \"}\") {\n this.index += 1;\n return output;\n }\n while (this.index < this.source.length) {\n if (this.source[this.index] !== \"\\\"\") this.malformed();\n const key = this.parseString();\n if (keys.has(key)) {\n throw new StrictJsonError(\"duplicate-field\", `typed compaction request contains duplicate field ${JSON.stringify(key)}`);\n }\n keys.add(key);\n this.skipWhitespace();\n if (this.source[this.index] !== \":\") this.malformed();\n this.index += 1;\n this.skipWhitespace();\n output[key] = this.parseValue(depth);\n this.skipWhitespace();\n const delimiter = this.source[this.index];\n if (delimiter === \"}\") {\n this.index += 1;\n return output;\n }\n if (delimiter !== \",\") this.malformed();\n this.index += 1;\n this.skipWhitespace();\n }\n return this.malformed();\n }\n\n private parseArray(depth: number): unknown[] {\n this.index += 1;\n this.skipWhitespace();\n const output: unknown[] = [];\n if (this.source[this.index] === \"]\") {\n this.index += 1;\n return output;\n }\n while (this.index < this.source.length) {\n output.push(this.parseValue(depth));\n this.skipWhitespace();\n const delimiter = this.source[this.index];\n if (delimiter === \"]\") {\n this.index += 1;\n return output;\n }\n if (delimiter !== \",\") this.malformed();\n this.index += 1;\n this.skipWhitespace();\n }\n return this.malformed();\n }\n\n private parseString(): string {\n this.index += 1;\n let output = \"\";\n while (this.index < this.source.length) {\n const unit = this.source.charCodeAt(this.index);\n if (unit === 0x22) {\n this.index += 1;\n if (!hasPairedSurrogates(output)) {\n throw new StrictJsonError(\"invalid-unicode\", \"typed compaction JSON string contains an unpaired UTF-16 surrogate\");\n }\n return output;\n }\n if (unit <= 0x1f) this.malformed();\n if (unit !== 0x5c) {\n output += this.source[this.index]!;\n this.index += 1;\n continue;\n }\n this.index += 1;\n const escape = this.source[this.index];\n this.index += 1;\n if (escape === \"\\\"\" || escape === \"\\\\\" || escape === \"/\") output += escape;\n else if (escape === \"b\") output += \"\\b\";\n else if (escape === \"f\") output += \"\\f\";\n else if (escape === \"n\") output += \"\\n\";\n else if (escape === \"r\") output += \"\\r\";\n else if (escape === \"t\") output += \"\\t\";\n else if (escape === \"u\") {\n let value = 0;\n for (let offset = 0; offset < 4; offset++) {\n const digit = this.hexValue(this.source.charCodeAt(this.index + offset));\n if (digit < 0) this.malformed();\n value = value * 16 + digit;\n }\n this.index += 4;\n output += String.fromCharCode(value);\n } else {\n this.malformed();\n }\n }\n return this.malformed();\n }\n\n private parseNumber(): number {\n const start = this.index;\n if (this.source[this.index] === \"-\") this.index += 1;\n if (this.source[this.index] === \"0\") {\n this.index += 1;\n if (this.isDigit(this.source.charCodeAt(this.index))) this.malformed();\n } else {\n if (!this.isDigitOneToNine(this.source.charCodeAt(this.index))) this.malformed();\n while (this.isDigit(this.source.charCodeAt(this.index))) this.index += 1;\n }\n if (this.source[this.index] === \".\") {\n this.index += 1;\n if (!this.isDigit(this.source.charCodeAt(this.index))) this.malformed();\n while (this.isDigit(this.source.charCodeAt(this.index))) this.index += 1;\n }\n const exponent = this.source[this.index];\n if (exponent === \"e\" || exponent === \"E\") {\n this.index += 1;\n const sign = this.source[this.index];\n if (sign === \"+\" || sign === \"-\") this.index += 1;\n if (!this.isDigit(this.source.charCodeAt(this.index))) this.malformed();\n while (this.isDigit(this.source.charCodeAt(this.index))) this.index += 1;\n }\n const value = Number(this.source.slice(start, this.index));\n if (!Number.isFinite(value)) this.malformed();\n return value;\n }\n\n private parseLiteral<T>(literal: string, value: T): T {\n if (!this.source.startsWith(literal, this.index)) this.malformed();\n this.index += literal.length;\n return value;\n }\n\n private skipWhitespace(): void {\n while (this.index < this.source.length) {\n const unit = this.source.charCodeAt(this.index);\n if (unit !== 0x20 && unit !== 0x09 && unit !== 0x0a && unit !== 0x0d) return;\n this.index += 1;\n }\n }\n\n private hexValue(unit: number): number {\n if (unit >= 0x30 && unit <= 0x39) return unit - 0x30;\n if (unit >= 0x41 && unit <= 0x46) return unit - 0x41 + 10;\n if (unit >= 0x61 && unit <= 0x66) return unit - 0x61 + 10;\n return -1;\n }\n\n private isDigit(unit: number): boolean {\n return unit >= 0x30 && unit <= 0x39;\n }\n\n private isDigitOneToNine(unit: number): boolean {\n return unit >= 0x31 && unit <= 0x39;\n }\n\n private malformed(): never {\n throw new StrictJsonError(\"malformed-json\", \"typed compaction request contains malformed JSON\");\n }\n}\n\nexport const decodeCompactionInstructions = (\n source: string | undefined,\n): DecodedCompactionInstructions => {\n if (source === undefined || source === \"\") {\n return {\n ok: true,\n requestLines: [],\n policy: {\n mode: \"none\",\n canonicalized: false,\n sourceBytes: 0,\n truncated: false,\n preserveCount: 0,\n omittedPreserveCount: 0,\n },\n };\n }\n if (!source.startsWith(FABRIC_COMPACTION_REQUEST_PREFIX)) return plainInstructions(source);\n\n const encodedSourceBytes = utf8Bytes(source);\n if (encodedSourceBytes > MAX_TYPED_COMPACTION_SOURCE_BYTES) {\n return rejection(\n \"encoded-source-too-large\",\n `typed compaction request exceeds ${MAX_TYPED_COMPACTION_SOURCE_BYTES} encoded UTF-8 bytes`,\n encodedSourceBytes,\n );\n }\n\n let parsed: unknown;\n try {\n parsed = new StrictJsonParser(source.slice(FABRIC_COMPACTION_REQUEST_PREFIX.length)).parse();\n } catch (error) {\n if (error instanceof StrictJsonError) {\n return rejection(error.code, error.message, encodedSourceBytes);\n }\n return rejection(\"malformed-json\", \"typed compaction request contains malformed JSON\", encodedSourceBytes);\n }\n if (!isRecord(parsed)) {\n return rejection(\"invalid-object\", \"typed compaction request must be a JSON object\", encodedSourceBytes);\n }\n\n const keys = Object.keys(parsed);\n const unknownField = keys.find((key) => key !== \"version\" && key !== \"instructions\" && key !== \"preserve\");\n if (unknownField !== undefined) {\n return rejection(\"unknown-field\", `typed compaction request contains unknown field ${JSON.stringify(unknownField)}`, encodedSourceBytes);\n }\n if (parsed.version !== 1) {\n return rejection(\"unsupported-version\", \"typed compaction request version must be 1\", encodedSourceBytes);\n }\n if (parsed.instructions !== undefined && typeof parsed.instructions !== \"string\") {\n return rejection(\"invalid-type\", \"typed compaction request instructions must be a string\", encodedSourceBytes);\n }\n if (parsed.preserve !== undefined && !Array.isArray(parsed.preserve)) {\n return rejection(\"invalid-type\", \"typed compaction request preserve must be an array\", encodedSourceBytes);\n }\n\n const preserve = parsed.preserve as unknown[] | undefined;\n if (preserve !== undefined && preserve.length > MAX_PRESERVE_ITEMS) {\n return rejection(\n \"preserve-too-many\",\n `typed compaction preserve exceeds ${MAX_PRESERVE_ITEMS} items`,\n encodedSourceBytes,\n );\n }\n if (preserve !== undefined && !preserve.every((item) => typeof item === \"string\")) {\n return rejection(\"invalid-type\", \"typed compaction preserve items must be strings\", encodedSourceBytes);\n }\n\n const request: Omit<TypedCompactionRequest, \"version\"> = {\n ...(parsed.instructions !== undefined ? { instructions: parsed.instructions } : {}),\n ...(preserve !== undefined ? { preserve: preserve as string[] } : {}),\n };\n const boundsError = compactionRequestBoundsError(request);\n if (boundsError) return rejection(boundsError.code, boundsError.message, encodedSourceBytes);\n\n const requestLines: string[] = [];\n let valueSourceBytes = 0;\n let truncated = false;\n let canonicalized = false;\n if (request.instructions !== undefined) {\n const instructions = canonicalizeText(request.instructions, MAX_COMPACTION_INSTRUCTIONS_BYTES);\n valueSourceBytes += instructions.sourceBytes;\n truncated ||= instructions.truncated;\n canonicalized ||= instructions.text !== request.instructions;\n if (instructions.text) requestLines.push(instructions.text);\n }\n\n for (let index = 0; index < (request.preserve?.length ?? 0); index++) {\n const sourceItem = request.preserve![index]!;\n const item = canonicalizeText(sourceItem, MAX_PRESERVE_ITEM_BYTES);\n valueSourceBytes += item.sourceBytes;\n truncated ||= item.truncated;\n canonicalized ||= item.text !== sourceItem;\n if (item.text) requestLines.push(`- ${item.text} [preserve:${index}]`);\n }\n\n return {\n ok: true,\n requestLines,\n policy: {\n mode: \"typed-v1\",\n canonicalized,\n sourceBytes: valueSourceBytes,\n truncated,\n preserveCount: request.preserve?.length ?? 0,\n omittedPreserveCount: 0,\n },\n };\n};\n", "import { clipUtf8, MAX_SUMMARY_BYTES, utf8Bytes } from \"./bounds.js\";\nimport type { Sections } from \"./projections.js\";\n\nconst SECTION_ORDER: { key: keyof Sections; header: string; maxBytes: number }[] = [\n { key: \"goal\", header: \"[Session Goal]\", maxBytes: 4096 },\n { key: \"files\", header: \"[Files And Changes]\", maxBytes: 4608 },\n { key: \"activity\", header: \"[Fabric Activity]\", maxBytes: 2048 },\n { key: \"outstanding\", header: \"[Outstanding Context]\", maxBytes: 4608 },\n { key: \"earlierTurns\", header: \"[Earlier Turns]\", maxBytes: 3072 },\n { key: \"status\", header: \"[Current Status]\", maxBytes: 2048 },\n];\n\nconst REQUEST_MAX_BYTES = 3072;\nconst TRANSCRIPT_MAX_BYTES = 5120;\nconst FOOTER_MAX_BYTES = 1536;\nconst MAX_INPUT_LINES_PER_SECTION = 128;\nconst MAX_RENDERED_LINE_BYTES = 1024;\n\nexport interface RenderOptions {\n firstEntryId: string;\n lastEntryId: string;\n lastTimestamp: string;\n requestLines?: string[];\n summaryKind?: \"compaction\" | \"branch\";\n}\n\nexport const LCM_RECOVERY_POINTER =\n \"For exact pre-summary history, use memory.recall on this range, then memory.expand by stable entry or operation address.\";\nconst POINTER_LINE = LCM_RECOVERY_POINTER;\n\nconst sampledLines = (lines: readonly string[], keep: number): string[] => {\n if (lines.length <= keep) return [...lines];\n const earliest = Math.ceil(keep / 2);\n const latest = Math.floor(keep / 2);\n return [\n ...lines.slice(0, earliest),\n `\u2026 omitted ${lines.length - keep} rendered lines`,\n ...lines.slice(lines.length - latest),\n ];\n};\n\nconst boundedBlock = (header: string, sourceLines: readonly string[], maxBytes: number): string => {\n const clipped = sourceLines.map((line) => clipUtf8(line, MAX_RENDERED_LINE_BYTES));\n const capped = sampledLines(clipped, Math.min(clipped.length, MAX_INPUT_LINES_PER_SECTION));\n for (let keep = capped.length; keep >= 0; keep--) {\n const lines = sampledLines(capped, keep);\n const block = [header, ...lines].join(\"\\n\");\n if (utf8Bytes(block) <= maxBytes) return block;\n }\n return clipUtf8(header, maxBytes);\n};\n\nexport const renderSummary = (sections: Sections, options: RenderOptions): string => {\n const blocks: string[] = [];\n for (const { key, header, maxBytes } of SECTION_ORDER) {\n const lines = sections[key];\n if (lines.length === 0) continue;\n blocks.push(boundedBlock(header, lines, maxBytes));\n if (key === \"goal\" && options.requestLines && options.requestLines.length > 0) {\n blocks.push(boundedBlock(\"[Compaction Request]\", options.requestLines, REQUEST_MAX_BYTES));\n }\n }\n if (sections.goal.length === 0 && options.requestLines && options.requestLines.length > 0) {\n blocks.unshift(boundedBlock(\"[Compaction Request]\", options.requestLines, REQUEST_MAX_BYTES));\n }\n\n if (sections.transcript.length > 0) {\n blocks.push(boundedBlock(\"---\", sections.transcript, TRANSCRIPT_MAX_BYTES));\n }\n\n const timestamp = options.lastTimestamp || \"(unknown time)\";\n const range = options.firstEntryId || options.lastEntryId\n ? `${options.firstEntryId || \"(start)\"} \u2192 ${options.lastEntryId || \"(end)\"}`\n : \"(no entries)\";\n const footer = options.summaryKind === \"branch\"\n ? `[branch summarized ${timestamp}; structural source entries ${range}]`\n : `[compacted ${timestamp}; cumulative source entries ${range}]`;\n blocks.push(boundedBlock(\"---\", [footer, POINTER_LINE], FOOTER_MAX_BYTES));\n\n const summary = `${blocks.join(\"\\n\\n\")}\\n`;\n if (utf8Bytes(summary) <= MAX_SUMMARY_BYTES) return summary;\n return `${clipUtf8(summary, MAX_SUMMARY_BYTES - 1, \"\")}\\n`;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAEO,IAAM,mCAAmC;AACzC,IAAM,oCAAoC,IAAI;AACrD,IAAM,oCAAoC,IAAI;AACvC,IAAM,qBAAqB;AAC3B,IAAM,0BAA0B,IAAI;AAC3C,IAAM,0BAA0B,IAAI;AAC7B,IAAM,oCAAoC,KAAK;AAiDtD,IAAM,YAAY,CAChB,MACA,SACA,iBACmC;AAAA,EACnC,IAAI;AAAA,EACJ,cAAc,CAAC;AAAA,EACf,OAAO,EAAE,MAAM,SAAS,YAAY;AACtC;AAEA,IAAM,WAAW,CAAC,UAChB,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAErE,IAAM,sBAAsB,CAAC,UAA2B;AACtD,WAAS,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;AACjD,UAAM,OAAO,MAAM,WAAW,KAAK;AACnC,QAAI,QAAQ,SAAU,QAAQ,OAAQ;AACpC,YAAM,OAAO,MAAM,WAAW,QAAQ,CAAC;AACvC,UAAI,EAAE,QAAQ,SAAU,QAAQ,OAAS,QAAO;AAChD,eAAS;AAAA,IACX,WAAW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