@linzumi/cli 0.0.72-beta → 0.0.73-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1831,6 +1831,10 @@ function interruptQueuedMessages(queue, throughSeq) {
1831
1831
  }
1832
1832
  function fuseQueuedMessages(selected) {
1833
1833
  const last = selected[selected.length - 1];
1834
+ const receivedAtMs = selected.reduce(
1835
+ (earliest, message) => message.receivedAtMs === void 0 ? earliest : earliest === void 0 ? message.receivedAtMs : Math.min(earliest, message.receivedAtMs),
1836
+ void 0
1837
+ );
1834
1838
  if (last === void 0) {
1835
1839
  return void 0;
1836
1840
  }
@@ -1839,7 +1843,8 @@ function fuseQueuedMessages(selected) {
1839
1843
  actorSlug: "kandan",
1840
1844
  actorUserId: void 0,
1841
1845
  body: selected.map(codexInputForQueuedKandanMessage).join("\n\n---\n\n"),
1842
- attachments: selected.flatMap((message) => message.attachments)
1846
+ attachments: selected.flatMap((message) => message.attachments),
1847
+ receivedAtMs
1843
1848
  };
1844
1849
  }
1845
1850
  var init_kandanQueue = __esm({
@@ -4914,6 +4919,10 @@ function parsePortForwardDecision(body) {
4914
4919
  requestId: match[2] ?? ""
4915
4920
  };
4916
4921
  }
4922
+ function runnerConsoleBodyPreview(body) {
4923
+ const normalized = body.replace(/\s+/g, " ").trim();
4924
+ return normalized.length <= 50 ? normalized : `${normalized.slice(0, 47)}...`;
4925
+ }
4917
4926
  async function handleKandanChatEvent(args, state, runnerIdentity, payloadContext, event) {
4918
4927
  const session = args.options.channelSession;
4919
4928
  if (event.type !== "thread.message") {
@@ -5032,17 +5041,25 @@ async function handleKandanChatEvent(args, state, runnerIdentity, payloadContext
5032
5041
  });
5033
5042
  return;
5034
5043
  }
5044
+ const receivedAtMs = Date.now();
5035
5045
  enqueuePendingKandanMessage(state.queue, {
5036
5046
  seq: event.seq,
5037
5047
  actorSlug: event.actorSlug,
5038
5048
  actorUserId: event.actorUserId,
5039
5049
  body: event.body,
5040
- attachments: event.attachments
5050
+ attachments: event.attachments,
5051
+ receivedAtMs
5041
5052
  });
5042
5053
  args.log("kandan.message_queued", {
5043
5054
  seq: event.seq,
5044
5055
  actor_slug: event.actorSlug ?? null,
5045
5056
  actor_user_id: event.actorUserId ?? null,
5057
+ linzumi_thread_id: state.kandanThreadId ?? null,
5058
+ codex_thread_id: state.codexThreadId ?? null,
5059
+ runner_console: {
5060
+ body_preview: runnerConsoleBodyPreview(event.body),
5061
+ message_received_at_ms: receivedAtMs
5062
+ },
5046
5063
  queue_depth: pendingKandanMessageQueueLength(state.queue)
5047
5064
  });
5048
5065
  await publishKandanMessageState(args, event, { status: "queued" });
@@ -5111,13 +5128,20 @@ async function startThreadMessageTurn(args, state, payloadContext, message) {
5111
5128
  actorSlug: message.actorSlug,
5112
5129
  actorUserId: message.actorUserId,
5113
5130
  body: message.body,
5114
- attachments: []
5131
+ attachments: [],
5132
+ receivedAtMs: Date.now()
5115
5133
  };
5116
5134
  enqueuePendingKandanMessage(state.queue, queued);
5117
5135
  args.log("kandan.message_queued", {
5118
5136
  seq: queued.seq,
5119
5137
  actor_slug: queued.actorSlug ?? null,
5120
5138
  actor_user_id: queued.actorUserId ?? null,
5139
+ linzumi_thread_id: state.kandanThreadId ?? null,
5140
+ codex_thread_id: state.codexThreadId ?? null,
5141
+ runner_console: {
5142
+ body_preview: runnerConsoleBodyPreview(queued.body),
5143
+ message_received_at_ms: queued.receivedAtMs ?? Date.now()
5144
+ },
5121
5145
  queue_depth: pendingKandanMessageQueueLength(state.queue)
5122
5146
  });
5123
5147
  await publishQueuedMessageState(args, state, queued, { status: "queued" });
@@ -5240,7 +5264,12 @@ async function drainKandanMessageQueue(args, state, payloadContext) {
5240
5264
  queued_seq: next.seq,
5241
5265
  actor_slug: next.actorSlug ?? null,
5242
5266
  actor_user_id: next.actorUserId ?? null,
5267
+ linzumi_thread_id: state.kandanThreadId ?? null,
5243
5268
  codex_thread_id: state.codexThreadId ?? null,
5269
+ runner_console: {
5270
+ body_preview: runnerConsoleBodyPreview(next.body),
5271
+ message_received_at_ms: next.receivedAtMs ?? Date.now()
5272
+ },
5244
5273
  queue_depth: pendingKandanMessageQueueLength(state.queue)
5245
5274
  });
5246
5275
  await publishQueuedMessageState(args, state, next, {
@@ -5306,7 +5335,7 @@ async function drainKandanMessageQueue(args, state, payloadContext) {
5306
5335
  state.codexThreadId = newCodexThreadId;
5307
5336
  await bindCurrentCodexThread(args, state);
5308
5337
  args.log("codex.thread_rebound", {
5309
- kandan_thread_id: state.kandanThreadId,
5338
+ linzumi_thread_id: state.kandanThreadId,
5310
5339
  old_codex_thread_id: oldCodexThreadId ?? null,
5311
5340
  new_codex_thread_id: newCodexThreadId
5312
5341
  });
@@ -5966,7 +5995,12 @@ async function postCompletedOutputProjection(args, state, payloadContext, params
5966
5995
  );
5967
5996
  break;
5968
5997
  }
5969
- logCompletedCodexOutput(args, params.turnId, params.output.message);
5998
+ logCompletedCodexOutput(
5999
+ args,
6000
+ state,
6001
+ params.turnId,
6002
+ params.output.message
6003
+ );
5970
6004
  break;
5971
6005
  }
5972
6006
  case "cached_reasoning": {
@@ -5988,7 +6022,7 @@ async function postCompletedOutputProjection(args, state, payloadContext, params
5988
6022
  message.structured
5989
6023
  );
5990
6024
  forgetStreamingReasoningOutput(state, output.itemKey);
5991
- logCompletedCodexOutput(args, params.turnId, message);
6025
+ logCompletedCodexOutput(args, state, params.turnId, message);
5992
6026
  break;
5993
6027
  }
5994
6028
  case "cached_command": {
@@ -6015,7 +6049,7 @@ async function postCompletedOutputProjection(args, state, payloadContext, params
6015
6049
  message.structured
6016
6050
  );
6017
6051
  forgetStreamingCommandOutput(state, output.itemKey);
6018
- logCompletedCodexOutput(args, params.turnId, message);
6052
+ logCompletedCodexOutput(args, state, params.turnId, message);
6019
6053
  break;
6020
6054
  }
6021
6055
  case "cached_file_change": {
@@ -6038,16 +6072,21 @@ async function postCompletedOutputProjection(args, state, payloadContext, params
6038
6072
  message.structured
6039
6073
  );
6040
6074
  forgetStreamingFileChangeOutput(state, output.itemKey);
6041
- logCompletedCodexOutput(args, params.turnId, message);
6075
+ logCompletedCodexOutput(args, state, params.turnId, message);
6042
6076
  break;
6043
6077
  }
6044
6078
  }
6045
6079
  }
6046
- function logCompletedCodexOutput(args, turnId, message) {
6080
+ function logCompletedCodexOutput(args, state, turnId, message) {
6047
6081
  args.log("kandan.codex_output_forwarded", {
6048
6082
  turn_id: turnId,
6049
6083
  item_key: message.itemKey,
6084
+ linzumi_thread_id: state.kandanThreadId,
6085
+ codex_thread_id: state.codexThreadId,
6050
6086
  structured_kind: stringValue(message.structured.kind) ?? null,
6087
+ runner_console: {
6088
+ body_preview: runnerConsoleBodyPreview(message.body)
6089
+ },
6051
6090
  command: stringValue(message.structured.command) ?? null,
6052
6091
  file_paths: fileChangePaths(message.structured)
6053
6092
  });
@@ -6281,6 +6320,8 @@ async function forwardAssistantDeltaPayload(args, state, delta, payloadContext)
6281
6320
  args.log("kandan.codex_delta_forwarded", {
6282
6321
  item_key: delta.itemKey,
6283
6322
  turn_id: delta.turnId ?? null,
6323
+ linzumi_thread_id: state.kandanThreadId,
6324
+ codex_thread_id: state.codexThreadId,
6284
6325
  content_length: nextContent.length
6285
6326
  });
6286
6327
  }
@@ -6527,6 +6568,8 @@ async function forwardReasoningDeltaPayload(args, state, delta, payloadContext)
6527
6568
  args.log("kandan.codex_reasoning_delta_forwarded", {
6528
6569
  item_key: delta.itemKey,
6529
6570
  turn_id: turnId,
6571
+ linzumi_thread_id: state.kandanThreadId,
6572
+ codex_thread_id: state.codexThreadId,
6530
6573
  content_length: nextContent.length
6531
6574
  });
6532
6575
  }
