@voicethere/agent 0.25.0 → 0.26.0
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 +26 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -0
- package/dist/cli.js.map +1 -1
- package/dist/flow/classify.d.ts +12 -0
- package/dist/flow/classify.d.ts.map +1 -0
- package/dist/flow/classify.js +37 -0
- package/dist/flow/classify.js.map +1 -0
- package/dist/flow/cli-flow.d.ts +19 -0
- package/dist/flow/cli-flow.d.ts.map +1 -0
- package/dist/flow/cli-flow.js +566 -0
- package/dist/flow/cli-flow.js.map +1 -0
- package/dist/flow/core/compile.d.ts +131 -0
- package/dist/flow/core/compile.d.ts.map +1 -0
- package/dist/flow/core/compile.js +197 -0
- package/dist/flow/core/compile.js.map +1 -0
- package/dist/flow/core/conditions.d.ts +5 -0
- package/dist/flow/core/conditions.d.ts.map +1 -0
- package/dist/flow/core/conditions.js +70 -0
- package/dist/flow/core/conditions.js.map +1 -0
- package/dist/flow/core/effects.d.ts +105 -0
- package/dist/flow/core/effects.d.ts.map +1 -0
- package/dist/flow/core/effects.js +2 -0
- package/dist/flow/core/effects.js.map +1 -0
- package/dist/flow/core/generate-mock.d.ts +16 -0
- package/dist/flow/core/generate-mock.d.ts.map +1 -0
- package/dist/flow/core/generate-mock.js +206 -0
- package/dist/flow/core/generate-mock.js.map +1 -0
- package/dist/flow/core/host.d.ts +9 -0
- package/dist/flow/core/host.d.ts.map +1 -0
- package/dist/flow/core/host.js +99 -0
- package/dist/flow/core/host.js.map +1 -0
- package/dist/flow/core/index.d.ts +17 -0
- package/dist/flow/core/index.d.ts.map +1 -0
- package/dist/flow/core/index.js +17 -0
- package/dist/flow/core/index.js.map +1 -0
- package/dist/flow/core/interpreter.d.ts +69 -0
- package/dist/flow/core/interpreter.d.ts.map +1 -0
- package/dist/flow/core/interpreter.js +738 -0
- package/dist/flow/core/interpreter.js.map +1 -0
- package/dist/flow/core/json-pointer.d.ts +6 -0
- package/dist/flow/core/json-pointer.d.ts.map +1 -0
- package/dist/flow/core/json-pointer.js +28 -0
- package/dist/flow/core/json-pointer.js.map +1 -0
- package/dist/flow/core/migrate.d.ts +16 -0
- package/dist/flow/core/migrate.d.ts.map +1 -0
- package/dist/flow/core/migrate.js +29 -0
- package/dist/flow/core/migrate.js.map +1 -0
- package/dist/flow/core/mock-effects.d.ts +14 -0
- package/dist/flow/core/mock-effects.d.ts.map +1 -0
- package/dist/flow/core/mock-effects.js +90 -0
- package/dist/flow/core/mock-effects.js.map +1 -0
- package/dist/flow/core/mocks.d.ts +55 -0
- package/dist/flow/core/mocks.d.ts.map +1 -0
- package/dist/flow/core/mocks.js +73 -0
- package/dist/flow/core/mocks.js.map +1 -0
- package/dist/flow/core/route.d.ts +29 -0
- package/dist/flow/core/route.d.ts.map +1 -0
- package/dist/flow/core/route.js +61 -0
- package/dist/flow/core/route.js.map +1 -0
- package/dist/flow/core/schema.d.ts +19 -0
- package/dist/flow/core/schema.d.ts.map +1 -0
- package/dist/flow/core/schema.js +317 -0
- package/dist/flow/core/schema.js.map +1 -0
- package/dist/flow/core/template.d.ts +16 -0
- package/dist/flow/core/template.d.ts.map +1 -0
- package/dist/flow/core/template.js +65 -0
- package/dist/flow/core/template.js.map +1 -0
- package/dist/flow/core/trace.d.ts +26 -0
- package/dist/flow/core/trace.d.ts.map +1 -0
- package/dist/flow/core/trace.js +2 -0
- package/dist/flow/core/trace.js.map +1 -0
- package/dist/flow/core/types.d.ts +159 -0
- package/dist/flow/core/types.d.ts.map +1 -0
- package/dist/flow/core/types.js +2 -0
- package/dist/flow/core/types.js.map +1 -0
- package/dist/flow/core/validate.d.ts +3 -0
- package/dist/flow/core/validate.d.ts.map +1 -0
- package/dist/flow/core/validate.js +550 -0
- package/dist/flow/core/validate.js.map +1 -0
- package/dist/flow/create-flow-agent.d.ts +36 -0
- package/dist/flow/create-flow-agent.d.ts.map +1 -0
- package/dist/flow/create-flow-agent.js +175 -0
- package/dist/flow/create-flow-agent.js.map +1 -0
- package/dist/flow/effects-node.d.ts +21 -0
- package/dist/flow/effects-node.d.ts.map +1 -0
- package/dist/flow/effects-node.js +189 -0
- package/dist/flow/effects-node.js.map +1 -0
- package/dist/flow/index.d.ts +12 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +7 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/llm-node.d.ts +24 -0
- package/dist/flow/llm-node.d.ts.map +1 -0
- package/dist/flow/llm-node.js +251 -0
- package/dist/flow/llm-node.js.map +1 -0
- package/dist/flow/record.d.ts +22 -0
- package/dist/flow/record.d.ts.map +1 -0
- package/dist/flow/record.js +126 -0
- package/dist/flow/record.js.map +1 -0
- package/dist/llm/agent/build-tool-registry.d.ts +26 -0
- package/dist/llm/agent/build-tool-registry.d.ts.map +1 -0
- package/dist/llm/agent/build-tool-registry.js +106 -0
- package/dist/llm/agent/build-tool-registry.js.map +1 -0
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
- package/dist/llm/agent/create-llm-agent.js +27 -101
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/llm/anthropic-provider.d.ts.map +1 -1
- package/dist/llm/anthropic-provider.js +10 -0
- package/dist/llm/anthropic-provider.js.map +1 -1
- package/dist/llm/catalog.d.ts +4 -0
- package/dist/llm/catalog.d.ts.map +1 -1
- package/dist/llm/catalog.js +7 -0
- package/dist/llm/catalog.js.map +1 -1
- package/dist/llm/gemini-provider.d.ts.map +1 -1
- package/dist/llm/gemini-provider.js +12 -0
- package/dist/llm/gemini-provider.js.map +1 -1
- package/dist/llm/index.d.ts +2 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +1 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/openai-provider.d.ts.map +1 -1
- package/dist/llm/openai-provider.js +10 -0
- package/dist/llm/openai-provider.js.map +1 -1
- package/dist/llm/types.d.ts +7 -2
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js.map +1 -1
- package/dist/templates/flow-agent/agent.js +49085 -0
- package/dist/templates/llm-agent/agent.js +133 -99
- package/dist/templates/llm-docs-rag/agent.js +133 -99
- package/dist/templates/llm-mcp-service/agent.js +133 -99
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +23 -0
- package/dist/templates/registry.js.map +1 -1
- package/eject/llm/loop.ts +28 -101
- package/package.json +19 -2
- package/schema/voicethere.flow.schema.json +681 -0
- package/templates/flow-agent/README.md +38 -0
- package/templates/flow-agent/agent.ts +14 -0
- package/templates/flow-agent/tools.ts +5 -0
- package/templates/flow-agent/voicethere.flow.json +80 -0
- package/templates/flow-agent/voicethere.flow.mocks.json +17 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { withStreamBounds } from "../llm/bounded-provider.js";
|
|
2
|
+
import { SentenceSplitter } from "../llm/agent/sentence-splitter.js";
|
|
3
|
+
import { ThinkingStripper, stripThinking, } from "../llm/agent/thinking-stripper.js";
|
|
4
|
+
import { MAX_RESULT_BYTES } from "../llm/mcp/tool-registry.js";
|
|
5
|
+
import { LlmProviderError } from "../llm/types.js";
|
|
6
|
+
export const LLM_FIRST_TOKEN_TIMEOUT_MS = 10_000;
|
|
7
|
+
export const LLM_TOTAL_TIMEOUT_MS = 60_000;
|
|
8
|
+
export const LLM_TOOL_TIMEOUT_MS = 15_000;
|
|
9
|
+
const MAX_OUTPUT_TOKENS = 1024;
|
|
10
|
+
function truncate(text, max) {
|
|
11
|
+
const buf = Buffer.from(text, "utf8");
|
|
12
|
+
if (buf.length <= max)
|
|
13
|
+
return text;
|
|
14
|
+
let end = max;
|
|
15
|
+
while (end > 0 && (buf[end] & 0xc0) === 0x80)
|
|
16
|
+
end -= 1;
|
|
17
|
+
return `${buf.subarray(0, end).toString("utf8")}\n[truncated]`;
|
|
18
|
+
}
|
|
19
|
+
class EventQueue {
|
|
20
|
+
items = [];
|
|
21
|
+
waiter;
|
|
22
|
+
finished = false;
|
|
23
|
+
failure;
|
|
24
|
+
push(item) {
|
|
25
|
+
if (this.finished)
|
|
26
|
+
return;
|
|
27
|
+
this.items.push(item);
|
|
28
|
+
this.wake();
|
|
29
|
+
}
|
|
30
|
+
end() {
|
|
31
|
+
this.finished = true;
|
|
32
|
+
this.wake();
|
|
33
|
+
}
|
|
34
|
+
fail(err) {
|
|
35
|
+
this.failure = { err };
|
|
36
|
+
this.finished = true;
|
|
37
|
+
this.wake();
|
|
38
|
+
}
|
|
39
|
+
wake() {
|
|
40
|
+
const w = this.waiter;
|
|
41
|
+
this.waiter = undefined;
|
|
42
|
+
w?.();
|
|
43
|
+
}
|
|
44
|
+
async *drain() {
|
|
45
|
+
for (;;) {
|
|
46
|
+
if (this.items.length > 0) {
|
|
47
|
+
yield this.items.shift();
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (this.finished) {
|
|
51
|
+
if (this.failure)
|
|
52
|
+
throw this.failure.err;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
await new Promise((resolve) => {
|
|
56
|
+
this.waiter = resolve;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function offeredTools(registry, tools, log) {
|
|
62
|
+
if (!registry || tools === "none")
|
|
63
|
+
return [];
|
|
64
|
+
const all = registry.list().map((e) => e.spec);
|
|
65
|
+
if (tools === "all")
|
|
66
|
+
return all;
|
|
67
|
+
const byName = new Map(all.map((t) => [t.name, t]));
|
|
68
|
+
const out = [];
|
|
69
|
+
let skipped = 0;
|
|
70
|
+
for (const name of tools) {
|
|
71
|
+
const t = byName.get(name);
|
|
72
|
+
if (t)
|
|
73
|
+
out.push(t);
|
|
74
|
+
else
|
|
75
|
+
skipped += 1;
|
|
76
|
+
}
|
|
77
|
+
if (skipped > 0)
|
|
78
|
+
log?.("warn", "flow llm tools skipped", { skipped });
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* One llm node: up to `maxRounds` provider rounds, with tool calls between
|
|
83
|
+
* them. Yields sentences (when `call.speak`), tool start/end events and a
|
|
84
|
+
* final `done`.
|
|
85
|
+
*/
|
|
86
|
+
export async function* runLlmNode(provider, registry, call, signal, opts) {
|
|
87
|
+
const bounded = withStreamBounds(provider, {
|
|
88
|
+
firstTokenTimeoutMs: opts.firstTokenTimeoutMs ?? LLM_FIRST_TOKEN_TIMEOUT_MS,
|
|
89
|
+
totalTimeoutMs: call.timeoutMs ?? opts.totalTimeoutMs ?? LLM_TOTAL_TIMEOUT_MS,
|
|
90
|
+
retries: 0,
|
|
91
|
+
});
|
|
92
|
+
const toolTimeoutMs = opts.toolTimeoutMs ?? LLM_TOOL_TIMEOUT_MS;
|
|
93
|
+
const specs = offeredTools(registry, call.tools, opts.log);
|
|
94
|
+
const offered = new Set(specs.map((t) => t.name));
|
|
95
|
+
const maxRounds = Math.max(1, call.maxRounds ?? 5);
|
|
96
|
+
const q = new EventQueue();
|
|
97
|
+
let sentenceSeen = false;
|
|
98
|
+
let fillerTimer;
|
|
99
|
+
if (call.speak && call.filler) {
|
|
100
|
+
const f = call.filler;
|
|
101
|
+
fillerTimer = setTimeout(() => {
|
|
102
|
+
fillerTimer = undefined;
|
|
103
|
+
if (!sentenceSeen)
|
|
104
|
+
q.push({ type: "sentence", text: f.text, filler: true });
|
|
105
|
+
}, Math.max(0, f.afterMs));
|
|
106
|
+
}
|
|
107
|
+
const sentence = (text) => {
|
|
108
|
+
if (!call.speak || text.trim() === "")
|
|
109
|
+
return;
|
|
110
|
+
sentenceSeen = true;
|
|
111
|
+
if (fillerTimer) {
|
|
112
|
+
clearTimeout(fillerTimer);
|
|
113
|
+
fillerTimer = undefined;
|
|
114
|
+
}
|
|
115
|
+
q.push({ type: "sentence", text });
|
|
116
|
+
};
|
|
117
|
+
const messages = call.messages.map((m) => ({
|
|
118
|
+
role: m.role,
|
|
119
|
+
text: m.text,
|
|
120
|
+
}));
|
|
121
|
+
if (messages.length === 0 || messages[0].role === "assistant") {
|
|
122
|
+
// Providers want a conversation that starts with the caller.
|
|
123
|
+
messages.unshift({ role: "user", text: "(The call has started.)" });
|
|
124
|
+
}
|
|
125
|
+
const pump = (async () => {
|
|
126
|
+
const texts = [];
|
|
127
|
+
let input;
|
|
128
|
+
let output;
|
|
129
|
+
for (let round = 1; round <= maxRounds; round += 1) {
|
|
130
|
+
const splitter = new SentenceSplitter();
|
|
131
|
+
const stripper = new ThinkingStripper();
|
|
132
|
+
let final;
|
|
133
|
+
for await (const ev of bounded.stream({
|
|
134
|
+
model: call.model.model,
|
|
135
|
+
system: call.system,
|
|
136
|
+
messages,
|
|
137
|
+
tools: specs,
|
|
138
|
+
temperature: 0.2,
|
|
139
|
+
maxOutputTokens: MAX_OUTPUT_TOKENS,
|
|
140
|
+
signal,
|
|
141
|
+
})) {
|
|
142
|
+
if (signal.aborted)
|
|
143
|
+
break;
|
|
144
|
+
if (ev.type === "text_delta") {
|
|
145
|
+
for (const s of splitter.push(stripper.push(ev.text)))
|
|
146
|
+
sentence(s);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
final = ev;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (signal.aborted)
|
|
153
|
+
throw new LlmProviderError("LLM_ABORTED", "aborted");
|
|
154
|
+
if (!final || final.type !== "done") {
|
|
155
|
+
throw new LlmProviderError("LLM_PROVIDER_ERROR", "stream ended without done");
|
|
156
|
+
}
|
|
157
|
+
const tail = stripper.end();
|
|
158
|
+
for (const s of tail
|
|
159
|
+
? [...splitter.push(tail), ...splitter.end()]
|
|
160
|
+
: splitter.end())
|
|
161
|
+
sentence(s);
|
|
162
|
+
const cleaned = stripThinking(final.text);
|
|
163
|
+
if (cleaned.text)
|
|
164
|
+
texts.push(cleaned.text);
|
|
165
|
+
if (final.usage?.inputTokens !== undefined)
|
|
166
|
+
input = (input ?? 0) + final.usage.inputTokens;
|
|
167
|
+
if (final.usage?.outputTokens !== undefined)
|
|
168
|
+
output = (output ?? 0) + final.usage.outputTokens;
|
|
169
|
+
if (final.toolCalls.length === 0 || round === maxRounds)
|
|
170
|
+
break;
|
|
171
|
+
messages.push({
|
|
172
|
+
role: "assistant",
|
|
173
|
+
text: final.text,
|
|
174
|
+
toolCalls: final.toolCalls,
|
|
175
|
+
...(cleaned.strippedChars > 0 || final.providerState === undefined
|
|
176
|
+
? {}
|
|
177
|
+
: { providerState: final.providerState }),
|
|
178
|
+
});
|
|
179
|
+
const results = await Promise.all(final.toolCalls.map(async (c) => {
|
|
180
|
+
q.push({ type: "tool", name: c.name, phase: "start" });
|
|
181
|
+
const t0 = Date.now();
|
|
182
|
+
let content;
|
|
183
|
+
let isError = false;
|
|
184
|
+
if (!registry || !offered.has(c.name)) {
|
|
185
|
+
content = `tool ${c.name} is not available`;
|
|
186
|
+
isError = true;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
const ctl = new AbortController();
|
|
190
|
+
const onAbort = () => ctl.abort();
|
|
191
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
192
|
+
const timer = setTimeout(() => ctl.abort(), toolTimeoutMs);
|
|
193
|
+
try {
|
|
194
|
+
const r = await registry.call(c.name, c.input, {
|
|
195
|
+
signal: ctl.signal,
|
|
196
|
+
timeoutMs: toolTimeoutMs,
|
|
197
|
+
sessionId: opts.sessionId,
|
|
198
|
+
...(opts.turnId ? { turnId: opts.turnId } : {}),
|
|
199
|
+
callId: c.id,
|
|
200
|
+
});
|
|
201
|
+
content = r.content;
|
|
202
|
+
isError = r.isError;
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
content = "tool call failed";
|
|
206
|
+
isError = true;
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
clearTimeout(timer);
|
|
210
|
+
signal.removeEventListener("abort", onAbort);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
q.push({
|
|
214
|
+
type: "tool",
|
|
215
|
+
name: c.name,
|
|
216
|
+
phase: "end",
|
|
217
|
+
durationMs: Date.now() - t0,
|
|
218
|
+
...(isError ? { error: "TOOL_ERROR" } : {}),
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
callId: c.id,
|
|
222
|
+
name: c.name,
|
|
223
|
+
content: truncate(content, MAX_RESULT_BYTES),
|
|
224
|
+
isError,
|
|
225
|
+
};
|
|
226
|
+
}));
|
|
227
|
+
messages.push({ role: "tool", results });
|
|
228
|
+
}
|
|
229
|
+
q.push({
|
|
230
|
+
type: "done",
|
|
231
|
+
text: texts.join(" "),
|
|
232
|
+
...(input !== undefined || output !== undefined
|
|
233
|
+
? {
|
|
234
|
+
tokens: {
|
|
235
|
+
...(input !== undefined ? { input } : {}),
|
|
236
|
+
...(output !== undefined ? { output } : {}),
|
|
237
|
+
},
|
|
238
|
+
}
|
|
239
|
+
: {}),
|
|
240
|
+
});
|
|
241
|
+
})();
|
|
242
|
+
pump.then(() => q.end(), (err) => q.fail(err));
|
|
243
|
+
try {
|
|
244
|
+
yield* q.drain();
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
if (fillerTimer)
|
|
248
|
+
clearTimeout(fillerTimer);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=llm-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-node.js","sourceRoot":"","sources":["../../src/flow/llm-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,GACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAUnD,MAAM,CAAC,MAAM,0BAA0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AC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBAC5C;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,CAAC;IACL,CAAC,CAAC,EAAE,CAAC;IACL,IAAI,CAAC,IAAI,CACP,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,EACb,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACrB,CAAC;IACF,IAAI,CAAC;QACH,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;YAAS,CAAC;QACT,IAAI,WAAW;YAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FlowEffects } from "./core/effects.js";
|
|
2
|
+
import type { FlowMockCase, FlowMocks } from "./core/mocks.js";
|
|
3
|
+
export interface RecordingSink {
|
|
4
|
+
add(nodeId: string, c: FlowMockCase): void;
|
|
5
|
+
}
|
|
6
|
+
/** Collects recorded cases into a `FlowMocks` document. */
|
|
7
|
+
export declare function createMockRecorder(): {
|
|
8
|
+
sink: RecordingSink;
|
|
9
|
+
mocks(): FlowMocks;
|
|
10
|
+
};
|
|
11
|
+
export interface RecordingOptions {
|
|
12
|
+
env: Record<string, string | undefined>;
|
|
13
|
+
/** Secret names the flow declares, redacted even when not `AGENT_*`. */
|
|
14
|
+
referencedSecrets?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Passes every call through and appends its result as case `recorded-<n>`.
|
|
18
|
+
* Values are redacted (secret values from the env, sensitive keys, personal
|
|
19
|
+
* data) before they reach the sink; auth and cookie headers are dropped.
|
|
20
|
+
*/
|
|
21
|
+
export declare function wrapRecording(effects: FlowEffects, sink: RecordingSink, opts: RecordingOptions): FlowEffects;
|
|
22
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/flow/record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC5C;AAED,2DAA2D;AAC3D,wBAAgB,kBAAkB,IAAI;IACpC,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,IAAI,SAAS,CAAC;CACpB,CAUA;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAcD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,gBAAgB,GACrB,WAAW,CA4Fb"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { createRedactor, secretValuesFromEnv } from "../llm/agent/redact.js";
|
|
2
|
+
/** Collects recorded cases into a `FlowMocks` document. */
|
|
3
|
+
export function createMockRecorder() {
|
|
4
|
+
const nodes = Object.create(null);
|
|
5
|
+
return {
|
|
6
|
+
sink: {
|
|
7
|
+
add(nodeId, c) {
|
|
8
|
+
(nodes[nodeId] ??= []).push(c);
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
mocks: () => ({ version: 1, nodes: { ...nodes } }),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const DROPPED_HEADERS = new Set([
|
|
15
|
+
"authorization",
|
|
16
|
+
"proxy-authorization",
|
|
17
|
+
"cookie",
|
|
18
|
+
"set-cookie",
|
|
19
|
+
]);
|
|
20
|
+
function codeOf(err) {
|
|
21
|
+
const c = err?.code;
|
|
22
|
+
return typeof c === "string" ? c : undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Passes every call through and appends its result as case `recorded-<n>`.
|
|
26
|
+
* Values are redacted (secret values from the env, sensitive keys, personal
|
|
27
|
+
* data) before they reach the sink; auth and cookie headers are dropped.
|
|
28
|
+
*/
|
|
29
|
+
export function wrapRecording(effects, sink, opts) {
|
|
30
|
+
const redactor = createRedactor({
|
|
31
|
+
secretValues: secretValuesFromEnv(opts.env, opts.referencedSecrets ?? []),
|
|
32
|
+
mode: "redacted",
|
|
33
|
+
});
|
|
34
|
+
const counts = new Map();
|
|
35
|
+
let current = "";
|
|
36
|
+
const record = (nodeId, c) => {
|
|
37
|
+
const n = (counts.get(nodeId) ?? 0) + 1;
|
|
38
|
+
counts.set(nodeId, n);
|
|
39
|
+
sink.add(nodeId, { name: `recorded-${n}`, ...c });
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
...effects,
|
|
43
|
+
trace(e) {
|
|
44
|
+
if (e.phase === "enter" && e.parent === undefined)
|
|
45
|
+
current = e.nodeId;
|
|
46
|
+
effects.trace(e);
|
|
47
|
+
},
|
|
48
|
+
async http(req, signal) {
|
|
49
|
+
const nodeId = current;
|
|
50
|
+
try {
|
|
51
|
+
const res = await effects.http(req, signal);
|
|
52
|
+
if (signal.aborted) {
|
|
53
|
+
// The interpreter gave up (timeout): replay must take that path.
|
|
54
|
+
record(nodeId, { http: { error: "HTTP_TIMEOUT" } });
|
|
55
|
+
return res;
|
|
56
|
+
}
|
|
57
|
+
const headers = {};
|
|
58
|
+
for (const [k, v] of Object.entries(res.headers ?? {}))
|
|
59
|
+
if (!DROPPED_HEADERS.has(k.toLowerCase()))
|
|
60
|
+
headers[k] = String(redactor.redact(v));
|
|
61
|
+
record(nodeId, {
|
|
62
|
+
http: {
|
|
63
|
+
status: res.status,
|
|
64
|
+
...(Object.keys(headers).length > 0 ? { headers } : {}),
|
|
65
|
+
body: redactor.redact(res.body),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
return res;
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
const code = codeOf(err);
|
|
72
|
+
if (code === "HTTP_TIMEOUT" || code === "HTTP_NETWORK")
|
|
73
|
+
record(nodeId, { http: { error: code } });
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
async tool(source, tool, args, signal, o) {
|
|
78
|
+
const nodeId = current;
|
|
79
|
+
const res = await effects.tool(source, tool, args, signal, o);
|
|
80
|
+
if (signal.aborted) {
|
|
81
|
+
record(nodeId, { mcp: { error: "MCP_TIMEOUT" } });
|
|
82
|
+
return res;
|
|
83
|
+
}
|
|
84
|
+
if (res.isError)
|
|
85
|
+
record(nodeId, {
|
|
86
|
+
mcp: { isError: true, content: String(redactor.redact(res.content)) },
|
|
87
|
+
});
|
|
88
|
+
else {
|
|
89
|
+
let value = res.content;
|
|
90
|
+
try {
|
|
91
|
+
value = JSON.parse(res.content);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// plain text result
|
|
95
|
+
}
|
|
96
|
+
record(nodeId, { mcp: { result: redactor.redact(value) } });
|
|
97
|
+
}
|
|
98
|
+
return res;
|
|
99
|
+
},
|
|
100
|
+
llm(req, signal) {
|
|
101
|
+
const nodeId = current;
|
|
102
|
+
const inner = effects.llm(req, signal);
|
|
103
|
+
return (async function* () {
|
|
104
|
+
for await (const ev of inner) {
|
|
105
|
+
if (ev.type === "done" && signal.aborted)
|
|
106
|
+
record(nodeId, { llm: { error: "LLM_TIMEOUT" } });
|
|
107
|
+
else if (ev.type === "done")
|
|
108
|
+
record(nodeId, {
|
|
109
|
+
llm: { text: String(redactor.redact(ev.text)) },
|
|
110
|
+
});
|
|
111
|
+
yield ev;
|
|
112
|
+
}
|
|
113
|
+
})();
|
|
114
|
+
},
|
|
115
|
+
async classify(req, signal) {
|
|
116
|
+
const nodeId = current;
|
|
117
|
+
const res = await effects.classify(req, signal);
|
|
118
|
+
if (signal.aborted)
|
|
119
|
+
record(nodeId, { route: { error: "ROUTE_TIMEOUT" } });
|
|
120
|
+
else
|
|
121
|
+
record(nodeId, { route: { path: res.path } });
|
|
122
|
+
return res;
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/flow/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAQ7E,2DAA2D;AAC3D,MAAM,UAAU,kBAAkB;IAIhC,MAAM,KAAK,GAAmC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO;QACL,IAAI,EAAE;YACJ,GAAG,CAAC,MAAM,EAAE,CAAC;gBACX,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACjC,CAAC;SACF;QACD,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC;AAQD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,eAAe;IACf,qBAAqB;IACrB,QAAQ;IACR,YAAY;CACb,CAAC,CAAC;AAEH,SAAS,MAAM,CAAC,GAAY;IAC1B,MAAM,CAAC,GAAI,GAAiC,EAAE,IAAI,CAAC;IACnD,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAoB,EACpB,IAAmB,EACnB,IA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AAC,MAAM,EAAE;4BACb,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE;yBAChD,CAAC,CAAC;oBACL,MAAM,EAAE,CAAC;gBACX,CAAC;YACH,CAAC,CAAC,EAAE,CAAC;QACP,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM;YACxB,MAAM,MAAM,GAAG,OAAO,CAAC;YACvB,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAChD,IAAI,MAAM,CAAC,OAAO;gBAAE,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;;gBACrE,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACnD,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { McpToolSource } from "../mcp/mcp-tool-source.js";
|
|
2
|
+
import type { McpToolSourceOptions } from "../mcp/mcp-tool-source.js";
|
|
3
|
+
import { ToolRegistry } from "../mcp/tool-registry.js";
|
|
4
|
+
import type { CustomTool } from "../mcp/tool-registry.js";
|
|
5
|
+
import type { LlmAgentToolSource } from "./config.js";
|
|
6
|
+
import type { ToolCallLogMode } from "./redact.js";
|
|
7
|
+
export interface BuildToolRegistryOptions {
|
|
8
|
+
env: Record<string, string | undefined>;
|
|
9
|
+
toolSources: LlmAgentToolSource[];
|
|
10
|
+
customTools: CustomTool[];
|
|
11
|
+
/** Environment variable names whose values are removed from tool-call logs (source secrets are added here). */
|
|
12
|
+
secretNames: string[];
|
|
13
|
+
toolCallLogs: ToolCallLogMode;
|
|
14
|
+
servicePath: string;
|
|
15
|
+
makeSource?: (o: McpToolSourceOptions) => McpToolSource;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Builds a ToolRegistry from `toolSources` (the project service and external
|
|
19
|
+
* MCP servers) and custom tools, and starts the sources. Shared by the LLM
|
|
20
|
+
* agent and the flow agent.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildToolRegistry(o: BuildToolRegistryOptions): {
|
|
23
|
+
registry: ToolRegistry;
|
|
24
|
+
serviceSource: McpToolSource | undefined;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=build-tool-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-tool-registry.d.ts","sourceRoot":"","sources":["../../../src/llm/agent/build-tool-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAMnD,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,+GAA+G;IAC/G,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,eAAe,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,oBAAoB,KAAK,aAAa,CAAC;CACzD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,wBAAwB,GAAG;IAC9D,QAAQ,EAAE,YAAY,CAAC;IACvB,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;CAC1C,CA6FA"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { agentLog } from "../../runtime.js";
|
|
2
|
+
import { McpToolSource } from "../mcp/mcp-tool-source.js";
|
|
3
|
+
import { ToolRegistry } from "../mcp/tool-registry.js";
|
|
4
|
+
import { secretValuesFromEnv } from "./redact.js";
|
|
5
|
+
function nonEmpty(v) {
|
|
6
|
+
return v !== undefined && v.length > 0;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Builds a ToolRegistry from `toolSources` (the project service and external
|
|
10
|
+
* MCP servers) and custom tools, and starts the sources. Shared by the LLM
|
|
11
|
+
* agent and the flow agent.
|
|
12
|
+
*/
|
|
13
|
+
export function buildToolRegistry(o) {
|
|
14
|
+
const { env } = o;
|
|
15
|
+
const makeSource = o.makeSource ?? ((x) => new McpToolSource(x));
|
|
16
|
+
const reg = new ToolRegistry({
|
|
17
|
+
log: (level, message, fields) => agentLog(level, message, fields ?? {}),
|
|
18
|
+
toolCallLog: {
|
|
19
|
+
mode: o.toolCallLogs,
|
|
20
|
+
secretValues: secretValuesFromEnv(env, [
|
|
21
|
+
...o.secretNames,
|
|
22
|
+
...o.toolSources.flatMap((src) => {
|
|
23
|
+
if (src.kind !== "mcp" || !src.auth)
|
|
24
|
+
return [];
|
|
25
|
+
if (src.auth.type === "bearer")
|
|
26
|
+
return [src.auth.secret];
|
|
27
|
+
if (src.auth.type === "headers")
|
|
28
|
+
return Object.values(src.auth.headers);
|
|
29
|
+
return [];
|
|
30
|
+
}),
|
|
31
|
+
]),
|
|
32
|
+
emit: (fields, sid) => agentLog("info", "llm tool call", { ...fields }, sid),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
for (const tool of o.customTools)
|
|
36
|
+
reg.addCustomTool(tool);
|
|
37
|
+
let serviceSource;
|
|
38
|
+
const sources = [];
|
|
39
|
+
for (const src of o.toolSources) {
|
|
40
|
+
if (src.kind === "service") {
|
|
41
|
+
const base = env.AGENT_SERVICE_URL;
|
|
42
|
+
if (!nonEmpty(base)) {
|
|
43
|
+
agentLog("warn", "toolSources: service configured but this project has no service");
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const headers = {};
|
|
47
|
+
const token = env.AGENT_SERVICE_TOKEN;
|
|
48
|
+
if (nonEmpty(token)) {
|
|
49
|
+
headers.Authorization = `Bearer ${token}`;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
agentLog("warn", "toolSources: AGENT_SERVICE_TOKEN is not set");
|
|
53
|
+
}
|
|
54
|
+
const source = makeSource({
|
|
55
|
+
name: "service",
|
|
56
|
+
kind: "service",
|
|
57
|
+
url: `${base}${src.path ?? o.servicePath}`,
|
|
58
|
+
headers,
|
|
59
|
+
allow: src.allow,
|
|
60
|
+
deny: src.deny,
|
|
61
|
+
log: (level, message, fields) => agentLog(level, message, fields ?? {}),
|
|
62
|
+
});
|
|
63
|
+
serviceSource = source;
|
|
64
|
+
sources.push(source);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const headers = {};
|
|
68
|
+
let missing;
|
|
69
|
+
const auth = src.auth ?? { type: "none" };
|
|
70
|
+
if (auth.type === "bearer") {
|
|
71
|
+
const v = env[auth.secret];
|
|
72
|
+
if (nonEmpty(v))
|
|
73
|
+
headers.Authorization = `Bearer ${v}`;
|
|
74
|
+
else
|
|
75
|
+
missing = auth.secret;
|
|
76
|
+
}
|
|
77
|
+
else if (auth.type === "headers") {
|
|
78
|
+
for (const [header, envName] of Object.entries(auth.headers)) {
|
|
79
|
+
const v = env[envName];
|
|
80
|
+
if (nonEmpty(v))
|
|
81
|
+
headers[header] = v;
|
|
82
|
+
else
|
|
83
|
+
missing = envName;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (missing) {
|
|
87
|
+
agentLog("warn", `toolSources: ${src.name} skipped, environment variable ${missing} is not set`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
sources.push(makeSource({
|
|
91
|
+
name: src.name,
|
|
92
|
+
url: src.url,
|
|
93
|
+
headers,
|
|
94
|
+
allow: src.allow,
|
|
95
|
+
deny: src.deny,
|
|
96
|
+
log: (level, message, fields) => agentLog(level, message, fields ?? {}),
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
for (const source of sources) {
|
|
101
|
+
reg.addSource(source);
|
|
102
|
+
source.start();
|
|
103
|
+
}
|
|
104
|
+
return { registry: reg, serviceSource };
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=build-tool-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-tool-registry.js","sourceRoot":"","sources":["../../../src/llm/agent/build-tool-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,SAAS,QAAQ,CAAC,CAAqB;IACrC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACzC,CAAC;AAaD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAA2B;IAI3D,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClB,MAAM,UAAU,GACd,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAuB,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC;QAC3B,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,QAA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/llm/agent/create-llm-agent.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,aAAa,EAKd,MAAM,kBAAkB,CAAC;AAY1B,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAEV,WAAW,EACX,iBAAiB,EAIlB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"create-llm-agent.d.ts","sourceRoot":"","sources":["../../../src/llm/agent/create-llm-agent.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,aAAa,EAKd,MAAM,kBAAkB,CAAC;AAY1B,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAEV,WAAW,EACX,iBAAiB,EAIlB,MAAM,aAAa,CAAC;AAKrB,OAAO,KAAK,EAEV,aAAa,EAGd,MAAM,YAAY,CAAC;AAapB,MAAM,WAAW,qBAAqB;IACpC,qEAAqE;IACrE,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC/C,sBAAsB;IACtB,QAAQ,CAAC,E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