@maximoai/maximo-syntax-cli 0.1.41 → 0.1.42
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.
- package/dist/cli.mjs +395 -281
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -124077,7 +124077,7 @@ var init_metadata = __esm(() => {
|
|
|
124077
124077
|
isMaximoAiAuth: isMaximoAISubscriber(),
|
|
124078
124078
|
version: "99.0.0",
|
|
124079
124079
|
versionBase: getVersionBase(),
|
|
124080
|
-
buildTime: "2026-09-
|
|
124080
|
+
buildTime: "2026-09-08T14:04:17.261Z",
|
|
124081
124081
|
deploymentEnvironment: env3.detectDeploymentEnvironment(),
|
|
124082
124082
|
...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
|
|
124083
124083
|
githubEventName: process.env.GITHUB_EVENT_NAME,
|
|
@@ -176897,12 +176897,37 @@ function getAssistantMessageContentLength(message) {
|
|
|
176897
176897
|
}
|
|
176898
176898
|
return contentLength;
|
|
176899
176899
|
}
|
|
176900
|
+
function isUsableTokenUsage(usageCount, messages) {
|
|
176901
|
+
if (usageCount <= 0) {
|
|
176902
|
+
return false;
|
|
176903
|
+
}
|
|
176904
|
+
let compactPreTokens = 0;
|
|
176905
|
+
for (let i3 = messages.length - 1;i3 >= 0; i3--) {
|
|
176906
|
+
const message = messages[i3];
|
|
176907
|
+
if (message && message.type === "system" && "subtype" in message && message.subtype === "compact_boundary" && "compactMetadata" in message) {
|
|
176908
|
+
const preTokens = message.compactMetadata?.preTokens;
|
|
176909
|
+
if (typeof preTokens === "number" && preTokens > 0) {
|
|
176910
|
+
compactPreTokens = preTokens;
|
|
176911
|
+
}
|
|
176912
|
+
break;
|
|
176913
|
+
}
|
|
176914
|
+
}
|
|
176915
|
+
if (compactPreTokens > 0 && usageCount >= compactPreTokens * 0.9) {
|
|
176916
|
+
return false;
|
|
176917
|
+
}
|
|
176918
|
+
return true;
|
|
176919
|
+
}
|
|
176900
176920
|
function tokenCountWithEstimation(messages) {
|
|
176901
176921
|
let i3 = messages.length - 1;
|
|
176902
176922
|
while (i3 >= 0) {
|
|
176903
176923
|
const message = messages[i3];
|
|
176904
176924
|
const usage = message ? getTokenUsage(message) : undefined;
|
|
176905
176925
|
if (message && usage) {
|
|
176926
|
+
const usageCount = getTokenCountFromUsage(usage);
|
|
176927
|
+
if (!isUsableTokenUsage(usageCount, messages)) {
|
|
176928
|
+
i3--;
|
|
176929
|
+
continue;
|
|
176930
|
+
}
|
|
176906
176931
|
const responseId = getAssistantMessageId(message);
|
|
176907
176932
|
if (responseId) {
|
|
176908
176933
|
let j = i3 - 1;
|
|
@@ -176917,7 +176942,7 @@ function tokenCountWithEstimation(messages) {
|
|
|
176917
176942
|
j--;
|
|
176918
176943
|
}
|
|
176919
176944
|
}
|
|
176920
|
-
return
|
|
176945
|
+
return usageCount + roughTokenCountEstimationForMessages(messages.slice(i3 + 1));
|
|
176921
176946
|
}
|
|
176922
176947
|
i3--;
|
|
176923
176948
|
}
|
|
@@ -276984,7 +277009,7 @@ import { access as access3, writeFile as writeFile13 } from "fs/promises";
|
|
|
276984
277009
|
import { homedir as homedir22 } from "os";
|
|
276985
277010
|
import { join as join65 } from "path";
|
|
276986
277011
|
function getCurrentRealVersion() {
|
|
276987
|
-
return "0.1.
|
|
277012
|
+
return "0.1.42";
|
|
276988
277013
|
}
|
|
276989
277014
|
async function getRolloutConfig() {
|
|
276990
277015
|
try {
|
|
@@ -282282,6 +282307,8 @@ var init_coreSchemas = __esm(() => {
|
|
|
282282
282307
|
compact_metadata: exports_external.object({
|
|
282283
282308
|
trigger: exports_external.enum(["manual", "auto"]),
|
|
282284
282309
|
pre_tokens: exports_external.number(),
|
|
282310
|
+
post_tokens: exports_external.number().optional(),
|
|
282311
|
+
summary: exports_external.string().optional(),
|
|
282285
282312
|
preserved_segment: exports_external.object({
|
|
282286
282313
|
head_uuid: UUIDPlaceholder(),
|
|
282287
282314
|
anchor_uuid: UUIDPlaceholder(),
|
|
@@ -367697,7 +367724,7 @@ function getAnthropicEnvMetadata() {
|
|
|
367697
367724
|
function getBuildAgeMinutes() {
|
|
367698
367725
|
if (false)
|
|
367699
367726
|
;
|
|
367700
|
-
const buildTime = new Date("2026-09-
|
|
367727
|
+
const buildTime = new Date("2026-09-08T14:04:17.261Z").getTime();
|
|
367701
367728
|
if (isNaN(buildTime))
|
|
367702
367729
|
return;
|
|
367703
367730
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -368844,7 +368871,7 @@ function selectTailTurns(messages, keepTurns = 3) {
|
|
|
368844
368871
|
const summarizedGroups = groups.slice(0, groups.length - keepGroupCount);
|
|
368845
368872
|
const kept = keptGroups.flat();
|
|
368846
368873
|
const summarizedCount = summarizedGroups.reduce((sum, group) => sum + group.length, 0);
|
|
368847
|
-
if (summarizedCount < 1
|
|
368874
|
+
if (summarizedCount < 1) {
|
|
368848
368875
|
return { kept: [], summarizedCount: messages.length };
|
|
368849
368876
|
}
|
|
368850
368877
|
if (turnContainsUnansweredMedia(kept)) {
|
|
@@ -368949,6 +368976,30 @@ function buildPostCompactMessages(result) {
|
|
|
368949
368976
|
...result.hookResults
|
|
368950
368977
|
];
|
|
368951
368978
|
}
|
|
368979
|
+
function stripStaleUsageFromPreservedMessages(messages) {
|
|
368980
|
+
return messages.map((message) => {
|
|
368981
|
+
if (message.type !== "assistant" || !("usage" in message.message)) {
|
|
368982
|
+
return message;
|
|
368983
|
+
}
|
|
368984
|
+
const usage = message.message.usage;
|
|
368985
|
+
if (!usage) {
|
|
368986
|
+
return message;
|
|
368987
|
+
}
|
|
368988
|
+
return {
|
|
368989
|
+
...message,
|
|
368990
|
+
message: {
|
|
368991
|
+
...message.message,
|
|
368992
|
+
usage: {
|
|
368993
|
+
...usage,
|
|
368994
|
+
input_tokens: 0,
|
|
368995
|
+
output_tokens: 0,
|
|
368996
|
+
cache_creation_input_tokens: 0,
|
|
368997
|
+
cache_read_input_tokens: 0
|
|
368998
|
+
}
|
|
368999
|
+
}
|
|
369000
|
+
};
|
|
369001
|
+
});
|
|
369002
|
+
}
|
|
368952
369003
|
function annotateBoundaryWithPreservedSegment(boundary, anchorUuid, messagesToKeep) {
|
|
368953
369004
|
const keep = messagesToKeep ?? [];
|
|
368954
369005
|
if (keep.length === 0)
|
|
@@ -369103,7 +369154,8 @@ async function compactConversation(messages, context7, cacheSafeParams, suppress
|
|
|
369103
369154
|
].sort();
|
|
369104
369155
|
}
|
|
369105
369156
|
const transcriptPath = getTranscriptPath();
|
|
369106
|
-
const { kept:
|
|
369157
|
+
const { kept: rawKeptTail } = selectTailTurns(messages);
|
|
369158
|
+
const keptTail = stripStaleUsageFromPreservedMessages(rawKeptTail);
|
|
369107
369159
|
const summaryMessages = [
|
|
369108
369160
|
createUserMessage({
|
|
369109
369161
|
content: getCompactUserSummaryMessage(summary, suppressFollowUpQuestions, transcriptPath, keptTail.length > 0),
|
|
@@ -369114,6 +369166,10 @@ async function compactConversation(messages, context7, cacheSafeParams, suppress
|
|
|
369114
369166
|
if (keptTail.length > 0) {
|
|
369115
369167
|
boundaryMarker.compactMetadata = annotateBoundaryWithPreservedSegment(boundaryMarker, summaryMessages.at(-1).uuid, keptTail).compactMetadata;
|
|
369116
369168
|
}
|
|
369169
|
+
const compactSummary = formatCompactSummary(summary);
|
|
369170
|
+
if (compactSummary) {
|
|
369171
|
+
boundaryMarker.compactMetadata.compactSummary = compactSummary;
|
|
369172
|
+
}
|
|
369117
369173
|
const compactionCallTotalTokens = tokenCountFromLastAPIResponse([
|
|
369118
369174
|
summaryResponse
|
|
369119
369175
|
]);
|
|
@@ -369124,6 +369180,7 @@ async function compactConversation(messages, context7, cacheSafeParams, suppress
|
|
|
369124
369180
|
...postCompactFileAttachments,
|
|
369125
369181
|
...hookMessages
|
|
369126
369182
|
]);
|
|
369183
|
+
boundaryMarker.compactMetadata.postTokens = truePostCompactTokenCount;
|
|
369127
369184
|
const compactionUsage = getTokenUsage(summaryResponse);
|
|
369128
369185
|
const querySourceForEvent = recompactionInfo?.querySource ?? context7.options.querySource ?? "unknown";
|
|
369129
369186
|
logEvent("tengu_compact", {
|
|
@@ -370240,7 +370297,7 @@ async function trySessionMemoryCompaction(messages, agentId, autoCompactThreshol
|
|
|
370240
370297
|
logEvent("tengu_sm_compact_resumed_session", {});
|
|
370241
370298
|
}
|
|
370242
370299
|
const startIndex = calculateMessagesToKeepIndex(messages, lastSummarizedIndex);
|
|
370243
|
-
const messagesToKeep = messages.slice(startIndex).filter((m) => !isCompactBoundaryMessage(m));
|
|
370300
|
+
const messagesToKeep = stripStaleUsageFromPreservedMessages(messages.slice(startIndex).filter((m) => !isCompactBoundaryMessage(m)));
|
|
370244
370301
|
const hookResults = await processSessionStartHooks("compact", {
|
|
370245
370302
|
model: getMainLoopModel()
|
|
370246
370303
|
});
|
|
@@ -370329,6 +370386,9 @@ function getAutoCompactPercent() {
|
|
|
370329
370386
|
}
|
|
370330
370387
|
return AUTOCOMPACT_DEFAULT_PERCENT;
|
|
370331
370388
|
}
|
|
370389
|
+
function releaseInitialAutoCompactSkip() {
|
|
370390
|
+
autoCompactArmed = true;
|
|
370391
|
+
}
|
|
370332
370392
|
function getMaximoOutputRatio(model) {
|
|
370333
370393
|
const limits = getCachedMaximoModelLimits(model);
|
|
370334
370394
|
if (!limits?.contextWindow || !limits.maxOutputTokens) {
|
|
@@ -370433,6 +370493,10 @@ async function shouldAutoCompact(messages, model, querySource, snipTokensFreed =
|
|
|
370433
370493
|
}
|
|
370434
370494
|
if (false) {}
|
|
370435
370495
|
if (false) {}
|
|
370496
|
+
if (!autoCompactArmed) {
|
|
370497
|
+
logForDebugging2("autocompact: skipping until the first turn of this process completes");
|
|
370498
|
+
return false;
|
|
370499
|
+
}
|
|
370436
370500
|
const tokenCount = tokenCountWithEstimation(messages) - snipTokensFreed;
|
|
370437
370501
|
const threshold = getAutoCompactThreshold(model);
|
|
370438
370502
|
const effectiveWindow = getEffectiveContextWindowSize(model);
|
|
@@ -370448,10 +370512,6 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
|
|
|
370448
370512
|
return { wasCompacted: false };
|
|
370449
370513
|
}
|
|
370450
370514
|
const model = toolUseContext.options.mainLoopModel;
|
|
370451
|
-
if (skipInitialAutoCompact) {
|
|
370452
|
-
skipInitialAutoCompact = false;
|
|
370453
|
-
return { wasCompacted: false };
|
|
370454
|
-
}
|
|
370455
370515
|
const shouldCompact = await shouldAutoCompact(messages, model, querySource, snipTokensFreed);
|
|
370456
370516
|
if (!shouldCompact) {
|
|
370457
370517
|
return { wasCompacted: false };
|
|
@@ -370497,7 +370557,7 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
|
|
|
370497
370557
|
return { wasCompacted: false, consecutiveFailures: nextFailures };
|
|
370498
370558
|
}
|
|
370499
370559
|
}
|
|
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;
|
|
370560
|
+
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
370561
|
var init_autoCompact = __esm(() => {
|
|
370502
370562
|
init_state();
|
|
370503
370563
|
init_state();
|
|
@@ -370515,7 +370575,8 @@ var init_autoCompact = __esm(() => {
|
|
|
370515
370575
|
init_compact();
|
|
370516
370576
|
init_postCompactCleanup();
|
|
370517
370577
|
init_sessionMemoryCompact();
|
|
370518
|
-
skipInitialAutoCompact = isEnvTruthy(process.env.MAXIMO_SYNTAX_SKIP_FIRST_AUTOCOMPACT);
|
|
370578
|
+
skipInitialAutoCompact = isEnvTruthy(process.env.MAXIMO_SYNTAX_SKIP_FIRST_AUTOCOMPACT) || isEnvTruthy(process.env.MAXIMO_SYNTAX_DESKTOP);
|
|
370579
|
+
autoCompactArmed = !skipInitialAutoCompact;
|
|
370519
370580
|
});
|
|
370520
370581
|
|
|
370521
370582
|
// src/utils/analyzeContext.ts
|
|
@@ -383204,6 +383265,29 @@ function getMessagesAfterCompactBoundary(messages, options2) {
|
|
|
383204
383265
|
if (!options2?.includeSnipped && false) {}
|
|
383205
383266
|
return sliced;
|
|
383206
383267
|
}
|
|
383268
|
+
function hideReplayedCompactTail(messages, isTranscriptMode) {
|
|
383269
|
+
if (isTranscriptMode) {
|
|
383270
|
+
return messages;
|
|
383271
|
+
}
|
|
383272
|
+
const boundaryIndex = findLastCompactBoundaryIndex(messages);
|
|
383273
|
+
if (boundaryIndex === -1) {
|
|
383274
|
+
return messages;
|
|
383275
|
+
}
|
|
383276
|
+
const boundary = messages[boundaryIndex];
|
|
383277
|
+
const boundaryTimestamp = boundary?.timestamp;
|
|
383278
|
+
if (!boundaryTimestamp) {
|
|
383279
|
+
return messages;
|
|
383280
|
+
}
|
|
383281
|
+
return messages.filter((message, index) => {
|
|
383282
|
+
if (index <= boundaryIndex) {
|
|
383283
|
+
return true;
|
|
383284
|
+
}
|
|
383285
|
+
if (message.type === "user" && (message.isCompactSummary || message.isVisibleInTranscriptOnly)) {
|
|
383286
|
+
return false;
|
|
383287
|
+
}
|
|
383288
|
+
return message.timestamp >= boundaryTimestamp;
|
|
383289
|
+
});
|
|
383290
|
+
}
|
|
383207
383291
|
function shouldShowUserMessage(message, isTranscriptMode) {
|
|
383208
383292
|
if (message.type !== "user")
|
|
383209
383293
|
return true;
|
|
@@ -433885,7 +433969,7 @@ function getRecentActivitySync() {
|
|
|
433885
433969
|
return cachedActivity;
|
|
433886
433970
|
}
|
|
433887
433971
|
function getLogoDisplayData() {
|
|
433888
|
-
const version2 = process.env.DEMO_VERSION ?? "0.1.
|
|
433972
|
+
const version2 = process.env.DEMO_VERSION ?? "0.1.42" ?? "99.0.0";
|
|
433889
433973
|
const serverUrl = getDirectConnectServerUrl();
|
|
433890
433974
|
const displayPath = process.env.DEMO_VERSION ? "/code/maximo" : getDisplayPath(getCwd());
|
|
433891
433975
|
const cwd2 = serverUrl ? `${displayPath} in ${serverUrl.replace(/^https?:\/\//, "")}` : displayPath;
|
|
@@ -438802,9 +438886,9 @@ var import_react_compiler_runtime208, React86, import_react160, jsx_runtime266,
|
|
|
438802
438886
|
hasTruncatedMessages: hasTruncatedMessages_0,
|
|
438803
438887
|
hiddenMessageCount: hiddenMessageCount_0
|
|
438804
438888
|
} = import_react160.useMemo(() => {
|
|
438805
|
-
const compactAwareMessages = verbose || isFullscreenEnvEnabled() ? normalizedMessages : getMessagesAfterCompactBoundary(normalizedMessages, {
|
|
438889
|
+
const compactAwareMessages = hideReplayedCompactTail(verbose || isFullscreenEnvEnabled() ? normalizedMessages : getMessagesAfterCompactBoundary(normalizedMessages, {
|
|
438806
438890
|
includeSnipped: true
|
|
438807
|
-
});
|
|
438891
|
+
}), isTranscriptMode);
|
|
438808
438892
|
const messagesToShowNotTruncated = reorderMessagesInUI(compactAwareMessages.filter((msg_2) => msg_2.type !== "progress").filter((msg_3) => !isNullRenderingAttachment(msg_3)).filter((_) => shouldShowUserMessage(_, isTranscriptMode)), syntheticStreamingToolUseMessages);
|
|
438809
438893
|
const briefToolNames = [BRIEF_TOOL_NAME4, SEND_USER_FILE_TOOL_NAME2].filter((n2) => n2 !== null);
|
|
438810
438894
|
const dropTextToolNames = [BRIEF_TOOL_NAME4].filter((n_0) => n_0 !== null);
|
|
@@ -446083,6 +446167,7 @@ function toInternalMessages(messages) {
|
|
|
446083
446167
|
}
|
|
446084
446168
|
function toSDKCompactMetadata(meta) {
|
|
446085
446169
|
const seg = meta.preservedSegment;
|
|
446170
|
+
const extra = meta;
|
|
446086
446171
|
return {
|
|
446087
446172
|
trigger: meta.trigger,
|
|
446088
446173
|
pre_tokens: meta.preTokens,
|
|
@@ -446092,7 +446177,9 @@ function toSDKCompactMetadata(meta) {
|
|
|
446092
446177
|
anchor_uuid: seg.anchorUuid,
|
|
446093
446178
|
tail_uuid: seg.tailUuid
|
|
446094
446179
|
}
|
|
446095
|
-
}
|
|
446180
|
+
},
|
|
446181
|
+
...typeof extra.compactSummary === "string" && extra.compactSummary ? { summary: extra.compactSummary } : {},
|
|
446182
|
+
...typeof extra.postTokens === "number" ? { post_tokens: extra.postTokens } : {}
|
|
446096
446183
|
};
|
|
446097
446184
|
}
|
|
446098
446185
|
function fromSDKCompactMetadata(meta) {
|
|
@@ -463404,7 +463491,7 @@ var init_bridge_kick = __esm(() => {
|
|
|
463404
463491
|
var call57 = async () => {
|
|
463405
463492
|
return {
|
|
463406
463493
|
type: "text",
|
|
463407
|
-
value: `${"99.0.0"} (built ${"2026-09-
|
|
463494
|
+
value: `${"99.0.0"} (built ${"2026-09-08T14:04:17.261Z"})`
|
|
463408
463495
|
};
|
|
463409
463496
|
}, version2, version_default;
|
|
463410
463497
|
var init_version = __esm(() => {
|
|
@@ -475849,6 +475936,7 @@ function applyPreservedSegmentRelinks(messages) {
|
|
|
475849
475936
|
return;
|
|
475850
475937
|
const segIsLive = lastSegBoundaryIdx === absoluteLastBoundaryIdx;
|
|
475851
475938
|
const preservedUuids = new Set;
|
|
475939
|
+
let relinkLive = false;
|
|
475852
475940
|
if (segIsLive) {
|
|
475853
475941
|
const walkSeen = new Set;
|
|
475854
475942
|
let cur = messages.get(lastSeg.tailUuid);
|
|
@@ -475862,7 +475950,9 @@ function applyPreservedSegmentRelinks(messages) {
|
|
|
475862
475950
|
}
|
|
475863
475951
|
cur = cur.parentUuid ? messages.get(cur.parentUuid) : undefined;
|
|
475864
475952
|
}
|
|
475865
|
-
if (
|
|
475953
|
+
if (reachedHead) {
|
|
475954
|
+
relinkLive = true;
|
|
475955
|
+
} else {
|
|
475866
475956
|
logEvent("tengu_relink_walk_broken", {
|
|
475867
475957
|
tailInTranscript: messages.has(lastSeg.tailUuid),
|
|
475868
475958
|
headInTranscript: messages.has(lastSeg.headUuid),
|
|
@@ -475870,10 +475960,10 @@ function applyPreservedSegmentRelinks(messages) {
|
|
|
475870
475960
|
walkSteps: walkSeen.size,
|
|
475871
475961
|
transcriptSize: messages.size
|
|
475872
475962
|
});
|
|
475873
|
-
|
|
475963
|
+
preservedUuids.clear();
|
|
475874
475964
|
}
|
|
475875
475965
|
}
|
|
475876
|
-
if (
|
|
475966
|
+
if (relinkLive) {
|
|
475877
475967
|
const head = messages.get(lastSeg.headUuid);
|
|
475878
475968
|
if (head) {
|
|
475879
475969
|
messages.set(lastSeg.headUuid, {
|
|
@@ -539391,7 +539481,7 @@ function SetupRow({ children }) {
|
|
|
539391
539481
|
}
|
|
539392
539482
|
function WelcomeV2() {
|
|
539393
539483
|
const { columns } = useTerminalSize();
|
|
539394
|
-
const version3 = "0.1.
|
|
539484
|
+
const version3 = "0.1.42";
|
|
539395
539485
|
const width = Math.max(48, Math.min(columns || 92, 92));
|
|
539396
539486
|
const stacked = width < OCTOPUS_COMPACT_WIDTH + 42;
|
|
539397
539487
|
return /* @__PURE__ */ jsx_runtime479.jsx(ThemedBox_default, {
|
|
@@ -548031,6 +548121,20 @@ class QueryEngine {
|
|
|
548031
548121
|
readFileState;
|
|
548032
548122
|
discoveredSkillNames = new Set;
|
|
548033
548123
|
loadedNestedMemoryPaths = new Set;
|
|
548124
|
+
compactRestoreBoundaryTimestamp;
|
|
548125
|
+
shouldSuppressCompactRestore(message) {
|
|
548126
|
+
if (!this.compactRestoreBoundaryTimestamp) {
|
|
548127
|
+
return false;
|
|
548128
|
+
}
|
|
548129
|
+
if (message.type === "user" && (message.isCompactSummary || message.isVisibleInTranscriptOnly)) {
|
|
548130
|
+
return true;
|
|
548131
|
+
}
|
|
548132
|
+
if (message.timestamp < this.compactRestoreBoundaryTimestamp) {
|
|
548133
|
+
return true;
|
|
548134
|
+
}
|
|
548135
|
+
this.compactRestoreBoundaryTimestamp = undefined;
|
|
548136
|
+
return false;
|
|
548137
|
+
}
|
|
548034
548138
|
constructor(config3) {
|
|
548035
548139
|
this.config = config3;
|
|
548036
548140
|
this.mutableMessages = config3.initialMessages ?? [];
|
|
@@ -548069,15 +548173,15 @@ class QueryEngine {
|
|
|
548069
548173
|
const persistSession = !isSessionPersistenceDisabled();
|
|
548070
548174
|
const startTime2 = Date.now();
|
|
548071
548175
|
const wrappedCanUseTool = async (tool, input, toolUseContext, assistantMessage, toolUseID, forceDecision) => {
|
|
548072
|
-
const
|
|
548073
|
-
if (
|
|
548176
|
+
const result = await canUseTool(tool, input, toolUseContext, assistantMessage, toolUseID, forceDecision);
|
|
548177
|
+
if (result.behavior !== "allow") {
|
|
548074
548178
|
this.permissionDenials.push({
|
|
548075
548179
|
tool_name: sdkCompatToolName(tool.name),
|
|
548076
548180
|
tool_use_id: toolUseID,
|
|
548077
548181
|
tool_input: input
|
|
548078
548182
|
});
|
|
548079
548183
|
}
|
|
548080
|
-
return
|
|
548184
|
+
return result;
|
|
548081
548185
|
};
|
|
548082
548186
|
const initialAppState = getAppState();
|
|
548083
548187
|
const initialMainLoopModel = userSpecifiedModel ? parseUserSpecifiedModel(userSpecifiedModel) : getMainLoopModel();
|
|
@@ -548267,7 +548371,7 @@ class QueryEngine {
|
|
|
548267
548371
|
headlessProfilerCheckpoint("system_message_yielded");
|
|
548268
548372
|
if (!shouldQuery) {
|
|
548269
548373
|
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}>`)
|
|
548374
|
+
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
548375
|
yield {
|
|
548272
548376
|
type: "user",
|
|
548273
548377
|
message: {
|
|
@@ -548278,7 +548382,7 @@ class QueryEngine {
|
|
|
548278
548382
|
parent_tool_use_id: null,
|
|
548279
548383
|
uuid: msg.uuid,
|
|
548280
548384
|
timestamp: msg.timestamp,
|
|
548281
|
-
isReplay:
|
|
548385
|
+
isReplay: true,
|
|
548282
548386
|
isSynthetic: msg.isMeta || msg.isVisibleInTranscriptOnly
|
|
548283
548387
|
};
|
|
548284
548388
|
}
|
|
@@ -548337,111 +548441,250 @@ class QueryEngine {
|
|
|
548337
548441
|
let lastStopReason = null;
|
|
548338
548442
|
const errorLogWatermark = getInMemoryErrors().at(-1);
|
|
548339
548443
|
const initialStructuredOutputCalls = jsonSchema ? countToolCalls(this.mutableMessages, SYNTHETIC_OUTPUT_TOOL_NAME) : 0;
|
|
548340
|
-
|
|
548341
|
-
|
|
548342
|
-
|
|
548343
|
-
|
|
548344
|
-
|
|
548345
|
-
|
|
548346
|
-
|
|
548347
|
-
|
|
548348
|
-
|
|
548349
|
-
|
|
548350
|
-
|
|
548351
|
-
|
|
548352
|
-
|
|
548353
|
-
if (
|
|
548354
|
-
|
|
548355
|
-
|
|
548356
|
-
|
|
548357
|
-
|
|
548358
|
-
|
|
548444
|
+
try {
|
|
548445
|
+
for await (const message of query({
|
|
548446
|
+
messages,
|
|
548447
|
+
systemPrompt,
|
|
548448
|
+
userContext,
|
|
548449
|
+
systemContext,
|
|
548450
|
+
canUseTool: wrappedCanUseTool,
|
|
548451
|
+
toolUseContext: processUserInputContext,
|
|
548452
|
+
fallbackModel,
|
|
548453
|
+
querySource: "sdk",
|
|
548454
|
+
maxTurns,
|
|
548455
|
+
taskBudget
|
|
548456
|
+
})) {
|
|
548457
|
+
if (message.type === "assistant" || message.type === "user" || message.type === "system" && message.subtype === "compact_boundary") {
|
|
548458
|
+
if (persistSession && message.type === "system" && message.subtype === "compact_boundary") {
|
|
548459
|
+
const tailUuid = message.compactMetadata?.preservedSegment?.tailUuid;
|
|
548460
|
+
if (tailUuid) {
|
|
548461
|
+
const tailIdx = this.mutableMessages.findLastIndex((m) => m.uuid === tailUuid);
|
|
548462
|
+
if (tailIdx !== -1) {
|
|
548463
|
+
await recordTranscript(this.mutableMessages.slice(0, tailIdx + 1));
|
|
548464
|
+
}
|
|
548359
548465
|
}
|
|
548360
548466
|
}
|
|
548361
|
-
|
|
548362
|
-
|
|
548363
|
-
|
|
548364
|
-
|
|
548365
|
-
|
|
548366
|
-
|
|
548367
|
-
|
|
548467
|
+
messages.push(message);
|
|
548468
|
+
if (persistSession) {
|
|
548469
|
+
if (message.type === "assistant") {
|
|
548470
|
+
recordTranscript(messages);
|
|
548471
|
+
} else {
|
|
548472
|
+
await recordTranscript(messages);
|
|
548473
|
+
}
|
|
548474
|
+
}
|
|
548475
|
+
if (!hasAcknowledgedInitialMessages && messagesToAck.length > 0) {
|
|
548476
|
+
hasAcknowledgedInitialMessages = true;
|
|
548477
|
+
for (const msgToAck of messagesToAck) {
|
|
548478
|
+
if (msgToAck.type === "user") {
|
|
548479
|
+
yield {
|
|
548480
|
+
type: "user",
|
|
548481
|
+
message: msgToAck.message,
|
|
548482
|
+
session_id: getSessionId(),
|
|
548483
|
+
parent_tool_use_id: null,
|
|
548484
|
+
uuid: msgToAck.uuid,
|
|
548485
|
+
timestamp: msgToAck.timestamp,
|
|
548486
|
+
isReplay: true
|
|
548487
|
+
};
|
|
548488
|
+
}
|
|
548489
|
+
}
|
|
548368
548490
|
}
|
|
548369
548491
|
}
|
|
548370
|
-
if (
|
|
548371
|
-
|
|
548372
|
-
|
|
548373
|
-
|
|
548492
|
+
if (message.type === "user") {
|
|
548493
|
+
turnCount++;
|
|
548494
|
+
}
|
|
548495
|
+
switch (message.type) {
|
|
548496
|
+
case "tombstone":
|
|
548497
|
+
break;
|
|
548498
|
+
case "assistant":
|
|
548499
|
+
if (message.message.stop_reason != null) {
|
|
548500
|
+
lastStopReason = message.message.stop_reason;
|
|
548501
|
+
}
|
|
548502
|
+
this.mutableMessages.push(message);
|
|
548503
|
+
if (!this.shouldSuppressCompactRestore(message)) {
|
|
548504
|
+
yield* normalizeMessage(message);
|
|
548505
|
+
}
|
|
548506
|
+
break;
|
|
548507
|
+
case "progress":
|
|
548508
|
+
this.mutableMessages.push(message);
|
|
548509
|
+
if (persistSession) {
|
|
548510
|
+
messages.push(message);
|
|
548511
|
+
recordTranscript(messages);
|
|
548512
|
+
}
|
|
548513
|
+
yield* normalizeMessage(message);
|
|
548514
|
+
break;
|
|
548515
|
+
case "user":
|
|
548516
|
+
this.mutableMessages.push(message);
|
|
548517
|
+
if (!this.shouldSuppressCompactRestore(message)) {
|
|
548518
|
+
yield* normalizeMessage(message);
|
|
548519
|
+
}
|
|
548520
|
+
break;
|
|
548521
|
+
case "stream_event":
|
|
548522
|
+
if (message.event.type === "message_start") {
|
|
548523
|
+
currentMessageUsage = EMPTY_USAGE;
|
|
548524
|
+
currentMessageUsage = updateUsage(currentMessageUsage, message.event.message.usage);
|
|
548525
|
+
}
|
|
548526
|
+
if (message.event.type === "message_delta") {
|
|
548527
|
+
currentMessageUsage = updateUsage(currentMessageUsage, message.event.usage);
|
|
548528
|
+
if (message.event.delta.stop_reason != null) {
|
|
548529
|
+
lastStopReason = message.event.delta.stop_reason;
|
|
548530
|
+
}
|
|
548531
|
+
}
|
|
548532
|
+
if (message.event.type === "message_stop") {
|
|
548533
|
+
this.totalUsage = accumulateUsage(this.totalUsage, currentMessageUsage);
|
|
548534
|
+
}
|
|
548535
|
+
if (includePartialMessages) {
|
|
548536
|
+
yield {
|
|
548537
|
+
type: "stream_event",
|
|
548538
|
+
event: message.event,
|
|
548539
|
+
session_id: getSessionId(),
|
|
548540
|
+
parent_tool_use_id: null,
|
|
548541
|
+
uuid: randomUUID51()
|
|
548542
|
+
};
|
|
548543
|
+
}
|
|
548544
|
+
break;
|
|
548545
|
+
case "attachment":
|
|
548546
|
+
this.mutableMessages.push(message);
|
|
548547
|
+
if (persistSession) {
|
|
548548
|
+
messages.push(message);
|
|
548549
|
+
recordTranscript(messages);
|
|
548550
|
+
}
|
|
548551
|
+
if (message.attachment.type === "structured_output") {
|
|
548552
|
+
structuredOutputFromTool = message.attachment.data;
|
|
548553
|
+
} else if (message.attachment.type === "max_turns_reached") {
|
|
548554
|
+
if (persistSession) {
|
|
548555
|
+
if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
|
|
548556
|
+
await flushSessionStorage();
|
|
548557
|
+
}
|
|
548558
|
+
}
|
|
548559
|
+
yield {
|
|
548560
|
+
type: "result",
|
|
548561
|
+
subtype: "error_max_turns",
|
|
548562
|
+
duration_ms: Date.now() - startTime2,
|
|
548563
|
+
duration_api_ms: getTotalAPIDuration(),
|
|
548564
|
+
is_error: true,
|
|
548565
|
+
num_turns: message.attachment.turnCount,
|
|
548566
|
+
stop_reason: lastStopReason,
|
|
548567
|
+
session_id: getSessionId(),
|
|
548568
|
+
total_cost_usd: getTotalCostUSD(),
|
|
548569
|
+
usage: this.totalUsage,
|
|
548570
|
+
modelUsage: getModelUsage(),
|
|
548571
|
+
permission_denials: this.permissionDenials,
|
|
548572
|
+
fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
|
|
548573
|
+
uuid: randomUUID51(),
|
|
548574
|
+
errors: [
|
|
548575
|
+
`Reached maximum number of turns (${message.attachment.maxTurns})`
|
|
548576
|
+
]
|
|
548577
|
+
};
|
|
548578
|
+
return;
|
|
548579
|
+
} else if (replayUserMessages && message.attachment.type === "queued_command") {
|
|
548374
548580
|
yield {
|
|
548375
548581
|
type: "user",
|
|
548376
|
-
message:
|
|
548582
|
+
message: {
|
|
548583
|
+
role: "user",
|
|
548584
|
+
content: message.attachment.prompt
|
|
548585
|
+
},
|
|
548377
548586
|
session_id: getSessionId(),
|
|
548378
548587
|
parent_tool_use_id: null,
|
|
548379
|
-
uuid:
|
|
548380
|
-
timestamp:
|
|
548588
|
+
uuid: message.attachment.source_uuid || message.uuid,
|
|
548589
|
+
timestamp: message.timestamp,
|
|
548381
548590
|
isReplay: true
|
|
548382
548591
|
};
|
|
548383
548592
|
}
|
|
548384
|
-
|
|
548385
|
-
|
|
548386
|
-
|
|
548387
|
-
|
|
548388
|
-
|
|
548389
|
-
|
|
548390
|
-
|
|
548391
|
-
|
|
548392
|
-
|
|
548393
|
-
|
|
548394
|
-
|
|
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;
|
|
548593
|
+
break;
|
|
548594
|
+
case "stream_request_start":
|
|
548595
|
+
break;
|
|
548596
|
+
case "system": {
|
|
548597
|
+
const snipResult = this.config.snipReplay?.(message, this.mutableMessages);
|
|
548598
|
+
if (snipResult !== undefined) {
|
|
548599
|
+
if (snipResult.executed) {
|
|
548600
|
+
this.mutableMessages.length = 0;
|
|
548601
|
+
this.mutableMessages.push(...snipResult.messages);
|
|
548602
|
+
}
|
|
548603
|
+
break;
|
|
548421
548604
|
}
|
|
548605
|
+
this.mutableMessages.push(message);
|
|
548606
|
+
if (message.subtype === "compact_boundary" && message.compactMetadata) {
|
|
548607
|
+
const mutableBoundaryIdx = this.mutableMessages.length - 1;
|
|
548608
|
+
if (mutableBoundaryIdx > 0) {
|
|
548609
|
+
this.mutableMessages.splice(0, mutableBoundaryIdx);
|
|
548610
|
+
}
|
|
548611
|
+
const localBoundaryIdx = messages.length - 1;
|
|
548612
|
+
if (localBoundaryIdx > 0) {
|
|
548613
|
+
messages.splice(0, localBoundaryIdx);
|
|
548614
|
+
}
|
|
548615
|
+
this.compactRestoreBoundaryTimestamp = message.timestamp;
|
|
548616
|
+
yield {
|
|
548617
|
+
type: "system",
|
|
548618
|
+
subtype: "compact_boundary",
|
|
548619
|
+
session_id: getSessionId(),
|
|
548620
|
+
uuid: message.uuid,
|
|
548621
|
+
compact_metadata: toSDKCompactMetadata(message.compactMetadata)
|
|
548622
|
+
};
|
|
548623
|
+
}
|
|
548624
|
+
if (message.subtype === "api_error") {
|
|
548625
|
+
yield {
|
|
548626
|
+
type: "system",
|
|
548627
|
+
subtype: "api_retry",
|
|
548628
|
+
attempt: message.retryAttempt,
|
|
548629
|
+
max_retries: message.maxRetries,
|
|
548630
|
+
retry_delay_ms: message.retryInMs,
|
|
548631
|
+
error_status: message.error.status ?? null,
|
|
548632
|
+
error: categorizeRetryableAPIError(message.error),
|
|
548633
|
+
session_id: getSessionId(),
|
|
548634
|
+
uuid: message.uuid
|
|
548635
|
+
};
|
|
548636
|
+
}
|
|
548637
|
+
if (message.subtype === "informational" && typeof message.content === "string" && (message.content.startsWith("Goal ") || message.content.startsWith("Goal:"))) {
|
|
548638
|
+
yield {
|
|
548639
|
+
type: "system",
|
|
548640
|
+
subtype: "status",
|
|
548641
|
+
status: message.content.slice(0, 500),
|
|
548642
|
+
session_id: getSessionId(),
|
|
548643
|
+
uuid: message.uuid
|
|
548644
|
+
};
|
|
548645
|
+
}
|
|
548646
|
+
break;
|
|
548422
548647
|
}
|
|
548423
|
-
|
|
548424
|
-
this.totalUsage = accumulateUsage(this.totalUsage, currentMessageUsage);
|
|
548425
|
-
}
|
|
548426
|
-
if (includePartialMessages) {
|
|
548648
|
+
case "tool_use_summary":
|
|
548427
548649
|
yield {
|
|
548428
|
-
type: "
|
|
548429
|
-
|
|
548650
|
+
type: "tool_use_summary",
|
|
548651
|
+
summary: message.summary,
|
|
548652
|
+
preceding_tool_use_ids: message.precedingToolUseIds,
|
|
548430
548653
|
session_id: getSessionId(),
|
|
548431
|
-
|
|
548432
|
-
uuid: randomUUID51()
|
|
548654
|
+
uuid: message.uuid
|
|
548433
548655
|
};
|
|
548434
|
-
|
|
548435
|
-
|
|
548436
|
-
|
|
548437
|
-
this.mutableMessages.push(message);
|
|
548656
|
+
break;
|
|
548657
|
+
}
|
|
548658
|
+
if (maxBudgetUsd !== undefined && getTotalCostUSD() >= maxBudgetUsd) {
|
|
548438
548659
|
if (persistSession) {
|
|
548439
|
-
|
|
548440
|
-
|
|
548660
|
+
if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
|
|
548661
|
+
await flushSessionStorage();
|
|
548662
|
+
}
|
|
548441
548663
|
}
|
|
548442
|
-
|
|
548443
|
-
|
|
548444
|
-
|
|
548664
|
+
yield {
|
|
548665
|
+
type: "result",
|
|
548666
|
+
subtype: "error_max_budget_usd",
|
|
548667
|
+
duration_ms: Date.now() - startTime2,
|
|
548668
|
+
duration_api_ms: getTotalAPIDuration(),
|
|
548669
|
+
is_error: true,
|
|
548670
|
+
num_turns: turnCount,
|
|
548671
|
+
stop_reason: lastStopReason,
|
|
548672
|
+
session_id: getSessionId(),
|
|
548673
|
+
total_cost_usd: getTotalCostUSD(),
|
|
548674
|
+
usage: this.totalUsage,
|
|
548675
|
+
modelUsage: getModelUsage(),
|
|
548676
|
+
permission_denials: this.permissionDenials,
|
|
548677
|
+
fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
|
|
548678
|
+
uuid: randomUUID51(),
|
|
548679
|
+
errors: [`Reached maximum budget ($${maxBudgetUsd})`]
|
|
548680
|
+
};
|
|
548681
|
+
return;
|
|
548682
|
+
}
|
|
548683
|
+
if (message.type === "user" && jsonSchema) {
|
|
548684
|
+
const currentCalls = countToolCalls(this.mutableMessages, SYNTHETIC_OUTPUT_TOOL_NAME);
|
|
548685
|
+
const callsThisQuery = currentCalls - initialStructuredOutputCalls;
|
|
548686
|
+
const maxRetries = parseInt(process.env.MAX_STRUCTURED_OUTPUT_RETRIES || "5", 10);
|
|
548687
|
+
if (callsThisQuery >= maxRetries) {
|
|
548445
548688
|
if (persistSession) {
|
|
548446
548689
|
if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
|
|
548447
548690
|
await flushSessionStorage();
|
|
@@ -548449,11 +548692,11 @@ class QueryEngine {
|
|
|
548449
548692
|
}
|
|
548450
548693
|
yield {
|
|
548451
548694
|
type: "result",
|
|
548452
|
-
subtype: "
|
|
548695
|
+
subtype: "error_max_structured_output_retries",
|
|
548453
548696
|
duration_ms: Date.now() - startTime2,
|
|
548454
548697
|
duration_api_ms: getTotalAPIDuration(),
|
|
548455
548698
|
is_error: true,
|
|
548456
|
-
num_turns:
|
|
548699
|
+
num_turns: turnCount,
|
|
548457
548700
|
stop_reason: lastStopReason,
|
|
548458
548701
|
session_id: getSessionId(),
|
|
548459
548702
|
total_cost_usd: getTotalCostUSD(),
|
|
@@ -548463,97 +548706,25 @@ class QueryEngine {
|
|
|
548463
548706
|
fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
|
|
548464
548707
|
uuid: randomUUID51(),
|
|
548465
548708
|
errors: [
|
|
548466
|
-
`
|
|
548709
|
+
`Failed to provide valid structured output after ${maxRetries} attempts`
|
|
548467
548710
|
]
|
|
548468
548711
|
};
|
|
548469
548712
|
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
548713
|
}
|
|
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
548714
|
}
|
|
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
548715
|
}
|
|
548548
|
-
|
|
548549
|
-
|
|
548550
|
-
|
|
548551
|
-
|
|
548552
|
-
|
|
548716
|
+
const result = messages.findLast((m) => m.type === "assistant" || m.type === "user");
|
|
548717
|
+
const edeResultType = result?.type ?? "undefined";
|
|
548718
|
+
const edeLastContentType = result?.type === "assistant" ? last_default(result.message.content)?.type ?? "none" : "n/a";
|
|
548719
|
+
if (persistSession) {
|
|
548720
|
+
if (isEnvTruthy(process.env.MAXIMO_SYNTAX_EAGER_FLUSH) || isEnvTruthy(process.env.MAXIMO_SYNTAX_IS_COWORK)) {
|
|
548721
|
+
await flushSessionStorage();
|
|
548553
548722
|
}
|
|
548723
|
+
}
|
|
548724
|
+
if (!isResultSuccessful(result, lastStopReason)) {
|
|
548554
548725
|
yield {
|
|
548555
548726
|
type: "result",
|
|
548556
|
-
subtype: "
|
|
548727
|
+
subtype: "error_during_execution",
|
|
548557
548728
|
duration_ms: Date.now() - startTime2,
|
|
548558
548729
|
duration_api_ms: getTotalAPIDuration(),
|
|
548559
548730
|
is_error: true,
|
|
@@ -548566,105 +548737,47 @@ class QueryEngine {
|
|
|
548566
548737
|
permission_denials: this.permissionDenials,
|
|
548567
548738
|
fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
|
|
548568
548739
|
uuid: randomUUID51(),
|
|
548569
|
-
errors:
|
|
548740
|
+
errors: (() => {
|
|
548741
|
+
const all4 = getInMemoryErrors();
|
|
548742
|
+
const start = errorLogWatermark ? all4.lastIndexOf(errorLogWatermark) + 1 : 0;
|
|
548743
|
+
return [
|
|
548744
|
+
`[ede_diagnostic] result_type=${edeResultType} last_content_type=${edeLastContentType} stop_reason=${lastStopReason}`,
|
|
548745
|
+
...all4.slice(start).map((_) => _.error)
|
|
548746
|
+
];
|
|
548747
|
+
})()
|
|
548570
548748
|
};
|
|
548571
548749
|
return;
|
|
548572
548750
|
}
|
|
548573
|
-
|
|
548574
|
-
|
|
548575
|
-
|
|
548576
|
-
const
|
|
548577
|
-
if (
|
|
548578
|
-
|
|
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;
|
|
548751
|
+
let textResult = "";
|
|
548752
|
+
let isApiError = false;
|
|
548753
|
+
if (result.type === "assistant") {
|
|
548754
|
+
const lastContent = last_default(result.message.content);
|
|
548755
|
+
if (lastContent?.type === "text" && !SYNTHETIC_MESSAGES.has(lastContent.text)) {
|
|
548756
|
+
textResult = lastContent.text;
|
|
548603
548757
|
}
|
|
548758
|
+
isApiError = Boolean(result.isApiErrorMessage);
|
|
548604
548759
|
}
|
|
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
548760
|
yield {
|
|
548616
548761
|
type: "result",
|
|
548617
|
-
subtype: "
|
|
548762
|
+
subtype: "success",
|
|
548763
|
+
is_error: isApiError,
|
|
548618
548764
|
duration_ms: Date.now() - startTime2,
|
|
548619
548765
|
duration_api_ms: getTotalAPIDuration(),
|
|
548620
|
-
is_error: true,
|
|
548621
548766
|
num_turns: turnCount,
|
|
548767
|
+
result: textResult,
|
|
548622
548768
|
stop_reason: lastStopReason,
|
|
548623
548769
|
session_id: getSessionId(),
|
|
548624
548770
|
total_cost_usd: getTotalCostUSD(),
|
|
548625
548771
|
usage: this.totalUsage,
|
|
548626
548772
|
modelUsage: getModelUsage(),
|
|
548627
548773
|
permission_denials: this.permissionDenials,
|
|
548774
|
+
structured_output: structuredOutputFromTool,
|
|
548628
548775
|
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
|
-
})()
|
|
548776
|
+
uuid: randomUUID51()
|
|
548638
548777
|
};
|
|
548639
|
-
|
|
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);
|
|
548778
|
+
} finally {
|
|
548779
|
+
releaseInitialAutoCompactSkip();
|
|
548649
548780
|
}
|
|
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
548781
|
}
|
|
548669
548782
|
interrupt() {
|
|
548670
548783
|
this.abortController.abort();
|
|
@@ -548757,6 +548870,7 @@ var init_QueryEngine = __esm(() => {
|
|
|
548757
548870
|
init_last();
|
|
548758
548871
|
init_state();
|
|
548759
548872
|
init_maximo();
|
|
548873
|
+
init_autoCompact();
|
|
548760
548874
|
init_logging();
|
|
548761
548875
|
init_strip_ansi();
|
|
548762
548876
|
init_commands2();
|
|
@@ -559327,7 +559441,7 @@ Usage: maximo --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
559327
559441
|
pendingHookMessages
|
|
559328
559442
|
}, renderAndRun);
|
|
559329
559443
|
}
|
|
559330
|
-
}).version("0.1.
|
|
559444
|
+
}).version("0.1.42 (Maximo Syntax)", "-v, --version", "Output the version number");
|
|
559331
559445
|
program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
|
|
559332
559446
|
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
559447
|
if (canUserConfigureAdvisor()) {
|
|
@@ -559866,7 +559980,7 @@ function validateProviderEnvOrExit() {
|
|
|
559866
559980
|
async function main2() {
|
|
559867
559981
|
const args = process.argv.slice(2);
|
|
559868
559982
|
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
|
|
559869
|
-
console.log(`${"0.1.
|
|
559983
|
+
console.log(`${"0.1.42"} (Maximo Syntax)`);
|
|
559870
559984
|
return;
|
|
559871
559985
|
}
|
|
559872
559986
|
validateProviderEnvOrExit();
|
|
@@ -559943,4 +560057,4 @@ async function main2() {
|
|
|
559943
560057
|
}
|
|
559944
560058
|
main2();
|
|
559945
560059
|
|
|
559946
|
-
//# debugId=
|
|
560060
|
+
//# debugId=3875DDE89712754664756E2164756E21
|