@rdmind/rdmind 0.1.4-alpha.1 → 0.1.4-alpha.10

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.
Files changed (2) hide show
  1. package/cli.js +239 -69
  2. package/package.json +2 -2
package/cli.js CHANGED
@@ -37605,7 +37605,12 @@ var require_sign_stream = __commonJS({
37605
37605
  }
37606
37606
  __name(jwsSign, "jwsSign");
37607
37607
  function SignStream(opts) {
37608
- var secret = opts.secret || opts.privateKey || opts.key;
37608
+ var secret = opts.secret;
37609
+ secret = secret == null ? opts.privateKey : secret;
37610
+ secret = secret == null ? opts.key : secret;
37611
+ if (/^hs/i.test(opts.header.alg) === true && secret == null) {
37612
+ throw new TypeError("secret must be a string or buffer or a KeyObject");
37613
+ }
37609
37614
  var secretStream = new DataStream(secret);
37610
37615
  this.readable = true;
37611
37616
  this.header = opts.header;
@@ -37728,7 +37733,12 @@ var require_verify_stream = __commonJS({
37728
37733
  __name(jwsDecode, "jwsDecode");
37729
37734
  function VerifyStream(opts) {
37730
37735
  opts = opts || {};
37731
- var secretOrKey = opts.secret || opts.publicKey || opts.key;
37736
+ var secretOrKey = opts.secret;
37737
+ secretOrKey = secretOrKey == null ? opts.publicKey : secretOrKey;
37738
+ secretOrKey = secretOrKey == null ? opts.key : secretOrKey;
37739
+ if (/^hs/i.test(opts.algorithm) === true && secretOrKey == null) {
37740
+ throw new TypeError("secret must be a string or buffer or a KeyObject");
37741
+ }
37732
37742
  var secretStream = new DataStream(secretOrKey);
37733
37743
  this.readable = true;
37734
37744
  this.algorithm = opts.algorithm;
@@ -89290,6 +89300,8 @@ var init_subagent_statistics = __esm({
89290
89300
  failedToolCalls = 0;
89291
89301
  inputTokens = 0;
89292
89302
  outputTokens = 0;
89303
+ thoughtTokens = 0;
89304
+ cachedTokens = 0;
89293
89305
  toolUsage = /* @__PURE__ */ new Map();
89294
89306
  start(now = Date.now()) {
89295
89307
  this.startTimeMs = now;
@@ -89318,15 +89330,17 @@ var init_subagent_statistics = __esm({
89318
89330
  tu.averageDurationMs = tu.count > 0 ? tu.totalDurationMs / tu.count : 0;
89319
89331
  this.toolUsage.set(name3, tu);
89320
89332
  }
89321
- recordTokens(input, output) {
89333
+ recordTokens(input, output, thought = 0, cached2 = 0) {
89322
89334
  this.inputTokens += Math.max(0, input || 0);
89323
89335
  this.outputTokens += Math.max(0, output || 0);
89336
+ this.thoughtTokens += Math.max(0, thought || 0);
89337
+ this.cachedTokens += Math.max(0, cached2 || 0);
89324
89338
  }
89325
89339
  getSummary(now = Date.now()) {
89326
89340
  const totalDurationMs = this.startTimeMs ? now - this.startTimeMs : 0;
89327
89341
  const totalToolCalls = this.totalToolCalls;
89328
89342
  const successRate = totalToolCalls > 0 ? this.successfulToolCalls / totalToolCalls * 100 : 0;
89329
- const totalTokens = this.inputTokens + this.outputTokens;
89343
+ const totalTokens = this.inputTokens + this.outputTokens + this.thoughtTokens + this.cachedTokens;
89330
89344
  const estimatedCost = this.inputTokens * 3e-5 + this.outputTokens * 6e-5;
89331
89345
  return {
89332
89346
  rounds: this.rounds,
@@ -89337,6 +89351,8 @@ var init_subagent_statistics = __esm({
89337
89351
  successRate,
89338
89352
  inputTokens: this.inputTokens,
89339
89353
  outputTokens: this.outputTokens,
89354
+ thoughtTokens: this.thoughtTokens,
89355
+ cachedTokens: this.cachedTokens,
89340
89356
  totalTokens,
89341
89357
  estimatedCost,
89342
89358
  toolUsage: Array.from(this.toolUsage.values())
@@ -89351,8 +89367,12 @@ var init_subagent_statistics = __esm({
89351
89367
  `\u23F1\uFE0F Duration: ${this.fmtDuration(stats.totalDurationMs)} | \u{1F501} Rounds: ${stats.rounds}`
89352
89368
  ];
89353
89369
  if (typeof stats.totalTokens === "number") {
89370
+ const parts = [
89371
+ `in ${stats.inputTokens ?? 0}`,
89372
+ `out ${stats.outputTokens ?? 0}`
89373
+ ];
89354
89374
  lines.push(
89355
- `\u{1F522} Tokens: ${stats.totalTokens.toLocaleString()}${stats.inputTokens || stats.outputTokens ? ` (in ${stats.inputTokens ?? 0}, out ${stats.outputTokens ?? 0})` : ""}`
89375
+ `\u{1F522} Tokens: ${stats.totalTokens.toLocaleString()}${parts.length ? ` (${parts.join(", ")})` : ""}`
89356
89376
  );
89357
89377
  }
89358
89378
  return lines.join("\n");
@@ -89380,8 +89400,12 @@ var init_subagent_statistics = __esm({
89380
89400
  `\u{1F527} Tools: ${stats.totalToolCalls} calls, ${sr.toFixed(1)}% success (${stats.successfulToolCalls} ok, ${stats.failedToolCalls} failed)`
89381
89401
  );
89382
89402
  if (typeof stats.totalTokens === "number") {
89403
+ const parts = [
89404
+ `in ${stats.inputTokens ?? 0}`,
89405
+ `out ${stats.outputTokens ?? 0}`
89406
+ ];
89383
89407
  lines.push(
89384
- `\u{1F522} Tokens: ${stats.totalTokens.toLocaleString()} (in ${stats.inputTokens ?? 0}, out ${stats.outputTokens ?? 0})`
89408
+ `\u{1F522} Tokens: ${stats.totalTokens.toLocaleString()} (${parts.join(", ")})`
89385
89409
  );
89386
89410
  }
89387
89411
  if (stats.toolUsage && stats.toolUsage.length) {
@@ -147556,6 +147580,7 @@ var init_uiTelemetry = __esm({
147556
147580
  init_esbuild_shims();
147557
147581
  init_constants();
147558
147582
  init_tool_call_decision();
147583
+ init_constants();
147559
147584
  createInitialModelMetrics = /* @__PURE__ */ __name(() => ({
147560
147585
  api: {
147561
147586
  totalRequests: 0,
@@ -160654,7 +160679,7 @@ var init_geminiContentGenerator = __esm({
160654
160679
  config: {
160655
160680
  ...request4.config,
160656
160681
  thinkingConfig: {
160657
- includeThoughts: true,
160682
+ includeThoughts: false,
160658
160683
  thinkingLevel
160659
160684
  }
160660
160685
  }
@@ -160801,7 +160826,7 @@ function createContentGeneratorConfig(config2, authType, generationConfig) {
160801
160826
  };
160802
160827
  }
160803
160828
  async function createContentGenerator(config2, gcConfig, isInitialAuth) {
160804
- const version3 = "0.1.4-alpha.1";
160829
+ const version3 = "0.1.4-alpha.10";
160805
160830
  const userAgent2 = `QwenCode/${version3} (${process.platform}; ${process.arch})`;
160806
160831
  const baseHeaders = {
160807
160832
  "User-Agent": userAgent2
@@ -172624,6 +172649,12 @@ function getCachedEncodingForBuffer(buffer) {
172624
172649
  cachedSystemEncoding = getSystemEncoding();
172625
172650
  }
172626
172651
  if (cachedSystemEncoding) {
172652
+ if (cachedSystemEncoding !== "utf-8") {
172653
+ const detected = detectEncodingFromBuffer(buffer);
172654
+ if (detected === "utf-8") {
172655
+ return "utf-8";
172656
+ }
172657
+ }
172627
172658
  return cachedSystemEncoding;
172628
172659
  }
172629
172660
  return detectEncodingFromBuffer(buffer) || "utf-8";
@@ -179312,6 +179343,7 @@ var init_subagent_events = __esm({
179312
179343
  SubAgentEventType2["TOOL_CALL"] = "tool_call";
179313
179344
  SubAgentEventType2["TOOL_RESULT"] = "tool_result";
179314
179345
  SubAgentEventType2["TOOL_WAITING_APPROVAL"] = "tool_waiting_approval";
179346
+ SubAgentEventType2["USAGE_METADATA"] = "usage_metadata";
179315
179347
  SubAgentEventType2["FINISH"] = "finish";
179316
179348
  SubAgentEventType2["ERROR"] = "error";
179317
179349
  return SubAgentEventType2;
@@ -179563,6 +179595,7 @@ var init_subagent = __esm({
179563
179595
  tools: [{ functionDeclarations: toolsList }]
179564
179596
  }
179565
179597
  };
179598
+ const roundStreamStart = Date.now();
179566
179599
  const responseStream = await chat.sendMessageStream(
179567
179600
  this.modelConfig.model || this.runtimeContext.getModel() || DEFAULT_QWEN_MODEL,
179568
179601
  messageParams,
@@ -179625,16 +179658,27 @@ var init_subagent = __esm({
179625
179658
  if (lastUsage) {
179626
179659
  const inTok = Number(lastUsage.promptTokenCount || 0);
179627
179660
  const outTok = Number(lastUsage.candidatesTokenCount || 0);
179628
- if (isFinite(inTok) || isFinite(outTok)) {
179661
+ const thoughtTok = Number(lastUsage.thoughtsTokenCount || 0);
179662
+ const cachedTok = Number(lastUsage.cachedContentTokenCount || 0);
179663
+ if (isFinite(inTok) || isFinite(outTok) || isFinite(thoughtTok) || isFinite(cachedTok)) {
179629
179664
  this.stats.recordTokens(
179630
179665
  isFinite(inTok) ? inTok : 0,
179631
- isFinite(outTok) ? outTok : 0
179666
+ isFinite(outTok) ? outTok : 0,
179667
+ isFinite(thoughtTok) ? thoughtTok : 0,
179668
+ isFinite(cachedTok) ? cachedTok : 0
179632
179669
  );
179633
179670
  this.executionStats.inputTokens = (this.executionStats.inputTokens || 0) + (isFinite(inTok) ? inTok : 0);
179634
179671
  this.executionStats.outputTokens = (this.executionStats.outputTokens || 0) + (isFinite(outTok) ? outTok : 0);
179635
- this.executionStats.totalTokens = (this.executionStats.inputTokens || 0) + (this.executionStats.outputTokens || 0);
179672
+ this.executionStats.totalTokens = (this.executionStats.inputTokens || 0) + (this.executionStats.outputTokens || 0) + (isFinite(thoughtTok) ? thoughtTok : 0) + (isFinite(cachedTok) ? cachedTok : 0);
179636
179673
  this.executionStats.estimatedCost = (this.executionStats.inputTokens || 0) * 3e-5 + (this.executionStats.outputTokens || 0) * 6e-5;
179637
179674
  }
179675
+ this.eventEmitter?.emit("usage_metadata" /* USAGE_METADATA */, {
179676
+ subagentId: this.subagentId,
179677
+ round: turnCounter,
179678
+ usage: lastUsage,
179679
+ durationMs: Date.now() - roundStreamStart,
179680
+ timestamp: Date.now()
179681
+ });
179638
179682
  }
179639
179683
  if (functionCalls.length > 0) {
179640
179684
  currentMessages = await this.processFunctionCalls(
@@ -209076,7 +209120,7 @@ var init_ide_client = __esm({
209076
209120
  if (this.connectionConfig?.authToken) {
209077
209121
  this.authToken = this.connectionConfig.authToken;
209078
209122
  }
209079
- const workspacePath = this.connectionConfig?.workspacePath ?? process.env["QWEN_CODE_IDE_WORKSPACE_PATH"];
209123
+ const workspacePath = this.connectionConfig?.workspacePath ?? process.env["RDMIND_CODE_IDE_WORKSPACE_PATH"];
209080
209124
  const { isValid: isValid2, error: error2 } = _IdeClient.validateWorkspacePath(
209081
209125
  workspacePath,
209082
209126
  process.cwd()
@@ -209386,18 +209430,18 @@ var init_ide_client = __esm({
209386
209430
  return { isValid: true };
209387
209431
  }
209388
209432
  getPortFromEnv() {
209389
- const port = process.env["QWEN_CODE_IDE_SERVER_PORT"];
209433
+ const port = process.env["RDMIND_CODE_IDE_SERVER_PORT"];
209390
209434
  if (!port) {
209391
209435
  return void 0;
209392
209436
  }
209393
209437
  return port;
209394
209438
  }
209395
209439
  getStdioConfigFromEnv() {
209396
- const command2 = process.env["QWEN_CODE_IDE_SERVER_STDIO_COMMAND"];
209440
+ const command2 = process.env["RDMIND_CODE_IDE_SERVER_STDIO_COMMAND"];
209397
209441
  if (!command2) {
209398
209442
  return void 0;
209399
209443
  }
209400
- const argsStr = process.env["QWEN_CODE_IDE_SERVER_STDIO_ARGS"];
209444
+ const argsStr = process.env["RDMIND_CODE_IDE_SERVER_STDIO_ARGS"];
209401
209445
  let args = [];
209402
209446
  if (argsStr) {
209403
209447
  try {
@@ -209406,11 +209450,11 @@ var init_ide_client = __esm({
209406
209450
  args = parsedArgs;
209407
209451
  } else {
209408
209452
  logger.error(
209409
- "QWEN_CODE_IDE_SERVER_STDIO_ARGS must be a JSON array string."
209453
+ "RDMIND_CODE_IDE_SERVER_STDIO_ARGS must be a JSON array string."
209410
209454
  );
209411
209455
  }
209412
209456
  } catch (e3) {
209413
- logger.error("Failed to parse QWEN_CODE_IDE_SERVER_STDIO_ARGS:", e3);
209457
+ logger.error("Failed to parse RDMIND_CODE_IDE_SERVER_STDIO_ARGS:", e3);
209414
209458
  }
209415
209459
  }
209416
209460
  return { command: command2, args };
@@ -209422,7 +209466,7 @@ var init_ide_client = __esm({
209422
209466
  try {
209423
209467
  const portFile = path38.join(
209424
209468
  os20.tmpdir(),
209425
- `qwen-code-ide-server-${this.ideProcessInfo.pid}.json`
209469
+ `rdmind-code-ide-server-${this.ideProcessInfo.pid}.json`
209426
209470
  );
209427
209471
  const portFileContents = await fs35.promises.readFile(portFile, "utf8");
209428
209472
  return JSON.parse(portFileContents);
@@ -209440,7 +209484,7 @@ var init_ide_client = __esm({
209440
209484
  return void 0;
209441
209485
  }
209442
209486
  const fileRegex = new RegExp(
209443
- `^qwen-code-ide-server-${this.ideProcessInfo.pid}-\\d+\\.json$`
209487
+ `^rdmind-code-ide-server-${this.ideProcessInfo.pid}-\\d+\\.json$`
209444
209488
  );
209445
209489
  const matchingFiles = portFiles.filter((file) => fileRegex.test(file)).sort();
209446
209490
  if (matchingFiles.length === 0) {
@@ -235947,8 +235991,8 @@ var init_git_commit = __esm({
235947
235991
  "packages/core/src/generated/git-commit.ts"() {
235948
235992
  "use strict";
235949
235993
  init_esbuild_shims();
235950
- GIT_COMMIT_INFO = "4f0a7859";
235951
- CLI_VERSION = "0.1.4-alpha.1";
235994
+ GIT_COMMIT_INFO = "a5a74672";
235995
+ CLI_VERSION = "0.1.4-alpha.10";
235952
235996
  }
235953
235997
  });
235954
235998
 
@@ -236884,6 +236928,9 @@ __export(core_exports4, {
236884
236928
  DeclarativeTool: () => DeclarativeTool,
236885
236929
  DiscoveredMCPTool: () => DiscoveredMCPTool,
236886
236930
  DiscoveredTool: () => DiscoveredTool,
236931
+ EVENT_API_ERROR: () => EVENT_API_ERROR,
236932
+ EVENT_API_RESPONSE: () => EVENT_API_RESPONSE,
236933
+ EVENT_TOOL_CALL: () => EVENT_TOOL_CALL,
236887
236934
  EditTool: () => EditTool,
236888
236935
  EndSessionEvent: () => EndSessionEvent,
236889
236936
  ExitPlanModeTool: () => ExitPlanModeTool,
@@ -286473,12 +286520,12 @@ var init_header = __esm({
286473
286520
  if (!buf || !(buf.length >= off + 512)) {
286474
286521
  throw new Error("need 512 bytes for header");
286475
286522
  }
286476
- this.path = decString(buf, off, 100);
286477
- this.mode = decNumber(buf, off + 100, 8);
286478
- this.uid = decNumber(buf, off + 108, 8);
286479
- this.gid = decNumber(buf, off + 116, 8);
286480
- this.size = decNumber(buf, off + 124, 12);
286481
- this.mtime = decDate(buf, off + 136, 12);
286523
+ this.path = ex?.path ?? decString(buf, off, 100);
286524
+ this.mode = ex?.mode ?? gex?.mode ?? decNumber(buf, off + 100, 8);
286525
+ this.uid = ex?.uid ?? gex?.uid ?? decNumber(buf, off + 108, 8);
286526
+ this.gid = ex?.gid ?? gex?.gid ?? decNumber(buf, off + 116, 8);
286527
+ this.size = ex?.size ?? gex?.size ?? decNumber(buf, off + 124, 12);
286528
+ this.mtime = ex?.mtime ?? gex?.mtime ?? decDate(buf, off + 136, 12);
286482
286529
  this.cksum = decNumber(buf, off + 148, 12);
286483
286530
  if (gex)
286484
286531
  this.#slurp(gex, true);
@@ -286496,10 +286543,10 @@ var init_header = __esm({
286496
286543
  }
286497
286544
  this.linkpath = decString(buf, off + 157, 100);
286498
286545
  if (buf.subarray(off + 257, off + 265).toString() === "ustar\x0000") {
286499
- this.uname = decString(buf, off + 265, 32);
286500
- this.gname = decString(buf, off + 297, 32);
286501
- this.devmaj = decNumber(buf, off + 329, 8) ?? 0;
286502
- this.devmin = decNumber(buf, off + 337, 8) ?? 0;
286546
+ this.uname = ex?.uname ?? gex?.uname ?? decString(buf, off + 265, 32);
286547
+ this.gname = ex?.gname ?? gex?.gname ?? decString(buf, off + 297, 32);
286548
+ this.devmaj = ex?.devmaj ?? gex?.devmaj ?? decNumber(buf, off + 329, 8) ?? 0;
286549
+ this.devmin = ex?.devmin ?? gex?.devmin ?? decNumber(buf, off + 337, 8) ?? 0;
286503
286550
  if (buf[off + 475] !== 0) {
286504
286551
  const prefix = decString(buf, off + 345, 155);
286505
286552
  this.path = prefix + "/" + this.path;
@@ -286508,8 +286555,8 @@ var init_header = __esm({
286508
286555
  if (prefix) {
286509
286556
  this.path = prefix + "/" + this.path;
286510
286557
  }
286511
- this.atime = decDate(buf, off + 476, 12);
286512
- this.ctime = decDate(buf, off + 488, 12);
286558
+ this.atime = ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12);
286559
+ this.ctime = ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12);
286513
286560
  }
286514
286561
  }
286515
286562
  let sum = 8 * 32;
@@ -287504,13 +287551,15 @@ var init_list = __esm({
287504
287551
  const readSize = opt.maxReadSize || 16 * 1024 * 1024;
287505
287552
  if (stat7.size < readSize) {
287506
287553
  const buf = Buffer.allocUnsafe(stat7.size);
287507
- fs63.readSync(fd, buf, 0, stat7.size, 0);
287508
- p.end(buf);
287554
+ const read3 = fs63.readSync(fd, buf, 0, stat7.size, 0);
287555
+ p.end(read3 === buf.byteLength ? buf : buf.subarray(0, read3));
287509
287556
  } else {
287510
287557
  let pos2 = 0;
287511
287558
  const buf = Buffer.allocUnsafe(readSize);
287512
287559
  while (pos2 < stat7.size) {
287513
287560
  const bytesRead = fs63.readSync(fd, buf, 0, readSize, pos2);
287561
+ if (bytesRead === 0)
287562
+ break;
287514
287563
  pos2 += bytesRead;
287515
287564
  p.write(buf.subarray(0, bytesRead));
287516
287565
  }
@@ -334023,7 +334072,7 @@ var patchConsole = /* @__PURE__ */ __name((callback) => {
334023
334072
  var dist_default2 = patchConsole;
334024
334073
 
334025
334074
  // node_modules/ink/build/ink.js
334026
- var import_constants20 = __toESM(require_constants11(), 1);
334075
+ var import_constants21 = __toESM(require_constants11(), 1);
334027
334076
 
334028
334077
  // node_modules/yoga-layout/dist/src/index.js
334029
334078
  init_esbuild_shims();
@@ -336086,7 +336135,7 @@ __name(wrapAnsi, "wrapAnsi");
336086
336135
  // node_modules/ink/build/reconciler.js
336087
336136
  init_esbuild_shims();
336088
336137
  var import_react_reconciler = __toESM(require_react_reconciler(), 1);
336089
- var import_constants19 = __toESM(require_constants11(), 1);
336138
+ var import_constants20 = __toESM(require_constants11(), 1);
336090
336139
  import process15 from "node:process";
336091
336140
  var import_react = __toESM(require_react(), 1);
336092
336141
 
@@ -337057,7 +337106,7 @@ var cleanupYogaNode = /* @__PURE__ */ __name((node) => {
337057
337106
  node?.unsetMeasureFunc();
337058
337107
  node?.freeRecursive();
337059
337108
  }, "cleanupYogaNode");
337060
- var currentUpdatePriority = import_constants19.NoEventPriority;
337109
+ var currentUpdatePriority = import_constants20.NoEventPriority;
337061
337110
  var currentRootNode;
337062
337111
  var reconciler_default = (0, import_react_reconciler.default)({
337063
337112
  getRootHostContext: /* @__PURE__ */ __name(() => ({
@@ -337214,10 +337263,10 @@ var reconciler_default = (0, import_react_reconciler.default)({
337214
337263
  },
337215
337264
  getCurrentUpdatePriority: /* @__PURE__ */ __name(() => currentUpdatePriority, "getCurrentUpdatePriority"),
337216
337265
  resolveUpdatePriority() {
337217
- if (currentUpdatePriority !== import_constants19.NoEventPriority) {
337266
+ if (currentUpdatePriority !== import_constants20.NoEventPriority) {
337218
337267
  return currentUpdatePriority;
337219
337268
  }
337220
- return import_constants19.DefaultEventPriority;
337269
+ return import_constants20.DefaultEventPriority;
337221
337270
  },
337222
337271
  maySuspendCommit() {
337223
337272
  return false;
@@ -339735,7 +339784,7 @@ var Ink = class {
339735
339784
  this.fullStaticOutput = "";
339736
339785
  this.container = reconciler_default.createContainer(
339737
339786
  this.rootNode,
339738
- import_constants20.LegacyRoot,
339787
+ import_constants21.LegacyRoot,
339739
339788
  null,
339740
339789
  false,
339741
339790
  null,
@@ -346302,7 +346351,7 @@ __name(getPackageJson, "getPackageJson");
346302
346351
  // packages/cli/src/utils/version.ts
346303
346352
  async function getCliVersion() {
346304
346353
  const pkgJson = await getPackageJson();
346305
- return "0.1.4-alpha.1";
346354
+ return "0.1.4-alpha.10";
346306
346355
  }
346307
346356
  __name(getCliVersion, "getCliVersion");
346308
346357
 
@@ -352832,7 +352881,7 @@ var formatDuration = /* @__PURE__ */ __name((milliseconds) => {
352832
352881
 
352833
352882
  // packages/cli/src/generated/git-commit.ts
352834
352883
  init_esbuild_shims();
352835
- var GIT_COMMIT_INFO2 = "4f0a7859";
352884
+ var GIT_COMMIT_INFO2 = "a5a74672";
352836
352885
 
352837
352886
  // packages/cli/src/utils/systemInfo.ts
352838
352887
  async function getNpmVersion() {
@@ -388416,7 +388465,7 @@ function IdeIntegrationNudge({
388416
388465
  { isActive: true }
388417
388466
  );
388418
388467
  const { displayName: ideName } = ide;
388419
- const isExtensionPreInstalled = !!process.env["QWEN_CODE_IDE_SERVER_PORT"] && !!process.env["QWEN_CODE_IDE_WORKSPACE_PATH"];
388468
+ const isExtensionPreInstalled = !!process.env["RDMIND_CODE_IDE_SERVER_PORT"] && !!process.env["RDMIND_CODE_IDE_WORKSPACE_PATH"];
388420
388469
  const OPTIONS = [
388421
388470
  {
388422
388471
  label: "Yes",
@@ -394072,12 +394121,17 @@ var InputPrompt = /* @__PURE__ */ __name(({
394072
394121
  statusColor = theme.status.warning;
394073
394122
  statusText = t3("Accepting edits");
394074
394123
  }
394124
+ const borderColor = isShellFocused && !isEmbeddedShellFocused ? statusColor ?? theme.border.focused : theme.border.default;
394075
394125
  return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_jsx_runtime95.Fragment, { children: [
394076
394126
  /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
394077
394127
  Box_default,
394078
394128
  {
394079
- borderStyle: "round",
394080
- borderColor: isShellFocused && !isEmbeddedShellFocused ? statusColor ?? theme.border.focused : theme.border.default,
394129
+ borderStyle: "single",
394130
+ borderTop: true,
394131
+ borderBottom: true,
394132
+ borderLeft: false,
394133
+ borderRight: false,
394134
+ borderColor,
394081
394135
  paddingX: 1,
394082
394136
  children: [
394083
394137
  /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
@@ -394156,7 +394210,7 @@ var InputPrompt = /* @__PURE__ */ __name(({
394156
394210
  });
394157
394211
  if (isOnCursorLine && cursorVisualColAbsolute === cpLen(lineText)) {
394158
394212
  renderedLine.push(
394159
- /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Text3, { children: showCursor ? import_chalk7.default.inverse(" ") : " " }, `cursor-end-${cursorVisualColAbsolute}`)
394213
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Text3, { children: showCursor ? import_chalk7.default.inverse(" ") + "\u200B" : " \u200B" }, `cursor-end-${cursorVisualColAbsolute}`)
394160
394214
  );
394161
394215
  }
394162
394216
  return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Box_default, { height: 1, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Text3, { children: renderedLine }) }, `line-${visualIdxInRenderedSet}`);
@@ -405697,8 +405751,8 @@ async function start_sandbox(config2, nodeArgs = [], cliConfig, cliArgs = []) {
405697
405751
  args.push("--env", `COLORTERM=${process.env["COLORTERM"]}`);
405698
405752
  }
405699
405753
  for (const envVar of [
405700
- "QWEN_CODE_IDE_SERVER_PORT",
405701
- "QWEN_CODE_IDE_WORKSPACE_PATH",
405754
+ "RDMIND_CODE_IDE_SERVER_PORT",
405755
+ "RDMIND_CODE_IDE_WORKSPACE_PATH",
405702
405756
  "TERM_PROGRAM"
405703
405757
  ]) {
405704
405758
  if (process.env[envVar]) {
@@ -406582,6 +406636,17 @@ var annotationsSchema = external_exports.object({
406582
406636
  lastModified: external_exports.string().optional().nullable(),
406583
406637
  priority: external_exports.number().optional().nullable()
406584
406638
  });
406639
+ var usageSchema = external_exports.object({
406640
+ promptTokens: external_exports.number().optional().nullable(),
406641
+ completionTokens: external_exports.number().optional().nullable(),
406642
+ thoughtsTokens: external_exports.number().optional().nullable(),
406643
+ totalTokens: external_exports.number().optional().nullable(),
406644
+ cachedTokens: external_exports.number().optional().nullable()
406645
+ });
406646
+ var sessionUpdateMetaSchema = external_exports.object({
406647
+ usage: usageSchema.optional().nullable(),
406648
+ durationMs: external_exports.number().optional().nullable()
406649
+ });
406585
406650
  var requestPermissionResponseSchema = external_exports.object({
406586
406651
  outcome: requestPermissionOutcomeSchema
406587
406652
  });
@@ -406737,11 +406802,13 @@ var sessionUpdateSchema = external_exports.union([
406737
406802
  }),
406738
406803
  external_exports.object({
406739
406804
  content: contentBlockSchema,
406740
- sessionUpdate: external_exports.literal("agent_message_chunk")
406805
+ sessionUpdate: external_exports.literal("agent_message_chunk"),
406806
+ _meta: sessionUpdateMetaSchema.optional().nullable()
406741
406807
  }),
406742
406808
  external_exports.object({
406743
406809
  content: contentBlockSchema,
406744
- sessionUpdate: external_exports.literal("agent_thought_chunk")
406810
+ sessionUpdate: external_exports.literal("agent_thought_chunk"),
406811
+ _meta: sessionUpdateMetaSchema.optional().nullable()
406745
406812
  }),
406746
406813
  external_exports.object({
406747
406814
  content: external_exports.array(toolCallContentSchema).optional(),
@@ -407071,6 +407138,15 @@ var AcpFileSystemService = class {
407071
407138
  line: null,
407072
407139
  limit: null
407073
407140
  });
407141
+ if (response.content.startsWith("ERROR: ENOENT:")) {
407142
+ const match2 = /^ERROR:\s*ENOENT:\s*(?<path>.*)$/i.exec(response.content);
407143
+ const err = new Error(response.content);
407144
+ err.code = "ENOENT";
407145
+ err.errno = -2;
407146
+ const rawPath = match2?.groups?.["path"]?.trim();
407147
+ err["path"] = rawPath ? rawPath.replace(/^['"]|['"]$/g, "") || filePath : filePath;
407148
+ throw err;
407149
+ }
407074
407150
  return response.content;
407075
407151
  }
407076
407152
  async writeTextFile(filePath, content) {
@@ -407152,6 +407228,15 @@ var MessageEmitter = class extends BaseEmitter {
407152
407228
  content: { type: "text", text }
407153
407229
  });
407154
407230
  }
407231
+ /**
407232
+ * Emits an agent thought chunk.
407233
+ */
407234
+ async emitAgentThought(text) {
407235
+ await this.sendUpdate({
407236
+ sessionUpdate: "agent_thought_chunk",
407237
+ content: { type: "text", text }
407238
+ });
407239
+ }
407155
407240
  /**
407156
407241
  * Emits an agent message chunk.
407157
407242
  */
@@ -407162,12 +407247,21 @@ var MessageEmitter = class extends BaseEmitter {
407162
407247
  });
407163
407248
  }
407164
407249
  /**
407165
- * Emits an agent thought chunk.
407250
+ * Emits usage metadata.
407166
407251
  */
407167
- async emitAgentThought(text) {
407252
+ async emitUsageMetadata(usageMetadata, text = "", durationMs) {
407253
+ const usage2 = {
407254
+ promptTokens: usageMetadata.promptTokenCount,
407255
+ completionTokens: usageMetadata.candidatesTokenCount,
407256
+ thoughtsTokens: usageMetadata.thoughtsTokenCount,
407257
+ totalTokens: usageMetadata.totalTokenCount,
407258
+ cachedTokens: usageMetadata.cachedContentTokenCount
407259
+ };
407260
+ const meta = typeof durationMs === "number" ? { usage: usage2, durationMs } : { usage: usage2 };
407168
407261
  await this.sendUpdate({
407169
- sessionUpdate: "agent_thought_chunk",
407170
- content: { type: "text", text }
407262
+ sessionUpdate: "agent_message_chunk",
407263
+ content: { type: "text", text },
407264
+ _meta: meta
407171
407265
  });
407172
407266
  }
407173
407267
  /**
@@ -407284,7 +407378,7 @@ var ToolCallEmitter = class extends BaseEmitter {
407284
407378
  await this.sendUpdate({
407285
407379
  sessionUpdate: "tool_call",
407286
407380
  toolCallId: params.callId,
407287
- status: "in_progress",
407381
+ status: params.status || "pending",
407288
407382
  title,
407289
407383
  content: [],
407290
407384
  locations,
@@ -407451,7 +407545,10 @@ var ToolCallEmitter = class extends BaseEmitter {
407451
407545
  }
407452
407546
  if ("functionResponse" in part && part.functionResponse) {
407453
407547
  try {
407454
- const responseText = JSON.stringify(part.functionResponse.response);
407548
+ const resp = part.functionResponse.response;
407549
+ const outputField = resp["output"];
407550
+ const errorField = resp["error"];
407551
+ const responseText = typeof outputField === "string" ? outputField : typeof errorField === "string" ? errorField : JSON.stringify(resp);
407455
407552
  result.push({
407456
407553
  type: "content",
407457
407554
  content: { type: "text", text: responseText }
@@ -407499,6 +407596,9 @@ var HistoryReplayer = class {
407499
407596
  if (record2.message) {
407500
407597
  await this.replayContent(record2.message, "assistant");
407501
407598
  }
407599
+ if (record2.usageMetadata) {
407600
+ await this.replayUsageMetadata(record2.usageMetadata);
407601
+ }
407502
407602
  break;
407503
407603
  case "tool_result":
407504
407604
  await this.replayToolResult(record2);
@@ -407523,11 +407623,19 @@ var HistoryReplayer = class {
407523
407623
  await this.toolCallEmitter.emitStart({
407524
407624
  toolName: functionName,
407525
407625
  callId,
407526
- args: part.functionCall.args
407626
+ args: part.functionCall.args,
407627
+ status: "in_progress"
407527
407628
  });
407528
407629
  }
407529
407630
  }
407530
407631
  }
407632
+ /**
407633
+ * Replays usage metadata.
407634
+ * @param usageMetadata - The usage metadata to replay
407635
+ */
407636
+ async replayUsageMetadata(usageMetadata) {
407637
+ await this.messageEmitter.emitUsageMetadata(usageMetadata);
407638
+ }
407531
407639
  /**
407532
407640
  * Replays a tool result record.
407533
407641
  */
@@ -407548,6 +407656,40 @@ var HistoryReplayer = class {
407548
407656
  // Note: args aren't stored in tool_result records by default
407549
407657
  args: void 0
407550
407658
  });
407659
+ const { resultDisplay } = result ?? {};
407660
+ if (!!resultDisplay && typeof resultDisplay === "object" && "type" in resultDisplay && resultDisplay.type === "task_execution") {
407661
+ await this.emitTaskUsageFromResultDisplay(
407662
+ resultDisplay
407663
+ );
407664
+ }
407665
+ }
407666
+ /**
407667
+ * Emits token usage from a TaskResultDisplay execution summary, if present.
407668
+ */
407669
+ async emitTaskUsageFromResultDisplay(resultDisplay) {
407670
+ const summary = resultDisplay.executionSummary;
407671
+ if (!summary) {
407672
+ return;
407673
+ }
407674
+ const usageMetadata = {};
407675
+ if (Number.isFinite(summary.inputTokens)) {
407676
+ usageMetadata.promptTokenCount = summary.inputTokens;
407677
+ }
407678
+ if (Number.isFinite(summary.outputTokens)) {
407679
+ usageMetadata.candidatesTokenCount = summary.outputTokens;
407680
+ }
407681
+ if (Number.isFinite(summary.thoughtTokens)) {
407682
+ usageMetadata.thoughtsTokenCount = summary.thoughtTokens;
407683
+ }
407684
+ if (Number.isFinite(summary.cachedTokens)) {
407685
+ usageMetadata.cachedContentTokenCount = summary.cachedTokens;
407686
+ }
407687
+ if (Number.isFinite(summary.totalTokens)) {
407688
+ usageMetadata.totalTokenCount = summary.totalTokens;
407689
+ }
407690
+ if (Object.keys(usageMetadata).length > 0) {
407691
+ await this.messageEmitter.emitUsageMetadata(usageMetadata);
407692
+ }
407551
407693
  }
407552
407694
  /**
407553
407695
  * Extracts tool name from a chat record's function response.
@@ -407585,11 +407727,13 @@ var SubAgentTracker = class {
407585
407727
  this.ctx = ctx;
407586
407728
  this.client = client;
407587
407729
  this.toolCallEmitter = new ToolCallEmitter(ctx);
407730
+ this.messageEmitter = new MessageEmitter(ctx);
407588
407731
  }
407589
407732
  static {
407590
407733
  __name(this, "SubAgentTracker");
407591
407734
  }
407592
407735
  toolCallEmitter;
407736
+ messageEmitter;
407593
407737
  toolStates = /* @__PURE__ */ new Map();
407594
407738
  /**
407595
407739
  * Sets up event listeners for a sub-agent's tool events.
@@ -407602,14 +407746,17 @@ var SubAgentTracker = class {
407602
407746
  const onToolCall = this.createToolCallHandler(abortSignal);
407603
407747
  const onToolResult = this.createToolResultHandler(abortSignal);
407604
407748
  const onApproval = this.createApprovalHandler(abortSignal);
407749
+ const onUsageMetadata = this.createUsageMetadataHandler(abortSignal);
407605
407750
  eventEmitter.on("tool_call" /* TOOL_CALL */, onToolCall);
407606
407751
  eventEmitter.on("tool_result" /* TOOL_RESULT */, onToolResult);
407607
407752
  eventEmitter.on("tool_waiting_approval" /* TOOL_WAITING_APPROVAL */, onApproval);
407753
+ eventEmitter.on("usage_metadata" /* USAGE_METADATA */, onUsageMetadata);
407608
407754
  return [
407609
407755
  () => {
407610
407756
  eventEmitter.off("tool_call" /* TOOL_CALL */, onToolCall);
407611
407757
  eventEmitter.off("tool_result" /* TOOL_RESULT */, onToolResult);
407612
407758
  eventEmitter.off("tool_waiting_approval" /* TOOL_WAITING_APPROVAL */, onApproval);
407759
+ eventEmitter.off("usage_metadata" /* USAGE_METADATA */, onUsageMetadata);
407613
407760
  this.toolStates.clear();
407614
407761
  }
407615
407762
  ];
@@ -407712,6 +407859,16 @@ var SubAgentTracker = class {
407712
407859
  }
407713
407860
  };
407714
407861
  }
407862
+ /**
407863
+ * Creates a handler for usage metadata events.
407864
+ */
407865
+ createUsageMetadataHandler(abortSignal) {
407866
+ return (...args) => {
407867
+ const event = args[0];
407868
+ if (abortSignal.aborted) return;
407869
+ this.messageEmitter.emitUsageMetadata(event.usage, "", event.durationMs);
407870
+ };
407871
+ }
407715
407872
  /**
407716
407873
  * Converts confirmation details to permission options for the client.
407717
407874
  */
@@ -407786,6 +407943,7 @@ var Session3 = class {
407786
407943
  this.toolCallEmitter = new ToolCallEmitter(this);
407787
407944
  this.planEmitter = new PlanEmitter(this);
407788
407945
  this.historyReplayer = new HistoryReplayer(this);
407946
+ this.messageEmitter = new MessageEmitter(this);
407789
407947
  }
407790
407948
  static {
407791
407949
  __name(this, "Session");
@@ -407796,6 +407954,7 @@ var Session3 = class {
407796
407954
  historyReplayer;
407797
407955
  toolCallEmitter;
407798
407956
  planEmitter;
407957
+ messageEmitter;
407799
407958
  // Implement SessionContext interface
407800
407959
  sessionId;
407801
407960
  getId() {
@@ -407862,6 +408021,8 @@ var Session3 = class {
407862
408021
  return { stopReason: "cancelled" };
407863
408022
  }
407864
408023
  const functionCalls = [];
408024
+ let usageMetadata = null;
408025
+ const streamStartTime = Date.now();
407865
408026
  try {
407866
408027
  const responseStream = await chat.sendMessageStream(
407867
408028
  this.config.getModel(),
@@ -407884,16 +408045,16 @@ var Session3 = class {
407884
408045
  if (!part.text) {
407885
408046
  continue;
407886
408047
  }
407887
- const content = {
407888
- type: "text",
407889
- text: part.text
407890
- };
407891
- this.sendUpdate({
407892
- sessionUpdate: part.thought ? "agent_thought_chunk" : "agent_message_chunk",
407893
- content
407894
- });
408048
+ this.messageEmitter.emitMessage(
408049
+ part.text,
408050
+ "assistant",
408051
+ part.thought
408052
+ );
407895
408053
  }
407896
408054
  }
408055
+ if (resp.type === "chunk" /* CHUNK */ && resp.value.usageMetadata) {
408056
+ usageMetadata = resp.value.usageMetadata;
408057
+ }
407897
408058
  if (resp.type === "chunk" /* CHUNK */ && resp.value.functionCalls) {
407898
408059
  functionCalls.push(...resp.value.functionCalls);
407899
408060
  }
@@ -407907,6 +408068,14 @@ var Session3 = class {
407907
408068
  }
407908
408069
  throw error2;
407909
408070
  }
408071
+ if (usageMetadata) {
408072
+ const durationMs = Date.now() - streamStartTime;
408073
+ await this.messageEmitter.emitUsageMetadata(
408074
+ usageMetadata,
408075
+ "",
408076
+ durationMs
408077
+ );
408078
+ }
407910
408079
  if (functionCalls.length > 0) {
407911
408080
  const toolResponseParts = [];
407912
408081
  for (const fc of functionCalls) {
@@ -408045,7 +408214,7 @@ var Session3 = class {
408045
408214
  abortSignal
408046
408215
  );
408047
408216
  }
408048
- const confirmationDetails = await invocation.shouldConfirmExecute(abortSignal);
408217
+ const confirmationDetails = this.config.getApprovalMode() !== "yolo" /* YOLO */ ? await invocation.shouldConfirmExecute(abortSignal) : false;
408049
408218
  if (confirmationDetails) {
408050
408219
  const content = [];
408051
408220
  if (confirmationDetails.type === "edit") {
@@ -408104,7 +408273,8 @@ var Session3 = class {
408104
408273
  const startParams = {
408105
408274
  callId,
408106
408275
  toolName: fc.name,
408107
- args
408276
+ args,
408277
+ status: "in_progress"
408108
408278
  };
408109
408279
  await this.toolCallEmitter.emitStart(startParams);
408110
408280
  }
@@ -408517,7 +408687,7 @@ var GeminiAgent = class {
408517
408687
  name: APPROVAL_MODE_INFO[mode].name,
408518
408688
  description: APPROVAL_MODE_INFO[mode].description
408519
408689
  }));
408520
- const version3 = "0.1.4-alpha.1";
408690
+ const version3 = "0.1.4-alpha.10";
408521
408691
  return {
408522
408692
  protocolVersion: PROTOCOL_VERSION,
408523
408693
  agentInfo: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdmind/rdmind",
3
- "version": "0.1.4-alpha.1",
3
+ "version": "0.1.4-alpha.10",
4
4
  "description": "RDMind - AI-powered coding assistant",
5
5
  "type": "module",
6
6
  "main": "cli.js",
@@ -20,7 +20,7 @@
20
20
  "locales"
21
21
  ],
22
22
  "config": {
23
- "sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.1.4-alpha.1"
23
+ "sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.1.4-alpha.10"
24
24
  },
25
25
  "publishConfig": {
26
26
  "access": "public"