@maximoai/maximo-syntax-cli 0.1.41 → 0.1.43

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 +425 -298
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -54629,7 +54629,7 @@ function buildHookSchemas() {
54629
54629
  prompt: exports_external.string().describe("Prompt to evaluate with LLM. Use $ARGUMENTS placeholder for hook input JSON."),
54630
54630
  if: IfConditionSchema(),
54631
54631
  timeout: exports_external.number().positive().optional().describe("Timeout in seconds for this specific prompt evaluation"),
54632
- model: exports_external.string().optional().describe('Model to use for this prompt hook (e.g., "maximo-pandora-3.8-nano"). If not specified, uses the active provider default.'),
54632
+ model: exports_external.string().optional().describe('Model to use for this prompt hook (e.g., "maximo-pandora-3.9-nano"). If not specified, uses the active provider default.'),
54633
54633
  statusMessage: exports_external.string().optional().describe("Custom status message to display in spinner while hook runs"),
54634
54634
  once: exports_external.boolean().optional().describe("If true, hook runs once and is removed after execution")
54635
54635
  });
@@ -54648,7 +54648,7 @@ function buildHookSchemas() {
54648
54648
  prompt: exports_external.string().describe('Prompt describing what to verify (e.g. "Verify that unit tests ran and passed."). Use $ARGUMENTS placeholder for hook input JSON.'),
54649
54649
  if: IfConditionSchema(),
54650
54650
  timeout: exports_external.number().positive().optional().describe("Timeout in seconds for agent execution (default 60)"),
54651
- model: exports_external.string().optional().describe('Model to use for this agent hook (e.g., "maximo-pandora-3.8-nano"). If not specified, uses the active provider default.'),
54651
+ model: exports_external.string().optional().describe('Model to use for this agent hook (e.g., "maximo-pandora-3.9-nano"). If not specified, uses the active provider default.'),
54652
54652
  statusMessage: exports_external.string().optional().describe("Custom status message to display in spinner while hook runs"),
54653
54653
  once: exports_external.boolean().optional().describe("If true, hook runs once and is removed after execution")
54654
54654
  });
