@sentropic/h2a-runtime 0.91.1 → 0.93.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.
Files changed (108) hide show
  1. package/dist/config.d.ts +2 -0
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +16 -3
  4. package/dist/config.js.map +1 -1
  5. package/dist/conv-guard.d.ts +6 -1
  6. package/dist/conv-guard.d.ts.map +1 -1
  7. package/dist/conv-guard.js +33 -8
  8. package/dist/conv-guard.js.map +1 -1
  9. package/dist/enroll.d.ts.map +1 -1
  10. package/dist/enroll.js +12 -2
  11. package/dist/enroll.js.map +1 -1
  12. package/dist/index.d.ts +3 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +819 -155
  15. package/dist/index.js.map +1 -1
  16. package/dist/launch-layout.d.ts +74 -0
  17. package/dist/launch-layout.d.ts.map +1 -0
  18. package/dist/launch-layout.js +324 -0
  19. package/dist/launch-layout.js.map +1 -0
  20. package/dist/llm-gateway-runtime/index.d.ts +6 -0
  21. package/dist/llm-gateway-runtime/index.d.ts.map +1 -1
  22. package/dist/llm-gateway-runtime/index.js +134 -60
  23. package/dist/llm-gateway-runtime/index.js.map +1 -1
  24. package/dist/llm-gateway-runtime/session-ledger.d.ts +38 -55
  25. package/dist/llm-gateway-runtime/session-ledger.d.ts.map +1 -1
  26. package/dist/llm-gateway-runtime/session-ledger.js +102 -250
  27. package/dist/llm-gateway-runtime/session-ledger.js.map +1 -1
  28. package/dist/llm-gateway-runtime/sticky.d.ts +25 -52
  29. package/dist/llm-gateway-runtime/sticky.d.ts.map +1 -1
  30. package/dist/llm-gateway-runtime/sticky.js +36 -605
  31. package/dist/llm-gateway-runtime/sticky.js.map +1 -1
  32. package/dist/llm-mesh.d.ts +19 -72
  33. package/dist/llm-mesh.d.ts.map +1 -1
  34. package/dist/llm-mesh.js +42 -399
  35. package/dist/llm-mesh.js.map +1 -1
  36. package/dist/llm-routing-config.d.ts +28 -0
  37. package/dist/llm-routing-config.d.ts.map +1 -0
  38. package/dist/llm-routing-config.js +100 -0
  39. package/dist/llm-routing-config.js.map +1 -0
  40. package/dist/native-host.d.ts +146 -0
  41. package/dist/native-host.d.ts.map +1 -0
  42. package/dist/native-host.js +456 -0
  43. package/dist/native-host.js.map +1 -0
  44. package/dist/native-terminal/host.d.ts +317 -1
  45. package/dist/native-terminal/host.d.ts.map +1 -1
  46. package/dist/native-terminal/host.js +696 -3
  47. package/dist/native-terminal/host.js.map +1 -1
  48. package/dist/native-terminal/op.d.ts +5 -0
  49. package/dist/native-terminal/op.d.ts.map +1 -0
  50. package/dist/native-terminal/op.js +408 -0
  51. package/dist/native-terminal/op.js.map +1 -0
  52. package/dist/native-terminal/process.d.ts +2 -0
  53. package/dist/native-terminal/process.d.ts.map +1 -1
  54. package/dist/native-terminal/process.js +16 -2
  55. package/dist/native-terminal/process.js.map +1 -1
  56. package/dist/native-terminal/server.d.ts.map +1 -1
  57. package/dist/native-terminal/server.js +6 -2
  58. package/dist/native-terminal/server.js.map +1 -1
  59. package/dist/native-terminal/socket-path.d.ts +8 -0
  60. package/dist/native-terminal/socket-path.d.ts.map +1 -1
  61. package/dist/native-terminal/socket-path.js +31 -1
  62. package/dist/native-terminal/socket-path.js.map +1 -1
  63. package/dist/native-terminal/supervisor.d.ts +13 -0
  64. package/dist/native-terminal/supervisor.d.ts.map +1 -1
  65. package/dist/native-terminal/supervisor.js +45 -0
  66. package/dist/native-terminal/supervisor.js.map +1 -1
  67. package/dist/pty.d.ts +23 -0
  68. package/dist/pty.d.ts.map +1 -1
  69. package/dist/pty.js +35 -0
  70. package/dist/pty.js.map +1 -1
  71. package/dist/readiness.d.ts +7 -0
  72. package/dist/readiness.d.ts.map +1 -1
  73. package/dist/readiness.js +12 -9
  74. package/dist/readiness.js.map +1 -1
  75. package/dist/registry.d.ts +324 -2
  76. package/dist/registry.d.ts.map +1 -1
  77. package/dist/registry.js +659 -20
  78. package/dist/registry.js.map +1 -1
  79. package/dist/restore.d.ts +91 -32
  80. package/dist/restore.d.ts.map +1 -1
  81. package/dist/restore.js +226 -186
  82. package/dist/restore.js.map +1 -1
  83. package/dist/status-projection.d.ts.map +1 -1
  84. package/dist/tmux.d.ts +9 -6
  85. package/dist/tmux.d.ts.map +1 -1
  86. package/dist/tmux.js +34 -8
  87. package/dist/tmux.js.map +1 -1
  88. package/package.json +3 -3
  89. package/dist/llm-gateway-runtime/accounts.d.ts +0 -62
  90. package/dist/llm-gateway-runtime/accounts.d.ts.map +0 -1
  91. package/dist/llm-gateway-runtime/accounts.js +0 -323
  92. package/dist/llm-gateway-runtime/accounts.js.map +0 -1
  93. package/dist/llm-gateway-runtime/model-catalog.d.ts +0 -44
  94. package/dist/llm-gateway-runtime/model-catalog.d.ts.map +0 -1
  95. package/dist/llm-gateway-runtime/model-catalog.js +0 -191
  96. package/dist/llm-gateway-runtime/model-catalog.js.map +0 -1
  97. package/dist/llm-gateway-runtime/proxy-anthropic.d.ts +0 -3
  98. package/dist/llm-gateway-runtime/proxy-anthropic.d.ts.map +0 -1
  99. package/dist/llm-gateway-runtime/proxy-anthropic.js +0 -318
  100. package/dist/llm-gateway-runtime/proxy-anthropic.js.map +0 -1
  101. package/dist/llm-gateway-runtime/proxy-cloud-code.d.ts +0 -11
  102. package/dist/llm-gateway-runtime/proxy-cloud-code.d.ts.map +0 -1
  103. package/dist/llm-gateway-runtime/proxy-cloud-code.js +0 -215
  104. package/dist/llm-gateway-runtime/proxy-cloud-code.js.map +0 -1
  105. package/dist/llm-gateway-runtime/proxy-openai.d.ts +0 -118
  106. package/dist/llm-gateway-runtime/proxy-openai.d.ts.map +0 -1
  107. package/dist/llm-gateway-runtime/proxy-openai.js +0 -1305
  108. package/dist/llm-gateway-runtime/proxy-openai.js.map +0 -1
