copilotkit 2.0.4 → 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilotkit",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "copilotkit": "./index.js"
package/src/config.d.ts CHANGED
@@ -15,6 +15,18 @@ export declare function setOpsApiUrl(url: string): void;
15
15
  export declare function getOpsFrontendUrl(): string;
16
16
  /** Override the ops frontend URL at runtime. */
17
17
  export declare function setOpsFrontendUrl(url: string): void;
18
+ /**
19
+ * Resolves the telemetry sink ingest endpoint URL.
20
+ *
21
+ * Honors the `COPILOTKIT_TELEMETRY_ENDPOINT` env var when set, otherwise falls
22
+ * back to the build-time default baked in via esbuild `define`. When neither
23
+ * is available (unbundled execution like `tsx` or unit tests), returns the
24
+ * production endpoint as a final fallback — the caller is expected to also
25
+ * gate sends on dev-mode detection via {@link getBuildInfo}.
26
+ *
27
+ * @returns Absolute URL of the telemetry ingest endpoint.
28
+ */
29
+ export declare function getTelemetryEndpointUrl(): string;
18
30
  /**
19
31
  * Build identity for this CLI binary.
20
32
  *
@@ -22,6 +34,9 @@ export declare function setOpsFrontendUrl(url: string): void;
22
34
  * - `buildNumber` — GitHub Actions run id of the build, or `"dev"` for local builds.
23
35
  * Maps back to a workflow run at github.com/<repo>/actions/runs/<buildNumber>.
24
36
  * - `commitSha` — git commit the binary was built from, or `"dev"` for local builds.
37
+ *
38
+ * Falls back to `"dev"` when running outside an esbuild bundle (e.g., `tsx`
39
+ * or vitest), so callers do not crash with a `ReferenceError`.
25
40
  */
26
41
  export declare function getBuildInfo(): {
27
42
  version: string;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../apps/cli/src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,kDAAkD;AAClD,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,2CAA2C;AAC3C,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAMA"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../apps/cli/src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH,kDAAkD;AAClD,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,2CAA2C;AAC3C,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAQhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,IAAI;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAMA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../apps/cli/src/index.ts"],"names":[],"mappings":";AAoOA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAIzE;AAgPD;;GAEG;AACH,wBAAsB,IAAI,CAAC,OAAO,WAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiEzE;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAMT"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../apps/cli/src/index.ts"],"names":[],"mappings":";AAgPA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAIzE;AA8QD;;GAEG;AACH,wBAAsB,IAAI,CAAC,OAAO,WAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoFzE;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAMT"}
