pi-fabric 0.96.2 → 0.96.4

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/README.md CHANGED
@@ -146,8 +146,8 @@ See the [interface & commands reference](docs/interface.md) for every view, keyb
146
146
  - [Interface & commands](docs/interface.md): dashboard, settings, keybindings, slash commands, and headless runs.
147
147
  - [Agents, actors & mesh](docs/agents.md): model handoff, `/fabric prewalk`, runners, transports, actors, councils, recursive queries, and durable coordination.
148
148
  - [Durable residency through Pi](docs/residency-runtime.md): background host lifecycle and the Pi-runtime launcher boundary.
149
- - [External connector components](docs/harnesses.md): connector-owned browser/macOS extensions using the generic component lifecycle. No connector-specific runtime registration; works with ordinary models, deterministic code, or Jev.
150
- - [Jev System One programs](docs/jev.md): typed judgments, `/login jev`, `openrouter`, or `vercel-ai-gateway` credentials, foreground/background loops, and budgets.
149
+ - [Harness CLI composition](docs/harnesses.md): use browser/macOS tools through their existing CLIs, without Fabric-specific bridges or component configuration.
150
+ - [Jev shell orchestration](docs/jev.md): bounded process supervision, event-driven task wait/watch, optional explicit typed judgments, and foreground/background budgets.
151
151
  - [Components & committed capabilities](docs/components.md): supervised effects, exact requirements, external per-model guidance and execution-profile replacement, rolling provider generations, actor commitments, and both formal calculi.
152
152
  - [External providers](docs/providers.md): the versioned provider protocol for extensions.
153
153
  - [Architecture & security](docs/architecture.md): the host bridge, sandboxing, tool-call robustness, and limits.
