pi-fabric 0.76.0 → 0.76.2
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-NI3ZXJZD.js → chunk-PAAXKXWT.js} +293 -1
- package/dist/chunks/{chunk-NI3ZXJZD.js.map → chunk-PAAXKXWT.js.map} +3 -3
- package/dist/chunks/{fabric-runtime-state-FBAJTXB2.js → fabric-runtime-state-VCLWTB55.js} +7 -5
- package/dist/chunks/fabric-runtime-state-VCLWTB55.js.map +7 -0
- package/dist/core/system-guidance.d.ts.map +1 -1
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/fabric-exec-arguments.d.ts.map +1 -1
- package/dist/fabric-exec-tool.d.ts.map +1 -1
- package/dist/index.js +71 -32
- package/dist/index.js.map +3 -3
- package/dist/runtime/guest-code-repair.d.ts +2 -0
- package/dist/runtime/guest-code-repair.d.ts.map +1 -0
- package/dist/type-error-guidance.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/fabric-runtime-state-FBAJTXB2.js.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-guidance.d.ts","sourceRoot":"","sources":["../../src/core/system-guidance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"system-guidance.d.ts","sourceRoot":"","sources":["../../src/core/system-guidance.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,6BAA6B,GAAI,cAAc,OAAO,KAAG,MASzD,CAAC;AAEd,eAAO,MAAM,8BAA8B,GAAI,cAAc,OAAO,KAAG,MAGoQ,CAAC;AAG5U,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD;AAqCD,eAAO,MAAM,2BAA2B,GACtC,OAAO,aAAa,CAAC,yBAAyB,CAAC,EAC/C,eAAe,WAAW,CAAC,MAAM,CAAC,KACjC,MAAM,GAAG,SA8BX,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,KAAK,GAAG,OAAO,GAAG,SAAS,KAAG,MAAM,GAAG,SAQjF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-service.d.ts","sourceRoot":"","sources":["../src/execution-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAML,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAIV,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EAErB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,sBAAsB,EAEvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAKlF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"execution-service.d.ts","sourceRoot":"","sources":["../src/execution-service.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fabric-exec-arguments.d.ts","sourceRoot":"","sources":["../src/fabric-exec-arguments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fabric-exec-arguments.d.ts","sourceRoot":"","sources":["../src/fabric-exec-arguments.ts"],"names":[],"mappings":"AA0DA,eAAO,MAAM,yBAAyB,GAAI,QAAQ;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAC8D,CAAC;AAE5F,eAAO,MAAM,0BAA0B,GAAI,OAAO,OAAO,KAAG,OA4C3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fabric-exec-tool.d.ts","sourceRoot":"","sources":["../src/fabric-exec-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAa7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,4BAA4B,CAAC;AAQpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"fabric-exec-tool.d.ts","sourceRoot":"","sources":["../src/fabric-exec-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAa7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,4BAA4B,CAAC;AAQpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AASrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AA6CjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAiDxE,eAAO,MAAM,oBAAoB,GAC/B,OAAO,WAAW,EAClB,qBAAqB,mBAAmB,EACxC,iBAAiB,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAClD,gBAAe,wBAA+C,EAC9D,cAAc,2BAA2B,KACxC,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAk1B9B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,10 +15,11 @@ import {
|
|
|
15
15
|
formatSkillsForPrompt,
|
|
16
16
|
hasPrewalkArmedPrompt,
|
|
17
17
|
prewalkArmedPrompt,
|
|
18
|
+
repairFabricGuestCode,
|
|
18
19
|
resolveFabricIdentity,
|
|
19
20
|
settleInPlacePrewalk,
|
|
20
21
|
withTrajectoryRearmDirective
|
|
21
|
-
} from "./chunks/chunk-
|
|
22
|
+
} from "./chunks/chunk-PAAXKXWT.js";
|
|
22
23
|
import {
|
|
23
24
|
activeStatuses,
|
|
24
25
|
arcItemStyled,
|
|
@@ -1603,6 +1604,8 @@ ${sections.join("\n")}` : "";
|
|
|
1603
1604
|
};
|
|
1604
1605
|
|
|
1605
1606
|
// src/core/system-guidance.ts
|
|
1607
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
1608
|
+
import * as path4 from "node:path";
|
|
1606
1609
|
var fabricExecutionKernelGuidance = (fullCodeMode) => [
|
|
1607
1610
|
fullCodeMode ? "Pi Fabric full code mode: `fabric_exec` is the only way to call Pi core tools \u2014 use them as `pi.*` inside `code`." : "Pi Fabric is in orchestration-only mode. Pi core and registered extension tools stay on their native direct execution path; inside fabric_exec, `pi.*` and `extensions.*` are unavailable.",
|
|
1608
1611
|
// Files the model has not opened (images in particular) must be read before
|
|
@@ -1611,13 +1614,38 @@ var fabricExecutionKernelGuidance = (fullCodeMode) => [
|
|
|
1611
1614
|
`Read every file the user provides (images, screenshots, code, text) with the ${fullCodeMode ? "`pi.read`" : "`read`"} tool before responding \u2014 never assume its contents.`
|
|
1612
1615
|
].join(" ");
|
|
1613
1616
|
var defaultFabricExecutionGuidance = (fullCodeMode) => fullCodeMode ? "Examples and returns: `pi.read('/x')`, `pi.grep('TODO','src')` / `pi.grep({pattern:'TODO', path:'src', ignoreCase:true, context:2})`, `pi.find({pattern:'*.ts', path:'src', limit:20})`, and `pi.ls('src')` return strings; `pi.bash({cmd:'ls'})`, `pi.edit({path:'/x', old:'a', new:'b'})`, and `pi.write({path:'/y', text:'z'})` return `{ok, output, details}` (read `.output`); failed core calls reject, including `bash` on an ordinary nonzero exit; pass `settle: true` to `pi.bash` to get `{ ok: false, exitCode, output, error }` instead. Timeout, cancellation, approval, and security failures still reject.\n`tools` is discovery + generic calls only (`providers`/`catalog`/`list`/`search`/`describe`/`call`/`models`). Call known MCP tools as `mcp.<sanitized_server>.<sanitized_tool>(args)`, captured tools as `extensions.<tool>(args)`, and stable providers as `memory.*`, `state.*`, `schema.*`, or `compact.*`. Use `tools.call({ref,args})` for computed refs. `pi` is the core tools; `\u03C0.<key>` reads named `strings` (not a tool)." : "Call known actions through `mcp.<sanitized_server>.<sanitized_tool>(args)`, `memory.*`, `state.*`, `schema.*`, `components.*`, `compact.*`, `agents.*`, or `mesh.*`; use `tools.catalog`/`search`/`describe`/`list` for discovery and `tools.call({ref,args})` for computed refs. Other surfaces are opt-in via user-loaded skills.";
|
|
1617
|
+
var manifestNameCache = /* @__PURE__ */ new Map();
|
|
1618
|
+
var packageNameFromManifest = (startPath) => {
|
|
1619
|
+
if (!startPath) return void 0;
|
|
1620
|
+
let directory = path4.dirname(path4.resolve(startPath));
|
|
1621
|
+
while (true) {
|
|
1622
|
+
if (manifestNameCache.has(directory)) return manifestNameCache.get(directory);
|
|
1623
|
+
const manifestPath = path4.join(directory, "package.json");
|
|
1624
|
+
let name;
|
|
1625
|
+
if (existsSync2(manifestPath)) {
|
|
1626
|
+
try {
|
|
1627
|
+
const manifest = JSON.parse(readFileSync2(manifestPath, "utf8"));
|
|
1628
|
+
if (typeof manifest.name === "string" && manifest.name.trim()) name = manifest.name.trim();
|
|
1629
|
+
} catch {
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
manifestNameCache.set(directory, name);
|
|
1633
|
+
if (name) return name;
|
|
1634
|
+
const parent = path4.dirname(directory);
|
|
1635
|
+
if (parent === directory) return void 0;
|
|
1636
|
+
directory = parent;
|
|
1637
|
+
}
|
|
1638
|
+
};
|
|
1614
1639
|
var extensionToolRosterGuidance = (tools, coreToolNames) => {
|
|
1615
1640
|
const extensionTools = tools.filter((tool) => !coreToolNames.has(tool.name));
|
|
1616
1641
|
if (extensionTools.length === 0) return void 0;
|
|
1617
1642
|
const namespaceLabel = (tool) => {
|
|
1618
1643
|
const source = tool.sourceInfo?.source?.trim();
|
|
1619
|
-
if (source) return source;
|
|
1620
|
-
const
|
|
1644
|
+
if (source?.startsWith("npm:")) return source.slice("npm:".length) || source;
|
|
1645
|
+
const manifestName = packageNameFromManifest(tool.sourceInfo?.path) ?? packageNameFromManifest(source && /[\\/]/.test(source) ? source : void 0);
|
|
1646
|
+
if (manifestName) return manifestName;
|
|
1647
|
+
if (source && !/[\\/]/.test(source)) return source;
|
|
1648
|
+
const parts = (tool.sourceInfo?.path ?? source ?? "").split(/[\\/]/).filter(Boolean);
|
|
1621
1649
|
const base = parts.at(-1)?.trim() ?? "";
|
|
1622
1650
|
if (/^index\./i.test(base)) return parts.at(-2)?.trim() || base;
|
|
1623
1651
|
return base || "extensions";
|
|
@@ -1851,8 +1879,8 @@ var formatFailureProgress = (trace) => {
|
|
|
1851
1879
|
);
|
|
1852
1880
|
if (completed.length === 0) return void 0;
|
|
1853
1881
|
const summaries = completed.slice(0, MAX_COMPLETED_CALLS).map((operation) => {
|
|
1854
|
-
const
|
|
1855
|
-
return typeof
|
|
1882
|
+
const path10 = operation.args.path;
|
|
1883
|
+
return typeof path10 === "string" ? `${operation.ref}(${compactPath(path10)})` : operation.ref;
|
|
1856
1884
|
});
|
|
1857
1885
|
const omitted = completed.length - summaries.length;
|
|
1858
1886
|
return [
|
|
@@ -1901,7 +1929,7 @@ var normalizeFabricExecStrings = (input) => {
|
|
|
1901
1929
|
};
|
|
1902
1930
|
var resolveFabricExecPayloads = (params) => normalizeFabricExecStrings(params.payloads) ?? normalizeFabricExecStrings(params.strings);
|
|
1903
1931
|
var prepareFabricExecArguments = (input) => {
|
|
1904
|
-
if (typeof input === "string") return { code: input };
|
|
1932
|
+
if (typeof input === "string") return { code: repairFabricGuestCode(input) };
|
|
1905
1933
|
if (!isRecord4(input)) return input;
|
|
1906
1934
|
let prepared = input;
|
|
1907
1935
|
const writable = () => {
|
|
@@ -1911,6 +1939,10 @@ var prepareFabricExecArguments = (input) => {
|
|
|
1911
1939
|
if (Array.isArray(prepared.code) && prepared.code.every((line) => typeof line === "string")) {
|
|
1912
1940
|
writable().code = prepared.code.join("\n");
|
|
1913
1941
|
}
|
|
1942
|
+
if (typeof prepared.code === "string") {
|
|
1943
|
+
const repaired = repairFabricGuestCode(prepared.code);
|
|
1944
|
+
if (repaired !== prepared.code) writable().code = repaired;
|
|
1945
|
+
}
|
|
1914
1946
|
for (const key of OPTIONAL_FABRIC_EXEC_KEYS) {
|
|
1915
1947
|
if (!Object.hasOwn(prepared, key)) continue;
|
|
1916
1948
|
if (prepared[key] === null || prepared[key] === void 0) delete writable()[key];
|
|
@@ -1999,6 +2031,7 @@ var CORE_TOOL_PROPERTIES = collectCoreToolProperties(GUEST_TYPE_DECLARATIONS);
|
|
|
1999
2031
|
// src/type-error-guidance.ts
|
|
2000
2032
|
var SYNTAX_ERROR_PATTERN = /expected|unterminated|unexpected|invalid character/i;
|
|
2001
2033
|
var PAYLOAD_CALL_PATTERN = /\bpi\.(?:edit|write)\s*\(/;
|
|
2034
|
+
var UNQUOTED_PATH_HEAD = /\bpi\.(?:read|ls|write|edit)\(\s*(?:https?:\/\/|\/(?![/*])|\.\/|\.\.\/|~\/|[A-Za-z]:[\\/])/;
|
|
2002
2035
|
var PROMISE_ALL_PATTERN = /\bPromise\.all\s*\(/;
|
|
2003
2036
|
var TUPLE_ARITY_PATTERN = /Tuple type .* of length '[0-9]+' has no element at index '[0-9]+'/;
|
|
2004
2037
|
var MISSING_NAME_PATTERN = /^Cannot find name '([^']+)'/;
|
|
@@ -2084,6 +2117,11 @@ var typeErrorRecoveryHint = (code, errors) => {
|
|
|
2084
2117
|
if (hasLiteralPayloadInterpolation(code, errors)) {
|
|
2085
2118
|
return "Recovery hint: a `${...}` expression in an edit/write payload is being evaluated by the Fabric TypeScript program. Declare it if intentional; for literal file content, move the payload to top-level `payloads` and reference `\u03C0.key`.";
|
|
2086
2119
|
}
|
|
2120
|
+
if (UNQUOTED_PATH_HEAD.test(code) && errors.some(
|
|
2121
|
+
(error) => SYNTAX_ERROR_PATTERN.test(error.message) || error.message.includes("Cannot find name") || error.message.includes("Expected 1-2 arguments")
|
|
2122
|
+
)) {
|
|
2123
|
+
return "Recovery hint: quote filesystem paths and URLs as strings, e.g. `pi.read('/x')` or `pi.read({ path: '/x' })`. Unquoted paths are parsed as regex, division, or extra arguments.";
|
|
2124
|
+
}
|
|
2087
2125
|
if (!PAYLOAD_CALL_PATTERN.test(code)) return void 0;
|
|
2088
2126
|
if (!errors.some((error) => SYNTAX_ERROR_PATTERN.test(error.message))) {
|
|
2089
2127
|
return void 0;
|
|
@@ -2175,12 +2213,12 @@ var PartialResultObserver = class {
|
|
|
2175
2213
|
// src/output-budget.ts
|
|
2176
2214
|
import { mkdtemp, writeFile } from "node:fs/promises";
|
|
2177
2215
|
import { tmpdir } from "node:os";
|
|
2178
|
-
import
|
|
2216
|
+
import path5 from "node:path";
|
|
2179
2217
|
var MAX_FAILURE_MODEL_OUTPUT_CHARS = 2e4;
|
|
2180
2218
|
var modelOutputBudget = (configuredMaxChars, success) => success ? configuredMaxChars : Math.min(configuredMaxChars, MAX_FAILURE_MODEL_OUTPUT_CHARS);
|
|
2181
2219
|
var writeOutputArtifact = async (content) => {
|
|
2182
|
-
const directory = await mkdtemp(
|
|
2183
|
-
const artifactPath =
|
|
2220
|
+
const directory = await mkdtemp(path5.join(tmpdir(), "pi-fabric-output-"));
|
|
2221
|
+
const artifactPath = path5.join(directory, "output.txt");
|
|
2184
2222
|
await writeFile(artifactPath, content, { encoding: "utf8", mode: 384 });
|
|
2185
2223
|
return artifactPath;
|
|
2186
2224
|
};
|
|
@@ -2786,7 +2824,8 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
2786
2824
|
},
|
|
2787
2825
|
async execute(toolCallId, params, signal, onUpdate, context) {
|
|
2788
2826
|
await state.ensure(context);
|
|
2789
|
-
const
|
|
2827
|
+
const joined = Array.isArray(params.code) ? params.code.join("\n") : params.code;
|
|
2828
|
+
const code = repairFabricGuestCode(joined);
|
|
2790
2829
|
const runDisplay = normalizeRunDisplay(params.display);
|
|
2791
2830
|
const strings = resolveFabricExecPayloads(params);
|
|
2792
2831
|
const result = await state.execution.execute({
|
|
@@ -2923,7 +2962,7 @@ ${recoveryHint}` : ""}`,
|
|
|
2923
2962
|
|
|
2924
2963
|
// src/fabric-state.ts
|
|
2925
2964
|
import fs2 from "node:fs";
|
|
2926
|
-
import
|
|
2965
|
+
import path6 from "node:path";
|
|
2927
2966
|
var FabricState = class {
|
|
2928
2967
|
constructor(pi, capturedTools, options = {}) {
|
|
2929
2968
|
this.pi = pi;
|
|
@@ -3059,10 +3098,10 @@ var FabricState = class {
|
|
|
3059
3098
|
const sessionId = context.sessionManager.getSessionId();
|
|
3060
3099
|
if (resolveFabricIdentity(sessionId).identity.kind !== "main") return false;
|
|
3061
3100
|
const projectRoot = process.env.PI_FABRIC_PROJECT_ROOT ?? context.cwd;
|
|
3062
|
-
const meshRoot = process.env.PI_FABRIC_MESH_ROOT ?? (this.config.mesh.root ?
|
|
3063
|
-
const actorRoot = this.config.mesh.actorScope === "session" ?
|
|
3101
|
+
const meshRoot = process.env.PI_FABRIC_MESH_ROOT ?? (this.config.mesh.root ? path6.resolve(projectRoot, this.config.mesh.root) : path6.join(projectRoot, ".pi", "fabric", "mesh"));
|
|
3102
|
+
const actorRoot = this.config.mesh.actorScope === "session" ? path6.join(meshRoot, "actors", sessionId) : path6.join(meshRoot, "actors");
|
|
3064
3103
|
try {
|
|
3065
|
-
const registry = JSON.parse(fs2.readFileSync(
|
|
3104
|
+
const registry = JSON.parse(fs2.readFileSync(path6.join(actorRoot, "actors.json"), "utf8"));
|
|
3066
3105
|
if (typeof registry !== "object" || registry === null || Array.isArray(registry)) return false;
|
|
3067
3106
|
const actors = registry.actors;
|
|
3068
3107
|
return Array.isArray(actors) && actors.some((value) => {
|
|
@@ -3267,7 +3306,7 @@ var FabricState = class {
|
|
|
3267
3306
|
return activation;
|
|
3268
3307
|
}
|
|
3269
3308
|
async #createRuntime() {
|
|
3270
|
-
const module = await (this.#options.runtimeLoader?.() ?? import("./chunks/fabric-runtime-state-
|
|
3309
|
+
const module = await (this.#options.runtimeLoader?.() ?? import("./chunks/fabric-runtime-state-VCLWTB55.js"));
|
|
3271
3310
|
return new module.FabricRuntimeState(
|
|
3272
3311
|
this.pi,
|
|
3273
3312
|
this.capturedTools,
|
|
@@ -3291,8 +3330,8 @@ var FabricState = class {
|
|
|
3291
3330
|
};
|
|
3292
3331
|
|
|
3293
3332
|
// src/host-compatibility.ts
|
|
3294
|
-
import { existsSync as
|
|
3295
|
-
import
|
|
3333
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
|
|
3334
|
+
import path7 from "node:path";
|
|
3296
3335
|
var MINIMUM_PI_HOST_VERSION = "0.80.6";
|
|
3297
3336
|
var PI_HOST_PACKAGE_NAMES = /* @__PURE__ */ new Set([
|
|
3298
3337
|
"@earendil-works/pi-coding-agent",
|
|
@@ -3323,22 +3362,22 @@ var detectPiHostVersion = (cliPath = process.argv[1]) => {
|
|
|
3323
3362
|
if (!cliPath) return void 0;
|
|
3324
3363
|
let directory;
|
|
3325
3364
|
try {
|
|
3326
|
-
directory =
|
|
3365
|
+
directory = path7.dirname(realpathSync2(cliPath));
|
|
3327
3366
|
} catch {
|
|
3328
3367
|
return void 0;
|
|
3329
3368
|
}
|
|
3330
3369
|
while (true) {
|
|
3331
|
-
const manifestPath =
|
|
3332
|
-
if (
|
|
3370
|
+
const manifestPath = path7.join(directory, "package.json");
|
|
3371
|
+
if (existsSync3(manifestPath)) {
|
|
3333
3372
|
try {
|
|
3334
|
-
const manifest = JSON.parse(
|
|
3373
|
+
const manifest = JSON.parse(readFileSync3(manifestPath, "utf8"));
|
|
3335
3374
|
if (typeof manifest.name === "string" && PI_HOST_PACKAGE_NAMES.has(manifest.name) && typeof manifest.version === "string") {
|
|
3336
3375
|
return manifest.version;
|
|
3337
3376
|
}
|
|
3338
3377
|
} catch {
|
|
3339
3378
|
}
|
|
3340
3379
|
}
|
|
3341
|
-
const parent =
|
|
3380
|
+
const parent = path7.dirname(directory);
|
|
3342
3381
|
if (parent === directory) return void 0;
|
|
3343
3382
|
directory = parent;
|
|
3344
3383
|
}
|
|
@@ -3351,7 +3390,7 @@ var piHostCompatibilityWarning = (version = detectPiHostVersion()) => {
|
|
|
3351
3390
|
};
|
|
3352
3391
|
|
|
3353
3392
|
// src/ui/controller.ts
|
|
3354
|
-
import
|
|
3393
|
+
import path8 from "node:path";
|
|
3355
3394
|
|
|
3356
3395
|
// src/ui/snapshot.ts
|
|
3357
3396
|
var MAX_UI_AGENTS = 240;
|
|
@@ -4063,7 +4102,7 @@ var FabricUiController = class {
|
|
|
4063
4102
|
logFile: actor.worker.logFile
|
|
4064
4103
|
};
|
|
4065
4104
|
}
|
|
4066
|
-
const retained = actor.lastRunId && actor.logDir ?
|
|
4105
|
+
const retained = actor.lastRunId && actor.logDir ? path8.join(actor.logDir, actor.lastRunId, "events.jsonl") : void 0;
|
|
4067
4106
|
if (retained) return { id: actor.id, status: actor.status, logFile: retained };
|
|
4068
4107
|
if (actor.sessionFile) {
|
|
4069
4108
|
return { id: actor.id, status: actor.status, logFile: actor.sessionFile };
|
|
@@ -4182,16 +4221,16 @@ var FabricToolDisplayController = class {
|
|
|
4182
4221
|
var REFRESH_CARDS_PER_TICK = 3;
|
|
4183
4222
|
|
|
4184
4223
|
// src/index.ts
|
|
4185
|
-
import { existsSync as
|
|
4186
|
-
import
|
|
4224
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
4225
|
+
import path9 from "node:path";
|
|
4187
4226
|
import { fileURLToPath } from "node:url";
|
|
4188
|
-
var FABRIC_EXTENSION_ENTRY_PATH =
|
|
4189
|
-
var FABRIC_ENTRY_DIR =
|
|
4227
|
+
var FABRIC_EXTENSION_ENTRY_PATH = path9.resolve(fileURLToPath(import.meta.url));
|
|
4228
|
+
var FABRIC_ENTRY_DIR = path9.dirname(FABRIC_EXTENSION_ENTRY_PATH);
|
|
4190
4229
|
var FABRIC_RUNTIME_PATHS = {
|
|
4191
4230
|
extension: FABRIC_EXTENSION_ENTRY_PATH,
|
|
4192
|
-
worker:
|
|
4193
|
-
residentHost:
|
|
4194
|
-
skills:
|
|
4231
|
+
worker: path9.join(FABRIC_ENTRY_DIR, "worker.js"),
|
|
4232
|
+
residentHost: path9.join(FABRIC_ENTRY_DIR, "residency", "launcher.js"),
|
|
4233
|
+
skills: path9.resolve(FABRIC_ENTRY_DIR, "..", "skills")
|
|
4195
4234
|
};
|
|
4196
4235
|
var FABRIC_SKILLS_DIR = FABRIC_RUNTIME_PATHS.skills;
|
|
4197
4236
|
var componentRegistrationFrom = (value) => {
|
|
@@ -4273,7 +4312,7 @@ async function piFabric(pi) {
|
|
|
4273
4312
|
}
|
|
4274
4313
|
);
|
|
4275
4314
|
pi.on("resources_discover", async () => {
|
|
4276
|
-
if (
|
|
4315
|
+
if (existsSync4(FABRIC_SKILLS_DIR)) return { skillPaths: [FABRIC_SKILLS_DIR] };
|
|
4277
4316
|
return {};
|
|
4278
4317
|
});
|
|
4279
4318
|
const fabricTool = createFabricExecTool(
|