@@ -108443,12 +108443,16 @@ function normalizeRetiredMytabulonModel(value) {
108443
108443
  function chooseMytabulonDefaultModel(modelIds) {
108444
108444
  return modelIds.find((id) => id === MYTABULON_DEFAULT_MODEL) ?? modelIds.find((id) => !RETIRED_MYTABULON_MODEL_SET.has(id)) ?? MYTABULON_DEFAULT_MODEL;
108445
108445
  }
108446
- var MYTABULON_DEFAULT_MODEL = "maximo-atlas-1.2", RETIRED_MYTABULON_MODELS, RETIRED_MYTABULON_MODEL_SET;
108446
+ var MYTABULON_DEFAULT_MODEL = "maximo-atlas-1.4", RETIRED_MYTABULON_MODELS, RETIRED_MYTABULON_MODEL_SET;
108447
108447
  var init_modelDefaults = __esm(() => {
108448
108448
  RETIRED_MYTABULON_MODELS = [
108449
108449
  "maximo-atlas-preview",
108450
108450
  "maximo-atlas-1.1",
108451
- "atlas-1.1"
108451
+ "atlas-1.1",
108452
+ "maximo-atlas-1.2",
108453
+ "atlas-1.2",
108454
+ "maximo-atlas-1.3",
108455
+ "atlas-1.3"
108452
108456
  ];
108453
108457
  RETIRED_MYTABULON_MODEL_SET = new Set(RETIRED_MYTABULON_MODELS);
108454
108458
  });
@@ -109731,7 +109735,7 @@ function getOpenAIProviderDefaultModel(fallback) {
109731
109735
  return normalizeRetiredMytabulonModel(globalConfig2.mytabulonDefaultModel) || MYTABULON_DEFAULT_MODEL;
109732
109736
  }
109733
109737
  if (baseUrl.includes("maximoai.co")) {
109734
- return "maximo-pandora-3.8-nano";
109738
+ return "maximo-pandora-3.9-nano";
109735
109739
  }
109736
109740
  if (baseUrl.includes("openrouter.ai/api/v1")) {
109737
109741
  return globalConfig2.openAIModel || "openai/gpt-5.4";
@@ -109857,12 +109861,21 @@ function getDefaultMainLoopModel() {
109857
109861
  }
109858
109862
  function firstPartyNameToCanonical(name) {
109859
109863
  name = name.toLowerCase();
109864
+ if (name.includes("maximo-pandora-3.9-nano")) {
109865
+ return "maximo-pandora-3.9-nano";
109866
+ }
109860
109867
  if (name.includes("maximo-pandora-3.8-nano")) {
109861
109868
  return "maximo-pandora-3.8-nano";
109862
109869
  }
109863
109870
  if (name.includes("maximo-pandora-3.7-nano")) {
109864
109871
  return "maximo-pandora-3.7-nano";
109865
109872
  }
109873
+ if (name.includes("maximo-atlas-1.4")) {
109874
+ return "maximo-atlas-1.4";
109875
+ }
109876
+ if (name.includes("maximo-atlas-1.3")) {
109877
+ return "maximo-atlas-1.3";
109878
+ }
109866
109879
  if (name.includes("maximo-atlas-1.2")) {
109867
109880
  return "maximo-atlas-1.2";
109868
109881
  }
@@ -109946,14 +109959,14 @@ function getMaximoAiUserDefaultModelDescription(fastMode = false) {
109946
109959
  const nanoModel = cachedOptions.find((opt) => opt.label.toLowerCase().includes("nano") || String(opt.value || "").toLowerCase().includes("nano")) || cachedOptions[cachedOptions.length - 1];
109947
109960
  return `${nanoModel.label} · Fast & efficient`;
109948
109961
  }
109949
- const defaultModel = getOpenAIProviderDefaultModel(String(cachedOptions[0].value || "maximo-pandora-3.8-nano"));
109962
+ const defaultModel = getOpenAIProviderDefaultModel(String(cachedOptions[0].value || "maximo-pandora-3.9-nano"));
109950
109963
  const preferredModel = cachedOptions.find((option) => option.value === defaultModel) || cachedOptions[0];
109951
109964
  return `${preferredModel.label} · Optimized for coding`;
109952
109965
  }
109953
109966
  if (fastMode) {
109954
- return "Pandora 3.8 Nano · Fast & efficient";
109967
+ return "Pandora 3.9 Nano · Fast & efficient";
109955
109968
  }
109956
- return getOpenAIProviderDefaultModel("maximo-pandora-3.8-nano") === MYTABULON_DEFAULT_MODEL ? "Atlas 1.2 · Included with MyTabulon Coding Plan" : "Pandora 3.8 Nano · Optimized for coding";
109969
+ return getOpenAIProviderDefaultModel("maximo-pandora-3.9-nano") === MYTABULON_DEFAULT_MODEL ? "Atlas 1.4 · Included with MyTabulon Coding Plan" : "Pandora 3.9 Nano · Optimized for coding";
109957
109970
  }
109958
109971
  if (isMaxSubscriber() || isTeamPremiumSubscriber()) {
109959
109972
  if (isOpus1mMergeEnabled()) {
@@ -124077,7 +124090,7 @@ var init_metadata = __esm(() => {
124077
124090
  isMaximoAiAuth: isMaximoAISubscriber(),
124078
124091
  version: "99.0.0",
124079
124092
  versionBase: getVersionBase(),
124080
- buildTime: "2026-09-02T17:58:47.476Z",
124093
+ buildTime: "2026-09-22T00:55:47.019Z",
124081
124094
  deploymentEnvironment: env3.detectDeploymentEnvironment(),
124082
124095
  ...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
124083
124096
  githubEventName: process.env.GITHUB_EVENT_NAME,
@@ -170182,8 +170195,8 @@ How to use the statusLine command:
170182
170195
  "transcript_path": "string", // Path to the conversation transcript
170183
170196
  "cwd": "string", // Current working directory
170184
170197
  "model": {
170185
- "id": "string", // Model ID (e.g., "maximo-pandora-3.8-nano")
170186
- "display_name": "string" // Display name (e.g., "Pandora 3.8 Nano")
170198
+ "id": "string", // Model ID (e.g., "maximo-pandora-3.9-nano")
170199
+ "display_name": "string" // Display name (e.g., "Pandora 3.9 Nano")
170187
170200
  },
170188
170201
  "workspace": {
170189
170202
  "current_dir": "string", // Current working directory path
@@ -176897,12 +176910,37 @@ function getAssistantMessageContentLength(message) {
176897
176910
  }
176898
176911
  return contentLength;
176899
176912
  }
176913
+ function isUsableTokenUsage(usageCount, messages) {
176914
+ if (usageCount <= 0) {
176915
+ return false;
176916
+ }
176917
+ let compactPreTokens = 0;
176918
+ for (let i3 = messages.length - 1;i3 >= 0; i3--) {
176919
+ const message = messages[i3];
176920
+ if (message && message.type === "system" && "subtype" in message && message.subtype === "compact_boundary" && "compactMetadata" in message) {
176921
+ const preTokens = message.compactMetadata?.preTokens;
176922
+ if (typeof preTokens === "number" && preTokens > 0) {
176923
+ compactPreTokens = preTokens;
176924
+ }
176925
+ break;
176926
+ }
176927
+ }
176928
+ if (compactPreTokens > 0 && usageCount >= compactPreTokens * 0.9) {
176929
+ return false;
176930
+ }
176931
+ return true;
176932
+ }
176900
176933
  function tokenCountWithEstimation(messages) {
176901
176934
  let i3 = messages.length - 1;
176902
176935
  while (i3 >= 0) {
176903
176936
  const message = messages[i3];
176904
176937
  const usage = message ? getTokenUsage(message) : undefined;
176905
176938
  if (message && usage) {
176939
+ const usageCount = getTokenCountFromUsage(usage);
176940
+ if (!isUsableTokenUsage(usageCount, messages)) {
176941
+ i3--;
176942
+ continue;
176943
+ }
176906
176944
  const responseId = getAssistantMessageId(message);
176907
176945
  if (responseId) {
176908
176946
  let j = i3 - 1;
@@ -176917,7 +176955,7 @@ function tokenCountWithEstimation(messages) {
176917
176955
  j--;
176918
176956
  }
176919
176957
  }
176920
- return getTokenCountFromUsage(usage) + roughTokenCountEstimationForMessages(messages.slice(i3 + 1));
176958
+ return usageCount + roughTokenCountEstimationForMessages(messages.slice(i3 + 1));
176921
176959
  }
176922
176960
  i3--;
176923
176961
  }
@@ -276984,7 +277022,7 @@ import { access as access3, writeFile as writeFile13 } from "fs/promises";
276984
277022
  import { homedir as homedir22 } from "os";
276985
277023
  import { join as join65 } from "path";
276986
277024
  function getCurrentRealVersion() {
276987
- return "0.1.41";
277025
+ return "0.1.43";
276988
277026
  }
276989
277027
  async function getRolloutConfig() {
276990
277028
  try {
@@ -278426,7 +278464,7 @@ async function installOAuthTokens(tokens) {
278426
278464
  process.env.MAXIMO_SYNTAX_USE_OPENAI = "true";
278427
278465
  process.env.OPENAI_BASE_URL = "https://api.maximoai.co/v1";
278428
278466
  process.env.OPENAI_API_KEY = tokens.accessToken;
278429
- process.env.OPENAI_MODEL = "maximo-pandora-3.8-nano";
278467
+ process.env.OPENAI_MODEL = "maximo-pandora-3.9-nano";
278430
278468
  } else {
278431
278469
  const apiKey = await createAndStoreApiKey(tokens.accessToken);
278432
278470
  if (!apiKey) {
@@ -282072,7 +282110,7 @@ var init_coreSchemas = __esm(() => {
282072
282110
  tools: exports_external.array(exports_external.string()).optional().describe("Array of allowed tool names. If omitted, inherits all tools from parent"),
282073
282111
  disallowedTools: exports_external.array(exports_external.string()).optional().describe("Array of tool names to explicitly disallow for this agent"),
282074
282112
  prompt: exports_external.string().describe("The agent's system prompt"),
282075
- model: exports_external.string().optional().describe("Model ID from the active provider (e.g. 'maximo-pandora-3.8-nano') or 'inherit'. If omitted or 'inherit', uses the main model"),
282113
+ model: exports_external.string().optional().describe("Model ID from the active provider (e.g. 'maximo-pandora-3.9-nano') or 'inherit'. If omitted or 'inherit', uses the main model"),
282076
282114
  mcpServers: exports_external.array(AgentMcpServerSpecSchema2()).optional(),
282077
282115
  criticalSystemReminder_EXPERIMENTAL: exports_external.string().optional().describe("Experimental: Critical reminder added to system prompt"),
282078
282116
  skills: exports_external.array(exports_external.string()).optional().describe("Array of skill names to preload into the agent context"),
@@ -282282,6 +282320,8 @@ var init_coreSchemas = __esm(() => {
282282
282320
  compact_metadata: exports_external.object({
282283
282321
  trigger: exports_external.enum(["manual", "auto"]),
282284
282322
  pre_tokens: exports_external.number(),
282323
+ post_tokens: exports_external.number().optional(),
282324
+ summary: exports_external.string().optional(),
282285
282325
  preserved_segment: exports_external.object({
282286
282326
  head_uuid: UUIDPlaceholder(),
282287
282327
  anchor_uuid: UUIDPlaceholder(),
@@ -288089,7 +288129,7 @@ function OAuthStatusMessage(t0) {
288089
288129
  process.env.MAXIMO_SYNTAX_USE_OPENAI = "1";
288090
288130
  process.env.OPENAI_API_KEY = apiKey;
288091
288131
  process.env.OPENAI_BASE_URL = "https://api.maximoai.co/v1";
288092
- process.env.OPENAI_MODEL = "maximo-pandora-3.8-nano";
288132
+ process.env.OPENAI_MODEL = "maximo-pandora-3.9-nano";
288093
288133
  const { saveGlobalConfig: saveGlobalConfig2 } = (init_config2(), __toCommonJS(exports_config));
288094
288134
  saveGlobalConfig2((current) => ({
288095
288135
  ...current,
@@ -365393,7 +365433,7 @@ var init_tokenBudget2 = __esm(() => {
365393
365433
  });
365394
365434
 
365395
365435
  // src/services/goal/types.ts
365396
- var GOAL_EVALUATOR_MODEL = "maximo-pandora-3.8-nano", GOAL_CLASSIFIER_MAX_RUNS_DEFAULT = 6, GOAL_EVALUATOR_BLOCKER_STREAK = 3, GOAL_STALL_THRESHOLD = 2, GOAL_EVALUATOR_TIMEOUT_MS = 30000, GOAL_VERIFIER_TIMEOUT_MS = 90000, GOAL_HISTORY_MAX = 64, GOAL_TRANSCRIPT_MAX_CHARS, GOAL_ITEM_MAX_CHARS;
365436
+ var GOAL_EVALUATOR_MODEL = "maximo-pandora-3.9-nano", GOAL_CLASSIFIER_MAX_RUNS_DEFAULT = 6, GOAL_EVALUATOR_BLOCKER_STREAK = 3, GOAL_STALL_THRESHOLD = 2, GOAL_EVALUATOR_TIMEOUT_MS = 30000, GOAL_VERIFIER_TIMEOUT_MS = 90000, GOAL_HISTORY_MAX = 64, GOAL_TRANSCRIPT_MAX_CHARS, GOAL_ITEM_MAX_CHARS;
365397
365437
  var init_types10 = __esm(() => {
365398
365438
  GOAL_TRANSCRIPT_MAX_CHARS = 32 * 1024;
365399
365439
  GOAL_ITEM_MAX_CHARS = 4 * 1024;
@@ -367697,7 +367737,7 @@ function getAnthropicEnvMetadata() {
367697
367737
  function getBuildAgeMinutes() {
367698
367738
  if (false)
367699
367739
  ;
367700
- const buildTime = new Date("2026-09-02T17:58:47.476Z").getTime();
367740
+ const buildTime = new Date("2026-09-22T00:55:47.019Z").getTime();
367701
367741
  if (isNaN(buildTime))
367702
367742
  return;
367703
367743
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -368844,7 +368884,7 @@ function selectTailTurns(messages, keepTurns = 3) {
368844
368884
  const summarizedGroups = groups.slice(0, groups.length - keepGroupCount);
368845
368885
  const kept = keptGroups.flat();
368846
368886
  const summarizedCount = summarizedGroups.reduce((sum, group) => sum + group.length, 0);
368847
- if (summarizedCount < 1 || kept.length > messages.length * 0.6) {
368887
+ if (summarizedCount < 1) {
368848
368888
  return { kept: [], summarizedCount: messages.length };
368849
368889
  }
368850
368890
  if (turnContainsUnansweredMedia(kept)) {
@@ -368949,6 +368989,30 @@ function buildPostCompactMessages(result) {
368949
368989
  ...result.hookResults
368950
368990
  ];
368951
368991
  }
368992
+ function stripStaleUsageFromPreservedMessages(messages) {
368993
+ return messages.map((message) => {
368994
+ if (message.type !== "assistant" || !("usage" in message.message)) {
368995
+ return message;
368996
+ }
368997
+ const usage = message.message.usage;
368998
+ if (!usage) {
368999
+ return message;
369000
+ }
369001
+ return {
369002
+ ...message,
369003
+ message: {
369004
+ ...message.message,
369005
+ usage: {
369006
+ ...usage,
369007
+ input_tokens: 0,
369008
+ output_tokens: 0,
369009
+ cache_creation_input_tokens: 0,
369010
+ cache_read_input_tokens: 0
369011
+ }
369012
+ }
369013
+ };
369014
+ });
369015
+ }
368952
369016
  function annotateBoundaryWithPreservedSegment(boundary, anchorUuid, messagesToKeep) {
368953
369017
  const keep = messagesToKeep ?? [];
368954
369018
  if (keep.length === 0)
@@ -369103,7 +369167,8 @@ async function compactConversation(messages, context7, cacheSafeParams, suppress
369103
369167
  ].sort();
369104
369168
  }
369105
369169
  const transcriptPath = getTranscriptPath();
369106
- const { kept: keptTail } = selectTailTurns(messages);
369170
+ const { kept: rawKeptTail } = selectTailTurns(messages);
369171
+ const keptTail = stripStaleUsageFromPreservedMessages(rawKeptTail);
369107
369172
  const summaryMessages = [
369108
369173
  createUserMessage({
369109
369174
  content: getCompactUserSummaryMessage(summary, suppressFollowUpQuestions, transcriptPath, keptTail.length > 0),
@@ -369114,6 +369179,10 @@ async function compactConversation(messages, context7, cacheSafeParams, suppress
369114
369179
  if (keptTail.length > 0) {
369115
369180
  boundaryMarker.compactMetadata = annotateBoundaryWithPreservedSegment(boundaryMarker, summaryMessages.at(-1).uuid, keptTail).compactMetadata;
369116
369181
  }
369182
+ const compactSummary = formatCompactSummary(summary);
369183
+ if (compactSummary) {
369184
+ boundaryMarker.compactMetadata.compactSummary = compactSummary;
369185
+ }
369117
369186
  const compactionCallTotalTokens = tokenCountFromLastAPIResponse([
369118
369187
  summaryResponse
369119
369188
  ]);
@@ -369124,6 +369193,7 @@ async function compactConversation(messages, context7, cacheSafeParams, suppress
369124
369193
  ...postCompactFileAttachments,
369125
369194
  ...hookMessages
369126
369195
  ]);
369196
+ boundaryMarker.compactMetadata.postTokens = truePostCompactTokenCount;
369127
369197
  const compactionUsage = getTokenUsage(summaryResponse);
369128
369198
  const querySourceForEvent = recompactionInfo?.querySource ?? context7.options.querySource ?? "unknown";
369129
369199
  logEvent("tengu_compact", {
@@ -370240,7 +370310,7 @@ async function trySessionMemoryCompaction(messages, agentId, autoCompactThreshol
370240
370310
  logEvent("tengu_sm_compact_resumed_session", {});
370241
370311
  }
370242
370312
  const startIndex = calculateMessagesToKeepIndex(messages, lastSummarizedIndex);
370243
- const messagesToKeep = messages.slice(startIndex).filter((m) => !isCompactBoundaryMessage(m));
370313
+ const messagesToKeep = stripStaleUsageFromPreservedMessages(messages.slice(startIndex).filter((m) => !isCompactBoundaryMessage(m)));
370244
370314
  const hookResults = await processSessionStartHooks("compact", {
370245
370315
  model: getMainLoopModel()
370246
370316
  });
@@ -370329,6 +370399,9 @@ function getAutoCompactPercent() {
370329
370399
  }
370330
370400
  return AUTOCOMPACT_DEFAULT_PERCENT;
370331
370401
  }
370402
+ function releaseInitialAutoCompactSkip() {
370403
+ autoCompactArmed = true;
370404
+ }
370332
370405
  function getMaximoOutputRatio(model) {
370333
370406
  const limits = getCachedMaximoModelLimits(model);
370334
370407
  if (!limits?.contextWindow || !limits.maxOutputTokens) {
@@ -370433,6 +370506,10 @@ async function shouldAutoCompact(messages, model, querySource, snipTokensFreed =
370433
370506
  }
370434
370507
  if (false) {}
370435
370508
  if (false) {}
370509
+ if (!autoCompactArmed) {
370510
+ logForDebugging2("autocompact: skipping until the first turn of this process completes");
370511
+ return false;
370512
+ }
370436
370513
  const tokenCount = tokenCountWithEstimation(messages) - snipTokensFreed;
370437
370514
  const threshold = getAutoCompactThreshold(model);
370438
370515
  const effectiveWindow = getEffectiveContextWindowSize(model);
@@ -370448,10 +370525,6 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
370448
370525
  return { wasCompacted: false };
370449
370526
  }
370450
370527
  const model = toolUseContext.options.mainLoopModel;
370451
- if (skipInitialAutoCompact) {
370452
- skipInitialAutoCompact = false;
370453
- return { wasCompacted: false };
370454
- }
370455
370528
  const shouldCompact = await shouldAutoCompact(messages, model, querySource, snipTokensFreed);
370456
370529
  if (!shouldCompact) {
370457
370530
  return { wasCompacted: false };
@@ -370497,7 +370570,7 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
370497
370570
  return { wasCompacted: false, consecutiveFailures: nextFailures };
370498
370571
  }
370499
370572
  }
370500
- 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;
370573
+ 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, autoCompactArmed;
370501
370574
  var init_autoCompact = __esm(() => {
370502
370575
  init_state();
370503
370576
  init_state();
@@ -370515,7 +370588,8 @@ var init_autoCompact = __esm(() => {
370515
370588
  init_compact();
370516
370589
  init_postCompactCleanup();
370517
370590
  init_sessionMemoryCompact();
370518
- skipInitialAutoCompact = isEnvTruthy(process.env.MAXIMO_SYNTAX_SKIP_FIRST_AUTOCOMPACT);
370591
+ skipInitialAutoCompact = isEnvTruthy(process.env.MAXIMO_SYNTAX_SKIP_FIRST_AUTOCOMPACT) || isEnvTruthy(process.env.MAXIMO_SYNTAX_DESKTOP);
370592
+ autoCompactArmed = !skipInitialAutoCompact;
370519
370593
  });
370520
370594
 
370521
370595
  // src/utils/analyzeContext.ts
@@ -383204,6 +383278,29 @@ function getMessagesAfterCompactBoundary(messages, options2) {
383204
383278
  if (!options2?.includeSnipped && false) {}
383205
383279
  return sliced;
383206
383280
  }
383281
+ function hideReplayedCompactTail(messages, isTranscriptMode) {
383282
+ if (isTranscriptMode) {
383283
+ return messages;
383284
+ }
383285
+ const boundaryIndex = findLastCompactBoundaryIndex(messages);
383286
+ if (boundaryIndex === -1) {
383287
+ return messages;
383288
+ }
383289
+ const boundary = messages[boundaryIndex];
383290
+ const boundaryTimestamp = boundary?.timestamp;
383291
+ if (!boundaryTimestamp) {
383292
+ return messages;
383293
+ }
383294
+ return messages.filter((message, index) => {
383295
+ if (index <= boundaryIndex) {
383296
+ return true;
383297
+ }
383298
+ if (message.type === "user" && (message.isCompactSummary || message.isVisibleInTranscriptOnly)) {
383299
+ return false;
383300
+ }
383301
+ return message.timestamp >= boundaryTimestamp;
383302
+ });
383303
+ }
383207
383304
  function shouldShowUserMessage(message, isTranscriptMode) {
383208
383305
  if (message.type !== "user")
383209
383306
  return true;
@@ -405864,7 +405961,7 @@ function Doctor(t0) {
405864
405961
  },
405865
405962
  {
405866
405963
  name: "MAXIMO_SYNTAX_MAX_OUTPUT_TOKENS",
405867
- ...getModelMaxOutputTokens(process.env.OPENAI_MODEL || "maximo-pandora-3.8-nano")
405964
+ ...getModelMaxOutputTokens(process.env.OPENAI_MODEL || "maximo-pandora-3.9-nano")
405868
405965
  }
405869
405966
  ];
405870
405967
  t4 = envVars.map(_temp85).filter(_temp93);
@@ -433885,7 +433982,7 @@ function getRecentActivitySync() {
433885
433982
  return cachedActivity;
433886
433983
  }
433887
433984
  function getLogoDisplayData() {
433888
- const version2 = process.env.DEMO_VERSION ?? "0.1.41" ?? "99.0.0";
433985
+ const version2 = process.env.DEMO_VERSION ?? "0.1.43" ?? "99.0.0";
433889
433986
  const serverUrl = getDirectConnectServerUrl();
433890
433987
  const displayPath = process.env.DEMO_VERSION ? "/code/maximo" : getDisplayPath(getCwd());
433891
433988
  const cwd2 = serverUrl ? `${displayPath} in ${serverUrl.replace(/^https?:\/\//, "")}` : displayPath;
@@ -438802,9 +438899,9 @@ var import_react_compiler_runtime208, React86, import_react160, jsx_runtime266,
438802
438899
  hasTruncatedMessages: hasTruncatedMessages_0,
438803
438900
  hiddenMessageCount: hiddenMessageCount_0
438804
438901
  } = import_react160.useMemo(() => {
438805
- const compactAwareMessages = verbose || isFullscreenEnvEnabled() ? normalizedMessages : getMessagesAfterCompactBoundary(normalizedMessages, {
438902
+ const compactAwareMessages = hideReplayedCompactTail(verbose || isFullscreenEnvEnabled() ? normalizedMessages : getMessagesAfterCompactBoundary(normalizedMessages, {
438806
438903
  includeSnipped: true
438807
- });
438904
+ }), isTranscriptMode);
438808
438905
  const messagesToShowNotTruncated = reorderMessagesInUI(compactAwareMessages.filter((msg_2) => msg_2.type !== "progress").filter((msg_3) => !isNullRenderingAttachment(msg_3)).filter((_) => shouldShowUserMessage(_, isTranscriptMode)), syntheticStreamingToolUseMessages);
438809
438906
  const briefToolNames = [BRIEF_TOOL_NAME4, SEND_USER_FILE_TOOL_NAME2].filter((n2) => n2 !== null);
438810
438907
  const dropTextToolNames = [BRIEF_TOOL_NAME4].filter((n_0) => n_0 !== null);
@@ -446083,6 +446180,7 @@ function toInternalMessages(messages) {
446083
446180
  }
446084
446181
  function toSDKCompactMetadata(meta) {
446085
446182
  const seg = meta.preservedSegment;
446183
+ const extra = meta;
446086
446184
  return {
446087
446185
  trigger: meta.trigger,
446088
446186
  pre_tokens: meta.preTokens,
@@ -446092,7 +446190,9 @@ function toSDKCompactMetadata(meta) {
446092
446190
  anchor_uuid: seg.anchorUuid,
446093
446191
  tail_uuid: seg.tailUuid
446094
446192
  }
446095
- }
446193
+ },
446194
+ ...typeof extra.compactSummary === "string" && extra.compactSummary ? { summary: extra.compactSummary } : {},
446195
+ ...typeof extra.postTokens === "number" ? { post_tokens: extra.postTokens } : {}
446096
446196
  };
446097
446197
  }
446098
446198
  function fromSDKCompactMetadata(meta) {
@@ -463404,7 +463504,7 @@ var init_bridge_kick = __esm(() => {
463404
463504
  var call57 = async () => {
463405
463505
  return {
463406
463506
  type: "text",
463407
- value: `${"99.0.0"} (built ${"2026-09-02T17:58:47.476Z"})`
463507
+ value: `${"99.0.0"} (built ${"2026-09-22T00:55:47.019Z"})`
463408
463508
  };
463409
463509
  }, version2, version_default;
463410
463510
  var init_version = __esm(() => {
@@ -475849,6 +475949,7 @@ function applyPreservedSegmentRelinks(messages) {
475849
475949
  return;
475850
475950
  const segIsLive = lastSegBoundaryIdx === absoluteLastBoundaryIdx;
475851
475951
  const preservedUuids = new Set;
475952
+ let relinkLive = false;
475852
475953
  if (segIsLive) {
475853
475954
  const walkSeen = new Set;
475854
475955
  let cur = messages.get(lastSeg.tailUuid);
@@ -475862,7 +475963,9 @@ function applyPreservedSegmentRelinks(messages) {
475862
475963
  }
475863
475964
  cur = cur.parentUuid ? messages.get(cur.parentUuid) : undefined;
475864
475965
  }
475865
- if (!reachedHead) {
475966
+ if (reachedHead) {
475967
+ relinkLive = true;
475968
+ } else {
475866
475969
  logEvent("tengu_relink_walk_broken", {
475867
475970
  tailInTranscript: messages.has(lastSeg.tailUuid),
475868
475971
  headInTranscript: messages.has(lastSeg.headUuid),
@@ -475870,10 +475973,10 @@ function applyPreservedSegmentRelinks(messages) {
475870
475973
  walkSteps: walkSeen.size,
475871
475974
  transcriptSize: messages.size
475872
475975
  });
475873
- return;
475976
+ preservedUuids.clear();
475874
475977
  }
475875
475978
  }
475876
- if (segIsLive) {
475979
+ if (relinkLive) {
475877
475980
  const head = messages.get(lastSeg.headUuid);
475878
475981
  if (head) {
475879
475982
  messages.set(lastSeg.headUuid, {
@@ -489451,7 +489554,7 @@ function applySafeConfigEnvironmentVariables() {
489451
489554
  } else if (baseUrl.includes("opencode.ai/zen/")) {
489452
489555
  process.env.OPENAI_MODEL = "deepseek-v4-flash";
489453
489556
  } else {
489454
- process.env.OPENAI_MODEL = "maximo-pandora-3.8-nano";
489557
+ process.env.OPENAI_MODEL = "maximo-pandora-3.9-nano";
489455
489558
  }
489456
489559
  }
489457
489560
  }
@@ -539391,7 +539494,7 @@ function SetupRow({ children }) {
539391
539494
  }
539392
539495
  function WelcomeV2() {
539393
539496
  const { columns } = useTerminalSize();
539394
- const version3 = "0.1.41";
539497
+ const version3 = "0.1.43";
539395
539498
  const width = Math.max(48, Math.min(columns || 92, 92));
539396
539499
  const stacked = width < OCTOPUS_COMPACT_WIDTH + 42;
539397
539500
  return /* @__PURE__ */ jsx_runtime479.jsx(ThemedBox_default, {
@@ -548031,6 +548134,20 @@ class QueryEngine {
548031
548134
  readFileState;
548032
548135
  discoveredSkillNames = new Set;
548033
548136
  loadedNestedMemoryPaths = new Set;
548137
+ compactRestoreBoundaryTimestamp;
548138
+ shouldSuppressCompactRestore(message) {
548139
+ if (!this.compactRestoreBoundaryTimestamp) {
548140
+ return false;
548141
+ }
548142
+ if (message.type === "user" && (message.isCompactSummary || message.isVisibleInTranscriptOnly)) {
548143
+ return true;
548144
+ }
548145
+ if (message.timestamp < this.compactRestoreBoundaryTimestamp) {
548146
+ return true;
548147
+ }
548148
+ this.compactRestoreBoundaryTimestamp = undefined;
548149
+ return false;
548150
+ }
548034
548151
  constructor(config3) {
548035
548152
  this.config = config3;
548036
548153
  this.mutableMessages = config3.initialMessages ?? [];
@@ -548069,15 +548186,15 @@ class QueryEngine {
548069
548186
  const persistSession = !isSessionPersistenceDisabled();
548070
548187
  const startTime2 = Date.now();
548071
548188
  const wrappedCanUseTool = async (tool, input, toolUseContext, assistantMessage, toolUseID, forceDecision) => {
548072
- const result2 = await canUseTool(tool, input, toolUseContext, assistantMessage, toolUseID, forceDecision);
548073
- if (result2.behavior !== "allow") {
548189
+ const result = await canUseTool(tool, input, toolUseContext, assistantMessage, toolUseID, forceDecision);
548190
+ if (result.behavior !== "allow") {
548074
548191
  this.permissionDenials.push({
548075
548192
  tool_name: sdkCompatToolName(tool.name),
548076
548193
  tool_use_id: toolUseID,
548077
548194
  tool_input: input
548078
548195
  });
548079
548196
  }
548080
- return result2;
548197
+ return result;
548081
548198
  };
548082
548199
  const initialAppState = getAppState();
548083
548200
  const initialMainLoopModel = userSpecifiedModel ? parseUserSpecifiedModel(userSpecifiedModel) : getMainLoopModel();
@@ -548267,7 +548384,7 @@ class QueryEngine {
548267
548384
  headlessProfilerCheckpoint("system_message_yielded");
548268
548385
  if (!shouldQuery) {
548269
548386
  for (const msg of messagesFromUserInput) {
548270
- if (msg.type === "user" && typeof msg.message.content === "string" && (msg.message.content.includes(`<${LOCAL_COMMAND_STDOUT_TAG}>`) || msg.message.content.includes(`<${LOCAL_COMMAND_STDERR_TAG}>`) || msg.isCompactSummary)) {
548387
+ if (msg.type === "user" && typeof msg.message.content === "string" && (msg.message.content.includes(`<${LOCAL_COMMAND_STDOUT_TAG}>`) || msg.message.content.includes(`<${LOCAL_COMMAND_STDERR_TAG}>`))) {
548271
548388
  yield {
548272
548389
  type: "user",
548273
548390
  message: {
@@ -548278,7 +548395,7 @@ class QueryEngine {
548278
548395
  parent_tool_use_id: null,
548279
548396
  uuid: msg.uuid,
548280
548397
  timestamp: msg.timestamp,
548281
- isReplay: !msg.isCompactSummary,
548398
+ isReplay: true,
548282
548399
  isSynthetic: msg.isMeta || msg.isVisibleInTranscriptOnly
548283
548400
  };
548284
548401
  }
@@ -548337,111 +548454,250 @@ class QueryEngine {
548337
548454
  let lastStopReason = null;
548338
548455
  const errorLogWatermark = getInMemoryErrors().at(-1);
548339
548456
  const initialStructuredOutputCalls = jsonSchema ? countToolCalls(this.mutableMessages, SYNTHETIC_OUTPUT_TOOL_NAME) : 0;
548340
- for await (const message of query({
548341
- messages,
548342
- systemPrompt,
548343
- userContext,
548344
- systemContext,
548345
- canUseTool: wrappedCanUseTool,
548346
- toolUseContext: processUserInputContext,
548347
- fallbackModel,
548348
- querySource: "sdk",
548349
- maxTurns,
548350
- taskBudget
548351
- })) {
548352
- if (message.type === "assistant" || message.type === "user" || message.type === "system" && message.subtype === "compact_boundary") {
548353
- if (persistSession && message.type === "system" && message.subtype === "compact_boundary") {
548354
- const tailUuid = message.compactMetadata?.preservedSegment?.tailUuid;
548355
- if (tailUuid) {
548356
- const tailIdx = this.mutableMessages.findLastIndex((m) => m.uuid === tailUuid);
548357
- if (tailIdx !== -1) {
548358
- await recordTranscript(this.mutableMessages.slice(0, tailIdx + 1));
548457
+ try {
548458
+ for await (const message of query({
548459
+ messages,
548460
+ systemPrompt,
548461
+ userContext,
548462
+ systemContext,
548463
+ canUseTool: wrappedCanUseTool,
548464
+ toolUseContext: processUserInputContext,
548465
+ fallbackModel,
548466
+ querySource: "sdk",
548467
+ maxTurns,
548468
+ taskBudget
548469
+ })) {
548470
+ if (message.type === "assistant" || message.type === "user" || message.type === "system" && message.subtype === "compact_boundary") {
548471
+ if (persistSession && message.type === "system" && message.subtype === "compact_boundary") {
548472
+ const tailUuid = message.compactMetadata?.preservedSegment?.tailUuid;
548473
+ if (tailUuid) {
548474
+ const tailIdx = this.mutableMessages.findLastIndex((m) => m.uuid === tailUuid);
548475
+ if (tailIdx !== -1) {
548476
+ await recordTranscript(this.mutableMessages.slice(0, tailIdx + 1));
548477
+ }
548359
548478
  }
548360
548479
  }
548361
- }
548362
- messages.push(message);
548363
- if (persistSession) {
548364
- if (message.type === "assistant") {
548365
- recordTranscript(messages);
548366
- } else {
548367
- await recordTranscript(messages);
548480
+ messages.push(message);
548481
+ if (persistSession) {
548482
+ if (message.type === "assistant") {
548483
+ recordTranscript(messages);
548484
+ } else {
548485
+ await recordTranscript(messages);
548486
+ }
548368
548487
  }
548488
+ if (!hasAcknowledgedInitialMessages && messagesToAck.length > 0) {
548489
+ hasAcknowledgedInitialMessages = true;
548490
+ for (const msgToAck of messagesToAck) {
548491
+ if (msgToAck.type === "user") {
548492
+ yield {
548493
+ type: "user",
548494
+ message: msgToAck.message,
548495
+ session_id: getSessionId(),
548496
+ parent_tool_use_id: null,
548497
+ uuid: msgToAck.uuid,
548498
+ timestamp: msgToAck.timestamp,
548499
+ isReplay: true
548500
+ };
548501
+ }
548502
+ }
548503
+ }
548504
+ }
548505
+ if (message.type === "user") {
548506
+ turnCount++;
548369
548507
  }
548370
- if (!hasAcknowledgedInitialMessages && messagesToAck.length > 0) {
548371
- hasAcknowledgedInitialMessages = true;
548372
- for (const msgToAck of messagesToAck) {
548373
- if (msgToAck.type === "user") {
548508
+ switch (message.type) {
548509
+ case "tombstone":
548510
+ break;
548511
+ case "assistant":
548512
+ if (message.message.stop_reason != null) {
548513
+ lastStopReason = message.message.stop_reason;
548514
+ }
548515
+ this.mutableMessages.push(message);
548516
+ if (!this.shouldSuppressCompactRestore(message)) {
548517
+ yield* normalizeMessage(message);
548518
+ }
548519
+ break;
548520
+ case "progress":
548521
+ this.mutableMessages.push(message);
548522
+ if (persistSession) {
548523
+ messages.push(message);
548524
+ recordTranscript(messages);
548525
+ }
548526
+ yield* normalizeMessage(message);
548527
+ break;
548528
+ case "user":
548529
+ this.mutableMessages.push(message);
548530
+ if (!this.shouldSuppressCompactRestore(message)) {
548531
+ yield* normalizeMessage(message);
548532
+ }
548533
+ break;
548534
+ case "stream_event":
548535
+ if (message.event.type === "message_start") {
548536
+ currentMessageUsage = EMPTY_USAGE;
548537
+ currentMessageUsage = updateUsage(currentMessageUsage, message.event.message.usage);
548538
+ }
548539
+ if (message.event.type === "message_delta") {
548540
+ currentMessageUsage = updateUsage(currentMessageUsage, message.event.usage);
548541
+ if (message.event.delta.stop_reason != null) {
548542
+ lastStopReason = message.event.delta.stop_reason;
548543
+ }
548544
+ }
548545
+ if (message.event.type === "message_stop") {
548546
+ this.totalUsage = accumulateUsage(this.totalUsage, currentMessageUsage);
548547
+ }
548548
+ if (includePartialMessages) {
548549
+ yield {
548550
+ type: "stream_event",
548551
+ event: message.event,
548552
+ session_id: getSessionId(),
548553
+ parent_tool_use_id: null,
548554
+ uuid: randomUUID51()
548555
+ };
548556
+ }
548557
+ break;
548558
+ case "attachment":
548559
+ this.mutableMessages.push(message);
548560
+ if (persistSession) {
548561
+ messages.push(message);
548562
+ recordTranscript(messages);
548563
+ }
548564
+ if (message.attachment.type === "structured_output") {
548565
+ structuredOutputFromTool = message.attachment.data;
548566
+ } else if (message.attachment.type === "max_turns_reached") {
548567
+ if (persistSession) {
548568
+ if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
548569
+ await flushSessionStorage();
548570
+ }
548571
+ }
548572
+ yield {
548573
+ type: "result",
548574
+ subtype: "error_max_turns",
548575
+ duration_ms: Date.now() - startTime2,
548576
+ duration_api_ms: getTotalAPIDuration(),
548577
+ is_error: true,
548578
+ num_turns: message.attachment.turnCount,
548579
+ stop_reason: lastStopReason,
548580
+ session_id: getSessionId(),
548581
+ total_cost_usd: getTotalCostUSD(),
548582
+ usage: this.totalUsage,
548583
+ modelUsage: getModelUsage(),
548584
+ permission_denials: this.permissionDenials,
548585
+ fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
548586
+ uuid: randomUUID51(),
548587
+ errors: [
548588
+ `Reached maximum number of turns (${message.attachment.maxTurns})`
548589
+ ]
548590
+ };
548591
+ return;
548592
+ } else if (replayUserMessages && message.attachment.type === "queued_command") {
548374
548593
  yield {
548375
548594
  type: "user",
548376
- message: msgToAck.message,
548595
+ message: {
548596
+ role: "user",
548597
+ content: message.attachment.prompt
548598
+ },
548377
548599
  session_id: getSessionId(),
548378
548600
  parent_tool_use_id: null,
548379
- uuid: msgToAck.uuid,
548380
- timestamp: msgToAck.timestamp,
548601
+ uuid: message.attachment.source_uuid || message.uuid,
548602
+ timestamp: message.timestamp,
548381
548603
  isReplay: true
548382
548604
  };
548383
548605
  }
548384
- }
548385
- }
548386
- }
548387
- if (message.type === "user") {
548388
- turnCount++;
548389
- }
548390
- switch (message.type) {
548391
- case "tombstone":
548392
- break;
548393
- case "assistant":
548394
- if (message.message.stop_reason != null) {
548395
- lastStopReason = message.message.stop_reason;
548396
- }
548397
- this.mutableMessages.push(message);
548398
- yield* normalizeMessage(message);
548399
- break;
548400
- case "progress":
548401
- this.mutableMessages.push(message);
548402
- if (persistSession) {
548403
- messages.push(message);
548404
- recordTranscript(messages);
548405
- }
548406
- yield* normalizeMessage(message);
548407
- break;
548408
- case "user":
548409
- this.mutableMessages.push(message);
548410
- yield* normalizeMessage(message);
548411
- break;
548412
- case "stream_event":
548413
- if (message.event.type === "message_start") {
548414
- currentMessageUsage = EMPTY_USAGE;
548415
- currentMessageUsage = updateUsage(currentMessageUsage, message.event.message.usage);
548416
- }
548417
- if (message.event.type === "message_delta") {
548418
- currentMessageUsage = updateUsage(currentMessageUsage, message.event.usage);
548419
- if (message.event.delta.stop_reason != null) {
548420
- lastStopReason = message.event.delta.stop_reason;
548606
+ break;
548607
+ case "stream_request_start":
548608
+ break;
548609
+ case "system": {
548610
+ const snipResult = this.config.snipReplay?.(message, this.mutableMessages);
548611
+ if (snipResult !== undefined) {
548612
+ if (snipResult.executed) {
548613
+ this.mutableMessages.length = 0;
548614
+ this.mutableMessages.push(...snipResult.messages);
548615
+ }
548616
+ break;
548421
548617
  }
548618
+ this.mutableMessages.push(message);
548619
+ if (message.subtype === "compact_boundary" && message.compactMetadata) {
548620
+ const mutableBoundaryIdx = this.mutableMessages.length - 1;
548621
+ if (mutableBoundaryIdx > 0) {
548622
+ this.mutableMessages.splice(0, mutableBoundaryIdx);
548623
+ }
548624
+ const localBoundaryIdx = messages.length - 1;
548625
+ if (localBoundaryIdx > 0) {
548626
+ messages.splice(0, localBoundaryIdx);
548627
+ }
548628
+ this.compactRestoreBoundaryTimestamp = message.timestamp;
548629
+ yield {
548630
+ type: "system",
548631
+ subtype: "compact_boundary",
548632
+ session_id: getSessionId(),
548633
+ uuid: message.uuid,
548634
+ compact_metadata: toSDKCompactMetadata(message.compactMetadata)
548635
+ };
548636
+ }
548637
+ if (message.subtype === "api_error") {
548638
+ yield {
548639
+ type: "system",
548640
+ subtype: "api_retry",
548641
+ attempt: message.retryAttempt,
548642
+ max_retries: message.maxRetries,
548643
+ retry_delay_ms: message.retryInMs,
548644
+ error_status: message.error.status ?? null,
548645
+ error: categorizeRetryableAPIError(message.error),
548646
+ session_id: getSessionId(),
548647
+ uuid: message.uuid
548648
+ };
548649
+ }
548650
+ if (message.subtype === "informational" && typeof message.content === "string" && (message.content.startsWith("Goal ") || message.content.startsWith("Goal:"))) {
548651
+ yield {
548652
+ type: "system",
548653
+ subtype: "status",
548654
+ status: message.content.slice(0, 500),
548655
+ session_id: getSessionId(),
548656
+ uuid: message.uuid
548657
+ };
548658
+ }
548659
+ break;
548422
548660
  }
548423
- if (message.event.type === "message_stop") {
548424
- this.totalUsage = accumulateUsage(this.totalUsage, currentMessageUsage);
548425
- }
548426
- if (includePartialMessages) {
548661
+ case "tool_use_summary":
548427
548662
  yield {
548428
- type: "stream_event",
548429
- event: message.event,
548663
+ type: "tool_use_summary",
548664
+ summary: message.summary,
548665
+ preceding_tool_use_ids: message.precedingToolUseIds,
548430
548666
  session_id: getSessionId(),
548431
- parent_tool_use_id: null,
548432
- uuid: randomUUID51()
548667
+ uuid: message.uuid
548433
548668
  };
548434
- }
548435
- break;
548436
- case "attachment":
548437
- this.mutableMessages.push(message);
548669
+ break;
548670
+ }
548671
+ if (maxBudgetUsd !== undefined && getTotalCostUSD() >= maxBudgetUsd) {
548438
548672
  if (persistSession) {
548439
- messages.push(message);
548440
- recordTranscript(messages);
548673
+ if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
548674
+ await flushSessionStorage();
548675
+ }
548441
548676
  }
548442
- if (message.attachment.type === "structured_output") {
548443
- structuredOutputFromTool = message.attachment.data;
548444
- } else if (message.attachment.type === "max_turns_reached") {
548677
+ yield {
548678
+ type: "result",
548679
+ subtype: "error_max_budget_usd",
548680
+ duration_ms: Date.now() - startTime2,
548681
+ duration_api_ms: getTotalAPIDuration(),
548682
+ is_error: true,
548683
+ num_turns: turnCount,
548684
+ stop_reason: lastStopReason,
548685
+ session_id: getSessionId(),
548686
+ total_cost_usd: getTotalCostUSD(),
548687
+ usage: this.totalUsage,
548688
+ modelUsage: getModelUsage(),
548689
+ permission_denials: this.permissionDenials,
548690
+ fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
548691
+ uuid: randomUUID51(),
548692
+ errors: [`Reached maximum budget ($${maxBudgetUsd})`]
548693
+ };
548694
+ return;
548695
+ }
548696
+ if (message.type === "user" && jsonSchema) {
548697
+ const currentCalls = countToolCalls(this.mutableMessages, SYNTHETIC_OUTPUT_TOOL_NAME);
548698
+ const callsThisQuery = currentCalls - initialStructuredOutputCalls;
548699
+ const maxRetries = parseInt(process.env.MAX_STRUCTURED_OUTPUT_RETRIES || "5", 10);
548700
+ if (callsThisQuery >= maxRetries) {
548445
548701
  if (persistSession) {
548446
548702
  if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
548447
548703
  await flushSessionStorage();
@@ -548449,11 +548705,11 @@ class QueryEngine {
548449
548705
  }
548450
548706
  yield {
548451
548707
  type: "result",
548452
- subtype: "error_max_turns",
548708
+ subtype: "error_max_structured_output_retries",
548453
548709
  duration_ms: Date.now() - startTime2,
548454
548710
  duration_api_ms: getTotalAPIDuration(),
548455
548711
  is_error: true,
548456
- num_turns: message.attachment.turnCount,
548712
+ num_turns: turnCount,
548457
548713
  stop_reason: lastStopReason,
548458
548714
  session_id: getSessionId(),
548459
548715
  total_cost_usd: getTotalCostUSD(),
@@ -548463,97 +548719,25 @@ class QueryEngine {
548463
548719
  fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
548464
548720
  uuid: randomUUID51(),
548465
548721
  errors: [
548466
- `Reached maximum number of turns (${message.attachment.maxTurns})`
548722
+ `Failed to provide valid structured output after ${maxRetries} attempts`
548467
548723
  ]
548468
548724
  };
548469
548725
  return;
548470
- } else if (replayUserMessages && message.attachment.type === "queued_command") {
548471
- yield {
548472
- type: "user",
548473
- message: {
548474
- role: "user",
548475
- content: message.attachment.prompt
548476
- },
548477
- session_id: getSessionId(),
548478
- parent_tool_use_id: null,
548479
- uuid: message.attachment.source_uuid || message.uuid,
548480
- timestamp: message.timestamp,
548481
- isReplay: true
548482
- };
548483
- }
548484
- break;
548485
- case "stream_request_start":
548486
- break;
548487
- case "system": {
548488
- const snipResult = this.config.snipReplay?.(message, this.mutableMessages);
548489
- if (snipResult !== undefined) {
548490
- if (snipResult.executed) {
548491
- this.mutableMessages.length = 0;
548492
- this.mutableMessages.push(...snipResult.messages);
548493
- }
548494
- break;
548495
- }
548496
- this.mutableMessages.push(message);
548497
- if (message.subtype === "compact_boundary" && message.compactMetadata) {
548498
- const mutableBoundaryIdx = this.mutableMessages.length - 1;
548499
- if (mutableBoundaryIdx > 0) {
548500
- this.mutableMessages.splice(0, mutableBoundaryIdx);
548501
- }
548502
- const localBoundaryIdx = messages.length - 1;
548503
- if (localBoundaryIdx > 0) {
548504
- messages.splice(0, localBoundaryIdx);
548505
- }
548506
- yield {
548507
- type: "system",
548508
- subtype: "compact_boundary",
548509
- session_id: getSessionId(),
548510
- uuid: message.uuid,
548511
- compact_metadata: toSDKCompactMetadata(message.compactMetadata)
548512
- };
548513
548726
  }
548514
- if (message.subtype === "api_error") {
548515
- yield {
548516
- type: "system",
548517
- subtype: "api_retry",
548518
- attempt: message.retryAttempt,
548519
- max_retries: message.maxRetries,
548520
- retry_delay_ms: message.retryInMs,
548521
- error_status: message.error.status ?? null,
548522
- error: categorizeRetryableAPIError(message.error),
548523
- session_id: getSessionId(),
548524
- uuid: message.uuid
548525
- };
548526
- }
548527
- if (message.subtype === "informational" && typeof message.content === "string" && (message.content.startsWith("Goal ") || message.content.startsWith("Goal:"))) {
548528
- yield {
548529
- type: "system",
548530
- subtype: "status",
548531
- status: message.content.slice(0, 500),
548532
- session_id: getSessionId(),
548533
- uuid: message.uuid
548534
- };
548535
- }
548536
- break;
548537
548727
  }
548538
- case "tool_use_summary":
548539
- yield {
548540
- type: "tool_use_summary",
548541
- summary: message.summary,
548542
- preceding_tool_use_ids: message.precedingToolUseIds,
548543
- session_id: getSessionId(),
548544
- uuid: message.uuid
548545
- };
548546
- break;
548547
548728
  }
548548
- if (maxBudgetUsd !== undefined && getTotalCostUSD() >= maxBudgetUsd) {
548549
- if (persistSession) {
548550
- if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
548551
- await flushSessionStorage();
548552
- }
548729
+ const result = messages.findLast((m) => m.type === "assistant" || m.type === "user");
548730
+ const edeResultType = result?.type ?? "undefined";
548731
+ const edeLastContentType = result?.type === "assistant" ? last_default(result.message.content)?.type ?? "none" : "n/a";
548732
+ if (persistSession) {
548733
+ if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
548734
+ await flushSessionStorage();
548553
548735
  }
548736
+ }
548737
+ if (!isResultSuccessful(result, lastStopReason)) {
548554
548738
  yield {
548555
548739
  type: "result",
548556
- subtype: "error_max_budget_usd",
548740
+ subtype: "error_during_execution",
548557
548741
  duration_ms: Date.now() - startTime2,
548558
548742
  duration_api_ms: getTotalAPIDuration(),
548559
548743
  is_error: true,
@@ -548566,105 +548750,47 @@ class QueryEngine {
548566
548750
  permission_denials: this.permissionDenials,
548567
548751
  fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
548568
548752
  uuid: randomUUID51(),
548569
- errors: [`Reached maximum budget ($${maxBudgetUsd})`]
548753
+ errors: (() => {
548754
+ const all4 = getInMemoryErrors();
548755
+ const start = errorLogWatermark ? all4.lastIndexOf(errorLogWatermark) + 1 : 0;
548756
+ return [
548757
+ `[ede_diagnostic] result_type=${edeResultType} last_content_type=${edeLastContentType} stop_reason=${lastStopReason}`,
548758
+ ...all4.slice(start).map((_) => _.error)
548759
+ ];
548760
+ })()
548570
548761
  };
548571
548762
  return;
548572
548763
  }
548573
- if (message.type === "user" && jsonSchema) {
548574
- const currentCalls = countToolCalls(this.mutableMessages, SYNTHETIC_OUTPUT_TOOL_NAME);
548575
- const callsThisQuery = currentCalls - initialStructuredOutputCalls;
548576
- const maxRetries = parseInt(process.env.MAX_STRUCTURED_OUTPUT_RETRIES || "5", 10);
548577
- if (callsThisQuery >= maxRetries) {
548578
- if (persistSession) {
548579
- if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
548580
- await flushSessionStorage();
548581
- }
548582
- }
548583
- yield {
548584
- type: "result",
548585
- subtype: "error_max_structured_output_retries",
548586
- duration_ms: Date.now() - startTime2,
548587
- duration_api_ms: getTotalAPIDuration(),
548588
- is_error: true,
548589
- num_turns: turnCount,
548590
- stop_reason: lastStopReason,
548591
- session_id: getSessionId(),
548592
- total_cost_usd: getTotalCostUSD(),
548593
- usage: this.totalUsage,
548594
- modelUsage: getModelUsage(),
548595
- permission_denials: this.permissionDenials,
548596
- fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
548597
- uuid: randomUUID51(),
548598
- errors: [
548599
- `Failed to provide valid structured output after ${maxRetries} attempts`
548600
- ]
548601
- };
548602
- return;
548764
+ let textResult = "";
548765
+ let isApiError = false;
548766
+ if (result.type === "assistant") {
548767
+ const lastContent = last_default(result.message.content);
548768
+ if (lastContent?.type === "text" && !SYNTHETIC_MESSAGES.has(lastContent.text)) {
548769
+ textResult = lastContent.text;
548603
548770
  }
548771
+ isApiError = Boolean(result.isApiErrorMessage);
548604
548772
  }
548605
- }
548606
- const result = messages.findLast((m) => m.type === "assistant" || m.type === "user");
548607
- const edeResultType = result?.type ?? "undefined";
548608
- const edeLastContentType = result?.type === "assistant" ? last_default(result.message.content)?.type ?? "none" : "n/a";
548609
- if (persistSession) {
548610
- if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
548611
- await flushSessionStorage();
548612
- }
548613
- }
548614
- if (!isResultSuccessful(result, lastStopReason)) {
548615
548773
  yield {
548616
548774
  type: "result",
548617
- subtype: "error_during_execution",
548775
+ subtype: "success",
548776
+ is_error: isApiError,
548618
548777
  duration_ms: Date.now() - startTime2,
548619
548778
  duration_api_ms: getTotalAPIDuration(),
548620
- is_error: true,
548621
548779
  num_turns: turnCount,
548780
+ result: textResult,
548622
548781
  stop_reason: lastStopReason,
548623
548782
  session_id: getSessionId(),
548624
548783
  total_cost_usd: getTotalCostUSD(),
548625
548784
  usage: this.totalUsage,
548626
548785
  modelUsage: getModelUsage(),
548627
548786
  permission_denials: this.permissionDenials,
548787
+ structured_output: structuredOutputFromTool,
548628
548788
  fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
548629
- uuid: randomUUID51(),
548630
- errors: (() => {
548631
- const all4 = getInMemoryErrors();
548632
- const start = errorLogWatermark ? all4.lastIndexOf(errorLogWatermark) + 1 : 0;
548633
- return [
548634
- `[ede_diagnostic] result_type=${edeResultType} last_content_type=${edeLastContentType} stop_reason=${lastStopReason}`,
548635
- ...all4.slice(start).map((_) => _.error)
548636
- ];
548637
- })()
548789
+ uuid: randomUUID51()
548638
548790
  };
548639
- return;
548640
- }
548641
- let textResult = "";
548642
- let isApiError = false;
548643
- if (result.type === "assistant") {
548644
- const lastContent = last_default(result.message.content);
548645
- if (lastContent?.type === "text" && !SYNTHETIC_MESSAGES.has(lastContent.text)) {
548646
- textResult = lastContent.text;
548647
- }
548648
- isApiError = Boolean(result.isApiErrorMessage);
548791
+ } finally {
548792
+ releaseInitialAutoCompactSkip();
548649
548793
  }
548650
- yield {
548651
- type: "result",
548652
- subtype: "success",
548653
- is_error: isApiError,
548654
- duration_ms: Date.now() - startTime2,
548655
- duration_api_ms: getTotalAPIDuration(),
548656
- num_turns: turnCount,
548657
- result: textResult,
548658
- stop_reason: lastStopReason,
548659
- session_id: getSessionId(),
548660
- total_cost_usd: getTotalCostUSD(),
548661
- usage: this.totalUsage,
548662
- modelUsage: getModelUsage(),
548663
- permission_denials: this.permissionDenials,
548664
- structured_output: structuredOutputFromTool,
548665
- fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
548666
- uuid: randomUUID51()
548667
- };
548668
548794
  }
548669
548795
  interrupt() {
548670
548796
  this.abortController.abort();
@@ -548757,6 +548883,7 @@ var init_QueryEngine = __esm(() => {
548757
548883
  init_last();
548758
548884
  init_state();
548759
548885
  init_maximo();
548886
+ init_autoCompact();
548760
548887
  init_logging();
548761
548888
  init_strip_ansi();
548762
548889
  init_commands2();
@@ -557741,7 +557868,7 @@ async function run() {
557741
557868
  }).hideHelp()).option("--replay-user-messages", "Re-emit user messages from stdin back on stdout for acknowledgment (only works with --input-format=stream-json and --output-format=stream-json)", () => true).addOption(new Option("--enable-auth-status", "Enable auth status messages in SDK mode").default(false).hideHelp()).option("--allowedTools, --allowed-tools <tools...>", 'Comma or space-separated list of tool names to allow (e.g. "Bash(git:*) Edit")').option("--tools <tools...>", 'Specify the list of available tools from the built-in set. Use "" to disable all tools, "default" to use all tools, or specify tool names (e.g. "Bash,Edit,Read").').option("--disallowedTools, --disallowed-tools <tools...>", 'Comma or space-separated list of tool names to deny (e.g. "Bash(git:*) Edit")').option("--mcp-config <configs...>", "Load MCP servers from JSON files or strings (space-separated)").addOption(new Option("--permission-prompt-tool <tool>", "MCP tool to use for permission prompts (only works with --print)").argParser(String).hideHelp()).addOption(new Option("--system-prompt <prompt>", "System prompt to use for the session").argParser(String)).addOption(new Option("--system-prompt-file <file>", "Read system prompt from a file").argParser(String).hideHelp()).addOption(new Option("--append-system-prompt <prompt>", "Append a system prompt to the default system prompt").argParser(String)).addOption(new Option("--append-system-prompt-file <file>", "Read system prompt from a file and append to the default system prompt").argParser(String).hideHelp()).addOption(new Option("--permission-mode <mode>", "Permission mode to use for the session").argParser(String).choices(PERMISSION_MODES)).option("-c, --continue", "Continue the most recent conversation in the current directory", () => true).option("-r, --resume [value]", "Resume a conversation by session ID, or open interactive picker with optional search term", (value) => value || true).option("--fork-session", "When resuming, create a new session ID instead of reusing the original (use with --resume or --continue)", () => true).addOption(new Option("--prefill <text>", "Pre-fill the prompt input with text without submitting it").hideHelp()).addOption(new Option("--deep-link-origin", "Signal that this session was launched from a deep link").hideHelp()).addOption(new Option("--deep-link-repo <slug>", "Repo slug the deep link ?repo= parameter resolved to the current cwd").hideHelp()).addOption(new Option("--deep-link-last-fetch <ms>", "FETCH_HEAD mtime in epoch ms, precomputed by the deep link trampoline").argParser((v) => {
557742
557869
  const n3 = Number(v);
557743
557870
  return Number.isFinite(n3) ? n3 : undefined;
557744
- }).hideHelp()).option("--from-pr [value]", "Resume a session linked to a PR by PR number/URL, or open interactive picker with optional search term", (value) => value || true).option("--no-session-persistence", "Disable session persistence - sessions will not be saved to disk and cannot be resumed (only works with --print)").addOption(new Option("--resume-session-at <message id>", "When resuming, only messages up to and including the assistant message with <message.id> (use with --resume in print mode)").argParser(String).hideHelp()).addOption(new Option("--rewind-files <user-message-id>", "Restore files to state at the specified user message and exit (requires --resume)").hideHelp()).option("--model <model>", `Model for the current session. Use a model from the active provider (e.g. 'maximo-pandora-3.8-nano' or 'maximo-atlas-1.2').`).addOption(new Option("--effort <level>", `Effort level for the current session (minimal, low, medium, high, xhigh, max, ultra)`).argParser((rawValue) => {
557871
+ }).hideHelp()).option("--from-pr [value]", "Resume a session linked to a PR by PR number/URL, or open interactive picker with optional search term", (value) => value || true).option("--no-session-persistence", "Disable session persistence - sessions will not be saved to disk and cannot be resumed (only works with --print)").addOption(new Option("--resume-session-at <message id>", "When resuming, only messages up to and including the assistant message with <message.id> (use with --resume in print mode)").argParser(String).hideHelp()).addOption(new Option("--rewind-files <user-message-id>", "Restore files to state at the specified user message and exit (requires --resume)").hideHelp()).option("--model <model>", `Model for the current session. Use a model from the active provider (e.g. 'maximo-pandora-3.9-nano' or 'maximo-atlas-1.4').`).addOption(new Option("--effort <level>", `Effort level for the current session (minimal, low, medium, high, xhigh, max, ultra)`).argParser((rawValue) => {
557745
557872
  const normalized = rawValue.trim().toLowerCase().replace(/[-_\s]+/g, "").replace(/^extrahigh$/, "xhigh").replace(/^ultra$/, "xhigh").replace(/^maximum$/, "max").replace(/^med$/, "medium");
557746
557873
  const allowed = ["minimal", "low", "medium", "high", "xhigh", "max", "ultra"];
557747
557874
  if (!allowed.includes(normalized)) {
@@ -559327,7 +559454,7 @@ Usage: maximo --remote "your task description"`, () => gracefulShutdown(1));
559327
559454
  pendingHookMessages
559328
559455
  }, renderAndRun);
559329
559456
  }
559330
- }).version("0.1.41 (Maximo Syntax)", "-v, --version", "Output the version number");
559457
+ }).version("0.1.43 (Maximo Syntax)", "-v, --version", "Output the version number");
559331
559458
  program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
559332
559459
  program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
559333
559460
  if (canUserConfigureAdvisor()) {
@@ -559866,7 +559993,7 @@ function validateProviderEnvOrExit() {
559866
559993
  async function main2() {
559867
559994
  const args = process.argv.slice(2);
559868
559995
  if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
559869
- console.log(`${"0.1.41"} (Maximo Syntax)`);
559996
+ console.log(`${"0.1.43"} (Maximo Syntax)`);
559870
559997
  return;
559871
559998
  }
559872
559999
  validateProviderEnvOrExit();
@@ -559943,4 +560070,4 @@ async function main2() {
559943
560070
  }
559944
560071
  main2();
559945
560072
 
559946
- //# debugId=986998060839D15F64756E2164756E21
560073
+ //# debugId=CB53469D58B7999264756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maximoai/maximo-syntax-cli",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
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": {