@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
|
@@ -46,10 +46,8 @@ export declare class InputHistoryStore {
|
|
|
46
46
|
private scrubAndFilter;
|
|
47
47
|
/**
|
|
48
48
|
* Heuristic: did the scrubber actually redact anything? DefaultSecretScrubber
|
|
49
|
-
* replaces matches with "
|
|
50
|
-
*
|
|
51
|
-
* can be accommodated by widening this check in the future; for now the
|
|
52
|
-
* marker check covers the shipped scrubber.
|
|
49
|
+
* replaces matches with "[REDACTED:<type>]" (and legacy mocks with
|
|
50
|
+
* "***REDACTED***"), so a residual marker means a secret was detected.
|
|
53
51
|
*/
|
|
54
52
|
private looksRedacted;
|
|
55
53
|
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { OneShotOrchestrator } from '../execution/one-shot-llm.js';
|
|
2
|
+
import type { AfterRunHook, AgentExtension } from '../extension/extension-points.js';
|
|
3
|
+
import type { MemoryStore } from '../types/memory.js';
|
|
4
|
+
import type { Provider } from '../types/provider.js';
|
|
5
|
+
export type CuratorSageKind = 'fact' | 'decision' | 'convention' | 'preference' | 'anti_pattern' | 'warning' | 'workflow' | 'bug_root_cause' | 'file_note' | 'symbol_note' | 'command_note';
|
|
6
|
+
export interface CuratorMemoryAnchor {
|
|
7
|
+
type: 'file' | 'directory' | 'symbol' | 'package' | 'command' | 'test' | 'git';
|
|
8
|
+
path?: string | undefined;
|
|
9
|
+
symbol?: string | undefined;
|
|
10
|
+
command?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface CuratorSageRecord {
|
|
13
|
+
id: string;
|
|
14
|
+
text: string;
|
|
15
|
+
scope?: string | undefined;
|
|
16
|
+
kind?: string | undefined;
|
|
17
|
+
status?: string | undefined;
|
|
18
|
+
importance?: number | undefined;
|
|
19
|
+
confidence?: number | undefined;
|
|
20
|
+
freshness?: number | undefined;
|
|
21
|
+
tags?: string[] | undefined;
|
|
22
|
+
anchors?: CuratorMemoryAnchor[] | undefined;
|
|
23
|
+
persistence?: 'permanent' | 'long_lived' | 'short_lived' | undefined;
|
|
24
|
+
contradicts?: string[] | undefined;
|
|
25
|
+
supersedes?: string[] | undefined;
|
|
26
|
+
createdAt?: string | undefined;
|
|
27
|
+
updatedAt?: string | undefined;
|
|
28
|
+
}
|
|
29
|
+
export interface CuratorSageCandidate {
|
|
30
|
+
id: string;
|
|
31
|
+
memoryId?: string | undefined;
|
|
32
|
+
reason?: string | undefined;
|
|
33
|
+
suggestedAction?: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
export interface CuratorSage {
|
|
36
|
+
rememberSage(input: {
|
|
37
|
+
text: string;
|
|
38
|
+
scope?: string | undefined;
|
|
39
|
+
kind?: CuratorSageKind | undefined;
|
|
40
|
+
tags?: string[] | undefined;
|
|
41
|
+
importance?: number | undefined;
|
|
42
|
+
confidence?: number | undefined;
|
|
43
|
+
persistence?: 'permanent' | 'long_lived' | 'short_lived' | undefined;
|
|
44
|
+
anchors?: CuratorMemoryAnchor[] | undefined;
|
|
45
|
+
sources?: Array<{
|
|
46
|
+
type: string;
|
|
47
|
+
sessionId?: string | undefined;
|
|
48
|
+
}> | undefined;
|
|
49
|
+
supersedes?: string[] | undefined;
|
|
50
|
+
contradicts?: string[] | undefined;
|
|
51
|
+
}): Promise<{
|
|
52
|
+
id?: string;
|
|
53
|
+
} | unknown>;
|
|
54
|
+
getSage?(id: string): Promise<CuratorSageRecord | null>;
|
|
55
|
+
updateSage?(id: string, patch: Partial<CuratorSageRecord>): Promise<unknown>;
|
|
56
|
+
deleteSage?(id: string, reason?: string): Promise<void>;
|
|
57
|
+
listCandidates?(includeResolved?: boolean): Promise<CuratorSageCandidate[]>;
|
|
58
|
+
retrieveForPath?(opts: {
|
|
59
|
+
path: string;
|
|
60
|
+
limit?: number;
|
|
61
|
+
includeStatuses?: string[];
|
|
62
|
+
}): Promise<CuratorSageRecord[]>;
|
|
63
|
+
searchSage?(query: string, opts?: {
|
|
64
|
+
limit?: number;
|
|
65
|
+
scope?: 'project';
|
|
66
|
+
includeStatuses?: string[];
|
|
67
|
+
}): Promise<unknown[]>;
|
|
68
|
+
}
|
|
69
|
+
export type CuratorOperation = {
|
|
70
|
+
action: 'supersede';
|
|
71
|
+
targetId: string;
|
|
72
|
+
reason: string;
|
|
73
|
+
supersededBy?: string | undefined;
|
|
74
|
+
} | {
|
|
75
|
+
action: 'contradict';
|
|
76
|
+
targetId: string;
|
|
77
|
+
reason: string;
|
|
78
|
+
contradictsWith?: string | undefined;
|
|
79
|
+
} | {
|
|
80
|
+
action: 'merge';
|
|
81
|
+
targetIds: string[];
|
|
82
|
+
text: string;
|
|
83
|
+
type?: string | undefined;
|
|
84
|
+
priority?: string | undefined;
|
|
85
|
+
confidence?: number | undefined;
|
|
86
|
+
tags?: string[] | undefined;
|
|
87
|
+
anchors?: CuratorMemoryAnchor[] | undefined;
|
|
88
|
+
reason: string;
|
|
89
|
+
} | {
|
|
90
|
+
action: 'split';
|
|
91
|
+
targetId: string;
|
|
92
|
+
items: Array<{
|
|
93
|
+
text: string;
|
|
94
|
+
type?: string | undefined;
|
|
95
|
+
priority?: string | undefined;
|
|
96
|
+
confidence?: number | undefined;
|
|
97
|
+
tags?: string[] | undefined;
|
|
98
|
+
anchors?: CuratorMemoryAnchor[] | undefined;
|
|
99
|
+
}>;
|
|
100
|
+
reason: string;
|
|
101
|
+
} | {
|
|
102
|
+
action: 'recalibrate';
|
|
103
|
+
targetId: string;
|
|
104
|
+
importance?: number | undefined;
|
|
105
|
+
confidence?: number | undefined;
|
|
106
|
+
freshness?: number | undefined;
|
|
107
|
+
status?: string | undefined;
|
|
108
|
+
reason: string;
|
|
109
|
+
} | {
|
|
110
|
+
action: 'keep';
|
|
111
|
+
targetId: string;
|
|
112
|
+
reason: string;
|
|
113
|
+
};
|
|
114
|
+
export interface SessionMemoryCuratorOptions {
|
|
115
|
+
memoryStore: MemoryStore;
|
|
116
|
+
Sage?: CuratorSage | undefined;
|
|
117
|
+
provider?: Provider | undefined;
|
|
118
|
+
model?: string | undefined;
|
|
119
|
+
maxTargetMemories?: number | undefined;
|
|
120
|
+
oneShotOrchestrator?: OneShotOrchestrator | undefined;
|
|
121
|
+
}
|
|
122
|
+
export declare class SessionMemoryCurator implements AgentExtension {
|
|
123
|
+
name: string;
|
|
124
|
+
owner: string;
|
|
125
|
+
private readonly Sage?;
|
|
126
|
+
private readonly provider?;
|
|
127
|
+
private readonly model?;
|
|
128
|
+
private readonly maxTargetMemories;
|
|
129
|
+
private readonly oneShotOrchestrator?;
|
|
130
|
+
constructor(opts: SessionMemoryCuratorOptions);
|
|
131
|
+
afterRun: AfterRunHook;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=memory-curator.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writer-boundary agent attribution.
|
|
3
|
+
*
|
|
4
|
+
* A leader's journal can contain events that a SUBAGENT produced. That is not
|
|
5
|
+
* a bug: `createParentSubagentSessionWriter` deliberately forwards a
|
|
6
|
+
* subagent's appends into the leader's JSONL when that subagent has no journal
|
|
7
|
+
* of its own, because the leader's file is the one `/rewind` and the resume
|
|
8
|
+
* timeline read. What WAS a bug is that the forwarded events arrived
|
|
9
|
+
* unlabelled — a subagent's `tool_call_start` looked exactly like the
|
|
10
|
+
* leader's, so no reader could attribute the work.
|
|
11
|
+
*
|
|
12
|
+
* Stamping belongs here rather than at the emit sites. Every producer
|
|
13
|
+
* (director, fleet manager, tool loop, context) appends through a writer it
|
|
14
|
+
* was handed and has no idea whether that writer is its own or a parent's;
|
|
15
|
+
* the wrapper is the single place that does know. Doing it at the boundary
|
|
16
|
+
* also means a new emit site cannot forget.
|
|
17
|
+
*
|
|
18
|
+
* The stamp is never overwritten: an event that already carries an `agentId`
|
|
19
|
+
* came from a deeper agent whose own wrapper labelled it first, and that
|
|
20
|
+
* inner attribution is the more specific truth.
|
|
21
|
+
*/
|
|
22
|
+
import type { SessionEvent, SessionWriter } from '../types/session.js';
|
|
23
|
+
/** Apply `agentId` to an event unless it already carries one. */
|
|
24
|
+
export declare function stampAgentId(event: SessionEvent, agentId: string): SessionEvent;
|
|
25
|
+
/**
|
|
26
|
+
* Wrap a writer so every event appended through it is attributed to `agentId`.
|
|
27
|
+
*
|
|
28
|
+
* Only `append`/`appendBatch` are intercepted. `recordFileChange` and
|
|
29
|
+
* `recordSideEffect` build their events inside the underlying writer, so a
|
|
30
|
+
* wrapper cannot reach them — those paths keep the writer's own identity,
|
|
31
|
+
* which for the parent-interleaved case is the correct owner anyway (the
|
|
32
|
+
* parent files them against its own prompt index so `/rewind` can undo them).
|
|
33
|
+
*
|
|
34
|
+
* An empty `agentId` returns the writer untouched rather than stamping an
|
|
35
|
+
* empty string, so a caller that has not resolved a name yet degrades to
|
|
36
|
+
* today's behaviour instead of writing a meaningless label.
|
|
37
|
+
*/
|
|
38
|
+
export declare function withAgentAttribution(writer: SessionWriter, agentId: string): SessionWriter;
|
|
39
|
+
//# sourceMappingURL=session-agent-attribution.d.ts.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { SecretScrubber } from '../types/secret-scrubber.js';
|
|
2
|
+
export type SessionLifecycleBoundary = 'session_start' | 'in_flight_start' | 'in_flight_end' | 'session_end';
|
|
3
|
+
export type SessionFindingCode =
|
|
4
|
+
/** Lines the loader cannot parse. It skips them silently, so they are invisible. */
|
|
5
|
+
'unparsable_lines'
|
|
6
|
+
/** The file does not end in a newline — a process died mid-write. */
|
|
7
|
+
| 'truncated_tail'
|
|
8
|
+
/** No `session_start`: the journal never recorded what it was. */
|
|
9
|
+
| 'missing_session_start'
|
|
10
|
+
/** Last boundary is `in_flight_start` — the process died mid-turn. */
|
|
11
|
+
| 'died_mid_turn'
|
|
12
|
+
/** No `session_end`: closed by a kill, not by a clean exit. */
|
|
13
|
+
| 'never_closed'
|
|
14
|
+
/** No events at all. */
|
|
15
|
+
| 'empty'
|
|
16
|
+
/** No `.summary.json` sidecar; the picker has no title for it. */
|
|
17
|
+
| 'missing_summary'
|
|
18
|
+
/** The sidecar predates the transcript, so its counts are behind. */
|
|
19
|
+
| 'stale_summary'
|
|
20
|
+
/** Large enough that opening it is a visible wait. */
|
|
21
|
+
| 'oversized';
|
|
22
|
+
export interface SessionFinding {
|
|
23
|
+
code: SessionFindingCode;
|
|
24
|
+
severity: 'error' | 'warn' | 'info';
|
|
25
|
+
detail: string;
|
|
26
|
+
/** Present when `repairSessionSummaries` can resolve this finding. */
|
|
27
|
+
fix?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SessionDiagnosis {
|
|
30
|
+
/** Store-relative id, e.g. `2026-08-29/sess_01M16QFGAJ…`. */
|
|
31
|
+
id: string;
|
|
32
|
+
file: string;
|
|
33
|
+
bytes: number;
|
|
34
|
+
/** Physical lines, including any that failed to parse. */
|
|
35
|
+
lines: number;
|
|
36
|
+
unparsableLines: number;
|
|
37
|
+
/** Bytes held by superseded conversation snapshots — reported, never rewritten. */
|
|
38
|
+
snapshotBytes: number;
|
|
39
|
+
lastBoundary: SessionLifecycleBoundary | null;
|
|
40
|
+
hasSessionStart: boolean;
|
|
41
|
+
hasSummarySidecar: boolean;
|
|
42
|
+
/** True when the sidecar is older than the transcript it summarizes. */
|
|
43
|
+
summaryStale: boolean;
|
|
44
|
+
findings: SessionFinding[];
|
|
45
|
+
}
|
|
46
|
+
export interface SessionDoctorTotals {
|
|
47
|
+
sessions: number;
|
|
48
|
+
bytes: number;
|
|
49
|
+
snapshotBytes: number;
|
|
50
|
+
unparsableLines: number;
|
|
51
|
+
}
|
|
52
|
+
export interface SessionDoctorReport {
|
|
53
|
+
sessionsDir: string;
|
|
54
|
+
totals: SessionDoctorTotals;
|
|
55
|
+
/** How many sessions carry each finding. */
|
|
56
|
+
byCode: Partial<Record<SessionFindingCode, number>>;
|
|
57
|
+
/** Every scanned session, worst-first (errors, then warnings, then size). */
|
|
58
|
+
sessions: SessionDiagnosis[];
|
|
59
|
+
/** Journals that could not be read at all, with the reason. */
|
|
60
|
+
unreadable: Array<{
|
|
61
|
+
id: string;
|
|
62
|
+
reason: string;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
export interface DiagnoseSessionsOptions {
|
|
66
|
+
sessionsDir: string;
|
|
67
|
+
/**
|
|
68
|
+
* Size at which a session is flagged as slow to open. Default 64 MB —
|
|
69
|
+
* measured on this corpus, journals load at roughly 40 MB/s, so that is a
|
|
70
|
+
* couple of seconds and climbing.
|
|
71
|
+
*/
|
|
72
|
+
oversizedBytes?: number | undefined;
|
|
73
|
+
/** Progress for a scan that walks tens of gigabytes. */
|
|
74
|
+
onProgress?: ((progress: {
|
|
75
|
+
scanned: number;
|
|
76
|
+
total: number;
|
|
77
|
+
id: string;
|
|
78
|
+
}) => void) | undefined;
|
|
79
|
+
signal?: AbortSignal | undefined;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Walk every journal under `sessionsDir` and report on it. Writes nothing.
|
|
83
|
+
*/
|
|
84
|
+
export declare function diagnoseSessions(options: DiagnoseSessionsOptions): Promise<SessionDoctorReport>;
|
|
85
|
+
export interface SummaryRepairResult {
|
|
86
|
+
repaired: string[];
|
|
87
|
+
failed: Array<{
|
|
88
|
+
id: string;
|
|
89
|
+
reason: string;
|
|
90
|
+
}>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Rebuild the `.summary.json` sidecars the report flagged.
|
|
94
|
+
*
|
|
95
|
+
* The only thing this module writes. A summary is a projection of the journal
|
|
96
|
+
* beside it — regenerating one cannot lose anything, and a session whose
|
|
97
|
+
* summary is missing is a session the picker cannot describe.
|
|
98
|
+
*/
|
|
99
|
+
export declare function repairSessionSummaries(options: {
|
|
100
|
+
report: SessionDoctorReport;
|
|
101
|
+
secretScrubber?: SecretScrubber | undefined;
|
|
102
|
+
onProgress?: ((progress: {
|
|
103
|
+
repaired: number;
|
|
104
|
+
total: number;
|
|
105
|
+
id: string;
|
|
106
|
+
}) => void) | undefined;
|
|
107
|
+
signal?: AbortSignal | undefined;
|
|
108
|
+
}): Promise<SummaryRepairResult>;
|
|
109
|
+
//# sourceMappingURL=session-doctor.d.ts.map
|
|
@@ -45,12 +45,12 @@ export interface SessionEventBridge {
|
|
|
45
45
|
allows(type: SessionEvent['type']): boolean;
|
|
46
46
|
}
|
|
47
47
|
/** Core events that are always written regardless of auditLevel. */
|
|
48
|
-
declare const CORE_RECONSTRUCT_EVENTS: Set<"agent_error" | "agent_spawned" | "agent_stopped" | "checkpoint" | "compaction" | "context_snapshot" | "error" | "file_event" | "file_observation" | "file_snapshot" | "in_flight_end" | "in_flight_start" | "llm_request" | "llm_response" | "message_appended" | "message_truncated" | "message_updated" | "messages_dropped" | "messages_replaced" | "mode_changed" | "provider_error" | "provider_retry" | "rewound" | "session_end" | "session_forked" | "session_resumed" | "session_start" | "side_effect" | "skill_activated" | "skill_deactivated" | "
|
|
48
|
+
export declare const CORE_RECONSTRUCT_EVENTS: Set<"agent_error" | "agent_session_linked" | "agent_spawned" | "agent_stopped" | "checkpoint" | "compaction" | "context_snapshot" | "delegate_completed" | "delegate_started" | "error" | "file_event" | "file_observation" | "file_snapshot" | "in_flight_end" | "in_flight_start" | "llm_request" | "llm_response" | "loop_detected" | "message_appended" | "message_truncated" | "message_updated" | "messages_dropped" | "messages_replaced" | "mode_changed" | "model_switched" | "provider_error" | "provider_retry" | "rewound" | "session_end" | "session_forked" | "session_resumed" | "session_start" | "side_effect" | "skill_activated" | "skill_deactivated" | "task_completed" | "task_created" | "task_failed" | "task_updated" | "tool_call_end" | "tool_call_start" | "tool_progress" | "tool_result" | "tool_use" | "user_input">;
|
|
49
49
|
/**
|
|
50
50
|
* Events that are considered "standard" audit detail.
|
|
51
51
|
* These are lightweight and high-value for forensics.
|
|
52
52
|
*/
|
|
53
|
-
declare const STANDARD_AUDIT_EVENTS: Set<"agent_error" | "agent_spawned" | "agent_stopped" | "checkpoint" | "compaction" | "context_snapshot" | "error" | "file_event" | "file_observation" | "file_snapshot" | "in_flight_end" | "in_flight_start" | "llm_request" | "llm_response" | "message_appended" | "message_truncated" | "message_updated" | "messages_dropped" | "messages_replaced" | "mode_changed" | "provider_error" | "provider_retry" | "rewound" | "session_end" | "session_forked" | "session_resumed" | "session_start" | "side_effect" | "skill_activated" | "skill_deactivated" | "
|
|
53
|
+
export declare const STANDARD_AUDIT_EVENTS: Set<"agent_error" | "agent_session_linked" | "agent_spawned" | "agent_stopped" | "checkpoint" | "compaction" | "context_snapshot" | "delegate_completed" | "delegate_started" | "error" | "file_event" | "file_observation" | "file_snapshot" | "in_flight_end" | "in_flight_start" | "llm_request" | "llm_response" | "loop_detected" | "message_appended" | "message_truncated" | "message_updated" | "messages_dropped" | "messages_replaced" | "mode_changed" | "model_switched" | "provider_error" | "provider_retry" | "rewound" | "session_end" | "session_forked" | "session_resumed" | "session_start" | "side_effect" | "skill_activated" | "skill_deactivated" | "task_completed" | "task_created" | "task_failed" | "task_updated" | "tool_call_end" | "tool_call_start" | "tool_progress" | "tool_result" | "tool_use" | "user_input">;
|
|
54
54
|
/**
|
|
55
55
|
* Create a safe, audit-level-aware bridge around a SessionWriter.
|
|
56
56
|
*
|
|
@@ -65,8 +65,6 @@ declare const STANDARD_AUDIT_EVENTS: Set<"agent_error" | "agent_spawned" | "agen
|
|
|
65
65
|
* });
|
|
66
66
|
*/
|
|
67
67
|
export declare function createSessionEventBridge(writer: SessionWriter | (() => SessionWriter | undefined | null) | undefined | null, level?: AuditLevel, options?: SessionEventBridgeOptions): SessionEventBridge;
|
|
68
|
-
/** Convenience re-export of the allowed core set for tests/docs. */
|
|
69
|
-
export { CORE_RECONSTRUCT_EVENTS, STANDARD_AUDIT_EVENTS };
|
|
70
68
|
/**
|
|
71
69
|
* Safely extract the auditLevel from a (possibly partial) Config object.
|
|
72
70
|
* Falls back to 'standard' if not present or invalid.
|
|
@@ -86,9 +84,9 @@ export declare function resolveSessionLoggingConfig(cfg?: {
|
|
|
86
84
|
sampling?: {
|
|
87
85
|
toolProgress?: {
|
|
88
86
|
sampleRate?: number | undefined;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
};
|
|
87
|
+
} | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
} | undefined;
|
|
92
90
|
} | null): {
|
|
93
91
|
auditLevel: AuditLevel;
|
|
94
92
|
sampling: {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { SessionEvent, SessionSummary } from '../types/session.js';
|
|
2
|
+
/**
|
|
3
|
+
* The single definition of `SessionSummary.outcome`.
|
|
4
|
+
*
|
|
5
|
+
* Two code paths produce this field — the live writer's `SessionSummaryTracker`
|
|
6
|
+
* and the disk-rebuild `summarizeSessionEventSequence` — and they disagreed
|
|
7
|
+
* three ways on the same journal, so the value a user saw depended on whether
|
|
8
|
+
* the `.summary.json` sidecar cache happened to be warm:
|
|
9
|
+
*
|
|
10
|
+
* 1. **Precedence.** The rebuild asked "how did this session END", letting a
|
|
11
|
+
* trailing `session_end` mean `completed`. The live tracker made `error`
|
|
12
|
+
* sticky from the moment it was set, overriding the terminal marker — so a
|
|
13
|
+
* session that hit one error and then finished cleanly reported `error`
|
|
14
|
+
* forever, and no successful recovery could clear it.
|
|
15
|
+
* 2. **What counts as an error.** The live tracker treated any `tool_result`
|
|
16
|
+
* with `isError` as an errored session. A failed grep is ordinary agent
|
|
17
|
+
* operation; `toolErrorCount` already records those precisely. Only
|
|
18
|
+
* `error` / `provider_error` events mean the session itself went wrong.
|
|
19
|
+
* 3. **The no-signal case.** The rebuild left `outcome` undefined when the
|
|
20
|
+
* journal ended on neither a terminal marker nor an error; the live
|
|
21
|
+
* tracker defaulted to `completed`, asserting a clean end it had no
|
|
22
|
+
* evidence for.
|
|
23
|
+
*
|
|
24
|
+
* Measured drift: one journal (`user_input`, an errored `tool_result`, a normal
|
|
25
|
+
* `llm_response`, `session_end`) summarized as `error` live and `completed`
|
|
26
|
+
* rebuilt. Both paths now call this function.
|
|
27
|
+
*
|
|
28
|
+
* @param lastEventType Type of the final event in the journal, or undefined for
|
|
29
|
+
* an empty one. `session_end` means a clean shutdown wrote its marker; a
|
|
30
|
+
* trailing `in_flight_start` means the process died mid-operation.
|
|
31
|
+
* @param hadSessionError Whether any `error` / `provider_error` event was
|
|
32
|
+
* observed. Consulted only when the journal has no terminal marker to speak
|
|
33
|
+
* for itself.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveSessionOutcome(lastEventType: SessionEvent['type'] | undefined, hadSessionError: boolean): SessionSummary['outcome'];
|
|
36
|
+
/**
|
|
37
|
+
* Whether an event means the SESSION failed, as opposed to one operation
|
|
38
|
+
* inside it failing. Kept next to {@link resolveSessionOutcome} so both
|
|
39
|
+
* producers classify identically.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isSessionErrorEvent(event: SessionEvent): boolean;
|
|
42
|
+
//# sourceMappingURL=session-outcome.d.ts.map
|
|
@@ -29,6 +29,35 @@ export interface StaleSession {
|
|
|
29
29
|
/** Total events in the log. */
|
|
30
30
|
eventCount: number;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* A session whose journal has no trailing `session_end`.
|
|
34
|
+
*
|
|
35
|
+
* Broader than {@link StaleSession} on purpose. `StaleSession` answers "did a
|
|
36
|
+
* process die *mid-iteration*", which needs a dangling `in_flight_start`. But a
|
|
37
|
+
* host killed while the agent was idle — waiting for the next prompt — closes
|
|
38
|
+
* its last turn with `in_flight_end` and then simply stops writing. Such a
|
|
39
|
+
* session is every bit as unfinished, and matching only on `in_flight_start`
|
|
40
|
+
* made exactly the common case (close the terminal, kill the daemon, reboot)
|
|
41
|
+
* invisible to recovery.
|
|
42
|
+
*
|
|
43
|
+
* Detection is a tail scan for the newest lifecycle boundary:
|
|
44
|
+
* - `session_end` -> closed, not reported
|
|
45
|
+
* - `in_flight_start` -> unclosed AND stale (died mid-iteration)
|
|
46
|
+
* - `in_flight_end` / none -> unclosed, not stale (died between turns)
|
|
47
|
+
*/
|
|
48
|
+
export interface UnclosedSession {
|
|
49
|
+
sessionId: string;
|
|
50
|
+
/** Path to the JSONL log. */
|
|
51
|
+
path: string;
|
|
52
|
+
/** Newest lifecycle boundary, or null for a journal that has none. */
|
|
53
|
+
lastBoundary: 'in_flight_start' | 'in_flight_end' | null;
|
|
54
|
+
/** Boundary timestamp when there is one, else the file's mtime as ISO. */
|
|
55
|
+
lastEventTs: string;
|
|
56
|
+
/** True when the newest boundary is a dangling `in_flight_start`. */
|
|
57
|
+
stale: boolean;
|
|
58
|
+
/** File mtime in ms — the ordering key, since a boundary-less log has no ts. */
|
|
59
|
+
modifiedAt: number;
|
|
60
|
+
}
|
|
32
61
|
export interface RecoveryPlan {
|
|
33
62
|
sessionId: string;
|
|
34
63
|
/** True if the session is stale (has a dangling in_flight_start). */
|
|
@@ -110,6 +139,32 @@ export declare class SessionRecovery {
|
|
|
110
139
|
* recent crash first.
|
|
111
140
|
*/
|
|
112
141
|
listResumable(): Promise<StaleSession[]>;
|
|
142
|
+
/**
|
|
143
|
+
* List every session whose journal has no trailing `session_end`, newest
|
|
144
|
+
* file first. This is the read side of "recovery" as a user means it: the
|
|
145
|
+
* conversations a crash, a `kill`, or a closed laptop lid left hanging.
|
|
146
|
+
*
|
|
147
|
+
* Ordering is by file mtime, not by boundary timestamp: a journal with no
|
|
148
|
+
* lifecycle boundary at all (a session that never completed a turn) has no
|
|
149
|
+
* timestamp to sort on, and mtime is the one key every candidate has.
|
|
150
|
+
*
|
|
151
|
+
* @param options.limit Stop after this many unclosed sessions are found.
|
|
152
|
+
* Candidates are examined newest-mtime-first, so the cap keeps the common
|
|
153
|
+
* "give me the last one" call to a couple of tail reads instead of a scan
|
|
154
|
+
* of every transcript the project ever wrote.
|
|
155
|
+
*/
|
|
156
|
+
listUnclosed(options?: {
|
|
157
|
+
limit?: number;
|
|
158
|
+
}): Promise<UnclosedSession[]>;
|
|
159
|
+
private detectUnclosedExact;
|
|
160
|
+
/**
|
|
161
|
+
* Every session transcript under `dir`, with the stat both scanners need.
|
|
162
|
+
*
|
|
163
|
+
* Modern sessions live inside date-shard subdirectories
|
|
164
|
+
* ("2026-06-11/<base>.jsonl"); legacy/flat sessions sit at the root. Scan
|
|
165
|
+
* both — a root-only scan silently misses every modern crash.
|
|
166
|
+
*/
|
|
167
|
+
private collectTranscripts;
|
|
113
168
|
private filePath;
|
|
114
169
|
constructor(dir: string);
|
|
115
170
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EventBus } from '../event-bus-port.js';
|
|
2
|
+
import type { SessionLoadProgress } from '../../types/session.js';
|
|
2
3
|
import type { SecretScrubber } from '../../types/secret-scrubber.js';
|
|
3
4
|
import type { SessionData } from '../../types/session.js';
|
|
4
5
|
/**
|
|
@@ -28,5 +29,15 @@ export declare function loadSessionDataFromFile(params: {
|
|
|
28
29
|
events?: EventBus | undefined;
|
|
29
30
|
secretScrubber: SecretScrubber;
|
|
30
31
|
maxRetainedEventBytes?: number | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Byte-level parse progress for large journals. Throttled to one call per
|
|
34
|
+
* `progressIntervalMs` (the per-line accounting approximates delimiters)
|
|
35
|
+
* plus an unthrottled final call at EOF reporting
|
|
36
|
+
* `loadedBytes === totalBytes` exactly. When omitted,
|
|
37
|
+
* no progress work happens at all — not even the source-size stat.
|
|
38
|
+
*/
|
|
39
|
+
onLoadProgress?: ((progress: SessionLoadProgress) => void) | undefined;
|
|
40
|
+
/** Test seam: override the throttle window (0 = every line). */
|
|
41
|
+
progressIntervalMs?: number | undefined;
|
|
31
42
|
}): Promise<SessionData>;
|
|
32
43
|
//# sourceMappingURL=load-session-data.d.ts.map
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* predicate is what stops them disagreeing again.
|
|
5
5
|
*/
|
|
6
6
|
export declare function isPrunableSessionJsonl(name: string): boolean;
|
|
7
|
-
export declare function pruneSessionFiles(storeDir: string, maxAgeDays: number, deleteSession: (id: string) => Promise<void>): Promise<number>;
|
|
7
|
+
export declare function pruneSessionFiles(storeDir: string, maxAgeDays: number, deleteSession: (id: string) => Promise<void>, isSessionInUse?: ((sessionId: string) => Promise<string | null>) | undefined): Promise<number>;
|
|
8
8
|
//# sourceMappingURL=prune-helpers.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as fsp from 'node:fs/promises';
|
|
2
1
|
import type { EventBus } from '../event-bus-port.js';
|
|
3
2
|
import type { SecretScrubber } from '../../types/secret-scrubber.js';
|
|
4
3
|
import type { ResumedSession, SessionData, SessionEvent, SessionSummary } from '../../types/session.js';
|
|
@@ -24,5 +23,4 @@ export interface ResumeSessionParams {
|
|
|
24
23
|
sessionsDir?: string | undefined;
|
|
25
24
|
}
|
|
26
25
|
export declare function executeResumeSession(params: ResumeSessionParams): Promise<ResumedSession>;
|
|
27
|
-
export declare function openSessionForAppend(file: string): Promise<fsp.FileHandle>;
|
|
28
26
|
//# sourceMappingURL=resume-session.d.ts.map
|
|
@@ -48,8 +48,16 @@ export interface SessionStoreOptions {
|
|
|
48
48
|
*/
|
|
49
49
|
export interface LoadCacheEntry {
|
|
50
50
|
mtimeMs: number;
|
|
51
|
+
/** Source journal size — the freshness key, paired with `mtimeMs`. */
|
|
51
52
|
size: number;
|
|
52
53
|
data: SessionData;
|
|
54
|
+
/**
|
|
55
|
+
* Estimated heap this entry occupies, and what it is charged against the
|
|
56
|
+
* cache budget. Distinct from `size`: a journal is mostly superseded
|
|
57
|
+
* snapshots and evicted events, so the file dwarfs what survives into
|
|
58
|
+
* `data`. Optional for entries written before the distinction existed.
|
|
59
|
+
*/
|
|
60
|
+
bytes?: number | undefined;
|
|
53
61
|
}
|
|
54
62
|
export interface IndexCacheEntry {
|
|
55
63
|
mtimeMs: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ForkedSession, ResumedSession, SessionData, SessionEvent, SessionForkOptions, SessionMetadata, SessionStore, SessionSummary, SessionWriter, WorkspaceCheckpointRef } from '../types/session.js';
|
|
1
|
+
import type { ForkedSession, ResumedSession, SessionData, SessionEvent, SessionForkOptions, SessionLoadProgress, SessionMetadata, SessionStore, SessionSummary, SessionWriter, WorkspaceCheckpointRef } from '../types/session.js';
|
|
2
2
|
import type { SessionStoreOptions } from './session-store/types.js';
|
|
3
3
|
export type { SessionStoreOptions } from './session-store/types.js';
|
|
4
4
|
export declare class DefaultSessionStore implements SessionStore {
|
|
@@ -69,8 +69,8 @@ export declare class DefaultSessionStore implements SessionStore {
|
|
|
69
69
|
captureWorkspaceCheckpoint(sessionId: string, promptIndex: number): Promise<WorkspaceCheckpointRef | undefined>;
|
|
70
70
|
materializeWorkspaceCheckpoint(checkpoint: WorkspaceCheckpointRef, targetRoot: string): Promise<import("../types/session.js").WorkspaceMaterializationResult>;
|
|
71
71
|
resolveId(query: string): Promise<string>;
|
|
72
|
-
resume(id: string): Promise<ResumedSession>;
|
|
73
|
-
load(id: string): Promise<SessionData>;
|
|
72
|
+
resume(id: string, onLoadProgress?: (progress: SessionLoadProgress) => void): Promise<ResumedSession>;
|
|
73
|
+
load(id: string, onLoadProgress?: (progress: SessionLoadProgress) => void): Promise<SessionData>;
|
|
74
74
|
loadEventsOnly(id: string): Promise<SessionData>;
|
|
75
75
|
private loadInternal;
|
|
76
76
|
searchEvents(id: string, predicate: (event: SessionEvent, eventIndex: number, ts: string) => boolean, opts?: {
|
|
@@ -26,7 +26,14 @@ export declare class SessionSummaryTracker {
|
|
|
26
26
|
private messageCount;
|
|
27
27
|
private lastUserMessage;
|
|
28
28
|
private lastActivityAt;
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Whether an `error`/`provider_error` was seen. Not a latched outcome — see
|
|
31
|
+
* {@link resolveSessionOutcome} for why a trailing terminal marker outranks
|
|
32
|
+
* it, and why a failed tool_result is deliberately not counted here.
|
|
33
|
+
*/
|
|
34
|
+
private hadSessionError;
|
|
35
|
+
/** Type of the newest observed event; the terminal-marker signal. */
|
|
36
|
+
private lastEventType;
|
|
30
37
|
private openToolUses;
|
|
31
38
|
constructor(opts: SessionSummaryTrackerOptions);
|
|
32
39
|
get currentSummary(): Readonly<SessionSummary>;
|
|
@@ -26,6 +26,16 @@ export declare class SessionWriteBuffer {
|
|
|
26
26
|
private static readonly FLUSH_SIZE;
|
|
27
27
|
private static readonly WRITE_BUFFER_MAX_EVENTS;
|
|
28
28
|
private static readonly WRITE_BUFFER_MAX_BYTES;
|
|
29
|
+
/**
|
|
30
|
+
* Absolute ceiling for ONE event, even via the empty-buffer exemption in
|
|
31
|
+
* `push`. That exemption exists so a legitimately huge user prompt is
|
|
32
|
+
* persisted instead of silently dropped (its bytes are already resident —
|
|
33
|
+
* accepting it costs one reference, not a copy); without a ceiling an
|
|
34
|
+
* unbounded payload could pin memory and stall the event loop on
|
|
35
|
+
* stringify. 64MiB is 4x the retention budget and far above any real
|
|
36
|
+
* prompt, so it only fires on pathological input.
|
|
37
|
+
*/
|
|
38
|
+
private static readonly MAX_SINGLE_EVENT_BYTES;
|
|
29
39
|
private writeBuffer;
|
|
30
40
|
private writeBufferBytes;
|
|
31
41
|
private flushTimer;
|
|
@@ -33,6 +43,8 @@ export declare class SessionWriteBuffer {
|
|
|
33
43
|
private lastBufferOverflowWarnAt;
|
|
34
44
|
private appendFailCount;
|
|
35
45
|
private lastAppendWarnAt;
|
|
46
|
+
private invalidEventCount;
|
|
47
|
+
private lastInvalidEventWarnAt;
|
|
36
48
|
private writeChain;
|
|
37
49
|
private flushPromise;
|
|
38
50
|
/**
|
|
@@ -57,6 +69,12 @@ export declare class SessionWriteBuffer {
|
|
|
57
69
|
/**
|
|
58
70
|
* Last-gasp synchronous append (SIGKILL/SIGTERM traps, `process.on('exit')`).
|
|
59
71
|
*
|
|
72
|
+
* If an async append is actively writing when teardown arrives, flushSync
|
|
73
|
+
* must not open a second append descriptor and race it. It defers with a
|
|
74
|
+
* structured `session.flush_sync_deferred` warning, leaving the buffer
|
|
75
|
+
* untouched for the already-running flush loop to drain if the process
|
|
76
|
+
* survives.
|
|
77
|
+
*
|
|
60
78
|
* Failure contract: nothing is discarded before the write is known to have
|
|
61
79
|
* landed. Buffered events stay in `writeBuffer` — it is cleared only after
|
|
62
80
|
* `fsyncSync` returns — and a stolen in-flight batch is handed back to the
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export interface SessionTruncatePlan {
|
|
2
2
|
checkpointByteOffset: number;
|
|
3
3
|
removedCount: number;
|
|
4
|
+
/** Transcript paths referenced ONLY by the removed window — safe to delete. */
|
|
5
|
+
removedSubagentTranscriptPaths: string[];
|
|
4
6
|
}
|
|
5
7
|
export declare function findSessionCheckpointTruncatePlan(filePath: string, targetPromptIndex: number): Promise<SessionTruncatePlan | null>;
|
|
6
8
|
export declare function rewriteSessionToCheckpoint(filePath: string, checkpointByteOffset: number): Promise<void>;
|