@agent-native/core 0.84.14 → 0.84.16

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 (59) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +17 -0
  3. package/corpus/core/package.json +2 -2
  4. package/corpus/core/src/agent/durable-background.ts +6 -0
  5. package/corpus/core/src/agent/engine/builder-engine.ts +7 -3
  6. package/corpus/core/src/agent/production-agent.ts +10 -3
  7. package/corpus/core/src/client/AssistantChat.tsx +30 -4
  8. package/corpus/core/src/client/MultiTabAssistantChat.tsx +11 -3
  9. package/corpus/core/src/client/agent-chat.ts +18 -3
  10. package/corpus/core/src/client/use-agent-engine-configured.ts +7 -4
  11. package/corpus/core/src/db/client.ts +10 -1
  12. package/corpus/core/src/server/agent-chat-plugin.ts +69 -43
  13. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/DashboardFilterBar.tsx +18 -24
  14. package/corpus/templates/analytics/changelog/2026-07-01-dashboard-charts-no-longer-show-future-dates-when-clients-se.md +6 -0
  15. package/corpus/templates/analytics/changelog/2026-07-01-dashboard-filters-take-less-space-and-keep-view-actions-tucked.md +6 -0
  16. package/corpus/templates/analytics/server/lib/first-party-analytics.ts +34 -9
  17. package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +6 -2
  18. package/corpus/templates/analytics/server/lib/session-replay.ts +109 -50
  19. package/corpus/templates/analytics/server/plugins/db.ts +21 -0
  20. package/corpus/templates/clips/chrome-extension/public/manifest.json +1 -1
  21. package/corpus/templates/design/app/pages/DesignEditor.tsx +176 -13
  22. package/corpus/templates/design/changelog/2026-07-01-exporting-a-design-as-png-or-svg-now-downloads-just-the-sele.md +6 -0
  23. package/dist/agent/durable-background.d.ts +1 -0
  24. package/dist/agent/durable-background.d.ts.map +1 -1
  25. package/dist/agent/durable-background.js +3 -0
  26. package/dist/agent/durable-background.js.map +1 -1
  27. package/dist/agent/engine/builder-engine.d.ts.map +1 -1
  28. package/dist/agent/engine/builder-engine.js +7 -1
  29. package/dist/agent/engine/builder-engine.js.map +1 -1
  30. package/dist/agent/production-agent.d.ts.map +1 -1
  31. package/dist/agent/production-agent.js +6 -4
  32. package/dist/agent/production-agent.js.map +1 -1
  33. package/dist/client/AssistantChat.d.ts +8 -2
  34. package/dist/client/AssistantChat.d.ts.map +1 -1
  35. package/dist/client/AssistantChat.js +18 -2
  36. package/dist/client/AssistantChat.js.map +1 -1
  37. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  38. package/dist/client/MultiTabAssistantChat.js +7 -3
  39. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  40. package/dist/client/agent-chat.d.ts +7 -0
  41. package/dist/client/agent-chat.d.ts.map +1 -1
  42. package/dist/client/agent-chat.js +5 -1
  43. package/dist/client/agent-chat.js.map +1 -1
  44. package/dist/client/use-agent-engine-configured.d.ts.map +1 -1
  45. package/dist/client/use-agent-engine-configured.js +7 -1
  46. package/dist/client/use-agent-engine-configured.js.map +1 -1
  47. package/dist/collab/awareness.d.ts +2 -2
  48. package/dist/collab/awareness.d.ts.map +1 -1
  49. package/dist/db/client.d.ts +6 -0
  50. package/dist/db/client.d.ts.map +1 -1
  51. package/dist/db/client.js +8 -1
  52. package/dist/db/client.js.map +1 -1
  53. package/dist/notifications/routes.d.ts +3 -3
  54. package/dist/observability/routes.d.ts +6 -6
  55. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  56. package/dist/server/agent-chat-plugin.js +57 -40
  57. package/dist/server/agent-chat-plugin.js.map +1 -1
  58. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  59. package/package.json +2 -2
@@ -7,7 +7,7 @@ import { updateTaskStatusMessage } from "../a2a/task-store.js";
7
7
  import { ACTION_CHAT_UI_DATA_WIDGET_RENDERER } from "../action-ui.js";
8
8
  import { canUpdateAgentAppModelDefaultSettings, normalizeAgentAppModelDefaultAppId, readAgentAppModelDefaultSettings, resetAgentAppModelDefaultSettings, writeAgentAppModelDefaultSettings, } from "../agent/app-model-defaults.js";
