@agent-native/core 0.84.57 → 0.84.58

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 (69) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +8 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/action.ts +11 -0
  5. package/corpus/core/src/agent/production-agent.ts +24 -46
  6. package/corpus/core/src/client/AssistantChat.tsx +69 -12
  7. package/corpus/core/src/client/MultiTabAssistantChat.tsx +1 -1
  8. package/corpus/core/src/client/conversation/use-near-bottom-autoscroll.ts +45 -2
  9. package/corpus/core/src/coding-tools/run-code.ts +1 -0
  10. package/corpus/core/src/integrations/webhook-handler.ts +10 -9
  11. package/corpus/core/src/server/action-discovery.ts +3 -0
  12. package/corpus/core/src/server/credential-provider.ts +11 -6
  13. package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +29 -0
  14. package/corpus/templates/analytics/server/plugins/agent-chat.ts +9 -1
  15. package/corpus/templates/design/actions/list-design-extensions.ts +2 -2
  16. package/corpus/templates/design/app/components/design/CodeWorkbenchHost.tsx +11 -89
  17. package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +314 -181
  18. package/corpus/templates/design/app/components/design/DesignImportPanel.tsx +92 -134
  19. package/corpus/templates/design/app/components/design/EditPanel.tsx +93 -19
  20. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +18 -26
  21. package/corpus/templates/design/app/components/design/TokensPanel.tsx +220 -192
  22. package/corpus/templates/design/app/components/design/code-workbench-theme.ts +150 -0
  23. package/corpus/templates/design/app/i18n/zh-TW.ts +5 -7
  24. package/corpus/templates/design/app/i18n-data.ts +61 -77
  25. package/corpus/templates/design/app/lib/design-import.ts +4 -1
  26. package/corpus/templates/design/app/pages/DesignEditor.tsx +97 -48
  27. package/corpus/templates/design/changelog/2026-07-02-design-inspector-and-canvas-controls-stay-consistent-when-se.md +6 -0
  28. package/corpus/templates/design/changelog/2026-07-02-fixed-a-crash-when-opening-the-code-editor.md +6 -0
  29. package/corpus/templates/design/changelog/2026-07-02-fixed-motion-drawer-open-transition.md +6 -0
  30. package/corpus/templates/design/changelog/2026-07-02-improved-design-assets-panel.md +6 -0
  31. package/dist/action.d.ts +8 -0
  32. package/dist/action.d.ts.map +1 -1
  33. package/dist/action.js +3 -0
  34. package/dist/action.js.map +1 -1
  35. package/dist/agent/production-agent.d.ts +10 -11
  36. package/dist/agent/production-agent.d.ts.map +1 -1
  37. package/dist/agent/production-agent.js +21 -44
  38. package/dist/agent/production-agent.js.map +1 -1
  39. package/dist/client/AssistantChat.d.ts +1 -0
  40. package/dist/client/AssistantChat.d.ts.map +1 -1
  41. package/dist/client/AssistantChat.js +61 -11
  42. package/dist/client/AssistantChat.js.map +1 -1
  43. package/dist/client/MultiTabAssistantChat.js +1 -1
  44. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  45. package/dist/client/conversation/use-near-bottom-autoscroll.d.ts.map +1 -1
  46. package/dist/client/conversation/use-near-bottom-autoscroll.js +43 -2
  47. package/dist/client/conversation/use-near-bottom-autoscroll.js.map +1 -1
  48. package/dist/coding-tools/run-code.d.ts.map +1 -1
  49. package/dist/coding-tools/run-code.js +1 -0
  50. package/dist/coding-tools/run-code.js.map +1 -1
  51. package/dist/collab/awareness.d.ts +2 -2
  52. package/dist/collab/awareness.d.ts.map +1 -1
  53. package/dist/collab/routes.d.ts +1 -1
  54. package/dist/file-upload/actions/upload-image.d.ts +2 -2
  55. package/dist/integrations/webhook-handler.d.ts +1 -0
  56. package/dist/integrations/webhook-handler.d.ts.map +1 -1
  57. package/dist/integrations/webhook-handler.js +9 -9
  58. package/dist/integrations/webhook-handler.js.map +1 -1
  59. package/dist/notifications/routes.d.ts +3 -3
  60. package/dist/observability/routes.d.ts +5 -5
  61. package/dist/server/action-discovery.d.ts.map +1 -1
  62. package/dist/server/action-discovery.js +3 -0
  63. package/dist/server/action-discovery.js.map +1 -1
  64. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  65. package/dist/server/credential-provider.d.ts +4 -0
  66. package/dist/server/credential-provider.d.ts.map +1 -1
  67. package/dist/server/credential-provider.js +13 -7
  68. package/dist/server/credential-provider.js.map +1 -1
  69. package/package.json +1 -1
