@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,14 @@
|
|
|
1
|
+
// src/utils/expect-defined.ts
|
|
2
|
+
function expectDefined(value, label) {
|
|
3
|
+
if (value === null || value === void 0) {
|
|
4
|
+
const err = new Error(label ? `Expected ${label} to be defined` : "Expected value to be defined");
|
|
5
|
+
err.name = "ExpectDefinedError";
|
|
6
|
+
throw err;
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
expectDefined
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-PFZO3C6H.js.map
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {
|
|
2
|
+
slugify
|
|
3
|
+
} from "./chunk-J2WRWR37.js";
|
|
4
|
+
import {
|
|
5
|
+
ulid
|
|
6
|
+
} from "./chunk-HI3JGZR2.js";
|
|
7
|
+
import {
|
|
8
|
+
atomicWrite,
|
|
9
|
+
ensureDir
|
|
10
|
+
} from "./chunk-OSGLYW5J.js";
|
|
11
|
+
|
|
12
|
+
// src/storage/prompt-store.ts
|
|
13
|
+
import { createHash } from "node:crypto";
|
|
14
|
+
import * as fs from "node:fs/promises";
|
|
15
|
+
import * as path from "node:path";
|
|
16
|
+
var SCHEMA_VERSION = 2;
|
|
17
|
+
function promptChecksum(content) {
|
|
18
|
+
return createHash("sha256").update(content, "utf8").digest("hex");
|
|
19
|
+
}
|
|
20
|
+
function migratePromptEntry(raw) {
|
|
21
|
+
if (!raw || typeof raw !== "object") return null;
|
|
22
|
+
const r = raw;
|
|
23
|
+
if (typeof r["id"] !== "string" || typeof r["title"] !== "string") return null;
|
|
24
|
+
const title = r["title"];
|
|
25
|
+
const content = typeof r["content"] === "string" ? r["content"] : "";
|
|
26
|
+
const now = typeof r["createdAt"] === "string" ? r["createdAt"] : (/* @__PURE__ */ new Date(0)).toISOString();
|
|
27
|
+
const tags = Array.isArray(r["tags"]) ? r["tags"].filter((t) => typeof t === "string") : [];
|
|
28
|
+
return {
|
|
29
|
+
id: r["id"],
|
|
30
|
+
slug: typeof r["slug"] === "string" && r["slug"].length > 0 ? r["slug"] : slugify(title),
|
|
31
|
+
title,
|
|
32
|
+
description: typeof r["description"] === "string" ? r["description"] : "",
|
|
33
|
+
content,
|
|
34
|
+
category: typeof r["category"] === "string" && r["category"].length > 0 ? r["category"] : "uncategorized",
|
|
35
|
+
tags,
|
|
36
|
+
source: isPromptSource(r["source"]) ? r["source"] : "user",
|
|
37
|
+
favorite: r["favorite"] === true,
|
|
38
|
+
variables: normalizeVariables(r["variables"]),
|
|
39
|
+
author: typeof r["author"] === "string" ? r["author"] : void 0,
|
|
40
|
+
version: typeof r["version"] === "string" ? r["version"] : void 0,
|
|
41
|
+
license: typeof r["license"] === "string" ? r["license"] : void 0,
|
|
42
|
+
checksum: typeof r["checksum"] === "string" ? r["checksum"] : void 0,
|
|
43
|
+
forkedFrom: typeof r["forkedFrom"] === "string" ? r["forkedFrom"] : void 0,
|
|
44
|
+
createdAt: now,
|
|
45
|
+
updatedAt: typeof r["updatedAt"] === "string" ? r["updatedAt"] : now
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function isPromptSource(v) {
|
|
49
|
+
return v === "builtin" || v === "user" || v === "project" || v === "synced";
|
|
50
|
+
}
|
|
51
|
+
function normalizeVariables(v) {
|
|
52
|
+
if (!Array.isArray(v)) return void 0;
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const item of v) {
|
|
55
|
+
if (item && typeof item === "object" && typeof item["name"] === "string") {
|
|
56
|
+
const o = item;
|
|
57
|
+
const enumVals = Array.isArray(o["enum"]) && o["enum"].every((x) => typeof x === "string") ? o["enum"] : void 0;
|
|
58
|
+
out.push({
|
|
59
|
+
name: o["name"],
|
|
60
|
+
description: typeof o["description"] === "string" ? o["description"] : void 0,
|
|
61
|
+
default: typeof o["default"] === "string" ? o["default"] : void 0,
|
|
62
|
+
required: o["required"] === true ? true : void 0,
|
|
63
|
+
enum: enumVals && enumVals.length > 0 ? enumVals : void 0,
|
|
64
|
+
multiline: o["multiline"] === true ? true : void 0
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return out.length > 0 ? out : void 0;
|
|
69
|
+
}
|
|
70
|
+
var DefaultPromptStore = class {
|
|
71
|
+
dir;
|
|
72
|
+
constructor(pathsOrDir) {
|
|
73
|
+
this.dir = typeof pathsOrDir === "string" ? pathsOrDir : pathsOrDir.globalPrompts;
|
|
74
|
+
}
|
|
75
|
+
async list() {
|
|
76
|
+
await ensureDir(this.dir);
|
|
77
|
+
const entries = [];
|
|
78
|
+
try {
|
|
79
|
+
const files = await fs.readdir(this.dir);
|
|
80
|
+
for (const file of files) {
|
|
81
|
+
if (!file.endsWith(".json")) continue;
|
|
82
|
+
try {
|
|
83
|
+
const raw = JSON.parse(
|
|
84
|
+
await fs.readFile(path.join(this.dir, file), "utf8")
|
|
85
|
+
);
|
|
86
|
+
const migrated = migratePromptEntry(raw.entry);
|
|
87
|
+
if (migrated) entries.push(migrated);
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
return entries.sort(
|
|
94
|
+
(a, b) => (Date.parse(b.updatedAt) || 0) - (Date.parse(a.updatedAt) || 0)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
async get(id) {
|
|
98
|
+
const file = path.join(this.dir, `${id}.json`);
|
|
99
|
+
try {
|
|
100
|
+
const raw = JSON.parse(await fs.readFile(file, "utf8"));
|
|
101
|
+
return migratePromptEntry(raw.entry);
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async save(entry) {
|
|
107
|
+
await ensureDir(this.dir);
|
|
108
|
+
const file = path.join(this.dir, `${entry.id}.json`);
|
|
109
|
+
const raw = { version: SCHEMA_VERSION, entry };
|
|
110
|
+
await atomicWrite(file, JSON.stringify(raw, null, 2));
|
|
111
|
+
}
|
|
112
|
+
async delete(id) {
|
|
113
|
+
const file = path.join(this.dir, `${id}.json`);
|
|
114
|
+
try {
|
|
115
|
+
await fs.unlink(file);
|
|
116
|
+
return true;
|
|
117
|
+
} catch {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async find(query) {
|
|
122
|
+
const all = await this.list();
|
|
123
|
+
const lower = query.toLowerCase();
|
|
124
|
+
return all.filter(
|
|
125
|
+
(e) => e.title.toLowerCase().includes(lower) || e.description.toLowerCase().includes(lower) || e.content.toLowerCase().includes(lower) || e.category.toLowerCase().includes(lower) || e.tags.some((t) => t.toLowerCase().includes(lower))
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
/** Create a new v2 entry and return it. Does NOT persist — call save() afterwards. */
|
|
129
|
+
createNew(title, content, tags = [], extra = {}) {
|
|
130
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
131
|
+
return {
|
|
132
|
+
id: ulid(),
|
|
133
|
+
slug: extra.slug && extra.slug.length > 0 ? extra.slug : slugify(title),
|
|
134
|
+
title,
|
|
135
|
+
description: extra.description ?? "",
|
|
136
|
+
content,
|
|
137
|
+
category: extra.category ?? "uncategorized",
|
|
138
|
+
tags,
|
|
139
|
+
source: extra.source ?? "user",
|
|
140
|
+
favorite: extra.favorite ?? false,
|
|
141
|
+
variables: extra.variables,
|
|
142
|
+
author: extra.author,
|
|
143
|
+
version: extra.version,
|
|
144
|
+
license: extra.license,
|
|
145
|
+
checksum: extra.checksum,
|
|
146
|
+
forkedFrom: extra.forkedFrom,
|
|
147
|
+
createdAt: now,
|
|
148
|
+
updatedAt: now
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export {
|
|
154
|
+
promptChecksum,
|
|
155
|
+
migratePromptEntry,
|
|
156
|
+
DefaultPromptStore
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=chunk-PGRVXIMY.js.map
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// src/notifications/notifier-impl.ts
|
|
2
|
+
function emptyCounters() {
|
|
3
|
+
return { attempted: 0, delivered: 0, failed: 0, suppressed: 0 };
|
|
4
|
+
}
|
|
5
|
+
var NotifierImpl = class _NotifierImpl {
|
|
6
|
+
#channels = /* @__PURE__ */ new Map();
|
|
7
|
+
#counters = /* @__PURE__ */ new Map();
|
|
8
|
+
/** Soft cap for #counters — prevents unbounded growth if channels are
|
|
9
|
+
* repeatedly registered with distinct names. */
|
|
10
|
+
static #MAX_COUNTERS = 100;
|
|
11
|
+
// -----------------------------------------------------------------------
|
|
12
|
+
// Lifecycle
|
|
13
|
+
// -----------------------------------------------------------------------
|
|
14
|
+
notify(channels, message) {
|
|
15
|
+
const names = typeof channels === "string" ? [channels] : channels;
|
|
16
|
+
if (names.length === 0) return Promise.resolve([]);
|
|
17
|
+
const results = [];
|
|
18
|
+
for (const name of names) {
|
|
19
|
+
const channel = this.#channels.get(name);
|
|
20
|
+
if (!channel) continue;
|
|
21
|
+
const counters = this.#counters.get(name) ?? emptyCounters();
|
|
22
|
+
counters.attempted += 1;
|
|
23
|
+
this.#counters.set(name, counters);
|
|
24
|
+
results.push(
|
|
25
|
+
channel.deliver(message).then(
|
|
26
|
+
(result) => {
|
|
27
|
+
if (result.ok) {
|
|
28
|
+
counters.delivered += 1;
|
|
29
|
+
} else {
|
|
30
|
+
counters.failed += 1;
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
},
|
|
34
|
+
(err) => {
|
|
35
|
+
counters.failed += 1;
|
|
36
|
+
const error = err instanceof Error ? err.message : "unknown rejection";
|
|
37
|
+
return {
|
|
38
|
+
ok: false,
|
|
39
|
+
channel: name,
|
|
40
|
+
error: `threw: ${error}`,
|
|
41
|
+
deliveredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return Promise.all(results);
|
|
48
|
+
}
|
|
49
|
+
registerChannel(channel) {
|
|
50
|
+
this.#channels.set(channel.name, channel);
|
|
51
|
+
if (!this.#counters.has(channel.name)) {
|
|
52
|
+
if (this.#counters.size >= _NotifierImpl.#MAX_COUNTERS) {
|
|
53
|
+
const oldest = this.#counters.keys().next();
|
|
54
|
+
if (!oldest.done && oldest.value !== void 0) {
|
|
55
|
+
this.#counters.delete(oldest.value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
this.#counters.set(channel.name, emptyCounters());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
unregisterChannel(name) {
|
|
62
|
+
this.#channels.delete(name);
|
|
63
|
+
}
|
|
64
|
+
async channels() {
|
|
65
|
+
const entries = Array.from(this.#channels.entries());
|
|
66
|
+
const results = await Promise.allSettled(
|
|
67
|
+
entries.map(async ([name, channel]) => {
|
|
68
|
+
try {
|
|
69
|
+
const ping = await channel.ping();
|
|
70
|
+
return { name, type: channel.type, ok: ping.ok, error: ping.error };
|
|
71
|
+
} catch {
|
|
72
|
+
return { name, type: channel.type, ok: false, error: "ping threw" };
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
return results.map(
|
|
77
|
+
(r) => r.status === "fulfilled" ? r.value : { name: "unknown", type: "unknown", ok: false, error: "unhandled ping rejection" }
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
counters() {
|
|
81
|
+
let attempted = 0;
|
|
82
|
+
let delivered = 0;
|
|
83
|
+
let failed = 0;
|
|
84
|
+
let suppressed = 0;
|
|
85
|
+
for (const c of this.#counters.values()) {
|
|
86
|
+
attempted += c.attempted;
|
|
87
|
+
delivered += c.delivered;
|
|
88
|
+
failed += c.failed;
|
|
89
|
+
suppressed += c.suppressed;
|
|
90
|
+
}
|
|
91
|
+
return { attempted, delivered, failed, suppressed };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Return per-channel counters for detailed diagnostics.
|
|
95
|
+
* Not part of the `Notifier` interface — available on the concrete class.
|
|
96
|
+
*/
|
|
97
|
+
perChannelCounters() {
|
|
98
|
+
const result = {};
|
|
99
|
+
for (const [name, c] of this.#counters) {
|
|
100
|
+
result[name] = {
|
|
101
|
+
attempted: c.attempted,
|
|
102
|
+
delivered: c.delivered,
|
|
103
|
+
failed: c.failed
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
NotifierImpl
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=chunk-PHH7LD45.js.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
atomicWrite,
|
|
3
|
+
ensureDir
|
|
4
|
+
} from "./chunk-OSGLYW5J.js";
|
|
5
|
+
import {
|
|
6
|
+
diffRegistry,
|
|
7
|
+
validateRegistryManifest
|
|
8
|
+
} from "./chunk-IYFBFX34.js";
|
|
9
|
+
import {
|
|
10
|
+
FetchError,
|
|
11
|
+
ParseError
|
|
12
|
+
} from "./chunk-25LSLC3G.js";
|
|
13
|
+
|
|
14
|
+
// src/prompts/prompt-installer.ts
|
|
15
|
+
var defaultFetcher = async (url) => {
|
|
16
|
+
const res = await fetch(url);
|
|
17
|
+
if (!res.ok) {
|
|
18
|
+
throw new FetchError({
|
|
19
|
+
message: `registry fetch failed: ${res.status} ${res.statusText}`,
|
|
20
|
+
status: res.status,
|
|
21
|
+
context: { op: "fetchManifest" }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return res.json();
|
|
25
|
+
};
|
|
26
|
+
var PromptInstaller = class {
|
|
27
|
+
fetcher;
|
|
28
|
+
constructor(opts = {}) {
|
|
29
|
+
this.fetcher = opts.fetcher ?? defaultFetcher;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Fetch + validate a manifest and report what a sync WOULD change. Read-only.
|
|
33
|
+
* @param manifestUrl URL to the registry's `registry.json`.
|
|
34
|
+
* @param local The prompts the caller already has (slug + checksum).
|
|
35
|
+
*/
|
|
36
|
+
async pull(manifestUrl, local) {
|
|
37
|
+
const raw = await this.fetcher(manifestUrl);
|
|
38
|
+
const validated = validateRegistryManifest(raw);
|
|
39
|
+
if (!validated.ok) {
|
|
40
|
+
throw new ParseError({
|
|
41
|
+
message: `Invalid prompt registry manifest:
|
|
42
|
+
- ${validated.errors.join("\n - ")}`,
|
|
43
|
+
source: "prompt-registry-manifest"
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const diff = diffRegistry(local, validated.manifest);
|
|
47
|
+
return { manifest: validated.manifest, diff, dryRun: true };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* EXTENSION POINT (not yet wired): download the prompt bodies for the given
|
|
51
|
+
* registry refs and write them into the user layer as `source:'synced'`,
|
|
52
|
+
* recording each in the installed-prompts manifest. Intentionally unimplemented
|
|
53
|
+
* — pulling real content over the network is gated behind a future change so
|
|
54
|
+
* the format/diff path can ship and be reviewed first.
|
|
55
|
+
*/
|
|
56
|
+
async install() {
|
|
57
|
+
throw new Error(
|
|
58
|
+
"Prompt sync is not implemented yet. `pull()` reports the diff; installing remote prompt bodies will land in a follow-up."
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/prompts/prompt-manifest-store.ts
|
|
64
|
+
import * as fs from "node:fs/promises";
|
|
65
|
+
import * as path from "node:path";
|
|
66
|
+
var PromptManifestStore = class {
|
|
67
|
+
constructor(manifestPath) {
|
|
68
|
+
this.manifestPath = manifestPath;
|
|
69
|
+
}
|
|
70
|
+
manifestPath;
|
|
71
|
+
async load() {
|
|
72
|
+
try {
|
|
73
|
+
const raw = JSON.parse(await fs.readFile(this.manifestPath, "utf8"));
|
|
74
|
+
if (raw && typeof raw === "object" && Array.isArray(raw.entries)) {
|
|
75
|
+
return { version: 1, entries: raw.entries };
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
return { version: 1, entries: [] };
|
|
80
|
+
}
|
|
81
|
+
async save(data) {
|
|
82
|
+
await ensureDir(path.dirname(this.manifestPath));
|
|
83
|
+
await atomicWrite(this.manifestPath, JSON.stringify(data, null, 2));
|
|
84
|
+
}
|
|
85
|
+
/** Upsert one entry keyed by slug. */
|
|
86
|
+
async record(entry) {
|
|
87
|
+
const data = await this.load();
|
|
88
|
+
const idx = data.entries.findIndex((e) => e.slug === entry.slug);
|
|
89
|
+
if (idx === -1) data.entries.push(entry);
|
|
90
|
+
else data.entries[idx] = entry;
|
|
91
|
+
await this.save(data);
|
|
92
|
+
}
|
|
93
|
+
async remove(slug) {
|
|
94
|
+
const data = await this.load();
|
|
95
|
+
const next = data.entries.filter((e) => e.slug !== slug);
|
|
96
|
+
if (next.length === data.entries.length) return false;
|
|
97
|
+
await this.save({ version: 1, entries: next });
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
async list() {
|
|
101
|
+
return (await this.load()).entries;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
PromptInstaller,
|
|
107
|
+
PromptManifestStore
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=chunk-PISBFBJN.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/utils/socket-path.ts
|
|
2
|
+
import { assertUnixSocketPathWithinLimit, checkUnixSocketPath, unixSocketPathLimit } from "@wrongstack/persistence";
|
|
3
|
+
|
|
4
|
+
export {
|
|
5
|
+
assertUnixSocketPathWithinLimit,
|
|
6
|
+
checkUnixSocketPath,
|
|
7
|
+
unixSocketPathLimit
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=chunk-POOOIWE5.js.map
|