omp-fabric 1.25.34 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +1 -0
- package/dist/chunks/{chunk-HOKJTRI4.js → chunk-3OQKG7H6.js} +3 -3
- package/dist/chunks/{chunk-JWC7B67Z.js → chunk-66H3QSMR.js} +62 -1
- package/dist/chunks/chunk-66H3QSMR.js.map +7 -0
- package/dist/chunks/{chunk-UKB5RJDP.js → chunk-BEFZRH76.js} +61 -1
- package/dist/chunks/{chunk-UKB5RJDP.js.map → chunk-BEFZRH76.js.map} +2 -2
- package/dist/chunks/{chunk-TRM76YFF.js → chunk-CEDP5WMR.js} +11 -3
- package/dist/chunks/chunk-CEDP5WMR.js.map +7 -0
- package/dist/chunks/{chunk-2C5YN36Y.js → chunk-GFUWAUL2.js} +15 -1
- package/dist/chunks/chunk-GFUWAUL2.js.map +7 -0
- package/dist/chunks/{chunk-5CW2S6EB.js → chunk-Q2LRXHPR.js} +2 -2
- package/dist/chunks/{chunk-3FCNSDDD.js → chunk-TGIT2F2G.js} +3 -3
- package/dist/chunks/{chunk-OLFP7R5J.js → chunk-Z3KAY6S7.js} +2 -2
- package/dist/compaction/hook.js +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/core/session-context.d.ts.map +1 -1
- package/dist/core/system-guidance.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +797 -139
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/index.js +6 -6
- package/dist/index.js.map +2 -2
- package/dist/providers/image-provider.d.ts +37 -0
- package/dist/providers/image-provider.d.ts.map +1 -0
- package/dist/residency/host.js +5 -5
- package/dist/residency/omp-entry.js +5 -5
- package/dist/runtime/core-override-guest-types.js +1 -1
- 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/node-process-runtime.js +1 -1
- package/dist/runtime/quickjs-runtime.d.ts +1 -1
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +1 -1
- package/dist/ui/settings.d.ts +1 -1
- package/dist/ui/settings.d.ts.map +1 -1
- package/dist/ui/settings.js +126 -11
- package/dist/ui/settings.js.map +3 -3
- package/docs/architecture.md +1 -1
- package/docs/certification.md +1 -1
- package/docs/configuration.md +13 -1
- package/docs/image.md +79 -0
- package/package.json +8 -8
- package/dist/chunks/chunk-2C5YN36Y.js.map +0 -7
- package/dist/chunks/chunk-JWC7B67Z.js.map +0 -7
- package/dist/chunks/chunk-TRM76YFF.js.map +0 -7
- /package/dist/chunks/{chunk-HOKJTRI4.js.map → chunk-3OQKG7H6.js.map} +0 -0
- /package/dist/chunks/{chunk-5CW2S6EB.js.map → chunk-Q2LRXHPR.js.map} +0 -0
- /package/dist/chunks/{chunk-3FCNSDDD.js.map → chunk-TGIT2F2G.js.map} +0 -0
- /package/dist/chunks/{chunk-OLFP7R5J.js.map → chunk-Z3KAY6S7.js.map} +0 -0
|
@@ -22,7 +22,7 @@ export interface FabricSandboxOptions {
|
|
|
22
22
|
transpiledSourceMap?: string;
|
|
23
23
|
}
|
|
24
24
|
export type FabricHostCall = (ref: string, args: Record<string, unknown>, signal: AbortSignal) => Promise<unknown>;
|
|
25
|
-
export declare const GUEST_SETUP = "\n(() => {\nconst __fabricBridge = globalThis.__fabricHostCall;\ndelete globalThis.__fabricHostCall;\nconst __successfulCalls = [];\nconst __resolvedCallRef = (ref, args) =>\n ref === \"fabric.$call\" && args && typeof args.ref === \"string\" ? args.ref : ref;\nconst __recordSuccessfulCall = (ref, args) => {\n __successfulCalls.push(Object.freeze({ ref: __resolvedCallRef(ref, args) }));\n};\nconst __handoffFacts = () => {\n const calls = Object.freeze(__successfulCalls.slice());\n const count = (ref) => {\n if (ref === undefined) return calls.length;\n const refs = new Set(Array.isArray(ref) ? ref : [ref]);\n return calls.reduce((total, call) => total + (refs.has(call.ref) ? 1 : 0), 0);\n };\n return Object.freeze({ calls, count });\n};\nconst __call = async (ref, args) => {\n const normalizedArgs = args ?? {};\n const value = await __fabricBridge(ref, normalizedArgs);\n __recordSuccessfulCall(ref, normalizedArgs);\n return value;\n};\nconst __ompToolNames = [\"read\",\"bash\",\"edit\",\"write\",\"grep\",\"find\",\"ls\",\"wait\"];\nconst __toolsBase = {\n providers: () => __call(\"fabric.$providers\", {}),\n catalog: (args = {}) => __call(\"fabric.$catalog\", args),\n list: (args = {}) => __call(\"fabric.$list\", args),\n search: (args) => __call(\n \"fabric.$search\",\n typeof args === \"string\" ? { query: args } : args,\n ),\n describe: (args) => __call(\"fabric.$describe\", args),\n call: (args) => __call(\"fabric.$call\", args),\n progress: (args) => __call(\"fabric.$progress\", args),\n models: () => __call(\"fabric.$models\", {}),\n};\n// tools is discovery + generic calls only. The proxy keeps the seven discovery\n// methods and turns a core-tool name (read/bash/edit/...) into an actionable\n// error pointing at omp.<name>, so a model that writes tools.read(...) learns\n// the fix in one turn instead of looping on \"tools.read is not a function\".\nglobalThis.tools = new Proxy(__toolsBase, {\n get(target, property) {\n if (property === \"then\" || typeof property === \"symbol\") return undefined;\n const name = String(property);\n if (__ompToolNames.indexOf(name) >= 0) {\n return () => {\n throw new Error(\n \"tools.\" + name + \" is not available on the discovery API. tools is discovery + generic calls only (providers/catalog/list/search/describe/call/models). For the OMP core tool, call omp.\" + name + \"(args), e.g. omp.\" + name + \"({ ... }).\"\n );\n };\n }\n return target[property];\n },\n set() { return true; },\n deleteProperty() { return true; },\n});\nconst __ompStringFields = { bash: \"command\", read: \"path\", ls: \"path\", grep: \"pattern\", find: \"pattern\" };\n// Per-tool key aliases. The runtime normalizes them to the canonical form\n// before the host validates args; unit-converting aliases are handled separately\n// in __normalizeOmpArgs. This lets a model that writes { query, regex, ... }\n// or { file } instead of { pattern } / { path } still succeeds on the first\n// call. Keep these in sync with the OmpToolsApi overloads in guest-types.ts so\n// the type-checker accepts the same spellings it coercion-handles at runtime.\nconst __ompArgAliases = {\n bash: {\n cmd: \"command\", shell: \"command\", cmdline: \"command\", script: \"command\",\n commandLine: \"command\",\n workdir: \"cwd\", directory: \"cwd\", workingDirectory: \"cwd\",\n },\n find: {\n query: \"pattern\", regex: \"pattern\", search: \"pattern\", name: \"pattern\",\n filename: \"pattern\", glob: \"pattern\", expression: \"pattern\", include: \"pattern\",\n max: \"limit\",\n },\n grep: {\n query: \"pattern\", regex: \"pattern\", search: \"pattern\", q: \"pattern\",\n expression: \"pattern\", text: \"pattern\",\n ic: \"ignoreCase\", caseInsensitive: \"ignoreCase\",\n globPattern: \"glob\",\n ctx: \"context\",\n },\n read: {\n file: \"path\", absolutePath: \"path\", file_path: \"path\", filePath: \"path\",\n filepath: \"path\", pathname: \"path\", target_file: \"path\", targetFile: \"path\",\n absolute_path: \"path\", fileAbsolutePath: \"path\",\n max: \"limit\", start: \"offset\",\n },\n ls: {\n dir: \"path\", file: \"path\", folder: \"path\", absolutePath: \"path\",\n file_path: \"path\", filePath: \"path\", filepath: \"path\", pathname: \"path\",\n target_file: \"path\", targetFile: \"path\", absolute_path: \"path\",\n fileAbsolutePath: \"path\", directory: \"path\", directoryPath: \"path\",\n max: \"limit\",\n },\n edit: {\n file: \"path\", absolutePath: \"path\", file_path: \"path\", filePath: \"path\",\n filepath: \"path\", pathname: \"path\", target_file: \"path\", targetFile: \"path\",\n absolute_path: \"path\", fileAbsolutePath: \"path\",\n old: \"oldText\", old_string: \"oldText\", oldString: \"oldText\",\n old_str: \"oldText\", oldStr: \"oldText\", from: \"oldText\",\n old_value: \"oldText\", old_text: \"oldText\", oldContent: \"oldText\",\n old_content: \"oldText\",\n new: \"newText\", replacement: \"newText\", new_string: \"newText\",\n newString: \"newText\", new_str: \"newText\", newStr: \"newText\",\n to: \"newText\", new_value: \"newText\", new_text: \"newText\",\n newContent: \"newText\", new_content: \"newText\",\n },\n write: {\n file: \"path\", absolutePath: \"path\", file_path: \"path\", filePath: \"path\",\n filepath: \"path\", pathname: \"path\", target_file: \"path\", targetFile: \"path\",\n absolute_path: \"path\", fileAbsolutePath: \"path\",\n contents: \"content\", body: \"content\", text: \"content\", data: \"content\",\n fileContent: \"content\",\n },\n};\n// Multi-arg positional order, used only when a call passes >= 2 args and the\n// (primary, options) merge in __positionalToArgs does not apply. One-field\n// tools (read/bash/ls) stay absent: their two-arg form is a bare string plus\n// an options object, repaired by the merge instead of a wrong-arity (2554)\n// type error; only a non-object second arg still fails 2554.\nconst __ompPositionalFields = {\n grep: [\"pattern\", \"path\", \"skip\"],\n find: [\"pattern\", \"path\", \"limit\"],\n write: [\"path\", \"content\"],\n edit: [\"path\", \"oldText\", \"newText\"],\n};\n// Models often pass numbers as strings (\"20\"); coerce the known numeric\n// option fields so the host schema sees a number. Non-numeric strings pass\n// through untouched and fail host validation exactly as before. Kept in sync\n// with the numeric optionals in the OmpToolsApi overloads in guest-types.ts.\nconst __ompNumericFields = {\n read: [\"offset\", \"limit\"],\n bash: [\"timeout\"],\n grep: [\"skip\", \"context\", \"limit\"],\n find: [\"limit\"],\n ls: [\"limit\"],\n};\nconst __ompOptionalFields = {\n read: [\"offset\", \"limit\"],\n grep: [\"path\", \"glob\", \"ignoreCase\", \"literal\", \"context\", \"limit\"],\n find: [\"path\", \"limit\"],\n ls: [\"path\", \"limit\"],\n};\n// (primary, options) two-arg merge for the string-primary tools:\n// omp.read(\"index.ts\", { limit: 120 }) becomes { path: \"index.ts\", limit: 120 }.\n// A plain-object second arg is never a valid positional value for these tools\n// (grep/find take (pattern, path, limit) strings/numbers), so merging is\n// unambiguous; the positional string wins the primary field on conflict. The\n// merged object flows through the same alias, unit, and numeric normalization\n// in __normalizeOmpArgs as any other options object.\nconst __positionalToArgs = (name, rest) => {\n const first = rest[0];\n const second = rest[1];\n const primaryField = __ompStringFields[name];\n if (\n rest.length === 2 &&\n typeof first === \"string\" &&\n primaryField !== undefined &&\n second !== null && typeof second === \"object\" && !Array.isArray(second)\n ) {\n const merged = Object.assign({}, second);\n merged[primaryField] = first;\n return merged;\n }\n const order = __ompPositionalFields[name];\n if (!order) return rest.length > 0 ? first : {};\n const out = {};\n for (let i = 0; i < rest.length && i < order.length; i++) {\n const v = rest[i];\n if (v !== undefined) out[order[i]] = v;\n }\n return out;\n};\nconst __normalizeOmpArgs = (name, args) => {\n const field = __ompStringFields[name];\n if (typeof args === \"string\" && field) return { [field]: args };\n if (args === null || typeof args !== \"object\" || Array.isArray(args)) return args;\n const aliases = __ompArgAliases[name];\n let out = args;\n if (name === \"bash\" && \"timeoutMs\" in out) {\n out = Object.assign({}, args);\n if (!(\"timeout\" in out)) {\n const timeoutMs = out.timeoutMs;\n if (timeoutMs !== null && timeoutMs !== undefined) {\n out.timeout = Number.isFinite(Number(timeoutMs)) ? Number(timeoutMs) / 1000 : timeoutMs;\n }\n }\n delete out.timeoutMs;\n }\n // settle is a guest-only directive (settles nonzero exits instead of\n // rejecting); strip it so it never reaches the host/bash schema.\n if (name === \"bash\" && \"settle\" in out) {\n if (out === args) out = Object.assign({}, args);\n delete out.settle;\n }\n if (aliases) {\n for (const alias in aliases) {\n const canonical = aliases[alias];\n if (alias in out) {\n if (out === args) out = Object.assign({}, args);\n if (!(canonical in out)) out[canonical] = out[alias];\n delete out[alias];\n }\n }\n }\n const numerics = __ompNumericFields[name];\n if (numerics) {\n for (const key of numerics) {\n const value = out[key];\n if (typeof value === \"string\" && value.trim() !== \"\" && Number.isFinite(Number(value))) {\n if (out === args) out = Object.assign({}, args);\n out[key] = Number(value);\n }\n }\n }\n const optionalFields = __ompOptionalFields[name];\n if (optionalFields) {\n for (const key of optionalFields) {\n if (out[key] !== null && out[key] !== undefined) continue;\n if (!(key in out)) continue;\n if (out === args) out = Object.assign({}, args);\n delete out[key];\n }\n }\n if (name === \"edit\" && Array.isArray(out.edits)) {\n let changed = false;\n const editAliases = __ompArgAliases.edit;\n const edits = out.edits.map((entry) => {\n if (entry === null || typeof entry !== \"object\" || Array.isArray(entry)) return entry;\n let edit = entry;\n for (const alias in editAliases) {\n const canonical = editAliases[alias];\n if (canonical !== \"oldText\" && canonical !== \"newText\") continue;\n if (!(alias in edit)) continue;\n if (edit === entry) edit = Object.assign({}, entry);\n if (!(canonical in edit)) edit[canonical] = edit[alias];\n delete edit[alias];\n changed = true;\n }\n return edit;\n });\n if (changed) {\n if (out === args) out = Object.assign({}, args);\n out.edits = edits;\n }\n }\n if (name === \"edit\" && !Array.isArray(out.edits) && (\"oldText\" in out || \"newText\" in out)) {\n if (out === args) out = Object.assign({}, args);\n const edit = {};\n if (\"oldText\" in out) edit.oldText = out.oldText;\n if (\"newText\" in out) edit.newText = out.newText;\n out.edits = [edit];\n delete out.oldText;\n delete out.newText;\n }\n return out;\n};\n// shell/edit/write resolve envelope objects { ok, output, details }, and the\n// type-checker deliberately suppresses property-miss (2339) diagnostics, so\n// result.trim() on an envelope typechecks and then dies with QuickJS's terse\n// \"not a function\" \u2014 an error models cannot localize (observed: misdirected\n// debugging spirals probing unrelated globals). Guard envelopes with a proxy\n// that throws an actionable TypeError for string-method access and iteration,\n// naming the tool and the .output fix. Ordinary reads (ok/output/details/\n// exitCode/error), destructuring, 'in' checks, and JSON marshaling pass through.\nconst __ompEnvelopeTools = { bash: true, edit: true, write: true, wait: true };\nconst __ompEnvelopeStringTraps = new Set([\n \"anchor\", \"at\", \"big\", \"blink\", \"bold\", \"charAt\", \"charCodeAt\", \"codePointAt\",\n \"concat\", \"endsWith\", \"fixed\", \"fontcolor\", \"fontsize\", \"includes\", \"indexOf\",\n \"italics\", \"lastIndexOf\", \"length\", \"link\", \"localeCompare\", \"match\", \"matchAll\",\n \"normalize\", \"padEnd\", \"padStart\", \"repeat\", \"replace\", \"replaceAll\", \"search\",\n \"slice\", \"small\", \"split\", \"startsWith\", \"strike\", \"sub\", \"substr\", \"substring\",\n \"sup\", \"toLocaleLowerCase\", \"toLocaleUpperCase\", \"toLowerCase\", \"toUpperCase\",\n \"trim\", \"trimEnd\", \"trimStart\",\n]);\nconst __ompEnvelopeGuard = (name, value) => {\n if (value === null || typeof value !== \"object\" || typeof value.ok !== \"boolean\") return value;\n return new Proxy(value, {\n get(target, property, receiver) {\n if (property === Symbol.iterator || property === Symbol.asyncIterator) {\n throw new TypeError(\n \"omp.\" + name + \"(...) resolves an envelope { ok, output, details }, which is not iterable. \" +\n \"Iterate the text instead: (await omp.\" + name + \"(...)).output.split('\\\\n')\"\n );\n }\n if (typeof property === \"string\" && __ompEnvelopeStringTraps.has(property)) {\n throw new TypeError(\n \"omp.\" + name + \"(...) resolves an envelope { ok, output, details }, not a string, so .\" + property +\n \" is unavailable on it. Read the text first: const out = (await omp.\" + name + \"(...)).output; then out.\" + property +\n \"(...). Shell commands reject on a nonzero exit \u2014 pass settle: true to receive an ok:false envelope instead.\"\n );\n }\n return Reflect.get(target, property, receiver);\n },\n });\n};\n// The omp proxy accepts: a bare string (primary field), an options object, a\n// (primary, options) two-arg merge for the string-primary tools, or a\n// positional spread mapped by __ompPositionalFields. 0/1 args preserve the\n// legacy (args = {}) default so existing programs are unchanged.\nglobalThis.omp = new Proxy({}, {\n get(_target, property) {\n if (property === \"then\") return undefined;\n const name = String(property);\n // fabric_exec payload values are readable directly on the omp surface\n // (documented for skills as payloads.<key>), while core tool names stay\n // callables. Only shadow a payload key that actually exists.\n const payloadValues = (typeof globalThis[\"payloads\"] === \"object\" && globalThis[\"payloads\"] !== null)\n ? globalThis[\"payloads\"]\n : {};\n if (__ompToolNames.indexOf(name) < 0 && Object.prototype.hasOwnProperty.call(payloadValues, name)) {\n return payloadValues[name];\n }\n return (...rest) => {\n let args;\n if (rest.length <= 1) {\n const first = rest.length === 1 ? rest[0] : undefined;\n args = first === undefined ? {} : first;\n } else {\n args = __positionalToArgs(name, rest);\n }\n // Shell tools reject on an ordinary nonzero exit; settle:true returns\n // {ok:false, exitCode, ...} instead (opt-in). Other failures still reject.\n const settle = name === \"bash\" &&\n typeof args === \"object\" && args !== null && args.settle === true;\n const call = __call(\"omp.\" + name, __normalizeOmpArgs(name, args));\n const promise = settle ? call.catch((error) => {\n // node-process bridge errors originate in a different VM realm.\n const message = typeof error?.message === \"string\" ? error.message : String(error);\n const exit = error?.__fabricBashExit;\n if (!exit || !Number.isSafeInteger(exit.exitCode) || exit.exitCode <= 0 ||\n typeof exit.output !== \"string\") throw error;\n return {\n ok: false,\n output: exit.output,\n details: null,\n exitCode: exit.exitCode,\n error: message,\n };\n }) : call;\n return __ompEnvelopeTools[name] === true\n ? promise.then((value) => __ompEnvelopeGuard(name, value))\n : promise;\n };\n },\n});\nconst __payloads = (typeof globalThis[\"payloads\"] === \"object\" && globalThis[\"payloads\"] !== null) ? globalThis[\"payloads\"] : {};\nglobalThis[\"payloads\"] = new Proxy(__payloads, {\n get(target, property) {\n if (typeof property === \"symbol\") return undefined;\n const name = String(property);\n if (name === \"then\" || name === \"toJSON\" || name === \"constructor\") return undefined;\n if (Object.prototype.hasOwnProperty.call(target, name)) return target[name];\n if (__ompToolNames.indexOf(name) >= 0) {\n throw new Error(\n \"payloads.\" + name + \" is the payloads accessor, not a tool. For the OMP core tool, call omp.\" + name + \"(args).\"\n );\n }\n const provided = Object.keys(target);\n throw new Error(\n \"payloads.\" + name + \" is not defined. payloads only exposes keys from the fabric_exec payloads parameter\" +\n (provided.length ? \" (provided: \" + provided.join(\", \") + \")\" : \" (none provided)\") +\n \". Pass payloads: { \" + name + \": '...' } to use payloads.\" + name + \".\" +\n \" For large or quote-heavy content, keep it in top-level payloads and reference payloads.\" + name + \" instead of escaping it inside code.\"\n );\n },\n ownKeys(target) { return Reflect.ownKeys(target); },\n getOwnPropertyDescriptor(target, prop) { return Reflect.getOwnPropertyDescriptor(target, prop); },\n has(target, prop) { return Object.prototype.hasOwnProperty.call(target, prop); }\n});\n// Stable providers share a lazy dispatch proxy; the guest declarations keep\n// their known actions typed while the registry remains the runtime authority.\n// extensions' per-tool surface is additionally rendered from the captured\n// catalog by guestTypeDeclarations (runtime/dynamic-guest-types.ts).\nconst __memorySelectionKeys = [\n \"indices\",\n \"entryIds\",\n \"operationAddresses\",\n \"entryRange\",\n \"index\",\n \"entry_ids\",\n \"operation_addresses\",\n \"entry_range\",\n];\nconst __hasMemorySelection = (args) => __memorySelectionKeys.some((key) => {\n const value = args[key];\n if (Array.isArray(value)) return value.length > 0;\n return value !== undefined && value !== null;\n});\nconst __memoryWalk = async (args, visitor) => {\n if (!args || typeof args !== \"object\" || Array.isArray(args)) {\n throw new TypeError(\"memory.walk expects an expansion options object\");\n }\n if (typeof visitor !== \"function\") {\n throw new TypeError(\"memory.walk expects a visitor function as its second argument\");\n }\n\n let request = { ...args };\n if (Number(request.textOffset ?? request.text_offset ?? 0) !== 0) {\n throw new TypeError(\"memory.walk must start at text offset 0 to yield complete entries\");\n }\n if (!__hasMemorySelection(request)) {\n if (request.entryOffset !== undefined || request.entry_offset !== undefined ||\n request.textOffset !== undefined || request.text_offset !== undefined) {\n throw new TypeError(\"memory.walk continuation offsets require an explicit selection\");\n }\n if (Number(request.before ?? 0) > 0 || Number(request.after ?? 0) > 0) {\n throw new TypeError(\"memory.walk before/after requires an explicit selection\");\n }\n const head = await __call(\"memory.expand\", request);\n if (!head || typeof head !== \"object\") {\n throw new Error(\"memory.expand returned an invalid metadata response\");\n }\n if (head.error) return { visited: 0, stopped: false, error: head.error };\n if (!Number.isSafeInteger(head.entryCount) || head.entryCount < 0) {\n throw new Error(\"memory.expand metadata omitted a valid entryCount\");\n }\n if (head.entryCount === 0) return { visited: 0, stopped: false };\n request = {\n ...request,\n session: head.session ?? request.session,\n expectedSourceHash: head.sourceHash,\n expectedLineageFingerprint: head.lineageFingerprint,\n branches: head.branches,\n entryRange: { first: 0, last: head.entryCount - 1 },\n };\n }\n\n let visited = 0;\n let pending = null;\n let pendingStart = 0;\n let pendingEnd = 0;\n let pendingTotal = 0;\n const seen = new Set([JSON.stringify({ ref: \"memory.expand\", args: request })]);\n let page = await __call(\"memory.expand\", request);\n\n while (true) {\n if (!page || typeof page !== \"object\") {\n throw new Error(\"memory.expand returned an invalid page\");\n }\n if (page.error) return { visited, stopped: false, error: page.error };\n if (!Array.isArray(page.entries)) {\n throw new Error(\"memory.expand page omitted entries\");\n }\n\n for (const chunk of page.entries) {\n if (!chunk || typeof chunk !== \"object\" || typeof chunk.text !== \"string\") {\n throw new Error(\"memory.expand returned an invalid entry chunk\");\n }\n const range = chunk.textRange;\n if (!range || typeof range !== \"object\" ||\n !Number.isSafeInteger(range.start) || !Number.isSafeInteger(range.end) ||\n !Number.isSafeInteger(range.total) || range.start < 0 ||\n range.end < range.start || range.total < range.end) {\n throw new Error(\"memory.expand returned an invalid textRange\");\n }\n if (chunk.text.length !== range.end - range.start) {\n throw new Error(\"memory.expand entry chunk disagrees with textRange\");\n }\n\n if (pending === null) {\n pending = { ...chunk, text: \"\" };\n pendingStart = range.start;\n pendingEnd = range.start;\n pendingTotal = range.total;\n } else if (pending.index !== chunk.index) {\n throw new Error(\"memory.expand advanced before completing an entry\");\n }\n if (range.start !== pendingEnd || range.total !== pendingTotal) {\n throw new Error(\"memory.expand returned discontinuous entry chunks\");\n }\n for (const key of Object.keys(chunk)) {\n if (pending[key] === undefined) pending[key] = chunk[key];\n }\n pending.text += chunk.text;\n pendingEnd = range.end;\n\n if (range.complete) {\n pending.textRange = {\n start: pendingStart,\n end: pendingEnd,\n total: pendingTotal,\n complete: true,\n };\n const entry = pending;\n pending = null;\n const keepGoing = await visitor(entry, visited);\n visited += 1;\n if (keepGoing === false) return { visited, stopped: true };\n }\n }\n\n if (page.next === null || page.next === undefined) {\n if (pending !== null) {\n throw new Error(\"memory.expand ended before completing an entry\");\n }\n return { visited, stopped: false };\n }\n if (page.next.ref !== \"memory.expand\" || !page.next.args ||\n typeof page.next.args !== \"object\" || Array.isArray(page.next.args)) {\n throw new Error(\"memory.expand returned an invalid continuation\");\n }\n const continuationKey = JSON.stringify(page.next);\n if (seen.has(continuationKey)) {\n throw new Error(\"memory.expand returned a cyclic continuation\");\n }\n seen.add(continuationKey);\n page = await __call(page.next.ref, page.next.args);\n }\n};\n\nconst __proxyNames = (() => {\n const raw = globalThis.__fabricProxyNames;\n delete globalThis.__fabricProxyNames;\n return raw && typeof raw === \"object\" ? raw : {};\n})();\nconst __nameList = (value) =>\n Array.isArray(value) ? value.filter((name) => typeof name === \"string\") : [];\nconst __lazyNamespace = (names, resolve, local = {}) => new Proxy(local, {\n get(target, property) {\n if (property === \"then\" || typeof property === \"symbol\") return undefined;\n if (Object.prototype.hasOwnProperty.call(target, property)) return target[property];\n return resolve(String(property));\n },\n ownKeys(target) {\n const own = Object.keys(target);\n return names.concat(own.filter((key) => names.indexOf(key) < 0));\n },\n getOwnPropertyDescriptor(target, property) {\n if (typeof property === \"symbol\") return undefined;\n const name = String(property);\n if (names.indexOf(name) < 0 && !Object.prototype.hasOwnProperty.call(target, name)) {\n return undefined;\n }\n const value = Object.prototype.hasOwnProperty.call(target, name)\n ? target[name]\n : resolve(name);\n return { value, writable: false, enumerable: true, configurable: true };\n },\n has(target, property) {\n if (typeof property === \"symbol\") return false;\n return names.indexOf(String(property)) >= 0\n || Object.prototype.hasOwnProperty.call(target, property);\n },\n});\nconst __providerProxy = (provider, local = {}, names = []) =>\n __lazyNamespace(names, (property) => (args = {}) => __call(provider + \".\" + property, args), local);\nglobalThis.extensions = __providerProxy(\"extensions\", {}, __nameList(__proxyNames.extensions));\nglobalThis.memory = __providerProxy(\"memory\", { walk: __memoryWalk });\nglobalThis.state = __providerProxy(\"state\");\nglobalThis.schema = __providerProxy(\"schema\");\nglobalThis.components = __providerProxy(\"components\");\nglobalThis.compact = __providerProxy(\"compact\");\nglobalThis.codemap = __providerProxy(\"codemap\");\nglobalThis.judgment = __providerProxy(\"judgment\");\nconst __chunkBatchItems = (items, maxItems = 25, maxBytes = 49152) => {\n const chunks = [];\n let current = [];\n let currentBytes = 2;\n for (const item of items) {\n let serialized = \"\";\n try {\n serialized = JSON.stringify(item) ?? \"null\";\n } catch {\n serialized = JSON.stringify(String(item));\n }\n let stateItem = item;\n if (serialized.length > 40960) {\n stateItem = typeof item === \"string\"\n ? item.slice(0, 40000) + \" [truncated]\"\n : String(item).slice(0, 40000) + \" [truncated]\";\n serialized = JSON.stringify(stateItem);\n }\n const itemBytes = serialized.length + 1;\n if (current.length > 0 && (current.length >= maxItems || currentBytes + itemBytes > maxBytes)) {\n chunks.push(current);\n current = [];\n currentBytes = 2;\n }\n current.push({ item, stateItem });\n currentBytes += itemBytes;\n }\n if (current.length > 0) chunks.push(current);\n return chunks;\n};\nconst __judgeAsk = (first, second) => {\n if (second !== undefined) {\n return globalThis.judgment.ask({ state: first, questions: second });\n }\n return globalThis.judgment.ask(first);\n};\nconst __judgeBool = async (state, instructions, options) => {\n try {\n const outcome = await globalThis.judgment.ask({\n state,\n questions: { q: { type: \"bool\", instructions: String(instructions) } },\n });\n if (outcome && outcome.ok && outcome.answers && outcome.answers.q && outcome.answers.q.type === \"bool\" && typeof outcome.answers.q.bool === \"number\") {\n return outcome.answers.q.bool;\n }\n } catch {}\n return options && typeof options.fallback === \"number\" ? options.fallback : undefined;\n};\nconst __judgeChoice = async (state, optionsListOrCriteria, instructions, config) => {\n let criteria = {};\n if (Array.isArray(optionsListOrCriteria)) {\n for (const opt of optionsListOrCriteria) criteria[String(opt)] = null;\n } else if (optionsListOrCriteria && typeof optionsListOrCriteria === \"object\") {\n criteria = optionsListOrCriteria;\n } else {\n throw new TypeError(\"judge.choice options must be an array or criteria object\");\n }\n if (Object.keys(criteria).length < 2) {\n throw new TypeError(\"judge.choice requires at least 2 unique options\");\n }\n try {\n const outcome = await globalThis.judgment.ask({\n state,\n questions: { q: { type: \"choice\", instructions: String(instructions), criteria } },\n });\n if (outcome && outcome.ok && outcome.answers && outcome.answers.q && outcome.answers.q.type === \"choice\" && typeof outcome.answers.q.choice === \"string\") {\n return outcome.answers.q.choice;\n }\n } catch {}\n return config && typeof config.fallback === \"string\" ? config.fallback : undefined;\n};\nconst __judgeScore = async (state, criteria, instructions, config) => {\n if (!Array.isArray(criteria) || criteria.length < 2) {\n throw new TypeError(\"judge.score requires at least 2 ordered criteria levels\");\n }\n try {\n const outcome = await globalThis.judgment.ask({\n state,\n questions: { q: { type: \"score\", instructions: String(instructions), criteria } },\n });\n if (outcome && outcome.ok && outcome.answers && outcome.answers.q && outcome.answers.q.type === \"score\" && typeof outcome.answers.q.score === \"number\") {\n return outcome.answers.q.score;\n }\n } catch {}\n return config && typeof config.fallback === \"number\" ? config.fallback : undefined;\n};\nconst __judgeFilter = async (items, instructions, options = {}) => {\n if (!Array.isArray(items) || items.length === 0) return [];\n const threshold = Number.isFinite(options.threshold) ? options.threshold : 0.7;\n const onFail = options.onFail || \"keep-all\";\n const chunks = __chunkBatchItems(items, options.maxItems || 25, options.maxBytes || 49152);\n const chunkPromises = chunks.map(async (chunk) => {\n const questions = {};\n chunk.forEach((_, idx) => {\n questions[\"item_\" + idx] = {\n type: \"bool\",\n instructions: \"Regarding items[\" + idx + \"]: \" + String(instructions),\n };\n });\n let outcome;\n try {\n outcome = await globalThis.judgment.ask({ state: { items: chunk.map((c) => c.stateItem) }, questions });\n } catch (err) {\n outcome = { ok: false, reason: \"failed\", detail: String(err && err.message ? err.message : err) };\n }\n if (!outcome || !outcome.ok) {\n if (onFail === \"throw\") {\n throw new Error(\"judge.filter failed: \" + (outcome && outcome.reason ? outcome.reason : \"unknown error\") + (outcome && outcome.detail ? \" (\" + outcome.detail + \")\" : \"\"));\n }\n return onFail === \"empty\" ? [] : chunk.map((c) => c.item);\n }\n return chunk\n .filter((_, idx) => {\n const ans = outcome.answers && outcome.answers[\"item_\" + idx];\n return ans && ans.type === \"bool\" && typeof ans.bool === \"number\" && ans.bool >= threshold;\n })\n .map((c) => c.item);\n });\n const results = await Promise.all(chunkPromises);\n return results.flat();\n};\nconst __judgeClassify = async (items, categories, instructions, options = {}) => {\n if (!Array.isArray(items) || items.length === 0) return [];\n if (!Array.isArray(categories) || categories.length < 2) {\n throw new TypeError(\"judge.classify requires at least 2 categories\");\n }\n const criteria = {};\n for (const cat of categories) criteria[String(cat)] = null;\n const onFail = options.onFail || \"keep-all\";\n const chunks = __chunkBatchItems(items, options.maxItems || 25, options.maxBytes || 49152);\n const chunkPromises = chunks.map(async (chunk) => {\n const questions = {};\n chunk.forEach((_, idx) => {\n questions[\"item_\" + idx] = {\n type: \"choice\",\n instructions: \"Regarding items[\" + idx + \"]: \" + String(instructions),\n criteria,\n };\n });\n let outcome;\n try {\n outcome = await globalThis.judgment.ask({ state: { items: chunk.map((c) => c.stateItem) }, questions });\n } catch (err) {\n outcome = { ok: false, reason: \"failed\", detail: String(err && err.message ? err.message : err) };\n }\n if (!outcome || !outcome.ok) {\n if (onFail === \"throw\") {\n throw new Error(\"judge.classify failed: \" + (outcome && outcome.reason ? outcome.reason : \"unknown error\") + (outcome && outcome.detail ? \" (\" + outcome.detail + \")\" : \"\"));\n }\n if (onFail === \"empty\") return [];\n return chunk.map((c) => ({ item: c.item, category: options.fallbackCategory, confidence: undefined }));\n }\n return chunk.map((c, idx) => {\n const ans = outcome.answers && outcome.answers[\"item_\" + idx];\n const category = ans && ans.type === \"choice\" && typeof ans.choice === \"string\" ? ans.choice : options.fallbackCategory;\n const confidence = ans && typeof ans.confidence === \"number\" ? ans.confidence : undefined;\n return { item: c.item, category, confidence };\n });\n });\n const results = await Promise.all(chunkPromises);\n return results.flat();\n};\nglobalThis.judge = Object.freeze({\n ask: __judgeAsk,\n bool: __judgeBool,\n choice: __judgeChoice,\n score: __judgeScore,\n filter: __judgeFilter,\n classify: __judgeClassify,\n});\nconst __createActor = async (args = {}) => {\n if (!args || typeof args !== \"object\" || Array.isArray(args)) {\n throw new TypeError(\"agents.create expects an options object\");\n }\n const request = { ...args };\n const validWhile = request.validWhile;\n if (validWhile !== undefined) {\n if (typeof validWhile !== \"function\") {\n throw new TypeError(\"agents.create validWhile must be a pure predicate function\");\n }\n const source = Function.prototype.toString.call(validWhile);\n if (source.trimStart().startsWith(\"async\")) {\n throw new TypeError(\"agents.create validWhile must be synchronous\");\n }\n request.validWhile = { version: 1, source };\n }\n return __call(\"agents.create\", request);\n};\nconst __handoff = async (args = {}) => {\n if (!args || typeof args !== \"object\" || Array.isArray(args)) {\n throw new TypeError(\"agents.handoff expects an options object\");\n }\n const request = { ...args };\n const when = request.when;\n delete request.when;\n if (when !== undefined) {\n if (typeof when !== \"function\") {\n throw new TypeError(\"agents.handoff when must be a pure predicate function\");\n }\n const decision = when(__handoffFacts());\n if (decision && typeof decision.then === \"function\") {\n throw new TypeError(\"agents.handoff when must return a boolean synchronously\");\n }\n if (decision !== true) {\n throw new Error(\"agents.handoff predicate returned false; no agent was started\");\n }\n }\n return __call(\"agents.handoff\", request);\n};\nglobalThis.agents = Object.freeze({\n run: (args) => __call(\"agents.run\", args),\n handoff: __handoff,\n spawn: (args) => __call(\"agents.spawn\", args),\n wait: (args) => __call(\"agents.wait\", args),\n status: (args) => __call(\"agents.status\", args),\n list: (args = {}) => __call(\"agents.list\", args),\n members: (args = {}) => __call(\"agents.members\", args),\n self: () => __call(\"agents.self\", {}),\n main: () => __call(\"agents.main\", {}),\n peers: () => __call(\"agents.peers\", {}),\n subscribe: (args) => __call(\"agents.subscribe\", args),\n subscriptions: (args = {}) => __call(\"agents.subscriptions\", args),\n unsubscribe: (args) => __call(\"agents.unsubscribe\", args),\n models: (args = {}) => __call(\"agents.models\", args),\n stop: (args) => __call(\"agents.stop\", args),\n cleanup: (args) => __call(\"agents.cleanup\", args),\n create: __createActor,\n ask: (args) => __call(\"agents.ask\", args),\n tell: (args) => __call(\"agents.tell\", args),\n steer: (args) => __call(\"agents.steer\", args),\n followUp: (args) => __call(\"agents.followUp\", args),\n setSteeringMode: (args) => __call(\"agents.setSteeringMode\", args),\n setFollowUpMode: (args) => __call(\"agents.setFollowUpMode\", args),\n actorStatus: (args) => __call(\"agents.actorStatus\", args),\n setModel: (args) => __call(\"agents.setModel\", args),\n switchModel: (args) => __call(\"agents.switchModel\", args),\n setThinking: (args) => __call(\"agents.setThinking\", args),\n setEvents: (args) => __call(\"agents.setEvents\", args),\n setInstructions: (args) => __call(\"agents.setInstructions\", args),\n actors: () => __call(\"agents.actors\", {}),\n messages: (args) => __call(\"agents.messages\", args),\n remove: (args) => __call(\"agents.remove\", args),\n log: (args) => __call(\"agents.log\", args),\n});\nglobalThis.mesh = Object.freeze({\n self: () => __call(\"mesh.self\", {}),\n publish: (args) => __call(\"mesh.publish\", args),\n read: (args = {}) => __call(\"mesh.read\", args),\n members: (args = {}) => __call(\"mesh.members\", args),\n get: (args) => __call(\"mesh.get\", args),\n list: (args = {}) => __call(\"mesh.list\", args),\n put: (args) => __call(\"mesh.put\", args),\n delete: (args) => __call(\"mesh.delete\", args),\n});\n// The mcp proxy itself stays schema-less \u2014 the registry validates args at\n// dispatch \u2014 but guestTypeDeclarations renders per-server argument types from\n// the live descriptor cache (runtime/dynamic-guest-types.ts), so known tools\n// fail type-check on argument-shape mistakes before this proxy ever runs.\nconst __mcpServerTools = (() => {\n const raw = __proxyNames.mcp;\n const out = {};\n if (raw && typeof raw === \"object\") {\n for (const server of Object.keys(raw)) out[server] = __nameList(raw[server]);\n }\n return out;\n})();\nconst __mcpManagement = {\n servers: () => __call(\"mcp.$servers\", {}),\n reload: () => __call(\"mcp.$reload\", {}),\n register: (args) => __call(\"mcp.$register\", args),\n call: (args) => __call(\"mcp.$call\", args),\n};\nglobalThis.mcp = __lazyNamespace(\n Object.keys(__mcpServerTools).sort(),\n (server) => __lazyNamespace(\n __mcpServerTools[server] ? __mcpServerTools[server].slice().sort() : [],\n (tool) => (args = {}) => __call(\"mcp.\" + server + \".\" + tool, args),\n ),\n __mcpManagement,\n);\nlet __workflowSpentTokens = 0;\nconst __workflowBudgetTotal = Number.isFinite(globalThis.__fabricTokenBudget)\n ? Math.max(0, globalThis.__fabricTokenBudget)\n : Number.POSITIVE_INFINITY;\nconst __recordAgentUsage = (result) => {\n const usage = result && result.usage;\n if (usage) __workflowSpentTokens += Number(usage.input || 0) + Number(usage.output || 0);\n return result;\n};\nconst __workflowAgent = async (prompt, options = {}) => {\n if (__workflowSpentTokens >= __workflowBudgetTotal) {\n throw new Error(\"Fabric workflow token budget exhausted\");\n }\n const { label, ...agentOptions } = options;\n const workerName = String(label || agentOptions.name || \"Fabric workflow agent\");\n const result = __recordAgentUsage(await agents.run({\n ...agentOptions,\n ...(label && !agentOptions.name ? { name: label } : {}),\n task: prompt,\n }));\n if (!result || result.status !== \"completed\") {\n const reason = result && result.error ? result.error : \"agent did not complete\";\n throw new Error(workerName + \" failed: \" + reason);\n }\n return result.value !== undefined ? result.value : result.text;\n};\n// Budget-aware agents.run used by council.run and rlm.query so their usage is\n// counted in budget.spent() and the tokenBudget guard can preempt them, just\n// like workflow.agent(). Without this, councils bypass the budget entirely.\nconst __budgetedRun = async (args) => {\n if (__workflowSpentTokens >= __workflowBudgetTotal) {\n throw new Error(\"Fabric workflow token budget exhausted\");\n }\n return __recordAgentUsage(await agents.run(args));\n};\nlet __nextWorkflowSpanId = 0;\nconst __workflowSpanMetadata = (kind, items, options, stageCount) => {\n const itemCount = Array.isArray(items) ? items.length : undefined;\n let concurrency;\n if (kind === \"parallel\" && itemCount !== undefined) {\n if (itemCount === 0) concurrency = 0;\n else {\n const concurrencyOpt = typeof options === \"number\" ? { concurrency: options } : options ?? {};\n const requested = Number(concurrencyOpt.concurrency ?? itemCount);\n if (Number.isFinite(requested) && requested >= 1) {\n concurrency = Math.max(1, Math.min(itemCount, Math.floor(requested)));\n }\n }\n }\n return {\n kind,\n ...(itemCount !== undefined ? { itemCount } : {}),\n ...(stageCount !== undefined ? { stageCount } : {}),\n ...(concurrency !== undefined ? { concurrency } : {}),\n };\n};\nconst __withWorkflowSpan = async (metadata, body) => {\n const id = \"span-\" + __nextWorkflowSpanId++;\n await __call(\"fabric.$spanStart\", { id, ...metadata });\n try {\n const value = await body();\n await __call(\"fabric.$spanEnd\", { id, outcome: \"succeeded\" });\n return value;\n } catch (error) {\n try { await __call(\"fabric.$spanEnd\", { id, outcome: \"failed\" }); } catch { /* preserve the workflow error */ }\n throw error;\n }\n};\nconst __runParallel = async (thunks, options) => {\n if (!Array.isArray(thunks) || thunks.some((thunk) => typeof thunk !== \"function\")) {\n throw new TypeError(\"workflow.parallel expects an array of functions or (items, mapper)\");\n }\n if (thunks.length === 0) return [];\n const concurrencyOpt = typeof options === \"number\" ? { concurrency: options } : options ?? {};\n const requestedConcurrency = Number(concurrencyOpt.concurrency ?? thunks.length);\n if (!Number.isFinite(requestedConcurrency) || requestedConcurrency < 1) {\n throw new RangeError(\"workflow.parallel concurrency must be a positive finite number\");\n }\n const concurrency = Math.max(1, Math.min(thunks.length || 1, Math.floor(requestedConcurrency)));\n const results = new Array(thunks.length);\n let cursor = 0;\n await Promise.all(Array.from({ length: concurrency }, async () => {\n while (cursor < thunks.length) {\n const index = cursor++;\n results[index] = await thunks[index]();\n }\n }));\n return results;\n};\nconst __workflowParallel = async (items, arg2, arg3) => {\n const options = typeof arg2 === \"function\" ? arg3 : arg2;\n return __withWorkflowSpan(\n __workflowSpanMetadata(\"parallel\", items, options),\n async () => {\n if (typeof arg2 === \"function\") {\n if (!Array.isArray(items)) throw new TypeError(\"workflow.parallel expects an array as the first argument\");\n return __runParallel(items.map((item, index) => () => arg2(item, index)), arg3);\n }\n return __runParallel(items, arg2);\n },\n );\n};\nconst __workflowPipeline = async (items, ...stages) =>\n __withWorkflowSpan(\n __workflowSpanMetadata(\"pipeline\", items, undefined, stages.length),\n async () => {\n if (!Array.isArray(items) || stages.some((stage) => typeof stage !== \"function\")) {\n throw new TypeError(\"workflow.pipeline expects an array followed by stage functions\");\n }\n return __workflowParallel(items.map((original, index) => async () => {\n let value = original;\n for (const stage of stages) value = await stage(value, original, index);\n return value;\n }));\n },\n );\nglobalThis.workflow = Object.freeze({\n agent: __workflowAgent,\n parallel: __workflowParallel,\n pipeline: __workflowPipeline,\n configure: (args) => __call(\"fabric.$configure\", args),\n phase: (nameOrInput, options = {}) => {\n const input =\n nameOrInput && typeof nameOrInput === \"object\" && !Array.isArray(nameOrInput)\n ? { ...nameOrInput }\n : { ...options, name: nameOrInput };\n return __call(\"fabric.$phase\", input);\n },\n item: (args) => __call(\"fabric.$item\", args),\n event: (args) => __call(\"fabric.$event\", args),\n log: (...values) => print(...values),\n budget: Object.freeze({\n total: __workflowBudgetTotal,\n spent: () => __workflowSpentTokens,\n remaining: () => Math.max(0, __workflowBudgetTotal - __workflowSpentTokens),\n }),\n});\nglobalThis.agent = __workflowAgent;\nglobalThis.parallel = __workflowParallel;\nglobalThis.pipeline = __workflowPipeline;\nglobalThis.phase = workflow.phase;\nglobalThis.log = workflow.log;\nglobalThis.budget = workflow.budget;\nglobalThis.rlm = Object.freeze({\n query: (args) => {\n if (args && args.runner && args.runner !== \"omp\") {\n throw new Error(\"rlm.query requires the OMP runner because recursive Fabric is unavailable in Claude Code\");\n }\n return __budgetedRun({ ...args, runner: \"omp\", recursive: true });\n },\n});\nglobalThis.council = Object.freeze({\n async run(args) {\n const { task, roles, synthesize = true, ...agentOptions } = args;\n const results = await Promise.all(roles.map((role) => __budgetedRun({\n ...agentOptions,\n name: role,\n task: \"Act as the \" + role + \" council member. Independently analyze this task:\\n\\n\" + task,\n })));\n if (!synthesize) return results;\n return __budgetedRun({\n ...agentOptions,\n name: \"council-synthesizer\",\n task: \"Synthesize the council's independent reports into one decision. Preserve disagreements and cite which role raised each concern.\\n\\nTask:\\n\" + task + \"\\n\\nReports:\\n\" + JSON.stringify(results),\n });\n },\n});\nglobalThis.console = Object.freeze({ log: print, info: print, warn: print, error: print });\nconst __timerCallbacks = new Map();\nlet __nextTimerId = 1;\nglobalThis.setTimeout = (callback, ms = 0) => {\n const id = __nextTimerId++;\n __timerCallbacks.set(id, { callback, interval: false });\n __call(\"fabric.$timer\", { ms }).then(() => {\n const entry = __timerCallbacks.get(id);\n if (!entry) return;\n __timerCallbacks.delete(id);\n try { entry.callback(); } catch { /* swallow timer callback errors */ }\n });\n return id;\n};\nglobalThis.setInterval = (callback, ms = 0) => {\n const id = __nextTimerId++;\n __timerCallbacks.set(id, { callback, interval: true });\n const schedule = () => {\n __call(\"fabric.$timer\", { ms }).then(() => {\n const entry = __timerCallbacks.get(id);\n if (!entry) return;\n try { entry.callback(); } catch { /* swallow timer callback errors */ }\n if (__timerCallbacks.has(id)) schedule();\n });\n };\n schedule();\n return id;\n};\nglobalThis.clearTimeout = (id) => { __timerCallbacks.delete(id); };\nglobalThis.clearInterval = (id) => { __timerCallbacks.delete(id); };\n})();\n";
|
|
25
|
+
export declare const GUEST_SETUP = "\n(() => {\nconst __fabricBridge = globalThis.__fabricHostCall;\ndelete globalThis.__fabricHostCall;\nconst __successfulCalls = [];\nconst __resolvedCallRef = (ref, args) =>\n ref === \"fabric.$call\" && args && typeof args.ref === \"string\" ? args.ref : ref;\nconst __recordSuccessfulCall = (ref, args) => {\n __successfulCalls.push(Object.freeze({ ref: __resolvedCallRef(ref, args) }));\n};\nconst __handoffFacts = () => {\n const calls = Object.freeze(__successfulCalls.slice());\n const count = (ref) => {\n if (ref === undefined) return calls.length;\n const refs = new Set(Array.isArray(ref) ? ref : [ref]);\n return calls.reduce((total, call) => total + (refs.has(call.ref) ? 1 : 0), 0);\n };\n return Object.freeze({ calls, count });\n};\nconst __call = async (ref, args) => {\n const normalizedArgs = args ?? {};\n const value = await __fabricBridge(ref, normalizedArgs);\n __recordSuccessfulCall(ref, normalizedArgs);\n return value;\n};\nconst __ompToolNames = [\"read\",\"bash\",\"edit\",\"write\",\"grep\",\"find\",\"ls\",\"wait\"];\nconst __toolsBase = {\n providers: () => __call(\"fabric.$providers\", {}),\n catalog: (args = {}) => __call(\"fabric.$catalog\", args),\n list: (args = {}) => __call(\"fabric.$list\", args),\n search: (args) => __call(\n \"fabric.$search\",\n typeof args === \"string\" ? { query: args } : args,\n ),\n describe: (args) => __call(\"fabric.$describe\", args),\n call: (args) => __call(\"fabric.$call\", args),\n progress: (args) => __call(\"fabric.$progress\", args),\n models: () => __call(\"fabric.$models\", {}),\n};\n// tools is discovery + generic calls only. The proxy keeps the seven discovery\n// methods and turns a core-tool name (read/bash/edit/...) into an actionable\n// error pointing at omp.<name>, so a model that writes tools.read(...) learns\n// the fix in one turn instead of looping on \"tools.read is not a function\".\nglobalThis.tools = new Proxy(__toolsBase, {\n get(target, property) {\n if (property === \"then\" || typeof property === \"symbol\") return undefined;\n const name = String(property);\n if (__ompToolNames.indexOf(name) >= 0) {\n return () => {\n throw new Error(\n \"tools.\" + name + \" is not available on the discovery API. tools is discovery + generic calls only (providers/catalog/list/search/describe/call/models). For the OMP core tool, call omp.\" + name + \"(args), e.g. omp.\" + name + \"({ ... }).\"\n );\n };\n }\n return target[property];\n },\n set() { return true; },\n deleteProperty() { return true; },\n});\nconst __ompStringFields = { bash: \"command\", read: \"path\", ls: \"path\", grep: \"pattern\", find: \"pattern\" };\n// Per-tool key aliases. The runtime normalizes them to the canonical form\n// before the host validates args; unit-converting aliases are handled separately\n// in __normalizeOmpArgs. This lets a model that writes { query, regex, ... }\n// or { file } instead of { pattern } / { path } still succeeds on the first\n// call. Keep these in sync with the OmpToolsApi overloads in guest-types.ts so\n// the type-checker accepts the same spellings it coercion-handles at runtime.\nconst __ompArgAliases = {\n bash: {\n cmd: \"command\", shell: \"command\", cmdline: \"command\", script: \"command\",\n commandLine: \"command\",\n workdir: \"cwd\", directory: \"cwd\", workingDirectory: \"cwd\",\n },\n find: {\n query: \"pattern\", regex: \"pattern\", search: \"pattern\", name: \"pattern\",\n filename: \"pattern\", glob: \"pattern\", expression: \"pattern\", include: \"pattern\",\n max: \"limit\",\n },\n grep: {\n query: \"pattern\", regex: \"pattern\", search: \"pattern\", q: \"pattern\",\n expression: \"pattern\", text: \"pattern\",\n ic: \"ignoreCase\", caseInsensitive: \"ignoreCase\",\n globPattern: \"glob\",\n ctx: \"context\",\n },\n read: {\n file: \"path\", absolutePath: \"path\", file_path: \"path\", filePath: \"path\",\n filepath: \"path\", pathname: \"path\", target_file: \"path\", targetFile: \"path\",\n absolute_path: \"path\", fileAbsolutePath: \"path\",\n max: \"limit\", start: \"offset\",\n },\n ls: {\n dir: \"path\", file: \"path\", folder: \"path\", absolutePath: \"path\",\n file_path: \"path\", filePath: \"path\", filepath: \"path\", pathname: \"path\",\n target_file: \"path\", targetFile: \"path\", absolute_path: \"path\",\n fileAbsolutePath: \"path\", directory: \"path\", directoryPath: \"path\",\n max: \"limit\",\n },\n edit: {\n file: \"path\", absolutePath: \"path\", file_path: \"path\", filePath: \"path\",\n filepath: \"path\", pathname: \"path\", target_file: \"path\", targetFile: \"path\",\n absolute_path: \"path\", fileAbsolutePath: \"path\",\n old: \"oldText\", old_string: \"oldText\", oldString: \"oldText\",\n old_str: \"oldText\", oldStr: \"oldText\", from: \"oldText\",\n old_value: \"oldText\", old_text: \"oldText\", oldContent: \"oldText\",\n old_content: \"oldText\",\n new: \"newText\", replacement: \"newText\", new_string: \"newText\",\n newString: \"newText\", new_str: \"newText\", newStr: \"newText\",\n to: \"newText\", new_value: \"newText\", new_text: \"newText\",\n newContent: \"newText\", new_content: \"newText\",\n },\n write: {\n file: \"path\", absolutePath: \"path\", file_path: \"path\", filePath: \"path\",\n filepath: \"path\", pathname: \"path\", target_file: \"path\", targetFile: \"path\",\n absolute_path: \"path\", fileAbsolutePath: \"path\",\n contents: \"content\", body: \"content\", text: \"content\", data: \"content\",\n fileContent: \"content\",\n },\n};\n// Multi-arg positional order, used only when a call passes >= 2 args and the\n// (primary, options) merge in __positionalToArgs does not apply. One-field\n// tools (read/bash/ls) stay absent: their two-arg form is a bare string plus\n// an options object, repaired by the merge instead of a wrong-arity (2554)\n// type error; only a non-object second arg still fails 2554.\nconst __ompPositionalFields = {\n grep: [\"pattern\", \"path\", \"skip\"],\n find: [\"pattern\", \"path\", \"limit\"],\n write: [\"path\", \"content\"],\n edit: [\"path\", \"oldText\", \"newText\"],\n};\n// Models often pass numbers as strings (\"20\"); coerce the known numeric\n// option fields so the host schema sees a number. Non-numeric strings pass\n// through untouched and fail host validation exactly as before. Kept in sync\n// with the numeric optionals in the OmpToolsApi overloads in guest-types.ts.\nconst __ompNumericFields = {\n read: [\"offset\", \"limit\"],\n bash: [\"timeout\"],\n grep: [\"skip\", \"context\", \"limit\"],\n find: [\"limit\"],\n ls: [\"limit\"],\n};\nconst __ompOptionalFields = {\n read: [\"offset\", \"limit\"],\n grep: [\"path\", \"glob\", \"ignoreCase\", \"literal\", \"context\", \"limit\"],\n find: [\"path\", \"limit\"],\n ls: [\"path\", \"limit\"],\n};\n// (primary, options) two-arg merge for the string-primary tools:\n// omp.read(\"index.ts\", { limit: 120 }) becomes { path: \"index.ts\", limit: 120 }.\n// A plain-object second arg is never a valid positional value for these tools\n// (grep/find take (pattern, path, limit) strings/numbers), so merging is\n// unambiguous; the positional string wins the primary field on conflict. The\n// merged object flows through the same alias, unit, and numeric normalization\n// in __normalizeOmpArgs as any other options object.\nconst __positionalToArgs = (name, rest) => {\n const first = rest[0];\n const second = rest[1];\n const primaryField = __ompStringFields[name];\n if (\n rest.length === 2 &&\n typeof first === \"string\" &&\n primaryField !== undefined &&\n second !== null && typeof second === \"object\" && !Array.isArray(second)\n ) {\n const merged = Object.assign({}, second);\n merged[primaryField] = first;\n return merged;\n }\n const order = __ompPositionalFields[name];\n if (!order) return rest.length > 0 ? first : {};\n const out = {};\n for (let i = 0; i < rest.length && i < order.length; i++) {\n const v = rest[i];\n if (v !== undefined) out[order[i]] = v;\n }\n return out;\n};\nconst __normalizeOmpArgs = (name, args) => {\n const field = __ompStringFields[name];\n if (typeof args === \"string\" && field) return { [field]: args };\n if (args === null || typeof args !== \"object\" || Array.isArray(args)) return args;\n const aliases = __ompArgAliases[name];\n let out = args;\n if (name === \"bash\" && \"timeoutMs\" in out) {\n out = Object.assign({}, args);\n if (!(\"timeout\" in out)) {\n const timeoutMs = out.timeoutMs;\n if (timeoutMs !== null && timeoutMs !== undefined) {\n out.timeout = Number.isFinite(Number(timeoutMs)) ? Number(timeoutMs) / 1000 : timeoutMs;\n }\n }\n delete out.timeoutMs;\n }\n // settle is a guest-only directive (settles nonzero exits instead of\n // rejecting); strip it so it never reaches the host/bash schema.\n if (name === \"bash\" && \"settle\" in out) {\n if (out === args) out = Object.assign({}, args);\n delete out.settle;\n }\n if (aliases) {\n for (const alias in aliases) {\n const canonical = aliases[alias];\n if (alias in out) {\n if (out === args) out = Object.assign({}, args);\n if (!(canonical in out)) out[canonical] = out[alias];\n delete out[alias];\n }\n }\n }\n const numerics = __ompNumericFields[name];\n if (numerics) {\n for (const key of numerics) {\n const value = out[key];\n if (typeof value === \"string\" && value.trim() !== \"\" && Number.isFinite(Number(value))) {\n if (out === args) out = Object.assign({}, args);\n out[key] = Number(value);\n }\n }\n }\n const optionalFields = __ompOptionalFields[name];\n if (optionalFields) {\n for (const key of optionalFields) {\n if (out[key] !== null && out[key] !== undefined) continue;\n if (!(key in out)) continue;\n if (out === args) out = Object.assign({}, args);\n delete out[key];\n }\n }\n if (name === \"edit\" && Array.isArray(out.edits)) {\n let changed = false;\n const editAliases = __ompArgAliases.edit;\n const edits = out.edits.map((entry) => {\n if (entry === null || typeof entry !== \"object\" || Array.isArray(entry)) return entry;\n let edit = entry;\n for (const alias in editAliases) {\n const canonical = editAliases[alias];\n if (canonical !== \"oldText\" && canonical !== \"newText\") continue;\n if (!(alias in edit)) continue;\n if (edit === entry) edit = Object.assign({}, entry);\n if (!(canonical in edit)) edit[canonical] = edit[alias];\n delete edit[alias];\n changed = true;\n }\n return edit;\n });\n if (changed) {\n if (out === args) out = Object.assign({}, args);\n out.edits = edits;\n }\n }\n if (name === \"edit\" && !Array.isArray(out.edits) && (\"oldText\" in out || \"newText\" in out)) {\n if (out === args) out = Object.assign({}, args);\n const edit = {};\n if (\"oldText\" in out) edit.oldText = out.oldText;\n if (\"newText\" in out) edit.newText = out.newText;\n out.edits = [edit];\n delete out.oldText;\n delete out.newText;\n }\n return out;\n};\n// shell/edit/write resolve envelope objects { ok, output, details }, and the\n// type-checker deliberately suppresses property-miss (2339) diagnostics, so\n// result.trim() on an envelope typechecks and then dies with QuickJS's terse\n// \"not a function\" \u2014 an error models cannot localize (observed: misdirected\n// debugging spirals probing unrelated globals). Guard envelopes with a proxy\n// that throws an actionable TypeError for string-method access and iteration,\n// naming the tool and the .output fix. Ordinary reads (ok/output/details/\n// exitCode/error), destructuring, 'in' checks, and JSON marshaling pass through.\nconst __ompEnvelopeTools = { bash: true, edit: true, write: true, wait: true };\nconst __ompEnvelopeStringTraps = new Set([\n \"anchor\", \"at\", \"big\", \"blink\", \"bold\", \"charAt\", \"charCodeAt\", \"codePointAt\",\n \"concat\", \"endsWith\", \"fixed\", \"fontcolor\", \"fontsize\", \"includes\", \"indexOf\",\n \"italics\", \"lastIndexOf\", \"length\", \"link\", \"localeCompare\", \"match\", \"matchAll\",\n \"normalize\", \"padEnd\", \"padStart\", \"repeat\", \"replace\", \"replaceAll\", \"search\",\n \"slice\", \"small\", \"split\", \"startsWith\", \"strike\", \"sub\", \"substr\", \"substring\",\n \"sup\", \"toLocaleLowerCase\", \"toLocaleUpperCase\", \"toLowerCase\", \"toUpperCase\",\n \"trim\", \"trimEnd\", \"trimStart\",\n]);\nconst __ompEnvelopeGuard = (name, value) => {\n if (value === null || typeof value !== \"object\" || typeof value.ok !== \"boolean\") return value;\n return new Proxy(value, {\n get(target, property, receiver) {\n if (property === Symbol.iterator || property === Symbol.asyncIterator) {\n throw new TypeError(\n \"omp.\" + name + \"(...) resolves an envelope { ok, output, details }, which is not iterable. \" +\n \"Iterate the text instead: (await omp.\" + name + \"(...)).output.split('\\\\n')\"\n );\n }\n if (typeof property === \"string\" && __ompEnvelopeStringTraps.has(property)) {\n throw new TypeError(\n \"omp.\" + name + \"(...) resolves an envelope { ok, output, details }, not a string, so .\" + property +\n \" is unavailable on it. Read the text first: const out = (await omp.\" + name + \"(...)).output; then out.\" + property +\n \"(...). Shell commands reject on a nonzero exit \u2014 pass settle: true to receive an ok:false envelope instead.\"\n );\n }\n return Reflect.get(target, property, receiver);\n },\n });\n};\n// The omp proxy accepts: a bare string (primary field), an options object, a\n// (primary, options) two-arg merge for the string-primary tools, or a\n// positional spread mapped by __ompPositionalFields. 0/1 args preserve the\n// legacy (args = {}) default so existing programs are unchanged.\nglobalThis.omp = new Proxy({}, {\n get(_target, property) {\n if (property === \"then\") return undefined;\n const name = String(property);\n // fabric_exec payload values are readable directly on the omp surface\n // (documented for skills as payloads.<key>), while core tool names stay\n // callables. Only shadow a payload key that actually exists.\n const payloadValues = (typeof globalThis[\"payloads\"] === \"object\" && globalThis[\"payloads\"] !== null)\n ? globalThis[\"payloads\"]\n : {};\n if (__ompToolNames.indexOf(name) < 0 && Object.prototype.hasOwnProperty.call(payloadValues, name)) {\n return payloadValues[name];\n }\n return (...rest) => {\n let args;\n if (rest.length <= 1) {\n const first = rest.length === 1 ? rest[0] : undefined;\n args = first === undefined ? {} : first;\n } else {\n args = __positionalToArgs(name, rest);\n }\n // Shell tools reject on an ordinary nonzero exit; settle:true returns\n // {ok:false, exitCode, ...} instead (opt-in). Other failures still reject.\n const settle = name === \"bash\" &&\n typeof args === \"object\" && args !== null && args.settle === true;\n const call = __call(\"omp.\" + name, __normalizeOmpArgs(name, args));\n const promise = settle ? call.catch((error) => {\n // node-process bridge errors originate in a different VM realm.\n const message = typeof error?.message === \"string\" ? error.message : String(error);\n const exit = error?.__fabricBashExit;\n if (!exit || !Number.isSafeInteger(exit.exitCode) || exit.exitCode <= 0 ||\n typeof exit.output !== \"string\") throw error;\n return {\n ok: false,\n output: exit.output,\n details: null,\n exitCode: exit.exitCode,\n error: message,\n };\n }) : call;\n return __ompEnvelopeTools[name] === true\n ? promise.then((value) => __ompEnvelopeGuard(name, value))\n : promise;\n };\n },\n});\nconst __payloads = (typeof globalThis[\"payloads\"] === \"object\" && globalThis[\"payloads\"] !== null) ? globalThis[\"payloads\"] : {};\nglobalThis[\"payloads\"] = new Proxy(__payloads, {\n get(target, property) {\n if (typeof property === \"symbol\") return undefined;\n const name = String(property);\n if (name === \"then\" || name === \"toJSON\" || name === \"constructor\") return undefined;\n if (Object.prototype.hasOwnProperty.call(target, name)) return target[name];\n if (__ompToolNames.indexOf(name) >= 0) {\n throw new Error(\n \"payloads.\" + name + \" is the payloads accessor, not a tool. For the OMP core tool, call omp.\" + name + \"(args).\"\n );\n }\n const provided = Object.keys(target);\n throw new Error(\n \"payloads.\" + name + \" is not defined. payloads only exposes keys from the fabric_exec payloads parameter\" +\n (provided.length ? \" (provided: \" + provided.join(\", \") + \")\" : \" (none provided)\") +\n \". Pass payloads: { \" + name + \": '...' } to use payloads.\" + name + \".\" +\n \" For large or quote-heavy content, keep it in top-level payloads and reference payloads.\" + name + \" instead of escaping it inside code.\"\n );\n },\n ownKeys(target) { return Reflect.ownKeys(target); },\n getOwnPropertyDescriptor(target, prop) { return Reflect.getOwnPropertyDescriptor(target, prop); },\n has(target, prop) { return Object.prototype.hasOwnProperty.call(target, prop); }\n});\n// Stable providers share a lazy dispatch proxy; the guest declarations keep\n// their known actions typed while the registry remains the runtime authority.\n// extensions' per-tool surface is additionally rendered from the captured\n// catalog by guestTypeDeclarations (runtime/dynamic-guest-types.ts).\nconst __memorySelectionKeys = [\n \"indices\",\n \"entryIds\",\n \"operationAddresses\",\n \"entryRange\",\n \"index\",\n \"entry_ids\",\n \"operation_addresses\",\n \"entry_range\",\n];\nconst __hasMemorySelection = (args) => __memorySelectionKeys.some((key) => {\n const value = args[key];\n if (Array.isArray(value)) return value.length > 0;\n return value !== undefined && value !== null;\n});\nconst __memoryWalk = async (args, visitor) => {\n if (!args || typeof args !== \"object\" || Array.isArray(args)) {\n throw new TypeError(\"memory.walk expects an expansion options object\");\n }\n if (typeof visitor !== \"function\") {\n throw new TypeError(\"memory.walk expects a visitor function as its second argument\");\n }\n\n let request = { ...args };\n if (Number(request.textOffset ?? request.text_offset ?? 0) !== 0) {\n throw new TypeError(\"memory.walk must start at text offset 0 to yield complete entries\");\n }\n if (!__hasMemorySelection(request)) {\n if (request.entryOffset !== undefined || request.entry_offset !== undefined ||\n request.textOffset !== undefined || request.text_offset !== undefined) {\n throw new TypeError(\"memory.walk continuation offsets require an explicit selection\");\n }\n if (Number(request.before ?? 0) > 0 || Number(request.after ?? 0) > 0) {\n throw new TypeError(\"memory.walk before/after requires an explicit selection\");\n }\n const head = await __call(\"memory.expand\", request);\n if (!head || typeof head !== \"object\") {\n throw new Error(\"memory.expand returned an invalid metadata response\");\n }\n if (head.error) return { visited: 0, stopped: false, error: head.error };\n if (!Number.isSafeInteger(head.entryCount) || head.entryCount < 0) {\n throw new Error(\"memory.expand metadata omitted a valid entryCount\");\n }\n if (head.entryCount === 0) return { visited: 0, stopped: false };\n request = {\n ...request,\n session: head.session ?? request.session,\n expectedSourceHash: head.sourceHash,\n expectedLineageFingerprint: head.lineageFingerprint,\n branches: head.branches,\n entryRange: { first: 0, last: head.entryCount - 1 },\n };\n }\n\n let visited = 0;\n let pending = null;\n let pendingStart = 0;\n let pendingEnd = 0;\n let pendingTotal = 0;\n const seen = new Set([JSON.stringify({ ref: \"memory.expand\", args: request })]);\n let page = await __call(\"memory.expand\", request);\n\n while (true) {\n if (!page || typeof page !== \"object\") {\n throw new Error(\"memory.expand returned an invalid page\");\n }\n if (page.error) return { visited, stopped: false, error: page.error };\n if (!Array.isArray(page.entries)) {\n throw new Error(\"memory.expand page omitted entries\");\n }\n\n for (const chunk of page.entries) {\n if (!chunk || typeof chunk !== \"object\" || typeof chunk.text !== \"string\") {\n throw new Error(\"memory.expand returned an invalid entry chunk\");\n }\n const range = chunk.textRange;\n if (!range || typeof range !== \"object\" ||\n !Number.isSafeInteger(range.start) || !Number.isSafeInteger(range.end) ||\n !Number.isSafeInteger(range.total) || range.start < 0 ||\n range.end < range.start || range.total < range.end) {\n throw new Error(\"memory.expand returned an invalid textRange\");\n }\n if (chunk.text.length !== range.end - range.start) {\n throw new Error(\"memory.expand entry chunk disagrees with textRange\");\n }\n\n if (pending === null) {\n pending = { ...chunk, text: \"\" };\n pendingStart = range.start;\n pendingEnd = range.start;\n pendingTotal = range.total;\n } else if (pending.index !== chunk.index) {\n throw new Error(\"memory.expand advanced before completing an entry\");\n }\n if (range.start !== pendingEnd || range.total !== pendingTotal) {\n throw new Error(\"memory.expand returned discontinuous entry chunks\");\n }\n for (const key of Object.keys(chunk)) {\n if (pending[key] === undefined) pending[key] = chunk[key];\n }\n pending.text += chunk.text;\n pendingEnd = range.end;\n\n if (range.complete) {\n pending.textRange = {\n start: pendingStart,\n end: pendingEnd,\n total: pendingTotal,\n complete: true,\n };\n const entry = pending;\n pending = null;\n const keepGoing = await visitor(entry, visited);\n visited += 1;\n if (keepGoing === false) return { visited, stopped: true };\n }\n }\n\n if (page.next === null || page.next === undefined) {\n if (pending !== null) {\n throw new Error(\"memory.expand ended before completing an entry\");\n }\n return { visited, stopped: false };\n }\n if (page.next.ref !== \"memory.expand\" || !page.next.args ||\n typeof page.next.args !== \"object\" || Array.isArray(page.next.args)) {\n throw new Error(\"memory.expand returned an invalid continuation\");\n }\n const continuationKey = JSON.stringify(page.next);\n if (seen.has(continuationKey)) {\n throw new Error(\"memory.expand returned a cyclic continuation\");\n }\n seen.add(continuationKey);\n page = await __call(page.next.ref, page.next.args);\n }\n};\n\nconst __proxyNames = (() => {\n const raw = globalThis.__fabricProxyNames;\n delete globalThis.__fabricProxyNames;\n return raw && typeof raw === \"object\" ? raw : {};\n})();\nconst __nameList = (value) =>\n Array.isArray(value) ? value.filter((name) => typeof name === \"string\") : [];\nconst __lazyNamespace = (names, resolve, local = {}) => new Proxy(local, {\n get(target, property) {\n if (property === \"then\" || typeof property === \"symbol\") return undefined;\n if (Object.prototype.hasOwnProperty.call(target, property)) return target[property];\n return resolve(String(property));\n },\n ownKeys(target) {\n const own = Object.keys(target);\n return names.concat(own.filter((key) => names.indexOf(key) < 0));\n },\n getOwnPropertyDescriptor(target, property) {\n if (typeof property === \"symbol\") return undefined;\n const name = String(property);\n if (names.indexOf(name) < 0 && !Object.prototype.hasOwnProperty.call(target, name)) {\n return undefined;\n }\n const value = Object.prototype.hasOwnProperty.call(target, name)\n ? target[name]\n : resolve(name);\n return { value, writable: false, enumerable: true, configurable: true };\n },\n has(target, property) {\n if (typeof property === \"symbol\") return false;\n return names.indexOf(String(property)) >= 0\n || Object.prototype.hasOwnProperty.call(target, property);\n },\n});\nconst __providerProxy = (provider, local = {}, names = []) =>\n __lazyNamespace(names, (property) => (args = {}) => __call(provider + \".\" + property, args), local);\nglobalThis.extensions = __providerProxy(\"extensions\", {}, __nameList(__proxyNames.extensions));\nglobalThis.memory = __providerProxy(\"memory\", { walk: __memoryWalk });\nglobalThis.state = __providerProxy(\"state\");\nglobalThis.schema = __providerProxy(\"schema\");\nglobalThis.components = __providerProxy(\"components\");\nglobalThis.compact = __providerProxy(\"compact\");\nglobalThis.codemap = __providerProxy(\"codemap\");\nglobalThis.judgment = __providerProxy(\"judgment\");\nconst __imagePromptArgs = (first, second) =>\n typeof first === \"string\" ? { prompt: first, ...(second ?? {}) } : { ...(first ?? {}) };\nconst __imageEditArgs = (first, second, third) => {\n if (typeof first === \"string\") {\n return { prompt: first, images: Array.isArray(second) ? second : [], ...(third ?? {}) };\n }\n const args = { ...(first ?? {}) };\n if (!Array.isArray(args.images)) args.images = Array.isArray(second) ? second : [];\n return args;\n};\nglobalThis.image = __providerProxy(\"image\", {\n generate: (first, second) => __call(\"image.generate\", __imagePromptArgs(first, second)),\n edit: (first, second, third) => __call(\"image.edit\", __imageEditArgs(first, second, third)),\n});\nconst __chunkBatchItems = (items, maxItems = 25, maxBytes = 49152) => {\n const chunks = [];\n let current = [];\n let currentBytes = 2;\n for (const item of items) {\n let serialized = \"\";\n try {\n serialized = JSON.stringify(item) ?? \"null\";\n } catch {\n serialized = JSON.stringify(String(item));\n }\n let stateItem = item;\n if (serialized.length > 40960) {\n stateItem = typeof item === \"string\"\n ? item.slice(0, 40000) + \" [truncated]\"\n : String(item).slice(0, 40000) + \" [truncated]\";\n serialized = JSON.stringify(stateItem);\n }\n const itemBytes = serialized.length + 1;\n if (current.length > 0 && (current.length >= maxItems || currentBytes + itemBytes > maxBytes)) {\n chunks.push(current);\n current = [];\n currentBytes = 2;\n }\n current.push({ item, stateItem });\n currentBytes += itemBytes;\n }\n if (current.length > 0) chunks.push(current);\n return chunks;\n};\nconst __judgeAsk = (first, second) => {\n if (second !== undefined) {\n return globalThis.judgment.ask({ state: first, questions: second });\n }\n return globalThis.judgment.ask(first);\n};\nconst __judgeBool = async (state, instructions, options) => {\n try {\n const outcome = await globalThis.judgment.ask({\n state,\n questions: { q: { type: \"bool\", instructions: String(instructions) } },\n });\n if (outcome && outcome.ok && outcome.answers && outcome.answers.q && outcome.answers.q.type === \"bool\" && typeof outcome.answers.q.bool === \"number\") {\n return outcome.answers.q.bool;\n }\n } catch {}\n return options && typeof options.fallback === \"number\" ? options.fallback : undefined;\n};\nconst __judgeChoice = async (state, optionsListOrCriteria, instructions, config) => {\n let criteria = {};\n if (Array.isArray(optionsListOrCriteria)) {\n for (const opt of optionsListOrCriteria) criteria[String(opt)] = null;\n } else if (optionsListOrCriteria && typeof optionsListOrCriteria === \"object\") {\n criteria = optionsListOrCriteria;\n } else {\n throw new TypeError(\"judge.choice options must be an array or criteria object\");\n }\n if (Object.keys(criteria).length < 2) {\n throw new TypeError(\"judge.choice requires at least 2 unique options\");\n }\n try {\n const outcome = await globalThis.judgment.ask({\n state,\n questions: { q: { type: \"choice\", instructions: String(instructions), criteria } },\n });\n if (outcome && outcome.ok && outcome.answers && outcome.answers.q && outcome.answers.q.type === \"choice\" && typeof outcome.answers.q.choice === \"string\") {\n return outcome.answers.q.choice;\n }\n } catch {}\n return config && typeof config.fallback === \"string\" ? config.fallback : undefined;\n};\nconst __judgeScore = async (state, criteria, instructions, config) => {\n if (!Array.isArray(criteria) || criteria.length < 2) {\n throw new TypeError(\"judge.score requires at least 2 ordered criteria levels\");\n }\n try {\n const outcome = await globalThis.judgment.ask({\n state,\n questions: { q: { type: \"score\", instructions: String(instructions), criteria } },\n });\n if (outcome && outcome.ok && outcome.answers && outcome.answers.q && outcome.answers.q.type === \"score\" && typeof outcome.answers.q.score === \"number\") {\n return outcome.answers.q.score;\n }\n } catch {}\n return config && typeof config.fallback === \"number\" ? config.fallback : undefined;\n};\nconst __judgeFilter = async (items, instructions, options = {}) => {\n if (!Array.isArray(items) || items.length === 0) return [];\n const threshold = Number.isFinite(options.threshold) ? options.threshold : 0.7;\n const onFail = options.onFail || \"keep-all\";\n const chunks = __chunkBatchItems(items, options.maxItems || 25, options.maxBytes || 49152);\n const chunkPromises = chunks.map(async (chunk) => {\n const questions = {};\n chunk.forEach((_, idx) => {\n questions[\"item_\" + idx] = {\n type: \"bool\",\n instructions: \"Regarding items[\" + idx + \"]: \" + String(instructions),\n };\n });\n let outcome;\n try {\n outcome = await globalThis.judgment.ask({ state: { items: chunk.map((c) => c.stateItem) }, questions });\n } catch (err) {\n outcome = { ok: false, reason: \"failed\", detail: String(err && err.message ? err.message : err) };\n }\n if (!outcome || !outcome.ok) {\n if (onFail === \"throw\") {\n throw new Error(\"judge.filter failed: \" + (outcome && outcome.reason ? outcome.reason : \"unknown error\") + (outcome && outcome.detail ? \" (\" + outcome.detail + \")\" : \"\"));\n }\n return onFail === \"empty\" ? [] : chunk.map((c) => c.item);\n }\n return chunk\n .filter((_, idx) => {\n const ans = outcome.answers && outcome.answers[\"item_\" + idx];\n return ans && ans.type === \"bool\" && typeof ans.bool === \"number\" && ans.bool >= threshold;\n })\n .map((c) => c.item);\n });\n const results = await Promise.all(chunkPromises);\n return results.flat();\n};\nconst __judgeClassify = async (items, categories, instructions, options = {}) => {\n if (!Array.isArray(items) || items.length === 0) return [];\n if (!Array.isArray(categories) || categories.length < 2) {\n throw new TypeError(\"judge.classify requires at least 2 categories\");\n }\n const criteria = {};\n for (const cat of categories) criteria[String(cat)] = null;\n const onFail = options.onFail || \"keep-all\";\n const chunks = __chunkBatchItems(items, options.maxItems || 25, options.maxBytes || 49152);\n const chunkPromises = chunks.map(async (chunk) => {\n const questions = {};\n chunk.forEach((_, idx) => {\n questions[\"item_\" + idx] = {\n type: \"choice\",\n instructions: \"Regarding items[\" + idx + \"]: \" + String(instructions),\n criteria,\n };\n });\n let outcome;\n try {\n outcome = await globalThis.judgment.ask({ state: { items: chunk.map((c) => c.stateItem) }, questions });\n } catch (err) {\n outcome = { ok: false, reason: \"failed\", detail: String(err && err.message ? err.message : err) };\n }\n if (!outcome || !outcome.ok) {\n if (onFail === \"throw\") {\n throw new Error(\"judge.classify failed: \" + (outcome && outcome.reason ? outcome.reason : \"unknown error\") + (outcome && outcome.detail ? \" (\" + outcome.detail + \")\" : \"\"));\n }\n if (onFail === \"empty\") return [];\n return chunk.map((c) => ({ item: c.item, category: options.fallbackCategory, confidence: undefined }));\n }\n return chunk.map((c, idx) => {\n const ans = outcome.answers && outcome.answers[\"item_\" + idx];\n const category = ans && ans.type === \"choice\" && typeof ans.choice === \"string\" ? ans.choice : options.fallbackCategory;\n const confidence = ans && typeof ans.confidence === \"number\" ? ans.confidence : undefined;\n return { item: c.item, category, confidence };\n });\n });\n const results = await Promise.all(chunkPromises);\n return results.flat();\n};\nglobalThis.judge = Object.freeze({\n ask: __judgeAsk,\n bool: __judgeBool,\n choice: __judgeChoice,\n score: __judgeScore,\n filter: __judgeFilter,\n classify: __judgeClassify,\n});\nconst __createActor = async (args = {}) => {\n if (!args || typeof args !== \"object\" || Array.isArray(args)) {\n throw new TypeError(\"agents.create expects an options object\");\n }\n const request = { ...args };\n const validWhile = request.validWhile;\n if (validWhile !== undefined) {\n if (typeof validWhile !== \"function\") {\n throw new TypeError(\"agents.create validWhile must be a pure predicate function\");\n }\n const source = Function.prototype.toString.call(validWhile);\n if (source.trimStart().startsWith(\"async\")) {\n throw new TypeError(\"agents.create validWhile must be synchronous\");\n }\n request.validWhile = { version: 1, source };\n }\n return __call(\"agents.create\", request);\n};\nconst __handoff = async (args = {}) => {\n if (!args || typeof args !== \"object\" || Array.isArray(args)) {\n throw new TypeError(\"agents.handoff expects an options object\");\n }\n const request = { ...args };\n const when = request.when;\n delete request.when;\n if (when !== undefined) {\n if (typeof when !== \"function\") {\n throw new TypeError(\"agents.handoff when must be a pure predicate function\");\n }\n const decision = when(__handoffFacts());\n if (decision && typeof decision.then === \"function\") {\n throw new TypeError(\"agents.handoff when must return a boolean synchronously\");\n }\n if (decision !== true) {\n throw new Error(\"agents.handoff predicate returned false; no agent was started\");\n }\n }\n return __call(\"agents.handoff\", request);\n};\nglobalThis.agents = Object.freeze({\n run: (args) => __call(\"agents.run\", args),\n handoff: __handoff,\n spawn: (args) => __call(\"agents.spawn\", args),\n wait: (args) => __call(\"agents.wait\", args),\n status: (args) => __call(\"agents.status\", args),\n list: (args = {}) => __call(\"agents.list\", args),\n members: (args = {}) => __call(\"agents.members\", args),\n self: () => __call(\"agents.self\", {}),\n main: () => __call(\"agents.main\", {}),\n peers: () => __call(\"agents.peers\", {}),\n subscribe: (args) => __call(\"agents.subscribe\", args),\n subscriptions: (args = {}) => __call(\"agents.subscriptions\", args),\n unsubscribe: (args) => __call(\"agents.unsubscribe\", args),\n models: (args = {}) => __call(\"agents.models\", args),\n stop: (args) => __call(\"agents.stop\", args),\n cleanup: (args) => __call(\"agents.cleanup\", args),\n create: __createActor,\n ask: (args) => __call(\"agents.ask\", args),\n tell: (args) => __call(\"agents.tell\", args),\n steer: (args) => __call(\"agents.steer\", args),\n followUp: (args) => __call(\"agents.followUp\", args),\n setSteeringMode: (args) => __call(\"agents.setSteeringMode\", args),\n setFollowUpMode: (args) => __call(\"agents.setFollowUpMode\", args),\n actorStatus: (args) => __call(\"agents.actorStatus\", args),\n setModel: (args) => __call(\"agents.setModel\", args),\n switchModel: (args) => __call(\"agents.switchModel\", args),\n setThinking: (args) => __call(\"agents.setThinking\", args),\n setEvents: (args) => __call(\"agents.setEvents\", args),\n setInstructions: (args) => __call(\"agents.setInstructions\", args),\n actors: () => __call(\"agents.actors\", {}),\n messages: (args) => __call(\"agents.messages\", args),\n remove: (args) => __call(\"agents.remove\", args),\n log: (args) => __call(\"agents.log\", args),\n});\nglobalThis.mesh = Object.freeze({\n self: () => __call(\"mesh.self\", {}),\n publish: (args) => __call(\"mesh.publish\", args),\n read: (args = {}) => __call(\"mesh.read\", args),\n members: (args = {}) => __call(\"mesh.members\", args),\n get: (args) => __call(\"mesh.get\", args),\n list: (args = {}) => __call(\"mesh.list\", args),\n put: (args) => __call(\"mesh.put\", args),\n delete: (args) => __call(\"mesh.delete\", args),\n});\n// The mcp proxy itself stays schema-less \u2014 the registry validates args at\n// dispatch \u2014 but guestTypeDeclarations renders per-server argument types from\n// the live descriptor cache (runtime/dynamic-guest-types.ts), so known tools\n// fail type-check on argument-shape mistakes before this proxy ever runs.\nconst __mcpServerTools = (() => {\n const raw = __proxyNames.mcp;\n const out = {};\n if (raw && typeof raw === \"object\") {\n for (const server of Object.keys(raw)) out[server] = __nameList(raw[server]);\n }\n return out;\n})();\nconst __mcpManagement = {\n servers: () => __call(\"mcp.$servers\", {}),\n reload: () => __call(\"mcp.$reload\", {}),\n register: (args) => __call(\"mcp.$register\", args),\n call: (args) => __call(\"mcp.$call\", args),\n};\nglobalThis.mcp = __lazyNamespace(\n Object.keys(__mcpServerTools).sort(),\n (server) => __lazyNamespace(\n __mcpServerTools[server] ? __mcpServerTools[server].slice().sort() : [],\n (tool) => (args = {}) => __call(\"mcp.\" + server + \".\" + tool, args),\n ),\n __mcpManagement,\n);\nlet __workflowSpentTokens = 0;\nconst __workflowBudgetTotal = Number.isFinite(globalThis.__fabricTokenBudget)\n ? Math.max(0, globalThis.__fabricTokenBudget)\n : Number.POSITIVE_INFINITY;\nconst __recordAgentUsage = (result) => {\n const usage = result && result.usage;\n if (usage) __workflowSpentTokens += Number(usage.input || 0) + Number(usage.output || 0);\n return result;\n};\nconst __workflowAgent = async (prompt, options = {}) => {\n if (__workflowSpentTokens >= __workflowBudgetTotal) {\n throw new Error(\"Fabric workflow token budget exhausted\");\n }\n const { label, ...agentOptions } = options;\n const workerName = String(label || agentOptions.name || \"Fabric workflow agent\");\n const result = __recordAgentUsage(await agents.run({\n ...agentOptions,\n ...(label && !agentOptions.name ? { name: label } : {}),\n task: prompt,\n }));\n if (!result || result.status !== \"completed\") {\n const reason = result && result.error ? result.error : \"agent did not complete\";\n throw new Error(workerName + \" failed: \" + reason);\n }\n return result.value !== undefined ? result.value : result.text;\n};\n// Budget-aware agents.run used by council.run and rlm.query so their usage is\n// counted in budget.spent() and the tokenBudget guard can preempt them, just\n// like workflow.agent(). Without this, councils bypass the budget entirely.\nconst __budgetedRun = async (args) => {\n if (__workflowSpentTokens >= __workflowBudgetTotal) {\n throw new Error(\"Fabric workflow token budget exhausted\");\n }\n return __recordAgentUsage(await agents.run(args));\n};\nlet __nextWorkflowSpanId = 0;\nconst __workflowSpanMetadata = (kind, items, options, stageCount) => {\n const itemCount = Array.isArray(items) ? items.length : undefined;\n let concurrency;\n if (kind === \"parallel\" && itemCount !== undefined) {\n if (itemCount === 0) concurrency = 0;\n else {\n const concurrencyOpt = typeof options === \"number\" ? { concurrency: options } : options ?? {};\n const requested = Number(concurrencyOpt.concurrency ?? itemCount);\n if (Number.isFinite(requested) && requested >= 1) {\n concurrency = Math.max(1, Math.min(itemCount, Math.floor(requested)));\n }\n }\n }\n return {\n kind,\n ...(itemCount !== undefined ? { itemCount } : {}),\n ...(stageCount !== undefined ? { stageCount } : {}),\n ...(concurrency !== undefined ? { concurrency } : {}),\n };\n};\nconst __withWorkflowSpan = async (metadata, body) => {\n const id = \"span-\" + __nextWorkflowSpanId++;\n await __call(\"fabric.$spanStart\", { id, ...metadata });\n try {\n const value = await body();\n await __call(\"fabric.$spanEnd\", { id, outcome: \"succeeded\" });\n return value;\n } catch (error) {\n try { await __call(\"fabric.$spanEnd\", { id, outcome: \"failed\" }); } catch { /* preserve the workflow error */ }\n throw error;\n }\n};\nconst __runParallel = async (thunks, options) => {\n if (!Array.isArray(thunks) || thunks.some((thunk) => typeof thunk !== \"function\")) {\n throw new TypeError(\"workflow.parallel expects an array of functions or (items, mapper)\");\n }\n if (thunks.length === 0) return [];\n const concurrencyOpt = typeof options === \"number\" ? { concurrency: options } : options ?? {};\n const requestedConcurrency = Number(concurrencyOpt.concurrency ?? thunks.length);\n if (!Number.isFinite(requestedConcurrency) || requestedConcurrency < 1) {\n throw new RangeError(\"workflow.parallel concurrency must be a positive finite number\");\n }\n const concurrency = Math.max(1, Math.min(thunks.length || 1, Math.floor(requestedConcurrency)));\n const results = new Array(thunks.length);\n let cursor = 0;\n await Promise.all(Array.from({ length: concurrency }, async () => {\n while (cursor < thunks.length) {\n const index = cursor++;\n results[index] = await thunks[index]();\n }\n }));\n return results;\n};\nconst __workflowParallel = async (items, arg2, arg3) => {\n const options = typeof arg2 === \"function\" ? arg3 : arg2;\n return __withWorkflowSpan(\n __workflowSpanMetadata(\"parallel\", items, options),\n async () => {\n if (typeof arg2 === \"function\") {\n if (!Array.isArray(items)) throw new TypeError(\"workflow.parallel expects an array as the first argument\");\n return __runParallel(items.map((item, index) => () => arg2(item, index)), arg3);\n }\n return __runParallel(items, arg2);\n },\n );\n};\nconst __workflowPipeline = async (items, ...stages) =>\n __withWorkflowSpan(\n __workflowSpanMetadata(\"pipeline\", items, undefined, stages.length),\n async () => {\n if (!Array.isArray(items) || stages.some((stage) => typeof stage !== \"function\")) {\n throw new TypeError(\"workflow.pipeline expects an array followed by stage functions\");\n }\n return __workflowParallel(items.map((original, index) => async () => {\n let value = original;\n for (const stage of stages) value = await stage(value, original, index);\n return value;\n }));\n },\n );\nglobalThis.workflow = Object.freeze({\n agent: __workflowAgent,\n parallel: __workflowParallel,\n pipeline: __workflowPipeline,\n configure: (args) => __call(\"fabric.$configure\", args),\n phase: (nameOrInput, options = {}) => {\n const input =\n nameOrInput && typeof nameOrInput === \"object\" && !Array.isArray(nameOrInput)\n ? { ...nameOrInput }\n : { ...options, name: nameOrInput };\n return __call(\"fabric.$phase\", input);\n },\n item: (args) => __call(\"fabric.$item\", args),\n event: (args) => __call(\"fabric.$event\", args),\n log: (...values) => print(...values),\n budget: Object.freeze({\n total: __workflowBudgetTotal,\n spent: () => __workflowSpentTokens,\n remaining: () => Math.max(0, __workflowBudgetTotal - __workflowSpentTokens),\n }),\n});\nglobalThis.agent = __workflowAgent;\nglobalThis.parallel = __workflowParallel;\nglobalThis.pipeline = __workflowPipeline;\nglobalThis.phase = workflow.phase;\nglobalThis.log = workflow.log;\nglobalThis.budget = workflow.budget;\nglobalThis.rlm = Object.freeze({\n query: (args) => {\n if (args && args.runner && args.runner !== \"omp\") {\n throw new Error(\"rlm.query requires the OMP runner because recursive Fabric is unavailable in Claude Code\");\n }\n return __budgetedRun({ ...args, runner: \"omp\", recursive: true });\n },\n});\nglobalThis.council = Object.freeze({\n async run(args) {\n const { task, roles, synthesize = true, ...agentOptions } = args;\n const results = await Promise.all(roles.map((role) => __budgetedRun({\n ...agentOptions,\n name: role,\n task: \"Act as the \" + role + \" council member. Independently analyze this task:\\n\\n\" + task,\n })));\n if (!synthesize) return results;\n return __budgetedRun({\n ...agentOptions,\n name: \"council-synthesizer\",\n task: \"Synthesize the council's independent reports into one decision. Preserve disagreements and cite which role raised each concern.\\n\\nTask:\\n\" + task + \"\\n\\nReports:\\n\" + JSON.stringify(results),\n });\n },\n});\nglobalThis.console = Object.freeze({ log: print, info: print, warn: print, error: print });\nconst __timerCallbacks = new Map();\nlet __nextTimerId = 1;\nglobalThis.setTimeout = (callback, ms = 0) => {\n const id = __nextTimerId++;\n __timerCallbacks.set(id, { callback, interval: false });\n __call(\"fabric.$timer\", { ms }).then(() => {\n const entry = __timerCallbacks.get(id);\n if (!entry) return;\n __timerCallbacks.delete(id);\n try { entry.callback(); } catch { /* swallow timer callback errors */ }\n });\n return id;\n};\nglobalThis.setInterval = (callback, ms = 0) => {\n const id = __nextTimerId++;\n __timerCallbacks.set(id, { callback, interval: true });\n const schedule = () => {\n __call(\"fabric.$timer\", { ms }).then(() => {\n const entry = __timerCallbacks.get(id);\n if (!entry) return;\n try { entry.callback(); } catch { /* swallow timer callback errors */ }\n if (__timerCallbacks.has(id)) schedule();\n });\n };\n schedule();\n return id;\n};\nglobalThis.clearTimeout = (id) => { __timerCallbacks.delete(id); };\nglobalThis.clearInterval = (id) => { __timerCallbacks.delete(id); };\n})();\n";
|
|
26
26
|
export declare class QuickJsRuntime {
|
|
27
27
|
execute(code: string, hostCall: FabricHostCall, options: FabricSandboxOptions): Promise<FabricSandboxResult>;
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quickjs-runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/quickjs-runtime.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,8BAA8B,GACtC,WAAW,GACX,eAAe,GACf,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,iBAAiB,EAAE,8BAA8B,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,2BAA2B,CAAC,CAC1B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,GAAG,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,MAAM,cAAc,GAAG,CAC3B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,WAAW,KAChB,OAAO,CAAC,OAAO,CAAC,CAAC;AA+CtB,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"quickjs-runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/quickjs-runtime.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,8BAA8B,GACtC,WAAW,GACX,eAAe,GACf,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,iBAAiB,EAAE,8BAA8B,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,2BAA2B,CAAC,CAC1B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,GAAG,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,MAAM,cAAc,GAAG,CAC3B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,WAAW,KAChB,OAAO,CAAC,OAAO,CAAC,CAAC;AA+CtB,eAAO,MAAM,WAAW,457CA0hCvB,CAAC;AA0DF,qBAAa,cAAc;IACnB,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC;CA0XhC"}
|
package/dist/ui/settings.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { buildClaudeModelSource, type ModelSource } from "./model-picker.js";
|
|
|
4
4
|
import { type FabricConfig, type FabricConfigScope } from "../config.js";
|
|
5
5
|
import type { CapturedToolCatalog } from "../capture/catalog.js";
|
|
6
6
|
import type { FabricState } from "../fabric-state.js";
|
|
7
|
-
export declare const ROOT_ITEM_IDS: readonly ["fullCodeMode", "executor", "schema", "approvals", "mcp", "prewalk", "codemap", "agents", "models", "capture", "ui", "compaction", "retention", "mesh", "memory", "speculation", "judgment", "codePreview"];
|
|
7
|
+
export declare const ROOT_ITEM_IDS: readonly ["fullCodeMode", "executor", "schema", "approvals", "mcp", "prewalk", "codemap", "agents", "models", "capture", "ui", "compaction", "retention", "mesh", "memory", "speculation", "judgment", "image", "codePreview"];
|
|
8
8
|
export declare const FILE_ONLY_CONFIG_KEYS: Readonly<Record<string, string>>;
|
|
9
9
|
export declare const ALIASED_CONFIG_KEYS: Readonly<Record<string, string>>;
|
|
10
10
|
export declare const executorMemoryLimitOptions: (maximumBytes?: number) => number[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/ui/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEzE,OAAO,EACL,SAAS,EAST,YAAY,EACZ,KAAK,WAAW,EAIjB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,sBAAsB,EAItB,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/ui/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEzE,OAAO,EACL,SAAS,EAST,YAAY,EACZ,KAAK,WAAW,EAIjB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,sBAAsB,EAItB,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAaL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA0EtD,eAAO,MAAM,aAAa,gOAoBhB,CAAC;AAGX,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOlE,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIhE,CAAC;AAgDF,eAAO,MAAM,0BAA0B,GACrC,qBAA6C,KAC5C,MAAM,EAMR,CAAC;AAoBF,MAAM,MAAM,4BAA4B,GACpC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AActC,eAAO,MAAM,0BAA0B,GACrC,UAAU,MAAM,EAChB,WAAW,4BAA4B,KACtC,MAAM,CAAC,MAAM,EAAE,OAAO,CAKvB,CAAC;AA2BH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,MAIhD,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,KAAG,MAsB1D,CAAC;AAuFF,eAAO,MAAM,WAAW,GAAI,IAAI,MAAM,EAAE,OAAO,MAAM,EAAE,QAAQ,YAAY,KAAG,OA2D7E,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,EAAE,OAAO,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAc/E,CAAC;AAwkBF,MAAM,WAAW,8BAA8B;IAC7C,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACvD,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,WAAW,EAAE,CAAC;CACjE;AAED,qBAAa,uBAAwB,SAAQ,SAAS;IACpD,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAO;IACrC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAY;IAClD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAU;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyC;IAClE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqC;IACvE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA4D;IAC9F,OAAO,CAAC,SAAS,CAAoB;gBAGnC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,WAAW,EAAE,EACpB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,EAChD,QAAQ,EAAE,MAAM,IAAI,EACpB,OAAO,GAAE,8BAAmC;IAwB9C,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAiB/B,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,mBAAmB;CAe5B;AAED,eAAO,MAAM,yBAAyB,GACpC,QAAQ,WAAW,EACnB,MAAM,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,KAChE,OAAO,CAAC,IAAI,CAId,CAAC;AAkBF,eAAO,MAAM,wBAAwB,GACnC,OAAO,KAAK,EACZ,QAAQ,YAAY,EACpB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,EAC3C,SAAS;IACP,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,CAAC,EAAE,WAAW,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,KACA,WAAW,EA+1Db,CAAC;AAwOF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,WAAW,CAAC;IACnB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,EAAE,mBAAmB,CAAC;IACnC,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,IAAI,CAAC,CAsIf"}
|
package/dist/ui/settings.js
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
DEFAULT_FABRIC_CONFIG,
|
|
18
18
|
MAX_COMPACTION_RATIO_THRESHOLD,
|
|
19
19
|
MAX_COMPACTION_TOKEN_THRESHOLD,
|
|
20
|
+
MAX_IMAGE_MODELS,
|
|
20
21
|
MIN_COMPACTION_RATIO_THRESHOLD,
|
|
21
22
|
MIN_COMPACTION_TOKEN_THRESHOLD,
|
|
22
23
|
QUICKJS_MAX_MEMORY_LIMIT_BYTES,
|
|
@@ -26,7 +27,7 @@ import {
|
|
|
26
27
|
maxExecutorMemoryLimitBytes,
|
|
27
28
|
resolveAgentDir,
|
|
28
29
|
saveFabricConfig
|
|
29
|
-
} from "../chunks/chunk-
|
|
30
|
+
} from "../chunks/chunk-66H3QSMR.js";
|
|
30
31
|
import {
|
|
31
32
|
THINKING_LEVELS,
|
|
32
33
|
thinkingLabel
|
|
@@ -133,16 +134,19 @@ var ROOT_ITEM_IDS = [
|
|
|
133
134
|
"memory",
|
|
134
135
|
"speculation",
|
|
135
136
|
"judgment",
|
|
137
|
+
"image",
|
|
136
138
|
"codePreview"
|
|
137
139
|
];
|
|
138
140
|
var RELOAD_SECTIONS = /* @__PURE__ */ new Set(["mesh", "agents", "mcp", "retention", "memory"]);
|
|
139
141
|
var FILE_ONLY_CONFIG_KEYS = {
|
|
140
142
|
components: "Every entry is a supervised instance record whose config field carries definition-specific JSON that no fixed row can validate.",
|
|
143
|
+
"image.dialects": "Per-model dialect overrides are a provider-by-provider escape hatch; the panel edits the priority chain and leaves the override map to the file.",
|
|
141
144
|
"schema.trustedCommands": "Every entry is an execution record (command, args, shell, timeoutMs) that bypasses approval in enforce mode, so a mistyped row would widen that bypass."
|
|
142
145
|
};
|
|
143
146
|
var ALIASED_CONFIG_KEYS = {
|
|
144
147
|
"compaction.thresholds": COMPACTION_THRESHOLD_SETTING_ID,
|
|
145
|
-
"compaction.tokenThresholds": COMPACTION_THRESHOLD_SETTING_ID
|
|
148
|
+
"compaction.tokenThresholds": COMPACTION_THRESHOLD_SETTING_ID,
|
|
149
|
+
"image.models": "image.models.1"
|
|
146
150
|
};
|
|
147
151
|
var SAVE_SCOPE_SHORTCUT = Key.ctrl("g");
|
|
148
152
|
var unique = (values) => [...new Set(values)];
|
|
@@ -277,6 +281,25 @@ var parseModelAliases = (value) => {
|
|
|
277
281
|
}
|
|
278
282
|
return parsed;
|
|
279
283
|
};
|
|
284
|
+
var IMAGE_SLOT_PREFIX = "image.models.";
|
|
285
|
+
var IMAGE_EMPTY_SLOT = "\u2014 empty \u2014";
|
|
286
|
+
var imageSlotIndex = (id) => {
|
|
287
|
+
if (!id.startsWith(IMAGE_SLOT_PREFIX)) return void 0;
|
|
288
|
+
const raw = id.slice(IMAGE_SLOT_PREFIX.length);
|
|
289
|
+
if (!/^\d+$/.test(raw)) return void 0;
|
|
290
|
+
const slot = Number(raw);
|
|
291
|
+
return slot >= 1 && slot <= MAX_IMAGE_MODELS ? slot : void 0;
|
|
292
|
+
};
|
|
293
|
+
var imageSlotPartial = (config, id, value) => {
|
|
294
|
+
const slot = imageSlotIndex(id);
|
|
295
|
+
const models = [...config.image.models];
|
|
296
|
+
if (slot === void 0) return { image: { models } };
|
|
297
|
+
const selector = typeof value === "string" && value !== IMAGE_EMPTY_SLOT ? value.trim() : "";
|
|
298
|
+
if (selector.length === 0) models.splice(slot - 1, 1);
|
|
299
|
+
else if (slot <= models.length) models[slot - 1] = selector;
|
|
300
|
+
else models.push(selector);
|
|
301
|
+
return { image: { models } };
|
|
302
|
+
};
|
|
280
303
|
var coerceValue = (id, value, config) => {
|
|
281
304
|
if (id === "executor.hostCallTimeouts") {
|
|
282
305
|
const parsed = parseHostCallTimeouts(value);
|
|
@@ -286,6 +309,8 @@ var coerceValue = (id, value, config) => {
|
|
|
286
309
|
const parsed = parseModelAliases(value);
|
|
287
310
|
return parsed === void 0 ? { ...config.models.aliases } : withRemovals(config.models.aliases, parsed);
|
|
288
311
|
}
|
|
312
|
+
if (imageSlotIndex(id) !== void 0) return value === IMAGE_EMPTY_SLOT ? "" : value;
|
|
313
|
+
if (id === "image.outputDir") return value === "OS temp" ? "" : value;
|
|
289
314
|
if (id === "speculation.mcpAllowlist") return splitEntries(value);
|
|
290
315
|
if (id === "ui.conversationShortcut") return value === "off" ? "" : value;
|
|
291
316
|
if (id === COMPACTION_THRESHOLD_SETTING_ID) {
|
|
@@ -377,6 +402,11 @@ var summaryFor = (id, config) => {
|
|
|
377
402
|
const gates = Object.values(config.judgment.gates).filter(Boolean).length;
|
|
378
403
|
return gates === 0 ? formatMs(config.judgment.timeoutMs) : `${gates} gate${gates === 1 ? "" : "s"} on`;
|
|
379
404
|
}
|
|
405
|
+
case "image": {
|
|
406
|
+
if (!config.image.enabled) return "disabled";
|
|
407
|
+
const count = config.image.models.length;
|
|
408
|
+
return count === 0 ? "no models" : `${count} model${count === 1 ? "" : "s"}`;
|
|
409
|
+
}
|
|
380
410
|
case "codePreview":
|
|
381
411
|
return config.codePreview.shikiTheme;
|
|
382
412
|
default:
|
|
@@ -447,9 +477,15 @@ var markDrillIn = (items) => {
|
|
|
447
477
|
}
|
|
448
478
|
return items;
|
|
449
479
|
};
|
|
450
|
-
var sectionSubmenu = (theme, title, description, items, persist) => (_currentValue, done) => (
|
|
451
|
-
|
|
452
|
-
|
|
480
|
+
var sectionSubmenu = (theme, title, description, items, persist, rebuild) => (_currentValue, done) => new SectionSubmenu(
|
|
481
|
+
theme,
|
|
482
|
+
title,
|
|
483
|
+
description,
|
|
484
|
+
markDrillIn(items),
|
|
485
|
+
persist,
|
|
486
|
+
() => done(),
|
|
487
|
+
true,
|
|
488
|
+
rebuild === void 0 ? void 0 : () => markDrillIn(rebuild())
|
|
453
489
|
);
|
|
454
490
|
var IntegerInputSubmenu = class extends Container {
|
|
455
491
|
input;
|
|
@@ -692,25 +728,43 @@ var SectionSubmenu = class extends Container {
|
|
|
692
728
|
settingsList;
|
|
693
729
|
items;
|
|
694
730
|
applyChange;
|
|
695
|
-
|
|
731
|
+
listContainer;
|
|
732
|
+
rebuild;
|
|
733
|
+
constructor(theme, title, description, items, onChange, onCancel, enableSearch = false, rebuild) {
|
|
696
734
|
super();
|
|
697
735
|
this.items = items;
|
|
698
|
-
this.
|
|
736
|
+
this.rebuild = rebuild;
|
|
737
|
+
this.applyChange = (id, newValue) => {
|
|
738
|
+
onChange(id, newValue);
|
|
739
|
+
const rebuild2 = this.rebuild;
|
|
740
|
+
if (!rebuild2) return;
|
|
741
|
+
queueMicrotask(() => {
|
|
742
|
+
this.items = rebuild2();
|
|
743
|
+
this.listContainer.clear();
|
|
744
|
+
this.settingsList = this.createList(theme, this.items, onChange, onCancel, enableSearch);
|
|
745
|
+
this.listContainer.addChild(this.settingsList);
|
|
746
|
+
});
|
|
747
|
+
};
|
|
699
748
|
this.addChild(new Text(theme.bold(theme.fg("accent", title)), 0, 0));
|
|
700
749
|
if (description) {
|
|
701
750
|
this.addChild(new Spacer(1));
|
|
702
751
|
this.addChild(new Text(theme.fg("muted", description), 0, 0));
|
|
703
752
|
}
|
|
704
753
|
this.addChild(new Spacer(1));
|
|
705
|
-
this.
|
|
754
|
+
this.listContainer = new Container();
|
|
755
|
+
this.settingsList = this.createList(theme, items, onChange, onCancel, enableSearch);
|
|
756
|
+
this.listContainer.addChild(this.settingsList);
|
|
757
|
+
this.addChild(this.listContainer);
|
|
758
|
+
}
|
|
759
|
+
createList(theme, items, onChange, onCancel, enableSearch) {
|
|
760
|
+
return new SettingsList(
|
|
706
761
|
items,
|
|
707
762
|
Math.min(items.length, 16),
|
|
708
763
|
settingsListTheme(theme),
|
|
709
|
-
|
|
764
|
+
(id, newValue) => this.applyChange(id, newValue),
|
|
710
765
|
onCancel,
|
|
711
766
|
{ typeToSearch: enableSearch }
|
|
712
767
|
);
|
|
713
|
-
this.addChild(this.settingsList);
|
|
714
768
|
}
|
|
715
769
|
handleInput(data) {
|
|
716
770
|
this.settingsList.handleInput(data);
|
|
@@ -792,6 +846,56 @@ var buildFabricSettingsItems = (theme, config, apply, options) => {
|
|
|
792
846
|
const persist = (id, newValue) => apply(id, coerceValue(id, newValue, config));
|
|
793
847
|
const envFullCode = process.env.OMP_FABRIC_FULL_CODE_MODE;
|
|
794
848
|
const fullCodeDescription = envFullCode ? "Fabric owns OMP core tools (read, bash, edit, write, grep, find, ls) via fabric_exec; only tools active in OMP stay reachable. Currently overridden by the OMP_FABRIC_FULL_CODE_MODE environment variable." : "Fabric owns OMP core tools (read, bash, edit, write, grep, find, ls) via fabric_exec; only tools active in OMP stay reachable. Disable to keep native tools model-facing (orchestration-only mode).";
|
|
849
|
+
const imageSectionItems = () => [
|
|
850
|
+
setting("image.enabled", "Enabled", config.image.enabled ? "true" : "false", {
|
|
851
|
+
description: "Master switch for the image.generate, image.edit, and image.models actions.",
|
|
852
|
+
values: BOOLEANS
|
|
853
|
+
}),
|
|
854
|
+
...Array.from({ length: MAX_IMAGE_MODELS }, (_unused, index) => {
|
|
855
|
+
const slot = index + 1;
|
|
856
|
+
return setting(
|
|
857
|
+
`image.models.${slot}`,
|
|
858
|
+
`Priority ${slot}`,
|
|
859
|
+
config.image.models[index] ?? IMAGE_EMPTY_SLOT,
|
|
860
|
+
{
|
|
861
|
+
description: "Model tried at this priority. Pick a model, or Empty to skip this slot.",
|
|
862
|
+
submenu: modelPickerSubmenu(theme, options.modelSource, {
|
|
863
|
+
headerText: `Model tried at priority ${slot}. Empty skips this slot.`,
|
|
864
|
+
inheritLabel: IMAGE_EMPTY_SLOT,
|
|
865
|
+
inheritName: "Leave this priority empty"
|
|
866
|
+
})
|
|
867
|
+
}
|
|
868
|
+
);
|
|
869
|
+
}),
|
|
870
|
+
setting("image.retries", "Retries", String(config.image.retries), {
|
|
871
|
+
description: "Extra attempts per model after a failure; hosted image backends drop calls often.",
|
|
872
|
+
submenu: numericSubmenu(
|
|
873
|
+
theme,
|
|
874
|
+
[0, 1, 2, 3, 4],
|
|
875
|
+
String,
|
|
876
|
+
"Retries",
|
|
877
|
+
"Extra attempts per model after a failure."
|
|
878
|
+
)
|
|
879
|
+
}),
|
|
880
|
+
setting("image.timeoutMs", "Attempt deadline", formatMs(config.image.timeoutMs), {
|
|
881
|
+
description: "Deadline for one model attempt, including the body read.",
|
|
882
|
+
submenu: numericSubmenu(
|
|
883
|
+
theme,
|
|
884
|
+
[3e4, 6e4, 9e4, 12e4, 18e4, 3e5, 6e5, 9e5],
|
|
885
|
+
formatMs,
|
|
886
|
+
"Attempt deadline",
|
|
887
|
+
"Deadline for one model attempt, including the body read."
|
|
888
|
+
)
|
|
889
|
+
}),
|
|
890
|
+
setting("image.outputDir", "Output directory", config.image.outputDir || "OS temp", {
|
|
891
|
+
description: "Where generated files are written. Empty uses the OS temp directory.",
|
|
892
|
+
submenu: stringInputSubmenu(
|
|
893
|
+
theme,
|
|
894
|
+
"Output directory",
|
|
895
|
+
"Directory for generated files, absolute or relative to the session cwd. Enter OS temp to clear."
|
|
896
|
+
)
|
|
897
|
+
})
|
|
898
|
+
];
|
|
795
899
|
const executorMemoryDescription = () => config.executor.runtime === "quickjs" ? "Maximum QuickJS heap size. WASM32 limits this to less than 4 GiB." : config.executor.runtime === "bun-process" ? "Heap target for the disposable Bun process. Bun ignores V8 heap flags, so this limit is not enforced." : "V8 old-generation heap limit for the disposable Node process. Large allocations may destabilize the system.";
|
|
796
900
|
const defaultToolsItem = setting(
|
|
797
901
|
"agents.defaultTools",
|
|
@@ -2408,6 +2512,17 @@ var buildFabricSettingsItems = (theme, config, apply, options) => {
|
|
|
2408
2512
|
persist
|
|
2409
2513
|
)
|
|
2410
2514
|
}),
|
|
2515
|
+
setting("image", "Image", summaryFor("image", config), {
|
|
2516
|
+
description: "Image generation and editing through a configurable priority chain of image models.",
|
|
2517
|
+
submenu: sectionSubmenu(
|
|
2518
|
+
theme,
|
|
2519
|
+
"Image",
|
|
2520
|
+
"Each priority is tried in order until a model returns bytes. An empty priority is skipped, so the chain compacts upward. Changes apply after /fabric reload.",
|
|
2521
|
+
imageSectionItems(),
|
|
2522
|
+
persist,
|
|
2523
|
+
imageSectionItems
|
|
2524
|
+
)
|
|
2525
|
+
}),
|
|
2411
2526
|
setting("codePreview", "Code previews", summaryFor("codePreview", config), {
|
|
2412
2527
|
description: "Core tool previews, diffs, and Shiki syntax highlighting.",
|
|
2413
2528
|
submenu: sectionSubmenu(
|
|
@@ -2714,7 +2829,7 @@ async function openFabricSettings(context, deps) {
|
|
|
2714
2829
|
let dirty = false;
|
|
2715
2830
|
const activeModelKey = context.model ? modelKey(context.model.provider, context.model.id) : void 0;
|
|
2716
2831
|
const apply = (id, value) => {
|
|
2717
|
-
const partial = id === COMPACTION_THRESHOLD_SETTING_ID && activeModelKey ? compactionThresholdPartial(activeModelKey, value) : buildPartial(id, value);
|
|
2832
|
+
const partial = id === COMPACTION_THRESHOLD_SETTING_ID && activeModelKey ? compactionThresholdPartial(activeModelKey, value) : imageSlotIndex(id) !== void 0 ? imageSlotPartial(settingsConfig, id, value) : buildPartial(id, value);
|
|
2718
2833
|
try {
|
|
2719
2834
|
saveFabricConfig(
|
|
2720
2835
|
{ cwd: context.cwd, agentDir, projectTrusted, scope: saveScope },
|