@app-vitals/agent-runtime 1.70.0 → 1.71.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
@@ -98,7 +98,7 @@ import {
98
98
  } from "./sessions.ts";
99
99
  import { ensureAgentHome, installPlugins, runMiseStartup } from "./setup.ts";
100
100
  import { SCRIPTS_BIN } from "./scripts-bin.ts";
101
- import { setupGitHubAuth } from "./setup-github-auth.ts";
101
+ import { checkCredentialHelper, setupGitHubAuth } from "./setup-github-auth.ts";
102
102
  import { HttpShipwrightRuntimeClient } from "./shipwright-runtime-client.ts";
103
103
  import { createSlackApp, hasSlackCredentials } from "./slack.ts";
104
104
  import {
@@ -250,6 +250,10 @@ export async function startAgent(
250
250
  apiUrl: config.shipwright.apiUrl,
251
251
  agentId: config.shipwright.agentId,
252
252
  apiKey: config.shipwright.apiKey,
253
+ checkCredentialHelper: () =>
254
+ checkCredentialHelper(
255
+ join(SCRIPTS_BIN, "git-credential-shipwright.sh"),
256
+ ),
253
257
  repoAccessProbe: createRepoAccessProbe({
254
258
  fetch,
255
259
  clock: SystemClock(),
@@ -19,6 +19,7 @@ import type {
19
19
  InstallationState,
20
20
  InstallationsSnapshot,
21
21
  } from "./github-installations.ts";
22
+ import type { CredentialHelperCheck } from "./setup-github-auth.ts";
22
23
  import type { RepoAccessEntry, RepoAccessProbe } from "./repo-access-probe.ts";
23
24
 
24
25
  export const INSTALLATIONS_HEARTBEAT_MS = 30 * 60 * 1000;
@@ -41,7 +42,21 @@ const REASON_TEXT: Record<NonNullable<InstallationState["reason"]>, string> = {
41
42
  mint_rejected: "installation token mint rejected",
42
43
  };
43
44
 
44
- function toReported(i: InstallationState): ReportedInstallation {
45
+ /** Constant on purpose: the helper path and raw check reason stay off the wire. */
46
+ export const CREDENTIAL_HELPER_BROKEN_TEXT = "git credential helper not found";
47
+
48
+ function toReported(
49
+ i: InstallationState,
50
+ helperBroken: boolean,
51
+ ): ReportedInstallation {
52
+ if (helperBroken) {
53
+ return {
54
+ owner: i.owner ?? "unknown",
55
+ installationId: i.id,
56
+ state: "broken",
57
+ lastError: CREDENTIAL_HELPER_BROKEN_TEXT,
58
+ };
59
+ }
45
60
  return {
46
61
  owner: i.owner ?? "unknown",
47
62
  installationId: i.id,
@@ -62,6 +77,11 @@ interface HttpGitHubInstallationsReporterOptions {
62
77
  * scope change); the reporter just merges whatever it returns into the PUT.
63
78
  */
64
79
  repoAccessProbe?: RepoAccessProbe;
80
+ /**
81
+ * CHP-1.3: evaluated on every report so the broken state clears itself once
82
+ * the helper is fixed. A failing check marks every installation broken.
83
+ */
84
+ checkCredentialHelper?: () => CredentialHelperCheck;
65
85
  }
66
86
 
67
87
  export class HttpGitHubInstallationsReporter
@@ -82,7 +102,10 @@ export class HttpGitHubInstallationsReporter
82
102
 
83
103
  async report(snapshot: InstallationsSnapshot): Promise<void> {
84
104
  try {
85
- const installations = snapshot.installations.map(toReported);
105
+ const helperBroken = this.opts.checkCredentialHelper?.().ok === false;
106
+ const installations = snapshot.installations.map((i) =>
107
+ toReported(i, helperBroken),
108
+ );
86
109
  const signature = JSON.stringify(installations);
87
110
  const probed = await this.opts.repoAccessProbe?.run();
88
111
  if (probed) this.lastRepos = probed;
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { describe, expect, test } from "bun:test";
7
7
  import type { InstallationsSnapshot } from "./github-installations.ts";
8
+ import type { CredentialHelperCheck } from "./setup-github-auth.ts";
8
9
  import type { RepoAccessEntry, RepoAccessProbe } from "./repo-access-probe.ts";
9
10
  import {
10
11
  HttpGitHubInstallationsReporter,
@@ -35,6 +36,7 @@ function snap(
35
36
  function harness(
36
37
  responses: (Response | Error)[] = [],
37
38
  repoAccessProbe?: RepoAccessProbe,
39
+ checkCredentialHelper?: () => CredentialHelperCheck,
38
40
  ) {
39
41
  let nowMs = Date.UTC(2026, 0, 1);
40
42
  const calls: { url: string; init: RequestInit | undefined }[] = [];
@@ -52,6 +54,7 @@ function harness(
52
54
  fetchFn,
53
55
  clock: { now: () => new Date(nowMs) },
54
56
  repoAccessProbe,
57
+ checkCredentialHelper,
55
58
  });
56
59
  return {
57
60
  reporter,
@@ -214,3 +217,60 @@ describe("HttpGitHubInstallationsReporter repo access (COS-44.1)", () => {
214
217
  ).toEqual(["installations", "reportedAt"]);
215
218
  });
216
219
  });
220
+
221
+ describe("credential helper check (CHP-1.3)", () => {
222
+ test("failing check reports every installation broken with constant lastError", async () => {
223
+ const h = harness([], undefined, () => ({
224
+ ok: false,
225
+ reason: "missing /secret/path",
226
+ }));
227
+ await h.reporter.report(
228
+ snap("ok", [
229
+ { id: 2, owner: "beta", pinned: false, health: "ok", reason: null },
230
+ ]),
231
+ );
232
+ const raw = String(h.calls[0].init?.body);
233
+ const body = JSON.parse(raw);
234
+ expect(body.installations).toEqual([
235
+ {
236
+ owner: "acme",
237
+ installationId: 1,
238
+ state: "broken",
239
+ lastError: "git credential helper not found",
240
+ },
241
+ {
242
+ owner: "beta",
243
+ installationId: 2,
244
+ state: "broken",
245
+ lastError: "git credential helper not found",
246
+ },
247
+ ]);
248
+ expect(raw).not.toContain("/secret/path");
249
+ });
250
+
251
+ test("passing check leaves the health/reason mapping unchanged", async () => {
252
+ const h = harness([], undefined, () => ({ ok: true }));
253
+ await h.reporter.report(snap("broken"));
254
+ const body = JSON.parse(String(h.calls[0].init?.body));
255
+ expect(body.installations[0].lastError).toBe(
256
+ "installation token mint rejected",
257
+ );
258
+ });
259
+
260
+ test("ok <-> broken flip posts immediately inside the heartbeat window and recovers", async () => {
261
+ let check: CredentialHelperCheck = { ok: true };
262
+ const h = harness([], undefined, () => check);
263
+ await h.reporter.report(snap());
264
+ h.advance(1_000);
265
+ check = { ok: false, reason: "missing" };
266
+ await h.reporter.report(snap());
267
+ h.advance(1_000);
268
+ check = { ok: true };
269
+ await h.reporter.report(snap());
270
+ expect(h.calls).toHaveLength(3);
271
+ const states = h.calls.map(
272
+ (c) => JSON.parse(String(c.init?.body)).installations[0].state,
273
+ );
274
+ expect(states).toEqual(["ok", "broken", "ok"]);
275
+ });
276
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-runtime",
3
- "version": "1.70.0",
3
+ "version": "1.71.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -41,8 +41,8 @@
41
41
  "./workspace-paths": "./workspace-paths.ts"
42
42
  },
43
43
  "dependencies": {
44
- "@app-vitals/agent-admin": "1.70.0",
45
- "@app-vitals/agent-lib": "1.70.0",
44
+ "@app-vitals/agent-admin": "1.71.0",
45
+ "@app-vitals/agent-lib": "1.71.0",
46
46
  "@octokit/auth-app": "^8.2.0",
47
47
  "@sentry/bun": "^10.63.0",
48
48
  "@slack/bolt": "^5.0.0",