@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.cjs
CHANGED
|
@@ -5321,16 +5321,10 @@ function validateToolArguments(tool, toolCall) {
|
|
|
5321
5321
|
throw new Error(errorMessage);
|
|
5322
5322
|
}
|
|
5323
5323
|
//#endregion
|
|
5324
|
-
//#region ../agent/dist/schemas-
|
|
5324
|
+
//#region ../agent/dist/schemas-i6pkwhd7.mjs
|
|
5325
5325
|
const getModelLoose = require_event_stream.getModel;
|
|
5326
|
-
const
|
|
5327
|
-
|
|
5328
|
-
id: zod.z.string().min(1)
|
|
5329
|
-
});
|
|
5330
|
-
const AgentModelIdSchema = zod.z.union([zod.z.string().regex(/^[a-z0-9-]+\/.+/, "model must be vendor/model-id"), LEGACY_MODEL_REF_SCHEMA.transform(({ provider, id }) => `${provider}/${id}`)]);
|
|
5331
|
-
function parseAgentModelId(input) {
|
|
5332
|
-
return AgentModelIdSchema.parse(input);
|
|
5333
|
-
}
|
|
5326
|
+
const AGENT_MODEL_ID_PATTERN = /^[a-z0-9-]+\/.+/;
|
|
5327
|
+
const AgentModelIdSchema = zod.z.custom((value) => typeof value === "string" && AGENT_MODEL_ID_PATTERN.test(value), "model must be vendor/model-id");
|
|
5334
5328
|
function splitAgentModelId(modelId) {
|
|
5335
5329
|
const slash = modelId.indexOf("/");
|
|
5336
5330
|
return {
|
|
@@ -5338,12 +5332,8 @@ function splitAgentModelId(modelId) {
|
|
|
5338
5332
|
directId: modelId.slice(slash + 1)
|
|
5339
5333
|
};
|
|
5340
5334
|
}
|
|
5341
|
-
function isWorkerRuntime() {
|
|
5342
|
-
return process.env.KEYSTROKE_MODE === "worker";
|
|
5343
|
-
}
|
|
5344
|
-
/** Gateway transport when hosted or when a local gateway key is configured. */
|
|
5345
5335
|
function shouldUseGatewayTransport() {
|
|
5346
|
-
return
|
|
5336
|
+
return !!process.env.AI_GATEWAY_API_KEY?.trim();
|
|
5347
5337
|
}
|
|
5348
5338
|
function directModelIdCandidates(directId) {
|
|
5349
5339
|
const candidates = [directId];
|
|
@@ -5353,20 +5343,28 @@ function directModelIdCandidates(directId) {
|
|
|
5353
5343
|
if (dashToDot !== directId) candidates.push(dashToDot);
|
|
5354
5344
|
return candidates;
|
|
5355
5345
|
}
|
|
5346
|
+
function agentModelIdCandidates(modelId) {
|
|
5347
|
+
const { vendor, directId } = splitAgentModelId(modelId);
|
|
5348
|
+
return directModelIdCandidates(directId).map((candidate) => `${vendor}/${candidate}`);
|
|
5349
|
+
}
|
|
5356
5350
|
function resolveGatewayBaseUrl() {
|
|
5357
5351
|
const configured = process.env.AI_GATEWAY_BASE_URL?.trim();
|
|
5358
5352
|
if (!configured) return;
|
|
5359
5353
|
return configured.replace(/\/$/, "");
|
|
5360
5354
|
}
|
|
5361
5355
|
function resolveGatewayModel(modelId) {
|
|
5362
|
-
const
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5356
|
+
for (const candidate of agentModelIdCandidates(modelId)) {
|
|
5357
|
+
const registered = getModelLoose("vercel-ai-gateway", candidate);
|
|
5358
|
+
if (registered) {
|
|
5359
|
+
const baseUrl = resolveGatewayBaseUrl();
|
|
5360
|
+
if (!baseUrl) return registered;
|
|
5361
|
+
return {
|
|
5362
|
+
...registered,
|
|
5363
|
+
baseUrl
|
|
5364
|
+
};
|
|
5365
|
+
}
|
|
5366
|
+
}
|
|
5367
|
+
throw new Error(`Unknown gateway model: ${modelId}`);
|
|
5370
5368
|
}
|
|
5371
5369
|
function resolveDirectModel(modelId) {
|
|
5372
5370
|
const { vendor, directId } = splitAgentModelId(modelId);
|
|
@@ -5381,15 +5379,6 @@ function resolveAgentModel(modelId) {
|
|
|
5381
5379
|
if (shouldUseGatewayTransport()) return resolveGatewayModel(modelId);
|
|
5382
5380
|
return resolveDirectModel(modelId);
|
|
5383
5381
|
}
|
|
5384
|
-
/** Fail fast at discovery when a model id cannot be resolved in this runtime. */
|
|
5385
|
-
function validateAgentModel(modelId) {
|
|
5386
|
-
resolveAgentModel(modelId);
|
|
5387
|
-
}
|
|
5388
|
-
/** @deprecated Use {@link AgentModelId} string (`vendor/model-id`) instead. */
|
|
5389
|
-
const ModelRefSchema = zod.z.object({
|
|
5390
|
-
provider: zod.z.string(),
|
|
5391
|
-
id: zod.z.string()
|
|
5392
|
-
});
|
|
5393
5382
|
const ThinkingLevelSchema = zod.z.enum([
|
|
5394
5383
|
"off",
|
|
5395
5384
|
"minimal",
|
|
@@ -5406,11 +5395,7 @@ const AgentCreateInputSchema = zod.z.object({
|
|
|
5406
5395
|
thinkingLevel: ThinkingLevelSchema.optional()
|
|
5407
5396
|
});
|
|
5408
5397
|
function parseAgentCreateInput(input) {
|
|
5409
|
-
|
|
5410
|
-
return {
|
|
5411
|
-
...parsed,
|
|
5412
|
-
model: parsed.model
|
|
5413
|
-
};
|
|
5398
|
+
return AgentCreateInputSchema.parse(input);
|
|
5414
5399
|
}
|
|
5415
5400
|
function resolveThinkingLevel(level) {
|
|
5416
5401
|
return level ?? "medium";
|
|
@@ -13995,8 +13980,7 @@ async function buildAgentRuntime(def, ctx, runPrompt = {}) {
|
|
|
13995
13980
|
model: resolveAgentModel(def.model),
|
|
13996
13981
|
thinkingLevel,
|
|
13997
13982
|
messages: ctx.messages,
|
|
13998
|
-
tools
|
|
13999
|
-
...isWorkerRuntime() ? { getApiKey: async () => process.env.WORKER_INTERNAL_TOKEN?.trim() ?? "" } : {}
|
|
13983
|
+
tools
|
|
14000
13984
|
}),
|
|
14001
13985
|
sandbox: handle.runtime,
|
|
14002
13986
|
tools,
|
|
@@ -14193,7 +14177,6 @@ function defineSubagentTool(input) {
|
|
|
14193
14177
|
exports.AgentCreateInputSchema = AgentCreateInputSchema;
|
|
14194
14178
|
exports.AgentModelIdSchema = AgentModelIdSchema;
|
|
14195
14179
|
exports.DEFAULT_THINKING_LEVEL = DEFAULT_THINKING_LEVEL;
|
|
14196
|
-
exports.ModelRefSchema = ModelRefSchema;
|
|
14197
14180
|
exports.SUBAGENT_TOOL = SUBAGENT_TOOL;
|
|
14198
14181
|
exports.SessionAgentMismatchError = SessionAgentMismatchError;
|
|
14199
14182
|
exports.ThinkingLevelSchema = ThinkingLevelSchema;
|
|
@@ -14210,12 +14193,10 @@ exports.errorMessage = errorMessage;
|
|
|
14210
14193
|
exports.getModel = require_event_stream.getModel;
|
|
14211
14194
|
exports.getSubagentToolMetadata = getSubagentToolMetadata;
|
|
14212
14195
|
exports.isMcp = require_dist$3.isMcp;
|
|
14213
|
-
exports.isWorkerRuntime = isWorkerRuntime;
|
|
14214
14196
|
exports.loadAssetManifest = loadAssetManifest;
|
|
14215
14197
|
exports.messages = messages;
|
|
14216
14198
|
exports.normalizeAgentDefinition = normalizeAgentDefinition;
|
|
14217
14199
|
exports.parseAgentCreateInput = parseAgentCreateInput;
|
|
14218
|
-
exports.parseAgentModelId = parseAgentModelId;
|
|
14219
14200
|
exports.prepareAgentSession = prepareAgentSession;
|
|
14220
14201
|
exports.prompt = prompt;
|
|
14221
14202
|
exports.resolveAgentAssets = resolveAgentAssets;
|
|
@@ -14225,8 +14206,6 @@ exports.resolveAgentTools = resolveAgentTools;
|
|
|
14225
14206
|
exports.resolveAgentWorkspaceRoot = resolveAgentWorkspaceRoot;
|
|
14226
14207
|
exports.resolveThinkingLevel = resolveThinkingLevel;
|
|
14227
14208
|
exports.runAgentPrompt = runAgentPrompt;
|
|
14228
|
-
exports.shouldUseGatewayTransport = shouldUseGatewayTransport;
|
|
14229
14209
|
exports.snapshot = snapshot;
|
|
14230
|
-
exports.validateAgentModel = validateAgentModel;
|
|
14231
14210
|
|
|
14232
14211
|
//# sourceMappingURL=agent.cjs.map
|