@@ -0,0 +1,102 @@
1
+ /** Bounded enum of `command` values emitted on telemetry events. */
2
+ export type TelemetryCommand = "init" | "login" | "logout" | "license" | "whoami" | "docs" | "help" | "version" | "unknown";
3
+ /** Bounded enum of `outcome` values emitted on telemetry events. */
4
+ export type TelemetryOutcome = "started" | "succeeded" | "failed";
5
+ /** Bounded enum of `error_code` values emitted on failed events. */
6
+ export type TelemetryErrorCode = "validation" | "auth" | "network" | "timeout" | "prerequisite_missing" | "template_fetch" | "git" | "filesystem" | "user_aborted" | "unknown";
7
+ /**
8
+ * Minimal session payload read from the auth store when building base
9
+ * properties. Decouples this module from the full {@link StoredAuth} shape.
10
+ */
11
+ export interface TelemetryAuthSnapshot {
12
+ userId: string;
13
+ email: string;
14
+ }
15
+ /**
16
+ * Build identity payload mirroring the shape of {@link getBuildInfo}.
17
+ */
18
+ export interface TelemetryBuildInfo {
19
+ version: string;
20
+ buildNumber: string;
21
+ commitSha: string;
22
+ }
23
+ /** Injectable dependencies for {@link buildBaseProperties}. */
24
+ export interface BaseDeps {
25
+ installationId: string;
26
+ sessionId: string;
27
+ buildInfo: TelemetryBuildInfo;
28
+ auth: TelemetryAuthSnapshot | null;
29
+ env: NodeJS.ProcessEnv;
30
+ nodeVersion: string;
31
+ platform: NodeJS.Platform | string;
32
+ arch: string;
33
+ }
34
+ /** Output shape of {@link buildBaseProperties}. */
35
+ export interface BaseProperties {
36
+ installation_id: string;
37
+ session_id: string;
38
+ cli_version: string;
39
+ cli_build_number: string;
40
+ cli_commit_sha: string;
41
+ node_version: string;
42
+ platform: string;
43
+ arch: string;
44
+ is_ci: boolean;
45
+ is_authenticated: boolean;
46
+ clerk_user_id?: string;
47
+ email_hash?: string;
48
+ }
49
+ /**
50
+ * Detects whether the current process is running in a CI environment.
51
+ *
52
+ * @param env - Process environment variables.
53
+ * @returns `true` when any known CI indicator env var is set to a non-empty value.
54
+ */
55
+ export declare function detectCi(env: NodeJS.ProcessEnv): boolean;
56
+ /**
57
+ * Truncated SHA-256 hash of an email for PII-free correlation.
58
+ *
59
+ * Matches the wire format used by ops-api at
60
+ * `apps/ops-api/src/services/telemetry-sink.service.ts:68-70`.
61
+ *
62
+ * @param email - The email to hash.
63
+ * @returns A 16-character lowercase hex string.
64
+ */
65
+ export declare function hashEmail(email: string): string;
66
+ /**
67
+ * Builds the base property set emitted on every telemetry event.
68
+ *
69
+ * @param deps - Build identity, auth snapshot, env, and platform info.
70
+ * @returns The base properties object.
71
+ */
72
+ export declare function buildBaseProperties(deps: BaseDeps): BaseProperties;
73
+ /**
74
+ * Flag shape for {@link subcommandForInit}.
75
+ */
76
+ export interface InitSubcommandFlags {
77
+ intelligence?: boolean;
78
+ framework?: string;
79
+ }
80
+ /**
81
+ * Derives the bounded `subcommand` property for the init/create command.
82
+ *
83
+ * Returns `"interactive"` when neither branching flag is set, `"intelligence"`
84
+ * for the intelligence branch, the framework value when `--framework` is set
85
+ * to a known {@link AgentFramework}, and `"invalid"` when an unknown framework
86
+ * value is supplied (to avoid leaking arbitrary user-typed strings).
87
+ *
88
+ * @param flags - The parsed init flags.
89
+ * @returns The bounded subcommand value.
90
+ */
91
+ export declare function subcommandForInit(flags: InitSubcommandFlags): string;
92
+ /**
93
+ * Classifies an unknown error value into a bounded {@link TelemetryErrorCode}.
94
+ *
95
+ * Inspects `Error.name`, status codes on `ApiClientError`-shaped errors, and
96
+ * `AbortError` for timeouts. Never returns or emits the raw error message.
97
+ *
98
+ * @param err - The thrown value.
99
+ * @returns A bounded error code suitable for the `error_code` property.
100
+ */
101
+ export declare function classifyError(err: unknown): TelemetryErrorCode;
102
+ //# sourceMappingURL=event-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-properties.d.ts","sourceRoot":"","sources":["../../../../../../apps/cli/src/services/telemetry/event-properties.ts"],"names":[],"mappings":"AAGA,oEAAoE;AACpE,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,OAAO,GACP,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,MAAM,GACN,MAAM,GACN,SAAS,GACT,SAAS,CAAC;AAEd,oEAAoE;AACpE,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAElE,oEAAoE;AACpE,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,MAAM,GACN,SAAS,GACT,SAAS,GACT,sBAAsB,GACtB,gBAAgB,GAChB,KAAK,GACL,YAAY,GACZ,cAAc,GACd,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,+DAA+D;AAC/D,MAAM,WAAW,QAAQ;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,IAAI,EAAE,qBAAqB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
2
+ /**
3
+ * Lazily constructs and returns the process-wide telemetry service.
4
+ *
5
+ * Generates a fresh `session_id` on first call, resolves opt-out state, and
6
+ * persists the anonymous `installation_id` if not already present.
7
+ *
8
+ * @returns The singleton telemetry service.
9
+ */
10
+ export declare function getTelemetry(): TelemetryService;
11
+ /**
12
+ * Records a telemetry event through the process-wide singleton.
13
+ *
14
+ * @param event - The event payload to send.
15
+ */
16
+ export declare function recordTelemetryEvent(event: TelemetryEvent): void;
17
+ /**
18
+ * Awaits in-flight telemetry sends up to a bounded timeout. No-op when the
19
+ * singleton has not been initialised.
20
+ *
21
+ * @param timeoutMs - Optional override for the flush ceiling.
22
+ */
23
+ export declare function flushTelemetry(timeoutMs?: number): Promise<void>;
24
+ /**
25
+ * Flushes telemetry then exits the process with the given code. Use this in
26
+ * place of bare `process.exit(N)` calls anywhere an event may have just been
27
+ * recorded.
28
+ *
29
+ * @param code - The exit code to use.
30
+ */
31
+ export declare function exitWithFlush(code: number): Promise<never>;
32
+ /**
33
+ * Wraps an async command runner with a `started` event on entry and a
34
+ * `succeeded` or `failed` event on exit. The wrapped function's return value
35
+ * and rejections pass through unchanged.
36
+ *
37
+ * @param base - The event properties common to both started and finished
38
+ * events (typically `{ command, subcommand?, scope? }`).
39
+ * @param fn - The command runner to wrap.
40
+ * @returns The result of `fn`.
41
+ */
42
+ export declare function withTelemetry<T>(base: Omit<TelemetryEventProperties, "outcome" | "duration_ms" | "error_code">, fn: () => Promise<T>): Promise<T>;
43
+ /**
44
+ * Test-only helper that drops the singleton so each test sees a fresh state.
45
+ * Not part of the public production surface.
46
+ */
47
+ export declare function __resetTelemetryForTests(): void;
48
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../apps/cli/src/services/telemetry/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAE7B,KAAK,gBAAgB,EACtB,MAAM,wBAAwB,CAAC;AA2BhC;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,gBAAgB,CA4B/C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAEhE;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,SAAS,GAAE,MAAiC,GAC3C,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAGhE;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,CAAC,EACnC,IAAI,EAAE,IAAI,CAAC,wBAAwB,EAAE,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC,EAC9E,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAoBZ;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
@@ -0,0 +1,22 @@
1
+ /** Config-store key under which the persistent installation id is stored. */
2
+ export declare const INSTALLATION_ID_KEY = "telemetry.installationId";
3
+ /** Minimal config-store surface used to persist the installation id. */
4
+ export interface ConfigStoreReadWrite {
5
+ get<T>(key: string): T | undefined;
6
+ set(key: string, value: unknown): void;
7
+ }
8
+ /** Injectable dependencies for {@link getOrCreateInstallationId}. */
9
+ export interface InstallationIdDeps {
10
+ configStore: ConfigStoreReadWrite;
11
+ /** Injectable UUID generator for deterministic tests. Defaults to crypto. */
12
+ generateId?: () => string;
13
+ }
14
+ /**
15
+ * Reads the persistent anonymous installation id, generating and persisting
16
+ * a fresh UUID v4 on first call.
17
+ *
18
+ * @param deps - Injectable config store and id generator.
19
+ * @returns The installation id as a string.
20
+ */
21
+ export declare function getOrCreateInstallationId(deps: InstallationIdDeps): string;
22
+ //# sourceMappingURL=installation-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installation-id.d.ts","sourceRoot":"","sources":["../../../../../../apps/cli/src/services/telemetry/installation-id.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,6BAA6B,CAAC;AAE9D,wEAAwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CACxC;AAED,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,oBAAoB,CAAC;IAClC,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAS1E"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Resolves whether telemetry should be disabled for this process.
3
+ *
4
+ * Honors, in order of precedence:
5
+ * 1. The `DO_NOT_TRACK` env var (consoledonottrack.com standard).
6
+ * 2. The `COPILOTKIT_TELEMETRY_DISABLED` env var.
7
+ * 3. A persisted `telemetry.optOut` boolean in {@link ConfigStoreReader}.
8
+ *
9
+ * Env values are matched case-insensitively against `1 | true | yes | on`.
10
+ * Empty or unset values are treated as not-set.
11
+ */
12
+ /** Minimal config-store surface used to read the persisted opt-out flag. */
13
+ export interface ConfigStoreReader {
14
+ get<T>(key: string): T | undefined;
15
+ }
16
+ /**
17
+ * Resolves the effective opt-out state for the current process.
18
+ *
19
+ * @param env - Process environment variables (defaults to `process.env`).
20
+ * @param configStore - Persistent config store with `telemetry.optOut`.
21
+ * @returns `true` when telemetry should be disabled.
22
+ */
23
+ export declare function resolveOptOut(env: NodeJS.ProcessEnv, configStore: ConfigStoreReader): boolean;
24
+ //# sourceMappingURL=opt-out.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opt-out.d.ts","sourceRoot":"","sources":["../../../../../../apps/cli/src/services/telemetry/opt-out.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,4EAA4E;AAC5E,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;CACpC;AAaD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAIT"}
@@ -0,0 +1,74 @@
1
+ import type { BaseProperties, TelemetryCommand, TelemetryErrorCode, TelemetryOutcome } from "./event-properties.js";
2
+ /** Wire-shape event name; one allowlist entry covers every CLI event. */
3
+ export declare const CLI_TELEMETRY_EVENT_NAME: "cli.command.invoked";
4
+ /** Per-event property keys that may appear in addition to base properties. */
5
+ export interface TelemetryEventProperties {
6
+ command: TelemetryCommand;
7
+ outcome: TelemetryOutcome;
8
+ subcommand?: string;
9
+ scope?: "org" | "user";
10
+ duration_ms?: number;
11
+ error_code?: TelemetryErrorCode;
12
+ }
13
+ /** Full event payload accepted by {@link TelemetryService.recordEvent}. */
14
+ export interface TelemetryEvent {
15
+ properties: TelemetryEventProperties;
16
+ }
17
+ /** Maximum concurrent in-flight requests; excess events are dropped. */
18
+ export declare const MAX_INFLIGHT = 32;
19
+ /** Per-request hard timeout for the outbound POST. */
20
+ export declare const DEFAULT_PER_REQUEST_TIMEOUT_MS = 2000;
21
+ /** Default flush timeout used by {@link TelemetryService.flush}. */
22
+ export declare const DEFAULT_FLUSH_TIMEOUT_MS = 1500;
23
+ /**
24
+ * Minimal logger surface used by the telemetry service. Mirrors the subset of
25
+ * the CLI's `writeCliLog` signature so callers can pass a thin wrapper.
26
+ */
27
+ export interface TelemetryLogger {
28
+ debug: (payload: Record<string, unknown>) => void;
29
+ warn: (payload: Record<string, unknown>) => void;
30
+ error: (payload: Record<string, unknown>) => void;
31
+ }
32
+ /** Injectable dependencies for {@link createTelemetryService}. */
33
+ export interface TelemetryServiceDeps {
34
+ /** Master on/off; when `false`, `recordEvent` is a synchronous no-op. */
35
+ enabled: boolean;
36
+ /** Absolute URL of the telemetry ingest endpoint. */
37
+ endpointUrl: string;
38
+ /** Producer of the base properties merged into every event. */
39
+ buildBaseProperties: () => BaseProperties;
40
+ /** Structured logger for diagnostic events. */
41
+ logger: TelemetryLogger;
42
+ /** Injectable fetch for tests. Defaults to global `fetch`. */
43
+ fetch?: typeof fetch;
44
+ /** Per-request hard timeout. Defaults to {@link DEFAULT_PER_REQUEST_TIMEOUT_MS}. */
45
+ perRequestTimeoutMs?: number;
46
+ /** Cap on in-flight requests. Defaults to {@link MAX_INFLIGHT}. */
47
+ maxInFlight?: number;
48
+ }
49
+ /** Public surface of the telemetry service. */
50
+ export interface TelemetryService {
51
+ /**
52
+ * Synchronously schedules a telemetry event for fire-and-forget delivery.
53
+ * Returns `void` and never throws — callers must not `await` this.
54
+ */
55
+ recordEvent(event: TelemetryEvent): void;
56
+ /**
57
+ * Awaits all in-flight requests up to a bounded timeout, then resolves.
58
+ * Safe to call multiple times; resolves immediately when the queue is empty.
59
+ */
60
+ flush(timeoutMs?: number): Promise<void>;
61
+ }
62
+ /**
63
+ * Constructs a CLI telemetry service.
64
+ *
65
+ * Sends `{ event: "cli.command.invoked", properties }` to the configured
66
+ * endpoint as fire-and-forget POSTs, with a bounded in-flight queue and a
67
+ * per-request `AbortController`. All failures are swallowed and logged via
68
+ * the injected `logger`.
69
+ *
70
+ * @param deps - Injectable configuration and collaborators.
71
+ * @returns The telemetry service instance.
72
+ */
73
+ export declare function createTelemetryService(deps: TelemetryServiceDeps): TelemetryService;
74
+ //# sourceMappingURL=telemetry.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.service.d.ts","sourceRoot":"","sources":["../../../../../../apps/cli/src/services/telemetry/telemetry.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,g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