@agent-native/core 0.231.0 → 0.232.0-nightly-20261118152333

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 (71) hide show
  1. package/dist/a2a/call-hooks.d.ts +135 -0
  2. package/dist/a2a/call-hooks.js +164 -0
  3. package/dist/a2a/client.d.ts +5 -0
  4. package/dist/a2a/client.js +22 -0
  5. package/dist/a2a/foreground-call-scope.d.ts +6 -0
  6. package/dist/a2a/foreground-call-scope.js +26 -0
  7. package/dist/a2a/handlers.js +119 -2
  8. package/dist/a2a/index.d.ts +3 -0
  9. package/dist/a2a/index.js +2 -0
  10. package/dist/a2a/invoke.js +17 -0
  11. package/dist/a2a/server.js +3 -0
  12. package/dist/action.js +3 -1
  13. package/dist/agent/durable-background.d.ts +6 -0
  14. package/dist/agent/durable-background.js +6 -0
  15. package/dist/agent/durable-turn-grant.d.ts +53 -0
  16. package/dist/agent/durable-turn-grant.js +83 -0
  17. package/dist/agent/production-agent.js +54 -2
  18. package/dist/app-config/agent.d.ts +1 -0
  19. package/dist/app-config/agent.js +7 -0
  20. package/dist/app-config/schema.d.ts +1 -0
  21. package/dist/cli/doctor.d.ts +1 -0
  22. package/dist/cli/doctor.js +10 -4
  23. package/dist/client/sharing/useShareButtonController.d.ts +5 -0
  24. package/dist/client/sharing/useShareButtonController.js +2 -1
  25. package/dist/client/use-chat-threads.js +3 -0
  26. package/dist/client/use-db-sync.js +22 -0
  27. package/dist/collab/routes.d.ts +1 -1
  28. package/dist/deploy/build.d.ts +4 -1
  29. package/dist/deploy/build.js +25 -15
  30. package/dist/file-upload/actions/upload-image.d.ts +2 -2
  31. package/dist/framework-package-versions.json +7 -7
  32. package/dist/guards/index.d.ts +1 -1
  33. package/dist/guards/index.js +1 -1
  34. package/dist/guards/no-env-credentials.d.ts +15 -1
  35. package/dist/guards/no-env-credentials.js +27 -0
  36. package/dist/integrations/internal-token.d.ts +15 -0
  37. package/dist/integrations/internal-token.js +19 -0
  38. package/dist/mcp/build-server.js +18 -2
  39. package/dist/mcp/index.d.ts +1 -0
  40. package/dist/mcp/index.js +1 -0
  41. package/dist/mcp/turn-grant-admitters.d.ts +61 -0
  42. package/dist/mcp/turn-grant-admitters.js +83 -0
  43. package/dist/mcp/turn-grant-store.d.ts +5 -0
  44. package/dist/mcp/turn-grant-store.js +19 -0
  45. package/dist/org/index.d.ts +2 -2
  46. package/dist/org/workspace-app-access.js +30 -11
  47. package/dist/provider-api/actions/custom-provider-registration.d.ts +16 -16
  48. package/dist/provider-api/actions/provider-api.d.ts +8 -8
  49. package/dist/provider-api/call-gates.d.ts +71 -2
  50. package/dist/provider-api/call-gates.js +157 -3
  51. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  52. package/dist/provider-api/index.d.ts +1 -1
  53. package/dist/provider-api/index.js +1 -1
  54. package/dist/provider-api/interactive-scope.d.ts +2 -1
  55. package/dist/provider-api/interactive-scope.js +17 -4
  56. package/dist/server/agent-chat-plugin.js +9 -2
  57. package/dist/server/agent-run-context.d.ts +1 -1
  58. package/dist/server/agent-run-context.js +34 -3
  59. package/dist/server/entry-server.js +3 -1
  60. package/dist/server/transcribe-voice.d.ts +1 -1
  61. package/dist/shared/build-id.d.ts +14 -0
  62. package/dist/shared/build-id.js +21 -0
  63. package/dist/vite/client.d.ts +16 -0
  64. package/dist/vite/client.js +6 -3
  65. package/dist/vitest-config.js +1 -0
  66. package/dist/workspace-connections/workspace-credential-actions.d.ts +1 -0
  67. package/dist/workspace-connections/workspace-credential-actions.js +1 -0
  68. package/dist/workspace-connections/workspace-credentials.d.ts +4 -0
  69. package/dist/workspace-connections/workspace-credentials.js +40 -4
  70. package/docs/workspace-credential-drafts.md +28 -0
  71. package/package.json +5 -4
@@ -137,6 +137,12 @@ export const AGENT_CHAT_BACKGROUND_SETUP_CLEANUP_FIELD = "__agentChatBackgroundS
137
137
  export const AGENT_CHAT_BROWSER_SESSION_ID_FIELD = "__agentNativeBrowserSessionId";
138
138
  /** Captured turn origin; durable workers do not restore loopback trust from this payload. */
139
139
  export const AGENT_CHAT_REQUEST_CONTEXT_FIELD = "__agentChatRequestContext";
