pi-fabric 0.132.2 → 0.132.3
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-UJPP3EVE.js → chunk-5INZBPCM.js} +51 -18
- package/dist/chunks/chunk-5INZBPCM.js.map +7 -0
- package/dist/core/execution-guidelines.d.ts +6 -0
- package/dist/core/execution-guidelines.d.ts.map +1 -0
- package/dist/core/guidance-delivery.d.ts +19 -0
- package/dist/core/guidance-delivery.d.ts.map +1 -0
- package/dist/core/prompt-guidance.d.ts +1 -0
- package/dist/core/prompt-guidance.d.ts.map +1 -1
- package/dist/core/prompt-guidance.js +50 -1
- package/dist/core/prompt-guidance.js.map +3 -3
- package/dist/durable-extension.js +1 -1
- package/dist/durable-extension.js.map +1 -1
- package/dist/extension-bootstrap.d.ts.map +1 -1
- package/dist/extension-bootstrap.js +1 -1
- package/dist/extension.d.ts.map +1 -1
- package/dist/fabric-exec-tool.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +16 -4
- package/dist/fabric-runtime-state.js.map +2 -2
- package/dist/index.js +1 -1
- package/dist/topology/peer-presence.d.ts.map +1 -1
- package/dist/verified/generated/manifest.json +12 -3
- package/dist/verified/generated/prompt-guidance.d.ts +4 -0
- package/dist/verified/generated/prompt-guidance.js +17 -0
- package/docs/agents.md +1 -0
- package/docs/verified-kernels.md +23 -0
- package/package.json +1 -1
- package/proofs/index.ts +2 -0
- package/proofs/prompt-guidance.ts +38 -0
- package/scripts/verified-kernels.ts +1 -1
- package/dist/chunks/chunk-UJPP3EVE.js.map +0 -7
|
@@ -1781,6 +1781,25 @@ var FabricDirectToolApproval = class {
|
|
|
1781
1781
|
}
|
|
1782
1782
|
};
|
|
1783
1783
|
|
|
1784
|
+
// src/core/execution-guidelines.ts
|
|
1785
|
+
var fabricExecutionGuidelines = (kernel = "typescript", pythonRuntime = "monty", managedHost = false) => managedHost ? [
|
|
1786
|
+
"Batch independent operations with bounded concurrency, keep dependent calls ordered, inspect results, and return compact evidence."
|
|
1787
|
+
] : [
|
|
1788
|
+
kernel === "python" ? "Batch independent operations in one `fabric_exec` Python program with `asyncio.gather`; await dependent/conditional steps sequentially. Coalesce independent replacements into one `await pi.edit(path=..., edits=[...])`. Return only the compact final JSON-compatible value." : "Batch independent operations in one `fabric_exec` program (`Promise.all` for parallel, sequential `await` for ordered), not one call per tool; keep dependent/conditional steps sequential. Coalesce non-dependent replacements from one file snapshot into one `pi.edit({path, edits:[...]})`; use `all:true` only for intentional repeated exact anchors. Return only the compact final value; intermediate results stay in the sandbox.",
|
|
1789
|
+
kernel === "python" ? "Search before reading with `await pi.grep(pattern=..., path=...)` or `await pi.find(pattern=..., path=...)`, then `await pi.read(path=..., offset=..., limit=...)`. Use Python dict syntax, `True`/`False`/`None`, and bounded searches; unbounded reads cap at 2000 lines or 50KB. Read continuation notices when needed." : "Search before reading: use `pi.grep`/`pi.find` to locate relevant lines, then `pi.read({path, offset, limit})` that range. Escape regex metacharacters, or use `literal:true` for exact punctuated text. Keep fan-out search limits small and widen only on misses. An unbounded `pi.read` returns at most 2000 lines or 50KB and, when truncated, ends with a `Use offset=\u2026` continuation notice; reserve whole-file reads for small files you will use in full.",
|
|
1790
|
+
"Keep the acceptance ledger in reasoning or concise progress notes (no tool call): define concrete checks, trace execution before editing, implement end to end, then run targeted tests and direct behavioral probes. Confirm requested public symbols, registrations, and configuration entries. Use the smallest checks that cover the ledger; escalate only for failures or cross-cutting risk. Inspect failures and iterate instead of rerunning unchanged passing checks. A build alone is not completion.",
|
|
1791
|
+
kernel === "python" ? "For test/probe nonzero exits, use `await pi.bash(command=..., settle=True)` and inspect the returned dict: `r['ok']`, `r['output']`, and `r.get('exitCode')`. Set shell `timeout` in seconds once for long suites. Return decisions and evidence rather than raw logs." : "Amortize round trips without inflating context: batch only independent, bounded work. Keep search\u2192read and edit\u2192verify sequential when an output determines the next action. Use `settle:true` for tests or probes whose nonzero result is evidence rather than an exceptional stop; for a known long suite, set `pi.bash` `timeout` in seconds once instead of retrying a timed-out call. Filter or summarize noisy command output inside the program and return decisions, failures, and evidence\u2014not raw logs or unused intermediate results.",
|
|
1792
|
+
"For edits/writes, pass named payloads through top-level `payloads`; each `\u03C0.key` must exactly match a key there; prefer `pi.edit`/`pi.write`. `pi.bash`: no stdin.",
|
|
1793
|
+
"Use `display.name` and objective `display.description`; Fabric pairs them with verified outcomes in deterministic compaction.",
|
|
1794
|
+
...kernel === "python" && pythonRuntime === "monty" ? ["Monty requires acyclic JSON host arguments. For underscore-prefixed provider/tool names, use `await tools.call(ref=..., args={...})`, not direct attributes. Use `payloads['key']` for private/non-identifier payload keys."] : []
|
|
1795
|
+
];
|
|
1796
|
+
var fabricOwnedExecutionGuidelines = () => [.../* @__PURE__ */ new Set([
|
|
1797
|
+
...fabricExecutionGuidelines(),
|
|
1798
|
+
...fabricExecutionGuidelines("python", "monty"),
|
|
1799
|
+
...fabricExecutionGuidelines("python", "cpython"),
|
|
1800
|
+
...fabricExecutionGuidelines("typescript", "monty", true)
|
|
1801
|
+
])];
|
|
1802
|
+
|
|
1784
1803
|
// src/fabric-exec-tool.ts
|
|
1785
1804
|
import { Container as Container2, Text as Text2 } from "@earendil-works/pi-tui";
|
|
1786
1805
|
import { Type } from "typebox";
|
|
@@ -2100,17 +2119,7 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
|
|
|
2100
2119
|
label: "Fabric",
|
|
2101
2120
|
description: managedHost ? "Execute type-checked TypeScript in the managed QuickJS runtime. See the managed execution guidance for authorized tool contracts." : python ? monty ? "Execute Python through Fabric's configured Monty sandbox. Monty runs a Python subset with VM resource limits, no native filesystem/network/environment access, and only host-mediated tools. Each invocation starts fresh. This is the exclusive model tool path in full code mode and Schema enforce mode." : "Execute Python through Fabric\u2019s configured CPython kernel for Pi core tools, MCP, providers, discovery, and extensions. Each call uses a fresh process. Native execution is trusted code; Schema enforce requires OS isolation. This is the exclusive model tool path in full code mode and Schema enforce mode." : "Execute code through Fabric's TypeScript kernel: type-checked TypeScript by default, unmodified JavaScript with executor.codemodeProfile native. Both support nativeTools; native mode places Pi-compatible calls on tools and Fabric discovery on fabric.tools. Compose Pi core tools, MCP, Fabric providers, discovery, and extensions. QuickJS is isolated by default; the optional Node/Bun process is an unsafe trusted-code escape hatch. In full code mode, and always in Schema enforce mode, this is the exclusive model tool path.",
|
|
2102
2121
|
promptSnippet: managedHost ? `Authorized host tools (${managedHost.providers.join(", ") || "none"}) and deterministic computation` : "Pi core tools, MCP, Fabric providers, discovery, and extensions",
|
|
2103
|
-
promptGuidelines:
|
|
2104
|
-
"Batch independent operations with bounded concurrency, keep dependent calls ordered, inspect results, and return compact evidence."
|
|
2105
|
-
] : [
|
|
2106
|
-
python ? "Batch independent operations in one `fabric_exec` Python program with `asyncio.gather`; await dependent/conditional steps sequentially. Coalesce independent replacements into one `await pi.edit(path=..., edits=[...])`. Return only the compact final JSON-compatible value." : "Batch independent operations in one `fabric_exec` program (`Promise.all` for parallel, sequential `await` for ordered), not one call per tool; keep dependent/conditional steps sequential. Coalesce non-dependent replacements from one file snapshot into one `pi.edit({path, edits:[...]})`; use `all:true` only for intentional repeated exact anchors. Return only the compact final value; intermediate results stay in the sandbox.",
|
|
2107
|
-
python ? "Search before reading with `await pi.grep(pattern=..., path=...)` or `await pi.find(pattern=..., path=...)`, then `await pi.read(path=..., offset=..., limit=...)`. Use Python dict syntax, `True`/`False`/`None`, and bounded searches; unbounded reads cap at 2000 lines or 50KB. Read continuation notices when needed." : "Search before reading: use `pi.grep`/`pi.find` to locate relevant lines, then `pi.read({path, offset, limit})` that range. Escape regex metacharacters, or use `literal:true` for exact punctuated text. Keep fan-out search limits small and widen only on misses. An unbounded `pi.read` returns at most 2000 lines or 50KB and, when truncated, ends with a `Use offset=\u2026` continuation notice; reserve whole-file reads for small files you will use in full.",
|
|
2108
|
-
"Keep the acceptance ledger in reasoning or concise progress notes (no tool call): define concrete checks, trace execution before editing, implement end to end, then run targeted tests and direct behavioral probes. Confirm requested public symbols, registrations, and configuration entries. Use the smallest checks that cover the ledger; escalate only for failures or cross-cutting risk. Inspect failures and iterate instead of rerunning unchanged passing checks. A build alone is not completion.",
|
|
2109
|
-
python ? "For test/probe nonzero exits, use `await pi.bash(command=..., settle=True)` and inspect the returned dict: `r['ok']`, `r['output']`, and `r.get('exitCode')`. Set shell `timeout` in seconds once for long suites. Return decisions and evidence rather than raw logs." : "Amortize round trips without inflating context: batch only independent, bounded work. Keep search\u2192read and edit\u2192verify sequential when an output determines the next action. Use `settle:true` for tests or probes whose nonzero result is evidence rather than an exceptional stop; for a known long suite, set `pi.bash` `timeout` in seconds once instead of retrying a timed-out call. Filter or summarize noisy command output inside the program and return decisions, failures, and evidence\u2014not raw logs or unused intermediate results.",
|
|
2110
|
-
"For edits/writes, pass named payloads through top-level `payloads`; each `\u03C0.key` must exactly match a key there; prefer `pi.edit`/`pi.write`. `pi.bash`: no stdin.",
|
|
2111
|
-
"Use `display.name` and objective `display.description`; Fabric pairs them with verified outcomes in deterministic compaction.",
|
|
2112
|
-
...monty ? ["Monty requires acyclic JSON host arguments. For underscore-prefixed provider/tool names, use `await tools.call(ref=..., args={...})`, not direct attributes. Use `payloads['key']` for private/non-identifier payload keys."] : []
|
|
2113
|
-
],
|
|
2122
|
+
promptGuidelines: fabricExecutionGuidelines(toolKernel(state), python ? state.config.executor.pythonRuntime : void 0, Boolean(managedHost)),
|
|
2114
2123
|
// The model-facing schema is intentionally flat: one large `code` string
|
|
2115
2124
|
// plus scalar/optional params. Do not add nested arrays-of-objects with
|
|
2116
2125
|
// escaped content here. SOTA models are post-trained on one dominant
|
|
@@ -6808,6 +6817,9 @@ function createFabricExtension(entryUrl) {
|
|
|
6808
6817
|
defaultFabricExecutionGuidance,
|
|
6809
6818
|
extensionToolRosterGuidance,
|
|
6810
6819
|
fabricExecutionKernelGuidance,
|
|
6820
|
+
fabricGuidanceDelivery,
|
|
6821
|
+
relocateFabricGuidelines,
|
|
6822
|
+
stripFabricRuleBullets,
|
|
6811
6823
|
managedHostExecutionGuidance,
|
|
6812
6824
|
managedHostKernelGuidance,
|
|
6813
6825
|
fabricSchemaGuidance
|
|
@@ -6816,8 +6828,25 @@ function createFabricExtension(entryUrl) {
|
|
|
6816
6828
|
const captureSnapshot = state.bootstrapped ? capturePolicy() : void 0;
|
|
6817
6829
|
const managedHost = state.managedHostOptions;
|
|
6818
6830
|
const skillReader = managedHost ? managedHost.skillReader ?? null : void 0;
|
|
6819
|
-
const
|
|
6820
|
-
|
|
6831
|
+
const delivery = fabricGuidanceDelivery(
|
|
6832
|
+
true,
|
|
6833
|
+
event.systemPromptOptions.sections !== void 0,
|
|
6834
|
+
event.systemPromptOptions.forceSystemPrompt !== void 0
|
|
6835
|
+
);
|
|
6836
|
+
const sections = delivery.section ? event.systemPromptOptions.sections : void 0;
|
|
6837
|
+
const ownedExecutionRules = fabricOwnedExecutionGuidelines();
|
|
6838
|
+
const executionRules = relocateFabricGuidelines(
|
|
6839
|
+
event.systemPromptOptions.toolGuidelines,
|
|
6840
|
+
fabricExecutionGuidelines(config.executor.kernel, config.executor.pythonRuntime, Boolean(managedHost)),
|
|
6841
|
+
delivery,
|
|
6842
|
+
ownedExecutionRules
|
|
6843
|
+
);
|
|
6844
|
+
const systemPrompt = sections ? "" : restoreSkillsForFullCodePrompt(
|
|
6845
|
+
stripFabricRuleBullets(event.systemPrompt, ownedExecutionRules),
|
|
6846
|
+
skills,
|
|
6847
|
+
effectiveFullCodeMode,
|
|
6848
|
+
skillReader
|
|
6849
|
+
);
|
|
6821
6850
|
const prompt = userPromptText(event);
|
|
6822
6851
|
const skillReferenceGuidance = effectiveFullCodeMode && prompt !== void 0 ? buildSkillReferenceGuidance(prompt, skills, skillReader) : void 0;
|
|
6823
6852
|
const currentModel = context.model ? `${context.model.provider}/${context.model.id}` : void 0;
|
|
@@ -6837,20 +6866,24 @@ function createFabricExtension(entryUrl) {
|
|
|
6837
6866
|
const guidance = [
|
|
6838
6867
|
managedHost ? managedHostKernelGuidance(managedHost) : fabricExecutionKernelGuidance(effectiveFullCodeMode, config.executor.kernel, config.executor.pythonRuntime, config.executor.codemodeProfile),
|
|
6839
6868
|
resolvedGuidance.slotText,
|
|
6869
|
+
executionRules.text,
|
|
6840
6870
|
fabricSchemaGuidance(schemaMode),
|
|
6841
6871
|
overrideGuidance,
|
|
6842
6872
|
extensionRoster,
|
|
6843
6873
|
resolvedGuidance.appendText,
|
|
6844
6874
|
managedHost?.guidance
|
|
6845
6875
|
].filter((section) => Boolean(section)).join("\n\n");
|
|
6876
|
+
const catalog = sections ? restoreSkillsForFullCodePrompt(sections.skills ?? "", skills, effectiveFullCodeMode, skillReader).trim() : void 0;
|
|
6877
|
+
const forced = delivery.append ? { systemPrompt: `${systemPrompt}
|
|
6878
|
+
|
|
6879
|
+
${guidance}` } : {};
|
|
6846
6880
|
if (sections) {
|
|
6847
|
-
const catalog = restoreSkillsForFullCodePrompt("", skills, effectiveFullCodeMode, skillReader).trim();
|
|
6848
6881
|
if (catalog) sections.skills = catalog;
|
|
6849
6882
|
sections.fabric = guidance;
|
|
6850
6883
|
}
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6884
|
+
if (executionRules.remaining !== void 0 && event.systemPromptOptions.toolGuidelines) {
|
|
6885
|
+
event.systemPromptOptions.toolGuidelines.fabric_exec = executionRules.remaining;
|
|
6886
|
+
}
|
|
6854
6887
|
if (!skillReferenceGuidance) return sections ? void 0 : forced;
|
|
6855
6888
|
return {
|
|
6856
6889
|
...forced,
|
|
@@ -7004,4 +7037,4 @@ export {
|
|
|
7004
7037
|
FABRIC_MANAGED_HOST_VERSION,
|
|
7005
7038
|
createFabricExtension
|
|
7006
7039
|
};
|
|
7007
|
-
//# sourceMappingURL=chunk-
|
|
7040
|
+
//# sourceMappingURL=chunk-5INZBPCM.js.map
|