@deliverd/sdk 0.33.0 → 0.34.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 CHANGED
@@ -866,6 +866,27 @@ Only approved calls run; a declined one's result tells the model a person said
866
866
  no, and why. `runMuseToolCalls(message, runTool, { deliverd })` does the same
867
867
  for Chat Completions' `tool_calls`.
868
868
 
869
+ **Vercel UI SDK** (`@ui-sdk/*`) — when an agent drives your interface, the
870
+ controls you mark `data-agent-confirm` wait for a person. The browser asks your
871
+ route; your route, which holds the agent key, asks Deliverd:
872
+
873
+ ```ts
874
+ // in the browser
875
+ import { deliverdAllow } from "@deliverd/sdk/adapters";
876
+
877
+ const agent = createAgent({ allow: deliverdAllow({ endpoint: "/api/deliverd/ui-approval" }), timeout: 15 * 60_000 });
878
+
879
+ // app/api/deliverd/ui-approval/route.ts
880
+ import { uiSdkApprovalRoute } from "@deliverd/sdk/adapters";
881
+
882
+ export const POST = uiSdkApprovalRoute({ deliverd, approvers: ["ops"], timeout: "13m" });
883
+ ```
884
+
885
+ The approver reads the mark's own sentence ("Deletes the project and all its
886
+ files"). A no, a wait that runs out, or a route that fails all leave the
887
+ control untouched. The route waits four minutes by default; raise its
888
+ `timeout`, the bridge's `timeout` and your function's limit together.
889
+
869
890
  **LangGraph** — pause the graph rather than a process, and resume it from the callback:
870
891
 
