@agent-native/core 0.161.20 → 0.161.22

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 (52) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/clips/actions/finalize-meeting.ts +57 -21
  3. package/corpus/templates/clips/actions/get-meeting.ts +11 -3
  4. package/corpus/templates/clips/actions/request-transcript.ts +183 -8
  5. package/corpus/templates/clips/actions/update-meeting.ts +66 -14
  6. package/corpus/templates/clips/app/components/meetings/canvas-editor.tsx +80 -135
  7. package/corpus/templates/clips/app/i18n/en-US.ts +4 -0
  8. package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +470 -35
  9. package/corpus/templates/clips/changelog/2026-08-18-meeting-notes-support-rich-editing-for-personal-notes-summar.md +6 -0
  10. package/corpus/templates/clips/desktop/src-tauri/src/whisper_speech.rs +13 -3
  11. package/corpus/templates/mail/app/components/email/EmailList.tsx +74 -22
  12. package/corpus/templates/mail/app/components/email/infinite-pagination.ts +82 -0
  13. package/corpus/templates/mail/app/hooks/use-emails.ts +1 -0
  14. package/corpus/templates/mail/app/pages/InboxPage.tsx +15 -10
  15. package/corpus/templates/mail/app/pages/inbox-zero.ts +35 -0
  16. package/corpus/templates/mail/changelog/2026-08-18-pinned-labels-load-matches.md +6 -0
  17. package/corpus/templates/slides/actions/get-deck.ts +5 -1
  18. package/corpus/templates/slides/actions/list-decks.ts +29 -8
  19. package/corpus/templates/slides/actions/view-screen.ts +7 -3
  20. package/corpus/templates/slides/changelog/2026-08-18-decks-appear-under-mine.md +6 -0
  21. package/corpus/templates/slides/shared/ownership.ts +6 -0
  22. package/dist/app-config/schema.d.ts +2 -0
  23. package/dist/app-config/workspace.d.ts +2 -0
  24. package/dist/app-config/workspace.js +18 -0
  25. package/dist/catalog.json +23 -23
  26. package/dist/client/analytics.d.ts +1 -0
  27. package/dist/client/api-path.js +7 -3
  28. package/dist/client/frame.js +20 -6
  29. package/dist/client/org/workspace-app-links.js +10 -1
  30. package/dist/collab/awareness.d.ts +2 -2
  31. package/dist/collab/struct-routes.d.ts +1 -1
  32. package/dist/deploy/build.js +26 -2
  33. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  34. package/dist/notifications/routes.d.ts +1 -1
  35. package/dist/observability/routes.d.ts +6 -6
  36. package/dist/progress/routes.d.ts +1 -1
  37. package/dist/provider-api/actions/custom-provider-registration.d.ts +14 -14
  38. package/dist/provider-api/actions/provider-api.d.ts +15 -15
  39. package/dist/secrets/routes.d.ts +9 -9
  40. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  41. package/dist/server/app-origin-config.d.ts +1 -0
  42. package/dist/server/app-origin-config.js +3 -0
  43. package/dist/server/auth.js +2 -2
  44. package/dist/server/cookie-namespace.js +17 -2
  45. package/dist/server/credential-provider.js +5 -2
  46. package/dist/server/derived-secret.js +3 -2
  47. package/dist/server/onboarding-html.js +34 -2
  48. package/dist/server/workspace-oauth.js +11 -6
  49. package/dist/shared/runtime-config.d.ts +2 -0
  50. package/dist/shared/runtime-config.js +12 -3
  51. package/dist/vite/client.js +5 -2
  52. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import { isTruthyRuntimeValue } from "../shared/runtime-config.js";
1
2
  import { agentNativePath } from "./api-path.js";