140
+ /**
141
+ * Signed proof, minted only by the foreground handler, that the turn a durable
142
+ * run continues was started interactively by its owner. A client can submit
143
+ * this field too, so the foreground handler always overwrites it.
144
+ */
145
+ export const AGENT_CHAT_TURN_GRANT_FIELD = "__agentChatTurnGrant";
140
146
  export function isHostedRuntimeForDurableBackground() {
141
147
  if (process.env.NETLIFY_LOCAL === "true")
142
148
  return false;
@@ -0,0 +1,53 @@
1
+ import { type DurableTurnGrantClaim } from "../integrations/internal-token.js";
2
+ import type { ProviderTurnGrant } from "../provider-api/interactive-scope.js";
3
+ import type { AgentTurnInitiator } from "./run-store.js";
4
+ /**
5
+ * Where the background worker leaves the turn grant it verified from the
6
+ * dispatch payload, for `runWithAgentRunContext` to scope the run with.
7
+ */
8
+ export declare const VERIFIED_TURN_GRANT_CONTEXT_KEY = "__agentNativeVerifiedTurnGrant";
9
+ /** A claim plus its signature, as carried in a durable dispatch payload. */
10
+ export type SignedDurableTurnGrant = DurableTurnGrantClaim & {
11
+ signature: string;
12
+ };
13
+ /**
14
+ * The grant a foreground handler hands the durable run it dispatches, or
15
+ * undefined. Only a fresh turn its signed-in owner is driving interactively
16
+ * gets one; a continuation, recovery or anonymous turn never does.
17
+ */
18
+ export declare function mintDurableTurnGrant(input: {
19
+ runId: string;
20
+ turnId: string;
21
+ initiator: AgentTurnInitiator | undefined;
22
+ interactive: boolean;
23
+ continuation: boolean;
24
+ lifetimeMs: number;
25
+ now?: number;
26
+ }): SignedDurableTurnGrant | undefined;
27
+ /**
28
+ * The same turn's grant for the run a server-driven continuation chains to.
29
+ * Only a run that verified its own grant passes one on, keeping its turn,
30
+ * initiator and expiry; anything else returns undefined, so a stale or
31
+ * forged grant never reaches the next run.
32
+ */
33
+ export declare function reissueDurableTurnGrant(input: {
34
+ verified: ProviderTurnGrant | undefined;
35
+ initiator: AgentTurnInitiator | undefined;
36
+ turnId: string;
37
+ nextRunId: string;
38
+ now?: number;
39
+ }): SignedDurableTurnGrant | undefined;
40
+ export interface DurableTurnGrantStore {
41
+ getRunTurnRef(runId: string): Promise<{
42
+ threadId: string;
43
+ turnId: string;
44
+ } | null>;
45
+ getTurnInitiatorByRun(runId: string): Promise<AgentTurnInitiator | null>;
46
+ isTurnAborted(threadId: string, turnId: string): Promise<boolean>;
47
+ }
48
+ /**
49
+ * The grant a durable dispatch carried, checked against the run's persisted
50
+ * turn and initiator. Null when the payload has none or it no longer holds:
51
+ * another run, turn or person, a bad signature, expired, or an aborted turn.
52
+ */
53
+ export declare function verifyDispatchedTurnGrant(candidate: unknown, runId: string, store: DurableTurnGrantStore, now?: number): Promise<ProviderTurnGrant | null>;
@@ -0,0 +1,83 @@
1
+ import { signDurableTurnGrant, verifyDurableTurnGrant, } from "../integrations/internal-token.js";
2
+ /**
3
+ * Where the background worker leaves the turn grant it verified from the
4
+ * dispatch payload, for `runWithAgentRunContext` to scope the run with.
5
+ */
6
+ export const VERIFIED_TURN_GRANT_CONTEXT_KEY = "__agentNativeVerifiedTurnGrant";
7
+ function claimFor(runId, turnId, initiator, expiresAt) {
8
+ return {
9
+ runId,
10
+ turnId,
11
+ initiator: {
12
+ email: initiator.email,
13
+ authUserId: initiator.authUserId ?? null,
14
+ orgId: initiator.orgId ?? null,
15
+ orgScope: initiator.orgScope ?? null,
16
+ },
17
+ expiresAt,
18
+ };
19
+ }
20
+ function signed(claim) {
21
+ return { ...claim, signature: signDurableTurnGrant(claim) };
22
+ }
23
+ /**
24
+ * The grant a foreground handler hands the durable run it dispatches, or
25
+ * undefined. Only a fresh turn its signed-in owner is driving interactively
26
+ * gets one; a continuation, recovery or anonymous turn never does.
27
+ */
28
+ export function mintDurableTurnGrant(input) {
29
+ const { initiator } = input;
30
+ if (!initiator || initiator.anonymous || !input.interactive)
31
+ return undefined;
32
+ if (input.continuation)
33
+ return undefined;
34
+ return signed(claimFor(input.runId, input.turnId, initiator, (input.now ?? Date.now()) + input.lifetimeMs));
35
+ }
36
+ /**
37
+ * The same turn's grant for the run a server-driven continuation chains to.
38
+ * Only a run that verified its own grant passes one on, keeping its turn,
39
+ * initiator and expiry; anything else returns undefined, so a stale or
40
+ * forged grant never reaches the next run.
41
+ */
42
+ export function reissueDurableTurnGrant(input) {
43
+ const { verified, initiator } = input;
44
+ if (!verified || !initiator || initiator.anonymous)
45
+ return undefined;
46
+ if (verified.turnId !== input.turnId)
47
+ return undefined;
48
+ if (verified.owner.trim().toLowerCase() !== initiator.email.trim().toLowerCase())
49
+ return undefined;
50
+ if (verified.expiresAt <= (input.now ?? Date.now()))
51
+ return undefined;
52
+ return signed(claimFor(input.nextRunId, input.turnId, initiator, verified.expiresAt));
53
+ }
54
+ /**
55
+ * The grant a durable dispatch carried, checked against the run's persisted
56
+ * turn and initiator. Null when the payload has none or it no longer holds:
57
+ * another run, turn or person, a bad signature, expired, or an aborted turn.
58
+ */
59
+ export async function verifyDispatchedTurnGrant(candidate, runId, store, now = Date.now()) {
60
+ if (!candidate || typeof candidate !== "object" || Array.isArray(candidate))
61
+ return null;
62
+ const grant = candidate;
63
+ const expiresAt = grant.expiresAt;
64
+ if (typeof expiresAt !== "number" ||
65
+ !Number.isFinite(expiresAt) ||
66
+ expiresAt <= now)
67
+ return null;
68
+ if (grant.runId !== runId)
69
+ return null;
70
+ const [turn, initiator] = await Promise.all([
71
+ store.getRunTurnRef(runId),
72
+ store.getTurnInitiatorByRun(runId),
73
+ ]);
74
+ if (!turn || !initiator || initiator.anonymous)
75
+ return null;
76
+ if (grant.turnId !== turn.turnId)
77
+ return null;
78
+ if (!verifyDurableTurnGrant(claimFor(runId, turn.turnId, initiator, expiresAt), grant.signature))
79
+ return null;
80
+ if (await store.isTurnAborted(turn.threadId, turn.turnId))
81
+ return null;
82
+ return { runId, turnId: turn.turnId, owner: initiator.email, expiresAt };
83
+ }
@@ -41,6 +41,7 @@ import { parseServiceIdentityEmail } from "../org/service-identity.js";
41
41
  import { ServicePrincipalRefusedError } from "../org/service-principal-guard.js";
42
42
  import { isAttachmentError } from "../private-blob/attachment-errors.js";
43
43
  import { completeRun as completeProgressRun, startRun as startProgressRun, updateRunProgress, } from "../progress/registry.js";
44
+ import { isProviderInteractiveScope, runWithDurableTurnToolScope, } from "../provider-api/interactive-scope.js";
44
45
  import { readOptionalKeyCache, writeOptionalKeyCache, } from "../secrets/optional-key-cache.js";
45
46
  import { AGENT_CHAT_AI_SETUP_REQUIRED_CODE, isAgentChatAiSetupRequiredError, } from "../server/agent-chat-ai-setup.js";
46
47
  import { finalizeClaimedAgentChatProcessRunFailure } from "../server/agent-chat/process-run-failure.js";
@@ -74,7 +75,8 @@ import { clipHead } from "./clip-text.js";
74
75
  import { connectionRequiredMessage, priorConnectionContextNote, resolvePriorConnectionNote, } from "./connection-required-note.js";
75
76
  import { buildSystemManifestSections, readContextXraySystemSections, } from "./context-xray/manifest.js";
76
77
  import { AGENT_INTERNAL_CONTINUE_PROMPT } from "./continuation-prompt.js";
77
- import { AGENT_CHAT_BROWSER_SESSION_ID_FIELD, AGENT_CHAT_REQUEST_CONTEXT_FIELD, AGENT_CHAT_BACKGROUND_RUN_FIELD, AGENT_CHAT_BACKGROUND_SETUP_CLEANUP_FIELD, AGENT_CHAT_PROCESS_RUN_PATH, AGENT_CHAT_RECOVERY_OF_RUN_FIELD, backgroundRuntimeDiagnosticDetail, dispatchPathTargetsNetlifyBackgroundFunction, isAgentChatDurableBackgroundEnabled, isAgentChatForegroundSelfChainEnabled, isInBackgroundFunctionRuntime, resolveAgentChatProcessRunDispatchPath, shouldUseBackgroundFunctionTimeoutForWorker, } from "./durable-background.js";
78
+ import { AGENT_CHAT_BROWSER_SESSION_ID_FIELD, AGENT_CHAT_REQUEST_CONTEXT_FIELD, AGENT_CHAT_TURN_GRANT_FIELD, AGENT_CHAT_BACKGROUND_RUN_FIELD, AGENT_CHAT_BACKGROUND_SETUP_CLEANUP_FIELD, AGENT_CHAT_PROCESS_RUN_PATH, AGENT_CHAT_RECOVERY_OF_RUN_FIELD, backgroundRuntimeDiagnosticDetail, dispatchPathTargetsNetlifyBackgroundFunction, isAgentChatDurableBackgroundEnabled, isAgentChatForegroundSelfChainEnabled, isInBackgroundFunctionRuntime, resolveAgentChatProcessRunDispatchPath, shouldUseBackgroundFunctionTimeoutForWorker, } from "./durable-background.js";
79
+ import { VERIFIED_TURN_GRANT_CONTEXT_KEY, mintDurableTurnGrant, reissueDurableTurnGrant, } from "./durable-turn-grant.js";
78
80
  import { applyContextXrayTransformForIteration } from "./engine/context-directives-transform.js";
79
81
  import { attemptContinuationDispatch } from "./engine/continuation-dispatch-retry.js";
80
82
  import { formatLlmCredentialErrorMessage, LLM_MISSING_CREDENTIALS_ERROR_CODE, LLM_MISSING_CREDENTIALS_MESSAGE, userFacingLlmCredentialError, } from "./engine/credential-errors.js";
@@ -7952,7 +7954,16 @@ export async function runAgentLoop(opts) {
7952
7954
  ...(actionUserEmail ? { userEmail: actionUserEmail } : {}),
7953
7955
  ...(actionOrgId ? { orgId: actionOrgId } : {}),
7954
7956
  ...(requestContext?.run ? { run: requestContext.run } : {}),
7955
- }, invokeAction));
7957
+ }, () => runWithDurableTurnToolScope(invokeAction, AbortSignal.any([signal, timeoutSignal]), {
7958
+ runId: opts.runId,
7959
+ turnId: opts.turnId,
7960
+ owner: opts.ownerEmail,
7961
+ ...(opts.networkProtocol
7962
+ ? { networkProtocol: opts.networkProtocol }
7963
+ : {}),
7964
+ unattended: Boolean(opts.automation ||
7965
+ (opts.actionCaller && opts.actionCaller !== "tool")),
7966
+ })));
7956
7967
  // When the run is aborted (soft-timeout / user cancel) while this tool
