@keystrokehq/cli 0.1.18 → 0.1.20
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/{dist-DR8DYUc4.mjs → dist-5F59cW3X.mjs} +3 -3
- package/dist/dist-5F59cW3X.mjs.map +1 -0
- package/dist/{dist-BaOUOcKY.mjs → dist-BYODo4g3.mjs} +2103 -1498
- package/dist/dist-BYODo4g3.mjs.map +1 -0
- package/dist/dist-CJ2FFTtR.mjs +3 -0
- package/dist/{dist-CNZVjlhC.mjs → dist-DmqYCJqU.mjs} +5 -2
- package/dist/{dist-CNZVjlhC.mjs.map → dist-DmqYCJqU.mjs.map} +1 -1
- package/dist/{dist-RRjysgkw.mjs → dist-QE1G9hAR.mjs} +2 -2
- package/dist/{dist-RRjysgkw.mjs.map → dist-QE1G9hAR.mjs.map} +1 -1
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{maybe-auto-update-BNvizwom.mjs → maybe-auto-update-DVsgC8Cq.mjs} +2 -2
- package/dist/{maybe-auto-update-BNvizwom.mjs.map → maybe-auto-update-DVsgC8Cq.mjs.map} +1 -1
- package/dist/skills-bundle/_AGENTS.md +2 -0
- package/dist/skills-bundle/skills/keystroke-agents/SKILL.md +2 -2
- package/dist/skills-bundle/skills/keystroke-agents/references/tools-mcp-codemode.md +2 -2
- package/dist/skills-bundle/skills/keystroke-cli/SKILL.md +13 -0
- package/dist/skills-bundle/skills/keystroke-workflows/SKILL.md +1 -1
- package/dist/skills-bundle/skills/keystroke-workflows/references/authoring.md +3 -3
- package/dist/templates/hello-world/src/agents/hello.ts +1 -1
- package/dist/{version-Dv-7vfQn.mjs → version-BudDbxko.mjs} +2 -2
- package/dist/{version-Dv-7vfQn.mjs.map → version-BudDbxko.mjs.map} +1 -1
- package/package.json +3 -4
- package/dist/dist-BaOUOcKY.mjs.map +0 -1
- package/dist/dist-DR8DYUc4.mjs.map +0 -1
- package/dist/dist-Wchlpwl7.mjs +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { n as __require, t as __commonJSMin } from "./chunk-DiodbrVj.mjs";
|
|
3
|
-
import { $n as
|
|
4
|
-
import "./dist-
|
|
3
|
+
import { $n as _enum, Qn as ZodType, Rn as credentialInputSchema, Un as normalizeCredentialList, Ut as PromptResponseSchema, W as DEFAULT_CLOUD_PLATFORM_ORIGIN, Wt as PublicModelsResponseSchema, Zn as number$1, _r as unknown, ar as custom, br as toJSONSchema, cr as literal, dr as object, er as _function, fr as optional, gr as union, hr as string, ir as boolean$1, lr as looseObject, mr as record, nr as any, or as discriminatedUnion, pr as preprocess, qt as ROUTE_MANIFEST_REL_PATH, rr as array, sr as intersection, tr as _null, ur as number, vr as url, xr as NEVER, yr as datetime } from "./dist-DmqYCJqU.mjs";
|
|
4
|
+
import "./dist-QE1G9hAR.mjs";
|
|
5
5
|
import "./chunk-BZUGFHVS-CPWRFwK8.mjs";
|
|
6
6
|
import "./chunk-DLL7UR66-BUYgzxnR.mjs";
|
|
7
7
|
import "./chunk-TN7HHBQW-CSB_R-XD.mjs";
|
|
@@ -138,7 +138,7 @@ new Set([
|
|
|
138
138
|
p.SEMI_SEMI_AND
|
|
139
139
|
]);
|
|
140
140
|
//#endregion
|
|
141
|
-
//#region ../../packages/manifest/dist/discovery-
|
|
141
|
+
//#region ../../packages/manifest/dist/discovery-C6Un-m9-.mjs
|
|
142
142
|
const SOURCE_EXT = /\.(ts|mts|mjs|js)$/;
|
|
143
143
|
const DECLARATION_FILE$1 = /\.d\.(ts|mts|cts)$/;
|
|
144
144
|
function entryIdFromFile(rootDir, filePath, options) {
|
|
@@ -202,6 +202,33 @@ async function discoverModuleFileEntries(rootDir, options) {
|
|
|
202
202
|
moduleFile
|
|
203
203
|
}));
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Slugs are unique per (project, primitive kind), mirroring the per-table
|
|
207
|
+
* `(project_id, slug)` unique index in the database. An agent, a workflow, and a
|
|
208
|
+
* trigger may all share the same slug because they live in separate tables and
|
|
209
|
+
* are routed by type (`/agents/{slug}` vs `/workflows/{slug}`); two of the same
|
|
210
|
+
* kind may not.
|
|
211
|
+
*
|
|
212
|
+
* Single pass over `entries` (O(n)) — keyed on `kind + key` so cross-kind slug
|
|
213
|
+
* reuse is allowed without a nested scan.
|
|
214
|
+
*/
|
|
215
|
+
function validateUniqueModuleKeys(entries) {
|
|
216
|
+
const byScopedKey = /* @__PURE__ */ new Map();
|
|
217
|
+
for (const entry of entries) {
|
|
218
|
+
const scopedKey = `${entry.kind}\u0000${entry.key}`;
|
|
219
|
+
const existing = byScopedKey.get(scopedKey);
|
|
220
|
+
if (existing) existing.filePaths.push(entry.filePath);
|
|
221
|
+
else byScopedKey.set(scopedKey, {
|
|
222
|
+
kind: entry.kind,
|
|
223
|
+
key: entry.key,
|
|
224
|
+
filePaths: [entry.filePath]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
for (const { kind, key, filePaths } of byScopedKey.values()) {
|
|
228
|
+
if (filePaths.length <= 1) continue;
|
|
229
|
+
throw new Error(`Duplicate ${kind} slug "${key}": ${filePaths.join(", ")}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
205
232
|
const HEADER_BYTES = 2048;
|
|
206
233
|
const DIRECTIVE_RE = /@keystroke\s+ignore(?::([a-z]+))?/;
|
|
207
234
|
/** Parse `@keystroke ignore` directives from a file header snippet. */
|
|
@@ -1109,430 +1136,16 @@ Object.freeze({
|
|
|
1109
1136
|
option is given.`]]
|
|
1110
1137
|
]).keys()].sort();
|
|
1111
1138
|
new TextDecoder("utf-8", { fatal: !0 });
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
day: date.getDate(),
|
|
1120
|
-
month: date.getMonth(),
|
|
1121
|
-
weekday: date.getDay(),
|
|
1122
|
-
year: date.getFullYear()
|
|
1123
|
-
};
|
|
1124
|
-
}
|
|
1125
|
-
function getDaysInMonth(year, month) {
|
|
1126
|
-
return new Date(year, month + 1, 0).getDate();
|
|
1139
|
+
new AsyncLocalStorage();
|
|
1140
|
+
new AsyncLocalStorage();
|
|
1141
|
+
new AsyncLocalStorage();
|
|
1142
|
+
new AsyncLocalStorage();
|
|
1143
|
+
createRequire(import.meta.url);
|
|
1144
|
+
function buildPgSchema$1(registry) {
|
|
1145
|
+
return Object.fromEntries(Object.entries(registry).map(([name, { pg }]) => [name, pg]));
|
|
1127
1146
|
}
|
|
1128
|
-
function
|
|
1129
|
-
|
|
1130
|
-
return 6 - weekday1 + weekday2 + 1;
|
|
1131
|
-
}
|
|
1132
|
-
//#endregion
|
|
1133
|
-
//#region ../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.js
|
|
1134
|
-
var Cron = class {
|
|
1135
|
-
constructor({ seconds, minutes, hours, days, months, weekdays }) {
|
|
1136
|
-
if (!seconds || seconds.size === 0) throw new Error("There must be at least one allowed second.");
|
|
1137
|
-
if (!minutes || minutes.size === 0) throw new Error("There must be at least one allowed minute.");
|
|
1138
|
-
if (!hours || hours.size === 0) throw new Error("There must be at least one allowed hour.");
|
|
1139
|
-
if (!months || months.size === 0) throw new Error("There must be at least one allowed month.");
|
|
1140
|
-
if ((!weekdays || weekdays.size === 0) && (!days || days.size === 0)) throw new Error("There must be at least one allowed day or weekday.");
|
|
1141
|
-
this.seconds = Array.from(seconds).sort((a, b) => a - b);
|
|
1142
|
-
this.minutes = Array.from(minutes).sort((a, b) => a - b);
|
|
1143
|
-
this.hours = Array.from(hours).sort((a, b) => a - b);
|
|
1144
|
-
this.days = Array.from(days).sort((a, b) => a - b);
|
|
1145
|
-
this.months = Array.from(months).sort((a, b) => a - b);
|
|
1146
|
-
this.weekdays = Array.from(weekdays).sort((a, b) => a - b);
|
|
1147
|
-
const validateData = (name, data, constraint) => {
|
|
1148
|
-
if (data.some((x) => typeof x !== "number" || x % 1 !== 0 || x < constraint.min || x > constraint.max)) throw new Error(`${name} must only consist of integers which are within the range of ${constraint.min} and ${constraint.max}`);
|
|
1149
|
-
};
|
|
1150
|
-
validateData("seconds", this.seconds, {
|
|
1151
|
-
min: 0,
|
|
1152
|
-
max: 59
|
|
1153
|
-
});
|
|
1154
|
-
validateData("minutes", this.minutes, {
|
|
1155
|
-
min: 0,
|
|
1156
|
-
max: 59
|
|
1157
|
-
});
|
|
1158
|
-
validateData("hours", this.hours, {
|
|
1159
|
-
min: 0,
|
|
1160
|
-
max: 23
|
|
1161
|
-
});
|
|
1162
|
-
validateData("days", this.days, {
|
|
1163
|
-
min: 1,
|
|
1164
|
-
max: 31
|
|
1165
|
-
});
|
|
1166
|
-
validateData("months", this.months, {
|
|
1167
|
-
min: 0,
|
|
1168
|
-
max: 11
|
|
1169
|
-
});
|
|
1170
|
-
validateData("weekdays", this.weekdays, {
|
|
1171
|
-
min: 0,
|
|
1172
|
-
max: 6
|
|
1173
|
-
});
|
|
1174
|
-
this.reversed = {
|
|
1175
|
-
seconds: this.seconds.map((x) => x).reverse(),
|
|
1176
|
-
minutes: this.minutes.map((x) => x).reverse(),
|
|
1177
|
-
hours: this.hours.map((x) => x).reverse(),
|
|
1178
|
-
days: this.days.map((x) => x).reverse(),
|
|
1179
|
-
months: this.months.map((x) => x).reverse(),
|
|
1180
|
-
weekdays: this.weekdays.map((x) => x).reverse()
|
|
1181
|
-
};
|
|
1182
|
-
}
|
|
1183
|
-
/**
|
|
1184
|
-
* Find the next or previous hour, starting from the given start hour that matches the hour constraint.
|
|
1185
|
-
* startHour itself might also be allowed.
|
|
1186
|
-
*/
|
|
1187
|
-
findAllowedHour(dir, startHour) {
|
|
1188
|
-
return dir === "next" ? this.hours.find((x) => x >= startHour) : this.reversed.hours.find((x) => x <= startHour);
|
|
1189
|
-
}
|
|
1190
|
-
/**
|
|
1191
|
-
* Find the next or previous minute, starting from the given start minute that matches the minute constraint.
|
|
1192
|
-
* startMinute itself might also be allowed.
|
|
1193
|
-
*/
|
|
1194
|
-
findAllowedMinute(dir, startMinute) {
|
|
1195
|
-
return dir === "next" ? this.minutes.find((x) => x >= startMinute) : this.reversed.minutes.find((x) => x <= startMinute);
|
|
1196
|
-
}
|
|
1197
|
-
/**
|
|
1198
|
-
* Find the next or previous second, starting from the given start second that matches the second constraint.
|
|
1199
|
-
* startSecond itself IS NOT allowed.
|
|
1200
|
-
*/
|
|
1201
|
-
findAllowedSecond(dir, startSecond) {
|
|
1202
|
-
return dir === "next" ? this.seconds.find((x) => x > startSecond) : this.reversed.seconds.find((x) => x < startSecond);
|
|
1203
|
-
}
|
|
1204
|
-
/**
|
|
1205
|
-
* Find the next or previous time, starting from the given start time that matches the hour, minute
|
|
1206
|
-
* and second constraints. startTime itself might also be allowed.
|
|
1207
|
-
*/
|
|
1208
|
-
findAllowedTime(dir, startTime) {
|
|
1209
|
-
let hour = this.findAllowedHour(dir, startTime.hour);
|
|
1210
|
-
if (hour !== void 0) if (hour === startTime.hour) {
|
|
1211
|
-
let minute = this.findAllowedMinute(dir, startTime.minute);
|
|
1212
|
-
if (minute !== void 0) if (minute === startTime.minute) {
|
|
1213
|
-
const second = this.findAllowedSecond(dir, startTime.second);
|
|
1214
|
-
if (second !== void 0) return {
|
|
1215
|
-
hour,
|
|
1216
|
-
minute,
|
|
1217
|
-
second
|
|
1218
|
-
};
|
|
1219
|
-
minute = this.findAllowedMinute(dir, dir === "next" ? startTime.minute + 1 : startTime.minute - 1);
|
|
1220
|
-
if (minute !== void 0) return {
|
|
1221
|
-
hour,
|
|
1222
|
-
minute,
|
|
1223
|
-
second: dir === "next" ? this.seconds[0] : this.reversed.seconds[0]
|
|
1224
|
-
};
|
|
1225
|
-
} else return {
|
|
1226
|
-
hour,
|
|
1227
|
-
minute,
|
|
1228
|
-
second: dir === "next" ? this.seconds[0] : this.reversed.seconds[0]
|
|
1229
|
-
};
|
|
1230
|
-
hour = this.findAllowedHour(dir, dir === "next" ? startTime.hour + 1 : startTime.hour - 1);
|
|
1231
|
-
if (hour !== void 0) return {
|
|
1232
|
-
hour,
|
|
1233
|
-
minute: dir === "next" ? this.minutes[0] : this.reversed.minutes[0],
|
|
1234
|
-
second: dir === "next" ? this.seconds[0] : this.reversed.seconds[0]
|
|
1235
|
-
};
|
|
1236
|
-
} else return {
|
|
1237
|
-
hour,
|
|
1238
|
-
minute: dir === "next" ? this.minutes[0] : this.reversed.minutes[0],
|
|
1239
|
-
second: dir === "next" ? this.seconds[0] : this.reversed.seconds[0]
|
|
1240
|
-
};
|
|
1241
|
-
}
|
|
1242
|
-
/**
|
|
1243
|
-
* Find the next or previous day in the given month, starting from the given startDay
|
|
1244
|
-
* that matches either the day or the weekday constraint. startDay itself might also be allowed.
|
|
1245
|
-
*/
|
|
1246
|
-
findAllowedDayInMonth(dir, year, month, startDay) {
|
|
1247
|
-
var _a, _b;
|
|
1248
|
-
if (startDay < 1) throw new Error("startDay must not be smaller than 1.");
|
|
1249
|
-
const daysInMonth = getDaysInMonth(year, month);
|
|
1250
|
-
const daysRestricted = this.days.length !== 31;
|
|
1251
|
-
const weekdaysRestricted = this.weekdays.length !== 7;
|
|
1252
|
-
if (!daysRestricted && !weekdaysRestricted) {
|
|
1253
|
-
if (startDay > daysInMonth) return dir === "next" ? void 0 : daysInMonth;
|
|
1254
|
-
return startDay;
|
|
1255
|
-
}
|
|
1256
|
-
let allowedDayByDays;
|
|
1257
|
-
if (daysRestricted) {
|
|
1258
|
-
allowedDayByDays = dir === "next" ? this.days.find((x) => x >= startDay) : this.reversed.days.find((x) => x <= startDay);
|
|
1259
|
-
if (allowedDayByDays !== void 0 && allowedDayByDays > daysInMonth) allowedDayByDays = void 0;
|
|
1260
|
-
}
|
|
1261
|
-
let allowedDayByWeekdays;
|
|
1262
|
-
if (weekdaysRestricted) {
|
|
1263
|
-
const startWeekday = new Date(year, month, startDay).getDay();
|
|
1264
|
-
const nearestAllowedWeekday = dir === "next" ? (_a = this.weekdays.find((x) => x >= startWeekday)) !== null && _a !== void 0 ? _a : this.weekdays[0] : (_b = this.reversed.weekdays.find((x) => x <= startWeekday)) !== null && _b !== void 0 ? _b : this.reversed.weekdays[0];
|
|
1265
|
-
if (nearestAllowedWeekday !== void 0) {
|
|
1266
|
-
const daysBetweenWeekdays = dir === "next" ? getDaysBetweenWeekdays(startWeekday, nearestAllowedWeekday) : getDaysBetweenWeekdays(nearestAllowedWeekday, startWeekday);
|
|
1267
|
-
allowedDayByWeekdays = dir === "next" ? startDay + daysBetweenWeekdays : startDay - daysBetweenWeekdays;
|
|
1268
|
-
if (allowedDayByWeekdays > daysInMonth || allowedDayByWeekdays < 1) allowedDayByWeekdays = void 0;
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
if (allowedDayByDays !== void 0 && allowedDayByWeekdays !== void 0) return dir === "next" ? Math.min(allowedDayByDays, allowedDayByWeekdays) : Math.max(allowedDayByDays, allowedDayByWeekdays);
|
|
1272
|
-
if (allowedDayByDays !== void 0) return allowedDayByDays;
|
|
1273
|
-
if (allowedDayByWeekdays !== void 0) return allowedDayByWeekdays;
|
|
1274
|
-
}
|
|
1275
|
-
/** Gets the next date starting from the given start date or now. */
|
|
1276
|
-
getNextDate(startDate = /* @__PURE__ */ new Date()) {
|
|
1277
|
-
const startDateElements = extractDateElements(startDate);
|
|
1278
|
-
let minYear = startDateElements.year;
|
|
1279
|
-
let startIndexMonth = this.months.findIndex((x) => x >= startDateElements.month);
|
|
1280
|
-
if (startIndexMonth === -1) {
|
|
1281
|
-
startIndexMonth = 0;
|
|
1282
|
-
minYear++;
|
|
1283
|
-
}
|
|
1284
|
-
const maxIterations = this.months.length * 5;
|
|
1285
|
-
for (let i = 0; i < maxIterations; i++) {
|
|
1286
|
-
const year = minYear + Math.floor((startIndexMonth + i) / this.months.length);
|
|
1287
|
-
const month = this.months[(startIndexMonth + i) % this.months.length];
|
|
1288
|
-
const isStartMonth = year === startDateElements.year && month === startDateElements.month;
|
|
1289
|
-
let day = this.findAllowedDayInMonth("next", year, month, isStartMonth ? startDateElements.day : 1);
|
|
1290
|
-
let isStartDay = isStartMonth && day === startDateElements.day;
|
|
1291
|
-
if (day !== void 0 && isStartDay) {
|
|
1292
|
-
const nextTime = this.findAllowedTime("next", startDateElements);
|
|
1293
|
-
if (nextTime !== void 0) return new Date(year, month, day, nextTime.hour, nextTime.minute, nextTime.second);
|
|
1294
|
-
day = this.findAllowedDayInMonth("next", year, month, day + 1);
|
|
1295
|
-
isStartDay = false;
|
|
1296
|
-
}
|
|
1297
|
-
if (day !== void 0 && !isStartDay) return new Date(year, month, day, this.hours[0], this.minutes[0], this.seconds[0]);
|
|
1298
|
-
}
|
|
1299
|
-
throw new Error("No valid next date was found.");
|
|
1300
|
-
}
|
|
1301
|
-
/** Gets the specified amount of future dates starting from the given start date or now. */
|
|
1302
|
-
getNextDates(amount, startDate) {
|
|
1303
|
-
const dates = [];
|
|
1304
|
-
let nextDate;
|
|
1305
|
-
for (let i = 0; i < amount; i++) {
|
|
1306
|
-
nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);
|
|
1307
|
-
dates.push(nextDate);
|
|
1308
|
-
}
|
|
1309
|
-
return dates;
|
|
1310
|
-
}
|
|
1311
|
-
/**
|
|
1312
|
-
* Get an ES6 compatible iterator which iterates over the next dates starting from startDate or now.
|
|
1313
|
-
* The iterator runs until the optional endDate is reached or forever.
|
|
1314
|
-
*/
|
|
1315
|
-
*getNextDatesIterator(startDate, endDate) {
|
|
1316
|
-
let nextDate;
|
|
1317
|
-
while (true) {
|
|
1318
|
-
nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);
|
|
1319
|
-
if (endDate && endDate.getTime() < nextDate.getTime()) return;
|
|
1320
|
-
yield nextDate;
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
/** Gets the previous date starting from the given start date or now. */
|
|
1324
|
-
getPrevDate(startDate = /* @__PURE__ */ new Date()) {
|
|
1325
|
-
const startDateElements = extractDateElements(startDate);
|
|
1326
|
-
let maxYear = startDateElements.year;
|
|
1327
|
-
let startIndexMonth = this.reversed.months.findIndex((x) => x <= startDateElements.month);
|
|
1328
|
-
if (startIndexMonth === -1) {
|
|
1329
|
-
startIndexMonth = 0;
|
|
1330
|
-
maxYear--;
|
|
1331
|
-
}
|
|
1332
|
-
const maxIterations = this.reversed.months.length * 5;
|
|
1333
|
-
for (let i = 0; i < maxIterations; i++) {
|
|
1334
|
-
const year = maxYear - Math.floor((startIndexMonth + i) / this.reversed.months.length);
|
|
1335
|
-
const month = this.reversed.months[(startIndexMonth + i) % this.reversed.months.length];
|
|
1336
|
-
const isStartMonth = year === startDateElements.year && month === startDateElements.month;
|
|
1337
|
-
let day = this.findAllowedDayInMonth("prev", year, month, isStartMonth ? startDateElements.day : getDaysInMonth(year, month));
|
|
1338
|
-
let isStartDay = isStartMonth && day === startDateElements.day;
|
|
1339
|
-
if (day !== void 0 && isStartDay) {
|
|
1340
|
-
const prevTime = this.findAllowedTime("prev", startDateElements);
|
|
1341
|
-
if (prevTime !== void 0) return new Date(year, month, day, prevTime.hour, prevTime.minute, prevTime.second);
|
|
1342
|
-
if (day > 1) {
|
|
1343
|
-
day = this.findAllowedDayInMonth("prev", year, month, day - 1);
|
|
1344
|
-
isStartDay = false;
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
if (day !== void 0 && !isStartDay) return new Date(year, month, day, this.reversed.hours[0], this.reversed.minutes[0], this.reversed.seconds[0]);
|
|
1348
|
-
}
|
|
1349
|
-
throw new Error("No valid previous date was found.");
|
|
1350
|
-
}
|
|
1351
|
-
/** Gets the specified amount of previous dates starting from the given start date or now. */
|
|
1352
|
-
getPrevDates(amount, startDate) {
|
|
1353
|
-
const dates = [];
|
|
1354
|
-
let prevDate;
|
|
1355
|
-
for (let i = 0; i < amount; i++) {
|
|
1356
|
-
prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);
|
|
1357
|
-
dates.push(prevDate);
|
|
1358
|
-
}
|
|
1359
|
-
return dates;
|
|
1360
|
-
}
|
|
1361
|
-
/**
|
|
1362
|
-
* Get an ES6 compatible iterator which iterates over the previous dates starting from startDate or now.
|
|
1363
|
-
* The iterator runs until the optional endDate is reached or forever.
|
|
1364
|
-
*/
|
|
1365
|
-
*getPrevDatesIterator(startDate, endDate) {
|
|
1366
|
-
let prevDate;
|
|
1367
|
-
while (true) {
|
|
1368
|
-
prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);
|
|
1369
|
-
if (endDate && endDate.getTime() > prevDate.getTime()) return;
|
|
1370
|
-
yield prevDate;
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
/** Returns true when there is a cron date at the given date. */
|
|
1374
|
-
matchDate(date) {
|
|
1375
|
-
const { second, minute, hour, day, month, weekday } = extractDateElements(date);
|
|
1376
|
-
if (this.seconds.indexOf(second) === -1 || this.minutes.indexOf(minute) === -1 || this.hours.indexOf(hour) === -1 || this.months.indexOf(month) === -1) return false;
|
|
1377
|
-
if (this.days.length !== 31 && this.weekdays.length !== 7) return this.days.indexOf(day) !== -1 || this.weekdays.indexOf(weekday) !== -1;
|
|
1378
|
-
return this.days.indexOf(day) !== -1 && this.weekdays.indexOf(weekday) !== -1;
|
|
1379
|
-
}
|
|
1380
|
-
};
|
|
1381
|
-
//#endregion
|
|
1382
|
-
//#region ../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron-parser.js
|
|
1383
|
-
const secondConstraint = {
|
|
1384
|
-
min: 0,
|
|
1385
|
-
max: 59
|
|
1386
|
-
};
|
|
1387
|
-
const minuteConstraint = {
|
|
1388
|
-
min: 0,
|
|
1389
|
-
max: 59
|
|
1390
|
-
};
|
|
1391
|
-
const hourConstraint = {
|
|
1392
|
-
min: 0,
|
|
1393
|
-
max: 23
|
|
1394
|
-
};
|
|
1395
|
-
const dayConstraint = {
|
|
1396
|
-
min: 1,
|
|
1397
|
-
max: 31
|
|
1398
|
-
};
|
|
1399
|
-
const monthConstraint = {
|
|
1400
|
-
min: 1,
|
|
1401
|
-
max: 12,
|
|
1402
|
-
aliases: {
|
|
1403
|
-
jan: "1",
|
|
1404
|
-
feb: "2",
|
|
1405
|
-
mar: "3",
|
|
1406
|
-
apr: "4",
|
|
1407
|
-
may: "5",
|
|
1408
|
-
jun: "6",
|
|
1409
|
-
jul: "7",
|
|
1410
|
-
aug: "8",
|
|
1411
|
-
sep: "9",
|
|
1412
|
-
oct: "10",
|
|
1413
|
-
nov: "11",
|
|
1414
|
-
dec: "12"
|
|
1415
|
-
}
|
|
1416
|
-
};
|
|
1417
|
-
const weekdayConstraint = {
|
|
1418
|
-
min: 0,
|
|
1419
|
-
max: 7,
|
|
1420
|
-
aliases: {
|
|
1421
|
-
mon: "1",
|
|
1422
|
-
tue: "2",
|
|
1423
|
-
wed: "3",
|
|
1424
|
-
thu: "4",
|
|
1425
|
-
fri: "5",
|
|
1426
|
-
sat: "6",
|
|
1427
|
-
sun: "7"
|
|
1428
|
-
}
|
|
1429
|
-
};
|
|
1430
|
-
const timeNicknames = {
|
|
1431
|
-
"@yearly": "0 0 1 1 *",
|
|
1432
|
-
"@annually": "0 0 1 1 *",
|
|
1433
|
-
"@monthly": "0 0 1 * *",
|
|
1434
|
-
"@weekly": "0 0 * * 0",
|
|
1435
|
-
"@daily": "0 0 * * *",
|
|
1436
|
-
"@hourly": "0 * * * *",
|
|
1437
|
-
"@minutely": "* * * * *"
|
|
1438
|
-
};
|
|
1439
|
-
function parseElement(element, constraint) {
|
|
1440
|
-
const result = /* @__PURE__ */ new Set();
|
|
1441
|
-
if (element === "*") {
|
|
1442
|
-
for (let i = constraint.min; i <= constraint.max; i = i + 1) result.add(i);
|
|
1443
|
-
return result;
|
|
1444
|
-
}
|
|
1445
|
-
const listElements = element.split(",");
|
|
1446
|
-
if (listElements.length > 1) {
|
|
1447
|
-
for (const listElement of listElements) {
|
|
1448
|
-
const parsedListElement = parseElement(listElement, constraint);
|
|
1449
|
-
for (const x of parsedListElement) result.add(x);
|
|
1450
|
-
}
|
|
1451
|
-
return result;
|
|
1452
|
-
}
|
|
1453
|
-
const parseSingleElement = (singleElement) => {
|
|
1454
|
-
var _a, _b;
|
|
1455
|
-
singleElement = (_b = (_a = constraint.aliases) === null || _a === void 0 ? void 0 : _a[singleElement.toLowerCase()]) !== null && _b !== void 0 ? _b : singleElement;
|
|
1456
|
-
const parsedElement = Number.parseInt(singleElement, 10);
|
|
1457
|
-
if (Number.isNaN(parsedElement)) throw new Error(`Failed to parse ${element}: ${singleElement} is NaN.`);
|
|
1458
|
-
if (parsedElement < constraint.min || parsedElement > constraint.max) throw new Error(`Failed to parse ${element}: ${singleElement} is outside of constraint range of ${constraint.min} - ${constraint.max}.`);
|
|
1459
|
-
return parsedElement;
|
|
1460
|
-
};
|
|
1461
|
-
const rangeSegments = /^(([0-9a-zA-Z]+)-([0-9a-zA-Z]+)|\*)(\/([0-9]+))?$/.exec(element);
|
|
1462
|
-
if (rangeSegments === null) {
|
|
1463
|
-
result.add(parseSingleElement(element));
|
|
1464
|
-
return result;
|
|
1465
|
-
}
|
|
1466
|
-
let parsedStart = rangeSegments[1] === "*" ? constraint.min : parseSingleElement(rangeSegments[2]);
|
|
1467
|
-
const parsedEnd = rangeSegments[1] === "*" ? constraint.max : parseSingleElement(rangeSegments[3]);
|
|
1468
|
-
if (constraint === weekdayConstraint && parsedStart === 7 && parsedEnd !== 7) parsedStart = 0;
|
|
1469
|
-
if (parsedStart > parsedEnd) throw new Error(`Failed to parse ${element}: Invalid range (start: ${parsedStart}, end: ${parsedEnd}).`);
|
|
1470
|
-
const step = rangeSegments[5];
|
|
1471
|
-
let parsedStep = 1;
|
|
1472
|
-
if (step !== void 0) {
|
|
1473
|
-
parsedStep = Number.parseInt(step, 10);
|
|
1474
|
-
if (Number.isNaN(parsedStep)) throw new Error(`Failed to parse step: ${step} is NaN.`);
|
|
1475
|
-
if (parsedStep < 1) throw new Error(`Failed to parse step: Expected ${step} to be greater than 0.`);
|
|
1476
|
-
}
|
|
1477
|
-
for (let i = parsedStart; i <= parsedEnd; i = i + parsedStep) result.add(i);
|
|
1478
|
-
return result;
|
|
1479
|
-
}
|
|
1480
|
-
/** Parses a cron expression into a Cron instance. */
|
|
1481
|
-
function parseCronExpression(cronExpression) {
|
|
1482
|
-
var _a;
|
|
1483
|
-
if (typeof cronExpression !== "string") throw new TypeError("Invalid cron expression: must be of type string.");
|
|
1484
|
-
cronExpression = (_a = timeNicknames[cronExpression.toLowerCase()]) !== null && _a !== void 0 ? _a : cronExpression;
|
|
1485
|
-
const elements = cronExpression.split(" ").filter((elem) => elem.length > 0);
|
|
1486
|
-
if (elements.length < 5 || elements.length > 6) throw new Error("Invalid cron expression: expected 5 or 6 elements.");
|
|
1487
|
-
const rawSeconds = elements.length === 6 ? elements[0] : "0";
|
|
1488
|
-
const rawMinutes = elements.length === 6 ? elements[1] : elements[0];
|
|
1489
|
-
const rawHours = elements.length === 6 ? elements[2] : elements[1];
|
|
1490
|
-
const rawDays = elements.length === 6 ? elements[3] : elements[2];
|
|
1491
|
-
const rawMonths = elements.length === 6 ? elements[4] : elements[3];
|
|
1492
|
-
const rawWeekdays = elements.length === 6 ? elements[5] : elements[4];
|
|
1493
|
-
return new Cron({
|
|
1494
|
-
seconds: parseElement(rawSeconds, secondConstraint),
|
|
1495
|
-
minutes: parseElement(rawMinutes, minuteConstraint),
|
|
1496
|
-
hours: parseElement(rawHours, hourConstraint),
|
|
1497
|
-
days: parseElement(rawDays, dayConstraint),
|
|
1498
|
-
months: new Set(Array.from(parseElement(rawMonths, monthConstraint)).map((x) => x - 1)),
|
|
1499
|
-
weekdays: new Set(Array.from(parseElement(rawWeekdays, weekdayConstraint)).map((x) => x % 7))
|
|
1500
|
-
});
|
|
1501
|
-
}
|
|
1502
|
-
//#endregion
|
|
1503
|
-
//#region ../../packages/action/dist/index.mjs
|
|
1504
|
-
const zodSchema$3 = custom((v) => v instanceof ZodType, "must be a Zod schema");
|
|
1505
|
-
object({
|
|
1506
|
-
slug: string().trim().min(1),
|
|
1507
|
-
name: string().optional(),
|
|
1508
|
-
description: string().optional(),
|
|
1509
|
-
input: zodSchema$3,
|
|
1510
|
-
output: zodSchema$3,
|
|
1511
|
-
credentials: array(credentialInputSchema).optional(),
|
|
1512
|
-
run: _function()
|
|
1513
|
-
});
|
|
1514
|
-
new AsyncLocalStorage();
|
|
1515
|
-
new AsyncLocalStorage();
|
|
1516
|
-
new AbortController().signal;
|
|
1517
|
-
const REGISTRY_KEY$2 = Symbol.for("keystroke.workflowRunGetter");
|
|
1518
|
-
function registry$1() {
|
|
1519
|
-
const globalScope = globalThis;
|
|
1520
|
-
if (!globalScope[REGISTRY_KEY$2]) globalScope[REGISTRY_KEY$2] = {};
|
|
1521
|
-
return globalScope[REGISTRY_KEY$2];
|
|
1522
|
-
}
|
|
1523
|
-
function registerWorkflowRunGetter(fn) {
|
|
1524
|
-
registry$1().getter = fn;
|
|
1525
|
-
}
|
|
1526
|
-
new AsyncLocalStorage();
|
|
1527
|
-
new AsyncLocalStorage();
|
|
1528
|
-
new AsyncLocalStorage();
|
|
1529
|
-
new AsyncLocalStorage();
|
|
1530
|
-
createRequire(import.meta.url);
|
|
1531
|
-
function buildPgSchema$1(registry) {
|
|
1532
|
-
return Object.fromEntries(Object.entries(registry).map(([name, { pg }]) => [name, pg]));
|
|
1533
|
-
}
|
|
1534
|
-
function buildSqliteSchema$1(registry) {
|
|
1535
|
-
return Object.fromEntries(Object.entries(registry).map(([name, { sqlite }]) => [name, sqlite]));
|
|
1147
|
+
function buildSqliteSchema$1(registry) {
|
|
1148
|
+
return Object.fromEntries(Object.entries(registry).map(([name, { sqlite }]) => [name, sqlite]));
|
|
1536
1149
|
}
|
|
1537
1150
|
const agents = pgTable("agents", {
|
|
1538
1151
|
id: text("id").primaryKey(),
|
|
@@ -2203,850 +1816,215 @@ const tableRegistry$1 = {
|
|
|
2203
1816
|
buildPgSchema$1(tableRegistry$1);
|
|
2204
1817
|
buildSqliteSchema$1(tableRegistry$1);
|
|
2205
1818
|
//#endregion
|
|
2206
|
-
//#region ../../packages/
|
|
2207
|
-
const
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
preferences: jsonb("preferences"),
|
|
2214
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2215
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
1819
|
+
//#region ../../packages/agent/dist/schemas-DqPtvoUX.mjs
|
|
1820
|
+
const AGENT_MODEL_ID_PATTERN = /^[a-z0-9-]+\/.+/;
|
|
1821
|
+
const AgentModelIdSchema = custom((value) => typeof value === "string" && AGENT_MODEL_ID_PATTERN.test(value), "model must be vendor/model-id");
|
|
1822
|
+
const GatewayModelPricingSchema = object({
|
|
1823
|
+
input: string().optional(),
|
|
1824
|
+
output: string().optional(),
|
|
1825
|
+
input_cache_read: string().optional()
|
|
2216
1826
|
});
|
|
2217
|
-
|
|
2218
|
-
id:
|
|
2219
|
-
name:
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
1827
|
+
object({
|
|
1828
|
+
id: string().min(1),
|
|
1829
|
+
name: string().optional(),
|
|
1830
|
+
type: string().optional(),
|
|
1831
|
+
context_window: number().int().positive().optional(),
|
|
1832
|
+
max_tokens: number().int().positive().optional(),
|
|
1833
|
+
tags: array(string()).optional(),
|
|
1834
|
+
pricing: GatewayModelPricingSchema.optional()
|
|
2226
1835
|
});
|
|
2227
|
-
const
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2241
|
-
}, (table) => [index("account_user_id_idx").on(table.userId)]);
|
|
2242
|
-
const authAccountsSqlite = sqliteTable("accounts", {
|
|
2243
|
-
id: text$1("id").primaryKey(),
|
|
2244
|
-
accountId: text$1("account_id").notNull(),
|
|
2245
|
-
providerId: text$1("provider_id").notNull(),
|
|
2246
|
-
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
2247
|
-
accessToken: text$1("access_token"),
|
|
2248
|
-
refreshToken: text$1("refresh_token"),
|
|
2249
|
-
idToken: text$1("id_token"),
|
|
2250
|
-
accessTokenExpiresAt: integer$1("access_token_expires_at", { mode: "timestamp_ms" }),
|
|
2251
|
-
refreshTokenExpiresAt: integer$1("refresh_token_expires_at", { mode: "timestamp_ms" }),
|
|
2252
|
-
scope: text$1("scope"),
|
|
2253
|
-
password: text$1("password"),
|
|
2254
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2255
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
2256
|
-
}, (table) => [index$1("account_user_id_idx").on(table.userId)]);
|
|
2257
|
-
const authDeviceCodes = pgTable("device_auth_codes", {
|
|
2258
|
-
id: text("id").primaryKey(),
|
|
2259
|
-
deviceCode: text("device_code").notNull(),
|
|
2260
|
-
userCode: text("user_code").notNull(),
|
|
2261
|
-
userId: text("user_id"),
|
|
2262
|
-
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
|
|
2263
|
-
status: text("status").notNull(),
|
|
2264
|
-
lastPolledAt: timestamp("last_polled_at", { withTimezone: true }),
|
|
2265
|
-
pollingInterval: integer("polling_interval"),
|
|
2266
|
-
clientId: text("client_id"),
|
|
2267
|
-
scope: text("scope")
|
|
1836
|
+
const ThinkingLevelSchema = _enum([
|
|
1837
|
+
"provider-default",
|
|
1838
|
+
"none",
|
|
1839
|
+
"minimal",
|
|
1840
|
+
"low",
|
|
1841
|
+
"medium",
|
|
1842
|
+
"high",
|
|
1843
|
+
"xhigh"
|
|
1844
|
+
]);
|
|
1845
|
+
object({
|
|
1846
|
+
systemPrompt: string(),
|
|
1847
|
+
model: AgentModelIdSchema,
|
|
1848
|
+
thinkingLevel: ThinkingLevelSchema.optional()
|
|
2268
1849
|
});
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
1850
|
+
globalThis.crypto?.webcrypto ?? globalThis.crypto ?? import("node:crypto").then((m) => m.webcrypto);
|
|
1851
|
+
//#endregion
|
|
1852
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
1853
|
+
const RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
1854
|
+
/**
|
|
1855
|
+
* Assert 'object' type schema.
|
|
1856
|
+
*
|
|
1857
|
+
* @internal
|
|
1858
|
+
*/
|
|
1859
|
+
const AssertObjectSchema = custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
|
|
1860
|
+
/**
|
|
1861
|
+
* A progress token, used to associate progress notifications with the original request.
|
|
1862
|
+
*/
|
|
1863
|
+
const ProgressTokenSchema = union([string(), number().int()]);
|
|
1864
|
+
/**
|
|
1865
|
+
* An opaque token used to represent a cursor for pagination.
|
|
1866
|
+
*/
|
|
1867
|
+
const CursorSchema = string();
|
|
1868
|
+
looseObject({
|
|
1869
|
+
/**
|
|
1870
|
+
* Requested duration in milliseconds to retain task from creation.
|
|
1871
|
+
*/
|
|
1872
|
+
ttl: number().optional(),
|
|
1873
|
+
/**
|
|
1874
|
+
* Time in milliseconds to wait between task status requests.
|
|
1875
|
+
*/
|
|
1876
|
+
pollInterval: number().optional()
|
|
2280
1877
|
});
|
|
2281
|
-
const
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
1878
|
+
const TaskMetadataSchema = object({ ttl: number().optional() });
|
|
1879
|
+
/**
|
|
1880
|
+
* Metadata for associating messages with a task.
|
|
1881
|
+
* Include this in the `_meta` field under the key `io.modelcontextprotocol/related-task`.
|
|
1882
|
+
*/
|
|
1883
|
+
const RelatedTaskMetadataSchema = object({ taskId: string() });
|
|
1884
|
+
const RequestMetaSchema = looseObject({
|
|
1885
|
+
/**
|
|
1886
|
+
* If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
|
|
1887
|
+
*/
|
|
1888
|
+
progressToken: ProgressTokenSchema.optional(),
|
|
1889
|
+
/**
|
|
1890
|
+
* If specified, this request is related to the provided task.
|
|
1891
|
+
*/
|
|
1892
|
+
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
2287
1893
|
});
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
1894
|
+
/**
|
|
1895
|
+
* Common params for any request.
|
|
1896
|
+
*/
|
|
1897
|
+
const BaseRequestParamsSchema = object({
|
|
1898
|
+
/**
|
|
1899
|
+
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
|
|
1900
|
+
*/
|
|
1901
|
+
_meta: RequestMetaSchema.optional() });
|
|
1902
|
+
/**
|
|
1903
|
+
* Common params for any task-augmented request.
|
|
1904
|
+
*/
|
|
1905
|
+
const TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
1906
|
+
/**
|
|
1907
|
+
* If specified, the caller is requesting task-augmented execution for this request.
|
|
1908
|
+
* The request will return a CreateTaskResult immediately, and the actual result can be
|
|
1909
|
+
* retrieved later via tasks/result.
|
|
1910
|
+
*
|
|
1911
|
+
* Task augmentation is subject to capability negotiation - receivers MUST declare support
|
|
1912
|
+
* for task augmentation of specific request types in their capabilities.
|
|
1913
|
+
*/
|
|
1914
|
+
task: TaskMetadataSchema.optional() });
|
|
1915
|
+
const RequestSchema = object({
|
|
1916
|
+
method: string(),
|
|
1917
|
+
params: BaseRequestParamsSchema.loose().optional()
|
|
2294
1918
|
});
|
|
2295
|
-
const
|
|
2296
|
-
id: text("id").primaryKey(),
|
|
2297
|
-
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
|
|
2298
|
-
token: text("token").notNull().unique(),
|
|
2299
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2300
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
2301
|
-
ipAddress: text("ip_address"),
|
|
2302
|
-
userAgent: text("user_agent"),
|
|
2303
|
-
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" })
|
|
2304
|
-
}, (table) => [index("session_user_id_idx").on(table.userId)]);
|
|
2305
|
-
const authSessionsSqlite = sqliteTable("sessions", {
|
|
2306
|
-
id: text$1("id").primaryKey(),
|
|
2307
|
-
expiresAt: integer$1("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
2308
|
-
token: text$1("token").notNull().unique(),
|
|
2309
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2310
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
2311
|
-
ipAddress: text$1("ip_address"),
|
|
2312
|
-
userAgent: text$1("user_agent"),
|
|
2313
|
-
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" })
|
|
2314
|
-
}, (table) => [index$1("session_user_id_idx").on(table.userId)]);
|
|
2315
|
-
const authVerifications = pgTable("verification", {
|
|
2316
|
-
id: text("id").primaryKey(),
|
|
2317
|
-
identifier: text("identifier").notNull(),
|
|
2318
|
-
value: text("value").notNull(),
|
|
2319
|
-
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
|
|
2320
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2321
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2322
|
-
}, (table) => [index("verification_identifier_idx").on(table.identifier)]);
|
|
2323
|
-
const authVerificationsSqlite = sqliteTable("verification", {
|
|
2324
|
-
id: text$1("id").primaryKey(),
|
|
2325
|
-
identifier: text$1("identifier").notNull(),
|
|
2326
|
-
value: text$1("value").notNull(),
|
|
2327
|
-
expiresAt: integer$1("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
2328
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2329
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
2330
|
-
}, (table) => [index$1("verification_identifier_idx").on(table.identifier)]);
|
|
1919
|
+
const NotificationsParamsSchema = object({
|
|
2331
1920
|
/**
|
|
2332
|
-
*
|
|
2333
|
-
*
|
|
2334
|
-
|
|
1921
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
1922
|
+
* for notes on _meta usage.
|
|
1923
|
+
*/
|
|
1924
|
+
_meta: RequestMetaSchema.optional() });
|
|
1925
|
+
const NotificationSchema = object({
|
|
1926
|
+
method: string(),
|
|
1927
|
+
params: NotificationsParamsSchema.loose().optional()
|
|
1928
|
+
});
|
|
1929
|
+
const ResultSchema = looseObject({
|
|
1930
|
+
/**
|
|
1931
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
1932
|
+
* for notes on _meta usage.
|
|
1933
|
+
*/
|
|
1934
|
+
_meta: RequestMetaSchema.optional() });
|
|
1935
|
+
/**
|
|
1936
|
+
* A uniquely identifying ID for a request in JSON-RPC.
|
|
1937
|
+
*/
|
|
1938
|
+
const RequestIdSchema = union([string(), number().int()]);
|
|
1939
|
+
/**
|
|
1940
|
+
* A request that expects a response.
|
|
1941
|
+
*/
|
|
1942
|
+
const JSONRPCRequestSchema = object({
|
|
1943
|
+
jsonrpc: literal("2.0"),
|
|
1944
|
+
id: RequestIdSchema,
|
|
1945
|
+
...RequestSchema.shape
|
|
1946
|
+
}).strict();
|
|
1947
|
+
/**
|
|
1948
|
+
* A notification which does not expect a response.
|
|
1949
|
+
*/
|
|
1950
|
+
const JSONRPCNotificationSchema = object({
|
|
1951
|
+
jsonrpc: literal("2.0"),
|
|
1952
|
+
...NotificationSchema.shape
|
|
1953
|
+
}).strict();
|
|
1954
|
+
/**
|
|
1955
|
+
* A successful (non-error) response to a request.
|
|
1956
|
+
*/
|
|
1957
|
+
const JSONRPCResultResponseSchema = object({
|
|
1958
|
+
jsonrpc: literal("2.0"),
|
|
1959
|
+
id: RequestIdSchema,
|
|
1960
|
+
result: ResultSchema
|
|
1961
|
+
}).strict();
|
|
1962
|
+
/**
|
|
1963
|
+
* Error codes defined by the JSON-RPC specification.
|
|
1964
|
+
*/
|
|
1965
|
+
var ErrorCode;
|
|
1966
|
+
(function(ErrorCode) {
|
|
1967
|
+
ErrorCode[ErrorCode["ConnectionClosed"] = -32e3] = "ConnectionClosed";
|
|
1968
|
+
ErrorCode[ErrorCode["RequestTimeout"] = -32001] = "RequestTimeout";
|
|
1969
|
+
ErrorCode[ErrorCode["ParseError"] = -32700] = "ParseError";
|
|
1970
|
+
ErrorCode[ErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
|
|
1971
|
+
ErrorCode[ErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
1972
|
+
ErrorCode[ErrorCode["InvalidParams"] = -32602] = "InvalidParams";
|
|
1973
|
+
ErrorCode[ErrorCode["InternalError"] = -32603] = "InternalError";
|
|
1974
|
+
ErrorCode[ErrorCode["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
1975
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
1976
|
+
/**
|
|
1977
|
+
* A response to a request that indicates an error occurred.
|
|
1978
|
+
*/
|
|
1979
|
+
const JSONRPCErrorResponseSchema = object({
|
|
1980
|
+
jsonrpc: literal("2.0"),
|
|
1981
|
+
id: RequestIdSchema.optional(),
|
|
1982
|
+
error: object({
|
|
1983
|
+
/**
|
|
1984
|
+
* The error type that occurred.
|
|
1985
|
+
*/
|
|
1986
|
+
code: number().int(),
|
|
1987
|
+
/**
|
|
1988
|
+
* A short description of the error. The message SHOULD be limited to a concise single sentence.
|
|
1989
|
+
*/
|
|
1990
|
+
message: string(),
|
|
1991
|
+
/**
|
|
1992
|
+
* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
|
|
1993
|
+
*/
|
|
1994
|
+
data: unknown().optional()
|
|
1995
|
+
})
|
|
1996
|
+
}).strict();
|
|
1997
|
+
union([
|
|
1998
|
+
JSONRPCRequestSchema,
|
|
1999
|
+
JSONRPCNotificationSchema,
|
|
2000
|
+
JSONRPCResultResponseSchema,
|
|
2001
|
+
JSONRPCErrorResponseSchema
|
|
2002
|
+
]);
|
|
2003
|
+
union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
|
|
2004
|
+
/**
|
|
2005
|
+
* A response that indicates success but carries no data.
|
|
2006
|
+
*/
|
|
2007
|
+
const EmptyResultSchema = ResultSchema.strict();
|
|
2008
|
+
const CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
2009
|
+
/**
|
|
2010
|
+
* The ID of the request to cancel.
|
|
2011
|
+
*
|
|
2012
|
+
* This MUST correspond to the ID of a request previously issued in the same direction.
|
|
2013
|
+
*/
|
|
2014
|
+
requestId: RequestIdSchema.optional(),
|
|
2015
|
+
/**
|
|
2016
|
+
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
|
|
2017
|
+
*/
|
|
2018
|
+
reason: string().optional()
|
|
2019
|
+
});
|
|
2020
|
+
/**
|
|
2021
|
+
* This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
|
|
2335
2022
|
*
|
|
2336
|
-
*
|
|
2337
|
-
* inverse — keystroke as an OAuth *client* storing our users' connections to
|
|
2338
|
-
* third-party providers. These `mcp_oauth_*` tables are the provider side.
|
|
2023
|
+
* The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
|
|
2339
2024
|
*
|
|
2340
|
-
*
|
|
2341
|
-
* addresses these by its fixed model names (`oauthApplication`,
|
|
2342
|
-
* `oauthAccessToken`, `oauthConsent`) and by field name (the JS property keys
|
|
2343
|
-
* below); the physical table/column names are ours to choose.
|
|
2025
|
+
* This notification indicates that the result will be unused, so any associated processing SHOULD cease.
|
|
2344
2026
|
*
|
|
2345
|
-
*
|
|
2346
|
-
* (the Better Auth mcp plugin looks them up directly and cannot hash them),
|
|
2347
|
-
* consistent with how the `sessions` table stores session tokens. They are
|
|
2348
|
-
* short-lived; rely on DB access controls + at-rest encryption.
|
|
2349
|
-
*/
|
|
2350
|
-
const mcpOauthClient = pgTable("mcp_oauth_client", {
|
|
2351
|
-
id: text("id").primaryKey(),
|
|
2352
|
-
name: text("name").notNull(),
|
|
2353
|
-
icon: text("icon"),
|
|
2354
|
-
metadata: text("metadata"),
|
|
2355
|
-
clientId: text("client_id").notNull().unique(),
|
|
2356
|
-
clientSecret: text("client_secret"),
|
|
2357
|
-
redirectUrls: text("redirect_urls").notNull(),
|
|
2358
|
-
type: text("type").notNull(),
|
|
2359
|
-
disabled: boolean("disabled").notNull().default(false),
|
|
2360
|
-
userId: text("user_id").references(() => users.id, { onDelete: "cascade" }),
|
|
2361
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2362
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2363
|
-
}, (table) => [index("mcp_oauth_client_user_id_idx").on(table.userId)]);
|
|
2364
|
-
const mcpOauthClientSqlite = sqliteTable("mcp_oauth_client", {
|
|
2365
|
-
id: text$1("id").primaryKey(),
|
|
2366
|
-
name: text$1("name").notNull(),
|
|
2367
|
-
icon: text$1("icon"),
|
|
2368
|
-
metadata: text$1("metadata"),
|
|
2369
|
-
clientId: text$1("client_id").notNull().unique(),
|
|
2370
|
-
clientSecret: text$1("client_secret"),
|
|
2371
|
-
redirectUrls: text$1("redirect_urls").notNull(),
|
|
2372
|
-
type: text$1("type").notNull(),
|
|
2373
|
-
disabled: integer$1("disabled", { mode: "boolean" }).notNull().default(false),
|
|
2374
|
-
userId: text$1("user_id").references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
2375
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2376
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
2377
|
-
}, (table) => [index$1("mcp_oauth_client_user_id_idx").on(table.userId)]);
|
|
2378
|
-
const mcpOauthAccessToken = pgTable("mcp_oauth_access_token", {
|
|
2379
|
-
id: text("id").primaryKey(),
|
|
2380
|
-
accessToken: text("access_token").notNull().unique(),
|
|
2381
|
-
refreshToken: text("refresh_token").unique(),
|
|
2382
|
-
accessTokenExpiresAt: timestamp("access_token_expires_at", { withTimezone: true }),
|
|
2383
|
-
refreshTokenExpiresAt: timestamp("refresh_token_expires_at", { withTimezone: true }),
|
|
2384
|
-
clientId: text("client_id").notNull(),
|
|
2385
|
-
userId: text("user_id").references(() => users.id, { onDelete: "cascade" }),
|
|
2386
|
-
scopes: text("scopes"),
|
|
2387
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2388
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2389
|
-
}, (table) => [index("mcp_oauth_access_token_client_id_idx").on(table.clientId), index("mcp_oauth_access_token_user_id_idx").on(table.userId)]);
|
|
2390
|
-
const mcpOauthAccessTokenSqlite = sqliteTable("mcp_oauth_access_token", {
|
|
2391
|
-
id: text$1("id").primaryKey(),
|
|
2392
|
-
accessToken: text$1("access_token").notNull().unique(),
|
|
2393
|
-
refreshToken: text$1("refresh_token").unique(),
|
|
2394
|
-
accessTokenExpiresAt: integer$1("access_token_expires_at", { mode: "timestamp_ms" }),
|
|
2395
|
-
refreshTokenExpiresAt: integer$1("refresh_token_expires_at", { mode: "timestamp_ms" }),
|
|
2396
|
-
clientId: text$1("client_id").notNull(),
|
|
2397
|
-
userId: text$1("user_id").references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
2398
|
-
scopes: text$1("scopes"),
|
|
2399
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2400
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
2401
|
-
}, (table) => [index$1("mcp_oauth_access_token_client_id_idx").on(table.clientId), index$1("mcp_oauth_access_token_user_id_idx").on(table.userId)]);
|
|
2402
|
-
const mcpOauthConsent = pgTable("mcp_oauth_consent", {
|
|
2403
|
-
id: text("id").primaryKey(),
|
|
2404
|
-
clientId: text("client_id").notNull(),
|
|
2405
|
-
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
2406
|
-
scopes: text("scopes"),
|
|
2407
|
-
consentGiven: boolean("consent_given").notNull().default(false),
|
|
2408
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2409
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2410
|
-
}, (table) => [index("mcp_oauth_consent_client_id_idx").on(table.clientId), index("mcp_oauth_consent_user_id_idx").on(table.userId)]);
|
|
2411
|
-
const mcpOauthConsentSqlite = sqliteTable("mcp_oauth_consent", {
|
|
2412
|
-
id: text$1("id").primaryKey(),
|
|
2413
|
-
clientId: text$1("client_id").notNull(),
|
|
2414
|
-
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
2415
|
-
scopes: text$1("scopes"),
|
|
2416
|
-
consentGiven: integer$1("consent_given", { mode: "boolean" }).notNull().default(false),
|
|
2417
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2418
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
2419
|
-
}, (table) => [index$1("mcp_oauth_consent_client_id_idx").on(table.clientId), index$1("mcp_oauth_consent_user_id_idx").on(table.userId)]);
|
|
2420
|
-
createRequire(import.meta.url);
|
|
2421
|
-
function buildPgSchema(registry) {
|
|
2422
|
-
return Object.fromEntries(Object.entries(registry).map(([name, { pg }]) => [name, pg]));
|
|
2423
|
-
}
|
|
2424
|
-
function buildSqliteSchema(registry) {
|
|
2425
|
-
return Object.fromEntries(Object.entries(registry).map(([name, { sqlite }]) => [name, sqlite]));
|
|
2426
|
-
}
|
|
2427
|
-
/** Better Auth API Key shape (`apikey` model → physical `api_keys`). */
|
|
2428
|
-
const authApiKeys = pgTable("api_keys", {
|
|
2429
|
-
id: text("id").primaryKey(),
|
|
2430
|
-
configId: text("config_id").notNull().default("default"),
|
|
2431
|
-
name: text("name"),
|
|
2432
|
-
start: text("start"),
|
|
2433
|
-
prefix: text("prefix"),
|
|
2434
|
-
/** Hashed secret for verification (Better Auth `key`). */
|
|
2435
|
-
key: text("key").notNull(),
|
|
2436
|
-
/** Encrypted plaintext secret — keystroke extension for re-display. */
|
|
2437
|
-
keyCiphertext: text("key_ciphertext"),
|
|
2438
|
-
referenceId: text("reference_id").notNull(),
|
|
2439
|
-
refillInterval: integer("refill_interval"),
|
|
2440
|
-
refillAmount: integer("refill_amount"),
|
|
2441
|
-
lastRefillAt: timestamp("last_refill_at", { withTimezone: true }),
|
|
2442
|
-
enabled: boolean("enabled").default(true),
|
|
2443
|
-
rateLimitEnabled: boolean("rate_limit_enabled").default(true),
|
|
2444
|
-
rateLimitTimeWindow: integer("rate_limit_time_window"),
|
|
2445
|
-
rateLimitMax: integer("rate_limit_max"),
|
|
2446
|
-
requestCount: integer("request_count").default(0),
|
|
2447
|
-
remaining: integer("remaining"),
|
|
2448
|
-
lastRequest: timestamp("last_request", { withTimezone: true }),
|
|
2449
|
-
expiresAt: timestamp("expires_at", { withTimezone: true }),
|
|
2450
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2451
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
2452
|
-
permissions: text("permissions"),
|
|
2453
|
-
metadata: text("metadata")
|
|
2454
|
-
}, (table) => [
|
|
2455
|
-
index("api_keys_reference_id_idx").on(table.referenceId),
|
|
2456
|
-
index("api_keys_config_id_idx").on(table.configId),
|
|
2457
|
-
index("api_keys_key_idx").on(table.key)
|
|
2458
|
-
]);
|
|
2459
|
-
const authApiKeysSqlite = sqliteTable("api_keys", {
|
|
2460
|
-
id: text$1("id").primaryKey(),
|
|
2461
|
-
configId: text$1("config_id").notNull().default("default"),
|
|
2462
|
-
name: text$1("name"),
|
|
2463
|
-
start: text$1("start"),
|
|
2464
|
-
prefix: text$1("prefix"),
|
|
2465
|
-
key: text$1("key").notNull(),
|
|
2466
|
-
keyCiphertext: text$1("key_ciphertext"),
|
|
2467
|
-
referenceId: text$1("reference_id").notNull(),
|
|
2468
|
-
refillInterval: integer$1("refill_interval"),
|
|
2469
|
-
refillAmount: integer$1("refill_amount"),
|
|
2470
|
-
lastRefillAt: integer$1("last_refill_at", { mode: "timestamp_ms" }),
|
|
2471
|
-
enabled: integer$1("enabled", { mode: "boolean" }).default(true),
|
|
2472
|
-
rateLimitEnabled: integer$1("rate_limit_enabled", { mode: "boolean" }).default(true),
|
|
2473
|
-
rateLimitTimeWindow: integer$1("rate_limit_time_window"),
|
|
2474
|
-
rateLimitMax: integer$1("rate_limit_max"),
|
|
2475
|
-
requestCount: integer$1("request_count").default(0),
|
|
2476
|
-
remaining: integer$1("remaining"),
|
|
2477
|
-
lastRequest: integer$1("last_request", { mode: "timestamp_ms" }),
|
|
2478
|
-
expiresAt: integer$1("expires_at", { mode: "timestamp_ms" }),
|
|
2479
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2480
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
2481
|
-
permissions: text$1("permissions"),
|
|
2482
|
-
metadata: text$1("metadata")
|
|
2483
|
-
}, (table) => [
|
|
2484
|
-
index$1("api_keys_reference_id_idx").on(table.referenceId),
|
|
2485
|
-
index$1("api_keys_config_id_idx").on(table.configId),
|
|
2486
|
-
index$1("api_keys_key_idx").on(table.key)
|
|
2487
|
-
]);
|
|
2488
|
-
const organizations = pgTable("organizations", {
|
|
2489
|
-
id: text("id").primaryKey(),
|
|
2490
|
-
name: text("name").notNull(),
|
|
2491
|
-
slug: text("slug").notNull(),
|
|
2492
|
-
dbSchema: text("db_schema").notNull(),
|
|
2493
|
-
dbUser: text("db_user").notNull(),
|
|
2494
|
-
dbPasswordCiphertext: text("db_password_ciphertext").notNull(),
|
|
2495
|
-
hostingAppName: text("hosting_app_name"),
|
|
2496
|
-
runtimeId: text("runtime_id"),
|
|
2497
|
-
baseUrl: text("base_url"),
|
|
2498
|
-
storageBucket: text("storage_bucket"),
|
|
2499
|
-
storageEndpoint: text("storage_endpoint"),
|
|
2500
|
-
storageAccessKeyIdCiphertext: text("storage_access_key_id_ciphertext"),
|
|
2501
|
-
storageSecretAccessKeyCiphertext: text("storage_secret_access_key_ciphertext"),
|
|
2502
|
-
storageRegion: text("storage_region"),
|
|
2503
|
-
storageForcePathStyle: boolean("storage_force_path_style"),
|
|
2504
|
-
customLogoEnabled: boolean("custom_logo_enabled").notNull().default(false),
|
|
2505
|
-
customLogoExplicitlyDisabled: boolean("custom_logo_explicitly_disabled").notNull().default(false),
|
|
2506
|
-
logoLightUrl: text("logo_light_url"),
|
|
2507
|
-
logoDarkUrl: text("logo_dark_url"),
|
|
2508
|
-
logoHeightPx: integer("logo_height_px").notNull().default(20),
|
|
2509
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2510
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
2511
|
-
verifiedAt: timestamp("verified_at", { withTimezone: true }),
|
|
2512
|
-
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
2513
|
-
}, (table) => [uniqueIndex("organizations_slug_unique").on(table.slug)]);
|
|
2514
|
-
const organizationsSqlite = sqliteTable("organizations", {
|
|
2515
|
-
id: text$1("id").primaryKey(),
|
|
2516
|
-
name: text$1("name").notNull(),
|
|
2517
|
-
slug: text$1("slug").notNull(),
|
|
2518
|
-
dbSchema: text$1("db_schema").notNull(),
|
|
2519
|
-
dbUser: text$1("db_user").notNull(),
|
|
2520
|
-
dbPasswordCiphertext: text$1("db_password_ciphertext").notNull(),
|
|
2521
|
-
hostingAppName: text$1("hosting_app_name"),
|
|
2522
|
-
runtimeId: text$1("runtime_id"),
|
|
2523
|
-
baseUrl: text$1("base_url"),
|
|
2524
|
-
storageBucket: text$1("storage_bucket"),
|
|
2525
|
-
storageEndpoint: text$1("storage_endpoint"),
|
|
2526
|
-
storageAccessKeyIdCiphertext: text$1("storage_access_key_id_ciphertext"),
|
|
2527
|
-
storageSecretAccessKeyCiphertext: text$1("storage_secret_access_key_ciphertext"),
|
|
2528
|
-
storageRegion: text$1("storage_region"),
|
|
2529
|
-
storageForcePathStyle: integer$1("storage_force_path_style", { mode: "boolean" }),
|
|
2530
|
-
customLogoEnabled: integer$1("custom_logo_enabled", { mode: "boolean" }).notNull().default(false),
|
|
2531
|
-
customLogoExplicitlyDisabled: integer$1("custom_logo_explicitly_disabled", { mode: "boolean" }).notNull().default(false),
|
|
2532
|
-
logoLightUrl: text$1("logo_light_url"),
|
|
2533
|
-
logoDarkUrl: text$1("logo_dark_url"),
|
|
2534
|
-
logoHeightPx: integer$1("logo_height_px").notNull().default(20),
|
|
2535
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2536
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
2537
|
-
verifiedAt: integer$1("verified_at", { mode: "timestamp_ms" }),
|
|
2538
|
-
deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
|
|
2539
|
-
}, (table) => [uniqueIndex$1("organizations_slug_unique").on(table.slug)]);
|
|
2540
|
-
const apps = pgTable("apps", {
|
|
2541
|
-
id: text("id").primaryKey(),
|
|
2542
|
-
organizationId: text("organization_id").references(() => organizations.id, { onDelete: "cascade" }),
|
|
2543
|
-
slug: text("slug").notNull(),
|
|
2544
|
-
name: text("name").notNull(),
|
|
2545
|
-
description: text("description").notNull(),
|
|
2546
|
-
category: text("category").notNull(),
|
|
2547
|
-
logo: text("logo"),
|
|
2548
|
-
authKind: text("auth_kind").$type().notNull(),
|
|
2549
|
-
oauthScopes: jsonb("oauth_scopes").$type().notNull(),
|
|
2550
|
-
credentialFields: jsonb("credential_fields").$type().notNull().default({}),
|
|
2551
|
-
credentialScheme: text("credential_scheme").$type(),
|
|
2552
|
-
url: text("url"),
|
|
2553
|
-
source: text("source").$type().notNull(),
|
|
2554
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2555
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2556
|
-
}, (table) => [uniqueIndex("apps_slug_idx").on(table.slug), index("apps_organization_id_idx").on(table.organizationId)]);
|
|
2557
|
-
const appsSqlite = sqliteTable("apps", {
|
|
2558
|
-
id: text$1("id").primaryKey(),
|
|
2559
|
-
organizationId: text$1("organization_id").references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
2560
|
-
slug: text$1("slug").notNull(),
|
|
2561
|
-
name: text$1("name").notNull(),
|
|
2562
|
-
description: text$1("description").notNull(),
|
|
2563
|
-
category: text$1("category").notNull(),
|
|
2564
|
-
logo: text$1("logo"),
|
|
2565
|
-
authKind: text$1("auth_kind").$type().notNull(),
|
|
2566
|
-
oauthScopes: text$1("oauth_scopes", { mode: "json" }).$type().notNull(),
|
|
2567
|
-
credentialFields: text$1("credential_fields", { mode: "json" }).$type().notNull().default({}),
|
|
2568
|
-
credentialScheme: text$1("credential_scheme").$type(),
|
|
2569
|
-
url: text$1("url"),
|
|
2570
|
-
source: text$1("source").$type().notNull(),
|
|
2571
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2572
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
2573
|
-
}, (table) => [uniqueIndex$1("apps_slug_idx").on(table.slug), index$1("apps_organization_id_idx").on(table.organizationId)]);
|
|
2574
|
-
const oauthApps = pgTable("oauth_apps", {
|
|
2575
|
-
id: text("id").primaryKey(),
|
|
2576
|
-
organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
|
2577
|
-
provider: text("provider").notNull(),
|
|
2578
|
-
slug: text("slug").notNull(),
|
|
2579
|
-
tokenStrategy: text("token_strategy").$type().notNull(),
|
|
2580
|
-
clientIdCiphertext: text("client_id_ciphertext").notNull(),
|
|
2581
|
-
clientSecretCiphertext: text("client_secret_ciphertext").notNull(),
|
|
2582
|
-
signingSecretCiphertext: text("signing_secret_ciphertext"),
|
|
2583
|
-
redirectUri: text("redirect_uri"),
|
|
2584
|
-
metadata: jsonb("metadata").$type(),
|
|
2585
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2586
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2587
|
-
}, (table) => [uniqueIndex("oauth_apps_organization_id_slug_idx").on(table.organizationId, table.slug), index("oauth_apps_slug_idx").on(table.slug)]);
|
|
2588
|
-
const oauthAppsSqlite = sqliteTable("oauth_apps", {
|
|
2589
|
-
id: text$1("id").primaryKey(),
|
|
2590
|
-
organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
2591
|
-
provider: text$1("provider").notNull(),
|
|
2592
|
-
slug: text$1("slug").notNull(),
|
|
2593
|
-
tokenStrategy: text$1("token_strategy").$type().notNull(),
|
|
2594
|
-
clientIdCiphertext: text$1("client_id_ciphertext").notNull(),
|
|
2595
|
-
clientSecretCiphertext: text$1("client_secret_ciphertext").notNull(),
|
|
2596
|
-
signingSecretCiphertext: text$1("signing_secret_ciphertext"),
|
|
2597
|
-
redirectUri: text$1("redirect_uri"),
|
|
2598
|
-
metadata: text$1("metadata", { mode: "json" }).$type(),
|
|
2599
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2600
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
2601
|
-
}, (table) => [uniqueIndex$1("oauth_apps_organization_id_slug_idx").on(table.organizationId, table.slug), index$1("oauth_apps_slug_idx").on(table.slug)]);
|
|
2602
|
-
const oauthConnections = pgTable("oauth_connections", {
|
|
2603
|
-
id: text("id").primaryKey(),
|
|
2604
|
-
appId: text("app_id").notNull().references(() => oauthApps.id, { onDelete: "cascade" }),
|
|
2605
|
-
externalId: text("external_id").notNull(),
|
|
2606
|
-
accessTokenCiphertext: text("access_token_ciphertext").notNull(),
|
|
2607
|
-
refreshTokenCiphertext: text("refresh_token_ciphertext"),
|
|
2608
|
-
accessTokenExpiresAt: timestamp("access_token_expires_at", { withTimezone: true }),
|
|
2609
|
-
grantedScopes: jsonb("granted_scopes").$type(),
|
|
2610
|
-
metadata: jsonb("metadata").$type(),
|
|
2611
|
-
connectedAt: timestamp("connected_at", { withTimezone: true }).notNull(),
|
|
2612
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2613
|
-
}, (table) => [uniqueIndex("oauth_connections_app_external_unique").on(table.appId, table.externalId), index("oauth_connections_external_id_idx").on(table.externalId)]);
|
|
2614
|
-
const oauthConnectionsSqlite = sqliteTable("oauth_connections", {
|
|
2615
|
-
id: text$1("id").primaryKey(),
|
|
2616
|
-
appId: text$1("app_id").notNull().references(() => oauthAppsSqlite.id, { onDelete: "cascade" }),
|
|
2617
|
-
externalId: text$1("external_id").notNull(),
|
|
2618
|
-
accessTokenCiphertext: text$1("access_token_ciphertext").notNull(),
|
|
2619
|
-
refreshTokenCiphertext: text$1("refresh_token_ciphertext"),
|
|
2620
|
-
accessTokenExpiresAt: integer$1("access_token_expires_at", { mode: "timestamp_ms" }),
|
|
2621
|
-
grantedScopes: text$1("granted_scopes", { mode: "json" }).$type(),
|
|
2622
|
-
metadata: text$1("metadata", { mode: "json" }).$type(),
|
|
2623
|
-
connectedAt: integer$1("connected_at", { mode: "timestamp_ms" }).notNull(),
|
|
2624
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
2625
|
-
}, (table) => [uniqueIndex$1("oauth_connections_app_external_unique").on(table.appId, table.externalId), index$1("oauth_connections_external_id_idx").on(table.externalId)]);
|
|
2626
|
-
const organizationUsers = pgTable("organization_users", {
|
|
2627
|
-
organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
|
2628
|
-
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
2629
|
-
role: text("role").notNull().$type(),
|
|
2630
|
-
status: text("status").notNull().$type().default("active"),
|
|
2631
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2632
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
2633
|
-
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
2634
|
-
}, (table) => [primaryKey({ columns: [table.organizationId, table.userId] }), index("organization_users_user_id_idx").on(table.userId)]);
|
|
2635
|
-
const organizationUsersSqlite = sqliteTable("organization_users", {
|
|
2636
|
-
organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
2637
|
-
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
2638
|
-
role: text$1("role").notNull().$type(),
|
|
2639
|
-
status: text$1("status").notNull().$type().default("active"),
|
|
2640
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2641
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
2642
|
-
deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
|
|
2643
|
-
}, (table) => [primaryKey$1({ columns: [table.organizationId, table.userId] }), index$1("organization_users_user_id_idx").on(table.userId)]);
|
|
2644
|
-
const organizationInvitations = pgTable("organization_invitations", {
|
|
2645
|
-
id: text("id").primaryKey(),
|
|
2646
|
-
organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
|
2647
|
-
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
2648
|
-
email: text("email").notNull(),
|
|
2649
|
-
role: text("role").notNull().$type(),
|
|
2650
|
-
status: text("status").notNull().$type(),
|
|
2651
|
-
invitedByUserId: text("invited_by_user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
2652
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2653
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
2654
|
-
expiresAt: timestamp("expires_at", { withTimezone: true })
|
|
2655
|
-
}, (table) => [
|
|
2656
|
-
index("organization_invitations_user_id_idx").on(table.userId),
|
|
2657
|
-
index("organization_invitations_organization_id_idx").on(table.organizationId),
|
|
2658
|
-
uniqueIndex("organization_invitations_org_user_pending_unique").on(table.organizationId, table.userId).where(sql`${table.status} = 'pending'`)
|
|
2659
|
-
]);
|
|
2660
|
-
const organizationInvitationsSqlite = sqliteTable("organization_invitations", {
|
|
2661
|
-
id: text$1("id").primaryKey(),
|
|
2662
|
-
organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
2663
|
-
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
2664
|
-
email: text$1("email").notNull(),
|
|
2665
|
-
role: text$1("role").notNull().$type(),
|
|
2666
|
-
status: text$1("status").notNull().$type(),
|
|
2667
|
-
invitedByUserId: text$1("invited_by_user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
2668
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2669
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
2670
|
-
expiresAt: integer$1("expires_at", { mode: "timestamp_ms" })
|
|
2671
|
-
}, (table) => [
|
|
2672
|
-
index$1("organization_invitations_user_id_idx").on(table.userId),
|
|
2673
|
-
index$1("organization_invitations_organization_id_idx").on(table.organizationId),
|
|
2674
|
-
uniqueIndex$1("organization_invitations_org_user_pending_unique").on(table.organizationId, table.userId).where(sql`${table.status} = 'pending'`)
|
|
2675
|
-
]);
|
|
2676
|
-
const projectStatusEnum = pgEnum("project_status", [
|
|
2677
|
-
"inactive",
|
|
2678
|
-
"starting",
|
|
2679
|
-
"active",
|
|
2680
|
-
"failed"
|
|
2681
|
-
]);
|
|
2682
|
-
const projects = pgTable("projects", {
|
|
2683
|
-
id: text("id").primaryKey(),
|
|
2684
|
-
organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
|
2685
|
-
name: text("name").notNull(),
|
|
2686
|
-
slug: text("slug").notNull(),
|
|
2687
|
-
description: text("description"),
|
|
2688
|
-
defaultMemberRole: text("default_member_role").notNull().$type().default("builder"),
|
|
2689
|
-
invitePermission: text("invite_permission").notNull().$type().default("admin"),
|
|
2690
|
-
createdByUserId: text("created_by_user_id").references(() => users.id, { onDelete: "set null" }),
|
|
2691
|
-
status: projectStatusEnum("status").notNull(),
|
|
2692
|
-
baseUrl: text("base_url"),
|
|
2693
|
-
runtimeId: text("runtime_id"),
|
|
2694
|
-
activeArtifactId: text("active_artifact_id"),
|
|
2695
|
-
pendingArtifactId: text("pending_artifact_id"),
|
|
2696
|
-
lastError: text("last_error"),
|
|
2697
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2698
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
2699
|
-
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
2700
|
-
}, (table) => [index("projects_organization_id_idx").on(table.organizationId), uniqueIndex("projects_organization_slug_unique").on(table.organizationId, table.slug).where(sql`${table.deletedAt} IS NULL`)]);
|
|
2701
|
-
const projectsSqlite = sqliteTable("projects", {
|
|
2702
|
-
id: text$1("id").primaryKey(),
|
|
2703
|
-
organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
2704
|
-
name: text$1("name").notNull(),
|
|
2705
|
-
slug: text$1("slug").notNull(),
|
|
2706
|
-
description: text$1("description"),
|
|
2707
|
-
defaultMemberRole: text$1("default_member_role").notNull().$type().default("builder"),
|
|
2708
|
-
invitePermission: text$1("invite_permission").notNull().$type().default("admin"),
|
|
2709
|
-
createdByUserId: text$1("created_by_user_id").references(() => usersSqlite.id, { onDelete: "set null" }),
|
|
2710
|
-
status: text$1("status").$type().notNull(),
|
|
2711
|
-
baseUrl: text$1("base_url"),
|
|
2712
|
-
runtimeId: text$1("runtime_id"),
|
|
2713
|
-
activeArtifactId: text$1("active_artifact_id"),
|
|
2714
|
-
pendingArtifactId: text$1("pending_artifact_id"),
|
|
2715
|
-
lastError: text$1("last_error"),
|
|
2716
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2717
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
2718
|
-
deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
|
|
2719
|
-
}, (table) => [index$1("projects_organization_id_idx").on(table.organizationId), uniqueIndex$1("projects_organization_slug_unique").on(table.organizationId, table.slug).where(sql`${table.deletedAt} IS NULL`)]);
|
|
2720
|
-
const projectArtifactStatusEnum = pgEnum("project_artifact_status", ["pending", "ready"]);
|
|
2721
|
-
const projectArtifacts = pgTable("project_artifacts", {
|
|
2722
|
-
id: text("id").primaryKey(),
|
|
2723
|
-
projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
2724
|
-
storageKey: text("storage_key").notNull(),
|
|
2725
|
-
manifestJson: jsonb("manifest_json"),
|
|
2726
|
-
sourceManifestJson: jsonb("source_manifest_json"),
|
|
2727
|
-
version: integer("version").notNull(),
|
|
2728
|
-
createdByUserId: text("created_by_user_id").references(() => users.id, { onDelete: "set null" }),
|
|
2729
|
-
status: projectArtifactStatusEnum("status").notNull(),
|
|
2730
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2731
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2732
|
-
}, (table) => [index("project_artifacts_project_id_idx").on(table.projectId)]);
|
|
2733
|
-
const projectArtifactsSqlite = sqliteTable("project_artifacts", {
|
|
2734
|
-
id: text$1("id").primaryKey(),
|
|
2735
|
-
projectId: text$1("project_id").notNull().references(() => projectsSqlite.id, { onDelete: "cascade" }),
|
|
2736
|
-
storageKey: text$1("storage_key").notNull(),
|
|
2737
|
-
manifestJson: text$1("manifest_json", { mode: "json" }),
|
|
2738
|
-
sourceManifestJson: text$1("source_manifest_json", { mode: "json" }),
|
|
2739
|
-
version: integer$1("version").notNull(),
|
|
2740
|
-
createdByUserId: text$1("created_by_user_id").references(() => usersSqlite.id, { onDelete: "set null" }),
|
|
2741
|
-
status: text$1("status").$type().notNull(),
|
|
2742
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2743
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
2744
|
-
}, (table) => [index$1("project_artifacts_project_id_idx").on(table.projectId)]);
|
|
2745
|
-
const projectUsers = pgTable("project_users", {
|
|
2746
|
-
projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
2747
|
-
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
2748
|
-
role: text("role").notNull().$type(),
|
|
2749
|
-
status: text("status").notNull().$type().default("active"),
|
|
2750
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2751
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
2752
|
-
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
2753
|
-
}, (table) => [primaryKey({ columns: [table.projectId, table.userId] }), index("project_users_user_id_idx").on(table.userId)]);
|
|
2754
|
-
const projectUsersSqlite = sqliteTable("project_users", {
|
|
2755
|
-
projectId: text$1("project_id").notNull().references(() => projectsSqlite.id, { onDelete: "cascade" }),
|
|
2756
|
-
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
2757
|
-
role: text$1("role").notNull().$type(),
|
|
2758
|
-
status: text$1("status").notNull().$type().default("active"),
|
|
2759
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2760
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
2761
|
-
deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
|
|
2762
|
-
}, (table) => [primaryKey$1({ columns: [table.projectId, table.userId] }), index$1("project_users_user_id_idx").on(table.userId)]);
|
|
2763
|
-
const secretValues = pgTable("secret_values", {
|
|
2764
|
-
id: text("id").primaryKey(),
|
|
2765
|
-
organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
|
2766
|
-
refKind: text("ref_kind").$type().notNull(),
|
|
2767
|
-
refId: text("ref_id").notNull(),
|
|
2768
|
-
field: text("field").$type().notNull(),
|
|
2769
|
-
ciphertext: text("ciphertext").notNull(),
|
|
2770
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
2771
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2772
|
-
}, (table) => [uniqueIndex("secret_values_ref_unique").on(table.organizationId, table.refKind, table.refId, table.field)]);
|
|
2773
|
-
const secretValuesSqlite = sqliteTable("secret_values", {
|
|
2774
|
-
id: text$1("id").primaryKey(),
|
|
2775
|
-
organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
2776
|
-
refKind: text$1("ref_kind").$type().notNull(),
|
|
2777
|
-
refId: text$1("ref_id").notNull(),
|
|
2778
|
-
field: text$1("field").$type().notNull(),
|
|
2779
|
-
ciphertext: text$1("ciphertext").notNull(),
|
|
2780
|
-
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
2781
|
-
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
2782
|
-
}, (table) => [uniqueIndex$1("secret_values_ref_unique").on(table.organizationId, table.refKind, table.refId, table.field)]);
|
|
2783
|
-
/**
|
|
2784
|
-
* Platform control-plane tables — Postgres (hosted) or SQLite (local dev).
|
|
2785
|
-
*/
|
|
2786
|
-
const tableRegistry = {
|
|
2787
|
-
organizations: {
|
|
2788
|
-
pg: organizations,
|
|
2789
|
-
sqlite: organizationsSqlite
|
|
2790
|
-
},
|
|
2791
|
-
organizationUsers: {
|
|
2792
|
-
pg: organizationUsers,
|
|
2793
|
-
sqlite: organizationUsersSqlite
|
|
2794
|
-
},
|
|
2795
|
-
organizationInvitations: {
|
|
2796
|
-
pg: organizationInvitations,
|
|
2797
|
-
sqlite: organizationInvitationsSqlite
|
|
2798
|
-
},
|
|
2799
|
-
projects: {
|
|
2800
|
-
pg: projects,
|
|
2801
|
-
sqlite: projectsSqlite
|
|
2802
|
-
},
|
|
2803
|
-
projectUsers: {
|
|
2804
|
-
pg: projectUsers,
|
|
2805
|
-
sqlite: projectUsersSqlite
|
|
2806
|
-
},
|
|
2807
|
-
projectArtifacts: {
|
|
2808
|
-
pg: projectArtifacts,
|
|
2809
|
-
sqlite: projectArtifactsSqlite
|
|
2810
|
-
},
|
|
2811
|
-
users: {
|
|
2812
|
-
pg: users,
|
|
2813
|
-
sqlite: usersSqlite
|
|
2814
|
-
},
|
|
2815
|
-
authSessions: {
|
|
2816
|
-
pg: authSessions,
|
|
2817
|
-
sqlite: authSessionsSqlite
|
|
2818
|
-
},
|
|
2819
|
-
authAccounts: {
|
|
2820
|
-
pg: authAccounts,
|
|
2821
|
-
sqlite: authAccountsSqlite
|
|
2822
|
-
},
|
|
2823
|
-
authVerifications: {
|
|
2824
|
-
pg: authVerifications,
|
|
2825
|
-
sqlite: authVerificationsSqlite
|
|
2826
|
-
},
|
|
2827
|
-
authDeviceCodes: {
|
|
2828
|
-
pg: authDeviceCodes,
|
|
2829
|
-
sqlite: authDeviceCodesSqlite
|
|
2830
|
-
},
|
|
2831
|
-
authJwks: {
|
|
2832
|
-
pg: authJwks,
|
|
2833
|
-
sqlite: authJwksSqlite
|
|
2834
|
-
},
|
|
2835
|
-
authApiKeys: {
|
|
2836
|
-
pg: authApiKeys,
|
|
2837
|
-
sqlite: authApiKeysSqlite
|
|
2838
|
-
},
|
|
2839
|
-
apps: {
|
|
2840
|
-
pg: apps,
|
|
2841
|
-
sqlite: appsSqlite
|
|
2842
|
-
},
|
|
2843
|
-
oauthApps: {
|
|
2844
|
-
pg: oauthApps,
|
|
2845
|
-
sqlite: oauthAppsSqlite
|
|
2846
|
-
},
|
|
2847
|
-
oauthConnections: {
|
|
2848
|
-
pg: oauthConnections,
|
|
2849
|
-
sqlite: oauthConnectionsSqlite
|
|
2850
|
-
},
|
|
2851
|
-
mcpOauthClient: {
|
|
2852
|
-
pg: mcpOauthClient,
|
|
2853
|
-
sqlite: mcpOauthClientSqlite
|
|
2854
|
-
},
|
|
2855
|
-
mcpOauthAccessToken: {
|
|
2856
|
-
pg: mcpOauthAccessToken,
|
|
2857
|
-
sqlite: mcpOauthAccessTokenSqlite
|
|
2858
|
-
},
|
|
2859
|
-
mcpOauthConsent: {
|
|
2860
|
-
pg: mcpOauthConsent,
|
|
2861
|
-
sqlite: mcpOauthConsentSqlite
|
|
2862
|
-
},
|
|
2863
|
-
secretValues: {
|
|
2864
|
-
pg: secretValues,
|
|
2865
|
-
sqlite: secretValuesSqlite
|
|
2866
|
-
}
|
|
2867
|
-
};
|
|
2868
|
-
buildPgSchema(tableRegistry);
|
|
2869
|
-
buildSqliteSchema(tableRegistry);
|
|
2870
|
-
new AsyncLocalStorage();
|
|
2871
|
-
new AsyncLocalStorage();
|
|
2872
|
-
globalThis.crypto?.webcrypto ?? globalThis.crypto ?? import("node:crypto").then((m) => m.webcrypto);
|
|
2873
|
-
//#endregion
|
|
2874
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
2875
|
-
const RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
2876
|
-
/**
|
|
2877
|
-
* Assert 'object' type schema.
|
|
2878
|
-
*
|
|
2879
|
-
* @internal
|
|
2880
|
-
*/
|
|
2881
|
-
const AssertObjectSchema = custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
|
|
2882
|
-
/**
|
|
2883
|
-
* A progress token, used to associate progress notifications with the original request.
|
|
2884
|
-
*/
|
|
2885
|
-
const ProgressTokenSchema = union([string(), number().int()]);
|
|
2886
|
-
/**
|
|
2887
|
-
* An opaque token used to represent a cursor for pagination.
|
|
2888
|
-
*/
|
|
2889
|
-
const CursorSchema = string();
|
|
2890
|
-
looseObject({
|
|
2891
|
-
/**
|
|
2892
|
-
* Requested duration in milliseconds to retain task from creation.
|
|
2893
|
-
*/
|
|
2894
|
-
ttl: number().optional(),
|
|
2895
|
-
/**
|
|
2896
|
-
* Time in milliseconds to wait between task status requests.
|
|
2897
|
-
*/
|
|
2898
|
-
pollInterval: number().optional()
|
|
2899
|
-
});
|
|
2900
|
-
const TaskMetadataSchema = object({ ttl: number().optional() });
|
|
2901
|
-
/**
|
|
2902
|
-
* Metadata for associating messages with a task.
|
|
2903
|
-
* Include this in the `_meta` field under the key `io.modelcontextprotocol/related-task`.
|
|
2904
|
-
*/
|
|
2905
|
-
const RelatedTaskMetadataSchema = object({ taskId: string() });
|
|
2906
|
-
const RequestMetaSchema = looseObject({
|
|
2907
|
-
/**
|
|
2908
|
-
* If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
|
|
2909
|
-
*/
|
|
2910
|
-
progressToken: ProgressTokenSchema.optional(),
|
|
2911
|
-
/**
|
|
2912
|
-
* If specified, this request is related to the provided task.
|
|
2913
|
-
*/
|
|
2914
|
-
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
2915
|
-
});
|
|
2916
|
-
/**
|
|
2917
|
-
* Common params for any request.
|
|
2918
|
-
*/
|
|
2919
|
-
const BaseRequestParamsSchema = object({
|
|
2920
|
-
/**
|
|
2921
|
-
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
|
|
2922
|
-
*/
|
|
2923
|
-
_meta: RequestMetaSchema.optional() });
|
|
2924
|
-
/**
|
|
2925
|
-
* Common params for any task-augmented request.
|
|
2926
|
-
*/
|
|
2927
|
-
const TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
2928
|
-
/**
|
|
2929
|
-
* If specified, the caller is requesting task-augmented execution for this request.
|
|
2930
|
-
* The request will return a CreateTaskResult immediately, and the actual result can be
|
|
2931
|
-
* retrieved later via tasks/result.
|
|
2932
|
-
*
|
|
2933
|
-
* Task augmentation is subject to capability negotiation - receivers MUST declare support
|
|
2934
|
-
* for task augmentation of specific request types in their capabilities.
|
|
2935
|
-
*/
|
|
2936
|
-
task: TaskMetadataSchema.optional() });
|
|
2937
|
-
const RequestSchema = object({
|
|
2938
|
-
method: string(),
|
|
2939
|
-
params: BaseRequestParamsSchema.loose().optional()
|
|
2940
|
-
});
|
|
2941
|
-
const NotificationsParamsSchema = object({
|
|
2942
|
-
/**
|
|
2943
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
2944
|
-
* for notes on _meta usage.
|
|
2945
|
-
*/
|
|
2946
|
-
_meta: RequestMetaSchema.optional() });
|
|
2947
|
-
const NotificationSchema = object({
|
|
2948
|
-
method: string(),
|
|
2949
|
-
params: NotificationsParamsSchema.loose().optional()
|
|
2950
|
-
});
|
|
2951
|
-
const ResultSchema = looseObject({
|
|
2952
|
-
/**
|
|
2953
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
2954
|
-
* for notes on _meta usage.
|
|
2955
|
-
*/
|
|
2956
|
-
_meta: RequestMetaSchema.optional() });
|
|
2957
|
-
/**
|
|
2958
|
-
* A uniquely identifying ID for a request in JSON-RPC.
|
|
2959
|
-
*/
|
|
2960
|
-
const RequestIdSchema = union([string(), number().int()]);
|
|
2961
|
-
/**
|
|
2962
|
-
* A request that expects a response.
|
|
2963
|
-
*/
|
|
2964
|
-
const JSONRPCRequestSchema = object({
|
|
2965
|
-
jsonrpc: literal("2.0"),
|
|
2966
|
-
id: RequestIdSchema,
|
|
2967
|
-
...RequestSchema.shape
|
|
2968
|
-
}).strict();
|
|
2969
|
-
/**
|
|
2970
|
-
* A notification which does not expect a response.
|
|
2971
|
-
*/
|
|
2972
|
-
const JSONRPCNotificationSchema = object({
|
|
2973
|
-
jsonrpc: literal("2.0"),
|
|
2974
|
-
...NotificationSchema.shape
|
|
2975
|
-
}).strict();
|
|
2976
|
-
/**
|
|
2977
|
-
* A successful (non-error) response to a request.
|
|
2978
|
-
*/
|
|
2979
|
-
const JSONRPCResultResponseSchema = object({
|
|
2980
|
-
jsonrpc: literal("2.0"),
|
|
2981
|
-
id: RequestIdSchema,
|
|
2982
|
-
result: ResultSchema
|
|
2983
|
-
}).strict();
|
|
2984
|
-
/**
|
|
2985
|
-
* Error codes defined by the JSON-RPC specification.
|
|
2986
|
-
*/
|
|
2987
|
-
var ErrorCode;
|
|
2988
|
-
(function(ErrorCode) {
|
|
2989
|
-
ErrorCode[ErrorCode["ConnectionClosed"] = -32e3] = "ConnectionClosed";
|
|
2990
|
-
ErrorCode[ErrorCode["RequestTimeout"] = -32001] = "RequestTimeout";
|
|
2991
|
-
ErrorCode[ErrorCode["ParseError"] = -32700] = "ParseError";
|
|
2992
|
-
ErrorCode[ErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
|
|
2993
|
-
ErrorCode[ErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
2994
|
-
ErrorCode[ErrorCode["InvalidParams"] = -32602] = "InvalidParams";
|
|
2995
|
-
ErrorCode[ErrorCode["InternalError"] = -32603] = "InternalError";
|
|
2996
|
-
ErrorCode[ErrorCode["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
2997
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
2998
|
-
/**
|
|
2999
|
-
* A response to a request that indicates an error occurred.
|
|
3000
|
-
*/
|
|
3001
|
-
const JSONRPCErrorResponseSchema = object({
|
|
3002
|
-
jsonrpc: literal("2.0"),
|
|
3003
|
-
id: RequestIdSchema.optional(),
|
|
3004
|
-
error: object({
|
|
3005
|
-
/**
|
|
3006
|
-
* The error type that occurred.
|
|
3007
|
-
*/
|
|
3008
|
-
code: number().int(),
|
|
3009
|
-
/**
|
|
3010
|
-
* A short description of the error. The message SHOULD be limited to a concise single sentence.
|
|
3011
|
-
*/
|
|
3012
|
-
message: string(),
|
|
3013
|
-
/**
|
|
3014
|
-
* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
|
|
3015
|
-
*/
|
|
3016
|
-
data: unknown().optional()
|
|
3017
|
-
})
|
|
3018
|
-
}).strict();
|
|
3019
|
-
union([
|
|
3020
|
-
JSONRPCRequestSchema,
|
|
3021
|
-
JSONRPCNotificationSchema,
|
|
3022
|
-
JSONRPCResultResponseSchema,
|
|
3023
|
-
JSONRPCErrorResponseSchema
|
|
3024
|
-
]);
|
|
3025
|
-
union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
|
|
3026
|
-
/**
|
|
3027
|
-
* A response that indicates success but carries no data.
|
|
3028
|
-
*/
|
|
3029
|
-
const EmptyResultSchema = ResultSchema.strict();
|
|
3030
|
-
const CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
3031
|
-
/**
|
|
3032
|
-
* The ID of the request to cancel.
|
|
3033
|
-
*
|
|
3034
|
-
* This MUST correspond to the ID of a request previously issued in the same direction.
|
|
3035
|
-
*/
|
|
3036
|
-
requestId: RequestIdSchema.optional(),
|
|
3037
|
-
/**
|
|
3038
|
-
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
|
|
3039
|
-
*/
|
|
3040
|
-
reason: string().optional()
|
|
3041
|
-
});
|
|
3042
|
-
/**
|
|
3043
|
-
* This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
|
|
3044
|
-
*
|
|
3045
|
-
* The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
|
|
3046
|
-
*
|
|
3047
|
-
* This notification indicates that the result will be unused, so any associated processing SHOULD cease.
|
|
3048
|
-
*
|
|
3049
|
-
* A client MUST NOT attempt to cancel its `initialize` request.
|
|
2027
|
+
* A client MUST NOT attempt to cancel its `initialize` request.
|
|
3050
2028
|
*/
|
|
3051
2029
|
const CancelledNotificationSchema = NotificationSchema.extend({
|
|
3052
2030
|
method: literal("notifications/cancelled"),
|
|
@@ -11186,10 +10164,701 @@ var require_limit = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
11186
10164
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 || (_b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`);
|
|
11187
10165
|
for (const f of list) ajv.addFormat(f, fs[f]);
|
|
11188
10166
|
}
|
|
11189
|
-
module.exports = exports = formatsPlugin;
|
|
11190
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11191
|
-
exports.default = formatsPlugin;
|
|
11192
|
-
})))();
|
|
10167
|
+
module.exports = exports = formatsPlugin;
|
|
10168
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10169
|
+
exports.default = formatsPlugin;
|
|
10170
|
+
})))();
|
|
10171
|
+
//#endregion
|
|
10172
|
+
//#region ../../packages/action/dist/index.mjs
|
|
10173
|
+
const zodSchema$3 = custom((v) => v instanceof ZodType, "must be a Zod schema");
|
|
10174
|
+
object({
|
|
10175
|
+
slug: string().trim().min(1),
|
|
10176
|
+
name: string().optional(),
|
|
10177
|
+
description: string().optional(),
|
|
10178
|
+
input: zodSchema$3,
|
|
10179
|
+
output: zodSchema$3,
|
|
10180
|
+
credentials: array(credentialInputSchema).optional(),
|
|
10181
|
+
run: _function()
|
|
10182
|
+
});
|
|
10183
|
+
new AsyncLocalStorage();
|
|
10184
|
+
new AsyncLocalStorage();
|
|
10185
|
+
new AbortController().signal;
|
|
10186
|
+
const REGISTRY_KEY$2 = Symbol.for("keystroke.workflowRunGetter");
|
|
10187
|
+
function registry$1() {
|
|
10188
|
+
const globalScope = globalThis;
|
|
10189
|
+
if (!globalScope[REGISTRY_KEY$2]) globalScope[REGISTRY_KEY$2] = {};
|
|
10190
|
+
return globalScope[REGISTRY_KEY$2];
|
|
10191
|
+
}
|
|
10192
|
+
function registerWorkflowRunGetter(fn) {
|
|
10193
|
+
registry$1().getter = fn;
|
|
10194
|
+
}
|
|
10195
|
+
//#endregion
|
|
10196
|
+
//#region ../../packages/platform-database/dist/mcp-oauth-SRTcHMWZ.mjs
|
|
10197
|
+
const users = pgTable("users", {
|
|
10198
|
+
id: text("id").primaryKey(),
|
|
10199
|
+
name: text("name").notNull(),
|
|
10200
|
+
email: text("email").notNull().unique(),
|
|
10201
|
+
emailVerified: boolean("email_verified").notNull(),
|
|
10202
|
+
image: text("image"),
|
|
10203
|
+
preferences: jsonb("preferences"),
|
|
10204
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10205
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10206
|
+
});
|
|
10207
|
+
const usersSqlite = sqliteTable("users", {
|
|
10208
|
+
id: text$1("id").primaryKey(),
|
|
10209
|
+
name: text$1("name").notNull(),
|
|
10210
|
+
email: text$1("email").notNull().unique(),
|
|
10211
|
+
emailVerified: integer$1("email_verified", { mode: "boolean" }).notNull(),
|
|
10212
|
+
image: text$1("image"),
|
|
10213
|
+
preferences: text$1("preferences", { mode: "json" }),
|
|
10214
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10215
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10216
|
+
});
|
|
10217
|
+
const authAccounts = pgTable("accounts", {
|
|
10218
|
+
id: text("id").primaryKey(),
|
|
10219
|
+
accountId: text("account_id").notNull(),
|
|
10220
|
+
providerId: text("provider_id").notNull(),
|
|
10221
|
+
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
10222
|
+
accessToken: text("access_token"),
|
|
10223
|
+
refreshToken: text("refresh_token"),
|
|
10224
|
+
idToken: text("id_token"),
|
|
10225
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at", { withTimezone: true }),
|
|
10226
|
+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at", { withTimezone: true }),
|
|
10227
|
+
scope: text("scope"),
|
|
10228
|
+
password: text("password"),
|
|
10229
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10230
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10231
|
+
}, (table) => [index("account_user_id_idx").on(table.userId)]);
|
|
10232
|
+
const authAccountsSqlite = sqliteTable("accounts", {
|
|
10233
|
+
id: text$1("id").primaryKey(),
|
|
10234
|
+
accountId: text$1("account_id").notNull(),
|
|
10235
|
+
providerId: text$1("provider_id").notNull(),
|
|
10236
|
+
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
10237
|
+
accessToken: text$1("access_token"),
|
|
10238
|
+
refreshToken: text$1("refresh_token"),
|
|
10239
|
+
idToken: text$1("id_token"),
|
|
10240
|
+
accessTokenExpiresAt: integer$1("access_token_expires_at", { mode: "timestamp_ms" }),
|
|
10241
|
+
refreshTokenExpiresAt: integer$1("refresh_token_expires_at", { mode: "timestamp_ms" }),
|
|
10242
|
+
scope: text$1("scope"),
|
|
10243
|
+
password: text$1("password"),
|
|
10244
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10245
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10246
|
+
}, (table) => [index$1("account_user_id_idx").on(table.userId)]);
|
|
10247
|
+
const authDeviceCodes = pgTable("device_auth_codes", {
|
|
10248
|
+
id: text("id").primaryKey(),
|
|
10249
|
+
deviceCode: text("device_code").notNull(),
|
|
10250
|
+
userCode: text("user_code").notNull(),
|
|
10251
|
+
userId: text("user_id"),
|
|
10252
|
+
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
|
|
10253
|
+
status: text("status").notNull(),
|
|
10254
|
+
lastPolledAt: timestamp("last_polled_at", { withTimezone: true }),
|
|
10255
|
+
pollingInterval: integer("polling_interval"),
|
|
10256
|
+
clientId: text("client_id"),
|
|
10257
|
+
scope: text("scope")
|
|
10258
|
+
});
|
|
10259
|
+
const authDeviceCodesSqlite = sqliteTable("device_auth_codes", {
|
|
10260
|
+
id: text$1("id").primaryKey(),
|
|
10261
|
+
deviceCode: text$1("device_code").notNull(),
|
|
10262
|
+
userCode: text$1("user_code").notNull(),
|
|
10263
|
+
userId: text$1("user_id"),
|
|
10264
|
+
expiresAt: integer$1("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
10265
|
+
status: text$1("status").notNull(),
|
|
10266
|
+
lastPolledAt: integer$1("last_polled_at", { mode: "timestamp_ms" }),
|
|
10267
|
+
pollingInterval: integer$1("polling_interval"),
|
|
10268
|
+
clientId: text$1("client_id"),
|
|
10269
|
+
scope: text$1("scope")
|
|
10270
|
+
});
|
|
10271
|
+
const authJwks = pgTable("jwks", {
|
|
10272
|
+
id: text("id").primaryKey(),
|
|
10273
|
+
publicKey: text("public_key").notNull(),
|
|
10274
|
+
privateKey: text("private_key").notNull(),
|
|
10275
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10276
|
+
expiresAt: timestamp("expires_at", { withTimezone: true })
|
|
10277
|
+
});
|
|
10278
|
+
const authJwksSqlite = sqliteTable("jwks", {
|
|
10279
|
+
id: text$1("id").primaryKey(),
|
|
10280
|
+
publicKey: text$1("public_key").notNull(),
|
|
10281
|
+
privateKey: text$1("private_key").notNull(),
|
|
10282
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10283
|
+
expiresAt: integer$1("expires_at", { mode: "timestamp_ms" })
|
|
10284
|
+
});
|
|
10285
|
+
const authSessions = pgTable("sessions", {
|
|
10286
|
+
id: text("id").primaryKey(),
|
|
10287
|
+
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
|
|
10288
|
+
token: text("token").notNull().unique(),
|
|
10289
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10290
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
10291
|
+
ipAddress: text("ip_address"),
|
|
10292
|
+
userAgent: text("user_agent"),
|
|
10293
|
+
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" })
|
|
10294
|
+
}, (table) => [index("session_user_id_idx").on(table.userId)]);
|
|
10295
|
+
const authSessionsSqlite = sqliteTable("sessions", {
|
|
10296
|
+
id: text$1("id").primaryKey(),
|
|
10297
|
+
expiresAt: integer$1("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
10298
|
+
token: text$1("token").notNull().unique(),
|
|
10299
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10300
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
10301
|
+
ipAddress: text$1("ip_address"),
|
|
10302
|
+
userAgent: text$1("user_agent"),
|
|
10303
|
+
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" })
|
|
10304
|
+
}, (table) => [index$1("session_user_id_idx").on(table.userId)]);
|
|
10305
|
+
const authVerifications = pgTable("verification", {
|
|
10306
|
+
id: text("id").primaryKey(),
|
|
10307
|
+
identifier: text("identifier").notNull(),
|
|
10308
|
+
value: text("value").notNull(),
|
|
10309
|
+
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
|
|
10310
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10311
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10312
|
+
}, (table) => [index("verification_identifier_idx").on(table.identifier)]);
|
|
10313
|
+
const authVerificationsSqlite = sqliteTable("verification", {
|
|
10314
|
+
id: text$1("id").primaryKey(),
|
|
10315
|
+
identifier: text$1("identifier").notNull(),
|
|
10316
|
+
value: text$1("value").notNull(),
|
|
10317
|
+
expiresAt: integer$1("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
10318
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10319
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10320
|
+
}, (table) => [index$1("verification_identifier_idx").on(table.identifier)]);
|
|
10321
|
+
/**
|
|
10322
|
+
* Tables backing keystroke as an OAuth 2.1 Authorization Server for the
|
|
10323
|
+
* Universal MCP server: dynamically-registered MCP/AI clients, their issued
|
|
10324
|
+
* access/refresh tokens, and consent records.
|
|
10325
|
+
*
|
|
10326
|
+
* NOT to be confused with `oauth_apps` / `oauth_connections`, which model the
|
|
10327
|
+
* inverse — keystroke as an OAuth *client* storing our users' connections to
|
|
10328
|
+
* third-party providers. These `mcp_oauth_*` tables are the provider side.
|
|
10329
|
+
*
|
|
10330
|
+
* Wired to Better Auth via the Drizzle adapter (`authSchemaFor`). Better Auth
|
|
10331
|
+
* addresses these by its fixed model names (`oauthApplication`,
|
|
10332
|
+
* `oauthAccessToken`, `oauthConsent`) and by field name (the JS property keys
|
|
10333
|
+
* below); the physical table/column names are ours to choose.
|
|
10334
|
+
*
|
|
10335
|
+
* Note: access/refresh tokens are stored as opaque plaintext bearer strings
|
|
10336
|
+
* (the Better Auth mcp plugin looks them up directly and cannot hash them),
|
|
10337
|
+
* consistent with how the `sessions` table stores session tokens. They are
|
|
10338
|
+
* short-lived; rely on DB access controls + at-rest encryption.
|
|
10339
|
+
*/
|
|
10340
|
+
const mcpOauthClient = pgTable("mcp_oauth_client", {
|
|
10341
|
+
id: text("id").primaryKey(),
|
|
10342
|
+
name: text("name").notNull(),
|
|
10343
|
+
icon: text("icon"),
|
|
10344
|
+
metadata: text("metadata"),
|
|
10345
|
+
clientId: text("client_id").notNull().unique(),
|
|
10346
|
+
clientSecret: text("client_secret"),
|
|
10347
|
+
redirectUrls: text("redirect_urls").notNull(),
|
|
10348
|
+
type: text("type").notNull(),
|
|
10349
|
+
disabled: boolean("disabled").notNull().default(false),
|
|
10350
|
+
userId: text("user_id").references(() => users.id, { onDelete: "cascade" }),
|
|
10351
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10352
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10353
|
+
}, (table) => [index("mcp_oauth_client_user_id_idx").on(table.userId)]);
|
|
10354
|
+
const mcpOauthClientSqlite = sqliteTable("mcp_oauth_client", {
|
|
10355
|
+
id: text$1("id").primaryKey(),
|
|
10356
|
+
name: text$1("name").notNull(),
|
|
10357
|
+
icon: text$1("icon"),
|
|
10358
|
+
metadata: text$1("metadata"),
|
|
10359
|
+
clientId: text$1("client_id").notNull().unique(),
|
|
10360
|
+
clientSecret: text$1("client_secret"),
|
|
10361
|
+
redirectUrls: text$1("redirect_urls").notNull(),
|
|
10362
|
+
type: text$1("type").notNull(),
|
|
10363
|
+
disabled: integer$1("disabled", { mode: "boolean" }).notNull().default(false),
|
|
10364
|
+
userId: text$1("user_id").references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
10365
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10366
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10367
|
+
}, (table) => [index$1("mcp_oauth_client_user_id_idx").on(table.userId)]);
|
|
10368
|
+
const mcpOauthAccessToken = pgTable("mcp_oauth_access_token", {
|
|
10369
|
+
id: text("id").primaryKey(),
|
|
10370
|
+
accessToken: text("access_token").notNull().unique(),
|
|
10371
|
+
refreshToken: text("refresh_token").unique(),
|
|
10372
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at", { withTimezone: true }),
|
|
10373
|
+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at", { withTimezone: true }),
|
|
10374
|
+
clientId: text("client_id").notNull(),
|
|
10375
|
+
userId: text("user_id").references(() => users.id, { onDelete: "cascade" }),
|
|
10376
|
+
scopes: text("scopes"),
|
|
10377
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10378
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10379
|
+
}, (table) => [index("mcp_oauth_access_token_client_id_idx").on(table.clientId), index("mcp_oauth_access_token_user_id_idx").on(table.userId)]);
|
|
10380
|
+
const mcpOauthAccessTokenSqlite = sqliteTable("mcp_oauth_access_token", {
|
|
10381
|
+
id: text$1("id").primaryKey(),
|
|
10382
|
+
accessToken: text$1("access_token").notNull().unique(),
|
|
10383
|
+
refreshToken: text$1("refresh_token").unique(),
|
|
10384
|
+
accessTokenExpiresAt: integer$1("access_token_expires_at", { mode: "timestamp_ms" }),
|
|
10385
|
+
refreshTokenExpiresAt: integer$1("refresh_token_expires_at", { mode: "timestamp_ms" }),
|
|
10386
|
+
clientId: text$1("client_id").notNull(),
|
|
10387
|
+
userId: text$1("user_id").references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
10388
|
+
scopes: text$1("scopes"),
|
|
10389
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10390
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10391
|
+
}, (table) => [index$1("mcp_oauth_access_token_client_id_idx").on(table.clientId), index$1("mcp_oauth_access_token_user_id_idx").on(table.userId)]);
|
|
10392
|
+
const mcpOauthConsent = pgTable("mcp_oauth_consent", {
|
|
10393
|
+
id: text("id").primaryKey(),
|
|
10394
|
+
clientId: text("client_id").notNull(),
|
|
10395
|
+
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
10396
|
+
scopes: text("scopes"),
|
|
10397
|
+
consentGiven: boolean("consent_given").notNull().default(false),
|
|
10398
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10399
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10400
|
+
}, (table) => [index("mcp_oauth_consent_client_id_idx").on(table.clientId), index("mcp_oauth_consent_user_id_idx").on(table.userId)]);
|
|
10401
|
+
const mcpOauthConsentSqlite = sqliteTable("mcp_oauth_consent", {
|
|
10402
|
+
id: text$1("id").primaryKey(),
|
|
10403
|
+
clientId: text$1("client_id").notNull(),
|
|
10404
|
+
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
10405
|
+
scopes: text$1("scopes"),
|
|
10406
|
+
consentGiven: integer$1("consent_given", { mode: "boolean" }).notNull().default(false),
|
|
10407
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10408
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10409
|
+
}, (table) => [index$1("mcp_oauth_consent_client_id_idx").on(table.clientId), index$1("mcp_oauth_consent_user_id_idx").on(table.userId)]);
|
|
10410
|
+
createRequire(import.meta.url);
|
|
10411
|
+
function buildPgSchema(registry) {
|
|
10412
|
+
return Object.fromEntries(Object.entries(registry).map(([name, { pg }]) => [name, pg]));
|
|
10413
|
+
}
|
|
10414
|
+
function buildSqliteSchema(registry) {
|
|
10415
|
+
return Object.fromEntries(Object.entries(registry).map(([name, { sqlite }]) => [name, sqlite]));
|
|
10416
|
+
}
|
|
10417
|
+
/** Better Auth API Key shape (`apikey` model → physical `api_keys`). */
|
|
10418
|
+
const authApiKeys = pgTable("api_keys", {
|
|
10419
|
+
id: text("id").primaryKey(),
|
|
10420
|
+
configId: text("config_id").notNull().default("default"),
|
|
10421
|
+
name: text("name"),
|
|
10422
|
+
start: text("start"),
|
|
10423
|
+
prefix: text("prefix"),
|
|
10424
|
+
/** Hashed secret for verification (Better Auth `key`). */
|
|
10425
|
+
key: text("key").notNull(),
|
|
10426
|
+
/** Encrypted plaintext secret — keystroke extension for re-display. */
|
|
10427
|
+
keyCiphertext: text("key_ciphertext"),
|
|
10428
|
+
referenceId: text("reference_id").notNull(),
|
|
10429
|
+
refillInterval: integer("refill_interval"),
|
|
10430
|
+
refillAmount: integer("refill_amount"),
|
|
10431
|
+
lastRefillAt: timestamp("last_refill_at", { withTimezone: true }),
|
|
10432
|
+
enabled: boolean("enabled").default(true),
|
|
10433
|
+
rateLimitEnabled: boolean("rate_limit_enabled").default(true),
|
|
10434
|
+
rateLimitTimeWindow: integer("rate_limit_time_window"),
|
|
10435
|
+
rateLimitMax: integer("rate_limit_max"),
|
|
10436
|
+
requestCount: integer("request_count").default(0),
|
|
10437
|
+
remaining: integer("remaining"),
|
|
10438
|
+
lastRequest: timestamp("last_request", { withTimezone: true }),
|
|
10439
|
+
expiresAt: timestamp("expires_at", { withTimezone: true }),
|
|
10440
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10441
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
10442
|
+
permissions: text("permissions"),
|
|
10443
|
+
metadata: text("metadata")
|
|
10444
|
+
}, (table) => [
|
|
10445
|
+
index("api_keys_reference_id_idx").on(table.referenceId),
|
|
10446
|
+
index("api_keys_config_id_idx").on(table.configId),
|
|
10447
|
+
index("api_keys_key_idx").on(table.key)
|
|
10448
|
+
]);
|
|
10449
|
+
const authApiKeysSqlite = sqliteTable("api_keys", {
|
|
10450
|
+
id: text$1("id").primaryKey(),
|
|
10451
|
+
configId: text$1("config_id").notNull().default("default"),
|
|
10452
|
+
name: text$1("name"),
|
|
10453
|
+
start: text$1("start"),
|
|
10454
|
+
prefix: text$1("prefix"),
|
|
10455
|
+
key: text$1("key").notNull(),
|
|
10456
|
+
keyCiphertext: text$1("key_ciphertext"),
|
|
10457
|
+
referenceId: text$1("reference_id").notNull(),
|
|
10458
|
+
refillInterval: integer$1("refill_interval"),
|
|
10459
|
+
refillAmount: integer$1("refill_amount"),
|
|
10460
|
+
lastRefillAt: integer$1("last_refill_at", { mode: "timestamp_ms" }),
|
|
10461
|
+
enabled: integer$1("enabled", { mode: "boolean" }).default(true),
|
|
10462
|
+
rateLimitEnabled: integer$1("rate_limit_enabled", { mode: "boolean" }).default(true),
|
|
10463
|
+
rateLimitTimeWindow: integer$1("rate_limit_time_window"),
|
|
10464
|
+
rateLimitMax: integer$1("rate_limit_max"),
|
|
10465
|
+
requestCount: integer$1("request_count").default(0),
|
|
10466
|
+
remaining: integer$1("remaining"),
|
|
10467
|
+
lastRequest: integer$1("last_request", { mode: "timestamp_ms" }),
|
|
10468
|
+
expiresAt: integer$1("expires_at", { mode: "timestamp_ms" }),
|
|
10469
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10470
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
10471
|
+
permissions: text$1("permissions"),
|
|
10472
|
+
metadata: text$1("metadata")
|
|
10473
|
+
}, (table) => [
|
|
10474
|
+
index$1("api_keys_reference_id_idx").on(table.referenceId),
|
|
10475
|
+
index$1("api_keys_config_id_idx").on(table.configId),
|
|
10476
|
+
index$1("api_keys_key_idx").on(table.key)
|
|
10477
|
+
]);
|
|
10478
|
+
const organizations = pgTable("organizations", {
|
|
10479
|
+
id: text("id").primaryKey(),
|
|
10480
|
+
name: text("name").notNull(),
|
|
10481
|
+
slug: text("slug").notNull(),
|
|
10482
|
+
dbSchema: text("db_schema").notNull(),
|
|
10483
|
+
dbUser: text("db_user").notNull(),
|
|
10484
|
+
dbPasswordCiphertext: text("db_password_ciphertext").notNull(),
|
|
10485
|
+
hostingAppName: text("hosting_app_name"),
|
|
10486
|
+
runtimeId: text("runtime_id"),
|
|
10487
|
+
baseUrl: text("base_url"),
|
|
10488
|
+
storageBucket: text("storage_bucket"),
|
|
10489
|
+
storageEndpoint: text("storage_endpoint"),
|
|
10490
|
+
storageAccessKeyIdCiphertext: text("storage_access_key_id_ciphertext"),
|
|
10491
|
+
storageSecretAccessKeyCiphertext: text("storage_secret_access_key_ciphertext"),
|
|
10492
|
+
storageRegion: text("storage_region"),
|
|
10493
|
+
storageForcePathStyle: boolean("storage_force_path_style"),
|
|
10494
|
+
customLogoEnabled: boolean("custom_logo_enabled").notNull().default(false),
|
|
10495
|
+
customLogoExplicitlyDisabled: boolean("custom_logo_explicitly_disabled").notNull().default(false),
|
|
10496
|
+
logoLightUrl: text("logo_light_url"),
|
|
10497
|
+
logoDarkUrl: text("logo_dark_url"),
|
|
10498
|
+
logoHeightPx: integer("logo_height_px").notNull().default(20),
|
|
10499
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10500
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
10501
|
+
verifiedAt: timestamp("verified_at", { withTimezone: true }),
|
|
10502
|
+
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
10503
|
+
}, (table) => [uniqueIndex("organizations_slug_unique").on(table.slug)]);
|
|
10504
|
+
const organizationsSqlite = sqliteTable("organizations", {
|
|
10505
|
+
id: text$1("id").primaryKey(),
|
|
10506
|
+
name: text$1("name").notNull(),
|
|
10507
|
+
slug: text$1("slug").notNull(),
|
|
10508
|
+
dbSchema: text$1("db_schema").notNull(),
|
|
10509
|
+
dbUser: text$1("db_user").notNull(),
|
|
10510
|
+
dbPasswordCiphertext: text$1("db_password_ciphertext").notNull(),
|
|
10511
|
+
hostingAppName: text$1("hosting_app_name"),
|
|
10512
|
+
runtimeId: text$1("runtime_id"),
|
|
10513
|
+
baseUrl: text$1("base_url"),
|
|
10514
|
+
storageBucket: text$1("storage_bucket"),
|
|
10515
|
+
storageEndpoint: text$1("storage_endpoint"),
|
|
10516
|
+
storageAccessKeyIdCiphertext: text$1("storage_access_key_id_ciphertext"),
|
|
10517
|
+
storageSecretAccessKeyCiphertext: text$1("storage_secret_access_key_ciphertext"),
|
|
10518
|
+
storageRegion: text$1("storage_region"),
|
|
10519
|
+
storageForcePathStyle: integer$1("storage_force_path_style", { mode: "boolean" }),
|
|
10520
|
+
customLogoEnabled: integer$1("custom_logo_enabled", { mode: "boolean" }).notNull().default(false),
|
|
10521
|
+
customLogoExplicitlyDisabled: integer$1("custom_logo_explicitly_disabled", { mode: "boolean" }).notNull().default(false),
|
|
10522
|
+
logoLightUrl: text$1("logo_light_url"),
|
|
10523
|
+
logoDarkUrl: text$1("logo_dark_url"),
|
|
10524
|
+
logoHeightPx: integer$1("logo_height_px").notNull().default(20),
|
|
10525
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10526
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
10527
|
+
verifiedAt: integer$1("verified_at", { mode: "timestamp_ms" }),
|
|
10528
|
+
deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
|
|
10529
|
+
}, (table) => [uniqueIndex$1("organizations_slug_unique").on(table.slug)]);
|
|
10530
|
+
const apps = pgTable("apps", {
|
|
10531
|
+
id: text("id").primaryKey(),
|
|
10532
|
+
organizationId: text("organization_id").references(() => organizations.id, { onDelete: "cascade" }),
|
|
10533
|
+
slug: text("slug").notNull(),
|
|
10534
|
+
name: text("name").notNull(),
|
|
10535
|
+
description: text("description").notNull(),
|
|
10536
|
+
category: text("category").notNull(),
|
|
10537
|
+
logo: text("logo"),
|
|
10538
|
+
authKind: text("auth_kind").$type().notNull(),
|
|
10539
|
+
oauthScopes: jsonb("oauth_scopes").$type().notNull(),
|
|
10540
|
+
credentialFields: jsonb("credential_fields").$type().notNull().default({}),
|
|
10541
|
+
credentialScheme: text("credential_scheme").$type(),
|
|
10542
|
+
url: text("url"),
|
|
10543
|
+
source: text("source").$type().notNull(),
|
|
10544
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10545
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10546
|
+
}, (table) => [uniqueIndex("apps_slug_idx").on(table.slug), index("apps_organization_id_idx").on(table.organizationId)]);
|
|
10547
|
+
const appsSqlite = sqliteTable("apps", {
|
|
10548
|
+
id: text$1("id").primaryKey(),
|
|
10549
|
+
organizationId: text$1("organization_id").references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
10550
|
+
slug: text$1("slug").notNull(),
|
|
10551
|
+
name: text$1("name").notNull(),
|
|
10552
|
+
description: text$1("description").notNull(),
|
|
10553
|
+
category: text$1("category").notNull(),
|
|
10554
|
+
logo: text$1("logo"),
|
|
10555
|
+
authKind: text$1("auth_kind").$type().notNull(),
|
|
10556
|
+
oauthScopes: text$1("oauth_scopes", { mode: "json" }).$type().notNull(),
|
|
10557
|
+
credentialFields: text$1("credential_fields", { mode: "json" }).$type().notNull().default({}),
|
|
10558
|
+
credentialScheme: text$1("credential_scheme").$type(),
|
|
10559
|
+
url: text$1("url"),
|
|
10560
|
+
source: text$1("source").$type().notNull(),
|
|
10561
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10562
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10563
|
+
}, (table) => [uniqueIndex$1("apps_slug_idx").on(table.slug), index$1("apps_organization_id_idx").on(table.organizationId)]);
|
|
10564
|
+
const oauthApps = pgTable("oauth_apps", {
|
|
10565
|
+
id: text("id").primaryKey(),
|
|
10566
|
+
organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
|
10567
|
+
provider: text("provider").notNull(),
|
|
10568
|
+
slug: text("slug").notNull(),
|
|
10569
|
+
tokenStrategy: text("token_strategy").$type().notNull(),
|
|
10570
|
+
clientIdCiphertext: text("client_id_ciphertext").notNull(),
|
|
10571
|
+
clientSecretCiphertext: text("client_secret_ciphertext").notNull(),
|
|
10572
|
+
signingSecretCiphertext: text("signing_secret_ciphertext"),
|
|
10573
|
+
redirectUri: text("redirect_uri"),
|
|
10574
|
+
metadata: jsonb("metadata").$type(),
|
|
10575
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10576
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10577
|
+
}, (table) => [uniqueIndex("oauth_apps_organization_id_slug_idx").on(table.organizationId, table.slug), index("oauth_apps_slug_idx").on(table.slug)]);
|
|
10578
|
+
const oauthAppsSqlite = sqliteTable("oauth_apps", {
|
|
10579
|
+
id: text$1("id").primaryKey(),
|
|
10580
|
+
organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
10581
|
+
provider: text$1("provider").notNull(),
|
|
10582
|
+
slug: text$1("slug").notNull(),
|
|
10583
|
+
tokenStrategy: text$1("token_strategy").$type().notNull(),
|
|
10584
|
+
clientIdCiphertext: text$1("client_id_ciphertext").notNull(),
|
|
10585
|
+
clientSecretCiphertext: text$1("client_secret_ciphertext").notNull(),
|
|
10586
|
+
signingSecretCiphertext: text$1("signing_secret_ciphertext"),
|
|
10587
|
+
redirectUri: text$1("redirect_uri"),
|
|
10588
|
+
metadata: text$1("metadata", { mode: "json" }).$type(),
|
|
10589
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10590
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10591
|
+
}, (table) => [uniqueIndex$1("oauth_apps_organization_id_slug_idx").on(table.organizationId, table.slug), index$1("oauth_apps_slug_idx").on(table.slug)]);
|
|
10592
|
+
const oauthConnections = pgTable("oauth_connections", {
|
|
10593
|
+
id: text("id").primaryKey(),
|
|
10594
|
+
appId: text("app_id").notNull().references(() => oauthApps.id, { onDelete: "cascade" }),
|
|
10595
|
+
externalId: text("external_id").notNull(),
|
|
10596
|
+
accessTokenCiphertext: text("access_token_ciphertext").notNull(),
|
|
10597
|
+
refreshTokenCiphertext: text("refresh_token_ciphertext"),
|
|
10598
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at", { withTimezone: true }),
|
|
10599
|
+
grantedScopes: jsonb("granted_scopes").$type(),
|
|
10600
|
+
metadata: jsonb("metadata").$type(),
|
|
10601
|
+
connectedAt: timestamp("connected_at", { withTimezone: true }).notNull(),
|
|
10602
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10603
|
+
}, (table) => [uniqueIndex("oauth_connections_app_external_unique").on(table.appId, table.externalId), index("oauth_connections_external_id_idx").on(table.externalId)]);
|
|
10604
|
+
const oauthConnectionsSqlite = sqliteTable("oauth_connections", {
|
|
10605
|
+
id: text$1("id").primaryKey(),
|
|
10606
|
+
appId: text$1("app_id").notNull().references(() => oauthAppsSqlite.id, { onDelete: "cascade" }),
|
|
10607
|
+
externalId: text$1("external_id").notNull(),
|
|
10608
|
+
accessTokenCiphertext: text$1("access_token_ciphertext").notNull(),
|
|
10609
|
+
refreshTokenCiphertext: text$1("refresh_token_ciphertext"),
|
|
10610
|
+
accessTokenExpiresAt: integer$1("access_token_expires_at", { mode: "timestamp_ms" }),
|
|
10611
|
+
grantedScopes: text$1("granted_scopes", { mode: "json" }).$type(),
|
|
10612
|
+
metadata: text$1("metadata", { mode: "json" }).$type(),
|
|
10613
|
+
connectedAt: integer$1("connected_at", { mode: "timestamp_ms" }).notNull(),
|
|
10614
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10615
|
+
}, (table) => [uniqueIndex$1("oauth_connections_app_external_unique").on(table.appId, table.externalId), index$1("oauth_connections_external_id_idx").on(table.externalId)]);
|
|
10616
|
+
const organizationUsers = pgTable("organization_users", {
|
|
10617
|
+
organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
|
10618
|
+
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
10619
|
+
role: text("role").notNull().$type(),
|
|
10620
|
+
status: text("status").notNull().$type().default("active"),
|
|
10621
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10622
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
10623
|
+
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
10624
|
+
}, (table) => [primaryKey({ columns: [table.organizationId, table.userId] }), index("organization_users_user_id_idx").on(table.userId)]);
|
|
10625
|
+
const organizationUsersSqlite = sqliteTable("organization_users", {
|
|
10626
|
+
organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
10627
|
+
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
10628
|
+
role: text$1("role").notNull().$type(),
|
|
10629
|
+
status: text$1("status").notNull().$type().default("active"),
|
|
10630
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10631
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
10632
|
+
deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
|
|
10633
|
+
}, (table) => [primaryKey$1({ columns: [table.organizationId, table.userId] }), index$1("organization_users_user_id_idx").on(table.userId)]);
|
|
10634
|
+
const organizationInvitations = pgTable("organization_invitations", {
|
|
10635
|
+
id: text("id").primaryKey(),
|
|
10636
|
+
organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
|
10637
|
+
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
10638
|
+
email: text("email").notNull(),
|
|
10639
|
+
role: text("role").notNull().$type(),
|
|
10640
|
+
status: text("status").notNull().$type(),
|
|
10641
|
+
invitedByUserId: text("invited_by_user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
10642
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10643
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
10644
|
+
expiresAt: timestamp("expires_at", { withTimezone: true })
|
|
10645
|
+
}, (table) => [
|
|
10646
|
+
index("organization_invitations_user_id_idx").on(table.userId),
|
|
10647
|
+
index("organization_invitations_organization_id_idx").on(table.organizationId),
|
|
10648
|
+
uniqueIndex("organization_invitations_org_user_pending_unique").on(table.organizationId, table.userId).where(sql`${table.status} = 'pending'`)
|
|
10649
|
+
]);
|
|
10650
|
+
const organizationInvitationsSqlite = sqliteTable("organization_invitations", {
|
|
10651
|
+
id: text$1("id").primaryKey(),
|
|
10652
|
+
organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
10653
|
+
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
10654
|
+
email: text$1("email").notNull(),
|
|
10655
|
+
role: text$1("role").notNull().$type(),
|
|
10656
|
+
status: text$1("status").notNull().$type(),
|
|
10657
|
+
invitedByUserId: text$1("invited_by_user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
10658
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10659
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
10660
|
+
expiresAt: integer$1("expires_at", { mode: "timestamp_ms" })
|
|
10661
|
+
}, (table) => [
|
|
10662
|
+
index$1("organization_invitations_user_id_idx").on(table.userId),
|
|
10663
|
+
index$1("organization_invitations_organization_id_idx").on(table.organizationId),
|
|
10664
|
+
uniqueIndex$1("organization_invitations_org_user_pending_unique").on(table.organizationId, table.userId).where(sql`${table.status} = 'pending'`)
|
|
10665
|
+
]);
|
|
10666
|
+
const projectStatusEnum = pgEnum("project_status", [
|
|
10667
|
+
"inactive",
|
|
10668
|
+
"starting",
|
|
10669
|
+
"active",
|
|
10670
|
+
"failed"
|
|
10671
|
+
]);
|
|
10672
|
+
const projects = pgTable("projects", {
|
|
10673
|
+
id: text("id").primaryKey(),
|
|
10674
|
+
organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
|
10675
|
+
name: text("name").notNull(),
|
|
10676
|
+
slug: text("slug").notNull(),
|
|
10677
|
+
description: text("description"),
|
|
10678
|
+
defaultMemberRole: text("default_member_role").notNull().$type().default("builder"),
|
|
10679
|
+
invitePermission: text("invite_permission").notNull().$type().default("admin"),
|
|
10680
|
+
createdByUserId: text("created_by_user_id").references(() => users.id, { onDelete: "set null" }),
|
|
10681
|
+
status: projectStatusEnum("status").notNull(),
|
|
10682
|
+
baseUrl: text("base_url"),
|
|
10683
|
+
runtimeId: text("runtime_id"),
|
|
10684
|
+
activeArtifactId: text("active_artifact_id"),
|
|
10685
|
+
pendingArtifactId: text("pending_artifact_id"),
|
|
10686
|
+
lastError: text("last_error"),
|
|
10687
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10688
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
10689
|
+
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
10690
|
+
}, (table) => [index("projects_organization_id_idx").on(table.organizationId), uniqueIndex("projects_organization_slug_unique").on(table.organizationId, table.slug).where(sql`${table.deletedAt} IS NULL`)]);
|
|
10691
|
+
const projectsSqlite = sqliteTable("projects", {
|
|
10692
|
+
id: text$1("id").primaryKey(),
|
|
10693
|
+
organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
10694
|
+
name: text$1("name").notNull(),
|
|
10695
|
+
slug: text$1("slug").notNull(),
|
|
10696
|
+
description: text$1("description"),
|
|
10697
|
+
defaultMemberRole: text$1("default_member_role").notNull().$type().default("builder"),
|
|
10698
|
+
invitePermission: text$1("invite_permission").notNull().$type().default("admin"),
|
|
10699
|
+
createdByUserId: text$1("created_by_user_id").references(() => usersSqlite.id, { onDelete: "set null" }),
|
|
10700
|
+
status: text$1("status").$type().notNull(),
|
|
10701
|
+
baseUrl: text$1("base_url"),
|
|
10702
|
+
runtimeId: text$1("runtime_id"),
|
|
10703
|
+
activeArtifactId: text$1("active_artifact_id"),
|
|
10704
|
+
pendingArtifactId: text$1("pending_artifact_id"),
|
|
10705
|
+
lastError: text$1("last_error"),
|
|
10706
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10707
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
10708
|
+
deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
|
|
10709
|
+
}, (table) => [index$1("projects_organization_id_idx").on(table.organizationId), uniqueIndex$1("projects_organization_slug_unique").on(table.organizationId, table.slug).where(sql`${table.deletedAt} IS NULL`)]);
|
|
10710
|
+
const projectArtifactStatusEnum = pgEnum("project_artifact_status", ["pending", "ready"]);
|
|
10711
|
+
const projectArtifacts = pgTable("project_artifacts", {
|
|
10712
|
+
id: text("id").primaryKey(),
|
|
10713
|
+
projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
10714
|
+
storageKey: text("storage_key").notNull(),
|
|
10715
|
+
manifestJson: jsonb("manifest_json"),
|
|
10716
|
+
sourceManifestJson: jsonb("source_manifest_json"),
|
|
10717
|
+
version: integer("version").notNull(),
|
|
10718
|
+
createdByUserId: text("created_by_user_id").references(() => users.id, { onDelete: "set null" }),
|
|
10719
|
+
status: projectArtifactStatusEnum("status").notNull(),
|
|
10720
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10721
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10722
|
+
}, (table) => [index("project_artifacts_project_id_idx").on(table.projectId)]);
|
|
10723
|
+
const projectArtifactsSqlite = sqliteTable("project_artifacts", {
|
|
10724
|
+
id: text$1("id").primaryKey(),
|
|
10725
|
+
projectId: text$1("project_id").notNull().references(() => projectsSqlite.id, { onDelete: "cascade" }),
|
|
10726
|
+
storageKey: text$1("storage_key").notNull(),
|
|
10727
|
+
manifestJson: text$1("manifest_json", { mode: "json" }),
|
|
10728
|
+
sourceManifestJson: text$1("source_manifest_json", { mode: "json" }),
|
|
10729
|
+
version: integer$1("version").notNull(),
|
|
10730
|
+
createdByUserId: text$1("created_by_user_id").references(() => usersSqlite.id, { onDelete: "set null" }),
|
|
10731
|
+
status: text$1("status").$type().notNull(),
|
|
10732
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10733
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10734
|
+
}, (table) => [index$1("project_artifacts_project_id_idx").on(table.projectId)]);
|
|
10735
|
+
const projectUsers = pgTable("project_users", {
|
|
10736
|
+
projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
10737
|
+
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
10738
|
+
role: text("role").notNull().$type(),
|
|
10739
|
+
status: text("status").notNull().$type().default("active"),
|
|
10740
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10741
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
10742
|
+
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
10743
|
+
}, (table) => [primaryKey({ columns: [table.projectId, table.userId] }), index("project_users_user_id_idx").on(table.userId)]);
|
|
10744
|
+
const projectUsersSqlite = sqliteTable("project_users", {
|
|
10745
|
+
projectId: text$1("project_id").notNull().references(() => projectsSqlite.id, { onDelete: "cascade" }),
|
|
10746
|
+
userId: text$1("user_id").notNull().references(() => usersSqlite.id, { onDelete: "cascade" }),
|
|
10747
|
+
role: text$1("role").notNull().$type(),
|
|
10748
|
+
status: text$1("status").notNull().$type().default("active"),
|
|
10749
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10750
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
10751
|
+
deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
|
|
10752
|
+
}, (table) => [primaryKey$1({ columns: [table.projectId, table.userId] }), index$1("project_users_user_id_idx").on(table.userId)]);
|
|
10753
|
+
const secretValues = pgTable("secret_values", {
|
|
10754
|
+
id: text("id").primaryKey(),
|
|
10755
|
+
organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
|
10756
|
+
refKind: text("ref_kind").$type().notNull(),
|
|
10757
|
+
refId: text("ref_id").notNull(),
|
|
10758
|
+
field: text("field").$type().notNull(),
|
|
10759
|
+
ciphertext: text("ciphertext").notNull(),
|
|
10760
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
10761
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
10762
|
+
}, (table) => [uniqueIndex("secret_values_ref_unique").on(table.organizationId, table.refKind, table.refId, table.field)]);
|
|
10763
|
+
const secretValuesSqlite = sqliteTable("secret_values", {
|
|
10764
|
+
id: text$1("id").primaryKey(),
|
|
10765
|
+
organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
|
|
10766
|
+
refKind: text$1("ref_kind").$type().notNull(),
|
|
10767
|
+
refId: text$1("ref_id").notNull(),
|
|
10768
|
+
field: text$1("field").$type().notNull(),
|
|
10769
|
+
ciphertext: text$1("ciphertext").notNull(),
|
|
10770
|
+
createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
10771
|
+
updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
10772
|
+
}, (table) => [uniqueIndex$1("secret_values_ref_unique").on(table.organizationId, table.refKind, table.refId, table.field)]);
|
|
10773
|
+
/**
|
|
10774
|
+
* Platform control-plane tables — Postgres (hosted) or SQLite (local dev).
|
|
10775
|
+
*/
|
|
10776
|
+
const tableRegistry = {
|
|
10777
|
+
organizations: {
|
|
10778
|
+
pg: organizations,
|
|
10779
|
+
sqlite: organizationsSqlite
|
|
10780
|
+
},
|
|
10781
|
+
organizationUsers: {
|
|
10782
|
+
pg: organizationUsers,
|
|
10783
|
+
sqlite: organizationUsersSqlite
|
|
10784
|
+
},
|
|
10785
|
+
organizationInvitations: {
|
|
10786
|
+
pg: organizationInvitations,
|
|
10787
|
+
sqlite: organizationInvitationsSqlite
|
|
10788
|
+
},
|
|
10789
|
+
projects: {
|
|
10790
|
+
pg: projects,
|
|
10791
|
+
sqlite: projectsSqlite
|
|
10792
|
+
},
|
|
10793
|
+
projectUsers: {
|
|
10794
|
+
pg: projectUsers,
|
|
10795
|
+
sqlite: projectUsersSqlite
|
|
10796
|
+
},
|
|
10797
|
+
projectArtifacts: {
|
|
10798
|
+
pg: projectArtifacts,
|
|
10799
|
+
sqlite: projectArtifactsSqlite
|
|
10800
|
+
},
|
|
10801
|
+
users: {
|
|
10802
|
+
pg: users,
|
|
10803
|
+
sqlite: usersSqlite
|
|
10804
|
+
},
|
|
10805
|
+
authSessions: {
|
|
10806
|
+
pg: authSessions,
|
|
10807
|
+
sqlite: authSessionsSqlite
|
|
10808
|
+
},
|
|
10809
|
+
authAccounts: {
|
|
10810
|
+
pg: authAccounts,
|
|
10811
|
+
sqlite: authAccountsSqlite
|
|
10812
|
+
},
|
|
10813
|
+
authVerifications: {
|
|
10814
|
+
pg: authVerifications,
|
|
10815
|
+
sqlite: authVerificationsSqlite
|
|
10816
|
+
},
|
|
10817
|
+
authDeviceCodes: {
|
|
10818
|
+
pg: authDeviceCodes,
|
|
10819
|
+
sqlite: authDeviceCodesSqlite
|
|
10820
|
+
},
|
|
10821
|
+
authJwks: {
|
|
10822
|
+
pg: authJwks,
|
|
10823
|
+
sqlite: authJwksSqlite
|
|
10824
|
+
},
|
|
10825
|
+
authApiKeys: {
|
|
10826
|
+
pg: authApiKeys,
|
|
10827
|
+
sqlite: authApiKeysSqlite
|
|
10828
|
+
},
|
|
10829
|
+
apps: {
|
|
10830
|
+
pg: apps,
|
|
10831
|
+
sqlite: appsSqlite
|
|
10832
|
+
},
|
|
10833
|
+
oauthApps: {
|
|
10834
|
+
pg: oauthApps,
|
|
10835
|
+
sqlite: oauthAppsSqlite
|
|
10836
|
+
},
|
|
10837
|
+
oauthConnections: {
|
|
10838
|
+
pg: oauthConnections,
|
|
10839
|
+
sqlite: oauthConnectionsSqlite
|
|
10840
|
+
},
|
|
10841
|
+
mcpOauthClient: {
|
|
10842
|
+
pg: mcpOauthClient,
|
|
10843
|
+
sqlite: mcpOauthClientSqlite
|
|
10844
|
+
},
|
|
10845
|
+
mcpOauthAccessToken: {
|
|
10846
|
+
pg: mcpOauthAccessToken,
|
|
10847
|
+
sqlite: mcpOauthAccessTokenSqlite
|
|
10848
|
+
},
|
|
10849
|
+
mcpOauthConsent: {
|
|
10850
|
+
pg: mcpOauthConsent,
|
|
10851
|
+
sqlite: mcpOauthConsentSqlite
|
|
10852
|
+
},
|
|
10853
|
+
secretValues: {
|
|
10854
|
+
pg: secretValues,
|
|
10855
|
+
sqlite: secretValuesSqlite
|
|
10856
|
+
}
|
|
10857
|
+
};
|
|
10858
|
+
buildPgSchema(tableRegistry);
|
|
10859
|
+
buildSqliteSchema(tableRegistry);
|
|
10860
|
+
new AsyncLocalStorage();
|
|
10861
|
+
new AsyncLocalStorage();
|
|
11193
10862
|
//#endregion
|
|
11194
10863
|
//#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js
|
|
11195
10864
|
var require_identity = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
@@ -17561,246 +17230,1030 @@ var require_parser = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17561
17230
|
} else yield* this.lineEnd(fc);
|
|
17562
17231
|
}
|
|
17563
17232
|
}
|
|
17564
|
-
flowScalar(type) {
|
|
17565
|
-
if (this.onNewLine) {
|
|
17566
|
-
let nl = this.source.indexOf("\n") + 1;
|
|
17567
|
-
while (nl !== 0) {
|
|
17568
|
-
this.onNewLine(this.offset + nl);
|
|
17569
|
-
nl = this.source.indexOf("\n", nl) + 1;
|
|
17570
|
-
}
|
|
17571
|
-
}
|
|
17572
|
-
return {
|
|
17573
|
-
type,
|
|
17574
|
-
offset: this.offset,
|
|
17575
|
-
indent: this.indent,
|
|
17576
|
-
source: this.source
|
|
17577
|
-
};
|
|
17233
|
+
flowScalar(type) {
|
|
17234
|
+
if (this.onNewLine) {
|
|
17235
|
+
let nl = this.source.indexOf("\n") + 1;
|
|
17236
|
+
while (nl !== 0) {
|
|
17237
|
+
this.onNewLine(this.offset + nl);
|
|
17238
|
+
nl = this.source.indexOf("\n", nl) + 1;
|
|
17239
|
+
}
|
|
17240
|
+
}
|
|
17241
|
+
return {
|
|
17242
|
+
type,
|
|
17243
|
+
offset: this.offset,
|
|
17244
|
+
indent: this.indent,
|
|
17245
|
+
source: this.source
|
|
17246
|
+
};
|
|
17247
|
+
}
|
|
17248
|
+
startBlockValue(parent) {
|
|
17249
|
+
switch (this.type) {
|
|
17250
|
+
case "alias":
|
|
17251
|
+
case "scalar":
|
|
17252
|
+
case "single-quoted-scalar":
|
|
17253
|
+
case "double-quoted-scalar": return this.flowScalar(this.type);
|
|
17254
|
+
case "block-scalar-header": return {
|
|
17255
|
+
type: "block-scalar",
|
|
17256
|
+
offset: this.offset,
|
|
17257
|
+
indent: this.indent,
|
|
17258
|
+
props: [this.sourceToken],
|
|
17259
|
+
source: ""
|
|
17260
|
+
};
|
|
17261
|
+
case "flow-map-start":
|
|
17262
|
+
case "flow-seq-start": return {
|
|
17263
|
+
type: "flow-collection",
|
|
17264
|
+
offset: this.offset,
|
|
17265
|
+
indent: this.indent,
|
|
17266
|
+
start: this.sourceToken,
|
|
17267
|
+
items: [],
|
|
17268
|
+
end: []
|
|
17269
|
+
};
|
|
17270
|
+
case "seq-item-ind": return {
|
|
17271
|
+
type: "block-seq",
|
|
17272
|
+
offset: this.offset,
|
|
17273
|
+
indent: this.indent,
|
|
17274
|
+
items: [{ start: [this.sourceToken] }]
|
|
17275
|
+
};
|
|
17276
|
+
case "explicit-key-ind": {
|
|
17277
|
+
this.onKeyLine = true;
|
|
17278
|
+
const start = getFirstKeyStartProps(getPrevProps(parent));
|
|
17279
|
+
start.push(this.sourceToken);
|
|
17280
|
+
return {
|
|
17281
|
+
type: "block-map",
|
|
17282
|
+
offset: this.offset,
|
|
17283
|
+
indent: this.indent,
|
|
17284
|
+
items: [{
|
|
17285
|
+
start,
|
|
17286
|
+
explicitKey: true
|
|
17287
|
+
}]
|
|
17288
|
+
};
|
|
17289
|
+
}
|
|
17290
|
+
case "map-value-ind": {
|
|
17291
|
+
this.onKeyLine = true;
|
|
17292
|
+
const start = getFirstKeyStartProps(getPrevProps(parent));
|
|
17293
|
+
return {
|
|
17294
|
+
type: "block-map",
|
|
17295
|
+
offset: this.offset,
|
|
17296
|
+
indent: this.indent,
|
|
17297
|
+
items: [{
|
|
17298
|
+
start,
|
|
17299
|
+
key: null,
|
|
17300
|
+
sep: [this.sourceToken]
|
|
17301
|
+
}]
|
|
17302
|
+
};
|
|
17303
|
+
}
|
|
17304
|
+
}
|
|
17305
|
+
return null;
|
|
17306
|
+
}
|
|
17307
|
+
atIndentedComment(start, indent) {
|
|
17308
|
+
if (this.type !== "comment") return false;
|
|
17309
|
+
if (this.indent <= indent) return false;
|
|
17310
|
+
return start.every((st) => st.type === "newline" || st.type === "space");
|
|
17311
|
+
}
|
|
17312
|
+
*documentEnd(docEnd) {
|
|
17313
|
+
if (this.type !== "doc-mode") {
|
|
17314
|
+
if (docEnd.end) docEnd.end.push(this.sourceToken);
|
|
17315
|
+
else docEnd.end = [this.sourceToken];
|
|
17316
|
+
if (this.type === "newline") yield* this.pop();
|
|
17317
|
+
}
|
|
17318
|
+
}
|
|
17319
|
+
*lineEnd(token) {
|
|
17320
|
+
switch (this.type) {
|
|
17321
|
+
case "comma":
|
|
17322
|
+
case "doc-start":
|
|
17323
|
+
case "doc-end":
|
|
17324
|
+
case "flow-seq-end":
|
|
17325
|
+
case "flow-map-end":
|
|
17326
|
+
case "map-value-ind":
|
|
17327
|
+
yield* this.pop();
|
|
17328
|
+
yield* this.step();
|
|
17329
|
+
break;
|
|
17330
|
+
case "newline": this.onKeyLine = false;
|
|
17331
|
+
default:
|
|
17332
|
+
if (token.end) token.end.push(this.sourceToken);
|
|
17333
|
+
else token.end = [this.sourceToken];
|
|
17334
|
+
if (this.type === "newline") yield* this.pop();
|
|
17335
|
+
}
|
|
17336
|
+
}
|
|
17337
|
+
};
|
|
17338
|
+
exports.Parser = Parser;
|
|
17339
|
+
}));
|
|
17340
|
+
//#endregion
|
|
17341
|
+
//#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/public-api.js
|
|
17342
|
+
var require_public_api = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17343
|
+
var composer = require_composer();
|
|
17344
|
+
var Document = require_Document();
|
|
17345
|
+
var errors = require_errors();
|
|
17346
|
+
var log = require_log();
|
|
17347
|
+
var identity = require_identity();
|
|
17348
|
+
var lineCounter = require_line_counter();
|
|
17349
|
+
var parser = require_parser();
|
|
17350
|
+
function parseOptions(options) {
|
|
17351
|
+
const prettyErrors = options.prettyErrors !== false;
|
|
17352
|
+
return {
|
|
17353
|
+
lineCounter: options.lineCounter || prettyErrors && new lineCounter.LineCounter() || null,
|
|
17354
|
+
prettyErrors
|
|
17355
|
+
};
|
|
17356
|
+
}
|
|
17357
|
+
/**
|
|
17358
|
+
* Parse the input as a stream of YAML documents.
|
|
17359
|
+
*
|
|
17360
|
+
* Documents should be separated from each other by `...` or `---` marker lines.
|
|
17361
|
+
*
|
|
17362
|
+
* @returns If an empty `docs` array is returned, it will be of type
|
|
17363
|
+
* EmptyStream and contain additional stream information. In
|
|
17364
|
+
* TypeScript, you should use `'empty' in docs` as a type guard for it.
|
|
17365
|
+
*/
|
|
17366
|
+
function parseAllDocuments(source, options = {}) {
|
|
17367
|
+
const { lineCounter, prettyErrors } = parseOptions(options);
|
|
17368
|
+
const parser$1 = new parser.Parser(lineCounter?.addNewLine);
|
|
17369
|
+
const composer$1 = new composer.Composer(options);
|
|
17370
|
+
const docs = Array.from(composer$1.compose(parser$1.parse(source)));
|
|
17371
|
+
if (prettyErrors && lineCounter) for (const doc of docs) {
|
|
17372
|
+
doc.errors.forEach(errors.prettifyError(source, lineCounter));
|
|
17373
|
+
doc.warnings.forEach(errors.prettifyError(source, lineCounter));
|
|
17374
|
+
}
|
|
17375
|
+
if (docs.length > 0) return docs;
|
|
17376
|
+
return Object.assign([], { empty: true }, composer$1.streamInfo());
|
|
17377
|
+
}
|
|
17378
|
+
/** Parse an input string into a single YAML.Document */
|
|
17379
|
+
function parseDocument(source, options = {}) {
|
|
17380
|
+
const { lineCounter, prettyErrors } = parseOptions(options);
|
|
17381
|
+
const parser$1 = new parser.Parser(lineCounter?.addNewLine);
|
|
17382
|
+
const composer$1 = new composer.Composer(options);
|
|
17383
|
+
let doc = null;
|
|
17384
|
+
for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) if (!doc) doc = _doc;
|
|
17385
|
+
else if (doc.options.logLevel !== "silent") {
|
|
17386
|
+
doc.errors.push(new errors.YAMLParseError(_doc.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
|
|
17387
|
+
break;
|
|
17578
17388
|
}
|
|
17579
|
-
|
|
17580
|
-
|
|
17581
|
-
|
|
17582
|
-
|
|
17583
|
-
|
|
17584
|
-
|
|
17585
|
-
|
|
17586
|
-
|
|
17587
|
-
|
|
17588
|
-
|
|
17589
|
-
|
|
17590
|
-
|
|
17591
|
-
|
|
17592
|
-
|
|
17593
|
-
|
|
17594
|
-
|
|
17595
|
-
|
|
17596
|
-
|
|
17597
|
-
|
|
17598
|
-
|
|
17599
|
-
|
|
17389
|
+
if (prettyErrors && lineCounter) {
|
|
17390
|
+
doc.errors.forEach(errors.prettifyError(source, lineCounter));
|
|
17391
|
+
doc.warnings.forEach(errors.prettifyError(source, lineCounter));
|
|
17392
|
+
}
|
|
17393
|
+
return doc;
|
|
17394
|
+
}
|
|
17395
|
+
function parse(src, reviver, options) {
|
|
17396
|
+
let _reviver = void 0;
|
|
17397
|
+
if (typeof reviver === "function") _reviver = reviver;
|
|
17398
|
+
else if (options === void 0 && reviver && typeof reviver === "object") options = reviver;
|
|
17399
|
+
const doc = parseDocument(src, options);
|
|
17400
|
+
if (!doc) return null;
|
|
17401
|
+
doc.warnings.forEach((warning) => log.warn(doc.options.logLevel, warning));
|
|
17402
|
+
if (doc.errors.length > 0) if (doc.options.logLevel !== "silent") throw doc.errors[0];
|
|
17403
|
+
else doc.errors = [];
|
|
17404
|
+
return doc.toJS(Object.assign({ reviver: _reviver }, options));
|
|
17405
|
+
}
|
|
17406
|
+
function stringify(value, replacer, options) {
|
|
17407
|
+
let _replacer = null;
|
|
17408
|
+
if (typeof replacer === "function" || Array.isArray(replacer)) _replacer = replacer;
|
|
17409
|
+
else if (options === void 0 && replacer) options = replacer;
|
|
17410
|
+
if (typeof options === "string") options = options.length;
|
|
17411
|
+
if (typeof options === "number") {
|
|
17412
|
+
const indent = Math.round(options);
|
|
17413
|
+
options = indent < 1 ? void 0 : indent > 8 ? { indent: 8 } : { indent };
|
|
17414
|
+
}
|
|
17415
|
+
if (value === void 0) {
|
|
17416
|
+
const { keepUndefined } = options ?? replacer ?? {};
|
|
17417
|
+
if (!keepUndefined) return void 0;
|
|
17418
|
+
}
|
|
17419
|
+
if (identity.isDocument(value) && !_replacer) return value.toString(options);
|
|
17420
|
+
return new Document.Document(value, _replacer, options).toString(options);
|
|
17421
|
+
}
|
|
17422
|
+
exports.parse = parse;
|
|
17423
|
+
exports.parseAllDocuments = parseAllDocuments;
|
|
17424
|
+
exports.parseDocument = parseDocument;
|
|
17425
|
+
exports.stringify = stringify;
|
|
17426
|
+
}));
|
|
17427
|
+
(/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17428
|
+
var composer = require_composer();
|
|
17429
|
+
var Document = require_Document();
|
|
17430
|
+
var Schema = require_Schema();
|
|
17431
|
+
var errors = require_errors();
|
|
17432
|
+
var Alias = require_Alias();
|
|
17433
|
+
var identity = require_identity();
|
|
17434
|
+
var Pair = require_Pair();
|
|
17435
|
+
var Scalar = require_Scalar();
|
|
17436
|
+
var YAMLMap = require_YAMLMap();
|
|
17437
|
+
var YAMLSeq = require_YAMLSeq();
|
|
17438
|
+
require_cst();
|
|
17439
|
+
var lexer = require_lexer();
|
|
17440
|
+
var lineCounter = require_line_counter();
|
|
17441
|
+
var parser = require_parser();
|
|
17442
|
+
var publicApi = require_public_api();
|
|
17443
|
+
var visit = require_visit();
|
|
17444
|
+
exports.Composer = composer.Composer;
|
|
17445
|
+
exports.Document = Document.Document;
|
|
17446
|
+
exports.Schema = Schema.Schema;
|
|
17447
|
+
exports.YAMLError = errors.YAMLError;
|
|
17448
|
+
exports.YAMLParseError = errors.YAMLParseError;
|
|
17449
|
+
exports.YAMLWarning = errors.YAMLWarning;
|
|
17450
|
+
exports.Alias = Alias.Alias;
|
|
17451
|
+
exports.isAlias = identity.isAlias;
|
|
17452
|
+
exports.isCollection = identity.isCollection;
|
|
17453
|
+
exports.isDocument = identity.isDocument;
|
|
17454
|
+
exports.isMap = identity.isMap;
|
|
17455
|
+
exports.isNode = identity.isNode;
|
|
17456
|
+
exports.isPair = identity.isPair;
|
|
17457
|
+
exports.isScalar = identity.isScalar;
|
|
17458
|
+
exports.isSeq = identity.isSeq;
|
|
17459
|
+
exports.Pair = Pair.Pair;
|
|
17460
|
+
exports.Scalar = Scalar.Scalar;
|
|
17461
|
+
exports.YAMLMap = YAMLMap.YAMLMap;
|
|
17462
|
+
exports.YAMLSeq = YAMLSeq.YAMLSeq;
|
|
17463
|
+
exports.Lexer = lexer.Lexer;
|
|
17464
|
+
exports.LineCounter = lineCounter.LineCounter;
|
|
17465
|
+
exports.Parser = parser.Parser;
|
|
17466
|
+
exports.parse = publicApi.parse;
|
|
17467
|
+
exports.parseAllDocuments = publicApi.parseAllDocuments;
|
|
17468
|
+
exports.parseDocument = publicApi.parseDocument;
|
|
17469
|
+
exports.stringify = publicApi.stringify;
|
|
17470
|
+
exports.visit = visit.visit;
|
|
17471
|
+
exports.visitAsync = visit.visitAsync;
|
|
17472
|
+
})))();
|
|
17473
|
+
//#endregion
|
|
17474
|
+
//#region ../../packages/memory/dist/index.mjs
|
|
17475
|
+
const memoryPathSchema = string().describe("Relative path under the memory dir (e.g. MEMORY.md, USER.md, archive/note.md).");
|
|
17476
|
+
const searchScopeSchema = _enum([
|
|
17477
|
+
"archive",
|
|
17478
|
+
"sessions",
|
|
17479
|
+
"all"
|
|
17480
|
+
]).describe("Where to look: all (default) = archive/*.md plus every saved session transcript across all past chats; archive = long-form notes only; sessions = all past session transcripts only. USER.md and MEMORY.md are in the system snapshot — use read for those.");
|
|
17481
|
+
const searchQuerySchema = string().describe("Keywords to find across archive notes and/or all past session transcripts. Plain words, case-insensitive; multiple words match if ANY word appears. Use when the user references an earlier chat or prior decision. Returns ranked snippets — use read on a hit path for the full file.");
|
|
17482
|
+
object({
|
|
17483
|
+
action: _enum([
|
|
17484
|
+
"list",
|
|
17485
|
+
"read",
|
|
17486
|
+
"write",
|
|
17487
|
+
"edit",
|
|
17488
|
+
"search"
|
|
17489
|
+
]).describe("list: archive/*.md filenames; read: { path }; write: { path, content }; edit: { path, oldText, newText }; search: { query, scope?, limit?, full? }."),
|
|
17490
|
+
path: memoryPathSchema.optional(),
|
|
17491
|
+
content: string().describe("Full file content (write).").optional(),
|
|
17492
|
+
oldText: string().describe("Exact text to replace, first match (edit).").optional(),
|
|
17493
|
+
newText: string().describe("Replacement text; empty string deletes oldText (edit).").optional(),
|
|
17494
|
+
query: searchQuerySchema.optional(),
|
|
17495
|
+
scope: searchScopeSchema.optional(),
|
|
17496
|
+
limit: number().int().min(1).max(50).optional(),
|
|
17497
|
+
full: boolean$1().describe("When true, return complete archive note files for archive hits, ignored for session hits (search).").optional()
|
|
17498
|
+
});
|
|
17499
|
+
new AsyncLocalStorage();
|
|
17500
|
+
[
|
|
17501
|
+
"You are an expert chat title generator.",
|
|
17502
|
+
"",
|
|
17503
|
+
"Given the conversation so far (initial user message), generate a short, clear, and natural title (max 6-8 words) that captures the main topic or goal.",
|
|
17504
|
+
"",
|
|
17505
|
+
"Rules:",
|
|
17506
|
+
"- Be specific and descriptive; avoid vague titles like \"Conversation\" or \"Question\"",
|
|
17507
|
+
"- Prefer action-oriented or outcome-focused phrasing when possible",
|
|
17508
|
+
"- Use title case",
|
|
17509
|
+
"- Keep it under 65 characters when possible",
|
|
17510
|
+
"- Do not use quotes or emojis",
|
|
17511
|
+
"- Return ONLY the title, nothing else",
|
|
17512
|
+
"",
|
|
17513
|
+
"Examples:",
|
|
17514
|
+
"",
|
|
17515
|
+
"User: How do I set up a new Next.js project with TypeScript?",
|
|
17516
|
+
"→ Setting Up Next.js Project with TypeScript",
|
|
17517
|
+
"",
|
|
17518
|
+
"User: Help me debug this React hook that's causing infinite re-renders. Here's the code...",
|
|
17519
|
+
"→ Debugging Infinite Re-render in React Hook",
|
|
17520
|
+
"",
|
|
17521
|
+
"User: Write a cold email sequence for fundraising from YC alums",
|
|
17522
|
+
"→ YC Alumni Fundraising Cold Email Sequence"
|
|
17523
|
+
].join("\n");
|
|
17524
|
+
const STATIC_MODEL_IDS = new Set([
|
|
17525
|
+
"alibaba/qwen-3-14b",
|
|
17526
|
+
"alibaba/qwen-3-235b",
|
|
17527
|
+
"alibaba/qwen-3-30b",
|
|
17528
|
+
"alibaba/qwen-3-32b",
|
|
17529
|
+
"alibaba/qwen-3.6-max-preview",
|
|
17530
|
+
"alibaba/qwen3-235b-a22b-thinking",
|
|
17531
|
+
"alibaba/qwen3-coder",
|
|
17532
|
+
"alibaba/qwen3-coder-30b-a3b",
|
|
17533
|
+
"alibaba/qwen3-coder-next",
|
|
17534
|
+
"alibaba/qwen3-coder-plus",
|
|
17535
|
+
"alibaba/qwen3-embedding-0.6b",
|
|
17536
|
+
"alibaba/qwen3-embedding-4b",
|
|
17537
|
+
"alibaba/qwen3-embedding-8b",
|
|
17538
|
+
"alibaba/qwen3-max",
|
|
17539
|
+
"alibaba/qwen3-max-preview",
|
|
17540
|
+
"alibaba/qwen3-max-thinking",
|
|
17541
|
+
"alibaba/qwen3-next-80b-a3b-instruct",
|
|
17542
|
+
"alibaba/qwen3-next-80b-a3b-thinking",
|
|
17543
|
+
"alibaba/qwen3-vl-235b-a22b-instruct",
|
|
17544
|
+
"alibaba/qwen3-vl-instruct",
|
|
17545
|
+
"alibaba/qwen3-vl-thinking",
|
|
17546
|
+
"alibaba/qwen3.5-flash",
|
|
17547
|
+
"alibaba/qwen3.5-plus",
|
|
17548
|
+
"alibaba/qwen3.6-27b",
|
|
17549
|
+
"alibaba/qwen3.6-plus",
|
|
17550
|
+
"alibaba/qwen3.7-max",
|
|
17551
|
+
"alibaba/qwen3.7-plus",
|
|
17552
|
+
"alibaba/wan-v2.5-t2v-preview",
|
|
17553
|
+
"alibaba/wan-v2.6-i2v",
|
|
17554
|
+
"alibaba/wan-v2.6-i2v-flash",
|
|
17555
|
+
"alibaba/wan-v2.6-r2v",
|
|
17556
|
+
"alibaba/wan-v2.6-r2v-flash",
|
|
17557
|
+
"alibaba/wan-v2.6-t2v",
|
|
17558
|
+
"amazon/nova-2-lite",
|
|
17559
|
+
"amazon/nova-lite",
|
|
17560
|
+
"amazon/nova-micro",
|
|
17561
|
+
"amazon/nova-pro",
|
|
17562
|
+
"amazon/titan-embed-text-v2",
|
|
17563
|
+
"anthropic/claude-3-haiku",
|
|
17564
|
+
"anthropic/claude-3.5-haiku",
|
|
17565
|
+
"anthropic/claude-haiku-4.5",
|
|
17566
|
+
"anthropic/claude-opus-4",
|
|
17567
|
+
"anthropic/claude-opus-4.1",
|
|
17568
|
+
"anthropic/claude-opus-4.5",
|
|
17569
|
+
"anthropic/claude-opus-4.6",
|
|
17570
|
+
"anthropic/claude-opus-4.7",
|
|
17571
|
+
"anthropic/claude-opus-4.8",
|
|
17572
|
+
"anthropic/claude-sonnet-4",
|
|
17573
|
+
"anthropic/claude-sonnet-4.5",
|
|
17574
|
+
"anthropic/claude-sonnet-4.6",
|
|
17575
|
+
"arcee-ai/trinity-large-preview",
|
|
17576
|
+
"arcee-ai/trinity-large-thinking",
|
|
17577
|
+
"arcee-ai/trinity-mini",
|
|
17578
|
+
"bfl/flux-2-flex",
|
|
17579
|
+
"bfl/flux-2-klein-4b",
|
|
17580
|
+
"bfl/flux-2-klein-9b",
|
|
17581
|
+
"bfl/flux-2-max",
|
|
17582
|
+
"bfl/flux-2-pro",
|
|
17583
|
+
"bfl/flux-kontext-max",
|
|
17584
|
+
"bfl/flux-kontext-pro",
|
|
17585
|
+
"bfl/flux-pro-1.0-fill",
|
|
17586
|
+
"bfl/flux-pro-1.1",
|
|
17587
|
+
"bfl/flux-pro-1.1-ultra",
|
|
17588
|
+
"bytedance/seed-1.6",
|
|
17589
|
+
"bytedance/seed-1.8",
|
|
17590
|
+
"bytedance/seedance-2.0",
|
|
17591
|
+
"bytedance/seedance-2.0-fast",
|
|
17592
|
+
"bytedance/seedance-v1.0-pro",
|
|
17593
|
+
"bytedance/seedance-v1.0-pro-fast",
|
|
17594
|
+
"bytedance/seedance-v1.5-pro",
|
|
17595
|
+
"bytedance/seedream-4.0",
|
|
17596
|
+
"bytedance/seedream-4.5",
|
|
17597
|
+
"bytedance/seedream-5.0-lite",
|
|
17598
|
+
"cohere/command-a",
|
|
17599
|
+
"cohere/embed-v4.0",
|
|
17600
|
+
"cohere/rerank-v3.5",
|
|
17601
|
+
"cohere/rerank-v4-fast",
|
|
17602
|
+
"cohere/rerank-v4-pro",
|
|
17603
|
+
"deepseek/deepseek-r1",
|
|
17604
|
+
"deepseek/deepseek-v3",
|
|
17605
|
+
"deepseek/deepseek-v3.1",
|
|
17606
|
+
"deepseek/deepseek-v3.1-terminus",
|
|
17607
|
+
"deepseek/deepseek-v3.2",
|
|
17608
|
+
"deepseek/deepseek-v3.2-thinking",
|
|
17609
|
+
"deepseek/deepseek-v4-flash",
|
|
17610
|
+
"deepseek/deepseek-v4-pro",
|
|
17611
|
+
"google/gemini-2.5-flash",
|
|
17612
|
+
"google/gemini-2.5-flash-image",
|
|
17613
|
+
"google/gemini-2.5-flash-lite",
|
|
17614
|
+
"google/gemini-2.5-pro",
|
|
17615
|
+
"google/gemini-3-flash",
|
|
17616
|
+
"google/gemini-3-pro-image",
|
|
17617
|
+
"google/gemini-3-pro-preview",
|
|
17618
|
+
"google/gemini-3.1-flash-image",
|
|
17619
|
+
"google/gemini-3.1-flash-image-preview",
|
|
17620
|
+
"google/gemini-3.1-flash-lite",
|
|
17621
|
+
"google/gemini-3.1-flash-lite-image",
|
|
17622
|
+
"google/gemini-3.1-flash-lite-preview",
|
|
17623
|
+
"google/gemini-3.1-pro-preview",
|
|
17624
|
+
"google/gemini-3.5-flash",
|
|
17625
|
+
"google/gemini-embedding-001",
|
|
17626
|
+
"google/gemini-embedding-2",
|
|
17627
|
+
"google/gemma-4-26b-a4b-it",
|
|
17628
|
+
"google/gemma-4-31b-it",
|
|
17629
|
+
"google/imagen-4.0-fast-generate-001",
|
|
17630
|
+
"google/imagen-4.0-generate-001",
|
|
17631
|
+
"google/imagen-4.0-ultra-generate-001",
|
|
17632
|
+
"google/text-embedding-005",
|
|
17633
|
+
"google/text-multilingual-embedding-002",
|
|
17634
|
+
"google/veo-3.0-fast-generate-001",
|
|
17635
|
+
"google/veo-3.0-generate-001",
|
|
17636
|
+
"google/veo-3.1-fast-generate-001",
|
|
17637
|
+
"google/veo-3.1-generate-001",
|
|
17638
|
+
"inception/mercury-2",
|
|
17639
|
+
"inception/mercury-coder-small",
|
|
17640
|
+
"interfaze/interfaze-beta",
|
|
17641
|
+
"klingai/kling-v2.5-turbo-i2v",
|
|
17642
|
+
"klingai/kling-v2.5-turbo-t2v",
|
|
17643
|
+
"klingai/kling-v2.6-i2v",
|
|
17644
|
+
"klingai/kling-v2.6-motion-control",
|
|
17645
|
+
"klingai/kling-v2.6-t2v",
|
|
17646
|
+
"klingai/kling-v3.0-i2v",
|
|
17647
|
+
"klingai/kling-v3.0-motion-control",
|
|
17648
|
+
"klingai/kling-v3.0-t2v",
|
|
17649
|
+
"kwaipilot/kat-coder-pro-v1",
|
|
17650
|
+
"kwaipilot/kat-coder-pro-v2",
|
|
17651
|
+
"meituan/longcat-flash-chat",
|
|
17652
|
+
"meituan/longcat-flash-thinking-2601",
|
|
17653
|
+
"meta/llama-3.1-70b",
|
|
17654
|
+
"meta/llama-3.1-8b",
|
|
17655
|
+
"meta/llama-3.2-11b",
|
|
17656
|
+
"meta/llama-3.2-1b",
|
|
17657
|
+
"meta/llama-3.2-3b",
|
|
17658
|
+
"meta/llama-3.2-90b",
|
|
17659
|
+
"meta/llama-3.3-70b",
|
|
17660
|
+
"meta/llama-4-maverick",
|
|
17661
|
+
"meta/llama-4-scout",
|
|
17662
|
+
"minimax/minimax-m2",
|
|
17663
|
+
"minimax/minimax-m2.1",
|
|
17664
|
+
"minimax/minimax-m2.1-lightning",
|
|
17665
|
+
"minimax/minimax-m2.5",
|
|
17666
|
+
"minimax/minimax-m2.5-highspeed",
|
|
17667
|
+
"minimax/minimax-m2.7",
|
|
17668
|
+
"minimax/minimax-m2.7-highspeed",
|
|
17669
|
+
"minimax/minimax-m3",
|
|
17670
|
+
"mistral/codestral",
|
|
17671
|
+
"mistral/codestral-embed",
|
|
17672
|
+
"mistral/devstral-2",
|
|
17673
|
+
"mistral/devstral-small",
|
|
17674
|
+
"mistral/devstral-small-2",
|
|
17675
|
+
"mistral/magistral-medium",
|
|
17676
|
+
"mistral/magistral-small",
|
|
17677
|
+
"mistral/ministral-14b",
|
|
17678
|
+
"mistral/ministral-3b",
|
|
17679
|
+
"mistral/ministral-8b",
|
|
17680
|
+
"mistral/mistral-embed",
|
|
17681
|
+
"mistral/mistral-large-3",
|
|
17682
|
+
"mistral/mistral-medium",
|
|
17683
|
+
"mistral/mistral-medium-3.5",
|
|
17684
|
+
"mistral/mistral-nemo",
|
|
17685
|
+
"mistral/mistral-small",
|
|
17686
|
+
"mistral/pixtral-12b",
|
|
17687
|
+
"mistral/pixtral-large",
|
|
17688
|
+
"moonshotai/kimi-k2",
|
|
17689
|
+
"moonshotai/kimi-k2-thinking",
|
|
17690
|
+
"moonshotai/kimi-k2.5",
|
|
17691
|
+
"moonshotai/kimi-k2.6",
|
|
17692
|
+
"moonshotai/kimi-k2.7-code",
|
|
17693
|
+
"moonshotai/kimi-k2.7-code-highspeed",
|
|
17694
|
+
"morph/morph-v3-fast",
|
|
17695
|
+
"morph/morph-v3-large",
|
|
17696
|
+
"nvidia/nemotron-3-nano-30b-a3b",
|
|
17697
|
+
"nvidia/nemotron-3-super-120b-a12b",
|
|
17698
|
+
"nvidia/nemotron-3-ultra-550b-a55b",
|
|
17699
|
+
"nvidia/nemotron-nano-12b-v2-vl",
|
|
17700
|
+
"nvidia/nemotron-nano-9b-v2",
|
|
17701
|
+
"openai/gpt-3.5-turbo",
|
|
17702
|
+
"openai/gpt-3.5-turbo-instruct",
|
|
17703
|
+
"openai/gpt-4-turbo",
|
|
17704
|
+
"openai/gpt-4.1",
|
|
17705
|
+
"openai/gpt-4.1-mini",
|
|
17706
|
+
"openai/gpt-4.1-nano",
|
|
17707
|
+
"openai/gpt-4o",
|
|
17708
|
+
"openai/gpt-4o-mini",
|
|
17709
|
+
"openai/gpt-4o-mini-search-preview",
|
|
17710
|
+
"openai/gpt-4o-mini-transcribe",
|
|
17711
|
+
"openai/gpt-4o-transcribe",
|
|
17712
|
+
"openai/gpt-5",
|
|
17713
|
+
"openai/gpt-5-chat",
|
|
17714
|
+
"openai/gpt-5-codex",
|
|
17715
|
+
"openai/gpt-5-mini",
|
|
17716
|
+
"openai/gpt-5-nano",
|
|
17717
|
+
"openai/gpt-5-pro",
|
|
17718
|
+
"openai/gpt-5.1-codex",
|
|
17719
|
+
"openai/gpt-5.1-codex-max",
|
|
17720
|
+
"openai/gpt-5.1-codex-mini",
|
|
17721
|
+
"openai/gpt-5.1-instant",
|
|
17722
|
+
"openai/gpt-5.1-thinking",
|
|
17723
|
+
"openai/gpt-5.2",
|
|
17724
|
+
"openai/gpt-5.2-chat",
|
|
17725
|
+
"openai/gpt-5.2-codex",
|
|
17726
|
+
"openai/gpt-5.2-pro",
|
|
17727
|
+
"openai/gpt-5.3-chat",
|
|
17728
|
+
"openai/gpt-5.3-codex",
|
|
17729
|
+
"openai/gpt-5.4",
|
|
17730
|
+
"openai/gpt-5.4-mini",
|
|
17731
|
+
"openai/gpt-5.4-nano",
|
|
17732
|
+
"openai/gpt-5.4-pro",
|
|
17733
|
+
"openai/gpt-5.5",
|
|
17734
|
+
"openai/gpt-5.5-pro",
|
|
17735
|
+
"openai/gpt-image-1",
|
|
17736
|
+
"openai/gpt-image-1-mini",
|
|
17737
|
+
"openai/gpt-image-1.5",
|
|
17738
|
+
"openai/gpt-image-2",
|
|
17739
|
+
"openai/gpt-oss-120b",
|
|
17740
|
+
"openai/gpt-oss-20b",
|
|
17741
|
+
"openai/gpt-oss-safeguard-20b",
|
|
17742
|
+
"openai/gpt-realtime-1.5",
|
|
17743
|
+
"openai/gpt-realtime-2",
|
|
17744
|
+
"openai/gpt-realtime-mini",
|
|
17745
|
+
"openai/o1",
|
|
17746
|
+
"openai/o3",
|
|
17747
|
+
"openai/o3-deep-research",
|
|
17748
|
+
"openai/o3-mini",
|
|
17749
|
+
"openai/o3-pro",
|
|
17750
|
+
"openai/o4-mini",
|
|
17751
|
+
"openai/text-embedding-3-large",
|
|
17752
|
+
"openai/text-embedding-3-small",
|
|
17753
|
+
"openai/text-embedding-ada-002",
|
|
17754
|
+
"openai/tts-1",
|
|
17755
|
+
"openai/tts-1-hd",
|
|
17756
|
+
"openai/whisper-1",
|
|
17757
|
+
"perplexity/sonar",
|
|
17758
|
+
"perplexity/sonar-pro",
|
|
17759
|
+
"perplexity/sonar-reasoning-pro",
|
|
17760
|
+
"prodia/flux-fast-schnell",
|
|
17761
|
+
"quiverai/arrow-1.1",
|
|
17762
|
+
"recraft/recraft-v2",
|
|
17763
|
+
"recraft/recraft-v3",
|
|
17764
|
+
"recraft/recraft-v4",
|
|
17765
|
+
"recraft/recraft-v4-pro",
|
|
17766
|
+
"recraft/recraft-v4.1",
|
|
17767
|
+
"recraft/recraft-v4.1-pro",
|
|
17768
|
+
"recraft/recraft-v4.1-utility",
|
|
17769
|
+
"recraft/recraft-v4.1-utility-pro",
|
|
17770
|
+
"sakana/fugu-ultra",
|
|
17771
|
+
"stepfun/step-3.5-flash",
|
|
17772
|
+
"stepfun/step-3.7-flash",
|
|
17773
|
+
"voyage/rerank-2.5",
|
|
17774
|
+
"voyage/rerank-2.5-lite",
|
|
17775
|
+
"voyage/voyage-3-large",
|
|
17776
|
+
"voyage/voyage-3.5",
|
|
17777
|
+
"voyage/voyage-3.5-lite",
|
|
17778
|
+
"voyage/voyage-4",
|
|
17779
|
+
"voyage/voyage-4-large",
|
|
17780
|
+
"voyage/voyage-4-lite",
|
|
17781
|
+
"voyage/voyage-code-2",
|
|
17782
|
+
"voyage/voyage-code-3",
|
|
17783
|
+
"voyage/voyage-finance-2",
|
|
17784
|
+
"voyage/voyage-law-2",
|
|
17785
|
+
"xai/grok-4.1-fast-non-reasoning",
|
|
17786
|
+
"xai/grok-4.1-fast-reasoning",
|
|
17787
|
+
"xai/grok-4.20-multi-agent",
|
|
17788
|
+
"xai/grok-4.20-multi-agent-beta",
|
|
17789
|
+
"xai/grok-4.20-non-reasoning",
|
|
17790
|
+
"xai/grok-4.20-non-reasoning-beta",
|
|
17791
|
+
"xai/grok-4.20-reasoning",
|
|
17792
|
+
"xai/grok-4.20-reasoning-beta",
|
|
17793
|
+
"xai/grok-4.3",
|
|
17794
|
+
"xai/grok-build-0.1",
|
|
17795
|
+
"xai/grok-imagine-image",
|
|
17796
|
+
"xai/grok-imagine-video",
|
|
17797
|
+
"xai/grok-imagine-video-1.5",
|
|
17798
|
+
"xai/grok-imagine-video-1.5-preview",
|
|
17799
|
+
"xai/grok-stt",
|
|
17800
|
+
"xai/grok-tts",
|
|
17801
|
+
"xai/grok-voice-think-fast-1.0",
|
|
17802
|
+
"xiaomi/mimo-v2-flash",
|
|
17803
|
+
"xiaomi/mimo-v2-pro",
|
|
17804
|
+
"xiaomi/mimo-v2.5",
|
|
17805
|
+
"xiaomi/mimo-v2.5-pro",
|
|
17806
|
+
"zai/glm-4.5",
|
|
17807
|
+
"zai/glm-4.5-air",
|
|
17808
|
+
"zai/glm-4.5v",
|
|
17809
|
+
"zai/glm-4.6",
|
|
17810
|
+
"zai/glm-4.6v",
|
|
17811
|
+
"zai/glm-4.6v-flash",
|
|
17812
|
+
"zai/glm-4.7",
|
|
17813
|
+
"zai/glm-4.7-flash",
|
|
17814
|
+
"zai/glm-4.7-flashx",
|
|
17815
|
+
"zai/glm-5",
|
|
17816
|
+
"zai/glm-5-turbo",
|
|
17817
|
+
"zai/glm-5.1",
|
|
17818
|
+
"zai/glm-5.2",
|
|
17819
|
+
"zai/glm-5.2-fast",
|
|
17820
|
+
"zai/glm-5v-turbo"
|
|
17821
|
+
]);
|
|
17822
|
+
let cachedModelIds;
|
|
17823
|
+
let pendingModelIds;
|
|
17824
|
+
function resolvePlatformOriginForModelCatalog() {
|
|
17825
|
+
const fromKeystroke = process.env.KEYSTROKE_PLATFORM_URL?.trim();
|
|
17826
|
+
if (fromKeystroke) return fromKeystroke.replace(/\/+$/, "");
|
|
17827
|
+
const fromPlatform = process.env.PLATFORM_URL?.trim();
|
|
17828
|
+
if (fromPlatform) return fromPlatform.replace(/\/+$/, "");
|
|
17829
|
+
return DEFAULT_CLOUD_PLATFORM_ORIGIN;
|
|
17830
|
+
}
|
|
17831
|
+
async function fetchPublicModelIds() {
|
|
17832
|
+
if (cachedModelIds) return cachedModelIds;
|
|
17833
|
+
if (pendingModelIds) return pendingModelIds;
|
|
17834
|
+
const platformOrigin = resolvePlatformOriginForModelCatalog();
|
|
17835
|
+
pendingModelIds = (async () => {
|
|
17836
|
+
try {
|
|
17837
|
+
const response = await fetch(`${platformOrigin}/api/public/models`, { headers: { accept: "application/json" } });
|
|
17838
|
+
if (!response.ok) throw new Error(`Failed to fetch public model catalog (${response.status})`);
|
|
17839
|
+
const parsed = PublicModelsResponseSchema.safeParse(await response.json());
|
|
17840
|
+
if (!parsed.success || parsed.data.models.length === 0) throw new Error("Public model catalog response had no models");
|
|
17841
|
+
cachedModelIds = new Set(parsed.data.models);
|
|
17842
|
+
return cachedModelIds;
|
|
17843
|
+
} catch (error) {
|
|
17844
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
17845
|
+
console.warn(`Skipping agent model validation: ${message}`);
|
|
17846
|
+
return;
|
|
17847
|
+
} finally {
|
|
17848
|
+
pendingModelIds = void 0;
|
|
17849
|
+
}
|
|
17850
|
+
})();
|
|
17851
|
+
return pendingModelIds;
|
|
17852
|
+
}
|
|
17853
|
+
/**
|
|
17854
|
+
* Fail when any model id is unknown. Checks the committed catalog first (fast,
|
|
17855
|
+
* offline) and only fetches the live catalog to confirm misses — so newly added
|
|
17856
|
+
* gateway models still validate without a per-build network round-trip.
|
|
17857
|
+
*/
|
|
17858
|
+
async function validateAgentModelIds(modelIds) {
|
|
17859
|
+
const missingFromStatic = [...new Set(modelIds)].filter((id) => !STATIC_MODEL_IDS.has(id));
|
|
17860
|
+
if (missingFromStatic.length === 0) return;
|
|
17861
|
+
const live = await fetchPublicModelIds();
|
|
17862
|
+
if (!live) return;
|
|
17863
|
+
const unknown = missingFromStatic.filter((id) => !live.has(id));
|
|
17864
|
+
if (unknown.length === 0) return;
|
|
17865
|
+
throw new Error(unknown.length === 1 ? `Unknown gateway model: ${unknown[0]}` : `Unknown gateway models: ${unknown.join(", ")}`);
|
|
17866
|
+
}
|
|
17867
|
+
//#endregion
|
|
17868
|
+
//#region ../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/utils.js
|
|
17869
|
+
function extractDateElements(date) {
|
|
17870
|
+
return {
|
|
17871
|
+
second: date.getSeconds(),
|
|
17872
|
+
minute: date.getMinutes(),
|
|
17873
|
+
hour: date.getHours(),
|
|
17874
|
+
day: date.getDate(),
|
|
17875
|
+
month: date.getMonth(),
|
|
17876
|
+
weekday: date.getDay(),
|
|
17877
|
+
year: date.getFullYear()
|
|
17878
|
+
};
|
|
17879
|
+
}
|
|
17880
|
+
function getDaysInMonth(year, month) {
|
|
17881
|
+
return new Date(year, month + 1, 0).getDate();
|
|
17882
|
+
}
|
|
17883
|
+
function getDaysBetweenWeekdays(weekday1, weekday2) {
|
|
17884
|
+
if (weekday1 <= weekday2) return weekday2 - weekday1;
|
|
17885
|
+
return 6 - weekday1 + weekday2 + 1;
|
|
17886
|
+
}
|
|
17887
|
+
//#endregion
|
|
17888
|
+
//#region ../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.js
|
|
17889
|
+
var Cron = class {
|
|
17890
|
+
constructor({ seconds, minutes, hours, days, months, weekdays }) {
|
|
17891
|
+
if (!seconds || seconds.size === 0) throw new Error("There must be at least one allowed second.");
|
|
17892
|
+
if (!minutes || minutes.size === 0) throw new Error("There must be at least one allowed minute.");
|
|
17893
|
+
if (!hours || hours.size === 0) throw new Error("There must be at least one allowed hour.");
|
|
17894
|
+
if (!months || months.size === 0) throw new Error("There must be at least one allowed month.");
|
|
17895
|
+
if ((!weekdays || weekdays.size === 0) && (!days || days.size === 0)) throw new Error("There must be at least one allowed day or weekday.");
|
|
17896
|
+
this.seconds = Array.from(seconds).sort((a, b) => a - b);
|
|
17897
|
+
this.minutes = Array.from(minutes).sort((a, b) => a - b);
|
|
17898
|
+
this.hours = Array.from(hours).sort((a, b) => a - b);
|
|
17899
|
+
this.days = Array.from(days).sort((a, b) => a - b);
|
|
17900
|
+
this.months = Array.from(months).sort((a, b) => a - b);
|
|
17901
|
+
this.weekdays = Array.from(weekdays).sort((a, b) => a - b);
|
|
17902
|
+
const validateData = (name, data, constraint) => {
|
|
17903
|
+
if (data.some((x) => typeof x !== "number" || x % 1 !== 0 || x < constraint.min || x > constraint.max)) throw new Error(`${name} must only consist of integers which are within the range of ${constraint.min} and ${constraint.max}`);
|
|
17904
|
+
};
|
|
17905
|
+
validateData("seconds", this.seconds, {
|
|
17906
|
+
min: 0,
|
|
17907
|
+
max: 59
|
|
17908
|
+
});
|
|
17909
|
+
validateData("minutes", this.minutes, {
|
|
17910
|
+
min: 0,
|
|
17911
|
+
max: 59
|
|
17912
|
+
});
|
|
17913
|
+
validateData("hours", this.hours, {
|
|
17914
|
+
min: 0,
|
|
17915
|
+
max: 23
|
|
17916
|
+
});
|
|
17917
|
+
validateData("days", this.days, {
|
|
17918
|
+
min: 1,
|
|
17919
|
+
max: 31
|
|
17920
|
+
});
|
|
17921
|
+
validateData("months", this.months, {
|
|
17922
|
+
min: 0,
|
|
17923
|
+
max: 11
|
|
17924
|
+
});
|
|
17925
|
+
validateData("weekdays", this.weekdays, {
|
|
17926
|
+
min: 0,
|
|
17927
|
+
max: 6
|
|
17928
|
+
});
|
|
17929
|
+
this.reversed = {
|
|
17930
|
+
seconds: this.seconds.map((x) => x).reverse(),
|
|
17931
|
+
minutes: this.minutes.map((x) => x).reverse(),
|
|
17932
|
+
hours: this.hours.map((x) => x).reverse(),
|
|
17933
|
+
days: this.days.map((x) => x).reverse(),
|
|
17934
|
+
months: this.months.map((x) => x).reverse(),
|
|
17935
|
+
weekdays: this.weekdays.map((x) => x).reverse()
|
|
17936
|
+
};
|
|
17937
|
+
}
|
|
17938
|
+
/**
|
|
17939
|
+
* Find the next or previous hour, starting from the given start hour that matches the hour constraint.
|
|
17940
|
+
* startHour itself might also be allowed.
|
|
17941
|
+
*/
|
|
17942
|
+
findAllowedHour(dir, startHour) {
|
|
17943
|
+
return dir === "next" ? this.hours.find((x) => x >= startHour) : this.reversed.hours.find((x) => x <= startHour);
|
|
17944
|
+
}
|
|
17945
|
+
/**
|
|
17946
|
+
* Find the next or previous minute, starting from the given start minute that matches the minute constraint.
|
|
17947
|
+
* startMinute itself might also be allowed.
|
|
17948
|
+
*/
|
|
17949
|
+
findAllowedMinute(dir, startMinute) {
|
|
17950
|
+
return dir === "next" ? this.minutes.find((x) => x >= startMinute) : this.reversed.minutes.find((x) => x <= startMinute);
|
|
17951
|
+
}
|
|
17952
|
+
/**
|
|
17953
|
+
* Find the next or previous second, starting from the given start second that matches the second constraint.
|
|
17954
|
+
* startSecond itself IS NOT allowed.
|
|
17955
|
+
*/
|
|
17956
|
+
findAllowedSecond(dir, startSecond) {
|
|
17957
|
+
return dir === "next" ? this.seconds.find((x) => x > startSecond) : this.reversed.seconds.find((x) => x < startSecond);
|
|
17958
|
+
}
|
|
17959
|
+
/**
|
|
17960
|
+
* Find the next or previous time, starting from the given start time that matches the hour, minute
|
|
17961
|
+
* and second constraints. startTime itself might also be allowed.
|
|
17962
|
+
*/
|
|
17963
|
+
findAllowedTime(dir, startTime) {
|
|
17964
|
+
let hour = this.findAllowedHour(dir, startTime.hour);
|
|
17965
|
+
if (hour !== void 0) if (hour === startTime.hour) {
|
|
17966
|
+
let minute = this.findAllowedMinute(dir, startTime.minute);
|
|
17967
|
+
if (minute !== void 0) if (minute === startTime.minute) {
|
|
17968
|
+
const second = this.findAllowedSecond(dir, startTime.second);
|
|
17969
|
+
if (second !== void 0) return {
|
|
17970
|
+
hour,
|
|
17971
|
+
minute,
|
|
17972
|
+
second
|
|
17600
17973
|
};
|
|
17601
|
-
|
|
17602
|
-
|
|
17603
|
-
|
|
17604
|
-
|
|
17605
|
-
|
|
17974
|
+
minute = this.findAllowedMinute(dir, dir === "next" ? startTime.minute + 1 : startTime.minute - 1);
|
|
17975
|
+
if (minute !== void 0) return {
|
|
17976
|
+
hour,
|
|
17977
|
+
minute,
|
|
17978
|
+
second: dir === "next" ? this.seconds[0] : this.reversed.seconds[0]
|
|
17606
17979
|
};
|
|
17607
|
-
|
|
17608
|
-
|
|
17609
|
-
|
|
17610
|
-
|
|
17611
|
-
|
|
17612
|
-
|
|
17613
|
-
|
|
17614
|
-
|
|
17615
|
-
|
|
17616
|
-
|
|
17617
|
-
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
|
|
17623
|
-
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
|
|
17980
|
+
} else return {
|
|
17981
|
+
hour,
|
|
17982
|
+
minute,
|
|
17983
|
+
second: dir === "next" ? this.seconds[0] : this.reversed.seconds[0]
|
|
17984
|
+
};
|
|
17985
|
+
hour = this.findAllowedHour(dir, dir === "next" ? startTime.hour + 1 : startTime.hour - 1);
|
|
17986
|
+
if (hour !== void 0) return {
|
|
17987
|
+
hour,
|
|
17988
|
+
minute: dir === "next" ? this.minutes[0] : this.reversed.minutes[0],
|
|
17989
|
+
second: dir === "next" ? this.seconds[0] : this.reversed.seconds[0]
|
|
17990
|
+
};
|
|
17991
|
+
} else return {
|
|
17992
|
+
hour,
|
|
17993
|
+
minute: dir === "next" ? this.minutes[0] : this.reversed.minutes[0],
|
|
17994
|
+
second: dir === "next" ? this.seconds[0] : this.reversed.seconds[0]
|
|
17995
|
+
};
|
|
17996
|
+
}
|
|
17997
|
+
/**
|
|
17998
|
+
* Find the next or previous day in the given month, starting from the given startDay
|
|
17999
|
+
* that matches either the day or the weekday constraint. startDay itself might also be allowed.
|
|
18000
|
+
*/
|
|
18001
|
+
findAllowedDayInMonth(dir, year, month, startDay) {
|
|
18002
|
+
var _a, _b;
|
|
18003
|
+
if (startDay < 1) throw new Error("startDay must not be smaller than 1.");
|
|
18004
|
+
const daysInMonth = getDaysInMonth(year, month);
|
|
18005
|
+
const daysRestricted = this.days.length !== 31;
|
|
18006
|
+
const weekdaysRestricted = this.weekdays.length !== 7;
|
|
18007
|
+
if (!daysRestricted && !weekdaysRestricted) {
|
|
18008
|
+
if (startDay > daysInMonth) return dir === "next" ? void 0 : daysInMonth;
|
|
18009
|
+
return startDay;
|
|
18010
|
+
}
|
|
18011
|
+
let allowedDayByDays;
|
|
18012
|
+
if (daysRestricted) {
|
|
18013
|
+
allowedDayByDays = dir === "next" ? this.days.find((x) => x >= startDay) : this.reversed.days.find((x) => x <= startDay);
|
|
18014
|
+
if (allowedDayByDays !== void 0 && allowedDayByDays > daysInMonth) allowedDayByDays = void 0;
|
|
18015
|
+
}
|
|
18016
|
+
let allowedDayByWeekdays;
|
|
18017
|
+
if (weekdaysRestricted) {
|
|
18018
|
+
const startWeekday = new Date(year, month, startDay).getDay();
|
|
18019
|
+
const nearestAllowedWeekday = dir === "next" ? (_a = this.weekdays.find((x) => x >= startWeekday)) !== null && _a !== void 0 ? _a : this.weekdays[0] : (_b = this.reversed.weekdays.find((x) => x <= startWeekday)) !== null && _b !== void 0 ? _b : this.reversed.weekdays[0];
|
|
18020
|
+
if (nearestAllowedWeekday !== void 0) {
|
|
18021
|
+
const daysBetweenWeekdays = dir === "next" ? getDaysBetweenWeekdays(startWeekday, nearestAllowedWeekday) : getDaysBetweenWeekdays(nearestAllowedWeekday, startWeekday);
|
|
18022
|
+
allowedDayByWeekdays = dir === "next" ? startDay + daysBetweenWeekdays : startDay - daysBetweenWeekdays;
|
|
18023
|
+
if (allowedDayByWeekdays > daysInMonth || allowedDayByWeekdays < 1) allowedDayByWeekdays = void 0;
|
|
17635
18024
|
}
|
|
17636
|
-
return null;
|
|
17637
18025
|
}
|
|
17638
|
-
|
|
17639
|
-
|
|
17640
|
-
|
|
17641
|
-
|
|
18026
|
+
if (allowedDayByDays !== void 0 && allowedDayByWeekdays !== void 0) return dir === "next" ? Math.min(allowedDayByDays, allowedDayByWeekdays) : Math.max(allowedDayByDays, allowedDayByWeekdays);
|
|
18027
|
+
if (allowedDayByDays !== void 0) return allowedDayByDays;
|
|
18028
|
+
if (allowedDayByWeekdays !== void 0) return allowedDayByWeekdays;
|
|
18029
|
+
}
|
|
18030
|
+
/** Gets the next date starting from the given start date or now. */
|
|
18031
|
+
getNextDate(startDate = /* @__PURE__ */ new Date()) {
|
|
18032
|
+
const startDateElements = extractDateElements(startDate);
|
|
18033
|
+
let minYear = startDateElements.year;
|
|
18034
|
+
let startIndexMonth = this.months.findIndex((x) => x >= startDateElements.month);
|
|
18035
|
+
if (startIndexMonth === -1) {
|
|
18036
|
+
startIndexMonth = 0;
|
|
18037
|
+
minYear++;
|
|
17642
18038
|
}
|
|
17643
|
-
*
|
|
17644
|
-
|
|
17645
|
-
|
|
17646
|
-
|
|
17647
|
-
|
|
18039
|
+
const maxIterations = this.months.length * 5;
|
|
18040
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
18041
|
+
const year = minYear + Math.floor((startIndexMonth + i) / this.months.length);
|
|
18042
|
+
const month = this.months[(startIndexMonth + i) % this.months.length];
|
|
18043
|
+
const isStartMonth = year === startDateElements.year && month === startDateElements.month;
|
|
18044
|
+
let day = this.findAllowedDayInMonth("next", year, month, isStartMonth ? startDateElements.day : 1);
|
|
18045
|
+
let isStartDay = isStartMonth && day === startDateElements.day;
|
|
18046
|
+
if (day !== void 0 && isStartDay) {
|
|
18047
|
+
const nextTime = this.findAllowedTime("next", startDateElements);
|
|
18048
|
+
if (nextTime !== void 0) return new Date(year, month, day, nextTime.hour, nextTime.minute, nextTime.second);
|
|
18049
|
+
day = this.findAllowedDayInMonth("next", year, month, day + 1);
|
|
18050
|
+
isStartDay = false;
|
|
17648
18051
|
}
|
|
18052
|
+
if (day !== void 0 && !isStartDay) return new Date(year, month, day, this.hours[0], this.minutes[0], this.seconds[0]);
|
|
17649
18053
|
}
|
|
17650
|
-
|
|
17651
|
-
|
|
17652
|
-
|
|
17653
|
-
|
|
17654
|
-
|
|
17655
|
-
|
|
17656
|
-
|
|
17657
|
-
|
|
17658
|
-
|
|
17659
|
-
|
|
17660
|
-
|
|
17661
|
-
|
|
17662
|
-
|
|
17663
|
-
|
|
17664
|
-
|
|
17665
|
-
|
|
18054
|
+
throw new Error("No valid next date was found.");
|
|
18055
|
+
}
|
|
18056
|
+
/** Gets the specified amount of future dates starting from the given start date or now. */
|
|
18057
|
+
getNextDates(amount, startDate) {
|
|
18058
|
+
const dates = [];
|
|
18059
|
+
let nextDate;
|
|
18060
|
+
for (let i = 0; i < amount; i++) {
|
|
18061
|
+
nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);
|
|
18062
|
+
dates.push(nextDate);
|
|
18063
|
+
}
|
|
18064
|
+
return dates;
|
|
18065
|
+
}
|
|
18066
|
+
/**
|
|
18067
|
+
* Get an ES6 compatible iterator which iterates over the next dates starting from startDate or now.
|
|
18068
|
+
* The iterator runs until the optional endDate is reached or forever.
|
|
18069
|
+
*/
|
|
18070
|
+
*getNextDatesIterator(startDate, endDate) {
|
|
18071
|
+
let nextDate;
|
|
18072
|
+
while (true) {
|
|
18073
|
+
nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);
|
|
18074
|
+
if (endDate && endDate.getTime() < nextDate.getTime()) return;
|
|
18075
|
+
yield nextDate;
|
|
18076
|
+
}
|
|
18077
|
+
}
|
|
18078
|
+
/** Gets the previous date starting from the given start date or now. */
|
|
18079
|
+
getPrevDate(startDate = /* @__PURE__ */ new Date()) {
|
|
18080
|
+
const startDateElements = extractDateElements(startDate);
|
|
18081
|
+
let maxYear = startDateElements.year;
|
|
18082
|
+
let startIndexMonth = this.reversed.months.findIndex((x) => x <= startDateElements.month);
|
|
18083
|
+
if (startIndexMonth === -1) {
|
|
18084
|
+
startIndexMonth = 0;
|
|
18085
|
+
maxYear--;
|
|
18086
|
+
}
|
|
18087
|
+
const maxIterations = this.reversed.months.length * 5;
|
|
18088
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
18089
|
+
const year = maxYear - Math.floor((startIndexMonth + i) / this.reversed.months.length);
|
|
18090
|
+
const month = this.reversed.months[(startIndexMonth + i) % this.reversed.months.length];
|
|
18091
|
+
const isStartMonth = year === startDateElements.year && month === startDateElements.month;
|
|
18092
|
+
let day = this.findAllowedDayInMonth("prev", year, month, isStartMonth ? startDateElements.day : getDaysInMonth(year, month));
|
|
18093
|
+
let isStartDay = isStartMonth && day === startDateElements.day;
|
|
18094
|
+
if (day !== void 0 && isStartDay) {
|
|
18095
|
+
const prevTime = this.findAllowedTime("prev", startDateElements);
|
|
18096
|
+
if (prevTime !== void 0) return new Date(year, month, day, prevTime.hour, prevTime.minute, prevTime.second);
|
|
18097
|
+
if (day > 1) {
|
|
18098
|
+
day = this.findAllowedDayInMonth("prev", year, month, day - 1);
|
|
18099
|
+
isStartDay = false;
|
|
18100
|
+
}
|
|
17666
18101
|
}
|
|
18102
|
+
if (day !== void 0 && !isStartDay) return new Date(year, month, day, this.reversed.hours[0], this.reversed.minutes[0], this.reversed.seconds[0]);
|
|
17667
18103
|
}
|
|
17668
|
-
|
|
17669
|
-
|
|
17670
|
-
|
|
18104
|
+
throw new Error("No valid previous date was found.");
|
|
18105
|
+
}
|
|
18106
|
+
/** Gets the specified amount of previous dates starting from the given start date or now. */
|
|
18107
|
+
getPrevDates(amount, startDate) {
|
|
18108
|
+
const dates = [];
|
|
18109
|
+
let prevDate;
|
|
18110
|
+
for (let i = 0; i < amount; i++) {
|
|
18111
|
+
prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);
|
|
18112
|
+
dates.push(prevDate);
|
|
18113
|
+
}
|
|
18114
|
+
return dates;
|
|
18115
|
+
}
|
|
18116
|
+
/**
|
|
18117
|
+
* Get an ES6 compatible iterator which iterates over the previous dates starting from startDate or now.
|
|
18118
|
+
* The iterator runs until the optional endDate is reached or forever.
|
|
18119
|
+
*/
|
|
18120
|
+
*getPrevDatesIterator(startDate, endDate) {
|
|
18121
|
+
let prevDate;
|
|
18122
|
+
while (true) {
|
|
18123
|
+
prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);
|
|
18124
|
+
if (endDate && endDate.getTime() > prevDate.getTime()) return;
|
|
18125
|
+
yield prevDate;
|
|
18126
|
+
}
|
|
18127
|
+
}
|
|
18128
|
+
/** Returns true when there is a cron date at the given date. */
|
|
18129
|
+
matchDate(date) {
|
|
18130
|
+
const { second, minute, hour, day, month, weekday } = extractDateElements(date);
|
|
18131
|
+
if (this.seconds.indexOf(second) === -1 || this.minutes.indexOf(minute) === -1 || this.hours.indexOf(hour) === -1 || this.months.indexOf(month) === -1) return false;
|
|
18132
|
+
if (this.days.length !== 31 && this.weekdays.length !== 7) return this.days.indexOf(day) !== -1 || this.weekdays.indexOf(weekday) !== -1;
|
|
18133
|
+
return this.days.indexOf(day) !== -1 && this.weekdays.indexOf(weekday) !== -1;
|
|
18134
|
+
}
|
|
18135
|
+
};
|
|
17671
18136
|
//#endregion
|
|
17672
|
-
//#region ../../node_modules/.pnpm/
|
|
17673
|
-
|
|
17674
|
-
|
|
17675
|
-
|
|
17676
|
-
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
18137
|
+
//#region ../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron-parser.js
|
|
18138
|
+
const secondConstraint = {
|
|
18139
|
+
min: 0,
|
|
18140
|
+
max: 59
|
|
18141
|
+
};
|
|
18142
|
+
const minuteConstraint = {
|
|
18143
|
+
min: 0,
|
|
18144
|
+
max: 59
|
|
18145
|
+
};
|
|
18146
|
+
const hourConstraint = {
|
|
18147
|
+
min: 0,
|
|
18148
|
+
max: 23
|
|
18149
|
+
};
|
|
18150
|
+
const dayConstraint = {
|
|
18151
|
+
min: 1,
|
|
18152
|
+
max: 31
|
|
18153
|
+
};
|
|
18154
|
+
const monthConstraint = {
|
|
18155
|
+
min: 1,
|
|
18156
|
+
max: 12,
|
|
18157
|
+
aliases: {
|
|
18158
|
+
jan: "1",
|
|
18159
|
+
feb: "2",
|
|
18160
|
+
mar: "3",
|
|
18161
|
+
apr: "4",
|
|
18162
|
+
may: "5",
|
|
18163
|
+
jun: "6",
|
|
18164
|
+
jul: "7",
|
|
18165
|
+
aug: "8",
|
|
18166
|
+
sep: "9",
|
|
18167
|
+
oct: "10",
|
|
18168
|
+
nov: "11",
|
|
18169
|
+
dec: "12"
|
|
17687
18170
|
}
|
|
17688
|
-
|
|
17689
|
-
|
|
17690
|
-
|
|
17691
|
-
|
|
17692
|
-
|
|
17693
|
-
|
|
17694
|
-
|
|
17695
|
-
|
|
17696
|
-
|
|
17697
|
-
|
|
17698
|
-
|
|
17699
|
-
|
|
17700
|
-
const composer$1 = new composer.Composer(options);
|
|
17701
|
-
const docs = Array.from(composer$1.compose(parser$1.parse(source)));
|
|
17702
|
-
if (prettyErrors && lineCounter) for (const doc of docs) {
|
|
17703
|
-
doc.errors.forEach(errors.prettifyError(source, lineCounter));
|
|
17704
|
-
doc.warnings.forEach(errors.prettifyError(source, lineCounter));
|
|
17705
|
-
}
|
|
17706
|
-
if (docs.length > 0) return docs;
|
|
17707
|
-
return Object.assign([], { empty: true }, composer$1.streamInfo());
|
|
18171
|
+
};
|
|
18172
|
+
const weekdayConstraint = {
|
|
18173
|
+
min: 0,
|
|
18174
|
+
max: 7,
|
|
18175
|
+
aliases: {
|
|
18176
|
+
mon: "1",
|
|
18177
|
+
tue: "2",
|
|
18178
|
+
wed: "3",
|
|
18179
|
+
thu: "4",
|
|
18180
|
+
fri: "5",
|
|
18181
|
+
sat: "6",
|
|
18182
|
+
sun: "7"
|
|
17708
18183
|
}
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
18184
|
+
};
|
|
18185
|
+
const timeNicknames = {
|
|
18186
|
+
"@yearly": "0 0 1 1 *",
|
|
18187
|
+
"@annually": "0 0 1 1 *",
|
|
18188
|
+
"@monthly": "0 0 1 * *",
|
|
18189
|
+
"@weekly": "0 0 * * 0",
|
|
18190
|
+
"@daily": "0 0 * * *",
|
|
18191
|
+
"@hourly": "0 * * * *",
|
|
18192
|
+
"@minutely": "* * * * *"
|
|
18193
|
+
};
|
|
18194
|
+
function parseElement(element, constraint) {
|
|
18195
|
+
const result = /* @__PURE__ */ new Set();
|
|
18196
|
+
if (element === "*") {
|
|
18197
|
+
for (let i = constraint.min; i <= constraint.max; i = i + 1) result.add(i);
|
|
18198
|
+
return result;
|
|
18199
|
+
}
|
|
18200
|
+
const listElements = element.split(",");
|
|
18201
|
+
if (listElements.length > 1) {
|
|
18202
|
+
for (const listElement of listElements) {
|
|
18203
|
+
const parsedListElement = parseElement(listElement, constraint);
|
|
18204
|
+
for (const x of parsedListElement) result.add(x);
|
|
17723
18205
|
}
|
|
17724
|
-
return
|
|
18206
|
+
return result;
|
|
17725
18207
|
}
|
|
17726
|
-
|
|
17727
|
-
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
if (
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
18208
|
+
const parseSingleElement = (singleElement) => {
|
|
18209
|
+
var _a, _b;
|
|
18210
|
+
singleElement = (_b = (_a = constraint.aliases) === null || _a === void 0 ? void 0 : _a[singleElement.toLowerCase()]) !== null && _b !== void 0 ? _b : singleElement;
|
|
18211
|
+
const parsedElement = Number.parseInt(singleElement, 10);
|
|
18212
|
+
if (Number.isNaN(parsedElement)) throw new Error(`Failed to parse ${element}: ${singleElement} is NaN.`);
|
|
18213
|
+
if (parsedElement < constraint.min || parsedElement > constraint.max) throw new Error(`Failed to parse ${element}: ${singleElement} is outside of constraint range of ${constraint.min} - ${constraint.max}.`);
|
|
18214
|
+
return parsedElement;
|
|
18215
|
+
};
|
|
18216
|
+
const rangeSegments = /^(([0-9a-zA-Z]+)-([0-9a-zA-Z]+)|\*)(\/([0-9]+))?$/.exec(element);
|
|
18217
|
+
if (rangeSegments === null) {
|
|
18218
|
+
result.add(parseSingleElement(element));
|
|
18219
|
+
return result;
|
|
17736
18220
|
}
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
|
|
17742
|
-
|
|
17743
|
-
|
|
17744
|
-
|
|
17745
|
-
}
|
|
17746
|
-
if (
|
|
17747
|
-
const { keepUndefined } = options ?? replacer ?? {};
|
|
17748
|
-
if (!keepUndefined) return void 0;
|
|
17749
|
-
}
|
|
17750
|
-
if (identity.isDocument(value) && !_replacer) return value.toString(options);
|
|
17751
|
-
return new Document.Document(value, _replacer, options).toString(options);
|
|
18221
|
+
let parsedStart = rangeSegments[1] === "*" ? constraint.min : parseSingleElement(rangeSegments[2]);
|
|
18222
|
+
const parsedEnd = rangeSegments[1] === "*" ? constraint.max : parseSingleElement(rangeSegments[3]);
|
|
18223
|
+
if (constraint === weekdayConstraint && parsedStart === 7 && parsedEnd !== 7) parsedStart = 0;
|
|
18224
|
+
if (parsedStart > parsedEnd) throw new Error(`Failed to parse ${element}: Invalid range (start: ${parsedStart}, end: ${parsedEnd}).`);
|
|
18225
|
+
const step = rangeSegments[5];
|
|
18226
|
+
let parsedStep = 1;
|
|
18227
|
+
if (step !== void 0) {
|
|
18228
|
+
parsedStep = Number.parseInt(step, 10);
|
|
18229
|
+
if (Number.isNaN(parsedStep)) throw new Error(`Failed to parse step: ${step} is NaN.`);
|
|
18230
|
+
if (parsedStep < 1) throw new Error(`Failed to parse step: Expected ${step} to be greater than 0.`);
|
|
17752
18231
|
}
|
|
17753
|
-
|
|
17754
|
-
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
exports.YAMLError = errors.YAMLError;
|
|
17779
|
-
exports.YAMLParseError = errors.YAMLParseError;
|
|
17780
|
-
exports.YAMLWarning = errors.YAMLWarning;
|
|
17781
|
-
exports.Alias = Alias.Alias;
|
|
17782
|
-
exports.isAlias = identity.isAlias;
|
|
17783
|
-
exports.isCollection = identity.isCollection;
|
|
17784
|
-
exports.isDocument = identity.isDocument;
|
|
17785
|
-
exports.isMap = identity.isMap;
|
|
17786
|
-
exports.isNode = identity.isNode;
|
|
17787
|
-
exports.isPair = identity.isPair;
|
|
17788
|
-
exports.isScalar = identity.isScalar;
|
|
17789
|
-
exports.isSeq = identity.isSeq;
|
|
17790
|
-
exports.Pair = Pair.Pair;
|
|
17791
|
-
exports.Scalar = Scalar.Scalar;
|
|
17792
|
-
exports.YAMLMap = YAMLMap.YAMLMap;
|
|
17793
|
-
exports.YAMLSeq = YAMLSeq.YAMLSeq;
|
|
17794
|
-
exports.Lexer = lexer.Lexer;
|
|
17795
|
-
exports.LineCounter = lineCounter.LineCounter;
|
|
17796
|
-
exports.Parser = parser.Parser;
|
|
17797
|
-
exports.parse = publicApi.parse;
|
|
17798
|
-
exports.parseAllDocuments = publicApi.parseAllDocuments;
|
|
17799
|
-
exports.parseDocument = publicApi.parseDocument;
|
|
17800
|
-
exports.stringify = publicApi.stringify;
|
|
17801
|
-
exports.visit = visit.visit;
|
|
17802
|
-
exports.visitAsync = visit.visitAsync;
|
|
17803
|
-
})))();
|
|
18232
|
+
for (let i = parsedStart; i <= parsedEnd; i = i + parsedStep) result.add(i);
|
|
18233
|
+
return result;
|
|
18234
|
+
}
|
|
18235
|
+
/** Parses a cron expression into a Cron instance. */
|
|
18236
|
+
function parseCronExpression(cronExpression) {
|
|
18237
|
+
var _a;
|
|
18238
|
+
if (typeof cronExpression !== "string") throw new TypeError("Invalid cron expression: must be of type string.");
|
|
18239
|
+
cronExpression = (_a = timeNicknames[cronExpression.toLowerCase()]) !== null && _a !== void 0 ? _a : cronExpression;
|
|
18240
|
+
const elements = cronExpression.split(" ").filter((elem) => elem.length > 0);
|
|
18241
|
+
if (elements.length < 5 || elements.length > 6) throw new Error("Invalid cron expression: expected 5 or 6 elements.");
|
|
18242
|
+
const rawSeconds = elements.length === 6 ? elements[0] : "0";
|
|
18243
|
+
const rawMinutes = elements.length === 6 ? elements[1] : elements[0];
|
|
18244
|
+
const rawHours = elements.length === 6 ? elements[2] : elements[1];
|
|
18245
|
+
const rawDays = elements.length === 6 ? elements[3] : elements[2];
|
|
18246
|
+
const rawMonths = elements.length === 6 ? elements[4] : elements[3];
|
|
18247
|
+
const rawWeekdays = elements.length === 6 ? elements[5] : elements[4];
|
|
18248
|
+
return new Cron({
|
|
18249
|
+
seconds: parseElement(rawSeconds, secondConstraint),
|
|
18250
|
+
minutes: parseElement(rawMinutes, minuteConstraint),
|
|
18251
|
+
hours: parseElement(rawHours, hourConstraint),
|
|
18252
|
+
days: parseElement(rawDays, dayConstraint),
|
|
18253
|
+
months: new Set(Array.from(parseElement(rawMonths, monthConstraint)).map((x) => x - 1)),
|
|
18254
|
+
weekdays: new Set(Array.from(parseElement(rawWeekdays, weekdayConstraint)).map((x) => x % 7))
|
|
18255
|
+
});
|
|
18256
|
+
}
|
|
17804
18257
|
//#endregion
|
|
17805
18258
|
//#region ../../packages/workflow/dist/index.mjs
|
|
17806
18259
|
const zodSchema$2 = custom((v) => v instanceof ZodType, "must be a Zod schema");
|
|
@@ -17933,6 +18386,12 @@ function isTriggerAttachment(value) {
|
|
|
17933
18386
|
if (!(TRIGGER_ATTACHMENT$1 in value) || value[TRIGGER_ATTACHMENT$1] !== true) return false;
|
|
17934
18387
|
return triggerAttachmentCoreSchema$1.safeParse(value).success;
|
|
17935
18388
|
}
|
|
18389
|
+
function isWorkflowTriggerAttachment(attachment) {
|
|
18390
|
+
return attachment.target === "workflow";
|
|
18391
|
+
}
|
|
18392
|
+
function isAgentTriggerAttachment(attachment) {
|
|
18393
|
+
return attachment.target === "agent";
|
|
18394
|
+
}
|
|
17936
18395
|
/** Read slug from a trigger source (`slug` preferred, legacy `key` fallback). */
|
|
17937
18396
|
function sourceSlugFrom(source) {
|
|
17938
18397
|
const slug = source.slug?.trim() || source.key?.trim();
|
|
@@ -17990,6 +18449,12 @@ function agentRouteFromKey(key) {
|
|
|
17990
18449
|
function workflowRouteFromKey(key) {
|
|
17991
18450
|
return `/workflows/${key}`;
|
|
17992
18451
|
}
|
|
18452
|
+
function pollRouteFromSourceSlug(sourceSlug) {
|
|
18453
|
+
return `/triggers/${sourceSlug}/poll`;
|
|
18454
|
+
}
|
|
18455
|
+
function pollGroupRouteFromId(pollId) {
|
|
18456
|
+
return `/triggers/polls/${pollId}/run`;
|
|
18457
|
+
}
|
|
17993
18458
|
function webhookRouteFromEndpoint(endpoint) {
|
|
17994
18459
|
const normalized = normalizeWebhookEndpoint(endpoint);
|
|
17995
18460
|
if (!normalized) throw new Error("Webhook endpoint must not be empty");
|
|
@@ -18069,6 +18534,142 @@ function agentManifestEntry(agent, options) {
|
|
|
18069
18534
|
toolSlugs: collectAgentToolSlugs(agent)
|
|
18070
18535
|
};
|
|
18071
18536
|
}
|
|
18537
|
+
function pollGroupId(discovered) {
|
|
18538
|
+
const source = discovered.attachment.source;
|
|
18539
|
+
if (source.kind !== "poll") throw new Error(`Attachment "${discovered.slug}" is not a poll trigger`);
|
|
18540
|
+
return source.id ?? sourceSlugFrom(source);
|
|
18541
|
+
}
|
|
18542
|
+
function buildPollGroups(attachments) {
|
|
18543
|
+
const byId = /* @__PURE__ */ new Map();
|
|
18544
|
+
for (const discovered of attachments) {
|
|
18545
|
+
if (discovered.attachment.source.kind !== "poll") continue;
|
|
18546
|
+
const id = pollGroupId(discovered);
|
|
18547
|
+
const group = byId.get(id) ?? [];
|
|
18548
|
+
group.push(discovered);
|
|
18549
|
+
byId.set(id, group);
|
|
18550
|
+
}
|
|
18551
|
+
return [...byId.entries()].map(([id, groupAttachments]) => ({
|
|
18552
|
+
id,
|
|
18553
|
+
attachments: groupAttachments
|
|
18554
|
+
}));
|
|
18555
|
+
}
|
|
18556
|
+
function validatePollGroups(groups) {
|
|
18557
|
+
for (const group of groups) {
|
|
18558
|
+
if (group.attachments.length <= 1) continue;
|
|
18559
|
+
if (new Set(group.attachments.map((discovered) => {
|
|
18560
|
+
const source = discovered.attachment.source;
|
|
18561
|
+
if (source.kind !== "poll") throw new Error(`Poll group "${group.id}" has non-poll attachment ${discovered.slug}`);
|
|
18562
|
+
return source.schedule;
|
|
18563
|
+
})).size > 1) {
|
|
18564
|
+
const slugs = group.attachments.map((discovered) => discovered.slug).join(", ");
|
|
18565
|
+
throw new Error(`Poll group "${group.id}" has attachments with different schedules (${slugs})`);
|
|
18566
|
+
}
|
|
18567
|
+
}
|
|
18568
|
+
}
|
|
18569
|
+
function discoveredSlug(attachment) {
|
|
18570
|
+
return attachment.slug;
|
|
18571
|
+
}
|
|
18572
|
+
function validateTriggerAttachments(attachments) {
|
|
18573
|
+
const pollRoutes = /* @__PURE__ */ new Map();
|
|
18574
|
+
for (const attachment of attachments) {
|
|
18575
|
+
const source = attachment.attachment.source;
|
|
18576
|
+
const slug = discoveredSlug(attachment);
|
|
18577
|
+
if (source.kind === "poll") {
|
|
18578
|
+
const sourceSlug = sourceSlugFrom(source);
|
|
18579
|
+
const route = pollRouteFromSourceSlug(sourceSlug);
|
|
18580
|
+
const existingPoll = pollRoutes.get(route);
|
|
18581
|
+
if (existingPoll) throw new Error(`Poll route ${route} is declared by both "${existingPoll}" and "${sourceSlug}"`);
|
|
18582
|
+
pollRoutes.set(route, sourceSlug);
|
|
18583
|
+
const groupRoute = pollGroupRouteFromId(source.id ?? sourceSlug);
|
|
18584
|
+
if (pollRoutes.has(groupRoute)) throw new Error(`Poll group route ${groupRoute} conflicts with a poll attachment route`);
|
|
18585
|
+
if (!source.schedule.trim()) throw new Error(`Trigger attachment "${slug}" has an empty poll schedule`);
|
|
18586
|
+
continue;
|
|
18587
|
+
}
|
|
18588
|
+
if (source.kind === "cron") {
|
|
18589
|
+
if (!source.schedule.trim()) throw new Error(`Trigger attachment "${slug}" has an empty cron schedule`);
|
|
18590
|
+
continue;
|
|
18591
|
+
}
|
|
18592
|
+
if (!source.endpoint.trim()) throw new Error(`Trigger attachment "${slug}" has an empty webhook endpoint`);
|
|
18593
|
+
const route = webhookRouteFromEndpoint(source.endpoint);
|
|
18594
|
+
if (pollRoutes.has(route)) throw new Error(`Webhook route ${route} conflicts with a poll trigger route`);
|
|
18595
|
+
}
|
|
18596
|
+
}
|
|
18597
|
+
function workflowKeyForAttachment(attachment, workflows) {
|
|
18598
|
+
if (!isWorkflowTriggerAttachment(attachment.attachment)) throw new Error(`Trigger attachment "${discoveredSlug(attachment)}" is not a workflow attachment`);
|
|
18599
|
+
const workflowKey = attachment.attachment.workflow.slug;
|
|
18600
|
+
const matched = workflows.find((entry) => entry.key === workflowKey);
|
|
18601
|
+
if (!matched) throw new Error(`Trigger attachment "${discoveredSlug(attachment)}" references an unknown workflow`);
|
|
18602
|
+
return matched.key;
|
|
18603
|
+
}
|
|
18604
|
+
function agentKeyForAttachment(attachment, agents) {
|
|
18605
|
+
if (!isAgentTriggerAttachment(attachment.attachment)) throw new Error(`Trigger attachment "${discoveredSlug(attachment)}" is not an agent attachment`);
|
|
18606
|
+
const agentKey = attachment.attachment.agent.slug;
|
|
18607
|
+
const matched = agents.find((entry) => entry.key === agentKey);
|
|
18608
|
+
if (!matched) throw new Error(`Trigger attachment "${discoveredSlug(attachment)}" references an unknown agent`);
|
|
18609
|
+
return matched.key;
|
|
18610
|
+
}
|
|
18611
|
+
function validateAttachmentTargets(attachments, workflows, agents) {
|
|
18612
|
+
for (const attachment of attachments) {
|
|
18613
|
+
if (isWorkflowTriggerAttachment(attachment.attachment)) {
|
|
18614
|
+
workflowKeyForAttachment(attachment, workflows);
|
|
18615
|
+
continue;
|
|
18616
|
+
}
|
|
18617
|
+
agentKeyForAttachment(attachment, agents);
|
|
18618
|
+
}
|
|
18619
|
+
}
|
|
18620
|
+
function validateUniqueAttachmentSlugs(attachments) {
|
|
18621
|
+
const bySlug = /* @__PURE__ */ new Map();
|
|
18622
|
+
for (const attachment of attachments) {
|
|
18623
|
+
const slug = discoveredSlug(attachment);
|
|
18624
|
+
const existing = bySlug.get(slug);
|
|
18625
|
+
if (existing) throw new Error(`Duplicate trigger attachment slug "${slug}" (${existing}, ${attachment.filePath})`);
|
|
18626
|
+
bySlug.set(slug, attachment.filePath);
|
|
18627
|
+
}
|
|
18628
|
+
}
|
|
18629
|
+
function sourceConfigSignature(source) {
|
|
18630
|
+
if (source.kind === "webhook") return `webhook:${source.endpoint}`;
|
|
18631
|
+
if (source.kind === "cron") return `cron:${source.schedule}`;
|
|
18632
|
+
return `poll:${source.id ?? source.slug}:${source.schedule}`;
|
|
18633
|
+
}
|
|
18634
|
+
function validateUniqueTriggerSourceSlugs(attachments) {
|
|
18635
|
+
const bySourceSlug = /* @__PURE__ */ new Map();
|
|
18636
|
+
for (const attachment of attachments) {
|
|
18637
|
+
const source = attachment.attachment.source;
|
|
18638
|
+
const sourceSlug = sourceSlugFrom(source);
|
|
18639
|
+
const signature = sourceConfigSignature(source);
|
|
18640
|
+
const existing = bySourceSlug.get(sourceSlug);
|
|
18641
|
+
if (existing && existing.signature !== signature) throw new Error(`Conflicting trigger source slug "${sourceSlug}" with differing config (${existing.filePath}, ${attachment.filePath})`);
|
|
18642
|
+
if (!existing) bySourceSlug.set(sourceSlug, {
|
|
18643
|
+
filePath: attachment.filePath,
|
|
18644
|
+
signature
|
|
18645
|
+
});
|
|
18646
|
+
}
|
|
18647
|
+
}
|
|
18648
|
+
/** Build/deploy manifest invariants — not re-run at runtime bootstrap. */
|
|
18649
|
+
function validateProjectModules(input) {
|
|
18650
|
+
validateTriggerAttachments(input.attachments);
|
|
18651
|
+
validatePollGroups(buildPollGroups(input.attachments));
|
|
18652
|
+
validateUniqueTriggerSourceSlugs(input.attachments);
|
|
18653
|
+
validateUniqueAttachmentSlugs(input.attachments);
|
|
18654
|
+
validateAttachmentTargets(input.attachments, input.workflows, input.agents);
|
|
18655
|
+
validateUniqueModuleKeys([
|
|
18656
|
+
...input.agents.map((entry) => ({
|
|
18657
|
+
kind: "agent",
|
|
18658
|
+
key: entry.key,
|
|
18659
|
+
filePath: entry.filePath
|
|
18660
|
+
})),
|
|
18661
|
+
...input.workflows.map((workflow) => ({
|
|
18662
|
+
kind: "workflow",
|
|
18663
|
+
key: workflow.key,
|
|
18664
|
+
filePath: workflow.filePath
|
|
18665
|
+
})),
|
|
18666
|
+
...input.attachments.map((attachment) => ({
|
|
18667
|
+
kind: "trigger",
|
|
18668
|
+
key: attachment.slug,
|
|
18669
|
+
filePath: attachment.filePath
|
|
18670
|
+
}))
|
|
18671
|
+
]);
|
|
18672
|
+
}
|
|
18072
18673
|
const SKIP_DIRS = new Set([".git", "node_modules"]);
|
|
18073
18674
|
function toPosix$1(path) {
|
|
18074
18675
|
return path.split(sep).join("/");
|
|
@@ -18339,11 +18940,6 @@ async function importTriggerAttachments(filePath, options) {
|
|
|
18339
18940
|
if (candidates.length === 0) return [validateImportedTriggerAttachment(void 0, filePath)];
|
|
18340
18941
|
return candidates.map((candidate) => validateImportedTriggerAttachment(candidate, filePath));
|
|
18341
18942
|
}
|
|
18342
|
-
function pollGroupId(discovered) {
|
|
18343
|
-
const source = discovered.attachment.source;
|
|
18344
|
-
if (source.kind !== "poll") throw new Error(`Attachment "${discovered.slug}" is not a poll trigger`);
|
|
18345
|
-
return source.id ?? sourceSlugFrom(source);
|
|
18346
|
-
}
|
|
18347
18943
|
function buildWebhookBindingsByRoute(attachments, handlerOptionsFor) {
|
|
18348
18944
|
const webhookBindingsByRoute = /* @__PURE__ */ new Map();
|
|
18349
18945
|
for (const discovered of attachments) {
|
|
@@ -18504,12 +19100,22 @@ async function buildStoredRouteManifestForProject(projectRoot, options) {
|
|
|
18504
19100
|
const sourcePaths = new SourceModuleFileResolver(projectRoot);
|
|
18505
19101
|
const manifest = [{ kind: "health" }];
|
|
18506
19102
|
const agentEntries = await discoverAgentEntries(dirs.agentsDir, reload);
|
|
18507
|
-
|
|
18508
|
-
|
|
19103
|
+
const workflows = await discoverWorkflows(dirs.workflowsDir, reload);
|
|
19104
|
+
const attachments = await discoverTriggerAttachments(dirs.triggersDir, reload);
|
|
19105
|
+
validateProjectModules({
|
|
19106
|
+
agents: agentEntries,
|
|
19107
|
+
workflows,
|
|
19108
|
+
attachments
|
|
19109
|
+
});
|
|
19110
|
+
const loadedAgents = await Promise.all(agentEntries.map(async (entry) => ({
|
|
19111
|
+
entry,
|
|
19112
|
+
agent: await importAgentDefinition(entry.filePath, reload)
|
|
19113
|
+
})));
|
|
19114
|
+
await validateAgentModelIds(loadedAgents.map(({ agent }) => agent.model));
|
|
19115
|
+
for (const { entry, agent } of loadedAgents) {
|
|
18509
19116
|
const moduleFile = await sourcePaths.resolve("agents", "agent", dirs.agentsDir, entry.filePath);
|
|
18510
19117
|
manifest.push(agentManifestEntry(agent, { moduleFile }));
|
|
18511
19118
|
}
|
|
18512
|
-
const workflows = await discoverWorkflows(dirs.workflowsDir, reload);
|
|
18513
19119
|
for (const workflow of workflows) {
|
|
18514
19120
|
const moduleFile = await sourcePaths.resolve("workflows", "workflow", dirs.workflowsDir, workflow.filePath);
|
|
18515
19121
|
manifest.push({
|
|
@@ -18522,7 +19128,6 @@ async function buildStoredRouteManifestForProject(projectRoot, options) {
|
|
|
18522
19128
|
request: workflow.definition.input
|
|
18523
19129
|
});
|
|
18524
19130
|
}
|
|
18525
|
-
const attachments = await discoverTriggerAttachments(dirs.triggersDir, reload);
|
|
18526
19131
|
const discoveredBySlug = new Map(attachments.map((attachment) => [attachment.slug, attachment]));
|
|
18527
19132
|
const cronByTriggerSlug = /* @__PURE__ */ new Map();
|
|
18528
19133
|
const pollByGroupId = /* @__PURE__ */ new Map();
|
|
@@ -18619,6 +19224,6 @@ async function emitStoredRouteManifestForProject(projectRoot) {
|
|
|
18619
19224
|
persistStoredRouteManifest(projectRoot, await buildStoredRouteManifestForProject(projectRoot));
|
|
18620
19225
|
}
|
|
18621
19226
|
//#endregion
|
|
18622
|
-
export {
|
|
19227
|
+
export { validatePollGroups as A, attachmentSlugFromRecord as B, pollRouteFromSourceSlug as C, validateAttachmentTargets as D, toStoredRouteManifest as E, webhookManifestAttachmentSchemasFromBindings as F, readKeystrokeIgnoreDirective as G, discoverEntries as H, webhookMatchSchemaForBindings as I, walkTypeScriptFiles as J, shouldSkipKeystrokeModuleFile as K, webhookRouteFromEndpoint as L, validateTriggerAttachments as M, validateUniqueAttachmentSlugs as N, validateImportedTriggerAttachment as O, validateUniqueTriggerSourceSlugs as P, workflowKeyForAttachment as R, pollGroupRouteFromId as S, serializeRouteManifest as T, discoverModuleFileEntries as U, packAssetDirs as V, entryIdFromFile as W, importAgentDefinition as _, buildStoredRouteManifestForProject as a, persistStoredRouteManifest as b, collectAgentAppSlugs as c, discoverAgentEntries as d, discoverSkillManifestEntries as f, emitStoredRouteManifestForProject as g, discoverWorkflows as h, buildPollGroups as i, validateProjectModules as j, validateImportedWorkflowDefinition as k, collectAgentToolSlugs as l, discoverWorkflowEntries as m, agentManifestEntry as n, buildStoredRouteManifestFromContext as o, discoverTriggerAttachments as p, validateUniqueModuleKeys as q, agentRouteFromKey as r, buildWebhookBindingsByRoute as s, agentKeyForAttachment as t, countAgentCredentials as u, importTriggerAttachments as v, schemaToJson as w, pollGroupId as x, importWorkflowDefinition as y, workflowRouteFromKey as z };
|
|
18623
19228
|
|
|
18624
|
-
//# sourceMappingURL=dist-
|
|
19229
|
+
//# sourceMappingURL=dist-BYODo4g3.mjs.map
|