pi-fabric 0.60.0 → 0.61.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/README.md +1 -1
- package/dist/agents/manager.d.ts +8 -1
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/chunks/chunk-22RY7UMR.js +240 -0
- package/dist/chunks/chunk-22RY7UMR.js.map +7 -0
- package/dist/chunks/{chunk-LC3UNIED.js → chunk-5KEG4TKY.js} +6 -2
- package/dist/chunks/chunk-5KEG4TKY.js.map +7 -0
- package/dist/chunks/{chunk-ZBV4KN3K.js → chunk-6YPMW7CD.js} +5 -15
- package/dist/chunks/{chunk-ZBV4KN3K.js.map → chunk-6YPMW7CD.js.map} +3 -3
- package/dist/chunks/{chunk-AMCVSPFW.js → chunk-FPHSJZZE.js} +1 -1
- package/dist/chunks/{chunk-AMCVSPFW.js.map → chunk-FPHSJZZE.js.map} +1 -1
- package/dist/chunks/{chunk-TQB64HFM.js → chunk-XJIAE7IO.js} +6 -4
- package/dist/chunks/{chunk-TQB64HFM.js.map → chunk-XJIAE7IO.js.map} +1 -1
- package/dist/chunks/{chunk-RRBCG2MS.js → chunk-ZQMNKN4L.js} +36 -16
- package/dist/chunks/chunk-ZQMNKN4L.js.map +7 -0
- package/dist/chunks/{dashboard-52NKQ5HQ.js → dashboard-5Q5Y5EFF.js} +2 -2
- package/dist/chunks/{fabric-runtime-state-GYMNKGG6.js → fabric-runtime-state-NW5NIBSB.js} +137 -10
- package/dist/chunks/fabric-runtime-state-NW5NIBSB.js.map +7 -0
- package/dist/components/model-guidance.d.ts +48 -0
- package/dist/components/model-guidance.d.ts.map +1 -0
- package/dist/components/supervisor.d.ts +2 -0
- package/dist/components/supervisor.d.ts.map +1 -1
- package/dist/components/types.d.ts +21 -0
- package/dist/components/types.d.ts.map +1 -1
- package/dist/core/action-registry.js +3 -2
- package/dist/core/system-guidance.d.ts +4 -0
- package/dist/core/system-guidance.d.ts.map +1 -0
- package/dist/fabric-runtime-state.d.ts +2 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-state.d.ts +2 -0
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -12
- package/dist/index.js.map +3 -3
- package/dist/protocol.d.ts +2 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +15 -1
- package/dist/residency/client.d.ts +2 -0
- package/dist/residency/client.d.ts.map +1 -1
- package/dist/residency/host.d.ts.map +1 -1
- package/dist/residency/host.js +18 -1
- package/dist/residency/host.js.map +2 -2
- package/dist/residency/protocol.d.ts +2 -0
- package/dist/residency/protocol.d.ts.map +1 -1
- package/dist/ui/core-tool-render.d.ts.map +1 -1
- package/docs/agents.md +2 -0
- package/docs/component-calculus.md +18 -3
- package/docs/components.md +102 -1
- package/package.json +1 -1
- package/dist/chunks/chunk-LC3UNIED.js.map +0 -7
- package/dist/chunks/chunk-RRBCG2MS.js.map +0 -7
- package/dist/chunks/fabric-runtime-state-GYMNKGG6.js.map +0 -7
- /package/dist/chunks/{dashboard-52NKQ5HQ.js.map → dashboard-5Q5Y5EFF.js.map} +0 -0
package/README.md
CHANGED
|
@@ -128,7 +128,7 @@ See the [interface & commands reference](docs/interface.md) for every view, keyb
|
|
|
128
128
|
- [Configuration](docs/configuration.md): `fabric.json`, code modes, tool capture, approvals, and budgets.
|
|
129
129
|
- [Interface & commands](docs/interface.md): dashboard, settings, keybindings, slash commands, and headless runs.
|
|
130
130
|
- [Agents, actors & mesh](docs/agents.md): model handoff, `/fabric prewalk`, runners, transports, actors, councils, recursive queries, and durable coordination.
|
|
131
|
-
- [Components & committed capabilities](docs/components.md): supervised effects, exact requirements, rolling provider generations, actor commitments, and both formal calculi.
|
|
131
|
+
- [Components & committed capabilities](docs/components.md): supervised effects, exact requirements, external per-model guidance and execution-profile replacement, rolling provider generations, actor commitments, and both formal calculi.
|
|
132
132
|
- [External providers](docs/providers.md): the versioned provider protocol for extensions.
|
|
133
133
|
- [Architecture & security](docs/architecture.md): the host bridge, sandboxing, tool-call robustness, and limits.
|
|
134
134
|
- [Skills](docs/skills.md): the core-first invocation policy and user-invoked advanced patterns.
|
package/dist/agents/manager.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { type FabricAgentConfig, type FabricRetentionConfig } from "../config.js";
|
|
1
|
+
import { type FabricAgentRunner, type FabricAgentConfig, type FabricRetentionConfig } from "../config.js";
|
|
2
2
|
import { type ClaudeModelInfo } from "./claude-cli.js";
|
|
3
3
|
import type { FabricSteeringMode, FabricAgentLog, AgentHandleInfo, AgentRunRecord, AgentRunRequest, AgentRunResult, AgentSteerResult } from "./types.js";
|
|
4
4
|
import { type FabricLifecyclePublishRequest } from "../lifecycle/types.js";
|
|
5
5
|
export declare const effectiveAgentTimeoutMs: (configuredTimeoutMs: number, requestedTimeoutMs?: number) => number;
|
|
6
|
+
interface AgentParticipantGuidanceRequest {
|
|
7
|
+
model?: string;
|
|
8
|
+
runner: FabricAgentRunner;
|
|
9
|
+
}
|
|
10
|
+
type AgentParticipantGuidanceResolver = (request: AgentParticipantGuidanceRequest) => string | undefined;
|
|
6
11
|
export declare class AgentManager {
|
|
7
12
|
#private;
|
|
8
13
|
readonly cwd: string;
|
|
@@ -24,6 +29,7 @@ export declare class AgentManager {
|
|
|
24
29
|
onBackgroundComplete?: (result: AgentRunResult) => void;
|
|
25
30
|
onLifecycle?: (event: FabricLifecyclePublishRequest) => void;
|
|
26
31
|
preparePiModel?: (model: string) => Promise<void>;
|
|
32
|
+
resolveParticipantGuidance?: AgentParticipantGuidanceResolver;
|
|
27
33
|
});
|
|
28
34
|
subscribeUi(listener: () => void): () => void;
|
|
29
35
|
spawn(request: AgentRunRequest, signal?: AbortSignal): Promise<AgentHandleInfo>;
|
|
@@ -51,4 +57,5 @@ export declare class AgentManager {
|
|
|
51
57
|
compact(id: string, instructions?: string): AgentSteerResult;
|
|
52
58
|
close(): Promise<void>;
|
|
53
59
|
}
|
|
60
|
+
export {};
|
|
54
61
|
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/agents/manager.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/agents/manager.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AAWzB,OAAO,KAAK,EAEV,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,EAEd,gBAAgB,EAIjB,MAAM,YAAY,CAAC;AAqBpB,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,uBAAuB,CAAC;AAkB/B,eAAO,MAAM,uBAAuB,GAClC,qBAAqB,MAAM,EAC3B,qBAAqB,MAAM,KAC1B,MAYF,CAAC;AAEF,UAAU,+BAA+B;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,KAAK,gCAAgC,GAAG,CACtC,OAAO,EAAE,+BAA+B,KACrC,MAAM,GAAG,SAAS,CAAC;AAgOxB,qBAAa,YAAY;;IAuCrB,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,QAAQ,CAAC,MAAM,EAAE,iBAAiB;gBADzB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB,EAClC,OAAO,GAAE;QACP,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACp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CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAUzD,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAsBzC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,UAAQ,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAa9E,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,cAAc;IAkBnF,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,gBAAgB;IAKpE,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,gBAAgB;IAgBvE,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,gBAAgB;IAIvE,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,gBAAgB;IAUvE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,gBAAgB;IA4BtD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAiiB7B"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// src/core/stable-hash.ts
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
var stableJsonValue = (value) => {
|
|
4
|
+
if (Array.isArray(value)) return value.map(stableJsonValue);
|
|
5
|
+
if (value instanceof URL) return value.href;
|
|
6
|
+
if (value === null || typeof value !== "object") return value;
|
|
7
|
+
return Object.fromEntries(
|
|
8
|
+
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, stableJsonValue(nested)])
|
|
9
|
+
);
|
|
10
|
+
};
|
|
11
|
+
var stableJsonHash = (value) => createHash("sha256").update(JSON.stringify(stableJsonValue(value))).digest("hex");
|
|
12
|
+
|
|
13
|
+
// src/components/model-guidance.ts
|
|
14
|
+
var FABRIC_EXECUTION_GUIDANCE_SLOT = "fabric.execution";
|
|
15
|
+
var MAX_FABRIC_MODEL_GUIDANCE_PER_COMPONENT = 64;
|
|
16
|
+
var MAX_FABRIC_MODEL_GUIDANCE_CONTENT_CHARS = 32e3;
|
|
17
|
+
var MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS = 64e3;
|
|
18
|
+
var MAX_FABRIC_MODEL_GUIDANCE_REGISTRATIONS = 1024;
|
|
19
|
+
var MAX_FABRIC_MODEL_GUIDANCE_SNAPSHOT_CHARS = 1e6;
|
|
20
|
+
var MAX_LABEL_CHARS = 128;
|
|
21
|
+
var MAX_SLOT_CHARS = 128;
|
|
22
|
+
var MAX_MODEL_PATTERNS = 32;
|
|
23
|
+
var MAX_MODEL_PATTERN_CHARS = 256;
|
|
24
|
+
var CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/;
|
|
25
|
+
var REGEX_CHARACTER = /[\\^$+.[\]{}()|]/;
|
|
26
|
+
var compareStableText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
27
|
+
var compareFabricOwnedModelGuidance = (left, right) => compareStableText(left.componentId, right.componentId) || compareStableText(left.label, right.label);
|
|
28
|
+
var guidanceError = (message) => new Error(`Invalid Fabric model guidance: ${message}`);
|
|
29
|
+
var normalizedIdentifier = (value, field, max) => {
|
|
30
|
+
if (typeof value !== "string") throw guidanceError(`${field} must be a string`);
|
|
31
|
+
const normalized = value.trim();
|
|
32
|
+
if (!normalized) throw guidanceError(`${field} must not be empty`);
|
|
33
|
+
if (normalized.length > max) throw guidanceError(`${field} exceeds ${max} characters`);
|
|
34
|
+
if (CONTROL_CHARACTER.test(normalized)) {
|
|
35
|
+
throw guidanceError(`${field} must not contain control characters`);
|
|
36
|
+
}
|
|
37
|
+
return normalized;
|
|
38
|
+
};
|
|
39
|
+
var normalizeTargets = (targets) => {
|
|
40
|
+
if (targets === void 0) return ["main", "participant"];
|
|
41
|
+
if (!Array.isArray(targets) || targets.length === 0) {
|
|
42
|
+
throw guidanceError("targets must contain main and/or participant");
|
|
43
|
+
}
|
|
44
|
+
const normalized = [];
|
|
45
|
+
for (const target of targets) {
|
|
46
|
+
if (target !== "main" && target !== "participant") {
|
|
47
|
+
throw guidanceError(`unsupported target ${String(target)}`);
|
|
48
|
+
}
|
|
49
|
+
if (!normalized.includes(target)) normalized.push(target);
|
|
50
|
+
}
|
|
51
|
+
return normalized;
|
|
52
|
+
};
|
|
53
|
+
var normalizeFabricModelGuidance = (guidance) => {
|
|
54
|
+
if (!guidance || typeof guidance !== "object" || Array.isArray(guidance)) {
|
|
55
|
+
throw guidanceError("registration must be an object");
|
|
56
|
+
}
|
|
57
|
+
const label = normalizedIdentifier(guidance.label, "label", MAX_LABEL_CHARS);
|
|
58
|
+
if (!Array.isArray(guidance.models) || guidance.models.length === 0) {
|
|
59
|
+
throw guidanceError(`${label} must select at least one provider/model pattern`);
|
|
60
|
+
}
|
|
61
|
+
if (guidance.models.length > MAX_MODEL_PATTERNS) {
|
|
62
|
+
throw guidanceError(`${label} selects more than ${MAX_MODEL_PATTERNS} model patterns`);
|
|
63
|
+
}
|
|
64
|
+
const models = [];
|
|
65
|
+
for (const candidate of guidance.models) {
|
|
66
|
+
if (typeof candidate !== "string") {
|
|
67
|
+
throw guidanceError(`${label} model patterns must be strings`);
|
|
68
|
+
}
|
|
69
|
+
const pattern = candidate.trim();
|
|
70
|
+
if (!pattern || pattern.length > MAX_MODEL_PATTERN_CHARS || !pattern.includes("/")) {
|
|
71
|
+
throw guidanceError(
|
|
72
|
+
`${label} model pattern ${JSON.stringify(candidate)} must be a provider/model glob of at most ${MAX_MODEL_PATTERN_CHARS} characters`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
if (CONTROL_CHARACTER.test(pattern)) {
|
|
76
|
+
throw guidanceError(`${label} model patterns must not contain control characters`);
|
|
77
|
+
}
|
|
78
|
+
if (!models.includes(pattern)) models.push(pattern);
|
|
79
|
+
}
|
|
80
|
+
if (typeof guidance.content !== "string" || !guidance.content.trim()) {
|
|
81
|
+
throw guidanceError(`${label} content must be a non-empty string`);
|
|
82
|
+
}
|
|
83
|
+
const content = guidance.content.trim();
|
|
84
|
+
if (content.length > MAX_FABRIC_MODEL_GUIDANCE_CONTENT_CHARS) {
|
|
85
|
+
throw guidanceError(
|
|
86
|
+
`${label} content exceeds ${MAX_FABRIC_MODEL_GUIDANCE_CONTENT_CHARS} characters`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const placement = guidance.placement ?? "append";
|
|
90
|
+
if (placement !== "append" && placement !== "replace") {
|
|
91
|
+
throw guidanceError(`${label} placement must be append or replace`);
|
|
92
|
+
}
|
|
93
|
+
const slot = guidance.slot === void 0 ? void 0 : normalizedIdentifier(guidance.slot, "slot", MAX_SLOT_CHARS);
|
|
94
|
+
if (placement === "replace" && !slot) {
|
|
95
|
+
throw guidanceError(`${label} replacement guidance requires a slot`);
|
|
96
|
+
}
|
|
97
|
+
if (placement === "append" && slot) {
|
|
98
|
+
throw guidanceError(`${label} append guidance must not declare a slot`);
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
label,
|
|
102
|
+
models,
|
|
103
|
+
content,
|
|
104
|
+
targets: normalizeTargets(guidance.targets),
|
|
105
|
+
placement,
|
|
106
|
+
...slot ? { slot } : {}
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
var parseFabricOwnedModelGuidance = (value) => {
|
|
110
|
+
if (!Array.isArray(value) || value.length > MAX_FABRIC_MODEL_GUIDANCE_REGISTRATIONS) return [];
|
|
111
|
+
try {
|
|
112
|
+
const parsed = value.map((candidate) => {
|
|
113
|
+
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
|
|
114
|
+
throw guidanceError("serialized owner must be an object");
|
|
115
|
+
}
|
|
116
|
+
const record = candidate;
|
|
117
|
+
const normalized = normalizeFabricModelGuidance(record);
|
|
118
|
+
if (typeof record.componentId !== "string" || !record.componentId.trim() || typeof record.component !== "string" || !record.component.trim() || !Number.isSafeInteger(record.revision) || (record.revision ?? 0) < 1) {
|
|
119
|
+
throw guidanceError("serialized owner metadata is incomplete");
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
...normalized,
|
|
123
|
+
componentId: record.componentId.trim(),
|
|
124
|
+
component: record.component.trim(),
|
|
125
|
+
revision: record.revision
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
if (parsed.reduce((sum, entry) => sum + entry.content.length, 0) > MAX_FABRIC_MODEL_GUIDANCE_SNAPSHOT_CHARS) return [];
|
|
129
|
+
return parsed;
|
|
130
|
+
} catch {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var fabricModelGuidanceInfo = (guidance) => ({
|
|
135
|
+
label: guidance.label,
|
|
136
|
+
models: [...guidance.models],
|
|
137
|
+
targets: [...guidance.targets],
|
|
138
|
+
placement: guidance.placement,
|
|
139
|
+
...guidance.slot ? { slot: guidance.slot } : {},
|
|
140
|
+
contentChars: guidance.content.length,
|
|
141
|
+
contentHash: stableJsonHash(guidance.content)
|
|
142
|
+
});
|
|
143
|
+
var wildcardMatch = (pattern, value) => {
|
|
144
|
+
let expression = "^";
|
|
145
|
+
for (const character of pattern) {
|
|
146
|
+
if (character === "*") expression += ".*";
|
|
147
|
+
else if (character === "?") expression += ".";
|
|
148
|
+
else expression += REGEX_CHARACTER.test(character) ? `\\${character}` : character;
|
|
149
|
+
}
|
|
150
|
+
return new RegExp(`${expression}$`, "u").test(value);
|
|
151
|
+
};
|
|
152
|
+
var fabricModelGuidanceMatches = (guidance, model, target) => guidance.targets.includes(target) && guidance.models.some((pattern) => wildcardMatch(pattern, model));
|
|
153
|
+
var sourceInfo = (guidance) => ({
|
|
154
|
+
componentId: guidance.componentId,
|
|
155
|
+
component: guidance.component,
|
|
156
|
+
label: guidance.label,
|
|
157
|
+
placement: guidance.placement,
|
|
158
|
+
...guidance.slot ? { slot: guidance.slot } : {},
|
|
159
|
+
contentHash: stableJsonHash(guidance.content)
|
|
160
|
+
});
|
|
161
|
+
var resolveFabricModelGuidance = (guidance, options) => {
|
|
162
|
+
const includeSlots = options.includeSlots !== false;
|
|
163
|
+
const matching = options.model ? guidance.filter((entry) => fabricModelGuidanceMatches(entry, options.model, options.target)) : [];
|
|
164
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
165
|
+
const additions = [];
|
|
166
|
+
for (const entry of matching) {
|
|
167
|
+
if (entry.placement === "append") {
|
|
168
|
+
additions.push(entry);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (!includeSlots || !entry.slot) continue;
|
|
172
|
+
const existing = replacements.get(entry.slot) ?? [];
|
|
173
|
+
existing.push(entry);
|
|
174
|
+
replacements.set(entry.slot, existing);
|
|
175
|
+
}
|
|
176
|
+
const defaultSlots = options.defaults ?? [];
|
|
177
|
+
const slotOrder = [
|
|
178
|
+
...defaultSlots.map((entry) => entry.slot),
|
|
179
|
+
...[...replacements.keys()].filter((slot) => !defaultSlots.some((entry) => entry.slot === slot)).sort(compareStableText)
|
|
180
|
+
];
|
|
181
|
+
const slotSections = [];
|
|
182
|
+
const sources = [];
|
|
183
|
+
if (includeSlots) {
|
|
184
|
+
for (const slot of slotOrder) {
|
|
185
|
+
const candidates = replacements.get(slot) ?? [];
|
|
186
|
+
if (candidates.length > 1) {
|
|
187
|
+
const owners = candidates.map((entry) => `${entry.componentId}:${entry.label}`).sort(compareStableText).join(", ");
|
|
188
|
+
throw new Error(
|
|
189
|
+
`Fabric guidance slot ${slot} has multiple replacements for ${options.model ?? "the current model"}: ${owners}`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
const replacement = candidates[0];
|
|
193
|
+
if (replacement) {
|
|
194
|
+
slotSections.push(replacement.content);
|
|
195
|
+
sources.push(sourceInfo(replacement));
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const fallback = defaultSlots.find((entry) => entry.slot === slot)?.content.trim();
|
|
199
|
+
if (fallback) slotSections.push(fallback);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
additions.sort(compareFabricOwnedModelGuidance);
|
|
203
|
+
for (const addition of additions) sources.push(sourceInfo(addition));
|
|
204
|
+
const appendSections = additions.map((entry) => entry.content);
|
|
205
|
+
const slotText = slotSections.join("\n\n");
|
|
206
|
+
const appendText = appendSections.join("\n\n");
|
|
207
|
+
const resolvedChars = slotText.length + appendText.length + (slotText && appendText ? 2 : 0);
|
|
208
|
+
if (resolvedChars > MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
`Resolved Fabric model guidance exceeds ${MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS} characters for ${options.model ?? "the current model"}`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
slotText,
|
|
215
|
+
appendText,
|
|
216
|
+
sources,
|
|
217
|
+
digest: stableJsonHash({
|
|
218
|
+
model: options.model,
|
|
219
|
+
target: options.target,
|
|
220
|
+
slots: slotSections,
|
|
221
|
+
additions: sources
|
|
222
|
+
})
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export {
|
|
227
|
+
stableJsonHash,
|
|
228
|
+
FABRIC_EXECUTION_GUIDANCE_SLOT,
|
|
229
|
+
MAX_FABRIC_MODEL_GUIDANCE_PER_COMPONENT,
|
|
230
|
+
MAX_FABRIC_MODEL_GUIDANCE_CONTENT_CHARS,
|
|
231
|
+
MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS,
|
|
232
|
+
MAX_FABRIC_MODEL_GUIDANCE_REGISTRATIONS,
|
|
233
|
+
MAX_FABRIC_MODEL_GUIDANCE_SNAPSHOT_CHARS,
|
|
234
|
+
compareFabricOwnedModelGuidance,
|
|
235
|
+
normalizeFabricModelGuidance,
|
|
236
|
+
parseFabricOwnedModelGuidance,
|
|
237
|
+
fabricModelGuidanceInfo,
|
|
238
|
+
resolveFabricModelGuidance
|
|
239
|
+
};
|
|
240
|
+
//# sourceMappingURL=chunk-22RY7UMR.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/core/stable-hash.ts", "../../src/components/model-guidance.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash } from \"node:crypto\";\n\n// Deterministic JSON shaping for hashing: object keys sort recursively so\n// equivalent values hash identically regardless of key insertion order. URL\n// instances hash by href \u2014 they expose no enumerable own properties, so\n// untreated they would all collapse to \"{}\" (MCP server definitions carry\n// `URL` instances for HTTP transports).\nconst stableJsonValue = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(stableJsonValue);\n if (value instanceof URL) return value.href;\n if (value === null || typeof value !== \"object\") return value;\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, nested]) => [key, stableJsonValue(nested)]),\n );\n};\n\nexport const stableJsonHash = (value: unknown): string =>\n createHash(\"sha256\").update(JSON.stringify(stableJsonValue(value))).digest(\"hex\");\n", "import { stableJsonHash } from \"../core/stable-hash.js\";\nimport type {\n FabricModelGuidance,\n FabricModelGuidanceInfo,\n FabricModelGuidancePlacement,\n FabricModelGuidanceTarget,\n} from \"./types.js\";\n\nexport const FABRIC_EXECUTION_GUIDANCE_SLOT = \"fabric.execution\";\nexport const MAX_FABRIC_MODEL_GUIDANCE_PER_COMPONENT = 64;\nexport const MAX_FABRIC_MODEL_GUIDANCE_CONTENT_CHARS = 32_000;\nexport const MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS = 64_000;\nexport const MAX_FABRIC_MODEL_GUIDANCE_REGISTRATIONS = 1_024;\nexport const MAX_FABRIC_MODEL_GUIDANCE_SNAPSHOT_CHARS = 1_000_000;\n\nconst MAX_LABEL_CHARS = 128;\nconst MAX_SLOT_CHARS = 128;\nconst MAX_MODEL_PATTERNS = 32;\nconst MAX_MODEL_PATTERN_CHARS = 256;\nconst CONTROL_CHARACTER = /[\\u0000-\\u001f\\u007f]/;\nconst REGEX_CHARACTER = /[\\\\^$+.[\\]{}()|]/;\n\nexport interface NormalizedFabricModelGuidance {\n label: string;\n models: string[];\n content: string;\n targets: FabricModelGuidanceTarget[];\n placement: FabricModelGuidancePlacement;\n slot?: string;\n}\n\nexport interface FabricOwnedModelGuidance extends NormalizedFabricModelGuidance {\n componentId: string;\n component: string;\n revision: number;\n}\n\nconst compareStableText = (left: string, right: string): number =>\n left < right ? -1 : left > right ? 1 : 0;\n\nexport const compareFabricOwnedModelGuidance = (\n left: FabricOwnedModelGuidance,\n right: FabricOwnedModelGuidance,\n): number =>\n compareStableText(left.componentId, right.componentId) ||\n compareStableText(left.label, right.label);\n\nexport interface FabricGuidanceDefaultSlot {\n slot: string;\n content: string;\n}\n\nexport interface FabricResolvedModelGuidance {\n slotText: string;\n appendText: string;\n digest: string;\n sources: Array<{\n componentId: string;\n component: string;\n label: string;\n placement: FabricModelGuidancePlacement;\n slot?: string;\n contentHash: string;\n }>;\n}\n\nconst guidanceError = (message: string): Error =>\n new Error(`Invalid Fabric model guidance: ${message}`);\n\nconst normalizedIdentifier = (value: unknown, field: \"label\" | \"slot\", max: number): string => {\n if (typeof value !== \"string\") throw guidanceError(`${field} must be a string`);\n const normalized = value.trim();\n if (!normalized) throw guidanceError(`${field} must not be empty`);\n if (normalized.length > max) throw guidanceError(`${field} exceeds ${max} characters`);\n if (CONTROL_CHARACTER.test(normalized)) {\n throw guidanceError(`${field} must not contain control characters`);\n }\n return normalized;\n};\n\nconst normalizeTargets = (\n targets: readonly FabricModelGuidanceTarget[] | undefined,\n): FabricModelGuidanceTarget[] => {\n if (targets === undefined) return [\"main\", \"participant\"];\n if (!Array.isArray(targets) || targets.length === 0) {\n throw guidanceError(\"targets must contain main and/or participant\");\n }\n const normalized: FabricModelGuidanceTarget[] = [];\n for (const target of targets) {\n if (target !== \"main\" && target !== \"participant\") {\n throw guidanceError(`unsupported target ${String(target)}`);\n }\n if (!normalized.includes(target)) normalized.push(target);\n }\n return normalized;\n};\n\nexport const normalizeFabricModelGuidance = (\n guidance: FabricModelGuidance,\n): NormalizedFabricModelGuidance => {\n if (!guidance || typeof guidance !== \"object\" || Array.isArray(guidance)) {\n throw guidanceError(\"registration must be an object\");\n }\n const label = normalizedIdentifier(guidance.label, \"label\", MAX_LABEL_CHARS);\n if (!Array.isArray(guidance.models) || guidance.models.length === 0) {\n throw guidanceError(`${label} must select at least one provider/model pattern`);\n }\n if (guidance.models.length > MAX_MODEL_PATTERNS) {\n throw guidanceError(`${label} selects more than ${MAX_MODEL_PATTERNS} model patterns`);\n }\n const models: string[] = [];\n for (const candidate of guidance.models) {\n if (typeof candidate !== \"string\") {\n throw guidanceError(`${label} model patterns must be strings`);\n }\n const pattern = candidate.trim();\n if (!pattern || pattern.length > MAX_MODEL_PATTERN_CHARS || !pattern.includes(\"/\")) {\n throw guidanceError(\n `${label} model pattern ${JSON.stringify(candidate)} must be a provider/model glob of at most ${MAX_MODEL_PATTERN_CHARS} characters`,\n );\n }\n if (CONTROL_CHARACTER.test(pattern)) {\n throw guidanceError(`${label} model patterns must not contain control characters`);\n }\n if (!models.includes(pattern)) models.push(pattern);\n }\n if (typeof guidance.content !== \"string\" || !guidance.content.trim()) {\n throw guidanceError(`${label} content must be a non-empty string`);\n }\n const content = guidance.content.trim();\n if (content.length > MAX_FABRIC_MODEL_GUIDANCE_CONTENT_CHARS) {\n throw guidanceError(\n `${label} content exceeds ${MAX_FABRIC_MODEL_GUIDANCE_CONTENT_CHARS} characters`,\n );\n }\n const placement = guidance.placement ?? \"append\";\n if (placement !== \"append\" && placement !== \"replace\") {\n throw guidanceError(`${label} placement must be append or replace`);\n }\n const slot = guidance.slot === undefined\n ? undefined\n : normalizedIdentifier(guidance.slot, \"slot\", MAX_SLOT_CHARS);\n if (placement === \"replace\" && !slot) {\n throw guidanceError(`${label} replacement guidance requires a slot`);\n }\n if (placement === \"append\" && slot) {\n throw guidanceError(`${label} append guidance must not declare a slot`);\n }\n return {\n label,\n models,\n content,\n targets: normalizeTargets(guidance.targets),\n placement,\n ...(slot ? { slot } : {}),\n };\n};\n\nexport const parseFabricOwnedModelGuidance = (value: unknown): FabricOwnedModelGuidance[] => {\n if (!Array.isArray(value) || value.length > MAX_FABRIC_MODEL_GUIDANCE_REGISTRATIONS) return [];\n try {\n const parsed = value.map((candidate) => {\n if (!candidate || typeof candidate !== \"object\" || Array.isArray(candidate)) {\n throw guidanceError(\"serialized owner must be an object\");\n }\n const record = candidate as Partial<FabricOwnedModelGuidance>;\n const normalized = normalizeFabricModelGuidance(record as FabricModelGuidance);\n if (\n typeof record.componentId !== \"string\" ||\n !record.componentId.trim() ||\n typeof record.component !== \"string\" ||\n !record.component.trim() ||\n !Number.isSafeInteger(record.revision) ||\n (record.revision ?? 0) < 1\n ) {\n throw guidanceError(\"serialized owner metadata is incomplete\");\n }\n return {\n ...normalized,\n componentId: record.componentId.trim(),\n component: record.component.trim(),\n revision: record.revision!,\n };\n });\n if (parsed.reduce((sum, entry) => sum + entry.content.length, 0) >\n MAX_FABRIC_MODEL_GUIDANCE_SNAPSHOT_CHARS) return [];\n return parsed;\n } catch {\n return [];\n }\n};\n\nexport const fabricModelGuidanceInfo = (\n guidance: NormalizedFabricModelGuidance,\n): FabricModelGuidanceInfo => ({\n label: guidance.label,\n models: [...guidance.models],\n targets: [...guidance.targets],\n placement: guidance.placement,\n ...(guidance.slot ? { slot: guidance.slot } : {}),\n contentChars: guidance.content.length,\n contentHash: stableJsonHash(guidance.content),\n});\n\nconst wildcardMatch = (pattern: string, value: string): boolean => {\n let expression = \"^\";\n for (const character of pattern) {\n if (character === \"*\") expression += \".*\";\n else if (character === \"?\") expression += \".\";\n else expression += REGEX_CHARACTER.test(character) ? `\\\\${character}` : character;\n }\n return new RegExp(`${expression}$`, \"u\").test(value);\n};\n\nconst fabricModelGuidanceMatches = (\n guidance: NormalizedFabricModelGuidance,\n model: string,\n target: FabricModelGuidanceTarget,\n): boolean =>\n guidance.targets.includes(target) && guidance.models.some((pattern) => wildcardMatch(pattern, model));\n\nconst sourceInfo = (guidance: FabricOwnedModelGuidance) => ({\n componentId: guidance.componentId,\n component: guidance.component,\n label: guidance.label,\n placement: guidance.placement,\n ...(guidance.slot ? { slot: guidance.slot } : {}),\n contentHash: stableJsonHash(guidance.content),\n});\n\nexport const resolveFabricModelGuidance = (\n guidance: readonly FabricOwnedModelGuidance[],\n options: {\n model?: string;\n target: FabricModelGuidanceTarget;\n defaults?: readonly FabricGuidanceDefaultSlot[];\n includeSlots?: boolean;\n },\n): FabricResolvedModelGuidance => {\n const includeSlots = options.includeSlots !== false;\n const matching = options.model\n ? guidance.filter((entry) => fabricModelGuidanceMatches(entry, options.model!, options.target))\n : [];\n const replacements = new Map<string, FabricOwnedModelGuidance[]>();\n const additions: FabricOwnedModelGuidance[] = [];\n for (const entry of matching) {\n if (entry.placement === \"append\") {\n additions.push(entry);\n continue;\n }\n if (!includeSlots || !entry.slot) continue;\n const existing = replacements.get(entry.slot) ?? [];\n existing.push(entry);\n replacements.set(entry.slot, existing);\n }\n\n const defaultSlots = options.defaults ?? [];\n const slotOrder = [\n ...defaultSlots.map((entry) => entry.slot),\n ...[...replacements.keys()]\n .filter((slot) => !defaultSlots.some((entry) => entry.slot === slot))\n .sort(compareStableText),\n ];\n const slotSections: string[] = [];\n const sources: FabricResolvedModelGuidance[\"sources\"] = [];\n if (includeSlots) {\n for (const slot of slotOrder) {\n const candidates = replacements.get(slot) ?? [];\n if (candidates.length > 1) {\n const owners = candidates\n .map((entry) => `${entry.componentId}:${entry.label}`)\n .sort(compareStableText)\n .join(\", \");\n throw new Error(\n `Fabric guidance slot ${slot} has multiple replacements for ${options.model ?? \"the current model\"}: ${owners}`,\n );\n }\n const replacement = candidates[0];\n if (replacement) {\n slotSections.push(replacement.content);\n sources.push(sourceInfo(replacement));\n continue;\n }\n const fallback = defaultSlots.find((entry) => entry.slot === slot)?.content.trim();\n if (fallback) slotSections.push(fallback);\n }\n }\n\n additions.sort(compareFabricOwnedModelGuidance);\n for (const addition of additions) sources.push(sourceInfo(addition));\n const appendSections = additions.map((entry) => entry.content);\n const slotText = slotSections.join(\"\\n\\n\");\n const appendText = appendSections.join(\"\\n\\n\");\n const resolvedChars = slotText.length + appendText.length +\n (slotText && appendText ? 2 : 0);\n if (resolvedChars > MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS) {\n throw new Error(\n `Resolved Fabric model guidance exceeds ${MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS} characters for ${options.model ?? \"the current model\"}`,\n );\n }\n return {\n slotText,\n appendText,\n sources,\n digest: stableJsonHash({\n model: options.model,\n target: options.target,\n slots: slotSections,\n additions: sources,\n }),\n };\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,kBAAkB;AAO3B,IAAM,kBAAkB,CAAC,UAA4B;AACnD,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,eAAe;AAC1D,MAAI,iBAAiB,IAAK,QAAO,MAAM;AACvC,MAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,KAAgC,EAC5C,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MAAM,KAAK,cAAc,KAAK,CAAC,EACnD,IAAI,CAAC,CAAC,KAAK,MAAM,MAAM,CAAC,KAAK,gBAAgB,MAAM,CAAC,CAAC;AAAA,EAC1D;AACF;AAEO,IAAM,iBAAiB,CAAC,UAC7B,WAAW,QAAQ,EAAE,OAAO,KAAK,UAAU,gBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,KAAK;;;ACX3E,IAAM,iCAAiC;A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ACA,YAAM,WAAW,aAAa,KAAK,CAAC,UAAU,MAAM,SAAS,IAAI,GAAG,QAAQ,KAAK;AACjF,UAAI,SAAU,cAAa,KAAK,QAAQ;AAAA,IAC1C;AAAA,EACF;AAEA,YAAU,KAAK,+BAA+B;AAC9C,aAAW,YAAY,UAAW,SAAQ,KAAK,WAAW,QAAQ,CAAC;AACnE,QAAM,iBAAiB,UAAU,IAAI,CAAC,UAAU,MAAM,OAAO;AAC7D,QAAM,WAAW,aAAa,KAAK,MAAM;AACzC,QAAM,aAAa,eAAe,KAAK,MAAM;AAC7C,QAAM,gBAAgB,SAAS,SAAS,WAAW,UAChD,YAAY,aAAa,IAAI;AAChC,MAAI,gBAAgB,uCAAuC;AACzD,UAAM,IAAI;AAAA,MACR,0CAA0C,qCAAqC,mBAAmB,QAAQ,SAAS,mBAAmB;AAAA,IACxI;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,eAAe;AAAA,MACrB,OAAO,QAAQ;AAAA,MACf,QAAQ,QAAQ;AAAA,MAChB,OAAO;AAAA,MACP,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1628,6 +1628,7 @@ var AgentManager = class {
|
|
|
1628
1628
|
this.#onBackgroundComplete = options.onBackgroundComplete;
|
|
1629
1629
|
this.#onLifecycle = options.onLifecycle;
|
|
1630
1630
|
this.#preparePiModel = options.preparePiModel;
|
|
1631
|
+
this.#resolveParticipantGuidance = options.resolveParticipantGuidance;
|
|
1631
1632
|
this.#currentDepth = Math.max(0, Number(process.env.PI_FABRIC_DEPTH ?? "0") || 0);
|
|
1632
1633
|
this.#fullCodeMode = options.fullCodeMode ?? true;
|
|
1633
1634
|
this.#mainAgentId = options.mainAgentId ?? process.env.PI_FABRIC_MAIN_AGENT_ID;
|
|
@@ -1680,6 +1681,7 @@ var AgentManager = class {
|
|
|
1680
1681
|
#onBackgroundComplete;
|
|
1681
1682
|
#onLifecycle;
|
|
1682
1683
|
#preparePiModel;
|
|
1684
|
+
#resolveParticipantGuidance;
|
|
1683
1685
|
#piModelPreparations = /* @__PURE__ */ new Map();
|
|
1684
1686
|
#budget;
|
|
1685
1687
|
#budgetOwned;
|
|
@@ -1817,6 +1819,8 @@ var AgentManager = class {
|
|
|
1817
1819
|
const thinking = request.thinking ?? this.config.thinking;
|
|
1818
1820
|
const recursive = runner === "pi" && request.recursive === true;
|
|
1819
1821
|
const extensions = recursive ? true : request.extensions ?? this.config.extensions;
|
|
1822
|
+
const componentGuidance = recursive ? void 0 : this.#resolveParticipantGuidance?.({ ...model ? { model } : {}, runner })?.trim();
|
|
1823
|
+
const systemPrompt = [request.systemPrompt?.trim(), componentGuidance].filter((section) => Boolean(section)).join("\n\n") || void 0;
|
|
1820
1824
|
const sessionExportDir = resolveSessionExportDir(this.config);
|
|
1821
1825
|
const sessionExportFile = sessionExportDir ? sessionExportFileFor(sessionExportDir, agentCwd, id, /* @__PURE__ */ new Date()) : void 0;
|
|
1822
1826
|
const workerArguments = [
|
|
@@ -1866,7 +1870,7 @@ var AgentManager = class {
|
|
|
1866
1870
|
...recursive ? ["--fabric-extension", this.#fabricExtensionPath] : [],
|
|
1867
1871
|
...model ? ["--model", model] : [],
|
|
1868
1872
|
...thinking ? ["--thinking", thinking] : [],
|
|
1869
|
-
...
|
|
1873
|
+
...systemPrompt ? ["--system-prompt", systemPrompt] : [],
|
|
1870
1874
|
...sessionFile ? ["--session-file", sessionFile] : [],
|
|
1871
1875
|
...sessionExportFile ? ["--session-export-file", sessionExportFile] : [],
|
|
1872
1876
|
...request.actorId ? ["--actor-id", request.actorId] : [],
|
|
@@ -6118,4 +6122,4 @@ export {
|
|
|
6118
6122
|
residentRoot,
|
|
6119
6123
|
residentDeliveryPrefix
|
|
6120
6124
|
};
|
|
6121
|
-
//# sourceMappingURL=chunk-
|
|
6125
|
+
//# sourceMappingURL=chunk-5KEG4TKY.js.map
|