@amodalai/runtime 0.3.69 → 0.3.71
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/dist/src/auth/__fixtures__/custom-strategy.d.ts +8 -0
- package/dist/src/auth/__fixtures__/custom-strategy.js +27 -0
- package/dist/src/auth/__fixtures__/custom-strategy.js.map +1 -0
- package/dist/src/auth/compose.d.ts +55 -0
- package/dist/src/auth/compose.js +142 -0
- package/dist/src/auth/compose.js.map +1 -0
- package/dist/src/auth/compose.test.d.ts +6 -0
- package/dist/src/auth/compose.test.js +159 -0
- package/dist/src/auth/compose.test.js.map +1 -0
- package/dist/src/auth/config.d.ts +261 -0
- package/dist/src/auth/config.js +107 -0
- package/dist/src/auth/config.js.map +1 -0
- package/dist/src/auth/config.test.d.ts +6 -0
- package/dist/src/auth/config.test.js +85 -0
- package/dist/src/auth/config.test.js.map +1 -0
- package/dist/src/auth/factory.d.ts +19 -0
- package/dist/src/auth/factory.js +57 -0
- package/dist/src/auth/factory.js.map +1 -0
- package/dist/src/auth/factory.test.d.ts +6 -0
- package/dist/src/auth/factory.test.js +60 -0
- package/dist/src/auth/factory.test.js.map +1 -0
- package/dist/src/auth/index.d.ts +48 -0
- package/dist/src/auth/index.js +19 -0
- package/dist/src/auth/index.js.map +1 -0
- package/dist/src/auth/strategies/amodal.d.ts +36 -0
- package/dist/src/auth/strategies/amodal.js +28 -0
- package/dist/src/auth/strategies/amodal.js.map +1 -0
- package/dist/src/auth/strategies/api-key.d.ts +41 -0
- package/dist/src/auth/strategies/api-key.js +63 -0
- package/dist/src/auth/strategies/api-key.js.map +1 -0
- package/dist/src/auth/strategies/auth-modes.integration.test.d.ts +6 -0
- package/dist/src/auth/strategies/auth-modes.integration.test.js +363 -0
- package/dist/src/auth/strategies/auth-modes.integration.test.js.map +1 -0
- package/dist/src/auth/strategies/cookie.d.ts +41 -0
- package/dist/src/auth/strategies/cookie.js +84 -0
- package/dist/src/auth/strategies/cookie.js.map +1 -0
- package/dist/src/auth/strategies/custom-loader.d.ts +17 -0
- package/dist/src/auth/strategies/custom-loader.js +37 -0
- package/dist/src/auth/strategies/custom-loader.js.map +1 -0
- package/dist/src/auth/strategies/header.d.ts +35 -0
- package/dist/src/auth/strategies/header.js +42 -0
- package/dist/src/auth/strategies/header.js.map +1 -0
- package/dist/src/auth/strategies/jwks.d.ts +38 -0
- package/dist/src/auth/strategies/jwks.js +86 -0
- package/dist/src/auth/strategies/jwks.js.map +1 -0
- package/dist/src/auth/strategies/jwt-secret.d.ts +25 -0
- package/dist/src/auth/strategies/jwt-secret.js +82 -0
- package/dist/src/auth/strategies/jwt-secret.js.map +1 -0
- package/dist/src/auth/strategies/jwt-secret.test.d.ts +6 -0
- package/dist/src/auth/strategies/jwt-secret.test.js +75 -0
- package/dist/src/auth/strategies/jwt-secret.test.js.map +1 -0
- package/dist/src/auth/strategies/none.d.ts +37 -0
- package/dist/src/auth/strategies/none.js +31 -0
- package/dist/src/auth/strategies/none.js.map +1 -0
- package/dist/src/auth/strategies/oidc.d.ts +48 -0
- package/dist/src/auth/strategies/oidc.integration.test.d.ts +6 -0
- package/dist/src/auth/strategies/oidc.integration.test.js +290 -0
- package/dist/src/auth/strategies/oidc.integration.test.js.map +1 -0
- package/dist/src/auth/strategies/oidc.js +284 -0
- package/dist/src/auth/strategies/oidc.js.map +1 -0
- package/dist/src/auth/strategies/oidc.test.d.ts +6 -0
- package/dist/src/auth/strategies/oidc.test.js +111 -0
- package/dist/src/auth/strategies/oidc.test.js.map +1 -0
- package/dist/src/auth/strategies/strategies.test.d.ts +6 -0
- package/dist/src/auth/strategies/strategies.test.js +190 -0
- package/dist/src/auth/strategies/strategies.test.js.map +1 -0
- package/dist/src/auth/types.d.ts +95 -0
- package/dist/src/auth/types.js +7 -0
- package/dist/src/auth/types.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/routes/session-resolver.d.ts +10 -10
- package/dist/src/routes/session-resolver.js +33 -17
- package/dist/src/routes/session-resolver.js.map +1 -1
- package/dist/src/routes/session-resolver.test.js +121 -80
- package/dist/src/routes/session-resolver.test.js.map +1 -1
- package/dist/src/session/drizzle-session-store.d.ts +8 -12
- package/dist/src/session/drizzle-session-store.js +38 -37
- package/dist/src/session/drizzle-session-store.js.map +1 -1
- package/dist/src/session/store.d.ts +5 -5
- package/dist/src/session/store.js +54 -38
- package/dist/src/session/store.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -4
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Auth strategy interface — modeled on Rails' Warden.
|
|
8
|
+
*
|
|
9
|
+
* Each strategy is two methods:
|
|
10
|
+
*
|
|
11
|
+
* - `valid(req)`: cheap, synchronous check — does this strategy apply to
|
|
12
|
+
* the request at all? (E.g. JwksStrategy returns false when there's no
|
|
13
|
+
* Bearer header; ApiKeyStrategy returns false when the token doesn't
|
|
14
|
+
* start with `ak_`.) Strategies that return false are skipped without
|
|
15
|
+
* running their `authenticate` step.
|
|
16
|
+
*
|
|
17
|
+
* - `authenticate(req)`: the slow path. Verify the token / call the IdP /
|
|
18
|
+
* read the cookie. Returns a discriminated union:
|
|
19
|
+
*
|
|
20
|
+
* { kind: 'authenticated', session } ← chain stops, request proceeds
|
|
21
|
+
* { kind: 'rejected', reason } ← chain stops, request 401s
|
|
22
|
+
*
|
|
23
|
+
* No exceptions for control flow. Plugin authors can't accidentally
|
|
24
|
+
* bypass auth by returning the wrong sentinel.
|
|
25
|
+
*
|
|
26
|
+
* Strategies that own a login flow (OAuth dance, magic link, etc.)
|
|
27
|
+
* implement the optional `routes()` method to mount their own routes
|
|
28
|
+
* onto the auth controller's router (`/auth/<strategy>/start`,
|
|
29
|
+
* `/auth/<strategy>/callback`, etc.).
|
|
30
|
+
*
|
|
31
|
+
* Order = priority. Compose strategies into a chain via `authenticate(...)`.
|
|
32
|
+
* The first strategy whose `valid(req)` returns true and whose
|
|
33
|
+
* `authenticate(req)` returns 'authenticated' wins. No merging across
|
|
34
|
+
* strategies.
|
|
35
|
+
*/
|
|
36
|
+
import type { Request, Router } from 'express';
|
|
37
|
+
/**
|
|
38
|
+
* The authenticated identity attached to `res.locals.session` by the
|
|
39
|
+
* auth middleware. Every strategy populates `user.id` (required); other
|
|
40
|
+
* fields are optional or strategy-specific.
|
|
41
|
+
*/
|
|
42
|
+
export interface AuthSession {
|
|
43
|
+
user: {
|
|
44
|
+
/** Stable identifier for the principal. Required. */
|
|
45
|
+
id: string;
|
|
46
|
+
email?: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
};
|
|
49
|
+
/** Strategy that authenticated the request (`'jwks'`, `'api-key'`, etc.). */
|
|
50
|
+
method: string;
|
|
51
|
+
/**
|
|
52
|
+
* Stable identifier for the agent this session is scoped to, when the
|
|
53
|
+
* strategy carries it (e.g. platform JWTs include `agent_id`). Optional.
|
|
54
|
+
*/
|
|
55
|
+
agentId?: string;
|
|
56
|
+
/**
|
|
57
|
+
* End-user scope id — used for per-user data isolation when the agent
|
|
58
|
+
* has end-user auth configured. Optional.
|
|
59
|
+
*/
|
|
60
|
+
scopeId?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Raw provider claims, opaque to the runtime. Strategies that have
|
|
63
|
+
* additional payload (OIDC `groups`, custom JWT fields) put it here.
|
|
64
|
+
*/
|
|
65
|
+
claims?: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
export type AuthResult = {
|
|
68
|
+
kind: 'authenticated';
|
|
69
|
+
session: AuthSession;
|
|
70
|
+
} | {
|
|
71
|
+
kind: 'rejected';
|
|
72
|
+
reason: string;
|
|
73
|
+
};
|
|
74
|
+
export interface AuthStrategy {
|
|
75
|
+
/** Stable identifier (`'jwks'`, `'oidc'`, `'api-key'`, etc.). */
|
|
76
|
+
readonly name: string;
|
|
77
|
+
/**
|
|
78
|
+
* Cheap, synchronous check: does this strategy apply to the request?
|
|
79
|
+
* Strategies must return false promptly when they don't recognize the
|
|
80
|
+
* incoming credential shape so the chain falls through to the next
|
|
81
|
+
* strategy without paying the `authenticate` cost.
|
|
82
|
+
*/
|
|
83
|
+
valid(req: Request): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Slow path: actually verify the credential. Called only when
|
|
86
|
+
* `valid(req)` returned true. Must return either an authenticated
|
|
87
|
+
* session or a rejection reason — never throw for control flow.
|
|
88
|
+
*/
|
|
89
|
+
authenticate(req: Request): Promise<AuthResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Optional: mount strategy-specific routes (login redirects, OAuth
|
|
92
|
+
* callbacks, magic-link handlers, etc.) onto the auth router.
|
|
93
|
+
*/
|
|
94
|
+
routes?(): Router;
|
|
95
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/auth/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export { createStoresRouter } from './agent/routes/stores.js';
|
|
|
27
27
|
export type { StoreRouterOptions } from './agent/routes/stores.js';
|
|
28
28
|
export { getAuthContext } from './middleware/auth.js';
|
|
29
29
|
export type { AuthContext } from './middleware/auth.js';
|
|
30
|
+
export { authenticate, authRouter, getSession, JwksAuthStrategy, ApiKeyAuthStrategy, HeaderAuthStrategy, NoneAuthStrategy, CookieSessionStrategy, JwtSecretAuthStrategy, OidcAuthStrategy, AmodalAuthStrategy, AuthConfigSchema, parseAuthConfig, createAuthStrategy, loadCustomStrategy, } from './auth/index.js';
|
|
31
|
+
export type { AuthStrategy, AuthResult, AuthSession, AuthLogEvent, AuthenticateOptions, JwksAuthStrategyOptions, ApiKeyAuthStrategyOptions, ApiKeyValidationResult, HeaderAuthStrategyOptions, NoneAuthStrategyOptions, CookieSessionStrategyOptions, JwtSecretAuthStrategyOptions, OidcAuthStrategyOptions, AmodalAuthStrategyOptions, AuthConfig, NoneAuthConfig, JwtSecretAuthConfig, OidcAuthConfig, HeaderAuthConfig, CustomAuthConfig, AmodalAuthConfig, } from './auth/index.js';
|
|
30
32
|
export { commitSetup, composeAmodalJson, SetupNotReadyError, } from './setup/commit-setup.js';
|
|
31
33
|
export type { CommitSetupOptions, CommitSetupResult, CommitSetupSuccess, CommitSetupNotReady, CommitSetupNoState, } from './setup/commit-setup.js';
|
|
32
34
|
export { resolveScope } from './scope.js';
|
package/dist/src/index.js
CHANGED
|
@@ -33,6 +33,8 @@ export { createTaskRouter } from './agent/routes/task.js';
|
|
|
33
33
|
export { createStoresRouter } from './agent/routes/stores.js';
|
|
34
34
|
// Auth types (middleware implementation provided by hosting layer)
|
|
35
35
|
export { getAuthContext } from './middleware/auth.js';
|
|
36
|
+
// Pluggable auth — Warden-shape primitive layer.
|
|
37
|
+
export { authenticate, authRouter, getSession, JwksAuthStrategy, ApiKeyAuthStrategy, HeaderAuthStrategy, NoneAuthStrategy, CookieSessionStrategy, JwtSecretAuthStrategy, OidcAuthStrategy, AmodalAuthStrategy, AuthConfigSchema, parseAuthConfig, createAuthStrategy, loadCustomStrategy, } from './auth/index.js';
|
|
36
38
|
// Setup-completion primitive (Phase E.2). Used by both the agent
|
|
37
39
|
// `request_complete_setup` / `force_complete_setup` tools and the
|
|
38
40
|
// Studio "Finish setup" button via /api/admin-chat/commit-setup.
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,YAAY,EAAuB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,MAAM,CAAC,MAAM,cAAc,GAAG,OA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C,CAAC;AACL,CAAC"}
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
* resolution, session lookup/resume/create into a single function so
|
|
11
11
|
* chat-stream, ai-stream, and chat routes share the same flow.
|
|
12
12
|
*/
|
|
13
|
-
import type { AgentBundle, CustomToolExecutor, StoreBackend } from
|
|
14
|
-
import type { McpManager, FieldScrubber } from
|
|
15
|
-
import type { NodePgDatabase } from
|
|
16
|
-
import type { StandaloneSessionManager } from
|
|
17
|
-
import type { Session } from
|
|
18
|
-
import type { ToolContext } from
|
|
19
|
-
import type { SessionComponents, SessionType } from
|
|
20
|
-
import type { AuthContext } from
|
|
21
|
-
import type { Logger } from
|
|
22
|
-
import type { CredentialResolver } from
|
|
13
|
+
import type { AgentBundle, CustomToolExecutor, StoreBackend } from "@amodalai/types";
|
|
14
|
+
import type { McpManager, FieldScrubber } from "@amodalai/core";
|
|
15
|
+
import type { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
16
|
+
import type { StandaloneSessionManager } from "../session/manager.js";
|
|
17
|
+
import type { Session } from "../session/types.js";
|
|
18
|
+
import type { ToolContext } from "../tools/types.js";
|
|
19
|
+
import type { SessionComponents, SessionType } from "../session/session-builder.js";
|
|
20
|
+
import type { AuthContext } from "../middleware/auth.js";
|
|
21
|
+
import type { Logger } from "../logger.js";
|
|
22
|
+
import type { CredentialResolver } from "../credentials.js";
|
|
23
23
|
/** How the route resolves an AgentBundle for a given request. */
|
|
24
24
|
export interface BundleResolver {
|
|
25
25
|
/** Static bundle for local dev (used when no deploy_id is provided). */
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Copyright 2026 Amodal Labs, Inc.
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
import { buildSessionComponents } from
|
|
7
|
-
import { loadIntents } from
|
|
8
|
-
import { loadMemoryContent } from
|
|
9
|
-
import { SessionError } from
|
|
6
|
+
import { buildSessionComponents } from "../session/session-builder.js";
|
|
7
|
+
import { loadIntents } from "../intent/index.js";
|
|
8
|
+
import { loadMemoryContent } from "../tools/memory-tool.js";
|
|
9
|
+
import { SessionError } from "../errors.js";
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
11
|
// Bundle resolution
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
@@ -30,17 +30,20 @@ async function buildComponents(bundle, shared, opts) {
|
|
|
30
30
|
let memoryContent;
|
|
31
31
|
const memoryDb = shared.memoryDb;
|
|
32
32
|
if (bundle.config.memory?.enabled && memoryDb) {
|
|
33
|
-
memoryContent = await loadMemoryContent(memoryDb, shared.appId ??
|
|
34
|
-
shared.logger.info(
|
|
33
|
+
memoryContent = await loadMemoryContent(memoryDb, shared.appId ?? "local", opts.scopeId ?? "");
|
|
34
|
+
shared.logger.info("memory_loaded", {
|
|
35
|
+
contentLength: memoryContent.length,
|
|
36
|
+
scopeId: opts.scopeId ?? "",
|
|
37
|
+
});
|
|
35
38
|
}
|
|
36
39
|
const credentialResolver = shared.buildCredentialResolver?.(opts.scopeId);
|
|
37
40
|
// Load deterministic intents from <repoPath>/intents/. Empty array
|
|
38
41
|
// when the repo doesn't have one (most agents). Loaded async here
|
|
39
42
|
// because esbuild compile + dynamic import are async; the rest of
|
|
40
43
|
// session building stays sync.
|
|
41
|
-
const intents = bundle.source ===
|
|
44
|
+
const intents = bundle.source === "local" && bundle.origin
|
|
42
45
|
? await loadIntents(bundle.origin).catch((err) => {
|
|
43
|
-
shared.logger.warn(
|
|
46
|
+
shared.logger.warn("intent_load_failed", {
|
|
44
47
|
repoPath: bundle.origin,
|
|
45
48
|
error: err instanceof Error ? err.message : String(err),
|
|
46
49
|
});
|
|
@@ -85,12 +88,15 @@ async function buildComponents(bundle, shared, opts) {
|
|
|
85
88
|
*/
|
|
86
89
|
export async function resolveSession(sessionId, opts) {
|
|
87
90
|
const { sessionManager, bundleResolver, shared, auth } = opts;
|
|
88
|
-
const scopeId = opts.scopeId ??
|
|
91
|
+
const scopeId = opts.scopeId ?? "";
|
|
89
92
|
// 1. In-memory lookup (existing live session)
|
|
90
93
|
if (sessionId) {
|
|
91
94
|
const existing = sessionManager.get(sessionId);
|
|
92
95
|
if (existing && existing.toolContextFactory) {
|
|
93
|
-
return {
|
|
96
|
+
return {
|
|
97
|
+
session: existing,
|
|
98
|
+
toolContextFactory: existing.toolContextFactory,
|
|
99
|
+
};
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
// Resolve bundle once — shared between resume and create paths
|
|
@@ -106,7 +112,10 @@ export async function resolveSession(sessionId, opts) {
|
|
|
106
112
|
// regardless of sessionId. Cache the first result and apply it to
|
|
107
113
|
// subsequent components by copying the enhanced systemPrompt.
|
|
108
114
|
if (!hookResult) {
|
|
109
|
-
hookResult = await opts.onSessionBuild(components, {
|
|
115
|
+
hookResult = await opts.onSessionBuild(components, {
|
|
116
|
+
auth,
|
|
117
|
+
bundle: bundle,
|
|
118
|
+
});
|
|
110
119
|
return hookResult;
|
|
111
120
|
}
|
|
112
121
|
// Reuse the enhanced prompt from the first call
|
|
@@ -118,10 +127,13 @@ export async function resolveSession(sessionId, opts) {
|
|
|
118
127
|
if (!resolvedSessionId && scopeId && bundle) {
|
|
119
128
|
const sessionStore = sessionManager.getStore();
|
|
120
129
|
if (sessionStore?.findByScopeId) {
|
|
121
|
-
const found = await sessionStore.findByScopeId(scopeId);
|
|
130
|
+
const found = await sessionStore.findByScopeId(scopeId, shared.appId);
|
|
122
131
|
if (found) {
|
|
123
132
|
resolvedSessionId = found;
|
|
124
|
-
shared.logger.info(
|
|
133
|
+
shared.logger.info("session_resolved_by_scope", {
|
|
134
|
+
scopeId,
|
|
135
|
+
sessionId: found,
|
|
136
|
+
});
|
|
125
137
|
}
|
|
126
138
|
}
|
|
127
139
|
}
|
|
@@ -142,18 +154,22 @@ export async function resolveSession(sessionId, opts) {
|
|
|
142
154
|
permissionChecker: components.permissionChecker,
|
|
143
155
|
systemPrompt: components.systemPrompt,
|
|
144
156
|
toolContextFactory: components.toolContextFactory,
|
|
157
|
+
appId: shared.appId,
|
|
145
158
|
scopeId,
|
|
146
159
|
...(metadata ? { metadata } : {}),
|
|
147
160
|
});
|
|
148
161
|
if (resumed) {
|
|
149
|
-
return {
|
|
162
|
+
return {
|
|
163
|
+
session: resumed,
|
|
164
|
+
toolContextFactory: components.toolContextFactory,
|
|
165
|
+
};
|
|
150
166
|
}
|
|
151
167
|
}
|
|
152
168
|
// 3. Create new session
|
|
153
169
|
if (!bundle) {
|
|
154
|
-
throw new SessionError(
|
|
155
|
-
sessionId: resolvedSessionId ??
|
|
156
|
-
context: { operation:
|
|
170
|
+
throw new SessionError("No bundle available — provide a deploy_id or configure a static bundle", {
|
|
171
|
+
sessionId: resolvedSessionId ?? "new",
|
|
172
|
+
context: { operation: "resolveSession", deployId: opts.deployId },
|
|
157
173
|
});
|
|
158
174
|
}
|
|
159
175
|
const rawComponents = await buildComponents(bundle, shared, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-resolver.js","sourceRoot":"","sources":["../../../src/routes/session-resolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"session-resolver.js","sourceRoot":"","sources":["../../../src/routes/session-resolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA8E5C,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAwB,EACxB,QAAiB,EACjB,KAAc;IAEd,IAAI,QAAQ,IAAI,QAAQ,CAAC,cAAc,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC,cAAc,CAAC,QAAQ,EA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