@botiverse/raft-daemon 1.0.0 → 1.0.3

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.
@@ -1418,10 +1418,11 @@ var TRACE_EVENT_ROW_V2_PROJECTION_COLUMNS = [
1418
1418
  ["shadow_direction", "string"],
1419
1419
  ["shadow_plan_kind", "string"]
1420
1420
  ];
1421
+ var TRACE_EVENT_ROW_V2_TABLE = "raft.trace_events_v2";
1421
1422
  var TRACE_EVENT_ROW_V2_INGEST_STATEMENT = [
1422
1423
  "SELECT",
1423
1424
  TRACE_EVENT_ROW_V2_PROJECTION_COLUMNS.map(([column, type]) => `$0["${column}"]::${type} AS ${column}`).join(", "),
1424
- "INSERT INTO raft.trace_events_v2",
1425
+ `INSERT INTO ${TRACE_EVENT_ROW_V2_TABLE}`,
1425
1426
  `(${TRACE_EVENT_ROW_V2_PROJECTION_COLUMNS.map(([column]) => column).join(", ")})`
1426
1427
  ].join(" ");
1427
1428
  var PROMOTED_IDENTITY_ATTRS = [
@@ -3670,6 +3671,12 @@ function currentTimeMs() {
3670
3671
  function currentDate() {
3671
3672
  return new Date(currentTimeMs());
3672
3673
  }
3674
+ function setClockTimeout(fn, ms) {
3675
+ return setTimeout(fn, ms);
3676
+ }
3677
+ function clearClockTimeout(timeout) {
3678
+ clearTimeout(timeout);
3679
+ }
3673
3680
 
3674
3681
  // ../shared/src/agentInbox.ts
3675
3682
  function formatAgentInboxDelta(rows, options = {}) {
@@ -5167,8 +5174,31 @@ If a tool or error output contains credential-shaped strings, redact them to \`s
5167
5174
 
5168
5175
  **Profile credential resolution is strict.** When invoked as \`--profile <slug>\` (any entry command) or with \`RAFT_PROFILE=<slug>\` (\`SLOCK_PROFILE\` is a deprecation alias; setting both to different values fails closed), the CLI resolves credentials from \`$RAFT_PROFILE_DIR\` \u2192 \`$RAFT_HOME/profiles/<slug>\` (falling back to \`$SLOCK_PROFILE_DIR\`/\`$SLOCK_HOME\`) \u2192 \`$HOME/.slock/profiles/<slug>\` in that order. It does **not** fall back to a different profile's credential, to an ambient user-level token, or to environment-leaked secrets \u2014 if your designated profile credential is missing or unreadable, the CLI fails closed rather than authenticating as someone else.`;
5169
5176
  }
5170
- function buildSendingMessagesSection() {
5177
+ function buildSendingMessagesSection(shell) {
5171
5178
  const D = MESSAGE_HEREDOC_DELIMITER;
5179
+ if (shell === "powershell") {
5180
+ return `### Sending messages
5181
+
5182
+ - **Reply to a channel**: pipe a PowerShell here-string into \`raft message send --target "#channel-name"\`
5183
+ - **Reply to a DM**: pipe a PowerShell here-string into \`raft message send --target dm:@peer-name\`
5184
+ - **Reply in a thread**: pipe a PowerShell here-string into \`raft message send --target "#channel:shortid"\`
5185
+ - **Start a NEW DM**: pipe a PowerShell here-string into \`raft message send --target dm:@person-name\`
5186
+
5187
+ Message content is always read from stdin. On Windows PowerShell, use a single-quoted here-string so quotes, backticks, dollar variables, and newlines stay literal:
5188
+ \`\`\`powershell
5189
+ @'
5190
+ Long message with "quotes", $vars, \`backticks\`, and code blocks.
5191
+ '@ | raft message send --target "#channel-name"
5192
+ \`\`\`
5193
+
5194
+ The closing \`'@\` must start at the beginning of its line. Do not use Bash heredoc syntax (\`<<\`) in PowerShell.
5195
+
5196
+ If Slock says a message was not sent and was saved as a draft, choose one path:
5197
+ - To update the draft, pipe the revised here-string into a normal \`raft message send --target <target>\` command.
5198
+ - To send the current draft unchanged, use \`raft message send --send-draft --target <target>\` with no stdin. Do not use \`--send-draft\` when changing content.
5199
+
5200
+ **IMPORTANT**: To reply to any message, always reuse the exact \`target\` from the received message. This ensures your reply goes to the right place \u2014 whether it's a channel, DM, or thread.`;
5201
+ }
5172
5202
  return `### Sending messages
5173
5203
 
5174
5204
  - **Reply to a channel**: \`raft message send --target "#channel-name" <<'${D}'\` followed by the message body and \`${D}\`
@@ -5199,15 +5229,16 @@ When a reminder already exists, prefer \`raft reminder snooze\` to push it later
5199
5229
  Use \`raft reminder schedule\` rather than runtime-native wake or cron tools such as ScheduleWakeup or CronCreate for user-visible reminders, so reminders stay author-owned, persistent, observable, snoozable, updatable, and cancelable in Slock.
5200
5230
  Create agent reminders only after resolving the anchor message from the current conversation and passing its msgId explicitly; if no anchor can be resolved, consider posting a status update in the relevant thread so the intent is visible, then revisit when context is available.`;
5201
5231
  }
5202
- function buildThreadsSection() {
5232
+ function buildThreadsSection(shell) {
5203
5233
  const D = MESSAGE_HEREDOC_DELIMITER;
5234
+ const startThreadInstruction = shell === "powershell" ? 'pipe a PowerShell single-quoted here-string into `raft message send --target "#general:00000000"`' : `reply with \`raft message send --target "#general:00000000" <<'${D}'\` followed by the message body and \`${D}\``;
5204
5235
  return `### Threads
5205
5236
 
5206
5237
  Threads are sub-conversations attached to a specific message. They let you discuss a topic without cluttering the main channel.
5207
5238
 
5208
5239
  - **Thread targets** have a colon and short ID suffix: \`#general:00000000\` (thread in #general) or \`dm:@richard:11111111\` (thread in a DM).
5209
5240
  - When you receive a message from a thread (the target has a \`:shortid\` suffix), **always reply using that same target** to keep the conversation in the thread.
5210
- - **Start a new thread**: Use the \`msg=\` field from the header as the thread suffix. For example, if you see \`[target=#general msg=00000000 ...]\`, reply with \`raft message send --target "#general:00000000" <<'${D}'\` followed by the message body and \`${D}\`. The thread will be auto-created if it doesn't exist yet. Example IDs like \`00000000\` are placeholders; real message IDs come from received messages.
5241
+ - **Start a new thread**: Use the \`msg=\` field from the header as the thread suffix. For example, if you see \`[target=#general msg=00000000 ...]\`, ${startThreadInstruction}. The thread will be auto-created if it doesn't exist yet. Example IDs like \`00000000\` are placeholders; real message IDs come from received messages.
5211
5242
  - When you send a message, the response includes the message ID. You can use it to start a thread on your own message.
5212
5243
  - You can read thread history: \`raft message read --target "#general:00000000"\`
5213
5244
  - Unfollowing a thread removes its follow record and stops its ordinary delivery while the parent channel is unmuted: \`raft thread unfollow --target "#general:00000000"\`. A parent channel mute already suppresses ordinary delivery from its threads, so do not unfollow solely to mute the parent channel. Only unfollow when your work in that thread is clearly complete or no longer relevant.
@@ -5404,12 +5435,13 @@ Your context will be periodically compressed to stay within limits. When this ha
5404
5435
  - Keep MEMORY.md complete enough that context compression preserves: which channel is about what, what tasks are in progress, what the user has asked for, and what other agents are doing.`;
5405
5436
  }
5406
5437
  function buildSlockCliGuideSections(options) {
5438
+ const shell = options.shell ?? "posix";
5407
5439
  return {
5408
5440
  communication: buildCommunicationSection(options.audience),
5409
5441
  credentialHygiene: buildCredentialHygieneSection(),
5410
- sendingMessages: buildSendingMessagesSection(),
5442
+ sendingMessages: buildSendingMessagesSection(shell),
5411
5443
  reminders: buildRemindersSection(),
5412
- threads: buildThreadsSection(),
5444
+ threads: buildThreadsSection(shell),
5413
5445
  discovery: buildDiscoverySection(),
5414
5446
  channelAwareness: buildChannelAwarenessSection(),
5415
5447
  readingHistory: buildReadingHistorySection(),
@@ -5459,6 +5491,7 @@ function buildPrompt(config, opts) {
5459
5491
  handle: config.name,
5460
5492
  displayName: config.displayName || config.name
5461
5493
  },
5494
+ shell: opts.commandShell,
5462
5495
  taskClaimCmd
5463
5496
  });
5464
5497
  const checkCmd = "`raft message check`";
@@ -8195,6 +8228,19 @@ function buildClaudeProviderIsolationEnv(ctx) {
8195
8228
  import { execFileSync } from "child_process";
8196
8229
  import { existsSync as existsSync3 } from "fs";
8197
8230
  import path4 from "path";
8231
+
8232
+ // src/drivers/windowsPowerShellEnv.ts
8233
+ function createWindowsPowerShellChildEnv(env) {
8234
+ const childEnv = { ...env ?? process.env };
8235
+ for (const key of Object.keys(childEnv)) {
8236
+ if (key.toLowerCase() === "psmodulepath") {
8237
+ delete childEnv[key];
8238
+ }
8239
+ }
8240
+ return childEnv;
8241
+ }
8242
+
8243
+ // src/drivers/probe.ts
8198
8244
  function normalizeExecOutput(raw) {
8199
8245
  return Buffer.isBuffer(raw) ? raw.toString("utf8") : String(raw ?? "");
8200
8246
  }
@@ -8212,7 +8258,20 @@ var WINDOWS_ENVIRONMENT_SCRIPT = [
8212
8258
  " }",
8213
8259
  " $result | ConvertTo-Json -Compress -Depth 3",
8214
8260
  "}"
8215
- ].join(" ");
8261
+ ].join("\n");
8262
+ var WINDOWS_ENVIRONMENT_ERROR_SUMMARY_MAX_LENGTH = 240;
8263
+ function summarizeWindowsEnvironmentError(error) {
8264
+ const details = error;
8265
+ const exit = typeof details?.status === "number" ? String(details.status) : "unknown";
8266
+ const code = typeof details?.code === "string" ? details.code : "unknown";
8267
+ const signal = typeof details?.signal === "string" ? details.signal : "none";
8268
+ const stderr = normalizeExecOutput(details?.stderr).trim().replace(/\s+/g, " ");
8269
+ const fallback = error instanceof Error ? error.message.trim().replace(/\s+/g, " ") : String(error);
8270
+ const rawSummary = stderr || fallback || "no child error detail";
8271
+ const summary = rawSummary.length > WINDOWS_ENVIRONMENT_ERROR_SUMMARY_MAX_LENGTH ? `${rawSummary.slice(0, WINDOWS_ENVIRONMENT_ERROR_SUMMARY_MAX_LENGTH - 3)}...` : rawSummary;
8272
+ return `[Daemon] Windows environment refresh failed (exit=${exit}, code=${code}, signal=${signal}): ${summary}`;
8273
+ }
8274
+ var WINDOWS_COMMAND_RESOLVE_TIMEOUT_MS = 1e3;
8216
8275
  function normalizeProcessEnv(value) {
8217
8276
  if (!value || typeof value !== "object" || Array.isArray(value)) return {};
8218
8277
  const env = {};
@@ -8223,7 +8282,7 @@ function normalizeProcessEnv(value) {
8223
8282
  }
8224
8283
  return env;
8225
8284
  }
8226
- function readWindowsMachineUserEnvironment(env, execFileSyncFn) {
8285
+ function readWindowsMachineUserEnvironment(env, execFileSyncFn, warn) {
8227
8286
  try {
8228
8287
  const output = normalizeExecOutput(execFileSyncFn("powershell.exe", [
8229
8288
  "-NoProfile",
@@ -8232,7 +8291,7 @@ function readWindowsMachineUserEnvironment(env, execFileSyncFn) {
8232
8291
  WINDOWS_ENVIRONMENT_SCRIPT
8233
8292
  ], {
8234
8293
  stdio: ["ignore", "pipe", "ignore"],
8235
- env,
8294
+ env: createWindowsPowerShellChildEnv(env),
8236
8295
  timeout: 5e3
8237
8296
  }));
8238
8297
  const parsed = JSON.parse(output || "{}");
@@ -8240,7 +8299,8 @@ function readWindowsMachineUserEnvironment(env, execFileSyncFn) {
8240
8299
  machine: normalizeProcessEnv(parsed.Machine),
8241
8300
  user: normalizeProcessEnv(parsed.User)
8242
8301
  };
8243
- } catch {
8302
+ } catch (error) {
8303
+ warn?.(summarizeWindowsEnvironmentError(error));
8244
8304
  return null;
8245
8305
  }
8246
8306
  }
@@ -8306,7 +8366,8 @@ function withWindowsUserEnvironment(env, deps = {}) {
8306
8366
  if (platform !== "win32") return env;
8307
8367
  const execFileSyncFn = deps.execFileSyncFn ?? execFileSync;
8308
8368
  const reader = deps.windowsEnvironmentReaderFn ?? readWindowsMachineUserEnvironment;
8309
- const scopes = reader(env, execFileSyncFn);
8369
+ const warn = deps.warn ?? ((message) => logger.warn(message));
8370
+ const scopes = reader(env, execFileSyncFn, warn);
8310
8371
  if (!scopes) return env;
8311
8372
  return mergeWindowsEnvironmentScopes(env, scopes);
8312
8373
  }
@@ -8321,7 +8382,8 @@ function resolveCommandOnWindows(command, env, execFileSyncFn, existsSyncFn) {
8321
8382
  command
8322
8383
  ], {
8323
8384
  stdio: ["ignore", "pipe", "ignore"],
8324
- env
8385
+ env: createWindowsPowerShellChildEnv(env),
8386
+ timeout: WINDOWS_COMMAND_RESOLVE_TIMEOUT_MS
8325
8387
  }));
8326
8388
  const resolved = output.trim().split(/\r?\n/)[0];
8327
8389
  if (!resolved) return null;
@@ -11014,7 +11076,7 @@ import {
11014
11076
  } from "@botiverse/kimi-code-sdk";
11015
11077
  var requireFromHere = createRequire2(import.meta.url);
11016
11078
  var KIMI_CODE_USER_AGENT_PRODUCT = "kimi-code-cli";
11017
- var KIMI_CODE_HOST_VERSION = "0.18.0-botiverse.0";
11079
+ var KIMI_CODE_HOST_VERSION = "0.26.0-botiverse.2";
11018
11080
  function getDaemonVersion() {
11019
11081
  try {
11020
11082
  const pkg = requireFromHere("../../package.json");
@@ -11105,12 +11167,23 @@ function mapKimiSdkEventToParsedEvents(event, state) {
11105
11167
  // tool-call progress / hooks (could elevate to internal_progress in future)
11106
11168
  case "tool.call.delta":
11107
11169
  case "tool.progress":
11170
+ case "shell.output":
11171
+ case "shell.started":
11108
11172
  case "hook.result":
11109
11173
  // status / meta updates
11110
11174
  case "agent.status.updated":
11111
11175
  case "session.meta.updated":
11176
+ case "event.session.created":
11177
+ case "event.workspace.created":
11178
+ case "event.workspace.updated":
11179
+ case "event.workspace.deleted":
11180
+ case "event.session.work_changed":
11181
+ case "event.session.status_changed":
11182
+ case "event.config.changed":
11183
+ case "event.model_catalog.changed":
11112
11184
  case "goal.updated":
11113
11185
  case "skill.activated":
11186
+ case "plugin_command.activated":
11114
11187
  // MCP infra
11115
11188
  case "tool.list.updated":
11116
11189
  case "mcp.server.status":
@@ -11124,13 +11197,20 @@ function mapKimiSdkEventToParsedEvents(event, state) {
11124
11197
  case "compaction.blocked":
11125
11198
  case "compaction.cancelled":
11126
11199
  // out-of-band
11200
+ case "task.started":
11201
+ case "task.terminated":
11127
11202
  case "background.task.started":
11128
11203
  case "background.task.terminated":
11129
11204
  case "cron.fired":
11205
+ case "prompt.submitted":
11206
+ case "prompt.completed":
11207
+ case "prompt.aborted":
11208
+ case "prompt.steered":
11130
11209
  return events;
11131
11210
  default: {
11132
11211
  const _exhaustive = event;
11133
- return _exhaustive;
11212
+ void _exhaustive;
11213
+ return events;
11134
11214
  }
11135
11215
  }
11136
11216
  }
@@ -11180,7 +11260,7 @@ async function createKimiAgentSessionForContext(ctx, sessionId, deps = {}) {
11180
11260
  const cliTransport = await prepareTransportImpl(ctx, { NO_COLOR: "1" });
11181
11261
  const spawnEnv = cliTransport.spawnEnv;
11182
11262
  const wrapperPath = cliTransport.wrapperPath;
11183
- const homeDir = spawnEnv.KIMI_HOME || (process.env.HOME ? path10.join(process.env.HOME, ".kimi") : path10.join(ctx.workingDirectory, ".kimi"));
11263
+ const homeDir = resolveKimiHome(spawnEnv.KIMI_CODE_HOME);
11184
11264
  mkdirSync2(homeDir, { recursive: true });
11185
11265
  const harness = createHarnessImpl({
11186
11266
  homeDir,
@@ -11932,7 +12012,6 @@ import { mkdirSync as mkdirSync3, readdirSync as readdirSync3 } from "fs";
11932
12012
  import path12 from "path";
11933
12013
  import {
11934
12014
  AuthStorage,
11935
- createBashTool,
11936
12015
  createAgentSessionFromServices,
11937
12016
  createAgentSessionServices,
11938
12017
  getAgentDir,
@@ -11940,6 +12019,126 @@ import {
11940
12019
  SettingsManager,
11941
12020
  VERSION as PI_SDK_VERSION
11942
12021
  } from "@earendil-works/pi-coding-agent";
12022
+
12023
+ // src/drivers/piCommandTool.ts
12024
+ import { spawn as spawn9 } from "child_process";
12025
+ import {
12026
+ createBashTool
12027
+ } from "@earendil-works/pi-coding-agent";
12028
+ var POWERSHELL_STDIN_LOADER = [
12029
+ "$raftReader = [System.IO.StreamReader]::new([Console]::OpenStandardInput(), [System.Text.Encoding]::ASCII, $false)",
12030
+ "try { $raftEncodedScript = $raftReader.ReadToEnd() } finally { $raftReader.Dispose() }",
12031
+ "$raftScript = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($raftEncodedScript))",
12032
+ "& ([ScriptBlock]::Create($raftScript))"
12033
+ ].join("\r\n");
12034
+ var POWERSHELL_ARGS = [
12035
+ "-NoLogo",
12036
+ "-NoProfile",
12037
+ "-NonInteractive",
12038
+ "-ExecutionPolicy",
12039
+ "Bypass",
12040
+ "-Command",
12041
+ POWERSHELL_STDIN_LOADER
12042
+ ];
12043
+ var MAX_TIMEOUT_SECONDS = 2147483647 / 1e3;
12044
+ function killWindowsProcessTree(pid) {
12045
+ const killer = spawn9("taskkill.exe", ["/F", "/T", "/PID", String(pid)], {
12046
+ detached: true,
12047
+ stdio: "ignore",
12048
+ windowsHide: true
12049
+ });
12050
+ killer.unref();
12051
+ }
12052
+ function buildPiPowerShellScript(command) {
12053
+ return [
12054
+ "$ErrorActionPreference = 'Stop'",
12055
+ "$utf8NoBom = New-Object System.Text.UTF8Encoding($false)",
12056
+ "[Console]::OutputEncoding = $utf8NoBom",
12057
+ "$OutputEncoding = $utf8NoBom",
12058
+ "$global:LASTEXITCODE = 0",
12059
+ "& {",
12060
+ command,
12061
+ "}",
12062
+ "$raftCommandSucceeded = $?",
12063
+ "$raftNativeExitCode = $global:LASTEXITCODE",
12064
+ "if ($raftNativeExitCode -ne 0) { exit $raftNativeExitCode }",
12065
+ "if (-not $raftCommandSucceeded) { exit 1 }",
12066
+ "exit 0",
12067
+ ""
12068
+ ].join("\r\n");
12069
+ }
12070
+ function createPiPowerShellOperations(deps = {}) {
12071
+ const spawnProcess = deps.spawn ?? spawn9;
12072
+ const killProcessTree = deps.killProcessTree ?? killWindowsProcessTree;
12073
+ return {
12074
+ exec: async (command, cwd, { onData, signal, timeout, env }) => {
12075
+ if (signal?.aborted) throw new Error("aborted");
12076
+ if (timeout !== void 0 && (!Number.isFinite(timeout) || timeout <= 0 || timeout > MAX_TIMEOUT_SECONDS)) {
12077
+ throw new Error(
12078
+ `Invalid timeout: must be between 0 and ${MAX_TIMEOUT_SECONDS} seconds`
12079
+ );
12080
+ }
12081
+ const child = spawnProcess("powershell.exe", [...POWERSHELL_ARGS], {
12082
+ cwd,
12083
+ env: createWindowsPowerShellChildEnv(env),
12084
+ stdio: ["pipe", "pipe", "pipe"],
12085
+ windowsHide: true
12086
+ });
12087
+ child.stdout.on("data", onData);
12088
+ child.stderr.on("data", onData);
12089
+ child.stdin.on("error", () => void 0);
12090
+ child.stdin.end(
12091
+ Buffer.from(buildPiPowerShellScript(command), "utf16le").toString(
12092
+ "base64"
12093
+ )
12094
+ );
12095
+ let timedOut = false;
12096
+ const terminate = () => {
12097
+ if (child.pid) killProcessTree(child.pid);
12098
+ };
12099
+ const timeoutHandle = timeout === void 0 ? void 0 : setClockTimeout(() => {
12100
+ timedOut = true;
12101
+ terminate();
12102
+ }, timeout * 1e3);
12103
+ const onAbort = () => terminate();
12104
+ signal?.addEventListener("abort", onAbort, { once: true });
12105
+ if (signal?.aborted) terminate();
12106
+ try {
12107
+ const exitCode = await new Promise((resolve, reject) => {
12108
+ child.once("error", reject);
12109
+ child.once("close", resolve);
12110
+ });
12111
+ if (signal?.aborted) throw new Error("aborted");
12112
+ if (timedOut) throw new Error(`timeout:${timeout}`);
12113
+ return { exitCode };
12114
+ } finally {
12115
+ if (timeoutHandle) clearClockTimeout(timeoutHandle);
12116
+ signal?.removeEventListener("abort", onAbort);
12117
+ }
12118
+ }
12119
+ };
12120
+ }
12121
+ function createPiCommandTool(cwd, toolSpawnEnv, deps = {}) {
12122
+ const platform = deps.platform ?? process.platform;
12123
+ const tool = createBashTool(cwd, {
12124
+ ...platform === "win32" ? { operations: createPiPowerShellOperations(deps) } : {},
12125
+ spawnHook: (spawnContext) => ({
12126
+ ...spawnContext,
12127
+ env: {
12128
+ ...spawnContext.env,
12129
+ ...toolSpawnEnv
12130
+ }
12131
+ })
12132
+ });
12133
+ if (platform !== "win32") return tool;
12134
+ return {
12135
+ ...tool,
12136
+ label: "PowerShell",
12137
+ description: "Execute a Windows PowerShell 5.1 command in the current working directory. Use PowerShell syntax, not Bash syntax. Standard output and standard error are returned."
12138
+ };
12139
+ }
12140
+
12141
+ // src/drivers/pi.ts
11943
12142
  var PI_SESSION_DIR = ".pi-sessions";
11944
12143
  var BUILTIN_SESSION_DIR = ".builtin-sessions";
11945
12144
  var BUILTIN_AGENT_DIR = ".builtin-runtime";
@@ -12048,8 +12247,12 @@ async function withProcessEnvPatch(patch, fn, opts = {}) {
12048
12247
  }
12049
12248
  });
12050
12249
  }
12051
- function resolvePiModelFromRegistry(modelId, modelRegistry) {
12250
+ function resolvePiModelFromRegistry(modelId, modelRegistry, runtimeConfig) {
12052
12251
  if (!modelId || modelId === "default") return void 0;
12252
+ if (runtimeConfig.runtime === "builtin" && runtimeConfig.provider.kind === "gateway" && runtimeConfig.model.kind === "custom") {
12253
+ const provider2 = runtimeConfig.provider.providerId === "openai-compatible" ? "openai" : "anthropic";
12254
+ return modelRegistry.find(provider2, runtimeConfig.model.name);
12255
+ }
12053
12256
  const [provider, ...modelParts] = modelId.split("/");
12054
12257
  if (provider && modelParts.length > 0) {
12055
12258
  return modelRegistry.find(provider, modelParts.join("/"));
@@ -12381,7 +12584,7 @@ async function createPiAgentSessionForContext(ctx, sessionId, opts = {}) {
12381
12584
  agent_dir_source: opts.agentDirSource ?? (spawnEnv.PI_CODING_AGENT_DIR ? "spawn_env" : "default"),
12382
12585
  ...launchTraceEvidenceAttrs
12383
12586
  });
12384
- const model = resolvePiModelFromRegistry(launchRuntimeFields.model, services.modelRegistry);
12587
+ const model = resolvePiModelFromRegistry(launchRuntimeFields.model, services.modelRegistry, runtimeConfig);
12385
12588
  const resolvedModel = formatPiModelLogId(model);
12386
12589
  traceSpan?.addEvent(`${traceEventPrefix}.model_resolved`, {
12387
12590
  available_models_count: services.modelRegistry.getAvailable().length,
@@ -12437,15 +12640,7 @@ async function createPiAgentSessionForContext(ctx, sessionId, opts = {}) {
12437
12640
  model,
12438
12641
  thinkingLevel: launchRuntimeFields.reasoningEffort,
12439
12642
  customTools: [
12440
- createBashTool(ctx.workingDirectory, {
12441
- spawnHook: (spawnContext) => ({
12442
- ...spawnContext,
12443
- env: {
12444
- ...spawnContext.env,
12445
- ...toolSpawnEnv
12446
- }
12447
- })
12448
- })
12643
+ createPiCommandTool(ctx.workingDirectory, toolSpawnEnv)
12449
12644
  ]
12450
12645
  }), { removeFirst: providerEnvScope });
12451
12646
  traceSpan?.addEvent(`${traceEventPrefix}.started`, {
@@ -12756,13 +12951,15 @@ var PiDriver = class {
12756
12951
  return null;
12757
12952
  }
12758
12953
  buildSystemPrompt(config, _agentId) {
12954
+ const windowsPowerShell = process.platform === "win32";
12759
12955
  return buildCliTransportSystemPrompt(config, {
12760
- extraCriticalRules: [],
12956
+ extraCriticalRules: windowsPowerShell ? ["- Pi's `bash` tool is a compatibility name on Windows: it executes native Windows PowerShell 5.1. Use PowerShell syntax and never Bash heredocs or Unix-only commands."] : [],
12761
12957
  postStartupNotes: [
12762
12958
  "**Pi runtime note:** Slock keeps Pi running as a persistent SDK session. While you are working, Slock may send inbox-count notifications into the current turn; call `raft message check` at natural breakpoints."
12763
12959
  ],
12764
12960
  includeStdinNotificationSection: true,
12765
- messageNotificationStyle: "direct"
12961
+ messageNotificationStyle: "direct",
12962
+ commandShell: windowsPowerShell ? "powershell" : "posix"
12766
12963
  });
12767
12964
  }
12768
12965
  };
@@ -12798,13 +12995,15 @@ var BuiltInDriver = class extends PiDriver {
12798
12995
  }));
12799
12996
  }
12800
12997
  buildSystemPrompt(config, _agentId) {
12998
+ const windowsPowerShell = process.platform === "win32";
12801
12999
  return buildCliTransportSystemPrompt(config, {
12802
- extraCriticalRules: [],
13000
+ extraCriticalRules: windowsPowerShell ? ["- This runtime's `bash` tool is a compatibility name on Windows: it executes native Windows PowerShell 5.1. Use PowerShell syntax and never Bash heredocs or Unix-only commands."] : [],
12803
13001
  postStartupNotes: [
12804
13002
  "**Built-in runtime note:** Slock keeps this runtime in an isolated SDK session. While you are working, Slock may send inbox-count notifications into the current turn; call `raft message check` at natural breakpoints."
12805
13003
  ],
12806
13004
  includeStdinNotificationSection: true,
12807
- messageNotificationStyle: "direct"
13005
+ messageNotificationStyle: "direct",
13006
+ commandShell: windowsPowerShell ? "powershell" : "posix"
12808
13007
  });
12809
13008
  }
12810
13009
  };
@@ -25096,7 +25295,7 @@ function resolveSlockCliPathOrEmpty(moduleUrl = import.meta.url) {
25096
25295
  }
25097
25296
  async function runBundledSlockCli(argv) {
25098
25297
  process.argv = [process.execPath, "slock", ...argv];
25099
- await import("./dist-YLMDSQ55.js");
25298
+ await import("./dist-WK22442Z.js");
25100
25299
  }
25101
25300
  function detectRuntimes(tracer = noopTracer) {
25102
25301
  const ids = [];
@@ -26512,6 +26711,11 @@ var DaemonCore = class {
26512
26711
  });
26513
26712
  }
26514
26713
  handleConnect() {
26714
+ try {
26715
+ this.options.lifecycleHooks?.onConnect?.();
26716
+ } catch (err) {
26717
+ logger.warn(`[Daemon] Connection lifecycle hook failed: ${err instanceof Error ? err.message : String(err)}`);
26718
+ }
26515
26719
  if (!this.opencliWrappersRegenerated) {
26516
26720
  this.opencliWrappersRegenerated = true;
26517
26721
  try {
@@ -26604,7 +26808,6 @@ var DaemonCore = class {
26604
26808
  for (const agentId of agentsForSnapshot) {
26605
26809
  this.connection.send({ type: "reminder.snapshot.request", agentId });
26606
26810
  }
26607
- this.options.lifecycleHooks?.onConnect?.();
26608
26811
  }
26609
26812
  handleDisconnect() {
26610
26813
  logger.warn("[Daemon] Lost connection \u2014 agents continue running locally");
package/dist/cli/index.js CHANGED
@@ -28833,10 +28833,11 @@ var TRACE_EVENT_ROW_V2_PROJECTION_COLUMNS = [
28833
28833
  ["shadow_direction", "string"],
28834
28834
  ["shadow_plan_kind", "string"]
28835
28835
  ];
28836
+ var TRACE_EVENT_ROW_V2_TABLE = "raft.trace_events_v2";
28836
28837
  var TRACE_EVENT_ROW_V2_INGEST_STATEMENT = [
28837
28838
  "SELECT",
28838
28839
  TRACE_EVENT_ROW_V2_PROJECTION_COLUMNS.map(([column, type]) => `$0["${column}"]::${type} AS ${column}`).join(", "),
28839
- "INSERT INTO raft.trace_events_v2",
28840
+ `INSERT INTO ${TRACE_EVENT_ROW_V2_TABLE}`,
28840
28841
  `(${TRACE_EVENT_ROW_V2_PROJECTION_COLUMNS.map(([column]) => column).join(", ")})`
28841
28842
  ].join(" ");
28842
28843
  var PROMOTED_IDENTITY_ATTRS = [
package/dist/core.js CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  stageAgentMigrationObjectStoreBundle,
37
37
  subscribeDaemonLogs,
38
38
  verifyAgentMigrationAdoptPlan
39
- } from "./chunk-FGXAADHM.js";
39
+ } from "./chunk-7K62FEME.js";
40
40
  export {
41
41
  AGENT_MIGRATION_BUNDLE_SCHEMA_VERSION,
42
42
  AGENT_MIGRATION_CONTROL_SEAM_ENV,
@@ -28581,10 +28581,11 @@ var TRACE_EVENT_ROW_V2_PROJECTION_COLUMNS = [
28581
28581
  ["shadow_direction", "string"],
28582
28582
  ["shadow_plan_kind", "string"]
28583
28583
  ];
28584
+ var TRACE_EVENT_ROW_V2_TABLE = "raft.trace_events_v2";
28584
28585
  var TRACE_EVENT_ROW_V2_INGEST_STATEMENT = [
28585
28586
  "SELECT",
28586
28587
  TRACE_EVENT_ROW_V2_PROJECTION_COLUMNS.map(([column, type]) => `$0["${column}"]::${type} AS ${column}`).join(", "),
28587
- "INSERT INTO raft.trace_events_v2",
28588
+ `INSERT INTO ${TRACE_EVENT_ROW_V2_TABLE}`,
28588
28589
  `(${TRACE_EVENT_ROW_V2_PROJECTION_COLUMNS.map(([column]) => column).join(", ")})`
28589
28590
  ].join(" ");
28590
28591
  var PROMOTED_IDENTITY_ATTRS = [
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  DAEMON_CLI_USAGE,
4
4
  DaemonCore,
5
5
  parseDaemonCliArgs
6
- } from "./chunk-FGXAADHM.js";
6
+ } from "./chunk-7K62FEME.js";
7
7
 
8
8
  // src/index.ts
9
9
  var parsedArgs = parseDaemonCliArgs(process.argv.slice(2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botiverse/raft-daemon",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "raft-daemon": "dist/raft-daemon.js",
@@ -45,7 +45,7 @@
45
45
  "release:alpha": "npm version prerelease --preid=alpha --no-git-tag-version && cd ../.. && pnpm install --lockfile-only && git add packages/daemon/package.json pnpm-lock.yaml && git commit -m \"chore: bump @botiverse/raft-daemon to v$(node -p \"require('./packages/daemon/package.json').version\")\" && git tag daemon-v$(node -p \"require('./packages/daemon/package.json').version\") && git push && git push --tags"
46
46
  },
47
47
  "dependencies": {
48
- "@botiverse/kimi-code-sdk": "0.23.5-botiverse.1",
48
+ "@botiverse/kimi-code-sdk": "0.26.0-botiverse.2",
49
49
  "@earendil-works/pi-ai": "0.80.6",
50
50
  "@earendil-works/pi-coding-agent": "0.80.6",
51
51
  "@jackwener/opencli": "^1.8.3",