@mastra/platform-workspace 0.0.0-esbuild-bundle-worker-20260807173433

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 ADDED
@@ -0,0 +1,115 @@
1
+ # @mastra/platform-workspace
2
+
3
+ Mastra Platform workspace provider. Gives agents environment-scoped sandbox execution and bucket-backed filesystem access through the Mastra Platform workspace proxy.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/platform-workspace
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ All options can be passed to the constructor or read from environment variables:
14
+
15
+ | Option | Env var | Required |
16
+ | --------------- | ------------------------------ | ---------------- |
17
+ | `accessToken` | `MASTRA_PLATFORM_ACCESS_TOKEN` | Yes |
18
+ | `projectId` | `MASTRA_PROJECT_ID` | Yes |
19
+ | `environmentId` | `MASTRA_ENVIRONMENT_ID` | Yes (sandbox) |
20
+ | `bucketName` | `MASTRA_PLATFORM_BUCKET_NAME` | Yes (filesystem) |
21
+
22
+ The proxy URL defaults to `https://workspaces.mastra.ai` and can be overridden with the `MASTRA_WORKSPACE_PROXY_URL` env var (useful for staging).
23
+
24
+ Requests to the proxy are authenticated with `Authorization: Bearer <accessToken>`.
25
+
26
+ ## Usage
27
+
28
+ ```typescript
29
+ import { Agent } from '@mastra/core/agent';
30
+ import { Workspace } from '@mastra/core/workspace';
31
+ import { PlatformFilesystem, PlatformSandbox } from '@mastra/platform-workspace';
32
+
33
+ const workspace = new Workspace({
34
+ filesystem: new PlatformFilesystem({
35
+ // accessToken, projectId, bucketName all fall back to env
36
+ }),
37
+ sandbox: new PlatformSandbox({
38
+ // accessToken, projectId, environmentId all fall back to env
39
+ idleTimeoutMinutes: 30,
40
+ networkIsolation: 'ISOLATED',
41
+ }),
42
+ });
43
+
44
+ const agent = new Agent({
45
+ name: 'code-analyzer',
46
+ model: 'anthropic/claude-sonnet-4-5',
47
+ workspace,
48
+ });
49
+ ```
50
+
51
+ ## Filesystem
52
+
53
+ `PlatformFilesystem` implements the Mastra filesystem interface against a workspace bucket. Object keys are percent-encoded per segment, so filenames with `?`, `#`, `%`, `&`, `+`, or spaces are preserved end-to-end.
54
+
55
+ ```typescript
56
+ const fs = new PlatformFilesystem({ bucketName: 'reports' });
57
+
58
+ await fs.writeFile('/analyses/repo.md', markdown);
59
+ const content = await fs.readFile('/analyses/repo.md');
60
+ const entries = await fs.readdir('/analyses');
61
+ await fs.moveFile('/analyses/repo.md', '/analyses/repo-final.md');
62
+ ```
63
+
64
+ Pass `readOnly: true` to mount the bucket read-only. Mutating calls will throw `WorkspaceReadOnlyError`.
65
+
66
+ ## Sandbox
67
+
68
+ `PlatformSandbox` executes commands inside a Railway-backed sandbox tied to a Platform environment. Sessions boot from a pre-built recipe checkpoint (Python 3, Node 22, TypeScript/tsx, common build tooling).
69
+
70
+ ```typescript
71
+ const sandbox = new PlatformSandbox({ environmentId: 'env_abc' });
72
+
73
+ const result = await sandbox.executeCommand('python', ['analyze.py'], {
74
+ timeout: 30_000,
75
+ env: { INPUT: 'repo' },
76
+ });
77
+
78
+ console.log(result.stdout);
79
+ ```
80
+
81
+ Pass an existing `sandboxId` to reattach to a live sandbox instead of creating a new one.
82
+
83
+ ## Errors
84
+
85
+ Failures from the proxy raise `PlatformApiError`. Structured `{ error: { message, type } }` payloads from the proxy are parsed into `.code` (machine kind) and `.proxyMessage` (human string); the raw response body stays available on `.body`:
86
+
87
+ ```typescript
88
+ import { PlatformApiError } from '@mastra/platform-workspace';
89
+
90
+ try {
91
+ await fs.readFile('/missing.txt');
92
+ } catch (err) {
93
+ if (err instanceof PlatformApiError) {
94
+ if (err.code === 'not_found') {
95
+ // handle missing file
96
+ } else if (err.code === 'authentication_error') {
97
+ // refresh token
98
+ }
99
+ console.error(err.status, err.code, err.proxyMessage, err.body);
100
+ }
101
+ }
102
+ ```
103
+
104
+ `code` / `proxyMessage` are `undefined` when the proxy returns a non-JSON body (e.g. an HTML 502 from a load balancer).
105
+
106
+ Filesystem-specific errors (`FileNotFoundError`, `FileExistsError`, `WorkspaceReadOnlyError`) are re-exported from `@mastra/core`.
107
+
108
+ ### Sandbox exec errors
109
+
110
+ `PlatformSandbox.executeCommand` runs over the direct-exec data plane (a WebSocket straight to the Railway tcp-proxy) and can throw two typed errors on unrecoverable failure:
111
+
112
+ - `SandboxDestroyedError` — the platform returned 410 for `/exec-lease`, meaning the sandbox has been destroyed. The cached sandbox id and lease are cleared, so a reused `PlatformSandbox` instance will re-provision on the next call. Fleet-level code that owns a binding store should catch this, clear the stale sandbox id, and reprovision + replay.
113
+ - `SandboxExecTransportError` — both the initial WebSocket attempt and the built-in retry closed without an `exit` frame against a live sandbox. Carries `{ opened, closeCode, closeReason, wsEndpoint }` diagnostics plus `sandboxId`, `command`, and `attempts` so upstream logs / alerts can distinguish "the Railway data plane is broken" from "your command failed".
114
+
115
+ `PlatformApiError` (with status 404 / 500 / 501 on `/exec-lease`) can also bubble up from `executeCommand` — those are configuration or platform errors, not "reprovision me" signals, and are propagated as-is.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * In-process `sandboxId → instanceUrl` registry populated by
3
+ * {@link PlatformSandbox.start} from the `instanceUrl` field workspace-proxy
4
+ * includes on create + get responses, and consumed by
5
+ * {@link PlatformSandbox.executeCommand} on the private-network fast path.
6
+ *
7
+ * The registry lives in the same Node process as the `PlatformSandbox`
8
+ * consumer — for shipyard, that is the Mastra runtime deployed from
9
+ * `mastracode/web`. There is no receiver route and no cross-service dance;
10
+ * the address is just a field copied from a response the runtime already
11
+ * receives.
12
+ *
13
+ * State intentionally does not persist:
14
+ *
15
+ * - The IPv6 rotates on every sandbox recreate.
16
+ * - The URL has no meaning after the sandbox is destroyed.
17
+ * - The live sandbox binding, session context, and lease all die with the
18
+ * runtime process; the address dying with them is correct.
19
+ * - The proxy's `environment_sandboxes.instance_url` column is the durable
20
+ * source of truth — a runtime restart re-populates the registry on the
21
+ * next `start()` / reattach from the proxy's response.
22
+ */
23
+ import type { SandboxAddressRegistry } from './sandbox.js';
24
+ /**
25
+ * Concrete in-process {@link SandboxAddressRegistry}. Backed by a `Map`; no
26
+ * eviction policy, no TTL — entries live until an observed transport failure
27
+ * calls `delete`, until the sandbox is explicitly destroyed, or until the
28
+ * process exits.
29
+ */
30
+ export declare class InProcessSandboxAddressRegistry implements SandboxAddressRegistry {
31
+ #private;
32
+ get(sandboxId: string): string | undefined;
33
+ /**
34
+ * Populate or overwrite the address for a sandbox. Called by
35
+ * {@link PlatformSandbox.start} on every fresh provision and every reattach;
36
+ * overwriting is intentional so a re-provision with a fresh IPv6 heals the
37
+ * map without a branch.
38
+ */
39
+ set(sandboxId: string, instanceUrl: string): void;
40
+ delete(sandboxId: string): void;
41
+ /**
42
+ * Test-only introspection. Not part of {@link SandboxAddressRegistry} —
43
+ * production callers must not read the registry as a whole.
44
+ */
45
+ get size(): number;
46
+ }
47
+ //# sourceMappingURL=address-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-registry.d.ts","sourceRoot":"","sources":["../src/address-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D;;;;;GAKG;AACH,qBAAa,+BAAgC,YAAW,sBAAsB;;IAG5E,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI1C;;;;;OAKG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAIjD,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/B;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
@@ -0,0 +1,44 @@
1
+ export interface PlatformClientOptions {
2
+ accessToken?: string;
3
+ projectId?: string;
4
+ fetch?: typeof fetch;
5
+ }
6
+ export interface PlatformRequestOptions extends RequestInit {
7
+ query?: Record<string, string | number | boolean | undefined>;
8
+ }
9
+ export declare function requireOption(value: string | undefined, name: string): string;
10
+ export declare function resolvePlatformOptions(options: PlatformClientOptions): {
11
+ accessToken: string;
12
+ projectId: string;
13
+ proxyUrl: string;
14
+ fetch: typeof fetch;
15
+ };
16
+ /**
17
+ * Structured error shape returned by the workspace proxy. All routes emit
18
+ * `{ error: { message, type } }` on failure — see servers/workspace-proxy in
19
+ * the Platform repo. Kept as a wire-level type so callers can switch on
20
+ * `error.code` without re-parsing `error.body`.
21
+ */
22
+ export interface PlatformProxyError {
23
+ message: string;
24
+ /** Machine-readable error kind, e.g. `not_found`, `invalid_request`, `authentication_error`. */
25
+ type: string;
26
+ }
27
+ export declare class PlatformApiError extends Error {
28
+ readonly status: number;
29
+ readonly body: string;
30
+ /** Machine-readable proxy error kind (e.g. `not_found`), when the response body matches `{ error: { message, type } }`. */
31
+ readonly code: string | undefined;
32
+ /** Human-readable proxy error message, when the response body matches `{ error: { message, type } }`. */
33
+ readonly proxyMessage: string | undefined;
34
+ constructor(status: number, body: string);
35
+ }
36
+ export declare class PlatformClient {
37
+ readonly accessToken: string;
38
+ readonly projectId: string;
39
+ readonly proxyUrl: string;
40
+ readonly fetch: typeof fetch;
41
+ constructor(options: PlatformClientOptions);
42
+ request(path: string, options?: PlatformRequestOptions): Promise<Response>;
43
+ }
44
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC/D;AAWD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7E;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,qBAAqB;;;;;EAOpE;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,IAAI,EAAE,MAAM,CAAC;CACd;AAkBD,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2HAA2H;IAC3H,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,yGAAyG;IACzG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE9B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAUzC;AAED,qBAAa,cAAc;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC;gBAEjB,OAAO,EAAE,qBAAqB;IAQpC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,QAAQ,CAAC;CAoBrF"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Direct exec client — opens Railway's tcp-proxy exec WebSocket directly using
3
+ * a short-lived JWT minted by the workspace proxy's exec-lease endpoint. This
4
+ * removes the platform data plane from the exec stdout/stderr path entirely
5
+ * (see `docs/factory/direct-sandbox-connection.md` in the Platform repo),
6
+ * cutting payload-scaled Cloud Run egress and RTT for commands like
7
+ * `pnpm install` that stream tens of MB of output.
8
+ *
9
+ * The frame protocol below mirrors `connectExecWs()` in `railway@3.5.5`
10
+ * (`workspaces/railway/node_modules/railway/dist/index.js`). The `railway`
11
+ * SDK's version is pinned on both sides (platform + here); a version bump
12
+ * signals the protocol may have drifted and this module must be revisited.
13
+ */
14
+ /**
15
+ * Minimal WebSocket surface this module depends on. Matches both the browser
16
+ * `WebSocket` global and Node 22+'s built-in `WebSocket`. Extracted so tests
17
+ * can inject a fake without pulling in `ws` or jsdom.
18
+ */
19
+ export interface DirectExecWebSocket {
20
+ binaryType: 'blob' | 'arraybuffer';
21
+ onopen: ((event: unknown) => void) | null;
22
+ onmessage: ((event: {
23
+ data: unknown;
24
+ }) => void) | null;
25
+ onclose: ((event: {
26
+ code: number;
27
+ reason: string;
28
+ }) => void) | null;
29
+ onerror: ((event: unknown) => void) | null;
30
+ send(data: string): void;
31
+ close(code?: number, reason?: string): void;
32
+ }
33
+ /**
34
+ * Factory that opens a WebSocket to `endpoint` with the given subprotocols.
35
+ * Defaults to the global `WebSocket` when omitted, which works on Node 22+
36
+ * (the package's minimum) and in the browser. Tests inject a fake here.
37
+ */
38
+ export type DirectExecWebSocketFactory = (endpoint: string, subprotocols: string[]) => DirectExecWebSocket;
39
+ /** Lease payload returned by `POST /v1/projects/:projectId/sandbox/:sandboxId/exec-lease`. */
40
+ export interface ExecLease {
41
+ jwt: string;
42
+ wsEndpoint: string;
43
+ subprotocol: string;
44
+ /** ISO-8601 UTC. Null when the provider issues a JWT without an `exp` claim. */
45
+ expiresAt: string | null;
46
+ }
47
+ /** Inputs to a direct exec invocation. Mirrors the shape of the `/exec` route body. */
48
+ export interface DirectExecOptions {
49
+ command: string;
50
+ cwd?: string;
51
+ env?: Record<string, string>;
52
+ /**
53
+ * Wall-clock cap for the exec. When elapsed, we close the socket and
54
+ * return `{timedOut: true, exitCode: 124}` matching the semantics of the
55
+ * proxy's `/exec` route.
56
+ */
57
+ timeoutMs?: number;
58
+ onStdout?: (chunk: string) => void;
59
+ onStderr?: (chunk: string) => void;
60
+ /** Injected for tests. Defaults to `globalThis.WebSocket`. */
61
+ webSocketFactory?: DirectExecWebSocketFactory;
62
+ }
63
+ /**
64
+ * Result of a direct exec. Shape matches the workspace-proxy `/exec` response
65
+ * so the caller (`PlatformSandbox.executeCommand`) can hand it back with no
66
+ * translation.
67
+ *
68
+ * `exitCode` is `null` when the socket closed without an `exit` frame AND the
69
+ * exec did not time out (rare — usually a mid-stream network drop). Callers
70
+ * currently coerce `null` to `1` upstream; kept nullable here to preserve the
71
+ * distinction for future observability.
72
+ */
73
+ export interface DirectExecResult {
74
+ exitCode: number | null;
75
+ stdout: string;
76
+ stderr: string;
77
+ truncated: boolean;
78
+ timedOut: boolean;
79
+ /**
80
+ * WebSocket close metadata. Populated on any close (normal or transport
81
+ * failure). `opened` distinguishes handshake failures (never opened) from
82
+ * mid-stream drops. Callers use this for diagnostic logging; not part of
83
+ * the CommandResult contract.
84
+ */
85
+ closeCode?: number;
86
+ closeReason?: string;
87
+ opened?: boolean;
88
+ }
89
+ /**
90
+ * Open the provider exec WebSocket using `lease`, run `command`, and resolve
91
+ * with the accumulated stdout/stderr + exit code. See the module docstring
92
+ * for the wire protocol reference.
93
+ *
94
+ * The client sends `stdin_close` immediately after `init_exec`, matching the
95
+ * SDK's own one-shot exec behavior — we never stream stdin from the caller.
96
+ */
97
+ export declare function execViaLease(lease: ExecLease, options: DirectExecOptions): Promise<DirectExecResult>;
98
+ //# sourceMappingURL=direct-exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direct-exec.d.ts","sourceRoot":"","sources":["../src/direct-exec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAeH;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,GAAG,aAAa,CAAC;IACnC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1C,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAA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G,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAcD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyJpG"}
@@ -0,0 +1,62 @@
1
+ import { Buffer } from 'node:buffer';
2
+ import type { RequestContext } from '@mastra/core/request-context';
3
+ import type { CopyOptions, FileContent, FileEntry, FileStat, FilesystemIcon, FilesystemInfo, InstructionsOption, ListOptions, MastraFilesystemOptions, ProviderStatus, ReadOptions, RemoveOptions, WriteOptions } from '@mastra/core/workspace';
4
+ import { MastraFilesystem } from '@mastra/core/workspace';
5
+ import type { PlatformClientOptions } from './client.js';
6
+ export interface PlatformFilesystemOptions extends PlatformClientOptions, MastraFilesystemOptions {
7
+ id?: string;
8
+ bucketName?: string;
9
+ readOnly?: boolean;
10
+ displayName?: string;
11
+ icon?: FilesystemIcon;
12
+ description?: string;
13
+ instructions?: InstructionsOption;
14
+ }
15
+ export declare class PlatformFilesystem extends MastraFilesystem {
16
+ readonly id: string;
17
+ readonly name = "PlatformFilesystem";
18
+ readonly provider = "platform";
19
+ readonly readOnly?: boolean;
20
+ readonly displayName?: string;
21
+ readonly icon: FilesystemIcon;
22
+ readonly description?: string;
23
+ status: ProviderStatus;
24
+ private readonly _client;
25
+ private readonly _bucketName;
26
+ private readonly _instructionsOverride?;
27
+ constructor(options?: PlatformFilesystemOptions);
28
+ private generateId;
29
+ readFile(path: string, options?: ReadOptions): Promise<string | Buffer>;
30
+ writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void>;
31
+ /**
32
+ * Append bytes to a file.
33
+ *
34
+ * **Not atomic.** Object storage behind the workspace proxy has no native
35
+ * append or compare-and-swap primitive, so this implementation is a
36
+ * read-modify-write: it reads the current contents, concatenates the new
37
+ * bytes, and PUTs the whole object back. Concurrent `appendFile` calls to
38
+ * the same path can overwrite each other's writes ("last write wins").
39
+ * Use `writeFile` with distinct keys for concurrent writers.
40
+ */
41
+ appendFile(path: string, content: FileContent): Promise<void>;
42
+ deleteFile(path: string, options?: RemoveOptions): Promise<void>;
43
+ copyFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
44
+ moveFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
45
+ mkdir(path: string, _options?: {
46
+ recursive?: boolean;
47
+ }): Promise<void>;
48
+ rmdir(path: string, options?: RemoveOptions): Promise<void>;
49
+ readdir(path: string, options?: ListOptions): Promise<FileEntry[]>;
50
+ exists(path: string): Promise<boolean>;
51
+ stat(path: string): Promise<FileStat>;
52
+ realpath(path: string): Promise<string>;
53
+ getInstructions(opts?: {
54
+ requestContext?: RequestContext;
55
+ }): string;
56
+ getInfo(): FilesystemInfo<{
57
+ bucketName: string;
58
+ displayName?: string;
59
+ description?: string;
60
+ }>;
61
+ }
62
+ //# sourceMappingURL=filesystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACR,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,aAAa,EACb,YAAY,EACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAsC,gBAAgB,EAA0B,MAAM,wBAAwB,CAAC;AACtH,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