@@ -6715,6 +6758,8 @@ async function forwardCommandOutputDeltaPayload(args, state, delta, payloadConte
6715
6758
  args.log("kandan.codex_command_output_forwarded", {
6716
6759
  item_key: delta.itemKey,
6717
6760
  turn_id: turnId,
6761
+ linzumi_thread_id: state.kandanThreadId,
6762
+ codex_thread_id: state.codexThreadId,
6718
6763
  process_id: delta.processId ?? null,
6719
6764
  stream: delta.stream,
6720
6765
  output_length: persistedOutput.length
@@ -6798,6 +6843,8 @@ async function forwardFileChangeDeltaPayload(args, state, delta, payloadContext)
6798
6843
  args.log("kandan.codex_file_change_forwarded", {
6799
6844
  item_key: delta.itemKey,
6800
6845
  turn_id: turnId,
6846
+ linzumi_thread_id: state.kandanThreadId,
6847
+ codex_thread_id: state.codexThreadId,
6801
6848
  patch_length: patchText.length
6802
6849
  });
6803
6850
  }
@@ -6936,6 +6983,8 @@ async function forwardTerminalInput(args, state, params, payloadContext) {
6936
6983
  args.log("kandan.codex_output_forwarded", {
6937
6984
  turn_id: turnId,
6938
6985
  item_key: terminal.itemKey,
6986
+ linzumi_thread_id: state.kandanThreadId,
6987
+ codex_thread_id: state.codexThreadId,
6939
6988
  structured_kind: "codex_terminal_input",
6940
6989
  command: null,
6941
6990
  file_paths: []
@@ -7023,6 +7072,8 @@ async function forwardWebSearchProgress(args, state, params, payloadContext) {
7023
7072
  args.log("kandan.codex_web_search_progress_forwarded", {
7024
7073
  turn_id: progress.turnId,
7025
7074
  item_key: progress.itemKey,
7075
+ linzumi_thread_id: state.kandanThreadId,
7076
+ codex_thread_id: state.codexThreadId,
7026
7077
  query_count: queries.length
7027
7078
  });
7028
7079
  }
@@ -8898,7 +8949,7 @@ function createRunnerLogger(logFile, consoleReporter) {
8898
8949
  `,
8899
8950
  "utf8"
8900
8951
  );
8901
- consoleReporter?.(event, redacted);
8952
+ consoleReporter?.(event, runnerConsolePayload(redacted, payload));
8902
8953
  });
8903
8954
  Object.defineProperty(logger, "close", {
8904
8955
  value: () => closeStream(stream)
@@ -8953,12 +9004,19 @@ function redactObject(value) {
8953
9004
  const headerName = typeof value.name === "string" ? value.name.toLowerCase() : void 0;
8954
9005
  const shouldRedactHeaderValue = headerName === "authorization" || headerName === "cookie" || headerName === "set-cookie";
8955
9006
  return Object.fromEntries(
8956
- Object.entries(value).map(([key, entry]) => [
9007
+ Object.entries(value).filter(([key]) => key !== "runner_console").map(([key, entry]) => [
8957
9008
  key,
8958
9009
  shouldRedactHeaderValue && key === "value" ? sensitiveMarker : redactValue(entry, key)
8959
9010
  ])
8960
9011
  );
8961
9012
  }
9013
+ function runnerConsolePayload(redacted, original) {
9014
+ const consoleFields = objectValue2(original.runner_console);
9015
+ return consoleFields === void 0 ? redacted : { ...redacted, ...redactForCliLog(consoleFields) };
9016
+ }
9017
+ function objectValue2(value) {
9018
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
9019
+ }
8962
9020
  function redactArgs(args) {
8963
9021
  let redactNext = false;
8964
9022
  return args.map((arg) => {
@@ -9201,7 +9259,9 @@ var init_mcpConfig = __esm({
9201
9259
  });
9202
9260
 
9203
9261
  // src/codexAppServer.ts
9204
- import { spawn } from "node:child_process";
9262
+ import {
9263
+ spawn
9264
+ } from "node:child_process";
9205
9265
  import { createServer } from "node:net";
9206
9266
  async function chooseLoopbackPort() {
9207
9267
  return new Promise((resolve11, reject) => {
@@ -9229,6 +9289,7 @@ async function startCodexAppServer(codexBin, cwd, options = {}) {
9229
9289
  const port = await chooseLoopbackPort();
9230
9290
  const url = `ws://127.0.0.1:${port}`;
9231
9291
  const args = codexAppServerArgs(url, options);
9292
+ const stdio = codexAppServerStdio(process.stdout.isTTY === true);
9232
9293
  writeCliAuditEvent("process.spawn", {
9233
9294
  command: codexBin,
9234
9295
  args,
@@ -9238,9 +9299,15 @@ async function startCodexAppServer(codexBin, cwd, options = {}) {
9238
9299
  const child = spawn(codexBin, args, {
9239
9300
  cwd,
9240
9301
  env: codexAppServerEnv(options.env),
9241
- stdio: ["ignore", "inherit", "inherit"],
9302
+ stdio,
9242
9303
  detached: true
9243
9304
  });
9305
+ if (stdio[1] === "pipe") {
9306
+ drainCodexAppServerOutput(child, "stdout");
9307
+ }
9308
+ if (stdio[2] === "pipe") {
9309
+ drainCodexAppServerOutput(child, "stderr");
9310
+ }
9244
9311
  const stop = () => stopCodexAppServerProcess(child);
9245
9312
  writeCliAuditEvent("process.spawned", {
9246
9313
  command: codexBin,
@@ -9274,6 +9341,25 @@ async function startCodexAppServer(codexBin, cwd, options = {}) {
9274
9341
  }
9275
9342
  return { url, process: child, stop };
9276
9343
  }
9344
+ function codexAppServerStdio(stdoutIsTty) {
9345
+ return stdoutIsTty ? ["ignore", "pipe", "pipe"] : ["ignore", "inherit", "inherit"];
9346
+ }
9347
+ function drainCodexAppServerOutput(child, streamName) {
9348
+ const stream = child[streamName];
9349
+ if (stream === null) {
9350
+ return;
9351
+ }
9352
+ stream.on("data", (chunk) => {
9353
+ const text2 = chunk.toString();
9354
+ writeCliAuditEvent("process.output", {
9355
+ pid: child.pid,
9356
+ purpose: "codex.app_server",
9357
+ stream: streamName,
9358
+ chars: text2.length,
9359
+ output: text2
9360
+ });
9361
+ });
9362
+ }
9277
9363
  function codexAppServerEnv(overrides) {
9278
9364
  const env = { ...process.env };
9279
9365
  for (const key of blockedCodexAppServerEnvKeys) {
@@ -9614,9 +9700,9 @@ function codexConfigWithTrustedProject(config, projectPath) {
9614
9700
  trust_level = "trusted"
9615
9701
  `;
9616
9702
  }
9617
- const table = config.slice(range.start, range.end);
9703
+ const table2 = config.slice(range.start, range.end);
9618
9704
  const trustLine = /^(\s*trust_level\s*=\s*).*(\r?)$/m;
9619
- const nextTable = trustLine.test(table) ? table.replace(trustLine, '$1"trusted"$2') : `${trimTrailingNewlines(table)}
9705
+ const nextTable = trustLine.test(table2) ? table2.replace(trustLine, '$1"trusted"$2') : `${trimTrailingNewlines(table2)}
9620
9706
  trust_level = "trusted"
9621
9707
  `;
9622
9708
  return `${config.slice(0, range.start)}${nextTable}${config.slice(range.end)}`;
@@ -9648,6 +9734,125 @@ var init_codexProjectTrust = __esm({
9648
9734
  }
9649
9735
  });
9650
9736
 
9737
+ // src/codexNotificationConsoleStats.ts
9738
+ function codexNotificationConsoleLogPayload(method, params) {
9739
+ return {
9740
+ method,
9741
+ metadata: extractCodexIds(params),
9742
+ ...codexNotificationConsoleStats(method, params)
9743
+ };
9744
+ }
9745
+ function codexNotificationConsoleStats(method, params) {
9746
+ switch (method) {
9747
+ case "thread/tokenUsage/updated":
9748
+ return {
9749
+ token_usage_summary: tokenUsageSummary(params) ?? "seen (no details)"
9750
+ };
9751
+ case "account/rateLimits/updated":
9752
+ return {
9753
+ rate_limit_summary: rateLimitSummary(params) ?? "seen (no details)"
9754
+ };
9755
+ default:
9756
+ return {};
9757
+ }
9758
+ }
9759
+ function tokenUsageSummary(params) {
9760
+ const usage = objectValue3(params.tokenUsage) ?? objectValue3(params.token_usage) ?? objectValue3(params.usage) ?? params;
9761
+ const total = tokenUsageBreakdownSummary(objectValue3(usage.total)) ?? tokenUsageBreakdownSummary(objectValue3(usage.totalUsage)) ?? tokenUsageBreakdownSummary(objectValue3(usage.total_usage)) ?? tokenUsageBreakdownSummary(objectValue3(params.totalTokenUsage)) ?? tokenUsageBreakdownSummary(objectValue3(params.total_token_usage)) ?? tokenUsageBreakdownSummary(usage);
9762
+ const last = tokenUsageBreakdownSummary(objectValue3(usage.last)) ?? tokenUsageBreakdownSummary(objectValue3(usage.lastUsage)) ?? tokenUsageBreakdownSummary(objectValue3(usage.last_usage)) ?? tokenUsageBreakdownSummary(objectValue3(params.lastTokenUsage)) ?? tokenUsageBreakdownSummary(objectValue3(params.last_token_usage));
9763
+ const summary = [
9764
+ total === void 0 ? void 0 : `total ${total}`,
9765
+ last === void 0 ? void 0 : `last ${last}`
9766
+ ].filter((value) => value !== void 0);
9767
+ return summary.length === 0 ? void 0 : summary.join(" | ");
9768
+ }
9769
+ function tokenUsageBreakdownSummary(breakdown) {
9770
+ if (breakdown === void 0) {
9771
+ return void 0;
9772
+ }
9773
+ const inputDetails = objectValue3(breakdown.inputTokensDetails) ?? objectValue3(breakdown.input_tokens_details);
9774
+ const outputDetails = objectValue3(breakdown.outputTokensDetails) ?? objectValue3(breakdown.output_tokens_details);
9775
+ const input = integerValue2(breakdown.inputTokens) ?? integerValue2(breakdown.input_tokens) ?? integerValue2(breakdown.promptTokens) ?? integerValue2(breakdown.prompt_tokens);
9776
+ const output = integerValue2(breakdown.outputTokens) ?? integerValue2(breakdown.output_tokens) ?? integerValue2(breakdown.completionTokens) ?? integerValue2(breakdown.completion_tokens);
9777
+ const total = integerValue2(breakdown.totalTokens) ?? integerValue2(breakdown.total_tokens);
9778
+ const cached = integerValue2(breakdown.cachedInputTokens) ?? integerValue2(breakdown.cached_input_tokens) ?? integerValue2(breakdown.cacheReadInputTokens) ?? integerValue2(breakdown.cache_read_input_tokens) ?? integerValue2(inputDetails?.cachedTokens) ?? integerValue2(inputDetails?.cached_tokens);
9779
+ const reasoning = integerValue2(breakdown.reasoningOutputTokens) ?? integerValue2(breakdown.reasoning_output_tokens) ?? integerValue2(breakdown.reasoningTokens) ?? integerValue2(breakdown.reasoning_tokens) ?? integerValue2(outputDetails?.reasoningTokens) ?? integerValue2(outputDetails?.reasoning_tokens);
9780
+ const values = [
9781
+ input === void 0 ? void 0 : `${input} in`,
9782
+ output === void 0 ? void 0 : `${output} out`,
9783
+ total === void 0 ? void 0 : `${total} total`,
9784
+ cached === void 0 ? void 0 : `${cached} cached`,
9785
+ reasoning === void 0 ? void 0 : `${reasoning} reasoning`
9786
+ ].filter((value) => value !== void 0);
9787
+ return values.length === 0 ? void 0 : values.join(" / ");
9788
+ }
9789
+ function rateLimitSummary(params) {
9790
+ const rateLimits = objectValue3(params.rateLimits) ?? objectValue3(params.rate_limits) ?? objectValue3(params.limits) ?? params;
9791
+ const direct = rateLimitBucketSummary(rateLimits, void 0);
9792
+ const children = Object.entries(rateLimits).flatMap(([name, value]) => {
9793
+ const bucket = objectValue3(value);
9794
+ return bucket === void 0 ? [] : [rateLimitBucketSummary(bucket, name)];
9795
+ });
9796
+ const summaries = [direct, ...children].filter(
9797
+ (value) => value !== void 0
9798
+ );
9799
+ return summaries.length === 0 ? void 0 : summaries.join(" | ");
9800
+ }
9801
+ function rateLimitBucketSummary(bucket, fallbackName) {
9802
+ const name = stringValue2(bucket.limitName) ?? stringValue2(bucket.limit_name) ?? stringValue2(bucket.name) ?? stringValue2(bucket.type) ?? fallbackName;
9803
+ const plan = stringValue2(bucket.planType) ?? stringValue2(bucket.plan_type) ?? stringValue2(bucket.plan);
9804
+ const remaining = integerValue2(bucket.remaining) ?? integerValue2(bucket.remainingRequests) ?? integerValue2(bucket.remaining_requests) ?? integerValue2(bucket.remainingTokens) ?? integerValue2(bucket.remaining_tokens);
9805
+ const limit = integerValue2(bucket.limit) ?? integerValue2(bucket.requestLimit) ?? integerValue2(bucket.request_limit) ?? integerValue2(bucket.limitRequests) ?? integerValue2(bucket.limit_requests) ?? integerValue2(bucket.tokenLimit) ?? integerValue2(bucket.token_limit) ?? integerValue2(bucket.limitTokens) ?? integerValue2(bucket.limit_tokens);
9806
+ const reset = stringValue2(bucket.resetAt) ?? stringValue2(bucket.reset_at) ?? stringValue2(bucket.resetsAt) ?? stringValue2(bucket.resets_at) ?? unixTimestampValue(bucket.resetsAt) ?? unixTimestampValue(bucket.resets_at) ?? secondsValue(bucket.resetAfterSeconds) ?? secondsValue(bucket.reset_after_seconds) ?? secondsValue(bucket.retryAfterSeconds) ?? secondsValue(bucket.retry_after_seconds);
9807
+ const usedPercent = integerValue2(bucket.usedPercent) ?? integerValue2(bucket.used_percent);
9808
+ const windowDurationMins = integerValue2(bucket.windowDurationMins) ?? integerValue2(bucket.window_duration_mins);
9809
+ const label = [name, plan].filter((value) => value !== void 0).join(" ");
9810
+ const prefix = label === "" ? void 0 : label;
9811
+ const remainingSummary = remaining === void 0 ? void 0 : limit === void 0 ? `${remaining} remaining` : `${remaining}/${limit} remaining`;
9812
+ const fields = [
9813
+ remainingSummary,
9814
+ usedPercent === void 0 ? void 0 : `${usedPercent}% used`,
9815
+ windowDurationMins === void 0 ? void 0 : `${windowDurationMins}m window`,
9816
+ reset === void 0 ? void 0 : `reset ${reset}`
9817
+ ].filter((value) => value !== void 0);
9818
+ switch (fields.length) {
9819
+ case 0:
9820
+ return prefix === void 0 ? void 0 : `${prefix} seen (no details)`;
9821
+ default:
9822
+ return prefix === void 0 ? fields.join(" ") : `${prefix} ${fields.join(" ")}`;
9823
+ }
9824
+ }
9825
+ function secondsValue(value) {
9826
+ const seconds = integerValue2(value);
9827
+ return seconds === void 0 ? void 0 : `${seconds}s`;
9828
+ }
9829
+ function unixTimestampValue(value) {
9830
+ const seconds = integerValue2(value);
9831
+ return seconds === void 0 ? void 0 : new Date(seconds * 1e3).toISOString();
9832
+ }
9833
+ function objectValue3(value) {
9834
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
9835
+ }
9836
+ function stringValue2(value) {
9837
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
9838
+ }
9839
+ function integerValue2(value) {
9840
+ if (typeof value === "number" && Number.isSafeInteger(value)) {
9841
+ return value;
9842
+ }
9843
+ if (typeof value !== "string") {
9844
+ return void 0;
9845
+ }
9846
+ const parsed = Number.parseInt(value, 10);
9847
+ return Number.isSafeInteger(parsed) && parsed.toString() === value.trim() ? parsed : void 0;
9848
+ }
9849
+ var init_codexNotificationConsoleStats = __esm({
9850
+ "src/codexNotificationConsoleStats.ts"() {
9851
+ "use strict";
9852
+ init_protocol();
9853
+ }
9854
+ });
9855
+
9651
9856
  // src/localCapabilities.ts
9652
9857
  import { realpathSync as realpathSync2 } from "node:fs";
9653
9858
  import { homedir as homedir6 } from "node:os";
@@ -13422,7 +13627,7 @@ var linzumiCliVersion, linzumiCliVersionText;
13422
13627
  var init_version = __esm({
13423
13628
  "src/version.ts"() {
13424
13629
  "use strict";
13425
- linzumiCliVersion = "0.0.72-beta";
13630
+ linzumiCliVersion = "0.0.73-beta";
13426
13631
  linzumiCliVersionText = `linzumi ${linzumiCliVersion}`;
13427
13632
  }
13428
13633
  });
@@ -13694,13 +13899,193 @@ var init_runnerLock = __esm({
13694
13899
  });
13695
13900
 
13696
13901
  // src/runnerConsoleReporter.ts
13902
+ import blessed from "blessed";
13697
13903
  function reportRunnerConsoleEvent(event, payload) {
13904
+ if (shouldRenderDashboard()) {
13905
+ const tui = initializeDashboardTui(dashboardState);
13906
+ updateRunnerConsoleDashboard(dashboardState, event, payload, Date.now());
13907
+ if (tui !== void 0) {
13908
+ tui.render(Date.now());
13909
+ return;
13910
+ }
13911
+ initializeDashboardKeyboard(dashboardState);
13912
+ initializeDashboardTicker(dashboardState);
13913
+ const screen = renderRunnerConsoleDashboard(dashboardState, Date.now());
13914
+ if (screen !== void 0) {
13915
+ redrawScreen(screen);
13916
+ return;
13917
+ }
13918
+ }
13698
13919
  const line = formatRunnerConsoleEvent(event, payload);
13699
13920
  if (line !== void 0) {
13700
13921
  process.stdout.write(`${line}
13701
13922
  `);
13702
13923
  }
13703
13924
  }
13925
+ function shouldRenderDashboard() {
13926
+ switch (process.env.LINZUMI_RUNNER_CONSOLE) {
13927
+ case "dashboard":
13928
+ return true;
13929
+ case "lines":
13930
+ return false;
13931
+ default:
13932
+ return process.stdout.isTTY === true;
13933
+ }
13934
+ }
13935
+ function updateRunnerConsoleDashboard(state, event, payload, nowMs) {
13936
+ state.lastUpdateAtMs = nowMs;
13937
+ const previousJobKey = latestDashboardJob(state)?.key;
13938
+ switch (event) {
13939
+ case "kandan.message_queued":
13940
+ case "codex.turn_starting": {
13941
+ const job = dashboardJobForPayload(state, payload, nowMs);
13942
+ job.linzumiThreadId = stringValue3(payload.linzumi_thread_id) ?? job.linzumiThreadId;
13943
+ job.codexThreadId = stringValue3(payload.codex_thread_id) ?? job.codexThreadId;
13944
+ job.lastIncomingPreview = stringValue3(payload.body_preview) ?? job.lastIncomingPreview;
13945
+ job.lastIncomingAtMs = numberValue(payload.message_received_at_ms) ?? job.lastIncomingAtMs;
13946
+ job.queueDepth = numberValue(payload.queue_depth) ?? job.queueDepth;
13947
+ job.eventType = dashboardEventLabel(event);
13948
+ job.updatedAtMs = nowMs;
13949
+ break;
13950
+ }
13951
+ case "codex.notification": {
13952
+ const tokenUsage = stringValue3(payload.token_usage_summary);
13953
+ const rateLimit = stringValue3(payload.rate_limit_summary);
13954
+ if (tokenUsage !== void 0) {
13955
+ state.tokenUsage = tokenUsage;
13956
+ }
13957
+ if (rateLimit !== void 0) {
13958
+ state.rateLimit = mergeRateLimitSummary(state.rateLimit, rateLimit);
13959
+ }
13960
+ const method = stringValue3(payload.method);
13961
+ const metadata = objectValue4(payload.metadata);
13962
+ const metadataHasJobSignal = stringValue3(metadata?.threadId) !== void 0 || stringValue3(metadata?.turnId) !== void 0 || stringValue3(metadata?.itemId) !== void 0;
13963
+ if (!metadataHasJobSignal) {
13964
+ break;
13965
+ }
13966
+ const codexThreadId = stringValue3(metadata?.threadId);
13967
+ const job = codexThreadId === void 0 ? latestDashboardJob(state) : dashboardJobForKey(state, `codex:${codexThreadId}`, nowMs);
13968
+ if (job !== void 0) {
13969
+ job.codexThreadId = codexThreadId ?? job.codexThreadId;
13970
+ job.tokenUsage = tokenUsage ?? job.tokenUsage;
13971
+ job.latestCodexEventId = codexEventId(payload);
13972
+ job.eventType = method ?? event;
13973
+ job.turnId = stringValue3(metadata?.turnId) ?? job.turnId;
13974
+ job.updatedAtMs = nowMs;
13975
+ }
13976
+ break;
13977
+ }
13978
+ case "kandan.codex_output_forwarded":
13979
+ case "kandan.codex_delta_forwarded":
13980
+ case "kandan.codex_reasoning_delta_forwarded":
13981
+ case "kandan.codex_command_output_forwarded":
13982
+ case "kandan.codex_file_change_forwarded":
13983
+ case "kandan.codex_web_search_progress_forwarded": {
13984
+ const job = dashboardJobForPayload(state, payload, nowMs);
13985
+ job.latestCodexEventId = stringValue3(payload.item_key) ?? job.latestCodexEventId;
13986
+ job.eventType = codexOutputDashboardLabel(event, payload);
13987
+ job.turnId = stringValue3(payload.turn_id) ?? job.turnId;
13988
+ if (stringValue3(payload.structured_kind) === "codex_assistant_message") {
13989
+ job.lastAssistantPreview = stringValue3(payload.body_preview) ?? job.lastAssistantPreview;
13990
+ job.lastAssistantAtMs = nowMs;
13991
+ }
13992
+ job.updatedAtMs = nowMs;
13993
+ break;
13994
+ }
13995
+ default:
13996
+ break;
13997
+ }
13998
+ rememberRawLine(state, event, payload, previousJobKey);
13999
+ }
14000
+ function renderRunnerConsoleDashboard(state, nowMs) {
14001
+ if (state.jobs.size === 0 && state.tokenUsage === void 0 && state.rateLimit === void 0) {
14002
+ return void 0;
14003
+ }
14004
+ const jobs = Array.from(state.jobs.values()).sort(
14005
+ (left, right) => right.updatedAtMs - left.updatedAtMs
14006
+ );
14007
+ switch (state.mode.type) {
14008
+ case "table":
14009
+ return renderDashboardTable(state, jobs, nowMs);
14010
+ case "raw_all":
14011
+ return renderRawDashboard(
14012
+ state,
14013
+ "Raw Stream",
14014
+ void 0,
14015
+ "esc: table",
14016
+ state.rawLines,
14017
+ nowMs
14018
+ );
14019
+ case "raw_job": {
14020
+ const jobKey = state.mode.jobKey;
14021
+ const job = state.jobs.get(jobKey);
14022
+ const title = `Raw Stream: ${shortId(job?.linzumiThreadId)} / ${agentId(job?.codexThreadId)}`;
14023
+ return renderRawDashboard(
14024
+ state,
14025
+ title,
14026
+ job?.tokenUsage,
14027
+ "esc: table",
14028
+ state.rawLines.filter((line) => line.jobKey === jobKey),
14029
+ nowMs
14030
+ );
14031
+ }
14032
+ }
14033
+ }
14034
+ function renderDashboardTable(state, jobs, nowMs) {
14035
+ const model = dashboardTableModel(state, jobs, nowMs);
14036
+ return [
14037
+ "Linzumi Commander",
14038
+ "",
14039
+ `Jobs: ${jobs.length} Last update: ${timeAgo(state.lastUpdateAtMs, nowMs)}`,
14040
+ `Overall Token Usage: ${state.tokenUsage ?? "?"}`,
14041
+ `Account rate limits: ${state.rateLimit ?? "?"}`,
14042
+ "Controls: up/down select | enter raw job | r raw stream | esc table",
14043
+ "",
14044
+ table(model.rows),
14045
+ ""
14046
+ ].join("\n");
14047
+ }
14048
+ function dashboardTableModel(state, jobs, nowMs) {
14049
+ const selectedJobKey = selectedDashboardJobKey(state, jobs);
14050
+ const rows = jobs.length === 0 ? [dashboardTableHeader(), emptyJobRow()] : [
14051
+ dashboardTableHeader(),
14052
+ ...jobs.map((job) => jobRow(job, selectedJobKey, nowMs))
14053
+ ];
14054
+ return {
14055
+ jobs,
14056
+ selectedJobKey,
14057
+ rows
14058
+ };
14059
+ }
14060
+ function dashboardTableHeader() {
14061
+ return [
14062
+ "",
14063
+ "Linzumi thread",
14064
+ "Agent",
14065
+ "Last user message",
14066
+ "Ago",
14067
+ "Last assistant reply",
14068
+ "Ago",
14069
+ "Latest event",
14070
+ "Event type"
14071
+ ];
14072
+ }
14073
+ function mergeRateLimitSummary(previous, next) {
14074
+ if (previous === void 0) {
14075
+ return next;
14076
+ }
14077
+ const buckets = /* @__PURE__ */ new Map();
14078
+ for (const summary of previous.split(" | ")) {
14079
+ buckets.set(rateLimitSummaryKey(summary), summary);
14080
+ }
14081
+ for (const summary of next.split(" | ")) {
14082
+ buckets.set(rateLimitSummaryKey(summary), summary);
14083
+ }
14084
+ return Array.from(buckets.values()).join(" | ");
14085
+ }
14086
+ function rateLimitSummaryKey(summary) {
14087
+ return summary.split(" ", 1)[0] ?? summary;
14088
+ }
13704
14089
  function formatRunnerConsoleEvent(event, payload) {
13705
14090
  switch (event) {
13706
14091
  case "runner.instance_started":
@@ -13719,13 +14104,19 @@ function formatRunnerConsoleEvent(event, payload) {
13719
14104
  case "kandan.chat_event_failed":
13720
14105
  return `Incoming message handling failed: seq=${text(payload.seq)} reason=${text(payload.message)}`;
13721
14106
  case "kandan.reconnected":
13722
- return `Kandan reconnected: codex_session=${text(payload.codex_thread_id)} cursor=${text(payload.min_seq)}`;
14107
+ return `Linzumi reconnected: codex_session=${text(payload.codex_thread_id)} cursor=${text(payload.min_seq)}`;
13723
14108
  case "codex.turn_starting":
13724
14109
  return `Incoming message from ${sender(payload)}: forwarding to Codex session ${text(payload.codex_thread_id)} seq=${text(payload.queued_seq)}`;
13725
14110
  case "codex.turn_started":
13726
14111
  return `Codex turn started: id=${text(payload.turn_id)}`;
13727
- case "codex.notification":
13728
- return `Codex event [id=${codexEventId(payload)}]: ${text(payload.method)}`;
14112
+ case "codex.notification": {
14113
+ const summary = [
14114
+ stringValue3(payload.token_usage_summary),
14115
+ stringValue3(payload.rate_limit_summary)
14116
+ ].filter((value) => value !== void 0).join(" | ");
14117
+ const suffix = summary === "" ? "" : ` ${summary}`;
14118
+ return `Codex event [id=${codexEventId(payload)}]: ${text(payload.method)}${suffix}`;
14119
+ }
13729
14120
  case "codex.turn_completed":
13730
14121
  return `Codex turn completed: id=${text(payload.turn_id)} outputs=${text(payload.output_count)}`;
13731
14122
  case "kandan.codex_output_forwarded":
@@ -13758,11 +14149,11 @@ function connectedRunnerMessage(payload) {
13758
14149
  ].filter((line) => line !== void 0).join("\n");
13759
14150
  }
13760
14151
  function optionalLine(label, value) {
13761
- const normalized = stringValue2(value) ?? numberValue(value)?.toString();
14152
+ const normalized = stringValue3(value) ?? numberValue(value)?.toString();
13762
14153
  return normalized === void 0 ? void 0 : `${label}: ${normalized}`;
13763
14154
  }
13764
14155
  function optionalField(label, value) {
13765
- const normalized = stringValue2(value) ?? numberValue(value)?.toString();
14156
+ const normalized = stringValue3(value) ?? numberValue(value)?.toString();
13766
14157
  return normalized === void 0 ? void 0 : `${label}=${normalized}`;
13767
14158
  }
13768
14159
  function ignoredMessage(payload) {
@@ -13786,17 +14177,17 @@ function replacementLines(value) {
13786
14177
  return [];
13787
14178
  }
13788
14179
  const record = entry;
13789
- const runnerId = stringValue2(record.runnerId);
14180
+ const runnerId = stringValue3(record.runnerId);
13790
14181
  if (runnerId === void 0) {
13791
14182
  return [];
13792
14183
  }
13793
- const version = stringValue2(record.version);
14184
+ const version = stringValue3(record.version);
13794
14185
  const suffix = version === void 0 ? "" : ` (CLI ${version})`;
13795
14186
  return [`Replaced older runner from this machine: ${runnerId}${suffix}`];
13796
14187
  });
13797
14188
  }
13798
14189
  function sender(payload) {
13799
- const slug = stringValue2(payload.actor_slug);
14190
+ const slug = stringValue3(payload.actor_slug);
13800
14191
  const userId = numberValue(payload.actor_user_id);
13801
14192
  if (slug !== void 0 && userId !== void 0) {
13802
14193
  return `${slug}#${userId}`;
@@ -13804,7 +14195,7 @@ function sender(payload) {
13804
14195
  return slug ?? (userId === void 0 ? "unknown" : `user#${userId}`);
13805
14196
  }
13806
14197
  function codexOutputLabel(payload) {
13807
- const kind = stringValue2(payload.structured_kind) ?? "output";
14198
+ const kind = stringValue3(payload.structured_kind) ?? "output";
13808
14199
  switch (kind) {
13809
14200
  case "codex_assistant_message":
13810
14201
  return "assistant_message";
@@ -13830,22 +14221,653 @@ function codexEventId(payload) {
13830
14221
  const metadata = payload.metadata;
13831
14222
  if (typeof metadata === "object" && metadata !== null && !Array.isArray(metadata)) {
13832
14223
  const record = metadata;
13833
- return stringValue2(record.turnId) ?? stringValue2(record.itemId) ?? stringValue2(record.threadId) ?? "?";
14224
+ return stringValue3(record.turnId) ?? stringValue3(record.itemId) ?? stringValue3(record.threadId) ?? "?";
13834
14225
  }
13835
14226
  return "?";
13836
14227
  }
14228
+ function rememberRawLine(state, event, payload, previousJobKey) {
14229
+ const line = formatRunnerConsoleEvent(event, payload);
14230
+ if (line === void 0) {
14231
+ return;
14232
+ }
14233
+ const jobKey = dashboardRawLineJobKey(state, payload, previousJobKey);
14234
+ state.rawLines.push({ jobKey, line });
14235
+ if (state.rawLines.length > maxRawLines) {
14236
+ state.rawLines.splice(0, state.rawLines.length - maxRawLines);
14237
+ }
14238
+ }
14239
+ function dashboardRawLineJobKey(state, payload, previousJobKey) {
14240
+ const linzumiThreadId = stringValue3(payload.linzumi_thread_id);
14241
+ const codexThreadId = stringValue3(payload.codex_thread_id);
14242
+ if (linzumiThreadId !== void 0) {
14243
+ return `linzumi:${linzumiThreadId}`;
14244
+ }
14245
+ if (codexThreadId !== void 0) {
14246
+ return Array.from(state.jobs.values()).find(
14247
+ (job) => job.codexThreadId === codexThreadId
14248
+ )?.key;
14249
+ }
14250
+ const metadata = objectValue4(payload.metadata);
14251
+ const metadataCodexThreadId = stringValue3(metadata?.threadId);
14252
+ if (metadataCodexThreadId !== void 0) {
14253
+ return Array.from(state.jobs.values()).find(
14254
+ (job) => job.codexThreadId === metadataCodexThreadId
14255
+ )?.key;
14256
+ }
14257
+ return previousJobKey;
14258
+ }
14259
+ function selectedDashboardJobKey(state, jobs) {
14260
+ if (jobs.length === 0) {
14261
+ state.selectedJobKey = void 0;
14262
+ return void 0;
14263
+ }
14264
+ if (state.selectedJobKey === void 0 || jobs.every((job) => job.key !== state.selectedJobKey)) {
14265
+ state.selectedJobKey = jobs[0]?.key;
14266
+ }
14267
+ return state.selectedJobKey;
14268
+ }
14269
+ function renderRawDashboard(state, title, tokenUsage, controls, lines, nowMs) {
14270
+ const visibleLines = lines.slice(-40).map((entry) => entry.line);
14271
+ return [
14272
+ "Linzumi Commander",
14273
+ "",
14274
+ `${title} Last update: ${timeAgo(state.lastUpdateAtMs, nowMs)}`,
14275
+ ...tokenUsage === void 0 ? [] : [`Token usage: ${tokenUsage}`],
14276
+ `Controls: ${controls}`,
14277
+ "",
14278
+ ...visibleLines.length === 0 ? ["No raw events yet."] : visibleLines,
14279
+ ""
14280
+ ].join("\n");
14281
+ }
14282
+ function rawDashboardModel(state, mode) {
14283
+ switch (mode.type) {
14284
+ case "raw_all":
14285
+ return {
14286
+ title: "Raw Stream",
14287
+ tokenUsage: void 0,
14288
+ lines: state.rawLines.map((entry) => entry.line)
14289
+ };
14290
+ case "raw_job": {
14291
+ const jobKey = mode.jobKey;
14292
+ const job = state.jobs.get(jobKey);
14293
+ return {
14294
+ title: `Raw Stream: ${shortId(job?.linzumiThreadId)} / ${agentId(job?.codexThreadId)}`,
14295
+ tokenUsage: job?.tokenUsage,
14296
+ lines: state.rawLines.filter((line) => line.jobKey === jobKey).map((entry) => entry.line)
14297
+ };
14298
+ }
14299
+ }
14300
+ }
14301
+ function dashboardJobs(state) {
14302
+ return Array.from(state.jobs.values()).sort(
14303
+ (left, right) => right.updatedAtMs - left.updatedAtMs
14304
+ );
14305
+ }
14306
+ function selectDashboardJobAtVisibleIndex(state, index) {
14307
+ const jobs = dashboardJobs(state);
14308
+ const job = jobs[index];
14309
+ if (job !== void 0) {
14310
+ state.selectedJobKey = job.key;
14311
+ }
14312
+ }
14313
+ function moveSelection(state, direction) {
14314
+ const jobs = dashboardJobs(state);
14315
+ if (jobs.length === 0) {
14316
+ state.selectedJobKey = void 0;
14317
+ return;
14318
+ }
14319
+ const selectedKey = selectedDashboardJobKey(state, jobs);
14320
+ const currentIndex = Math.max(
14321
+ 0,
14322
+ jobs.findIndex((job) => job.key === selectedKey)
14323
+ );
14324
+ const nextIndex = Math.min(
14325
+ jobs.length - 1,
14326
+ Math.max(0, currentIndex + direction)
14327
+ );
14328
+ state.selectedJobKey = jobs[nextIndex]?.key;
14329
+ }
14330
+ function initializeDashboardKeyboard(state) {
14331
+ if (keyboardState.initialized || process.stdin.isTTY !== true || typeof process.stdin.setRawMode !== "function") {
14332
+ return;
14333
+ }
14334
+ keyboardState.initialized = true;
14335
+ process.stdin.setRawMode(true);
14336
+ process.stdin.resume();
14337
+ process.stdin.on("data", (chunk) => {
14338
+ handleDashboardKey(state, chunk.toString("utf8"));
14339
+ });
14340
+ }
14341
+ function initializeDashboardTicker(state) {
14342
+ if (tickerState.stop !== void 0) {
14343
+ return;
14344
+ }
14345
+ tickerState.stop = startRunnerConsoleDashboardTicker(state);
14346
+ }
14347
+ function initializeDashboardTui(state) {
14348
+ if (tuiState.dashboard !== void 0) {
14349
+ return tuiState.dashboard;
14350
+ }
14351
+ if (process.stdin.isTTY !== true || process.stdout.isTTY !== true) {
14352
+ return void 0;
14353
+ }
14354
+ const dashboard = createRunnerConsoleDashboardTui(state);
14355
+ tuiState.dashboard = dashboard;
14356
+ tuiState.stop = startRunnerConsoleDashboardRenderTicker(() => {
14357
+ dashboard.render(Date.now());
14358
+ });
14359
+ return dashboard;
14360
+ }
14361
+ function startRunnerConsoleDashboardTicker(state, redraw = redrawScreen, intervalMs = 1e3) {
14362
+ const interval = setInterval(() => {
14363
+ const screen = renderRunnerConsoleDashboard(state, Date.now());
14364
+ if (screen !== void 0) {
14365
+ redraw(screen);
14366
+ }
14367
+ }, intervalMs);
14368
+ interval.unref?.();
14369
+ return () => {
14370
+ clearInterval(interval);
14371
+ };
14372
+ }
14373
+ function startRunnerConsoleDashboardRenderTicker(render, intervalMs = 1e3) {
14374
+ const interval = setInterval(render, intervalMs);
14375
+ interval.unref?.();
14376
+ return () => {
14377
+ clearInterval(interval);
14378
+ };
14379
+ }
14380
+ function handleDashboardKey(state, key, exitProcess = () => process.kill(process.pid, "SIGINT")) {
14381
+ if (key === ctrlCKey) {
14382
+ exitProcess();
14383
+ return;
14384
+ }
14385
+ updateRunnerConsoleDashboardMode(state, key);
14386
+ const screen = renderRunnerConsoleDashboard(state, Date.now());
14387
+ if (screen !== void 0) {
14388
+ redrawScreen(screen);
14389
+ }
14390
+ }
14391
+ function createRunnerConsoleDashboardTui(state, exitProcess = () => process.kill(process.pid, "SIGINT")) {
14392
+ let rendering = false;
14393
+ let rawScrollAnchor;
14394
+ const screen = blessed.screen({
14395
+ title: "Linzumi Commander",
14396
+ smartCSR: true,
14397
+ fullUnicode: true,
14398
+ mouse: true
14399
+ });
14400
+ const header = blessed.box({
14401
+ top: 0,
14402
+ left: 0,
14403
+ width: "100%",
14404
+ height: 6,
14405
+ tags: false
14406
+ });
14407
+ const tableElement = blessed.listtable({
14408
+ top: 6,
14409
+ left: 0,
14410
+ width: "100%",
14411
+ bottom: 1,
14412
+ keys: true,
14413
+ vi: true,
14414
+ mouse: true,
14415
+ scrollable: true,
14416
+ alwaysScroll: true,
14417
+ border: "line",
14418
+ pad: 1,
14419
+ data: [dashboardTableHeader(), emptyJobRow()],
14420
+ scrollbar: {
14421
+ ch: " ",
14422
+ style: { inverse: true }
14423
+ },
14424
+ style: {
14425
+ header: { bold: true },
14426
+ cell: {
14427
+ selected: {
14428
+ inverse: true
14429
+ }
14430
+ },
14431
+ border: {
14432
+ fg: "grey"
14433
+ }
14434
+ }
14435
+ });
14436
+ const rawTitle = blessed.box({
14437
+ top: 0,
14438
+ left: 12,
14439
+ right: 0,
14440
+ height: 2,
14441
+ tags: false,
14442
+ hidden: true
14443
+ });
14444
+ const backButton = blessed.button({
14445
+ top: 0,
14446
+ left: 0,
14447
+ width: 10,
14448
+ height: 1,
14449
+ content: "< Back",
14450
+ mouse: true,
14451
+ keys: true,
14452
+ shrink: true,
14453
+ hidden: true,
14454
+ style: {
14455
+ focus: { inverse: true },
14456
+ hover: { inverse: true }
14457
+ }
14458
+ });
14459
+ const rawBox = blessed.box({
14460
+ top: 3,
14461
+ left: 0,
14462
+ width: "100%",
14463
+ bottom: 0,
14464
+ keys: true,
14465
+ vi: true,
14466
+ mouse: true,
14467
+ scrollable: true,
14468
+ alwaysScroll: true,
14469
+ border: "line",
14470
+ tags: false,
14471
+ hidden: true,
14472
+ scrollbar: {
14473
+ ch: " ",
14474
+ style: { inverse: true }
14475
+ },
14476
+ style: {
14477
+ border: {
14478
+ fg: "grey"
14479
+ }
14480
+ }
14481
+ });
14482
+ screen.append(header);
14483
+ screen.append(tableElement);
14484
+ screen.append(rawTitle);
14485
+ screen.append(backButton);
14486
+ screen.append(rawBox);
14487
+ const showTable = () => {
14488
+ state.mode = { type: "table" };
14489
+ render(Date.now());
14490
+ };
14491
+ const showAllRaw = () => {
14492
+ state.mode = { type: "raw_all" };
14493
+ render(Date.now());
14494
+ };
14495
+ const showSelectedRaw = () => {
14496
+ const selectedKey = selectedDashboardJobKey(state, dashboardJobs(state));
14497
+ if (selectedKey !== void 0) {
14498
+ state.mode = { type: "raw_job", jobKey: selectedKey };
14499
+ render(Date.now());
14500
+ }
14501
+ };
14502
+ screen.key(["C-c"], () => {
14503
+ destroy();
14504
+ exitProcess();
14505
+ });
14506
+ screen.key(["escape"], showTable);
14507
+ screen.key(["r"], showAllRaw);
14508
+ tableElement.key(["enter"], showSelectedRaw);
14509
+ tableElement.on("select item", (_item, index) => {
14510
+ if (rendering || state.mode.type !== "table") {
14511
+ return;
14512
+ }
14513
+ selectDashboardJobAtVisibleIndex(state, index - 1);
14514
+ });
14515
+ tableElement.on("select", (_item, index) => {
14516
+ if (rendering || state.mode.type !== "table") {
14517
+ return;
14518
+ }
14519
+ selectDashboardJobAtVisibleIndex(state, index - 1);
14520
+ showSelectedRaw();
14521
+ });
14522
+ backButton.on("press", showTable);
14523
+ backButton.on("click", showTable);
14524
+ function render(nowMs) {
14525
+ rendering = true;
14526
+ try {
14527
+ switch (state.mode.type) {
14528
+ case "table": {
14529
+ const model = dashboardTableModel(state, dashboardJobs(state), nowMs);
14530
+ header.setContent(tuiHeaderContent(state, model.jobs.length, nowMs));
14531
+ header.show();
14532
+ tableElement.setData(model.rows);
14533
+ tableElement.show();
14534
+ rawTitle.hide();
14535
+ backButton.hide();
14536
+ rawBox.hide();
14537
+ rawScrollAnchor = void 0;
14538
+ syncTuiTableSelection(tableElement, model);
14539
+ tableElement.focus();
14540
+ break;
14541
+ }
14542
+ case "raw_all":
14543
+ case "raw_job": {
14544
+ const model = rawDashboardModel(state, state.mode);
14545
+ const nextRawScrollAnchor = `${state.mode.type}:${state.mode.type === "raw_job" ? state.mode.jobKey : "*"}:${model.lines.length}`;
14546
+ header.hide();
14547
+ tableElement.hide();
14548
+ rawTitle.setContent(
14549
+ [
14550
+ `${model.title} Last update: ${timeAgo(state.lastUpdateAtMs, nowMs)} esc/back: table`,
14551
+ model.tokenUsage === void 0 ? void 0 : `Token usage: ${model.tokenUsage}`
14552
+ ].filter((value) => value !== void 0).join("\n")
14553
+ );
14554
+ rawBox.setContent(
14555
+ model.lines.length === 0 ? "No raw events yet." : model.lines.join("\n")
14556
+ );
14557
+ rawTitle.show();
14558
+ backButton.show();
14559
+ rawBox.show();
14560
+ if (rawScrollAnchor !== nextRawScrollAnchor) {
14561
+ rawBox.setScrollPerc(100);
14562
+ rawScrollAnchor = nextRawScrollAnchor;
14563
+ }
14564
+ rawBox.focus();
14565
+ break;
14566
+ }
14567
+ }
14568
+ screen.render();
14569
+ } finally {
14570
+ rendering = false;
14571
+ }
14572
+ }
14573
+ function destroy() {
14574
+ tuiState.stop?.();
14575
+ tuiState.stop = void 0;
14576
+ tuiState.dashboard = void 0;
14577
+ screen.destroy();
14578
+ }
14579
+ return { render, destroy };
14580
+ }
14581
+ function syncTuiTableSelection(tableElement, model) {
14582
+ const selectedIndex = model.jobs.findIndex(
14583
+ (job) => job.key === model.selectedJobKey
14584
+ );
14585
+ const tableIndex = selectedIndex < 0 ? 1 : selectedIndex + 1;
14586
+ tableElement.select(tableIndex);
14587
+ }
14588
+ function tuiHeaderContent(state, jobCount, nowMs) {
14589
+ return [
14590
+ "Linzumi Commander",
14591
+ `Jobs: ${jobCount} Last update: ${timeAgo(state.lastUpdateAtMs, nowMs)}`,
14592
+ `Overall Token Usage: ${state.tokenUsage ?? "?"}`,
14593
+ `Account rate limits: ${state.rateLimit ?? "?"}`,
14594
+ "Controls: click row/enter raw job | r raw stream | esc/back table | mouse wheel scroll"
14595
+ ].join("\n");
14596
+ }
14597
+ function updateRunnerConsoleDashboardMode(state, key) {
14598
+ switch (key) {
14599
+ case "r":
14600
+ state.mode = { type: "raw_all" };
14601
+ break;
14602
+ case escapeKey:
14603
+ state.mode = { type: "table" };
14604
+ break;
14605
+ case enterKey: {
14606
+ const selectedKey = selectedDashboardJobKey(state, dashboardJobs(state));
14607
+ if (selectedKey !== void 0) {
14608
+ state.mode = { type: "raw_job", jobKey: selectedKey };
14609
+ }
14610
+ break;
14611
+ }
14612
+ case upKey:
14613
+ moveSelection(state, -1);
14614
+ break;
14615
+ case downKey:
14616
+ moveSelection(state, 1);
14617
+ break;
14618
+ default:
14619
+ break;
14620
+ }
14621
+ }
14622
+ function dashboardJobForPayload(state, payload, nowMs) {
14623
+ const linzumiThreadId = stringValue3(payload.linzumi_thread_id);
14624
+ const codexThreadId = stringValue3(payload.codex_thread_id);
14625
+ const existingByCodex = codexThreadId !== void 0 ? Array.from(state.jobs.values()).find(
14626
+ (job) => job.codexThreadId === codexThreadId
14627
+ ) : void 0;
14628
+ if (existingByCodex !== void 0) {
14629
+ return promoteDashboardJobKey(state, existingByCodex, linzumiThreadId);
14630
+ }
14631
+ const key = linzumiThreadId === void 0 ? codexThreadId === void 0 ? "job:unknown" : `codex:${codexThreadId}` : `linzumi:${linzumiThreadId}`;
14632
+ const existing = state.jobs.get(key);
14633
+ if (existing !== void 0) {
14634
+ return existing;
14635
+ }
14636
+ const created = {
14637
+ key,
14638
+ linzumiThreadId,
14639
+ codexThreadId,
14640
+ tokenUsage: void 0,
14641
+ lastIncomingPreview: void 0,
14642
+ lastIncomingAtMs: void 0,
14643
+ lastAssistantPreview: void 0,
14644
+ lastAssistantAtMs: void 0,
14645
+ latestCodexEventId: void 0,
14646
+ eventType: void 0,
14647
+ queueDepth: void 0,
14648
+ turnId: void 0,
14649
+ updatedAtMs: nowMs
14650
+ };
14651
+ state.jobs.set(key, created);
14652
+ return created;
14653
+ }
14654
+ function promoteDashboardJobKey(state, job, linzumiThreadId) {
14655
+ if (linzumiThreadId === void 0) {
14656
+ return job;
14657
+ }
14658
+ const key = `linzumi:${linzumiThreadId}`;
14659
+ if (job.key === key) {
14660
+ job.linzumiThreadId = linzumiThreadId;
14661
+ return job;
14662
+ }
14663
+ const promoted = { ...job, key, linzumiThreadId };
14664
+ state.jobs.delete(job.key);
14665
+ state.jobs.set(key, promoted);
14666
+ if (state.selectedJobKey === job.key) {
14667
+ state.selectedJobKey = key;
14668
+ }
14669
+ if (state.mode.type === "raw_job" && state.mode.jobKey === job.key) {
14670
+ state.mode = { type: "raw_job", jobKey: key };
14671
+ }
14672
+ state.rawLines.splice(
14673
+ 0,
14674
+ state.rawLines.length,
14675
+ ...state.rawLines.map(
14676
+ (line) => line.jobKey === job.key ? { ...line, jobKey: key } : line
14677
+ )
14678
+ );
14679
+ return promoted;
14680
+ }
14681
+ function dashboardJobForKey(state, key, nowMs) {
14682
+ if (key.startsWith("codex:")) {
14683
+ const codexThreadId = key.slice("codex:".length);
14684
+ const existingByCodex = Array.from(state.jobs.values()).find(
14685
+ (job) => job.codexThreadId === codexThreadId
14686
+ );
14687
+ if (existingByCodex !== void 0) {
14688
+ return existingByCodex;
14689
+ }
14690
+ }
14691
+ const existing = state.jobs.get(key);
14692
+ if (existing !== void 0) {
14693
+ return existing;
14694
+ }
14695
+ const created = {
14696
+ key,
14697
+ linzumiThreadId: void 0,
14698
+ codexThreadId: key.startsWith("codex:") ? key.slice("codex:".length) : void 0,
14699
+ tokenUsage: void 0,
14700
+ lastIncomingPreview: void 0,
14701
+ lastIncomingAtMs: void 0,
14702
+ lastAssistantPreview: void 0,
14703
+ lastAssistantAtMs: void 0,
14704
+ latestCodexEventId: void 0,
14705
+ eventType: void 0,
14706
+ queueDepth: void 0,
14707
+ turnId: void 0,
14708
+ updatedAtMs: nowMs
14709
+ };
14710
+ state.jobs.set(key, created);
14711
+ return created;
14712
+ }
14713
+ function latestDashboardJob(state) {
14714
+ return Array.from(state.jobs.values()).sort(
14715
+ (left, right) => right.updatedAtMs - left.updatedAtMs
14716
+ )[0];
14717
+ }
14718
+ function jobRow(job, selectedJobKey, nowMs) {
14719
+ return [
14720
+ job.key === selectedJobKey ? ">" : " ",
14721
+ shortId(job.linzumiThreadId),
14722
+ agentId(job.codexThreadId),
14723
+ truncate(job.lastIncomingPreview ?? "?", 50),
14724
+ timeAgo(job.lastIncomingAtMs, nowMs),
14725
+ truncate(job.lastAssistantPreview ?? "?", 50),
14726
+ timeAgo(job.lastAssistantAtMs, nowMs),
14727
+ lastFour(job.latestCodexEventId),
14728
+ truncate(job.eventType ?? "?", 34)
14729
+ ];
14730
+ }
14731
+ function emptyJobRow() {
14732
+ return [" ", "?", "?", "?", "?", "?", "?", "?", "?"];
14733
+ }
14734
+ function codexOutputDashboardLabel(event, payload) {
14735
+ switch (event) {
14736
+ case "kandan.codex_output_forwarded":
14737
+ return codexOutputLabel(payload);
14738
+ case "kandan.codex_delta_forwarded":
14739
+ return "assistant_delta";
14740
+ case "kandan.codex_reasoning_delta_forwarded":
14741
+ return "reasoning_delta";
14742
+ case "kandan.codex_command_output_forwarded":
14743
+ return `command_output ${text(payload.stream)}`;
14744
+ case "kandan.codex_file_change_forwarded":
14745
+ return "file_change";
14746
+ case "kandan.codex_web_search_progress_forwarded":
14747
+ return "search_progress";
14748
+ default:
14749
+ return event;
14750
+ }
14751
+ }
14752
+ function dashboardEventLabel(event) {
14753
+ switch (event) {
14754
+ case "kandan.message_queued":
14755
+ return "message_queued";
14756
+ case "codex.turn_starting":
14757
+ return "turn_starting";
14758
+ default:
14759
+ return event;
14760
+ }
14761
+ }
14762
+ function table(rows) {
14763
+ if (rows.length === 0) {
14764
+ return "";
14765
+ }
14766
+ const widths = dashboardTableColumns.map((column) => column.width);
14767
+ const divider = widths.map((width) => "-".repeat(width)).join("-+-");
14768
+ return rows.map((row, index) => {
14769
+ const line = row.map(
14770
+ (cell, cellIndex) => fixedWidthCell(cell, widths[cellIndex] ?? displayWidth(cell))
14771
+ ).join(" | ");
14772
+ return index === 0 ? `${line}
14773
+ ${divider}` : line;
14774
+ }).join("\n");
14775
+ }
14776
+ function displayWidth(value) {
14777
+ return value.length;
14778
+ }
14779
+ function shortId(value) {
14780
+ return value === void 0 ? "?" : truncate(value, 18);
14781
+ }
14782
+ function agentId(codexThreadId) {
14783
+ if (codexThreadId === void 0) {
14784
+ return "?";
14785
+ }
14786
+ return `codex/...${lastN(codexThreadId, 5)}`;
14787
+ }
14788
+ function fixedWidthCell(value, width) {
14789
+ return truncate(value, width).padEnd(width, " ");
14790
+ }
14791
+ function truncate(value, maxLength) {
14792
+ if (value.length <= maxLength) {
14793
+ return value;
14794
+ }
14795
+ return `${value.slice(0, Math.max(0, maxLength - 3))}...`;
14796
+ }
14797
+ function lastFour(value) {
14798
+ if (value === void 0) {
14799
+ return "?";
14800
+ }
14801
+ return lastN(value, 4);
14802
+ }
14803
+ function lastN(value, count) {
14804
+ return value.length <= count ? value : value.slice(-count);
14805
+ }
14806
+ function timeAgo(valueMs, nowMs) {
14807
+ if (valueMs === void 0) {
14808
+ return "?";
14809
+ }
14810
+ const seconds = Math.max(0, Math.floor((nowMs - valueMs) / 1e3));
14811
+ if (seconds < 60) {
14812
+ return `${seconds}s`;
14813
+ }
14814
+ const minutes = Math.floor(seconds / 60);
14815
+ if (minutes < 60) {
14816
+ return `${minutes}m`;
14817
+ }
14818
+ return `${Math.floor(minutes / 60)}h`;
14819
+ }
14820
+ function objectValue4(value) {
14821
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
14822
+ }
13837
14823
  function text(value) {
13838
- return stringValue2(value) ?? numberValue(value)?.toString() ?? "?";
14824
+ return stringValue3(value) ?? numberValue(value)?.toString() ?? "?";
13839
14825
  }
13840
- function stringValue2(value) {
14826
+ function stringValue3(value) {
13841
14827
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
13842
14828
  }
13843
14829
  function numberValue(value) {
13844
14830
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
13845
14831
  }
14832
+ var dashboardState, maxRawLines, escapeKey, ctrlCKey, enterKey, upKey, downKey, dashboardTableColumns, redrawScreen, keyboardState, tickerState, tuiState;
13846
14833
  var init_runnerConsoleReporter = __esm({
13847
14834
  "src/runnerConsoleReporter.ts"() {
13848
14835
  "use strict";
14836
+ dashboardState = {
14837
+ jobs: /* @__PURE__ */ new Map(),
14838
+ rawLines: [],
14839
+ mode: { type: "table" },
14840
+ selectedJobKey: void 0,
14841
+ tokenUsage: void 0,
14842
+ rateLimit: void 0,
14843
+ lastUpdateAtMs: void 0
14844
+ };
14845
+ maxRawLines = 500;
14846
+ escapeKey = "\x1B";
14847
+ ctrlCKey = "";
14848
+ enterKey = "\r";
14849
+ upKey = "\x1B[A";
14850
+ downKey = "\x1B[B";
14851
+ dashboardTableColumns = [
14852
+ { width: 1 },
14853
+ { width: 20 },
14854
+ { width: 16 },
14855
+ { width: 38 },
14856
+ { width: 6 },
14857
+ { width: 42 },
14858
+ { width: 6 },
14859
+ { width: 12 },
14860
+ { width: 24 }
14861
+ ];
14862
+ redrawScreen = (screen) => {
14863
+ process.stdout.write(`\x1B[2J\x1B[H${screen}`);
14864
+ };
14865
+ keyboardState = { initialized: false };
14866
+ tickerState = { stop: void 0 };
14867
+ tuiState = {
14868
+ dashboard: void 0,
14869
+ stop: void 0
14870
+ };
13849
14871
  }
13850
14872
  });
13851
14873
 
@@ -15675,11 +16697,10 @@ async function openLocalCodexRunner(options, log, cleanup, close) {
15675
16697
  sessionCodex.onNotification((notification) => {
15676
16698
  seq.value += 1;
15677
16699
  const params = notification.params ?? {};
15678
- const metadata = extractCodexIds(params);
15679
- log("codex.notification", {
15680
- method: notification.method,
15681
- metadata
15682
- });
16700
+ log(
16701
+ "codex.notification",
16702
+ codexNotificationConsoleLogPayload(notification.method, params)
16703
+ );
15683
16704
  session.handleCodexNotification(notification.method, params);
15684
16705
  });
15685
16706
  }
@@ -15894,14 +16915,17 @@ async function openLocalCodexRunner(options, log, cleanup, close) {
15894
16915
  codex.onNotification((notification) => {
15895
16916
  seq.value += 1;
15896
16917
  const params = notification.params ?? {};
15897
- const metadata = extractCodexIds(params);
16918
+ const logPayload = codexNotificationConsoleLogPayload(
16919
+ notification.method,
16920
+ params
16921
+ );
15898
16922
  if (channelSession === void 0) {
15899
16923
  void kandan.push(topic, "codex_notification", {
15900
16924
  instanceId,
15901
16925
  seq: seq.value,
15902
16926
  method: notification.method,
15903
16927
  params,
15904
- metadata,
16928
+ metadata: logPayload.metadata,
15905
16929
  receivedAt: (/* @__PURE__ */ new Date()).toISOString()
15906
16930
  }).catch((error) => {
15907
16931
  log("kandan.codex_notification_push_failed", {
@@ -15909,10 +16933,7 @@ async function openLocalCodexRunner(options, log, cleanup, close) {
15909
16933
  });
15910
16934
  });
15911
16935
  }
15912
- log("codex.notification", {
15913
- method: notification.method,
15914
- metadata
15915
- });
16936
+ log("codex.notification", logPayload);
15916
16937
  channelSession?.handleCodexNotification(notification.method, params);
15917
16938
  for (const session of dynamicChannelSessions.values()) {
15918
16939
  session.handleCodexNotification(notification.method, params);
@@ -19474,6 +20495,7 @@ var init_runner = __esm({
19474
20495
  init_codexAppServer();
19475
20496
  init_codexProjectTrust();
19476
20497
  init_codexRuntimeOptions();
20498
+ init_codexNotificationConsoleStats();
19477
20499
  init_json();
19478
20500
  init_linzumiContext();
19479
20501
  init_localCapabilities();
@@ -29823,23 +30845,23 @@ var require_sbcs = __commonJS({
29823
30845
  this.ngramList = theNgramList;
29824
30846
  this.byteMap = theByteMap;
29825
30847
  }
29826
- search(table, value) {
30848
+ search(table2, value) {
29827
30849
  let index = 0;
29828
- if (table[index + 32] <= value)
30850
+ if (table2[index + 32] <= value)
29829
30851
  index += 32;
29830
- if (table[index + 16] <= value)
30852
+ if (table2[index + 16] <= value)
29831
30853
  index += 16;
29832
- if (table[index + 8] <= value)
30854
+ if (table2[index + 8] <= value)
29833
30855
  index += 8;
29834
- if (table[index + 4] <= value)
30856
+ if (table2[index + 4] <= value)
29835
30857
  index += 4;
29836
- if (table[index + 2] <= value)
30858
+ if (table2[index + 2] <= value)
29837
30859
  index += 2;
29838
- if (table[index + 1] <= value)
30860
+ if (table2[index + 1] <= value)
29839
30861
  index += 1;
29840
- if (table[index] > value)
30862
+ if (table2[index] > value)
29841
30863
  index -= 1;
29842
- if (index < 0 || table[index] != value)
30864
+ if (index < 0 || table2[index] != value)
29843
30865
  return -1;
29844
30866
  return index;
29845
30867
  }
@@ -36478,15 +37500,15 @@ var require_dbcs_codec = __commonJS({
36478
37500
  this.nodeIdx = 0;
36479
37501
  return ret;
36480
37502
  };
36481
- function findIdx(table, val) {
36482
- if (table[0] > val) {
37503
+ function findIdx(table2, val) {
37504
+ if (table2[0] > val) {
36483
37505
  return -1;
36484
37506
  }
36485
37507
  var l = 0;
36486
- var r = table.length;
37508
+ var r = table2.length;
36487
37509
  while (l < r - 1) {
36488
37510
  var mid = l + (r - l + 1 >> 1);
36489
- if (table[mid] <= val) {
37511
+ if (table2[mid] <= val) {
36490
37512
  l = mid;
36491
37513
  } else {
36492
37514
  r = mid;
@@ -38537,8 +39559,8 @@ var init_esm6 = __esm({
38537
39559
  if (status === "loading") {
38538
39560
  helpTip = theme.style.help("Received");
38539
39561
  } else if (status === "idle") {
38540
- const enterKey = theme.style.key("enter");
38541
- helpTip = theme.style.help(`Press ${enterKey} to launch your preferred editor.`);
39562
+ const enterKey2 = theme.style.key("enter");
39563
+ helpTip = theme.style.help(`Press ${enterKey2} to launch your preferred editor.`);
38542
39564
  }
38543
39565
  let error = "";
38544
39566
  if (errorMsg) {
@@ -39568,15 +40590,15 @@ function signupErrorCodeFromResponseText(text2) {
39568
40590
  function renderEmailCodeStart(value) {
39569
40591
  const body = objectRecord(value, "signup email-code start response");
39570
40592
  return {
39571
- pendingId: stringValue4(body, "pending_id"),
39572
- email: stringValue4(body, "email")
40593
+ pendingId: stringValue5(body, "pending_id"),
40594
+ email: stringValue5(body, "email")
39573
40595
  };
39574
40596
  }
39575
40597
  function renderEmailCodeVerify(value) {
39576
40598
  const body = objectRecord(value, "signup email-code verify response");
39577
40599
  return {
39578
- accessToken: stringValue4(body, "access_token"),
39579
- refreshToken: stringValue4(body, "refresh_token"),
40600
+ accessToken: stringValue5(body, "access_token"),
40601
+ refreshToken: stringValue5(body, "refresh_token"),
39580
40602
  expiresInSeconds: positiveIntegerValue(body, "expires_in"),
39581
40603
  user: renderUserRef(requiredValue(body, "user")),
39582
40604
  isNewUser: booleanValue(body, "is_new_user"),
@@ -39616,7 +40638,7 @@ function renderMissionControlComplete(value) {
39616
40638
  localRunnerToken: renderLocalRunnerToken(
39617
40639
  requiredValue(body, "local_runner_token")
39618
40640
  ),
39619
- launchUrl: stringValue4(body, "launch_url"),
40641
+ launchUrl: stringValue5(body, "launch_url"),
39620
40642
  ...missionControlUrl === void 0 ? {} : { missionControlUrl },
39621
40643
  config: {
39622
40644
  allowedCwds: arrayValue2(config, "allowed_cwds").map(
@@ -39636,21 +40658,21 @@ function renderLocalRunnerToken(value) {
39636
40658
  const body = objectRecord(value, "signup local runner token");
39637
40659
  const expiresInSeconds = optionalPositiveIntegerValue(body, "expires_in");
39638
40660
  return {
39639
- accessToken: stringValue4(body, "access_token"),
40661
+ accessToken: stringValue5(body, "access_token"),
39640
40662
  ...expiresInSeconds === void 0 ? {} : { expiresInSeconds },
39641
- workspaceSlug: stringValue4(body, "workspace"),
39642
- channelSlug: stringValue4(body, "channel")
40663
+ workspaceSlug: stringValue5(body, "workspace"),
40664
+ channelSlug: stringValue5(body, "channel")
39643
40665
  };
39644
40666
  }
39645
40667
  function renderTaskStartResult(value) {
39646
40668
  const body = objectRecord(value, "signup task start");
39647
- const status = stringValue4(body, "status");
40669
+ const status = stringValue5(body, "status");
39648
40670
  if (status !== "queued" && status !== "started" && status !== "failed") {
39649
40671
  throw new Error("signup task start status was incomplete");
39650
40672
  }
39651
40673
  return {
39652
- threadId: stringValue4(body, "thread_id"),
39653
- title: stringValue4(body, "title"),
40674
+ threadId: stringValue5(body, "thread_id"),
40675
+ title: stringValue5(body, "title"),
39654
40676
  status,
39655
40677
  ...optionalStringValue(body, "runner_id") === void 0 ? {} : { runnerId: optionalStringValue(body, "runner_id") },
39656
40678
  ...optionalStringValue(body, "error") === void 0 ? {} : { error: optionalStringValue(body, "error") }
@@ -39660,7 +40682,7 @@ function renderUserRef(value) {
39660
40682
  const body = objectRecord(value, "signup user");
39661
40683
  return {
39662
40684
  id: positiveIntegerValue(body, "id"),
39663
- username: stringValue4(body, "username"),
40685
+ username: stringValue5(body, "username"),
39664
40686
  ...optionalStringValue(body, "display_name") === void 0 ? {} : { displayName: optionalStringValue(body, "display_name") },
39665
40687
  ...optionalStringValue(body, "primary_email") === void 0 ? {} : { primaryEmail: optionalStringValue(body, "primary_email") }
39666
40688
  };
@@ -39669,23 +40691,23 @@ function renderWorkspaceRef(value) {
39669
40691
  const body = objectRecord(value, "signup workspace");
39670
40692
  return {
39671
40693
  id: positiveIntegerValue(body, "id"),
39672
- slug: stringValue4(body, "slug"),
39673
- name: stringValue4(body, "name")
40694
+ slug: stringValue5(body, "slug"),
40695
+ name: stringValue5(body, "name")
39674
40696
  };
39675
40697
  }
39676
40698
  function renderChannelRef(value) {
39677
40699
  const body = objectRecord(value, "signup channel");
39678
40700
  return {
39679
40701
  id: positiveIntegerValue(body, "id"),
39680
- slug: stringValue4(body, "slug"),
39681
- name: stringValue4(body, "name")
40702
+ slug: stringValue5(body, "slug"),
40703
+ name: stringValue5(body, "name")
39682
40704
  };
39683
40705
  }
39684
40706
  function renderThreadRef(value) {
39685
40707
  const body = objectRecord(value, "signup thread");
39686
40708
  return {
39687
- threadId: stringValue4(body, "thread_id"),
39688
- title: stringValue4(body, "title"),
40709
+ threadId: stringValue5(body, "thread_id"),
40710
+ title: stringValue5(body, "title"),
39689
40711
  rootSeq: positiveIntegerValue(body, "root_seq"),
39690
40712
  threadSeq: positiveIntegerValue(body, "thread_seq")
39691
40713
  };
@@ -39703,7 +40725,7 @@ function requiredValue(record, key) {
39703
40725
  }
39704
40726
  return value;
39705
40727
  }
39706
- function stringValue4(record, key) {
40728
+ function stringValue5(record, key) {
39707
40729
  return stringFromUnknown(requiredValue(record, key), `signup ${key}`);
39708
40730
  }
39709
40731
  function optionalStringValue(record, key) {
@@ -56065,16 +57087,16 @@ async function runMcpServer(args) {
56065
57087
  const kandanUrl = required(values, "api-url");
56066
57088
  const auth = await resolveMcpAuth({
56067
57089
  kandanUrl,
56068
- explicitToken: stringValue3(values, "token") ?? process.env.LINZUMI_MCP_ACCESS_TOKEN,
56069
- authFilePath: stringValue3(values, "auth-file"),
56070
- delegationAuthFilePath: stringValue3(values, "delegation-auth-file"),
56071
- workspaceSlug: stringValue3(values, "workspace"),
56072
- channelSlug: stringValue3(values, "channel")
56073
- });
56074
- const ownerUsername = stringValue3(values, "owner-username") ?? process.env.LINZUMI_MCP_OWNER_USERNAME;
56075
- const operatingMode = mcpOperatingMode(stringValue3(values, "mode"));
56076
- const cwd = stringValue3(values, "cwd") ?? process.cwd();
56077
- const defaultThreadId = stringValue3(values, "thread-id") ?? process.env.LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID;
57090
+ explicitToken: stringValue4(values, "token") ?? process.env.LINZUMI_MCP_ACCESS_TOKEN,
57091
+ authFilePath: stringValue4(values, "auth-file"),
57092
+ delegationAuthFilePath: stringValue4(values, "delegation-auth-file"),
57093
+ workspaceSlug: stringValue4(values, "workspace"),
57094
+ channelSlug: stringValue4(values, "channel")
57095
+ });
57096
+ const ownerUsername = stringValue4(values, "owner-username") ?? process.env.LINZUMI_MCP_OWNER_USERNAME;
57097
+ const operatingMode = mcpOperatingMode(stringValue4(values, "mode"));
57098
+ const cwd = stringValue4(values, "cwd") ?? process.cwd();
57099
+ const defaultThreadId = stringValue4(values, "thread-id") ?? process.env.LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID;
56078
57100
  const client = createLinzumiMcpApiClient({
56079
57101
  kandanUrl,
56080
57102
  accessToken: auth.accessToken,
@@ -56319,22 +57341,22 @@ function registerEmptyMcpResources(server) {
56319
57341
  async function runMcpConfig(args) {
56320
57342
  const values = strictFlagValues(args);
56321
57343
  const kandanUrl = required(values, "api-url");
56322
- const format = stringValue3(values, "format") ?? "codex";
56323
- const operatingMode = mcpOperatingMode(stringValue3(values, "mode"));
57344
+ const format = stringValue4(values, "format") ?? "codex";
57345
+ const operatingMode = mcpOperatingMode(stringValue4(values, "mode"));
56324
57346
  const token = values.get("include-token") === true ? (await resolveMcpAuth({
56325
57347
  kandanUrl,
56326
- explicitToken: stringValue3(values, "token") ?? process.env.LINZUMI_MCP_ACCESS_TOKEN,
56327
- authFilePath: stringValue3(values, "auth-file"),
56328
- delegationAuthFilePath: stringValue3(values, "delegation-auth-file"),
56329
- workspaceSlug: stringValue3(values, "workspace"),
56330
- channelSlug: stringValue3(values, "channel")
57348
+ explicitToken: stringValue4(values, "token") ?? process.env.LINZUMI_MCP_ACCESS_TOKEN,
57349
+ authFilePath: stringValue4(values, "auth-file"),
57350
+ delegationAuthFilePath: stringValue4(values, "delegation-auth-file"),
57351
+ workspaceSlug: stringValue4(values, "workspace"),
57352
+ channelSlug: stringValue4(values, "channel")
56331
57353
  })).accessToken : void 0;
56332
57354
  const config = linzumiMcpServerConfig({
56333
- command: stringValue3(values, "command"),
57355
+ command: stringValue4(values, "command"),
56334
57356
  kandanUrl,
56335
57357
  accessToken: token,
56336
- delegationAuthFilePath: stringValue3(values, "delegation-auth-file"),
56337
- ownerUsername: stringValue3(values, "owner-username") ?? process.env.LINZUMI_MCP_OWNER_USERNAME,
57358
+ delegationAuthFilePath: stringValue4(values, "delegation-auth-file"),
57359
+ ownerUsername: stringValue4(values, "owner-username") ?? process.env.LINZUMI_MCP_OWNER_USERNAME,
56338
57360
  operatingMode
56339
57361
  });
56340
57362
  switch (format) {
@@ -56353,19 +57375,19 @@ async function runMcpDoctor(args) {
56353
57375
  const kandanUrl = required(values, "api-url");
56354
57376
  const auth = await resolveMcpAuth({
56355
57377
  kandanUrl,
56356
- explicitToken: stringValue3(values, "token") ?? process.env.LINZUMI_MCP_ACCESS_TOKEN,
56357
- authFilePath: stringValue3(values, "auth-file"),
56358
- delegationAuthFilePath: stringValue3(values, "delegation-auth-file"),
56359
- workspaceSlug: stringValue3(values, "workspace"),
56360
- channelSlug: stringValue3(values, "channel")
57378
+ explicitToken: stringValue4(values, "token") ?? process.env.LINZUMI_MCP_ACCESS_TOKEN,
57379
+ authFilePath: stringValue4(values, "auth-file"),
57380
+ delegationAuthFilePath: stringValue4(values, "delegation-auth-file"),
57381
+ workspaceSlug: stringValue4(values, "workspace"),
57382
+ channelSlug: stringValue4(values, "channel")
56361
57383
  });
56362
57384
  switch (auth.mode) {
56363
57385
  case "local-runner": {
56364
57386
  const ok = await validateLocalRunnerToken({
56365
57387
  kandanUrl,
56366
57388
  accessToken: auth.accessToken,
56367
- workspaceSlug: stringValue3(values, "workspace"),
56368
- channelSlug: stringValue3(values, "channel")
57389
+ workspaceSlug: stringValue4(values, "workspace"),
57390
+ channelSlug: stringValue4(values, "channel")
56369
57391
  });
56370
57392
  if (!ok) {
56371
57393
  throw new Error("Linzumi MCP auth validation failed");
@@ -56377,7 +57399,7 @@ async function runMcpDoctor(args) {
56377
57399
  kandanUrl,
56378
57400
  accessToken: auth.accessToken,
56379
57401
  authMode: auth.mode,
56380
- operatingMode: mcpOperatingMode(stringValue3(values, "mode"))
57402
+ operatingMode: mcpOperatingMode(stringValue4(values, "mode"))
56381
57403
  });
56382
57404
  await client.validateAuth();
56383
57405
  break;
@@ -56448,7 +57470,7 @@ function strictFlagValues(args) {
56448
57470
  }
56449
57471
  return values;
56450
57472
  }
56451
- function stringValue3(values, key) {
57473
+ function stringValue4(values, key) {
56452
57474
  const value = values.get(key);
56453
57475
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
56454
57476
  }
@@ -56464,7 +57486,7 @@ function mcpOperatingMode(value) {
56464
57486
  }
56465
57487
  }
56466
57488
  function required(values, key) {
56467
- const value = stringValue3(values, key);
57489
+ const value = stringValue4(values, key);
56468
57490
  if (value === void 0) {
56469
57491
  throw new Error(`--${key} is required`);
56470
57492
  }
@@ -56683,11 +57705,11 @@ function runHelloCommand(args) {
56683
57705
  process.stdout.write(helloHelpText());
56684
57706
  return;
56685
57707
  }
56686
- const rootPath = stringValue5(values, "dir");
56687
- const parentDir = stringValue5(values, "parent-dir");
56688
- const name = stringValue5(values, "name");
57708
+ const rootPath = stringValue6(values, "dir");
57709
+ const parentDir = stringValue6(values, "parent-dir");
57710
+ const name = stringValue6(values, "name");
56689
57711
  const port = tcpPortValue(values, "port");
56690
- const host = stringValue5(values, "host");
57712
+ const host = stringValue6(values, "host");
56691
57713
  const project = createHelloLinzumiProject({
56692
57714
  ...rootPath === void 0 ? {} : { rootPath },
56693
57715
  ...parentDir === void 0 ? {} : { parentDir: resolveUserPath(parentDir) },
@@ -56827,8 +57849,8 @@ async function runCommanderDaemonCommand(args) {
56827
57849
  runnerId,
56828
57850
  cwd,
56829
57851
  args: stripDaemonSupervisorFlags(flagArgs),
56830
- logFile: stringValue5(values, "log-file"),
56831
- statusDir: stringValue5(values, "status-dir")
57852
+ logFile: stringValue6(values, "log-file"),
57853
+ statusDir: stringValue6(values, "status-dir")
56832
57854
  });
56833
57855
  process.stdout.write("commander_status: daemon_started\n");
56834
57856
  process.stdout.write(`runner_id: ${record.runnerId}
@@ -56849,7 +57871,7 @@ async function runCommanderDaemonCommand(args) {
56849
57871
  const runnerId = ensureLocalRunnerIdForLinzumiUrl(kandanUrl);
56850
57872
  const status = commanderDaemonStatus(
56851
57873
  runnerId,
56852
- stringValue5(values, "status-dir")
57874
+ stringValue6(values, "status-dir")
56853
57875
  );
56854
57876
  process.stdout.write(`${JSON.stringify(status)}
56855
57877
  `);
@@ -56863,7 +57885,7 @@ async function runCommanderDaemonCommand(args) {
56863
57885
  const result = await waitForCommanderDaemon({
56864
57886
  runnerId,
56865
57887
  timeoutMs,
56866
- statusDir: stringValue5(values, "status-dir")
57888
+ statusDir: stringValue6(values, "status-dir")
56867
57889
  });
56868
57890
  if (result.ok) {
56869
57891
  process.stdout.write("commander_status: connected\n");
@@ -56881,7 +57903,7 @@ async function runCommanderDaemonCommand(args) {
56881
57903
  const runnerId = ensureLocalRunnerIdForLinzumiUrl(kandanUrl);
56882
57904
  const status = stopCommanderDaemon(
56883
57905
  runnerId,
56884
- stringValue5(values, "status-dir")
57906
+ stringValue6(values, "status-dir")
56885
57907
  );
56886
57908
  process.stdout.write(`${JSON.stringify(status)}
56887
57909
  `);
@@ -56910,13 +57932,13 @@ async function runAuthCommand(args) {
56910
57932
  kandanUrl,
56911
57933
  workspaceSlug: target?.workspaceSlug,
56912
57934
  channelSlug: target?.channelSlug,
56913
- callbackHost: stringValue5(values, "oauth-callback-host")
57935
+ callbackHost: stringValue6(values, "oauth-callback-host")
56914
57936
  });
56915
57937
  const cached = writeCachedLocalRunnerToken({
56916
57938
  kandanUrl,
56917
57939
  accessToken: token.accessToken,
56918
57940
  expiresInSeconds: token.expiresInSeconds,
56919
- authFilePath: stringValue5(values, "auth-file")
57941
+ authFilePath: stringValue6(values, "auth-file")
56920
57942
  });
56921
57943
  process.stdout.write(
56922
57944
  `Saved Linzumi local runner auth for ${cached.kandanBaseUrl}
@@ -56943,11 +57965,11 @@ async function parseStartRunnerArgs(args, deps = {
56943
57965
  const requestedCwd = resolveUserPath(cwdArg ?? process.cwd());
56944
57966
  const cwd = assertConfiguredAllowedCwds([requestedCwd])[0] ?? requestedCwd;
56945
57967
  const explicitAllowedCwds = values.has("allowed-cwd") ? assertConfiguredAllowedCwds(
56946
- parseAllowedCwdList(stringValue5(values, "allowed-cwd"))
57968
+ parseAllowedCwdList(stringValue6(values, "allowed-cwd"))
56947
57969
  ) : [];
56948
57970
  const allowedCwds = Array.from(/* @__PURE__ */ new Set([cwd, ...explicitAllowedCwds]));
56949
- const requestedCodexBin = stringValue5(values, "codex-bin") ?? "codex";
56950
- const customCodeServerBin = stringValue5(values, "code-server-bin");
57971
+ const requestedCodexBin = stringValue6(values, "codex-bin") ?? "codex";
57972
+ const customCodeServerBin = stringValue6(values, "code-server-bin");
56951
57973
  const initialDependencyStatus = await deps.buildDependencyStatus({
56952
57974
  cwd,
56953
57975
  codexBin: requestedCodexBin,
@@ -56955,9 +57977,9 @@ async function parseStartRunnerArgs(args, deps = {
56955
57977
  });
56956
57978
  assertStartDependencies(initialDependencyStatus);
56957
57979
  const codexBin = initialDependencyStatus.codex.command;
56958
- const explicitToken = stringValue5(values, "token");
56959
- const authFilePath = stringValue5(values, "auth-file");
56960
- const callbackHost = stringValue5(values, "oauth-callback-host");
57980
+ const explicitToken = stringValue6(values, "token");
57981
+ const authFilePath = stringValue6(values, "auth-file");
57982
+ const callbackHost = stringValue6(values, "oauth-callback-host");
56961
57983
  const reportRejectedCachedToken = () => {
56962
57984
  process.stderr.write(
56963
57985
  "Cached Linzumi local runner auth was rejected; starting OAuth.\n"
@@ -57010,13 +58032,13 @@ async function parseStartRunnerArgs(args, deps = {
57010
58032
  workspaceSlug: target.workspaceSlug,
57011
58033
  cwd,
57012
58034
  codexBin,
57013
- codexUrl: stringValue5(values, "codex-url"),
58035
+ codexUrl: stringValue6(values, "codex-url"),
57014
58036
  launchTui: values.get("launch-tui") === true,
57015
58037
  fast: values.get("fast") === true,
57016
- logFile: stringValue5(values, "log-file"),
58038
+ logFile: stringValue6(values, "log-file"),
57017
58039
  allowedCwds,
57018
58040
  allowedForwardPorts: parseAllowedPortList(
57019
- stringValue5(values, "forward-port")
58041
+ stringValue6(values, "forward-port")
57020
58042
  ),
57021
58043
  codeServerBin: editorRuntime.codeServerBin,
57022
58044
  editorRuntime: editorRuntime.runtime,
@@ -57027,12 +58049,12 @@ async function parseStartRunnerArgs(args, deps = {
57027
58049
  channelSession: {
57028
58050
  workspaceSlug: target.workspaceSlug,
57029
58051
  channelSlug: target.channelSlug,
57030
- kandanThreadId: stringValue5(values, "linzumi-thread-id"),
57031
- listenUser: stringValue5(values, "listen-user") ?? defaultListenUserFromToken(targetToken),
57032
- model: stringValue5(values, "model"),
57033
- reasoningEffort: stringValue5(values, "reasoning-effort"),
57034
- sandbox: stringValue5(values, "sandbox"),
57035
- approvalPolicy: stringValue5(values, "approval-policy"),
58052
+ kandanThreadId: stringValue6(values, "linzumi-thread-id"),
58053
+ listenUser: stringValue6(values, "listen-user") ?? defaultListenUserFromToken(targetToken),
58054
+ model: stringValue6(values, "model"),
58055
+ reasoningEffort: stringValue6(values, "reasoning-effort"),
58056
+ sandbox: stringValue6(values, "sandbox"),
58057
+ approvalPolicy: stringValue6(values, "approval-policy"),
57036
58058
  allowPortForwardingByDefault: true,
57037
58059
  streamFlushMs: positiveIntegerValue2(values, "stream-flush-ms")
57038
58060
  }
@@ -57057,32 +58079,32 @@ async function parseAgentRunnerArgs(args, deps = {
57057
58079
  "linzumi commander accepts either <folder> or --cwd, not both"
57058
58080
  );
57059
58081
  }
57060
- const tokenFilePath = stringValue5(values, "agent-token-file") ?? defaultAgentTokenFilePath();
58082
+ const tokenFilePath = stringValue6(values, "agent-token-file") ?? defaultAgentTokenFilePath();
57061
58083
  const tokenFile = readStoredAgentTokenFile(tokenFilePath, deps.readTextFile);
57062
58084
  const channelSlug = tokenFile.channelId;
57063
58085
  rejectWorkspaceCommanderThreadFlags(values, channelSlug);
57064
58086
  const channelSession = channelSlug === void 0 ? void 0 : {
57065
58087
  workspaceSlug: tokenFile.workspaceId,
57066
58088
  channelSlug,
57067
- kandanThreadId: stringValue5(values, "linzumi-thread-id"),
57068
- listenUser: stringValue5(values, "listen-user") ?? requiredStoredOwnerUsername(tokenFile.ownerUsername),
57069
- model: stringValue5(values, "model"),
57070
- reasoningEffort: stringValue5(values, "reasoning-effort"),
57071
- sandbox: stringValue5(values, "sandbox"),
57072
- approvalPolicy: stringValue5(values, "approval-policy"),
58089
+ kandanThreadId: stringValue6(values, "linzumi-thread-id"),
58090
+ listenUser: stringValue6(values, "listen-user") ?? requiredStoredOwnerUsername(tokenFile.ownerUsername),
58091
+ model: stringValue6(values, "model"),
58092
+ reasoningEffort: stringValue6(values, "reasoning-effort"),
58093
+ sandbox: stringValue6(values, "sandbox"),
58094
+ approvalPolicy: stringValue6(values, "approval-policy"),
57073
58095
  allowPortForwardingByDefault: true,
57074
58096
  streamFlushMs: positiveIntegerValue2(values, "stream-flush-ms")
57075
58097
  };
57076
58098
  const kandanUrl = kandanUrlValue(values) ?? agentApiUrlToKandanUrl(tokenFile.apiUrl);
57077
- const requestedCwdValue = cwdArg ?? stringValue5(values, "cwd");
58099
+ const requestedCwdValue = cwdArg ?? stringValue6(values, "cwd");
57078
58100
  const requestedCwd = resolveUserPath(requestedCwdValue ?? process.cwd());
57079
58101
  const configuredAllowedCwds2 = requestedCwdValue === void 0 && !values.has("allowed-cwd") ? readConfiguredAllowedCwdDetailsForLinzumiUrl(kandanUrl) : { allowedCwds: [], missingAllowedCwds: [] };
57080
58102
  const allowedCwds = values.has("allowed-cwd") ? assertConfiguredAllowedCwds(
57081
- parseAllowedCwdList(stringValue5(values, "allowed-cwd"))
58103
+ parseAllowedCwdList(stringValue6(values, "allowed-cwd"))
57082
58104
  ) : requestedCwdValue === void 0 ? configuredAllowedCwds2.allowedCwds.length > 0 ? [...configuredAllowedCwds2.allowedCwds] : assertConfiguredAllowedCwds([requestedCwd]) : assertConfiguredAllowedCwds([requestedCwd]);
57083
58105
  const cwd = allowedCwds[0] ?? requestedCwd;
57084
- const requestedCodexBin = stringValue5(values, "codex-bin") ?? "codex";
57085
- const customCodeServerBin = stringValue5(values, "code-server-bin");
58106
+ const requestedCodexBin = stringValue6(values, "codex-bin") ?? "codex";
58107
+ const customCodeServerBin = stringValue6(values, "code-server-bin");
57086
58108
  const initialDependencyStatus = await deps.buildDependencyStatus({
57087
58109
  cwd,
57088
58110
  codexBin: requestedCodexBin,
@@ -57113,14 +58135,14 @@ async function parseAgentRunnerArgs(args, deps = {
57113
58135
  workspaceSlug: tokenFile.workspaceId,
57114
58136
  cwd,
57115
58137
  codexBin,
57116
- codexUrl: stringValue5(values, "codex-url"),
58138
+ codexUrl: stringValue6(values, "codex-url"),
57117
58139
  launchTui: values.get("launch-tui") === true,
57118
58140
  fast: values.get("fast") === true,
57119
- logFile: stringValue5(values, "log-file"),
58141
+ logFile: stringValue6(values, "log-file"),
57120
58142
  allowedCwds,
57121
58143
  missingAllowedCwds: configuredAllowedCwds2.missingAllowedCwds,
57122
58144
  allowedForwardPorts: parseAllowedPortList(
57123
- stringValue5(values, "forward-port")
58145
+ stringValue6(values, "forward-port")
57124
58146
  ),
57125
58147
  codeServerBin: editorRuntime.codeServerBin,
57126
58148
  editorRuntime: editorRuntime.runtime,
@@ -57233,16 +58255,16 @@ async function parseRunnerArgs(args, deps = {
57233
58255
  process.exit(0);
57234
58256
  }
57235
58257
  rejectConnectChannelFlags(values);
57236
- const workspaceSlug = stringValue5(values, "workspace");
58258
+ const workspaceSlug = stringValue6(values, "workspace");
57237
58259
  const kandanUrl = kandanUrlValue(values) ?? defaultLinzumiWebSocketUrl;
57238
- const cwd = stringValue5(values, "cwd") ?? process.cwd();
58260
+ const cwd = stringValue6(values, "cwd") ?? process.cwd();
57239
58261
  const cwdAllowedCwds = assertConfiguredAllowedCwds([cwd]);
57240
58262
  const localConfiguredAllowedCwds = values.has("allowed-cwd") ? { allowedCwds: [], missingAllowedCwds: [] } : readConfiguredAllowedCwdDetailsForLinzumiUrl(kandanUrl);
57241
58263
  const configuredAllowedCwds2 = values.has("allowed-cwd") ? assertConfiguredAllowedCwds(
57242
- parseAllowedCwdList(stringValue5(values, "allowed-cwd"))
58264
+ parseAllowedCwdList(stringValue6(values, "allowed-cwd"))
57243
58265
  ) : [...localConfiguredAllowedCwds.allowedCwds];
57244
- const requestedCodexBin = stringValue5(values, "codex-bin") ?? "codex";
57245
- const customCodeServerBin = stringValue5(values, "code-server-bin");
58266
+ const requestedCodexBin = stringValue6(values, "codex-bin") ?? "codex";
58267
+ const customCodeServerBin = stringValue6(values, "code-server-bin");
57246
58268
  const initialDependencyStatus = await deps.buildDependencyStatus({
57247
58269
  cwd,
57248
58270
  codexBin: requestedCodexBin,
@@ -57250,13 +58272,13 @@ async function parseRunnerArgs(args, deps = {
57250
58272
  });
57251
58273
  assertStartDependencies(initialDependencyStatus);
57252
58274
  const codexBin = initialDependencyStatus.codex.command;
57253
- const explicitToken = stringValue5(values, "token");
58275
+ const explicitToken = stringValue6(values, "token");
57254
58276
  const token = await deps.resolveToken({
57255
58277
  kandanUrl,
57256
58278
  explicitToken,
57257
58279
  workspaceSlug,
57258
- authFilePath: stringValue5(values, "auth-file"),
57259
- callbackHost: stringValue5(values, "oauth-callback-host"),
58280
+ authFilePath: stringValue6(values, "auth-file"),
58281
+ callbackHost: stringValue6(values, "oauth-callback-host"),
57260
58282
  reportRejectedCachedToken: () => {
57261
58283
  process.stderr.write(
57262
58284
  "Cached Linzumi local runner auth was rejected; starting OAuth.\n"
@@ -57285,16 +58307,16 @@ async function parseRunnerArgs(args, deps = {
57285
58307
  ),
57286
58308
  cwd,
57287
58309
  codexBin,
57288
- codexUrl: stringValue5(values, "codex-url"),
58310
+ codexUrl: stringValue6(values, "codex-url"),
57289
58311
  launchTui: values.get("launch-tui") === true,
57290
58312
  fast: values.get("fast") === true,
57291
- logFile: stringValue5(values, "log-file"),
58313
+ logFile: stringValue6(values, "log-file"),
57292
58314
  allowedCwds: Array.from(
57293
58315
  /* @__PURE__ */ new Set([...cwdAllowedCwds, ...configuredAllowedCwds2])
57294
58316
  ),
57295
58317
  missingAllowedCwds: localConfiguredAllowedCwds.missingAllowedCwds,
57296
58318
  allowedForwardPorts: parseAllowedPortList(
57297
- stringValue5(values, "forward-port")
58319
+ stringValue6(values, "forward-port")
57298
58320
  ),
57299
58321
  codeServerBin: editorRuntime.codeServerBin,
57300
58322
  editorRuntime: editorRuntime.runtime,
@@ -57308,16 +58330,16 @@ async function parseRunnerArgs(args, deps = {
57308
58330
  }
57309
58331
  function runnerRuntimeDefaultsFromValues(values) {
57310
58332
  return {
57311
- model: stringValue5(values, "model"),
57312
- reasoningEffort: stringValue5(values, "reasoning-effort"),
57313
- approvalPolicy: stringValue5(values, "approval-policy"),
57314
- sandbox: stringValue5(values, "sandbox"),
58333
+ model: stringValue6(values, "model"),
58334
+ reasoningEffort: stringValue6(values, "reasoning-effort"),
58335
+ approvalPolicy: stringValue6(values, "approval-policy"),
58336
+ sandbox: stringValue6(values, "sandbox"),
57315
58337
  allowPortForwardingByDefault: true
57316
58338
  };
57317
58339
  }
57318
58340
  function kandanUrlValue(values) {
57319
- const apiUrl = stringValue5(values, "api-url");
57320
- const linzumiUrl = stringValue5(values, "linzumi-url");
58341
+ const apiUrl = stringValue6(values, "api-url");
58342
+ const linzumiUrl = stringValue6(values, "linzumi-url");
57321
58343
  if (apiUrl !== void 0 && linzumiUrl !== void 0 && apiUrl !== linzumiUrl) {
57322
58344
  throw new Error("use only one of --api-url or --linzumi-url");
57323
58345
  }
@@ -57456,8 +58478,8 @@ function rejectConnectChannelFlags(values) {
57456
58478
  );
57457
58479
  }
57458
58480
  function parseOptionalChannelTarget(values) {
57459
- const channel = stringValue5(values, "channel");
57460
- const workspace = stringValue5(values, "workspace");
58481
+ const channel = stringValue6(values, "channel");
58482
+ const workspace = stringValue6(values, "workspace");
57461
58483
  if (channel === void 0) {
57462
58484
  if (workspace === void 0) {
57463
58485
  return void 0;
@@ -57491,9 +58513,9 @@ function withLocalMachineId(options) {
57491
58513
  function parseThreadCodexWorkerArgs(args) {
57492
58514
  const values = strictFlagValues2(args);
57493
58515
  const kandanUrl = kandanUrlValue(values) ?? defaultLinzumiWebSocketUrl;
57494
- const cwd = stringValue5(values, "cwd") ?? process.cwd();
58516
+ const cwd = stringValue6(values, "cwd") ?? process.cwd();
57495
58517
  const configuredAllowedCwds2 = values.has("allowed-cwd") ? assertConfiguredAllowedCwds(
57496
- parseAllowedCwdList(stringValue5(values, "allowed-cwd"))
58518
+ parseAllowedCwdList(stringValue6(values, "allowed-cwd"))
57497
58519
  ) : assertConfiguredAllowedCwds([cwd]);
57498
58520
  const kandanThreadId = requiredThreadRunnerKandanThreadId();
57499
58521
  const token = requiredThreadRunnerToken();
@@ -57503,17 +58525,17 @@ function parseThreadCodexWorkerArgs(args) {
57503
58525
  runnerId: `thread-codex-worker:${kandanThreadId}`,
57504
58526
  machineId: void 0,
57505
58527
  runnerLockConfigPath: void 0,
57506
- workspaceSlug: stringValue5(values, "workspace"),
58528
+ workspaceSlug: stringValue6(values, "workspace"),
57507
58529
  cwd,
57508
- codexBin: stringValue5(values, "codex-bin") ?? "codex",
58530
+ codexBin: stringValue6(values, "codex-bin") ?? "codex",
57509
58531
  codexUrl: void 0,
57510
58532
  launchTui: false,
57511
58533
  fast: values.get("fast") === true ? true : void 0,
57512
- logFile: stringValue5(values, "log-file"),
58534
+ logFile: stringValue6(values, "log-file"),
57513
58535
  allowedCwds: configuredAllowedCwds2.allowedCwds,
57514
58536
  missingAllowedCwds: configuredAllowedCwds2.missingAllowedCwds,
57515
58537
  allowedForwardPorts: parseAllowedPortList(
57516
- stringValue5(values, "forward-port")
58538
+ stringValue6(values, "forward-port")
57517
58539
  ),
57518
58540
  codeServerBin: void 0,
57519
58541
  editorRuntime: void 0,
@@ -57543,13 +58565,13 @@ function requiredThreadRunnerToken() {
57543
58565
  return token;
57544
58566
  }
57545
58567
  function required2(values, key) {
57546
- const value = stringValue5(values, key);
58568
+ const value = stringValue6(values, key);
57547
58569
  if (value === void 0) {
57548
58570
  throw new Error(`missing --${key}`);
57549
58571
  }
57550
58572
  return value;
57551
58573
  }
57552
- function stringValue5(values, key) {
58574
+ function stringValue6(values, key) {
57553
58575
  const value = values.get(key);
57554
58576
  if (typeof value === "string" && value.trim() !== "") {
57555
58577
  return value;
@@ -57557,7 +58579,7 @@ function stringValue5(values, key) {
57557
58579
  return void 0;
57558
58580
  }
57559
58581
  function positiveIntegerValue2(values, key) {
57560
- const value = stringValue5(values, key);
58582
+ const value = stringValue6(values, key);
57561
58583
  if (value === void 0) {
57562
58584
  return void 0;
57563
58585
  }
@@ -57568,7 +58590,7 @@ function positiveIntegerValue2(values, key) {
57568
58590
  throw new Error(`--${key} must be a positive integer`);
57569
58591
  }
57570
58592
  function tcpPortValue(values, key) {
57571
- const value = stringValue5(values, key);
58593
+ const value = stringValue6(values, key);
57572
58594
  if (value === void 0) {
57573
58595
  return void 0;
57574
58596
  }