@agent-native/core 0.173.2-nightly-20260825163448 → 0.174.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 (73) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/factory/AGENTS.md +1 -1
  3. package/corpus/templates/factory/actions/babysit-agent-native-pull-request.ts +23 -8
  4. package/corpus/templates/factory/actions/delete-factory.ts +174 -0
  5. package/corpus/templates/factory/actions/govern-agent-native-pull-request.ts +28 -20
  6. package/corpus/templates/factory/actions/poll-github-sources.ts +6 -0
  7. package/corpus/templates/factory/actions/poll-sentry-errors.ts +16 -1
  8. package/corpus/templates/factory/actions/poll-slack-channel.ts +12 -0
  9. package/corpus/templates/factory/actions/start-builder-for-item.ts +74 -42
  10. package/corpus/templates/factory/app/components/factory/FactorySettingsView.tsx +117 -1
  11. package/corpus/templates/factory/app/i18n/en-US.ts +12 -0
  12. package/corpus/templates/factory/app/routes/factory.tsx +6 -1
  13. package/corpus/templates/factory/changelog/2026-08-24-slack-polling-accepts-the-agentnative-bot-handle.md +6 -0
  14. package/corpus/templates/factory/changelog/2026-08-24-you-can-delete-a-user-created-factory-from-settings.md +6 -0
  15. package/corpus/templates/factory/server/lib/factory-automation-repair.ts +6 -0
  16. package/corpus/templates/factory/server/lib/factory-scope.ts +45 -1
  17. package/corpus/templates/factory/server/lib/require-factory-automation.ts +5 -0
  18. package/corpus/templates/factory/server/triage/slack-client.ts +10 -2
  19. package/corpus/templates/plan/server/plugins/core-routes.ts +6 -1
  20. package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +4 -1
  21. package/corpus/templates/slides/app/components/editor/canvas-interactions/slides-canvas-adapter.ts +4 -2
  22. package/dist/app-config/app-identity.d.ts +20 -0
  23. package/dist/app-config/app-identity.js +41 -0
  24. package/dist/app-config/app.d.ts +2 -0
  25. package/dist/app-config/app.js +14 -0
  26. package/dist/app-config/observability.d.ts +27 -0
  27. package/dist/app-config/observability.js +76 -0
  28. package/dist/app-config/schema.d.ts +13 -0
  29. package/dist/app-config/schema.js +2 -0
  30. package/dist/app-config/store.d.ts +14 -4
  31. package/dist/app-config/store.js +18 -3
  32. package/dist/collab/awareness.d.ts +2 -2
  33. package/dist/collab/routes.d.ts +1 -1
  34. package/dist/email-catalog/actions/list-email-log.js +2 -2
  35. package/dist/email-catalog/actions/list-transactional-emails.js +2 -2
  36. package/dist/email-catalog/registry.js +3 -3
  37. package/dist/mcp/connect-route.js +15 -2
  38. package/dist/notifications/routes.d.ts +3 -3
  39. package/dist/observability/index.d.ts +1 -2
  40. package/dist/observability/index.js +0 -1
  41. package/dist/observability/posthog-ai.js +11 -3
  42. package/dist/observability/sentiment.d.ts +0 -1
  43. package/dist/observability/sentiment.js +8 -5
  44. package/dist/observability/traces.js +6 -12
  45. package/dist/observability/types.d.ts +0 -7
  46. package/dist/observability/types.js +1 -12
  47. package/dist/progress/routes.d.ts +1 -1
  48. package/dist/provider-api/actions/custom-provider-registration.d.ts +4 -4
  49. package/dist/provider-api/actions/provider-api.d.ts +8 -8
  50. package/dist/resources/handlers.d.ts +1 -1
  51. package/dist/secrets/routes.d.ts +3 -3
  52. package/dist/server/agent-chat/plugin-options.d.ts +17 -1
  53. package/dist/server/agent-chat-plugin.d.ts +10 -0
  54. package/dist/server/agent-chat-plugin.js +75 -67
  55. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  56. package/dist/server/core-routes/mcp-connect-options.d.ts +70 -0
  57. package/dist/server/core-routes/mcp-connect-options.js +77 -0
  58. package/dist/server/core-routes-plugin.d.ts +15 -11
  59. package/dist/server/core-routes-plugin.js +8 -7
  60. package/dist/server/edge.d.ts +1 -0
  61. package/dist/server/email-template.js +2 -2
  62. package/dist/server/email-templates.js +7 -7
  63. package/dist/server/email.js +4 -4
  64. package/dist/server/google-oauth.js +2 -2
  65. package/dist/server/http-response-telemetry.js +4 -4
  66. package/dist/server/identity-sso.js +1 -2
  67. package/dist/server/index.d.ts +1 -0
  68. package/dist/server/realtime-token.d.ts +1 -1
  69. package/dist/server/social-og-image.js +2 -2
  70. package/docs/content/observability.mdx +25 -31
  71. package/package.json +3 -3
  72. package/dist/server/app-name.d.ts +0 -33
  73. package/dist/server/app-name.js +0 -82
