@keystrokehq/keystroke 0.1.36 → 0.1.37
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 +263 -11
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.mjs +263 -11
- package/dist/agent.mjs.map +1 -1
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/{dist-iDcp4e6O.mjs → dist-1heZMRTe.mjs} +172 -3
- package/dist/dist-1heZMRTe.mjs.map +1 -0
- package/dist/{dist-Di6PqKAu.cjs → dist-DlIUXcOB.cjs} +189 -2
- package/dist/dist-DlIUXcOB.cjs.map +1 -0
- package/dist/index-DUSEfNrG.d.cts.map +1 -1
- package/dist/index-DUSEfNrG.d.mts.map +1 -1
- package/dist/{token-DUN0yjzi.mjs → token-CJ2Rrkyp.mjs} +2 -2
- package/dist/{token-DUN0yjzi.mjs.map → token-CJ2Rrkyp.mjs.map} +1 -1
- package/dist/{token-CQiw-m2-.cjs → token-qixf8bl9.cjs} +2 -2
- package/dist/{token-CQiw-m2-.cjs.map → token-qixf8bl9.cjs.map} +1 -1
- package/dist/trigger.cjs +1 -1
- package/dist/trigger.mjs +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.mjs +1 -1
- package/package.json +1 -1
- package/dist/dist-Di6PqKAu.cjs.map +0 -1
- package/dist/dist-iDcp4e6O.mjs.map +0 -1
|
@@ -6890,7 +6890,7 @@ var require_get_vercel_oidc_token = /* @__PURE__ */ require_chunk.__commonJSMin(
|
|
|
6890
6890
|
err = error;
|
|
6891
6891
|
}
|
|
6892
6892
|
try {
|
|
6893
|
-
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([await Promise.resolve().then(() => /* @__PURE__ */ require_chunk.__toESM(require_token_util())), await Promise.resolve().then(() => /* @__PURE__ */ require_chunk.__toESM(require("./token-
|
|
6893
|
+
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([await Promise.resolve().then(() => /* @__PURE__ */ require_chunk.__toESM(require_token_util())), await Promise.resolve().then(() => /* @__PURE__ */ require_chunk.__toESM(require("./token-qixf8bl9.cjs").default))]);
|
|
6894
6894
|
if (!token || isExpired(getTokenPayload(token), options?.expirationBufferMs)) {
|
|
6895
6895
|
await refreshToken(options);
|
|
6896
6896
|
token = getVercelOidcTokenSync();
|
|
@@ -12428,6 +12428,12 @@ function createRestrictedTelemetryDispatcher({ telemetry, includeRuntimeContext,
|
|
|
12428
12428
|
function isStepCount(stepCount) {
|
|
12429
12429
|
return ({ steps }) => steps.length === stepCount;
|
|
12430
12430
|
}
|
|
12431
|
+
function hasToolCall(...toolName) {
|
|
12432
|
+
return ({ steps }) => {
|
|
12433
|
+
var _a22, _b, _c;
|
|
12434
|
+
return (_c = (_b = (_a22 = steps[steps.length - 1]) == null ? void 0 : _a22.toolCalls) == null ? void 0 : _b.some((toolCall) => toolName.includes(toolCall.toolName))) != null ? _c : false;
|
|
12435
|
+
};
|
|
12436
|
+
}
|
|
12431
12437
|
async function isStopConditionMet({ stopConditions, steps }) {
|
|
12432
12438
|
return (await Promise.all(stopConditions.map((condition) => condition({ steps })))).some((result) => result);
|
|
12433
12439
|
}
|
|
@@ -17295,6 +17301,169 @@ createIdGenerator({
|
|
|
17295
17301
|
prefix: "aiobj",
|
|
17296
17302
|
size: 24
|
|
17297
17303
|
});
|
|
17304
|
+
function defaultTransform(text2) {
|
|
17305
|
+
return text2.replace(/^```(?:json)?\s*\n?/, "").replace(/\n?```\s*$/, "").trim();
|
|
17306
|
+
}
|
|
17307
|
+
function extractJsonMiddleware(options) {
|
|
17308
|
+
var _a22;
|
|
17309
|
+
const transform = (_a22 = options == null ? void 0 : options.transform) != null ? _a22 : defaultTransform;
|
|
17310
|
+
const hasCustomTransform = (options == null ? void 0 : options.transform) !== void 0;
|
|
17311
|
+
return {
|
|
17312
|
+
specificationVersion: "v4",
|
|
17313
|
+
wrapGenerate: async ({ doGenerate }) => {
|
|
17314
|
+
const { content, ...rest } = await doGenerate();
|
|
17315
|
+
const transformedContent = [];
|
|
17316
|
+
for (const part of content) {
|
|
17317
|
+
if (part.type !== "text") {
|
|
17318
|
+
transformedContent.push(part);
|
|
17319
|
+
continue;
|
|
17320
|
+
}
|
|
17321
|
+
transformedContent.push({
|
|
17322
|
+
...part,
|
|
17323
|
+
text: transform(part.text)
|
|
17324
|
+
});
|
|
17325
|
+
}
|
|
17326
|
+
return {
|
|
17327
|
+
content: transformedContent,
|
|
17328
|
+
...rest
|
|
17329
|
+
};
|
|
17330
|
+
},
|
|
17331
|
+
wrapStream: async ({ doStream }) => {
|
|
17332
|
+
const { stream, ...rest } = await doStream();
|
|
17333
|
+
const textBlocks = createIdMap();
|
|
17334
|
+
const SUFFIX_BUFFER_SIZE = 12;
|
|
17335
|
+
return {
|
|
17336
|
+
stream: stream.pipeThrough(new TransformStream({ transform: (chunk, controller) => {
|
|
17337
|
+
if (chunk.type === "text-start") {
|
|
17338
|
+
textBlocks[chunk.id] = {
|
|
17339
|
+
startEvent: chunk,
|
|
17340
|
+
phase: hasCustomTransform ? "buffering" : "prefix",
|
|
17341
|
+
buffer: "",
|
|
17342
|
+
prefixStripped: false
|
|
17343
|
+
};
|
|
17344
|
+
return;
|
|
17345
|
+
}
|
|
17346
|
+
if (chunk.type === "text-delta") {
|
|
17347
|
+
const block = textBlocks[chunk.id];
|
|
17348
|
+
if (!block) {
|
|
17349
|
+
controller.enqueue(chunk);
|
|
17350
|
+
return;
|
|
17351
|
+
}
|
|
17352
|
+
block.buffer += chunk.delta;
|
|
17353
|
+
if (block.phase === "buffering") return;
|
|
17354
|
+
if (block.phase === "prefix") {
|
|
17355
|
+
if (block.buffer.length > 0 && !block.buffer.startsWith("`")) {
|
|
17356
|
+
block.phase = "streaming";
|
|
17357
|
+
controller.enqueue(block.startEvent);
|
|
17358
|
+
} else if (block.buffer.startsWith("```")) {
|
|
17359
|
+
if (block.buffer.includes("\n")) {
|
|
17360
|
+
const prefixMatch = block.buffer.match(/^```(?:json)?\s*\n/);
|
|
17361
|
+
if (prefixMatch) {
|
|
17362
|
+
block.buffer = block.buffer.slice(prefixMatch[0].length);
|
|
17363
|
+
block.prefixStripped = true;
|
|
17364
|
+
block.phase = "streaming";
|
|
17365
|
+
controller.enqueue(block.startEvent);
|
|
17366
|
+
} else {
|
|
17367
|
+
block.phase = "streaming";
|
|
17368
|
+
controller.enqueue(block.startEvent);
|
|
17369
|
+
}
|
|
17370
|
+
}
|
|
17371
|
+
} else if (block.buffer.length >= 3 && !block.buffer.startsWith("```")) {
|
|
17372
|
+
block.phase = "streaming";
|
|
17373
|
+
controller.enqueue(block.startEvent);
|
|
17374
|
+
}
|
|
17375
|
+
}
|
|
17376
|
+
if (block.phase === "streaming" && block.buffer.length > SUFFIX_BUFFER_SIZE) {
|
|
17377
|
+
const toStream = block.buffer.slice(0, -12);
|
|
17378
|
+
block.buffer = block.buffer.slice(-12);
|
|
17379
|
+
controller.enqueue({
|
|
17380
|
+
type: "text-delta",
|
|
17381
|
+
id: chunk.id,
|
|
17382
|
+
delta: toStream
|
|
17383
|
+
});
|
|
17384
|
+
}
|
|
17385
|
+
return;
|
|
17386
|
+
}
|
|
17387
|
+
if (chunk.type === "text-end") {
|
|
17388
|
+
const block = textBlocks[chunk.id];
|
|
17389
|
+
if (block) {
|
|
17390
|
+
if (block.phase === "prefix" || block.phase === "buffering") controller.enqueue(block.startEvent);
|
|
17391
|
+
let remaining = block.buffer;
|
|
17392
|
+
if (block.phase === "buffering") remaining = transform(remaining);
|
|
17393
|
+
else if (block.prefixStripped) remaining = remaining.replace(/\n?```\s*$/, "").trimEnd();
|
|
17394
|
+
else remaining = transform(remaining);
|
|
17395
|
+
if (remaining.length > 0) controller.enqueue({
|
|
17396
|
+
type: "text-delta",
|
|
17397
|
+
id: chunk.id,
|
|
17398
|
+
delta: remaining
|
|
17399
|
+
});
|
|
17400
|
+
controller.enqueue(chunk);
|
|
17401
|
+
delete textBlocks[chunk.id];
|
|
17402
|
+
return;
|
|
17403
|
+
}
|
|
17404
|
+
}
|
|
17405
|
+
controller.enqueue(chunk);
|
|
17406
|
+
} })),
|
|
17407
|
+
...rest
|
|
17408
|
+
};
|
|
17409
|
+
}
|
|
17410
|
+
};
|
|
17411
|
+
}
|
|
17412
|
+
var wrapLanguageModel = ({ model: inputModel, middleware: middlewareArg, modelId, providerId }) => {
|
|
17413
|
+
const model = asLanguageModelV4(inputModel);
|
|
17414
|
+
return [...asArray(middlewareArg)].reverse().reduce((wrappedModel, middleware) => {
|
|
17415
|
+
return doWrap({
|
|
17416
|
+
model: wrappedModel,
|
|
17417
|
+
middleware,
|
|
17418
|
+
modelId,
|
|
17419
|
+
providerId
|
|
17420
|
+
});
|
|
17421
|
+
}, model);
|
|
17422
|
+
};
|
|
17423
|
+
var doWrap = ({ model, middleware: { transformParams, wrapGenerate, wrapStream, overrideProvider, overrideModelId, overrideSupportedUrls }, modelId, providerId }) => {
|
|
17424
|
+
var _a22, _b, _c;
|
|
17425
|
+
async function doTransform({ params, type }) {
|
|
17426
|
+
return transformParams ? await transformParams({
|
|
17427
|
+
params,
|
|
17428
|
+
type,
|
|
17429
|
+
model
|
|
17430
|
+
}) : params;
|
|
17431
|
+
}
|
|
17432
|
+
return {
|
|
17433
|
+
specificationVersion: "v4",
|
|
17434
|
+
provider: (_a22 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a22 : model.provider,
|
|
17435
|
+
modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
|
|
17436
|
+
supportedUrls: (_c = overrideSupportedUrls == null ? void 0 : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
|
|
17437
|
+
async doGenerate(params) {
|
|
17438
|
+
const transformedParams = await doTransform({
|
|
17439
|
+
params,
|
|
17440
|
+
type: "generate"
|
|
17441
|
+
});
|
|
17442
|
+
const doGenerate = async () => await model.doGenerate(transformedParams);
|
|
17443
|
+
const doStream = async () => await model.doStream(transformedParams);
|
|
17444
|
+
return wrapGenerate ? await wrapGenerate({
|
|
17445
|
+
doGenerate,
|
|
17446
|
+
doStream,
|
|
17447
|
+
params: transformedParams,
|
|
17448
|
+
model
|
|
17449
|
+
}) : await doGenerate();
|
|
17450
|
+
},
|
|
17451
|
+
async doStream(params) {
|
|
17452
|
+
const transformedParams = await doTransform({
|
|
17453
|
+
params,
|
|
17454
|
+
type: "stream"
|
|
17455
|
+
});
|
|
17456
|
+
const doGenerate = async () => await model.doGenerate(transformedParams);
|
|
17457
|
+
const doStream = async () => await model.doStream(transformedParams);
|
|
17458
|
+
return wrapStream ? await wrapStream({
|
|
17459
|
+
doGenerate,
|
|
17460
|
+
doStream,
|
|
17461
|
+
params: transformedParams,
|
|
17462
|
+
model
|
|
17463
|
+
}) : await doStream();
|
|
17464
|
+
}
|
|
17465
|
+
};
|
|
17466
|
+
};
|
|
17298
17467
|
createIdGenerator({
|
|
17299
17468
|
prefix: "call",
|
|
17300
17469
|
size: 24
|
|
@@ -47119,6 +47288,12 @@ Object.defineProperty(exports, "executeWorkflow", {
|
|
|
47119
47288
|
return executeWorkflow;
|
|
47120
47289
|
}
|
|
47121
47290
|
});
|
|
47291
|
+
Object.defineProperty(exports, "extractJsonMiddleware", {
|
|
47292
|
+
enumerable: true,
|
|
47293
|
+
get: function() {
|
|
47294
|
+
return extractJsonMiddleware;
|
|
47295
|
+
}
|
|
47296
|
+
});
|
|
47122
47297
|
Object.defineProperty(exports, "failAgentSession", {
|
|
47123
47298
|
enumerable: true,
|
|
47124
47299
|
get: function() {
|
|
@@ -47167,6 +47342,12 @@ Object.defineProperty(exports, "getTraceContext", {
|
|
|
47167
47342
|
return getTraceContext;
|
|
47168
47343
|
}
|
|
47169
47344
|
});
|
|
47345
|
+
Object.defineProperty(exports, "hasToolCall", {
|
|
47346
|
+
enumerable: true,
|
|
47347
|
+
get: function() {
|
|
47348
|
+
return hasToolCall;
|
|
47349
|
+
}
|
|
47350
|
+
});
|
|
47170
47351
|
Object.defineProperty(exports, "isCredentialError", {
|
|
47171
47352
|
enumerable: true,
|
|
47172
47353
|
get: function() {
|
|
@@ -47329,5 +47510,11 @@ Object.defineProperty(exports, "withSpan", {
|
|
|
47329
47510
|
return withSpan;
|
|
47330
47511
|
}
|
|
47331
47512
|
});
|
|
47513
|
+
Object.defineProperty(exports, "wrapLanguageModel", {
|
|
47514
|
+
enumerable: true,
|
|
47515
|
+
get: function() {
|
|
47516
|
+
return wrapLanguageModel;
|
|
47517
|
+
}
|
|
47518
|
+
});
|
|
47332
47519
|
|
|
47333
|
-
//# sourceMappingURL=dist-
|
|
47520
|
+
//# sourceMappingURL=dist-DlIUXcOB.cjs.map
|