@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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/plugins/review-finding-types.ts
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
var FindingNotFoundError = class extends Error {
|
|
4
|
+
findingId;
|
|
5
|
+
constructor(findingId) {
|
|
6
|
+
super(`Finding not found: ${findingId}`);
|
|
7
|
+
this.name = "FindingNotFoundError";
|
|
8
|
+
this.findingId = findingId;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var InvalidTransitionError = class extends Error {
|
|
12
|
+
from;
|
|
13
|
+
to;
|
|
14
|
+
constructor(from, to, reason) {
|
|
15
|
+
const msg = reason ?? `Invalid transition from "${from}" to "${to}"`;
|
|
16
|
+
super(msg);
|
|
17
|
+
this.name = "InvalidTransitionError";
|
|
18
|
+
this.from = from;
|
|
19
|
+
this.to = to;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var FindingStoreLockError = class extends Error {
|
|
23
|
+
path;
|
|
24
|
+
constructor(path, cause) {
|
|
25
|
+
super(`Could not acquire finding store lock: ${path}${cause ? ` (${cause})` : ""}`);
|
|
26
|
+
this.name = "FindingStoreLockError";
|
|
27
|
+
this.path = path;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function normalizeFingerprintTitle(title) {
|
|
31
|
+
return title.trim().toLowerCase().replace(/[^\w\s]/g, "").replace(/\s+/g, " ").trim();
|
|
32
|
+
}
|
|
33
|
+
function computeFindingFingerprint(file, line, title) {
|
|
34
|
+
const normalizedTitle = normalizeFingerprintTitle(title);
|
|
35
|
+
const normalizedFile = file.replace(/\\/g, "/").trim().toLowerCase();
|
|
36
|
+
const lineStr = line != null && line >= 0 ? String(line) : "0";
|
|
37
|
+
const hash = createHash("sha256");
|
|
38
|
+
hash.update(`${normalizedFile}:${lineStr}:${normalizedTitle}`);
|
|
39
|
+
return hash.digest("hex");
|
|
40
|
+
}
|
|
41
|
+
var TRANSITION_MATRIX = {
|
|
42
|
+
active: /* @__PURE__ */ new Set(["triaged", "ignored", "resolved"]),
|
|
43
|
+
triaged: /* @__PURE__ */ new Set(["in_progress", "ignored", "resolved"]),
|
|
44
|
+
in_progress: /* @__PURE__ */ new Set(["resolved", "active"]),
|
|
45
|
+
ignored: /* @__PURE__ */ new Set(["active"]),
|
|
46
|
+
resolved: /* @__PURE__ */ new Set(["active"])
|
|
47
|
+
};
|
|
48
|
+
function validateTransition(from, to) {
|
|
49
|
+
if (from === to) return;
|
|
50
|
+
const allowed = TRANSITION_MATRIX[from];
|
|
51
|
+
if (!allowed?.has(to)) {
|
|
52
|
+
throw new InvalidTransitionError(from, to);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function validateResolution(status, outcome) {
|
|
56
|
+
if (status !== "resolved") return;
|
|
57
|
+
if (!outcome) {
|
|
58
|
+
throw new InvalidTransitionError(
|
|
59
|
+
"active",
|
|
60
|
+
"resolved",
|
|
61
|
+
'A resolution outcome is required when transitioning to "resolved"'
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
FindingNotFoundError,
|
|
68
|
+
InvalidTransitionError,
|
|
69
|
+
FindingStoreLockError,
|
|
70
|
+
normalizeFingerprintTitle,
|
|
71
|
+
computeFindingFingerprint,
|
|
72
|
+
validateTransition,
|
|
73
|
+
validateResolution
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=chunk-UJILKYES.js.map
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// src/types/session-markers.ts
|
|
2
|
+
var SESSION_MARKER_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
3
|
+
"mode_changed",
|
|
4
|
+
"compaction",
|
|
5
|
+
"checkpoint",
|
|
6
|
+
"skill_activated",
|
|
7
|
+
"skill_deactivated",
|
|
8
|
+
"agent_spawned",
|
|
9
|
+
"agent_session_linked",
|
|
10
|
+
"agent_stopped",
|
|
11
|
+
"agent_error",
|
|
12
|
+
"delegate_started",
|
|
13
|
+
"delegate_completed",
|
|
14
|
+
"loop_detected",
|
|
15
|
+
"model_switched",
|
|
16
|
+
"error",
|
|
17
|
+
"provider_retry",
|
|
18
|
+
"provider_error",
|
|
19
|
+
"message_truncated"
|
|
20
|
+
]);
|
|
21
|
+
var CHAT_EXCLUDED_MARKER_SOURCES = /* @__PURE__ */ new Set([
|
|
22
|
+
"checkpoint",
|
|
23
|
+
"agent_spawned",
|
|
24
|
+
"agent_session_linked",
|
|
25
|
+
"agent_stopped",
|
|
26
|
+
"agent_error",
|
|
27
|
+
"delegate_started",
|
|
28
|
+
"delegate_completed"
|
|
29
|
+
]);
|
|
30
|
+
var CHAT_MARKER_SOURCES = new Set(
|
|
31
|
+
[...SESSION_MARKER_EVENT_TYPES].filter((type) => !CHAT_EXCLUDED_MARKER_SOURCES.has(type))
|
|
32
|
+
);
|
|
33
|
+
function sessionEventToMarker(ev) {
|
|
34
|
+
switch (ev.type) {
|
|
35
|
+
case "compaction": {
|
|
36
|
+
const before = (ev.before / 1e3).toFixed(0);
|
|
37
|
+
const after = (ev.after / 1e3).toFixed(0);
|
|
38
|
+
const level = ev.level ? ` (${ev.level})` : "";
|
|
39
|
+
const reductions = ev.reductions && ev.reductions.length > 0 ? ` [${ev.reductions.map((r) => `${r.phase}: \u2212${r.saved}`).join(", ")}]` : "";
|
|
40
|
+
return {
|
|
41
|
+
ts: ev.ts,
|
|
42
|
+
source: ev.type,
|
|
43
|
+
level: "info",
|
|
44
|
+
text: `\u27F2 context compacted${level}: ${before}K \u2192 ${after}K tokens${reductions}`
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
case "error":
|
|
48
|
+
return {
|
|
49
|
+
ts: ev.ts,
|
|
50
|
+
source: ev.type,
|
|
51
|
+
level: "error",
|
|
52
|
+
text: ev.phase ? `[${ev.phase}] ${ev.message}` : ev.message
|
|
53
|
+
};
|
|
54
|
+
case "provider_retry": {
|
|
55
|
+
const secs = (ev.delayMs / 1e3).toFixed(ev.delayMs >= 1e3 ? 1 : 2);
|
|
56
|
+
return {
|
|
57
|
+
ts: ev.ts,
|
|
58
|
+
source: ev.type,
|
|
59
|
+
level: "warn",
|
|
60
|
+
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}`
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
case "provider_error":
|
|
64
|
+
return {
|
|
65
|
+
ts: ev.ts,
|
|
66
|
+
source: ev.type,
|
|
67
|
+
level: "error",
|
|
68
|
+
text: ev.status ? `provider error (HTTP ${ev.status}, ${ev.retryable ? "retryable" : "fatal"}): ${ev.description}` : `provider error (${ev.retryable ? "retryable" : "fatal"}): ${ev.description}`
|
|
69
|
+
};
|
|
70
|
+
case "checkpoint":
|
|
71
|
+
return {
|
|
72
|
+
ts: ev.ts,
|
|
73
|
+
source: ev.type,
|
|
74
|
+
level: "info",
|
|
75
|
+
text: `\u2713 checkpoint #${ev.promptIndex}: "${ev.promptPreview.slice(0, 60)}"`
|
|
76
|
+
};
|
|
77
|
+
case "agent_spawned":
|
|
78
|
+
return {
|
|
79
|
+
ts: ev.ts,
|
|
80
|
+
source: ev.type,
|
|
81
|
+
level: "info",
|
|
82
|
+
text: `spawned as ${ev.role}`,
|
|
83
|
+
agentId: ev.agentId
|
|
84
|
+
};
|
|
85
|
+
case "agent_session_linked":
|
|
86
|
+
return {
|
|
87
|
+
ts: ev.ts,
|
|
88
|
+
source: ev.type,
|
|
89
|
+
level: "info",
|
|
90
|
+
// The transcript path is the point of the marker: it is how a reader
|
|
91
|
+
// of a resumed session gets from "this agent ran" to what it actually
|
|
92
|
+
// did. Falls back to the journal id when the writer had no file.
|
|
93
|
+
text: `transcript \u2192 ${ev.transcriptPath ?? ev.agentSessionId}`,
|
|
94
|
+
agentId: ev.agentId
|
|
95
|
+
};
|
|
96
|
+
case "agent_stopped":
|
|
97
|
+
return {
|
|
98
|
+
ts: ev.ts,
|
|
99
|
+
source: ev.type,
|
|
100
|
+
level: "info",
|
|
101
|
+
text: "stopped",
|
|
102
|
+
agentId: ev.agentId
|
|
103
|
+
};
|
|
104
|
+
case "delegate_started":
|
|
105
|
+
return {
|
|
106
|
+
ts: ev.ts,
|
|
107
|
+
source: ev.type,
|
|
108
|
+
level: "info",
|
|
109
|
+
text: `\u{1F91D} delegating \u2192 ${ev.target}: ${ev.task.length > 100 ? `${ev.task.slice(0, 99)}\u2026` : ev.task}`,
|
|
110
|
+
agentId: ev.subagentId,
|
|
111
|
+
detail: { kind: "delegate_started", target: ev.target, task: ev.task }
|
|
112
|
+
};
|
|
113
|
+
case "delegate_completed": {
|
|
114
|
+
const cost = ev.costUsd && ev.costUsd > 0 ? ` \xB7 $${ev.costUsd.toFixed(4)}` : "";
|
|
115
|
+
return {
|
|
116
|
+
ts: ev.ts,
|
|
117
|
+
source: ev.type,
|
|
118
|
+
level: ev.ok ? "info" : "error",
|
|
119
|
+
text: `${ev.ok ? "\u2705" : "\u274C"} ${ev.summary}${cost}`,
|
|
120
|
+
agentId: ev.subagentId,
|
|
121
|
+
detail: {
|
|
122
|
+
kind: "delegate_completed",
|
|
123
|
+
target: ev.target,
|
|
124
|
+
task: ev.task,
|
|
125
|
+
ok: ev.ok,
|
|
126
|
+
status: ev.status,
|
|
127
|
+
summary: ev.summary,
|
|
128
|
+
durationMs: ev.durationMs,
|
|
129
|
+
iterations: ev.iterations,
|
|
130
|
+
toolCalls: ev.toolCalls,
|
|
131
|
+
costUsd: ev.costUsd
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
case "loop_detected": {
|
|
136
|
+
const what = ev.kind === "message" ? "the same reply" : ev.tools ? `\`${ev.tools}\`` : "the same step";
|
|
137
|
+
return {
|
|
138
|
+
ts: ev.ts,
|
|
139
|
+
source: ev.type,
|
|
140
|
+
level: "warn",
|
|
141
|
+
text: ev.action === "steer" ? `\u{1F501} Loop detected \u2014 ${what} repeated ${ev.repeatCount}\xD7 ; the run was steered.` : `\u{1F501} Loop detected \u2014 ${what} repeated ${ev.repeatCount}\xD7 ; the run was stopped.`
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
case "model_switched": {
|
|
145
|
+
const to = `${ev.to.providerId}/${ev.to.model}`;
|
|
146
|
+
const from = ev.from ? `${ev.from.providerId}/${ev.from.model} \u2192 ` : "";
|
|
147
|
+
return {
|
|
148
|
+
ts: ev.ts,
|
|
149
|
+
source: ev.type,
|
|
150
|
+
level: ev.reason === "fallback" ? "warn" : "info",
|
|
151
|
+
text: ev.reason === "fallback" ? `\u26A0 fallback${ev.status ? ` (HTTP ${ev.status})` : ""}: ${from}${to}` : `model: ${from}${to}`
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
case "agent_error":
|
|
155
|
+
return {
|
|
156
|
+
ts: ev.ts,
|
|
157
|
+
source: ev.type,
|
|
158
|
+
level: "error",
|
|
159
|
+
text: `error: ${ev.error.slice(0, 80)}`,
|
|
160
|
+
agentId: ev.agentId
|
|
161
|
+
};
|
|
162
|
+
case "mode_changed":
|
|
163
|
+
return {
|
|
164
|
+
ts: ev.ts,
|
|
165
|
+
source: ev.type,
|
|
166
|
+
level: "info",
|
|
167
|
+
text: `mode: ${ev.from} \u2192 ${ev.to}`
|
|
168
|
+
};
|
|
169
|
+
case "skill_activated":
|
|
170
|
+
return {
|
|
171
|
+
ts: ev.ts,
|
|
172
|
+
source: ev.type,
|
|
173
|
+
level: "info",
|
|
174
|
+
text: `skill activated: ${ev.skillName}`
|
|
175
|
+
};
|
|
176
|
+
case "skill_deactivated":
|
|
177
|
+
return {
|
|
178
|
+
ts: ev.ts,
|
|
179
|
+
source: ev.type,
|
|
180
|
+
level: "info",
|
|
181
|
+
text: `skill deactivated: ${ev.skillName}`
|
|
182
|
+
};
|
|
183
|
+
case "message_truncated":
|
|
184
|
+
return {
|
|
185
|
+
ts: ev.ts,
|
|
186
|
+
source: ev.type,
|
|
187
|
+
level: "warn",
|
|
188
|
+
text: ev.after < ev.before ? `message truncated: ${ev.before} \u2192 ${ev.after} tokens` : `message truncated at ${ev.after} tokens`
|
|
189
|
+
};
|
|
190
|
+
default:
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function projectSessionMarkers(events, sources = SESSION_MARKER_EVENT_TYPES) {
|
|
195
|
+
const markers = [];
|
|
196
|
+
for (const ev of events) {
|
|
197
|
+
if (!sources.has(ev.type)) continue;
|
|
198
|
+
const marker = sessionEventToMarker(ev);
|
|
199
|
+
if (marker) markers.push(marker);
|
|
200
|
+
}
|
|
201
|
+
return markers;
|
|
202
|
+
}
|
|
203
|
+
var SYSTEM_INJECTION_PREFIXES = [
|
|
204
|
+
"[MAILBOX]",
|
|
205
|
+
"[MAILBOX BTW]",
|
|
206
|
+
"[BY THE WAY \u2014",
|
|
207
|
+
"[QUEUED MESSAGES \u2014",
|
|
208
|
+
"[FLEET PULSE]",
|
|
209
|
+
"[loop-detector]",
|
|
210
|
+
// Written by `compaction-elision.ts` in place of the tool history it
|
|
211
|
+
// elided — a note addressed to the MODEL about what it can no longer see.
|
|
212
|
+
// It was replaying as the first line of the transcript, so every resumed
|
|
213
|
+
// session opened with a machine-readable inventory of its own compaction
|
|
214
|
+
// instead of the user's first prompt.
|
|
215
|
+
"[tool_history_digest:",
|
|
216
|
+
"[session.resume] Request targeted session"
|
|
217
|
+
];
|
|
218
|
+
function isSystemInjectedMessage(text) {
|
|
219
|
+
const trimmed = text.trimStart();
|
|
220
|
+
for (const prefix of SYSTEM_INJECTION_PREFIXES) {
|
|
221
|
+
if (trimmed.startsWith(prefix)) return true;
|
|
222
|
+
}
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export {
|
|
227
|
+
SESSION_MARKER_EVENT_TYPES,
|
|
228
|
+
CHAT_MARKER_SOURCES,
|
|
229
|
+
sessionEventToMarker,
|
|
230
|
+
projectSessionMarkers,
|
|
231
|
+
SYSTEM_INJECTION_PREFIXES,
|
|
232
|
+
isSystemInjectedMessage
|
|
233
|
+
};
|
|
234
|
+
//# sourceMappingURL=chunk-ULMAQV3T.js.map
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toErrorMessage
|
|
3
|
+
} from "./chunk-TBRL2RCC.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/safe-json.ts
|
|
6
|
+
function safeParse(input, maxBytes = 5e6) {
|
|
7
|
+
if (Buffer.byteLength(input, "utf8") > maxBytes) {
|
|
8
|
+
return { ok: false, error: `Input exceeds limit (${maxBytes} bytes)` };
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
return { ok: true, value: JSON.parse(input) };
|
|
12
|
+
} catch (err) {
|
|
13
|
+
return {
|
|
14
|
+
ok: false,
|
|
15
|
+
error: toErrorMessage(err)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function safeStringify(value, pretty = false) {
|
|
20
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
21
|
+
const replacer = (_k, v) => {
|
|
22
|
+
if (typeof v === "bigint") return v.toString();
|
|
23
|
+
if (v instanceof Error) {
|
|
24
|
+
return { name: v.name, message: v.message, stack: v.stack };
|
|
25
|
+
}
|
|
26
|
+
if (typeof v === "object" && v !== null) {
|
|
27
|
+
if (seen.has(v)) return "[Circular]";
|
|
28
|
+
seen.add(v);
|
|
29
|
+
}
|
|
30
|
+
return v;
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
return JSON.stringify(value, replacer, pretty ? 2 : void 0) ?? "null";
|
|
34
|
+
} catch (err) {
|
|
35
|
+
return JSON.stringify({
|
|
36
|
+
__serialization_error: toErrorMessage(err)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function sanitizeJsonString(s) {
|
|
41
|
+
let out = s.trim();
|
|
42
|
+
out = stripJsonComments(out);
|
|
43
|
+
out = out.replace(/,(\s*[}\]])/g, "$1");
|
|
44
|
+
out = escapeControlCharsInStrings(out);
|
|
45
|
+
try {
|
|
46
|
+
JSON.parse(out);
|
|
47
|
+
return out;
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function stripCodeFences(s) {
|
|
53
|
+
const trimmed = s.trim();
|
|
54
|
+
const opener = /^```[\w+-]*[ \t]*\r?\n?/.exec(trimmed);
|
|
55
|
+
if (opener) {
|
|
56
|
+
const inner = trimmed.slice(opener[0].length).replace(/(\r?\n)?[ \t]*```[ \t]*$/, "");
|
|
57
|
+
return inner.trim();
|
|
58
|
+
}
|
|
59
|
+
const embedded = /```[\w+-]*[ \t]*\r?\n([\s\S]*?)\r?\n[ \t]*```/.exec(trimmed);
|
|
60
|
+
if (embedded) return (embedded[1] ?? "").trim();
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
function escapeControlCharsInStrings(s) {
|
|
64
|
+
let inString = false;
|
|
65
|
+
let escaped = false;
|
|
66
|
+
let out = "";
|
|
67
|
+
for (let i = 0; i < s.length; i++) {
|
|
68
|
+
const c = s.charAt(i);
|
|
69
|
+
if (inString) {
|
|
70
|
+
if (escaped) {
|
|
71
|
+
escaped = false;
|
|
72
|
+
out += c;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (c === "\\") {
|
|
76
|
+
escaped = true;
|
|
77
|
+
out += c;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (c === '"') {
|
|
81
|
+
inString = false;
|
|
82
|
+
out += c;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const code = c.charCodeAt(0);
|
|
86
|
+
if (code < 32) {
|
|
87
|
+
switch (c) {
|
|
88
|
+
case "\n":
|
|
89
|
+
out += "\\n";
|
|
90
|
+
break;
|
|
91
|
+
case "\r":
|
|
92
|
+
out += "\\r";
|
|
93
|
+
break;
|
|
94
|
+
case " ":
|
|
95
|
+
out += "\\t";
|
|
96
|
+
break;
|
|
97
|
+
case "\b":
|
|
98
|
+
out += "\\b";
|
|
99
|
+
break;
|
|
100
|
+
case "\f":
|
|
101
|
+
out += "\\f";
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
out += `\\u${code.toString(16).padStart(4, "0")}`;
|
|
105
|
+
}
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
out += c;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (c === '"') {
|
|
112
|
+
inString = true;
|
|
113
|
+
}
|
|
114
|
+
out += c;
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
function stripJsonComments(s) {
|
|
119
|
+
let inString = false;
|
|
120
|
+
let escaped = false;
|
|
121
|
+
const chars = [];
|
|
122
|
+
let i = 0;
|
|
123
|
+
while (i < s.length) {
|
|
124
|
+
const c = s.charAt(i);
|
|
125
|
+
if (inString) {
|
|
126
|
+
chars.push(c);
|
|
127
|
+
if (escaped) {
|
|
128
|
+
escaped = false;
|
|
129
|
+
} else if (c === "\\") {
|
|
130
|
+
escaped = true;
|
|
131
|
+
} else if (c === '"') {
|
|
132
|
+
inString = false;
|
|
133
|
+
}
|
|
134
|
+
i++;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (c === '"') {
|
|
138
|
+
inString = true;
|
|
139
|
+
chars.push(c);
|
|
140
|
+
i++;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (c === "/" && s.charAt(i + 1) === "/") {
|
|
144
|
+
while (i < s.length && s.charAt(i) !== "\n") i++;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (c === "/" && s.charAt(i + 1) === "*") {
|
|
148
|
+
const end = s.indexOf("*/", i + 2);
|
|
149
|
+
if (end === -1) {
|
|
150
|
+
chars.push(s.slice(i));
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
i = end + 2;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
chars.push(c);
|
|
157
|
+
i++;
|
|
158
|
+
}
|
|
159
|
+
return chars.join("");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export {
|
|
163
|
+
safeParse,
|
|
164
|
+
safeStringify,
|
|
165
|
+
sanitizeJsonString,
|
|
166
|
+
stripCodeFences
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=chunk-W5VITDM2.js.map
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import {
|
|
2
|
+
expectDefined
|
|
3
|
+
} from "./chunk-PFZO3C6H.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/glob-match.ts
|
|
6
|
+
function escapeRegex(s) {
|
|
7
|
+
return s.replace(/[.+^${}()|\\]/g, "\\$&");
|
|
8
|
+
}
|
|
9
|
+
var COMPILED_GLOB_CACHE = /* @__PURE__ */ new Map();
|
|
10
|
+
var CACHE_MAX_SIZE = 2e3;
|
|
11
|
+
var NEVER_MATCH = /[^\s\S]/;
|
|
12
|
+
var COMMAND_WILDCARD_STOP = ";&|\\n\\r`$<>";
|
|
13
|
+
function getCachedGlob(pattern, commandSubject = false) {
|
|
14
|
+
const cacheKey = commandSubject ? `cmd\0${pattern}` : pattern;
|
|
15
|
+
const cached = COMPILED_GLOB_CACHE.get(cacheKey);
|
|
16
|
+
if (cached) return cached;
|
|
17
|
+
if (COMPILED_GLOB_CACHE.size >= CACHE_MAX_SIZE) {
|
|
18
|
+
const keys = [...COMPILED_GLOB_CACHE.keys()];
|
|
19
|
+
for (let i = 0; i < Math.floor(CACHE_MAX_SIZE / 4); i++) {
|
|
20
|
+
COMPILED_GLOB_CACHE.delete(expectDefined(keys[i]));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
let re;
|
|
24
|
+
try {
|
|
25
|
+
re = compileGlob(pattern, commandSubject);
|
|
26
|
+
} catch {
|
|
27
|
+
re = NEVER_MATCH;
|
|
28
|
+
}
|
|
29
|
+
COMPILED_GLOB_CACHE.set(cacheKey, re);
|
|
30
|
+
return re;
|
|
31
|
+
}
|
|
32
|
+
var MAX_GLOB_PATTERN_LEN = 1024;
|
|
33
|
+
function compileGlob(pattern, commandSubject = false) {
|
|
34
|
+
if (pattern.length > MAX_GLOB_PATTERN_LEN) {
|
|
35
|
+
throw new Error(`Glob pattern exceeds ${MAX_GLOB_PATTERN_LEN} characters`);
|
|
36
|
+
}
|
|
37
|
+
const star = commandSubject ? `[^/${COMMAND_WILDCARD_STOP}]*` : "[^/]*";
|
|
38
|
+
const question = commandSubject ? `[^/${COMMAND_WILDCARD_STOP}]` : "[^/]";
|
|
39
|
+
let i = 0;
|
|
40
|
+
let re = "^";
|
|
41
|
+
while (i < pattern.length) {
|
|
42
|
+
const c = pattern[i];
|
|
43
|
+
if (c === "*") {
|
|
44
|
+
if (pattern[i + 1] === "*") {
|
|
45
|
+
re += commandSubject ? `[^${COMMAND_WILDCARD_STOP}]*` : ".*";
|
|
46
|
+
i += 2;
|
|
47
|
+
if (pattern[i] === "/") i++;
|
|
48
|
+
} else {
|
|
49
|
+
re += star;
|
|
50
|
+
i++;
|
|
51
|
+
}
|
|
52
|
+
} else if (c === "?") {
|
|
53
|
+
re += question;
|
|
54
|
+
i++;
|
|
55
|
+
} else if (c === "[") {
|
|
56
|
+
const closeIndex = pattern.indexOf("]", i + 1);
|
|
57
|
+
if (closeIndex === -1) {
|
|
58
|
+
re += "\\[";
|
|
59
|
+
i++;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
let cls = "[";
|
|
63
|
+
i++;
|
|
64
|
+
if (pattern[i] === "!" || pattern[i] === "^") {
|
|
65
|
+
cls += "^";
|
|
66
|
+
i++;
|
|
67
|
+
}
|
|
68
|
+
while (i < pattern.length && pattern[i] !== "]") {
|
|
69
|
+
const ch = pattern[i] ?? "";
|
|
70
|
+
if (ch === "\\") {
|
|
71
|
+
cls += "\\\\";
|
|
72
|
+
} else if (ch === "]" || ch === "^") {
|
|
73
|
+
cls += `\\${ch}`;
|
|
74
|
+
} else {
|
|
75
|
+
cls += ch;
|
|
76
|
+
}
|
|
77
|
+
i++;
|
|
78
|
+
}
|
|
79
|
+
cls += "]";
|
|
80
|
+
re += cls;
|
|
81
|
+
i++;
|
|
82
|
+
} else {
|
|
83
|
+
re += escapeRegex(c ?? "");
|
|
84
|
+
i++;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
re += "$";
|
|
88
|
+
return new RegExp(re);
|
|
89
|
+
}
|
|
90
|
+
function matchGlob(pattern, input) {
|
|
91
|
+
return getCachedGlob(pattern).test(input);
|
|
92
|
+
}
|
|
93
|
+
function matchAny(patterns, input) {
|
|
94
|
+
return patterns.some((p) => matchGlob(p, input));
|
|
95
|
+
}
|
|
96
|
+
function matchCommandGlob(pattern, input) {
|
|
97
|
+
return getCachedGlob(pattern, true).test(input);
|
|
98
|
+
}
|
|
99
|
+
function matchAnyCommand(patterns, input) {
|
|
100
|
+
return patterns.some((p) => matchCommandGlob(p, input));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/utils/tool-subject.ts
|
|
104
|
+
var GLOB_METACHARACTERS = /[*?[\]]/g;
|
|
105
|
+
function escapeGlobSubject(value) {
|
|
106
|
+
return value.replace(GLOB_METACHARACTERS, (char) => `\\${char}`);
|
|
107
|
+
}
|
|
108
|
+
function normalizePathSubject(value) {
|
|
109
|
+
return escapeGlobSubject(value.replace(/\\/g, "/"));
|
|
110
|
+
}
|
|
111
|
+
function isPathSubjectKey(subjectKey) {
|
|
112
|
+
return subjectKey === "path" || subjectKey === "file" || subjectKey === "files";
|
|
113
|
+
}
|
|
114
|
+
function renderCommandLine(command, args) {
|
|
115
|
+
if (!Array.isArray(args) || args.length === 0) return command;
|
|
116
|
+
const rendered = args.map((arg) => {
|
|
117
|
+
const str = String(arg);
|
|
118
|
+
return /\s/.test(str) ? `"${str.replace(/"/g, '\\"')}"` : str;
|
|
119
|
+
});
|
|
120
|
+
return [command, ...rendered].join(" ");
|
|
121
|
+
}
|
|
122
|
+
function renderSubjectFields(obj, fields) {
|
|
123
|
+
const parts = [];
|
|
124
|
+
for (const field of fields) {
|
|
125
|
+
const value = obj[field];
|
|
126
|
+
if (value === void 0 || value === null || value === "" || value === false) continue;
|
|
127
|
+
const str = String(value);
|
|
128
|
+
parts.push(`${field}=${/\s/.test(str) ? `"${str.replace(/"/g, '\\"')}"` : str}`);
|
|
129
|
+
}
|
|
130
|
+
return parts.join(" ");
|
|
131
|
+
}
|
|
132
|
+
function subjectForToolInput(toolName, input, subjectKey, subjectFields) {
|
|
133
|
+
if (!input || typeof input !== "object") return void 0;
|
|
134
|
+
const obj = input;
|
|
135
|
+
const extra = subjectFields && subjectFields.length > 0 ? renderSubjectFields(obj, subjectFields) : "";
|
|
136
|
+
const withExtra = (base) => extra ? `${base} ${extra}` : base;
|
|
137
|
+
if (subjectKey) {
|
|
138
|
+
const value = obj[subjectKey];
|
|
139
|
+
if (Array.isArray(value)) {
|
|
140
|
+
return escapeGlobSubject(JSON.stringify(value));
|
|
141
|
+
}
|
|
142
|
+
if (typeof value === "string") {
|
|
143
|
+
if (isPathSubjectKey(subjectKey)) {
|
|
144
|
+
const normalized = normalizePathSubject(value);
|
|
145
|
+
if (subjectKey === "files" && obj["check"] === true) return `${normalized}:check`;
|
|
146
|
+
if (subjectKey === "files" && obj["dry_run"] === true) return `${normalized}:dry-run`;
|
|
147
|
+
return normalized;
|
|
148
|
+
}
|
|
149
|
+
if (subjectKey === "command") {
|
|
150
|
+
const rendered = renderCommandLine(value, obj["args"]);
|
|
151
|
+
if (value === "commit" && obj["dry_run"] === true) {
|
|
152
|
+
return `${escapeGlobSubject(withExtra(rendered))}:dry-run`;
|
|
153
|
+
}
|
|
154
|
+
return escapeGlobSubject(withExtra(rendered));
|
|
155
|
+
}
|
|
156
|
+
if (subjectKey === "directory" && obj["dry_run"] === true) {
|
|
157
|
+
return `${escapeGlobSubject(value)}:dry-run`;
|
|
158
|
+
}
|
|
159
|
+
if (subjectKey === "packages" && obj["dry_run"] === true) {
|
|
160
|
+
return `${escapeGlobSubject(value)}:dry-run`;
|
|
161
|
+
}
|
|
162
|
+
if (subjectKey === "name" && obj["dry_run"] === true) {
|
|
163
|
+
return `${escapeGlobSubject(value)}:dry-run`;
|
|
164
|
+
}
|
|
165
|
+
return escapeGlobSubject(value);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (toolName === "bash" && typeof obj.command === "string") {
|
|
169
|
+
return escapeGlobSubject(obj.command);
|
|
170
|
+
}
|
|
171
|
+
if (typeof obj.path === "string") {
|
|
172
|
+
return normalizePathSubject(obj.path);
|
|
173
|
+
}
|
|
174
|
+
if (typeof obj.url === "string") {
|
|
175
|
+
return escapeGlobSubject(obj.url);
|
|
176
|
+
}
|
|
177
|
+
if (typeof obj.name === "string") {
|
|
178
|
+
return escapeGlobSubject(obj.name);
|
|
179
|
+
}
|
|
180
|
+
return void 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export {
|
|
184
|
+
compileGlob,
|
|
185
|
+
matchGlob,
|
|
186
|
+
matchAny,
|
|
187
|
+
matchCommandGlob,
|
|
188
|
+
matchAnyCommand,
|
|
189
|
+
escapeGlobSubject,
|
|
190
|
+
normalizePathSubject,
|
|
191
|
+
isPathSubjectKey,
|
|
192
|
+
subjectForToolInput
|
|
193
|
+
};
|
|
194
|
+
//# sourceMappingURL=chunk-WAHQVNWT.js.map
|