@@ -1,10 +1,10 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { getHeader, getMethod, getResponseStatus, setResponseHeader, setServerTiming, } from "h3";
3
+ import { getAppConfig } from "../app-config/index.js";
3
4
  import { claimStartupDatabaseTelemetry, createDatabaseRequestTelemetry, enterDatabaseRequestTelemetry, } from "../db/request-telemetry.js";
4
5
  import { getDatabaseRuntimeFingerprint } from "../db/runtime-diagnostics.js";
5
6
  import { isMcpPublicPath } from "../mcp/route-paths.js";
6
7
  import { track } from "../tracking/index.js";
7
- import { getAppName } from "./app-name.js";
8
8
  const TELEMETRY_EVENT_NAME = "http.response";
9
9
  const REQUEST_ID_HEADER = "x-agent-native-request-id";
10
10
  // Provider delivery posts back to these collectors. Recording the collector
@@ -182,8 +182,8 @@ function emitTelemetry(event, state, response) {
182
182
  const db = getDatabaseRuntimeFingerprint();
183
183
  track(TELEMETRY_EVENT_NAME, {
184
184
  source: "server",
185
- app: getAppName(),
186
- template: envValue("AGENT_NATIVE_TEMPLATE") ?? getAppName(),
185
+ app: getAppConfig().app.name,
186
+ template: envValue("AGENT_NATIVE_TEMPLATE") ?? getAppConfig().app.name,
187
187
  organization: organizationForHost(host),
188
188
  method: getMethod(event),
189
189
  path: normalizeHttpTelemetryPath(pathname),
@@ -330,7 +330,7 @@ function logSlowRequest(event, state, response, durationMs, pathname) {
330
330
  return;
331
331
  console.log(JSON.stringify({
332
332
  event: SLOW_REQUEST_LOG_EVENT,
333
- app: getAppName(),
333
+ app: getAppConfig().app.name,
334
334
  method: getMethod(event),
335
335
  path: normalizeHttpTelemetryPath(pathname),
336
336
  status: responseStatusCode(event, response),
@@ -18,7 +18,6 @@ import * as jose from "jose";
18
18
  import { getAppConfig } from "../app-config/index.js";
19
19
  import { GOOGLE_AUTH_REQUIRED_MESSAGE, isGoogleSignInRequiredForEmail, } from "../org/auth-policy.js";
20
20
  import { SIGN_IN_ENTRY_PATH } from "../shared/sign-in-journey.js";
21
- import { getAppName } from "./app-name.js";
22
21
  import { addSignupAttributionHeader, signupAttributionContextFromCookieHeader, } from "./attribution.js";
23
22
  import { getSession, isExpectedAuthFailure, safeReturnPath } from "./auth.js";
24
23
  import { getBetterAuth, getBetterAuthInternalAdapter, } from "./better-auth-instance.js";
@@ -108,7 +107,7 @@ function resolveAppId(event) {
108
107
  const configured = app.id ?? app.workspaceId;
109
108
  if (configured)
110
109
  return configured;
111
- const name = getAppName();
110
+ const name = getAppConfig().app.name;
112
111
  if (name && name !== "app")
113
112
  return name;
114
113
  try {
@@ -41,6 +41,7 @@ export { configureAgentNativeEmbeddedEnvironment, createAgentNativeEmbeddedAuthO
41
41
  export { createThread, getThread, listThreads, updateThreadData, deleteThread, setThreadArchived, setThreadPinned, setThreadScope, type ChatThread, type ChatThreadScope, type ChatThreadSummary, type ListThreadsOptions, } from "../chat-threads/store.js";
42
42
  export { createResourcesPlugin, defaultResourcesPlugin, } from "./resources-plugin.js";
43
43
  export { createCoreRoutesPlugin, defaultCoreRoutesPlugin, FRAMEWORK_ROUTE_PREFIX, type CoreRoutesPluginOptions, } from "./core-routes-plugin.js";
44
+ export type { CoreRoutesMcpOptions } from "./core-routes/mcp-connect-options.js";
44
45
  export { buildRuntimeConfigPrompt, formatRuntimeConfigReport, getRuntimeConfigReport, parseRuntimeConfigReport, runtimeConfigRequirementsFromSearchParams, type RuntimeConfigEnvironment, type RuntimeConfigIssue, type RuntimeConfigIssueCode, type RuntimeConfigIssueSeverity, type RuntimeConfigPhase, type RuntimeConfigReport, type RuntimeConfigRequirements, } from "../shared/runtime-config.js";
45
46
  export { AGENT_NATIVE_OG_IMAGE_CACHE_CONTROL, AGENT_NATIVE_OG_IMAGE_HEIGHT, AGENT_NATIVE_OG_IMAGE_NETLIFY_CACHE_CONTROL, AGENT_NATIVE_OG_IMAGE_WIDTH, agentNativeOgImageResponseHeaders, createAgentNativeOgImageHandler, renderAgentNativeOgImagePng, renderAgentNativeOgImageSvg, type AgentNativeOgImageInput, } from "./social-og-image.js";
46
47
  export { OG_FONT_FAMILY, resolveOgFontFiles } from "./og-fonts.js";
@@ -26,8 +26,8 @@ export declare function createRealtimeTokenHandler(): import("h3").EventHandlerW
26
26
  expiresAt?: undefined;
27
27
  ttlSeconds?: undefined;
28
28
  } | {
29
+ error?: undefined;
29
30
  token: string;
30
31
  expiresAt: string;
31
32
  ttlSeconds: number;
32
- error?: undefined;
33
33
  }>>;
@@ -1,5 +1,5 @@
1
1
  import { defineEventHandler, getHeader, getMethod, getQuery, getRequestURL, } from "h3";
2
- import { getAppName } from "./app-name.js";
2
+ import { getAppConfig } from "../app-config/index.js";
3
3
  import { resolveBuiltInAuthMarketing, resolveBuiltInAuthMarketingByName, } from "./auth-marketing.js";
4
4
  import { OG_ARABIC_FONT_FAMILY, OG_FONT_FAMILY, resolveOgFontFiles, } from "./og-fonts.js";
5
5
  export const AGENT_NATIVE_OG_IMAGE_WIDTH = 1200;
@@ -174,7 +174,7 @@ export function resolveAgentNativeOgImageAppName(event) {
174
174
  })?.appName;
175
175
  if (builtInAppName)
176
176
  return builtInAppName;
177
- const appName = getAppName();
177
+ const appName = getAppConfig().app.name;
178
178
  if (appName) {
179
179
  return resolveBuiltInAuthMarketingByName(appName)?.appName ?? appName;
180
180
  }
@@ -152,11 +152,14 @@ Five deterministic scorers run after every agent run:
152
152
  Enable sampled LLM-based evaluation by setting `evalSampleRate`:
153
153
 
154
154
  ```ts
155
- import { putSetting } from "@agent-native/core/settings";
156
-
157
- await putSetting("observability-config", {
158
- enabled: true,
159
- evalSampleRate: 0.05, // 5% of runs
155
+ // server/plugins/config.ts
156
+ import { defineAppConfig } from "@agent-native/core/server";
157
+
158
+ export default defineAppConfig({
159
+ observability: {
160
+ enabled: true,
161
+ evalSampleRate: 0.05, // 5%
162
+ },
160
163
  });
161
164
  ```
162
165
 
@@ -248,18 +251,22 @@ Use the real model identifiers your engine accepts in place of `<your-model-id>`
248
251
 
249
252
  ## Configuration {#config}
250
253
 
251
- All settings are stored in the `observability-config` key:
254
+ Set from a server plugin with `defineAppConfig()`. Every field also has a deployment environment variable alias — see the declared configuration reference.
252
255
 
253
256
  ```ts
254
- {
255
- enabled: true, // Master switch
256
- capturePrompts: false, // Store prompt content in traces
257
- captureToolArgs: false, // Store action input arguments
258
- captureToolResults: false, // Store action results
259
- captureLlmSpans: true, // Emit one $ai_span per tool call to PostHog
260
- evalSampleRate: 0, // 0-1, fraction of runs to LLM-judge
261
- exporters: [] // OTLP export targets
262
- }
257
+ // server/plugins/config.ts
258
+ import { defineAppConfig } from "@agent-native/core/server";
259
+
260
+ export default defineAppConfig({
261
+ observability: {
262
+ enabled: true, // Master switch
263
+ capturePrompts: false, // Store prompt content in traces
264
+ captureToolArgs: false, // Store action input arguments
265
+ captureToolResults: false, // Store action results
266
+ captureLlmSpans: true, // Emit one $ai_span per tool call to PostHog
267
+ evalSampleRate: 0, // 0-1, fraction of runs to LLM-judge
268
+ },
269
+ });
263
270
  ```
264
271
 
265
272
  <Callout id="doc-block-1xvsimn" tone="info">
@@ -360,26 +367,13 @@ response, and a thumbs-down stays marked incomplete until its follow-up arrives.
360
367
 
361
368
  ## Export to external platforms {#export}
362
369
 
363
- Send traces to Langfuse, Datadog, Grafana, or any OTel-compatible backend:
364
-
365
- ```ts
366
- await putSetting("observability-config", {
367
- enabled: true,
368
- exporters: [
369
- {
370
- type: "otlp",
371
- endpoint: "https://cloud.langfuse.com/api/public/otel",
372
- headers: { Authorization: "Bearer sk-..." },
373
- },
374
- ],
375
- });
376
- ```
370
+ Send traces to Langfuse, Datadog, Grafana, or any OTel-compatible backend by registering an OpenTelemetry provider in your own app — see [OpenTelemetry spans](#otel) below. The framework emits `gen_ai.*` semantic convention spans compatible with the OpenTelemetry GenAI spec, and your provider owns the exporter and its credentials.
377
371
 
378
- The framework emits `gen_ai.*` semantic convention spans compatible with the OpenTelemetry GenAI spec.
372
+ Core deliberately ships no exporter and holds no export endpoint or token, so a backend credential lives in your provider wiring (and the vault), never in framework configuration.
379
373
 
380
374
  ## OpenTelemetry spans {#otel}
381
375
 
382
- Separate from the `exporters` config above (which ships the in-house traces to an OTLP endpoint), the agent loop can also emit **live OpenTelemetry spans** for every run, model call, and tool call — so a host that already runs an OTel collector sees agent activity alongside the rest of its distributed traces.
376
+ The agent loop emits **live OpenTelemetry spans** for every run, model call, and tool call — so a host that already runs an OTel collector sees agent activity alongside the rest of its distributed traces.
383
377
 
384
378
  This layer is **optional and no-op by default**:
385
379
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.173.2-nightly-20260825163448",
3
+ "version": "0.174.0",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -429,8 +429,8 @@
429
429
  "y-protocols": "^1.0.7",
430
430
  "yjs": "^13.6.32",
431
431
  "zod": "^4.3.6",
432
- "@agent-native/recap-cli": "0.5.10",
433
- "@agent-native/toolkit": "^0.16.13"
432
+ "@agent-native/recap-cli": "0.5.11",
433
+ "@agent-native/toolkit": "^0.16.14"
434
434
  },
435
435
  "devDependencies": {
436
436
  "@ai-sdk/anthropic": "^3.0.71",
@@ -1,33 +0,0 @@
1
- /**
2
- * Resolve the user-facing name of this app — used in transactional emails,
3
- * page titles, and anywhere the framework needs to refer to "this app" by
4
- * name (e.g. "John invited you to Acme on Forms").
5
- *
6
- * Resolution order:
7
- * 1. `APP_NAME` env var — explicit override (recommended for prod)
8
- * 2. `displayName` from the app's package.json
9
- * 3. Titlecased `name` from package.json (only if it matches a known
10
- * first-party template — on serverless runtimes `process.cwd()` may
11
- * point at a bundler-generated package.json with a bogus name)
12
- * 4. First-party template label matched by package.json name
13
- * 5. `undefined` — caller should degrade gracefully
14
- */
15
- export declare function getAppName(): string | undefined;
16
- /**
17
- * Resolve the app's slug — the machine-readable identifier used for the
18
- * per-app transactional email sender (e.g. `clips@agent-native.com`).
19
- *
20
- * Only a first-party template name matched by package.json qualifies. A slug
21
- * derived from an arbitrary `APP_NAME` must not mint a mailbox on the
22
- * agent-native.com domain: a custom app would then send as
23
- * `<its-name>@agent-native.com` and route replies to the Builder mailbox.
24
- * Returns `undefined` for anything unrecognized, which leaves the deployment's
25
- * configured sender in place.
26
- */
27
- export declare function getAppSlug(): string | undefined;
28
- /**
29
- * One-line description of the app, used to tailor transactional email bodies
30
- * so recipients recognize which app they signed up for. Sourced from the
31
- * first-party template metadata; `undefined` for unknown apps.
32
- */
33
- export declare function getAppDescription(): string | undefined;
@@ -1,82 +0,0 @@
1
- /**
2
- * Resolve the user-facing name of this app — used in transactional emails,
3
- * page titles, and anywhere the framework needs to refer to "this app" by
4
- * name (e.g. "John invited you to Acme on Forms").
5
- *
6
- * Resolution order:
7
- * 1. `APP_NAME` env var — explicit override (recommended for prod)
8
- * 2. `displayName` from the app's package.json
9
- * 3. Titlecased `name` from package.json (only if it matches a known
10
- * first-party template — on serverless runtimes `process.cwd()` may
11
- * point at a bundler-generated package.json with a bogus name)
12
- * 4. First-party template label matched by package.json name
13
- * 5. `undefined` — caller should degrade gracefully
14
- */
15
- import fs from "node:fs";
16
- import path from "node:path";
17
- import { TEMPLATES } from "../cli/templates-meta.js";
18
- let cachedFromPkg = null;
19
- function readPkg() {
20
- try {
21
- const pkgPath = path.join(process.cwd(), "package.json");
22
- return JSON.parse(fs.readFileSync(pkgPath, "utf8"));
23
- }
24
- catch {
25
- return null;
26
- }
27
- }
28
- function titlecase(s) {
29
- return s
30
- .split(/[-_\s]+/)
31
- .filter(Boolean)
32
- .map((w) => w[0].toUpperCase() + w.slice(1))
33
- .join(" ");
34
- }
35
- export function getAppName() {
36
- if (process.env.APP_NAME)
37
- return process.env.APP_NAME;
38
- if (cachedFromPkg !== null)
39
- return cachedFromPkg ?? undefined;
40
- const pkg = readPkg();
41
- let name;
42
- if (pkg?.displayName) {
43
- name = pkg.displayName;
44
- }
45
- else if (pkg?.name) {
46
- const tmpl = TEMPLATES.find((t) => t.name === pkg.name);
47
- name = tmpl ? tmpl.label || titlecase(tmpl.name) : undefined;
48
- }
49
- cachedFromPkg = name ?? undefined;
50
- return name;
51
- }
52
- /**
53
- * Resolve the app's slug — the machine-readable identifier used for the
54
- * per-app transactional email sender (e.g. `clips@agent-native.com`).
55
- *
56
- * Only a first-party template name matched by package.json qualifies. A slug
57
- * derived from an arbitrary `APP_NAME` must not mint a mailbox on the
58
- * agent-native.com domain: a custom app would then send as
59
- * `<its-name>@agent-native.com` and route replies to the Builder mailbox.
60
- * Returns `undefined` for anything unrecognized, which leaves the deployment's
61
- * configured sender in place.
62
- */
63
- export function getAppSlug() {
64
- const pkg = readPkg();
65
- if (!pkg?.name)
66
- return undefined;
67
- return TEMPLATES.find((t) => t.name === pkg.name)?.name;
68
- }
69
- /**
70
- * One-line description of the app, used to tailor transactional email bodies
71
- * so recipients recognize which app they signed up for. Sourced from the
72
- * first-party template metadata; `undefined` for unknown apps.
73
- */
74
- export function getAppDescription() {
75
- const pkg = readPkg();
76
- if (pkg?.name) {
77
- const tmpl = TEMPLATES.find((t) => t.name === pkg.name);
78
- if (tmpl)
79
- return tmpl.hint;
80
- }
81
- return undefined;
82
- }