2
3
  /**
3
4
  * Frame Communication (browser)
@@ -174,8 +175,7 @@ export function getCallbackOrigin() {
174
175
  return typeof window !== "undefined" ? window.location.origin : "";
175
176
  }
176
177
  function envFlag(name) {
177
- const value = runtimeEnvValue(name);
178
- return value === "1" || value === "true" || value === true;
178
+ return isTruthyRuntimeValue(runtimeEnvValue(name));
179
179
  }
180
180
  function runtimeEnvValue(name) {
181
181
  const importMetaEnv = import.meta.env;
@@ -193,9 +193,21 @@ function workspaceOAuthOrigin() {
193
193
  // guaranteed — which is why the chain lists both and why it is not the
194
194
  // primary path any more.
195
195
  const shell = typeof window !== "undefined" ? window.__AGENT_NATIVE_CONFIG__ : undefined;
196
- const raw = shell?.workspaceOAuthOrigin ||
197
- shell?.appUrl ||
198
- shell?.workspaceGatewayUrl ||
196
+ const projectedRaw = shell?.workspaceOAuthOrigin || shell?.appUrl || shell?.workspaceGatewayUrl;
197
+ if (shell?.workspaceRuntime === true) {
198
+ if (typeof projectedRaw === "string" && projectedRaw.trim()) {
199
+ try {
200
+ return new URL(projectedRaw).origin;
201
+ }
202
+ catch {
203
+ // coercion-ok: a stale projected origin intentionally falls back below.
204
+ // Fall through to the current origin when the projected value is stale.
205
+ }
206
+ }
207
+ const currentOrigin = getCallbackOrigin();
208
+ return currentOrigin || null;
209
+ }
210
+ const raw = projectedRaw ||
199
211
  runtimeEnvValue("VITE_WORKSPACE_OAUTH_ORIGIN") ||
200
212
  runtimeEnvValue("WORKSPACE_OAUTH_ORIGIN") ||
201
213
  runtimeEnvValue("VITE_APP_URL") ||
@@ -214,7 +226,9 @@ function workspaceOAuthOrigin() {
214
226
  }
215
227
  }
216
228
  function shouldUseWorkspaceCallbackRelay(path) {
217
- return (envFlag("VITE_AGENT_NATIVE_WORKSPACE") &&
229
+ const projectedWorkspaceRuntime = typeof window !== "undefined" &&
230
+ window.__AGENT_NATIVE_CONFIG__?.workspaceRuntime === true;
231
+ return ((projectedWorkspaceRuntime || envFlag("VITE_AGENT_NATIVE_WORKSPACE")) &&
218
232
  path.startsWith("/_agent-native/") &&
219
233
  (path.endsWith("/callback") || path.includes("/callback/")));
220
234
  }
@@ -1,5 +1,6 @@
1
1
  import { useEffect, useMemo, useState } from "react";
2
2
  import { coreTemplates, getTemplate } from "../../cli/templates-meta.js";
3
+ import { isTruthyRuntimeValue } from "../../shared/runtime-config.js";
3
4
  const DISPATCH_ID = "dispatch";
4
5
  export const ORG_SWITCHER_MAX_APP_LINKS = 9;
5
6
  function runtimeEnv() {
@@ -9,6 +10,13 @@ function envString(env, key) {
9
10
  const value = env[key];
10
11
  return typeof value === "string" && value.trim() ? value.trim() : undefined;
11
12
  }
13
+ function envFlag(env, key) {
14
+ return isTruthyRuntimeValue(env[key]);
15
+ }
16
+ function projectedWorkspaceRuntime() {
17
+ return (typeof window !== "undefined" &&
18
+ window.__AGENT_NATIVE_CONFIG__?.workspaceRuntime === true);
19
+ }
12
20
  function titleCase(value) {
13
21
  return value
14
22
  .split(/[-_\s]+/)
@@ -170,7 +178,8 @@ export function defaultOrgAppLinks() {
170
178
  })));
171
179
  }
172
180
  export function isWorkspaceAppEnvironment(env = runtimeEnv()) {
173
- return (envString(env, "VITE_AGENT_NATIVE_WORKSPACE") === "1" ||
181
+ return (envFlag(env, "VITE_AGENT_NATIVE_WORKSPACE") ||
182
+ projectedWorkspaceRuntime() ||
174
183
  Boolean(envString(env, "VITE_WORKSPACE_GATEWAY_URL")) ||
175
184
  Boolean(envString(env, "VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON")));
176
185
  }
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
62
62
  error: string;
63
63
  states?: undefined;
64
64
  } | {
65
- error?: undefined;
66
65
  states: {
67
66
  clientId: number;
68
67
  state: string;
69
68
  }[];
69
+ error?: undefined;
70
70
  }>>;
71
71
  /**
72
72
  * GET /_agent-native/collab/:docId/users
@@ -77,9 +77,9 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
77
77
  error: string;
78
78
  users?: undefined;
79
79
  } | {
80
- error?: undefined;
81
80
  users: {
82
81
  clientId: number;
83
82
  lastSeen: number;
84
83
  }[];
84
+ error?: undefined;
85
85
  }>>;
@@ -13,8 +13,8 @@
13
13
  * Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
14
14
  */
