@keystrokehq/keystroke 0.1.76 → 0.1.79
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/README.md +18 -8
- package/dist/agent-types.cjs +1 -1
- package/dist/agent-types.mjs +1 -1
- package/dist/agent.cjs +52 -62
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.mjs +6 -16
- package/dist/agent.mjs.map +1 -1
- package/dist/{context-compaction-B2veGznA-BNxANwjo.cjs → context-compaction-Bxp4WK2B-CWLdNWoS.cjs} +169 -30
- package/dist/context-compaction-Bxp4WK2B-CWLdNWoS.cjs.map +1 -0
- package/dist/{context-compaction-B2veGznA-Br9-3A43.mjs → context-compaction-Bxp4WK2B-Ct4RSjlg.mjs} +154 -33
- package/dist/context-compaction-Bxp4WK2B-Ct4RSjlg.mjs.map +1 -0
- package/dist/dist-BQo9dZi7.cjs.map +1 -1
- package/dist/dist-DD3DTmkE.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/context-compaction-B2veGznA-BNxANwjo.cjs.map +0 -1
- package/dist/context-compaction-B2veGznA-Br9-3A43.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -39,20 +39,30 @@ import { defineConfig } from "@keystrokehq/keystroke/config";
|
|
|
39
39
|
import { defineCredential } from "@keystrokehq/keystroke/credentials";
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
## Custom
|
|
42
|
+
## Custom apps
|
|
43
|
+
|
|
44
|
+
For a credentialed custom integration, use `defineApp` (not a standalone credential file):
|
|
43
45
|
|
|
44
46
|
```typescript
|
|
45
|
-
import {
|
|
47
|
+
import { defineApp } from "@keystrokehq/keystroke/app";
|
|
46
48
|
import { z } from "zod";
|
|
47
49
|
|
|
48
|
-
export const
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
export const customApp = defineApp({
|
|
51
|
+
slug: "custom-app",
|
|
52
|
+
auth: "api_key",
|
|
53
|
+
credential: { apiKey: z.string() },
|
|
51
54
|
});
|
|
52
|
-
```
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
export const doThing = customApp.action({
|
|
57
|
+
slug: "do-thing",
|
|
58
|
+
input: z.object({ id: z.string() }),
|
|
59
|
+
output: z.object({ ok: z.boolean() }),
|
|
60
|
+
async run(input, credentials) {
|
|
61
|
+
return callApi(input.id, credentials["custom-app"].apiKey);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
56
64
|
```
|
|
57
65
|
|
|
66
|
+
Register a connectable org app with `keystroke apps create` when users should connect via the Apps UI, then `keystroke connect custom-app` (or `credentials create`). See the custom apps docs.
|
|
67
|
+
|
|
58
68
|
Direct `@keystrokehq/action` (and other primitive) imports remain valid.
|
package/dist/agent-types.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require("./context-compaction-
|
|
1
|
+
require("./context-compaction-Bxp4WK2B-CWLdNWoS.cjs");
|
package/dist/agent-types.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "./context-compaction-
|
|
1
|
+
import "./context-compaction-Bxp4WK2B-Ct4RSjlg.mjs";
|
|
2
2
|
export {};
|
package/dist/agent.cjs
CHANGED
|
@@ -3,7 +3,7 @@ const require_dist = require("./dist-Dg83IPct.cjs");
|
|
|
3
3
|
const require_dist$1 = require("./dist-Dz88Bzu0.cjs");
|
|
4
4
|
const require_dist$2 = require("./dist-IS8Bvv2i.cjs");
|
|
5
5
|
const require_dist$3 = require("./dist-BQo9dZi7.cjs");
|
|
6
|
-
const
|
|
6
|
+
const require_context_compaction_Bxp4WK2B = require("./context-compaction-Bxp4WK2B-CWLdNWoS.cjs");
|
|
7
7
|
const require_dist$4 = require("./dist-j8370AIo.cjs");
|
|
8
8
|
let zod = require("zod");
|
|
9
9
|
let node_async_hooks = require("node:async_hooks");
|
|
@@ -771,27 +771,16 @@ function buildMemoryFromHandle(config, db) {
|
|
|
771
771
|
}
|
|
772
772
|
//#endregion
|
|
773
773
|
//#region ../agent/dist/index.mjs
|
|
774
|
-
/** Map every `FileUIPart` in each message, leaving other parts and non-array messages untouched. */
|
|
775
|
-
async function mapMessageFileParts(messages, mapFilePart) {
|
|
776
|
-
return Promise.all(messages.map(async (message) => {
|
|
777
|
-
if (!Array.isArray(message.parts)) return message;
|
|
778
|
-
const parts = await Promise.all(message.parts.map((part) => require_dist$2.isFileUIPart(part) ? mapFilePart(part) : part));
|
|
779
|
-
return {
|
|
780
|
-
...message,
|
|
781
|
-
parts
|
|
782
|
-
};
|
|
783
|
-
}));
|
|
784
|
-
}
|
|
785
774
|
/** Replace unsupported `FileUIPart`s with text placeholders before model conversion. */
|
|
786
775
|
function applyCapabilityPlaceholderToMessages(messages, capabilities) {
|
|
787
|
-
return mapMessageFileParts(messages, (part) => require_dist.modelSupportsMediaType(capabilities, part.mediaType) ? part : {
|
|
776
|
+
return require_context_compaction_Bxp4WK2B.mapMessageFileParts(messages, (part) => require_dist.modelSupportsMediaType(capabilities, part.mediaType) ? part : {
|
|
788
777
|
type: "text",
|
|
789
|
-
text:
|
|
778
|
+
text: require_context_compaction_Bxp4WK2B.attachmentPlaceholderText(part.filename, part.mediaType)
|
|
790
779
|
});
|
|
791
780
|
}
|
|
792
781
|
/** Resolve private chat attachment paths to data URLs before `convertToModelMessages`. */
|
|
793
782
|
async function hydrateChatAttachmentMessages(messages, download) {
|
|
794
|
-
return mapMessageFileParts(messages, async (part) => {
|
|
783
|
+
return require_context_compaction_Bxp4WK2B.mapMessageFileParts(messages, async (part) => {
|
|
795
784
|
if (!require_dist.parseChatAttachmentServePath(part.url)) return part;
|
|
796
785
|
const [result] = await download([{
|
|
797
786
|
url: new URL(part.url, "http://local"),
|
|
@@ -825,7 +814,7 @@ function gateToolResultOutput(output, capabilities) {
|
|
|
825
814
|
if (!mediaType || require_dist.modelSupportsMediaType(capabilities, mediaType)) return [part];
|
|
826
815
|
return [{
|
|
827
816
|
type: "text",
|
|
828
|
-
text:
|
|
817
|
+
text: require_context_compaction_Bxp4WK2B.attachmentPlaceholderText(void 0, mediaType)
|
|
829
818
|
}];
|
|
830
819
|
})
|
|
831
820
|
};
|
|
@@ -967,7 +956,7 @@ const SUBMIT_TOOL_VENDORS = new Set([
|
|
|
967
956
|
"deepseek"
|
|
968
957
|
]);
|
|
969
958
|
function structuredOutputSubmitToolVendor(modelId) {
|
|
970
|
-
const { vendor } =
|
|
959
|
+
const { vendor } = require_context_compaction_Bxp4WK2B.splitAgentModelId(modelId);
|
|
971
960
|
return SUBMIT_TOOL_VENDORS.has(vendor);
|
|
972
961
|
}
|
|
973
962
|
/**
|
|
@@ -980,7 +969,7 @@ function structuredOutputSubmitToolVendor(modelId) {
|
|
|
980
969
|
function usesStructuredOutputSubmitTool(args) {
|
|
981
970
|
if (!args.structuredOutput || !structuredOutputSubmitToolVendor(args.modelId)) return false;
|
|
982
971
|
if (args.promptLlm) return true;
|
|
983
|
-
const { vendor } =
|
|
972
|
+
const { vendor } = require_context_compaction_Bxp4WK2B.splitAgentModelId(args.modelId);
|
|
984
973
|
return (vendor === "zai" || vendor === "alibaba") && (args.hasTools ?? false);
|
|
985
974
|
}
|
|
986
975
|
function appendStructuredOutputSubmitTool(tools, schema) {
|
|
@@ -1010,7 +999,7 @@ function extractStructuredOutputFromSubmitTool(args) {
|
|
|
1010
999
|
*/
|
|
1011
1000
|
function augmentInstructionsForStructuredOutput(args) {
|
|
1012
1001
|
if (!args.structuredOutput) return args.instructions;
|
|
1013
|
-
const { vendor } =
|
|
1002
|
+
const { vendor } = require_context_compaction_Bxp4WK2B.splitAgentModelId(args.modelId);
|
|
1014
1003
|
let instructions = args.instructions;
|
|
1015
1004
|
const submitTool = usesStructuredOutputSubmitTool({
|
|
1016
1005
|
modelId: args.modelId,
|
|
@@ -1053,7 +1042,7 @@ function parseRepairedStructuredOutput(args) {
|
|
|
1053
1042
|
*/
|
|
1054
1043
|
function resolveProviderOptions(args) {
|
|
1055
1044
|
if (!args.structuredOutput) return;
|
|
1056
|
-
const { vendor } =
|
|
1045
|
+
const { vendor } = require_context_compaction_Bxp4WK2B.splitAgentModelId(args.modelId);
|
|
1057
1046
|
if (vendor === "anthropic") return { anthropic: { structuredOutputMode: "outputFormat" } };
|
|
1058
1047
|
}
|
|
1059
1048
|
/**
|
|
@@ -1069,7 +1058,7 @@ function wrapLanguageModelForStructuredOutput(args) {
|
|
|
1069
1058
|
structuredOutput: args.structuredOutput,
|
|
1070
1059
|
hasTools: args.hasTools ?? false
|
|
1071
1060
|
})) return args.languageModel;
|
|
1072
|
-
const { vendor } =
|
|
1061
|
+
const { vendor } = require_context_compaction_Bxp4WK2B.splitAgentModelId(args.modelId);
|
|
1073
1062
|
if (vendor !== "zai") return args.languageModel;
|
|
1074
1063
|
return require_dist$2.wrapLanguageModel({
|
|
1075
1064
|
model: args.languageModel,
|
|
@@ -1077,7 +1066,7 @@ function wrapLanguageModelForStructuredOutput(args) {
|
|
|
1077
1066
|
});
|
|
1078
1067
|
}
|
|
1079
1068
|
function needsStructuredOutputToolGuard(modelId) {
|
|
1080
|
-
const { vendor, directId } =
|
|
1069
|
+
const { vendor, directId } = require_context_compaction_Bxp4WK2B.splitAgentModelId(modelId);
|
|
1081
1070
|
if (vendor === "anthropic") return !directId.includes("haiku");
|
|
1082
1071
|
return false;
|
|
1083
1072
|
}
|
|
@@ -1108,14 +1097,14 @@ function resolveReasoningForStructuredOutputPromptLlm(args) {
|
|
|
1108
1097
|
structuredOutput: args.structuredOutput,
|
|
1109
1098
|
promptLlm: true
|
|
1110
1099
|
})) return args.thinkingLevel;
|
|
1111
|
-
const { vendor } =
|
|
1100
|
+
const { vendor } = require_context_compaction_Bxp4WK2B.splitAgentModelId(args.modelId);
|
|
1112
1101
|
if (vendor === "alibaba" || vendor === "minimax") return "none";
|
|
1113
1102
|
return args.thinkingLevel;
|
|
1114
1103
|
}
|
|
1115
1104
|
/** Alibaba may require the word "json" in user messages when response_format is enabled. */
|
|
1116
1105
|
function augmentInputForStructuredOutput(args) {
|
|
1117
1106
|
if (!args.structuredOutput) return args.input;
|
|
1118
|
-
const { vendor } =
|
|
1107
|
+
const { vendor } = require_context_compaction_Bxp4WK2B.splitAgentModelId(args.modelId);
|
|
1119
1108
|
if (vendor !== "alibaba") return args.input;
|
|
1120
1109
|
if (/\bjson\b/i.test(args.input)) return args.input;
|
|
1121
1110
|
return `${args.input}\n\nReturn the final answer as json matching the schema.`;
|
|
@@ -1199,8 +1188,8 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1199
1188
|
structuredOutput,
|
|
1200
1189
|
hasTools
|
|
1201
1190
|
});
|
|
1202
|
-
const budgetTracker = new
|
|
1203
|
-
const budgetOverheadChars =
|
|
1191
|
+
const budgetTracker = new require_context_compaction_Bxp4WK2B.ContextBudgetTracker(require_context_compaction_Bxp4WK2B.resolveContextBudget(config.resolvedModel));
|
|
1192
|
+
const budgetOverheadChars = require_context_compaction_Bxp4WK2B.estimateSerializedChars({
|
|
1204
1193
|
systemPrompt: config.systemPrompt,
|
|
1205
1194
|
tools: aiTools
|
|
1206
1195
|
});
|
|
@@ -1215,10 +1204,10 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1215
1204
|
if (estimate?.decision === "compact" && !compactionInFlight) {
|
|
1216
1205
|
compactionInFlight = (async () => {
|
|
1217
1206
|
try {
|
|
1218
|
-
const compacted = await
|
|
1207
|
+
const compacted = await require_context_compaction_Bxp4WK2B.compactModelMessages({
|
|
1219
1208
|
messages: stepArgs.messages,
|
|
1220
1209
|
sourceModel: config.resolvedModel.modelId,
|
|
1221
|
-
compactionModelId:
|
|
1210
|
+
compactionModelId: require_context_compaction_Bxp4WK2B.resolveCompactionModelId(config.compactionModelId),
|
|
1222
1211
|
compactedThroughSeq: config.compactedThroughSeq ?? 0,
|
|
1223
1212
|
durable: false,
|
|
1224
1213
|
estimatedBeforeTokens: estimate.estimatedInputTokens,
|
|
@@ -1317,8 +1306,8 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1317
1306
|
budgetTracker.recordStepUsage(inputTokens);
|
|
1318
1307
|
await emit({
|
|
1319
1308
|
type: "usage_record",
|
|
1320
|
-
usage:
|
|
1321
|
-
byok:
|
|
1309
|
+
usage: require_context_compaction_Bxp4WK2B.llmUsageFromLanguageModelUsage(step.usage, config.resolvedModel, {
|
|
1310
|
+
byok: require_context_compaction_Bxp4WK2B.byokFromResponseHeaders(step.response.headers),
|
|
1322
1311
|
stepRef: `${step.callId}:${step.stepNumber}`
|
|
1323
1312
|
})
|
|
1324
1313
|
});
|
|
@@ -1538,7 +1527,7 @@ async function generateSessionTitle(message) {
|
|
|
1538
1527
|
const input = message.trim();
|
|
1539
1528
|
if (!input) return null;
|
|
1540
1529
|
const { text } = await require_dist$2.generateText({
|
|
1541
|
-
model: (await
|
|
1530
|
+
model: (await require_context_compaction_Bxp4WK2B.resolveAgentModel(TITLE_MODEL_ID)).languageModel,
|
|
1542
1531
|
system: TITLE_SYSTEM_PROMPT,
|
|
1543
1532
|
prompt: input.slice(0, MAX_INPUT_CHARS),
|
|
1544
1533
|
maxOutputTokens: 512,
|
|
@@ -1652,13 +1641,13 @@ async function loadSessionModelContext(sessionId) {
|
|
|
1652
1641
|
for (let index = allEvents.length - 1; index >= 0; index -= 1) {
|
|
1653
1642
|
const event = allEvents[index];
|
|
1654
1643
|
if (event.eventType !== "context_compacted") continue;
|
|
1655
|
-
const parsed =
|
|
1644
|
+
const parsed = require_context_compaction_Bxp4WK2B.parseContextCompactionCheckpoint(event.payload);
|
|
1656
1645
|
if (parsed?.durable) {
|
|
1657
1646
|
checkpoint = parsed;
|
|
1658
1647
|
break;
|
|
1659
1648
|
}
|
|
1660
1649
|
}
|
|
1661
|
-
const modelMessages =
|
|
1650
|
+
const modelMessages = require_context_compaction_Bxp4WK2B.rebuildMessagesFromCheckpoint({
|
|
1662
1651
|
checkpoint,
|
|
1663
1652
|
messageEvents: messageEvents.map((event) => ({
|
|
1664
1653
|
seq: event.seq,
|
|
@@ -1717,7 +1706,7 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1717
1706
|
finalizeOnly: resume.complete
|
|
1718
1707
|
});
|
|
1719
1708
|
const titleSource = priorMessages.length === 0 ? require_dist.stripPromptContext(input.message.trim()) || input.files?.map((file) => file.filename ?? file.mediaType).join(", ") || "" : "";
|
|
1720
|
-
const titleTask = priorMessages.length === 0 && titleSource.length > 0 ?
|
|
1709
|
+
const titleTask = priorMessages.length === 0 && titleSource.length > 0 ? require_context_compaction_Bxp4WK2B.withLlmRunContext({
|
|
1721
1710
|
runId: sessionId,
|
|
1722
1711
|
runKind: "agent",
|
|
1723
1712
|
skipUsage: true
|
|
@@ -1792,25 +1781,26 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1792
1781
|
throw error;
|
|
1793
1782
|
}
|
|
1794
1783
|
const activeRuntime = runtime;
|
|
1795
|
-
const budget =
|
|
1784
|
+
const budget = require_context_compaction_Bxp4WK2B.resolveContextBudget(activeRuntime.runConfig.resolvedModel);
|
|
1796
1785
|
if (budget && modelMessages.length > 0) {
|
|
1797
|
-
const tracker = new
|
|
1798
|
-
const modelMsgs = await require_dist$2.convertToModelMessages(modelMessages);
|
|
1786
|
+
const tracker = new require_context_compaction_Bxp4WK2B.ContextBudgetTracker(budget);
|
|
1787
|
+
const modelMsgs = await require_dist$2.convertToModelMessages(await require_context_compaction_Bxp4WK2B.placeholderChatAttachmentMessages(modelMessages));
|
|
1799
1788
|
const estimate = tracker.estimate({
|
|
1800
1789
|
systemPrompt: activeRuntime.runConfig.systemPrompt,
|
|
1801
1790
|
messages: modelMsgs,
|
|
1802
|
-
tools: activeRuntime.tools
|
|
1791
|
+
tools: activeRuntime.tools,
|
|
1792
|
+
extraMessageTokens: require_context_compaction_Bxp4WK2B.estimateChatAttachmentTokens(modelMessages)
|
|
1803
1793
|
});
|
|
1804
1794
|
if (estimate?.decision === "compact") try {
|
|
1805
1795
|
const priorDurable = activeCheckpoint?.durable === true ? activeCheckpoint : null;
|
|
1806
|
-
const suffixModel = await require_dist$2.convertToModelMessages(priorDurable ? sessionContext.messageEvents.filter((event) => event.seq > priorDurable.compactedThroughSeq).map((event) => event.message) : modelMessages);
|
|
1807
|
-
const compacted = await
|
|
1796
|
+
const suffixModel = await require_dist$2.convertToModelMessages(await require_context_compaction_Bxp4WK2B.placeholderChatAttachmentMessages(priorDurable ? sessionContext.messageEvents.filter((event) => event.seq > priorDurable.compactedThroughSeq).map((event) => event.message) : modelMessages));
|
|
1797
|
+
const compacted = await require_context_compaction_Bxp4WK2B.withLlmRunContext({
|
|
1808
1798
|
runId: sessionId,
|
|
1809
1799
|
runKind: "agent"
|
|
1810
|
-
}, () =>
|
|
1800
|
+
}, () => require_context_compaction_Bxp4WK2B.compactModelMessages({
|
|
1811
1801
|
messages: suffixModel,
|
|
1812
1802
|
sourceModel: activeRuntime.runConfig.resolvedModel.modelId,
|
|
1813
|
-
compactionModelId:
|
|
1803
|
+
compactionModelId: require_context_compaction_Bxp4WK2B.resolveCompactionModelId(agent.compactionModel ?? "deepseek/deepseek-v4-flash"),
|
|
1814
1804
|
compactedThroughSeq: (prefixMessageCount) => compactedThroughSeqForPrefix({
|
|
1815
1805
|
checkpoint: priorDurable,
|
|
1816
1806
|
messageEvents: sessionContext.messageEvents,
|
|
@@ -1830,7 +1820,7 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1830
1820
|
checkpoint: compacted.checkpoint
|
|
1831
1821
|
});
|
|
1832
1822
|
activeCheckpoint = compacted.checkpoint;
|
|
1833
|
-
modelMessages = [
|
|
1823
|
+
modelMessages = [require_context_compaction_Bxp4WK2B.summaryToUiMessage(compacted.checkpoint.summary), ...sessionContext.messageEvents.filter((event) => event.seq > throughSeq).map((event) => event.message)];
|
|
1834
1824
|
activeRuntime.runConfig.messages = modelMessages;
|
|
1835
1825
|
activeRuntime.runConfig.compactedThroughSeq = throughSeq;
|
|
1836
1826
|
} catch (error) {
|
|
@@ -1877,7 +1867,7 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
1877
1867
|
let streamResult;
|
|
1878
1868
|
const promptMessage = resume || require_dist.hasAgentTimestampContext(input.message) ? input.message : require_dist.prependAgentUserContext(input.message, { ...options.timezone !== void 0 ? { timezone: options.timezone } : {} });
|
|
1879
1869
|
try {
|
|
1880
|
-
streamResult = await require_dist$2.captureConsole(() =>
|
|
1870
|
+
streamResult = await require_dist$2.captureConsole(() => require_context_compaction_Bxp4WK2B.withLlmRunContext({
|
|
1881
1871
|
runId: sessionId,
|
|
1882
1872
|
runKind: "agent"
|
|
1883
1873
|
}, () => streamAgentPrompt(activeRuntime.runConfig, promptMessage, {
|
|
@@ -2278,11 +2268,11 @@ async function buildAgentRuntime(def, ctx, runPrompt = {}, agentSlug) {
|
|
|
2278
2268
|
hasSkills: attachedSkills.length > 0
|
|
2279
2269
|
})}\n\n${systemPrompt}`;
|
|
2280
2270
|
if (memory) systemPrompt = `${memory.systemPromptInjection()}\n\n${systemPrompt}`;
|
|
2281
|
-
const thinkingLevel =
|
|
2271
|
+
const thinkingLevel = require_context_compaction_Bxp4WK2B.resolveThinkingLevel(runPrompt.thinkingLevel ?? def.thinkingLevel);
|
|
2282
2272
|
return {
|
|
2283
2273
|
runConfig: {
|
|
2284
2274
|
systemPrompt,
|
|
2285
|
-
resolvedModel: await
|
|
2275
|
+
resolvedModel: await require_context_compaction_Bxp4WK2B.resolveAgentModel(def.model),
|
|
2286
2276
|
compactionModelId: def.compactionModel ?? "deepseek/deepseek-v4-flash",
|
|
2287
2277
|
thinkingLevel,
|
|
2288
2278
|
messages: ctx.messages ?? [],
|
|
@@ -2349,7 +2339,7 @@ function normalizeAgentDefinition(input, options = {}) {
|
|
|
2349
2339
|
return {
|
|
2350
2340
|
systemPrompt: input.systemPrompt,
|
|
2351
2341
|
model: input.model,
|
|
2352
|
-
thinkingLevel:
|
|
2342
|
+
thinkingLevel: require_context_compaction_Bxp4WK2B.resolveThinkingLevel(input.thinkingLevel),
|
|
2353
2343
|
...input.compactionModel !== void 0 ? { compactionModel: input.compactionModel } : {},
|
|
2354
2344
|
...input.tools !== void 0 ? { tools: input.tools } : {},
|
|
2355
2345
|
...input.runtimeHooks !== void 0 ? { runtimeHooks: input.runtimeHooks } : {},
|
|
@@ -2749,20 +2739,20 @@ function agentModelIdsFromStoredManifest(manifest) {
|
|
|
2749
2739
|
const ids = [];
|
|
2750
2740
|
for (const entry of manifest.entries) {
|
|
2751
2741
|
if (entry.kind !== "agent") continue;
|
|
2752
|
-
const parsed =
|
|
2742
|
+
const parsed = require_context_compaction_Bxp4WK2B.AgentModelIdSchema.safeParse(entry.model);
|
|
2753
2743
|
if (parsed.success) ids.push(parsed.data);
|
|
2754
2744
|
if ("compactionModel" in entry && typeof entry.compactionModel === "string") {
|
|
2755
|
-
const compaction =
|
|
2745
|
+
const compaction = require_context_compaction_Bxp4WK2B.AgentModelIdSchema.safeParse(entry.compactionModel);
|
|
2756
2746
|
if (compaction.success) ids.push(compaction.data);
|
|
2757
2747
|
}
|
|
2758
2748
|
}
|
|
2759
2749
|
return ids;
|
|
2760
2750
|
}
|
|
2761
2751
|
async function resolvePromptModel(model) {
|
|
2762
|
-
return
|
|
2752
|
+
return require_context_compaction_Bxp4WK2B.resolveAgentModel(require_context_compaction_Bxp4WK2B.AgentModelIdSchema.parse(model));
|
|
2763
2753
|
}
|
|
2764
2754
|
async function recordUsage(resolved, usage, hooks, responseHeaders) {
|
|
2765
|
-
await hooks?.onUsage?.(
|
|
2755
|
+
await hooks?.onUsage?.(require_context_compaction_Bxp4WK2B.llmUsageFromLanguageModelUsage(usage, resolved, { byok: require_context_compaction_Bxp4WK2B.byokFromResponseHeaders(responseHeaders) }));
|
|
2766
2756
|
}
|
|
2767
2757
|
function reasoningCallOption(thinkingLevel) {
|
|
2768
2758
|
return thinkingLevel === void 0 ? {} : { reasoning: thinkingLevel };
|
|
@@ -2868,18 +2858,18 @@ async function runLlm(opts, hooks) {
|
|
|
2868
2858
|
}
|
|
2869
2859
|
//#endregion
|
|
2870
2860
|
exports.AGENT = AGENT;
|
|
2871
|
-
exports.AgentCreateInputSchema =
|
|
2872
|
-
exports.AgentModelIdSchema =
|
|
2873
|
-
exports.DEFAULT_COMPACTION_MODEL_ID =
|
|
2874
|
-
exports.DEFAULT_THINKING_LEVEL =
|
|
2861
|
+
exports.AgentCreateInputSchema = require_context_compaction_Bxp4WK2B.AgentCreateInputSchema;
|
|
2862
|
+
exports.AgentModelIdSchema = require_context_compaction_Bxp4WK2B.AgentModelIdSchema;
|
|
2863
|
+
exports.DEFAULT_COMPACTION_MODEL_ID = require_context_compaction_Bxp4WK2B.DEFAULT_COMPACTION_MODEL_ID;
|
|
2864
|
+
exports.DEFAULT_THINKING_LEVEL = require_context_compaction_Bxp4WK2B.DEFAULT_THINKING_LEVEL;
|
|
2875
2865
|
exports.SessionAgentMismatchError = SessionAgentMismatchError;
|
|
2876
|
-
exports.ThinkingLevelSchema =
|
|
2866
|
+
exports.ThinkingLevelSchema = require_context_compaction_Bxp4WK2B.ThinkingLevelSchema;
|
|
2877
2867
|
exports.agentModelIdsFromStoredManifest = agentModelIdsFromStoredManifest;
|
|
2878
2868
|
exports.buildAgentRuntime = buildAgentRuntime;
|
|
2879
2869
|
exports.connectMcpDefinition = require_dist$3.connectMcpDefinition;
|
|
2880
2870
|
exports.connectMcpServer = require_dist$3.connectMcpServer;
|
|
2881
2871
|
exports.connectMcpStdio = require_dist$3.connectMcpStdio;
|
|
2882
|
-
exports.currentLlmRunContext =
|
|
2872
|
+
exports.currentLlmRunContext = require_context_compaction_Bxp4WK2B.currentLlmRunContext;
|
|
2883
2873
|
exports.defineAgent = defineAgent;
|
|
2884
2874
|
exports.defineMcp = require_dist$3.defineMcp;
|
|
2885
2875
|
exports.defineTool = require_dist.defineTool;
|
|
@@ -2891,21 +2881,21 @@ exports.isWithinAgentPromptExecution = isWithinAgentPromptExecution;
|
|
|
2891
2881
|
exports.loadAssetManifest = require_dist$4.loadAssetManifest;
|
|
2892
2882
|
exports.modelSupportsMediaType = require_dist.modelSupportsMediaType;
|
|
2893
2883
|
exports.normalizeAgentDefinition = normalizeAgentDefinition;
|
|
2894
|
-
exports.parseAgentCreateInput =
|
|
2884
|
+
exports.parseAgentCreateInput = require_context_compaction_Bxp4WK2B.parseAgentCreateInput;
|
|
2895
2885
|
exports.prepareAgentSession = prepareAgentSession;
|
|
2896
2886
|
exports.resolveAgentAssets = resolveAgentAssets;
|
|
2897
2887
|
exports.resolveAgentId = resolveAgentId;
|
|
2898
|
-
exports.resolveAgentModel =
|
|
2888
|
+
exports.resolveAgentModel = require_context_compaction_Bxp4WK2B.resolveAgentModel;
|
|
2899
2889
|
exports.resolveAgentTools = resolveAgentTools;
|
|
2900
2890
|
exports.resolveAgentWorkspaceRoot = resolveAgentWorkspaceRoot;
|
|
2901
|
-
exports.resolveModelCapabilities =
|
|
2902
|
-
exports.resolveThinkingLevel =
|
|
2891
|
+
exports.resolveModelCapabilities = require_context_compaction_Bxp4WK2B.resolveModelCapabilities;
|
|
2892
|
+
exports.resolveThinkingLevel = require_context_compaction_Bxp4WK2B.resolveThinkingLevel;
|
|
2903
2893
|
exports.runAgentPrompt = runAgentPrompt;
|
|
2904
2894
|
exports.runDirectAgentPrompt = runDirectAgentPrompt;
|
|
2905
2895
|
exports.runLlm = runLlm;
|
|
2906
2896
|
exports.streamAgentPrompt = streamAgentPrompt;
|
|
2907
2897
|
exports.toSubagentTool = toSubagentTool;
|
|
2908
2898
|
exports.validateAgentModelIds = validateAgentModelIds;
|
|
2909
|
-
exports.withLlmRunContext =
|
|
2899
|
+
exports.withLlmRunContext = require_context_compaction_Bxp4WK2B.withLlmRunContext;
|
|
2910
2900
|
|
|
2911
2901
|
//# sourceMappingURL=agent.cjs.map
|