@wrongstack/core 0.313.1 → 0.316.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chronicle/index.js +31 -31
- 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 +39 -31
- package/dist/chronicle/sink.d.ts +13 -0
- package/dist/chronicle/sqlite-journal.d.ts +20 -2
- package/dist/{chunk-WOEZV3Q4.js → chunk-25LSLC3G.js} +2 -1
- package/dist/{chunk-AI4LLQ2U.js → chunk-27QIURLN.js} +229 -12
- package/dist/{chunk-I45KAW2N.js → chunk-3AGWVSS7.js} +38 -450
- package/dist/chunk-3BDV7RL3.js +211 -0
- package/dist/{chunk-NFAYHPRH.js → chunk-3ECENVHL.js} +10 -8
- package/dist/{chunk-FW5LDDMJ.js → chunk-45WI72ZB.js} +1576 -1156
- package/dist/{chunk-AT4V4XGI.js → chunk-4BMVPOHO.js} +539 -313
- package/dist/{chunk-YBUJCZ57.js → chunk-4I7HGVVA.js} +17 -5
- package/dist/{chunk-JVGPR3TS.js → chunk-4LCZVJVF.js} +7 -55
- package/dist/{chunk-4ZHTKJHM.js → chunk-4SJNS7OB.js} +36 -2
- package/dist/{chunk-AD7ZFZCS.js → chunk-5BMIE7QG.js} +3 -3
- package/dist/{chunk-IQ35HMQL.js → chunk-5YPSXQXM.js} +71 -24
- package/dist/chunk-6FHWXLPT.js +10 -0
- package/dist/{chunk-FIV4IJL7.js → chunk-6H5GEOET.js} +163 -20
- package/dist/{chunk-VB3H5WWB.js → chunk-6NWEVFEL.js} +2 -2
- package/dist/{chunk-E6I5RXVK.js → chunk-AYW5YINX.js} +2 -2
- package/dist/{chunk-DEIQMBD2.js → chunk-B7F4WVP4.js} +2 -2
- package/dist/{chunk-XQ2XGIBF.js → chunk-BPBKKBUK.js} +6 -7
- package/dist/{chunk-K4YUNKU7.js → chunk-BYD345OX.js} +2 -2
- package/dist/{chunk-LZDDLNCZ.js → chunk-C27KDLOX.js} +4 -4
- package/dist/{chunk-6AKOTGLM.js → chunk-CU546ESW.js} +7 -7
- package/dist/{chunk-ZZ4V3WIZ.js → chunk-DLHHXUAM.js} +10 -1
- package/dist/{chunk-BAKVJLEV.js → chunk-DOTHQSJ2.js} +28 -16
- package/dist/{chunk-KBZGE6LN.js → chunk-DYLPMV4Q.js} +4 -3
- package/dist/{chunk-52RTVH4M.js → chunk-F3JWNST7.js} +2 -2
- package/dist/{chunk-WEBMSQP2.js → chunk-FC2ZGRF3.js} +21 -4
- package/dist/{chunk-FHAMQS7Q.js → chunk-FCBTO76Z.js} +76 -146
- package/dist/{chunk-4LJJYBAU.js → chunk-FHZVFYSL.js} +9 -1
- package/dist/{chunk-W4A6QA3D.js → chunk-FWNLEZYG.js} +4 -3
- package/dist/{chunk-OJZEX73F.js → chunk-GDQ7CZRQ.js} +5 -1
- package/dist/{chunk-QVOVMXJR.js → chunk-GJJGJB2R.js} +32 -9
- package/dist/{chunk-4XV6IR37.js → chunk-HI3JGZR2.js} +7 -6
- package/dist/{chunk-FSWCWSTS.js → chunk-HMLIGAU7.js} +26 -26
- package/dist/{chunk-PFXFQQRT.js → chunk-HXKZ7OBQ.js} +7 -43
- package/dist/{chunk-2FQL4PDC.js → chunk-I7DALG7J.js} +5 -5
- package/dist/{chunk-GM54GJBU.js → chunk-IRUTEHCE.js} +3 -3
- package/dist/{chunk-TYW2GI5I.js → chunk-J2WRWR37.js} +40 -13
- package/dist/{chunk-ZEHUCJHY.js → chunk-JFPJ6LLQ.js} +2 -2
- package/dist/chunk-JMULFFLN.js +9 -0
- package/dist/{chunk-RD6DEE36.js → chunk-JO4MGB6Z.js} +94 -8
- package/dist/{chunk-5DSMEVA4.js → chunk-K6BXGITA.js} +7 -7
- package/dist/{chunk-O74MJHXU.js → chunk-KZMSZV32.js} +2 -2
- package/dist/{chunk-GFJOMSHG.js → chunk-LA7CLDRW.js} +6 -2
- package/dist/{chunk-M2WF6AXG.js → chunk-LSMMOS2Z.js} +7 -3
- package/dist/{chunk-ASX6AW36.js → chunk-LXWCMQNJ.js} +3 -3
- package/dist/{chunk-WZO23AWO.js → chunk-M27LIEKV.js} +72 -22
- package/dist/{chunk-JTHKOYWU.js → chunk-MJPHJRAL.js} +15 -15
- package/dist/{chunk-G5AAKEEZ.js → chunk-MTL4O5YR.js} +5 -5
- package/dist/chunk-NHJ75HXY.js +1 -0
- package/dist/{chunk-ZYU2YOJ6.js → chunk-NIOAGFPB.js} +29 -15
- package/dist/{chunk-Y2GE5TSI.js → chunk-NS52ISWS.js} +2 -2
- package/dist/{chunk-UIWONWVG.js → chunk-NSOFPKGT.js} +541 -148
- package/dist/{chunk-RCQYT2I4.js → chunk-NVIZG63R.js} +2 -2
- package/dist/{chunk-EPC3GZD4.js → chunk-OOYZPOXM.js} +2 -2
- package/dist/{chunk-7ZHZE5EO.js → chunk-OSGLYW5J.js} +2 -2
- package/dist/{chunk-CE4ZOCOI.js → chunk-PFCMSSUF.js} +9 -9
- package/dist/{chunk-GFXZTHNI.js → chunk-PGRVXIMY.js} +5 -5
- package/dist/{chunk-JJPMWPB6.js → chunk-PISBFBJN.js} +6 -6
- package/dist/chunk-POOOIWE5.js +9 -0
- package/dist/{chunk-5RP3QTRL.js → chunk-PQNS3U7Z.js} +20 -3
- package/dist/{chunk-3E244UDA.js → chunk-QSTSJOCK.js} +52 -6
- package/dist/{chunk-YUPMXOGP.js → chunk-RFQMOKWK.js} +3 -3
- package/dist/chunk-RTOTNK3P.js +484 -0
- package/dist/{chunk-SN2DQRL6.js → chunk-RXKSDUAU.js} +7 -7
- package/dist/{chunk-T3KGZBU5.js → chunk-S45JPKQN.js} +189 -43
- package/dist/{chunk-YNCVSFGF.js → chunk-SAFHACFA.js} +4 -1
- package/dist/{chunk-KI4L2DUL.js → chunk-TCCHINEF.js} +114 -19
- package/dist/{chunk-AWNQ6ED6.js → chunk-THEGTRAG.js} +7 -2
- package/dist/{chunk-2KKODIQU.js → chunk-TR4LQE7L.js} +15 -15
- package/dist/{chunk-GPQ3NJPR.js → chunk-TWJMGXCI.js} +3 -3
- package/dist/{chunk-H72H4XDU.js → chunk-U45AXT5D.js} +9 -9
- package/dist/{chunk-62V2AFVG.js → chunk-U4FWBSO3.js} +160 -73
- package/dist/{chunk-A455ATZB.js → chunk-UBGDX6FI.js} +8 -1
- package/dist/chunk-UJILKYES.js +75 -0
- package/dist/{chunk-KSJ5UTP7.js → chunk-ULMAQV3T.js} +84 -4
- package/dist/{chunk-CB2HFKTP.js → chunk-VVBP6KGT.js} +1 -1
- package/dist/{chunk-RPOA7IAE.js → chunk-W5VITDM2.js} +43 -25
- package/dist/{chunk-QRTG4XTI.js → chunk-WAHQVNWT.js} +7 -1
- package/dist/{chunk-SQP64RCS.js → chunk-WGGYRBXH.js} +3019 -2976
- package/dist/{chunk-K3G6JBUC.js → chunk-WLYKU45P.js} +679 -141
- package/dist/chunk-WP7BVANJ.js +53 -0
- package/dist/{chunk-GAZEWQEZ.js → chunk-XF4VUMKW.js} +2 -2
- package/dist/{chunk-PAAWLLZX.js → chunk-Y5YXDM7D.js} +2 -2
- package/dist/{chunk-65RDIOR2.js → chunk-YOPAUVU4.js} +162 -44
- package/dist/{chunk-FFSX2QDQ.js → chunk-YPT4A46F.js} +3 -3
- package/dist/chunk-YWXT3JNM.js +425 -0
- package/dist/{chunk-EFEHDQGY.js → chunk-ZHZ2Y2DH.js} +64 -10
- package/dist/{chunk-CQQL4ZOQ.js → chunk-ZT7JNIGX.js} +4 -3
- 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 +52 -22
- 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 +86 -49
- 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 +15 -15
- 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 +37 -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 +1 -1
- package/dist/core/context.d.ts +22 -3
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +130 -38
- 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 +3 -3
- 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.js +138 -129
- package/dist/execution/model-runtime.d.ts +0 -7
- package/dist/execution/parallel-eternal-engine.d.ts +7 -7
- package/dist/extension/index.js +3 -3
- package/dist/goal/index.js +6 -6
- package/dist/hooks/index.js +3 -3
- package/dist/hq/index.js +14 -12
- package/dist/hq/persistence/event-log.d.ts +0 -1
- package/dist/hq/persistence.d.ts +4 -4
- package/dist/hq/publisher.d.ts +2 -0
- package/dist/index.d.ts +14 -11
- package/dist/index.js +728 -635
- package/dist/infrastructure/index.d.ts +4 -4
- package/dist/infrastructure/index.js +281 -260
- 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 +7 -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 +4 -4
- package/dist/mailbox-attach.d.ts +1 -1
- package/dist/models/index.js +10 -9
- package/dist/observability/event-bridge.d.ts +25 -5
- package/dist/observability/index.d.ts +9 -8
- package/dist/observability/index.js +459 -351
- package/dist/observability/tool-usage-source.d.ts +65 -0
- package/dist/plugin/index.d.ts +5 -0
- package/dist/plugin/index.js +66 -50
- package/dist/plugins/auto-review-plugin.d.ts +3 -2
- package/dist/plugins/review-finding-commands.d.ts +0 -8
- package/dist/{review-finding-store-DKAV3AS6.js → plugins/review-finding-store.js} +7 -6
- package/dist/plugins/review-finding-types.js +19 -0
- package/dist/plugins/review-report-integration.js +21 -0
- package/dist/{review-report-store-OWY3EC3N.js → plugins/review-report-store.js} +7 -6
- package/dist/plugins/review-report-types.js +13 -0
- package/dist/prompts/index.js +5 -5
- package/dist/registry/index.js +3 -3
- package/dist/registry/tool-registry.d.ts +59 -9
- package/dist/{registry-R23UBE7H.js → registry-7N4O3E7W.js} +5 -5
- package/dist/security/capabilities.d.ts +6 -0
- package/dist/security/file-permissions.d.ts +1 -1
- package/dist/security/index.js +47 -33
- 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 +19 -14
- package/dist/session-catalog/project-server.js +30 -13
- 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 +5 -5
- 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 +76 -61
- 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 +2 -2
- package/dist/tools/fallback-manage-tools.d.ts +6 -4
- package/dist/tools/index.js +21 -21
- package/dist/tools/model-tier-set-tool.d.ts +66 -0
- package/dist/types/agent-bridge.d.ts +2 -1
- 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.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 +2 -1
- package/dist/types/index.d.ts +11 -9
- package/dist/types/index.js +25 -15
- package/dist/types/multi-agent.d.ts +43 -0
- package/dist/types/plugin.d.ts +1 -1
- 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 +1 -1
- 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/heap-watchdog.js +2 -2
- package/dist/utils/index.js +50 -48
- package/dist/utils/message-invariants.d.ts +4 -1
- package/dist/utils/regex-guard.d.ts +1 -1
- 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 +28 -0
- package/dist/wiring/proxy-rewrite.js +7 -1
- package/dist/worktree/index.js +2 -2
- 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 +33 -5
- package/dist/chunk-2BUUIMQB.js +0 -225
- package/dist/chunk-FAYRX2AD.js +0 -13
- package/dist/chunk-H5E77KUJ.js +0 -15
- package/dist/chunk-M7BS2K6U.js +0 -1
- 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
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-WQTOVMGV.js";
|
|
5
5
|
import {
|
|
6
6
|
estimateToolDefTokens
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HMLIGAU7.js";
|
|
8
8
|
import {
|
|
9
9
|
ERROR_CODES,
|
|
10
10
|
WrongStackError
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-25LSLC3G.js";
|
|
12
12
|
import {
|
|
13
13
|
toErrorMessage
|
|
14
14
|
} from "./chunk-TBRL2RCC.js";
|
|
@@ -198,11 +198,20 @@ var ToolRegistry = class _ToolRegistry {
|
|
|
198
198
|
tools = /* @__PURE__ */ new Map();
|
|
199
199
|
descriptionModes = /* @__PURE__ */ new Map();
|
|
200
200
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
201
|
+
* Disabled tool names plus the audit-trail metadata explaining WHY each
|
|
202
|
+
* one was disabled. `user` is the historical default (manual
|
|
203
|
+
* `/tool disable`); `auto-thinned` is the new path the auto-thinning
|
|
204
|
+
* pipeline writes so `/tool autothin undo` can restore the right subset.
|
|
205
|
+
* The underlying tool data stays in `_tools` so re-enable is constant-time.
|
|
204
206
|
*/
|
|
205
|
-
_disabled = /* @__PURE__ */ new
|
|
207
|
+
_disabled = /* @__PURE__ */ new Map();
|
|
208
|
+
/**
|
|
209
|
+
* Optional EventBus used by `thinUnderused()` to emit `tool.thinned`.
|
|
210
|
+
* Set via `setEventBus()` at boot — optional so the registry stays
|
|
211
|
+
* usable in pure unit tests and in code paths that never run the
|
|
212
|
+
* auto-thinning pipeline.
|
|
213
|
+
*/
|
|
214
|
+
_events;
|
|
206
215
|
/** Monotonic version bumped on every registry mutation. */
|
|
207
216
|
_version = 0;
|
|
208
217
|
/** Cached `list()` result, frozen after build. Invalidated on _version change. */
|
|
@@ -388,18 +397,32 @@ var ToolRegistry = class _ToolRegistry {
|
|
|
388
397
|
return this.tools.get(name)?.owner;
|
|
389
398
|
}
|
|
390
399
|
// ── Disable / enable ────────────────────────────────────────────
|
|
400
|
+
/** Attach the EventBus so `thinUnderused()` can emit `tool.thinned`.
|
|
401
|
+
* Idempotent; safe to call multiple times at boot. */
|
|
402
|
+
setEventBus(events) {
|
|
403
|
+
this._events = events;
|
|
404
|
+
}
|
|
391
405
|
/**
|
|
392
406
|
* Disable a tool by name. The tool is removed from all public accessors
|
|
393
407
|
* (list(), get(), listByCategory(), listWithOwner()) so it does NOT
|
|
394
408
|
* appear in the system prompt or provider request. The underlying
|
|
395
409
|
* registration is preserved in memory — use `enable()` to restore it.
|
|
396
410
|
*
|
|
411
|
+
* `reason` defaults to `'user'` for backward compatibility — every
|
|
412
|
+
* historical caller (CLI `/tool disable`, WebUI, subagent filter)
|
|
413
|
+
* writes a user-authored disable. The auto-thinning pipeline always
|
|
414
|
+
* passes `'auto-thinned'`.
|
|
415
|
+
*
|
|
397
416
|
* @returns `true` if the tool was found and disabled; `false` if the
|
|
398
417
|
* tool is not registered or is already disabled.
|
|
399
418
|
*/
|
|
400
|
-
disable(name) {
|
|
419
|
+
disable(name, reason = "user", meta) {
|
|
401
420
|
if (!this.tools.has(name) || this._disabled.has(name)) return false;
|
|
402
|
-
this._disabled.
|
|
421
|
+
this._disabled.set(name, {
|
|
422
|
+
reason,
|
|
423
|
+
at: Date.now(),
|
|
424
|
+
...meta?.caller ? { caller: meta.caller } : {}
|
|
425
|
+
});
|
|
403
426
|
this._version++;
|
|
404
427
|
return true;
|
|
405
428
|
}
|
|
@@ -428,34 +451,106 @@ var ToolRegistry = class _ToolRegistry {
|
|
|
428
451
|
this._version++;
|
|
429
452
|
return count;
|
|
430
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* Re-enable only the tools that were disabled by the auto-thinning
|
|
456
|
+
* pipeline (`reason === 'auto-thinned'` in `disabledToolMeta`). Manual
|
|
457
|
+
* user disables are preserved. Returns the names that were re-enabled.
|
|
458
|
+
*/
|
|
459
|
+
enableAutoThinned() {
|
|
460
|
+
const restored = [];
|
|
461
|
+
for (const [name, meta] of this._disabled) {
|
|
462
|
+
if (meta.reason === "auto-thinned") {
|
|
463
|
+
this._disabled.delete(name);
|
|
464
|
+
restored.push(name);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (restored.length > 0) this._version++;
|
|
468
|
+
return restored;
|
|
469
|
+
}
|
|
431
470
|
/**
|
|
432
471
|
* Check whether a tool is currently disabled.
|
|
433
472
|
*/
|
|
434
473
|
isDisabled(name) {
|
|
435
474
|
return this._disabled.has(name);
|
|
436
475
|
}
|
|
476
|
+
/** Return the audit-trail metadata for a disabled tool, if any. */
|
|
477
|
+
disabledMeta(name) {
|
|
478
|
+
return this._disabled.get(name);
|
|
479
|
+
}
|
|
437
480
|
/**
|
|
438
481
|
* Apply a list of tool names to disable. Tools not in the registry
|
|
439
482
|
* are silently ignored so config can reference future tools without
|
|
440
|
-
* error. Returns the number of tools actually disabled.
|
|
483
|
+
* error. Returns the number of tools actually disabled. Always
|
|
484
|
+
* tagged `reason: 'user'` — the auto-thinning pipeline uses
|
|
485
|
+
* `thinUnderused()` instead.
|
|
441
486
|
*/
|
|
442
487
|
applyDisabled(names) {
|
|
443
488
|
let count = 0;
|
|
444
489
|
for (const name of names) {
|
|
445
|
-
if (this.disable(name)) count++;
|
|
490
|
+
if (this.disable(name, "user")) count++;
|
|
446
491
|
}
|
|
447
492
|
return count;
|
|
448
493
|
}
|
|
449
494
|
/**
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
495
|
+
* Apply the audit-trail metadata for a previously-disabled tool.
|
|
496
|
+
* Used at boot to restore `disabledToolMeta` (so the auto-thinned
|
|
497
|
+
* decision survives a restart). Does NOT mutate the disabled set
|
|
498
|
+
* itself — pair with `applyDisabled()` on the same names.
|
|
499
|
+
*/
|
|
500
|
+
applyDisabledMeta(meta) {
|
|
501
|
+
let count = 0;
|
|
502
|
+
const at = Date.now();
|
|
503
|
+
for (const [name, entry] of Object.entries(meta)) {
|
|
504
|
+
if (!this._disabled.has(name)) continue;
|
|
505
|
+
this._disabled.set(name, { ...entry, at: entry.at ?? at });
|
|
506
|
+
count++;
|
|
507
|
+
}
|
|
508
|
+
if (count > 0) this._version++;
|
|
509
|
+
return count;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Disable every name in `candidates` that is currently registered and
|
|
513
|
+
* not already disabled, tagged with `reason: 'auto-thinned'`. Emits
|
|
514
|
+
* a `tool.thinned` event with the names that actually flipped.
|
|
515
|
+
*
|
|
516
|
+
* @returns `{ thinned, skipped }` so the caller can persist the
|
|
517
|
+
* decision to `disabledToolMeta` and report what was changed.
|
|
518
|
+
*/
|
|
519
|
+
thinUnderused(candidates, caller) {
|
|
520
|
+
const thinned = [];
|
|
521
|
+
const skipped = [];
|
|
522
|
+
const at = Date.now();
|
|
523
|
+
for (const name of candidates) {
|
|
524
|
+
if (!this.tools.has(name)) {
|
|
525
|
+
skipped.push(name);
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
if (this._disabled.has(name)) {
|
|
529
|
+
skipped.push(name);
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
this._disabled.set(name, { reason: "auto-thinned", at, caller });
|
|
533
|
+
thinned.push(name);
|
|
534
|
+
}
|
|
535
|
+
if (thinned.length > 0) {
|
|
536
|
+
this._version++;
|
|
537
|
+
this._events?.emit("tool.thinned", { names: thinned, reason: caller, at });
|
|
538
|
+
}
|
|
539
|
+
return { thinned, skipped };
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Return the list of all disabled tool entries (tool + owner + reason).
|
|
543
|
+
* Useful for the /tools slash command to show disabled tools alongside
|
|
544
|
+
* enabled ones, and for `/tool autothin status` to count the auto-thinned subset.
|
|
453
545
|
*/
|
|
454
546
|
listDisabled() {
|
|
455
|
-
|
|
547
|
+
const out = [];
|
|
548
|
+
for (const [name, meta] of this._disabled) {
|
|
456
549
|
const entry = this.tools.get(name);
|
|
457
|
-
|
|
458
|
-
|
|
550
|
+
if (!entry) continue;
|
|
551
|
+
out.push({ tool: entry.tool, owner: entry.owner, meta });
|
|
552
|
+
}
|
|
553
|
+
return out;
|
|
459
554
|
}
|
|
460
555
|
list() {
|
|
461
556
|
if (this._listSnapshot && this._version === this._listSnapshotVersion) {
|
|
@@ -543,8 +638,8 @@ var ToolRegistry = class _ToolRegistry {
|
|
|
543
638
|
for (const [name, { tool, owner }] of this.tools) {
|
|
544
639
|
copy.tools.set(name, { tool, owner });
|
|
545
640
|
}
|
|
546
|
-
for (const name of this._disabled) {
|
|
547
|
-
copy._disabled.
|
|
641
|
+
for (const [name, meta] of this._disabled) {
|
|
642
|
+
copy._disabled.set(name, { ...meta });
|
|
548
643
|
}
|
|
549
644
|
copy._providerToolNames = this._providerToolNames ? new Set(this._providerToolNames) : void 0;
|
|
550
645
|
copy._version = this._version;
|
|
@@ -557,4 +652,4 @@ export {
|
|
|
557
652
|
SlashCommandRegistry,
|
|
558
653
|
ToolRegistry
|
|
559
654
|
};
|
|
560
|
-
//# sourceMappingURL=chunk-
|
|
655
|
+
//# sourceMappingURL=chunk-TCCHINEF.js.map
|
|
@@ -91,7 +91,12 @@ var RUNTIME_CAPABILITY_MANIFEST = [
|
|
|
91
91
|
id: "coordination.mailbox",
|
|
92
92
|
pack: "fleet",
|
|
93
93
|
exposure: "direct",
|
|
94
|
-
|
|
94
|
+
// `session_note` sits beside mailbox rather than in its own capability:
|
|
95
|
+
// both are "one agent speaks to another". The split that matters is
|
|
96
|
+
// durability — mailbox persists and crosses sessions, a note is
|
|
97
|
+
// in-process and dies with the session — and that is a property of the
|
|
98
|
+
// tool, not of who is allowed to talk.
|
|
99
|
+
tools: ["mailbox", "mail_send", "mail_inbox", "fleet_status", "session_note"]
|
|
95
100
|
},
|
|
96
101
|
{
|
|
97
102
|
id: "fleet.delegate",
|
|
@@ -308,4 +313,4 @@ export {
|
|
|
308
313
|
runtimeToolReferencesFromText,
|
|
309
314
|
isDeprecatedRuntimeToolAlias
|
|
310
315
|
};
|
|
311
|
-
//# sourceMappingURL=chunk-
|
|
316
|
+
//# sourceMappingURL=chunk-THEGTRAG.js.map
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sessionScopedPath
|
|
3
|
+
} from "./chunk-5BMIE7QG.js";
|
|
1
4
|
import {
|
|
2
5
|
resolveHqRedactionPolicy,
|
|
3
6
|
scrubAndTruncateHqPreview,
|
|
4
7
|
summarizeHqToolArgs
|
|
5
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-NIOAGFPB.js";
|
|
6
9
|
import {
|
|
7
10
|
HQ_TRANSCRIPT_TEXT_CAP,
|
|
8
11
|
isHqKanbanSnapshotPayload
|
|
9
12
|
} from "./chunk-Z2IJUO45.js";
|
|
10
13
|
import {
|
|
11
14
|
SECRET_FILE_MODE
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
effectiveInputTokens
|
|
15
|
-
} from "./chunk-NFAYHPRH.js";
|
|
16
|
-
import {
|
|
17
|
-
CHAT_MARKER_SOURCES,
|
|
18
|
-
sessionEventToMarker
|
|
19
|
-
} from "./chunk-KSJ5UTP7.js";
|
|
20
|
-
import {
|
|
21
|
-
sessionScopedPath
|
|
22
|
-
} from "./chunk-AD7ZFZCS.js";
|
|
15
|
+
} from "./chunk-6FHWXLPT.js";
|
|
23
16
|
import {
|
|
24
17
|
atomicReplaceWithWriter,
|
|
25
18
|
atomicWrite,
|
|
26
19
|
withFileLock
|
|
27
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-OSGLYW5J.js";
|
|
28
21
|
import {
|
|
29
22
|
resolveWstackPaths
|
|
30
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-SAFHACFA.js";
|
|
24
|
+
import {
|
|
25
|
+
effectiveInputTokens
|
|
26
|
+
} from "./chunk-3ECENVHL.js";
|
|
27
|
+
import {
|
|
28
|
+
CHAT_MARKER_SOURCES,
|
|
29
|
+
sessionEventToMarker
|
|
30
|
+
} from "./chunk-ULMAQV3T.js";
|
|
31
31
|
|
|
32
32
|
// src/hq/session-bridge.ts
|
|
33
33
|
import * as fs from "node:fs";
|
|
@@ -2253,4 +2253,4 @@ export {
|
|
|
2253
2253
|
isOpenMode,
|
|
2254
2254
|
assessHqExposure
|
|
2255
2255
|
};
|
|
2256
|
-
//# sourceMappingURL=chunk-
|
|
2256
|
+
//# sourceMappingURL=chunk-TR4LQE7L.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertNotPrivateHost
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LA7CLDRW.js";
|
|
4
4
|
import {
|
|
5
5
|
buildChildEnv
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6NWEVFEL.js";
|
|
7
7
|
import {
|
|
8
8
|
toErrorMessage
|
|
9
9
|
} from "./chunk-TBRL2RCC.js";
|
|
@@ -897,4 +897,4 @@ export {
|
|
|
897
897
|
shellHooksEqual,
|
|
898
898
|
countShellHooks
|
|
899
899
|
};
|
|
900
|
-
//# sourceMappingURL=chunk-
|
|
900
|
+
//# sourceMappingURL=chunk-TWJMGXCI.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deactivateProxyOnConnectionFailure,
|
|
3
3
|
waitForProxyRoutingSettle
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4SJNS7OB.js";
|
|
5
5
|
import {
|
|
6
6
|
scrubErrorText
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Y5YXDM7D.js";
|
|
8
8
|
import {
|
|
9
9
|
runWithNetworkTelemetry
|
|
10
10
|
} from "./chunk-HA4ZYA6T.js";
|
|
@@ -16,22 +16,22 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
createChroniclePromptManifest
|
|
18
18
|
} from "./chunk-2YU4WVBW.js";
|
|
19
|
-
import {
|
|
20
|
-
ProviderError,
|
|
21
|
-
isFallbackWorthy
|
|
22
|
-
} from "./chunk-NFAYHPRH.js";
|
|
23
19
|
import {
|
|
24
20
|
bindRequestProvider,
|
|
25
21
|
completePartialObject,
|
|
26
22
|
resolveEventSessionId
|
|
27
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-ZHZ2Y2DH.js";
|
|
24
|
+
import {
|
|
25
|
+
ProviderError,
|
|
26
|
+
isFallbackWorthy
|
|
27
|
+
} from "./chunk-3ECENVHL.js";
|
|
28
28
|
import {
|
|
29
29
|
isTextBlock,
|
|
30
30
|
isToolUseBlock
|
|
31
31
|
} from "./chunk-O37BQ65S.js";
|
|
32
32
|
import {
|
|
33
33
|
toWrongStackError
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-25LSLC3G.js";
|
|
35
35
|
|
|
36
36
|
// src/core/streaming-response-builder.ts
|
|
37
37
|
import { randomUUID } from "node:crypto";
|
|
@@ -1020,4 +1020,4 @@ export {
|
|
|
1020
1020
|
runtimeFallbackChain,
|
|
1021
1021
|
createFallbackModelExtension
|
|
1022
1022
|
};
|
|
1023
|
-
//# sourceMappingURL=chunk-
|
|
1023
|
+
//# sourceMappingURL=chunk-U45AXT5D.js.map
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CHRONICLE_MAX_APPEND_BATCH
|
|
3
|
+
} from "./chunk-4BMVPOHO.js";
|
|
1
4
|
import {
|
|
2
5
|
mapWithConcurrency
|
|
3
6
|
} from "./chunk-SZ6AYUIZ.js";
|
|
4
7
|
import {
|
|
5
8
|
DEFAULT_WALK_IGNORE_DIRS,
|
|
6
9
|
watchProjectTree
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-J2WRWR37.js";
|
|
8
11
|
|
|
9
12
|
// src/chronicle/context.ts
|
|
10
13
|
import { randomUUID } from "node:crypto";
|
|
@@ -40,6 +43,7 @@ var DEFAULT_EXCLUDED = [
|
|
|
40
43
|
var SCAN_HASH_CONCURRENCY = 32;
|
|
41
44
|
var DEFAULT_FULL_RESCAN_MIN_INTERVAL_MS = 3e4;
|
|
42
45
|
var MAX_RECENT_TOOL_MUTATIONS = 500;
|
|
46
|
+
var JOURNAL_FLUSH_CHUNK = CHRONICLE_MAX_APPEND_BATCH;
|
|
43
47
|
async function startChronicleFileObserver(options) {
|
|
44
48
|
const root = path.resolve(options.projectRoot);
|
|
45
49
|
const excluded = new Set(options.excludedDirectories ?? DEFAULT_EXCLUDED);
|
|
@@ -81,6 +85,7 @@ async function startChronicleFileObserver(options) {
|
|
|
81
85
|
let timer;
|
|
82
86
|
let closed = false;
|
|
83
87
|
let flushTail = null;
|
|
88
|
+
let drainFailure;
|
|
84
89
|
const minFullRescanIntervalMs = options.minFullRescanIntervalMs ?? DEFAULT_FULL_RESCAN_MIN_INTERVAL_MS;
|
|
85
90
|
let lastFullScanAt = Date.now();
|
|
86
91
|
let fullRescanTimer;
|
|
@@ -137,86 +142,125 @@ async function startChronicleFileObserver(options) {
|
|
|
137
142
|
const deleted = changes.filter((change) => change.before && !change.after);
|
|
138
143
|
const created = changes.filter((change) => !change.before && change.after);
|
|
139
144
|
const consumed = /* @__PURE__ */ new Set();
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
145
|
+
const pendingEvents = [];
|
|
146
|
+
const pushPending = (eventType, relativePath, state, attributes, stateWrites) => {
|
|
147
|
+
const attribution = peekAttribution(relativePath, recentToolMutations);
|
|
148
|
+
const { input, emitActivity } = buildMutation(
|
|
149
|
+
options,
|
|
150
|
+
eventType,
|
|
151
|
+
relativePath,
|
|
152
|
+
state,
|
|
153
|
+
attributes,
|
|
154
|
+
attribution
|
|
144
155
|
);
|
|
156
|
+
pendingEvents.push({
|
|
157
|
+
input,
|
|
158
|
+
state: stateWrites,
|
|
159
|
+
emitActivity,
|
|
160
|
+
attribution,
|
|
161
|
+
attributionKey: attribution ? relativePath : void 0
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
const createdByHash = /* @__PURE__ */ new Map();
|
|
165
|
+
for (const to of created) {
|
|
166
|
+
const hash = to.after?.hash;
|
|
167
|
+
if (hash === void 0) continue;
|
|
168
|
+
const bucket = createdByHash.get(hash);
|
|
169
|
+
if (bucket) bucket.entries.push(to);
|
|
170
|
+
else createdByHash.set(hash, { entries: [to], cursor: 0 });
|
|
171
|
+
}
|
|
172
|
+
const claimCreated = (hash) => {
|
|
173
|
+
const bucket = createdByHash.get(hash);
|
|
174
|
+
if (!bucket) return void 0;
|
|
175
|
+
return bucket.cursor < bucket.entries.length ? bucket.entries[bucket.cursor++] : void 0;
|
|
176
|
+
};
|
|
177
|
+
for (const from of deleted) {
|
|
178
|
+
const fromHash = from.before?.hash;
|
|
179
|
+
if (fromHash === void 0) continue;
|
|
180
|
+
const match = claimCreated(fromHash);
|
|
145
181
|
if (!match) continue;
|
|
146
182
|
consumed.add(from.relative);
|
|
147
183
|
consumed.add(match.relative);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
"
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
mutationAttribution(match.relative, recentToolMutations)
|
|
163
|
-
)
|
|
184
|
+
pushPending(
|
|
185
|
+
"file.external.renamed",
|
|
186
|
+
match.relative,
|
|
187
|
+
match.after,
|
|
188
|
+
{
|
|
189
|
+
operation: "rename",
|
|
190
|
+
previousPath: from.relative,
|
|
191
|
+
previousResourceId: resourceId(from.relative),
|
|
192
|
+
actor: "external"
|
|
193
|
+
},
|
|
194
|
+
[
|
|
195
|
+
[from.relative, void 0],
|
|
196
|
+
[match.relative, match.after]
|
|
197
|
+
]
|
|
164
198
|
);
|
|
165
199
|
}
|
|
166
200
|
for (const change of changes) {
|
|
167
201
|
if (consumed.has(change.relative)) continue;
|
|
168
202
|
if (!change.after) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
previousSize: change.before?.size
|
|
181
|
-
},
|
|
182
|
-
mutationAttribution(change.relative, recentToolMutations)
|
|
183
|
-
)
|
|
203
|
+
pushPending(
|
|
204
|
+
"file.external.deleted",
|
|
205
|
+
change.relative,
|
|
206
|
+
change.before,
|
|
207
|
+
{
|
|
208
|
+
operation: "delete",
|
|
209
|
+
actor: "external",
|
|
210
|
+
previousHash: change.before?.hash,
|
|
211
|
+
previousSize: change.before?.size
|
|
212
|
+
},
|
|
213
|
+
[[change.relative, void 0]]
|
|
184
214
|
);
|
|
185
215
|
} else if (!change.before) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
actor: "external"
|
|
196
|
-
},
|
|
197
|
-
mutationAttribution(change.relative, recentToolMutations)
|
|
198
|
-
)
|
|
216
|
+
pushPending(
|
|
217
|
+
"file.external.created",
|
|
218
|
+
change.relative,
|
|
219
|
+
change.after,
|
|
220
|
+
{
|
|
221
|
+
operation: "write",
|
|
222
|
+
actor: "external"
|
|
223
|
+
},
|
|
224
|
+
[[change.relative, change.after]]
|
|
199
225
|
);
|
|
200
226
|
} else {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
previousSize: change.before.size
|
|
213
|
-
},
|
|
214
|
-
mutationAttribution(change.relative, recentToolMutations)
|
|
215
|
-
)
|
|
227
|
+
pushPending(
|
|
228
|
+
"file.external.modified",
|
|
229
|
+
change.relative,
|
|
230
|
+
change.after,
|
|
231
|
+
{
|
|
232
|
+
operation: "edit",
|
|
233
|
+
actor: "external",
|
|
234
|
+
previousHash: change.before.hash,
|
|
235
|
+
previousSize: change.before.size
|
|
236
|
+
},
|
|
237
|
+
[[change.relative, change.after]]
|
|
216
238
|
);
|
|
217
239
|
}
|
|
218
240
|
}
|
|
219
|
-
|
|
241
|
+
try {
|
|
242
|
+
await flushJournalInputs(options, pendingEvents, (committed) => {
|
|
243
|
+
for (const event of committed) {
|
|
244
|
+
for (const [relative2, after] of event.state) {
|
|
245
|
+
if (after) known.set(relative2, after);
|
|
246
|
+
else known.delete(relative2);
|
|
247
|
+
}
|
|
248
|
+
if (event.attributionKey && recentToolMutations.get(event.attributionKey) === event.attribution) {
|
|
249
|
+
recentToolMutations.delete(event.attributionKey);
|
|
250
|
+
}
|
|
251
|
+
event.emitActivity?.();
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
} catch (error) {
|
|
255
|
+
for (const event of pendingEvents) {
|
|
256
|
+
if (!event.attribution || !event.attributionKey) continue;
|
|
257
|
+
const held = recentToolMutations.get(event.attributionKey);
|
|
258
|
+
if (held !== event.attribution) continue;
|
|
259
|
+
recentToolMutations.set(event.attributionKey, { ...event.attribution, at: Date.now() });
|
|
260
|
+
}
|
|
261
|
+
requestFullRescan();
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
220
264
|
};
|
|
221
265
|
const drainPending = () => {
|
|
222
266
|
if (flushTail) return flushTail;
|
|
@@ -224,7 +268,12 @@ async function startChronicleFileObserver(options) {
|
|
|
224
268
|
while (pending.size > 0) {
|
|
225
269
|
const paths = [...pending];
|
|
226
270
|
pending.clear();
|
|
227
|
-
|
|
271
|
+
try {
|
|
272
|
+
await reconcile(paths);
|
|
273
|
+
} catch (error) {
|
|
274
|
+
drainFailure = error;
|
|
275
|
+
options.onError?.(error);
|
|
276
|
+
}
|
|
228
277
|
}
|
|
229
278
|
})().finally(() => {
|
|
230
279
|
if (flushTail === drain) flushTail = null;
|
|
@@ -247,9 +296,22 @@ async function startChronicleFileObserver(options) {
|
|
|
247
296
|
return known.size;
|
|
248
297
|
},
|
|
249
298
|
noteToolMutation,
|
|
299
|
+
/**
|
|
300
|
+
* Shut down the observer. If the final drain (an in-flight drain plus
|
|
301
|
+
* anything still pending at close time) fails, close() REJECTS with
|
|
302
|
+
* that error — a failed shutdown flush is surfaced, not silently
|
|
303
|
+
* dropped. The failure is still not retried after close returns:
|
|
304
|
+
* `requestFullRescan()` no-ops once `closed` is set, and `known` is
|
|
305
|
+
* in-memory state that dies here, so uncommitted changes are not
|
|
306
|
+
* re-derived by a future boot (the startup scan builds fresh
|
|
307
|
+
* fingerprints without diffing against this process's history). The
|
|
308
|
+
* journal remains authoritative for everything that did commit. A
|
|
309
|
+
* second close() call is a no-op and does not re-throw.
|
|
310
|
+
*/
|
|
250
311
|
async close() {
|
|
251
312
|
if (closed) return;
|
|
252
313
|
closed = true;
|
|
314
|
+
drainFailure = void 0;
|
|
253
315
|
offToolProgress?.();
|
|
254
316
|
watcher.close();
|
|
255
317
|
if (timer) {
|
|
@@ -259,17 +321,20 @@ async function startChronicleFileObserver(options) {
|
|
|
259
321
|
if (fullRescanTimer) {
|
|
260
322
|
clearTimeout(fullRescanTimer);
|
|
261
323
|
fullRescanTimer = void 0;
|
|
324
|
+
pending.add("*");
|
|
262
325
|
}
|
|
263
326
|
if (pending.size > 0) drainPending();
|
|
264
327
|
await flushTail;
|
|
265
328
|
recentToolMutations.clear();
|
|
329
|
+
if (drainFailure !== void 0) throw drainFailure;
|
|
266
330
|
}
|
|
267
331
|
};
|
|
268
332
|
}
|
|
269
|
-
|
|
333
|
+
function buildMutation(options, eventType, relativePath, state, attributes, attribution) {
|
|
270
334
|
const context = typeof options.context === "function" ? options.context() : options.context;
|
|
271
335
|
const operation = attributes["operation"];
|
|
272
|
-
options.events
|
|
336
|
+
const bus = options.events;
|
|
337
|
+
const activity = {
|
|
273
338
|
filePath: path.join(options.projectRoot, relativePath),
|
|
274
339
|
operation,
|
|
275
340
|
phase: "changed",
|
|
@@ -279,7 +344,10 @@ async function recordMutation(options, eventType, relativePath, state, attribute
|
|
|
279
344
|
traceId: context.correlation.traceId,
|
|
280
345
|
agentId: attribution?.agentId ?? context.scope.agentId,
|
|
281
346
|
...attribution ? { toolUseId: attribution.toolUseId, toolName: attribution.toolName } : {}
|
|
282
|
-
}
|
|
347
|
+
};
|
|
348
|
+
const emitActivity = bus ? () => {
|
|
349
|
+
bus.emit("file.activity", activity);
|
|
350
|
+
} : void 0;
|
|
283
351
|
const input = {
|
|
284
352
|
eventType: attribution ? eventType.replace(".external.", ".tool.") : eventType,
|
|
285
353
|
scope: {
|
|
@@ -308,12 +376,31 @@ async function recordMutation(options, eventType, relativePath, state, attribute
|
|
|
308
376
|
observedBy: "fs.watch"
|
|
309
377
|
}
|
|
310
378
|
};
|
|
311
|
-
|
|
379
|
+
return { input, emitActivity };
|
|
380
|
+
}
|
|
381
|
+
async function flushJournalInputs(options, events, onCommitted) {
|
|
382
|
+
if (events.length === 0) return;
|
|
383
|
+
const batch = options.journal.appendBatch?.bind(options.journal);
|
|
384
|
+
if (!batch) {
|
|
385
|
+
const settled = await Promise.allSettled(
|
|
386
|
+
events.map(async (event) => {
|
|
387
|
+
await options.journal.append(event.input);
|
|
388
|
+
onCommitted([event]);
|
|
389
|
+
})
|
|
390
|
+
);
|
|
391
|
+
const failure = settled.find((result) => result.status === "rejected");
|
|
392
|
+
if (failure) throw failure.reason;
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
for (let index = 0; index < events.length; index += JOURNAL_FLUSH_CHUNK) {
|
|
396
|
+
const chunk = events.slice(index, index + JOURNAL_FLUSH_CHUNK);
|
|
397
|
+
await batch(chunk.map((event) => event.input));
|
|
398
|
+
onCommitted(chunk);
|
|
399
|
+
}
|
|
312
400
|
}
|
|
313
|
-
function
|
|
401
|
+
function peekAttribution(relativePath, recent) {
|
|
314
402
|
const value = recent.get(relativePath);
|
|
315
403
|
if (!value) return void 0;
|
|
316
|
-
recent.delete(relativePath);
|
|
317
404
|
return Date.now() - value.at <= 2e3 ? value : void 0;
|
|
318
405
|
}
|
|
319
406
|
async function scanProject(root, excluded, excludedPaths, maxHashBytes, onError, previous) {
|
|
@@ -419,4 +506,4 @@ export {
|
|
|
419
506
|
childChronicleContext,
|
|
420
507
|
startChronicleFileObserver
|
|
421
508
|
};
|
|
422
|
-
//# sourceMappingURL=chunk-
|
|
509
|
+
//# sourceMappingURL=chunk-U4FWBSO3.js.map
|