@omnitype-code/adapter-sdk 2.0.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 (46) hide show
  1. package/README.md +163 -0
  2. package/dist/adapters/filesystem-only.d.ts +30 -0
  3. package/dist/adapters/filesystem-only.d.ts.map +1 -0
  4. package/dist/adapters/filesystem-only.js +115 -0
  5. package/dist/adapters/filesystem-only.js.map +1 -0
  6. package/dist/adapters/hook-poller.d.ts +40 -0
  7. package/dist/adapters/hook-poller.d.ts.map +1 -0
  8. package/dist/adapters/hook-poller.js +125 -0
  9. package/dist/adapters/hook-poller.js.map +1 -0
  10. package/dist/adapters/index.d.ts +34 -0
  11. package/dist/adapters/index.d.ts.map +1 -0
  12. package/dist/adapters/index.js +61 -0
  13. package/dist/adapters/index.js.map +1 -0
  14. package/dist/adapters/stdin-json-hook-tool.d.ts +87 -0
  15. package/dist/adapters/stdin-json-hook-tool.d.ts.map +1 -0
  16. package/dist/adapters/stdin-json-hook-tool.js +491 -0
  17. package/dist/adapters/stdin-json-hook-tool.js.map +1 -0
  18. package/dist/adapters/transcript-scavenger.d.ts +40 -0
  19. package/dist/adapters/transcript-scavenger.d.ts.map +1 -0
  20. package/dist/adapters/transcript-scavenger.js +569 -0
  21. package/dist/adapters/transcript-scavenger.js.map +1 -0
  22. package/dist/classifier.d.ts +132 -0
  23. package/dist/classifier.d.ts.map +1 -0
  24. package/dist/classifier.js +95 -0
  25. package/dist/classifier.js.map +1 -0
  26. package/dist/index.d.ts +8 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +8 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/loader.d.ts +51 -0
  31. package/dist/loader.d.ts.map +1 -0
  32. package/dist/loader.js +352 -0
  33. package/dist/loader.js.map +1 -0
  34. package/dist/manifest.d.ts +131 -0
  35. package/dist/manifest.d.ts.map +1 -0
  36. package/dist/manifest.js +12 -0
  37. package/dist/manifest.js.map +1 -0
  38. package/dist/normalize.d.ts +51 -0
  39. package/dist/normalize.d.ts.map +1 -0
  40. package/dist/normalize.js +122 -0
  41. package/dist/normalize.js.map +1 -0
  42. package/dist/tier.d.ts +12 -0
  43. package/dist/tier.d.ts.map +1 -0
  44. package/dist/tier.js +62 -0
  45. package/dist/tier.js.map +1 -0
  46. package/package.json +36 -0
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Classifier interface (Apache-2.0).
3
+ *
4
+ * The IP boundary. The open-source SDK ships:
5
+ * 1. The event schema, journal, materializer, transports
6
+ * 2. The `Classifier` interface (this file)
7
+ * 3. `BasicClassifier` — a minimal, auditable, deterministic fallback
8
+ * that uses only VSCode-native signals (undo, redo, paste, format-on-save)
9
+ * with zero heuristics. Anyone can ship a tool on top of this.
10
+ *
11
+ * The proprietary package (`@omnitype-code/classifier-pro`, BSL 1.1) ships:
12
+ * - Multi-line inline-completion accept heuristics
13
+ * - Active-AI-txn lookup (TxnBegin → file map with TTL)
14
+ * - Inline-completion command intercept table (across editor forks)
15
+ * - Formatter process detection ladder (40+ binaries)
16
+ * - Process-ancestry attestation for external writes
17
+ * - Tool/model detection ladder (transcript fingerprints, etc.)
18
+ * - Tier policy table (which signal combinations get T0/T1/T2/T3)
19
+ *
20
+ * Switch implementations with a single import. If `@omnitype-code/classifier-pro`
21
+ * is not installed, JournalBridge falls back to `BasicClassifier`.
22
+ */
23
+ export type ClassifierOrigin = 'ai' | 'user' | 'paste' | 'tool' | 'external' | 'unknown';
24
+ export type ClassifierIntent = 'type' | 'undo' | 'redo' | 'paste' | 'format' | 'edit-tool' | 'git-checkout' | 'unknown';
25
+ export type ClassifierTier = 'T0' | 'T1' | 'T2' | 'T3';
26
+ /** Editor-agnostic content change shape. Subset of vscode.TextDocumentChangeEvent. */
27
+ export interface ClassifierChange {
28
+ /** Was this change caused by an undo / redo command? */
29
+ reason: 'undo' | 'redo' | undefined;
30
+ /** Individual content edits in this change event. */
31
+ edits: ReadonlyArray<{
32
+ /** Number of bytes removed at this position. 0 == pure insertion. */
33
+ rangeLength: number;
34
+ /** Text inserted. Empty string == pure deletion. */
35
+ text: string;
36
+ }>;
37
+ }
38
+ export interface ClassifierContext {
39
+ /** Absolute file path (or VSCode URI string — the classifier doesn't care). */
40
+ fileId: string;
41
+ /** Monotonic timestamp (ms) for this event. Used to age signal markers. */
42
+ nowMs: number;
43
+ }
44
+ export interface ClassifierResult {
45
+ origin: ClassifierOrigin;
46
+ intent: ClassifierIntent;
47
+ tier: ClassifierTier;
48
+ /** 0.0–1.0. Used by the dashboard's reliability score. */
49
+ confidence: number;
50
+ /** Set when origin === 'ai' and we know the model. */
51
+ model?: string;
52
+ /** Set when origin === 'ai' and we know the tool. */
53
+ tool?: string;
54
+ /** Set when origin === 'ai' and we joined to an active session. */
55
+ sessionId?: string;
56
+ /** Set when origin === 'ai' and we joined to an active transaction. */
57
+ txnId?: string;
58
+ /** Human-readable reason — useful for `omnitype blame --explain`. */
59
+ basis?: string;
60
+ }
61
+ /**
62
+ * Signal markers the editor extension feeds into the classifier. The classifier
63
+ * is otherwise stateless from the consumer's perspective; markers age out
64
+ * internally (set-and-forget API).
65
+ */
66
+ export interface ClassifierMarkers {
67
+ /** A `clipboardPasteAction` fired in this file at this timestamp. */
68
+ recordPaste(fileId: string, ts: number): void;
69
+ /** An inline-suggestion accept command fired (Copilot, Cursor, …). */
70
+ recordInlineAccept(fileId: string, ts: number, tool: string): void;
71
+ /** A format-on-save participant is currently active for this file. */
72
+ setFormatSaveActive(fileId: string, active: boolean): void;
73
+ /** A keystroke-like edit happened (used to suppress no-keystroke heuristics). */
74
+ recordKeystroke(fileId: string, ts: number): void;
75
+ /** A TxnBegin from the hook-poller pinned an AI write to this file. */
76
+ registerActiveTxn(fileId: string, info: {
77
+ txnId: string;
78
+ sessionId: string;
79
+ model: string;
80
+ tool: string;
81
+ expiresAtMs: number;
82
+ }): void;
83
+ /** A SessionStarted/ModelClaim broadcast — used to back-fill model/tool. */
84
+ recordSession(sessionId: string, info: {
85
+ tool: string;
86
+ model: string;
87
+ }): void;
88
+ }
89
+ export interface Classifier extends ClassifierMarkers {
90
+ classify(change: ClassifierChange, ctx: ClassifierContext): ClassifierResult;
91
+ classifyExternal(ctx: ClassifierContext & {
92
+ isGitOperation: boolean;
93
+ }): ClassifierResult;
94
+ }
95
+ /**
96
+ * BasicClassifier — open-source, deterministic, no heuristics.
97
+ *
98
+ * Returns AI only when there is a positive active-AI-txn marker. Otherwise
99
+ * returns `user` for typing or `unknown` for external writes. This is the
100
+ * honest floor: anyone can audit it line-by-line in this file.
101
+ *
102
+ * If you want the calibrated tool/model/paste/format detection, install
103
+ * `@omnitype-code/classifier-pro` (BSL 1.1) and pass its constructor instead.
104
+ */
105
+ export declare class BasicClassifier implements Classifier {
106
+ private pastes;
107
+ private inlineAccepts;
108
+ private formatSave;
109
+ private keystrokes;
110
+ private activeTxns;
111
+ private sessions;
112
+ recordPaste(fileId: string, ts: number): void;
113
+ recordInlineAccept(fileId: string, ts: number, tool: string): void;
114
+ setFormatSaveActive(fileId: string, active: boolean): void;
115
+ recordKeystroke(fileId: string, ts: number): void;
116
+ registerActiveTxn(fileId: string, info: {
117
+ txnId: string;
118
+ sessionId: string;
119
+ model: string;
120
+ tool: string;
121
+ expiresAtMs: number;
122
+ }): void;
123
+ recordSession(sessionId: string, info: {
124
+ tool: string;
125
+ model: string;
126
+ }): void;
127
+ classify(change: ClassifierChange, ctx: ClassifierContext): ClassifierResult;
128
+ classifyExternal(ctx: ClassifierContext & {
129
+ isGitOperation: boolean;
130
+ }): ClassifierResult;
131
+ }
132
+ //# sourceMappingURL=classifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../src/classifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;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AAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAGlE,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAI1D,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IACjD,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;QACtC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;KACpF,GAAG,IAAI;IACR,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAI7E,QAAQ,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,iBAAiB,GAAG,gBAAgB;IA0B5E,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,GAAG;QAAE,cAAc,EAAE,OAAO,CAAA;KAAE,GAAG,gBAAgB;CAczF"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Classifier interface (Apache-2.0).
3
+ *
4
+ * The IP boundary. The open-source SDK ships:
5
+ * 1. The event schema, journal, materializer, transports
6
+ * 2. The `Classifier` interface (this file)
7
+ * 3. `BasicClassifier` — a minimal, auditable, deterministic fallback
8
+ * that uses only VSCode-native signals (undo, redo, paste, format-on-save)
9
+ * with zero heuristics. Anyone can ship a tool on top of this.
10
+ *
11
+ * The proprietary package (`@omnitype-code/classifier-pro`, BSL 1.1) ships:
12
+ * - Multi-line inline-completion accept heuristics
13
+ * - Active-AI-txn lookup (TxnBegin → file map with TTL)
14
+ * - Inline-completion command intercept table (across editor forks)
15
+ * - Formatter process detection ladder (40+ binaries)
16
+ * - Process-ancestry attestation for external writes
17
+ * - Tool/model detection ladder (transcript fingerprints, etc.)
18
+ * - Tier policy table (which signal combinations get T0/T1/T2/T3)
19
+ *
20
+ * Switch implementations with a single import. If `@omnitype-code/classifier-pro`
21
+ * is not installed, JournalBridge falls back to `BasicClassifier`.
22
+ */
23
+ /**
24
+ * BasicClassifier — open-source, deterministic, no heuristics.
25
+ *
26
+ * Returns AI only when there is a positive active-AI-txn marker. Otherwise
27
+ * returns `user` for typing or `unknown` for external writes. This is the
28
+ * honest floor: anyone can audit it line-by-line in this file.
29
+ *
30
+ * If you want the calibrated tool/model/paste/format detection, install
31
+ * `@omnitype-code/classifier-pro` (BSL 1.1) and pass its constructor instead.
32
+ */
33
+ export class BasicClassifier {
34
+ pastes = new Map();
35
+ inlineAccepts = new Map();
36
+ formatSave = new Set();
37
+ keystrokes = new Map();
38
+ activeTxns = new Map();
39
+ sessions = new Map();
40
+ recordPaste(fileId, ts) { this.pastes.set(fileId, ts); }
41
+ recordInlineAccept(fileId, ts, tool) {
42
+ this.inlineAccepts.set(fileId, { ts, tool });
43
+ }
44
+ setFormatSaveActive(fileId, active) {
45
+ if (active)
46
+ this.formatSave.add(fileId);
47
+ else
48
+ this.formatSave.delete(fileId);
49
+ }
50
+ recordKeystroke(fileId, ts) { this.keystrokes.set(fileId, ts); }
51
+ registerActiveTxn(fileId, info) { this.activeTxns.set(fileId, info); }
52
+ recordSession(sessionId, info) {
53
+ this.sessions.set(sessionId, info);
54
+ }
55
+ classify(change, ctx) {
56
+ if (change.reason === 'undo') {
57
+ return { origin: 'user', intent: 'undo', tier: 'T1', confidence: 1.0, basis: 'undo-command' };
58
+ }
59
+ if (change.reason === 'redo') {
60
+ return { origin: 'user', intent: 'redo', tier: 'T1', confidence: 1.0, basis: 'redo-command' };
61
+ }
62
+ const txn = this.activeTxns.get(ctx.fileId);
63
+ if (txn && txn.expiresAtMs > ctx.nowMs) {
64
+ return {
65
+ origin: 'ai', intent: 'edit-tool', tier: 'T1', confidence: 0.95,
66
+ sessionId: txn.sessionId, model: txn.model, tool: txn.tool, txnId: txn.txnId,
67
+ basis: 'active-txn',
68
+ };
69
+ }
70
+ if (this.formatSave.has(ctx.fileId)) {
71
+ return { origin: 'tool', intent: 'format', tier: 'T1', confidence: 1.0, basis: 'format-on-save' };
72
+ }
73
+ const pasteTs = this.pastes.get(ctx.fileId);
74
+ if (pasteTs !== undefined && ctx.nowMs - pasteTs <= 50) {
75
+ this.pastes.delete(ctx.fileId);
76
+ return { origin: 'paste', intent: 'paste', tier: 'T1', confidence: 0.95, basis: 'clipboard' };
77
+ }
78
+ return { origin: 'user', intent: 'type', tier: 'T1', confidence: 0.9, basis: 'default' };
79
+ }
80
+ classifyExternal(ctx) {
81
+ if (ctx.isGitOperation) {
82
+ return { origin: 'external', intent: 'git-checkout', tier: 'T1', confidence: 0.9, basis: 'git-busy' };
83
+ }
84
+ const txn = this.activeTxns.get(ctx.fileId);
85
+ if (txn && txn.expiresAtMs > ctx.nowMs) {
86
+ return {
87
+ origin: 'ai', intent: 'edit-tool', tier: 'T2', confidence: 0.8,
88
+ sessionId: txn.sessionId, model: txn.model, tool: txn.tool, txnId: txn.txnId,
89
+ basis: 'active-txn',
90
+ };
91
+ }
92
+ return { origin: 'unknown', intent: 'unknown', tier: 'T3', confidence: 0.0, basis: 'no-evidence' };
93
+ }
94
+ }
95
+ //# sourceMappingURL=classifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classifier.js","sourceRoot":"","sources":["../src/classifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA4EH;;;;;;;;;GASG;AACH,MAAM,OAAO,eAAe;IAClB,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACnC,aAAa,GAAG,IAAI,GAAG,EAAwC,CAAC;IAChE,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,UAAU,GAAG,IAAI,GAAG,EAExB,CAAC;IACG,QAAQ,GAA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O,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAC3F,CAAC;IAED,gBAAgB,CAAC,GAAoD;QACnE,IAAI,GAAG,CAAC,cAAc,EAAE,CAAC;YACvB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;QACxG,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,GAAG,IAAI,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC;YACvC,OAAO;gBACL,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG;gBAC9D,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK;gBAC5E,KAAK,EAAE,YAAY;aACpB,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IACrG,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ export * from './manifest.js';
2
+ export * from './tier.js';
3
+ export { AdapterLoader } from './loader.js';
4
+ export type { EmitFn } from './loader.js';
5
+ export * from './normalize.js';
6
+ export * from './adapters/index.js';
7
+ export * from './classifier.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ // Public API for @omnitype-code/adapter-sdk
2
+ export * from './manifest.js';
3
+ export * from './tier.js';
4
+ export { AdapterLoader } from './loader.js';
5
+ export * from './normalize.js';
6
+ export * from './adapters/index.js';
7
+ export * from './classifier.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Adapter loader — daemon-side.
3
+ *
4
+ * Responsibilities:
5
+ * 1. Discover adapters from the catalog directories.
6
+ * 2. Load and validate manifests.
7
+ * 3. Spawn co-process adapters, manage their lifecycle.
8
+ * 4. Validate incoming events (HMAC, capability gating, seq monotonicity).
9
+ * 5. Forward valid events to the Journal via the provided emit callback.
10
+ *
11
+ * Each co-process adapter communicates over stdin/stdout (stdin-json protocol).
12
+ * The loader sends ControlMsg, receives EventMsg | ReplyMsg.
13
+ */
14
+ import type { AdapterManifest } from './manifest.js';
15
+ import type { Actor, EventBody, Tier } from '@omnitype-code/journal';
16
+ export type ManifestTrustMode = 'strict' | 'permissive';
17
+ export interface EmitFn {
18
+ (actor: Actor, body: EventBody, tier: Tier, adapterId: string): void;
19
+ }
20
+ export declare class AdapterLoader {
21
+ private instances;
22
+ private emit;
23
+ private installKey;
24
+ private workspace;
25
+ private trustMode;
26
+ constructor(emit: EmitFn, installKey: Buffer, workspace: string, trustMode?: ManifestTrustMode);
27
+ loadAll(): void;
28
+ loadAdapter(manifest: AdapterManifest, adapterDir: string): void;
29
+ private spawnAdapter;
30
+ private sendControl;
31
+ private handleAdapterLine;
32
+ private handleReply;
33
+ private handleEventMsg;
34
+ private isEventAllowed;
35
+ private tierForInstance;
36
+ /** Built-in adapters call this instead of going through IPC */
37
+ emitDirect(actor: Actor, body: EventBody, tier: Tier, adapterId: string): void;
38
+ /**
39
+ * Build a sandboxed command for spawning adapter co-processes. (Day 17: §3.2)
40
+ * Returns [executable, args] ready to pass to spawn().
41
+ */
42
+ private buildSandboxedCommand;
43
+ private deriveSubkey;
44
+ stopAll(): void;
45
+ getStatus(): Array<{
46
+ id: string;
47
+ healthy: boolean;
48
+ mode: string;
49
+ }>;
50
+ }
51
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,KAAK,EAAE,eAAe,EAA6B,MAAM,eAAe,CAAC;AAChF,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAUrE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAsBxD,MAAM,WAAW,MAAM;IACrB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACtE;AAqBD,qBAAa,aAAa;IACxB,OAAO,CAAC,SAAS,CAAsC;IACvD,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,UAA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