@agent-native/core 0.227.0-nightly-20261110032437 → 0.227.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/agent/default-agent-engine.d.ts +1 -0
  2. package/dist/agent/default-agent-engine.js +6 -3
  3. package/dist/agent/engine/builder-engine.js +10 -6
  4. package/dist/agent/engine/chat-model-availability.d.ts +9 -0
  5. package/dist/agent/engine/chat-model-availability.js +39 -0
  6. package/dist/agent/optional-placeholders.d.ts +1 -0
  7. package/dist/agent/optional-placeholders.js +3 -0
  8. package/dist/cli/create.js +0 -49
  9. package/dist/cli/index.js +1 -1
  10. package/dist/cli/react-router-command.js +13 -7
  11. package/dist/client/chat/agentkit-protocol.js +259 -200
  12. package/dist/client/chat/run-outcome.d.ts +48 -0
  13. package/dist/client/chat/run-outcome.js +50 -0
  14. package/dist/collab/routes.d.ts +1 -1
  15. package/dist/collab/struct-routes.d.ts +1 -1
  16. package/dist/deploy/build.d.ts +1 -0
  17. package/dist/deploy/build.js +30 -1
  18. package/dist/framework-package-versions.json +11 -11
  19. package/dist/jobs/run-now.js +9 -1
  20. package/dist/notifications/routes.d.ts +3 -3
  21. package/dist/org/index.d.ts +1 -1
  22. package/dist/org/migrations.d.ts +1 -1
  23. package/dist/provider-api/actions/provider-api.d.ts +1 -1
  24. package/dist/resources/handlers.d.ts +1 -1
  25. package/dist/scripts/agent-engines/list-agent-engines.js +9 -5
  26. package/dist/server/auth.d.ts +3 -1
  27. package/dist/server/auth.js +29 -9
  28. package/dist/server/builder-signup-experiment.d.ts +89 -42
  29. package/dist/server/builder-signup-experiment.js +36 -14
  30. package/dist/server/core-routes-plugin.js +5 -3
  31. package/dist/server/index.d.ts +2 -1
  32. package/dist/server/index.js +2 -1
  33. package/dist/server/onboarding-html.d.ts +2 -0
  34. package/dist/server/onboarding-html.js +9 -5
  35. package/dist/server/release-migrations.d.ts +3 -1
  36. package/dist/server/release-migrations.js +8 -6
  37. package/dist/shared/mcp-embed-headers.js +8 -2
  38. package/dist/templates/builder-code-starter/AGENTS.md.patch +1 -1
  39. package/dist/templates/builder-code-starter/server/plugins/auth.ts.patch +2 -1
  40. package/dist/templates/chat/AGENTS.md +1 -1
  41. package/dist/templates/chat/app/components/layout/Sidebar.tsx +1 -1
  42. package/dist/templates/chat/scripts/migrate-production.ts +1 -1
  43. package/dist/templates/chat/server/plugins/auth.ts +1 -0
  44. package/dist/templates/default/pnpm-workspace.yaml +0 -41
  45. package/dist/templates/default/scripts/migrate-production.ts +1 -1
  46. package/dist/templates/workspace-root/pnpm-workspace.yaml +0 -41
  47. package/dist/tracking/providers.js +20 -8
  48. package/dist/triggers/actions/list-automations.js +7 -1
  49. package/docs/content/agent-web-surfaces.mdx +54 -42
  50. package/docs/content/authentication.mdx +14 -0
  51. package/docs/content/client-agent-chat.mdx +2 -0
  52. package/docs/content/client-routing.mdx +2 -0
  53. package/docs/content/create-with-an-agent.mdx +1 -1
  54. package/docs/content/environment-variables.mdx +2 -0
  55. package/docs/content/extensions.mdx +8 -9
  56. package/docs/content/external-agents.mdx +8 -0
  57. package/docs/content/upgrading-core-ui.mdx +2 -0
  58. package/docs/content/vercel.mdx +2 -0
  59. package/package.json +4 -4
  60. package/src/templates/builder-code-starter/AGENTS.md.patch +1 -1
  61. package/src/templates/builder-code-starter/server/plugins/auth.ts.patch +2 -1
  62. package/src/templates/chat/AGENTS.md +1 -1
  63. package/src/templates/chat/app/components/layout/Sidebar.tsx +1 -1
  64. package/src/templates/chat/scripts/migrate-production.ts +1 -1
  65. package/src/templates/chat/server/plugins/auth.ts +1 -0
  66. package/src/templates/default/pnpm-workspace.yaml +0 -41
  67. package/src/templates/default/scripts/migrate-production.ts +1 -1
  68. package/src/templates/workspace-root/pnpm-workspace.yaml +0 -41
