aglio-worker 0.54.0 → 0.61.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.
Files changed (2) hide show
  1. package/agent.js +168 -95
  2. package/package.json +1 -1
package/agent.js CHANGED
@@ -27267,17 +27267,43 @@ var repoConnectionReportSchema = external_exports.object({
27267
27267
  });
27268
27268
 
27269
27269
  // ../../packages/shared/src/notifications.ts
27270
+ var DIGEST_FREQUENCIES = ["1h", "4h", "12h", "24h"];
27271
+ var DEFAULT_DIGEST_FREQUENCY = "4h";
27270
27272
  var DEFAULT_NOTIFICATION_PREFERENCES = {
27271
27273
  emailDigest: true,
27272
27274
  emailQuestions: true,
27273
27275
  emailFailures: true,
27274
- emailPrReady: true
27275
- };
27276
+ emailPrReady: true,
27277
+ digestFrequency: DEFAULT_DIGEST_FREQUENCY,
27278
+ telegramEnabled: false,
27279
+ telegramChatId: "",
27280
+ telegramBotConfigured: false,
27281
+ telegramBotUsername: "",
27282
+ telegramLinked: false,
27283
+ telegramChatLabel: "",
27284
+ telegramLinkCode: "",
27285
+ telegramLinkCodeExpiresAt: ""
27286
+ };
27287
+ var TELEGRAM_LINK_CODE_TTL_MS = 10 * 60 * 1e3;
27276
27288
  var notificationPreferencesSchema = external_exports.object({
27277
27289
  emailDigest: external_exports.boolean().catch(DEFAULT_NOTIFICATION_PREFERENCES.emailDigest),
27278
27290
  emailQuestions: external_exports.boolean().catch(DEFAULT_NOTIFICATION_PREFERENCES.emailQuestions),
27279
27291
  emailFailures: external_exports.boolean().catch(DEFAULT_NOTIFICATION_PREFERENCES.emailFailures),
27280
- emailPrReady: external_exports.boolean().catch(DEFAULT_NOTIFICATION_PREFERENCES.emailPrReady)
27292
+ emailPrReady: external_exports.boolean().catch(DEFAULT_NOTIFICATION_PREFERENCES.emailPrReady),
27293
+ digestFrequency: external_exports.enum(DIGEST_FREQUENCIES).catch(DEFAULT_NOTIFICATION_PREFERENCES.digestFrequency),
27294
+ telegramEnabled: external_exports.boolean().catch(DEFAULT_NOTIFICATION_PREFERENCES.telegramEnabled),
27295
+ telegramChatId: external_exports.string().trim().max(64).catch(DEFAULT_NOTIFICATION_PREFERENCES.telegramChatId),
27296
+ telegramBotConfigured: external_exports.boolean().catch(DEFAULT_NOTIFICATION_PREFERENCES.telegramBotConfigured),
27297
+ telegramBotUsername: external_exports.string().trim().max(64).catch(DEFAULT_NOTIFICATION_PREFERENCES.telegramBotUsername),
27298
+ telegramLinked: external_exports.boolean().catch(DEFAULT_NOTIFICATION_PREFERENCES.telegramLinked),
27299
+ telegramChatLabel: external_exports.string().trim().max(64).catch(DEFAULT_NOTIFICATION_PREFERENCES.telegramChatLabel),
27300
+ telegramLinkCode: external_exports.string().trim().max(64).catch(DEFAULT_NOTIFICATION_PREFERENCES.telegramLinkCode),
27301
+ telegramLinkCodeExpiresAt: external_exports.string().trim().max(64).catch(DEFAULT_NOTIFICATION_PREFERENCES.telegramLinkCodeExpiresAt)
27302
+ });
27303
+ var storedNotificationPreferencesSchema = notificationPreferencesSchema.extend({
27304
+ telegramBotToken: external_exports.string().trim().max(4096).catch(""),
27305
+ telegramUpdateOffset: external_exports.number().int().nonnegative().catch(0),
27306
+ telegramLinkedAt: external_exports.string().trim().max(64).catch("")
27281
27307
  });