15
15
  export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
16
- error: string;
17
16
  ok?: undefined;
17
+ error: string;
18
18
  } | {
19
19
  error?: undefined;
20
20
  ok: boolean;
@@ -25,6 +25,7 @@ import { RECURRING_JOBS_SWEEP_PATH, RECURRING_JOBS_SWEEP_TOKEN_SUBJECT, } from "
25
25
  import { normalizeAppBasePath } from "../server/app-base-path.js";
26
26
  import { DEFAULT_SPECULATION_RULES_PATH, resolveSsrCacheHeaders, resolveSsrCacheKeyHeaders, } from "../shared/cache-control.js";
27
27
  import { mcpEmbedStaticAssetRouteRules } from "../shared/mcp-embed-headers.js";
28
+ import { isTruthyRuntimeValue } from "../shared/runtime-config.js";
28
29
  import { AGENT_NATIVE_SOCIAL_IMAGE_ALT, AGENT_NATIVE_SOCIAL_IMAGE_CACHE_BUSTER, AGENT_NATIVE_SOCIAL_IMAGE_HEIGHT, AGENT_NATIVE_SOCIAL_IMAGE_PATH, AGENT_NATIVE_SOCIAL_IMAGE_TYPE, AGENT_NATIVE_SOCIAL_IMAGE_WIDTH, } from "../shared/social-meta.js";
29
30
  import { generateActionRegistryForProject } from "../vite/action-types-plugin.js";
30
31
  import { createAgentNativeConfigContext, loadResolvedAgentNativeConfig, } from "../vite/agent-native-config-loader.js";
@@ -882,6 +883,14 @@ function firstNonEmpty() {
882
883
  }
883
884
  }
884
885
 
