@keystrokehq/keystroke 0.1.82 → 0.1.84
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/action.d.cts +2 -2
- package/dist/action.d.mts +2 -2
- package/dist/agent-types.cjs +1 -1
- package/dist/agent-types.d.cts +2 -2
- package/dist/agent-types.d.mts +2 -2
- package/dist/agent-types.mjs +1 -1
- package/dist/agent.cjs +70 -55
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.d.cts +6 -6
- package/dist/agent.d.mts +6 -6
- package/dist/agent.mjs +19 -6
- package/dist/agent.mjs.map +1 -1
- package/dist/app.d.cts +2 -2
- package/dist/app.d.mts +2 -2
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/{context-compaction-Bxp4WK2B-9Roa_Go7.cjs → context-compaction-D2_B1nky-B5P-jcVq.cjs} +27 -5
- package/dist/context-compaction-D2_B1nky-B5P-jcVq.cjs.map +1 -0
- package/dist/{context-compaction-Bxp4WK2B-BJw7-xJn.mjs → context-compaction-D2_B1nky-BH4LYEIR.mjs} +16 -6
- package/dist/context-compaction-D2_B1nky-BH4LYEIR.mjs.map +1 -0
- package/dist/credentials.d.cts +1 -1
- package/dist/credentials.d.mts +1 -1
- package/dist/{dist-BBUHIiCy.cjs → dist-BBtHuSHr.cjs} +8 -2
- package/dist/{dist-BBUHIiCy.cjs.map → dist-BBtHuSHr.cjs.map} +1 -1
- package/dist/{dist-6IeP9zFU.mjs → dist-BZIQEsLI.mjs} +2 -2
- package/dist/{dist-6IeP9zFU.mjs.map → dist-BZIQEsLI.mjs.map} +1 -1
- package/dist/{dist-DI5TEUn3.cjs → dist-CIuy_U4W.cjs} +2 -2
- package/dist/{dist-DI5TEUn3.cjs.map → dist-CIuy_U4W.cjs.map} +1 -1
- package/dist/{dist-D6MVcMP4.mjs → dist-DpHlMye4.mjs} +3 -3
- package/dist/{dist-D6MVcMP4.mjs.map → dist-DpHlMye4.mjs.map} +1 -1
- package/dist/{index-C0ti6AGs.d.mts → index-BGruu2-9.d.mts} +9 -8
- package/dist/index-BGruu2-9.d.mts.map +1 -0
- package/dist/{index-Cy8K1nkq.d.cts → index-BS9GVhZL.d.cts} +9 -8
- package/dist/index-BS9GVhZL.d.cts.map +1 -0
- package/dist/{index-C6-1mYWX.d.mts → index-BUWzkui_.d.mts} +2 -2
- package/dist/{index-BtzNM6b1.d.cts.map → index-BUWzkui_.d.mts.map} +1 -1
- package/dist/{index-2fQM4f2x.d.cts → index-BZBfoxTW.d.mts} +3 -3
- package/dist/{index-2fQM4f2x.d.cts.map → index-BZBfoxTW.d.mts.map} +1 -1
- package/dist/{index-dzoGze6j.d.cts → index-BiuxubmU.d.cts} +2 -2
- package/dist/{index-DJMl6DSu.d.mts.map → index-BiuxubmU.d.cts.map} +1 -1
- package/dist/{index-BJ6ZvEun.d.mts → index-BuDJO13c.d.cts} +3 -3
- package/dist/{index-BJ6ZvEun.d.mts.map → index-BuDJO13c.d.cts.map} +1 -1
- package/dist/{index-DJMl6DSu.d.mts → index-C05t3LuY.d.mts} +2 -2
- package/dist/{index-dzoGze6j.d.cts.map → index-C05t3LuY.d.mts.map} +1 -1
- package/dist/{index-BtzNM6b1.d.cts → index-CsBKCcPQ.d.cts} +2 -2
- package/dist/{index-C6-1mYWX.d.mts.map → index-CsBKCcPQ.d.cts.map} +1 -1
- package/dist/{index-Bnrig0bt.d.cts → index-DJh_wp_7.d.cts} +2 -2
- package/dist/{index-Bnrig0bt.d.cts.map → index-DJh_wp_7.d.cts.map} +1 -1
- package/dist/{index-BGDEj1cq.d.mts → index-dDHyyZ6y.d.cts} +2 -2
- package/dist/{index-BGDEj1cq.d.cts.map → index-dDHyyZ6y.d.cts.map} +1 -1
- package/dist/{index-BGDEj1cq.d.cts → index-dDHyyZ6y.d.mts} +2 -2
- package/dist/{index-BGDEj1cq.d.mts.map → index-dDHyyZ6y.d.mts.map} +1 -1
- package/dist/{index-DagBDW8r.d.mts → index-vqmxOMVm.d.mts} +2 -2
- package/dist/{index-DagBDW8r.d.mts.map → index-vqmxOMVm.d.mts.map} +1 -1
- package/dist/sandbox.d.cts +2 -2
- package/dist/sandbox.d.mts +2 -2
- package/dist/{schemas-B9dXuD9C-bgRI3JRS.d.mts → schemas-lSbMfQRy-C2bvPXJf.d.mts} +9 -5
- package/dist/schemas-lSbMfQRy-C2bvPXJf.d.mts.map +1 -0
- package/dist/{schemas-B9dXuD9C-DRGMFsVP.d.cts → schemas-lSbMfQRy-poeBiwCM.d.cts} +9 -5
- package/dist/schemas-lSbMfQRy-poeBiwCM.d.cts.map +1 -0
- package/dist/{token-A3WLmCKE.cjs → token-BeAAlWuP.cjs} +2 -2
- package/dist/{token-A3WLmCKE.cjs.map → token-BeAAlWuP.cjs.map} +1 -1
- package/dist/{token-BmCWLwTZ.mjs → token-DOaX-fFI.mjs} +2 -2
- package/dist/{token-BmCWLwTZ.mjs.map → token-DOaX-fFI.mjs.map} +1 -1
- package/dist/trigger.cjs +1 -1
- package/dist/trigger.d.cts +3 -3
- package/dist/trigger.d.mts +3 -3
- package/dist/trigger.mjs +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.d.cts +2 -2
- package/dist/workflow.d.mts +2 -2
- package/dist/workflow.mjs +1 -1
- package/package.json +3 -3
- package/dist/context-compaction-Bxp4WK2B-9Roa_Go7.cjs.map +0 -1
- package/dist/context-compaction-Bxp4WK2B-BJw7-xJn.mjs.map +0 -1
- package/dist/index-C0ti6AGs.d.mts.map +0 -1
- package/dist/index-Cy8K1nkq.d.cts.map +0 -1
- package/dist/schemas-B9dXuD9C-DRGMFsVP.d.cts.map +0 -1
- package/dist/schemas-B9dXuD9C-bgRI3JRS.d.mts.map +0 -1
package/dist/action.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as credentialInputSchema, F as normalizeCredentialList, I as toCredentialRequirement, N as isCredentialInput, T as ResolvedCredentials, _ as DefineStaticCredentialInput, a as CREDENTIAL_SCOPE_TYPES, b as NormalizeCredential, c as CredentialAuthKind, d as CredentialList, f as CredentialRequirement, g as DefineOAuthCredentialInput, h as DefineCredentialInput, j as defineCredential, k as credential, l as CredentialConsumer, m as CredentialScopeType, o as Credential, u as CredentialInput } from "./index-
|
|
2
|
-
import { C as registerWorkflowRunGetter, D as runWithRunSignal, E as runWithMcpCredentialContext, O as runWithinActionExecution, S as registerProjectScopeGetter, T as runOutsideActionExecution, _ as getRunSignal, a as ResolveActionCredentialsFn, b as isStepInvocation, c as WorkflowActionDefinition, d as createStepInvocation, f as defineAction, g as getRegisteredProjectScopeId, h as getRegisteredMcpCredentialContext, i as McpCredentialContext, l as WorkflowRunHandle, m as getActionCredentialRequirements, n as ActionDefinitionInput, o as ResolveActionToolOptions, p as executeAction, r as AgentRunOptions, s as StepInvocation, t as ActionDefinition, u as actionCoreSchema, v as getWorkflowRunHandle, w as resolveActionTool, x as isWithinActionExecution, y as isAction } from "./index-
|
|
1
|
+
import { A as credentialInputSchema, F as normalizeCredentialList, I as toCredentialRequirement, N as isCredentialInput, T as ResolvedCredentials, _ as DefineStaticCredentialInput, a as CREDENTIAL_SCOPE_TYPES, b as NormalizeCredential, c as CredentialAuthKind, d as CredentialList, f as CredentialRequirement, g as DefineOAuthCredentialInput, h as DefineCredentialInput, j as defineCredential, k as credential, l as CredentialConsumer, m as CredentialScopeType, o as Credential, u as CredentialInput } from "./index-dDHyyZ6y.cjs";
|
|
2
|
+
import { C as registerWorkflowRunGetter, D as runWithRunSignal, E as runWithMcpCredentialContext, O as runWithinActionExecution, S as registerProjectScopeGetter, T as runOutsideActionExecution, _ as getRunSignal, a as ResolveActionCredentialsFn, b as isStepInvocation, c as WorkflowActionDefinition, d as createStepInvocation, f as defineAction, g as getRegisteredProjectScopeId, h as getRegisteredMcpCredentialContext, i as McpCredentialContext, l as WorkflowRunHandle, m as getActionCredentialRequirements, n as ActionDefinitionInput, o as ResolveActionToolOptions, p as executeAction, r as AgentRunOptions, s as StepInvocation, t as ActionDefinition, u as actionCoreSchema, v as getWorkflowRunHandle, w as resolveActionTool, x as isWithinActionExecution, y as isAction } from "./index-DJh_wp_7.cjs";
|
|
3
3
|
export { type ActionDefinition, type ActionDefinitionInput, type AgentRunOptions, CREDENTIAL_SCOPE_TYPES, type Credential, type CredentialAuthKind, type CredentialConsumer, type CredentialInput, type CredentialList, type CredentialRequirement, type CredentialScopeType, type DefineCredentialInput, type DefineOAuthCredentialInput, type DefineStaticCredentialInput, type McpCredentialContext, type NormalizeCredential, type ResolveActionCredentialsFn, type ResolveActionToolOptions, type ResolvedCredentials, type StepInvocation, type WorkflowActionDefinition, type WorkflowRunHandle, actionCoreSchema, createStepInvocation, credential, credentialInputSchema, defineAction, defineCredential, executeAction, getActionCredentialRequirements, getRegisteredMcpCredentialContext, getRegisteredProjectScopeId, getRunSignal, getWorkflowRunHandle, isAction, isCredentialInput, isStepInvocation, isWithinActionExecution, normalizeCredentialList, registerProjectScopeGetter, registerWorkflowRunGetter, resolveActionTool, runOutsideActionExecution, runWithMcpCredentialContext, runWithRunSignal, runWithinActionExecution, toCredentialRequirement };
|
package/dist/action.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as credentialInputSchema, F as normalizeCredentialList, I as toCredentialRequirement, N as isCredentialInput, T as ResolvedCredentials, _ as DefineStaticCredentialInput, a as CREDENTIAL_SCOPE_TYPES, b as NormalizeCredential, c as CredentialAuthKind, d as CredentialList, f as CredentialRequirement, g as DefineOAuthCredentialInput, h as DefineCredentialInput, j as defineCredential, k as credential, l as CredentialConsumer, m as CredentialScopeType, o as Credential, u as CredentialInput } from "./index-
|
|
2
|
-
import { C as registerWorkflowRunGetter, D as runWithRunSignal, E as runWithMcpCredentialContext, O as runWithinActionExecution, S as registerProjectScopeGetter, T as runOutsideActionExecution, _ as getRunSignal, a as ResolveActionCredentialsFn, b as isStepInvocation, c as WorkflowActionDefinition, d as createStepInvocation, f as defineAction, g as getRegisteredProjectScopeId, h as getRegisteredMcpCredentialContext, i as McpCredentialContext, l as WorkflowRunHandle, m as getActionCredentialRequirements, n as ActionDefinitionInput, o as ResolveActionToolOptions, p as executeAction, r as AgentRunOptions, s as StepInvocation, t as ActionDefinition, u as actionCoreSchema, v as getWorkflowRunHandle, w as resolveActionTool, x as isWithinActionExecution, y as isAction } from "./index-
|
|
1
|
+
import { A as credentialInputSchema, F as normalizeCredentialList, I as toCredentialRequirement, N as isCredentialInput, T as ResolvedCredentials, _ as DefineStaticCredentialInput, a as CREDENTIAL_SCOPE_TYPES, b as NormalizeCredential, c as CredentialAuthKind, d as CredentialList, f as CredentialRequirement, g as DefineOAuthCredentialInput, h as DefineCredentialInput, j as defineCredential, k as credential, l as CredentialConsumer, m as CredentialScopeType, o as Credential, u as CredentialInput } from "./index-dDHyyZ6y.mjs";
|
|
2
|
+
import { C as registerWorkflowRunGetter, D as runWithRunSignal, E as runWithMcpCredentialContext, O as runWithinActionExecution, S as registerProjectScopeGetter, T as runOutsideActionExecution, _ as getRunSignal, a as ResolveActionCredentialsFn, b as isStepInvocation, c as WorkflowActionDefinition, d as createStepInvocation, f as defineAction, g as getRegisteredProjectScopeId, h as getRegisteredMcpCredentialContext, i as McpCredentialContext, l as WorkflowRunHandle, m as getActionCredentialRequirements, n as ActionDefinitionInput, o as ResolveActionToolOptions, p as executeAction, r as AgentRunOptions, s as StepInvocation, t as ActionDefinition, u as actionCoreSchema, v as getWorkflowRunHandle, w as resolveActionTool, x as isWithinActionExecution, y as isAction } from "./index-vqmxOMVm.mjs";
|
|
3
3
|
export { type ActionDefinition, type ActionDefinitionInput, type AgentRunOptions, CREDENTIAL_SCOPE_TYPES, type Credential, type CredentialAuthKind, type CredentialConsumer, type CredentialInput, type CredentialList, type CredentialRequirement, type CredentialScopeType, type DefineCredentialInput, type DefineOAuthCredentialInput, type DefineStaticCredentialInput, type McpCredentialContext, type NormalizeCredential, type ResolveActionCredentialsFn, type ResolveActionToolOptions, type ResolvedCredentials, type StepInvocation, type WorkflowActionDefinition, type WorkflowRunHandle, actionCoreSchema, createStepInvocation, credential, credentialInputSchema, defineAction, defineCredential, executeAction, getActionCredentialRequirements, getRegisteredMcpCredentialContext, getRegisteredProjectScopeId, getRunSignal, getWorkflowRunHandle, isAction, isCredentialInput, isStepInvocation, isWithinActionExecution, normalizeCredentialList, registerProjectScopeGetter, registerWorkflowRunGetter, resolveActionTool, runOutsideActionExecution, runWithMcpCredentialContext, runWithRunSignal, runWithinActionExecution, toCredentialRequirement };
|
package/dist/agent-types.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require("./context-compaction-
|
|
1
|
+
require("./context-compaction-D2_B1nky-B5P-jcVq.cjs");
|
package/dist/agent-types.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as AgentToolUpdateCallback, n as AgentToolParameters, r as AgentToolResult, t as AgentTool } from "./index-
|
|
1
|
+
import { i as AgentToolUpdateCallback, n as AgentToolParameters, r as AgentToolResult, t as AgentTool } from "./index-dDHyyZ6y.cjs";
|
|
2
2
|
import { a as UIMessage } from "./index-GJs4NjSJ.cjs";
|
|
3
|
-
import { c as AgentStreamEvent,
|
|
3
|
+
import { c as AgentStreamEvent, i as AgentMessage, p as ThinkingLevel, s as AgentStepStartEvent, t as AgentContextCompactedEvent } from "./schemas-lSbMfQRy-poeBiwCM.cjs";
|
|
4
4
|
export { AgentContextCompactedEvent, AgentMessage, AgentStepStartEvent, AgentStreamEvent, type AgentTool, type AgentToolParameters, type AgentToolResult, type AgentToolUpdateCallback, ThinkingLevel, type UIMessage };
|
package/dist/agent-types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as AgentToolUpdateCallback, n as AgentToolParameters, r as AgentToolResult, t as AgentTool } from "./index-
|
|
1
|
+
import { i as AgentToolUpdateCallback, n as AgentToolParameters, r as AgentToolResult, t as AgentTool } from "./index-dDHyyZ6y.mjs";
|
|
2
2
|
import { a as UIMessage } from "./index-BolOkiNw.mjs";
|
|
3
|
-
import { c as AgentStreamEvent,
|
|
3
|
+
import { c as AgentStreamEvent, i as AgentMessage, p as ThinkingLevel, s as AgentStepStartEvent, t as AgentContextCompactedEvent } from "./schemas-lSbMfQRy-C2bvPXJf.mjs";
|
|
4
4
|
export { AgentContextCompactedEvent, AgentMessage, AgentStepStartEvent, AgentStreamEvent, type AgentTool, type AgentToolParameters, type AgentToolResult, type AgentToolUpdateCallback, ThinkingLevel, type UIMessage };
|
package/dist/agent-types.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "./context-compaction-
|
|
1
|
+
import "./context-compaction-D2_B1nky-BH4LYEIR.mjs";
|
|
2
2
|
export {};
|
package/dist/agent.cjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_dist = require("./dist-WQXy4GAY.cjs");
|
|
3
3
|
const require_dist$1 = require("./dist-CvYt8qNc.cjs");
|
|
4
|
-
const require_dist$2 = require("./dist-
|
|
5
|
-
const require_dist$3 = require("./dist-
|
|
6
|
-
const
|
|
4
|
+
const require_dist$2 = require("./dist-BBtHuSHr.cjs");
|
|
5
|
+
const require_dist$3 = require("./dist-CIuy_U4W.cjs");
|
|
6
|
+
const require_context_compaction_D2_B1nky = require("./context-compaction-D2_B1nky-B5P-jcVq.cjs");
|
|
7
7
|
const require_dist$4 = require("./dist-D5fdJhcE.cjs");
|
|
8
8
|
let zod = require("zod");
|
|
9
9
|
let node_async_hooks = require("node:async_hooks");
|
|
10
10
|
let node_fs = require("node:fs");
|
|
11
11
|
let node_path = require("node:path");
|
|
12
|
+
require("node:crypto");
|
|
12
13
|
let node_os = require("node:os");
|
|
13
14
|
let node_fs_promises = require("node:fs/promises");
|
|
14
15
|
let node_sqlite = require("node:sqlite");
|
|
@@ -773,14 +774,14 @@ function buildMemoryFromHandle(config, db) {
|
|
|
773
774
|
//#region ../agent/dist/index.mjs
|
|
774
775
|
/** Replace unsupported `FileUIPart`s with text placeholders before model conversion. */
|
|
775
776
|
function applyCapabilityPlaceholderToMessages(messages, capabilities) {
|
|
776
|
-
return
|
|
777
|
+
return require_context_compaction_D2_B1nky.mapMessageFileParts(messages, (part) => require_dist.modelSupportsMediaType(capabilities, part.mediaType) ? part : {
|
|
777
778
|
type: "text",
|
|
778
|
-
text:
|
|
779
|
+
text: require_context_compaction_D2_B1nky.attachmentPlaceholderText(part.filename, part.mediaType)
|
|
779
780
|
});
|
|
780
781
|
}
|
|
781
782
|
/** Resolve private chat attachment paths to data URLs before `convertToModelMessages`. */
|
|
782
783
|
async function hydrateChatAttachmentMessages(messages, download) {
|
|
783
|
-
return
|
|
784
|
+
return require_context_compaction_D2_B1nky.mapMessageFileParts(messages, async (part) => {
|
|
784
785
|
if (!require_dist.parseChatAttachmentServePath(part.url)) return part;
|
|
785
786
|
const [result] = await download([{
|
|
786
787
|
url: new URL(part.url, "http://local"),
|
|
@@ -814,7 +815,7 @@ function gateToolResultOutput(output, capabilities) {
|
|
|
814
815
|
if (!mediaType || require_dist.modelSupportsMediaType(capabilities, mediaType)) return [part];
|
|
815
816
|
return [{
|
|
816
817
|
type: "text",
|
|
817
|
-
text:
|
|
818
|
+
text: require_context_compaction_D2_B1nky.attachmentPlaceholderText(void 0, mediaType)
|
|
818
819
|
}];
|
|
819
820
|
})
|
|
820
821
|
};
|
|
@@ -956,7 +957,7 @@ const SUBMIT_TOOL_VENDORS = new Set([
|
|
|
956
957
|
"deepseek"
|
|
957
958
|
]);
|
|
958
959
|
function structuredOutputSubmitToolVendor(modelId) {
|
|
959
|
-
const { vendor } =
|
|
960
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(modelId);
|
|
960
961
|
return SUBMIT_TOOL_VENDORS.has(vendor);
|
|
961
962
|
}
|
|
962
963
|
/**
|
|
@@ -969,7 +970,7 @@ function structuredOutputSubmitToolVendor(modelId) {
|
|
|
969
970
|
function usesStructuredOutputSubmitTool(args) {
|
|
970
971
|
if (!args.structuredOutput || !structuredOutputSubmitToolVendor(args.modelId)) return false;
|
|
971
972
|
if (args.promptLlm) return true;
|
|
972
|
-
const { vendor } =
|
|
973
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
973
974
|
return (vendor === "zai" || vendor === "alibaba") && (args.hasTools ?? false);
|
|
974
975
|
}
|
|
975
976
|
function appendStructuredOutputSubmitTool(tools, schema) {
|
|
@@ -986,6 +987,15 @@ function resolveStructuredOutputStopWhen(args) {
|
|
|
986
987
|
if (!usesStructuredOutputSubmitTool(args)) return;
|
|
987
988
|
return require_dist$2.hasToolCall(STRUCTURED_OUTPUT_SUBMIT_TOOL_NAME);
|
|
988
989
|
}
|
|
990
|
+
/**
|
|
991
|
+
* Always apply the agent step cap; combine with structured-output submit-tool stop when needed.
|
|
992
|
+
* Passing this explicitly keeps the AI SDK from falling back to its ToolLoopAgent default of 20.
|
|
993
|
+
*/
|
|
994
|
+
function resolveAgentStopWhen(args) {
|
|
995
|
+
const stepLimit = require_dist$2.isStepCount(args.maxSteps);
|
|
996
|
+
const structuredStop = resolveStructuredOutputStopWhen(args);
|
|
997
|
+
return structuredStop ? [stepLimit, structuredStop] : stepLimit;
|
|
998
|
+
}
|
|
989
999
|
function extractStructuredOutputFromSubmitTool(args) {
|
|
990
1000
|
for (let index = args.steps.length - 1; index >= 0; index -= 1) {
|
|
991
1001
|
const step = args.steps[index];
|
|
@@ -999,7 +1009,7 @@ function extractStructuredOutputFromSubmitTool(args) {
|
|
|
999
1009
|
*/
|
|
1000
1010
|
function augmentInstructionsForStructuredOutput(args) {
|
|
1001
1011
|
if (!args.structuredOutput) return args.instructions;
|
|
1002
|
-
const { vendor } =
|
|
1012
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
1003
1013
|
let instructions = args.instructions;
|
|
1004
1014
|
const submitTool = usesStructuredOutputSubmitTool({
|
|
1005
1015
|
modelId: args.modelId,
|
|
@@ -1042,7 +1052,7 @@ function parseRepairedStructuredOutput(args) {
|
|
|
1042
1052
|
*/
|
|
1043
1053
|
function resolveProviderOptions(args) {
|
|
1044
1054
|
if (!args.structuredOutput) return;
|
|
1045
|
-
const { vendor } =
|
|
1055
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
1046
1056
|
if (vendor === "anthropic") return { anthropic: { structuredOutputMode: "outputFormat" } };
|
|
1047
1057
|
}
|
|
1048
1058
|
/**
|
|
@@ -1058,7 +1068,7 @@ function wrapLanguageModelForStructuredOutput(args) {
|
|
|
1058
1068
|
structuredOutput: args.structuredOutput,
|
|
1059
1069
|
hasTools: args.hasTools ?? false
|
|
1060
1070
|
})) return args.languageModel;
|
|
1061
|
-
const { vendor } =
|
|
1071
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
1062
1072
|
if (vendor !== "zai") return args.languageModel;
|
|
1063
1073
|
return require_dist$2.wrapLanguageModel({
|
|
1064
1074
|
model: args.languageModel,
|
|
@@ -1066,7 +1076,7 @@ function wrapLanguageModelForStructuredOutput(args) {
|
|
|
1066
1076
|
});
|
|
1067
1077
|
}
|
|
1068
1078
|
function needsStructuredOutputToolGuard(modelId) {
|
|
1069
|
-
const { vendor, directId } =
|
|
1079
|
+
const { vendor, directId } = require_context_compaction_D2_B1nky.splitAgentModelId(modelId);
|
|
1070
1080
|
if (vendor === "anthropic") return !directId.includes("haiku");
|
|
1071
1081
|
return false;
|
|
1072
1082
|
}
|
|
@@ -1097,14 +1107,14 @@ function resolveReasoningForStructuredOutputPromptLlm(args) {
|
|
|
1097
1107
|
structuredOutput: args.structuredOutput,
|
|
1098
1108
|
promptLlm: true
|
|
1099
1109
|
})) return args.thinkingLevel;
|
|
1100
|
-
const { vendor } =
|
|
1110
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
1101
1111
|
if (vendor === "alibaba" || vendor === "minimax") return "none";
|
|
1102
1112
|
return args.thinkingLevel;
|
|
1103
1113
|
}
|
|
1104
1114
|
/** Alibaba may require the word "json" in user messages when response_format is enabled. */
|
|
1105
1115
|
function augmentInputForStructuredOutput(args) {
|
|
1106
1116
|
if (!args.structuredOutput) return args.input;
|
|
1107
|
-
const { vendor } =
|
|
1117
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
1108
1118
|
if (vendor !== "alibaba") return args.input;
|
|
1109
1119
|
if (/\bjson\b/i.test(args.input)) return args.input;
|
|
1110
1120
|
return `${args.input}\n\nReturn the final answer as json matching the schema.`;
|
|
@@ -1188,8 +1198,8 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1188
1198
|
structuredOutput,
|
|
1189
1199
|
hasTools
|
|
1190
1200
|
});
|
|
1191
|
-
const budgetTracker = new
|
|
1192
|
-
const budgetOverheadChars =
|
|
1201
|
+
const budgetTracker = new require_context_compaction_D2_B1nky.ContextBudgetTracker(require_context_compaction_D2_B1nky.resolveContextBudget(config.resolvedModel));
|
|
1202
|
+
const budgetOverheadChars = require_context_compaction_D2_B1nky.estimateSerializedChars({
|
|
1193
1203
|
systemPrompt: config.systemPrompt,
|
|
1194
1204
|
tools: aiTools
|
|
1195
1205
|
});
|
|
@@ -1204,10 +1214,10 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1204
1214
|
if (estimate?.decision === "compact" && !compactionInFlight) {
|
|
1205
1215
|
compactionInFlight = (async () => {
|
|
1206
1216
|
try {
|
|
1207
|
-
const compacted = await
|
|
1217
|
+
const compacted = await require_context_compaction_D2_B1nky.compactModelMessages({
|
|
1208
1218
|
messages: stepArgs.messages,
|
|
1209
1219
|
sourceModel: config.resolvedModel.modelId,
|
|
1210
|
-
compactionModelId:
|
|
1220
|
+
compactionModelId: require_context_compaction_D2_B1nky.resolveCompactionModelId(config.compactionModelId),
|
|
1211
1221
|
compactedThroughSeq: config.compactedThroughSeq ?? 0,
|
|
1212
1222
|
durable: false,
|
|
1213
1223
|
estimatedBeforeTokens: estimate.estimatedInputTokens,
|
|
@@ -1252,7 +1262,8 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1252
1262
|
if (lastCompactedMessages) lastCompactedMessages = null;
|
|
1253
1263
|
return result;
|
|
1254
1264
|
};
|
|
1255
|
-
const stopWhen =
|
|
1265
|
+
const stopWhen = resolveAgentStopWhen({
|
|
1266
|
+
maxSteps: config.maxSteps,
|
|
1256
1267
|
modelId: config.resolvedModel.modelId,
|
|
1257
1268
|
structuredOutput,
|
|
1258
1269
|
hasTools
|
|
@@ -1276,7 +1287,7 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1276
1287
|
...!submitToolOutput && options.outputSchema ? { output: require_dist$2.output_exports.object({ schema: options.outputSchema }) } : {},
|
|
1277
1288
|
...providerOptions ? { providerOptions } : {},
|
|
1278
1289
|
prepareStep: prepareStepOnce,
|
|
1279
|
-
|
|
1290
|
+
stopWhen
|
|
1280
1291
|
}).stream({
|
|
1281
1292
|
messages: modelMessages,
|
|
1282
1293
|
abortSignal: options.signal,
|
|
@@ -1306,8 +1317,8 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1306
1317
|
budgetTracker.recordStepUsage(inputTokens);
|
|
1307
1318
|
await emit({
|
|
1308
1319
|
type: "usage_record",
|
|
1309
|
-
usage:
|
|
1310
|
-
byok:
|
|
1320
|
+
usage: require_context_compaction_D2_B1nky.llmUsageFromLanguageModelUsage(step.usage, config.resolvedModel, {
|
|
1321
|
+
byok: require_context_compaction_D2_B1nky.byokFromResponseHeaders(step.response.headers),
|
|
1311
1322
|
stepRef: `${step.callId}:${step.stepNumber}`
|
|
1312
1323
|
})
|
|
1313
1324
|
});
|
|
@@ -1527,7 +1538,7 @@ async function generateSessionTitle(message) {
|
|
|
1527
1538
|
const input = message.trim();
|
|
1528
1539
|
if (!input) return null;
|
|
1529
1540
|
const { text } = await require_dist$2.generateText({
|
|
1530
|
-
model: (await
|
|
1541
|
+
model: (await require_context_compaction_D2_B1nky.resolveAgentModel(TITLE_MODEL_ID)).languageModel,
|
|
1531
1542
|
system: TITLE_SYSTEM_PROMPT,
|
|
1532
1543
|
prompt: input.slice(0, MAX_INPUT_CHARS),
|
|
1533
1544
|
maxOutputTokens: 512,
|
|
@@ -1641,13 +1652,13 @@ async function loadSessionModelContext(sessionId) {
|
|
|
1641
1652
|
for (let index = allEvents.length - 1; index >= 0; index -= 1) {
|
|
1642
1653
|
const event = allEvents[index];
|
|
1643
1654
|
if (event.eventType !== "context_compacted") continue;
|
|
1644
|
-
const parsed =
|
|
1655
|
+
const parsed = require_context_compaction_D2_B1nky.parseContextCompactionCheckpoint(event.payload);
|
|
1645
1656
|
if (parsed?.durable) {
|
|
1646
1657
|
checkpoint = parsed;
|
|
1647
1658
|
break;
|
|
1648
1659
|
}
|
|
1649
1660
|
}
|
|
1650
|
-
const modelMessages =
|
|
1661
|
+
const modelMessages = require_context_compaction_D2_B1nky.rebuildMessagesFromCheckpoint({
|
|
1651
1662
|
checkpoint,
|
|
1652
1663
|
messageEvents: messageEvents.map((event) => ({
|
|
1653
1664
|
seq: event.seq,
|
|
@@ -1706,7 +1717,7 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1706
1717
|
finalizeOnly: resume.complete
|
|
1707
1718
|
});
|
|
1708
1719
|
const titleSource = priorMessages.length === 0 ? require_dist.stripPromptContext(input.message.trim()) || input.files?.map((file) => file.filename ?? file.mediaType).join(", ") || "" : "";
|
|
1709
|
-
const titleTask = priorMessages.length === 0 && titleSource.length > 0 ?
|
|
1720
|
+
const titleTask = priorMessages.length === 0 && titleSource.length > 0 ? require_context_compaction_D2_B1nky.withLlmRunContext({
|
|
1710
1721
|
runId: sessionId,
|
|
1711
1722
|
runKind: "agent",
|
|
1712
1723
|
skipUsage: true
|
|
@@ -1781,26 +1792,26 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1781
1792
|
throw error;
|
|
1782
1793
|
}
|
|
1783
1794
|
const activeRuntime = runtime;
|
|
1784
|
-
const budget =
|
|
1795
|
+
const budget = require_context_compaction_D2_B1nky.resolveContextBudget(activeRuntime.runConfig.resolvedModel);
|
|
1785
1796
|
if (budget && modelMessages.length > 0) {
|
|
1786
|
-
const tracker = new
|
|
1787
|
-
const modelMsgs = await require_dist$2.convertToModelMessages(await
|
|
1797
|
+
const tracker = new require_context_compaction_D2_B1nky.ContextBudgetTracker(budget);
|
|
1798
|
+
const modelMsgs = await require_dist$2.convertToModelMessages(await require_context_compaction_D2_B1nky.placeholderChatAttachmentMessages(modelMessages));
|
|
1788
1799
|
const estimate = tracker.estimate({
|
|
1789
1800
|
systemPrompt: activeRuntime.runConfig.systemPrompt,
|
|
1790
1801
|
messages: modelMsgs,
|
|
1791
1802
|
tools: activeRuntime.tools,
|
|
1792
|
-
extraMessageTokens:
|
|
1803
|
+
extraMessageTokens: require_context_compaction_D2_B1nky.estimateChatAttachmentTokens(modelMessages)
|
|
1793
1804
|
});
|
|
1794
1805
|
if (estimate?.decision === "compact") try {
|
|
1795
1806
|
const priorDurable = activeCheckpoint?.durable === true ? activeCheckpoint : null;
|
|
1796
|
-
const suffixModel = await require_dist$2.convertToModelMessages(await
|
|
1797
|
-
const compacted = await
|
|
1807
|
+
const suffixModel = await require_dist$2.convertToModelMessages(await require_context_compaction_D2_B1nky.placeholderChatAttachmentMessages(priorDurable ? sessionContext.messageEvents.filter((event) => event.seq > priorDurable.compactedThroughSeq).map((event) => event.message) : modelMessages));
|
|
1808
|
+
const compacted = await require_context_compaction_D2_B1nky.withLlmRunContext({
|
|
1798
1809
|
runId: sessionId,
|
|
1799
1810
|
runKind: "agent"
|
|
1800
|
-
}, () =>
|
|
1811
|
+
}, () => require_context_compaction_D2_B1nky.compactModelMessages({
|
|
1801
1812
|
messages: suffixModel,
|
|
1802
1813
|
sourceModel: activeRuntime.runConfig.resolvedModel.modelId,
|
|
1803
|
-
compactionModelId:
|
|
1814
|
+
compactionModelId: require_context_compaction_D2_B1nky.resolveCompactionModelId(agent.compactionModel ?? "deepseek/deepseek-v4-flash"),
|
|
1804
1815
|
compactedThroughSeq: (prefixMessageCount) => compactedThroughSeqForPrefix({
|
|
1805
1816
|
checkpoint: priorDurable,
|
|
1806
1817
|
messageEvents: sessionContext.messageEvents,
|
|
@@ -1820,7 +1831,7 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1820
1831
|
checkpoint: compacted.checkpoint
|
|
1821
1832
|
});
|
|
1822
1833
|
activeCheckpoint = compacted.checkpoint;
|
|
1823
|
-
modelMessages = [
|
|
1834
|
+
modelMessages = [require_context_compaction_D2_B1nky.summaryToUiMessage(compacted.checkpoint.summary), ...sessionContext.messageEvents.filter((event) => event.seq > throughSeq).map((event) => event.message)];
|
|
1824
1835
|
activeRuntime.runConfig.messages = modelMessages;
|
|
1825
1836
|
activeRuntime.runConfig.compactedThroughSeq = throughSeq;
|
|
1826
1837
|
} catch (error) {
|
|
@@ -1867,7 +1878,7 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1867
1878
|
let streamResult;
|
|
1868
1879
|
const promptMessage = resume || require_dist.hasAgentTimestampContext(input.message) ? input.message : require_dist.prependAgentUserContext(input.message, { ...options.timezone !== void 0 ? { timezone: options.timezone } : {} });
|
|
1869
1880
|
try {
|
|
1870
|
-
streamResult = await require_dist$2.captureConsole(() =>
|
|
1881
|
+
streamResult = await require_dist$2.captureConsole(() => require_context_compaction_D2_B1nky.withLlmRunContext({
|
|
1871
1882
|
runId: sessionId,
|
|
1872
1883
|
runKind: "agent"
|
|
1873
1884
|
}, () => streamAgentPrompt(activeRuntime.runConfig, promptMessage, {
|
|
@@ -2268,13 +2279,14 @@ async function buildAgentRuntime(def, ctx, runPrompt = {}, agentSlug) {
|
|
|
2268
2279
|
hasSkills: attachedSkills.length > 0
|
|
2269
2280
|
})}\n\n${systemPrompt}`;
|
|
2270
2281
|
if (memory) systemPrompt = `${memory.systemPromptInjection()}\n\n${systemPrompt}`;
|
|
2271
|
-
const thinkingLevel =
|
|
2282
|
+
const thinkingLevel = require_context_compaction_D2_B1nky.resolveThinkingLevel(runPrompt.thinkingLevel ?? def.thinkingLevel);
|
|
2272
2283
|
return {
|
|
2273
2284
|
runConfig: {
|
|
2274
2285
|
systemPrompt,
|
|
2275
|
-
resolvedModel: await
|
|
2286
|
+
resolvedModel: await require_context_compaction_D2_B1nky.resolveAgentModel(def.model),
|
|
2276
2287
|
compactionModelId: def.compactionModel ?? "deepseek/deepseek-v4-flash",
|
|
2277
2288
|
thinkingLevel,
|
|
2289
|
+
maxSteps: def.maxSteps ?? 100,
|
|
2278
2290
|
messages: ctx.messages ?? [],
|
|
2279
2291
|
tools,
|
|
2280
2292
|
mcpToolSet: captured.toolSet,
|
|
@@ -2339,7 +2351,8 @@ function normalizeAgentDefinition(input, options = {}) {
|
|
|
2339
2351
|
return {
|
|
2340
2352
|
systemPrompt: input.systemPrompt,
|
|
2341
2353
|
model: input.model,
|
|
2342
|
-
thinkingLevel:
|
|
2354
|
+
thinkingLevel: require_context_compaction_D2_B1nky.resolveThinkingLevel(input.thinkingLevel),
|
|
2355
|
+
maxSteps: require_context_compaction_D2_B1nky.resolveMaxSteps(input.maxSteps),
|
|
2343
2356
|
...input.compactionModel !== void 0 ? { compactionModel: input.compactionModel } : {},
|
|
2344
2357
|
...input.tools !== void 0 ? { tools: input.tools } : {},
|
|
2345
2358
|
...input.runtimeHooks !== void 0 ? { runtimeHooks: input.runtimeHooks } : {},
|
|
@@ -2739,20 +2752,20 @@ function agentModelIdsFromStoredManifest(manifest) {
|
|
|
2739
2752
|
const ids = [];
|
|
2740
2753
|
for (const entry of manifest.entries) {
|
|
2741
2754
|
if (entry.kind !== "agent") continue;
|
|
2742
|
-
const parsed =
|
|
2755
|
+
const parsed = require_context_compaction_D2_B1nky.AgentModelIdSchema.safeParse(entry.model);
|
|
2743
2756
|
if (parsed.success) ids.push(parsed.data);
|
|
2744
2757
|
if ("compactionModel" in entry && typeof entry.compactionModel === "string") {
|
|
2745
|
-
const compaction =
|
|
2758
|
+
const compaction = require_context_compaction_D2_B1nky.AgentModelIdSchema.safeParse(entry.compactionModel);
|
|
2746
2759
|
if (compaction.success) ids.push(compaction.data);
|
|
2747
2760
|
}
|
|
2748
2761
|
}
|
|
2749
2762
|
return ids;
|
|
2750
2763
|
}
|
|
2751
2764
|
async function resolvePromptModel(model) {
|
|
2752
|
-
return
|
|
2765
|
+
return require_context_compaction_D2_B1nky.resolveAgentModel(require_context_compaction_D2_B1nky.AgentModelIdSchema.parse(model));
|
|
2753
2766
|
}
|
|
2754
2767
|
async function recordUsage(resolved, usage, hooks, responseHeaders) {
|
|
2755
|
-
await hooks?.onUsage?.(
|
|
2768
|
+
await hooks?.onUsage?.(require_context_compaction_D2_B1nky.llmUsageFromLanguageModelUsage(usage, resolved, { byok: require_context_compaction_D2_B1nky.byokFromResponseHeaders(responseHeaders) }));
|
|
2756
2769
|
}
|
|
2757
2770
|
function reasoningCallOption(thinkingLevel) {
|
|
2758
2771
|
return thinkingLevel === void 0 ? {} : { reasoning: thinkingLevel };
|
|
@@ -2858,18 +2871,19 @@ async function runLlm(opts, hooks) {
|
|
|
2858
2871
|
}
|
|
2859
2872
|
//#endregion
|
|
2860
2873
|
exports.AGENT = AGENT;
|
|
2861
|
-
exports.AgentCreateInputSchema =
|
|
2862
|
-
exports.AgentModelIdSchema =
|
|
2863
|
-
exports.DEFAULT_COMPACTION_MODEL_ID =
|
|
2864
|
-
exports.
|
|
2874
|
+
exports.AgentCreateInputSchema = require_context_compaction_D2_B1nky.AgentCreateInputSchema;
|
|
2875
|
+
exports.AgentModelIdSchema = require_context_compaction_D2_B1nky.AgentModelIdSchema;
|
|
2876
|
+
exports.DEFAULT_COMPACTION_MODEL_ID = require_context_compaction_D2_B1nky.DEFAULT_COMPACTION_MODEL_ID;
|
|
2877
|
+
exports.DEFAULT_MAX_STEPS = require_context_compaction_D2_B1nky.DEFAULT_MAX_STEPS;
|
|
2878
|
+
exports.DEFAULT_THINKING_LEVEL = require_context_compaction_D2_B1nky.DEFAULT_THINKING_LEVEL;
|
|
2865
2879
|
exports.SessionAgentMismatchError = SessionAgentMismatchError;
|
|
2866
|
-
exports.ThinkingLevelSchema =
|
|
2880
|
+
exports.ThinkingLevelSchema = require_context_compaction_D2_B1nky.ThinkingLevelSchema;
|
|
2867
2881
|
exports.agentModelIdsFromStoredManifest = agentModelIdsFromStoredManifest;
|
|
2868
2882
|
exports.buildAgentRuntime = buildAgentRuntime;
|
|
2869
2883
|
exports.connectMcpDefinition = require_dist$3.connectMcpDefinition;
|
|
2870
2884
|
exports.connectMcpServer = require_dist$3.connectMcpServer;
|
|
2871
2885
|
exports.connectMcpStdio = require_dist$3.connectMcpStdio;
|
|
2872
|
-
exports.currentLlmRunContext =
|
|
2886
|
+
exports.currentLlmRunContext = require_context_compaction_D2_B1nky.currentLlmRunContext;
|
|
2873
2887
|
exports.defineAgent = defineAgent;
|
|
2874
2888
|
exports.defineMcp = require_dist$3.defineMcp;
|
|
2875
2889
|
exports.defineTool = require_dist.defineTool;
|
|
@@ -2881,21 +2895,22 @@ exports.isWithinAgentPromptExecution = isWithinAgentPromptExecution;
|
|
|
2881
2895
|
exports.loadAssetManifest = require_dist$4.loadAssetManifest;
|
|
2882
2896
|
exports.modelSupportsMediaType = require_dist.modelSupportsMediaType;
|
|
2883
2897
|
exports.normalizeAgentDefinition = normalizeAgentDefinition;
|
|
2884
|
-
exports.parseAgentCreateInput =
|
|
2898
|
+
exports.parseAgentCreateInput = require_context_compaction_D2_B1nky.parseAgentCreateInput;
|
|
2885
2899
|
exports.prepareAgentSession = prepareAgentSession;
|
|
2886
2900
|
exports.resolveAgentAssets = resolveAgentAssets;
|
|
2887
2901
|
exports.resolveAgentId = resolveAgentId;
|
|
2888
|
-
exports.resolveAgentModel =
|
|
2902
|
+
exports.resolveAgentModel = require_context_compaction_D2_B1nky.resolveAgentModel;
|
|
2889
2903
|
exports.resolveAgentTools = resolveAgentTools;
|
|
2890
2904
|
exports.resolveAgentWorkspaceRoot = resolveAgentWorkspaceRoot;
|
|
2891
|
-
exports.
|
|
2892
|
-
exports.
|
|
2905
|
+
exports.resolveMaxSteps = require_context_compaction_D2_B1nky.resolveMaxSteps;
|
|
2906
|
+
exports.resolveModelCapabilities = require_context_compaction_D2_B1nky.resolveModelCapabilities;
|
|
2907
|
+
exports.resolveThinkingLevel = require_context_compaction_D2_B1nky.resolveThinkingLevel;
|
|
2893
2908
|
exports.runAgentPrompt = runAgentPrompt;
|
|
2894
2909
|
exports.runDirectAgentPrompt = runDirectAgentPrompt;
|
|
2895
2910
|
exports.runLlm = runLlm;
|
|
2896
2911
|
exports.streamAgentPrompt = streamAgentPrompt;
|
|
2897
2912
|
exports.toSubagentTool = toSubagentTool;
|
|
2898
2913
|
exports.validateAgentModelIds = validateAgentModelIds;
|
|
2899
|
-
exports.withLlmRunContext =
|
|
2914
|
+
exports.withLlmRunContext = require_context_compaction_D2_B1nky.withLlmRunContext;
|
|
2900
2915
|
|
|
2901
2916
|
//# sourceMappingURL=agent.cjs.map
|