871
892
  ```ts
@@ -18,6 +18,8 @@ export { generateWithDeliverdApprovals, pendingMastraApproval, resolveMastraAppr
18
18
  export type { MastraApprovingAgent, MastraOutput } from "./mastra.js";
19
19
  export { runMuseFunctionCalls, runMuseToolCalls } from "./muse-spark.js";
20
20
  export type { MuseFunctionCall, MuseFunctionCallOutput, MuseToolApprovalOptions, MuseToolCall, MuseToolMessage, MuseToolRunner, } from "./muse-spark.js";
21
+ export { deliverdAllow, describeStep, uiSdkApprovalRoute, UI_SDK_DEFAULT_TIMEOUT } from "./ui-sdk.js";
22
+ export type { DeliverdAllowOptions, UiSdkApprovalAnswer, UiSdkApprovalRouteOptions, UiSdkStep } from "./ui-sdk.js";
21
23
  export { defaultDescription, DEFAULT_TOOL_EXPIRY } from "./shared.js";
22
24
  export type { Approver, CallDescription, CallOutcome, ToolApprovalOptions } from "./shared.js";
23
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACpF,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpE,YAAY,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAChH,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC1G,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aA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AE,MAAM,aAAa,CAAC;AACnH,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACtE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
@@ -12,4 +12,5 @@ export { resolveInterruptions, runWithDeliverdApprovals } from "./openai-agents.
12
12
  export { approveInGraph, resumeFromCallback } from "./langgraph.js";
13
13
  export { generateWithDeliverdApprovals, pendingMastraApproval, resolveMastraApproval } from "./mastra.js";
14
14
  export { runMuseFunctionCalls, runMuseToolCalls } from "./muse-spark.js";
15
+ export { deliverdAllow, describeStep, uiSdkApprovalRoute, UI_SDK_DEFAULT_TIMEOUT } from "./ui-sdk.js";
15
16
  export { defaultDescription, DEFAULT_TOOL_EXPIRY } from "./shared.js";
@@ -0,0 +1,116 @@
1
+ import type { Duration } from "../duration.js";
2
+ import { type CallDescription, type ToolApprovalOptions } from "./shared.js";
3
+ /**
4
+ * Vercel's UI SDK (`@ui-sdk/*`): a person approves what an agent does in your
5
+ * interface, through Deliverd.
6
+ *
7
+ * UI SDK's agent bridge lets an agent press buttons and fill fields in an app
8
+ * built with its components. Controls marked `data-agent-confirm="…"` wait for
9
+ * the bridge's `allow` hook. These two functions make that hook a Deliverd
10
+ * approval: the browser half asks your server, and your server, which holds the
11
+ * agent key, asks Deliverd and waits for the person.
12
+ *
13
+ * In the browser, where the bridge is created:
14
+ *
15
+ * ```ts
16
+ * import { createAgent } from "@ui-sdk/react/agent";
17
+ * import { deliverdAllow } from "@deliverd/sdk/adapters";
18
+ *
19
+ * const agent = createAgent({
20
+ * allow: deliverdAllow({ endpoint: "/api/deliverd/ui-approval" }),
21
+ * timeout: 15 * 60_000,
22
+ * });
23
+ * ```
24
+ *
25
+ * On the server, as a fetch-style route (Next.js `app/api/deliverd/ui-approval/route.ts`):
26
+ *
27
+ * ```ts
28
+ * import { Deliverd } from "@deliverd/sdk";
29
+ * import { uiSdkApprovalRoute } from "@deliverd/sdk/adapters";
30
+ *
31
+ * export const maxDuration = 800;
32
+ * export const POST = uiSdkApprovalRoute({ deliverd: new Deliverd(), approvers: ["ops"], timeout: "13m" });
33
+ * ```
34
+ *
35
+ * The browser never sees the agent key, and the agent never sees the answer
36
+ * until a person gives it. Each ask is its own request: an approval is for
37
+ * that one step, then, and is never reused for a later one. A wait that runs
38
+ * out is a no, and the request expires with it, so nobody approves a step the
39
+ * agent has stopped waiting for.
40
+ *
41
+ * Shapes follow `AgentAction` and `createAgent`'s `allow` option in
42
+ * `@ui-sdk/core`'s agent docs (0.1.0-beta.1).
43
+ */
44
+ /** The step UI SDK hands to `allow`: its `AgentAction`. */
45
+ export interface UiSdkStep {
46
+ ref: string;
47
+ component: string;
48
+ label?: string;
49
+ action: string;
50
+ args?: unknown[];
51
+ /** The sentence from a `data-agent-confirm` mark on the target, when it has one. */
52
+ confirm?: string;
53
+ }
54
+ /** What the server route answers. */
55
+ export type UiSdkApprovalAnswer = {
56
+ allowed: true;
57
+ decidedBy: string | null;
58
+ } | {
59
+ allowed: false;
60
+ reason: string;
61
+ };
62
+ export interface DeliverdAllowOptions {
63
+ /** Your server route that calls `uiSdkApprovalRoute`. */
64
+ endpoint: string;
65
+ /**
66
+ * Which steps go to a person. Default: those on a `data-agent-confirm`
67
+ * mark. Steps outside it are allowed without asking.
68
+ */
69
+ when?: (step: UiSdkStep) => boolean;
70
+ /** Headers for the call to your route, such as a CSRF token. */
71
+ headers?: Record<string, string> | (() => Record<string, string>);
72
+ /** Told each answer, so the page can show a person's reason. */
73
+ onAnswer?: (answer: UiSdkApprovalAnswer, step: UiSdkStep) => void;
74
+ fetch?: typeof globalThis.fetch;
75
+ }
76
+ /**
77
+ * UI SDK's `allow` hook, answered by a person through Deliverd.
78
+ *
79
+ * Anything other than a clear yes from your route is a no: a network failure,
80
+ * an error status, an answer it cannot read. UI SDK then tells the agent the
81
+ * person said no, and the control is not touched.
82
+ */
83
+ export declare function deliverdAllow(options: DeliverdAllowOptions): (step: UiSdkStep, context?: {
84
+ signal?: AbortSignal;
85
+ }) => Promise<boolean>;
86
+ export interface UiSdkApprovalRouteOptions extends Omit<ToolApprovalOptions, "when" | "describe"> {
87
+ /**
88
+ * Which steps go to a person, decided on the server. Default: those on a
89
+ * `data-agent-confirm` mark. A step outside it is refused, not allowed:
90
+ * the browser only sends steps it wants a person for, so anything else
91
+ * arriving here was not sent by `deliverdAllow`.
92
+ */
93
+ when?: (step: UiSdkStep, request: Request) => boolean | Promise<boolean>;
94
+ /** What the approver reads. Built from the mark's sentence, the control and its values when omitted. */
95
+ describe?: (step: UiSdkStep) => CallDescription;
96
+ /**
97
+ * How long to wait for the person. Default four minutes, inside UI SDK's
98
+ * own five-minute wait and a typical function limit. Raise all three together.
99
+ */
100
+ timeout?: Duration;
101
+ /** How long the request stays open. Default: the same as `timeout`. */
102
+ expiresIn?: Duration;
103
+ }
104
+ export declare const UI_SDK_DEFAULT_TIMEOUT: Duration;
105
+ /**
106
+ * The server half: a fetch-style `POST` handler (Next.js route handlers, Hono,
107
+ * Remix, Workers) that asks Deliverd about one UI SDK step and waits.
108
+ *
109
+ * Set `timeout` below both your platform's function limit and the bridge's
110
+ * own `timeout`, or the function is cut off before it can answer. The
111
+ * request's abort signal cancels the wait when the page stops asking.
112
+ */
113
+ export declare function uiSdkApprovalRoute(options: UiSdkApprovalRouteOptions): (request: Request) => Promise<Response>;
114
+ /** What an approver reads about a step, when the app did not write it. */
115
+ export declare function describeStep(step: UiSdkStep): CallDescription;
116
+ //# sourceMappingURL=ui-sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-sdk.d.ts","sourceRoot":"","sources":["../../src/adapters/ui-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE3F;;;;;;;;;;;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,GAAG,UAAU,CAAC;IAC/F;;;;;OAKG;IACH,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzE,wGAAwG;IACxG,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,eAAe,CAAC;IAChD;;;OAGG;IACH,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,uEAAuE;IACvE,SAAS,CAAC,EAAE,QAAQ,CAAC;CACtB;AAED,eAAO,MAAM,sBAAsB,EAAE,QAAe,CAAC;AAErD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAwC9G;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe,CAa7D"}
@@ -0,0 +1,164 @@
1
+ import { askAboutCall } from "./shared.js";
2
+ /**
3
+ * UI SDK's `allow` hook, answered by a person through Deliverd.
4
+ *
5
+ * Anything other than a clear yes from your route is a no: a network failure,
6
+ * an error status, an answer it cannot read. UI SDK then tells the agent the
7
+ * person said no, and the control is not touched.
8
+ */
9
+ export function deliverdAllow(options) {
10
+ const needsPerson = options.when ?? ((step) => Boolean(step.confirm));
11
+ return async (step, context) => {
12
+ if (!needsPerson(step))
13
+ return true;
14
+ const doFetch = options.fetch ?? globalThis.fetch;
15
+ const headers = typeof options.headers === "function" ? options.headers() : options.headers;
16
+ let answer;
17
+ try {
18
+ const response = await doFetch(options.endpoint, {
19
+ method: "POST",
20
+ headers: { "content-type": "application/json", ...headers },
21
+ body: JSON.stringify({ step: pickStep(step), nonce: nonce() }),
22
+ signal: context?.signal,
23
+ });
24
+ const body = (await response.json().catch(() => null));
25
+ answer =
26
+ response.ok && body?.allowed === true
27
+ ? { allowed: true, decidedBy: typeof body.decidedBy === "string" ? body.decidedBy : null }
28
+ : {
29
+ allowed: false,
30
+ reason: body && body.allowed === false && typeof body.reason === "string"
31
+ ? body.reason
32
+ : `The approval route answered ${response.status}, so the step was not run.`,
33
+ };
34
+ }
35
+ catch {
36
+ if (context?.signal?.aborted)
37
+ return false;
38
+ answer = { allowed: false, reason: "The approval route could not be reached, so the step was not run." };
39
+ }
40
+ options.onAnswer?.(answer, step);
41
+ return answer.allowed;
42
+ };
43
+ }
44
+ export const UI_SDK_DEFAULT_TIMEOUT = "4m";
45
+ /**
46
+ * The server half: a fetch-style `POST` handler (Next.js route handlers, Hono,
47
+ * Remix, Workers) that asks Deliverd about one UI SDK step and waits.
48
+ *
49
+ * Set `timeout` below both your platform's function limit and the bridge's
50
+ * own `timeout`, or the function is cut off before it can answer. The
51
+ * request's abort signal cancels the wait when the page stops asking.
52
+ */
53
+ export function uiSdkApprovalRoute(options) {
54
+ const needsPerson = options.when ?? ((step) => Boolean(step.confirm));
55
+ const describe = options.describe ?? describeStep;
56
+ const timeout = options.timeout ?? UI_SDK_DEFAULT_TIMEOUT;
57
+ return async (request) => {
58
+ if (request.method !== "POST")
59
+ return json({ allowed: false, reason: "Use POST." }, 405);
60
+ let raw;
61
+ try {
62
+ const text = await request.text();
63
+ if (text.length > BODY_MAX)
64
+ return json({ allowed: false, reason: "The step is too large to ask about." }, 413);
65
+ raw = JSON.parse(text);
66
+ }
67
+ catch {
68
+ return json({ allowed: false, reason: "The step could not be read." }, 400);
69
+ }
70
+ const parsed = readBody(raw);
71
+ if (!parsed)
72
+ return json({ allowed: false, reason: "The step could not be read." }, 400);
73
+ const { step, nonce: id } = parsed;
74
+ if (!(await needsPerson(step, request))) {
75
+ return json({ allowed: false, reason: "This step is not one this route asks a person about." }, 403);
76
+ }
77
+ const name = stepName(step);
78
+ const outcome = await askAboutCall(name, { component: step.component, ref: step.ref, action: step.action, args: step.args ?? [] }, `ui-sdk:${await sha256(canonical({ step, id }))}`, {
79
+ ...options,
80
+ when: undefined,
81
+ describe: () => describe(step),
82
+ timeout,
83
+ expiresIn: options.expiresIn ?? timeout,
84
+ metadata: { ...options.metadata, source: "ui-sdk" },
85
+ }, request.signal);
86
+ return json(outcome.allowed ? { allowed: true, decidedBy: outcome.decidedBy } : { allowed: false, reason: outcome.reason }, 200);
87
+ };
88
+ }
89
+ /** What an approver reads about a step, when the app did not write it. */
90
+ export function describeStep(step) {
91
+ const target = step.label ? `"${step.label}"` : `the ${step.component}`;
92
+ const verb = step.action === "press" ? "press" : step.action === "setValue" ? "set" : step.action;
93
+ const values = (step.args ?? []).map((arg) => (typeof arg === "string" ? arg : JSON.stringify(arg))).join(", ");
94
+ const lines = [
95
+ step.confirm ? `The app says this: ${step.confirm}` : undefined,
96
+ `An agent wants to ${verb} ${target}${values ? ` (${truncate(values, 500)})` : ""} in the app.`,
97
+ ].filter(Boolean);
98
+ return {
99
+ title: truncate(step.confirm ?? `Let the agent ${verb} ${target}`, 200),
100
+ description: lines.join("\n\n"),
101
+ risk: step.confirm ? "high" : "medium",
102
+ };
103
+ }
104
+ const BODY_MAX = 16_000;
105
+ function stepName(step) {
106
+ return step.label ? `${step.action} "${step.label}"` : `${step.action} ${step.component}`;
107
+ }
108
+ /** Only the fields `AgentAction` documents, so nothing else on the object leaves the page. */
109
+ function pickStep(step) {
110
+ return {
111
+ ref: step.ref,
112
+ component: step.component,
113
+ ...(step.label !== undefined ? { label: step.label } : {}),
114
+ action: step.action,
115
+ args: step.args ?? [],
116
+ ...(step.confirm !== undefined ? { confirm: step.confirm } : {}),
117
+ };
118
+ }
119
+ function readBody(raw) {
120
+ if (typeof raw !== "object" || raw === null)
121
+ return null;
122
+ const { step, nonce: id } = raw;
123
+ if (typeof id !== "string" || id.length === 0 || id.length > 100)
124
+ return null;
125
+ if (typeof step !== "object" || step === null)
126
+ return null;
127
+ const s = step;
128
+ const str = (v) => typeof v === "string" && v.length <= 1000;
129
+ if (!str(s.ref) || !str(s.component) || !str(s.action))
130
+ return null;
131
+ if (s.label !== undefined && !str(s.label))
132
+ return null;
133
+ if (s.confirm !== undefined && !str(s.confirm))
134
+ return null;
135
+ if (s.args !== undefined && !Array.isArray(s.args))
136
+ return null;
137
+ return { step: pickStep(s), nonce: id };
138
+ }
139
+ function json(body, status) {
140
+ return new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json" } });
141
+ }
142
+ function truncate(text, max) {
143
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;
144
+ }
145
+ function nonce() {
146
+ const c = globalThis.crypto;
147
+ if (c?.randomUUID)
148
+ return c.randomUUID();
149
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
150
+ }
151
+ function canonical(value) {
152
+ if (value === null || typeof value !== "object")
153
+ return JSON.stringify(value ?? null);
154
+ if (Array.isArray(value))
155
+ return `[${value.map(canonical).join(",")}]`;
156
+ const entries = Object.entries(value)
157
+ .filter(([, v]) => v !== undefined)
158
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
159
+ return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(",")}}`;
160
+ }
161
+ async function sha256(text) {
162
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
163
+ return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
164
+ }
@@ -43,7 +43,7 @@
43
43
  * **Add the version here when you publish it, not before.** An entry is a
44
44
  * claim that `npm install @deliverd/sdk@x` works today.
45
45
  */
46
- export declare const PUBLISHED_TO_NPM: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.6.2", "0.7.0", "0.7.1", "0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.11.0", "0.11.1", "0.12.0", "0.13.0", "0.14.0", "0.15.0", "0.16.0", "0.17.0", "0.18.0", "0.19.0", "0.20.0", "0.21.0", "0.22.0", "0.23.0", "0.24.0", "0.24.1", "0.25.0", "0.25.1", "0.26.0", "0.27.0", "0.28.0", "0.29.0", "0.30.0", "0.31.0", "0.32.0"];
46
+ export declare const PUBLISHED_TO_NPM: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.6.2", "0.7.0", "0.7.1", "0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.11.0", "0.11.1", "0.12.0", "0.13.0", "0.14.0", "0.15.0", "0.16.0", "0.17.0", "0.18.0", "0.19.0", "0.20.0", "0.21.0", "0.22.0", "0.23.0", "0.24.0", "0.24.1", "0.25.0", "0.25.1", "0.26.0", "0.27.0", "0.28.0", "0.29.0", "0.30.0", "0.31.0", "0.32.0", "0.33.0"];
47
47
  /**
48
48
  * A fingerprint of what each *published* version recorded.
49
49
  *
@@ -1 +1 @@
1
- {"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,6YAyCnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA+GzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CA0l7BtD,CAAC"}
1
+ {"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,uZA0CnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAiHzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAmi+BtD,CAAC"}