886
+ function isTruthyRuntimeValue(value) {
887
+ if (typeof value === "boolean") return value;
888
+ if (typeof value !== "string") return false;
889
+ return ["1", "true", "yes", "on"].includes(
890
+ value.trim().toLowerCase(),
891
+ );
892
+ }
893
+
885
894
  function getSentryClientConfigScript() {
886
895
  const env = globalThis.process?.env || {};
887
896
  const key = firstNonEmpty(env.SENTRY_CLIENT_KEY, env.VITE_SENTRY_CLIENT_KEY);
@@ -993,10 +1002,21 @@ function getAppOriginClientConfigScript() {
993
1002
  env.WORKSPACE_OAUTH_ORIGIN,
994
1003
  env.VITE_WORKSPACE_OAUTH_ORIGIN,
995
1004
  );
1005
+ const workspaceRuntime = [
1006
+ env.AGENT_NATIVE_WORKSPACE,
1007
+ env.VITE_AGENT_NATIVE_WORKSPACE,
1008
+ ].some((value) => isTruthyRuntimeValue(value)) ||
1009
+ Boolean(
1010
+ firstNonEmpty(
1011
+ env.AGENT_NATIVE_WORKSPACE_APPS_JSON,
1012
+ env.VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON,
1013
+ ),
1014
+ );
996
1015
  const config = {
997
1016
  ...(appUrl ? { appUrl } : {}),
998
1017
  ...(workspaceGatewayUrl ? { workspaceGatewayUrl } : {}),
999
1018
  ...(workspaceOAuthOrigin ? { workspaceOAuthOrigin } : {}),
1019
+ ...(workspaceRuntime ? { workspaceRuntime: true } : {}),
1000
1020
  };
1001
1021
  if (Object.keys(config).length === 0) return null;
1002
1022
  return (
@@ -3044,8 +3064,12 @@ function reportNetlifyFunctionSizes(internalDir, failures) {
3044
3064
  export function assertSingleTemplateNetlifyBuildOutput(projectCwd) {
3045
3065
  const failures = [];
3046
3066
  const publishDir = path.join(projectCwd, "dist");
3047
- const workspaceAppBasePath = process.env.AGENT_NATIVE_WORKSPACE === "1" ||
3048
- process.env.VITE_AGENT_NATIVE_WORKSPACE === "1"
3067
+ const workspaceAppBasePath = [
3068
+ process.env.AGENT_NATIVE_WORKSPACE,
3069
+ process.env.VITE_AGENT_NATIVE_WORKSPACE,
3070
+ ].some((value) => isTruthyRuntimeValue(value)) ||
3071
+ Boolean(process.env.AGENT_NATIVE_WORKSPACE_APPS_JSON?.trim()) ||
3072
+ Boolean(process.env.VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON?.trim())
3049
3073
  ? normalizeConfiguredAppBasePath()
3050
3074
  : "";
3051
3075
  const assetsRelativeDir = workspaceAppBasePath
@@ -17,11 +17,11 @@ declare const _default: import("../../action.js").ActionDefinition<{
17
17
  id?: undefined;
18
18
  provider?: undefined;
19
19
  } | {
20
- error?: undefined;
21
20
  configured?: undefined;
22
21
  connectPath?: undefined;
23
22
  url: string;
24
23
  id: string;
25
24
  provider: string;
25
+ error?: undefined;
26
26
  }>;
27
27
  export default _default;
@@ -28,6 +28,6 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
28
28
  } | {
29
29
  count?: undefined;
30
30
  updated?: undefined;
31
- ok: boolean;
32
31
  error?: undefined;
32
+ ok: boolean;
33
33
  }>>;
@@ -41,27 +41,27 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
+ error?: undefined;
45
+ ok?: undefined;
44
46
  summary: import("./types.js").TraceSummary;
45
47
  spans: import("./types.js").TraceSpan[];
46
48
  id?: undefined;
47
- ok?: undefined;
48
- error?: undefined;
49
49
  } | {
50
+ error?: undefined;
51
+ ok?: undefined;
50
52
  summary?: undefined;
51
53
  spans?: undefined;
52
54
  id: string;
53
- ok?: undefined;
54
- error?: undefined;
55
55
  } | {
56
+ ok?: undefined;
56
57
  summary?: undefined;
57
58
  spans?: undefined;
58
59
  id?: undefined;
59
60
  error: any;
60
- ok?: undefined;
61
61
  } | {
62
+ error?: undefined;
62
63
  summary?: undefined;
63
64
  spans?: undefined;
64
65
  id?: undefined;
65
66
  ok: boolean;
66
- error?: undefined;
67
67
  }>>;
@@ -15,6 +15,6 @@ export declare function createProgressHandler(): import("h3").EventHandlerWithFe
15
15
  error: string;
16
16
  ok?: undefined;
17
17
  } | {
18
- ok: boolean;
19
18
  error?: undefined;
19
+ ok: boolean;
20
20
  }>>;
@@ -75,9 +75,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
+ message?: undefined;
78
79
  id?: undefined;
79
- provider?: undefined;
80
80
  deleted?: undefined;
81
+ found?: undefined;
81
82
  providers: {
82
83
  id: string;
83
84
  label: string;
@@ -88,46 +89,45 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
88
89
  updatedAt: number;
89
90
  }[];
90
91
  count: number;
91
- found?: undefined;
92
+ provider?: undefined;
92
93
  registered?: undefined;
93
94
  label?: undefined;
94
- message?: undefined;
95
95
  } | {
96
+ message?: undefined;
97
+ count?: undefined;
96
98
  id?: undefined;
97
99
  deleted?: undefined;
98
100
  providers?: undefined;
99
- count?: undefined;
100
101
  found: boolean;
101
102
  provider: import("../custom-registry.js").CustomProviderConfig;
102
103
  registered?: undefined;
103
104
  label?: undefined;
104
- message?: undefined;
105
105
  } | {
106
- provider?: undefined;
106
+ message?: undefined;
107
+ count?: undefined;
107
108
  deleted?: undefined;
108
109
  providers?: undefined;
109
- count?: undefined;
110
+ provider?: undefined;
110
111
  found: boolean;
111
112
  id: string;
112
113
  registered?: undefined;
113
114
  label?: undefined;
114
- message?: undefined;
115
115
  } | {
116
- provider?: undefined;
117
- providers?: undefined;
116
+ message?: undefined;
118
117
  count?: undefined;
119
118
  found?: undefined;
119
+ providers?: undefined;
120
+ provider?: undefined;
120
121
  deleted: boolean;
121
122
  id: string;
122
123
  registered?: undefined;
123
124
  label?: undefined;
124
- message?: undefined;
125
125
  } | {
126
- provider?: undefined;
127
- deleted?: undefined;
128
- providers?: undefined;
129
126
  count?: undefined;
127
+ deleted?: undefined;
130
128
  found?: undefined;
129
+ providers?: undefined;
130
+ provider?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
133
133
  label: string;
@@ -312,7 +312,9 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
312
312
  scope?: "org" | "user" | undefined;
313
313
  }, {
314
314
  id?: undefined;
315
- message?: undefined;
315
+ deleted?: undefined;
316
+ provider?: undefined;
317
+ found?: undefined;
316
318
  providers: {
317
319
  id: string;
318
320
  label: string;
@@ -323,47 +325,45 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
323
325
  updatedAt: number;
324
326
  }[];
325
327
  count: number;
326
- provider?: undefined;
327
- found?: undefined;
328
- deleted?: undefined;
329
328
  registered?: undefined;
330
329
  label?: undefined;
330
+ message?: undefined;
331
331
  } | {
332
332
  id?: undefined;
333
- message?: undefined;
333
+ deleted?: undefined;
334
334
  providers?: undefined;
335
335
  count?: undefined;
336
336
  found: boolean;
337
337
  provider: import("../custom-registry.js").CustomProviderConfig;
338
- deleted?: undefined;
339
338
  registered?: undefined;
340
339
  label?: undefined;
341
- } | {
342
340
  message?: undefined;
341
+ } | {
342
+ deleted?: undefined;
343
+ provider?: undefined;
343
344
  providers?: undefined;
344
345
  count?: undefined;
345
- provider?: undefined;
346
346
  found: boolean;
347
347
  id: string;
348
- deleted?: undefined;
349
348
  registered?: undefined;
350
349
  label?: undefined;
351
- } | {
352
350
  message?: undefined;
353
- providers?: undefined;
354
- count?: undefined;
351
+ } | {
355
352
  provider?: undefined;
356
353
  found?: undefined;
354
+ providers?: undefined;
355
+ count?: undefined;
357
356
  deleted: boolean;
358
357
  id: string;
359
358
  registered?: undefined;
360
359
  label?: undefined;
360
+ message?: undefined;
361
361
  } | {
362
- providers?: undefined;
363
- count?: undefined;
362
+ deleted?: undefined;
364
363
  provider?: undefined;
365
364
  found?: undefined;
366
- deleted?: undefined;
365
+ providers?: undefined;
366
+ count?: undefined;
367
367
  registered: boolean;
368
368
  id: string;
369
369
  label: string;
@@ -34,37 +34,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
34
34
  /** POST /_agent-native/secrets/:key — write a secret. */
35
35
  export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
36
36
  error: string;
37
- status?: undefined;
38
37
  ok?: undefined;
38
+ status?: undefined;
39
39
  } | {
40
+ error?: undefined;
40
41
  ok: boolean;
41
42
  status: string;
42
- error?: undefined;
43
43
  } | {
44
+ ok?: undefined;
44
45
  error: string;
45
46
  removed?: undefined;
46
- ok?: undefined;
47
47
  } | {
48
+ error?: undefined;
48
49
  ok: boolean;
49
50
  removed: boolean;
50
- error?: undefined;
51
51
  }>>;
