engine7 7.1.151 → 7.1.153
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/bg-worker.mjs +978 -424
- package/dist/cli.mjs +1209 -728
- package/dist/engine-startup.mjs +1775 -1169
- package/dist/main.mjs +1729 -1123
- package/dist/recall-worker.mjs +162 -52
- package/dist/sqlite-maintenance-worker.mjs +1 -1
- package/dist/topics-worker.mjs +144 -45
- package/dist/travel-data.mjs +1 -1
- package/dist/travel-gateway.mjs +608 -255
- package/dist/travel-host.mjs +659 -404
- package/dist/travel-initial-baseline.mjs +1 -1
- package/dist/travel-node-data.mjs +1 -1
- package/dist/travel-node.mjs +124 -41
- package/dist/travel-pairing.mjs +637 -284
- package/package.json +1 -1
- package/templates/skills/sop/SKILL.md +42 -150
package/dist/travel-host.mjs
CHANGED
|
@@ -3706,8 +3706,9 @@ function invalidateDerivedDependencies(db2, event2) {
|
|
|
3706
3706
|
}
|
|
3707
3707
|
return invalidateChildren(db2, event2.scopeId, pending, event2.kind);
|
|
3708
3708
|
}
|
|
3709
|
-
function invalidateScopeDependencies(db2, scope, parent, reason) {
|
|
3710
|
-
|
|
3709
|
+
function invalidateScopeDependencies(db2, scope, parent, reason, options = {}) {
|
|
3710
|
+
let children = db2.prepare("SELECT child_kind,child_id FROM memory_dependencies WHERE scope_id=? AND parent_kind='scope' AND parent_id=?").all(scope, parent);
|
|
3711
|
+
if (options.skipKinds?.size) children = children.filter((child) => !options.skipKinds.has(child.child_kind));
|
|
3711
3712
|
invalidateChildren(db2, scope, children, reason);
|
|
3712
3713
|
}
|
|
3713
3714
|
function invalidateChildren(db2, scope, pending, reason) {
|
|
@@ -3727,7 +3728,7 @@ function invalidateChildren(db2, scope, pending, reason) {
|
|
|
3727
3728
|
}
|
|
3728
3729
|
const state2 = child.deleted ? "deleted" : "needs_revalidation";
|
|
3729
3730
|
db2.prepare(`UPDATE memory_derivations SET state=?,reason=?,updated_at=?
|
|
3730
|
-
WHERE scope_id=? AND child_kind=? AND child_id=? AND state IN ('current','needs_revalidation'
|
|
3731
|
+
WHERE scope_id=? AND child_kind=? AND child_id=? AND state IN ('current','needs_revalidation') AND state<>?`).run(state2, reason, (/* @__PURE__ */ new Date()).toISOString(), scope, child.child_kind, child.child_id, state2);
|
|
3731
3732
|
result.push(child.child_id);
|
|
3732
3733
|
pending.push(...db2.prepare("SELECT child_kind,child_id,role FROM memory_dependencies WHERE scope_id=? AND parent_kind='artifact' AND parent_id=?").all(scope, child.child_id).map((row) => ({ ...row, deleted: child.deleted && row.role === "supports" })));
|
|
3733
3734
|
}
|
|
@@ -4406,7 +4407,7 @@ import { createHash as createHash10 } from "node:crypto";
|
|
|
4406
4407
|
function projectedSourceIdFromScopeId(id2, originKey, sourceVersion) {
|
|
4407
4408
|
return "src_" + digest2([id2, originKey, sourceVersion]);
|
|
4408
4409
|
}
|
|
4409
|
-
var SOURCE_SCHEMA, SOURCE_ALIAS_SCHEMA, digest2, SourceStore;
|
|
4410
|
+
var RECEIVED_INVALIDATION_SKIP, SOURCE_SCHEMA, SOURCE_ALIAS_SCHEMA, digest2, SourceStore;
|
|
4410
4411
|
var init_source_store = __esm({
|
|
4411
4412
|
"src/mem7/core/source-store.ts"() {
|
|
4412
4413
|
"use strict";
|
|
@@ -4418,6 +4419,7 @@ var init_source_store = __esm({
|
|
|
4418
4419
|
init_watermarks();
|
|
4419
4420
|
init_interpretation_impact();
|
|
4420
4421
|
init_conversation_text();
|
|
4422
|
+
RECEIVED_INVALIDATION_SKIP = /* @__PURE__ */ new Set(["foresight"]);
|
|
4421
4423
|
SOURCE_SCHEMA = `
|
|
4422
4424
|
CREATE TABLE memory_scopes (
|
|
4423
4425
|
scope_id TEXT PRIMARY KEY, owner_id TEXT NOT NULL, app_id TEXT NOT NULL, project_id TEXT NOT NULL,
|
|
@@ -4599,8 +4601,8 @@ CREATE TABLE IF NOT EXISTS memory_source_aliases (
|
|
|
4599
4601
|
if (this.db.prepare("SELECT 1 FROM memory_sources WHERE scope_id=? AND origin_key=? AND interpretation_status='deleted'").get(id2, input.originKey)) throw new Error("DELETED_EVIDENCE");
|
|
4600
4602
|
if (version !== Number(latest.version ?? 0) + 1) throw new Error("SOURCE_VERSION_CONFLICT: edits must follow the previous version");
|
|
4601
4603
|
this.db.prepare("UPDATE memory_scopes SET source_seq=source_seq+1,context_revision=context_revision+1 WHERE scope_id=?").run(id2);
|
|
4602
|
-
invalidateScopeDependencies(this.db, id2, "sources", "source.received");
|
|
4603
|
-
invalidateScopeDependencies(this.db, id2, "context", "source.received");
|
|
4604
|
+
invalidateScopeDependencies(this.db, id2, "sources", "source.received", { skipKinds: RECEIVED_INVALIDATION_SKIP });
|
|
4605
|
+
invalidateScopeDependencies(this.db, id2, "context", "source.received", { skipKinds: RECEIVED_INVALIDATION_SKIP });
|
|
4604
4606
|
const seq = Number(this.db.prepare("SELECT source_seq FROM memory_scopes WHERE scope_id=?").get(id2).source_seq);
|
|
4605
4607
|
const sourceId = projectedSourceIdFromScopeId(id2, input.originKey, version);
|
|
4606
4608
|
const receiptId = "rcpt_" + digest2([id2, sourceId]);
|
|
@@ -7964,7 +7966,29 @@ function tokenize(text2) {
|
|
|
7964
7966
|
function tokenizeToField(text2) {
|
|
7965
7967
|
return tokenize(text2).join(" ");
|
|
7966
7968
|
}
|
|
7967
|
-
|
|
7969
|
+
function cjkBigrams(text2) {
|
|
7970
|
+
const out = [];
|
|
7971
|
+
for (const seg of String(text2 ?? "").match(/[\u4e00-\u9fff]{2,}/g) ?? []) {
|
|
7972
|
+
for (let i = 0; i + 1 < seg.length; i++) out.push(seg.slice(i, i + 2));
|
|
7973
|
+
}
|
|
7974
|
+
return out;
|
|
7975
|
+
}
|
|
7976
|
+
function invisibleCjkNeedles(candidates) {
|
|
7977
|
+
return [...new Set(candidates.map((token) => token.trim()))].filter((token) => /^[\u4e00-\u9fff]{2,}$/.test(token) && tokenize(token).length === 0).slice(0, 8);
|
|
7978
|
+
}
|
|
7979
|
+
function literalQueryNeedles(text2) {
|
|
7980
|
+
const chars = shortCjkCharCount(text2);
|
|
7981
|
+
if (!chars || chars > 6) return null;
|
|
7982
|
+
const names2 = invisibleCjkNeedles(engine().cut(String(text2 ?? ""), true));
|
|
7983
|
+
return names2.length ? names2 : queryBigramNeedles(text2);
|
|
7984
|
+
}
|
|
7985
|
+
function queryBigramNeedles(text2) {
|
|
7986
|
+
const chars = shortCjkCharCount(text2);
|
|
7987
|
+
if (!chars || chars > 6) return null;
|
|
7988
|
+
const grams = [...new Set(cjkBigrams(text2))].slice(0, 8);
|
|
7989
|
+
return grams.length ? grams : null;
|
|
7990
|
+
}
|
|
7991
|
+
var DEFAULT_STOPWORDS, MIN_TOKEN_LENGTH, jieba, shortCjkCharCount;
|
|
7968
7992
|
var init_tokenizer = __esm({
|
|
7969
7993
|
"src/mem7/core/tokenizer.ts"() {
|
|
7970
7994
|
"use strict";
|
|
@@ -8037,6 +8061,7 @@ var init_tokenizer = __esm({
|
|
|
8037
8061
|
]);
|
|
8038
8062
|
MIN_TOKEN_LENGTH = 2;
|
|
8039
8063
|
jieba = null;
|
|
8064
|
+
shortCjkCharCount = (text2) => (String(text2 ?? "").match(/[\u4e00-\u9fff]/g) ?? []).length;
|
|
8040
8065
|
}
|
|
8041
8066
|
});
|
|
8042
8067
|
|
|
@@ -10456,7 +10481,7 @@ function contentHash(text2) {
|
|
|
10456
10481
|
function mem7Root(stateDir) {
|
|
10457
10482
|
return join16(stateDir, "mem7");
|
|
10458
10483
|
}
|
|
10459
|
-
var STALE_ARTIFACT_FORCE_MS, SCHEMA, AGENT_SCHEMA, Mem7Store;
|
|
10484
|
+
var STALE_ARTIFACT_FORCE_MS, STARVATION_GRACE_MS, SCHEMA, AGENT_SCHEMA, Mem7Store;
|
|
10460
10485
|
var init_store = __esm({
|
|
10461
10486
|
"src/mem7/core/store.ts"() {
|
|
10462
10487
|
"use strict";
|
|
@@ -10494,6 +10519,7 @@ var init_store = __esm({
|
|
|
10494
10519
|
init_job_retention();
|
|
10495
10520
|
init_retire_graph_audits();
|
|
10496
10521
|
STALE_ARTIFACT_FORCE_MS = 2 * 36e5;
|
|
10522
|
+
STARVATION_GRACE_MS = 36e5;
|
|
10497
10523
|
SCHEMA = `
|
|
10498
10524
|
CREATE TABLE IF NOT EXISTS memcells (
|
|
10499
10525
|
id TEXT PRIMARY KEY,
|
|
@@ -11584,7 +11610,7 @@ ${e.outcome}
|
|
|
11584
11610
|
return this.transaction(() => {
|
|
11585
11611
|
const kindFilter = options.kinds ? ` AND kind IN (${options.kinds.map(() => "?").join(",")})` : "";
|
|
11586
11612
|
const scopeFilter = options.scopeId !== void 0 ? " AND scope_id=?" : "";
|
|
11587
|
-
const
|
|
11613
|
+
const base = `SELECT * FROM ome_jobs j INDEXED BY ${options.scopeId !== void 0 && options.kinds?.length === 1 ? "idx_jobs_scope_priority" : "idx_jobs_runnable_priority"}
|
|
11588
11614
|
WHERE status IN ('pending','running') AND NOT EXISTS (SELECT 1 FROM memory_job_holds h WHERE h.job_id=j.id AND h.released_at IS NULL)
|
|
11589
11615
|
AND ((status='pending' AND next_run_at<=?)
|
|
11590
11616
|
OR (status='running' AND COALESCE(lease_until,0)<=?))${kindFilter}${scopeFilter}
|
|
@@ -11604,40 +11630,48 @@ ${e.outcome}
|
|
|
11604
11630
|
-- Cognition rebuilds its read set at claim time; delayed old work must not fence fresh judgments.
|
|
11605
11631
|
AND (kind IN ('social.interpret','source.interpret','relationship.cognition') OR scope_id NOT LIKE 'resource:%' OR NOT EXISTS (SELECT 1 FROM ome_jobs prior
|
|
11606
11632
|
WHERE prior.scope_id=j.scope_id AND prior.id<j.id AND prior.status IN ('pending','running')
|
|
11607
|
-
AND NOT EXISTS (SELECT 1 FROM memory_job_holds h WHERE h.job_id=prior.id AND h.released_at IS NULL)) OR scope_id IS NULL)
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
if (
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11633
|
+
AND NOT EXISTS (SELECT 1 FROM memory_job_holds h WHERE h.job_id=prior.id AND h.released_at IS NULL)) OR scope_id IS NULL)`;
|
|
11634
|
+
const select = (starved2) => {
|
|
11635
|
+
const sql = `${base}${starved2 ? " AND status='pending' AND next_run_at<=?" : ""}
|
|
11636
|
+
ORDER BY priority,next_run_at,id LIMIT ?`;
|
|
11637
|
+
const args = starved2 ? [now2, now2, ...options.kinds ?? [], ...options.scopeId !== void 0 ? [options.scopeId] : [], now2, now2 - STARVATION_GRACE_MS, limit] : [now2, now2, ...options.kinds ?? [], ...options.scopeId !== void 0 ? [options.scopeId] : [], now2, limit];
|
|
11638
|
+
return this.db.prepare(sql).all(...args);
|
|
11639
|
+
};
|
|
11640
|
+
const claim = (rows) => {
|
|
11641
|
+
const claimedScopes = /* @__PURE__ */ new Set();
|
|
11642
|
+
return rows.flatMap((row) => {
|
|
11643
|
+
if (!this.jobProvenance.prepareForClaim(row.id, now2)) return [];
|
|
11644
|
+
const updated = this.db.prepare("SELECT * FROM ome_jobs WHERE id=?").get(row.id);
|
|
11645
|
+
if (updated.scope_id !== row.scope_id && updated.scope_id) {
|
|
11646
|
+
const conflict = this.db.prepare(`SELECT 1 FROM ome_jobs j WHERE j.scope_id=? AND j.id<>?
|
|
11647
|
+
AND (j.status='running' AND j.lease_until>? OR ? LIKE 'resource:%' AND j.id<? AND j.status IN ('pending','running')
|
|
11648
|
+
AND NOT EXISTS (SELECT 1 FROM memory_job_holds h WHERE h.job_id=j.id AND h.released_at IS NULL))`).get(updated.scope_id, updated.id, now2, updated.scope_id, updated.id);
|
|
11649
|
+
if (conflict) return [];
|
|
11650
|
+
}
|
|
11651
|
+
return [updated];
|
|
11652
|
+
}).filter((row) => {
|
|
11653
|
+
if (!row.scope_id) return true;
|
|
11654
|
+
if (claimedScopes.has(row.scope_id)) return false;
|
|
11655
|
+
claimedScopes.add(row.scope_id);
|
|
11656
|
+
return true;
|
|
11657
|
+
}).map((row) => {
|
|
11658
|
+
const leaseToken = randomUUID10();
|
|
11659
|
+
this.db.prepare("UPDATE ome_jobs SET status='running',lease_token=?,lease_until=? WHERE id=?").run(leaseToken, now2 + leaseMs, row.id);
|
|
11660
|
+
return {
|
|
11661
|
+
id: row.id,
|
|
11662
|
+
kind: row.kind,
|
|
11663
|
+
payload: JSON.parse(row.payload),
|
|
11664
|
+
attempts: row.attempts,
|
|
11665
|
+
leaseToken,
|
|
11666
|
+
inputVersion: row.input_version,
|
|
11667
|
+
scopeId: row.scope_id ?? void 0,
|
|
11668
|
+
result: row.result_json === null ? void 0 : JSON.parse(row.result_json)
|
|
11669
|
+
};
|
|
11670
|
+
});
|
|
11671
|
+
};
|
|
11672
|
+
if (options.staleOnly) return claim(select(true));
|
|
11673
|
+
const starved = claim(select(true));
|
|
11674
|
+
return starved.length ? starved : claim(select(false));
|
|
11641
11675
|
});
|
|
11642
11676
|
}
|
|
11643
11677
|
/** Compatibility entry point: only expired leases can be recovered. */
|
|
@@ -12296,7 +12330,7 @@ function textColumnOf(kind) {
|
|
|
12296
12330
|
return "fact";
|
|
12297
12331
|
}
|
|
12298
12332
|
}
|
|
12299
|
-
var isIntelMac, lancePromise, mem7VectorWarning, arrowPromise, Mem7VectorUnavailableError, VECTOR_DIM, BM25_FIELDS, RRF_K, warnedFts, warnedVecIdx, incompatibleIndexSegments, bootAt, schemasCache, Mem7VectorStore;
|
|
12333
|
+
var isIntelMac, lancePromise, mem7VectorWarning, arrowPromise, Mem7VectorUnavailableError, VECTOR_DIM, BM25_FIELDS, BM25_TEXT_FIELDS, sqlLiteral, RRF_K, warnedFts, warnedVecIdx, incompatibleIndexSegments, bootAt, schemasCache, Mem7VectorStore;
|
|
12300
12334
|
var init_vector_store = __esm({
|
|
12301
12335
|
"src/mem7/core/vector-store.ts"() {
|
|
12302
12336
|
"use strict";
|
|
@@ -12327,6 +12361,14 @@ var init_vector_store = __esm({
|
|
|
12327
12361
|
agent_case: ["task_intent_tokens", "approach_tokens"],
|
|
12328
12362
|
agent_skill: ["description_tokens", "content_tokens"]
|
|
12329
12363
|
};
|
|
12364
|
+
BM25_TEXT_FIELDS = {
|
|
12365
|
+
foresight: ["foresight", "evidence"],
|
|
12366
|
+
episode: ["episode"],
|
|
12367
|
+
atomic_fact: ["fact"],
|
|
12368
|
+
agent_case: ["task_intent", "approach"],
|
|
12369
|
+
agent_skill: ["description", "content"]
|
|
12370
|
+
};
|
|
12371
|
+
sqlLiteral = (value2) => value2.replace(/'/g, "''");
|
|
12330
12372
|
RRF_K = 60;
|
|
12331
12373
|
warnedFts = /* @__PURE__ */ new Set();
|
|
12332
12374
|
warnedVecIdx = /* @__PURE__ */ new Set();
|
|
@@ -12924,6 +12966,47 @@ var init_vector_store = __esm({
|
|
|
12924
12966
|
if (!cur || score > Number(cur._score ?? 0)) best.set(rid, r);
|
|
12925
12967
|
}
|
|
12926
12968
|
}
|
|
12969
|
+
const textCols = BM25_TEXT_FIELDS[kind];
|
|
12970
|
+
const scan = async (terms, op, limit) => {
|
|
12971
|
+
const expr = op === "AND" ? terms.map((g) => `(${textCols.map((col) => `contains(${col}, '${sqlLiteral(g)}')`).join(" OR ")})`).join(" AND ") : textCols.map((col) => `(${terms.map((g) => `contains(${col}, '${sqlLiteral(g)}')`).join(" OR ")})`).join(" OR ");
|
|
12972
|
+
const where2 = compileFilter(opts.filter);
|
|
12973
|
+
return await tbl.query().where(where2 ? `(${where2}) AND (${expr})` : expr).limit(limit).toArray();
|
|
12974
|
+
};
|
|
12975
|
+
const maxScore = [...best.values()].reduce((max, r) => Math.max(max, Number(r._score ?? 0)), 0);
|
|
12976
|
+
const scoreLiteral = (needles2, rows) => {
|
|
12977
|
+
const terms = [.../* @__PURE__ */ new Set([...needles2, ...tokenizeToField(queryText).split(/\s+/).filter(Boolean)])];
|
|
12978
|
+
const occurrences2 = (text2, term) => text2.split(term).length - 1;
|
|
12979
|
+
for (const r of rows) {
|
|
12980
|
+
const rid = String(r.id ?? "");
|
|
12981
|
+
if (!rid) continue;
|
|
12982
|
+
const text2 = textCols.map((col) => String(r[col] ?? "")).join(" ");
|
|
12983
|
+
const matched = terms.filter((term) => text2.includes(term));
|
|
12984
|
+
if (!matched.length || matched.every((term) => !needles2.includes(term))) continue;
|
|
12985
|
+
const full = matched.length === terms.length;
|
|
12986
|
+
const density = matched.reduce((sum, term) => sum + occurrences2(text2, term), 0) / Math.max(text2.length, 1) * 1e3;
|
|
12987
|
+
const score = full ? maxScore + 1 + Math.min(0.99, density / 10) : maxScore > 0 ? maxScore * (0.5 + 0.5 * matched.length / terms.length) : matched.length / terms.length;
|
|
12988
|
+
const cur = best.get(rid);
|
|
12989
|
+
if (cur) {
|
|
12990
|
+
if (full) cur._score = Math.max(Number(cur._score ?? 0), score);
|
|
12991
|
+
} else best.set(rid, { ...r, _score: score });
|
|
12992
|
+
}
|
|
12993
|
+
};
|
|
12994
|
+
const needles = literalQueryNeedles(queryText);
|
|
12995
|
+
if (needles) {
|
|
12996
|
+
try {
|
|
12997
|
+
const terms = [.../* @__PURE__ */ new Set([...needles, ...tokenizeToField(queryText).split(/\s+/).filter(Boolean)])];
|
|
12998
|
+
const [all, any] = await Promise.all([
|
|
12999
|
+
terms.length > 1 ? scan(terms, "AND", topK * 10) : Promise.resolve([]),
|
|
13000
|
+
scan(needles, "OR", topK * 3)
|
|
13001
|
+
]);
|
|
13002
|
+
scoreLiteral(needles, [...all, ...any]);
|
|
13003
|
+
if (![...best.values()].some((r) => Number(r._score ?? 0) > maxScore)) {
|
|
13004
|
+
const bigrams = [...new Set(needles.flatMap((name) => queryBigramNeedles(name) ?? []))].slice(0, 8);
|
|
13005
|
+
if (bigrams.length && JSON.stringify(bigrams) !== JSON.stringify(needles)) scoreLiteral(bigrams, await scan(bigrams, "OR", topK * 3));
|
|
13006
|
+
}
|
|
13007
|
+
} catch {
|
|
13008
|
+
}
|
|
13009
|
+
}
|
|
12927
13010
|
return this.visibleRows(kind, [...best.values()]).filter((r) => Number(r._score ?? 0) > 0).sort((a, b) => Number(b._score ?? 0) - Number(a._score ?? 0)).slice(0, topK).map((r) => ({ ...this.toHit(kind, r), distance: 0, score: Number(r._score ?? 0) }));
|
|
12928
13011
|
} catch (err) {
|
|
12929
13012
|
const msg2 = String(err?.message ?? err);
|
|
@@ -21265,8 +21348,10 @@ async function executeOneHook(hook, hookEvent, hookName, hookInput, toolUseID, s
|
|
|
21265
21348
|
hookEvent,
|
|
21266
21349
|
durationMs: durationMs2
|
|
21267
21350
|
});
|
|
21351
|
+
const output = syncOutput.hookSpecificOutput;
|
|
21268
21352
|
return {
|
|
21269
21353
|
...processed,
|
|
21354
|
+
...hook.id === "skill-gate-prompt" && output?.hookEventName === "UserPromptSubmit" && output.selectSkill === true ? { selectSkill: true } : {},
|
|
21270
21355
|
outcome: processed.blockingError ? "blocking" : "success",
|
|
21271
21356
|
hook
|
|
21272
21357
|
};
|
|
@@ -21368,6 +21453,7 @@ function aggregateResults(results) {
|
|
|
21368
21453
|
if (result.permissionBehavior) {
|
|
21369
21454
|
aggregated.permissionBehavior = result.permissionBehavior;
|
|
21370
21455
|
}
|
|
21456
|
+
if (result.selectSkill) aggregated.selectSkill = true;
|
|
21371
21457
|
if (result.additionalContext) {
|
|
21372
21458
|
aggregated.additionalContexts.push(result.additionalContext);
|
|
21373
21459
|
}
|
|
@@ -23596,6 +23682,412 @@ var init_store2 = __esm({
|
|
|
23596
23682
|
}
|
|
23597
23683
|
});
|
|
23598
23684
|
|
|
23685
|
+
// src/skills/recent-user-texts.ts
|
|
23686
|
+
var init_recent_user_texts = __esm({
|
|
23687
|
+
"src/skills/recent-user-texts.ts"() {
|
|
23688
|
+
"use strict";
|
|
23689
|
+
init_strip_injected();
|
|
23690
|
+
}
|
|
23691
|
+
});
|
|
23692
|
+
|
|
23693
|
+
// src/core/query-skill-selection.ts
|
|
23694
|
+
async function selectSkillCall(provider, params, allowedNames, recordUsage) {
|
|
23695
|
+
const timeout = AbortSignal.timeout(5e3);
|
|
23696
|
+
const signal = AbortSignal.any([params.signal, timeout]);
|
|
23697
|
+
const chunks = [];
|
|
23698
|
+
let calledSkill = false;
|
|
23699
|
+
let skillName = "";
|
|
23700
|
+
let requestComplete = false;
|
|
23701
|
+
let otherCut = false;
|
|
23702
|
+
try {
|
|
23703
|
+
for await (const chunk of provider.streamChat({
|
|
23704
|
+
...params,
|
|
23705
|
+
signal,
|
|
23706
|
+
httpRetry: { maxRetries: 0 }
|
|
23707
|
+
})) {
|
|
23708
|
+
signal.throwIfAborted();
|
|
23709
|
+
if (chunk.type === "error") return { outcome: "upstream-error" };
|
|
23710
|
+
if (chunk.type === "tool_call") {
|
|
23711
|
+
if (calledSkill || !chunk.tool_call?.id || chunk.tool_call.function?.name !== SKILL_TOOL_NAME) return { outcome: "invalid" };
|
|
23712
|
+
let args;
|
|
23713
|
+
try {
|
|
23714
|
+
args = JSON.parse(chunk.tool_call.function.arguments);
|
|
23715
|
+
} catch {
|
|
23716
|
+
return { outcome: "invalid" };
|
|
23717
|
+
}
|
|
23718
|
+
if (typeof args?.skill !== "string" || !allowedNames.has(args.skill.trim().replace(/^\//, ""))) return { outcome: "invalid" };
|
|
23719
|
+
calledSkill = true;
|
|
23720
|
+
skillName = args.skill.trim().replace(/^\//, "");
|
|
23721
|
+
chunks.push(chunk);
|
|
23722
|
+
}
|
|
23723
|
+
if (chunk.type === "done") {
|
|
23724
|
+
if (chunk.usage) recordUsage(chunk.usage);
|
|
23725
|
+
requestComplete ||= chunk.requestComplete === true;
|
|
23726
|
+
otherCut ||= ["incomplete", "content_filter"].includes(chunk.stopReason ?? "");
|
|
23727
|
+
}
|
|
23728
|
+
}
|
|
23729
|
+
} catch (error) {
|
|
23730
|
+
params.signal.throwIfAborted();
|
|
23731
|
+
if (error instanceof Error && /^TRAVEL_/.test(error.message)) throw error;
|
|
23732
|
+
return { outcome: timeout.aborted ? "timeout" : "upstream-error" };
|
|
23733
|
+
}
|
|
23734
|
+
params.signal.throwIfAborted();
|
|
23735
|
+
if (timeout.aborted) return { outcome: "timeout" };
|
|
23736
|
+
if (!requestComplete || otherCut) return { outcome: "incomplete" };
|
|
23737
|
+
return calledSkill ? { outcome: "selected", skill: skillName, chunks } : { outcome: "no-skill" };
|
|
23738
|
+
}
|
|
23739
|
+
var SKILL_SELECTION_PROMPT, SKILL_SELECTION_MAX_TOKENS;
|
|
23740
|
+
var init_query_skill_selection = __esm({
|
|
23741
|
+
"src/core/query-skill-selection.ts"() {
|
|
23742
|
+
"use strict";
|
|
23743
|
+
init_constants4();
|
|
23744
|
+
init_types();
|
|
23745
|
+
init_recent_user_texts();
|
|
23746
|
+
SKILL_SELECTION_PROMPT = "\u6309 currentTask \u7684\u76EE\u6807\u548C\u6240\u5904\u9636\u6BB5\uFF0C\u5224\u65AD\u54EA\u9879\u5DF2\u5B89\u88C5\u6280\u80FD\u80FD\u5207\u5B9E\u5E2E\u52A9\u5B8C\u6210\u8FD9\u8F6E\u4EFB\u52A1\uFF0C\u6D41\u7A0B\u7C7B\u6280\u80FD\u7EA6\u675F\u505A\u6CD5\uFF0C\u6587\u6863\u3001\u8868\u683C\u3001\u53D1\u5E03\u7B49\u9886\u57DF\u7C7B\u6280\u80FD\u63D0\u4F9B\u4E13\u95E8\u80FD\u529B\u3002recentDialogue \u53EA\u7528\u4E8E\u7406\u89E3\u6307\u4EE3\u3002\u4E0B\u9762\u662F\u5DF2\u5B89\u88C5\u6280\u80FD\u7684\u540D\u79F0\u548C\u7528\u9014\u3002\u4F60\u53EA\u8D1F\u8D23\u6311\u9009\u6280\u80FD\uFF0C\u4E0D\u8D1F\u8D23\u56DE\u7B54\u4EFB\u52A1\u672C\u8EAB\uFF1A\u6B63\u5F0F\u56DE\u7B54\u7531\u540E\u7EED\u9636\u6BB5\u5B8C\u6210\uFF0C\u8FD9\u91CC\u4E0D\u8981\u5199\u4EFB\u4F55\u56DE\u7B54\u3002\u9002\u7528\u65F6\u76F4\u63A5\u8C03\u7528\u4E00\u9879\u6700\u5408\u9002\u7684 Skill\uFF0C\u4E0D\u8981\u8F93\u51FA\u4EFB\u4F55\u8BF4\u660E\u6587\u5B57\u3002\u7528\u666E\u901A\u5DE5\u5177\u6216\u53EA\u8BFB\u64CD\u4F5C\u4E5F\u53EF\u4EE5\u9075\u5FAA\u6D41\u7A0B\u3002\u5982\u679C\u5BF9\u65B9\u660E\u786E\u8981\u6C42\u8DF3\u8FC7\u3001\u5F53\u524D\u4EFB\u52A1\u6CA1\u6709\u9002\u7528\u7684\u6280\u80FD\uFF0C\u6216\u7F3A\u5C11\u9009\u51C6\u6240\u9700\u7684\u4FE1\u606F\uFF0C\u4E0D\u8C03\u7528\u4EFB\u4F55\u5DE5\u5177\uFF0C\u4E5F\u4E0D\u5199\u4EFB\u4F55\u5B57\uFF0C\u7ACB\u5373\u7ED3\u675F\u3002\u6B63\u5E38\u5DE5\u4F5C\u9636\u6BB5\u4F1A\u63D0\u4F9B\u5B8C\u6574\u5BF9\u8BDD\u548C\u9879\u76EE\u5DE5\u5177\u3002";
|
|
23747
|
+
SKILL_SELECTION_MAX_TOKENS = 64;
|
|
23748
|
+
}
|
|
23749
|
+
});
|
|
23750
|
+
|
|
23751
|
+
// src/skills/scanner.ts
|
|
23752
|
+
import * as path27 from "node:path";
|
|
23753
|
+
import * as fs23 from "node:fs";
|
|
23754
|
+
function scanSkills(skillsDir) {
|
|
23755
|
+
if (!fs23.existsSync(skillsDir)) {
|
|
23756
|
+
console.log(`[skills] Directory not found: ${skillsDir}`);
|
|
23757
|
+
return [];
|
|
23758
|
+
}
|
|
23759
|
+
const skills = [];
|
|
23760
|
+
const scanDir = (dir, depth, seen) => {
|
|
23761
|
+
const entries = fs23.readdirSync(dir, { withFileTypes: true });
|
|
23762
|
+
for (const entry of entries) {
|
|
23763
|
+
if (entry.name.startsWith(".") || entry.name === "_archive") continue;
|
|
23764
|
+
const full = path27.join(dir, entry.name);
|
|
23765
|
+
let isDir = entry.isDirectory();
|
|
23766
|
+
let isFile = entry.isFile();
|
|
23767
|
+
if (entry.isSymbolicLink()) {
|
|
23768
|
+
try {
|
|
23769
|
+
const st = fs23.statSync(full);
|
|
23770
|
+
isDir = st.isDirectory();
|
|
23771
|
+
isFile = st.isFile();
|
|
23772
|
+
} catch {
|
|
23773
|
+
console.warn(`[skills] Broken symlink, skipped: ${full}`);
|
|
23774
|
+
continue;
|
|
23775
|
+
}
|
|
23776
|
+
}
|
|
23777
|
+
if (isDir && depth < 3) {
|
|
23778
|
+
let real;
|
|
23779
|
+
try {
|
|
23780
|
+
real = fs23.realpathSync(full);
|
|
23781
|
+
} catch {
|
|
23782
|
+
continue;
|
|
23783
|
+
}
|
|
23784
|
+
if (seen.has(real)) continue;
|
|
23785
|
+
seen.add(real);
|
|
23786
|
+
scanDir(full, depth + 1, seen);
|
|
23787
|
+
continue;
|
|
23788
|
+
}
|
|
23789
|
+
if (!isFile || entry.name !== "SKILL.md") continue;
|
|
23790
|
+
try {
|
|
23791
|
+
const content = fs23.readFileSync(full, "utf-8");
|
|
23792
|
+
const frontmatter = parseFrontmatter(content);
|
|
23793
|
+
if (!frontmatter.name) {
|
|
23794
|
+
console.warn(`[skills] Skipping ${full}: missing 'name' in frontmatter`);
|
|
23795
|
+
continue;
|
|
23796
|
+
}
|
|
23797
|
+
const rel = path27.relative(skillsDir, full).split(path27.sep).join("/");
|
|
23798
|
+
skills.push({
|
|
23799
|
+
name: frontmatter.name,
|
|
23800
|
+
description: frontmatter.description || "",
|
|
23801
|
+
location: `skills/${rel}`,
|
|
23802
|
+
...frontmatter
|
|
23803
|
+
});
|
|
23804
|
+
} catch (err) {
|
|
23805
|
+
console.warn(`[skills] Error parsing ${full}: ${err.message}`);
|
|
23806
|
+
}
|
|
23807
|
+
}
|
|
23808
|
+
};
|
|
23809
|
+
scanDir(skillsDir, 0, /* @__PURE__ */ new Set([fs23.realpathSync(skillsDir)]));
|
|
23810
|
+
console.log(`[skills] Scanned ${skills.length} skills from ${skillsDir}`);
|
|
23811
|
+
return skills;
|
|
23812
|
+
}
|
|
23813
|
+
function parseFrontmatter(content) {
|
|
23814
|
+
const result = {};
|
|
23815
|
+
const match = content.match(/^---\s*\n([\s\S]*?)\n---/);
|
|
23816
|
+
if (!match) return result;
|
|
23817
|
+
const lines = match[1].split("\n");
|
|
23818
|
+
let i = 0;
|
|
23819
|
+
while (i < lines.length) {
|
|
23820
|
+
const line = lines[i];
|
|
23821
|
+
const colonIdx = line.indexOf(":");
|
|
23822
|
+
if (colonIdx === -1) {
|
|
23823
|
+
i++;
|
|
23824
|
+
continue;
|
|
23825
|
+
}
|
|
23826
|
+
const key3 = line.slice(0, colonIdx).trim();
|
|
23827
|
+
let value2 = line.slice(colonIdx + 1).trim();
|
|
23828
|
+
if (value2.startsWith('"') && value2.endsWith('"') || value2.startsWith("'") && value2.endsWith("'")) {
|
|
23829
|
+
value2 = value2.slice(1, -1);
|
|
23830
|
+
result[key3] = value2;
|
|
23831
|
+
i++;
|
|
23832
|
+
continue;
|
|
23833
|
+
} else if (value2 === "|" || value2 === ">") {
|
|
23834
|
+
const blockLines = [];
|
|
23835
|
+
i++;
|
|
23836
|
+
while (i < lines.length && lines[i].startsWith(" ")) {
|
|
23837
|
+
blockLines.push(lines[i].slice(2));
|
|
23838
|
+
i++;
|
|
23839
|
+
}
|
|
23840
|
+
result[key3] = blockLines.join("\n").trim();
|
|
23841
|
+
continue;
|
|
23842
|
+
} else if (value2.startsWith("[") && value2.endsWith("]")) {
|
|
23843
|
+
result[key3] = value2.slice(1, -1).split(",").map((s) => s.trim());
|
|
23844
|
+
i++;
|
|
23845
|
+
continue;
|
|
23846
|
+
} else if (value2.includes(" ") && !value2.startsWith('"')) {
|
|
23847
|
+
result[key3] = value2;
|
|
23848
|
+
} else {
|
|
23849
|
+
result[key3] = value2;
|
|
23850
|
+
}
|
|
23851
|
+
i++;
|
|
23852
|
+
}
|
|
23853
|
+
return result;
|
|
23854
|
+
}
|
|
23855
|
+
var init_scanner = __esm({
|
|
23856
|
+
"src/skills/scanner.ts"() {
|
|
23857
|
+
"use strict";
|
|
23858
|
+
}
|
|
23859
|
+
});
|
|
23860
|
+
|
|
23861
|
+
// src/tools/SkillTool/SkillTool.ts
|
|
23862
|
+
import { createHash as createHash36 } from "node:crypto";
|
|
23863
|
+
import * as fs24 from "node:fs";
|
|
23864
|
+
import * as path28 from "node:path";
|
|
23865
|
+
function getSkillSelectionCatalog() {
|
|
23866
|
+
return selectionCatalog;
|
|
23867
|
+
}
|
|
23868
|
+
function getCharBudget(contextWindowTokens) {
|
|
23869
|
+
if (contextWindowTokens) {
|
|
23870
|
+
return Math.floor(contextWindowTokens * CHARS_PER_TOKEN * SKILL_BUDGET_CONTEXT_PERCENT);
|
|
23871
|
+
}
|
|
23872
|
+
return DEFAULT_CHAR_BUDGET;
|
|
23873
|
+
}
|
|
23874
|
+
function stringWidth(str) {
|
|
23875
|
+
return str.length;
|
|
23876
|
+
}
|
|
23877
|
+
function truncate(str, maxLen) {
|
|
23878
|
+
if (str.length <= maxLen) return str;
|
|
23879
|
+
return str.slice(0, maxLen - 1) + "\u2026";
|
|
23880
|
+
}
|
|
23881
|
+
function getCommandDescription(skill) {
|
|
23882
|
+
return (skill.description || "").length > MAX_LISTING_DESC_CHARS ? (skill.description || "").slice(0, MAX_LISTING_DESC_CHARS - 1) + "\u2026" : skill.description || "";
|
|
23883
|
+
}
|
|
23884
|
+
function formatSkillsListing(skills, contextWindowTokens) {
|
|
23885
|
+
if (skills.length === 0) return "";
|
|
23886
|
+
const budget = getCharBudget(contextWindowTokens);
|
|
23887
|
+
const fullEntries = skills.map((s) => ({
|
|
23888
|
+
skill: s,
|
|
23889
|
+
full: `- ${s.name}: ${getCommandDescription(s)}`
|
|
23890
|
+
}));
|
|
23891
|
+
const fullTotal = fullEntries.reduce((sum, e) => sum + stringWidth(e.full), 0) + (fullEntries.length - 1);
|
|
23892
|
+
if (fullTotal <= budget) {
|
|
23893
|
+
return fullEntries.map((e) => e.full).join("\n");
|
|
23894
|
+
}
|
|
23895
|
+
const nameOverhead = skills.reduce((sum, s) => sum + stringWidth(s.name) + 4, 0) + (skills.length - 1);
|
|
23896
|
+
const availableForDescs = budget - nameOverhead;
|
|
23897
|
+
const maxDescLen = Math.floor(availableForDescs / skills.length);
|
|
23898
|
+
if (maxDescLen < MIN_DESC_LENGTH) {
|
|
23899
|
+
return skills.map((s) => `- ${s.name}`).join("\n");
|
|
23900
|
+
}
|
|
23901
|
+
return skills.map((s) => {
|
|
23902
|
+
const description = getCommandDescription(s);
|
|
23903
|
+
return `- ${s.name}: ${truncate(description, maxDescLen)}`;
|
|
23904
|
+
}).join("\n");
|
|
23905
|
+
}
|
|
23906
|
+
function buildSkillToolPrompt() {
|
|
23907
|
+
return `Execute a skill within the main conversation
|
|
23908
|
+
|
|
23909
|
+
Skills provide specialized capabilities and domain knowledge.
|
|
23910
|
+
|
|
23911
|
+
When users reference a "slash command" or "/<something>" (e.g., "/commit", "/review-pr"), they are referring to a skill. Use this tool to invoke it.
|
|
23912
|
+
|
|
23913
|
+
How to invoke:
|
|
23914
|
+
- Use this tool with the skill name and optional arguments
|
|
23915
|
+
- Examples:
|
|
23916
|
+
- \`skill: "pdf"\` - invoke the pdf skill
|
|
23917
|
+
- \`skill: "commit", args: "-m 'Fix bug'"\` - invoke with arguments
|
|
23918
|
+
- \`skill: "review-pr", args: "123"\` - invoke with arguments
|
|
23919
|
+
- \`skill: "ms-office-suite:pdf"\` - invoke using fully qualified name
|
|
23920
|
+
|
|
23921
|
+
Important:
|
|
23922
|
+
- Available skills are listed in system-reminder messages in the conversation
|
|
23923
|
+
- Do not invoke a skill that is already running
|
|
23924
|
+
- Do not use this tool for built-in CLI commands (like /help, /clear, etc.)
|
|
23925
|
+
- If you see a <${COMMAND_NAME_TAG}> tag in the current conversation turn, the skill has ALREADY been loaded - follow the instructions directly instead of calling this tool again
|
|
23926
|
+
`;
|
|
23927
|
+
}
|
|
23928
|
+
function loadSkillContent(skillsDir, skill) {
|
|
23929
|
+
const skillMdPath = skill.location ? path28.join(skillsDir, skill.location.slice("skills/".length)) : path28.join(skillsDir, skill.name, "SKILL.md");
|
|
23930
|
+
if (!fs24.existsSync(skillMdPath)) return null;
|
|
23931
|
+
const content = fs24.readFileSync(skillMdPath, "utf-8");
|
|
23932
|
+
const dependencies2 = parseFrontmatter(content)["requires-tools"];
|
|
23933
|
+
const requiredTools = [...new Set((Array.isArray(dependencies2) ? dependencies2 : typeof dependencies2 === "string" ? dependencies2.split(/[\s,]+/) : []).filter((n) => typeof n === "string").map((n) => n.trim().replace(/^(['"])(.*)\1$/, "$2")).filter(Boolean))];
|
|
23934
|
+
const bodyMatch = content.match(/^---\s*\n[\s\S]*?\n---\s*\n([\s\S]*)/);
|
|
23935
|
+
const body = bodyMatch ? bodyMatch[1] : content;
|
|
23936
|
+
const skillDir = path28.dirname(skillMdPath);
|
|
23937
|
+
const normalizedDir = process.platform === "win32" ? skillDir.replace(/\\/g, "/") : skillDir;
|
|
23938
|
+
let finalContent = `Base directory for this skill: ${normalizedDir}
|
|
23939
|
+
|
|
23940
|
+
${body}`;
|
|
23941
|
+
finalContent = finalContent.replace(/\$\{CLAUDE_SKILL_DIR\}/g, normalizedDir);
|
|
23942
|
+
finalContent = finalContent.replace(/\$\{CLAUDE_SESSION_ID\}/g, getSessionId());
|
|
23943
|
+
return { content: finalContent, requiredTools };
|
|
23944
|
+
}
|
|
23945
|
+
function getSessionId() {
|
|
23946
|
+
return String(process.pid);
|
|
23947
|
+
}
|
|
23948
|
+
function skillFingerprint(skill, body) {
|
|
23949
|
+
return createHash36("sha256").update(skill.location ?? skill.name).update("\0").update(body).digest("hex").slice(0, 16);
|
|
23950
|
+
}
|
|
23951
|
+
function findLoadedSkill(history, skill, fingerprint2, resolve47) {
|
|
23952
|
+
if (!history) return void 0;
|
|
23953
|
+
for (let i = history.length - 1; i >= 0; i--) {
|
|
23954
|
+
const message = history[i];
|
|
23955
|
+
if (!("role" in message) || message.role !== "tool" || message.is_error || typeof message.content !== "string") continue;
|
|
23956
|
+
let call;
|
|
23957
|
+
for (let j = i - 1; j >= 0 && !call; j--) {
|
|
23958
|
+
const previous = history[j];
|
|
23959
|
+
if ("role" in previous && previous.role === "assistant") call = (previous.tool_calls ?? []).find((c) => c.id === message.tool_call_id && c.function.name === SKILL_TOOL_NAME);
|
|
23960
|
+
}
|
|
23961
|
+
if (!call) continue;
|
|
23962
|
+
let args = {};
|
|
23963
|
+
try {
|
|
23964
|
+
args = JSON.parse(call.function.arguments);
|
|
23965
|
+
} catch {
|
|
23966
|
+
continue;
|
|
23967
|
+
}
|
|
23968
|
+
if (typeof args?.skill !== "string" || resolve47(args.skill.trim().replace(/^\//, "")) !== skill) continue;
|
|
23969
|
+
if (!message.content.includes(SKILL_FINGERPRINT_PREFIX + fingerprint2 + "]")) return void 0;
|
|
23970
|
+
return estimateMessageTokens(history.slice(i + 1)) <= SKILL_RELOAD_DISTANCE_TOKENS ? call.id : void 0;
|
|
23971
|
+
}
|
|
23972
|
+
return void 0;
|
|
23973
|
+
}
|
|
23974
|
+
function findLoadedSkillCall(history, skillName) {
|
|
23975
|
+
const resolve47 = resolveSkillFn;
|
|
23976
|
+
if (!history || !resolve47) return void 0;
|
|
23977
|
+
const skill = resolve47(skillName.trim().replace(/^\//, ""));
|
|
23978
|
+
if (!skill) return void 0;
|
|
23979
|
+
const content = loadSkillContent(skillsDirPath, skill);
|
|
23980
|
+
if (!content) return void 0;
|
|
23981
|
+
return findLoadedSkill(history, skill, skillFingerprint(skill, content.content), resolve47);
|
|
23982
|
+
}
|
|
23983
|
+
function registerSkillTool(skillsDir, skills, contextWindowTokens) {
|
|
23984
|
+
skillsDirPath = skillsDir;
|
|
23985
|
+
cachedSkills = skills;
|
|
23986
|
+
cachedContextWindowTokens = contextWindowTokens;
|
|
23987
|
+
const groupedSkills = /* @__PURE__ */ new Map();
|
|
23988
|
+
for (const skill of skills) {
|
|
23989
|
+
const parts = skill.location?.split("/");
|
|
23990
|
+
if (!parts || parts[0] !== "skills" || parts.length < 4 || skill.name.includes(":")) continue;
|
|
23991
|
+
const qualifiedName = `${parts[1]}:${skill.name}`;
|
|
23992
|
+
if (!groupedSkills.has(qualifiedName)) groupedSkills.set(qualifiedName, skill);
|
|
23993
|
+
}
|
|
23994
|
+
const resolveSkill = (name) => skills.find((s) => s.name === name) ?? groupedSkills.get(name);
|
|
23995
|
+
resolveSkillFn = resolveSkill;
|
|
23996
|
+
const entries = [];
|
|
23997
|
+
const allowedNames = /* @__PURE__ */ new Set();
|
|
23998
|
+
for (const skill of skills) {
|
|
23999
|
+
const shortName = skill.name;
|
|
24000
|
+
const parts = skill.location?.split("/");
|
|
24001
|
+
const qualifiedName = !shortName.includes(":") && parts && parts[0] === "skills" && parts.length >= 4 ? `${parts[1]}:${shortName}` : shortName;
|
|
24002
|
+
const names2 = [.../* @__PURE__ */ new Set([shortName, qualifiedName])].filter((candidate) => resolveSkill(candidate) === skill);
|
|
24003
|
+
if (names2.length === 0) continue;
|
|
24004
|
+
for (const name of names2) allowedNames.add(name);
|
|
24005
|
+
entries.push({ name: names2[0], description: getCommandDescription(skill) });
|
|
24006
|
+
}
|
|
24007
|
+
selectionCatalog = { entries, allowedNames };
|
|
24008
|
+
const descriptionText = buildSkillToolPrompt();
|
|
24009
|
+
cachedListing = formatSkillsListing(cachedSkills, contextWindowTokens);
|
|
24010
|
+
registry.register({
|
|
24011
|
+
name: SKILL_TOOL_NAME,
|
|
24012
|
+
description: descriptionText,
|
|
24013
|
+
schema: {
|
|
24014
|
+
type: "object",
|
|
24015
|
+
properties: {
|
|
24016
|
+
skill: { type: "string", description: 'The skill name. E.g., "commit", "review-pr", or "pdf"' },
|
|
24017
|
+
args: { type: "string", description: "Optional arguments for the skill" }
|
|
24018
|
+
},
|
|
24019
|
+
required: ["skill"]
|
|
24020
|
+
},
|
|
24021
|
+
// 对齐 CC SkillTool.call()
|
|
24022
|
+
handler: async (args, ctx) => {
|
|
24023
|
+
const skillName = (args.skill || "").trim();
|
|
24024
|
+
const skillArgs = args.args || "";
|
|
24025
|
+
if (!skillName) {
|
|
24026
|
+
return { content: "Invalid skill: empty name", isError: true };
|
|
24027
|
+
}
|
|
24028
|
+
const normalizedName = skillName.startsWith("/") ? skillName.substring(1) : skillName;
|
|
24029
|
+
const skill = resolveSkill(normalizedName);
|
|
24030
|
+
if (!skill) {
|
|
24031
|
+
const available = skills.map((s) => s.name).join(", ");
|
|
24032
|
+
return { content: `Unknown skill: ${normalizedName}. Available: ${available}`, isError: true };
|
|
24033
|
+
}
|
|
24034
|
+
const content = loadSkillContent(skillsDir, skill);
|
|
24035
|
+
if (!content) {
|
|
24036
|
+
return { content: `Skill file not found: ${normalizedName}`, isError: true };
|
|
24037
|
+
}
|
|
24038
|
+
const fingerprint2 = skillFingerprint(skill, content.content);
|
|
24039
|
+
const loadedEarlier = findLoadedSkill(ctx.toolResultHistory, skill, fingerprint2, resolveSkill);
|
|
24040
|
+
if (loadedEarlier) {
|
|
24041
|
+
return { content: `[\u6280\u80FD\u5DF2\u52A0\u8F7D\uFF1A${skill.name} \u6B63\u6587\u672A\u53D8\uFF0C\u89C1\u5DE5\u5177\u7ED3\u679C ${loadedEarlier}\uFF1B\u4E0D\u91CD\u590D\u6CE8\u5165\u3002]` };
|
|
24042
|
+
}
|
|
24043
|
+
let dependencyContent = "";
|
|
24044
|
+
if (content.requiredTools.length) {
|
|
24045
|
+
const loaded = loadToolSchemas(content.requiredTools, ctx);
|
|
24046
|
+
if (loaded.isError) return loaded;
|
|
24047
|
+
dependencyContent = `
|
|
24048
|
+
<${SKILL_DEPENDENCIES_TAG}>
|
|
24049
|
+
${content.requiredTools.join("\n")}
|
|
24050
|
+
</${SKILL_DEPENDENCIES_TAG}>
|
|
24051
|
+
${loaded.content}
|
|
24052
|
+
`;
|
|
24053
|
+
}
|
|
24054
|
+
const argLine = skillArgs ? `
|
|
24055
|
+
|
|
24056
|
+
User arguments: ${skillArgs}` : "";
|
|
24057
|
+
return { content: `Skill "${skill.name}" loaded. ${SKILL_FINGERPRINT_PREFIX}${fingerprint2}]${dependencyContent}
|
|
24058
|
+
|
|
24059
|
+
${content.content}${argLine}` };
|
|
24060
|
+
},
|
|
24061
|
+
// 对齐 CC SkillTool properties
|
|
24062
|
+
isConcurrencySafe: () => false,
|
|
24063
|
+
isDestructive: () => false,
|
|
24064
|
+
isReadOnly: () => true
|
|
24065
|
+
});
|
|
24066
|
+
console.log(`[skills] SkillTool registered with ${cachedSkills.length} skills (budget: ${getCharBudget(contextWindowTokens)} chars)`);
|
|
24067
|
+
}
|
|
24068
|
+
function getSkillToolState() {
|
|
24069
|
+
return { skillsDirPath, contextWindowTokens: cachedContextWindowTokens, skillNames: cachedSkills.map((s) => s.name) };
|
|
24070
|
+
}
|
|
24071
|
+
var COMMAND_NAME_TAG, MIN_DESC_LENGTH, skillsDirPath, cachedSkills, selectionCatalog, cachedListing, cachedContextWindowTokens, resolveSkillFn, SKILL_FINGERPRINT_PREFIX, SKILL_RELOAD_DISTANCE_TOKENS;
|
|
24072
|
+
var init_SkillTool = __esm({
|
|
24073
|
+
"src/tools/SkillTool/SkillTool.ts"() {
|
|
24074
|
+
"use strict";
|
|
24075
|
+
init_registry();
|
|
24076
|
+
init_scanner();
|
|
24077
|
+
init_tool_loading();
|
|
24078
|
+
init_tokenEstimate();
|
|
24079
|
+
init_constants4();
|
|
24080
|
+
COMMAND_NAME_TAG = "command-name";
|
|
24081
|
+
MIN_DESC_LENGTH = 20;
|
|
24082
|
+
skillsDirPath = "";
|
|
24083
|
+
cachedSkills = [];
|
|
24084
|
+
selectionCatalog = { entries: [], allowedNames: /* @__PURE__ */ new Set() };
|
|
24085
|
+
cachedListing = "";
|
|
24086
|
+
SKILL_FINGERPRINT_PREFIX = "[fingerprint ";
|
|
24087
|
+
SKILL_RELOAD_DISTANCE_TOKENS = 16e3;
|
|
24088
|
+
}
|
|
24089
|
+
});
|
|
24090
|
+
|
|
23599
24091
|
// src/memory/memdir/memoryTypes.ts
|
|
23600
24092
|
var MEMORY_TYPES, TYPES_SECTION_INDIVIDUAL, WHAT_NOT_TO_SAVE_SECTION, MEMORY_DRIFT_CAVEAT, WHEN_TO_ACCESS_SECTION, TRUSTING_RECALL_SECTION, MEMORY_FRONTMATTER_EXAMPLE;
|
|
23601
24093
|
var init_memoryTypes = __esm({
|
|
@@ -23760,8 +24252,8 @@ __export(memdir_exports, {
|
|
|
23760
24252
|
loadMemoryPrompt: () => loadMemoryPrompt,
|
|
23761
24253
|
truncateEntrypointContent: () => truncateEntrypointContent
|
|
23762
24254
|
});
|
|
23763
|
-
import { readFileSync as
|
|
23764
|
-
import { join as
|
|
24255
|
+
import { readFileSync as readFileSync21 } from "node:fs";
|
|
24256
|
+
import { join as join38 } from "node:path";
|
|
23765
24257
|
function truncateEntrypointContent(raw) {
|
|
23766
24258
|
const trimmed = raw.trim();
|
|
23767
24259
|
const contentLines = trimmed.split("\n");
|
|
@@ -23854,11 +24346,11 @@ function buildMemoryLines(displayName, memoryDir, extraGuidelines, skipIndex = f
|
|
|
23854
24346
|
}
|
|
23855
24347
|
function buildMemoryPrompt(params) {
|
|
23856
24348
|
const { displayName, memoryDir, extraGuidelines } = params;
|
|
23857
|
-
const entrypoint =
|
|
24349
|
+
const entrypoint = join38(memoryDir, ENTRYPOINT_NAME);
|
|
23858
24350
|
let entrypointContent = params.entrypointContent ?? "";
|
|
23859
24351
|
if (params.entrypointContent === void 0) {
|
|
23860
24352
|
try {
|
|
23861
|
-
entrypointContent =
|
|
24353
|
+
entrypointContent = readFileSync21(entrypoint, "utf-8");
|
|
23862
24354
|
} catch {
|
|
23863
24355
|
}
|
|
23864
24356
|
}
|
|
@@ -23904,8 +24396,8 @@ __export(context_analyzer_exports, {
|
|
|
23904
24396
|
formatContextReport: () => formatContextReport,
|
|
23905
24397
|
scanMemoryFiles: () => scanMemoryFiles
|
|
23906
24398
|
});
|
|
23907
|
-
import * as
|
|
23908
|
-
import * as
|
|
24399
|
+
import * as fs25 from "node:fs";
|
|
24400
|
+
import * as path29 from "node:path";
|
|
23909
24401
|
function estimateMessageTokens2(m) {
|
|
23910
24402
|
let tokens = 0;
|
|
23911
24403
|
if (typeof m.content === "string") {
|
|
@@ -24015,9 +24507,9 @@ function breakdownMessages(messages) {
|
|
|
24015
24507
|
}
|
|
24016
24508
|
async function scanMemoryFiles(workspace) {
|
|
24017
24509
|
const files = [];
|
|
24018
|
-
const soul = readFileIfExists(
|
|
24510
|
+
const soul = readFileIfExists(path29.join(workspace, "SOUL.md"));
|
|
24019
24511
|
if (soul) files.push({ path: "SOUL.md", tokens: roughTokenCountEstimation(soul), stable: true });
|
|
24020
|
-
const agents = readFileIfExists(
|
|
24512
|
+
const agents = readFileIfExists(path29.join(workspace, "AGENTS.md"));
|
|
24021
24513
|
if (agents) files.push({ path: "AGENTS.md", tokens: roughTokenCountEstimation(agents), stable: true });
|
|
24022
24514
|
try {
|
|
24023
24515
|
const { buildMemoryPrompt: buildMemoryPrompt2 } = await Promise.resolve().then(() => (init_memdir(), memdir_exports));
|
|
@@ -24033,7 +24525,7 @@ async function scanMemoryFiles(workspace) {
|
|
|
24033
24525
|
}
|
|
24034
24526
|
function readFileIfExists(filePath) {
|
|
24035
24527
|
try {
|
|
24036
|
-
if (
|
|
24528
|
+
if (fs25.existsSync(filePath)) return fs25.readFileSync(filePath, "utf-8");
|
|
24037
24529
|
} catch {
|
|
24038
24530
|
}
|
|
24039
24531
|
return null;
|
|
@@ -24304,6 +24796,8 @@ var init_query = __esm({
|
|
|
24304
24796
|
init_task_manager();
|
|
24305
24797
|
init_skill_gate();
|
|
24306
24798
|
init_skill_gate();
|
|
24799
|
+
init_query_skill_selection();
|
|
24800
|
+
init_SkillTool();
|
|
24307
24801
|
QueryEngine = class _QueryEngine {
|
|
24308
24802
|
constructor(provider, options) {
|
|
24309
24803
|
this.provider = provider;
|
|
@@ -24657,6 +25151,7 @@ var init_query = __esm({
|
|
|
24657
25151
|
turnCount++;
|
|
24658
25152
|
const steers = this.pendingSteers.splice(0);
|
|
24659
25153
|
let steerConsumedThisTurn = false;
|
|
25154
|
+
let userSteerConsumedThisTurn = false;
|
|
24660
25155
|
if (steers.length > 0) {
|
|
24661
25156
|
for (const input of steers) {
|
|
24662
25157
|
if (this.steerHistoryIds.has(input.id)) {
|
|
@@ -24688,6 +25183,7 @@ var init_query = __esm({
|
|
|
24688
25183
|
if (collectStopEvidence) stopUserMessages.push(input.originalText ?? input.text);
|
|
24689
25184
|
this.steerHistoryIds.add(input.id);
|
|
24690
25185
|
steerConsumedThisTurn = true;
|
|
25186
|
+
userSteerConsumedThisTurn = true;
|
|
24691
25187
|
yield {
|
|
24692
25188
|
type: "user_input",
|
|
24693
25189
|
message: steerMsg,
|
|
@@ -24943,7 +25439,53 @@ var init_query = __esm({
|
|
|
24943
25439
|
let turnAborted = false;
|
|
24944
25440
|
try {
|
|
24945
25441
|
wholeQueryAbort.signal.throwIfAborted();
|
|
24946
|
-
const
|
|
25442
|
+
const beforeRequest = () => {
|
|
25443
|
+
wholeQueryAbort.signal.throwIfAborted();
|
|
25444
|
+
ac.signal.throwIfAborted();
|
|
25445
|
+
};
|
|
25446
|
+
const startRequest = () => {
|
|
25447
|
+
this.phase = "streaming";
|
|
25448
|
+
assertRuntimeAuthority(void 0, "INPUT");
|
|
25449
|
+
if (perTurnOptions?.onRequestStarted) {
|
|
25450
|
+
const start = perTurnOptions.onRequestStarted;
|
|
25451
|
+
setImmediate(() => {
|
|
25452
|
+
if (!wholeQueryAbort.signal.aborted) start();
|
|
25453
|
+
});
|
|
25454
|
+
}
|
|
25455
|
+
};
|
|
25456
|
+
let selected;
|
|
25457
|
+
const selectionInput = perTurnOptions?.skillSelectionInput;
|
|
25458
|
+
const skill = turnCount === 1 && maxTurns >= 2 && !userSteerConsumedThisTurn && !hasPendingUserInput() && selectionInput ? allToolDefs.find((tool) => tool.function.name === SKILL_TOOL_NAME) : void 0;
|
|
25459
|
+
const catalog = skill ? getSkillSelectionCatalog() : void 0;
|
|
25460
|
+
if (skill && selectionInput && catalog?.entries.length) {
|
|
25461
|
+
const input = normalizeMessagesForAPI([selectionInput]);
|
|
25462
|
+
const started = performance.now();
|
|
25463
|
+
startRequest();
|
|
25464
|
+
const selection = await selectSkillCall(queryProvider, {
|
|
25465
|
+
preferFastFallback,
|
|
25466
|
+
model: queryModel,
|
|
25467
|
+
messages: input,
|
|
25468
|
+
tools: [skill],
|
|
25469
|
+
systemStable: SKILL_SELECTION_PROMPT + "\n\n" + JSON.stringify(catalog.entries),
|
|
25470
|
+
maxTokens: SKILL_SELECTION_MAX_TOKENS,
|
|
25471
|
+
signal: ac.signal,
|
|
25472
|
+
beforeRequest: () => {
|
|
25473
|
+
assertHostTurnCurrent();
|
|
25474
|
+
beforeRequest();
|
|
25475
|
+
},
|
|
25476
|
+
disableThinking: true
|
|
25477
|
+
}, catalog.allowedNames, recordUsage);
|
|
25478
|
+
assertHostTurnCurrent();
|
|
25479
|
+
beforeRequest();
|
|
25480
|
+
console.log(`${this.logPrefix} [skill-selection] ${selection.outcome} ms=${Math.round(performance.now() - started)}`);
|
|
25481
|
+
if (hasPendingUserInput()) continue;
|
|
25482
|
+
if (selection.outcome === "selected") {
|
|
25483
|
+
if (findLoadedSkillCall(currentMessages, selection.skill)) {
|
|
25484
|
+
console.log(`${this.logPrefix} [skill-selection] already-loaded ${selection.skill}`);
|
|
25485
|
+
} else selected = selection.chunks;
|
|
25486
|
+
}
|
|
25487
|
+
}
|
|
25488
|
+
const view = (selected ? [] : normalizeMessagesForAPI(currentMessages)).map((m) => {
|
|
24947
25489
|
if (!Array.isArray(m.content) || !m.imageInput?.observed || !queryModelRef) return m;
|
|
24948
25490
|
const blocks = m.content.filter((b) => {
|
|
24949
25491
|
if (b.type === "image" || b.type === "image_ref") return !!queryInputs?.includes("image");
|
|
@@ -24978,7 +25520,7 @@ ${hint}` : [...current2.content, { type: "text", text: hint }] };
|
|
|
24978
25520
|
const fullSystemDynamic = deferredHint && perTurnSystemDynamic ? `${deferredHint}
|
|
24979
25521
|
|
|
24980
25522
|
${perTurnSystemDynamic}` : deferredHint || perTurnSystemDynamic;
|
|
24981
|
-
if ((!this.options.agentLabel || this.options.agentLabel === "main") && isContextDumpEnabled()) {
|
|
25523
|
+
if (!selected && (!this.options.agentLabel || this.options.agentLabel === "main") && isContextDumpEnabled()) {
|
|
24982
25524
|
try {
|
|
24983
25525
|
const ws = process.env.ENGINE7_WORKSPACE;
|
|
24984
25526
|
if (ws) {
|
|
@@ -24994,15 +25536,8 @@ ${perTurnSystemDynamic}` : deferredHint || perTurnSystemDynamic;
|
|
|
24994
25536
|
} catch {
|
|
24995
25537
|
}
|
|
24996
25538
|
}
|
|
24997
|
-
|
|
24998
|
-
|
|
24999
|
-
if (perTurnOptions?.onRequestStarted) {
|
|
25000
|
-
const start = perTurnOptions.onRequestStarted;
|
|
25001
|
-
setImmediate(() => {
|
|
25002
|
-
if (!wholeQueryAbort.signal.aborted) start();
|
|
25003
|
-
});
|
|
25004
|
-
}
|
|
25005
|
-
for await (const chunk of queryProvider.streamChat({
|
|
25539
|
+
if (!selected) startRequest();
|
|
25540
|
+
for await (const chunk of selected ?? queryProvider.streamChat({
|
|
25006
25541
|
preferFastFallback,
|
|
25007
25542
|
model: queryModel,
|
|
25008
25543
|
messages: apiMessages,
|
|
@@ -25015,10 +25550,7 @@ ${perTurnSystemDynamic}` : deferredHint || perTurnSystemDynamic;
|
|
|
25015
25550
|
maxTokens: this.resolveRequestMaxTokens(apiMessages, maxTokensOverride),
|
|
25016
25551
|
temperature: this.options.temperature,
|
|
25017
25552
|
signal: ac.signal,
|
|
25018
|
-
beforeRequest
|
|
25019
|
-
wholeQueryAbort.signal.throwIfAborted();
|
|
25020
|
-
ac.signal.throwIfAborted();
|
|
25021
|
-
},
|
|
25553
|
+
beforeRequest,
|
|
25022
25554
|
disableThinking: this.options.disableThinking || !!perTurnEmotion
|
|
25023
25555
|
// 情感模式关 thinking(对齐 deskBuddy)
|
|
25024
25556
|
})) {
|
|
@@ -25379,6 +25911,7 @@ ${perTurnSystemDynamic}` : deferredHint || perTurnSystemDynamic;
|
|
|
25379
25911
|
if (vcDelivery) await vcDelivery;
|
|
25380
25912
|
}
|
|
25381
25913
|
const { messages: toolResults, summaries } = toolRes;
|
|
25914
|
+
if (selected) console.log(`${this.logPrefix} [skill-selection] ${summaries.length === 1 && !summaries[0].isError ? "loaded" : "load-failed"}`);
|
|
25382
25915
|
if (collectStopEvidence) stopToolResults.push(...summaries);
|
|
25383
25916
|
for (const s of summaries) {
|
|
25384
25917
|
try {
|
|
@@ -26446,30 +26979,30 @@ __export(teamHelpers_exports, {
|
|
|
26446
26979
|
writeTeamFile: () => writeTeamFile,
|
|
26447
26980
|
writeTeamFileAsync: () => writeTeamFileAsync
|
|
26448
26981
|
});
|
|
26449
|
-
import { mkdirSync as mkdirSync21, readFileSync as
|
|
26982
|
+
import { mkdirSync as mkdirSync21, readFileSync as readFileSync23, writeFileSync as writeFileSync21 } from "node:fs";
|
|
26450
26983
|
import { mkdir as mkdir2, readFile, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
|
|
26451
|
-
import { join as
|
|
26984
|
+
import { join as join40 } from "node:path";
|
|
26452
26985
|
function initTeamDirs(stateDir) {
|
|
26453
26986
|
_stateDir = stateDir;
|
|
26454
26987
|
}
|
|
26455
26988
|
function getTeamsDir() {
|
|
26456
|
-
return
|
|
26989
|
+
return join40(_stateDir, "teams");
|
|
26457
26990
|
}
|
|
26458
26991
|
function getTasksDir() {
|
|
26459
|
-
return
|
|
26992
|
+
return join40(_stateDir, "tasks");
|
|
26460
26993
|
}
|
|
26461
26994
|
function sanitizeName(name) {
|
|
26462
26995
|
return name.replace(/[^a-zA-Z0-9_-]/g, "-").toLowerCase();
|
|
26463
26996
|
}
|
|
26464
26997
|
function getTeamDir(teamName) {
|
|
26465
|
-
return
|
|
26998
|
+
return join40(getTeamsDir(), sanitizeName(teamName));
|
|
26466
26999
|
}
|
|
26467
27000
|
function getTeamFilePath(teamName) {
|
|
26468
|
-
return
|
|
27001
|
+
return join40(getTeamDir(teamName), "config.json");
|
|
26469
27002
|
}
|
|
26470
27003
|
function readTeamFile(teamName) {
|
|
26471
27004
|
try {
|
|
26472
|
-
const content =
|
|
27005
|
+
const content = readFileSync23(getTeamFilePath(teamName), "utf-8");
|
|
26473
27006
|
return JSON.parse(content);
|
|
26474
27007
|
} catch (e) {
|
|
26475
27008
|
if (e?.code === "ENOENT") return null;
|
|
@@ -26570,7 +27103,7 @@ async function cleanupTeamDirectories(teamName) {
|
|
|
26570
27103
|
} catch (error) {
|
|
26571
27104
|
console.warn(`[teamHelpers] Failed to clean up team directory ${teamDir}: ${error.message}`);
|
|
26572
27105
|
}
|
|
26573
|
-
const tasksDir =
|
|
27106
|
+
const tasksDir = join40(getTasksDir(), sanitizedName);
|
|
26574
27107
|
try {
|
|
26575
27108
|
await rm2(tasksDir, { recursive: true, force: true });
|
|
26576
27109
|
console.log(`[teamHelpers] Cleaned up tasks directory: ${tasksDir}`);
|
|
@@ -26579,7 +27112,7 @@ async function cleanupTeamDirectories(teamName) {
|
|
|
26579
27112
|
}
|
|
26580
27113
|
}
|
|
26581
27114
|
function ensureTasksDir(taskListId) {
|
|
26582
|
-
const dir =
|
|
27115
|
+
const dir = join40(getTasksDir(), taskListId);
|
|
26583
27116
|
mkdirSync21(dir, { recursive: true });
|
|
26584
27117
|
}
|
|
26585
27118
|
function setLeaderTeamName(name) {
|
|
@@ -26760,9 +27293,9 @@ The user interacts primarily with the team lead. Your work is coordinated throug
|
|
|
26760
27293
|
|
|
26761
27294
|
// src/swarm/teammateMailbox.ts
|
|
26762
27295
|
import { mkdir as mkdir3, readFile as readFile2, writeFile as writeFile4 } from "node:fs/promises";
|
|
26763
|
-
import { join as
|
|
27296
|
+
import { join as join41 } from "node:path";
|
|
26764
27297
|
function getTeamsDir2() {
|
|
26765
|
-
return
|
|
27298
|
+
return join41(process.env.ENGINE_STATE_DIR || ".", "teams");
|
|
26766
27299
|
}
|
|
26767
27300
|
function sanitizePathComponent(s) {
|
|
26768
27301
|
return s.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
@@ -26771,12 +27304,12 @@ function getInboxPath(agentName, teamName) {
|
|
|
26771
27304
|
const team = teamName || "default";
|
|
26772
27305
|
const safeTeam = sanitizePathComponent(team);
|
|
26773
27306
|
const safeAgentName = sanitizePathComponent(agentName);
|
|
26774
|
-
return
|
|
27307
|
+
return join41(getTeamsDir2(), safeTeam, "inboxes", `${safeAgentName}.json`);
|
|
26775
27308
|
}
|
|
26776
27309
|
async function ensureInboxDir(teamName) {
|
|
26777
27310
|
const team = teamName || "default";
|
|
26778
27311
|
const safeTeam = sanitizePathComponent(team);
|
|
26779
|
-
const inboxDir =
|
|
27312
|
+
const inboxDir = join41(getTeamsDir2(), safeTeam, "inboxes");
|
|
26780
27313
|
await mkdir3(inboxDir, { recursive: true });
|
|
26781
27314
|
}
|
|
26782
27315
|
async function sleep2(ms) {
|
|
@@ -28476,284 +29009,6 @@ var init_web_fetch = __esm({
|
|
|
28476
29009
|
}
|
|
28477
29010
|
});
|
|
28478
29011
|
|
|
28479
|
-
// src/skills/scanner.ts
|
|
28480
|
-
import * as path28 from "node:path";
|
|
28481
|
-
import * as fs24 from "node:fs";
|
|
28482
|
-
function scanSkills(skillsDir) {
|
|
28483
|
-
if (!fs24.existsSync(skillsDir)) {
|
|
28484
|
-
console.log(`[skills] Directory not found: ${skillsDir}`);
|
|
28485
|
-
return [];
|
|
28486
|
-
}
|
|
28487
|
-
const skills = [];
|
|
28488
|
-
const scanDir = (dir, depth, seen) => {
|
|
28489
|
-
const entries = fs24.readdirSync(dir, { withFileTypes: true });
|
|
28490
|
-
for (const entry of entries) {
|
|
28491
|
-
if (entry.name.startsWith(".") || entry.name === "_archive") continue;
|
|
28492
|
-
const full = path28.join(dir, entry.name);
|
|
28493
|
-
let isDir = entry.isDirectory();
|
|
28494
|
-
let isFile = entry.isFile();
|
|
28495
|
-
if (entry.isSymbolicLink()) {
|
|
28496
|
-
try {
|
|
28497
|
-
const st = fs24.statSync(full);
|
|
28498
|
-
isDir = st.isDirectory();
|
|
28499
|
-
isFile = st.isFile();
|
|
28500
|
-
} catch {
|
|
28501
|
-
console.warn(`[skills] Broken symlink, skipped: ${full}`);
|
|
28502
|
-
continue;
|
|
28503
|
-
}
|
|
28504
|
-
}
|
|
28505
|
-
if (isDir && depth < 3) {
|
|
28506
|
-
let real;
|
|
28507
|
-
try {
|
|
28508
|
-
real = fs24.realpathSync(full);
|
|
28509
|
-
} catch {
|
|
28510
|
-
continue;
|
|
28511
|
-
}
|
|
28512
|
-
if (seen.has(real)) continue;
|
|
28513
|
-
seen.add(real);
|
|
28514
|
-
scanDir(full, depth + 1, seen);
|
|
28515
|
-
continue;
|
|
28516
|
-
}
|
|
28517
|
-
if (!isFile || entry.name !== "SKILL.md") continue;
|
|
28518
|
-
try {
|
|
28519
|
-
const content = fs24.readFileSync(full, "utf-8");
|
|
28520
|
-
const frontmatter = parseFrontmatter(content);
|
|
28521
|
-
if (!frontmatter.name) {
|
|
28522
|
-
console.warn(`[skills] Skipping ${full}: missing 'name' in frontmatter`);
|
|
28523
|
-
continue;
|
|
28524
|
-
}
|
|
28525
|
-
const rel = path28.relative(skillsDir, full).split(path28.sep).join("/");
|
|
28526
|
-
skills.push({
|
|
28527
|
-
name: frontmatter.name,
|
|
28528
|
-
description: frontmatter.description || "",
|
|
28529
|
-
location: `skills/${rel}`,
|
|
28530
|
-
...frontmatter
|
|
28531
|
-
});
|
|
28532
|
-
} catch (err) {
|
|
28533
|
-
console.warn(`[skills] Error parsing ${full}: ${err.message}`);
|
|
28534
|
-
}
|
|
28535
|
-
}
|
|
28536
|
-
};
|
|
28537
|
-
scanDir(skillsDir, 0, /* @__PURE__ */ new Set([fs24.realpathSync(skillsDir)]));
|
|
28538
|
-
console.log(`[skills] Scanned ${skills.length} skills from ${skillsDir}`);
|
|
28539
|
-
return skills;
|
|
28540
|
-
}
|
|
28541
|
-
function parseFrontmatter(content) {
|
|
28542
|
-
const result = {};
|
|
28543
|
-
const match = content.match(/^---\s*\n([\s\S]*?)\n---/);
|
|
28544
|
-
if (!match) return result;
|
|
28545
|
-
const lines = match[1].split("\n");
|
|
28546
|
-
let i = 0;
|
|
28547
|
-
while (i < lines.length) {
|
|
28548
|
-
const line = lines[i];
|
|
28549
|
-
const colonIdx = line.indexOf(":");
|
|
28550
|
-
if (colonIdx === -1) {
|
|
28551
|
-
i++;
|
|
28552
|
-
continue;
|
|
28553
|
-
}
|
|
28554
|
-
const key3 = line.slice(0, colonIdx).trim();
|
|
28555
|
-
let value2 = line.slice(colonIdx + 1).trim();
|
|
28556
|
-
if (value2.startsWith('"') && value2.endsWith('"') || value2.startsWith("'") && value2.endsWith("'")) {
|
|
28557
|
-
value2 = value2.slice(1, -1);
|
|
28558
|
-
result[key3] = value2;
|
|
28559
|
-
i++;
|
|
28560
|
-
continue;
|
|
28561
|
-
} else if (value2 === "|" || value2 === ">") {
|
|
28562
|
-
const blockLines = [];
|
|
28563
|
-
i++;
|
|
28564
|
-
while (i < lines.length && lines[i].startsWith(" ")) {
|
|
28565
|
-
blockLines.push(lines[i].slice(2));
|
|
28566
|
-
i++;
|
|
28567
|
-
}
|
|
28568
|
-
result[key3] = blockLines.join("\n").trim();
|
|
28569
|
-
continue;
|
|
28570
|
-
} else if (value2.startsWith("[") && value2.endsWith("]")) {
|
|
28571
|
-
result[key3] = value2.slice(1, -1).split(",").map((s) => s.trim());
|
|
28572
|
-
i++;
|
|
28573
|
-
continue;
|
|
28574
|
-
} else if (value2.includes(" ") && !value2.startsWith('"')) {
|
|
28575
|
-
result[key3] = value2;
|
|
28576
|
-
} else {
|
|
28577
|
-
result[key3] = value2;
|
|
28578
|
-
}
|
|
28579
|
-
i++;
|
|
28580
|
-
}
|
|
28581
|
-
return result;
|
|
28582
|
-
}
|
|
28583
|
-
var init_scanner = __esm({
|
|
28584
|
-
"src/skills/scanner.ts"() {
|
|
28585
|
-
"use strict";
|
|
28586
|
-
}
|
|
28587
|
-
});
|
|
28588
|
-
|
|
28589
|
-
// src/tools/SkillTool/SkillTool.ts
|
|
28590
|
-
import * as fs25 from "node:fs";
|
|
28591
|
-
import * as path29 from "node:path";
|
|
28592
|
-
function getCharBudget(contextWindowTokens) {
|
|
28593
|
-
if (contextWindowTokens) {
|
|
28594
|
-
return Math.floor(contextWindowTokens * CHARS_PER_TOKEN * SKILL_BUDGET_CONTEXT_PERCENT);
|
|
28595
|
-
}
|
|
28596
|
-
return DEFAULT_CHAR_BUDGET;
|
|
28597
|
-
}
|
|
28598
|
-
function stringWidth(str) {
|
|
28599
|
-
return str.length;
|
|
28600
|
-
}
|
|
28601
|
-
function truncate(str, maxLen) {
|
|
28602
|
-
if (str.length <= maxLen) return str;
|
|
28603
|
-
return str.slice(0, maxLen - 1) + "\u2026";
|
|
28604
|
-
}
|
|
28605
|
-
function getCommandDescription(skill) {
|
|
28606
|
-
return (skill.description || "").length > MAX_LISTING_DESC_CHARS ? (skill.description || "").slice(0, MAX_LISTING_DESC_CHARS - 1) + "\u2026" : skill.description || "";
|
|
28607
|
-
}
|
|
28608
|
-
function formatSkillsListing(skills, contextWindowTokens) {
|
|
28609
|
-
if (skills.length === 0) return "";
|
|
28610
|
-
const budget = getCharBudget(contextWindowTokens);
|
|
28611
|
-
const fullEntries = skills.map((s) => ({
|
|
28612
|
-
skill: s,
|
|
28613
|
-
full: `- ${s.name}: ${getCommandDescription(s)}`
|
|
28614
|
-
}));
|
|
28615
|
-
const fullTotal = fullEntries.reduce((sum, e) => sum + stringWidth(e.full), 0) + (fullEntries.length - 1);
|
|
28616
|
-
if (fullTotal <= budget) {
|
|
28617
|
-
return fullEntries.map((e) => e.full).join("\n");
|
|
28618
|
-
}
|
|
28619
|
-
const nameOverhead = skills.reduce((sum, s) => sum + stringWidth(s.name) + 4, 0) + (skills.length - 1);
|
|
28620
|
-
const availableForDescs = budget - nameOverhead;
|
|
28621
|
-
const maxDescLen = Math.floor(availableForDescs / skills.length);
|
|
28622
|
-
if (maxDescLen < MIN_DESC_LENGTH) {
|
|
28623
|
-
return skills.map((s) => `- ${s.name}`).join("\n");
|
|
28624
|
-
}
|
|
28625
|
-
return skills.map((s) => {
|
|
28626
|
-
const description = getCommandDescription(s);
|
|
28627
|
-
return `- ${s.name}: ${truncate(description, maxDescLen)}`;
|
|
28628
|
-
}).join("\n");
|
|
28629
|
-
}
|
|
28630
|
-
function buildSkillToolPrompt() {
|
|
28631
|
-
return `Execute a skill within the main conversation
|
|
28632
|
-
|
|
28633
|
-
Skills provide specialized capabilities and domain knowledge.
|
|
28634
|
-
|
|
28635
|
-
When users reference a "slash command" or "/<something>" (e.g., "/commit", "/review-pr"), they are referring to a skill. Use this tool to invoke it.
|
|
28636
|
-
|
|
28637
|
-
How to invoke:
|
|
28638
|
-
- Use this tool with the skill name and optional arguments
|
|
28639
|
-
- Examples:
|
|
28640
|
-
- \`skill: "pdf"\` - invoke the pdf skill
|
|
28641
|
-
- \`skill: "commit", args: "-m 'Fix bug'"\` - invoke with arguments
|
|
28642
|
-
- \`skill: "review-pr", args: "123"\` - invoke with arguments
|
|
28643
|
-
- \`skill: "ms-office-suite:pdf"\` - invoke using fully qualified name
|
|
28644
|
-
|
|
28645
|
-
Important:
|
|
28646
|
-
- Available skills are listed in system-reminder messages in the conversation
|
|
28647
|
-
- Do not invoke a skill that is already running
|
|
28648
|
-
- Do not use this tool for built-in CLI commands (like /help, /clear, etc.)
|
|
28649
|
-
- If you see a <${COMMAND_NAME_TAG}> tag in the current conversation turn, the skill has ALREADY been loaded - follow the instructions directly instead of calling this tool again
|
|
28650
|
-
`;
|
|
28651
|
-
}
|
|
28652
|
-
function loadSkillContent(skillsDir, skill) {
|
|
28653
|
-
const skillMdPath = skill.location ? path29.join(skillsDir, skill.location.slice("skills/".length)) : path29.join(skillsDir, skill.name, "SKILL.md");
|
|
28654
|
-
if (!fs25.existsSync(skillMdPath)) return null;
|
|
28655
|
-
const content = fs25.readFileSync(skillMdPath, "utf-8");
|
|
28656
|
-
const dependencies2 = parseFrontmatter(content)["requires-tools"];
|
|
28657
|
-
const requiredTools = [...new Set((Array.isArray(dependencies2) ? dependencies2 : typeof dependencies2 === "string" ? dependencies2.split(/[\s,]+/) : []).filter((n) => typeof n === "string").map((n) => n.trim().replace(/^(['"])(.*)\1$/, "$2")).filter(Boolean))];
|
|
28658
|
-
const bodyMatch = content.match(/^---\s*\n[\s\S]*?\n---\s*\n([\s\S]*)/);
|
|
28659
|
-
const body = bodyMatch ? bodyMatch[1] : content;
|
|
28660
|
-
const skillDir = path29.dirname(skillMdPath);
|
|
28661
|
-
const normalizedDir = process.platform === "win32" ? skillDir.replace(/\\/g, "/") : skillDir;
|
|
28662
|
-
let finalContent = `Base directory for this skill: ${normalizedDir}
|
|
28663
|
-
|
|
28664
|
-
${body}`;
|
|
28665
|
-
finalContent = finalContent.replace(/\$\{CLAUDE_SKILL_DIR\}/g, normalizedDir);
|
|
28666
|
-
finalContent = finalContent.replace(/\$\{CLAUDE_SESSION_ID\}/g, getSessionId());
|
|
28667
|
-
return { content: finalContent, requiredTools };
|
|
28668
|
-
}
|
|
28669
|
-
function getSessionId() {
|
|
28670
|
-
return String(process.pid);
|
|
28671
|
-
}
|
|
28672
|
-
function registerSkillTool(skillsDir, skills, contextWindowTokens) {
|
|
28673
|
-
skillsDirPath = skillsDir;
|
|
28674
|
-
cachedSkills = skills;
|
|
28675
|
-
cachedContextWindowTokens = contextWindowTokens;
|
|
28676
|
-
const groupedSkills = /* @__PURE__ */ new Map();
|
|
28677
|
-
for (const skill of skills) {
|
|
28678
|
-
const parts = skill.location?.split("/");
|
|
28679
|
-
if (!parts || parts[0] !== "skills" || parts.length < 4 || skill.name.includes(":")) continue;
|
|
28680
|
-
const qualifiedName = `${parts[1]}:${skill.name}`;
|
|
28681
|
-
if (!groupedSkills.has(qualifiedName)) groupedSkills.set(qualifiedName, skill);
|
|
28682
|
-
}
|
|
28683
|
-
const descriptionText = buildSkillToolPrompt();
|
|
28684
|
-
cachedListing = formatSkillsListing(cachedSkills, contextWindowTokens);
|
|
28685
|
-
registry.register({
|
|
28686
|
-
name: SKILL_TOOL_NAME,
|
|
28687
|
-
description: descriptionText,
|
|
28688
|
-
schema: {
|
|
28689
|
-
type: "object",
|
|
28690
|
-
properties: {
|
|
28691
|
-
skill: { type: "string", description: 'The skill name. E.g., "commit", "review-pr", or "pdf"' },
|
|
28692
|
-
args: { type: "string", description: "Optional arguments for the skill" }
|
|
28693
|
-
},
|
|
28694
|
-
required: ["skill"]
|
|
28695
|
-
},
|
|
28696
|
-
// 对齐 CC SkillTool.call()
|
|
28697
|
-
handler: async (args, ctx) => {
|
|
28698
|
-
const skillName = (args.skill || "").trim();
|
|
28699
|
-
const skillArgs = args.args || "";
|
|
28700
|
-
if (!skillName) {
|
|
28701
|
-
return { content: "Invalid skill: empty name", isError: true };
|
|
28702
|
-
}
|
|
28703
|
-
const normalizedName = skillName.startsWith("/") ? skillName.substring(1) : skillName;
|
|
28704
|
-
const skill = skills.find((s) => s.name === normalizedName) ?? groupedSkills.get(normalizedName);
|
|
28705
|
-
if (!skill) {
|
|
28706
|
-
const available = skills.map((s) => s.name).join(", ");
|
|
28707
|
-
return { content: `Unknown skill: ${normalizedName}. Available: ${available}`, isError: true };
|
|
28708
|
-
}
|
|
28709
|
-
const content = loadSkillContent(skillsDir, skill);
|
|
28710
|
-
if (!content) {
|
|
28711
|
-
return { content: `Skill file not found: ${normalizedName}`, isError: true };
|
|
28712
|
-
}
|
|
28713
|
-
let dependencyContent = "";
|
|
28714
|
-
if (content.requiredTools.length) {
|
|
28715
|
-
const loaded = loadToolSchemas(content.requiredTools, ctx);
|
|
28716
|
-
if (loaded.isError) return loaded;
|
|
28717
|
-
dependencyContent = `
|
|
28718
|
-
<${SKILL_DEPENDENCIES_TAG}>
|
|
28719
|
-
${content.requiredTools.join("\n")}
|
|
28720
|
-
</${SKILL_DEPENDENCIES_TAG}>
|
|
28721
|
-
${loaded.content}
|
|
28722
|
-
`;
|
|
28723
|
-
}
|
|
28724
|
-
const argLine = skillArgs ? `
|
|
28725
|
-
|
|
28726
|
-
User arguments: ${skillArgs}` : "";
|
|
28727
|
-
return { content: `Skill "${skill.name}" loaded.${dependencyContent}
|
|
28728
|
-
|
|
28729
|
-
${content.content}${argLine}` };
|
|
28730
|
-
},
|
|
28731
|
-
// 对齐 CC SkillTool properties
|
|
28732
|
-
isConcurrencySafe: () => false,
|
|
28733
|
-
isDestructive: () => false,
|
|
28734
|
-
isReadOnly: () => true
|
|
28735
|
-
});
|
|
28736
|
-
console.log(`[skills] SkillTool registered with ${cachedSkills.length} skills (budget: ${getCharBudget(contextWindowTokens)} chars)`);
|
|
28737
|
-
}
|
|
28738
|
-
function getSkillToolState() {
|
|
28739
|
-
return { skillsDirPath, contextWindowTokens: cachedContextWindowTokens, skillNames: cachedSkills.map((s) => s.name) };
|
|
28740
|
-
}
|
|
28741
|
-
var COMMAND_NAME_TAG, MIN_DESC_LENGTH, skillsDirPath, cachedSkills, cachedListing, cachedContextWindowTokens;
|
|
28742
|
-
var init_SkillTool = __esm({
|
|
28743
|
-
"src/tools/SkillTool/SkillTool.ts"() {
|
|
28744
|
-
"use strict";
|
|
28745
|
-
init_registry();
|
|
28746
|
-
init_scanner();
|
|
28747
|
-
init_tool_loading();
|
|
28748
|
-
init_constants4();
|
|
28749
|
-
COMMAND_NAME_TAG = "command-name";
|
|
28750
|
-
MIN_DESC_LENGTH = 20;
|
|
28751
|
-
skillsDirPath = "";
|
|
28752
|
-
cachedSkills = [];
|
|
28753
|
-
cachedListing = "";
|
|
28754
|
-
}
|
|
28755
|
-
});
|
|
28756
|
-
|
|
28757
29012
|
// src/startup/skill-sync.ts
|
|
28758
29013
|
import * as fs26 from "node:fs";
|
|
28759
29014
|
import * as path30 from "node:path";
|
|
@@ -31844,7 +32099,7 @@ import { request as request8 } from "node:https";
|
|
|
31844
32099
|
import { existsSync as existsSync26, mkdirSync as mkdirSync24, readFileSync as readFileSync26, writeFileSync as writeFileSync23, readdirSync as readdirSync11, cpSync, realpathSync as realpathSync14, symlinkSync, lstatSync as lstatSync18 } from "node:fs";
|
|
31845
32100
|
import { join as join46 } from "node:path";
|
|
31846
32101
|
import { homedir as homedir3 } from "node:os";
|
|
31847
|
-
import { randomBytes as randomBytes4, createHash as
|
|
32102
|
+
import { randomBytes as randomBytes4, createHash as createHash37, X509Certificate } from "node:crypto";
|
|
31848
32103
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
31849
32104
|
import { createServer } from "node:net";
|
|
31850
32105
|
|
|
@@ -34163,7 +34418,7 @@ var RuntimeRecoveryArchive = class _RuntimeRecoveryArchive {
|
|
|
34163
34418
|
}
|
|
34164
34419
|
};
|
|
34165
34420
|
async function verifyContent(objects, content) {
|
|
34166
|
-
const { createHash:
|
|
34421
|
+
const { createHash: createHash57 } = await import("node:crypto"), hash12 = createHash57("sha256");
|
|
34167
34422
|
for (const ref of content.chunks) hash12.update(await objects.read(ref));
|
|
34168
34423
|
if (hash12.digest("hex") !== content.sha256) throw new Error("RECOVERY_CONTENT_CORRUPT");
|
|
34169
34424
|
}
|
|
@@ -34875,7 +35130,7 @@ function resolveRequiredTools(features, licensedFeatures) {
|
|
|
34875
35130
|
}
|
|
34876
35131
|
|
|
34877
35132
|
// src/continuity/pairing-setup.ts
|
|
34878
|
-
var sha6 = (value2) =>
|
|
35133
|
+
var sha6 = (value2) => createHash37("sha256").update(value2).digest("hex");
|
|
34879
35134
|
var write = (file2, value2) => writeFileSync23(file2, JSON.stringify(value2), { mode: 384, flush: true });
|
|
34880
35135
|
var free = () => new Promise((done, reject) => {
|
|
34881
35136
|
const server = createServer();
|
|
@@ -35165,7 +35420,7 @@ import { readFileSync as readFileSync32, lstatSync as lstatSync29, realpathSync
|
|
|
35165
35420
|
import { DatabaseSync as DatabaseSync37 } from "node:sqlite";
|
|
35166
35421
|
import { isAbsolute as isAbsolute13, resolve as resolve41 } from "node:path";
|
|
35167
35422
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
35168
|
-
import { randomUUID as randomUUID24, createHash as
|
|
35423
|
+
import { randomUUID as randomUUID24, createHash as createHash51 } from "node:crypto";
|
|
35169
35424
|
|
|
35170
35425
|
// src/continuity/node-agent.ts
|
|
35171
35426
|
import { DatabaseSync as DatabaseSync36 } from "node:sqlite";
|
|
@@ -35198,7 +35453,7 @@ function runtimeEngineConfig(original, stateDir, workspace) {
|
|
|
35198
35453
|
// src/continuity/node-agent.ts
|
|
35199
35454
|
import { existsSync as existsSync38, lstatSync as lstatSync28, mkdirSync as mkdirSync31, readFileSync as readFileSync31, realpathSync as realpathSync27, writeFileSync as writeFileSync40 } from "node:fs";
|
|
35200
35455
|
import { isAbsolute as isAbsolute12, join as join70, resolve as resolve40 } from "node:path";
|
|
35201
|
-
import { createHash as
|
|
35456
|
+
import { createHash as createHash49, randomUUID as randomUUID23 } from "node:crypto";
|
|
35202
35457
|
import { isIP as isIP2 } from "node:net";
|
|
35203
35458
|
|
|
35204
35459
|
// src/continuity/activation.ts
|
|
@@ -35312,7 +35567,7 @@ init_schema_migrations();
|
|
|
35312
35567
|
init_key_service_store();
|
|
35313
35568
|
|
|
35314
35569
|
// src/continuity/generation-integrity.ts
|
|
35315
|
-
import { createHash as
|
|
35570
|
+
import { createHash as createHash38 } from "node:crypto";
|
|
35316
35571
|
import { constants as constants11, closeSync as closeSync17, fstatSync as fstatSync7, lstatSync as lstatSync19, openSync as openSync18, readSync as readSync6, readdirSync as readdirSync12, realpathSync as realpathSync15 } from "node:fs";
|
|
35317
35572
|
import { join as join50, resolve as resolve28 } from "node:path";
|
|
35318
35573
|
import { open as open5 } from "node:fs/promises";
|
|
@@ -35346,7 +35601,7 @@ function runtimeGenerationIntegrity(directory2) {
|
|
|
35346
35601
|
const files = generationFiles(root);
|
|
35347
35602
|
for (const { path: path37, stat: before } of files) {
|
|
35348
35603
|
const file2 = join50(root, path37);
|
|
35349
|
-
const fd = openSync18(file2, constants11.O_RDONLY | (constants11.O_NOFOLLOW ?? 0)), hash12 =
|
|
35604
|
+
const fd = openSync18(file2, constants11.O_RDONLY | (constants11.O_NOFOLLOW ?? 0)), hash12 = createHash38("sha256");
|
|
35350
35605
|
let bytes = 0;
|
|
35351
35606
|
try {
|
|
35352
35607
|
while (true) {
|
|
@@ -35369,7 +35624,7 @@ async function runtimeGenerationIntegrityAsync(directory2) {
|
|
|
35369
35624
|
const root = resolve28(directory2), result = [], buffer = Buffer.allocUnsafe(1024 * 1024);
|
|
35370
35625
|
const files = generationFiles(root);
|
|
35371
35626
|
for (const { path: path37, stat: before } of files) {
|
|
35372
|
-
const file2 = join50(root, path37), handle = await open5(file2, constants11.O_RDONLY | (constants11.O_NOFOLLOW ?? 0)), hash12 =
|
|
35627
|
+
const file2 = join50(root, path37), handle = await open5(file2, constants11.O_RDONLY | (constants11.O_NOFOLLOW ?? 0)), hash12 = createHash38("sha256");
|
|
35373
35628
|
let bytes = 0;
|
|
35374
35629
|
try {
|
|
35375
35630
|
while (true) {
|
|
@@ -35406,13 +35661,13 @@ async function verifyRuntimeGenerationIntegrityAsync(directory2, expected) {
|
|
|
35406
35661
|
// src/continuity/recovery-deletion-visibility.ts
|
|
35407
35662
|
init_key_service_store();
|
|
35408
35663
|
import { DatabaseSync as DatabaseSync22 } from "node:sqlite";
|
|
35409
|
-
import { createHash as
|
|
35664
|
+
import { createHash as createHash41, randomUUID as randomUUID19 } from "node:crypto";
|
|
35410
35665
|
import { existsSync as existsSync31, realpathSync as realpathSync17, renameSync as renameSync11, unlinkSync as unlinkSync11, writeFileSync as writeFileSync28 } from "node:fs";
|
|
35411
35666
|
import { join as join53, resolve as resolve30 } from "node:path";
|
|
35412
35667
|
|
|
35413
35668
|
// src/continuity/recovery-deletion-overlay.ts
|
|
35414
35669
|
import { DatabaseSync as DatabaseSync21 } from "node:sqlite";
|
|
35415
|
-
import { createHash as
|
|
35670
|
+
import { createHash as createHash40, randomUUID as randomUUID18 } from "node:crypto";
|
|
35416
35671
|
import { existsSync as existsSync30, realpathSync as realpathSync16, renameSync as renameSync10, unlinkSync as unlinkSync10, writeFileSync as writeFileSync27 } from "node:fs";
|
|
35417
35672
|
import { dirname as dirname21, join as join52, resolve as resolve29 } from "node:path";
|
|
35418
35673
|
init_key_service_store();
|
|
@@ -35432,7 +35687,7 @@ init_vector_publications();
|
|
|
35432
35687
|
init_scope();
|
|
35433
35688
|
init_schema_migrations();
|
|
35434
35689
|
import { DatabaseSync as DatabaseSync20 } from "node:sqlite";
|
|
35435
|
-
import { createHash as
|
|
35690
|
+
import { createHash as createHash39 } from "node:crypto";
|
|
35436
35691
|
import { gunzipSync as gunzipSync3 } from "node:zlib";
|
|
35437
35692
|
import { isUtf8 } from "node:buffer";
|
|
35438
35693
|
import { rmSync as rmSync4, writeFileSync as writeFileSync26, existsSync as existsSync29, unlinkSync as unlinkSync9 } from "node:fs";
|
|
@@ -35441,7 +35696,7 @@ init_sqlite_replication();
|
|
|
35441
35696
|
init_key_service_store();
|
|
35442
35697
|
init_attachments();
|
|
35443
35698
|
init_result_snapshot();
|
|
35444
|
-
var sha7 = (bytes) =>
|
|
35699
|
+
var sha7 = (bytes) => createHash39("sha256").update(bytes).digest("hex");
|
|
35445
35700
|
var object3 = (value2) => !!value2 && typeof value2 === "object" && !Array.isArray(value2);
|
|
35446
35701
|
var currentDebugCaches = /* @__PURE__ */ new Set([".context-debug.txt", ".system-prompt.txt"]);
|
|
35447
35702
|
async function cleanRecoveryDeletionRuntimeCopies(options) {
|
|
@@ -35764,7 +36019,7 @@ async function cleanRecoveryDeletionRuntimeCopies(options) {
|
|
|
35764
36019
|
|
|
35765
36020
|
// src/continuity/recovery-deletion-overlay.ts
|
|
35766
36021
|
var same4 = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
35767
|
-
var sha8 = (value2) =>
|
|
36022
|
+
var sha8 = (value2) => createHash40("sha256").update(value2).digest("hex");
|
|
35768
36023
|
var evidenceRow = (row) => Object.fromEntries(Object.entries(row).map(([key3, value2]) => [
|
|
35769
36024
|
key3,
|
|
35770
36025
|
value2 === null ? ["null"] : typeof value2 === "string" ? ["text", value2] : typeof value2 === "bigint" ? ["integer", String(value2)] : typeof value2 === "number" ? ["real", String(value2)] : ["blob", Buffer.from(value2).toString("base64")]
|
|
@@ -35997,7 +36252,7 @@ async function deletionOverlay(options, runtimeCopies) {
|
|
|
35997
36252
|
// src/continuity/recovery-deletion-visibility.ts
|
|
35998
36253
|
init_schema_migrations();
|
|
35999
36254
|
var same5 = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
36000
|
-
var sha9 = (value2) =>
|
|
36255
|
+
var sha9 = (value2) => createHash41("sha256").update(value2).digest("hex");
|
|
36001
36256
|
var format2 = "engine7-current-h-deletion-visibility-v1";
|
|
36002
36257
|
function receipt(options) {
|
|
36003
36258
|
const root = resolve30(options.snapshot);
|
|
@@ -36288,7 +36543,7 @@ import { fork } from "node:child_process";
|
|
|
36288
36543
|
import { DatabaseSync as DatabaseSync24 } from "node:sqlite";
|
|
36289
36544
|
import { closeSync as closeSync18, lstatSync as lstatSync20, openSync as openSync19, readFileSync as readFileSync29, realpathSync as realpathSync19 } from "node:fs";
|
|
36290
36545
|
import { isAbsolute as isAbsolute7, join as join55 } from "node:path";
|
|
36291
|
-
import { createHash as
|
|
36546
|
+
import { createHash as createHash42, randomUUID as randomUUID20 } from "node:crypto";
|
|
36292
36547
|
|
|
36293
36548
|
// src/continuity/engine-control.ts
|
|
36294
36549
|
init_runtime_authority();
|
|
@@ -36402,7 +36657,7 @@ var SupervisedRuntimeProcess = class {
|
|
|
36402
36657
|
if (retired && (!recovery || continuation?.state !== "SUSPENDED" || continuation.entry_hash !== this.options.entrySha256 || continuation.authority_boot_id !== permit.authorityBootId)) throw new Error("TRAVEL_PROCESS_GENERATION_RETIRED");
|
|
36403
36658
|
if (recovery && !retired) throw new Error("TRAVEL_PROCESS_GENERATION_RETIRED");
|
|
36404
36659
|
const info = lstatSync20(this.options.entry);
|
|
36405
|
-
if (!info.isFile() || info.isSymbolicLink() || info.size > 64 * 1024 * 1024 || realpathSync19(this.options.entry) !== this.options.entry ||
|
|
36660
|
+
if (!info.isFile() || info.isSymbolicLink() || info.size > 64 * 1024 * 1024 || realpathSync19(this.options.entry) !== this.options.entry || createHash42("sha256").update(readFileSync29(this.options.entry)).digest("hex") !== this.options.entrySha256) throw new Error("TRAVEL_PROCESS_BUILD");
|
|
36406
36661
|
let environment;
|
|
36407
36662
|
try {
|
|
36408
36663
|
environment = supervisedRuntimeEnvironment(JSON.parse(readPrivateFile(this.options.configFile, 1024 * 1024).toString()), process.env, this.options.environmentNames);
|
|
@@ -36743,7 +36998,7 @@ init_key_service_store();
|
|
|
36743
36998
|
init_publication_objects();
|
|
36744
36999
|
import { DatabaseSync as DatabaseSync27 } from "node:sqlite";
|
|
36745
37000
|
import { existsSync as existsSync33, lstatSync as lstatSync22, realpathSync as realpathSync21 } from "node:fs";
|
|
36746
|
-
import { createHash as
|
|
37001
|
+
import { createHash as createHash43 } from "node:crypto";
|
|
36747
37002
|
import { isAbsolute as isAbsolute8, join as join58, resolve as resolve34 } from "node:path";
|
|
36748
37003
|
init_sqlite_replication();
|
|
36749
37004
|
init_schema_migrations();
|
|
@@ -36826,7 +37081,7 @@ async function openRuntimeGenerationSource(options) {
|
|
|
36826
37081
|
}
|
|
36827
37082
|
if (sessionTrees.length !== profile.trees.filter((tree) => tree.kind === "session").length) throw new Error("TRAVEL_SOURCE_LAYOUT");
|
|
36828
37083
|
const lanceStores = profile.trees.filter((tree) => tree.kind === "vector").map((tree) => ({ treeId: tree.id, directory: join58(stateDir, layout.trees[tree.id]) }));
|
|
36829
|
-
const layoutDigest =
|
|
37084
|
+
const layoutDigest = createHash43("sha256").update(JSON.stringify([stateDir, profile, layout])).digest("hex");
|
|
36830
37085
|
trees = await RuntimeTreeSource.open({ directory: join58(dataDirectory, "runtime-trees"), profile, objects: options.objects, initialize: options.initialize });
|
|
36831
37086
|
source = await RuntimePublicationSource.open({ directory: join58(dataDirectory, "runtime-publications"), profile, objects: options.objects, trees, layoutDigest, initialize: options.initialize });
|
|
36832
37087
|
const capture2 = () => {
|
|
@@ -38669,7 +38924,7 @@ import { createServer as createServer4 } from "node:https";
|
|
|
38669
38924
|
|
|
38670
38925
|
// src/continuity/publication-transport.ts
|
|
38671
38926
|
import { createServer as createServer3, request as request4, Agent as Agent3 } from "node:https";
|
|
38672
|
-
import { createHash as
|
|
38927
|
+
import { createHash as createHash44 } from "node:crypto";
|
|
38673
38928
|
init_publication_objects();
|
|
38674
38929
|
var BODY_LIMIT = PUBLICATION_MANIFEST_BYTES + 65536;
|
|
38675
38930
|
var safeCode = (error) => error instanceof Error && /^(PUBLICATION|REPLICATION)_[A-Z_]+$/.test(error.message) ? error.message : "PUBLICATION_OPERATION_FAILED";
|
|
@@ -38779,7 +39034,7 @@ function createPublicationServer(options) {
|
|
|
38779
39034
|
case "object": {
|
|
38780
39035
|
validateObjectRef(value2.ref);
|
|
38781
39036
|
const body = decodeChunk(value2.body);
|
|
38782
|
-
if (body.length !== value2.ref.bytes ||
|
|
39037
|
+
if (body.length !== value2.ref.bytes || createHash44("sha256").update(body).digest("hex") !== value2.ref.sha256) throw new Error("PUBLICATION_OBJECT_MISMATCH");
|
|
38783
39038
|
await check();
|
|
38784
39039
|
result = await receiver.objects.put(body);
|
|
38785
39040
|
break;
|
|
@@ -38876,13 +39131,13 @@ import { isAbsolute as isAbsolute11, join as join68, resolve as resolve39 } from
|
|
|
38876
39131
|
|
|
38877
39132
|
// src/continuity/recovery-admission.ts
|
|
38878
39133
|
import { DatabaseSync as DatabaseSync34 } from "node:sqlite";
|
|
38879
|
-
import { createHash as
|
|
39134
|
+
import { createHash as createHash46 } from "node:crypto";
|
|
38880
39135
|
import { mkdtempSync as mkdtempSync3, rmSync as rmSync6, writeFileSync as writeFileSync37 } from "node:fs";
|
|
38881
39136
|
import { join as join66 } from "node:path";
|
|
38882
39137
|
|
|
38883
39138
|
// src/continuity/recovery-diff.ts
|
|
38884
39139
|
import { DatabaseSync as DatabaseSync33 } from "node:sqlite";
|
|
38885
|
-
import { createHash as
|
|
39140
|
+
import { createHash as createHash45 } from "node:crypto";
|
|
38886
39141
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync36 } from "node:fs";
|
|
38887
39142
|
import { join as join65 } from "node:path";
|
|
38888
39143
|
init_legacy_sqlite_indexes();
|
|
@@ -38958,7 +39213,7 @@ async function compareRecoveryArchives(options) {
|
|
|
38958
39213
|
counts[s]++;
|
|
38959
39214
|
scannedRecords++;
|
|
38960
39215
|
if (s !== "UNCHANGED") {
|
|
38961
|
-
const item = { ...identity3, state: s, common: c, local: l, remote: r, originalHash:
|
|
39216
|
+
const item = { ...identity3, state: s, common: c, local: l, remote: r, originalHash: createHash45("sha256").update(JSON.stringify(l)).digest("hex") };
|
|
38962
39217
|
resultBytes += Buffer.byteLength(JSON.stringify(item));
|
|
38963
39218
|
if (resultBytes > maximumResultBytes) throw new Error("RECOVERY_DIFF_LIMIT");
|
|
38964
39219
|
items.push(item);
|
|
@@ -39058,7 +39313,7 @@ async function compareRecoveryArchives(options) {
|
|
|
39058
39313
|
return map;
|
|
39059
39314
|
});
|
|
39060
39315
|
for (let i = 0; i < entries.length; i++) for (const file2 of entries[i].manifest.trees.find((t) => t.id === treeId).files) {
|
|
39061
|
-
const hash12 =
|
|
39316
|
+
const hash12 = createHash45("sha256");
|
|
39062
39317
|
for (const chunk of file2.content.chunks) {
|
|
39063
39318
|
await check();
|
|
39064
39319
|
hash12.update(await references[i].archive.objects.read(chunk));
|
|
@@ -39089,7 +39344,7 @@ async function compareRecoveryArchives(options) {
|
|
|
39089
39344
|
activationAllowed: false,
|
|
39090
39345
|
ancestryVerified: false
|
|
39091
39346
|
};
|
|
39092
|
-
return { ...body, digest:
|
|
39347
|
+
return { ...body, digest: createHash45("sha256").update(JSON.stringify(body)).digest("hex") };
|
|
39093
39348
|
} finally {
|
|
39094
39349
|
for (const dir of temporaries) rmSync5(dir, { recursive: true, force: true });
|
|
39095
39350
|
}
|
|
@@ -39101,7 +39356,7 @@ init_artifact_history();
|
|
|
39101
39356
|
init_recovery_deletion();
|
|
39102
39357
|
init_job_retention();
|
|
39103
39358
|
init_protocol();
|
|
39104
|
-
var hash8 = (value2) =>
|
|
39359
|
+
var hash8 = (value2) => createHash46("sha256").update(value2).digest("hex");
|
|
39105
39360
|
var same10 = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
39106
39361
|
var quote3 = (s) => '"' + s.replaceAll('"', '""') + '"';
|
|
39107
39362
|
function authReadinessHistory(body) {
|
|
@@ -40172,13 +40427,13 @@ async function admitRecoveryArchives(options) {
|
|
|
40172
40427
|
}
|
|
40173
40428
|
|
|
40174
40429
|
// src/continuity/recovery-artifact-projection.ts
|
|
40175
|
-
import { createHash as
|
|
40430
|
+
import { createHash as createHash47, randomUUID as randomUUID22 } from "node:crypto";
|
|
40176
40431
|
import { existsSync as existsSync37, linkSync, lstatSync as lstatSync26, mkdirSync as mkdirSync29, readFileSync as readFileSync30, realpathSync as realpathSync25, unlinkSync as unlinkSync13, writeFileSync as writeFileSync38 } from "node:fs";
|
|
40177
40432
|
import { dirname as dirname26, join as join67, resolve as resolve38 } from "node:path";
|
|
40178
40433
|
import { createRequire as createRequire9 } from "node:module";
|
|
40179
40434
|
init_runtime_authority();
|
|
40180
40435
|
init_dependencies();
|
|
40181
|
-
var sha10 = (bytes) =>
|
|
40436
|
+
var sha10 = (bytes) => createHash47("sha256").update(bytes).digest("hex");
|
|
40182
40437
|
var require5 = createRequire9(import.meta.url);
|
|
40183
40438
|
function privateParents(root, path37) {
|
|
40184
40439
|
if (realpathSync25(root) !== root) throw new Error("RECOVERY_PROJECTION_UNSAFE_PATH");
|
|
@@ -40512,10 +40767,10 @@ init_runtime_lock();
|
|
|
40512
40767
|
// src/continuity/local-exit-proof.ts
|
|
40513
40768
|
init_runtime_lock();
|
|
40514
40769
|
init_key_service_store();
|
|
40515
|
-
import { createHash as
|
|
40770
|
+
import { createHash as createHash48, verify as verify2 } from "node:crypto";
|
|
40516
40771
|
import { createReadStream, mkdirSync as mkdirSync30, readdirSync as readdirSync14, writeFileSync as writeFileSync39 } from "node:fs";
|
|
40517
40772
|
import { join as join69, relative as relative14 } from "node:path";
|
|
40518
|
-
var hash9 = (value2) =>
|
|
40773
|
+
var hash9 = (value2) => createHash48("sha256").update(value2).digest("hex");
|
|
40519
40774
|
var equal2 = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
40520
40775
|
function copyLocalExitPath(source, path37) {
|
|
40521
40776
|
const name = relative14(source, path37).replaceAll("\\", "/");
|
|
@@ -40533,7 +40788,7 @@ async function localExitFilesDigest(root, ordinary = false) {
|
|
|
40533
40788
|
continue;
|
|
40534
40789
|
}
|
|
40535
40790
|
if (!entry.isFile() || files.length >= 1e6) throw new Error("TRAVEL_EXIT_RECOVERY_REQUIRED");
|
|
40536
|
-
const digest7 =
|
|
40791
|
+
const digest7 = createHash48("sha256");
|
|
40537
40792
|
for await (const chunk of createReadStream(file2)) digest7.update(chunk);
|
|
40538
40793
|
files.push({ path: relative14(root, file2).replaceAll("\\", "/"), sha256: digest7.digest("hex") });
|
|
40539
40794
|
}
|
|
@@ -40583,7 +40838,7 @@ async function verifyStoppedLocalExitProof(options) {
|
|
|
40583
40838
|
|
|
40584
40839
|
// src/continuity/node-agent.ts
|
|
40585
40840
|
var clock = () => Number(process.hrtime.bigint() / 1000000n);
|
|
40586
|
-
var hash10 = (value2) =>
|
|
40841
|
+
var hash10 = (value2) => createHash49("sha256").update(value2).digest("hex");
|
|
40587
40842
|
var same12 = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
40588
40843
|
var TravelNodeAgent = class _TravelNodeAgent {
|
|
40589
40844
|
constructor(options) {
|
|
@@ -42259,7 +42514,7 @@ var TravelNodeAgent = class _TravelNodeAgent {
|
|
|
42259
42514
|
import { createPublicKey } from "node:crypto";
|
|
42260
42515
|
|
|
42261
42516
|
// src/continuity/node-data-authority.ts
|
|
42262
|
-
import { createHash as
|
|
42517
|
+
import { createHash as createHash50 } from "node:crypto";
|
|
42263
42518
|
var fields = ["tenantId", "companionId", "seatId", "nodeId", "role", "credentialHash"];
|
|
42264
42519
|
var equal3 = (left, right) => !!left && fields.every((field) => left[field] === right[field]);
|
|
42265
42520
|
var RemoteTravelDataAuthority = class {
|
|
@@ -42267,7 +42522,7 @@ var RemoteTravelDataAuthority = class {
|
|
|
42267
42522
|
reads = /* @__PURE__ */ new Map();
|
|
42268
42523
|
grants;
|
|
42269
42524
|
constructor(grants) {
|
|
42270
|
-
if (!grants.length || grants.length > 2 || new Set(grants.map((grant) => grant.credential)).size !== grants.length || grants.some((grant) => !/^e7t_[a-f0-9]{64}$/.test(grant.credential) ||
|
|
42525
|
+
if (!grants.length || grants.length > 2 || new Set(grants.map((grant) => grant.credential)).size !== grants.length || grants.some((grant) => !/^e7t_[a-f0-9]{64}$/.test(grant.credential) || createHash50("sha256").update(grant.credential).digest("hex") !== grant.principal.credentialHash)) throw new Error("TRAVEL_AUTH_DENIED");
|
|
42271
42526
|
this.grants = grants.map((grant) => ({ ...grant, principal: Object.freeze({ ...grant.principal }) }));
|
|
42272
42527
|
}
|
|
42273
42528
|
async authenticate(credential) {
|
|
@@ -43262,7 +43517,7 @@ async function startTravelNodeService(input) {
|
|
|
43262
43517
|
const keyService = { ...clientTls, url: config.keyService?.url, identity: config.keyService?.identity, minimumDeletionWatermark: (await authority.status(config.principal)).deletionWatermark };
|
|
43263
43518
|
const material = await fetchTravelKey(keyService);
|
|
43264
43519
|
try {
|
|
43265
|
-
if (
|
|
43520
|
+
if (createHash51("sha256").update(material.key).digest("hex") !== config.keySha256) throw new Error("TRAVEL_NODE_KEY_BARRIER");
|
|
43266
43521
|
objects = await PublicationObjects.open({ directory: path34(config.objectsDirectory), identity: { tenantId: config.principal.tenantId, companionId: config.principal.companionId, seatId: config.principal.seatId }, key: material.key });
|
|
43267
43522
|
} finally {
|
|
43268
43523
|
material.key.fill(0);
|
|
@@ -43596,11 +43851,11 @@ import { isAbsolute as isAbsolute17, resolve as resolve45 } from "node:path";
|
|
|
43596
43851
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
43597
43852
|
import { execFile as execFile6 } from "node:child_process";
|
|
43598
43853
|
import { promisify as promisify6 } from "node:util";
|
|
43599
|
-
import { createHash as
|
|
43854
|
+
import { createHash as createHash56 } from "node:crypto";
|
|
43600
43855
|
|
|
43601
43856
|
// src/continuity/user-seat-resource.ts
|
|
43602
43857
|
import { spawn as spawn7 } from "node:child_process";
|
|
43603
|
-
import { createHash as
|
|
43858
|
+
import { createHash as createHash52 } from "node:crypto";
|
|
43604
43859
|
import { isAbsolute as isAbsolute14, resolve as resolve42 } from "node:path";
|
|
43605
43860
|
var UserSeatResource = class {
|
|
43606
43861
|
constructor(config) {
|
|
@@ -43608,7 +43863,7 @@ var UserSeatResource = class {
|
|
|
43608
43863
|
if (!/^[a-z_][a-z0-9_-]{0,31}$/.test(config.runAs.user) || [config.directory, config.runAs.node, config.runAs.entry, config.runAs.configFile].some((path37) => !isAbsolute14(path37) || resolve42(path37) !== path37 || /[\r\n\0]/.test(path37))) throw new Error("TRAVEL_RETIREMENT_CONFIG");
|
|
43609
43864
|
this.identity = config.identity;
|
|
43610
43865
|
this.path = config.directory;
|
|
43611
|
-
this.id = "directory-" +
|
|
43866
|
+
this.id = "directory-" + createHash52("sha256").update(this.path).digest("hex");
|
|
43612
43867
|
}
|
|
43613
43868
|
id;
|
|
43614
43869
|
path;
|
|
@@ -43661,12 +43916,12 @@ var UserSeatResource = class {
|
|
|
43661
43916
|
init_publication_objects();
|
|
43662
43917
|
init_key_service_store();
|
|
43663
43918
|
import { DatabaseSync as DatabaseSync39 } from "node:sqlite";
|
|
43664
|
-
import { createHash as
|
|
43919
|
+
import { createHash as createHash53 } from "node:crypto";
|
|
43665
43920
|
import { existsSync as existsSync39 } from "node:fs";
|
|
43666
43921
|
import { accessSync, constants as constants14, lstatSync as lstatSync30, readdirSync as readdirSync15, readFileSync as readFileSync33, readlinkSync, realpathSync as realpathSync29, rmSync as rmSync7 } from "node:fs";
|
|
43667
43922
|
import { dirname as dirname27, isAbsolute as isAbsolute15, join as join71, resolve as resolve43, relative as relative15 } from "node:path";
|
|
43668
43923
|
var identity = (value2) => JSON.stringify([value2.tenantId, value2.companionId, value2.seatId]);
|
|
43669
|
-
var sha11 = (value2) =>
|
|
43924
|
+
var sha11 = (value2) => createHash53("sha256").update(value2).digest("hex");
|
|
43670
43925
|
var LocalSeatResource = class {
|
|
43671
43926
|
constructor(path37, identity3) {
|
|
43672
43927
|
this.path = path37;
|
|
@@ -43834,14 +44089,14 @@ init_runtime_lock();
|
|
|
43834
44089
|
import { cpSync as cpSync2, existsSync as existsSync40, mkdirSync as mkdirSync32, readFileSync as readFileSync34, readdirSync as readdirSync16, realpathSync as realpathSync30, rmSync as rmSync8, writeFileSync as writeFileSync41 } from "node:fs";
|
|
43835
44090
|
import { DatabaseSync as DatabaseSync41 } from "node:sqlite";
|
|
43836
44091
|
import { isAbsolute as isAbsolute16, join as join72, dirname as dirname29, resolve as resolve44 } from "node:path";
|
|
43837
|
-
import { createHash as
|
|
44092
|
+
import { createHash as createHash55, verify as verify3 } from "node:crypto";
|
|
43838
44093
|
|
|
43839
44094
|
// src/continuity/local-dedupe.ts
|
|
43840
44095
|
init_publication_objects();
|
|
43841
44096
|
import { DatabaseSync as DatabaseSync40 } from "node:sqlite";
|
|
43842
|
-
import { createHash as
|
|
44097
|
+
import { createHash as createHash54 } from "node:crypto";
|
|
43843
44098
|
import { dirname as dirname28 } from "node:path";
|
|
43844
|
-
var sha12 = (value2) =>
|
|
44099
|
+
var sha12 = (value2) => createHash54("sha256").update(value2).digest("hex");
|
|
43845
44100
|
var hash11 = (value2) => typeof value2 === "string" && /^[a-f0-9]{64}$/.test(value2);
|
|
43846
44101
|
var PlatformReceiptStore = class {
|
|
43847
44102
|
db;
|
|
@@ -43909,7 +44164,7 @@ var PlatformReceiptStore = class {
|
|
|
43909
44164
|
// src/continuity/local-exit.ts
|
|
43910
44165
|
init_key_service_store();
|
|
43911
44166
|
var identity2 = (value2) => JSON.stringify([value2.tenantId, value2.companionId, value2.seatId]);
|
|
43912
|
-
var sha13 = (value2) =>
|
|
44167
|
+
var sha13 = (value2) => createHash55("sha256").update(value2).digest("hex");
|
|
43913
44168
|
function detachReplication(directory2) {
|
|
43914
44169
|
for (const entry of readdirSync16(directory2, { withFileTypes: true })) {
|
|
43915
44170
|
const file2 = join72(directory2, entry.name);
|
|
@@ -43994,7 +44249,7 @@ async function createOrdinaryLocalRecovery(options) {
|
|
|
43994
44249
|
init_key_service_store();
|
|
43995
44250
|
init_key_service_store();
|
|
43996
44251
|
var command = promisify6(execFile6);
|
|
43997
|
-
var sha14 = (value2) =>
|
|
44252
|
+
var sha14 = (value2) => createHash56("sha256").update(value2).digest("hex");
|
|
43998
44253
|
var path36 = (value2) => {
|
|
43999
44254
|
if (typeof value2 !== "string" || !isAbsolute17(value2) || resolve45(value2) !== value2) throw new Error("TRAVEL_RETIREMENT_PATH");
|
|
44000
44255
|
return value2;
|