@app-vitals/agent-runtime 1.45.0 → 1.46.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/boot.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  * 2. Health server — binds immediately so kubelet probes stay green during setup
12
12
  * 3. runMiseStartup + installPlugins (defaults)
13
13
  * 4. Config sync — fetch AgentConfigBundle, apply env, install agent plugins (await first)
14
- * 5. reconcileSystemCrons — best-effort, non-fatal
14
+ * 5. reconcileTemplate + reconcileSystemCrons — best-effort, non-fatal
15
15
  * 6. Cron sync loop (60s)
16
16
  * 7. Slack Bolt Socket Mode app
17
17
  * 8. Graceful SIGTERM/SIGINT shutdown
@@ -705,9 +705,21 @@ export async function startAgent(
705
705
  console.log("[agent] config sync started (60s interval)");
706
706
  }
707
707
 
708
- // ─── Step 5: reconcileSystemCrons — best-effort ───────────────────────────────
708
+ // ─── Step 5: reconcile template, then system crons — best-effort ─────────────
709
+ // The template reconcile runs first so its cron/tool/plugin rows are in
710
+ // place; a failure (older admin without the route, or a transient error) is
711
+ // non-fatal and never blocks boot.
709
712
 
710
713
  if (runtimeClient && agentId) {
714
+ try {
715
+ await runtimeClient.reconcileTemplate(agentId);
716
+ console.log("[agent] agent template reconciled");
717
+ } catch (err) {
718
+ console.error(
719
+ "[agent] reconcileTemplate failed (non-fatal):",
720
+ err instanceof Error ? err.message : String(err),
721
+ );
722
+ }
711
723
  try {
712
724
  await runtimeClient.reconcileSystemCrons(agentId);
713
725
  console.log("[agent] system crons reconciled");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-runtime",
3
- "version": "1.45.0",
3
+ "version": "1.46.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -40,8 +40,8 @@
40
40
  "./workspace-paths": "./workspace-paths.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@app-vitals/agent-admin": "1.45.0",
44
- "@app-vitals/agent-lib": "1.45.0",
43
+ "@app-vitals/agent-admin": "1.46.0",
44
+ "@app-vitals/agent-lib": "1.46.0",
45
45
  "@octokit/auth-app": "^8.2.0",
46
46
  "@sentry/bun": "^10.63.0",
47
47
  "@slack/bolt": "^5.0.0",
@@ -338,3 +338,32 @@ describe("HttpShipwrightRuntimeClient.reconcileSystemCrons", () => {
338
338
  );
339
339
  });
340
340
  });
341
+
342
+ // ─── reconcileTemplate ─────────────────────────────────────────────────────────
343
+
344
+ describe("HttpShipwrightRuntimeClient.reconcileTemplate", () => {
345
+ it("POSTs /agents/{id}/template/reconcile and resolves on 200", async () => {
346
+ const { fn, calls } = capturingFetch(200, { status: "reconciled" });
347
+ const client = new HttpShipwrightRuntimeClient({
348
+ apiUrl: API_URL,
349
+ apiKey: API_KEY,
350
+ fetchFn: fn,
351
+ });
352
+
353
+ await expect(client.reconcileTemplate(AGENT_ID)).resolves.toBeUndefined();
354
+ expect(calls).toHaveLength(1);
355
+ expect(calls[0]?.url).toContain(`/agents/${AGENT_ID}/template/reconcile`);
356
+ });
357
+
358
+ it("throws ShipwrightClientError on a non-2xx response", async () => {
359
+ const client = new HttpShipwrightRuntimeClient({
360
+ apiUrl: API_URL,
361
+ apiKey: API_KEY,
362
+ fetchFn: fakeFetch(404, { error: "Not found" }),
363
+ });
364
+
365
+ const err = await client.reconcileTemplate(AGENT_ID).catch((e) => e);
366
+ expect(err).toBeInstanceOf(ShipwrightClientError);
367
+ expect(err.statusCode).toBe(404);
368
+ });
369
+ });
@@ -38,6 +38,8 @@ interface ShipwrightRuntimeClient {
38
38
  getAgentConfigBundle(agentId: string): Promise<AgentConfigResponse>;
39
39
  listAgentCronJobs(agentId: string): Promise<AgentCronJob[]>;
40
40
  reconcileSystemCrons(agentId: string): Promise<void>;
41
+ /** ATP-2.2: apply the agent's template (env, tools, plugins, crons). */
42
+ reconcileTemplate(agentId: string): Promise<void>;
41
43
  }
42
44
 
43
45
  // ─── HttpShipwrightRuntimeClient ──────────────────────────────────────────────
@@ -115,4 +117,17 @@ export class HttpShipwrightRuntimeClient implements ShipwrightRuntimeClient {
115
117
  );
116
118
  }
117
119
  }
120
+
121
+ async reconcileTemplate(agentId: string): Promise<void> {
122
+ const { response } = await this.adminClient.POST(
123
+ "/agents/{id}/template/reconcile",
124
+ { params: { path: { id: agentId } } },
125
+ );
126
+ if (!response.ok) {
127
+ throw new ShipwrightClientError(
128
+ response.status,
129
+ `POST /agents/${agentId}/template/reconcile failed: ${response.status}`,
130
+ );
131
+ }
132
+ }
118
133
  }