@maximoai/maximo-syntax-cli 0.1.38 → 0.1.40

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/dist/cli.mjs +340 -56
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -108074,6 +108074,8 @@ async function populateOAuthAccountInfoIfNeeded() {
108074
108074
  emailAddress: profile.account.email,
108075
108075
  organizationUuid: profile.organization.uuid,
108076
108076
  displayName: profile.account.display_name || undefined,
108077
+ username: profile.account.username || undefined,
108078
+ profilePhotoUrl: profile.account.profile_photo_url || undefined,
108077
108079
  hasExtraUsageEnabled: profile.organization.has_extra_usage_enabled ?? false,
108078
108080
  billingType: profile.organization.billing_type ?? undefined,
108079
108081
  accountCreatedAt: profile.account.created_at,
@@ -108089,6 +108091,8 @@ function storeOAuthAccountInfo({
108089
108091
  emailAddress,
108090
108092
  organizationUuid,
108091
108093
  displayName,
108094
+ username,
108095
+ profilePhotoUrl,
108092
108096
  hasExtraUsageEnabled,
108093
108097
  billingType,
108094
108098
  accountCreatedAt,
@@ -108106,8 +108110,14 @@ function storeOAuthAccountInfo({
108106
108110
  if (displayName) {
108107
108111
  accountInfo.displayName = displayName;
108108
108112
  }
108113
+ if (username) {
108114
+ accountInfo.username = username;
108115
+ }
108116
+ if (profilePhotoUrl) {
108117
+ accountInfo.profilePhotoUrl = profilePhotoUrl;
108118
+ }
108109
108119
  saveGlobalConfig((current) => {
108110
- if (current.oauthAccount?.accountUuid === accountInfo.accountUuid && current.oauthAccount?.emailAddress === accountInfo.emailAddress && current.oauthAccount?.organizationUuid === accountInfo.organizationUuid && current.oauthAccount?.displayName === accountInfo.displayName && current.oauthAccount?.hasExtraUsageEnabled === accountInfo.hasExtraUsageEnabled && current.oauthAccount?.billingType === accountInfo.billingType && current.oauthAccount?.accountCreatedAt === accountInfo.accountCreatedAt && current.oauthAccount?.subscriptionCreatedAt === accountInfo.subscriptionCreatedAt) {
108120
+ if (current.oauthAccount?.accountUuid === accountInfo.accountUuid && current.oauthAccount?.emailAddress === accountInfo.emailAddress && current.oauthAccount?.organizationUuid === accountInfo.organizationUuid && current.oauthAccount?.displayName === accountInfo.displayName && current.oauthAccount?.username === accountInfo.username && current.oauthAccount?.profilePhotoUrl === accountInfo.profilePhotoUrl && current.oauthAccount?.hasExtraUsageEnabled === accountInfo.hasExtraUsageEnabled && current.oauthAccount?.billingType === accountInfo.billingType && current.oauthAccount?.accountCreatedAt === accountInfo.accountCreatedAt && current.oauthAccount?.subscriptionCreatedAt === accountInfo.subscriptionCreatedAt) {
108111
108121
  return current;
108112
108122
  }
108113
108123
  return { ...current, oauthAccount: accountInfo };
@@ -108831,6 +108841,7 @@ async function refreshMyTabulonAccount({
108831
108841
  emailAddress: context2?.user?.email || previous?.emailAddress,
108832
108842
  displayName: context2?.user?.display_name || previous?.displayName,
108833
108843
  username: context2?.user?.username || previous?.username,
108844
+ profilePhotoUrl: context2?.user?.profile_photo_url || previous?.profilePhotoUrl,
108834
108845
  workspaceId: context2?.workspace?.id || previous?.workspaceId,
108835
108846
  workspaceName: context2?.workspace?.name || previous?.workspaceName,
108836
108847
  codingPlanActive: typeof plan.active === "boolean" ? plan.active : previous?.codingPlanActive ?? true,
@@ -108856,6 +108867,7 @@ function persistMyTabulonState(apiKey, baseUrl, models, account) {
108856
108867
  openAIModel: undefined,
108857
108868
  mytabulonDefaultModel: defaultModel,
108858
108869
  mytabulonAccount: account,
108870
+ maximoAccount: undefined,
108859
108871
  cencoriApiKey: undefined
108860
108872
  }));
108861
108873
  }
@@ -108900,7 +108912,8 @@ function persistCencoriState(apiKey, baseUrl, model) {
108900
108912
  openAIModel: model ?? current.openAIModel,
108901
108913
  openCodePlan: undefined,
108902
108914
  mytabulonDefaultModel: undefined,
108903
- mytabulonAccount: undefined
108915
+ mytabulonAccount: undefined,
108916
+ maximoAccount: undefined
108904
108917
  }));
108905
108918
  }
108906
108919
  async function configureCencoriProvider(apiKey) {
@@ -108954,6 +108967,7 @@ function persistExternalProviderState({
108954
108967
  cencoriApiKey: undefined,
108955
108968
  mytabulonDefaultModel: undefined,
108956
108969
  mytabulonAccount: undefined,
108970
+ maximoAccount: undefined,
108957
108971
  oauthAccount: undefined
108958
108972
  }));
108959
108973
  }
@@ -111323,6 +111337,32 @@ function containsImageContent(value) {
111323
111337
  return true;
111324
111338
  return containsImageContent(record2.content) || containsImageContent(record2.message);
111325
111339
  }
111340
+ function errorText(value) {
111341
+ if (value instanceof Error)
111342
+ return value.message;
111343
+ return typeof value === "string" ? value : "";
111344
+ }
111345
+ function isOpenAIUserAbort(error41, signal) {
111346
+ if (signal?.aborted && /timed out/i.test(errorText(signal.reason)))
111347
+ return false;
111348
+ if (signal?.aborted)
111349
+ return true;
111350
+ if (/timed out/i.test(errorText(error41)))
111351
+ return false;
111352
+ return error41 instanceof Error && error41.name === "AbortError";
111353
+ }
111354
+ function throwOpenAICompatibleHttpError(response, errorBody) {
111355
+ let parsed;
111356
+ try {
111357
+ parsed = JSON.parse(errorBody);
111358
+ } catch {
111359
+ parsed = undefined;
111360
+ }
111361
+ const record2 = parsed && typeof parsed === "object" ? parsed : undefined;
111362
+ const nested = record2?.error && typeof record2.error === "object" ? record2.error : record2;
111363
+ const display = `OpenAI-compatible API error ${response.status}: ${errorBody}`;
111364
+ throw new APIError(response.status, { ...nested ?? {}, message: display }, display, response.headers);
111365
+ }
111326
111366
 
111327
111367
  class OpenAIShimMessages {
111328
111368
  defaultHeaders;
@@ -111452,15 +111492,27 @@ class OpenAIShimMessages {
111452
111492
  headers["HTTP-Referer"] = "https://maximoai.co";
111453
111493
  headers["X-OpenRouter-Title"] = "Maximo Syntax";
111454
111494
  }
111455
- const response = await fetch(`${request.baseUrl}/chat/completions`, {
111456
- method: "POST",
111457
- headers,
111458
- body: JSON.stringify(body),
111459
- signal: options?.signal
111460
- });
111495
+ let response;
111496
+ try {
111497
+ response = await fetch(`${request.baseUrl}/chat/completions`, {
111498
+ method: "POST",
111499
+ headers,
111500
+ body: JSON.stringify(body),
111501
+ signal: options?.signal
111502
+ });
111503
+ } catch (error41) {
111504
+ if (isOpenAIUserAbort(error41, options?.signal))
111505
+ throw error41;
111506
+ if (error41 instanceof APIError)
111507
+ throw error41;
111508
+ throw new APIConnectionError({
111509
+ message: error41 instanceof Error ? error41.message : "fetch failed",
111510
+ cause: error41 instanceof Error ? error41 : undefined
111511
+ });
111512
+ }
111461
111513
  if (!response.ok) {
111462
111514
  const errorBody = await response.text().catch(() => "unknown error");
111463
- throw new Error(`OpenAI-compatible API error ${response.status}: ${errorBody}`);
111515
+ throwOpenAICompatibleHttpError(response, errorBody);
111464
111516
  }
111465
111517
  return response;
111466
111518
  }
@@ -111565,6 +111617,7 @@ function createOpenAIShimClient(options) {
111565
111617
  }
111566
111618
  var TOOL_RESULT_IMAGE_PLACEHOLDER = "[Tool returned an image.]", OpenAIShimStream;
111567
111619
  var init_openaiShim = __esm(() => {
111620
+ init_sdk();
111568
111621
  init_providerConfig();
111569
111622
  OpenAIShimStream = class OpenAIShimStream {
111570
111623
  generator;
@@ -124011,7 +124064,7 @@ var init_metadata = __esm(() => {
124011
124064
  isMaximoAiAuth: isMaximoAISubscriber(),
124012
124065
  version: "99.0.0",
124013
124066
  versionBase: getVersionBase(),
124014
- buildTime: "2026-08-20T22:52:41.981Z",
124067
+ buildTime: "2026-08-30T20:30:34.525Z",
124015
124068
  deploymentEnvironment: env3.detectDeploymentEnvironment(),
124016
124069
  ...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
124017
124070
  githubEventName: process.env.GITHUB_EVENT_NAME,
@@ -125521,6 +125574,7 @@ function createDefaultGlobalConfig() {
125521
125574
  verbose: false,
125522
125575
  editorMode: "normal",
125523
125576
  autoCompactEnabled: true,
125577
+ autoCompactPercent: 40,
125524
125578
  showTurnDuration: true,
125525
125579
  hasSeenTasksHint: false,
125526
125580
  hasUsedStash: false,
@@ -126250,6 +126304,7 @@ var init_config2 = __esm(() => {
126250
126304
  "editorMode",
126251
126305
  "hasUsedBackslashReturn",
126252
126306
  "autoCompactEnabled",
126307
+ "autoCompactPercent",
126253
126308
  "showTurnDuration",
126254
126309
  "diffTool",
126255
126310
  "env",
@@ -177657,6 +177712,61 @@ function isPersistentRetryEnabled() {
177657
177712
  function isTransientCapacityError(error42) {
177658
177713
  return is529Error(error42) || error42 instanceof APIError && error42.status === 429;
177659
177714
  }
177715
+ function providerErrorBlob(error42) {
177716
+ if (error42 == null)
177717
+ return "";
177718
+ if (typeof error42 === "string")
177719
+ return error42;
177720
+ if (error42 instanceof Error) {
177721
+ const extra = "error" in error42 && error42.error != null ? JSON.stringify(error42.error) : "";
177722
+ return `${error42.message} ${extra}`;
177723
+ }
177724
+ try {
177725
+ return JSON.stringify(error42);
177726
+ } catch {
177727
+ return String(error42);
177728
+ }
177729
+ }
177730
+ function isTransientProviderRateLimit(error42) {
177731
+ const blob2 = providerErrorBlob(error42);
177732
+ return /token_limit_exceeded/i.test(blob2) || /tokens per minute limit/i.test(blob2) || /OpenAI-compatible API error 429/i.test(blob2);
177733
+ }
177734
+ function isUserAbortError(error42) {
177735
+ if (error42 instanceof APIUserAbortError)
177736
+ return true;
177737
+ return error42 instanceof Error && error42.name === "AbortError";
177738
+ }
177739
+ function isGenericTransientProviderError(error42) {
177740
+ if (error42 == null || isUserAbortError(error42))
177741
+ return false;
177742
+ if (error42 instanceof APIError)
177743
+ return false;
177744
+ if (error42 instanceof TypeError)
177745
+ return true;
177746
+ const blob2 = providerErrorBlob(error42);
177747
+ return /fetch failed/i.test(blob2) || /failed to fetch/i.test(blob2) || /ECONNRESET|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|ENETUNREACH|EHOSTUNREACH/i.test(blob2) || /socket hang up|UND_ERR|timed out/i.test(blob2) || /OpenAI-compatible API error (429|408|409|5\d\d)/i.test(blob2) || /token_limit_exceeded/i.test(blob2);
177748
+ }
177749
+ function asSystemRetryError(error42) {
177750
+ if (error42 instanceof APIError)
177751
+ return error42;
177752
+ const message = error42 instanceof Error ? error42.message : String(error42);
177753
+ const statusMatch = /OpenAI-compatible API error (\d{3})/.exec(message);
177754
+ const status = statusMatch ? Number(statusMatch[1]) : undefined;
177755
+ if (status) {
177756
+ return new APIError(status, { message }, message, new globalThis.Headers);
177757
+ }
177758
+ return new APIConnectionError({
177759
+ message,
177760
+ cause: error42 instanceof Error ? error42 : undefined
177761
+ });
177762
+ }
177763
+ function isRetryableApiFailure(error42) {
177764
+ if (isUserAbortError(error42))
177765
+ return false;
177766
+ if (error42 instanceof APIError)
177767
+ return shouldRetry(error42);
177768
+ return isGenericTransientProviderError(error42);
177769
+ }
177660
177770
  function isStaleConnectionError(error42) {
177661
177771
  if (!(error42 instanceof APIConnectionError)) {
177662
177772
  return false;
@@ -177758,7 +177868,7 @@ async function* withRetry(getClient, operation, options2) {
177758
177868
  throw new CannotRetryError(error42, retryContext);
177759
177869
  }
177760
177870
  const handledCloudAuthError = handleAwsCredentialError(error42) || handleGcpCredentialError(error42);
177761
- if (!handledCloudAuthError && (!(error42 instanceof APIError) || !shouldRetry(error42))) {
177871
+ if (!handledCloudAuthError && !isRetryableApiFailure(error42)) {
177762
177872
  throw new CannotRetryError(error42, retryContext);
177763
177873
  }
177764
177874
  if (error42 instanceof APIError) {
@@ -177794,6 +177904,9 @@ async function* withRetry(getClient, operation, options2) {
177794
177904
  delayMs = Math.min(getRetryDelay(persistentAttempt, retryAfter, PERSISTENT_MAX_BACKOFF_MS), PERSISTENT_RESET_CAP_MS);
177795
177905
  } else {
177796
177906
  delayMs = getRetryDelay(attempt, retryAfter);
177907
+ if (isTransientProviderRateLimit(error42)) {
177908
+ delayMs = Math.max(delayMs, RATE_LIMIT_MIN_DELAY_MS);
177909
+ }
177797
177910
  }
177798
177911
  const reportedAttempt = persistent ? persistentAttempt : attempt;
177799
177912
  logEvent("tengu_api_retry", {
@@ -177816,9 +177929,7 @@ async function* withRetry(getClient, operation, options2) {
177816
177929
  while (remaining > 0) {
177817
177930
  if (options2.signal?.aborted)
177818
177931
  throw new APIUserAbortError;
177819
- if (error42 instanceof APIError) {
177820
- yield createSystemAPIErrorMessage(error42, remaining, reportedAttempt, maxRetries);
177821
- }
177932
+ yield createSystemAPIErrorMessage(asSystemRetryError(error42), remaining, reportedAttempt, maxRetries);
177822
177933
  const chunk = Math.min(remaining, HEARTBEAT_INTERVAL_MS);
177823
177934
  await sleep2(chunk, options2.signal, { abortError });
177824
177935
  remaining -= chunk;
@@ -177826,9 +177937,7 @@ async function* withRetry(getClient, operation, options2) {
177826
177937
  if (attempt >= maxRetries)
177827
177938
  attempt = maxRetries;
177828
177939
  } else {
177829
- if (error42 instanceof APIError) {
177830
- yield createSystemAPIErrorMessage(error42, delayMs, attempt, maxRetries);
177831
- }
177940
+ yield createSystemAPIErrorMessage(asSystemRetryError(error42), delayMs, attempt, maxRetries);
177832
177941
  await sleep2(delayMs, options2.signal, { abortError });
177833
177942
  }
177834
177943
  }
@@ -177963,6 +178072,8 @@ function shouldRetry(error42) {
177963
178072
  if (error42.status === 409)
177964
178073
  return true;
177965
178074
  if (error42.status === 429) {
178075
+ if (isTransientProviderRateLimit(error42))
178076
+ return true;
177966
178077
  return !isMaximoAISubscriber() || isEnterpriseSubscriber();
177967
178078
  }
177968
178079
  if (error42.status === 401) {
@@ -178007,7 +178118,7 @@ function getRateLimitResetDelayMs(error42) {
178007
178118
  return null;
178008
178119
  return Math.min(delayMs, PERSISTENT_RESET_CAP_MS);
178009
178120
  }
178010
- var abortError = () => new APIUserAbortError, DEFAULT_MAX_RETRIES = 10, FLOOR_OUTPUT_TOKENS = 3000, MAX_529_RETRIES = 3, BASE_DELAY_MS = 500, FOREGROUND_529_RETRY_SOURCES, PERSISTENT_MAX_BACKOFF_MS, PERSISTENT_RESET_CAP_MS, HEARTBEAT_INTERVAL_MS = 30000, CannotRetryError, FallbackTriggeredError, DEFAULT_FAST_MODE_FALLBACK_HOLD_MS, SHORT_RETRY_THRESHOLD_MS, MIN_COOLDOWN_MS;
178121
+ var abortError = () => new APIUserAbortError, DEFAULT_MAX_RETRIES = 10, FLOOR_OUTPUT_TOKENS = 3000, MAX_529_RETRIES = 3, BASE_DELAY_MS = 500, FOREGROUND_529_RETRY_SOURCES, PERSISTENT_MAX_BACKOFF_MS, PERSISTENT_RESET_CAP_MS, HEARTBEAT_INTERVAL_MS = 30000, RATE_LIMIT_MIN_DELAY_MS = 2000, CannotRetryError, FallbackTriggeredError, DEFAULT_FAST_MODE_FALLBACK_HOLD_MS, SHORT_RETRY_THRESHOLD_MS, MIN_COOLDOWN_MS;
178011
178122
  var init_withRetry = __esm(() => {
178012
178123
  init_sdk();
178013
178124
  init_aws();
@@ -274587,6 +274698,7 @@ async function performLogout({
274587
274698
  updated.openAIProvider = undefined;
274588
274699
  updated.mytabulonDefaultModel = undefined;
274589
274700
  updated.mytabulonAccount = undefined;
274701
+ updated.maximoAccount = undefined;
274590
274702
  updated.openCodePlan = undefined;
274591
274703
  updated.cencoriApiKey = undefined;
274592
274704
  updated.openAIModel = undefined;
@@ -276785,7 +276897,7 @@ import { access as access3, writeFile as writeFile13 } from "fs/promises";
276785
276897
  import { homedir as homedir22 } from "os";
276786
276898
  import { join as join65 } from "path";
276787
276899
  function getCurrentRealVersion() {
276788
- return "0.1.38";
276900
+ return "0.1.40";
276789
276901
  }
276790
276902
  async function getRolloutConfig() {
276791
276903
  try {
@@ -278191,6 +278303,8 @@ async function installOAuthTokens(tokens) {
278191
278303
  emailAddress: profile.account.email,
278192
278304
  organizationUuid: profile.organization.uuid,
278193
278305
  displayName: profile.account.display_name || undefined,
278306
+ username: profile.account.username || undefined,
278307
+ profilePhotoUrl: profile.account.profile_photo_url || undefined,
278194
278308
  hasExtraUsageEnabled: profile.organization.has_extra_usage_enabled ?? undefined,
278195
278309
  billingType: profile.organization.billing_type ?? undefined,
278196
278310
  subscriptionCreatedAt: profile.organization.subscription_created_at ?? undefined,
@@ -366618,6 +366732,65 @@ async function* queryLoop(params, consumedCommandUuids) {
366618
366732
  });
366619
366733
  return { reason: "max_turns", turnCount: nextTurnCount };
366620
366734
  }
366735
+ const inTurnCandidate = [...messagesForQuery, ...assistantMessages, ...toolResults];
366736
+ const mainThreadNoAgent = !toolUseContext.agentId && !querySource.startsWith("agent:");
366737
+ if (mainThreadNoAgent && !toolUseContext.abortController.signal.aborted && !shouldPreventContinuation && isAutoCompactEnabled() && tokenCountWithEstimation(inTurnCandidate) - snipTokensFreed >= getAutoCompactThreshold(toolUseContext.options.mainLoopModel) + IN_TURN_COMPACT_SAFETY_MARGIN_TOKENS) {
366738
+ queryCheckpoint("query_in_turn_autocompact_start");
366739
+ const { compactionResult: inTurnResult, consecutiveFailures: inTurnFailures } = await deps.autocompact(inTurnCandidate, toolUseContext, {
366740
+ systemPrompt,
366741
+ userContext,
366742
+ systemContext,
366743
+ toolUseContext,
366744
+ forkContextMessages: inTurnCandidate
366745
+ }, querySource, tracking, snipTokensFreed);
366746
+ queryCheckpoint("query_in_turn_autocompact_end");
366747
+ if (inTurnResult) {
366748
+ logEvent("tengu_auto_compact_succeeded", {
366749
+ originalMessageCount: inTurnCandidate.length,
366750
+ compactedMessageCount: inTurnResult.summaryMessages.length + inTurnResult.attachments.length + inTurnResult.hookResults.length + (inTurnResult.messagesToKeep?.length ?? 0),
366751
+ preCompactTokenCount: inTurnResult.preCompactTokenCount,
366752
+ postCompactTokenCount: inTurnResult.postCompactTokenCount,
366753
+ truePostCompactTokenCount: inTurnResult.truePostCompactTokenCount,
366754
+ compactionInputTokens: inTurnResult.compactionUsage?.input_tokens,
366755
+ compactionOutputTokens: inTurnResult.compactionUsage?.output_tokens,
366756
+ compactionCacheReadTokens: inTurnResult.compactionUsage?.cache_read_input_tokens ?? 0,
366757
+ compactionCacheCreationTokens: inTurnResult.compactionUsage?.cache_creation_input_tokens ?? 0,
366758
+ compactionTotalTokens: inTurnResult.compactionUsage ? inTurnResult.compactionUsage.input_tokens + (inTurnResult.compactionUsage.cache_creation_input_tokens ?? 0) + (inTurnResult.compactionUsage.cache_read_input_tokens ?? 0) + inTurnResult.compactionUsage.output_tokens : 0,
366759
+ queryChainId: queryChainIdForAnalytics,
366760
+ queryDepth: queryTracking.depth,
366761
+ midTurn: true
366762
+ });
366763
+ tracking = {
366764
+ compacted: true,
366765
+ turnId: deps.uuid(),
366766
+ turnCounter: 0,
366767
+ consecutiveFailures: 0
366768
+ };
366769
+ const postCompactMessages = buildPostCompactMessages(inTurnResult);
366770
+ for (const message of postCompactMessages) {
366771
+ yield message;
366772
+ }
366773
+ toolResults.length = 0;
366774
+ state = {
366775
+ messages: postCompactMessages,
366776
+ toolUseContext: { ...updatedToolUseContext, queryTracking },
366777
+ autoCompactTracking: tracking,
366778
+ turnCount: nextTurnCount,
366779
+ maxOutputTokensRecoveryCount: 0,
366780
+ hasAttemptedReactiveCompact: false,
366781
+ pendingToolUseSummary: nextPendingToolUseSummary,
366782
+ maxOutputTokensOverride: undefined,
366783
+ stopHookActive,
366784
+ transition: { reason: "next_turn" }
366785
+ };
366786
+ continue;
366787
+ } else if (inTurnFailures !== undefined) {
366788
+ tracking = {
366789
+ ...tracking ?? { compacted: false, turnId: "", turnCounter: 0 },
366790
+ consecutiveFailures: inTurnFailures
366791
+ };
366792
+ }
366793
+ }
366621
366794
  queryCheckpoint("query_recursive_call");
366622
366795
  const next = {
366623
366796
  messages: [...messagesForQuery, ...assistantMessages, ...toolResults],
@@ -366639,7 +366812,7 @@ async function* queryLoop(params, consumedCommandUuids) {
366639
366812
  __callDispose(__stack, _err, _hasErr);
366640
366813
  }
366641
366814
  }
366642
- var reactiveCompact = null, skillPrefetch = null, MAX_OUTPUT_TOKENS_RECOVERY_LIMIT = 3;
366815
+ var reactiveCompact = null, skillPrefetch = null, IN_TURN_COMPACT_SAFETY_MARGIN_TOKENS = 2000, MAX_OUTPUT_TOKENS_RECOVERY_LIMIT = 3;
366643
366816
  var init_query2 = __esm(() => {
366644
366817
  init_withRetry();
366645
366818
  init_autoCompact();
@@ -366748,7 +366921,7 @@ function getAnthropicEnvMetadata() {
366748
366921
  function getBuildAgeMinutes() {
366749
366922
  if (false)
366750
366923
  ;
366751
- const buildTime = new Date("2026-08-20T22:52:41.981Z").getTime();
366924
+ const buildTime = new Date("2026-08-30T20:30:34.525Z").getTime();
366752
366925
  if (isNaN(buildTime))
366753
366926
  return;
366754
366927
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -367842,6 +368015,68 @@ Please provide your summary following this structure, ensuring precision and tho
367842
368015
  REMINDER: Do NOT call any tools. Respond with plain text only — ` + "an <analysis> block followed by a <summary> block. " + "Tool calls will be rejected and you will fail the task.";
367843
368016
  });
367844
368017
 
368018
+ // src/services/compact/turnSlicing.ts
368019
+ function isRealUserPrompt(message) {
368020
+ if (message.type !== "user") {
368021
+ return false;
368022
+ }
368023
+ if (message.isMeta || message.isCompactSummary || message.isVisibleInTranscriptOnly || message.isVirtual) {
368024
+ return false;
368025
+ }
368026
+ const content = message.message.content;
368027
+ if (typeof content === "string") {
368028
+ return true;
368029
+ }
368030
+ return Array.isArray(content) && !content.some((block2) => block2.type === "tool_result");
368031
+ }
368032
+ function turnContainsUnansweredMedia(messages) {
368033
+ let sawAssistant = false;
368034
+ for (const message of messages) {
368035
+ if (message.type === "assistant") {
368036
+ sawAssistant = true;
368037
+ continue;
368038
+ }
368039
+ if (!sawAssistant || message.type !== "user" || typeof message.message.content === "string") {
368040
+ continue;
368041
+ }
368042
+ const hasMedia = message.message.content.some((block2) => block2?.type === "image" || block2?.type === "document");
368043
+ if (hasMedia) {
368044
+ return true;
368045
+ }
368046
+ }
368047
+ return false;
368048
+ }
368049
+ function selectTailTurns(messages, keepTurns = 3) {
368050
+ const groups = [];
368051
+ let current2 = [];
368052
+ for (const message of messages) {
368053
+ if (isRealUserPrompt(message) && current2.length > 0) {
368054
+ groups.push(current2);
368055
+ current2 = [message];
368056
+ } else {
368057
+ current2.push(message);
368058
+ }
368059
+ }
368060
+ if (current2.length > 0) {
368061
+ groups.push(current2);
368062
+ }
368063
+ if (groups.length < 2) {
368064
+ return { kept: [], summarizedCount: messages.length };
368065
+ }
368066
+ const keepGroupCount = Math.min(keepTurns, groups.length - 1);
368067
+ const keptGroups = groups.slice(groups.length - keepGroupCount);
368068
+ const summarizedGroups = groups.slice(0, groups.length - keepGroupCount);
368069
+ const kept = keptGroups.flat();
368070
+ const summarizedCount = summarizedGroups.reduce((sum, group) => sum + group.length, 0);
368071
+ if (summarizedCount < 1 || kept.length > messages.length * 0.6) {
368072
+ return { kept: [], summarizedCount: messages.length };
368073
+ }
368074
+ if (turnContainsUnansweredMedia(kept)) {
368075
+ return { kept: [], summarizedCount: messages.length };
368076
+ }
368077
+ return { kept, summarizedCount };
368078
+ }
368079
+
367845
368080
  // src/services/compact/compact.ts
367846
368081
  function stripImagesFromMessages(messages) {
367847
368082
  return messages.map((message) => {
@@ -368092,19 +368327,24 @@ async function compactConversation(messages, context6, cacheSafeParams, suppress
368092
368327
  ].sort();
368093
368328
  }
368094
368329
  const transcriptPath = getTranscriptPath();
368330
+ const { kept: keptTail } = selectTailTurns(messages);
368095
368331
  const summaryMessages = [
368096
368332
  createUserMessage({
368097
- content: getCompactUserSummaryMessage(summary, suppressFollowUpQuestions, transcriptPath),
368333
+ content: getCompactUserSummaryMessage(summary, suppressFollowUpQuestions, transcriptPath, keptTail.length > 0),
368098
368334
  isCompactSummary: true,
368099
368335
  isVisibleInTranscriptOnly: true
368100
368336
  })
368101
368337
  ];
368338
+ if (keptTail.length > 0) {
368339
+ boundaryMarker.compactMetadata = annotateBoundaryWithPreservedSegment(boundaryMarker, summaryMessages.at(-1).uuid, keptTail).compactMetadata;
368340
+ }
368102
368341
  const compactionCallTotalTokens = tokenCountFromLastAPIResponse([
368103
368342
  summaryResponse
368104
368343
  ]);
368105
368344
  const truePostCompactTokenCount = roughTokenCountEstimationForMessages([
368106
368345
  boundaryMarker,
368107
368346
  ...summaryMessages,
368347
+ ...keptTail,
368108
368348
  ...postCompactFileAttachments,
368109
368349
  ...hookMessages
368110
368350
  ]);
@@ -368158,6 +368398,7 @@ async function compactConversation(messages, context6, cacheSafeParams, suppress
368158
368398
  return {
368159
368399
  boundaryMarker,
368160
368400
  summaryMessages,
368401
+ messagesToKeep: keptTail.length > 0 ? keptTail : undefined,
368161
368402
  attachments: postCompactFileAttachments,
368162
368403
  hookResults: hookMessages,
368163
368404
  userDisplayMessage: combinedUserDisplayMessage || undefined,
@@ -369293,9 +369534,24 @@ function getEffectiveContextWindowSize(model) {
369293
369534
  const reservedTokensForSummary = getCompactSummaryMaxOutputTokensForModel(model, contextWindow);
369294
369535
  return Math.max(0, contextWindow - reservedTokensForSummary);
369295
369536
  }
369296
- function usesMaximoModelLimits(model) {
369297
- const limits = getCachedMaximoModelLimits(model);
369298
- return Boolean(limits?.contextWindow && limits.maxOutputTokens);
369537
+ function clampAutoCompactPercent(value) {
369538
+ if (!Number.isFinite(value))
369539
+ return AUTOCOMPACT_DEFAULT_PERCENT;
369540
+ return Math.min(AUTOCOMPACT_MAX_PERCENT, Math.max(AUTOCOMPACT_MIN_PERCENT, Math.floor(value)));
369541
+ }
369542
+ function getAutoCompactPercent() {
369543
+ const envPercent = process.env.MAXIMO_SYNTAX_AUTOCOMPACT_PCT;
369544
+ if (envPercent) {
369545
+ const parsed = parseFloat(envPercent);
369546
+ if (!isNaN(parsed) && parsed > 0 && parsed <= 100) {
369547
+ return clampAutoCompactPercent(parsed);
369548
+ }
369549
+ }
369550
+ const configured = getGlobalConfig().autoCompactPercent;
369551
+ if (typeof configured === "number") {
369552
+ return clampAutoCompactPercent(configured);
369553
+ }
369554
+ return AUTOCOMPACT_DEFAULT_PERCENT;
369299
369555
  }
369300
369556
  function getMaximoOutputRatio(model) {
369301
369557
  const limits = getCachedMaximoModelLimits(model);
@@ -369312,17 +369568,15 @@ function getThresholdBufferTokens(model, threshold, fallback) {
369312
369568
  return Math.floor(Math.min(threshold, threshold * outputRatio));
369313
369569
  }
369314
369570
  function getAutoCompactThreshold(model) {
369315
- const effectiveContextWindow = getEffectiveContextWindowSize(model);
369316
- const autocompactThreshold = usesMaximoModelLimits(model) ? effectiveContextWindow : effectiveContextWindow - AUTOCOMPACT_BUFFER_TOKENS;
369317
- const envPercent = process.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE;
369318
- if (envPercent) {
369319
- const parsed = parseFloat(envPercent);
369320
- if (!isNaN(parsed) && parsed > 0 && parsed <= 100) {
369321
- const percentageThreshold = Math.floor(effectiveContextWindow * (parsed / 100));
369322
- return Math.min(percentageThreshold, autocompactThreshold);
369571
+ let contextWindow = getContextWindowForModel(model, getSdkBetas());
369572
+ const autoCompactWindow = process.env.MAXIMO_SYNTAX_AUTO_COMPACT_WINDOW;
369573
+ if (autoCompactWindow) {
369574
+ const parsed = parseInt(autoCompactWindow, 10);
369575
+ if (!isNaN(parsed) && parsed > 0) {
369576
+ contextWindow = Math.min(contextWindow, parsed);
369323
369577
  }
369324
369578
  }
369325
- return Math.max(0, autocompactThreshold);
369579
+ return Math.max(0, Math.floor(contextWindow * (getAutoCompactPercent() / 100)));
369326
369580
  }
369327
369581
  function calculateTokenWarningState(tokenUsage, model) {
369328
369582
  const autoCompactThreshold = getAutoCompactThreshold(model);
@@ -369418,6 +369672,10 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
369418
369672
  return { wasCompacted: false };
369419
369673
  }
369420
369674
  const model = toolUseContext.options.mainLoopModel;
369675
+ if (skipInitialAutoCompact) {
369676
+ skipInitialAutoCompact = false;
369677
+ return { wasCompacted: false };
369678
+ }
369421
369679
  const shouldCompact = await shouldAutoCompact(messages, model, querySource, snipTokensFreed);
369422
369680
  if (!shouldCompact) {
369423
369681
  return { wasCompacted: false };
@@ -369429,16 +369687,18 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
369429
369687
  autoCompactThreshold: getAutoCompactThreshold(model),
369430
369688
  querySource
369431
369689
  };
369432
- const sessionMemoryResult = await trySessionMemoryCompaction(messages, toolUseContext.agentId, recompactionInfo.autoCompactThreshold);
369433
- if (sessionMemoryResult) {
369434
- setLastSummarizedMessageId(undefined);
369435
- runPostCompactCleanup(querySource);
369436
- if (false) {}
369437
- markPostCompaction();
369438
- return {
369439
- wasCompacted: true,
369440
- compactionResult: sessionMemoryResult
369441
- };
369690
+ if (!isEnvTruthy(process.env.MAXIMO_SYNTAX_DISABLE_KEEP_TAIL_COMPACT)) {
369691
+ const sessionMemoryResult = await trySessionMemoryCompaction(messages, toolUseContext.agentId, recompactionInfo.autoCompactThreshold);
369692
+ if (sessionMemoryResult) {
369693
+ setLastSummarizedMessageId(undefined);
369694
+ runPostCompactCleanup(querySource);
369695
+ if (false) {}
369696
+ markPostCompaction();
369697
+ return {
369698
+ wasCompacted: true,
369699
+ compactionResult: sessionMemoryResult
369700
+ };
369701
+ }
369442
369702
  }
369443
369703
  try {
369444
369704
  const compactionResult = await compactConversation(messages, toolUseContext, cacheSafeParams, true, undefined, true, recompactionInfo);
@@ -369461,7 +369721,7 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
369461
369721
  return { wasCompacted: false, consecutiveFailures: nextFailures };
369462
369722
  }
369463
369723
  }
369464
- var AUTOCOMPACT_BUFFER_TOKENS = 13000, WARNING_THRESHOLD_BUFFER_TOKENS = 20000, ERROR_THRESHOLD_BUFFER_TOKENS = 20000, MANUAL_COMPACT_BUFFER_TOKENS = 3000, MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3;
369724
+ var AUTOCOMPACT_DEFAULT_PERCENT = 40, AUTOCOMPACT_MIN_PERCENT = 10, AUTOCOMPACT_MAX_PERCENT = 70, WARNING_THRESHOLD_BUFFER_TOKENS = 20000, ERROR_THRESHOLD_BUFFER_TOKENS = 20000, MANUAL_COMPACT_BUFFER_TOKENS = 3000, MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3, skipInitialAutoCompact;
369465
369725
  var init_autoCompact = __esm(() => {
369466
369726
  init_state();
369467
369727
  init_state();
@@ -369479,6 +369739,7 @@ var init_autoCompact = __esm(() => {
369479
369739
  init_compact();
369480
369740
  init_postCompactCleanup();
369481
369741
  init_sessionMemoryCompact();
369742
+ skipInitialAutoCompact = isEnvTruthy(process.env.MAXIMO_SYNTAX_SKIP_FIRST_AUTOCOMPACT);
369482
369743
  });
369483
369744
 
369484
369745
  // src/utils/analyzeContext.ts
@@ -380458,11 +380719,11 @@ function normalizeMessagesForAPI(messages, tools = []) {
380458
380719
  if (!isSyntheticApiErrorMessage(msg)) {
380459
380720
  continue;
380460
380721
  }
380461
- const errorText = Array.isArray(msg.message.content) && msg.message.content[0]?.type === "text" ? msg.message.content[0].text : undefined;
380462
- if (!errorText) {
380722
+ const errorText2 = Array.isArray(msg.message.content) && msg.message.content[0]?.type === "text" ? msg.message.content[0].text : undefined;
380723
+ if (!errorText2) {
380463
380724
  continue;
380464
380725
  }
380465
- const blockTypesToStrip = errorToBlockTypes[errorText];
380726
+ const blockTypesToStrip = errorToBlockTypes[errorText2];
380466
380727
  if (!blockTypesToStrip) {
380467
380728
  continue;
380468
380729
  }
@@ -397368,6 +397629,11 @@ var init_autoUpdateSchedulerSetup = __esm(() => {
397368
397629
  });
397369
397630
 
397370
397631
  // src/components/Settings/Config.tsx
397632
+ function clampAutoCompactPercentSetting(value) {
397633
+ if (typeof value !== "number" || !Number.isFinite(value))
397634
+ return 40;
397635
+ return Math.min(70, Math.max(10, Math.round(value)));
397636
+ }
397371
397637
  function Config({
397372
397638
  onClose,
397373
397639
  context: context6,
@@ -397516,6 +397782,24 @@ function Config({
397516
397782
  });
397517
397783
  }
397518
397784
  },
397785
+ {
397786
+ id: "autoCompactPercent",
397787
+ label: "Auto-compact threshold (% of context)",
397788
+ value: String(clampAutoCompactPercentSetting(globalConfig2.autoCompactPercent)),
397789
+ options: ["10", "20", "30", "40", "50", "60", "70"],
397790
+ type: "enum",
397791
+ onChange(autoCompactPercent) {
397792
+ const percent = Number(autoCompactPercent);
397793
+ saveGlobalConfig((current2) => ({
397794
+ ...current2,
397795
+ autoCompactPercent: percent
397796
+ }));
397797
+ setGlobalConfig({
397798
+ ...getGlobalConfig(),
397799
+ autoCompactPercent: percent
397800
+ });
397801
+ }
397802
+ },
397519
397803
  {
397520
397804
  id: "spinnerTipsEnabled",
397521
397805
  label: "Show tips",
@@ -432826,7 +433110,7 @@ function getRecentActivitySync() {
432826
433110
  return cachedActivity;
432827
433111
  }
432828
433112
  function getLogoDisplayData() {
432829
- const version2 = process.env.DEMO_VERSION ?? "0.1.38" ?? "99.0.0";
433113
+ const version2 = process.env.DEMO_VERSION ?? "0.1.40" ?? "99.0.0";
432830
433114
  const serverUrl = getDirectConnectServerUrl();
432831
433115
  const displayPath = process.env.DEMO_VERSION ? "/code/maximo" : getDisplayPath(getCwd());
432832
433116
  const cwd2 = serverUrl ? `${displayPath} in ${serverUrl.replace(/^https?:\/\//, "")}` : displayPath;
@@ -462291,7 +462575,7 @@ var init_bridge_kick = __esm(() => {
462291
462575
  var call57 = async () => {
462292
462576
  return {
462293
462577
  type: "text",
462294
- value: `${"99.0.0"} (built ${"2026-08-20T22:52:41.981Z"})`
462578
+ value: `${"99.0.0"} (built ${"2026-08-30T20:30:34.525Z"})`
462295
462579
  };
462296
462580
  }, version2, version_default;
462297
462581
  var init_version = __esm(() => {
@@ -536824,7 +537108,7 @@ function SetupRow({ children }) {
536824
537108
  }
536825
537109
  function WelcomeV2() {
536826
537110
  const { columns } = useTerminalSize();
536827
- const version3 = "0.1.38";
537111
+ const version3 = "0.1.40";
536828
537112
  const width = Math.max(48, Math.min(columns || 92, 92));
536829
537113
  const stacked = width < OCTOPUS_COMPACT_WIDTH + 42;
536830
537114
  return /* @__PURE__ */ jsx_runtime479.jsx(ThemedBox_default, {
@@ -552830,14 +553114,14 @@ async function startMCPServer(cwd3, debug2, verbose) {
552830
553114
  } catch (error42) {
552831
553115
  logError2(error42);
552832
553116
  const parts = error42 instanceof Error ? getErrorParts(error42) : [String(error42)];
552833
- const errorText = parts.filter(Boolean).join(`
553117
+ const errorText2 = parts.filter(Boolean).join(`
552834
553118
  `).trim() || "Error";
552835
553119
  return {
552836
553120
  isError: true,
552837
553121
  content: [
552838
553122
  {
552839
553123
  type: "text",
552840
- text: errorText
553124
+ text: errorText2
552841
553125
  }
552842
553126
  ]
552843
553127
  };
@@ -556760,7 +557044,7 @@ Usage: maximo --remote "your task description"`, () => gracefulShutdown(1));
556760
557044
  pendingHookMessages
556761
557045
  }, renderAndRun);
556762
557046
  }
556763
- }).version("0.1.38 (Maximo Syntax)", "-v, --version", "Output the version number");
557047
+ }).version("0.1.40 (Maximo Syntax)", "-v, --version", "Output the version number");
556764
557048
  program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
556765
557049
  program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
556766
557050
  if (canUserConfigureAdvisor()) {
@@ -557299,7 +557583,7 @@ function validateProviderEnvOrExit() {
557299
557583
  async function main2() {
557300
557584
  const args = process.argv.slice(2);
557301
557585
  if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
557302
- console.log(`${"0.1.38"} (Maximo Syntax)`);
557586
+ console.log(`${"0.1.40"} (Maximo Syntax)`);
557303
557587
  return;
557304
557588
  }
557305
557589
  validateProviderEnvOrExit();
@@ -557376,4 +557660,4 @@ async function main2() {
557376
557660
  }
557377
557661
  main2();
557378
557662
 
557379
- //# debugId=E6A3D8375CCFC23E64756E2164756E21
557663
+ //# debugId=B2B7B0786EC5C8EB64756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maximoai/maximo-syntax-cli",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "Maximo Syntax CLI - A powerful AI-powered command-line interface for code development with any LLM",
5
5
  "type": "module",
6
6
  "bin": {