@app-vitals/agent-admin 1.95.0 → 1.97.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-admin",
3
- "version": "1.95.0",
3
+ "version": "1.97.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@anthropic-ai/sdk": "0.137.0",
47
- "@app-vitals/agent-lib": "1.95.0",
47
+ "@app-vitals/agent-lib": "1.97.0",
48
48
  "@hono/zod-openapi": "^1.0.0",
49
49
  "@prisma/adapter-pg": "^7.10.0",
50
50
  "@prisma/client": "^7.10.0",
@@ -1378,6 +1378,122 @@ describe("admin UI — new local agent create flow", () => {
1378
1378
  );
1379
1379
  });
1380
1380
 
1381
+ // ── SWI-17.2: Slack + GitHub App no longer skips the App branch ──
1382
+
1383
+ const slackCookiePayload = (res: Response) => {
1384
+ const m = (res.headers.get("Set-Cookie") ?? "").match(
1385
+ /slack_provision_state=([^;]+)/,
1386
+ );
1387
+ expect(m).toBeTruthy();
1388
+ return JSON.parse(
1389
+ Buffer.from(
1390
+ decodeURIComponent(m?.[1] ?? "").split(".")[1] ?? "",
1391
+ "base64url",
1392
+ ).toString("utf-8"),
1393
+ );
1394
+ };
1395
+
1396
+ const manualAppForm = (extra: Record<string, string>, withId = true) => {
1397
+ const form = new FormData();
1398
+ form.append("name", "slack-gh-manual");
1399
+ form.append("type", TYPE);
1400
+ form.append("runtime", "in-cluster");
1401
+ form.append("connectSlack", "true");
1402
+ form.append("xoxpToken", "xoxe.xoxp-test-token");
1403
+ form.append("ghAuthMode", "app");
1404
+ form.append("ghAppMode", "manual");
1405
+ if (withId) form.append("ghAppId", "12345");
1406
+ form.append("ghAppInstallationId", "67890");
1407
+ form.append(
1408
+ "ghAppPrivateKeyFile",
1409
+ new File(
1410
+ ["-----BEGIN RSA PRIVATE KEY-----\nk\n-----END RSA PRIVATE KEY-----"],
1411
+ "k.pem",
1412
+ ),
1413
+ );
1414
+ for (const [k, v] of Object.entries(extra)) form.append(k, v);
1415
+ return form;
1416
+ };
1417
+
1418
+ it("Slack + manual GitHub App stores the App env before redirecting to Slack", async () => {
1419
+ const { deps, calls } = makeProvisioningDeps();
1420
+ const res = await createAdminUIApp(deps).request("/admin/agents", {
1421
+ method: "POST",
1422
+ body: manualAppForm({}),
1423
+ headers: { Cookie: `admin_session=${adminCookie}` },
1424
+ });
1425
+ expect(res.status).toBe(302);
1426
+ expect(res.headers.get("Location") ?? "").toContain(
1427
+ "slack.com/oauth/authorize",
1428
+ );
1429
+ expect(calls.envPatches.find((p) => p.env.GH_APP_ID)?.env.GH_APP_ID).toBe(
1430
+ "12345",
1431
+ );
1432
+ expect(
1433
+ calls.envPatches.find((p) => p.env.GH_APP_INSTALLATION_ID),
1434
+ ).toBeDefined();
1435
+ expect(
1436
+ calls.envPatches.find((p) => p.env.GH_APP_PRIVATE_KEY),
1437
+ ).toBeDefined();
1438
+ expect(slackCookiePayload(res).ghConnectError).toBeUndefined();
1439
+ });
1440
+
1441
+ it("Slack + manual GitHub App failure does not block Slack and is carried as a warning", async () => {
1442
+ const { deps, calls } = makeProvisioningDeps();
1443
+ const res = await createAdminUIApp(deps).request("/admin/agents", {
1444
+ method: "POST",
1445
+ body: manualAppForm({}, false),
1446
+ headers: { Cookie: `admin_session=${adminCookie}` },
1447
+ });
1448
+ expect(res.status).toBe(302);
1449
+ expect(res.headers.get("Location") ?? "").toContain(
1450
+ "slack.com/oauth/authorize",
1451
+ );
1452
+ expect(calls.envPatches.find((p) => p.env.GH_APP_ID)).toBeUndefined();
1453
+ expect(typeof slackCookiePayload(res).ghConnectError).toBe("string");
1454
+ expect(slackCookiePayload(res).ghConnectSource).toBe("app");
1455
+ });
1456
+
1457
+ it("Slack + auto GitHub App redirects to Slack and carries non-secret deferred inputs in the cookie", async () => {
1458
+ const { deps } = makeProvisioningDeps();
1459
+ const res = await postAgent(deps, {
1460
+ name: "slack-gh-auto",
1461
+ type: TYPE,
1462
+ runtime: "in-cluster",
1463
+ connectSlack: "true",
1464
+ xoxpToken: "xoxe.xoxp-test-token",
1465
+ ghAuthMode: "app",
1466
+ ghAppMode: "auto",
1467
+ githubOrg: "my-org",
1468
+ ghAppPublic: "true",
1469
+ });
1470
+ expect(res.status).toBe(302);
1471
+ expect(res.headers.get("Location") ?? "").toContain(
1472
+ "slack.com/oauth/authorize",
1473
+ );
1474
+ const payload = slackCookiePayload(res);
1475
+ expect(payload.githubOrg).toBe("my-org");
1476
+ expect(payload.ghAppPublic).toBe(true);
1477
+ expect(payload.resumeGithub).toBe(true);
1478
+ expect(JSON.stringify(payload)).not.toContain("xoxe.xoxp-test-token");
1479
+ });
1480
+
1481
+ it("Slack + PAT does not add deferred GitHub fields to the cookie", async () => {
1482
+ const { deps } = makeProvisioningDeps();
1483
+ const res = await postAgent(deps, {
1484
+ name: "slack-pat-nodefer",
1485
+ type: TYPE,
1486
+ runtime: "in-cluster",
1487
+ connectSlack: "true",
1488
+ xoxpToken: "xoxe.xoxp-test-token",
1489
+ ghAuthMode: "pat",
1490
+ ghPat: "ghp_x",
1491
+ });
1492
+ const payload = slackCookiePayload(res);
1493
+ expect(payload.resumeGithub).toBeUndefined();
1494
+ expect(payload.githubOrg).toBeUndefined();
1495
+ });
1496
+
1381
1497
  // ── UAP-5.1: runtime=self-hosted must never trigger Slack/GitHub provisioning ──
