@sensu-ai/sdk 0.1.1 → 0.1.3
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/package.json +6 -6
- package/src/client.ts +338 -1
- package/src/index.ts +15 -0
- package/src/types.ts +148 -0
- package/dist/client.d.ts +0 -76
- package/dist/client.d.ts.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/integrations/langchain.d.ts +0 -46
- package/dist/integrations/langchain.d.ts.map +0 -1
- package/dist/integrations/openai.d.ts +0 -26
- package/dist/integrations/openai.d.ts.map +0 -1
- package/dist/types.d.ts +0 -60
- package/dist/types.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sensu-ai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"./integrations/langchain": "./src/integrations/langchain.ts",
|
|
9
9
|
"./integrations/openai": "./src/integrations/openai.ts"
|
|
10
10
|
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsc --watch"
|
|
14
|
+
},
|
|
11
15
|
"dependencies": {
|
|
12
16
|
"@sensu-ai/shared": "*",
|
|
13
17
|
"zod": "^3.23.8"
|
|
@@ -27,9 +31,5 @@
|
|
|
27
31
|
"openai": {
|
|
28
32
|
"optional": true
|
|
29
33
|
}
|
|
30
|
-
},
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "tsc",
|
|
33
|
-
"dev": "tsc --watch"
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -7,6 +7,21 @@ import type {
|
|
|
7
7
|
TrackLlmOptions,
|
|
8
8
|
TrackToolOptions,
|
|
9
9
|
RawLlmCallOptions,
|
|
10
|
+
ContextBreakdown,
|
|
11
|
+
TrackRetrievalOptions,
|
|
12
|
+
RawRetrievalOptions,
|
|
13
|
+
TrackEmbeddingOptions,
|
|
14
|
+
RawEmbeddingOptions,
|
|
15
|
+
RecordFeedbackOptions,
|
|
16
|
+
RecordEvalScoreOptions,
|
|
17
|
+
HandoffOptions,
|
|
18
|
+
SpawnRunOptions,
|
|
19
|
+
TrackGuardrailOptions,
|
|
20
|
+
RawGuardrailOptions,
|
|
21
|
+
RecordPromptRenderOptions,
|
|
22
|
+
DeployPromptVersionOptions,
|
|
23
|
+
StartSessionOptions,
|
|
24
|
+
ResumeSessionOptions,
|
|
10
25
|
} from './types.js';
|
|
11
26
|
|
|
12
27
|
// ---------------------------------------------------------------------------
|
|
@@ -96,6 +111,7 @@ export class StepHandle {
|
|
|
96
111
|
|
|
97
112
|
// Try to extract token usage from common response shapes
|
|
98
113
|
const usage = extractUsage(result, opts.model);
|
|
114
|
+
const contextBreakdown = opts.extractContextBreakdown?.(result);
|
|
99
115
|
|
|
100
116
|
this.client.enqueue({
|
|
101
117
|
...this.base(),
|
|
@@ -107,6 +123,7 @@ export class StepHandle {
|
|
|
107
123
|
latency_ms: latencyMs,
|
|
108
124
|
status,
|
|
109
125
|
...usage,
|
|
126
|
+
...(contextBreakdown ? { context_breakdown: contextBreakdown } : {}),
|
|
110
127
|
});
|
|
111
128
|
|
|
112
129
|
if (err) throw err;
|
|
@@ -115,10 +132,12 @@ export class StepHandle {
|
|
|
115
132
|
|
|
116
133
|
/** Emit a raw LLM call event (when you have the stats already) */
|
|
117
134
|
recordLlm(opts: RawLlmCallOptions): void {
|
|
135
|
+
const { contextBreakdown, ...rest } = opts;
|
|
118
136
|
this.client.enqueue({
|
|
119
137
|
...this.base(),
|
|
120
138
|
event_type: 'llm.request.completed',
|
|
121
|
-
...
|
|
139
|
+
...rest,
|
|
140
|
+
...(contextBreakdown ? { context_breakdown: contextBreakdown } : {}),
|
|
122
141
|
});
|
|
123
142
|
}
|
|
124
143
|
|
|
@@ -152,6 +171,171 @@ export class StepHandle {
|
|
|
152
171
|
return result;
|
|
153
172
|
}
|
|
154
173
|
|
|
174
|
+
/** Track a retrieval call — wraps fn(), measures latency, emits started + completed */
|
|
175
|
+
async trackRetrieval(opts: TrackRetrievalOptions): Promise<unknown> {
|
|
176
|
+
const startMs = Date.now();
|
|
177
|
+
const spanId = randomUUID();
|
|
178
|
+
|
|
179
|
+
this.client.enqueue({
|
|
180
|
+
...this.base(),
|
|
181
|
+
span_id: spanId,
|
|
182
|
+
event_type: 'retrieval.started',
|
|
183
|
+
vector_store_id: opts.vectorStoreId,
|
|
184
|
+
top_k: opts.topK,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
let result: unknown;
|
|
188
|
+
let status: 'success' | 'error' = 'success';
|
|
189
|
+
let err: unknown;
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
result = await opts.fn();
|
|
193
|
+
} catch (e) {
|
|
194
|
+
status = 'error';
|
|
195
|
+
err = e;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const latencyMs = Date.now() - startMs;
|
|
199
|
+
|
|
200
|
+
this.client.enqueue({
|
|
201
|
+
...this.base(),
|
|
202
|
+
span_id: spanId,
|
|
203
|
+
event_type: 'retrieval.completed',
|
|
204
|
+
vector_store_id: opts.vectorStoreId,
|
|
205
|
+
top_k: opts.topK,
|
|
206
|
+
latency_ms: latencyMs,
|
|
207
|
+
status,
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
if (err) throw err;
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Emit a raw retrieval completed event (when you have the stats already) */
|
|
215
|
+
recordRetrieval(opts: RawRetrievalOptions): void {
|
|
216
|
+
this.client.enqueue({
|
|
217
|
+
...this.base(),
|
|
218
|
+
event_type: 'retrieval.completed',
|
|
219
|
+
...opts,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Track an embedding call — wraps fn(), measures latency */
|
|
224
|
+
async trackEmbedding(opts: TrackEmbeddingOptions): Promise<unknown> {
|
|
225
|
+
const startMs = Date.now();
|
|
226
|
+
let result: unknown;
|
|
227
|
+
let err: unknown;
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
result = await opts.fn();
|
|
231
|
+
} catch (e) {
|
|
232
|
+
err = e;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const latencyMs = Date.now() - startMs;
|
|
236
|
+
|
|
237
|
+
this.client.enqueue({
|
|
238
|
+
...this.base(),
|
|
239
|
+
event_type: 'embedding.created',
|
|
240
|
+
model: opts.model,
|
|
241
|
+
input_text_length: opts.inputTextLength,
|
|
242
|
+
batch_size: opts.batchSize,
|
|
243
|
+
latency_ms: latencyMs,
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
if (err) throw err;
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Emit a raw embedding event */
|
|
251
|
+
recordEmbedding(opts: RawEmbeddingOptions): void {
|
|
252
|
+
this.client.enqueue({
|
|
253
|
+
...this.base(),
|
|
254
|
+
event_type: 'embedding.created',
|
|
255
|
+
model: opts.model,
|
|
256
|
+
input_text_length: opts.inputTextLength,
|
|
257
|
+
token_count: opts.tokenCount,
|
|
258
|
+
latency_ms: opts.latencyMs,
|
|
259
|
+
cost_usd_estimate: opts.costUsdEstimate,
|
|
260
|
+
batch_size: opts.batchSize,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Track a guardrail check — wraps fn(), measures latency, handles block */
|
|
265
|
+
async trackGuardrail(opts: TrackGuardrailOptions): Promise<'pass' | 'fail' | 'modified'> {
|
|
266
|
+
const startMs = Date.now();
|
|
267
|
+
|
|
268
|
+
this.client.enqueue({
|
|
269
|
+
...this.base(),
|
|
270
|
+
event_type: 'guardrail.check.started',
|
|
271
|
+
guardrail_id: opts.guardrailId,
|
|
272
|
+
guardrail_type: opts.guardrailType,
|
|
273
|
+
input_hash: opts.inputHash,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
let result: 'pass' | 'fail' | 'modified' = 'pass';
|
|
277
|
+
let err: unknown;
|
|
278
|
+
|
|
279
|
+
try {
|
|
280
|
+
result = await opts.fn();
|
|
281
|
+
} catch (e) {
|
|
282
|
+
err = e;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const latencyMs = Date.now() - startMs;
|
|
286
|
+
|
|
287
|
+
this.client.enqueue({
|
|
288
|
+
...this.base(),
|
|
289
|
+
event_type: 'guardrail.check.completed',
|
|
290
|
+
guardrail_id: opts.guardrailId,
|
|
291
|
+
guardrail_type: opts.guardrailType,
|
|
292
|
+
input_hash: opts.inputHash,
|
|
293
|
+
result,
|
|
294
|
+
latency_ms: latencyMs,
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
if (err) throw err;
|
|
298
|
+
return result;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Emit a raw guardrail result (check or block) */
|
|
302
|
+
recordGuardrail(opts: RawGuardrailOptions): void {
|
|
303
|
+
if (opts.blocked) {
|
|
304
|
+
this.client.enqueue({
|
|
305
|
+
...this.base(),
|
|
306
|
+
event_type: 'guardrail.blocked',
|
|
307
|
+
guardrail_id: opts.guardrailId,
|
|
308
|
+
guardrail_type: opts.guardrailType,
|
|
309
|
+
input_hash: opts.inputHash,
|
|
310
|
+
block_reason: opts.blockReason,
|
|
311
|
+
severity: opts.severity,
|
|
312
|
+
});
|
|
313
|
+
} else {
|
|
314
|
+
this.client.enqueue({
|
|
315
|
+
...this.base(),
|
|
316
|
+
event_type: 'guardrail.check.completed',
|
|
317
|
+
guardrail_id: opts.guardrailId,
|
|
318
|
+
guardrail_type: opts.guardrailType,
|
|
319
|
+
input_hash: opts.inputHash,
|
|
320
|
+
result: opts.result,
|
|
321
|
+
latency_ms: opts.latencyMs,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Record a prompt template render event */
|
|
327
|
+
recordPromptRender(opts: RecordPromptRenderOptions): void {
|
|
328
|
+
this.client.enqueue({
|
|
329
|
+
...this.base(),
|
|
330
|
+
event_type: 'prompt.rendered',
|
|
331
|
+
template_id: opts.templateId,
|
|
332
|
+
template_version: opts.templateVersion,
|
|
333
|
+
rendered_token_count: opts.renderedTokenCount,
|
|
334
|
+
variable_count: opts.variableCount,
|
|
335
|
+
latency_ms: opts.latencyMs,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
155
339
|
async end(): Promise<void> {
|
|
156
340
|
if (this.ended) return;
|
|
157
341
|
this.ended = true;
|
|
@@ -238,6 +422,41 @@ export class RunHandle {
|
|
|
238
422
|
});
|
|
239
423
|
}
|
|
240
424
|
|
|
425
|
+
/** Record user feedback for this run */
|
|
426
|
+
recordFeedback(opts: RecordFeedbackOptions): void {
|
|
427
|
+
this.client.enqueue({
|
|
428
|
+
...this.base(),
|
|
429
|
+
event_type: 'feedback.received',
|
|
430
|
+
type: opts.type,
|
|
431
|
+
score: opts.score,
|
|
432
|
+
comment: opts.comment,
|
|
433
|
+
end_user_id: opts.endUserId,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** Record an automated eval score for this run */
|
|
438
|
+
recordEvalScore(opts: RecordEvalScoreOptions): void {
|
|
439
|
+
this.client.enqueue({
|
|
440
|
+
...this.base(),
|
|
441
|
+
event_type: 'eval.score.recorded',
|
|
442
|
+
metric: opts.metric,
|
|
443
|
+
score: opts.score,
|
|
444
|
+
evaluator_id: opts.evaluatorId,
|
|
445
|
+
model_used_for_eval: opts.modelUsedForEval,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/** Emit an agent.handoff event from this run to another agent */
|
|
450
|
+
handoff(opts: HandoffOptions): void {
|
|
451
|
+
this.client.enqueue({
|
|
452
|
+
...this.base(),
|
|
453
|
+
event_type: 'agent.handoff',
|
|
454
|
+
to_agent_id: opts.toAgentId,
|
|
455
|
+
reason: opts.reason,
|
|
456
|
+
context_tokens_transferred: opts.contextTokensTransferred,
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
|
|
241
460
|
async end(status: 'completed' | 'failed' = 'completed'): Promise<void> {
|
|
242
461
|
if (this.ended) return;
|
|
243
462
|
this.ended = true;
|
|
@@ -358,6 +577,124 @@ export class SensuClient {
|
|
|
358
577
|
});
|
|
359
578
|
}
|
|
360
579
|
|
|
580
|
+
/**
|
|
581
|
+
* Spawn a child agent run from within a parent run.
|
|
582
|
+
* Emits `agent.spawned` on the parent and returns a RunHandle for the child.
|
|
583
|
+
*/
|
|
584
|
+
spawnRun(parentRun: RunHandle, opts: SpawnRunOptions): RunHandle {
|
|
585
|
+
const childRunId = opts.childRunId ?? randomUUID();
|
|
586
|
+
const childAgentId = opts.childAgentId;
|
|
587
|
+
const sessionId = opts.sessionId ?? parentRun.sessionId;
|
|
588
|
+
const traceId = parentRun.traceId;
|
|
589
|
+
const spanId = randomUUID();
|
|
590
|
+
|
|
591
|
+
// Emit agent.spawned on the parent run
|
|
592
|
+
this.enqueue({
|
|
593
|
+
event_id: randomUUID(),
|
|
594
|
+
event_type: 'agent.spawned',
|
|
595
|
+
timestamp: new Date().toISOString(),
|
|
596
|
+
org_id: this.orgId,
|
|
597
|
+
agent_id: parentRun.agentId,
|
|
598
|
+
session_id: sessionId,
|
|
599
|
+
run_id: parentRun.runId,
|
|
600
|
+
trace_id: traceId,
|
|
601
|
+
span_id: spanId,
|
|
602
|
+
child_run_id: childRunId,
|
|
603
|
+
child_agent_id: childAgentId,
|
|
604
|
+
spawn_reason: opts.spawnReason,
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
// Emit agent.run.started for the child run (child agent emits this itself in practice,
|
|
608
|
+
// but the SDK can also do it on behalf of known child agents)
|
|
609
|
+
this.enqueue({
|
|
610
|
+
event_id: randomUUID(),
|
|
611
|
+
event_type: 'agent.run.started',
|
|
612
|
+
timestamp: new Date().toISOString(),
|
|
613
|
+
org_id: this.orgId,
|
|
614
|
+
agent_id: childAgentId,
|
|
615
|
+
session_id: sessionId,
|
|
616
|
+
run_id: childRunId,
|
|
617
|
+
trace_id: traceId,
|
|
618
|
+
span_id: randomUUID(),
|
|
619
|
+
run_type: opts.runType,
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
return new RunHandle(this, {
|
|
623
|
+
runId: childRunId,
|
|
624
|
+
sessionId,
|
|
625
|
+
agentId: childAgentId,
|
|
626
|
+
orgId: this.orgId,
|
|
627
|
+
traceId,
|
|
628
|
+
spanId,
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/** Explicitly start a session (sets channel and end_user_id) */
|
|
633
|
+
startSession(opts: StartSessionOptions = {}): string {
|
|
634
|
+
const sessionId = opts.sessionId ?? randomUUID();
|
|
635
|
+
const traceId = randomUUID();
|
|
636
|
+
const spanId = randomUUID();
|
|
637
|
+
|
|
638
|
+
this.enqueue({
|
|
639
|
+
event_id: randomUUID(),
|
|
640
|
+
event_type: 'session.started',
|
|
641
|
+
timestamp: new Date().toISOString(),
|
|
642
|
+
org_id: this.orgId,
|
|
643
|
+
agent_id: this.agentId,
|
|
644
|
+
session_id: sessionId,
|
|
645
|
+
run_id: sessionId, // run_id required by base schema; reuse session_id as placeholder
|
|
646
|
+
trace_id: traceId,
|
|
647
|
+
span_id: spanId,
|
|
648
|
+
channel: opts.channel,
|
|
649
|
+
end_user_id: opts.endUserId,
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
return sessionId;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/** Resume a previous session */
|
|
656
|
+
resumeSession(opts: ResumeSessionOptions): string {
|
|
657
|
+
const sessionId = opts.sessionId ?? randomUUID();
|
|
658
|
+
const traceId = randomUUID();
|
|
659
|
+
const spanId = randomUUID();
|
|
660
|
+
|
|
661
|
+
this.enqueue({
|
|
662
|
+
event_id: randomUUID(),
|
|
663
|
+
event_type: 'session.resumed',
|
|
664
|
+
timestamp: new Date().toISOString(),
|
|
665
|
+
org_id: this.orgId,
|
|
666
|
+
agent_id: this.agentId,
|
|
667
|
+
session_id: sessionId,
|
|
668
|
+
run_id: sessionId,
|
|
669
|
+
trace_id: traceId,
|
|
670
|
+
span_id: spanId,
|
|
671
|
+
resumed_from_session_id: opts.resumedFromSessionId,
|
|
672
|
+
channel: opts.channel,
|
|
673
|
+
end_user_id: opts.endUserId,
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
return sessionId;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/** Record a prompt version deployment (org-level event, not tied to a run) */
|
|
680
|
+
deployPromptVersion(opts: DeployPromptVersionOptions): void {
|
|
681
|
+
this.enqueue({
|
|
682
|
+
event_id: randomUUID(),
|
|
683
|
+
event_type: 'prompt.version.deployed',
|
|
684
|
+
timestamp: new Date().toISOString(),
|
|
685
|
+
org_id: this.orgId,
|
|
686
|
+
agent_id: this.agentId,
|
|
687
|
+
session_id: 'system',
|
|
688
|
+
run_id: 'system',
|
|
689
|
+
trace_id: randomUUID(),
|
|
690
|
+
span_id: randomUUID(),
|
|
691
|
+
template_id: opts.templateId,
|
|
692
|
+
new_version: opts.newVersion,
|
|
693
|
+
old_version: opts.oldVersion,
|
|
694
|
+
deployed_by: opts.deployedBy,
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
|
|
361
698
|
destroy(): void {
|
|
362
699
|
if (this.flushTimer) clearInterval(this.flushTimer);
|
|
363
700
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,4 +6,19 @@ export type {
|
|
|
6
6
|
TrackLlmOptions,
|
|
7
7
|
TrackToolOptions,
|
|
8
8
|
RawLlmCallOptions,
|
|
9
|
+
ContextBreakdown,
|
|
10
|
+
TrackRetrievalOptions,
|
|
11
|
+
RawRetrievalOptions,
|
|
12
|
+
TrackEmbeddingOptions,
|
|
13
|
+
RawEmbeddingOptions,
|
|
14
|
+
RecordFeedbackOptions,
|
|
15
|
+
RecordEvalScoreOptions,
|
|
16
|
+
SpawnRunOptions,
|
|
17
|
+
HandoffOptions,
|
|
18
|
+
TrackGuardrailOptions,
|
|
19
|
+
RawGuardrailOptions,
|
|
20
|
+
RecordPromptRenderOptions,
|
|
21
|
+
DeployPromptVersionOptions,
|
|
22
|
+
StartSessionOptions,
|
|
23
|
+
ResumeSessionOptions,
|
|
9
24
|
} from './types.ts';
|
package/src/types.ts
CHANGED
|
@@ -27,12 +27,25 @@ export interface StartStepOptions {
|
|
|
27
27
|
stepId?: string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export interface ContextBreakdown {
|
|
31
|
+
system_tokens?: number;
|
|
32
|
+
user_tokens?: number;
|
|
33
|
+
assistant_tokens?: number;
|
|
34
|
+
tool_tokens?: number;
|
|
35
|
+
retrieval_tokens?: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
export interface TrackLlmOptions {
|
|
31
39
|
provider: string;
|
|
32
40
|
model: string;
|
|
33
41
|
/** Wraps the LLM call and measures latency automatically */
|
|
34
42
|
fn: () => Promise<unknown>;
|
|
35
43
|
maxContextTokens?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Optional callback to extract a context breakdown from the LLM response.
|
|
46
|
+
* Called with the raw response after fn() resolves.
|
|
47
|
+
*/
|
|
48
|
+
extractContextBreakdown?: (result: unknown) => ContextBreakdown | undefined;
|
|
36
49
|
}
|
|
37
50
|
|
|
38
51
|
export interface LlmResult {
|
|
@@ -62,4 +75,139 @@ export interface RawLlmCallOptions {
|
|
|
62
75
|
ttftMs?: number;
|
|
63
76
|
costUsdEstimate?: number;
|
|
64
77
|
status?: 'success' | 'error' | 'timeout';
|
|
78
|
+
contextBreakdown?: ContextBreakdown;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
// Retrieval & Embedding
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
|
|
85
|
+
export interface TrackRetrievalOptions {
|
|
86
|
+
/** Wraps the retrieval call and measures latency automatically */
|
|
87
|
+
fn: () => Promise<unknown>;
|
|
88
|
+
vectorStoreId?: string;
|
|
89
|
+
topK?: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface RawRetrievalOptions {
|
|
93
|
+
vectorStoreId?: string;
|
|
94
|
+
topK?: number;
|
|
95
|
+
latencyMs?: number;
|
|
96
|
+
chunksReturned?: number;
|
|
97
|
+
tokensInjected?: number;
|
|
98
|
+
similarityScoreAvg?: number;
|
|
99
|
+
status?: 'success' | 'error';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface TrackEmbeddingOptions {
|
|
103
|
+
model: string;
|
|
104
|
+
/** Wraps the embedding call and measures latency automatically */
|
|
105
|
+
fn: () => Promise<unknown>;
|
|
106
|
+
inputTextLength?: number;
|
|
107
|
+
batchSize?: number;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface RawEmbeddingOptions {
|
|
111
|
+
model: string;
|
|
112
|
+
inputTextLength?: number;
|
|
113
|
+
tokenCount?: number;
|
|
114
|
+
latencyMs?: number;
|
|
115
|
+
costUsdEstimate?: number;
|
|
116
|
+
batchSize?: number;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
// Evaluation & Feedback
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
export interface RecordFeedbackOptions {
|
|
124
|
+
type: 'thumbs_up' | 'thumbs_down' | 'score' | 'correction';
|
|
125
|
+
score?: number;
|
|
126
|
+
comment?: string;
|
|
127
|
+
endUserId?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface RecordEvalScoreOptions {
|
|
131
|
+
metric: string;
|
|
132
|
+
score: number;
|
|
133
|
+
evaluatorId?: string;
|
|
134
|
+
modelUsedForEval?: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
// Multi-Agent
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
|
|
141
|
+
export interface SpawnRunOptions {
|
|
142
|
+
childAgentId: string;
|
|
143
|
+
childRunId?: string;
|
|
144
|
+
spawnReason?: string;
|
|
145
|
+
/** Options forwarded to the child RunHandle */
|
|
146
|
+
runType?: string;
|
|
147
|
+
sessionId?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface HandoffOptions {
|
|
151
|
+
toAgentId: string;
|
|
152
|
+
reason?: string;
|
|
153
|
+
contextTokensTransferred?: number;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
// Guardrails
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
|
|
160
|
+
export interface TrackGuardrailOptions {
|
|
161
|
+
guardrailId: string;
|
|
162
|
+
guardrailType?: 'content' | 'pii' | 'jailbreak' | 'custom';
|
|
163
|
+
inputHash?: string;
|
|
164
|
+
/** Wraps the guardrail check and measures latency automatically */
|
|
165
|
+
fn: () => Promise<'pass' | 'fail' | 'modified'>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface RawGuardrailOptions {
|
|
169
|
+
guardrailId: string;
|
|
170
|
+
guardrailType?: 'content' | 'pii' | 'jailbreak' | 'custom';
|
|
171
|
+
inputHash?: string;
|
|
172
|
+
result?: 'pass' | 'fail' | 'modified';
|
|
173
|
+
blockReason?: string;
|
|
174
|
+
severity?: 'low' | 'medium' | 'high';
|
|
175
|
+
latencyMs?: number;
|
|
176
|
+
blocked?: boolean;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
// Prompt Management
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
|
|
183
|
+
export interface RecordPromptRenderOptions {
|
|
184
|
+
templateId: string;
|
|
185
|
+
templateVersion?: string;
|
|
186
|
+
renderedTokenCount?: number;
|
|
187
|
+
variableCount?: number;
|
|
188
|
+
latencyMs?: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface DeployPromptVersionOptions {
|
|
192
|
+
templateId: string;
|
|
193
|
+
newVersion: string;
|
|
194
|
+
oldVersion?: string;
|
|
195
|
+
deployedBy?: string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// ---------------------------------------------------------------------------
|
|
199
|
+
// Session Lifecycle
|
|
200
|
+
// ---------------------------------------------------------------------------
|
|
201
|
+
|
|
202
|
+
export interface StartSessionOptions {
|
|
203
|
+
sessionId?: string;
|
|
204
|
+
channel?: 'web' | 'api' | 'mobile';
|
|
205
|
+
endUserId?: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface ResumeSessionOptions {
|
|
209
|
+
sessionId?: string;
|
|
210
|
+
resumedFromSessionId: string;
|
|
211
|
+
channel?: 'web' | 'api' | 'mobile';
|
|
212
|
+
endUserId?: string;
|
|
65
213
|
}
|
package/dist/client.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { TelemetryEvent } from '@sensu-ai/shared';
|
|
2
|
-
import type { SensuClientOptions, StartRunOptions, StartStepOptions, TrackLlmOptions, TrackToolOptions, RawLlmCallOptions } from './types.js';
|
|
3
|
-
export declare class StepHandle {
|
|
4
|
-
private readonly client;
|
|
5
|
-
readonly stepId: string;
|
|
6
|
-
readonly runId: string;
|
|
7
|
-
readonly sessionId: string;
|
|
8
|
-
readonly agentId: string;
|
|
9
|
-
readonly orgId: string;
|
|
10
|
-
readonly traceId: string;
|
|
11
|
-
readonly spanId: string;
|
|
12
|
-
private sequence;
|
|
13
|
-
private stepName?;
|
|
14
|
-
private ended;
|
|
15
|
-
constructor(client: SensuClient, opts: {
|
|
16
|
-
stepId: string;
|
|
17
|
-
runId: string;
|
|
18
|
-
sessionId: string;
|
|
19
|
-
agentId: string;
|
|
20
|
-
orgId: string;
|
|
21
|
-
traceId: string;
|
|
22
|
-
spanId: string;
|
|
23
|
-
sequence: number;
|
|
24
|
-
name?: string;
|
|
25
|
-
});
|
|
26
|
-
private base;
|
|
27
|
-
/** Track an LLM call — wraps fn(), measures latency, emits event */
|
|
28
|
-
trackLlm(opts: TrackLlmOptions): Promise<unknown>;
|
|
29
|
-
/** Emit a raw LLM call event (when you have the stats already) */
|
|
30
|
-
recordLlm(opts: RawLlmCallOptions): void;
|
|
31
|
-
/** Track a tool call — wraps fn(), measures latency */
|
|
32
|
-
trackTool(opts: TrackToolOptions): Promise<unknown>;
|
|
33
|
-
end(): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
export declare class RunHandle {
|
|
36
|
-
private readonly client;
|
|
37
|
-
readonly runId: string;
|
|
38
|
-
readonly sessionId: string;
|
|
39
|
-
readonly agentId: string;
|
|
40
|
-
readonly orgId: string;
|
|
41
|
-
readonly traceId: string;
|
|
42
|
-
readonly spanId: string;
|
|
43
|
-
private stepCount;
|
|
44
|
-
private ended;
|
|
45
|
-
constructor(client: SensuClient, opts: {
|
|
46
|
-
runId: string;
|
|
47
|
-
sessionId: string;
|
|
48
|
-
agentId: string;
|
|
49
|
-
orgId: string;
|
|
50
|
-
traceId: string;
|
|
51
|
-
spanId: string;
|
|
52
|
-
});
|
|
53
|
-
private base;
|
|
54
|
-
startStep(opts?: StartStepOptions): StepHandle;
|
|
55
|
-
end(status?: 'completed' | 'failed'): Promise<void>;
|
|
56
|
-
}
|
|
57
|
-
export declare class SensuClient {
|
|
58
|
-
private readonly apiKey;
|
|
59
|
-
private readonly baseUrl;
|
|
60
|
-
private readonly agentId;
|
|
61
|
-
private readonly orgId;
|
|
62
|
-
private readonly batchSize;
|
|
63
|
-
private readonly flushIntervalMs;
|
|
64
|
-
readonly disabled: boolean;
|
|
65
|
-
private buffer;
|
|
66
|
-
private flushTimer;
|
|
67
|
-
constructor(opts?: SensuClientOptions);
|
|
68
|
-
/** Enqueue an event for batched sending */
|
|
69
|
-
enqueue(event: TelemetryEvent): void;
|
|
70
|
-
/** Flush all buffered events to the Sensu API */
|
|
71
|
-
flush(): Promise<void>;
|
|
72
|
-
/** Start a new agent run */
|
|
73
|
-
startRun(opts?: StartRunOptions): RunHandle;
|
|
74
|
-
destroy(): void;
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAMpB,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAS;gBAGpB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC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Q,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,UAAU,CAA+C;gBAErD,IAAI,GAAE,kBAAuB;IA8BzC,2CAA2C;IAC3C,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAQpC,iDAAiD;IAC3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB5B,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,GAAE,eAAoB,GAAG,SAAS;IA8B/C,OAAO,IAAI,IAAI;CAGhB"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LangChain callback handler for Sensu telemetry.
|
|
3
|
-
*
|
|
4
|
-
* Usage:
|
|
5
|
-
* import { SensuCallbackHandler } from '@sensu-ai/sdk/integrations/langchain';
|
|
6
|
-
* const handler = new SensuCallbackHandler({ client: sensu });
|
|
7
|
-
* const chain = new LLMChain({ ..., callbacks: [handler] });
|
|
8
|
-
*/
|
|
9
|
-
import type { SensuClient } from '../client.ts';
|
|
10
|
-
interface LangChainCallbackHandlerOptions {
|
|
11
|
-
client: SensuClient;
|
|
12
|
-
sessionId?: string;
|
|
13
|
-
runId?: string;
|
|
14
|
-
}
|
|
15
|
-
interface LangChainLlmStartInput {
|
|
16
|
-
name?: string;
|
|
17
|
-
[key: string]: unknown;
|
|
18
|
-
}
|
|
19
|
-
interface LangChainLlmEndOutput {
|
|
20
|
-
generations?: Array<Array<{
|
|
21
|
-
text?: string;
|
|
22
|
-
generationInfo?: Record<string, unknown>;
|
|
23
|
-
}>>;
|
|
24
|
-
llmOutput?: Record<string, unknown>;
|
|
25
|
-
}
|
|
26
|
-
export declare class SensuCallbackHandler {
|
|
27
|
-
private readonly client;
|
|
28
|
-
private readonly sessionId;
|
|
29
|
-
private runId;
|
|
30
|
-
private traceId;
|
|
31
|
-
private startTimes;
|
|
32
|
-
private toolStartTimes;
|
|
33
|
-
private stepIds;
|
|
34
|
-
constructor(opts: LangChainCallbackHandlerOptions);
|
|
35
|
-
private base;
|
|
36
|
-
handleChainStart(_chain: unknown, _inputs: unknown, runId: string): Promise<void>;
|
|
37
|
-
handleChainEnd(_outputs: unknown, runId: string): Promise<void>;
|
|
38
|
-
handleLLMStart(llm: LangChainLlmStartInput, _prompts: string[], runId: string): Promise<void>;
|
|
39
|
-
handleLLMEnd(output: LangChainLlmEndOutput, runId: string): Promise<void>;
|
|
40
|
-
handleLLMError(err: Error, runId: string): Promise<void>;
|
|
41
|
-
handleToolStart(_tool: unknown, _input: string, runId: string): Promise<void>;
|
|
42
|
-
handleToolEnd(output: string, runId: string): Promise<void>;
|
|
43
|
-
handleToolError(err: Error, runId: string): Promise<void>;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
46
|
-
//# sourceMappingURL=langchain.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../src/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAA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AM;IAgBxC,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAU7D,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAgB3C,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM;CAahD"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenAI SDK wrapper for Sensu telemetry.
|
|
3
|
-
* Wraps the OpenAI client to automatically track all completions.
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* import { wrapOpenAI } from '@sensu-ai/sdk/integrations/openai';
|
|
7
|
-
* const openai = wrapOpenAI(new OpenAI({ apiKey }), { client: sensu, runHandle });
|
|
8
|
-
* const resp = await openai.chat.completions.create({ ... }); // auto-tracked
|
|
9
|
-
*/
|
|
10
|
-
import type { SensuClient, RunHandle } from '../client.ts';
|
|
11
|
-
interface OpenAILike {
|
|
12
|
-
chat: {
|
|
13
|
-
completions: {
|
|
14
|
-
create: (params: unknown) => Promise<unknown>;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
interface WrapOpenAIOptions {
|
|
19
|
-
client: SensuClient;
|
|
20
|
-
runHandle?: RunHandle;
|
|
21
|
-
defaultModel?: string;
|
|
22
|
-
defaultProvider?: string;
|
|
23
|
-
}
|
|
24
|
-
export declare function wrapOpenAI<T extends OpenAILike>(openai: T, opts: WrapOpenAIOptions): T;
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/integrations/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,UAAU,UAAU;IAClB,IAAI,EAAE;QACJ,WAAW,EAAE;YACX,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;SAC/C,CAAC;KACH,CAAC;CACH;AAED,UAAU,iBAAiB;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAaD,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,EAC7C,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,iBAAiB,GACtB,CAAC,CAmEH"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
export interface SensuClientOptions {
|
|
2
|
-
apiKey?: string;
|
|
3
|
-
baseUrl?: string;
|
|
4
|
-
agentId?: string;
|
|
5
|
-
orgId?: string;
|
|
6
|
-
/** Read config from environment variables */
|
|
7
|
-
fromEnv?: boolean;
|
|
8
|
-
/** Flush buffer when this many events accumulate */
|
|
9
|
-
batchSize?: number;
|
|
10
|
-
/** Flush buffer every N milliseconds */
|
|
11
|
-
flushIntervalMs?: number;
|
|
12
|
-
/** Disable all telemetry (useful for tests) */
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface StartRunOptions {
|
|
16
|
-
sessionId?: string;
|
|
17
|
-
runType?: string;
|
|
18
|
-
endUserId?: string;
|
|
19
|
-
runId?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface StartStepOptions {
|
|
22
|
-
name?: string;
|
|
23
|
-
stepType?: string;
|
|
24
|
-
sequence?: number;
|
|
25
|
-
stepId?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface TrackLlmOptions {
|
|
28
|
-
provider: string;
|
|
29
|
-
model: string;
|
|
30
|
-
/** Wraps the LLM call and measures latency automatically */
|
|
31
|
-
fn: () => Promise<unknown>;
|
|
32
|
-
maxContextTokens?: number;
|
|
33
|
-
}
|
|
34
|
-
export interface LlmResult {
|
|
35
|
-
inputTokens?: number;
|
|
36
|
-
outputTokens?: number;
|
|
37
|
-
cachedInputTokens?: number;
|
|
38
|
-
totalTokens?: number;
|
|
39
|
-
costUsdEstimate?: number;
|
|
40
|
-
result: unknown;
|
|
41
|
-
}
|
|
42
|
-
export interface TrackToolOptions {
|
|
43
|
-
toolName: string;
|
|
44
|
-
fn: () => Promise<unknown>;
|
|
45
|
-
}
|
|
46
|
-
export interface RawLlmCallOptions {
|
|
47
|
-
provider: string;
|
|
48
|
-
model: string;
|
|
49
|
-
inputTokens?: number;
|
|
50
|
-
outputTokens?: number;
|
|
51
|
-
cachedInputTokens?: number;
|
|
52
|
-
totalTokens?: number;
|
|
53
|
-
maxContextTokens?: number;
|
|
54
|
-
contextUsedTokens?: number;
|
|
55
|
-
latencyMs?: number;
|
|
56
|
-
ttftMs?: number;
|
|
57
|
-
costUsdEstimate?: number;
|
|
58
|
-
status?: 'success' | 'error' | 'timeout';
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;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