@keystrokehq/keystroke 0.1.82 → 0.1.83
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 +69 -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 +18 -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 +1 -1
- 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,9 +1,9 @@
|
|
|
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");
|
|
@@ -773,14 +773,14 @@ function buildMemoryFromHandle(config, db) {
|
|
|
773
773
|
//#region ../agent/dist/index.mjs
|
|
774
774
|
/** Replace unsupported `FileUIPart`s with text placeholders before model conversion. */
|
|
775
775
|
function applyCapabilityPlaceholderToMessages(messages, capabilities) {
|
|
776
|
-
return
|
|
776
|
+
return require_context_compaction_D2_B1nky.mapMessageFileParts(messages, (part) => require_dist.modelSupportsMediaType(capabilities, part.mediaType) ? part : {
|
|
777
777
|
type: "text",
|
|
778
|
-
text:
|
|
778
|
+
text: require_context_compaction_D2_B1nky.attachmentPlaceholderText(part.filename, part.mediaType)
|
|
779
779
|
});
|
|
780
780
|
}
|
|
781
781
|
/** Resolve private chat attachment paths to data URLs before `convertToModelMessages`. */
|
|
782
782
|
async function hydrateChatAttachmentMessages(messages, download) {
|
|
783
|
-
return
|
|
783
|
+
return require_context_compaction_D2_B1nky.mapMessageFileParts(messages, async (part) => {
|
|
784
784
|
if (!require_dist.parseChatAttachmentServePath(part.url)) return part;
|
|
785
785
|
const [result] = await download([{
|
|
786
786
|
url: new URL(part.url, "http://local"),
|
|
@@ -814,7 +814,7 @@ function gateToolResultOutput(output, capabilities) {
|
|
|
814
814
|
if (!mediaType || require_dist.modelSupportsMediaType(capabilities, mediaType)) return [part];
|
|
815
815
|
return [{
|
|
816
816
|
type: "text",
|
|
817
|
-
text:
|
|
817
|
+
text: require_context_compaction_D2_B1nky.attachmentPlaceholderText(void 0, mediaType)
|
|
818
818
|
}];
|
|
819
819
|
})
|
|
820
820
|
};
|
|
@@ -956,7 +956,7 @@ const SUBMIT_TOOL_VENDORS = new Set([
|
|
|
956
956
|
"deepseek"
|
|
957
957
|
]);
|
|
958
958
|
function structuredOutputSubmitToolVendor(modelId) {
|
|
959
|
-
const { vendor } =
|
|
959
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(modelId);
|
|
960
960
|
return SUBMIT_TOOL_VENDORS.has(vendor);
|
|
961
961
|
}
|
|
962
962
|
/**
|
|
@@ -969,7 +969,7 @@ function structuredOutputSubmitToolVendor(modelId) {
|
|
|
969
969
|
function usesStructuredOutputSubmitTool(args) {
|
|
970
970
|
if (!args.structuredOutput || !structuredOutputSubmitToolVendor(args.modelId)) return false;
|
|
971
971
|
if (args.promptLlm) return true;
|
|
972
|
-
const { vendor } =
|
|
972
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
973
973
|
return (vendor === "zai" || vendor === "alibaba") && (args.hasTools ?? false);
|
|
974
974
|
}
|
|
975
975
|
function appendStructuredOutputSubmitTool(tools, schema) {
|
|
@@ -986,6 +986,15 @@ function resolveStructuredOutputStopWhen(args) {
|
|
|
986
986
|
if (!usesStructuredOutputSubmitTool(args)) return;
|
|
987
987
|
return require_dist$2.hasToolCall(STRUCTURED_OUTPUT_SUBMIT_TOOL_NAME);
|
|
988
988
|
}
|
|
989
|
+
/**
|
|
990
|
+
* Always apply the agent step cap; combine with structured-output submit-tool stop when needed.
|
|
991
|
+
* Passing this explicitly keeps the AI SDK from falling back to its ToolLoopAgent default of 20.
|
|
992
|
+
*/
|
|
993
|
+
function resolveAgentStopWhen(args) {
|
|
994
|
+
const stepLimit = require_dist$2.isStepCount(args.maxSteps);
|
|
995
|
+
const structuredStop = resolveStructuredOutputStopWhen(args);
|
|
996
|
+
return structuredStop ? [stepLimit, structuredStop] : stepLimit;
|
|
997
|
+
}
|
|
989
998
|
function extractStructuredOutputFromSubmitTool(args) {
|
|
990
999
|
for (let index = args.steps.length - 1; index >= 0; index -= 1) {
|
|
991
1000
|
const step = args.steps[index];
|
|
@@ -999,7 +1008,7 @@ function extractStructuredOutputFromSubmitTool(args) {
|
|
|
999
1008
|
*/
|
|
1000
1009
|
function augmentInstructionsForStructuredOutput(args) {
|
|
1001
1010
|
if (!args.structuredOutput) return args.instructions;
|
|
1002
|
-
const { vendor } =
|
|
1011
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
1003
1012
|
let instructions = args.instructions;
|
|
1004
1013
|
const submitTool = usesStructuredOutputSubmitTool({
|
|
1005
1014
|
modelId: args.modelId,
|
|
@@ -1042,7 +1051,7 @@ function parseRepairedStructuredOutput(args) {
|
|
|
1042
1051
|
*/
|
|
1043
1052
|
function resolveProviderOptions(args) {
|
|
1044
1053
|
if (!args.structuredOutput) return;
|
|
1045
|
-
const { vendor } =
|
|
1054
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
1046
1055
|
if (vendor === "anthropic") return { anthropic: { structuredOutputMode: "outputFormat" } };
|
|
1047
1056
|
}
|
|
1048
1057
|
/**
|
|
@@ -1058,7 +1067,7 @@ function wrapLanguageModelForStructuredOutput(args) {
|
|
|
1058
1067
|
structuredOutput: args.structuredOutput,
|
|
1059
1068
|
hasTools: args.hasTools ?? false
|
|
1060
1069
|
})) return args.languageModel;
|
|
1061
|
-
const { vendor } =
|
|
1070
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
1062
1071
|
if (vendor !== "zai") return args.languageModel;
|
|
1063
1072
|
return require_dist$2.wrapLanguageModel({
|
|
1064
1073
|
model: args.languageModel,
|
|
@@ -1066,7 +1075,7 @@ function wrapLanguageModelForStructuredOutput(args) {
|
|
|
1066
1075
|
});
|
|
1067
1076
|
}
|
|
1068
1077
|
function needsStructuredOutputToolGuard(modelId) {
|
|
1069
|
-
const { vendor, directId } =
|
|
1078
|
+
const { vendor, directId } = require_context_compaction_D2_B1nky.splitAgentModelId(modelId);
|
|
1070
1079
|
if (vendor === "anthropic") return !directId.includes("haiku");
|
|
1071
1080
|
return false;
|
|
1072
1081
|
}
|
|
@@ -1097,14 +1106,14 @@ function resolveReasoningForStructuredOutputPromptLlm(args) {
|
|
|
1097
1106
|
structuredOutput: args.structuredOutput,
|
|
1098
1107
|
promptLlm: true
|
|
1099
1108
|
})) return args.thinkingLevel;
|
|
1100
|
-
const { vendor } =
|
|
1109
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
1101
1110
|
if (vendor === "alibaba" || vendor === "minimax") return "none";
|
|
1102
1111
|
return args.thinkingLevel;
|
|
1103
1112
|
}
|
|
1104
1113
|
/** Alibaba may require the word "json" in user messages when response_format is enabled. */
|
|
1105
1114
|
function augmentInputForStructuredOutput(args) {
|
|
1106
1115
|
if (!args.structuredOutput) return args.input;
|
|
1107
|
-
const { vendor } =
|
|
1116
|
+
const { vendor } = require_context_compaction_D2_B1nky.splitAgentModelId(args.modelId);
|
|
1108
1117
|
if (vendor !== "alibaba") return args.input;
|
|
1109
1118
|
if (/\bjson\b/i.test(args.input)) return args.input;
|
|
1110
1119
|
return `${args.input}\n\nReturn the final answer as json matching the schema.`;
|
|
@@ -1188,8 +1197,8 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1188
1197
|
structuredOutput,
|
|
1189
1198
|
hasTools
|
|
1190
1199
|
});
|
|
1191
|
-
const budgetTracker = new
|
|
1192
|
-
const budgetOverheadChars =
|
|
1200
|
+
const budgetTracker = new require_context_compaction_D2_B1nky.ContextBudgetTracker(require_context_compaction_D2_B1nky.resolveContextBudget(config.resolvedModel));
|
|
1201
|
+
const budgetOverheadChars = require_context_compaction_D2_B1nky.estimateSerializedChars({
|
|
1193
1202
|
systemPrompt: config.systemPrompt,
|
|
1194
1203
|
tools: aiTools
|
|
1195
1204
|
});
|
|
@@ -1204,10 +1213,10 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1204
1213
|
if (estimate?.decision === "compact" && !compactionInFlight) {
|
|
1205
1214
|
compactionInFlight = (async () => {
|
|
1206
1215
|
try {
|
|
1207
|
-
const compacted = await
|
|
1216
|
+
const compacted = await require_context_compaction_D2_B1nky.compactModelMessages({
|
|
1208
1217
|
messages: stepArgs.messages,
|
|
1209
1218
|
sourceModel: config.resolvedModel.modelId,
|
|
1210
|
-
compactionModelId:
|
|
1219
|
+
compactionModelId: require_context_compaction_D2_B1nky.resolveCompactionModelId(config.compactionModelId),
|
|
1211
1220
|
compactedThroughSeq: config.compactedThroughSeq ?? 0,
|
|
1212
1221
|
durable: false,
|
|
1213
1222
|
estimatedBeforeTokens: estimate.estimatedInputTokens,
|
|
@@ -1252,7 +1261,8 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1252
1261
|
if (lastCompactedMessages) lastCompactedMessages = null;
|
|
1253
1262
|
return result;
|
|
1254
1263
|
};
|
|
1255
|
-
const stopWhen =
|
|
1264
|
+
const stopWhen = resolveAgentStopWhen({
|
|
1265
|
+
maxSteps: config.maxSteps,
|
|
1256
1266
|
modelId: config.resolvedModel.modelId,
|
|
1257
1267
|
structuredOutput,
|
|
1258
1268
|
hasTools
|
|
@@ -1276,7 +1286,7 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1276
1286
|
...!submitToolOutput && options.outputSchema ? { output: require_dist$2.output_exports.object({ schema: options.outputSchema }) } : {},
|
|
1277
1287
|
...providerOptions ? { providerOptions } : {},
|
|
1278
1288
|
prepareStep: prepareStepOnce,
|
|
1279
|
-
|
|
1289
|
+
stopWhen
|
|
1280
1290
|
}).stream({
|
|
1281
1291
|
messages: modelMessages,
|
|
1282
1292
|
abortSignal: options.signal,
|
|
@@ -1306,8 +1316,8 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1306
1316
|
budgetTracker.recordStepUsage(inputTokens);
|
|
1307
1317
|
await emit({
|
|
1308
1318
|
type: "usage_record",
|
|
1309
|
-
usage:
|
|
1310
|
-
byok:
|
|
1319
|
+
usage: require_context_compaction_D2_B1nky.llmUsageFromLanguageModelUsage(step.usage, config.resolvedModel, {
|
|
1320
|
+
byok: require_context_compaction_D2_B1nky.byokFromResponseHeaders(step.response.headers),
|
|
1311
1321
|
stepRef: `${step.callId}:${step.stepNumber}`
|
|
1312
1322
|
})
|
|
1313
1323
|
});
|
|
@@ -1527,7 +1537,7 @@ async function generateSessionTitle(message) {
|
|
|
1527
1537
|
const input = message.trim();
|
|
1528
1538
|
if (!input) return null;
|
|
1529
1539
|
const { text } = await require_dist$2.generateText({
|
|
1530
|
-
model: (await
|
|
1540
|
+
model: (await require_context_compaction_D2_B1nky.resolveAgentModel(TITLE_MODEL_ID)).languageModel,
|
|
1531
1541
|
system: TITLE_SYSTEM_PROMPT,
|
|
1532
1542
|
prompt: input.slice(0, MAX_INPUT_CHARS),
|
|
1533
1543
|
maxOutputTokens: 512,
|
|
@@ -1641,13 +1651,13 @@ async function loadSessionModelContext(sessionId) {
|
|
|
1641
1651
|
for (let index = allEvents.length - 1; index >= 0; index -= 1) {
|
|
1642
1652
|
const event = allEvents[index];
|
|
1643
1653
|
if (event.eventType !== "context_compacted") continue;
|
|
1644
|
-
const parsed =
|
|
1654
|
+
const parsed = require_context_compaction_D2_B1nky.parseContextCompactionCheckpoint(event.payload);
|
|
1645
1655
|
if (parsed?.durable) {
|
|
1646
1656
|
checkpoint = parsed;
|
|
1647
1657
|
break;
|
|
1648
1658
|
}
|
|
1649
1659
|
}
|
|
1650
|
-
const modelMessages =
|
|
1660
|
+
const modelMessages = require_context_compaction_D2_B1nky.rebuildMessagesFromCheckpoint({
|
|
1651
1661
|
checkpoint,
|
|
1652
1662
|
messageEvents: messageEvents.map((event) => ({
|
|
1653
1663
|
seq: event.seq,
|
|
@@ -1706,7 +1716,7 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1706
1716
|
finalizeOnly: resume.complete
|
|
1707
1717
|
});
|
|
1708
1718
|
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 ?
|
|
1719
|
+
const titleTask = priorMessages.length === 0 && titleSource.length > 0 ? require_context_compaction_D2_B1nky.withLlmRunContext({
|
|
1710
1720
|
runId: sessionId,
|
|
1711
1721
|
runKind: "agent",
|
|
1712
1722
|
skipUsage: true
|
|
@@ -1781,26 +1791,26 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1781
1791
|
throw error;
|
|
1782
1792
|
}
|
|
1783
1793
|
const activeRuntime = runtime;
|
|
1784
|
-
const budget =
|
|
1794
|
+
const budget = require_context_compaction_D2_B1nky.resolveContextBudget(activeRuntime.runConfig.resolvedModel);
|
|
1785
1795
|
if (budget && modelMessages.length > 0) {
|
|
1786
|
-
const tracker = new
|
|
1787
|
-
const modelMsgs = await require_dist$2.convertToModelMessages(await
|
|
1796
|
+
const tracker = new require_context_compaction_D2_B1nky.ContextBudgetTracker(budget);
|
|
1797
|
+
const modelMsgs = await require_dist$2.convertToModelMessages(await require_context_compaction_D2_B1nky.placeholderChatAttachmentMessages(modelMessages));
|
|
1788
1798
|
const estimate = tracker.estimate({
|
|
1789
1799
|
systemPrompt: activeRuntime.runConfig.systemPrompt,
|
|
1790
1800
|
messages: modelMsgs,
|
|
1791
1801
|
tools: activeRuntime.tools,
|
|
1792
|
-
extraMessageTokens:
|
|
1802
|
+
extraMessageTokens: require_context_compaction_D2_B1nky.estimateChatAttachmentTokens(modelMessages)
|
|
1793
1803
|
});
|
|
1794
1804
|
if (estimate?.decision === "compact") try {
|
|
1795
1805
|
const priorDurable = activeCheckpoint?.durable === true ? activeCheckpoint : null;
|
|
1796
|
-
const suffixModel = await require_dist$2.convertToModelMessages(await
|
|
1797
|
-
const compacted = await
|
|
1806
|
+
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));
|
|
1807
|
+
const compacted = await require_context_compaction_D2_B1nky.withLlmRunContext({
|
|
1798
1808
|
runId: sessionId,
|
|
1799
1809
|
runKind: "agent"
|
|
1800
|
-
}, () =>
|
|
1810
|
+
}, () => require_context_compaction_D2_B1nky.compactModelMessages({
|
|
1801
1811
|
messages: suffixModel,
|
|
1802
1812
|
sourceModel: activeRuntime.runConfig.resolvedModel.modelId,
|
|
1803
|
-
compactionModelId:
|
|
1813
|
+
compactionModelId: require_context_compaction_D2_B1nky.resolveCompactionModelId(agent.compactionModel ?? "deepseek/deepseek-v4-flash"),
|
|
1804
1814
|
compactedThroughSeq: (prefixMessageCount) => compactedThroughSeqForPrefix({
|
|
1805
1815
|
checkpoint: priorDurable,
|
|
1806
1816
|
messageEvents: sessionContext.messageEvents,
|
|
@@ -1820,7 +1830,7 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1820
1830
|
checkpoint: compacted.checkpoint
|
|
1821
1831
|
});
|
|
1822
1832
|
activeCheckpoint = compacted.checkpoint;
|
|
1823
|
-
modelMessages = [
|
|
1833
|
+
modelMessages = [require_context_compaction_D2_B1nky.summaryToUiMessage(compacted.checkpoint.summary), ...sessionContext.messageEvents.filter((event) => event.seq > throughSeq).map((event) => event.message)];
|
|
1824
1834
|
activeRuntime.runConfig.messages = modelMessages;
|
|
1825
1835
|
activeRuntime.runConfig.compactedThroughSeq = throughSeq;
|
|
1826
1836
|
} catch (error) {
|
|
@@ -1867,7 +1877,7 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1867
1877
|
let streamResult;
|
|
1868
1878
|
const promptMessage = resume || require_dist.hasAgentTimestampContext(input.message) ? input.message : require_dist.prependAgentUserContext(input.message, { ...options.timezone !== void 0 ? { timezone: options.timezone } : {} });
|
|
1869
1879
|
try {
|
|
1870
|
-
streamResult = await require_dist$2.captureConsole(() =>
|
|
1880
|
+
streamResult = await require_dist$2.captureConsole(() => require_context_compaction_D2_B1nky.withLlmRunContext({
|
|
1871
1881
|
runId: sessionId,
|
|
1872
1882
|
runKind: "agent"
|
|
1873
1883
|
}, () => streamAgentPrompt(activeRuntime.runConfig, promptMessage, {
|
|
@@ -2268,13 +2278,14 @@ async function buildAgentRuntime(def, ctx, runPrompt = {}, agentSlug) {
|
|
|
2268
2278
|
hasSkills: attachedSkills.length > 0
|
|
2269
2279
|
})}\n\n${systemPrompt}`;
|
|
2270
2280
|
if (memory) systemPrompt = `${memory.systemPromptInjection()}\n\n${systemPrompt}`;
|
|
2271
|
-
const thinkingLevel =
|
|
2281
|
+
const thinkingLevel = require_context_compaction_D2_B1nky.resolveThinkingLevel(runPrompt.thinkingLevel ?? def.thinkingLevel);
|
|
2272
2282
|
return {
|
|
2273
2283
|
runConfig: {
|
|
2274
2284
|
systemPrompt,
|
|
2275
|
-
resolvedModel: await
|
|
2285
|
+
resolvedModel: await require_context_compaction_D2_B1nky.resolveAgentModel(def.model),
|
|
2276
2286
|
compactionModelId: def.compactionModel ?? "deepseek/deepseek-v4-flash",
|
|
2277
2287
|
thinkingLevel,
|
|
2288
|
+
maxSteps: def.maxSteps ?? 100,
|
|
2278
2289
|
messages: ctx.messages ?? [],
|
|
2279
2290
|
tools,
|
|
2280
2291
|
mcpToolSet: captured.toolSet,
|
|
@@ -2339,7 +2350,8 @@ function normalizeAgentDefinition(input, options = {}) {
|
|
|
2339
2350
|
return {
|
|
2340
2351
|
systemPrompt: input.systemPrompt,
|
|
2341
2352
|
model: input.model,
|
|
2342
|
-
thinkingLevel:
|
|
2353
|
+
thinkingLevel: require_context_compaction_D2_B1nky.resolveThinkingLevel(input.thinkingLevel),
|
|
2354
|
+
maxSteps: require_context_compaction_D2_B1nky.resolveMaxSteps(input.maxSteps),
|
|
2343
2355
|
...input.compactionModel !== void 0 ? { compactionModel: input.compactionModel } : {},
|
|
2344
2356
|
...input.tools !== void 0 ? { tools: input.tools } : {},
|
|
2345
2357
|
...input.runtimeHooks !== void 0 ? { runtimeHooks: input.runtimeHooks } : {},
|
|
@@ -2739,20 +2751,20 @@ function agentModelIdsFromStoredManifest(manifest) {
|
|
|
2739
2751
|
const ids = [];
|
|
2740
2752
|
for (const entry of manifest.entries) {
|
|
2741
2753
|
if (entry.kind !== "agent") continue;
|
|
2742
|
-
const parsed =
|
|
2754
|
+
const parsed = require_context_compaction_D2_B1nky.AgentModelIdSchema.safeParse(entry.model);
|
|
2743
2755
|
if (parsed.success) ids.push(parsed.data);
|
|
2744
2756
|
if ("compactionModel" in entry && typeof entry.compactionModel === "string") {
|
|
2745
|
-
const compaction =
|
|
2757
|
+
const compaction = require_context_compaction_D2_B1nky.AgentModelIdSchema.safeParse(entry.compactionModel);
|
|
2746
2758
|
if (compaction.success) ids.push(compaction.data);
|
|
2747
2759
|
}
|
|
2748
2760
|
}
|
|
2749
2761
|
return ids;
|
|
2750
2762
|
}
|
|
2751
2763
|
async function resolvePromptModel(model) {
|
|
2752
|
-
return
|
|
2764
|
+
return require_context_compaction_D2_B1nky.resolveAgentModel(require_context_compaction_D2_B1nky.AgentModelIdSchema.parse(model));
|
|
2753
2765
|
}
|
|
2754
2766
|
async function recordUsage(resolved, usage, hooks, responseHeaders) {
|
|
2755
|
-
await hooks?.onUsage?.(
|
|
2767
|
+
await hooks?.onUsage?.(require_context_compaction_D2_B1nky.llmUsageFromLanguageModelUsage(usage, resolved, { byok: require_context_compaction_D2_B1nky.byokFromResponseHeaders(responseHeaders) }));
|
|
2756
2768
|
}
|
|
2757
2769
|
function reasoningCallOption(thinkingLevel) {
|
|
2758
2770
|
return thinkingLevel === void 0 ? {} : { reasoning: thinkingLevel };
|
|
@@ -2858,18 +2870,19 @@ async function runLlm(opts, hooks) {
|
|
|
2858
2870
|
}
|
|
2859
2871
|
//#endregion
|
|
2860
2872
|
exports.AGENT = AGENT;
|
|
2861
|
-
exports.AgentCreateInputSchema =
|
|
2862
|
-
exports.AgentModelIdSchema =
|
|
2863
|
-
exports.DEFAULT_COMPACTION_MODEL_ID =
|
|
2864
|
-
exports.
|
|
2873
|
+
exports.AgentCreateInputSchema = require_context_compaction_D2_B1nky.AgentCreateInputSchema;
|
|
2874
|
+
exports.AgentModelIdSchema = require_context_compaction_D2_B1nky.AgentModelIdSchema;
|
|
2875
|
+
exports.DEFAULT_COMPACTION_MODEL_ID = require_context_compaction_D2_B1nky.DEFAULT_COMPACTION_MODEL_ID;
|
|
2876
|
+
exports.DEFAULT_MAX_STEPS = require_context_compaction_D2_B1nky.DEFAULT_MAX_STEPS;
|
|
2877
|
+
exports.DEFAULT_THINKING_LEVEL = require_context_compaction_D2_B1nky.DEFAULT_THINKING_LEVEL;
|
|
2865
2878
|
exports.SessionAgentMismatchError = SessionAgentMismatchError;
|
|
2866
|
-
exports.ThinkingLevelSchema =
|
|
2879
|
+
exports.ThinkingLevelSchema = require_context_compaction_D2_B1nky.ThinkingLevelSchema;
|
|
2867
2880
|
exports.agentModelIdsFromStoredManifest = agentModelIdsFromStoredManifest;
|
|
2868
2881
|
exports.buildAgentRuntime = buildAgentRuntime;
|
|
2869
2882
|
exports.connectMcpDefinition = require_dist$3.connectMcpDefinition;
|
|
2870
2883
|
exports.connectMcpServer = require_dist$3.connectMcpServer;
|
|
2871
2884
|
exports.connectMcpStdio = require_dist$3.connectMcpStdio;
|
|
2872
|
-
exports.currentLlmRunContext =
|
|
2885
|
+
exports.currentLlmRunContext = require_context_compaction_D2_B1nky.currentLlmRunContext;
|
|
2873
2886
|
exports.defineAgent = defineAgent;
|
|
2874
2887
|
exports.defineMcp = require_dist$3.defineMcp;
|
|
2875
2888
|
exports.defineTool = require_dist.defineTool;
|
|
@@ -2881,21 +2894,22 @@ exports.isWithinAgentPromptExecution = isWithinAgentPromptExecution;
|
|
|
2881
2894
|
exports.loadAssetManifest = require_dist$4.loadAssetManifest;
|
|
2882
2895
|
exports.modelSupportsMediaType = require_dist.modelSupportsMediaType;
|
|
2883
2896
|
exports.normalizeAgentDefinition = normalizeAgentDefinition;
|
|
2884
|
-
exports.parseAgentCreateInput =
|
|
2897
|
+
exports.parseAgentCreateInput = require_context_compaction_D2_B1nky.parseAgentCreateInput;
|
|
2885
2898
|
exports.prepareAgentSession = prepareAgentSession;
|
|
2886
2899
|
exports.resolveAgentAssets = resolveAgentAssets;
|
|
2887
2900
|
exports.resolveAgentId = resolveAgentId;
|
|
2888
|
-
exports.resolveAgentModel =
|
|
2901
|
+
exports.resolveAgentModel = require_context_compaction_D2_B1nky.resolveAgentModel;
|
|
2889
2902
|
exports.resolveAgentTools = resolveAgentTools;
|
|
2890
2903
|
exports.resolveAgentWorkspaceRoot = resolveAgentWorkspaceRoot;
|
|
2891
|
-
exports.
|
|
2892
|
-
exports.
|
|
2904
|
+
exports.resolveMaxSteps = require_context_compaction_D2_B1nky.resolveMaxSteps;
|
|
2905
|
+
exports.resolveModelCapabilities = require_context_compaction_D2_B1nky.resolveModelCapabilities;
|
|
2906
|
+
exports.resolveThinkingLevel = require_context_compaction_D2_B1nky.resolveThinkingLevel;
|
|
2893
2907
|
exports.runAgentPrompt = runAgentPrompt;
|
|
2894
2908
|
exports.runDirectAgentPrompt = runDirectAgentPrompt;
|
|
2895
2909
|
exports.runLlm = runLlm;
|
|
2896
2910
|
exports.streamAgentPrompt = streamAgentPrompt;
|
|
2897
2911
|
exports.toSubagentTool = toSubagentTool;
|
|
2898
2912
|
exports.validateAgentModelIds = validateAgentModelIds;
|
|
2899
|
-
exports.withLlmRunContext =
|
|
2913
|
+
exports.withLlmRunContext = require_context_compaction_D2_B1nky.withLlmRunContext;
|
|
2900
2914
|
|
|
2901
2915
|
//# sourceMappingURL=agent.cjs.map
|