@@ -355,7 +355,7 @@ var jevLaunchSchema = Type.Object({
355
355
  requires: Type.Array(Type.String({ minLength: 3, maxLength: 256 }), { maxItems: 64, uniqueItems: true }),
356
356
  limits: Type.Optional(Type.Object({
357
357
  timeoutMs: Type.Optional(Type.Integer({ minimum: 1 })),
358
- maxEvaluations: Type.Optional(Type.Integer({ minimum: 1 })),
358
+ maxEvaluations: Type.Optional(Type.Integer({ minimum: 0 })),
359
359
  maxToolCalls: Type.Optional(Type.Integer({ minimum: 1 })),
360
360
  maxTokens: Type.Optional(Type.Integer({ minimum: 1 }))
361
361
  }, { additionalProperties: false }))
@@ -375,7 +375,7 @@ var jevAdviceSchema = Type.Object({
375
375
  }, { additionalProperties: false });
376
376
  var JEV_ACTION_DESCRIPTORS = [
377
377
  { name: "evaluate", description: "Ask Jev typed Choice, Noul (probability of yes), and Score questions over shared state. No generated text. Batch independent questions. Sends state to TypeSafe and consumes API credits; no automatic retries.", inputSchema: jevRequestSchema, risk: "network", effect: { kind: "emission", resources: ["typesafe:inference"], ordering: "unknown" } },
378
- { name: "run", description: "Run an isolated TypeScript System One program in the foreground. Returns a terminal run envelope with schema-validated result or error. Globals: input, jev.evaluate, program.sleep(ms), program.emit(value), and Fabric tools restricted to exact requires. Loops are supported; no host imports or secrets.", inputSchema: jevLaunchSchema, risk: "execute" },
378
+ { name: "run", description: "Run a bounded TypeScript shell orchestrator or typed-decision program in the foreground. Returns a terminal run envelope with schema-validated result or error. Globals: input, jev.evaluate, program.sleep(ms), program.emit(value), and Fabric tools restricted to exact requires. Use granted pi.bash and tasks.wait/watch for shell orchestration; maxEvaluations:0 disables program inference. No automatic judgments, host imports or secrets.", inputSchema: jevLaunchSchema, risk: "execute" },
379
379
  { name: "spawn", description: "Launch a session-owned background Jev program. Optional observe requires read approval and subscribes to Main lifecycle events; program.nextEvent waits without polling and shares only explicitly selected bounded context. program.advise needs observe.delivery and requires jev.advise. Use status, wait/join, and stop; not restart-durable.", inputSchema: jevLaunchSchema, risk: "execute" },
380
380
  { name: "status", description: "Without id: credential configuration status (never retrieves secrets) and run summaries. With id: state, usage, bounded events after sequence, logs, result/error. Retains at most 64 events; nextSequence allows detecting gaps.", inputSchema: statusSchema, risk: "read" },
381
381
  { name: "wait", description: "Wait for a background Jev program's terminal run envelope. Cancelling the wait does not cancel the program.", inputSchema: idSchema, risk: "read" },
@@ -385,7 +385,7 @@ var JEV_ACTION_DESCRIPTORS = [
385
385
  ];
386
386
  var JevProvider = class {
387
387
  name = "jev";
388
- description = "TypeSafe System One judgments and foreground/background reactive TypeScript programs";
388
+ description = "Shell-first TypeScript orchestration with explicit typed Jev decisions";
389
389
  manager;
390
390
  client;
391
391
  route;
@@ -448,4 +448,4 @@ export {
448
448
  JEV_ACTION_DESCRIPTORS,
449
449
  JevProvider
450
450
  };
451
- //# sourceMappingURL=chunk-4BW7JF2W.js.map
451
+ //# sourceMappingURL=chunk-QFKHAAZA.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/providers/jev-provider.ts", "../../src/jev/manager.ts"],
4
+ "sourcesContent": ["import { Type } from \"typebox\";\nimport { validationMessage } from \"../core/action-arguments.js\";\nimport type { FabricActionDescriptor, FabricInvocationContext, FabricProvider, FabricProviderListRequest } from \"../protocol.js\";\nimport { JevClient, JevCredentials, type JevCredentialSource } from \"../jev/client.js\";\nimport { JevProgramManager, type JevManagerOptions } from \"../jev/manager.js\";\nimport { resolveJevModelRoute, type JevRoute } from \"../jev/routes.js\";\nimport type { JevLaunch, JevRequest } from \"../jev/types.js\";\nimport { jevObserveSchema } from \"../jev/observation.js\";\n\nconst description = Type.Union([Type.String(), Type.Array(Type.Unknown()), Type.Record(Type.String(), Type.Unknown())]);\nconst question = Type.Union([\n Type.Object({ type: Type.Literal(\"noul\"), instructions: description, criteria: Type.Optional(Type.Object({ true: Type.Optional(description), false: Type.Optional(description) }, { additionalProperties: false })) }, { additionalProperties: false }),\n Type.Object({ type: Type.Literal(\"choice\"), instructions: description, criteria: Type.Record(Type.String(), Type.Union([description, Type.Null()]), { minProperties: 1, maxProperties: 255 }) }, { additionalProperties: false }),\n Type.Object({ type: Type.Literal(\"score\"), instructions: description, criteria: Type.Array(description, { minItems: 2, maxItems: 10 }) }, { additionalProperties: false }),\n]);\nexport const jevRequestSchema = Type.Object({\n state: description,\n questions: Type.Record(Type.String(), question, { minProperties: 1, maxProperties: 128 }),\n model: Type.Optional(Type.String({ minLength: 1, maxLength: 128 })),\n}, { additionalProperties: false });\nexport const jevLaunchSchema = Type.Object({\n program: Type.Object({\n name: Type.String({ minLength: 1, maxLength: 128 }),\n code: Type.String({ minLength: 1, maxLength: 65_536 }),\n inputSchema: Type.Record(Type.String(), Type.Unknown()),\n outputSchema: Type.Record(Type.String(), Type.Unknown()),\n requires: Type.Array(Type.String({ minLength: 3, maxLength: 256 }), { maxItems: 64, uniqueItems: true }),\n limits: Type.Optional(Type.Object({\n timeoutMs: Type.Optional(Type.Integer({ minimum: 1 })),\n maxEvaluations: Type.Optional(Type.Integer({ minimum: 0 })),\n maxToolCalls: Type.Optional(Type.Integer({ minimum: 1 })),\n maxTokens: Type.Optional(Type.Integer({ minimum: 1 })),\n }, { additionalProperties: false })),\n }, { additionalProperties: false }),\n input: Type.Unknown(),\n observe: Type.Optional(jevObserveSchema),\n}, { additionalProperties: false });\nconst idSchema = Type.Object({ id: Type.String({ minLength: 1, maxLength: 128 }) }, { additionalProperties: false });\nconst statusSchema = Type.Object({\n id: Type.Optional(Type.String({ minLength: 1, maxLength: 128 })),\n after: Type.Optional(Type.Integer({ minimum: 0 })),\n}, { additionalProperties: false });\nexport const jevAdviceSchema = Type.Object({\n id: Type.String({ minLength: 1, maxLength: 128 }),\n eventId: Type.String({ minLength: 1, maxLength: 256 }),\n message: Type.String({ minLength: 1, maxLength: 2000 }),\n}, { additionalProperties: false });\nexport const JEV_ACTION_DESCRIPTORS: FabricActionDescriptor[] = [\n { name: \"evaluate\", description: \"Ask Jev typed Choice, Noul (probability of yes), and Score questions over shared state. No generated text. Batch independent questions. Sends state to TypeSafe and consumes API credits; no automatic retries.\", inputSchema: jevRequestSchema as unknown as Record<string, unknown>, risk: \"network\", effect: { kind: \"emission\", resources: [\"typesafe:inference\"], ordering: \"unknown\" } },\n { name: \"run\", description: \"Run a bounded TypeScript shell orchestrator or typed-decision program in the foreground. Returns a terminal run envelope with schema-validated result or error. Globals: input, jev.evaluate, program.sleep(ms), program.emit(value), and Fabric tools restricted to exact requires. Use granted pi.bash and tasks.wait/watch for shell orchestration; maxEvaluations:0 disables program inference. No automatic judgments, host imports or secrets.\", inputSchema: jevLaunchSchema as unknown as Record<string, unknown>, risk: \"execute\" },\n { name: \"spawn\", description: \"Launch a session-owned background Jev program. Optional observe requires read approval and subscribes to Main lifecycle events; program.nextEvent waits without polling and shares only explicitly selected bounded context. program.advise needs observe.delivery and requires jev.advise. Use status, wait/join, and stop; not restart-durable.\", inputSchema: jevLaunchSchema as unknown as Record<string, unknown>, risk: \"execute\" },\n { name: \"status\", description: \"Without id: credential configuration status (never retrieves secrets) and run summaries. With id: state, usage, bounded events after sequence, logs, result/error. Retains at most 64 events; nextSequence allows detecting gaps.\", inputSchema: statusSchema as unknown as Record<string, unknown>, risk: \"read\" },\n { name: \"wait\", description: \"Wait for a background Jev program's terminal run envelope. Cancelling the wait does not cancel the program.\", inputSchema: idSchema as unknown as Record<string, unknown>, risk: \"read\" },\n { name: \"join\", description: \"Alias for jev.wait: wait for a background Jev program's terminal run envelope without cancelling the program when the wait is cancelled.\", inputSchema: idSchema as unknown as Record<string, unknown>, risk: \"read\" },\n { name: \"advise\", description: \"Deliver bounded advice from an observing Jev run to Main. Requires its current consumed eventId, explicit observe.delivery, freshness, message budget, and the per-input feedback gate. The program helper program.advise supplies its own id. Subject to agent approvals; returns delivered and an optional suppression reason.\", inputSchema: jevAdviceSchema as unknown as Record<string, unknown>, risk: \"agent\", effect: { kind: \"emission\", resources: [\"main:messages\"], ordering: \"ordered\" } },\n { name: \"stop\", description: \"Cancel a Jev program and await sandbox cleanup. Idempotent for retained terminal runs; already-issued external effects cannot be undone.\", inputSchema: idSchema as unknown as Record<string, unknown>, risk: \"execute\" },\n];\n\nexport class JevProvider implements FabricProvider {\n readonly name = \"jev\";\n readonly description = \"Shell-first TypeScript orchestration with explicit typed Jev decisions\";\n readonly manager: JevProgramManager;\n readonly client: JevClient;\n readonly route: JevRoute;\n constructor(options: JevManagerOptions & { credentialSource?: JevCredentialSource }, client?: JevClient) {\n this.manager = new JevProgramManager(options);\n this.route = resolveJevModelRoute(options.config.jev.model).route;\n this.client = client ?? new JevClient(options.config.jev, undefined,\n new JevCredentials(options.config.jev.credentialCommand, process.env, options.credentialSource, this.route.envKeys), this.route);\n }\n async list(request: FabricProviderListRequest): Promise<FabricActionDescriptor[]> {\n const query = request.query?.toLowerCase();\n return JEV_ACTION_DESCRIPTORS.filter(d => !query || `${d.name} ${d.description}`.toLowerCase().includes(query));\n }\n async describe(name: string): Promise<FabricActionDescriptor | undefined> { return JEV_ACTION_DESCRIPTORS.find(d => d.name === name); }\n async invoke(name: string, args: Record<string, unknown>, context: FabricInvocationContext): Promise<unknown> {\n const descriptor = await this.describe(name);\n if (!descriptor) throw new Error(`Unknown Jev action: ${name}`);\n const invalid = validationMessage(descriptor.inputSchema, args);\n if (invalid) throw new Error(`Invalid jev.${name} arguments: ${invalid}`);\n switch (name) {\n case \"evaluate\": return this.client.evaluate(args as unknown as JevRequest, context.signal ?? new AbortController().signal);\n case \"run\": return this.manager.launch(args as unknown as JevLaunch, context, false);\n case \"spawn\": return this.manager.launch(args as unknown as JevLaunch, context, true);\n case \"status\": return typeof args.id === \"string\" ? this.manager.status(args.id, args.after as number | undefined) : {\n credentials: this.client.credentials.status(), model: this.client.config.model, route: this.route.id, runs: this.manager.list(),\n };\n case \"join\":\n case \"wait\": return this.manager.wait(args.id as string, context.signal);\n case \"advise\": return this.manager.advise(args.id as string, args.eventId as string, args.message as string);\n case \"stop\": return this.manager.stop(args.id as string);\n }\n }\n async close(): Promise<void> { await this.manager.close(); this.client.close(); }\n}\n", "import { randomUUID } from \"node:crypto\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { runAbortable } from \"../async-settlement.js\";\nimport type { ActionRegistry, FabricCapabilityViewLease, FabricCallAudit } from \"../core/action-registry.js\";\nimport { ApprovalController, FabricSessionApprovals } from \"../core/approval-controller.js\";\nimport { FabricAutoApprovalClassifier } from \"../core/auto-approval-classifier.js\";\nimport type { FabricConfig } from \"../config.js\";\nimport type { FabricInvocationContext } from \"../protocol.js\";\nimport type { JevLaunch, JevRunInfo, JevJson, JevResponse } from \"./types.js\";\nimport { checkSchema, checkValue, jsonText, object } from \"./validation.js\";\nimport { checkObserve, type JevObservationHost, type JevSubscription } from \"./observation.js\";\n\ninterface Run {\n info: JevRunInfo;\n controller: AbortController;\n done: Promise<JevRunInfo>;\n observation: JevSubscription | undefined;\n}\nexport interface JevManagerOptions {\n registry: ActionRegistry;\n config: FabricConfig;\n observationHost?: JevObservationHost | undefined;\n authorize?(ref: string, parentToolCallId: string): Promise<void>;\n}\nconst prelude = `const input = JSON.parse(\u03C0.__jevInput);\nconst program = Object.freeze({\n sleep: (ms: number): Promise<unknown> => tools.call({ ref: \"jev.$sleep\", args: { ms } }),\n emit: (value: unknown): Promise<unknown> => tools.call({ ref: \"jev.$emit\", args: { value } }),\n nextEvent: (): Promise<FabricJevHostEvent> => tools.call({ ref: \"jev.$nextEvent\" }) as Promise<FabricJevHostEvent>,\n advise: (args: {eventId: string; message: string}): Promise<FabricJevAdviceResult> => tools.call({ ref: \"jev.advise\", args: {...args, id: \u03C0.__jevRunId} }) as Promise<FabricJevAdviceResult>,\n});\\n`;\n\nexport class JevProgramManager {\n readonly #runs = new Map<string, Run>();\n readonly #approvals = new FabricSessionApprovals();\n #closed = false;\n #starting = 0;\n constructor(readonly options: JevManagerOptions) {}\n list() {\n return [...this.#runs.values()].map(({ info }) => ({\n id: info.id, name: info.name, state: info.state, background: info.background,\n startedAt: info.startedAt, evaluations: info.evaluations, toolCalls: info.toolCalls,\n ...(info.observation ? { observation: structuredClone(info.observation) } : {}),\n }));\n }\n #get(id: string): Run {\n const run = this.#runs.get(id);\n if (!run) throw new Error(\"Unknown or expired Jev run ID\");\n return run;\n }\n status(id: string, after = 0): JevRunInfo {\n const info = this.#get(id).info;\n return structuredClone({ ...info, events: info.events.filter(e => e.sequence > after) });\n }\n async wait(id: string, signal?: AbortSignal): Promise<JevRunInfo> {\n return structuredClone(await runAbortable(signal, () => this.#get(id).done));\n }\n /** Alias for wait. */\n join(id: string, signal?: AbortSignal): Promise<JevRunInfo> {\n return this.wait(id, signal);\n }\n async stop(id: string): Promise<JevRunInfo> {\n const run = this.#get(id);\n if (run.info.state === \"running\") run.controller.abort(new Error(\"Jev run stopped\"));\n return structuredClone(await run.done);\n }\n advise(id: string, eventId: string, message: string) {\n if (typeof message !== \"string\" || !message.trim() || message.length > 2000 || typeof eventId !== \"string\" || eventId.length > 256)\n throw new Error(\"Advice requires a current eventId and 1\u20132000 message characters\");\n const run = this.#get(id);\n if (!run.observation) throw new Error(\"Jev run has no observation subscription\");\n return run.observation.advise(eventId, message);\n }\n async launch(request: JevLaunch, context: FabricInvocationContext, background: boolean): Promise<JevRunInfo> {\n const { config, registry } = this.options;\n if (this.#closed) throw new Error(\"Jev program manager is closed\");\n if (this.#starting + [...this.#runs.values()].filter(r => r.info.state === \"running\").length >= config.jev.maxConcurrentRuns)\n throw new Error(\"Jev concurrent run limit reached\");\n context.signal?.throwIfAborted();\n this.#starting++;\n let lease: FabricCapabilityViewLease | undefined;\n let starting = true;\n try {\n const { program: definition, input, observe } = structuredClone(request);\n const observationHost = this.options.observationHost;\n const observationRevision = observationHost?.revision;\n if (observe !== undefined) {\n checkObserve(observe);\n if (!background) throw new Error(\"Observation requires jev.spawn; foreground runs cannot wait for their own turn to end\");\n if (!observationHost) throw new Error(\"Main lifecycle observation is unavailable in this host\");\n if (context.extensionContext.sessionManager?.getSessionId() !== observationHost.sessionId)\n throw new Error(\"Jev observation is scoped to its owning Main session\");\n }\n checkSchema(definition.inputSchema);\n checkSchema(definition.outputSchema);\n checkValue(definition.inputSchema, input, \"Program input\");\n const requires = [...new Set(definition.requires)];\n for (const ref of requires) {\n if (!/^[a-z][a-z0-9_-]*\\.[a-zA-Z0-9_.$-]+$/.test(ref) || (ref.startsWith(\"jev.\") && ref !== \"jev.evaluate\" && ref !== \"jev.advise\"))\n throw new Error(\"Programs require exact action refs; recursive Jev lifecycle calls are not allowed\");\n if (context.capabilityView && !Object.hasOwn(context.capabilityView.bindings, ref))\n throw new Error(`Jev program cannot widen its caller's capabilities: ${ref}`);\n if (!config.fullCodeMode && (ref.startsWith(\"pi.\") || ref.startsWith(\"extensions.\")))\n throw new Error(\"Full-code tool access is disabled\");\n }\n lease = await registry.acquireCapabilityView(requires, context);\n if (!lease.satisfied || !lease.view) throw new Error(`Missing Jev program capabilities: ${lease.missing.join(\", \")}`);\n if (context.capabilityView) for (const ref of requires) {\n const before = context.capabilityView.bindings[ref]!;\n const after = lease.view.bindings[ref]!;\n if (before.providerBindingId !== after.providerBindingId || before.descriptorHash !== after.descriptorHash)\n throw new Error(\"Caller capability generation changed; relaunch with a fresh commitment\");\n }\n const { TypeScriptKernelRuntime } = await import(\"../runtime/typescript-kernel.js\");\n const runtime = new TypeScriptKernelRuntime(\"quickjs\");\n const sources = await registry.guestTypeSources({ ...context, capabilityView: lease.view });\n const { code, checked } = runtime.prepare(prelude + definition.code, true, [], sources, [], true);\n if (checked.errors.length) throw new Error(`Jev program typecheck failed: ${checked.errors.map(e => e.message).join(\"; \").slice(0, 2000)}`);\n const approval = new ApprovalController(config.approvals, context.extensionContext, this.#approvals, new FabricAutoApprovalClassifier(() => config.jev));\n if (observe) await approval.approve({\n ref: \"jev.spawn\", provider: \"jev\", name: \"spawn\",\n description: \"Observe future Main lifecycle events and explicitly selected content for a bounded Jev program\",\n inputSchema: {}, risk: \"read\",\n }, { observe });\n if (this.#closed) throw new Error(\"Jev program manager is closed\");\n context.signal?.throwIfAborted();\n if (observe && observationHost!.revision !== observationRevision)\n throw new Error(\"Main lifecycle changed while preparing the observer; relaunch explicitly with current context\");\n const limits = definition.limits ?? {};\n const bounded = (value: number | undefined, fallback: number, ceiling: number) => Math.min(value ?? fallback, ceiling);\n const timeoutMs = bounded(limits.timeoutMs, 60_000, config.jev.maxDurationMs);\n const maxEvaluations = bounded(limits.maxEvaluations, 100, config.jev.maxEvaluations);\n const maxToolCalls = bounded(limits.maxToolCalls, 1000, config.jev.maxToolCalls);\n const maxTokens = bounded(limits.maxTokens, 100_000, config.jev.maxTokens);\n const id = randomUUID();\n const controller = new AbortController();\n const info: JevRunInfo = {\n id, name: definition.name, state: \"running\", background, startedAt: Date.now(),\n evaluations: 0, toolCalls: 0, usage: { input_tokens: 0, output_tokens: 0 },\n events: [], nextSequence: 1, logs: [],\n };\n let budgetFailure: string | undefined;\n const failBudget = (message: string): never => {\n budgetFailure = message;\n queueMicrotask(() => controller.abort(new Error(message)));\n throw new Error(message);\n };\n const observation = observe ? observationHost!.subscribe(observe, { id, name: definition.name }, controller) : undefined;\n if (observation) info.observation = observation.stats;\n const runLease = lease;\n lease = undefined;\n const abort = () => controller.abort(new Error(\"Foreground caller cancelled\"));\n if (!background) context.signal?.addEventListener(\"abort\", abort, { once: true });\n let timedOut = false;\n const timer = setTimeout(() => { timedOut = true; controller.abort(new Error(\"Jev deadline exceeded\")); }, timeoutMs);\n let evaluating = false;\n const audits: FabricCallAudit[] = [];\n const emit = (value: unknown) => {\n jsonText(value, 4096, \"Program event\");\n info.events.push({ sequence: info.nextSequence++, at: Date.now(), value: value as JevJson });\n if (info.events.length > 64) info.events.shift();\n };\n const run: Run = { info, controller, observation, done: undefined! };\n this.#runs.set(id, run);\n this.#starting--;\n starting = false;\n this.#prune();\n // Yield before execution so spawn returns without running a controller tick inline.\n run.done = (async () => {\n try {\n await delay(0, undefined, { signal: controller.signal });\n const result = await runtime.execute(code, async (rawRef, rawArgs, signal) => {\n signal.throwIfAborted();\n controller.signal.throwIfAborted();\n if (budgetFailure) throw new Error(budgetFailure);\n if (++info.toolCalls > maxToolCalls) return failBudget(\"Jev tool-call budget exhausted\");\n const ref = rawRef === \"fabric.$call\" ? rawArgs.ref : rawRef;\n const args = rawRef === \"fabric.$call\" ? rawArgs.args ?? {} : rawArgs;\n if (typeof ref !== \"string\" || !object(args)) throw new Error(\"Invalid Jev program tool call\");\n if (ref === \"jev.$sleep\") {\n if (typeof args.ms !== \"number\" || !Number.isFinite(args.ms) || args.ms < 0 || args.ms > timeoutMs) throw new Error(\"Invalid program.sleep duration\");\n await delay(args.ms, undefined, { signal });\n return null;\n }\n if (ref === \"jev.$emit\") { emit(args.value); return null; }\n if (ref === \"jev.$nextEvent\") {\n if (!observation) throw new Error(\"program.nextEvent requires observe on jev.spawn\");\n return observation.next();\n }\n if (ref === \"jev.advise\" && args.id !== id) throw new Error(\"A Jev program can only advise through its own run\");\n if (!Object.hasOwn(runLease.view!.bindings, ref)) throw new Error(`Capability not granted to Jev program: ${ref}`);\n if (ref === \"jev.evaluate\") {\n if (evaluating) throw new Error(\"One Jev evaluation may be in flight per program; batch independent questions in one request\");\n if (info.evaluations >= maxEvaluations || info.usage.input_tokens + info.usage.output_tokens >= maxTokens)\n return failBudget(\"Jev inference budget exhausted\");\n info.evaluations++;\n evaluating = true;\n }\n try {\n const value = await registry.invoke(ref, args, {\n cwd: context.cwd, extensionContext: context.extensionContext, signal, capabilityView: runLease.view!,\n ...(context.effectPolicy ? { effectPolicy: context.effectPolicy } : {}),\n parentToolCallId: `jev:${id}`, nestedToolCallId: `jev:${id}:${info.toolCalls}`,\n update() {}, activity() {}, attachMedia() {}, attachPreview() {},\n authorize: async action => { await this.options.authorize?.(action.ref, `jev:${id}`); },\n approve: async (action, prepared) => {\n if (action.ref === \"schema.commit\") {\n await approval.approve({ ...action, risk: \"write\" }, prepared);\n await approval.approve({ ...action, risk: \"execute\" }, prepared);\n } else await approval.approve(action, prepared);\n },\n audits, maxResultChars: ref === \"jev.evaluate\" ? 1_048_576 : config.executor.maxNestedResultChars,\n });\n if (ref === \"jev.evaluate\") {\n const response = value as JevResponse;\n info.usage.input_tokens += response.usage.input_tokens;\n info.usage.output_tokens += response.usage.output_tokens;\n if (info.usage.input_tokens + info.usage.output_tokens > maxTokens)\n return failBudget(\"Jev reported-token budget exhausted\");\n }\n return value;\n } finally {\n if (ref === \"jev.evaluate\") evaluating = false;\n // Keep audit retention bounded even in a long-lived loop.\n if (audits.length > 64) audits.splice(0, audits.length - 64);\n }\n }, {\n timeoutMs, memoryLimitBytes: Math.min(config.executor.memoryLimitBytes, 64 * 1024 * 1024),\n maxCpuSliceMs: 100, maxPendingTimers: 128, maxLogChars: 4096, strings: { __jevInput: JSON.stringify(input), __jevRunId: id }, signal: controller.signal,\n });\n info.logs = result.logs;\n if (budgetFailure) { info.state = \"failed\"; info.error = budgetFailure; }\n else if (timedOut || result.terminationReason === \"timed_out\") { info.state = \"timed_out\"; info.error = result.error ?? \"Jev deadline exceeded\"; }\n else if (controller.signal.aborted || result.terminationReason === \"aborted\") { info.state = \"cancelled\"; }\n else if (result.terminationReason !== \"completed\") { info.state = \"failed\"; info.error = result.error ?? \"Jev program failed\"; }\n else {\n checkValue(definition.outputSchema, result.value, \"Program output\");\n info.result = result.value;\n info.state = \"completed\";\n }\n } catch (error) {\n info.state = budgetFailure ? \"failed\" : timedOut ? \"timed_out\" : controller.signal.aborted ? \"cancelled\" : \"failed\";\n info.error = (budgetFailure ?? (error instanceof Error ? error.message : \"Jev program failed\")).slice(0, 2000);\n } finally {\n clearTimeout(timer);\n observation?.close();\n context.signal?.removeEventListener(\"abort\", abort);\n await runLease.release();\n info.endedAt = Date.now();\n this.#prune();\n }\n return info;\n })();\n return background ? this.status(id) : structuredClone(await run.done);\n } finally {\n if (starting) this.#starting--;\n await lease?.release();\n }\n }\n #prune(): void {\n for (const [id, run] of this.#runs) {\n if (this.#runs.size <= this.options.config.jev.maxRetainedRuns) break;\n if (run.info.state !== \"running\") this.#runs.delete(id);\n }\n }\n stopAll(): void {\n for (const run of this.#runs.values()) if (run.info.state === \"running\") run.controller.abort(new Error(\"Jev provider closed\"));\n }\n async close(): Promise<void> {\n this.#closed = true;\n // Terminal runs are already out of QuickJS and may be releasing the last\n // provider lease right now. Waiting for those here would self-deadlock.\n const running = [...this.#runs.values()].filter(r => r.info.state === \"running\");\n this.stopAll();\n await Promise.all(running.map(r => r.done));\n this.#runs.clear();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;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abricShellJobEvent) => void): () => void;
113
113
  constructor(tempRoot?: string);
114
114
  begin(tool: PiShellToolName, command: string, options?: FabricShellJobOptions): FabricShellJob;
115
+ /** Event-driven, bounded observation. Timeout/cancellation never stops the job. */
116
+ waitFor(id: string, options: {
117
+ after?: number;
118
+ timeoutMs: number;
119
+ signal?: AbortSignal | undefined;
120
+ }): Promise<{
121
+ task: FabricShellJobInfo;
122
+ timedOut: boolean;
123
+ }>;
115
124
  stop(id: string): boolean;
116
125
  acknowledge(id: string): void;
117
126
  get(id: string): FabricShellJob | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"shell-jobs.d.ts","sourceRoot":"","sources":["../../src/core/shell-jobs.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAgB,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEpG,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,eAAO,MAAM,gBAAgB,QAAc,CAAC;AAC5C,eAAO,MAAM,eAAe,QAAkB,CAAC;AAC/C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAW3C,eAAO,MAAM,sBAAsB,GACjC,SAAS,MAAM,EACf,SAAS,MAAM,EACf,MAAM,eAAe,KACpB,MAIiH,CAAC;AAErH,eAAO,MAAM,qBAAqB,GAAI,OAAO;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,KAAG,MAIH,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,KAAG,MAC3B,CAAC;AAE7C,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,SAGrD,C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  #listeners = /* @__PURE__ */ new Set();
648
648
  #closed = false;
649
+ #closing = new AbortController();
649
650
  subscribe(listener) {
650
651
  this.#listeners.add(listener);
651
652
  return () => {
@@ -662,7 +663,7 @@ var FabricShellJobStore = class {
662
663
  }
663
664
  }
664
665
  #prune() {
665
- const completed = [...this.#jobs.values()].filter((job) => job.finished);
666
+ const completed = [...this.#jobs.values()].filter((job) => job.finishedAt !== void 0);
666
667
  completed.sort((a, b) => (a.finishedAt ?? 0) - (b.finishedAt ?? 0));
667
668
  for (const [index, job] of completed.entries()) {
668
669
  if (index < completed.length - SHELL_COMPLETED_HANDLES || Date.now() - (job.finishedAt ?? 0) >= SHELL_COMPLETED_MAX_AGE_MS) this.#jobs.delete(job.id);
@@ -679,6 +680,50 @@ var FabricShellJobStore = class {
679
680
  this.#emit({ type: "started", job: job.info() });
680
681
  return job;
681
682
  }
683
+ /** Event-driven, bounded observation. Timeout/cancellation never stops the job. */
684
+ waitFor(id, options) {
685
+ options.signal?.throwIfAborted();
686
+ this.#closing.signal.throwIfAborted();
687
+ const job = this.get(id);
688
+ if (!job) throw new Error(`Unknown shell task: ${id}`);
689
+ if (!Number.isInteger(options.timeoutMs) || options.timeoutMs < 1 || options.timeoutMs > 3e5)
690
+ throw new Error("Task observation timeoutMs must be an integer from 1 to 300000");
691
+ if (options.after !== void 0 && (!Number.isSafeInteger(options.after) || options.after < 0 || options.after > job.eventCount))
692
+ throw new Error("Task observation after must be an existing event cursor");
693
+ return new Promise((resolve2, reject) => {
694
+ let timer;
695
+ let unsubscribe = () => {
696
+ };
697
+ const cleanup = () => {
698
+ if (timer) clearTimeout(timer);
699
+ unsubscribe();
700
+ options.signal?.removeEventListener("abort", abort);
701
+ this.#closing.signal.removeEventListener("abort", closing);
702
+ };
703
+ const abort = () => {
704
+ cleanup();
705
+ reject(options.signal?.reason ?? new Error("Task observation cancelled"));
706
+ };
707
+ const closing = () => {
708
+ cleanup();
709
+ reject(new Error("Shell job store is closed"));
710
+ };
711
+ const complete = (timedOut) => {
712
+ cleanup();
713
+ resolve2({ task: job.info(), timedOut });
714
+ };
715
+ const check = () => {
716
+ if (job.info().finishedAt !== void 0 || options.after !== void 0 && job.eventCount > options.after) complete(false);
717
+ };
718
+ unsubscribe = this.subscribe((event) => {
719
+ if (event.job.id === id) check();
720
+ });
721
+ options.signal?.addEventListener("abort", abort, { once: true });
722
+ this.#closing.signal.addEventListener("abort", closing, { once: true });
723
+ timer = setTimeout(() => complete(true), options.timeoutMs);
724
+ check();
725
+ });
726
+ }
682
727
  stop(id) {
683
728
  const job = this.get(id);
684
729
  if (!job) throw new Error(`Unknown shell task: ${id}`);
@@ -715,6 +760,7 @@ var FabricShellJobStore = class {
715
760
  }
716
761
  async close() {
717
762
  this.#closed = true;
763
+ this.#closing.abort(new Error("Shell job store is closed"));
718
764
  this.#listeners.clear();
719
765
  const live = this.live();
720
766
  for (const job of live) {
@@ -8723,7 +8769,7 @@ var closedPiInputSchema = (name, source) => {
8723
8769
  properties.monitor = shellMonitorSchema;
8724
8770
  properties.background = {
8725
8771
  type: "boolean",
8726
- description: "Detach immediately: returns ok:true with taskId, pid and a bounded live log. Completion notifies the owning agent. Inspect/stop with tools.call tasks.get/tasks.stop. monitor also detaches, requires explicit ui/wake delivery and has a finite deadline. Do not poll."
8772
+ description: "Detach immediately: returns ok:true with taskId, pid and a bounded live log. Completion notifies the owning agent. Inspect/stop with tools.call tasks.get/tasks.stop; bounded controllers can await tasks.wait/tasks.watch without polling. monitor also detaches, requires explicit ui/wake delivery and has a finite deadline. Do not poll."
8727
8773
  };
8728
8774
  }
8729
8775
  if (name === "edit") {
@@ -9336,9 +9382,19 @@ var PiToolsProvider = class {
9336
9382
 
9337
9383
  // src/providers/tasks-provider.ts
9338
9384
  var idSchema = { type: "object", properties: { id: { type: "string", minLength: 1 } }, required: ["id"], additionalProperties: false };
9385
+ var waitSchema = { ...idSchema, properties: {
9386
+ ...idSchema.properties,
9387
+ timeoutMs: { type: "integer", minimum: 1, maximum: 3e5, description: "Observation ceiling in milliseconds, not a delay or process deadline. Timeout never cancels the task." }
9388
+ } };
9389
+ var watchSchema = { ...waitSchema, properties: {
9390
+ ...waitSchema.properties,
9391
+ after: { type: "integer", minimum: 0, maximum: Number.MAX_SAFE_INTEGER, description: "Previously returned nextCursor; default 0. Missing retained events are disclosed as omitted." }
9392
+ } };
9339
9393
  var descriptors5 = [
9340
9394
  { name: "list", description: "List this session's tracked shell tasks and monitors, with IDs, command, cwd, state, timestamps, and bounded monitor events. No output polling is needed: detached completions notify the owning agent.", inputSchema: { type: "object", properties: {}, additionalProperties: false }, risk: "read", effect: { kind: "none", ordering: "commutative" } },
9341
9395
  { name: "get", description: "Inspect one shell task by ID, returning metadata and a bounded output tail. Acknowledges its pending notification after a successful read. Full retained output is at logPath (bounded, not an archive).", inputSchema: idSchema, risk: "read", effect: { kind: "emission", ordering: "ordered" } },
9396
+ { name: "wait", description: "Wait without polling for a session-owned shell task to finish, default 30 seconds. Returns task metadata, a bounded output tail and timedOut. Inspect status and exitCode; an exited task is not goal verification. Timeout or cancellation stops only this wait.", inputSchema: waitSchema, risk: "read", effect: { kind: "emission", ordering: "ordered" } },
9397
+ { name: "watch", description: "Wait without polling for the next bounded monitor batch, task exit, or timeout (default 5 seconds). Start pi.bash with monitor.delivery ui and an optional literal monitor.match first. Returns reason, lines, omitted, nextCursor and task metadata; pass nextCursor as after. No inference, wakeup, renewal or cancellation of the task. Previews are not a lossless RPC stream.", inputSchema: watchSchema, risk: "read", effect: { kind: "none", ordering: "commutative" } },
9342
9398
  { name: "stop", description: "Stop one session-owned shell task or monitor by ID using its existing abort controller, not an arbitrary PID. Cancellation does not wake the owning agent.", inputSchema: idSchema, risk: "execute", effect: { kind: "emission", ordering: "ordered" } }
9343
9399
  ];
9344
9400
  var TasksProvider = class {
@@ -9346,7 +9402,7 @@ var TasksProvider = class {
9346
9402
  this.jobs = jobs;
9347
9403
  }
9348
9404
  name = "tasks";
9349
- description = "Session-owned background shell tasks and opt-in monitors";
9405
+ description = "Session-owned shell orchestration with bounded wait/watch and explicit stop";
9350
9406
  async list(request) {
9351
9407
  const query = request.query?.toLowerCase();
9352
9408
  return query ? descriptors5.filter((d) => `${d.name} ${d.description}`.toLowerCase().includes(query)) : descriptors5;
@@ -9354,18 +9410,37 @@ var TasksProvider = class {
9354
9410
  async describe(name) {
9355
9411
  return descriptors5.find((d) => d.name === name);
9356
9412
  }
9357
- async invoke(name, args, _context) {
9413
+ async invoke(name, args, context) {
9414
+ const descriptor = await this.describe(name);
9415
+ if (!descriptor) throw new Error(`Unknown tasks action: ${name}`);
9416
+ const invalid = validationMessage(descriptor.inputSchema, args);
9417
+ if (invalid) throw new Error(`Invalid tasks.${name} arguments: ${invalid}`);
9358
9418
  if (name === "list") return this.jobs.list();
9359
- if (name !== "get" && name !== "stop") throw new Error(`Unknown tasks action: ${name}`);
9360
- if (typeof args.id !== "string") throw new Error("tasks requires an id");
9361
- const job = this.jobs.get(args.id);
9362
- if (!job) throw new Error(`Unknown shell task: ${args.id}`);
9363
- if (name === "stop") return { stopped: this.jobs.stop(args.id), task: job.info() };
9419
+ const id = args.id;
9420
+ const job = this.jobs.get(id);
9421
+ if (!job) throw new Error(`Unknown shell task: ${id}`);
9422
+ if (name === "stop") return { stopped: this.jobs.stop(id), task: job.info() };
9423
+ if (name === "watch") {
9424
+ if (!job.options.monitor) throw new Error("tasks.watch requires a task started with monitor; use tasks.wait for ordinary tasks");
9425
+ const after2 = args.after ?? 0;
9426
+ const { task, timedOut } = await this.jobs.waitFor(id, { after: after2, timeoutMs: args.timeoutMs ?? 5e3, signal: context.signal });
9427
+ const count = task.eventCount - after2;
9428
+ const retained = task.lastEvent?.lines ?? [];
9429
+ const lines = count > 0 ? retained.slice(-Math.min(count, retained.length)) : [];
9430
+ return {
9431
+ task,
9432
+ reason: count > 0 ? "event" : timedOut ? "timeout" : "finished",
9433
+ lines,
9434
+ omitted: Math.max(0, count - lines.length),
9435
+ nextCursor: task.eventCount
9436
+ };
9437
+ }
9438
+ const waited = name === "wait" ? await this.jobs.waitFor(id, { timeoutMs: args.timeoutMs ?? 3e4, signal: context.signal }) : void 0;
9364
9439
  const before = job.info();
9365
9440
  const output = await job.outputText();
9366
9441
  const after = job.info();
9367
- if (before.eventCount === after.eventCount && before.finishedAt === after.finishedAt) this.jobs.acknowledge(args.id);
9368
- return { task: job.info(), output };
9442
+ if (!waited?.timedOut && before.eventCount === after.eventCount && before.finishedAt === after.finishedAt) this.jobs.acknowledge(id);
9443
+ return { task: job.info(), output, ...waited ? { timedOut: waited.timedOut } : {} };
9369
9444
  }
9370
9445
  };
9371
9446
 
@@ -13424,13 +13499,13 @@ ${escapeXmlText(text)}
13424
13499
  const { JevObservationHost } = await import("./jev/observation.js");
13425
13500
  await builtins.install(createProviderComponent({
13426
13501
  provider: "jev",
13427
- description: "TypeSafe System One judgments and reactive programs",
13502
+ description: "Shell orchestration and explicit typed Jev decisions",
13428
13503
  create: (component) => {
13429
13504
  component.guide({
13430
13505
  label: "jev-programs",
13431
13506
  models: ["*/*"],
13432
13507
  targets: ["main", "participant"],
13433
- content: "Jev supplies typed Choice, Noul, and Score judgments, not generated text. Use jev.evaluate for batched questions; jev.run/spawn for isolated TypeScript programs that may loop using input, program.sleep, program.emit, and exact requires capabilities. run/wait return terminal envelopes (join aliases wait for both agents and Jev); inspect state and result/error. Background programs are session-owned; jev.status and jev.stop inspect/cancel them. For Main-turn advisors, spawn with observe, await program.nextEvent without polling, and opt into bounded context fields. program.advise requires jev.advise and explicit delivery; default is record-only. Return the observer ID without waiting in Main; Escape/Main abort cancels observers. Use /login jev, TYPESAFE_API_KEY, /login openrouter, OPENROUTER_API_KEY, /login vercel-ai-gateway, AI_GATEWAY_API_KEY, or a trusted credentialCommand. Credentials stay host-side; status never retrieves a key. See docs/jev.md for schemas, budgets, and browser integration."
13508
+ content: "Jev supplies typed Choice, Noul, and Score judgments, not generated text. Prefer shell-first orchestration: granted pi.bash runs existing CLIs; tasks.wait/watch await bounded receipts/monitor batches without polling or inference. Use UI-only monitors to avoid Main wakeups. Browser/macOS tools need no Fabric bridge. Code owns commands; never execute a model answer as shell source. Omit jev.evaluate and set maxEvaluations:0 for deterministic programs (host auto approvals remain independent). Use jev.evaluate only for explicit authorized batched questions; jev.run/spawn for isolated TypeScript programs that may loop using input, program.sleep, program.emit, and exact requires capabilities. run/wait return terminal envelopes (join aliases wait for both agents and Jev); inspect state and result/error. Programs and detached tasks are session-owned, not restart-durable. jev.status/stop control programs; tasks.stop separately stops their detached tasks. Observation timeout/cancellation never cancels the task; keep task IDs and finite process deadlines. For Main-turn advisors, spawn with observe, await program.nextEvent without polling, and opt into bounded context fields. program.advise requires jev.advise and explicit delivery; default is record-only. Return the observer ID without waiting in Main; Escape/Main abort cancels observers. Use /login jev, TYPESAFE_API_KEY, /login openrouter, OPENROUTER_API_KEY, /login vercel-ai-gateway, AI_GATEWAY_API_KEY, or a trusted credentialCommand. Credentials stay host-side; status never retrieves a key. See docs/jev.md for schemas, budgets, and shell/CLI composition."
13434
13509
  });
13435
13510
  const observationHost = identity.kind === "main" ? new JevObservationHost(context.sessionManager.getSessionId(), (advice) => {
13436
13511
  this.pi.sendMessage({