1382
1498
 
1383
1499
  it("runtime=self-hosted with connectSlack=true performs no Slack provisioning — plain redirect, no OAuth redirect, no env writes", async () => {
@@ -1030,12 +1030,18 @@ export function renderAgentSetupPage(
1030
1030
  userName: string,
1031
1031
  agent: { id: string; name: string },
1032
1032
  steps: AgentSetupStep[],
1033
+ warning?: string,
1033
1034
  ): string {
1035
+ const warningHtml = warning
1036
+ ? `<div class="alert alert-warning">${escapeHtml(warning)}</div>`
1037
+ : "";
1034
1038
  const allDone = steps.every((s) => s.connected);
1035
1039
  const agentPath = agentSectionPath(agent.id);
1036
1040
  const rows = steps
1037
1041
  .map(
1038
- (s) => `<li class="setup-step" data-step="${s.id}" data-connected="${s.connected}" style="display:flex;justify-content:space-between;align-items:center;padding:8px 0">
1042
+ (
1043
+ s,
1044
+ ) => `<li class="setup-step" data-step="${s.id}" data-connected="${s.connected}" style="display:flex;justify-content:space-between;align-items:center;padding:8px 0">
1039
1045
  <span>${s.connected ? "✅" : "⬜"} ${escapeHtml(s.id === "slack" ? "Slack" : "GitHub")}: ${s.connected ? "connected" : "not connected"}</span>
1040
1046
  ${s.connected ? "" : `<a class="btn btn-primary" href="${escapeHtml(s.href)}">${escapeHtml(s.label)}</a>`}
1041
1047
  </li>`,
@@ -1052,6 +1058,7 @@ export function renderAgentSetupPage(
1052
1058
  <h1 class="page-title">Set up ${escapeHtml(agent.name)}</h1>
1053
1059
  </div>
1054
1060
  <div class="card">
1061
+ ${warningHtml}
1055
1062
  ${doneHtml}
1056
1063
  <ul style="list-style:none;padding:0;margin:0">
1057
1064
  ${rows}
@@ -2436,7 +2443,7 @@ export function renderAgentDetailPage(
2436
2443
  */
2437
2444
  export function renderGithubAppManifestRedirectPage(
2438
2445
  userName: string,
2439
- opts: { githubOrg: string; manifest: unknown },
2446
+ opts: { githubOrg: string; manifest: unknown; warning?: string },
2440
2447
  ): string {
2441
2448
  const actionUrl = `https://github.com/organizations/${encodeURIComponent(opts.githubOrg)}/settings/apps/new`;
2442
2449
  const manifestJson = JSON.stringify(opts.manifest);
@@ -2454,6 +2461,7 @@ export function renderGithubAppManifestRedirectPage(
2454
2461
  <span class="provision-step">3. Complete</span>
2455
2462
  </div>
2456
2463
  <div class="card">
2464
+ ${opts.warning ? `<div class="alert alert-warning">${escapeHtml(opts.warning)}</div>` : ""}
2457
2465
  <p style="font-size:14px;margin-bottom:16px;color:var(--vos-text-muted)">
2458
2466
  Redirecting to GitHub to create the GitHub App under <strong>${escapeHtml(opts.githubOrg)}</strong>…
2459
2467
  </p>
@@ -0,0 +1,258 @@
1
+ /**
2
+ * Smoke tests (app.request()) for SWI-17.3: Slack callback / app-token hand
3
+ * off to the setup page, which auto-starts the carried GitHub App step.
4
+ */
5
+ import { beforeAll, describe, expect, it } from "bun:test";
6
+ import { sign } from "hono/jwt";
7
+ import {
8
+ AGENT_ID,
9
+ makeMockDeps,
10
+ makeSessionCookie,
11
+ SESSION_SECRET,
12
+ } from "./admin-ui.fixtures.ts";
13
+ import { createAdminUIApp } from "./admin-ui.ts";
14
+ import { signSetupResume } from "./setup-resume.ts";
15
+
16
+ const PROVISION_STATE_COOKIE = "slack_provision_state";
17
+
18
+ function makeApp(env: Record<string, string> = {}, bundle = false) {
19
+ return createAdminUIApp(
20
+ makeMockDeps({
21
+ agentEnvService: {
22
+ getByAgentId: async () => ({ env, secretKeys: [] }),
23
+ upsert: async () => {},
24
+ patch: async () => {},
25
+ deleteKey: async () => {},
26
+ getConfigBundle: async () =>
27
+ bundle
28
+ ? { agentId: AGENT_ID, env, secretKeys: [], allowedTools: [] }
29
+ : null,
30
+ },
31
+ }),
32
+ );
33
+ }
34
+
35
+ async function slackState(extra: Record<string, unknown> = {}) {
36
+ const now = Math.floor(Date.now() / 1000);
37
+ return sign(
38
+ {
39
+ agentId: AGENT_ID,
40
+ clientId: "c",
41
+ clientSecret: "cs",
42
+ signingSecret: "ss",
43
+ appId: "A0123456789",
44
+ iat: now,
45
+ exp: now + 300,
46
+ ...extra,
47
+ },
48
+ SESSION_SECRET,
49
+ "HS256",
50
+ );
51
+ }
52
+
53
+ /** Pull `name=value` for a Set-Cookie name out of a response (undefined if absent / cleared). */
54
+ function setCookieValue(res: Response, name: string): string | undefined {
55
+ for (const h of res.headers.getSetCookie()) {
56
+ const m = h.match(new RegExp(`^${name}=([^;]*)`));
57
+ if (m?.[1]) return m[1];
58
+ }
59
+ return undefined;
60
+ }
61
+
62
+ describe("Slack -> setup hand-off (SWI-17.3)", () => {
63
+ let admin: string;
64
+ beforeAll(async () => {
65
+ admin = await makeSessionCookie(SESSION_SECRET);
66
+ });
67
+ const headers = (extra = "") => ({
68
+ Cookie: `admin_session=${admin}${extra}`,
69
+ });
70
+ const callback = async (
71
+ app: ReturnType<typeof makeApp>,
72
+ extra: Record<string, unknown>,
73
+ ) =>
74
+ app.request(
75
+ `/admin/agents/${AGENT_ID}/connect-slack/callback?code=valid-oauth-code`,
76
+ {
77
+ headers: headers(
78
+ `; ${PROVISION_STATE_COOKIE}=${await slackState(extra)}`,
79
+ ),
80
+ redirect: "manual",
81
+ },
82
+ );
83
+
84
+ it("Slack-only callback keeps the xapp-token page and sets no setup_resume", async () => {
85
+ const res = await callback(makeApp(), {});
86
+ expect(res.status).toBe(200);
87
+ expect((await res.text()).toLowerCase()).toContain("xapp");
88
+ expect(setCookieValue(res, "setup_resume")).toBeUndefined();
89
+ });
90
+
91
+ it("Slack-only app-token completion keeps the terminal page", async () => {
92
+ const res = await makeApp().request(
93
+ `/admin/agents/${AGENT_ID}/connect-slack/app-token`,
94
+ {
95
+ method: "POST",
96
+ body: new URLSearchParams({ xappToken: "xapp-1-TEST" }).toString(),
97
+ headers: {
98
+ "Content-Type": "application/x-www-form-urlencoded",
99
+ ...headers(),
100
+ },
101
+ redirect: "manual",
102
+ },
103
+ );
104
+ expect(res.status).toBe(200);
105
+ });
106
+
107
+ it("a carried warning still surfaces on the auto-started manifest redirect page", async () => {
108
+ const token = await signSetupResume(
109
+ {
110
+ agentId: AGENT_ID,
111
+ githubOrg: "my-org",
112
+ resumeGithub: true,
113
+ warning: "GitHub was not connected — boom",
114
+ },
115
+ SESSION_SECRET,
116
+ );
117
+ const res = await makeApp().request(`/admin/agents/${AGENT_ID}/setup`, {
118
+ headers: headers(`; setup_resume=${token}`),
119
+ });
120
+ expect(res.status).toBe(200);
121
+ const body = await res.text();
122
+ expect(body).toContain("github-app-manifest-form");
123
+ expect(body).toContain("GitHub was not connected — boom");
124
+ });
125
+
126
+ it("carried GitHub step: callback shows xapp form, app-token redirects to setup, setup auto-starts the manifest redirect", async () => {
127
+ const app = makeApp();
128
+ const cb = await callback(app, {
129
+ githubOrg: "my-org",
130
+ ghAppPublic: true,
131
+ resumeGithub: true,
132
+ });
133
+ expect(cb.status).toBe(200);
134
+ expect((await cb.text()).toLowerCase()).toContain("xapp");
135
+ const resume = setCookieValue(cb, "setup_resume");
136
+ expect(resume).toBeTruthy();
137
+
138
+ const tok = await app.request(
139
+ `/admin/agents/${AGENT_ID}/connect-slack/app-token`,
140
+ {
141
+ method: "POST",
142
+ body: new URLSearchParams({ xappToken: "xapp-1-TEST" }).toString(),
143
+ headers: {
144
+ "Content-Type": "application/x-www-form-urlencoded",
145
+ ...headers(`; setup_resume=${resume}`),
146
+ },
147
+ redirect: "manual",
148
+ },
149
+ );
150
+ expect(tok.status).toBe(302);
151
+ expect(tok.headers.get("Location")).toBe(`/admin/agents/${AGENT_ID}/setup`);
152
+
153
+ const setup = await app.request(`/admin/agents/${AGENT_ID}/setup`, {
154
+ headers: headers(`; setup_resume=${resume}`),
155
+ });
156
+ expect(setup.status).toBe(200);
157
+ const body = await setup.text();
158
+ expect(body).toContain("github-app-manifest-form");
159
+ expect(body).toContain("organizations/my-org/settings/apps/new");
160
+ expect(body).toContain("&quot;public&quot;:true");
161
+ expect(setCookieValue(setup, "github_provision_state")).toBeTruthy();
162
+ expect(setup.headers.getSetCookie().join("\n")).toContain("setup_resume=;");
163
+ });
164
+
165
+ it("carried GitHub step on a Slack reinstall redirects straight to setup", async () => {
166
+ const app = makeApp({ SLACK_APP_TOKEN: "xapp-x" }, true);
167
+ const cb = await callback(app, { githubOrg: "o", resumeGithub: true });
168
+ expect(cb.status).toBe(302);
169
+ expect(cb.headers.get("Location")).toBe(`/admin/agents/${AGENT_ID}/setup`);
170
+ expect(setCookieValue(cb, "setup_resume")).toBeTruthy();
171
+ });
172
+
173
+ it("does not auto-start when GitHub is already connected", async () => {
174
+ const resume = await signSetupResume(
175
+ { agentId: AGENT_ID, githubOrg: "o", resumeGithub: true },
176
+ SESSION_SECRET,
177
+ );
178
+ const res = await makeApp({ GH_APP_ID: "1" }).request(
179
+ `/admin/agents/${AGENT_ID}/setup`,
180
+ { headers: headers(`; setup_resume=${resume}`) },
181
+ );
182
+ const body = await res.text();
183
+ expect(body).not.toContain("github-app-manifest-form");
184
+ expect(body).toContain("GitHub: connected");
185
+ });
186
+
187
+ it("an invalid org degrades to the checklist with a warning, not an error page", async () => {
188
+ const resume = await signSetupResume(
189
+ { agentId: AGENT_ID, githubOrg: "bad org!", resumeGithub: true },
190
+ SESSION_SECRET,
191
+ );
192
+ const res = await makeApp().request(`/admin/agents/${AGENT_ID}/setup`, {
193
+ headers: headers(`; setup_resume=${resume}`),
194
+ });
195
+ expect(res.status).toBe(200);
196
+ const body = await res.text();
197
+ expect(body).toContain("GitHub: not connected");
198
+ expect(body).toContain("GitHub was not connected");
199
+ });
200
+
201
+ it.each([
202
+ ["garbage", "garbage"],
203
+ ["wrong secret", "WRONG"],
204
+ ["expired", "EXPIRED"],
205
+ ["other agent", "OTHER"],
206
+ ])(
207
+ "a %s setup_resume cookie degrades to the plain checklist",
208
+ async (_n, kind) => {
209
+ const now = Math.floor(Date.now() / 1000);
210
+ let token = "garbage";
211
+ if (kind === "WRONG")
212
+ token = await signSetupResume(
213
+ { agentId: AGENT_ID, githubOrg: "o", resumeGithub: true },
214
+ "other-secret",
215
+ );
216
+ if (kind === "EXPIRED")
217
+ token = await sign(
218
+ {
219
+ agentId: AGENT_ID,
220
+ githubOrg: "o",
221
+ resumeGithub: true,
222
+ exp: now - 5,
223
+ },
224
+ SESSION_SECRET,
225
+ "HS256",
226
+ );
227
+ if (kind === "OTHER")
228
+ token = await signSetupResume(
229
+ { agentId: "someone-else", githubOrg: "o", resumeGithub: true },
230
+ SESSION_SECRET,
231
+ );
232
+ const res = await makeApp().request(`/admin/agents/${AGENT_ID}/setup`, {
233
+ headers: headers(`; setup_resume=${token}`),
234
+ });
235
+ expect(res.status).toBe(200);
236
+ const body = await res.text();
237
+ expect(body).toContain("GitHub: not connected");
238
+ expect(body).not.toContain("github-app-manifest-form");
239
+ },
240
+ );
241
+
242
+ it("ghConnectError still surfaces for a PAT-failure Slack flow (existing terminal behavior)", async () => {
243
+ const cb = await callback(makeApp(), { ghConnectError: "bad pat" });
244
+ expect(cb.status).toBe(200);
245
+ expect(await cb.text()).toContain("bad pat");
246
+ });
247
+
248
+ it("a carried warning surfaces on the setup page", async () => {
249
+ const resume = await signSetupResume(
250
+ { agentId: AGENT_ID, warning: "GitHub was not connected — boom" },
251
+ SESSION_SECRET,
252
+ );
253
+ const res = await makeApp().request(`/admin/agents/${AGENT_ID}/setup`, {
254
+ headers: headers(`; setup_resume=${resume}`),
255
+ });
256
+ expect(await res.text()).toContain("GitHub was not connected — boom");
257
+ });
258
+ });
package/src/admin-ui.ts CHANGED
@@ -167,6 +167,12 @@ import {
167
167
  DEFAULT_SELF_SERVE_CONTACT_EMAIL,
168
168
  type SelfServeConfig,
169
169
  } from "./self-serve-config.ts";
170
+ import {
171
+ SETUP_RESUME_COOKIE,
172
+ SETUP_RESUME_TTL_SECONDS,
173
+ signSetupResume,
174
+ verifySetupResume,
175
+ } from "./setup-resume.ts";
170
176
  import {
171
177
  hasStoredSlackConfigToken,
172
178
  type SlackConfigTokenResolver,
@@ -178,6 +184,7 @@ import {
178
184
  buildAgentManifest,
179
185
  } from "./slack-provisioning-client.ts";
180
186
  import {
187
+ type DeferredGithubState,
181
188
  PROVISION_STATE_COOKIE,
182
189
  PROVISION_STATE_TTL_SECONDS,
183
190
  SlackProvisioningService,
@@ -1716,6 +1723,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1716
1723
  let ghAppId: string | undefined;
1717
1724
  let ghAppInstallationId: string | undefined;
1718
1725
  let ghAppPrivateKey: string | undefined;
1726
+ let ghAppPublic = false;
1719
1727
  let templateDetachedRaw: string | undefined;
1720
1728
  let envRaw: string | undefined;
1721
1729
  try {
@@ -1748,6 +1756,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1748
1756
  ghAppMode = formData.get("ghAppMode")?.toString()?.trim();
1749
1757
  ghAppId = formData.get("ghAppId")?.toString();
1750
1758
  ghAppInstallationId = formData.get("ghAppInstallationId")?.toString();
1759
+ ghAppPublic = formData.get("ghAppPublic")?.toString() === "true";
1751
1760
  // UAP-5.3: the "Use existing GitHub App" option submits the private
1752
1761
  // key as a file upload rather than pasted text — read its contents
1753
1762
  // server-side, mirroring the per-agent connect-github route.
@@ -1859,9 +1868,11 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1859
1868
  // Slack/GitHub can produce the final HTTP response. When both are
1860
1869
  // requested, GitHub's storage/redirect-prep runs first (PAT storage is
1861
1870
  // synchronous; the App-manifest flow can't run before Slack's redirect
1862
- // either, so it's skipped when Slack is also requested) so GH_TOKEN is
1863
- // already in place by the time the user lands back from Slack's OAuth
1864
- // callback — then Slack's redirect is returned last.
1871
+ // either, so with Slack its non-secret inputs are carried in the signed
1872
+ // provision-state cookie (SWI-17.2) and resumed after the callback). The
1873
+ // manual-App branch is synchronous and runs inline before Slack's redirect
1874
+ // like PAT, so GH_APP_* is in place by the time the user lands back — then
1875
+ // Slack's redirect is returned last.
1865
1876
  //
1866
1877
  // UAP-5.1: this whole block only applies to in-cluster agents. Self-hosted
1867
1878
  // agents use local git config for GitHub auth, not admin-managed
@@ -1892,20 +1903,60 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1892
1903
  }
1893
1904
  }
1894
1905
 
1906
+ // UAP-5.3 / SWI-17.2: "Use existing GitHub App" — validates and persists
1907
+ // GH_APP_ID/GH_APP_INSTALLATION_ID/GH_APP_PRIVATE_KEY directly, no GitHub
1908
+ // API call. Runs inline BEFORE Slack's redirect so it is never skipped
1909
+ // when Slack is selected. Without Slack a failure redirects as before;
1910
+ // with Slack it is carried as a non-blocking warning like the PAT failure.
1911
+ let ghManualError: string | undefined;
1912
+ if (ghAuthMode === "app" && ghAppMode === "manual") {
1913
+ const manualResult =
1914
+ await githubProvisioningService.startAppManualConnect(agent.id, {
1915
+ ghAppId,
1916
+ ghAppInstallationId,
1917
+ ghAppPrivateKey,
1918
+ });
1919
+ if (!manualResult.ok) {
1920
+ if (!connectSlack) {
1921
+ return c.redirect(
1922
+ `/admin/agents/${agent.id}?error=${encodeURIComponent(manualResult.error)}`,
1923
+ 302,
1924
+ );
1925
+ }
1926
+ console.error(
1927
+ "[admin-ui] GitHub App manual storage failed during combined Slack+GitHub connect:",
1928
+ manualResult.error,
1929
+ );
1930
+ ghManualError = manualResult.error;
1931
+ }
1932
+ }
1933
+
1895
1934
  if (connectSlack) {
1896
1935
  const redirectUri = `${appBaseUrl}/admin/agents/${agent.id}/connect-slack/callback`;
1897
- // Carry a failed-PAT-storage warning (UAP-2.1) through Slack's OAuth
1898
- // round trip via the signed provision-state cookie so it resurfaces on
1899
- // the post-callback landing page. Without this, a GitHub PAT that failed
1900
- // to store above would be silently swallowed and the operator misled
1901
- // into believing GH_TOKEN was connected.
1936
+ // Carry a failed-PAT/manual-App storage warning (UAP-2.1) through
1937
+ // Slack's OAuth round trip via the signed provision-state cookie so it
1938
+ // resurfaces on the post-callback landing page.
1902
1939
  const ghConnectError =
1903
- ghPatResult && !ghPatResult.ok ? ghPatResult.error : undefined;
1940
+ (ghPatResult && !ghPatResult.ok ? ghPatResult.error : undefined) ??
1941
+ ghManualError;
1942
+ // SWI-17.2: auto App can't run before Slack's redirect; carry its
1943
+ // non-secret inputs (never tokens) so the callback can resume it.
1944
+ const deferredGithub: DeferredGithubState | undefined =
1945
+ ghAuthMode === "app" && ghAppMode !== "manual"
1946
+ ? {
1947
+ githubOrg,
1948
+ ghAppPublic,
1949
+ resumeGithub: true,
1950
+ }
1951
+ : ghManualError
1952
+ ? { ghConnectSource: "app" }
1953
+ : undefined;
1904
1954
  const slackResult = await slackProvisioningService.startConnect(
1905
1955
  agent.id,
1906
1956
  xoxpToken,
1907
1957
  redirectUri,
1908
1958
  ghConnectError,
1959
+ deferredGithub,
1909
1960
  );
1910
1961
  if (!slackResult.ok) {
1911
1962
  return c.redirect(
@@ -1923,25 +1974,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1923
1974
  return c.redirect(slackResult.oauthRedirectUrl, 302);
1924
1975
  }
1925
1976
 
1926
- if (ghAuthMode === "app" && ghAppMode === "manual") {
1927
- // UAP-5.3: "Use existing GitHub App" — validates and persists
1928
- // GH_APP_ID/GH_APP_INSTALLATION_ID/GH_APP_PRIVATE_KEY directly, no
1929
- // GitHub API call. On success falls through to the shared
1930
- // redirectWithMembersWarning below, matching the ghAuthMode=pat
1931
- // branch's success path.
1932
- const manualResult =
1933
- await githubProvisioningService.startAppManualConnect(agent.id, {
1934
- ghAppId,
1935
- ghAppInstallationId,
1936
- ghAppPrivateKey,
1937
- });
1938
- if (!manualResult.ok) {
1939
- return c.redirect(
1940
- `/admin/agents/${agent.id}?error=${encodeURIComponent(manualResult.error)}`,
1941
- 302,
1942
- );
1943
- }
1944
- } else if (ghAuthMode === "app") {
1977
+ // Manual App was handled above; success falls through to the shared
1978
+ // redirectWithMembersWarning below.
1979
+ if (ghAuthMode === "app" && ghAppMode !== "manual") {
1945
1980
  const appResult = await githubProvisioningService.startAppAutoConnect(
1946
1981
  agent.id,
1947
1982
  githubOrg,
@@ -2717,11 +2752,54 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
2717
2752
  return new Response("Forbidden", { status: 403 });
2718
2753
  }
2719
2754
  const envResult = await agentEnvService.getByAgentId(agentId);
2755
+ const steps = deriveAgentSetupSteps(agentId, envResult?.env ?? {});
2756
+ // SWI-17.3: read-and-clear the Slack hand-off cookie. Anything invalid,
2757
+ // expired or for another agent degrades to the plain checklist.
2758
+ const rawResume = getCookie(c, SETUP_RESUME_COOKIE);
2759
+ if (rawResume !== undefined) deleteCookie(c, SETUP_RESUME_COOKIE);
2760
+ const verified = await verifySetupResume(rawResume, sessionSecret);
2761
+ const resume = verified?.agentId === agentId ? verified : null;
2762
+ let warning = resume?.warning;
2763
+ const githubConnected = steps.find((s) => s.id === "github")?.connected;
2764
+ if (resume?.resumeGithub && !githubConnected) {
2765
+ const appResult = await githubProvisioningService.startAppAutoConnect(
2766
+ agentId,
2767
+ resume.githubOrg,
2768
+ {
2769
+ redirectUri: `${appBaseUrl}/admin/agents/${agentId}/connect-github/callback`,
2770
+ setupUrl: `${appBaseUrl}/admin/agents/${agentId}/connect-github/installed`,
2771
+ },
2772
+ { public: resume.ghAppPublic === true },
2773
+ );
2774
+ if (appResult.ok) {
2775
+ setCookie(
2776
+ c,
2777
+ GITHUB_PROVISION_STATE_COOKIE,
2778
+ appResult.provisionStateToken,
2779
+ {
2780
+ httpOnly: true,
2781
+ maxAge: GITHUB_PROVISION_STATE_TTL_SECONDS,
2782
+ sameSite: "Lax",
2783
+ path: "/",
2784
+ secure: appBaseUrl.startsWith("https://"),
2785
+ },
2786
+ );
2787
+ return c.html(
2788
+ renderGithubAppManifestRedirectPage(c.var.userEmail, {
2789
+ githubOrg: appResult.githubOrg,
2790
+ manifest: appResult.manifest,
2791
+ warning,
2792
+ }),
2793
+ );
2794
+ }
2795
+ warning = `GitHub was not connected — ${appResult.error}`;
2796
+ }
2720
2797
  return html(
2721
2798
  renderAgentSetupPage(
2722
2799
  c.var.userEmail,
2723
2800
  { id: agent.id, name: agent.name },
2724
- deriveAgentSetupSteps(agentId, envResult?.env ?? {}),
2801
+ steps,
2802
+ warning,
2725
2803
  ),
2726
2804
  );
2727
2805
  });
@@ -3886,9 +3964,40 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
3886
3964
  // cookie — surface it now so the operator isn't misled into believing
3887
3965
  // GH_TOKEN was stored.
3888
3966
  const ghConnectWarning = result.ghConnectError
3889
- ? `GitHub was not connected — storing the PAT failed: ${result.ghConnectError}`
3967
+ ? result.ghConnectSource === "app"
3968
+ ? `GitHub was not connected — storing the GitHub App credentials failed: ${result.ghConnectError}`
3969
+ : `GitHub was not connected — storing the PAT failed: ${result.ghConnectError}`
3890
3970
  : undefined;
3891
3971
 
3972
+ // SWI-17.3: a carried GitHub step hands off to the setup page via a
3973
+ // short-lived signed cookie (the Slack cookie is consumed above).
3974
+ if (result.resumeGithub) {
3975
+ setCookie(
3976
+ c,
3977
+ SETUP_RESUME_COOKIE,
3978
+ await signSetupResume(
3979
+ {
3980
+ agentId: result.agentId,
3981
+ githubOrg: result.githubOrg,
3982
+ ghAppPublic: result.ghAppPublic,
3983
+ resumeGithub: true,
3984
+ warning: ghConnectWarning,
3985
+ },
3986
+ sessionSecret,
3987
+ ),
3988
+ {
3989
+ httpOnly: true,
3990
+ maxAge: SETUP_RESUME_TTL_SECONDS,
3991
+ sameSite: "Lax",
3992
+ path: "/",
3993
+ secure: appBaseUrl.startsWith("https://"),
3994
+ },
3995
+ );
3996
+ if (result.outcome === "reinstalled") {
3997
+ return c.redirect(`/admin/agents/${result.agentId}/setup`, 302);
3998
+ }
3999
+ }
4000
+
3892
4001
  if (result.outcome === "reinstalled") {
3893
4002
  const query = ghConnectWarning
3894
4003
  ? `?success=reinstalled&warning=${encodeURIComponent(ghConnectWarning)}`
@@ -3899,8 +4008,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
3899
4008
  );
3900
4009
  }
3901
4010
 
3902
- // result.outcome === "needs_app_token"
3903
- return html(
4011
+ // result.outcome === "needs_app_token". c.html() so a Set-Cookie from
4012
+ // the SWI-17.3 hand-off above is included.
4013
+ return c.html(
3904
4014
  renderProvisionXappTokenPage(userEmail, {
3905
4015
  agentId: result.agentId,
3906
4016
  warning: ghConnectWarning,
@@ -3946,6 +4056,16 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
3946
4056
  );
3947
4057
  }
3948
4058
 
4059
+ // SWI-17.3: a carried GitHub step (valid setup_resume cookie for this
4060
+ // agent) continues on the setup page, which reads and clears the cookie.
4061
+ const resume = await verifySetupResume(
4062
+ getCookie(c, SETUP_RESUME_COOKIE),
4063
+ sessionSecret,
4064
+ );
4065
+ if (resume?.resumeGithub && resume.agentId === result.agentId) {
4066
+ return c.redirect(`/admin/agents/${result.agentId}/setup`, 302);
4067
+ }
4068
+
3949
4069
  return html(
3950
4070
  renderProvisionCompletePage(userEmail, {
3951
4071
  success: true,
@@ -0,0 +1,53 @@
1
+ /**
2
+ * SWI-17.3: short-lived signed `setup_resume` cookie. The Slack callback
3
+ * consumes the Slack provision-state cookie and the xapp-token form sits in
4
+ * between, so the deferred (non-secret) GitHub step is re-signed here and read
5
+ * and cleared by the setup page. Verification never throws: a missing, expired
6
+ * or tampered cookie yields `null` so the setup page degrades to the checklist.
7
+ */
8
+ import { sign, verify } from "hono/jwt";
9
+
10
+ export const SETUP_RESUME_COOKIE = "setup_resume";
11
+ export const SETUP_RESUME_TTL_SECONDS = 900; // 15 min: covers the xapp-token form
12
+
13
+ export interface SetupResume {
14
+ agentId: string;
15
+ githubOrg?: string;
16
+ ghAppPublic?: boolean;
17
+ resumeGithub?: boolean;
18
+ /** Non-blocking GitHub warning carried from the combined create flow. */
19
+ warning?: string;
20
+ }
21
+
22
+ export async function signSetupResume(
23
+ data: SetupResume,
24
+ secret: string,
25
+ ): Promise<string> {
26
+ const now = Math.floor(Date.now() / 1000);
27
+ return sign(
28
+ { ...data, iat: now, exp: now + SETUP_RESUME_TTL_SECONDS },
29
+ secret,
30
+ "HS256",
31
+ );
32
+ }
33
+
34
+ export async function verifySetupResume(
35
+ token: string | undefined,
36
+ secret: string,
37
+ ): Promise<SetupResume | null> {
38
+ if (!token) return null;
39
+ try {
40
+ const p = (await verify(token, secret, "HS256")) as Record<string, unknown>;
41
+ if (typeof p.agentId !== "string") return null;
42
+ return {
43
+ agentId: p.agentId,
44
+ githubOrg: typeof p.githubOrg === "string" ? p.githubOrg : undefined,
45
+ ghAppPublic:
46
+ typeof p.ghAppPublic === "boolean" ? p.ghAppPublic : undefined,
47
+ resumeGithub: p.resumeGithub === true ? true : undefined,
48
+ warning: typeof p.warning === "string" ? p.warning : undefined,
49
+ };
50
+ } catch {
51
+ return null;
52
+ }
53
+ }
@@ -0,0 +1,55 @@
1
+ import { describe, expect, it } from "bun:test";
2
+ import { sign } from "hono/jwt";
3
+ import {
4
+ SETUP_RESUME_COOKIE,
5
+ signSetupResume,
6
+ verifySetupResume,
7
+ } from "./setup-resume.ts";
8
+
9
+ const SECRET = "s3cret";
10
+
11
+ describe("setup_resume cookie", () => {
12
+ it("uses the setup_resume cookie name", () => {
13
+ expect(SETUP_RESUME_COOKIE).toBe("setup_resume");
14
+ });
15
+
16
+ it("round-trips carried data", async () => {
17
+ const token = await signSetupResume(
18
+ {
19
+ agentId: "a1",
20
+ githubOrg: "org",
21
+ ghAppPublic: true,
22
+ resumeGithub: true,
23
+ },
24
+ SECRET,
25
+ );
26
+ expect(await verifySetupResume(token, SECRET)).toEqual({
27
+ agentId: "a1",
28
+ githubOrg: "org",
29
+ ghAppPublic: true,
30
+ resumeGithub: true,
31
+ warning: undefined,
32
+ });
33
+ });
34
+
35
+ it("returns null for missing, tampered, wrong-secret and expired tokens", async () => {
36
+ const token = await signSetupResume({ agentId: "a1" }, SECRET);
37
+ expect(await verifySetupResume(undefined, SECRET)).toBeNull();
38
+ expect(await verifySetupResume("garbage", SECRET)).toBeNull();
39
+ expect(await verifySetupResume(token, "other")).toBeNull();
40
+ expect(await verifySetupResume(`${token}x`, SECRET)).toBeNull();
41
+ const now = Math.floor(Date.now() / 1000);
42
+ const expired = await sign(
43
+ { agentId: "a1", iat: now - 100, exp: now - 10 },
44
+ SECRET,
45
+ "HS256",
46
+ );
47
+ expect(await verifySetupResume(expired, SECRET)).toBeNull();
48
+ });
49
+
50
+ it("returns null when the payload has no agentId", async () => {
51
+ const now = Math.floor(Date.now() / 1000);
52
+ const t = await sign({ exp: now + 60 }, SECRET, "HS256");
53
+ expect(await verifySetupResume(t, SECRET)).toBeNull();
54
+ });
55
+ });
@@ -53,6 +53,18 @@ interface ProvisionStatePayload {
53
53
  redirectUri?: string;
54
54
  }
55
55
 
56
+ /**
57
+ * SWI-17.2: non-secret GitHub inputs deferred across Slack's OAuth round trip
58
+ * (auto GitHub App selected together with Slack). Never carries secrets.
59
+ */
60
+ export interface DeferredGithubState {
61
+ githubOrg?: string;
62
+ ghAppPublic?: boolean;
63
+ resumeGithub?: boolean;
64
+ /** Which GitHub step produced `ghConnectError`; absent means the PAT. */
65
+ ghConnectSource?: "app";
66
+ }
67
+
56
68
  type StartConnectResult =
57
69
  | {
58
70
  ok: true;
@@ -90,6 +102,11 @@ export type CompleteConnectResult =
90
102
  * isn't misled into believing GH_TOKEN was stored.
91
103
  */
92
104
  ghConnectError?: string;
105
+ /** SWI-17.2 deferred GitHub inputs (absent on older cookies). */
106
+ githubOrg?: string;
107
+ ghAppPublic?: boolean;
108
+ resumeGithub?: boolean;
109
+ ghConnectSource?: "app";
93
110
  }
94
111
  | {
95
112
  /** Success, fresh provisioning — show the xapp-token page next. */
@@ -97,6 +114,10 @@ export type CompleteConnectResult =
97
114
  agentId: string;
98
115
  /** See `reinstalled.ghConnectError` — same non-fatal combined-flow warning. */
99
116
  ghConnectError?: string;
117
+ githubOrg?: string;
118
+ ghAppPublic?: boolean;
119
+ resumeGithub?: boolean;
120
+ ghConnectSource?: "app";
100
121
  };
101
122
 
102
123
  type SaveAppTokenResult =
@@ -235,6 +256,7 @@ export class SlackProvisioningService {
235
256
  xoxpToken: string | undefined,
236
257
  redirectUri: string,
237
258
  ghConnectError?: string,
259
+ deferredGithub?: DeferredGithubState,
238
260
  ): Promise<StartConnectResult> {
239
261
  const prefixError = {
240
262
  ok: false,
@@ -286,7 +308,17 @@ export class SlackProvisioningService {
286
308
  appId,
287
309
  redirectUri,
288
310
  },
289
- ghConnectError ? { ghConnectError } : undefined,
311
+ {
312
+ ...(ghConnectError ? { ghConnectError } : {}),
313
+ ...(deferredGithub?.githubOrg
314
+ ? { githubOrg: deferredGithub.githubOrg }
315
+ : {}),
316
+ ...(deferredGithub?.ghAppPublic !== undefined
317
+ ? { ghAppPublic: deferredGithub.ghAppPublic }
318
+ : {}),
319
+ ...(deferredGithub?.resumeGithub ? { resumeGithub: true } : {}),
320
+ ...(deferredGithub?.ghConnectSource ? { ghConnectSource: "app" } : {}),
321
+ },
290
322
  );
291
323
 
292
324
  return { ok: true, provisionStateToken, oauthRedirectUrl };
@@ -328,6 +360,7 @@ export class SlackProvisioningService {
328
360
  // escapes the verify() try block; kept separate from the
329
361
  // ProvisionStatePayload shape since it's flow-specific, not Slack state.
330
362
  let ghConnectError: string | undefined;
363
+ let deferred: DeferredGithubState = {};
331
364
  try {
332
365
  const payload = (await verify(
333
366
  rawStateCookie,
@@ -358,6 +391,19 @@ export class SlackProvisioningService {
358
391
  typeof payload.ghConnectError === "string"
359
392
  ? payload.ghConnectError
360
393
  : undefined;
394
+ deferred = {
395
+ githubOrg:
396
+ typeof payload.githubOrg === "string" ? payload.githubOrg : undefined,
397
+ ghAppPublic:
398
+ typeof payload.ghAppPublic === "boolean"
399
+ ? payload.ghAppPublic
400
+ : undefined,
401
+ resumeGithub:
402
+ typeof payload.resumeGithub === "boolean"
403
+ ? payload.resumeGithub
404
+ : undefined,
405
+ ghConnectSource: payload.ghConnectSource === "app" ? "app" : undefined,
406
+ };
361
407
  } catch {
362
408
  return {
363
409
  outcome: "invalid_state",
@@ -425,6 +471,7 @@ export class SlackProvisioningService {
425
471
  outcome: "reinstalled",
426
472
  agentId: provisionState.agentId,
427
473
  ghConnectError,
474
+ ...deferred,
428
475
  };
429
476
  }
430
477
 
@@ -432,6 +479,7 @@ export class SlackProvisioningService {
432
479
  outcome: "needs_app_token",
433
480
  agentId: provisionState.agentId,
434
481
  ghConnectError,
482
+ ...deferred,
435
483
  };
436
484
  }
437
485
 
@@ -0,0 +1,124 @@
1
+ /**
2
+ * SWI-17.2: the signed Slack provision-state cookie carries non-secret
3
+ * deferred GitHub inputs (githubOrg, ghAppPublic, resumeGithub) alongside
4
+ * ghConnectError, and completeConnect() hands them back. Older cookies without
5
+ * the fields must keep verifying.
6
+ */
7
+ import { describe, expect, it } from "bun:test";
8
+ import { sign } from "hono/jwt";
9
+ import { SlackProvisioningService } from "./slack-provisioning-service.ts";
10
+
11
+ const SECRET = "test-admin-session-secret-32-bytes!";
12
+ const AGENT_ID = "agent-1";
13
+ const CALLBACK =
14
+ "https://example.com/admin/agents/agent-1/connect-slack/callback";
15
+
16
+ function makeService() {
17
+ return new SlackProvisioningService({
18
+ slackClient: {
19
+ createAppManifest: async () => ({
20
+ appId: "A1",
21
+ oauthRedirectUrl: "https://slack.com/oauth/v2/authorize?x=1",
22
+ clientId: "cid",
23
+ clientSecret: "csecret",
24
+ signingSecret: "ssecret",
25
+ }),
26
+ updateAppManifest: async () => {},
27
+ exchangeOAuthCode: async () => ({ botToken: "xoxb-bot" }),
28
+ authTest: async () => ({ userId: "U1" }),
29
+ },
30
+ agentService: {
31
+ getDetail: async () => ({ id: AGENT_ID, name: "a", accountId: null }),
32
+ updateFields: async () => ({}),
33
+ },
34
+ agentEnvService: {
35
+ patch: async () => {},
36
+ getConfigBundle: async () => null,
37
+ },
38
+ agentCronJobService: { reconcileSystemCrons: async () => ({}) },
39
+ sessionSecret: SECRET,
40
+ appBaseUrl: "https://example.com",
41
+ secretEnvVars: new Set(),
42
+ } as unknown as ConstructorParameters<typeof SlackProvisioningService>[0]);
43
+ }
44
+
45
+ function decode(token: string): Record<string, unknown> {
46
+ return JSON.parse(
47
+ Buffer.from(token.split(".")[1] ?? "", "base64url").toString("utf-8"),
48
+ );
49
+ }
50
+
51
+ describe("SlackProvisioningService deferred GitHub state", () => {
52
+ it("startConnect folds deferred non-secret GitHub inputs into the signed state", async () => {
53
+ const r = await makeService().startConnect(
54
+ AGENT_ID,
55
+ "xoxe.xoxp-secret-token",
56
+ CALLBACK,
57
+ undefined,
58
+ { githubOrg: "my-org", ghAppPublic: true, resumeGithub: true },
59
+ );
60
+ if (!r.ok) throw new Error("expected ok");
61
+ const payload = decode(r.provisionStateToken);
62
+ expect(payload.githubOrg).toBe("my-org");
63
+ expect(payload.ghAppPublic).toBe(true);
64
+ expect(payload.resumeGithub).toBe(true);
65
+ expect(JSON.stringify(payload)).not.toContain("xoxe.xoxp");
66
+ });
67
+
68
+ it("startConnect without deferred inputs omits the fields", async () => {
69
+ const r = await makeService().startConnect(
70
+ AGENT_ID,
71
+ "xoxe.xoxp-t",
72
+ CALLBACK,
73
+ );
74
+ if (!r.ok) throw new Error("expected ok");
75
+ const payload = decode(r.provisionStateToken);
76
+ expect("githubOrg" in payload).toBe(false);
77
+ expect("ghAppPublic" in payload).toBe(false);
78
+ expect("resumeGithub" in payload).toBe(false);
79
+ });
80
+
81
+ it("completeConnect returns the deferred inputs and ghConnectError", async () => {
82
+ const svc = makeService();
83
+ const r = await svc.startConnect(
84
+ AGENT_ID,
85
+ "xoxe.xoxp-t",
86
+ CALLBACK,
87
+ "pat failed",
88
+ { githubOrg: "my-org", ghAppPublic: false, resumeGithub: true },
89
+ );
90
+ if (!r.ok) throw new Error("expected ok");
91
+ const out = await svc.completeConnect(
92
+ r.provisionStateToken,
93
+ "code",
94
+ CALLBACK,
95
+ );
96
+ if (out.outcome !== "needs_app_token") throw new Error(out.outcome);
97
+ expect(out.ghConnectError).toBe("pat failed");
98
+ expect(out.githubOrg).toBe("my-org");
99
+ expect(out.ghAppPublic).toBe(false);
100
+ expect(out.resumeGithub).toBe(true);
101
+ });
102
+
103
+ it("an older cookie without the new fields still verifies", async () => {
104
+ const now = Math.floor(Date.now() / 1000);
105
+ const token = await sign(
106
+ {
107
+ agentId: AGENT_ID,
108
+ clientId: "c",
109
+ clientSecret: "s",
110
+ signingSecret: "g",
111
+ appId: "A",
112
+ iat: now,
113
+ exp: now + 300,
114
+ },
115
+ SECRET,
116
+ "HS256",
117
+ );
118
+ const out = await makeService().completeConnect(token, "code", CALLBACK);
119
+ if (out.outcome !== "needs_app_token") throw new Error(out.outcome);
120
+ expect(out.githubOrg).toBeUndefined();
121
+ expect(out.ghAppPublic).toBeUndefined();
122
+ expect(out.resumeGithub).toBeUndefined();
123
+ });
124
+ });