@rdmind/rdmind 0.2.8-alpha.13 → 0.2.8-alpha.14

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 +178 -60
  2. package/package.json +2 -2
package/cli.js CHANGED
@@ -134348,7 +134348,8 @@ var init_loggingContentGenerator = __esm({
134348
134348
  combinedParts.push({
134349
134349
  text: part.text,
134350
134350
  ...part.thought ? { thought: true } : {},
134351
- ...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {}
134351
+ ...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
134352
+ ..."codexReasoningItem" in part && part.codexReasoningItem ? { codexReasoningItem: part.codexReasoningItem } : {}
134352
134353
  });
134353
134354
  }
134354
134355
  continue;
@@ -148869,6 +148870,45 @@ function buildCodexInput(contents, systemInstruction, modalities) {
148869
148870
  }
148870
148871
  function convertContentToCodexMessages(content, modalities) {
148871
148872
  const messages = [];
148873
+ const convertCodexReasoningItem = /* @__PURE__ */ __name((rawItem, fallbackText, fallbackSignature) => {
148874
+ if (!rawItem || typeof rawItem !== "object") {
148875
+ if (!fallbackSignature) {
148876
+ return null;
148877
+ }
148878
+ return {
148879
+ type: "reasoning",
148880
+ summary: [{ type: "summary_text", text: fallbackText }],
148881
+ encrypted_content: fallbackSignature
148882
+ };
148883
+ }
148884
+ const raw2 = rawItem;
148885
+ const type = raw2["type"];
148886
+ if (type !== "reasoning") {
148887
+ return null;
148888
+ }
148889
+ const normalized2 = {
148890
+ type: "reasoning",
148891
+ id: typeof raw2["id"] === "string" ? raw2["id"] : void 0,
148892
+ status: typeof raw2["status"] === "string" || raw2["status"] === null ? raw2["status"] : void 0,
148893
+ encrypted_content: typeof raw2["encrypted_content"] === "string" || raw2["encrypted_content"] === null ? raw2["encrypted_content"] : fallbackSignature
148894
+ };
148895
+ if (Array.isArray(raw2["summary"])) {
148896
+ normalized2.summary = raw2["summary"].filter(
148897
+ (summaryItem) => typeof summaryItem === "object" && summaryItem !== null
148898
+ ).map((summaryItem) => ({
148899
+ ...summaryItem,
148900
+ type: summaryItem["type"] === "summary_text" ? "summary_text" : "summary_text",
148901
+ text: typeof summaryItem["text"] === "string" ? summaryItem["text"] : ""
148902
+ }));
148903
+ }
148904
+ if (Array.isArray(raw2["content"])) {
148905
+ normalized2.content = raw2["content"].filter((contentItem) => typeof contentItem === "object" && contentItem).map((contentItem) => ({ ...contentItem }));
148906
+ }
148907
+ if (!normalized2.summary || normalized2.summary.length === 0) {
148908
+ normalized2.summary = [{ type: "summary_text", text: fallbackText }];
148909
+ }
148910
+ return normalized2;
148911
+ }, "convertCodexReasoningItem");
148872
148912
  if (!content) return messages;
148873
148913
  if (typeof content === "string") {
148874
148914
  if (content.trim()) {
@@ -148886,7 +148926,21 @@ function convertContentToCodexMessages(content, modalities) {
148886
148926
  const partObj = part;
148887
148927
  if ("text" in partObj && typeof partObj["text"] === "string") {
148888
148928
  const text = partObj["text"];
148889
- if (!partObj["thought"]) {
148929
+ const isThought = Boolean(partObj["thought"]);
148930
+ const thoughtSignature = typeof partObj["thoughtSignature"] === "string" ? partObj["thoughtSignature"] : void 0;
148931
+ const codexReasoningItem = "codexReasoningItem" in partObj ? partObj["codexReasoningItem"] : void 0;
148932
+ if (isThought) {
148933
+ if (role === "assistant") {
148934
+ const reasoningMessage = convertCodexReasoningItem(
148935
+ codexReasoningItem,
148936
+ text,
148937
+ thoughtSignature
148938
+ );
148939
+ if (reasoningMessage) {
148940
+ messages.push(reasoningMessage);
148941
+ }
148942
+ }
148943
+ } else {
148890
148944
  messages.push({ role, content: text });
148891
148945
  }
148892
148946
  }
@@ -149142,11 +149196,66 @@ function mapCodexStatusToFinishReason(status) {
149142
149196
  return FinishReason.STOP;
149143
149197
  }
149144
149198
  }
149199
+ function finalizeStreamResponse(response, streamState) {
149200
+ const finalResponse = convertCodexResponseToGemini(response);
149201
+ const shouldKeepThoughtPartsOnly = streamState.sawOutputTextDelta || streamState.sawFunctionCallChunk;
149202
+ if (!finalResponse.candidates?.length) {
149203
+ return finalResponse;
149204
+ }
149205
+ finalResponse.candidates = [
149206
+ {
149207
+ ...finalResponse.candidates[0] || {
149208
+ index: 0,
149209
+ content: { role: "model", parts: [] },
149210
+ safetyRatings: []
149211
+ },
149212
+ content: {
149213
+ role: "model",
149214
+ parts: finalResponse.candidates[0]?.content?.parts?.flatMap((part) => {
149215
+ if (shouldKeepThoughtPartsOnly && !part.thought) {
149216
+ return [];
149217
+ }
149218
+ if (streamState.sawReasoningSummaryTextDelta && part.thought) {
149219
+ return [
149220
+ {
149221
+ ...part,
149222
+ text: ""
149223
+ }
149224
+ ];
149225
+ }
149226
+ return [part];
149227
+ }) || []
149228
+ }
149229
+ }
149230
+ ];
149231
+ return finalResponse;
149232
+ }
149145
149233
  function convertCodexResponseToGemini(response) {
149146
149234
  const parts = [];
149147
149235
  if (response.output && Array.isArray(response.output)) {
149148
149236
  for (const item of response.output) {
149149
149237
  if (item.type === "reasoning") {
149238
+ const summaryText = item.summary?.map((summaryItem) => summaryItem.text).filter(Boolean).join("") || "";
149239
+ if (summaryText || item.encrypted_content) {
149240
+ const thoughtPart = {
149241
+ text: summaryText,
149242
+ thought: true
149243
+ };
149244
+ if (item.encrypted_content) {
149245
+ thoughtPart.thoughtSignature = item.encrypted_content;
149246
+ }
149247
+ thoughtPart.codexReasoningItem = {
149248
+ type: "reasoning",
149249
+ id: item.id,
149250
+ status: item.status,
149251
+ content: Array.isArray(item.content) ? item.content.map((contentItem) => ({
149252
+ ...contentItem
149253
+ })) : void 0,
149254
+ summary: item.summary?.map((summaryItem) => ({ ...summaryItem })),
149255
+ encrypted_content: item.encrypted_content
149256
+ };
149257
+ parts.push(thoughtPart);
149258
+ }
149150
149259
  continue;
149151
149260
  }
149152
149261
  if (item.type === "message" && item.content) {
@@ -149301,14 +149410,25 @@ var init_codexContentGenerator = __esm({
149301
149410
  };
149302
149411
  }
149303
149412
  async fetchApi(request4) {
149304
- const response = await fetch(this.baseUrl, {
149305
- method: "POST",
149306
- headers: {
149307
- "Content-Type": "application/json",
149308
- "api-key": this.apiKey
149309
- },
149310
- body: JSON.stringify(request4)
149311
- });
149413
+ let response;
149414
+ try {
149415
+ response = await fetch(this.baseUrl, {
149416
+ method: "POST",
149417
+ headers: {
149418
+ "Content-Type": "application/json",
149419
+ "api-key": this.apiKey
149420
+ },
149421
+ body: JSON.stringify(request4)
149422
+ });
149423
+ } catch (err) {
149424
+ const cause = err instanceof Error ? err.cause : void 0;
149425
+ const code2 = cause && typeof cause === "object" && "code" in cause ? cause.code : void 0;
149426
+ const msg = cause instanceof Error ? cause.message : String(cause ?? err);
149427
+ throw new Error(
149428
+ `Codex API network error: fetch failed (${code2 ?? "unknown"}). ${msg}`,
149429
+ { cause: err }
149430
+ );
149431
+ }
149312
149432
  if (!response.ok) {
149313
149433
  const errorText = await response.text();
149314
149434
  throw new Error(
@@ -149329,7 +149449,8 @@ var init_codexContentGenerator = __esm({
149329
149449
  model,
149330
149450
  input,
149331
149451
  stream: stream2,
149332
- store: true,
149452
+ store: false,
149453
+ include: ["reasoning.encrypted_content"],
149333
149454
  truncation: "auto",
149334
149455
  temperature: this.samplingParams?.temperature ?? 1,
149335
149456
  top_p: this.samplingParams?.top_p,
@@ -149367,6 +149488,11 @@ var init_codexContentGenerator = __esm({
149367
149488
  };
149368
149489
  let streamFinished = false;
149369
149490
  const toolCallArgs = /* @__PURE__ */ new Map();
149491
+ const streamState = {
149492
+ sawReasoningSummaryTextDelta: false,
149493
+ sawOutputTextDelta: false,
149494
+ sawFunctionCallChunk: false
149495
+ };
149370
149496
  try {
149371
149497
  let isFirstChunk = true;
149372
149498
  while (!streamFinished) {
@@ -149408,7 +149534,9 @@ var init_codexContentGenerator = __esm({
149408
149534
  streamDiag.finalOutputTypes = finalResponse?.output?.map((item) => item.type) ?? [];
149409
149535
  streamDiag.finalOutputSummary = finalResponse?.output?.map((item) => ({
149410
149536
  type: item.type,
149411
- contentTypes: item.content?.map((c4) => c4.type)
149537
+ contentTypes: item.content?.map(
149538
+ (c4) => typeof c4 === "object" && c4 && "type" in c4 ? c4.type : void 0
149539
+ ).filter((type) => typeof type === "string")
149412
149540
  })) ?? [];
149413
149541
  }
149414
149542
  if (eventType === "error") {
@@ -149421,7 +149549,8 @@ var init_codexContentGenerator = __esm({
149421
149549
  const response = this.handleStreamEvent(
149422
149550
  currentEvent,
149423
149551
  data,
149424
- toolCallArgs
149552
+ toolCallArgs,
149553
+ streamState
149425
149554
  );
149426
149555
  if (response) {
149427
149556
  yield response;
@@ -149443,14 +149572,23 @@ var init_codexContentGenerator = __esm({
149443
149572
  reader.releaseLock();
149444
149573
  }
149445
149574
  }
149446
- handleStreamEvent(event, data, toolCallArgs) {
149575
+ handleStreamEvent(event, data, toolCallArgs, streamState) {
149447
149576
  switch (event) {
149448
149577
  case "response.reasoning_summary_text.delta": {
149449
- return null;
149578
+ const text = data.delta;
149579
+ if (!text) return null;
149580
+ streamState.sawReasoningSummaryTextDelta = true;
149581
+ return createGeminiResponse(data.item_id || "unknown", [
149582
+ {
149583
+ text,
149584
+ thought: true
149585
+ }
149586
+ ]);
149450
149587
  }
149451
149588
  case "response.output_text.delta": {
149452
149589
  const text = data.delta;
149453
149590
  if (!text) return null;
149591
+ streamState.sawOutputTextDelta = true;
149454
149592
  return createGeminiResponse(data.item_id || "unknown", [{ text }]);
149455
149593
  }
149456
149594
  case "response.function_call_arguments.delta": {
@@ -149474,6 +149612,7 @@ var init_codexContentGenerator = __esm({
149474
149612
  const callId = item.call_id || item.id || accumulated?.id || `call_${Date.now()}`;
149475
149613
  const name3 = item.name || accumulated?.name || "unknown";
149476
149614
  toolCallArgs.delete(index);
149615
+ streamState.sawFunctionCallChunk = true;
149477
149616
  return createGeminiResponse(data.item_id || "unknown", [
149478
149617
  {
149479
149618
  functionCall: { id: callId, name: name3, args }
@@ -149487,48 +149626,27 @@ var init_codexContentGenerator = __esm({
149487
149626
  }
149488
149627
  case "response.completed": {
149489
149628
  const response = data.response;
149490
- const finishReason = mapCodexStatusToFinishReason(response?.status);
149491
- return createGeminiResponse(
149492
- response?.id || "final",
149493
- [],
149494
- finishReason,
149495
- response?.usage ? {
149496
- promptTokenCount: response.usage.input_tokens,
149497
- candidatesTokenCount: response.usage.output_tokens,
149498
- totalTokenCount: response.usage.total_tokens,
149499
- cachedContentTokenCount: response.usage.input_tokens_details?.cached_tokens,
149500
- thoughtsTokenCount: response.usage.output_tokens_details?.reasoning_tokens
149501
- } : void 0
149502
- );
149629
+ if (response) {
149630
+ return finalizeStreamResponse(response, streamState);
149631
+ }
149632
+ return createGeminiResponse("final", []);
149503
149633
  }
149504
149634
  case "response.incomplete": {
149505
149635
  const response = data.response;
149506
- return createGeminiResponse(
149507
- response?.id || "final",
149508
- [],
149509
- FinishReason.MAX_TOKENS,
149510
- response?.usage ? {
149511
- promptTokenCount: response.usage.input_tokens,
149512
- candidatesTokenCount: response.usage.output_tokens,
149513
- totalTokenCount: response.usage.total_tokens,
149514
- cachedContentTokenCount: response.usage.input_tokens_details?.cached_tokens,
149515
- thoughtsTokenCount: response.usage.output_tokens_details?.reasoning_tokens
149516
- } : void 0
149517
- );
149636
+ if (response) {
149637
+ return finalizeStreamResponse(response, streamState);
149638
+ }
149639
+ return createGeminiResponse("final", [], FinishReason.MAX_TOKENS);
149518
149640
  }
149519
149641
  case "response.failed": {
149520
149642
  const response = data.response;
149643
+ if (response) {
149644
+ return finalizeStreamResponse(response, streamState);
149645
+ }
149521
149646
  return createGeminiResponse(
149522
- response?.id || "final",
149647
+ "final",
149523
149648
  [],
149524
- FinishReason.FINISH_REASON_UNSPECIFIED,
149525
- response?.usage ? {
149526
- promptTokenCount: response.usage.input_tokens,
149527
- candidatesTokenCount: response.usage.output_tokens,
149528
- totalTokenCount: response.usage.total_tokens,
149529
- cachedContentTokenCount: response.usage.input_tokens_details?.cached_tokens,
149530
- thoughtsTokenCount: response.usage.output_tokens_details?.reasoning_tokens
149531
- } : void 0
149649
+ FinishReason.FINISH_REASON_UNSPECIFIED
149532
149650
  );
149533
149651
  }
149534
149652
  default:
@@ -149602,6 +149720,7 @@ var init_codexContentGenerator = __esm({
149602
149720
  __name(convertTools, "convertTools");
149603
149721
  __name(convertGeminiSchemaToOpenAI, "convertGeminiSchemaToOpenAI");
149604
149722
  __name(mapCodexStatusToFinishReason, "mapCodexStatusToFinishReason");
149723
+ __name(finalizeStreamResponse, "finalizeStreamResponse");
149605
149724
  __name(convertCodexResponseToGemini, "convertCodexResponseToGemini");
149606
149725
  __name(createGeminiResponse, "createGeminiResponse");
149607
149726
  }
@@ -161193,7 +161312,7 @@ __export(geminiContentGenerator_exports2, {
161193
161312
  createGeminiContentGenerator: () => createGeminiContentGenerator
161194
161313
  });
161195
161314
  function createGeminiContentGenerator(config2, gcConfig) {
161196
- const version2 = "0.2.8-alpha.13";
161315
+ const version2 = "0.2.8-alpha.14";
161197
161316
  const userAgent2 = config2.userAgent || `QwenCode/${version2} (${process.platform}; ${process.arch})`;
161198
161317
  const baseHeaders = {
161199
161318
  "User-Agent": userAgent2
@@ -163143,6 +163262,12 @@ This error was probably caused by cyclic schema references in one of the followi
163143
163262
  if (thoughtContentPart && thoughtSignature) {
163144
163263
  thoughtContentPart.thoughtSignature = thoughtSignature;
163145
163264
  }
163265
+ const codexReasoningItem = allModelParts.find(
163266
+ (part) => part && typeof part === "object" && "thought" in part && part.thought && "codexReasoningItem" in part
163267
+ );
163268
+ if (thoughtContentPart && codexReasoningItem?.codexReasoningItem) {
163269
+ thoughtContentPart.codexReasoningItem = codexReasoningItem.codexReasoningItem;
163270
+ }
163146
163271
  }
163147
163272
  const contentParts = allModelParts.filter((part) => !part.thought);
163148
163273
  const consolidatedHistoryParts = [];
@@ -377173,7 +377298,7 @@ __name(getPackageJson, "getPackageJson");
377173
377298
  // packages/cli/src/utils/version.ts
377174
377299
  async function getCliVersion() {
377175
377300
  const pkgJson = await getPackageJson();
377176
- return "0.2.8-alpha.13";
377301
+ return "0.2.8-alpha.14";
377177
377302
  }
377178
377303
  __name(getCliVersion, "getCliVersion");
377179
377304
 
@@ -384896,7 +385021,7 @@ var formatDuration = /* @__PURE__ */ __name((milliseconds) => {
384896
385021
 
384897
385022
  // packages/cli/src/generated/git-commit.ts
384898
385023
  init_esbuild_shims();
384899
- var GIT_COMMIT_INFO = "32931e816";
385024
+ var GIT_COMMIT_INFO = "4ebf619b1";
384900
385025
 
384901
385026
  // packages/cli/src/utils/systemInfo.ts
384902
385027
  async function getNpmVersion() {
@@ -426271,13 +426396,6 @@ var XHS_SSO_MODELS = [
426271
426396
  contextWindow: "272K",
426272
426397
  description: "\u7528\u4E8E\u5904\u7406\u590D\u6742\u4E13\u4E1A\u5DE5\u4F5C\u7684\u524D\u6CBF\u6A21\u578B (\u63A8\u7406\u5F3A\u5EA6\u4E2D)"
426273
426398
  },
426274
- {
426275
- id: "gpt-5.4(xhigh)",
426276
- displayName: "gpt-5.4(xhigh)",
426277
- baseUrl: "https://runway.devops.rednote.life/openai/v1/responses?api-version=v1",
426278
- contextWindow: "272K",
426279
- description: "\u7528\u4E8E\u5904\u7406\u590D\u6742\u4E13\u4E1A\u5DE5\u4F5C\u7684\u524D\u6CBF\u6A21\u578B (\u63A8\u7406\u5F3A\u5EA6\u6781\u9AD8)"
426280
- },
426281
426399
  {
426282
426400
  id: "gpt-5.3-codex(medium)",
426283
426401
  displayName: "gpt-5.3-codex(medium)",
@@ -447272,7 +447390,7 @@ var QwenAgent = class {
447272
447390
  async initialize(args) {
447273
447391
  this.clientCapabilities = args.clientCapabilities;
447274
447392
  const authMethods = buildAuthMethods();
447275
- const version2 = "0.2.8-alpha.13";
447393
+ const version2 = "0.2.8-alpha.14";
447276
447394
  return {
447277
447395
  protocolVersion: PROTOCOL_VERSION,
447278
447396
  agentInfo: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdmind/rdmind",
3
- "version": "0.2.8-alpha.13",
3
+ "version": "0.2.8-alpha.14",
4
4
  "description": "RDMind - AI-powered coding assistant",
5
5
  "type": "module",
6
6
  "main": "cli.js",
@@ -19,7 +19,7 @@
19
19
  "locales"
20
20
  ],
21
21
  "config": {
22
- "sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.2.8-alpha.13"
22
+ "sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.2.8-alpha.14"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"