pi-fabric 0.53.1 → 0.54.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/dist/chunks/{chunk-WXY7GS3P.js → chunk-EGNEZYFZ.js} +2 -2
- package/dist/chunks/{chunk-Y5PP5IBY.js → chunk-V4J3TRB2.js} +228 -2
- package/dist/chunks/chunk-V4J3TRB2.js.map +7 -0
- package/dist/chunks/{chunk-AZYZUP2Z.js → chunk-ZW446OQR.js} +19 -3
- package/dist/chunks/chunk-ZW446OQR.js.map +7 -0
- package/dist/chunks/{fabric-runtime-state-2MON7OB3.js → fabric-runtime-state-NYZMKR7Z.js} +27 -6
- package/dist/chunks/fabric-runtime-state-NYZMKR7Z.js.map +7 -0
- package/dist/chunks/{guest-types-ZJRRNSZH.js → guest-types-PEUDC6JY.js} +67 -21
- package/dist/chunks/guest-types-PEUDC6JY.js.map +7 -0
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +1 -1
- package/dist/index.js +3 -3
- package/dist/providers/agents-provider.d.ts +2 -0
- package/dist/providers/agents-provider.d.ts.map +1 -1
- package/dist/providers/arg-normalization.d.ts +12 -0
- package/dist/providers/arg-normalization.d.ts.map +1 -0
- package/dist/providers/compact-provider.d.ts +2 -0
- package/dist/providers/compact-provider.d.ts.map +1 -1
- package/dist/providers/memory-provider.d.ts +2 -0
- package/dist/providers/memory-provider.d.ts.map +1 -1
- package/dist/providers/memory-provider.js +5 -3
- package/dist/providers/mesh-provider.d.ts +2 -0
- package/dist/providers/mesh-provider.d.ts.map +1 -1
- package/dist/providers/schema-provider.d.ts +2 -0
- package/dist/providers/schema-provider.d.ts.map +1 -1
- package/dist/providers/state-provider.d.ts +2 -0
- package/dist/providers/state-provider.d.ts.map +1 -1
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/docs/component-calculus.md +30 -32
- package/docs/provider-component-calculus.md +135 -147
- package/package.json +1 -1
- package/skills/fabric-exec/SKILL.md +4 -0
- package/dist/chunks/chunk-AZYZUP2Z.js.map +0 -7
- package/dist/chunks/chunk-Y5PP5IBY.js.map +0 -7
- package/dist/chunks/fabric-runtime-state-2MON7OB3.js.map +0 -7
- package/dist/chunks/guest-types-ZJRRNSZH.js.map +0 -7
- /package/dist/chunks/{chunk-WXY7GS3P.js.map → chunk-EGNEZYFZ.js.map} +0 -0
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
NESTED_TOOL_CALL_ID_PREFIX,
|
|
18
18
|
stableJsonHash
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-ZW446OQR.js";
|
|
20
20
|
import {
|
|
21
21
|
runAbortable,
|
|
22
22
|
throwIfAborted
|
|
@@ -2349,4 +2349,4 @@ export {
|
|
|
2349
2349
|
resolveFabricIdentity,
|
|
2350
2350
|
MainAgentController
|
|
2351
2351
|
};
|
|
2352
|
-
//# sourceMappingURL=chunk-
|
|
2352
|
+
//# sourceMappingURL=chunk-EGNEZYFZ.js.map
|
|
@@ -23,6 +23,205 @@ import {
|
|
|
23
23
|
|
|
24
24
|
// src/providers/memory-provider.ts
|
|
25
25
|
import path from "node:path";
|
|
26
|
+
|
|
27
|
+
// src/providers/arg-normalization.ts
|
|
28
|
+
var normalizeForm = (key) => key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
29
|
+
var KEY_SYNONYM_CLASSES = [
|
|
30
|
+
["session", "sessionId", "id", "file", "path"],
|
|
31
|
+
["hypothesisId", "id"],
|
|
32
|
+
["id", "agentId", "actorId", "runId"],
|
|
33
|
+
["query", "q"],
|
|
34
|
+
["limit", "max", "pageSize"],
|
|
35
|
+
["task", "prompt", "instructions"],
|
|
36
|
+
["label", "labels", "name", "title"],
|
|
37
|
+
["summary", "description"],
|
|
38
|
+
["text", "message", "body"],
|
|
39
|
+
["check", "command", "cmd", "script", "predicate"],
|
|
40
|
+
["files", "paths"],
|
|
41
|
+
["ifVersion", "versionRef", "version"],
|
|
42
|
+
["indices", "index"]
|
|
43
|
+
];
|
|
44
|
+
var KEY_CLASS_FORMS = KEY_SYNONYM_CLASSES.map(
|
|
45
|
+
(cls) => new Set(cls.map(normalizeForm))
|
|
46
|
+
);
|
|
47
|
+
var ENUM_VALUE_CLASSES = [
|
|
48
|
+
["project", "cwd", "repo", "repository", "workspace", "checkout", "tree"],
|
|
49
|
+
["global", "all"],
|
|
50
|
+
["permanent", "pinned", "sticky", "durable"]
|
|
51
|
+
];
|
|
52
|
+
var VALUE_CLASS_FORMS = ENUM_VALUE_CLASSES.map(
|
|
53
|
+
(cls) => new Set(cls.map(normalizeForm))
|
|
54
|
+
);
|
|
55
|
+
var numericKind = (property) => {
|
|
56
|
+
if (!property || typeof property !== "object") return void 0;
|
|
57
|
+
const schema = property;
|
|
58
|
+
if (schema.type === "number" || schema.type === "integer") return "scalar";
|
|
59
|
+
if (schema.type === "array") {
|
|
60
|
+
const items = schema.items;
|
|
61
|
+
if (items && typeof items === "object" && (items.type === "number" || items.type === "integer")) {
|
|
62
|
+
return "array";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return void 0;
|
|
66
|
+
};
|
|
67
|
+
var stringEnumValues = (property) => {
|
|
68
|
+
if (!property || typeof property !== "object") return void 0;
|
|
69
|
+
const schema = property;
|
|
70
|
+
if (Array.isArray(schema.enum)) {
|
|
71
|
+
const values = schema.enum.filter(
|
|
72
|
+
(entry) => typeof entry === "string"
|
|
73
|
+
);
|
|
74
|
+
return values.length > 0 ? values : void 0;
|
|
75
|
+
}
|
|
76
|
+
for (const branch of [schema.oneOf, schema.anyOf]) {
|
|
77
|
+
if (!Array.isArray(branch)) continue;
|
|
78
|
+
const consts = branch.map(
|
|
79
|
+
(entry) => entry && typeof entry === "object" ? entry.const : void 0
|
|
80
|
+
).filter((entry) => typeof entry === "string");
|
|
81
|
+
if (consts.length > 0) return consts;
|
|
82
|
+
}
|
|
83
|
+
return void 0;
|
|
84
|
+
};
|
|
85
|
+
var deriveEnumValueMap = (values) => {
|
|
86
|
+
const map = /* @__PURE__ */ new Map();
|
|
87
|
+
const seen = /* @__PURE__ */ new Map();
|
|
88
|
+
for (const value of values) {
|
|
89
|
+
const form = normalizeForm(value);
|
|
90
|
+
seen.set(form, seen.has(form) ? void 0 : value);
|
|
91
|
+
}
|
|
92
|
+
for (const [form, value] of seen) if (value !== void 0) map.set(form, value);
|
|
93
|
+
for (const classForms of VALUE_CLASS_FORMS) {
|
|
94
|
+
const members = values.filter((value) => classForms.has(normalizeForm(value)));
|
|
95
|
+
if (members.length !== 1) continue;
|
|
96
|
+
const [hit] = members;
|
|
97
|
+
for (const form of classForms) {
|
|
98
|
+
if (form !== normalizeForm(hit) && !map.has(form)) map.set(form, hit);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return map;
|
|
102
|
+
};
|
|
103
|
+
var deriveAction = (inputSchema, explicit) => {
|
|
104
|
+
const properties = inputSchema && typeof inputSchema === "object" && inputSchema.properties && typeof inputSchema.properties === "object" ? inputSchema.properties : void 0;
|
|
105
|
+
const declared = new Set(Object.keys(properties ?? {}));
|
|
106
|
+
const declaredForms = /* @__PURE__ */ new Map();
|
|
107
|
+
const ambiguousForms = /* @__PURE__ */ new Set();
|
|
108
|
+
for (const key of declared) {
|
|
109
|
+
const form = normalizeForm(key);
|
|
110
|
+
if (declaredForms.has(form)) {
|
|
111
|
+
ambiguousForms.add(form);
|
|
112
|
+
declaredForms.delete(form);
|
|
113
|
+
} else if (!ambiguousForms.has(form)) {
|
|
114
|
+
declaredForms.set(form, key);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const singulars = /* @__PURE__ */ new Map();
|
|
118
|
+
for (const key of declared) {
|
|
119
|
+
const form = normalizeForm(key);
|
|
120
|
+
if (!form.endsWith("s")) continue;
|
|
121
|
+
const singular = form.slice(0, -1);
|
|
122
|
+
if (!singular || declaredForms.has(singular) || singular === form) continue;
|
|
123
|
+
if (singulars.get(singular) !== void 0) singulars.delete(singular);
|
|
124
|
+
else singulars.set(singular, key);
|
|
125
|
+
}
|
|
126
|
+
for (const form of ambiguousForms) singulars.delete(form);
|
|
127
|
+
const numerics = new Set(explicit?.numerics ?? []);
|
|
128
|
+
const numericArrays = new Set(explicit?.numericArrays ?? []);
|
|
129
|
+
const values = /* @__PURE__ */ new Map();
|
|
130
|
+
if (properties) {
|
|
131
|
+
for (const [key, property] of Object.entries(properties)) {
|
|
132
|
+
const kind = numericKind(property);
|
|
133
|
+
if (kind === "scalar") numerics.add(key);
|
|
134
|
+
else if (kind === "array") numericArrays.add(key);
|
|
135
|
+
const enumValues = stringEnumValues(property);
|
|
136
|
+
if (enumValues) values.set(key, new Map(deriveEnumValueMap(enumValues)));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
for (const [key, remaps] of Object.entries(explicit?.values ?? {})) {
|
|
140
|
+
const map = values.get(key) ?? /* @__PURE__ */ new Map();
|
|
141
|
+
for (const [spelling, target] of Object.entries(remaps)) {
|
|
142
|
+
map.set(normalizeForm(spelling), target);
|
|
143
|
+
}
|
|
144
|
+
values.set(key, map);
|
|
145
|
+
}
|
|
146
|
+
return { declared, declaredForms, singulars, numerics, numericArrays, values, aliases: explicit?.aliases };
|
|
147
|
+
};
|
|
148
|
+
var lexiconRepair = (form, declaredForms) => {
|
|
149
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
150
|
+
for (const classForms of KEY_CLASS_FORMS) {
|
|
151
|
+
if (!classForms.has(form)) continue;
|
|
152
|
+
for (const [declaredForm, declaredKey] of declaredForms) {
|
|
153
|
+
if (declaredForm !== form && classForms.has(declaredForm)) {
|
|
154
|
+
candidates.add(declaredKey);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return candidates.size === 1 ? [...candidates][0] : void 0;
|
|
159
|
+
};
|
|
160
|
+
var applyDerived = (args, derived) => {
|
|
161
|
+
const out = { ...args };
|
|
162
|
+
const repair = (alias, canonical) => {
|
|
163
|
+
if (!(alias in out) || alias === canonical) return;
|
|
164
|
+
if (!(canonical in out)) out[canonical] = out[alias];
|
|
165
|
+
delete out[alias];
|
|
166
|
+
};
|
|
167
|
+
for (const [alias, canonical] of Object.entries(derived.aliases ?? {})) {
|
|
168
|
+
repair(alias, canonical);
|
|
169
|
+
}
|
|
170
|
+
for (const key of [...Object.keys(out)]) {
|
|
171
|
+
if (derived.declared.has(key)) continue;
|
|
172
|
+
const form = normalizeForm(key);
|
|
173
|
+
const canonical = derived.declaredForms.get(form) ?? derived.singulars.get(form) ?? lexiconRepair(form, derived.declaredForms);
|
|
174
|
+
if (canonical && canonical !== key) repair(key, canonical);
|
|
175
|
+
}
|
|
176
|
+
for (const key of derived.numerics) {
|
|
177
|
+
const value = out[key];
|
|
178
|
+
if (typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value))) {
|
|
179
|
+
out[key] = Number(value);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
for (const key of derived.numericArrays) {
|
|
183
|
+
const value = out[key];
|
|
184
|
+
if (Array.isArray(value)) {
|
|
185
|
+
out[key] = value.map(
|
|
186
|
+
(entry) => typeof entry === "string" && entry.trim() !== "" && !Number.isNaN(Number(entry)) ? Number(entry) : entry
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
for (const [key, remaps] of derived.values) {
|
|
191
|
+
const value = out[key];
|
|
192
|
+
if (typeof value === "string") {
|
|
193
|
+
const next = remaps.get(normalizeForm(value));
|
|
194
|
+
if (next !== void 0) out[key] = next;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (derived.declared.size > 0) {
|
|
198
|
+
for (const key of Object.keys(out)) {
|
|
199
|
+
if (derived.declared.has(key) && (out[key] === null || out[key] === void 0)) {
|
|
200
|
+
delete out[key];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return out;
|
|
205
|
+
};
|
|
206
|
+
var actionArgNormalizer = (describeActions, table = {}) => {
|
|
207
|
+
const derived = /* @__PURE__ */ new Map();
|
|
208
|
+
for (const descriptor of describeActions()) {
|
|
209
|
+
derived.set(
|
|
210
|
+
descriptor.name,
|
|
211
|
+
deriveAction(
|
|
212
|
+
descriptor.inputSchema,
|
|
213
|
+
table[descriptor.name]
|
|
214
|
+
)
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
return (actionName, args) => {
|
|
218
|
+
if (!args || typeof args !== "object" || Array.isArray(args)) return args;
|
|
219
|
+
const action = derived.get(actionName);
|
|
220
|
+
return action ? applyDerived(args, action) : args;
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// src/providers/memory-provider.ts
|
|
26
225
|
var RECALL_DEFAULT_PAGE_SIZE = 25;
|
|
27
226
|
var RECALL_MAX_PAGE_SIZE = 200;
|
|
28
227
|
var SESSIONS_MAX = 500;
|
|
@@ -148,6 +347,11 @@ var descriptors = [
|
|
|
148
347
|
type: "string",
|
|
149
348
|
enum: ["active", "all"],
|
|
150
349
|
description: "Count the active parent-linked path (default) or every branch."
|
|
350
|
+
},
|
|
351
|
+
limit: {
|
|
352
|
+
type: "number",
|
|
353
|
+
minimum: 1,
|
|
354
|
+
description: "Maximum sessions returned; capped at the internal session ceiling."
|
|
151
355
|
}
|
|
152
356
|
},
|
|
153
357
|
additionalProperties: false
|
|
@@ -156,6 +360,22 @@ var descriptors = [
|
|
|
156
360
|
namespace: "memory"
|
|
157
361
|
}
|
|
158
362
|
];
|
|
363
|
+
var MEMORY_SCOPE_VALUE_ALIASES = {
|
|
364
|
+
cwd: "project",
|
|
365
|
+
repo: "project",
|
|
366
|
+
directory: "project",
|
|
367
|
+
folder: "project",
|
|
368
|
+
all: "global",
|
|
369
|
+
current: "session"
|
|
370
|
+
};
|
|
371
|
+
var MEMORY_ARG_NORMALIZATION = {
|
|
372
|
+
recall: { values: { scope: MEMORY_SCOPE_VALUE_ALIASES } },
|
|
373
|
+
sessions: { values: { scope: MEMORY_SCOPE_VALUE_ALIASES } }
|
|
374
|
+
};
|
|
375
|
+
var normalizeMemoryArgs = actionArgNormalizer(
|
|
376
|
+
() => descriptors,
|
|
377
|
+
MEMORY_ARG_NORMALIZATION
|
|
378
|
+
);
|
|
159
379
|
var parseBranches = (value, action) => {
|
|
160
380
|
if (value === void 0) return "active";
|
|
161
381
|
if (value === "active" || value === "all") return value;
|
|
@@ -230,6 +450,9 @@ var MemoryProvider = class {
|
|
|
230
450
|
async describe(actionName, _context) {
|
|
231
451
|
return descriptors.find((descriptor) => descriptor.name === actionName);
|
|
232
452
|
}
|
|
453
|
+
prepareArguments(actionName, args) {
|
|
454
|
+
return normalizeMemoryArgs(actionName, args);
|
|
455
|
+
}
|
|
233
456
|
async invoke(actionName, args, invocationContext) {
|
|
234
457
|
try {
|
|
235
458
|
switch (actionName) {
|
|
@@ -593,7 +816,8 @@ var MemoryProvider = class {
|
|
|
593
816
|
async sessions(args) {
|
|
594
817
|
const scope = typeof args.scope === "string" ? args.scope : void 0;
|
|
595
818
|
const branches = parseBranches(args.branches, "memory.sessions");
|
|
596
|
-
const
|
|
819
|
+
const limit = typeof args.limit === "number" && Number.isSafeInteger(args.limit) && args.limit >= 1 ? Math.min(args.limit, SESSIONS_MAX) : SESSIONS_MAX;
|
|
820
|
+
const refs = resolveRefs(scope, this.context, true).slice(0, limit);
|
|
597
821
|
const options = resolveIndexOptions(
|
|
598
822
|
this.context.config,
|
|
599
823
|
this.context.agentDir,
|
|
@@ -623,6 +847,8 @@ var MemoryProvider = class {
|
|
|
623
847
|
};
|
|
624
848
|
|
|
625
849
|
export {
|
|
850
|
+
actionArgNormalizer,
|
|
851
|
+
normalizeMemoryArgs,
|
|
626
852
|
MemoryProvider
|
|
627
853
|
};
|
|
628
|
-
//# sourceMappingURL=chunk-
|
|
854
|
+
//# sourceMappingURL=chunk-V4J3TRB2.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/providers/memory-provider.ts", "../../src/providers/arg-normalization.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n FabricActionDescriptor,\n FabricInvocationContext,\n FabricProvider,\n FabricProviderListRequest,\n} from \"../protocol.js\";\nimport type { FabricMemoryConfig } from \"../config.js\";\nimport path from \"node:path\";\nimport {\n AmbiguousSessionError,\n enumerateAllSessions,\n resolveScope,\n resolveSessionTarget,\n type ResolveScopeInput,\n type SessionRef,\n} from \"../memory/discovery.js\";\nimport type { LiveSessionBranch, MemoryBranches } from \"../memory/lineage.js\";\nimport { reconstructSessionLineage } from \"../memory/lineage.js\";\nimport { expandSessionEntriesChecked, normalizeSession } from \"../memory/normalize.js\";\nimport {\n DEFAULT_HOT_SESSIONS,\n fingerprintSource,\n loadTieredIndex,\n type EntryRange,\n type MemoryIndexOptions,\n type SearchFilters,\n} from \"../memory/index.js\";\nimport {\n DEFAULT_REGEX_MAX_HAYSTACK_BYTES,\n DEFAULT_REGEX_MAX_HAYSTACK_TERMS,\n DEFAULT_REGEX_MAX_PATTERN_BYTES,\n DEFAULT_REGEX_TIMEOUT_MS,\n formatSearchResult,\n searchMemoryIndex,\n type SearchItem,\n} from \"../memory/search.js\";\nimport type { MemoryQueryMode } from \"../memory/tokenize.js\";\nimport { actionArgNormalizer, type ArgNormalizationSpec } from \"./arg-normalization.js\";\n\nconst RECALL_DEFAULT_PAGE_SIZE = 25;\nconst RECALL_MAX_PAGE_SIZE = 200;\nconst SESSIONS_MAX = 500;\n\nconst descriptors: FabricActionDescriptor[] = [\n {\n name: \"recall\",\n description:\n \"Search hot session entries and cold session digests. Use scope session:<id-or-path> to hydrate a cold session and search its entries.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\" },\n queryMode: {\n type: \"string\",\n enum: [\"literal\", \"regex\"],\n description: \"Literal canonical-token matching (default) or explicitly bounded regex.\",\n },\n expectedSourceHash: {\n type: \"string\",\n description: \"SHA-256 from a prior pointer; stale sources are refused.\",\n },\n expectedLineageFingerprint: {\n type: \"string\",\n description: \"Active-lineage fingerprint from a prior pointer; changed leaves are refused.\",\n },\n branches: {\n type: \"string\",\n enum: [\"active\", \"all\"],\n description: \"Search the active parent-linked path (default) or every branch.\",\n },\n scope: {\n type: \"string\",\n description:\n \"session | project | global | session:<id-or-path>. Defaults to session.\",\n },\n page: { type: \"number\", minimum: 1 },\n pageSize: { type: \"number\", minimum: 1, maximum: RECALL_MAX_PAGE_SIZE },\n role: { type: \"string\" },\n tool: { type: \"string\" },\n ref: {\n type: \"string\",\n minLength: 1,\n description: \"Exact persisted Fabric action ref, such as pi.grep. This is structural selection, not lexical expansion.\",\n },\n provider: {\n type: \"string\",\n minLength: 1,\n description: \"Exact persisted Fabric provider identity.\",\n },\n action: {\n type: \"string\",\n minLength: 1,\n description: \"Exact persisted Fabric action name.\",\n },\n outcome: {\n type: \"string\",\n enum: [\"succeeded\", \"failed\", \"aborted\", \"timed_out\"],\n description: \"Exact persisted Fabric execution outcome.\",\n },\n since: { type: \"number\" },\n until: { type: \"number\" },\n entryRange: {\n type: \"object\",\n description:\n \"Inclusive normalized-entry range for an explicit session:<id> hydration.\",\n properties: {\n first: { type: \"number\", minimum: 0 },\n last: { type: \"number\", minimum: 0 },\n },\n required: [\"first\", \"last\"],\n additionalProperties: false,\n },\n },\n additionalProperties: false,\n },\n risk: \"read\",\n namespace: \"memory\",\n },\n {\n name: \"expand\",\n description:\n \"Re-read full text or a bounded structured Fabric operation by index, entry id, operation address, or inclusive range.\",\n inputSchema: {\n type: \"object\",\n properties: {\n session: { type: \"string\", description: \"Exact session file path or unambiguous id.\" },\n expectedSourceHash: {\n type: \"string\",\n description: \"SHA-256 from a prior pointer; stale sources are refused.\",\n },\n expectedLineageFingerprint: {\n type: \"string\",\n description: \"Active-lineage fingerprint from a prior pointer; changed leaves are refused.\",\n },\n branches: {\n type: \"string\",\n enum: [\"active\", \"all\"],\n description: \"Expand on the active parent-linked path (default) or across every branch.\",\n },\n indices: { type: \"array\", items: { type: \"number\", minimum: 0 } },\n entryIds: { type: \"array\", items: { type: \"string\" } },\n operationAddresses: { type: \"array\", items: { type: \"string\" } },\n entryRange: {\n type: \"object\",\n properties: {\n first: { type: \"number\", minimum: 0 },\n last: { type: \"number\", minimum: 0 },\n },\n required: [\"first\", \"last\"],\n additionalProperties: false,\n },\n },\n required: [\"session\"],\n additionalProperties: false,\n },\n risk: \"read\",\n namespace: \"memory\",\n },\n {\n name: \"sessions\",\n description: \"List known sessions in scope with id, file, cwd, mtime, entry count, and hot/cold tier.\",\n inputSchema: {\n type: \"object\",\n properties: {\n scope: { type: \"string\" },\n branches: {\n type: \"string\",\n enum: [\"active\", \"all\"],\n description: \"Count the active parent-linked path (default) or every branch.\",\n },\n limit: {\n type: \"number\",\n minimum: 1,\n description: \"Maximum sessions returned; capped at the internal session ceiling.\",\n },\n },\n additionalProperties: false,\n },\n risk: \"read\",\n namespace: \"memory\",\n },\n];\n\n// Value spellings models reliably substitute for the documented memory scopes,\n// e.g. scope \"cwd\" for \"project\". Same discipline as the key aliases below:\n// identical intent only. Unknown scopes still fall through to resolveScope's\n// default \"session\" handling.\nconst MEMORY_SCOPE_VALUE_ALIASES: Record<string, string> = {\n cwd: \"project\",\n repo: \"project\",\n directory: \"project\",\n folder: \"project\",\n all: \"global\",\n current: \"session\",\n};\n\nconst MEMORY_ARG_NORMALIZATION: Record<string, ArgNormalizationSpec> = {\n recall: { values: { scope: MEMORY_SCOPE_VALUE_ALIASES } },\n sessions: { values: { scope: MEMORY_SCOPE_VALUE_ALIASES } },\n};\n\n// Argument repair derives from the action schemas plus the shared synonym\n// lexicon; only scope value spellings stay table-bound because the schema\n// spells scope as a free string rather than an enum.\nexport const normalizeMemoryArgs = actionArgNormalizer(\n () => descriptors,\n MEMORY_ARG_NORMALIZATION,\n);\n\nexport interface MemoryProviderContext {\n agentDir: string;\n cwd: string;\n config: FabricMemoryConfig;\n sessionId?: string;\n sessionFile?: string;\n getLiveBranch?: () => LiveSessionBranch;\n}\n\nconst parseBranches = (value: unknown, action: string): MemoryBranches => {\n if (value === undefined) return \"active\";\n if (value === \"active\" || value === \"all\") return value;\n throw new Error(`${action} branches must be \"active\" or \"all\"`);\n};\n\nconst resolveIndexOptions = (\n config: FabricMemoryConfig,\n agentDir: string,\n branches: MemoryBranches,\n liveBranchForFile?: MemoryIndexOptions[\"liveBranchForFile\"],\n): MemoryIndexOptions => ({\n indexDir: config.indexDir ?? `${agentDir}/fabric/memory-index`,\n maxEntryChars: config.maxEntryChars,\n branches,\n indexThinking: config.indexThinking ?? false,\n indexToolOutput: config.indexToolOutput ?? true,\n ...(liveBranchForFile ? { liveBranchForFile } : {}),\n hotSessions: config.hotSessions ?? DEFAULT_HOT_SESSIONS,\n digestTerms: config.digestTerms ?? 200,\n ...(config.maxColdVocabularyBytes === undefined\n ? {} : { maxColdVocabularyBytes: config.maxColdVocabularyBytes }),\n ...(config.maxColdCacheBytes === undefined ? {} : { maxColdCacheBytes: config.maxColdCacheBytes }),\n ...(config.maxSyncSessions === undefined ? {} : { maxSyncSessions: config.maxSyncSessions }),\n ...(config.maxSyncSourceBytes === undefined ? {} : { maxSyncSourceBytes: config.maxSyncSourceBytes }),\n ...(config.maxCacheCleanupFiles === undefined\n ? {} : { maxCacheCleanupFiles: config.maxCacheCleanupFiles }),\n});\n\nconst resolveTierRefs = (refs: SessionRef[], context: MemoryProviderContext): SessionRef[] => {\n const all = enumerateAllSessions(context.agentDir, Number.MAX_SAFE_INTEGER);\n const known = new Set(all.map((ref) => ref.file));\n for (const ref of refs) {\n if (!known.has(ref.file)) all.push(ref);\n }\n return all;\n};\n\nconst resolveRefs = (\n scope: string | undefined,\n context: MemoryProviderContext,\n boundedBrowse: boolean,\n): SessionRef[] => {\n const effectiveScope = scope ?? \"session\";\n const input: ResolveScopeInput = {\n agentDir: context.agentDir,\n cwd: context.cwd,\n scope: effectiveScope,\n maxSessions: boundedBrowse ? context.config.maxSessions : Number.MAX_SAFE_INTEGER,\n };\n if (context.sessionId) input.sessionId = context.sessionId;\n if (context.sessionFile) input.sessionFile = context.sessionFile;\n return resolveScope(input);\n};\n\nconst liveBranchResolver = (\n context: MemoryProviderContext,\n): MemoryIndexOptions[\"liveBranchForFile\"] | undefined => {\n if (!context.sessionFile || !context.getLiveBranch) return undefined;\n const current = path.resolve(context.sessionFile);\n return (sessionFile) => path.resolve(sessionFile) === current\n ? context.getLiveBranch?.()\n : undefined;\n};\n\nconst stalePointerError = (\n sessionFile: string,\n expectedSourceHash: string | undefined,\n actualSourceHash: string,\n expectedLineageFingerprint?: string,\n actualLineageFingerprint?: string,\n) => ({\n code: \"stale_pointer\",\n message: expectedLineageFingerprint !== undefined &&\n expectedLineageFingerprint !== actualLineageFingerprint\n ? \"Session active lineage changed after the pointer was issued.\"\n : \"Session source changed after the pointer was issued.\",\n sessionFile,\n ...(expectedSourceHash === undefined ? {} : { expectedSourceHash }),\n actualSourceHash,\n ...(expectedLineageFingerprint === undefined ? {} : { expectedLineageFingerprint }),\n ...(actualLineageFingerprint === undefined ? {} : { actualLineageFingerprint }),\n});\n\nconst addressError = (message: string, entryCount?: number) => ({\n code: \"index_out_of_bounds\",\n message,\n ...(entryCount === undefined ? {} : { entryCount }),\n});\n\nexport class MemoryProvider implements FabricProvider {\n readonly name = \"memory\";\n readonly description =\n \"Cross-session memory: a search engine over every Pi session timeline on this machine\";\n\n constructor(private readonly context: MemoryProviderContext) {}\n\n async list(\n request: FabricProviderListRequest,\n _context: FabricInvocationContext,\n ): Promise<FabricActionDescriptor[]> {\n const query = request.query?.toLowerCase();\n return query\n ? descriptors.filter((descriptor) =>\n `${descriptor.name} ${descriptor.description}`.toLowerCase().includes(query),\n )\n : descriptors;\n }\n\n async describe(\n actionName: string,\n _context: FabricInvocationContext,\n ): Promise<FabricActionDescriptor | undefined> {\n return descriptors.find((descriptor) => descriptor.name === actionName);\n }\n\n prepareArguments(\n actionName: string,\n args: Record<string, unknown>,\n ): Record<string, unknown> {\n return normalizeMemoryArgs(actionName, args);\n }\n\n async invoke(\n actionName: string,\n args: Record<string, unknown>,\n invocationContext: FabricInvocationContext,\n ): Promise<unknown> {\n try {\n switch (actionName) {\n case \"recall\":\n return await this.recall(args, invocationContext);\n case \"expand\":\n return await this.expand(args);\n case \"sessions\":\n return await this.sessions(args);\n default:\n throw new Error(`Unknown memory action: ${actionName}`);\n }\n } catch (error) {\n if (error instanceof AmbiguousSessionError) {\n return {\n error: {\n code: error.code,\n message: error.message,\n session: error.session,\n candidates: error.candidates,\n },\n };\n }\n throw error;\n }\n }\n\n private async recall(\n args: Record<string, unknown>,\n invocationContext: FabricInvocationContext,\n ): Promise<unknown> {\n const query = typeof args.query === \"string\" ? args.query : undefined;\n const rawQueryMode = args.queryMode;\n if (rawQueryMode !== undefined && rawQueryMode !== \"literal\" && rawQueryMode !== \"regex\") {\n throw new Error('memory.recall queryMode must be \"literal\" or \"regex\"');\n }\n const queryMode: MemoryQueryMode = rawQueryMode === \"regex\" ? \"regex\" : \"literal\";\n const expectedSourceHash = typeof args.expectedSourceHash === \"string\"\n ? args.expectedSourceHash\n : undefined;\n const expectedLineageFingerprint = typeof args.expectedLineageFingerprint === \"string\"\n ? args.expectedLineageFingerprint\n : undefined;\n const branches = parseBranches(args.branches, \"memory.recall\");\n const scope = typeof args.scope === \"string\" ? args.scope : undefined;\n const role = typeof args.role === \"string\" ? args.role : undefined;\n const tool = typeof args.tool === \"string\" ? args.tool : undefined;\n const ref = typeof args.ref === \"string\" ? args.ref : undefined;\n const provider = typeof args.provider === \"string\" ? args.provider : undefined;\n const action = typeof args.action === \"string\" ? args.action : undefined;\n const rawOutcome = args.outcome;\n if (\n rawOutcome !== undefined &&\n rawOutcome !== \"succeeded\" &&\n rawOutcome !== \"failed\" &&\n rawOutcome !== \"aborted\" &&\n rawOutcome !== \"timed_out\"\n ) {\n throw new Error(\"memory.recall outcome must be succeeded, failed, aborted, or timed_out\");\n }\n const outcome = rawOutcome as SearchFilters[\"outcome\"];\n const since = typeof args.since === \"number\" ? args.since : undefined;\n const until = typeof args.until === \"number\" ? args.until : undefined;\n const page = typeof args.page === \"number\" && args.page >= 1 ? Math.floor(args.page) : 1;\n const pageSize =\n typeof args.pageSize === \"number\" && args.pageSize >= 1\n ? Math.min(Math.floor(args.pageSize), RECALL_MAX_PAGE_SIZE)\n : RECALL_DEFAULT_PAGE_SIZE;\n\n const refs = resolveRefs(scope, this.context, false);\n const liveResolver = liveBranchResolver(this.context);\n const options = resolveIndexOptions(\n this.context.config,\n this.context.agentDir,\n branches,\n liveResolver,\n );\n const hydrate = scope?.trim().startsWith(\"session:\") ?? false;\n if ((expectedSourceHash !== undefined || expectedLineageFingerprint !== undefined) && !hydrate) {\n throw new Error(\"memory.recall integrity expectations require scope session:<id-or-path>\");\n }\n if (hydrate && refs[0]) {\n const state = fingerprintSource(refs[0].file);\n const lineage = reconstructSessionLineage(\n refs[0].file,\n branches,\n liveResolver?.(refs[0].file),\n );\n const sourceChanged = expectedSourceHash !== undefined &&\n state?.sourceHash !== expectedSourceHash;\n const lineageChanged = expectedLineageFingerprint !== undefined &&\n lineage.fingerprint !== expectedLineageFingerprint;\n if (state && (sourceChanged || lineageChanged)) {\n return {\n scope: scope ?? \"session\",\n query: query ?? null,\n branches,\n error: stalePointerError(\n refs[0].file,\n expectedSourceHash,\n state.sourceHash,\n expectedLineageFingerprint,\n lineage.fingerprint,\n ),\n segments: [],\n digestHits: [],\n items: [],\n };\n }\n }\n\n const rawRange = args.entryRange;\n const entryRange = rawRange && typeof rawRange === \"object\" && !Array.isArray(rawRange)\n ? rawRange as Record<string, unknown>\n : undefined;\n const first = entryRange?.first;\n const last = entryRange?.last;\n if ((first === undefined) !== (last === undefined)) {\n throw new Error(\"memory.recall entryRange requires both first and last\");\n }\n if ((first !== undefined || last !== undefined) && !hydrate) {\n throw new Error(\"memory.recall entryRange requires scope session:<id-or-path>\");\n }\n if (first !== undefined && (\n typeof first !== \"number\" ||\n typeof last !== \"number\" ||\n !Number.isSafeInteger(first) ||\n !Number.isSafeInteger(last) ||\n first < 0 ||\n last < first\n )) {\n return {\n scope: scope ?? \"session\",\n query: query ?? null,\n error: addressError(\"Entry range requires safe integers with 0 <= first <= last.\"),\n segments: [],\n digestHits: [],\n items: [],\n };\n }\n const selectedRange: EntryRange | undefined =\n typeof first === \"number\" && typeof last === \"number\" ? { first, last } : undefined;\n const index = loadTieredIndex(\n refs,\n resolveTierRefs(refs, this.context),\n options,\n hydrate,\n selectedRange,\n );\n const hydratedShard = index.shards[0];\n const hydratedSourceChanged = expectedSourceHash !== undefined &&\n hydratedShard?.sourceHash !== expectedSourceHash;\n const hydratedLineageChanged = expectedLineageFingerprint !== undefined &&\n hydratedShard?.lineageFingerprint !== expectedLineageFingerprint;\n if (hydrate && hydratedShard && (hydratedSourceChanged || hydratedLineageChanged)) {\n return {\n scope: scope ?? \"session\",\n query: query ?? null,\n branches,\n error: stalePointerError(\n hydratedShard.sessionFile,\n expectedSourceHash,\n hydratedShard.sourceHash,\n expectedLineageFingerprint,\n hydratedShard.lineageFingerprint,\n ),\n segments: [],\n digestHits: [],\n items: [],\n };\n }\n if (hydrate && selectedRange && index.shards[0] && selectedRange.last >= index.shards[0].totalEntryCount) {\n return {\n scope: scope ?? \"session\",\n query: query ?? null,\n error: addressError(\n `Entry range ends at ${selectedRange.last}, but the session has ${index.shards[0].totalEntryCount} entries.`,\n index.shards[0].totalEntryCount,\n ),\n segments: [],\n digestHits: [],\n items: [],\n };\n }\n\n const filters: SearchFilters = {};\n if (role) filters.role = role;\n if (tool) filters.tool = tool;\n if (ref) filters.ref = ref;\n if (provider) filters.provider = provider;\n if (action) filters.action = action;\n if (outcome) filters.outcome = outcome;\n if (since !== undefined) filters.since = since;\n if (until !== undefined) filters.until = until;\n const searchQuery = {\n ...(query === undefined ? {} : { query }),\n queryMode,\n filters,\n regexLimits: {\n maxPatternBytes: this.context.config.regexMaxPatternBytes\n ?? DEFAULT_REGEX_MAX_PATTERN_BYTES,\n maxHaystackTerms: this.context.config.regexMaxHaystackTerms\n ?? DEFAULT_REGEX_MAX_HAYSTACK_TERMS,\n maxHaystackBytes: this.context.config.regexMaxHaystackBytes\n ?? DEFAULT_REGEX_MAX_HAYSTACK_BYTES,\n timeoutMs: this.context.config.regexTimeoutMs ?? DEFAULT_REGEX_TIMEOUT_MS,\n },\n };\n const result = await searchMemoryIndex(index.shards, index.digests, searchQuery);\n const coverage = {\n ...index.coverage,\n complete: index.coverage.complete && result.queryCoverage.complete,\n reasons: [...new Set([...index.coverage.reasons, ...result.queryCoverage.reasons])].sort(),\n ...(result.queryCoverage.error ? { error: result.queryCoverage.error } : {}),\n };\n\n const start = (page - 1) * pageSize;\n const pagedItems = result.items.slice(start, start + pageSize);\n const pagedSegments = pagedItems\n .filter((item): item is Extract<SearchItem, { kind: \"entry\" }> => item.kind === \"entry\")\n .map((item) => item.segment);\n const pagedDigests = pagedItems\n .filter((item): item is Extract<SearchItem, { kind: \"digest\" }> => item.kind === \"digest\")\n .map((item) => item.digest);\n const displayResult = {\n ...result,\n segments: pagedSegments,\n digestHits: pagedDigests,\n items: pagedItems,\n };\n const pagedResult = {\n scope: scope ?? \"session\",\n branches,\n query: query ?? null,\n queryMode,\n matchMode: result.matchMode,\n structuralFilters: filters,\n matchedCount: result.matchedCount,\n totalMatches: result.totalMatches,\n totalItems: result.totalItems,\n segmentCount: result.segmentCount,\n segments: pagedSegments,\n digestHits: pagedDigests,\n items: pagedItems,\n page,\n pageSize,\n hasNext: start + pageSize < result.totalItems,\n coverage,\n text: formatSearchResult(displayResult, query, coverage, filters),\n };\n invocationContext.update(\n result.matchMode === \"structural\"\n ? `memory.recall: ${result.matchedCount} structural result items`\n : result.matchMode === \"combined\"\n ? `memory.recall: ${result.matchedCount} lexical matches within exact structural filters`\n : query\n ? `memory.recall: ${result.matchedCount} matches across ${result.segmentCount} segments`\n : `memory.recall: ${result.matchedCount} recent entries`,\n );\n return pagedResult;\n }\n\n private async expand(args: Record<string, unknown>): Promise<unknown> {\n const session = typeof args.session === \"string\" ? args.session : \"\";\n const expectedSourceHash = typeof args.expectedSourceHash === \"string\"\n ? args.expectedSourceHash\n : undefined;\n const expectedLineageFingerprint = typeof args.expectedLineageFingerprint === \"string\"\n ? args.expectedLineageFingerprint\n : undefined;\n const branches = parseBranches(args.branches, \"memory.expand\");\n const rawIndices = args.indices;\n if (rawIndices !== undefined && !Array.isArray(rawIndices)) {\n throw new Error(\"memory.expand indices must be an array\");\n }\n if (Array.isArray(rawIndices) && !rawIndices.every((index) =>\n typeof index === \"number\" && Number.isSafeInteger(index) && index >= 0)) {\n return { session, error: addressError(\"Every entry index must be a non-negative safe integer.\"), expanded: [] };\n }\n const indices = (rawIndices as number[] | undefined) ?? [];\n const entryIds = Array.isArray(args.entryIds)\n ? args.entryIds.filter(\n (entryId): entryId is string => typeof entryId === \"string\" && entryId.length > 0,\n )\n : [];\n const operationAddresses = Array.isArray(args.operationAddresses)\n ? args.operationAddresses.filter(\n (address): address is string => typeof address === \"string\" && address.length > 0,\n )\n : [];\n const rawRange = args.entryRange;\n const rangeRecord = rawRange && typeof rawRange === \"object\" && !Array.isArray(rawRange)\n ? rawRange as Record<string, unknown>\n : undefined;\n const first = rangeRecord?.first;\n const last = rangeRecord?.last;\n if (!session) throw new Error(\"memory.expand requires a session\");\n if ((first === undefined) !== (last === undefined)) {\n throw new Error(\"memory.expand entryRange requires both first and last\");\n }\n if (first !== undefined && (\n typeof first !== \"number\" ||\n typeof last !== \"number\" ||\n !Number.isSafeInteger(first) ||\n !Number.isSafeInteger(last) ||\n first < 0 ||\n last < first\n )) {\n return { session, error: addressError(\"Entry range requires safe integers with 0 <= first <= last.\"), expanded: [] };\n }\n\n const ref = resolveSessionTarget(this.context.agentDir, session);\n if (!ref) {\n return {\n session,\n error: { code: \"session_not_found\", message: `Session not found: ${session}` },\n expanded: [],\n };\n }\n const liveResolver = liveBranchResolver(this.context);\n const initialState = fingerprintSource(ref.file);\n const initialLineage = reconstructSessionLineage(\n ref.file,\n branches,\n liveResolver?.(ref.file),\n );\n if (!initialState) {\n return {\n session: ref.file,\n error: { code: \"source_unavailable\", message: `Session source is unavailable: ${ref.file}` },\n expanded: [],\n };\n }\n const sourceChanged = expectedSourceHash !== undefined &&\n initialState.sourceHash !== expectedSourceHash;\n const lineageChanged = expectedLineageFingerprint !== undefined &&\n initialLineage.fingerprint !== expectedLineageFingerprint;\n if (sourceChanged || lineageChanged) {\n return {\n session: ref.file,\n branches,\n error: stalePointerError(\n ref.file,\n expectedSourceHash,\n initialState.sourceHash,\n expectedLineageFingerprint,\n initialLineage.fingerprint,\n ),\n expanded: [],\n };\n }\n\n const expansionOptions = {\n lineage: initialLineage,\n indexThinking: true,\n indexToolOutput: true,\n };\n const entryCount = normalizeSession(\n ref.file,\n Number.MAX_SAFE_INTEGER,\n expansionOptions,\n ).entries.length;\n const outOfBounds = indices.find((index) => index >= entryCount);\n if (outOfBounds !== undefined) {\n return {\n session: ref.file,\n error: addressError(`Entry index ${outOfBounds} is outside 0..${Math.max(0, entryCount - 1)}.`, entryCount),\n expanded: [],\n };\n }\n if (typeof last === \"number\" && last >= entryCount) {\n return {\n session: ref.file,\n error: addressError(`Entry range ends at ${last}, but the session has ${entryCount} entries.`, entryCount),\n expanded: [],\n };\n }\n if (\n indices.length === 0 &&\n entryIds.length === 0 &&\n operationAddresses.length === 0 &&\n (first === undefined || last === undefined)\n ) {\n return {\n session: ref.file,\n sourceHash: initialState.sourceHash,\n branches,\n lineageFingerprint: initialLineage.fingerprint,\n expanded: [],\n };\n }\n\n const selection: {\n indices?: number[];\n entryIds?: string[];\n operationAddresses?: string[];\n entryRange?: { first: number; last: number };\n } = {};\n if (indices.length > 0) selection.indices = indices;\n if (entryIds.length > 0) selection.entryIds = entryIds;\n if (operationAddresses.length > 0) selection.operationAddresses = operationAddresses;\n if (typeof first === \"number\" && typeof last === \"number\") {\n selection.entryRange = { first, last };\n }\n const expansion = expandSessionEntriesChecked(ref.file, selection, expansionOptions);\n const finalState = fingerprintSource(ref.file);\n const finalLineage = reconstructSessionLineage(\n ref.file,\n branches,\n liveResolver?.(ref.file),\n );\n if (\n !finalState ||\n finalState.sourceHash !== initialState.sourceHash ||\n finalLineage.fingerprint !== initialLineage.fingerprint\n ) {\n return {\n session: ref.file,\n error: stalePointerError(\n ref.file,\n expectedSourceHash ?? initialState.sourceHash,\n finalState?.sourceHash ?? \"\",\n expectedLineageFingerprint ?? initialLineage.fingerprint,\n finalLineage.fingerprint,\n ),\n expanded: [],\n };\n }\n if (\"error\" in expansion) {\n return {\n session: ref.file,\n sourceHash: finalState.sourceHash,\n branches,\n lineageFingerprint: finalLineage.fingerprint,\n error: expansion.error,\n expanded: [],\n };\n }\n return {\n session: ref.file,\n sourceHash: finalState.sourceHash,\n branches,\n lineageFingerprint: finalLineage.fingerprint,\n expanded: expansion.expanded,\n };\n }\n\n private async sessions(args: Record<string, unknown>): Promise<unknown> {\n const scope = typeof args.scope === \"string\" ? args.scope : undefined;\n const branches = parseBranches(args.branches, \"memory.sessions\");\n const limit =\n typeof args.limit === \"number\" && Number.isSafeInteger(args.limit) && args.limit >= 1\n ? Math.min(args.limit, SESSIONS_MAX)\n : SESSIONS_MAX;\n const refs = resolveRefs(scope, this.context, true).slice(0, limit);\n const options = resolveIndexOptions(\n this.context.config,\n this.context.agentDir,\n branches,\n liveBranchResolver(this.context),\n );\n const index = loadTieredIndex(refs, resolveTierRefs(refs, this.context), options);\n const shards = new Map(index.shards.map((shard) => [shard.sessionFile, shard]));\n const digests = new Map(index.digests.map((digest) => [digest.file, digest]));\n const sessions = refs.map((ref) => {\n const tier = index.tiers.get(ref.file) ?? \"cold\";\n const shard = shards.get(ref.file);\n const digest = digests.get(ref.file);\n return {\n id: shard?.sessionId ?? digest?.sessionId ?? ref.id,\n file: ref.file,\n cwd: digest?.cwd ?? ref.cwd,\n mtime: ref.mtime,\n entryCount: shard?.entries.length ?? digest?.entryCount ?? 0,\n tier,\n branches,\n lineageFingerprint: shard?.lineageFingerprint ?? digest?.lineageFingerprint ?? null,\n };\n });\n return { scope: scope ?? \"session\", branches, sessions };\n }\n}\n", "import type { FabricActionDescriptor } from \"../protocol.js\";\n\n// Argument-shape normalization shared by the stable Fabric providers,\n// mirroring the pi core tool architecture:\n//\n// 1. prepareArguments canonicalizes near-miss argument spellings at the\n// registry prepare stage \u2014 aliases resolve to the canonical key (which\n// wins on conflict), value spellings repair, numeric strings coerce for\n// schema-declared numeric fields, and nullish values of declared\n// optionals are stripped.\n// 2. validateArguments then owns the didactic failure tier: required\n// canonical keys are enforced and unknown keys fail\n// additionalProperties: false validation with the offending path named.\n//\n// Most of the repair surface is derived from each action's inputSchema\n// rather than maintained by hand: key casing/spacing variants and\n// singular/plural near-misses come from the declared property names,\n// numeric coercion from the declared property types, and enum-value\n// repairs (casing variants plus the shared synonym classes below) from the\n// declared enum members. Only genuinely semantic synonyms need explicit\n// vocabulary: the shared KEY_SYNONYM_CLASSES / ENUM_VALUE_CLASSES classes\n// here, and provider-local `values` tables where the schema spells a\n// concept as a free string instead of an enum (memory scope).\n\ninterface JsonSchemaObject {\n type?: unknown;\n properties?: unknown;\n enum?: unknown;\n items?: unknown;\n oneOf?: unknown;\n anyOf?: unknown;\n}\n\nexport interface ArgNormalizationSpec {\n // Explicit escape-hatch rows. Prefer derivation or a shared synonym\n // class; keep entries here only for action-local semantics.\n aliases?: Readonly<Record<string, string>>;\n numerics?: readonly string[];\n numericArrays?: readonly string[];\n values?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n // Declared property names whose nullish values are stripped before\n // validation. Derived from the descriptor schema when omitted.\n knownKeys?: readonly string[];\n}\n\nexport type ActionArgNormalizer = (\n actionName: string,\n args: Record<string, unknown>,\n) => Record<string, unknown>;\n\n// Casing/spacing/underscore-insensitive key and value form, e.g.\n// \"requested_by\", \"requestedBy\", and \"REQUESTED-BY\" all share one form.\nconst normalizeForm = (key: string): string =>\n key.toLowerCase().replace(/[^a-z0-9]/g, \"\");\n\n// Semantic near-miss vocabulary shared by every stable provider. A spilled\n// key belonging to a class repairs to a declared canonical key only when\n// exactly one member of that class is declared by the action's schema \u2014\n// ambiguity (or absence) leaves the key untouched so the validate stage\n// owns its failure. `id` deliberately appears in several classes: the\n// declared members of each action's schema disambiguate which repair fires\n// (memory.expand takes a session id; agents.wait takes an agent id).\nconst KEY_SYNONYM_CLASSES: ReadonlyArray<ReadonlyArray<string>> = [\n [\"session\", \"sessionId\", \"id\", \"file\", \"path\"],\n [\"hypothesisId\", \"id\"],\n [\"id\", \"agentId\", \"actorId\", \"runId\"],\n [\"query\", \"q\"],\n [\"limit\", \"max\", \"pageSize\"],\n [\"task\", \"prompt\", \"instructions\"],\n [\"label\", \"labels\", \"name\", \"title\"],\n [\"summary\", \"description\"],\n [\"text\", \"message\", \"body\"],\n [\"check\", \"command\", \"cmd\", \"script\", \"predicate\"],\n [\"files\", \"paths\"],\n [\"ifVersion\", \"versionRef\", \"version\"],\n [\"indices\", \"index\"],\n];\n\nconst KEY_CLASS_FORMS = KEY_SYNONYM_CLASSES.map(\n (cls) => new Set(cls.map(normalizeForm)),\n);\n\n// Synonym classes for schema enum values, applied only when the declared\n// enum contains exactly one class member. Scope spellings such as `cwd` \u2192\n// \"project\" repair wherever an enum spells that concept this way; a schema\n// whose enum lacks the concept keeps the value untouched for validation.\nconst ENUM_VALUE_CLASSES: ReadonlyArray<ReadonlyArray<string>> = [\n [\"project\", \"cwd\", \"repo\", \"repository\", \"workspace\", \"checkout\", \"tree\"],\n [\"global\", \"all\"],\n [\"permanent\", \"pinned\", \"sticky\", \"durable\"],\n];\n\nconst VALUE_CLASS_FORMS = ENUM_VALUE_CLASSES.map(\n (cls) => new Set(cls.map(normalizeForm)),\n);\n\ntype NumericKind = \"scalar\" | \"array\" | undefined;\n\nconst numericKind = (property: unknown): NumericKind => {\n if (!property || typeof property !== \"object\") return undefined;\n const schema = property as JsonSchemaObject;\n if (schema.type === \"number\" || schema.type === \"integer\") return \"scalar\";\n if (schema.type === \"array\") {\n const items = schema.items;\n if (\n items &&\n typeof items === \"object\" &&\n ((items as JsonSchemaObject).type === \"number\" ||\n (items as JsonSchemaObject).type === \"integer\")\n ) {\n return \"array\";\n }\n }\n return undefined;\n};\n\nconst stringEnumValues = (property: unknown): readonly string[] | undefined => {\n if (!property || typeof property !== \"object\") return undefined;\n const schema = property as JsonSchemaObject;\n if (Array.isArray(schema.enum)) {\n const values = schema.enum.filter(\n (entry): entry is string => typeof entry === \"string\",\n );\n return values.length > 0 ? values : undefined;\n }\n for (const branch of [schema.oneOf, schema.anyOf]) {\n if (!Array.isArray(branch)) continue;\n const consts = branch\n .map((entry) =>\n entry && typeof entry === \"object\"\n ? (entry as { const?: unknown }).const\n : undefined,\n )\n .filter((entry): entry is string => typeof entry === \"string\");\n if (consts.length > 0) return consts;\n }\n return undefined;\n};\n\n// form \u2192 enum value. Exact forms of declared members win; class synonyms\n// fill in only when exactly one declared member belongs to the class.\nconst deriveEnumValueMap = (\n values: readonly string[],\n): Map<string, string> => {\n const map = new Map<string, string>();\n const seen = new Map<string, string | undefined>();\n for (const value of values) {\n const form = normalizeForm(value);\n seen.set(form, seen.has(form) ? undefined : value);\n }\n for (const [form, value] of seen) if (value !== undefined) map.set(form, value);\n for (const classForms of VALUE_CLASS_FORMS) {\n const members = values.filter((value) => classForms.has(normalizeForm(value)));\n if (members.length !== 1) continue;\n const [hit] = members as [string];\n for (const form of classForms) {\n if (form !== normalizeForm(hit) && !map.has(form)) map.set(form, hit);\n }\n }\n return map;\n};\n\ntype DerivedAction = {\n declared: Set<string>;\n declaredForms: Map<string, string>;\n singulars: Map<string, string>;\n numerics: Set<string>;\n numericArrays: Set<string>;\n values: Map<string, Map<string, unknown>>;\n aliases?: Readonly<Record<string, string>> | undefined;\n};\n\n// The value-column meaning of the schema, precomputed once per action.\nconst deriveAction = (\n inputSchema: JsonSchemaObject | undefined,\n explicit: ArgNormalizationSpec | undefined,\n): DerivedAction => {\n const properties =\n inputSchema && typeof inputSchema === \"object\" &&\n inputSchema.properties &&\n typeof inputSchema.properties === \"object\"\n ? (inputSchema.properties as Record<string, unknown>)\n : undefined;\n const declared = new Set(Object.keys(properties ?? {}));\n const declaredForms = new Map<string, string>();\n const ambiguousForms = new Set<string>();\n for (const key of declared) {\n const form = normalizeForm(key);\n if (declaredForms.has(form)) {\n ambiguousForms.add(form);\n declaredForms.delete(form);\n } else if (!ambiguousForms.has(form)) {\n declaredForms.set(form, key);\n }\n }\n const singulars = new Map<string, string>();\n for (const key of declared) {\n const form = normalizeForm(key);\n if (!form.endsWith(\"s\")) continue;\n const singular = form.slice(0, -1);\n if (!singular || declaredForms.has(singular) || singular === form) continue;\n if (singulars.get(singular) !== undefined) singulars.delete(singular);\n else singulars.set(singular, key);\n }\n for (const form of ambiguousForms) singulars.delete(form);\n\n const numerics = new Set(explicit?.numerics ?? []);\n const numericArrays = new Set(explicit?.numericArrays ?? []);\n const values = new Map<string, Map<string, unknown>>();\n if (properties) {\n for (const [key, property] of Object.entries(properties)) {\n const kind = numericKind(property);\n if (kind === \"scalar\") numerics.add(key);\n else if (kind === \"array\") numericArrays.add(key);\n const enumValues = stringEnumValues(property);\n if (enumValues) values.set(key, new Map(deriveEnumValueMap(enumValues)));\n }\n }\n for (const [key, remaps] of Object.entries(explicit?.values ?? {})) {\n const map = values.get(key) ?? new Map<string, unknown>();\n for (const [spelling, target] of Object.entries(remaps)) {\n map.set(normalizeForm(spelling), target);\n }\n values.set(key, map);\n }\n return { declared, declaredForms, singulars, numerics, numericArrays, values, aliases: explicit?.aliases };\n};\n\nconst lexiconRepair = (\n form: string,\n declaredForms: Map<string, string>,\n): string | undefined => {\n const candidates = new Set<string>();\n for (const classForms of KEY_CLASS_FORMS) {\n if (!classForms.has(form)) continue;\n for (const [declaredForm, declaredKey] of declaredForms) {\n if (declaredForm !== form && classForms.has(declaredForm)) {\n candidates.add(declaredKey);\n }\n }\n }\n return candidates.size === 1 ? [...candidates][0] : undefined;\n};\n\nconst applyDerived = (\n args: Record<string, unknown>,\n derived: DerivedAction,\n): Record<string, unknown> => {\n const out: Record<string, unknown> = { ...args };\n\n // Explicit action-local aliases first, then derived repairs. Both obey\n // canonical-wins: the canonical key keeps an already-supplied value and\n // the spelling variant is dropped either way.\n const repair = (alias: string, canonical: string) => {\n if (!(alias in out) || alias === canonical) return;\n if (!(canonical in out)) out[canonical] = out[alias];\n delete out[alias];\n };\n for (const [alias, canonical] of Object.entries(derived.aliases ?? {})) {\n repair(alias, canonical);\n }\n for (const key of [...Object.keys(out)]) {\n if (derived.declared.has(key)) continue;\n const form = normalizeForm(key);\n const canonical =\n derived.declaredForms.get(form) ??\n derived.singulars.get(form) ??\n lexiconRepair(form, derived.declaredForms);\n if (canonical && canonical !== key) repair(key, canonical);\n }\n\n for (const key of derived.numerics) {\n const value = out[key];\n if (typeof value === \"string\" && value.trim() !== \"\" && !Number.isNaN(Number(value))) {\n out[key] = Number(value);\n }\n }\n for (const key of derived.numericArrays) {\n const value = out[key];\n if (Array.isArray(value)) {\n out[key] = value.map((entry) =>\n typeof entry === \"string\" && entry.trim() !== \"\" && !Number.isNaN(Number(entry))\n ? Number(entry)\n : entry,\n );\n }\n }\n for (const [key, remaps] of derived.values) {\n const value = out[key];\n if (typeof value === \"string\") {\n const next = remaps.get(normalizeForm(value));\n if (next !== undefined) out[key] = next;\n }\n }\n if (derived.declared.size > 0) {\n for (const key of Object.keys(out)) {\n if (derived.declared.has(key) && (out[key] === null || out[key] === undefined)) {\n delete out[key];\n }\n }\n }\n return out;\n};\n\n// Low-level explicit-spec normalizer. Used directly by tests and as the\n// shared mechanics for per-key aliases, value spellings, numeric strings,\n// and nullish stripping; actionArgNormalizer layers schema derivation and\n// the shared synonym lexicon on top.\nexport const normalizeActionArgs = (\n args: Record<string, unknown>,\n spec: ArgNormalizationSpec,\n): Record<string, unknown> => {\n const derived: DerivedAction = {\n // The low-level path strips nullish values only for explicit knownKeys;\n // schema-derived declared keys come from actionArgNormalizer.\n declared: new Set(spec.knownKeys ?? []),\n declaredForms: new Map(),\n singulars: new Map(),\n numerics: new Set(spec.numerics ?? []),\n numericArrays: new Set(spec.numericArrays ?? []),\n values: new Map(\n Object.entries(spec.values ?? {}).map(([key, remaps]) => [\n key,\n new Map(\n Object.entries(remaps).map(([spelling, target]) => [normalizeForm(spelling), target]),\n ),\n ]),\n ),\n aliases: spec.aliases,\n };\n if (!args || typeof args !== \"object\" || Array.isArray(args)) return args;\n return applyDerived(args, derived);\n};\n\n// Build a provider prepareArguments hook. Repair behavior derives from each\n// action's inputSchema (declared key forms, singular/plural variants,\n// numeric property types, enum value spellings) plus the shared synonym\n// lexicon; the residual table holds only action-local semantics the schema\n// cannot express.\nexport const actionArgNormalizer = (\n describeActions: () => ReadonlyArray<Pick<FabricActionDescriptor, \"name\" | \"inputSchema\">>,\n table: Record<string, ArgNormalizationSpec> = {},\n): ActionArgNormalizer => {\n const derived = new Map<string, DerivedAction>();\n for (const descriptor of describeActions()) {\n derived.set(\n descriptor.name,\n deriveAction(\n descriptor.inputSchema as JsonSchemaObject | undefined,\n table[descriptor.name],\n ),\n );\n }\n return (actionName, args) => {\n if (!args || typeof args !== \"object\" || Array.isArray(args)) return args;\n const action = derived.get(actionName);\n return action ? applyDerived(args, action) : args;\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAOA,OAAO,UAAU;;;AC6CjB,IAAM,gBAAgB,CAAC,QACrB,IAAI,YAAY,EAAE,QAAQ,cAAc,EAAE;AAS5C,IAAM,sBAA4D;AAAA,EAChE,CAAC,WAAW,aAAa,MAAM,QAAQ,MAAM;AAAA,EAC7C,CAAC,gBAAgB,IAAI;AAAA,EACrB,CAAC,MAAM,WAAW,WAAW,OAAO;AAAA,EACpC,CAAC,SAAS,GAAG;AAAA,EACb,CAAC,SAAS,OAAO,UAAU;AAAA,EAC3B,CAAC,QAAQ,UAAU,cAAc;AAAA,EACjC,CAAC,SAAS,UAAU,QAAQ,OAAO;AAAA,EACnC,CAAC,WAAW,aA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U,IAAI,IAAI,MAAM,QAAQ,IAAI,CAAC,WAAW,CAAC,OAAO,MAAM,MAAM,CAAC,CAAC;AAC5E,UAAM,WAAW,KAAK,IAAI,CAAC,QAAQ;AACjC,YAAM,OAAO,MAAM,MAAM,IAAI,IAAI,IAAI,KAAK;AAC1C,YAAM,QAAQ,OAAO,IAAI,IAAI,IAAI;AACjC,YAAM,SAAS,QAAQ,IAAI,IAAI,IAAI;AACnC,aAAO;AAAA,QACL,IAAI,OAAO,aAAa,QAAQ,aAAa,IAAI;AAAA,QACjD,MAAM,IAAI;AAAA,QACV,KAAK,QAAQ,OAAO,IAAI;AAAA,QACxB,OAAO,IAAI;AAAA,QACX,YAAY,OAAO,QAAQ,UAAU,QAAQ,cAAc;AAAA,QAC3D;AAAA,QACA;AAAA,QACA,oBAAoB,OAAO,sBAAsB,QAAQ,sBAAsB;AAAA,MACjF;AAAA,IACF,CAAC;AACD,WAAO,EAAE,OAAO,SAAS,WAAW,UAAU,SAAS;AAAA,EACzD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -388,11 +388,27 @@ var conflictBetween = (left, right) => {
|
|
|
388
388
|
if (left.ordering === "commutative" && right.ordering === "commutative") return void 0;
|
|
389
389
|
return { resources: overlap, reason: "shared_resource" };
|
|
390
390
|
};
|
|
391
|
+
var unexpectedKeys = (schema, value) => {
|
|
392
|
+
if (schema.type !== "object") return [];
|
|
393
|
+
if (schema.additionalProperties !== false) return [];
|
|
394
|
+
const properties = schema.properties;
|
|
395
|
+
if (!properties) return [];
|
|
396
|
+
return Object.keys(value).filter((key) => !(key in properties));
|
|
397
|
+
};
|
|
391
398
|
var validationMessage = (schema, value) => {
|
|
392
399
|
try {
|
|
393
400
|
if (Value.Check(schema, value)) return void 0;
|
|
394
|
-
const
|
|
395
|
-
|
|
401
|
+
const messages = [...Value.Errors(schema, value)].slice(0, 5).map((error) => {
|
|
402
|
+
const at = error.path;
|
|
403
|
+
return typeof at === "string" && at !== "" && at !== "/" ? `${at}: ${error.message}` : error.message;
|
|
404
|
+
});
|
|
405
|
+
for (const key of unexpectedKeys(schema, value).slice(0, 5)) {
|
|
406
|
+
messages.push(`/${key}: must not have additional properties`);
|
|
407
|
+
}
|
|
408
|
+
return truncateString(
|
|
409
|
+
messages.join("; ") || "Schema validation failed",
|
|
410
|
+
MAX_VALIDATION_MESSAGE_CHARS
|
|
411
|
+
);
|
|
396
412
|
} catch {
|
|
397
413
|
return "Schema validator failed";
|
|
398
414
|
}
|
|
@@ -1082,4 +1098,4 @@ export {
|
|
|
1082
1098
|
NESTED_TOOL_CALL_ID_PREFIX,
|
|
1083
1099
|
ActionRegistry
|
|
1084
1100
|
};
|
|
1085
|
-
//# sourceMappingURL=chunk-
|
|
1101
|
+
//# sourceMappingURL=chunk-ZW446OQR.js.map
|