omp-fabric 0.85.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/LICENSE +21 -0
- package/README.md +170 -0
- package/THIRD_PARTY_NOTICES.md +33 -0
- package/dist/activity/store.d.ts +32 -0
- package/dist/activity/store.d.ts.map +1 -0
- package/dist/activity/types.d.ts +104 -0
- package/dist/activity/types.d.ts.map +1 -0
- package/dist/actors/binding-store.d.ts +17 -0
- package/dist/actors/binding-store.d.ts.map +1 -0
- package/dist/actors/context.d.ts +13 -0
- package/dist/actors/context.d.ts.map +1 -0
- package/dist/actors/delivery-policy.d.ts +8 -0
- package/dist/actors/delivery-policy.d.ts.map +1 -0
- package/dist/actors/directory.d.ts +47 -0
- package/dist/actors/directory.d.ts.map +1 -0
- package/dist/actors/global-registry.d.ts +47 -0
- package/dist/actors/global-registry.d.ts.map +1 -0
- package/dist/actors/host-event-observer.d.ts +5 -0
- package/dist/actors/host-event-observer.d.ts.map +1 -0
- package/dist/actors/host-event-payload.d.ts +14 -0
- package/dist/actors/host-event-payload.d.ts.map +1 -0
- package/dist/actors/manager.d.ts +175 -0
- package/dist/actors/manager.d.ts.map +1 -0
- package/dist/actors/predicate.d.ts +7 -0
- package/dist/actors/predicate.d.ts.map +1 -0
- package/dist/actors/types.d.ts +211 -0
- package/dist/actors/types.d.ts.map +1 -0
- package/dist/agents/bash-worktree-add.d.ts +24 -0
- package/dist/agents/bash-worktree-add.d.ts.map +1 -0
- package/dist/agents/budget-ledger.d.ts +88 -0
- package/dist/agents/budget-ledger.d.ts.map +1 -0
- package/dist/agents/claude-cli.d.ts +32 -0
- package/dist/agents/claude-cli.d.ts.map +1 -0
- package/dist/agents/claude-cli.js +17 -0
- package/dist/agents/claude-cli.js.map +7 -0
- package/dist/agents/clone-first-worktree.d.ts +17 -0
- package/dist/agents/clone-first-worktree.d.ts.map +1 -0
- package/dist/agents/compact-control.d.ts +32 -0
- package/dist/agents/compact-control.d.ts.map +1 -0
- package/dist/agents/compact-control.js +127 -0
- package/dist/agents/compact-control.js.map +7 -0
- package/dist/agents/constants.d.ts +5 -0
- package/dist/agents/constants.d.ts.map +1 -0
- package/dist/agents/cow-clone.d.ts +8 -0
- package/dist/agents/cow-clone.d.ts.map +1 -0
- package/dist/agents/handoff.d.ts +19 -0
- package/dist/agents/handoff.d.ts.map +1 -0
- package/dist/agents/manager.d.ts +68 -0
- package/dist/agents/manager.d.ts.map +1 -0
- package/dist/agents/omp-binary.d.ts +7 -0
- package/dist/agents/omp-binary.d.ts.map +1 -0
- package/dist/agents/rm.d.ts +15 -0
- package/dist/agents/rm.d.ts.map +1 -0
- package/dist/agents/semaphore.d.ts +7 -0
- package/dist/agents/semaphore.d.ts.map +1 -0
- package/dist/agents/session-export.d.ts +9 -0
- package/dist/agents/session-export.d.ts.map +1 -0
- package/dist/agents/thinking-transfer.d.ts +39 -0
- package/dist/agents/thinking-transfer.d.ts.map +1 -0
- package/dist/agents/transports/herdr-transport.d.ts +10 -0
- package/dist/agents/transports/herdr-transport.d.ts.map +1 -0
- package/dist/agents/transports/localterm-transport.d.ts +7 -0
- package/dist/agents/transports/localterm-transport.d.ts.map +1 -0
- package/dist/agents/transports/process-transport.d.ts +7 -0
- package/dist/agents/transports/process-transport.d.ts.map +1 -0
- package/dist/agents/transports/process-utils.d.ts +29 -0
- package/dist/agents/transports/process-utils.d.ts.map +1 -0
- package/dist/agents/transports/screen-transport.d.ts +7 -0
- package/dist/agents/transports/screen-transport.d.ts.map +1 -0
- package/dist/agents/transports/tmux-transport.d.ts +7 -0
- package/dist/agents/transports/tmux-transport.d.ts.map +1 -0
- package/dist/agents/types.d.ts +251 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/veda-cli.d.ts +22 -0
- package/dist/agents/veda-cli.d.ts.map +1 -0
- package/dist/agents/veda-cli.js +13 -0
- package/dist/agents/veda-cli.js.map +7 -0
- package/dist/agents/worktree-manager.d.ts +14 -0
- package/dist/agents/worktree-manager.d.ts.map +1 -0
- package/dist/agents/worktree-paths.d.ts +5 -0
- package/dist/agents/worktree-paths.d.ts.map +1 -0
- package/dist/async-settlement.d.ts +4 -0
- package/dist/async-settlement.d.ts.map +1 -0
- package/dist/audit/details.d.ts +82 -0
- package/dist/audit/details.d.ts.map +1 -0
- package/dist/audit/index.d.ts +4 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/projection.d.ts +20 -0
- package/dist/audit/projection.d.ts.map +1 -0
- package/dist/audit/trace.d.ts +95 -0
- package/dist/audit/trace.d.ts.map +1 -0
- package/dist/capture/catalog.d.ts +29 -0
- package/dist/capture/catalog.d.ts.map +1 -0
- package/dist/capture/interceptor.d.ts +21 -0
- package/dist/capture/interceptor.d.ts.map +1 -0
- package/dist/capture/wrapper.d.ts +15 -0
- package/dist/capture/wrapper.d.ts.map +1 -0
- package/dist/chunks/chunk-2GQC324T.js +5001 -0
- package/dist/chunks/chunk-2GQC324T.js.map +7 -0
- package/dist/chunks/chunk-2KEWFW56.js +1229 -0
- package/dist/chunks/chunk-2KEWFW56.js.map +7 -0
- package/dist/chunks/chunk-3J7BKUNG.js +354 -0
- package/dist/chunks/chunk-3J7BKUNG.js.map +7 -0
- package/dist/chunks/chunk-4A4MVZQW.js +253 -0
- package/dist/chunks/chunk-4A4MVZQW.js.map +7 -0
- package/dist/chunks/chunk-4HQDSTHN.js +221 -0
- package/dist/chunks/chunk-4HQDSTHN.js.map +7 -0
- package/dist/chunks/chunk-4LEDA76O.js +688 -0
- package/dist/chunks/chunk-4LEDA76O.js.map +7 -0
- package/dist/chunks/chunk-5GTPD4BA.js +1318 -0
- package/dist/chunks/chunk-5GTPD4BA.js.map +7 -0
- package/dist/chunks/chunk-5IWFSDU5.js +87 -0
- package/dist/chunks/chunk-5IWFSDU5.js.map +7 -0
- package/dist/chunks/chunk-6N4XGAZY.js +21 -0
- package/dist/chunks/chunk-6N4XGAZY.js.map +7 -0
- package/dist/chunks/chunk-6QBPSZJ5.js +647 -0
- package/dist/chunks/chunk-6QBPSZJ5.js.map +7 -0
- package/dist/chunks/chunk-6X6WUU2K.js +73 -0
- package/dist/chunks/chunk-6X6WUU2K.js.map +7 -0
- package/dist/chunks/chunk-7363CD5A.js +38 -0
- package/dist/chunks/chunk-7363CD5A.js.map +7 -0
- package/dist/chunks/chunk-77FQHHZD.js +231 -0
- package/dist/chunks/chunk-77FQHHZD.js.map +7 -0
- package/dist/chunks/chunk-7BIA5BJN.js +112 -0
- package/dist/chunks/chunk-7BIA5BJN.js.map +7 -0
- package/dist/chunks/chunk-7BOAOKWH.js +64 -0
- package/dist/chunks/chunk-7BOAOKWH.js.map +7 -0
- package/dist/chunks/chunk-7TB7NXSL.js +58 -0
- package/dist/chunks/chunk-7TB7NXSL.js.map +7 -0
- package/dist/chunks/chunk-7VIQNUPS.js +17 -0
- package/dist/chunks/chunk-7VIQNUPS.js.map +7 -0
- package/dist/chunks/chunk-CT2AJ2UI.js +225 -0
- package/dist/chunks/chunk-CT2AJ2UI.js.map +7 -0
- package/dist/chunks/chunk-DLXPTBPL.js +151 -0
- package/dist/chunks/chunk-DLXPTBPL.js.map +7 -0
- package/dist/chunks/chunk-ED3BRM6P.js +17 -0
- package/dist/chunks/chunk-ED3BRM6P.js.map +7 -0
- package/dist/chunks/chunk-G2IBGGBM.js +42 -0
- package/dist/chunks/chunk-G2IBGGBM.js.map +7 -0
- package/dist/chunks/chunk-GKOFZ76R.js +1596 -0
- package/dist/chunks/chunk-GKOFZ76R.js.map +7 -0
- package/dist/chunks/chunk-HDJBUXDX.js +1102 -0
- package/dist/chunks/chunk-HDJBUXDX.js.map +7 -0
- package/dist/chunks/chunk-IGVDD2HT.js +10 -0
- package/dist/chunks/chunk-IGVDD2HT.js.map +7 -0
- package/dist/chunks/chunk-JHKOG5GS.js +187 -0
- package/dist/chunks/chunk-JHKOG5GS.js.map +7 -0
- package/dist/chunks/chunk-JP4LIZFT.js +1334 -0
- package/dist/chunks/chunk-JP4LIZFT.js.map +7 -0
- package/dist/chunks/chunk-JSBTB3P6.js +127 -0
- package/dist/chunks/chunk-JSBTB3P6.js.map +7 -0
- package/dist/chunks/chunk-KAD7UWT2.js +99 -0
- package/dist/chunks/chunk-KAD7UWT2.js.map +7 -0
- package/dist/chunks/chunk-KIH3KLZU.js +95 -0
- package/dist/chunks/chunk-KIH3KLZU.js.map +7 -0
- package/dist/chunks/chunk-KIREBD2V.js +2208 -0
- package/dist/chunks/chunk-KIREBD2V.js.map +7 -0
- package/dist/chunks/chunk-LMAVZN7J.js +8 -0
- package/dist/chunks/chunk-LMAVZN7J.js.map +7 -0
- package/dist/chunks/chunk-NCPJZXLM.js +57 -0
- package/dist/chunks/chunk-NCPJZXLM.js.map +7 -0
- package/dist/chunks/chunk-OJZNMROB.js +195 -0
- package/dist/chunks/chunk-OJZNMROB.js.map +7 -0
- package/dist/chunks/chunk-OPTP4PSE.js +469 -0
- package/dist/chunks/chunk-OPTP4PSE.js.map +7 -0
- package/dist/chunks/chunk-QPXSCMTG.js +24 -0
- package/dist/chunks/chunk-QPXSCMTG.js.map +7 -0
- package/dist/chunks/chunk-ROKMBLGN.js +1265 -0
- package/dist/chunks/chunk-ROKMBLGN.js.map +7 -0
- package/dist/chunks/chunk-SXMWV447.js +2445 -0
- package/dist/chunks/chunk-SXMWV447.js.map +7 -0
- package/dist/chunks/chunk-T5ZA5YRU.js +786 -0
- package/dist/chunks/chunk-T5ZA5YRU.js.map +7 -0
- package/dist/chunks/chunk-T6OAX4FO.js +1835 -0
- package/dist/chunks/chunk-T6OAX4FO.js.map +7 -0
- package/dist/chunks/chunk-U5FYOMG5.js +119 -0
- package/dist/chunks/chunk-U5FYOMG5.js.map +7 -0
- package/dist/chunks/chunk-UOSJZXJV.js +142 -0
- package/dist/chunks/chunk-UOSJZXJV.js.map +7 -0
- package/dist/chunks/chunk-UPCARIJP.js +6627 -0
- package/dist/chunks/chunk-UPCARIJP.js.map +7 -0
- package/dist/chunks/chunk-VPPIJRNZ.js +50 -0
- package/dist/chunks/chunk-VPPIJRNZ.js.map +7 -0
- package/dist/chunks/chunk-XU5Z4JCQ.js +297 -0
- package/dist/chunks/chunk-XU5Z4JCQ.js.map +7 -0
- package/dist/chunks/chunk-YWEXP724.js +427 -0
- package/dist/chunks/chunk-YWEXP724.js.map +7 -0
- package/dist/chunks/chunk-YZZIKJX6.js +60 -0
- package/dist/chunks/chunk-YZZIKJX6.js.map +7 -0
- package/dist/chunks/chunk-ZNAJDPT7.js +2203 -0
- package/dist/chunks/chunk-ZNAJDPT7.js.map +7 -0
- package/dist/chunks/chunk-ZTM45GH5.js +163 -0
- package/dist/chunks/chunk-ZTM45GH5.js.map +7 -0
- package/dist/commands/fabric.d.ts +17 -0
- package/dist/commands/fabric.d.ts.map +1 -0
- package/dist/compaction/bounds.d.ts +23 -0
- package/dist/compaction/bounds.d.ts.map +1 -0
- package/dist/compaction/branch-details.d.ts +83 -0
- package/dist/compaction/branch-details.d.ts.map +1 -0
- package/dist/compaction/branch-summary.d.ts +9 -0
- package/dist/compaction/branch-summary.d.ts.map +1 -0
- package/dist/compaction/enrichers.d.ts +10 -0
- package/dist/compaction/enrichers.d.ts.map +1 -0
- package/dist/compaction/hook.d.ts +98 -0
- package/dist/compaction/hook.d.ts.map +1 -0
- package/dist/compaction/hook.js +19 -0
- package/dist/compaction/hook.js.map +7 -0
- package/dist/compaction/instructions.d.ts +38 -0
- package/dist/compaction/instructions.d.ts.map +1 -0
- package/dist/compaction/normalize.d.ts +83 -0
- package/dist/compaction/normalize.d.ts.map +1 -0
- package/dist/compaction/projections.d.ts +31 -0
- package/dist/compaction/projections.d.ts.map +1 -0
- package/dist/compaction/qa.d.ts +27 -0
- package/dist/compaction/qa.d.ts.map +1 -0
- package/dist/compaction/render.d.ts +10 -0
- package/dist/compaction/render.d.ts.map +1 -0
- package/dist/compaction/threshold.d.ts +5 -0
- package/dist/compaction/threshold.d.ts.map +1 -0
- package/dist/compaction/trace-events.d.ts +23 -0
- package/dist/compaction/trace-events.d.ts.map +1 -0
- package/dist/components/catalog.d.ts +25 -0
- package/dist/components/catalog.d.ts.map +1 -0
- package/dist/components/effect-scope.d.ts +31 -0
- package/dist/components/effect-scope.d.ts.map +1 -0
- package/dist/components/loader.d.ts +27 -0
- package/dist/components/loader.d.ts.map +1 -0
- package/dist/components/model-guidance.d.ts +48 -0
- package/dist/components/model-guidance.d.ts.map +1 -0
- package/dist/components/provider-component.d.ts +31 -0
- package/dist/components/provider-component.d.ts.map +1 -0
- package/dist/components/supervisor.d.ts +29 -0
- package/dist/components/supervisor.d.ts.map +1 -0
- package/dist/components/types.d.ts +140 -0
- package/dist/components/types.d.ts.map +1 -0
- package/dist/config-migrations.d.ts +11 -0
- package/dist/config-migrations.d.ts.map +1 -0
- package/dist/config.d.ts +269 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/core/action-registry.d.ts +159 -0
- package/dist/core/action-registry.d.ts.map +1 -0
- package/dist/core/action-registry.js +17 -0
- package/dist/core/action-registry.js.map +7 -0
- package/dist/core/action-repair.d.ts +20 -0
- package/dist/core/action-repair.d.ts.map +1 -0
- package/dist/core/agent-dir.d.ts +2 -0
- package/dist/core/agent-dir.d.ts.map +1 -0
- package/dist/core/approval-controller.d.ts +30 -0
- package/dist/core/approval-controller.d.ts.map +1 -0
- package/dist/core/atomic-write.d.ts +15 -0
- package/dist/core/atomic-write.d.ts.map +1 -0
- package/dist/core/auto-approval-classifier.d.ts +13 -0
- package/dist/core/auto-approval-classifier.d.ts.map +1 -0
- package/dist/core/call-preview.d.ts +8 -0
- package/dist/core/call-preview.d.ts.map +1 -0
- package/dist/core/child-tool-allowlist.d.ts +3 -0
- package/dist/core/child-tool-allowlist.d.ts.map +1 -0
- package/dist/core/compact-controller.d.ts +42 -0
- package/dist/core/compact-controller.d.ts.map +1 -0
- package/dist/core/core-override-guidance.d.ts +7 -0
- package/dist/core/core-override-guidance.d.ts.map +1 -0
- package/dist/core/direct-tool-approval.d.ts +19 -0
- package/dist/core/direct-tool-approval.d.ts.map +1 -0
- package/dist/core/effect-conflict.d.ts +3 -0
- package/dist/core/effect-conflict.d.ts.map +1 -0
- package/dist/core/file-lock.d.ts +12 -0
- package/dist/core/file-lock.d.ts.map +1 -0
- package/dist/core/model-resolution.d.ts +62 -0
- package/dist/core/model-resolution.d.ts.map +1 -0
- package/dist/core/model-usage.d.ts +8 -0
- package/dist/core/model-usage.d.ts.map +1 -0
- package/dist/core/omp-bash-error.d.ts +11 -0
- package/dist/core/omp-bash-error.d.ts.map +1 -0
- package/dist/core/omp-tools.d.ts +9 -0
- package/dist/core/omp-tools.d.ts.map +1 -0
- package/dist/core/provider-bindings.d.ts +47 -0
- package/dist/core/provider-bindings.d.ts.map +1 -0
- package/dist/core/proxy-contract.d.ts +18 -0
- package/dist/core/proxy-contract.d.ts.map +1 -0
- package/dist/core/session-context.d.ts +6 -0
- package/dist/core/session-context.d.ts.map +1 -0
- package/dist/core/skill-block.d.ts +10 -0
- package/dist/core/skill-block.d.ts.map +1 -0
- package/dist/core/skill-dir.d.ts +4 -0
- package/dist/core/skill-dir.d.ts.map +1 -0
- package/dist/core/skill-prompt.d.ts +3 -0
- package/dist/core/skill-prompt.d.ts.map +1 -0
- package/dist/core/skill-references.d.ts +7 -0
- package/dist/core/skill-references.d.ts.map +1 -0
- package/dist/core/stable-hash.d.ts +3 -0
- package/dist/core/stable-hash.d.ts.map +1 -0
- package/dist/core/system-guidance.d.ts +12 -0
- package/dist/core/system-guidance.d.ts.map +1 -0
- package/dist/core/token-math.d.ts +16 -0
- package/dist/core/token-math.d.ts.map +1 -0
- package/dist/core/tool-ownership.d.ts +52 -0
- package/dist/core/tool-ownership.d.ts.map +1 -0
- package/dist/core/tool-result-proxy.d.ts +18 -0
- package/dist/core/tool-result-proxy.d.ts.map +1 -0
- package/dist/entropy/active.d.ts +7 -0
- package/dist/entropy/active.d.ts.map +1 -0
- package/dist/entropy/compiled-store.d.ts +16 -0
- package/dist/entropy/compiled-store.d.ts.map +1 -0
- package/dist/entropy/compiled-surface.d.ts +51 -0
- package/dist/entropy/compiled-surface.d.ts.map +1 -0
- package/dist/entropy/compiler.d.ts +28 -0
- package/dist/entropy/compiler.d.ts.map +1 -0
- package/dist/entropy/corpus.d.ts +22 -0
- package/dist/entropy/corpus.d.ts.map +1 -0
- package/dist/entropy/fingerprint.d.ts +9 -0
- package/dist/entropy/fingerprint.d.ts.map +1 -0
- package/dist/entropy/index.d.ts +15 -0
- package/dist/entropy/index.d.ts.map +1 -0
- package/dist/entropy/index.js +172 -0
- package/dist/entropy/index.js.map +7 -0
- package/dist/entropy/meter.d.ts +10 -0
- package/dist/entropy/meter.d.ts.map +1 -0
- package/dist/entropy/passes.d.ts +13 -0
- package/dist/entropy/passes.d.ts.map +1 -0
- package/dist/entropy/pool-store.d.ts +15 -0
- package/dist/entropy/pool-store.d.ts.map +1 -0
- package/dist/entropy/pool.d.ts +41 -0
- package/dist/entropy/pool.d.ts.map +1 -0
- package/dist/entropy/presentation.d.ts +13 -0
- package/dist/entropy/presentation.d.ts.map +1 -0
- package/dist/entropy/sessions.d.ts +47 -0
- package/dist/entropy/sessions.d.ts.map +1 -0
- package/dist/entropy/surface.d.ts +30 -0
- package/dist/entropy/surface.d.ts.map +1 -0
- package/dist/entropy/trial.d.ts +35 -0
- package/dist/entropy/trial.d.ts.map +1 -0
- package/dist/entropy/types.d.ts +158 -0
- package/dist/entropy/types.d.ts.map +1 -0
- package/dist/execution-service.d.ts +63 -0
- package/dist/execution-service.d.ts.map +1 -0
- package/dist/fabric-exec-arguments.d.ts +5 -0
- package/dist/fabric-exec-arguments.d.ts.map +1 -0
- package/dist/fabric-exec-tool.d.ts +8 -0
- package/dist/fabric-exec-tool.d.ts.map +1 -0
- package/dist/fabric-runtime-state.d.ts +90 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -0
- package/dist/fabric-runtime-state.js +13060 -0
- package/dist/fabric-runtime-state.js.map +7 -0
- package/dist/fabric-state.d.ts +89 -0
- package/dist/fabric-state.d.ts.map +1 -0
- package/dist/failure-progress.d.ts +3 -0
- package/dist/failure-progress.d.ts.map +1 -0
- package/dist/host-compatibility.d.ts +5 -0
- package/dist/host-compatibility.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5719 -0
- package/dist/index.js.map +7 -0
- package/dist/lifecycle/broker.d.ts +30 -0
- package/dist/lifecycle/broker.d.ts.map +1 -0
- package/dist/lifecycle/delivery-scheduler.d.ts +30 -0
- package/dist/lifecycle/delivery-scheduler.d.ts.map +1 -0
- package/dist/lifecycle/types.d.ts +91 -0
- package/dist/lifecycle/types.d.ts.map +1 -0
- package/dist/log-tail.d.ts +11 -0
- package/dist/log-tail.d.ts.map +1 -0
- package/dist/main-agent.d.ts +70 -0
- package/dist/main-agent.d.ts.map +1 -0
- package/dist/memory/context.d.ts +112 -0
- package/dist/memory/context.d.ts.map +1 -0
- package/dist/memory/digest.d.ts +48 -0
- package/dist/memory/digest.d.ts.map +1 -0
- package/dist/memory/digest.js +7 -0
- package/dist/memory/digest.js.map +7 -0
- package/dist/memory/discovery.d.ts +43 -0
- package/dist/memory/discovery.d.ts.map +1 -0
- package/dist/memory/discovery.js +23 -0
- package/dist/memory/discovery.js.map +7 -0
- package/dist/memory/index.d.ts +107 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/lineage.d.ts +20 -0
- package/dist/memory/lineage.d.ts.map +1 -0
- package/dist/memory/normalize.d.ts +170 -0
- package/dist/memory/normalize.d.ts.map +1 -0
- package/dist/memory/normalize.js +22 -0
- package/dist/memory/normalize.js.map +7 -0
- package/dist/memory/regex.d.ts +19 -0
- package/dist/memory/regex.d.ts.map +1 -0
- package/dist/memory/search.d.ts +98 -0
- package/dist/memory/search.d.ts.map +1 -0
- package/dist/memory/search.js +22 -0
- package/dist/memory/search.js.map +7 -0
- package/dist/memory/tokenize.d.ts +24 -0
- package/dist/memory/tokenize.d.ts.map +1 -0
- package/dist/mesh/store.d.ts +78 -0
- package/dist/mesh/store.d.ts.map +1 -0
- package/dist/output-budget.d.ts +12 -0
- package/dist/output-budget.d.ts.map +1 -0
- package/dist/prewalk/arm.d.ts +8 -0
- package/dist/prewalk/arm.d.ts.map +1 -0
- package/dist/prewalk/controller.d.ts +60 -0
- package/dist/prewalk/controller.d.ts.map +1 -0
- package/dist/prewalk/fs-drift.d.ts +19 -0
- package/dist/prewalk/fs-drift.d.ts.map +1 -0
- package/dist/prewalk/handoff.d.ts +45 -0
- package/dist/prewalk/handoff.d.ts.map +1 -0
- package/dist/protocol.d.ts +273 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +46 -0
- package/dist/protocol.js.map +7 -0
- package/dist/providers/agents-actions.d.ts +3 -0
- package/dist/providers/agents-actions.d.ts.map +1 -0
- package/dist/providers/agents-provider.d.ts +59 -0
- package/dist/providers/agents-provider.d.ts.map +1 -0
- package/dist/providers/arg-normalization.d.ts +15 -0
- package/dist/providers/arg-normalization.d.ts.map +1 -0
- package/dist/providers/captured-tools-provider.d.ts +23 -0
- package/dist/providers/captured-tools-provider.d.ts.map +1 -0
- package/dist/providers/compact-provider.d.ts +14 -0
- package/dist/providers/compact-provider.d.ts.map +1 -0
- package/dist/providers/components-provider.d.ts +12 -0
- package/dist/providers/components-provider.d.ts.map +1 -0
- package/dist/providers/mcp-descriptor-cache.d.ts +47 -0
- package/dist/providers/mcp-descriptor-cache.d.ts.map +1 -0
- package/dist/providers/mcp-provider.d.ts +27 -0
- package/dist/providers/mcp-provider.d.ts.map +1 -0
- package/dist/providers/memory-provider.d.ts +35 -0
- package/dist/providers/memory-provider.d.ts.map +1 -0
- package/dist/providers/memory-provider.js +16 -0
- package/dist/providers/memory-provider.js.map +7 -0
- package/dist/providers/mesh-provider.d.ts +17 -0
- package/dist/providers/mesh-provider.d.ts.map +1 -0
- package/dist/providers/omp-bash-cwd.d.ts +31 -0
- package/dist/providers/omp-bash-cwd.d.ts.map +1 -0
- package/dist/providers/omp-tools-provider.d.ts +15 -0
- package/dist/providers/omp-tools-provider.d.ts.map +1 -0
- package/dist/providers/schema-provider.d.ts +15 -0
- package/dist/providers/schema-provider.d.ts.map +1 -0
- package/dist/providers/state-provider.d.ts +16 -0
- package/dist/providers/state-provider.d.ts.map +1 -0
- package/dist/providers/write-diff-limits.d.ts +5 -0
- package/dist/providers/write-diff-limits.d.ts.map +1 -0
- package/dist/providers/write-preview.d.ts +3 -0
- package/dist/providers/write-preview.d.ts.map +1 -0
- package/dist/ref-names.d.ts +2 -0
- package/dist/ref-names.d.ts.map +1 -0
- package/dist/repairs/active.d.ts +7 -0
- package/dist/repairs/active.d.ts.map +1 -0
- package/dist/repairs/apply.d.ts +7 -0
- package/dist/repairs/apply.d.ts.map +1 -0
- package/dist/repairs/catalog-digest.d.ts +5 -0
- package/dist/repairs/catalog-digest.d.ts.map +1 -0
- package/dist/repairs/classify.d.ts +10 -0
- package/dist/repairs/classify.d.ts.map +1 -0
- package/dist/repairs/compiler.d.ts +33 -0
- package/dist/repairs/compiler.d.ts.map +1 -0
- package/dist/repairs/promote.d.ts +4 -0
- package/dist/repairs/promote.d.ts.map +1 -0
- package/dist/repairs/store.d.ts +10 -0
- package/dist/repairs/store.d.ts.map +1 -0
- package/dist/repairs/types.d.ts +49 -0
- package/dist/repairs/types.d.ts.map +1 -0
- package/dist/residency/actor-client.d.ts +16 -0
- package/dist/residency/actor-client.d.ts.map +1 -0
- package/dist/residency/actor-client.js +9 -0
- package/dist/residency/actor-client.js.map +7 -0
- package/dist/residency/client.d.ts +44 -0
- package/dist/residency/client.d.ts.map +1 -0
- package/dist/residency/host.d.ts +3 -0
- package/dist/residency/host.d.ts.map +1 -0
- package/dist/residency/host.js +25 -0
- package/dist/residency/host.js.map +7 -0
- package/dist/residency/launcher-owner.d.ts +7 -0
- package/dist/residency/launcher-owner.d.ts.map +1 -0
- package/dist/residency/launcher.d.ts +3 -0
- package/dist/residency/launcher.d.ts.map +1 -0
- package/dist/residency/launcher.js +152 -0
- package/dist/residency/launcher.js.map +7 -0
- package/dist/residency/omp-entry.d.ts +3 -0
- package/dist/residency/omp-entry.d.ts.map +1 -0
- package/dist/residency/omp-entry.js +41 -0
- package/dist/residency/omp-entry.js.map +7 -0
- package/dist/residency/protocol.d.ts +119 -0
- package/dist/residency/protocol.d.ts.map +1 -0
- package/dist/run-display.d.ts +3 -0
- package/dist/run-display.d.ts.map +1 -0
- package/dist/runtime/core-override-guest-types.d.ts +15 -0
- package/dist/runtime/core-override-guest-types.d.ts.map +1 -0
- package/dist/runtime/core-override-guest-types.js +291 -0
- package/dist/runtime/core-override-guest-types.js.map +7 -0
- package/dist/runtime/core-tool-properties.d.ts +6 -0
- package/dist/runtime/core-tool-properties.d.ts.map +1 -0
- package/dist/runtime/dynamic-guest-types.d.ts +3 -0
- package/dist/runtime/dynamic-guest-types.d.ts.map +1 -0
- package/dist/runtime/dynamic-guest-types.js +226 -0
- package/dist/runtime/dynamic-guest-types.js.map +7 -0
- package/dist/runtime/guest-code-repair.d.ts +2 -0
- package/dist/runtime/guest-code-repair.d.ts.map +1 -0
- package/dist/runtime/guest-stack-map.d.ts +11 -0
- package/dist/runtime/guest-stack-map.d.ts.map +1 -0
- package/dist/runtime/guest-types.d.ts +35 -0
- package/dist/runtime/guest-types.d.ts.map +1 -0
- package/dist/runtime/guest-types.js +13 -0
- package/dist/runtime/guest-types.js.map +7 -0
- package/dist/runtime/node-process-child-source.d.ts +2 -0
- package/dist/runtime/node-process-child-source.d.ts.map +1 -0
- package/dist/runtime/node-process-runtime.d.ts +10 -0
- package/dist/runtime/node-process-runtime.d.ts.map +1 -0
- package/dist/runtime/node-process-runtime.js +319 -0
- package/dist/runtime/node-process-runtime.js.map +7 -0
- package/dist/runtime/orchestration.d.ts +3 -0
- package/dist/runtime/orchestration.d.ts.map +1 -0
- package/dist/runtime/quickjs-runtime.d.ts +24 -0
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
- package/dist/runtime/quickjs-runtime.js +12 -0
- package/dist/runtime/quickjs-runtime.js.map +7 -0
- package/dist/runtime/type-checker.d.ts +21 -0
- package/dist/runtime/type-checker.d.ts.map +1 -0
- package/dist/runtime/type-checker.js +15 -0
- package/dist/runtime/type-checker.js.map +7 -0
- package/dist/runtime-paths.d.ts +7 -0
- package/dist/runtime-paths.d.ts.map +1 -0
- package/dist/schema/controller.d.ts +35 -0
- package/dist/schema/controller.d.ts.map +1 -0
- package/dist/schema/types.d.ts +86 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/workspace.d.ts +19 -0
- package/dist/schema/workspace.d.ts.map +1 -0
- package/dist/speculation/eligibility.d.ts +22 -0
- package/dist/speculation/eligibility.d.ts.map +1 -0
- package/dist/speculation/freshness.d.ts +10 -0
- package/dist/speculation/freshness.d.ts.map +1 -0
- package/dist/speculation/partial-json.d.ts +9 -0
- package/dist/speculation/partial-json.d.ts.map +1 -0
- package/dist/speculation/scanner.d.ts +13 -0
- package/dist/speculation/scanner.d.ts.map +1 -0
- package/dist/speculation/scanner.js +182 -0
- package/dist/speculation/scanner.js.map +7 -0
- package/dist/speculation/store.d.ts +39 -0
- package/dist/speculation/store.d.ts.map +1 -0
- package/dist/speculation/stream-tap.d.ts +27 -0
- package/dist/speculation/stream-tap.d.ts.map +1 -0
- package/dist/speculation/types.d.ts +44 -0
- package/dist/speculation/types.d.ts.map +1 -0
- package/dist/state/complexity.d.ts +13 -0
- package/dist/state/complexity.d.ts.map +1 -0
- package/dist/state/evidence-runner.d.ts +17 -0
- package/dist/state/evidence-runner.d.ts.map +1 -0
- package/dist/state/store.d.ts +76 -0
- package/dist/state/store.d.ts.map +1 -0
- package/dist/state/types.d.ts +165 -0
- package/dist/state/types.d.ts.map +1 -0
- package/dist/storage/retention.d.ts +22 -0
- package/dist/storage/retention.d.ts.map +1 -0
- package/dist/thinking.d.ts +19 -0
- package/dist/thinking.d.ts.map +1 -0
- package/dist/topology/control-plane.d.ts +58 -0
- package/dist/topology/control-plane.d.ts.map +1 -0
- package/dist/topology/participant-directory.d.ts +33 -0
- package/dist/topology/participant-directory.d.ts.map +1 -0
- package/dist/topology/peer-settle.d.ts +51 -0
- package/dist/topology/peer-settle.d.ts.map +1 -0
- package/dist/topology/records.d.ts +6 -0
- package/dist/topology/records.d.ts.map +1 -0
- package/dist/topology/types.d.ts +89 -0
- package/dist/topology/types.d.ts.map +1 -0
- package/dist/type-error-guidance.d.ts +3 -0
- package/dist/type-error-guidance.d.ts.map +1 -0
- package/dist/ui/arc-group.d.ts +17 -0
- package/dist/ui/arc-group.d.ts.map +1 -0
- package/dist/ui/code-preview-shell.d.ts +26 -0
- package/dist/ui/code-preview-shell.d.ts.map +1 -0
- package/dist/ui/code-preview.d.ts +53 -0
- package/dist/ui/code-preview.d.ts.map +1 -0
- package/dist/ui/controller.d.ts +20 -0
- package/dist/ui/controller.d.ts.map +1 -0
- package/dist/ui/conversation-chrome.d.ts +15 -0
- package/dist/ui/conversation-chrome.d.ts.map +1 -0
- package/dist/ui/conversation-chrome.js +10 -0
- package/dist/ui/conversation-chrome.js.map +7 -0
- package/dist/ui/conversation-native-reader.d.ts +106 -0
- package/dist/ui/conversation-native-reader.d.ts.map +1 -0
- package/dist/ui/conversation-native-reader.js +784 -0
- package/dist/ui/conversation-native-reader.js.map +7 -0
- package/dist/ui/conversation-queue-store.d.ts +12 -0
- package/dist/ui/conversation-queue-store.d.ts.map +1 -0
- package/dist/ui/conversation-queue.d.ts +242 -0
- package/dist/ui/conversation-queue.d.ts.map +1 -0
- package/dist/ui/conversation-render.d.ts +45 -0
- package/dist/ui/conversation-render.d.ts.map +1 -0
- package/dist/ui/conversation-shortcut.d.ts +3 -0
- package/dist/ui/conversation-shortcut.d.ts.map +1 -0
- package/dist/ui/conversation-targets.d.ts +7 -0
- package/dist/ui/conversation-targets.d.ts.map +1 -0
- package/dist/ui/conversation-targets.js +12 -0
- package/dist/ui/conversation-targets.js.map +7 -0
- package/dist/ui/conversation-transcript.d.ts +25 -0
- package/dist/ui/conversation-transcript.d.ts.map +1 -0
- package/dist/ui/conversation.d.ts +170 -0
- package/dist/ui/conversation.d.ts.map +1 -0
- package/dist/ui/conversation.js +1868 -0
- package/dist/ui/conversation.js.map +7 -0
- package/dist/ui/core-tool-render.d.ts +20 -0
- package/dist/ui/core-tool-render.d.ts.map +1 -0
- package/dist/ui/dashboard-detail.d.ts +68 -0
- package/dist/ui/dashboard-detail.d.ts.map +1 -0
- package/dist/ui/dashboard-fabric-graph.d.ts +50 -0
- package/dist/ui/dashboard-fabric-graph.d.ts.map +1 -0
- package/dist/ui/dashboard-model.d.ts +111 -0
- package/dist/ui/dashboard-model.d.ts.map +1 -0
- package/dist/ui/dashboard-presentation.d.ts +6 -0
- package/dist/ui/dashboard-presentation.d.ts.map +1 -0
- package/dist/ui/dashboard.d.ts +188 -0
- package/dist/ui/dashboard.d.ts.map +1 -0
- package/dist/ui/dashboard.js +4604 -0
- package/dist/ui/dashboard.js.map +7 -0
- package/dist/ui/diff-background.d.ts +12 -0
- package/dist/ui/diff-background.d.ts.map +1 -0
- package/dist/ui/dynamic-border.d.ts +8 -0
- package/dist/ui/dynamic-border.d.ts.map +1 -0
- package/dist/ui/escape-halt.d.ts +11 -0
- package/dist/ui/escape-halt.d.ts.map +1 -0
- package/dist/ui/fabric-actor-delivery-selector.d.ts +17 -0
- package/dist/ui/fabric-actor-delivery-selector.d.ts.map +1 -0
- package/dist/ui/fabric-actor-tool-selector.d.ts +22 -0
- package/dist/ui/fabric-actor-tool-selector.d.ts.map +1 -0
- package/dist/ui/fabric-code-parser.d.ts +8 -0
- package/dist/ui/fabric-code-parser.d.ts.map +1 -0
- package/dist/ui/fabric-host-event-selector.d.ts +29 -0
- package/dist/ui/fabric-host-event-selector.d.ts.map +1 -0
- package/dist/ui/fabric-model-selector.d.ts +64 -0
- package/dist/ui/fabric-model-selector.d.ts.map +1 -0
- package/dist/ui/fabric-render.d.ts +113 -0
- package/dist/ui/fabric-render.d.ts.map +1 -0
- package/dist/ui/fabric-thinking-selector.d.ts +26 -0
- package/dist/ui/fabric-thinking-selector.d.ts.map +1 -0
- package/dist/ui/fabric-title-hint.d.ts +2 -0
- package/dist/ui/fabric-title-hint.d.ts.map +1 -0
- package/dist/ui/format.d.ts +9 -0
- package/dist/ui/format.d.ts.map +1 -0
- package/dist/ui/highlight.d.ts +69 -0
- package/dist/ui/highlight.d.ts.map +1 -0
- package/dist/ui/model-picker.d.ts +46 -0
- package/dist/ui/model-picker.d.ts.map +1 -0
- package/dist/ui/model-picker.js +17 -0
- package/dist/ui/model-picker.js.map +7 -0
- package/dist/ui/preview-lines.d.ts +16 -0
- package/dist/ui/preview-lines.d.ts.map +1 -0
- package/dist/ui/row-balance.d.ts +29 -0
- package/dist/ui/row-balance.d.ts.map +1 -0
- package/dist/ui/settings.d.ts +57 -0
- package/dist/ui/settings.d.ts.map +1 -0
- package/dist/ui/settings.js +1908 -0
- package/dist/ui/settings.js.map +7 -0
- package/dist/ui/shiki-language.d.ts +7 -0
- package/dist/ui/shiki-language.d.ts.map +1 -0
- package/dist/ui/shiki-theme.d.ts +7 -0
- package/dist/ui/shiki-theme.d.ts.map +1 -0
- package/dist/ui/snapshot.d.ts +7 -0
- package/dist/ui/snapshot.d.ts.map +1 -0
- package/dist/ui/spinner.d.ts +6 -0
- package/dist/ui/spinner.d.ts.map +1 -0
- package/dist/ui/state-file-preview.d.ts +13 -0
- package/dist/ui/state-file-preview.d.ts.map +1 -0
- package/dist/ui/structured.d.ts +9 -0
- package/dist/ui/structured.d.ts.map +1 -0
- package/dist/ui/symbol-theme.d.ts +3 -0
- package/dist/ui/symbol-theme.d.ts.map +1 -0
- package/dist/ui/tool-call-timing.d.ts +2 -0
- package/dist/ui/tool-call-timing.d.ts.map +1 -0
- package/dist/ui/tool-display.d.ts +8 -0
- package/dist/ui/tool-display.d.ts.map +1 -0
- package/dist/ui/topology.d.ts +162 -0
- package/dist/ui/topology.d.ts.map +1 -0
- package/dist/ui/transcript-parser.d.ts +18 -0
- package/dist/ui/transcript-parser.d.ts.map +1 -0
- package/dist/ui/transcript-reader.d.ts +10 -0
- package/dist/ui/transcript-reader.d.ts.map +1 -0
- package/dist/ui/transcript-sanitization.d.ts +14 -0
- package/dist/ui/transcript-sanitization.d.ts.map +1 -0
- package/dist/ui/transcript.d.ts +52 -0
- package/dist/ui/transcript.d.ts.map +1 -0
- package/dist/ui/types.d.ts +84 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/widget.d.ts +16 -0
- package/dist/ui/widget.d.ts.map +1 -0
- package/dist/ui/word-diff/alignment.d.ts +6 -0
- package/dist/ui/word-diff/alignment.d.ts.map +1 -0
- package/dist/ui/word-diff/change-block.d.ts +18 -0
- package/dist/ui/word-diff/change-block.d.ts.map +1 -0
- package/dist/ui/word-diff/changed-line.d.ts +14 -0
- package/dist/ui/word-diff/changed-line.d.ts.map +1 -0
- package/dist/ui/word-diff/emphasis.d.ts +9 -0
- package/dist/ui/word-diff/emphasis.d.ts.map +1 -0
- package/dist/ui/word-diff/line-emphasis.d.ts +7 -0
- package/dist/ui/word-diff/line-emphasis.d.ts.map +1 -0
- package/dist/ui/word-diff/line-matching.d.ts +10 -0
- package/dist/ui/word-diff/line-matching.d.ts.map +1 -0
- package/dist/ui/word-diff/line-similarity.d.ts +16 -0
- package/dist/ui/word-diff/line-similarity.d.ts.map +1 -0
- package/dist/ui/word-diff/normalize.d.ts +3 -0
- package/dist/ui/word-diff/normalize.d.ts.map +1 -0
- package/dist/ui/word-diff/parse.d.ts +17 -0
- package/dist/ui/word-diff/parse.d.ts.map +1 -0
- package/dist/ui/word-diff/range-refinement.d.ts +5 -0
- package/dist/ui/word-diff/range-refinement.d.ts.map +1 -0
- package/dist/ui/word-diff/ranges.d.ts +11 -0
- package/dist/ui/word-diff/ranges.d.ts.map +1 -0
- package/dist/ui/word-diff/smart-filter.d.ts +3 -0
- package/dist/ui/word-diff/smart-filter.d.ts.map +1 -0
- package/dist/ui/word-diff/sparse-line-matching.d.ts +25 -0
- package/dist/ui/word-diff/sparse-line-matching.d.ts.map +1 -0
- package/dist/ui/word-diff/text-boundaries.d.ts +11 -0
- package/dist/ui/word-diff/text-boundaries.d.ts.map +1 -0
- package/dist/ui/word-diff/token-alignment.d.ts +9 -0
- package/dist/ui/word-diff/token-alignment.d.ts.map +1 -0
- package/dist/ui/word-diff/token-text-refinement.d.ts +4 -0
- package/dist/ui/word-diff/token-text-refinement.d.ts.map +1 -0
- package/dist/ui/word-diff/tokens.d.ts +16 -0
- package/dist/ui/word-diff/tokens.d.ts.map +1 -0
- package/dist/ui/word-diff/types.d.ts +10 -0
- package/dist/ui/word-diff/types.d.ts.map +1 -0
- package/dist/util.d.ts +3 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/worker/options.d.ts +3 -0
- package/dist/worker/options.d.ts.map +1 -0
- package/dist/worker/options.js +104 -0
- package/dist/worker/options.js.map +7 -0
- package/dist/worker/run-record.d.ts +22 -0
- package/dist/worker/run-record.d.ts.map +1 -0
- package/dist/worker/run-record.js +123 -0
- package/dist/worker/run-record.js.map +7 -0
- package/dist/worker/session-export.d.ts +45 -0
- package/dist/worker/session-export.d.ts.map +1 -0
- package/dist/worker/session-export.js +91 -0
- package/dist/worker/session-export.js.map +7 -0
- package/dist/worker.d.ts +3 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +1061 -0
- package/dist/worker.js.map +7 -0
- package/docs/agents.md +564 -0
- package/docs/architecture.md +139 -0
- package/docs/audit-trace.md +116 -0
- package/docs/certification.md +134 -0
- package/docs/compaction.md +332 -0
- package/docs/component-calculus.md +191 -0
- package/docs/components.md +329 -0
- package/docs/configuration.md +478 -0
- package/docs/entropy.md +396 -0
- package/docs/interface.md +149 -0
- package/docs/memory-recall.md +614 -0
- package/docs/programmatic-compaction.md +207 -0
- package/docs/provider-component-calculus.md +378 -0
- package/docs/providers.md +109 -0
- package/docs/repairs.md +69 -0
- package/docs/residency-runtime.md +82 -0
- package/docs/schema-enforcement.md +166 -0
- package/docs/skills.md +48 -0
- package/docs/speculation.md +132 -0
- package/docs/state-layer.md +197 -0
- package/package.json +116 -0
- package/skills/fabric-advisor/SKILL.md +29 -0
- package/skills/fabric-ambient/SKILL.md +44 -0
- package/skills/fabric-ambient/references/setup.md +90 -0
- package/skills/fabric-council/SKILL.md +94 -0
- package/skills/fabric-exec/SKILL.md +123 -0
- package/skills/fabric-exec/references/agents.md +211 -0
- package/skills/fabric-exec/references/mcp.md +49 -0
- package/skills/fabric-exec/references/mesh.md +51 -0
- package/skills/fabric-fusion/SKILL.md +332 -0
- package/skills/fabric-guide/SKILL.md +28 -0
- package/skills/fabric-rlm/SKILL.md +284 -0
- package/skills/fabric-schema/SKILL.md +121 -0
- package/skills/fabric-spec/SKILL.md +42 -0
- package/skills/fabric-supervisor/SKILL.md +37 -0
- package/skills/fabric-swarm/SKILL.md +80 -0
- package/skills/fabric-workflow/SKILL.md +133 -0
package/dist/worker.js
ADDED
|
@@ -0,0 +1,1061 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/worker.ts
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import crossSpawn from "cross-spawn";
|
|
7
|
+
import { StringDecoder } from "node:string_decoder";
|
|
8
|
+
import { validateJsonSchemaValue } from "@oh-my-pi/pi-ai/utils/schema";
|
|
9
|
+
var NODE_SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".cjs", ".mjs", ".ts", ".cts", ".mts"]);
|
|
10
|
+
var spawnCli = (command, args, options) => NODE_SCRIPT_EXTENSIONS.has(path.extname(command).toLowerCase()) ? crossSpawn(process.execPath, [command, ...args], options) : crossSpawn(command, [...args], options);
|
|
11
|
+
var loadWorkerOptions = async () => {
|
|
12
|
+
if (!import.meta.url.endsWith(".ts")) return import("./worker/options.js");
|
|
13
|
+
const sourceModulePath = "./worker/options.ts";
|
|
14
|
+
return import(sourceModulePath);
|
|
15
|
+
};
|
|
16
|
+
var loadWorkerRunRecord = async () => {
|
|
17
|
+
if (!import.meta.url.endsWith(".ts")) return import("./worker/run-record.js");
|
|
18
|
+
const sourceModulePath = "./worker/run-record.ts";
|
|
19
|
+
return import(sourceModulePath);
|
|
20
|
+
};
|
|
21
|
+
var loadWorkerSessionExport = async () => {
|
|
22
|
+
if (!import.meta.url.endsWith(".ts")) return import("./worker/session-export.js");
|
|
23
|
+
const sourceModulePath = "./worker/session-export.ts";
|
|
24
|
+
return import(sourceModulePath);
|
|
25
|
+
};
|
|
26
|
+
var loadCompactControl = async () => {
|
|
27
|
+
if (!import.meta.url.endsWith(".ts")) return import("./agents/compact-control.js");
|
|
28
|
+
const sourceModulePath = "./agents/compact-control.ts";
|
|
29
|
+
return import(sourceModulePath);
|
|
30
|
+
};
|
|
31
|
+
var loadClaudeCli = async () => {
|
|
32
|
+
if (!import.meta.url.endsWith(".ts")) return import("./agents/claude-cli.js");
|
|
33
|
+
const sourceModulePath = "./agents/claude-cli.ts";
|
|
34
|
+
return import(sourceModulePath);
|
|
35
|
+
};
|
|
36
|
+
var loadVedaCli = async () => {
|
|
37
|
+
if (!import.meta.url.endsWith(".ts")) return import("./agents/veda-cli.js");
|
|
38
|
+
const sourceModulePath = "./agents/veda-cli.ts";
|
|
39
|
+
return import(sourceModulePath);
|
|
40
|
+
};
|
|
41
|
+
var MAX_STDERR_CHARS = 2e4;
|
|
42
|
+
var MAX_EVENT_LINE_CHARS = 4 * 1024 * 1024;
|
|
43
|
+
var STEER_READ_CHUNK_BYTES = 256 * 1024;
|
|
44
|
+
var MAX_STEER_LINE_BYTES = 64 * 1024;
|
|
45
|
+
var MAX_STEER_COMMANDS_PER_POLL = 256;
|
|
46
|
+
var MAX_CLAUDE_PENDING_INPUTS = 256;
|
|
47
|
+
var MAX_CLAUDE_PENDING_TOOLS = 1e3;
|
|
48
|
+
var KILL_GRACE_MS = 5e3;
|
|
49
|
+
var extractText = (message) => {
|
|
50
|
+
const content = message.content;
|
|
51
|
+
if (typeof content === "string") return content;
|
|
52
|
+
if (!Array.isArray(content)) return "";
|
|
53
|
+
return content.filter(
|
|
54
|
+
(part) => typeof part === "object" && part !== null && part.type === "text" && typeof part.text === "string"
|
|
55
|
+
).map((part) => part.text).join("");
|
|
56
|
+
};
|
|
57
|
+
var readImages = (filePath) => {
|
|
58
|
+
if (!filePath) return [];
|
|
59
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
60
|
+
if (!Array.isArray(parsed)) throw new Error("Agent images file must contain an array");
|
|
61
|
+
const images = [];
|
|
62
|
+
for (const value of parsed) {
|
|
63
|
+
if (typeof value !== "object" || value === null || Array.isArray(value) || value.type !== "image" || typeof value.data !== "string" || typeof value.mimeType !== "string") {
|
|
64
|
+
throw new Error("Agent images file contains an invalid image block");
|
|
65
|
+
}
|
|
66
|
+
images.push({
|
|
67
|
+
type: "image",
|
|
68
|
+
data: value.data,
|
|
69
|
+
mimeType: value.mimeType
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return images;
|
|
73
|
+
};
|
|
74
|
+
var numberField = (value) => typeof value === "number" ? value : 0;
|
|
75
|
+
var stringField = (value) => typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
76
|
+
var assistantError = (message) => {
|
|
77
|
+
const details = [];
|
|
78
|
+
const direct = stringField(message.errorMessage) ?? stringField(message.error);
|
|
79
|
+
if (direct) details.push(direct);
|
|
80
|
+
if (Array.isArray(message.diagnostics)) {
|
|
81
|
+
for (const diagnostic of message.diagnostics) {
|
|
82
|
+
if (typeof diagnostic !== "object" || diagnostic === null || Array.isArray(diagnostic)) continue;
|
|
83
|
+
const record = diagnostic;
|
|
84
|
+
const nested = typeof record.error === "object" && record.error !== null && !Array.isArray(record.error) ? record.error : void 0;
|
|
85
|
+
const detail = stringField(nested?.message) ?? stringField(record.message);
|
|
86
|
+
if (detail) details.push(detail);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const unique = [...new Set(details)];
|
|
90
|
+
const provider = stringField(message.provider);
|
|
91
|
+
const model = stringField(message.model);
|
|
92
|
+
const source = [provider, model].filter((value) => Boolean(value)).join("/");
|
|
93
|
+
const summary = unique.join(" \xB7 ") || "OMP agent reported an error";
|
|
94
|
+
return `${source ? `${source}: ` : ""}${summary}`.slice(0, MAX_STDERR_CHARS);
|
|
95
|
+
};
|
|
96
|
+
var runnerLabel = (runner) => runner === "claude" ? "Claude" : runner === "veda" ? "Veda" : "OMP";
|
|
97
|
+
var terminateChild = (child, signal) => {
|
|
98
|
+
if (!child.pid) return;
|
|
99
|
+
try {
|
|
100
|
+
process.kill(process.platform === "win32" ? child.pid : -child.pid, signal);
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var extractBalancedJson = (text, start) => {
|
|
105
|
+
const open = text[start];
|
|
106
|
+
if (open !== "{" && open !== "[") return null;
|
|
107
|
+
const close = open === "{" ? "}" : "]";
|
|
108
|
+
let depth = 0;
|
|
109
|
+
let inString = false;
|
|
110
|
+
let escaped = false;
|
|
111
|
+
for (let i = start; i < text.length; i++) {
|
|
112
|
+
const ch = text[i];
|
|
113
|
+
if (inString) {
|
|
114
|
+
if (escaped) escaped = false;
|
|
115
|
+
else if (ch === "\\") escaped = true;
|
|
116
|
+
else if (ch === '"') inString = false;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (ch === '"') inString = true;
|
|
120
|
+
else if (ch === open) depth++;
|
|
121
|
+
else if (ch === close) {
|
|
122
|
+
depth--;
|
|
123
|
+
if (depth === 0) return text.slice(start, i + 1);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
};
|
|
128
|
+
var parseStructuredValue = (text) => {
|
|
129
|
+
const trimmed = text.trim();
|
|
130
|
+
try {
|
|
131
|
+
return JSON.parse(trimmed);
|
|
132
|
+
} catch {
|
|
133
|
+
}
|
|
134
|
+
const fenced = trimmed.match(/```(?:json)?\s*\n([\s\S]*?)\n```/i);
|
|
135
|
+
if (fenced?.[1]) {
|
|
136
|
+
try {
|
|
137
|
+
return JSON.parse(fenced[1].trim());
|
|
138
|
+
} catch {
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const start = trimmed.search(/[{\[]/);
|
|
142
|
+
if (start >= 0) {
|
|
143
|
+
const balanced = extractBalancedJson(trimmed, start);
|
|
144
|
+
if (balanced) return JSON.parse(balanced);
|
|
145
|
+
}
|
|
146
|
+
return JSON.parse(trimmed);
|
|
147
|
+
};
|
|
148
|
+
var crashContext;
|
|
149
|
+
var runRecordHelpers;
|
|
150
|
+
var terminalWritten = false;
|
|
151
|
+
var writeCrashStatus = (error) => {
|
|
152
|
+
if (!crashContext || !runRecordHelpers || terminalWritten) return;
|
|
153
|
+
try {
|
|
154
|
+
runRecordHelpers.writeCrashRunRecord(crashContext.statusFile, crashContext.record, error);
|
|
155
|
+
} catch {
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
process.on("uncaughtException", (error) => {
|
|
159
|
+
writeCrashStatus(error);
|
|
160
|
+
process.stderr.write(`${error instanceof Error ? error.stack ?? error.message : error}
|
|
161
|
+
`);
|
|
162
|
+
process.exit(1);
|
|
163
|
+
});
|
|
164
|
+
process.on("unhandledRejection", (error) => {
|
|
165
|
+
writeCrashStatus(error);
|
|
166
|
+
process.stderr.write(`Unhandled rejection: ${error instanceof Error ? error.stack ?? error.message : error}
|
|
167
|
+
`);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
});
|
|
170
|
+
var main = async () => {
|
|
171
|
+
const [optionHelpers, loadedRunRecordHelpers, sessionExportHelpers] = await Promise.all([
|
|
172
|
+
loadWorkerOptions(),
|
|
173
|
+
loadWorkerRunRecord(),
|
|
174
|
+
loadWorkerSessionExport()
|
|
175
|
+
]);
|
|
176
|
+
runRecordHelpers = loadedRunRecordHelpers;
|
|
177
|
+
const {
|
|
178
|
+
applyUsage,
|
|
179
|
+
createRunningRecord,
|
|
180
|
+
emptyUsage,
|
|
181
|
+
extractUsageDelta,
|
|
182
|
+
latestRunText,
|
|
183
|
+
updateRunRecord,
|
|
184
|
+
writeRunRecord
|
|
185
|
+
} = loadedRunRecordHelpers;
|
|
186
|
+
const options = optionHelpers.parseWorkerOptions();
|
|
187
|
+
const sessionExporter = options.sessionExportFile ? new sessionExportHelpers.SessionExporter({
|
|
188
|
+
file: options.sessionExportFile,
|
|
189
|
+
sessionId: options.id,
|
|
190
|
+
cwd: options.cwd,
|
|
191
|
+
agentName: options.name
|
|
192
|
+
}) : void 0;
|
|
193
|
+
const thinking = options.thinking === "off" || options.thinking === "minimal" || options.thinking === "low" || options.thinking === "medium" || options.thinking === "high" || options.thinking === "xhigh" || options.thinking === "max" ? options.thinking : void 0;
|
|
194
|
+
const task = fs.readFileSync(options.taskFile, "utf8");
|
|
195
|
+
const images = readImages(options.imagesFile);
|
|
196
|
+
const record = createRunningRecord(options, task, thinking, Date.now());
|
|
197
|
+
writeRunRecord(options.statusFile, record);
|
|
198
|
+
const emitLifecycle = (event, data) => {
|
|
199
|
+
try {
|
|
200
|
+
fs.mkdirSync(path.dirname(options.lifecycleFile), { recursive: true });
|
|
201
|
+
fs.appendFileSync(
|
|
202
|
+
options.lifecycleFile,
|
|
203
|
+
JSON.stringify({ version: 1, event, occurredAt: Date.now(), ...data ? { data } : {} }) + "\n",
|
|
204
|
+
{ encoding: "utf8", mode: 384 }
|
|
205
|
+
);
|
|
206
|
+
} catch {
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
crashContext = { statusFile: options.statusFile, record };
|
|
210
|
+
process.stdout.write(`[omp-fabric] ${options.name}
|
|
211
|
+
${task}
|
|
212
|
+
|
|
213
|
+
`);
|
|
214
|
+
fs.mkdirSync(path.dirname(options.logFile), { recursive: true });
|
|
215
|
+
const appendLog = (text) => {
|
|
216
|
+
try {
|
|
217
|
+
fs.appendFileSync(options.logFile, text, { encoding: "utf8", mode: 384 });
|
|
218
|
+
} catch {
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
const sessionStream = options.runner === "claude" && options.sessionFile ? fs.createWriteStream(options.sessionFile, { flags: "a", mode: 384 }) : void 0;
|
|
222
|
+
sessionStream?.on("error", () => {
|
|
223
|
+
});
|
|
224
|
+
const schema = options.schemaFile ? fs.readFileSync(options.schemaFile, "utf8") : void 0;
|
|
225
|
+
const ompArguments = ["--mode", "rpc"];
|
|
226
|
+
if (options.sessionFile) ompArguments.push("--session", options.sessionFile);
|
|
227
|
+
else ompArguments.push("--no-session");
|
|
228
|
+
if (!options.extensions) ompArguments.push("--no-extensions");
|
|
229
|
+
if (options.fabricExtensionPath) ompArguments.push("-e", options.fabricExtensionPath);
|
|
230
|
+
if (options.tools.length > 0) ompArguments.push("--tools", options.tools.join(","));
|
|
231
|
+
else ompArguments.push("--no-tools");
|
|
232
|
+
if (options.model) ompArguments.push("--model", options.model);
|
|
233
|
+
if (thinking) ompArguments.push("--thinking", thinking);
|
|
234
|
+
if (options.systemPrompt) ompArguments.push("--append-system-prompt", options.systemPrompt);
|
|
235
|
+
if (schema) {
|
|
236
|
+
ompArguments.push(
|
|
237
|
+
"--append-system-prompt",
|
|
238
|
+
`Your final response must contain only JSON matching this schema, without Markdown fences:
|
|
239
|
+
${schema}`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
const claudeCli = options.runner === "claude" ? await loadClaudeCli() : void 0;
|
|
243
|
+
const vedaCli = options.runner === "veda" ? await loadVedaCli() : void 0;
|
|
244
|
+
const childArguments = options.runner === "claude" ? claudeCli.buildClaudeArguments({
|
|
245
|
+
tools: options.tools,
|
|
246
|
+
extensions: options.extensions,
|
|
247
|
+
persistentSession: Boolean(options.sessionFile),
|
|
248
|
+
...options.model ? { model: options.model } : {},
|
|
249
|
+
...thinking ? { thinking } : {},
|
|
250
|
+
...options.systemPrompt ? { systemPrompt: options.systemPrompt } : {},
|
|
251
|
+
...schema ? { schema } : {},
|
|
252
|
+
...options.runnerSessionId ? { runnerSessionId: options.runnerSessionId } : {},
|
|
253
|
+
name: options.name
|
|
254
|
+
}) : options.runner === "veda" ? vedaCli.buildVedaArguments({
|
|
255
|
+
backend: options.vedaBackend,
|
|
256
|
+
persona: options.vedaPersona,
|
|
257
|
+
...options.model ? { model: options.model } : {},
|
|
258
|
+
...thinking ? { thinking } : {},
|
|
259
|
+
tools: options.tools,
|
|
260
|
+
// Isolate selection and conversation state per child run so
|
|
261
|
+
// parallel Fabric agents never share Veda session state.
|
|
262
|
+
session: `fabric-${options.id}`
|
|
263
|
+
}) : ompArguments;
|
|
264
|
+
const childBinary = options.runner === "claude" ? options.claudeBinary : options.runner === "veda" ? options.vedaBinary : options.ompBinary;
|
|
265
|
+
const child = spawnCli(childBinary, childArguments, {
|
|
266
|
+
cwd: options.cwd,
|
|
267
|
+
detached: process.platform !== "win32",
|
|
268
|
+
env: {
|
|
269
|
+
...process.env,
|
|
270
|
+
OMP_FABRIC_DEPTH: String(options.depth),
|
|
271
|
+
OMP_FABRIC_PARENT_RUN: options.id,
|
|
272
|
+
OMP_FABRIC_AGENT_NAME: options.name,
|
|
273
|
+
...options.mainAgentId ? { OMP_FABRIC_MAIN_AGENT_ID: options.mainAgentId } : {},
|
|
274
|
+
...options.fabricSessionId ? { OMP_FABRIC_SESSION_ID: options.fabricSessionId } : {},
|
|
275
|
+
OMP_FABRIC_GRANTED_RISKS: options.grantedRisks.join(","),
|
|
276
|
+
OMP_FABRIC_FULL_CODE_MODE: String(options.fullCodeMode),
|
|
277
|
+
// Native tool allowlist for nested-call enforcement: full-code children
|
|
278
|
+
// reach omp.* through fabric_exec, which is not gated by the --tools
|
|
279
|
+
// allowlist, so both OMP and captured-tool providers enforce this
|
|
280
|
+
// child-side allowlist before preparation, discovery, and invocation.
|
|
281
|
+
OMP_FABRIC_TOOL_ALLOWLIST: JSON.stringify(options.tools),
|
|
282
|
+
...options.actorId ? { OMP_FABRIC_ACTOR_ID: options.actorId } : {},
|
|
283
|
+
...options.actorName ? { OMP_FABRIC_ACTOR_NAME: options.actorName } : {},
|
|
284
|
+
OMP_FABRIC_CAPABILITY_REQUIREMENTS: JSON.stringify(
|
|
285
|
+
options.capabilityRequirements ?? []
|
|
286
|
+
),
|
|
287
|
+
OMP_FABRIC_CAPABILITY_DIGEST: options.capabilityDigest ?? "",
|
|
288
|
+
...options.meshRoot ? { OMP_FABRIC_MESH_ROOT: options.meshRoot } : {},
|
|
289
|
+
...options.projectRoot ? { OMP_FABRIC_PROJECT_ROOT: options.projectRoot } : {},
|
|
290
|
+
...options.ownerHostId ? { OMP_FABRIC_OWNER_HOST_ID: options.ownerHostId } : {},
|
|
291
|
+
...options.ownerIdentityId ? { OMP_FABRIC_OWNER_IDENTITY_ID: options.ownerIdentityId } : {},
|
|
292
|
+
...options.runRoot ? { OMP_FABRIC_RUN_ROOT: options.runRoot } : {}
|
|
293
|
+
},
|
|
294
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
295
|
+
});
|
|
296
|
+
let stderr = "";
|
|
297
|
+
let outputBuffer = "";
|
|
298
|
+
let vedaOutput = "";
|
|
299
|
+
let vedaParsed;
|
|
300
|
+
const outputDecoder = new StringDecoder("utf8");
|
|
301
|
+
const stderrDecoder = new StringDecoder("utf8");
|
|
302
|
+
let terminalStatus;
|
|
303
|
+
let terminalError;
|
|
304
|
+
let sawAgentError = false;
|
|
305
|
+
let retryPending = false;
|
|
306
|
+
let lastCompactionReason;
|
|
307
|
+
const update = () => updateRunRecord(options.statusFile, record);
|
|
308
|
+
const lastEmittedUsage = emptyUsage();
|
|
309
|
+
const emitTokenUsage = (delta, attribution) => {
|
|
310
|
+
const snapshot = record.usage;
|
|
311
|
+
if (snapshot.input === lastEmittedUsage.input && snapshot.output === lastEmittedUsage.output && snapshot.cacheRead === lastEmittedUsage.cacheRead && snapshot.cacheWrite === lastEmittedUsage.cacheWrite && snapshot.cost === lastEmittedUsage.cost) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
emitLifecycle("tokens.usage", {
|
|
315
|
+
runId: options.id,
|
|
316
|
+
name: options.name,
|
|
317
|
+
runner: options.runner,
|
|
318
|
+
depth: options.depth,
|
|
319
|
+
...options.actorId ? { actorId: options.actorId } : {},
|
|
320
|
+
...options.actorName ? { actorName: options.actorName } : {},
|
|
321
|
+
cumulativeTokens: snapshot.input + snapshot.output + snapshot.cacheRead + snapshot.cacheWrite,
|
|
322
|
+
input: delta?.input ?? 0,
|
|
323
|
+
output: delta?.output ?? 0,
|
|
324
|
+
cacheRead: delta?.cacheRead ?? 0,
|
|
325
|
+
cacheWrite: delta?.cacheWrite ?? 0,
|
|
326
|
+
cost: delta?.cost ?? snapshot.cost
|
|
327
|
+
});
|
|
328
|
+
sessionExporter?.push(
|
|
329
|
+
{
|
|
330
|
+
input: delta?.input ?? 0,
|
|
331
|
+
output: delta?.output ?? 0,
|
|
332
|
+
cacheRead: delta?.cacheRead ?? 0,
|
|
333
|
+
cacheWrite: delta?.cacheWrite ?? 0,
|
|
334
|
+
cost: delta?.cost ?? snapshot.cost
|
|
335
|
+
},
|
|
336
|
+
attribution?.model ?? record.model ?? options.model,
|
|
337
|
+
attribution?.provider
|
|
338
|
+
);
|
|
339
|
+
lastEmittedUsage.input = snapshot.input;
|
|
340
|
+
lastEmittedUsage.output = snapshot.output;
|
|
341
|
+
lastEmittedUsage.cacheRead = snapshot.cacheRead;
|
|
342
|
+
lastEmittedUsage.cacheWrite = snapshot.cacheWrite;
|
|
343
|
+
lastEmittedUsage.cost = snapshot.cost;
|
|
344
|
+
};
|
|
345
|
+
const { ChildCompactControl } = await loadCompactControl();
|
|
346
|
+
const compactControl = new ChildCompactControl(options.id, {
|
|
347
|
+
send(frame) {
|
|
348
|
+
if (!child.stdin || child.stdin.writableEnded || child.stdin.destroyed) {
|
|
349
|
+
throw new Error("Child OMP stdin closed before compaction could start");
|
|
350
|
+
}
|
|
351
|
+
child.stdin.write(`${JSON.stringify(frame)}
|
|
352
|
+
`);
|
|
353
|
+
},
|
|
354
|
+
close() {
|
|
355
|
+
child.stdin?.end();
|
|
356
|
+
},
|
|
357
|
+
update(status) {
|
|
358
|
+
record.compaction = status;
|
|
359
|
+
update();
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
const enforceTokenLimit = () => {
|
|
363
|
+
if (terminalStatus || !options.maxTokens || options.maxTokens <= 0) return;
|
|
364
|
+
const total = record.usage.input + record.usage.output + record.usage.cacheRead + record.usage.cacheWrite;
|
|
365
|
+
if (total <= options.maxTokens) return;
|
|
366
|
+
terminalStatus = "timed_out";
|
|
367
|
+
terminalError = `Fabric token limit reached: ${total} tokens (limit ${options.maxTokens} set by agents.maxTokensPerChild); terminating child. The count is cumulative across the run and includes cache reads/writes, so it grows every turn; raise or disable agents.maxTokensPerChild in /fabric settings (0 disables), or split the task into smaller agent runs.`;
|
|
368
|
+
terminateChild(child, "SIGTERM");
|
|
369
|
+
setTimeout(() => terminateChild(child, "SIGKILL"), KILL_GRACE_MS).unref();
|
|
370
|
+
child.stdin?.end();
|
|
371
|
+
};
|
|
372
|
+
const claudeTools = /* @__PURE__ */ new Map();
|
|
373
|
+
const claudeCompletedUsage = emptyUsage();
|
|
374
|
+
const claudeCurrentUsage = emptyUsage();
|
|
375
|
+
const syncClaudeUsage = () => {
|
|
376
|
+
record.usage = {
|
|
377
|
+
input: claudeCompletedUsage.input + claudeCurrentUsage.input,
|
|
378
|
+
output: claudeCompletedUsage.output + claudeCurrentUsage.output,
|
|
379
|
+
cacheRead: claudeCompletedUsage.cacheRead + claudeCurrentUsage.cacheRead,
|
|
380
|
+
cacheWrite: claudeCompletedUsage.cacheWrite + claudeCurrentUsage.cacheWrite,
|
|
381
|
+
cost: claudeCompletedUsage.cost
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
const claudeSentInputs = [];
|
|
385
|
+
const claudeSteering = [];
|
|
386
|
+
const claudeFollowUps = [];
|
|
387
|
+
let claudeSteeringMode = "one-at-a-time";
|
|
388
|
+
let claudeFollowUpMode = "one-at-a-time";
|
|
389
|
+
let claudeCanFollowUp = false;
|
|
390
|
+
let claudeResultSeen = false;
|
|
391
|
+
const enqueueClaudeControl = (queue, message) => {
|
|
392
|
+
const pendingInputs = claudeSentInputs.length + claudeSteering.length + claudeFollowUps.length;
|
|
393
|
+
if (pendingInputs >= MAX_CLAUDE_PENDING_INPUTS) return;
|
|
394
|
+
queue.push(message);
|
|
395
|
+
};
|
|
396
|
+
let claudeCloseTimer;
|
|
397
|
+
const updateClaudeQueue = () => {
|
|
398
|
+
const sentSteering = claudeSentInputs.filter((entry) => entry.kind === "steer").map((entry) => entry.message);
|
|
399
|
+
const sentFollowUps = claudeSentInputs.filter((entry) => entry.kind === "follow_up").map((entry) => entry.message);
|
|
400
|
+
record.pendingMessages = {
|
|
401
|
+
steering: [...sentSteering, ...claudeSteering],
|
|
402
|
+
followUp: [...sentFollowUps, ...claudeFollowUps]
|
|
403
|
+
};
|
|
404
|
+
update();
|
|
405
|
+
};
|
|
406
|
+
const writeClaudeInput = (kind, message, inputImages = []) => {
|
|
407
|
+
if (claudeCloseTimer) clearTimeout(claudeCloseTimer);
|
|
408
|
+
claudeCloseTimer = void 0;
|
|
409
|
+
if (!child.stdin || child.stdin.writableEnded || child.stdin.destroyed) return;
|
|
410
|
+
claudeSentInputs.push({ kind, message });
|
|
411
|
+
if (kind === "follow_up") claudeCanFollowUp = false;
|
|
412
|
+
child.stdin.write(
|
|
413
|
+
`${JSON.stringify(claudeCli.claudeUserMessage(message, inputImages))}
|
|
414
|
+
`
|
|
415
|
+
);
|
|
416
|
+
updateClaudeQueue();
|
|
417
|
+
};
|
|
418
|
+
const flushClaudeSteering = () => {
|
|
419
|
+
if (claudeSteering.length === 0) return;
|
|
420
|
+
const alreadySent = claudeSentInputs.some((entry) => entry.kind === "steer");
|
|
421
|
+
if (claudeSteeringMode === "one-at-a-time" && alreadySent) return;
|
|
422
|
+
const count = claudeSteeringMode === "all" ? claudeSteering.length : 1;
|
|
423
|
+
for (const message of claudeSteering.splice(0, count)) {
|
|
424
|
+
writeClaudeInput("steer", message);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
const flushClaudeFollowUps = () => {
|
|
428
|
+
if (claudeFollowUps.length === 0 || claudeSteering.length > 0) return;
|
|
429
|
+
if (claudeSentInputs.some((entry) => entry.kind === "steer")) return;
|
|
430
|
+
const alreadySent = claudeSentInputs.some((entry) => entry.kind === "follow_up");
|
|
431
|
+
if (claudeFollowUpMode === "one-at-a-time" && alreadySent) return;
|
|
432
|
+
const count = claudeFollowUpMode === "all" ? claudeFollowUps.length : 1;
|
|
433
|
+
for (const message of claudeFollowUps.splice(0, count)) {
|
|
434
|
+
writeClaudeInput("follow_up", message);
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
const scheduleClaudeClose = () => {
|
|
438
|
+
if (claudeCloseTimer || terminalStatus) return;
|
|
439
|
+
claudeCloseTimer = setTimeout(() => {
|
|
440
|
+
claudeCloseTimer = void 0;
|
|
441
|
+
if (claudeSentInputs.length === 0 && claudeSteering.length === 0 && claudeFollowUps.length === 0) {
|
|
442
|
+
child.stdin?.end();
|
|
443
|
+
}
|
|
444
|
+
}, 300);
|
|
445
|
+
claudeCloseTimer.unref();
|
|
446
|
+
};
|
|
447
|
+
const processClaudeEvent = (event) => {
|
|
448
|
+
if (event.type === "system" && event.subtype === "init") {
|
|
449
|
+
const sessionId2 = stringField(event.session_id);
|
|
450
|
+
if (sessionId2) record.runnerSessionId = sessionId2;
|
|
451
|
+
const model = stringField(event.model);
|
|
452
|
+
if (model && !record.model) record.model = model;
|
|
453
|
+
update();
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
if (event.type === "assistant") {
|
|
457
|
+
const message = event.message;
|
|
458
|
+
if (typeof message !== "object" || message === null || Array.isArray(message)) return;
|
|
459
|
+
const assistant = message;
|
|
460
|
+
const text = extractText(assistant);
|
|
461
|
+
if (text) {
|
|
462
|
+
record.text = latestRunText(text);
|
|
463
|
+
process.stdout.write(`
|
|
464
|
+
${text}
|
|
465
|
+
`);
|
|
466
|
+
}
|
|
467
|
+
const content = assistant.content;
|
|
468
|
+
if (Array.isArray(content)) {
|
|
469
|
+
for (const block of content) {
|
|
470
|
+
if (typeof block !== "object" || block === null || Array.isArray(block)) continue;
|
|
471
|
+
const part = block;
|
|
472
|
+
if (part.type !== "tool_use") continue;
|
|
473
|
+
const id = stringField(part.id);
|
|
474
|
+
const name = stringField(part.name);
|
|
475
|
+
if (!id || !name || claudeTools.has(id)) continue;
|
|
476
|
+
claudeTools.set(id, name);
|
|
477
|
+
while (claudeTools.size > MAX_CLAUDE_PENDING_TOOLS) {
|
|
478
|
+
const oldestToolId = claudeTools.keys().next().value;
|
|
479
|
+
if (oldestToolId === void 0) break;
|
|
480
|
+
claudeTools.delete(oldestToolId);
|
|
481
|
+
}
|
|
482
|
+
record.toolCalls++;
|
|
483
|
+
record.currentTool = name;
|
|
484
|
+
process.stdout.write(`\u2192 ${name}
|
|
485
|
+
`);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
const usage = assistant.usage;
|
|
489
|
+
if (typeof usage === "object" && usage !== null && !Array.isArray(usage)) {
|
|
490
|
+
const values = usage;
|
|
491
|
+
const delta = {
|
|
492
|
+
input: numberField(values.input_tokens),
|
|
493
|
+
output: numberField(values.output_tokens),
|
|
494
|
+
cacheRead: numberField(values.cache_read_input_tokens),
|
|
495
|
+
cacheWrite: numberField(values.cache_creation_input_tokens),
|
|
496
|
+
cost: 0
|
|
497
|
+
};
|
|
498
|
+
claudeCurrentUsage.input += delta.input;
|
|
499
|
+
claudeCurrentUsage.output += delta.output;
|
|
500
|
+
claudeCurrentUsage.cacheRead += delta.cacheRead;
|
|
501
|
+
claudeCurrentUsage.cacheWrite += delta.cacheWrite;
|
|
502
|
+
syncClaudeUsage();
|
|
503
|
+
emitTokenUsage(delta, { model: record.model ?? stringField(event.model) });
|
|
504
|
+
}
|
|
505
|
+
if (typeof event.error === "string") {
|
|
506
|
+
sawAgentError = true;
|
|
507
|
+
terminalError = event.error;
|
|
508
|
+
}
|
|
509
|
+
enforceTokenLimit();
|
|
510
|
+
update();
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
if (event.type === "user") {
|
|
514
|
+
const message = event.message;
|
|
515
|
+
if (typeof message !== "object" || message === null || Array.isArray(message)) return;
|
|
516
|
+
const content = message.content;
|
|
517
|
+
if (!Array.isArray(content)) return;
|
|
518
|
+
for (const block of content) {
|
|
519
|
+
if (typeof block !== "object" || block === null || Array.isArray(block)) continue;
|
|
520
|
+
const part = block;
|
|
521
|
+
if (part.type !== "tool_result") continue;
|
|
522
|
+
const id = stringField(part.tool_use_id);
|
|
523
|
+
if (id) claudeTools.delete(id);
|
|
524
|
+
}
|
|
525
|
+
const current = [...claudeTools.values()].at(-1);
|
|
526
|
+
if (current) record.currentTool = current;
|
|
527
|
+
else delete record.currentTool;
|
|
528
|
+
update();
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (event.type === "stream_event") {
|
|
532
|
+
const streamEvent = event.event;
|
|
533
|
+
if (typeof streamEvent !== "object" || streamEvent === null || Array.isArray(streamEvent)) return;
|
|
534
|
+
const stream = streamEvent;
|
|
535
|
+
if (stream.type !== "content_block_start") return;
|
|
536
|
+
const contentBlock = stream.content_block;
|
|
537
|
+
if (typeof contentBlock !== "object" || contentBlock === null || Array.isArray(contentBlock)) return;
|
|
538
|
+
const block = contentBlock;
|
|
539
|
+
const name = stringField(block.name);
|
|
540
|
+
if (block.type === "tool_use" && name) {
|
|
541
|
+
record.currentTool = name;
|
|
542
|
+
update();
|
|
543
|
+
}
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
if (event.type !== "result") return;
|
|
547
|
+
claudeResultSeen = true;
|
|
548
|
+
const sessionId = stringField(event.session_id);
|
|
549
|
+
if (sessionId) record.runnerSessionId = sessionId;
|
|
550
|
+
const resultText = typeof event.result === "string" ? event.result : "";
|
|
551
|
+
if (resultText) record.text = latestRunText(resultText);
|
|
552
|
+
if (event.structured_output !== void 0) record.value = event.structured_output;
|
|
553
|
+
record.turns += Math.max(0, Math.floor(numberField(event.num_turns)));
|
|
554
|
+
const resultUsage = typeof event.usage === "object" && event.usage !== null && !Array.isArray(event.usage) ? event.usage : void 0;
|
|
555
|
+
const resultDelta = resultUsage ? {
|
|
556
|
+
input: numberField(resultUsage.input_tokens) - claudeCurrentUsage.input,
|
|
557
|
+
output: numberField(resultUsage.output_tokens) - claudeCurrentUsage.output,
|
|
558
|
+
cacheRead: numberField(resultUsage.cache_read_input_tokens) - claudeCurrentUsage.cacheRead,
|
|
559
|
+
cacheWrite: numberField(resultUsage.cache_creation_input_tokens) - claudeCurrentUsage.cacheWrite,
|
|
560
|
+
cost: Math.max(0, numberField(event.total_cost_usd))
|
|
561
|
+
} : { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: Math.max(0, numberField(event.total_cost_usd)) };
|
|
562
|
+
claudeCompletedUsage.input += resultUsage ? numberField(resultUsage.input_tokens) : claudeCurrentUsage.input;
|
|
563
|
+
claudeCompletedUsage.output += resultUsage ? numberField(resultUsage.output_tokens) : claudeCurrentUsage.output;
|
|
564
|
+
claudeCompletedUsage.cacheRead += resultUsage ? numberField(resultUsage.cache_read_input_tokens) : claudeCurrentUsage.cacheRead;
|
|
565
|
+
claudeCompletedUsage.cacheWrite += resultUsage ? numberField(resultUsage.cache_creation_input_tokens) : claudeCurrentUsage.cacheWrite;
|
|
566
|
+
claudeCompletedUsage.cost += Math.max(0, numberField(event.total_cost_usd));
|
|
567
|
+
claudeCurrentUsage.input = 0;
|
|
568
|
+
claudeCurrentUsage.output = 0;
|
|
569
|
+
claudeCurrentUsage.cacheRead = 0;
|
|
570
|
+
claudeCurrentUsage.cacheWrite = 0;
|
|
571
|
+
syncClaudeUsage();
|
|
572
|
+
emitTokenUsage(resultDelta, { model: record.model ?? stringField(event.model) });
|
|
573
|
+
enforceTokenLimit();
|
|
574
|
+
const failed = event.is_error === true || event.subtype !== "success";
|
|
575
|
+
if (failed) {
|
|
576
|
+
sawAgentError = true;
|
|
577
|
+
const errors = Array.isArray(event.errors) ? event.errors.filter((value) => typeof value === "string").join(" \xB7 ") : "";
|
|
578
|
+
terminalError = errors || resultText || `Claude returned ${String(event.subtype ?? "an error")}`;
|
|
579
|
+
claudeSteering.splice(0);
|
|
580
|
+
claudeFollowUps.splice(0);
|
|
581
|
+
} else {
|
|
582
|
+
sawAgentError = false;
|
|
583
|
+
if (!terminalStatus) terminalError = void 0;
|
|
584
|
+
}
|
|
585
|
+
if (failed || terminalStatus) claudeSentInputs.splice(0);
|
|
586
|
+
else claudeSentInputs.shift();
|
|
587
|
+
claudeCanFollowUp = !failed && !terminalStatus;
|
|
588
|
+
delete record.currentTool;
|
|
589
|
+
updateClaudeQueue();
|
|
590
|
+
if (failed || terminalStatus) {
|
|
591
|
+
child.stdin?.end();
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
flushClaudeSteering();
|
|
595
|
+
if (claudeSentInputs.length === 0 && claudeSteering.length === 0) {
|
|
596
|
+
flushClaudeFollowUps();
|
|
597
|
+
}
|
|
598
|
+
if (claudeSentInputs.length === 0 && claudeSteering.length === 0 && claudeFollowUps.length === 0) {
|
|
599
|
+
scheduleClaudeClose();
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
const processEvent = (line) => {
|
|
603
|
+
if (process.env.OMP_FABRIC_INJECT_CRASH === "stream") throw new Error("simulated stream crash");
|
|
604
|
+
if (!line.trim()) return;
|
|
605
|
+
appendLog(`${line}
|
|
606
|
+
`);
|
|
607
|
+
sessionStream?.write(`${line}
|
|
608
|
+
`);
|
|
609
|
+
let event;
|
|
610
|
+
try {
|
|
611
|
+
const parsed = JSON.parse(line);
|
|
612
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return;
|
|
613
|
+
event = parsed;
|
|
614
|
+
} catch {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
if (options.runner === "claude") {
|
|
618
|
+
processClaudeEvent(event);
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
compactControl.observe(event);
|
|
622
|
+
if (event.type === "agent_start") {
|
|
623
|
+
emitLifecycle("omp.agent_start");
|
|
624
|
+
retryPending = false;
|
|
625
|
+
sawAgentError = false;
|
|
626
|
+
terminalError = void 0;
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
if (event.type === "response" && event.command === "prompt" && event.success === false) {
|
|
630
|
+
sawAgentError = true;
|
|
631
|
+
terminalError = typeof event.error === "string" ? event.error : "OMP rejected the prompt";
|
|
632
|
+
child.stdin?.end();
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
if (event.type === "extension_ui_request") {
|
|
636
|
+
const method = event.method;
|
|
637
|
+
if (typeof event.id === "string" && (method === "select" || method === "confirm" || method === "input" || method === "editor")) {
|
|
638
|
+
child.stdin?.write(
|
|
639
|
+
`${JSON.stringify({ type: "extension_ui_response", id: event.id, cancelled: true })}
|
|
640
|
+
`
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
if (event.type === "tool_execution_start") {
|
|
646
|
+
record.toolCalls++;
|
|
647
|
+
if (typeof event.toolName === "string") {
|
|
648
|
+
record.currentTool = event.toolName;
|
|
649
|
+
process.stdout.write(`\u2192 ${event.toolName}
|
|
650
|
+
`);
|
|
651
|
+
}
|
|
652
|
+
update();
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
if (event.type === "tool_execution_end") {
|
|
656
|
+
if (event.isError === true) {
|
|
657
|
+
emitLifecycle("omp.tool_error", {
|
|
658
|
+
...typeof event.toolCallId === "string" ? { toolCallId: event.toolCallId } : {},
|
|
659
|
+
...typeof event.toolName === "string" ? { toolName: event.toolName } : {}
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
delete record.currentTool;
|
|
663
|
+
update();
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
if (event.type === "turn_end") {
|
|
667
|
+
emitLifecycle("omp.turn_end", {
|
|
668
|
+
...typeof event.turnIndex === "number" ? { turnIndex: event.turnIndex } : {}
|
|
669
|
+
});
|
|
670
|
+
record.turns++;
|
|
671
|
+
update();
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
if (event.type === "queue_update") {
|
|
675
|
+
const steering = Array.isArray(event.steering) ? event.steering.filter((value) => typeof value === "string") : [];
|
|
676
|
+
const followUp = Array.isArray(event.followUp) ? event.followUp.filter((value) => typeof value === "string") : [];
|
|
677
|
+
record.pendingMessages = { steering, followUp };
|
|
678
|
+
update();
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (event.type === "message_end") {
|
|
682
|
+
const message = event.message;
|
|
683
|
+
if (typeof message !== "object" || message === null || Array.isArray(message)) return;
|
|
684
|
+
const messageRecord = message;
|
|
685
|
+
if (messageRecord.role !== "assistant") return;
|
|
686
|
+
const text = extractText(messageRecord);
|
|
687
|
+
if (text) {
|
|
688
|
+
record.text = latestRunText(text);
|
|
689
|
+
process.stdout.write(`
|
|
690
|
+
${text}
|
|
691
|
+
`);
|
|
692
|
+
}
|
|
693
|
+
const usageDelta = extractUsageDelta(messageRecord);
|
|
694
|
+
applyUsage(record, messageRecord);
|
|
695
|
+
emitTokenUsage(usageDelta, {
|
|
696
|
+
model: stringField(messageRecord.model),
|
|
697
|
+
provider: stringField(messageRecord.provider)
|
|
698
|
+
});
|
|
699
|
+
enforceTokenLimit();
|
|
700
|
+
if (messageRecord.stopReason === "error") {
|
|
701
|
+
sawAgentError = true;
|
|
702
|
+
terminalError = assistantError(messageRecord);
|
|
703
|
+
} else {
|
|
704
|
+
sawAgentError = false;
|
|
705
|
+
if (!terminalStatus) terminalError = void 0;
|
|
706
|
+
}
|
|
707
|
+
update();
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
if (event.type === "agent_end") {
|
|
711
|
+
retryPending = event.isTerminal === false;
|
|
712
|
+
emitLifecycle("omp.agent_end", { isTerminal: !retryPending });
|
|
713
|
+
if (!retryPending) {
|
|
714
|
+
pollSteer();
|
|
715
|
+
compactControl.childSettled();
|
|
716
|
+
}
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
if (event.type === "auto_compaction_start") {
|
|
720
|
+
lastCompactionReason = typeof event.reason === "string" ? event.reason : void 0;
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
if (event.type === "auto_compaction_end") {
|
|
724
|
+
emitLifecycle("omp.session_compact", {
|
|
725
|
+
...lastCompactionReason !== void 0 ? { reason: lastCompactionReason } : {},
|
|
726
|
+
...typeof event.willRetry === "boolean" ? { willRetry: event.willRetry } : {},
|
|
727
|
+
...typeof event.aborted === "boolean" ? { aborted: event.aborted } : {}
|
|
728
|
+
});
|
|
729
|
+
lastCompactionReason = void 0;
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
if (event.type === "extension_error") {
|
|
733
|
+
const error = typeof event.error === "string" ? event.error : "Extension error";
|
|
734
|
+
stderr = `${stderr}
|
|
735
|
+
${error}`.trim().slice(-MAX_STDERR_CHARS);
|
|
736
|
+
update();
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
child.stdin?.on("error", () => {
|
|
740
|
+
});
|
|
741
|
+
if (options.runner === "claude") {
|
|
742
|
+
writeClaudeInput("initial", task, images);
|
|
743
|
+
} else if (options.runner === "veda") {
|
|
744
|
+
const sections = [];
|
|
745
|
+
if (options.systemPrompt) {
|
|
746
|
+
sections.push(`<system_instructions>
|
|
747
|
+
${options.systemPrompt}
|
|
748
|
+
</system_instructions>`);
|
|
749
|
+
}
|
|
750
|
+
if (schema) {
|
|
751
|
+
sections.push(
|
|
752
|
+
`Your final response must contain only JSON matching this schema, without Markdown fences:
|
|
753
|
+
${schema}`
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
sections.push(task);
|
|
757
|
+
child.stdin?.write(sections.join("\n\n"));
|
|
758
|
+
child.stdin?.end();
|
|
759
|
+
} else {
|
|
760
|
+
child.stdin?.write(
|
|
761
|
+
`${JSON.stringify({
|
|
762
|
+
type: "prompt",
|
|
763
|
+
message: task,
|
|
764
|
+
...images.length > 0 ? { images } : {}
|
|
765
|
+
})}
|
|
766
|
+
`
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
let steerOffset = 0;
|
|
770
|
+
let steerRemainder = Buffer.alloc(0);
|
|
771
|
+
let skippingOversizedSteerLine = false;
|
|
772
|
+
const pollSteer = () => {
|
|
773
|
+
if (!options.steerFile || terminalStatus) return;
|
|
774
|
+
let descriptor;
|
|
775
|
+
try {
|
|
776
|
+
descriptor = fs.openSync(options.steerFile, "r");
|
|
777
|
+
} catch {
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
try {
|
|
781
|
+
const size = fs.fstatSync(descriptor).size;
|
|
782
|
+
if (size < steerOffset) {
|
|
783
|
+
steerOffset = 0;
|
|
784
|
+
steerRemainder = Buffer.alloc(0);
|
|
785
|
+
skippingOversizedSteerLine = false;
|
|
786
|
+
}
|
|
787
|
+
if (size <= steerOffset) return;
|
|
788
|
+
const length = Math.min(size - steerOffset, STEER_READ_CHUNK_BYTES);
|
|
789
|
+
const buffer = Buffer.allocUnsafe(length);
|
|
790
|
+
const bytesRead = fs.readSync(descriptor, buffer, 0, length, steerOffset);
|
|
791
|
+
steerOffset += bytesRead;
|
|
792
|
+
let combined = Buffer.concat([steerRemainder, buffer.subarray(0, bytesRead)]);
|
|
793
|
+
if (skippingOversizedSteerLine) {
|
|
794
|
+
const skippedLineEnd = combined.indexOf(10);
|
|
795
|
+
if (skippedLineEnd < 0) return;
|
|
796
|
+
combined = combined.subarray(skippedLineEnd + 1);
|
|
797
|
+
skippingOversizedSteerLine = false;
|
|
798
|
+
}
|
|
799
|
+
const newline = combined.lastIndexOf(10);
|
|
800
|
+
if (newline < 0) {
|
|
801
|
+
if (combined.length > MAX_STEER_LINE_BYTES) {
|
|
802
|
+
steerRemainder = Buffer.alloc(0);
|
|
803
|
+
skippingOversizedSteerLine = true;
|
|
804
|
+
} else {
|
|
805
|
+
steerRemainder = Buffer.from(combined);
|
|
806
|
+
}
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
const remainder = combined.subarray(newline + 1);
|
|
810
|
+
if (remainder.length > MAX_STEER_LINE_BYTES) {
|
|
811
|
+
steerRemainder = Buffer.alloc(0);
|
|
812
|
+
skippingOversizedSteerLine = true;
|
|
813
|
+
} else {
|
|
814
|
+
steerRemainder = Buffer.from(remainder);
|
|
815
|
+
}
|
|
816
|
+
let processedCommands = 0;
|
|
817
|
+
for (const raw of combined.subarray(0, newline + 1).toString("utf8").split("\n")) {
|
|
818
|
+
if (processedCommands >= MAX_STEER_COMMANDS_PER_POLL) break;
|
|
819
|
+
if (Buffer.byteLength(raw, "utf8") > MAX_STEER_LINE_BYTES) continue;
|
|
820
|
+
const line = raw.trim();
|
|
821
|
+
if (!line) continue;
|
|
822
|
+
processedCommands += 1;
|
|
823
|
+
let command;
|
|
824
|
+
try {
|
|
825
|
+
command = JSON.parse(line);
|
|
826
|
+
} catch {
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
try {
|
|
830
|
+
if (options.runner === "claude") {
|
|
831
|
+
if (claudeCloseTimer) clearTimeout(claudeCloseTimer);
|
|
832
|
+
claudeCloseTimer = void 0;
|
|
833
|
+
if (command.type === "steer" && typeof command.message === "string") {
|
|
834
|
+
enqueueClaudeControl(claudeSteering, command.message);
|
|
835
|
+
flushClaudeSteering();
|
|
836
|
+
} else if (command.type === "follow_up" && typeof command.message === "string") {
|
|
837
|
+
enqueueClaudeControl(claudeFollowUps, command.message);
|
|
838
|
+
if (claudeCanFollowUp && claudeSentInputs.length === 0) flushClaudeFollowUps();
|
|
839
|
+
} else if (command.type === "set_steering_mode" && (command.mode === "all" || command.mode === "one-at-a-time")) {
|
|
840
|
+
claudeSteeringMode = command.mode;
|
|
841
|
+
flushClaudeSteering();
|
|
842
|
+
} else if (command.type === "set_follow_up_mode" && (command.mode === "all" || command.mode === "one-at-a-time")) {
|
|
843
|
+
claudeFollowUpMode = command.mode;
|
|
844
|
+
if (claudeCanFollowUp && claudeSentInputs.length === 0) flushClaudeFollowUps();
|
|
845
|
+
}
|
|
846
|
+
updateClaudeQueue();
|
|
847
|
+
} else if (options.runner === "veda") {
|
|
848
|
+
} else if (command.type === "steer" && typeof command.message === "string") {
|
|
849
|
+
child.stdin?.write(JSON.stringify({ type: "steer", message: command.message }) + "\n");
|
|
850
|
+
} else if (command.type === "follow_up" && typeof command.message === "string") {
|
|
851
|
+
child.stdin?.write(JSON.stringify({ type: "follow_up", message: command.message }) + "\n");
|
|
852
|
+
} else if (command.type === "set_steering_mode" && typeof command.mode === "string") {
|
|
853
|
+
child.stdin?.write(JSON.stringify({ type: "set_steering_mode", mode: command.mode }) + "\n");
|
|
854
|
+
} else if (command.type === "set_follow_up_mode" && typeof command.mode === "string") {
|
|
855
|
+
child.stdin?.write(JSON.stringify({ type: "set_follow_up_mode", mode: command.mode }) + "\n");
|
|
856
|
+
} else if (command.type === "compact") {
|
|
857
|
+
compactControl.queue(command.instructions);
|
|
858
|
+
}
|
|
859
|
+
} catch {
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
} finally {
|
|
863
|
+
fs.closeSync(descriptor);
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
const steerTimer = options.steerFile ? setInterval(pollSteer, 200) : void 0;
|
|
867
|
+
steerTimer?.unref?.();
|
|
868
|
+
const failOversizedEvent = (line) => {
|
|
869
|
+
const prefix = line.slice(0, MAX_EVENT_LINE_CHARS);
|
|
870
|
+
let artifactPath;
|
|
871
|
+
try {
|
|
872
|
+
artifactPath = path.join(path.dirname(options.logFile), "oversized-event-prefix.txt");
|
|
873
|
+
fs.writeFileSync(artifactPath, prefix, { encoding: "utf8", mode: 384 });
|
|
874
|
+
} catch {
|
|
875
|
+
artifactPath = void 0;
|
|
876
|
+
}
|
|
877
|
+
terminalStatus = "failed";
|
|
878
|
+
terminalError = artifactPath ? `Agent emitted an oversized event line; first ${prefix.length} characters saved to: ${artifactPath}` : "Agent emitted an oversized event line";
|
|
879
|
+
outputBuffer = "";
|
|
880
|
+
terminateChild(child, "SIGTERM");
|
|
881
|
+
};
|
|
882
|
+
child.stdout?.on("data", (chunk) => {
|
|
883
|
+
const decoded = outputDecoder.write(chunk);
|
|
884
|
+
if (options.runner === "veda") {
|
|
885
|
+
vedaOutput += decoded;
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
outputBuffer += decoded;
|
|
889
|
+
while (true) {
|
|
890
|
+
const newline = outputBuffer.indexOf("\n");
|
|
891
|
+
if (newline < 0) {
|
|
892
|
+
if (outputBuffer.length > MAX_EVENT_LINE_CHARS) {
|
|
893
|
+
failOversizedEvent(outputBuffer);
|
|
894
|
+
}
|
|
895
|
+
break;
|
|
896
|
+
}
|
|
897
|
+
if (newline > MAX_EVENT_LINE_CHARS) {
|
|
898
|
+
failOversizedEvent(outputBuffer.slice(0, newline));
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
const line = outputBuffer.slice(0, newline).replace(/\r$/, "");
|
|
902
|
+
outputBuffer = outputBuffer.slice(newline + 1);
|
|
903
|
+
processEvent(line);
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
const recordStderr = (text) => {
|
|
907
|
+
if (!text) return;
|
|
908
|
+
appendLog(`${JSON.stringify({ type: "worker_stderr", text })}
|
|
909
|
+
`);
|
|
910
|
+
process.stderr.write(text);
|
|
911
|
+
stderr = `${stderr}${text}`.slice(-MAX_STDERR_CHARS);
|
|
912
|
+
};
|
|
913
|
+
child.stderr?.on("data", (chunk) => {
|
|
914
|
+
recordStderr(stderrDecoder.write(chunk));
|
|
915
|
+
});
|
|
916
|
+
child.stderr?.on("error", () => {
|
|
917
|
+
});
|
|
918
|
+
const timeout = setTimeout(() => {
|
|
919
|
+
terminalStatus = "timed_out";
|
|
920
|
+
terminalError = `Agent timed out after ${options.timeoutMs}ms`;
|
|
921
|
+
terminateChild(child, "SIGTERM");
|
|
922
|
+
setTimeout(() => terminateChild(child, "SIGKILL"), KILL_GRACE_MS).unref();
|
|
923
|
+
}, options.timeoutMs);
|
|
924
|
+
timeout.unref();
|
|
925
|
+
const stop = () => {
|
|
926
|
+
if (terminalStatus) return;
|
|
927
|
+
terminalStatus = "stopped";
|
|
928
|
+
terminalError = "Agent stopped";
|
|
929
|
+
terminateChild(child, "SIGTERM");
|
|
930
|
+
setTimeout(() => terminateChild(child, "SIGKILL"), KILL_GRACE_MS).unref();
|
|
931
|
+
};
|
|
932
|
+
process.once("SIGTERM", stop);
|
|
933
|
+
process.once("SIGINT", stop);
|
|
934
|
+
process.once("SIGHUP", stop);
|
|
935
|
+
const exitCode = await new Promise((resolve) => {
|
|
936
|
+
child.once("error", (error) => {
|
|
937
|
+
terminalStatus = "failed";
|
|
938
|
+
terminalError = error.message;
|
|
939
|
+
resolve(null);
|
|
940
|
+
});
|
|
941
|
+
child.once("close", (code) => resolve(code));
|
|
942
|
+
});
|
|
943
|
+
if (steerTimer) clearInterval(steerTimer);
|
|
944
|
+
if (claudeCloseTimer) clearTimeout(claudeCloseTimer);
|
|
945
|
+
clearTimeout(timeout);
|
|
946
|
+
if (process.env.OMP_FABRIC_INJECT_CRASH === "close") throw new Error("simulated close crash");
|
|
947
|
+
if (options.runner === "veda") {
|
|
948
|
+
vedaOutput += outputDecoder.end();
|
|
949
|
+
} else {
|
|
950
|
+
outputBuffer += outputDecoder.end();
|
|
951
|
+
}
|
|
952
|
+
recordStderr(stderrDecoder.end());
|
|
953
|
+
if (options.runner === "veda") {
|
|
954
|
+
const trimmed = vedaOutput.trim();
|
|
955
|
+
if (trimmed) {
|
|
956
|
+
try {
|
|
957
|
+
const parsed = parseStructuredValue(trimmed);
|
|
958
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
959
|
+
vedaParsed = parsed;
|
|
960
|
+
const text = stringField(vedaParsed.text) ?? "";
|
|
961
|
+
if (text) {
|
|
962
|
+
record.text = latestRunText(text);
|
|
963
|
+
process.stdout.write(`
|
|
964
|
+
${text}
|
|
965
|
+
`);
|
|
966
|
+
}
|
|
967
|
+
const sessionId = stringField(vedaParsed.sessionId);
|
|
968
|
+
if (sessionId) record.runnerSessionId = sessionId;
|
|
969
|
+
const usage = vedaParsed.usage;
|
|
970
|
+
if (typeof usage === "object" && usage !== null && !Array.isArray(usage)) {
|
|
971
|
+
const values = usage;
|
|
972
|
+
const input = numberField(values.inputTokens);
|
|
973
|
+
const output = numberField(values.outputTokens);
|
|
974
|
+
const cacheRead = numberField(values.cachedTokens);
|
|
975
|
+
const cost = typeof values.costUsd === "number" ? values.costUsd : 0;
|
|
976
|
+
record.usage = { input, output, cacheRead, cacheWrite: 0, cost };
|
|
977
|
+
emitTokenUsage({ input, output, cacheRead, cacheWrite: 0, cost }, { model: stringField(vedaParsed.model) });
|
|
978
|
+
}
|
|
979
|
+
const envelopeErrors = [];
|
|
980
|
+
const error = stringField(vedaParsed.error);
|
|
981
|
+
if (error) envelopeErrors.push(error);
|
|
982
|
+
for (const key of ["design", "worker"]) {
|
|
983
|
+
const gate = vedaParsed[key];
|
|
984
|
+
if (typeof gate !== "object" || gate === null || Array.isArray(gate)) continue;
|
|
985
|
+
const status = gate;
|
|
986
|
+
if (status.ok !== false) continue;
|
|
987
|
+
const details = Array.isArray(status.errors) ? status.errors.filter((entry) => typeof entry === "string").join("; ") : [stringField(status.reason), stringField(status.detail)].filter((entry) => entry !== void 0).join(": ");
|
|
988
|
+
envelopeErrors.push(`Veda ${key} failed${details ? `: ${details}` : ""}`);
|
|
989
|
+
}
|
|
990
|
+
if (envelopeErrors.length > 0) {
|
|
991
|
+
sawAgentError = true;
|
|
992
|
+
terminalError = envelopeErrors.join("\n");
|
|
993
|
+
}
|
|
994
|
+
record.turns += 1;
|
|
995
|
+
update();
|
|
996
|
+
}
|
|
997
|
+
} catch {
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
} else if (outputBuffer.trim()) {
|
|
1001
|
+
processEvent(outputBuffer);
|
|
1002
|
+
}
|
|
1003
|
+
record.exitCode = exitCode;
|
|
1004
|
+
record.stderr = stderr.slice(-MAX_STDERR_CHARS);
|
|
1005
|
+
if (record.compaction?.status === "queued" || record.compaction?.status === "in_flight") {
|
|
1006
|
+
const error = terminalError ?? "Child OMP exited before the queued compaction completed";
|
|
1007
|
+
record.compaction = {
|
|
1008
|
+
...record.compaction,
|
|
1009
|
+
status: "failed",
|
|
1010
|
+
updatedAt: Date.now(),
|
|
1011
|
+
finishedAt: Date.now(),
|
|
1012
|
+
error
|
|
1013
|
+
};
|
|
1014
|
+
if (!terminalStatus) {
|
|
1015
|
+
terminalStatus = "failed";
|
|
1016
|
+
terminalError = error;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
record.finishedAt = Date.now();
|
|
1020
|
+
record.updatedAt = record.finishedAt;
|
|
1021
|
+
const childCompleted = exitCode === 0 && !sawAgentError && (options.runner === "omp" || options.runner === "claude" && claudeResultSeen && claudeSentInputs.length === 0 && claudeSteering.length === 0 && claudeFollowUps.length === 0 || options.runner === "veda" && vedaParsed !== void 0);
|
|
1022
|
+
record.status = terminalStatus ?? (childCompleted ? "completed" : "failed");
|
|
1023
|
+
if (terminalError) record.error = terminalError;
|
|
1024
|
+
if (record.status === "failed" && !record.error) {
|
|
1025
|
+
record.error = stderr.trim() || (exitCode === 0 ? `${runnerLabel(options.runner)} agent reported an error before exiting` : `${runnerLabel(options.runner)} exited with code ${exitCode ?? "unknown"}`);
|
|
1026
|
+
}
|
|
1027
|
+
if (record.status === "completed" && options.schemaFile) {
|
|
1028
|
+
try {
|
|
1029
|
+
const schema2 = JSON.parse(fs.readFileSync(options.schemaFile, "utf8"));
|
|
1030
|
+
const value = record.value ?? parseStructuredValue(record.text);
|
|
1031
|
+
const validation = validateJsonSchemaValue(schema2, value);
|
|
1032
|
+
if (!validation.success) {
|
|
1033
|
+
const errors = validation.issues.slice(0, 5).map((error) => error.message).join("; ");
|
|
1034
|
+
throw new Error(errors || "value does not match schema");
|
|
1035
|
+
}
|
|
1036
|
+
record.value = value;
|
|
1037
|
+
} catch (error) {
|
|
1038
|
+
record.status = "failed";
|
|
1039
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1040
|
+
const output = record.text.trim();
|
|
1041
|
+
const snippet = output.slice(0, 200);
|
|
1042
|
+
record.error = `Structured agent output was invalid: ${reason}${snippet ? ` (output: ${snippet}${output.length > 200 ? "\u2026" : ""})` : ""}`;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
delete record.currentTool;
|
|
1046
|
+
writeRunRecord(options.statusFile, record);
|
|
1047
|
+
terminalWritten = true;
|
|
1048
|
+
process.stdout.write(`
|
|
1049
|
+
[omp-fabric] ${record.status}
|
|
1050
|
+
`);
|
|
1051
|
+
await new Promise(
|
|
1052
|
+
(resolve) => sessionStream ? sessionStream.end(resolve) : resolve()
|
|
1053
|
+
);
|
|
1054
|
+
process.exitCode = record.status === "completed" ? 0 : 1;
|
|
1055
|
+
};
|
|
1056
|
+
main().catch((error) => {
|
|
1057
|
+
console.error(error instanceof Error ? error.stack ?? error.message : String(error));
|
|
1058
|
+
writeCrashStatus(error);
|
|
1059
|
+
process.exit(1);
|
|
1060
|
+
});
|
|
1061
|
+
//# sourceMappingURL=worker.js.map
|