veryfront 0.1.1174 → 0.1.1175

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 (30) hide show
  1. package/esm/deno.js +1 -1
  2. package/esm/extensions/ext-observability-sentry/src/node.d.ts +9 -0
  3. package/esm/extensions/ext-observability-sentry/src/node.d.ts.map +1 -0
  4. package/esm/extensions/ext-observability-sentry/src/node.js +32 -0
  5. package/esm/extensions/ext-observability-sentry/src/policy.d.ts +43 -0
  6. package/esm/extensions/ext-observability-sentry/src/policy.d.ts.map +1 -0
  7. package/esm/extensions/ext-observability-sentry/src/policy.js +108 -0
  8. package/esm/src/agent/hosted/veryfront-cloud-agent-service.d.ts.map +1 -1
  9. package/esm/src/agent/hosted/veryfront-cloud-agent-service.js +21 -2
  10. package/esm/src/agent/service/bootstrap.d.ts +2 -0
  11. package/esm/src/agent/service/bootstrap.d.ts.map +1 -1
  12. package/esm/src/agent/service/bootstrap.js +9 -1
  13. package/esm/src/agent/service/node-runtime-infrastructure.d.ts +3 -1
  14. package/esm/src/agent/service/node-runtime-infrastructure.d.ts.map +1 -1
  15. package/esm/src/agent/service/node-runtime-infrastructure.js +13 -0
  16. package/esm/src/agent/service/node-sentry.d.ts +35 -0
  17. package/esm/src/agent/service/node-sentry.d.ts.map +1 -0
  18. package/esm/src/agent/service/node-sentry.js +242 -0
  19. package/esm/src/observability/application-errors.d.ts +1 -0
  20. package/esm/src/observability/application-errors.d.ts.map +1 -1
  21. package/esm/src/observability/application-errors.js +12 -2
  22. package/esm/src/utils/logger/index.d.ts +1 -1
  23. package/esm/src/utils/logger/index.d.ts.map +1 -1
  24. package/esm/src/utils/logger/index.js +1 -1
  25. package/esm/src/utils/logger/logger.d.ts +3 -1
  26. package/esm/src/utils/logger/logger.d.ts.map +1 -1
  27. package/esm/src/utils/logger/logger.js +25 -5
  28. package/esm/src/utils/version-constant.d.ts +1 -1
  29. package/esm/src/utils/version-constant.js +1 -1
  30. package/package.json +5 -5
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.1174",
3
+ "version": "0.1.1175",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "minimumDependencyAge": {
@@ -0,0 +1,9 @@
1
+ import * as Sentry from "@sentry/node";
2
+ import type { ApplicationErrorReporter, SentryConfig } from "../../../src/observability/sentry.js";
3
+ import { type SentryPolicySdk } from "./policy.js";
4
+ type NodeSentrySdk = SentryPolicySdk & {
5
+ init(options: Parameters<typeof Sentry.init>[0]): unknown;
6
+ };
7
+ export declare function createNodeSentryApplicationErrorReporter(config: Required<SentryConfig>, sdk?: NodeSentrySdk): ApplicationErrorReporter;
8
+ export {};
9
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-observability-sentry/src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACnG,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAErB,KAAK,aAAa,GAAG,eAAe,GAAG;IACrC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;CAC3D,CAAC;AAEF,wBAAgB,wCAAwC,CACtD,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,GAAG,GAAE,aAAsB,GAC1B,wBAAwB,CA8B1B"}
@@ -0,0 +1,32 @@
1
+ import * as Sentry from "@sentry/node";
2
+ import { captureWithSentryPolicy, flushWithSentryPolicy, prepareSentryEvent, } from "./policy.js";
3
+ export function createNodeSentryApplicationErrorReporter(config, sdk = Sentry) {
4
+ sdk.init({
5
+ dsn: config.dsn,
6
+ ...(config.environment ? { environment: config.environment } : {}),
7
+ ...(config.release ? { release: config.release } : {}),
8
+ beforeSend: (event) => prepareSentryEvent(event, config.serviceName),
9
+ dataCollection: {
10
+ cookies: false,
11
+ databaseQueryData: false,
12
+ frameContextLines: 0,
13
+ genAI: { inputs: false, outputs: false },
14
+ graphQL: { document: false, variables: false },
15
+ httpBodies: [],
16
+ httpHeaders: { request: false, response: false },
17
+ stackFrameVariables: false,
18
+ urlQueryParams: false,
19
+ userInfo: false,
20
+ },
21
+ defaultIntegrations: false,
22
+ enableLogs: false,
23
+ sendDefaultPii: false,
24
+ skipOpenTelemetrySetup: true,
25
+ });
26
+ return {
27
+ capture(error, context) {
28
+ return captureWithSentryPolicy(sdk, config.serviceName, error, context);
29
+ },
30
+ flush: (timeoutMs) => flushWithSentryPolicy(sdk, timeoutMs),
31
+ };
32
+ }
@@ -0,0 +1,43 @@
1
+ import type { ApplicationErrorContext } from "../../../src/observability/sentry.js";
2
+ export declare const DEFAULT_FINGERPRINT = "{{ default }}";
3
+ export type SentryPolicyScope = {
4
+ setContext(name: string, context: Record<string, unknown>): void;
5
+ setFingerprint(fingerprint: string[]): void;
6
+ setTag(key: string, value: string): void;
7
+ };
8
+ export type SentryPolicySdk = {
9
+ captureException(error: unknown): string;
10
+ flush(timeoutMs?: number): Promise<boolean>;
11
+ withScope(callback: (scope: SentryPolicyScope) => void): void;
12
+ };
13
+ export type SentryPolicyEvent = {
14
+ breadcrumbs?: unknown;
15
+ exception?: {
16
+ values?: Array<{
17
+ value?: string;
18
+ stacktrace?: {
19
+ frames?: Array<{
20
+ abs_path?: string;
21
+ filename?: string;
22
+ }>;
23
+ };
24
+ }>;
25
+ };
26
+ fingerprint?: string[];
27
+ logentry?: {
28
+ message?: string;
29
+ };
30
+ message?: string;
31
+ request?: unknown;
32
+ tags?: Record<string, unknown>;
33
+ type?: undefined;
34
+ user?: unknown;
35
+ };
36
+ export declare function captureWithSentryPolicy(sdk: SentryPolicySdk, serviceName: string, error: unknown, context: ApplicationErrorContext): string | undefined;
37
+ export declare function flushWithSentryPolicy(sdk: Pick<SentryPolicySdk, "flush">, timeoutMs?: number): Promise<boolean>;
38
+ export declare function applySentryScopePolicy(scope: SentryPolicyScope, serviceName: string, context: ApplicationErrorContext): void;
39
+ export declare function prepareSentryEvent<TEvent extends SentryPolicyEvent>(event: TEvent, serviceName: string): TEvent & SentryPolicyEvent;
40
+ export declare function redactSensitiveText(value: string): string;
41
+ export declare function sanitizeApplicationErrorAttributes(attributes: Record<string, string | number | boolean>): Record<string, string | number | boolean>;
42
+ export declare function sanitizeStackFramePath(value: string): string;
43
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-observability-sentry/src/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAEpF,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AAWnD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACjE,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACzC,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,IAAI,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW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E,MAAM,GAAG,MAAM,CAOzD;AAED,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GACpD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAU3C;AAOD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAW5D"}
@@ -0,0 +1,108 @@
1
+ export const DEFAULT_FINGERPRINT = "{{ default }}";
2
+ const SENTRY_TOKEN_PATTERN = /\bsntrys_[A-Za-z0-9_+/=-]+\b/g;
3
+ const BEARER_TOKEN_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+\b/gi;
4
+ const JWT_PATTERN = /\b[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{16,}\b/g;
5
+ const URL_CREDENTIAL_PATTERN = /(https?:\/\/)[^@\s/]+(@[^/\s]+)/gi;
6
+ const SENSITIVE_QUERY_PATTERN = /([?&](?:access_token|api_key|auth|authorization|dsn|password|secret|token)=)[^&#\s]+/gi;
7
+ const SENSITIVE_ATTRIBUTE_KEY_PATTERN = /(?:^|[_\-.])(?:api[_\-.]?key|auth|authorization|cookie|credentials?|dsn|jwt|password|secret|session|signature|token)(?:$|[_\-.])/i;
8
+ export function captureWithSentryPolicy(sdk, serviceName, error, context) {
9
+ try {
10
+ let eventId;
11
+ sdk.withScope((scope) => {
12
+ applySentryScopePolicy(scope, serviceName, context);
13
+ eventId = sdk.captureException(error);
14
+ });
15
+ return eventId;
16
+ }
17
+ catch {
18
+ return undefined;
19
+ }
20
+ }
21
+ export async function flushWithSentryPolicy(sdk, timeoutMs) {
22
+ try {
23
+ return await sdk.flush(timeoutMs);
24
+ }
25
+ catch {
26
+ return false;
27
+ }
28
+ }
29
+ export function applySentryScopePolicy(scope, serviceName, context) {
30
+ scope.setFingerprint([serviceName, DEFAULT_FINGERPRINT]);
31
+ scope.setTag("service.name", serviceName);
32
+ scope.setTag("veryfront.boundary", context.boundary);
33
+ if (context.method)
34
+ scope.setTag("http.request.method", context.method);
35
+ if (context.requestId)
36
+ scope.setTag("veryfront.request_id", context.requestId);
37
+ if (context.traceId) {
38
+ scope.setTag("grafana.trace_id", context.traceId);
39
+ scope.setContext("grafana_trace", {
40
+ trace_id: context.traceId,
41
+ ...(context.spanId ? { span_id: context.spanId } : {}),
42
+ });
43
+ }
44
+ if (context.attributes && Object.keys(context.attributes).length > 0) {
45
+ scope.setContext("veryfront_application_error", sanitizeApplicationErrorAttributes(context.attributes));
46
+ }
47
+ }
48
+ export function prepareSentryEvent(event, serviceName) {
49
+ event.tags = {
50
+ ...event.tags,
51
+ "service.name": serviceName,
52
+ };
53
+ event.fingerprint = [serviceName, ...(event.fingerprint ?? [DEFAULT_FINGERPRINT])];
54
+ delete event.breadcrumbs;
55
+ delete event.request;
56
+ delete event.user;
57
+ if (event.message)
58
+ event.message = redactSensitiveText(event.message);
59
+ if (event.logentry?.message) {
60
+ event.logentry.message = redactSensitiveText(event.logentry.message);
61
+ }
62
+ for (const value of event.exception?.values ?? []) {
63
+ if (value.value)
64
+ value.value = redactSensitiveText(value.value);
65
+ for (const frame of value.stacktrace?.frames ?? []) {
66
+ if (frame.filename)
67
+ frame.filename = sanitizeStackFramePath(frame.filename);
68
+ if (frame.abs_path)
69
+ frame.abs_path = sanitizeStackFramePath(frame.abs_path);
70
+ }
71
+ }
72
+ return event;
73
+ }
74
+ export function redactSensitiveText(value) {
75
+ return value
76
+ .replace(SENTRY_TOKEN_PATTERN, "[REDACTED]")
77
+ .replace(BEARER_TOKEN_PATTERN, "[REDACTED]")
78
+ .replace(JWT_PATTERN, "[REDACTED]")
79
+ .replace(URL_CREDENTIAL_PATTERN, "$1[REDACTED]$2")
80
+ .replace(SENSITIVE_QUERY_PATTERN, "$1[REDACTED]");
81
+ }
82
+ export function sanitizeApplicationErrorAttributes(attributes) {
83
+ const sanitized = {};
84
+ for (const [key, value] of Object.entries(attributes)) {
85
+ if (typeof value !== "string") {
86
+ sanitized[key] = value;
87
+ continue;
88
+ }
89
+ sanitized[key] = isSensitiveAttributeKey(key) ? "[REDACTED]" : redactSensitiveText(value);
90
+ }
91
+ return sanitized;
92
+ }
93
+ function isSensitiveAttributeKey(key) {
94
+ const normalized = key.replace(/([a-z0-9])([A-Z])/g, "$1_$2");
95
+ return SENSITIVE_ATTRIBUTE_KEY_PATTERN.test(normalized);
96
+ }
97
+ export function sanitizeStackFramePath(value) {
98
+ const redacted = redactSensitiveText(value);
99
+ const path = redacted.startsWith("file://") ? redacted.slice("file://".length) : redacted;
100
+ if (!path.startsWith("/") && !/^[A-Za-z]:[\\/]/.test(path))
101
+ return redacted;
102
+ const normalized = path.replaceAll("\\", "/");
103
+ const sourcePath = normalized.match(/(?:^|\/)((?:src|extensions|cli|dist)\/.+)$/)?.[1];
104
+ if (sourcePath)
105
+ return sourcePath;
106
+ const basename = normalized.split("/").filter(Boolean).at(-1);
107
+ return basename ? `[REDACTED]/${basename}` : "[REDACTED]";
108
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"veryfront-cloud-agent-service.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/veryfront-cloud-agent-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAG9E,OAAO,EAGL,KAAK,0BAA0B,EAChC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,KAAK,yBAAyB,EAI9B,KAAK,2BAA2B,EACjC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kDAAkD,EAAE,MAAM,2CAA2C,CAAC;AACpH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAClF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;;;;;CAM/C,CAAC;AAEF,yDAAyD;AACzD,wBAAsB,2CAA2C,CAC/D,OAAO,GAAE,qCAA0C,GAClD,OAAO,CAAC,yBAAyB,CAAC,+CAA+C,CAAC,CAAC,CAKrF;AAED,iDAAiD;AACjD,wBAAsB,mCAAmC,CACvD,OAAO,GAAE,qCAA0C,GAClD,OAAO,CAAC,2BAA2B,CAAC,+CAA+C,CAAC,CAAC,CAgBvF;AAED,4BAA4B;AAC5B,wBAAsB,iBAAiB,CACrC,OAAO,GAAE,qCAA0C,GAClD,OAAO,CAAC,IAAI,CAAC,CAoEf"}
@@ -62,10 +62,18 @@ export async function startAgentService(options = {}) {
62
62
  ...resolvedOptions,
63
63
  processTarget,
64
64
  });
65
+ let applicationErrors = {
66
+ captureStartupError: (_error) => { },
67
+ flush: () => Promise.resolve(true),
68
+ reset: () => { },
69
+ };
70
+ let startupErrorHandled = false;
65
71
  getRuntimeTraceContext = context.infrastructure.getTraceContext;
66
- await initializeNodeVeryfrontCloudAgentServiceContext(context);
67
72
  await runAgentServiceMain({
68
73
  loadLogger: () => context.infrastructure.logger,
74
+ initializeApplicationErrors: async () => {
75
+ applicationErrors = await context.infrastructure.initializeApplicationErrors();
76
+ },
69
77
  initializeTelemetry: async () => {
70
78
  return await context.infrastructure.initializeOpenTelemetry().catch((error) => {
71
79
  agentLogger.error("Failed to initialize OpenTelemetry:", { error });
@@ -80,6 +88,7 @@ export async function startAgentService(options = {}) {
80
88
  __registerTraceContextGetter(getter);
81
89
  },
82
90
  start: async () => {
91
+ await initializeNodeVeryfrontCloudAgentServiceContext(context);
83
92
  const registrationLifecycle = await createControlPlaneRegistrationLifecycle(context);
84
93
  try {
85
94
  await startAgentServiceRuntime({
@@ -94,8 +103,18 @@ export async function startAgentService(options = {}) {
94
103
  throw error;
95
104
  }
96
105
  },
97
- onStartupError: (error) => {
106
+ onStartupError: async (error) => {
107
+ applicationErrors.captureStartupError(error);
98
108
  agentLogger.error("Error in server startup:", { error });
109
+ await applicationErrors.flush();
110
+ applicationErrors.reset();
111
+ startupErrorHandled = true;
112
+ },
113
+ onFinally: async () => {
114
+ if (!startupErrorHandled) {
115
+ await applicationErrors.flush();
116
+ }
117
+ applicationErrors.reset();
99
118
  },
100
119
  exit: processTarget?.exit,
101
120
  processTarget,
@@ -11,6 +11,7 @@ export type AgentServiceBootstrapExit = (code: number) => never | void;
11
11
  /** Options accepted by bootstrap agent service. */
12
12
  export type BootstrapAgentServiceOptions = {
13
13
  loadLogger?: () => AbortRejectionGuardLogger | Promise<AbortRejectionGuardLogger>;
14
+ initializeApplicationErrors?: () => void | Promise<void>;
14
15
  initializeTelemetry?: () => boolean | Promise<boolean>;
15
16
  onTelemetryInitialized?: () => void | Promise<void>;
16
17
  getTraceContext?: AgentServiceTraceContextGetter;
@@ -20,6 +21,7 @@ export type BootstrapAgentServiceOptions = {
20
21
  /** Options accepted by run agent service main. */
21
22
  export type RunAgentServiceMainOptions = BootstrapAgentServiceOptions & {
22
23
  onStartupError?: (error: unknown) => void | Promise<void>;
24
+ onFinally?: () => void | Promise<void>;
23
25
  exit?: AgentServiceBootstrapExit;
24
26
  processTarget?: AbortRejectionProcessTarget | null;
25
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/service/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAEjC,MAAM,4BAA4B,CAAC;AAEpC,uCAAuC;AACvC,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,8BAA8B,GAAG,MAAM,wBAAwB,CAAC;AAE5E,4DAA4D;AAC5D,MAAM,MAAM,yBAAyB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,GAAG,IAAI,CAAC;AAEvE,mDAA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O,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBtF"}
@@ -5,6 +5,9 @@ async function initializeTelemetry(options) {
5
5
  await options.onTelemetryInitialized?.();
6
6
  }
7
7
  }
8
+ async function initializeApplicationErrors(options) {
9
+ await options.initializeApplicationErrors?.();
10
+ }
8
11
  async function registerTraceContext(options) {
9
12
  if (!options.getTraceContext || !options.registerTraceContextGetter) {
10
13
  return;
@@ -16,6 +19,7 @@ export async function bootstrapAgentService(options) {
16
19
  installAbortRejectionGuard({
17
20
  loadLogger: options.loadLogger,
18
21
  });
22
+ await initializeApplicationErrors(options);
19
23
  await initializeTelemetry(options);
20
24
  await registerTraceContext(options);
21
25
  await options.start();
@@ -26,7 +30,8 @@ export function runAgentServiceMain(options) {
26
30
  loadLogger: options.loadLogger,
27
31
  processTarget: options.processTarget,
28
32
  });
29
- return initializeTelemetry(options)
33
+ return initializeApplicationErrors(options)
34
+ .then(() => initializeTelemetry(options))
30
35
  .then(() => registerTraceContext(options))
31
36
  .then(() => options.start())
32
37
  .catch(async (error) => {
@@ -36,5 +41,8 @@ export function runAgentServiceMain(options) {
36
41
  return;
37
42
  }
38
43
  throw error;
44
+ })
45
+ .finally(async () => {
46
+ await options.onFinally?.();
39
47
  });
40
48
  }
@@ -2,10 +2,11 @@ import { createOpenTelemetryServiceTracer, type ServiceTracerAttributes } from "
2
2
  import { type Logger } from "../../utils/logger/index.js";
3
3
  import { type AgentServiceConfig, type AgentServiceConfigInput } from "./config.js";
4
4
  import { type NodeAgentServiceTelemetryEnv, type NodeAgentServiceTelemetryLogger, type NodeAgentServiceTelemetryProcessTarget } from "./node-telemetry.js";
5
+ import { type NodeAgentServiceApplicationErrorEnv, type NodeAgentServiceApplicationErrorLifecycle } from "./node-sentry.js";
5
6
  /** Options accepted by create node agent service runtime infrastructure. */
6
7
  export type CreateNodeAgentServiceRuntimeInfrastructureOptions = {
7
8
  serviceName: string;
8
- env: AgentServiceConfigInput & NodeAgentServiceTelemetryEnv;
9
+ env: AgentServiceConfigInput & NodeAgentServiceTelemetryEnv & NodeAgentServiceApplicationErrorEnv;
9
10
  telemetryLogger?: NodeAgentServiceTelemetryLogger;
10
11
  processTarget?: NodeAgentServiceTelemetryProcessTarget;
11
12
  };
@@ -21,6 +22,7 @@ export type NodeAgentServiceRuntimeInfrastructure = {
21
22
  traceId?: string;
22
23
  spanId?: string;
23
24
  };
25
+ initializeApplicationErrors(): Promise<NodeAgentServiceApplicationErrorLifecycle>;
24
26
  initializeOpenTelemetry(): Promise<boolean>;
25
27
  };
26
28
  /** Public API contract for node hosted agent service runtime infrastructure. */
@@ -1 +1 @@
1
- {"version":3,"file":"node-runtime-infrastructure.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/service/node-runtime-infrastructure.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gCAAgC,EAChC,KAAK,uBAAuB,EAC7B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAA2C,KAAK,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAE7B,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,+BAA+B,EACpC,KAAK,sCAAsC,EAE5C,MAAM,qBAAqB,CAAC;AAE7B,4EAA4E;AAC5E,MAAM,MAAM,kDAAkD,GAAG;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,uBAAuB,GAAG,4BAA4B,CAAC;IAC5D,eAAe,CAAC,EAAE,+BAA+B,CAAC;IAClD,aAAa,CAAC,EAAE,sCAAsC,CAAC;CACxD,CAAC;AAEF,mFAAmF;AACnF,MAAM,MAAM,wDAAwD,GAClE,kDAAkD,CAAC;AAErD,yEAAyE;AACzE,MAAM,MAAM,qCAAqC,GAAG;IAClD,SAAS,IAAI,kBAAkB,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,UAAU,CAAC,OAAO,gCAAgC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACtE,uBAAuB,CAAC,UAAU,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACnE,eAAe,IAAI;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7C,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,2CAA2C,GAAG,qCAAqC,CAAC;AAEhG,wDAAwD;AACxD,wBAAgB,2CAA2C,CACzD,OAAO,EAAE,kDAAkD,GAC1D,qCAAqC,CA0BvC;AAED,+DAA+D;AAC/D,eAAO,MAAM,iDAAiD,oDACjB,CAAC"}
1
+ {"version":3,"file":"node-runtime-infrastructure.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/service/node-runtime-infrastructure.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gCAAgC,EAChC,KAAK,uBAAuB,EAC7B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAA2C,KAAK,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAE7B,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,+BAA+B,EACpC,KAAK,sCAAsC,EAE5C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,mCAAmC,EACxC,KAAK,yCAAyC,EAC/C,MAAM,kBAAkB,CAAC;AAE1B,4EAA4E;AAC5E,MAAM,MAAM,kDAAkD,GAAG;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,uBAAuB,GAAG,4BAA4B,GAAG,mCAAmC,CAAC;IAClG,eAAe,CAAC,EAAE,+BAA+B,CAAC;IAClD,aAAa,CAAC,EAAE,sCAAsC,CAAC;CACxD,CAAC;AAEF,mFAAmF;AACnF,MAAM,MAAM,wDAAwD,GAClE,kDAAkD,CAAC;AAErD,yEAAyE;AACzE,MAAM,MAAM,qCAAqC,GAAG;IAClD,SAAS,IAAI,kBAAkB,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,UAAU,CAAC,OAAO,gCAAgC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACtE,uBAAuB,CAAC,UAAU,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACnE,eAAe,IAAI;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,2BAA2B,IAAI,OAAO,CAAC,yCAAyC,CAAC,CAAC;IAClF,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7C,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,2CAA2C,GAAG,qCAAqC,CAAC;AAEhG,wDAAwD;AACxD,wBAAgB,2CAA2C,CACzD,OAAO,EAAE,kDAAkD,GAC1D,qCAAqC,CAuCvC;AAED,+DAA+D;AAC/D,eAAO,MAAM,iDAAiD,oDACjB,CAAC"}
@@ -3,6 +3,7 @@ import { createOpenTelemetryServiceTracer, } from "../../observability/tracing/s
3
3
  import { __registerLogRecordEmitter, agentLogger } from "../../utils/logger/index.js";
4
4
  import { parseAgentServiceConfig, } from "./config.js";
5
5
  import { initializeNodeAgentServiceOpenTelemetry, resolveNodeAgentServiceTelemetryConfig, } from "./node-telemetry.js";
6
+ import { initializeNodeAgentServiceSentryApplicationErrors, } from "./node-sentry.js";
6
7
  /** Create node agent service runtime infrastructure. */
7
8
  export function createNodeAgentServiceRuntimeInfrastructure(options) {
8
9
  const telemetryConfig = resolveNodeAgentServiceTelemetryConfig({
@@ -21,6 +22,18 @@ export function createNodeAgentServiceRuntimeInfrastructure(options) {
21
22
  tracer: serviceTracer.tracer,
22
23
  setActiveSpanAttributes: serviceTracer.setActiveSpanAttributes,
23
24
  getTraceContext: serviceTracer.getTraceContext,
25
+ initializeApplicationErrors: () => initializeNodeAgentServiceSentryApplicationErrors({
26
+ env: options.env,
27
+ defaultServiceName: telemetryConfig.serviceName,
28
+ }).catch((error) => {
29
+ agentLogger.error("Failed to initialize Sentry application error reporting:", { error });
30
+ return {
31
+ enabled: false,
32
+ captureStartupError: () => { },
33
+ flush: () => Promise.resolve(true),
34
+ reset: () => { },
35
+ };
36
+ }),
24
37
  initializeOpenTelemetry: () => initializeNodeAgentServiceOpenTelemetry({
25
38
  ...telemetryConfig,
26
39
  logger: options.telemetryLogger,
@@ -0,0 +1,35 @@
1
+ import { type ApplicationErrorReporter } from "../../observability/application-errors.js";
2
+ import type { LogRecordEmitter } from "../../utils/logger/index.js";
3
+ /** Environment used by node agent service application-error reporting. */
4
+ export type NodeAgentServiceApplicationErrorEnv = Record<string, string | undefined>;
5
+ /** Configuration used by node agent service Sentry application-error reporting. */
6
+ export type NodeAgentServiceSentryConfig = {
7
+ dsn: string;
8
+ environment: string;
9
+ release?: string;
10
+ serviceName: string;
11
+ };
12
+ /** Application-error lifecycle returned by node agent service Sentry initialization. */
13
+ export type NodeAgentServiceApplicationErrorLifecycle = {
14
+ enabled: boolean;
15
+ captureStartupError(error: unknown): void;
16
+ flush(timeoutMs?: number): Promise<boolean>;
17
+ reset(): void;
18
+ };
19
+ type SentryExtensionModule = {
20
+ createNodeSentryApplicationErrorReporter(config: Required<NodeAgentServiceSentryConfig>): ApplicationErrorReporter;
21
+ };
22
+ type SentryExtensionLoader = () => Promise<SentryExtensionModule>;
23
+ /** Resolve node agent service Sentry config from environment. */
24
+ export declare function resolveNodeAgentServiceSentryConfig(env: NodeAgentServiceApplicationErrorEnv, defaultServiceName?: string): NodeAgentServiceSentryConfig | undefined;
25
+ /** Convert agent framework error logs to application errors. */
26
+ export declare function createNodeAgentServiceLogApplicationErrorEmitter(): LogRecordEmitter;
27
+ /** Initialize node agent service Sentry application-error reporting. */
28
+ export declare function initializeNodeAgentServiceSentryApplicationErrors(options: {
29
+ env: NodeAgentServiceApplicationErrorEnv;
30
+ defaultServiceName?: string;
31
+ loadExtension?: SentryExtensionLoader;
32
+ flushTimeoutMs?: number;
33
+ }): Promise<NodeAgentServiceApplicationErrorLifecycle>;
34
+ export {};
35
+ //# sourceMappingURL=node-sentry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-sentry.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/service/node-sentry.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,wBAAwB,EAI9B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAY,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAI9E,0EAA0E;AAC1E,MAAM,MAAM,mCAAmC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAErF,mFAAmF;AACnF,MAAM,MAAM,4BAA4B,GAAG;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wFAAwF;AACxF,MAAM,MAAM,yCAAyC,GAAG;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1C,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,wCAAwC,CACtC,MAAM,EAAE,QAAQ,CAAC,4BAA4B,CAAC,GAC7C,wBAAwB,CAAC;CAC7B,CAAC;AAEF,KAAK,qBAAqB,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAC;AA2BlE,iEAAiE;AACjE,wBAAgB,mCAAmC,CACjD,GAAG,EAAE,mCAAmC,EACxC,kBAAkB,SAAuB,GACxC,4BAA4B,GAAG,SAAS,CA4B1C;AAkFD,gEAAgE;AAChE,wBAAgB,gDAAgD,IAAI,gBAAgB,CAKnF;AAkCD,wEAAwE;AACxE,wBAAsB,iDAAiD,CAAC,OAAO,EAAE;IAC/E,GAAG,EAAE,mCAAmC,CAAC;IACzC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAyDrD"}
@@ -0,0 +1,242 @@
1
+ import { isMissingFirstPartyExtensionModule } from "../../extensions/first-party-import.js";
2
+ import { captureApplicationError, flushApplicationErrors, setApplicationErrorReporter, } from "../../observability/application-errors.js";
3
+ import { __subscribeLogRecordEmitter } from "../../utils/logger/index.js";
4
+ import { VERSION } from "../../utils/version.js";
5
+ const DEFAULT_SERVICE_NAME = "veryfront-agent";
6
+ const DEFAULT_ENVIRONMENT = "production";
7
+ const DEFAULT_FLUSH_TIMEOUT_MS = 2_000;
8
+ const EXPECTED_ERROR_CODES = new Set([
9
+ "AUTHENTICATION_REQUIRED",
10
+ "CONTROL_PLANE_RUN_ID_MISMATCH",
11
+ "FORBIDDEN",
12
+ "INVALID_ARGUMENT",
13
+ "NOT_FOUND",
14
+ "PROJECT_ACCESS_DENIED",
15
+ "VALIDATION_ERROR",
16
+ ]);
17
+ let currentInitializationId = 0;
18
+ let currentLifecycle;
19
+ let currentLifecycleOwner;
20
+ function readTrimmedEnv(env, key) {
21
+ const value = env[key]?.trim();
22
+ return value ? value : undefined;
23
+ }
24
+ /** Resolve node agent service Sentry config from environment. */
25
+ export function resolveNodeAgentServiceSentryConfig(env, defaultServiceName = DEFAULT_SERVICE_NAME) {
26
+ const dsn = readTrimmedEnv(env, "SENTRY_DSN");
27
+ if (!dsn)
28
+ return undefined;
29
+ const serviceName = readTrimmedEnv(env, "SENTRY_SERVICE_NAME") ??
30
+ readTrimmedEnv(env, "SENTRY_SERVICE") ??
31
+ readTrimmedEnv(env, "OTEL_SERVICE_NAME") ??
32
+ readTrimmedEnv(env, "npm_package_name") ??
33
+ defaultServiceName;
34
+ const environment = readTrimmedEnv(env, "SENTRY_ENVIRONMENT") ??
35
+ readTrimmedEnv(env, "APP_ENVIRONMENT") ??
36
+ readTrimmedEnv(env, "VERYFRONT_ENV") ??
37
+ readTrimmedEnv(env, "VERYFRONT_ENVIRONMENT") ??
38
+ readTrimmedEnv(env, "NODE_ENV") ??
39
+ DEFAULT_ENVIRONMENT;
40
+ const release = readTrimmedEnv(env, "SENTRY_RELEASE") ??
41
+ readTrimmedEnv(env, "OTEL_SERVICE_VERSION") ??
42
+ readTrimmedEnv(env, "RELEASE_VERSION") ??
43
+ readTrimmedEnv(env, "VERYFRONT_VERSION") ??
44
+ readTrimmedEnv(env, "npm_package_version") ??
45
+ VERSION;
46
+ return {
47
+ dsn,
48
+ environment,
49
+ ...(release ? { release } : {}),
50
+ serviceName,
51
+ };
52
+ }
53
+ function getExpectedErrorCode(entry) {
54
+ const code = entry.context?.errorCode ?? entry.context?.error_code ?? entry.context?.code;
55
+ return typeof code === "string" ? code : undefined;
56
+ }
57
+ function getStatusCode(entry) {
58
+ const status = entry.context?.statusCode ?? entry.context?.status_code ?? entry.context?.status;
59
+ return typeof status === "number" && Number.isInteger(status) ? status : undefined;
60
+ }
61
+ function isExpectedAgentErrorLog(entry) {
62
+ if (entry.error?.name === "AbortError")
63
+ return true;
64
+ const errorCode = getExpectedErrorCode(entry);
65
+ if (errorCode && EXPECTED_ERROR_CODES.has(errorCode))
66
+ return true;
67
+ const statusCode = getStatusCode(entry);
68
+ return statusCode !== undefined && statusCode >= 400 && statusCode < 500;
69
+ }
70
+ function addPrimitiveAttribute(attributes, key, value) {
71
+ if (typeof value === "string" || typeof value === "boolean") {
72
+ attributes[key] = value;
73
+ return;
74
+ }
75
+ if (typeof value === "number" && Number.isFinite(value)) {
76
+ attributes[key] = value;
77
+ }
78
+ }
79
+ function buildLogAttributes(entry) {
80
+ const attributes = {};
81
+ addPrimitiveAttribute(attributes, "log.service", entry.service);
82
+ addPrimitiveAttribute(attributes, "log.component", entry.component);
83
+ addPrimitiveAttribute(attributes, "request.id", entry.request_id ?? entry.requestId);
84
+ addPrimitiveAttribute(attributes, "trace.id", entry.trace_id ?? entry.traceId);
85
+ addPrimitiveAttribute(attributes, "span.id", entry.span_id ?? entry.spanId);
86
+ addPrimitiveAttribute(attributes, "project.id", entry.project_id);
87
+ addPrimitiveAttribute(attributes, "project.slug", entry.project_slug ?? entry.projectSlug);
88
+ addPrimitiveAttribute(attributes, "release.id", entry.release_id);
89
+ addPrimitiveAttribute(attributes, "branch.id", entry.branch_id);
90
+ addPrimitiveAttribute(attributes, "branch.name", entry.branch_name);
91
+ addPrimitiveAttribute(attributes, "run.execution_id", entry.run_execution_id);
92
+ addPrimitiveAttribute(attributes, "run.id", entry.run_id);
93
+ addPrimitiveAttribute(attributes, "agent.id", entry.agent_id);
94
+ addPrimitiveAttribute(attributes, "conversation.id", entry.conversation_id ?? entry.conversationId);
95
+ addPrimitiveAttribute(attributes, "schedule.id", entry.schedule_id);
96
+ addPrimitiveAttribute(attributes, "schedule.name", entry.schedule_name);
97
+ addPrimitiveAttribute(attributes, "tool.name", entry.tool_name);
98
+ addPrimitiveAttribute(attributes, "tool.call_id", entry.tool_call_id);
99
+ addPrimitiveAttribute(attributes, "task", entry.task);
100
+ addPrimitiveAttribute(attributes, "event.kind", entry.event_kind);
101
+ addPrimitiveAttribute(attributes, "duration.ms", entry.duration_ms ?? entry.durationMs);
102
+ return attributes;
103
+ }
104
+ function errorFromLogEntry(entry) {
105
+ if (!entry.error)
106
+ return new Error(entry.message);
107
+ const error = new Error(entry.error.message);
108
+ error.name = entry.error.name;
109
+ error.stack = entry.error.stack;
110
+ return error;
111
+ }
112
+ function contextFromLogEntry(entry) {
113
+ return {
114
+ boundary: "agent.framework-log",
115
+ requestId: entry.request_id ?? entry.requestId,
116
+ spanId: entry.span_id ?? entry.spanId,
117
+ traceId: entry.trace_id ?? entry.traceId,
118
+ attributes: buildLogAttributes(entry),
119
+ };
120
+ }
121
+ /** Convert agent framework error logs to application errors. */
122
+ export function createNodeAgentServiceLogApplicationErrorEmitter() {
123
+ return (entry) => {
124
+ if (entry.level !== "error" || isExpectedAgentErrorLog(entry))
125
+ return;
126
+ captureApplicationError(errorFromLogEntry(entry), contextFromLogEntry(entry));
127
+ };
128
+ }
129
+ function defaultLifecycle() {
130
+ return {
131
+ enabled: false,
132
+ captureStartupError: () => { },
133
+ flush: () => Promise.resolve(true),
134
+ reset: () => { },
135
+ };
136
+ }
137
+ function deactivateCurrentLifecycle() {
138
+ currentLifecycle?.reset();
139
+ currentLifecycle = undefined;
140
+ currentLifecycleOwner = undefined;
141
+ }
142
+ async function withWallClockTimeout(operation, timeoutMs) {
143
+ let timeoutId;
144
+ try {
145
+ return await Promise.race([
146
+ operation.catch(() => false),
147
+ new Promise((resolve) => {
148
+ timeoutId = setTimeout(() => resolve(false), Math.max(0, timeoutMs));
149
+ }),
150
+ ]);
151
+ }
152
+ finally {
153
+ if (timeoutId !== undefined)
154
+ clearTimeout(timeoutId);
155
+ }
156
+ }
157
+ /** Initialize node agent service Sentry application-error reporting. */
158
+ export async function initializeNodeAgentServiceSentryApplicationErrors(options) {
159
+ const initializationId = ++currentInitializationId;
160
+ deactivateCurrentLifecycle();
161
+ const config = resolveNodeAgentServiceSentryConfig(options.env, options.defaultServiceName);
162
+ if (!config)
163
+ return defaultLifecycle();
164
+ const extension = await (options.loadExtension ?? loadNodeSentryExtension)();
165
+ if (initializationId !== currentInitializationId)
166
+ return defaultLifecycle();
167
+ const reporter = extension.createNodeSentryApplicationErrorReporter({
168
+ dsn: config.dsn,
169
+ environment: config.environment,
170
+ release: config.release ?? "",
171
+ serviceName: config.serviceName,
172
+ });
173
+ setApplicationErrorReporter(reporter);
174
+ const owner = Symbol("node-agent-service-sentry");
175
+ const unsubscribeLogCapture = __subscribeLogRecordEmitter(createNodeAgentServiceLogApplicationErrorEmitter());
176
+ currentLifecycleOwner = owner;
177
+ let active = true;
178
+ let logCaptureActive = true;
179
+ const flushTimeoutMs = options.flushTimeoutMs ?? DEFAULT_FLUSH_TIMEOUT_MS;
180
+ const lifecycle = {
181
+ enabled: true,
182
+ captureStartupError(error) {
183
+ if (!active || currentLifecycleOwner !== owner)
184
+ return;
185
+ if (logCaptureActive) {
186
+ logCaptureActive = false;
187
+ unsubscribeLogCapture();
188
+ }
189
+ captureApplicationError(error, { boundary: "agent.process.startup" });
190
+ },
191
+ flush(timeoutMs = flushTimeoutMs) {
192
+ if (!active || currentLifecycleOwner !== owner)
193
+ return Promise.resolve(true);
194
+ return withWallClockTimeout(flushApplicationErrors(timeoutMs), timeoutMs);
195
+ },
196
+ reset() {
197
+ if (!active)
198
+ return;
199
+ active = false;
200
+ if (logCaptureActive) {
201
+ logCaptureActive = false;
202
+ unsubscribeLogCapture();
203
+ }
204
+ if (currentLifecycleOwner === owner) {
205
+ currentLifecycleOwner = undefined;
206
+ currentLifecycle = undefined;
207
+ setApplicationErrorReporter(undefined);
208
+ }
209
+ },
210
+ };
211
+ currentLifecycle = lifecycle;
212
+ return lifecycle;
213
+ }
214
+ async function loadNodeSentryExtension() {
215
+ let sourceError;
216
+ for (const sourceSpecifier of [
217
+ "../../../extensions/ext-observability-sentry/src/node.ts",
218
+ "../../../extensions/ext-observability-sentry/src/node.js",
219
+ ]) {
220
+ try {
221
+ return await import(sourceSpecifier);
222
+ }
223
+ catch (error) {
224
+ if (!isMissingFirstPartyExtensionModule(error, ["extensions/ext-observability-sentry/src/node"])) {
225
+ throw error;
226
+ }
227
+ sourceError ??= error;
228
+ }
229
+ }
230
+ try {
231
+ return await import("../../../extensions/ext-observability-sentry/src/node.js");
232
+ }
233
+ catch (error) {
234
+ if (!isMissingFirstPartyExtensionModule(error, ["@veryfront/ext-observability-sentry/node"])) {
235
+ throw error;
236
+ }
237
+ if (error instanceof Error && sourceError !== undefined && error.cause === undefined) {
238
+ error.cause = sourceError;
239
+ }
240
+ throw error;
241
+ }
242
+ }
@@ -4,6 +4,7 @@ export type ApplicationErrorContext = {
4
4
  requestId?: string;
5
5
  spanId?: string;
6
6
  traceId?: string;
7
+ attributes?: Record<string, string | number | boolean>;
7
8
  };
8
9
  export type ApplicationErrorReporter = {
9
10
  capture(error: unknown, context: ApplicationErrorContext): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"application-errors.d.ts","sourceRoot":"","sources":["../../../src/src/observability/application-errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,GAAG,MAAM,GAAG,SAAS,CAAC;IAC9E,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7C,CAAC;AAIF,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,wBAAwB,GAAG,SAAS,GACjD,IAAI,CAEN;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,uBAAuB,GAC/B,MAAM,GAAG,SAAS,CAGpB;AAED,wBAAgB,sBAAsB,CAAC,SAAS,SAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAE1E;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAElE"}
1
+ {"version":3,"file":"application-errors.d.ts","sourceRoot":"","sources":["../../../src/src/observability/application-errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,GAAG,MAAM,GAAG,SAAS,CAAC;IAC9E,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7C,CAAC;AAIF,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,wBAAwB,GAAG,SAAS,GACjD,IAAI,CAEN;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,uBAAuB,GAC/B,MAAM,GAAG,SAAS,CAOpB;AAED,wBAAgB,sBAAsB,CAAC,SAAS,SAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAM1E;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAElE"}
@@ -5,10 +5,20 @@ export function setApplicationErrorReporter(nextReporter) {
5
5
  export function captureApplicationError(error, context) {
6
6
  if (isExpectedApplicationError(error))
7
7
  return undefined;
8
- return reporter?.capture(error, context);
8
+ try {
9
+ return reporter?.capture(error, context);
10
+ }
11
+ catch {
12
+ return undefined;
13
+ }
9
14
  }
10
15
  export function flushApplicationErrors(timeoutMs = 2_000) {
11
- return reporter?.flush(timeoutMs) ?? Promise.resolve(true);
16
+ try {
17
+ return reporter?.flush(timeoutMs) ?? Promise.resolve(true);
18
+ }
19
+ catch {
20
+ return Promise.resolve(false);
21
+ }
12
22
  }
13
23
  export function isExpectedApplicationError(error) {
14
24
  return error instanceof DOMException && error.name === "AbortError";
@@ -4,7 +4,7 @@
4
4
  * @module utils/logger
5
5
  */
6
6
  import "../../../_dnt.polyfills.js";
7
- export { __registerLogRecordEmitter, __registerRequestContextGetter, __registerTraceContextGetter, __resetLoggerConfigForTests, __resetLogRecordEmitterForTests, __resetTraceContextGetterForTests, agentLogger, bundlerLogger, cliLogger, createRequestLogger, createRunUserLogger, getBaseLogger, getDefaultLevel, type LogEntry, type LogFormat, type Logger, logger, LogLevel, proxyLogger, refreshLoggerConfig, rendererLogger, serverLogger, setLoggerPreset, setLogLevel, } from "./logger.js";
7
+ export { __registerLogRecordEmitter, __registerRequestContextGetter, __registerTraceContextGetter, __resetLoggerConfigForTests, __resetLogRecordEmitterForTests, __resetTraceContextGetterForTests, __subscribeLogRecordEmitter, agentLogger, bundlerLogger, cliLogger, createRequestLogger, createRunUserLogger, getBaseLogger, getDefaultLevel, type LogEntry, type LogFormat, type Logger, logger, LogLevel, type LogRecordEmitter, proxyLogger, refreshLoggerConfig, rendererLogger, serverLogger, setLoggerPreset, setLogLevel, } from "./logger.js";
8
8
  export { ANSI, colorize, formatContextText, formatErrorText, formatTimestamp, formatValue, isRecord, LEVEL_COLORS, LEVEL_GLYPHS, type LogLevelName, normalizeText, padTag, PREFIX_WIDTH, type SerializedError, serializeError, TAG_WIDTH, truncateText, } from "./core.js";
9
9
  export { getRequestContext, getRequestLogger, type RequestContext, requestContextStore, runWithRequestContext, runWithRequestContextAsync, } from "./request-context.js";
10
10
  export { type LogComponent, LogComponents } from "./components.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,4BAA4B,CAAC;AAGpC,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,4BAA4B,EAC5B,2BAA2B,EAC3B,+BAA+B,EAC/B,iCAAiC,EACjC,WAAW,EACX,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,MAAM,EACX,MAAM,EACN,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,KAAK,YAAY,EACjB,aAAa,EACb,MAAM,EACN,YAAY,EACZ,KAAK,eAAe,EACpB,cAAc,EACd,SAAS,EACT,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,cAAc,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,4BAA4B,CAAC;AAGpC,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,4BAA4B,EAC5B,2BAA2B,EAC3B,+BAA+B,EAC/B,iCAAiC,EACjC,2BAA2B,EAC3B,WAAW,EACX,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,MAAM,EACX,MAAM,EACN,QAAQ,EACR,KAAK,gBAAgB,EACrB,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,KAAK,YAAY,EACjB,aAAa,EACb,MAAM,EACN,YAAY,EACZ,KAAK,eAAe,EACpB,cAAc,EACd,SAAS,EACT,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,cAAc,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * @module utils/logger
5
5
  */
6
6
  import "../../../_dnt.polyfills.js";
7
- export { __registerLogRecordEmitter, __registerRequestContextGetter, __registerTraceContextGetter, __resetLoggerConfigForTests, __resetLogRecordEmitterForTests, __resetTraceContextGetterForTests, agentLogger, bundlerLogger, cliLogger, createRequestLogger, createRunUserLogger, getBaseLogger, getDefaultLevel, logger, LogLevel, proxyLogger, refreshLoggerConfig, rendererLogger, serverLogger, setLoggerPreset, setLogLevel, } from "./logger.js";
7
+ export { __registerLogRecordEmitter, __registerRequestContextGetter, __registerTraceContextGetter, __resetLoggerConfigForTests, __resetLogRecordEmitterForTests, __resetTraceContextGetterForTests, __subscribeLogRecordEmitter, agentLogger, bundlerLogger, cliLogger, createRequestLogger, createRunUserLogger, getBaseLogger, getDefaultLevel, logger, LogLevel, proxyLogger, refreshLoggerConfig, rendererLogger, serverLogger, setLoggerPreset, setLogLevel, } from "./logger.js";
8
8
  export { ANSI, colorize, formatContextText, formatErrorText, formatTimestamp, formatValue, isRecord, LEVEL_COLORS, LEVEL_GLYPHS, normalizeText, padTag, PREFIX_WIDTH, serializeError, TAG_WIDTH, truncateText, } from "./core.js";
9
9
  export { getRequestContext, getRequestLogger, requestContextStore, runWithRequestContext, runWithRequestContextAsync, } from "./request-context.js";
10
10
  export { LogComponents } from "./components.js";
@@ -81,7 +81,7 @@ export interface Logger {
81
81
  type ConsoleLoggerOptions = {
82
82
  injectTraceContext?: boolean;
83
83
  };
84
- type LogRecordEmitter = (entry: LogEntry) => void;
84
+ export type LogRecordEmitter = (entry: LogEntry) => void;
85
85
  /**
86
86
  * Determine the log level based on environment variables.
87
87
  * Exported for testing purposes.
@@ -111,6 +111,8 @@ export declare function setLogLevel(level: LogLevel): void;
111
111
  export declare const __resetLoggerConfigForTests: typeof refreshLoggerConfig;
112
112
  /** Register a process-level structured log emitter, for example an OTel bridge. */
113
113
  export declare function __registerLogRecordEmitter(emitter: LogRecordEmitter | null): void;
114
+ /** Subscribe to process-level structured log records. Returns an unregister function. */
115
+ export declare function __subscribeLogRecordEmitter(emitter: LogRecordEmitter): () => void;
114
116
  /** Reset the process-level structured log emitter. Only intended for tests. */
115
117
  export declare function __resetLogRecordEmitterForTests(): void;
116
118
  declare class ConsoleLogger implements Logger {
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/logger.ts"],"names":[],"mappings":"AAIA,OAAO,EAOL,KAAK,YAAY,EAEjB,KAAK,eAAe,EAErB,MAAM,WAAW,CAAC;AAGnB,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAEhB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElC,KAAK,CAAC,EAAE,eAAe,CAAC;IAExB,kJAAkJ;IAClJ,SAAS,CAAC,EAAE,MAAM,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,SAAS,QAA0C,CAAC;AACjE,kCAAkC;AAClC,eAAO,MAAM,YAAY,QAA6C,CAAC;AACvE,oCAAoC;AACpC,eAAO,MAAM,cAAc,QAA+C,CAAC;AAC3E,mCAAmC;AACnC,eAAO,MAAM,aAAa,QAA8C,CAAC;AACzE,iCAAiC;AACjC,eAAO,MAAM,WAAW,QAA4C,CAAC;AACrE,eAAO,MAAM,WAAW,QAA4C,CAAC;AACrE,2BAA2B;AAC3B,eAAO,MAAM,MAAM,QAAuC,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,oBAAoB,GAC7B,aAAa,CASf;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACA,MAAM,CAER;AAED,8BAA8B;AAC9B,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,MAAM,CAUR"}
@@ -54,7 +54,8 @@ function getDefaultFormat(envFormat = getHostEnv("LOG_FORMAT"), envMode = getHos
54
54
  * per-request project env overlay cannot change process-level logger config.
55
55
  */
56
56
  let loggerConfig = null;
57
- let logRecordEmitter = null;
57
+ let legacyLogRecordEmitter = null;
58
+ const logRecordSubscribers = new Set();
58
59
  /**
59
60
  * Re-read logger configuration from environment variables.
60
61
  * Call after loading .env files so the logger picks up any overrides.
@@ -90,11 +91,19 @@ export function setLogLevel(level) {
90
91
  export const __resetLoggerConfigForTests = refreshLoggerConfig;
91
92
  /** Register a process-level structured log emitter, for example an OTel bridge. */
92
93
  export function __registerLogRecordEmitter(emitter) {
93
- logRecordEmitter = emitter;
94
+ legacyLogRecordEmitter = emitter;
95
+ }
96
+ /** Subscribe to process-level structured log records. Returns an unregister function. */
97
+ export function __subscribeLogRecordEmitter(emitter) {
98
+ logRecordSubscribers.add(emitter);
99
+ return () => {
100
+ logRecordSubscribers.delete(emitter);
101
+ };
94
102
  }
95
103
  /** Reset the process-level structured log emitter. Only intended for tests. */
96
104
  export function __resetLogRecordEmitterForTests() {
97
- logRecordEmitter = null;
105
+ legacyLogRecordEmitter = null;
106
+ logRecordSubscribers.clear();
98
107
  }
99
108
  function resolveLoggerConfig() {
100
109
  if (loggerConfig === null) {
@@ -329,9 +338,20 @@ class ConsoleLogger {
329
338
  return JSON.stringify(entry);
330
339
  })()
331
340
  : this.formatTextLine(level, message, args);
332
- if (logRecordEmitter) {
341
+ const emittedEntry = entry ?? this.createEntry(level, message, args);
342
+ if (legacyLogRecordEmitter) {
343
+ try {
344
+ legacyLogRecordEmitter(emittedEntry);
345
+ }
346
+ catch (_) {
347
+ /* do not let telemetry export failures affect application logging */
348
+ }
349
+ }
350
+ for (const subscriber of logRecordSubscribers) {
351
+ if (subscriber === legacyLogRecordEmitter)
352
+ continue;
333
353
  try {
334
- logRecordEmitter(entry ?? this.createEntry(level, message, args));
354
+ subscriber(emittedEntry);
335
355
  }
336
356
  catch (_) {
337
357
  /* do not let telemetry export failures affect application logging */
@@ -1,3 +1,3 @@
1
1
  /** Shared version value. */
2
- export declare const VERSION = "0.1.1174";
2
+ export declare const VERSION = "0.1.1175";
3
3
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
3
  /** Shared version value. */
4
- export const VERSION = "0.1.1174";
4
+ export const VERSION = "0.1.1175";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.1174",
3
+ "version": "0.1.1175",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",
@@ -344,10 +344,10 @@
344
344
  "@types/react": "19.2.14",
345
345
  "@types/react-dom": "19.2.3",
346
346
  "ws": "8.21.0",
347
- "@veryfront/ext-bundler-esbuild": "0.1.1174",
348
- "@veryfront/ext-content-mdx": "0.1.1174",
349
- "@veryfront/ext-css-tailwind": "0.1.1174",
350
- "@veryfront/ext-parser-babel": "0.1.1174"
347
+ "@veryfront/ext-bundler-esbuild": "0.1.1175",
348
+ "@veryfront/ext-content-mdx": "0.1.1175",
349
+ "@veryfront/ext-css-tailwind": "0.1.1175",
350
+ "@veryfront/ext-parser-babel": "0.1.1175"
351
351
  },
352
352
  "devDependencies": {
353
353
  "@types/node": "20.9.0"