@@ -51,6 +51,7 @@ export interface DefaultAgentEngineSelection {
51
51
  engine: string;
52
52
  model: string;
53
53
  }
54
+ export declare function isDefaultAgentEngineScopeResolved(ctx?: DefaultAgentEngineContext): boolean;
54
55
  /**
55
56
  * Read the default that applies to `ctx` (the current request when omitted):
56
57
  * the organization's row, else an explicitly personal user's own row, else
@@ -36,6 +36,11 @@ function normalizedContext(ctx) {
36
36
  function hasEngine(value) {
37
37
  return typeof value.engine === "string" && value.engine.trim().length > 0;
38
38
  }
39
+ export function isDefaultAgentEngineScopeResolved(ctx = requestContext()) {
40
+ return !!(normalizedContext(ctx).orgId ||
41
+ ctx.orgScope === "personal" ||
42
+ ctx.defaultAgentEngineScope === "deployment");
43
+ }
39
44
  /**
40
45
  * Read the default that applies to `ctx` (the current request when omitted):
41
46
  * the organization's row, else an explicitly personal user's own row, else
@@ -47,9 +52,7 @@ function hasEngine(value) {
47
52
  */
48
53
  export async function readDefaultAgentEngineSettingDetailed(ctx = requestContext()) {
49
54
  const { userEmail, orgId } = normalizedContext(ctx);
50
- if (!orgId &&
51
- ctx.orgScope !== "personal" &&
52
- ctx.defaultAgentEngineScope !== "deployment") {
55
+ if (!isDefaultAgentEngineScopeResolved(ctx)) {
53
56
  throw new Error("Organization scope could not be resolved.");
54
57
  }
55
58
  if (orgId) {
@@ -803,22 +803,26 @@ async function* parseJsonlStream(reader, model, captureContext = {}) {
803
803
  const errMsg = event.error ||
804
804
  event.message ||
805
805
  "Builder gateway rejected the request as malformed.";
806
- const rawErrCode = typeof event.errorCode === "string"
806
+ const gatewayErrCode = typeof event.errorCode === "string"
807
807
  ? event.errorCode
808
808
  : typeof event.code === "string"
809
809
  ? event.code
810
- : "invalid_request";
811
- const errCode = canonicalizeBuilderGatewayErrorCode(rawErrCode, String(errMsg)) ??
812
- rawErrCode;
810
+ : undefined;
811
+ const errCode = canonicalizeBuilderGatewayErrorCode(gatewayErrCode, String(errMsg)) ??
812
+ gatewayErrCode ??
813
+ "invalid_request";
813
814
  const gatewayRequestId = typeof event.requestId === "string" ? event.requestId : undefined;
814
- console.warn(`[builder-engine] stop reason=invalid_request model=${model} code=${errCode} requestId=${gatewayRequestId ?? "(none)"} providerMessagePresent=${Boolean(event.error || event.message || event.detail)}`);
815
+ console.warn(`[builder-engine] stop reason=invalid_request model=${model} code=${errCode} requestId=${gatewayRequestId ?? "(none)"} requestShape=${JSON.stringify(captureContext.requestShape)} providerMessagePresent=${Boolean(event.error || event.message || event.detail)}`);
815
816
  if (isExplicitBuilderCreditsLimitCode(errCode)) {
816
817
  await notifyBuilderCreditLimit();
817
818
  }
818
819
  yield stop({
819
820
  error: errMsg,
820
821
  errorCode: errCode,
821
- providerRetryable: errCode === BUILDER_GATEWAY_INTERNAL_ERROR_CODE,
822
+ // Without a gateway code the masked envelope does not say the fault
823
+ // was transient, and the rejected request would be sent unchanged.
824
+ providerRetryable: gatewayErrCode !== undefined &&
825
+ errCode === BUILDER_GATEWAY_INTERNAL_ERROR_CODE,
822
826
  ...(isCreditsLimitErrorCode(errCode)
823
827
  ? { upgradeUrl: await buildUpgradeUrl() }
824
828
  : {}),
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Whether the current request's user can run a chat model: Builder, a provider
3
+ * key of their own, or a deployment key. A connected Builder account counts
4
+ * even when its credits are spent: that is a top-up problem, not a missing
5
+ * model. "unknown" means the engine or its credential could not be resolved,
6
+ * which is not the same as having none.
7
+ */
8
+ export type ChatModelAvailability = "available" | "unavailable" | "unknown";
9
+ export declare function resolveChatModelAvailability(): Promise<ChatModelAvailability>;
@@ -0,0 +1,39 @@
1
+ import { getAppConfig } from "../../app-config/index.js";
2
+ import { readDeployCredentialEnv } from "../../server/credential-provider.js";
3
+ import { getRequestOrgId, getRequestUserEmail, } from "../../server/request-context.js";
4
+ import { resolveChatEngine, resolveOwnerEngineApiKey, } from "../production-agent.js";
5
+ import { isResolvedEngineUsableForRequest, registerBuiltinEngines, } from "./index.js";
6
+ export async function resolveChatModelAvailability() {
7
+ // Credentials and the default-engine setting are both read in the request's
8
+ // scope, so only the request user can be checked; with none, there is no one
9
+ // whose model to look up, which is "unknown", never "unavailable".
10
+ const userEmail = getRequestUserEmail();
11
+ if (!userEmail)
12
+ return "unknown";
13
+ const orgId = getRequestOrgId() ?? null;
14
+ try {
15
+ registerBuiltinEngines();
16
+ const credentialIdentity = { userEmail, orgId };
17
+ const anthropicFallback = readDeployCredentialEnv("ANTHROPIC_API_KEY");
18
+ const ownerKey = await resolveOwnerEngineApiKey({
19
+ ownerEmail: userEmail,
20
+ ...(anthropicFallback ? { anthropicFallback } : {}),
21
+ });
22
+ const appId = getAppConfig().app.id ?? getAppConfig().app.template;
23
+ const engine = await resolveChatEngine({
24
+ ownerKey,
25
+ ...(appId ? { appId } : {}),
26
+ credentialIdentity,
27
+ });
28
+ return (await isResolvedEngineUsableForRequest(engine, {
29
+ ...(ownerKey.apiKey ? { apiKey: ownerKey.apiKey } : {}),
30
+ credentialIdentity,
31
+ }))
32
+ ? "available"
33
+ : "unavailable";
34
+ }
35
+ catch (error) {
36
+ console.warn("[chat-model-availability] could not resolve the chat engine:", error instanceof Error ? error.message : error);
37
+ return "unknown";
38
+ }
39
+ }
@@ -10,6 +10,7 @@ export declare function schemaAcceptsToolValue(schema: object, value: unknown):
10
10
  export declare function discriminatedBranchIndex(branches: readonly AgentNativeJsonSchema[], value: unknown): number;
11
11
  export declare class AmbiguousToolPlaceholdersError extends Error {
12
12
  readonly errorCode = "ambiguous_tool_placeholders";
13
+ readonly statusCode = 400;
13
14
  constructor();
14
15
  }
15
16
  export declare function normalizeOptionalToolPlaceholders(schema: RawJsonSchema | undefined, input: unknown, entry: Parameters<typeof actionCallReadOnly>[0] & {
@@ -167,6 +167,9 @@ function stripOptionalToolPlaceholders(schema, value, emptyValues, depth = 0) {
167
167
  }
168
168
  export class AmbiguousToolPlaceholdersError extends Error {
169
169
  errorCode = "ambiguous_tool_placeholders";
170
+ // A refusal of the caller's input that ran nothing, so the HTTP action
171
+ // route answers 400 with this message rather than a captured 500.
172
+ statusCode = 400;
170
173
  constructor() {
171
174
  super("Tool input mixes invalid placeholders with valid empty values, so it is unclear which fields should be cleared. " +
172
175
  "No action was run. Retry the native tool with sparse JSON containing only the intended changes. " +
@@ -34,49 +34,6 @@ const STANDALONE_EXACT_DEPENDENCY_OVERRIDES = {
34
34
  "@react-router/fs-routes": "8.1.0",
35
35
  "react-router": "8.1.0",
36
36
  };
37
- const TIPTAP_WORKSPACE_OVERRIDES = {
38
- '"@tiptap/core"': '"3.28.0"',
39
- '"@tiptap/extension-blockquote"': '"3.28.0"',
40
- '"@tiptap/extension-bold"': '"3.28.0"',
41
- '"@tiptap/extension-bubble-menu"': '"3.28.0"',
42
- '"@tiptap/extension-bullet-list"': '"3.28.0"',
43
- '"@tiptap/extension-code"': '"3.28.0"',
44
- '"@tiptap/extension-code-block"': '"3.28.0"',
45
- '"@tiptap/extension-code-block-lowlight"': '"3.28.0"',
46
- '"@tiptap/extension-collaboration"': '"3.28.0"',
47
- '"@tiptap/extension-collaboration-caret"': '"3.28.0"',
48
- '"@tiptap/extension-color"': '"3.28.0"',
49
- '"@tiptap/extension-document"': '"3.28.0"',
50
- '"@tiptap/extension-dropcursor"': '"3.28.0"',
51
- '"@tiptap/extension-floating-menu"': '"3.28.0"',
52
- '"@tiptap/extension-gapcursor"': '"3.28.0"',
53
- '"@tiptap/extension-hard-break"': '"3.28.0"',
54
- '"@tiptap/extension-heading"': '"3.28.0"',
55
- '"@tiptap/extension-horizontal-rule"': '"3.28.0"',
56
- '"@tiptap/extension-image"': '"3.28.0"',
57
- '"@tiptap/extension-italic"': '"3.28.0"',
58
- '"@tiptap/extension-link"': '"3.28.0"',
59
- '"@tiptap/extension-list"': '"3.28.0"',
60
- '"@tiptap/extension-list-item"': '"3.28.0"',
61
- '"@tiptap/extension-list-keymap"': '"3.28.0"',
62
- '"@tiptap/extension-ordered-list"': '"3.28.0"',
63
- '"@tiptap/extension-paragraph"': '"3.28.0"',
64
- '"@tiptap/extension-placeholder"': '"3.28.0"',
65
- '"@tiptap/extension-strike"': '"3.28.0"',
66
- '"@tiptap/extension-table"': '"3.28.0"',
67
- '"@tiptap/extension-table-cell"': '"3.28.0"',
68
- '"@tiptap/extension-table-header"': '"3.28.0"',
69
- '"@tiptap/extension-table-row"': '"3.28.0"',
70
- '"@tiptap/extension-task-item"': '"3.28.0"',
71
- '"@tiptap/extension-task-list"': '"3.28.0"',
72
- '"@tiptap/extension-text"': '"3.28.0"',
73
- '"@tiptap/extension-text-style"': '"3.28.0"',
74
- '"@tiptap/extension-underline"': '"3.28.0"',
75
- '"@tiptap/extensions"': '"3.28.0"',
76
- '"@tiptap/pm"': '"3.28.0"',
77
- '"@tiptap/react"': '"3.28.0"',
78
- '"@tiptap/starter-kit"': '"3.28.0"',
79
- };
80
37
  const REACT_ROUTER_BUILD_DEPENDENCIES = [
81
38
  "@react-router/dev",
82
39
  "@react-router/fs-routes",
@@ -1749,12 +1706,6 @@ function postProcessStandalone(name, targetDir, templateName, resolution) {
1749
1706
  nf3: '"0.3.17"',
1750
1707
  };
1751
1708
  }
1752
- if (templateName && getTemplate(firstPartyBaseTemplate(templateName))) {
1753
- sections.overrides = {
1754
- ...sections.overrides,
1755
- ...TIPTAP_WORKSPACE_OVERRIDES,
1756
- };
1757
- }
1758
1709
  const localFrameworkOverrides = getLocalFrameworkPackageOverrides();
1759
1710
  if (Object.keys(localFrameworkOverrides).length > 0) {
1760
1711
  sections.overrides ??= {};
package/dist/cli/index.js CHANGED
@@ -1098,7 +1098,7 @@ Options:
1098
1098
  --eager With workspace dev, start every app immediately
1099
1099
  --prewarm With workspace dev, warm non-default apps in the background
1100
1100
  --no-prewarm With workspace dev, keep non-default apps lazy
1101
- --no-open With workspace dev, do not open a browser
1101
+ --no-open With dev or workspace dev, do not open a browser
1102
1102
  --url <url> URL to audit with audit-agent-web
1103
1103
 
1104
1104
  Feedback: ${FEEDBACK_URL}
@@ -16,8 +16,8 @@ export function findBinUpwards(binName, cwd = process.cwd()) {
16
16
  }
17
17
  export function findReactRouterInvocation(args, cwd = process.cwd()) {
18
18
  const shim = findBinUpwards("react-router", cwd);
19
- if (shim) {
20
- return { command: shim, args, shell: process.platform === "win32" };
19
+ if (shim && process.platform !== "win32") {
20
+ return { command: shim, args, shell: false };
21
21
  }
22
22
  const require = createRequire(path.join(cwd, "package.json"));
23
23
  let pkgJsonPath;
@@ -28,11 +28,17 @@ export function findReactRouterInvocation(args, cwd = process.cwd()) {
28
28
  if (error.code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") {
29
29
  throw error;
30
30
  }
31
- return {
32
- command: "react-router",
33
- args,
34
- shell: process.platform === "win32",
35
- };
31
+ const localPackageJson = shim
32
+ ? path.join(path.dirname(path.dirname(shim)), "@react-router/dev/package.json")
33
+ : undefined;
34
+ if (!localPackageJson || !fs.existsSync(localPackageJson)) {
35
+ return {
36
+ command: "react-router",
37
+ args,
38
+ shell: process.platform === "win32",
39
+ };
40
+ }
41
+ pkgJsonPath = localPackageJson;
36
42
  }
37
43
  const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
38
44
  const rel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.["react-router"];