@pentoshi/clai 4.11.2 → 4.11.3
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/agent/runner.js +37 -6
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/tool-history.js +4 -2
- package/dist/agent/tool-history.js.map +1 -1
- package/dist/app/controllers/session-prompt-queue.d.ts +6 -7
- package/dist/app/controllers/session-prompt-queue.js +80 -85
- package/dist/app/controllers/session-prompt-queue.js.map +1 -1
- package/dist/app/controllers/turn-continuation.js +3 -0
- package/dist/app/controllers/turn-continuation.js.map +1 -1
- package/dist/llm/token-estimate-calibration.d.ts +0 -1
- package/dist/llm/token-estimate-calibration.js +3 -3
- package/dist/llm/token-estimate-calibration.js.map +1 -1
- package/dist/llm/tool-protocol.d.ts +1 -0
- package/dist/llm/tool-protocol.js +29 -7
- package/dist/llm/tool-protocol.js.map +1 -1
- package/dist/prompts/embedded.js +1 -1
- package/dist/prompts/embedded.js.map +1 -1
- package/dist/prompts/system.agent.md +5 -5
- package/dist/session-runtime/binding.d.ts +1 -1
- package/dist/session-runtime/binding.js +3 -1
- package/dist/session-runtime/binding.js.map +1 -1
- package/dist/session-runtime/child-bridge.d.ts +7 -2
- package/dist/session-runtime/child-bridge.js +55 -4
- package/dist/session-runtime/child-bridge.js.map +1 -1
- package/dist/session-runtime/client.d.ts +5 -0
- package/dist/session-runtime/client.js +13 -5
- package/dist/session-runtime/client.js.map +1 -1
- package/dist/session-runtime/host.d.ts +7 -0
- package/dist/session-runtime/host.js +112 -19
- package/dist/session-runtime/host.js.map +1 -1
- package/dist/session-runtime/types.d.ts +10 -0
- package/dist/tools/fs.d.ts +0 -5
- package/dist/tools/fs.js +318 -272
- package/dist/tools/fs.js.map +1 -1
- package/dist/tools/shell.d.ts +5 -2
- package/dist/tools/shell.js +313 -20
- package/dist/tools/shell.js.map +1 -1
- package/dist/tui-v2/app/App.js +72 -55
- package/dist/tui-v2/app/App.js.map +1 -1
- package/dist/tui-v2/app/layout-widths.d.ts +21 -0
- package/dist/tui-v2/app/layout-widths.js +50 -0
- package/dist/tui-v2/app/layout-widths.js.map +1 -0
- package/dist/tui-v2/bootstrap/resize-repaint.d.ts +8 -1
- package/dist/tui-v2/bootstrap/resize-repaint.js +8 -0
- package/dist/tui-v2/bootstrap/resize-repaint.js.map +1 -1
- package/dist/tui-v2/bootstrap/start-tui-v2.js +22 -7
- package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -1
- package/dist/tui-v2/components/modal/secret-modal.js +10 -10
- package/dist/tui-v2/components/modal/secret-modal.js.map +1 -1
- package/dist/tui-v2/components/pager/pager.js +6 -1
- package/dist/tui-v2/components/pager/pager.js.map +1 -1
- package/dist/tui-v2/components/transcript/assistant-message.d.ts +2 -0
- package/dist/tui-v2/components/transcript/assistant-message.js +4 -2
- package/dist/tui-v2/components/transcript/assistant-message.js.map +1 -1
- package/dist/tui-v2/components/transcript/compacted-row.js +4 -1
- package/dist/tui-v2/components/transcript/compacted-row.js.map +1 -1
- package/dist/tui-v2/components/transcript/tool-card.js +4 -1
- package/dist/tui-v2/components/transcript/tool-card.js.map +1 -1
- package/dist/tui-v2/components/transcript/transcript-row.js +1 -1
- package/dist/tui-v2/components/transcript/transcript-row.js.map +1 -1
- package/dist/tui-v2/input/chord-from-opentui-key.d.ts +6 -0
- package/dist/tui-v2/input/chord-from-opentui-key.js +32 -6
- package/dist/tui-v2/input/chord-from-opentui-key.js.map +1 -1
- package/dist/tui-v2/input/escape-cancellation.d.ts +7 -0
- package/dist/tui-v2/input/escape-cancellation.js +11 -0
- package/dist/tui-v2/input/escape-cancellation.js.map +1 -0
- package/dist/tui-v2/rendering/pager-markdown.d.ts +4 -0
- package/dist/tui-v2/rendering/pager-markdown.js +2 -0
- package/dist/tui-v2/rendering/pager-markdown.js.map +1 -1
- package/dist/ui-core/actions/chord.d.ts +4 -0
- package/dist/ui-core/actions/chord.js.map +1 -1
- package/dist/ui-core/bootstrap/capabilities.d.ts +6 -0
- package/dist/ui-core/bootstrap/capabilities.js +39 -4
- package/dist/ui-core/bootstrap/capabilities.js.map +1 -1
- package/dist/ui-core/react/use-session-state.d.ts +9 -2
- package/dist/ui-core/react/use-session-state.js +35 -4
- package/dist/ui-core/react/use-session-state.js.map +1 -1
- package/dist/ui-core/rendering/code-block.d.ts +10 -5
- package/dist/ui-core/rendering/code-block.js +68 -40
- package/dist/ui-core/rendering/code-block.js.map +1 -1
- package/dist/ui-core/rendering/markdown.d.ts +6 -3
- package/dist/ui-core/rendering/markdown.js +92 -71
- package/dist/ui-core/rendering/markdown.js.map +1 -1
- package/dist/ui-core/rendering/render-markdown-lines.d.ts +4 -0
- package/dist/ui-core/rendering/render-markdown-lines.js +4 -1
- package/dist/ui-core/rendering/render-markdown-lines.js.map +1 -1
- package/dist/ui-core/rendering/streaming-markdown.js +14 -1
- package/dist/ui-core/rendering/streaming-markdown.js.map +1 -1
- package/dist/version.generated.d.ts +2 -2
- package/dist/version.generated.js +2 -2
- package/package.json +1 -1
package/dist/agent/runner.js
CHANGED
|
@@ -986,6 +986,7 @@ export async function runAgentTurn(prompt, options = {}) {
|
|
|
986
986
|
// provider's reported prompt size below so the estimator learns this route's
|
|
987
987
|
// bias instead of permanently over-reporting it.
|
|
988
988
|
let dispatchedRawRequestTokens = 0;
|
|
989
|
+
let dispatchedRequestRoute;
|
|
989
990
|
let consecutiveSynthesizedRounds = 0;
|
|
990
991
|
const engagementPolicy = new EngagementPolicyEngine();
|
|
991
992
|
const probeStateKey = (call) => {
|
|
@@ -3011,6 +3012,11 @@ export async function runAgentTurn(prompt, options = {}) {
|
|
|
3011
3012
|
}
|
|
3012
3013
|
async function maybeAutoCompact(reason, force = false) {
|
|
3013
3014
|
const beforeTokens = estimateNextRequestTokens(messages);
|
|
3015
|
+
emit({
|
|
3016
|
+
type: "context-estimate",
|
|
3017
|
+
estimatedTokens: beforeTokens,
|
|
3018
|
+
model,
|
|
3019
|
+
});
|
|
3014
3020
|
const contextLimitTokens = currentContextLimitTokens();
|
|
3015
3021
|
const compactTrigger = autoCompactTriggerTokens(getReliabilityPolicy(), {
|
|
3016
3022
|
provider,
|
|
@@ -3351,6 +3357,7 @@ export async function runAgentTurn(prompt, options = {}) {
|
|
|
3351
3357
|
...(contextLimitTokens !== undefined ? { contextLimitTokens } : {}),
|
|
3352
3358
|
}).accounting;
|
|
3353
3359
|
dispatchedRawRequestTokens = finalAccounting.rawRequestTokens;
|
|
3360
|
+
dispatchedRequestRoute = { provider, model };
|
|
3354
3361
|
// The chip reports the request that is actually about to be sent, from
|
|
3355
3362
|
// the same accounting the fit gate and the compaction card use, so the
|
|
3356
3363
|
// three can never disagree.
|
|
@@ -3665,7 +3672,11 @@ export async function runAgentTurn(prompt, options = {}) {
|
|
|
3665
3672
|
provider = completion.provider;
|
|
3666
3673
|
model = completion.model;
|
|
3667
3674
|
if (completion.usage) {
|
|
3668
|
-
|
|
3675
|
+
const requestRouteMatched = dispatchedRequestRoute?.provider === completion.provider &&
|
|
3676
|
+
dispatchedRequestRoute.model === completion.model;
|
|
3677
|
+
if (completion.usage.exact &&
|
|
3678
|
+
completion.usage.promptTokens > 0 &&
|
|
3679
|
+
requestRouteMatched) {
|
|
3669
3680
|
recordRequestTokenObservation({
|
|
3670
3681
|
provider: completion.provider,
|
|
3671
3682
|
model: completion.model,
|
|
@@ -3865,7 +3876,30 @@ export async function runAgentTurn(prompt, options = {}) {
|
|
|
3865
3876
|
// next turn is not orphaned, then nudge for append.
|
|
3866
3877
|
const salvageHistoryCalls = ensureUniqueToolCallIds(nativeToolCalls, toolCallIdsInHistory(messages));
|
|
3867
3878
|
const salvagedCallIndex = nativeToolCalls.indexOf(writeTc);
|
|
3879
|
+
const salvagedToolName = salvaged.operation === "append"
|
|
3880
|
+
? "fs.append"
|
|
3881
|
+
: "fs.write";
|
|
3882
|
+
const salvagedHistoryArgs = {
|
|
3883
|
+
path: salvaged.path,
|
|
3884
|
+
content: salvaged.content,
|
|
3885
|
+
...(salvaged.operation === "append"
|
|
3886
|
+
? {
|
|
3887
|
+
position: "end",
|
|
3888
|
+
...(typeof salvaged.expectedPriorBytes === "number"
|
|
3889
|
+
? { expectedPriorBytes: salvaged.expectedPriorBytes }
|
|
3890
|
+
: {}),
|
|
3891
|
+
}
|
|
3892
|
+
: {}),
|
|
3893
|
+
};
|
|
3868
3894
|
const salvagedCallId = salvageHistoryCalls[salvagedCallIndex]?.id ?? writeTc.id;
|
|
3895
|
+
if (salvagedCallIndex >= 0) {
|
|
3896
|
+
salvageHistoryCalls[salvagedCallIndex] = {
|
|
3897
|
+
id: salvagedCallId,
|
|
3898
|
+
name: salvagedToolName,
|
|
3899
|
+
args: salvagedHistoryArgs,
|
|
3900
|
+
rawArguments: JSON.stringify(salvagedHistoryArgs),
|
|
3901
|
+
};
|
|
3902
|
+
}
|
|
3869
3903
|
appendAssistantWithTools(messages, assistantText.visible, salvageHistoryCalls, completion.reasoningBlock ??
|
|
3870
3904
|
(assistantText.hasThinking && assistantText.thinkContent
|
|
3871
3905
|
? { text: assistantText.thinkContent }
|
|
@@ -3876,17 +3910,14 @@ export async function runAgentTurn(prompt, options = {}) {
|
|
|
3876
3910
|
: `Tool ${tc.name} result (exit=1, ok=false):\nCancelled — sibling write was truncated and salvaged.`, tc.name, tc.id === salvagedCallId);
|
|
3877
3911
|
}
|
|
3878
3912
|
const priorBytes = writeResult.bytesOnDisk;
|
|
3879
|
-
const salvagedToolName = salvaged.operation === "append"
|
|
3880
|
-
? "fs.append"
|
|
3881
|
-
: "fs.write";
|
|
3882
3913
|
const appendNudge = toolsAttached
|
|
3883
3914
|
? `Your ${salvagedToolName} tool call was cut off at the token limit, but the system salvaged the partial content and wrote ${lineCount} lines (file is now ${priorBytes} bytes) to ${salvaged.path}. ` +
|
|
3884
3915
|
`The file ends with: ${JSON.stringify(salvaged.lastLine)}\n\n` +
|
|
3885
|
-
`CONTINUE by calling fs.append
|
|
3916
|
+
`CONTINUE by calling fs.append with path=${JSON.stringify(salvaged.path)}, expectedPriorBytes=${priorBytes}, and content set to ONLY the next remaining chunk not already on disk. Keep each chunk under 24,000 characters and wait for its receipt before sending another. ` +
|
|
3886
3917
|
`Do not re-read the full file; do not re-send content already saved. Use the platform tool interface — no markdown fences.`
|
|
3887
3918
|
: `Your ${salvagedToolName} tool call was cut off at the token limit, but the system salvaged the partial content and wrote ${lineCount} lines (file is now ${priorBytes} bytes) to ${salvaged.path}. ` +
|
|
3888
3919
|
`The file ends with: ${JSON.stringify(salvaged.lastLine)}\n\n` +
|
|
3889
|
-
`CONTINUE with
|
|
3920
|
+
`CONTINUE with one fs.append chunk under 24,000 characters, then wait for its receipt before sending another:\n` +
|
|
3890
3921
|
'```tool\n{"name":"fs.append","args":{"path":' +
|
|
3891
3922
|
JSON.stringify(salvaged.path) +
|
|
3892
3923
|
',"expectedPriorBytes":' +
|