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