@agentworkforce/deploy 3.0.6 → 3.0.8

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.
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Canonicalize the workforce cloud URL to the public host the user logged
3
+ * into, regardless of which edge / origin-bypass URL the auth response
4
+ * happened to come from.
5
+ *
6
+ * Why this exists: cloud's auth-result handler currently echoes
7
+ * `request.url` back as `apiUrl`, so when the auth request happens to
8
+ * route through the SST/Cloudflare origin-bypass (`origin.agentrelay.cloud`)
9
+ * the CLI ends up persisting that hostname and sending every subsequent
10
+ * API call to it. Session cookies and Bearer tokens don't validate
11
+ * cross-subdomain, so every call 401s.
12
+ *
13
+ * This is a CLI-side mitigation; the proper structural fix is cloud-side
14
+ * (the handler should emit a configured public URL, never `request.url`).
15
+ *
16
+ * Rules:
17
+ * - Map known-bypass hostnames (`origin.agentrelay.cloud`,
18
+ * `*.agentrelay.cloud`) → canonical `https://agentrelay.com/cloud`.
19
+ * - Leave other hostnames untouched (dev `localhost:*`, custom tenants,
20
+ * etc.) — only the cloud-bypass family is remapped.
21
+ * - Strip a trailing slash so equality comparisons in the rest of the
22
+ * deploy code stay stable.
23
+ */
24
+ export declare function canonicalizeCloudUrl(input: string): string;
25
+ //# sourceMappingURL=cloud-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-url.d.ts","sourceRoot":"","sources":["../src/cloud-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiB1D"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Canonicalize the workforce cloud URL to the public host the user logged
3
+ * into, regardless of which edge / origin-bypass URL the auth response
4
+ * happened to come from.
5
+ *
6
+ * Why this exists: cloud's auth-result handler currently echoes
7
+ * `request.url` back as `apiUrl`, so when the auth request happens to
8
+ * route through the SST/Cloudflare origin-bypass (`origin.agentrelay.cloud`)
9
+ * the CLI ends up persisting that hostname and sending every subsequent
10
+ * API call to it. Session cookies and Bearer tokens don't validate
11
+ * cross-subdomain, so every call 401s.
12
+ *
13
+ * This is a CLI-side mitigation; the proper structural fix is cloud-side
14
+ * (the handler should emit a configured public URL, never `request.url`).
15
+ *
16
+ * Rules:
17
+ * - Map known-bypass hostnames (`origin.agentrelay.cloud`,
18
+ * `*.agentrelay.cloud`) → canonical `https://agentrelay.com/cloud`.
19
+ * - Leave other hostnames untouched (dev `localhost:*`, custom tenants,
20
+ * etc.) — only the cloud-bypass family is remapped.
21
+ * - Strip a trailing slash so equality comparisons in the rest of the
22
+ * deploy code stay stable.
23
+ */
24
+ export function canonicalizeCloudUrl(input) {
25
+ const trimmed = input.trim();
26
+ if (!trimmed)
27
+ return trimmed;
28
+ let url;
29
+ try {
30
+ url = new URL(trimmed);
31
+ }
32
+ catch {
33
+ // If it doesn't parse as a URL we don't know how to remap it; return
34
+ // the original (trimmed) string so the caller can choose to error
35
+ // downstream.
36
+ return trimmed;
37
+ }
38
+ const host = url.hostname.toLowerCase();
39
+ if (host === 'agentrelay.cloud' || host.endsWith('.agentrelay.cloud')) {
40
+ return 'https://agentrelay.com/cloud';
41
+ }
42
+ return stripTrailingSlash(url.toString());
43
+ }
44
+ function stripTrailingSlash(value) {
45
+ return value.replace(/\/+$/, '');
46
+ }
47
+ //# sourceMappingURL=cloud-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-url.js","sourceRoot":"","sources":["../src/cloud-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAC7B,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,qEAAqE;QACrE,kEAAkE;QAClE,cAAc;QACd,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACxC,IAAI,IAAI,KAAK,kBAAkB,IAAI,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACtE,OAAO,8BAA8B,CAAC;IACxC,CAAC;IACD,OAAO,kBAAkB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cloud-url.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-url.test.d.ts","sourceRoot":"","sources":["../src/cloud-url.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { canonicalizeCloudUrl } from './cloud-url.js';
4
+ test('canonicalizeCloudUrl: origin.agentrelay.cloud bare host → public canonical', () => {
5
+ assert.equal(canonicalizeCloudUrl('https://origin.agentrelay.cloud'), 'https://agentrelay.com/cloud');
6
+ });
7
+ test('canonicalizeCloudUrl: origin.agentrelay.cloud/cloud → public canonical', () => {
8
+ assert.equal(canonicalizeCloudUrl('https://origin.agentrelay.cloud/cloud'), 'https://agentrelay.com/cloud');
9
+ });
10
+ test('canonicalizeCloudUrl: staging.agentrelay.cloud → public canonical', () => {
11
+ assert.equal(canonicalizeCloudUrl('https://staging.agentrelay.cloud'), 'https://agentrelay.com/cloud');
12
+ });
13
+ test('canonicalizeCloudUrl: bare agentrelay.cloud/cloud → public canonical', () => {
14
+ assert.equal(canonicalizeCloudUrl('https://agentrelay.cloud/cloud'), 'https://agentrelay.com/cloud');
15
+ });
16
+ test('canonicalizeCloudUrl: public canonical is idempotent', () => {
17
+ assert.equal(canonicalizeCloudUrl('https://agentrelay.com/cloud'), 'https://agentrelay.com/cloud');
18
+ });
19
+ test('canonicalizeCloudUrl: trailing slash is stripped on canonical input', () => {
20
+ assert.equal(canonicalizeCloudUrl('https://agentrelay.com/cloud/'), 'https://agentrelay.com/cloud');
21
+ });
22
+ test('canonicalizeCloudUrl: localhost dev URLs are left untouched', () => {
23
+ assert.equal(canonicalizeCloudUrl('http://localhost:3000'), 'http://localhost:3000');
24
+ });
25
+ test('canonicalizeCloudUrl: unrelated tenant URLs are left untouched', () => {
26
+ assert.equal(canonicalizeCloudUrl('https://some-other-tenant.example.com'), 'https://some-other-tenant.example.com');
27
+ });
28
+ test('canonicalizeCloudUrl: empty input returns empty string', () => {
29
+ assert.equal(canonicalizeCloudUrl(''), '');
30
+ });
31
+ test('canonicalizeCloudUrl: unparseable input is returned untouched (trimmed)', () => {
32
+ assert.equal(canonicalizeCloudUrl(' not-a-url '), 'not-a-url');
33
+ });
34
+ //# sourceMappingURL=cloud-url.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-url.test.js","sourceRoot":"","sources":["../src/cloud-url.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,IAAI,CAAC,4EAA4E,EAAE,GAAG,EAAE;IACtF,MAAM,CAAC,KAAK,CACV,oBAAoB,CAAC,iCAAiC,CAAC,EACvD,8BAA8B,CAC/B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wEAAwE,EAAE,GAAG,EAAE;IAClF,MAAM,CAAC,KAAK,CACV,oBAAoB,CAAC,uCAAuC,CAAC,EAC7D,8BAA8B,CAC/B,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;AACnE,CAAC,CAAC,CAAC"}
package/dist/connect.d.ts CHANGED
@@ -41,6 +41,18 @@ export interface ProviderSubscriptionResolver {
41
41
  provider: string;
42
42
  }>;
