@botiverse/raft-daemon 0.72.8-play.20260713140653 → 0.72.8

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.
@@ -1,5 +1,5 @@
1
1
  // src/core.ts
2
- import path24 from "path";
2
+ import path23 from "path";
3
3
  import os8 from "os";
4
4
  import { randomUUID as randomUUID9 } from "crypto";
5
5
  import { createRequire as createRequire3 } from "module";
@@ -4558,17 +4558,16 @@ var TRIAL_DURATION_DAYS = (TRIAL_END_DATE.getTime() - TRIAL_START_DATE.getTime()
4558
4558
 
4559
4559
  // src/agentProcessManager.ts
4560
4560
  import { existsSync as existsSync8, mkdirSync as mkdirSync4, readFileSync as readFileSync6, readdirSync as readdirSync4, statSync, writeFileSync as writeFileSync4 } from "fs";
4561
- import { readdir as readdir3, stat as stat2, readFile, rm as rm2, lstat, realpath as realpath2, open } from "fs/promises";
4561
+ import { mkdir, writeFile, access, readdir as readdir2, stat as stat2, readFile, rm as rm2, lstat, realpath, open } from "fs/promises";
4562
4562
  import { createHash as createHash3, randomUUID as randomUUID6 } from "crypto";
4563
- import path15 from "path";
4563
+ import path14 from "path";
4564
4564
  import { gzipSync } from "zlib";
4565
4565
  import os6 from "os";
4566
4566
 
4567
4567
  // src/proxy.ts
4568
4568
  import { HttpsProxyAgent } from "https-proxy-agent";
4569
- import { Agent, ProxyAgent } from "undici";
4569
+ import { ProxyAgent } from "undici";
4570
4570
  var fetchDispatcherCache = /* @__PURE__ */ new Map();
4571
- var isolatedFetchDispatcherCache = /* @__PURE__ */ new Map();
4572
4571
  function getFetchPreResponseTimeoutMs(env) {
4573
4572
  const parsed = Number.parseInt(env.SLOCK_DAEMON_FETCH_PRE_RESPONSE_TIMEOUT_MS || "", 10);
4574
4573
  return Number.isFinite(parsed) && parsed > 0 ? parsed : 3e4;
@@ -4633,60 +4632,32 @@ function resolveProxyUrl(targetUrl, env) {
4633
4632
  if (shouldBypassProxy(targetUrl, env)) return void 0;
4634
4633
  return proxyUrl;
4635
4634
  }
4636
- function createProxyDispatcher(proxyUrl, timeoutMs) {
4637
- return new ProxyAgent({
4638
- uri: proxyUrl,
4639
- connect: { timeout: timeoutMs },
4640
- requestTls: { timeout: timeoutMs },
4641
- headersTimeout: timeoutMs
4642
- });
4643
- }
4644
- function closeDispatcherBestEffort(dispatcher) {
4645
- void Promise.resolve().then(() => dispatcher.close()).catch(() => dispatcher.destroy?.(new Error("evicted"))).catch(() => {
4646
- });
4647
- }
4648
4635
  function buildFetchDispatcher(targetUrl, env) {
4649
4636
  const proxyUrl = resolveProxyUrl(targetUrl, env);
4650
4637
  if (!proxyUrl) return void 0;
4651
4638
  const cached = fetchDispatcherCache.get(proxyUrl);
4652
4639
  if (cached) return cached;
4653
4640
  const timeoutMs = getFetchPreResponseTimeoutMs(env);
4654
- const dispatcher = createProxyDispatcher(proxyUrl, timeoutMs);
4655
- fetchDispatcherCache.set(proxyUrl, dispatcher);
4656
- return dispatcher;
4657
- }
4658
- function getIsolatedDispatcherCacheKey(targetUrl, isolationKey, env) {
4659
- const proxyUrl = resolveProxyUrl(targetUrl, env);
4660
- const routeKey = proxyUrl ? `proxy:${proxyUrl}` : `direct:${new URL(targetUrl).origin}`;
4661
- return { cacheKey: `${isolationKey}\0${routeKey}`, proxyUrl };
4662
- }
4663
- function buildIsolatedFetchDispatcher(targetUrl, isolationKey, env) {
4664
- const { cacheKey, proxyUrl } = getIsolatedDispatcherCacheKey(targetUrl, isolationKey, env);
4665
- const cached = isolatedFetchDispatcherCache.get(cacheKey);
4666
- if (cached) return cached;
4667
- const timeoutMs = getFetchPreResponseTimeoutMs(env);
4668
- const dispatcher = proxyUrl ? createProxyDispatcher(proxyUrl, timeoutMs) : new Agent({
4641
+ const dispatcher = new ProxyAgent({
4642
+ uri: proxyUrl,
4643
+ // All three are pre-response and body-agnostic (see getFetchPreResponseTimeoutMs):
4644
+ // headersTimeout = headers-hang leg; requestTls.timeout = CONNECT-tunnel
4645
+ // establish leg; connect.timeout = socket to the proxy itself (defensive).
4669
4646
  connect: { timeout: timeoutMs },
4647
+ requestTls: { timeout: timeoutMs },
4670
4648
  headersTimeout: timeoutMs
4671
4649
  });
4672
- isolatedFetchDispatcherCache.set(cacheKey, dispatcher);
4650
+ fetchDispatcherCache.set(proxyUrl, dispatcher);
4673
4651
  return dispatcher;
4674
4652
  }
4675
- function evictIsolatedFetchDispatcher(targetUrl, isolationKey, env) {
4676
- const { cacheKey } = getIsolatedDispatcherCacheKey(targetUrl, isolationKey, env);
4677
- const cached = isolatedFetchDispatcherCache.get(cacheKey);
4678
- if (!cached) return false;
4679
- isolatedFetchDispatcherCache.delete(cacheKey);
4680
- closeDispatcherBestEffort(cached);
4681
- return true;
4682
- }
4683
4653
  function evictFetchDispatcher(targetUrl, env) {
4684
4654
  const proxyUrl = resolveProxyUrl(targetUrl, env);
4685
4655
  if (!proxyUrl) return false;
4686
4656
  const cached = fetchDispatcherCache.get(proxyUrl);
4687
4657
  if (!cached) return false;
4688
4658
  fetchDispatcherCache.delete(proxyUrl);
4689
- closeDispatcherBestEffort(cached);
4659
+ void Promise.resolve().then(() => cached.close()).catch(() => cached.destroy?.(new Error("evicted"))).catch(() => {
4660
+ });
4690
4661
  return true;
4691
4662
  }
4692
4663
 
@@ -4695,17 +4666,11 @@ function withDaemonFetchProxy(input, init = {}, env = process.env) {
4695
4666
  const dispatcher = buildFetchDispatcher(input.toString(), env);
4696
4667
  return dispatcher ? { ...init, dispatcher } : init;
4697
4668
  }
4698
- async function daemonFetch(input, init, env = process.env, options = {}) {
4699
- const targetUrl = input.toString();
4700
- const fetchInit = options.isolationKey ? { ...init, dispatcher: buildIsolatedFetchDispatcher(targetUrl, options.isolationKey, env) } : withDaemonFetchProxy(input, init, env);
4669
+ async function daemonFetch(input, init, env = process.env) {
4701
4670
  try {
4702
- return await fetch(input, fetchInit);
4671
+ return await fetch(input, withDaemonFetchProxy(input, init, env));
4703
4672
  } catch (err) {
4704
- if (options.isolationKey) {
4705
- evictIsolatedFetchDispatcher(targetUrl, options.isolationKey, env);
4706
- } else {
4707
- evictFetchDispatcher(targetUrl, env);
4708
- }
4673
+ evictFetchDispatcher(input.toString(), env);
4709
4674
  throw err;
4710
4675
  }
4711
4676
  }
@@ -4866,8 +4831,8 @@ async function executeResponseRequest(url, init, {
4866
4831
  }
4867
4832
 
4868
4833
  // src/directUploadCapability.ts
4869
- function joinUrl(base, path25) {
4870
- return `${base.replace(/\/+$/, "")}${path25}`;
4834
+ function joinUrl(base, path24) {
4835
+ return `${base.replace(/\/+$/, "")}${path24}`;
4871
4836
  }
4872
4837
  function jsonHeaders(apiKey) {
4873
4838
  return {
@@ -4997,37 +4962,6 @@ import { existsSync as existsSync2, mkdirSync, readdirSync, readFileSync, rmSync
4997
4962
  import { createRequire } from "module";
4998
4963
  import path2 from "path";
4999
4964
 
5000
- // src/gitIdentity.ts
5001
- function resolveAgentGitIdentity(agentName) {
5002
- const name = agentName.trim();
5003
- if (!name) {
5004
- throw new Error("Cannot provision git identity for an agent without a name");
5005
- }
5006
- return { name, email: `${name.toLowerCase()}@mail.build` };
5007
- }
5008
- function buildProvisionSignedGitEnv(agentName) {
5009
- const identity = resolveAgentGitIdentity(agentName);
5010
- return {
5011
- GIT_AUTHOR_NAME: identity.name,
5012
- GIT_AUTHOR_EMAIL: identity.email,
5013
- GIT_COMMITTER_NAME: identity.name,
5014
- GIT_COMMITTER_EMAIL: identity.email
5015
- };
5016
- }
5017
- function withProvisionSignedGitEnv(config) {
5018
- const identityEnv = buildProvisionSignedGitEnv(config.name);
5019
- return {
5020
- ...config,
5021
- envVars: { ...config.envVars ?? {}, ...identityEnv },
5022
- ...config.runtimeConfig ? {
5023
- runtimeConfig: {
5024
- ...config.runtimeConfig,
5025
- envVars: { ...config.runtimeConfig.envVars ?? {}, ...identityEnv }
5026
- }
5027
- } : {}
5028
- };
5029
- }
5030
-
5031
4965
  // src/drivers/raftCliGuide.ts
5032
4966
  var MESSAGE_HEREDOC_DELIMITER = "SLOCKMSG";
5033
4967
  function describeSlockInstallation(audience) {
@@ -5588,15 +5522,6 @@ function listLegacySlockStatePaths(slockHome = resolveSlockHome(), homeDir = os.
5588
5522
  return candidates.filter((candidate) => existsSync(candidate.path));
5589
5523
  }
5590
5524
 
5591
- // src/authEnv.ts
5592
- var DAEMON_API_KEY_ENV = "SLOCK_MACHINE_API_KEY";
5593
- var SLOCK_AGENT_TOKEN_ENV = "SLOCK_AGENT_TOKEN";
5594
- function scrubDaemonChildEnv(env) {
5595
- delete env[DAEMON_API_KEY_ENV];
5596
- delete env[SLOCK_AGENT_TOKEN_ENV];
5597
- return env;
5598
- }
5599
-
5600
5525
  // src/agentCredentialProxy.ts
5601
5526
  import { randomBytes } from "crypto";
5602
5527
  import http from "http";
@@ -6574,7 +6499,6 @@ var HOP_BY_HOP_REQUEST_HEADERS = /* @__PURE__ */ new Set([
6574
6499
  var LOCAL_HELD_CONTEXT_LIMIT = 3;
6575
6500
  var AGENT_CREDENTIAL_PROXY_HOST = "127.0.0.1";
6576
6501
  var AGENT_CREDENTIAL_PROXY_BIND_MAX_ATTEMPTS = 3;
6577
- var AGENT_CREDENTIAL_PROXY_FETCH_ISOLATION_KEY = "agent-credential-proxy";
6578
6502
  function createProxyRequestHandler() {
6579
6503
  return (req, res) => {
6580
6504
  void handleProxyRequest(req, res);
@@ -6729,16 +6653,11 @@ async function handleProxyRequest(req, res) {
6729
6653
  headers.set("content-type", "application/json");
6730
6654
  headers.delete("content-length");
6731
6655
  }
6732
- const upstream = await daemonFetch(
6733
- target,
6734
- {
6735
- method,
6736
- headers,
6737
- body
6738
- },
6739
- process.env,
6740
- { isolationKey: AGENT_CREDENTIAL_PROXY_FETCH_ISOLATION_KEY }
6741
- );
6656
+ const upstream = await daemonFetch(target, {
6657
+ method,
6658
+ headers,
6659
+ body
6660
+ });
6742
6661
  if (upstream.status >= 500) {
6743
6662
  const transportError = transportNormalizedErrorForHttpStatus(target, upstream.status, registration.launchId);
6744
6663
  logger.warn(
@@ -7221,9 +7140,7 @@ var LOOPBACK_NO_PROXY = "127.0.0.1,localhost";
7221
7140
  var CLI_TRANSPORT_TRACE_DIR_ENV = "SLOCK_CLI_TRANSPORT_TRACE_DIR";
7222
7141
  var safePathPart = (value) => value.replace(/[^a-zA-Z0-9_.-]/g, "_");
7223
7142
  var RAW_CREDENTIAL_ENV_DENYLIST = [
7224
- "SLOCK_AGENT_TOKEN",
7225
- "SLOCK_AGENT_CREDENTIAL_KEY",
7226
- "SLOCK_AGENT_CREDENTIAL_KEY_FILE"
7143
+ "SLOCK_AGENT_CREDENTIAL_KEY"
7227
7144
  ];
7228
7145
  var WORKSPACE_CLI_TRANSPORT_FILENAMES = [
7229
7146
  "agent-token",
@@ -7564,7 +7481,6 @@ set "SLOCK_AGENT_ACTIVE_CAPABILITIES=${DEFAULT_ACTIVE_CAPABILITIES}"\r
7564
7481
  }
7565
7482
  const wrapperPath = platform === "win32" ? path2.join(slockDir, "slock.cmd") : posixWrapper;
7566
7483
  const launchRuntimeFields = runtimeConfigToLaunchFields(hydrateRuntimeConfig(ctx.config));
7567
- const provisionSignedGitEnv = ctx.config.name?.trim() ? buildProvisionSignedGitEnv(ctx.config.name) : {};
7568
7484
  const spawnEnv = {
7569
7485
  ...process.env,
7570
7486
  FORCE_COLOR: "0",
@@ -7572,7 +7488,6 @@ set "SLOCK_AGENT_ACTIVE_CAPABILITIES=${DEFAULT_ACTIVE_CAPABILITIES}"\r
7572
7488
  ...extraEnv,
7573
7489
  ...platform === "win32" ? windowsUtf8Env() : {},
7574
7490
  ...runtimeContextEnv(ctx.config),
7575
- ...provisionSignedGitEnv,
7576
7491
  [SLOCK_HOME_ENV]: slockHome,
7577
7492
  SLOCK_AGENT_ID: ctx.agentId,
7578
7493
  ...ctx.launchId ? { SLOCK_AGENT_LAUNCH_ID: ctx.launchId } : {},
@@ -7580,7 +7495,7 @@ set "SLOCK_AGENT_ACTIVE_CAPABILITIES=${DEFAULT_ACTIVE_CAPABILITIES}"\r
7580
7495
  SLOCK_SERVER_URL: ctx.config.serverUrl,
7581
7496
  PATH: `${slockDir}${path2.delimiter}${process.env.PATH ?? ""}`
7582
7497
  };
7583
- scrubDaemonChildEnv(spawnEnv);
7498
+ delete spawnEnv.SLOCK_AGENT_TOKEN;
7584
7499
  for (const key of RAW_CREDENTIAL_ENV_DENYLIST) {
7585
7500
  delete spawnEnv[key];
7586
7501
  }
@@ -8188,7 +8103,7 @@ function requiresWindowsShell(command, platform = process.platform) {
8188
8103
  }
8189
8104
  function resolveCommandOnPath(command, deps = {}) {
8190
8105
  const platform = deps.platform ?? process.platform;
8191
- const env = scrubDaemonChildEnv({ ...withWindowsUserEnvironment(deps.env ?? process.env, deps) });
8106
+ const env = withWindowsUserEnvironment(deps.env ?? process.env, deps);
8192
8107
  const execFileSyncFn = deps.execFileSyncFn ?? execFileSync;
8193
8108
  const existsSyncFn = deps.existsSyncFn ?? existsSync3;
8194
8109
  if (platform === "win32") {
@@ -8214,7 +8129,7 @@ function firstExistingPath(candidates, deps = {}) {
8214
8129
  return null;
8215
8130
  }
8216
8131
  function readCommandVersion(command, args = [], deps = {}) {
8217
- const env = scrubDaemonChildEnv({ ...withWindowsUserEnvironment(deps.env ?? process.env, deps) });
8132
+ const env = withWindowsUserEnvironment(deps.env ?? process.env, deps);
8218
8133
  const execFileSyncFn = deps.execFileSyncFn ?? execFileSync;
8219
8134
  try {
8220
8135
  const output = normalizeExecOutput(execFileSyncFn(command, [...args, "--version"], {
@@ -8688,7 +8603,7 @@ function codexNotificationDiagnosticEvent(message) {
8688
8603
  return null;
8689
8604
  }
8690
8605
  const sessionId = codexMessageThreadId(message);
8691
- const path25 = boundedString(params.path);
8606
+ const path24 = boundedString(params.path);
8692
8607
  return {
8693
8608
  kind: "runtime_diagnostic",
8694
8609
  severity: "warning",
@@ -8696,7 +8611,7 @@ function codexNotificationDiagnosticEvent(message) {
8696
8611
  itemType: message.method,
8697
8612
  message: diagnosticMessage,
8698
8613
  ...details ? { details } : {},
8699
- ...path25 ? { path: path25 } : {},
8614
+ ...path24 ? { path: path24 } : {},
8700
8615
  ...params.range !== void 0 ? { range: params.range } : {},
8701
8616
  payloadBytes: payloadBytes(params),
8702
8617
  ...sessionId ? { sessionId } : {}
@@ -10418,11 +10333,11 @@ function detectCursorModels(runCommand = runCursorModelsCommand) {
10418
10333
  return parseCursorModelsOutput(String(result.stdout || ""));
10419
10334
  }
10420
10335
  function buildCursorModelProbeEnv(deps = {}) {
10421
- return scrubDaemonChildEnv(withWindowsUserEnvironment({
10336
+ return withWindowsUserEnvironment({
10422
10337
  ...deps.env ?? process.env,
10423
10338
  FORCE_COLOR: "0",
10424
10339
  NO_COLOR: "1"
10425
- }, deps));
10340
+ }, deps);
10426
10341
  }
10427
10342
  function runCursorModelsCommand() {
10428
10343
  return spawnSync("cursor-agent", ["models"], {
@@ -10478,7 +10393,7 @@ function resolveGeminiSpawn(commandArgs, deps = {}) {
10478
10393
  }
10479
10394
  const execFileSyncFn = deps.execFileSyncFn ?? execFileSync3;
10480
10395
  const existsSyncFn = deps.existsSyncFn ?? existsSync5;
10481
- const env = scrubDaemonChildEnv({ ...deps.env ?? process.env });
10396
+ const env = deps.env ?? process.env;
10482
10397
  const winPath = path8.win32;
10483
10398
  let geminiEntry = null;
10484
10399
  try {
@@ -10615,15 +10530,12 @@ var GeminiDriver = class {
10615
10530
  // src/drivers/kimi.ts
10616
10531
  import { randomUUID as randomUUID2 } from "crypto";
10617
10532
  import { spawn as spawn7 } from "child_process";
10618
- import { chmodSync, existsSync as existsSync6, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
10533
+ import { existsSync as existsSync6, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
10619
10534
  import os4 from "os";
10620
10535
  import path9 from "path";
10621
10536
  var KIMI_WIRE_PROTOCOL_VERSION = "1.3";
10622
10537
  var KIMI_SYSTEM_PROMPT_FILE = ".slock-kimi-system.md";
10623
10538
  var KIMI_AGENT_FILE = ".slock-kimi-agent.yaml";
10624
- var KIMI_GENERATED_CONFIG_FILE = ".slock-kimi-config.toml";
10625
- var SLOCK_KIMI_CONFIG_CONTENT_ENV = "SLOCK_KIMI_CONFIG_CONTENT";
10626
- var SLOCK_KIMI_CONFIG_FILE_ENV = "SLOCK_KIMI_CONFIG_FILE";
10627
10539
  function parseToolArguments(raw) {
10628
10540
  if (typeof raw !== "string") return raw;
10629
10541
  try {
@@ -10632,73 +10544,6 @@ function parseToolArguments(raw) {
10632
10544
  return raw;
10633
10545
  }
10634
10546
  }
10635
- function readKimiConfigSource(home = os4.homedir(), env = process.env) {
10636
- const inlineConfig = env[SLOCK_KIMI_CONFIG_CONTENT_ENV];
10637
- if (inlineConfig && inlineConfig.trim()) {
10638
- return {
10639
- raw: inlineConfig,
10640
- explicitPath: null,
10641
- sourcePath: SLOCK_KIMI_CONFIG_CONTENT_ENV
10642
- };
10643
- }
10644
- const explicitPath = env[SLOCK_KIMI_CONFIG_FILE_ENV];
10645
- const configPath = explicitPath && explicitPath.trim() ? explicitPath : path9.join(home, ".kimi", "config.toml");
10646
- try {
10647
- return {
10648
- raw: readFileSync3(configPath, "utf8"),
10649
- explicitPath: explicitPath && explicitPath.trim() ? explicitPath : null,
10650
- sourcePath: configPath
10651
- };
10652
- } catch {
10653
- return {
10654
- raw: null,
10655
- explicitPath: explicitPath && explicitPath.trim() ? explicitPath : null,
10656
- sourcePath: configPath
10657
- };
10658
- }
10659
- }
10660
- function buildKimiSpawnEnv(env = process.env) {
10661
- const spawnEnv = { ...env, FORCE_COLOR: "0", NO_COLOR: "1" };
10662
- delete spawnEnv[SLOCK_KIMI_CONFIG_CONTENT_ENV];
10663
- delete spawnEnv[SLOCK_KIMI_CONFIG_FILE_ENV];
10664
- return scrubDaemonChildEnv(spawnEnv);
10665
- }
10666
- function buildKimiEffectiveEnv(ctx, overrideEnv) {
10667
- return {
10668
- ...process.env,
10669
- ...ctx.config.envVars || {},
10670
- ...overrideEnv || {}
10671
- };
10672
- }
10673
- function buildKimiLaunchOptions(ctx, opts = {}) {
10674
- const env = buildKimiEffectiveEnv(ctx, opts.env);
10675
- const source = readKimiConfigSource(opts.home ?? os4.homedir(), env);
10676
- const args = [];
10677
- let configFilePath = null;
10678
- let configContent = null;
10679
- if (source.explicitPath) {
10680
- configFilePath = source.explicitPath;
10681
- } else if (source.raw !== null && source.sourcePath === SLOCK_KIMI_CONFIG_CONTENT_ENV) {
10682
- configFilePath = path9.join(ctx.workingDirectory, KIMI_GENERATED_CONFIG_FILE);
10683
- configContent = source.raw;
10684
- if (opts.writeGeneratedConfig !== false) {
10685
- writeFileSync3(configFilePath, source.raw, { encoding: "utf8", mode: 384 });
10686
- chmodSync(configFilePath, 384);
10687
- }
10688
- }
10689
- if (configFilePath) {
10690
- args.push("--config-file", configFilePath);
10691
- }
10692
- if (ctx.config.model && ctx.config.model !== "default") {
10693
- args.push("--model", ctx.config.model);
10694
- }
10695
- return {
10696
- args,
10697
- env: buildKimiSpawnEnv(env),
10698
- configFilePath,
10699
- configContent
10700
- };
10701
- }
10702
10547
  function resolveKimiSpawn(commandArgs, deps = {}) {
10703
10548
  return {
10704
10549
  command: resolveCommandOnPath("kimi", deps) ?? "kimi",
@@ -10722,25 +10567,7 @@ var KimiDriver = class {
10722
10567
  };
10723
10568
  model = {
10724
10569
  detectedModelsVerifiedAs: "launchable",
10725
- toLaunchSpec: (modelId, ctx, opts) => {
10726
- if (!ctx) return { args: ["--model", modelId] };
10727
- const launchCtx = {
10728
- ...ctx,
10729
- config: {
10730
- ...ctx.config,
10731
- model: modelId
10732
- }
10733
- };
10734
- const launch = buildKimiLaunchOptions(launchCtx, {
10735
- home: opts?.home,
10736
- writeGeneratedConfig: false
10737
- });
10738
- return {
10739
- args: launch.args,
10740
- env: launch.env,
10741
- configFiles: launch.configFilePath ? [launch.configFilePath] : void 0
10742
- };
10743
- }
10570
+ toLaunchSpec: (modelId) => ({ args: ["--model", modelId] })
10744
10571
  };
10745
10572
  supportsStdinNotification = true;
10746
10573
  busyDeliveryMode = "direct";
@@ -10764,23 +10591,21 @@ var KimiDriver = class {
10764
10591
  ` system_prompt_path: ./${KIMI_SYSTEM_PROMPT_FILE}`,
10765
10592
  ""
10766
10593
  ].join("\n"), "utf8");
10767
- const launch = buildKimiLaunchOptions(ctx);
10768
10594
  const args = [
10769
10595
  "--wire",
10770
10596
  "--yolo",
10771
10597
  "--agent-file",
10772
10598
  agentFilePath,
10773
10599
  "--session",
10774
- this.sessionId,
10775
- ...launch.args
10600
+ this.sessionId
10776
10601
  ];
10777
10602
  const launchRuntimeFields = runtimeConfigToLaunchFields(hydrateRuntimeConfig(ctx.config));
10778
10603
  if (launchRuntimeFields.model && launchRuntimeFields.model !== "default") {
10779
10604
  args.push("--model", launchRuntimeFields.model);
10780
10605
  }
10781
10606
  const spawnEnv = (await prepareCliTransport(ctx, { NO_COLOR: "1" })).spawnEnv;
10782
- const spawnTarget = resolveKimiSpawn(args);
10783
- const proc = spawn7(spawnTarget.command, spawnTarget.args, {
10607
+ const launch = resolveKimiSpawn(args);
10608
+ const proc = spawn7(launch.command, launch.args, {
10784
10609
  cwd: ctx.workingDirectory,
10785
10610
  stdio: ["pipe", "pipe", "pipe"],
10786
10611
  env: spawnEnv,
@@ -10788,7 +10613,7 @@ var KimiDriver = class {
10788
10613
  // and has an 8191-character command-line limit. Kimi's official
10789
10614
  // installer/uv entrypoint is an executable, so launch it directly and
10790
10615
  // keep prompts on stdin / files instead of routing through cmd.exe.
10791
- shell: spawnTarget.shell
10616
+ shell: launch.shell
10792
10617
  });
10793
10618
  proc.stdin?.write(JSON.stringify({
10794
10619
  jsonrpc: "2.0",
@@ -10901,9 +10726,14 @@ var KimiDriver = class {
10901
10726
  return detectKimiModels();
10902
10727
  }
10903
10728
  };
10904
- function detectKimiModels(home = os4.homedir(), opts = {}) {
10905
- const raw = readKimiConfigSource(home, opts.env).raw;
10906
- if (raw === null) return null;
10729
+ function detectKimiModels(home = os4.homedir()) {
10730
+ const configPath = path9.join(home, ".kimi", "config.toml");
10731
+ let raw;
10732
+ try {
10733
+ raw = readFileSync3(configPath, "utf8");
10734
+ } catch {
10735
+ return null;
10736
+ }
10907
10737
  const models = [];
10908
10738
  const sectionRe = /^\s*\[models(?:\.([^\]]+)|"\.[^"]+"|\."[^"]+")\s*\]\s*$/gm;
10909
10739
  const lineRe = /^\s*\[models\.(.+?)\s*\]\s*$/gm;
@@ -10929,7 +10759,6 @@ import { mkdirSync as mkdirSync2, readFileSync as readFileSync4 } from "fs";
10929
10759
  import path10 from "path";
10930
10760
  import { createRequire as createRequire2 } from "module";
10931
10761
  import {
10932
- LocalKaos,
10933
10762
  createKimiHarness,
10934
10763
  resolveKimiHome
10935
10764
  } from "@botiverse/kimi-code-sdk";
@@ -11095,7 +10924,6 @@ So instead of \`raft message send ...\`, run \`${wrapperPath} message send ...\`
11095
10924
  }
11096
10925
  async function createKimiAgentSessionForContext(ctx, sessionId, deps = {}) {
11097
10926
  const createHarnessImpl = deps.createHarness ?? createKimiHarness;
11098
- const createKaosImpl = deps.createKaos ?? LocalKaos.create;
11099
10927
  const prepareTransportImpl = deps.prepareTransport ?? prepareCliTransport;
11100
10928
  const sessionDir = buildKimiSessionDir(ctx.workingDirectory);
11101
10929
  mkdirSync2(sessionDir, { recursive: true });
@@ -11114,10 +10942,8 @@ async function createKimiAgentSessionForContext(ctx, sessionId, deps = {}) {
11114
10942
  });
11115
10943
  const launchRuntimeFields = runtimeConfigToLaunchFields(hydrateRuntimeConfig(ctx.config));
11116
10944
  const roleAdditional = composeStandingRoleAdditional(ctx.standingPrompt, wrapperPath);
11117
- const kaos = (await createKaosImpl()).withEnv(buildProvisionSignedGitEnv(ctx.config.name));
11118
10945
  const sessionFields = {
11119
10946
  workDir: ctx.workingDirectory,
11120
- kaos,
11121
10947
  ...launchRuntimeFields.model && launchRuntimeFields.model !== "default" ? { model: launchRuntimeFields.model } : {},
11122
10948
  ...roleAdditional ? { roleAdditional } : {}
11123
10949
  };
@@ -11592,7 +11418,7 @@ function runOpenCodeModelsCommand(home, deps = {}) {
11592
11418
  const platform = deps.platform ?? process.platform;
11593
11419
  const spawnSyncFn = deps.spawnSyncFn ?? spawnSync2;
11594
11420
  const result = spawnSyncFn("opencode", ["models"], {
11595
- env: scrubDaemonChildEnv({ ...process.env, HOME: home, FORCE_COLOR: "0", NO_COLOR: "1" }),
11421
+ env: { ...process.env, HOME: home, FORCE_COLOR: "0", NO_COLOR: "1" },
11596
11422
  encoding: "utf8",
11597
11423
  timeout: 5e3,
11598
11424
  shell: platform === "win32"
@@ -12952,27 +12778,8 @@ async function reapOrphanProcesses(pids, logger2, recordTrace) {
12952
12778
  }
12953
12779
 
12954
12780
  // src/workspaces.ts
12955
- import { access, mkdir, readdir, rm, stat, writeFile } from "fs/promises";
12781
+ import { readdir, rm, stat } from "fs/promises";
12956
12782
  import path13 from "path";
12957
- async function initializeAgentWorkspace(workspacePath, initialMemoryMd, seedFiles) {
12958
- await mkdir(workspacePath, { recursive: true });
12959
- const memoryMdPath = path13.join(workspacePath, "MEMORY.md");
12960
- try {
12961
- await access(memoryMdPath);
12962
- } catch {
12963
- await writeFile(memoryMdPath, initialMemoryMd);
12964
- }
12965
- await mkdir(path13.join(workspacePath, "notes"), { recursive: true });
12966
- for (const { relativePath, content } of seedFiles) {
12967
- const fullPath = path13.join(workspacePath, relativePath);
12968
- try {
12969
- await access(fullPath);
12970
- } catch {
12971
- await mkdir(path13.dirname(fullPath), { recursive: true });
12972
- await writeFile(fullPath, content);
12973
- }
12974
- }
12975
- }
12976
12783
  function isValidWorkspaceDirectoryName(directoryName) {
12977
12784
  return !directoryName.includes("/") && !directoryName.includes("\\") && !directoryName.includes("..");
12978
12785
  }
@@ -13079,120 +12886,6 @@ async function deleteWorkspaceDirectory(dataDir, directoryName) {
13079
12886
  }
13080
12887
  }
13081
12888
 
13082
- // src/workspaceGitIdentity.ts
13083
- import { execFile } from "child_process";
13084
- import { readdir as readdir2, realpath } from "fs/promises";
13085
- import path14 from "path";
13086
- import { promisify } from "util";
13087
- var execFileAsync = promisify(execFile);
13088
- var DISCOVERY_SKIP_DIRECTORIES = /* @__PURE__ */ new Set([".git", "node_modules"]);
13089
- var RepositoryOwnershipError = class extends Error {
13090
- };
13091
- async function runGit(repoPath, args) {
13092
- const { stdout } = await execFileAsync("git", ["-C", repoPath, ...args], {
13093
- encoding: "utf8"
13094
- });
13095
- return stdout.trim();
13096
- }
13097
- function isPathInside(rootPath, candidatePath) {
13098
- const relative = path14.relative(rootPath, candidatePath);
13099
- return relative === "" || !relative.startsWith(`..${path14.sep}`) && relative !== ".." && !path14.isAbsolute(relative);
13100
- }
13101
- async function inspectGitRepository(repoPath, ownedRootPath) {
13102
- try {
13103
- const [gitDirOutput, commonDirOutput] = await Promise.all([
13104
- runGit(repoPath, ["rev-parse", "--absolute-git-dir"]),
13105
- runGit(repoPath, ["rev-parse", "--git-common-dir"])
13106
- ]);
13107
- const [canonicalRepoPath, gitDir, commonDir] = await Promise.all([
13108
- realpath(repoPath),
13109
- realpath(gitDirOutput),
13110
- realpath(
13111
- path14.isAbsolute(commonDirOutput) ? commonDirOutput : path14.resolve(repoPath, commonDirOutput)
13112
- )
13113
- ]);
13114
- if (!isPathInside(ownedRootPath, canonicalRepoPath) || !isPathInside(ownedRootPath, gitDir) || !isPathInside(ownedRootPath, commonDir)) {
13115
- throw new RepositoryOwnershipError(
13116
- `Refusing to provision git identity outside the agent-owned workspace: ${repoPath}`
13117
- );
13118
- }
13119
- return { repoPath, linkedWorktree: gitDir !== commonDir };
13120
- } catch (error) {
13121
- if (error.code === "ENOENT") {
13122
- throw new Error("git is required to provision repository identity", { cause: error });
13123
- }
13124
- if (error instanceof RepositoryOwnershipError) {
13125
- throw error;
13126
- }
13127
- return null;
13128
- }
13129
- }
13130
- async function discoverWorkspaceGitRepositories(workspacePath) {
13131
- const repositories = [];
13132
- const pending = [workspacePath];
13133
- while (pending.length > 0) {
13134
- const currentPath = pending.pop();
13135
- const entries = await readdir2(currentPath, { withFileTypes: true });
13136
- if (entries.some((entry) => entry.name === ".git")) {
13137
- repositories.push(currentPath);
13138
- }
13139
- for (const entry of entries) {
13140
- if (!entry.isDirectory() || DISCOVERY_SKIP_DIRECTORIES.has(entry.name)) {
13141
- continue;
13142
- }
13143
- pending.push(path14.join(currentPath, entry.name));
13144
- }
13145
- }
13146
- return repositories.sort();
13147
- }
13148
- async function reconcileWorkspaceGitIdentity(workspacePath, agentName) {
13149
- const identity = resolveAgentGitIdentity(agentName);
13150
- const ownedRootPath = await realpath(workspacePath);
13151
- const repositories = await discoverWorkspaceGitRepositories(workspacePath);
13152
- const result = {
13153
- discovered: repositories.length,
13154
- configuredStandalone: 0,
13155
- configuredLinkedWorktree: 0,
13156
- skippedInvalid: 0
13157
- };
13158
- const layouts = [];
13159
- for (const repoPath of repositories) {
13160
- const layout = await inspectGitRepository(repoPath, ownedRootPath);
13161
- if (!layout) {
13162
- result.skippedInvalid += 1;
13163
- continue;
13164
- }
13165
- layouts.push(layout);
13166
- }
13167
- for (const layout of layouts) {
13168
- const { repoPath } = layout;
13169
- if (layout.linkedWorktree) {
13170
- await runGit(repoPath, ["config", "--local", "extensions.worktreeConfig", "true"]);
13171
- await runGit(repoPath, ["config", "--worktree", "user.name", identity.name]);
13172
- await runGit(repoPath, ["config", "--worktree", "user.email", identity.email]);
13173
- result.configuredLinkedWorktree += 1;
13174
- continue;
13175
- }
13176
- await runGit(repoPath, ["config", "--local", "user.name", identity.name]);
13177
- await runGit(repoPath, ["config", "--local", "user.email", identity.email]);
13178
- result.configuredStandalone += 1;
13179
- }
13180
- return result;
13181
- }
13182
- async function provisionWorkspaceGitIdentity(workspacePath, agentId, agentName) {
13183
- const result = await reconcileWorkspaceGitIdentity(workspacePath, agentName);
13184
- if (result.discovered > 0) {
13185
- logger.info(
13186
- `[Agent ${agentId}] Git identity provisioned for ${result.configuredStandalone} standalone repositories and ${result.configuredLinkedWorktree} linked worktrees`
13187
- );
13188
- }
13189
- if (result.skippedInvalid > 0) {
13190
- logger.warn(
13191
- `[Agent ${agentId}] Skipped ${result.skippedInvalid} invalid git repository markers while provisioning identity`
13192
- );
13193
- }
13194
- }
13195
-
13196
12889
  // src/agentStartCoordinator.ts
13197
12890
  var AgentStartCoordinator = class {
13198
12891
  starting = /* @__PURE__ */ new Set();
@@ -14696,7 +14389,7 @@ function isWorkspaceNeverVisibleHiddenEntry(name) {
14696
14389
  return WORKSPACE_NEVER_VISIBLE_HIDDEN_NAMES.has(name) || name.startsWith(".slock-");
14697
14390
  }
14698
14391
  function workspacePathParts(relativePath) {
14699
- return relativePath.split(path15.sep).filter(Boolean);
14392
+ return relativePath.split(path14.sep).filter(Boolean);
14700
14393
  }
14701
14394
  function isWorkspaceHiddenPath(relativePath) {
14702
14395
  return workspacePathParts(relativePath).some((part) => part.startsWith("."));
@@ -14823,29 +14516,29 @@ function allowedTranscriptRootsForRuntime(runtime, homeDir, workspaceDir) {
14823
14516
  const roots = [workspaceDir];
14824
14517
  switch (runtime) {
14825
14518
  case "claude":
14826
- roots.push(path15.join(homeDir, ".claude"));
14519
+ roots.push(path14.join(homeDir, ".claude"));
14827
14520
  break;
14828
14521
  case "codex":
14829
- roots.push(homeDir, path15.join(homeDir, ".codex"));
14522
+ roots.push(homeDir, path14.join(homeDir, ".codex"));
14830
14523
  break;
14831
14524
  case "kimi":
14832
14525
  case "kimi-sdk":
14833
- roots.push(path15.join(homeDir, ".kimi"));
14526
+ roots.push(path14.join(homeDir, ".kimi"));
14834
14527
  break;
14835
14528
  case "pi":
14836
- roots.push(path15.join(homeDir, ".pi"), path15.join(homeDir, ".pi", "agent"));
14529
+ roots.push(path14.join(homeDir, ".pi"), path14.join(homeDir, ".pi", "agent"));
14837
14530
  break;
14838
14531
  }
14839
14532
  return roots;
14840
14533
  }
14841
14534
  async function isPathWithinAllowedRoots(filePath, roots) {
14842
- const real = await realpath2(filePath).catch(() => null);
14535
+ const real = await realpath(filePath).catch(() => null);
14843
14536
  if (!real) return false;
14844
14537
  for (const root of roots) {
14845
- const realRoot = await realpath2(root).catch(() => null);
14538
+ const realRoot = await realpath(root).catch(() => null);
14846
14539
  if (!realRoot) continue;
14847
- const rel = path15.relative(realRoot, real);
14848
- if (!rel.startsWith("..") && !path15.isAbsolute(rel)) return true;
14540
+ const rel = path14.relative(realRoot, real);
14541
+ if (!rel.startsWith("..") && !path14.isAbsolute(rel)) return true;
14849
14542
  }
14850
14543
  return false;
14851
14544
  }
@@ -14892,12 +14585,12 @@ function findSessionJsonl(root, predicate) {
14892
14585
  for (const entry of entries) {
14893
14586
  if (++visited > maxEntries) return null;
14894
14587
  if (!entry.isFile() || !predicate(entry.name)) continue;
14895
- return path15.join(dir, entry.name);
14588
+ return path14.join(dir, entry.name);
14896
14589
  }
14897
14590
  for (const entry of entries) {
14898
14591
  if (++visited > maxEntries) return null;
14899
14592
  if (!entry.isDirectory()) continue;
14900
- const found = visit(path15.join(dir, entry.name), depth - 1);
14593
+ const found = visit(path14.join(dir, entry.name), depth - 1);
14901
14594
  if (found) return found;
14902
14595
  }
14903
14596
  return null;
@@ -14905,7 +14598,7 @@ function findSessionJsonl(root, predicate) {
14905
14598
  return visit(root, maxDepth);
14906
14599
  }
14907
14600
  function findKimiSdkSessionDir(sessionId, agentId, homeDir) {
14908
- const indexPath = path15.join(homeDir, ".kimi", "session_index.jsonl");
14601
+ const indexPath = path14.join(homeDir, ".kimi", "session_index.jsonl");
14909
14602
  try {
14910
14603
  const index = readFileSync6(indexPath, "utf8");
14911
14604
  for (const line of index.split("\n")) {
@@ -14920,12 +14613,12 @@ function findKimiSdkSessionDir(sessionId, agentId, homeDir) {
14920
14613
  }
14921
14614
  } catch {
14922
14615
  }
14923
- const sessionsRoot = path15.join(homeDir, ".kimi", "sessions");
14616
+ const sessionsRoot = path14.join(homeDir, ".kimi", "sessions");
14924
14617
  try {
14925
14618
  const prefix = agentId ? `wd_${agentId}_` : `wd_`;
14926
14619
  for (const entry of readdirSync4(sessionsRoot, { withFileTypes: true })) {
14927
14620
  if (!entry.isDirectory() || !entry.name.startsWith(prefix)) continue;
14928
- const candidate = path15.join(sessionsRoot, entry.name, `session_${sessionId}`);
14621
+ const candidate = path14.join(sessionsRoot, entry.name, `session_${sessionId}`);
14929
14622
  if (existsSync8(candidate)) return candidate;
14930
14623
  }
14931
14624
  } catch {
@@ -14934,16 +14627,16 @@ function findKimiSdkSessionDir(sessionId, agentId, homeDir) {
14934
14627
  }
14935
14628
  function findPiSessionFile2(sessionId, workingDirectory, homeDir) {
14936
14629
  if (workingDirectory) {
14937
- const piSessionsDir = path15.join(workingDirectory, ".pi-sessions");
14630
+ const piSessionsDir = path14.join(workingDirectory, ".pi-sessions");
14938
14631
  try {
14939
- const files = readdirSync4(piSessionsDir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => ({ name: e.name, path: path15.join(piSessionsDir, e.name), stat: statSync(path15.join(piSessionsDir, e.name)) })).filter((f) => f.stat.isFile() && f.name.includes(sessionId)).sort((a, b) => b.stat.mtimeMs - a.stat.mtimeMs);
14632
+ const files = readdirSync4(piSessionsDir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => ({ name: e.name, path: path14.join(piSessionsDir, e.name), stat: statSync(path14.join(piSessionsDir, e.name)) })).filter((f) => f.stat.isFile() && f.name.includes(sessionId)).sort((a, b) => b.stat.mtimeMs - a.stat.mtimeMs);
14940
14633
  if (files[0]) return files[0].path;
14941
14634
  } catch {
14942
14635
  }
14943
14636
  }
14944
14637
  const legacyRoots = [
14945
- path15.join(homeDir, ".pi", "agent"),
14946
- path15.join(homeDir, ".pi")
14638
+ path14.join(homeDir, ".pi", "agent"),
14639
+ path14.join(homeDir, ".pi")
14947
14640
  ];
14948
14641
  for (const root of legacyRoots) {
14949
14642
  const found = findSessionJsonl(root, (filename) => filename.endsWith(".jsonl") && filename.includes(sessionId));
@@ -14957,9 +14650,9 @@ function safeSessionFilename(value) {
14957
14650
  }
14958
14651
  function writeRuntimeSessionHandoff(runtime, sessionId, fallbackDir, join, resolve) {
14959
14652
  try {
14960
- const dir = path15.join(fallbackDir, ".slock", "runtime-sessions");
14653
+ const dir = path14.join(fallbackDir, ".slock", "runtime-sessions");
14961
14654
  mkdirSync4(dir, { recursive: true });
14962
- const filePath = path15.join(dir, `${runtime}-${safeSessionFilename(sessionId)}.jsonl`);
14655
+ const filePath = path14.join(dir, `${runtime}-${safeSessionFilename(sessionId)}.jsonl`);
14963
14656
  const searchedPaths = resolve?.searchedPaths ?? [];
14964
14657
  writeFileSync4(filePath, JSON.stringify({
14965
14658
  type: "runtime_session_handoff",
@@ -15014,7 +14707,7 @@ function resolveRuntimeSessionRef(runtime, sessionId, homeDir = os6.homedir(), f
15014
14707
  const searchedPaths = [];
15015
14708
  if (runtime === "claude") {
15016
14709
  lookupMethod = "claude_jsonl";
15017
- const claudeRoot = path15.join(homeDir, ".claude", "projects");
14710
+ const claudeRoot = path14.join(homeDir, ".claude", "projects");
15018
14711
  searchedPaths.push(claudeRoot);
15019
14712
  resolvedPath = findSessionJsonl(claudeRoot, (filename) => filename === `${sessionId}.jsonl`);
15020
14713
  } else if (runtime === "codex") {
@@ -16386,7 +16079,7 @@ var AgentProcessManager = class _AgentProcessManager {
16386
16079
  this.sendToServer = sendToServer;
16387
16080
  this.daemonApiKey = daemonApiKey;
16388
16081
  this.serverUrl = opts.serverUrl;
16389
- this.slockHome = opts.slockHome ? path15.resolve(opts.slockHome) : resolveSlockHome();
16082
+ this.slockHome = opts.slockHome ? path14.resolve(opts.slockHome) : resolveSlockHome();
16390
16083
  this.dataDir = opts.dataDir || resolveSlockHomePath("agents", this.slockHome);
16391
16084
  this.runtimeSessionHomeDir = opts.runtimeSessionHomeDir || os6.homedir();
16392
16085
  this.driverResolver = opts.driverResolver || getDriver;
@@ -17701,13 +17394,30 @@ var AgentProcessManager = class _AgentProcessManager {
17701
17394
  let pendingStartRebind;
17702
17395
  const originalLaunchId = launchId || null;
17703
17396
  try {
17704
- const agentDataDir = path15.join(this.dataDir, agentId);
17397
+ const agentDataDir = path14.join(this.dataDir, agentId);
17398
+ await mkdir(agentDataDir, { recursive: true });
17705
17399
  const initialRuntimeConfig = withLocalRuntimeContext(config, agentId, agentDataDir);
17706
- await initializeAgentWorkspace(
17707
- agentDataDir,
17708
- buildInitialMemoryMd(initialRuntimeConfig),
17709
- getOnboardingSeedMode(config) === FIRST_CINDY_SEED_MODE ? buildOnboardingSeedFiles() : []
17710
- );
17400
+ const memoryMdPath = path14.join(agentDataDir, "MEMORY.md");
17401
+ try {
17402
+ await access(memoryMdPath);
17403
+ } catch {
17404
+ const initialMemoryMd = buildInitialMemoryMd(initialRuntimeConfig);
17405
+ await writeFile(memoryMdPath, initialMemoryMd);
17406
+ }
17407
+ const notesDir = path14.join(agentDataDir, "notes");
17408
+ await mkdir(notesDir, { recursive: true });
17409
+ if (getOnboardingSeedMode(config) === FIRST_CINDY_SEED_MODE) {
17410
+ const seedFiles = buildOnboardingSeedFiles();
17411
+ for (const { relativePath, content } of seedFiles) {
17412
+ const fullPath = path14.join(agentDataDir, relativePath);
17413
+ try {
17414
+ await access(fullPath);
17415
+ } catch {
17416
+ await mkdir(path14.dirname(fullPath), { recursive: true });
17417
+ await writeFile(fullPath, content);
17418
+ }
17419
+ }
17420
+ }
17711
17421
  pendingStartRebind = this.lifecycleRecords.getPendingStartRebind(agentId);
17712
17422
  if (pendingStartRebind) {
17713
17423
  this.lifecycleRecords.deletePendingStartRebind(agentId);
@@ -17730,7 +17440,6 @@ var AgentProcessManager = class _AgentProcessManager {
17730
17440
  wakeMessageTransient = pendingStartRebind.wakeMessageTransient === true;
17731
17441
  }
17732
17442
  }
17733
- await provisionWorkspaceGitIdentity(agentDataDir, agentId, config.name);
17734
17443
  this.enterNoProcessResidency(
17735
17444
  "starting_process",
17736
17445
  this.noProcessResidencyIdentity(agentId, config, launchId, this.startLaunchSource(config, wakeMessage, resumePrompt)),
@@ -18480,26 +18189,36 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
18480
18189
  async buildSpawnConfig(agentId, config) {
18481
18190
  const baseConfig = config.serverUrl === this.serverUrl ? config : { ...config, serverUrl: this.serverUrl };
18482
18191
  const runnerConfig = await this.ensureManagedRunnerCredential(agentId, baseConfig);
18483
- let effectiveConfig = runnerConfig;
18484
- if (this.defaultAgentEnvVarsProvider) {
18485
- try {
18486
- const defaultEnvVars = await this.defaultAgentEnvVarsProvider({
18487
- runtime: runnerConfig.runtime,
18488
- model: runnerConfig.model,
18489
- envVars: runnerConfig.envVars
18490
- });
18491
- const mergedEnvVars = { ...defaultEnvVars ?? {}, ...runnerConfig.envVars ?? {} };
18492
- if (!this.sameEnvVars(mergedEnvVars, runnerConfig.envVars)) {
18493
- effectiveConfig = { ...runnerConfig, envVars: mergedEnvVars };
18494
- }
18495
- } catch (error) {
18496
- const reason = error instanceof Error ? error.message : String(error);
18497
- logger.warn(
18498
- `[Agent ${agentId}] Failed to resolve default runtime env vars \u2014 continuing without machine-level defaults (${reason})`
18499
- );
18192
+ if (!this.defaultAgentEnvVarsProvider) {
18193
+ return runnerConfig;
18194
+ }
18195
+ try {
18196
+ const defaultEnvVars = await this.defaultAgentEnvVarsProvider({
18197
+ runtime: runnerConfig.runtime,
18198
+ model: runnerConfig.model,
18199
+ envVars: runnerConfig.envVars
18200
+ });
18201
+ if (!defaultEnvVars || Object.keys(defaultEnvVars).length === 0) {
18202
+ return runnerConfig;
18203
+ }
18204
+ const mergedEnvVars = {
18205
+ ...defaultEnvVars,
18206
+ ...runnerConfig.envVars ?? {}
18207
+ };
18208
+ if (this.sameEnvVars(mergedEnvVars, runnerConfig.envVars)) {
18209
+ return runnerConfig;
18500
18210
  }
18211
+ return {
18212
+ ...runnerConfig,
18213
+ envVars: mergedEnvVars
18214
+ };
18215
+ } catch (error) {
18216
+ const reason = error instanceof Error ? error.message : String(error);
18217
+ logger.warn(
18218
+ `[Agent ${agentId}] Failed to resolve default runtime env vars \u2014 continuing without machine-level defaults (${reason})`
18219
+ );
18220
+ return runnerConfig;
18501
18221
  }
18502
- return withProvisionSignedGitEnv(effectiveConfig);
18503
18222
  }
18504
18223
  async requestManagedRunnerCredentialOnce(agentId, config) {
18505
18224
  const url = new URL(`/internal/computer/runners/${encodeURIComponent(agentId)}/credentials`, this.serverUrl);
@@ -19238,7 +18957,7 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19238
18957
  return true;
19239
18958
  }
19240
18959
  async resetWorkspace(agentId) {
19241
- const agentDataDir = path15.join(this.dataDir, agentId);
18960
+ const agentDataDir = path14.join(this.dataDir, agentId);
19242
18961
  try {
19243
18962
  await rm2(agentDataDir, { recursive: true, force: true });
19244
18963
  logger.info(`[Agent ${agentId}] Workspace reset complete (${agentDataDir})`);
@@ -19320,7 +19039,7 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19320
19039
  return result;
19321
19040
  }
19322
19041
  buildRuntimeProfileReport(agentId, config, sessionId, launchId, observedRuntimeHomeDir, processInstanceId) {
19323
- const workspacePath = path15.join(this.dataDir, agentId);
19042
+ const workspacePath = path14.join(this.dataDir, agentId);
19324
19043
  const runtimeHomeDir = observedRuntimeHomeDir || resolveRuntimeHomeDir(config, this.runtimeSessionHomeDir, workspacePath, { agentId, slockHome: this.slockHome });
19325
19044
  return {
19326
19045
  agentId,
@@ -19656,7 +19375,7 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19656
19375
  }
19657
19376
  // Workspace file browsing
19658
19377
  async getFileTree(agentId, dirPath, includeHidden = false) {
19659
- const agentDir = path15.join(this.dataDir, agentId);
19378
+ const agentDir = path14.join(this.dataDir, agentId);
19660
19379
  try {
19661
19380
  await stat2(agentDir);
19662
19381
  } catch {
@@ -19664,11 +19383,11 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19664
19383
  }
19665
19384
  let targetDir = agentDir;
19666
19385
  if (dirPath) {
19667
- const resolved = path15.resolve(agentDir, dirPath);
19668
- if (!resolved.startsWith(agentDir + path15.sep) && resolved !== agentDir) {
19386
+ const resolved = path14.resolve(agentDir, dirPath);
19387
+ if (!resolved.startsWith(agentDir + path14.sep) && resolved !== agentDir) {
19669
19388
  return [];
19670
19389
  }
19671
- const relativePath = path15.relative(agentDir, resolved);
19390
+ const relativePath = path14.relative(agentDir, resolved);
19672
19391
  if (isWorkspaceNeverVisibleHiddenPath(relativePath)) {
19673
19392
  return [];
19674
19393
  }
@@ -19680,18 +19399,18 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19680
19399
  return this.listDirectoryChildren(targetDir, agentDir, includeHidden);
19681
19400
  }
19682
19401
  async readFile(agentId, filePath) {
19683
- const agentDir = path15.join(this.dataDir, agentId);
19684
- const resolved = path15.resolve(agentDir, filePath);
19685
- if (!resolved.startsWith(agentDir + path15.sep) && resolved !== agentDir) {
19402
+ const agentDir = path14.join(this.dataDir, agentId);
19403
+ const resolved = path14.resolve(agentDir, filePath);
19404
+ if (!resolved.startsWith(agentDir + path14.sep) && resolved !== agentDir) {
19686
19405
  throw new Error("Access denied");
19687
19406
  }
19688
- const relativePath = path15.relative(agentDir, resolved);
19407
+ const relativePath = path14.relative(agentDir, resolved);
19689
19408
  if (isWorkspaceNeverVisibleHiddenPath(relativePath) || isWorkspaceSecretFilePath(relativePath)) {
19690
19409
  throw new Error("Preview is disabled for sensitive workspace files");
19691
19410
  }
19692
19411
  const info = await stat2(resolved);
19693
19412
  if (info.isDirectory()) throw new Error("Cannot read a directory");
19694
- const ext = path15.extname(resolved).toLowerCase();
19413
+ const ext = path14.extname(resolved).toLowerCase();
19695
19414
  if (WORKSPACE_TEXT_EXTENSIONS.has(ext) || ext === "") {
19696
19415
  if (info.size > WORKSPACE_TEXT_FILE_MAX_BYTES) throw new Error("File too large");
19697
19416
  const content = await readFile(resolved, "utf-8");
@@ -19742,7 +19461,7 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19742
19461
  };
19743
19462
  }
19744
19463
  const runtime = config.runtime;
19745
- const workspaceDir = path15.join(this.dataDir, agentId);
19464
+ const workspaceDir = path14.join(this.dataDir, agentId);
19746
19465
  const homeDir = agent?.runtime.currentRuntimeHomeDir || ensureRuntimeHomeDir(config, this.runtimeSessionHomeDir, workspaceDir, { agentId, slockHome: this.slockHome });
19747
19466
  if (!actualSessionId) {
19748
19467
  return {
@@ -19783,7 +19502,7 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19783
19502
  let redacted = false;
19784
19503
  if (ref.reachable && ref.path) {
19785
19504
  try {
19786
- const resolved = path15.resolve(ref.path);
19505
+ const resolved = path14.resolve(ref.path);
19787
19506
  const allowedRoots = allowedTranscriptRootsForRuntime(runtime, homeDir, workspaceDir);
19788
19507
  if (!await isPathWithinAllowedRoots(resolved, allowedRoots)) {
19789
19508
  throw new Error("resolved session path is outside allowed runtime directories");
@@ -19794,7 +19513,7 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19794
19513
  throw new Error("symbolic links are not allowed");
19795
19514
  }
19796
19515
  if (info.isDirectory()) {
19797
- targetPath = path15.join(resolved, "state.json");
19516
+ targetPath = path14.join(resolved, "state.json");
19798
19517
  }
19799
19518
  if (!await isPathWithinAllowedRoots(targetPath, allowedRoots)) {
19800
19519
  throw new Error("resolved session state path is outside allowed runtime directories");
@@ -19906,17 +19625,17 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19906
19625
  const idle = this.lifecycleRecords.getRestartSnapshot(agentId);
19907
19626
  const config = agent?.config ?? idle?.config ?? null;
19908
19627
  const runtime = runtimeHint || config?.runtime || "claude";
19909
- const workspaceDir = path15.join(this.dataDir, agentId);
19628
+ const workspaceDir = path14.join(this.dataDir, agentId);
19910
19629
  const hostHome = os6.homedir();
19911
19630
  const home = agent?.runtime.currentRuntimeHomeDir || (config ? ensureRuntimeHomeDir(config, hostHome, workspaceDir, { agentId, slockHome: this.slockHome }) : runtime === "codex" ? resolveCodexHomeRootFromEnv(process.env, { defaultHomeDir: hostHome, cwd: workspaceDir }) : hostHome);
19912
19631
  const paths = _AgentProcessManager.SKILL_PATHS[runtime] || _AgentProcessManager.SKILL_PATHS.claude;
19913
19632
  const globalDirs = runtime === "codex" ? [
19914
- path15.join(home, "skills"),
19915
- path15.join(home, "skills", ".system"),
19916
- path15.join(home, ".agents", "skills"),
19917
- ...hasConfiguredCodexHome(config) ? [] : [path15.join(hostHome, ".agents", "skills")]
19918
- ] : paths.global.map((p) => path15.join(home, p));
19919
- const workspaceDirs = paths.workspace.map((p) => path15.join(workspaceDir, p));
19633
+ path14.join(home, "skills"),
19634
+ path14.join(home, "skills", ".system"),
19635
+ path14.join(home, ".agents", "skills"),
19636
+ ...hasConfiguredCodexHome(config) ? [] : [path14.join(hostHome, ".agents", "skills")]
19637
+ ] : paths.global.map((p) => path14.join(home, p));
19638
+ const workspaceDirs = paths.workspace.map((p) => path14.join(workspaceDir, p));
19920
19639
  const globalResults = await Promise.all(
19921
19640
  globalDirs.map((dir) => this.scanSkillsDir(dir))
19922
19641
  );
@@ -19943,14 +19662,14 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19943
19662
  async scanSkillsDir(dir) {
19944
19663
  let entries;
19945
19664
  try {
19946
- entries = await readdir3(dir, { withFileTypes: true });
19665
+ entries = await readdir2(dir, { withFileTypes: true });
19947
19666
  } catch {
19948
19667
  return [];
19949
19668
  }
19950
19669
  const skills = [];
19951
19670
  for (const entry of entries) {
19952
19671
  if (entry.isDirectory() || entry.isSymbolicLink()) {
19953
- const skillMd = path15.join(dir, entry.name, "SKILL.md");
19672
+ const skillMd = path14.join(dir, entry.name, "SKILL.md");
19954
19673
  try {
19955
19674
  const content = await readFile(skillMd, "utf-8");
19956
19675
  const skill = this.parseSkillMd(entry.name, content);
@@ -19961,7 +19680,7 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
19961
19680
  } else if (entry.name.endsWith(".md")) {
19962
19681
  const cmdName = entry.name.replace(/\.md$/, "");
19963
19682
  try {
19964
- const content = await readFile(path15.join(dir, entry.name), "utf-8");
19683
+ const content = await readFile(path14.join(dir, entry.name), "utf-8");
19965
19684
  const skill = this.parseSkillMd(cmdName, content);
19966
19685
  skill.sourcePath = dir;
19967
19686
  skills.push(skill);
@@ -22029,7 +21748,7 @@ ${RESPONSE_TARGET_HINT}`);
22029
21748
  async listDirectoryChildren(dir, rootDir, includeHidden = false) {
22030
21749
  let entries;
22031
21750
  try {
22032
- entries = await readdir3(dir, { withFileTypes: true });
21751
+ entries = await readdir2(dir, { withFileTypes: true });
22033
21752
  } catch {
22034
21753
  return [];
22035
21754
  }
@@ -22043,8 +21762,8 @@ ${RESPONSE_TARGET_HINT}`);
22043
21762
  const isHidden = entry.name.startsWith(".");
22044
21763
  if (entry.name === "node_modules") continue;
22045
21764
  if (isHidden && (!includeHidden || isWorkspaceNeverVisibleHiddenEntry(entry.name))) continue;
22046
- const fullPath = path15.join(dir, entry.name);
22047
- const relativePath = path15.relative(rootDir, fullPath);
21765
+ const fullPath = path14.join(dir, entry.name);
21766
+ const relativePath = path14.relative(rootDir, fullPath);
22048
21767
  let info;
22049
21768
  try {
22050
21769
  info = await stat2(fullPath);
@@ -22513,7 +22232,7 @@ var ReminderCache = class {
22513
22232
  import { createHash as createHash4, randomUUID as randomUUID7 } from "crypto";
22514
22233
  import { mkdirSync as mkdirSync5, readFileSync as readFileSync7, rmSync as rmSync3, statSync as statSync2, writeFileSync as writeFileSync5 } from "fs";
22515
22234
  import os7 from "os";
22516
- import path16 from "path";
22235
+ import path15 from "path";
22517
22236
  var INCOMPLETE_LOCK_STALE_MS = 3e4;
22518
22237
  var DaemonMachineLockConflictError = class extends Error {
22519
22238
  code = "DAEMON_MACHINE_LOCK_HELD";
@@ -22535,7 +22254,7 @@ function resolveDefaultMachineStateRoot() {
22535
22254
  return resolveSlockHomePath("machines");
22536
22255
  }
22537
22256
  function ownerPath(lockDir) {
22538
- return path16.join(lockDir, "owner.json");
22257
+ return path15.join(lockDir, "owner.json");
22539
22258
  }
22540
22259
  function readOwner(lockDir) {
22541
22260
  try {
@@ -22565,8 +22284,8 @@ function acquireDaemonMachineLock(options) {
22565
22284
  const rootDir = options.rootDir ?? resolveDefaultMachineStateRoot();
22566
22285
  const fingerprint = apiKeyFingerprint(options.apiKey);
22567
22286
  const lockId = getDaemonMachineLockId(options.apiKey);
22568
- const machineDir = path16.join(rootDir, lockId);
22569
- const lockDir = path16.join(machineDir, "daemon.lock");
22287
+ const machineDir = path15.join(rootDir, lockId);
22288
+ const lockDir = path15.join(machineDir, "daemon.lock");
22570
22289
  const token = randomUUID7();
22571
22290
  mkdirSync5(machineDir, { recursive: true });
22572
22291
  for (let attempt = 0; attempt < 2; attempt += 1) {
@@ -22627,7 +22346,7 @@ function acquireDaemonMachineLock(options) {
22627
22346
 
22628
22347
  // ../trace-client/src/localTraceSink.ts
22629
22348
  import { appendFileSync, mkdirSync as mkdirSync6, readdirSync as readdirSync5, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "fs";
22630
- import path17 from "path";
22349
+ import path16 from "path";
22631
22350
  var DEFAULT_MAX_FILE_BYTES = 5 * 1024 * 1024;
22632
22351
  var DEFAULT_MAX_FILE_AGE_MS = 5 * 60 * 1e3;
22633
22352
  var DEFAULT_MAX_FILES = 8;
@@ -22672,7 +22391,7 @@ var LocalRotatingTraceSink = class {
22672
22391
  currentSize = 0;
22673
22392
  sequence = 0;
22674
22393
  constructor(options) {
22675
- this.traceDir = path17.join(options.machineDir, "traces");
22394
+ this.traceDir = path16.join(options.machineDir, "traces");
22676
22395
  this.maxFileBytes = Math.max(1024, Math.floor(options.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES));
22677
22396
  const baseAgeMs = Math.max(1e3, Math.floor(options.maxFileAgeMs ?? DEFAULT_MAX_FILE_AGE_MS));
22678
22397
  const ageJitterMs = Math.max(0, Math.floor(options.maxFileAgeJitterMs ?? 0));
@@ -22702,7 +22421,7 @@ var LocalRotatingTraceSink = class {
22702
22421
  const nowMs = this.nowMsProvider();
22703
22422
  const shouldRotateForAge = this.currentFileOpenedAtMs !== null && nowMs - this.currentFileOpenedAtMs >= this.maxFileAgeMs;
22704
22423
  if (!this.currentFile || this.currentSize + nextBytes > this.maxFileBytes || shouldRotateForAge) {
22705
- this.currentFile = path17.join(
22424
+ this.currentFile = path16.join(
22706
22425
  this.traceDir,
22707
22426
  `daemon-trace-${safeTimestamp(nowMs)}-${process.pid}-${String(this.sequence++).padStart(4, "0")}.jsonl`
22708
22427
  );
@@ -22717,7 +22436,7 @@ var LocalRotatingTraceSink = class {
22717
22436
  const excess = files.length - this.maxFiles;
22718
22437
  if (excess <= 0) return;
22719
22438
  for (const file of files.slice(0, excess)) {
22720
- rmSync4(path17.join(this.traceDir, file), { force: true });
22439
+ rmSync4(path16.join(this.traceDir, file), { force: true });
22721
22440
  }
22722
22441
  }
22723
22442
  };
@@ -22893,8 +22612,8 @@ function createTraceClient(options) {
22893
22612
  // src/traceBundleUpload.ts
22894
22613
  import { createHash as createHash6, randomUUID as randomUUID8 } from "crypto";
22895
22614
  import { gzipSync as gzipSync2 } from "zlib";
22896
- import { mkdir as mkdir2, readFile as readFile2, readdir as readdir4, stat as stat3, writeFile as writeFile2 } from "fs/promises";
22897
- import path18 from "path";
22615
+ import { mkdir as mkdir2, readFile as readFile2, readdir as readdir3, stat as stat3, writeFile as writeFile2 } from "fs/promises";
22616
+ import path17 from "path";
22898
22617
  var TRACE_UPLOAD_SCOPE = "daemon-trace-bundle:create";
22899
22618
  var DEFAULT_UPLOAD_INTERVAL_MS = 5 * 60 * 1e3;
22900
22619
  var DEFAULT_MIN_FILE_AGE_MS = 60 * 1e3;
@@ -22977,10 +22696,10 @@ var DaemonTraceBundleUploader = class {
22977
22696
  }, nextMs);
22978
22697
  }
22979
22698
  async findUploadCandidates() {
22980
- const traceDir = path18.join(this.options.machineDir, "traces");
22699
+ const traceDir = path17.join(this.options.machineDir, "traces");
22981
22700
  let names;
22982
22701
  try {
22983
- names = await readdir4(traceDir);
22702
+ names = await readdir3(traceDir);
22984
22703
  } catch {
22985
22704
  return [];
22986
22705
  }
@@ -22989,8 +22708,8 @@ var DaemonTraceBundleUploader = class {
22989
22708
  const currentFile = this.options.currentFileProvider?.();
22990
22709
  const candidates = [];
22991
22710
  for (const name of names.filter((entry) => entry.startsWith("daemon-trace-") && entry.endsWith(".jsonl")).sort()) {
22992
- const file = path18.join(traceDir, name);
22993
- if (currentFile && path18.resolve(file) === path18.resolve(currentFile)) continue;
22711
+ const file = path17.join(traceDir, name);
22712
+ if (currentFile && path17.resolve(file) === path17.resolve(currentFile)) continue;
22994
22713
  if (await this.isUploaded(file)) continue;
22995
22714
  try {
22996
22715
  const info = await stat3(file);
@@ -23068,8 +22787,8 @@ var DaemonTraceBundleUploader = class {
23068
22787
  }
23069
22788
  }
23070
22789
  uploadStatePath(file) {
23071
- const stateDir = path18.join(this.options.machineDir, "trace-uploads");
23072
- return path18.join(stateDir, `${path18.basename(file)}.uploaded.json`);
22790
+ const stateDir = path17.join(this.options.machineDir, "trace-uploads");
22791
+ return path17.join(stateDir, `${path17.basename(file)}.uploaded.json`);
23073
22792
  }
23074
22793
  async isUploaded(file) {
23075
22794
  try {
@@ -23081,9 +22800,9 @@ var DaemonTraceBundleUploader = class {
23081
22800
  }
23082
22801
  async markUploaded(file, metadata) {
23083
22802
  const stateFile = this.uploadStatePath(file);
23084
- await mkdir2(path18.dirname(stateFile), { recursive: true, mode: 448 });
22803
+ await mkdir2(path17.dirname(stateFile), { recursive: true, mode: 448 });
23085
22804
  await writeFile2(stateFile, `${JSON.stringify({
23086
- file: path18.basename(file),
22805
+ file: path17.basename(file),
23087
22806
  uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
23088
22807
  ...metadata
23089
22808
  }, null, 2)}
@@ -23102,7 +22821,7 @@ function readPositiveIntegerEnv2(name, fallback) {
23102
22821
 
23103
22822
  // src/computerMigrationGuard.ts
23104
22823
  import { existsSync as existsSync9, readdirSync as readdirSync6, readFileSync as readFileSync9 } from "fs";
23105
- import path19 from "path";
22824
+ import path18 from "path";
23106
22825
 
23107
22826
  // src/legacySupervisor.ts
23108
22827
  import { execFileSync as execFileSync4 } from "child_process";
@@ -23289,7 +23008,7 @@ function daemonApiKeyFingerprint(apiKey) {
23289
23008
  return getDaemonMachineLockId(apiKey).slice("machine-".length);
23290
23009
  }
23291
23010
  function findAdoptedComputerForLegacyFingerprint(slockHome, legacyApiKeyFingerprint) {
23292
- const serversDir = path19.join(slockHome, "computer", "servers");
23011
+ const serversDir = path18.join(slockHome, "computer", "servers");
23293
23012
  if (!existsSync9(serversDir)) return null;
23294
23013
  let serverDirs;
23295
23014
  try {
@@ -23298,7 +23017,7 @@ function findAdoptedComputerForLegacyFingerprint(slockHome, legacyApiKeyFingerpr
23298
23017
  return null;
23299
23018
  }
23300
23019
  for (const serverId of serverDirs) {
23301
- const attachmentPath = path19.join(serversDir, serverId, "runner.state.json");
23020
+ const attachmentPath = path18.join(serversDir, serverId, "runner.state.json");
23302
23021
  let raw;
23303
23022
  try {
23304
23023
  raw = readFileSync9(attachmentPath, "utf8");
@@ -23849,7 +23568,7 @@ function onceDrain(res) {
23849
23568
  import { createHash as createHash9 } from "crypto";
23850
23569
  import { createReadStream as createReadStream2, createWriteStream } from "fs";
23851
23570
  import { lstat as lstat3, mkdir as mkdir3, readlink as readlink2, rm as rm3, symlink } from "fs/promises";
23852
- import path21 from "path";
23571
+ import path20 from "path";
23853
23572
  import { Transform } from "stream";
23854
23573
  import { pipeline } from "stream/promises";
23855
23574
  import { createGunzip, createGzip } from "zlib";
@@ -23858,8 +23577,8 @@ import { extract, pack } from "tar-stream";
23858
23577
  // src/agentMigrationExport.ts
23859
23578
  import { createHash as createHash8 } from "crypto";
23860
23579
  import { createReadStream } from "fs";
23861
- import { lstat as lstat2, readdir as readdir5, readFile as readFile3, readlink } from "fs/promises";
23862
- import path20 from "path";
23580
+ import { lstat as lstat2, readdir as readdir4, readFile as readFile3, readlink } from "fs/promises";
23581
+ import path19 from "path";
23863
23582
  var AGENT_MIGRATION_BUNDLE_SCHEMA_VERSION = "agent-bundle/v1";
23864
23583
  var REGENERABLE_DIRECTORY_NAMES = [
23865
23584
  ".cache",
@@ -23883,8 +23602,8 @@ var SECRET_FILE_NAMES = /* @__PURE__ */ new Set([
23883
23602
  ]);
23884
23603
  var ENV_KEY_PATTERN = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/;
23885
23604
  async function buildAgentMigrationExportManifest(input) {
23886
- const slockHome = path20.resolve(input.slockHome);
23887
- const workspace = path20.resolve(input.workspacePath ?? path20.join(slockHome, "agents", input.agentId));
23605
+ const slockHome = path19.resolve(input.slockHome);
23606
+ const workspace = path19.resolve(input.workspacePath ?? path19.join(slockHome, "agents", input.agentId));
23888
23607
  const proposedIncludes = normalizeProposalPaths(input.cooperativeManifest?.include, workspace, "include");
23889
23608
  const proposedRegenerableExcludes = normalizeProposalPaths(input.cooperativeManifest?.exclude_regenerable, workspace, "exclude_regenerable");
23890
23609
  const cleanedProposal = normalizeProposalPaths(input.cooperativeManifest?.cleaned, workspace, "cleaned");
@@ -23945,10 +23664,10 @@ async function buildAgentMigrationExportManifest(input) {
23945
23664
  };
23946
23665
  }
23947
23666
  async function walkWorkspace(root, relativeDir, proposedRegenerableExcludes, state, opts) {
23948
- const absoluteDir = path20.join(root, relativeDir);
23667
+ const absoluteDir = path19.join(root, relativeDir);
23949
23668
  let entries;
23950
23669
  try {
23951
- entries = await readdir5(absoluteDir, { withFileTypes: true });
23670
+ entries = await readdir4(absoluteDir, { withFileTypes: true });
23952
23671
  } catch {
23953
23672
  state.unreachable.push({
23954
23673
  path: relativeDir || ".",
@@ -23959,7 +23678,7 @@ async function walkWorkspace(root, relativeDir, proposedRegenerableExcludes, sta
23959
23678
  }
23960
23679
  entries.sort((a, b) => a.name.localeCompare(b.name));
23961
23680
  for (const entry of entries) {
23962
- const relativePath = toPosixPath(path20.join(relativeDir, entry.name));
23681
+ const relativePath = toPosixPath(path19.join(relativeDir, entry.name));
23963
23682
  if (entry.isDirectory()) {
23964
23683
  if (!opts.forceIncludeRegenerable && isRegenerablePath(relativePath)) {
23965
23684
  if (state.explicitIncludePaths.has(relativePath)) {
@@ -23986,7 +23705,7 @@ async function walkWorkspace(root, relativeDir, proposedRegenerableExcludes, sta
23986
23705
  async function includeWorkspacePath(workspaceRelativePath, state, opts) {
23987
23706
  const normalizedRelativePath = normalizeRelativePath(workspaceRelativePath);
23988
23707
  if (state.seenWorkspacePaths.has(normalizedRelativePath)) return;
23989
- const sourcePath = path20.join(state.workspace, normalizedRelativePath);
23708
+ const sourcePath = path19.join(state.workspace, normalizedRelativePath);
23990
23709
  let stat5;
23991
23710
  try {
23992
23711
  stat5 = await lstat2(sourcePath);
@@ -24003,7 +23722,7 @@ async function includeWorkspacePath(workspaceRelativePath, state, opts) {
24003
23722
  state.excludedRegenerable.push({
24004
23723
  path: normalizedRelativePath,
24005
23724
  reason: "cooperative_exclude_regenerable",
24006
- regenerableHint: `${path20.basename(normalizedRelativePath)} is treated as rebuildable/installable state and is not bundled by default`
23725
+ regenerableHint: `${path19.basename(normalizedRelativePath)} is treated as rebuildable/installable state and is not bundled by default`
24007
23726
  });
24008
23727
  return;
24009
23728
  }
@@ -24050,8 +23769,8 @@ async function includeWorkspacePath(workspaceRelativePath, state, opts) {
24050
23769
  async function buildCrossTreeRefs(refs) {
24051
23770
  const result = [];
24052
23771
  for (const ref of refs) {
24053
- const sourcePath = path20.resolve(ref.path);
24054
- const bundlePath = `runtime/${safeBundleSegment(ref.runtime)}/${safeBundleSegment(ref.label)}/${safeBundleSegment(path20.basename(sourcePath) || "session")}`;
23772
+ const sourcePath = path19.resolve(ref.path);
23773
+ const bundlePath = `runtime/${safeBundleSegment(ref.runtime)}/${safeBundleSegment(ref.label)}/${safeBundleSegment(path19.basename(sourcePath) || "session")}`;
24055
23774
  const entry = {
24056
23775
  runtime: ref.runtime,
24057
23776
  label: ref.label,
@@ -24084,7 +23803,7 @@ async function sha256File(filePath) {
24084
23803
  return hash.digest("hex");
24085
23804
  }
24086
23805
  async function detectSecretShapes(sourcePath, relativePath) {
24087
- const basename = path20.basename(relativePath);
23806
+ const basename = path19.basename(relativePath);
24088
23807
  const lowerBasename = basename.toLowerCase();
24089
23808
  const shapes = /* @__PURE__ */ new Set();
24090
23809
  if (SECRET_FILE_NAMES.has(lowerBasename) || lowerBasename.startsWith(".env.")) {
@@ -24117,9 +23836,9 @@ function normalizeProposalPaths(paths, workspace, source) {
24117
23836
  for (const value of paths) {
24118
23837
  const trimmed = value.trim();
24119
23838
  if (!trimmed) continue;
24120
- if (path20.isAbsolute(trimmed)) {
24121
- const relative = path20.relative(workspace, trimmed);
24122
- if (relative.startsWith("..") || path20.isAbsolute(relative)) {
23839
+ if (path19.isAbsolute(trimmed)) {
23840
+ const relative = path19.relative(workspace, trimmed);
23841
+ if (relative.startsWith("..") || path19.isAbsolute(relative)) {
24123
23842
  refusals.push({
24124
23843
  path: trimmed,
24125
23844
  reason: "outside_workspace",
@@ -24151,8 +23870,8 @@ function normalizeProposalPaths(paths, workspace, source) {
24151
23870
  return { paths: [...new Set(result)], refusals };
24152
23871
  }
24153
23872
  function normalizeRelativePath(value) {
24154
- const normalized = path20.normalize(value).replace(/^[\\/]+/, "");
24155
- if (!normalized || normalized === "." || normalized.startsWith("..") || path20.isAbsolute(normalized)) {
23873
+ const normalized = path19.normalize(value).replace(/^[\\/]+/, "");
23874
+ if (!normalized || normalized === "." || normalized.startsWith("..") || path19.isAbsolute(normalized)) {
24156
23875
  throw new Error(`unsafe migration export path: ${value}`);
24157
23876
  }
24158
23877
  return toPosixPath(normalized);
@@ -24171,7 +23890,7 @@ function safeBundleSegment(value) {
24171
23890
  return value.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "unknown";
24172
23891
  }
24173
23892
  function toPosixPath(value) {
24174
- return value.split(path20.sep).join("/");
23893
+ return value.split(path19.sep).join("/");
24175
23894
  }
24176
23895
  function sortBundleEntries(entries) {
24177
23896
  return [...entries].sort((a, b) => a.bundlePath.localeCompare(b.bundlePath));
@@ -24200,7 +23919,7 @@ var AgentMigrationObjectStoreBundleTooLargeError = class extends Error {
24200
23919
  };
24201
23920
  async function buildAgentMigrationObjectStoreBundle(input) {
24202
23921
  assertPositiveMaxBytes(input.maxBytes);
24203
- const workspacePath = path21.resolve(input.workspacePath);
23922
+ const workspacePath = path20.resolve(input.workspacePath);
24204
23923
  const manifest = await buildAgentMigrationExportManifest({
24205
23924
  agentId: input.agentId,
24206
23925
  slockHome: input.slockHome,
@@ -24233,8 +23952,8 @@ async function buildAgentMigrationObjectStoreBundle(input) {
24233
23952
  }
24234
23953
  async function stageAgentMigrationObjectStoreBundle(input) {
24235
23954
  assertPositiveMaxBytes(input.maxBytes);
24236
- const stagingWorkspacePath = path21.join(
24237
- path21.resolve(input.slockHome),
23955
+ const stagingWorkspacePath = path20.join(
23956
+ path20.resolve(input.slockHome),
24238
23957
  "migrations",
24239
23958
  sanitizePathSegment(input.sessionId),
24240
23959
  "workspace"
@@ -24306,7 +24025,7 @@ async function writeArchive(tarPack, manifestBuffer, manifest, workspacePath) {
24306
24025
  throw new Error("MIGRATION_OBJECT_STORE_UNSUPPORTED_ENTRY");
24307
24026
  }
24308
24027
  const relativePath = normalizeWorkspaceRelativePath(entry.workspaceRelativePath);
24309
- const sourcePath = path21.resolve(entry.sourcePath);
24028
+ const sourcePath = path20.resolve(entry.sourcePath);
24310
24029
  const archivePath = `${ARCHIVE_WORKSPACE_PREFIX}${relativePath}`;
24311
24030
  if (entry.kind === "symlink") {
24312
24031
  await writeBufferedEntry(tarPack, {
@@ -24356,8 +24075,8 @@ async function handleArchiveEntry(input) {
24356
24075
  const expected = input.getExpectedEntries().get(relativePath);
24357
24076
  if (!expected) throw new Error(`MIGRATION_OBJECT_STORE_ARCHIVE_ENTRY_UNEXPECTED:${relativePath}`);
24358
24077
  input.extractedEntries.add(relativePath);
24359
- const targetPath = path21.join(input.stagingWorkspacePath, relativePath);
24360
- await mkdir3(path21.dirname(targetPath), { recursive: true });
24078
+ const targetPath = path20.join(input.stagingWorkspacePath, relativePath);
24079
+ await mkdir3(path20.dirname(targetPath), { recursive: true });
24361
24080
  if (expected.kind === "symlink") {
24362
24081
  if (input.header.type !== "symlink" || input.header.linkname !== expected.linkTarget) {
24363
24082
  throw new Error(`MIGRATION_OBJECT_STORE_LINK_TARGET_MISMATCH:${relativePath}`);
@@ -24474,8 +24193,8 @@ function encodeAccountingPath(value) {
24474
24193
  return encoded;
24475
24194
  }
24476
24195
  function normalizeWorkspaceRelativePath(relativePath) {
24477
- const normalized = path21.posix.normalize(relativePath.replaceAll("\\", "/"));
24478
- if (normalized === "." || normalized.startsWith("../") || normalized === ".." || path21.isAbsolute(normalized)) {
24196
+ const normalized = path20.posix.normalize(relativePath.replaceAll("\\", "/"));
24197
+ if (normalized === "." || normalized.startsWith("../") || normalized === ".." || path20.isAbsolute(normalized)) {
24479
24198
  throw new Error("MIGRATION_OBJECT_STORE_UNSAFE_PATH");
24480
24199
  }
24481
24200
  return normalized;
@@ -24536,15 +24255,15 @@ function sanitizePathSegment(value) {
24536
24255
  import { createHash as createHash10 } from "crypto";
24537
24256
  import { createReadStream as createReadStream3 } from "fs";
24538
24257
  import { access as access2, cp, lstat as lstat4, mkdir as mkdir4, readlink as readlink3, rename, writeFile as writeFile3 } from "fs/promises";
24539
- import path22 from "path";
24258
+ import path21 from "path";
24540
24259
  async function buildAgentMigrationAdoptPlan(input) {
24541
- const slockHome = path22.resolve(input.slockHome);
24260
+ const slockHome = path21.resolve(input.slockHome);
24542
24261
  let manifest;
24543
24262
  if (input.sourceKind === "orphan_directory" && !input.manifest) {
24544
24263
  manifest = await buildAgentMigrationExportManifest({
24545
24264
  agentId: input.agentId,
24546
24265
  slockHome,
24547
- workspacePath: path22.resolve(input.orphanWorkspacePath),
24266
+ workspacePath: path21.resolve(input.orphanWorkspacePath),
24548
24267
  mode: "forensic",
24549
24268
  now: input.now
24550
24269
  });
@@ -24557,11 +24276,11 @@ async function buildAgentMigrationAdoptPlan(input) {
24557
24276
  manifest,
24558
24277
  expectedAgentId: input.sourceKind === "orphan_directory" ? input.agentId : manifest.agentId
24559
24278
  });
24560
- const sourceWorkspacePath = path22.resolve(
24279
+ const sourceWorkspacePath = path21.resolve(
24561
24280
  input.sourceKind === "staged_bundle" ? input.stagingWorkspacePath : input.orphanWorkspacePath
24562
24281
  );
24563
- const finalWorkspacePath = path22.resolve(input.finalWorkspacePath ?? path22.join(slockHome, "agents", manifest.agentId));
24564
- const reportPath = path22.resolve(input.reportPath ?? path22.join(
24282
+ const finalWorkspacePath = path21.resolve(input.finalWorkspacePath ?? path21.join(slockHome, "agents", manifest.agentId));
24283
+ const reportPath = path21.resolve(input.reportPath ?? path21.join(
24565
24284
  slockHome,
24566
24285
  "migrations",
24567
24286
  sanitizePathSegment2(input.generation.grantKey),
@@ -24686,7 +24405,7 @@ async function verifyManifestFileEntry(sourceWorkspacePath, entry) {
24686
24405
  throw new Error("MIGRATION_MANIFEST_ENTRY_NOT_WORKSPACE");
24687
24406
  }
24688
24407
  const relative = normalizeWorkspaceRelativePath2(entry.workspaceRelativePath);
24689
- const entryPath = path22.join(sourceWorkspacePath, relative);
24408
+ const entryPath = path21.join(sourceWorkspacePath, relative);
24690
24409
  const info = await lstat4(entryPath).catch(() => null);
24691
24410
  if (!info) throw new Error("MIGRATION_MANIFEST_FILE_MISSING");
24692
24411
  if (entry.kind === "symlink") {
@@ -24705,14 +24424,14 @@ async function verifyManifestFileEntry(sourceWorkspacePath, entry) {
24705
24424
  }
24706
24425
  }
24707
24426
  function normalizeWorkspaceRelativePath2(relativePath) {
24708
- const normalized = path22.posix.normalize(relativePath.replaceAll("\\", "/"));
24709
- if (normalized === "." || normalized.startsWith("../") || normalized === ".." || path22.isAbsolute(normalized)) {
24427
+ const normalized = path21.posix.normalize(relativePath.replaceAll("\\", "/"));
24428
+ if (normalized === "." || normalized.startsWith("../") || normalized === ".." || path21.isAbsolute(normalized)) {
24710
24429
  throw new Error("MIGRATION_MANIFEST_UNSAFE_PATH");
24711
24430
  }
24712
24431
  return normalized;
24713
24432
  }
24714
24433
  async function assertFinalWorkspaceAvailable(sourceWorkspacePath, finalWorkspacePath) {
24715
- if (path22.resolve(sourceWorkspacePath) === path22.resolve(finalWorkspacePath)) return;
24434
+ if (path21.resolve(sourceWorkspacePath) === path21.resolve(finalWorkspacePath)) return;
24716
24435
  try {
24717
24436
  await access2(finalWorkspacePath);
24718
24437
  throw new Error("MIGRATION_WORKSPACE_ALREADY_EXISTS");
@@ -24721,9 +24440,9 @@ async function assertFinalWorkspaceAvailable(sourceWorkspacePath, finalWorkspace
24721
24440
  }
24722
24441
  }
24723
24442
  async function placeWorkspace(sourceWorkspacePath, finalWorkspacePath) {
24724
- if (path22.resolve(sourceWorkspacePath) === path22.resolve(finalWorkspacePath)) return;
24443
+ if (path21.resolve(sourceWorkspacePath) === path21.resolve(finalWorkspacePath)) return;
24725
24444
  const stagingPath = `${finalWorkspacePath}.migration-${process.pid}-${Date.now()}`;
24726
- await mkdir4(path22.dirname(finalWorkspacePath), { recursive: true });
24445
+ await mkdir4(path21.dirname(finalWorkspacePath), { recursive: true });
24727
24446
  await cp(sourceWorkspacePath, stagingPath, {
24728
24447
  recursive: true,
24729
24448
  dereference: false,
@@ -24736,7 +24455,7 @@ async function placeWorkspace(sourceWorkspacePath, finalWorkspacePath) {
24736
24455
  async function writeArrivalReport(reportPath, report) {
24737
24456
  const payload = `${canonicalJson3(report)}
24738
24457
  `;
24739
- await mkdir4(path22.dirname(reportPath), { recursive: true });
24458
+ await mkdir4(path21.dirname(reportPath), { recursive: true });
24740
24459
  await writeFile3(reportPath, payload, { mode: 384 });
24741
24460
  return sha256Buffer3(Buffer.from(payload, "utf8"));
24742
24461
  }
@@ -24767,8 +24486,8 @@ function sanitizePathSegment2(value) {
24767
24486
  }
24768
24487
 
24769
24488
  // src/secretFile.ts
24770
- import { chmodSync as chmodSync2, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "fs";
24771
- import path23 from "path";
24489
+ import { chmodSync, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "fs";
24490
+ import path22 from "path";
24772
24491
  function readSecretFileSync(filePath) {
24773
24492
  return readFileSync10(filePath, "utf8").trim();
24774
24493
  }
@@ -25041,13 +24760,13 @@ function readDaemonVersion(moduleUrl = import.meta.url) {
25041
24760
  }
25042
24761
  }
25043
24762
  function resolveSlockCliPath(moduleUrl = import.meta.url) {
25044
- const thisDir = path24.dirname(fileURLToPath(moduleUrl));
25045
- const bundledDistPath = path24.resolve(thisDir, "cli", "index.js");
24763
+ const thisDir = path23.dirname(fileURLToPath(moduleUrl));
24764
+ const bundledDistPath = path23.resolve(thisDir, "cli", "index.js");
25046
24765
  try {
25047
24766
  accessSync(bundledDistPath);
25048
24767
  return bundledDistPath;
25049
24768
  } catch {
25050
- const workspaceDistPath = path24.resolve(thisDir, "..", "..", "cli", "dist", "index.js");
24769
+ const workspaceDistPath = path23.resolve(thisDir, "..", "..", "cli", "dist", "index.js");
25051
24770
  accessSync(workspaceDistPath);
25052
24771
  return workspaceDistPath;
25053
24772
  }
@@ -25061,7 +24780,7 @@ function resolveSlockCliPathOrEmpty(moduleUrl = import.meta.url) {
25061
24780
  }
25062
24781
  async function runBundledSlockCli(argv) {
25063
24782
  process.argv = [process.execPath, "slock", ...argv];
25064
- await import("./dist-FTGVGDYA.js");
24783
+ await import("./dist-54TOXXOV.js");
25065
24784
  }
25066
24785
  function detectRuntimes(tracer = noopTracer) {
25067
24786
  const ids = [];
@@ -25289,7 +25008,7 @@ var DaemonCore = class {
25289
25008
  }
25290
25009
  resolveMachineStateRoot() {
25291
25010
  if (this.options.machineStateDir) return this.options.machineStateDir;
25292
- if (this.options.dataDir) return path24.join(path24.dirname(this.options.dataDir), "machines");
25011
+ if (this.options.dataDir) return path23.join(path23.dirname(this.options.dataDir), "machines");
25293
25012
  return resolveDefaultMachineStateRoot();
25294
25013
  }
25295
25014
  shouldEnableLocalTrace() {
@@ -25317,7 +25036,7 @@ var DaemonCore = class {
25317
25036
  sinks: [this.localTraceSink]
25318
25037
  }));
25319
25038
  this.agentManager.setTracer(this.tracer);
25320
- this.agentManager.setCliTransportTraceDir(path24.join(machineDir, "traces"));
25039
+ this.agentManager.setCliTransportTraceDir(path23.join(machineDir, "traces"));
25321
25040
  }
25322
25041
  installTraceBundleUploader(machineDir) {
25323
25042
  if (!this.shouldEnableLocalTrace()) return;
@@ -25641,11 +25360,11 @@ var DaemonCore = class {
25641
25360
  const built = await buildAgentMigrationObjectStoreBundle({
25642
25361
  agentId: lease.agentId,
25643
25362
  slockHome: this.slockHome,
25644
- workspacePath: path24.join(this.agentsDataDir, lease.agentId),
25363
+ workspacePath: path23.join(this.agentsDataDir, lease.agentId),
25645
25364
  maxBytes: lease.maxBytes
25646
25365
  });
25647
- const spoolDirectory = await mkdtemp(path24.join(os8.tmpdir(), "raft-agent-migration-upload-"));
25648
- const spoolPath = path24.join(spoolDirectory, "bundle.tar.gz");
25366
+ const spoolDirectory = await mkdtemp(path23.join(os8.tmpdir(), "raft-agent-migration-upload-"));
25367
+ const spoolPath = path23.join(spoolDirectory, "bundle.tar.gz");
25649
25368
  let archiveBytes = 0;
25650
25369
  let uploadStatus = 0;
25651
25370
  try {
@@ -25708,7 +25427,7 @@ var DaemonCore = class {
25708
25427
  sourceKind: "staged_bundle",
25709
25428
  slockHome: this.slockHome,
25710
25429
  stagingWorkspacePath: staged.stagingWorkspacePath,
25711
- finalWorkspacePath: path24.join(this.agentsDataDir, lease.agentId),
25430
+ finalWorkspacePath: path23.join(this.agentsDataDir, lease.agentId),
25712
25431
  manifest: staged.manifest,
25713
25432
  manifestSha256: staged.manifestSha256,
25714
25433
  generation: {