52
52
  /**
53
53
  * POST /_agent-native/secrets/:key/test — validate an optional candidate value
54
54
  * or the current stored value without changing anything.
55
55
  */
56
56
  export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
57
+ ok?: undefined;
57
58
  error: string;
58
59
  note?: undefined;
59
- ok?: undefined;
60
60
  } | {
61
+ error?: undefined;
61
62
  ok: boolean;
62
63
  note?: undefined;
63
- error?: undefined;
64
64
  } | {
65
+ error?: undefined;
65
66
  ok: boolean;
66
67
  note: string;
67
- error?: undefined;
68
68
  } | {
69
69
  note?: undefined;
70
70
  ok: boolean;
@@ -95,11 +95,11 @@ export interface AdHocSecretPayload {
95
95
  export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
96
96
  error: string;
97
97
  } | {
98
+ error?: undefined;
98
99
  ok: boolean;
99
100
  key: string;
100
- error?: undefined;
101
101
  } | {
102
+ error?: undefined;
102
103
  ok: boolean;
103
104
  removed: boolean;
104
- error?: undefined;
105
105
  }>>;
@@ -27,10 +27,10 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
27
27
  export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
28
28
  error: any;
29
29
  } | {
30
+ error?: undefined;
30
31
  ok: boolean;
31
32
  key: string;
32
33
  baseUrlKey?: string;
33
34
  scope: AgentEngineApiKeyScope;
34
- error?: undefined;
35
35
  }>>;
36
36
  export {};
