aglio-worker 0.101.2 → 0.102.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 +165 -27
  2. package/package.json +1 -1
package/agent.js CHANGED
@@ -50183,7 +50183,16 @@ var RUN_STATUSES_FOR_SCHEMA = [
50183
50183
  "cancelled",
50184
50184
  "skipped"
50185
50185
  ];
50186
- var RUN_KINDS = ["planning", "agent", "build", "consult", "review", "workspace_consult", "job"];
50186
+ var RUN_KINDS = [
50187
+ "planning",
50188
+ "agent",
50189
+ "overseer",
50190
+ "build",
50191
+ "consult",
50192
+ "review",
50193
+ "workspace_consult",
50194
+ "job"
50195
+ ];
50187
50196
  var AGENT_DRIVERS = ["pi", "claude", "codex", "cursor", "opencode", "antigravity", "hermes"];
50188
50197
  var QUESTION_TYPES = ["single", "multi", "text"];
50189
50198
  var VERIFICATION_KINDS = ["test_output", "screenshot", "recording", "not_applicable"];
@@ -50206,6 +50215,7 @@ var RUN_TRIGGERS = [
50206
50215
  "review_poll",
50207
50216
  "planning_chat",
50208
50217
  "agent_chat",
50218
+ "auto_mode",
50209
50219
  "followup",
50210
50220
  "workspace_chat",
50211
50221
  "schedule"
@@ -70473,6 +70483,11 @@ var agentRoleDialsMapSchema = external_exports.object({
70473
70483
  planning: agentRoleDialsSchema.optional()
70474
70484
  });
70475
70485
 
70486
+ // ../../packages/shared/src/agent-colors.ts
70487
+ var DEFAULT_AGENT_COLOR = "#22c55e";
70488
+ var HEX_COLOR = /^#[0-9a-f]{6}$/;
70489
+ var agentColorSchema = external_exports.string().trim().toLowerCase().regex(HEX_COLOR, "Use a six-digit hex color").default(DEFAULT_AGENT_COLOR);
70490
+
70476
70491
  // ../../packages/shared/src/auto-mode.ts
70477
70492
  var AUTO_MODE_PAUSE_REASONS = ["manual", "failures", "blocker", "costCap"];
70478
70493
  var autoModePauseReasonSchema = external_exports.enum(AUTO_MODE_PAUSE_REASONS);
@@ -70493,7 +70508,11 @@ var autoModeStateSchema = external_exports.object({
70493
70508
  /** Last tick decision, so the board can say what it checked and skipped. */
70494
70509
  lastTick: autoModeTickSchema.nullable().default(null),
70495
70510
  /** Set when a tick starts, so two triggers cannot plan at once. */
70496
- tickStartedAt: external_exports.string().datetime().nullable().default(null)
70511
+ tickStartedAt: external_exports.string().datetime().nullable().default(null),
70512
+ /** Ticket/PR digest seen by the last overseer wake. New state wakes it again. */
70513
+ overseerSignature: external_exports.string().nullable().default(null),
70514
+ /** When the live overseer last woke, so the board can show it is watching. */
70515
+ lastOverseerAt: external_exports.string().datetime().nullable().default(null)
70497
70516
  });
70498
70517
  var defaultAutoModeState = {
70499
70518
  paused: false,
@@ -70502,7 +70521,9 @@ var defaultAutoModeState = {
70502
70521
  consecutiveFailures: 0,
70503
70522
  lastPlannerRunAt: null,
70504
70523
  lastTick: null,
70505
- tickStartedAt: null
70524
+ tickStartedAt: null,
70525
+ overseerSignature: null,
70526
+ lastOverseerAt: null
70506
70527
  };
70507
70528
  var autoModeSettingsSchema = external_exports.object({
70508
70529
  enabled: external_exports.boolean().default(false),
@@ -70513,6 +70534,24 @@ var autoModeSettingsSchema = external_exports.object({
70513
70534
  consecutiveFailureLimit: external_exports.number().int().min(1).max(10).default(3),
70514
70535
  /** GitHub Actions workflow file name for workflow_dispatch. */
70515
70536
  shipWorkflow: external_exports.string().trim().max(200).nullable().default(null),
70537
+ /** Goals to start after the current goal finishes, in order. */
70538
+ queueCardIds: external_exports.array(external_exports.string().uuid()).default([]),
70539
+ /** Overseer agent. Null uses the goal assignee, then the project default. */
70540
+ overseerAgentConfigId: external_exports.string().uuid().nullable().default(null),
70541
+ /** Agent for planned tickets. Null uses the project builder settings. */
70542
+ buildAgentConfigId: external_exports.string().uuid().nullable().default(null),
70543
+ /** Worker labels for the overseer. Null inherits the project build labels. */
70544
+ overseerRequiredWorkerLabels: external_exports.array(external_exports.string().trim().min(1).max(100)).max(20).nullable().default(null),
70545
+ /** Worker labels for planned tickets. Null inherits the project build labels. */
70546
+ buildRequiredWorkerLabels: external_exports.array(external_exports.string().trim().min(1).max(100)).max(20).nullable().default(null),
70547
+ /** Where the overseer runs. Null follows the project runner target. */
70548
+ overseerRunnerTarget: external_exports.enum(JOB_TARGETS).nullable().default(null),
70549
+ /** Cloud size for the overseer. Null follows the project cloud size. */
70550
+ overseerPoolSize: external_exports.enum(POOL_SIZES).nullable().default(null),
70551
+ /** Where goal tickets build. Null follows the project runner target. */
70552
+ buildRunnerTarget: external_exports.enum(JOB_TARGETS).nullable().default(null),
70553
+ /** Cloud size for goal tickets. Null follows the project cloud size. */
70554
+ buildPoolSize: external_exports.enum(POOL_SIZES).nullable().default(null),
70516
70555
  /** Runtime pause/failure state. Never edited by the settings form. */
70517
70556
  state: autoModeStateSchema.default(defaultAutoModeState)
70518
70557
  });
@@ -70523,6 +70562,15 @@ var defaultAutoMode = {
70523
70562
  maxCardsPerTick: 3,
70524
70563
  consecutiveFailureLimit: 3,
70525
70564
  shipWorkflow: null,
70565
+ queueCardIds: [],
70566
+ overseerAgentConfigId: null,
70567
+ buildAgentConfigId: null,
70568
+ overseerRequiredWorkerLabels: null,
70569
+ buildRequiredWorkerLabels: null,
70570
+ overseerRunnerTarget: null,
70571
+ overseerPoolSize: null,
70572
+ buildRunnerTarget: null,
70573
+ buildPoolSize: null,
70526
70574
  state: defaultAutoModeState
70527
70575
  };
70528
70576
 
@@ -70850,7 +70898,7 @@ var createAgentConfigSchema = external_exports.object({
70850
70898
  provider: external_exports.string().trim().min(1).max(100),
70851
70899
  model: external_exports.string().trim().min(1).max(200),
70852
70900
  authMode: external_exports.enum(["byok", "aglio"]).default("byok"),
70853
- color: external_exports.string().max(20).default("#22c55e"),
70901
+ color: agentColorSchema,
70854
70902
  credentialId: external_exports.string().nullish(),
70855
70903
  options: agentConfigOptionsSchema.default({})
70856
70904
  });
@@ -86005,7 +86053,23 @@ async function runRemoteCardJob(deps) {
86005
86053
  } catch (error63) {
86006
86054
  return { state: "failed", error: `Could not load run context: ${errorText2(error63)}` };
86007
86055
  }
86008
- const claim3 = await deps.api.claimRun?.(lease).catch(() => "started") ?? "started";
86056
+ let claim3 = "started";
86057
+ if (deps.api.claimRun) {
86058
+ let lastError = null;
86059
+ for (let attempt = 1; attempt <= 3; attempt += 1) {
86060
+ try {
86061
+ claim3 = await deps.api.claimRun(lease);
86062
+ lastError = null;
86063
+ break;
86064
+ } catch (error63) {
86065
+ lastError = error63;
86066
+ if (attempt < 3) await new Promise((resolve7) => setTimeout(resolve7, attempt * 1e3));
86067
+ }
86068
+ }
86069
+ if (lastError) {
86070
+ return { state: "failed", error: `Could not claim run: ${errorText2(lastError)}` };
86071
+ }
86072
+ }
86009
86073
  if (claim3 === "waiting") {
86010
86074
  write("[aglio] waiting for a free run slot\n");
86011
86075
  return { state: "succeeded", error: null };
@@ -86066,8 +86130,35 @@ async function runRemoteCardJob(deps) {
86066
86130
  log: (message) => deps.log?.(message)
86067
86131
  });
86068
86132
  const repoPaths = await cloneRepos();
86069
- const restoredSessionId = await restoreRunContext(repoPaths, context);
86070
- if (restoredSessionId && !context.run.sessionId) context.run.sessionId = restoredSessionId;
86133
+ const repoStartHeads = await Promise.all(
86134
+ repoPaths.map(async (target) => {
86135
+ const targetRun = containerPath(runRoot, workspace, target);
86136
+ return gitOutput(["-C", targetRun, "rev-parse", "HEAD"]).then((value) => value.trim()).catch(() => "");
86137
+ })
86138
+ );
86139
+ const restore = await restoreRunContext(repoPaths, context);
86140
+ if (!context.run.sessionId && restore.sessionId && restore.driver === context.agent.driver && restore.agentConfigId === context.agent.id) {
86141
+ context.run.sessionId = restore.sessionId;
86142
+ }
86143
+ const expectedResume = Boolean(context.run.sessionId);
86144
+ let sessionResumeStatus = "fresh";
86145
+ let sessionResumeReason = null;
86146
+ if (expectedResume) {
86147
+ const resumed = context.run.restoreContextArtifactId ? restore.restored : true;
86148
+ if (resumed) {
86149
+ sessionResumeStatus = "resumed";
86150
+ const resumePrompt = context.run.resumePrompt?.trim();
86151
+ if (resumePrompt) context.prompt = resumePrompt;
86152
+ } else {
86153
+ sessionResumeStatus = "restarted";
86154
+ sessionResumeReason = "The inherited session snapshot could not be restored, so this run started a fresh session.";
86155
+ context.run.sessionId = null;
86156
+ }
86157
+ } else if (context.run.restoreContextArtifactId) {
86158
+ sessionResumeStatus = "restarted";
86159
+ sessionResumeReason = "The inherited context has no resumable session for this agent, so this run started a fresh session.";
86160
+ }
86161
+ await status({ sessionResumeStatus, sessionResumeReason });
86071
86162
  if (context.run.kind === "workspace_consult") {
86072
86163
  await rm3(gitConfigPath, { force: true }).catch(() => void 0);
86073
86164
  }
@@ -86091,7 +86182,7 @@ async function runRemoteCardJob(deps) {
86091
86182
  systemPromptAppend: context.systemPromptAppend
86092
86183
  });
86093
86184
  const exit = await runAgent(command, env);
86094
- await uploadRunContext(repoPaths, context, exit.sessionId).catch((error63) => {
86185
+ await uploadRunContext(repoPaths, context, exit.sessionId, repoStartHeads).catch((error63) => {
86095
86186
  write(`[aglio] context snapshot failed: ${errorText2(error63)}
86096
86187
  `);
86097
86188
  });
@@ -86454,8 +86545,8 @@ async function runRemoteCardJob(deps) {
86454
86545
  if (driver === "hermes") return ["sessions"];
86455
86546
  return [];
86456
86547
  }
86457
- async function uploadRunContext(repoPaths, current, sessionId) {
86458
- if (!current.card || current.run.kind === "workspace_consult") return;
86548
+ async function uploadRunContext(repoPaths, current, sessionId, baseHeads) {
86549
+ if (!current.card && current.run.kind !== "workspace_consult") return;
86459
86550
  const staging = join5(workspace, ".aglio", "context");
86460
86551
  const archivePath = join5(workspace, ".aglio", `run-context-${current.run.id}.tar.gz`);
86461
86552
  await rm3(staging, { recursive: true, force: true }).catch(() => void 0);
@@ -86465,6 +86556,7 @@ async function runRemoteCardJob(deps) {
86465
86556
  version: 1,
86466
86557
  runId: current.run.id,
86467
86558
  driver: current.agent.driver,
86559
+ agentConfigId: current.agent.id,
86468
86560
  sessionId: sessionId ?? current.run.sessionId,
86469
86561
  sessionDirs: [],
86470
86562
  repos: [],
@@ -86475,7 +86567,7 @@ async function runRemoteCardJob(deps) {
86475
86567
  if (!repo) continue;
86476
86568
  const targetRun = containerPath(runRoot, workspace, target);
86477
86569
  const base = repo.baseBranch || "main";
86478
- const baseRef = (await runGit(workspace, ["-C", targetRun, "rev-parse", "--verify", `origin/${base}`])).code === 0 ? `origin/${base}` : base;
86570
+ const baseRef = baseHeads[index3] || ((await runGit(workspace, ["-C", targetRun, "rev-parse", "--verify", `origin/${base}`])).code === 0 ? `origin/${base}` : base);
86479
86571
  const patchRel = `repo-${index3}.patch`;
86480
86572
  const patchPath = join5(staging, patchRel);
86481
86573
  const indexFile = join5(staging, `index-${index3}`);
@@ -86563,7 +86655,9 @@ async function runRemoteCardJob(deps) {
86563
86655
  }
86564
86656
  async function restoreRunContext(repoPaths, current) {
86565
86657
  const artifactId = current.run.restoreContextArtifactId;
86566
- if (!artifactId) return null;
86658
+ if (!artifactId) {
86659
+ return { sessionId: null, restored: false, driver: null, agentConfigId: null };
86660
+ }
86567
86661
  const restoreDir = join5(workspace, ".aglio", "context-restore");
86568
86662
  const archivePath = join5(restoreDir, "context.tar.gz");
86569
86663
  await rm3(restoreDir, { recursive: true, force: true }).catch(() => void 0);
@@ -86574,7 +86668,7 @@ async function runRemoteCardJob(deps) {
86574
86668
  } catch (error63) {
86575
86669
  write(`[aglio] context restore download failed: ${errorText2(error63)}
86576
86670
  `);
86577
- return null;
86671
+ return { sessionId: null, restored: false, driver: null, agentConfigId: null };
86578
86672
  }
86579
86673
  await writeFile(archivePath, data);
86580
86674
  const unpacked = await deps.runCommand({
@@ -86586,12 +86680,12 @@ async function runRemoteCardJob(deps) {
86586
86680
  });
86587
86681
  if (unpacked !== 0) {
86588
86682
  write("[aglio] context restore unpack failed\n");
86589
- return null;
86683
+ return { sessionId: null, restored: false, driver: null, agentConfigId: null };
86590
86684
  }
86591
86685
  const manifest = await readFile2(join5(restoreDir, "manifest.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
86592
86686
  if (!manifest) {
86593
86687
  write("[aglio] context restore manifest missing\n");
86594
- return null;
86688
+ return { sessionId: null, restored: false, driver: null, agentConfigId: null };
86595
86689
  }
86596
86690
  for (const [index3, repo] of (manifest.repos ?? []).entries()) {
86597
86691
  if (!repo.patch) continue;
@@ -86614,6 +86708,7 @@ async function runRemoteCardJob(deps) {
86614
86708
  }
86615
86709
  }
86616
86710
  }
86711
+ let restoredSessions = 0;
86617
86712
  for (const session of manifest.sessionDirs ?? []) {
86618
86713
  if (!session.path || !session.archive) continue;
86619
86714
  const target = resolve4(toolDir, session.path);
@@ -86627,11 +86722,19 @@ async function runRemoteCardJob(deps) {
86627
86722
  signal: deps.signal,
86628
86723
  onOutput: () => void 0
86629
86724
  });
86630
- if (restored === 0) write(`[aglio] restored session ${session.path}
86725
+ if (restored === 0) {
86726
+ restoredSessions += 1;
86727
+ write(`[aglio] restored session ${session.path}
86631
86728
  `);
86729
+ }
86632
86730
  }
86633
86731
  await rm3(restoreDir, { recursive: true, force: true }).catch(() => void 0);
86634
- return manifest.sessionId ?? null;
86732
+ return {
86733
+ sessionId: manifest.sessionId ?? null,
86734
+ restored: restoredSessions > 0,
86735
+ driver: manifest.driver ?? null,
86736
+ agentConfigId: manifest.agentConfigId ?? null
86737
+ };
86635
86738
  }
86636
86739
  async function gitOutput(args) {
86637
86740
  let output2 = "";
@@ -86692,7 +86795,8 @@ async function runRemoteCardJob(deps) {
86692
86795
  let consumeQueue = Promise.resolve();
86693
86796
  const isPlanning = context.run.kind === "planning";
86694
86797
  const isAgent = context.run.kind === "agent";
86695
- const isChat = isPlanning || isAgent;
86798
+ const isOverseer = context.run.kind === "overseer";
86799
+ const isChat = isPlanning || isAgent || isOverseer;
86696
86800
  const isConsult = context.run.kind === "workspace_consult";
86697
86801
  const emitLive = async (events) => {
86698
86802
  if (events.length === 0) return;
@@ -99861,10 +99965,10 @@ function createServerForRun(run) {
99861
99965
  server.registerTool(
99862
99966
  "card_get",
99863
99967
  {
99864
- description: "Read the current card, subtickets, comments, work log, linked PRs and feedback.",
99865
- inputSchema: {}
99968
+ description: "Read a card with subtickets, comments, work log, linked PRs, recent runs and feedback. Auto mode overseer may pass cardId or cardNumber to read any ticket in its goal.",
99969
+ inputSchema: { cardId: external_exports.string().optional(), cardNumber: external_exports.number().int().positive().optional() }
99866
99970
  },
99867
- async () => forward("card_get", {})
99971
+ async (input2) => forward("card_get", input2)
99868
99972
  );
99869
99973
  server.registerTool(
99870
99974
  "repo_list",
@@ -99874,28 +99978,40 @@ function createServerForRun(run) {
99874
99978
  server.registerTool(
99875
99979
  "pr_get",
99876
99980
  {
99877
- description: "Read linked pull requests, or one PR with reviews, comments and checks.",
99878
- inputSchema: { repoId: external_exports.string().optional(), number: external_exports.number().int().optional() }
99981
+ description: "Read linked pull requests, or one PR with reviews, comments and checks. The overseer may pass cardId or cardNumber to read a goal ticket's PRs.",
99982
+ inputSchema: {
99983
+ repoId: external_exports.string().optional(),
99984
+ number: external_exports.number().int().optional(),
99985
+ cardId: external_exports.string().optional(),
99986
+ cardNumber: external_exports.number().int().positive().optional()
99987
+ }
99879
99988
  },
99880
99989
  async (input2) => forward("pr_get", input2)
99881
99990
  );
99882
99991
  server.registerTool(
99883
99992
  "comment_add",
99884
99993
  {
99885
- description: "Post a comment on the card. Pass parentCommentId to answer inside a thread; a consult started from a comment replies there by default.",
99886
- inputSchema: { body: external_exports.string().min(1).max(2e4), parentCommentId: external_exports.string().optional() }
99994
+ description: "Post a comment on the card. Pass parentCommentId to answer inside a thread; a consult started from a comment replies there by default. The overseer may pass cardId or cardNumber to comment on a goal ticket.",
99995
+ inputSchema: {
99996
+ body: external_exports.string().min(1).max(2e4),
99997
+ parentCommentId: external_exports.string().optional(),
99998
+ cardId: external_exports.string().optional(),
99999
+ cardNumber: external_exports.number().int().positive().optional()
100000
+ }
99887
100001
  },
99888
100002
  async (input2) => forward("comment_add", input2)
99889
100003
  );
99890
100004
  server.registerTool(
99891
100005
  "worklog_add",
99892
100006
  {
99893
- description: "Add a short work log entry. Keep summaries to one or two short sentences.",
100007
+ description: "Add a short work log entry. Keep summaries to one or two short sentences. The overseer may pass cardId or cardNumber to log on a goal ticket.",
99894
100008
  inputSchema: {
99895
100009
  type: external_exports.enum(WORK_LOG_TYPES),
99896
100010
  summary: external_exports.string().min(1).max(400),
99897
100011
  details: external_exports.string().max(2e4).optional(),
99898
- artifactIds: external_exports.array(external_exports.string()).optional()
100012
+ artifactIds: external_exports.array(external_exports.string()).optional(),
100013
+ cardId: external_exports.string().optional(),
100014
+ cardNumber: external_exports.number().int().positive().optional()
99899
100015
  }
99900
100016
  },
99901
100017
  async (input2) => forward("worklog_add", input2)
@@ -100116,6 +100232,28 @@ function createServerForRun(run) {
100116
100232
  return forward("pr_open", input2);
100117
100233
  }
100118
100234
  );
100235
+ server.registerTool(
100236
+ "pr_merge",
100237
+ {
100238
+ description: "Auto mode overseer only. Merge the green pull request of one goal ticket and move the ticket to Done. Refuses while checks are pending or failed, or when the PR touches PLAN.md or a rejected file.",
100239
+ inputSchema: {
100240
+ cardId: external_exports.string().optional(),
100241
+ cardNumber: external_exports.number().int().positive().optional()
100242
+ }
100243
+ },
100244
+ async (input2) => forward("pr_merge", input2)
100245
+ );
100246
+ server.registerTool(
100247
+ "card_retry",
100248
+ {
100249
+ description: "Auto mode overseer only. Retry the latest failed or cancelled run of one goal ticket, with the same agent and prompt.",
100250
+ inputSchema: {
100251
+ cardId: external_exports.string().optional(),
100252
+ cardNumber: external_exports.number().int().positive().optional()
100253
+ }
100254
+ },
100255
+ async (input2) => forward("card_retry", input2)
100256
+ );
100119
100257
  return server;
100120
100258
  }
100121
100259
  function createRemoteMcpHost(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aglio-worker",
3
- "version": "0.101.2",
3
+ "version": "0.102.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": {