@keystrokehq/keystroke 0.0.113 → 0.1.0
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 +22 -43
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.d.cts +2 -2
- package/dist/agent.d.mts +2 -2
- package/dist/agent.mjs +23 -39
- package/dist/agent.mjs.map +1 -1
- package/dist/{index-DlDI4B85.d.mts → index-B-0T983l.d.mts} +7 -34
- package/dist/index-B-0T983l.d.mts.map +1 -0
- package/dist/{index-CveEf6PN.d.cts → index-C1yABiQA.d.cts} +7 -34
- package/dist/index-C1yABiQA.d.cts.map +1 -0
- package/dist/trigger.d.cts +1 -1
- package/dist/trigger.d.mts +1 -1
- package/package.json +1 -1
- package/dist/index-CveEf6PN.d.cts.map +0 -1
- package/dist/index-DlDI4B85.d.mts.map +0 -1
package/dist/agent.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { l as ThinkingLevel, u as getModel } from "./index-BcMCpDKh.cjs";
|
|
2
|
-
import {
|
|
2
|
+
import { A as messages, B as AgentCreateInput, C as createAgent, D as errorMessage, E as defineTool, F as resolveAgentId, G as ThinkingLevelSchema, H as AgentModelId, I as resolveAgentTools, J as resolveThinkingLevel, K as parseAgentCreateInput, L as resolveAgentWorkspaceRoot, M as prepareAgentSession, N as prompt, O as getSubagentToolMetadata, P as resolveAgentAssets, R as runAgentPrompt, S as buildAgentRuntime, T as defineSubagentTool, U as AgentModelIdSchema, V as AgentCreateInputSchema, W as DEFAULT_THINKING_LEVEL, _ as SessionAgentMismatchError, a as AgentDefinitionInput, b as SubagentToolInherit, c as BuildAgentRuntimeContext, d as PromptInput, f as PromptResponse, g as SandboxedAgentRuntime, h as SUBAGENT_TOOL, i as AgentDefinition, j as normalizeAgentDefinition, k as loadAssetManifest, l as DefineAgentOptions, m as RunAgentPromptOptions, n as AgentAssetInput, o as AgentRuntime, p as ResolvedAgentAssets, q as resolveAgentModel, r as AgentConfig, s as AgentSnapshot, t as Agent, u as DefineSubagentToolInput, v as SubagentTool, w as defineAgent, x as SubagentToolMetadata, y as SubagentToolDetails, z as snapshot } from "./index-C1yABiQA.cjs";
|
|
3
3
|
import { a as McpDefinition, c as McpServerOptions, d as McpTransport, f as connectMcpDefinition, g as isMcp, h as defineMcp, i as McpConnection, l as McpStdioOptions, m as connectMcpStdio, n as McpAuthOptions, o as McpDefinitionInput, p as connectMcpServer, r as McpCallToolOptions, s as McpHttpTransport, t as ToolCredentialResolver, u as McpStdioTransport } from "./index-MfPRY7cK.cjs";
|
|
4
|
-
export { type Agent, type AgentAssetInput, type AgentConfig, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentModelId, AgentModelIdSchema, type AgentRuntime, type AgentSnapshot, type BuildAgentRuntimeContext, DEFAULT_THINKING_LEVEL, type DefineAgentOptions, type DefineSubagentToolInput, type McpAuthOptions, type McpCallToolOptions, type McpConnection, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpTransport, type
|
|
4
|
+
export { type Agent, type AgentAssetInput, type AgentConfig, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentModelId, AgentModelIdSchema, type AgentRuntime, type AgentSnapshot, type BuildAgentRuntimeContext, DEFAULT_THINKING_LEVEL, type DefineAgentOptions, type DefineSubagentToolInput, type McpAuthOptions, type McpCallToolOptions, type McpConnection, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpTransport, type PromptInput, type PromptResponse, type ResolvedAgentAssets, type RunAgentPromptOptions, SUBAGENT_TOOL, type SandboxedAgentRuntime, SessionAgentMismatchError, type SubagentTool, type SubagentToolDetails, type SubagentToolInherit, type SubagentToolMetadata, type ThinkingLevel, ThinkingLevelSchema, type ToolCredentialResolver, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, createAgent, defineAgent, defineMcp, defineSubagentTool, defineTool, errorMessage, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentId, resolveAgentModel, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, snapshot };
|
package/dist/agent.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { l as ThinkingLevel, u as getModel } from "./index-Bd_asjgz.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { A as messages, B as AgentCreateInput, C as createAgent, D as errorMessage, E as defineTool, F as resolveAgentId, G as ThinkingLevelSchema, H as AgentModelId, I as resolveAgentTools, J as resolveThinkingLevel, K as parseAgentCreateInput, L as resolveAgentWorkspaceRoot, M as prepareAgentSession, N as prompt, O as getSubagentToolMetadata, P as resolveAgentAssets, R as runAgentPrompt, S as buildAgentRuntime, T as defineSubagentTool, U as AgentModelIdSchema, V as AgentCreateInputSchema, W as DEFAULT_THINKING_LEVEL, _ as SessionAgentMismatchError, a as AgentDefinitionInput, b as SubagentToolInherit, c as BuildAgentRuntimeContext, d as PromptInput, f as PromptResponse, g as SandboxedAgentRuntime, h as SUBAGENT_TOOL, i as AgentDefinition, j as normalizeAgentDefinition, k as loadAssetManifest, l as DefineAgentOptions, m as RunAgentPromptOptions, n as AgentAssetInput, o as AgentRuntime, p as ResolvedAgentAssets, q as resolveAgentModel, r as AgentConfig, s as AgentSnapshot, t as Agent, u as DefineSubagentToolInput, v as SubagentTool, w as defineAgent, x as SubagentToolMetadata, y as SubagentToolDetails, z as snapshot } from "./index-B-0T983l.mjs";
|
|
3
3
|
import { a as McpDefinition, c as McpServerOptions, d as McpTransport, f as connectMcpDefinition, g as isMcp, h as defineMcp, i as McpConnection, l as McpStdioOptions, m as connectMcpStdio, n as McpAuthOptions, o as McpDefinitionInput, p as connectMcpServer, r as McpCallToolOptions, s as McpHttpTransport, t as ToolCredentialResolver, u as McpStdioTransport } from "./index-ptRM3z9H.mjs";
|
|
4
|
-
export { type Agent, type AgentAssetInput, type AgentConfig, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentModelId, AgentModelIdSchema, type AgentRuntime, type AgentSnapshot, type BuildAgentRuntimeContext, DEFAULT_THINKING_LEVEL, type DefineAgentOptions, type DefineSubagentToolInput, type McpAuthOptions, type McpCallToolOptions, type McpConnection, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpTransport, type
|
|
4
|
+
export { type Agent, type AgentAssetInput, type AgentConfig, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentModelId, AgentModelIdSchema, type AgentRuntime, type AgentSnapshot, type BuildAgentRuntimeContext, DEFAULT_THINKING_LEVEL, type DefineAgentOptions, type DefineSubagentToolInput, type McpAuthOptions, type McpCallToolOptions, type McpConnection, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpTransport, type PromptInput, type PromptResponse, type ResolvedAgentAssets, type RunAgentPromptOptions, SUBAGENT_TOOL, type SandboxedAgentRuntime, SessionAgentMismatchError, type SubagentTool, type SubagentToolDetails, type SubagentToolInherit, type SubagentToolMetadata, type ThinkingLevel, ThinkingLevelSchema, type ToolCredentialResolver, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, createAgent, defineAgent, defineMcp, defineSubagentTool, defineTool, errorMessage, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentId, resolveAgentModel, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, snapshot };
|
package/dist/agent.mjs
CHANGED
|
@@ -5310,16 +5310,10 @@ function validateToolArguments(tool, toolCall) {
|
|
|
5310
5310
|
throw new Error(errorMessage);
|
|
5311
5311
|
}
|
|
5312
5312
|
//#endregion
|
|
5313
|
-
//#region ../agent/dist/schemas-
|
|
5313
|
+
//#region ../agent/dist/schemas-i6pkwhd7.mjs
|
|
5314
5314
|
const getModelLoose = getModel;
|
|
5315
|
-
const
|
|
5316
|
-
|
|
5317
|
-
id: z.string().min(1)
|
|
5318
|
-
});
|
|
5319
|
-
const AgentModelIdSchema = z.union([z.string().regex(/^[a-z0-9-]+\/.+/, "model must be vendor/model-id"), LEGACY_MODEL_REF_SCHEMA.transform(({ provider, id }) => `${provider}/${id}`)]);
|
|
5320
|
-
function parseAgentModelId(input) {
|
|
5321
|
-
return AgentModelIdSchema.parse(input);
|
|
5322
|
-
}
|
|
5315
|
+
const AGENT_MODEL_ID_PATTERN = /^[a-z0-9-]+\/.+/;
|
|
5316
|
+
const AgentModelIdSchema = z.custom((value) => typeof value === "string" && AGENT_MODEL_ID_PATTERN.test(value), "model must be vendor/model-id");
|
|
5323
5317
|
function splitAgentModelId(modelId) {
|
|
5324
5318
|
const slash = modelId.indexOf("/");
|
|
5325
5319
|
return {
|
|
@@ -5327,12 +5321,8 @@ function splitAgentModelId(modelId) {
|
|
|
5327
5321
|
directId: modelId.slice(slash + 1)
|
|
5328
5322
|
};
|
|
5329
5323
|
}
|
|
5330
|
-
function isWorkerRuntime() {
|
|
5331
|
-
return process.env.KEYSTROKE_MODE === "worker";
|
|
5332
|
-
}
|
|
5333
|
-
/** Gateway transport when hosted or when a local gateway key is configured. */
|
|
5334
5324
|
function shouldUseGatewayTransport() {
|
|
5335
|
-
return
|
|
5325
|
+
return !!process.env.AI_GATEWAY_API_KEY?.trim();
|
|
5336
5326
|
}
|
|
5337
5327
|
function directModelIdCandidates(directId) {
|
|
5338
5328
|
const candidates = [directId];
|
|
@@ -5342,20 +5332,28 @@ function directModelIdCandidates(directId) {
|
|
|
5342
5332
|
if (dashToDot !== directId) candidates.push(dashToDot);
|
|
5343
5333
|
return candidates;
|
|
5344
5334
|
}
|
|
5335
|
+
function agentModelIdCandidates(modelId) {
|
|
5336
|
+
const { vendor, directId } = splitAgentModelId(modelId);
|
|
5337
|
+
return directModelIdCandidates(directId).map((candidate) => `${vendor}/${candidate}`);
|
|
5338
|
+
}
|
|
5345
5339
|
function resolveGatewayBaseUrl() {
|
|
5346
5340
|
const configured = process.env.AI_GATEWAY_BASE_URL?.trim();
|
|
5347
5341
|
if (!configured) return;
|
|
5348
5342
|
return configured.replace(/\/$/, "");
|
|
5349
5343
|
}
|
|
5350
5344
|
function resolveGatewayModel(modelId) {
|
|
5351
|
-
const
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5345
|
+
for (const candidate of agentModelIdCandidates(modelId)) {
|
|
5346
|
+
const registered = getModelLoose("vercel-ai-gateway", candidate);
|
|
5347
|
+
if (registered) {
|
|
5348
|
+
const baseUrl = resolveGatewayBaseUrl();
|
|
5349
|
+
if (!baseUrl) return registered;
|
|
5350
|
+
return {
|
|
5351
|
+
...registered,
|
|
5352
|
+
baseUrl
|
|
5353
|
+
};
|
|
5354
|
+
}
|
|
5355
|
+
}
|
|
5356
|
+
throw new Error(`Unknown gateway model: ${modelId}`);
|
|
5359
5357
|
}
|
|
5360
5358
|
function resolveDirectModel(modelId) {
|
|
5361
5359
|
const { vendor, directId } = splitAgentModelId(modelId);
|
|
@@ -5370,15 +5368,6 @@ function resolveAgentModel(modelId) {
|
|
|
5370
5368
|
if (shouldUseGatewayTransport()) return resolveGatewayModel(modelId);
|
|
5371
5369
|
return resolveDirectModel(modelId);
|
|
5372
5370
|
}
|
|
5373
|
-
/** Fail fast at discovery when a model id cannot be resolved in this runtime. */
|
|
5374
|
-
function validateAgentModel(modelId) {
|
|
5375
|
-
resolveAgentModel(modelId);
|
|
5376
|
-
}
|
|
5377
|
-
/** @deprecated Use {@link AgentModelId} string (`vendor/model-id`) instead. */
|
|
5378
|
-
const ModelRefSchema = z.object({
|
|
5379
|
-
provider: z.string(),
|
|
5380
|
-
id: z.string()
|
|
5381
|
-
});
|
|
5382
5371
|
const ThinkingLevelSchema = z.enum([
|
|
5383
5372
|
"off",
|
|
5384
5373
|
"minimal",
|
|
@@ -5395,11 +5384,7 @@ const AgentCreateInputSchema = z.object({
|
|
|
5395
5384
|
thinkingLevel: ThinkingLevelSchema.optional()
|
|
5396
5385
|
});
|
|
5397
5386
|
function parseAgentCreateInput(input) {
|
|
5398
|
-
|
|
5399
|
-
return {
|
|
5400
|
-
...parsed,
|
|
5401
|
-
model: parsed.model
|
|
5402
|
-
};
|
|
5387
|
+
return AgentCreateInputSchema.parse(input);
|
|
5403
5388
|
}
|
|
5404
5389
|
function resolveThinkingLevel(level) {
|
|
5405
5390
|
return level ?? "medium";
|
|
@@ -13984,8 +13969,7 @@ async function buildAgentRuntime(def, ctx, runPrompt = {}) {
|
|
|
13984
13969
|
model: resolveAgentModel(def.model),
|
|
13985
13970
|
thinkingLevel,
|
|
13986
13971
|
messages: ctx.messages,
|
|
13987
|
-
tools
|
|
13988
|
-
...isWorkerRuntime() ? { getApiKey: async () => process.env.WORKER_INTERNAL_TOKEN?.trim() ?? "" } : {}
|
|
13972
|
+
tools
|
|
13989
13973
|
}),
|
|
13990
13974
|
sandbox: handle.runtime,
|
|
13991
13975
|
tools,
|
|
@@ -14179,6 +14163,6 @@ function defineSubagentTool(input) {
|
|
|
14179
14163
|
return subagentTool;
|
|
14180
14164
|
}
|
|
14181
14165
|
//#endregion
|
|
14182
|
-
export { AgentCreateInputSchema, AgentModelIdSchema, DEFAULT_THINKING_LEVEL,
|
|
14166
|
+
export { AgentCreateInputSchema, AgentModelIdSchema, DEFAULT_THINKING_LEVEL, SUBAGENT_TOOL, SessionAgentMismatchError, ThinkingLevelSchema, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, createAgent, defineAgent, defineMcp, defineSubagentTool, defineTool, errorMessage, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentId, resolveAgentModel, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, snapshot };
|
|
14183
14167
|
|
|
14184
14168
|
//# sourceMappingURL=agent.mjs.map
|