@rdmind/rdmind 0.1.4-alpha.5 → 0.1.4-alpha.9

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 +185 -38
  2. package/package.json +2 -2
package/cli.js CHANGED
@@ -89300,6 +89300,8 @@ var init_subagent_statistics = __esm({
89300
89300
  failedToolCalls = 0;
89301
89301
  inputTokens = 0;
89302
89302
  outputTokens = 0;
89303
+ thoughtTokens = 0;
89304
+ cachedTokens = 0;
89303
89305
  toolUsage = /* @__PURE__ */ new Map();
89304
89306
  start(now = Date.now()) {
89305
89307
  this.startTimeMs = now;
@@ -89328,15 +89330,17 @@ var init_subagent_statistics = __esm({
89328
89330
  tu.averageDurationMs = tu.count > 0 ? tu.totalDurationMs / tu.count : 0;
89329
89331
  this.toolUsage.set(name3, tu);
89330
89332
  }
89331
- recordTokens(input, output) {
89333
+ recordTokens(input, output, thought = 0, cached2 = 0) {
89332
89334
  this.inputTokens += Math.max(0, input || 0);
89333
89335
  this.outputTokens += Math.max(0, output || 0);
89336
+ this.thoughtTokens += Math.max(0, thought || 0);
89337
+ this.cachedTokens += Math.max(0, cached2 || 0);
89334
89338
  }
89335
89339
  getSummary(now = Date.now()) {
89336
89340
  const totalDurationMs = this.startTimeMs ? now - this.startTimeMs : 0;
89337
89341
  const totalToolCalls = this.totalToolCalls;
89338
89342
  const successRate = totalToolCalls > 0 ? this.successfulToolCalls / totalToolCalls * 100 : 0;
89339
- const totalTokens = this.inputTokens + this.outputTokens;
89343
+ const totalTokens = this.inputTokens + this.outputTokens + this.thoughtTokens + this.cachedTokens;
89340
89344
  const estimatedCost = this.inputTokens * 3e-5 + this.outputTokens * 6e-5;
89341
89345
  return {
89342
89346
  rounds: this.rounds,
@@ -89347,6 +89351,8 @@ var init_subagent_statistics = __esm({
89347
89351
  successRate,
89348
89352
  inputTokens: this.inputTokens,
89349
89353
  outputTokens: this.outputTokens,
89354
+ thoughtTokens: this.thoughtTokens,
89355
+ cachedTokens: this.cachedTokens,
89350
89356
  totalTokens,
89351
89357
  estimatedCost,
89352
89358
  toolUsage: Array.from(this.toolUsage.values())
@@ -89361,8 +89367,12 @@ var init_subagent_statistics = __esm({
89361
89367
  `\u23F1\uFE0F Duration: ${this.fmtDuration(stats.totalDurationMs)} | \u{1F501} Rounds: ${stats.rounds}`
89362
89368
  ];
89363
89369
  if (typeof stats.totalTokens === "number") {
89370
+ const parts = [
89371
+ `in ${stats.inputTokens ?? 0}`,
89372
+ `out ${stats.outputTokens ?? 0}`
89373
+ ];
89364
89374
  lines.push(
89365
- `\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(", ")})` : ""}`
89366
89376
  );
89367
89377
  }
89368
89378
  return lines.join("\n");
@@ -89390,8 +89400,12 @@ var init_subagent_statistics = __esm({
89390
89400
  `\u{1F527} Tools: ${stats.totalToolCalls} calls, ${sr.toFixed(1)}% success (${stats.successfulToolCalls} ok, ${stats.failedToolCalls} failed)`
89391
89401
  );
89392
89402
  if (typeof stats.totalTokens === "number") {
89403
+ const parts = [
89404
+ `in ${stats.inputTokens ?? 0}`,
89405
+ `out ${stats.outputTokens ?? 0}`
89406
+ ];
89393
89407
  lines.push(
89394
- `\u{1F522} Tokens: ${stats.totalTokens.toLocaleString()} (in ${stats.inputTokens ?? 0}, out ${stats.outputTokens ?? 0})`
89408
+ `\u{1F522} Tokens: ${stats.totalTokens.toLocaleString()} (${parts.join(", ")})`
89395
89409
  );
89396
89410
  }
89397
89411
  if (stats.toolUsage && stats.toolUsage.length) {
@@ -147566,6 +147580,7 @@ var init_uiTelemetry = __esm({
147566
147580
  init_esbuild_shims();
147567
147581
  init_constants();
147568
147582
  init_tool_call_decision();
147583
+ init_constants();
147569
147584
  createInitialModelMetrics = /* @__PURE__ */ __name(() => ({
147570
147585
  api: {
147571
147586
  totalRequests: 0,
@@ -160811,7 +160826,7 @@ function createContentGeneratorConfig(config2, authType, generationConfig) {
160811
160826
  };
160812
160827
  }
160813
160828
  async function createContentGenerator(config2, gcConfig, isInitialAuth) {
160814
- const version3 = "0.1.4-alpha.5";
160829
+ const version3 = "0.1.4-alpha.9";
160815
160830
  const userAgent2 = `QwenCode/${version3} (${process.platform}; ${process.arch})`;
160816
160831
  const baseHeaders = {
160817
160832
  "User-Agent": userAgent2
@@ -179328,6 +179343,7 @@ var init_subagent_events = __esm({
179328
179343
  SubAgentEventType2["TOOL_CALL"] = "tool_call";
179329
179344
  SubAgentEventType2["TOOL_RESULT"] = "tool_result";
179330
179345
  SubAgentEventType2["TOOL_WAITING_APPROVAL"] = "tool_waiting_approval";
179346
+ SubAgentEventType2["USAGE_METADATA"] = "usage_metadata";
179331
179347
  SubAgentEventType2["FINISH"] = "finish";
179332
179348
  SubAgentEventType2["ERROR"] = "error";
179333
179349
  return SubAgentEventType2;
@@ -179579,6 +179595,7 @@ var init_subagent = __esm({
179579
179595
  tools: [{ functionDeclarations: toolsList }]
179580
179596
  }
179581
179597
  };
179598
+ const roundStreamStart = Date.now();
179582
179599
  const responseStream = await chat.sendMessageStream(
179583
179600
  this.modelConfig.model || this.runtimeContext.getModel() || DEFAULT_QWEN_MODEL,
179584
179601
  messageParams,
@@ -179641,16 +179658,27 @@ var init_subagent = __esm({
179641
179658
  if (lastUsage) {
179642
179659
  const inTok = Number(lastUsage.promptTokenCount || 0);
179643
179660
  const outTok = Number(lastUsage.candidatesTokenCount || 0);
179644
- 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)) {
179645
179664
  this.stats.recordTokens(
179646
179665
  isFinite(inTok) ? inTok : 0,
179647
- isFinite(outTok) ? outTok : 0
179666
+ isFinite(outTok) ? outTok : 0,
179667
+ isFinite(thoughtTok) ? thoughtTok : 0,
179668
+ isFinite(cachedTok) ? cachedTok : 0
179648
179669
  );
179649
179670
  this.executionStats.inputTokens = (this.executionStats.inputTokens || 0) + (isFinite(inTok) ? inTok : 0);
179650
179671
  this.executionStats.outputTokens = (this.executionStats.outputTokens || 0) + (isFinite(outTok) ? outTok : 0);
179651
- 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);
179652
179673
  this.executionStats.estimatedCost = (this.executionStats.inputTokens || 0) * 3e-5 + (this.executionStats.outputTokens || 0) * 6e-5;
179653
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
+ });
179654
179682
  }
179655
179683
  if (functionCalls.length > 0) {
179656
179684
  currentMessages = await this.processFunctionCalls(
@@ -235963,8 +235991,8 @@ var init_git_commit = __esm({
235963
235991
  "packages/core/src/generated/git-commit.ts"() {
235964
235992
  "use strict";
235965
235993
  init_esbuild_shims();
235966
- GIT_COMMIT_INFO = "24f4e0cf";
235967
- CLI_VERSION = "0.1.4-alpha.5";
235994
+ GIT_COMMIT_INFO = "a5a74672";
235995
+ CLI_VERSION = "0.1.4-alpha.9";
235968
235996
  }
235969
235997
  });
235970
235998
 
@@ -236900,6 +236928,9 @@ __export(core_exports4, {
236900
236928
  DeclarativeTool: () => DeclarativeTool,
236901
236929
  DiscoveredMCPTool: () => DiscoveredMCPTool,
236902
236930
  DiscoveredTool: () => DiscoveredTool,
236931
+ EVENT_API_ERROR: () => EVENT_API_ERROR,
236932
+ EVENT_API_RESPONSE: () => EVENT_API_RESPONSE,
236933
+ EVENT_TOOL_CALL: () => EVENT_TOOL_CALL,
236903
236934
  EditTool: () => EditTool,
236904
236935
  EndSessionEvent: () => EndSessionEvent,
236905
236936
  ExitPlanModeTool: () => ExitPlanModeTool,
@@ -334041,7 +334072,7 @@ var patchConsole = /* @__PURE__ */ __name((callback) => {
334041
334072
  var dist_default2 = patchConsole;
334042
334073
 
334043
334074
  // node_modules/ink/build/ink.js
334044
- var import_constants20 = __toESM(require_constants11(), 1);
334075
+ var import_constants21 = __toESM(require_constants11(), 1);
334045
334076
 
334046
334077
  // node_modules/yoga-layout/dist/src/index.js
334047
334078
  init_esbuild_shims();
@@ -336104,7 +336135,7 @@ __name(wrapAnsi, "wrapAnsi");
336104
336135
  // node_modules/ink/build/reconciler.js
336105
336136
  init_esbuild_shims();
336106
336137
  var import_react_reconciler = __toESM(require_react_reconciler(), 1);
336107
- var import_constants19 = __toESM(require_constants11(), 1);
336138
+ var import_constants20 = __toESM(require_constants11(), 1);
336108
336139
  import process15 from "node:process";
336109
336140
  var import_react = __toESM(require_react(), 1);
336110
336141
 
@@ -337075,7 +337106,7 @@ var cleanupYogaNode = /* @__PURE__ */ __name((node) => {
337075
337106
  node?.unsetMeasureFunc();
337076
337107
  node?.freeRecursive();
337077
337108
  }, "cleanupYogaNode");
337078
- var currentUpdatePriority = import_constants19.NoEventPriority;
337109
+ var currentUpdatePriority = import_constants20.NoEventPriority;
337079
337110
  var currentRootNode;
337080
337111
  var reconciler_default = (0, import_react_reconciler.default)({
337081
337112
  getRootHostContext: /* @__PURE__ */ __name(() => ({
@@ -337232,10 +337263,10 @@ var reconciler_default = (0, import_react_reconciler.default)({
337232
337263
  },
337233
337264
  getCurrentUpdatePriority: /* @__PURE__ */ __name(() => currentUpdatePriority, "getCurrentUpdatePriority"),
337234
337265
  resolveUpdatePriority() {
337235
- if (currentUpdatePriority !== import_constants19.NoEventPriority) {
337266
+ if (currentUpdatePriority !== import_constants20.NoEventPriority) {
337236
337267
  return currentUpdatePriority;
337237
337268
  }
337238
- return import_constants19.DefaultEventPriority;
337269
+ return import_constants20.DefaultEventPriority;
337239
337270
  },
337240
337271
  maySuspendCommit() {
337241
337272
  return false;
@@ -339753,7 +339784,7 @@ var Ink = class {
339753
339784
  this.fullStaticOutput = "";
339754
339785
  this.container = reconciler_default.createContainer(
339755
339786
  this.rootNode,
339756
- import_constants20.LegacyRoot,
339787
+ import_constants21.LegacyRoot,
339757
339788
  null,
339758
339789
  false,
339759
339790
  null,
@@ -346320,7 +346351,7 @@ __name(getPackageJson, "getPackageJson");
346320
346351
  // packages/cli/src/utils/version.ts
346321
346352
  async function getCliVersion() {
346322
346353
  const pkgJson = await getPackageJson();
346323
- return "0.1.4-alpha.5";
346354
+ return "0.1.4-alpha.9";
346324
346355
  }
346325
346356
  __name(getCliVersion, "getCliVersion");
346326
346357
 
@@ -352850,7 +352881,7 @@ var formatDuration = /* @__PURE__ */ __name((milliseconds) => {
352850
352881
 
352851
352882
  // packages/cli/src/generated/git-commit.ts
352852
352883
  init_esbuild_shims();
352853
- var GIT_COMMIT_INFO2 = "24f4e0cf";
352884
+ var GIT_COMMIT_INFO2 = "a5a74672";
352854
352885
 
352855
352886
  // packages/cli/src/utils/systemInfo.ts
352856
352887
  async function getNpmVersion() {
@@ -406605,6 +406636,17 @@ var annotationsSchema = external_exports.object({
406605
406636
  lastModified: external_exports.string().optional().nullable(),
406606
406637
  priority: external_exports.number().optional().nullable()
406607
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
+ });
406608
406650
  var requestPermissionResponseSchema = external_exports.object({
406609
406651
  outcome: requestPermissionOutcomeSchema
406610
406652
  });
@@ -406760,11 +406802,13 @@ var sessionUpdateSchema = external_exports.union([
406760
406802
  }),
406761
406803
  external_exports.object({
406762
406804
  content: contentBlockSchema,
406763
- sessionUpdate: external_exports.literal("agent_message_chunk")
406805
+ sessionUpdate: external_exports.literal("agent_message_chunk"),
406806
+ _meta: sessionUpdateMetaSchema.optional().nullable()
406764
406807
  }),
406765
406808
  external_exports.object({
406766
406809
  content: contentBlockSchema,
406767
- sessionUpdate: external_exports.literal("agent_thought_chunk")
406810
+ sessionUpdate: external_exports.literal("agent_thought_chunk"),
406811
+ _meta: sessionUpdateMetaSchema.optional().nullable()
406768
406812
  }),
406769
406813
  external_exports.object({
406770
406814
  content: external_exports.array(toolCallContentSchema).optional(),
@@ -407094,6 +407138,15 @@ var AcpFileSystemService = class {
407094
407138
  line: null,
407095
407139
  limit: null
407096
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
+ }
407097
407150
  return response.content;
407098
407151
  }
407099
407152
  async writeTextFile(filePath, content) {
@@ -407175,6 +407228,15 @@ var MessageEmitter = class extends BaseEmitter {
407175
407228
  content: { type: "text", text }
407176
407229
  });
407177
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
+ }
407178
407240
  /**
407179
407241
  * Emits an agent message chunk.
407180
407242
  */
@@ -407185,12 +407247,21 @@ var MessageEmitter = class extends BaseEmitter {
407185
407247
  });
407186
407248
  }
407187
407249
  /**
407188
- * Emits an agent thought chunk.
407250
+ * Emits usage metadata.
407189
407251
  */
407190
- 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 };
407191
407261
  await this.sendUpdate({
407192
- sessionUpdate: "agent_thought_chunk",
407193
- content: { type: "text", text }
407262
+ sessionUpdate: "agent_message_chunk",
407263
+ content: { type: "text", text },
407264
+ _meta: meta
407194
407265
  });
407195
407266
  }
407196
407267
  /**
@@ -407307,7 +407378,7 @@ var ToolCallEmitter = class extends BaseEmitter {
407307
407378
  await this.sendUpdate({
407308
407379
  sessionUpdate: "tool_call",
407309
407380
  toolCallId: params.callId,
407310
- status: "in_progress",
407381
+ status: params.status || "pending",
407311
407382
  title,
407312
407383
  content: [],
407313
407384
  locations,
@@ -407474,7 +407545,10 @@ var ToolCallEmitter = class extends BaseEmitter {
407474
407545
  }
407475
407546
  if ("functionResponse" in part && part.functionResponse) {
407476
407547
  try {
407477
- 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);
407478
407552
  result.push({
407479
407553
  type: "content",
407480
407554
  content: { type: "text", text: responseText }
@@ -407522,6 +407596,9 @@ var HistoryReplayer = class {
407522
407596
  if (record2.message) {
407523
407597
  await this.replayContent(record2.message, "assistant");
407524
407598
  }
407599
+ if (record2.usageMetadata) {
407600
+ await this.replayUsageMetadata(record2.usageMetadata);
407601
+ }
407525
407602
  break;
407526
407603
  case "tool_result":
407527
407604
  await this.replayToolResult(record2);
@@ -407546,11 +407623,19 @@ var HistoryReplayer = class {
407546
407623
  await this.toolCallEmitter.emitStart({
407547
407624
  toolName: functionName,
407548
407625
  callId,
407549
- args: part.functionCall.args
407626
+ args: part.functionCall.args,
407627
+ status: "in_progress"
407550
407628
  });
407551
407629
  }
407552
407630
  }
407553
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
+ }
407554
407639
  /**
407555
407640
  * Replays a tool result record.
407556
407641
  */
@@ -407571,6 +407656,40 @@ var HistoryReplayer = class {
407571
407656
  // Note: args aren't stored in tool_result records by default
407572
407657
  args: void 0
407573
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
+ }
407574
407693
  }
407575
407694
  /**
407576
407695
  * Extracts tool name from a chat record's function response.
@@ -407608,11 +407727,13 @@ var SubAgentTracker = class {
407608
407727
  this.ctx = ctx;
407609
407728
  this.client = client;
407610
407729
  this.toolCallEmitter = new ToolCallEmitter(ctx);
407730
+ this.messageEmitter = new MessageEmitter(ctx);
407611
407731
  }
407612
407732
  static {
407613
407733
  __name(this, "SubAgentTracker");
407614
407734
  }
407615
407735
  toolCallEmitter;
407736
+ messageEmitter;
407616
407737
  toolStates = /* @__PURE__ */ new Map();
407617
407738
  /**
407618
407739
  * Sets up event listeners for a sub-agent's tool events.
@@ -407625,14 +407746,17 @@ var SubAgentTracker = class {
407625
407746
  const onToolCall = this.createToolCallHandler(abortSignal);
407626
407747
  const onToolResult = this.createToolResultHandler(abortSignal);
407627
407748
  const onApproval = this.createApprovalHandler(abortSignal);
407749
+ const onUsageMetadata = this.createUsageMetadataHandler(abortSignal);
407628
407750
  eventEmitter.on("tool_call" /* TOOL_CALL */, onToolCall);
407629
407751
  eventEmitter.on("tool_result" /* TOOL_RESULT */, onToolResult);
407630
407752
  eventEmitter.on("tool_waiting_approval" /* TOOL_WAITING_APPROVAL */, onApproval);
407753
+ eventEmitter.on("usage_metadata" /* USAGE_METADATA */, onUsageMetadata);
407631
407754
  return [
407632
407755
  () => {
407633
407756
  eventEmitter.off("tool_call" /* TOOL_CALL */, onToolCall);
407634
407757
  eventEmitter.off("tool_result" /* TOOL_RESULT */, onToolResult);
407635
407758
  eventEmitter.off("tool_waiting_approval" /* TOOL_WAITING_APPROVAL */, onApproval);
407759
+ eventEmitter.off("usage_metadata" /* USAGE_METADATA */, onUsageMetadata);
407636
407760
  this.toolStates.clear();
407637
407761
  }
407638
407762
  ];
@@ -407735,6 +407859,16 @@ var SubAgentTracker = class {
407735
407859
  }
407736
407860
  };
407737
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
+ }
407738
407872
  /**
407739
407873
  * Converts confirmation details to permission options for the client.
407740
407874
  */
@@ -407809,6 +407943,7 @@ var Session3 = class {
407809
407943
  this.toolCallEmitter = new ToolCallEmitter(this);
407810
407944
  this.planEmitter = new PlanEmitter(this);
407811
407945
  this.historyReplayer = new HistoryReplayer(this);
407946
+ this.messageEmitter = new MessageEmitter(this);
407812
407947
  }
407813
407948
  static {
407814
407949
  __name(this, "Session");
@@ -407819,6 +407954,7 @@ var Session3 = class {
407819
407954
  historyReplayer;
407820
407955
  toolCallEmitter;
407821
407956
  planEmitter;
407957
+ messageEmitter;
407822
407958
  // Implement SessionContext interface
407823
407959
  sessionId;
407824
407960
  getId() {
@@ -407885,6 +408021,8 @@ var Session3 = class {
407885
408021
  return { stopReason: "cancelled" };
407886
408022
  }
407887
408023
  const functionCalls = [];
408024
+ let usageMetadata = null;
408025
+ const streamStartTime = Date.now();
407888
408026
  try {
407889
408027
  const responseStream = await chat.sendMessageStream(
407890
408028
  this.config.getModel(),
@@ -407907,16 +408045,16 @@ var Session3 = class {
407907
408045
  if (!part.text) {
407908
408046
  continue;
407909
408047
  }
407910
- const content = {
407911
- type: "text",
407912
- text: part.text
407913
- };
407914
- this.sendUpdate({
407915
- sessionUpdate: part.thought ? "agent_thought_chunk" : "agent_message_chunk",
407916
- content
407917
- });
408048
+ this.messageEmitter.emitMessage(
408049
+ part.text,
408050
+ "assistant",
408051
+ part.thought
408052
+ );
407918
408053
  }
407919
408054
  }
408055
+ if (resp.type === "chunk" /* CHUNK */ && resp.value.usageMetadata) {
408056
+ usageMetadata = resp.value.usageMetadata;
408057
+ }
407920
408058
  if (resp.type === "chunk" /* CHUNK */ && resp.value.functionCalls) {
407921
408059
  functionCalls.push(...resp.value.functionCalls);
407922
408060
  }
@@ -407930,6 +408068,14 @@ var Session3 = class {
407930
408068
  }
407931
408069
  throw error2;
407932
408070
  }
408071
+ if (usageMetadata) {
408072
+ const durationMs = Date.now() - streamStartTime;
408073
+ await this.messageEmitter.emitUsageMetadata(
408074
+ usageMetadata,
408075
+ "",
408076
+ durationMs
408077
+ );
408078
+ }
407933
408079
  if (functionCalls.length > 0) {
407934
408080
  const toolResponseParts = [];
407935
408081
  for (const fc of functionCalls) {
@@ -408068,7 +408214,7 @@ var Session3 = class {
408068
408214
  abortSignal
408069
408215
  );
408070
408216
  }
408071
- const confirmationDetails = await invocation.shouldConfirmExecute(abortSignal);
408217
+ const confirmationDetails = this.config.getApprovalMode() !== "yolo" /* YOLO */ ? await invocation.shouldConfirmExecute(abortSignal) : false;
408072
408218
  if (confirmationDetails) {
408073
408219
  const content = [];
408074
408220
  if (confirmationDetails.type === "edit") {
@@ -408127,7 +408273,8 @@ var Session3 = class {
408127
408273
  const startParams = {
408128
408274
  callId,
408129
408275
  toolName: fc.name,
408130
- args
408276
+ args,
408277
+ status: "in_progress"
408131
408278
  };
408132
408279
  await this.toolCallEmitter.emitStart(startParams);
408133
408280
  }
@@ -408540,7 +408687,7 @@ var GeminiAgent = class {
408540
408687
  name: APPROVAL_MODE_INFO[mode].name,
408541
408688
  description: APPROVAL_MODE_INFO[mode].description
408542
408689
  }));
408543
- const version3 = "0.1.4-alpha.5";
408690
+ const version3 = "0.1.4-alpha.9";
408544
408691
  return {
408545
408692
  protocolVersion: PROTOCOL_VERSION,
408546
408693
  agentInfo: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdmind/rdmind",
3
- "version": "0.1.4-alpha.5",
3
+ "version": "0.1.4-alpha.9",
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.5"
23
+ "sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.1.4-alpha.9"
24
24
  },
25
25
  "publishConfig": {
26
26
  "access": "public"