@sequenceholdings/managed-functions 0.4.0 → 0.4.2
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/README.md +444 -2
- package/dist/abrigo-contract.d.ts +92 -0
- package/dist/abrigo-contract.js +55 -0
- package/dist/abrigo-response.d.ts +6 -0
- package/dist/abrigo-response.js +27 -0
- package/dist/abrigo.d.ts +14 -0
- package/dist/abrigo.js +150 -0
- package/dist/agent-evidence.d.ts +9 -0
- package/dist/agent-evidence.js +84 -0
- package/dist/agent-source-evidence-contract.d.ts +1197 -0
- package/dist/agent-source-evidence-contract.js +96 -0
- package/dist/agents-contract.d.ts +99 -0
- package/dist/agents-contract.js +69 -0
- package/dist/agents.d.ts +15 -0
- package/dist/agents.js +121 -0
- package/dist/capabilities.d.ts +165 -0
- package/dist/capabilities.js +61 -1
- package/dist/config.d.ts +18 -2
- package/dist/config.js +62 -1
- package/dist/deployed-policy.js +102 -0
- package/dist/directory-config.d.ts +23 -0
- package/dist/directory-config.js +22 -0
- package/dist/directory-contract.d.ts +68 -0
- package/dist/directory-contract.js +57 -0
- package/dist/directory-manifest.d.ts +5 -0
- package/dist/directory-manifest.js +10 -0
- package/dist/directory.d.ts +15 -0
- package/dist/directory.js +65 -0
- package/dist/http-tracing.js +3 -0
- package/dist/immutable-release-contract.d.ts +3 -0
- package/dist/immutable-release-contract.js +12 -0
- package/dist/index.d.ts +40 -1
- package/dist/index.js +75 -1
- package/dist/invocation-client.d.ts +45 -0
- package/dist/invocation-client.js +90 -0
- package/dist/invocation-contract.d.ts +36 -0
- package/dist/invocation-contract.js +48 -0
- package/dist/invocation.d.ts +8 -0
- package/dist/invocation.js +134 -0
- package/dist/lattice-capability.d.ts +5 -0
- package/dist/lattice-capability.js +16 -0
- package/dist/lattice-provenance-contract.d.ts +519 -0
- package/dist/lattice-provenance-contract.js +148 -0
- package/dist/lattice-provenance.d.ts +16 -0
- package/dist/lattice-provenance.js +167 -0
- package/dist/monitoring-annotations.d.ts +53 -0
- package/dist/monitoring-annotations.js +54 -0
- package/dist/monitoring-contract.d.ts +463 -0
- package/dist/monitoring-contract.js +89 -0
- package/dist/monitoring-events.d.ts +257 -0
- package/dist/monitoring-events.js +136 -0
- package/dist/monitoring.d.ts +14 -0
- package/dist/monitoring.js +78 -0
- package/dist/orm-contract.d.ts +1 -0
- package/dist/orm-contract.js +4 -0
- package/dist/orm.d.ts +19 -3
- package/dist/orm.js +93 -13
- package/dist/preflight-abrigo.d.ts +10 -0
- package/dist/preflight-abrigo.js +26 -0
- package/dist/preflight-agents.d.ts +10 -0
- package/dist/preflight-agents.js +51 -0
- package/dist/preflight-directory.d.ts +10 -0
- package/dist/preflight-directory.js +36 -0
- package/dist/preflight-immutable-release.d.ts +10 -0
- package/dist/preflight-immutable-release.js +34 -0
- package/dist/preflight-invocation.d.ts +10 -0
- package/dist/preflight-invocation.js +40 -0
- package/dist/preflight-lattice.d.ts +10 -0
- package/dist/preflight-lattice.js +40 -0
- package/dist/preflight-monitoring.d.ts +10 -0
- package/dist/preflight-monitoring.js +46 -0
- package/dist/preflight-service-directory.d.ts +10 -0
- package/dist/preflight-service-directory.js +26 -0
- package/dist/preflight-workflows.d.ts +10 -0
- package/dist/preflight-workflows.js +38 -0
- package/dist/preflight.js +50 -2
- package/dist/processes-contract.d.ts +20 -0
- package/dist/processes-contract.js +8 -1
- package/dist/processes.d.ts +4 -8
- package/dist/processes.js +52 -83
- package/dist/runtime.cjs +3387 -259
- package/dist/sdk-range.d.ts +1 -0
- package/dist/sdk-range.js +25 -0
- package/dist/service-directory.d.ts +12 -0
- package/dist/service-directory.js +72 -0
- package/dist/workflow-scopes-contract.d.ts +8 -0
- package/dist/workflow-scopes-contract.js +29 -0
- package/dist/workflow-source-contract.d.ts +524 -0
- package/dist/workflow-source-contract.js +59 -0
- package/dist/workflow-source.d.ts +12 -0
- package/dist/workflow-source.js +93 -0
- package/package.json +2 -2
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { functionMonitoringAnnotationSchema } from './monitoring-annotations';
|
|
3
|
+
export type { DeltaEventInput as MonitoringDeltaEvent } from './monitoring-events';
|
|
4
|
+
export declare const FUNCTION_MONITORING_TOKEN_HEADER = "x-sequence-monitoring-service-token";
|
|
5
|
+
export declare const FUNCTION_MONITORING_DELIVERIES_PATH = "/api/managed-functions/monitoring/deliveries";
|
|
6
|
+
export declare const MONITORING_PRODUCER_CAPABILITY = "emit_monitoring";
|
|
7
|
+
export declare const MONITORING_CATALOG_CAPABILITY = "read_monitoring_catalog";
|
|
8
|
+
export declare const MAX_MONITORING_DELIVERY_BYTES: number;
|
|
9
|
+
export declare const functionMonitoringScopesSchema: z.ZodObject<{
|
|
10
|
+
producers: z.ZodArray<z.ZodString>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export declare function readFunctionMonitoringScopes(manifest: unknown): string[];
|
|
13
|
+
export declare const monitoringEventsSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
14
|
+
contextType: z.ZodLiteral<"artifact_delta">;
|
|
15
|
+
context: z.ZodObject<{
|
|
16
|
+
artifactKind: z.ZodString;
|
|
17
|
+
sectionPath: z.ZodString;
|
|
18
|
+
before: z.ZodString;
|
|
19
|
+
after: z.ZodString;
|
|
20
|
+
changeKind: z.ZodEnum<{
|
|
21
|
+
added: "added";
|
|
22
|
+
removed: "removed";
|
|
23
|
+
modified: "modified";
|
|
24
|
+
}>;
|
|
25
|
+
category: z.ZodOptional<z.ZodString>;
|
|
26
|
+
sourceRefs: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
27
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
idempotencyKey: z.ZodString;
|
|
30
|
+
subjectId: z.ZodString;
|
|
31
|
+
subjectKind: z.ZodEnum<{
|
|
32
|
+
workflow: "workflow";
|
|
33
|
+
agent: "agent";
|
|
34
|
+
}>;
|
|
35
|
+
occurredAt: z.ZodString;
|
|
36
|
+
deltaReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
|
+
deltaSource: z.ZodDefault<z.ZodEnum<{
|
|
38
|
+
unknown: "unknown";
|
|
39
|
+
human: "human";
|
|
40
|
+
llm: "llm";
|
|
41
|
+
}>>;
|
|
42
|
+
actionability: z.ZodDefault<z.ZodLiteral<"unknown">>;
|
|
43
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
44
|
+
contextType: z.ZodLiteral<"dti_delta">;
|
|
45
|
+
context: z.ZodObject<{
|
|
46
|
+
stageId: z.ZodString;
|
|
47
|
+
loanId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
fieldPath: z.ZodString;
|
|
49
|
+
before: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
50
|
+
after: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
51
|
+
section: z.ZodOptional<z.ZodEnum<{
|
|
52
|
+
debt: "debt";
|
|
53
|
+
income: "income";
|
|
54
|
+
other: "other";
|
|
55
|
+
}>>;
|
|
56
|
+
itemLabel: z.ZodOptional<z.ZodString>;
|
|
57
|
+
calculatorType: z.ZodOptional<z.ZodEnum<{
|
|
58
|
+
basic: "basic";
|
|
59
|
+
advanced: "advanced";
|
|
60
|
+
}>>;
|
|
61
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
62
|
+
sourceDocRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
idempotencyKey: z.ZodString;
|
|
65
|
+
subjectId: z.ZodString;
|
|
66
|
+
subjectKind: z.ZodEnum<{
|
|
67
|
+
workflow: "workflow";
|
|
68
|
+
agent: "agent";
|
|
69
|
+
}>;
|
|
70
|
+
occurredAt: z.ZodString;
|
|
71
|
+
deltaReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
72
|
+
deltaSource: z.ZodDefault<z.ZodEnum<{
|
|
73
|
+
unknown: "unknown";
|
|
74
|
+
human: "human";
|
|
75
|
+
llm: "llm";
|
|
76
|
+
}>>;
|
|
77
|
+
actionability: z.ZodDefault<z.ZodLiteral<"unknown">>;
|
|
78
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
79
|
+
contextType: z.ZodLiteral<"doc_extract_edit">;
|
|
80
|
+
context: z.ZodObject<{
|
|
81
|
+
documentId: z.ZodString;
|
|
82
|
+
docType: z.ZodString;
|
|
83
|
+
fieldPath: z.ZodString;
|
|
84
|
+
oldValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
85
|
+
newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
86
|
+
rowKey: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
87
|
+
stageId: z.ZodOptional<z.ZodString>;
|
|
88
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
89
|
+
citation: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
page: z.ZodNumber;
|
|
91
|
+
region: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strict>>;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
idempotencyKey: z.ZodString;
|
|
95
|
+
subjectId: z.ZodString;
|
|
96
|
+
subjectKind: z.ZodEnum<{
|
|
97
|
+
workflow: "workflow";
|
|
98
|
+
agent: "agent";
|
|
99
|
+
}>;
|
|
100
|
+
occurredAt: z.ZodString;
|
|
101
|
+
deltaReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
102
|
+
deltaSource: z.ZodDefault<z.ZodEnum<{
|
|
103
|
+
unknown: "unknown";
|
|
104
|
+
human: "human";
|
|
105
|
+
llm: "llm";
|
|
106
|
+
}>>;
|
|
107
|
+
actionability: z.ZodDefault<z.ZodLiteral<"unknown">>;
|
|
108
|
+
}, z.core.$strict>], "contextType">>;
|
|
109
|
+
export declare function monitoringPayloadHash({ events, observation }: {
|
|
110
|
+
events: z.input<typeof monitoringEventsSchema>;
|
|
111
|
+
observation?: z.input<typeof functionMonitoringAnnotationSchema>;
|
|
112
|
+
}): string;
|
|
113
|
+
export declare const monitoringDeliveryKeySchema: z.ZodObject<{
|
|
114
|
+
producer: z.ZodString;
|
|
115
|
+
businessKey: z.ZodString;
|
|
116
|
+
}, z.core.$strict>;
|
|
117
|
+
export declare const monitoringCatalogQuerySchema: z.ZodObject<{
|
|
118
|
+
producer: z.ZodString;
|
|
119
|
+
}, z.core.$strict>;
|
|
120
|
+
export declare const monitoringBucketCatalogSchema: z.ZodObject<{
|
|
121
|
+
producer: z.ZodString;
|
|
122
|
+
complete: z.ZodLiteral<true>;
|
|
123
|
+
buckets: z.ZodArray<z.ZodObject<{
|
|
124
|
+
slug: z.ZodString;
|
|
125
|
+
name: z.ZodString;
|
|
126
|
+
description: z.ZodString;
|
|
127
|
+
severity: z.ZodEnum<{
|
|
128
|
+
critical: "critical";
|
|
129
|
+
high: "high";
|
|
130
|
+
medium: "medium";
|
|
131
|
+
low: "low";
|
|
132
|
+
}>;
|
|
133
|
+
category: z.ZodString;
|
|
134
|
+
}, z.core.$strict>>;
|
|
135
|
+
}, z.core.$strict>;
|
|
136
|
+
export type MonitoringCatalogQuery = z.infer<typeof monitoringCatalogQuerySchema>;
|
|
137
|
+
export type MonitoringBucketCatalog = z.infer<typeof monitoringBucketCatalogSchema>;
|
|
138
|
+
export declare const monitoringPublishSchema: z.ZodObject<{
|
|
139
|
+
producer: z.ZodString;
|
|
140
|
+
businessKey: z.ZodString;
|
|
141
|
+
payloadHash: z.ZodString;
|
|
142
|
+
events: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
143
|
+
contextType: z.ZodLiteral<"artifact_delta">;
|
|
144
|
+
context: z.ZodObject<{
|
|
145
|
+
artifactKind: z.ZodString;
|
|
146
|
+
sectionPath: z.ZodString;
|
|
147
|
+
before: z.ZodString;
|
|
148
|
+
after: z.ZodString;
|
|
149
|
+
changeKind: z.ZodEnum<{
|
|
150
|
+
added: "added";
|
|
151
|
+
removed: "removed";
|
|
152
|
+
modified: "modified";
|
|
153
|
+
}>;
|
|
154
|
+
category: z.ZodOptional<z.ZodString>;
|
|
155
|
+
sourceRefs: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
156
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
157
|
+
}, z.core.$strict>;
|
|
158
|
+
idempotencyKey: z.ZodString;
|
|
159
|
+
subjectId: z.ZodString;
|
|
160
|
+
subjectKind: z.ZodEnum<{
|
|
161
|
+
workflow: "workflow";
|
|
162
|
+
agent: "agent";
|
|
163
|
+
}>;
|
|
164
|
+
occurredAt: z.ZodString;
|
|
165
|
+
deltaReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
|
+
deltaSource: z.ZodDefault<z.ZodEnum<{
|
|
167
|
+
unknown: "unknown";
|
|
168
|
+
human: "human";
|
|
169
|
+
llm: "llm";
|
|
170
|
+
}>>;
|
|
171
|
+
actionability: z.ZodDefault<z.ZodLiteral<"unknown">>;
|
|
172
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
173
|
+
contextType: z.ZodLiteral<"dti_delta">;
|
|
174
|
+
context: z.ZodObject<{
|
|
175
|
+
stageId: z.ZodString;
|
|
176
|
+
loanId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
177
|
+
fieldPath: z.ZodString;
|
|
178
|
+
before: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
179
|
+
after: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
180
|
+
section: z.ZodOptional<z.ZodEnum<{
|
|
181
|
+
debt: "debt";
|
|
182
|
+
income: "income";
|
|
183
|
+
other: "other";
|
|
184
|
+
}>>;
|
|
185
|
+
itemLabel: z.ZodOptional<z.ZodString>;
|
|
186
|
+
calculatorType: z.ZodOptional<z.ZodEnum<{
|
|
187
|
+
basic: "basic";
|
|
188
|
+
advanced: "advanced";
|
|
189
|
+
}>>;
|
|
190
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
191
|
+
sourceDocRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
192
|
+
}, z.core.$strict>;
|
|
193
|
+
idempotencyKey: z.ZodString;
|
|
194
|
+
subjectId: z.ZodString;
|
|
195
|
+
subjectKind: z.ZodEnum<{
|
|
196
|
+
workflow: "workflow";
|
|
197
|
+
agent: "agent";
|
|
198
|
+
}>;
|
|
199
|
+
occurredAt: z.ZodString;
|
|
200
|
+
deltaReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
201
|
+
deltaSource: z.ZodDefault<z.ZodEnum<{
|
|
202
|
+
unknown: "unknown";
|
|
203
|
+
human: "human";
|
|
204
|
+
llm: "llm";
|
|
205
|
+
}>>;
|
|
206
|
+
actionability: z.ZodDefault<z.ZodLiteral<"unknown">>;
|
|
207
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
208
|
+
contextType: z.ZodLiteral<"doc_extract_edit">;
|
|
209
|
+
context: z.ZodObject<{
|
|
210
|
+
documentId: z.ZodString;
|
|
211
|
+
docType: z.ZodString;
|
|
212
|
+
fieldPath: z.ZodString;
|
|
213
|
+
oldValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
214
|
+
newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
215
|
+
rowKey: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
216
|
+
stageId: z.ZodOptional<z.ZodString>;
|
|
217
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
218
|
+
citation: z.ZodOptional<z.ZodObject<{
|
|
219
|
+
page: z.ZodNumber;
|
|
220
|
+
region: z.ZodOptional<z.ZodString>;
|
|
221
|
+
}, z.core.$strict>>;
|
|
222
|
+
}, z.core.$strict>;
|
|
223
|
+
idempotencyKey: z.ZodString;
|
|
224
|
+
subjectId: z.ZodString;
|
|
225
|
+
subjectKind: z.ZodEnum<{
|
|
226
|
+
workflow: "workflow";
|
|
227
|
+
agent: "agent";
|
|
228
|
+
}>;
|
|
229
|
+
occurredAt: z.ZodString;
|
|
230
|
+
deltaReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
231
|
+
deltaSource: z.ZodDefault<z.ZodEnum<{
|
|
232
|
+
unknown: "unknown";
|
|
233
|
+
human: "human";
|
|
234
|
+
llm: "llm";
|
|
235
|
+
}>>;
|
|
236
|
+
actionability: z.ZodDefault<z.ZodLiteral<"unknown">>;
|
|
237
|
+
}, z.core.$strict>], "contextType">>;
|
|
238
|
+
observation: z.ZodOptional<z.ZodObject<{
|
|
239
|
+
sourceType: z.ZodString;
|
|
240
|
+
sourceRef: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
241
|
+
generatingSubject: z.ZodObject<{
|
|
242
|
+
subjectId: z.ZodString;
|
|
243
|
+
subjectKind: z.ZodEnum<{
|
|
244
|
+
workflow: "workflow";
|
|
245
|
+
agent: "agent";
|
|
246
|
+
}>;
|
|
247
|
+
}, z.core.$strict>;
|
|
248
|
+
occurredAt: z.ZodISODateTime;
|
|
249
|
+
summary: z.ZodNullable<z.ZodString>;
|
|
250
|
+
metrics: z.ZodCustom<import("./monitoring-annotations").MonitoringJson, import("./monitoring-annotations").MonitoringJson>;
|
|
251
|
+
conversationFindings: z.ZodArray<z.ZodObject<{
|
|
252
|
+
type: z.ZodString;
|
|
253
|
+
description: z.ZodString;
|
|
254
|
+
excerpt: z.ZodString;
|
|
255
|
+
severity: z.ZodEnum<{
|
|
256
|
+
high: "high";
|
|
257
|
+
medium: "medium";
|
|
258
|
+
low: "low";
|
|
259
|
+
}>;
|
|
260
|
+
}, z.core.$strict>>;
|
|
261
|
+
classifications: z.ZodArray<z.ZodObject<{
|
|
262
|
+
matchedBucketSlug: z.ZodNullable<z.ZodString>;
|
|
263
|
+
newBucketProposal: z.ZodNullable<z.ZodObject<{
|
|
264
|
+
name: z.ZodString;
|
|
265
|
+
description: z.ZodString;
|
|
266
|
+
severity: z.ZodEnum<{
|
|
267
|
+
critical: "critical";
|
|
268
|
+
high: "high";
|
|
269
|
+
medium: "medium";
|
|
270
|
+
low: "low";
|
|
271
|
+
}>;
|
|
272
|
+
category: z.ZodString;
|
|
273
|
+
}, z.core.$strict>>;
|
|
274
|
+
excerpt: z.ZodString;
|
|
275
|
+
inputTags: z.ZodArray<z.ZodObject<{
|
|
276
|
+
type: z.ZodString;
|
|
277
|
+
value: z.ZodString;
|
|
278
|
+
}, z.core.$strict>>;
|
|
279
|
+
}, z.core.$strict>>;
|
|
280
|
+
coarseFallbacks: z.ZodArray<z.ZodObject<{
|
|
281
|
+
bucketSlug: z.ZodString;
|
|
282
|
+
excerpt: z.ZodString;
|
|
283
|
+
coarseCategory: z.ZodString;
|
|
284
|
+
}, z.core.$strict>>;
|
|
285
|
+
}, z.core.$strict>>;
|
|
286
|
+
}, z.core.$strict>;
|
|
287
|
+
export declare const functionMonitoringRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
288
|
+
producer: z.ZodString;
|
|
289
|
+
businessKey: z.ZodString;
|
|
290
|
+
payloadHash: z.ZodString;
|
|
291
|
+
events: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
292
|
+
contextType: z.ZodLiteral<"artifact_delta">;
|
|
293
|
+
context: z.ZodObject<{
|
|
294
|
+
artifactKind: z.ZodString;
|
|
295
|
+
sectionPath: z.ZodString;
|
|
296
|
+
before: z.ZodString;
|
|
297
|
+
after: z.ZodString;
|
|
298
|
+
changeKind: z.ZodEnum<{
|
|
299
|
+
added: "added";
|
|
300
|
+
removed: "removed";
|
|
301
|
+
modified: "modified";
|
|
302
|
+
}>;
|
|
303
|
+
category: z.ZodOptional<z.ZodString>;
|
|
304
|
+
sourceRefs: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
305
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
306
|
+
}, z.core.$strict>;
|
|
307
|
+
idempotencyKey: z.ZodString;
|
|
308
|
+
subjectId: z.ZodString;
|
|
309
|
+
subjectKind: z.ZodEnum<{
|
|
310
|
+
workflow: "workflow";
|
|
311
|
+
agent: "agent";
|
|
312
|
+
}>;
|
|
313
|
+
occurredAt: z.ZodString;
|
|
314
|
+
deltaReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
315
|
+
deltaSource: z.ZodDefault<z.ZodEnum<{
|
|
316
|
+
unknown: "unknown";
|
|
317
|
+
human: "human";
|
|
318
|
+
llm: "llm";
|
|
319
|
+
}>>;
|
|
320
|
+
actionability: z.ZodDefault<z.ZodLiteral<"unknown">>;
|
|
321
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
322
|
+
contextType: z.ZodLiteral<"dti_delta">;
|
|
323
|
+
context: z.ZodObject<{
|
|
324
|
+
stageId: z.ZodString;
|
|
325
|
+
loanId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
326
|
+
fieldPath: z.ZodString;
|
|
327
|
+
before: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
328
|
+
after: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
329
|
+
section: z.ZodOptional<z.ZodEnum<{
|
|
330
|
+
debt: "debt";
|
|
331
|
+
income: "income";
|
|
332
|
+
other: "other";
|
|
333
|
+
}>>;
|
|
334
|
+
itemLabel: z.ZodOptional<z.ZodString>;
|
|
335
|
+
calculatorType: z.ZodOptional<z.ZodEnum<{
|
|
336
|
+
basic: "basic";
|
|
337
|
+
advanced: "advanced";
|
|
338
|
+
}>>;
|
|
339
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
340
|
+
sourceDocRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
341
|
+
}, z.core.$strict>;
|
|
342
|
+
idempotencyKey: z.ZodString;
|
|
343
|
+
subjectId: z.ZodString;
|
|
344
|
+
subjectKind: z.ZodEnum<{
|
|
345
|
+
workflow: "workflow";
|
|
346
|
+
agent: "agent";
|
|
347
|
+
}>;
|
|
348
|
+
occurredAt: z.ZodString;
|
|
349
|
+
deltaReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
350
|
+
deltaSource: z.ZodDefault<z.ZodEnum<{
|
|
351
|
+
unknown: "unknown";
|
|
352
|
+
human: "human";
|
|
353
|
+
llm: "llm";
|
|
354
|
+
}>>;
|
|
355
|
+
actionability: z.ZodDefault<z.ZodLiteral<"unknown">>;
|
|
356
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
357
|
+
contextType: z.ZodLiteral<"doc_extract_edit">;
|
|
358
|
+
context: z.ZodObject<{
|
|
359
|
+
documentId: z.ZodString;
|
|
360
|
+
docType: z.ZodString;
|
|
361
|
+
fieldPath: z.ZodString;
|
|
362
|
+
oldValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
363
|
+
newValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
364
|
+
rowKey: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
365
|
+
stageId: z.ZodOptional<z.ZodString>;
|
|
366
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
367
|
+
citation: z.ZodOptional<z.ZodObject<{
|
|
368
|
+
page: z.ZodNumber;
|
|
369
|
+
region: z.ZodOptional<z.ZodString>;
|
|
370
|
+
}, z.core.$strict>>;
|
|
371
|
+
}, z.core.$strict>;
|
|
372
|
+
idempotencyKey: z.ZodString;
|
|
373
|
+
subjectId: z.ZodString;
|
|
374
|
+
subjectKind: z.ZodEnum<{
|
|
375
|
+
workflow: "workflow";
|
|
376
|
+
agent: "agent";
|
|
377
|
+
}>;
|
|
378
|
+
occurredAt: z.ZodString;
|
|
379
|
+
deltaReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
380
|
+
deltaSource: z.ZodDefault<z.ZodEnum<{
|
|
381
|
+
unknown: "unknown";
|
|
382
|
+
human: "human";
|
|
383
|
+
llm: "llm";
|
|
384
|
+
}>>;
|
|
385
|
+
actionability: z.ZodDefault<z.ZodLiteral<"unknown">>;
|
|
386
|
+
}, z.core.$strict>], "contextType">>;
|
|
387
|
+
observation: z.ZodOptional<z.ZodObject<{
|
|
388
|
+
sourceType: z.ZodString;
|
|
389
|
+
sourceRef: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
390
|
+
generatingSubject: z.ZodObject<{
|
|
391
|
+
subjectId: z.ZodString;
|
|
392
|
+
subjectKind: z.ZodEnum<{
|
|
393
|
+
workflow: "workflow";
|
|
394
|
+
agent: "agent";
|
|
395
|
+
}>;
|
|
396
|
+
}, z.core.$strict>;
|
|
397
|
+
occurredAt: z.ZodISODateTime;
|
|
398
|
+
summary: z.ZodNullable<z.ZodString>;
|
|
399
|
+
metrics: z.ZodCustom<import("./monitoring-annotations").MonitoringJson, import("./monitoring-annotations").MonitoringJson>;
|
|
400
|
+
conversationFindings: z.ZodArray<z.ZodObject<{
|
|
401
|
+
type: z.ZodString;
|
|
402
|
+
description: z.ZodString;
|
|
403
|
+
excerpt: z.ZodString;
|
|
404
|
+
severity: z.ZodEnum<{
|
|
405
|
+
high: "high";
|
|
406
|
+
medium: "medium";
|
|
407
|
+
low: "low";
|
|
408
|
+
}>;
|
|
409
|
+
}, z.core.$strict>>;
|
|
410
|
+
classifications: z.ZodArray<z.ZodObject<{
|
|
411
|
+
matchedBucketSlug: z.ZodNullable<z.ZodString>;
|
|
412
|
+
newBucketProposal: z.ZodNullable<z.ZodObject<{
|
|
413
|
+
name: z.ZodString;
|
|
414
|
+
description: z.ZodString;
|
|
415
|
+
severity: z.ZodEnum<{
|
|
416
|
+
critical: "critical";
|
|
417
|
+
high: "high";
|
|
418
|
+
medium: "medium";
|
|
419
|
+
low: "low";
|
|
420
|
+
}>;
|
|
421
|
+
category: z.ZodString;
|
|
422
|
+
}, z.core.$strict>>;
|
|
423
|
+
excerpt: z.ZodString;
|
|
424
|
+
inputTags: z.ZodArray<z.ZodObject<{
|
|
425
|
+
type: z.ZodString;
|
|
426
|
+
value: z.ZodString;
|
|
427
|
+
}, z.core.$strict>>;
|
|
428
|
+
}, z.core.$strict>>;
|
|
429
|
+
coarseFallbacks: z.ZodArray<z.ZodObject<{
|
|
430
|
+
bucketSlug: z.ZodString;
|
|
431
|
+
excerpt: z.ZodString;
|
|
432
|
+
coarseCategory: z.ZodString;
|
|
433
|
+
}, z.core.$strict>>;
|
|
434
|
+
}, z.core.$strict>>;
|
|
435
|
+
operation: z.ZodLiteral<"publish">;
|
|
436
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
437
|
+
producer: z.ZodString;
|
|
438
|
+
businessKey: z.ZodString;
|
|
439
|
+
operation: z.ZodLiteral<"get">;
|
|
440
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
441
|
+
producer: z.ZodString;
|
|
442
|
+
operation: z.ZodLiteral<"getBucketCatalog">;
|
|
443
|
+
}, z.core.$strict>], "operation">;
|
|
444
|
+
export type MonitoringPublish = z.input<typeof monitoringPublishSchema>;
|
|
445
|
+
export type MonitoringDeliveryKey = z.infer<typeof monitoringDeliveryKeySchema>;
|
|
446
|
+
export type FunctionMonitoringRequest = z.infer<typeof functionMonitoringRequestSchema>;
|
|
447
|
+
export declare const monitoringDeliveryReceiptSchema: z.ZodObject<{
|
|
448
|
+
id: z.ZodUUID;
|
|
449
|
+
producer: z.ZodString;
|
|
450
|
+
businessKey: z.ZodString;
|
|
451
|
+
payloadHash: z.ZodString;
|
|
452
|
+
status: z.ZodLiteral<"confirmed">;
|
|
453
|
+
eventCount: z.ZodNumber;
|
|
454
|
+
confirmedAt: z.ZodISODateTime;
|
|
455
|
+
eventIds: z.ZodArray<z.ZodUUID>;
|
|
456
|
+
}, z.core.$strict>;
|
|
457
|
+
export type MonitoringDeliveryReceipt = z.infer<typeof monitoringDeliveryReceiptSchema>;
|
|
458
|
+
export declare class FunctionMonitoringError extends Error {
|
|
459
|
+
readonly status: number;
|
|
460
|
+
readonly code: string;
|
|
461
|
+
readonly name = "FunctionMonitoringError";
|
|
462
|
+
constructor(status: number, code: string, message: string);
|
|
463
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FunctionMonitoringError = exports.monitoringDeliveryReceiptSchema = exports.functionMonitoringRequestSchema = exports.monitoringPublishSchema = exports.monitoringBucketCatalogSchema = exports.monitoringCatalogQuerySchema = exports.monitoringDeliveryKeySchema = exports.monitoringEventsSchema = exports.functionMonitoringScopesSchema = exports.MAX_MONITORING_DELIVERY_BYTES = exports.MONITORING_CATALOG_CAPABILITY = exports.MONITORING_PRODUCER_CAPABILITY = exports.FUNCTION_MONITORING_DELIVERIES_PATH = exports.FUNCTION_MONITORING_TOKEN_HEADER = void 0;
|
|
4
|
+
exports.readFunctionMonitoringScopes = readFunctionMonitoringScopes;
|
|
5
|
+
exports.monitoringPayloadHash = monitoringPayloadHash;
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const monitoring_events_1 = require("./monitoring-events");
|
|
9
|
+
const monitoring_annotations_1 = require("./monitoring-annotations");
|
|
10
|
+
exports.FUNCTION_MONITORING_TOKEN_HEADER = 'x-sequence-monitoring-service-token';
|
|
11
|
+
exports.FUNCTION_MONITORING_DELIVERIES_PATH = '/api/managed-functions/monitoring/deliveries';
|
|
12
|
+
exports.MONITORING_PRODUCER_CAPABILITY = 'emit_monitoring';
|
|
13
|
+
exports.MONITORING_CATALOG_CAPABILITY = 'read_monitoring_catalog';
|
|
14
|
+
exports.MAX_MONITORING_DELIVERY_BYTES = 512 * 1024;
|
|
15
|
+
const producer = zod_1.z.string().min(1).max(41).regex(/^[a-z][a-z0-9_]{0,40}$/);
|
|
16
|
+
exports.functionMonitoringScopesSchema = zod_1.z.strictObject({
|
|
17
|
+
producers: zod_1.z.array(producer).min(1).max(16).refine(ids => new Set(ids).size === ids.length, 'Producer namespaces must be distinct'),
|
|
18
|
+
});
|
|
19
|
+
function readFunctionMonitoringScopes(manifest) {
|
|
20
|
+
if (typeof manifest !== 'object' || manifest === null)
|
|
21
|
+
return [];
|
|
22
|
+
const capabilities = Reflect.get(manifest, 'capabilities');
|
|
23
|
+
if (typeof capabilities !== 'object' || capabilities === null)
|
|
24
|
+
return [];
|
|
25
|
+
const monitoring = Reflect.get(capabilities, 'monitoring');
|
|
26
|
+
return monitoring === undefined ? [] : exports.functionMonitoringScopesSchema.parse(monitoring).producers;
|
|
27
|
+
}
|
|
28
|
+
exports.monitoringEventsSchema = zod_1.z.array(monitoring_events_1.deltaEventSchema).max(monitoring_events_1.MAX_DELTA_EVENTS_PER_REQUEST).superRefine((events, context) => {
|
|
29
|
+
const seen = new Set();
|
|
30
|
+
for (const [index, event] of events.entries()) {
|
|
31
|
+
if (seen.has(event.idempotencyKey))
|
|
32
|
+
context.addIssue({ code: 'custom', path: [index, 'idempotencyKey'], message: 'Event keys must be distinct within a delivery' });
|
|
33
|
+
seen.add(event.idempotencyKey);
|
|
34
|
+
}
|
|
35
|
+
if (Buffer.byteLength(JSON.stringify(events), 'utf8') > exports.MAX_MONITORING_DELIVERY_BYTES) {
|
|
36
|
+
context.addIssue({ code: 'custom', message: 'Monitoring events exceed the delivery size limit' });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
function canonical(value) {
|
|
40
|
+
if (Array.isArray(value))
|
|
41
|
+
return `[${value.map(canonical).join(',')}]`;
|
|
42
|
+
if (typeof value === 'object' && value !== null) {
|
|
43
|
+
return `{${Object.entries(value).filter(([, entry]) => entry !== undefined).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entry]) => `${JSON.stringify(key)}:${canonical(entry)}`).join(',')}}`;
|
|
44
|
+
}
|
|
45
|
+
const serialized = JSON.stringify(value);
|
|
46
|
+
if (serialized === undefined)
|
|
47
|
+
throw new Error('Monitoring payload is not JSON');
|
|
48
|
+
return serialized;
|
|
49
|
+
}
|
|
50
|
+
function monitoringPayloadHash({ events, observation }) {
|
|
51
|
+
return (0, node_crypto_1.createHash)('sha256').update(canonical({ events: exports.monitoringEventsSchema.parse(events), ...(observation === undefined ? {} : { observation: monitoring_annotations_1.functionMonitoringAnnotationSchema.parse(observation) }) })).digest('hex');
|
|
52
|
+
}
|
|
53
|
+
const key = zod_1.z.string().min(1).max(512);
|
|
54
|
+
exports.monitoringDeliveryKeySchema = zod_1.z.strictObject({ producer, businessKey: key });
|
|
55
|
+
exports.monitoringCatalogQuerySchema = zod_1.z.strictObject({ producer });
|
|
56
|
+
exports.monitoringBucketCatalogSchema = zod_1.z.strictObject({
|
|
57
|
+
producer, complete: zod_1.z.literal(true), buckets: zod_1.z.array(zod_1.z.strictObject({
|
|
58
|
+
slug: zod_1.z.string().min(1).max(512), name: zod_1.z.string().max(512), description: zod_1.z.string().max(50_000),
|
|
59
|
+
severity: zod_1.z.enum(['critical', 'high', 'medium', 'low']), category: zod_1.z.string().max(512),
|
|
60
|
+
})).max(2000),
|
|
61
|
+
});
|
|
62
|
+
exports.monitoringPublishSchema = exports.monitoringDeliveryKeySchema.extend({
|
|
63
|
+
payloadHash: zod_1.z.string().regex(/^[a-f0-9]{64}$/), events: exports.monitoringEventsSchema,
|
|
64
|
+
observation: monitoring_annotations_1.functionMonitoringAnnotationSchema.optional(),
|
|
65
|
+
});
|
|
66
|
+
exports.functionMonitoringRequestSchema = zod_1.z.discriminatedUnion('operation', [
|
|
67
|
+
exports.monitoringPublishSchema.extend({ operation: zod_1.z.literal('publish') }),
|
|
68
|
+
exports.monitoringDeliveryKeySchema.extend({ operation: zod_1.z.literal('get') }),
|
|
69
|
+
exports.monitoringCatalogQuerySchema.extend({ operation: zod_1.z.literal('getBucketCatalog') }),
|
|
70
|
+
]).superRefine((request, context) => {
|
|
71
|
+
if (Buffer.byteLength(JSON.stringify(request), 'utf8') > exports.MAX_MONITORING_DELIVERY_BYTES)
|
|
72
|
+
context.addIssue({ code: 'custom', message: 'Monitoring delivery exceeds the size limit' });
|
|
73
|
+
});
|
|
74
|
+
exports.monitoringDeliveryReceiptSchema = zod_1.z.strictObject({
|
|
75
|
+
id: zod_1.z.uuid(), producer, businessKey: key, payloadHash: zod_1.z.string().regex(/^[a-f0-9]{64}$/),
|
|
76
|
+
status: zod_1.z.literal('confirmed'), eventCount: zod_1.z.number().int().min(0).max(monitoring_events_1.MAX_DELTA_EVENTS_PER_REQUEST),
|
|
77
|
+
confirmedAt: zod_1.z.iso.datetime({ offset: true }), eventIds: zod_1.z.array(zod_1.z.uuid()).max(monitoring_events_1.MAX_DELTA_EVENTS_PER_REQUEST),
|
|
78
|
+
}).refine(receipt => receipt.eventCount === receipt.eventIds.length && new Set(receipt.eventIds).size === receipt.eventIds.length, 'Receipt count must match distinct event ids');
|
|
79
|
+
class FunctionMonitoringError extends Error {
|
|
80
|
+
status;
|
|
81
|
+
code;
|
|
82
|
+
name = 'FunctionMonitoringError';
|
|
83
|
+
constructor(status, code, message) {
|
|
84
|
+
super(message);
|
|
85
|
+
this.status = status;
|
|
86
|
+
this.code = code;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.FunctionMonitoringError = FunctionMonitoringError;
|