open-agents-ai 0.63.0 → 0.65.0
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 +93 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13801,7 +13801,7 @@ Rules:
|
|
|
13801
13801
|
const keepRecentDivisor = tier === "small" ? 2e3 : tier === "medium" ? 3e3 : 4e3;
|
|
13802
13802
|
keepRecent = Math.max(4, Math.min(keepRecentMax, Math.floor(ctx / keepRecentDivisor)));
|
|
13803
13803
|
} else {
|
|
13804
|
-
keepRecent = deep ? 20 : 12;
|
|
13804
|
+
keepRecent = deep ? tier === "small" ? 8 : tier === "medium" ? 14 : 20 : tier === "small" ? 4 : tier === "medium" ? 6 : 12;
|
|
13805
13805
|
}
|
|
13806
13806
|
const maxOutputTokens = ctx > 0 ? Math.min(this.options.maxTokens, Math.max(2048, Math.floor(ctx * 0.25))) : this.options.maxTokens;
|
|
13807
13807
|
const toolOutputCeiling = deep ? 16e3 : 8e3;
|
|
@@ -14088,7 +14088,14 @@ Integrate this guidance into your current approach. Continue working on the task
|
|
|
14088
14088
|
const choiceContent = response.choices[0]?.message?.content ?? "";
|
|
14089
14089
|
const choiceArgs = response.choices[0]?.message?.toolCalls?.map((tc) => JSON.stringify(tc.arguments)).join("") ?? "";
|
|
14090
14090
|
estimatedTokens += Math.ceil((choiceContent.length + choiceArgs.length) / 4);
|
|
14091
|
-
const estimatedContextTokens = Math.ceil(compacted.reduce((sum, m) =>
|
|
14091
|
+
const estimatedContextTokens = Math.ceil(compacted.reduce((sum, m) => {
|
|
14092
|
+
let chars = typeof m.content === "string" ? m.content.length : 100;
|
|
14093
|
+
if (m.tool_calls) {
|
|
14094
|
+
for (const tc of m.tool_calls)
|
|
14095
|
+
chars += tc.function.arguments?.length ?? 0;
|
|
14096
|
+
}
|
|
14097
|
+
return sum + chars;
|
|
14098
|
+
}, 0) / 4);
|
|
14092
14099
|
this.emit({
|
|
14093
14100
|
type: "token_usage",
|
|
14094
14101
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -14386,7 +14393,14 @@ Integrate this guidance into your current approach. Continue working on the task
|
|
|
14386
14393
|
const choiceContent2 = response.choices[0]?.message?.content ?? "";
|
|
14387
14394
|
const choiceArgs2 = response.choices[0]?.message?.toolCalls?.map((tc) => JSON.stringify(tc.arguments)).join("") ?? "";
|
|
14388
14395
|
estimatedTokens += Math.ceil((choiceContent2.length + choiceArgs2.length) / 4);
|
|
14389
|
-
const bfEstCtx = Math.ceil(compactedMsgs.reduce((sum, m) =>
|
|
14396
|
+
const bfEstCtx = Math.ceil(compactedMsgs.reduce((sum, m) => {
|
|
14397
|
+
let chars = typeof m.content === "string" ? m.content.length : 100;
|
|
14398
|
+
if (m.tool_calls) {
|
|
14399
|
+
for (const tc of m.tool_calls)
|
|
14400
|
+
chars += tc.function.arguments?.length ?? 0;
|
|
14401
|
+
}
|
|
14402
|
+
return sum + chars;
|
|
14403
|
+
}, 0) / 4);
|
|
14390
14404
|
this.emit({
|
|
14391
14405
|
type: "token_usage",
|
|
14392
14406
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -14659,12 +14673,19 @@ ${tail}`;
|
|
|
14659
14673
|
if (messages.length < 3)
|
|
14660
14674
|
return messages;
|
|
14661
14675
|
const totalChars = messages.reduce((sum, m) => {
|
|
14676
|
+
let chars = 0;
|
|
14662
14677
|
if (typeof m.content === "string")
|
|
14663
|
-
|
|
14664
|
-
if (Array.isArray(m.content)) {
|
|
14665
|
-
|
|
14678
|
+
chars += m.content.length;
|
|
14679
|
+
else if (Array.isArray(m.content)) {
|
|
14680
|
+
chars += m.content.reduce((s, p) => s + (p.text?.length || 0) + (p.image_url ? 1e3 : 0), 0);
|
|
14681
|
+
}
|
|
14682
|
+
if (m.tool_calls) {
|
|
14683
|
+
for (const tc of m.tool_calls) {
|
|
14684
|
+
chars += tc.function.arguments?.length ?? 0;
|
|
14685
|
+
chars += tc.function.name?.length ?? 0;
|
|
14686
|
+
}
|
|
14666
14687
|
}
|
|
14667
|
-
return sum;
|
|
14688
|
+
return sum + chars;
|
|
14668
14689
|
}, 0);
|
|
14669
14690
|
const estimatedTokens = totalChars / 4;
|
|
14670
14691
|
const limits = this.contextLimits();
|
|
@@ -14758,7 +14779,34 @@ ${fullSummary}
|
|
|
14758
14779
|
[Continue from the recent context below. Do not repeat work already completed above.]`
|
|
14759
14780
|
};
|
|
14760
14781
|
this.persistCheckpoint(fullSummary);
|
|
14761
|
-
|
|
14782
|
+
let result = [...head, compactionMsg, ...recent];
|
|
14783
|
+
const ctxWindow = this.options.contextWindowSize;
|
|
14784
|
+
if (ctxWindow > 0) {
|
|
14785
|
+
const estimateResult = (msgs) => msgs.reduce((sum, m) => {
|
|
14786
|
+
let chars = typeof m.content === "string" ? m.content.length : 100;
|
|
14787
|
+
if (m.tool_calls) {
|
|
14788
|
+
for (const tc of m.tool_calls)
|
|
14789
|
+
chars += tc.function.arguments?.length ?? 0;
|
|
14790
|
+
}
|
|
14791
|
+
return sum + chars;
|
|
14792
|
+
}, 0) / 4;
|
|
14793
|
+
const safetyTarget = Math.floor(ctxWindow * 0.65);
|
|
14794
|
+
let trimmedRecent = [...recent];
|
|
14795
|
+
while (estimateResult(result) > safetyTarget && trimmedRecent.length > 2) {
|
|
14796
|
+
trimmedRecent = trimmedRecent.slice(1);
|
|
14797
|
+
while (trimmedRecent.length > 1 && trimmedRecent[0]?.role === "tool") {
|
|
14798
|
+
trimmedRecent = trimmedRecent.slice(1);
|
|
14799
|
+
}
|
|
14800
|
+
result = [...head, compactionMsg, ...trimmedRecent];
|
|
14801
|
+
}
|
|
14802
|
+
if (trimmedRecent.length < recent.length) {
|
|
14803
|
+
this.emit({
|
|
14804
|
+
type: "status",
|
|
14805
|
+
content: `Post-compaction trim: reduced recent from ${recent.length} to ${trimmedRecent.length} messages to fit ${ctxWindow.toLocaleString()}-token context window`,
|
|
14806
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
14807
|
+
});
|
|
14808
|
+
}
|
|
14809
|
+
}
|
|
14762
14810
|
if (result.length < 2)
|
|
14763
14811
|
return messages;
|
|
14764
14812
|
return result;
|
|
@@ -31567,6 +31615,37 @@ Call task_complete with the JSON array when done.`, onEvent)
|
|
|
31567
31615
|
});
|
|
31568
31616
|
|
|
31569
31617
|
// packages/cli/dist/tui/emotion-engine.js
|
|
31618
|
+
function labelFromCoordinates(valence, arousal) {
|
|
31619
|
+
if (valence > 0.6 && arousal > 0.6)
|
|
31620
|
+
return { label: "exhilarated", emoji: "\u{1F929}" };
|
|
31621
|
+
if (valence > 0.4 && arousal > 0.5)
|
|
31622
|
+
return { label: "excited", emoji: "\u{1F525}" };
|
|
31623
|
+
if (valence > 0.25 && arousal > 0.45)
|
|
31624
|
+
return { label: "energized", emoji: "\u26A1" };
|
|
31625
|
+
if (valence < -0.6 && arousal > 0.6)
|
|
31626
|
+
return { label: "distressed", emoji: "\u{1F630}" };
|
|
31627
|
+
if (valence < -0.3 && arousal > 0.5)
|
|
31628
|
+
return { label: "frustrated", emoji: "\u{1F624}" };
|
|
31629
|
+
if (valence < -0.15 && arousal > 0.4)
|
|
31630
|
+
return { label: "tense", emoji: "\u{1F62C}" };
|
|
31631
|
+
if (valence < -0.5 && arousal < 0.25)
|
|
31632
|
+
return { label: "dejected", emoji: "\u{1F61E}" };
|
|
31633
|
+
if (valence < -0.3 && arousal < 0.35)
|
|
31634
|
+
return { label: "weary", emoji: "\u{1F62E}\u200D\u{1F4A8}" };
|
|
31635
|
+
if (valence < -0.1 && arousal < 0.3)
|
|
31636
|
+
return { label: "cautious", emoji: "\u{1F610}" };
|
|
31637
|
+
if (valence > 0.5 && arousal < 0.25)
|
|
31638
|
+
return { label: "serene", emoji: "\u{1F60C}" };
|
|
31639
|
+
if (valence > 0.3 && arousal < 0.35)
|
|
31640
|
+
return { label: "content", emoji: "\u{1F60A}" };
|
|
31641
|
+
if (valence > 0.15 && arousal < 0.35)
|
|
31642
|
+
return { label: "calm", emoji: "\u{1F642}" };
|
|
31643
|
+
if (valence > 0.2)
|
|
31644
|
+
return { label: "optimistic", emoji: "\u{1F642}" };
|
|
31645
|
+
if (valence < -0.1)
|
|
31646
|
+
return { label: "wary", emoji: "\u{1F928}" };
|
|
31647
|
+
return { label: "curious", emoji: "\u{1F914}" };
|
|
31648
|
+
}
|
|
31570
31649
|
function appraiseEvent(event) {
|
|
31571
31650
|
switch (event.type) {
|
|
31572
31651
|
case "tool_result":
|
|
@@ -31683,6 +31762,9 @@ ${behavioralHint}`;
|
|
|
31683
31762
|
this.state.valence = clamp(this.state.valence + delta.valence * momentum, -1, 1);
|
|
31684
31763
|
this.state.arousal = clamp(this.state.arousal + delta.arousal * momentum, 0, 1);
|
|
31685
31764
|
this.state.updatedAt = Date.now();
|
|
31765
|
+
const deterministicLabel = labelFromCoordinates(this.state.valence, this.state.arousal);
|
|
31766
|
+
this.state.label = deterministicLabel.label;
|
|
31767
|
+
this.state.emoji = deterministicLabel.emoji;
|
|
31686
31768
|
const valenceShift = Math.abs(this.state.valence - this.lastLabelValence);
|
|
31687
31769
|
const arousalShift = Math.abs(this.state.arousal - this.lastLabelArousal);
|
|
31688
31770
|
const significantDrift = valenceShift > LABEL_REGEN_THRESHOLD || arousalShift > LABEL_REGEN_THRESHOLD;
|
|
@@ -34978,6 +35060,9 @@ async function startInteractive(config, repoPath) {
|
|
|
34978
35060
|
if (ctxSize) {
|
|
34979
35061
|
resolvedContextWindowSize = ctxSize;
|
|
34980
35062
|
statusBar.setContextWindowSize(ctxSize);
|
|
35063
|
+
if (activeTask) {
|
|
35064
|
+
activeTask.runner.setContextWindowSize(ctxSize);
|
|
35065
|
+
}
|
|
34981
35066
|
}
|
|
34982
35067
|
}).catch(() => {
|
|
34983
35068
|
});
|
package/package.json
CHANGED