7957
7968
  // call is in flight, Promise.race below will throw "Run aborted" and the
7958
7969
  // action's promise becomes a zombie — it keeps running but its result is
@@ -9786,6 +9797,17 @@ export function isLoopProtectionDispatchError(err) {
9786
9797
  return /\bHTTP\s*508\b/i.test(err.message);
9787
9798
  }
9788
9799
  export const MAX_NESTED_SELF_DISPATCH_DEPTH = 6;
9800
+ function verifiedTurnGrantOf(event) {
9801
+ if (!event || typeof event !== "object")
9802
+ return undefined;
9803
+ const context = Reflect.get(event, "context");
9804
+ if (!context || typeof context !== "object")
9805
+ return undefined;
9806
+ const grant = Reflect.get(context, VERIFIED_TURN_GRANT_CONTEXT_KEY);
9807
+ return grant && typeof grant === "object"
9808
+ ? grant
9809
+ : undefined;
9810
+ }
9789
9811
  export async function chainServerDrivenContinuation(opts) {
9790
9812
  const d = {
9791
9813
  countRunsForTurn: opts.deps?.countRunsForTurn ?? countRunsForTurn,
@@ -9883,6 +9905,18 @@ export async function chainServerDrivenContinuation(opts) {
9883
9905
  }
9884
9906
  : {}),
9885
9907
  };
