@agent-native/core 0.209.1 → 0.209.2-nightly-20261016005836

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 (97) hide show
  1. package/dist/agent/actions/list-model-providers.js +15 -2
  2. package/dist/agent/app-model-defaults.d.ts +9 -13
  3. package/dist/agent/app-model-defaults.js +23 -5
  4. package/dist/agent/default-agent-engine.d.ts +5 -3
  5. package/dist/agent/default-agent-engine.js +38 -8
  6. package/dist/agent/durable-background.d.ts +2 -0
  7. package/dist/agent/durable-background.js +2 -0
  8. package/dist/agent/engine/registry.js +6 -0
  9. package/dist/agent/production-agent.js +58 -5
  10. package/dist/app-config/clips.d.ts +43 -0
  11. package/dist/app-config/clips.js +91 -0
  12. package/dist/app-config/index.d.ts +1 -0
  13. package/dist/app-config/index.js +1 -0
  14. package/dist/app-config/schema.d.ts +17 -0
  15. package/dist/app-config/schema.js +2 -0
  16. package/dist/automations/service.d.ts +2 -0
  17. package/dist/automations/service.js +4 -1
  18. package/dist/client/analytics.js +48 -1
  19. package/dist/client/application-state.js +7 -2
  20. package/dist/client/chat/agentkit-protocol.js +12 -3
  21. package/dist/client/client-bootstrap.js +2 -0
  22. package/dist/client/problem-report.d.ts +11 -0
  23. package/dist/client/problem-report.js +19 -0
  24. package/dist/client/recorder.d.ts +88 -0
  25. package/dist/client/recorder.js +585 -0
  26. package/dist/client/route-chunk-recovery.js +4 -1
  27. package/dist/client/sign-out.js +2 -0
  28. package/dist/client/use-action.js +3 -0
  29. package/dist/deploy/workspace-deploy.js +77 -3
  30. package/dist/file-upload/actions/upload-image.d.ts +2 -2
  31. package/dist/integrations/google-docs-poller.js +12 -5
  32. package/dist/integrations/plugin.js +86 -19
  33. package/dist/integrations/request-scope.d.ts +16 -0
  34. package/dist/integrations/request-scope.js +27 -0
  35. package/dist/integrations/webhook-handler.d.ts +2 -0
  36. package/dist/integrations/webhook-handler.js +38 -18
  37. package/dist/jobs/background-automation-runner.d.ts +2 -0
  38. package/dist/jobs/background-automation-runner.js +25 -2
  39. package/dist/jobs/scheduler.js +36 -22
  40. package/dist/mcp/screen-memory-stdio.d.ts +7 -7
  41. package/dist/notifications/routes.d.ts +2 -2
  42. package/dist/observability/routes.d.ts +1 -1
  43. package/dist/org/context.d.ts +12 -0
  44. package/dist/org/context.js +26 -11
  45. package/dist/org/index.d.ts +1 -1
  46. package/dist/problem-report/actions/read-problem-report.d.ts +27 -0
  47. package/dist/problem-report/actions/read-problem-report.js +103 -0
  48. package/dist/problem-report/actions/save-problem-report.d.ts +35 -0
  49. package/dist/problem-report/actions/save-problem-report.js +36 -0
  50. package/dist/problem-report/format.d.ts +7 -0
  51. package/dist/problem-report/format.js +110 -0
  52. package/dist/problem-report/schema.d.ts +41 -0
  53. package/dist/problem-report/schema.js +34 -0
  54. package/dist/provider-api/actions/custom-provider-registration.d.ts +8 -8
  55. package/dist/provider-api/actions/provider-api.d.ts +14 -14
  56. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  57. package/dist/scripts/agent-engines/manage-agent-engine.js +9 -4
  58. package/dist/scripts/agent-engines/set-agent-engine.js +7 -1
  59. package/dist/server/action-discovery.js +11 -0
  60. package/dist/server/action-routes.js +2 -0
  61. package/dist/server/agent-chat-ai-setup.d.ts +2 -3
  62. package/dist/server/agent-chat-ai-setup.js +18 -4
  63. package/dist/server/agent-chat-plugin.js +97 -22
  64. package/dist/server/agent-chat-stream.d.ts +17 -5
  65. package/dist/server/agent-chat-stream.js +15 -0
  66. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  67. package/dist/server/agent-engine-default-model-route.d.ts +2 -2
  68. package/dist/server/agent-engine-default-model-route.js +39 -6
  69. package/dist/server/agent-engine-status-cache.d.ts +4 -0
  70. package/dist/server/agent-engine-status-cache.js +2 -0
  71. package/dist/server/agent-run-context.d.ts +9 -0
  72. package/dist/server/agent-run-context.js +82 -17
  73. package/dist/server/auth.js +6 -1
  74. package/dist/server/builder-browser.js +18 -3
  75. package/dist/server/chatgpt-subscription-oauth.js +12 -17
  76. package/dist/server/core-routes-plugin.d.ts +1 -0
  77. package/dist/server/core-routes-plugin.js +46 -9
  78. package/dist/server/index.d.ts +1 -1
  79. package/dist/server/index.js +1 -1
  80. package/dist/server/loopback.d.ts +1 -0
  81. package/dist/server/loopback.js +30 -0
  82. package/dist/server/origin-allowlist.d.ts +2 -0
  83. package/dist/server/origin-allowlist.js +13 -1
  84. package/dist/server/realtime-token.d.ts +1 -1
  85. package/dist/server/request-context.d.ts +4 -0
  86. package/dist/templates/chat/app/components/layout/Sidebar.tsx +11 -1
  87. package/dist/templates/factory/.agents/skills/review-latest-feedback/SKILL.md +2 -2
  88. package/dist/templates/factory/.agents/skills/review-latest-feedback/references/channel-inventory.md +31 -0
  89. package/dist/triggers/dispatcher.js +117 -31
  90. package/docs/content/recorder.mdx +259 -0
  91. package/docs/content/template-clips-developers.mdx +9 -8
  92. package/docs/content/template-clips-features.mdx +8 -7
  93. package/package.json +7 -4
  94. package/src/templates/chat/app/components/layout/Sidebar.tsx +11 -1
  95. package/src/templates/factory/.agents/skills/review-latest-feedback/SKILL.md +2 -2
  96. package/src/templates/factory/.agents/skills/review-latest-feedback/references/channel-inventory.md +31 -0
  97. package/third-party-licenses/TABLER-ICONS.txt +21 -0
