@code-partner/codepipe-hub 0.14.1-dev.422.gf90f06c4 → 0.14.1-dev.424.ge3c8cc77
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/hub/dist/embedded.js +66 -9
- package/hub/dist/index.js +513 -178
- package/package.json +1 -1
package/hub/dist/embedded.js
CHANGED
|
@@ -457,7 +457,7 @@ var PLATFORM_VERSION;
|
|
|
457
457
|
var init_version_generated = __esm({
|
|
458
458
|
"../packages/shared/dist/version.generated.js"() {
|
|
459
459
|
"use strict";
|
|
460
|
-
PLATFORM_VERSION = "0.14.1-dev.
|
|
460
|
+
PLATFORM_VERSION = "0.14.1-dev.424.ge3c8cc77";
|
|
461
461
|
}
|
|
462
462
|
});
|
|
463
463
|
|
|
@@ -467,7 +467,7 @@ var init_version = __esm({
|
|
|
467
467
|
"../packages/shared/dist/version.js"() {
|
|
468
468
|
"use strict";
|
|
469
469
|
init_version_generated();
|
|
470
|
-
PROTOCOL_VERSION =
|
|
470
|
+
PROTOCOL_VERSION = 5;
|
|
471
471
|
}
|
|
472
472
|
});
|
|
473
473
|
|
|
@@ -4983,6 +4983,8 @@ function createCommandOperations(deps) {
|
|
|
4983
4983
|
throw errors.unprocessable({ details: { reason: outcome.reason } });
|
|
4984
4984
|
case "not_found":
|
|
4985
4985
|
throw errors.notFound();
|
|
4986
|
+
case "rate_limited":
|
|
4987
|
+
throw errors.rateLimited();
|
|
4986
4988
|
}
|
|
4987
4989
|
}
|
|
4988
4990
|
function accountActorOf(actor) {
|
|
@@ -5572,6 +5574,14 @@ function createCommandOperations(deps) {
|
|
|
5572
5574
|
return { value: run.result, replayed: run.replayed };
|
|
5573
5575
|
});
|
|
5574
5576
|
},
|
|
5577
|
+
async issueWorkerRegistrationToken(actor) {
|
|
5578
|
+
const subjectId = actor.principal.subjectId;
|
|
5579
|
+
return await audited(actor, { operationId: "worker.issueRegistrationToken", aggregateType: "account", aggregateId: subjectId, projectId: null }, async (policy) => {
|
|
5580
|
+
await require2(actor, "account.manage", { type: "account" }, policy);
|
|
5581
|
+
const issued = unwrap(await write2.issueWorkerRegistrationToken({ owner: accountActorOf(actor) }));
|
|
5582
|
+
return { value: { secret: issued.secret, expiresAt: toTimestamp(issued.expiresAt) }, replayed: false };
|
|
5583
|
+
});
|
|
5584
|
+
},
|
|
5575
5585
|
async reportInitStatus(actor, command) {
|
|
5576
5586
|
const { projectId, phase } = command;
|
|
5577
5587
|
return await audited(actor, { operationId: "project.reportInitStatus", aggregateType: "project", aggregateId: projectId, projectId, data: { phase, failed: command.error !== void 0 } }, async (policy) => {
|
|
@@ -10972,7 +10982,20 @@ var init_auth = __esm({
|
|
|
10972
10982
|
});
|
|
10973
10983
|
|
|
10974
10984
|
// src/sandbox-reg-tokens.ts
|
|
10985
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
10975
10986
|
import { nanoid as nanoid7 } from "nanoid";
|
|
10987
|
+
function hashSandboxRegToken(secret) {
|
|
10988
|
+
return createHash2("sha256").update(secret, "utf8").digest("hex");
|
|
10989
|
+
}
|
|
10990
|
+
async function issueEphemeralSandboxRegToken(db, email, ttlMs = EPHEMERAL_REG_TOKEN_TTL_MS) {
|
|
10991
|
+
const normalized = email.trim().toLowerCase();
|
|
10992
|
+
const secret = `sbxreg_${nanoid7(48)}`;
|
|
10993
|
+
const now = Date.now();
|
|
10994
|
+
const expiresAt = now + ttlMs;
|
|
10995
|
+
await db.run(`INSERT INTO sandbox_reg_tokens (token_hash, email, user_id, created_at, expires_at)
|
|
10996
|
+
VALUES (?, ?, (SELECT id FROM users WHERE email = ?), ?, ?)`, hashSandboxRegToken(secret), normalized, normalized, now, expiresAt);
|
|
10997
|
+
return { secret, expiresAt };
|
|
10998
|
+
}
|
|
10976
10999
|
var EPHEMERAL_REG_TOKEN_TTL_MS;
|
|
10977
11000
|
var init_sandbox_reg_tokens = __esm({
|
|
10978
11001
|
"src/sandbox-reg-tokens.ts"() {
|
|
@@ -11268,6 +11291,25 @@ var init_state_machine2 = __esm({
|
|
|
11268
11291
|
});
|
|
11269
11292
|
|
|
11270
11293
|
// src/abuse-throttle.ts
|
|
11294
|
+
function createAbuseThrottle(opts) {
|
|
11295
|
+
const hits = /* @__PURE__ */ new Map();
|
|
11296
|
+
return {
|
|
11297
|
+
take(key) {
|
|
11298
|
+
const now = Date.now();
|
|
11299
|
+
const entry = hits.get(key);
|
|
11300
|
+
if (!entry || entry.resetAt <= now) {
|
|
11301
|
+
hits.set(key, { count: 1, resetAt: now + opts.windowMs });
|
|
11302
|
+
return true;
|
|
11303
|
+
}
|
|
11304
|
+
if (entry.count >= opts.max) return false;
|
|
11305
|
+
entry.count += 1;
|
|
11306
|
+
return true;
|
|
11307
|
+
},
|
|
11308
|
+
reset() {
|
|
11309
|
+
hits.clear();
|
|
11310
|
+
}
|
|
11311
|
+
};
|
|
11312
|
+
}
|
|
11271
11313
|
var init_abuse_throttle = __esm({
|
|
11272
11314
|
"src/abuse-throttle.ts"() {
|
|
11273
11315
|
"use strict";
|
|
@@ -11298,11 +11340,11 @@ var init_sandbox2 = __esm({
|
|
|
11298
11340
|
init_sealedbox();
|
|
11299
11341
|
init_abuse_throttle();
|
|
11300
11342
|
init_auth();
|
|
11301
|
-
init_cli_auth();
|
|
11302
11343
|
init_sandbox_reg_tokens();
|
|
11303
11344
|
init_users();
|
|
11304
11345
|
init_agent_auth_probe();
|
|
11305
11346
|
init_ws();
|
|
11347
|
+
init_route_registry();
|
|
11306
11348
|
}
|
|
11307
11349
|
});
|
|
11308
11350
|
|
|
@@ -11357,6 +11399,7 @@ var init_farm2 = __esm({
|
|
|
11357
11399
|
init_sealedbox();
|
|
11358
11400
|
init_abuse_throttle();
|
|
11359
11401
|
init_ws();
|
|
11402
|
+
init_route_registry();
|
|
11360
11403
|
}
|
|
11361
11404
|
});
|
|
11362
11405
|
|
|
@@ -11389,6 +11432,7 @@ var init_runner2 = __esm({
|
|
|
11389
11432
|
init_users();
|
|
11390
11433
|
init_runner_reg_tokens();
|
|
11391
11434
|
init_ws();
|
|
11435
|
+
init_route_registry();
|
|
11392
11436
|
}
|
|
11393
11437
|
});
|
|
11394
11438
|
|
|
@@ -12367,10 +12411,10 @@ __export(regimen_config_exports, {
|
|
|
12367
12411
|
loadWorkflowSettings: () => loadWorkflowSettings,
|
|
12368
12412
|
loadYouTrackWrites: () => loadYouTrackWrites
|
|
12369
12413
|
});
|
|
12370
|
-
import { createHash as
|
|
12414
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
12371
12415
|
import { parse as parseYaml2 } from "yaml";
|
|
12372
12416
|
function contentSha2(content) {
|
|
12373
|
-
return
|
|
12417
|
+
return createHash3("sha1").update(content, "utf-8").digest("hex");
|
|
12374
12418
|
}
|
|
12375
12419
|
async function applyRegimenContent(db, projectId, content, log, preParsed) {
|
|
12376
12420
|
const previous = cache3.get(projectId) ?? null;
|
|
@@ -19186,9 +19230,9 @@ var init_cluster_order = __esm({
|
|
|
19186
19230
|
});
|
|
19187
19231
|
|
|
19188
19232
|
// src/prompts/prompt-cache.ts
|
|
19189
|
-
import { createHash as
|
|
19233
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
19190
19234
|
function contentSha3(content) {
|
|
19191
|
-
return
|
|
19235
|
+
return createHash4("sha1").update(content, "utf-8").digest("hex");
|
|
19192
19236
|
}
|
|
19193
19237
|
function getProjectPromptTemplate(projectId, role) {
|
|
19194
19238
|
return cache4.get(projectId)?.get(role)?.content ?? null;
|
|
@@ -22786,7 +22830,7 @@ __export(lifecycle_exports, {
|
|
|
22786
22830
|
taskRunsDirectImplement: () => taskRunsDirectImplement,
|
|
22787
22831
|
triggerRework: () => triggerRework
|
|
22788
22832
|
});
|
|
22789
|
-
import { createHash as
|
|
22833
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
22790
22834
|
async function reconcileStuckTasks(db, log) {
|
|
22791
22835
|
let recovered = 0;
|
|
22792
22836
|
for (const task of await listTasks(db)) {
|
|
@@ -23381,7 +23425,7 @@ async function maybeAwaitingAnswer(db, task, log, blockingQuestions = []) {
|
|
|
23381
23425
|
if (blocking.length === 0) return false;
|
|
23382
23426
|
const now = Date.now();
|
|
23383
23427
|
for (let i = 0; i < blocking.length; i++) {
|
|
23384
|
-
const digest2 =
|
|
23428
|
+
const digest2 = createHash5("sha256").update(blocking[i]).digest("hex").slice(0, 12);
|
|
23385
23429
|
await ingestComment(db, {
|
|
23386
23430
|
taskId: task.id,
|
|
23387
23431
|
trackerCommentId: `agent:${task.phase.toLowerCase()}:${i}:${digest2}`,
|
|
@@ -28487,6 +28531,8 @@ function requestGhRunnersDelete(runnerId, projectId, sealedBundle, timeoutMs) {
|
|
|
28487
28531
|
init_farm2();
|
|
28488
28532
|
init_runner2();
|
|
28489
28533
|
init_init_status();
|
|
28534
|
+
init_sandbox_reg_tokens();
|
|
28535
|
+
init_abuse_throttle();
|
|
28490
28536
|
|
|
28491
28537
|
// src/projects/forget.ts
|
|
28492
28538
|
init_legacy_cred_bundles();
|
|
@@ -28675,6 +28721,7 @@ function nodeUnavailable(capability, err) {
|
|
|
28675
28721
|
function taskState(row) {
|
|
28676
28722
|
return { ...row, revision: String(row.updatedAt) };
|
|
28677
28723
|
}
|
|
28724
|
+
var WORKER_REG_TOKEN_MINTS = createAbuseThrottle({ windowMs: 60 * 6e4, max: 30 });
|
|
28678
28725
|
function createWriteModel(db, log, hooks = {}) {
|
|
28679
28726
|
async function readTaskRow(projectId, key) {
|
|
28680
28727
|
const row = await db.get(
|
|
@@ -29357,6 +29404,16 @@ function createWriteModel(db, log, hooks = {}) {
|
|
|
29357
29404
|
log.info({ projectId, jobId, kind }, kind === "backfill" ? "backfill job enqueued" : "index job enqueued");
|
|
29358
29405
|
return ok({ jobId });
|
|
29359
29406
|
},
|
|
29407
|
+
async issueWorkerRegistrationToken({ owner }) {
|
|
29408
|
+
if (owner.email === null) return { ok: false, refusal: "unprocessable", reason: "account_has_no_email" };
|
|
29409
|
+
if (!WORKER_REG_TOKEN_MINTS.take(`email:${owner.email}`)) {
|
|
29410
|
+
log.warn({ email: owner.email }, "ephemeral sandbox reg token mint throttled");
|
|
29411
|
+
return { ok: false, refusal: "rate_limited" };
|
|
29412
|
+
}
|
|
29413
|
+
const issued = await issueEphemeralSandboxRegToken(db, owner.email);
|
|
29414
|
+
log.info({ email: owner.email }, "ephemeral sandbox reg token issued for a client");
|
|
29415
|
+
return ok(issued);
|
|
29416
|
+
},
|
|
29360
29417
|
async reportInitStatus({ projectId, phase, error }) {
|
|
29361
29418
|
const recorded = await advanceInitPhase(db, projectId, phase);
|
|
29362
29419
|
if (error !== null) {
|