9908
+ // The turn grant names its run, so the next run gets its own copy, and
9909
+ // only when this run verified the grant it was dispatched with.
9910
+ const nextTurnGrant = reissueDurableTurnGrant({
9911
+ verified: verifiedTurnGrantOf(opts.event),
9912
+ initiator: opts.turnInitiator,
9913
+ turnId: effectiveTurnId,
9914
+ nextRunId,
9915
+ });
9916
+ if (nextTurnGrant)
9917
+ continuationBody[AGENT_CHAT_TURN_GRANT_FIELD] = nextTurnGrant;
9918
+ else
9919
+ delete continuationBody[AGENT_CHAT_TURN_GRANT_FIELD];
9886
9920
  // Approval selectors apply only to the request that consumes their one-shot grants.
9887
9921
  delete continuationBody.approvedToolCalls;
9888
9922
  delete continuationBody.approvedToolCallAskIds;
@@ -10438,6 +10472,7 @@ export function createProductionAgentHandler(options) {
10438
10472
  });
10439
10473
  const mutableBody = body;
10440
10474
  if (!isBackgroundWorker) {
10475
+ delete mutableBody[AGENT_CHAT_TURN_GRANT_FIELD];
10441
10476
  // A client can submit this private field, so overwrite it at the boundary.
10442
10477
  mutableBody[AGENT_CHAT_BROWSER_SESSION_ID_FIELD] =
10443
10478
  getRequestContext()?.browserSessionId ?? null;
@@ -12282,6 +12317,23 @@ export function createProductionAgentHandler(options) {
12282
12317
  (typeof requestTurnId === "string" && requestTurnId.trim()
12283
12318
  ? requestTurnId.trim()
12284
12319
  : runId));
12320
+ // Only a fresh turn the owner is driving from the page right now hands its
12321
+ // foreground standing to the durable run; continuations never mint one.
12322
+ if (dispatchToBackground && getAppConfig().agent.interactiveChatTurns) {
12323
+ const grant = mintDurableTurnGrant({
12324
+ runId,
12325
+ turnId: effectiveTurnId,
12326
+ initiator: turnInitiator,
12327
+ interactive: isProviderInteractiveScope(),
12328
+ continuation: internalContinuation === true ||
12329
+ Boolean(continueOf) ||
12330
+ Boolean(requestedAutoContinueOfRunId) ||
12331
+ Boolean(requestedContinueOfRunId),
12332
+ lifetimeMs: MAX_TURN_WALL_CLOCK_MS,
12333
+ });
12334
+ if (grant)
12335
+ mutableBody[AGENT_CHAT_TURN_GRANT_FIELD] = grant;
12336
+ }
12285
12337
  let durableDispatchPayload;
12286
12338
  if (dispatchToBackground) {
12287
12339
  try {
@@ -17,6 +17,7 @@ export declare const agentConfig: z.ZodObject<{
17
17
  builtInEngines: z.ZodOptional<z.ZodArray<z.ZodString>>;
18
18
  buildEnginePackages: z.ZodOptional<z.ZodString>;
19
19
  mode: z.ZodOptional<z.ZodString>;
20
+ interactiveChatTurns: z.ZodDefault<z.ZodBoolean>;
20
21
  preferBringYourOwnKey: z.ZodDefault<z.ZodBoolean>;
21
22
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
22
23
  mainChatMaxOutputTokens: z.ZodDefault<z.ZodNumber>;
@@ -78,6 +78,13 @@ export const agentConfig = z.object({
78
78
  env: ["AGENT_MODE"],
79
79
  doc: 'Runtime mode. "production" turns off development-only agent behavior.',
80
80
  }),
81
+ interactiveChatTurns: z
82
+ .boolean()
83
+ .default(false)
84
+ .meta({
85
+ env: ["AGENT_INTERACTIVE_CHAT_TURNS"],
86
+ doc: "Mark a chat turn its signed-in owner sent from this app's own page as interactive (foreground) provider work, including the tool calls of the durable run it hands off to, so provider call gates can admit them.",
87
+ }),
81
88
  preferBringYourOwnKey: z
82
89
  .boolean()
83
90
  .default(false)
@@ -105,6 +105,7 @@ export declare const appConfigSchema: z.ZodObject<{
105
105
  builtInEngines: z.ZodOptional<z.ZodArray<z.ZodString>>;
106
106
  buildEnginePackages: z.ZodOptional<z.ZodString>;
107
107
  mode: z.ZodOptional<z.ZodString>;
108
+ interactiveChatTurns: z.ZodDefault<z.ZodBoolean>;
108
109
  preferBringYourOwnKey: z.ZodDefault<z.ZodBoolean>;
109
110
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
110
111
  mainChatMaxOutputTokens: z.ZodDefault<z.ZodNumber>;
@@ -4,6 +4,7 @@ export declare const ALL_GUARD_NAMES: GuardName[];
4
4
  export interface DoctorConfig {
5
5
  disabledGuards: string[];
6
6
  dbToolScopingDenylist: Record<string, string>;
7
+ testEnvKeys: string[];
7
8
  failOnBuild: boolean;
8
9
  }
9
10
  export interface DoctorFinding {
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { nativeManifestSchema } from "../app-config/schema.js";
4
- import { scanDbToolScoping, scanDrizzlePush, scanEmptyMigrations, scanEnvCredentials, scanEnvMutation, scanExplicitCollabAccess, scanIdentityColumnsRegistered, scanLocalhostFallback, scanResourceActionAccess, scanServerPluginDefaultExport, scanUnscopedCredentials, scanUnscopedQueries, } from "../guards/index.js";
4
+ import { scanDbToolScoping, scanDrizzlePush, scanEmptyMigrations, scanEnvCredentials, scanEnvMutation, scanExplicitCollabAccess, scanIdentityColumnsRegistered, scanLocalhostFallback, scanResourceActionAccess, scanServerPluginDefaultExport, scanUnscopedCredentials, scanUnscopedQueries, parseTestEnvKeys, } from "../guards/index.js";
5
5
  import { AGENT_NATIVE_MIGRATION_GUIDE_URL, AGENT_NATIVE_UPGRADE_CODEMOD_COMMAND, loadMigrationManifestsForProject, resolveMigrationSymbolMove, scanDeprecatedImports, } from "../package-lifecycle/index.js";
6
6
  import { formatBytes, scanCleanTargets } from "./clean.js";
7
7
  import { loadActiveMigrationDependencies, isDirectCoreDependency, readCliCoreVersion, readUpgradeEnvironment, resolveInstalledPackageVersion, selectMigrationDependencies, } from "./upgrade.js";
@@ -32,12 +32,17 @@ export const ALL_GUARD_NAMES = [
32
32
  const DEFAULT_DOCTOR_CONFIG = {
33
33
  disabledGuards: [],
34
34
  dbToolScopingDenylist: {},
35
+ testEnvKeys: [],
35
36
  failOnBuild: true,
36
37
  };
37
38
  export function readDoctorConfig(root) {
38
39
  const manifestPath = path.join(root, "agent-native.json");
39
40
  if (!fs.existsSync(manifestPath)) {
40
- return { ...DEFAULT_DOCTOR_CONFIG, dbToolScopingDenylist: {} };
41
+ return {
42
+ ...DEFAULT_DOCTOR_CONFIG,
43
+ dbToolScopingDenylist: {},
44
+ testEnvKeys: [],
45
+ };
41
46
  }
42
47
  try {
43
48
  const raw = fs.readFileSync(manifestPath, "utf-8");
@@ -53,7 +58,8 @@ export function readDoctorConfig(root) {
53
58
  const failOnBuild = typeof doctor.failOnBuild === "boolean"
54
59
  ? doctor.failOnBuild
55
60
  : DEFAULT_DOCTOR_CONFIG.failOnBuild;
56
- return { disabledGuards, dbToolScopingDenylist, failOnBuild };
61
+ const testEnvKeys = parseTestEnvKeys(doctor.testEnvKeys);
62
+ return { disabledGuards, dbToolScopingDenylist, testEnvKeys, failOnBuild };
57
63
  }
58
64
  catch (error) {
59
65
  throw new Error(`Could not read Doctor configuration from ${manifestPath}: ${error instanceof Error ? error.message : String(error)}`);
@@ -103,7 +109,7 @@ function runGuard(name, root, config, migrationManifests, shellEnvironment = pro
103
109
  case "no-unscoped-queries":
104
110
  return scanUnscopedQueries({ root, extraExemptPaths: [] });
105
111
  case "no-env-credentials":
106
- return scanEnvCredentials({ root });
112
+ return scanEnvCredentials({ root, testEnvKeys: config.testEnvKeys });
107
113
  case "db-tool-scoping":
108
114
  return scanDbToolScoping({
109
115
  root,
@@ -95,6 +95,11 @@ export interface ShareButtonControllerOptions {
95
95
  * returns true. See `ShareVisibilityTransitionOptions.confirmVisibility`.
96
96
  */
97
97
  confirmVisibility?: (from: ShareButtonVisibility, to: ShareButtonVisibility) => boolean;
98
+ /**
99
+ * False saves a private-to-organization change at once even when the policy
100
+ * asks first. `confirmVisibility` still asks for the changes it names.
101
+ */
102
+ confirmOrgVisibility?: boolean;
98
103
  }
99
104
  export interface ShareButtonController {
100
105
  open: boolean;
@@ -248,7 +248,8 @@ export function useShareButtonController(options) {
248
248
  resourceId: options.resourceId,
249
249
  current: visibility,
250
250
  orgId: data?.orgId ?? null,
251
- confirmOrgVisibility: policy.confirmOrgVisibility === true,
251
+ confirmOrgVisibility: options.confirmOrgVisibility !== false &&
252
+ policy.confirmOrgVisibility === true,
252
253
  confirmVisibility: options.confirmVisibility,
253
254
  canManage,
254
255
  active: open,
@@ -1518,6 +1518,9 @@ export function useChatThreads(apiUrl = agentNativePath("/_agent-native/agent-ch
1518
1518
  };
1519
1519
  let saved = await putThread();
1520
1520
  if (saved.absent) {
1521
+ if (serverConfirmedThreadIdsRef.current.has(serverConfirmedThreadKey(apiUrl, historyScopeKey, id))) {
1522
+ return false;
1523
+ }
1521
1524
  const created = await fetch(withChatThreadScope(`${apiUrl}/threads`, historyScope), {
1522
1525
  method: "POST",
1523
1526
  headers: { "Content-Type": "application/json" },
@@ -176,6 +176,8 @@ export function acquireCollabPollBoost() {
176
176
  }
177
177
  const processedRunToolEvents = new WeakSet();
178
178
  const processedRunEndEvents = new WeakSet();
179
+ const processedExplicitRefreshEvents = new WeakSet();
180
+ const explicitRefreshClients = new WeakMap();
179
181
  class HttpStatusError extends Error {
180
182
  status;
181
183
  constructor(status) {
@@ -1731,6 +1733,25 @@ export function useDbSync(options = {}) {
1731
1733
  };
1732
1734
  window.addEventListener("agent-native:tool-done", handleRunToolDone);
1733
1735
  window.addEventListener("agentNative.chatRunning", handleRunStatus);
1736
+ const handleExplicitRefresh = (event) => {
1737
+ if (!processedExplicitRefreshEvents.has(event)) {
1738
+ processedExplicitRefreshEvents.add(event);
1739
+ bumpLocalChangeVersion("action");
1740
+ bumpActiveLocalChangeVersions(["action"]);
1741
+ }
1742
+ if (queryClient) {
1743
+ let clients = explicitRefreshClients.get(event);
1744
+ if (!clients) {
1745
+ clients = new WeakSet();
1746
+ explicitRefreshClients.set(event, clients);
1747
+ }
1748
+ if (clients.has(queryClient))
1749
+ return;
1750
+ clients.add(queryClient);
1751
+ }
1752
+ queueInvalidateBatch([{ source: "action", version: 0 }]);
1753
+ };
1754
+ window.addEventListener("agentNative:refresh-data", handleExplicitRefresh);
1734
1755
  let transport;
1735
1756
  if (realtimeReason) {
1736
1757
  transport = getOrCreateTransport(pollUrl, sseUrl, resolveGatewayBinding(sseUrl));
@@ -1748,6 +1769,7 @@ export function useDbSync(options = {}) {
1748
1769
  return () => {
1749
1770
  window.removeEventListener("agent-native:tool-done", handleRunToolDone);
1750
1771
  window.removeEventListener("agentNative.chatRunning", handleRunStatus);
1772
+ window.removeEventListener("agentNative:refresh-data", handleExplicitRefresh);
1751
1773
  disposed = true;
1752
1774
  if (invalidateTimer) {
1753
1775
  clearTimeout(invalidateTimer);
@@ -26,8 +26,8 @@ export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import
26
26
  ok: boolean;
27
27
  }>>;
28
28
  export declare const postCollabText: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
29
- text?: undefined;
30
29
  ok?: undefined;
30
+ text?: undefined;
31
31
  error: string;
32
32
  } | {
33
33
  error?: undefined;
@@ -59,7 +59,10 @@ export declare function shouldBundleFfmpegStaticForServerless(hostPlatform?: Nod
59
59
  export declare function findServerlessBrowserRuntimeConsumer(projectCwd?: string): string | null;
60
60
  export declare function findInstalledPackageRoot(packageName: string, nodeModulesRoots: string[], fromPackageDir?: string): string | null;
61
61
  export declare function copyInstalledBrowserRuntimePackages(serverDir: string | undefined, projectCwd?: string): number;
62
- export declare function copyInstalledExternalSsrPackages(serverDir: string | undefined, projectCwd?: string): number;
62
+ export declare function copyInstalledExternalSsrPackages(serverDir: string | undefined, projectCwd?: string, options?: {
63
+ includeSsrPackages?: boolean;
64
+ }): number;
65
+ export declare function copyPresetRuntimePackages(targetPreset: string, serverDir: string | undefined, projectCwd?: string): void;
63
66
  export declare function findInstalledFfmpegStaticPackage(nodeModulesRoots: string[]): string | null;
64
67
  export declare function findInstalledResvgPackages(nodeModulesRoots: string[]): Array<{
65
68
  packageName: string;
@@ -2942,7 +2942,7 @@ export function copyInstalledBrowserRuntimePackages(serverDir, projectCwd = cwd)
2942
2942
  console.log(`[deploy] Copied ${copiedCount} serverless browser runtime package(s) into the server bundle (required by ${consumer}).`);
2943
2943
  return copiedCount;
2944
2944
  }
2945
- export function copyInstalledExternalSsrPackages(serverDir, projectCwd = cwd) {
2945
+ export function copyInstalledExternalSsrPackages(serverDir, projectCwd = cwd, options = {}) {
2946
2946
  if (!serverDir || !fs.existsSync(serverDir))
2947
2947
  return 0;
2948
2948
  const packagesToCopy = new Set();
@@ -2951,9 +2951,11 @@ export function copyInstalledExternalSsrPackages(serverDir, projectCwd = cwd) {
2951
2951
  // Keep undici opaque to client bundlers, but copy it into the server runtime.
2952
2952
  if (/(\"|'|\x60)undici\1/.test(source))
2953
2953
  packagesToCopy.add("undici");
2954
- for (const packageName of SERVERLESS_EXTERNAL_SSR_PACKAGES) {
2955
- if (hasExternalSsrRuntimeReference(source, packageName)) {
2956
- packagesToCopy.add(packageName);
2954
+ if (options.includeSsrPackages !== false) {
2955
+ for (const packageName of SERVERLESS_EXTERNAL_SSR_PACKAGES) {
2956
+ if (hasExternalSsrRuntimeReference(source, packageName)) {
2957
+ packagesToCopy.add(packageName);
2958
+ }
2957
2959
  }
2958
2960
  }
2959
2961
  });
@@ -2994,6 +2996,24 @@ export function copyInstalledExternalSsrPackages(serverDir, projectCwd = cwd) {
2994
2996
  console.log(`[deploy] Copied ${copiedCount} external SSR runtime package(s) into the server bundle.`);
2995
2997
  return copiedCount;
2996
2998
  }
2999
+ export function copyPresetRuntimePackages(targetPreset, serverDir, projectCwd = cwd) {
3000
+ if (targetPreset === "netlify" ||
3001
+ targetPreset === "vercel" ||
3002
+ isAwsLambdaPreset(targetPreset) ||
3003
+ isAwsAmplifyPreset(targetPreset)) {
3004
+ copyInstalledResvgPackages(serverDir);
3005
+ copyInstalledFfmpegStaticPackage(serverDir);
3006
+ copyInstalledBrowserRuntimePackages(serverDir);
3007
+ copyInstalledExternalSsrPackages(serverDir, projectCwd);
3008
+ sanitizeServerlessFunctionPackageManifest(serverDir);
3009
+ pruneServerlessFunctionDeadWeight(serverDir);
3010
+ }
3011
+ else if (targetPreset === "node" || targetPreset === "node-server") {
3012
+ copyInstalledExternalSsrPackages(serverDir, projectCwd, {
3013
+ includeSsrPackages: false,
3014
+ });
3015
+ }
3016
+ }
2997
3017
  function hasFfmpegStaticBinary(packageDir) {
2998
3018
  return FFMPEG_STATIC_BINARY_NAMES.some((binaryName) => fs.existsSync(path.join(packageDir, binaryName)));
2999
3019
  }
@@ -5269,17 +5289,7 @@ export default bundle;
5269
5289
  if (preset === "vercel") {
5270
5290
  addVercelSweepCron(nitro.options.output.dir);
5271
5291
  }
5272
- if (preset === "netlify" ||
5273
- preset === "vercel" ||
5274
- isAwsLambdaPreset(preset) ||
5275
- isAwsAmplifyPreset(preset)) {
5276
- copyInstalledResvgPackages(nitro.options.output.serverDir);
5277
- copyInstalledFfmpegStaticPackage(nitro.options.output.serverDir);
5278
- copyInstalledBrowserRuntimePackages(nitro.options.output.serverDir);
5279
- copyInstalledExternalSsrPackages(nitro.options.output.serverDir);
5280
- sanitizeServerlessFunctionPackageManifest(nitro.options.output.serverDir);
5281
- pruneServerlessFunctionDeadWeight(nitro.options.output.serverDir);
5282
- }
5292
+ copyPresetRuntimePackages(preset, nitro.options.output.serverDir);
5283
5293
  if (preset === "vercel") {
5284
5294
  prepareVercelFunctionOutputs(nitro.options.output.dir, cwd);
5285
5295
  }
@@ -33,9 +33,9 @@ declare const _default: import("../../action.js").ActionDefinition<{
33
33
  idempotencyKey: string;
34
34
  deleted: boolean;
35
35
  } | {
36
- id?: undefined;
37
36
  error: string;
38
37
  url?: undefined;
38
+ id?: undefined;
39
39
  provider?: undefined;
40
40
  configured?: undefined;
41
41
  } | {
@@ -45,8 +45,8 @@ declare const _default: import("../../action.js").ActionDefinition<{
45
45
  provider: string;
46
46
  configured?: undefined;
47
47
  } | {
48
- id?: undefined;
49
48
  url?: undefined;
49
+ id?: undefined;
50
50
  provider?: undefined;
51
51
  error: string;
52
52
  configured: boolean;
@@ -1,17 +1,17 @@
1
1
  {
2
- "@agent-native/agentkit": "0.231.0",
2
+ "@agent-native/agentkit": "0.232.0-nightly-20261118152333",
3
3
  "@agent-native/code-agents-ui": "0.1.75",
4
- "@agent-native/core": "0.231.0",
5
- "@agent-native/core-corpus": "0.231.0",
4
+ "@agent-native/core": "0.232.0-nightly-20261118152333",
5
+ "@agent-native/core-corpus": "0.232.0-nightly-20261118152333",
6
6
  "@agent-native/creative-context": "0.8.75",
7
- "@agent-native/dispatch": "0.42.10",
7
+ "@agent-native/dispatch": "0.42.11-nightly-20261118152333",
8
8
  "@agent-native/embedding": "0.2.0",
9
9
  "@agent-native/migrate": "0.0.7",
10
10
  "@agent-native/otel": "0.1.42",
11
11
  "@agent-native/pinpoint": "0.1.118",
12
12
  "@agent-native/recap-cli": "0.5.106",
13
- "@agent-native/scheduling": "0.3.2",
13
+ "@agent-native/scheduling": "0.4.0-nightly-20261118152333",
14
14
  "@agent-native/shared-app-config": "0.1.2",
15
- "@agent-native/skills": "0.4.10",
16
- "@agent-native/toolkit": "0.231.0"
15
+ "@agent-native/skills": "0.4.11-nightly-20261118152333",
16
+ "@agent-native/toolkit": "0.232.0-nightly-20261118152333"
17
17
  }
@@ -6,7 +6,7 @@ export { scanEmptyMigrations } from "./no-empty-migrations.js";
6
6
  export { scanReleaseSchemaCoverage } from "./release-schema-complete.js";
7
7
  export type { EmptyMigrationsSourceOptions } from "./no-empty-migrations.js";
8
8
  export { analyzeEmptyMigrationsSource, shouldScanEmptyMigrationsFile, } from "./no-empty-migrations.js";
9
- export { scanEnvCredentials } from "./no-env-credentials.js";
9
+ export { parseTestEnvKeys, scanEnvCredentials, type EnvCredentialsScanOptions, } from "./no-env-credentials.js";
10
10
  export { scanEnvMutation } from "./no-env-mutation.js";
11
11
  export { scanIdentityColumnsRegistered } from "./identity-columns-registered.js";
12
12
  export { scanLocalhostFallback } from "./no-localhost-fallback.js";
@@ -4,7 +4,7 @@ export { scanDrizzlePush } from "./no-drizzle-push.js";
4
4
  export { scanEmptyMigrations } from "./no-empty-migrations.js";
5
5
  export { scanReleaseSchemaCoverage } from "./release-schema-complete.js";
6
6
  export { analyzeEmptyMigrationsSource, shouldScanEmptyMigrationsFile, } from "./no-empty-migrations.js";
7
- export { scanEnvCredentials } from "./no-env-credentials.js";
7
+ export { parseTestEnvKeys, scanEnvCredentials, } from "./no-env-credentials.js";
8
8
  export { scanEnvMutation } from "./no-env-mutation.js";
9
9
  export { scanIdentityColumnsRegistered } from "./identity-columns-registered.js";
10
10
  export { scanLocalhostFallback } from "./no-localhost-fallback.js";
@@ -32,4 +32,18 @@
32
32
  * process.env.SOMETHING // guard:allow-env-credential — short reason
33
33
  */
34
34
  import type { GuardResult, GuardScanOptions } from "./types.js";
35
- export declare function scanEnvCredentials(options: GuardScanOptions): GuardResult;
35
+ export interface EnvCredentialsScanOptions extends GuardScanOptions {
36
+ /**
37
+ * Non-secret configuration keys (a test target URL, an artifact directory)
38
+ * the app's tests may read: honored only in `tests/` and `*.spec.*` /
39
+ * `*.test.*` files. From agent-native.json `doctor.testEnvKeys`.
40
+ */
41
+ testEnvKeys?: readonly string[];
42
+ }
43
+ /**
44
+ * Validates `doctor.testEnvKeys`. Throws on anything but env key names, and on
45
+ * a credential-like name, so a bad entry fails the guard rather than reading
46
+ * as an empty list or widening it to a secret.
47
+ */
48
+ export declare function parseTestEnvKeys(value: unknown): string[];
49
+ export declare function scanEnvCredentials(options: EnvCredentialsScanOptions): GuardResult;