@e4779/pi-fabric 0.92.24-fork.4 → 0.92.28-fork.5
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/actors/host-event-payload.d.ts.map +1 -1
- package/dist/agents/request.d.ts +4 -0
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents.js +2 -1
- package/dist/agents.js.map +1 -1
- package/dist/chunks/{chunk-VYXFSUWU.js → chunk-77PDIBK2.js} +12 -1
- package/dist/chunks/{chunk-VYXFSUWU.js.map → chunk-77PDIBK2.js.map} +2 -2
- package/dist/chunks/chunk-7TX532EG.js +134 -0
- package/dist/chunks/chunk-7TX532EG.js.map +7 -0
- package/dist/chunks/chunk-BJOJX2UW.js +59 -0
- package/dist/chunks/chunk-BJOJX2UW.js.map +7 -0
- package/dist/chunks/{chunk-2PZWDVJB.js → chunk-BYOGRJME.js} +13 -4
- package/dist/chunks/chunk-BYOGRJME.js.map +7 -0
- package/dist/chunks/{chunk-RERA6YWA.js → chunk-CIODQX77.js} +12 -4
- package/dist/chunks/chunk-CIODQX77.js.map +7 -0
- package/dist/chunks/{chunk-ZMIJ6AT4.js → chunk-D6YSBP3R.js} +2 -2
- package/dist/chunks/{chunk-WVH324VF.js → chunk-FAMBJFFF.js} +1 -1
- package/dist/chunks/{chunk-WVH324VF.js.map → chunk-FAMBJFFF.js.map} +1 -1
- package/dist/chunks/{chunk-VWSXAEX6.js → chunk-G7UJLM33.js} +6 -198
- package/dist/chunks/chunk-G7UJLM33.js.map +7 -0
- package/dist/chunks/chunk-JNMTTJMQ.js +50 -0
- package/dist/chunks/chunk-JNMTTJMQ.js.map +7 -0
- package/dist/chunks/{chunk-KFZYTGF5.js → chunk-JOEFBOFN.js} +7 -3
- package/dist/chunks/chunk-JOEFBOFN.js.map +7 -0
- package/dist/chunks/chunk-KI277YNS.js +218 -0
- package/dist/chunks/chunk-KI277YNS.js.map +7 -0
- package/dist/chunks/{chunk-Y7KNRAFL.js → chunk-M3ZNZ6EZ.js} +28 -3
- package/dist/chunks/chunk-M3ZNZ6EZ.js.map +7 -0
- package/dist/chunks/{chunk-QX3TUAWO.js → chunk-M7W57BRC.js} +2 -2
- package/dist/chunks/{chunk-4SSMGBF4.js → chunk-QLV2IZ3F.js} +6 -7
- package/dist/chunks/chunk-QLV2IZ3F.js.map +7 -0
- package/dist/chunks/{chunk-7OH6DD3S.js → chunk-RAEGNBRA.js} +2 -2
- package/dist/chunks/{chunk-BOTRGFQQ.js → chunk-RWDKJ24D.js} +26 -19
- package/dist/chunks/chunk-RWDKJ24D.js.map +7 -0
- package/dist/chunks/{chunk-3CPWRPCE.js → chunk-RZKN534S.js} +2 -2
- package/dist/chunks/{chunk-3ZX76BVU.js → chunk-ULLIZPBH.js} +7 -7
- package/dist/chunks/{chunk-32BNQ75J.js → chunk-WG24VI7K.js} +56 -2
- package/dist/chunks/{chunk-32BNQ75J.js.map → chunk-WG24VI7K.js.map} +2 -2
- package/dist/chunks/{chunk-4JETKRFE.js → chunk-ZHJNWM6A.js} +2 -2
- package/dist/components/configuration.d.ts +42 -0
- package/dist/components/configuration.d.ts.map +1 -0
- package/dist/components/configuration.js +18 -0
- package/dist/components/configuration.js.map +7 -0
- package/dist/components/control.d.ts +76 -0
- package/dist/components/control.d.ts.map +1 -0
- package/dist/components/loader.d.ts +12 -0
- package/dist/components/loader.d.ts.map +1 -1
- package/dist/components/supervisor.d.ts.map +1 -1
- package/dist/components/types.d.ts +2 -0
- package/dist/components/types.d.ts.map +1 -1
- package/dist/components/validation.d.ts +6 -0
- package/dist/components/validation.d.ts.map +1 -0
- package/dist/config.d.ts +4 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/core/action-registry.d.ts +1 -0
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +2 -2
- package/dist/core/media-sanitize.d.ts +45 -0
- package/dist/core/media-sanitize.d.ts.map +1 -0
- package/dist/core/model-resolution.d.ts +20 -3
- package/dist/core/model-resolution.d.ts.map +1 -1
- package/dist/execution-service.d.ts +3 -1
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/fabric-exec-tool.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +398 -47
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/index.js +64 -17
- package/dist/index.js.map +2 -2
- package/dist/jev/browser.d.ts.map +1 -1
- package/dist/jev/browser.js +1 -1
- package/dist/jev/observation.js +3 -2
- package/dist/jev.js +5 -4
- package/dist/output-budget.d.ts.map +1 -1
- package/dist/protocol.d.ts +1 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +1 -1
- package/dist/providers/agents-actions.d.ts.map +1 -1
- package/dist/providers/captured-tools-provider.d.ts.map +1 -1
- package/dist/providers/components-provider.d.ts +5 -3
- package/dist/providers/components-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.js +4 -3
- package/dist/residency/actor-client.d.ts +2 -2
- package/dist/residency/actor-client.d.ts.map +1 -1
- package/dist/residency/actor-client.js +2 -2
- package/dist/residency/client.d.ts.map +1 -1
- package/dist/residency/host.js +5 -4
- package/dist/residency/pi-entry.js +5 -4
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/residency/protocol.d.ts +11 -2
- package/dist/residency/protocol.d.ts.map +1 -1
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/monty-runtime.js +2 -1
- package/dist/runtime/monty-runtime.js.map +1 -1
- package/dist/runtime/node-process-runtime.d.ts.map +1 -1
- package/dist/runtime/node-process-runtime.js +2 -2
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +1 -1
- package/dist/runtime/typescript-kernel.js +7 -7
- package/dist/schema/policy.d.ts.map +1 -1
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/settings.js +2 -1
- package/dist/ui/settings.js.map +1 -1
- package/dist/ui/widget.d.ts +12 -1
- package/dist/ui/widget.d.ts.map +1 -1
- package/dist/worker.js +11 -3
- package/dist/worker.js.map +2 -2
- package/docs/architecture.md +1 -1
- package/docs/components.md +30 -1
- package/docs/configuration.md +5 -3
- package/docs/jev.md +66 -1
- package/package.json +1 -1
- package/skillsets/typescript/fabric-exec/SKILL.md +5 -1
- package/skillsets/typescript/fabric-exec/references/agents.md +2 -0
- package/dist/chunks/chunk-2PZWDVJB.js.map +0 -7
- package/dist/chunks/chunk-4SSMGBF4.js.map +0 -7
- package/dist/chunks/chunk-BOTRGFQQ.js.map +0 -7
- package/dist/chunks/chunk-KFZYTGF5.js.map +0 -7
- package/dist/chunks/chunk-RERA6YWA.js.map +0 -7
- package/dist/chunks/chunk-TSRKCXNI.js +0 -17
- package/dist/chunks/chunk-TSRKCXNI.js.map +0 -7
- package/dist/chunks/chunk-VWSXAEX6.js.map +0 -7
- package/dist/chunks/chunk-Y7KNRAFL.js.map +0 -7
- /package/dist/chunks/{chunk-ZMIJ6AT4.js.map → chunk-D6YSBP3R.js.map} +0 -0
- /package/dist/chunks/{chunk-QX3TUAWO.js.map → chunk-M7W57BRC.js.map} +0 -0
- /package/dist/chunks/{chunk-7OH6DD3S.js.map → chunk-RAEGNBRA.js.map} +0 -0
- /package/dist/chunks/{chunk-3CPWRPCE.js.map → chunk-RZKN534S.js.map} +0 -0
- /package/dist/chunks/{chunk-3ZX76BVU.js.map → chunk-ULLIZPBH.js.map} +0 -0
- /package/dist/chunks/{chunk-4JETKRFE.js.map → chunk-ZHJNWM6A.js.map} +0 -0
|
@@ -6,12 +6,19 @@ import {
|
|
|
6
6
|
piBashExitMetadata,
|
|
7
7
|
piBashResultError
|
|
8
8
|
} from "./chunks/chunk-PAN6C3JM.js";
|
|
9
|
+
import {
|
|
10
|
+
COMPONENT_ID_PATTERN,
|
|
11
|
+
FabricComponentConfiguration,
|
|
12
|
+
componentEntries,
|
|
13
|
+
validateComponentConfig,
|
|
14
|
+
watchComponentConfiguration
|
|
15
|
+
} from "./chunks/chunk-7TX532EG.js";
|
|
9
16
|
import {
|
|
10
17
|
WorkerMemoryProvider
|
|
11
18
|
} from "./chunks/chunk-EDL4JDW7.js";
|
|
12
19
|
import {
|
|
13
20
|
ResidentActorClient
|
|
14
|
-
} from "./chunks/chunk-
|
|
21
|
+
} from "./chunks/chunk-RWDKJ24D.js";
|
|
15
22
|
import {
|
|
16
23
|
FABRIC_COMPONENT_PROVIDER_NAMES,
|
|
17
24
|
FABRIC_PROVIDER_COMPONENT_PREFIX,
|
|
@@ -26,7 +33,7 @@ import {
|
|
|
26
33
|
expandSkillDirMarkersForRead,
|
|
27
34
|
resolveFabricIdentity,
|
|
28
35
|
runFabricHandoffAtBoundary
|
|
29
|
-
} from "./chunks/chunk-
|
|
36
|
+
} from "./chunks/chunk-M7W57BRC.js";
|
|
30
37
|
import {
|
|
31
38
|
AgentTranscriptReader,
|
|
32
39
|
MAX_WRITE_DIFF_BYTES,
|
|
@@ -39,7 +46,7 @@ import {
|
|
|
39
46
|
ActionRegistry,
|
|
40
47
|
fabricActionListLimit,
|
|
41
48
|
repairActionName
|
|
42
|
-
} from "./chunks/chunk-
|
|
49
|
+
} from "./chunks/chunk-JOEFBOFN.js";
|
|
43
50
|
import {
|
|
44
51
|
formatFabricEffectConflict
|
|
45
52
|
} from "./chunks/chunk-LMAVZN7J.js";
|
|
@@ -60,14 +67,14 @@ import "./chunks/chunk-IGVDD2HT.js";
|
|
|
60
67
|
import {
|
|
61
68
|
AGENTS_ACTION_DESCRIPTORS,
|
|
62
69
|
normalizeAgentRunRequest
|
|
63
|
-
} from "./chunks/chunk-
|
|
70
|
+
} from "./chunks/chunk-BYOGRJME.js";
|
|
64
71
|
import {
|
|
65
72
|
actionArgNormalizer,
|
|
66
73
|
uniqueDeclaredKeyForSpelling
|
|
67
74
|
} from "./chunks/chunk-NQOEHX62.js";
|
|
68
75
|
import {
|
|
69
76
|
prepareFabricActorHostPayload
|
|
70
|
-
} from "./chunks/chunk-
|
|
77
|
+
} from "./chunks/chunk-QLV2IZ3F.js";
|
|
71
78
|
import {
|
|
72
79
|
ApprovalController,
|
|
73
80
|
FabricAutoApprovalClassifier,
|
|
@@ -90,7 +97,11 @@ import {
|
|
|
90
97
|
FABRIC_PROVIDER_DISCOVER_EVENT,
|
|
91
98
|
FABRIC_TOOL_RESULT_PROXY_KIND,
|
|
92
99
|
readFabricToolResultProxyDetailsV1
|
|
93
|
-
} from "./chunks/chunk-
|
|
100
|
+
} from "./chunks/chunk-FAMBJFFF.js";
|
|
101
|
+
import {
|
|
102
|
+
sanitizeFabricMediaText,
|
|
103
|
+
sanitizeFabricMediaValue
|
|
104
|
+
} from "./chunks/chunk-BJOJX2UW.js";
|
|
94
105
|
import {
|
|
95
106
|
ActorDirectory,
|
|
96
107
|
ActorRegistryOwnershipError,
|
|
@@ -112,7 +123,7 @@ import {
|
|
|
112
123
|
resolveInheritedSessionPins,
|
|
113
124
|
resolvePiBinary,
|
|
114
125
|
withInheritedSessionPins
|
|
115
|
-
} from "./chunks/chunk-
|
|
126
|
+
} from "./chunks/chunk-RAEGNBRA.js";
|
|
116
127
|
import {
|
|
117
128
|
executeFile,
|
|
118
129
|
processIsAlive,
|
|
@@ -122,10 +133,12 @@ import "./chunks/chunk-VPPIJRNZ.js";
|
|
|
122
133
|
import "./chunks/chunk-PM5I335G.js";
|
|
123
134
|
import {
|
|
124
135
|
RESIDENT_HOST_FORMAT,
|
|
136
|
+
abandonResidentRequest,
|
|
125
137
|
residentDeliveryPrefix,
|
|
126
138
|
residentHostId,
|
|
127
|
-
residentRoot
|
|
128
|
-
|
|
139
|
+
residentRoot,
|
|
140
|
+
sleepUnlessAborted
|
|
141
|
+
} from "./chunks/chunk-JNMTTJMQ.js";
|
|
129
142
|
import {
|
|
130
143
|
checkedHandoffCompaction
|
|
131
144
|
} from "./chunks/chunk-2IAVP4O2.js";
|
|
@@ -138,7 +151,6 @@ import {
|
|
|
138
151
|
import {
|
|
139
152
|
DEFAULT_FABRIC_CONFIG,
|
|
140
153
|
DEFAULT_SHELL_HANG_MS,
|
|
141
|
-
FUZZY_RESOLUTION_MARKERS,
|
|
142
154
|
FabricShellJobStore,
|
|
143
155
|
MAX_AGENT_TIMEOUT_MS,
|
|
144
156
|
MIN_AGENT_TIMEOUT_MS,
|
|
@@ -146,10 +158,8 @@ import {
|
|
|
146
158
|
formatShellHangNotice,
|
|
147
159
|
loadFabricConfig,
|
|
148
160
|
raceShellHang,
|
|
149
|
-
resolveAvailablePiModel,
|
|
150
|
-
resolveFabricModel,
|
|
151
161
|
trackShellOperations
|
|
152
|
-
} from "./chunks/chunk-
|
|
162
|
+
} from "./chunks/chunk-G7UJLM33.js";
|
|
153
163
|
import "./chunks/chunk-OKOHRXGF.js";
|
|
154
164
|
import "./chunks/chunk-RAO6TQFP.js";
|
|
155
165
|
import {
|
|
@@ -170,6 +180,11 @@ import {
|
|
|
170
180
|
FABRIC_ACTOR_HOST_EVENTS,
|
|
171
181
|
isFabricActorHostEvent
|
|
172
182
|
} from "./chunks/chunk-OTCASLY2.js";
|
|
183
|
+
import {
|
|
184
|
+
FUZZY_RESOLUTION_MARKERS,
|
|
185
|
+
resolveAvailablePiModel,
|
|
186
|
+
resolveFabricModel
|
|
187
|
+
} from "./chunks/chunk-KI277YNS.js";
|
|
173
188
|
import {
|
|
174
189
|
isFabricThinking
|
|
175
190
|
} from "./chunks/chunk-MGWQOKBV.js";
|
|
@@ -1068,7 +1083,7 @@ var FabricEffectScope = class {
|
|
|
1068
1083
|
};
|
|
1069
1084
|
|
|
1070
1085
|
// src/components/supervisor.ts
|
|
1071
|
-
var
|
|
1086
|
+
var COMPONENT_ID_PATTERN2 = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
|
|
1072
1087
|
var PROVIDER_NAME_PATTERN = /^[a-z][a-z0-9_-]*$/;
|
|
1073
1088
|
var MAX_COMPONENT_EFFECTS = 256;
|
|
1074
1089
|
var MAX_SUPERVISED_COMPONENTS = 1024;
|
|
@@ -1407,7 +1422,7 @@ var FabricComponentSupervisor = class {
|
|
|
1407
1422
|
const sequence = ++parent.childSequence;
|
|
1408
1423
|
const rawLocalId = options.id ?? `${definition.name}-${sequence}`;
|
|
1409
1424
|
const localId = options.id ? rawLocalId : rawLocalId.replace(/[^a-zA-Z0-9._-]/g, "-").replace(/^[^a-zA-Z0-9]+/, "") || `child-${sequence}`;
|
|
1410
|
-
if (!
|
|
1425
|
+
if (!COMPONENT_ID_PATTERN2.test(localId)) {
|
|
1411
1426
|
throw new Error(`Invalid Fabric child component id: ${rawLocalId}`);
|
|
1412
1427
|
}
|
|
1413
1428
|
const joined = `${parent.entry.id}.${localId}`;
|
|
@@ -1455,7 +1470,8 @@ var FabricComponentSupervisor = class {
|
|
|
1455
1470
|
};
|
|
1456
1471
|
}
|
|
1457
1472
|
#validateEntry(entry, definition) {
|
|
1458
|
-
|
|
1473
|
+
validateComponentConfig(entry, definition);
|
|
1474
|
+
if (!COMPONENT_ID_PATTERN2.test(entry.id)) {
|
|
1459
1475
|
throw new Error(`Invalid Fabric component id: ${entry.id}`);
|
|
1460
1476
|
}
|
|
1461
1477
|
if (entry.component !== definition.name) {
|
|
@@ -2233,7 +2249,6 @@ var FabricComponentSupervisor = class {
|
|
|
2233
2249
|
};
|
|
2234
2250
|
|
|
2235
2251
|
// src/components/loader.ts
|
|
2236
|
-
var ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
|
|
2237
2252
|
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
2238
2253
|
var cloneEntry = (entry) => structuredClone(entry);
|
|
2239
2254
|
var entryHash = (entry) => stableJsonHash(entry);
|
|
@@ -2270,6 +2285,7 @@ var FabricComponentLoader = class {
|
|
|
2270
2285
|
name: definition.name,
|
|
2271
2286
|
...definition.description ? { description: definition.description } : {},
|
|
2272
2287
|
revision,
|
|
2288
|
+
...definition.configSchema ? { configSchema: structuredClone(definition.configSchema) } : {},
|
|
2273
2289
|
requirements: (definition.requires ?? []).map(
|
|
2274
2290
|
(requirement) => typeof requirement === "string" ? requirement : requirement.ref
|
|
2275
2291
|
),
|
|
@@ -2278,6 +2294,36 @@ var FabricComponentLoader = class {
|
|
|
2278
2294
|
)
|
|
2279
2295
|
}));
|
|
2280
2296
|
}
|
|
2297
|
+
describe(name) {
|
|
2298
|
+
const definition = this.definitions().find((candidate) => candidate.name === name);
|
|
2299
|
+
if (!definition) throw new Error(`Unknown Fabric component definition: ${name}`);
|
|
2300
|
+
return { ...definition, instances: this.list().filter((instance) => instance.component === name) };
|
|
2301
|
+
}
|
|
2302
|
+
validateEntries(entries) {
|
|
2303
|
+
const next = this.#entryMap(entries);
|
|
2304
|
+
for (const id of next.keys()) {
|
|
2305
|
+
if (this.#pinned.has(id)) throw new Error(`Fabric component entry id is reserved by a pinned component: ${id}`);
|
|
2306
|
+
}
|
|
2307
|
+
const provisions = /* @__PURE__ */ new Map();
|
|
2308
|
+
for (const entry of [...this.#pinned.values(), ...next.values()]) {
|
|
2309
|
+
if (entry.disabled) continue;
|
|
2310
|
+
for (const provision of this.catalog.get(entry.component)?.definition.provides ?? []) {
|
|
2311
|
+
const name = typeof provision === "string" ? provision : provision.provider;
|
|
2312
|
+
const owner = provisions.get(name);
|
|
2313
|
+
if (owner) throw new Error(`Fabric components ${owner} and ${entry.id} declare the same provider: ${name}`);
|
|
2314
|
+
provisions.set(name, entry.id);
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
unavailableProviderMessage(provider) {
|
|
2319
|
+
const definitions = this.definitions().filter((definition) => definition.provisions.includes(provider));
|
|
2320
|
+
if (!definitions.length) return void 0;
|
|
2321
|
+
const names = definitions.map((definition) => definition.name);
|
|
2322
|
+
const entries = [...this.#targetEntries().values()].filter((entry) => names.includes(entry.component));
|
|
2323
|
+
if (entries.length) return `Component instances ${entries.map((entry) => entry.id).join(", ")} provide ${provider}, but none is active. Inspect components.status and components.list configuration diagnostics; use components.reconcile after correcting configuration.`;
|
|
2324
|
+
const name = names[0];
|
|
2325
|
+
return `Component definition ${name} is registered, but no instance provides ${provider}. Call components.describe({component:${JSON.stringify(name)}}), then components.plan({entries:[{id:${JSON.stringify(provider)},component:${JSON.stringify(name)},config:{...}}]}) and components.apply with that plan's request and revision. Session scope needs no file edit or /fabric reload.`;
|
|
2326
|
+
}
|
|
2281
2327
|
list() {
|
|
2282
2328
|
const live = new Map(
|
|
2283
2329
|
this.supervisor.list().map((info) => [
|
|
@@ -2406,13 +2452,9 @@ var FabricComponentLoader = class {
|
|
|
2406
2452
|
}
|
|
2407
2453
|
#entryMap(entries) {
|
|
2408
2454
|
const next = /* @__PURE__ */ new Map();
|
|
2409
|
-
for (const
|
|
2410
|
-
const
|
|
2411
|
-
if (
|
|
2412
|
-
if (!entry.component.trim()) {
|
|
2413
|
-
throw new Error(`Fabric component entry ${entry.id} has an empty component name`);
|
|
2414
|
-
}
|
|
2415
|
-
if (next.has(entry.id)) throw new Error(`Duplicate Fabric component entry id: ${entry.id}`);
|
|
2455
|
+
for (const entry of componentEntries(entries)) {
|
|
2456
|
+
const definition = this.catalog.get(entry.component)?.definition;
|
|
2457
|
+
if (definition) validateComponentConfig(entry, definition);
|
|
2416
2458
|
next.set(entry.id, entry);
|
|
2417
2459
|
}
|
|
2418
2460
|
return next;
|
|
@@ -2432,6 +2474,7 @@ var FabricComponentLoader = class {
|
|
|
2432
2474
|
if (entry.disabled) continue;
|
|
2433
2475
|
const catalogEntry = this.catalog.get(entry.component);
|
|
2434
2476
|
if (!catalogEntry) continue;
|
|
2477
|
+
validateComponentConfig(entry, catalogEntry.definition);
|
|
2435
2478
|
targets.set(entry.id, {
|
|
2436
2479
|
entry: cloneEntry(entry),
|
|
2437
2480
|
definition: catalogEntry.definition,
|
|
@@ -2514,6 +2557,198 @@ var FabricComponentLoader = class {
|
|
|
2514
2557
|
}
|
|
2515
2558
|
};
|
|
2516
2559
|
|
|
2560
|
+
// src/components/control.ts
|
|
2561
|
+
var hash = (value) => stableJsonHash(value);
|
|
2562
|
+
var FabricComponentControl = class {
|
|
2563
|
+
constructor(loader, options = {}) {
|
|
2564
|
+
this.loader = loader;
|
|
2565
|
+
this.options = options;
|
|
2566
|
+
this.#base = structuredClone(options.initialEntries ?? loader.entries());
|
|
2567
|
+
try {
|
|
2568
|
+
this.#snapshot = options.store?.read();
|
|
2569
|
+
} catch (error) {
|
|
2570
|
+
this.#error = error instanceof Error ? error.message : String(error);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
#base;
|
|
2574
|
+
#overrides = /* @__PURE__ */ new Map();
|
|
2575
|
+
#snapshot;
|
|
2576
|
+
#tail = Promise.resolve();
|
|
2577
|
+
#epoch = 0;
|
|
2578
|
+
#closed = false;
|
|
2579
|
+
#error;
|
|
2580
|
+
configuration() {
|
|
2581
|
+
return {
|
|
2582
|
+
sessionOverrides: [...this.#overrides.keys()].sort(),
|
|
2583
|
+
sources: structuredClone(this.#snapshot?.sources ?? []),
|
|
2584
|
+
warnings: [...this.#snapshot?.warnings ?? []],
|
|
2585
|
+
...this.#error ? { error: this.#error } : {},
|
|
2586
|
+
removalPolicy: "drain"
|
|
2587
|
+
};
|
|
2588
|
+
}
|
|
2589
|
+
plan(request) {
|
|
2590
|
+
return this.#enqueue(() => this.#prepare(request).plan);
|
|
2591
|
+
}
|
|
2592
|
+
apply(request, signal) {
|
|
2593
|
+
return this.#enqueue(async () => {
|
|
2594
|
+
this.options.assertMutable?.();
|
|
2595
|
+
signal?.throwIfAborted();
|
|
2596
|
+
await this.loader.settle();
|
|
2597
|
+
signal?.throwIfAborted();
|
|
2598
|
+
const prepared = this.#prepare(request);
|
|
2599
|
+
if (request.expectedRevision !== prepared.plan.revision) throw new Error("Component plan is stale; call components.plan again");
|
|
2600
|
+
const previous = this.loader.entries();
|
|
2601
|
+
await this.loader.reconcile(prepared.effective);
|
|
2602
|
+
let snapshot = prepared.snapshot;
|
|
2603
|
+
try {
|
|
2604
|
+
if (prepared.persisted) {
|
|
2605
|
+
snapshot = this.options.store.write(prepared.plan.request.scope, prepared.persisted, snapshot.revision);
|
|
2606
|
+
} else if (snapshot && this.options.store.read().revision !== snapshot.revision) {
|
|
2607
|
+
throw new Error("Component configuration changed during activation; plan again");
|
|
2608
|
+
}
|
|
2609
|
+
} catch (error) {
|
|
2610
|
+
try {
|
|
2611
|
+
await this.loader.reconcile(previous);
|
|
2612
|
+
} catch (rollback) {
|
|
2613
|
+
throw new AggregateError([error, rollback], "Component apply and rollback failed");
|
|
2614
|
+
}
|
|
2615
|
+
throw error;
|
|
2616
|
+
}
|
|
2617
|
+
this.#base = prepared.base;
|
|
2618
|
+
this.#overrides = prepared.overrides;
|
|
2619
|
+
this.#snapshot = snapshot;
|
|
2620
|
+
this.#epoch++;
|
|
2621
|
+
this.#error = void 0;
|
|
2622
|
+
this.options.applied?.(structuredClone(prepared.effective));
|
|
2623
|
+
return { components: this.loader.list(), configuration: this.configuration(), scope: prepared.plan.request.scope };
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
reconcile(entries) {
|
|
2627
|
+
return this.#enqueue(async () => {
|
|
2628
|
+
this.options.assertMutable?.();
|
|
2629
|
+
const snapshot = this.options.store?.read();
|
|
2630
|
+
if (!entries && !snapshot) throw new Error("No host configuration source is available for components.reconcile");
|
|
2631
|
+
if (!entries && snapshot?.revision === this.#snapshot?.revision && hash(snapshot?.entries) === hash(this.#base)) {
|
|
2632
|
+
this.#snapshot = snapshot;
|
|
2633
|
+
this.#error = void 0;
|
|
2634
|
+
return { components: this.loader.list(), configuration: this.configuration() };
|
|
2635
|
+
}
|
|
2636
|
+
const base = componentEntries(entries ?? snapshot.entries);
|
|
2637
|
+
const effective = this.#effective(base, this.#overrides);
|
|
2638
|
+
this.loader.validateEntries(effective);
|
|
2639
|
+
await this.loader.reconcile(effective);
|
|
2640
|
+
this.#base = base;
|
|
2641
|
+
this.#snapshot = snapshot;
|
|
2642
|
+
this.#epoch++;
|
|
2643
|
+
this.#error = void 0;
|
|
2644
|
+
this.options.applied?.(structuredClone(effective));
|
|
2645
|
+
return { components: this.loader.list(), configuration: this.configuration() };
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
reload(id) {
|
|
2649
|
+
return this.#enqueue(async () => {
|
|
2650
|
+
const components = await this.loader.reload(id);
|
|
2651
|
+
this.#epoch++;
|
|
2652
|
+
this.#error = void 0;
|
|
2653
|
+
return { components };
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
async settle() {
|
|
2657
|
+
await this.#tail;
|
|
2658
|
+
}
|
|
2659
|
+
async close() {
|
|
2660
|
+
this.#closed = true;
|
|
2661
|
+
await this.#tail;
|
|
2662
|
+
}
|
|
2663
|
+
#prepare(input) {
|
|
2664
|
+
const scope = input.scope ?? "session";
|
|
2665
|
+
if (!["session", "global", "project"].includes(scope)) throw new Error("Invalid component configuration scope");
|
|
2666
|
+
const entries = componentEntries(input.entries ?? []);
|
|
2667
|
+
const ids = (values) => {
|
|
2668
|
+
if (!Array.isArray(values) || values.length > 256 || values.some((id) => typeof id !== "string" || !COMPONENT_ID_PATTERN.test(id))) throw new Error("Invalid component change IDs");
|
|
2669
|
+
return [...values];
|
|
2670
|
+
};
|
|
2671
|
+
const remove = ids(input.remove ?? []);
|
|
2672
|
+
const reset = ids(input.reset ?? []);
|
|
2673
|
+
const changed = [...entries.map((entry) => entry.id), ...remove, ...reset];
|
|
2674
|
+
if (!changed.length) throw new Error("Component plan needs entries, remove, or reset");
|
|
2675
|
+
if (new Set(changed).size !== changed.length) throw new Error("A component may appear only once in a change request");
|
|
2676
|
+
const pinned = new Set(this.loader.pinnedEntries().map((entry) => entry.id));
|
|
2677
|
+
if (changed.some((id) => pinned.has(id) || id.startsWith("fabric.provider.")) || entries.some((entry) => entry.component.startsWith("fabric.provider."))) throw new Error("Live component changes cannot modify reserved built-in components");
|
|
2678
|
+
if (scope !== "session" && reset.length) throw new Error("reset is available only for session overrides");
|
|
2679
|
+
const snapshot = this.options.store?.read();
|
|
2680
|
+
if (scope !== "session" && !snapshot) throw new Error("Persistent component configuration is unavailable in this host");
|
|
2681
|
+
if (scope === "project" && !snapshot.sources.find((source) => source.scope === "project")?.trusted) throw new Error("Cannot write project components in an untrusted project");
|
|
2682
|
+
const base = structuredClone(snapshot?.entries ?? this.#base);
|
|
2683
|
+
const overrides = new Map(this.#overrides);
|
|
2684
|
+
let nextBase = base;
|
|
2685
|
+
let persisted;
|
|
2686
|
+
if (scope === "session") {
|
|
2687
|
+
for (const entry of entries) overrides.set(entry.id, entry);
|
|
2688
|
+
for (const id of remove) overrides.set(id, null);
|
|
2689
|
+
for (const id of reset) overrides.delete(id);
|
|
2690
|
+
} else {
|
|
2691
|
+
const layer = scope === "global" ? snapshot.layers.global : snapshot.layers.project ?? snapshot.layers.global;
|
|
2692
|
+
const patched = new Map(layer.map((entry) => [entry.id, entry]));
|
|
2693
|
+
for (const entry of entries) patched.set(entry.id, entry);
|
|
2694
|
+
for (const id of remove) patched.delete(id);
|
|
2695
|
+
persisted = [...patched.values()];
|
|
2696
|
+
this.loader.validateEntries(persisted);
|
|
2697
|
+
nextBase = scope === "global" ? snapshot.layers.project ?? persisted : persisted;
|
|
2698
|
+
}
|
|
2699
|
+
if (overrides.size > 256) throw new Error("Fabric supports at most 256 session component overrides, including removal masks");
|
|
2700
|
+
const effective = this.#effective(nextBase, overrides);
|
|
2701
|
+
this.loader.validateEntries(effective);
|
|
2702
|
+
const before = new Map(this.loader.entries().map((entry) => [entry.id, entry]));
|
|
2703
|
+
const after = new Map(effective.map((entry) => [entry.id, entry]));
|
|
2704
|
+
const definitions = this.loader.definitions();
|
|
2705
|
+
const changes = [];
|
|
2706
|
+
for (const id of [.../* @__PURE__ */ new Set([...before.keys(), ...after.keys()])].sort()) {
|
|
2707
|
+
const old = before.get(id), next = after.get(id);
|
|
2708
|
+
if (hash(old ?? null) === hash(next ?? null)) continue;
|
|
2709
|
+
const entry = next ?? old;
|
|
2710
|
+
const definition = definitions.find((candidate) => candidate.name === entry.component);
|
|
2711
|
+
changes.push({ id, operation: !next ? "remove" : old ? "replace" : "add", component: entry.component, requirements: definition?.requirements ?? [], provisions: definition?.provisions ?? [] });
|
|
2712
|
+
}
|
|
2713
|
+
const warnings = [...snapshot?.warnings ?? []];
|
|
2714
|
+
if (scope === "global" && snapshot?.layers.project) warnings.push("The project's components array shadows the global array; this write may not change live instances.");
|
|
2715
|
+
if (scope !== "session" && changed.some((id) => overrides.has(id))) warnings.push("Session overrides remain in effect; reset those IDs in session scope to use persisted values.");
|
|
2716
|
+
for (const entry of effective) {
|
|
2717
|
+
if (!entry.disabled && !this.loader.catalog.get(entry.component)) warnings.push(`Definition ${entry.component} is unavailable; ${entry.id} will wait for registration.`);
|
|
2718
|
+
}
|
|
2719
|
+
if (changes.some((change) => change.operation !== "add")) warnings.push("Replacement/removal retires the old generation; existing committed views may drain. This is not immediate revocation or rollback of issued effects.");
|
|
2720
|
+
const revision = hash({ epoch: this.#epoch, source: snapshot?.revision, entries: this.loader.entries(), definitions, instances: this.loader.list().map(({ id, revision: revision2 }) => ({ id, revision: revision2 })) });
|
|
2721
|
+
return {
|
|
2722
|
+
plan: { revision, request: { scope, entries, remove, reset }, changes, warnings, sources: structuredClone(snapshot?.sources ?? []) },
|
|
2723
|
+
snapshot,
|
|
2724
|
+
base: structuredClone(nextBase),
|
|
2725
|
+
overrides,
|
|
2726
|
+
effective,
|
|
2727
|
+
persisted
|
|
2728
|
+
};
|
|
2729
|
+
}
|
|
2730
|
+
#effective(base, overrides) {
|
|
2731
|
+
const effective = new Map(base.map((entry) => [entry.id, entry]));
|
|
2732
|
+
for (const [id, entry] of overrides) {
|
|
2733
|
+
if (entry) effective.set(id, entry);
|
|
2734
|
+
else effective.delete(id);
|
|
2735
|
+
}
|
|
2736
|
+
return componentEntries([...effective.values()]);
|
|
2737
|
+
}
|
|
2738
|
+
#enqueue(operation) {
|
|
2739
|
+
this.loader.supervisor.assertLifecycleEntryAllowed("change component configuration");
|
|
2740
|
+
if (this.#closed) return Promise.reject(new Error("Component control is closed"));
|
|
2741
|
+
const task = this.#tail.then(() => {
|
|
2742
|
+
if (this.#closed) throw new Error("Component control is closed");
|
|
2743
|
+
return operation();
|
|
2744
|
+
});
|
|
2745
|
+
this.#tail = task.then(() => void 0, (error) => {
|
|
2746
|
+
this.#error = error instanceof Error ? error.message : String(error);
|
|
2747
|
+
});
|
|
2748
|
+
return task;
|
|
2749
|
+
}
|
|
2750
|
+
};
|
|
2751
|
+
|
|
2517
2752
|
// src/core/compact-controller.ts
|
|
2518
2753
|
var DEFAULT_REQUESTED_BY = "model";
|
|
2519
2754
|
var isString = (value) => typeof value === "string" && value.length > 0;
|
|
@@ -3378,18 +3613,20 @@ Recovery hint: ${hint}`;
|
|
|
3378
3613
|
const runOutcome = executionOutcomeFromTermination(sandboxResult.terminationReason);
|
|
3379
3614
|
const succeeded = runOutcome === "succeeded";
|
|
3380
3615
|
this.activity?.finish(options.parentToolCallId, succeeded, sandboxResult.error);
|
|
3616
|
+
const sanitizedValue = sanitizeFabricMediaValue(sandboxResult.value);
|
|
3381
3617
|
return {
|
|
3382
3618
|
success: succeeded,
|
|
3383
3619
|
kernel: python ? "python" : "typescript",
|
|
3384
|
-
value:
|
|
3385
|
-
logs: sandboxResult.logs,
|
|
3620
|
+
value: sanitizedValue.value,
|
|
3621
|
+
logs: sandboxResult.logs.map(sanitizeFabricMediaText),
|
|
3622
|
+
...sanitizedValue.images.length > 0 ? { media: sanitizedValue.images } : {},
|
|
3386
3623
|
audits,
|
|
3387
3624
|
phases,
|
|
3388
3625
|
// Guest and provider error text may embed tool output or source
|
|
3389
3626
|
// literals, so the durable trace records only safe causes.
|
|
3390
3627
|
trace: traceRecorder.seal(runOutcome, phases),
|
|
3391
3628
|
elapsedMs: performance.now() - startedAt,
|
|
3392
|
-
...sandboxResult.error ? { error: sandboxResult.error } : {},
|
|
3629
|
+
...sandboxResult.error ? { error: sanitizeFabricMediaText(sandboxResult.error) } : {},
|
|
3393
3630
|
...handoffRequest ? { handoffRequest } : {},
|
|
3394
3631
|
...classifierUsages.length > 0 ? { usage: aggregateUsage(classifierUsages) } : {}
|
|
3395
3632
|
};
|
|
@@ -4357,6 +4594,7 @@ var allowedEnforceRefs = /* @__PURE__ */ new Set([
|
|
|
4357
4594
|
"mesh.list",
|
|
4358
4595
|
"compact.status",
|
|
4359
4596
|
"components.list",
|
|
4597
|
+
"components.describe",
|
|
4360
4598
|
"components.status",
|
|
4361
4599
|
"components.graph",
|
|
4362
4600
|
"schema.status",
|
|
@@ -4678,7 +4916,7 @@ var ResidencyClient = class {
|
|
|
4678
4916
|
if (signal?.aborted) throw new Error(`Waiting for durable Fabric agent ${id} was aborted`);
|
|
4679
4917
|
const status = this.statusAgent(id);
|
|
4680
4918
|
if (terminal(status.status) && "startedAt" in status) return status;
|
|
4681
|
-
await
|
|
4919
|
+
await sleepUnlessAborted(STATUS_POLL_MS, signal).catch(() => void 0);
|
|
4682
4920
|
}
|
|
4683
4921
|
}
|
|
4684
4922
|
readAgentLog(id, options = {}) {
|
|
@@ -4764,19 +5002,24 @@ var ResidencyClient = class {
|
|
|
4764
5002
|
const responsePath = path4.join(this.#responsesPath, `${command.requestId}.json`);
|
|
4765
5003
|
atomicWrite2(path4.join(this.#requestsPath, `${command.requestId}.json`), command);
|
|
4766
5004
|
const deadline = Date.now() + COMMAND_TIMEOUT_MS;
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
5005
|
+
try {
|
|
5006
|
+
while (Date.now() < deadline) {
|
|
5007
|
+
if (signal?.aborted) throw new Error("Fabric residency request was aborted");
|
|
5008
|
+
const response = readJson(responsePath);
|
|
5009
|
+
if (response?.format === RESIDENT_HOST_FORMAT && response.requestId === command.requestId) {
|
|
5010
|
+
fs4.rmSync(responsePath, { force: true });
|
|
5011
|
+
if (!response.ok) throw new Error(response.error ?? "Fabric resident host rejected request");
|
|
5012
|
+
return response;
|
|
5013
|
+
}
|
|
5014
|
+
const owner = this.#liveOwner();
|
|
5015
|
+
if (!owner) throw new Error("Fabric resident host exited while processing a request");
|
|
5016
|
+
await sleepUnlessAborted(STATUS_POLL_MS, signal).catch(() => void 0);
|
|
4774
5017
|
}
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
5018
|
+
throw new Error(`Timed out waiting for Fabric residency request ${command.requestId}`);
|
|
5019
|
+
} catch (error) {
|
|
5020
|
+
abandonResidentRequest(this.#requestsPath, this.#responsesPath, command.requestId);
|
|
5021
|
+
throw error;
|
|
4778
5022
|
}
|
|
4779
|
-
throw new Error(`Timed out waiting for Fabric residency request ${command.requestId}`);
|
|
4780
5023
|
}
|
|
4781
5024
|
async #waitForParticipant(id, kind) {
|
|
4782
5025
|
const deadline = Date.now() + STARTUP_TIMEOUT_MS;
|
|
@@ -6308,6 +6551,23 @@ var CompactProvider = class {
|
|
|
6308
6551
|
};
|
|
6309
6552
|
|
|
6310
6553
|
// src/providers/components-provider.ts
|
|
6554
|
+
var entrySchema = {
|
|
6555
|
+
type: "object",
|
|
6556
|
+
properties: {
|
|
6557
|
+
id: { type: "string", minLength: 1, maxLength: 128 },
|
|
6558
|
+
component: { type: "string", minLength: 1, maxLength: 128 },
|
|
6559
|
+
config: {},
|
|
6560
|
+
disabled: { type: "boolean" }
|
|
6561
|
+
},
|
|
6562
|
+
required: ["id", "component"],
|
|
6563
|
+
additionalProperties: false
|
|
6564
|
+
};
|
|
6565
|
+
var changeProperties = {
|
|
6566
|
+
scope: { type: "string", enum: ["session", "global", "project"], description: "Defaults to session: no file writes. Persistent scope must be explicit." },
|
|
6567
|
+
entries: { type: "array", items: entrySchema, maxItems: 256, description: "Upsert complete entries by id; other entries are preserved." },
|
|
6568
|
+
remove: { type: "array", items: { type: "string" }, maxItems: 256 },
|
|
6569
|
+
reset: { type: "array", items: { type: "string" }, maxItems: 256, description: "Session only: remove overlays and use trusted file configuration for these IDs." }
|
|
6570
|
+
};
|
|
6311
6571
|
var descriptors2 = [
|
|
6312
6572
|
{
|
|
6313
6573
|
name: "list",
|
|
@@ -6335,6 +6595,34 @@ var descriptors2 = [
|
|
|
6335
6595
|
risk: "read",
|
|
6336
6596
|
effect: { kind: "none", resources: ["fabric:components"], ordering: "commutative" }
|
|
6337
6597
|
},
|
|
6598
|
+
{
|
|
6599
|
+
name: "describe",
|
|
6600
|
+
description: "Inspect a registered component definition, its config JSON Schema, declared requirements/provisions, and instances, even before activation.",
|
|
6601
|
+
inputSchema: { type: "object", properties: { component: { type: "string", minLength: 1 } }, required: ["component"], additionalProperties: false },
|
|
6602
|
+
risk: "read",
|
|
6603
|
+
effect: { kind: "none", resources: ["fabric:components"], ordering: "commutative" }
|
|
6604
|
+
},
|
|
6605
|
+
{
|
|
6606
|
+
name: "plan",
|
|
6607
|
+
description: "Validate a component configuration change without activation or file writes. Returns a request and revision for apply, changes, trust provenance, and warnings. A plan is not approval or a connectivity check.",
|
|
6608
|
+
inputSchema: { type: "object", properties: changeProperties, additionalProperties: false },
|
|
6609
|
+
risk: "read",
|
|
6610
|
+
effect: { kind: "none", resources: ["fabric:components"], ordering: "commutative" }
|
|
6611
|
+
},
|
|
6612
|
+
{
|
|
6613
|
+
name: "apply",
|
|
6614
|
+
description: "Apply a validated component change without reloading Fabric. Pass the planned request plus expectedRevision. Session scope is ephemeral; global/project scopes write only components atomically. Runs pinned to retired generations may drain; this is not immediate revocation. Trusted host code may execute during activation. Unavailable to committed guest views.",
|
|
6615
|
+
inputSchema: { type: "object", properties: { ...changeProperties, expectedRevision: { type: "string", minLength: 1 } }, required: ["expectedRevision"], additionalProperties: false },
|
|
6616
|
+
risk: "execute",
|
|
6617
|
+
effect: { kind: "emission", resources: ["fabric:components", "fabric:configuration"], ordering: "ordered" }
|
|
6618
|
+
},
|
|
6619
|
+
{
|
|
6620
|
+
name: "reconcile",
|
|
6621
|
+
description: "Re-read trusted component configuration and reconcile changed instances without restarting unrelated providers. Session overrides remain. Invalid edits retain the last applied state. Unavailable to committed guest views.",
|
|
6622
|
+
inputSchema: { type: "object", additionalProperties: false },
|
|
6623
|
+
risk: "execute",
|
|
6624
|
+
effect: { kind: "transactional", resources: ["fabric:components"], ordering: "ordered" }
|
|
6625
|
+
},
|
|
6338
6626
|
{
|
|
6339
6627
|
name: "reload",
|
|
6340
6628
|
description: "Restart one component, or all loaded components, with rollback to the previous revision on activation failure.",
|
|
@@ -6348,8 +6636,9 @@ var descriptors2 = [
|
|
|
6348
6636
|
}
|
|
6349
6637
|
];
|
|
6350
6638
|
var ComponentsProvider = class {
|
|
6351
|
-
constructor(loader) {
|
|
6639
|
+
constructor(loader, control = new FabricComponentControl(loader)) {
|
|
6352
6640
|
this.loader = loader;
|
|
6641
|
+
this.control = control;
|
|
6353
6642
|
}
|
|
6354
6643
|
name = "components";
|
|
6355
6644
|
description = "Supervised component lifecycle, exact capability dependencies, effect cleanup, and reload diagnostics.";
|
|
@@ -6363,13 +6652,31 @@ var ComponentsProvider = class {
|
|
|
6363
6652
|
async describe(actionName, _context) {
|
|
6364
6653
|
return descriptors2.find((descriptor) => descriptor.name === actionName);
|
|
6365
6654
|
}
|
|
6366
|
-
async invoke(actionName, args,
|
|
6655
|
+
async invoke(actionName, args, context) {
|
|
6656
|
+
const descriptor = descriptors2.find((action) => action.name === actionName);
|
|
6657
|
+
if (descriptor) {
|
|
6658
|
+
const invalid = validationMessage(descriptor.inputSchema, args);
|
|
6659
|
+
if (invalid) throw new Error(`Invalid components.${actionName} arguments: ${invalid}`);
|
|
6660
|
+
}
|
|
6661
|
+
if (["apply", "reconcile"].includes(actionName) && context.capabilityView) {
|
|
6662
|
+
throw new Error("Component configuration changes require an unrestricted host caller, not a committed guest capability view");
|
|
6663
|
+
}
|
|
6664
|
+
context.signal?.throwIfAborted();
|
|
6367
6665
|
switch (actionName) {
|
|
6368
6666
|
case "list":
|
|
6369
6667
|
return {
|
|
6370
6668
|
definitions: this.loader.definitions(),
|
|
6371
|
-
components: this.loader.list()
|
|
6669
|
+
components: this.loader.list(),
|
|
6670
|
+
configuration: this.control.configuration()
|
|
6372
6671
|
};
|
|
6672
|
+
case "describe":
|
|
6673
|
+
return this.loader.describe(args.component);
|
|
6674
|
+
case "plan":
|
|
6675
|
+
return this.control.plan(args);
|
|
6676
|
+
case "apply":
|
|
6677
|
+
return this.control.apply({ ...args, expectedRevision: args.expectedRevision }, context.signal);
|
|
6678
|
+
case "reconcile":
|
|
6679
|
+
return this.control.reconcile();
|
|
6373
6680
|
case "status": {
|
|
6374
6681
|
const id = args.id;
|
|
6375
6682
|
if (typeof id !== "string" || !id.trim()) throw new Error("components.status requires id");
|
|
@@ -6382,9 +6689,7 @@ var ComponentsProvider = class {
|
|
|
6382
6689
|
if (id !== void 0 && (typeof id !== "string" || !id.trim())) {
|
|
6383
6690
|
throw new Error("components.reload id must be a non-empty string");
|
|
6384
6691
|
}
|
|
6385
|
-
return
|
|
6386
|
-
components: await this.loader.reload(typeof id === "string" ? id : void 0)
|
|
6387
|
-
};
|
|
6692
|
+
return this.control.reload(typeof id === "string" ? id : void 0);
|
|
6388
6693
|
}
|
|
6389
6694
|
default:
|
|
6390
6695
|
throw new Error(`Unknown components action: ${actionName}`);
|
|
@@ -6572,6 +6877,8 @@ var CapturedToolsProvider = class {
|
|
|
6572
6877
|
result,
|
|
6573
6878
|
isError
|
|
6574
6879
|
}));
|
|
6880
|
+
const images = result.content.filter((part) => part.type === "image");
|
|
6881
|
+
if (images.length > 0) context.attachMedia?.(images);
|
|
6575
6882
|
if (isError) {
|
|
6576
6883
|
if (isPiShellToolName(entry.name)) {
|
|
6577
6884
|
throw piBashResultError(thrown, textFromContent2(result.content));
|
|
@@ -10846,6 +11153,9 @@ var FabricRuntimeState = class {
|
|
|
10846
11153
|
#schema;
|
|
10847
11154
|
#componentSupervisor;
|
|
10848
11155
|
#componentLoader;
|
|
11156
|
+
#componentControl;
|
|
11157
|
+
#componentConfiguration;
|
|
11158
|
+
#stopComponentWatch;
|
|
10849
11159
|
#componentTransitionSignatures = /* @__PURE__ */ new Map();
|
|
10850
11160
|
#componentTransitionPublications = /* @__PURE__ */ new Set();
|
|
10851
11161
|
#sessionCapabilityLease;
|
|
@@ -11017,7 +11327,25 @@ var FabricRuntimeState = class {
|
|
|
11017
11327
|
this.componentCatalog,
|
|
11018
11328
|
this.#componentSupervisor
|
|
11019
11329
|
);
|
|
11020
|
-
|
|
11330
|
+
if (!this.#managedHost && this.#config.schema.mode !== "enforce") {
|
|
11331
|
+
this.#componentConfiguration = new FabricComponentConfiguration({
|
|
11332
|
+
cwd: context.cwd,
|
|
11333
|
+
agentDir: resolveAgentDir(),
|
|
11334
|
+
projectTrusted: () => context.isProjectTrusted()
|
|
11335
|
+
});
|
|
11336
|
+
}
|
|
11337
|
+
this.#componentControl = new FabricComponentControl(this.#componentLoader, {
|
|
11338
|
+
...this.#componentConfiguration ? { store: this.#componentConfiguration } : {},
|
|
11339
|
+
initialEntries: this.#config.schema.mode === "enforce" ? [] : this.#config.components,
|
|
11340
|
+
assertMutable: () => {
|
|
11341
|
+
if (this.#managedHost || this.#config?.schema.mode === "enforce") throw new Error("Live component configuration is unavailable in managed hosts and Schema enforce mode");
|
|
11342
|
+
},
|
|
11343
|
+
applied: (entries) => {
|
|
11344
|
+
if (this.#config) this.#config.components = entries;
|
|
11345
|
+
}
|
|
11346
|
+
});
|
|
11347
|
+
this.#registry.setUnavailableResolver((name) => this.#componentLoader?.unavailableProviderMessage(name));
|
|
11348
|
+
this.#registry.register(this.#managedHost?.provider("components") ?? new ComponentsProvider(this.#componentLoader, this.#componentControl));
|
|
11021
11349
|
const builtinManifest = new FabricProviderComponentManifest(
|
|
11022
11350
|
this.componentCatalog,
|
|
11023
11351
|
this.#componentLoader
|
|
@@ -11500,6 +11828,18 @@ ${escapeXmlText(advice.message)}
|
|
|
11500
11828
|
};
|
|
11501
11829
|
this.pi.events.emit(FABRIC_COMPONENT_DISCOVER_EVENT, componentDiscovery);
|
|
11502
11830
|
await this.components.reconcile(enforceSchema ? [] : this.config.components);
|
|
11831
|
+
const configuration = this.#componentConfiguration;
|
|
11832
|
+
const control = this.#componentControl;
|
|
11833
|
+
if (configuration && control) {
|
|
11834
|
+
this.#stopComponentWatch = watchComponentConfiguration(configuration.paths, () => {
|
|
11835
|
+
void control.reconcile().catch((error) => {
|
|
11836
|
+
if (context.hasUI) context.ui.notify(`Pi Fabric component configuration not applied: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
11837
|
+
});
|
|
11838
|
+
});
|
|
11839
|
+
for (const warning of control.configuration().warnings) {
|
|
11840
|
+
if (context.hasUI) context.ui.notify(warning, "warning");
|
|
11841
|
+
}
|
|
11842
|
+
}
|
|
11503
11843
|
}
|
|
11504
11844
|
async ensure(context) {
|
|
11505
11845
|
if (!this.initialized || this.#cwd !== context.cwd) await this.initialize(context);
|
|
@@ -11533,7 +11873,7 @@ ${escapeXmlText(advice.message)}
|
|
|
11533
11873
|
this.prewalkDrift.drop(context.sessionManager.getSessionId());
|
|
11534
11874
|
if (context.hasUI) context.ui.setStatus("fabric-prewalk", void 0);
|
|
11535
11875
|
}
|
|
11536
|
-
void this.#componentLoader?.reconcile(next.components)
|
|
11876
|
+
void (this.#componentControl?.reconcile(next.components) ?? this.#componentLoader?.reconcile(next.components))?.catch((error) => {
|
|
11537
11877
|
if (this.#config) this.#config.components = previousComponents;
|
|
11538
11878
|
const detail = error instanceof Error ? error.message : String(error);
|
|
11539
11879
|
if (context.hasUI) context.ui.notify(`Pi Fabric component reload failed: ${detail}`, "error");
|
|
@@ -11749,6 +12089,7 @@ ${escapeXmlText(advice.message)}
|
|
|
11749
12089
|
this.componentCatalog.register(component, options);
|
|
11750
12090
|
}
|
|
11751
12091
|
async settleComponents() {
|
|
12092
|
+
await this.#componentControl?.settle();
|
|
11752
12093
|
await this.#componentLoader?.settle();
|
|
11753
12094
|
}
|
|
11754
12095
|
async shutdown() {
|
|
@@ -11756,6 +12097,11 @@ ${escapeXmlText(advice.message)}
|
|
|
11756
12097
|
await this.#deactivateRepairs();
|
|
11757
12098
|
clearActiveCompiledSurface();
|
|
11758
12099
|
await this.#participants?.quiesce().catch(() => void 0);
|
|
12100
|
+
this.#stopComponentWatch?.();
|
|
12101
|
+
this.#stopComponentWatch = void 0;
|
|
12102
|
+
await this.#componentControl?.close();
|
|
12103
|
+
this.#componentControl = void 0;
|
|
12104
|
+
this.#componentConfiguration = void 0;
|
|
11759
12105
|
await this.#componentLoader?.close();
|
|
11760
12106
|
await Promise.allSettled([...this.#componentTransitionPublications]);
|
|
11761
12107
|
await this.#sessionCapabilityLease?.release().catch(() => void 0);
|
|
@@ -11836,6 +12182,11 @@ ${escapeXmlText(advice.message)}
|
|
|
11836
12182
|
await this.#deactivateRepairs();
|
|
11837
12183
|
if (!this.#registry) return;
|
|
11838
12184
|
await this.#participants?.quiesce().catch(() => void 0);
|
|
12185
|
+
this.#stopComponentWatch?.();
|
|
12186
|
+
this.#stopComponentWatch = void 0;
|
|
12187
|
+
await this.#componentControl?.close();
|
|
12188
|
+
this.#componentControl = void 0;
|
|
12189
|
+
this.#componentConfiguration = void 0;
|
|
11839
12190
|
await this.#componentLoader?.close();
|
|
11840
12191
|
await Promise.allSettled([...this.#componentTransitionPublications]);
|
|
11841
12192
|
await this.#sessionCapabilityLease?.release().catch(() => void 0);
|