@cleocode/core 2026.8.1 → 2026.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +57 -27
- package/dist/bootstrap.js.map +1 -1
- package/dist/db/index.d.ts +13 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +13 -0
- package/dist/db/index.js.map +1 -1
- package/dist/docs/display-alias.js +1 -1
- package/dist/docs/display-alias.js.map +1 -1
- package/dist/docs/export-document.js +434 -365
- package/dist/docs/export-document.js.map +3 -3
- package/dist/docs/numbering.js +1 -1
- package/dist/docs/numbering.js.map +1 -1
- package/dist/docs/supersede.js +1 -1
- package/dist/docs/supersede.js.map +1 -1
- package/dist/injection.d.ts.map +1 -1
- package/dist/injection.js +44 -3
- package/dist/injection.js.map +1 -1
- package/dist/lifecycle/index.js +1 -1
- package/dist/lifecycle/index.js.map +1 -1
- package/dist/llm/plugin-facade.js +232 -96
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/memory/brain-backfill.js +3 -3
- package/dist/memory/brain-backfill.js.map +1 -1
- package/dist/memory/brain-consolidator.js +2 -2
- package/dist/memory/brain-consolidator.js.map +1 -1
- package/dist/memory/brain-doctor.js +1 -1
- package/dist/memory/brain-doctor.js.map +1 -1
- package/dist/memory/brain-health-dashboard.js +1 -1
- package/dist/memory/brain-health-dashboard.js.map +1 -1
- package/dist/memory/brain-lifecycle.js +10 -10
- package/dist/memory/brain-lifecycle.js.map +1 -1
- package/dist/memory/brain-maintenance.js +1 -1
- package/dist/memory/brain-maintenance.js.map +1 -1
- package/dist/memory/brain-page-nodes.js +4 -4
- package/dist/memory/brain-page-nodes.js.map +1 -1
- package/dist/memory/brain-reasoning.js +1 -1
- package/dist/memory/brain-reasoning.js.map +1 -1
- package/dist/memory/brain-search.js +1 -1
- package/dist/memory/brain-search.js.map +1 -1
- package/dist/memory/brain-similarity.js +1 -1
- package/dist/memory/brain-similarity.js.map +1 -1
- package/dist/memory/brain-stdp.js +6 -6
- package/dist/memory/brain-stdp.js.map +1 -1
- package/dist/memory/brain-sweep-executor.js +1 -1
- package/dist/memory/brain-sweep-executor.js.map +1 -1
- package/dist/memory/brain-writer-handlers.js +2 -2
- package/dist/memory/brain-writer-handlers.js.map +1 -1
- package/dist/memory/claude-mem-migration.d.ts.map +1 -1
- package/dist/memory/claude-mem-migration.js +2 -2
- package/dist/memory/claude-mem-migration.js.map +1 -1
- package/dist/memory/engine-compat.js +4 -4
- package/dist/memory/engine-compat.js.map +1 -1
- package/dist/memory/extraction-gate.js +3 -3
- package/dist/memory/extraction-gate.js.map +1 -1
- package/dist/memory/graph-memory-bridge.js +9 -9
- package/dist/memory/graph-memory-bridge.js.map +1 -1
- package/dist/memory/graph-queries.js +4 -4
- package/dist/memory/graph-queries.js.map +1 -1
- package/dist/memory/llm-extraction.js +1 -1
- package/dist/memory/llm-extraction.js.map +1 -1
- package/dist/memory/memory-bridge.js +1 -1
- package/dist/memory/memory-bridge.js.map +1 -1
- package/dist/memory/nexus-plasticity.js +1 -1
- package/dist/memory/nexus-plasticity.js.map +1 -1
- package/dist/memory/observer-reflector.js +1 -1
- package/dist/memory/observer-reflector.js.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.d.ts.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.js +13 -3
- package/dist/memory/pipeline-manifest-sqlite.js.map +1 -1
- package/dist/memory/quality-feedback.js +4 -4
- package/dist/memory/quality-feedback.js.map +1 -1
- package/dist/memory/retrieval/increment-citation-counts.js +1 -1
- package/dist/memory/retrieval/increment-citation-counts.js.map +1 -1
- package/dist/memory/retrieval/log-retrieval.js +1 -1
- package/dist/memory/retrieval/log-retrieval.js.map +1 -1
- package/dist/memory/retrieval/observe.js +1 -1
- package/dist/memory/retrieval/observe.js.map +1 -1
- package/dist/memory/retrieval/search.js +1 -1
- package/dist/memory/retrieval/search.js.map +1 -1
- package/dist/memory/retrieval/timeline.js +1 -1
- package/dist/memory/retrieval/timeline.js.map +1 -1
- package/dist/memory/sleep-consolidation.js +4 -4
- package/dist/memory/sleep-consolidation.js.map +1 -1
- package/dist/memory/temporal-supersession.js +5 -5
- package/dist/memory/temporal-supersession.js.map +1 -1
- package/dist/memory/transcript-extractor.js +1 -1
- package/dist/memory/transcript-extractor.js.map +1 -1
- package/dist/memory/transcript-ingestor.js +1 -1
- package/dist/memory/transcript-ingestor.js.map +1 -1
- package/dist/memory/transcript-scanner.js +1 -1
- package/dist/memory/transcript-scanner.js.map +1 -1
- package/dist/nexus/living-brain.js +7 -7
- package/dist/nexus/living-brain.js.map +1 -1
- package/dist/nexus/tasks-bridge.js +4 -4
- package/dist/nexus/tasks-bridge.js.map +1 -1
- package/dist/release/reconcile.d.ts.map +1 -1
- package/dist/release/reconcile.js +5 -1
- package/dist/release/reconcile.js.map +1 -1
- package/dist/sagas/migrate-containment.d.ts.map +1 -1
- package/dist/sagas/migrate-containment.js +4 -2
- package/dist/sagas/migrate-containment.js.map +1 -1
- package/dist/scaffold/ensure-dirs.js +1 -1
- package/dist/scaffold/ensure-dirs.js.map +1 -1
- package/dist/selfimprove/fix-gen.js +235 -99
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/sentient/dream-cycle.js +1 -1
- package/dist/sentient/dream-cycle.js.map +1 -1
- package/dist/sentient/hygiene-scan.js +1 -1
- package/dist/sentient/hygiene-scan.js.map +1 -1
- package/dist/sentient/propose-tick.js +3 -3
- package/dist/sentient/propose-tick.js.map +1 -1
- package/dist/sentient/stage-drift-tick.js +1 -1
- package/dist/sentient/stage-drift-tick.js.map +1 -1
- package/dist/sequence/index.js +1 -1
- package/dist/sequence/index.js.map +1 -1
- package/dist/store/agent-registry-store.d.ts.map +1 -1
- package/dist/store/agent-registry-store.js +71 -28
- package/dist/store/agent-registry-store.js.map +1 -1
- package/dist/store/attachment-store.js +3 -3
- package/dist/store/attachment-store.js.map +1 -1
- package/dist/store/conduit-sqlite.d.ts +21 -1
- package/dist/store/conduit-sqlite.d.ts.map +1 -1
- package/dist/store/conduit-sqlite.js +42 -56
- package/dist/store/conduit-sqlite.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts +39 -0
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +26 -8
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/memory-sqlite.d.ts +57 -3
- package/dist/store/memory-sqlite.d.ts.map +1 -1
- package/dist/store/memory-sqlite.js +70 -89
- package/dist/store/memory-sqlite.js.map +1 -1
- package/dist/store/nexus-sqlite.d.ts +42 -0
- package/dist/store/nexus-sqlite.d.ts.map +1 -1
- package/dist/store/nexus-sqlite.js +79 -115
- package/dist/store/nexus-sqlite.js.map +1 -1
- package/dist/store/ports/domain-binding.d.ts +233 -0
- package/dist/store/ports/domain-binding.d.ts.map +1 -0
- package/dist/store/ports/domain-binding.js +500 -0
- package/dist/store/ports/domain-binding.js.map +1 -0
- package/dist/store/ports/fk-integrity.d.ts +155 -0
- package/dist/store/ports/fk-integrity.d.ts.map +1 -0
- package/dist/store/ports/fk-integrity.js +182 -0
- package/dist/store/ports/fk-integrity.js.map +1 -0
- package/dist/store/role-accessors-impl.js +2 -2
- package/dist/store/role-accessors-impl.js.map +1 -1
- package/dist/store/skills-db.d.ts +19 -0
- package/dist/store/skills-db.d.ts.map +1 -1
- package/dist/store/skills-db.js +80 -72
- package/dist/store/skills-db.js.map +1 -1
- package/dist/store/sqlite-backup.js +2 -2
- package/dist/store/sqlite-backup.js.map +1 -1
- package/dist/store/sqlite-data-accessor.js +1 -1
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/sqlite.d.ts +72 -10
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +173 -160
- package/dist/store/sqlite.js.map +1 -1
- package/dist/store/tasks-sqlite.js +2 -2
- package/dist/store/tasks-sqlite.js.map +1 -1
- package/dist/system/health.d.ts +0 -4
- package/dist/system/health.d.ts.map +1 -1
- package/dist/system/health.js +58 -2
- package/dist/system/health.js.map +1 -1
- package/dist/upgrade.js +2 -2
- package/dist/upgrade.js.map +1 -1
- package/dist/validation/doctor/checks.d.ts +23 -1
- package/dist/validation/doctor/checks.d.ts.map +1 -1
- package/dist/validation/doctor/checks.js +79 -19
- package/dist/validation/doctor/checks.js.map +1 -1
- package/dist/worktree/list.js +1 -1
- package/dist/worktree/list.js.map +1 -1
- package/package.json +22 -12
|
@@ -15722,6 +15722,18 @@ var init_service_provider = __esm({
|
|
|
15722
15722
|
}
|
|
15723
15723
|
});
|
|
15724
15724
|
|
|
15725
|
+
// packages/contracts/src/caamp-markers.ts
|
|
15726
|
+
var H, damagedMarkerSource, CAAMP_DAMAGED_START_PATTERN_SOURCE, CAAMP_DAMAGED_END_PATTERN_SOURCE;
|
|
15727
|
+
var init_caamp_markers = __esm({
|
|
15728
|
+
"packages/contracts/src/caamp-markers.ts"() {
|
|
15729
|
+
"use strict";
|
|
15730
|
+
H = "[ \\t\\r]";
|
|
15731
|
+
damagedMarkerSource = (keyword) => `^${H}*[<!-]{1,4}${H}*CAAMP${H}*:${H}*${keyword}${H}*[->]{1,3}${H}*$`;
|
|
15732
|
+
CAAMP_DAMAGED_START_PATTERN_SOURCE = damagedMarkerSource("START");
|
|
15733
|
+
CAAMP_DAMAGED_END_PATTERN_SOURCE = damagedMarkerSource("END");
|
|
15734
|
+
}
|
|
15735
|
+
});
|
|
15736
|
+
|
|
15725
15737
|
// packages/contracts/src/index.ts
|
|
15726
15738
|
var init_src = __esm({
|
|
15727
15739
|
"packages/contracts/src/index.ts"() {
|
|
@@ -15789,6 +15801,7 @@ var init_src = __esm({
|
|
|
15789
15801
|
init_validator();
|
|
15790
15802
|
init_service_provider();
|
|
15791
15803
|
init_workgraph();
|
|
15804
|
+
init_caamp_markers();
|
|
15792
15805
|
}
|
|
15793
15806
|
});
|
|
15794
15807
|
|
|
@@ -23511,7 +23524,7 @@ function resolveDbIdentity(db) {
|
|
|
23511
23524
|
return identity;
|
|
23512
23525
|
}
|
|
23513
23526
|
function sleepAsync(ms) {
|
|
23514
|
-
return new Promise((
|
|
23527
|
+
return new Promise((resolve7) => setTimeout(resolve7, Math.max(0, Math.round(ms))));
|
|
23515
23528
|
}
|
|
23516
23529
|
function isPidAlive(pid) {
|
|
23517
23530
|
try {
|
|
@@ -24329,7 +24342,7 @@ async function sendResourceRelease(socketPath, cls, holderId) {
|
|
|
24329
24342
|
return { unavailable: true, reason: `unexpected response kind: ${result.kind}` };
|
|
24330
24343
|
}
|
|
24331
24344
|
function sendLeaseRequest(socketPath, request, expectedKind) {
|
|
24332
|
-
return new Promise((
|
|
24345
|
+
return new Promise((resolve7) => {
|
|
24333
24346
|
const id = `ra-${process.pid}-${request.kind}`;
|
|
24334
24347
|
const envelope = LeaseIpcRequestEnvelopeSchema.parse({
|
|
24335
24348
|
protocol_version: LEASE_IPC_PROTOCOL_VERSION,
|
|
@@ -24347,7 +24360,7 @@ function sendLeaseRequest(socketPath, request, expectedKind) {
|
|
|
24347
24360
|
settled = true;
|
|
24348
24361
|
socket.removeAllListeners();
|
|
24349
24362
|
socket.destroy();
|
|
24350
|
-
|
|
24363
|
+
resolve7(value);
|
|
24351
24364
|
};
|
|
24352
24365
|
const degrade = (reason) => done({ unavailable: true, reason });
|
|
24353
24366
|
socket.setTimeout(REQUEST_TIMEOUT_MS);
|
|
@@ -27772,8 +27785,8 @@ async function openDualScopeDbAtPath(scope, dbPath, exodusCwd, options) {
|
|
|
27772
27785
|
}
|
|
27773
27786
|
let initResolve = null;
|
|
27774
27787
|
let initReject = null;
|
|
27775
|
-
const initPromise = new Promise((
|
|
27776
|
-
initResolve =
|
|
27788
|
+
const initPromise = new Promise((resolve7, reject) => {
|
|
27789
|
+
initResolve = resolve7;
|
|
27777
27790
|
initReject = reject;
|
|
27778
27791
|
});
|
|
27779
27792
|
_cache.set(key, {
|
|
@@ -28026,24 +28039,35 @@ var init_dual_scope_db = __esm({
|
|
|
28026
28039
|
async openProject(dbPath, options) {
|
|
28027
28040
|
const normalized = resolve3(dbPath);
|
|
28028
28041
|
if (options?.dedicated) {
|
|
28029
|
-
const handle = await openDualScopeDbAtPath("project", normalized,
|
|
28042
|
+
const handle = await openDualScopeDbAtPath("project", normalized, options?.exodusCwd, {
|
|
28030
28043
|
dedicated: true
|
|
28031
28044
|
});
|
|
28032
28045
|
return this.buildStore("project", handle, 0);
|
|
28033
28046
|
}
|
|
28034
|
-
return this.openEntry("project", normalized);
|
|
28047
|
+
return this.openEntry("project", normalized, 0, options?.exodusCwd);
|
|
28035
28048
|
}
|
|
28036
28049
|
/** @inheritdoc */
|
|
28037
28050
|
async openGlobal(options) {
|
|
28038
28051
|
const dbPath = resolveDualScopeDbPath("global");
|
|
28039
28052
|
const normalized = resolve3(dbPath);
|
|
28040
28053
|
if (options?.dedicated) {
|
|
28041
|
-
const handle = await openDualScopeDbAtPath("global", normalized,
|
|
28054
|
+
const handle = await openDualScopeDbAtPath("global", normalized, options?.exodusCwd, {
|
|
28055
|
+
dedicated: true
|
|
28056
|
+
});
|
|
28057
|
+
return this.buildStore("global", handle, 0);
|
|
28058
|
+
}
|
|
28059
|
+
return this.openEntry("global", normalized, 0, options?.exodusCwd);
|
|
28060
|
+
}
|
|
28061
|
+
/** @inheritdoc */
|
|
28062
|
+
async openGlobalAt(dbPath, options) {
|
|
28063
|
+
const normalized = resolve3(dbPath);
|
|
28064
|
+
if (options?.dedicated) {
|
|
28065
|
+
const handle = await openDualScopeDbAtPath("global", normalized, options?.exodusCwd, {
|
|
28042
28066
|
dedicated: true
|
|
28043
28067
|
});
|
|
28044
28068
|
return this.buildStore("global", handle, 0);
|
|
28045
28069
|
}
|
|
28046
|
-
return this.openEntry("global", normalized);
|
|
28070
|
+
return this.openEntry("global", normalized, 0, options?.exodusCwd);
|
|
28047
28071
|
}
|
|
28048
28072
|
/** @inheritdoc */
|
|
28049
28073
|
closeProject(dbPath) {
|
|
@@ -28069,7 +28093,7 @@ var init_dual_scope_db = __esm({
|
|
|
28069
28093
|
* retry calls this with `depth + 1`. A second dead handle at depth 1
|
|
28070
28094
|
* throws {@link LivenessExhaustedError} instead of recursing further.
|
|
28071
28095
|
*/
|
|
28072
|
-
async openEntry(scope, dbPath, depth = 0) {
|
|
28096
|
+
async openEntry(scope, dbPath, depth = 0, exodusCwd) {
|
|
28073
28097
|
const key = cacheKey(scope, dbPath);
|
|
28074
28098
|
const existing = this._registry.get(key);
|
|
28075
28099
|
if (existing) {
|
|
@@ -28084,8 +28108,8 @@ var init_dual_scope_db = __esm({
|
|
|
28084
28108
|
const entryId = ++this._nextId;
|
|
28085
28109
|
let initResolve;
|
|
28086
28110
|
let initReject;
|
|
28087
|
-
const initPromise = new Promise((
|
|
28088
|
-
initResolve =
|
|
28111
|
+
const initPromise = new Promise((resolve7, reject) => {
|
|
28112
|
+
initResolve = resolve7;
|
|
28089
28113
|
initReject = reject;
|
|
28090
28114
|
});
|
|
28091
28115
|
this._registry.set(key, { id: entryId, store: null, initPromise });
|
|
@@ -28096,7 +28120,7 @@ var init_dual_scope_db = __esm({
|
|
|
28096
28120
|
}
|
|
28097
28121
|
});
|
|
28098
28122
|
try {
|
|
28099
|
-
const dualHandle = scope === "project" ? await this.openDualScopeFn("project", dbPath) : await this.openDualScopeFn("global", dbPath);
|
|
28123
|
+
const dualHandle = scope === "project" ? await this.openDualScopeFn("project", dbPath, exodusCwd) : await this.openDualScopeFn("global", dbPath, exodusCwd);
|
|
28100
28124
|
const current = this._registry.get(key);
|
|
28101
28125
|
if (!current || current.id !== entryId) {
|
|
28102
28126
|
throw new EntryCancelledError(scope, dbPath);
|
|
@@ -28107,7 +28131,7 @@ var init_dual_scope_db = __esm({
|
|
|
28107
28131
|
if (depth >= 1) {
|
|
28108
28132
|
throw new LivenessExhaustedError(scope, dbPath);
|
|
28109
28133
|
}
|
|
28110
|
-
const retryStore = await this.openEntry(scope, dbPath, depth + 1);
|
|
28134
|
+
const retryStore = await this.openEntry(scope, dbPath, depth + 1, exodusCwd);
|
|
28111
28135
|
initResolve(retryStore);
|
|
28112
28136
|
return retryStore;
|
|
28113
28137
|
}
|
|
@@ -28203,6 +28227,151 @@ var init_dual_scope_db = __esm({
|
|
|
28203
28227
|
}
|
|
28204
28228
|
});
|
|
28205
28229
|
|
|
28230
|
+
// packages/core/src/store/ports/domain-binding.ts
|
|
28231
|
+
import { resolve as resolve4 } from "node:path";
|
|
28232
|
+
function getCleoRuntime() {
|
|
28233
|
+
if (!_runtime) {
|
|
28234
|
+
_runtime = createCleoRuntime();
|
|
28235
|
+
}
|
|
28236
|
+
return _runtime;
|
|
28237
|
+
}
|
|
28238
|
+
function bindingKey(scope, dbPath, domain2) {
|
|
28239
|
+
return `${scope}::${dbPath}::${domain2}`;
|
|
28240
|
+
}
|
|
28241
|
+
function nativeOf(store) {
|
|
28242
|
+
const native = store.db.$client;
|
|
28243
|
+
if (!native) {
|
|
28244
|
+
throw new Error(
|
|
28245
|
+
`T12037: CleoRuntime store for ${store.scope}::${store.dbPath} exposed no $client \u2014 cannot bind a domain schema to it.`
|
|
28246
|
+
);
|
|
28247
|
+
}
|
|
28248
|
+
return native;
|
|
28249
|
+
}
|
|
28250
|
+
function reuseValid(key, store) {
|
|
28251
|
+
const row = _bindings.get(key);
|
|
28252
|
+
if (!row) return void 0;
|
|
28253
|
+
if (row.store !== store || !store.isOpen || !row.native.isOpen) {
|
|
28254
|
+
_bindings.delete(key);
|
|
28255
|
+
return void 0;
|
|
28256
|
+
}
|
|
28257
|
+
return row;
|
|
28258
|
+
}
|
|
28259
|
+
async function bindAgainst(key, store, establish) {
|
|
28260
|
+
const cached2 = reuseValid(key, store);
|
|
28261
|
+
if (cached2) return cached2;
|
|
28262
|
+
const pending = _inflight.get(key);
|
|
28263
|
+
if (pending) {
|
|
28264
|
+
const row = await pending;
|
|
28265
|
+
if (row.store === store && row.native.isOpen) return row;
|
|
28266
|
+
return bindAgainst(key, store, establish);
|
|
28267
|
+
}
|
|
28268
|
+
const native = nativeOf(store);
|
|
28269
|
+
const flight = (async () => {
|
|
28270
|
+
const db = await establish(native, store);
|
|
28271
|
+
const row = { store, native, db };
|
|
28272
|
+
if (store.isOpen && native.isOpen) {
|
|
28273
|
+
_bindings.set(key, row);
|
|
28274
|
+
}
|
|
28275
|
+
return row;
|
|
28276
|
+
})();
|
|
28277
|
+
_inflight.set(key, flight);
|
|
28278
|
+
try {
|
|
28279
|
+
return await flight;
|
|
28280
|
+
} finally {
|
|
28281
|
+
if (_inflight.get(key) === flight) {
|
|
28282
|
+
_inflight.delete(key);
|
|
28283
|
+
}
|
|
28284
|
+
}
|
|
28285
|
+
}
|
|
28286
|
+
async function bindLive(scope, key, dbPath, openStore, establish) {
|
|
28287
|
+
let lastError;
|
|
28288
|
+
for (let attempt = 0; attempt < MAX_LIVENESS_ATTEMPTS; attempt += 1) {
|
|
28289
|
+
let store;
|
|
28290
|
+
try {
|
|
28291
|
+
store = await openStore();
|
|
28292
|
+
} catch (err) {
|
|
28293
|
+
lastError = err;
|
|
28294
|
+
releaseDomainBindings({ scope, dbPath });
|
|
28295
|
+
if (attempt + 1 >= MAX_LIVENESS_ATTEMPTS) throw err;
|
|
28296
|
+
continue;
|
|
28297
|
+
}
|
|
28298
|
+
try {
|
|
28299
|
+
const row = await bindAgainst(key, store, establish);
|
|
28300
|
+
if (row.store.isOpen && row.native.isOpen) return row;
|
|
28301
|
+
} catch (err) {
|
|
28302
|
+
lastError = err;
|
|
28303
|
+
if (store.isOpen) throw err;
|
|
28304
|
+
}
|
|
28305
|
+
releaseDomainBindings({ scope, dbPath });
|
|
28306
|
+
try {
|
|
28307
|
+
store.close();
|
|
28308
|
+
} catch {
|
|
28309
|
+
}
|
|
28310
|
+
}
|
|
28311
|
+
if (lastError !== void 0) throw lastError;
|
|
28312
|
+
throw new Error(
|
|
28313
|
+
`T12037: could not bind ${key} over a live connection after ${MAX_LIVENESS_ATTEMPTS} attempts \u2014 the consolidated handle was closed each time.`
|
|
28314
|
+
);
|
|
28315
|
+
}
|
|
28316
|
+
async function bindProjectDomain(domain2, cwd, establish) {
|
|
28317
|
+
const dbPath = resolve4(resolveDualScopeDbPath("project", cwd));
|
|
28318
|
+
const row = await bindLive(
|
|
28319
|
+
"project",
|
|
28320
|
+
bindingKey("project", dbPath, domain2),
|
|
28321
|
+
dbPath,
|
|
28322
|
+
() => getCleoRuntime().openProject(dbPath, { exodusCwd: cwd }),
|
|
28323
|
+
establish
|
|
28324
|
+
);
|
|
28325
|
+
return row;
|
|
28326
|
+
}
|
|
28327
|
+
function releaseDomainBindings(filter2) {
|
|
28328
|
+
if (!filter2) {
|
|
28329
|
+
_bindings.clear();
|
|
28330
|
+
return;
|
|
28331
|
+
}
|
|
28332
|
+
const wantPath = filter2.dbPath === void 0 ? void 0 : resolve4(filter2.dbPath);
|
|
28333
|
+
for (const key of [..._bindings.keys()]) {
|
|
28334
|
+
const sep = key.indexOf("::");
|
|
28335
|
+
const lastSep = key.lastIndexOf("::");
|
|
28336
|
+
const scope = key.slice(0, sep);
|
|
28337
|
+
const dbPath = key.slice(sep + 2, lastSep);
|
|
28338
|
+
const domain2 = key.slice(lastSep + 2);
|
|
28339
|
+
if (filter2.scope !== void 0 && scope !== filter2.scope) continue;
|
|
28340
|
+
if (wantPath !== void 0 && dbPath !== wantPath) continue;
|
|
28341
|
+
if (filter2.domain !== void 0 && domain2 !== filter2.domain) continue;
|
|
28342
|
+
_bindings.delete(key);
|
|
28343
|
+
}
|
|
28344
|
+
}
|
|
28345
|
+
function boundProjectNative(domain2, cwd) {
|
|
28346
|
+
return peekProjectDomain(domain2, cwd)?.native ?? null;
|
|
28347
|
+
}
|
|
28348
|
+
function peekProjectDomain(domain2, cwd) {
|
|
28349
|
+
const dbPath = resolve4(resolveDualScopeDbPath("project", cwd));
|
|
28350
|
+
const row = _bindings.get(bindingKey("project", dbPath, domain2));
|
|
28351
|
+
if (row?.native.isOpen) return row;
|
|
28352
|
+
if (cwd !== void 0) return null;
|
|
28353
|
+
const suffix = `::${domain2}`;
|
|
28354
|
+
let sole;
|
|
28355
|
+
for (const [key, candidate] of _bindings) {
|
|
28356
|
+
if (!key.startsWith("project::") || !key.endsWith(suffix)) continue;
|
|
28357
|
+
if (!candidate.native.isOpen) continue;
|
|
28358
|
+
if (sole) return null;
|
|
28359
|
+
sole = candidate;
|
|
28360
|
+
}
|
|
28361
|
+
return sole ?? null;
|
|
28362
|
+
}
|
|
28363
|
+
var _runtime, _bindings, _inflight, MAX_LIVENESS_ATTEMPTS;
|
|
28364
|
+
var init_domain_binding = __esm({
|
|
28365
|
+
"packages/core/src/store/ports/domain-binding.ts"() {
|
|
28366
|
+
"use strict";
|
|
28367
|
+
init_dual_scope_db();
|
|
28368
|
+
_runtime = null;
|
|
28369
|
+
_bindings = /* @__PURE__ */ new Map();
|
|
28370
|
+
_inflight = /* @__PURE__ */ new Map();
|
|
28371
|
+
MAX_LIVENESS_ATTEMPTS = 2;
|
|
28372
|
+
}
|
|
28373
|
+
});
|
|
28374
|
+
|
|
28206
28375
|
// packages/core/src/store/schema/nexus-schema.ts
|
|
28207
28376
|
var nexus_schema_exports = {};
|
|
28208
28377
|
__export(nexus_schema_exports, {
|
|
@@ -28711,6 +28880,7 @@ var nexus_sqlite_exports = {};
|
|
|
28711
28880
|
__export(nexus_sqlite_exports, {
|
|
28712
28881
|
NEXUS_SCHEMA_VERSION: () => NEXUS_SCHEMA_VERSION,
|
|
28713
28882
|
_resetNestedNexusWarningGate: () => _resetNestedNexusWarningGate,
|
|
28883
|
+
bindNexusDomain: () => bindNexusDomain,
|
|
28714
28884
|
closeNexusDb: () => closeNexusDb,
|
|
28715
28885
|
detectAndWarnOnNestedNexus: () => detectAndWarnOnNestedNexus,
|
|
28716
28886
|
getNestedNexusSentinelPath: () => getNestedNexusSentinelPath,
|
|
@@ -28919,13 +29089,13 @@ function ensureNexusRelationWeights(nativeDb) {
|
|
|
28919
29089
|
nativeDb.exec(`PRAGMA foreign_keys=${fkWasOn ? "ON" : "OFF"}`);
|
|
28920
29090
|
}
|
|
28921
29091
|
}
|
|
28922
|
-
function runNexusMigrations(nativeDb, db) {
|
|
29092
|
+
function runNexusMigrations(nativeDb, db, dbPath) {
|
|
28923
29093
|
const migrationsFolder = resolveNexusMigrationsFolder();
|
|
28924
|
-
if (tableExists4(nativeDb, "nexus_nodes")
|
|
28925
|
-
const backupPath =
|
|
29094
|
+
if (tableExists4(nativeDb, "nexus_nodes")) {
|
|
29095
|
+
const backupPath = dbPath.replace(/\.db$/, "-pre-cleo.db.bak");
|
|
28926
29096
|
if (!existsSync14(backupPath)) {
|
|
28927
29097
|
try {
|
|
28928
|
-
copyFileSync4(
|
|
29098
|
+
copyFileSync4(dbPath, backupPath);
|
|
28929
29099
|
} catch {
|
|
28930
29100
|
}
|
|
28931
29101
|
}
|
|
@@ -28967,75 +29137,45 @@ function runNexusMigrations(nativeDb, db) {
|
|
|
28967
29137
|
ensureNexusFts5(nativeDb);
|
|
28968
29138
|
}
|
|
28969
29139
|
async function getNexusDb() {
|
|
28970
|
-
|
|
29140
|
+
return (await bindNexusDomain()).db.drizzle;
|
|
29141
|
+
}
|
|
29142
|
+
async function bindNexusDomain() {
|
|
28971
29143
|
const requestedRegistryPath = getNexusRegistryDbPath();
|
|
28972
|
-
|
|
28973
|
-
|
|
28974
|
-
|
|
28975
|
-
if (_nexusDb && _nexusRegistryPath !== requestedRegistryPath) {
|
|
28976
|
-
resetNexusDbState();
|
|
29144
|
+
const bound = peekProjectDomain("nexus");
|
|
29145
|
+
if (bound && bound.db.registryPath !== requestedRegistryPath) {
|
|
29146
|
+
releaseDomainBindings({ scope: "project", domain: "nexus" });
|
|
28977
29147
|
}
|
|
28978
|
-
|
|
28979
|
-
|
|
28980
|
-
|
|
28981
|
-
if (_nexusDb) {
|
|
28982
|
-
if (_nexusNativeDb) {
|
|
28983
|
-
try {
|
|
28984
|
-
ensureGlobalRegistryAttached(_nexusNativeDb);
|
|
28985
|
-
} catch {
|
|
28986
|
-
resetNexusDbState();
|
|
28987
|
-
}
|
|
28988
|
-
}
|
|
28989
|
-
if (_nexusDb) return _nexusDb;
|
|
28990
|
-
}
|
|
28991
|
-
if (_nexusInitPromise) return _nexusInitPromise;
|
|
28992
|
-
_nexusInitPromise = (async () => {
|
|
28993
|
-
const dbPath = requestedPath;
|
|
28994
|
-
_nexusDbPath = dbPath;
|
|
28995
|
-
_nexusRegistryPath = requestedRegistryPath;
|
|
28996
|
-
detectAndWarnOnNestedNexus();
|
|
28997
|
-
await openDualScopeDb("global");
|
|
28998
|
-
const dualHandle = await openDualScopeDb("project");
|
|
28999
|
-
const nativeDb = dualHandle.db.$client ?? null;
|
|
29000
|
-
if (!nativeDb) {
|
|
29001
|
-
throw new Error(
|
|
29002
|
-
"T11648: openDualScopeDb returned a handle without $client \u2014 cannot extract DatabaseSync for the nexus-schema drizzle wrapping."
|
|
29003
|
-
);
|
|
29004
|
-
}
|
|
29005
|
-
_nexusNativeDb = nativeDb;
|
|
29148
|
+
detectAndWarnOnNestedNexus();
|
|
29149
|
+
await openDualScopeDb("global");
|
|
29150
|
+
const binding = await bindProjectDomain("nexus", void 0, (nativeDb, store) => {
|
|
29006
29151
|
ensureGlobalRegistryAttached(nativeDb);
|
|
29007
29152
|
const db = drizzle({ client: nativeDb });
|
|
29008
|
-
runNexusMigrations(nativeDb, db);
|
|
29153
|
+
runNexusMigrations(nativeDb, db, store.dbPath);
|
|
29009
29154
|
nativeDb.prepare(
|
|
29010
29155
|
`INSERT OR IGNORE INTO nexus_schema_meta (key, value) VALUES ('schemaVersion', '${NEXUS_SCHEMA_VERSION}')`
|
|
29011
29156
|
).run();
|
|
29012
|
-
|
|
29013
|
-
|
|
29014
|
-
})();
|
|
29157
|
+
return { drizzle: db, registryPath: requestedRegistryPath };
|
|
29158
|
+
});
|
|
29015
29159
|
try {
|
|
29016
|
-
|
|
29017
|
-
}
|
|
29018
|
-
|
|
29160
|
+
ensureGlobalRegistryAttached(binding.native);
|
|
29161
|
+
} catch {
|
|
29162
|
+
releaseDomainBindings({ scope: "project", domain: "nexus" });
|
|
29163
|
+
throw new Error(
|
|
29164
|
+
"T12039: nexus binding lost its GLOBAL registry ATTACH and could not re-attach."
|
|
29165
|
+
);
|
|
29019
29166
|
}
|
|
29167
|
+
return binding;
|
|
29020
29168
|
}
|
|
29021
29169
|
function closeNexusDb() {
|
|
29022
|
-
|
|
29023
|
-
_nexusDb = null;
|
|
29024
|
-
_nexusDbPath = null;
|
|
29025
|
-
_nexusRegistryPath = null;
|
|
29026
|
-
_nexusInitPromise = null;
|
|
29170
|
+
releaseDomainBindings({ scope: "project", domain: "nexus" });
|
|
29027
29171
|
}
|
|
29028
29172
|
function resetNexusDbState() {
|
|
29029
|
-
|
|
29030
|
-
_nexusDb = null;
|
|
29031
|
-
_nexusDbPath = null;
|
|
29032
|
-
_nexusRegistryPath = null;
|
|
29033
|
-
_nexusInitPromise = null;
|
|
29173
|
+
releaseDomainBindings({ scope: "project", domain: "nexus" });
|
|
29034
29174
|
}
|
|
29035
29175
|
function getNexusNativeDb() {
|
|
29036
|
-
return
|
|
29176
|
+
return boundProjectNative("nexus");
|
|
29037
29177
|
}
|
|
29038
|
-
var NEXUS_SCHEMA_VERSION,
|
|
29178
|
+
var NEXUS_SCHEMA_VERSION, NEXUS_GLOBAL_ATTACH_ALIAS, NESTED_NEXUS_SENTINEL, _warnedNestedPaths;
|
|
29039
29179
|
var init_nexus_sqlite = __esm({
|
|
29040
29180
|
"packages/core/src/store/nexus-sqlite.ts"() {
|
|
29041
29181
|
"use strict";
|
|
@@ -29044,15 +29184,11 @@ var init_nexus_sqlite = __esm({
|
|
|
29044
29184
|
init_paths();
|
|
29045
29185
|
init_dual_scope_db();
|
|
29046
29186
|
init_migration_manager();
|
|
29187
|
+
init_domain_binding();
|
|
29047
29188
|
init_resolve_migrations_folder();
|
|
29048
29189
|
init_nexus_schema();
|
|
29049
29190
|
init_with_retry();
|
|
29050
29191
|
NEXUS_SCHEMA_VERSION = "1.0.0";
|
|
29051
|
-
_nexusDb = null;
|
|
29052
|
-
_nexusNativeDb = null;
|
|
29053
|
-
_nexusDbPath = null;
|
|
29054
|
-
_nexusRegistryPath = null;
|
|
29055
|
-
_nexusInitPromise = null;
|
|
29056
29192
|
NEXUS_GLOBAL_ATTACH_ALIAS = "nexus_global";
|
|
29057
29193
|
NESTED_NEXUS_SENTINEL = "nexus.db";
|
|
29058
29194
|
_warnedNestedPaths = /* @__PURE__ */ new Set();
|
|
@@ -29064,7 +29200,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
29064
29200
|
import { existsSync as existsSync15, readFileSync as readFileSync4, statSync as statSync5 } from "node:fs";
|
|
29065
29201
|
import { createRequire as createRequire5 } from "node:module";
|
|
29066
29202
|
import { homedir } from "node:os";
|
|
29067
|
-
import { basename as basename4, dirname as dirname6, join as join15, resolve as
|
|
29203
|
+
import { basename as basename4, dirname as dirname6, join as join15, resolve as resolve5 } from "node:path";
|
|
29068
29204
|
import {
|
|
29069
29205
|
computeCanonicalProjectId as _computeCanonicalProjectId,
|
|
29070
29206
|
getCanonicalTemplatesTildePath as _getCanonicalTemplatesTildePath,
|
|
@@ -29131,24 +29267,24 @@ function getCleoDirAbsolute(cwd, opts) {
|
|
|
29131
29267
|
try {
|
|
29132
29268
|
const projectRoot = getProjectRoot(cwd);
|
|
29133
29269
|
const canonical = _resolveCanonicalCleoDir(project.projectId);
|
|
29134
|
-
if (canonical !== null && canonical ===
|
|
29270
|
+
if (canonical !== null && canonical === resolve5(projectRoot, cleoDir)) {
|
|
29135
29271
|
return canonical;
|
|
29136
29272
|
}
|
|
29137
|
-
return
|
|
29273
|
+
return resolve5(projectRoot, cleoDir);
|
|
29138
29274
|
} catch {
|
|
29139
|
-
return
|
|
29275
|
+
return resolve5(project.projectRoot, cleoDir);
|
|
29140
29276
|
}
|
|
29141
29277
|
}
|
|
29142
29278
|
try {
|
|
29143
|
-
return
|
|
29279
|
+
return resolve5(getProjectRoot(cwd), cleoDir);
|
|
29144
29280
|
} catch (err) {
|
|
29145
29281
|
if (opts?.bootstrap) {
|
|
29146
|
-
return
|
|
29282
|
+
return resolve5(cwd ?? process.cwd(), cleoDir);
|
|
29147
29283
|
}
|
|
29148
29284
|
if (_cwdHasGitAncestor(cwd)) {
|
|
29149
29285
|
throw err;
|
|
29150
29286
|
}
|
|
29151
|
-
return
|
|
29287
|
+
return resolve5(cwd ?? process.cwd(), cleoDir);
|
|
29152
29288
|
}
|
|
29153
29289
|
}
|
|
29154
29290
|
function _resolveProjectByCwdFromNexus(cwd) {
|
|
@@ -29156,7 +29292,7 @@ function _resolveProjectByCwdFromNexus(cwd) {
|
|
|
29156
29292
|
const cleoHome = getCleoHome();
|
|
29157
29293
|
const globalDbPath = join15(cleoHome, "cleo.db");
|
|
29158
29294
|
if (!existsSync15(globalDbPath)) return null;
|
|
29159
|
-
const start =
|
|
29295
|
+
const start = resolve5(cwd ?? process.cwd());
|
|
29160
29296
|
let current = start;
|
|
29161
29297
|
const DatabaseSync2 = _getDatabaseSyncCtor();
|
|
29162
29298
|
const db = new DatabaseSync2(globalDbPath, { readOnly: true });
|
|
@@ -29189,7 +29325,7 @@ function _cleoDirEnvOverride() {
|
|
|
29189
29325
|
}
|
|
29190
29326
|
function _findCleoDirRoot(cwd) {
|
|
29191
29327
|
const homeRoot = homedir();
|
|
29192
|
-
let current =
|
|
29328
|
+
let current = resolve5(cwd ?? process.cwd());
|
|
29193
29329
|
while (true) {
|
|
29194
29330
|
const isDangerousRoot = current === homeRoot || current === "/" || current === "";
|
|
29195
29331
|
if (!isDangerousRoot) {
|
|
@@ -29219,7 +29355,7 @@ function resolveCleoDir(cwd) {
|
|
|
29219
29355
|
if (root !== null) {
|
|
29220
29356
|
return join15(root, ".cleo");
|
|
29221
29357
|
}
|
|
29222
|
-
const start =
|
|
29358
|
+
const start = resolve5(cwd ?? process.cwd());
|
|
29223
29359
|
let current = start;
|
|
29224
29360
|
while (true) {
|
|
29225
29361
|
const mainRepo = _resolveMainRepoFromGitlink(current);
|
|
@@ -29255,15 +29391,15 @@ function _resolveCleoDir(cwd) {
|
|
|
29255
29391
|
const project = _pathsResolveProjectByCwd(cwd);
|
|
29256
29392
|
if (project !== null) {
|
|
29257
29393
|
try {
|
|
29258
|
-
return
|
|
29394
|
+
return resolve5(getProjectRoot(cwd), cleoDir);
|
|
29259
29395
|
} catch {
|
|
29260
|
-
return
|
|
29396
|
+
return resolve5(project.projectRoot, cleoDir);
|
|
29261
29397
|
}
|
|
29262
29398
|
}
|
|
29263
29399
|
return getCleoDirAbsolute(cwd);
|
|
29264
29400
|
}
|
|
29265
29401
|
function _cwdHasGitAncestor(cwd) {
|
|
29266
|
-
const start =
|
|
29402
|
+
const start = resolve5(cwd ?? process.cwd());
|
|
29267
29403
|
let current = start;
|
|
29268
29404
|
while (true) {
|
|
29269
29405
|
const gitMarker = join15(current, ".git");
|
|
@@ -29363,7 +29499,7 @@ function getProjectRoot(cwd) {
|
|
|
29363
29499
|
}
|
|
29364
29500
|
return cleoDirEnv;
|
|
29365
29501
|
}
|
|
29366
|
-
const start =
|
|
29502
|
+
const start = resolve5(cwd ?? process.cwd());
|
|
29367
29503
|
let current = start;
|
|
29368
29504
|
const mainRepoFromStart = _resolveMainRepoFromGitlink(start);
|
|
29369
29505
|
if (mainRepoFromStart !== null) return mainRepoFromStart;
|
|
@@ -29456,7 +29592,7 @@ async function registerProjectOnEncounter(projectRoot, infoProjectId) {
|
|
|
29456
29592
|
const db = await getNexusDb2();
|
|
29457
29593
|
const existingRows = await db.select().from(projectRegistry2).where(eq2(projectRegistry2.projectId, immutableId)).limit(1);
|
|
29458
29594
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
29459
|
-
const resolvedPath =
|
|
29595
|
+
const resolvedPath = resolve5(projectRoot);
|
|
29460
29596
|
const projectName = _readProjectNameFromInfo(resolvedPath) || basename4(projectRoot) || "unnamed";
|
|
29461
29597
|
if (existingRows.length > 0) {
|
|
29462
29598
|
const existingPath = existingRows[0].projectPath;
|
|
@@ -33317,7 +33453,7 @@ function storedToResolved(stored) {
|
|
|
33317
33453
|
};
|
|
33318
33454
|
}
|
|
33319
33455
|
function sleep2(ms) {
|
|
33320
|
-
return new Promise((
|
|
33456
|
+
return new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
33321
33457
|
}
|
|
33322
33458
|
function backoffMs(policy, attempt) {
|
|
33323
33459
|
const base = policy.baseDelayMs * 2 ** attempt;
|
|
@@ -37211,7 +37347,7 @@ function normalizeOllamaToolCall(tc) {
|
|
|
37211
37347
|
};
|
|
37212
37348
|
}
|
|
37213
37349
|
function sleep3(ms) {
|
|
37214
|
-
return new Promise((
|
|
37350
|
+
return new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
37215
37351
|
}
|
|
37216
37352
|
var OLLAMA_DEFAULT_BASE_URL, MAX_RETRIES, INITIAL_BACKOFF_MS, RETRYABLE_STATUS_CODES, OllamaTransport;
|
|
37217
37353
|
var init_ollama2 = __esm({
|
|
@@ -57725,7 +57861,7 @@ function createProviderToolFactoryWithOutputSchema({
|
|
|
57725
57861
|
supportsDeferredResults
|
|
57726
57862
|
});
|
|
57727
57863
|
}
|
|
57728
|
-
async function
|
|
57864
|
+
async function resolve6(value) {
|
|
57729
57865
|
if (typeof value === "function") {
|
|
57730
57866
|
value = value();
|
|
57731
57867
|
}
|
|
@@ -61759,14 +61895,14 @@ var init_dist4 = __esm({
|
|
|
61759
61895
|
headers
|
|
61760
61896
|
}) {
|
|
61761
61897
|
return combineHeaders(
|
|
61762
|
-
await
|
|
61898
|
+
await resolve6(this.config.headers),
|
|
61763
61899
|
headers,
|
|
61764
61900
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
61765
61901
|
);
|
|
61766
61902
|
}
|
|
61767
61903
|
async getBetasFromHeaders(requestHeaders) {
|
|
61768
61904
|
var _a17, _b16;
|
|
61769
|
-
const configHeaders = await
|
|
61905
|
+
const configHeaders = await resolve6(this.config.headers);
|
|
61770
61906
|
const configBetaHeader = (_a17 = configHeaders["anthropic-beta"]) != null ? _a17 : "";
|
|
61771
61907
|
const requestBetaHeader = (_b16 = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b16 : "";
|
|
61772
61908
|
return new Set(
|