43
43
  }
44
+ /**
45
+ * Called after a cloud integration status check gets a 401. The CLI uses
46
+ * this to run the established browser login flow, refresh the active bearer
47
+ * token, and let the status check retry once.
48
+ */
49
+ export interface IntegrationAuthRecoveryResolver {
50
+ recover(args: {
51
+ workspace: string;
52
+ provider: string;
53
+ reason: string;
54
+ }): Promise<boolean>;
55
+ }
44
56
  /**
45
57
  * Resolver backed by env vars. Used as the default when no higher-level
46
58
  * implementation is plugged in. `isConnected` returns true exactly when
@@ -52,7 +64,7 @@ export declare function envIntegrationResolver(): IntegrationConnectResolver;
52
64
  export declare function relayfileIntegrationResolver(opts: {
53
65
  apiUrl: string;
54
66
  workspaceId: string;
55
- workspaceToken: string;
67
+ workspaceToken: string | (() => string | Promise<string>);
56
68
  io?: Pick<DeployIO, 'info' | 'warn'>;
57
69
  pollIntervalMs?: number;
58
70
  timeoutMs?: number;
@@ -64,8 +76,11 @@ export interface ConnectAllInput {
64
76
  persona: PersonaSpec;
65
77
  workspace: string;
66
78
  noConnect: boolean;
79
+ noPrompt?: boolean;
67
80
  io: DeployIO;
68
81
  integrations: IntegrationConnectResolver;
82
+ /** Optional cloud-login recovery for interactive 401s. */
83
+ authRecovery?: IntegrationAuthRecoveryResolver;
69
84
  /** Required only when persona.useSubscription is true. */