9
9
  import { DEFAULT_ANTHROPIC_MODEL } from "../agent/default-model.js";
10
- import { AGENT_CHAT_PROCESS_RUN_PATH, extractProcessRunId, isInBackgroundFunctionRuntime, prepareProcessRunRequest, } from "../agent/durable-background.js";
10
+ import { AGENT_CHAT_BACKGROUND_RUN_FIELD, AGENT_CHAT_PROCESS_RUN_PATH, backgroundRunMarkerExpectsBackgroundRuntime, isInBackgroundFunctionRuntime, prepareProcessRunRequest, } from "../agent/durable-background.js";
11
11
  import { resolveEngine, createAnthropicEngine, getStoredModelForEngine, normalizeModelForEngine, getAgentEngineEntry, isAgentEnginePackageInstalled, isStoredEngineUsableForRequest, listAgentEngines, registerBuiltinEngines, } from "../agent/engine/index.js";
12
12
  import { createProductionAgentHandler, actionsToEngineTools, getActiveRunForThreadAsync, abortRun, subscribeToRun, } from "../agent/production-agent.js";
13
13
  import { runAgentLoopDirectWithSoftTimeout } from "../agent/run-loop-with-resume.js";
@@ -6233,18 +6233,6 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
6233
6233
  setResponseStatus(event, 405);
6234
6234
  return { error: "Method not allowed" };
6235
6235
  }
6236
- // DIAGNOSTIC: load the run-store diagnostic recorder. Each stage we
6237
- // reach is written onto the run row (diag_stage) so a silent failure
6238
- // INSIDE the Netlify background function — whose logs we cannot read —
6239
- // is still diagnosable from the client via /runs/active. Best-effort:
6240
- // the import + every record call is wrapped so diagnostics can never
6241
- // break the worker path.
6242
- const diag = await import("../agent/run-store.js")
6243
- .then((m) => ({
6244
- record: m.recordRunDiagnostic,
6245
- stages: m.RUN_DIAG_STAGE,
6246
- }))
6247
- .catch(() => null);
6248
6236
  // Consume the body ONCE (h3 v2's web Request stream is single-use).
6249
6237
  let processBody;
6250
6238
  try {
@@ -6254,17 +6242,6 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
6254
6242
  setResponseStatus(event, 400);
6255
6243
  return { error: "Invalid request body" };
6256
6244
  }
6257
- // Record "the route handler was entered" against the run BEFORE auth
6258
- // runs. This is the proof the bg-fn invocation actually reached Nitro
6259
- // (vs. dying at the function entry / never being invoked). The runId
6260
- // is parsed without authenticating so we can attach it even on a
6261
- // subsequent auth failure.
6262
- const diagRunId = extractProcessRunId(processBody);
6263
- if (diag && diagRunId) {
6264
- await diag
6265
- .record(diagRunId, diag.stages.routeEntered)
6266
- .catch(() => { });
6267
- }
6268
6245
  // Validate + HMAC-authenticate the self-dispatch and prepare the
6269
6246
  // background-worker body. Pure decision (unit-tested in
6270
6247
  // durable-background.spec.ts); the route only wires it to h3.
@@ -6276,6 +6253,12 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
6276
6253
  // bypassing session auth) inside the unreadable bg function would
6277
6254
  // leave the run to time out with NO clue. The detail carries the
6278
6255
  // status + whether A2A_SECRET is even present in this isolate.
6256
+ const diag = await import("../agent/run-store.js")
6257
+ .then((m) => ({
6258
+ record: m.recordRunDiagnostic,
6259
+ stages: m.RUN_DIAG_STAGE,
6260
+ }))
6261
+ .catch(() => null);
6279
6262
  if (diag && prepared.runId) {
6280
6263
  const a2aPresent = Boolean(process.env.A2A_SECRET && process.env.A2A_SECRET.length > 0);
6281
6264
  await diag
@@ -6285,24 +6268,47 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
6285
6268
  setResponseStatus(event, prepared.status);
6286
6269
  return { error: prepared.error };
6287
6270
  }
