@farm.js/core 0.1.25 → 0.1.26
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.
- package/dist/agent-runtime.d.mts +2 -2
- package/dist/agent-runtime.d.ts +2 -2
- package/dist/api/route-manager.d.mts +2 -2
- package/dist/api/route-manager.d.ts +2 -2
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/{app-ZuWrAMc_.d.mts → app-29vG5tmY.d.mts} +3 -3
- package/dist/{app-BF-ctoxh.d.ts → app-Cx71s_PT.d.ts} +3 -3
- package/dist/app-markdown.cjs +6 -4
- package/dist/app-markdown.d.mts +3 -3
- package/dist/app-markdown.d.ts +3 -3
- package/dist/app-markdown.mjs +5 -3
- package/dist/{chunk-E3RDL2DA.cjs → chunk-2CT6XUNO.cjs} +61 -31
- package/dist/{chunk-R7LCG3BT.cjs → chunk-3TQG7CGC.cjs} +84 -77
- package/dist/{chunk-AXYTGLF3.cjs → chunk-3WSWXPYM.cjs} +4 -4
- package/dist/{chunk-2BIJGZR3.mjs → chunk-74RZNRY6.mjs} +1 -1
- package/dist/{chunk-TTVHACQV.cjs → chunk-ALIFMS4A.cjs} +1 -1
- package/dist/{chunk-T2OPSH6S.mjs → chunk-ARXCHQLX.mjs} +9 -2
- package/dist/{chunk-2KI3CL3N.mjs → chunk-DU2CASV6.mjs} +1 -1
- package/dist/chunk-J63ZH5OQ.cjs +62 -0
- package/dist/{chunk-XM4ZDVD7.mjs → chunk-JM5GQL4H.mjs} +1 -1
- package/dist/{chunk-6VEHUKZ2.mjs → chunk-MM5D6VLP.mjs} +4 -20
- package/dist/chunk-MVL2RAJW.mjs +62 -0
- package/dist/{chunk-YA6LLTIJ.cjs → chunk-ND224OE2.cjs} +4 -20
- package/dist/{chunk-XME4TCLB.mjs → chunk-OFKG57MZ.mjs} +2 -2
- package/dist/{chunk-U4MP7XTD.mjs → chunk-OOIL3BWR.mjs} +168 -16
- package/dist/{chunk-WOI2HOGA.mjs → chunk-PPIW3MH6.mjs} +1 -1
- package/dist/{chunk-2ITKVAIF.cjs → chunk-QIH2HD6H.cjs} +191 -39
- package/dist/{chunk-65P6OGYN.cjs → chunk-QJ4D3UKJ.cjs} +10 -3
- package/dist/{chunk-RYDW7GPR.cjs → chunk-QLXEYIAW.cjs} +13 -13
- package/dist/{chunk-WJYCI56T.mjs → chunk-QPPQHB6X.mjs} +43 -30
- package/dist/{chunk-RR6UGYUT.mjs → chunk-RAI7NULA.mjs} +39 -9
- package/dist/{chunk-6K4SPQWL.cjs → chunk-RCYINC4A.cjs} +3 -3
- package/dist/{chunk-QYMRIVG6.cjs → chunk-SZ4LYNUX.cjs} +110 -97
- package/dist/{chunk-N2Z4ZFDE.mjs → chunk-UXQXGB5A.mjs} +19 -12
- package/dist/{chunk-CFNOGDUS.cjs → chunk-W2HZKYES.cjs} +2 -2
- package/dist/{chunk-O5DVPF3R.cjs → chunk-WFPRVVF2.cjs} +10 -10
- package/dist/{chunk-5YYJ6Q2L.mjs → chunk-YMUH2BLR.mjs} +2 -2
- package/dist/{client-plugins-DPG0NeZN.d.mts → client-plugins-B8RPJnot.d.mts} +90 -3
- package/dist/{client-plugins-Fgni-_25.d.ts → client-plugins-bPBf4haK.d.ts} +90 -3
- package/dist/client-plugins.d.mts +2 -2
- package/dist/client-plugins.d.ts +2 -2
- package/dist/client.d.mts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/config.d.mts +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/{devtools-I7TBFOKD.mjs → devtools-5D4ZDRPR.mjs} +5 -3
- package/dist/{devtools-6OA7FEF6.cjs → devtools-QZJEUOJW.cjs} +6 -4
- package/dist/docs.cjs +8 -6
- package/dist/docs.mjs +7 -5
- package/dist/index.cjs +17 -13
- package/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.mjs +16 -12
- package/dist/integrations.d.mts +2 -2
- package/dist/integrations.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.cjs +5 -3
- package/dist/internal/app-markdown-runtime.d.mts +2 -2
- package/dist/internal/app-markdown-runtime.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.mjs +4 -2
- package/dist/internal/build-runtime.cjs +14 -13
- package/dist/internal/build-runtime.d.mts +4 -4
- package/dist/internal/build-runtime.d.ts +4 -4
- package/dist/internal/build-runtime.mjs +13 -12
- package/dist/internal/cli-runtime.cjs +6 -5
- package/dist/internal/cli-runtime.mjs +5 -4
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +2 -2
- package/dist/internal/compression-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.cjs +6 -4
- package/dist/internal/config-runtime.d.mts +3 -3
- package/dist/internal/config-runtime.d.ts +3 -3
- package/dist/internal/config-runtime.mjs +5 -3
- package/dist/internal/infra-analytics-runtime.cjs +4 -3
- package/dist/internal/infra-analytics-runtime.mjs +2 -1
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +5 -4
- package/dist/internal/production-runtime.d.mts +11 -9
- package/dist/internal/production-runtime.d.ts +11 -9
- package/dist/internal/production-runtime.mjs +4 -3
- package/dist/markdown.cjs +4 -2
- package/dist/markdown.mjs +3 -1
- package/dist/{metadata-D0EF7esB.d.mts → metadata-C3na4CBj.d.mts} +1 -1
- package/dist/{metadata-CDnRHKVq.d.ts → metadata-CzBP4Mfp.d.ts} +1 -1
- package/dist/middleware.d.mts +4 -4
- package/dist/middleware.d.ts +4 -4
- package/dist/navigation.d.mts +5 -5
- package/dist/navigation.d.ts +5 -5
- package/dist/observability-BupkiN0m.d.mts +447 -0
- package/dist/observability-BupkiN0m.d.ts +447 -0
- package/dist/observability.d.mts +2 -417
- package/dist/observability.d.ts +2 -417
- package/dist/plugin.cjs +9 -8
- package/dist/plugin.d.mts +2 -2
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.mjs +8 -7
- package/dist/{production-runtime-DpCt0opU.d.ts → production-runtime-CYg4wM4E.d.ts} +1 -1
- package/dist/{production-runtime-x3W4wVqx.d.mts → production-runtime-DP94hPGe.d.mts} +1 -1
- package/dist/{render-plan-D5oFRVBV.d.ts → render-plan-Bl6Fzg5z.d.ts} +1 -1
- package/dist/{render-plan-tazUJalK.d.mts → render-plan-CKAJg0jC.d.mts} +1 -1
- package/dist/renderer-client.d.mts +4 -4
- package/dist/renderer-client.d.ts +4 -4
- package/dist/{request-CzZX0Aew.d.ts → request-CR-Bp1Px.d.ts} +1 -1
- package/dist/{request-CXmQy5ks.d.mts → request-CrBCcPZZ.d.mts} +1 -1
- package/dist/request.d.mts +3 -3
- package/dist/request.d.ts +3 -3
- package/dist/{route-rendering-B-qpe32B.d.mts → route-rendering-C1NAHo-C.d.mts} +1 -1
- package/dist/{route-rendering-Dw3C362T.d.ts → route-rendering-CZH5FegB.d.ts} +1 -1
- package/dist/{router-CafM2jlw.d.mts → router-B57eDJ3u.d.mts} +1 -1
- package/dist/{router-CLl3xHwl.d.ts → router-Cg_kD3Bd.d.ts} +1 -1
- package/dist/routes.d.mts +2 -2
- package/dist/routes.d.ts +2 -2
- package/dist/server-plugins.d.mts +3 -3
- package/dist/server-plugins.d.ts +3 -3
- package/dist/server.cjs +159 -102
- package/dist/server.d.mts +8 -8
- package/dist/server.d.ts +8 -8
- package/dist/server.mjs +140 -83
- package/dist/{spa-router-DePr2aZ6.d.ts → spa-router-BstQUO6Q.d.ts} +2 -2
- package/dist/{spa-router-6sJfsMlQ.d.mts → spa-router-DTdbuinx.d.mts} +2 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/{utils-BPHr-1mP.d.mts → utils-CS3ZLnEJ.d.mts} +1 -1
- package/dist/{utils-BBKC3cf3.d.ts → utils-D3rdsIvM.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +9 -8
- package/dist/vite.d.mts +2 -2
- package/dist/vite.d.ts +2 -2
- package/dist/vite.mjs +8 -7
- package/package.json +1 -1
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { Attributes, SpanKind } from '@opentelemetry/api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Recognizes AI agents and crawlers by the token they put in User-Agent.
|
|
5
|
+
*
|
|
6
|
+
* These are declarations, not proof of identity: any client can send them. Use
|
|
7
|
+
* the result to understand traffic and tailor responses, never to grant access.
|
|
8
|
+
*/
|
|
9
|
+
interface FarmAgentIdentity {
|
|
10
|
+
family: "unknown" | "openai" | "anthropic" | "google" | "microsoft" | "perplexity" | "other";
|
|
11
|
+
/** `crawler` indexes or trains; `agent` fetches on a person's request. */
|
|
12
|
+
category: "unknown" | "crawler" | "agent" | "harness";
|
|
13
|
+
identity: "unknown" | "self-reported";
|
|
14
|
+
}
|
|
15
|
+
/** Classifies a User-Agent header value. Ambiguous or unknown values are `unknown`. */
|
|
16
|
+
declare function classifyFarmAgent(userAgent: string | null | undefined): FarmAgentIdentity;
|
|
17
|
+
|
|
18
|
+
type FarmTraceSpanKind = "request" | "render" | "middleware" | "api" | "integration" | "storage" | "ppr" | "build" | "plugin";
|
|
19
|
+
interface FarmTracingConfig {
|
|
20
|
+
/** Enable Farm's OpenTelemetry spans. */
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
/** Span families to record. All families are enabled by default. */
|
|
23
|
+
spans?: readonly FarmTraceSpanKind[];
|
|
24
|
+
/** Add Farm lifecycle events to the active span. Defaults to true. */
|
|
25
|
+
recordEvents?: boolean;
|
|
26
|
+
/** Static attributes added to every Farm-created span. */
|
|
27
|
+
attributes?: Attributes;
|
|
28
|
+
/** Path prefixes that should not create request spans. */
|
|
29
|
+
ignorePaths?: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
type FarmTracingUserConfig = boolean | FarmTracingConfig;
|
|
32
|
+
interface FarmResolvedTracingConfig {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
spans: ReadonlySet<FarmTraceSpanKind>;
|
|
35
|
+
recordEvents: boolean;
|
|
36
|
+
attributes: Attributes;
|
|
37
|
+
ignorePaths: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
interface FarmTraceContext {
|
|
40
|
+
traceId: string;
|
|
41
|
+
spanId: string;
|
|
42
|
+
traceSampled: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface FarmRequestSpanOptions {
|
|
45
|
+
getStatusCode?: () => number | undefined;
|
|
46
|
+
onStart?: () => void;
|
|
47
|
+
onComplete?: (status: number, durationMs: number) => void;
|
|
48
|
+
onError?: (error: unknown, durationMs: number) => void;
|
|
49
|
+
}
|
|
50
|
+
interface FarmSpanOptions {
|
|
51
|
+
kind?: FarmTraceSpanKind;
|
|
52
|
+
attributes?: Attributes;
|
|
53
|
+
spanKind?: SpanKind;
|
|
54
|
+
}
|
|
55
|
+
declare function normalizeFarmTracingConfig(config: FarmTracingUserConfig | undefined): FarmResolvedTracingConfig;
|
|
56
|
+
declare function configureFarmTracing(config: FarmTracingUserConfig | FarmResolvedTracingConfig | undefined): void;
|
|
57
|
+
declare function getFarmTraceContext(): FarmTraceContext | undefined;
|
|
58
|
+
declare function runWithFarmSpan<T>(name: string, handler: () => T | Promise<T>, options?: FarmSpanOptions): Promise<T>;
|
|
59
|
+
|
|
60
|
+
type FarmEventLevel = "debug" | "info" | "warn" | "error";
|
|
61
|
+
interface FarmEventBase {
|
|
62
|
+
type: string;
|
|
63
|
+
timestamp: number;
|
|
64
|
+
level: FarmEventLevel;
|
|
65
|
+
requestId?: string;
|
|
66
|
+
traceId?: string;
|
|
67
|
+
spanId?: string;
|
|
68
|
+
traceSampled?: boolean;
|
|
69
|
+
route?: string;
|
|
70
|
+
pathname?: string;
|
|
71
|
+
}
|
|
72
|
+
type FarmRequestEvent = (FarmEventBase & {
|
|
73
|
+
type: "request.start";
|
|
74
|
+
method: string;
|
|
75
|
+
pathname: string;
|
|
76
|
+
}) | (FarmEventBase & {
|
|
77
|
+
type: "request.complete";
|
|
78
|
+
method: string;
|
|
79
|
+
pathname: string;
|
|
80
|
+
status: number;
|
|
81
|
+
durationMs: number;
|
|
82
|
+
}) | (FarmEventBase & {
|
|
83
|
+
type: "request.error";
|
|
84
|
+
method: string;
|
|
85
|
+
pathname: string;
|
|
86
|
+
durationMs: number;
|
|
87
|
+
error: unknown;
|
|
88
|
+
});
|
|
89
|
+
type FarmServerEvent = (FarmEventBase & {
|
|
90
|
+
type: "server.start";
|
|
91
|
+
mode: "dev" | "preview" | "production";
|
|
92
|
+
port?: number;
|
|
93
|
+
}) | (FarmEventBase & {
|
|
94
|
+
type: "server.ready";
|
|
95
|
+
url?: string;
|
|
96
|
+
}) | (FarmEventBase & {
|
|
97
|
+
type: "server.shutdown";
|
|
98
|
+
reason?: string;
|
|
99
|
+
});
|
|
100
|
+
type FarmRouteEvent = (FarmEventBase & {
|
|
101
|
+
type: "route.discovered";
|
|
102
|
+
route: string;
|
|
103
|
+
filePath: string;
|
|
104
|
+
}) | (FarmEventBase & {
|
|
105
|
+
type: "route.matched";
|
|
106
|
+
pathname: string;
|
|
107
|
+
route: string;
|
|
108
|
+
params?: Record<string, string>;
|
|
109
|
+
}) | (FarmEventBase & {
|
|
110
|
+
type: "route.notFound";
|
|
111
|
+
pathname: string;
|
|
112
|
+
}) | (FarmEventBase & {
|
|
113
|
+
type: "route.redirect";
|
|
114
|
+
from: string;
|
|
115
|
+
to: string;
|
|
116
|
+
status?: number;
|
|
117
|
+
}) | (FarmEventBase & {
|
|
118
|
+
type: "route.rewrite";
|
|
119
|
+
from: string;
|
|
120
|
+
to: string;
|
|
121
|
+
});
|
|
122
|
+
type FarmRenderEvent = (FarmEventBase & {
|
|
123
|
+
type: "render.start";
|
|
124
|
+
route: string;
|
|
125
|
+
pathname?: string;
|
|
126
|
+
}) | (FarmEventBase & {
|
|
127
|
+
type: "render.complete";
|
|
128
|
+
route: string;
|
|
129
|
+
durationMs: number;
|
|
130
|
+
status?: number;
|
|
131
|
+
}) | (FarmEventBase & {
|
|
132
|
+
type: "render.error";
|
|
133
|
+
route?: string;
|
|
134
|
+
error: unknown;
|
|
135
|
+
}) | (FarmEventBase & {
|
|
136
|
+
type: "render.stream.start";
|
|
137
|
+
route: string;
|
|
138
|
+
}) | (FarmEventBase & {
|
|
139
|
+
type: "render.stream.shellReady";
|
|
140
|
+
route: string;
|
|
141
|
+
durationMs: number;
|
|
142
|
+
}) | (FarmEventBase & {
|
|
143
|
+
type: "render.stream.complete";
|
|
144
|
+
route: string;
|
|
145
|
+
durationMs: number;
|
|
146
|
+
});
|
|
147
|
+
type FarmCacheEvent = (FarmEventBase & {
|
|
148
|
+
type: "cache.hit";
|
|
149
|
+
key: string;
|
|
150
|
+
route?: string;
|
|
151
|
+
tags?: readonly string[];
|
|
152
|
+
revalidate?: number | false;
|
|
153
|
+
stale?: boolean;
|
|
154
|
+
}) | (FarmEventBase & {
|
|
155
|
+
type: "cache.miss";
|
|
156
|
+
key: string;
|
|
157
|
+
route?: string;
|
|
158
|
+
reason?: string;
|
|
159
|
+
}) | (FarmEventBase & {
|
|
160
|
+
type: "cache.set";
|
|
161
|
+
key: string;
|
|
162
|
+
route?: string;
|
|
163
|
+
tags?: readonly string[];
|
|
164
|
+
revalidate?: number | false;
|
|
165
|
+
}) | (FarmEventBase & {
|
|
166
|
+
type: "cache.dedupe";
|
|
167
|
+
key: string;
|
|
168
|
+
}) | (FarmEventBase & {
|
|
169
|
+
type: "cache.bypass";
|
|
170
|
+
key?: string;
|
|
171
|
+
route?: string;
|
|
172
|
+
reason: string;
|
|
173
|
+
}) | (FarmEventBase & {
|
|
174
|
+
type: "cache.stale";
|
|
175
|
+
key: string;
|
|
176
|
+
route?: string;
|
|
177
|
+
tags?: readonly string[];
|
|
178
|
+
revalidate?: number | false;
|
|
179
|
+
}) | (FarmEventBase & {
|
|
180
|
+
type: "cache.revalidatePath";
|
|
181
|
+
path: string;
|
|
182
|
+
count: number;
|
|
183
|
+
}) | (FarmEventBase & {
|
|
184
|
+
type: "cache.revalidateTag";
|
|
185
|
+
tag: string;
|
|
186
|
+
profile?: unknown;
|
|
187
|
+
count: number;
|
|
188
|
+
}) | (FarmEventBase & {
|
|
189
|
+
type: "cache.updateTag";
|
|
190
|
+
tag: string;
|
|
191
|
+
count: number;
|
|
192
|
+
}) | (FarmEventBase & {
|
|
193
|
+
type: "cache.invalidated";
|
|
194
|
+
key?: string;
|
|
195
|
+
route?: string;
|
|
196
|
+
tag?: string;
|
|
197
|
+
reason?: string;
|
|
198
|
+
count?: number;
|
|
199
|
+
}) | (FarmEventBase & {
|
|
200
|
+
type: "cache.delete";
|
|
201
|
+
key: string;
|
|
202
|
+
deleted: boolean;
|
|
203
|
+
}) | (FarmEventBase & {
|
|
204
|
+
type: "cache.clear";
|
|
205
|
+
count: number;
|
|
206
|
+
}) | (FarmEventBase & {
|
|
207
|
+
type: "cache.error";
|
|
208
|
+
key?: string;
|
|
209
|
+
operation: "get" | "set" | "delete" | "revalidate";
|
|
210
|
+
error: unknown;
|
|
211
|
+
});
|
|
212
|
+
type FarmPPREvent = (FarmEventBase & {
|
|
213
|
+
type: "ppr.shell.hit";
|
|
214
|
+
route: string;
|
|
215
|
+
key: string;
|
|
216
|
+
}) | (FarmEventBase & {
|
|
217
|
+
type: "ppr.shell.miss";
|
|
218
|
+
route: string;
|
|
219
|
+
key: string;
|
|
220
|
+
}) | (FarmEventBase & {
|
|
221
|
+
type: "ppr.shell.cached";
|
|
222
|
+
route: string;
|
|
223
|
+
key: string;
|
|
224
|
+
revalidate?: number;
|
|
225
|
+
}) | (FarmEventBase & {
|
|
226
|
+
type: "ppr.shell.bypass";
|
|
227
|
+
route: string;
|
|
228
|
+
reason: string;
|
|
229
|
+
}) | (FarmEventBase & {
|
|
230
|
+
type: "ppr.shell.invalidated";
|
|
231
|
+
route: string;
|
|
232
|
+
reason?: string;
|
|
233
|
+
count?: number;
|
|
234
|
+
}) | (FarmEventBase & {
|
|
235
|
+
type: "ppr.suspense.holeDetected";
|
|
236
|
+
route: string;
|
|
237
|
+
}) | (FarmEventBase & {
|
|
238
|
+
type: "ppr.refresh.start";
|
|
239
|
+
route: string;
|
|
240
|
+
}) | (FarmEventBase & {
|
|
241
|
+
type: "ppr.refresh.complete";
|
|
242
|
+
route: string;
|
|
243
|
+
durationMs: number;
|
|
244
|
+
}) | (FarmEventBase & {
|
|
245
|
+
type: "ppr.refresh.error";
|
|
246
|
+
route: string;
|
|
247
|
+
error: unknown;
|
|
248
|
+
});
|
|
249
|
+
type FarmAPIEvent = (FarmEventBase & {
|
|
250
|
+
type: "api.request.start";
|
|
251
|
+
route: string;
|
|
252
|
+
method: string;
|
|
253
|
+
}) | (FarmEventBase & {
|
|
254
|
+
type: "api.request.complete";
|
|
255
|
+
route: string;
|
|
256
|
+
method: string;
|
|
257
|
+
status: number;
|
|
258
|
+
durationMs: number;
|
|
259
|
+
}) | (FarmEventBase & {
|
|
260
|
+
type: "api.validation.failed";
|
|
261
|
+
route: string;
|
|
262
|
+
method: string;
|
|
263
|
+
issues?: unknown;
|
|
264
|
+
}) | (FarmEventBase & {
|
|
265
|
+
type: "api.error";
|
|
266
|
+
route: string;
|
|
267
|
+
method: string;
|
|
268
|
+
durationMs: number;
|
|
269
|
+
error: unknown;
|
|
270
|
+
});
|
|
271
|
+
type FarmIntegrationEvent = (FarmEventBase & {
|
|
272
|
+
type: "integration.registered";
|
|
273
|
+
name: string;
|
|
274
|
+
}) | (FarmEventBase & {
|
|
275
|
+
type: "integration.config.validated";
|
|
276
|
+
name: string;
|
|
277
|
+
}) | (FarmEventBase & {
|
|
278
|
+
type: "integration.ready";
|
|
279
|
+
name: string;
|
|
280
|
+
}) | (FarmEventBase & {
|
|
281
|
+
type: "integration.disposed";
|
|
282
|
+
name: string;
|
|
283
|
+
}) | (FarmEventBase & {
|
|
284
|
+
type: "integration.api.call.start";
|
|
285
|
+
integration: string;
|
|
286
|
+
operation: string;
|
|
287
|
+
}) | (FarmEventBase & {
|
|
288
|
+
type: "integration.api.call.complete";
|
|
289
|
+
integration: string;
|
|
290
|
+
operation: string;
|
|
291
|
+
durationMs: number;
|
|
292
|
+
}) | (FarmEventBase & {
|
|
293
|
+
type: "integration.api.call.error";
|
|
294
|
+
integration: string;
|
|
295
|
+
operation: string;
|
|
296
|
+
error: unknown;
|
|
297
|
+
}) | (FarmEventBase & {
|
|
298
|
+
type: "integration.webhook.received";
|
|
299
|
+
integration: string;
|
|
300
|
+
event?: string;
|
|
301
|
+
}) | (FarmEventBase & {
|
|
302
|
+
type: "integration.webhook.verified";
|
|
303
|
+
integration: string;
|
|
304
|
+
event?: string;
|
|
305
|
+
}) | (FarmEventBase & {
|
|
306
|
+
type: "integration.webhook.failed";
|
|
307
|
+
integration: string;
|
|
308
|
+
reason: string;
|
|
309
|
+
});
|
|
310
|
+
/** A registered MCP tool callback completed; not an HTTP response or an agent run. */
|
|
311
|
+
type FarmMCPEvent = FarmEventBase & {
|
|
312
|
+
type: "mcp.tool.complete";
|
|
313
|
+
/** Configured transport path, never a raw request URL. */
|
|
314
|
+
route: string;
|
|
315
|
+
server: string;
|
|
316
|
+
tool: string;
|
|
317
|
+
outcome: "success" | "error";
|
|
318
|
+
durationMs: number;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* An agent surface answered a request: a Markdown mirror or `page.md`, llms.txt,
|
|
322
|
+
* llms-full.txt, or the API catalog. `agent` is what the User-Agent declares,
|
|
323
|
+
* not a verified identity.
|
|
324
|
+
*/
|
|
325
|
+
type FarmAgentEvent = FarmEventBase & {
|
|
326
|
+
type: "agent.read";
|
|
327
|
+
surface: "markdown" | "llms" | "llms-full" | "api-catalog";
|
|
328
|
+
/** The path served, such as `/pricing.md`; never the query string. */
|
|
329
|
+
route: string;
|
|
330
|
+
/** For Markdown, the partial view asked for. */
|
|
331
|
+
view?: "outline" | "section" | "parts" | "actions";
|
|
332
|
+
status: number;
|
|
333
|
+
agent: FarmAgentIdentity;
|
|
334
|
+
};
|
|
335
|
+
type FarmMiddlewareEvent = (FarmEventBase & {
|
|
336
|
+
type: "middleware.start";
|
|
337
|
+
route?: string;
|
|
338
|
+
name?: string;
|
|
339
|
+
}) | (FarmEventBase & {
|
|
340
|
+
type: "middleware.complete";
|
|
341
|
+
route?: string;
|
|
342
|
+
name?: string;
|
|
343
|
+
durationMs: number;
|
|
344
|
+
}) | (FarmEventBase & {
|
|
345
|
+
type: "middleware.shortCircuit";
|
|
346
|
+
route?: string;
|
|
347
|
+
name?: string;
|
|
348
|
+
status?: number;
|
|
349
|
+
}) | (FarmEventBase & {
|
|
350
|
+
type: "middleware.error";
|
|
351
|
+
route?: string;
|
|
352
|
+
name?: string;
|
|
353
|
+
error: unknown;
|
|
354
|
+
});
|
|
355
|
+
type FarmStorageEvent = (FarmEventBase & {
|
|
356
|
+
type: "storage.query.start";
|
|
357
|
+
integration?: string;
|
|
358
|
+
operation: string;
|
|
359
|
+
}) | (FarmEventBase & {
|
|
360
|
+
type: "storage.query.complete";
|
|
361
|
+
integration?: string;
|
|
362
|
+
operation: string;
|
|
363
|
+
durationMs: number;
|
|
364
|
+
}) | (FarmEventBase & {
|
|
365
|
+
type: "storage.query.error";
|
|
366
|
+
integration?: string;
|
|
367
|
+
operation: string;
|
|
368
|
+
error: unknown;
|
|
369
|
+
}) | (FarmEventBase & {
|
|
370
|
+
type: "storage.schema.ready";
|
|
371
|
+
integration?: string;
|
|
372
|
+
}) | (FarmEventBase & {
|
|
373
|
+
type: "storage.schema.error";
|
|
374
|
+
integration?: string;
|
|
375
|
+
error: unknown;
|
|
376
|
+
});
|
|
377
|
+
type FarmBuildEvent = (FarmEventBase & {
|
|
378
|
+
type: "build.start";
|
|
379
|
+
target?: string;
|
|
380
|
+
}) | (FarmEventBase & {
|
|
381
|
+
type: "build.complete";
|
|
382
|
+
target?: string;
|
|
383
|
+
durationMs: number;
|
|
384
|
+
}) | (FarmEventBase & {
|
|
385
|
+
type: "build.error";
|
|
386
|
+
target?: string;
|
|
387
|
+
error: unknown;
|
|
388
|
+
}) | (FarmEventBase & {
|
|
389
|
+
type: "routes.generated";
|
|
390
|
+
pageCount: number;
|
|
391
|
+
apiCount?: number;
|
|
392
|
+
}) | (FarmEventBase & {
|
|
393
|
+
type: "types.generated";
|
|
394
|
+
filePath: string;
|
|
395
|
+
}) | (FarmEventBase & {
|
|
396
|
+
type: "manifest.generated";
|
|
397
|
+
routeCount: number;
|
|
398
|
+
});
|
|
399
|
+
type FarmPluginEvent = (FarmEventBase & {
|
|
400
|
+
type: "plugin.hook.start";
|
|
401
|
+
plugin: string;
|
|
402
|
+
hook: string;
|
|
403
|
+
}) | (FarmEventBase & {
|
|
404
|
+
type: "plugin.hook.complete";
|
|
405
|
+
plugin: string;
|
|
406
|
+
hook: string;
|
|
407
|
+
durationMs: number;
|
|
408
|
+
}) | (FarmEventBase & {
|
|
409
|
+
type: "plugin.hook.error";
|
|
410
|
+
plugin: string;
|
|
411
|
+
hook: string;
|
|
412
|
+
error: unknown;
|
|
413
|
+
});
|
|
414
|
+
type FarmErrorEvent = FarmEventBase & {
|
|
415
|
+
type: "error";
|
|
416
|
+
source: string;
|
|
417
|
+
error: unknown;
|
|
418
|
+
route?: string;
|
|
419
|
+
};
|
|
420
|
+
type FarmEvent = FarmRequestEvent | FarmServerEvent | FarmRouteEvent | FarmRenderEvent | FarmCacheEvent | FarmPPREvent | FarmAPIEvent | FarmIntegrationEvent | FarmMCPEvent | FarmAgentEvent | FarmMiddlewareEvent | FarmStorageEvent | FarmBuildEvent | FarmPluginEvent | FarmErrorEvent;
|
|
421
|
+
type FarmEventType = FarmEvent["type"];
|
|
422
|
+
type FarmEventHandler = (event: FarmEvent) => void | Promise<void>;
|
|
423
|
+
type FarmEventInput = FarmEvent extends infer T ? T extends FarmEvent ? Omit<T, "timestamp" | "level"> & Partial<Pick<T, "timestamp" | "level">> : never : never;
|
|
424
|
+
type FarmObservabilityUserConfig = boolean | {
|
|
425
|
+
logs?: boolean;
|
|
426
|
+
onEvent?: FarmEventHandler | readonly FarmEventHandler[];
|
|
427
|
+
events?: readonly FarmEventType[];
|
|
428
|
+
tracing?: FarmTracingUserConfig;
|
|
429
|
+
};
|
|
430
|
+
interface FarmResolvedObservabilityConfig {
|
|
431
|
+
logs: boolean;
|
|
432
|
+
handlers: FarmEventHandler[];
|
|
433
|
+
events?: Set<FarmEventType>;
|
|
434
|
+
tracing: FarmResolvedTracingConfig;
|
|
435
|
+
}
|
|
436
|
+
interface FarmEventSubscriptionOptions {
|
|
437
|
+
/** Receive events even when they are excluded by `observability.events`. */
|
|
438
|
+
unfiltered?: boolean;
|
|
439
|
+
}
|
|
440
|
+
declare function configureFarmObservability(config: FarmObservabilityUserConfig | undefined): void;
|
|
441
|
+
declare function normalizeFarmObservabilityConfig(config: FarmObservabilityUserConfig | undefined): FarmResolvedObservabilityConfig;
|
|
442
|
+
declare function onFarmEvent(handler: FarmEventHandler, options?: FarmEventSubscriptionOptions): () => void;
|
|
443
|
+
declare function resetFarmObservability(): void;
|
|
444
|
+
declare function emitFarmEvent(input: FarmEventInput): FarmEvent;
|
|
445
|
+
declare function runWithFarmRequestSpan<T>(request: Request, handler: () => T | Promise<T>, options?: FarmRequestSpanOptions): Promise<T>;
|
|
446
|
+
|
|
447
|
+
export { type FarmAgentEvent as A, type FarmMiddlewareEvent as B, type FarmStorageEvent as C, type FarmBuildEvent as D, type FarmPluginEvent as E, type FarmAgentIdentity as F, type FarmErrorEvent as G, type FarmEvent as H, type FarmEventType as I, type FarmEventHandler as J, type FarmEventInput as K, type FarmObservabilityUserConfig as L, type FarmResolvedObservabilityConfig as M, type FarmEventSubscriptionOptions as N, normalizeFarmObservabilityConfig as O, onFarmEvent as P, resetFarmObservability as Q, classifyFarmAgent as a, configureFarmTracing as b, configureFarmObservability as c, runWithFarmSpan as d, emitFarmEvent as e, type FarmRequestSpanOptions as f, getFarmTraceContext as g, type FarmResolvedTracingConfig as h, type FarmSpanOptions as i, type FarmTraceContext as j, type FarmTraceSpanKind as k, type FarmTracingConfig as l, type FarmTracingUserConfig as m, normalizeFarmTracingConfig as n, type FarmEventLevel as o, type FarmEventBase as p, type FarmRequestEvent as q, runWithFarmRequestSpan as r, type FarmServerEvent as s, type FarmRouteEvent as t, type FarmRenderEvent as u, type FarmCacheEvent as v, type FarmPPREvent as w, type FarmAPIEvent as x, type FarmIntegrationEvent as y, type FarmMCPEvent as z };
|