@@ -19,6 +19,7 @@ import { scheduleAfterPaint } from "./use-after-paint.js";
19
19
  export { clearAnalyticsSessionId, setAnalyticsSessionId, } from "./analytics-session.js";
20
20
  import { fetchAgentEngineStatus, fetchAuthSessionStatus, } from "./client-status-requests.js";
21
21
  import { firstPartyHosts, installErrorCapture, } from "./error-capture.js";
22
+ import { buildRecorderReport, recorderSentryEnabled, } from "./recorder.js";
22
23
  import { currentRouteTemplate } from "./route-template.js";
23
24
  import { scrubUrl } from "./url-scrub.js";
24
25
  import { installWebVitals, } from "./web-vitals.js";
@@ -815,6 +816,51 @@ function shouldDropBrowserSentryNoise(event) {
815
816
  firstPartyHosts: firstPartyHosts(),
816
817
  }).drop;
817
818
  }
819
+ // Sentry keeps 100 breadcrumbs by default; the attachment carries the whole report.
820
+ const SENTRY_RECORDER_BREADCRUMBS = 100;
821
+ function recorderBreadcrumb(recorded) {
822
+ const { t: _t, at, type, name, data: _data, ...outcome } = recorded;
823
+ return {
824
+ category: `recorder.${type}`,
825
+ message: [
826
+ name,
827
+ outcome.ok === undefined ? undefined : outcome.ok ? "ok" : "failed",
828
+ outcome.status,
829
+ outcome.errorCode,
830
+ outcome.ms === undefined ? undefined : `${outcome.ms}ms`,
831
+ ]
832
+ .filter((part) => part !== undefined)
833
+ .join(" "),
834
+ level: type === "error" || (type === "toast" && name === "error")
835
+ ? "error"
836
+ : type === "toast" || outcome.ok === false
837
+ ? "warning"
838
+ : "info",
839
+ timestamp: at / 1000,
840
+ data: outcome,
841
+ };
842
+ }
843
+ function addRecorderContext(event, hint) {
844
+ if (!recorderSentryEnabled())
845
+ return;
846
+ const report = buildRecorderReport("error");
847
+ if (report.events.length > 0) {
848
+ event.breadcrumbs = [
849
+ ...(event.breadcrumbs ?? []),
850
+ ...report.events
851
+ .slice(-SENTRY_RECORDER_BREADCRUMBS)
852
+ .map(recorderBreadcrumb),
853
+ ].sort((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0));
854
+ }
855
+ hint.attachments = [
856
+ ...(hint.attachments ?? []),
857
+ {
858
+ filename: "recorder.json",
859
+ data: JSON.stringify(report),
860
+ contentType: "application/json",
861
+ },
862
+ ];
863
+ }
818
864
  function firstNonEmpty(...values) {
819
865
  for (const value of values) {
820
866
  const trimmed = value?.trim();
@@ -895,7 +941,7 @@ function ensureSentry(loadWithoutDsn = false) {
895
941
  dsn,
896
942
  environment: resolveClientDeploymentEnvironment(),
897
943
  release: resolveClientRelease(),
898
- beforeSend(event) {
944
+ beforeSend(event, hint = {}) {
899
945
  if (isSyntheticBrowserTraffic())
900
946
  return null;
901
947
  event.tags = {
@@ -924,6 +970,7 @@ function ensureSentry(loadWithoutDsn = false) {
924
970
  }
925
971
  }
926
972
  }
973
+ addRecorderContext(event, hint);
927
974
  return event;
928
975
  },
929
976
  });
@@ -1,6 +1,7 @@
1
1
  import { agentNativePath } from "./api-path.js";
2
2
  import { assertAgentNativeApiEnabled } from "./api-surface.js";
3
3
  import { getBrowserTabId } from "./browser-tab-id.js";
4
+ import { recordStateWrite } from "./recorder.js";
4
5
  const APP_STATE_KEY_PATTERN = /^[a-zA-Z0-9_:-]+$/;
5
6
  const pendingMutations = new Map();
6
7
  const mutationRevisions = new Map();
@@ -200,7 +201,7 @@ export async function readClientAppState(key, options = {}) {
200
201
  }
201
202
  export async function writeClientAppState(key, value, options = {}) {
202
203
  assertAgentNativeApiEnabled(`write application state "${key}"`);
203
- return runClientAppStateMutation(key, async () => {
204
+ const write = runClientAppStateMutation(key, async () => {
204
205
  const response = await fetch(appStateUrl(key), {
205
206
  method: "PUT",
206
207
  headers: buildHeaders(options.requestSource),
@@ -210,6 +211,8 @@ export async function writeClientAppState(key, value, options = {}) {
210
211
  });
211
212
  return parseAppStateResponse(response, `Write application state "${key}"`);
212
213
  });
214
+ recordStateWrite(key, value, write, options.signal);
215
+ return write;
213
216
  }
214
217
  export async function compareAndSetClientAppState(key, expected, next, options = {}) {
215
218
  assertAgentNativeApiEnabled(`compare application state \"${key}\"`);
@@ -230,7 +233,7 @@ export async function compareAndSetClientAppState(key, expected, next, options =
230
233
  }
231
234
  export async function deleteClientAppState(key, options = {}) {
232
235
  assertAgentNativeApiEnabled(`delete application state "${key}"`);
233
- await runClientAppStateMutation(key, async () => {
236
+ const deletion = runClientAppStateMutation(key, async () => {
234
237
  const response = await fetch(appStateUrl(key), {
235
238
  method: "DELETE",
236
239
  headers: {
@@ -245,6 +248,8 @@ export async function deleteClientAppState(key, options = {}) {
245
248
  });
246
249
  return parseAppStateResponse(response, `Delete application state "${key}"`);
247
250
  });
251
+ recordStateWrite(key, undefined, deletion, options.signal);
252
+ await deletion;
248
253
  }
249
254
  export async function setClientAppState(key, value, options = {}) {
250
255
  if (value === null || value === undefined) {
@@ -3232,9 +3232,18 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
3232
3232
  activeMessageCompleted: run.activeMessageCompleted,
3233
3233
  pendingWidgets: new Map(run.pendingWidgets),
3234
3234
  actions: new Map(run.actions),
3235
- activeTools: new Map(run.activeTools),
3236
- pendingToolMessageAssociations: new Map(run.pendingToolMessageAssociations),
3237
- activeActivities: new Map(run.activeActivities),
3235
+ activeTools: new Map([...run.activeTools].map(([id, tool]) => [
3236
+ id,
3237
+ { ...tool, runId: nextRunId },
3238
+ ])),
3239
+ pendingToolMessageAssociations: new Map([...run.pendingToolMessageAssociations].map(([id, tool]) => [
3240
+ id,
3241
+ { ...tool, runId: nextRunId },
3242
+ ])),
3243
+ activeActivities: new Map([...run.activeActivities].map(([id, activity]) => [
3244
+ id,
3245
+ { ...activity, runId: nextRunId },
3246
+ ])),
3238
3247
  terminalAppendDepth: 0,
3239
3248
  pumpPromise: null,
3240
3249
  continuationPromise: null,
@@ -1,6 +1,8 @@
1
1
  import { ensureEmbedAuthFetchInterceptor } from "./embed-auth.js";
2
+ import { startRecorder } from "./recorder.js";
2
3
  import { installRouteChunkRecovery } from "./route-chunk-recovery.js";
3
4
  export function initializeAgentNativeClient() {
4
5
  ensureEmbedAuthFetchInterceptor();
5
6
  installRouteChunkRecovery();
7
+ startRecorder();
6
8
  }
@@ -0,0 +1,11 @@
1
+ import type { RecorderReport } from "./recorder.js";
2
+ export { countRecorderEventsByType, formatProblemReportSummary, formatRecorderEvent, isFailedRecorderEvent, } from "../problem-report/format.js";
3
+ export type ProblemReportUpload = {
4
+ status: "ok";
5
+ ref: string;
6
+ } | {
7
+ status: "failed";
8
+ errorCode?: string;
9
+ message?: string;
10
+ };
11
+ export declare function uploadProblemReport(report: RecorderReport): Promise<ProblemReportUpload>;
@@ -0,0 +1,19 @@
1
+ import { actionErrorMessage, callAction } from "./use-action.js";
2
+ export { countRecorderEventsByType, formatProblemReportSummary, formatRecorderEvent, isFailedRecorderEvent, } from "../problem-report/format.js";
3
+ export async function uploadProblemReport(report) {
4
+ try {
5
+ const { ref } = await callAction("save-problem-report", {
6
+ report,
7
+ });
8
+ return { status: "ok", ref };
9
+ }
10
+ catch (error) {
11
+ const errorCode = error.errorCode;
12
+ const message = actionErrorMessage(error);
13
+ return {
14
+ status: "failed",
15
+ ...(typeof errorCode === "string" ? { errorCode } : {}),
16
+ ...(message ? { message } : {}),
17
+ };
18
+ }
19
+ }
@@ -0,0 +1,88 @@
1
+ export type RecorderEventType = "action" | "state" | "nav" | "error" | "toast" | "log";
2
+ export type RecorderReportReason = "user" | "error" | "test" | "manual";
3
+ export interface RecorderEvent {
4
+ /** Seconds before the report was made (negative). */
5
+ t: number;
6
+ /** Epoch ms, the same clock as Clips diagnostics `timestampMs`. */
7
+ at: number;
8
+ type: RecorderEventType;
9
+ name?: string;
10
+ ok?: boolean;
11
+ status?: number;
12
+ errorCode?: string;
13
+ ms?: number;
14
+ requestId?: string;
15
+ /** Redacted and bounded: strings ≤ 200 characters, the event ≤ about 2 KB. */
16
+ data?: Record<string, unknown>;
17
+ }
18
+ export interface RecorderPendingWork {
19
+ type: "action" | "state" | string;
20
+ name: string;
21
+ ageMs: number;
22
+ }
23
+ export interface RecorderReport {
24
+ app: string;
25
+ build: string;
26
+ /** The route path, with every query value redacted. */
27
+ url: string;
28
+ at: string;
29
+ reason: RecorderReportReason;
30
+ windowSeconds: number;
31
+ events: RecorderEvent[];
32
+ watched: Record<string, unknown>;
33
+ pending: RecorderPendingWork[];
34
+ /** Events lost to the caps since the last clear. */
35
+ dropped: number;
36
+ }
37
+ export interface RecorderReportOptions {
38
+ seconds?: number;
39
+ reason?: RecorderReportReason;
40
+ }
41
+ /** @internal Called when an action starts; call the result when it settles. */
42
+ export declare function recordActionStart(name: string, method: string): (outcome: {
43
+ error: unknown;
44
+ response: Response | undefined;
45
+ signal: AbortSignal | undefined;
46
+ }) => void;
47
+ /** @internal An `application_state` write, or a delete when `value` is undefined. */
48
+ export declare function recordStateWrite(key: string, value: unknown, write: Promise<unknown>, signal: AbortSignal | undefined): void;
49
+ /** @internal */
50
+ export declare function recordNav(): void;
51
+ /** @internal The report without notifying `onReport` listeners, for core's own destinations. */
52
+ export declare function buildRecorderReport(reason: RecorderReportReason, seconds?: number): RecorderReport;
53
+ declare function report(options?: RecorderReportOptions): RecorderReport;
54
+ declare function pending(): RecorderPendingWork[];
55
+ export declare const recorder: {
56
+ /** Synchronous. Listeners hear about every report except a `"manual"` one. */
57
+ report: typeof report;
58
+ log(name: string, data?: unknown): void;
59
+ /** Adds `getValue()` to every report. Returns a function that stops it. */
60
+ watch(name: string, getValue: () => unknown): () => void;
61
+ onReport(listener: (report: RecorderReport) => void): () => void;
62
+ /** Field names (`"body"`), or dotted paths that start with the event's name (`"compose.body"`, `"payment.*"`). */
63
+ redact(...keys: string[]): void;
64
+ pending: typeof pending;
65
+ disable(): void;
66
+ };
67
+ declare global {
68
+ interface Window {
69
+ __agentNativeRecorder?: {
70
+ report: typeof report;
71
+ };
72
+ }
73
+ }
74
+ export declare function configureRecorder(options: {
75
+ windowSeconds?: number;
76
+ maxEvents?: number;
77
+ sentry?: boolean;
78
+ enabled?: boolean;
79
+ }): void;
80
+ /** @internal Whether `ensureSentry()` should attach recorder events. */
81
+ export declare function recorderSentryEnabled(): boolean;
82
+ /** @internal Forgets everything recorded, e.g. on sign-out. */
83
+ export declare function clearRecorder(): void;
84
+ /** @internal Called once from client bootstrap. */
85
+ export declare function startRecorder(): void;
86
+ /** @internal */
87
+ export declare function resetRecorderForTests(): void;
88
+ export {};