@keystrokehq/keystroke 0.1.24 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.cjs +47 -8
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.d.cts +1 -1
- package/dist/agent.d.mts +1 -1
- package/dist/agent.mjs +47 -8
- package/dist/agent.mjs.map +1 -1
- package/dist/{dist-8lWsO4r8.cjs → dist-C8V-TQaa.cjs} +7 -4
- package/dist/{dist-8lWsO4r8.cjs.map → dist-C8V-TQaa.cjs.map} +1 -1
- package/dist/{dist-CkW_0ydn.mjs → dist-DXQ9dYvL.mjs} +7 -4
- package/dist/{dist-CkW_0ydn.mjs.map → dist-DXQ9dYvL.mjs.map} +1 -1
- package/dist/{index-D4OqVz9B.d.mts → index-BboH3db0.d.mts} +15 -4
- package/dist/index-BboH3db0.d.mts.map +1 -0
- package/dist/{index-DAbG7A9m.d.cts → index-DHCs9z3O.d.cts} +15 -4
- package/dist/index-DHCs9z3O.d.cts.map +1 -0
- package/dist/{index-CYrYmgtQ.d.cts → index-RQo-Cn3t.d.cts} +15 -2
- package/dist/index-RQo-Cn3t.d.cts.map +1 -0
- package/dist/{index-DPKSoH6A.d.mts → index-aos8ZlFk.d.mts} +15 -2
- package/dist/index-aos8ZlFk.d.mts.map +1 -0
- package/dist/{token-aMT15EKk.cjs → token-BgVDRLkZ.cjs} +2 -2
- package/dist/{token-aMT15EKk.cjs.map → token-BgVDRLkZ.cjs.map} +1 -1
- package/dist/{token-Basg5yOB.mjs → token-C_E59byl.mjs} +2 -2
- package/dist/{token-Basg5yOB.mjs.map → token-C_E59byl.mjs.map} +1 -1
- package/dist/trigger.cjs +1 -1
- package/dist/trigger.d.cts +2 -2
- package/dist/trigger.d.mts +2 -2
- 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 +2 -2
- package/dist/index-CYrYmgtQ.d.cts.map +0 -1
- package/dist/index-D4OqVz9B.d.mts.map +0 -1
- package/dist/index-DAbG7A9m.d.cts.map +0 -1
- package/dist/index-DPKSoH6A.d.mts.map +0 -1
package/dist/agent.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_dist = require("./dist-CI6bW6Xj.cjs");
|
|
3
3
|
const require_dist$1 = require("./dist-B3qAA4eL.cjs");
|
|
4
|
-
const require_dist$2 = require("./dist-
|
|
4
|
+
const require_dist$2 = require("./dist-C8V-TQaa.cjs");
|
|
5
5
|
const require_dist$3 = require("./dist-D8doj-M6.cjs");
|
|
6
6
|
let zod = require("zod");
|
|
7
7
|
let node_async_hooks = require("node:async_hooks");
|
|
@@ -1123,6 +1123,25 @@ function llmUsageFromLanguageModelUsage(usage, resolved) {
|
|
|
1123
1123
|
}
|
|
1124
1124
|
};
|
|
1125
1125
|
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Baked-in AI SDK `providerOptions` a model needs for structured output.
|
|
1128
|
+
*
|
|
1129
|
+
* Anthropic-only today: the AI SDK default (`structuredOutputMode: "auto"`) falls back to a
|
|
1130
|
+
* forced `json` tool, which Anthropic rejects while extended thinking is enabled
|
|
1131
|
+
* ("Thinking may not be enabled when tool_choice forces tool use"). Since our agents default to
|
|
1132
|
+
* `thinkingLevel: "medium"`, every structured `agent.prompt`/`promptLlm` call hits that conflict
|
|
1133
|
+
* and stalls. Forcing `"outputFormat"` uses Anthropic's native JSON-schema output (no forced
|
|
1134
|
+
* tool), which is reasoning-compatible. The AI SDK provider docs do not warn about this, so the
|
|
1135
|
+
* rationale lives here. See vercel/ai#7220, #9351. Origin: changeset `8eaf54a` shipped
|
|
1136
|
+
* `Output.object` + always-on `reasoning` together with no guard.
|
|
1137
|
+
*
|
|
1138
|
+
* OpenAI/Google/xAI use native, reasoning-compatible structured output and need nothing here.
|
|
1139
|
+
*/
|
|
1140
|
+
function resolveProviderOptions(args) {
|
|
1141
|
+
if (!args.structuredOutput) return;
|
|
1142
|
+
const { vendor } = splitAgentModelId(args.modelId);
|
|
1143
|
+
if (vendor === "anthropic") return { anthropic: { structuredOutputMode: "outputFormat" } };
|
|
1144
|
+
}
|
|
1126
1145
|
function buildUserMessageParts(text, files) {
|
|
1127
1146
|
const parts = [];
|
|
1128
1147
|
const trimmed = text.trim();
|
|
@@ -1160,13 +1179,18 @@ async function streamAgentPrompt(config, input, options) {
|
|
|
1160
1179
|
let messagesForModel = await applyCapabilityPlaceholderToMessages(priorMessages, config.resolvedModel.capabilities);
|
|
1161
1180
|
if (config.experimentalDownload) messagesForModel = await hydrateChatAttachmentMessages(messagesForModel, config.experimentalDownload);
|
|
1162
1181
|
const modelMessages = await require_dist$2.convertToModelMessages(messagesForModel);
|
|
1182
|
+
const providerOptions = resolveProviderOptions({
|
|
1183
|
+
modelId: config.resolvedModel.modelId,
|
|
1184
|
+
structuredOutput: Boolean(options.outputSchema)
|
|
1185
|
+
});
|
|
1163
1186
|
const streamResult = await new require_dist$2.ToolLoopAgent({
|
|
1164
1187
|
model: config.resolvedModel.languageModel,
|
|
1165
1188
|
instructions: config.systemPrompt,
|
|
1166
1189
|
tools: aiTools,
|
|
1167
1190
|
reasoning: config.thinkingLevel,
|
|
1168
1191
|
...config.experimentalDownload ? { experimental_download: config.experimentalDownload } : {},
|
|
1169
|
-
...options.outputSchema ? { output: require_dist$2.output_exports.object({ schema: options.outputSchema }) } : {}
|
|
1192
|
+
...options.outputSchema ? { output: require_dist$2.output_exports.object({ schema: options.outputSchema }) } : {},
|
|
1193
|
+
...providerOptions ? { providerOptions } : {}
|
|
1170
1194
|
}).stream({
|
|
1171
1195
|
messages: modelMessages,
|
|
1172
1196
|
abortSignal: options.signal,
|
|
@@ -1617,7 +1641,7 @@ function defaultToMessage(params) {
|
|
|
1617
1641
|
}
|
|
1618
1642
|
throw new Error("Subagent tool params must include a non-empty \"message\" string.");
|
|
1619
1643
|
}
|
|
1620
|
-
function toSubagentTool(agent) {
|
|
1644
|
+
function toSubagentTool(agent, context = {}) {
|
|
1621
1645
|
const name = agent.slug;
|
|
1622
1646
|
return require_dist.defineTool({
|
|
1623
1647
|
name,
|
|
@@ -1634,7 +1658,11 @@ function toSubagentTool(agent) {
|
|
|
1634
1658
|
tool: name,
|
|
1635
1659
|
type: "subagent"
|
|
1636
1660
|
}
|
|
1637
|
-
}, async () => runDirectAgentPrompt(agent, agent.slug, { message: defaultToMessage(params) }, {
|
|
1661
|
+
}, async () => runDirectAgentPrompt(agent, agent.slug, { message: defaultToMessage(params) }, {
|
|
1662
|
+
tracing: { trigger: "subagent" },
|
|
1663
|
+
...context.credentials ? { credentials: context.credentials } : {},
|
|
1664
|
+
...context.oauthAdapter ? { oauthAdapter: context.oauthAdapter } : {}
|
|
1665
|
+
}));
|
|
1638
1666
|
if (result.error) throw new Error(result.error);
|
|
1639
1667
|
return {
|
|
1640
1668
|
content: [{
|
|
@@ -1684,13 +1712,13 @@ async function resolveAgentTools(tools, resolver, options) {
|
|
|
1684
1712
|
continue;
|
|
1685
1713
|
}
|
|
1686
1714
|
if (require_dist$2.isWorkflow(item)) {
|
|
1687
|
-
const tool = require_dist$2.resolveWorkflowTool(item);
|
|
1715
|
+
const tool = require_dist$2.resolveWorkflowTool(item, options?.childContext);
|
|
1688
1716
|
assertUniqueToolName(seenNames, tool);
|
|
1689
1717
|
prepared.push(tool);
|
|
1690
1718
|
continue;
|
|
1691
1719
|
}
|
|
1692
1720
|
if (isAgent(item)) {
|
|
1693
|
-
const tool = toSubagentTool(item);
|
|
1721
|
+
const tool = toSubagentTool(item, options?.childContext);
|
|
1694
1722
|
assertUniqueToolName(seenNames, tool);
|
|
1695
1723
|
prepared.push(tool);
|
|
1696
1724
|
continue;
|
|
@@ -1746,7 +1774,13 @@ async function buildAgentRuntime(def, ctx, runPrompt = {}, agentSlug) {
|
|
|
1746
1774
|
type: "agent",
|
|
1747
1775
|
key: assignmentTargetKey
|
|
1748
1776
|
} } : void 0;
|
|
1749
|
-
const resolved = await resolveAgentTools(def.tools ?? [], resolver, {
|
|
1777
|
+
const resolved = await resolveAgentTools(def.tools ?? [], resolver, {
|
|
1778
|
+
mcpCredentialContext,
|
|
1779
|
+
childContext: {
|
|
1780
|
+
credentials: runPrompt.credentials,
|
|
1781
|
+
oauthAdapter: runPrompt.oauthAdapter
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1750
1784
|
const captured = require_dist$2.captureCredentialToolErrors([
|
|
1751
1785
|
...memoryTools,
|
|
1752
1786
|
...resolved.tools,
|
|
@@ -2272,6 +2306,10 @@ async function runPromptObject(opts, hooks) {
|
|
|
2272
2306
|
const schema = opts.outputSchema;
|
|
2273
2307
|
if (!schema) throw new Error("outputSchema is required for structured LLM output");
|
|
2274
2308
|
const resolved = await resolvePromptModel(opts.model);
|
|
2309
|
+
const providerOptions = resolveProviderOptions({
|
|
2310
|
+
modelId: resolved.modelId,
|
|
2311
|
+
structuredOutput: true
|
|
2312
|
+
});
|
|
2275
2313
|
const result = await require_dist$2.generateObject({
|
|
2276
2314
|
model: resolved.languageModel,
|
|
2277
2315
|
system: opts.system,
|
|
@@ -2279,7 +2317,8 @@ async function runPromptObject(opts, hooks) {
|
|
|
2279
2317
|
schema,
|
|
2280
2318
|
...opts.temperature !== void 0 ? { temperature: opts.temperature } : {},
|
|
2281
2319
|
...opts.maxTokens !== void 0 ? { maxOutputTokens: opts.maxTokens } : {},
|
|
2282
|
-
...reasoningCallOption(opts.thinkingLevel)
|
|
2320
|
+
...reasoningCallOption(opts.thinkingLevel),
|
|
2321
|
+
...providerOptions ? { providerOptions } : {}
|
|
2283
2322
|
});
|
|
2284
2323
|
await recordUsage(resolved, result.usage, hooks);
|
|
2285
2324
|
return result.object;
|