@keystrokehq/keystroke 0.0.100 → 0.0.102
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/action.cjs +2 -1
- package/dist/action.d.cts +2 -2
- package/dist/action.d.mts +2 -2
- package/dist/action.mjs +2 -2
- package/dist/agent.cjs +144 -116
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.d.cts +3 -274
- package/dist/agent.d.mts +3 -274
- package/dist/agent.mjs +144 -117
- package/dist/agent.mjs.map +1 -1
- package/dist/credentials.cjs +1 -1
- package/dist/credentials.mjs +1 -1
- package/dist/{dist-BML_gJSh.mjs → dist-BUfE2se6.mjs} +115 -42
- package/dist/{dist-BML_gJSh.mjs.map → dist-BUfE2se6.mjs.map} +1 -1
- package/dist/{dist-ByV6mHKd.cjs → dist-BkC9pJIu.cjs} +120 -41
- package/dist/{dist-ByV6mHKd.cjs.map → dist-BkC9pJIu.cjs.map} +1 -1
- package/dist/{dist-CxaI84Ch.cjs → dist-C8RdaDkW.cjs} +110 -79
- package/dist/dist-C8RdaDkW.cjs.map +1 -0
- package/dist/{dist-CiaGdqFg.mjs → dist-DY_F2zw5.mjs} +110 -79
- package/dist/dist-DY_F2zw5.mjs.map +1 -0
- package/dist/{dist-T7a5DjzV.cjs → dist-DnqDVVpK.cjs} +51 -8
- package/dist/dist-DnqDVVpK.cjs.map +1 -0
- package/dist/{dist-B1fqDXYa.mjs → dist-SGAuX401.mjs} +46 -9
- package/dist/dist-SGAuX401.mjs.map +1 -0
- package/dist/{index-CfK7yBQI.d.cts → index-B6BYxmgO.d.cts} +14 -3
- package/dist/index-B6BYxmgO.d.cts.map +1 -0
- package/dist/index-CiuCYKLw.d.cts.map +1 -1
- package/dist/index-CiuCYKLw.d.mts.map +1 -1
- package/dist/{index-DwZkaYLS.d.mts → index-DsP83E4y.d.mts} +10 -3
- package/dist/index-DsP83E4y.d.mts.map +1 -0
- package/dist/{index-by6PXA-8.d.mts → index-DtcAWajc.d.mts} +14 -3
- package/dist/index-DtcAWajc.d.mts.map +1 -0
- package/dist/index-FlkwP4zn.d.cts +279 -0
- package/dist/index-FlkwP4zn.d.cts.map +1 -0
- package/dist/index-TLlgJ1q1.d.mts +279 -0
- package/dist/index-TLlgJ1q1.d.mts.map +1 -0
- package/dist/{index-C6_DVB_V.d.cts → index-i9JrhOqL.d.cts} +10 -3
- package/dist/index-i9JrhOqL.d.cts.map +1 -0
- package/dist/{mistral-CI7CQc_C.mjs → mistral-DUtxOD_C.mjs} +2 -2
- package/dist/{mistral-CI7CQc_C.mjs.map → mistral-DUtxOD_C.mjs.map} +1 -1
- package/dist/{mistral-BLRy436m.cjs → mistral-DXb4X3t4.cjs} +2 -2
- package/dist/{mistral-BLRy436m.cjs.map → mistral-DXb4X3t4.cjs.map} +1 -1
- package/dist/{sse-Bxvdniu5.mjs → sse-DezHFNKg.mjs} +2 -2
- package/dist/{sse-Bxvdniu5.mjs.map → sse-DezHFNKg.mjs.map} +1 -1
- package/dist/{sse-DGaTY14k.cjs → sse-SwZnScle.cjs} +2 -2
- package/dist/{sse-DGaTY14k.cjs.map → sse-SwZnScle.cjs.map} +1 -1
- package/dist/trigger.cjs +67 -30
- package/dist/trigger.cjs.map +1 -1
- package/dist/trigger.d.cts +38 -23
- package/dist/trigger.d.cts.map +1 -1
- package/dist/trigger.d.mts +38 -23
- package/dist/trigger.d.mts.map +1 -1
- package/dist/trigger.mjs +65 -31
- package/dist/trigger.mjs.map +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 +1 -1
- package/dist/agent.d.cts.map +0 -1
- package/dist/agent.d.mts.map +0 -1
- package/dist/dist-B1fqDXYa.mjs.map +0 -1
- package/dist/dist-CiaGdqFg.mjs.map +0 -1
- package/dist/dist-CxaI84Ch.cjs.map +0 -1
- package/dist/dist-T7a5DjzV.cjs.map +0 -1
- package/dist/index-C6_DVB_V.d.cts.map +0 -1
- package/dist/index-CfK7yBQI.d.cts.map +0 -1
- package/dist/index-DwZkaYLS.d.mts.map +0 -1
- package/dist/index-by6PXA-8.d.mts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_dist$1 = require("./dist-CLqJza2Y.cjs");
|
|
2
|
-
const require_dist$2 = require("./dist-
|
|
2
|
+
const require_dist$2 = require("./dist-DnqDVVpK.cjs");
|
|
3
3
|
let node_async_hooks = require("node:async_hooks");
|
|
4
4
|
require("node:fs");
|
|
5
5
|
let zod_v3 = require("zod/v3");
|
|
@@ -13262,7 +13262,7 @@ async function connectMcpServer(name, options) {
|
|
|
13262
13262
|
}
|
|
13263
13263
|
async function createTransport(url, transport, requestInit, fetchImpl) {
|
|
13264
13264
|
if (transport === "sse") {
|
|
13265
|
-
const { SSEClientTransport } = await Promise.resolve().then(() => require("./sse-
|
|
13265
|
+
const { SSEClientTransport } = await Promise.resolve().then(() => require("./sse-SwZnScle.cjs"));
|
|
13266
13266
|
return new SSEClientTransport(url, {
|
|
13267
13267
|
requestInit,
|
|
13268
13268
|
fetch: fetchImpl
|
|
@@ -15763,6 +15763,16 @@ function and(...unfilteredConditions) {
|
|
|
15763
15763
|
new StringChunk(")")
|
|
15764
15764
|
]);
|
|
15765
15765
|
}
|
|
15766
|
+
function or(...unfilteredConditions) {
|
|
15767
|
+
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
15768
|
+
if (conditions.length === 0) return;
|
|
15769
|
+
if (conditions.length === 1) return new SQL(conditions);
|
|
15770
|
+
return new SQL([
|
|
15771
|
+
new StringChunk("("),
|
|
15772
|
+
sql.join(conditions, new StringChunk(" or ")),
|
|
15773
|
+
new StringChunk(")")
|
|
15774
|
+
]);
|
|
15775
|
+
}
|
|
15766
15776
|
function isNull(value) {
|
|
15767
15777
|
return sql`${value} is null`;
|
|
15768
15778
|
}
|
|
@@ -16341,6 +16351,41 @@ function index(name) {
|
|
|
16341
16351
|
function uniqueIndex(name) {
|
|
16342
16352
|
return new IndexBuilderOn(name, true);
|
|
16343
16353
|
}
|
|
16354
|
+
const traceContextStorage = new node_async_hooks.AsyncLocalStorage();
|
|
16355
|
+
function getTraceContext() {
|
|
16356
|
+
return traceContextStorage.getStore();
|
|
16357
|
+
}
|
|
16358
|
+
const CONSOLE_LEVELS = [
|
|
16359
|
+
"log",
|
|
16360
|
+
"debug",
|
|
16361
|
+
"info",
|
|
16362
|
+
"warn",
|
|
16363
|
+
"error"
|
|
16364
|
+
];
|
|
16365
|
+
async function captureConsole(fn) {
|
|
16366
|
+
const originals = /* @__PURE__ */ new Map();
|
|
16367
|
+
for (const level of CONSOLE_LEVELS) {
|
|
16368
|
+
originals.set(level, console[level].bind(console));
|
|
16369
|
+
console[level] = (...args) => {
|
|
16370
|
+
originals.get(level)?.(...args);
|
|
16371
|
+
getTraceContext();
|
|
16372
|
+
};
|
|
16373
|
+
}
|
|
16374
|
+
try {
|
|
16375
|
+
return await fn();
|
|
16376
|
+
} finally {
|
|
16377
|
+
for (const level of CONSOLE_LEVELS) {
|
|
16378
|
+
const original = originals.get(level);
|
|
16379
|
+
if (original) console[level] = original;
|
|
16380
|
+
}
|
|
16381
|
+
}
|
|
16382
|
+
}
|
|
16383
|
+
async function logSystem(level, message, data) {
|
|
16384
|
+
getTraceContext();
|
|
16385
|
+
}
|
|
16386
|
+
async function withSpan(input, fn) {
|
|
16387
|
+
return await fn();
|
|
16388
|
+
}
|
|
16344
16389
|
//#endregion
|
|
16345
16390
|
//#region ../database/dist/index.mjs
|
|
16346
16391
|
const tenantScopeStorage = new node_async_hooks.AsyncLocalStorage();
|
|
@@ -16400,6 +16445,8 @@ const agentSessions = pgTable("agent_sessions", {
|
|
|
16400
16445
|
id: text$1("id").primaryKey(),
|
|
16401
16446
|
projectId: text$1("project_id").notNull(),
|
|
16402
16447
|
agentId: text$1("agent_id").notNull().references(() => agents.id),
|
|
16448
|
+
sourceKind: text$1("source_kind").$type().notNull().default("api"),
|
|
16449
|
+
sourceId: text$1("source_id"),
|
|
16403
16450
|
parentSpanId: text$1("parent_span_id"),
|
|
16404
16451
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
16405
16452
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
@@ -16409,6 +16456,8 @@ const agentSessionsSqlite = sqliteTable("agent_sessions", {
|
|
|
16409
16456
|
id: text("id").primaryKey(),
|
|
16410
16457
|
projectId: text("project_id").notNull(),
|
|
16411
16458
|
agentId: text("agent_id").notNull().references(() => agentsSqlite.id),
|
|
16459
|
+
sourceKind: text("source_kind").$type().notNull().default("api"),
|
|
16460
|
+
sourceId: text("source_id"),
|
|
16412
16461
|
parentSpanId: text("parent_span_id"),
|
|
16413
16462
|
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
16414
16463
|
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
@@ -16436,7 +16485,9 @@ const triggerAttachments = pgTable("trigger_attachments", {
|
|
|
16436
16485
|
id: text$1("id").primaryKey(),
|
|
16437
16486
|
projectId: text$1("project_id").notNull(),
|
|
16438
16487
|
key: text$1("key").notNull(),
|
|
16439
|
-
|
|
16488
|
+
targetKind: text$1("target_kind").$type().notNull().default("workflow"),
|
|
16489
|
+
workflowKey: text$1("workflow_key"),
|
|
16490
|
+
agentKey: text$1("agent_key"),
|
|
16440
16491
|
moduleFile: text$1("module_file").notNull(),
|
|
16441
16492
|
source: jsonb("source").$type().notNull(),
|
|
16442
16493
|
registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
|
|
@@ -16447,7 +16498,9 @@ const triggerAttachmentsSqlite = sqliteTable("trigger_attachments", {
|
|
|
16447
16498
|
id: text("id").primaryKey(),
|
|
16448
16499
|
projectId: text("project_id").notNull(),
|
|
16449
16500
|
key: text("key").notNull(),
|
|
16450
|
-
|
|
16501
|
+
targetKind: text("target_kind").$type().notNull().default("workflow"),
|
|
16502
|
+
workflowKey: text("workflow_key"),
|
|
16503
|
+
agentKey: text("agent_key"),
|
|
16451
16504
|
moduleFile: text("module_file").notNull(),
|
|
16452
16505
|
source: text("source", { mode: "json" }).$type().notNull(),
|
|
16453
16506
|
registeredAt: integer("registered_at", { mode: "timestamp_ms" }).notNull(),
|
|
@@ -16519,6 +16572,8 @@ const workflowRuns = pgTable("workflow_runs", {
|
|
|
16519
16572
|
triggerRunId: text$1("trigger_run_id").references(() => triggerRuns.id),
|
|
16520
16573
|
parentWorkflowRunId: text$1("parent_workflow_run_id"),
|
|
16521
16574
|
parentSpanId: text$1("parent_span_id"),
|
|
16575
|
+
sourceKind: text$1("source_kind").$type().notNull().default("api"),
|
|
16576
|
+
sourceId: text$1("source_id"),
|
|
16522
16577
|
status: text$1("status").$type().notNull(),
|
|
16523
16578
|
trigger: text$1("trigger").$type().notNull(),
|
|
16524
16579
|
triggeredAt: timestamp("triggered_at", { withTimezone: true }).notNull(),
|
|
@@ -16537,6 +16592,8 @@ const workflowRunsSqlite = sqliteTable("workflow_runs", {
|
|
|
16537
16592
|
triggerRunId: text("trigger_run_id").references(() => triggerRunsSqlite.id),
|
|
16538
16593
|
parentWorkflowRunId: text("parent_workflow_run_id"),
|
|
16539
16594
|
parentSpanId: text("parent_span_id"),
|
|
16595
|
+
sourceKind: text("source_kind").$type().notNull().default("api"),
|
|
16596
|
+
sourceId: text("source_id"),
|
|
16540
16597
|
status: text("status").$type().notNull(),
|
|
16541
16598
|
trigger: text("trigger").$type().notNull(),
|
|
16542
16599
|
triggeredAt: integer("triggered_at", { mode: "timestamp_ms" }).notNull(),
|
|
@@ -16944,6 +17001,10 @@ function scopedAnd$1(table, ...conditions) {
|
|
|
16944
17001
|
function projectScopeId() {
|
|
16945
17002
|
return getProjectScopeId();
|
|
16946
17003
|
}
|
|
17004
|
+
/** Use with left joins on workflowRuns/triggerRuns/agentSessions keyed by trace or ref id. */
|
|
17005
|
+
function traceRootProjectScopeFilter() {
|
|
17006
|
+
return or(eq(workflowRuns.projectId, getProjectScopeId()), eq(triggerRuns.projectId, getProjectScopeId()), eq(agentSessions.projectId, getProjectScopeId()));
|
|
17007
|
+
}
|
|
16947
17008
|
async function selectActiveAgentByRoute(route) {
|
|
16948
17009
|
return (await getDb$1().select({
|
|
16949
17010
|
id: agents.id,
|
|
@@ -16953,6 +17014,8 @@ async function selectActiveAgentByRoute(route) {
|
|
|
16953
17014
|
async function insertAgentSession(values) {
|
|
16954
17015
|
await getDb$1().insert(agentSessions).values({
|
|
16955
17016
|
...values,
|
|
17017
|
+
sourceKind: values.sourceKind ?? "api",
|
|
17018
|
+
sourceId: values.sourceId ?? null,
|
|
16956
17019
|
projectId: projectScopeId()
|
|
16957
17020
|
});
|
|
16958
17021
|
}
|
|
@@ -16990,16 +17053,61 @@ async function selectCredentialInstancesForScope$1(key, scopeType, scopeId) {
|
|
|
16990
17053
|
const scopeCondition = scopeId === null ? and(eq(credentialInstances.scopeType, scopeType), isNull(credentialInstances.scopeId)) : and(eq(credentialInstances.scopeType, scopeType), eq(credentialInstances.scopeId, scopeId));
|
|
16991
17054
|
return db.select().from(credentialInstances).where(credentialScopeAnd(scopeType, eq(credentialInstances.key, key), scopeCondition));
|
|
16992
17055
|
}
|
|
17056
|
+
async function selectTraceSpanById(id) {
|
|
17057
|
+
const db = getDb$1();
|
|
17058
|
+
const rows = await db.select({ span: traceSpans }).from(traceSpans).leftJoin(workflowRuns, eq(workflowRuns.id, traceSpans.traceId)).leftJoin(triggerRuns, eq(triggerRuns.id, traceSpans.traceId)).leftJoin(agentSessions, eq(agentSessions.id, traceSpans.traceId)).where(and(eq(traceSpans.id, id), traceRootProjectScopeFilter())).limit(1);
|
|
17059
|
+
if (rows[0]) return rows[0].span;
|
|
17060
|
+
return (await db.select({ span: traceSpans }).from(traceSpans).leftJoin(workflowRuns, eq(workflowRuns.id, traceSpans.refId)).leftJoin(triggerRuns, eq(triggerRuns.id, traceSpans.refId)).leftJoin(agentSessions, eq(agentSessions.id, traceSpans.refId)).where(and(eq(traceSpans.id, id), traceRootProjectScopeFilter())).limit(1))[0]?.span;
|
|
17061
|
+
}
|
|
17062
|
+
function runSource(kind, id) {
|
|
17063
|
+
return {
|
|
17064
|
+
kind,
|
|
17065
|
+
id: id ?? null
|
|
17066
|
+
};
|
|
17067
|
+
}
|
|
17068
|
+
function sourceFromSpan(span) {
|
|
17069
|
+
switch (span.kind) {
|
|
17070
|
+
case "workflow_run": return runSource("workflow", span.refId);
|
|
17071
|
+
case "agent_session": return runSource("agent", span.refId);
|
|
17072
|
+
case "trigger_run": return runSource("trigger", span.refId);
|
|
17073
|
+
case "gateway_event": {
|
|
17074
|
+
const metadata = span.metadata;
|
|
17075
|
+
if (metadata && typeof metadata === "object" && "gatewayAttachmentId" in metadata) {
|
|
17076
|
+
const attachmentId = metadata.gatewayAttachmentId;
|
|
17077
|
+
if (typeof attachmentId === "string") return runSource("gateway", attachmentId);
|
|
17078
|
+
}
|
|
17079
|
+
return;
|
|
17080
|
+
}
|
|
17081
|
+
case "action": {
|
|
17082
|
+
const metadata = span.metadata;
|
|
17083
|
+
if (metadata && typeof metadata === "object" && "runId" in metadata) {
|
|
17084
|
+
const runId = metadata.runId;
|
|
17085
|
+
if (typeof runId === "string") return runSource("workflow", runId);
|
|
17086
|
+
}
|
|
17087
|
+
return;
|
|
17088
|
+
}
|
|
17089
|
+
default: return;
|
|
17090
|
+
}
|
|
17091
|
+
}
|
|
17092
|
+
async function resolveRunSourceFromTraceContext() {
|
|
17093
|
+
const parent = getTraceContext();
|
|
17094
|
+
if (!parent?.spanId) return runSource("api");
|
|
17095
|
+
const span = await selectTraceSpanById(parent.spanId);
|
|
17096
|
+
if (!span) return runSource("api");
|
|
17097
|
+
return sourceFromSpan(span) ?? runSource("api");
|
|
17098
|
+
}
|
|
16993
17099
|
async function getAgentByRoute(route) {
|
|
16994
17100
|
return selectActiveAgentByRoute(route);
|
|
16995
17101
|
}
|
|
16996
17102
|
const MESSAGE_EVENT_TYPE = "message";
|
|
16997
|
-
async function createSession(agentId, id) {
|
|
17103
|
+
async function createSession(agentId, id, source = runSource("api")) {
|
|
16998
17104
|
const now = /* @__PURE__ */ new Date();
|
|
16999
17105
|
const sessionId = id ?? crypto.randomUUID();
|
|
17000
17106
|
await insertAgentSession({
|
|
17001
17107
|
id: sessionId,
|
|
17002
17108
|
agentId,
|
|
17109
|
+
sourceKind: source.kind,
|
|
17110
|
+
sourceId: source.id,
|
|
17003
17111
|
createdAt: now,
|
|
17004
17112
|
updatedAt: now,
|
|
17005
17113
|
deletedAt: null
|
|
@@ -17999,41 +18107,6 @@ async function resolveActionCredentials(requirements, options) {
|
|
|
17999
18107
|
});
|
|
18000
18108
|
return parseResolvedCredentials(requirements, await resolveCredentials(requirements, options.consumer, options.contextOverride));
|
|
18001
18109
|
}
|
|
18002
|
-
const traceContextStorage = new node_async_hooks.AsyncLocalStorage();
|
|
18003
|
-
function getTraceContext() {
|
|
18004
|
-
return traceContextStorage.getStore();
|
|
18005
|
-
}
|
|
18006
|
-
const CONSOLE_LEVELS = [
|
|
18007
|
-
"log",
|
|
18008
|
-
"debug",
|
|
18009
|
-
"info",
|
|
18010
|
-
"warn",
|
|
18011
|
-
"error"
|
|
18012
|
-
];
|
|
18013
|
-
async function captureConsole(fn) {
|
|
18014
|
-
const originals = /* @__PURE__ */ new Map();
|
|
18015
|
-
for (const level of CONSOLE_LEVELS) {
|
|
18016
|
-
originals.set(level, console[level].bind(console));
|
|
18017
|
-
console[level] = (...args) => {
|
|
18018
|
-
originals.get(level)?.(...args);
|
|
18019
|
-
getTraceContext();
|
|
18020
|
-
};
|
|
18021
|
-
}
|
|
18022
|
-
try {
|
|
18023
|
-
return await fn();
|
|
18024
|
-
} finally {
|
|
18025
|
-
for (const level of CONSOLE_LEVELS) {
|
|
18026
|
-
const original = originals.get(level);
|
|
18027
|
-
if (original) console[level] = original;
|
|
18028
|
-
}
|
|
18029
|
-
}
|
|
18030
|
-
}
|
|
18031
|
-
async function logSystem(level, message, data) {
|
|
18032
|
-
getTraceContext();
|
|
18033
|
-
}
|
|
18034
|
-
async function withSpan(input, fn) {
|
|
18035
|
-
return await fn();
|
|
18036
|
-
}
|
|
18037
18110
|
//#endregion
|
|
18038
18111
|
Object.defineProperty(exports, "JSONRPCMessageSchema", {
|
|
18039
18112
|
enumerable: true,
|
|
@@ -18197,6 +18270,12 @@ Object.defineProperty(exports, "resolveMcpTools", {
|
|
|
18197
18270
|
return resolveMcpTools;
|
|
18198
18271
|
}
|
|
18199
18272
|
});
|
|
18273
|
+
Object.defineProperty(exports, "resolveRunSourceFromTraceContext", {
|
|
18274
|
+
enumerable: true,
|
|
18275
|
+
get: function() {
|
|
18276
|
+
return resolveRunSourceFromTraceContext;
|
|
18277
|
+
}
|
|
18278
|
+
});
|
|
18200
18279
|
Object.defineProperty(exports, "touchSession", {
|
|
18201
18280
|
enumerable: true,
|
|
18202
18281
|
get: function() {
|
|
@@ -18216,4 +18295,4 @@ Object.defineProperty(exports, "zodToJsonSchema", {
|
|
|
18216
18295
|
}
|
|
18217
18296
|
});
|
|
18218
18297
|
|
|
18219
|
-
//# sourceMappingURL=dist-
|
|
18298
|
+
//# sourceMappingURL=dist-BkC9pJIu.cjs.map
|