pi-fabric 0.50.0 → 0.50.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/chunk-27WW5M4Q.js +1177 -0
- package/dist/chunks/chunk-27WW5M4Q.js.map +7 -0
- package/dist/chunks/chunk-2AJ64IDF.js +773 -0
- package/dist/chunks/chunk-2AJ64IDF.js.map +7 -0
- package/dist/chunks/chunk-3ILAI7MG.js +340 -0
- package/dist/chunks/chunk-3ILAI7MG.js.map +7 -0
- package/dist/chunks/chunk-3RQ6FLPB.js +221 -0
- package/dist/chunks/chunk-3RQ6FLPB.js.map +7 -0
- package/dist/{runtime/quickjs-runtime.js → chunks/chunk-4CPY3VG6.js} +343 -410
- package/dist/chunks/chunk-4CPY3VG6.js.map +7 -0
- package/dist/chunks/chunk-5PNYCGCI.js +5469 -0
- package/dist/chunks/chunk-5PNYCGCI.js.map +7 -0
- package/dist/chunks/chunk-6EU7IVFO.js +110 -0
- package/dist/chunks/chunk-6EU7IVFO.js.map +7 -0
- package/dist/chunks/chunk-7B55UIZL.js +127 -0
- package/dist/chunks/chunk-7B55UIZL.js.map +7 -0
- package/dist/chunks/chunk-7PTKOZBU.js +1236 -0
- package/dist/chunks/chunk-7PTKOZBU.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-CQFP2RCP.js +64 -0
- package/dist/chunks/chunk-CQFP2RCP.js.map +7 -0
- package/dist/chunks/chunk-FJPFWZL4.js +5083 -0
- package/dist/chunks/chunk-FJPFWZL4.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-LDBAR4ZD.js +22 -0
- package/dist/chunks/chunk-LDBAR4ZD.js.map +7 -0
- package/dist/chunks/chunk-MAC56HUK.js +611 -0
- package/dist/chunks/chunk-MAC56HUK.js.map +7 -0
- package/dist/chunks/chunk-NFW7H77W.js +181 -0
- package/dist/chunks/chunk-NFW7H77W.js.map +7 -0
- package/dist/chunks/chunk-NNFA2OIC.js +105 -0
- package/dist/chunks/chunk-NNFA2OIC.js.map +7 -0
- package/dist/chunks/chunk-NPTSAKZW.js +2162 -0
- package/dist/chunks/chunk-NPTSAKZW.js.map +7 -0
- package/dist/chunks/chunk-NSCOEOEP.js +142 -0
- package/dist/chunks/chunk-NSCOEOEP.js.map +7 -0
- package/dist/chunks/chunk-PM5I335G.js +225 -0
- package/dist/chunks/chunk-PM5I335G.js.map +7 -0
- package/dist/chunks/chunk-RXPW7ACJ.js +570 -0
- package/dist/chunks/chunk-RXPW7ACJ.js.map +7 -0
- package/dist/chunks/chunk-TRCPWFCJ.js +122 -0
- package/dist/chunks/chunk-TRCPWFCJ.js.map +7 -0
- package/dist/chunks/chunk-UFD5C2SC.js +172 -0
- package/dist/chunks/chunk-UFD5C2SC.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-WXKXAYZT.js +2220 -0
- package/dist/chunks/chunk-WXKXAYZT.js.map +7 -0
- package/dist/chunks/chunk-XUBVRFGK.js +1011 -0
- package/dist/chunks/chunk-XUBVRFGK.js.map +7 -0
- package/dist/chunks/chunk-Y5PP5IBY.js +628 -0
- package/dist/chunks/chunk-Y5PP5IBY.js.map +7 -0
- package/dist/chunks/claude-cli-RJWGOSBV.js +17 -0
- package/dist/chunks/claude-cli-RJWGOSBV.js.map +7 -0
- package/dist/chunks/compact-control-HOMVGI4X.js +129 -0
- package/dist/chunks/compact-control-HOMVGI4X.js.map +7 -0
- package/dist/chunks/dashboard-ZP6EOGFH.js +4330 -0
- package/dist/chunks/dashboard-ZP6EOGFH.js.map +7 -0
- package/dist/chunks/dynamic-guest-types-7ZQD4IZT.js +226 -0
- package/dist/chunks/dynamic-guest-types-7ZQD4IZT.js.map +7 -0
- package/dist/chunks/fabric-runtime-state-G7KR3NVM.js +8562 -0
- package/dist/chunks/fabric-runtime-state-G7KR3NVM.js.map +7 -0
- package/dist/{runtime/guest-types.js → chunks/guest-types-WPOW4YFS.js} +44 -28
- package/dist/chunks/guest-types-WPOW4YFS.js.map +7 -0
- package/dist/chunks/model-picker-HGNRKC4H.js +17 -0
- package/dist/chunks/model-picker-HGNRKC4H.js.map +7 -0
- package/dist/chunks/node-process-runtime-6FPL5KJY.js +277 -0
- package/dist/chunks/node-process-runtime-6FPL5KJY.js.map +7 -0
- package/dist/chunks/options-OHJJGMV7.js +92 -0
- package/dist/chunks/options-OHJJGMV7.js.map +7 -0
- package/dist/chunks/quickjs-runtime-5G3QEDC3.js +11 -0
- package/dist/chunks/quickjs-runtime-5G3QEDC3.js.map +7 -0
- package/dist/chunks/run-record-7QXZEIN2.js +121 -0
- package/dist/chunks/run-record-7QXZEIN2.js.map +7 -0
- package/dist/chunks/settings-UWBLYYA6.js +1584 -0
- package/dist/chunks/settings-UWBLYYA6.js.map +7 -0
- package/dist/chunks/type-checker-W3FSQG6A.js +11 -0
- package/dist/chunks/type-checker-W3FSQG6A.js.map +7 -0
- package/dist/chunks/veda-cli-GKK22MPY.js +13 -0
- package/dist/chunks/veda-cli-GKK22MPY.js.map +7 -0
- package/dist/commands/fabric.d.ts +1 -1
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/compaction/hook.js +17 -661
- package/dist/compaction/hook.js.map +7 -1
- package/dist/core/action-registry.js +12 -618
- package/dist/core/action-registry.js.map +7 -1
- package/dist/fabric-runtime-state.d.ts +72 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -0
- package/dist/fabric-state.d.ts +36 -27
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4562 -560
- package/dist/index.js.map +7 -1
- package/dist/memory/digest.js +6 -86
- package/dist/memory/digest.js.map +7 -1
- package/dist/memory/discovery.js +18 -139
- package/dist/memory/discovery.js.map +7 -1
- package/dist/memory/normalize.js +21 -692
- package/dist/memory/normalize.js.map +7 -1
- package/dist/memory/search.js +23 -529
- package/dist/memory/search.js.map +7 -1
- package/dist/protocol.js +14 -17
- package/dist/protocol.js.map +7 -1
- package/dist/providers/mcp-advisory.d.ts +10 -0
- package/dist/providers/mcp-advisory.d.ts.map +1 -0
- package/dist/providers/mcp-provider.d.ts +1 -3
- package/dist/providers/mcp-provider.d.ts.map +1 -1
- package/dist/providers/memory-provider.js +13 -623
- package/dist/providers/memory-provider.js.map +7 -1
- package/dist/residency/host.js +577 -576
- package/dist/residency/host.js.map +7 -1
- package/dist/runtime-paths.d.ts +7 -0
- package/dist/runtime-paths.d.ts.map +1 -0
- package/dist/worker.js +961 -1164
- package/dist/worker.js.map +7 -1
- package/package.json +5 -3
- package/dist/activity/store.js +0 -573
- package/dist/activity/store.js.map +0 -1
- package/dist/activity/types.js +0 -2
- package/dist/activity/types.js.map +0 -1
- package/dist/actors/context.js +0 -155
- package/dist/actors/context.js.map +0 -1
- package/dist/actors/delivery-policy.js +0 -28
- package/dist/actors/delivery-policy.js.map +0 -1
- package/dist/actors/global-registry.js +0 -356
- package/dist/actors/global-registry.js.map +0 -1
- package/dist/actors/host-event-observer.js +0 -8
- package/dist/actors/host-event-observer.js.map +0 -1
- package/dist/actors/host-event-payload.js +0 -114
- package/dist/actors/host-event-payload.js.map +0 -1
- package/dist/actors/manager.js +0 -2003
- package/dist/actors/manager.js.map +0 -1
- package/dist/actors/predicate.js +0 -72
- package/dist/actors/predicate.js.map +0 -1
- package/dist/actors/types.js +0 -42
- package/dist/actors/types.js.map +0 -1
- package/dist/agents/budget-ledger.js +0 -159
- package/dist/agents/budget-ledger.js.map +0 -1
- package/dist/agents/claude-cli.js +0 -247
- package/dist/agents/claude-cli.js.map +0 -1
- package/dist/agents/compact-control.js +0 -143
- package/dist/agents/compact-control.js.map +0 -1
- package/dist/agents/constants.js +0 -5
- package/dist/agents/constants.js.map +0 -1
- package/dist/agents/handoff.js +0 -236
- package/dist/agents/handoff.js.map +0 -1
- package/dist/agents/manager.js +0 -1232
- package/dist/agents/manager.js.map +0 -1
- package/dist/agents/rm.js +0 -32
- package/dist/agents/rm.js.map +0 -1
- package/dist/agents/semaphore.js +0 -54
- package/dist/agents/semaphore.js.map +0 -1
- package/dist/agents/thinking-transfer.js +0 -130
- package/dist/agents/thinking-transfer.js.map +0 -1
- package/dist/agents/transports/herdr-transport.js +0 -140
- package/dist/agents/transports/herdr-transport.js.map +0 -1
- package/dist/agents/transports/localterm-transport.js +0 -50
- package/dist/agents/transports/localterm-transport.js.map +0 -1
- package/dist/agents/transports/process-transport.js +0 -17
- package/dist/agents/transports/process-transport.js.map +0 -1
- package/dist/agents/transports/process-utils.js +0 -128
- package/dist/agents/transports/process-utils.js.map +0 -1
- package/dist/agents/transports/screen-transport.js +0 -35
- package/dist/agents/transports/screen-transport.js.map +0 -1
- package/dist/agents/transports/tmux-transport.js +0 -43
- package/dist/agents/transports/tmux-transport.js.map +0 -1
- package/dist/agents/types.js +0 -2
- package/dist/agents/types.js.map +0 -1
- package/dist/agents/veda-cli.js +0 -59
- package/dist/agents/veda-cli.js.map +0 -1
- package/dist/agents/worktree-manager.js +0 -53
- package/dist/agents/worktree-manager.js.map +0 -1
- package/dist/async-settlement.js +0 -57
- package/dist/async-settlement.js.map +0 -1
- package/dist/audit/details.js +0 -111
- package/dist/audit/details.js.map +0 -1
- package/dist/audit/index.js +0 -4
- package/dist/audit/index.js.map +0 -1
- package/dist/audit/projection.js +0 -267
- package/dist/audit/projection.js.map +0 -1
- package/dist/audit/trace.js +0 -600
- package/dist/audit/trace.js.map +0 -1
- package/dist/capture/catalog.js +0 -53
- package/dist/capture/catalog.js.map +0 -1
- package/dist/capture/interceptor.js +0 -129
- package/dist/capture/interceptor.js.map +0 -1
- package/dist/commands/fabric.js +0 -616
- package/dist/commands/fabric.js.map +0 -1
- package/dist/compaction/bounds.js +0 -70
- package/dist/compaction/bounds.js.map +0 -1
- package/dist/compaction/branch-details.js +0 -163
- package/dist/compaction/branch-details.js.map +0 -1
- package/dist/compaction/branch-summary.js +0 -212
- package/dist/compaction/branch-summary.js.map +0 -1
- package/dist/compaction/enrichers.js +0 -11
- package/dist/compaction/enrichers.js.map +0 -1
- package/dist/compaction/instructions.js +0 -427
- package/dist/compaction/instructions.js.map +0 -1
- package/dist/compaction/normalize.js +0 -377
- package/dist/compaction/normalize.js.map +0 -1
- package/dist/compaction/projections.js +0 -562
- package/dist/compaction/projections.js.map +0 -1
- package/dist/compaction/qa.js +0 -268
- package/dist/compaction/qa.js.map +0 -1
- package/dist/compaction/render.js +0 -68
- package/dist/compaction/render.js.map +0 -1
- package/dist/compaction/threshold.js +0 -36
- package/dist/compaction/threshold.js.map +0 -1
- package/dist/compaction/trace-events.js +0 -87
- package/dist/compaction/trace-events.js.map +0 -1
- package/dist/config-migrations.js +0 -104
- package/dist/config-migrations.js.map +0 -1
- package/dist/config.js +0 -597
- package/dist/config.js.map +0 -1
- package/dist/core/approval-controller.js +0 -178
- package/dist/core/approval-controller.js.map +0 -1
- package/dist/core/atomic-write.js +0 -62
- package/dist/core/atomic-write.js.map +0 -1
- package/dist/core/auto-approval-classifier.js +0 -161
- package/dist/core/auto-approval-classifier.js.map +0 -1
- package/dist/core/call-preview.js +0 -61
- package/dist/core/call-preview.js.map +0 -1
- package/dist/core/capability-advisory.js +0 -636
- package/dist/core/capability-advisory.js.map +0 -1
- package/dist/core/capability-fingerprint.js +0 -171
- package/dist/core/capability-fingerprint.js.map +0 -1
- package/dist/core/compact-controller.js +0 -158
- package/dist/core/compact-controller.js.map +0 -1
- package/dist/core/direct-tool-approval.js +0 -71
- package/dist/core/direct-tool-approval.js.map +0 -1
- package/dist/core/pi-tools.js +0 -11
- package/dist/core/pi-tools.js.map +0 -1
- package/dist/core/skill-dir.js +0 -39
- package/dist/core/skill-dir.js.map +0 -1
- package/dist/core/skill-prompt.js +0 -18
- package/dist/core/skill-prompt.js.map +0 -1
- package/dist/core/skill-references.js +0 -37
- package/dist/core/skill-references.js.map +0 -1
- package/dist/core/stable-hash.js +0 -19
- package/dist/core/stable-hash.js.map +0 -1
- package/dist/core/tool-ownership.js +0 -156
- package/dist/core/tool-ownership.js.map +0 -1
- package/dist/core/tool-result-proxy.js +0 -66
- package/dist/core/tool-result-proxy.js.map +0 -1
- package/dist/execution-service.js +0 -533
- package/dist/execution-service.js.map +0 -1
- package/dist/fabric-exec-arguments.js +0 -40
- package/dist/fabric-exec-arguments.js.map +0 -1
- package/dist/fabric-exec-tool.js +0 -640
- package/dist/fabric-exec-tool.js.map +0 -1
- package/dist/fabric-state.js +0 -710
- package/dist/fabric-state.js.map +0 -1
- package/dist/failure-progress.js +0 -27
- package/dist/failure-progress.js.map +0 -1
- package/dist/host-compatibility.js +0 -74
- package/dist/host-compatibility.js.map +0 -1
- package/dist/lifecycle/broker.js +0 -291
- package/dist/lifecycle/broker.js.map +0 -1
- package/dist/lifecycle/types.js +0 -120
- package/dist/lifecycle/types.js.map +0 -1
- package/dist/log-tail.js +0 -102
- package/dist/log-tail.js.map +0 -1
- package/dist/main-agent.js +0 -116
- package/dist/main-agent.js.map +0 -1
- package/dist/memory/index.js +0 -680
- package/dist/memory/index.js.map +0 -1
- package/dist/memory/lineage.js +0 -90
- package/dist/memory/lineage.js.map +0 -1
- package/dist/memory/regex.js +0 -102
- package/dist/memory/regex.js.map +0 -1
- package/dist/memory/tokenize.js +0 -18
- package/dist/memory/tokenize.js.map +0 -1
- package/dist/mesh/store.js +0 -783
- package/dist/mesh/store.js.map +0 -1
- package/dist/output-budget.js +0 -38
- package/dist/output-budget.js.map +0 -1
- package/dist/prewalk/arm.js +0 -65
- package/dist/prewalk/arm.js.map +0 -1
- package/dist/prewalk/controller.js +0 -207
- package/dist/prewalk/controller.js.map +0 -1
- package/dist/prewalk/fs-drift.js +0 -205
- package/dist/prewalk/fs-drift.js.map +0 -1
- package/dist/prewalk/handoff.js +0 -467
- package/dist/prewalk/handoff.js.map +0 -1
- package/dist/providers/agents-provider.js +0 -1675
- package/dist/providers/agents-provider.js.map +0 -1
- package/dist/providers/captured-tools-provider.js +0 -185
- package/dist/providers/captured-tools-provider.js.map +0 -1
- package/dist/providers/compact-provider.js +0 -127
- package/dist/providers/compact-provider.js.map +0 -1
- package/dist/providers/mcp-descriptor-cache.js +0 -161
- package/dist/providers/mcp-descriptor-cache.js.map +0 -1
- package/dist/providers/mcp-provider.js +0 -861
- package/dist/providers/mcp-provider.js.map +0 -1
- package/dist/providers/mesh-provider.js +0 -237
- package/dist/providers/mesh-provider.js.map +0 -1
- package/dist/providers/pi-tools-provider.js +0 -413
- package/dist/providers/pi-tools-provider.js.map +0 -1
- package/dist/providers/schema-provider.js +0 -220
- package/dist/providers/schema-provider.js.map +0 -1
- package/dist/providers/state-provider.js +0 -298
- package/dist/providers/state-provider.js.map +0 -1
- package/dist/providers/write-diff-limits.js +0 -42
- package/dist/providers/write-diff-limits.js.map +0 -1
- package/dist/providers/write-preview.js +0 -85
- package/dist/providers/write-preview.js.map +0 -1
- package/dist/ref-names.js +0 -11
- package/dist/ref-names.js.map +0 -1
- package/dist/residency/client.js +0 -352
- package/dist/residency/client.js.map +0 -1
- package/dist/residency/protocol.js +0 -9
- package/dist/residency/protocol.js.map +0 -1
- package/dist/run-display.js +0 -43
- package/dist/run-display.js.map +0 -1
- package/dist/runtime/dynamic-guest-types.js +0 -268
- package/dist/runtime/dynamic-guest-types.js.map +0 -1
- package/dist/runtime/guest-types.js.map +0 -1
- package/dist/runtime/node-process-child-source.js +0 -103
- package/dist/runtime/node-process-child-source.js.map +0 -1
- package/dist/runtime/node-process-runtime.js +0 -159
- package/dist/runtime/node-process-runtime.js.map +0 -1
- package/dist/runtime/orchestration.js +0 -17
- package/dist/runtime/orchestration.js.map +0 -1
- package/dist/runtime/quickjs-runtime.js.map +0 -1
- package/dist/runtime/type-checker.js +0 -141
- package/dist/runtime/type-checker.js.map +0 -1
- package/dist/schema/controller.js +0 -842
- package/dist/schema/controller.js.map +0 -1
- package/dist/schema/types.js +0 -4
- package/dist/schema/types.js.map +0 -1
- package/dist/schema/workspace.js +0 -186
- package/dist/schema/workspace.js.map +0 -1
- package/dist/state/complexity.js +0 -293
- package/dist/state/complexity.js.map +0 -1
- package/dist/state/evidence-runner.js +0 -182
- package/dist/state/evidence-runner.js.map +0 -1
- package/dist/state/store.js +0 -1329
- package/dist/state/store.js.map +0 -1
- package/dist/state/types.js +0 -2
- package/dist/state/types.js.map +0 -1
- package/dist/storage/retention.js +0 -174
- package/dist/storage/retention.js.map +0 -1
- package/dist/thinking.js +0 -26
- package/dist/thinking.js.map +0 -1
- package/dist/topology/control-plane.js +0 -298
- package/dist/topology/control-plane.js.map +0 -1
- package/dist/topology/participant-directory.js +0 -563
- package/dist/topology/participant-directory.js.map +0 -1
- package/dist/topology/records.js +0 -71
- package/dist/topology/records.js.map +0 -1
- package/dist/topology/types.js +0 -2
- package/dist/topology/types.js.map +0 -1
- package/dist/type-error-guidance.js +0 -11
- package/dist/type-error-guidance.js.map +0 -1
- package/dist/ui/arc-group.js +0 -47
- package/dist/ui/arc-group.js.map +0 -1
- package/dist/ui/code-preview-shell.js +0 -310
- package/dist/ui/code-preview-shell.js.map +0 -1
- package/dist/ui/code-preview.js +0 -116
- package/dist/ui/code-preview.js.map +0 -1
- package/dist/ui/controller.js +0 -417
- package/dist/ui/controller.js.map +0 -1
- package/dist/ui/core-tool-render.js +0 -1367
- package/dist/ui/core-tool-render.js.map +0 -1
- package/dist/ui/dashboard-fabric-graph.js +0 -851
- package/dist/ui/dashboard-fabric-graph.js.map +0 -1
- package/dist/ui/dashboard-model.js +0 -503
- package/dist/ui/dashboard-model.js.map +0 -1
- package/dist/ui/dashboard-presentation.js +0 -154
- package/dist/ui/dashboard-presentation.js.map +0 -1
- package/dist/ui/dashboard.js +0 -2395
- package/dist/ui/dashboard.js.map +0 -1
- package/dist/ui/diff-background.js +0 -186
- package/dist/ui/diff-background.js.map +0 -1
- package/dist/ui/fabric-actor-delivery-selector.js +0 -52
- package/dist/ui/fabric-actor-delivery-selector.js.map +0 -1
- package/dist/ui/fabric-actor-tool-selector.js +0 -80
- package/dist/ui/fabric-actor-tool-selector.js.map +0 -1
- package/dist/ui/fabric-code-parser.js +0 -169
- package/dist/ui/fabric-code-parser.js.map +0 -1
- package/dist/ui/fabric-host-event-selector.js +0 -131
- package/dist/ui/fabric-host-event-selector.js.map +0 -1
- package/dist/ui/fabric-model-selector.js +0 -174
- package/dist/ui/fabric-model-selector.js.map +0 -1
- package/dist/ui/fabric-render.js +0 -1067
- package/dist/ui/fabric-render.js.map +0 -1
- package/dist/ui/fabric-thinking-selector.js +0 -57
- package/dist/ui/fabric-thinking-selector.js.map +0 -1
- package/dist/ui/format.js +0 -104
- package/dist/ui/format.js.map +0 -1
- package/dist/ui/highlight.js +0 -786
- package/dist/ui/highlight.js.map +0 -1
- package/dist/ui/model-picker.js +0 -80
- package/dist/ui/model-picker.js.map +0 -1
- package/dist/ui/preview-lines.js +0 -129
- package/dist/ui/preview-lines.js.map +0 -1
- package/dist/ui/row-balance.js +0 -95
- package/dist/ui/row-balance.js.map +0 -1
- package/dist/ui/settings.js +0 -1188
- package/dist/ui/settings.js.map +0 -1
- package/dist/ui/snapshot.js +0 -234
- package/dist/ui/snapshot.js.map +0 -1
- package/dist/ui/spinner.js +0 -21
- package/dist/ui/spinner.js.map +0 -1
- package/dist/ui/state-file-preview.js +0 -102
- package/dist/ui/state-file-preview.js.map +0 -1
- package/dist/ui/structured.js +0 -135
- package/dist/ui/structured.js.map +0 -1
- package/dist/ui/topology.js +0 -650
- package/dist/ui/topology.js.map +0 -1
- package/dist/ui/transcript-parser.js +0 -538
- package/dist/ui/transcript-parser.js.map +0 -1
- package/dist/ui/transcript-reader.js +0 -295
- package/dist/ui/transcript-reader.js.map +0 -1
- package/dist/ui/transcript-sanitization.js +0 -150
- package/dist/ui/transcript-sanitization.js.map +0 -1
- package/dist/ui/transcript.js +0 -43
- package/dist/ui/transcript.js.map +0 -1
- package/dist/ui/types.js +0 -17
- package/dist/ui/types.js.map +0 -1
- package/dist/ui/widget.js +0 -222
- package/dist/ui/widget.js.map +0 -1
- package/dist/ui/word-diff/alignment.js +0 -98
- package/dist/ui/word-diff/alignment.js.map +0 -1
- package/dist/ui/word-diff/change-block.js +0 -34
- package/dist/ui/word-diff/change-block.js.map +0 -1
- package/dist/ui/word-diff/changed-line.js +0 -18
- package/dist/ui/word-diff/changed-line.js.map +0 -1
- package/dist/ui/word-diff/emphasis.js +0 -45
- package/dist/ui/word-diff/emphasis.js.map +0 -1
- package/dist/ui/word-diff/line-emphasis.js +0 -15
- package/dist/ui/word-diff/line-emphasis.js.map +0 -1
- package/dist/ui/word-diff/line-matching.js +0 -219
- package/dist/ui/word-diff/line-matching.js.map +0 -1
- package/dist/ui/word-diff/line-similarity.js +0 -120
- package/dist/ui/word-diff/line-similarity.js.map +0 -1
- package/dist/ui/word-diff/normalize.js +0 -6
- package/dist/ui/word-diff/normalize.js.map +0 -1
- package/dist/ui/word-diff/parse.js +0 -33
- package/dist/ui/word-diff/parse.js.map +0 -1
- package/dist/ui/word-diff/range-refinement.js +0 -205
- package/dist/ui/word-diff/range-refinement.js.map +0 -1
- package/dist/ui/word-diff/ranges.js +0 -34
- package/dist/ui/word-diff/ranges.js.map +0 -1
- package/dist/ui/word-diff/smart-filter.js +0 -54
- package/dist/ui/word-diff/smart-filter.js.map +0 -1
- package/dist/ui/word-diff/sparse-line-matching.js +0 -261
- package/dist/ui/word-diff/sparse-line-matching.js.map +0 -1
- package/dist/ui/word-diff/text-boundaries.js +0 -121
- package/dist/ui/word-diff/text-boundaries.js.map +0 -1
- package/dist/ui/word-diff/token-alignment.js +0 -154
- package/dist/ui/word-diff/token-alignment.js.map +0 -1
- package/dist/ui/word-diff/token-text-refinement.js +0 -145
- package/dist/ui/word-diff/token-text-refinement.js.map +0 -1
- package/dist/ui/word-diff/tokens.js +0 -75
- package/dist/ui/word-diff/tokens.js.map +0 -1
- package/dist/ui/word-diff/types.js +0 -2
- package/dist/ui/word-diff/types.js.map +0 -1
- package/dist/util.js +0 -18
- package/dist/util.js.map +0 -1
- package/dist/worker/options.js +0 -89
- package/dist/worker/options.js.map +0 -1
- package/dist/worker/run-record.js +0 -137
- package/dist/worker/run-record.js.map +0 -1
|
@@ -0,0 +1,1177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readJsonlPageFromDescriptor
|
|
3
|
+
} from "./chunk-NSCOEOEP.js";
|
|
4
|
+
|
|
5
|
+
// src/core/call-preview.ts
|
|
6
|
+
var HEADLINE_ARG_KEYS = [
|
|
7
|
+
"task",
|
|
8
|
+
"path",
|
|
9
|
+
"query",
|
|
10
|
+
"message",
|
|
11
|
+
"search",
|
|
12
|
+
"pattern",
|
|
13
|
+
"command",
|
|
14
|
+
"text",
|
|
15
|
+
"prompt",
|
|
16
|
+
"question",
|
|
17
|
+
"input",
|
|
18
|
+
"content",
|
|
19
|
+
"expression",
|
|
20
|
+
"url",
|
|
21
|
+
"topic",
|
|
22
|
+
"key",
|
|
23
|
+
"filter",
|
|
24
|
+
"name",
|
|
25
|
+
"q"
|
|
26
|
+
];
|
|
27
|
+
var HEADLINE_SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
28
|
+
"label",
|
|
29
|
+
"title",
|
|
30
|
+
"type",
|
|
31
|
+
"kind",
|
|
32
|
+
"mode",
|
|
33
|
+
"format",
|
|
34
|
+
"resultFormat",
|
|
35
|
+
"limit",
|
|
36
|
+
"max",
|
|
37
|
+
"offset",
|
|
38
|
+
"start",
|
|
39
|
+
"concurrency",
|
|
40
|
+
"overwrite",
|
|
41
|
+
"id",
|
|
42
|
+
"provider",
|
|
43
|
+
"namespace",
|
|
44
|
+
"server",
|
|
45
|
+
"tool",
|
|
46
|
+
"ref",
|
|
47
|
+
"recursive",
|
|
48
|
+
"synthesize",
|
|
49
|
+
"commandDigest"
|
|
50
|
+
]);
|
|
51
|
+
var cleanOneLine = (value, max) => {
|
|
52
|
+
const single = value.replace(/\s+/g, " ").trim();
|
|
53
|
+
if (!single) return "";
|
|
54
|
+
return single.length <= max ? single : `${single.slice(0, Math.max(1, max - 1))}\u2026`;
|
|
55
|
+
};
|
|
56
|
+
var headlineArg = (args, max = 96) => {
|
|
57
|
+
if (!args) return void 0;
|
|
58
|
+
for (const key of HEADLINE_ARG_KEYS) {
|
|
59
|
+
const value = args[key];
|
|
60
|
+
if (typeof value === "string") {
|
|
61
|
+
const cleaned = cleanOneLine(value, max);
|
|
62
|
+
if (cleaned) return cleaned;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
for (const [key, value] of Object.entries(args)) {
|
|
66
|
+
if (HEADLINE_SKIP_KEYS.has(key)) continue;
|
|
67
|
+
if (typeof value === "string") {
|
|
68
|
+
const cleaned = cleanOneLine(value, max);
|
|
69
|
+
if (cleaned) return cleaned;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return void 0;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/ui/preview-lines.ts
|
|
76
|
+
function countContentLines(content) {
|
|
77
|
+
if (!content) return 0;
|
|
78
|
+
let terminators = 0;
|
|
79
|
+
for (let index = 0; index < content.length; index++) {
|
|
80
|
+
const code = content.charCodeAt(index);
|
|
81
|
+
if (code === 13) {
|
|
82
|
+
terminators++;
|
|
83
|
+
if (content.charCodeAt(index + 1) === 10) index++;
|
|
84
|
+
} else if (code === 10) {
|
|
85
|
+
terminators++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const finalCode = content.charCodeAt(content.length - 1);
|
|
89
|
+
return terminators + (finalCode === 10 || finalCode === 13 ? 0 : 1);
|
|
90
|
+
}
|
|
91
|
+
function selectPreviewTextLines(text, limit) {
|
|
92
|
+
if (!Number.isInteger(limit)) {
|
|
93
|
+
const lines = collectPreviewTextLines(text);
|
|
94
|
+
return { ...selectPreviewLines(lines, limit), total: lines.length };
|
|
95
|
+
}
|
|
96
|
+
const entries = [];
|
|
97
|
+
const split = limit >= 8;
|
|
98
|
+
const head = split ? Math.ceil(limit * 0.65) : limit;
|
|
99
|
+
const tailLimit = split ? Math.max(1, limit - head - 1) : 0;
|
|
100
|
+
const tail = [];
|
|
101
|
+
let tailSize = 0;
|
|
102
|
+
let tailCursor = 0;
|
|
103
|
+
let total = 0;
|
|
104
|
+
forEachPreviewTextLine(text, (line, index) => {
|
|
105
|
+
total++;
|
|
106
|
+
if (limit <= 0 || index < limit) entries.push({ kind: "line", line, index });
|
|
107
|
+
if (!split || index < head) return;
|
|
108
|
+
tail[tailCursor] = line;
|
|
109
|
+
if (++tailCursor === tailLimit) tailCursor = 0;
|
|
110
|
+
if (tailSize < tailLimit) tailSize++;
|
|
111
|
+
});
|
|
112
|
+
if (limit <= 0 || total <= limit) return { entries, shown: total, hidden: 0, total };
|
|
113
|
+
if (!split) return { entries, shown: limit, hidden: total - limit, total };
|
|
114
|
+
const hidden = total - head - tailLimit;
|
|
115
|
+
const selected = entries.slice(0, head);
|
|
116
|
+
selected.push({ kind: "hidden", hidden });
|
|
117
|
+
let tailSlot = tailSize === tailLimit ? tailCursor : 0;
|
|
118
|
+
for (let offset = 0; offset < tailSize; offset++) {
|
|
119
|
+
const line = tail[tailSlot];
|
|
120
|
+
if (line === void 0) throw new RangeError(`Missing preview tail line ${offset}`);
|
|
121
|
+
selected.push({ kind: "line", line, index: total - tailSize + offset });
|
|
122
|
+
if (++tailSlot === tailLimit) tailSlot = 0;
|
|
123
|
+
}
|
|
124
|
+
return { entries: selected, shown: head + tailLimit, hidden, total };
|
|
125
|
+
}
|
|
126
|
+
function selectPreviewLines(lines, limit) {
|
|
127
|
+
if (lines.length <= limit || limit <= 0) {
|
|
128
|
+
return {
|
|
129
|
+
entries: lines.map((line, index) => ({ kind: "line", line, index })),
|
|
130
|
+
shown: lines.length,
|
|
131
|
+
hidden: 0
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (limit < 8) {
|
|
135
|
+
return {
|
|
136
|
+
entries: lines.slice(0, limit).map((line, index) => ({ kind: "line", line, index })),
|
|
137
|
+
shown: limit,
|
|
138
|
+
hidden: lines.length - limit
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const head = Math.ceil(limit * 0.65);
|
|
142
|
+
const tail = Math.max(1, limit - head - 1);
|
|
143
|
+
const hidden = lines.length - head - tail;
|
|
144
|
+
return {
|
|
145
|
+
entries: [
|
|
146
|
+
...lines.slice(0, head).map((line, index) => ({ kind: "line", line, index })),
|
|
147
|
+
{ kind: "hidden", hidden },
|
|
148
|
+
...lines.slice(-tail).map((line, offset) => ({
|
|
149
|
+
kind: "line",
|
|
150
|
+
line,
|
|
151
|
+
index: lines.length - tail + offset
|
|
152
|
+
}))
|
|
153
|
+
],
|
|
154
|
+
shown: head + tail,
|
|
155
|
+
hidden
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function collectPreviewTextLines(text) {
|
|
159
|
+
const lines = [];
|
|
160
|
+
forEachPreviewTextLine(text, (line) => lines.push(line));
|
|
161
|
+
return lines;
|
|
162
|
+
}
|
|
163
|
+
function forEachPreviewTextLine(text, callback) {
|
|
164
|
+
let index = 0;
|
|
165
|
+
let pendingEmpty = 0;
|
|
166
|
+
forEachRawTextLine(text, (line) => {
|
|
167
|
+
if (line === "") {
|
|
168
|
+
pendingEmpty++;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
while (pendingEmpty > 0) {
|
|
172
|
+
callback("", index++);
|
|
173
|
+
pendingEmpty--;
|
|
174
|
+
}
|
|
175
|
+
callback(line, index++);
|
|
176
|
+
});
|
|
177
|
+
if (index === 0 && pendingEmpty > 0 && text.length > 0) callback("", index);
|
|
178
|
+
}
|
|
179
|
+
function forEachRawTextLine(text, callback) {
|
|
180
|
+
let start = 0;
|
|
181
|
+
while (start <= text.length) {
|
|
182
|
+
const newline = text.indexOf("\n", start);
|
|
183
|
+
if (newline < 0) {
|
|
184
|
+
callback(text.slice(start));
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
callback(text.slice(start, newline));
|
|
188
|
+
start = newline + 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/providers/write-diff-limits.ts
|
|
193
|
+
var configuredMaxBytes = Number.parseInt(
|
|
194
|
+
process.env.CODE_PREVIEW_MAX_WRITE_DIFF_BYTES ?? "",
|
|
195
|
+
10
|
|
196
|
+
);
|
|
197
|
+
var MAX_WRITE_DIFF_BYTES = Number.isFinite(configuredMaxBytes) && configuredMaxBytes > 0 ? configuredMaxBytes : 2e5;
|
|
198
|
+
var configuredMaxChangedLineCells = Number.parseInt(
|
|
199
|
+
process.env.CODE_PREVIEW_MAX_WRITE_DIFF_CHANGED_LINE_CELLS ?? "",
|
|
200
|
+
10
|
|
201
|
+
);
|
|
202
|
+
var MAX_WRITE_DIFF_CHANGED_LINE_CELLS = Number.isFinite(configuredMaxChangedLineCells) && configuredMaxChangedLineCells > 0 ? configuredMaxChangedLineCells : 1e6;
|
|
203
|
+
var writeContentForPreview = (content) => Buffer.byteLength(content, "utf8") <= MAX_WRITE_DIFF_BYTES ? content : void 0;
|
|
204
|
+
var shouldSkipWriteDiffBytes = (...texts) => {
|
|
205
|
+
let total = 0;
|
|
206
|
+
for (const text of texts) {
|
|
207
|
+
total += Buffer.byteLength(text, "utf8");
|
|
208
|
+
if (total > MAX_WRITE_DIFF_BYTES) return true;
|
|
209
|
+
}
|
|
210
|
+
return false;
|
|
211
|
+
};
|
|
212
|
+
var shouldSkipWriteDiffComplexity = (before, after) => {
|
|
213
|
+
const beforeLines = before.split("\n");
|
|
214
|
+
const afterLines = after.split("\n");
|
|
215
|
+
const sharedLimit = Math.min(beforeLines.length, afterLines.length);
|
|
216
|
+
let prefix = 0;
|
|
217
|
+
while (prefix < sharedLimit && beforeLines[prefix] === afterLines[prefix]) prefix++;
|
|
218
|
+
let suffix = 0;
|
|
219
|
+
const suffixLimit = sharedLimit - prefix;
|
|
220
|
+
while (suffix < suffixLimit && beforeLines[beforeLines.length - suffix - 1] === afterLines[afterLines.length - suffix - 1]) {
|
|
221
|
+
suffix++;
|
|
222
|
+
}
|
|
223
|
+
const changedBefore = beforeLines.length - prefix - suffix;
|
|
224
|
+
const changedAfter = afterLines.length - prefix - suffix;
|
|
225
|
+
return changedBefore * changedAfter > MAX_WRITE_DIFF_CHANGED_LINE_CELLS;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// src/ui/transcript-reader.ts
|
|
229
|
+
import fs from "node:fs";
|
|
230
|
+
|
|
231
|
+
// src/ui/transcript-sanitization.ts
|
|
232
|
+
var MAX_TOOL_SUMMARY_CHARS = 500;
|
|
233
|
+
var MAX_ENCODED_STRING_CHARS = 160;
|
|
234
|
+
var MAX_TRANSCRIPT_VALUE_CHARS = 4e4;
|
|
235
|
+
var MAX_TRANSCRIPT_STRING_CHARS = 12e3;
|
|
236
|
+
var MAX_TRANSCRIPT_VALUE_NODES = 400;
|
|
237
|
+
var secretKey = /authorization|api[-_]?key|token|password|secret|cookie|credential|private[-_]?key/i;
|
|
238
|
+
var recordOf = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
239
|
+
var terminalSafe = (value, trim = true) => {
|
|
240
|
+
const safe = value.replace(/\x1b\][^\x07]*(?:\x07|\x1b\\)/g, "").replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\u202a-\u202e\u2066-\u2069\u200e\u200f]/gi, "").replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, " ").replace(/\r\n?/g, "\n");
|
|
241
|
+
return trim ? safe.trim() : safe;
|
|
242
|
+
};
|
|
243
|
+
var graphemeSegmenter = Intl.Segmenter ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : void 0;
|
|
244
|
+
var graphemes = (value) => graphemeSegmenter ? [...graphemeSegmenter.segment(value)].map((entry) => entry.segment) : Array.from(value);
|
|
245
|
+
var clip = (value, max, trim = true) => {
|
|
246
|
+
const normalized = terminalSafe(value, trim);
|
|
247
|
+
if (normalized.length <= max) return normalized;
|
|
248
|
+
const parts = graphemes(normalized);
|
|
249
|
+
if (parts.length <= max) return normalized;
|
|
250
|
+
const tail = Math.min(1e3, Math.floor(max * 0.25));
|
|
251
|
+
return `${parts.slice(0, max - tail - 2).join("")}\u2026
|
|
252
|
+
${parts.slice(-tail).join("")}`;
|
|
253
|
+
};
|
|
254
|
+
var contentText = (value) => {
|
|
255
|
+
if (typeof value === "string") return value;
|
|
256
|
+
if (Array.isArray(value)) {
|
|
257
|
+
return value.map((part) => {
|
|
258
|
+
const record2 = recordOf(part);
|
|
259
|
+
return record2?.type === "text" && typeof record2.text === "string" ? record2.text : "";
|
|
260
|
+
}).filter(Boolean).join("");
|
|
261
|
+
}
|
|
262
|
+
const record = recordOf(value);
|
|
263
|
+
if (!record) return "";
|
|
264
|
+
if (typeof record.text === "string") return record.text;
|
|
265
|
+
if (record.content !== void 0) return contentText(record.content);
|
|
266
|
+
return "";
|
|
267
|
+
};
|
|
268
|
+
var messageError = (message) => {
|
|
269
|
+
if (message.role !== "assistant" || message.stopReason !== "error") return "";
|
|
270
|
+
const details = [];
|
|
271
|
+
if (typeof message.errorMessage === "string") details.push(message.errorMessage);
|
|
272
|
+
else if (typeof message.error === "string") details.push(message.error);
|
|
273
|
+
if (Array.isArray(message.diagnostics)) {
|
|
274
|
+
for (const value of message.diagnostics) {
|
|
275
|
+
const diagnostic = recordOf(value);
|
|
276
|
+
const nested = recordOf(diagnostic?.error);
|
|
277
|
+
const detail = typeof nested?.message === "string" ? nested.message : typeof diagnostic?.message === "string" ? diagnostic.message : void 0;
|
|
278
|
+
if (detail) details.push(detail);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return clip([...new Set(details)].join(" \xB7 ") || "Agent response failed", MAX_TOOL_SUMMARY_CHARS);
|
|
282
|
+
};
|
|
283
|
+
var redactInlineSecrets = (value) => value.replace(/\bBearer\s+[A-Za-z0-9._~+\/-]+=*/gi, "Bearer [redacted]").replace(/\bBasic\s+[A-Za-z0-9+/=]{8,}/gi, "Basic [redacted]").replace(/\b(?:sk|pk|ghp|github_pat|xox[baprs])[-_][A-Za-z0-9_-]{12,}\b/g, "[redacted]").replace(
|
|
284
|
+
/\b(Authorization|Proxy-Authorization|Cookie|Set-Cookie|X-Api-Key)\s*:\s*[^\r\n;]+/gi,
|
|
285
|
+
"$1: [redacted]"
|
|
286
|
+
).replace(
|
|
287
|
+
/\b([A-Z0-9_]*(?:PASSWORD|PASSWD|TOKEN|SECRET|API_KEY|ACCESS_KEY|PRIVATE_KEY|CREDENTIAL|COOKIE)[A-Z0-9_]*)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s;&|]+)/gi,
|
|
288
|
+
"$1=[redacted]"
|
|
289
|
+
).replace(
|
|
290
|
+
/(--?(?:password|passwd|token|secret|api[-_]?key|access[-_]?key|credential|cookie))(?:=|\s+)(?:"[^"]*"|'[^']*'|[^\s;&|]+)/gi,
|
|
291
|
+
"$1=[redacted]"
|
|
292
|
+
).replace(/(https?:\/\/)[^\s/:@]+:[^\s/@]+@/gi, "$1[redacted]@");
|
|
293
|
+
var redact = (value, key = "", depth = 0, budget = {
|
|
294
|
+
chars: MAX_TRANSCRIPT_VALUE_CHARS,
|
|
295
|
+
nodes: MAX_TRANSCRIPT_VALUE_NODES
|
|
296
|
+
}) => {
|
|
297
|
+
if (secretKey.test(key)) return "[redacted]";
|
|
298
|
+
if (depth > 12) return "[nested value]";
|
|
299
|
+
if (budget.nodes <= 0) return "[value omitted]";
|
|
300
|
+
budget.nodes--;
|
|
301
|
+
if (typeof value === "string") {
|
|
302
|
+
const safe = terminalSafe(value, false);
|
|
303
|
+
if (safe.length >= MAX_ENCODED_STRING_CHARS && /^[A-Za-z0-9+/=_-]+$/.test(safe)) {
|
|
304
|
+
return `[large encoded value \xB7 ${safe.length} chars]`;
|
|
305
|
+
}
|
|
306
|
+
const available = Math.max(0, Math.min(MAX_TRANSCRIPT_STRING_CHARS, budget.chars));
|
|
307
|
+
if (available === 0) return "[text omitted]";
|
|
308
|
+
const hidden = redactInlineSecrets(clip(safe, available, false));
|
|
309
|
+
budget.chars = Math.max(0, budget.chars - hidden.length);
|
|
310
|
+
return hidden;
|
|
311
|
+
}
|
|
312
|
+
if (Array.isArray(value)) {
|
|
313
|
+
const entries2 = [];
|
|
314
|
+
for (const entry of value) {
|
|
315
|
+
if (budget.nodes <= 0) {
|
|
316
|
+
entries2.push(`[${value.length - entries2.length} entries omitted]`);
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
entries2.push(redact(entry, key, depth + 1, budget));
|
|
320
|
+
}
|
|
321
|
+
return entries2;
|
|
322
|
+
}
|
|
323
|
+
const record = recordOf(value);
|
|
324
|
+
if (!record) return value;
|
|
325
|
+
const entries = Object.entries(record);
|
|
326
|
+
const redacted = {};
|
|
327
|
+
for (let index = 0; index < entries.length; index++) {
|
|
328
|
+
if (budget.nodes <= 0) {
|
|
329
|
+
redacted["\u2026"] = `[${entries.length - index} fields omitted]`;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
const [name, entry] = entries[index];
|
|
333
|
+
redacted[name] = redact(entry, name, depth + 1, budget);
|
|
334
|
+
}
|
|
335
|
+
return redacted;
|
|
336
|
+
};
|
|
337
|
+
var redactRecord = (value) => {
|
|
338
|
+
const record = recordOf(value);
|
|
339
|
+
if (!record) return void 0;
|
|
340
|
+
return recordOf(redact(record));
|
|
341
|
+
};
|
|
342
|
+
var compactRedactedValue = (value) => {
|
|
343
|
+
try {
|
|
344
|
+
return clip(JSON.stringify(value).replace(/\s+/g, " "), MAX_TOOL_SUMMARY_CHARS);
|
|
345
|
+
} catch {
|
|
346
|
+
return clip(String(value ?? "").replace(/\s+/g, " "), MAX_TOOL_SUMMARY_CHARS);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// src/ui/transcript-parser.ts
|
|
351
|
+
var MAX_TOOL_SUMMARY_CHARS2 = 500;
|
|
352
|
+
var MAX_TRANSCRIPT_MESSAGE_CHARS = 4e4;
|
|
353
|
+
var TRANSCRIPT_ENTRY_LIMIT = 80;
|
|
354
|
+
var TranscriptAccumulator = class {
|
|
355
|
+
entries = [];
|
|
356
|
+
#tools = /* @__PURE__ */ new Map();
|
|
357
|
+
#anonymousTools = /* @__PURE__ */ new Map();
|
|
358
|
+
#activeTools = [];
|
|
359
|
+
#assistant;
|
|
360
|
+
#retry;
|
|
361
|
+
#compaction;
|
|
362
|
+
#sequence = 0;
|
|
363
|
+
append(events) {
|
|
364
|
+
for (const event of events) this.#append(event);
|
|
365
|
+
}
|
|
366
|
+
snapshot(olderAvailable = false, updatedAt, maxEntries = TRANSCRIPT_ENTRY_LIMIT) {
|
|
367
|
+
const entries = maxEntries > 0 && this.entries.length > maxEntries ? this.entries.slice(-maxEntries) : this.entries;
|
|
368
|
+
const omitted = entries.length < this.entries.length;
|
|
369
|
+
return {
|
|
370
|
+
entries: entries.map((entry) => ({ ...entry })),
|
|
371
|
+
truncated: olderAvailable || omitted,
|
|
372
|
+
hasMore: olderAvailable || omitted,
|
|
373
|
+
...updatedAt !== void 0 ? { updatedAt } : {}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
#nextId(event, prefix = "event") {
|
|
377
|
+
if (typeof event.toolCallId === "string") return event.toolCallId;
|
|
378
|
+
if (typeof event.uuid === "string") return event.uuid;
|
|
379
|
+
if (typeof event.id === "string") return event.id;
|
|
380
|
+
return `${prefix}-${this.#sequence++}`;
|
|
381
|
+
}
|
|
382
|
+
#finishAssistant(status) {
|
|
383
|
+
if (!this.#assistant) return;
|
|
384
|
+
this.#assistant.status = status;
|
|
385
|
+
this.#assistant = void 0;
|
|
386
|
+
}
|
|
387
|
+
#pushMessage(kind, id, text, status = "completed", label = kind === "assistant" ? "Agent" : "User") {
|
|
388
|
+
const safe = clip(text, MAX_TRANSCRIPT_MESSAGE_CHARS);
|
|
389
|
+
if (!safe) return;
|
|
390
|
+
this.entries.push({ id, kind, label, text: safe, status });
|
|
391
|
+
}
|
|
392
|
+
#toolParent(id) {
|
|
393
|
+
if (!id.startsWith("fabric_")) return void 0;
|
|
394
|
+
for (let index = this.#activeTools.length - 1; index >= 0; index--) {
|
|
395
|
+
const candidate = this.#activeTools[index];
|
|
396
|
+
if (candidate?.toolName === "fabric_exec" && candidate.status === "running") return candidate;
|
|
397
|
+
}
|
|
398
|
+
return void 0;
|
|
399
|
+
}
|
|
400
|
+
#startTool(id, label, args) {
|
|
401
|
+
const existing = this.#tools.get(id);
|
|
402
|
+
const safeArgs = args === void 0 ? void 0 : redactRecord(args);
|
|
403
|
+
if (existing) {
|
|
404
|
+
if (safeArgs !== void 0) existing.args = safeArgs;
|
|
405
|
+
if (args !== void 0) existing.text = compactRedactedValue(safeArgs ?? redact(args));
|
|
406
|
+
return existing;
|
|
407
|
+
}
|
|
408
|
+
const parent = this.#toolParent(id);
|
|
409
|
+
const safeLabel = terminalSafe(label) || "tool";
|
|
410
|
+
const entry = {
|
|
411
|
+
id,
|
|
412
|
+
kind: "tool",
|
|
413
|
+
label: safeLabel,
|
|
414
|
+
toolName: safeLabel,
|
|
415
|
+
status: "running",
|
|
416
|
+
...safeArgs !== void 0 ? { args: safeArgs } : {},
|
|
417
|
+
...args !== void 0 ? { text: compactRedactedValue(safeArgs ?? redact(args)) } : {},
|
|
418
|
+
...parent ? { parentId: parent.id, depth: (parent.depth ?? 0) + 1 } : {}
|
|
419
|
+
};
|
|
420
|
+
this.entries.push(entry);
|
|
421
|
+
this.#tools.set(id, entry);
|
|
422
|
+
this.#activeTools.push(entry);
|
|
423
|
+
return entry;
|
|
424
|
+
}
|
|
425
|
+
#finishTool(id, label, result, failed) {
|
|
426
|
+
const safeLabel = terminalSafe(label) || "tool";
|
|
427
|
+
const anonymous = this.#anonymousTools.get(safeLabel);
|
|
428
|
+
const entry = id ? this.#tools.get(id) : anonymous?.shift();
|
|
429
|
+
if (anonymous?.length === 0) this.#anonymousTools.delete(safeLabel);
|
|
430
|
+
const safeResult = result === void 0 ? void 0 : redact(result);
|
|
431
|
+
if (entry) {
|
|
432
|
+
entry.status = failed ? "failed" : "completed";
|
|
433
|
+
if (safeResult !== void 0) entry.result = safeResult;
|
|
434
|
+
if (failed && result !== void 0) {
|
|
435
|
+
const failure = compactRedactedValue(safeResult);
|
|
436
|
+
entry.text = clip(
|
|
437
|
+
`${entry.text ? `${entry.text} \xB7 ` : ""}error: ${failure}`,
|
|
438
|
+
MAX_TOOL_SUMMARY_CHARS2
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
this.#tools.delete(entry.id);
|
|
442
|
+
const activeIndex = this.#activeTools.indexOf(entry);
|
|
443
|
+
if (activeIndex >= 0) this.#activeTools.splice(activeIndex, 1);
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
this.entries.push({
|
|
447
|
+
id: id ?? `tool-${this.#sequence++}`,
|
|
448
|
+
kind: "tool",
|
|
449
|
+
label: safeLabel,
|
|
450
|
+
toolName: safeLabel,
|
|
451
|
+
status: failed ? "failed" : "completed",
|
|
452
|
+
...safeResult !== void 0 ? { result: safeResult } : {},
|
|
453
|
+
...failed && safeResult !== void 0 ? { text: compactRedactedValue(safeResult) } : {}
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
#appendSessionMessage(event, message) {
|
|
457
|
+
const id = this.#nextId(event, "message");
|
|
458
|
+
if (message.role === "user") {
|
|
459
|
+
this.#pushMessage("user", id, contentText(message.content));
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
if (message.role === "assistant") {
|
|
463
|
+
const error = messageError(message);
|
|
464
|
+
const text = contentText(message.content);
|
|
465
|
+
if (text) this.#pushMessage("assistant", id, text, error ? "failed" : "completed");
|
|
466
|
+
if (error) {
|
|
467
|
+
this.entries.push({
|
|
468
|
+
id: `${id}-error`,
|
|
469
|
+
kind: "error",
|
|
470
|
+
label: "Agent error",
|
|
471
|
+
text: error,
|
|
472
|
+
status: "failed"
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
if (Array.isArray(message.content)) {
|
|
476
|
+
for (const value of message.content) {
|
|
477
|
+
const part = recordOf(value);
|
|
478
|
+
if (part?.type !== "toolCall" || typeof part.name !== "string") continue;
|
|
479
|
+
const toolId = typeof part.id === "string" ? part.id : `session-tool-${this.#sequence++}`;
|
|
480
|
+
this.#startTool(toolId, part.name, part.arguments);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (message.role === "toolResult") {
|
|
486
|
+
const toolId = typeof message.toolCallId === "string" ? message.toolCallId : void 0;
|
|
487
|
+
const label = typeof message.toolName === "string" ? message.toolName : "tool";
|
|
488
|
+
this.#finishTool(
|
|
489
|
+
toolId,
|
|
490
|
+
label,
|
|
491
|
+
{ content: message.content, ...message.details !== void 0 ? { details: message.details } : {} },
|
|
492
|
+
message.isError === true
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
#append(event) {
|
|
497
|
+
if (typeof event.type !== "string") return;
|
|
498
|
+
const id = this.#nextId(event);
|
|
499
|
+
if (event.type === "message") {
|
|
500
|
+
const message = recordOf(event.message);
|
|
501
|
+
if (message) this.#appendSessionMessage(event, message);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (event.type === "model_change") {
|
|
505
|
+
const provider = typeof event.provider === "string" ? event.provider : "";
|
|
506
|
+
const model = typeof event.modelId === "string" ? event.modelId : "";
|
|
507
|
+
this.entries.push({
|
|
508
|
+
id,
|
|
509
|
+
kind: "status",
|
|
510
|
+
label: "Model changed",
|
|
511
|
+
...provider || model ? { text: [provider, model].filter(Boolean).join("/") } : {},
|
|
512
|
+
status: "completed"
|
|
513
|
+
});
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (event.type === "thinking_level_change") {
|
|
517
|
+
this.entries.push({
|
|
518
|
+
id,
|
|
519
|
+
kind: "status",
|
|
520
|
+
label: "Thinking changed",
|
|
521
|
+
...typeof event.thinkingLevel === "string" ? { text: event.thinkingLevel } : {},
|
|
522
|
+
status: "completed"
|
|
523
|
+
});
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (event.type === "compaction") {
|
|
527
|
+
this.entries.push({
|
|
528
|
+
id,
|
|
529
|
+
kind: "status",
|
|
530
|
+
label: "Compacted context",
|
|
531
|
+
...typeof event.summary === "string" ? { text: terminalSafe(event.summary) } : {},
|
|
532
|
+
status: "completed"
|
|
533
|
+
});
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
if (event.type === "stream_event") {
|
|
537
|
+
const stream = recordOf(event.event);
|
|
538
|
+
const delta = recordOf(stream?.delta);
|
|
539
|
+
if (stream?.type === "content_block_delta" && delta?.type === "text_delta") {
|
|
540
|
+
const text = typeof delta.text === "string" ? terminalSafe(delta.text, false) : "";
|
|
541
|
+
if (!text) return;
|
|
542
|
+
if (!this.#assistant) {
|
|
543
|
+
this.#assistant = {
|
|
544
|
+
id,
|
|
545
|
+
kind: "assistant",
|
|
546
|
+
label: "Claude",
|
|
547
|
+
text: clip(text, MAX_TRANSCRIPT_MESSAGE_CHARS, false),
|
|
548
|
+
status: "running"
|
|
549
|
+
};
|
|
550
|
+
this.entries.push(this.#assistant);
|
|
551
|
+
} else {
|
|
552
|
+
this.#assistant.text = clip(
|
|
553
|
+
`${this.#assistant.text ?? ""}${text}`,
|
|
554
|
+
MAX_TRANSCRIPT_MESSAGE_CHARS,
|
|
555
|
+
false
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (event.type === "assistant") {
|
|
562
|
+
const message = recordOf(event.message);
|
|
563
|
+
if (!message || message.role !== "assistant") return;
|
|
564
|
+
if (Array.isArray(message.content)) {
|
|
565
|
+
for (const value of message.content) {
|
|
566
|
+
const part = recordOf(value);
|
|
567
|
+
if (part?.type !== "tool_use") continue;
|
|
568
|
+
const toolId = typeof part.id === "string" ? part.id : `claude-tool-${this.#sequence++}`;
|
|
569
|
+
const label = typeof part.name === "string" ? part.name : "tool";
|
|
570
|
+
this.#startTool(toolId, label, part.input);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
const text = terminalSafe(contentText(message.content));
|
|
574
|
+
if (text) {
|
|
575
|
+
if (this.#assistant) {
|
|
576
|
+
this.#assistant.text = clip(text, MAX_TRANSCRIPT_MESSAGE_CHARS);
|
|
577
|
+
this.#finishAssistant("completed");
|
|
578
|
+
} else {
|
|
579
|
+
this.#pushMessage("assistant", id, text, "completed", "Claude");
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (typeof event.error === "string") {
|
|
583
|
+
this.entries.push({
|
|
584
|
+
id: `${id}-error`,
|
|
585
|
+
kind: "error",
|
|
586
|
+
label: "Claude error",
|
|
587
|
+
text: clip(event.error, MAX_TOOL_SUMMARY_CHARS2),
|
|
588
|
+
status: "failed"
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (event.type === "user") {
|
|
594
|
+
const message = recordOf(event.message);
|
|
595
|
+
if (!message || !Array.isArray(message.content)) return;
|
|
596
|
+
let hasToolResult = false;
|
|
597
|
+
for (const value of message.content) {
|
|
598
|
+
const part = recordOf(value);
|
|
599
|
+
if (part?.type !== "tool_result" || typeof part.tool_use_id !== "string") continue;
|
|
600
|
+
hasToolResult = true;
|
|
601
|
+
this.#finishTool(part.tool_use_id, "tool", part.content, part.is_error === true);
|
|
602
|
+
}
|
|
603
|
+
if (!hasToolResult) this.#pushMessage("user", id, contentText(message.content));
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (event.type === "result") {
|
|
607
|
+
this.#finishAssistant(event.is_error === true ? "failed" : "completed");
|
|
608
|
+
if (event.is_error === true || event.subtype !== "success") {
|
|
609
|
+
const errors = Array.isArray(event.errors) ? event.errors.filter((value) => typeof value === "string").join(" \xB7 ") : "";
|
|
610
|
+
const text = errors || (typeof event.result === "string" ? event.result : "Claude run failed");
|
|
611
|
+
this.entries.push({
|
|
612
|
+
id,
|
|
613
|
+
kind: "error",
|
|
614
|
+
label: "Claude result",
|
|
615
|
+
text: clip(text, MAX_TOOL_SUMMARY_CHARS2),
|
|
616
|
+
status: "failed"
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
if (event.type === "system" && event.subtype === "api_retry") {
|
|
622
|
+
this.entries.push({
|
|
623
|
+
id,
|
|
624
|
+
kind: "status",
|
|
625
|
+
label: "Claude API retry",
|
|
626
|
+
status: "running",
|
|
627
|
+
...typeof event.error === "string" ? { text: clip(event.error, MAX_TOOL_SUMMARY_CHARS2) } : {}
|
|
628
|
+
});
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
if (event.type === "message_start") this.#finishAssistant("completed");
|
|
632
|
+
if (event.type === "message_start" || event.type === "message_update") {
|
|
633
|
+
const message = recordOf(event.message);
|
|
634
|
+
if (!message) return;
|
|
635
|
+
if (message.role === "user") {
|
|
636
|
+
if (event.type === "message_start") this.#pushMessage("user", id, contentText(message.content));
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if (message.role !== "assistant") return;
|
|
640
|
+
const text = terminalSafe(contentText(message.content));
|
|
641
|
+
if (!text) return;
|
|
642
|
+
if (!this.#assistant) {
|
|
643
|
+
this.#assistant = {
|
|
644
|
+
id,
|
|
645
|
+
kind: "assistant",
|
|
646
|
+
label: "Agent",
|
|
647
|
+
text: clip(text, MAX_TRANSCRIPT_MESSAGE_CHARS),
|
|
648
|
+
status: "running"
|
|
649
|
+
};
|
|
650
|
+
this.entries.push(this.#assistant);
|
|
651
|
+
} else {
|
|
652
|
+
this.#assistant.text = clip(text, MAX_TRANSCRIPT_MESSAGE_CHARS);
|
|
653
|
+
if (!this.entries.includes(this.#assistant)) this.entries.push(this.#assistant);
|
|
654
|
+
}
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (event.type === "message_end") {
|
|
658
|
+
const message = recordOf(event.message);
|
|
659
|
+
if (!message) return;
|
|
660
|
+
if (message.role === "user") {
|
|
661
|
+
this.#pushMessage("user", id, contentText(message.content));
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
if (message.role !== "assistant") return;
|
|
665
|
+
const error = messageError(message);
|
|
666
|
+
if (error) {
|
|
667
|
+
this.#finishAssistant("failed");
|
|
668
|
+
this.entries.push({ id, kind: "error", label: "Agent error", text: error, status: "failed" });
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
const text = terminalSafe(contentText(message.content));
|
|
672
|
+
if (!text) {
|
|
673
|
+
this.#finishAssistant("completed");
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
if (!this.#assistant) this.#pushMessage("assistant", id, text);
|
|
677
|
+
else {
|
|
678
|
+
this.#assistant.text = clip(text, MAX_TRANSCRIPT_MESSAGE_CHARS);
|
|
679
|
+
this.#finishAssistant("completed");
|
|
680
|
+
}
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
if (event.type === "response" && event.command === "prompt" && event.success === false) {
|
|
684
|
+
const text = typeof event.error === "string" ? event.error : "Pi rejected the prompt";
|
|
685
|
+
this.entries.push({
|
|
686
|
+
id,
|
|
687
|
+
kind: "error",
|
|
688
|
+
label: "Prompt rejected",
|
|
689
|
+
text: clip(text, MAX_TOOL_SUMMARY_CHARS2),
|
|
690
|
+
status: "failed"
|
|
691
|
+
});
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
if (event.type === "tool_execution_start") {
|
|
695
|
+
const label = typeof event.toolName === "string" ? event.toolName : "tool";
|
|
696
|
+
const entry = this.#startTool(id, label, event.args);
|
|
697
|
+
if (typeof event.toolCallId !== "string") {
|
|
698
|
+
const key = terminalSafe(label) || "tool";
|
|
699
|
+
this.#tools.delete(entry.id);
|
|
700
|
+
this.#anonymousTools.set(key, [...this.#anonymousTools.get(key) ?? [], entry]);
|
|
701
|
+
}
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
if (event.type === "tool_execution_end") {
|
|
705
|
+
const label = typeof event.toolName === "string" ? event.toolName : "tool";
|
|
706
|
+
this.#finishTool(
|
|
707
|
+
typeof event.toolCallId === "string" ? event.toolCallId : void 0,
|
|
708
|
+
label,
|
|
709
|
+
event.result,
|
|
710
|
+
event.isError === true
|
|
711
|
+
);
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
if (event.type === "auto_retry_start") {
|
|
715
|
+
const attempt = typeof event.attempt === "number" ? ` ${event.attempt}` : "";
|
|
716
|
+
this.#retry = {
|
|
717
|
+
id,
|
|
718
|
+
kind: "status",
|
|
719
|
+
label: `Retry${attempt}`,
|
|
720
|
+
status: "running",
|
|
721
|
+
...typeof event.errorMessage === "string" ? { text: clip(event.errorMessage, MAX_TOOL_SUMMARY_CHARS2) } : {}
|
|
722
|
+
};
|
|
723
|
+
this.entries.push(this.#retry);
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
if (event.type === "auto_retry_end") {
|
|
727
|
+
const failed = event.success === false;
|
|
728
|
+
if (this.#retry) {
|
|
729
|
+
this.#retry.status = failed ? "failed" : "completed";
|
|
730
|
+
if (failed && typeof event.finalError === "string") {
|
|
731
|
+
this.#retry.text = clip(event.finalError, MAX_TOOL_SUMMARY_CHARS2);
|
|
732
|
+
}
|
|
733
|
+
this.#retry = void 0;
|
|
734
|
+
}
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
if (event.type === "compaction_start") {
|
|
738
|
+
this.#compaction = {
|
|
739
|
+
id,
|
|
740
|
+
kind: "status",
|
|
741
|
+
label: "Compacting context",
|
|
742
|
+
status: "running"
|
|
743
|
+
};
|
|
744
|
+
this.entries.push(this.#compaction);
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
if (event.type === "compaction_end") {
|
|
748
|
+
if (this.#compaction) {
|
|
749
|
+
const failed = event.aborted === true || typeof event.errorMessage === "string";
|
|
750
|
+
this.#compaction.status = failed ? "failed" : "completed";
|
|
751
|
+
if (typeof event.errorMessage === "string") {
|
|
752
|
+
this.#compaction.text = clip(event.errorMessage, MAX_TOOL_SUMMARY_CHARS2);
|
|
753
|
+
}
|
|
754
|
+
this.#compaction = void 0;
|
|
755
|
+
}
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
if (event.type === "extension_error" || event.type === "worker_stderr") {
|
|
759
|
+
const text = typeof event.error === "string" ? event.error : typeof event.text === "string" ? event.text : "Extension error";
|
|
760
|
+
this.entries.push({
|
|
761
|
+
id,
|
|
762
|
+
kind: "error",
|
|
763
|
+
label: event.type === "worker_stderr" ? "Worker stderr" : "Error",
|
|
764
|
+
text: clip(text, MAX_TOOL_SUMMARY_CHARS2),
|
|
765
|
+
status: "failed"
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
var parseRaw = (raw) => {
|
|
771
|
+
try {
|
|
772
|
+
return recordOf(JSON.parse(raw));
|
|
773
|
+
} catch {
|
|
774
|
+
return void 0;
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
var parsedEvents = (lines) => lines.map((line) => recordOf(line.parsed) ?? parseRaw(line.raw)).filter((event) => event !== void 0);
|
|
778
|
+
var normalizedToolStarts = (event) => {
|
|
779
|
+
if (event.type === "tool_execution_start" && typeof event.toolCallId === "string") {
|
|
780
|
+
return [{ id: event.toolCallId, event }];
|
|
781
|
+
}
|
|
782
|
+
const starts = [];
|
|
783
|
+
const appendContentStarts = (content, type) => {
|
|
784
|
+
if (!Array.isArray(content)) return;
|
|
785
|
+
for (const value of content) {
|
|
786
|
+
const part = recordOf(value);
|
|
787
|
+
if (part?.type !== type || typeof part.id !== "string") continue;
|
|
788
|
+
const name = typeof part.name === "string" ? part.name : "tool";
|
|
789
|
+
starts.push({
|
|
790
|
+
id: part.id,
|
|
791
|
+
event: {
|
|
792
|
+
type: "tool_execution_start",
|
|
793
|
+
toolCallId: part.id,
|
|
794
|
+
toolName: name,
|
|
795
|
+
args: type === "toolCall" ? part.arguments : part.input
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
if (event.type === "message") {
|
|
801
|
+
const message = recordOf(event.message);
|
|
802
|
+
if (message?.role === "assistant") appendContentStarts(message.content, "toolCall");
|
|
803
|
+
} else if (event.type === "assistant") {
|
|
804
|
+
const message = recordOf(event.message);
|
|
805
|
+
if (message?.role === "assistant") appendContentStarts(message.content, "tool_use");
|
|
806
|
+
}
|
|
807
|
+
return starts;
|
|
808
|
+
};
|
|
809
|
+
var toolLifecycleEndIds = (event) => {
|
|
810
|
+
if (event.type === "tool_execution_end" && typeof event.toolCallId === "string") {
|
|
811
|
+
return [event.toolCallId];
|
|
812
|
+
}
|
|
813
|
+
if (event.type === "message") {
|
|
814
|
+
const message2 = recordOf(event.message);
|
|
815
|
+
return message2?.role === "toolResult" && typeof message2.toolCallId === "string" ? [message2.toolCallId] : [];
|
|
816
|
+
}
|
|
817
|
+
if (event.type !== "user") return [];
|
|
818
|
+
const message = recordOf(event.message);
|
|
819
|
+
if (!Array.isArray(message?.content)) return [];
|
|
820
|
+
return message.content.flatMap((value) => {
|
|
821
|
+
const part = recordOf(value);
|
|
822
|
+
return part?.type === "tool_result" && typeof part.tool_use_id === "string" ? [part.tool_use_id] : [];
|
|
823
|
+
});
|
|
824
|
+
};
|
|
825
|
+
var missingToolStartIds = (events) => {
|
|
826
|
+
const active = /* @__PURE__ */ new Set();
|
|
827
|
+
const missing = /* @__PURE__ */ new Set();
|
|
828
|
+
for (const event of events) {
|
|
829
|
+
for (const start of normalizedToolStarts(event)) active.add(start.id);
|
|
830
|
+
for (const id of toolLifecycleEndIds(event)) {
|
|
831
|
+
if (active.has(id)) active.delete(id);
|
|
832
|
+
else missing.add(id);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
return missing;
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// src/ui/transcript-reader.ts
|
|
839
|
+
var PAGE_LINES = 40;
|
|
840
|
+
var TOOL_LIFECYCLE_CONTEXT_LINES = PAGE_LINES * 4;
|
|
841
|
+
var MAX_PAGE_BYTES = 512 * 1024;
|
|
842
|
+
var MAX_CACHE_ENTRIES = 32;
|
|
843
|
+
var FORWARD_READ_CHUNK_BYTES = 64 * 1024;
|
|
844
|
+
var completeLogEnd = (descriptor, size, fallback = 0) => {
|
|
845
|
+
if (size <= 0) return 0;
|
|
846
|
+
const scanFloor = Math.max(0, size - MAX_PAGE_BYTES);
|
|
847
|
+
let scanEnd = size;
|
|
848
|
+
while (scanEnd > scanFloor) {
|
|
849
|
+
const scanStart = Math.max(scanFloor, scanEnd - FORWARD_READ_CHUNK_BYTES);
|
|
850
|
+
const chunk = Buffer.allocUnsafe(scanEnd - scanStart);
|
|
851
|
+
const bytesRead = fs.readSync(descriptor, chunk, 0, chunk.length, scanStart);
|
|
852
|
+
if (bytesRead <= 0) return 0;
|
|
853
|
+
for (let index = bytesRead - 1; index >= 0; index--) {
|
|
854
|
+
if (chunk[index] === 10) return scanStart + index + 1;
|
|
855
|
+
}
|
|
856
|
+
scanEnd = scanStart;
|
|
857
|
+
}
|
|
858
|
+
return Math.min(fallback, size);
|
|
859
|
+
};
|
|
860
|
+
var readForwardPage = (descriptor, start, end) => {
|
|
861
|
+
const lines = [];
|
|
862
|
+
const readLimit = Math.min(end, Math.max(0, start) + MAX_PAGE_BYTES);
|
|
863
|
+
let readOffset = Math.max(0, start);
|
|
864
|
+
let pending = Buffer.alloc(0);
|
|
865
|
+
let pendingOffset = readOffset;
|
|
866
|
+
let pageEnd = readOffset;
|
|
867
|
+
while (readOffset < readLimit && lines.length < PAGE_LINES) {
|
|
868
|
+
const chunkSize = Math.min(FORWARD_READ_CHUNK_BYTES, readLimit - readOffset);
|
|
869
|
+
const chunk = Buffer.allocUnsafe(chunkSize);
|
|
870
|
+
const bytesRead = fs.readSync(descriptor, chunk, 0, chunkSize, readOffset);
|
|
871
|
+
if (bytesRead <= 0) break;
|
|
872
|
+
const data = pending.length > 0 ? Buffer.concat([pending, chunk.subarray(0, bytesRead)]) : chunk.subarray(0, bytesRead);
|
|
873
|
+
const dataOffset = pending.length > 0 ? pendingOffset : readOffset;
|
|
874
|
+
let lineStart = 0;
|
|
875
|
+
for (let index = 0; index < data.length; index++) {
|
|
876
|
+
if (data[index] !== 10) continue;
|
|
877
|
+
const raw = data.subarray(lineStart, index).toString("utf8").replace(/\r$/, "");
|
|
878
|
+
pageEnd = dataOffset + index + 1;
|
|
879
|
+
if (raw) {
|
|
880
|
+
const offset = dataOffset + lineStart;
|
|
881
|
+
const parsed = parseRaw(raw);
|
|
882
|
+
lines.push({ offset, raw, ...parsed ? { parsed } : {} });
|
|
883
|
+
if (lines.length >= PAGE_LINES) return { lines, end: pageEnd };
|
|
884
|
+
}
|
|
885
|
+
lineStart = index + 1;
|
|
886
|
+
}
|
|
887
|
+
pending = Buffer.from(data.subarray(lineStart));
|
|
888
|
+
pendingOffset = dataOffset + lineStart;
|
|
889
|
+
readOffset += bytesRead;
|
|
890
|
+
}
|
|
891
|
+
return { lines, end: readOffset >= end ? end : pageEnd };
|
|
892
|
+
};
|
|
893
|
+
var AgentTranscriptReader = class {
|
|
894
|
+
#cache = /* @__PURE__ */ new Map();
|
|
895
|
+
read(source, followLatest = true) {
|
|
896
|
+
const filePath = source.logFile;
|
|
897
|
+
if (!filePath) {
|
|
898
|
+
return { entries: [], truncated: false, hasMore: false, hasNewer: false };
|
|
899
|
+
}
|
|
900
|
+
const cached = this.#cache.get(filePath);
|
|
901
|
+
let descriptor;
|
|
902
|
+
try {
|
|
903
|
+
const noFollow = typeof fs.constants.O_NOFOLLOW === "number" ? fs.constants.O_NOFOLLOW : 0;
|
|
904
|
+
descriptor = fs.openSync(filePath, fs.constants.O_RDONLY | noFollow);
|
|
905
|
+
const stat = fs.fstatSync(descriptor);
|
|
906
|
+
if (!stat.isFile()) {
|
|
907
|
+
return cached?.transcript ?? {
|
|
908
|
+
entries: [],
|
|
909
|
+
truncated: false,
|
|
910
|
+
hasMore: false,
|
|
911
|
+
hasNewer: false
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
const sameFile = cached?.device === stat.dev && cached.inode === stat.ino;
|
|
915
|
+
const sameSizeRewrite = sameFile && cached.offset === stat.size && cached.modifiedAt !== stat.mtimeMs;
|
|
916
|
+
let state;
|
|
917
|
+
if (!cached || !sameFile || stat.size < cached.offset || sameSizeRewrite) {
|
|
918
|
+
state = this.#latestState(descriptor, stat);
|
|
919
|
+
} else if (stat.size !== cached.offset || stat.mtimeMs !== cached.modifiedAt) {
|
|
920
|
+
const wasAtTail = cached.pageEnd >= cached.completeEnd;
|
|
921
|
+
const completeEnd = completeLogEnd(descriptor, stat.size, cached.completeEnd);
|
|
922
|
+
if (cached.pageEnd > completeEnd || followLatest && wasAtTail && completeEnd > cached.completeEnd) {
|
|
923
|
+
state = this.#latestState(descriptor, stat, completeEnd);
|
|
924
|
+
} else {
|
|
925
|
+
state = {
|
|
926
|
+
...cached,
|
|
927
|
+
modifiedAt: stat.mtimeMs,
|
|
928
|
+
offset: stat.size,
|
|
929
|
+
completeEnd,
|
|
930
|
+
transcript: {
|
|
931
|
+
...cached.transcript,
|
|
932
|
+
hasNewer: cached.pageEnd < completeEnd,
|
|
933
|
+
updatedAt: stat.mtimeMs
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
} else {
|
|
938
|
+
state = cached;
|
|
939
|
+
}
|
|
940
|
+
this.#remember(filePath, state);
|
|
941
|
+
return state.transcript;
|
|
942
|
+
} catch {
|
|
943
|
+
return cached?.transcript ?? {
|
|
944
|
+
entries: [],
|
|
945
|
+
truncated: false,
|
|
946
|
+
hasMore: false,
|
|
947
|
+
hasNewer: false
|
|
948
|
+
};
|
|
949
|
+
} finally {
|
|
950
|
+
if (descriptor !== void 0) {
|
|
951
|
+
try {
|
|
952
|
+
fs.closeSync(descriptor);
|
|
953
|
+
} catch {
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
loadOlder(source) {
|
|
959
|
+
const filePath = source.logFile;
|
|
960
|
+
if (!filePath) return false;
|
|
961
|
+
this.read(source, false);
|
|
962
|
+
const cached = this.#cache.get(filePath);
|
|
963
|
+
if (!cached?.hasMore || cached.pageStart <= 0) return false;
|
|
964
|
+
let descriptor;
|
|
965
|
+
try {
|
|
966
|
+
const noFollow = typeof fs.constants.O_NOFOLLOW === "number" ? fs.constants.O_NOFOLLOW : 0;
|
|
967
|
+
descriptor = fs.openSync(filePath, fs.constants.O_RDONLY | noFollow);
|
|
968
|
+
const stat = fs.fstatSync(descriptor);
|
|
969
|
+
if (!stat.isFile() || stat.dev !== cached.device || stat.ino !== cached.inode) return false;
|
|
970
|
+
const completeEnd = completeLogEnd(descriptor, stat.size, cached.completeEnd);
|
|
971
|
+
const pageEnd = Math.min(cached.pageStart, completeEnd);
|
|
972
|
+
const page = readJsonlPageFromDescriptor(
|
|
973
|
+
descriptor,
|
|
974
|
+
PAGE_LINES,
|
|
975
|
+
pageEnd,
|
|
976
|
+
stat.size,
|
|
977
|
+
MAX_PAGE_BYTES
|
|
978
|
+
);
|
|
979
|
+
const pageStart = page.lines[0]?.offset;
|
|
980
|
+
if (pageStart === void 0) return false;
|
|
981
|
+
const state = this.#stateForPage(
|
|
982
|
+
descriptor,
|
|
983
|
+
stat,
|
|
984
|
+
completeEnd,
|
|
985
|
+
page.lines,
|
|
986
|
+
pageStart,
|
|
987
|
+
pageEnd,
|
|
988
|
+
page.hasMore
|
|
989
|
+
);
|
|
990
|
+
this.#remember(filePath, state);
|
|
991
|
+
return true;
|
|
992
|
+
} catch {
|
|
993
|
+
return false;
|
|
994
|
+
} finally {
|
|
995
|
+
if (descriptor !== void 0) {
|
|
996
|
+
try {
|
|
997
|
+
fs.closeSync(descriptor);
|
|
998
|
+
} catch {
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
loadNewer(source) {
|
|
1004
|
+
const filePath = source.logFile;
|
|
1005
|
+
if (!filePath) return false;
|
|
1006
|
+
this.read(source, false);
|
|
1007
|
+
const cached = this.#cache.get(filePath);
|
|
1008
|
+
if (!cached || cached.pageEnd >= cached.completeEnd) return false;
|
|
1009
|
+
let descriptor;
|
|
1010
|
+
try {
|
|
1011
|
+
const noFollow = typeof fs.constants.O_NOFOLLOW === "number" ? fs.constants.O_NOFOLLOW : 0;
|
|
1012
|
+
descriptor = fs.openSync(filePath, fs.constants.O_RDONLY | noFollow);
|
|
1013
|
+
const stat = fs.fstatSync(descriptor);
|
|
1014
|
+
if (!stat.isFile() || stat.dev !== cached.device || stat.ino !== cached.inode) return false;
|
|
1015
|
+
const completeEnd = completeLogEnd(descriptor, stat.size, cached.completeEnd);
|
|
1016
|
+
const page = readForwardPage(descriptor, cached.pageEnd, completeEnd);
|
|
1017
|
+
if (page.lines.length === 0 || page.end <= cached.pageEnd) return false;
|
|
1018
|
+
const state = this.#stateForPage(
|
|
1019
|
+
descriptor,
|
|
1020
|
+
stat,
|
|
1021
|
+
completeEnd,
|
|
1022
|
+
page.lines,
|
|
1023
|
+
cached.pageEnd,
|
|
1024
|
+
page.end,
|
|
1025
|
+
cached.pageEnd > 0
|
|
1026
|
+
);
|
|
1027
|
+
this.#remember(filePath, state);
|
|
1028
|
+
return true;
|
|
1029
|
+
} catch {
|
|
1030
|
+
return false;
|
|
1031
|
+
} finally {
|
|
1032
|
+
if (descriptor !== void 0) {
|
|
1033
|
+
try {
|
|
1034
|
+
fs.closeSync(descriptor);
|
|
1035
|
+
} catch {
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
loadLatest(source) {
|
|
1041
|
+
const filePath = source.logFile;
|
|
1042
|
+
if (!filePath) return false;
|
|
1043
|
+
this.read(source, false);
|
|
1044
|
+
const cached = this.#cache.get(filePath);
|
|
1045
|
+
let descriptor;
|
|
1046
|
+
try {
|
|
1047
|
+
const noFollow = typeof fs.constants.O_NOFOLLOW === "number" ? fs.constants.O_NOFOLLOW : 0;
|
|
1048
|
+
descriptor = fs.openSync(filePath, fs.constants.O_RDONLY | noFollow);
|
|
1049
|
+
const stat = fs.fstatSync(descriptor);
|
|
1050
|
+
if (!stat.isFile()) return false;
|
|
1051
|
+
if (cached && (stat.dev !== cached.device || stat.ino !== cached.inode)) return false;
|
|
1052
|
+
const completeEnd = completeLogEnd(descriptor, stat.size, cached?.completeEnd ?? 0);
|
|
1053
|
+
const state = this.#latestState(descriptor, stat, completeEnd);
|
|
1054
|
+
this.#remember(filePath, state);
|
|
1055
|
+
return true;
|
|
1056
|
+
} catch {
|
|
1057
|
+
return false;
|
|
1058
|
+
} finally {
|
|
1059
|
+
if (descriptor !== void 0) {
|
|
1060
|
+
try {
|
|
1061
|
+
fs.closeSync(descriptor);
|
|
1062
|
+
} catch {
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
clear() {
|
|
1068
|
+
this.#cache.clear();
|
|
1069
|
+
}
|
|
1070
|
+
#latestState(descriptor, stat, knownCompleteEnd) {
|
|
1071
|
+
const completeEnd = knownCompleteEnd ?? completeLogEnd(descriptor, stat.size);
|
|
1072
|
+
const page = readJsonlPageFromDescriptor(
|
|
1073
|
+
descriptor,
|
|
1074
|
+
PAGE_LINES,
|
|
1075
|
+
completeEnd,
|
|
1076
|
+
stat.size,
|
|
1077
|
+
MAX_PAGE_BYTES
|
|
1078
|
+
);
|
|
1079
|
+
return this.#stateForPage(
|
|
1080
|
+
descriptor,
|
|
1081
|
+
stat,
|
|
1082
|
+
completeEnd,
|
|
1083
|
+
page.lines,
|
|
1084
|
+
page.lines[0]?.offset ?? completeEnd,
|
|
1085
|
+
completeEnd,
|
|
1086
|
+
page.hasMore
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
#stateForPage(descriptor, stat, completeEnd, lines, pageStart, pageEnd, hasMore) {
|
|
1090
|
+
const events = parsedEvents(lines);
|
|
1091
|
+
const missingStarts = missingToolStartIds(events);
|
|
1092
|
+
const lifecycleContext = [];
|
|
1093
|
+
if (missingStarts.size > 0 && pageStart > 0) {
|
|
1094
|
+
const contextPage = readJsonlPageFromDescriptor(
|
|
1095
|
+
descriptor,
|
|
1096
|
+
TOOL_LIFECYCLE_CONTEXT_LINES,
|
|
1097
|
+
pageStart,
|
|
1098
|
+
stat.size,
|
|
1099
|
+
MAX_PAGE_BYTES
|
|
1100
|
+
);
|
|
1101
|
+
const contextEvents = parsedEvents(contextPage.lines);
|
|
1102
|
+
for (let index = contextEvents.length - 1; index >= 0 && missingStarts.size > 0; index--) {
|
|
1103
|
+
const starts = normalizedToolStarts(contextEvents[index]);
|
|
1104
|
+
for (let startIndex = starts.length - 1; startIndex >= 0; startIndex--) {
|
|
1105
|
+
const start = starts[startIndex];
|
|
1106
|
+
if (!missingStarts.delete(start.id)) continue;
|
|
1107
|
+
lifecycleContext.unshift(start.event);
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
const accumulator = new TranscriptAccumulator();
|
|
1112
|
+
accumulator.append([...lifecycleContext, ...events]);
|
|
1113
|
+
const transcript = {
|
|
1114
|
+
...accumulator.snapshot(hasMore, stat.mtimeMs, Number.MAX_SAFE_INTEGER),
|
|
1115
|
+
hasNewer: pageEnd < completeEnd
|
|
1116
|
+
};
|
|
1117
|
+
return {
|
|
1118
|
+
device: stat.dev,
|
|
1119
|
+
inode: stat.ino,
|
|
1120
|
+
modifiedAt: stat.mtimeMs,
|
|
1121
|
+
offset: stat.size,
|
|
1122
|
+
completeEnd,
|
|
1123
|
+
pageStart,
|
|
1124
|
+
pageEnd,
|
|
1125
|
+
hasMore: transcript.hasMore ?? false,
|
|
1126
|
+
transcript
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
#remember(filePath, state) {
|
|
1130
|
+
this.#cache.delete(filePath);
|
|
1131
|
+
this.#cache.set(filePath, state);
|
|
1132
|
+
while (this.#cache.size > MAX_CACHE_ENTRIES) {
|
|
1133
|
+
const oldest = this.#cache.keys().next().value;
|
|
1134
|
+
if (!oldest) break;
|
|
1135
|
+
this.#cache.delete(oldest);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
// src/ui/transcript.ts
|
|
1141
|
+
var PREVIEW_TREE_GUARD_MAX_DEPTH = 8;
|
|
1142
|
+
var isFabricAgentToolPreviewNode = (value, depth) => {
|
|
1143
|
+
const record = recordOf(value);
|
|
1144
|
+
if (!record || typeof record.id !== "string" || typeof record.name !== "string" || record.text !== void 0 && typeof record.text !== "string" || record.currentTool !== void 0 && typeof record.currentTool !== "string" || !Array.isArray(record.tools)) {
|
|
1145
|
+
return false;
|
|
1146
|
+
}
|
|
1147
|
+
if (record.agents === void 0) return true;
|
|
1148
|
+
if (depth >= PREVIEW_TREE_GUARD_MAX_DEPTH || !Array.isArray(record.agents)) return false;
|
|
1149
|
+
return record.agents.every((child) => isFabricAgentToolPreviewNode(child, depth + 1));
|
|
1150
|
+
};
|
|
1151
|
+
var isFabricAgentToolPreview = (value) => recordOf(value)?.kind === "fabric-agent-tools" && isFabricAgentToolPreviewNode(value, 0);
|
|
1152
|
+
var recentTranscriptTools = (transcript, limit = 2) => {
|
|
1153
|
+
const tools = transcript.entries.filter((entry) => entry.kind === "tool");
|
|
1154
|
+
const boundedLimit = Math.max(1, limit);
|
|
1155
|
+
const running = tools.filter((entry) => entry.status === "running");
|
|
1156
|
+
const completed = tools.filter((entry) => entry.status !== "running");
|
|
1157
|
+
const completedSlots = Math.max(0, boundedLimit - Math.min(running.length, boundedLimit));
|
|
1158
|
+
const retained = /* @__PURE__ */ new Set([
|
|
1159
|
+
...running.slice(-boundedLimit),
|
|
1160
|
+
...completed.slice(-completedSlots)
|
|
1161
|
+
]);
|
|
1162
|
+
return tools.filter((entry) => retained.has(entry)).slice(-boundedLimit).map((entry) => ({ ...entry }));
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
export {
|
|
1166
|
+
headlineArg,
|
|
1167
|
+
countContentLines,
|
|
1168
|
+
selectPreviewTextLines,
|
|
1169
|
+
MAX_WRITE_DIFF_BYTES,
|
|
1170
|
+
writeContentForPreview,
|
|
1171
|
+
shouldSkipWriteDiffBytes,
|
|
1172
|
+
shouldSkipWriteDiffComplexity,
|
|
1173
|
+
AgentTranscriptReader,
|
|
1174
|
+
isFabricAgentToolPreview,
|
|
1175
|
+
recentTranscriptTools
|
|
1176
|
+
};
|
|
1177
|
+
//# sourceMappingURL=chunk-27WW5M4Q.js.map
|