27282
27308
  function isSlackWebhookUrl(value) {
27283
27309
  if (typeof value !== "string" || !value.trim()) return false;
@@ -27341,6 +27367,74 @@ function validateRoutingLabels(input2) {
27341
27367
  return labels;
27342
27368
  }
27343
27369
 
27370
+ // ../../packages/shared/src/plans.ts
27371
+ var PLAN_IDS = ["free", "pro", "team", "enterprise"];
27372
+ var MEGABYTE = 1024 * 1024;
27373
+ var GIGABYTE = 1024 * MEGABYTE;
27374
+ var PLAN_CATALOG = {
27375
+ free: {
27376
+ id: "free",
27377
+ label: "Free",
27378
+ tagline: "For a solo workspace trying Aglio.",
27379
+ priceLabel: "$0",
27380
+ monthlyPriceUsd: 0,
27381
+ entitlements: {
27382
+ seats: 1,
27383
+ projects: 2,
27384
+ runsPerMonth: null,
27385
+ storageBytes: 500 * MEGABYTE,
27386
+ poolSecondsPerMonth: 7200,
27387
+ cloudRunsPerMonth: 20
27388
+ }
27389
+ },
27390
+ pro: {
27391
+ id: "pro",
27392
+ label: "Pro",
27393
+ tagline: "For one person or a small crew shipping together.",
27394
+ priceLabel: "$19/mo",
27395
+ monthlyPriceUsd: 19,
27396
+ entitlements: {
27397
+ seats: 3,
27398
+ projects: 10,
27399
+ runsPerMonth: null,
27400
+ storageBytes: 5 * GIGABYTE,
27401
+ poolSecondsPerMonth: 72e3,
27402
+ cloudRunsPerMonth: 120
27403
+ }
27404
+ },
27405
+ team: {
27406
+ id: "team",
27407
+ label: "Team",
27408
+ tagline: "For a small team shipping together.",
27409
+ priceLabel: "$49/mo",
27410
+ monthlyPriceUsd: 49,
27411
+ entitlements: {
27412
+ seats: 10,
27413
+ projects: 20,
27414
+ runsPerMonth: null,
27415
+ storageBytes: 20 * GIGABYTE,
27416
+ poolSecondsPerMonth: 36e4,
27417
+ cloudRunsPerMonth: 500
27418
+ }
27419
+ },
27420
+ enterprise: {
27421
+ id: "enterprise",
27422
+ label: "Enterprise",
27423
+ tagline: "Unlimited seats, projects and usage.",
27424
+ priceLabel: "Contact us",
27425
+ monthlyPriceUsd: null,
27426
+ entitlements: {
27427
+ seats: null,
27428
+ projects: null,
27429
+ runsPerMonth: null,
27430
+ storageBytes: null,
27431
+ poolSecondsPerMonth: null,
27432
+ cloudRunsPerMonth: null
27433
+ }
27434
+ }
27435
+ };
27436
+ var PLAN_LIST = PLAN_IDS.map((id) => PLAN_CATALOG[id]);
27437
+
27344
27438
  // ../../packages/shared/src/worker-capacity.ts
27345
27439
  var WORKER_DEFAULT_CAPACITY = 1;
27346
27440
  var WORKER_MAX_CAPACITY = 8;
@@ -27725,6 +27819,11 @@ var createInviteSchema = external_exports.object({
27725
27819
  email: external_exports.string().email(),
27726
27820
  role: memberRoleSchema.default("member")
27727
27821
  });
27822
+ var changeEmailSchema = external_exports.object({
27823
+ newEmail: external_exports.string().trim().toLowerCase().max(254).email(),
27824
+ /** Empty for accounts that sign in with GitHub only. */
27825
+ currentPassword: external_exports.string().max(200).default("")
27826
+ });
27728
27827
  var jobPayloadSchema = external_exports.record(external_exports.string(), external_exports.unknown());
27729
27828
 
27730
27829
  // ../../packages/shared/src/project-mcp.ts
@@ -27837,6 +27936,12 @@ var appEventSchema = external_exports.object({
27837
27936
  createdAt: external_exports.string()
27838
27937
  });
27839
27938
 
27939
+ // ../../packages/shared/src/boards.ts
27940
+ var BOARD_NAME_MAX = 40;
27941
+ var boardInputSchema = external_exports.object({
27942
+ name: external_exports.string().trim().min(1).max(BOARD_NAME_MAX)
27943
+ });
27944
+
27840
27945
  // ../../packages/shared/src/files.ts
27841
27946
  function sanitizeFileName(input2, fallback = "file") {
27842
27947
  const cleaned = input2.replace(/[^a-zA-Z0-9._-]+/g, "_").replace(/^[._-]+/, "").slice(0, 120);
@@ -28322,6 +28427,8 @@ var cardLabelInputSchema = external_exports.object({
28322
28427
  // ../../packages/shared/src/workspace.ts
28323
28428
  var INVITE_TTL_DAYS = 7;
28324
28429
  var INVITE_TTL_MS = INVITE_TTL_DAYS * 24 * 60 * 60 * 1e3;
28430
+ var DEFAULT_INVITE_EXPIRY_DAYS = INVITE_TTL_DAYS;
28431
+ var MAX_INVITE_EXPIRY_DAYS = 90;
28325
28432
 
28326
28433
  // ../../packages/shared/src/workspace-settings.ts
28327
28434
  var WORKSPACE_SETTINGS_DEFAULTS = {
@@ -28330,13 +28437,16 @@ var WORKSPACE_SETTINGS_DEFAULTS = {
28330
28437
  /** 0 means keep artifacts forever. */
28331
28438
  artifactRetentionDays: 0,
28332
28439
  /** The shared workspace consultant is opt-out. Disabled hides every entry point. */
28333
- consultantEnabled: true
28440
+ consultantEnabled: true,
28441
+ /** How long new invite links stay valid. Existing invites keep their own date. */
28442
+ inviteExpiryDays: DEFAULT_INVITE_EXPIRY_DAYS
28334
28443
  };
28335
28444
  var workspaceSettingsSchema = external_exports.object({
28336
28445
  allowMemberInvites: external_exports.boolean().catch(WORKSPACE_SETTINGS_DEFAULTS.allowMemberInvites),
28337
28446
  defaultAgentConfigId: external_exports.string().trim().min(1).nullable().catch(null),
28338
28447
  artifactRetentionDays: external_exports.number().int().min(0).max(3650).catch(WORKSPACE_SETTINGS_DEFAULTS.artifactRetentionDays),
28339
- consultantEnabled: external_exports.boolean().catch(WORKSPACE_SETTINGS_DEFAULTS.consultantEnabled)
28448
+ consultantEnabled: external_exports.boolean().catch(WORKSPACE_SETTINGS_DEFAULTS.consultantEnabled),
28449
+ inviteExpiryDays: external_exports.number().int().min(1).max(MAX_INVITE_EXPIRY_DAYS).catch(WORKSPACE_SETTINGS_DEFAULTS.inviteExpiryDays)
28340
28450
  }).passthrough();
28341
28451
 
28342
28452
  // ../../packages/shared/src/theme.ts
@@ -28351,74 +28461,6 @@ var themePreferencesSchema = external_exports.object({
28351
28461
  themeScale: external_exports.enum(THEME_SCALES).catch(DEFAULT_THEME_PREFERENCES.themeScale)
28352
28462
  });
28353
28463
 
28354
- // ../../packages/shared/src/plans.ts
28355
- var PLAN_IDS = ["free", "pro", "team", "enterprise"];
28356
- var MEGABYTE = 1024 * 1024;
28357
- var GIGABYTE = 1024 * MEGABYTE;
28358
- var PLAN_CATALOG = {
28359
- free: {
28360
- id: "free",
28361
- label: "Free",
28362
- tagline: "For a solo workspace trying Aglio.",
28363
- priceLabel: "$0",
28364
- monthlyPriceUsd: 0,
28365
- entitlements: {
28366
- seats: 1,
28367
- projects: 2,
28368
- runsPerMonth: null,
28369
- storageBytes: 500 * MEGABYTE,
28370
- poolSecondsPerMonth: 7200,
28371
- cloudRunsPerMonth: 20
28372
- }
28373
- },
28374
- pro: {
28375
- id: "pro",
28376
- label: "Pro",
28377
- tagline: "For one person or a small crew shipping together.",
28378
- priceLabel: "$19/mo",
28379
- monthlyPriceUsd: 19,
28380
- entitlements: {
28381
- seats: 3,
28382
- projects: 10,
28383
- runsPerMonth: null,
28384
- storageBytes: 5 * GIGABYTE,
28385
- poolSecondsPerMonth: 72e3,
28386
- cloudRunsPerMonth: 120
28387
- }
28388
- },
28389
- team: {
28390
- id: "team",
28391
- label: "Team",
28392
- tagline: "For a small team shipping together.",
28393
- priceLabel: "$49/mo",
28394
- monthlyPriceUsd: 49,
28395
- entitlements: {
28396
- seats: 10,
28397
- projects: 20,
28398
- runsPerMonth: null,
28399
- storageBytes: 20 * GIGABYTE,
28400
- poolSecondsPerMonth: 36e4,
28401
- cloudRunsPerMonth: 500
28402
- }
28403
- },
28404
- enterprise: {
28405
- id: "enterprise",
28406
- label: "Enterprise",
28407
- tagline: "Unlimited seats, projects and usage.",
28408
- priceLabel: "Contact us",
28409
- monthlyPriceUsd: null,
28410
- entitlements: {
28411
- seats: null,
28412
- projects: null,
28413
- runsPerMonth: null,
28414
- storageBytes: null,
28415
- poolSecondsPerMonth: null,
28416
- cloudRunsPerMonth: null
28417
- }
28418
- }
28419
- };
28420
- var PLAN_LIST = PLAN_IDS.map((id) => PLAN_CATALOG[id]);
28421
-
28422
28464
  // ../../packages/shared/src/lists.ts
28423
28465
  var BOARD_LIST_NAME_MAX = 40;
28424
28466
  var boardListInputSchema = external_exports.object({
@@ -28434,6 +28476,9 @@ var boardListMoveSchema = external_exports.object({
28434
28476
  // ../../packages/shared/src/password-reset.ts
28435
28477
  var PASSWORD_RESET_TTL_SECONDS = 60 * 60;
28436
28478
 
28479
+ // ../../packages/shared/src/email-change.ts
28480
+ var EMAIL_CHANGE_TTL_SECONDS = 60 * 60;
28481
+
28437
28482
  // ../../packages/shared/src/card-open-mode.ts
28438
28483
  var CARD_OPEN_MODES = ["popup", "page"];
28439
28484
  var cardOpenModeSchema = external_exports.enum(CARD_OPEN_MODES);
@@ -31298,26 +31343,46 @@ import { join as join6, resolve as resolve5, sep } from "node:path";
31298
31343
  var FINAL = ["completed", "failed", "cancelled", "expired"];
31299
31344
  var POLL_MS = 700;
31300
31345
  var KICKOFF_MS = 4e3;
31346
+ var API_ATTEMPTS = 3;
31347
+ var API_RETRY_MS = 400;
31301
31348
  function isFinal(status) {
31302
31349
  return FINAL.includes(status);
31303
31350
  }
31304
31351
  function errorText3(error62) {
31305
31352
  return error62 instanceof Error ? error62.message : String(error62);
31306
31353
  }
31354
+ function errorStatus2(error62) {
31355
+ const status = error62?.status;
31356
+ return typeof status === "number" ? status : null;
31357
+ }
31358
+ function transientControlPlaneError(error62) {
31359
+ const status = errorStatus2(error62);
31360
+ return status === null || status === 429 || status >= 500;
31361
+ }
31362
+ async function withLoginRetry(call, signal) {
31363
+ for (let attempt = 1; ; attempt += 1) {
31364
+ try {
31365
+ return await call();
31366
+ } catch (error62) {
31367
+ if (signal.aborted || attempt >= API_ATTEMPTS || !transientControlPlaneError(error62)) throw error62;
31368
+ await new Promise((done) => setTimeout(done, API_RETRY_MS * attempt));
31369
+ }
31370
+ }
31371
+ }
31307
31372
  async function runRemoteProviderLogin(input2) {
31308
- let session = await input2.api.fetch();
31309
- const method = session.command;
31310
31373
  const root = join6(input2.workspace, "login");
31311
- const home = join6(root, "home");
31312
- const target = resolve5(home, session.bundlePath);
31313
- if (!target.startsWith(resolve5(home) + sep)) {
31314
- return { state: "failed", error: "Unsafe credential bundle path." };
31315
- }
31316
- await mkdir3(home, { recursive: true, mode: 448 });
31317
- input2.write(`[aglio] provider login ${session.provider} (${method.label})
31318
- `);
31319
31374
  let container = null;
31320
31375
  try {
31376
+ let session = await withLoginRetry(() => input2.api.fetch(), input2.signal);
31377
+ const method = session.command;
31378
+ const home = join6(root, "home");
31379
+ const target = resolve5(home, session.bundlePath);
31380
+ if (!target.startsWith(resolve5(home) + sep)) {
31381
+ return { state: "failed", error: "Unsafe credential bundle path." };
31382
+ }
31383
+ await mkdir3(home, { recursive: true, mode: 448 });
31384
+ input2.write(`[aglio] provider login ${session.provider} (${method.label})
31385
+ `);
31321
31386
  container = await createDockerLoginContainer({
31322
31387
  jobId: input2.job.id,
31323
31388
  workspace: root,
@@ -31349,7 +31414,7 @@ async function runRemoteProviderLogin(input2) {
31349
31414
  let lastSnapshot = "";
31350
31415
  let endedAt = null;
31351
31416
  while (!input2.signal.aborted && !input2.cancelled()) {
31352
- session = await input2.api.fetch();
31417
+ session = await withLoginRetry(() => input2.api.fetch(), input2.signal);
31353
31418
  if (isFinal(session.status)) {
31354
31419
  return {
31355
31420
  state: session.status === "cancelled" ? "cancelled" : session.status === "completed" ? "succeeded" : "failed",
@@ -31357,7 +31422,10 @@ async function runRemoteProviderLogin(input2) {
31357
31422
  };
31358
31423
  }
31359
31424
  if (new Date(session.expiresAt).getTime() <= Date.now()) {
31360
- await input2.api.update({ status: "expired", error: "Sign-in timed out. Start again." });
31425
+ await withLoginRetry(
31426
+ () => input2.api.update({ status: "expired", error: "Sign-in timed out. Start again." }),
31427
+ input2.signal
31428
+ );
31361
31429
  return { state: "failed", error: "Sign-in timed out. Start again." };
31362
31430
  }
31363
31431
  if (method.kickoff && !kickoffSent && Date.now() - startedAt >= KICKOFF_MS) {
@@ -31379,8 +31447,8 @@ async function runRemoteProviderLogin(input2) {
31379
31447
  } catch {
31380
31448
  }
31381
31449
  if (content) {
31382
- await input2.api.update({ status: "saving" });
31383
- const uploaded = await input2.api.uploadBundle(content);
31450
+ await withLoginRetry(() => input2.api.update({ status: "saving" }), input2.signal);
31451
+ const uploaded = await withLoginRetry(() => input2.api.uploadBundle(content), input2.signal);
31384
31452
  input2.write(`[aglio] credential bundle saved (${uploaded.credentialId})
31385
31453
  `);
31386
31454
  return { state: "succeeded", error: null };
@@ -31392,12 +31460,15 @@ async function runRemoteProviderLogin(input2) {
31392
31460
  const snapshot = JSON.stringify({ url: url2, userCode, status, output: output2.slice(-4e3) });
31393
31461
  if (snapshot !== lastSnapshot) {
31394
31462
  lastSnapshot = snapshot;
31395
- await input2.api.update({
31396
- status,
31397
- url: url2,
31398
- userCode,
31399
- output: output2.slice(-4e3)
31400
- });
31463
+ await withLoginRetry(
31464
+ () => input2.api.update({
31465
+ status,
31466
+ url: url2,
31467
+ userCode,
31468
+ output: output2.slice(-4e3)
31469
+ }),
31470
+ input2.signal
31471
+ );
31401
31472
  }
31402
31473
  if (ended) {
31403
31474
  endedAt ??= Date.now();
@@ -31406,7 +31477,7 @@ async function runRemoteProviderLogin(input2) {
31406
31477
  const tail2 = output2.trim().split("\n").slice(-6).join("\n");
31407
31478
  const message = `Sign-in ended before an auth file was written (exit ${info.ExitCode ?? "unknown"}).` + (tail2 ? `
31408
31479
  ${tail2}` : "");
31409
- await input2.api.update({ status: "failed", error: message });
31480
+ await withLoginRetry(() => input2.api.update({ status: "failed", error: message }), input2.signal);
31410
31481
  return { state: "failed", error: message };
31411
31482
  }
31412
31483
  }
@@ -31418,7 +31489,9 @@ ${tail2}` : "");
31418
31489
  return { state: "failed", error: "Sign-in stopped" };
31419
31490
  } catch (error62) {
31420
31491
  const message = errorText3(error62).slice(0, 2e3);
31421
- await input2.api.update({ status: "failed", error: message }).catch(() => void 0);
31492
+ await withLoginRetry(() => input2.api.update({ status: "failed", error: message }), input2.signal).catch(
31493
+ () => void 0
31494
+ );
31422
31495
  return { state: "failed", error: message };
31423
31496
  } finally {
31424
31497
  await container?.kill().catch(() => void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aglio-worker",
3
- "version": "0.54.0",
3
+ "version": "0.61.0",
4
4
  "description": "Host machine agent for Aglio: claims jobs over the API and starts aglio-runner containers.",
5
5
  "type": "module",
6
6
  "bin": {