@protolabsai/proto 0.25.13 → 0.25.15

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 +96 -6
  2. package/package.json +2 -2
package/cli.js CHANGED
@@ -170894,7 +170894,7 @@ __export(geminiContentGenerator_exports, {
170894
170894
  createGeminiContentGenerator: () => createGeminiContentGenerator
170895
170895
  });
170896
170896
  function createGeminiContentGenerator(config2, gcConfig) {
170897
- const version2 = "0.25.13";
170897
+ const version2 = "0.25.15";
170898
170898
  const userAgent2 = config2.userAgent || `QwenCode/${version2} (${process.platform}; ${process.arch})`;
170899
170899
  const baseHeaders = {
170900
170900
  "User-Agent": userAgent2
@@ -171950,13 +171950,78 @@ function extractCuratedHistory2(comprehensiveHistory) {
171950
171950
  }
171951
171951
  return curatedHistory;
171952
171952
  }
171953
+ function hasTruncationCascade(contents) {
171954
+ if (contents.length === 0)
171955
+ return false;
171956
+ const last2 = contents[contents.length - 1];
171957
+ if (last2.role !== "user")
171958
+ return false;
171959
+ return last2.parts?.some((p2) => {
171960
+ const err2 = p2.functionResponse?.response?.["error"];
171961
+ return typeof err2 === "string" && err2.includes(TRUNCATION_CASCADE_MARKER);
171962
+ }) ?? false;
171963
+ }
171964
+ function trimLargeToolResponsesFromContext(contents) {
171965
+ return contents.map((content) => {
171966
+ if (content.role !== "user" || !content.parts)
171967
+ return content;
171968
+ const needsTrim = content.parts.some((p2) => {
171969
+ const out2 = p2.functionResponse?.response?.["output"];
171970
+ return typeof out2 === "string" && out2.length > LARGE_TOOL_RESPONSE_TRIM_CHARS;
171971
+ });
171972
+ if (!needsTrim)
171973
+ return content;
171974
+ return {
171975
+ ...content,
171976
+ parts: content.parts.map((p2) => {
171977
+ const out2 = p2.functionResponse?.response?.["output"];
171978
+ if (typeof out2 !== "string" || out2.length <= LARGE_TOOL_RESPONSE_TRIM_CHARS)
171979
+ return p2;
171980
+ const trimmed2 = out2.slice(0, LARGE_TOOL_RESPONSE_TRIM_CHARS) + `
171981
+
171982
+ [... output trimmed from ${out2.length} to ${LARGE_TOOL_RESPONSE_TRIM_CHARS} chars to reduce context size ...]`;
171983
+ return {
171984
+ ...p2,
171985
+ functionResponse: {
171986
+ ...p2.functionResponse,
171987
+ response: {
171988
+ ...p2.functionResponse.response,
171989
+ output: trimmed2
171990
+ }
171991
+ }
171992
+ };
171993
+ })
171994
+ };
171995
+ });
171996
+ }
171997
+ function trimToolErrorsFromContext(contents, maxTrimPairs = 6) {
171998
+ const trimmed2 = [...contents];
171999
+ let trimmed_count = 0;
172000
+ while (trimmed2.length >= 2 && trimmed_count < maxTrimPairs) {
172001
+ const last2 = trimmed2[trimmed2.length - 1];
172002
+ const prev = trimmed2[trimmed2.length - 2];
172003
+ if (last2.role !== "user")
172004
+ break;
172005
+ const allErrors = last2.parts?.every((p2) => p2.functionResponse !== void 0 && typeof p2.functionResponse.response?.["error"] === "string");
172006
+ if (!allErrors)
172007
+ break;
172008
+ if (prev.role !== "model")
172009
+ break;
172010
+ const hasToolCall2 = prev.parts?.some((p2) => p2.functionCall !== void 0);
172011
+ if (!hasToolCall2)
172012
+ break;
172013
+ trimmed2.splice(trimmed2.length - 2, 2);
172014
+ trimmed_count++;
172015
+ }
172016
+ return trimmed2;
172017
+ }
171953
172018
  function isSchemaDepthError(errorMessage) {
171954
172019
  return errorMessage.includes("maximum schema depth exceeded");
171955
172020
  }
171956
172021
  function isInvalidArgumentError(errorMessage) {
171957
172022
  return errorMessage.includes("Request contains an invalid argument");
171958
172023
  }
171959
- var debugLogger22, StreamEventType, INVALID_CONTENT_RETRY_OPTIONS, INVALID_STREAM_RETRY_CONFIG, RATE_LIMIT_RETRY_OPTIONS, InvalidStreamError, GeminiChat;
172024
+ var debugLogger22, StreamEventType, INVALID_CONTENT_RETRY_OPTIONS, INVALID_STREAM_RETRY_CONFIG, RATE_LIMIT_RETRY_OPTIONS, TRUNCATION_CASCADE_MARKER, LARGE_TOOL_RESPONSE_TRIM_CHARS, InvalidStreamError, GeminiChat;
171960
172025
  var init_geminiChat = __esm({
171961
172026
  "packages/core/dist/src/core/geminiChat.js"() {
171962
172027
  "use strict";
@@ -171995,6 +172060,11 @@ var init_geminiChat = __esm({
171995
172060
  __name(isValidContentPart, "isValidContentPart");
171996
172061
  __name(validateHistory2, "validateHistory");
171997
172062
  __name(extractCuratedHistory2, "extractCuratedHistory");
172063
+ TRUNCATION_CASCADE_MARKER = "truncated due to max_tokens limit";
172064
+ LARGE_TOOL_RESPONSE_TRIM_CHARS = 1e4;
172065
+ __name(hasTruncationCascade, "hasTruncationCascade");
172066
+ __name(trimLargeToolResponsesFromContext, "trimLargeToolResponsesFromContext");
172067
+ __name(trimToolErrorsFromContext, "trimToolErrorsFromContext");
171998
172068
  InvalidStreamError = class extends Error {
171999
172069
  static {
172000
172070
  __name(this, "InvalidStreamError");
@@ -172072,7 +172142,12 @@ var init_geminiChat = __esm({
172072
172142
  this.sendPromise = streamDonePromise;
172073
172143
  const userContent = createUserContent(params.message);
172074
172144
  this.history.push(userContent);
172075
- const requestContents = this.getHistory(true);
172145
+ let requestContents = this.getHistory(true);
172146
+ if (hasTruncationCascade(requestContents)) {
172147
+ const withoutErrors = trimToolErrorsFromContext(requestContents);
172148
+ requestContents = trimLargeToolResponsesFromContext(withoutErrors);
172149
+ debugLogger22.warn(`MAX_TOKENS cascade detected: trimmed context from ${this.getHistory(true).length} to ${requestContents.length} entries and capped large tool responses.`);
172150
+ }
172076
172151
  const self2 = this;
172077
172152
  return async function* () {
172078
172153
  try {
@@ -172125,6 +172200,21 @@ var init_geminiChat = __esm({
172125
172200
  await new Promise((res) => setTimeout(res, delayMs));
172126
172201
  continue;
172127
172202
  }
172203
+ if (isTransientStreamError && error40.type === "NO_RESPONSE_TEXT") {
172204
+ const trimmedContents = trimToolErrorsFromContext(requestContents);
172205
+ if (trimmedContents.length < requestContents.length) {
172206
+ debugLogger22.warn(`NO_RESPONSE_TEXT: retrying with trimmed context (removed ${requestContents.length - trimmedContents.length} tool-error messages)`);
172207
+ try {
172208
+ const stream2 = await self2.makeApiCallAndProcessStream(model, trimmedContents, params, prompt_id);
172209
+ for await (const chunk of stream2) {
172210
+ yield { type: StreamEventType.CHUNK, value: chunk };
172211
+ }
172212
+ lastError = null;
172213
+ } catch {
172214
+ }
172215
+ }
172216
+ break;
172217
+ }
172128
172218
  if (isTransientStreamError) {
172129
172219
  break;
172130
172220
  }
@@ -414871,7 +414961,7 @@ __name(getPackageJson, "getPackageJson");
414871
414961
  // packages/cli/src/utils/version.ts
414872
414962
  async function getCliVersion() {
414873
414963
  const pkgJson = await getPackageJson();
414874
- return "0.25.13";
414964
+ return "0.25.15";
414875
414965
  }
414876
414966
  __name(getCliVersion, "getCliVersion");
414877
414967
 
@@ -422643,7 +422733,7 @@ var formatDuration = /* @__PURE__ */ __name((milliseconds) => {
422643
422733
 
422644
422734
  // packages/cli/src/generated/git-commit.ts
422645
422735
  init_esbuild_shims();
422646
- var GIT_COMMIT_INFO = "05b963410";
422736
+ var GIT_COMMIT_INFO = "eda760681";
422647
422737
 
422648
422738
  // packages/cli/src/utils/systemInfo.ts
422649
422739
  async function getNpmVersion() {
@@ -490122,7 +490212,7 @@ var QwenAgent = class {
490122
490212
  async initialize(args2) {
490123
490213
  this.clientCapabilities = args2.clientCapabilities;
490124
490214
  const authMethods = buildAuthMethods();
490125
- const version2 = "0.25.13";
490215
+ const version2 = "0.25.15";
490126
490216
  return {
490127
490217
  protocolVersion: PROTOCOL_VERSION,
490128
490218
  agentInfo: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protolabsai/proto",
3
- "version": "0.25.13",
3
+ "version": "0.25.15",
4
4
  "description": "proto - AI-powered coding agent",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "bundled"
22
22
  ],
23
23
  "config": {
24
- "sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.25.13"
24
+ "sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.25.15"
25
25
  },
26
26
  "dependencies": {},
27
27
  "optionalDependencies": {