pi-fabric 0.92.20 → 0.92.21
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-ROXAXSTJ.js → chunk-MAP2LVSM.js} +122 -122
- package/dist/chunks/chunk-MAP2LVSM.js.map +7 -0
- package/dist/fabric-runtime-state.js +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +2 -2
- package/dist/prewalk/arm.d.ts.map +1 -1
- package/docs/agents.md +1 -1
- package/docs/configuration.md +1 -1
- package/package.json +1 -1
- package/dist/chunks/chunk-ROXAXSTJ.js.map +0 -7
|
@@ -157,8 +157,121 @@ var CapturedToolCatalog = class {
|
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
-
// src/
|
|
160
|
+
// src/main-agent.ts
|
|
161
161
|
import { randomUUID } from "node:crypto";
|
|
162
|
+
var MAIN_AGENT_ALIAS = "main";
|
|
163
|
+
var resolveFabricIdentity = (sessionId, environment = process.env) => {
|
|
164
|
+
const actorId = environment.PI_FABRIC_ACTOR_ID?.trim();
|
|
165
|
+
const parentAgentId = environment.PI_FABRIC_PARENT_RUN?.trim();
|
|
166
|
+
const identity = actorId ? {
|
|
167
|
+
id: actorId,
|
|
168
|
+
name: environment.PI_FABRIC_ACTOR_NAME?.trim() || actorId.slice(0, 8),
|
|
169
|
+
kind: "actor",
|
|
170
|
+
sessionId
|
|
171
|
+
} : parentAgentId ? {
|
|
172
|
+
id: parentAgentId,
|
|
173
|
+
name: environment.PI_FABRIC_AGENT_NAME?.trim() || parentAgentId.slice(0, 8),
|
|
174
|
+
kind: "agent",
|
|
175
|
+
sessionId
|
|
176
|
+
} : { id: `session:${sessionId}`, name: "main", kind: "main", sessionId };
|
|
177
|
+
const inheritedMainAgentId = environment.PI_FABRIC_MAIN_AGENT_ID?.trim();
|
|
178
|
+
return {
|
|
179
|
+
identity,
|
|
180
|
+
mainAgentId: inheritedMainAgentId || (identity.kind === "main" ? identity.id : `session:${sessionId}`)
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
var escapeXmlText = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
184
|
+
var serializableData = (value) => {
|
|
185
|
+
try {
|
|
186
|
+
const serialized = JSON.stringify(value);
|
|
187
|
+
return serialized === void 0 ? void 0 : JSON.parse(serialized);
|
|
188
|
+
} catch {
|
|
189
|
+
return { fabricUnserializable: true };
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var MainAgentController = class {
|
|
193
|
+
constructor(pi, id, local, cwd, sessionId) {
|
|
194
|
+
this.pi = pi;
|
|
195
|
+
this.id = id;
|
|
196
|
+
this.local = local;
|
|
197
|
+
this.cwd = cwd;
|
|
198
|
+
this.sessionId = sessionId;
|
|
199
|
+
}
|
|
200
|
+
startedAt = Date.now();
|
|
201
|
+
matches(id) {
|
|
202
|
+
const target = id.trim();
|
|
203
|
+
return target === MAIN_AGENT_ALIAS || target === this.id;
|
|
204
|
+
}
|
|
205
|
+
info(context) {
|
|
206
|
+
const model = this.local && context?.model ? `${context.model.provider}/${context.model.id}` : void 0;
|
|
207
|
+
const thinking = this.local ? this.pi.getThinkingLevel() : void 0;
|
|
208
|
+
return {
|
|
209
|
+
id: this.id,
|
|
210
|
+
name: "Main",
|
|
211
|
+
kind: "main",
|
|
212
|
+
status: this.local ? context?.isIdle() === false ? "running" : "idle" : "remote",
|
|
213
|
+
runner: "pi",
|
|
214
|
+
transport: "host",
|
|
215
|
+
...this.local ? { cwd: this.cwd, startedAt: this.startedAt } : {},
|
|
216
|
+
...this.sessionId ? { sessionId: this.sessionId } : {},
|
|
217
|
+
...model ? { model } : {},
|
|
218
|
+
...thinking ? { thinking } : {},
|
|
219
|
+
updatedAt: Date.now(),
|
|
220
|
+
pendingMessages: this.local ? context?.hasPendingMessages() ?? false : false,
|
|
221
|
+
local: this.local
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
async switchModel(target, context) {
|
|
225
|
+
if (!this.local) {
|
|
226
|
+
return { ok: false, error: `Main agent ${this.id} is owned by another Fabric process` };
|
|
227
|
+
}
|
|
228
|
+
const key = `${target.provider}/${target.id}`;
|
|
229
|
+
const model = context.modelRegistry.find(target.provider, target.id);
|
|
230
|
+
if (!model) return { ok: false, error: `Model is not available: ${key}` };
|
|
231
|
+
const switched = await this.pi.setModel(model);
|
|
232
|
+
if (!switched) return { ok: false, error: `No authentication configured for model: ${key}` };
|
|
233
|
+
return { ok: true };
|
|
234
|
+
}
|
|
235
|
+
deliverUser(message, delivery) {
|
|
236
|
+
if (!this.local) throw new Error(`Main agent ${this.id} is owned by another Fabric process`);
|
|
237
|
+
const text = message.trim();
|
|
238
|
+
if (!text) throw new Error("Main agent message must not be empty");
|
|
239
|
+
const messageId = randomUUID();
|
|
240
|
+
this.pi.sendUserMessage(text, { deliverAs: delivery });
|
|
241
|
+
return { queued: true, messageId, routed: "main" };
|
|
242
|
+
}
|
|
243
|
+
deliverAgent(request) {
|
|
244
|
+
if (!this.local) throw new Error(`Main agent ${this.id} is owned by another Fabric process`);
|
|
245
|
+
const message = request.message.trim();
|
|
246
|
+
if (!message) throw new Error("Main agent message must not be empty");
|
|
247
|
+
const messageId = randomUUID();
|
|
248
|
+
const data = request.data === void 0 ? void 0 : serializableData(request.data);
|
|
249
|
+
this.pi.sendMessage(
|
|
250
|
+
{
|
|
251
|
+
customType: "pi-fabric-agent-message",
|
|
252
|
+
content: [
|
|
253
|
+
`<fabric-agent-message from_name=${JSON.stringify(request.from.name)} from_id=${JSON.stringify(request.from.id)} from_kind=${JSON.stringify(request.from.kind)}>`,
|
|
254
|
+
escapeXmlText(message),
|
|
255
|
+
data === void 0 ? void 0 : `<data>${escapeXmlText(JSON.stringify(data))}</data>`,
|
|
256
|
+
"</fabric-agent-message>"
|
|
257
|
+
].filter((line) => Boolean(line)).join("\n"),
|
|
258
|
+
display: true,
|
|
259
|
+
details: {
|
|
260
|
+
id: messageId,
|
|
261
|
+
from: structuredClone(request.from),
|
|
262
|
+
delivery: request.delivery,
|
|
263
|
+
triggerTurn: request.triggerTurn ?? true,
|
|
264
|
+
...data === void 0 ? {} : { data }
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
{ deliverAs: request.delivery, triggerTurn: request.triggerTurn ?? true }
|
|
268
|
+
);
|
|
269
|
+
return { queued: true, messageId, routed: "main" };
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// src/prewalk/handoff.ts
|
|
274
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
162
275
|
|
|
163
276
|
// src/agents/handoff-completion.ts
|
|
164
277
|
var HANDOFF_COMPLETION_MESSAGE_TYPE = "pi-fabric-handoff-complete";
|
|
@@ -324,7 +437,7 @@ var claimFabricFsDriftHandoff = (controller, execution, sessionId, drift, result
|
|
|
324
437
|
};
|
|
325
438
|
var buildPrewalkPending = (claim, resultFormat) => {
|
|
326
439
|
const inPlace = claim.arm.mode === "in-place";
|
|
327
|
-
const nestedToolCallId = `${NESTED_TOOL_CALL_ID_PREFIX}prewalk_${
|
|
440
|
+
const nestedToolCallId = `${NESTED_TOOL_CALL_ID_PREFIX}prewalk_${randomUUID2()}`;
|
|
328
441
|
const args = {
|
|
329
442
|
model: claim.arm.model,
|
|
330
443
|
name: inPlace ? "In-place Prewalk" : "Prewalk trajectory executor",
|
|
@@ -386,7 +499,7 @@ var runInPlacePrewalk = async (controller, extension, pending, context) => {
|
|
|
386
499
|
const returnModel = context.model;
|
|
387
500
|
if (!returnModel) throw new Error("Prewalk cannot determine Main return model");
|
|
388
501
|
const returnModelKey = `${returnModel.provider}/${returnModel.id}`;
|
|
389
|
-
const continuationId =
|
|
502
|
+
const continuationId = randomUUID2();
|
|
390
503
|
const switched = await extension.setModel(model);
|
|
391
504
|
if (!switched) {
|
|
392
505
|
throw new Error(`No authentication configured for prewalk model: ${modelKey}`);
|
|
@@ -735,7 +848,7 @@ var expandSkillDirMarkersForRead = (content, args, cwd) => {
|
|
|
735
848
|
};
|
|
736
849
|
|
|
737
850
|
// src/activity/store.ts
|
|
738
|
-
import { randomUUID as
|
|
851
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
739
852
|
var MAX_RUNS = 24;
|
|
740
853
|
var MAX_CALLS = 1e3;
|
|
741
854
|
var MAX_ITEMS = 1e3;
|
|
@@ -1033,7 +1146,7 @@ var FabricActivityStore = class {
|
|
|
1033
1146
|
if (!message) throw new Error("Workflow activity event message must not be empty");
|
|
1034
1147
|
const data = boundedData(input.data);
|
|
1035
1148
|
run.events.push({
|
|
1036
|
-
id:
|
|
1149
|
+
id: randomUUID3(),
|
|
1037
1150
|
message,
|
|
1038
1151
|
level: input.level ?? "info",
|
|
1039
1152
|
createdAt: Date.now(),
|
|
@@ -1842,121 +1955,10 @@ var PrewalkDriftTracker = class {
|
|
|
1842
1955
|
}
|
|
1843
1956
|
};
|
|
1844
1957
|
|
|
1845
|
-
// src/main-agent.ts
|
|
1846
|
-
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
1847
|
-
var MAIN_AGENT_ALIAS = "main";
|
|
1848
|
-
var resolveFabricIdentity = (sessionId, environment = process.env) => {
|
|
1849
|
-
const actorId = environment.PI_FABRIC_ACTOR_ID?.trim();
|
|
1850
|
-
const parentAgentId = environment.PI_FABRIC_PARENT_RUN?.trim();
|
|
1851
|
-
const identity = actorId ? {
|
|
1852
|
-
id: actorId,
|
|
1853
|
-
name: environment.PI_FABRIC_ACTOR_NAME?.trim() || actorId.slice(0, 8),
|
|
1854
|
-
kind: "actor",
|
|
1855
|
-
sessionId
|
|
1856
|
-
} : parentAgentId ? {
|
|
1857
|
-
id: parentAgentId,
|
|
1858
|
-
name: environment.PI_FABRIC_AGENT_NAME?.trim() || parentAgentId.slice(0, 8),
|
|
1859
|
-
kind: "agent",
|
|
1860
|
-
sessionId
|
|
1861
|
-
} : { id: `session:${sessionId}`, name: "main", kind: "main", sessionId };
|
|
1862
|
-
const inheritedMainAgentId = environment.PI_FABRIC_MAIN_AGENT_ID?.trim();
|
|
1863
|
-
return {
|
|
1864
|
-
identity,
|
|
1865
|
-
mainAgentId: inheritedMainAgentId || (identity.kind === "main" ? identity.id : `session:${sessionId}`)
|
|
1866
|
-
};
|
|
1867
|
-
};
|
|
1868
|
-
var escapeXmlText = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
1869
|
-
var serializableData = (value) => {
|
|
1870
|
-
try {
|
|
1871
|
-
const serialized = JSON.stringify(value);
|
|
1872
|
-
return serialized === void 0 ? void 0 : JSON.parse(serialized);
|
|
1873
|
-
} catch {
|
|
1874
|
-
return { fabricUnserializable: true };
|
|
1875
|
-
}
|
|
1876
|
-
};
|
|
1877
|
-
var MainAgentController = class {
|
|
1878
|
-
constructor(pi, id, local, cwd, sessionId) {
|
|
1879
|
-
this.pi = pi;
|
|
1880
|
-
this.id = id;
|
|
1881
|
-
this.local = local;
|
|
1882
|
-
this.cwd = cwd;
|
|
1883
|
-
this.sessionId = sessionId;
|
|
1884
|
-
}
|
|
1885
|
-
startedAt = Date.now();
|
|
1886
|
-
matches(id) {
|
|
1887
|
-
const target = id.trim();
|
|
1888
|
-
return target === MAIN_AGENT_ALIAS || target === this.id;
|
|
1889
|
-
}
|
|
1890
|
-
info(context) {
|
|
1891
|
-
const model = this.local && context?.model ? `${context.model.provider}/${context.model.id}` : void 0;
|
|
1892
|
-
const thinking = this.local ? this.pi.getThinkingLevel() : void 0;
|
|
1893
|
-
return {
|
|
1894
|
-
id: this.id,
|
|
1895
|
-
name: "Main",
|
|
1896
|
-
kind: "main",
|
|
1897
|
-
status: this.local ? context?.isIdle() === false ? "running" : "idle" : "remote",
|
|
1898
|
-
runner: "pi",
|
|
1899
|
-
transport: "host",
|
|
1900
|
-
...this.local ? { cwd: this.cwd, startedAt: this.startedAt } : {},
|
|
1901
|
-
...this.sessionId ? { sessionId: this.sessionId } : {},
|
|
1902
|
-
...model ? { model } : {},
|
|
1903
|
-
...thinking ? { thinking } : {},
|
|
1904
|
-
updatedAt: Date.now(),
|
|
1905
|
-
pendingMessages: this.local ? context?.hasPendingMessages() ?? false : false,
|
|
1906
|
-
local: this.local
|
|
1907
|
-
};
|
|
1908
|
-
}
|
|
1909
|
-
async switchModel(target, context) {
|
|
1910
|
-
if (!this.local) {
|
|
1911
|
-
return { ok: false, error: `Main agent ${this.id} is owned by another Fabric process` };
|
|
1912
|
-
}
|
|
1913
|
-
const key = `${target.provider}/${target.id}`;
|
|
1914
|
-
const model = context.modelRegistry.find(target.provider, target.id);
|
|
1915
|
-
if (!model) return { ok: false, error: `Model is not available: ${key}` };
|
|
1916
|
-
const switched = await this.pi.setModel(model);
|
|
1917
|
-
if (!switched) return { ok: false, error: `No authentication configured for model: ${key}` };
|
|
1918
|
-
return { ok: true };
|
|
1919
|
-
}
|
|
1920
|
-
deliverUser(message, delivery) {
|
|
1921
|
-
if (!this.local) throw new Error(`Main agent ${this.id} is owned by another Fabric process`);
|
|
1922
|
-
const text = message.trim();
|
|
1923
|
-
if (!text) throw new Error("Main agent message must not be empty");
|
|
1924
|
-
const messageId = randomUUID3();
|
|
1925
|
-
this.pi.sendUserMessage(text, { deliverAs: delivery });
|
|
1926
|
-
return { queued: true, messageId, routed: "main" };
|
|
1927
|
-
}
|
|
1928
|
-
deliverAgent(request) {
|
|
1929
|
-
if (!this.local) throw new Error(`Main agent ${this.id} is owned by another Fabric process`);
|
|
1930
|
-
const message = request.message.trim();
|
|
1931
|
-
if (!message) throw new Error("Main agent message must not be empty");
|
|
1932
|
-
const messageId = randomUUID3();
|
|
1933
|
-
const data = request.data === void 0 ? void 0 : serializableData(request.data);
|
|
1934
|
-
this.pi.sendMessage(
|
|
1935
|
-
{
|
|
1936
|
-
customType: "pi-fabric-agent-message",
|
|
1937
|
-
content: [
|
|
1938
|
-
`<fabric-agent-message from_name=${JSON.stringify(request.from.name)} from_id=${JSON.stringify(request.from.id)} from_kind=${JSON.stringify(request.from.kind)}>`,
|
|
1939
|
-
escapeXmlText(message),
|
|
1940
|
-
data === void 0 ? void 0 : `<data>${escapeXmlText(JSON.stringify(data))}</data>`,
|
|
1941
|
-
"</fabric-agent-message>"
|
|
1942
|
-
].filter((line) => Boolean(line)).join("\n"),
|
|
1943
|
-
display: true,
|
|
1944
|
-
details: {
|
|
1945
|
-
id: messageId,
|
|
1946
|
-
from: structuredClone(request.from),
|
|
1947
|
-
delivery: request.delivery,
|
|
1948
|
-
triggerTurn: request.triggerTurn ?? true,
|
|
1949
|
-
...data === void 0 ? {} : { data }
|
|
1950
|
-
}
|
|
1951
|
-
},
|
|
1952
|
-
{ deliverAs: request.delivery, triggerTurn: request.triggerTurn ?? true }
|
|
1953
|
-
);
|
|
1954
|
-
return { queued: true, messageId, routed: "main" };
|
|
1955
|
-
}
|
|
1956
|
-
};
|
|
1957
|
-
|
|
1958
1958
|
export {
|
|
1959
1959
|
CapturedToolCatalog,
|
|
1960
|
+
resolveFabricIdentity,
|
|
1961
|
+
MainAgentController,
|
|
1960
1962
|
HANDOFF_COMPLETION_MESSAGE_TYPE,
|
|
1961
1963
|
PREWALK_ARMED_MESSAGE_TYPE,
|
|
1962
1964
|
filterPrewalkContinuationMessages,
|
|
@@ -1977,8 +1979,6 @@ export {
|
|
|
1977
1979
|
FabricProviderComponentManifest,
|
|
1978
1980
|
createProviderComponent,
|
|
1979
1981
|
PrewalkController,
|
|
1980
|
-
PrewalkDriftTracker
|
|
1981
|
-
resolveFabricIdentity,
|
|
1982
|
-
MainAgentController
|
|
1982
|
+
PrewalkDriftTracker
|
|
1983
1983
|
};
|
|
1984
|
-
//# sourceMappingURL=chunk-
|
|
1984
|
+
//# sourceMappingURL=chunk-MAP2LVSM.js.map
|