@kky42/pievo-server 2.0.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/public/assets/{index-49hAH0gP.js → index-DT_reRxT.js} +3 -3
- package/.output/public/assets/{invite._token-C891oGkK.js → invite._token-5zhVSA26.js} +1 -1
- package/.output/public/assets/{lifecycleUi-C3k2MlX8.js → lifecycleUi-CMFw5Nlj.js} +1 -1
- package/.output/public/assets/{loops._loopId-DD4fKGMu.js → loops._loopId-6JlPOCsY.js} +1 -1
- package/.output/public/assets/{loops._loopId_.runs._runId-DoPcCQy7.js → loops._loopId_.runs._runId-wFUMHN9w.js} +2 -2
- package/.output/public/assets/{notifyFns-BaukhLAg.js → notifyFns-CF12Yboc.js} +1 -1
- package/.output/public/assets/{routes-BS4N7Lnf.js → routes-WVPuW976.js} +1 -1
- package/.output/public/assets/{t._teamId-DSYlMX_v.js → t._teamId-BdVLnwih.js} +1 -1
- package/.output/server/_ssr/{DashboardView-CQdjYy03.mjs → DashboardView-DJMpoucm.mjs} +4 -4
- package/.output/server/_ssr/{LoopPlaybook-C86vJIjZ.mjs → LoopPlaybook-WFNer22Y.mjs} +2 -2
- package/.output/server/_ssr/{LoopView-cDyjmf1B.mjs → LoopView-Dsc6oik9.mjs} +2 -2
- package/.output/server/_ssr/{SignIn-BQQiD3Ss.mjs → SignIn-2qr-vtR5.mjs} +2 -2
- package/.output/server/_ssr/{adapters-N4-yQ1vK.mjs → adapters-Bwuh6uek.mjs} +2 -2
- package/.output/server/_ssr/{artifactFiles-Dl1EaUtJ.mjs → artifactFiles-Cp1IBHne.mjs} +3 -3
- package/.output/server/_ssr/artifacts-9G_Ai7vO.mjs +2 -0
- package/.output/server/_ssr/{auth-CbAfO4Ne.mjs → auth-uQ19WsD1.mjs} +9 -9
- package/.output/server/_ssr/{boot-BZ-YyUiD.mjs → boot-DPoPmSLh.mjs} +76 -164
- package/.output/server/_ssr/{boot-BigKgB8p.mjs → boot-Zz5AJgfy.mjs} +1 -1
- package/.output/server/_ssr/{bun-sqlite-dialect-BW9W1_Ps-B67XLJZt.mjs → bun-sqlite-dialect-BW9W1_Ps-CqcLCApi.mjs} +2 -2
- package/.output/server/_ssr/{d1-sqlite-dialect-BLC8LXE6-nff_yHzH.mjs → d1-sqlite-dialect-BLC8LXE6-AuWb61y8.mjs} +2 -2
- package/.output/server/_ssr/db-BMANvbZu.mjs +2 -0
- package/.output/server/_ssr/{dist-BGjVt6NE.mjs → dist-CtYTvPCD.mjs} +2 -2
- package/.output/server/_ssr/{factory-DNeo3vVt.mjs → factory-BtqxMS8a.mjs} +2 -2
- package/.output/server/_ssr/{invite._token-Bipap1cl.mjs → invite._token-DBttmaDb.mjs} +4 -4
- package/.output/server/_ssr/{invite._token-z3PzCMzb.mjs → invite._token-DtAfQyfP.mjs} +3 -3
- package/.output/server/_ssr/{kysely-adapter-C1ww7PKr.mjs → kysely-adapter-bSpTlW7Z.mjs} +1 -1
- package/.output/server/_ssr/{lifecycleUi-5jMhxINb.mjs → lifecycleUi-Djb44Aj3.mjs} +4 -4
- package/.output/server/_ssr/logger-CR1a0flR.mjs +2 -0
- package/.output/server/_ssr/{loopApi-JzGGZZp2.mjs → loopApi-BXRBFGWh.mjs} +14 -14
- package/.output/server/_ssr/{loops._loopId-CJxQ0EG4.mjs → loops._loopId-6Q0DMXU0.mjs} +3 -3
- package/.output/server/_ssr/{loops._loopId-DFkyTJR3.mjs → loops._loopId-C0x0SE8F.mjs} +9 -9
- package/.output/server/_ssr/{loops._loopId_.runs._runId-lTigSOmT.mjs → loops._loopId_.runs._runId-BOJBJu_a.mjs} +3 -3
- package/.output/server/_ssr/{loops._loopId_.runs._runId-DkG-ZCD1.mjs → loops._loopId_.runs._runId-CkM0-ckn.mjs} +6 -6
- package/.output/server/_ssr/{machineFns-Dda8-rBY.mjs → machineFns-CQuvvdXx.mjs} +3 -3
- package/.output/server/_ssr/{node-sqlite-dialect-BS2OAFJh.mjs → node-sqlite-dialect-ZOyD6D7F.mjs} +2 -2
- package/.output/server/_ssr/{notifyFns-C9N0QLe3.mjs → notifyFns-BOeYZDRp.mjs} +3 -3
- package/.output/server/_ssr/{notifyFns-C6eyIFZE.mjs → notifyFns-UFZ2j7Fv.mjs} +4 -4
- package/.output/server/_ssr/{router-DIfoLu1r.mjs → router-jnPelPNh.mjs} +28 -28
- package/.output/server/_ssr/{routes-DYJB0rKC.mjs → routes-CMAUcUsZ.mjs} +5 -5
- package/.output/server/_ssr/{routes-bWgX0tRE.mjs → routes-CXnbFjB_.mjs} +4 -4
- package/.output/server/_ssr/runDiff-CDPvl_cY.mjs +2 -0
- package/.output/server/_ssr/ssr.mjs +48 -48
- package/.output/server/_ssr/store-DDOk2Ty_.mjs +2 -0
- package/.output/server/_ssr/{t._teamId-C_KZZ4Xh.mjs → t._teamId-36z-mmyw.mjs} +5 -5
- package/.output/server/_ssr/{t._teamId-B_ieXBNF.mjs → t._teamId-Bsm4WrJl.mjs} +4 -4
- package/.output/server/_ssr/{teamFns-O3ZmtZL2.mjs → teamFns-DAx4a1z4.mjs} +3 -3
- package/.output/server/_ssr/{tokens-DI_pklQB.mjs → tokens-7KEKpLnu.mjs} +1 -1
- package/.output/server/{_tanstack-start-manifest_v-DKnfwHZr.mjs → _tanstack-start-manifest_v-5iQOchGB.mjs} +16 -16
- package/.output/server/drizzle/0016_plural_machine_runs.sql +4 -0
- package/.output/server/drizzle/meta/_journal.json +7 -0
- package/.output/server/index.mjs +105 -105
- package/drizzle/0016_plural_machine_runs.sql +4 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
- package/.output/server/_ssr/artifacts-DzWJrBxK.mjs +0 -2
- package/.output/server/_ssr/db-BF8vSovA.mjs +0 -2
- package/.output/server/_ssr/logger-C7aewtve.mjs +0 -2
- package/.output/server/_ssr/runDiff-B9t7ouYj.mjs +0 -2
- package/.output/server/_ssr/store-Dw4LiFjE.mjs +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as getArtifactFile, Kt as safeRelPath, U as getArtifactSync, yt as listArtifactsWithMeta } from "./boot-
|
|
2
|
-
import { t as toArtifactSummary } from "./adapters-
|
|
3
|
-
//#region node_modules/.nitro/vite/services/ssr/assets/artifactFiles-
|
|
1
|
+
import { H as getArtifactFile, Kt as safeRelPath, U as getArtifactSync, yt as listArtifactsWithMeta } from "./boot-DPoPmSLh.mjs";
|
|
2
|
+
import { t as toArtifactSummary } from "./adapters-Bwuh6uek.mjs";
|
|
3
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/artifactFiles-Cp1IBHne.js
|
|
4
4
|
/**
|
|
5
5
|
* Server-side reads over a loop's live-synced artifacts (Phase 2). Pure helpers
|
|
6
6
|
* (no request/session context) so they're shared by the lazy server fns
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as sql, C as or, S as notInArray, _ as isNull$1, b as lte, c as asc, d as eq, f as gt, g as isNotNull, h as inArray, l as desc, m as ilike, o as count, p as gte, u as and, v as like, x as ne, y as lt } from "../_libs/drizzle-orm+postgres.mjs";
|
|
2
|
-
import { At as loginGateEnabled, Ft as normalizePathname, G as getBooleanEnvVar, Gt as resolveBaseURL, J as getEnvVar, M as defu, R as ensureTeam, T as createDefu, W as getBaseURL, X as getHost, Zt as teamIdForUser, _t as isTest, a as BetterAuthError, an as wildcardMatch, ct as isDynamicBaseURLConfig, dt as isProduction, et as getOrigin, ft as isRequestLike, gt as isTeamMember, h as betterFetch, j as db, l as ENV, n as APIError$1, o as BetterCallError, p as ValidationError$1, r as BASE_ERROR_CODES, st as isDevelopment, t as APIError, tt as getProtocol, v as capitalizeFirstLetter, vt as kAPIErrorHeaderSymbol, z as env } from "./boot-
|
|
3
|
-
import { C as withSpan, S as shouldPublishLog, _ as logger, a as __getBetterAuthGlobal, b as runWithTransaction, c as createRandomStringGenerator, d as getAuthTables, f as getBetterAuthVersion, g as initGetModelName, h as initGetFieldName, l as generateId$2, m as import_src, n as ATTR_HOOK_TYPE, o as createAdapterFactory, p as getCurrentAdapter, r as ATTR_OPERATION_ID, s as createLogger, t as ATTR_CONTEXT, u as getAsyncLocalStorage, v as queueAfterTransactionHook, x as safeJSONParse, y as runWithAdapter } from "./factory-
|
|
2
|
+
import { At as loginGateEnabled, Ft as normalizePathname, G as getBooleanEnvVar, Gt as resolveBaseURL, J as getEnvVar, M as defu, R as ensureTeam, T as createDefu, W as getBaseURL, X as getHost, Zt as teamIdForUser, _t as isTest, a as BetterAuthError, an as wildcardMatch, ct as isDynamicBaseURLConfig, dt as isProduction, et as getOrigin, ft as isRequestLike, gt as isTeamMember, h as betterFetch, j as db, l as ENV, n as APIError$1, o as BetterCallError, p as ValidationError$1, r as BASE_ERROR_CODES, st as isDevelopment, t as APIError, tt as getProtocol, v as capitalizeFirstLetter, vt as kAPIErrorHeaderSymbol, z as env } from "./boot-DPoPmSLh.mjs";
|
|
3
|
+
import { C as withSpan, S as shouldPublishLog, _ as logger, a as __getBetterAuthGlobal, b as runWithTransaction, c as createRandomStringGenerator, d as getAuthTables, f as getBetterAuthVersion, g as initGetModelName, h as initGetFieldName, l as generateId$2, m as import_src, n as ATTR_HOOK_TYPE, o as createAdapterFactory, p as getCurrentAdapter, r as ATTR_OPERATION_ID, s as createLogger, t as ATTR_CONTEXT, u as getAsyncLocalStorage, v as queueAfterTransactionHook, x as safeJSONParse, y as runWithAdapter } from "./factory-BtqxMS8a.mjs";
|
|
4
4
|
import { randomBytes, scrypt } from "node:crypto";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
@@ -1700,7 +1700,7 @@ var JOIN_TYPE_SQL = freeze({
|
|
|
1700
1700
|
Using: "using"
|
|
1701
1701
|
});
|
|
1702
1702
|
//#endregion
|
|
1703
|
-
//#region node_modules/.nitro/vite/services/ssr/assets/auth-
|
|
1703
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/auth-uQ19WsD1.js
|
|
1704
1704
|
/**
|
|
1705
1705
|
* @internal
|
|
1706
1706
|
*/
|
|
@@ -15993,7 +15993,7 @@ var createKyselyAdapter = async (config) => {
|
|
|
15993
15993
|
if ("getConnection" in db) dialect = new MysqlDialect(db);
|
|
15994
15994
|
if ("connect" in db) dialect = new PostgresDialect({ pool: db });
|
|
15995
15995
|
if ("fileControl" in db) {
|
|
15996
|
-
const { BunSqliteDialect } = await import("./bun-sqlite-dialect-BW9W1_Ps-
|
|
15996
|
+
const { BunSqliteDialect } = await import("./bun-sqlite-dialect-BW9W1_Ps-CqcLCApi.mjs");
|
|
15997
15997
|
dialect = new BunSqliteDialect({ database: db });
|
|
15998
15998
|
}
|
|
15999
15999
|
if ("createSession" in db) {
|
|
@@ -16009,12 +16009,12 @@ var createKyselyAdapter = async (config) => {
|
|
|
16009
16009
|
if (error !== null && typeof error === "object" && "code" in error && error.code !== "ERR_UNKNOWN_BUILTIN_MODULE") throw error;
|
|
16010
16010
|
}
|
|
16011
16011
|
if (DatabaseSync && db instanceof DatabaseSync) {
|
|
16012
|
-
const { NodeSqliteDialect } = await import("./node-sqlite-dialect-
|
|
16012
|
+
const { NodeSqliteDialect } = await import("./node-sqlite-dialect-ZOyD6D7F.mjs");
|
|
16013
16013
|
dialect = new NodeSqliteDialect({ database: db });
|
|
16014
16014
|
}
|
|
16015
16015
|
}
|
|
16016
16016
|
if ("batch" in db && "exec" in db && "prepare" in db) {
|
|
16017
|
-
const { D1SqliteDialect } = await import("./d1-sqlite-dialect-BLC8LXE6-
|
|
16017
|
+
const { D1SqliteDialect } = await import("./d1-sqlite-dialect-BLC8LXE6-AuWb61y8.mjs");
|
|
16018
16018
|
dialect = new D1SqliteDialect({ database: db });
|
|
16019
16019
|
}
|
|
16020
16020
|
return {
|
|
@@ -36526,7 +36526,7 @@ async function getBaseAdapter(options, handleDirectDatabase) {
|
|
|
36526
36526
|
acc[key] = [];
|
|
36527
36527
|
return acc;
|
|
36528
36528
|
}, {});
|
|
36529
|
-
const { memoryAdapter } = await import("./dist-
|
|
36529
|
+
const { memoryAdapter } = await import("./dist-CtYTvPCD.mjs");
|
|
36530
36530
|
adapter = memoryAdapter(memoryDB)(options);
|
|
36531
36531
|
} else if (typeof options.database === "function") adapter = options.database(options);
|
|
36532
36532
|
else adapter = await handleDirectDatabase(options);
|
|
@@ -36540,10 +36540,10 @@ async function getBaseAdapter(options, handleDirectDatabase) {
|
|
|
36540
36540
|
}
|
|
36541
36541
|
async function getAdapter(options) {
|
|
36542
36542
|
return getBaseAdapter(options, async (opts) => {
|
|
36543
|
-
const { createKyselyAdapter } = await import("./kysely-adapter-
|
|
36543
|
+
const { createKyselyAdapter } = await import("./kysely-adapter-bSpTlW7Z.mjs");
|
|
36544
36544
|
const { kysely, databaseType, transaction } = await createKyselyAdapter(opts);
|
|
36545
36545
|
if (!kysely) throw new BetterAuthError("Failed to initialize database adapter");
|
|
36546
|
-
const { kyselyAdapter } = await import("./kysely-adapter-
|
|
36546
|
+
const { kyselyAdapter } = await import("./kysely-adapter-bSpTlW7Z.mjs");
|
|
36547
36547
|
return kyselyAdapter(kysely, {
|
|
36548
36548
|
type: databaseType || "sqlite",
|
|
36549
36549
|
debugLogs: opts.database && "debugLogs" in opts.database ? opts.database.debugLogs : false,
|
|
@@ -13,7 +13,7 @@ import os from "node:os";
|
|
|
13
13
|
import fs$1 from "node:fs/promises";
|
|
14
14
|
import { lookup } from "node:dns/promises";
|
|
15
15
|
import { isIP } from "node:net";
|
|
16
|
-
//#region node_modules/.nitro/vite/services/ssr/assets/boot-
|
|
16
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/boot-DPoPmSLh.js
|
|
17
17
|
var import_pino = /* @__PURE__ */ __toESM(require_pino());
|
|
18
18
|
var import_pino_pretty = /* @__PURE__ */ __toESM(require_pino_pretty());
|
|
19
19
|
function defineErrorCodes(codes) {
|
|
@@ -1663,7 +1663,7 @@ var runs = pgTable("runs", {
|
|
|
1663
1663
|
uniqueIndex("runs_loop_run_index_idx").on(t.loopId, t.runIndex).where(sql`${t.runIndex} IS NOT NULL`),
|
|
1664
1664
|
index("runs_loop_terminal_history_idx").on(t.loopId, t.runIndex).where(sql`${t.runIndex} IS NOT NULL AND ${t.phase} IN ('done', 'error', 'canceled')`),
|
|
1665
1665
|
uniqueIndex("runs_loop_role_pending_idx").on(t.loopId, t.role).where(sql`${t.phase} = 'pending'`),
|
|
1666
|
-
uniqueIndex("
|
|
1666
|
+
uniqueIndex("one_running_run_per_loop").on(t.loopId).where(sql`${t.phase} = 'running'`)
|
|
1667
1667
|
]);
|
|
1668
1668
|
var runLeases = pgTable("run_leases", {
|
|
1669
1669
|
/** sha256 hex of the full wire token (`rk_…`, or a pre-Batch-6 bare UUID). */
|
|
@@ -2466,8 +2466,11 @@ async function terminalLifecycleTx(tx, currentLoop, run, terminalAt, loopPatch =
|
|
|
2466
2466
|
async function getRun(id) {
|
|
2467
2467
|
return (await db.select().from(runs).where(eq(runs.id, id)))[0];
|
|
2468
2468
|
}
|
|
2469
|
-
async function
|
|
2470
|
-
return
|
|
2469
|
+
async function runningRunsForMachine(machineId) {
|
|
2470
|
+
return db.select().from(runs).where(and(eq(runs.machineId, machineId), eq(runs.phase, "running"))).orderBy(asc(runs.createdAt), asc(runs.id));
|
|
2471
|
+
}
|
|
2472
|
+
async function runningRunForLoop(loopId) {
|
|
2473
|
+
return (await db.select().from(runs).where(and(eq(runs.loopId, loopId), eq(runs.phase, "running"))).limit(1))[0];
|
|
2471
2474
|
}
|
|
2472
2475
|
async function getReportReceipt(reportId) {
|
|
2473
2476
|
return (await db.select().from(runReportReceipts).where(eq(runReportReceipts.reportId, reportId)))[0];
|
|
@@ -2892,24 +2895,29 @@ async function initializeCronCadence(at = nowIso$1()) {
|
|
|
2892
2895
|
}
|
|
2893
2896
|
return initialized;
|
|
2894
2897
|
}
|
|
2895
|
-
/** Claim
|
|
2896
|
-
*
|
|
2897
|
-
*
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
const tokenHash = createHash("sha256").update(runToken).digest("hex");
|
|
2898
|
+
/** Claim one ready loop and mint its lease atomically. Repeated polls may add
|
|
2899
|
+
* unlimited cross-loop concurrency; the loop index remains the final same-loop
|
|
2900
|
+
* serialization invariant. Reported local runs exclude their loops even if the
|
|
2901
|
+
* server has already terminalized an older process. */
|
|
2902
|
+
async function claimReadyRunForMachine(machineId, at = nowIso$1(), excludeRunIds = []) {
|
|
2901
2903
|
return db.transaction(async (tx) => {
|
|
2902
2904
|
if (!(await tx.select({ id: machines.id }).from(machines).where(eq(machines.id, machineId)).for("update"))[0]) return void 0;
|
|
2903
|
-
|
|
2904
|
-
if (
|
|
2905
|
+
const excludedLoops = /* @__PURE__ */ new Set();
|
|
2906
|
+
if (excludeRunIds.length) {
|
|
2907
|
+
const rows = await tx.select({ loopId: runs.loopId }).from(runs).where(and(eq(runs.machineId, machineId), inArray(runs.id, [...new Set(excludeRunIds)])));
|
|
2908
|
+
for (const row of rows) excludedLoops.add(row.loopId);
|
|
2909
|
+
}
|
|
2905
2910
|
const next = (await tx.select({
|
|
2906
2911
|
run: runs,
|
|
2907
2912
|
loop: loops
|
|
2908
|
-
}).from(runs).innerJoin(loops, eq(loops.id, runs.loopId)).where(and(eq(runs.machineId, machineId), eq(runs.phase, "pending"), isNull(runs.cancelRequestedAt), or(eq(loops.enabled, true), eq(runs.requestedBy, "owner")), isNull(loops.deleteRequestedAt))).orderBy(sql`case ${runs.role} when 'steer' then 0 when 'evolve' then 1 else 2 end`, asc(runs.createdAt)).limit(1))[0];
|
|
2913
|
+
}).from(runs).innerJoin(loops, eq(loops.id, runs.loopId)).where(and(eq(runs.machineId, machineId), eq(runs.phase, "pending"), isNull(runs.cancelRequestedAt), or(eq(loops.enabled, true), eq(runs.requestedBy, "owner")), isNull(loops.deleteRequestedAt), excludedLoops.size ? notInArray(loops.id, [...excludedLoops]) : void 0, sql`not exists (select 1 from runs occupied where occupied.loop_id = ${loops.id} and occupied.phase = 'running')`, sql`not exists (select 1 from run_leases authority where authority.loop_id = ${loops.id} and (authority.state = 'active' or (authority.state = 'terminal-grace' and authority.expires_at > ${at})))`)).orderBy(sql`case ${runs.role} when 'steer' then 0 when 'evolve' then 1 else 2 end`, asc(runs.createdAt), asc(runs.id)).limit(1))[0];
|
|
2909
2914
|
if (!next) return void 0;
|
|
2910
2915
|
let loop = (await tx.select().from(loops).where(eq(loops.id, next.loop.id)).for("update"))[0];
|
|
2911
2916
|
const candidate = (await tx.select().from(runs).where(eq(runs.id, next.run.id)).limit(1).for("update"))[0];
|
|
2912
2917
|
if (!loop || !candidate || candidate.phase !== "pending" || candidate.cancelRequestedAt || loop.deleteRequestedAt || !loop.enabled && candidate.requestedBy !== "owner") return void 0;
|
|
2918
|
+
const occupied = (await tx.select({ id: runs.id }).from(runs).where(and(eq(runs.loopId, loop.id), eq(runs.phase, "running"))).limit(1))[0];
|
|
2919
|
+
const authority = (await tx.select({ tokenHash: runLeases.tokenHash }).from(runLeases).where(and(eq(runLeases.loopId, loop.id), inArray(runLeases.state, ["active", "terminal-grace"]), or(eq(runLeases.state, "active"), gt(runLeases.expiresAt, at)))).limit(1))[0];
|
|
2920
|
+
if (occupied || authority) return void 0;
|
|
2913
2921
|
const runIndex = await ensureRunIndexTx(tx, candidate);
|
|
2914
2922
|
const run = (await tx.update(runs).set({
|
|
2915
2923
|
phase: "running",
|
|
@@ -2926,6 +2934,8 @@ async function claimReadyRunForMachine(machineId, at = nowIso$1()) {
|
|
|
2926
2934
|
nextCadenceAt: null,
|
|
2927
2935
|
updatedAt: at
|
|
2928
2936
|
}).where(eq(loops.id, loop.id)).returning())[0];
|
|
2937
|
+
const runToken = `rk_${randomBytes(16).toString("hex")}`;
|
|
2938
|
+
const tokenHash = createHash("sha256").update(runToken).digest("hex");
|
|
2929
2939
|
const structural = run.role === "evolve" || run.role === "steer";
|
|
2930
2940
|
await tx.insert(runLeases).values({
|
|
2931
2941
|
tokenHash,
|
|
@@ -2955,15 +2965,6 @@ async function listRuns(loopId, limit = 30) {
|
|
|
2955
2965
|
async function listRunsBefore(loopId, beforeTs, limit = 16) {
|
|
2956
2966
|
return (await db.select().from(runs).where(and(eq(runs.loopId, loopId), lt(runs.ts, beforeTs))).orderBy(desc(runs.ts)).limit(limit)).reverse();
|
|
2957
2967
|
}
|
|
2958
|
-
/** Latest terminal of any role. For a pending row this is the earliest reliable
|
|
2959
|
-
* evidence that a same-loop blocker ended and the daemon could claim again. */
|
|
2960
|
-
async function lastTerminalRunAt(loopId) {
|
|
2961
|
-
return (await db.select({ ts: runs.ts }).from(runs).where(and(eq(runs.loopId, loopId), inArray(runs.phase, [
|
|
2962
|
-
"done",
|
|
2963
|
-
"error",
|
|
2964
|
-
"canceled"
|
|
2965
|
-
]))).orderBy(desc(runs.ts)).limit(1))[0]?.ts ?? null;
|
|
2966
|
-
}
|
|
2967
2968
|
/** Newest scheduled (exec) run for a loop — the last-result anchor that a later
|
|
2968
2969
|
* evolve/steer must never mask. Null ⇒ no exec run yet. */
|
|
2969
2970
|
async function lastExecRun(loopId) {
|
|
@@ -2981,14 +2982,17 @@ async function countRuns(loopId) {
|
|
|
2981
2982
|
async function markPendingRunDeferred(runId, expected, at) {
|
|
2982
2983
|
if (expected.requestedBy !== "system") return void 0;
|
|
2983
2984
|
return db.transaction(async (tx) => {
|
|
2984
|
-
const observed = (await tx.select({
|
|
2985
|
+
const observed = (await tx.select({
|
|
2986
|
+
loopId: runs.loopId,
|
|
2987
|
+
machineId: runs.machineId
|
|
2988
|
+
}).from(runs).where(eq(runs.id, runId)).limit(1))[0];
|
|
2985
2989
|
if (!observed) return void 0;
|
|
2990
|
+
const machine = (await tx.select({ online: machines.online }).from(machines).where(eq(machines.id, observed.machineId)).limit(1).for("update"))[0];
|
|
2991
|
+
if (!machine || machine.online) return void 0;
|
|
2986
2992
|
const loop = (await tx.select().from(loops).where(eq(loops.id, observed.loopId)).for("update"))[0];
|
|
2987
2993
|
if (!loop) return void 0;
|
|
2988
2994
|
const current = (await tx.select().from(runs).where(and(eq(runs.id, runId), eq(runs.loopId, loop.id), eq(runs.phase, "pending"), eq(runs.role, "exec"), eq(runs.requestedBy, "system"), eq(runs.updatedAt, expected.updatedAt))).limit(1).for("update"))[0];
|
|
2989
2995
|
if (!current || current.deferredAt) return void 0;
|
|
2990
|
-
const machine = (await tx.select({ online: machines.online }).from(machines).where(eq(machines.id, current.machineId)).limit(1).for("update"))[0];
|
|
2991
|
-
if (!machine || machine.online) return void 0;
|
|
2992
2996
|
return (await tx.update(runs).set({
|
|
2993
2997
|
deferredAt: at,
|
|
2994
2998
|
updatedAt: at
|
|
@@ -3005,41 +3009,6 @@ async function hasRunningRun(loopId) {
|
|
|
3005
3009
|
async function hasPendingRun(loopId) {
|
|
3006
3010
|
return !!(await db.select({ id: runs.id }).from(runs).where(and(eq(runs.loopId, loopId), eq(runs.phase, "pending"))).limit(1))[0];
|
|
3007
3011
|
}
|
|
3008
|
-
/** Recheck a never-claimed pending row from its sweep snapshot under the loop
|
|
3009
|
-
* lock. Coalescing/promotion refreshes updatedAt, so stale sweep work loses the
|
|
3010
|
-
* CAS before it can turn renewed owner intent into an error. */
|
|
3011
|
-
async function reclaimUnclaimedPendingRun(runId, expected, at, timeoutMs, reason, failureAutopauseStreak = 0) {
|
|
3012
|
-
return db.transaction(async (tx) => {
|
|
3013
|
-
const observed = (await tx.select({ loopId: runs.loopId }).from(runs).where(eq(runs.id, runId)).limit(1))[0];
|
|
3014
|
-
if (!observed) return void 0;
|
|
3015
|
-
const loop = (await tx.select().from(loops).where(eq(loops.id, observed.loopId)).for("update"))[0];
|
|
3016
|
-
if (!loop) return void 0;
|
|
3017
|
-
const current = (await tx.select().from(runs).where(and(eq(runs.id, runId), eq(runs.loopId, loop.id), eq(runs.phase, "pending"), eq(runs.requestedBy, expected.requestedBy), eq(runs.updatedAt, expected.updatedAt))).limit(1).for("update"))[0];
|
|
3018
|
-
if (!current) return void 0;
|
|
3019
|
-
if (!(await tx.select({ online: machines.online }).from(machines).where(eq(machines.id, current.machineId)).limit(1))[0]?.online) return void 0;
|
|
3020
|
-
const blocker = (await tx.select({ ts: runs.ts }).from(runs).where(and(eq(runs.loopId, loop.id), inArray(runs.phase, [
|
|
3021
|
-
"done",
|
|
3022
|
-
"error",
|
|
3023
|
-
"canceled"
|
|
3024
|
-
]))).orderBy(desc(runs.ts)).limit(1))[0];
|
|
3025
|
-
const running = (await tx.select({ id: runs.id }).from(runs).where(and(eq(runs.loopId, loop.id), eq(runs.phase, "running"))).limit(1))[0];
|
|
3026
|
-
const eligibleAt = Math.max(Date.parse(current.updatedAt), blocker ? Date.parse(blocker.ts) || 0 : 0);
|
|
3027
|
-
if (running || Date.parse(at) - eligibleAt <= timeoutMs) return void 0;
|
|
3028
|
-
const runIndex = await ensureRunIndexTx(tx, current);
|
|
3029
|
-
const reclaimed = (await tx.update(runs).set({
|
|
3030
|
-
phase: "error",
|
|
3031
|
-
runIndex,
|
|
3032
|
-
error: reason,
|
|
3033
|
-
ts: at,
|
|
3034
|
-
updatedAt: at
|
|
3035
|
-
}).where(and(eq(runs.id, runId), eq(runs.phase, "pending"), eq(runs.requestedBy, expected.requestedBy), eq(runs.updatedAt, expected.updatedAt))).returning())[0];
|
|
3036
|
-
if (!reclaimed) return void 0;
|
|
3037
|
-
return {
|
|
3038
|
-
run: reclaimed,
|
|
3039
|
-
...await terminalLifecycleTx(tx, loop, reclaimed, at, {}, false, failureAutopauseStreak)
|
|
3040
|
-
};
|
|
3041
|
-
});
|
|
3042
|
-
}
|
|
3043
3012
|
/** Expire one offline system row only if the sweep snapshot is still exact and
|
|
3044
3013
|
* its immutable lifetime remains over the cap under the loop lock. */
|
|
3045
3014
|
async function expirePendingRun(runId, expected, at, maxLifetimeMs, message) {
|
|
@@ -5367,15 +5336,7 @@ async function schemaKeysInUse(loopId) {
|
|
|
5367
5336
|
}
|
|
5368
5337
|
return [...keys];
|
|
5369
5338
|
}
|
|
5370
|
-
|
|
5371
|
-
* Lowest daemon package version this server may safely dispatch work to.
|
|
5372
|
-
*
|
|
5373
|
-
* Keep this as a coarse package-version gate: if a future server changes the
|
|
5374
|
-
* prompt/CLI/report protocol incompatibly, bump this constant to the matching
|
|
5375
|
-
* daemon release. Unknown versions are treated as incompatible because only
|
|
5376
|
-
* daemons that report a version can be known-safe for breaking protocol changes.
|
|
5377
|
-
*/
|
|
5378
|
-
var MIN_DAEMON_VERSION = "2.0.4";
|
|
5339
|
+
var MIN_DAEMON_VERSION = "2.1.0";
|
|
5379
5340
|
function daemonNeedsUpdate(current, required = MIN_DAEMON_VERSION) {
|
|
5380
5341
|
if (!current) return true;
|
|
5381
5342
|
if (current === required) return false;
|
|
@@ -5453,9 +5414,6 @@ var SESSION_ID_CAP = 200;
|
|
|
5453
5414
|
/** A loop's goal (setpoint) is a one-line, checkable statement — clip generously
|
|
5454
5415
|
* but keep it a single line's worth (not a document). Shared by createLoop/editLoop. */
|
|
5455
5416
|
var GOAL_CAP = 2e3;
|
|
5456
|
-
/** The 2MB machine-body cap is the primary bound; this generous secondary cap
|
|
5457
|
-
* covers machines running thousands of independent loops without query abuse. */
|
|
5458
|
-
var MAX_ACTIVE_RUN_IDS = 5e3;
|
|
5459
5417
|
/** Keep heartbeat throttling safely inside custom short timeout windows. */
|
|
5460
5418
|
function heartbeatRefreshMs(runTimeoutMs) {
|
|
5461
5419
|
if (!Number.isFinite(runTimeoutMs) || runTimeoutMs <= 0) return 1;
|
|
@@ -5700,21 +5658,17 @@ var MachineGateway = class {
|
|
|
5700
5658
|
* A RUNNING run that went silent is reclaimed as timed out; a PENDING run on
|
|
5701
5659
|
* an OFFLINE machine is NOT failed — it is held as a deferred catch-up (the
|
|
5702
5660
|
* pending row is the durable inbox; the daemon's next poll claims it, and later
|
|
5703
|
-
* same-role fires coalesce into it), bounded by DEFERRED_MAX_MS.
|
|
5704
|
-
*
|
|
5661
|
+
* same-role fires coalesce into it), bounded by DEFERRED_MAX_MS while offline.
|
|
5662
|
+
* Online pending rows never synthesize an execution error.
|
|
5705
5663
|
*/
|
|
5706
5664
|
async sweep() {
|
|
5707
5665
|
const now = Date.now();
|
|
5708
5666
|
for (const m of await listMachines()) if (m.online && (!m.lastSeen || now - Date.parse(m.lastSeen) > 3e4)) await updateMachine(m.id, { online: false });
|
|
5709
5667
|
for (const run of await openRuns()) {
|
|
5710
|
-
const blockerAt = run.phase === "pending" ? await lastTerminalRunAt(run.loopId) : null;
|
|
5711
|
-
const age = now - Math.max(Date.parse(run.updatedAt), blockerAt ? Date.parse(blockerAt) || 0 : 0);
|
|
5712
5668
|
const pendingLifetime = now - Date.parse(run.createdAt);
|
|
5713
5669
|
if (run.phase === "pending") {
|
|
5714
5670
|
const machine = await getMachine(run.machineId);
|
|
5715
|
-
if (machine?.online) {
|
|
5716
|
-
if (!await hasRunningRun(run.loopId) && age > RUN_TIMEOUT_MS) await this.reclaimRun(run, "run never claimed");
|
|
5717
|
-
} else if (run.requestedBy === "system" && pendingLifetime > DEFERRED_MAX_MS) await expirePendingRun(run.id, {
|
|
5671
|
+
if (machine?.online) {} else if (run.requestedBy === "system" && pendingLifetime > DEFERRED_MAX_MS) await expirePendingRun(run.id, {
|
|
5718
5672
|
requestedBy: run.requestedBy,
|
|
5719
5673
|
updatedAt: run.updatedAt
|
|
5720
5674
|
}, nowIso(), DEFERRED_MAX_MS, "skipped - the machine stayed offline past the catch-up window");
|
|
@@ -5745,15 +5699,12 @@ var MachineGateway = class {
|
|
|
5745
5699
|
* (`TERMINAL_GRACE_MS`) during which exactly ONE late wake-report may reconcile
|
|
5746
5700
|
* the run — see `report()`'s terminal-grace branch. The credential is still
|
|
5747
5701
|
* bounded: agent-api mutations are refused while terminal-grace, and the
|
|
5748
|
-
* reconciliation retires the lease single-shot.
|
|
5749
|
-
*
|
|
5702
|
+
* reconciliation retires the lease single-shot. Pending rows are durable inbox
|
|
5703
|
+
* entries and are never reclaimed by this path. */
|
|
5750
5704
|
async reclaimRun(run, reason) {
|
|
5751
|
-
if (run.phase !== "
|
|
5705
|
+
if (run.phase !== "running") return;
|
|
5752
5706
|
const at = nowIso();
|
|
5753
|
-
const reclaimed = run.
|
|
5754
|
-
requestedBy: run.requestedBy,
|
|
5755
|
-
updatedAt: run.updatedAt
|
|
5756
|
-
}, at, RUN_TIMEOUT_MS, reason, AUTOPAUSE_STREAK) : await reclaimRun(run.id, "running", reason, at, TERMINAL_GRACE_MS);
|
|
5707
|
+
const reclaimed = await reclaimRun(run.id, "running", reason, at, TERMINAL_GRACE_MS);
|
|
5757
5708
|
if (!reclaimed) return;
|
|
5758
5709
|
await this.notifyRunFailure(run.loopId, run.role, reason, reclaimed);
|
|
5759
5710
|
if (reclaimed.loop.enabled) this.scheduler.addLoop(reclaimed.loop);
|
|
@@ -5788,7 +5739,7 @@ var MachineGateway = class {
|
|
|
5788
5739
|
this.maintenanceRunning = false;
|
|
5789
5740
|
}
|
|
5790
5741
|
}
|
|
5791
|
-
async
|
|
5742
|
+
async pollCore(deviceToken, info, currentRunIds, watchDigest, claimWork = true) {
|
|
5792
5743
|
if (!isDeviceTokenShape(deviceToken)) return {
|
|
5793
5744
|
status: 401,
|
|
5794
5745
|
body: { error: "invalid device token" }
|
|
@@ -5835,25 +5786,22 @@ var MachineGateway = class {
|
|
|
5835
5786
|
};
|
|
5836
5787
|
if (Object.keys(patch).length) await updateMachine(machineId, patch);
|
|
5837
5788
|
}
|
|
5838
|
-
if (Array.isArray(
|
|
5789
|
+
if (Array.isArray(currentRunIds)) {
|
|
5839
5790
|
const ids = /* @__PURE__ */ new Set();
|
|
5840
|
-
for (const value of
|
|
5841
|
-
if (typeof value === "string") ids.add(value);
|
|
5842
|
-
if (ids.size >= MAX_ACTIVE_RUN_IDS) break;
|
|
5843
|
-
}
|
|
5791
|
+
for (const value of currentRunIds) if (typeof value === "string") ids.add(value);
|
|
5844
5792
|
if (ids.size) {
|
|
5845
5793
|
const now = Date.now();
|
|
5846
5794
|
await refreshRunHeartbeats(machineId, [...ids], new Date(now).toISOString(), new Date(now - HEARTBEAT_STAMP_REFRESH_MS).toISOString());
|
|
5847
5795
|
}
|
|
5848
5796
|
}
|
|
5849
|
-
|
|
5797
|
+
let delivery = null;
|
|
5850
5798
|
if (claimWork) {
|
|
5851
5799
|
await this.scheduler.advanceDueSchedules(machineId);
|
|
5852
|
-
const claimed = await claimReadyRunForMachine(machineId);
|
|
5853
|
-
if (claimed)
|
|
5800
|
+
const claimed = await claimReadyRunForMachine(machineId, void 0, currentRunIds ?? []);
|
|
5801
|
+
if (claimed) delivery = await buildDelivery(claimed.loop, claimed.run, claimed.runToken, machine.roots ?? []);
|
|
5854
5802
|
}
|
|
5855
5803
|
let cached = this.watchCache.get(machineId);
|
|
5856
|
-
if (!cached ||
|
|
5804
|
+
if (!cached || delivery || Date.now() - cached.at > WATCH_CACHE_TTL_MS) {
|
|
5857
5805
|
const watch = (await loopsForMachine(machineId)).map((l) => ({
|
|
5858
5806
|
loopId: l.id,
|
|
5859
5807
|
workdir: l.workdir ?? null,
|
|
@@ -5866,22 +5814,22 @@ var MachineGateway = class {
|
|
|
5866
5814
|
};
|
|
5867
5815
|
this.watchCache.set(machineId, cached);
|
|
5868
5816
|
}
|
|
5869
|
-
if (
|
|
5817
|
+
if (delivery) log$2.info({
|
|
5870
5818
|
machineId,
|
|
5871
|
-
|
|
5819
|
+
runId: delivery.runId
|
|
5872
5820
|
}, "poll: delivered");
|
|
5873
5821
|
return {
|
|
5874
5822
|
status: 200,
|
|
5875
5823
|
body: {
|
|
5876
|
-
|
|
5824
|
+
delivery,
|
|
5877
5825
|
watchDigest: cached.digest,
|
|
5878
5826
|
...watchDigest === cached.digest ? {} : { watch: cached.watch }
|
|
5879
5827
|
}
|
|
5880
5828
|
};
|
|
5881
5829
|
}
|
|
5882
|
-
/**
|
|
5883
|
-
async
|
|
5884
|
-
if (request.protocolVersion !==
|
|
5830
|
+
/** Protocol-v3 poll: plural local state, one new delivery per poll. */
|
|
5831
|
+
async pollV3(deviceToken, request) {
|
|
5832
|
+
if (request.protocolVersion !== 3) {
|
|
5885
5833
|
if (isDeviceTokenShape(deviceToken)) {
|
|
5886
5834
|
const machineId = machineIdFromToken(deviceToken);
|
|
5887
5835
|
if ((await getMachine(machineId))?.tokenHash === sha256(deviceToken)) await updateMachine(machineId, { daemonProtocol: typeof request.protocolVersion === "number" && Number.isInteger(request.protocolVersion) ? request.protocolVersion : null });
|
|
@@ -5891,89 +5839,58 @@ var MachineGateway = class {
|
|
|
5891
5839
|
body: {
|
|
5892
5840
|
error: "daemon upgrade required; run `npm install -g @kky42/pievo@latest`, then `pievo daemon restart`",
|
|
5893
5841
|
code: "UPGRADE_REQUIRED",
|
|
5894
|
-
requiredProtocol:
|
|
5842
|
+
requiredProtocol: 3
|
|
5895
5843
|
}
|
|
5896
5844
|
};
|
|
5897
5845
|
}
|
|
5898
|
-
const
|
|
5899
|
-
if (
|
|
5846
|
+
const validCurrent = (value) => typeof value?.runId === "string" && ["executing", "reporting"].includes(value.stage);
|
|
5847
|
+
if (!Array.isArray(request.currentRuns) || request.currentRuns.some((run) => !validCurrent(run))) return {
|
|
5900
5848
|
status: 400,
|
|
5901
5849
|
body: {
|
|
5902
|
-
error: "invalid
|
|
5850
|
+
error: "invalid currentRuns",
|
|
5903
5851
|
code: "VALIDATION_ERROR"
|
|
5904
5852
|
}
|
|
5905
5853
|
};
|
|
5854
|
+
const currentIds = [...new Set(request.currentRuns.map((run) => run.runId))];
|
|
5906
5855
|
const machineId = isDeviceTokenShape(deviceToken) ? machineIdFromToken(deviceToken) : "";
|
|
5907
5856
|
const priorMachine = machineId ? await getMachine(machineId) : void 0;
|
|
5908
5857
|
const reportedVersion = typeof request.info?.version === "string" ? clipText(request.info.version, 64) : priorMachine?.daemonVersion;
|
|
5909
5858
|
const needsUpdate = daemonNeedsUpdate(reportedVersion);
|
|
5910
|
-
const base = await this.
|
|
5859
|
+
const base = await this.pollCore(deviceToken, request.info, currentIds, request.watchDigest, !needsUpdate);
|
|
5911
5860
|
if (base.status !== 200) return base;
|
|
5912
|
-
if ((await getMachine(machineId))?.daemonProtocol !==
|
|
5913
|
-
const running = await
|
|
5861
|
+
if ((await getMachine(machineId))?.daemonProtocol !== 3) await updateMachine(machineId, { daemonProtocol: 3 });
|
|
5862
|
+
const running = await runningRunsForMachine(machineId);
|
|
5863
|
+
const currentSet = new Set(currentIds);
|
|
5914
5864
|
const body = base.body;
|
|
5915
|
-
const cancelRunId = current && running?.id === current.runId && running.cancelRequestedAt ? current.runId : void 0;
|
|
5916
5865
|
return {
|
|
5917
5866
|
status: 200,
|
|
5918
5867
|
body: {
|
|
5919
|
-
delivery:
|
|
5868
|
+
delivery: body.delivery,
|
|
5869
|
+
cancelRunIds: running.filter((run) => currentSet.has(run.id) && run.cancelRequestedAt).map((run) => run.id),
|
|
5920
5870
|
...needsUpdate ? { needsUpdate: {
|
|
5921
5871
|
current: reportedVersion ?? null,
|
|
5922
5872
|
required: MIN_DAEMON_VERSION,
|
|
5923
5873
|
command: daemonUpgradeCommand()
|
|
5924
5874
|
} } : {},
|
|
5925
|
-
...cancelRunId ? { cancelRunId } : {},
|
|
5926
|
-
...current && running && current.runId !== running.id ? { runConflict: {
|
|
5927
|
-
daemonRunId: current.runId,
|
|
5928
|
-
serverRunId: running.id
|
|
5929
|
-
} } : {},
|
|
5930
|
-
...!current && running && !body.deliveries.length ? { blockedRunId: running.id } : {},
|
|
5931
5875
|
watchDigest: body.watchDigest,
|
|
5932
5876
|
...body.watch ? { watch: body.watch } : {}
|
|
5933
5877
|
}
|
|
5934
5878
|
};
|
|
5935
5879
|
}
|
|
5936
|
-
/**
|
|
5937
|
-
async
|
|
5938
|
-
if (request.
|
|
5880
|
+
/** Idle v3 polls long-poll; active/reporting polls return immediately. */
|
|
5881
|
+
async pollV3Wait(deviceToken, request, waitMs = LONG_POLL_WAIT_MS) {
|
|
5882
|
+
if (request.currentRuns?.length || request.protocolVersion !== 3) return this.pollV3(deviceToken, request);
|
|
5939
5883
|
const machineId = machineIdFromToken(deviceToken);
|
|
5940
5884
|
const waiter = this.armPollWaiter(machineId, Math.min(Math.max(waitMs, 0), LONG_POLL_WAIT_MS));
|
|
5941
5885
|
try {
|
|
5942
|
-
const first = await this.
|
|
5886
|
+
const first = await this.pollV3(deviceToken, request);
|
|
5943
5887
|
if (first.status !== 200) return first;
|
|
5944
|
-
|
|
5945
|
-
if (body.delivery || body.blockedRunId) return first;
|
|
5888
|
+
if (first.body.delivery) return first;
|
|
5946
5889
|
if (!await waiter.promise) {
|
|
5947
5890
|
await setMachineOnline(machineId, true);
|
|
5948
5891
|
return first;
|
|
5949
5892
|
}
|
|
5950
|
-
return this.
|
|
5951
|
-
} finally {
|
|
5952
|
-
waiter.cancel();
|
|
5953
|
-
}
|
|
5954
|
-
}
|
|
5955
|
-
/**
|
|
5956
|
-
* Legacy long-poll wrapper over `poll()`: when the daemon opted in (`wait:true`) and
|
|
5957
|
-
* the immediate pass claimed nothing, park the request on the machine's waiter
|
|
5958
|
-
* until the Dispatcher wakes it (a run went pending) or the bounded window
|
|
5959
|
-
* elapses, then re-claim. Old daemons never send `wait` and keep the classic
|
|
5960
|
-
* instant response. The waiter is armed BEFORE the first claim pass, so a run
|
|
5961
|
-
* that goes pending while the pass is in flight can never slip past the park.
|
|
5962
|
-
*/
|
|
5963
|
-
async pollWait(deviceToken, info, activeRunIds, opts) {
|
|
5964
|
-
if (!opts?.wait) return this.poll(deviceToken, info, activeRunIds, opts?.watchDigest);
|
|
5965
|
-
const machineId = machineIdFromToken(deviceToken);
|
|
5966
|
-
const waitMs = Math.min(Math.max(opts.waitMs ?? LONG_POLL_WAIT_MS, 0), LONG_POLL_WAIT_MS);
|
|
5967
|
-
const waiter = this.armPollWaiter(machineId, waitMs);
|
|
5968
|
-
try {
|
|
5969
|
-
const first = await this.poll(deviceToken, info, activeRunIds, opts.watchDigest);
|
|
5970
|
-
if (first.status !== 200) return first;
|
|
5971
|
-
if (first.body.deliveries.length) return first;
|
|
5972
|
-
if (!await waiter.promise) {
|
|
5973
|
-
await setMachineOnline(machineId, true);
|
|
5974
|
-
return first;
|
|
5975
|
-
}
|
|
5976
|
-
return await this.poll(deviceToken, void 0, void 0, opts.watchDigest);
|
|
5893
|
+
return this.pollV3(deviceToken, request);
|
|
5977
5894
|
} finally {
|
|
5978
5895
|
waiter.cancel();
|
|
5979
5896
|
}
|
|
@@ -5997,7 +5914,11 @@ var MachineGateway = class {
|
|
|
5997
5914
|
};
|
|
5998
5915
|
const fresh = !!machine.lastSeen && Date.now() - Date.parse(machine.lastSeen) < 3e4;
|
|
5999
5916
|
const online = !!machine.online && fresh;
|
|
6000
|
-
const
|
|
5917
|
+
const currentRuns = (await runningRunsForMachine(machineId)).map((run) => ({
|
|
5918
|
+
runId: run.id,
|
|
5919
|
+
stage: "executing",
|
|
5920
|
+
cancelPending: run.cancelRequestedAt != null
|
|
5921
|
+
}));
|
|
6001
5922
|
return {
|
|
6002
5923
|
status: 200,
|
|
6003
5924
|
body: {
|
|
@@ -6005,14 +5926,7 @@ var MachineGateway = class {
|
|
|
6005
5926
|
name: machine.name || null,
|
|
6006
5927
|
lastSeen: machine.lastSeen ?? null,
|
|
6007
5928
|
daemonProtocol: machine.daemonProtocol ?? null,
|
|
6008
|
-
|
|
6009
|
-
...online ? { currentRun: {
|
|
6010
|
-
runId: running.id,
|
|
6011
|
-
stage: "executing",
|
|
6012
|
-
cancelPending: running.cancelRequestedAt != null
|
|
6013
|
-
} } : { blockedRunId: running.id },
|
|
6014
|
-
...running.cancelRequestedAt ? { cancelPending: true } : {}
|
|
6015
|
-
} : {}
|
|
5929
|
+
currentRuns: online ? currentRuns : []
|
|
6016
5930
|
}
|
|
6017
5931
|
};
|
|
6018
5932
|
}
|
|
@@ -8630,7 +8544,7 @@ var CliGateway = class {
|
|
|
8630
8544
|
}
|
|
8631
8545
|
async requireStopProtocol(machineId, running) {
|
|
8632
8546
|
if (!running) return void 0;
|
|
8633
|
-
if ((await getMachine(machineId))?.daemonProtocol ===
|
|
8547
|
+
if ((await getMachine(machineId))?.daemonProtocol === 3) return void 0;
|
|
8634
8548
|
return {
|
|
8635
8549
|
status: 426,
|
|
8636
8550
|
body: {
|
|
@@ -8645,8 +8559,7 @@ var CliGateway = class {
|
|
|
8645
8559
|
status: 404,
|
|
8646
8560
|
body: { error: "no such loop on this machine" }
|
|
8647
8561
|
};
|
|
8648
|
-
const
|
|
8649
|
-
const target = running?.loopId === loop.id ? running : void 0;
|
|
8562
|
+
const target = await runningRunForLoop(loop.id);
|
|
8650
8563
|
const upgrade = await this.requireStopProtocol(machineId, target);
|
|
8651
8564
|
if (upgrade) return upgrade;
|
|
8652
8565
|
const result = await stopLoop(loop.id);
|
|
@@ -8700,8 +8613,7 @@ var CliGateway = class {
|
|
|
8700
8613
|
body: { text: forceDeleteWarning(reachability) }
|
|
8701
8614
|
};
|
|
8702
8615
|
}
|
|
8703
|
-
const
|
|
8704
|
-
const target = running?.loopId === loop.id ? running : void 0;
|
|
8616
|
+
const target = await runningRunForLoop(loop.id);
|
|
8705
8617
|
const upgrade = await this.requireStopProtocol(machineId, target);
|
|
8706
8618
|
if (upgrade) return upgrade;
|
|
8707
8619
|
const result = await requestDeleteLoop(loop.id);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { U as getArtifactSync, Y as getGateway, q as getCliGateway } from "./boot-
|
|
1
|
+
import { U as getArtifactSync, Y as getGateway, q as getCliGateway } from "./boot-DPoPmSLh.mjs";
|
|
2
2
|
export { getArtifactSync, getCliGateway, getGateway };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as DefaultQueryCompiler, o as CompiledQuery, s as sql$1 } from "./auth-
|
|
1
|
+
import { n as DefaultQueryCompiler, o as CompiledQuery, s as sql$1 } from "./auth-uQ19WsD1.mjs";
|
|
2
2
|
import { n as DEFAULT_MIGRATION_TABLE, t as DEFAULT_MIGRATION_LOCK_TABLE } from "./kysely-migration-tables-JkVUjPF_-bPAX9LR_.mjs";
|
|
3
|
-
//#region node_modules/.nitro/vite/services/ssr/assets/bun-sqlite-dialect-BW9W1_Ps-
|
|
3
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/bun-sqlite-dialect-BW9W1_Ps-CqcLCApi.js
|
|
4
4
|
var BunSqliteAdapter = class {
|
|
5
5
|
get supportsCreateIfNotExists() {
|
|
6
6
|
return true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as SqliteQueryCompiler, i as SqliteAdapter } from "./auth-
|
|
1
|
+
import { a as SqliteQueryCompiler, i as SqliteAdapter } from "./auth-uQ19WsD1.mjs";
|
|
2
2
|
import { n as DEFAULT_MIGRATION_TABLE, t as DEFAULT_MIGRATION_LOCK_TABLE } from "./kysely-migration-tables-JkVUjPF_-bPAX9LR_.mjs";
|
|
3
|
-
//#region node_modules/.nitro/vite/services/ssr/assets/d1-sqlite-dialect-BLC8LXE6-
|
|
3
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/d1-sqlite-dialect-BLC8LXE6-AuWb61y8.js
|
|
4
4
|
var D1SqliteAdapter = class extends SqliteAdapter {};
|
|
5
5
|
var D1SqliteDriver = class {
|
|
6
6
|
#config;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as logger, o as createAdapterFactory } from "./factory-
|
|
2
|
-
//#region node_modules/.nitro/vite/services/ssr/assets/dist-
|
|
1
|
+
import { _ as logger, o as createAdapterFactory } from "./factory-BtqxMS8a.mjs";
|
|
2
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/dist-CtYTvPCD.js
|
|
3
3
|
/**
|
|
4
4
|
* Case-insensitive in-memory comparison helpers.
|
|
5
5
|
* Used when evaluating where clauses in the memory adapter.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { J as getEnvVar, a as BetterAuthError, z as env } from "./boot-
|
|
2
|
-
//#region node_modules/.nitro/vite/services/ssr/assets/factory-
|
|
1
|
+
import { J as getEnvVar, a as BetterAuthError, z as env } from "./boot-DPoPmSLh.mjs";
|
|
2
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/factory-BtqxMS8a.js
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
5
5
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -2,12 +2,12 @@ import { o as __toESM } from "../_runtime.mjs";
|
|
|
2
2
|
import { g as require_jsx_runtime, h as require_react } from "../_libs/@base-ui/react+[...].mjs";
|
|
3
3
|
import { l as btnPrimary } from "./ui-B6mE5-5v.mjs";
|
|
4
4
|
import { d as useNavigate } from "../_libs/@tanstack/react-router+[...].mjs";
|
|
5
|
-
import { i as PievoLogo, s as useSession } from "./LoopPlaybook-
|
|
5
|
+
import { i as PievoLogo, s as useSession } from "./LoopPlaybook-WFNer22Y.mjs";
|
|
6
6
|
import { t as setActiveTeamCookie } from "./teamCookie-B7hLOIie.mjs";
|
|
7
7
|
import { c as redeemTeamInvite } from "./teamFns-BBIbatdZ.mjs";
|
|
8
|
-
import { t as Route } from "./invite._token-
|
|
9
|
-
import { t as SignIn } from "./SignIn-
|
|
10
|
-
//#region node_modules/.nitro/vite/services/ssr/assets/invite._token-
|
|
8
|
+
import { t as Route } from "./invite._token-DtAfQyfP.mjs";
|
|
9
|
+
import { t as SignIn } from "./SignIn-2qr-vtR5.mjs";
|
|
10
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/invite._token-DBttmaDb.js
|
|
11
11
|
var import_react = /* @__PURE__ */ __toESM(require_react());
|
|
12
12
|
var import_jsx_runtime = require_jsx_runtime();
|
|
13
13
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { c as createFileRoute, s as lazyRouteComponent } from "../_libs/@tanstack/react-router+[...].mjs";
|
|
2
2
|
import { c as getAuthState } from "./loopApi-7MTSs6hy.mjs";
|
|
3
|
-
import { a as authClient } from "./LoopPlaybook-
|
|
4
|
-
//#region node_modules/.nitro/vite/services/ssr/assets/invite._token-
|
|
3
|
+
import { a as authClient } from "./LoopPlaybook-WFNer22Y.mjs";
|
|
4
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/invite._token-DtAfQyfP.js
|
|
5
5
|
var $$splitErrorComponentImporter = () => import("./invite._token-BlbVjz-o.mjs");
|
|
6
|
-
var $$splitComponentImporter = () => import("./invite._token-
|
|
6
|
+
var $$splitComponentImporter = () => import("./invite._token-DBttmaDb.mjs");
|
|
7
7
|
/**
|
|
8
8
|
* Invite-link redeem (`/invite/<token>`, design §4 option B). The recipient opens
|
|
9
9
|
* the link the owner shared; if signed out (under the gate) they hit the normal
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as kyselyAdapter, t as createKyselyAdapter } from "./auth-
|
|
1
|
+
import { r as kyselyAdapter, t as createKyselyAdapter } from "./auth-uQ19WsD1.mjs";
|
|
2
2
|
export { createKyselyAdapter, kyselyAdapter };
|