@wrongstack/core 0.313.0 → 0.316.1
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/chronicle/index.js +84 -6391
- package/dist/chronicle/legacy-journal-import.d.ts +0 -6
- package/dist/chronicle/metrics-ingest.d.ts +14 -0
- package/dist/chronicle/metrics-schema.d.ts +10 -1
- package/dist/chronicle/metrics-store.d.ts +20 -2
- package/dist/chronicle/project-server.js +98 -4874
- package/dist/chronicle/sink.d.ts +13 -0
- package/dist/chronicle/sqlite-journal.d.ts +20 -2
- package/dist/chunk-25LSLC3G.js +334 -0
- package/dist/chunk-27QIURLN.js +1073 -0
- package/dist/chunk-2FK4WTFF.js +207 -0
- package/dist/chunk-2YU4WVBW.js +134 -0
- package/dist/chunk-3AGWVSS7.js +4608 -0
- package/dist/chunk-3BDV7RL3.js +211 -0
- package/dist/chunk-3ECENVHL.js +325 -0
- package/dist/chunk-3XPVB7BA.js +135 -0
- package/dist/chunk-45WI72ZB.js +16884 -0
- package/dist/chunk-4BMVPOHO.js +3748 -0
- package/dist/chunk-4I7HGVVA.js +363 -0
- package/dist/chunk-4LCZVJVF.js +317 -0
- package/dist/chunk-4SJNS7OB.js +217 -0
- package/dist/chunk-4VWO3ZXL.js +342 -0
- package/dist/chunk-57GEWK5X.js +26 -0
- package/dist/chunk-5BMIE7QG.js +46 -0
- package/dist/chunk-5S437PRC.js +50 -0
- package/dist/chunk-5XDUGTKN.js +511 -0
- package/dist/chunk-5YPSXQXM.js +1443 -0
- package/dist/chunk-6FHWXLPT.js +10 -0
- package/dist/chunk-6H5GEOET.js +2406 -0
- package/dist/chunk-6NWEVFEL.js +151 -0
- package/dist/chunk-AYW5YINX.js +58 -0
- package/dist/chunk-B4AMLZPB.js +9 -0
- package/dist/chunk-B7F4WVP4.js +65 -0
- package/dist/chunk-BJHVULHO.js +55 -0
- package/dist/chunk-BPBKKBUK.js +2085 -0
- package/dist/chunk-BYD345OX.js +589 -0
- package/dist/chunk-C27KDLOX.js +279 -0
- package/dist/chunk-CU546ESW.js +597 -0
- package/dist/chunk-DLHHXUAM.js +172 -0
- package/dist/chunk-DOTHQSJ2.js +429 -0
- package/dist/chunk-DYLPMV4Q.js +711 -0
- package/dist/chunk-EODDVJBM.js +82 -0
- package/dist/chunk-F3JWNST7.js +361 -0
- package/dist/chunk-FC2ZGRF3.js +140 -0
- package/dist/chunk-FCBTO76Z.js +5786 -0
- package/dist/chunk-FHZVFYSL.js +396 -0
- package/dist/chunk-FNXVT7HF.js +52 -0
- package/dist/chunk-FWNLEZYG.js +259 -0
- package/dist/chunk-FXQLIX3K.js +211 -0
- package/dist/chunk-G5S3S5ZN.js +38 -0
- package/dist/chunk-GDQ7CZRQ.js +116 -0
- package/dist/chunk-GJJGJB2R.js +1374 -0
- package/dist/chunk-GTCU6DZ3.js +1 -0
- package/dist/chunk-HA4ZYA6T.js +178 -0
- package/dist/chunk-HI3JGZR2.js +188 -0
- package/dist/chunk-HMLIGAU7.js +395 -0
- package/dist/chunk-HXKZ7OBQ.js +303 -0
- package/dist/chunk-I7DALG7J.js +292 -0
- package/dist/chunk-IRUTEHCE.js +960 -0
- package/dist/chunk-IYFBFX34.js +86 -0
- package/dist/chunk-J2WRWR37.js +1104 -0
- package/dist/chunk-JFPJ6LLQ.js +129 -0
- package/dist/chunk-JMULFFLN.js +9 -0
- package/dist/chunk-JO4MGB6Z.js +1264 -0
- package/dist/chunk-JVKB2TBL.js +48 -0
- package/dist/chunk-JX7VBZDK.js +31 -0
- package/dist/chunk-K6BXGITA.js +931 -0
- package/dist/chunk-KDQJCT2J.js +45 -0
- package/dist/chunk-KJ2ZTQSL.js +47 -0
- package/dist/chunk-KZMSZV32.js +187 -0
- package/dist/chunk-LA7CLDRW.js +129 -0
- package/dist/chunk-LHOA5DWA.js +28 -0
- package/dist/chunk-LSMMOS2Z.js +119 -0
- package/dist/chunk-LX5QWLBL.js +27 -0
- package/dist/chunk-LXWCMQNJ.js +789 -0
- package/dist/chunk-M27LIEKV.js +2829 -0
- package/dist/chunk-MJPHJRAL.js +663 -0
- package/dist/chunk-MTL4O5YR.js +228 -0
- package/dist/chunk-NDBIPFNY.js +102 -0
- package/dist/chunk-NEMIWEXC.js +1199 -0
- package/dist/chunk-NHJ75HXY.js +1 -0
- package/dist/chunk-NIOAGFPB.js +1510 -0
- package/dist/chunk-NS52ISWS.js +355 -0
- package/dist/chunk-NSOFPKGT.js +5352 -0
- package/dist/chunk-NVIZG63R.js +757 -0
- package/dist/chunk-O37BQ65S.js +21 -0
- package/dist/chunk-OOYZPOXM.js +308 -0
- package/dist/chunk-OSGLYW5J.js +28 -0
- package/dist/chunk-PFCMSSUF.js +1640 -0
- package/dist/chunk-PFZO3C6H.js +14 -0
- package/dist/chunk-PGRVXIMY.js +158 -0
- package/dist/chunk-PHH7LD45.js +113 -0
- package/dist/chunk-PISBFBJN.js +109 -0
- package/dist/chunk-POOOIWE5.js +9 -0
- package/dist/chunk-PQNS3U7Z.js +1240 -0
- package/dist/chunk-QSTSJOCK.js +402 -0
- package/dist/chunk-RFQMOKWK.js +282 -0
- package/dist/chunk-RJIZEJ42.js +30 -0
- package/dist/chunk-RTOTNK3P.js +484 -0
- package/dist/chunk-RXKSDUAU.js +1172 -0
- package/dist/chunk-S45JPKQN.js +3317 -0
- package/dist/chunk-SAFHACFA.js +152 -0
- package/dist/chunk-SQJVFEBV.js +41 -0
- package/dist/chunk-SVT4RNTR.js +49 -0
- package/dist/chunk-SWUFN7XM.js +43 -0
- package/dist/chunk-SXMVYC5H.js +174 -0
- package/dist/chunk-SZ6AYUIZ.js +23 -0
- package/dist/chunk-TBRL2RCC.js +9 -0
- package/dist/chunk-TCCHINEF.js +655 -0
- package/dist/chunk-THEGTRAG.js +316 -0
- package/dist/chunk-TR4LQE7L.js +2256 -0
- package/dist/chunk-TRT2HRWZ.js +18 -0
- package/dist/chunk-TWJMGXCI.js +900 -0
- package/dist/chunk-U45AXT5D.js +1023 -0
- package/dist/chunk-U4FWBSO3.js +509 -0
- package/dist/chunk-UBGDX6FI.js +147 -0
- package/dist/chunk-UJILKYES.js +75 -0
- package/dist/chunk-ULMAQV3T.js +234 -0
- package/dist/chunk-VVBP6KGT.js +9 -0
- package/dist/chunk-W5VITDM2.js +168 -0
- package/dist/chunk-WAHQVNWT.js +194 -0
- package/dist/chunk-WBPVKEEE.js +227 -0
- package/dist/chunk-WGGYRBXH.js +5434 -0
- package/dist/chunk-WLYKU45P.js +5770 -0
- package/dist/chunk-WP7BVANJ.js +53 -0
- package/dist/chunk-WQQON3SV.js +473 -0
- package/dist/chunk-WQTOVMGV.js +119 -0
- package/dist/chunk-XBDP4QPW.js +7 -0
- package/dist/chunk-XEBHSJLT.js +103 -0
- package/dist/chunk-XF4VUMKW.js +231 -0
- package/dist/chunk-XQ2ECNK3.js +1 -0
- package/dist/chunk-Y5YXDM7D.js +74 -0
- package/dist/chunk-YOPAUVU4.js +2588 -0
- package/dist/chunk-YPT4A46F.js +362 -0
- package/dist/chunk-YWXT3JNM.js +425 -0
- package/dist/chunk-YY6APYUM.js +49 -0
- package/dist/chunk-Z2IJUO45.js +691 -0
- package/dist/chunk-ZHZ2Y2DH.js +1643 -0
- package/dist/chunk-ZT7JNIGX.js +152 -0
- package/dist/coordination/agent-monitor.d.ts +9 -1
- package/dist/coordination/agent-subagent-runner.d.ts +1 -1
- package/dist/coordination/agents/agent-prompts.d.ts +8 -0
- package/dist/coordination/agents/index.d.ts +33 -1
- package/dist/coordination/agents/index.js +184 -6269
- package/dist/coordination/agents/phase3-wave1-platform.d.ts +1 -3
- package/dist/coordination/agents/phase3-wave2-meta.d.ts +1 -3
- package/dist/coordination/agents/phase8-wave3-products.d.ts +1 -3
- package/dist/coordination/agents/phase9-wave4-platform-meta.d.ts +1 -3
- package/dist/coordination/agents/project-agent-identity.d.ts +11 -11
- package/dist/coordination/agents/types.d.ts +13 -2
- package/dist/coordination/brain-monitor.d.ts +30 -7
- package/dist/coordination/collab-debug.d.ts +1 -1
- package/dist/coordination/collab-pause.d.ts +1 -1
- package/dist/coordination/delegate-tool.d.ts +7 -5
- package/dist/coordination/director-kanban-queue-helpers.d.ts +1 -0
- package/dist/coordination/director-options.d.ts +7 -0
- package/dist/coordination/director-spawn-model.d.ts +17 -0
- package/dist/coordination/director-tools.d.ts +2 -2
- package/dist/coordination/director.d.ts +12 -0
- package/dist/coordination/dispatcher.d.ts +8 -0
- package/dist/coordination/fleet-bus.d.ts +35 -4
- package/dist/coordination/fleet-supervisor.d.ts +10 -2
- package/dist/coordination/fleet.d.ts +16 -7
- package/dist/coordination/index.d.ts +4 -0
- package/dist/coordination/index.js +402 -34324
- package/dist/coordination/kanban-dispatch-port.d.ts +2 -2
- package/dist/coordination/mailbox-http-router.d.ts +4 -3
- package/dist/coordination/mailbox-http-validation.d.ts +1 -1
- package/dist/coordination/mailbox-project-server.js +48 -3276
- package/dist/coordination/mailbox-types.d.ts +24 -6
- package/dist/coordination/model-tier-leader.d.ts +122 -0
- package/dist/coordination/model-tier.d.ts +122 -0
- package/dist/coordination/multi-agent-coordinator.d.ts +24 -0
- package/dist/coordination/origin-session.d.ts +16 -0
- package/dist/coordination/provider-status-tracker.d.ts +41 -5
- package/dist/coordination/session-note-hub.d.ts +44 -0
- package/dist/coordination/session-note-tool.d.ts +10 -0
- package/dist/core/agent.d.ts +15 -2
- package/dist/core/context.d.ts +22 -3
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +239 -12360
- package/dist/core/model-ref.js +5 -23
- package/dist/core/provider-runner.d.ts +36 -1
- package/dist/core/request-conversation-binding.d.ts +37 -0
- package/dist/core/session-notes.d.ts +25 -0
- package/dist/core/system-prompt-builder.d.ts +11 -2
- package/dist/core/system-prompt-variants.d.ts +78 -0
- package/dist/design/index.js +50 -1087
- package/dist/execution/auto-compaction-middleware.d.ts +11 -0
- package/dist/execution/autonomy-brain.d.ts +2 -1
- package/dist/execution/autonomy-prompt-contributor.d.ts +7 -2
- package/dist/execution/compaction-core.d.ts +4 -4
- package/dist/execution/eternal-autonomy.d.ts +1 -1
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.js +1615 -21895
- package/dist/execution/model-runtime.d.ts +0 -7
- package/dist/execution/parallel-eternal-engine.d.ts +7 -7
- package/dist/execution/prompt-enhancer.js +16 -535
- package/dist/execution/retry-policy.d.ts +31 -1
- package/dist/extension/index.js +7 -311
- package/dist/goal/index.js +33 -3435
- package/dist/hooks/index.js +14 -1138
- package/dist/hq/index.js +114 -5139
- package/dist/hq/persistence/event-log.d.ts +0 -1
- package/dist/hq/persistence.d.ts +4 -4
- package/dist/hq/protocol.js +21 -668
- package/dist/hq/publisher.d.ts +2 -0
- package/dist/index.d.ts +14 -11
- package/dist/index.js +1502 -92655
- package/dist/infrastructure/index.d.ts +4 -4
- package/dist/infrastructure/index.js +504 -5230
- package/dist/infrastructure/token-counter.d.ts +9 -0
- package/dist/kernel/events/agent-events.d.ts +77 -3
- package/dist/kernel/events/brain-events.d.ts +12 -0
- package/dist/kernel/events/provider-events.d.ts +22 -1
- package/dist/kernel/events/session-events.d.ts +14 -0
- package/dist/kernel/events/tool-events.d.ts +13 -0
- package/dist/kernel/index.js +14 -992
- package/dist/mailbox-attach.d.ts +1 -1
- package/dist/models/index.js +41 -1117
- package/dist/notifications/index.js +3 -108
- package/dist/observability/event-bridge.d.ts +25 -5
- package/dist/observability/index.d.ts +9 -8
- package/dist/observability/index.js +477 -631
- package/dist/observability/tool-usage-source.d.ts +65 -0
- package/dist/plugin/index.d.ts +5 -0
- package/dist/plugin/index.js +600 -14835
- package/dist/plugins/auto-review-plugin.d.ts +3 -2
- package/dist/plugins/review-finding-commands.d.ts +0 -8
- package/dist/plugins/review-finding-store.js +22 -0
- package/dist/plugins/review-finding-types.js +19 -0
- package/dist/plugins/review-report-integration.js +21 -0
- package/dist/plugins/review-report-store.js +20 -0
- package/dist/plugins/review-report-types.js +13 -0
- package/dist/prompts/index.js +14 -948
- package/dist/registry/index.js +9 -822
- package/dist/registry/tool-registry.d.ts +59 -9
- package/dist/registry-7N4O3E7W.js +14 -0
- package/dist/replay/index.js +6 -84
- package/dist/security/capabilities.d.ts +6 -0
- package/dist/security/file-permissions.d.ts +1 -1
- package/dist/security/index.js +161 -2235
- package/dist/security/permission-policy.d.ts +12 -1
- package/dist/security/secret-scrubber.d.ts +15 -0
- package/dist/session-catalog/index.d.ts +1 -0
- package/dist/session-catalog/index.js +41 -2103
- package/dist/session-catalog/project-server.js +59 -1435
- package/dist/session-catalog/protocol.d.ts +32 -1
- package/dist/session-catalog/registry.d.ts +17 -1
- package/dist/session-catalog/session-agents.d.ts +56 -0
- package/dist/session-catalog/store-rebuild.d.ts +14 -0
- package/dist/session-catalog/store-schema.d.ts +26 -0
- package/dist/session-catalog/store.d.ts +27 -1
- package/dist/session-note-attach.d.ts +9 -0
- package/dist/skills/index.js +35 -1578
- package/dist/statusline/index.d.ts +43 -0
- package/dist/statusline/index.js +102 -0
- package/dist/storage/board-store-port.d.ts +2 -2
- package/dist/storage/config-loader/in-project-policy.d.ts +29 -0
- package/dist/storage/config-loader.d.ts +3 -2
- package/dist/storage/file-session-writer.d.ts +4 -2
- package/dist/storage/goal-coordination.d.ts +6 -1
- package/dist/storage/goal-kanban.d.ts +4 -1
- package/dist/storage/index.d.ts +12 -4
- package/dist/storage/index.js +198 -15601
- package/dist/storage/input-history-store.d.ts +2 -4
- package/dist/storage/memory-curator.d.ts +133 -0
- package/dist/storage/session-agent-attribution.d.ts +39 -0
- package/dist/storage/session-doctor.d.ts +109 -0
- package/dist/storage/session-event-bridge.d.ts +5 -7
- package/dist/storage/session-outcome.d.ts +42 -0
- package/dist/storage/session-recovery.d.ts +55 -0
- package/dist/storage/session-store/load-session-data.d.ts +11 -0
- package/dist/storage/session-store/prune-helpers.d.ts +1 -1
- package/dist/storage/session-store/resume-session.d.ts +0 -2
- package/dist/storage/session-store/types.d.ts +8 -0
- package/dist/storage/session-store.d.ts +3 -3
- package/dist/storage/session-summary-tracker.d.ts +8 -1
- package/dist/storage/session-write-buffer.d.ts +18 -0
- package/dist/storage/session-writer-truncate.d.ts +2 -0
- package/dist/tasking/index.js +10 -676
- package/dist/tools/fallback-manage-tools.d.ts +6 -4
- package/dist/tools/index.js +52 -9590
- package/dist/tools/model-tier-set-tool.d.ts +66 -0
- package/dist/types/agent-bridge.d.ts +2 -1
- package/dist/types/config/autonomy.d.ts +5 -0
- package/dist/types/config/mcp-features.d.ts +7 -0
- package/dist/types/config/model-tiers.d.ts +148 -0
- package/dist/types/config/root.d.ts +9 -0
- package/dist/types/config/tools.d.ts +73 -0
- package/dist/types/config/ui.d.ts +1 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/types/context.d.ts +2 -0
- package/dist/types/default-config.d.ts +6 -0
- package/dist/types/errors.d.ts +20 -1
- package/dist/types/index.d.ts +11 -9
- package/dist/types/index.js +131 -1342
- package/dist/types/multi-agent.d.ts +43 -0
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/provider-runner.d.ts +8 -0
- package/dist/types/provider.d.ts +15 -0
- package/dist/types/runtime-capability-manifest.d.ts +1 -1
- package/dist/types/secret-scrubber.d.ts +15 -0
- package/dist/types/session-markers.d.ts +37 -10
- package/dist/types/session-markers.js +8 -144
- package/dist/types/session-timeline.d.ts +197 -0
- package/dist/types/session-timeline.js +12 -0
- package/dist/types/session.d.ts +172 -11
- package/dist/types/system-prompt.d.ts +27 -0
- package/dist/utils/config-backup.d.ts +9 -1
- package/dist/utils/error.js +3 -4
- package/dist/utils/expect-defined.js +3 -9
- package/dist/utils/heap-watchdog.js +6 -706
- package/dist/utils/index.js +271 -5685
- package/dist/utils/message-invariants.d.ts +4 -1
- package/dist/utils/regex-guard.d.ts +1 -1
- package/dist/utils/sage-output-block.js +5 -42
- package/dist/utils/socket-path.d.ts +1 -1
- package/dist/utils/token-estimate.d.ts +6 -2
- package/dist/utils/wstack-paths.d.ts +2 -0
- package/dist/wiring/proxy-rewrite.d.ts +46 -0
- package/dist/wiring/proxy-rewrite.js +24 -121
- package/dist/worktree/index.js +6 -887
- package/instructions/agents/explore-companion.md +45 -18
- package/instructions/agents/memory-curator.md +34 -22
- package/instructions/coordination/director-preamble.md +12 -7
- package/instructions/coordination/subagent-baseline.md +26 -5
- package/instructions/leader-after-task.md +4 -1
- package/instructions/llm/chimera-review.md +30 -9
- package/instructions/llm/memory-curator.md +31 -0
- package/instructions/sections/tool/delegation-compact.md +2 -0
- package/instructions/sections/tool/delegation-full.md +5 -1
- package/instructions/sections/tool/mailbox-compact.md +5 -1
- package/instructions/sections/tool/mailbox-full.md +3 -0
- package/instructions/sections/tool/session-note-compact.md +3 -0
- package/instructions/sections/tool/session-note-full.md +15 -0
- package/instructions/system-lite.md +9 -4
- package/instructions/system-pro.md +66 -143
- package/instructions/system.md +73 -175
- package/package.json +32 -4
- package/dist/coordination/agents.d.ts +0 -8
- package/dist/coordination/transport.d.ts +0 -2
- package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +0 -28
|
@@ -82,6 +82,24 @@ export interface SubagentConfig {
|
|
|
82
82
|
* caller input so a model cannot forge a shallower depth or larger budget.
|
|
83
83
|
*/
|
|
84
84
|
spawnLineage?: SubagentSpawnLineage | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* The conversation that ASKED for this spawn.
|
|
87
|
+
*
|
|
88
|
+
* The coordinator otherwise stamps a new worker with "which session is the
|
|
89
|
+
* host on right now", read from the host's own writer. In a single-session
|
|
90
|
+
* CLI those are the same answer. With four WebUI tabs sharing one process
|
|
91
|
+
* they are not: the host writer stays pinned to the boot tab, so every
|
|
92
|
+
* worker spawned from tabs 2-4 was filed under tab 1 — its lifecycle,
|
|
93
|
+
* budget and context events surfaced in the wrong roster, its spend was
|
|
94
|
+
* charged to the wrong conversation, and `stopSession` could not find it
|
|
95
|
+
* because nothing recorded who it belonged to.
|
|
96
|
+
*
|
|
97
|
+
* Set by the tools that spawn on an agent's behalf, from the run-pinned
|
|
98
|
+
* session of the caller. Absent (a host spawning for itself) the
|
|
99
|
+
* coordinator's live reading stands, which is what single-session hosts
|
|
100
|
+
* have always used.
|
|
101
|
+
*/
|
|
102
|
+
originSessionId?: string | undefined;
|
|
85
103
|
/**
|
|
86
104
|
* Working directory for this subagent's tools. Defaults to the factory's
|
|
87
105
|
* cwd. Goal sets this to a per-phase git worktree so parallel phases
|
|
@@ -116,6 +134,21 @@ export interface SubagentConfig {
|
|
|
116
134
|
* → the factory's own default fallback behavior (usually the leader's config).
|
|
117
135
|
*/
|
|
118
136
|
fallbackModels?: string[] | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Deterministic model tier for this subagent ('budget' | 'standard' |
|
|
139
|
+
* 'premium', or any user-defined level). Resolved at spawn time into a
|
|
140
|
+
* fallback profile, a budget, and runtime overrides. A tier only FILLS IN
|
|
141
|
+
* fields left unset — an explicit provider/model always wins over it.
|
|
142
|
+
*/
|
|
143
|
+
tier?: string | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Budget field names the CALLER pinned explicitly (e.g. `delegate({ maxCostUsd })`).
|
|
146
|
+
* The tier layer never touches a pinned field: a number the user typed is a
|
|
147
|
+
* decision, while a roster default is just a default. Without this marker the
|
|
148
|
+
* two are indistinguishable at spawn time, because `applyRosterBudget` has
|
|
149
|
+
* already populated every budget field by then.
|
|
150
|
+
*/
|
|
151
|
+
budgetPins?: readonly string[] | undefined;
|
|
119
152
|
/**
|
|
120
153
|
* Named live fallback profile for this subagent. Unlike `fallbackModels`, the
|
|
121
154
|
* factory re-resolves this profile from ConfigStore on every provider attempt,
|
|
@@ -493,6 +526,16 @@ export interface SubagentRunContext {
|
|
|
493
526
|
config: SubagentConfig;
|
|
494
527
|
budget: SubagentBudget;
|
|
495
528
|
signal: AbortSignal;
|
|
529
|
+
/**
|
|
530
|
+
* The session that spawned this subagent, fixed at spawn time.
|
|
531
|
+
*
|
|
532
|
+
* A worker belongs to one session for its whole life. Runners must stamp
|
|
533
|
+
* their events with THIS rather than re-reading the host's current session:
|
|
534
|
+
* with four tabs live, the host's session moves whenever the user switches
|
|
535
|
+
* tabs, and a late-firing event would then be filed under whichever tab
|
|
536
|
+
* happened to be in front.
|
|
537
|
+
*/
|
|
538
|
+
sessionId?: string | undefined;
|
|
496
539
|
/** Null until `setSubagentBridge` is called for this subagent. */
|
|
497
540
|
bridge: AgentBridge | null;
|
|
498
541
|
/** Publish a bounded in-memory snapshot that survives timeout races. */
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Mailbox } from '../coordination/mailbox-types.js';
|
|
2
2
|
import type { Notifier } from '../notifications/notifier.js';
|
|
3
3
|
export type { Notifier };
|
|
4
|
-
import type { ToolCallPipelinePayload } from '../core/agent.js';
|
|
4
|
+
import type { ToolCallPipelinePayload } from '../core/agent-types.js';
|
|
5
5
|
import type { AgentContext } from './context.js';
|
|
6
6
|
import type { ExtensionRegistry } from '../extension/registry.js';
|
|
7
7
|
import type { Container } from '../kernel/container.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderModelStatusTracker } from '../coordination/provider-status-tracker.js';
|
|
1
2
|
import type { EventBus } from '../kernel/events.js';
|
|
2
3
|
import type { AgentContext } from './context.js';
|
|
3
4
|
import type { Logger } from './logger.js';
|
|
@@ -18,6 +19,13 @@ export interface RunProviderOptions {
|
|
|
18
19
|
retry: RetryPolicy;
|
|
19
20
|
logger: Logger;
|
|
20
21
|
tracer?: Tracer | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Shared provider/model waiting room. A runner that honours it must refuse
|
|
24
|
+
* to call a quarantined (provider, model) pair and must report the wire
|
|
25
|
+
* outcome back — this funnel is the last line of defence that keeps a
|
|
26
|
+
* quota-exhausted route off the wire no matter which extensions are loaded.
|
|
27
|
+
*/
|
|
28
|
+
statusTracker?: ProviderModelStatusTracker | undefined;
|
|
21
29
|
}
|
|
22
30
|
/**
|
|
23
31
|
* A replaceable service for calling a provider with retry logic,
|
package/dist/types/provider.d.ts
CHANGED
|
@@ -103,6 +103,21 @@ export interface Usage {
|
|
|
103
103
|
export declare function effectiveInputTokens(usage: Usage): number;
|
|
104
104
|
/** Prompt tokens that were not served by a cache read. */
|
|
105
105
|
export declare function freshInputTokens(usage: Usage): number;
|
|
106
|
+
/**
|
|
107
|
+
* Every token this request moved — the complete prompt the model loaded plus
|
|
108
|
+
* what it generated.
|
|
109
|
+
*
|
|
110
|
+
* The single definition of `SessionSummary.tokenTotal`. Three call sites
|
|
111
|
+
* compute that field (the live writer's tracker, the disk-rebuild summary
|
|
112
|
+
* builder, and the SQLite catalog's transcript summarizer) and they had
|
|
113
|
+
* drifted: two summed only `input + output` while the third also counted the
|
|
114
|
+
* cache buckets. With prompt caching on, `cacheRead` is the bulk of a real
|
|
115
|
+
* prompt, so the narrow reading under-reported long sessions by more than an
|
|
116
|
+
* order of magnitude — one measured session listed 118,719 tokens against an
|
|
117
|
+
* actual 2,466,978. Route every tokenTotal through here so the three cannot
|
|
118
|
+
* disagree again.
|
|
119
|
+
*/
|
|
120
|
+
export declare function totalUsageTokens(usage: Usage): number;
|
|
106
121
|
/**
|
|
107
122
|
* Cache-read share of the complete prompt context, normalized to [0, 1].
|
|
108
123
|
*
|
|
@@ -69,7 +69,7 @@ export declare const RUNTIME_CAPABILITY_MANIFEST: readonly [{
|
|
|
69
69
|
readonly id: 'coordination.mailbox';
|
|
70
70
|
readonly pack: 'fleet';
|
|
71
71
|
readonly exposure: 'direct';
|
|
72
|
-
readonly tools: readonly ["mailbox", "mail_send", "mail_inbox", "fleet_status"];
|
|
72
|
+
readonly tools: readonly ["mailbox", "mail_send", "mail_inbox", "fleet_status", "session_note"];
|
|
73
73
|
}, {
|
|
74
74
|
readonly id: 'fleet.delegate';
|
|
75
75
|
readonly pack: 'fleet';
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
export interface SecretScrubber {
|
|
2
2
|
scrub(text: string): string;
|
|
3
3
|
scrubObject<T>(obj: T): T;
|
|
4
|
+
/**
|
|
5
|
+
* Same redaction as {@link scrubObject}, but the result MAY SHARE structure
|
|
6
|
+
* with the input: any subtree that needed no redaction is returned by
|
|
7
|
+
* reference instead of being rebuilt.
|
|
8
|
+
*
|
|
9
|
+
* Only call this on a graph you exclusively own and will not mutate — a
|
|
10
|
+
* freshly `JSON.parse`d journal line, say. On anything still referenced
|
|
11
|
+
* elsewhere (a live conversation message queued for an async write), the
|
|
12
|
+
* shared subtrees would alias state that can still change underneath the
|
|
13
|
+
* consumer; use {@link scrubObject} there.
|
|
14
|
+
*
|
|
15
|
+
* Optional so existing implementations (and the object literals tests hand
|
|
16
|
+
* in) stay valid; callers fall back to {@link scrubObject}.
|
|
17
|
+
*/
|
|
18
|
+
scrubObjectShared?<T>(obj: T): T;
|
|
4
19
|
}
|
|
5
20
|
//# sourceMappingURL=secret-scrubber.d.ts.map
|
|
@@ -31,9 +31,40 @@ export interface SessionMarker {
|
|
|
31
31
|
source: SessionEvent['type'];
|
|
32
32
|
level: SessionMarkerLevel;
|
|
33
33
|
text: string;
|
|
34
|
-
/** Set only for the `agent_*` sources. */
|
|
34
|
+
/** Set only for the `agent_*` and `delegate_*` sources. */
|
|
35
35
|
agentId?: string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The source event's own fields, for the sources a surface renders as
|
|
38
|
+
* something richer than a line of text.
|
|
39
|
+
*
|
|
40
|
+
* `text` stays the fallback every surface can always use. But the TUI draws
|
|
41
|
+
* a delegation as a labelled subagent row with its own icon, colour and
|
|
42
|
+
* compact stat line, and the WebUI as a two-line assistant message — both
|
|
43
|
+
* built from the structured payload, live. Handing replay only the rendered
|
|
44
|
+
* sentence would have forced those surfaces to show something they never
|
|
45
|
+
* showed while running, which is the exact divergence this module exists to
|
|
46
|
+
* prevent. Kept to the few sources that need it, and JSON-serializable so it
|
|
47
|
+
* survives the wire alongside the rest of the marker.
|
|
48
|
+
*/
|
|
49
|
+
detail?: SessionMarkerDetail | undefined;
|
|
36
50
|
}
|
|
51
|
+
/** Structured payload for the marker sources whose surfaces render richly. */
|
|
52
|
+
export type SessionMarkerDetail = {
|
|
53
|
+
kind: 'delegate_started';
|
|
54
|
+
target: string;
|
|
55
|
+
task: string;
|
|
56
|
+
} | {
|
|
57
|
+
kind: 'delegate_completed';
|
|
58
|
+
target: string;
|
|
59
|
+
task: string;
|
|
60
|
+
ok: boolean;
|
|
61
|
+
status?: string | undefined;
|
|
62
|
+
summary: string;
|
|
63
|
+
durationMs: number;
|
|
64
|
+
iterations: number;
|
|
65
|
+
toolCalls: number;
|
|
66
|
+
costUsd?: number | undefined;
|
|
67
|
+
};
|
|
37
68
|
/**
|
|
38
69
|
* Every event type that projects to a marker. Conversation-bearing events
|
|
39
70
|
* (`user_input`, `llm_response`, `tool_*`) are deliberately excluded — those
|
|
@@ -41,15 +72,6 @@ export interface SessionMarker {
|
|
|
41
72
|
* `message_appended` journal replay identically.
|
|
42
73
|
*/
|
|
43
74
|
export declare const SESSION_MARKER_EVENT_TYPES: ReadonlySet<SessionEvent['type']>;
|
|
44
|
-
/**
|
|
45
|
-
* The subset chat-shaped surfaces (WebUI, SimpleUI, HQ Live Console) render.
|
|
46
|
-
*
|
|
47
|
-
* `checkpoint` is excluded: one is written per user prompt
|
|
48
|
-
* (`agent-loop.ts` → `writeCheckpoint`), so in a chat transcript it would be a
|
|
49
|
-
* line restating the user message immediately next to it. Dense timeline
|
|
50
|
-
* surfaces like the TUI use {@link SESSION_MARKER_EVENT_TYPES} instead, where
|
|
51
|
-
* the checkpoint marker doubles as a `/rewind` target hint.
|
|
52
|
-
*/
|
|
53
75
|
export declare const CHAT_MARKER_SOURCES: ReadonlySet<SessionEvent['type']>;
|
|
54
76
|
/**
|
|
55
77
|
* Project one session event to a marker, or `null` when the event carries no
|
|
@@ -69,6 +91,11 @@ export declare function projectSessionMarkers(events: readonly SessionEvent[], s
|
|
|
69
91
|
* as `user`/`system`-role messages by the agent loop at runtime (mailbox,
|
|
70
92
|
* fleet pulse, loop detector, resume validation notices) but should NOT appear
|
|
71
93
|
* in the human-facing chat history on session resume/replay.
|
|
94
|
+
*
|
|
95
|
+
* Also covers routing-noise error bubbles that the WebUI client has already
|
|
96
|
+
* swallowed live (`handleError` drops them) but that earlier turns may have
|
|
97
|
+
* persisted to the on-disk transcript — replay must not resurrect them into
|
|
98
|
+
* the human-visible chat.
|
|
72
99
|
*/
|
|
73
100
|
export declare const SYSTEM_INJECTION_PREFIXES: readonly string[];
|
|
74
101
|
/**
|
|
@@ -1,147 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"agent_stopped",
|
|
10
|
-
"agent_error",
|
|
11
|
-
"error",
|
|
12
|
-
"provider_retry",
|
|
13
|
-
"provider_error",
|
|
14
|
-
"message_truncated"
|
|
15
|
-
]);
|
|
16
|
-
var CHAT_MARKER_SOURCES = new Set(
|
|
17
|
-
[...SESSION_MARKER_EVENT_TYPES].filter((type) => type !== "checkpoint")
|
|
18
|
-
);
|
|
19
|
-
function sessionEventToMarker(ev) {
|
|
20
|
-
switch (ev.type) {
|
|
21
|
-
case "compaction": {
|
|
22
|
-
const before = (ev.before / 1e3).toFixed(0);
|
|
23
|
-
const after = (ev.after / 1e3).toFixed(0);
|
|
24
|
-
const level = ev.level ? ` (${ev.level})` : "";
|
|
25
|
-
const reductions = ev.reductions && ev.reductions.length > 0 ? ` [${ev.reductions.map((r) => `${r.phase}: \u2212${r.saved}`).join(", ")}]` : "";
|
|
26
|
-
return {
|
|
27
|
-
ts: ev.ts,
|
|
28
|
-
source: ev.type,
|
|
29
|
-
level: "info",
|
|
30
|
-
text: `\u27F2 context compacted${level}: ${before}K \u2192 ${after}K tokens${reductions}`
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
case "error":
|
|
34
|
-
return {
|
|
35
|
-
ts: ev.ts,
|
|
36
|
-
source: ev.type,
|
|
37
|
-
level: "error",
|
|
38
|
-
text: ev.phase ? `[${ev.phase}] ${ev.message}` : ev.message
|
|
39
|
-
};
|
|
40
|
-
case "provider_retry": {
|
|
41
|
-
const secs = (ev.delayMs / 1e3).toFixed(ev.delayMs >= 1e3 ? 1 : 2);
|
|
42
|
-
return {
|
|
43
|
-
ts: ev.ts,
|
|
44
|
-
source: ev.type,
|
|
45
|
-
level: "warn",
|
|
46
|
-
text: ev.status ? `\u27F3 retry ${ev.attempt} (HTTP ${ev.status}) after ${secs}s \u2014 ${ev.description}` : `\u27F3 retry ${ev.attempt} after ${secs}s \u2014 ${ev.description}`
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
case "provider_error":
|
|
50
|
-
return {
|
|
51
|
-
ts: ev.ts,
|
|
52
|
-
source: ev.type,
|
|
53
|
-
level: "error",
|
|
54
|
-
text: ev.status ? `provider error (HTTP ${ev.status}, ${ev.retryable ? "retryable" : "fatal"}): ${ev.description}` : `provider error (${ev.retryable ? "retryable" : "fatal"}): ${ev.description}`
|
|
55
|
-
};
|
|
56
|
-
case "checkpoint":
|
|
57
|
-
return {
|
|
58
|
-
ts: ev.ts,
|
|
59
|
-
source: ev.type,
|
|
60
|
-
level: "info",
|
|
61
|
-
text: `\u2713 checkpoint #${ev.promptIndex}: "${ev.promptPreview.slice(0, 60)}"`
|
|
62
|
-
};
|
|
63
|
-
case "agent_spawned":
|
|
64
|
-
return {
|
|
65
|
-
ts: ev.ts,
|
|
66
|
-
source: ev.type,
|
|
67
|
-
level: "info",
|
|
68
|
-
text: `spawned as ${ev.role}`,
|
|
69
|
-
agentId: ev.agentId
|
|
70
|
-
};
|
|
71
|
-
case "agent_stopped":
|
|
72
|
-
return {
|
|
73
|
-
ts: ev.ts,
|
|
74
|
-
source: ev.type,
|
|
75
|
-
level: "info",
|
|
76
|
-
text: "stopped",
|
|
77
|
-
agentId: ev.agentId
|
|
78
|
-
};
|
|
79
|
-
case "agent_error":
|
|
80
|
-
return {
|
|
81
|
-
ts: ev.ts,
|
|
82
|
-
source: ev.type,
|
|
83
|
-
level: "error",
|
|
84
|
-
text: `error: ${ev.error.slice(0, 80)}`,
|
|
85
|
-
agentId: ev.agentId
|
|
86
|
-
};
|
|
87
|
-
case "mode_changed":
|
|
88
|
-
return {
|
|
89
|
-
ts: ev.ts,
|
|
90
|
-
source: ev.type,
|
|
91
|
-
level: "info",
|
|
92
|
-
text: `mode: ${ev.from} \u2192 ${ev.to}`
|
|
93
|
-
};
|
|
94
|
-
case "skill_activated":
|
|
95
|
-
return {
|
|
96
|
-
ts: ev.ts,
|
|
97
|
-
source: ev.type,
|
|
98
|
-
level: "info",
|
|
99
|
-
text: `skill activated: ${ev.skillName}`
|
|
100
|
-
};
|
|
101
|
-
case "skill_deactivated":
|
|
102
|
-
return {
|
|
103
|
-
ts: ev.ts,
|
|
104
|
-
source: ev.type,
|
|
105
|
-
level: "info",
|
|
106
|
-
text: `skill deactivated: ${ev.skillName}`
|
|
107
|
-
};
|
|
108
|
-
case "message_truncated":
|
|
109
|
-
return {
|
|
110
|
-
ts: ev.ts,
|
|
111
|
-
source: ev.type,
|
|
112
|
-
level: "warn",
|
|
113
|
-
text: ev.after < ev.before ? `message truncated: ${ev.before} \u2192 ${ev.after} tokens` : `message truncated at ${ev.after} tokens`
|
|
114
|
-
};
|
|
115
|
-
default:
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function projectSessionMarkers(events, sources = SESSION_MARKER_EVENT_TYPES) {
|
|
120
|
-
const markers = [];
|
|
121
|
-
for (const ev of events) {
|
|
122
|
-
if (!sources.has(ev.type)) continue;
|
|
123
|
-
const marker = sessionEventToMarker(ev);
|
|
124
|
-
if (marker) markers.push(marker);
|
|
125
|
-
}
|
|
126
|
-
return markers;
|
|
127
|
-
}
|
|
128
|
-
var SYSTEM_INJECTION_PREFIXES = [
|
|
129
|
-
"[MAILBOX]",
|
|
130
|
-
"[MAILBOX BTW]",
|
|
131
|
-
"[BY THE WAY \u2014",
|
|
132
|
-
"[QUEUED MESSAGES \u2014",
|
|
133
|
-
"[FLEET PULSE]",
|
|
134
|
-
"[loop-detector]",
|
|
135
|
-
"[SESSION RESUME FILE VALIDATION]",
|
|
136
|
-
"[SESSION RESUME INTERRUPTED WORK]"
|
|
137
|
-
];
|
|
138
|
-
function isSystemInjectedMessage(text) {
|
|
139
|
-
const trimmed = text.trimStart();
|
|
140
|
-
for (const prefix of SYSTEM_INJECTION_PREFIXES) {
|
|
141
|
-
if (trimmed.startsWith(prefix)) return true;
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
CHAT_MARKER_SOURCES,
|
|
3
|
+
SESSION_MARKER_EVENT_TYPES,
|
|
4
|
+
SYSTEM_INJECTION_PREFIXES,
|
|
5
|
+
isSystemInjectedMessage,
|
|
6
|
+
projectSessionMarkers,
|
|
7
|
+
sessionEventToMarker
|
|
8
|
+
} from "../chunk-ULMAQV3T.js";
|
|
145
9
|
export {
|
|
146
10
|
CHAT_MARKER_SOURCES,
|
|
147
11
|
SESSION_MARKER_EVENT_TYPES,
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type { Message } from './messages.js';
|
|
2
|
+
import { type SessionMarker, type SessionMarkerDetail } from './session-markers.js';
|
|
3
|
+
import type { SessionEvent } from './session.js';
|
|
4
|
+
/** An image the user attached to a prompt, as it survives in the journal. */
|
|
5
|
+
export interface SessionTimelineImage {
|
|
6
|
+
mediaType?: string | undefined;
|
|
7
|
+
/** Base64 payload, when the block carried one. */
|
|
8
|
+
data?: string | undefined;
|
|
9
|
+
/** Remote URL, when the block referenced one instead. */
|
|
10
|
+
url?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Tool-call metadata that lives in `tool_call_end` events rather than in the
|
|
14
|
+
* conversation.
|
|
15
|
+
*
|
|
16
|
+
* The message journal records WHICH tool ran with WHICH arguments and WHAT it
|
|
17
|
+
* returned; how long it took and how much it produced is audit detail, in a
|
|
18
|
+
* separate event keyed by the same `tool_use` id. The TUI reads both because
|
|
19
|
+
* it holds the raw event array; the browser surfaces are handed a projection
|
|
20
|
+
* over the wire, so this is the shape that projection carries.
|
|
21
|
+
*/
|
|
22
|
+
export interface SessionToolMeta {
|
|
23
|
+
/** The `tool_use` id this describes. */
|
|
24
|
+
id: string;
|
|
25
|
+
name?: string | undefined;
|
|
26
|
+
durationMs?: number | undefined;
|
|
27
|
+
outputBytes?: number | undefined;
|
|
28
|
+
outputTokens?: number | undefined;
|
|
29
|
+
outputLines?: number | undefined;
|
|
30
|
+
ok?: boolean | undefined;
|
|
31
|
+
/** Subagent that ran the tool; absent = the session's leader. */
|
|
32
|
+
agentId?: string | undefined;
|
|
33
|
+
}
|
|
34
|
+
interface TimelineEntryBase {
|
|
35
|
+
ts: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SessionTimelineUserEntry extends TimelineEntryBase {
|
|
38
|
+
kind: 'user';
|
|
39
|
+
text: string;
|
|
40
|
+
/** Present only when the prompt carried image blocks. */
|
|
41
|
+
images?: SessionTimelineImage[] | undefined;
|
|
42
|
+
}
|
|
43
|
+
export interface SessionTimelineAssistantEntry extends TimelineEntryBase {
|
|
44
|
+
kind: 'assistant';
|
|
45
|
+
text: string;
|
|
46
|
+
/**
|
|
47
|
+
* True when this prose ended its turn. A message carrying a `tool_use` block
|
|
48
|
+
* stopped for a tool call, so its text is mid-turn — the surfaces use this to
|
|
49
|
+
* decide whether a `<nextsteps>` panel may appear.
|
|
50
|
+
*/
|
|
51
|
+
final: boolean;
|
|
52
|
+
}
|
|
53
|
+
/** A conversation message with `role: 'system'` — resume notices and the like. */
|
|
54
|
+
export interface SessionTimelineSystemEntry extends TimelineEntryBase {
|
|
55
|
+
kind: 'system';
|
|
56
|
+
text: string;
|
|
57
|
+
}
|
|
58
|
+
export interface SessionTimelineThinkingEntry extends TimelineEntryBase {
|
|
59
|
+
kind: 'thinking';
|
|
60
|
+
text: string;
|
|
61
|
+
/** 1-based ordinal across the whole timeline; surfaces label iterations with it. */
|
|
62
|
+
index: number;
|
|
63
|
+
}
|
|
64
|
+
export interface SessionTimelineToolEntry extends TimelineEntryBase {
|
|
65
|
+
kind: 'tool';
|
|
66
|
+
/** The provider's `tool_use` id, or the `tool_result`'s id for an orphan result. */
|
|
67
|
+
toolUseId: string;
|
|
68
|
+
name: string;
|
|
69
|
+
input?: unknown;
|
|
70
|
+
/** Untruncated result body. Surfaces decide their own preview length. */
|
|
71
|
+
output?: string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* `undefined` while a call has no result in the journal — the run was still
|
|
74
|
+
* executing it when the process stopped. A surface renders that as "running"
|
|
75
|
+
* or "interrupted"; it is NOT a failure, and reporting it as one is what the
|
|
76
|
+
* SimpleUI replay used to do.
|
|
77
|
+
*/
|
|
78
|
+
ok?: boolean | undefined;
|
|
79
|
+
durationMs?: number | undefined;
|
|
80
|
+
outputBytes?: number | undefined;
|
|
81
|
+
outputTokens?: number | undefined;
|
|
82
|
+
outputLines?: number | undefined;
|
|
83
|
+
agentId?: string | undefined;
|
|
84
|
+
}
|
|
85
|
+
export interface SessionTimelineMarkerEntry extends TimelineEntryBase {
|
|
86
|
+
kind: 'marker';
|
|
87
|
+
source: SessionEvent['type'];
|
|
88
|
+
level: SessionMarker['level'];
|
|
89
|
+
text: string;
|
|
90
|
+
agentId?: string | undefined;
|
|
91
|
+
/** See {@link SessionMarker.detail} — structured fields for rich sources. */
|
|
92
|
+
detail?: SessionMarkerDetail | undefined;
|
|
93
|
+
}
|
|
94
|
+
export type SessionTimelineEntry = SessionTimelineUserEntry | SessionTimelineAssistantEntry | SessionTimelineSystemEntry | SessionTimelineThinkingEntry | SessionTimelineToolEntry | SessionTimelineMarkerEntry;
|
|
95
|
+
/**
|
|
96
|
+
* Where a message's thinking blocks land relative to its prose.
|
|
97
|
+
*
|
|
98
|
+
* Not a style choice — it is what the surface did LIVE, and resume has to
|
|
99
|
+
* match the surface it is resuming into:
|
|
100
|
+
*
|
|
101
|
+
* - `'inline'` — one entry per thinking block, before the prose, in provider
|
|
102
|
+
* block order. The TUI and SimpleUI stream thinking as it arrives and leave
|
|
103
|
+
* it where it fell.
|
|
104
|
+
* - `'merged-after'` — one entry per message, carrying every thinking block
|
|
105
|
+
* joined, emitted after that message's prose and tool calls. The WebUI keeps
|
|
106
|
+
* a transient thinking bubble during a run and only commits the archived log
|
|
107
|
+
* when the iteration completes, which is after the prose is on screen.
|
|
108
|
+
*/
|
|
109
|
+
export type ThinkingPlacement = 'inline' | 'merged-after';
|
|
110
|
+
/**
|
|
111
|
+
* How a message's text blocks relate to the tool calls between them.
|
|
112
|
+
*
|
|
113
|
+
* Again a record of what the surface did LIVE, not a preference:
|
|
114
|
+
*
|
|
115
|
+
* - `'split'` — a text run becomes its own entry wherever a tool interrupts
|
|
116
|
+
* it, so prose that followed a tool stays after that tool. The TUI and the
|
|
117
|
+
* WebUI render a fresh bubble per run.
|
|
118
|
+
* - `'join'` — every text block of a message becomes ONE entry, emitted before
|
|
119
|
+
* the message's tool entries. The SimpleUI streams a whole iteration into a
|
|
120
|
+
* single bubble and lists tool calls beside it, so splitting would invent
|
|
121
|
+
* bubbles that were never on screen.
|
|
122
|
+
*/
|
|
123
|
+
export type TextBlockMode = 'split' | 'join';
|
|
124
|
+
export interface ProjectSessionTimelineInput {
|
|
125
|
+
/** The reconstructed conversation, as `SessionStore.load()` rebuilds it. */
|
|
126
|
+
messages: readonly Message[];
|
|
127
|
+
/**
|
|
128
|
+
* Raw journal events. Callers holding the JSONL (the TUI, the servers) pass
|
|
129
|
+
* this and markers/toolMeta are projected from it.
|
|
130
|
+
*/
|
|
131
|
+
events?: readonly SessionEvent[] | undefined;
|
|
132
|
+
/** Pre-projected markers, for callers that received them over the wire. */
|
|
133
|
+
markers?: readonly SessionMarker[] | undefined;
|
|
134
|
+
/** Pre-projected tool metadata, for callers that received it over the wire. */
|
|
135
|
+
toolMeta?: readonly SessionToolMeta[] | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Which event types project to markers. Defaults to the dense
|
|
138
|
+
* {@link SESSION_MARKER_EVENT_TYPES}; chat-shaped surfaces pass
|
|
139
|
+
* `CHAT_MARKER_SOURCES`. Ignored when `markers` is supplied — the sender
|
|
140
|
+
* already applied its own set.
|
|
141
|
+
*/
|
|
142
|
+
markerSources?: ReadonlySet<SessionEvent['type']> | undefined;
|
|
143
|
+
/** See {@link ThinkingPlacement}. Defaults to `'inline'`. */
|
|
144
|
+
thinkingPlacement?: ThinkingPlacement | undefined;
|
|
145
|
+
/** See {@link TextBlockMode}. Defaults to `'split'`. */
|
|
146
|
+
textBlocks?: TextBlockMode | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Glue between adjacent text blocks of one run. Defaults to `''` — the
|
|
149
|
+
* provider already streamed them as one continuous body, and inserting a
|
|
150
|
+
* separator would put a break where the live render had none.
|
|
151
|
+
*/
|
|
152
|
+
textSeparator?: string | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Drop conversation messages the agent loop injected for the model's benefit
|
|
155
|
+
* (mailbox, fleet pulse, loop detector, resume notices). Defaults to true —
|
|
156
|
+
* every surface hides them, and a surface that wants the raw journal should
|
|
157
|
+
* read the events instead.
|
|
158
|
+
*/
|
|
159
|
+
hideSystemInjections?: boolean | undefined;
|
|
160
|
+
}
|
|
161
|
+
/** Project the `tool_call_end` records of an event stream, keyed by tool id. */
|
|
162
|
+
export declare function projectSessionToolMeta(events: Iterable<SessionEvent>): SessionToolMeta[];
|
|
163
|
+
/**
|
|
164
|
+
* Size of the LAST prompt this session sent, from its journal.
|
|
165
|
+
*
|
|
166
|
+
* This is the number the context-fill bar means: how full the window was when
|
|
167
|
+
* the conversation last went to the model. Live, `ctx.lastRequestTokens` holds
|
|
168
|
+
* exactly that (the pre-flight total). Every resume path instead reached for
|
|
169
|
+
* `SessionData.usage.input`, which is the SUM of every request the session has
|
|
170
|
+
* ever made — so a long session came back claiming a nine-million-token
|
|
171
|
+
* context on a one-million-token model. Cumulative totals belong in the cost
|
|
172
|
+
* and usage readouts; they are never a fill source.
|
|
173
|
+
*
|
|
174
|
+
* The last `llm_response` carries that request's own usage, and its prompt is
|
|
175
|
+
* everything the provider counted on the way in: fresh input plus whatever it
|
|
176
|
+
* served or wrote through the cache — `effectiveInputTokens` in `provider.ts`,
|
|
177
|
+
* inlined here because this module must stay importable from a browser bundle
|
|
178
|
+
* and that one pulls a value chain behind it. Scanned from the end, so a 100k-
|
|
179
|
+
* event journal costs one step. Returns `undefined` when the session never reached
|
|
180
|
+
* the model — the caller must then leave the estimate unset rather than
|
|
181
|
+
* publish a zero, which reads as "0% full" instead of "not known yet".
|
|
182
|
+
*/
|
|
183
|
+
export declare function projectLastRequestTokens(events: readonly SessionEvent[] | undefined): number | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Merge a session's conversation and audit streams into one ordered timeline.
|
|
186
|
+
*
|
|
187
|
+
* Ordering is a two-pointer merge of two sequences that are each already
|
|
188
|
+
* chronological — the message backbone by construction, the markers by journal
|
|
189
|
+
* order — so the conversation is never reordered: markers are only inserted
|
|
190
|
+
* between existing turns, and a tie keeps the backbone entry first. That is
|
|
191
|
+
* deliberately NOT a sort over the union: message timestamps repeat (every
|
|
192
|
+
* block of one message shares its `ts`), and sorting a repeated key moves tool
|
|
193
|
+
* calls away from the prose they belong to.
|
|
194
|
+
*/
|
|
195
|
+
export declare function projectSessionTimeline(input: ProjectSessionTimelineInput): SessionTimelineEntry[];
|
|
196
|
+
export {};
|
|
197
|
+
//# sourceMappingURL=session-timeline.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
projectLastRequestTokens,
|
|
3
|
+
projectSessionTimeline,
|
|
4
|
+
projectSessionToolMeta
|
|
5
|
+
} from "../chunk-3BDV7RL3.js";
|
|
6
|
+
import "../chunk-ULMAQV3T.js";
|
|
7
|
+
export {
|
|
8
|
+
projectLastRequestTokens,
|
|
9
|
+
projectSessionTimeline,
|
|
10
|
+
projectSessionToolMeta
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=session-timeline.js.map
|