@@ -19,5 +19,6 @@ export declare function resolvePublicAppOriginConfig(): {
19
19
  appUrl?: string;
20
20
  workspaceGatewayUrl?: string;
21
21
  workspaceOAuthOrigin?: string;
22
+ workspaceRuntime?: boolean;
22
23
  } | null;
23
24
  export declare function getAppOriginClientConfigScript(): string | null;
@@ -18,6 +18,8 @@ import { getAppConfig } from "../app-config/index.js";
18
18
  */
19
19
  export function resolvePublicAppOriginConfig() {
20
20
  const config = getAppConfig();
21
+ const workspaceRuntime = config.workspace.isWorkspace === true ||
22
+ typeof config.workspace.appsJson === "string";
21
23
  const resolved = {
22
24
  ...(config.app.url ? { appUrl: config.app.url } : {}),
23
25
  ...(config.workspace.gatewayUrl
@@ -26,6 +28,7 @@ export function resolvePublicAppOriginConfig() {
26
28
  ...(config.workspace.oauthOrigin
27
29
  ? { workspaceOAuthOrigin: config.workspace.oauthOrigin }
28
30
  : {}),
31
+ ...(workspaceRuntime ? { workspaceRuntime: true } : {}),
29
32
  };
30
33
  return Object.keys(resolved).length > 0 ? resolved : null;
31
34
  }
@@ -2957,8 +2957,8 @@ async function mountBetterAuthRoutes(app, options) {
2957
2957
  redirectPath: oauthDebugUrlPath(redirectUri),
2958
2958
  returnUrl,
2959
2959
  redirect: q.redirect === "1",
2960
- workspace: process.env.AGENT_NATIVE_WORKSPACE === "1" ||
2961
- process.env.VITE_AGENT_NATIVE_WORKSPACE === "1",
2960
+ workspace: getAppConfig().workspace.isWorkspace === true ||
2961
+ typeof getAppConfig().workspace.appsJson === "string",
2962
2962
  });
2963
2963
  const params = new URLSearchParams({
2964
2964
  client_id: googleSignInCredentials.clientId,
@@ -1,9 +1,12 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ import { getAppConfig } from "../app-config/index.js";
4
+ import { isTruthyRuntimeValue } from "../shared/runtime-config.js";
3
5
  const FIRST_PARTY_COOKIE_DOMAIN = "agent-native.com";
4
6
  export function resolveAuthCookieNamespace(env = process.env, cwd = process.cwd()) {
5
- const isWorkspaceMode = env.AGENT_NATIVE_WORKSPACE === "1" ||
6
- env.VITE_AGENT_NATIVE_WORKSPACE === "1";
7
+ const isWorkspaceMode = env === process.env
8
+ ? isConfiguredWorkspaceRuntime()
9
+ : isWorkspaceModeFromEnv(env);
7
10
  const configuredCookieDomain = normalizeCookieDomain(env.COOKIE_DOMAIN);
8
11
  const isFirstPartyCookieDomain = normalizeDomainForCompare(configuredCookieDomain) ===
9
12
  FIRST_PARTY_COOKIE_DOMAIN;
@@ -63,6 +66,18 @@ export function resolveAuthCookieNamespace(env = process.env, cwd = process.cwd(
63
66
  isFirstPartyCookieDomain,
64
67
  };
65
68
  }
69
+ function isConfiguredWorkspaceRuntime() {
70
+ const workspace = getAppConfig().workspace;
71
+ return (workspace.isWorkspace === true || typeof workspace.appsJson === "string");
72
+ }
73
+ function isWorkspaceModeFromEnv(env) {
74
+ const workspaceFlag = firstConfiguredValue(env.AGENT_NATIVE_WORKSPACE, env.VITE_AGENT_NATIVE_WORKSPACE);
75
+ const workspaceApps = firstConfiguredValue(env.AGENT_NATIVE_WORKSPACE_APPS_JSON, env.VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON);
76
+ return isTruthyRuntimeValue(workspaceFlag) || Boolean(workspaceApps);
77
+ }
78
+ function firstConfiguredValue(...values) {
79
+ return values.find((value) => value?.trim())?.trim();
80
+ }
66
81
  function readPackageJsonName(cwd) {
67
82
  try {
68
83
  const raw = fs.readFileSync(path.join(cwd, "package.json"), "utf8");
@@ -22,6 +22,7 @@ import { CREDENTIAL_STORE_UNAVAILABLE_ERROR_CODE, GATEWAY_UNAVAILABLE_VISITOR_ME
22
22
  import { getAppConfig } from "../app-config/index.js";
23
23
  import { getDbExec, isLocalDatabase, isTransientDatabaseError, } from "../db/client.js";
24
24
  import { getOrgSetting } from "../settings/org-settings.js";
25
+ import { isTruthyRuntimeValue } from "../shared/runtime-config.js";
25
26
  import { getRequestUserEmail, getRequestOrgId } from "./request-context.js";
26
27
  const DISPATCH_VAULT_ACCESS_SETTINGS_KEY = "dispatch-vault-access-settings";
27
28
  /**
@@ -209,8 +210,10 @@ function isHostedWorkspaceRuntime() {
209
210
  const hasFusionPreview = Boolean(process.env.FUSION_ENVIRONMENT ||
210
211
  process.env.FUSION_ENV_ORIGIN ||
211
212
  process.env.VITE_FUSION_ENV_ORIGIN);
212
- return (/^(1|true)$/i.test(process.env.AGENT_NATIVE_WORKSPACE ?? "") ||
213
- /^(1|true)$/i.test(process.env.VITE_AGENT_NATIVE_WORKSPACE ?? "") ||
213
+ return (isTruthyRuntimeValue(process.env.AGENT_NATIVE_WORKSPACE) ||
214
+ isTruthyRuntimeValue(process.env.VITE_AGENT_NATIVE_WORKSPACE) ||
215
+ Boolean(process.env.AGENT_NATIVE_WORKSPACE_APPS_JSON?.trim()) ||
216
+ Boolean(process.env.VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON?.trim()) ||
214
217
  hasFusionPreview);
215
218
  }
216
219
  function isProductionLikeRuntime() {
@@ -1,8 +1,9 @@
1
1
  import crypto from "node:crypto";
2
+ import { getAppConfig } from "../app-config/index.js";
2
3
  const DERIVED_SECRET_PREFIX = "agent-native:derived-secret:v1";
3
4
  function isWorkspaceRuntime() {
4
- return (process.env.AGENT_NATIVE_WORKSPACE === "1" ||
5
- process.env.VITE_AGENT_NATIVE_WORKSPACE === "1");
5
+ const workspace = getAppConfig().workspace;
6
+ return (workspace.isWorkspace === true || typeof workspace.appsJson === "string");
6
7
  }
7
8
  export function deriveServerSecret(rootSecret, purpose) {
8
9
  return crypto
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * After first account exists, this page acts as a normal login page.
8
8
  */
9
+ import { getAppConfig } from "../app-config/index.js";
9
10
  import { getLocaleInitScript } from "../localization/server.js";
10
11
  import { DEFAULT_LOCALE, LOCALE_METADATA, LOCALE_STORAGE_KEY, SUPPORTED_LOCALES, } from "../localization/shared.js";
11
12
  import { NATIVE_AUTH_COPY } from "../shared/auth-copy.js";
@@ -42,6 +43,25 @@ function getConnectionLabel() {
42
43
  return "Turso";
43
44
  return "SQL database";
44
45
  }
46
+ function isWorkspaceRuntime() {
47
+ const workspace = getAppConfig().workspace;
48
+ return (workspace.isWorkspace === true || typeof workspace.appsJson === "string");
49
+ }
50
+ function workspaceBasePathFromRequest(requestPath) {
51
+ if (!isWorkspaceRuntime() || !requestPath)
52
+ return "";
53
+ const pathname = requestPath.split(/[?#]/, 1)[0] || "/";
54
+ const firstSegment = pathname.split("/").find(Boolean);
55
+ if (!firstSegment ||
56
+ firstSegment === "_agent-native" ||
57
+ firstSegment === "api" ||
58
+ firstSegment === "sign-in" ||
59
+ firstSegment === "login" ||
60
+ firstSegment === "signup") {
61
+ return "";
62
+ }
63
+ return normalizeAppBasePath(`/${firstSegment}`);
64
+ }
45
65
  function withAppBasePath(path) {
46
66
  const cleanPath = path.startsWith("/") ? path : `/${path}`;
47
67
  const basePath = normalizeAppBasePath(process.env.VITE_APP_BASE_PATH || process.env.APP_BASE_PATH);
@@ -997,7 +1017,9 @@ export function getOnboardingHtml(opts = {}) {
997
1017
  // for every visitor. A genuinely misconfigured server instead surfaces a
998
1018
  // clear error at click time via the auth API.
999
1019
  const renderGoogleButton = showGoogle || googleOnly;
1000
- const appBasePath = normalizeAppBasePath(process.env.VITE_APP_BASE_PATH || process.env.APP_BASE_PATH);
1020
+ const configuredAppBasePath = normalizeAppBasePath(process.env.VITE_APP_BASE_PATH || process.env.APP_BASE_PATH);
1021
+ const appBasePath = configuredAppBasePath || workspaceBasePathFromRequest(opts.requestPath);
1022
+ const workspaceRuntime = isWorkspaceRuntime();
1001
1023
  const publicOAuthOrigin = getPublicOAuthOrigin();
1002
1024
  const workspaceGatewayReturnOrigin = getWorkspaceGatewayReturnOrigin();
1003
1025
  const googleAuthMode = resolveGoogleAuthMode(opts.googleAuthMode);
@@ -2126,7 +2148,17 @@ ${signupLocalModeNoteHtml}
2126
2148
  if (configured) return configured;
2127
2149
  var marker = '/_agent-native';
2128
2150
  var idx = window.location.pathname.indexOf(marker);
2129
- return idx > 0 ? window.location.pathname.slice(0, idx) : '';
2151
+ if (idx > 0) return window.location.pathname.slice(0, idx);
2152
+ if (${JSON.stringify(workspaceRuntime)}) {
2153
+ var segments = window.location.pathname.split('/');
2154
+ for (var i = 0; i < segments.length; i++) {
2155
+ var segment = segments[i];
2156
+ if (segment && segment !== '_agent-native' && segment !== 'api' && segment !== 'sign-in' && segment !== 'login' && segment !== 'signup') {
2157
+ return '/' + segment;
2158
+ }
2159
+ }
2160
+ }
2161
+ return '';
2130
2162
  }
2131
2163
  function __anPath(path) {
2132
2164
  return __anBasePath() + path;
@@ -1,3 +1,5 @@
1
+ import { getAppConfig } from "../app-config/index.js";
2
+ import { isTruthyRuntimeValue } from "../shared/runtime-config.js";
1
3
  /**
2
4
  * Whether workspace OAuth callbacks use the root framework relay.
3
5
  *
@@ -8,13 +10,16 @@
8
10
  * the mounted app that initiated it.
9
11
  */
10
12
  export function isWorkspaceOAuthCallbackRelayEnabled() {
13
+ const workspace = getAppConfig().workspace;
11
14
  const metaEnv = import.meta.env;
12
- return ([
13
- process.env.AGENT_NATIVE_WORKSPACE,
14
- process.env.VITE_AGENT_NATIVE_WORKSPACE,
15
- metaEnv?.AGENT_NATIVE_WORKSPACE,
16
- metaEnv?.VITE_AGENT_NATIVE_WORKSPACE,
17
- ].some((value) => value === "1" || value === "true") ||
15
+ return (workspace.isWorkspace === true ||
16
+ typeof workspace.appsJson === "string" ||
17
+ [
18
+ process.env.AGENT_NATIVE_WORKSPACE,
19
+ process.env.VITE_AGENT_NATIVE_WORKSPACE,
20
+ metaEnv?.AGENT_NATIVE_WORKSPACE,
21
+ metaEnv?.VITE_AGENT_NATIVE_WORKSPACE,
22
+ ].some((value) => isTruthyRuntimeValue(value)) ||
18
23
  [
19
24
  process.env.AGENT_NATIVE_WORKSPACE_APP_ID,
20
25
  process.env.VITE_AGENT_NATIVE_WORKSPACE_APP_ID,
@@ -37,6 +37,8 @@ export interface RuntimeConfigReportOptions {
37
37
  phase?: RuntimeConfigPhase;
38
38
  appName?: string;
39
39
  }
40
+ /** Parse the truthy spellings accepted by typed runtime configuration flags. */
41
+ export declare function isTruthyRuntimeValue(value: string | boolean | undefined): boolean;
40
42
  export declare function runtimeConfigRequirementsFromSearchParams(searchParams: URLSearchParams): RuntimeConfigRequirements;
41
43
  export declare function buildRuntimeConfigPrompt(report: Pick<RuntimeConfigReport, "environment" | "phase" | "issues">, appName?: string): string;
42
44
  export declare function getRuntimeConfigReport(env: Record<string, string | undefined>, requirements?: RuntimeConfigRequirements, options?: RuntimeConfigReportOptions): RuntimeConfigReport;