@botiverse/raft-daemon 0.63.0 → 0.63.1-play.20260619141001

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.
@@ -1599,7 +1599,7 @@ var DISPLAY_PLAN_CONFIG = {
1599
1599
  var FREE_MONTHLY_FILE_UPLOAD_LIMIT_BYTES = 100 * 1024 * 1024;
1600
1600
 
1601
1601
  // src/agentProcessManager.ts
1602
- import { existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync6, readdirSync as readdirSync3, statSync, writeFileSync as writeFileSync4 } from "fs";
1602
+ import { existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync6, readdirSync as readdirSync3, statSync, writeFileSync as writeFileSync4 } from "fs";
1603
1603
  import { mkdir, writeFile, access, readdir as readdir2, stat as stat2, readFile, rm as rm2, lstat, realpath, open } from "fs/promises";
1604
1604
  import { createHash as createHash3, randomUUID as randomUUID5 } from "crypto";
1605
1605
  import path14 from "path";
@@ -2582,6 +2582,19 @@ function listLegacySlockStatePaths(slockHome = resolveSlockHome(), homeDir = os.
2582
2582
  return candidates.filter((candidate) => existsSync(candidate.path));
2583
2583
  }
2584
2584
 
2585
+ // src/authEnv.ts
2586
+ var DAEMON_API_KEY_ENV = "SLOCK_MACHINE_API_KEY";
2587
+ var SLOCK_AGENT_TOKEN_ENV = "SLOCK_AGENT_TOKEN";
2588
+ function scrubDaemonAuthEnv(env) {
2589
+ delete env[DAEMON_API_KEY_ENV];
2590
+ return env;
2591
+ }
2592
+ function scrubDaemonChildEnv(env) {
2593
+ delete env[DAEMON_API_KEY_ENV];
2594
+ delete env[SLOCK_AGENT_TOKEN_ENV];
2595
+ return env;
2596
+ }
2597
+
2585
2598
  // src/agentCredentialProxy.ts
2586
2599
  import { randomBytes } from "crypto";
2587
2600
  import http from "http";
@@ -4148,7 +4161,9 @@ var LOOPBACK_NO_PROXY = "127.0.0.1,localhost";
4148
4161
  var CLI_TRANSPORT_TRACE_DIR_ENV = "SLOCK_CLI_TRANSPORT_TRACE_DIR";
4149
4162
  var safePathPart = (value) => value.replace(/[^a-zA-Z0-9_.-]/g, "_");
4150
4163
  var RAW_CREDENTIAL_ENV_DENYLIST = [
4151
- "SLOCK_AGENT_CREDENTIAL_KEY"
4164
+ "SLOCK_AGENT_TOKEN",
4165
+ "SLOCK_AGENT_CREDENTIAL_KEY",
4166
+ "SLOCK_AGENT_CREDENTIAL_KEY_FILE"
4152
4167
  ];
4153
4168
  var WORKSPACE_CLI_TRANSPORT_FILENAMES = [
4154
4169
  "agent-token",
@@ -4500,7 +4515,7 @@ set "SLOCK_AGENT_ACTIVE_CAPABILITIES=${DEFAULT_ACTIVE_CAPABILITIES}"\r
4500
4515
  SLOCK_SERVER_URL: ctx.config.serverUrl,
4501
4516
  PATH: `${slockDir}${path2.delimiter}${process.env.PATH ?? ""}`
4502
4517
  };
4503
- delete spawnEnv.SLOCK_AGENT_TOKEN;
4518
+ scrubDaemonChildEnv(spawnEnv);
4504
4519
  for (const key of RAW_CREDENTIAL_ENV_DENYLIST) {
4505
4520
  delete spawnEnv[key];
4506
4521
  }
@@ -4933,7 +4948,7 @@ function requiresWindowsShell(command, platform = process.platform) {
4933
4948
  }
4934
4949
  function resolveCommandOnPath(command, deps = {}) {
4935
4950
  const platform = deps.platform ?? process.platform;
4936
- const env = withWindowsUserEnvironment(deps.env ?? process.env, deps);
4951
+ const env = scrubDaemonChildEnv({ ...withWindowsUserEnvironment(deps.env ?? process.env, deps) });
4937
4952
  const execFileSyncFn = deps.execFileSyncFn ?? execFileSync;
4938
4953
  const existsSyncFn = deps.existsSyncFn ?? existsSync3;
4939
4954
  if (platform === "win32") {
@@ -4959,7 +4974,7 @@ function firstExistingPath(candidates, deps = {}) {
4959
4974
  return null;
4960
4975
  }
4961
4976
  function readCommandVersion(command, args = [], deps = {}) {
4962
- const env = withWindowsUserEnvironment(deps.env ?? process.env, deps);
4977
+ const env = scrubDaemonChildEnv({ ...withWindowsUserEnvironment(deps.env ?? process.env, deps) });
4963
4978
  const execFileSyncFn = deps.execFileSyncFn ?? execFileSync;
4964
4979
  try {
4965
4980
  const output = normalizeExecOutput(execFileSyncFn(command, [...args, "--version"], {
@@ -5203,35 +5218,11 @@ import path7 from "path";
5203
5218
 
5204
5219
  // src/drivers/codexHome.ts
5205
5220
  import os3 from "os";
5206
- import { mkdirSync as mkdirSync3 } from "fs";
5207
5221
  import path6 from "path";
5208
5222
  function readConfiguredCodexHome(env) {
5209
5223
  const raw = env.CODEX_HOME;
5210
5224
  return typeof raw === "string" && raw.trim().length > 0 ? raw : null;
5211
5225
  }
5212
- function readNonEmpty(value) {
5213
- return typeof value === "string" && value.trim().length > 0 ? value : null;
5214
- }
5215
- function safeCodexHomePathPart(value) {
5216
- const safe = value.replace(/[^a-zA-Z0-9._-]/g, "_");
5217
- return safe.length > 0 ? safe : "agent";
5218
- }
5219
- function resolveSlockManagedCodexHome(slockHome, agentId) {
5220
- return path6.join(path6.resolve(slockHome), "codex-home", safeCodexHomePathPart(agentId));
5221
- }
5222
- function resolveDefaultCodexHomeRootForAgent(agentId, opts = {}) {
5223
- return resolveSlockManagedCodexHome(readNonEmpty(opts.slockHome) ?? resolveSlockHome(opts.env), agentId);
5224
- }
5225
- function applyDefaultCodexHomeToEnv(env, agentId, opts = {}) {
5226
- if (readConfiguredCodexHome(env)) return null;
5227
- const codexHome = resolveDefaultCodexHomeRootForAgent(agentId, {
5228
- slockHome: readNonEmpty(opts.slockHome) ?? readNonEmpty(env.SLOCK_HOME) ?? void 0,
5229
- env
5230
- });
5231
- mkdirSync3(codexHome, { recursive: true });
5232
- env.CODEX_HOME = codexHome;
5233
- return codexHome;
5234
- }
5235
5226
  function resolveCodexHomeRootFromEnv(env = process.env, opts = {}) {
5236
5227
  const raw = readConfiguredCodexHome(env);
5237
5228
  if (raw) {
@@ -5246,18 +5237,12 @@ function hasConfiguredCodexHome(config, baseEnv = process.env) {
5246
5237
  ...launchRuntimeFields?.envVars || {}
5247
5238
  }));
5248
5239
  }
5249
- function resolveCodexHomeRootFromConfig(config, defaultHomeDir, cwd, baseEnv = process.env, opts = {}) {
5240
+ function resolveCodexHomeRootFromConfig(config, defaultHomeDir, cwd, baseEnv = process.env, _opts = {}) {
5250
5241
  const launchRuntimeFields = runtimeConfigToLaunchFields(config);
5251
5242
  const env = {
5252
5243
  ...baseEnv,
5253
5244
  ...launchRuntimeFields.envVars || {}
5254
5245
  };
5255
- if (readConfiguredCodexHome(env)) {
5256
- return resolveCodexHomeRootFromEnv(env, { defaultHomeDir, cwd });
5257
- }
5258
- if (opts.agentId) {
5259
- return resolveDefaultCodexHomeRootForAgent(opts.agentId, { slockHome: opts.slockHome, env });
5260
- }
5261
5246
  return resolveCodexHomeRootFromEnv(env, { defaultHomeDir, cwd });
5262
5247
  }
5263
5248
  function codexStateRootCandidates(homeDirOrCodexRoot) {
@@ -6209,7 +6194,6 @@ var CodexDriver = class {
6209
6194
  }
6210
6195
  async spawn(ctx) {
6211
6196
  const { spawnEnv } = await prepareCliTransport(ctx, { NO_COLOR: "1" });
6212
- applyDefaultCodexHomeToEnv(spawnEnv, ctx.agentId, { slockHome: ctx.slockHome });
6213
6197
  this.process = null;
6214
6198
  this.requestId = 0;
6215
6199
  this.pendingInitialPrompt = ctx.prompt;
@@ -7108,11 +7092,11 @@ function detectCursorModels(runCommand = runCursorModelsCommand) {
7108
7092
  return parseCursorModelsOutput(String(result.stdout || ""));
7109
7093
  }
7110
7094
  function buildCursorModelProbeEnv(deps = {}) {
7111
- return withWindowsUserEnvironment({
7095
+ return scrubDaemonChildEnv(withWindowsUserEnvironment({
7112
7096
  ...deps.env ?? process.env,
7113
7097
  FORCE_COLOR: "0",
7114
7098
  NO_COLOR: "1"
7115
- }, deps);
7099
+ }, deps));
7116
7100
  }
7117
7101
  function runCursorModelsCommand() {
7118
7102
  return spawnSync("cursor-agent", ["models"], {
@@ -7168,7 +7152,7 @@ function resolveGeminiSpawn(commandArgs, deps = {}) {
7168
7152
  }
7169
7153
  const execFileSyncFn = deps.execFileSyncFn ?? execFileSync3;
7170
7154
  const existsSyncFn = deps.existsSyncFn ?? existsSync6;
7171
- const env = deps.env ?? process.env;
7155
+ const env = scrubDaemonChildEnv({ ...deps.env ?? process.env });
7172
7156
  const winPath = path8.win32;
7173
7157
  let geminiEntry = null;
7174
7158
  try {
@@ -7305,12 +7289,15 @@ var GeminiDriver = class {
7305
7289
  // src/drivers/kimi.ts
7306
7290
  import { randomUUID as randomUUID2 } from "crypto";
7307
7291
  import { spawn as spawn7 } from "child_process";
7308
- import { existsSync as existsSync7, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
7292
+ import { chmodSync, existsSync as existsSync7, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
7309
7293
  import os5 from "os";
7310
7294
  import path9 from "path";
7311
7295
  var KIMI_WIRE_PROTOCOL_VERSION = "1.3";
7312
7296
  var KIMI_SYSTEM_PROMPT_FILE = ".slock-kimi-system.md";
7313
7297
  var KIMI_AGENT_FILE = ".slock-kimi-agent.yaml";
7298
+ var KIMI_GENERATED_CONFIG_FILE = ".slock-kimi-config.toml";
7299
+ var SLOCK_KIMI_CONFIG_CONTENT_ENV = "SLOCK_KIMI_CONFIG_CONTENT";
7300
+ var SLOCK_KIMI_CONFIG_FILE_ENV = "SLOCK_KIMI_CONFIG_FILE";
7314
7301
  function parseToolArguments(raw) {
7315
7302
  if (typeof raw !== "string") return raw;
7316
7303
  try {
@@ -7319,6 +7306,73 @@ function parseToolArguments(raw) {
7319
7306
  return raw;
7320
7307
  }
7321
7308
  }
7309
+ function readKimiConfigSource(home = os5.homedir(), env = process.env) {
7310
+ const inlineConfig = env[SLOCK_KIMI_CONFIG_CONTENT_ENV];
7311
+ if (inlineConfig && inlineConfig.trim()) {
7312
+ return {
7313
+ raw: inlineConfig,
7314
+ explicitPath: null,
7315
+ sourcePath: SLOCK_KIMI_CONFIG_CONTENT_ENV
7316
+ };
7317
+ }
7318
+ const explicitPath = env[SLOCK_KIMI_CONFIG_FILE_ENV];
7319
+ const configPath = explicitPath && explicitPath.trim() ? explicitPath : path9.join(home, ".kimi", "config.toml");
7320
+ try {
7321
+ return {
7322
+ raw: readFileSync3(configPath, "utf8"),
7323
+ explicitPath: explicitPath && explicitPath.trim() ? explicitPath : null,
7324
+ sourcePath: configPath
7325
+ };
7326
+ } catch {
7327
+ return {
7328
+ raw: null,
7329
+ explicitPath: explicitPath && explicitPath.trim() ? explicitPath : null,
7330
+ sourcePath: configPath
7331
+ };
7332
+ }
7333
+ }
7334
+ function buildKimiSpawnEnv(env = process.env) {
7335
+ const spawnEnv = { ...env, FORCE_COLOR: "0", NO_COLOR: "1" };
7336
+ delete spawnEnv[SLOCK_KIMI_CONFIG_CONTENT_ENV];
7337
+ delete spawnEnv[SLOCK_KIMI_CONFIG_FILE_ENV];
7338
+ return scrubDaemonChildEnv(spawnEnv);
7339
+ }
7340
+ function buildKimiEffectiveEnv(ctx, overrideEnv) {
7341
+ return {
7342
+ ...process.env,
7343
+ ...ctx.config.envVars || {},
7344
+ ...overrideEnv || {}
7345
+ };
7346
+ }
7347
+ function buildKimiLaunchOptions(ctx, opts = {}) {
7348
+ const env = buildKimiEffectiveEnv(ctx, opts.env);
7349
+ const source = readKimiConfigSource(opts.home ?? os5.homedir(), env);
7350
+ const args = [];
7351
+ let configFilePath = null;
7352
+ let configContent = null;
7353
+ if (source.explicitPath) {
7354
+ configFilePath = source.explicitPath;
7355
+ } else if (source.raw !== null && source.sourcePath === SLOCK_KIMI_CONFIG_CONTENT_ENV) {
7356
+ configFilePath = path9.join(ctx.workingDirectory, KIMI_GENERATED_CONFIG_FILE);
7357
+ configContent = source.raw;
7358
+ if (opts.writeGeneratedConfig !== false) {
7359
+ writeFileSync3(configFilePath, source.raw, { encoding: "utf8", mode: 384 });
7360
+ chmodSync(configFilePath, 384);
7361
+ }
7362
+ }
7363
+ if (configFilePath) {
7364
+ args.push("--config-file", configFilePath);
7365
+ }
7366
+ if (ctx.config.model && ctx.config.model !== "default") {
7367
+ args.push("--model", ctx.config.model);
7368
+ }
7369
+ return {
7370
+ args,
7371
+ env: buildKimiSpawnEnv(env),
7372
+ configFilePath,
7373
+ configContent
7374
+ };
7375
+ }
7322
7376
  function resolveKimiSpawn(commandArgs, deps = {}) {
7323
7377
  return {
7324
7378
  command: resolveCommandOnPath("kimi", deps) ?? "kimi",
@@ -7342,7 +7396,25 @@ var KimiDriver = class {
7342
7396
  };
7343
7397
  model = {
7344
7398
  detectedModelsVerifiedAs: "launchable",
7345
- toLaunchSpec: (modelId) => ({ args: ["--model", modelId] })
7399
+ toLaunchSpec: (modelId, ctx, opts) => {
7400
+ if (!ctx) return { args: ["--model", modelId] };
7401
+ const launchCtx = {
7402
+ ...ctx,
7403
+ config: {
7404
+ ...ctx.config,
7405
+ model: modelId
7406
+ }
7407
+ };
7408
+ const launch = buildKimiLaunchOptions(launchCtx, {
7409
+ home: opts?.home,
7410
+ writeGeneratedConfig: false
7411
+ });
7412
+ return {
7413
+ args: launch.args,
7414
+ env: launch.env,
7415
+ configFiles: launch.configFilePath ? [launch.configFilePath] : void 0
7416
+ };
7417
+ }
7346
7418
  };
7347
7419
  supportsStdinNotification = true;
7348
7420
  busyDeliveryMode = "direct";
@@ -7366,21 +7438,23 @@ var KimiDriver = class {
7366
7438
  ` system_prompt_path: ./${KIMI_SYSTEM_PROMPT_FILE}`,
7367
7439
  ""
7368
7440
  ].join("\n"), "utf8");
7441
+ const launch = buildKimiLaunchOptions(ctx);
7369
7442
  const args = [
7370
7443
  "--wire",
7371
7444
  "--yolo",
7372
7445
  "--agent-file",
7373
7446
  agentFilePath,
7374
7447
  "--session",
7375
- this.sessionId
7448
+ this.sessionId,
7449
+ ...launch.args
7376
7450
  ];
7377
7451
  const launchRuntimeFields = runtimeConfigToLaunchFields(ctx.config);
7378
7452
  if (launchRuntimeFields.model && launchRuntimeFields.model !== "default") {
7379
7453
  args.push("--model", launchRuntimeFields.model);
7380
7454
  }
7381
7455
  const spawnEnv = (await prepareCliTransport(ctx, { NO_COLOR: "1" })).spawnEnv;
7382
- const launch = resolveKimiSpawn(args);
7383
- const proc = spawn7(launch.command, launch.args, {
7456
+ const spawnTarget = resolveKimiSpawn(args);
7457
+ const proc = spawn7(spawnTarget.command, spawnTarget.args, {
7384
7458
  cwd: ctx.workingDirectory,
7385
7459
  stdio: ["pipe", "pipe", "pipe"],
7386
7460
  env: spawnEnv,
@@ -7388,7 +7462,7 @@ var KimiDriver = class {
7388
7462
  // and has an 8191-character command-line limit. Kimi's official
7389
7463
  // installer/uv entrypoint is an executable, so launch it directly and
7390
7464
  // keep prompts on stdin / files instead of routing through cmd.exe.
7391
- shell: launch.shell
7465
+ shell: spawnTarget.shell
7392
7466
  });
7393
7467
  proc.stdin?.write(JSON.stringify({
7394
7468
  jsonrpc: "2.0",
@@ -7501,14 +7575,9 @@ var KimiDriver = class {
7501
7575
  return detectKimiModels();
7502
7576
  }
7503
7577
  };
7504
- function detectKimiModels(home = os5.homedir()) {
7505
- const configPath = path9.join(home, ".kimi", "config.toml");
7506
- let raw;
7507
- try {
7508
- raw = readFileSync3(configPath, "utf8");
7509
- } catch {
7510
- return null;
7511
- }
7578
+ function detectKimiModels(home = os5.homedir(), opts = {}) {
7579
+ const raw = readKimiConfigSource(home, opts.env).raw;
7580
+ if (raw === null) return null;
7512
7581
  const models = [];
7513
7582
  const sectionRe = /^\s*\[models(?:\.([^\]]+)|"\.[^"]+"|\."[^"]+")\s*\]\s*$/gm;
7514
7583
  const lineRe = /^\s*\[models\.(.+?)\s*\]\s*$/gm;
@@ -7530,7 +7599,7 @@ function detectKimiModels(home = os5.homedir()) {
7530
7599
  // src/drivers/kimi-sdk.ts
7531
7600
  import { randomUUID as randomUUID3 } from "crypto";
7532
7601
  import { EventEmitter } from "events";
7533
- import { mkdirSync as mkdirSync4, readFileSync as readFileSync4 } from "fs";
7602
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync4 } from "fs";
7534
7603
  import path10 from "path";
7535
7604
  import { createRequire as createRequire2 } from "module";
7536
7605
  import {
@@ -7679,12 +7748,12 @@ var KIMI_SDK_RUNTIME_SESSION_DESCRIPTOR = {
7679
7748
  };
7680
7749
  async function createKimiAgentSessionForContext(ctx, sessionId) {
7681
7750
  const sessionDir = buildKimiSessionDir(ctx.workingDirectory);
7682
- mkdirSync4(sessionDir, { recursive: true });
7751
+ mkdirSync3(sessionDir, { recursive: true });
7683
7752
  const cliTransport = await prepareCliTransport(ctx, { NO_COLOR: "1" });
7684
7753
  const spawnEnv = cliTransport.spawnEnv;
7685
7754
  const wrapperPath = cliTransport.wrapperPath;
7686
7755
  const homeDir = spawnEnv.KIMI_HOME || (process.env.HOME ? path10.join(process.env.HOME, ".kimi") : path10.join(ctx.workingDirectory, ".kimi"));
7687
- mkdirSync4(homeDir, { recursive: true });
7756
+ mkdirSync3(homeDir, { recursive: true });
7688
7757
  const harness = createKimiHarness({
7689
7758
  homeDir,
7690
7759
  identity: {
@@ -8232,7 +8301,7 @@ function runOpenCodeModelsCommand(home, deps = {}) {
8232
8301
  const platform = deps.platform ?? process.platform;
8233
8302
  const spawnSyncFn = deps.spawnSyncFn ?? spawnSync2;
8234
8303
  const result = spawnSyncFn("opencode", ["models"], {
8235
- env: { ...process.env, HOME: home, FORCE_COLOR: "0", NO_COLOR: "1" },
8304
+ env: scrubDaemonChildEnv({ ...process.env, HOME: home, FORCE_COLOR: "0", NO_COLOR: "1" }),
8236
8305
  encoding: "utf8",
8237
8306
  timeout: 5e3,
8238
8307
  shell: platform === "win32"
@@ -8491,7 +8560,7 @@ var OpenCodeDriver = class {
8491
8560
  // src/drivers/pi.ts
8492
8561
  import { randomUUID as randomUUID4 } from "crypto";
8493
8562
  import { EventEmitter as EventEmitter2 } from "events";
8494
- import { mkdirSync as mkdirSync5, readdirSync as readdirSync2 } from "fs";
8563
+ import { mkdirSync as mkdirSync4, readdirSync as readdirSync2 } from "fs";
8495
8564
  import path12 from "path";
8496
8565
  import {
8497
8566
  AuthStorage,
@@ -8759,7 +8828,7 @@ var PI_IDLE_PROMPT_RETRY_MS = 25;
8759
8828
  var PI_IDLE_PROMPT_MAX_WAIT_MS = 1e3;
8760
8829
  async function createPiAgentSessionForContext(ctx, sessionId) {
8761
8830
  const sessionDir = buildPiSessionDir(ctx.workingDirectory);
8762
- mkdirSync5(sessionDir, { recursive: true });
8831
+ mkdirSync4(sessionDir, { recursive: true });
8763
8832
  const launchRuntimeFields = runtimeConfigToLaunchFields(ctx.config);
8764
8833
  const requestedModel = launchRuntimeFields.model || "default";
8765
8834
  const traceSpan = ctx.tracer?.startSpan("daemon.pi.session.create", {
@@ -10062,7 +10131,7 @@ function safeSessionFilename(value) {
10062
10131
  function writeRuntimeSessionHandoff(runtime, sessionId, fallbackDir) {
10063
10132
  try {
10064
10133
  const dir = path14.join(fallbackDir, ".slock", "runtime-sessions");
10065
- mkdirSync6(dir, { recursive: true });
10134
+ mkdirSync5(dir, { recursive: true });
10066
10135
  const filePath = path14.join(dir, `${runtime}-${safeSessionFilename(sessionId)}.jsonl`);
10067
10136
  writeFileSync4(filePath, JSON.stringify({
10068
10137
  type: "runtime_session_handoff",
@@ -10098,7 +10167,7 @@ function ensureRuntimeHomeDir(config, defaultHomeDir, workspacePath, opts = {})
10098
10167
  if (config.runtime === "codex") {
10099
10168
  const home = resolveCodexHomeRootFromConfig(config, defaultHomeDir, workspacePath, process.env, opts);
10100
10169
  if (opts.agentId) {
10101
- mkdirSync6(home, { recursive: true });
10170
+ mkdirSync5(home, { recursive: true });
10102
10171
  }
10103
10172
  return home;
10104
10173
  }
@@ -14168,7 +14237,7 @@ Use ${communicationCommand("read_history")} to catch up on the channels listed a
14168
14237
  const runtime = runtimeHint || config?.runtime || "claude";
14169
14238
  const workspaceDir = path14.join(this.dataDir, agentId);
14170
14239
  const hostHome = os7.homedir();
14171
- const home = agent?.runtime.currentRuntimeHomeDir || (config ? ensureRuntimeHomeDir(config, hostHome, workspaceDir, { agentId, slockHome: this.slockHome }) : runtime === "codex" ? resolveDefaultCodexHomeRootForAgent(agentId, { slockHome: this.slockHome }) : hostHome);
14240
+ const home = agent?.runtime.currentRuntimeHomeDir || (config ? ensureRuntimeHomeDir(config, hostHome, workspaceDir, { agentId, slockHome: this.slockHome }) : runtime === "codex" ? resolveCodexHomeRootFromEnv(process.env, { defaultHomeDir: hostHome, cwd: workspaceDir }) : hostHome);
14172
14241
  const paths = _AgentProcessManager.SKILL_PATHS[runtime] || _AgentProcessManager.SKILL_PATHS.claude;
14173
14242
  const globalDirs = runtime === "codex" ? [
14174
14243
  path14.join(home, "skills"),
@@ -16261,7 +16330,7 @@ var ReminderCache = class {
16261
16330
 
16262
16331
  // src/machineLock.ts
16263
16332
  import { createHash as createHash4, randomUUID as randomUUID6 } from "crypto";
16264
- import { mkdirSync as mkdirSync7, readFileSync as readFileSync7, rmSync as rmSync3, statSync as statSync2, writeFileSync as writeFileSync5 } from "fs";
16333
+ import { mkdirSync as mkdirSync6, readFileSync as readFileSync7, rmSync as rmSync3, statSync as statSync2, writeFileSync as writeFileSync5 } from "fs";
16265
16334
  import os8 from "os";
16266
16335
  import path15 from "path";
16267
16336
  var INCOMPLETE_LOCK_STALE_MS = 3e4;
@@ -16318,10 +16387,10 @@ function acquireDaemonMachineLock(options) {
16318
16387
  const machineDir = path15.join(rootDir, lockId);
16319
16388
  const lockDir = path15.join(machineDir, "daemon.lock");
16320
16389
  const token = randomUUID6();
16321
- mkdirSync7(machineDir, { recursive: true });
16390
+ mkdirSync6(machineDir, { recursive: true });
16322
16391
  for (let attempt = 0; attempt < 2; attempt += 1) {
16323
16392
  try {
16324
- mkdirSync7(lockDir);
16393
+ mkdirSync6(lockDir);
16325
16394
  const owner = {
16326
16395
  pid: process.pid,
16327
16396
  token,
@@ -16376,7 +16445,7 @@ function acquireDaemonMachineLock(options) {
16376
16445
  }
16377
16446
 
16378
16447
  // src/localTraceSink.ts
16379
- import { appendFileSync, mkdirSync as mkdirSync8, readdirSync as readdirSync4, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "fs";
16448
+ import { appendFileSync, mkdirSync as mkdirSync7, readdirSync as readdirSync4, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "fs";
16380
16449
  import path16 from "path";
16381
16450
  var DEFAULT_MAX_FILE_BYTES = 5 * 1024 * 1024;
16382
16451
  var DEFAULT_MAX_FILE_AGE_MS = 5 * 60 * 1e3;
@@ -16440,7 +16509,7 @@ var LocalRotatingTraceSink = class {
16440
16509
  return this.currentFile;
16441
16510
  }
16442
16511
  ensureFile(nextBytes) {
16443
- mkdirSync8(this.traceDir, { recursive: true, mode: 448 });
16512
+ mkdirSync7(this.traceDir, { recursive: true, mode: 448 });
16444
16513
  const nowMs = this.nowMsProvider();
16445
16514
  const shouldRotateForAge = this.currentFileOpenedAtMs !== null && nowMs - this.currentFileOpenedAtMs >= this.maxFileAgeMs;
16446
16515
  if (!this.currentFile || this.currentSize + nextBytes > this.maxFileBytes || shouldRotateForAge) {
@@ -16845,7 +16914,7 @@ var DAEMON_CORE_TRACE_ATTR_CONTRACTS = {
16845
16914
  spanAttrs: ["agentId", "event_kind", "runtime"]
16846
16915
  }
16847
16916
  };
16848
- var DAEMON_CLI_USAGE = "Usage: slock-daemon --server-url <url> --api-key <key>";
16917
+ var DAEMON_CLI_USAGE = `Usage: slock-daemon --server-url <url> (--api-key <key> or ${DAEMON_API_KEY_ENV}=<key>)`;
16849
16918
  var RunnerCredentialMintError2 = class extends Error {
16850
16919
  code;
16851
16920
  retryable;
@@ -16881,9 +16950,9 @@ function runnerCredentialErrorDetail2(error) {
16881
16950
  async function waitForRunnerCredentialRetry2() {
16882
16951
  await new Promise((resolve) => setTimeout(resolve, RUNNER_CREDENTIAL_MINT_RETRY_DELAY_MS2));
16883
16952
  }
16884
- function parseDaemonCliArgs(args) {
16953
+ function parseDaemonCliArgs(args, env = {}) {
16885
16954
  let serverUrl = "";
16886
- let apiKey = "";
16955
+ let apiKey = env[DAEMON_API_KEY_ENV] ?? "";
16887
16956
  for (let i = 0; i < args.length; i++) {
16888
16957
  if (args[i] === "--server-url" && args[i + 1]) serverUrl = args[++i];
16889
16958
  if (args[i] === "--api-key" && args[i + 1]) apiKey = args[++i];
@@ -17807,6 +17876,8 @@ var DaemonCore = class {
17807
17876
 
17808
17877
  export {
17809
17878
  subscribeDaemonLogs,
17879
+ DAEMON_API_KEY_ENV,
17880
+ scrubDaemonAuthEnv,
17810
17881
  resolveWorkspaceDirectoryPath,
17811
17882
  scanWorkspaceDirectories,
17812
17883
  deleteWorkspaceDirectory,
package/dist/core.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ DAEMON_API_KEY_ENV,
2
3
  DAEMON_CLI_USAGE,
3
4
  DaemonCore,
4
5
  deleteWorkspaceDirectory,
@@ -10,9 +11,11 @@ import {
10
11
  resolveWorkspaceDirectoryPath,
11
12
  runBundledSlockCli,
12
13
  scanWorkspaceDirectories,
14
+ scrubDaemonAuthEnv,
13
15
  subscribeDaemonLogs
14
- } from "./chunk-W2KSMJ4G.js";
16
+ } from "./chunk-R3YQ3ZXU.js";
15
17
  export {
18
+ DAEMON_API_KEY_ENV,
16
19
  DAEMON_CLI_USAGE,
17
20
  DaemonCore,
18
21
  deleteWorkspaceDirectory,
@@ -24,5 +27,6 @@ export {
24
27
  resolveWorkspaceDirectoryPath,
25
28
  runBundledSlockCli,
26
29
  scanWorkspaceDirectories,
30
+ scrubDaemonAuthEnv,
27
31
  subscribeDaemonLogs
28
32
  };
package/dist/index.js CHANGED
@@ -2,11 +2,13 @@
2
2
  import {
3
3
  DAEMON_CLI_USAGE,
4
4
  DaemonCore,
5
- parseDaemonCliArgs
6
- } from "./chunk-W2KSMJ4G.js";
5
+ parseDaemonCliArgs,
6
+ scrubDaemonAuthEnv
7
+ } from "./chunk-R3YQ3ZXU.js";
7
8
 
8
9
  // src/index.ts
9
- var parsedArgs = parseDaemonCliArgs(process.argv.slice(2));
10
+ var parsedArgs = parseDaemonCliArgs(process.argv.slice(2), process.env);
11
+ scrubDaemonAuthEnv(process.env);
10
12
  if (!parsedArgs) {
11
13
  console.error(DAEMON_CLI_USAGE);
12
14
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botiverse/raft-daemon",
3
- "version": "0.63.0",
3
+ "version": "0.63.1-play.20260619141001",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "raft-daemon": "dist/raft-daemon.js",