@lmzhen/dsh-evolution-core 0.46.0 → 0.47.0
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/lib/authority-plugin.js +1 -1
- package/lib/composition/index.js +3 -3
- package/lib/{composition-Da8NfRI7.js → composition-Cqjbho0t.js} +1 -1
- package/lib/{ensure-C5Mo1dbB.js → ensure-CAjLGd9f.js} +1 -2
- package/lib/http-routes.js +21 -96
- package/lib/index.js +26 -138
- package/lib/{io-AmUf4lVY.js → io-BCBSr6Ot.js} +1 -63
- package/lib/io-node.js +1 -1
- package/lib/io-registry.js +14 -29
- package/lib/{mutation-authority-DeJ_Wz14.js → mutation-authority-CM6wRgyK.js} +4 -14
- package/lib/{mutations-DwvbjRHF.js → mutations-DihgpfgG.js} +1 -1
- package/lib/runtime/plugin.js +1 -1
- package/lib/{session-projection-EB7mUOlJ.js → session-projection-BhlDXqws.js} +2 -2
- package/lib/{skill-health-D1pZGk5V.js → skill-health-BzkUQDi7.js} +3 -24
- package/lib/{skill-history-CjypdYqv.js → skill-history-RWt1-kbZ.js} +14 -54
- package/lib/skills.js +7 -7
- package/lib/subagent/index.js +4 -10
- package/lib/types/composition/preset-ids.d.ts +0 -1
- package/lib/types/composition/preset-ids.js +0 -1
- package/lib/types/curator.d.ts +0 -1
- package/lib/types/curator.js +0 -1
- package/lib/types/document-body.d.ts +0 -12
- package/lib/types/document-body.js +0 -14
- package/lib/types/http-routes.d.ts +9 -4
- package/lib/types/http-routes.js +36 -116
- package/lib/types/index.d.ts +0 -3
- package/lib/types/index.js +0 -3
- package/lib/types/io-registry.d.ts +11 -11
- package/lib/types/io-registry.js +13 -16
- package/lib/types/io.d.ts +0 -53
- package/lib/types/io.js +0 -56
- package/lib/types/journal-protocol.d.ts +0 -15
- package/lib/types/journal-protocol.js +1 -19
- package/lib/types/lease-store.d.ts +1 -1
- package/lib/types/lease-store.js +4 -15
- package/lib/types/live.d.ts +0 -12
- package/lib/types/live.js +0 -18
- package/lib/types/memory-store.d.ts +0 -1
- package/lib/types/memory-store.js +0 -1
- package/lib/types/mutation-unit.js +5 -4
- package/lib/types/probe.d.ts +0 -3
- package/lib/types/probe.js +0 -7
- package/lib/types/run-registry.js +10 -12
- package/lib/types/session-fold.d.ts +0 -8
- package/lib/types/session-fold.js +0 -5
- package/lib/types/session-projection.js +2 -2
- package/lib/types/skill-discovery.d.ts +0 -2
- package/lib/types/skill-discovery.js +1 -2
- package/lib/types/skill-history.d.ts +0 -24
- package/lib/types/skill-history.js +0 -41
- package/lib/types/skill-lint.d.ts +0 -3
- package/lib/types/skill-lint.js +0 -12
- package/lib/types/subagent/readiness.d.ts +0 -1
- package/lib/types/subagent/readiness.js +2 -8
- package/lib/types/unit-journal.d.ts +1 -1
- package/lib/types/unit-journal.js +2 -4
- package/lib/types/unit-storage.d.ts +1 -1
- package/lib/types/unit-storage.js +5 -16
- package/lib/write.js +2 -2
- package/package.json +1 -1
- package/persisted-write-inventory.json +47 -2
- package/lib/types/fold-untrusted.d.ts +0 -35
- package/lib/types/fold-untrusted.js +0 -44
- package/lib/types/unit-recovery.d.ts +0 -5
- package/lib/types/unit-recovery.js +0 -12
package/lib/authority-plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as evolutionHome, t as MutationAuthority } from "./mutation-authority-
|
|
1
|
+
import { c as evolutionHome, t as MutationAuthority } from "./mutation-authority-CM6wRgyK.js";
|
|
2
2
|
//#region lib/types/authority-plugin.js
|
|
3
3
|
const name = "evolution-authority";
|
|
4
4
|
const inject = ["evolutionIo"];
|
package/lib/composition/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as entryListSchema, c as MAINTAINER_PRESET_ID, d as
|
|
2
|
-
import { C as trimTrailingBlankLines, S as rowSiblingEnd, _ as presetRowId, a as composePresetComposition, b as resolveBasePresetPatch, c as composePresetRow, d as listDirectories, f as loadRowOverrides, g as presetRowBody, h as presetRowBlock, i as basePresetPlugins, l as compositionRowIds, m as presetPatchText, n as AGENT_PRESET_ROOT_HINT, o as composePresetEntry, p as mergePresetRow, r as EMPTY_PATCH_SEED, s as composePresetInsert, t as AGENT_PRESET_PACKAGE, u as denseBlockSequence, v as probeDesktopScope, x as rowBlockSpan, y as removePresetRow } from "../composition-
|
|
3
|
-
export { AGENT_PRESET_PACKAGE, AGENT_PRESET_ROOT_HINT, EMPTY_PATCH_SEED, EVOLUTION_PRESET_IDS, MAINTAINER_PRESET_ID,
|
|
1
|
+
import { a as entryListSchema, c as MAINTAINER_PRESET_ID, d as RESTRICTOR_MODULE, f as REVIEWER_PRESET_ID, i as composeRestrictedPresetDefinition, l as RESTRICTED_PRESET_DISPLAY, m as restrictedPresetId, n as ensureRestrictedPreset, o as parsePresetRows, p as normalizeAllow, r as restrictedPresetState, s as EVOLUTION_PRESET_IDS, t as disposeRestrictedPreset, u as RESTRICTED_TOOLS_ROW_ID } from "../ensure-CAjLGd9f.js";
|
|
2
|
+
import { C as trimTrailingBlankLines, S as rowSiblingEnd, _ as presetRowId, a as composePresetComposition, b as resolveBasePresetPatch, c as composePresetRow, d as listDirectories, f as loadRowOverrides, g as presetRowBody, h as presetRowBlock, i as basePresetPlugins, l as compositionRowIds, m as presetPatchText, n as AGENT_PRESET_ROOT_HINT, o as composePresetEntry, p as mergePresetRow, r as EMPTY_PATCH_SEED, s as composePresetInsert, t as AGENT_PRESET_PACKAGE, u as denseBlockSequence, v as probeDesktopScope, x as rowBlockSpan, y as removePresetRow } from "../composition-Cqjbho0t.js";
|
|
3
|
+
export { AGENT_PRESET_PACKAGE, AGENT_PRESET_ROOT_HINT, EMPTY_PATCH_SEED, EVOLUTION_PRESET_IDS, MAINTAINER_PRESET_ID, RESTRICTED_PRESET_DISPLAY, RESTRICTED_TOOLS_ROW_ID, RESTRICTOR_MODULE, REVIEWER_PRESET_ID, basePresetPlugins, composePresetComposition, composePresetEntry, composePresetInsert, composePresetRow, composeRestrictedPresetDefinition, compositionRowIds, denseBlockSequence, disposeRestrictedPreset, ensureRestrictedPreset, entryListSchema, listDirectories, loadRowOverrides, mergePresetRow, normalizeAllow, parsePresetRows, presetPatchText, presetRowBlock, presetRowBody, presetRowId, probeDesktopScope, removePresetRow, resolveBasePresetPatch, restrictedPresetId, restrictedPresetState, rowBlockSpan, rowSiblingEnd, trimTrailingBlankLines };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as scopedPackageName } from "./ensure-CAjLGd9f.js";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -59,7 +59,6 @@ const REVIEWER_PRESET_ID = "evolution-reviewer-readonly";
|
|
|
59
59
|
const MAINTAINER_PRESET_ID = "evolution-maintainer-readonly";
|
|
60
60
|
const RESTRICTED_TOOLS_ROW_ID = "evolution-restricted-tools";
|
|
61
61
|
const RESTRICTOR_MODULE = scopedPackageName("dsh-evolution-core/restrictor", import.meta.url);
|
|
62
|
-
const RESTRICTED_PRESET_DELIVERY = "runtime";
|
|
63
62
|
const RESTRICTED_PRESET_DISPLAY = {
|
|
64
63
|
reviewer: {
|
|
65
64
|
name: "evolution reviewer (read-only)",
|
|
@@ -212,4 +211,4 @@ async function disposeRestrictedPreset(ctx, kind) {
|
|
|
212
211
|
await releaseRestrictedPreset(ctx, kind);
|
|
213
212
|
}
|
|
214
213
|
//#endregion
|
|
215
|
-
export {
|
|
214
|
+
export { entryListSchema as a, MAINTAINER_PRESET_ID as c, RESTRICTOR_MODULE as d, REVIEWER_PRESET_ID as f, scopedPackageName as g, scopeOfNearestManifest as h, composeRestrictedPresetDefinition as i, RESTRICTED_PRESET_DISPLAY as l, restrictedPresetId as m, ensureRestrictedPreset as n, parsePresetRows as o, normalizeAllow as p, restrictedPresetState as r, EVOLUTION_PRESET_IDS as s, disposeRestrictedPreset as t, RESTRICTED_TOOLS_ROW_ID as u };
|
package/lib/http-routes.js
CHANGED
|
@@ -56,11 +56,7 @@ const HOST_ROUTES = {
|
|
|
56
56
|
body: "/api/dsh-evolution/merge/body",
|
|
57
57
|
history: "/api/dsh-evolution/merge/history"
|
|
58
58
|
},
|
|
59
|
-
diagnostics: { view: "/api/dsh-evolution/diagnostics" }
|
|
60
|
-
settings: {
|
|
61
|
-
describe: "/api/dsh-evolution/settings/describe",
|
|
62
|
-
mutate: "/api/dsh-evolution/settings/mutate"
|
|
63
|
-
}
|
|
59
|
+
diagnostics: { view: "/api/dsh-evolution/diagnostics" }
|
|
64
60
|
};
|
|
65
61
|
function hostSurface(ctx) {
|
|
66
62
|
const connection = ctx.get("connection");
|
|
@@ -74,74 +70,15 @@ function hostSurface(ctx) {
|
|
|
74
70
|
allowsRemoteAuthorities: connection.allowsRemoteAuthorities === true
|
|
75
71
|
};
|
|
76
72
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
} catch {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function nodeRoute(route) {
|
|
91
|
-
return {
|
|
92
|
-
kind: "exact",
|
|
93
|
-
path: route.path,
|
|
94
|
-
handler: async (req, res) => {
|
|
95
|
-
if (!isLoopback(req.socket.remoteAddress)) {
|
|
96
|
-
res.statusCode = 403;
|
|
97
|
-
res.end("forbidden");
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (!sameOrigin(req.headers.origin, req.headers.host)) {
|
|
101
|
-
res.statusCode = 403;
|
|
102
|
-
res.end("forbidden");
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const fetchSite = req.headers["sec-fetch-site"];
|
|
106
|
-
if (fetchSite !== void 0 && fetchSite !== "same-origin" && fetchSite !== "none") {
|
|
107
|
-
res.statusCode = 403;
|
|
108
|
-
res.end("forbidden");
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const method = req.method ?? "GET";
|
|
112
|
-
if (method !== "GET" && method !== "HEAD" && !(req.headers["content-type"] ?? "").toLowerCase().startsWith("application/json")) {
|
|
113
|
-
res.statusCode = 415;
|
|
114
|
-
res.end("json required");
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
try {
|
|
118
|
-
const chunks = [];
|
|
119
|
-
for await (const chunk of req) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
120
|
-
const headers = new Headers();
|
|
121
|
-
for (const [key, value] of Object.entries(req.headers)) {
|
|
122
|
-
if (value === void 0) continue;
|
|
123
|
-
headers.set(key, Array.isArray(value) ? value.join(",") : value);
|
|
124
|
-
}
|
|
125
|
-
const request = new Request(new URL(req.url ?? "/", "http://127.0.0.1"), {
|
|
126
|
-
method,
|
|
127
|
-
headers,
|
|
128
|
-
...method === "GET" || method === "HEAD" || chunks.length === 0 ? {} : { body: Buffer.concat(chunks) }
|
|
129
|
-
});
|
|
130
|
-
const response = await route.fetch(request);
|
|
131
|
-
res.statusCode = response.status;
|
|
132
|
-
response.headers.forEach((value, key) => {
|
|
133
|
-
try {
|
|
134
|
-
res.setHeader(key, value);
|
|
135
|
-
} catch {}
|
|
136
|
-
});
|
|
137
|
-
res.end(Buffer.from(await response.arrayBuffer()));
|
|
138
|
-
} catch (error) {
|
|
139
|
-
res.statusCode = 500;
|
|
140
|
-
res.end(error instanceof Error ? error.message : String(error));
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
73
|
+
/**
|
|
74
|
+
* Register the family host surface on the platform's exact-route carrier.
|
|
75
|
+
*
|
|
76
|
+
* The platform owns admission (Host/Origin hygiene + browserAuth + exact-route owner peer) and the
|
|
77
|
+
* disposer is bound to the CALLING fiber, not the connection service: the connection service can
|
|
78
|
+
* outlive a reloaded family fiber, so the family must release its own registrations on dispose.
|
|
79
|
+
* Routes carry the audit snapshot taken at registration time (deployment-level facts only — the
|
|
80
|
+
* exact-route handler receives a Request, not the peer identity).
|
|
81
|
+
*/
|
|
145
82
|
function registerHostRoutes(owner, build) {
|
|
146
83
|
const injecting = owner;
|
|
147
84
|
if (typeof injecting.inject !== "function") throw new Error("host routes require a context that owns inject()");
|
|
@@ -155,30 +92,18 @@ function registerHostRoutes(owner, build) {
|
|
|
155
92
|
for (const route of routes) if (!route.path.startsWith("/api/dsh-evolution/")) throw new Error("host route path must carry the /api/dsh-evolution/ prefix: " + route.path);
|
|
156
93
|
const effect = scope.effect;
|
|
157
94
|
if (typeof effect !== "function") throw new Error("connection scope has no effect() to own the registration");
|
|
158
|
-
if (connection?.fetch
|
|
159
|
-
|
|
160
|
-
effect.call(scope, () => {
|
|
161
|
-
const disposers = [];
|
|
162
|
-
try {
|
|
163
|
-
for (const route of routes) disposers.push(register(route));
|
|
164
|
-
} catch (error) {
|
|
165
|
-
for (const dispose of disposers) try {
|
|
166
|
-
dispose();
|
|
167
|
-
} catch {}
|
|
168
|
-
throw error;
|
|
169
|
-
}
|
|
170
|
-
return () => {
|
|
171
|
-
for (const dispose of disposers) try {
|
|
172
|
-
dispose();
|
|
173
|
-
} catch {}
|
|
174
|
-
};
|
|
175
|
-
}, "evolution-host-routes");
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
const web = scope.get?.("webServer") ?? owner.get?.("webServer");
|
|
179
|
-
if (web === void 0 || typeof web.register !== "function") throw new Error("connection service has no fetch.register(), and webServer is not mounted for the loopback host-route bridge");
|
|
95
|
+
if (connection?.fetch === void 0 || typeof connection.fetch.register !== "function") throw new Error("connection.fetch.register() is required to register family host routes (platform >= 0.2.2-rc.1); no fallback admission path exists");
|
|
96
|
+
const register = connection.fetch.register.bind(connection.fetch);
|
|
180
97
|
effect.call(scope, () => {
|
|
181
|
-
const disposers =
|
|
98
|
+
const disposers = [];
|
|
99
|
+
try {
|
|
100
|
+
for (const route of routes) disposers.push(register(route));
|
|
101
|
+
} catch (error) {
|
|
102
|
+
for (const dispose of disposers) try {
|
|
103
|
+
dispose();
|
|
104
|
+
} catch {}
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
182
107
|
return () => {
|
|
183
108
|
for (const dispose of disposers) try {
|
|
184
109
|
dispose();
|
package/lib/index.js
CHANGED
|
@@ -1,52 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as leaseFile, c as evolutionHome, d as AuthorityOrderError, f as AuthorityReentryError, h as leaseAsTreeLock, i as LeaseStore, l as evolutionRoot, m as authorityHolder, n as mutationLockFrom, o as HomeFence, p as HomeAuthority, r as DEFAULT_LEASE_TTL_MS, s as HomeFenceError, t as MutationAuthority, u as AuthorityBusyError } from "./mutation-authority-
|
|
3
|
-
import { A as countDispatches, B as supportFileReadFromPath, C as PTC_DISPATCH_EVENT, D as assertDispatchPayload, E as ToolDispatchPayloadError, F as isProgramToolName, G as KEEP_LINE_RE, H as CITATION_SUPPORT_DIRS, I as isSkillReadToolName, J as scanBodyHooks, K as isFileShapedPath, L as isSkillToolName, M as dispatchPathOf, N as dispatchStepOf, O as collectReadSkillNames, P as foldToolDispatches, R as readDispatchSignal, S as NATIVE_RESULT_EVENT, T as ToolDispatchNormalizer, U as DEFAULT_CITATION_REF_BUDGET, V as supportFileReadOf, W as HOOK_LINE_RE, _ as isBookkeepingFrame, a as evolutionSignalsProjection, b as MODEL_SESSION_EVENT_TYPES, c as sessionLastEventTime, d as advanceReview, f as foldTurnEvent, g as evidenceKindIndex, h as observeEvent, i as evolutionReadsProjection, j as dispatchKeyOf, k as collectReadSupportFiles, l as sessionReadNames, m as initialTurnFold, n as evolutionEvidenceProjection, o as isProjectableSession, p as foldTurnEvents, q as resolveCitations, r as evolutionProjectionHistoryProjection, s as sessionEvidenceIndex, t as evolutionActivityProjection, u as sessionTurnSignals, v as DEFAULT_SUPPORT_READ_TOOL_NAMES, w as PTC_DISPATCH_START_EVENT, x as NATIVE_CALL_EVENT, y as DISPATCH_EVENT_TYPES, z as skillReadNameOf } from "./session-projection-
|
|
1
|
+
import { _ as probePresent, a as nodeEvolutionIo, b as probeUnknown, c as writeDurableTmp, d as isMissingPath, f as isPresent, g as probeMtime, h as probeList, i as isProcessAlive, l as declaredReportStamp, m as probeAbsent, n as evolutionIoAdapter, o as renameWithRetry, p as isUnknown, r as isCommittedWarning, s as transactIo, t as atomicWriteFiles, u as isAbsent, v as probeReason, x as reportTime, y as probeText } from "./io-BCBSr6Ot.js";
|
|
2
|
+
import { a as leaseFile, c as evolutionHome, d as AuthorityOrderError, f as AuthorityReentryError, h as leaseAsTreeLock, i as LeaseStore, l as evolutionRoot, m as authorityHolder, n as mutationLockFrom, o as HomeFence, p as HomeAuthority, r as DEFAULT_LEASE_TTL_MS, s as HomeFenceError, t as MutationAuthority, u as AuthorityBusyError } from "./mutation-authority-CM6wRgyK.js";
|
|
3
|
+
import { A as countDispatches, B as supportFileReadFromPath, C as PTC_DISPATCH_EVENT, D as assertDispatchPayload, E as ToolDispatchPayloadError, F as isProgramToolName, G as KEEP_LINE_RE, H as CITATION_SUPPORT_DIRS, I as isSkillReadToolName, J as scanBodyHooks, K as isFileShapedPath, L as isSkillToolName, M as dispatchPathOf, N as dispatchStepOf, O as collectReadSkillNames, P as foldToolDispatches, R as readDispatchSignal, S as NATIVE_RESULT_EVENT, T as ToolDispatchNormalizer, U as DEFAULT_CITATION_REF_BUDGET, V as supportFileReadOf, W as HOOK_LINE_RE, _ as isBookkeepingFrame, a as evolutionSignalsProjection, b as MODEL_SESSION_EVENT_TYPES, c as sessionLastEventTime, d as advanceReview, f as foldTurnEvent, g as evidenceKindIndex, h as observeEvent, i as evolutionReadsProjection, j as dispatchKeyOf, k as collectReadSupportFiles, l as sessionReadNames, m as initialTurnFold, n as evolutionEvidenceProjection, o as isProjectableSession, p as foldTurnEvents, q as resolveCitations, r as evolutionProjectionHistoryProjection, s as sessionEvidenceIndex, t as evolutionActivityProjection, u as sessionTurnSignals, v as DEFAULT_SUPPORT_READ_TOOL_NAMES, w as PTC_DISPATCH_START_EVENT, x as NATIVE_CALL_EVENT, y as DISPATCH_EVENT_TYPES, z as skillReadNameOf } from "./session-projection-BhlDXqws.js";
|
|
4
4
|
import { $ as UPSTREAM_LIMIT_CHARS_PER_TOKEN, A as DEFAULT_STALE_AFTER_DAYS, B as MAX_SKILL_CONTENT_CHARS, C as DEFAULT_REVIEW_MESSAGE_CHARS, D as DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, E as DEFAULT_SKILL_CONTENT_CHARS, F as DEFAULT_USER_CHAR_LIMIT, G as PLATFORM_CATALOG_DESCRIPTION_DEFAULT, H as MAX_SKILL_NAME_LENGTH, I as ENTRY_DELIMITER, J as SKILLS_GUIDANCE_SECTION_ORDER, K as PLATFORM_ESTIMATE_CHARS_PER_TOKEN, L as EVOLUTION_WRITE_TOOLS, M as DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, N as DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, O as DEFAULT_SKILL_REVIEW_TRIGGER, P as DEFAULT_THREAT_MAX_SCAN_CHARS, Q as SUPPORT_SPRAWL_FILES, R as FORBIDDEN_CONTROL_KEYS, S as DEFAULT_REVIEW_MEMORY_INTERVAL, T as DEFAULT_REVIEW_TIMEOUT_MS, U as MAX_TIMER_DELAY_MS, V as MAX_SKILL_FILE_BYTES, W as MEMORY_GUIDANCE_SECTION_ORDER, X as SKILL_NAME_RE, Y as SKILL_ACTION_REQUIRED_FIELDS, Z as SUPPORT_DIRS, _ as DEFAULT_CURATOR_REVIEW_MAX_TOKENS, a as DEFAULT_SKILL_LIMITS, b as DEFAULT_PROBE_TIMEOUT_MS, c as policyStageLimits, d as CONTENT_SPLIT_HINT, f as DEFAULT_ARCHIVE_AFTER_DAYS, g as DEFAULT_CURATOR_MODEL, h as DEFAULT_CURATOR_INTERVAL_HOURS, i as DEFAULT_REFERENCE_REWRITE_POLICY, j as DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, k as DEFAULT_SKILL_VERSION_KEEP, l as AUTHORING_DESCRIPTION_BAR, m as DEFAULT_CURATOR_BOOT_GRACE_SECONDS, n as DEFAULT_ARCHIVE_RETENTION_POLICY, o as DEFAULT_SUPPORT_FILE_CHAR_POLICY, p as DEFAULT_CONSOLIDATION_FAILURES, q as PROTECTED_BUILTIN_SKILLS, r as DEFAULT_CITATION_POLICY, s as POLICY_STAGE_DEFAULTS, t as clampedNumber, u as AUTHORING_SPLIT_LINE_CHARS, v as DEFAULT_MEMORY_CHAR_LIMIT, w as DEFAULT_REVIEW_SKILL_INTERVAL, x as DEFAULT_REVIEW_CONTEXT_MESSAGES, y as DEFAULT_MIN_IDLE_HOURS, z as MAX_DESCRIPTION_LENGTH } from "./numeric-DLeLvvGb.js";
|
|
5
|
-
import {
|
|
6
|
-
import { $ as
|
|
5
|
+
import { c as MAINTAINER_PRESET_ID, d as RESTRICTOR_MODULE, f as REVIEWER_PRESET_ID, g as scopedPackageName, h as scopeOfNearestManifest, l as RESTRICTED_PRESET_DISPLAY, s as EVOLUTION_PRESET_IDS, u as RESTRICTED_TOOLS_ROW_ID } from "./ensure-CAjLGd9f.js";
|
|
6
|
+
import { $ as bumpView, A as listEventArchives, B as COST_CJK_TOKEN_HIGH, Bt as planRehoming, C as EVENT_ARCHIVE_PREFIX, D as appendEvolutionEvent, E as EVENT_LOG_VERSION, F as RULES, Ft as externalRefs, G as tokenLineFor, H as TOKEN_ASCII_WEIGHT, It as supportRefs, J as applyCuratorLifecycleFields, Jt as authorityFrom, K as MAX_SUPPORT_READ_PATHS, Kt as DEFAULT_WRITE_CONFIRM_MODE, L as lintSkill, Lt as applyReferenceRewrite, M as readEvolutionEvents, N as readEvolutionTimeline, O as eventsFile, P as retainEventArchives, Q as bumpUse, R as COST_ASCII_TOKEN_HIGH, Rt as describeReferenceRewrite, S as trimPatternBoundaries, St as readingStats, T as EVENT_LOG_ROTATE_AT, U as TOKEN_CJK_WEIGHT, Ut as isUnreadWrite, V as COST_CJK_TOKEN_LOW, W as bodyCost, X as bumpPatch, Y as applyCuratorMetaFields, Z as bumpSupportRead, _ as scanThreats, _t as planExtract, at as latestActivityAt, b as FUZZY_MAX_WORK, bt as displayBodyOf, c as clearReviewChannel, ct as markAgentCreated, d as sweepReviewChannelSessions, dt as saveSuppressedNames, et as daysSinceIso, f as PATTERN_OVERLAP, ft as saveUsage, g as scanMemoryThreats, gt as usageObserved, h as scanContentThreats, ht as usageFile, i as assessStructureHealth, it as idleDays, j as parseEvolutionEvents, k as evolutionEventPayloadIssue, kt as parseFrontmatter, l as isReviewChannelSession, lt as mutateUsage, m as evaluateThreat, mt as updateSuppressedNames, nt as foldCuratorFields, o as currentReviewContext, ot as loadSuppressedNames, p as THREAT_EXEMPTION_HINT, pt as suppressedFile, q as SUPPRESSED_FILE_VERSION, qt as DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, rt as getRecord, s as withReviewContext, st as loadUsage, t as DEFAULT_HEALTH_THRESHOLDS, tt as emptyRecord, u as markReviewChannel, ut as normalizeUsageRecord, v as makeSerialQueue, vt as projectExtractBodies, w as EVENT_LOG_RETAIN_ARCHIVES, x as fuzzyPatch, xt as h2Sections, y as FUZZY_MAX_PATTERN_CHARS, yt as selectSections, z as COST_ASCII_TOKEN_LOW, zt as planReferenceRewrite } from "./skill-health-BzkUQDi7.js";
|
|
7
7
|
import { i as HOST_LOCALES, n as errorText, r as errorTextIn, t as EVOLUTION_ERRORS } from "./errors-BxzLTVbS.js";
|
|
8
8
|
import { n as isRecord, t as asRecord } from "./guards-3f02mnf2.js";
|
|
9
|
-
import { a as mutationsFile, i as loadMutations, n as MUTATIONS_FILE_VERSION, o as recordMutation, r as contentHash, t as DEFAULT_MUTATION_CAP } from "./mutations-
|
|
9
|
+
import { a as mutationsFile, i as loadMutations, n as MUTATIONS_FILE_VERSION, o as recordMutation, r as contentHash, t as DEFAULT_MUTATION_CAP } from "./mutations-DihgpfgG.js";
|
|
10
10
|
import { HOST_ROUTES, MAX_REQUEST_BODY_BYTES, hostSurface, json, methodNotAllowed, readJsonObject, registerHostRoutes } from "./http-routes.js";
|
|
11
|
-
import { w as allowRowCollisions } from "./composition-
|
|
11
|
+
import { w as allowRowCollisions } from "./composition-Cqjbho0t.js";
|
|
12
12
|
import { u as scopeOf } from "./platform-CFA12Jam.js";
|
|
13
|
-
import { createSubagentChannel, probeChannelState
|
|
13
|
+
import { createSubagentChannel, probeChannelState } from "./subagent/index.js";
|
|
14
14
|
import { readFile, realpath, stat } from "node:fs/promises";
|
|
15
15
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
16
16
|
import { readFileSync } from "node:fs";
|
|
17
17
|
import { createHash, randomUUID } from "node:crypto";
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
19
|
import { parse } from "yaml";
|
|
20
|
-
//#region lib/types/journal-protocol.js
|
|
21
|
-
/**
|
|
22
|
-
* A journal protocol: the phases one multi-write operation records, which transitions it allows, and
|
|
23
|
-
* what a restart may do from each phase (W9-commit-protocol §3.1).
|
|
24
|
-
*
|
|
25
|
-
* The commit and undo journals used to disagree: commit had a transition table and a recovery
|
|
26
|
-
* decision but only reported it, while undo wrote a journal nobody read. Both now describe the same
|
|
27
|
-
* shape, so a resumer can be written once against `JournalProtocol` instead of per operation.
|
|
28
|
-
* @module @lmzhen/dsh-evolution-core/journal-protocol
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* True when `from` may advance to `to`.
|
|
32
|
-
* @param protocol - the journal's protocol.
|
|
33
|
-
* @param from - the recorded phase.
|
|
34
|
-
* @param to - the phase the caller wants to record next.
|
|
35
|
-
* @returns whether the transition is declared.
|
|
36
|
-
*/
|
|
37
|
-
function canAdvance(protocol, from, to) {
|
|
38
|
-
return protocol.next[from].includes(to);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* True when the phase is terminal (nothing may follow it).
|
|
42
|
-
* @param protocol - the journal's protocol.
|
|
43
|
-
* @param phase - the phase to test.
|
|
44
|
-
* @returns whether the phase is terminal.
|
|
45
|
-
*/
|
|
46
|
-
function isTerminal(protocol, phase) {
|
|
47
|
-
return protocol.next[phase].length === 0;
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
20
|
//#region lib/types/tree-write.js
|
|
51
21
|
/**
|
|
52
22
|
* G1/1.5 (S7-09): the TYPED critical section around a tree write.
|
|
@@ -2782,6 +2752,20 @@ function newRunRegistry(options) {
|
|
|
2782
2752
|
}
|
|
2783
2753
|
return [...live, ...[...perKind.values()].flat()].sort((a, b) => b.startedAt - a.startedAt);
|
|
2784
2754
|
};
|
|
2755
|
+
/** One serialization for every run-index write (live first, then terminal, then foreign rows). */
|
|
2756
|
+
const serializeIndex = (records, foreignRows) => {
|
|
2757
|
+
const kept = capped(records);
|
|
2758
|
+
const live = kept.filter((row) => row.state === "running");
|
|
2759
|
+
const done = kept.filter((row) => TERMINAL.has(row.state));
|
|
2760
|
+
return JSON.stringify({
|
|
2761
|
+
schemaVersion: 2,
|
|
2762
|
+
runs: [
|
|
2763
|
+
...live,
|
|
2764
|
+
...done,
|
|
2765
|
+
...foreignRows
|
|
2766
|
+
]
|
|
2767
|
+
}, null, 2);
|
|
2768
|
+
};
|
|
2785
2769
|
/**
|
|
2786
2770
|
* Update a surviving foreign row in place (identity stable), or add it.
|
|
2787
2771
|
*
|
|
@@ -2822,17 +2806,7 @@ function newRunRegistry(options) {
|
|
|
2822
2806
|
if (TERMINAL.has(row.state) && onDiskRow !== void 0 && !TERMINAL.has(onDiskRow.state)) merged.set(id, row);
|
|
2823
2807
|
}
|
|
2824
2808
|
for (const [id, row] of merged) if (row.state === "running" && !owned.has(id) && ownerIsGone(row)) merged.set(id, orphanOf(row));
|
|
2825
|
-
|
|
2826
|
-
const live = kept.filter((row) => row.state === "running");
|
|
2827
|
-
const done = kept.filter((row) => TERMINAL.has(row.state));
|
|
2828
|
-
return JSON.stringify({
|
|
2829
|
-
schemaVersion: 2,
|
|
2830
|
-
runs: [
|
|
2831
|
-
...live,
|
|
2832
|
-
...done,
|
|
2833
|
-
...onDisk.foreign
|
|
2834
|
-
]
|
|
2835
|
-
}, null, 2);
|
|
2809
|
+
return serializeIndex([...merged.values()], onDisk.foreign);
|
|
2836
2810
|
});
|
|
2837
2811
|
} catch (error) {
|
|
2838
2812
|
warn(`evolution-core: could not persist the run index (${error instanceof Error ? error.message : String(error)})`);
|
|
@@ -2970,17 +2944,7 @@ function newRunRegistry(options) {
|
|
|
2970
2944
|
row.supersededAt = now();
|
|
2971
2945
|
marked += 1;
|
|
2972
2946
|
}
|
|
2973
|
-
|
|
2974
|
-
const live = kept.filter((row) => row.state === "running");
|
|
2975
|
-
const done = kept.filter((row) => TERMINAL.has(row.state));
|
|
2976
|
-
return JSON.stringify({
|
|
2977
|
-
schemaVersion: 2,
|
|
2978
|
-
runs: [
|
|
2979
|
-
...live,
|
|
2980
|
-
...done,
|
|
2981
|
-
...onDisk.foreign
|
|
2982
|
-
]
|
|
2983
|
-
}, null, 2);
|
|
2947
|
+
return serializeIndex([...merged.values()], onDisk.foreign);
|
|
2984
2948
|
});
|
|
2985
2949
|
return marked;
|
|
2986
2950
|
},
|
|
@@ -3013,17 +2977,7 @@ function newRunRegistry(options) {
|
|
|
3013
2977
|
...outcome.resultRef === void 0 ? {} : { resultRef: outcome.resultRef },
|
|
3014
2978
|
...outcome.failure === void 0 ? {} : { failure: outcome.failure }
|
|
3015
2979
|
};
|
|
3016
|
-
|
|
3017
|
-
const live = kept.filter((item) => item.state === "running");
|
|
3018
|
-
const done = kept.filter((item) => TERMINAL.has(item.state));
|
|
3019
|
-
return JSON.stringify({
|
|
3020
|
-
schemaVersion: 2,
|
|
3021
|
-
runs: [
|
|
3022
|
-
...live,
|
|
3023
|
-
...done,
|
|
3024
|
-
...onDisk.foreign
|
|
3025
|
-
]
|
|
3026
|
-
}, null, 2);
|
|
2980
|
+
return serializeIndex(onDisk.records.map((item) => item.id === id ? next : item), onDisk.foreign);
|
|
3027
2981
|
});
|
|
3028
2982
|
if (changed) await this.load();
|
|
3029
2983
|
return changed;
|
|
@@ -5997,24 +5951,6 @@ function clampOnce(warned, warn, name, value, fallback, min, max) {
|
|
|
5997
5951
|
function liveBool(value, fallback = false) {
|
|
5998
5952
|
return unwrapLive(value) ?? fallback;
|
|
5999
5953
|
}
|
|
6000
|
-
/**
|
|
6001
|
-
* Read a string (live or plain). Blank/whitespace counts as unset — the same rule `evolutionRoot` uses
|
|
6002
|
-
* for `DSH_HOME`.
|
|
6003
|
-
*/
|
|
6004
|
-
function liveString(value, fallback) {
|
|
6005
|
-
const current = unwrapLive(value)?.trim();
|
|
6006
|
-
return current === void 0 || current.length === 0 ? fallback : current;
|
|
6007
|
-
}
|
|
6008
|
-
/**
|
|
6009
|
-
* Read an enumerated string (live or plain); a value outside `allowed` falls back.
|
|
6010
|
-
*
|
|
6011
|
-
* Used for the mode-like knobs (review mode, trigger, citation policy, write-confirm mode) where a
|
|
6012
|
-
* bare `?? default` would accept a typo the schema never saw.
|
|
6013
|
-
*/
|
|
6014
|
-
function liveEnum(value, allowed, fallback) {
|
|
6015
|
-
const current = unwrapLive(value);
|
|
6016
|
-
return current !== void 0 && allowed.includes(current) ? current : fallback;
|
|
6017
|
-
}
|
|
6018
5954
|
//#endregion
|
|
6019
5955
|
//#region lib/types/opt-in.js
|
|
6020
5956
|
/**
|
|
@@ -6112,50 +6048,6 @@ function sessionAudited(ctx, sessionId, sessionScoped) {
|
|
|
6112
6048
|
return false;
|
|
6113
6049
|
}
|
|
6114
6050
|
//#endregion
|
|
6115
|
-
//#region lib/types/fold-untrusted.js
|
|
6116
|
-
/**
|
|
6117
|
-
* Untrusted text rendered as prompt lines (T3-03/A31) — ONE folding rule.
|
|
6118
|
-
*
|
|
6119
|
-
* The background-review digest embeds conversation text and tool output into a
|
|
6120
|
-
* plain-text prompt whose PRODUCT is a plan with write permission. Anything the
|
|
6121
|
-
* session ingested (a fetched page, a file body, command output) can therefore
|
|
6122
|
-
* carry a newline plus a line shaped like the prompt's own structure — a
|
|
6123
|
-
* `SYSTEM:`/`Review kind:` header, a `[result]` evidence line, a second copy
|
|
6124
|
-
* of the closing instruction — and forge structure or inject instructions.
|
|
6125
|
-
*
|
|
6126
|
-
* FOLDING, not deleting: the reader (the model) must still SEE what the data
|
|
6127
|
-
* said, it just must never become structure. Line separators become a visible
|
|
6128
|
-
* `⏎`, and a line that would read as a role/evidence header gets a visible
|
|
6129
|
-
* marker in front of it. Every original character stays in place.
|
|
6130
|
-
*
|
|
6131
|
-
* The boundary is the separator itself, not only a real newline: a payload can
|
|
6132
|
-
* paste the separator verbatim, so neutralization matches after `⏎` whether it
|
|
6133
|
-
* came from the fold or from the data. Both edits are idempotent (a second pass
|
|
6134
|
-
* cannot add a second marker).
|
|
6135
|
-
*
|
|
6136
|
-
* Scope: text rendered as its OWN line(s) of a prompt. `render-facts`'
|
|
6137
|
-
* sanitizer (evolution-maintenance) is the same posture for `key=value` fields
|
|
6138
|
-
* and additionally escapes its block delimiter; it is not superseded here.
|
|
6139
|
-
* @module @lmzhen/dsh-evolution-core
|
|
6140
|
-
*/
|
|
6141
|
-
/** Visible stand-in for a folded line separator: one character that cannot be read as line structure. */
|
|
6142
|
-
const UNTRUSTED_LINE_BREAK = " ⏎ ";
|
|
6143
|
-
/** Visible marker prefixed to a line that would otherwise read as a role/structure header. */
|
|
6144
|
-
const UNTRUSTED_LINE_MARK = "· ";
|
|
6145
|
-
const NEWLINES = /\r\n|\r|\n/g;
|
|
6146
|
-
/** A line that reads as structure: a `Label:` head (SYSTEM:, Review kind:, Signals:) or a digest evidence tag.
|
|
6147
|
-
* The head is case-TOLERANT on purpose: this family's own prompt labels are mixed case, so an
|
|
6148
|
-
* uppercase-only rule neutralized SYSTEM: while leaving a forged "Review kind:" untouched. */
|
|
6149
|
-
const STRUCTURAL_HEAD = /(^|⏎)([ \t]*)((?:[A-Za-z][A-Za-z0-9 _]{2,}:|\[result\]|\[call\]))/g;
|
|
6150
|
-
/**
|
|
6151
|
-
* Fold untrusted `text` so it cannot become structure, then bound it to `limit`
|
|
6152
|
-
* visible characters. A non-positive `limit` means "no truncation".
|
|
6153
|
-
*/
|
|
6154
|
-
function foldUntrustedLines(text, limit) {
|
|
6155
|
-
const marked = text.replace(NEWLINES, UNTRUSTED_LINE_BREAK).replace(STRUCTURAL_HEAD, (_match, boundary, spaces, head) => `${boundary}${spaces}· ${head}`);
|
|
6156
|
-
return limit > 0 ? marked.slice(0, limit) : marked;
|
|
6157
|
-
}
|
|
6158
|
-
//#endregion
|
|
6159
6051
|
//#region lib/types/diagnostics.js
|
|
6160
6052
|
const DIAGNOSTICS_VIEW_SCHEMA_VERSION = 2;
|
|
6161
6053
|
const DIAGNOSTICS_FACT_KEYS = [
|
|
@@ -6198,9 +6090,5 @@ function classifySessionEvent(event) {
|
|
|
6198
6090
|
if (type.startsWith("plugin:")) return event.ignorable === true ? "plugin-record" : "unknown";
|
|
6199
6091
|
return MODEL_EVENT_TYPES.has(type) ? "model" : "unknown";
|
|
6200
6092
|
}
|
|
6201
|
-
/** True when the event must be skipped by evidence/usage readers (tolerant, never fatal). */
|
|
6202
|
-
function isIgnorableEvent(event) {
|
|
6203
|
-
return classifySessionEvent(event) !== "model";
|
|
6204
|
-
}
|
|
6205
6093
|
//#endregion
|
|
6206
|
-
export { AUTHORING_DESCRIPTION_BAR, AUTHORING_SPLIT_LINE_CHARS, AuthorityBusyError, AuthorityOrderError, AuthorityReentryError, CITATION_SUPPORT_DIRS, COMBINED_REVIEW_PROMPT, COMPLETION_SKILL_REVIEW_PROMPT, CONTENT_SPLIT_HINT, COST_ASCII_TOKEN_HIGH, COST_ASCII_TOKEN_LOW, COST_CJK_TOKEN_HIGH, COST_CJK_TOKEN_LOW, CURATOR_DRY_RUN_BANNER, CURATOR_PROMPT, DEDUP_MAX_PAIR_COMPARISONS, DEDUP_SIMILARITY_THRESHOLD, DEFAULT_ADMISSION, DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_CITATION_REF_BUDGET, DEFAULT_CONSOLIDATION_FAILURES, DEFAULT_CURATOR_BOOT_GRACE_SECONDS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_CURATOR_MODEL, DEFAULT_CURATOR_REVIEW_MAX_TOKENS, DEFAULT_LEASE_TTL_MS, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_MIN_IDLE_HOURS, DEFAULT_MUTATION_CAP, DEFAULT_PROBE_TIMEOUT_MS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_REVIEW_CONTEXT_MESSAGES, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_MESSAGE_CHARS, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_RUN_RECORDS, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_SKILL_VERSION_KEEP, DEFAULT_STALE_AFTER_DAYS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_SUPPORT_FILE_CHAR_POLICY, DEFAULT_SUPPORT_READ_TOOL_NAMES, DEFAULT_THREAT_MAX_SCAN_CHARS, DEFAULT_USER_CHAR_LIMIT, DEFAULT_WRITE_CONFIRM_MODE, DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, DIAGNOSTICS_FACT_KEYS, DIAGNOSTICS_RUNTIME_KEYS, DIAGNOSTICS_VIEW_SCHEMA_VERSION, DISPATCH_EVENT_TYPES, DRIFT_MAX_LINE_CHARS, DRIFT_SIGNALS_VERSION, DRIFT_SIGNAL_NOUNS, DSH_AUTHORING_STANDARDS, ENTRY_DELIMITER, EVENT_ARCHIVE_PREFIX, EVENT_LOG_RETAIN_ARCHIVES, EVENT_LOG_ROTATE_AT, EVENT_LOG_VERSION, EVOLUTION_ERRORS, EVOLUTION_PRESET_IDS, EVOLUTION_WRITE_TOOLS, EXTRACT_PROMPT_HASH, EXTRACT_PROMPT_V1, EXTRACT_PROMPT_VERSION, EvolutionGateSet, FAMILY_SESSION_TOOL_NAMES, FORBIDDEN_CONTROL_KEYS, FUZZY_MAX_PATTERN_CHARS, FUZZY_MAX_WORK, HOOK_LINE_RE, HOST_LOCALES, HOST_ROUTES, HomeAuthority, HomeFence, HomeFenceError, INJECT_COMBINED_REVIEW_PROMPT, INJECT_COMPLETION_SKILL_REVIEW_PROMPT, INJECT_MEMORY_REVIEW_PROMPT, INJECT_SKILL_REVIEW_PROMPT, INSTANCE_KEYS, KEEP_LINE_RE, LONG_RUNS, LOW_QUALITY_THRESHOLD, LeaseStore, MAINTAINER_PRESET_ID, MAINTAIN_OUTPUT_INSTRUCTION, MAINTAIN_PROMPT, MAX_DESCRIPTION_LENGTH, MAX_REQUEST_BODY_BYTES, MAX_SKILL_CONTENT_CHARS, MAX_SKILL_FILE_BYTES, MAX_SKILL_NAME_LENGTH, MAX_SUPPORT_READ_PATHS, MAX_TIMER_DELAY_MS, MEMORY_GUIDANCE_SECTION_ORDER, MEMORY_REVIEW_PROMPT, MODEL_SESSION_EVENT_TYPES
|
|
6094
|
+
export { AUTHORING_DESCRIPTION_BAR, AUTHORING_SPLIT_LINE_CHARS, AuthorityBusyError, AuthorityOrderError, AuthorityReentryError, CITATION_SUPPORT_DIRS, COMBINED_REVIEW_PROMPT, COMPLETION_SKILL_REVIEW_PROMPT, CONTENT_SPLIT_HINT, COST_ASCII_TOKEN_HIGH, COST_ASCII_TOKEN_LOW, COST_CJK_TOKEN_HIGH, COST_CJK_TOKEN_LOW, CURATOR_DRY_RUN_BANNER, CURATOR_PROMPT, DEDUP_MAX_PAIR_COMPARISONS, DEDUP_SIMILARITY_THRESHOLD, DEFAULT_ADMISSION, DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_CITATION_REF_BUDGET, DEFAULT_CONSOLIDATION_FAILURES, DEFAULT_CURATOR_BOOT_GRACE_SECONDS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_CURATOR_MODEL, DEFAULT_CURATOR_REVIEW_MAX_TOKENS, DEFAULT_LEASE_TTL_MS, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_MIN_IDLE_HOURS, DEFAULT_MUTATION_CAP, DEFAULT_PROBE_TIMEOUT_MS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_REVIEW_CONTEXT_MESSAGES, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_MESSAGE_CHARS, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_RUN_RECORDS, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_SKILL_VERSION_KEEP, DEFAULT_STALE_AFTER_DAYS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_SUPPORT_FILE_CHAR_POLICY, DEFAULT_SUPPORT_READ_TOOL_NAMES, DEFAULT_THREAT_MAX_SCAN_CHARS, DEFAULT_USER_CHAR_LIMIT, DEFAULT_WRITE_CONFIRM_MODE, DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, DIAGNOSTICS_FACT_KEYS, DIAGNOSTICS_RUNTIME_KEYS, DIAGNOSTICS_VIEW_SCHEMA_VERSION, DISPATCH_EVENT_TYPES, DRIFT_MAX_LINE_CHARS, DRIFT_SIGNALS_VERSION, DRIFT_SIGNAL_NOUNS, DSH_AUTHORING_STANDARDS, ENTRY_DELIMITER, EVENT_ARCHIVE_PREFIX, EVENT_LOG_RETAIN_ARCHIVES, EVENT_LOG_ROTATE_AT, EVENT_LOG_VERSION, EVOLUTION_ERRORS, EVOLUTION_PRESET_IDS, EVOLUTION_WRITE_TOOLS, EXTRACT_PROMPT_HASH, EXTRACT_PROMPT_V1, EXTRACT_PROMPT_VERSION, EvolutionGateSet, FAMILY_SESSION_TOOL_NAMES, FORBIDDEN_CONTROL_KEYS, FUZZY_MAX_PATTERN_CHARS, FUZZY_MAX_WORK, HOOK_LINE_RE, HOST_LOCALES, HOST_ROUTES, HomeAuthority, HomeFence, HomeFenceError, INJECT_COMBINED_REVIEW_PROMPT, INJECT_COMPLETION_SKILL_REVIEW_PROMPT, INJECT_MEMORY_REVIEW_PROMPT, INJECT_SKILL_REVIEW_PROMPT, INSTANCE_KEYS, KEEP_LINE_RE, LONG_RUNS, LOW_QUALITY_THRESHOLD, LeaseStore, MAINTAINER_PRESET_ID, MAINTAIN_OUTPUT_INSTRUCTION, MAINTAIN_PROMPT, MAX_DESCRIPTION_LENGTH, MAX_REQUEST_BODY_BYTES, MAX_SKILL_CONTENT_CHARS, MAX_SKILL_FILE_BYTES, MAX_SKILL_NAME_LENGTH, MAX_SUPPORT_READ_PATHS, MAX_TIMER_DELAY_MS, MEMORY_GUIDANCE_SECTION_ORDER, MEMORY_REVIEW_PROMPT, MODEL_SESSION_EVENT_TYPES, MUTATIONS_FILE_VERSION, MemoryStore, MutationAuthority, NAMESPACE_MIGRATIONS, NATIVE_CALL_EVENT, NATIVE_RESULT_EVENT, PARAM_ALIASES, PARAM_EXPOSURE, PARAM_GROUP_LABELS, PARAM_NAMESPACES, PATTERN_OVERLAP, PLATFORM_CATALOG_DESCRIPTION_DEFAULT, PLATFORM_ESTIMATE_CHARS_PER_TOKEN, PLATFORM_LINE, PLATFORM_SERVICE_PROBES, POLICY_STAGE_DEFAULTS, PROMPT_BUNDLE, PROMPT_BUNDLE_ID, PROMPT_BUNDLE_VERSION, PROTECTED_BUILTIN_SKILLS, PTC_DISPATCH_EVENT, PTC_DISPATCH_START_EVENT, QUALITY_WEIGHTS, RESTRICTED_PRESET_DISPLAY, RESTRICTED_TOOLS_ROW_ID, RESTRICTOR_MODULE, REVIEWER_PRESET_ID, RUNS_SCHEMA_VERSION, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, SKILL_NAME_RE, SKILL_REVIEW_PROMPT, STORE_LEDGER, SUMMARY_DUPLICATE_HINT_THRESHOLD, SUPPORT_DIRS, SUPPORT_SPRAWL_FILES, SUPPRESSED_FILE_VERSION, THREAT_EXEMPTION_HINT, TOKEN_ASCII_WEIGHT, TOKEN_CJK_WEIGHT, ToolDispatchNormalizer, ToolDispatchPayloadError, UPSTREAM_LIMIT_CHARS_PER_TOKEN, absentHostServices, admissionVerdict, advanceReview, affinity, allowRowCollisions, appendEvolutionEvent, applyCuratorLifecycleFields, applyCuratorMetaFields, applyNamespaceMigration, applyReferenceRewrite, asRecord, assertDispatchPayload, atomicWriteFiles, authorityFrom, authorityHolder, backupsReachability, bodyCost, buildCuratorRunReport, buildExtractPlanFromLibrary, buildHealthBaseline, buildLearnPrompt, bumpPatch, bumpSupportRead, bumpUse, bumpView, callingScope, canonicalWriteId, claimInstance, clampOnce, clampedNumber, classifyNamespaceMigration, classifySessionEvent, clearReviewChannel, collectReadSkillNames, collectReadSupportFiles, computeDedupGroups, computeDriftSignals, computeLifecycleTransitions, computePrefixClusters, computeQualityScores, computeScopeView, contentHash, countDispatches, createGateSet, createSubagentChannel, currentReviewContext, daysSinceIso, declaredReportStamp, describeReferenceRewrite, dispatchKeyOf, dispatchPathOf, dispatchStepOf, displayBodyOf, duplicateHeadings, emptyRecord, errorText, errorTextIn, evaluateThreat, eventsFile, evidenceKindIndex, evolutionActivityProjection, evolutionEventPayloadIssue, evolutionEvidenceProjection, evolutionHome, evolutionIoAdapter, evolutionProjectionHistoryProjection, evolutionReadsProjection, evolutionRoot, evolutionSignalsProjection, externalRefs, findDriftSignal, findOwnerCandidate, foldCuratorFields, foldToolDispatches, foldTurnEvent, foldTurnEvents, fuzzyPatch, getRecord, h2Sections, historyReachability, hostSurface, identity, idleDays, initialTurnFold, instanceClaimKey, instanceClaimedWriteSites, instanceHolder, isAbsent, isBookkeepingFrame, isCommittedWarning, isDeprecatedParamId, isFileShapedPath, isMissingPath, isPresent, isProcessAlive, isProgramToolName, isProjectableSession, isRecord, isReviewChannelSession, isSkillReadToolName, isSkillToolName, isUnknown, json, latestActivityAt, leaseAsTreeLock, leaseFile, lifecycleCandidate, listEventArchives, liveBool, liveNumber, loadMutations, loadSuppressedNames, loadUsage, makeSerialQueue, markAgentCreated, markReviewChannel, memoryRoot, methodNotAllowed, missingSupportPointers, mutateUsage, mutationLockFrom, mutationsFile, narrowNameMatches, nearDuplicateSummaries, newRunRegistry, nodeEvolutionIo, normalizeUsageRecord, observeEvent, overlongLines, ownerCandidatesFromSummaries, ownerDecisionText, paramNamespace, paramRowId, paramSettingsId, parseCuratorNominations, parseEvolutionEvents, payloadText, persistedWriteSite, persistedWriteSites, pickWithPolicy, planExtract, planNamespaceMigration, planReferenceRewrite, planRehoming, policyStageLimits, probeAbsent, probeChannelState, probeList, probeMtime, probePresent, probeReason, probeText, probeUnknown, projectExtractBodies, projectionText, proposalFromPlan, proposalReportDir, proposalReportName, protectedSkillNamesOf, readDispatchSignal, readEvolutionEvents, readEvolutionTimeline, readExternalSupport, readJsonObject, readNumberParam, readParam, readProposalReport, readProposalReports, readingStats, recordMutation, redactSecrets, referencedBlobs, registerHostRoutes, releaseInstance, renameWithRetry, renderCuratorReportMarkdown, renderLongRunTable, reportTime, reportsReachability, reportsSweepLockTarget, resolveCitations, resolveParamId, retainEventArchives, retirementReport, reviewPrompt, runWriteGates, runsFile, saveSuppressedNames, saveUsage, scanBodyHooks, scanContentThreats, scanMemoryThreats, scanThreats, scopeOfNearestManifest, scopedPackageName, scopedProbeReport, selectSections, sessionAudited, sessionEvidenceIndex, sessionLastEventTime, sessionReadNames, sessionSeesFamilyTools, sessionTurnSignals, skillReadNameOf, skillWriteGateContext, supportFileReadFromPath, supportFileReadOf, supportRefs, suppressedFile, sweepReports, sweepReviewChannelSessions, tokenLineFor, transactIo, trimPatternBoundaries, unhookedSupportPointers, unwrapLive, updateSuppressedNames, usageFile, usageObserved, userSetKeys, verifyPromptBundle, vocabulary, withReviewContext, withTreeWrite, writeDurableTmp, writePathSymbols, writeProposalReport };
|
|
@@ -27,13 +27,6 @@ function isAbsent(probe) {
|
|
|
27
27
|
function isUnknown(probe) {
|
|
28
28
|
return probe.kind === "unknown";
|
|
29
29
|
}
|
|
30
|
-
/** Only a PRESENT probe yields a value; absent and unknown both fall back. */
|
|
31
|
-
function valueOr(probe, fallback) {
|
|
32
|
-
return probe.kind === "present" ? probe.value : fallback;
|
|
33
|
-
}
|
|
34
|
-
function mapProbe(probe, transform) {
|
|
35
|
-
return probe.kind === "present" ? probePresent(transform(probe.value)) : probe;
|
|
36
|
-
}
|
|
37
30
|
/** The reason an `unknown` probe carries (message, never a bare String(object)). */
|
|
38
31
|
function probeReason(error) {
|
|
39
32
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -158,61 +151,6 @@ async function transactIo(io, path, task) {
|
|
|
158
151
|
console.warn(`evolution-io: ${path} was written but its directory fsync failed — the bytes are visible, durability is unconfirmed: ${error instanceof Error ? error.message : String(error)}`);
|
|
159
152
|
}
|
|
160
153
|
}
|
|
161
|
-
function outcomeFailure(error) {
|
|
162
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
163
|
-
if (isCommittedWarning(error)) return {
|
|
164
|
-
kind: "unknown",
|
|
165
|
-
message
|
|
166
|
-
};
|
|
167
|
-
const code = error?.code;
|
|
168
|
-
return {
|
|
169
|
-
kind: "rejected",
|
|
170
|
-
code: typeof code === "string" ? code : "io",
|
|
171
|
-
message
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Read-modify-commit that reports what actually happened instead of collapsing the two failure
|
|
176
|
-
* kinds. `transactIo` deliberately turns a committed-warning into success (the bytes are visible),
|
|
177
|
-
* which is right for callers that only need the write; a two-phase caller needs to know that its
|
|
178
|
-
* follow-up step is unconfirmed, so it uses this instead.
|
|
179
|
-
* @param io - the IO backend.
|
|
180
|
-
* @param path - the durable file.
|
|
181
|
-
* @param task - the read-modify-render step.
|
|
182
|
-
* @returns `landed`, `unknown` (written, durability unconfirmed) or `rejected`.
|
|
183
|
-
*/
|
|
184
|
-
async function transactOutcome(io, path, task) {
|
|
185
|
-
if (io.transact) try {
|
|
186
|
-
await io.transact(path, task);
|
|
187
|
-
return { kind: "landed" };
|
|
188
|
-
} catch (error) {
|
|
189
|
-
return outcomeFailure(error);
|
|
190
|
-
}
|
|
191
|
-
try {
|
|
192
|
-
const current = await io.readText(path);
|
|
193
|
-
const next = await task(current);
|
|
194
|
-
if (next === null) await io.remove(path);
|
|
195
|
-
else if (next !== current) await io.writeText(path, next);
|
|
196
|
-
return { kind: "landed" };
|
|
197
|
-
} catch (error) {
|
|
198
|
-
return outcomeFailure(error);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
/** Build a {@link TransactTaskGuard} for one write path. See its doc. */
|
|
202
|
-
function transactTaskGuard(what) {
|
|
203
|
-
let invoked = false;
|
|
204
|
-
return {
|
|
205
|
-
wrap: (task) => (current) => {
|
|
206
|
-
invoked = true;
|
|
207
|
-
return task(current);
|
|
208
|
-
},
|
|
209
|
-
invoked: () => invoked,
|
|
210
|
-
assertInvoked: () => {
|
|
211
|
-
if (invoked) return;
|
|
212
|
-
throw new Error(`internal error: the write transaction for ${what} did not invoke the task; no write was performed`);
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
154
|
/** Lazy adapter over an IO provider registry, shared by every evolution consumer. */
|
|
217
155
|
function evolutionIoAdapter(provider) {
|
|
218
156
|
return {
|
|
@@ -685,4 +623,4 @@ function atomicWriteFiles(targetDir, writes, fs = defaultFs, logger = console.wa
|
|
|
685
623
|
}
|
|
686
624
|
}
|
|
687
625
|
//#endregion
|
|
688
|
-
export {
|
|
626
|
+
export { probePresent as _, nodeEvolutionIo as a, probeUnknown as b, writeDurableTmp as c, isMissingPath as d, isPresent as f, probeMtime as g, probeList as h, isProcessAlive as i, declaredReportStamp as l, probeAbsent as m, evolutionIoAdapter as n, renameWithRetry as o, isUnknown as p, isCommittedWarning as r, transactIo as s, atomicWriteFiles as t, isAbsent as u, probeReason as v, reportTime as x, probeText as y };
|
package/lib/io-node.js
CHANGED
package/lib/io-registry.js
CHANGED
|
@@ -58,39 +58,24 @@ var EvolutionIoRegistry = class extends Service {
|
|
|
58
58
|
return first;
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
-
const mediumObservations = /* @__PURE__ */ new WeakMap();
|
|
62
61
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
62
|
+
* Resolve the seam implementation for a consumer, preferring a backend the deployment mounted.
|
|
63
|
+
*
|
|
64
|
+
* Contract C2 (declared gaps) has no other shape: a consumer that can work on either medium asks for
|
|
65
|
+
* its preference and the DEPLOYMENT decides which backends exist. The lookup is contained here because
|
|
66
|
+
* the registry deliberately has no presence probe (v20 A-3 removed `hasProvider`; a presence probe goes
|
|
67
|
+
* through `provider(name)`, which fails loud) — so this function is the ONE sanctioned place that turns
|
|
68
|
+
* that failure into a fallback. A caller that needs a SPECIFIC backend must call `provider(name)` and
|
|
69
|
+
* take the error.
|
|
70
|
+
* @param registry - the seam registry (`ctx.evolutionIo`).
|
|
71
|
+
* @param names - preferred provider names, most preferred first.
|
|
72
|
+
* @returns the first registered preference, else the registry default.
|
|
66
73
|
*/
|
|
67
|
-
function describeMedium(registry) {
|
|
68
|
-
const observation = mediumObservations.get(registry);
|
|
69
|
-
if (observation === void 0) return { state: "unknown" };
|
|
70
|
-
return {
|
|
71
|
-
state: "known",
|
|
72
|
-
requested: observation.requested,
|
|
73
|
-
resolved: observation.resolved,
|
|
74
|
-
via: observation.via
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
74
|
function preferProvider(registry, names) {
|
|
78
75
|
for (const name of names) try {
|
|
79
|
-
|
|
80
|
-
mediumObservations.set(registry, {
|
|
81
|
-
requested: names,
|
|
82
|
-
resolved: name,
|
|
83
|
-
via: "preference"
|
|
84
|
-
});
|
|
85
|
-
return resolved;
|
|
76
|
+
return registry.provider(name);
|
|
86
77
|
} catch {}
|
|
87
|
-
|
|
88
|
-
mediumObservations.set(registry, {
|
|
89
|
-
requested: names,
|
|
90
|
-
resolved: void 0,
|
|
91
|
-
via: "default"
|
|
92
|
-
});
|
|
93
|
-
return fallback;
|
|
78
|
+
return registry.provider();
|
|
94
79
|
}
|
|
95
80
|
//#endregion
|
|
96
|
-
export { EvolutionIoRegistry, EvolutionIoRegistry as default,
|
|
81
|
+
export { EvolutionIoRegistry, EvolutionIoRegistry as default, preferProvider };
|