@sponsio/sdk 0.1.0-alpha.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/contracts/capability/credentials.yaml +188 -0
- package/contracts/capability/database.yaml +141 -0
- package/contracts/capability/filesystem-strict.yaml +101 -0
- package/contracts/capability/filesystem.yaml +239 -0
- package/contracts/capability/self-modify.yaml +152 -0
- package/contracts/capability/shell.yaml +246 -0
- package/contracts/capability/subagent.yaml +184 -0
- package/contracts/core/llm_safety.yaml +130 -0
- package/contracts/core/runaway.yaml +43 -0
- package/contracts/core/universal.yaml +34 -0
- package/contracts/incident/claude-code-secret-bypass.yaml +197 -0
- package/contracts/incident/cursor-railway-wipe.yaml +164 -0
- package/contracts/incident/mcp-composition.yaml +418 -0
- package/contracts/incident/openclaw.yaml +500 -0
- package/contracts/incident/subagent-escape.yaml +177 -0
- package/contracts/premium/.gitkeep +7 -0
- package/dist/contract.d.ts +59 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +97 -0
- package/dist/contract.js.map +1 -0
- package/dist/core/config-loader.d.ts +90 -0
- package/dist/core/config-loader.d.ts.map +1 -0
- package/dist/core/config-loader.js +530 -0
- package/dist/core/config-loader.js.map +1 -0
- package/dist/core/evaluator.d.ts +15 -0
- package/dist/core/evaluator.d.ts.map +1 -0
- package/dist/core/evaluator.js +87 -0
- package/dist/core/evaluator.js.map +1 -0
- package/dist/core/formula.d.ts +103 -0
- package/dist/core/formula.d.ts.map +1 -0
- package/dist/core/formula.js +167 -0
- package/dist/core/formula.js.map +1 -0
- package/dist/core/grounding.d.ts +43 -0
- package/dist/core/grounding.d.ts.map +1 -0
- package/dist/core/grounding.js +269 -0
- package/dist/core/grounding.js.map +1 -0
- package/dist/core/nl-parser.d.ts +12 -0
- package/dist/core/nl-parser.d.ts.map +1 -0
- package/dist/core/nl-parser.js +152 -0
- package/dist/core/nl-parser.js.map +1 -0
- package/dist/core/pack-loader.d.ts +15 -0
- package/dist/core/pack-loader.d.ts.map +1 -0
- package/dist/core/pack-loader.js +220 -0
- package/dist/core/pack-loader.js.map +1 -0
- package/dist/core/parser.d.ts +19 -0
- package/dist/core/parser.d.ts.map +1 -0
- package/dist/core/parser.js +235 -0
- package/dist/core/parser.js.map +1 -0
- package/dist/core/pattern-factory.d.ts +38 -0
- package/dist/core/pattern-factory.d.ts.map +1 -0
- package/dist/core/pattern-factory.js +222 -0
- package/dist/core/pattern-factory.js.map +1 -0
- package/dist/core/patterns.d.ts +67 -0
- package/dist/core/patterns.d.ts.map +1 -0
- package/dist/core/patterns.js +585 -0
- package/dist/core/patterns.js.map +1 -0
- package/dist/core/session-log.d.ts +91 -0
- package/dist/core/session-log.d.ts.map +1 -0
- package/dist/core/session-log.js +196 -0
- package/dist/core/session-log.js.map +1 -0
- package/dist/core/spans.d.ts +92 -0
- package/dist/core/spans.d.ts.map +1 -0
- package/dist/core/spans.js +148 -0
- package/dist/core/spans.js.map +1 -0
- package/dist/core/sto.d.ts +120 -0
- package/dist/core/sto.d.ts.map +1 -0
- package/dist/core/sto.js +147 -0
- package/dist/core/sto.js.map +1 -0
- package/dist/index.d.ts +267 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +540 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/claude-agent.d.ts +29 -0
- package/dist/integrations/claude-agent.d.ts.map +1 -0
- package/dist/integrations/claude-agent.js +40 -0
- package/dist/integrations/claude-agent.js.map +1 -0
- package/dist/integrations/google-adk.d.ts +27 -0
- package/dist/integrations/google-adk.d.ts.map +1 -0
- package/dist/integrations/google-adk.js +81 -0
- package/dist/integrations/google-adk.js.map +1 -0
- package/dist/integrations/langchain.d.ts +26 -0
- package/dist/integrations/langchain.d.ts.map +1 -0
- package/dist/integrations/langchain.js +74 -0
- package/dist/integrations/langchain.js.map +1 -0
- package/dist/integrations/openai-agents.d.ts +45 -0
- package/dist/integrations/openai-agents.d.ts.map +1 -0
- package/dist/integrations/openai-agents.js +81 -0
- package/dist/integrations/openai-agents.js.map +1 -0
- package/dist/integrations/openai.d.ts +24 -0
- package/dist/integrations/openai.d.ts.map +1 -0
- package/dist/integrations/openai.js +77 -0
- package/dist/integrations/openai.js.map +1 -0
- package/dist/integrations/vercel-ai.d.ts +38 -0
- package/dist/integrations/vercel-ai.d.ts.map +1 -0
- package/dist/integrations/vercel-ai.js +107 -0
- package/dist/integrations/vercel-ai.js.map +1 -0
- package/dist/render/components.d.ts +23 -0
- package/dist/render/components.d.ts.map +1 -0
- package/dist/render/components.js +133 -0
- package/dist/render/components.js.map +1 -0
- package/dist/render/derive.d.ts +23 -0
- package/dist/render/derive.d.ts.map +1 -0
- package/dist/render/derive.js +92 -0
- package/dist/render/derive.js.map +1 -0
- package/dist/render/session-view.d.ts +19 -0
- package/dist/render/session-view.d.ts.map +1 -0
- package/dist/render/session-view.js +236 -0
- package/dist/render/session-view.js.map +1 -0
- package/dist/render/tokens.d.ts +44 -0
- package/dist/render/tokens.d.ts.map +1 -0
- package/dist/render/tokens.js +72 -0
- package/dist/render/tokens.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fluent contract builder — TS parity for the Python
|
|
3
|
+
* ``from sponsio import contract`` helper.
|
|
4
|
+
*
|
|
5
|
+
* Usage::
|
|
6
|
+
*
|
|
7
|
+
* import { Sponsio, contract } from "@sponsio/sdk";
|
|
8
|
+
*
|
|
9
|
+
* const guard = new Sponsio({
|
|
10
|
+
* agentId: "refund_bot",
|
|
11
|
+
* contracts: [
|
|
12
|
+
* contract("refund policy gate")
|
|
13
|
+
* .assume("called `issue_refund`")
|
|
14
|
+
* .enforce("must call `check_policy` before `issue_refund`"),
|
|
15
|
+
* contract("rate cap")
|
|
16
|
+
* .enforce("tool `issue_refund` at most 3 times"),
|
|
17
|
+
* ],
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* Repeated ``.assume`` / ``.enforce`` calls AND-combine (matching
|
|
21
|
+
* the Python builder). If ``.assume`` is omitted the contract is
|
|
22
|
+
* unconditional and the enforcement formula is used as-is. If
|
|
23
|
+
* ``.assume`` is present the formula is ``A -> E``.
|
|
24
|
+
*
|
|
25
|
+
* The builder satisfies ``DetFormula`` structurally, so it can be
|
|
26
|
+
* passed directly to ``Sponsio({ contracts: [...] })`` — no ``build()``
|
|
27
|
+
* step required.
|
|
28
|
+
*/
|
|
29
|
+
import { type Formula } from "./core/formula.js";
|
|
30
|
+
import type { DetFormula } from "./core/patterns.js";
|
|
31
|
+
export declare class ContractBuilder implements DetFormula {
|
|
32
|
+
readonly desc: string;
|
|
33
|
+
readonly patternName: string;
|
|
34
|
+
readonly liveness: boolean;
|
|
35
|
+
private _assumption;
|
|
36
|
+
private _enforcement;
|
|
37
|
+
constructor(desc?: string);
|
|
38
|
+
/** Add an assumption clause (A side). Repeated calls AND-combine. */
|
|
39
|
+
assume(clause: string | DetFormula): ContractBuilder;
|
|
40
|
+
/** Add an enforcement clause (E side). Repeated calls AND-combine. */
|
|
41
|
+
enforce(clause: string | DetFormula): ContractBuilder;
|
|
42
|
+
/**
|
|
43
|
+
* The compiled LTL formula. Accessed at `Sponsio` construction time.
|
|
44
|
+
*
|
|
45
|
+
* - If both A and E are set: ``G(A -> E)``. We wrap in ``G`` because
|
|
46
|
+
* the evaluator runs from ``pos=0``; a bare ``Implies(A, E)`` would
|
|
47
|
+
* short-circuit whenever ``A`` was false at step 0 regardless of
|
|
48
|
+
* later events. ``G`` lifts the implication to every step so the
|
|
49
|
+
* enforcement fires whenever the assumption holds.
|
|
50
|
+
* - If only E: ``E`` (unconditional; the pattern factories already
|
|
51
|
+
* emit safety properties wrapped in ``G`` where needed).
|
|
52
|
+
* - If neither: throws — every contract needs an enforcement.
|
|
53
|
+
*/
|
|
54
|
+
get formula(): Formula;
|
|
55
|
+
private _clone;
|
|
56
|
+
}
|
|
57
|
+
/** Start a fluent contract. Mirrors Python's ``sponsio.contract(desc)``. */
|
|
58
|
+
export declare function contract(desc?: string): ContractBuilder;
|
|
59
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,qBAAa,eAAgB,YAAW,UAAU;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAc;IAC1C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAS;IAEnC,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,YAAY,CAAiB;gBAEzB,IAAI,CAAC,EAAE,MAAM;IAMzB,qEAAqE;IACrE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe;IAOpD,sEAAsE;IACtE,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe;IAOrD;;;;;;;;;;;OAWG;IACH,IAAI,OAAO,IAAI,OAAO,CASrB;IAED,OAAO,CAAC,MAAM;CAMf;AAeD,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,eAAe,CAEvD"}
|
package/dist/contract.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fluent contract builder — TS parity for the Python
|
|
3
|
+
* ``from sponsio import contract`` helper.
|
|
4
|
+
*
|
|
5
|
+
* Usage::
|
|
6
|
+
*
|
|
7
|
+
* import { Sponsio, contract } from "@sponsio/sdk";
|
|
8
|
+
*
|
|
9
|
+
* const guard = new Sponsio({
|
|
10
|
+
* agentId: "refund_bot",
|
|
11
|
+
* contracts: [
|
|
12
|
+
* contract("refund policy gate")
|
|
13
|
+
* .assume("called `issue_refund`")
|
|
14
|
+
* .enforce("must call `check_policy` before `issue_refund`"),
|
|
15
|
+
* contract("rate cap")
|
|
16
|
+
* .enforce("tool `issue_refund` at most 3 times"),
|
|
17
|
+
* ],
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* Repeated ``.assume`` / ``.enforce`` calls AND-combine (matching
|
|
21
|
+
* the Python builder). If ``.assume`` is omitted the contract is
|
|
22
|
+
* unconditional and the enforcement formula is used as-is. If
|
|
23
|
+
* ``.assume`` is present the formula is ``A -> E``.
|
|
24
|
+
*
|
|
25
|
+
* The builder satisfies ``DetFormula`` structurally, so it can be
|
|
26
|
+
* passed directly to ``Sponsio({ contracts: [...] })`` — no ``build()``
|
|
27
|
+
* step required.
|
|
28
|
+
*/
|
|
29
|
+
import { parseNl } from "./core/nl-parser.js";
|
|
30
|
+
import { And, G, Implies } from "./core/formula.js";
|
|
31
|
+
export class ContractBuilder {
|
|
32
|
+
desc;
|
|
33
|
+
patternName = "contract";
|
|
34
|
+
liveness = false;
|
|
35
|
+
_assumption;
|
|
36
|
+
_enforcement;
|
|
37
|
+
constructor(desc) {
|
|
38
|
+
this.desc = desc ?? "contract";
|
|
39
|
+
this._assumption = null;
|
|
40
|
+
this._enforcement = null;
|
|
41
|
+
}
|
|
42
|
+
/** Add an assumption clause (A side). Repeated calls AND-combine. */
|
|
43
|
+
assume(clause) {
|
|
44
|
+
const next = this._clone();
|
|
45
|
+
const f = toFormula(clause, "assume");
|
|
46
|
+
next._assumption = next._assumption ? new And(next._assumption, f) : f;
|
|
47
|
+
return next;
|
|
48
|
+
}
|
|
49
|
+
/** Add an enforcement clause (E side). Repeated calls AND-combine. */
|
|
50
|
+
enforce(clause) {
|
|
51
|
+
const next = this._clone();
|
|
52
|
+
const f = toFormula(clause, "enforce");
|
|
53
|
+
next._enforcement = next._enforcement ? new And(next._enforcement, f) : f;
|
|
54
|
+
return next;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The compiled LTL formula. Accessed at `Sponsio` construction time.
|
|
58
|
+
*
|
|
59
|
+
* - If both A and E are set: ``G(A -> E)``. We wrap in ``G`` because
|
|
60
|
+
* the evaluator runs from ``pos=0``; a bare ``Implies(A, E)`` would
|
|
61
|
+
* short-circuit whenever ``A`` was false at step 0 regardless of
|
|
62
|
+
* later events. ``G`` lifts the implication to every step so the
|
|
63
|
+
* enforcement fires whenever the assumption holds.
|
|
64
|
+
* - If only E: ``E`` (unconditional; the pattern factories already
|
|
65
|
+
* emit safety properties wrapped in ``G`` where needed).
|
|
66
|
+
* - If neither: throws — every contract needs an enforcement.
|
|
67
|
+
*/
|
|
68
|
+
get formula() {
|
|
69
|
+
if (!this._enforcement) {
|
|
70
|
+
throw new Error(`contract(${JSON.stringify(this.desc)}): .enforce(...) is required`);
|
|
71
|
+
}
|
|
72
|
+
return this._assumption
|
|
73
|
+
? new G(new Implies(this._assumption, this._enforcement))
|
|
74
|
+
: this._enforcement;
|
|
75
|
+
}
|
|
76
|
+
_clone() {
|
|
77
|
+
const next = new ContractBuilder(this.desc);
|
|
78
|
+
next._assumption = this._assumption;
|
|
79
|
+
next._enforcement = this._enforcement;
|
|
80
|
+
return next;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function toFormula(clause, which) {
|
|
84
|
+
if (typeof clause === "string") {
|
|
85
|
+
const parsed = parseNl(clause);
|
|
86
|
+
if (!parsed) {
|
|
87
|
+
throw new Error(`contract().${which}("${clause}"): could not parse NL clause`);
|
|
88
|
+
}
|
|
89
|
+
return parsed.formula;
|
|
90
|
+
}
|
|
91
|
+
return clause.formula;
|
|
92
|
+
}
|
|
93
|
+
/** Start a fluent contract. Mirrors Python's ``sponsio.contract(desc)``. */
|
|
94
|
+
export function contract(desc) {
|
|
95
|
+
return new ContractBuilder(desc);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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-compatible sponsio.yaml into the shape the
|
|
5
|
+
* {@link Sponsio} constructor expects: a list of NL-string contracts
|
|
6
|
+
* plus runtime settings (mode, dashboard).
|
|
7
|
+
*
|
|
8
|
+
* Intentionally conservative — this loader understands the **subset**
|
|
9
|
+
* of the yaml schema that makes sense in TS today:
|
|
10
|
+
*
|
|
11
|
+
* - `runtime.mode` / `runtime.dashboard`
|
|
12
|
+
* - `agents.<id>.contracts[]` with either a plain-string `E:` field
|
|
13
|
+
* or a top-level `desc:` / direct-string entry. Structured
|
|
14
|
+
* `{ pattern, args }` forms that need pack-runtime support
|
|
15
|
+
* (token_budget, delegation_depth_limit, loop_detection, …)
|
|
16
|
+
* are *skipped with a warning* — the TS runtime does not ship
|
|
17
|
+
* pack infrastructure yet.
|
|
18
|
+
* - `include:` pack references are skipped with a warning for the
|
|
19
|
+
* same reason.
|
|
20
|
+
*
|
|
21
|
+
* The loader is therefore a **strict superset of inline TS usage**:
|
|
22
|
+
* contracts that work when passed as `contracts: string[]` to the
|
|
23
|
+
* ctor also work when loaded from yaml. More exotic Python-side
|
|
24
|
+
* features (sto contracts, packs, LTL patterns) are logged and
|
|
25
|
+
* ignored rather than crashing, so a user can share a single
|
|
26
|
+
* sponsio.yaml between Python and TS without the TS side refusing
|
|
27
|
+
* to start.
|
|
28
|
+
*/
|
|
29
|
+
import type { DetFormula } from "./patterns.js";
|
|
30
|
+
export interface LoadedConfig {
|
|
31
|
+
/**
|
|
32
|
+
* Det contracts the TS SDK can consume. NL strings get run through
|
|
33
|
+
* ``parseNl`` in the ctor; pre-built ``DetFormula`` entries (from
|
|
34
|
+
* structured patterns, raw LTL, or A/E composition) are pushed
|
|
35
|
+
* straight onto the contract list — no NL parsing required.
|
|
36
|
+
*/
|
|
37
|
+
contracts: (string | DetFormula)[];
|
|
38
|
+
/** Sto contract specs — compiled into evaluators by the ctor. */
|
|
39
|
+
stoSpecs: StoContractSpec[];
|
|
40
|
+
/** `judge:` block — provider / model / api_key / base_url / fallback. */
|
|
41
|
+
judge?: JudgeConfigSpec;
|
|
42
|
+
/** `enforce` | `observe` | undefined (fall through to default). */
|
|
43
|
+
mode?: "enforce" | "observe";
|
|
44
|
+
/** Dashboard URL or boolean from yaml, passed through unchanged. */
|
|
45
|
+
dashboard?: string | boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Contracts / packs we couldn't handle. Surfaced so the Sponsio
|
|
48
|
+
* ctor can warn once without spamming per-contract log lines.
|
|
49
|
+
*/
|
|
50
|
+
skipped: SkippedItem[];
|
|
51
|
+
}
|
|
52
|
+
export interface SkippedItem {
|
|
53
|
+
kind: "pack" | "structured-contract" | "sto-contract" | "unknown-contract";
|
|
54
|
+
detail: string;
|
|
55
|
+
}
|
|
56
|
+
export type StoAtomName = "tone" | "llm_judge" | "relevance" | "semantic_pii_free" | "hallucination_free" | "scope_respect" | "metric_integrity" | "injection_free";
|
|
57
|
+
/**
|
|
58
|
+
* Spec for a yaml-declared sto contract. The loader stays stateless:
|
|
59
|
+
* it emits a description of the rule, and the Sponsio ctor wires up
|
|
60
|
+
* an evaluator against the `judge:` client.
|
|
61
|
+
*/
|
|
62
|
+
export interface StoContractSpec {
|
|
63
|
+
atom: StoAtomName;
|
|
64
|
+
desc: string;
|
|
65
|
+
/** Threshold — score below this counts as a violation. */
|
|
66
|
+
threshold: number;
|
|
67
|
+
/** ``tone``: the target tone. ``scope_respect``: the scope blurb.
|
|
68
|
+
* Other atoms ignore this. */
|
|
69
|
+
args: string[];
|
|
70
|
+
/** Free-form rubric for ``llm_judge``. */
|
|
71
|
+
promptOverride?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface JudgeConfigSpec {
|
|
74
|
+
provider?: "openai";
|
|
75
|
+
model?: string;
|
|
76
|
+
apiKey?: string;
|
|
77
|
+
baseUrl?: string;
|
|
78
|
+
fallbackMode?: "allow" | "deny" | "skip";
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Load sponsio.yaml and project it onto the TS runtime's contract
|
|
82
|
+
* surface. Reads synchronously so it can be called from a ctor.
|
|
83
|
+
*
|
|
84
|
+
* @param path Path to sponsio.yaml (absolute or CWD-relative).
|
|
85
|
+
* @param agentId Which agent block to pull contracts from. Falls
|
|
86
|
+
* back to `agents["*"]` (the wildcard block used by
|
|
87
|
+
* packs) if `agentId` is missing.
|
|
88
|
+
*/
|
|
89
|
+
export declare function loadSponsoConfig(path: string, agentId: string): LoadedConfig;
|
|
90
|
+
//# sourceMappingURL=config-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/core/config-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAgBhD,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,SAAS,EAAE,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC;IACnC,iEAAiE;IACjE,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,yEAAyE;IACzE,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,mEAAmE;IACnE,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B;;;OAGG;IACH,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,qBAAqB,GAAG,cAAc,GAAG,kBAAkB,CAAC;IAC3E,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,WAAW,GACX,WAAW,GACX,mBAAmB,GACnB,oBAAoB,GACpB,eAAe,GACf,kBAAkB,GAClB,gBAAgB,CAAC;AAErB;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;I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