@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,45 @@
|
|
|
1
|
+
// src/types/prompt.ts
|
|
2
|
+
var BUILTIN_PROMPT_CATEGORIES = [
|
|
3
|
+
"coding",
|
|
4
|
+
"debugging",
|
|
5
|
+
"refactoring",
|
|
6
|
+
"testing",
|
|
7
|
+
"code-review",
|
|
8
|
+
"architecture",
|
|
9
|
+
"devops",
|
|
10
|
+
"documentation",
|
|
11
|
+
"data-analysis",
|
|
12
|
+
"writing",
|
|
13
|
+
"research",
|
|
14
|
+
"product",
|
|
15
|
+
"agentic-workflows",
|
|
16
|
+
"meta-prompting",
|
|
17
|
+
"uncategorized"
|
|
18
|
+
];
|
|
19
|
+
var PROMPT_CATEGORY_LABELS = {
|
|
20
|
+
coding: "Coding",
|
|
21
|
+
debugging: "Debugging",
|
|
22
|
+
refactoring: "Refactoring",
|
|
23
|
+
testing: "Testing",
|
|
24
|
+
"code-review": "Code Review",
|
|
25
|
+
architecture: "Architecture",
|
|
26
|
+
devops: "DevOps",
|
|
27
|
+
documentation: "Documentation",
|
|
28
|
+
"data-analysis": "Data Analysis",
|
|
29
|
+
writing: "Writing",
|
|
30
|
+
research: "Research",
|
|
31
|
+
product: "Product",
|
|
32
|
+
"agentic-workflows": "Agentic Workflows",
|
|
33
|
+
"meta-prompting": "Meta-Prompting",
|
|
34
|
+
uncategorized: "Uncategorized"
|
|
35
|
+
};
|
|
36
|
+
function isBuiltinCategory(value) {
|
|
37
|
+
return BUILTIN_PROMPT_CATEGORIES.includes(value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
BUILTIN_PROMPT_CATEGORIES,
|
|
42
|
+
PROMPT_CATEGORY_LABELS,
|
|
43
|
+
isBuiltinCategory
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=chunk-KDQJCT2J.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/types/config/runtime.ts
|
|
2
|
+
function normalizeTokenSavingTier(val) {
|
|
3
|
+
if (val === void 0) return "off";
|
|
4
|
+
if (typeof val === "boolean") return val ? "medium" : "off";
|
|
5
|
+
if (val === "auto") return "medium";
|
|
6
|
+
const validTiers = /* @__PURE__ */ new Set([
|
|
7
|
+
"off",
|
|
8
|
+
"minimal",
|
|
9
|
+
"light",
|
|
10
|
+
"medium",
|
|
11
|
+
"aggressive"
|
|
12
|
+
]);
|
|
13
|
+
return validTiers.has(val) ? val : "off";
|
|
14
|
+
}
|
|
15
|
+
function resolveTokenSavingTier(val, maxContext) {
|
|
16
|
+
if (val === "auto") {
|
|
17
|
+
if (typeof maxContext !== "number" || !Number.isFinite(maxContext) || maxContext <= 0) {
|
|
18
|
+
return "off";
|
|
19
|
+
}
|
|
20
|
+
if (maxContext < 32e3) return "medium";
|
|
21
|
+
if (maxContext < 128e3) return "light";
|
|
22
|
+
return "minimal";
|
|
23
|
+
}
|
|
24
|
+
return normalizeTokenSavingTier(val);
|
|
25
|
+
}
|
|
26
|
+
var DEFAULT_TUI_THINKING_WORD = "thinking";
|
|
27
|
+
var MAX_TUI_THINKING_WORD_LENGTH = 16;
|
|
28
|
+
var MAX_WRONGPROXY_URL_LENGTH = 2048;
|
|
29
|
+
function normalizeTuiThinkingWord(value) {
|
|
30
|
+
if (typeof value !== "string") return DEFAULT_TUI_THINKING_WORD;
|
|
31
|
+
const word = value.trim();
|
|
32
|
+
if (word.length === 0 || word.length > MAX_TUI_THINKING_WORD_LENGTH) {
|
|
33
|
+
return DEFAULT_TUI_THINKING_WORD;
|
|
34
|
+
}
|
|
35
|
+
if (!/^[\p{L}\p{N}_-]+$/u.test(word)) return DEFAULT_TUI_THINKING_WORD;
|
|
36
|
+
return word;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
normalizeTokenSavingTier,
|
|
41
|
+
resolveTokenSavingTier,
|
|
42
|
+
DEFAULT_TUI_THINKING_WORD,
|
|
43
|
+
MAX_TUI_THINKING_WORD_LENGTH,
|
|
44
|
+
MAX_WRONGPROXY_URL_LENGTH,
|
|
45
|
+
normalizeTuiThinkingWord
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=chunk-KJ2ZTQSL.js.map
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ERROR_CODES,
|
|
3
|
+
WrongStackError
|
|
4
|
+
} from "./chunk-25LSLC3G.js";
|
|
5
|
+
|
|
6
|
+
// src/kernel/container.ts
|
|
7
|
+
var Container = class {
|
|
8
|
+
entries = /* @__PURE__ */ new Map();
|
|
9
|
+
/**
|
|
10
|
+
* Tokens currently mid-resolve. Tracked so we can detect circular
|
|
11
|
+
* dependencies (A → B → A) and throw a structured error instead of
|
|
12
|
+
* overflowing the call stack with "Maximum call stack size exceeded".
|
|
13
|
+
*
|
|
14
|
+
* Not a memoization cache — the per-entry `cache` field is the source
|
|
15
|
+
* of truth for "have I built this before?". This set only lives for
|
|
16
|
+
* the duration of a single resolve call.
|
|
17
|
+
*/
|
|
18
|
+
resolving = /* @__PURE__ */ new Set();
|
|
19
|
+
bind(token, factory, opts = {}) {
|
|
20
|
+
if (this.entries.has(token)) {
|
|
21
|
+
throw new WrongStackError({
|
|
22
|
+
message: `Container: token "${token.description ?? "unknown"}" already bound`,
|
|
23
|
+
code: ERROR_CODES.CONTAINER_TOKEN_ALREADY_BOUND,
|
|
24
|
+
subsystem: "container",
|
|
25
|
+
context: { token: token.description }
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
this.entries.set(token, {
|
|
29
|
+
factory,
|
|
30
|
+
singleton: opts.singleton ?? true,
|
|
31
|
+
decorators: [],
|
|
32
|
+
hasCache: false,
|
|
33
|
+
owner: opts.owner ?? "core"
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
override(token, factory, opts = {}) {
|
|
37
|
+
const existing = this.entries.get(token);
|
|
38
|
+
if (!existing) {
|
|
39
|
+
throw new WrongStackError({
|
|
40
|
+
message: `Container: cannot override "${token.description ?? "unknown"}" \u2014 not bound`,
|
|
41
|
+
code: ERROR_CODES.CONTAINER_TOKEN_NOT_BOUND,
|
|
42
|
+
subsystem: "container",
|
|
43
|
+
context: { token: token.description }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
this.entries.set(token, {
|
|
47
|
+
factory,
|
|
48
|
+
singleton: opts.singleton ?? existing.singleton,
|
|
49
|
+
decorators: existing.decorators,
|
|
50
|
+
hasCache: false,
|
|
51
|
+
owner: opts.owner ?? existing.owner
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
decorate(token, decorator, owner = "core") {
|
|
55
|
+
const existing = this.entries.get(token);
|
|
56
|
+
if (!existing) {
|
|
57
|
+
throw new WrongStackError({
|
|
58
|
+
message: `Container: cannot decorate "${token.description ?? "unknown"}" \u2014 not bound`,
|
|
59
|
+
code: ERROR_CODES.CONTAINER_TOKEN_NOT_BOUND,
|
|
60
|
+
subsystem: "container",
|
|
61
|
+
context: { token: token.description }
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
existing.decorators.push(decorator);
|
|
65
|
+
existing.cache = void 0;
|
|
66
|
+
existing.hasCache = false;
|
|
67
|
+
existing.owner = `${existing.owner}+${owner}`;
|
|
68
|
+
}
|
|
69
|
+
resolve(token) {
|
|
70
|
+
const entry = this.entries.get(token);
|
|
71
|
+
if (!entry) {
|
|
72
|
+
throw new WrongStackError({
|
|
73
|
+
message: `Container: token "${token.description ?? "unknown"}" not bound`,
|
|
74
|
+
code: ERROR_CODES.CONTAINER_TOKEN_NOT_BOUND,
|
|
75
|
+
subsystem: "container",
|
|
76
|
+
context: { token: token.description }
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (entry.singleton && entry.hasCache) {
|
|
80
|
+
return entry.cache;
|
|
81
|
+
}
|
|
82
|
+
if (this.resolving.has(token)) {
|
|
83
|
+
const cycle = this.describeCycle(token);
|
|
84
|
+
throw new WrongStackError({
|
|
85
|
+
message: `Container: circular dependency detected \u2014 ${cycle}`,
|
|
86
|
+
code: ERROR_CODES.CONTAINER_CIRCULAR_DEPENDENCY,
|
|
87
|
+
subsystem: "container",
|
|
88
|
+
context: { token: token.description, cycle }
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
this.resolving.add(token);
|
|
92
|
+
try {
|
|
93
|
+
let value = entry.factory(this);
|
|
94
|
+
for (const d of entry.decorators) {
|
|
95
|
+
value = d(value, this);
|
|
96
|
+
}
|
|
97
|
+
if (entry.singleton) {
|
|
98
|
+
entry.cache = value;
|
|
99
|
+
entry.hasCache = true;
|
|
100
|
+
}
|
|
101
|
+
return value;
|
|
102
|
+
} finally {
|
|
103
|
+
this.resolving.delete(token);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Build a human-readable description of the dependency cycle that
|
|
108
|
+
* caused the resolution to re-enter. Lists the tokens in the order
|
|
109
|
+
* they were entered, then appends the re-entered token to close the
|
|
110
|
+
* loop. Falls back to a generic message if the resolving set is
|
|
111
|
+
* somehow empty (shouldn't happen, but defensive).
|
|
112
|
+
*/
|
|
113
|
+
describeCycle(reentry) {
|
|
114
|
+
const descs = [];
|
|
115
|
+
const seen = /* @__PURE__ */ new Set();
|
|
116
|
+
for (const t of this.resolving) {
|
|
117
|
+
if (seen.has(t)) continue;
|
|
118
|
+
seen.add(t);
|
|
119
|
+
descs.push(t.description ?? "unknown");
|
|
120
|
+
}
|
|
121
|
+
descs.push(reentry.description ?? "unknown");
|
|
122
|
+
return descs.join(" \u2192 ");
|
|
123
|
+
}
|
|
124
|
+
has(token) {
|
|
125
|
+
return this.entries.has(token);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Resolve a token if it is bound, otherwise return undefined.
|
|
129
|
+
* Unlike `resolve()`, this does not throw if the token is unbound.
|
|
130
|
+
*
|
|
131
|
+
* Single map lookup — `has()` + `resolve()` would walk the entries
|
|
132
|
+
* map twice. The bound check is folded into the resolve path so a
|
|
133
|
+
* non-existent token can never enter the `resolving` cycle-detection
|
|
134
|
+
* set.
|
|
135
|
+
*/
|
|
136
|
+
safeResolve(token) {
|
|
137
|
+
if (!this.entries.has(token)) return void 0;
|
|
138
|
+
return this.resolve(token);
|
|
139
|
+
}
|
|
140
|
+
ownerOf(token) {
|
|
141
|
+
return this.entries.get(token)?.owner;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Remove a token's binding (along with any decorators stacked on it).
|
|
145
|
+
* Returns true if the token existed. Use this to withdraw temporary
|
|
146
|
+
* bindings installed by a short-lived run or plugin — without it, the
|
|
147
|
+
* entry persists in the map forever.
|
|
148
|
+
*/
|
|
149
|
+
unbind(token) {
|
|
150
|
+
return this.entries.delete(token);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Drop every binding. Intended for tests and short-lived CLI invocations
|
|
154
|
+
* that rebuild the container from scratch. Production code should prefer
|
|
155
|
+
* `unbind` on the specific tokens it owns.
|
|
156
|
+
*/
|
|
157
|
+
clear() {
|
|
158
|
+
this.entries.clear();
|
|
159
|
+
}
|
|
160
|
+
list() {
|
|
161
|
+
return Array.from(this.entries.entries()).map(([token, entry]) => ({
|
|
162
|
+
token,
|
|
163
|
+
owner: entry.owner
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Inspect a binding's full shape, including decorator count and whether
|
|
168
|
+
* a singleton value is cached. Returns null if the token is unbound.
|
|
169
|
+
* Decorator and factory function references are not exposed — only counts
|
|
170
|
+
* and metadata, to keep internal state hidden.
|
|
171
|
+
*/
|
|
172
|
+
inspect(token) {
|
|
173
|
+
const entry = this.entries.get(token);
|
|
174
|
+
if (!entry) return null;
|
|
175
|
+
return {
|
|
176
|
+
owner: entry.owner,
|
|
177
|
+
singleton: entry.singleton,
|
|
178
|
+
decoratorCount: entry.decorators.length,
|
|
179
|
+
cached: entry.hasCache
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
Container
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=chunk-KZMSZV32.js.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// src/utils/ip-guard.ts
|
|
2
|
+
import * as dns from "node:dns/promises";
|
|
3
|
+
import * as net from "node:net";
|
|
4
|
+
function isPrivateIPv4(addr) {
|
|
5
|
+
const parts = addr.split(".").map((p) => {
|
|
6
|
+
if (!/^\d+$/.test(p)) return Number.NaN;
|
|
7
|
+
if (p.length > 1 && p.startsWith("0")) return Number.NaN;
|
|
8
|
+
return Number.parseInt(p, 10);
|
|
9
|
+
});
|
|
10
|
+
if (parts.length !== 4 || parts.some((n) => Number.isNaN(n) || n < 0 || n > 255)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
const [a, b, c] = parts;
|
|
14
|
+
if (a === 0) return true;
|
|
15
|
+
if (a === 10) return true;
|
|
16
|
+
if (a === 127) return true;
|
|
17
|
+
if (a === 169 && b === 254) return true;
|
|
18
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
19
|
+
if (a === 192 && b === 168) return true;
|
|
20
|
+
if (a === 192 && b === 0 && c === 0) return true;
|
|
21
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
22
|
+
if (a >= 224) return true;
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
function isPrivateIPv6(raw) {
|
|
26
|
+
const lower = raw.toLowerCase();
|
|
27
|
+
if (lower === "::" || lower === "::1") return true;
|
|
28
|
+
const groups = expandIPv6(lower);
|
|
29
|
+
if (!groups) return true;
|
|
30
|
+
if (groups[0] === 100 && groups[1] === 65435 && groups[2] === 1) return true;
|
|
31
|
+
if (groups[0] === 0 && groups[1] === 0 && groups[2] === 0 && groups[3] === 0 && groups[4] === 0 && groups[5] === 65535) {
|
|
32
|
+
const a = (groups[6] ?? 0) >> 8;
|
|
33
|
+
const b = (groups[6] ?? 0) & 255;
|
|
34
|
+
const c = (groups[7] ?? 0) >> 8;
|
|
35
|
+
const d = (groups[7] ?? 0) & 255;
|
|
36
|
+
return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
|
|
37
|
+
}
|
|
38
|
+
const embedded = embeddedIPv4(groups);
|
|
39
|
+
if (embedded) return isPrivateIPv4(embedded);
|
|
40
|
+
const high = groups[0] ?? 0;
|
|
41
|
+
if ((high & 65024) === 64512) return true;
|
|
42
|
+
if ((high & 65472) === 65152) return true;
|
|
43
|
+
if ((high & 65280) === 65280) return true;
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
function quad(hi, lo) {
|
|
47
|
+
return `${(hi ?? 0) >> 8}.${(hi ?? 0) & 255}.${(lo ?? 0) >> 8}.${(lo ?? 0) & 255}`;
|
|
48
|
+
}
|
|
49
|
+
function embeddedIPv4(groups) {
|
|
50
|
+
const g = (i) => groups[i] ?? 0;
|
|
51
|
+
if (g(0) === 100 && g(1) === 65435) {
|
|
52
|
+
if (g(2) === 0 && g(3) === 0 && g(4) === 0 && g(5) === 0) {
|
|
53
|
+
return quad(g(6), g(7));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (g(0) === 8194) return quad(g(1), g(2));
|
|
57
|
+
if (g(0) === 8193 && g(1) === 0) {
|
|
58
|
+
return quad(~g(6) & 65535, ~g(7) & 65535);
|
|
59
|
+
}
|
|
60
|
+
if ((g(4) === 0 || g(4) === 512) && g(5) === 24318) {
|
|
61
|
+
return quad(g(6), g(7));
|
|
62
|
+
}
|
|
63
|
+
const highZero = g(0) === 0 && g(1) === 0 && g(2) === 0 && g(3) === 0;
|
|
64
|
+
if (highZero && g(4) === 65535 && g(5) === 0) return quad(g(6), g(7));
|
|
65
|
+
if (highZero && g(4) === 0 && g(5) === 0) return quad(g(6), g(7));
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
function expandIPv6(addr) {
|
|
69
|
+
const parts = addr.split("::");
|
|
70
|
+
if (parts.length > 2) return null;
|
|
71
|
+
const parseGroups = (s) => {
|
|
72
|
+
if (s === "") return [];
|
|
73
|
+
const out = [];
|
|
74
|
+
for (const g of s.split(":")) {
|
|
75
|
+
if (g.length === 0 || g.length > 4) return null;
|
|
76
|
+
const n = Number.parseInt(g, 16);
|
|
77
|
+
if (Number.isNaN(n) || n < 0 || n > 65535) return null;
|
|
78
|
+
out.push(n);
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
};
|
|
82
|
+
if (parts.length === 1) {
|
|
83
|
+
const groups = parseGroups(parts[0] ?? "");
|
|
84
|
+
if (groups?.length !== 8) return null;
|
|
85
|
+
return groups;
|
|
86
|
+
}
|
|
87
|
+
const head = parseGroups(parts[0] ?? "");
|
|
88
|
+
const tail = parseGroups(parts[1] ?? "");
|
|
89
|
+
if (!head || !tail) return null;
|
|
90
|
+
const fill = 8 - head.length - tail.length;
|
|
91
|
+
if (fill < 0) return null;
|
|
92
|
+
return [...head, ...new Array(fill).fill(0), ...tail];
|
|
93
|
+
}
|
|
94
|
+
async function assertNotPrivateHost(hostname) {
|
|
95
|
+
const host = hostname.startsWith("[") && hostname.endsWith("]") ? hostname.slice(1, -1) : hostname;
|
|
96
|
+
if (host === "localhost" || host.endsWith(".localhost")) {
|
|
97
|
+
throw new Error("fetch: blocked localhost target");
|
|
98
|
+
}
|
|
99
|
+
const ipVersion = net.isIP(host);
|
|
100
|
+
if (ipVersion === 4) {
|
|
101
|
+
if (isPrivateIPv4(host)) {
|
|
102
|
+
throw new Error(`fetch: blocked private/loopback address "${host}"`);
|
|
103
|
+
}
|
|
104
|
+
} else if (ipVersion === 6) {
|
|
105
|
+
if (isPrivateIPv6(host)) {
|
|
106
|
+
throw new Error(`fetch: blocked private/loopback address "${host}"`);
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
try {
|
|
110
|
+
const records = await dns.lookup(host, { all: true });
|
|
111
|
+
for (const r of records) {
|
|
112
|
+
const bad = r.family === 4 ? isPrivateIPv4(r.address) : isPrivateIPv6(r.address);
|
|
113
|
+
if (bad) {
|
|
114
|
+
throw new Error(`fetch: resolved to private address ${r.address}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} catch (err) {
|
|
118
|
+
if (err instanceof Error && err.message.startsWith("fetch:")) throw err;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export {
|
|
124
|
+
isPrivateIPv4,
|
|
125
|
+
isPrivateIPv6,
|
|
126
|
+
expandIPv6,
|
|
127
|
+
assertNotPrivateHost
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=chunk-LA7CLDRW.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/utils/win32-cmd.ts
|
|
2
|
+
var WIN32_CMD_META = /[&|<>"%\r\n\0]/;
|
|
3
|
+
function buildWin32CmdShimInvocation(command, args = []) {
|
|
4
|
+
assertSafeWin32CmdArgs([command, ...args]);
|
|
5
|
+
const line = ["call", quoteWin32CmdArg(command), ...args.map(quoteWin32CmdArg)].join(" ");
|
|
6
|
+
return {
|
|
7
|
+
command: process.env["COMSPEC"] ?? "cmd.exe",
|
|
8
|
+
args: ["/d", "/c", line],
|
|
9
|
+
windowsVerbatimArguments: true
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function assertSafeWin32CmdArgs(args) {
|
|
13
|
+
for (const arg of args) {
|
|
14
|
+
if (typeof arg === "string" && WIN32_CMD_META.test(arg)) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
'win32 cmd shim spawn: argument contains a shell metacharacter (one of & | < > ", or a newline) that could enable command injection through the .cmd/.bat wrapper - refusing to run. Offending argument: ' + JSON.stringify(arg)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function quoteWin32CmdArg(arg) {
|
|
22
|
+
return `"${arg}"`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
buildWin32CmdShimInvocation
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=chunk-LHOA5DWA.js.map
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
expectDefined
|
|
3
|
+
} from "./chunk-PFZO3C6H.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/message-invariants.ts
|
|
6
|
+
function repairToolUseAdjacency(messages, opts = {}) {
|
|
7
|
+
const removedToolUses = [];
|
|
8
|
+
const removedToolResults = [];
|
|
9
|
+
let removedMessages = 0;
|
|
10
|
+
let changed = false;
|
|
11
|
+
const out = [];
|
|
12
|
+
for (let i = 0; i < messages.length; i++) {
|
|
13
|
+
const original = expectDefined(messages[i]);
|
|
14
|
+
let msg = original;
|
|
15
|
+
if (hasToolUse(msg)) {
|
|
16
|
+
const nextIds = toolResultIds(messages[i + 1]);
|
|
17
|
+
const filtered = mapContent(msg, (blocks) => {
|
|
18
|
+
const next = [];
|
|
19
|
+
for (const block of blocks) {
|
|
20
|
+
const preserveTrailing = opts.preserveTrailingToolUse === true && i === messages.length - 1 && block.type === "tool_use";
|
|
21
|
+
if (block.type === "tool_use" && !nextIds.has(block.id) && !preserveTrailing) {
|
|
22
|
+
removedToolUses.push(block.id);
|
|
23
|
+
changed = true;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
next.push(block);
|
|
27
|
+
}
|
|
28
|
+
return next;
|
|
29
|
+
});
|
|
30
|
+
msg = filtered ?? msg;
|
|
31
|
+
}
|
|
32
|
+
if (hasToolResult(msg)) {
|
|
33
|
+
const allowed = toolUseIds(out[out.length - 1]);
|
|
34
|
+
const filtered = mapContent(msg, (blocks) => {
|
|
35
|
+
const next = [];
|
|
36
|
+
for (const block of blocks) {
|
|
37
|
+
if (block.type === "tool_result" && !allowed.has(block.tool_use_id)) {
|
|
38
|
+
removedToolResults.push(block.tool_use_id);
|
|
39
|
+
changed = true;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
next.push(block);
|
|
43
|
+
}
|
|
44
|
+
return next;
|
|
45
|
+
});
|
|
46
|
+
msg = filtered ?? msg;
|
|
47
|
+
}
|
|
48
|
+
if (isEmptyMessage(msg)) {
|
|
49
|
+
removedMessages++;
|
|
50
|
+
changed = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
out.push(msg);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
messages: changed ? out : messages,
|
|
57
|
+
report: { changed, removedToolUses, removedToolResults, removedMessages }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function hasToolUse(msg) {
|
|
61
|
+
return contentBlocks(msg).some((b) => b.type === "tool_use");
|
|
62
|
+
}
|
|
63
|
+
function hasToolResult(msg) {
|
|
64
|
+
return contentBlocks(msg).some((b) => b.type === "tool_result");
|
|
65
|
+
}
|
|
66
|
+
function toolUseIds(msg) {
|
|
67
|
+
const ids = /* @__PURE__ */ new Set();
|
|
68
|
+
if (msg?.role !== "assistant") return ids;
|
|
69
|
+
for (const block of contentBlocks(msg)) {
|
|
70
|
+
if (block.type === "tool_use") ids.add(block.id);
|
|
71
|
+
}
|
|
72
|
+
return ids;
|
|
73
|
+
}
|
|
74
|
+
function toolResultIds(msg) {
|
|
75
|
+
const ids = /* @__PURE__ */ new Set();
|
|
76
|
+
if (msg?.role !== "user") return ids;
|
|
77
|
+
for (const block of contentBlocks(msg)) {
|
|
78
|
+
if (block.type === "tool_result") ids.add(block.tool_use_id);
|
|
79
|
+
}
|
|
80
|
+
return ids;
|
|
81
|
+
}
|
|
82
|
+
function contentBlocks(msg) {
|
|
83
|
+
return msg && Array.isArray(msg.content) ? msg.content : [];
|
|
84
|
+
}
|
|
85
|
+
function mapContent(msg, fn) {
|
|
86
|
+
if (!Array.isArray(msg.content)) return msg;
|
|
87
|
+
const next = fn(msg.content);
|
|
88
|
+
if (next.length === msg.content.length && next.every((b, idx) => b === msg.content[idx])) {
|
|
89
|
+
return msg;
|
|
90
|
+
}
|
|
91
|
+
return { ...msg, content: next };
|
|
92
|
+
}
|
|
93
|
+
function hasMeaningfulContent(content) {
|
|
94
|
+
if (!content) return false;
|
|
95
|
+
if (typeof content === "string") return content.trim().length > 0;
|
|
96
|
+
if (!Array.isArray(content)) return false;
|
|
97
|
+
for (const block of content) {
|
|
98
|
+
if (!block || typeof block !== "object") continue;
|
|
99
|
+
if (block.type === "text") {
|
|
100
|
+
if (block.text.trim().length > 0) return true;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (block.type === "thinking") {
|
|
104
|
+
if (block.thinking.trim().length > 0 || block.signature) return true;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
function isEmptyMessage(msg) {
|
|
112
|
+
return !hasMeaningfulContent(msg.content);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
repairToolUseAdjacency,
|
|
117
|
+
hasMeaningfulContent
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=chunk-LSMMOS2Z.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/utils/sqlite-warning.ts
|
|
2
|
+
var SQLITE_EXPERIMENTAL_WARNING_RE = /sqlite is an experimental feature/i;
|
|
3
|
+
function isSqliteExperimentalWarning(warning, rest) {
|
|
4
|
+
const message = typeof warning === "string" ? warning : warning instanceof Error ? warning.message : "";
|
|
5
|
+
const typeOrOptions = rest[0];
|
|
6
|
+
const warningType = typeof warning === "string" ? typeof typeOrOptions === "string" ? typeOrOptions : typeof typeOrOptions === "object" && typeOrOptions !== null && "type" in typeOrOptions && typeof typeOrOptions.type === "string" ? typeOrOptions.type : "" : warning instanceof Error ? warning.name : "";
|
|
7
|
+
const warningCode = typeof warning === "string" ? typeof typeOrOptions === "object" && typeOrOptions !== null && "code" in typeOrOptions && typeof typeOrOptions.code === "string" ? typeOrOptions.code : typeof rest[1] === "string" ? rest[1] : "" : warning instanceof Error && "code" in warning && typeof warning.code === "string" ? warning.code : "";
|
|
8
|
+
return SQLITE_EXPERIMENTAL_WARNING_RE.test(message) && (warningType === "ExperimentalWarning" || warningCode === "ExperimentalWarning");
|
|
9
|
+
}
|
|
10
|
+
function withSqliteExperimentalWarningSuppressed(run) {
|
|
11
|
+
const originalEmitWarning = process.emitWarning;
|
|
12
|
+
const forwardWarning = originalEmitWarning.bind(process);
|
|
13
|
+
process.emitWarning = ((warning, ...rest) => {
|
|
14
|
+
if (isSqliteExperimentalWarning(warning, rest)) return;
|
|
15
|
+
forwardWarning(warning, ...rest);
|
|
16
|
+
});
|
|
17
|
+
try {
|
|
18
|
+
return run();
|
|
19
|
+
} finally {
|
|
20
|
+
process.emitWarning = originalEmitWarning;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
withSqliteExperimentalWarningSuppressed
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-LX5QWLBL.js.map
|