@sema-agent/cli 1.0.41 → 1.0.42
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/npm-shrinkwrap.json +14 -14
- package/package.json +5 -5
- package/sema.js +577 -575
package/sema.js
CHANGED
|
@@ -216993,7 +216993,7 @@ var require_filesystem = __commonJS({
|
|
|
216993
216993
|
var LDD_PATH = "/usr/bin/ldd";
|
|
216994
216994
|
var SELF_PATH = "/proc/self/exe";
|
|
216995
216995
|
var MAX_LENGTH = 2048;
|
|
216996
|
-
var
|
|
216996
|
+
var readFileSync55 = (path27) => {
|
|
216997
216997
|
const fd2 = fs15.openSync(path27, "r");
|
|
216998
216998
|
const buffer5 = Buffer.alloc(MAX_LENGTH);
|
|
216999
216999
|
const bytesRead = fs15.readSync(fd2, buffer5, 0, MAX_LENGTH, 0);
|
|
@@ -217018,7 +217018,7 @@ var require_filesystem = __commonJS({
|
|
|
217018
217018
|
module2.exports = {
|
|
217019
217019
|
LDD_PATH,
|
|
217020
217020
|
SELF_PATH,
|
|
217021
|
-
readFileSync:
|
|
217021
|
+
readFileSync: readFileSync55,
|
|
217022
217022
|
readFile: readFile59
|
|
217023
217023
|
};
|
|
217024
217024
|
}
|
|
@@ -217067,7 +217067,7 @@ var require_detect_libc = __commonJS({
|
|
|
217067
217067
|
"use strict";
|
|
217068
217068
|
var childProcess3 = __require("child_process");
|
|
217069
217069
|
var { isLinux: isLinux2, getReport: getReport2 } = require_process();
|
|
217070
|
-
var { LDD_PATH, SELF_PATH, readFile: readFile59, readFileSync:
|
|
217070
|
+
var { LDD_PATH, SELF_PATH, readFile: readFile59, readFileSync: readFileSync55 } = require_filesystem();
|
|
217071
217071
|
var { interpreterPath } = require_elf();
|
|
217072
217072
|
var cachedFamilyInterpreter;
|
|
217073
217073
|
var cachedFamilyFilesystem;
|
|
@@ -217159,7 +217159,7 @@ var require_detect_libc = __commonJS({
|
|
|
217159
217159
|
}
|
|
217160
217160
|
cachedFamilyFilesystem = null;
|
|
217161
217161
|
try {
|
|
217162
|
-
const lddContent =
|
|
217162
|
+
const lddContent = readFileSync55(LDD_PATH);
|
|
217163
217163
|
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
|
217164
217164
|
} catch (e) {
|
|
217165
217165
|
}
|
|
@@ -217184,7 +217184,7 @@ var require_detect_libc = __commonJS({
|
|
|
217184
217184
|
}
|
|
217185
217185
|
cachedFamilyInterpreter = null;
|
|
217186
217186
|
try {
|
|
217187
|
-
const selfContent =
|
|
217187
|
+
const selfContent = readFileSync55(SELF_PATH);
|
|
217188
217188
|
const path27 = interpreterPath(selfContent);
|
|
217189
217189
|
cachedFamilyInterpreter = familyFromInterpreterPath(path27);
|
|
217190
217190
|
} catch (e) {
|
|
@@ -217248,7 +217248,7 @@ var require_detect_libc = __commonJS({
|
|
|
217248
217248
|
}
|
|
217249
217249
|
cachedVersionFilesystem = null;
|
|
217250
217250
|
try {
|
|
217251
|
-
const lddContent =
|
|
217251
|
+
const lddContent = readFileSync55(LDD_PATH);
|
|
217252
217252
|
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
|
217253
217253
|
if (versionMatch) {
|
|
217254
217254
|
cachedVersionFilesystem = versionMatch[1];
|
|
@@ -244604,6 +244604,7 @@ var init_modelChannels = __esm({
|
|
|
244604
244604
|
var engineSideChannel_exports = {};
|
|
244605
244605
|
__export(engineSideChannel_exports, {
|
|
244606
244606
|
UTILITY_EXCLUDE_ALL_TOOLS: () => UTILITY_EXCLUDE_ALL_TOOLS,
|
|
244607
|
+
__resetSideQueryCapCacheForTest: () => __resetSideQueryCapCacheForTest,
|
|
244607
244608
|
engineSideChannelActive: () => engineSideChannelActive,
|
|
244608
244609
|
engineUtilityTask: () => engineUtilityTask,
|
|
244609
244610
|
engineUtilityText: () => engineUtilityText,
|
|
@@ -244613,6 +244614,52 @@ __export(engineSideChannel_exports, {
|
|
|
244613
244614
|
});
|
|
244614
244615
|
import { readFileSync as readFileSync23 } from "node:fs";
|
|
244615
244616
|
import { join as join73 } from "node:path";
|
|
244617
|
+
async function sideQueryCapable(client4, baseUrl, signal) {
|
|
244618
|
+
const hit = sideQueryCapByBase.get(baseUrl);
|
|
244619
|
+
if (hit !== void 0) return hit;
|
|
244620
|
+
try {
|
|
244621
|
+
const caps = await withTimeoutSignal(CAPS_PROBE_TIMEOUT_MS, signal, (s) => client4.capabilities({ signal: s }));
|
|
244622
|
+
const ok2 = caps.sideQuery === true;
|
|
244623
|
+
sideQueryCapByBase.set(baseUrl, ok2);
|
|
244624
|
+
return ok2;
|
|
244625
|
+
} catch {
|
|
244626
|
+
return false;
|
|
244627
|
+
}
|
|
244628
|
+
}
|
|
244629
|
+
function __resetSideQueryCapCacheForTest() {
|
|
244630
|
+
sideQueryCapByBase.clear();
|
|
244631
|
+
}
|
|
244632
|
+
async function withTimeoutSignal(timeoutMs, outer, fn2) {
|
|
244633
|
+
const controller = new AbortController();
|
|
244634
|
+
const timer2 = setTimeout(() => controller.abort(), timeoutMs);
|
|
244635
|
+
const onOuterAbort = () => controller.abort();
|
|
244636
|
+
if (outer?.aborted) controller.abort();
|
|
244637
|
+
else outer?.addEventListener("abort", onOuterAbort, { once: true });
|
|
244638
|
+
try {
|
|
244639
|
+
return await fn2(controller.signal);
|
|
244640
|
+
} finally {
|
|
244641
|
+
clearTimeout(timer2);
|
|
244642
|
+
outer?.removeEventListener("abort", onOuterAbort);
|
|
244643
|
+
}
|
|
244644
|
+
}
|
|
244645
|
+
function sideQueryTextOf(r) {
|
|
244646
|
+
const err8 = typeof r.errorMessage === "string" && r.errorMessage.trim() ? r.errorMessage : void 0;
|
|
244647
|
+
if (err8) throw new Error(`sema engine side-channel: ${err8}`);
|
|
244648
|
+
const text2 = typeof r.text === "string" ? r.text.trim() : "";
|
|
244649
|
+
if (!text2) throw new Error("sema engine side-channel: empty result");
|
|
244650
|
+
return text2;
|
|
244651
|
+
}
|
|
244652
|
+
function usageFromSideQuery(r) {
|
|
244653
|
+
if (r.usageMissing === true) return null;
|
|
244654
|
+
const u = r.usage;
|
|
244655
|
+
if (!u || typeof u !== "object") return null;
|
|
244656
|
+
return {
|
|
244657
|
+
input_tokens: u.input ?? 0,
|
|
244658
|
+
output_tokens: u.output ?? 0,
|
|
244659
|
+
cache_creation_input_tokens: u.cacheWrite ?? 0,
|
|
244660
|
+
cache_read_input_tokens: u.cacheRead ?? 0
|
|
244661
|
+
};
|
|
244662
|
+
}
|
|
244616
244663
|
function mintSideSessionId() {
|
|
244617
244664
|
return `side-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
244618
244665
|
}
|
|
@@ -244655,29 +244702,45 @@ async function engineUtilityText(opts) {
|
|
|
244655
244702
|
const s = e?.status;
|
|
244656
244703
|
return typeof s === "number" ? s : void 0;
|
|
244657
244704
|
};
|
|
244658
|
-
const
|
|
244659
|
-
|
|
244660
|
-
const
|
|
244661
|
-
|
|
244662
|
-
|
|
244663
|
-
|
|
244664
|
-
try {
|
|
244665
|
-
return await client4.tasks.submit(
|
|
244705
|
+
const firstModel = opts.modelRef ?? cheap;
|
|
244706
|
+
if (await sideQueryCapable(client4, baseUrl, opts.signal)) {
|
|
244707
|
+
const query2 = (model) => withTimeoutSignal(
|
|
244708
|
+
timeoutMs,
|
|
244709
|
+
opts.signal,
|
|
244710
|
+
(signal) => client4.sideQuery.query(
|
|
244666
244711
|
{
|
|
244667
|
-
|
|
244668
|
-
sessionId: mintSideSessionId(),
|
|
244669
|
-
// 独立 session:utility 提示词绝不进主会话历史
|
|
244712
|
+
messages: [{ role: "user", content: opts.objective }],
|
|
244670
244713
|
...model ? { model } : {},
|
|
244671
|
-
...opts.maxTokens ? {
|
|
244714
|
+
...opts.maxTokens ? { maxOutputTokens: opts.maxTokens } : {}
|
|
244672
244715
|
},
|
|
244673
|
-
{ signal
|
|
244674
|
-
)
|
|
244675
|
-
|
|
244676
|
-
|
|
244677
|
-
|
|
244716
|
+
{ signal }
|
|
244717
|
+
)
|
|
244718
|
+
);
|
|
244719
|
+
let r;
|
|
244720
|
+
try {
|
|
244721
|
+
r = await query2(firstModel);
|
|
244722
|
+
} catch (e) {
|
|
244723
|
+
const status3 = statusOf2(e);
|
|
244724
|
+
if (opts.noFallback || status3 === void 0 || !firstModel || !CATALOG_GATE_STATUSES.has(status3)) throw e;
|
|
244725
|
+
logForDebugging(`[side-channel] side-query ${status3} with model=${firstModel} \u2014 retrying on the default model`);
|
|
244726
|
+
r = await query2(void 0);
|
|
244678
244727
|
}
|
|
244679
|
-
|
|
244680
|
-
|
|
244728
|
+
return sideQueryTextOf(r);
|
|
244729
|
+
}
|
|
244730
|
+
const submit = (model) => withTimeoutSignal(
|
|
244731
|
+
timeoutMs,
|
|
244732
|
+
opts.signal,
|
|
244733
|
+
(signal) => client4.tasks.submit(
|
|
244734
|
+
{
|
|
244735
|
+
objective: opts.objective,
|
|
244736
|
+
sessionId: mintSideSessionId(),
|
|
244737
|
+
// 独立 session:utility 提示词绝不进主会话历史
|
|
244738
|
+
...model ? { model } : {},
|
|
244739
|
+
...opts.maxTokens ? { maxTokens: opts.maxTokens } : {}
|
|
244740
|
+
},
|
|
244741
|
+
{ signal, idempotencyKey: null }
|
|
244742
|
+
)
|
|
244743
|
+
);
|
|
244681
244744
|
let data;
|
|
244682
244745
|
try {
|
|
244683
244746
|
data = await submit(firstModel);
|
|
@@ -244702,13 +244765,26 @@ async function engineUtilityTask(opts) {
|
|
|
244702
244765
|
});
|
|
244703
244766
|
if (!client4) throw new Error("sema engine side-channel: wire client unavailable");
|
|
244704
244767
|
const timeoutMs = opts.timeoutMs ?? SIDE_CHANNEL_TIMEOUT_MS;
|
|
244705
|
-
|
|
244706
|
-
|
|
244707
|
-
|
|
244708
|
-
|
|
244709
|
-
|
|
244710
|
-
|
|
244711
|
-
|
|
244768
|
+
if (await sideQueryCapable(client4, baseUrl, opts.signal)) {
|
|
244769
|
+
const r = await withTimeoutSignal(
|
|
244770
|
+
timeoutMs,
|
|
244771
|
+
opts.signal,
|
|
244772
|
+
(signal) => client4.sideQuery.query(
|
|
244773
|
+
{
|
|
244774
|
+
messages: [{ role: "user", content: opts.objective }],
|
|
244775
|
+
...opts.modelRef ? { model: opts.modelRef } : {},
|
|
244776
|
+
...opts.maxTokens ? { maxOutputTokens: opts.maxTokens } : {},
|
|
244777
|
+
...opts.systemPrompt ? { systemPrompt: opts.systemPrompt } : {}
|
|
244778
|
+
},
|
|
244779
|
+
{ signal }
|
|
244780
|
+
)
|
|
244781
|
+
);
|
|
244782
|
+
return { text: sideQueryTextOf(r), usage: usageFromSideQuery(r) };
|
|
244783
|
+
}
|
|
244784
|
+
const data = await withTimeoutSignal(
|
|
244785
|
+
timeoutMs,
|
|
244786
|
+
opts.signal,
|
|
244787
|
+
(signal) => client4.tasks.submit(
|
|
244712
244788
|
{
|
|
244713
244789
|
objective: opts.objective,
|
|
244714
244790
|
sessionId: mintSideSessionId(),
|
|
@@ -244718,22 +244794,19 @@ async function engineUtilityTask(opts) {
|
|
|
244718
244794
|
...opts.systemPrompt ? { systemPrompt: opts.systemPrompt } : {},
|
|
244719
244795
|
...opts.excludeTools ? { excludeTools: [...opts.excludeTools] } : {}
|
|
244720
244796
|
},
|
|
244721
|
-
{ signal
|
|
244722
|
-
)
|
|
244723
|
-
|
|
244724
|
-
|
|
244725
|
-
|
|
244726
|
-
|
|
244727
|
-
|
|
244728
|
-
|
|
244729
|
-
|
|
244730
|
-
|
|
244731
|
-
|
|
244732
|
-
|
|
244733
|
-
|
|
244734
|
-
clearTimeout(timer2);
|
|
244735
|
-
opts.signal?.removeEventListener("abort", onOuterAbort);
|
|
244736
|
-
}
|
|
244797
|
+
{ signal, idempotencyKey: null }
|
|
244798
|
+
)
|
|
244799
|
+
);
|
|
244800
|
+
const text2 = typeof data.result === "string" ? data.result.trim() : "";
|
|
244801
|
+
if (!text2) throw new Error("sema engine side-channel: empty result");
|
|
244802
|
+
const st2 = data.stats;
|
|
244803
|
+
const usage = st2 ? {
|
|
244804
|
+
input_tokens: st2.promptTokens ?? st2.totalInputTokens ?? 0,
|
|
244805
|
+
output_tokens: st2.outputTokens ?? 0,
|
|
244806
|
+
cache_creation_input_tokens: st2.cacheWriteTokens ?? 0,
|
|
244807
|
+
cache_read_input_tokens: st2.cachedTokens ?? 0
|
|
244808
|
+
} : null;
|
|
244809
|
+
return { text: text2, usage };
|
|
244737
244810
|
}
|
|
244738
244811
|
function extractJsonObjectText(text2) {
|
|
244739
244812
|
const m2 = text2.match(/\{[\s\S]*\}/);
|
|
@@ -244751,13 +244824,15 @@ function jsonDisciplineSuffix(schema) {
|
|
|
244751
244824
|
Return ONLY a JSON object (no prose, no markdown code fences) that matches this JSON Schema:
|
|
244752
244825
|
${JSON.stringify(schema)}`;
|
|
244753
244826
|
}
|
|
244754
|
-
var SIDE_CHANNEL_TIMEOUT_MS, CATALOG_GATE_STATUSES, UTILITY_EXCLUDE_ALL_TOOLS;
|
|
244827
|
+
var SIDE_CHANNEL_TIMEOUT_MS, sideQueryCapByBase, CAPS_PROBE_TIMEOUT_MS, CATALOG_GATE_STATUSES, UTILITY_EXCLUDE_ALL_TOOLS;
|
|
244755
244828
|
var init_engineSideChannel = __esm({
|
|
244756
244829
|
"build-src/src/sema/engineSideChannel.ts"() {
|
|
244757
244830
|
init_debug();
|
|
244758
244831
|
init_envUtils();
|
|
244759
244832
|
init_engineWireSdk();
|
|
244760
244833
|
SIDE_CHANNEL_TIMEOUT_MS = 6e4;
|
|
244834
|
+
sideQueryCapByBase = /* @__PURE__ */ new Map();
|
|
244835
|
+
CAPS_PROBE_TIMEOUT_MS = 5e3;
|
|
244761
244836
|
CATALOG_GATE_STATUSES = /* @__PURE__ */ new Set([400, 404, 422]);
|
|
244762
244837
|
UTILITY_EXCLUDE_ALL_TOOLS = [
|
|
244763
244838
|
"Bash",
|
|
@@ -334040,9 +334115,9 @@ function streamingTailWrap(unstableSuffix) {
|
|
|
334040
334115
|
var import_compiler_runtime43, import_react43, import_jsx_runtime53, TOKEN_CACHE_MAX, tokenCache, MD_SYNTAX_RE;
|
|
334041
334116
|
var init_Markdown = __esm({
|
|
334042
334117
|
"build-src/src/components/Markdown.tsx"() {
|
|
334043
|
-
import_compiler_runtime43 = __toESM(require_compiler_runtime()
|
|
334118
|
+
import_compiler_runtime43 = __toESM(require_compiler_runtime());
|
|
334044
334119
|
init_marked_esm();
|
|
334045
|
-
import_react43 = __toESM(require_react()
|
|
334120
|
+
import_react43 = __toESM(require_react());
|
|
334046
334121
|
init_useSettings();
|
|
334047
334122
|
init_ink2();
|
|
334048
334123
|
init_cliHighlight();
|
|
@@ -334050,7 +334125,7 @@ var init_Markdown = __esm({
|
|
|
334050
334125
|
init_markdown();
|
|
334051
334126
|
init_messages4();
|
|
334052
334127
|
init_MarkdownTable();
|
|
334053
|
-
import_jsx_runtime53 = __toESM(require_jsx_runtime()
|
|
334128
|
+
import_jsx_runtime53 = __toESM(require_jsx_runtime());
|
|
334054
334129
|
TOKEN_CACHE_MAX = 500;
|
|
334055
334130
|
tokenCache = /* @__PURE__ */ new Map();
|
|
334056
334131
|
MD_SYNTAX_RE = /[#*`|[>\-_~]|\n\n|^\d+\. |\n\d+\. /;
|
|
@@ -399162,14 +399237,14 @@ var require_turndown_cjs = __commonJS({
|
|
|
399162
399237
|
} else if (node.nodeType === 1) {
|
|
399163
399238
|
replacement = replacementForNode.call(self2, node);
|
|
399164
399239
|
}
|
|
399165
|
-
return
|
|
399240
|
+
return join207(output, replacement);
|
|
399166
399241
|
}, "");
|
|
399167
399242
|
}
|
|
399168
399243
|
function postProcess(output) {
|
|
399169
399244
|
var self2 = this;
|
|
399170
399245
|
this.rules.forEach(function(rule) {
|
|
399171
399246
|
if (typeof rule.append === "function") {
|
|
399172
|
-
output =
|
|
399247
|
+
output = join207(output, rule.append(self2.options));
|
|
399173
399248
|
}
|
|
399174
399249
|
});
|
|
399175
399250
|
return output.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
|
|
@@ -399181,7 +399256,7 @@ var require_turndown_cjs = __commonJS({
|
|
|
399181
399256
|
if (whitespace.leading || whitespace.trailing) content = content.trim();
|
|
399182
399257
|
return whitespace.leading + rule.replacement(content, node, this.options) + whitespace.trailing;
|
|
399183
399258
|
}
|
|
399184
|
-
function
|
|
399259
|
+
function join207(output, replacement) {
|
|
399185
399260
|
var s1 = trimTrailingNewlines(output);
|
|
399186
399261
|
var s2 = trimLeadingNewlines(replacement);
|
|
399187
399262
|
var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
|
|
@@ -434366,8 +434441,8 @@ Fix: run \`sema doctor\` to diagnose, or restart sema to retry.`,
|
|
|
434366
434441
|
const { hasOwnModelConfig: hasOwnModelConfig2, computeCcFallbackEnv: computeCcFallbackEnv2 } = await Promise.resolve().then(() => (init_ccConfigFallback(), ccConfigFallback_exports));
|
|
434367
434442
|
const { getClaudeConfigHomeDir: getClaudeConfigHomeDir3 } = await Promise.resolve().then(() => (init_envUtils(), envUtils_exports));
|
|
434368
434443
|
const { existsSync: existsSync36 } = await import("node:fs");
|
|
434369
|
-
const { join:
|
|
434370
|
-
const hasCatalog = existsSync36(
|
|
434444
|
+
const { join: join207 } = await import("node:path");
|
|
434445
|
+
const hasCatalog = existsSync36(join207(getClaudeConfigHomeDir3(), "config.d", "models.json"));
|
|
434371
434446
|
if (!hasOwnModelConfig2(process.env) && !hasCatalog && !computeCcFallbackEnv2(process.env)) {
|
|
434372
434447
|
yield createAssistantAPIErrorMessage({
|
|
434373
434448
|
content: `Model not configured \u2014 this message was NOT sent.
|
|
@@ -451572,7 +451647,7 @@ function Settings({
|
|
|
451572
451647
|
var import_react113, import_jsx_runtime193;
|
|
451573
451648
|
var init_cmd_config = __esm({
|
|
451574
451649
|
"build-src/src/sema/overrides/cmd-config.tsx"() {
|
|
451575
|
-
import_react113 = __toESM(require_react());
|
|
451650
|
+
import_react113 = __toESM(require_react(), 1);
|
|
451576
451651
|
init_useKeybinding();
|
|
451577
451652
|
init_useExitOnCtrlCDWithKeybindings();
|
|
451578
451653
|
init_useTerminalSize();
|
|
@@ -451583,7 +451658,7 @@ var init_cmd_config = __esm({
|
|
|
451583
451658
|
init_Config();
|
|
451584
451659
|
init_settings_usage();
|
|
451585
451660
|
init_Stats();
|
|
451586
|
-
import_jsx_runtime193 = __toESM(require_jsx_runtime());
|
|
451661
|
+
import_jsx_runtime193 = __toESM(require_jsx_runtime(), 1);
|
|
451587
451662
|
}
|
|
451588
451663
|
});
|
|
451589
451664
|
|
|
@@ -476641,88 +476716,18 @@ ${args ? "Additional user input: " + args : ""}
|
|
|
476641
476716
|
});
|
|
476642
476717
|
|
|
476643
476718
|
// build-src/src/sema/recapEngine.ts
|
|
476644
|
-
import { readFileSync as readFileSync29 } from "node:fs";
|
|
476645
|
-
import { join as join145 } from "node:path";
|
|
476646
476719
|
function getLastRecapEngineFailure() {
|
|
476647
476720
|
return lastFailure;
|
|
476648
476721
|
}
|
|
476649
|
-
function resolveEngineToken2() {
|
|
476650
|
-
const envToken = process.env.SEMA_LIVE_TOKEN ?? "";
|
|
476651
|
-
if (envToken) return envToken;
|
|
476652
|
-
try {
|
|
476653
|
-
return readFileSync29(join145(getClaudeConfigHomeDir(), "engine.token"), "utf-8").trim();
|
|
476654
|
-
} catch {
|
|
476655
|
-
return "";
|
|
476656
|
-
}
|
|
476657
|
-
}
|
|
476658
476722
|
async function recapViaEngine(objective, signal) {
|
|
476659
|
-
|
|
476660
|
-
if (!baseUrl) {
|
|
476661
|
-
lastFailure = "engine not running (no live wire)";
|
|
476662
|
-
return null;
|
|
476663
|
-
}
|
|
476664
|
-
const token = resolveEngineToken2();
|
|
476665
|
-
const cheap = process.env.MODEL_CHEAP_ID?.trim() || void 0;
|
|
476666
|
-
const client4 = makeEngineWireClient({
|
|
476667
|
-
baseUrl,
|
|
476668
|
-
...token ? { token } : {},
|
|
476669
|
-
principal: process.env.SEMA_LIVE_PRINCIPAL ?? "anon:shell-live"
|
|
476670
|
-
});
|
|
476671
|
-
if (!client4) {
|
|
476723
|
+
if (!engineSideChannelActive()) {
|
|
476672
476724
|
lastFailure = "engine not running (no live wire)";
|
|
476673
476725
|
return null;
|
|
476674
476726
|
}
|
|
476675
|
-
const statusOf2 = (e) => {
|
|
476676
|
-
const s = e?.status;
|
|
476677
|
-
return typeof s === "number" ? s : void 0;
|
|
476678
|
-
};
|
|
476679
|
-
const submit = async (model) => {
|
|
476680
|
-
const controller = new AbortController();
|
|
476681
|
-
const timer2 = setTimeout(() => controller.abort(), RECAP_TIMEOUT_MS);
|
|
476682
|
-
const onOuterAbort = () => controller.abort();
|
|
476683
|
-
if (signal.aborted) controller.abort();
|
|
476684
|
-
else signal.addEventListener("abort", onOuterAbort, { once: true });
|
|
476685
|
-
try {
|
|
476686
|
-
return await client4.tasks.submit(
|
|
476687
|
-
{
|
|
476688
|
-
objective,
|
|
476689
|
-
sessionId: `side-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`,
|
|
476690
|
-
...model ? { model } : {}
|
|
476691
|
-
},
|
|
476692
|
-
{ signal: controller.signal, idempotencyKey: null }
|
|
476693
|
-
);
|
|
476694
|
-
} finally {
|
|
476695
|
-
clearTimeout(timer2);
|
|
476696
|
-
signal.removeEventListener("abort", onOuterAbort);
|
|
476697
|
-
}
|
|
476698
|
-
};
|
|
476699
476727
|
try {
|
|
476700
|
-
|
|
476701
|
-
|
|
476702
|
-
|
|
476703
|
-
} catch (e) {
|
|
476704
|
-
const status3 = statusOf2(e);
|
|
476705
|
-
if (status3 === void 0) throw e;
|
|
476706
|
-
if (!cheap) {
|
|
476707
|
-
lastFailure = `engine returned ${status3}`;
|
|
476708
|
-
logForDebugging(`[recap] ${lastFailure}`);
|
|
476709
|
-
return null;
|
|
476710
|
-
}
|
|
476711
|
-
logForDebugging(`[recap] engine ${status3} with model=${cheap} \u2014 retrying on the default model`);
|
|
476712
|
-
try {
|
|
476713
|
-
data = await submit(void 0);
|
|
476714
|
-
} catch (e2) {
|
|
476715
|
-
const s2 = statusOf2(e2);
|
|
476716
|
-
if (s2 === void 0) throw e2;
|
|
476717
|
-
lastFailure = `engine returned ${s2}`;
|
|
476718
|
-
logForDebugging(`[recap] ${lastFailure}`);
|
|
476719
|
-
return null;
|
|
476720
|
-
}
|
|
476721
|
-
}
|
|
476722
|
-
const text2 = typeof data.result === "string" ? data.result.trim() : "";
|
|
476723
|
-
if (!text2) {
|
|
476724
|
-
lastFailure = "engine returned an empty result";
|
|
476725
|
-
logForDebugging(`[recap] ${lastFailure}`);
|
|
476728
|
+
const text2 = await engineUtilityText({ objective, signal, timeoutMs: RECAP_TIMEOUT_MS });
|
|
476729
|
+
if (text2 === null) {
|
|
476730
|
+
lastFailure = "engine not running (no live wire)";
|
|
476726
476731
|
return null;
|
|
476727
476732
|
}
|
|
476728
476733
|
lastFailure = null;
|
|
@@ -476732,6 +476737,17 @@ async function recapViaEngine(objective, signal) {
|
|
|
476732
476737
|
lastFailure = null;
|
|
476733
476738
|
return null;
|
|
476734
476739
|
}
|
|
476740
|
+
const status3 = err8?.status;
|
|
476741
|
+
if (typeof status3 === "number") {
|
|
476742
|
+
lastFailure = `engine returned ${status3}`;
|
|
476743
|
+
logForDebugging(`[recap] ${lastFailure}`);
|
|
476744
|
+
return null;
|
|
476745
|
+
}
|
|
476746
|
+
if (err8 instanceof Error && err8.message.includes("empty result")) {
|
|
476747
|
+
lastFailure = "engine returned an empty result";
|
|
476748
|
+
logForDebugging(`[recap] ${lastFailure}`);
|
|
476749
|
+
return null;
|
|
476750
|
+
}
|
|
476735
476751
|
const aborted2 = err8 instanceof Error && err8.name === "AbortError";
|
|
476736
476752
|
lastFailure = aborted2 ? `engine timed out after ${RECAP_TIMEOUT_MS / 1e3}s` : `engine unreachable (${err8 instanceof Error ? err8.message : String(err8)})`;
|
|
476737
476753
|
logForDebugging(`[recap] ${lastFailure}`);
|
|
@@ -476742,8 +476758,7 @@ var RECAP_TIMEOUT_MS, lastFailure;
|
|
|
476742
476758
|
var init_recapEngine = __esm({
|
|
476743
476759
|
"build-src/src/sema/recapEngine.ts"() {
|
|
476744
476760
|
init_debug();
|
|
476745
|
-
|
|
476746
|
-
init_engineWireSdk();
|
|
476761
|
+
init_engineSideChannel();
|
|
476747
476762
|
RECAP_TIMEOUT_MS = 2e4;
|
|
476748
476763
|
lastFailure = null;
|
|
476749
476764
|
}
|
|
@@ -476907,9 +476922,9 @@ __export(releaseNotes_exports, {
|
|
|
476907
476922
|
parseChangelog: () => parseChangelog
|
|
476908
476923
|
});
|
|
476909
476924
|
import { mkdir as mkdir38, readFile as readFile43, writeFile as writeFile41 } from "fs/promises";
|
|
476910
|
-
import { dirname as dirname67, join as
|
|
476925
|
+
import { dirname as dirname67, join as join145 } from "path";
|
|
476911
476926
|
function getChangelogCachePath() {
|
|
476912
|
-
return
|
|
476927
|
+
return join145(getClaudeConfigHomeDir(), "cache", "changelog.md");
|
|
476913
476928
|
}
|
|
476914
476929
|
function _resetChangelogCacheForTesting() {
|
|
476915
476930
|
changelogMemoryCache = null;
|
|
@@ -480436,13 +480451,13 @@ var init_sema_brand = __esm({
|
|
|
480436
480451
|
_doc: "Rendered as the 'What's new' feed (createWhatsNewFeed). Top version MUST be >= current app version (2.1.187) and newer than config.lastReleaseNotesSeen so the notes display and full-logo mode triggers. Pinned == app version (2.1.187) + lastReleaseNotesSeen (loginState.ts) so getRecentReleaseNotes()===[] \u2192 condensed logo (matches refs/chrome.empty-input.json).",
|
|
480437
480452
|
version: "2.1.187",
|
|
480438
480453
|
notes: [
|
|
480439
|
-
"/btw and background utilities now
|
|
480440
|
-
"
|
|
480441
|
-
"
|
|
480454
|
+
"/btw and background utilities now use the engine's dedicated side-query channel \u2014 no session storage residue at all (previously each call left a small side-session file)",
|
|
480455
|
+
"Utility calls on the new channel have no tool surface whatsoever \u2014 isolation is structural, not instruction-based",
|
|
480456
|
+
"Older engines are detected automatically and keep the previous isolated-session behavior"
|
|
480442
480457
|
]
|
|
480443
480458
|
},
|
|
480444
|
-
productVersion: "1.0.
|
|
480445
|
-
announcement:
|
|
480459
|
+
productVersion: "1.0.42",
|
|
480460
|
+
announcement: "sema 1.0.42 \u2014 background utility calls (/btw, session titles, recaps) now run through the engine's new side-query channel: zero session files left behind, tool access structurally impossible, and accurate token accounting."
|
|
480446
480461
|
};
|
|
480447
480462
|
}
|
|
480448
480463
|
});
|
|
@@ -483371,13 +483386,13 @@ var require_sema_brand = __commonJS({
|
|
|
483371
483386
|
_doc: "Rendered as the 'What's new' feed (createWhatsNewFeed). Top version MUST be >= current app version (2.1.187) and newer than config.lastReleaseNotesSeen so the notes display and full-logo mode triggers. Pinned == app version (2.1.187) + lastReleaseNotesSeen (loginState.ts) so getRecentReleaseNotes()===[] \u2192 condensed logo (matches refs/chrome.empty-input.json).",
|
|
483372
483387
|
version: "2.1.187",
|
|
483373
483388
|
notes: [
|
|
483374
|
-
"/btw and background utilities now
|
|
483375
|
-
"
|
|
483376
|
-
"
|
|
483389
|
+
"/btw and background utilities now use the engine's dedicated side-query channel \u2014 no session storage residue at all (previously each call left a small side-session file)",
|
|
483390
|
+
"Utility calls on the new channel have no tool surface whatsoever \u2014 isolation is structural, not instruction-based",
|
|
483391
|
+
"Older engines are detected automatically and keep the previous isolated-session behavior"
|
|
483377
483392
|
]
|
|
483378
483393
|
},
|
|
483379
|
-
productVersion: "1.0.
|
|
483380
|
-
announcement:
|
|
483394
|
+
productVersion: "1.0.42",
|
|
483395
|
+
announcement: "sema 1.0.42 \u2014 background utility calls (/btw, session titles, recaps) now run through the engine's new side-query channel: zero session files left behind, tool access structurally impossible, and accurate token accounting."
|
|
483381
483396
|
};
|
|
483382
483397
|
}
|
|
483383
483398
|
});
|
|
@@ -484512,7 +484527,7 @@ import {
|
|
|
484512
484527
|
realpathSync as realpathSync7,
|
|
484513
484528
|
writeFileSync as writeFileSync15
|
|
484514
484529
|
} from "node:fs";
|
|
484515
|
-
import { join as
|
|
484530
|
+
import { join as join146 } from "node:path";
|
|
484516
484531
|
function canonicalCwd() {
|
|
484517
484532
|
try {
|
|
484518
484533
|
return realpathSync7(process.cwd()).normalize("NFC");
|
|
@@ -484609,10 +484624,10 @@ async function pickSessions(items) {
|
|
|
484609
484624
|
});
|
|
484610
484625
|
}
|
|
484611
484626
|
function importSeedMarkerPath(dir, sessionId) {
|
|
484612
|
-
return
|
|
484627
|
+
return join146(dir, `${sessionId}${IMPORT_SEED_MARKER_SUFFIX}`);
|
|
484613
484628
|
}
|
|
484614
484629
|
function copySession(item, destDir) {
|
|
484615
|
-
const destJsonl =
|
|
484630
|
+
const destJsonl = join146(destDir, `${item.sessionId}.jsonl`);
|
|
484616
484631
|
if (existsSync18(destJsonl)) return { copied: false, sidecar: false };
|
|
484617
484632
|
copyFileSync4(item.filePath, destJsonl);
|
|
484618
484633
|
try {
|
|
@@ -484627,7 +484642,7 @@ function copySession(item, destDir) {
|
|
|
484627
484642
|
if (existsSync18(srcAnchors)) {
|
|
484628
484643
|
copyFileSync4(
|
|
484629
484644
|
srcAnchors,
|
|
484630
|
-
|
|
484645
|
+
join146(destDir, `${item.sessionId}.rewind-anchors.jsonl`)
|
|
484631
484646
|
);
|
|
484632
484647
|
sidecar2 = true;
|
|
484633
484648
|
}
|
|
@@ -484636,8 +484651,8 @@ function copySession(item, destDir) {
|
|
|
484636
484651
|
async function importSessionsHandler(opts) {
|
|
484637
484652
|
const cwd5 = canonicalCwd();
|
|
484638
484653
|
const slug = sanitizePath(cwd5);
|
|
484639
|
-
const srcDir = opts.from ? opts.from :
|
|
484640
|
-
const destDir =
|
|
484654
|
+
const srcDir = opts.from ? opts.from : join146(homedir38(), LEGACY_DIR, "projects", slug);
|
|
484655
|
+
const destDir = join146(getProjectsDir(), slug);
|
|
484641
484656
|
let srcReal = srcDir;
|
|
484642
484657
|
try {
|
|
484643
484658
|
srcReal = realpathSync7(srcDir);
|
|
@@ -484759,7 +484774,7 @@ var init_importSessions = __esm({
|
|
|
484759
484774
|
// build-src/src/sema/ccImport.ts
|
|
484760
484775
|
import { existsSync as existsSync19, mkdirSync as mkdirSync16, realpathSync as realpathSync8 } from "node:fs";
|
|
484761
484776
|
import { homedir as homedir39 } from "node:os";
|
|
484762
|
-
import { join as
|
|
484777
|
+
import { join as join147 } from "node:path";
|
|
484763
484778
|
function markCcImportLog(log2) {
|
|
484764
484779
|
;
|
|
484765
484780
|
log2[CC_IMPORT_MARK] = true;
|
|
@@ -484779,9 +484794,9 @@ function canonicalize2(p) {
|
|
|
484779
484794
|
}
|
|
484780
484795
|
}
|
|
484781
484796
|
function ccProjectsDirFor(cwd5) {
|
|
484782
|
-
const base =
|
|
484797
|
+
const base = join147(homedir39(), LEGACY_DIR2, "projects");
|
|
484783
484798
|
for (const candidate of [cwd5, canonicalize2(cwd5)]) {
|
|
484784
|
-
const dir =
|
|
484799
|
+
const dir = join147(base, sanitizePath(candidate));
|
|
484785
484800
|
if (existsSync19(dir)) return dir;
|
|
484786
484801
|
}
|
|
484787
484802
|
return null;
|
|
@@ -484799,7 +484814,7 @@ async function listCcImportableSessions(cwd5) {
|
|
|
484799
484814
|
}
|
|
484800
484815
|
const items = await listImportable(srcDir);
|
|
484801
484816
|
return items.filter(
|
|
484802
|
-
(i) => !existsSync19(
|
|
484817
|
+
(i) => !existsSync19(join147(destDir, `${i.sessionId}.jsonl`))
|
|
484803
484818
|
);
|
|
484804
484819
|
} catch {
|
|
484805
484820
|
return [];
|
|
@@ -484845,7 +484860,7 @@ function importCcSessionToProject(item, cwd5) {
|
|
|
484845
484860
|
const destDir = getProjectDir3(cwd5);
|
|
484846
484861
|
mkdirSync16(destDir, { recursive: true });
|
|
484847
484862
|
copySession(item, destDir);
|
|
484848
|
-
return
|
|
484863
|
+
return join147(destDir, `${item.sessionId}.jsonl`);
|
|
484849
484864
|
}
|
|
484850
484865
|
var LEGACY_DIR2, CC_SOURCE_BRAND, CC_IMPORT_ENTRY_ID, CC_IMPORT_MARK;
|
|
484851
484866
|
var init_ccImport = __esm({
|
|
@@ -487634,7 +487649,7 @@ var init_share = __esm({
|
|
|
487634
487649
|
|
|
487635
487650
|
// build-src/src/components/skills/SkillsMenu.tsx
|
|
487636
487651
|
import { existsSync as existsSync20, mkdirSync as mkdirSync17, renameSync as renameSync8 } from "node:fs";
|
|
487637
|
-
import { basename as basename45, dirname as dirname68, join as
|
|
487652
|
+
import { basename as basename45, dirname as dirname68, join as join148 } from "node:path";
|
|
487638
487653
|
function skillSourceDisplayName(source) {
|
|
487639
487654
|
switch (source) {
|
|
487640
487655
|
case "mcp":
|
|
@@ -487796,12 +487811,12 @@ function SkillsMenu({ onExit: onExit2, commands }) {
|
|
|
487796
487811
|
if (!skill?.skillRoot) return;
|
|
487797
487812
|
try {
|
|
487798
487813
|
const skillsDir = dirname68(skill.skillRoot);
|
|
487799
|
-
const removedDir =
|
|
487814
|
+
const removedDir = join148(
|
|
487800
487815
|
dirname68(skillsDir),
|
|
487801
487816
|
`skills-removed-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}`
|
|
487802
487817
|
);
|
|
487803
487818
|
mkdirSync17(removedDir, { recursive: true });
|
|
487804
|
-
let target =
|
|
487819
|
+
let target = join148(removedDir, basename45(skill.skillRoot));
|
|
487805
487820
|
if (existsSync20(target)) target = `${target}-${Date.now()}`;
|
|
487806
487821
|
renameSync8(skill.skillRoot, target);
|
|
487807
487822
|
const nameStillPresent = skills2.some(
|
|
@@ -499771,16 +499786,16 @@ var init_dist8 = __esm({
|
|
|
499771
499786
|
});
|
|
499772
499787
|
|
|
499773
499788
|
// build-src/src/sema/collabTemplates.ts
|
|
499774
|
-
import { readFileSync as
|
|
499775
|
-
import { join as
|
|
499789
|
+
import { readFileSync as readFileSync29 } from "node:fs";
|
|
499790
|
+
import { join as join149 } from "node:path";
|
|
499776
499791
|
function collabConfigPath(configHome) {
|
|
499777
|
-
return
|
|
499792
|
+
return join149(configHome, "config.d", "collab.json");
|
|
499778
499793
|
}
|
|
499779
499794
|
function readCatalog(configHome) {
|
|
499780
|
-
const path27 =
|
|
499795
|
+
const path27 = join149(configHome, "config.d", "models.json");
|
|
499781
499796
|
let raw2;
|
|
499782
499797
|
try {
|
|
499783
|
-
raw2 =
|
|
499798
|
+
raw2 = readFileSync29(path27, "utf-8");
|
|
499784
499799
|
} catch {
|
|
499785
499800
|
return { names: /* @__PURE__ */ new Set(), ok: false, note: "\u6A21\u578B\u76EE\u5F55\u4E0D\u53EF\u7528(models.json \u7F3A\u5931)\u2014\u2014\u60AC\u7A7A\u68C0\u6D4B\u8DF3\u8FC7" };
|
|
499786
499801
|
}
|
|
@@ -499803,7 +499818,7 @@ function readCollabTemplates(configHome) {
|
|
|
499803
499818
|
const path27 = collabConfigPath(configHome);
|
|
499804
499819
|
let raw2;
|
|
499805
499820
|
try {
|
|
499806
|
-
raw2 =
|
|
499821
|
+
raw2 = readFileSync29(path27, "utf-8");
|
|
499807
499822
|
} catch {
|
|
499808
499823
|
return { templates: [], path: path27 };
|
|
499809
499824
|
}
|
|
@@ -500038,7 +500053,7 @@ __export(thinkback_exports, {
|
|
|
500038
500053
|
playAnimation: () => playAnimation
|
|
500039
500054
|
});
|
|
500040
500055
|
import { readFile as readFile44 } from "fs/promises";
|
|
500041
|
-
import { join as
|
|
500056
|
+
import { join as join150 } from "path";
|
|
500042
500057
|
function getMarketplaceName() {
|
|
500043
500058
|
return false ? INTERNAL_MARKETPLACE_NAME : OFFICIAL_MARKETPLACE_NAME;
|
|
500044
500059
|
}
|
|
@@ -500056,15 +500071,15 @@ async function getThinkbackSkillDir() {
|
|
|
500056
500071
|
if (!thinkbackPlugin) {
|
|
500057
500072
|
return null;
|
|
500058
500073
|
}
|
|
500059
|
-
const skillDir =
|
|
500074
|
+
const skillDir = join150(thinkbackPlugin.path, "skills", SKILL_NAME);
|
|
500060
500075
|
if (await pathExists(skillDir)) {
|
|
500061
500076
|
return skillDir;
|
|
500062
500077
|
}
|
|
500063
500078
|
return null;
|
|
500064
500079
|
}
|
|
500065
500080
|
async function playAnimation(skillDir) {
|
|
500066
|
-
const dataPath =
|
|
500067
|
-
const playerPath =
|
|
500081
|
+
const dataPath = join150(skillDir, "year_in_review.js");
|
|
500082
|
+
const playerPath = join150(skillDir, "player.js");
|
|
500068
500083
|
try {
|
|
500069
500084
|
await readFile44(dataPath);
|
|
500070
500085
|
} catch (e) {
|
|
@@ -500113,7 +500128,7 @@ async function playAnimation(skillDir) {
|
|
|
500113
500128
|
} finally {
|
|
500114
500129
|
inkInstance.exitAlternateScreen();
|
|
500115
500130
|
}
|
|
500116
|
-
const htmlPath =
|
|
500131
|
+
const htmlPath = join150(skillDir, "year_in_review.html");
|
|
500117
500132
|
if (await pathExists(htmlPath)) {
|
|
500118
500133
|
const platform4 = getPlatform();
|
|
500119
500134
|
const openCmd = platform4 === "macos" ? "open" : platform4 === "windows" ? "start" : "xdg-open";
|
|
@@ -500414,7 +500429,7 @@ function ThinkbackFlow(t0) {
|
|
|
500414
500429
|
if (!skillDir) {
|
|
500415
500430
|
return;
|
|
500416
500431
|
}
|
|
500417
|
-
const dataPath =
|
|
500432
|
+
const dataPath = join150(skillDir, "year_in_review.js");
|
|
500418
500433
|
pathExists(dataPath).then((exists) => {
|
|
500419
500434
|
logForDebugging(`Checking for ${dataPath}: ${exists ? "found" : "not found"}`);
|
|
500420
500435
|
setHasGenerated(exists);
|
|
@@ -500574,7 +500589,7 @@ var thinkback_play_exports = {};
|
|
|
500574
500589
|
__export(thinkback_play_exports, {
|
|
500575
500590
|
call: () => call45
|
|
500576
500591
|
});
|
|
500577
|
-
import { join as
|
|
500592
|
+
import { join as join151 } from "path";
|
|
500578
500593
|
function getPluginId2() {
|
|
500579
500594
|
const marketplaceName = process.env.USER_TYPE === "ant" ? INTERNAL_MARKETPLACE_NAME : OFFICIAL_MARKETPLACE_NAME;
|
|
500580
500595
|
return `thinkback@${marketplaceName}`;
|
|
@@ -500596,7 +500611,7 @@ async function call45() {
|
|
|
500596
500611
|
value: "Thinkback plugin installation path not found."
|
|
500597
500612
|
};
|
|
500598
500613
|
}
|
|
500599
|
-
const skillDir =
|
|
500614
|
+
const skillDir = join151(firstInstall.installPath, "skills", SKILL_NAME2);
|
|
500600
500615
|
const result = await playAnimation(skillDir);
|
|
500601
500616
|
return { type: "text", value: result.message };
|
|
500602
500617
|
}
|
|
@@ -506536,7 +506551,7 @@ var init_types20 = __esm({
|
|
|
506536
506551
|
|
|
506537
506552
|
// build-src/src/components/agents/agentFileUtils.ts
|
|
506538
506553
|
import { mkdir as mkdir40, open as open16, unlink as unlink22 } from "fs/promises";
|
|
506539
|
-
import { join as
|
|
506554
|
+
import { join as join152 } from "path";
|
|
506540
506555
|
function formatAgentAsMarkdown(agentType, whenToUse, tools, systemPrompt, color4, model, memory2, effort) {
|
|
506541
506556
|
const escapedWhenToUse = whenToUse.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\\\n");
|
|
506542
506557
|
const isAllTools = tools === void 0 || tools.length === 1 && tools[0] === "*";
|
|
@@ -506563,23 +506578,23 @@ function getAgentDirectoryPath(location) {
|
|
|
506563
506578
|
case "flagSettings":
|
|
506564
506579
|
throw new Error(`Cannot get directory path for ${location} agents`);
|
|
506565
506580
|
case "userSettings":
|
|
506566
|
-
return
|
|
506581
|
+
return join152(getClaudeConfigHomeDir(), AGENT_PATHS.AGENTS_DIR);
|
|
506567
506582
|
case "projectSettings":
|
|
506568
|
-
return
|
|
506583
|
+
return join152(getCwd(), AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
|
|
506569
506584
|
case "policySettings":
|
|
506570
|
-
return
|
|
506585
|
+
return join152(
|
|
506571
506586
|
getManagedFilePath(),
|
|
506572
506587
|
AGENT_PATHS.FOLDER_NAME,
|
|
506573
506588
|
AGENT_PATHS.AGENTS_DIR
|
|
506574
506589
|
);
|
|
506575
506590
|
case "localSettings":
|
|
506576
|
-
return
|
|
506591
|
+
return join152(getCwd(), AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
|
|
506577
506592
|
}
|
|
506578
506593
|
}
|
|
506579
506594
|
function getRelativeAgentDirectoryPath(location) {
|
|
506580
506595
|
switch (location) {
|
|
506581
506596
|
case "projectSettings":
|
|
506582
|
-
return
|
|
506597
|
+
return join152(".", AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
|
|
506583
506598
|
default:
|
|
506584
506599
|
return getAgentDirectoryPath(location);
|
|
506585
506600
|
}
|
|
@@ -506593,7 +506608,7 @@ function getActualAgentFilePath(agent) {
|
|
|
506593
506608
|
}
|
|
506594
506609
|
const dirPath = getAgentDirectoryPath(agent.source);
|
|
506595
506610
|
const filename = agent.filename || agent.agentType;
|
|
506596
|
-
return
|
|
506611
|
+
return join152(dirPath, `${filename}.md`);
|
|
506597
506612
|
}
|
|
506598
506613
|
function getActualRelativeAgentFilePath(agent) {
|
|
506599
506614
|
if (isBuiltInAgent(agent)) {
|
|
@@ -506607,7 +506622,7 @@ function getActualRelativeAgentFilePath(agent) {
|
|
|
506607
506622
|
}
|
|
506608
506623
|
const dirPath = getRelativeAgentDirectoryPath(agent.source);
|
|
506609
506624
|
const filename = agent.filename || agent.agentType;
|
|
506610
|
-
return
|
|
506625
|
+
return join152(dirPath, `${filename}.md`);
|
|
506611
506626
|
}
|
|
506612
506627
|
async function updateAgentFile(agent, newWhenToUse, newTools, newSystemPrompt, newColor, newModel, newMemory, newEffort) {
|
|
506613
506628
|
if (agent.source === "built-in") {
|
|
@@ -510027,7 +510042,7 @@ var init_rewind2 = __esm({
|
|
|
510027
510042
|
// build-src/src/utils/heapDumpService.ts
|
|
510028
510043
|
import { createWriteStream as createWriteStream4, writeFileSync as writeFileSync16 } from "fs";
|
|
510029
510044
|
import { readdir as readdir26, readFile as readFile46, writeFile as writeFile43 } from "fs/promises";
|
|
510030
|
-
import { join as
|
|
510045
|
+
import { join as join153 } from "path";
|
|
510031
510046
|
import { pipeline as pipeline2 } from "stream/promises";
|
|
510032
510047
|
import {
|
|
510033
510048
|
getHeapSnapshot,
|
|
@@ -510149,8 +510164,8 @@ async function performHeapDump(trigger = "manual", dumpNumber = 0) {
|
|
|
510149
510164
|
const suffix = dumpNumber > 0 ? `-dump${dumpNumber}` : "";
|
|
510150
510165
|
const heapFilename = `${sessionId}${suffix}.heapsnapshot`;
|
|
510151
510166
|
const diagFilename = `${sessionId}${suffix}-diagnostics.json`;
|
|
510152
|
-
const heapPath =
|
|
510153
|
-
const diagPath =
|
|
510167
|
+
const heapPath = join153(dumpDir, heapFilename);
|
|
510168
|
+
const diagPath = join153(dumpDir, diagFilename);
|
|
510154
510169
|
await writeFile43(diagPath, jsonStringify(diagnostics, null, 2), {
|
|
510155
510170
|
mode: 384
|
|
510156
510171
|
});
|
|
@@ -511823,7 +511838,7 @@ var init_sandbox_toggle2 = __esm({
|
|
|
511823
511838
|
|
|
511824
511839
|
// build-src/src/utils/claudeInChrome/setupPortable.ts
|
|
511825
511840
|
import { readdir as readdir27 } from "fs/promises";
|
|
511826
|
-
import { join as
|
|
511841
|
+
import { join as join154 } from "path";
|
|
511827
511842
|
function getExtensionIds() {
|
|
511828
511843
|
return process.env.USER_TYPE === "ant" ? [PROD_EXTENSION_ID, DEV_EXTENSION_ID, ANT_EXTENSION_ID] : [PROD_EXTENSION_ID];
|
|
511829
511844
|
}
|
|
@@ -511853,7 +511868,7 @@ async function detectExtensionInstallationPortable(browserPaths, log2) {
|
|
|
511853
511868
|
}
|
|
511854
511869
|
for (const profile of profileDirs) {
|
|
511855
511870
|
for (const extensionId of extensionIds) {
|
|
511856
|
-
const extensionPath =
|
|
511871
|
+
const extensionPath = join154(
|
|
511857
511872
|
browserBasePath,
|
|
511858
511873
|
profile,
|
|
511859
511874
|
"Extensions",
|
|
@@ -511890,7 +511905,7 @@ var init_setupPortable = __esm({
|
|
|
511890
511905
|
// build-src/src/utils/claudeInChrome/setup.ts
|
|
511891
511906
|
import { chmod as chmod12, mkdir as mkdir41, readFile as readFile47, writeFile as writeFile44 } from "fs/promises";
|
|
511892
511907
|
import { homedir as homedir40 } from "os";
|
|
511893
|
-
import { join as
|
|
511908
|
+
import { join as join155 } from "path";
|
|
511894
511909
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
511895
511910
|
function shouldEnableClaudeInChrome(chromeFlag) {
|
|
511896
511911
|
if (getIsNonInteractiveSession() && chromeFlag !== true) {
|
|
@@ -511956,8 +511971,8 @@ function setupClaudeInChrome() {
|
|
|
511956
511971
|
};
|
|
511957
511972
|
} else {
|
|
511958
511973
|
const __filename3 = fileURLToPath8(import.meta.url);
|
|
511959
|
-
const __dirname2 =
|
|
511960
|
-
const cliPath =
|
|
511974
|
+
const __dirname2 = join155(__filename3, "..");
|
|
511975
|
+
const cliPath = join155(__dirname2, "cli.js");
|
|
511961
511976
|
void createWrapperScript(
|
|
511962
511977
|
`"${process.execPath}" "${cliPath}" --chrome-native-host`
|
|
511963
511978
|
).then(
|
|
@@ -511988,8 +512003,8 @@ function getNativeMessagingHostsDirs() {
|
|
|
511988
512003
|
const platform4 = getPlatform();
|
|
511989
512004
|
if (platform4 === "windows") {
|
|
511990
512005
|
const home = homedir40();
|
|
511991
|
-
const appData = process.env.APPDATA ||
|
|
511992
|
-
return [
|
|
512006
|
+
const appData = process.env.APPDATA || join155(home, "AppData", "Local");
|
|
512007
|
+
return [join155(appData, "Sema", "ChromeNativeHost")];
|
|
511993
512008
|
}
|
|
511994
512009
|
return getAllNativeMessagingHostsDirs().map(({ path: path27 }) => path27);
|
|
511995
512010
|
}
|
|
@@ -512017,7 +512032,7 @@ async function installChromeNativeHostManifest(manifestBinaryPath) {
|
|
|
512017
512032
|
const manifestContent = jsonStringify(manifest, null, 2);
|
|
512018
512033
|
let anyManifestUpdated = false;
|
|
512019
512034
|
for (const manifestDir of manifestDirs) {
|
|
512020
|
-
const manifestPath =
|
|
512035
|
+
const manifestPath = join155(manifestDir, NATIVE_HOST_MANIFEST_NAME);
|
|
512021
512036
|
const existingContent = await readFile47(manifestPath, "utf-8").catch(
|
|
512022
512037
|
() => null
|
|
512023
512038
|
);
|
|
@@ -512038,7 +512053,7 @@ async function installChromeNativeHostManifest(manifestBinaryPath) {
|
|
|
512038
512053
|
}
|
|
512039
512054
|
}
|
|
512040
512055
|
if (getPlatform() === "windows") {
|
|
512041
|
-
const manifestPath =
|
|
512056
|
+
const manifestPath = join155(manifestDirs[0], NATIVE_HOST_MANIFEST_NAME);
|
|
512042
512057
|
registerWindowsNativeHosts(manifestPath);
|
|
512043
512058
|
}
|
|
512044
512059
|
if (anyManifestUpdated) {
|
|
@@ -512086,8 +512101,8 @@ function registerWindowsNativeHosts(manifestPath) {
|
|
|
512086
512101
|
}
|
|
512087
512102
|
async function createWrapperScript(command8) {
|
|
512088
512103
|
const platform4 = getPlatform();
|
|
512089
|
-
const chromeDir =
|
|
512090
|
-
const wrapperPath = platform4 === "windows" ?
|
|
512104
|
+
const chromeDir = join155(getClaudeConfigHomeDir(), "chrome");
|
|
512105
|
+
const wrapperPath = platform4 === "windows" ? join155(chromeDir, "chrome-native-host.bat") : join155(chromeDir, "chrome-native-host");
|
|
512091
512106
|
const scriptContent = platform4 === "windows" ? `@echo off
|
|
512092
512107
|
REM Chrome native host wrapper script
|
|
512093
512108
|
REM Generated by Sema - do not edit manually
|
|
@@ -512751,7 +512766,7 @@ var init_cmd_advisor = __esm({
|
|
|
512751
512766
|
// build-src/src/skills/bundledSkills.ts
|
|
512752
512767
|
import { constants as fsConstants5 } from "fs";
|
|
512753
512768
|
import { mkdir as mkdir42, open as open17 } from "fs/promises";
|
|
512754
|
-
import { dirname as dirname69, isAbsolute as isAbsolute30, join as
|
|
512769
|
+
import { dirname as dirname69, isAbsolute as isAbsolute30, join as join156, normalize as normalize15, sep as pathSep2 } from "path";
|
|
512755
512770
|
function registerBundledSkill(definition) {
|
|
512756
512771
|
const { files: files2 } = definition;
|
|
512757
512772
|
let skillRoot;
|
|
@@ -512806,7 +512821,7 @@ function getBundledSkills() {
|
|
|
512806
512821
|
return [...bundledSkills];
|
|
512807
512822
|
}
|
|
512808
512823
|
function getBundledSkillExtractDir(skillName) {
|
|
512809
|
-
return
|
|
512824
|
+
return join156(getBundledSkillsRoot(), skillName);
|
|
512810
512825
|
}
|
|
512811
512826
|
async function extractBundledSkillFiles(skillName, files2) {
|
|
512812
512827
|
const dir = getBundledSkillExtractDir(skillName);
|
|
@@ -512850,7 +512865,7 @@ function resolveSkillFilePath(baseDir, relPath) {
|
|
|
512850
512865
|
if (isAbsolute30(normalized) || normalized.split(pathSep2).includes("..") || normalized.split("/").includes("..")) {
|
|
512851
512866
|
throw new Error(`bundled skill file path escapes skill dir: ${relPath}`);
|
|
512852
512867
|
}
|
|
512853
|
-
return
|
|
512868
|
+
return join156(baseDir, normalized);
|
|
512854
512869
|
}
|
|
512855
512870
|
function prependBaseDir(blocks, baseDir) {
|
|
512856
512871
|
const prefix = `Base directory for this skill: ${baseDir}
|
|
@@ -513203,7 +513218,7 @@ var init_exit2 = __esm({
|
|
|
513203
513218
|
});
|
|
513204
513219
|
|
|
513205
513220
|
// build-src/src/components/ExportDialog.tsx
|
|
513206
|
-
import { join as
|
|
513221
|
+
import { join as join157 } from "path";
|
|
513207
513222
|
function ExportDialog({
|
|
513208
513223
|
content,
|
|
513209
513224
|
defaultFilename,
|
|
@@ -513235,7 +513250,7 @@ function ExportDialog({
|
|
|
513235
513250
|
};
|
|
513236
513251
|
const handleFilenameSubmit = () => {
|
|
513237
513252
|
const finalFilename = filename.endsWith(".txt") ? filename : filename.replace(/\.[^.]+$/, "") + ".txt";
|
|
513238
|
-
const filepath =
|
|
513253
|
+
const filepath = join157(getCwd(), finalFilename);
|
|
513239
513254
|
try {
|
|
513240
513255
|
writeFileSync_DEPRECATED(filepath, content, {
|
|
513241
513256
|
encoding: "utf-8",
|
|
@@ -513383,7 +513398,7 @@ __export(export_exports, {
|
|
|
513383
513398
|
extractFirstPrompt: () => extractFirstPrompt,
|
|
513384
513399
|
sanitizeFilename: () => sanitizeFilename
|
|
513385
513400
|
});
|
|
513386
|
-
import { join as
|
|
513401
|
+
import { join as join158 } from "path";
|
|
513387
513402
|
function formatTimestamp(date5) {
|
|
513388
513403
|
const year = date5.getFullYear();
|
|
513389
513404
|
const month = String(date5.getMonth() + 1).padStart(2, "0");
|
|
@@ -513426,7 +513441,7 @@ async function call66(onDone, context3, args) {
|
|
|
513426
513441
|
const filename = args.trim();
|
|
513427
513442
|
if (filename) {
|
|
513428
513443
|
const finalFilename = filename.endsWith(".txt") ? filename : filename.replace(/\.[^.]+$/, "") + ".txt";
|
|
513429
|
-
const filepath =
|
|
513444
|
+
const filepath = join158(getCwd(), finalFilename);
|
|
513430
513445
|
try {
|
|
513431
513446
|
writeFileSync_DEPRECATED(filepath, content, {
|
|
513432
513447
|
encoding: "utf-8",
|
|
@@ -513479,8 +513494,8 @@ var init_export2 = __esm({
|
|
|
513479
513494
|
});
|
|
513480
513495
|
|
|
513481
513496
|
// build-src/src/sema/modelCtxOverride.ts
|
|
513482
|
-
import { existsSync as existsSync22, readFileSync as
|
|
513483
|
-
import { join as
|
|
513497
|
+
import { existsSync as existsSync22, readFileSync as readFileSync30, writeFileSync as writeFileSync17 } from "node:fs";
|
|
513498
|
+
import { join as join159 } from "node:path";
|
|
513484
513499
|
function nextStep(current3, steps) {
|
|
513485
513500
|
if (typeof current3 === "number") {
|
|
513486
513501
|
const i = steps.findIndex((v2) => v2 === current3);
|
|
@@ -513497,7 +513512,7 @@ function fmtCtxShort(n2) {
|
|
|
513497
513512
|
return `${n2 % 1e3 === 0 ? n2 / 1e3 : Math.round(n2 / 1024)}K`;
|
|
513498
513513
|
}
|
|
513499
513514
|
function configDModelsPath() {
|
|
513500
|
-
return
|
|
513515
|
+
return join159(getClaudeConfigHomeDir(), "config.d", "models.json");
|
|
513501
513516
|
}
|
|
513502
513517
|
function envKeyFor(name, field) {
|
|
513503
513518
|
if (process.env.MODEL_ID && process.env.MODEL_ID === name) return ENV_KEYS[field].main;
|
|
@@ -513517,7 +513532,7 @@ function applyModelOverride(modelName, field, value) {
|
|
|
513517
513532
|
try {
|
|
513518
513533
|
const path27 = configDModelsPath();
|
|
513519
513534
|
if (existsSync22(path27)) {
|
|
513520
|
-
const n2 = normalizeModelsDocShape(JSON.parse(
|
|
513535
|
+
const n2 = normalizeModelsDocShape(JSON.parse(readFileSync30(path27, "utf-8")));
|
|
513521
513536
|
const doc = n2?.doc ?? {};
|
|
513522
513537
|
const row2 = (doc.models ?? []).find((m2) => m2.id === name || m2.name === name);
|
|
513523
513538
|
if (row2) {
|
|
@@ -513555,7 +513570,7 @@ function readModelConfigOverride(modelName, field) {
|
|
|
513555
513570
|
try {
|
|
513556
513571
|
const path27 = configDModelsPath();
|
|
513557
513572
|
if (!existsSync22(path27)) return null;
|
|
513558
|
-
const n2 = normalizeModelsDocShape(JSON.parse(
|
|
513573
|
+
const n2 = normalizeModelsDocShape(JSON.parse(readFileSync30(path27, "utf-8")));
|
|
513559
513574
|
const doc = n2?.doc ?? {};
|
|
513560
513575
|
const row2 = (doc.models ?? []).find((m2) => m2.id === name || m2.name === name);
|
|
513561
513576
|
const v2 = row2?.[field];
|
|
@@ -515914,7 +515929,7 @@ import {
|
|
|
515914
515929
|
writeFile as writeFile45
|
|
515915
515930
|
} from "fs/promises";
|
|
515916
515931
|
import { tmpdir as tmpdir13 } from "os";
|
|
515917
|
-
import { extname as extname14, join as
|
|
515932
|
+
import { extname as extname14, join as join160 } from "path";
|
|
515918
515933
|
function getAnalysisModel() {
|
|
515919
515934
|
return getDefaultOpusModel();
|
|
515920
515935
|
}
|
|
@@ -515922,13 +515937,13 @@ function getInsightsModel() {
|
|
|
515922
515937
|
return getDefaultOpusModel();
|
|
515923
515938
|
}
|
|
515924
515939
|
function getDataDir() {
|
|
515925
|
-
return
|
|
515940
|
+
return join160(getClaudeConfigHomeDir(), "usage-data");
|
|
515926
515941
|
}
|
|
515927
515942
|
function getFacetsDir() {
|
|
515928
|
-
return
|
|
515943
|
+
return join160(getDataDir(), "facets");
|
|
515929
515944
|
}
|
|
515930
515945
|
function getSessionMetaDir() {
|
|
515931
|
-
return
|
|
515946
|
+
return join160(getDataDir(), "session-meta");
|
|
515932
515947
|
}
|
|
515933
515948
|
function getLanguageFromPath(filePath) {
|
|
515934
515949
|
const ext = extname14(filePath).toLowerCase();
|
|
@@ -516265,7 +516280,7 @@ async function formatTranscriptWithSummarization(log2) {
|
|
|
516265
516280
|
return header + summaries.join("\n\n---\n\n");
|
|
516266
516281
|
}
|
|
516267
516282
|
async function loadCachedFacets(sessionId) {
|
|
516268
|
-
const facetPath =
|
|
516283
|
+
const facetPath = join160(getFacetsDir(), `${sessionId}.json`);
|
|
516269
516284
|
try {
|
|
516270
516285
|
const content = await readFile48(facetPath, { encoding: "utf-8" });
|
|
516271
516286
|
const parsed = jsonParse(content);
|
|
@@ -516286,14 +516301,14 @@ async function saveFacets(facets) {
|
|
|
516286
516301
|
await mkdir43(getFacetsDir(), { recursive: true });
|
|
516287
516302
|
} catch {
|
|
516288
516303
|
}
|
|
516289
|
-
const facetPath =
|
|
516304
|
+
const facetPath = join160(getFacetsDir(), `${facets.session_id}.json`);
|
|
516290
516305
|
await writeFile45(facetPath, jsonStringify(facets, null, 2), {
|
|
516291
516306
|
encoding: "utf-8",
|
|
516292
516307
|
mode: 384
|
|
516293
516308
|
});
|
|
516294
516309
|
}
|
|
516295
516310
|
async function loadCachedSessionMeta(sessionId) {
|
|
516296
|
-
const metaPath =
|
|
516311
|
+
const metaPath = join160(getSessionMetaDir(), `${sessionId}.json`);
|
|
516297
516312
|
try {
|
|
516298
516313
|
const content = await readFile48(metaPath, { encoding: "utf-8" });
|
|
516299
516314
|
return jsonParse(content);
|
|
@@ -516306,7 +516321,7 @@ async function saveSessionMeta(meta3) {
|
|
|
516306
516321
|
await mkdir43(getSessionMetaDir(), { recursive: true });
|
|
516307
516322
|
} catch {
|
|
516308
516323
|
}
|
|
516309
|
-
const metaPath =
|
|
516324
|
+
const metaPath = join160(getSessionMetaDir(), `${meta3.session_id}.json`);
|
|
516310
516325
|
await writeFile45(metaPath, jsonStringify(meta3, null, 2), {
|
|
516311
516326
|
encoding: "utf-8",
|
|
516312
516327
|
mode: 384
|
|
@@ -517404,7 +517419,7 @@ async function scanAllSessions() {
|
|
|
517404
517419
|
} catch {
|
|
517405
517420
|
return [];
|
|
517406
517421
|
}
|
|
517407
|
-
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
517422
|
+
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join160(projectsDir, dirent.name));
|
|
517408
517423
|
const allSessions = [];
|
|
517409
517424
|
for (let i = 0; i < projectDirs.length; i++) {
|
|
517410
517425
|
const sessionFiles = await getSessionFilesWithMtime(projectDirs[i]);
|
|
@@ -517426,7 +517441,7 @@ async function scanAllSessions() {
|
|
|
517426
517441
|
async function generateUsageReport(options) {
|
|
517427
517442
|
let remoteStats;
|
|
517428
517443
|
if (process.env.USER_TYPE === "ant" && options?.collectRemote) {
|
|
517429
|
-
const destDir =
|
|
517444
|
+
const destDir = join160(getClaudeConfigHomeDir(), "projects");
|
|
517430
517445
|
const { hosts, totalCopied } = await collectAllRemoteHostData(destDir);
|
|
517431
517446
|
remoteStats = { hosts, totalCopied };
|
|
517432
517447
|
}
|
|
@@ -517572,7 +517587,7 @@ async function generateUsageReport(options) {
|
|
|
517572
517587
|
await mkdir43(getDataDir(), { recursive: true });
|
|
517573
517588
|
} catch {
|
|
517574
517589
|
}
|
|
517575
|
-
const htmlPath =
|
|
517590
|
+
const htmlPath = join160(getDataDir(), "report.html");
|
|
517576
517591
|
await writeFile45(htmlPath, htmlReport, {
|
|
517577
517592
|
encoding: "utf-8",
|
|
517578
517593
|
mode: 384
|
|
@@ -517641,7 +517656,7 @@ var init_insights = __esm({
|
|
|
517641
517656
|
} : async () => 0;
|
|
517642
517657
|
collectFromRemoteHost = process.env.USER_TYPE === "ant" ? async (homespace, destDir) => {
|
|
517643
517658
|
const result = { copied: 0, skipped: 0 };
|
|
517644
|
-
const tempDir = await mkdtemp(
|
|
517659
|
+
const tempDir = await mkdtemp(join160(tmpdir13(), "claude-hs-"));
|
|
517645
517660
|
try {
|
|
517646
517661
|
const scpResult = await execFileNoThrow(
|
|
517647
517662
|
"scp",
|
|
@@ -517651,7 +517666,7 @@ var init_insights = __esm({
|
|
|
517651
517666
|
if (scpResult.code !== 0) {
|
|
517652
517667
|
return result;
|
|
517653
517668
|
}
|
|
517654
|
-
const projectsDir =
|
|
517669
|
+
const projectsDir = join160(tempDir, "projects");
|
|
517655
517670
|
let projectDirents;
|
|
517656
517671
|
try {
|
|
517657
517672
|
projectDirents = await readdir28(projectsDir, { withFileTypes: true });
|
|
@@ -517661,10 +517676,10 @@ var init_insights = __esm({
|
|
|
517661
517676
|
await Promise.all(
|
|
517662
517677
|
projectDirents.map(async (dirent) => {
|
|
517663
517678
|
const projectName = dirent.name;
|
|
517664
|
-
const projectPath =
|
|
517679
|
+
const projectPath = join160(projectsDir, projectName);
|
|
517665
517680
|
if (!dirent.isDirectory()) return;
|
|
517666
517681
|
const destProjectName = `${projectName}__${homespace}`;
|
|
517667
|
-
const destProjectPath =
|
|
517682
|
+
const destProjectPath = join160(destDir, destProjectName);
|
|
517668
517683
|
try {
|
|
517669
517684
|
await mkdir43(destProjectPath, { recursive: true });
|
|
517670
517685
|
} catch {
|
|
@@ -517679,8 +517694,8 @@ var init_insights = __esm({
|
|
|
517679
517694
|
files2.map(async (fileDirent) => {
|
|
517680
517695
|
const fileName = fileDirent.name;
|
|
517681
517696
|
if (!fileName.endsWith(".jsonl")) return;
|
|
517682
|
-
const srcFile =
|
|
517683
|
-
const destFile =
|
|
517697
|
+
const srcFile = join160(projectPath, fileName);
|
|
517698
|
+
const destFile = join160(destProjectPath, fileName);
|
|
517684
517699
|
try {
|
|
517685
517700
|
await copyFile9(srcFile, destFile, fsConstants6.COPYFILE_EXCL);
|
|
517686
517701
|
result.copied++;
|
|
@@ -518703,7 +518718,7 @@ import {
|
|
|
518703
518718
|
fsyncSync as fsyncSync6,
|
|
518704
518719
|
mkdirSync as mkdirSync18,
|
|
518705
518720
|
openSync as openSync9,
|
|
518706
|
-
readFileSync as
|
|
518721
|
+
readFileSync as readFileSync31,
|
|
518707
518722
|
writeSync as writeSync4
|
|
518708
518723
|
} from "fs";
|
|
518709
518724
|
import { dirname as dirname70 } from "path";
|
|
@@ -518766,7 +518781,7 @@ function recordTurnJournalEntry(journalPath, entry, lockTargetPath) {
|
|
|
518766
518781
|
function readTurnJournal(journalPath) {
|
|
518767
518782
|
let raw2;
|
|
518768
518783
|
try {
|
|
518769
|
-
raw2 =
|
|
518784
|
+
raw2 = readFileSync31(journalPath, "utf8");
|
|
518770
518785
|
} catch {
|
|
518771
518786
|
return [];
|
|
518772
518787
|
}
|
|
@@ -518946,7 +518961,7 @@ import {
|
|
|
518946
518961
|
unlink as unlink24,
|
|
518947
518962
|
writeFile as writeFile46
|
|
518948
518963
|
} from "fs/promises";
|
|
518949
|
-
import { basename as basename46, dirname as dirname71, isAbsolute as isAbsolute31, join as
|
|
518964
|
+
import { basename as basename46, dirname as dirname71, isAbsolute as isAbsolute31, join as join161, relative as relative27 } from "path";
|
|
518950
518965
|
function isTranscriptMessage(entry) {
|
|
518951
518966
|
return entry.type === "user" || entry.type === "assistant" || entry.type === "attachment" || entry.type === "system";
|
|
518952
518967
|
}
|
|
@@ -518960,30 +518975,30 @@ function isEphemeralToolProgress(dataType) {
|
|
|
518960
518975
|
return typeof dataType === "string" && EPHEMERAL_PROGRESS_TYPES.has(dataType);
|
|
518961
518976
|
}
|
|
518962
518977
|
function getProjectsDir2() {
|
|
518963
|
-
return
|
|
518978
|
+
return join161(getClaudeConfigHomeDir(), "projects");
|
|
518964
518979
|
}
|
|
518965
518980
|
function getTranscriptPath() {
|
|
518966
518981
|
const projectDir2 = getSessionProjectDir() ?? getProjectDir3(getOriginalCwd());
|
|
518967
|
-
return
|
|
518982
|
+
return join161(projectDir2, `${getSessionId()}.jsonl`);
|
|
518968
518983
|
}
|
|
518969
518984
|
function getTurnJournalPath() {
|
|
518970
518985
|
const projectDir2 = getSessionProjectDir() ?? getProjectDir3(getOriginalCwd());
|
|
518971
|
-
return
|
|
518986
|
+
return join161(projectDir2, `${getSessionId()}.turn-journal.jsonl`);
|
|
518972
518987
|
}
|
|
518973
518988
|
function getRewindAnchorSidecarPath() {
|
|
518974
518989
|
const projectDir2 = getSessionProjectDir() ?? getProjectDir3(getOriginalCwd());
|
|
518975
|
-
return
|
|
518990
|
+
return join161(projectDir2, `${getSessionId()}.rewind-anchors.jsonl`);
|
|
518976
518991
|
}
|
|
518977
518992
|
function getSessionMapPath() {
|
|
518978
518993
|
const projectDir2 = getSessionProjectDir() ?? getProjectDir3(getOriginalCwd());
|
|
518979
|
-
return
|
|
518994
|
+
return join161(projectDir2, `${getSessionId()}.session-map.json`);
|
|
518980
518995
|
}
|
|
518981
518996
|
function getTranscriptPathForSession(sessionId) {
|
|
518982
518997
|
if (sessionId === getSessionId()) {
|
|
518983
518998
|
return getTranscriptPath();
|
|
518984
518999
|
}
|
|
518985
519000
|
const projectDir2 = getProjectDir3(getOriginalCwd());
|
|
518986
|
-
return
|
|
519001
|
+
return join161(projectDir2, `${sessionId}.jsonl`);
|
|
518987
519002
|
}
|
|
518988
519003
|
function setAgentTranscriptSubdir(agentId, subdir) {
|
|
518989
519004
|
agentTranscriptSubdirs.set(agentId, subdir);
|
|
@@ -518995,8 +519010,8 @@ function getAgentTranscriptPath(agentId) {
|
|
|
518995
519010
|
const projectDir2 = getSessionProjectDir() ?? getProjectDir3(getOriginalCwd());
|
|
518996
519011
|
const sessionId = getSessionId();
|
|
518997
519012
|
const subdir = agentTranscriptSubdirs.get(agentId);
|
|
518998
|
-
const base = subdir ?
|
|
518999
|
-
return
|
|
519013
|
+
const base = subdir ? join161(projectDir2, sessionId, "subagents", subdir) : join161(projectDir2, sessionId, "subagents");
|
|
519014
|
+
return join161(base, `agent-${agentId}.jsonl`);
|
|
519000
519015
|
}
|
|
519001
519016
|
function getAgentMetadataPath(agentId) {
|
|
519002
519017
|
return getAgentTranscriptPath(agentId).replace(/\.jsonl$/, ".meta.json");
|
|
@@ -519018,10 +519033,10 @@ async function readAgentMetadata(agentId) {
|
|
|
519018
519033
|
}
|
|
519019
519034
|
function getRemoteAgentsDir() {
|
|
519020
519035
|
const projectDir2 = getSessionProjectDir() ?? getProjectDir3(getOriginalCwd());
|
|
519021
|
-
return
|
|
519036
|
+
return join161(projectDir2, getSessionId(), "remote-agents");
|
|
519022
519037
|
}
|
|
519023
519038
|
function getRemoteAgentMetadataPath(taskId) {
|
|
519024
|
-
return
|
|
519039
|
+
return join161(getRemoteAgentsDir(), `remote-agent-${taskId}.meta.json`);
|
|
519025
519040
|
}
|
|
519026
519041
|
async function writeRemoteAgentMetadata(taskId, metadata2) {
|
|
519027
519042
|
const path27 = getRemoteAgentMetadataPath(taskId);
|
|
@@ -519060,7 +519075,7 @@ async function listRemoteAgentMetadata() {
|
|
|
519060
519075
|
for (const entry of entries) {
|
|
519061
519076
|
if (!entry.isFile() || !entry.name.endsWith(".meta.json")) continue;
|
|
519062
519077
|
try {
|
|
519063
|
-
const raw2 = await readFile49(
|
|
519078
|
+
const raw2 = await readFile49(join161(dir, entry.name), "utf-8");
|
|
519064
519079
|
results.push(JSON.parse(raw2));
|
|
519065
519080
|
} catch (e) {
|
|
519066
519081
|
logForDebugging(
|
|
@@ -519072,7 +519087,7 @@ async function listRemoteAgentMetadata() {
|
|
|
519072
519087
|
}
|
|
519073
519088
|
function sessionIdExists(sessionId) {
|
|
519074
519089
|
const projectDir2 = getProjectDir3(getOriginalCwd());
|
|
519075
|
-
const sessionFile =
|
|
519090
|
+
const sessionFile = join161(projectDir2, `${sessionId}.jsonl`);
|
|
519076
519091
|
const fs15 = getFsImplementation();
|
|
519077
519092
|
try {
|
|
519078
519093
|
fs15.statSync(sessionFile);
|
|
@@ -520588,7 +520603,7 @@ async function loadTranscriptFile(filePath, opts) {
|
|
|
520588
520603
|
};
|
|
520589
520604
|
}
|
|
520590
520605
|
async function loadSessionFile(sessionId) {
|
|
520591
|
-
const sessionFile =
|
|
520606
|
+
const sessionFile = join161(
|
|
520592
520607
|
getSessionProjectDir() ?? getProjectDir3(getOriginalCwd()),
|
|
520593
520608
|
`${sessionId}.jsonl`
|
|
520594
520609
|
);
|
|
@@ -520680,7 +520695,7 @@ async function loadAllProjectsMessageLogsFull(limit2) {
|
|
|
520680
520695
|
} catch {
|
|
520681
520696
|
return [];
|
|
520682
520697
|
}
|
|
520683
|
-
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
520698
|
+
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join161(projectsDir, dirent.name));
|
|
520684
520699
|
const logsPerProject = await Promise.all(
|
|
520685
520700
|
projectDirs.map((projectDir2) => getLogsWithoutIndex(projectDir2, limit2))
|
|
520686
520701
|
);
|
|
@@ -520707,7 +520722,7 @@ async function loadAllProjectsMessageLogsProgressive(limit2, initialEnrichCount
|
|
|
520707
520722
|
} catch {
|
|
520708
520723
|
return { logs: [], allStatLogs: [], nextIndex: 0 };
|
|
520709
520724
|
}
|
|
520710
|
-
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
520725
|
+
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join161(projectsDir, dirent.name));
|
|
520711
520726
|
const rawLogs = [];
|
|
520712
520727
|
for (const projectDir2 of projectDirs) {
|
|
520713
520728
|
rawLogs.push(...await getSessionFilesLite(projectDir2, limit2));
|
|
@@ -520780,7 +520795,7 @@ async function getStatOnlyLogsForWorktrees(worktreePaths, limit2) {
|
|
|
520780
520795
|
seenDirs.add(dirName);
|
|
520781
520796
|
allLogs.push(
|
|
520782
520797
|
...await getSessionFilesLite(
|
|
520783
|
-
|
|
520798
|
+
join161(projectsDir, dirent.name),
|
|
520784
520799
|
void 0,
|
|
520785
520800
|
wtPath
|
|
520786
520801
|
)
|
|
@@ -520863,7 +520878,7 @@ async function loadSubagentTranscripts(agentIds) {
|
|
|
520863
520878
|
return transcripts;
|
|
520864
520879
|
}
|
|
520865
520880
|
async function loadAllSubagentTranscriptsFromDisk() {
|
|
520866
|
-
const subagentsDir =
|
|
520881
|
+
const subagentsDir = join161(
|
|
520867
520882
|
getSessionProjectDir() ?? getProjectDir3(getOriginalCwd()),
|
|
520868
520883
|
getSessionId(),
|
|
520869
520884
|
"subagents"
|
|
@@ -521003,7 +521018,7 @@ async function getSessionFilesWithMtime(projectDir2) {
|
|
|
521003
521018
|
if (!dirent.isFile() || !dirent.name.endsWith(".jsonl")) continue;
|
|
521004
521019
|
const sessionId = validateUuid(basename46(dirent.name, ".jsonl"));
|
|
521005
521020
|
if (!sessionId) continue;
|
|
521006
|
-
candidates.push({ sessionId, filePath:
|
|
521021
|
+
candidates.push({ sessionId, filePath: join161(projectDir2, dirent.name) });
|
|
521007
521022
|
}
|
|
521008
521023
|
await Promise.all(
|
|
521009
521024
|
candidates.map(async ({ sessionId, filePath }) => {
|
|
@@ -521417,7 +521432,7 @@ var init_sessionStorage = __esm({
|
|
|
521417
521432
|
MAX_TRANSCRIPT_READ_BYTES = 50 * 1024 * 1024;
|
|
521418
521433
|
agentTranscriptSubdirs = /* @__PURE__ */ new Map();
|
|
521419
521434
|
getProjectDir3 = memoize_default((projectDir2) => {
|
|
521420
|
-
return
|
|
521435
|
+
return join161(getProjectsDir2(), sanitizePath(projectDir2));
|
|
521421
521436
|
});
|
|
521422
521437
|
project = null;
|
|
521423
521438
|
cleanupRegistered5 = false;
|
|
@@ -522352,13 +522367,13 @@ var init_memdir = __esm({
|
|
|
522352
522367
|
});
|
|
522353
522368
|
|
|
522354
522369
|
// build-src/src/tools/AgentTool/agentMemory.ts
|
|
522355
|
-
import { join as
|
|
522370
|
+
import { join as join162, normalize as normalize16, sep as sep33 } from "path";
|
|
522356
522371
|
function sanitizeAgentTypeForPath(agentType) {
|
|
522357
522372
|
return agentType.replace(/:/g, "-");
|
|
522358
522373
|
}
|
|
522359
522374
|
function getLocalAgentMemoryDir(dirName) {
|
|
522360
522375
|
if (process.env.SEMA_CODE_REMOTE_MEMORY_DIR) {
|
|
522361
|
-
return
|
|
522376
|
+
return join162(
|
|
522362
522377
|
process.env.SEMA_CODE_REMOTE_MEMORY_DIR,
|
|
522363
522378
|
"projects",
|
|
522364
522379
|
sanitizePath(
|
|
@@ -522368,36 +522383,36 @@ function getLocalAgentMemoryDir(dirName) {
|
|
|
522368
522383
|
dirName
|
|
522369
522384
|
) + sep33;
|
|
522370
522385
|
}
|
|
522371
|
-
return
|
|
522386
|
+
return join162(getCwd(), ".sema", "agent-memory-local", dirName) + sep33;
|
|
522372
522387
|
}
|
|
522373
522388
|
function getAgentMemoryDir(agentType, scope) {
|
|
522374
522389
|
const dirName = sanitizeAgentTypeForPath(agentType);
|
|
522375
522390
|
switch (scope) {
|
|
522376
522391
|
case "project":
|
|
522377
|
-
return
|
|
522392
|
+
return join162(getCwd(), ".sema", "agent-memory", dirName) + sep33;
|
|
522378
522393
|
case "local":
|
|
522379
522394
|
return getLocalAgentMemoryDir(dirName);
|
|
522380
522395
|
case "user":
|
|
522381
|
-
return
|
|
522396
|
+
return join162(getMemoryBaseDir(), "agent-memory", dirName) + sep33;
|
|
522382
522397
|
}
|
|
522383
522398
|
}
|
|
522384
522399
|
function isAgentMemoryPath(absolutePath) {
|
|
522385
522400
|
const normalizedPath = normalize16(absolutePath);
|
|
522386
522401
|
const memoryBase = getMemoryBaseDir();
|
|
522387
|
-
if (normalizedPath.startsWith(
|
|
522402
|
+
if (normalizedPath.startsWith(join162(memoryBase, "agent-memory") + sep33)) {
|
|
522388
522403
|
return true;
|
|
522389
522404
|
}
|
|
522390
|
-
if (normalizedPath.startsWith(
|
|
522405
|
+
if (normalizedPath.startsWith(join162(getCwd(), ".sema", "agent-memory") + sep33)) {
|
|
522391
522406
|
return true;
|
|
522392
522407
|
}
|
|
522393
522408
|
if (process.env.SEMA_CODE_REMOTE_MEMORY_DIR) {
|
|
522394
522409
|
if (normalizedPath.includes(sep33 + "agent-memory-local" + sep33) && normalizedPath.startsWith(
|
|
522395
|
-
|
|
522410
|
+
join162(process.env.SEMA_CODE_REMOTE_MEMORY_DIR, "projects") + sep33
|
|
522396
522411
|
)) {
|
|
522397
522412
|
return true;
|
|
522398
522413
|
}
|
|
522399
522414
|
} else if (normalizedPath.startsWith(
|
|
522400
|
-
|
|
522415
|
+
join162(getCwd(), ".sema", "agent-memory-local") + sep33
|
|
522401
522416
|
)) {
|
|
522402
522417
|
return true;
|
|
522403
522418
|
}
|
|
@@ -522406,7 +522421,7 @@ function isAgentMemoryPath(absolutePath) {
|
|
|
522406
522421
|
function getMemoryScopeDisplay(memory2) {
|
|
522407
522422
|
switch (memory2) {
|
|
522408
522423
|
case "user":
|
|
522409
|
-
return `User (${
|
|
522424
|
+
return `User (${join162(getMemoryBaseDir(), "agent-memory")}/)`;
|
|
522410
522425
|
case "project":
|
|
522411
522426
|
return "Project (.sema/agent-memory/)";
|
|
522412
522427
|
case "local":
|
|
@@ -522451,7 +522466,7 @@ var init_agentMemory = __esm({
|
|
|
522451
522466
|
// build-src/src/utils/permissions/filesystem.ts
|
|
522452
522467
|
import { randomBytes as randomBytes20 } from "crypto";
|
|
522453
522468
|
import { homedir as homedir41, tmpdir as tmpdir14 } from "os";
|
|
522454
|
-
import { join as
|
|
522469
|
+
import { join as join163, normalize as normalize17, posix as posix8, sep as sep34 } from "path";
|
|
522455
522470
|
function normalizeCaseForComparison2(path27) {
|
|
522456
522471
|
return path27.toLowerCase();
|
|
522457
522472
|
}
|
|
@@ -522460,11 +522475,11 @@ function getClaudeSkillScope(filePath) {
|
|
|
522460
522475
|
const absolutePathLower = normalizeCaseForComparison2(absolutePath);
|
|
522461
522476
|
const bases = [
|
|
522462
522477
|
{
|
|
522463
|
-
dir: expandPath(
|
|
522478
|
+
dir: expandPath(join163(getOriginalCwd(), ".sema", "skills")),
|
|
522464
522479
|
prefix: "/.sema/skills/"
|
|
522465
522480
|
},
|
|
522466
522481
|
{
|
|
522467
|
-
dir: expandPath(
|
|
522482
|
+
dir: expandPath(join163(homedir41(), ".sema", "skills")),
|
|
522468
522483
|
prefix: "~/.sema/skills/"
|
|
522469
522484
|
}
|
|
522470
522485
|
];
|
|
@@ -522521,21 +522536,21 @@ function isClaudeConfigFilePath(filePath) {
|
|
|
522521
522536
|
if (isClaudeSettingsPath(filePath)) {
|
|
522522
522537
|
return true;
|
|
522523
522538
|
}
|
|
522524
|
-
const commandsDir =
|
|
522525
|
-
const agentsDir =
|
|
522526
|
-
const skillsDir =
|
|
522539
|
+
const commandsDir = join163(getOriginalCwd(), ".sema", "commands");
|
|
522540
|
+
const agentsDir = join163(getOriginalCwd(), ".sema", "agents");
|
|
522541
|
+
const skillsDir = join163(getOriginalCwd(), ".sema", "skills");
|
|
522527
522542
|
return pathInWorkingPath(filePath, commandsDir) || pathInWorkingPath(filePath, agentsDir) || pathInWorkingPath(filePath, skillsDir);
|
|
522528
522543
|
}
|
|
522529
522544
|
function isSessionPlanFile(absolutePath) {
|
|
522530
|
-
const expectedPrefix =
|
|
522545
|
+
const expectedPrefix = join163(getPlansDirectory(), getPlanSlug());
|
|
522531
522546
|
const normalizedPath = normalize17(absolutePath);
|
|
522532
522547
|
return normalizedPath.startsWith(expectedPrefix) && normalizedPath.endsWith(".md");
|
|
522533
522548
|
}
|
|
522534
522549
|
function getSessionMemoryDir() {
|
|
522535
|
-
return
|
|
522550
|
+
return join163(getProjectDir3(getCwd()), getSessionId(), "session-memory") + sep34;
|
|
522536
522551
|
}
|
|
522537
522552
|
function getSessionMemoryPath() {
|
|
522538
|
-
return
|
|
522553
|
+
return join163(getSessionMemoryDir(), "summary.md");
|
|
522539
522554
|
}
|
|
522540
522555
|
function isSessionMemoryPath(absolutePath) {
|
|
522541
522556
|
const normalizedPath = normalize17(absolutePath);
|
|
@@ -522557,10 +522572,10 @@ function getClaudeTempDirName() {
|
|
|
522557
522572
|
return `claude-${uid}`;
|
|
522558
522573
|
}
|
|
522559
522574
|
function getProjectTempDir() {
|
|
522560
|
-
return
|
|
522575
|
+
return join163(getClaudeTempDir(), sanitizePath(getOriginalCwd())) + sep34;
|
|
522561
522576
|
}
|
|
522562
522577
|
function getScratchpadDir() {
|
|
522563
|
-
return
|
|
522578
|
+
return join163(getProjectTempDir(), getSessionId(), "scratchpad");
|
|
522564
522579
|
}
|
|
522565
522580
|
async function ensureScratchpadDir() {
|
|
522566
522581
|
if (!isScratchpadEnabled()) {
|
|
@@ -523212,7 +523227,7 @@ function checkEditableInternalPath(absolutePath, input) {
|
|
|
523212
523227
|
if (false) {
|
|
523213
523228
|
const jobDir = process.env.SEMA_JOB_DIR;
|
|
523214
523229
|
if (jobDir) {
|
|
523215
|
-
const jobsRoot =
|
|
523230
|
+
const jobsRoot = join163(getClaudeConfigHomeDir(), "jobs");
|
|
523216
523231
|
const jobDirForms = getPathsForPermissionCheck(jobDir).map(normalize17);
|
|
523217
523232
|
const jobsRootForms = getPathsForPermissionCheck(jobsRoot).map(normalize17);
|
|
523218
523233
|
const isUnderJobsRoot = jobDirForms.every(
|
|
@@ -523257,7 +523272,7 @@ function checkEditableInternalPath(absolutePath, input) {
|
|
|
523257
523272
|
}
|
|
523258
523273
|
};
|
|
523259
523274
|
}
|
|
523260
|
-
if (normalizeCaseForComparison2(normalizedPath) === normalizeCaseForComparison2(
|
|
523275
|
+
if (normalizeCaseForComparison2(normalizedPath) === normalizeCaseForComparison2(join163(getOriginalCwd(), ".sema", "launch.json"))) {
|
|
523261
523276
|
return {
|
|
523262
523277
|
behavior: "allow",
|
|
523263
523278
|
updatedInput: input,
|
|
@@ -523354,7 +523369,7 @@ function checkReadableInternalPath(absolutePath, input) {
|
|
|
523354
523369
|
}
|
|
523355
523370
|
};
|
|
523356
523371
|
}
|
|
523357
|
-
const tasksDir =
|
|
523372
|
+
const tasksDir = join163(getClaudeConfigHomeDir(), "tasks") + sep34;
|
|
523358
523373
|
if (normalizedPath === tasksDir.slice(0, -1) || normalizedPath.startsWith(tasksDir)) {
|
|
523359
523374
|
return {
|
|
523360
523375
|
behavior: "allow",
|
|
@@ -523365,7 +523380,7 @@ function checkReadableInternalPath(absolutePath, input) {
|
|
|
523365
523380
|
}
|
|
523366
523381
|
};
|
|
523367
523382
|
}
|
|
523368
|
-
const teamsReadDir =
|
|
523383
|
+
const teamsReadDir = join163(getClaudeConfigHomeDir(), "teams") + sep34;
|
|
523369
523384
|
if (normalizedPath === teamsReadDir.slice(0, -1) || normalizedPath.startsWith(teamsReadDir)) {
|
|
523370
523385
|
return {
|
|
523371
523386
|
behavior: "allow",
|
|
@@ -523441,12 +523456,12 @@ var init_filesystem = __esm({
|
|
|
523441
523456
|
resolvedBaseTmpDir = fs15.realpathSync(baseTmpDir);
|
|
523442
523457
|
} catch {
|
|
523443
523458
|
}
|
|
523444
|
-
return
|
|
523459
|
+
return join163(resolvedBaseTmpDir, getClaudeTempDirName()) + sep34;
|
|
523445
523460
|
});
|
|
523446
523461
|
getBundledSkillsRoot = memoize_default(
|
|
523447
523462
|
function getBundledSkillsRoot2() {
|
|
523448
523463
|
const nonce = randomBytes20(16).toString("hex");
|
|
523449
|
-
return
|
|
523464
|
+
return join163(getClaudeTempDir(), "bundled-skills", "2.1.88", nonce);
|
|
523450
523465
|
}
|
|
523451
523466
|
);
|
|
523452
523467
|
getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
|
|
@@ -523462,10 +523477,10 @@ import {
|
|
|
523462
523477
|
symlink as symlink4,
|
|
523463
523478
|
unlink as unlink25
|
|
523464
523479
|
} from "fs/promises";
|
|
523465
|
-
import { join as
|
|
523480
|
+
import { join as join164 } from "path";
|
|
523466
523481
|
function getTaskOutputDir() {
|
|
523467
523482
|
if (_taskOutputDir === void 0) {
|
|
523468
|
-
_taskOutputDir =
|
|
523483
|
+
_taskOutputDir = join164(getProjectTempDir(), getSessionId(), "tasks");
|
|
523469
523484
|
}
|
|
523470
523485
|
return _taskOutputDir;
|
|
523471
523486
|
}
|
|
@@ -523473,7 +523488,7 @@ async function ensureOutputDir() {
|
|
|
523473
523488
|
await mkdir45(getTaskOutputDir(), { recursive: true });
|
|
523474
523489
|
}
|
|
523475
523490
|
function getTaskOutputPath(taskId) {
|
|
523476
|
-
return
|
|
523491
|
+
return join164(getTaskOutputDir(), `${taskId}.output`);
|
|
523477
523492
|
}
|
|
523478
523493
|
function track(p) {
|
|
523479
523494
|
_pendingOps.add(p);
|
|
@@ -528206,7 +528221,7 @@ import {
|
|
|
528206
528221
|
symlink as symlink5,
|
|
528207
528222
|
utimes as utimes2
|
|
528208
528223
|
} from "fs/promises";
|
|
528209
|
-
import { basename as basename48, dirname as dirname72, join as
|
|
528224
|
+
import { basename as basename48, dirname as dirname72, join as join165 } from "path";
|
|
528210
528225
|
function validateWorktreeSlug(slug) {
|
|
528211
528226
|
if (slug.length > MAX_WORKTREE_SLUG_LENGTH) {
|
|
528212
528227
|
throw new Error(
|
|
@@ -528238,8 +528253,8 @@ async function symlinkDirectories(repoRootPath, worktreePath, dirsToSymlink) {
|
|
|
528238
528253
|
);
|
|
528239
528254
|
continue;
|
|
528240
528255
|
}
|
|
528241
|
-
const sourcePath =
|
|
528242
|
-
const destPath =
|
|
528256
|
+
const sourcePath = join165(repoRootPath, dir);
|
|
528257
|
+
const destPath = join165(worktreePath, dir);
|
|
528243
528258
|
try {
|
|
528244
528259
|
await symlink5(sourcePath, destPath, "dir");
|
|
528245
528260
|
logForDebugging(
|
|
@@ -528268,7 +528283,7 @@ function generateTmuxSessionName(repoPath, branch2) {
|
|
|
528268
528283
|
return combined.replace(/[/.]/g, "_");
|
|
528269
528284
|
}
|
|
528270
528285
|
function worktreesDir(repoRoot2) {
|
|
528271
|
-
return
|
|
528286
|
+
return join165(repoRoot2, ".sema", "worktrees");
|
|
528272
528287
|
}
|
|
528273
528288
|
function flattenSlug(slug) {
|
|
528274
528289
|
return slug.replaceAll("/", "+");
|
|
@@ -528277,7 +528292,7 @@ function worktreeBranchName(slug) {
|
|
|
528277
528292
|
return `worktree-${flattenSlug(slug)}`;
|
|
528278
528293
|
}
|
|
528279
528294
|
function worktreePathFor(repoRoot2, slug) {
|
|
528280
|
-
return
|
|
528295
|
+
return join165(worktreesDir(repoRoot2), flattenSlug(slug));
|
|
528281
528296
|
}
|
|
528282
528297
|
async function getOrCreateWorktree(repoRoot2, slug, options) {
|
|
528283
528298
|
const worktreePath = worktreePathFor(repoRoot2, slug);
|
|
@@ -528386,7 +528401,7 @@ async function getOrCreateWorktree(repoRoot2, slug, options) {
|
|
|
528386
528401
|
async function copyWorktreeIncludeFiles(repoRoot2, worktreePath) {
|
|
528387
528402
|
let includeContent;
|
|
528388
528403
|
try {
|
|
528389
|
-
includeContent = await readFile50(
|
|
528404
|
+
includeContent = await readFile50(join165(repoRoot2, ".worktreeinclude"), "utf-8");
|
|
528390
528405
|
} catch {
|
|
528391
528406
|
return [];
|
|
528392
528407
|
}
|
|
@@ -528444,8 +528459,8 @@ async function copyWorktreeIncludeFiles(repoRoot2, worktreePath) {
|
|
|
528444
528459
|
}
|
|
528445
528460
|
const copied = [];
|
|
528446
528461
|
for (const relativePath2 of files2) {
|
|
528447
|
-
const srcPath =
|
|
528448
|
-
const destPath =
|
|
528462
|
+
const srcPath = join165(repoRoot2, relativePath2);
|
|
528463
|
+
const destPath = join165(worktreePath, relativePath2);
|
|
528449
528464
|
try {
|
|
528450
528465
|
await mkdir46(dirname72(destPath), { recursive: true });
|
|
528451
528466
|
await copyFile10(srcPath, destPath);
|
|
@@ -528466,9 +528481,9 @@ async function copyWorktreeIncludeFiles(repoRoot2, worktreePath) {
|
|
|
528466
528481
|
}
|
|
528467
528482
|
async function performPostCreationSetup(repoRoot2, worktreePath) {
|
|
528468
528483
|
const localSettingsRelativePath = getRelativeSettingsFilePathForSource("localSettings");
|
|
528469
|
-
const sourceSettingsLocal =
|
|
528484
|
+
const sourceSettingsLocal = join165(repoRoot2, localSettingsRelativePath);
|
|
528470
528485
|
try {
|
|
528471
|
-
const destSettingsLocal =
|
|
528486
|
+
const destSettingsLocal = join165(worktreePath, localSettingsRelativePath);
|
|
528472
528487
|
await mkdirRecursive(dirname72(destSettingsLocal));
|
|
528473
528488
|
await copyFile10(sourceSettingsLocal, destSettingsLocal);
|
|
528474
528489
|
logForDebugging(
|
|
@@ -528483,8 +528498,8 @@ async function performPostCreationSetup(repoRoot2, worktreePath) {
|
|
|
528483
528498
|
);
|
|
528484
528499
|
}
|
|
528485
528500
|
}
|
|
528486
|
-
const huskyPath =
|
|
528487
|
-
const gitHooksPath =
|
|
528501
|
+
const huskyPath = join165(repoRoot2, ".husky");
|
|
528502
|
+
const gitHooksPath = join165(repoRoot2, ".git", "hooks");
|
|
528488
528503
|
let hooksPath = null;
|
|
528489
528504
|
for (const candidatePath of [huskyPath, gitHooksPath]) {
|
|
528490
528505
|
try {
|
|
@@ -528524,7 +528539,7 @@ async function performPostCreationSetup(repoRoot2, worktreePath) {
|
|
|
528524
528539
|
}
|
|
528525
528540
|
await copyWorktreeIncludeFiles(repoRoot2, worktreePath);
|
|
528526
528541
|
if (false) {
|
|
528527
|
-
const worktreeHooksDir = hooksPath === huskyPath ?
|
|
528542
|
+
const worktreeHooksDir = hooksPath === huskyPath ? join165(worktreePath, ".husky") : void 0;
|
|
528528
528543
|
void null.then(
|
|
528529
528544
|
(m2) => m2.installPrepareCommitMsgHook(worktreePath, worktreeHooksDir).catch((error51) => {
|
|
528530
528545
|
logForDebugging(
|
|
@@ -528819,7 +528834,7 @@ async function cleanupStaleAgentWorktrees(cutoffDate) {
|
|
|
528819
528834
|
if (!EPHEMERAL_WORKTREE_PATTERNS.some((p) => p.test(slug))) {
|
|
528820
528835
|
continue;
|
|
528821
528836
|
}
|
|
528822
|
-
const worktreePath =
|
|
528837
|
+
const worktreePath = join165(dir, slug);
|
|
528823
528838
|
if (currentPath === worktreePath) {
|
|
528824
528839
|
continue;
|
|
528825
528840
|
}
|
|
@@ -535345,7 +535360,7 @@ __export(markdownConfigLoader_exports, {
|
|
|
535345
535360
|
import { statSync as statSync11 } from "fs";
|
|
535346
535361
|
import { lstat as lstat6, readdir as readdir31, readFile as readFile51, realpath as realpath12, stat as stat45 } from "fs/promises";
|
|
535347
535362
|
import { homedir as homedir42 } from "os";
|
|
535348
|
-
import { dirname as dirname73, join as
|
|
535363
|
+
import { dirname as dirname73, join as join166, resolve as resolve44, sep as sep35 } from "path";
|
|
535349
535364
|
function extractDescriptionFromMarkdown(content, defaultDescription = "Custom item") {
|
|
535350
535365
|
const lines = content.split("\n");
|
|
535351
535366
|
for (const line of lines) {
|
|
@@ -535436,7 +535451,7 @@ function getProjectDirsUpToHome(subdir, cwd5) {
|
|
|
535436
535451
|
if (normalizePathForComparison(current3) === normalizePathForComparison(home)) {
|
|
535437
535452
|
break;
|
|
535438
535453
|
}
|
|
535439
|
-
const claudeSubdir =
|
|
535454
|
+
const claudeSubdir = join166(current3, ".sema", subdir);
|
|
535440
535455
|
try {
|
|
535441
535456
|
statSync11(claudeSubdir);
|
|
535442
535457
|
dirs.push(claudeSubdir);
|
|
@@ -535484,7 +535499,7 @@ async function findMarkdownFilesNative(dir, signal) {
|
|
|
535484
535499
|
if (signal.aborted) {
|
|
535485
535500
|
break;
|
|
535486
535501
|
}
|
|
535487
|
-
const fullPath =
|
|
535502
|
+
const fullPath = join166(currentDir, entry.name);
|
|
535488
535503
|
try {
|
|
535489
535504
|
if (entry.isSymbolicLink()) {
|
|
535490
535505
|
try {
|
|
@@ -535590,20 +535605,20 @@ var init_markdownConfigLoader = __esm({
|
|
|
535590
535605
|
loadMarkdownFilesForSubdir = memoize_default(
|
|
535591
535606
|
async function(subdir, cwd5) {
|
|
535592
535607
|
const searchStartTime = Date.now();
|
|
535593
|
-
const userDir =
|
|
535594
|
-
const managedDir =
|
|
535608
|
+
const userDir = join166(getClaudeConfigHomeDir(), subdir);
|
|
535609
|
+
const managedDir = join166(getManagedFilePath(), ".sema", subdir);
|
|
535595
535610
|
const projectDirs = getProjectDirsUpToHome(subdir, cwd5);
|
|
535596
535611
|
const gitRoot = findGitRoot(cwd5);
|
|
535597
535612
|
const canonicalRoot = findCanonicalGitRoot(cwd5);
|
|
535598
535613
|
if (gitRoot && canonicalRoot && canonicalRoot !== gitRoot) {
|
|
535599
535614
|
const worktreeSubdir = normalizePathForComparison(
|
|
535600
|
-
|
|
535615
|
+
join166(gitRoot, ".sema", subdir)
|
|
535601
535616
|
);
|
|
535602
535617
|
const worktreeHasSubdir = projectDirs.some(
|
|
535603
535618
|
(dir) => normalizePathForComparison(dir) === worktreeSubdir
|
|
535604
535619
|
);
|
|
535605
535620
|
if (!worktreeHasSubdir) {
|
|
535606
|
-
const mainClaudeSubdir =
|
|
535621
|
+
const mainClaudeSubdir = join166(canonicalRoot, ".sema", subdir);
|
|
535607
535622
|
if (!projectDirs.includes(mainClaudeSubdir)) {
|
|
535608
535623
|
projectDirs.push(mainClaudeSubdir);
|
|
535609
535624
|
}
|
|
@@ -556971,6 +556986,14 @@ var init_degrading = __esm({
|
|
|
556971
556986
|
}
|
|
556972
556987
|
});
|
|
556973
556988
|
|
|
556989
|
+
// node_modules/@sema-agent/core/dist/core/side-query.js
|
|
556990
|
+
var init_side_query = __esm({
|
|
556991
|
+
"node_modules/@sema-agent/core/dist/core/side-query.js"() {
|
|
556992
|
+
init_roles();
|
|
556993
|
+
init_degrading();
|
|
556994
|
+
}
|
|
556995
|
+
});
|
|
556996
|
+
|
|
556974
556997
|
// node_modules/@sema-agent/core/dist/core/runner/usage-accounting.js
|
|
556975
556998
|
var init_usage_accounting = __esm({
|
|
556976
556999
|
"node_modules/@sema-agent/core/dist/core/runner/usage-accounting.js"() {
|
|
@@ -557131,7 +557154,7 @@ var init_auto_mode_prompt = __esm({
|
|
|
557131
557154
|
|
|
557132
557155
|
// node_modules/@sema-agent/core/dist/core/mcp.js
|
|
557133
557156
|
import { tmpdir as tmpdir15 } from "node:os";
|
|
557134
|
-
import { join as
|
|
557157
|
+
import { join as join167 } from "node:path";
|
|
557135
557158
|
var MCP_IMAGE_MAX_BASE64, IMAGE_TARGET_RAW_SIZE3, MCP_BLOB_DIR;
|
|
557136
557159
|
var init_mcp5 = __esm({
|
|
557137
557160
|
"node_modules/@sema-agent/core/dist/core/mcp.js"() {
|
|
@@ -557143,7 +557166,7 @@ var init_mcp5 = __esm({
|
|
|
557143
557166
|
init_untrusted_text();
|
|
557144
557167
|
MCP_IMAGE_MAX_BASE64 = 5 * 1024 * 1024;
|
|
557145
557168
|
IMAGE_TARGET_RAW_SIZE3 = MCP_IMAGE_MAX_BASE64 * 3 / 4;
|
|
557146
|
-
MCP_BLOB_DIR =
|
|
557169
|
+
MCP_BLOB_DIR = join167(tmpdir15(), "sema-mcp-blobs");
|
|
557147
557170
|
}
|
|
557148
557171
|
});
|
|
557149
557172
|
|
|
@@ -557863,6 +557886,7 @@ var init_runtask = __esm({
|
|
|
557863
557886
|
init_degrading();
|
|
557864
557887
|
init_status_sink();
|
|
557865
557888
|
init_roles();
|
|
557889
|
+
init_side_query();
|
|
557866
557890
|
init_prompt_suggestions();
|
|
557867
557891
|
init_memory_consolidation();
|
|
557868
557892
|
init_consolidate_scope();
|
|
@@ -558808,6 +558832,7 @@ var init_dist9 = __esm({
|
|
|
558808
558832
|
init_builtin_workflows();
|
|
558809
558833
|
init_workflow();
|
|
558810
558834
|
init_run_workflow_tool();
|
|
558835
|
+
init_side_query();
|
|
558811
558836
|
init_present_plan_tool();
|
|
558812
558837
|
init_workflow_run_store();
|
|
558813
558838
|
init_workflow_run_store2();
|
|
@@ -563360,11 +563385,11 @@ __export(fullscreenDefault_exports, {
|
|
|
563360
563385
|
applyFullscreenDefault: () => applyFullscreenDefault,
|
|
563361
563386
|
readFullscreenDefault: () => readFullscreenDefault
|
|
563362
563387
|
});
|
|
563363
|
-
import { readFileSync as
|
|
563364
|
-
import { join as
|
|
563388
|
+
import { readFileSync as readFileSync32 } from "fs";
|
|
563389
|
+
import { join as join168 } from "path";
|
|
563365
563390
|
function readFullscreenDefault(cwd5 = process.cwd()) {
|
|
563366
563391
|
try {
|
|
563367
|
-
const raw2 =
|
|
563392
|
+
const raw2 = readFileSync32(join168(cwd5, "config", "sema.shell.json"), "utf8");
|
|
563368
563393
|
const cfg = JSON.parse(raw2);
|
|
563369
563394
|
if (typeof cfg.fullscreen === "boolean") return cfg.fullscreen;
|
|
563370
563395
|
} catch {
|
|
@@ -563982,7 +564007,7 @@ __export(upstreamproxy_exports, {
|
|
|
563982
564007
|
});
|
|
563983
564008
|
import { mkdir as mkdir47, readFile as readFile52, unlink as unlink26, writeFile as writeFile47 } from "fs/promises";
|
|
563984
564009
|
import { homedir as homedir43 } from "os";
|
|
563985
|
-
import { join as
|
|
564010
|
+
import { join as join169 } from "path";
|
|
563986
564011
|
async function initUpstreamProxy(opts) {
|
|
563987
564012
|
if (!isEnvTruthy(process.env.SEMA_CODE_REMOTE)) {
|
|
563988
564013
|
return state2;
|
|
@@ -564006,7 +564031,7 @@ async function initUpstreamProxy(opts) {
|
|
|
564006
564031
|
}
|
|
564007
564032
|
setNonDumpable();
|
|
564008
564033
|
const baseUrl = opts?.ccrBaseUrl ?? process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com";
|
|
564009
|
-
const caBundlePath = opts?.caBundlePath ??
|
|
564034
|
+
const caBundlePath = opts?.caBundlePath ?? join169(homedir43(), ".ccr", "ca-bundle.crt");
|
|
564010
564035
|
const caOk = await downloadCaBundle(
|
|
564011
564036
|
baseUrl,
|
|
564012
564037
|
opts?.systemCaPath ?? SYSTEM_CA_BUNDLE,
|
|
@@ -564123,7 +564148,7 @@ async function downloadCaBundle(baseUrl, systemCaPath, outPath) {
|
|
|
564123
564148
|
}
|
|
564124
564149
|
const ccrCa = await resp.text();
|
|
564125
564150
|
const systemCa = await readFile52(systemCaPath, "utf8").catch(() => "");
|
|
564126
|
-
await mkdir47(
|
|
564151
|
+
await mkdir47(join169(outPath, ".."), { recursive: true });
|
|
564127
564152
|
await writeFile47(outPath, systemCa + "\n" + ccrCa, "utf8");
|
|
564128
564153
|
return true;
|
|
564129
564154
|
} catch (err8) {
|
|
@@ -575369,7 +575394,7 @@ var init_ShowInIDEPrompt = __esm({
|
|
|
575369
575394
|
|
|
575370
575395
|
// build-src/src/components/permissions/FilePermissionDialog/permissionOptions.tsx
|
|
575371
575396
|
import { homedir as homedir44 } from "os";
|
|
575372
|
-
import { basename as basename53, join as
|
|
575397
|
+
import { basename as basename53, join as join170, sep as sep36 } from "path";
|
|
575373
575398
|
function isInClaudeFolder(filePath) {
|
|
575374
575399
|
const absolutePath = expandPath(filePath);
|
|
575375
575400
|
const claudeFolderPath = expandPath(`${getOriginalCwd()}/.claude`);
|
|
@@ -575380,7 +575405,7 @@ function isInClaudeFolder(filePath) {
|
|
|
575380
575405
|
}
|
|
575381
575406
|
function isInGlobalClaudeFolder(filePath) {
|
|
575382
575407
|
const absolutePath = expandPath(filePath);
|
|
575383
|
-
const globalClaudeFolderPath =
|
|
575408
|
+
const globalClaudeFolderPath = join170(homedir44(), ".sema");
|
|
575384
575409
|
const normalizedAbsolutePath = normalizeCaseForComparison2(absolutePath);
|
|
575385
575410
|
const normalizedGlobalClaudeFolderPath = normalizeCaseForComparison2(globalClaudeFolderPath);
|
|
575386
575411
|
return normalizedAbsolutePath.startsWith(normalizedGlobalClaudeFolderPath + sep36.toLowerCase()) || normalizedAbsolutePath.startsWith(normalizedGlobalClaudeFolderPath + "/");
|
|
@@ -580570,9 +580595,9 @@ var init_WebFetchPermissionRequest = __esm({
|
|
|
580570
580595
|
});
|
|
580571
580596
|
|
|
580572
580597
|
// build-src/src/components/permissions/EngineWorkflowPermissionRequest.tsx
|
|
580573
|
-
import { mkdtempSync as mkdtempSync3, readFileSync as
|
|
580598
|
+
import { mkdtempSync as mkdtempSync3, readFileSync as readFileSync33, writeFileSync as writeFileSync18 } from "node:fs";
|
|
580574
580599
|
import { tmpdir as tmpdir16 } from "node:os";
|
|
580575
|
-
import { join as
|
|
580600
|
+
import { join as join171 } from "node:path";
|
|
580576
580601
|
function parseWorkflowScriptPreview(script) {
|
|
580577
580602
|
if (!script) return { phases: [] };
|
|
580578
580603
|
const out6 = { phases: [] };
|
|
@@ -580627,15 +580652,15 @@ function EngineWorkflowPermissionRequest({
|
|
|
580627
580652
|
(ch2, key) => {
|
|
580628
580653
|
if (!(key.ctrl && (ch2 === "g" || ch2 === "\x07"))) return;
|
|
580629
580654
|
try {
|
|
580630
|
-
const dir = mkdtempSync3(
|
|
580631
|
-
const file2 =
|
|
580655
|
+
const dir = mkdtempSync3(join171(tmpdir16(), "sema-wf-edit-"));
|
|
580656
|
+
const file2 = join171(dir, "workflow-script.mjs");
|
|
580632
580657
|
writeFileSync18(file2, effectiveScript ?? "");
|
|
580633
580658
|
const ok2 = openFileInExternalEditor(file2);
|
|
580634
580659
|
if (!ok2) {
|
|
580635
580660
|
setEditNote("editor unavailable \u2014 set a terminal $EDITOR (vim/nano/\u2026)");
|
|
580636
580661
|
return;
|
|
580637
580662
|
}
|
|
580638
|
-
const next =
|
|
580663
|
+
const next = readFileSync33(file2, "utf8");
|
|
580639
580664
|
if (next !== (effectiveScript ?? "")) {
|
|
580640
580665
|
setEditedScript(next);
|
|
580641
580666
|
setEditNote('script edited \u2014 "Yes, run it" runs the edited script');
|
|
@@ -597720,9 +597745,9 @@ function initSkillImprovement() {
|
|
|
597720
597745
|
}
|
|
597721
597746
|
async function applySkillImprovement(skillName, updates) {
|
|
597722
597747
|
if (!skillName) return;
|
|
597723
|
-
const { join:
|
|
597748
|
+
const { join: join207 } = await import("path");
|
|
597724
597749
|
const fs15 = await import("fs/promises");
|
|
597725
|
-
const filePath =
|
|
597750
|
+
const filePath = join207(getCwd(), ".sema", "skills", skillName, "SKILL.md");
|
|
597726
597751
|
let currentContent;
|
|
597727
597752
|
try {
|
|
597728
597753
|
currentContent = await fs15.readFile(filePath, "utf-8");
|
|
@@ -598262,7 +598287,7 @@ var init_autoDream = __esm({
|
|
|
598262
598287
|
// build-src/src/utils/cleanup.ts
|
|
598263
598288
|
import * as fs14 from "fs/promises";
|
|
598264
598289
|
import { homedir as homedir45 } from "os";
|
|
598265
|
-
import { join as
|
|
598290
|
+
import { join as join172 } from "path";
|
|
598266
598291
|
function getCleanupPeriodDays() {
|
|
598267
598292
|
const settings2 = getSettings_DEPRECATED() || {};
|
|
598268
598293
|
return settings2.cleanupPeriodDays ?? DEFAULT_CLEANUP_PERIOD_DAYS;
|
|
@@ -598289,7 +598314,7 @@ async function cleanupOldFilesInDirectory(dirPath, cutoffDate, isMessagePath) {
|
|
|
598289
598314
|
try {
|
|
598290
598315
|
const timestamp = convertFileNameToDate(file2.name);
|
|
598291
598316
|
if (timestamp < cutoffDate) {
|
|
598292
|
-
await getFsImplementation().unlink(
|
|
598317
|
+
await getFsImplementation().unlink(join172(dirPath, file2.name));
|
|
598293
598318
|
if (isMessagePath) {
|
|
598294
598319
|
result.messages++;
|
|
598295
598320
|
} else {
|
|
@@ -598322,7 +598347,7 @@ async function cleanupOldMessageFiles() {
|
|
|
598322
598347
|
}
|
|
598323
598348
|
const mcpLogDirs = dirents.filter(
|
|
598324
598349
|
(dirent) => dirent.isDirectory() && dirent.name.startsWith("mcp-logs-")
|
|
598325
|
-
).map((dirent) =>
|
|
598350
|
+
).map((dirent) => join172(baseCachePath, dirent.name));
|
|
598326
598351
|
for (const mcpLogDir of mcpLogDirs) {
|
|
598327
598352
|
result = addCleanupResults(
|
|
598328
598353
|
result,
|
|
@@ -598364,7 +598389,7 @@ async function cleanupOldSessionFiles() {
|
|
|
598364
598389
|
}
|
|
598365
598390
|
for (const projectDirent of projectDirents) {
|
|
598366
598391
|
if (!projectDirent.isDirectory()) continue;
|
|
598367
|
-
const projectDir2 =
|
|
598392
|
+
const projectDir2 = join172(projectsDir, projectDirent.name);
|
|
598368
598393
|
let entries;
|
|
598369
598394
|
try {
|
|
598370
598395
|
entries = await fsImpl.readdir(projectDir2);
|
|
@@ -598378,14 +598403,14 @@ async function cleanupOldSessionFiles() {
|
|
|
598378
598403
|
continue;
|
|
598379
598404
|
}
|
|
598380
598405
|
try {
|
|
598381
|
-
if (await unlinkIfOld(
|
|
598406
|
+
if (await unlinkIfOld(join172(projectDir2, entry.name), cutoffDate, fsImpl)) {
|
|
598382
598407
|
result.messages++;
|
|
598383
598408
|
}
|
|
598384
598409
|
} catch {
|
|
598385
598410
|
result.errors++;
|
|
598386
598411
|
}
|
|
598387
598412
|
} else if (entry.isDirectory()) {
|
|
598388
|
-
const sessionDir =
|
|
598413
|
+
const sessionDir = join172(projectDir2, entry.name);
|
|
598389
598414
|
result = addCleanupResults(
|
|
598390
598415
|
result,
|
|
598391
598416
|
await cleanupToolResultsUnderSession(sessionDir, cutoffDate, fsImpl)
|
|
@@ -598403,7 +598428,7 @@ async function cleanupOldSessionFiles() {
|
|
|
598403
598428
|
}
|
|
598404
598429
|
async function cleanupToolResultsUnderSession(sessionDir, cutoffDate, fsImpl) {
|
|
598405
598430
|
const result = { messages: 0, errors: 0 };
|
|
598406
|
-
const toolResultsDir =
|
|
598431
|
+
const toolResultsDir = join172(sessionDir, TOOL_RESULTS_SUBDIR);
|
|
598407
598432
|
let toolDirs;
|
|
598408
598433
|
try {
|
|
598409
598434
|
toolDirs = await fsImpl.readdir(toolResultsDir);
|
|
@@ -598414,7 +598439,7 @@ async function cleanupToolResultsUnderSession(sessionDir, cutoffDate, fsImpl) {
|
|
|
598414
598439
|
if (toolEntry.isFile()) {
|
|
598415
598440
|
try {
|
|
598416
598441
|
if (await unlinkIfOld(
|
|
598417
|
-
|
|
598442
|
+
join172(toolResultsDir, toolEntry.name),
|
|
598418
598443
|
cutoffDate,
|
|
598419
598444
|
fsImpl
|
|
598420
598445
|
)) {
|
|
@@ -598424,7 +598449,7 @@ async function cleanupToolResultsUnderSession(sessionDir, cutoffDate, fsImpl) {
|
|
|
598424
598449
|
result.errors++;
|
|
598425
598450
|
}
|
|
598426
598451
|
} else if (toolEntry.isDirectory()) {
|
|
598427
|
-
const toolDirPath =
|
|
598452
|
+
const toolDirPath = join172(toolResultsDir, toolEntry.name);
|
|
598428
598453
|
let toolFiles;
|
|
598429
598454
|
try {
|
|
598430
598455
|
toolFiles = await fsImpl.readdir(toolDirPath);
|
|
@@ -598434,7 +598459,7 @@ async function cleanupToolResultsUnderSession(sessionDir, cutoffDate, fsImpl) {
|
|
|
598434
598459
|
for (const tf of toolFiles) {
|
|
598435
598460
|
if (!tf.isFile()) continue;
|
|
598436
598461
|
try {
|
|
598437
|
-
if (await unlinkIfOld(
|
|
598462
|
+
if (await unlinkIfOld(join172(toolDirPath, tf.name), cutoffDate, fsImpl)) {
|
|
598438
598463
|
result.messages++;
|
|
598439
598464
|
}
|
|
598440
598465
|
} catch {
|
|
@@ -598449,7 +598474,7 @@ async function cleanupToolResultsUnderSession(sessionDir, cutoffDate, fsImpl) {
|
|
|
598449
598474
|
}
|
|
598450
598475
|
async function cleanupSubagentsUnderSession(sessionDir, cutoffDate, fsImpl) {
|
|
598451
598476
|
const result = { messages: 0, errors: 0 };
|
|
598452
|
-
const subagentsDir =
|
|
598477
|
+
const subagentsDir = join172(sessionDir, "subagents");
|
|
598453
598478
|
let entries;
|
|
598454
598479
|
try {
|
|
598455
598480
|
entries = await fsImpl.readdir(subagentsDir);
|
|
@@ -598459,14 +598484,14 @@ async function cleanupSubagentsUnderSession(sessionDir, cutoffDate, fsImpl) {
|
|
|
598459
598484
|
for (const entry of entries) {
|
|
598460
598485
|
if (entry.isFile()) {
|
|
598461
598486
|
try {
|
|
598462
|
-
if (await unlinkIfOld(
|
|
598487
|
+
if (await unlinkIfOld(join172(subagentsDir, entry.name), cutoffDate, fsImpl)) {
|
|
598463
598488
|
result.messages++;
|
|
598464
598489
|
}
|
|
598465
598490
|
} catch {
|
|
598466
598491
|
result.errors++;
|
|
598467
598492
|
}
|
|
598468
598493
|
} else if (entry.isDirectory()) {
|
|
598469
|
-
const subDir =
|
|
598494
|
+
const subDir = join172(subagentsDir, entry.name);
|
|
598470
598495
|
let subEntries;
|
|
598471
598496
|
try {
|
|
598472
598497
|
subEntries = await fsImpl.readdir(subDir);
|
|
@@ -598477,7 +598502,7 @@ async function cleanupSubagentsUnderSession(sessionDir, cutoffDate, fsImpl) {
|
|
|
598477
598502
|
if (subEntry.isFile()) {
|
|
598478
598503
|
try {
|
|
598479
598504
|
if (await unlinkIfOld(
|
|
598480
|
-
|
|
598505
|
+
join172(subDir, subEntry.name),
|
|
598481
598506
|
cutoffDate,
|
|
598482
598507
|
fsImpl
|
|
598483
598508
|
)) {
|
|
@@ -598487,7 +598512,7 @@ async function cleanupSubagentsUnderSession(sessionDir, cutoffDate, fsImpl) {
|
|
|
598487
598512
|
result.errors++;
|
|
598488
598513
|
}
|
|
598489
598514
|
} else if (subEntry.isDirectory()) {
|
|
598490
|
-
const runDir =
|
|
598515
|
+
const runDir = join172(subDir, subEntry.name);
|
|
598491
598516
|
let runFiles;
|
|
598492
598517
|
try {
|
|
598493
598518
|
runFiles = await fsImpl.readdir(runDir);
|
|
@@ -598497,7 +598522,7 @@ async function cleanupSubagentsUnderSession(sessionDir, cutoffDate, fsImpl) {
|
|
|
598497
598522
|
for (const rf of runFiles) {
|
|
598498
598523
|
if (!rf.isFile()) continue;
|
|
598499
598524
|
try {
|
|
598500
|
-
if (await unlinkIfOld(
|
|
598525
|
+
if (await unlinkIfOld(join172(runDir, rf.name), cutoffDate, fsImpl)) {
|
|
598501
598526
|
result.messages++;
|
|
598502
598527
|
}
|
|
598503
598528
|
} catch {
|
|
@@ -598526,7 +598551,7 @@ async function cleanupSingleDirectory(dirPath, extension2, removeEmptyDir = true
|
|
|
598526
598551
|
for (const dirent of dirents) {
|
|
598527
598552
|
if (!dirent.isFile() || !dirent.name.endsWith(extension2)) continue;
|
|
598528
598553
|
try {
|
|
598529
|
-
if (await unlinkIfOld(
|
|
598554
|
+
if (await unlinkIfOld(join172(dirPath, dirent.name), cutoffDate, fsImpl)) {
|
|
598530
598555
|
result.messages++;
|
|
598531
598556
|
}
|
|
598532
598557
|
} catch {
|
|
@@ -598539,7 +598564,7 @@ async function cleanupSingleDirectory(dirPath, extension2, removeEmptyDir = true
|
|
|
598539
598564
|
return result;
|
|
598540
598565
|
}
|
|
598541
598566
|
function cleanupOldPlanFiles() {
|
|
598542
|
-
const plansDir =
|
|
598567
|
+
const plansDir = join172(getClaudeConfigHomeDir(), "plans");
|
|
598543
598568
|
return cleanupSingleDirectory(plansDir, ".md");
|
|
598544
598569
|
}
|
|
598545
598570
|
async function cleanupOldFileHistoryBackups() {
|
|
@@ -598548,14 +598573,14 @@ async function cleanupOldFileHistoryBackups() {
|
|
|
598548
598573
|
const fsImpl = getFsImplementation();
|
|
598549
598574
|
try {
|
|
598550
598575
|
const configDir = getClaudeConfigHomeDir();
|
|
598551
|
-
const fileHistoryStorageDir =
|
|
598576
|
+
const fileHistoryStorageDir = join172(configDir, "file-history");
|
|
598552
598577
|
let dirents;
|
|
598553
598578
|
try {
|
|
598554
598579
|
dirents = await fsImpl.readdir(fileHistoryStorageDir);
|
|
598555
598580
|
} catch {
|
|
598556
598581
|
return result;
|
|
598557
598582
|
}
|
|
598558
|
-
const fileHistorySessionsDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
598583
|
+
const fileHistorySessionsDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join172(fileHistoryStorageDir, dirent.name));
|
|
598559
598584
|
await Promise.all(
|
|
598560
598585
|
fileHistorySessionsDirs.map(async (fileHistorySessionDir) => {
|
|
598561
598586
|
try {
|
|
@@ -598584,14 +598609,14 @@ async function cleanupOldSessionEnvDirs() {
|
|
|
598584
598609
|
const fsImpl = getFsImplementation();
|
|
598585
598610
|
try {
|
|
598586
598611
|
const configDir = getClaudeConfigHomeDir();
|
|
598587
|
-
const sessionEnvBaseDir =
|
|
598612
|
+
const sessionEnvBaseDir = join172(configDir, "session-env");
|
|
598588
598613
|
let dirents;
|
|
598589
598614
|
try {
|
|
598590
598615
|
dirents = await fsImpl.readdir(sessionEnvBaseDir);
|
|
598591
598616
|
} catch {
|
|
598592
598617
|
return result;
|
|
598593
598618
|
}
|
|
598594
|
-
const sessionEnvDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
598619
|
+
const sessionEnvDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join172(sessionEnvBaseDir, dirent.name));
|
|
598595
598620
|
for (const sessionEnvDir of sessionEnvDirs) {
|
|
598596
598621
|
try {
|
|
598597
598622
|
const stats3 = await fsImpl.stat(sessionEnvDir);
|
|
@@ -598642,7 +598667,7 @@ async function cleanupOldDebugLogs() {
|
|
|
598642
598667
|
const cutoffDate = getCutoffDate();
|
|
598643
598668
|
const result = { messages: 0, errors: 0 };
|
|
598644
598669
|
const fsImpl = getFsImplementation();
|
|
598645
|
-
const debugDir =
|
|
598670
|
+
const debugDir = join172(getClaudeConfigHomeDir(), "debug");
|
|
598646
598671
|
let dirents;
|
|
598647
598672
|
try {
|
|
598648
598673
|
dirents = await fsImpl.readdir(debugDir);
|
|
@@ -598654,7 +598679,7 @@ async function cleanupOldDebugLogs() {
|
|
|
598654
598679
|
continue;
|
|
598655
598680
|
}
|
|
598656
598681
|
try {
|
|
598657
|
-
if (await unlinkIfOld(
|
|
598682
|
+
if (await unlinkIfOld(join172(debugDir, dirent.name), cutoffDate, fsImpl)) {
|
|
598658
598683
|
result.messages++;
|
|
598659
598684
|
}
|
|
598660
598685
|
} catch {
|
|
@@ -598664,7 +598689,7 @@ async function cleanupOldDebugLogs() {
|
|
|
598664
598689
|
return result;
|
|
598665
598690
|
}
|
|
598666
598691
|
async function cleanupNpmCacheForAnthropicPackages() {
|
|
598667
|
-
const markerPath =
|
|
598692
|
+
const markerPath = join172(getClaudeConfigHomeDir(), ".npm-cache-cleanup");
|
|
598668
598693
|
try {
|
|
598669
598694
|
const stat55 = await fs14.stat(markerPath);
|
|
598670
598695
|
if (Date.now() - stat55.mtimeMs < ONE_DAY_MS2) {
|
|
@@ -598680,7 +598705,7 @@ async function cleanupNpmCacheForAnthropicPackages() {
|
|
|
598680
598705
|
return;
|
|
598681
598706
|
}
|
|
598682
598707
|
logForDebugging("npm cache cleanup: starting");
|
|
598683
|
-
const npmCachePath =
|
|
598708
|
+
const npmCachePath = join172(homedir45(), ".npm", "_cacache");
|
|
598684
598709
|
const NPM_CACHE_RETENTION_COUNT = 5;
|
|
598685
598710
|
const startTime = Date.now();
|
|
598686
598711
|
try {
|
|
@@ -598740,7 +598765,7 @@ async function cleanupNpmCacheForAnthropicPackages() {
|
|
|
598740
598765
|
}
|
|
598741
598766
|
}
|
|
598742
598767
|
async function cleanupOldVersionsThrottled() {
|
|
598743
|
-
const markerPath =
|
|
598768
|
+
const markerPath = join172(getClaudeConfigHomeDir(), ".version-cleanup");
|
|
598744
598769
|
try {
|
|
598745
598770
|
const stat55 = await fs14.stat(markerPath);
|
|
598746
598771
|
if (Date.now() - stat55.mtimeMs < ONE_DAY_MS2) {
|
|
@@ -600823,8 +600848,6 @@ var init_useCanUseTool = __esm({
|
|
|
600823
600848
|
});
|
|
600824
600849
|
|
|
600825
600850
|
// build-src/src/sema/sessionAutoTitle.ts
|
|
600826
|
-
import { readFileSync as readFileSync35 } from "node:fs";
|
|
600827
|
-
import { join as join174 } from "node:path";
|
|
600828
600851
|
function maybeGenerateSessionTitle(sessionContent) {
|
|
600829
600852
|
if (attempted) return;
|
|
600830
600853
|
if (!process.env.SEMA_LIVE_BASEURL) {
|
|
@@ -600853,65 +600876,44 @@ function maybeGenerateSessionTitle(sessionContent) {
|
|
|
600853
600876
|
});
|
|
600854
600877
|
}
|
|
600855
600878
|
async function generateAndSave(snippet) {
|
|
600856
|
-
|
|
600857
|
-
if (!baseUrl) return;
|
|
600858
|
-
let token = process.env.SEMA_LIVE_TOKEN ?? "";
|
|
600859
|
-
if (!token) {
|
|
600860
|
-
try {
|
|
600861
|
-
token = readFileSync35(join174(getClaudeConfigHomeDir(), "engine.token"), "utf-8").trim();
|
|
600862
|
-
} catch {
|
|
600863
|
-
}
|
|
600864
|
-
}
|
|
600879
|
+
if (!engineSideChannelActive()) return;
|
|
600865
600880
|
const objective = `${TITLE_PROMPT}
|
|
600866
600881
|
|
|
600867
600882
|
<session>
|
|
600868
600883
|
${snippet}
|
|
600869
600884
|
</session>`;
|
|
600870
|
-
|
|
600871
|
-
baseUrl,
|
|
600872
|
-
...token ? { token } : {},
|
|
600873
|
-
principal: process.env.SEMA_LIVE_PRINCIPAL ?? "anon:shell-live"
|
|
600874
|
-
});
|
|
600875
|
-
if (!client4) return;
|
|
600876
|
-
const controller = new AbortController();
|
|
600877
|
-
const timer2 = setTimeout(() => controller.abort(), 6e4);
|
|
600885
|
+
let text2;
|
|
600878
600886
|
try {
|
|
600879
|
-
|
|
600880
|
-
|
|
600881
|
-
|
|
600882
|
-
|
|
600883
|
-
|
|
600884
|
-
|
|
600885
|
-
} catch (e) {
|
|
600886
|
-
const status3 = e?.status;
|
|
600887
|
-
if (typeof status3 === "number") {
|
|
600888
|
-
logForDebugging(`[auto-title] engine ${status3}`);
|
|
600889
|
-
return;
|
|
600890
|
-
}
|
|
600891
|
-
throw e;
|
|
600887
|
+
text2 = await engineUtilityText({ objective, timeoutMs: 6e4 }) ?? "";
|
|
600888
|
+
} catch (e) {
|
|
600889
|
+
const status3 = e?.status;
|
|
600890
|
+
if (typeof status3 === "number") {
|
|
600891
|
+
logForDebugging(`[auto-title] engine ${status3}`);
|
|
600892
|
+
return;
|
|
600892
600893
|
}
|
|
600893
|
-
|
|
600894
|
-
|
|
600895
|
-
const title = m2 ? JSON.parse(`"${m2[1]}"`) : "";
|
|
600896
|
-
if (typeof title !== "string" || !title.trim() || title.length > 120) {
|
|
600897
|
-
logForDebugging(`[auto-title] unparsable result (${text2.slice(0, 80)})`);
|
|
600894
|
+
if (e instanceof Error && e.message.includes("empty result")) {
|
|
600895
|
+
logForDebugging("[auto-title] unparsable result (empty)");
|
|
600898
600896
|
return;
|
|
600899
600897
|
}
|
|
600900
|
-
|
|
600901
|
-
|
|
600902
|
-
|
|
600903
|
-
}
|
|
600904
|
-
|
|
600898
|
+
throw e;
|
|
600899
|
+
}
|
|
600900
|
+
const m2 = text2.match(/\{[^{}]*"title"\s*:\s*"((?:[^"\\]|\\.)*)"[^{}]*\}/);
|
|
600901
|
+
const title = m2 ? JSON.parse(`"${m2[1]}"`) : "";
|
|
600902
|
+
if (typeof title !== "string" || !title.trim() || title.length > 120) {
|
|
600903
|
+
logForDebugging(`[auto-title] unparsable result (${text2.slice(0, 80)})`);
|
|
600904
|
+
return;
|
|
600905
600905
|
}
|
|
600906
|
+
if (getCurrentSessionTitle(getSessionId())) return;
|
|
600907
|
+
await saveCustomTitle(getSessionId(), title.trim(), void 0, "auto");
|
|
600908
|
+
logForDebugging(`[auto-title] saved: ${title.trim()}`);
|
|
600906
600909
|
}
|
|
600907
600910
|
var attempted, TITLE_PROMPT;
|
|
600908
600911
|
var init_sessionAutoTitle = __esm({
|
|
600909
600912
|
"build-src/src/sema/sessionAutoTitle.ts"() {
|
|
600910
600913
|
init_state();
|
|
600911
600914
|
init_debug();
|
|
600912
|
-
init_envUtils();
|
|
600913
600915
|
init_sessionStorage();
|
|
600914
|
-
|
|
600916
|
+
init_engineSideChannel();
|
|
600915
600917
|
attempted = false;
|
|
600916
600918
|
TITLE_PROMPT = `Generate a concise, sentence-case title (3-7 words) that captures the main topic or goal of this coding session. The title should be clear enough that the user recognizes the session in a list. Use sentence case: capitalize only the first word and proper nouns.
|
|
600917
600919
|
|
|
@@ -602789,7 +602791,7 @@ __export(asciicast_exports, {
|
|
|
602789
602791
|
renameRecordingForSession: () => renameRecordingForSession
|
|
602790
602792
|
});
|
|
602791
602793
|
import { appendFile as appendFile5, rename as rename14 } from "fs/promises";
|
|
602792
|
-
import { basename as basename63, dirname as dirname74, join as
|
|
602794
|
+
import { basename as basename63, dirname as dirname74, join as join174 } from "path";
|
|
602793
602795
|
function getRecordFilePath() {
|
|
602794
602796
|
if (recordingState.filePath !== null) {
|
|
602795
602797
|
return recordingState.filePath;
|
|
@@ -602800,10 +602802,10 @@ function getRecordFilePath() {
|
|
|
602800
602802
|
if (!isEnvTruthy(process.env.SEMA_CODE_TERMINAL_RECORDING)) {
|
|
602801
602803
|
return null;
|
|
602802
602804
|
}
|
|
602803
|
-
const projectsDir =
|
|
602804
|
-
const projectDir2 =
|
|
602805
|
+
const projectsDir = join174(getClaudeConfigHomeDir(), "projects");
|
|
602806
|
+
const projectDir2 = join174(projectsDir, sanitizePath(getOriginalCwd()));
|
|
602805
602807
|
recordingState.timestamp = Date.now();
|
|
602806
|
-
recordingState.filePath =
|
|
602808
|
+
recordingState.filePath = join174(
|
|
602807
602809
|
projectDir2,
|
|
602808
602810
|
`${getSessionId()}-${recordingState.timestamp}.cast`
|
|
602809
602811
|
);
|
|
@@ -602815,13 +602817,13 @@ function _resetRecordingStateForTesting() {
|
|
|
602815
602817
|
}
|
|
602816
602818
|
function getSessionRecordingPaths() {
|
|
602817
602819
|
const sessionId = getSessionId();
|
|
602818
|
-
const projectsDir =
|
|
602819
|
-
const projectDir2 =
|
|
602820
|
+
const projectsDir = join174(getClaudeConfigHomeDir(), "projects");
|
|
602821
|
+
const projectDir2 = join174(projectsDir, sanitizePath(getOriginalCwd()));
|
|
602820
602822
|
try {
|
|
602821
602823
|
const entries = getFsImplementation().readdirSync(projectDir2);
|
|
602822
602824
|
const names = typeof entries[0] === "string" ? entries : entries.map((e) => e.name);
|
|
602823
602825
|
const files2 = names.filter((f) => f.startsWith(sessionId) && f.endsWith(".cast")).sort();
|
|
602824
|
-
return files2.map((f) =>
|
|
602826
|
+
return files2.map((f) => join174(projectDir2, f));
|
|
602825
602827
|
} catch {
|
|
602826
602828
|
return [];
|
|
602827
602829
|
}
|
|
@@ -602831,9 +602833,9 @@ async function renameRecordingForSession() {
|
|
|
602831
602833
|
if (!oldPath || recordingState.timestamp === 0) {
|
|
602832
602834
|
return;
|
|
602833
602835
|
}
|
|
602834
|
-
const projectsDir =
|
|
602835
|
-
const projectDir2 =
|
|
602836
|
-
const newPath =
|
|
602836
|
+
const projectsDir = join174(getClaudeConfigHomeDir(), "projects");
|
|
602837
|
+
const projectDir2 = join174(projectsDir, sanitizePath(getOriginalCwd()));
|
|
602838
|
+
const newPath = join174(
|
|
602837
602839
|
projectDir2,
|
|
602838
602840
|
`${getSessionId()}-${recordingState.timestamp}.cast`
|
|
602839
602841
|
);
|
|
@@ -602964,7 +602966,7 @@ __export(sessionAutoSync_exports, {
|
|
|
602964
602966
|
maybeQueueAutoSyncPushAfterTurn: () => maybeQueueAutoSyncPushAfterTurn,
|
|
602965
602967
|
onAutoSyncEvent: () => onAutoSyncEvent
|
|
602966
602968
|
});
|
|
602967
|
-
import { readFileSync as
|
|
602969
|
+
import { readFileSync as readFileSync34 } from "node:fs";
|
|
602968
602970
|
function onAutoSyncEvent(cb) {
|
|
602969
602971
|
listener3 = cb;
|
|
602970
602972
|
for (const ev of pendingEvents2) cb(ev);
|
|
@@ -603005,7 +603007,7 @@ async function projectAutoSyncEnabled() {
|
|
|
603005
603007
|
const { getSettingsFilePathForSource: getSettingsFilePathForSource2 } = await Promise.resolve().then(() => (init_settings2(), settings_exports));
|
|
603006
603008
|
const path27 = getSettingsFilePathForSource2("localSettings");
|
|
603007
603009
|
if (!path27) return false;
|
|
603008
|
-
const doc = JSON.parse(
|
|
603010
|
+
const doc = JSON.parse(readFileSync34(path27, "utf8"));
|
|
603009
603011
|
return doc?.[AUTO_SYNC_SETTINGS_KEY] === true;
|
|
603010
603012
|
} catch {
|
|
603011
603013
|
return false;
|
|
@@ -606506,7 +606508,7 @@ var init_useChromeExtensionNotification = __esm({
|
|
|
606506
606508
|
});
|
|
606507
606509
|
|
|
606508
606510
|
// build-src/src/utils/plugins/officialMarketplaceStartupCheck.ts
|
|
606509
|
-
import { join as
|
|
606511
|
+
import { join as join175 } from "path";
|
|
606510
606512
|
function isOfficialMarketplaceAutoInstallDisabled() {
|
|
606511
606513
|
return isEnvTruthy(
|
|
606512
606514
|
process.env.SEMA_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL
|
|
@@ -606597,7 +606599,7 @@ async function checkAndInstallOfficialMarketplace() {
|
|
|
606597
606599
|
return { installed: false, skipped: true, reason: "policy_blocked" };
|
|
606598
606600
|
}
|
|
606599
606601
|
const cacheDir = getMarketplacesCacheDir();
|
|
606600
|
-
const installLocation =
|
|
606602
|
+
const installLocation = join175(cacheDir, OFFICIAL_MARKETPLACE_NAME);
|
|
606601
606603
|
const gcsSha = await fetchOfficialMarketplaceFromGcs(
|
|
606602
606604
|
installLocation,
|
|
606603
606605
|
cacheDir
|
|
@@ -610007,7 +610009,7 @@ var init_usePluginRecommendationBase = __esm({
|
|
|
610007
610009
|
});
|
|
610008
610010
|
|
|
610009
610011
|
// build-src/src/hooks/useLspPluginRecommendation.tsx
|
|
610010
|
-
import { extname as extname16, join as
|
|
610012
|
+
import { extname as extname16, join as join176 } from "path";
|
|
610011
610013
|
function useLspPluginRecommendation() {
|
|
610012
610014
|
const $3 = (0, import_compiler_runtime320.c)(12);
|
|
610013
610015
|
const trackedFiles = useAppState(_temp164);
|
|
@@ -610092,7 +610094,7 @@ function useLspPluginRecommendation() {
|
|
|
610092
610094
|
case "yes": {
|
|
610093
610095
|
installPluginAndNotify(pluginId, pluginName, "lsp-plugin", addNotification, async (pluginData) => {
|
|
610094
610096
|
logForDebugging(`[useLspPluginRecommendation] Installing plugin: ${pluginId}`);
|
|
610095
|
-
const localSourcePath = typeof pluginData.entry.source === "string" ?
|
|
610097
|
+
const localSourcePath = typeof pluginData.entry.source === "string" ? join176(pluginData.marketplaceInstallLocation, pluginData.entry.source) : void 0;
|
|
610096
610098
|
await cacheAndRegisterPlugin(pluginId, pluginData.entry, "user", void 0, localSourcePath);
|
|
610097
610099
|
const settings2 = getSettingsForSource("userSettings");
|
|
610098
610100
|
updateSettingsForSource("userSettings", {
|
|
@@ -612873,7 +612875,7 @@ __export(REPL_exports, {
|
|
|
612873
612875
|
REPL: () => REPL
|
|
612874
612876
|
});
|
|
612875
612877
|
import { spawnSync as spawnSync11 } from "child_process";
|
|
612876
|
-
import { dirname as dirname76, join as
|
|
612878
|
+
import { dirname as dirname76, join as join177 } from "path";
|
|
612877
612879
|
import { tmpdir as tmpdir17 } from "os";
|
|
612878
612880
|
import { writeFile as writeFile49 } from "fs/promises";
|
|
612879
612881
|
import { randomUUID as randomUUID51 } from "crypto";
|
|
@@ -615838,7 +615840,7 @@ Note: ctrl + z now suspends Sema, ctrl + _ undoes input.
|
|
|
615838
615840
|
const w2 = Math.max(80, (process.stdout.columns ?? 80) - 6);
|
|
615839
615841
|
const raw2 = await renderMessagesToPlainText(deferredMessages, tools, w2);
|
|
615840
615842
|
const text2 = raw2.replace(/[ \t]+$/gm, "");
|
|
615841
|
-
const path27 =
|
|
615843
|
+
const path27 = join177(tmpdir17(), `cc-transcript-${Date.now()}.txt`);
|
|
615842
615844
|
await writeFile49(path27, text2);
|
|
615843
615845
|
const opened = openFileInExternalEditor(path27);
|
|
615844
615846
|
setStatus(opened ? `opening ${path27}` : `wrote ${path27} \xB7 no $VISUAL/$EDITOR set`);
|
|
@@ -620263,8 +620265,8 @@ IMPORTANT: Start by calling mcp__claude-in-chrome__tabs_context_mcp to get infor
|
|
|
620263
620265
|
});
|
|
620264
620266
|
|
|
620265
620267
|
// build-src/src/sema/engineReportFindingsFace.ts
|
|
620266
|
-
import { existsSync as existsSync24, readFileSync as
|
|
620267
|
-
import { basename as basename64, dirname as dirname78, join as
|
|
620268
|
+
import { existsSync as existsSync24, readFileSync as readFileSync35 } from "fs";
|
|
620269
|
+
import { basename as basename64, dirname as dirname78, join as join178 } from "path";
|
|
620268
620270
|
function isLiveEngineSession() {
|
|
620269
620271
|
return typeof process.env.SEMA_LIVE_BASEURL === "string" && process.env.SEMA_LIVE_BASEURL.length > 0;
|
|
620270
620272
|
}
|
|
@@ -620282,18 +620284,18 @@ function localEngineCoreVersion() {
|
|
|
620282
620284
|
const entry = resolveEngineEntry();
|
|
620283
620285
|
if (!entry) return void 0;
|
|
620284
620286
|
const candidates = [
|
|
620285
|
-
|
|
620286
|
-
|
|
620287
|
+
join178(entry.cwd, "node_modules", "@sema-agent", "core", "package.json"),
|
|
620288
|
+
join178(entry.cwd, "node_modules", "@sema-ai", "core", "package.json")
|
|
620287
620289
|
];
|
|
620288
620290
|
const parent2 = dirname78(entry.cwd);
|
|
620289
620291
|
if (basename64(parent2) === "@sema-agent" || basename64(parent2) === "@sema-ai") {
|
|
620290
|
-
candidates.push(
|
|
620291
|
-
candidates.push(
|
|
620292
|
+
candidates.push(join178(parent2, "core", "package.json"));
|
|
620293
|
+
candidates.push(join178(dirname78(parent2), "@sema-agent", "core", "package.json"));
|
|
620292
620294
|
}
|
|
620293
620295
|
for (const p of candidates) {
|
|
620294
620296
|
try {
|
|
620295
620297
|
if (!existsSync24(p)) continue;
|
|
620296
|
-
const pkg = JSON.parse(
|
|
620298
|
+
const pkg = JSON.parse(readFileSync35(p, "utf8"));
|
|
620297
620299
|
if (typeof pkg.version === "string" && pkg.version.length > 0) return pkg.version;
|
|
620298
620300
|
} catch {
|
|
620299
620301
|
}
|
|
@@ -621891,8 +621893,8 @@ __export(semaUpdater_exports, {
|
|
|
621891
621893
|
startSemaAutoUpdate: () => startSemaAutoUpdate
|
|
621892
621894
|
});
|
|
621893
621895
|
import { execFile as execFile7 } from "node:child_process";
|
|
621894
|
-
import { readFileSync as
|
|
621895
|
-
import { join as
|
|
621896
|
+
import { readFileSync as readFileSync36, realpathSync as realpathSync9 } from "node:fs";
|
|
621897
|
+
import { join as join179 } from "node:path";
|
|
621896
621898
|
function updateRegistry() {
|
|
621897
621899
|
const r = process.env.SEMA_UPDATE_REGISTRY?.trim();
|
|
621898
621900
|
const base = r && /^https?:\/\//.test(r) ? r : DEFAULT_REGISTRY;
|
|
@@ -621908,7 +621910,7 @@ function realArgv1() {
|
|
|
621908
621910
|
function installedPkgRoot() {
|
|
621909
621911
|
const p = realArgv1();
|
|
621910
621912
|
for (const name of KNOWN_PKGS) {
|
|
621911
|
-
const seg =
|
|
621913
|
+
const seg = join179("node_modules", ...name.split("/"));
|
|
621912
621914
|
const rootIdx = p.indexOf(seg);
|
|
621913
621915
|
if (rootIdx >= 0) return p.slice(0, rootIdx + seg.length);
|
|
621914
621916
|
}
|
|
@@ -621921,7 +621923,7 @@ function installedPkgName() {
|
|
|
621921
621923
|
try {
|
|
621922
621924
|
const root2 = installedPkgRoot();
|
|
621923
621925
|
if (root2) {
|
|
621924
|
-
const pkg = JSON.parse(
|
|
621926
|
+
const pkg = JSON.parse(readFileSync36(join179(root2, "package.json"), "utf8"));
|
|
621925
621927
|
if (typeof pkg.name === "string" && pkg.name.length > 0) return pkg.name;
|
|
621926
621928
|
}
|
|
621927
621929
|
} catch {
|
|
@@ -621932,7 +621934,7 @@ function installedVersion() {
|
|
|
621932
621934
|
try {
|
|
621933
621935
|
const pkgRoot = installedPkgRoot();
|
|
621934
621936
|
if (!pkgRoot) return null;
|
|
621935
|
-
const pkg = JSON.parse(
|
|
621937
|
+
const pkg = JSON.parse(readFileSync36(join179(pkgRoot, "package.json"), "utf8"));
|
|
621936
621938
|
return typeof pkg.version === "string" ? pkg.version : null;
|
|
621937
621939
|
} catch {
|
|
621938
621940
|
return null;
|
|
@@ -621942,7 +621944,7 @@ function installedEngineVersion() {
|
|
|
621942
621944
|
try {
|
|
621943
621945
|
const pkgRoot = installedPkgRoot();
|
|
621944
621946
|
if (!pkgRoot) return null;
|
|
621945
|
-
const pkg = JSON.parse(
|
|
621947
|
+
const pkg = JSON.parse(readFileSync36(join179(pkgRoot, "package.json"), "utf8"));
|
|
621946
621948
|
return typeof pkg.semaEngineVersion === "string" && pkg.semaEngineVersion.length > 0 ? pkg.semaEngineVersion : null;
|
|
621947
621949
|
} catch {
|
|
621948
621950
|
return null;
|
|
@@ -621951,7 +621953,7 @@ function installedEngineVersion() {
|
|
|
621951
621953
|
function npmrcToken() {
|
|
621952
621954
|
try {
|
|
621953
621955
|
const host = new URL(updateRegistry()).host;
|
|
621954
|
-
const rc =
|
|
621956
|
+
const rc = readFileSync36(join179(process.env.HOME ?? "", ".npmrc"), "utf8");
|
|
621955
621957
|
for (const line of rc.split("\n")) {
|
|
621956
621958
|
const m2 = line.match(/^\s*\/\/([^/]+)[^:]*:_authToken=(.+)$/);
|
|
621957
621959
|
if (m2 && m2[1] === host) return m2[2].trim();
|
|
@@ -622039,7 +622041,7 @@ var init_semaUpdater = __esm({
|
|
|
622039
622041
|
});
|
|
622040
622042
|
|
|
622041
622043
|
// build-src/src/commands/doctor/semaSections.tsx
|
|
622042
|
-
import { existsSync as existsSync25, readFileSync as
|
|
622044
|
+
import { existsSync as existsSync25, readFileSync as readFileSync37 } from "node:fs";
|
|
622043
622045
|
function SemaVersionLines({
|
|
622044
622046
|
installationType,
|
|
622045
622047
|
ccVersion
|
|
@@ -622112,7 +622114,7 @@ function mergedModelEnv() {
|
|
|
622112
622114
|
const out6 = {};
|
|
622113
622115
|
try {
|
|
622114
622116
|
const sj = JSON.parse(
|
|
622115
|
-
|
|
622117
|
+
readFileSync37(`${getClaudeConfigHomeDir()}/settings.json`, "utf8")
|
|
622116
622118
|
);
|
|
622117
622119
|
if (sj?.env) {
|
|
622118
622120
|
for (const [k2, v2] of Object.entries(sj.env)) if (typeof v2 === "string") out6[k2] = v2;
|
|
@@ -622180,7 +622182,7 @@ async function collectEngineRows() {
|
|
|
622180
622182
|
let anchor = null;
|
|
622181
622183
|
try {
|
|
622182
622184
|
if (existsSync25(portFilePath)) {
|
|
622183
|
-
const parsed = JSON.parse(
|
|
622185
|
+
const parsed = JSON.parse(readFileSync37(portFilePath, "utf8"));
|
|
622184
622186
|
if (typeof parsed.port === "number" && typeof parsed.pid === "number") anchor = parsed;
|
|
622185
622187
|
}
|
|
622186
622188
|
} catch {
|
|
@@ -622224,7 +622226,7 @@ async function collectEngineRows() {
|
|
|
622224
622226
|
const tokenPath = getEngineTokenFilePath();
|
|
622225
622227
|
let hasToken = false;
|
|
622226
622228
|
try {
|
|
622227
|
-
hasToken = existsSync25(tokenPath) &&
|
|
622229
|
+
hasToken = existsSync25(tokenPath) && readFileSync37(tokenPath, "utf8").trim().length > 0;
|
|
622228
622230
|
} catch {
|
|
622229
622231
|
}
|
|
622230
622232
|
if (anchor && isProcessAlive(anchor.pid ?? -1)) {
|
|
@@ -625128,12 +625130,12 @@ var init_createDirectConnectSession = __esm({
|
|
|
625128
625130
|
});
|
|
625129
625131
|
|
|
625130
625132
|
// build-src/src/utils/errorLogSink.ts
|
|
625131
|
-
import { dirname as dirname79, join as
|
|
625133
|
+
import { dirname as dirname79, join as join180 } from "path";
|
|
625132
625134
|
function getErrorsPath() {
|
|
625133
|
-
return
|
|
625135
|
+
return join180(CACHE_PATHS.errors(), DATE2 + ".jsonl");
|
|
625134
625136
|
}
|
|
625135
625137
|
function getMCPLogsPath(serverName) {
|
|
625136
|
-
return
|
|
625138
|
+
return join180(CACHE_PATHS.mcpLogs(serverName), DATE2 + ".jsonl");
|
|
625137
625139
|
}
|
|
625138
625140
|
function createJsonlWriter(options) {
|
|
625139
625141
|
const writer = createBufferedWriter(options);
|
|
@@ -625499,7 +625501,7 @@ var init_sessionMemory = __esm({
|
|
|
625499
625501
|
// build-src/src/utils/iTermBackup.ts
|
|
625500
625502
|
import { copyFile as copyFile11, stat as stat49 } from "fs/promises";
|
|
625501
625503
|
import { homedir as homedir46 } from "os";
|
|
625502
|
-
import { join as
|
|
625504
|
+
import { join as join181 } from "path";
|
|
625503
625505
|
function markITerm2SetupComplete() {
|
|
625504
625506
|
saveGlobalConfig((current3) => ({
|
|
625505
625507
|
...current3,
|
|
@@ -625514,7 +625516,7 @@ function getIterm2RecoveryInfo() {
|
|
|
625514
625516
|
};
|
|
625515
625517
|
}
|
|
625516
625518
|
function getITerm2PlistPath() {
|
|
625517
|
-
return
|
|
625519
|
+
return join181(
|
|
625518
625520
|
homedir46(),
|
|
625519
625521
|
"Library",
|
|
625520
625522
|
"Preferences",
|
|
@@ -629613,7 +629615,7 @@ __export(skillsWire_exports, {
|
|
|
629613
629615
|
skillCommandsToSpecs: () => skillCommandsToSpecs,
|
|
629614
629616
|
toCappedSpec: () => toCappedSpec
|
|
629615
629617
|
});
|
|
629616
|
-
import { join as
|
|
629618
|
+
import { join as join182 } from "path";
|
|
629617
629619
|
async function loadSkillSpecs(cwd5) {
|
|
629618
629620
|
const [dir, plugin2] = await Promise.all([
|
|
629619
629621
|
getSkillDirCommands(cwd5).catch(() => []),
|
|
@@ -629631,7 +629633,7 @@ async function loadSkillSpecs(cwd5) {
|
|
|
629631
629633
|
await Promise.all(
|
|
629632
629634
|
roots.map(async (root2) => {
|
|
629633
629635
|
try {
|
|
629634
|
-
const raw2 = await fs15.readFile(
|
|
629636
|
+
const raw2 = await fs15.readFile(join182(root2, "SKILL.md"), { encoding: "utf-8" });
|
|
629635
629637
|
const body = parseFrontmatter(raw2).content.trim();
|
|
629636
629638
|
if (body) bodyByRoot.set(root2, body);
|
|
629637
629639
|
} catch {
|
|
@@ -631723,7 +631725,7 @@ var init_idleTimeout = __esm({
|
|
|
631723
631725
|
// build-src/src/bridge/inboundAttachments.ts
|
|
631724
631726
|
import { randomUUID as randomUUID54 } from "crypto";
|
|
631725
631727
|
import { mkdir as mkdir48, writeFile as writeFile51 } from "fs/promises";
|
|
631726
|
-
import { basename as basename65, join as
|
|
631728
|
+
import { basename as basename65, join as join183 } from "path";
|
|
631727
631729
|
function debug(msg) {
|
|
631728
631730
|
logForDebugging(`[bridge:inbound-attach] ${msg}`);
|
|
631729
631731
|
}
|
|
@@ -631739,7 +631741,7 @@ function sanitizeFileName(name) {
|
|
|
631739
631741
|
return base || "attachment";
|
|
631740
631742
|
}
|
|
631741
631743
|
function uploadsDir() {
|
|
631742
|
-
return
|
|
631744
|
+
return join183(getClaudeConfigHomeDir(), "uploads", getSessionId());
|
|
631743
631745
|
}
|
|
631744
631746
|
async function resolveOne(att) {
|
|
631745
631747
|
const token = getBridgeAccessToken();
|
|
@@ -631768,7 +631770,7 @@ async function resolveOne(att) {
|
|
|
631768
631770
|
const safeName = sanitizeFileName(att.file_name);
|
|
631769
631771
|
const prefix = (att.file_uuid.slice(0, 8) || randomUUID54().slice(0, 8)).replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
631770
631772
|
const dir = uploadsDir();
|
|
631771
|
-
const outPath =
|
|
631773
|
+
const outPath = join183(dir, `${prefix}-${safeName}`);
|
|
631772
631774
|
try {
|
|
631773
631775
|
await mkdir48(dir, { recursive: true });
|
|
631774
631776
|
await writeFile51(outPath, data);
|
|
@@ -631970,7 +631972,7 @@ var init_sessionUrl = __esm({
|
|
|
631970
631972
|
|
|
631971
631973
|
// build-src/src/utils/plugins/zipCacheAdapters.ts
|
|
631972
631974
|
import { readFile as readFile54 } from "fs/promises";
|
|
631973
|
-
import { join as
|
|
631975
|
+
import { join as join184 } from "path";
|
|
631974
631976
|
async function readZipCacheKnownMarketplaces() {
|
|
631975
631977
|
try {
|
|
631976
631978
|
const content = await readFile54(getZipCacheKnownMarketplacesPath(), "utf-8");
|
|
@@ -632001,13 +632003,13 @@ async function saveMarketplaceJsonToZipCache(marketplaceName, installLocation) {
|
|
|
632001
632003
|
const content = await readMarketplaceJsonContent(installLocation);
|
|
632002
632004
|
if (content !== null) {
|
|
632003
632005
|
const relPath = getMarketplaceJsonRelativePath(marketplaceName);
|
|
632004
|
-
await atomicWriteToZipCache(
|
|
632006
|
+
await atomicWriteToZipCache(join184(zipCachePath, relPath), content);
|
|
632005
632007
|
}
|
|
632006
632008
|
}
|
|
632007
632009
|
async function readMarketplaceJsonContent(dir) {
|
|
632008
632010
|
const candidates = [
|
|
632009
|
-
|
|
632010
|
-
|
|
632011
|
+
join184(dir, ".claude-plugin", "marketplace.json"),
|
|
632012
|
+
join184(dir, "marketplace.json"),
|
|
632011
632013
|
dir
|
|
632012
632014
|
// For URL sources, installLocation IS the marketplace JSON file
|
|
632013
632015
|
];
|
|
@@ -632592,9 +632594,9 @@ __export(bridgePointer_exports, {
|
|
|
632592
632594
|
writeBridgePointer: () => writeBridgePointer
|
|
632593
632595
|
});
|
|
632594
632596
|
import { mkdir as mkdir49, readFile as readFile55, stat as stat50, unlink as unlink27, writeFile as writeFile52 } from "fs/promises";
|
|
632595
|
-
import { dirname as dirname80, join as
|
|
632597
|
+
import { dirname as dirname80, join as join185 } from "path";
|
|
632596
632598
|
function getBridgePointerPath(dir) {
|
|
632597
|
-
return
|
|
632599
|
+
return join185(getProjectsDir(), sanitizePath(dir), "bridge-pointer.json");
|
|
632598
632600
|
}
|
|
632599
632601
|
async function writeBridgePointer(dir, pointer) {
|
|
632600
632602
|
const path27 = getBridgePointerPath(dir);
|
|
@@ -639914,7 +639916,7 @@ __export(claudeDesktop_exports, {
|
|
|
639914
639916
|
});
|
|
639915
639917
|
import { readdir as readdir32, readFile as readFile57, stat as stat52 } from "fs/promises";
|
|
639916
639918
|
import { homedir as homedir47 } from "os";
|
|
639917
|
-
import { join as
|
|
639919
|
+
import { join as join186 } from "path";
|
|
639918
639920
|
async function getClaudeDesktopConfigPath() {
|
|
639919
639921
|
const platform4 = getPlatform();
|
|
639920
639922
|
if (!SUPPORTED_PLATFORMS.includes(platform4)) {
|
|
@@ -639923,7 +639925,7 @@ async function getClaudeDesktopConfigPath() {
|
|
|
639923
639925
|
);
|
|
639924
639926
|
}
|
|
639925
639927
|
if (platform4 === "macos") {
|
|
639926
|
-
return
|
|
639928
|
+
return join186(
|
|
639927
639929
|
homedir47(),
|
|
639928
639930
|
"Library",
|
|
639929
639931
|
"Application Support",
|
|
@@ -639949,7 +639951,7 @@ async function getClaudeDesktopConfigPath() {
|
|
|
639949
639951
|
if (user.name === "Public" || user.name === "Default" || user.name === "Default User" || user.name === "All Users") {
|
|
639950
639952
|
continue;
|
|
639951
639953
|
}
|
|
639952
|
-
const potentialConfigPath =
|
|
639954
|
+
const potentialConfigPath = join186(
|
|
639953
639955
|
usersDir,
|
|
639954
639956
|
user.name,
|
|
639955
639957
|
"AppData",
|
|
@@ -640484,7 +640486,7 @@ __export(engineBgProbe_exports, {
|
|
|
640484
640486
|
evaluateBgSwitchGate: () => evaluateBgSwitchGate,
|
|
640485
640487
|
probeEngineActiveBgTasksForCli: () => probeEngineActiveBgTasksForCli
|
|
640486
640488
|
});
|
|
640487
|
-
import { readFileSync as
|
|
640489
|
+
import { readFileSync as readFileSync38 } from "node:fs";
|
|
640488
640490
|
async function drainFleetSnapshot(baseUrl, authToken) {
|
|
640489
640491
|
const { AgentClient: AgentClient6 } = await import("@sema-agent/sdk");
|
|
640490
640492
|
const client4 = new AgentClient6({ baseUrl, authToken, principal: "anon:shell-live" });
|
|
@@ -640543,7 +640545,7 @@ async function probeEngineActiveBgTasksForCli(deps2) {
|
|
|
640543
640545
|
const { getEnginePortFilePath: getEnginePortFilePath2, getEngineTokenFilePath: getEngineTokenFilePath2, isProcessAlive: isProcessAlive2, probeHealth: probeHealth2 } = await Promise.resolve().then(() => (init_engineLifecycleManager(), engineLifecycleManager_exports));
|
|
640544
640546
|
let anchor = null;
|
|
640545
640547
|
try {
|
|
640546
|
-
const parsed = JSON.parse(
|
|
640548
|
+
const parsed = JSON.parse(readFileSync38(getEnginePortFilePath2(), "utf8"));
|
|
640547
640549
|
if (typeof parsed.port === "number" && typeof parsed.pid === "number") anchor = parsed;
|
|
640548
640550
|
} catch {
|
|
640549
640551
|
}
|
|
@@ -640555,7 +640557,7 @@ async function probeEngineActiveBgTasksForCli(deps2) {
|
|
|
640555
640557
|
}
|
|
640556
640558
|
let token = { mode: "loopback-unauthed" };
|
|
640557
640559
|
try {
|
|
640558
|
-
const t2 =
|
|
640560
|
+
const t2 = readFileSync38(getEngineTokenFilePath2(), "utf8").trim();
|
|
640559
640561
|
if (t2) token = t2;
|
|
640560
640562
|
} catch {
|
|
640561
640563
|
}
|
|
@@ -642142,9 +642144,9 @@ __export(tlsTrust_exports, {
|
|
|
642142
642144
|
});
|
|
642143
642145
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
642144
642146
|
import { X509Certificate } from "node:crypto";
|
|
642145
|
-
import { existsSync as existsSync26, mkdirSync as mkdirSync19, readFileSync as
|
|
642147
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync19, readFileSync as readFileSync39, writeFileSync as writeFileSync19 } from "node:fs";
|
|
642146
642148
|
import { homedir as homedir48 } from "node:os";
|
|
642147
|
-
import { join as
|
|
642149
|
+
import { join as join187 } from "node:path";
|
|
642148
642150
|
function isCertError(detail) {
|
|
642149
642151
|
return /UNABLE_TO_GET_ISSUER_CERT|SELF_SIGNED_CERT|UNABLE_TO_VERIFY_LEAF|CERT_UNTRUSTED|DEPTH_ZERO_SELF_SIGNED|CERT_HAS_EXPIRED|ERR_TLS_CERT/i.test(
|
|
642150
642152
|
detail
|
|
@@ -642192,7 +642194,7 @@ async function injectDispatcher(extra) {
|
|
|
642192
642194
|
}
|
|
642193
642195
|
const ca = [...tls.rootCertificates, ...extra];
|
|
642194
642196
|
try {
|
|
642195
|
-
ca.push(
|
|
642197
|
+
ca.push(readFileSync39(process.env.NODE_EXTRA_CA_CERTS, "utf8"));
|
|
642196
642198
|
} catch {
|
|
642197
642199
|
}
|
|
642198
642200
|
const opts = {
|
|
@@ -642210,7 +642212,7 @@ async function injectDispatcher(extra) {
|
|
|
642210
642212
|
async function applyPersistedTlsTrust() {
|
|
642211
642213
|
try {
|
|
642212
642214
|
if (!existsSync26(CA_PATH)) return false;
|
|
642213
|
-
const raw2 =
|
|
642215
|
+
const raw2 = readFileSync39(CA_PATH, "utf8");
|
|
642214
642216
|
if (!raw2.includes("BEGIN CERTIFICATE")) return false;
|
|
642215
642217
|
const kept = filterCaCertificates(raw2);
|
|
642216
642218
|
if (kept.length === 0) return false;
|
|
@@ -642238,7 +642240,7 @@ async function applySystemTlsTrust() {
|
|
|
642238
642240
|
}
|
|
642239
642241
|
const kept = filterCaCertificates(pem);
|
|
642240
642242
|
if (kept.length === 0) return false;
|
|
642241
|
-
mkdirSync19(
|
|
642243
|
+
mkdirSync19(join187(homedir48(), ".sema"), { recursive: true });
|
|
642242
642244
|
writeFileSync19(CA_PATH, kept.join("\n") + "\n");
|
|
642243
642245
|
await injectDispatcher(kept);
|
|
642244
642246
|
return true;
|
|
@@ -642249,7 +642251,7 @@ async function applySystemTlsTrust() {
|
|
|
642249
642251
|
var CA_PATH, builtinRootBodies;
|
|
642250
642252
|
var init_tlsTrust = __esm({
|
|
642251
642253
|
"build-src/src/sema/tlsTrust.ts"() {
|
|
642252
|
-
CA_PATH =
|
|
642254
|
+
CA_PATH = join187(homedir48(), ".sema", "extra-ca.pem");
|
|
642253
642255
|
}
|
|
642254
642256
|
});
|
|
642255
642257
|
|
|
@@ -642260,11 +642262,11 @@ __export(printModeEngine_exports, {
|
|
|
642260
642262
|
ensurePrintModeEngine: () => ensurePrintModeEngine,
|
|
642261
642263
|
reclaimOneShotEngine: () => reclaimOneShotEngine
|
|
642262
642264
|
});
|
|
642263
|
-
import { readFileSync as
|
|
642264
|
-
import { join as
|
|
642265
|
+
import { readFileSync as readFileSync40, unlinkSync as unlinkSync8 } from "node:fs";
|
|
642266
|
+
import { join as join188 } from "node:path";
|
|
642265
642267
|
function seedUserSettingsEnv() {
|
|
642266
642268
|
try {
|
|
642267
|
-
const raw2 =
|
|
642269
|
+
const raw2 = readFileSync40(join188(getClaudeConfigHomeDir(), "settings.json"), "utf8");
|
|
642268
642270
|
const sj = JSON.parse(raw2);
|
|
642269
642271
|
if (sj?.env && typeof sj.env === "object") {
|
|
642270
642272
|
for (const [k2, v2] of Object.entries(sj.env)) {
|
|
@@ -642381,7 +642383,7 @@ function reclaimOneShotEngine(pid, api2, label = "one-shot") {
|
|
|
642381
642383
|
}
|
|
642382
642384
|
try {
|
|
642383
642385
|
const portPath = api2.getEnginePortFilePath();
|
|
642384
|
-
const cur = JSON.parse(
|
|
642386
|
+
const cur = JSON.parse(readFileSync40(portPath, "utf8"));
|
|
642385
642387
|
if (cur && cur.pid === pid) {
|
|
642386
642388
|
unlinkSync8(portPath);
|
|
642387
642389
|
try {
|
|
@@ -642544,8 +642546,8 @@ __export(cloudSessions_exports, {
|
|
|
642544
642546
|
cloudSessionPush: () => cloudSessionPush,
|
|
642545
642547
|
cloudSyncCommand: () => cloudSyncCommand
|
|
642546
642548
|
});
|
|
642547
|
-
import { existsSync as existsSync27, mkdirSync as mkdirSync20, readFileSync as
|
|
642548
|
-
import { join as
|
|
642549
|
+
import { existsSync as existsSync27, mkdirSync as mkdirSync20, readFileSync as readFileSync41, writeFileSync as writeFileSync20, copyFileSync as copyFileSync5 } from "node:fs";
|
|
642550
|
+
import { join as join189 } from "node:path";
|
|
642549
642551
|
import { realpathSync as realpathSync10 } from "node:fs";
|
|
642550
642552
|
function fail3(e) {
|
|
642551
642553
|
err5(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -642559,7 +642561,7 @@ function canonicalCwd2() {
|
|
|
642559
642561
|
}
|
|
642560
642562
|
}
|
|
642561
642563
|
function projectDir() {
|
|
642562
|
-
return
|
|
642564
|
+
return join189(getProjectsDir(), sanitizePath(canonicalCwd2()));
|
|
642563
642565
|
}
|
|
642564
642566
|
async function refuseIfTurnInflight2() {
|
|
642565
642567
|
const { activeTurnInflight: activeTurnInflight2 } = await Promise.resolve().then(() => (init_turnInflightMarker(), turnInflightMarker_exports));
|
|
@@ -642668,7 +642670,7 @@ async function engineIdForShellSession(shellSessionId) {
|
|
|
642668
642670
|
try {
|
|
642669
642671
|
const { SessionIdMapping: SessionIdMapping2 } = await Promise.resolve().then(() => (init_sessionIdMapping(), sessionIdMapping_exports));
|
|
642670
642672
|
const map2 = new SessionIdMapping2();
|
|
642671
|
-
map2.setPath(
|
|
642673
|
+
map2.setPath(join189(projectDir(), `${shellSessionId}.session-map.json`));
|
|
642672
642674
|
const rec = map2.read();
|
|
642673
642675
|
const engineId = rec?.engines?.local?.engineSessionId ?? rec?.engineSessionId;
|
|
642674
642676
|
return typeof engineId === "string" && engineId.length > 0 ? engineId : null;
|
|
@@ -642694,7 +642696,7 @@ async function recordSyncWatermark(shellSessionId, engineSessionId, peer, leafId
|
|
|
642694
642696
|
try {
|
|
642695
642697
|
const { SessionIdMapping: SessionIdMapping2, engineNamespaceKeyFor: engineNamespaceKeyFor2 } = await Promise.resolve().then(() => (init_sessionIdMapping(), sessionIdMapping_exports));
|
|
642696
642698
|
const map2 = new SessionIdMapping2();
|
|
642697
|
-
map2.setPath(
|
|
642699
|
+
map2.setPath(join189(projectDir(), `${shellSessionId}.session-map.json`));
|
|
642698
642700
|
map2.persistEngineEntry(
|
|
642699
642701
|
engineNamespaceKeyFor2(peer.baseUrl),
|
|
642700
642702
|
{
|
|
@@ -642731,7 +642733,7 @@ async function cloudSessionPush(sessionIdArg, opts = {}) {
|
|
|
642731
642733
|
const shellId = await resolveSessionId(sessionIdArg);
|
|
642732
642734
|
const engineId = await engineIdForShellSession(shellId);
|
|
642733
642735
|
if (!engineId) {
|
|
642734
|
-
const marker =
|
|
642736
|
+
const marker = join189(projectDir(), `${shellId}.import-seed.json`);
|
|
642735
642737
|
err5(`Error: no engine-side record for session ${shellId} \u2014 there is nothing to push.`);
|
|
642736
642738
|
if (existsSync27(marker)) {
|
|
642737
642739
|
err5(" This session was imported from Sema and has not run a turn here yet.");
|
|
@@ -642832,7 +642834,7 @@ async function cloudSessionPull(sessionIdArg, opts = {}) {
|
|
|
642832
642834
|
const { syncEntriesToTranscriptLines: syncEntriesToTranscriptLines2, selectEntriesByIds: selectEntriesByIds2, lastLineUuid: lastLineUuid2 } = await Promise.resolve().then(() => (init_sessionSyncTranscript(), sessionSyncTranscript_exports));
|
|
642833
642835
|
const destDir = projectDir();
|
|
642834
642836
|
mkdirSync20(destDir, { recursive: true });
|
|
642835
|
-
const jsonlPath =
|
|
642837
|
+
const jsonlPath = join189(destDir, `${id}.jsonl`);
|
|
642836
642838
|
const cwd5 = canonicalCwd2();
|
|
642837
642839
|
const version4 = "0.0.0-sync";
|
|
642838
642840
|
let appended = 0;
|
|
@@ -642845,7 +642847,7 @@ async function cloudSessionPull(sessionIdArg, opts = {}) {
|
|
|
642845
642847
|
} else {
|
|
642846
642848
|
const plan2 = engineHalf?.plan;
|
|
642847
642849
|
if (plan2 && plan2.relation === "fast_forward") {
|
|
642848
|
-
const body =
|
|
642850
|
+
const body = readFileSync41(jsonlPath, "utf8");
|
|
642849
642851
|
const known = /* @__PURE__ */ new Set();
|
|
642850
642852
|
for (const line of body.split("\n")) {
|
|
642851
642853
|
try {
|
|
@@ -642988,7 +642990,7 @@ async function cloudSyncCommand(action2, opts = {}) {
|
|
|
642988
642990
|
}
|
|
642989
642991
|
const { SessionIdMapping: SessionIdMapping2 } = await Promise.resolve().then(() => (init_sessionIdMapping(), sessionIdMapping_exports));
|
|
642990
642992
|
const map2 = new SessionIdMapping2();
|
|
642991
|
-
map2.setPath(
|
|
642993
|
+
map2.setPath(join189(projectDir(), `${id}.session-map.json`));
|
|
642992
642994
|
if (action2 === "status") {
|
|
642993
642995
|
await printSyncStatus(id, map2.read());
|
|
642994
642996
|
return;
|
|
@@ -643006,7 +643008,7 @@ async function cloudSyncCommand(action2, opts = {}) {
|
|
|
643006
643008
|
if (shellId) {
|
|
643007
643009
|
const { SessionIdMapping: SessionIdMapping2 } = await Promise.resolve().then(() => (init_sessionIdMapping(), sessionIdMapping_exports));
|
|
643008
643010
|
const map2 = new SessionIdMapping2();
|
|
643009
|
-
map2.setPath(
|
|
643011
|
+
map2.setPath(join189(projectDir(), `${shellId}.session-map.json`));
|
|
643010
643012
|
rec = map2.read();
|
|
643011
643013
|
}
|
|
643012
643014
|
await printSyncStatus(shellId, rec);
|
|
@@ -643140,8 +643142,8 @@ __export(cloudResources_exports, {
|
|
|
643140
643142
|
cloudResourceSync: () => cloudResourceSync
|
|
643141
643143
|
});
|
|
643142
643144
|
import { createHash as createHash26 } from "node:crypto";
|
|
643143
|
-
import { existsSync as existsSync28, readdirSync as readdirSync11, readFileSync as
|
|
643144
|
-
import { basename as basename66, dirname as dirname82, isAbsolute as isAbsolute33, join as
|
|
643145
|
+
import { existsSync as existsSync28, readdirSync as readdirSync11, readFileSync as readFileSync42, statSync as statSync13 } from "node:fs";
|
|
643146
|
+
import { basename as basename66, dirname as dirname82, isAbsolute as isAbsolute33, join as join190, resolve as resolve47 } from "node:path";
|
|
643145
643147
|
function fail4(e) {
|
|
643146
643148
|
err6(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
643147
643149
|
process.exit(1);
|
|
@@ -643512,10 +643514,10 @@ function stableStringify(v2) {
|
|
|
643512
643514
|
}
|
|
643513
643515
|
async function readLocalModels() {
|
|
643514
643516
|
const { getClaudeConfigHomeDir: getClaudeConfigHomeDir3 } = await Promise.resolve().then(() => (init_envUtils(), envUtils_exports));
|
|
643515
|
-
const path27 =
|
|
643517
|
+
const path27 = join190(getClaudeConfigHomeDir3(), "config.d", "models.json");
|
|
643516
643518
|
try {
|
|
643517
643519
|
const { normalizeModelsDocShape: normalizeModelsDocShape2 } = await Promise.resolve().then(() => (init_modelsDocShape(), modelsDocShape_exports));
|
|
643518
|
-
const doc = normalizeModelsDocShape2(JSON.parse(
|
|
643520
|
+
const doc = normalizeModelsDocShape2(JSON.parse(readFileSync42(path27, "utf-8")))?.doc ?? {};
|
|
643519
643521
|
const models = asArr3(doc.models).map(asRec3).filter((m2) => !!m2);
|
|
643520
643522
|
if (models.length > 0) return models;
|
|
643521
643523
|
} catch {
|
|
@@ -643580,7 +643582,7 @@ async function loadLocalModelEntries() {
|
|
|
643580
643582
|
async function readLocalModelRoles() {
|
|
643581
643583
|
try {
|
|
643582
643584
|
const { getClaudeConfigHomeDir: getClaudeConfigHomeDir3 } = await Promise.resolve().then(() => (init_envUtils(), envUtils_exports));
|
|
643583
|
-
const doc = JSON.parse(
|
|
643585
|
+
const doc = JSON.parse(readFileSync42(join190(getClaudeConfigHomeDir3(), "config.d", "models.json"), "utf-8"));
|
|
643584
643586
|
return asRec3(doc.roles);
|
|
643585
643587
|
} catch {
|
|
643586
643588
|
return void 0;
|
|
@@ -643668,7 +643670,7 @@ async function loadLocalMcpEntries() {
|
|
|
643668
643670
|
function readMcpFromFile(path27) {
|
|
643669
643671
|
let doc;
|
|
643670
643672
|
try {
|
|
643671
|
-
doc = JSON.parse(
|
|
643673
|
+
doc = JSON.parse(readFileSync42(resolve47(path27), "utf-8"));
|
|
643672
643674
|
} catch (e) {
|
|
643673
643675
|
return { error: `cannot read/parse ${path27}: ${e instanceof Error ? e.message : String(e)}` };
|
|
643674
643676
|
}
|
|
@@ -643693,13 +643695,13 @@ function readMcpFromFile(path27) {
|
|
|
643693
643695
|
async function skillRoots() {
|
|
643694
643696
|
const { getClaudeConfigHomeDir: getClaudeConfigHomeDir3 } = await Promise.resolve().then(() => (init_envUtils(), envUtils_exports));
|
|
643695
643697
|
const { getProjectDirsUpToHome: getProjectDirsUpToHome2 } = await Promise.resolve().then(() => (init_markdownConfigLoader(), markdownConfigLoader_exports));
|
|
643696
|
-
return [...getProjectDirsUpToHome2("skills", process.cwd()),
|
|
643698
|
+
return [...getProjectDirsUpToHome2("skills", process.cwd()), join190(getClaudeConfigHomeDir3(), "skills")];
|
|
643697
643699
|
}
|
|
643698
643700
|
async function resolveSkillFile(target) {
|
|
643699
643701
|
const tryFile = (p) => {
|
|
643700
643702
|
try {
|
|
643701
643703
|
if (!existsSync28(p)) return null;
|
|
643702
|
-
return statSync13(p).isDirectory() ? existsSync28(
|
|
643704
|
+
return statSync13(p).isDirectory() ? existsSync28(join190(p, "SKILL.md")) ? join190(p, "SKILL.md") : null : p;
|
|
643703
643705
|
} catch {
|
|
643704
643706
|
return null;
|
|
643705
643707
|
}
|
|
@@ -643712,7 +643714,7 @@ async function resolveSkillFile(target) {
|
|
|
643712
643714
|
}
|
|
643713
643715
|
const roots = await skillRoots();
|
|
643714
643716
|
for (const root2 of roots) {
|
|
643715
|
-
const f = tryFile(
|
|
643717
|
+
const f = tryFile(join190(root2, target));
|
|
643716
643718
|
if (f) return { file: f, fallbackName: target };
|
|
643717
643719
|
}
|
|
643718
643720
|
return { error: `no skill named '${target}' in the project or user skills directories (${roots.join(", ") || "none found"}) \u2014 pass a path to install from elsewhere` };
|
|
@@ -643720,7 +643722,7 @@ async function resolveSkillFile(target) {
|
|
|
643720
643722
|
async function readSkillEntry(file2, fallbackName) {
|
|
643721
643723
|
let raw2;
|
|
643722
643724
|
try {
|
|
643723
|
-
raw2 =
|
|
643725
|
+
raw2 = readFileSync42(file2, "utf-8");
|
|
643724
643726
|
} catch (e) {
|
|
643725
643727
|
return { name: fallbackName, display: fallbackName, entry: null, notes: [], skipReason: `cannot read ${file2}: ${e instanceof Error ? e.message : String(e)}` };
|
|
643726
643728
|
}
|
|
@@ -643753,7 +643755,7 @@ async function loadLocalSkillEntries() {
|
|
|
643753
643755
|
try {
|
|
643754
643756
|
dirs = readdirSync11(root2).filter((d4) => {
|
|
643755
643757
|
try {
|
|
643756
|
-
return statSync13(
|
|
643758
|
+
return statSync13(join190(root2, d4)).isDirectory() && existsSync28(join190(root2, d4, "SKILL.md"));
|
|
643757
643759
|
} catch {
|
|
643758
643760
|
return false;
|
|
643759
643761
|
}
|
|
@@ -643762,7 +643764,7 @@ async function loadLocalSkillEntries() {
|
|
|
643762
643764
|
continue;
|
|
643763
643765
|
}
|
|
643764
643766
|
for (const d4 of dirs) {
|
|
643765
|
-
const e = await readSkillEntry(
|
|
643767
|
+
const e = await readSkillEntry(join190(root2, d4, "SKILL.md"), d4);
|
|
643766
643768
|
if (!byName2.has(e.name)) byName2.set(e.name, e);
|
|
643767
643769
|
}
|
|
643768
643770
|
}
|
|
@@ -644495,7 +644497,7 @@ import { execFileSync as execFileSync6, spawn as spawn14 } from "child_process";
|
|
|
644495
644497
|
import { existsSync as existsSync29, statSync as statSync14 } from "fs";
|
|
644496
644498
|
import { createRequire as createRequire4 } from "module";
|
|
644497
644499
|
import { createInterface as createInterface3 } from "readline";
|
|
644498
|
-
import { dirname as dirname83, join as
|
|
644500
|
+
import { dirname as dirname83, join as join191, resolve as resolve48 } from "path";
|
|
644499
644501
|
function fail5(e) {
|
|
644500
644502
|
err7(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
644501
644503
|
process.exit(1);
|
|
@@ -644513,15 +644515,15 @@ function npmEngineLocalCandidates() {
|
|
|
644513
644515
|
const candidates = [];
|
|
644514
644516
|
for (const pkg of ENGINE_NPM_PACKAGES) {
|
|
644515
644517
|
try {
|
|
644516
|
-
const req = createRequire4(
|
|
644517
|
-
candidates.push(
|
|
644518
|
+
const req = createRequire4(join191(process.cwd(), "__sema_resolve__.js"));
|
|
644519
|
+
candidates.push(join191(dirname83(req.resolve(`${pkg}/package.json`)), ENGINE_REL_PATH));
|
|
644518
644520
|
} catch {
|
|
644519
644521
|
}
|
|
644520
644522
|
}
|
|
644521
644523
|
let dir = process.cwd();
|
|
644522
644524
|
for (; ; ) {
|
|
644523
644525
|
for (const pkg of ENGINE_NPM_PACKAGES) {
|
|
644524
|
-
candidates.push(
|
|
644526
|
+
candidates.push(join191(dir, "node_modules", pkg, ENGINE_REL_PATH));
|
|
644525
644527
|
}
|
|
644526
644528
|
const parent2 = dirname83(dir);
|
|
644527
644529
|
if (parent2 === dir) break;
|
|
@@ -644532,7 +644534,7 @@ function npmEngineLocalCandidates() {
|
|
|
644532
644534
|
function npmEngineGlobalCandidates() {
|
|
644533
644535
|
try {
|
|
644534
644536
|
const globalRoot = execFileSync6("npm", ["root", "-g"], { encoding: "utf8", timeout: 1e4 }).trim();
|
|
644535
|
-
return globalRoot ? ENGINE_NPM_PACKAGES.map((pkg) =>
|
|
644537
|
+
return globalRoot ? ENGINE_NPM_PACKAGES.map((pkg) => join191(globalRoot, pkg, ENGINE_REL_PATH)) : [];
|
|
644536
644538
|
} catch {
|
|
644537
644539
|
return [];
|
|
644538
644540
|
}
|
|
@@ -644542,9 +644544,9 @@ function resolveEnginePath(engineFlag) {
|
|
|
644542
644544
|
for (const base of [engineFlag, process.env.SEMA_UP_ENGINE]) {
|
|
644543
644545
|
if (!base) continue;
|
|
644544
644546
|
const abs = resolve48(base);
|
|
644545
|
-
explicit.push(abs,
|
|
644547
|
+
explicit.push(abs, join191(abs, "sema-up.sh"));
|
|
644546
644548
|
}
|
|
644547
|
-
return firstExistingFile(explicit) ?? firstExistingFile(npmEngineLocalCandidates()) ?? firstExistingFile(npmEngineGlobalCandidates()) ?? firstExistingFile([
|
|
644549
|
+
return firstExistingFile(explicit) ?? firstExistingFile(npmEngineLocalCandidates()) ?? firstExistingFile(npmEngineGlobalCandidates()) ?? firstExistingFile([join191(process.cwd(), "deploy", "sema-up", "sema-up.sh")]);
|
|
644548
644550
|
}
|
|
644549
644551
|
async function promptQuestion(reader, q2) {
|
|
644550
644552
|
out5("");
|
|
@@ -644814,7 +644816,7 @@ var init_cloudOps = __esm({
|
|
|
644814
644816
|
err7 = (line) => process.stderr.write(`${line}
|
|
644815
644817
|
`);
|
|
644816
644818
|
ENGINE_NPM_PACKAGES = ["@sema-agent/server", "@sema-ai/server"];
|
|
644817
|
-
ENGINE_REL_PATH =
|
|
644819
|
+
ENGINE_REL_PATH = join191("deploy", "sema-up", "sema-up.sh");
|
|
644818
644820
|
AnswerReader = class {
|
|
644819
644821
|
queue = [];
|
|
644820
644822
|
waiter;
|
|
@@ -646640,7 +646642,7 @@ var Doctor_exports = {};
|
|
|
646640
646642
|
__export(Doctor_exports, {
|
|
646641
646643
|
Doctor: () => Doctor
|
|
646642
646644
|
});
|
|
646643
|
-
import { join as
|
|
646645
|
+
import { join as join192 } from "path";
|
|
646644
646646
|
function Doctor(t0) {
|
|
646645
646647
|
const $3 = (0, import_compiler_runtime346.c)(84);
|
|
646646
646648
|
const {
|
|
@@ -646710,8 +646712,8 @@ function Doctor(t0) {
|
|
|
646710
646712
|
t5 = () => {
|
|
646711
646713
|
getDoctorDiagnostic().then(setDiagnostic);
|
|
646712
646714
|
(async () => {
|
|
646713
|
-
const userAgentsDir =
|
|
646714
|
-
const projectAgentsDir =
|
|
646715
|
+
const userAgentsDir = join192(getClaudeConfigHomeDir(), "agents");
|
|
646716
|
+
const projectAgentsDir = join192(getOriginalCwd(), ".sema", "agents");
|
|
646715
646717
|
const {
|
|
646716
646718
|
activeAgents,
|
|
646717
646719
|
allAgents,
|
|
@@ -646734,7 +646736,7 @@ function Doctor(t0) {
|
|
|
646734
646736
|
}, async () => toolPermissionContext);
|
|
646735
646737
|
setContextWarnings(warnings);
|
|
646736
646738
|
if (isPidBasedLockingEnabled()) {
|
|
646737
|
-
const locksDir =
|
|
646739
|
+
const locksDir = join192(getXDGStateHome(), "claude", "locks");
|
|
646738
646740
|
const staleLocksCleaned = cleanupStaleLocks(locksDir);
|
|
646739
646741
|
const locks = getAllLockInfo(locksDir);
|
|
646740
646742
|
setVersionLockInfo({
|
|
@@ -648569,17 +648571,17 @@ import {
|
|
|
648569
648571
|
existsSync as existsSync30,
|
|
648570
648572
|
mkdirSync as mkdirSync21,
|
|
648571
648573
|
readdirSync as readdirSync12,
|
|
648572
|
-
readFileSync as
|
|
648574
|
+
readFileSync as readFileSync43,
|
|
648573
648575
|
statSync as statSync15
|
|
648574
648576
|
} from "node:fs";
|
|
648575
|
-
import { dirname as dirname85, join as
|
|
648577
|
+
import { dirname as dirname85, join as join193, relative as relative36 } from "node:path";
|
|
648576
648578
|
function display(p) {
|
|
648577
648579
|
const home = homedir50();
|
|
648578
648580
|
return p.startsWith(home) ? "~" + p.slice(home.length) : p;
|
|
648579
648581
|
}
|
|
648580
648582
|
function filesEqual(a, b3) {
|
|
648581
648583
|
try {
|
|
648582
|
-
return
|
|
648584
|
+
return readFileSync43(a).equals(readFileSync43(b3));
|
|
648583
648585
|
} catch {
|
|
648584
648586
|
return false;
|
|
648585
648587
|
}
|
|
@@ -648652,7 +648654,7 @@ function syncPlainFile(src, dest, label, opts, report) {
|
|
|
648652
648654
|
}
|
|
648653
648655
|
function syncJsonFile(src, dest, label, opts, report) {
|
|
648654
648656
|
if (!existsSync30(src)) return;
|
|
648655
|
-
const srcText =
|
|
648657
|
+
const srcText = readFileSync43(src, "utf-8");
|
|
648656
648658
|
if (!existsSync30(dest)) {
|
|
648657
648659
|
if (!opts.dryRun) {
|
|
648658
648660
|
ensureDir2(dest);
|
|
@@ -648661,7 +648663,7 @@ function syncJsonFile(src, dest, label, opts, report) {
|
|
|
648661
648663
|
recordAction(report, { action: "copy", label });
|
|
648662
648664
|
return;
|
|
648663
648665
|
}
|
|
648664
|
-
const destText =
|
|
648666
|
+
const destText = readFileSync43(dest, "utf-8");
|
|
648665
648667
|
if (Buffer.from(srcText).equals(Buffer.from(destText))) {
|
|
648666
648668
|
recordAction(report, { action: "same", label });
|
|
648667
648669
|
return;
|
|
@@ -648716,8 +648718,8 @@ function syncTree(srcDir, destDir, labelBase, opts, report) {
|
|
|
648716
648718
|
return;
|
|
648717
648719
|
}
|
|
648718
648720
|
for (const name of readdirSync12(srcDir)) {
|
|
648719
|
-
const srcChild =
|
|
648720
|
-
const destChild =
|
|
648721
|
+
const srcChild = join193(srcDir, name);
|
|
648722
|
+
const destChild = join193(destDir, name);
|
|
648721
648723
|
let childStat;
|
|
648722
648724
|
try {
|
|
648723
648725
|
childStat = statSync15(srcChild);
|
|
@@ -648756,12 +648758,12 @@ function syncRoot(srcRoot, destRoot, manifest, scopeLabel, opts, report) {
|
|
|
648756
648758
|
return;
|
|
648757
648759
|
}
|
|
648758
648760
|
for (const dir of manifest.dirs) {
|
|
648759
|
-
syncTree(
|
|
648761
|
+
syncTree(join193(srcRoot, dir), join193(destRoot, dir), dir, opts, report);
|
|
648760
648762
|
}
|
|
648761
648763
|
for (const file2 of manifest.plainFiles) {
|
|
648762
648764
|
syncPlainFile(
|
|
648763
|
-
|
|
648764
|
-
|
|
648765
|
+
join193(srcRoot, file2),
|
|
648766
|
+
join193(destRoot, file2),
|
|
648765
648767
|
file2,
|
|
648766
648768
|
opts,
|
|
648767
648769
|
report
|
|
@@ -648769,8 +648771,8 @@ function syncRoot(srcRoot, destRoot, manifest, scopeLabel, opts, report) {
|
|
|
648769
648771
|
}
|
|
648770
648772
|
for (const file2 of manifest.jsonFiles) {
|
|
648771
648773
|
syncJsonFile(
|
|
648772
|
-
|
|
648773
|
-
|
|
648774
|
+
join193(srcRoot, file2),
|
|
648775
|
+
join193(destRoot, file2),
|
|
648774
648776
|
file2,
|
|
648775
648777
|
opts,
|
|
648776
648778
|
report
|
|
@@ -648804,7 +648806,7 @@ async function configSyncHandler(opts) {
|
|
|
648804
648806
|
const dryTag = opts.dryRun ? source_default.yellow(" [dry-run]") : "";
|
|
648805
648807
|
process.stdout.write(source_default.bold(`sema config sync${dryTag}
|
|
648806
648808
|
`));
|
|
648807
|
-
const userSrc =
|
|
648809
|
+
const userSrc = join193(homedir50(), LEGACY_DIR3);
|
|
648808
648810
|
const userDest = getClaudeConfigHomeDir();
|
|
648809
648811
|
process.stdout.write(
|
|
648810
648812
|
source_default.bold(`
|
|
@@ -648824,15 +648826,15 @@ user: ${display(userSrc)} \u2192 ${display(userDest)}
|
|
|
648824
648826
|
opts,
|
|
648825
648827
|
report
|
|
648826
648828
|
);
|
|
648827
|
-
const globalSrc =
|
|
648829
|
+
const globalSrc = join193(homedir50(), LEGACY_GLOBAL_FILE);
|
|
648828
648830
|
const globalDest = getGlobalClaudeFile();
|
|
648829
648831
|
if (existsSync30(globalSrc) && globalSrc !== globalDest) {
|
|
648830
648832
|
syncJsonFile(globalSrc, globalDest, display(globalDest), opts, report);
|
|
648831
648833
|
}
|
|
648832
648834
|
flushEntries(report, userStart, opts);
|
|
648833
648835
|
if (opts.project) {
|
|
648834
|
-
const projSrc =
|
|
648835
|
-
const projDest =
|
|
648836
|
+
const projSrc = join193(process.cwd(), LEGACY_DIR3);
|
|
648837
|
+
const projDest = join193(process.cwd(), ".sema");
|
|
648836
648838
|
process.stdout.write(
|
|
648837
648839
|
source_default.bold(
|
|
648838
648840
|
`
|
|
@@ -648938,9 +648940,9 @@ __export(importCredentials_exports, {
|
|
|
648938
648940
|
importCredentialsHandler: () => importCredentialsHandler
|
|
648939
648941
|
});
|
|
648940
648942
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
648941
|
-
import { readFileSync as
|
|
648943
|
+
import { readFileSync as readFileSync44 } from "node:fs";
|
|
648942
648944
|
import { homedir as homedir51, userInfo as userInfo4 } from "node:os";
|
|
648943
|
-
import { join as
|
|
648945
|
+
import { join as join194 } from "node:path";
|
|
648944
648946
|
function readCcKeychain() {
|
|
648945
648947
|
if (process.platform !== "darwin") return null;
|
|
648946
648948
|
try {
|
|
@@ -648956,13 +648958,13 @@ function readCcKeychain() {
|
|
|
648956
648958
|
}
|
|
648957
648959
|
function readCcFile(ccRoot) {
|
|
648958
648960
|
try {
|
|
648959
|
-
return JSON.parse(
|
|
648961
|
+
return JSON.parse(readFileSync44(join194(ccRoot, ".credentials.json"), "utf-8"));
|
|
648960
648962
|
} catch {
|
|
648961
648963
|
return null;
|
|
648962
648964
|
}
|
|
648963
648965
|
}
|
|
648964
648966
|
async function importCredentialsHandler(opts) {
|
|
648965
|
-
const ccRoot = opts.from ??
|
|
648967
|
+
const ccRoot = opts.from ?? join194(homedir51(), LEGACY_DIR4);
|
|
648966
648968
|
const fromKeychain = readCcKeychain();
|
|
648967
648969
|
const fromFile = readCcFile(ccRoot);
|
|
648968
648970
|
if (!fromKeychain && !fromFile) {
|
|
@@ -649038,9 +649040,9 @@ var init_importCredentials = __esm({
|
|
|
649038
649040
|
});
|
|
649039
649041
|
|
|
649040
649042
|
// build-src/src/sema/config/mcpChannels.ts
|
|
649041
|
-
import { readFileSync as
|
|
649043
|
+
import { readFileSync as readFileSync45 } from "node:fs";
|
|
649042
649044
|
import { homedir as homedir52 } from "node:os";
|
|
649043
|
-
import { join as
|
|
649045
|
+
import { join as join195 } from "node:path";
|
|
649044
649046
|
function mcpTransportOf(config4) {
|
|
649045
649047
|
const c2 = config4;
|
|
649046
649048
|
if (c2?.type) return c2.type;
|
|
@@ -649070,7 +649072,7 @@ function userScopeMcpNames() {
|
|
|
649070
649072
|
}
|
|
649071
649073
|
function readJsoncSafe(path27) {
|
|
649072
649074
|
try {
|
|
649073
|
-
const raw2 = parse5(
|
|
649075
|
+
const raw2 = parse5(readFileSync45(path27, "utf-8"), [], { allowTrailingComma: true });
|
|
649074
649076
|
return raw2 && typeof raw2 === "object" ? raw2 : null;
|
|
649075
649077
|
} catch {
|
|
649076
649078
|
return null;
|
|
@@ -649094,14 +649096,14 @@ function externalEntryToConfig(e) {
|
|
|
649094
649096
|
}
|
|
649095
649097
|
function detectMcpChannels() {
|
|
649096
649098
|
const out6 = [];
|
|
649097
|
-
const ccRoot = process.env.SEMA_CC_ROOT ||
|
|
649099
|
+
const ccRoot = process.env.SEMA_CC_ROOT || join195(homedir52(), CC_DIR4);
|
|
649098
649100
|
const merged = {};
|
|
649099
|
-
const settings2 = readJsoncSafe(
|
|
649101
|
+
const settings2 = readJsoncSafe(join195(ccRoot, "settings.json"));
|
|
649100
649102
|
const settingsServers = settings2?.mcpServers;
|
|
649101
649103
|
if (settingsServers && typeof settingsServers === "object") {
|
|
649102
649104
|
Object.assign(merged, settingsServers);
|
|
649103
649105
|
}
|
|
649104
|
-
const globalDoc = readJsoncSafe(
|
|
649106
|
+
const globalDoc = readJsoncSafe(join195(homedir52(), CC_GLOBAL_FILE2));
|
|
649105
649107
|
const globalServers = globalDoc?.mcpServers;
|
|
649106
649108
|
if (globalServers && typeof globalServers === "object") {
|
|
649107
649109
|
Object.assign(merged, globalServers);
|
|
@@ -649536,17 +649538,17 @@ var init_navStack = __esm({
|
|
|
649536
649538
|
});
|
|
649537
649539
|
|
|
649538
649540
|
// build-src/src/sema/config/skillsChannels.ts
|
|
649539
|
-
import { existsSync as existsSync31, mkdirSync as mkdirSync22, readdirSync as readdirSync13, readFileSync as
|
|
649540
|
-
import { basename as basename68, dirname as dirname86, join as
|
|
649541
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync22, readdirSync as readdirSync13, readFileSync as readFileSync46, realpathSync as realpathSync11, renameSync as renameSync9, statSync as statSync16 } from "node:fs";
|
|
649542
|
+
import { basename as basename68, dirname as dirname86, join as join196 } from "node:path";
|
|
649541
649543
|
function skillsDirFor(source) {
|
|
649542
|
-
return source === "user" ?
|
|
649544
|
+
return source === "user" ? join196(getClaudeConfigHomeDir(), "skills") : join196(getCwd(), ".sema", "skills");
|
|
649543
649545
|
}
|
|
649544
649546
|
function readSkillMeta(mdPath, name) {
|
|
649545
649547
|
let description;
|
|
649546
649548
|
let whenToUse;
|
|
649547
649549
|
let mtimeMs;
|
|
649548
649550
|
try {
|
|
649549
|
-
const { frontmatter: frontmatter2 } = parseFrontmatter(
|
|
649551
|
+
const { frontmatter: frontmatter2 } = parseFrontmatter(readFileSync46(mdPath, "utf-8"));
|
|
649550
649552
|
if (typeof frontmatter2.description === "string") description = frontmatter2.description;
|
|
649551
649553
|
if (typeof frontmatter2.when_to_use === "string") whenToUse = frontmatter2.when_to_use;
|
|
649552
649554
|
} catch {
|
|
@@ -649598,10 +649600,10 @@ function listInstalledSkills() {
|
|
|
649598
649600
|
continue;
|
|
649599
649601
|
}
|
|
649600
649602
|
for (const entry of entries.sort()) {
|
|
649601
|
-
const p =
|
|
649603
|
+
const p = join196(dir, entry);
|
|
649602
649604
|
try {
|
|
649603
649605
|
if (statSync16(p).isDirectory()) {
|
|
649604
|
-
const md3 =
|
|
649606
|
+
const md3 = join196(p, "SKILL.md");
|
|
649605
649607
|
out6.push({ name: entry, source, root: p, ...readSkillMeta(md3, entry) });
|
|
649606
649608
|
} else if (entry.endsWith(".md")) {
|
|
649607
649609
|
const name = entry.replace(/\.md$/, "");
|
|
@@ -649617,12 +649619,12 @@ function listInstalledSkills() {
|
|
|
649617
649619
|
function removeSkillWithBackup(skill) {
|
|
649618
649620
|
try {
|
|
649619
649621
|
const skillsDir = dirname86(skill.root);
|
|
649620
|
-
const removedDir =
|
|
649622
|
+
const removedDir = join196(
|
|
649621
649623
|
dirname86(skillsDir),
|
|
649622
649624
|
`skills-removed-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}`
|
|
649623
649625
|
);
|
|
649624
649626
|
mkdirSync22(removedDir, { recursive: true });
|
|
649625
|
-
let target =
|
|
649627
|
+
let target = join196(removedDir, basename68(skill.root));
|
|
649626
649628
|
if (existsSync31(target)) target = `${target}-${Date.now()}`;
|
|
649627
649629
|
renameSync9(skill.root, target);
|
|
649628
649630
|
const nameStillPresent = listInstalledSkills().some((s) => s.name === skill.name);
|
|
@@ -649695,12 +649697,12 @@ var init_skillsChannels = __esm({
|
|
|
649695
649697
|
});
|
|
649696
649698
|
|
|
649697
649699
|
// build-src/src/sema/config/EngineScreen.tsx
|
|
649698
|
-
import { readFileSync as
|
|
649699
|
-
import { join as
|
|
649700
|
+
import { readFileSync as readFileSync47 } from "node:fs";
|
|
649701
|
+
import { join as join197 } from "node:path";
|
|
649700
649702
|
function settingsEnv3() {
|
|
649701
649703
|
try {
|
|
649702
649704
|
const sj = JSON.parse(
|
|
649703
|
-
|
|
649705
|
+
readFileSync47(join197(getClaudeConfigHomeDir(), "settings.json"), "utf8")
|
|
649704
649706
|
);
|
|
649705
649707
|
const out6 = {};
|
|
649706
649708
|
if (sj?.env) {
|
|
@@ -650482,9 +650484,9 @@ var init_SkillsHub = __esm({
|
|
|
650482
650484
|
});
|
|
650483
650485
|
|
|
650484
650486
|
// build-src/src/sema/config/PluginsHub.tsx
|
|
650485
|
-
import { readFileSync as
|
|
650487
|
+
import { readFileSync as readFileSync48 } from "node:fs";
|
|
650486
650488
|
import { homedir as homedir53 } from "node:os";
|
|
650487
|
-
import { join as
|
|
650489
|
+
import { join as join198 } from "node:path";
|
|
650488
650490
|
function listInstalledPluginRows() {
|
|
650489
650491
|
let plugins = {};
|
|
650490
650492
|
try {
|
|
@@ -650510,16 +650512,16 @@ function listInstalledPluginRows() {
|
|
|
650510
650512
|
}
|
|
650511
650513
|
function readJsonSafe(path27) {
|
|
650512
650514
|
try {
|
|
650513
|
-
const raw2 = JSON.parse(
|
|
650515
|
+
const raw2 = JSON.parse(readFileSync48(path27, "utf-8"));
|
|
650514
650516
|
return raw2 && typeof raw2 === "object" ? raw2 : null;
|
|
650515
650517
|
} catch {
|
|
650516
650518
|
return null;
|
|
650517
650519
|
}
|
|
650518
650520
|
}
|
|
650519
650521
|
function detectCcPlugins() {
|
|
650520
|
-
const ccRoot = process.env.SEMA_CC_ROOT ||
|
|
650522
|
+
const ccRoot = process.env.SEMA_CC_ROOT || join198(homedir53(), CC_DIR5);
|
|
650521
650523
|
const byId = /* @__PURE__ */ new Map();
|
|
650522
|
-
const installedDoc = readJsonSafe(
|
|
650524
|
+
const installedDoc = readJsonSafe(join198(ccRoot, "plugins", "installed_plugins.json"));
|
|
650523
650525
|
const pluginsField = installedDoc?.plugins;
|
|
650524
650526
|
if (pluginsField && typeof pluginsField === "object") {
|
|
650525
650527
|
for (const [id, v2] of Object.entries(pluginsField)) {
|
|
@@ -650527,7 +650529,7 @@ function detectCcPlugins() {
|
|
|
650527
650529
|
byId.set(id, { id, version: entry?.version });
|
|
650528
650530
|
}
|
|
650529
650531
|
}
|
|
650530
|
-
const settings2 = readJsonSafe(
|
|
650532
|
+
const settings2 = readJsonSafe(join198(ccRoot, "settings.json"));
|
|
650531
650533
|
const enabled = settings2?.enabledPlugins;
|
|
650532
650534
|
if (enabled && typeof enabled === "object") {
|
|
650533
650535
|
for (const [id, on] of Object.entries(enabled)) {
|
|
@@ -650535,7 +650537,7 @@ function detectCcPlugins() {
|
|
|
650535
650537
|
byId.set(id, { ...cur, enabledInCc: on !== false });
|
|
650536
650538
|
}
|
|
650537
650539
|
}
|
|
650538
|
-
const mkts = readJsonSafe(
|
|
650540
|
+
const mkts = readJsonSafe(join198(ccRoot, "plugins", "known_marketplaces.json"));
|
|
650539
650541
|
const marketplaces = mkts ? Object.keys(mkts) : [];
|
|
650540
650542
|
return { plugins: [...byId.values()].sort((a, b3) => a.id.localeCompare(b3.id)), marketplaces };
|
|
650541
650543
|
}
|
|
@@ -652945,7 +652947,7 @@ __export(main_exports, {
|
|
|
652945
652947
|
main: () => main,
|
|
652946
652948
|
startDeferredPrefetches: () => startDeferredPrefetches
|
|
652947
652949
|
});
|
|
652948
|
-
import { readFileSync as
|
|
652950
|
+
import { readFileSync as readFileSync49 } from "fs";
|
|
652949
652951
|
import { resolve as resolve51 } from "path";
|
|
652950
652952
|
function logManagedSettings() {
|
|
652951
652953
|
try {
|
|
@@ -653112,7 +653114,7 @@ function loadSettingsFromFlag(settingsFile) {
|
|
|
653112
653114
|
resolvedPath: resolvedSettingsPath
|
|
653113
653115
|
} = safeResolvePath(getFsImplementation(), settingsFile);
|
|
653114
653116
|
try {
|
|
653115
|
-
|
|
653117
|
+
readFileSync49(resolvedSettingsPath, "utf8");
|
|
653116
653118
|
} catch (e) {
|
|
653117
653119
|
if (isENOENT(e)) {
|
|
653118
653120
|
process.stderr.write(source_default.red(`Error: Settings file not found: ${resolvedSettingsPath}
|
|
@@ -653689,7 +653691,7 @@ ${getTmuxInstallInstructions2()}
|
|
|
653689
653691
|
}
|
|
653690
653692
|
try {
|
|
653691
653693
|
const filePath = resolve51(options.systemPromptFile);
|
|
653692
|
-
systemPrompt =
|
|
653694
|
+
systemPrompt = readFileSync49(filePath, "utf8");
|
|
653693
653695
|
} catch (error51) {
|
|
653694
653696
|
const code2 = getErrnoCode(error51);
|
|
653695
653697
|
if (code2 === "ENOENT") {
|
|
@@ -653710,7 +653712,7 @@ ${getTmuxInstallInstructions2()}
|
|
|
653710
653712
|
}
|
|
653711
653713
|
try {
|
|
653712
653714
|
const filePath = resolve51(options.appendSystemPromptFile);
|
|
653713
|
-
appendSystemPrompt =
|
|
653715
|
+
appendSystemPrompt = readFileSync49(filePath, "utf8");
|
|
653714
653716
|
} catch (error51) {
|
|
653715
653717
|
const code2 = getErrnoCode(error51);
|
|
653716
653718
|
if (code2 === "ENOENT") {
|
|
@@ -655597,7 +655599,7 @@ Auth: unix socket -R \u2192 local proxy`, "info");
|
|
|
655597
655599
|
pendingHookMessages
|
|
655598
655600
|
}, renderAndRun);
|
|
655599
655601
|
}
|
|
655600
|
-
}).version("sema 1.0.
|
|
655602
|
+
}).version("sema 1.0.42", "-v, --version", "Output the version number");
|
|
655601
655603
|
program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
|
|
655602
655604
|
program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
|
|
655603
655605
|
if (canUserConfigureAdvisor()) {
|
|
@@ -659101,14 +659103,14 @@ __export(claudeImportHint_exports, {
|
|
|
659101
659103
|
});
|
|
659102
659104
|
import { existsSync as existsSync32 } from "node:fs";
|
|
659103
659105
|
import { homedir as homedir55 } from "node:os";
|
|
659104
|
-
import { join as
|
|
659106
|
+
import { join as join199 } from "node:path";
|
|
659105
659107
|
function shouldShowClaudeImportHint() {
|
|
659106
659108
|
try {
|
|
659107
659109
|
const claudeEnvKey = "CLAUDE_CONFIG_DIR";
|
|
659108
659110
|
if (process.env.SEMA_CONFIG_DIR || process.env[claudeEnvKey]) return false;
|
|
659109
|
-
const legacyDir =
|
|
659111
|
+
const legacyDir = join199(homedir55(), ".claude");
|
|
659110
659112
|
if (!existsSync32(legacyDir)) return false;
|
|
659111
|
-
if (existsSync32(
|
|
659113
|
+
if (existsSync32(join199(homedir55(), ".sema"))) return false;
|
|
659112
659114
|
if (getGlobalConfig().hasSeenClaudeImportHint) return false;
|
|
659113
659115
|
return true;
|
|
659114
659116
|
} catch {
|
|
@@ -659144,15 +659146,15 @@ var semaSettingsSeed_exports = {};
|
|
|
659144
659146
|
__export(semaSettingsSeed_exports, {
|
|
659145
659147
|
seedSemaSettings: () => seedSemaSettings
|
|
659146
659148
|
});
|
|
659147
|
-
import { existsSync as existsSync33, mkdirSync as mkdirSync23, readFileSync as
|
|
659148
|
-
import { dirname as dirname87, join as
|
|
659149
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync23, readFileSync as readFileSync50, writeFileSync as writeFileSync21 } from "node:fs";
|
|
659150
|
+
import { dirname as dirname87, join as join200 } from "node:path";
|
|
659149
659151
|
function seedSemaSettings() {
|
|
659150
|
-
const file2 =
|
|
659152
|
+
const file2 = join200(getClaudeConfigHomeDir(), "settings.json");
|
|
659151
659153
|
let current3 = {};
|
|
659152
659154
|
let parsedOk = false;
|
|
659153
659155
|
try {
|
|
659154
659156
|
if (existsSync33(file2)) {
|
|
659155
|
-
const parsed = JSON.parse(
|
|
659157
|
+
const parsed = JSON.parse(readFileSync50(file2, "utf8"));
|
|
659156
659158
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
659157
659159
|
current3 = parsed;
|
|
659158
659160
|
parsedOk = true;
|
|
@@ -659461,12 +659463,12 @@ var init_local_load = __esm({
|
|
|
659461
659463
|
});
|
|
659462
659464
|
|
|
659463
659465
|
// node_modules/@sema-agent/registry-core/dist/scheduler-store-node.js
|
|
659464
|
-
import { mkdirSync as mkdirSync24, readFileSync as
|
|
659466
|
+
import { mkdirSync as mkdirSync24, readFileSync as readFileSync51, writeFileSync as writeFileSync22, renameSync as renameSync10 } from "node:fs";
|
|
659465
659467
|
import { dirname as dirname88 } from "node:path";
|
|
659466
659468
|
import { randomBytes as randomBytes25, createHash as createHash27 } from "node:crypto";
|
|
659467
659469
|
function loadSchedulerStore(path27) {
|
|
659468
659470
|
try {
|
|
659469
|
-
return parseSchedulerStore(
|
|
659471
|
+
return parseSchedulerStore(readFileSync51(path27, "utf-8"));
|
|
659470
659472
|
} catch {
|
|
659471
659473
|
return [];
|
|
659472
659474
|
}
|
|
@@ -659481,7 +659483,7 @@ function mutateSchedulerStore(path27, fn2, opts) {
|
|
|
659481
659483
|
const maxRetries = Math.max(0, opts?.retries ?? 5);
|
|
659482
659484
|
const rawOf = () => {
|
|
659483
659485
|
try {
|
|
659484
|
-
return
|
|
659486
|
+
return readFileSync51(path27, "utf-8");
|
|
659485
659487
|
} catch {
|
|
659486
659488
|
return null;
|
|
659487
659489
|
}
|
|
@@ -659545,10 +659547,10 @@ var init_firePrompt = __esm({
|
|
|
659545
659547
|
});
|
|
659546
659548
|
|
|
659547
659549
|
// build-src/src/sema/scheduler/schedulerDaemonWire.ts
|
|
659548
|
-
import { join as
|
|
659550
|
+
import { join as join201 } from "node:path";
|
|
659549
659551
|
import { homedir as homedir56 } from "node:os";
|
|
659550
659552
|
function schedulerStorePath() {
|
|
659551
|
-
return
|
|
659553
|
+
return join201(process.env.SEMA_CONFIG_DIR ?? join201(homedir56(), ".sema"), "scheduled_tasks.json");
|
|
659552
659554
|
}
|
|
659553
659555
|
function fileSchedulerStoreIO(storePath) {
|
|
659554
659556
|
return {
|
|
@@ -659567,8 +659569,8 @@ var init_schedulerDaemonWire = __esm({
|
|
|
659567
659569
|
});
|
|
659568
659570
|
|
|
659569
659571
|
// build-src/src/sema/scheduler/sessionReap.ts
|
|
659570
|
-
import { mkdirSync as mkdirSync25, readdirSync as readdirSync14, readFileSync as
|
|
659571
|
-
import { dirname as dirname89, join as
|
|
659572
|
+
import { mkdirSync as mkdirSync25, readdirSync as readdirSync14, readFileSync as readFileSync52, unlinkSync as unlinkSync9, writeFileSync as writeFileSync23 } from "node:fs";
|
|
659573
|
+
import { dirname as dirname89, join as join202 } from "node:path";
|
|
659572
659574
|
function isSessionLifetimeRecord(r) {
|
|
659573
659575
|
return r.lifetime === "session";
|
|
659574
659576
|
}
|
|
@@ -659599,7 +659601,7 @@ function reapSessionRecords(io, departedSessionIds) {
|
|
|
659599
659601
|
return reaped.map((r) => r.id);
|
|
659600
659602
|
}
|
|
659601
659603
|
function schedulerClaimsDir(storePath) {
|
|
659602
|
-
return
|
|
659604
|
+
return join202(dirname89(storePath), "scheduler-claims");
|
|
659603
659605
|
}
|
|
659604
659606
|
function pidAlive3(pid) {
|
|
659605
659607
|
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
@@ -659612,10 +659614,10 @@ function pidAlive3(pid) {
|
|
|
659612
659614
|
}
|
|
659613
659615
|
function writeSchedulerClaim(storePath, sessionIds, pid = process.pid) {
|
|
659614
659616
|
const dir = schedulerClaimsDir(storePath);
|
|
659615
|
-
const file2 =
|
|
659617
|
+
const file2 = join202(dir, `${pid}.json`);
|
|
659616
659618
|
const ids = [...new Set(sessionIds.filter((id) => typeof id === "string" && id.length > 0))].sort();
|
|
659617
659619
|
try {
|
|
659618
|
-
const prev = JSON.parse(
|
|
659620
|
+
const prev = JSON.parse(readFileSync52(file2, "utf8"));
|
|
659619
659621
|
if (Array.isArray(prev.sessionIds) && prev.sessionIds.join("\n") === ids.join("\n")) return;
|
|
659620
659622
|
} catch {
|
|
659621
659623
|
}
|
|
@@ -659624,7 +659626,7 @@ function writeSchedulerClaim(storePath, sessionIds, pid = process.pid) {
|
|
|
659624
659626
|
}
|
|
659625
659627
|
function removeSchedulerClaim(storePath, pid = process.pid) {
|
|
659626
659628
|
try {
|
|
659627
|
-
unlinkSync9(
|
|
659629
|
+
unlinkSync9(join202(schedulerClaimsDir(storePath), `${pid}.json`));
|
|
659628
659630
|
} catch {
|
|
659629
659631
|
}
|
|
659630
659632
|
}
|
|
@@ -659644,7 +659646,7 @@ function readAliveClaimedSessionIds(storePath, opts = {}) {
|
|
|
659644
659646
|
if (!alive(pid)) {
|
|
659645
659647
|
if (opts.cleanupDead) {
|
|
659646
659648
|
try {
|
|
659647
|
-
unlinkSync9(
|
|
659649
|
+
unlinkSync9(join202(dir, f));
|
|
659648
659650
|
} catch {
|
|
659649
659651
|
}
|
|
659650
659652
|
}
|
|
@@ -659652,7 +659654,7 @@ function readAliveClaimedSessionIds(storePath, opts = {}) {
|
|
|
659652
659654
|
}
|
|
659653
659655
|
if (pid === opts.excludePid) continue;
|
|
659654
659656
|
try {
|
|
659655
|
-
const c2 = JSON.parse(
|
|
659657
|
+
const c2 = JSON.parse(readFileSync52(join202(dir, f), "utf8"));
|
|
659656
659658
|
if (Array.isArray(c2.sessionIds)) {
|
|
659657
659659
|
for (const id of c2.sessionIds) if (typeof id === "string" && id.length > 0) out6.add(id);
|
|
659658
659660
|
}
|
|
@@ -659980,7 +659982,7 @@ __export(loginState_exports, {
|
|
|
659980
659982
|
seedMockLoginState: () => seedMockLoginState,
|
|
659981
659983
|
seedProjectOnboardingState: () => seedProjectOnboardingState
|
|
659982
659984
|
});
|
|
659983
|
-
import { join as
|
|
659985
|
+
import { join as join203 } from "path";
|
|
659984
659986
|
import { mkdir as mkdir50, writeFile as writeFile53 } from "fs/promises";
|
|
659985
659987
|
function osDisplayName() {
|
|
659986
659988
|
try {
|
|
@@ -660049,8 +660051,8 @@ async function seedMockLoginState() {
|
|
|
660049
660051
|
}
|
|
660050
660052
|
try {
|
|
660051
660053
|
const { getClaudeConfigHomeDir: getClaudeConfigHomeDir3 } = await Promise.resolve().then(() => (init_envUtils(), envUtils_exports));
|
|
660052
|
-
const cachePath =
|
|
660053
|
-
await mkdir50(
|
|
660054
|
+
const cachePath = join203(getClaudeConfigHomeDir3(), "cache", "changelog.md");
|
|
660055
|
+
await mkdir50(join203(getClaudeConfigHomeDir3(), "cache"), { recursive: true });
|
|
660054
660056
|
await writeFile53(cachePath, buildChangelogMarkdown(BRAND3.whatsNew), { encoding: "utf-8" });
|
|
660055
660057
|
const { getStoredChangelog: getStoredChangelog2, _resetChangelogCacheForTesting: _resetChangelogCacheForTesting2 } = await Promise.resolve().then(() => (init_releaseNotes(), releaseNotes_exports));
|
|
660056
660058
|
_resetChangelogCacheForTesting2();
|
|
@@ -660903,7 +660905,7 @@ __export(agentsHotReload_exports, {
|
|
|
660903
660905
|
stopAgentsHotReload: () => stopAgentsHotReload
|
|
660904
660906
|
});
|
|
660905
660907
|
import { watch as watch3, existsSync as existsSync35 } from "node:fs";
|
|
660906
|
-
import { join as
|
|
660908
|
+
import { join as join204 } from "node:path";
|
|
660907
660909
|
async function reloadAgentDefinitions(cwd5) {
|
|
660908
660910
|
try {
|
|
660909
660911
|
const { clearAgentDefinitionsCache: clearAgentDefinitionsCache2, getAgentDefinitionsWithOverrides: getAgentDefinitionsWithOverrides2 } = await Promise.resolve().then(() => (init_loadAgentsDir(), loadAgentsDir_exports));
|
|
@@ -660940,7 +660942,7 @@ async function startAgentsHotReload(cwd5) {
|
|
|
660940
660942
|
}
|
|
660941
660943
|
try {
|
|
660942
660944
|
const { getClaudeConfigHomeDir: getClaudeConfigHomeDir3 } = await Promise.resolve().then(() => (init_envUtils(), envUtils_exports));
|
|
660943
|
-
const userDir =
|
|
660945
|
+
const userDir = join204(getClaudeConfigHomeDir3(), "agents");
|
|
660944
660946
|
if (existsSync35(userDir)) dirs.add(userDir);
|
|
660945
660947
|
} catch (e) {
|
|
660946
660948
|
if (process.env.SEMA_DEBUG) console.error("[sema] agents hot-reload user-dir scan soft-failed:", e);
|
|
@@ -661018,7 +661020,7 @@ __export(mcpFill_exports, {
|
|
|
661018
661020
|
loadCanonicalMcpClients: () => loadCanonicalMcpClients
|
|
661019
661021
|
});
|
|
661020
661022
|
import { homedir as homedir57 } from "os";
|
|
661021
|
-
import { readFileSync as
|
|
661023
|
+
import { readFileSync as readFileSync53 } from "fs";
|
|
661022
661024
|
function builtinDynamicConfig(command8) {
|
|
661023
661025
|
return { type: "stdio", command: command8, args: [], scope: "dynamic" };
|
|
661024
661026
|
}
|
|
@@ -661035,7 +661037,7 @@ function canonicalGlobalConfigFile() {
|
|
|
661035
661037
|
}
|
|
661036
661038
|
async function loadCanonicalMcpClients() {
|
|
661037
661039
|
try {
|
|
661038
|
-
const raw2 =
|
|
661040
|
+
const raw2 = readFileSync53(canonicalGlobalConfigFile(), "utf8");
|
|
661039
661041
|
const parsed = JSON.parse(raw2);
|
|
661040
661042
|
const mcpServers = parsed?.mcpServers;
|
|
661041
661043
|
if (!mcpServers || typeof mcpServers !== "object" || Object.keys(mcpServers).length === 0) {
|
|
@@ -661305,14 +661307,14 @@ var synthApprovalProbe_exports = {};
|
|
|
661305
661307
|
__export(synthApprovalProbe_exports, {
|
|
661306
661308
|
armSynthToolApprovalProbe: () => armSynthToolApprovalProbe
|
|
661307
661309
|
});
|
|
661308
|
-
import { writeFileSync as writeFileSync24, readFileSync as
|
|
661310
|
+
import { writeFileSync as writeFileSync24, readFileSync as readFileSync54 } from "node:fs";
|
|
661309
661311
|
function armSynthToolApprovalProbe() {
|
|
661310
661312
|
const specPath = process.env.SEMA_SYNTH_TOOL_APPROVAL;
|
|
661311
661313
|
if (!specPath) return;
|
|
661312
661314
|
const outPath = process.env.SEMA_SYNTH_TOOL_APPROVAL_OUT || `${specPath}.out.json`;
|
|
661313
661315
|
let spec;
|
|
661314
661316
|
try {
|
|
661315
|
-
spec = JSON.parse(
|
|
661317
|
+
spec = JSON.parse(readFileSync54(specPath, "utf8"));
|
|
661316
661318
|
} catch (e) {
|
|
661317
661319
|
logForDebugging(`synthApprovalProbe: spec unreadable (${String(e)}) \u2014 probe disarmed`);
|
|
661318
661320
|
return;
|
|
@@ -661383,7 +661385,7 @@ __export(workerScreen_exports, {
|
|
|
661383
661385
|
});
|
|
661384
661386
|
import { writeFileSync as writeFileSync25 } from "fs";
|
|
661385
661387
|
import { writeFile as writeFile54 } from "fs/promises";
|
|
661386
|
-
import { join as
|
|
661388
|
+
import { join as join205 } from "path";
|
|
661387
661389
|
function clampDims(c2, r) {
|
|
661388
661390
|
return {
|
|
661389
661391
|
c: Number.isFinite(c2) && c2 >= 20 ? Math.min(c2, 1e3) : 80,
|
|
@@ -661477,7 +661479,7 @@ function installWorkerVirtualTerminal(config4) {
|
|
|
661477
661479
|
}
|
|
661478
661480
|
const jobDir = config4.jobDir;
|
|
661479
661481
|
if (jobDir) {
|
|
661480
|
-
const screenPath =
|
|
661482
|
+
const screenPath = join205(jobDir, "screen.txt");
|
|
661481
661483
|
let lastWritten = "";
|
|
661482
661484
|
const flush = async () => {
|
|
661483
661485
|
const lines = snapshotLines();
|
|
@@ -661627,7 +661629,7 @@ import { spawn as spawn15 } from "child_process";
|
|
|
661627
661629
|
import { appendFileSync as appendFileSync7, createWriteStream as createWriteStream5 } from "fs";
|
|
661628
661630
|
import { chmod as chmod13, mkdir as mkdir51, readFile as readFile58, readdir as readdir33, rename as rename15, stat as stat54, unlink as unlink28 } from "fs/promises";
|
|
661629
661631
|
import { createConnection as createConnection4, createServer as createServer9 } from "net";
|
|
661630
|
-
import { dirname as dirname90, join as
|
|
661632
|
+
import { dirname as dirname90, join as join206 } from "path";
|
|
661631
661633
|
function probeSocketAlive(sockPath, timeoutMs = 1500) {
|
|
661632
661634
|
return (async () => {
|
|
661633
661635
|
const info = await readDaemonInfo();
|
|
@@ -661904,7 +661906,7 @@ var init_main4 = __esm({
|
|
|
661904
661906
|
});
|
|
661905
661907
|
this.logLine(`[daemon] supervisor up pid=${process.pid} origin=${this.origin}`);
|
|
661906
661908
|
await this.recoverJobs();
|
|
661907
|
-
await mkdir51(
|
|
661909
|
+
await mkdir51(join206(getDispatchDir(), "rejected"), { recursive: true, mode: 448 });
|
|
661908
661910
|
} catch (e) {
|
|
661909
661911
|
this.server?.close();
|
|
661910
661912
|
this.server = null;
|
|
@@ -662535,7 +662537,7 @@ var init_main4 = __esm({
|
|
|
662535
662537
|
return;
|
|
662536
662538
|
}
|
|
662537
662539
|
for (const f of files2) {
|
|
662538
|
-
const p =
|
|
662540
|
+
const p = join206(dir, f);
|
|
662539
662541
|
let size = 0;
|
|
662540
662542
|
try {
|
|
662541
662543
|
size = (await stat54(p)).size;
|
|
@@ -662551,7 +662553,7 @@ var init_main4 = __esm({
|
|
|
662551
662553
|
}
|
|
662552
662554
|
}
|
|
662553
662555
|
if (!payload2?.job) {
|
|
662554
|
-
await rename15(p,
|
|
662556
|
+
await rename15(p, join206(dir, "rejected", f)).catch(() => unlink28(p).catch(() => {
|
|
662555
662557
|
}));
|
|
662556
662558
|
this.logLine(`[daemon] rejected file dispatch ${f}`);
|
|
662557
662559
|
continue;
|
|
@@ -664633,12 +664635,12 @@ async function launchReplProduction() {
|
|
|
664633
664635
|
if (process.env.SEMA_QUESTION_FIXTURE) {
|
|
664634
664636
|
try {
|
|
664635
664637
|
const fixturePath = process.env.SEMA_QUESTION_FIXTURE;
|
|
664636
|
-
const { readFileSync:
|
|
664638
|
+
const { readFileSync: readFileSync55 } = await import("node:fs");
|
|
664637
664639
|
const { publishQuestionFrame: publishQuestionFrame2 } = await Promise.resolve().then(() => (init_liveQuestionStore(), liveQuestionStore_exports));
|
|
664638
664640
|
for (const delayMs of [3e3, 6e3, 9e3, 12e3, 15e3]) {
|
|
664639
664641
|
setTimeout(() => {
|
|
664640
664642
|
try {
|
|
664641
|
-
const frame = JSON.parse(
|
|
664643
|
+
const frame = JSON.parse(readFileSync55(fixturePath, "utf8"));
|
|
664642
664644
|
publishQuestionFrame2(frame);
|
|
664643
664645
|
try {
|
|
664644
664646
|
__require("node:fs").appendFileSync(`${fixturePath}.probe`, `published @${delayMs}
|