@general-liquidity/gordon-cli 0.8.15 → 0.8.16
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/index.js +98 -57
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2141431,7 +2141431,6 @@ When a user asks for market data, prices, candles, or orderbook info, route to S
|
|
|
2141431
2141431
|
});
|
|
2141432
2141432
|
|
|
2141433
2141433
|
// src/infra/agents/contextBudget.ts
|
|
2141434
|
-
import { createHash as createHash10 } from "crypto";
|
|
2141435
2141434
|
function estimateTokens2(text6) {
|
|
2141436
2141435
|
const trimmed = text6.trim();
|
|
2141437
2141436
|
if (!trimmed)
|
|
@@ -2141531,27 +2141530,18 @@ function getActiveIntegrationIds(context11, selection) {
|
|
|
2141531
2141530
|
function isAnthropicProvider(provider) {
|
|
2141532
2141531
|
return provider === "anthropic" || provider.includes("anthropic") || provider === "claude";
|
|
2141533
2141532
|
}
|
|
2141534
|
-
function getPromptCacheMetadata(context11,
|
|
2141533
|
+
function getPromptCacheMetadata(context11, _stablePrefix) {
|
|
2141535
2141534
|
const provider = context11.config.modelConfig?.provider ?? process.env.GORDON_PROVIDER ?? "unknown";
|
|
2141536
2141535
|
if (isAnthropicProvider(provider)) {
|
|
2141537
2141536
|
return {
|
|
2141538
2141537
|
supported: true,
|
|
2141539
|
-
provider
|
|
2141540
|
-
key: "anthropic-stable-prefix"
|
|
2141541
|
-
};
|
|
2141542
|
-
}
|
|
2141543
|
-
if (provider !== "openai") {
|
|
2141544
|
-
return {
|
|
2141545
|
-
supported: false,
|
|
2141546
|
-
provider,
|
|
2141547
|
-
reason: "Prompt-cache key hooks are only enabled on the native OpenAI and Anthropic paths."
|
|
2141538
|
+
provider
|
|
2141548
2141539
|
};
|
|
2141549
2141540
|
}
|
|
2141550
|
-
const hash9 = createHash10("sha256").update(stablePrefix).digest("hex").slice(0, 32);
|
|
2141551
2141541
|
return {
|
|
2141552
|
-
supported:
|
|
2141542
|
+
supported: false,
|
|
2141553
2141543
|
provider,
|
|
2141554
|
-
|
|
2141544
|
+
reason: "Transport-level prompt caching is currently only emitted on the Anthropic path."
|
|
2141555
2141545
|
};
|
|
2141556
2141546
|
}
|
|
2141557
2141547
|
function buildAnthropicCacheControlBlocks(envelope) {
|
|
@@ -2141649,18 +2141639,14 @@ ${userMessage}`].filter(Boolean).join(`
|
|
|
2141649
2141639
|
const report = buildReport(context11, selection, contextPieces, userMessage);
|
|
2141650
2141640
|
latestReports.set(report.threadId, report);
|
|
2141651
2141641
|
const requestOptions = {};
|
|
2141652
|
-
|
|
2141653
|
-
requestOptions.promptCacheKey = report.cache.key;
|
|
2141654
|
-
}
|
|
2141655
|
-
const providerOptions = report.cache.key === "anthropic-stable-prefix" ? { anthropic: { cacheControl: { type: "ephemeral" } } } : undefined;
|
|
2141642
|
+
const providerOptions = report.cache.supported && isAnthropicProvider(report.cache.provider) ? { anthropic: { cacheControl: { type: "ephemeral" } } } : undefined;
|
|
2141656
2141643
|
const messages2 = [];
|
|
2141657
2141644
|
if (stablePrefix.trim()) {
|
|
2141658
2141645
|
messages2.push({
|
|
2141659
2141646
|
role: "system",
|
|
2141660
2141647
|
content: stablePrefix,
|
|
2141661
2141648
|
...providerOptions ? {
|
|
2141662
|
-
providerOptions
|
|
2141663
|
-
experimental_providerMetadata: providerOptions
|
|
2141649
|
+
providerOptions
|
|
2141664
2141650
|
} : {}
|
|
2141665
2141651
|
});
|
|
2141666
2141652
|
}
|
|
@@ -2141698,7 +2141684,7 @@ ${uniqueReminderLines.join(`
|
|
|
2141698
2141684
|
requestOptions,
|
|
2141699
2141685
|
messages: messages2
|
|
2141700
2141686
|
};
|
|
2141701
|
-
if (report.cache.
|
|
2141687
|
+
if (report.cache.supported && isAnthropicProvider(report.cache.provider)) {
|
|
2141702
2141688
|
envelope.anthropicSystemBlocks = buildAnthropicCacheControlBlocks(envelope);
|
|
2141703
2141689
|
}
|
|
2141704
2141690
|
if (providerOptions) {
|
|
@@ -2141738,7 +2141724,7 @@ function formatPromptContextReport(report) {
|
|
|
2141738
2141724
|
if (!report) {
|
|
2141739
2141725
|
return "No prompt/context report is available for this session yet.";
|
|
2141740
2141726
|
}
|
|
2141741
|
-
const cacheLine = report.cache.supported ?
|
|
2141727
|
+
const cacheLine = report.cache.supported ? "Enabled (anthropic-cache-control)" : `Unavailable (${report.cache.reason ?? "unsupported"})`;
|
|
2141742
2141728
|
const usageLine = report.usage ? `${report.usage.promptTokens} prompt / ${report.usage.completionTokens} completion / ${report.usage.totalTokens} total` : "No provider usage reported yet.";
|
|
2141743
2141729
|
const cumulativeUsageLine = report.cumulativeUsage ? `${report.cumulativeUsage.requestCount} req \xB7 ${report.cumulativeUsage.promptTokens} prompt / ${report.cumulativeUsage.completionTokens} completion / ${report.cumulativeUsage.totalTokens} total` : "No cumulative usage recorded yet.";
|
|
2141744
2141730
|
const lines = [
|
|
@@ -2142079,7 +2142065,7 @@ var init_alpaca = __esm(() => {
|
|
|
2142079
2142065
|
});
|
|
2142080
2142066
|
|
|
2142081
2142067
|
// src/infra/broker/adapters/webull.ts
|
|
2142082
|
-
import { createHash as
|
|
2142068
|
+
import { createHash as createHash10, createHmac as createHmac7, randomUUID as randomUUID17 } from "crypto";
|
|
2142083
2142069
|
function parseNumber6(value) {
|
|
2142084
2142070
|
if (value === undefined || value === null || value === "")
|
|
2142085
2142071
|
return 0;
|
|
@@ -2142099,7 +2142085,7 @@ function parseBoolean3(value) {
|
|
|
2142099
2142085
|
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
2142100
2142086
|
}
|
|
2142101
2142087
|
function upperMd5(input) {
|
|
2142102
|
-
return
|
|
2142088
|
+
return createHash10("md5").update(input).digest("hex").toUpperCase();
|
|
2142103
2142089
|
}
|
|
2142104
2142090
|
function upperHmacSha1(secret, payload) {
|
|
2142105
2142091
|
return createHmac7("sha1", secret).update(payload).digest("hex").toUpperCase();
|
|
@@ -2145211,6 +2145197,9 @@ function normalizeWhitespace(message5) {
|
|
|
2145211
2145197
|
function normalizeForDeduplication(message5) {
|
|
2145212
2145198
|
return normalizeWhitespace(message5).toLowerCase();
|
|
2145213
2145199
|
}
|
|
2145200
|
+
function getProviderOptions(message5) {
|
|
2145201
|
+
return "providerOptions" in message5 ? message5.providerOptions : undefined;
|
|
2145202
|
+
}
|
|
2145214
2145203
|
function isMeaningfulUserContent(message5) {
|
|
2145215
2145204
|
const unescaped = RESERVED_MARKERS.reduce((current, marker21) => current.replaceAll(marker21.replace("[", "\\["), ""), message5);
|
|
2145216
2145205
|
return normalizeWhitespace(unescaped).length > 0;
|
|
@@ -2145297,6 +2145286,7 @@ function validateAndRepairModelMessages(messages2) {
|
|
|
2145297
2145286
|
for (const rawMessage of messages2) {
|
|
2145298
2145287
|
const role = rawMessage.role === "system" ? "system" : "user";
|
|
2145299
2145288
|
const normalizedContent = normalizeWhitespace(String(rawMessage.content ?? ""));
|
|
2145289
|
+
const providerOptions = getProviderOptions(rawMessage);
|
|
2145300
2145290
|
if (!normalizedContent) {
|
|
2145301
2145291
|
repairNotes.push(`Dropped empty ${role} message before model call.`);
|
|
2145302
2145292
|
continue;
|
|
@@ -2145307,7 +2145297,7 @@ function validateAndRepairModelMessages(messages2) {
|
|
|
2145307
2145297
|
if (role === "system" && normalizedForDedup.includes("[gordon_runtime_reminders_note]")) {
|
|
2145308
2145298
|
repairNotes.push("Converted a misplaced runtime reminder block into user-side guidance semantics.");
|
|
2145309
2145299
|
}
|
|
2145310
|
-
if (role === "system" && !
|
|
2145300
|
+
if (role === "system" && !providerOptions) {
|
|
2145311
2145301
|
if (seenDynamicSystemBlocks.has(normalizedForDedup)) {
|
|
2145312
2145302
|
repairNotes.push("Dropped a duplicate dynamic system block before provider call.");
|
|
2145313
2145303
|
continue;
|
|
@@ -2145328,18 +2145318,26 @@ function validateAndRepairModelMessages(messages2) {
|
|
|
2145328
2145318
|
}
|
|
2145329
2145319
|
seenUserIntents.add(normalizedForDedup);
|
|
2145330
2145320
|
}
|
|
2145331
|
-
if (previous && previous.role === "system" && role === "system" && !previous
|
|
2145321
|
+
if (previous && previous.role === "system" && role === "system" && !getProviderOptions(previous) && !providerOptions) {
|
|
2145332
2145322
|
previous.content = `${previous.content}
|
|
2145333
2145323
|
|
|
2145334
2145324
|
${sanitizedContent}`;
|
|
2145335
2145325
|
repairNotes.push("Merged adjacent uncached system messages before provider call.");
|
|
2145336
2145326
|
continue;
|
|
2145337
2145327
|
}
|
|
2145338
|
-
|
|
2145339
|
-
|
|
2145340
|
-
|
|
2145341
|
-
|
|
2145342
|
-
|
|
2145328
|
+
if (role === "system") {
|
|
2145329
|
+
repaired.push({
|
|
2145330
|
+
role: "system",
|
|
2145331
|
+
content: sanitizedContent,
|
|
2145332
|
+
...providerOptions ? { providerOptions } : {}
|
|
2145333
|
+
});
|
|
2145334
|
+
} else {
|
|
2145335
|
+
repaired.push({
|
|
2145336
|
+
role: "user",
|
|
2145337
|
+
content: sanitizedContent,
|
|
2145338
|
+
...providerOptions ? { providerOptions } : {}
|
|
2145339
|
+
});
|
|
2145340
|
+
}
|
|
2145343
2145341
|
}
|
|
2145344
2145342
|
if (repaired.length === 0 || repaired[repaired.length - 1]?.role !== "user") {
|
|
2145345
2145343
|
repaired.push({
|
|
@@ -2145623,6 +2145621,16 @@ var init_handoffs = __esm(() => {
|
|
|
2145623
2145621
|
});
|
|
2145624
2145622
|
|
|
2145625
2145623
|
// src/infra/memory/summarizer.ts
|
|
2145624
|
+
function determineCompactionStageFromPressure(contextFillRatio) {
|
|
2145625
|
+
if (contextFillRatio >= COMPACTION_PRESSURE_THRESHOLDS.full)
|
|
2145626
|
+
return "full";
|
|
2145627
|
+
if (contextFillRatio >= COMPACTION_PRESSURE_THRESHOLDS.aggressive)
|
|
2145628
|
+
return "aggressive";
|
|
2145629
|
+
if (contextFillRatio >= COMPACTION_PRESSURE_THRESHOLDS.pruning)
|
|
2145630
|
+
return "pruning";
|
|
2145631
|
+
return "masking";
|
|
2145632
|
+
}
|
|
2145633
|
+
|
|
2145626
2145634
|
class ConversationSummarizer {
|
|
2145627
2145635
|
config;
|
|
2145628
2145636
|
llm;
|
|
@@ -2145632,7 +2145640,7 @@ class ConversationSummarizer {
|
|
|
2145632
2145640
|
logger118.debug("Summarizer initialized", { config: this.config });
|
|
2145633
2145641
|
}
|
|
2145634
2145642
|
shouldSummarize(messages2) {
|
|
2145635
|
-
return messages2.length > this.config.messageThreshold;
|
|
2145643
|
+
return messages2.length > this.config.messageThreshold || this.estimateContextFillRatio(messages2) >= COMPACTION_PRESSURE_THRESHOLDS.masking;
|
|
2145636
2145644
|
}
|
|
2145637
2145645
|
getMessagesToSummarizeCount(messages2) {
|
|
2145638
2145646
|
if (!this.shouldSummarize(messages2)) {
|
|
@@ -2145640,6 +2145648,13 @@ class ConversationSummarizer {
|
|
|
2145640
2145648
|
}
|
|
2145641
2145649
|
return messages2.length - this.config.recentMessagesToKeep;
|
|
2145642
2145650
|
}
|
|
2145651
|
+
estimateMessageTokens(messages2) {
|
|
2145652
|
+
return messages2.reduce((total, message5) => total + Math.ceil(message5.content.length / 4), 0);
|
|
2145653
|
+
}
|
|
2145654
|
+
estimateContextFillRatio(messages2) {
|
|
2145655
|
+
const budget = Math.max(1, this.config.maxContextTokensEstimate);
|
|
2145656
|
+
return Math.min(1, this.estimateMessageTokens(messages2) / budget);
|
|
2145657
|
+
}
|
|
2145643
2145658
|
async summarize(messages2) {
|
|
2145644
2145659
|
if (!this.shouldSummarize(messages2)) {
|
|
2145645
2145660
|
logger118.debug("Summarization not needed", {
|
|
@@ -2145649,16 +2145664,19 @@ class ConversationSummarizer {
|
|
|
2145649
2145664
|
return {
|
|
2145650
2145665
|
summarized: false,
|
|
2145651
2145666
|
messages: messages2,
|
|
2145652
|
-
messagesSummarized: 0
|
|
2145667
|
+
messagesSummarized: 0,
|
|
2145668
|
+
contextFillRatio: this.estimateContextFillRatio(messages2)
|
|
2145653
2145669
|
};
|
|
2145654
2145670
|
}
|
|
2145655
2145671
|
const messagesToSummarize = messages2.length - this.config.recentMessagesToKeep;
|
|
2145656
|
-
const
|
|
2145672
|
+
const contextFillRatio = this.estimateContextFillRatio(messages2);
|
|
2145673
|
+
const compactionStage = determineCompactionStageFromPressure(contextFillRatio);
|
|
2145657
2145674
|
logger118.info("Starting conversation summarization", {
|
|
2145658
2145675
|
totalMessages: messages2.length,
|
|
2145659
2145676
|
messagesToSummarize,
|
|
2145660
2145677
|
keepingRecent: this.config.recentMessagesToKeep,
|
|
2145661
|
-
compactionStage
|
|
2145678
|
+
compactionStage,
|
|
2145679
|
+
contextFillRatio
|
|
2145662
2145680
|
});
|
|
2145663
2145681
|
try {
|
|
2145664
2145682
|
const preservedStableMessages = messages2.filter((message5) => this.isStableContextMessage(message5));
|
|
@@ -2145674,7 +2145692,8 @@ class ConversationSummarizer {
|
|
|
2145674
2145692
|
summarized: false,
|
|
2145675
2145693
|
messages: [...preservedStableMessages, ...recentMessages],
|
|
2145676
2145694
|
messagesSummarized: 0,
|
|
2145677
|
-
compactionStage
|
|
2145695
|
+
compactionStage,
|
|
2145696
|
+
contextFillRatio
|
|
2145678
2145697
|
};
|
|
2145679
2145698
|
}
|
|
2145680
2145699
|
const conversationText = this.formatMessagesForSummary(summarizableOlderMessages);
|
|
@@ -2145702,7 +2145721,8 @@ class ConversationSummarizer {
|
|
|
2145702
2145721
|
messagesSummarized: adjustedMessagesToSummarize,
|
|
2145703
2145722
|
summaryText,
|
|
2145704
2145723
|
tradingContext,
|
|
2145705
|
-
compactionStage
|
|
2145724
|
+
compactionStage,
|
|
2145725
|
+
contextFillRatio
|
|
2145706
2145726
|
};
|
|
2145707
2145727
|
} catch (error56) {
|
|
2145708
2145728
|
logger118.error("Summarization failed, returning original messages", error56);
|
|
@@ -2145710,23 +2145730,11 @@ class ConversationSummarizer {
|
|
|
2145710
2145730
|
summarized: false,
|
|
2145711
2145731
|
messages: messages2,
|
|
2145712
2145732
|
messagesSummarized: 0,
|
|
2145713
|
-
compactionStage
|
|
2145733
|
+
compactionStage,
|
|
2145734
|
+
contextFillRatio
|
|
2145714
2145735
|
};
|
|
2145715
2145736
|
}
|
|
2145716
2145737
|
}
|
|
2145717
|
-
determineCompactionStage(messageCount) {
|
|
2145718
|
-
const overage = messageCount - this.config.messageThreshold;
|
|
2145719
|
-
if (overage >= Math.max(12, Math.floor(this.config.messageThreshold * 1))) {
|
|
2145720
|
-
return "full";
|
|
2145721
|
-
}
|
|
2145722
|
-
if (overage >= Math.max(8, Math.floor(this.config.messageThreshold * 0.75))) {
|
|
2145723
|
-
return "aggressive";
|
|
2145724
|
-
}
|
|
2145725
|
-
if (overage >= Math.max(4, Math.floor(this.config.messageThreshold * 0.35))) {
|
|
2145726
|
-
return "pruning";
|
|
2145727
|
-
}
|
|
2145728
|
-
return "masking";
|
|
2145729
|
-
}
|
|
2145730
2145738
|
getRecentMessagesToKeepForStage(stage) {
|
|
2145731
2145739
|
const observationCount = RECENT_OBSERVATIONS_TO_KEEP[stage];
|
|
2145732
2145740
|
return Math.max(observationCount, Math.min(this.config.recentMessagesToKeep, observationCount + 2));
|
|
@@ -2145992,10 +2146000,11 @@ function createSummarizerConfigFromMemoryConfig(memoryConfig) {
|
|
|
2145992
2146000
|
const recentMessagesToKeep = Math.max(3, Math.floor(lastMessages * 0.25));
|
|
2145993
2146001
|
return {
|
|
2145994
2146002
|
messageThreshold,
|
|
2145995
|
-
recentMessagesToKeep
|
|
2146003
|
+
recentMessagesToKeep,
|
|
2146004
|
+
maxContextTokensEstimate: Math.max(6000, lastMessages * 600)
|
|
2145996
2146005
|
};
|
|
2145997
2146006
|
}
|
|
2145998
|
-
var logger118, DEFAULT_SUMMARIZER_CONFIG, RECENT_OBSERVATIONS_TO_KEEP, SUMMARIZATION_SYSTEM_PROMPT = `You are a trading conversation summarizer. Your job is to create a concise but complete summary of a conversation between a user and Gordon, an AI trading assistant.
|
|
2146007
|
+
var logger118, DEFAULT_SUMMARIZER_CONFIG, COMPACTION_PRESSURE_THRESHOLDS, RECENT_OBSERVATIONS_TO_KEEP, SUMMARIZATION_SYSTEM_PROMPT = `You are a trading conversation summarizer. Your job is to create a concise but complete summary of a conversation between a user and Gordon, an AI trading assistant.
|
|
2145999
2146008
|
|
|
2146000
2146009
|
IMPORTANT: Preserve ALL key trading information including:
|
|
2146001
2146010
|
- Trade decisions made (buy/sell, positions, sizing)
|
|
@@ -2146032,7 +2146041,14 @@ var init_summarizer = __esm(async () => {
|
|
|
2146032
2146041
|
messageThreshold: 20,
|
|
2146033
2146042
|
recentMessagesToKeep: 5,
|
|
2146034
2146043
|
maxSummaryTokens: 1000,
|
|
2146035
|
-
temperature: 0.3
|
|
2146044
|
+
temperature: 0.3,
|
|
2146045
|
+
maxContextTokensEstimate: 12000
|
|
2146046
|
+
};
|
|
2146047
|
+
COMPACTION_PRESSURE_THRESHOLDS = {
|
|
2146048
|
+
masking: 0.7,
|
|
2146049
|
+
pruning: 0.8,
|
|
2146050
|
+
aggressive: 0.9,
|
|
2146051
|
+
full: 0.99
|
|
2146036
2146052
|
};
|
|
2146037
2146053
|
RECENT_OBSERVATIONS_TO_KEEP = {
|
|
2146038
2146054
|
masking: 6,
|
|
@@ -2146670,6 +2146686,12 @@ async function awaitWithAbort(promise4, signal) {
|
|
|
2146670
2146686
|
});
|
|
2146671
2146687
|
});
|
|
2146672
2146688
|
}
|
|
2146689
|
+
function advanceReActStage(current, next) {
|
|
2146690
|
+
if (!REACT_STAGE_TRANSITIONS[current].includes(next)) {
|
|
2146691
|
+
throw new Error(`Invalid ReAct stage transition: ${current} -> ${next}`);
|
|
2146692
|
+
}
|
|
2146693
|
+
return next;
|
|
2146694
|
+
}
|
|
2146673
2146695
|
async function* processMessageStream(userMessage, context11, threadId, resourceId, options3 = {}) {
|
|
2146674
2146696
|
const startTime = Date.now();
|
|
2146675
2146697
|
logger119.debug("Starting streaming message processing", { messageLength: userMessage.length });
|
|
@@ -2146679,7 +2146701,9 @@ async function* processMessageStream(userMessage, context11, threadId, resourceI
|
|
|
2146679
2146701
|
const requestContext = createRequestContext(context11);
|
|
2146680
2146702
|
try {
|
|
2146681
2146703
|
const groundedPrompt = await buildGroundedPrompt(userMessage, context11, requestContext);
|
|
2146704
|
+
let reactStage = "compaction_checked";
|
|
2146682
2146705
|
await throwIfStreamAborted(signal);
|
|
2146706
|
+
reactStage = advanceReActStage(reactStage, "interrupt_checked_before_thinking");
|
|
2146683
2146707
|
let _thinkingResult = null;
|
|
2146684
2146708
|
const _thinkingDepth = getThinkingDepthFromContext(context11);
|
|
2146685
2146709
|
if (_thinkingDepth !== "off") {
|
|
@@ -2146692,9 +2146716,13 @@ async function* processMessageStream(userMessage, context11, threadId, resourceI
|
|
|
2146692
2146716
|
}
|
|
2146693
2146717
|
}
|
|
2146694
2146718
|
}
|
|
2146719
|
+
reactStage = advanceReActStage(reactStage, "thinking_complete");
|
|
2146720
|
+
reactStage = advanceReActStage(reactStage, "ui_drained");
|
|
2146695
2146721
|
await emitEvent("agent:started", { agent: "gordon" });
|
|
2146696
2146722
|
const tracingOptions = createAgentTracingOptions();
|
|
2146697
2146723
|
const effectiveResourceId = resourceId || context11.userId || "default";
|
|
2146724
|
+
await throwIfStreamAborted(signal);
|
|
2146725
|
+
reactStage = advanceReActStage(reactStage, "interrupt_checked_before_action");
|
|
2146698
2146726
|
const streamRequest = gordonAgent().stream(groundedPrompt.messages, {
|
|
2146699
2146727
|
requestContext,
|
|
2146700
2146728
|
...threadId && effectiveResourceId ? {
|
|
@@ -2146707,6 +2146735,7 @@ async function* processMessageStream(userMessage, context11, threadId, resourceI
|
|
|
2146707
2146735
|
...groundedPrompt.requestOptions,
|
|
2146708
2146736
|
...tracingOptions && { tracingOptions }
|
|
2146709
2146737
|
});
|
|
2146738
|
+
reactStage = advanceReActStage(reactStage, "action_started");
|
|
2146710
2146739
|
const streamResult = await awaitWithAbort(streamRequest, signal);
|
|
2146711
2146740
|
let fullText = "";
|
|
2146712
2146741
|
let lastSubAgentToolResult = null;
|
|
@@ -2147222,6 +2147251,7 @@ async function* processMessageStream(userMessage, context11, threadId, resourceI
|
|
|
2147222
2147251
|
usage,
|
|
2147223
2147252
|
agentName: currentAgent
|
|
2147224
2147253
|
};
|
|
2147254
|
+
reactStage = advanceReActStage(reactStage, "response_dispatched");
|
|
2147225
2147255
|
await finalizeAfterRequest(context11, {
|
|
2147226
2147256
|
threadId: threadId ?? context11.threadId,
|
|
2147227
2147257
|
agentName: currentAgent,
|
|
@@ -2147233,6 +2147263,7 @@ async function* processMessageStream(userMessage, context11, threadId, resourceI
|
|
|
2147233
2147263
|
totalTokens: usage.totalTokens
|
|
2147234
2147264
|
}
|
|
2147235
2147265
|
});
|
|
2147266
|
+
reactStage = advanceReActStage(reactStage, "persisted");
|
|
2147236
2147267
|
} catch (err2) {
|
|
2147237
2147268
|
if (err2 instanceof StreamCancelledError) {
|
|
2147238
2147269
|
logger119.info("Streaming cancelled by user", {
|
|
@@ -2147772,7 +2147803,7 @@ function createMessageStreamWorkflow(userMessage, context11, threadId, resourceI
|
|
|
2147772
2147803
|
}
|
|
2147773
2147804
|
};
|
|
2147774
2147805
|
}
|
|
2147775
|
-
var DEFAULT_FALLBACK_CHAIN, backtestCache, BACKTEST_CACHE_TTL_MS, logger119, _summarizer = null, lifecycleSessionContexts, lifecycleProcessHooksRegistered = false, TOOL_AGENT_MAP, handoffHistory, handoffCounter = 0, VALID_HANDOFF_RULES, StreamCancelledError;
|
|
2147806
|
+
var DEFAULT_FALLBACK_CHAIN, backtestCache, BACKTEST_CACHE_TTL_MS, logger119, _summarizer = null, lifecycleSessionContexts, lifecycleProcessHooksRegistered = false, TOOL_AGENT_MAP, handoffHistory, handoffCounter = 0, VALID_HANDOFF_RULES, StreamCancelledError, REACT_STAGE_TRANSITIONS;
|
|
2147776
2147807
|
var init_orchestrator = __esm(async () => {
|
|
2147777
2147808
|
init_request_context();
|
|
2147778
2147809
|
init_integrationGlossary();
|
|
@@ -2148263,6 +2148294,16 @@ var init_orchestrator = __esm(async () => {
|
|
|
2148263
2148294
|
this.name = "StreamCancelledError";
|
|
2148264
2148295
|
}
|
|
2148265
2148296
|
};
|
|
2148297
|
+
REACT_STAGE_TRANSITIONS = {
|
|
2148298
|
+
compaction_checked: ["interrupt_checked_before_thinking"],
|
|
2148299
|
+
interrupt_checked_before_thinking: ["thinking_complete"],
|
|
2148300
|
+
thinking_complete: ["ui_drained"],
|
|
2148301
|
+
ui_drained: ["interrupt_checked_before_action"],
|
|
2148302
|
+
interrupt_checked_before_action: ["action_started"],
|
|
2148303
|
+
action_started: ["response_dispatched"],
|
|
2148304
|
+
response_dispatched: ["persisted"],
|
|
2148305
|
+
persisted: []
|
|
2148306
|
+
};
|
|
2148266
2148307
|
});
|
|
2148267
2148308
|
|
|
2148268
2148309
|
// src/infra/rails/mcp.ts
|
|
@@ -2150203,11 +2150244,11 @@ function getSchemaByName(name16) {
|
|
|
2150203
2150244
|
// src/gateway/store/idempotency-store.ts
|
|
2150204
2150245
|
init_logger2();
|
|
2150205
2150246
|
init_database();
|
|
2150206
|
-
import { createHash as
|
|
2150247
|
+
import { createHash as createHash11 } from "crypto";
|
|
2150207
2150248
|
var logger120 = createModuleLogger("gateway-idempotency");
|
|
2150208
2150249
|
function hashIdempotencyPayload(payload) {
|
|
2150209
2150250
|
const canonical = JSON.stringify(payload ?? {});
|
|
2150210
|
-
return
|
|
2150251
|
+
return createHash11("sha256").update(canonical).digest("hex");
|
|
2150211
2150252
|
}
|
|
2150212
2150253
|
function reserveIdempotencyKey(input) {
|
|
2150213
2150254
|
const key = input.idempotencyKey;
|