@@ -0,0 +1,28 @@
1
+ import { InMemoryRoutePolicyProfiles, type ModelEquivalenceCouncil, type RoutePolicy, type RoutePolicyProfile, type RouteSelector } from "@sentropic/llm-mesh";
2
+ export interface LlmMeshRoutingConfig {
3
+ /** Host-level public policy override. Canonical routing knowledge remains in llm-mesh. */
4
+ policy?: RoutePolicy;
5
+ /** Optional named policies, validated and activated by llm-mesh. */
6
+ profiles?: RoutePolicyProfile[];
7
+ activeProfile?: string;
8
+ /** Optional request constraint; account selectors use only redacted refs. */
9
+ explicit?: RouteSelector;
10
+ /** Optional reviewed council replacement. Never synthesize one in h2a. */
11
+ council?: ModelEquivalenceCouncil;
12
+ }
13
+ export declare const ROUTING_TRANSPORT_ALIASES: {
14
+ readonly codex: "codex";
15
+ readonly "cloud-code": "cloud-code";
16
+ readonly agy: "cloud-code";
17
+ };
18
+ export type RoutingTransportAlias = keyof typeof ROUTING_TRANSPORT_ALIASES;
19
+ export declare function routeSelectorForTransport(value: string): RouteSelector;
20
+ export declare function validateLlmMeshRoutingConfig(config: LlmMeshRoutingConfig): LlmMeshRoutingConfig;
21
+ export declare function routingProfiles(config: LlmMeshRoutingConfig | undefined): InMemoryRoutePolicyProfiles | undefined;
22
+ export declare function preferredRoutingConfig(current: LlmMeshRoutingConfig | undefined, transports: readonly string[]): LlmMeshRoutingConfig;
23
+ export declare function strategyRoutingConfig(current: LlmMeshRoutingConfig | undefined, strategy: "last-enrolled" | "round-robin"): LlmMeshRoutingConfig;
24
+ export declare function effectiveRoutingPolicy(config: LlmMeshRoutingConfig | undefined): RoutePolicy;
25
+ export declare function effectiveRoutingCouncil(config: LlmMeshRoutingConfig | undefined): ModelEquivalenceCouncil;
26
+ export declare function parseLlmMeshRoutingConfig(value: string): LlmMeshRoutingConfig;
27
+ export declare function describeLlmMeshRoutingConfig(config: LlmMeshRoutingConfig | undefined): Record<string, unknown>;
28
+ //# sourceMappingURL=llm-routing-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-routing-config.d.ts","sourceRoot":"","sources":["../src/llm-routing-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,2BAA2B,EAI3B,KAAK,uBAAuB,EAC5B,KA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AAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBzB"}
@@ -0,0 +1,100 @@
1
+ import { DEFAULT_MODEL_EQUIVALENCE_COUNCIL, DEFAULT_ROUTE_POLICY, InMemoryRoutePolicyProfiles, modelProfiles, validateEquivalenceCouncil, validateRoutePolicy, } from "@sentropic/llm-mesh";
2
+ export const ROUTING_TRANSPORT_ALIASES = {
3
+ codex: "codex",
4
+ "cloud-code": "cloud-code",
5
+ agy: "cloud-code",
6
+ };
7
+ export function routeSelectorForTransport(value) {
8
+ const transport = ROUTING_TRANSPORT_ALIASES[value];
9
+ if (!transport) {
10
+ throw new Error(`unsupported routing transport "${value}"; expected codex, cloud-code, or agy`);
11
+ }
12
+ return { transportProviderId: transport };
13
+ }
14
+ export function validateLlmMeshRoutingConfig(config) {
15
+ if (config.policy)
16
+ validateRoutePolicy(config.policy);
17
+ const names = new Set();
18
+ for (const profile of config.profiles ?? []) {
19
+ if (names.has(profile.name)) {
20
+ throw new Error(`duplicate llm-mesh route profile: ${profile.name}`);
21
+ }
22
+ names.add(profile.name);
23
+ validateRoutePolicy(profile.policy);
24
+ }
25
+ if (config.activeProfile && !names.has(config.activeProfile)) {
26
+ throw new Error(`unknown llm-mesh route profile: ${config.activeProfile}`);
27
+ }
28
+ if (config.council) {
29
+ validateEquivalenceCouncil(config.council, modelProfiles);
30
+ }
31
+ return config;
32
+ }
33
+ export function routingProfiles(config) {
34
+ if (!config?.profiles?.length)
35
+ return undefined;
36
+ const profiles = new InMemoryRoutePolicyProfiles(config.profiles);
37
+ if (config.activeProfile)
38
+ profiles.activate(config.activeProfile);
39
+ return profiles;
40
+ }
41
+ export function preferredRoutingConfig(current, transports) {
42
+ if (transports.length === 0) {
43
+ throw new Error("at least one routing transport is required");
44
+ }
45
+ const policy = {
46
+ ...(current?.policy ?? DEFAULT_ROUTE_POLICY),
47
+ strategy: {
48
+ kind: "ordered",
49
+ preferences: transports.map(routeSelectorForTransport),
50
+ },
51
+ };
52
+ return validateLlmMeshRoutingConfig({ ...current, policy });
53
+ }
54
+ export function strategyRoutingConfig(current, strategy) {
55
+ const policy = {
56
+ ...(current?.policy ?? DEFAULT_ROUTE_POLICY),
57
+ strategy: strategy === "last-enrolled"
58
+ ? { kind: "last-enrolled" }
59
+ : { kind: "round-robin", scope: "new-affinity" },
60
+ };
61
+ return validateLlmMeshRoutingConfig({ ...current, policy });
62
+ }
63
+ export function effectiveRoutingPolicy(config) {
64
+ return config?.policy ?? DEFAULT_ROUTE_POLICY;
65
+ }
66
+ export function effectiveRoutingCouncil(config) {
67
+ return config?.council ?? DEFAULT_MODEL_EQUIVALENCE_COUNCIL;
68
+ }
69
+ export function parseLlmMeshRoutingConfig(value) {
70
+ let parsed;
71
+ try {
72
+ parsed = JSON.parse(value);
73
+ }
74
+ catch (error) {
75
+ throw new Error(`invalid routing JSON: ${error instanceof Error ? error.message : String(error)}`);
76
+ }
77
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
78
+ throw new Error("routing JSON must be an object");
79
+ }
80
+ return validateLlmMeshRoutingConfig(parsed);
81
+ }
82
+ export function describeLlmMeshRoutingConfig(config) {
83
+ const policy = effectiveRoutingPolicy(config);
84
+ return {
85
+ strategy: policy.strategy,
86
+ fallbackMode: policy.fallbackMode,
87
+ negativeCacheTtlMs: policy.negativeCacheTtlMs,
88
+ maxAttempts: policy.maxAttempts,
89
+ preferSameTransport: policy.preferSameTransport,
90
+ stickyAccount: policy.stickyAccount,
91
+ allowEquivalentModels: policy.allowEquivalentModels,
92
+ rotateEquivalentAccounts: policy.rotateEquivalentAccounts,
93
+ rules: policy.rules,
94
+ activeProfile: config?.activeProfile ?? null,
95
+ profiles: (config?.profiles ?? []).map(({ name, revision }) => ({ name, revision })),
96
+ explicit: config?.explicit ?? null,
97
+ councilRevision: effectiveRoutingCouncil(config).revision,
98
+ };
99
+ }
100
+ //# sourceMappingURL=llm-routing-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-routing-config.js","source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MAAM,CAAC,aAAa;QACnC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;QACnD,wBAAwB,EAAE,MAAM,CAAC,wBAAwB;QACzD,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,aAAa,EAAE,MAAM,EAAE,aAAa,IAAI,IAAI;QAC5C,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QACpF,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,IAAI;QAClC,eAAe,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC,QAAQ;KAC1D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,146 @@
1
+ import { type PromptDeliveryDeps } from "./prompt-delivery.js";
2
+ import { type SessionClass } from "./session-class.js";
3
+ export type SessionHostKind = "native" | "local-tmux";
4
+ /**
5
+ * Which host runs a NEW session's terminal. The native PTY host is the
6
+ * default; `--tmux` (per command) or H2A_SESSION_HOST=tmux (fleet-wide safety
7
+ * valve) selects tmux. Existing sessions are NEVER re-routed here — verbs that
8
+ * act on a recorded session honor its registry kind instead.
9
+ */
10
+ export declare function resolveSessionHostKind(opts: {
11
+ readonly tmux?: boolean;
12
+ }, env?: Readonly<Record<string, string | undefined>>): SessionHostKind;
13
+ /** Companion native session that hosts the h2a MCP sidecar for `name`. */
14
+ export declare function nativeSidecarName(name: string): string;
15
+ export type NativeSessionState = {
16
+ readonly id: string;
17
+ readonly pid: number;
18
+ readonly status: "running" | "stopping" | "exited";
19
+ readonly exit: {
20
+ readonly exitCode: number;
21
+ readonly signal?: number;
22
+ } | null;
23
+ /**
24
+ * Controller-visibility bit (never the controller's identity): true when an
25
+ * exclusive input controller is attached. OPTIONAL because an older running
26
+ * host does not report it — consumers must treat absence as an UNKNOWN view
27
+ * and fail closed (report, don't relaunch), never as "uncontrolled".
28
+ */
29
+ readonly controlled?: boolean;
30
+ };
31
+ export type NativeStartResult = {
32
+ readonly name: string;
33
+ readonly slug: string;
34
+ readonly pid: number;
35
+ };
36
+ /** node-pty loadable + containment binaries present. Pure preflight. */
37
+ export declare function nativeHostAvailable(): {
38
+ readonly ok: true;
39
+ } | {
40
+ readonly ok: false;
41
+ readonly reason: string;
42
+ };
43
+ /** Spawn-or-adopt the per-user host; returns its identity. */
44
+ export declare function ensureNativeHost(): {
45
+ hostPid: number;
46
+ socketPath: string;
47
+ };
48
+ export declare function listNativeSessions(): ReadonlyArray<NativeSessionState>;
49
+ /**
50
+ * 3-state session probe (F2). The lie this type removes: a failed `state` op
51
+ * used to flatten into `undefined`/`alive=false` — indistinguishable from a
52
+ * PROVEN dead/absent session, which let destructive acts read an op failure
53
+ * as a death certificate. The states:
54
+ * - "found": a reachable host answered with the session's state;
55
+ * - "absent": POSITIVE proof of absence — a reachable host does not know
56
+ * the session, or no host is listening at all (a PTY cannot outlive its
57
+ * host process, the same provable-death rule as a missing tmux server);
58
+ * - "unknown": the op failed (spawn error, timeout, protocol failure) —
59
+ * NEVER proof of death; destructive callers must fail closed on it.
60
+ * The classification happens IN-BAND in the `probe` op (op.ts), where the
61
+ * error codes live — never by parsing a generic failure on this side.
62
+ */
63
+ export type NativeStateProbe = {
64
+ readonly state: "found";
65
+ readonly session: NativeSessionState;
66
+ } | {
67
+ readonly state: "absent";
68
+ } | {
69
+ readonly state: "unknown";
70
+ readonly reason: string;
71
+ };
72
+ export declare function nativeSessionState(name: string): NativeStateProbe;
73
+ /**
74
+ * 3-state liveness (F2): `true` / `false` are POSITIVE verdicts; "unknown"
75
+ * is a probe failure that destructive paths must refuse on. Never throws.
76
+ */
77
+ export declare function nativeSessionLiveness(name: string): true | false | "unknown";
78
+ export declare function nativeSessionPid(name: string): number | undefined;
79
+ export type NativeLaunchMetadata = {
80
+ readonly label?: string;
81
+ readonly resumeId?: string;
82
+ readonly sessionClass?: SessionClass;
83
+ readonly terminateOnAgentExit?: boolean;
84
+ readonly refuseExisting?: boolean;
85
+ };
86
+ /**
87
+ * startLocalSession twin. Runs the SAME bash wrapper contract as the tmux
88
+ * path (LOCAL_WRAPPER drop-to-shell / STRUCTURED_LOCAL_WRAPPER exec-only), so
89
+ * agent exit semantics are identical across hosts.
90
+ */
91
+ export declare function startNativeSession(profile: string, command: string, cwd: string, args?: ReadonlyArray<string>, label?: string, metadata?: NativeLaunchMetadata): NativeStartResult;
92
+ /** sendKeysLiteral twin: raw keystrokes, no interpretation. */
93
+ export declare function nativeSendKeysLiteral(name: string, text: string): boolean;
94
+ /** paste-buffer -p twin: the text lands as ONE bracketed block. */
95
+ export declare function nativePasteBlock(name: string, text: string): boolean;
96
+ /** The Enter that submits a composed block. */
97
+ export declare function nativeSendEnter(name: string): boolean;
98
+ /**
99
+ * capturePane twin. IMPORTANT semantic difference: tmux returns the RENDERED
100
+ * screen; this returns the ANSI-stripped tail of the output stream. For probe
101
+ * matching (prompt echo, modal text) the stream tail carries the same visible
102
+ * text — full-screen-repaint TUIs re-emit their frame into the tail.
103
+ */
104
+ export declare function nativeCapture(name: string, bytes?: number): string | undefined;
105
+ /** kill-session twin: SIGTERM with SIGKILL escalation inside the op. */
106
+ export declare function killNativeSession(name: string): boolean;
107
+ /**
108
+ * Kill a session AND its h2a sidecar companion (the tmux twin gets this for
109
+ * free because the sidecar is a window inside the killed session).
110
+ */
111
+ export declare function killNativeSessionTree(name: string): boolean;
112
+ /**
113
+ * startHeadlessSession twin: run-once agent under HEADLESS_WRAPPER, writing
114
+ * result.json + output.log, session ends when the wrapper finishes. The
115
+ * prompt rides a 0600 file consumed and unlinked by the wrapper — identical
116
+ * contract to the tmux path.
117
+ */
118
+ export declare function startNativeHeadlessSession(profile: string, command: string, cwd: string, args: ReadonlyArray<string>, resultJson: string, outputLog: string, label: string, promptInput?: string, refuseExisting?: boolean, sessionClass?: SessionClass): NativeStartResult & {
119
+ promptFile?: string;
120
+ };
121
+ /**
122
+ * startH2aWindow twin: the h2a MCP sidecar runs in a COMPANION native session
123
+ * (`<name>.h2a`) instead of a tmux window. Lifecycle: killNativeSessionTree
124
+ * stops it with its main session.
125
+ */
126
+ export declare function startNativeH2aSidecar(name: string, cwd: string, h2aCommand: string, options?: {
127
+ verified?: boolean;
128
+ }): boolean;
129
+ /**
130
+ * Foreground interactive attach on the CURRENT terminal (tmux attach twin).
131
+ * Blocks until the session exits or the user detaches with Ctrl-\.
132
+ */
133
+ export declare function attachNativeSession(name: string): number;
134
+ /** clearPaneComposer twin: C-u wipes the composer line (best-effort). */
135
+ export declare function nativeClearComposer(name: string): boolean;
136
+ /** paneTreeCpuMs twin, keyed by session name instead of tmux pane. */
137
+ export declare function nativeTreeCpuMs(name: string): number | undefined;
138
+ /** paneWorkerPid twin: the pid actually doing the work under the wrapper. */
139
+ export declare function nativeWorkerPid(name: string): number | undefined;
140
+ /**
141
+ * PromptDeliveryDeps for a native session — deliverInitialPrompt() runs the
142
+ * SAME measured protocol as on tmux; only the transport differs. The "pane"
143
+ * key given to deliverInitialPrompt must be the session NAME.
144
+ */
145
+ export declare function nativePromptDeliveryDeps(sleep: (ms: number) => void): PromptDeliveryDeps;
146
+ //# sourceMappingURL=native-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-host.d.ts","sourceRoot":"","sources":["../src/native-host.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAa,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAI1E,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,YAAY,CAAC;AAEtD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,EACjC,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC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