6288
- // DIAGNOSTIC: auth + body validation passed. Reaching here proves the
6289
- // request was authenticated and we are about to invoke the worker.
6290
- if (diag) {
6291
- await diag
6292
- .record(prepared.runId, diag.stages.authPassed)
6293
- .catch(() => { });
6271
+ const preparedMarker = prepared.body[AGENT_CHAT_BACKGROUND_RUN_FIELD];
6272
+ const expectsBackgroundRuntime = backgroundRunMarkerExpectsBackgroundRuntime(preparedMarker);
6273
+ const runtimeGlobals = globalThis;
6274
+ const hadExpectedRuntimeMarker = Object.prototype.hasOwnProperty.call(runtimeGlobals, "__AGENT_NATIVE_BACKGROUND_RUNTIME_EXPECTED__");
6275
+ const previousExpectedRuntimeMarker = runtimeGlobals.__AGENT_NATIVE_BACKGROUND_RUNTIME_EXPECTED__;
6276
+ if (expectsBackgroundRuntime) {
6277
+ runtimeGlobals.__AGENT_NATIVE_BACKGROUND_RUNTIME_EXPECTED__ = true;
6294
6278
  }
6295
- // Stash the verified+augmented body for the handler — the body stream
6296
- // is already consumed, so the handler reads this instead.
6297
- event.context = event.context ?? {};
6298
- event.context.__agentChatBackgroundBody = prepared.body;
6299
- // Durable owner context: this self-dispatch is cookieless (HMAC-only).
6300
- // Resolve the owner from the persisted run row, never the request body,
6301
- // then invoke the normal handler. The shared agent-run context helper
6302
- // expands that owner into the same user/org AsyncLocalStorage context the
6303
- // foreground request uses, so credential and data scoping stay aligned.
6304
- await seedBackgroundAgentRunOwnerContext(event, prepared.runId);
6305
6279
  try {
6280
+ // DIAGNOSTIC: load the run-store diagnostic recorder only after the
6281
+ // authenticated marker has been mirrored into globalThis. run-store
6282
+ // can initialize the DB pool; the pool must see the same background
6283
+ // proof as the agent timeout logic before that happens.
6284
+ const diag = await import("../agent/run-store.js")
6285
+ .then((m) => ({
6286
+ record: m.recordRunDiagnostic,
6287
+ stages: m.RUN_DIAG_STAGE,
6288
+ }))
6289
+ .catch(() => null);
6290
+ // Record "the route handler was entered" against the run after auth
6291
+ // succeeds. This is the proof the bg-fn invocation actually reached
6292
+ // Nitro (vs. dying at the function entry / never being invoked).
6293
+ if (diag) {
6294
+ await diag
6295
+ .record(prepared.runId, diag.stages.routeEntered)
6296
+ .catch(() => { });
6297
+ await diag
6298
+ .record(prepared.runId, diag.stages.authPassed)
6299
+ .catch(() => { });
6300
+ }
6301
+ // Stash the verified+augmented body for the handler — the body stream
6302
+ // is already consumed, so the handler reads this instead.
6303
+ event.context = event.context ?? {};
6304
+ event.context.__agentChatBackgroundBody = prepared.body;
6305
+ // Durable owner context: this self-dispatch is cookieless (HMAC-only).
6306
+ // Resolve the owner from the persisted run row, never the request
6307
+ // body, then invoke the normal handler. The shared agent-run context
6308
+ // helper expands that owner into the same user/org AsyncLocalStorage
6309
+ // context the foreground request uses, so credential and data scoping
6310
+ // stay aligned.
6311
+ await seedBackgroundAgentRunOwnerContext(event, prepared.runId);
6306
6312
  return await invokeAgentChatHandler(event);
6307
6313
  }
6308
6314
  catch (err) {
@@ -6323,6 +6329,17 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
6323
6329
  setResponseStatus(event, 500);
6324
6330
  return { error: "process-run failed" };
6325
6331
  }
6332
+ finally {
6333
+ if (expectsBackgroundRuntime) {
6334
+ if (hadExpectedRuntimeMarker) {
6335
+ runtimeGlobals.__AGENT_NATIVE_BACKGROUND_RUNTIME_EXPECTED__ =
6336
+ previousExpectedRuntimeMarker;
6337
+ }
6338
+ else {
6339
+ Reflect.deleteProperty(runtimeGlobals, "__AGENT_NATIVE_BACKGROUND_RUNTIME_EXPECTED__");
6340
+ }
6341
+ }
6342
+ }
6326
6343
  }));
6327
6344
  // Mount the main chat handler — delegates to dev or prod handler based on current mode.
6328
6345
  // This is mounted last because h3's use() is prefix-based, meaning /_agent-native/agent-chat