70
85
  subscription?: ProviderSubscriptionResolver;
71
86
  }
@@ -83,6 +98,9 @@ export interface ConnectAllResult {
83
98
  * Behavior summary:
84
99
  * - integrations: {} or undefined → returns immediately, no prompts
85
100
  * - already-connected provider → no prompt; emits `already-connected`
101
+ * - 401 while checking status + authRecovery → prompts login and retries once
102
+ * - other auth failure while checking status → fails without integration prompts
103
+ * - not connected + noPrompt=true → fails immediately without prompting
86
104
  * - not connected + noConnect=true → fails the deploy with a clear message
87
105
  * - not connected + noConnect=false → prompts; on yes runs `connect`,
88
106
  * on no marks `skipped`. The orchestrator decides what to do with
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAkBtE;;;;;;;;;GASG;AACH,MAAM,WAAW,0BAA0B;IACzC,uDAAuD;IACvD,WAAW,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7E,2EAA2E;IAC3E,OAAO,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3F;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClF,OAAO,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5F;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,0BAA0B,CAcnE;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,GA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,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,GAAG,0BAA0B,CAiE7B;AAUD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,EAAE,QAAQ,CAAC;IACb,YAAY,EAAE,0BAA0B,CAAC;IACzC,0DAA0D;IAC1D,YAAY,CAAC,EAAE,+BAA+B,CAAC;IAC/C,0DAA0D;IAC1D,YAAY,CAAC,EAAE,4BAA4B,CAAC;CAC7C;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,yBAAyB,EAAE,CAAC;IACtC,+DAA+D;IAC/D,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA+I3F"}
package/dist/connect.js CHANGED
@@ -43,12 +43,14 @@ export function relayfileIntegrationResolver(opts) {
43
43
  return {
44
44
  async isConnected({ workspace, provider }) {
45
45
  const workspaceId = workspace || opts.workspaceId;
46
- const body = await requestJson(fetchImpl, `${apiUrl}/api/v1/workspaces/${encodeURIComponent(workspaceId)}/integrations`, opts.workspaceToken);
46
+ const token = await resolveWorkspaceToken(opts.workspaceToken);
47
+ const body = await requestJson(fetchImpl, `${apiUrl}/api/v1/workspaces/${encodeURIComponent(workspaceId)}/integrations`, token);
47
48
  return listHasConnectedProvider(body, provider);
48
49
  },
49
50
  async connect({ workspace, provider }) {
50
51
  const workspaceId = workspace || opts.workspaceId;
51
- const session = await requestJson(fetchImpl, `${apiUrl}/api/v1/workspaces/${encodeURIComponent(workspaceId)}/integrations/connect-session`, opts.workspaceToken, {
52
+ const token = await resolveWorkspaceToken(opts.workspaceToken);
53
+ const session = await requestJson(fetchImpl, `${apiUrl}/api/v1/workspaces/${encodeURIComponent(workspaceId)}/integrations/connect-session`, token, {
52
54
  method: 'POST',
53
55
  body: JSON.stringify({ allowedIntegrations: [provider] })
54
56
  });
@@ -72,7 +74,7 @@ export function relayfileIntegrationResolver(opts) {
72
74
  const statusUrl = new URL(`${apiUrl}/api/v1/workspaces/${encodeURIComponent(workspaceId)}/integrations/${encodeURIComponent(provider)}/status`);
73
75
  if (sessionId)
74
76
  statusUrl.searchParams.set('connectionId', sessionId);
75
- const status = await requestJson(fetchImpl, statusUrl.toString(), opts.workspaceToken);
77
+ const status = await requestJson(fetchImpl, statusUrl.toString(), await resolveWorkspaceToken(opts.workspaceToken));
76
78
  if (isConnectedStatus(status)) {
77
79
  const connectionId = readString(status, 'connectionId')
78
80
  ?? readString(status, 'currentConnectionId')
@@ -100,6 +102,9 @@ function providerHasEnvCredentials(provider) {
100
102
  * Behavior summary:
101
103
  * - integrations: {} or undefined → returns immediately, no prompts
102
104
  * - already-connected provider → no prompt; emits `already-connected`
105
+ * - 401 while checking status + authRecovery → prompts login and retries once
106
+ * - other auth failure while checking status → fails without integration prompts
107
+ * - not connected + noPrompt=true → fails immediately without prompting
103
108
  * - not connected + noConnect=true → fails the deploy with a clear message
104
109
  * - not connected + noConnect=false → prompts; on yes runs `connect`,
105
110
  * on no marks `skipped`. The orchestrator decides what to do with
@@ -109,17 +114,55 @@ export async function connectIntegrations(input) {
109
114
  const integrations = input.persona.integrations ?? {};
110
115
  const outcomes = [];
111
116
  for (const provider of Object.keys(integrations)) {
112
- const connected = await input.integrations
113
- .isConnected({ workspace: input.workspace, provider })
114
- .catch((err) => {
115
- input.io.warn(`failed to check connection status for ${provider}: ${err instanceof Error ? err.message : String(err)}`);
116
- return false;
117
+ let statusCheckFailure;
118
+ let connected = await checkProviderConnected(input, provider, (message) => {
119
+ statusCheckFailure = message;
117
120
  });
118
121
  if (connected) {
119
122
  input.io.info(`integrations.${provider}: already connected`);
120
123
  outcomes.push({ provider, status: 'already-connected' });
121
124
  continue;
122
125
  }
126
+ if (statusCheckFailure
127
+ && isIntegrationUnauthorizedFailure(statusCheckFailure)
128
+ && !input.noPrompt
129
+ && input.authRecovery) {
130
+ const recovered = await input.authRecovery
131
+ .recover({ workspace: input.workspace, provider, reason: statusCheckFailure })
132
+ .catch((err) => {
133
+ input.io.error(`integrations.${provider}: login failed: ${err instanceof Error ? err.message : String(err)}`);
134
+ return false;
135
+ });
136
+ if (recovered) {
137
+ statusCheckFailure = undefined;
138
+ connected = await checkProviderConnected(input, provider, (message) => {
139
+ statusCheckFailure = message;
140
+ });
141
+ if (connected) {
142
+ input.io.info(`integrations.${provider}: already connected`);
143
+ outcomes.push({ provider, status: 'already-connected' });
144
+ continue;
145
+ }
146
+ }
147
+ }
148
+ if (statusCheckFailure) {
149
+ input.io.error(`integrations.${provider}: ${isIntegrationAuthFailure(statusCheckFailure) ? 'auth failed' : 'failed'} while checking connection status`);
150
+ outcomes.push({
151
+ provider,
152
+ status: 'failed',
153
+ message: statusCheckFailure
154
+ });
155
+ continue;
156
+ }
157
+ if (input.noPrompt) {
158
+ input.io.error(`integrations.${provider}: not connected, and --no-prompt was passed. Connect it before deploying or run without --no-prompt.`);
159
+ outcomes.push({
160
+ provider,
161
+ status: 'failed',
162
+ message: 'not connected (--no-prompt was set)'
163
+ });
164
+ return { outcomes };
165
+ }
123
166
  if (input.noConnect) {
124
167
  input.io.error(`integrations.${provider}: not connected, and prompts are disabled`);
125
168
  outcomes.push({
@@ -157,6 +200,9 @@ export async function connectIntegrations(input) {
157
200
  .isConnected({ workspace: input.workspace })
158
201
  .catch(() => false);
159
202
  if (!isConn) {
203
+ if (input.noPrompt) {
204
+ throw new Error('persona requires a subscription provider connection, but --no-prompt was passed. Connect it before deploying or run without --no-prompt.');
205
+ }
160
206
  if (input.noConnect) {
161
207
  throw new Error('persona requires a subscription provider connection, but --no-connect was passed');
162
208
  }
@@ -177,6 +223,16 @@ export async function connectIntegrations(input) {
177
223
  ...(subscriptionProvider ? { subscriptionProvider } : {})
178
224
  };
179
225
  }
226
+ async function checkProviderConnected(input, provider, onFailure) {
227
+ return await input.integrations
228
+ .isConnected({ workspace: input.workspace, provider })
229
+ .catch((err) => {
230
+ const message = err instanceof Error ? err.message : String(err);
231
+ onFailure(message);
232
+ input.io.warn(`failed to check connection status for ${provider}: ${message}`);
233
+ return false;
234
+ });
235
+ }
180
236
  async function requestJson(fetchImpl, url, token, init = {}) {
181
237
  const res = await fetchImpl(url, {
182
238
  ...init,
@@ -187,13 +243,25 @@ async function requestJson(fetchImpl, url, token, init = {}) {
187
243
  }
188
244
  });
189
245
  if (res.status === 401) {
190
- throw new Error('cloud integration request failed: unauthorized. Run `agentworkforce login` and retry.');
246
+ throw new Error('cloud integration request failed: unauthorized. Your active workspace session is invalid or expired. Run `agentworkforce login --workspace <id-or-slug>` to refresh, then retry.');
247
+ }
248
+ if (res.status === 403) {
249
+ throw new Error('cloud integration request failed: forbidden. The active account is not authorized for this workspace. Run `agentworkforce login --workspace <id-or-slug>` against an account with access, then retry.');
191
250
  }
192
251
  if (!res.ok) {
193
252
  throw new Error(`cloud integration request failed: ${res.status} ${await res.text().catch(() => '')}`.trim());
194
253
  }
195
254
  return await res.json();
196
255
  }
256
+ function isIntegrationAuthFailure(message) {
257
+ return /cloud integration request failed: (unauthorized|forbidden)\b/i.test(message);
258
+ }
259
+ function isIntegrationUnauthorizedFailure(message) {
260
+ return /cloud integration request failed: unauthorized\b/i.test(message);
261
+ }
262
+ async function resolveWorkspaceToken(token) {
263
+ return typeof token === 'function' ? await token() : token;
264
+ }
197
265
  function listHasConnectedProvider(body, provider) {
198
266
  const candidates = Array.isArray(body)
199
267
  ? body
@@ -1 +1 @@
1
- {"version":3,"file":"connect.js","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EA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EAAE;QACrB,mEAAmE;IACrE,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import test from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
- import { relayfileIntegrationResolver } from './connect.js';
3
+ import { connectIntegrations, relayfileIntegrationResolver } from './connect.js';
4
4
  import { createBufferedIO } from './io.js';
5
5
  function okJson(body, status = 200) {
6
6
  return new Response(JSON.stringify(body), {
@@ -28,6 +28,28 @@ test('relayfileIntegrationResolver isConnected reads the cloud integration list'
28
28
  'https://cloud.example.test/api/v1/workspaces/ws-runtime/integrations'
29
29
  ]);
30
30
  });
31
+ test('relayfileIntegrationResolver reads the latest workspace token for each request', async () => {
32
+ let token = 'old-token';
33
+ const authHeaders = [];
34
+ const resolver = relayfileIntegrationResolver({
35
+ apiUrl: 'https://cloud.example.test',
36
+ workspaceId: 'ws-1',
37
+ workspaceToken: () => token,
38
+ fetch: async (_url, init) => {
39
+ authHeaders.push(String(new Headers(init?.headers).get('authorization')));
40
+ if (authHeaders.length === 1) {
41
+ return okJson({ error: 'Unauthorized' }, 401);
42
+ }
43
+ return okJson([
44
+ { provider: 'github', status: 'ready', connectionId: 'conn-1' }
45
+ ]);
46
+ }
47
+ });
48
+ await assert.rejects(resolver.isConnected({ workspace: 'ws-runtime', provider: 'github' }), /unauthorized/);
49
+ token = 'new-token';
50
+ assert.equal(await resolver.isConnected({ workspace: 'ws-runtime', provider: 'github' }), true);
51
+ assert.deepEqual(authHeaders, ['Bearer old-token', 'Bearer new-token']);
52
+ });
31
53
  test('relayfileIntegrationResolver connect opens a session and polls until connected', async () => {
32
54
  let polls = 0;
33
55
  const opened = [];
@@ -90,4 +112,221 @@ test('relayfileIntegrationResolver connect times out clearly', async () => {
90
112
  });
91
113
  await assert.rejects(resolver.connect({ workspace: 'ws-1', provider: 'github' }), /Timed out waiting for github OAuth/);
92
114
  });
115
+ test('connectIntegrations fails fast on auth errors without prompting to connect', async () => {
116
+ const io = createBufferedIO();
117
+ let connectCalled = false;
118
+ let confirmCalled = false;
119
+ io.confirm = async () => {
120
+ confirmCalled = true;
121
+ return true;
122
+ };
123
+ const result = await connectIntegrations({
124
+ persona: {
125
+ id: 'essay',
126
+ intent: 'essay',
127
+ description: 'test persona',
128
+ tags: ['implementation'],
129
+ integrations: { notion: {} }
130
+ },
131
+ workspace: 'ws-1',
132
+ noConnect: false,
133
+ io,
134
+ integrations: {
135
+ async isConnected() {
136
+ throw new Error('cloud integration request failed: unauthorized. Your active workspace session is invalid or expired. Run `agentworkforce login --workspace <id-or-slug>` to refresh, then retry.');
137
+ },
138
+ async connect() {
139
+ connectCalled = true;
140
+ throw new Error('connect should not be called after auth failure');
141
+ }
142
+ }
143
+ });
144
+ assert.equal(confirmCalled, false);
145
+ assert.equal(connectCalled, false);
146
+ assert.equal(result.outcomes.length, 1);
147
+ const [outcome] = result.outcomes;
148
+ assert.equal(outcome.provider, 'notion');
149
+ assert.equal(outcome.status, 'failed');
150
+ // Future-proofed against copy-edits: the message must point users at the
151
+ // workforce CLI's own login and must NOT instruct them to reach for the
152
+ // upstream `agent-relay` binary.
153
+ assert.match(outcome.message ?? '', /agentworkforce login/i);
154
+ assert.doesNotMatch(outcome.message ?? '', /agent-relay cloud/);
155
+ assert.ok(io.messages.some((message) => message.level === 'warn' && message.message.includes('failed to check connection status for notion')));
156
+ assert.ok(io.messages.some((message) => message.level === 'error' && message.message.includes('auth failed')));
157
+ });
158
+ test('relayfileIntegrationResolver surfaces the agentworkforce-native error on 401', async () => {
159
+ const resolver = relayfileIntegrationResolver({
160
+ apiUrl: 'https://cloud.example.test',
161
+ workspaceId: 'ws-1',
162
+ workspaceToken: 'tok',
163
+ fetch: async () => new Response('Unauthorized', { status: 401 })
164
+ });
165
+ await assert.rejects(resolver.isConnected({ workspace: 'ws-1', provider: 'notion' }), (err) => {
166
+ const message = err instanceof Error ? err.message : String(err);
167
+ assert.match(message, /unauthorized/i);
168
+ assert.match(message, /agentworkforce login/i);
169
+ assert.doesNotMatch(message, /agent-relay cloud/);
170
+ assert.doesNotMatch(message, /origin\.agentrelay\.cloud/);
171
+ return true;
172
+ });
173
+ });
174
+ test('connectIntegrations prompts auth recovery on unauthorized status checks and retries', async () => {
175
+ const io = createBufferedIO();
176
+ let checks = 0;
177
+ let recoverCalled = false;
178
+ let connectCalled = false;
179
+ const result = await connectIntegrations({
180
+ persona: {
181
+ id: 'essay',
182
+ intent: 'essay',
183
+ description: 'test persona',
184
+ tags: ['implementation'],
185
+ integrations: { notion: {} }
186
+ },
187
+ workspace: 'ws-1',
188
+ noConnect: false,
189
+ io,
190
+ integrations: {
191
+ async isConnected() {
192
+ checks += 1;
193
+ if (checks === 1) {
194
+ throw new Error('cloud integration request failed: unauthorized. Your active workspace session is invalid or expired. Run `agentworkforce login --workspace <id-or-slug>` to refresh, then retry.');
195
+ }
196
+ return true;
197
+ },
198
+ async connect() {
199
+ connectCalled = true;
200
+ throw new Error('connect should not be called after auth recovery');
201
+ }
202
+ },
203
+ authRecovery: {
204
+ async recover({ workspace, provider }) {
205
+ recoverCalled = true;
206
+ assert.equal(workspace, 'ws-1');
207
+ assert.equal(provider, 'notion');
208
+ return true;
209
+ }
210
+ }
211
+ });
212
+ assert.equal(recoverCalled, true);
213
+ assert.equal(connectCalled, false);
214
+ assert.equal(checks, 2);
215
+ assert.deepEqual(result.outcomes, [{ provider: 'notion', status: 'already-connected' }]);
216
+ });
217
+ test('connectIntegrations does not prompt auth recovery when --no-prompt is set', async () => {
218
+ const io = createBufferedIO();
219
+ let recoverCalled = false;
220
+ const result = await connectIntegrations({
221
+ persona: {
222
+ id: 'essay',
223
+ intent: 'essay',
224
+ description: 'test persona',
225
+ tags: ['implementation'],
226
+ integrations: { notion: {} }
227
+ },
228
+ workspace: 'ws-1',
229
+ noConnect: true,
230
+ noPrompt: true,
231
+ io,
232
+ integrations: {
233
+ async isConnected() {
234
+ throw new Error('cloud integration request failed: unauthorized. Your active workspace session is invalid or expired. Run `agentworkforce login --workspace <id-or-slug>` to refresh, then retry.');
235
+ },
236
+ async connect() {
237
+ throw new Error('connect should not be called after auth failure');
238
+ }
239
+ },
240
+ authRecovery: {
241
+ async recover() {
242
+ recoverCalled = true;
243
+ return true;
244
+ }
245
+ }
246
+ });
247
+ assert.equal(recoverCalled, false);
248
+ assert.deepEqual(result.outcomes, [
249
+ {
250
+ provider: 'notion',
251
+ status: 'failed',
252
+ message: 'cloud integration request failed: unauthorized. Your active workspace session is invalid or expired. Run `agentworkforce login --workspace <id-or-slug>` to refresh, then retry.'
253
+ }
254
+ ]);
255
+ });
256
+ test('connectIntegrations fails status-check errors without opening a connect flow', async () => {
257
+ const io = createBufferedIO();
258
+ let connectCalled = false;
259
+ const result = await connectIntegrations({
260
+ persona: {
261
+ id: 'essay',
262
+ intent: 'essay',
263
+ description: 'test persona',
264
+ tags: ['implementation'],
265
+ integrations: { notion: {} }
266
+ },
267
+ workspace: 'ws-1',
268
+ noConnect: false,
269
+ io,
270
+ integrations: {
271
+ async isConnected() {
272
+ throw new Error('cloud integration request failed: 503 Service Unavailable');
273
+ },
274
+ async connect() {
275
+ connectCalled = true;
276
+ throw new Error('connect should not be called after status-check failure');
277
+ }
278
+ }
279
+ });
280
+ assert.equal(connectCalled, false);
281
+ assert.deepEqual(result.outcomes, [
282
+ {
283
+ provider: 'notion',
284
+ status: 'failed',
285
+ message: 'cloud integration request failed: 503 Service Unavailable'
286
+ }
287
+ ]);
288
+ assert.ok(io.messages.some((message) => message.level === 'error' && message.message.includes('failed while checking connection status')));
289
+ });
290
+ test('connectIntegrations honors --no-prompt for subscription provider setup', async () => {
291
+ const io = createBufferedIO();
292
+ let confirmCalled = false;
293
+ let subscriptionConnectCalled = false;
294
+ io.confirm = async () => {
295
+ confirmCalled = true;
296
+ return true;
297
+ };
298
+ await assert.rejects(connectIntegrations({
299
+ persona: {
300
+ id: 'essay',
301
+ intent: 'essay',
302
+ description: 'test persona',
303
+ tags: ['implementation'],
304
+ useSubscription: true,
305
+ integrations: {}
306
+ },
307
+ workspace: 'ws-1',
308
+ noConnect: false,
309
+ noPrompt: true,
310
+ io,
311
+ integrations: {
312
+ async isConnected() {
313
+ throw new Error('no integration checks expected');
314
+ },
315
+ async connect() {
316
+ throw new Error('no integration connects expected');
317
+ }
318
+ },
319
+ subscription: {
320
+ async isConnected() {
321
+ return false;
322
+ },
323
+ async connect() {
324
+ subscriptionConnectCalled = true;
325
+ return { provider: 'anthropic' };
326
+ }
327
+ }
328
+ }), /--no-prompt was passed/);
329
+ assert.equal(confirmCalled, false);
330
+ assert.equal(subscriptionConnectCalled, false);
331
+ });
93
332
  //# sourceMappingURL=connect.test.js.map