@@ -11,7 +11,7 @@ import { isMcpActionResult } from "../mcp-client/app-result.js";
11
11
  import { isMcpToolAllowedForRequest } from "../mcp-client/visibility.js";
12
12
  import { completeRun as completeProgressRun, startRun as startProgressRun, updateRunProgress, } from "../progress/registry.js";
13
13
  import { getFrontmatterValue, parseFrontmatter, } from "../resources/metadata.js";
14
- import { isDeployCredentialFallbackAllowed, readDeployCredentialEnv, } from "../server/credential-provider.js";
14
+ import { canUseDeployCredentialFallbackForRequest, readDeployCredentialEnv, } from "../server/credential-provider.js";
15
15
  import { readBody } from "../server/h3-helpers.js";
16
16
  import { getRequestRunContext, ensureRequestRunContext, getRequestContext, getRequestOrgId, getRequestUserEmail, runWithRequestContext, } from "../server/request-context.js";
17
17
  import { fireInternalDispatch } from "../server/self-dispatch.js";
@@ -279,31 +279,16 @@ export async function getOwnerApiKey(provider, ownerEmail) {
279
279
  export function engineToProvider(engineName) {
280
280
  return engineName.startsWith("ai-sdk:") ? engineName.slice(7) : engineName;
281
281
  }
282
- /**
283
- * Returns true when this process should block generic deploy-level provider
284
- * credentials for signed-in chat requests.
285
- *
286
- * Self-hosted single-tenant deployments keep the env-var fallback so the
287
- * original BYO-server UX continues to work without a per-user key.
288
- */
289
- function shouldBlockDeployCredentialFallback() {
290
- return !isDeployCredentialFallbackAllowed();
291
- }
292
282
  /**
293
283
  * Resolve the active engine's provider and look up the user's API key for it.
294
284
  *
295
- * In shared hosted deploys we deliberately refuse the deploy-level fallback
296
- * for authenticated users. Without that gate any
297
- * signed-in user who hasn't configured their own provider key would silently
298
- * inherit the deployment's key (uncapped billing on the owner's account,
299
- * prompt logging tied to the deployment owner) — exactly the prior-incident
300
- * pattern we hit on 2026-04-29.
301
- *
302
- * Single-tenant (local-dev, self-hosted SQLite) keeps the env fallback.
285
+ * If the owner has no scoped key, fall back to provider keys supplied by the
286
+ * hosting environment only when the current request can safely use deploy-level
287
+ * credentials. This is a read from process-level config, not a request-scoped
288
+ * write to `process.env`.
303
289
  *
304
- * Callers in `agent-chat-plugin.ts`, `triggers/dispatcher.ts`,
305
- * `jobs/scheduler.ts`, and `integrations/plugin.ts` historically layer
306
- * another deployment-key fallback after this must keep the same gate.
290
+ * Callers that layer another deployment-key fallback after this should keep the
291
+ * same precedence: scoped key first, host-provided env key second.
307
292
  */
308
293
  export async function getOwnerActiveApiKey(ownerEmail) {
309
294
  try {
@@ -314,14 +299,8 @@ export async function getOwnerActiveApiKey(ownerEmail) {
314
299
  const userKey = await getOwnerApiKey(provider, ownerEmail);
315
300
  if (userKey)
316
301
  return userKey;
317
- if (shouldBlockDeployCredentialFallback()) {
318
- // Shared hosted default: refuse the env fallback. A null user
319
- // (unauthenticated / background context with no owner) gets undefined
320
- // here too — there's no user to bill, and the call site must surface a
321
- // "configure a key" error to the requester rather than silently using
322
- // the deploy key.
302
+ if (!canUseDeployCredentialFallbackForRequest())
323
303
  return undefined;
324
- }
325
304
  const envVar = PROVIDER_TO_ENV[provider];
326
305
  return envVar ? readDeployCredentialEnv(envVar) : undefined;
327
306
  }
@@ -417,6 +396,8 @@ function planModeBlockedMessage(toolName, reason) {
417
396
  ". Switch to Act mode after the user approves the plan, then retry the action.");
418
397
  }
419
398
  export function isPlanModeToolCallAllowed(name, input, entry) {
399
+ if (entry.allowInPlanMode === false)
400
+ return false;
420
401
  if (PLAN_MODE_BLOCKED_READONLY_TOOLS.has(name))
421
402
  return false;
422
403
  if (name === "web-request") {
@@ -498,6 +479,8 @@ export function createPlanModeActionRegistry(actions) {
498
479
  for (const [name, entry] of Object.entries(actions)) {
499
480
  if (name === TOOL_SEARCH_ACTION_NAME)
500
481
  continue;
482
+ if (entry.allowInPlanMode === false)
483
+ continue;
501
484
  if (PLAN_MODE_BLOCKED_READONLY_TOOLS.has(name))
502
485
  continue;
503
486
  const allowedActions = PLAN_MODE_ALLOWED_ACTIONS[name];
@@ -3625,15 +3608,13 @@ export function createProductionAgentHandler(options) {
3625
3608
  // for that provider instead of the global active engine's provider.
3626
3609
  // DIAGNOSTIC-ONLY: bracket per-owner API-key resolution (settings/app_secrets reads).
3627
3610
  workerStep("apikey_start");
3611
+ const allowDeployCredentialFallback = canUseDeployCredentialFallbackForRequest();
3628
3612
  let userApiKey;
3629
3613
  if (requestEngine) {
3630
3614
  const provider = engineToProvider(requestEngine);
3631
3615
  userApiKey = await getOwnerApiKey(provider, ownerEmail);
3632
- if (!userApiKey && !shouldBlockDeployCredentialFallback()) {
3633
- // Single-tenant only: env fallback for the requested provider. Shared
3634
- // hosted deploys never silently substitute the deploy-level key for
3635
- // an authenticated user (see getOwnerActiveApiKey for the full
3636
- // rationale).
3616
+ if (!userApiKey && allowDeployCredentialFallback) {
3617
+ // Read-only env fallback for the requested provider.
3637
3618
  const envVar = PROVIDER_TO_ENV[provider];
3638
3619
  userApiKey = envVar ? readDeployCredentialEnv(envVar) : undefined;
3639
3620
  }
@@ -3644,16 +3625,12 @@ export function createProductionAgentHandler(options) {
3644
3625
  // DIAGNOSTIC-ONLY: API-key resolution finished.
3645
3626
  workerStep("apikey_done");
3646
3627
  // `options.apiKey` is the value the template constructed the plugin with
3647
- // (e.g. wired from a deployment env var). On a shared hosted deploy this
3648
- // is the same cross-tenant hazard as any deploy-level provider key:
3649
- // accepting it as the final fallback would silently bill every key-less
3650
- // user to the deployment's account. Honour it only when the generic
3651
- // deploy fallback policy allows it.
3652
- const effectiveApiKey = shouldBlockDeployCredentialFallback()
3653
- ? userApiKey
3654
- : (userApiKey ??
3655
- options.apiKey ??
3656
- readDeployCredentialEnv("ANTHROPIC_API_KEY"));
3628
+ // (often wired from a deployment env var). Honor it as host-provided
3629
+ // read-only configuration after scoped keys when deploy fallback is safe.
3630
+ const hostApiKey = allowDeployCredentialFallback
3631
+ ? (options.apiKey ?? readDeployCredentialEnv("ANTHROPIC_API_KEY"))
3632
+ : undefined;
3633
+ const effectiveApiKey = userApiKey ?? hostApiKey;
3657
3634
  // Resolve engine — per-request engine override takes priority
3658
3635
  // DIAGNOSTIC-ONLY: bracket engine resolution (Builder credential / app-default
3659
3636
  // settings reads inside resolveEngine).