@chucky.cloud/sdk 0.2.5 → 0.3.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/README.md +6 -1
- package/dist/browser.cjs +1361 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +1 -0
- package/dist/browser.d.ts +1 -8
- package/dist/browser.js +1278 -11
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +1361 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1973 -0
- package/dist/index.d.ts +1953 -48
- package/dist/index.js +1278 -72
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +1361 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +1 -0
- package/dist/node.d.ts +1 -8
- package/dist/node.js +1278 -10
- package/dist/node.js.map +1 -1
- package/package.json +31 -9
- package/dist/browser.d.ts.map +0 -1
- package/dist/client/ChuckyClient.d.ts +0 -141
- package/dist/client/ChuckyClient.d.ts.map +0 -1
- package/dist/client/ChuckyClient.js +0 -209
- package/dist/client/ChuckyClient.js.map +0 -1
- package/dist/client/Session.d.ts +0 -167
- package/dist/client/Session.d.ts.map +0 -1
- package/dist/client/Session.js +0 -392
- package/dist/client/Session.js.map +0 -1
- package/dist/client/index.d.ts +0 -10
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -9
- package/dist/client/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/node.d.ts.map +0 -1
- package/dist/tools/McpServer.d.ts +0 -117
- package/dist/tools/McpServer.d.ts.map +0 -1
- package/dist/tools/McpServer.js +0 -142
- package/dist/tools/McpServer.js.map +0 -1
- package/dist/tools/index.d.ts +0 -9
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -8
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/tool.d.ts +0 -146
- package/dist/tools/tool.d.ts.map +0 -1
- package/dist/tools/tool.js +0 -232
- package/dist/tools/tool.js.map +0 -1
- package/dist/transport/Transport.d.ts +0 -82
- package/dist/transport/Transport.d.ts.map +0 -1
- package/dist/transport/Transport.js +0 -47
- package/dist/transport/Transport.js.map +0 -1
- package/dist/transport/WebSocketTransport.d.ts +0 -78
- package/dist/transport/WebSocketTransport.d.ts.map +0 -1
- package/dist/transport/WebSocketTransport.js +0 -258
- package/dist/transport/WebSocketTransport.js.map +0 -1
- package/dist/transport/index.d.ts +0 -10
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js +0 -8
- package/dist/transport/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -12
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -8
- package/dist/types/index.js.map +0 -1
- package/dist/types/messages.d.ts +0 -327
- package/dist/types/messages.d.ts.map +0 -1
- package/dist/types/messages.js +0 -133
- package/dist/types/messages.js.map +0 -1
- package/dist/types/options.d.ts +0 -212
- package/dist/types/options.d.ts.map +0 -1
- package/dist/types/options.js +0 -8
- package/dist/types/options.js.map +0 -1
- package/dist/types/results.d.ts +0 -186
- package/dist/types/results.d.ts.map +0 -1
- package/dist/types/results.js +0 -7
- package/dist/types/results.js.map +0 -1
- package/dist/types/token.d.ts +0 -124
- package/dist/types/token.d.ts.map +0 -1
- package/dist/types/token.js +0 -7
- package/dist/types/token.js.map +0 -1
- package/dist/types/tools.d.ts +0 -234
- package/dist/types/tools.d.ts.map +0 -1
- package/dist/types/tools.js +0 -31
- package/dist/types/tools.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -80
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -158
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -8
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/token.d.ts +0 -104
- package/dist/utils/token.d.ts.map +0 -1
- package/dist/utils/token.js +0 -209
- package/dist/utils/token.js.map +0 -1
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chucky Client
|
|
3
|
-
*
|
|
4
|
-
* Main entry point for the Chucky SDK.
|
|
5
|
-
* Provides methods to create sessions and execute prompts.
|
|
6
|
-
* Matches the official Claude Agent SDK V2 interface.
|
|
7
|
-
*/
|
|
8
|
-
import { WebSocketTransport } from '../transport/WebSocketTransport.js';
|
|
9
|
-
import { Session, getAssistantText, getResultText } from './Session.js';
|
|
10
|
-
/**
|
|
11
|
-
* Default base URL for the Chucky service
|
|
12
|
-
*/
|
|
13
|
-
const DEFAULT_BASE_URL = 'wss://conjure.chucky.cloud/ws';
|
|
14
|
-
/**
|
|
15
|
-
* Chucky client for interacting with the sandbox service
|
|
16
|
-
*
|
|
17
|
-
* Matches the official Claude Agent SDK V2 interface.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* import { ChuckyClient } from '@chucky.cloud/sdk';
|
|
22
|
-
*
|
|
23
|
-
* const client = new ChuckyClient({
|
|
24
|
-
* token: 'your-jwt-token',
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* // Create a session (V2 style)
|
|
28
|
-
* const session = client.createSession({
|
|
29
|
-
* model: 'claude-sonnet-4-5-20250929',
|
|
30
|
-
* systemPrompt: 'You are a helpful assistant.',
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* // Send messages and stream responses
|
|
34
|
-
* await session.send('Hello, world!');
|
|
35
|
-
* for await (const msg of session.stream()) {
|
|
36
|
-
* if (msg.type === 'assistant') {
|
|
37
|
-
* const text = getAssistantText(msg);
|
|
38
|
-
* console.log(text);
|
|
39
|
-
* }
|
|
40
|
-
* if (msg.type === 'result') {
|
|
41
|
-
* console.log('Done:', msg);
|
|
42
|
-
* }
|
|
43
|
-
* }
|
|
44
|
-
*
|
|
45
|
-
* session.close();
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export class ChuckyClient {
|
|
49
|
-
options;
|
|
50
|
-
eventHandlers = {};
|
|
51
|
-
activeSessions = new Map();
|
|
52
|
-
/**
|
|
53
|
-
* Create a new Chucky client
|
|
54
|
-
*/
|
|
55
|
-
constructor(options) {
|
|
56
|
-
this.options = {
|
|
57
|
-
baseUrl: DEFAULT_BASE_URL,
|
|
58
|
-
debug: false,
|
|
59
|
-
...options,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Set event handlers
|
|
64
|
-
*/
|
|
65
|
-
on(handlers) {
|
|
66
|
-
this.eventHandlers = { ...this.eventHandlers, ...handlers };
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Create a new session
|
|
71
|
-
*
|
|
72
|
-
* Matches V2 SDK: createSession() returns a Session immediately.
|
|
73
|
-
* Connection happens automatically on first send().
|
|
74
|
-
*
|
|
75
|
-
* @param options - Session configuration options
|
|
76
|
-
* @returns A new session instance
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```typescript
|
|
80
|
-
* const session = client.createSession({
|
|
81
|
-
* model: 'claude-sonnet-4-5-20250929',
|
|
82
|
-
* systemPrompt: 'You are a helpful coding assistant.',
|
|
83
|
-
* });
|
|
84
|
-
*
|
|
85
|
-
* await session.send('Hello!');
|
|
86
|
-
* for await (const msg of session.stream()) {
|
|
87
|
-
* // Handle messages
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
createSession(options = {}) {
|
|
92
|
-
const transport = this.createTransport();
|
|
93
|
-
const session = new Session(transport, options, {
|
|
94
|
-
debug: this.options.debug,
|
|
95
|
-
});
|
|
96
|
-
// Track the session
|
|
97
|
-
session.on({
|
|
98
|
-
onSessionInfo: (info) => {
|
|
99
|
-
if (info.sessionId) {
|
|
100
|
-
this.activeSessions.set(info.sessionId, session);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
return session;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Resume an existing session
|
|
108
|
-
*
|
|
109
|
-
* @param sessionId - The session ID to resume
|
|
110
|
-
* @param options - Additional session options
|
|
111
|
-
* @returns The resumed session
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* ```typescript
|
|
115
|
-
* const session = client.resumeSession('session-123');
|
|
116
|
-
* await session.send('Continue our conversation');
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
resumeSession(sessionId, options = {}) {
|
|
120
|
-
return this.createSession({
|
|
121
|
-
...options,
|
|
122
|
-
sessionId,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Execute a one-shot prompt (stateless)
|
|
127
|
-
*
|
|
128
|
-
* Matches V2 SDK: prompt() for simple one-off queries.
|
|
129
|
-
*
|
|
130
|
-
* @param message - The message to send
|
|
131
|
-
* @param options - Prompt configuration
|
|
132
|
-
* @returns The result message
|
|
133
|
-
*
|
|
134
|
-
* @example
|
|
135
|
-
* ```typescript
|
|
136
|
-
* const result = await client.prompt(
|
|
137
|
-
* 'Explain quantum computing in simple terms',
|
|
138
|
-
* { model: 'claude-sonnet-4-5-20250929' }
|
|
139
|
-
* );
|
|
140
|
-
* if (result.subtype === 'success') {
|
|
141
|
-
* console.log(result.result);
|
|
142
|
-
* }
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
async prompt(message, options = {}) {
|
|
146
|
-
const session = this.createSession(options);
|
|
147
|
-
try {
|
|
148
|
-
await session.send(message);
|
|
149
|
-
let result = null;
|
|
150
|
-
for await (const msg of session.stream()) {
|
|
151
|
-
if (msg.type === 'result') {
|
|
152
|
-
result = msg;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (!result) {
|
|
157
|
-
throw new Error('No result message received');
|
|
158
|
-
}
|
|
159
|
-
return result;
|
|
160
|
-
}
|
|
161
|
-
finally {
|
|
162
|
-
session.close();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Close all active sessions and disconnect
|
|
167
|
-
*/
|
|
168
|
-
close() {
|
|
169
|
-
for (const session of this.activeSessions.values()) {
|
|
170
|
-
session.close();
|
|
171
|
-
}
|
|
172
|
-
this.activeSessions.clear();
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Create a new transport instance
|
|
176
|
-
*/
|
|
177
|
-
createTransport() {
|
|
178
|
-
return new WebSocketTransport({
|
|
179
|
-
url: this.options.baseUrl,
|
|
180
|
-
token: this.options.token,
|
|
181
|
-
timeout: this.options.timeout,
|
|
182
|
-
keepAliveInterval: this.options.keepAliveInterval,
|
|
183
|
-
autoReconnect: this.options.autoReconnect,
|
|
184
|
-
maxReconnectAttempts: this.options.maxReconnectAttempts,
|
|
185
|
-
debug: this.options.debug,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Create a Chucky client
|
|
191
|
-
*
|
|
192
|
-
* @param options - Client configuration
|
|
193
|
-
* @returns A new ChuckyClient instance
|
|
194
|
-
*
|
|
195
|
-
* @example
|
|
196
|
-
* ```typescript
|
|
197
|
-
* import { createClient } from '@chucky.cloud/sdk';
|
|
198
|
-
*
|
|
199
|
-
* const client = createClient({
|
|
200
|
-
* token: 'your-jwt-token',
|
|
201
|
-
* });
|
|
202
|
-
* ```
|
|
203
|
-
*/
|
|
204
|
-
export function createClient(options) {
|
|
205
|
-
return new ChuckyClient(options);
|
|
206
|
-
}
|
|
207
|
-
// Re-export helpers for convenience
|
|
208
|
-
export { getAssistantText, getResultText };
|
|
209
|
-
//# sourceMappingURL=ChuckyClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChuckyClient.js","sourceRoot":"","sources":["../../src/client/ChuckyClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACx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AAa,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa;YACzC,oBAAoB,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB;YACvD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;SAC1B,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAAC,OAAsB;IACjD,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,oCAAoC;AACpC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/client/Session.d.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session
|
|
3
|
-
*
|
|
4
|
-
* Represents a conversation session with the Chucky sandbox.
|
|
5
|
-
* Matches the official Claude Agent SDK V2 interface.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const session = createSession({ token, model: 'claude-sonnet-4-5-20250929' });
|
|
10
|
-
*
|
|
11
|
-
* await session.send('Hello!');
|
|
12
|
-
* for await (const msg of session.stream()) {
|
|
13
|
-
* if (msg.type === 'assistant') {
|
|
14
|
-
* console.log(getAssistantText(msg));
|
|
15
|
-
* }
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
import type { SessionOptions } from '../types/options.js';
|
|
20
|
-
import type { SessionInfo } from '../types/results.js';
|
|
21
|
-
import type { SDKMessage } from '../types/messages.js';
|
|
22
|
-
import type { Transport } from '../transport/Transport.js';
|
|
23
|
-
/**
|
|
24
|
-
* Session event handlers
|
|
25
|
-
*/
|
|
26
|
-
export interface SessionEventHandlers {
|
|
27
|
-
onSessionInfo?: (info: SessionInfo) => void;
|
|
28
|
-
onError?: (error: Error) => void;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Internal session configuration
|
|
32
|
-
*/
|
|
33
|
-
interface SessionConfig {
|
|
34
|
-
debug?: boolean;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Session class - matches official V2 SDK interface
|
|
38
|
-
*
|
|
39
|
-
* Usage:
|
|
40
|
-
* ```typescript
|
|
41
|
-
* const session = createSession({ token, model: 'claude-sonnet-4-5-20250929' });
|
|
42
|
-
*
|
|
43
|
-
* // Multi-turn conversation
|
|
44
|
-
* await session.send('What is 5 + 3?');
|
|
45
|
-
* for await (const msg of session.stream()) {
|
|
46
|
-
* if (msg.type === 'result') console.log(msg.result);
|
|
47
|
-
* }
|
|
48
|
-
*
|
|
49
|
-
* await session.send('Multiply that by 2');
|
|
50
|
-
* for await (const msg of session.stream()) {
|
|
51
|
-
* if (msg.type === 'result') console.log(msg.result);
|
|
52
|
-
* }
|
|
53
|
-
*
|
|
54
|
-
* session.close();
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export declare class Session {
|
|
58
|
-
private transport;
|
|
59
|
-
private options;
|
|
60
|
-
private config;
|
|
61
|
-
private eventHandlers;
|
|
62
|
-
private toolHandlers;
|
|
63
|
-
private messageBuffer;
|
|
64
|
-
private _state;
|
|
65
|
-
private _sessionId;
|
|
66
|
-
private messageResolvers;
|
|
67
|
-
private connected;
|
|
68
|
-
private connectPromise;
|
|
69
|
-
constructor(transport: Transport, options: SessionOptions, config?: SessionConfig);
|
|
70
|
-
/**
|
|
71
|
-
* Get the session ID
|
|
72
|
-
*/
|
|
73
|
-
get sessionId(): string;
|
|
74
|
-
/**
|
|
75
|
-
* Set event handlers
|
|
76
|
-
*/
|
|
77
|
-
on(handlers: SessionEventHandlers): this;
|
|
78
|
-
/**
|
|
79
|
-
* Connect and initialize the session (called automatically on first send)
|
|
80
|
-
*/
|
|
81
|
-
private ensureConnected;
|
|
82
|
-
private connect;
|
|
83
|
-
/**
|
|
84
|
-
* Send a message to the session
|
|
85
|
-
*
|
|
86
|
-
* Matches V2 SDK: send() returns Promise<void>
|
|
87
|
-
* Use stream() to get the response.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* await session.send('Hello!');
|
|
92
|
-
* for await (const msg of session.stream()) {
|
|
93
|
-
* // Handle messages
|
|
94
|
-
* }
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
send(message: string): Promise<void>;
|
|
98
|
-
/**
|
|
99
|
-
* Stream the response after sending a message
|
|
100
|
-
*
|
|
101
|
-
* Matches V2 SDK: Returns AsyncGenerator<SDKMessage>
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```typescript
|
|
105
|
-
* await session.send('Hello!');
|
|
106
|
-
* for await (const msg of session.stream()) {
|
|
107
|
-
* if (msg.type === 'assistant') {
|
|
108
|
-
* const text = msg.message.content
|
|
109
|
-
* .filter(b => b.type === 'text')
|
|
110
|
-
* .map(b => b.text)
|
|
111
|
-
* .join('');
|
|
112
|
-
* console.log(text);
|
|
113
|
-
* }
|
|
114
|
-
* if (msg.type === 'result') {
|
|
115
|
-
* console.log('Done:', msg.result);
|
|
116
|
-
* }
|
|
117
|
-
* }
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
stream(): AsyncGenerator<SDKMessage, void, unknown>;
|
|
121
|
-
/**
|
|
122
|
-
* Receive messages (alias for stream for V2 compatibility)
|
|
123
|
-
*/
|
|
124
|
-
receive(): AsyncGenerator<SDKMessage, void, unknown>;
|
|
125
|
-
/**
|
|
126
|
-
* Close the session
|
|
127
|
-
*/
|
|
128
|
-
close(): void;
|
|
129
|
-
/**
|
|
130
|
-
* Support for `await using` (TypeScript 5.2+)
|
|
131
|
-
*/
|
|
132
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* Build init payload from options
|
|
135
|
-
*/
|
|
136
|
-
private buildInitPayload;
|
|
137
|
-
/**
|
|
138
|
-
* Handle incoming message
|
|
139
|
-
*/
|
|
140
|
-
private handleMessage;
|
|
141
|
-
/**
|
|
142
|
-
* Wait for session to be ready
|
|
143
|
-
*/
|
|
144
|
-
private waitForReady;
|
|
145
|
-
/**
|
|
146
|
-
* Wait for next message
|
|
147
|
-
*/
|
|
148
|
-
private waitForNextMessage;
|
|
149
|
-
/**
|
|
150
|
-
* Handle a tool call
|
|
151
|
-
*/
|
|
152
|
-
private handleToolCall;
|
|
153
|
-
/**
|
|
154
|
-
* Log debug messages
|
|
155
|
-
*/
|
|
156
|
-
private log;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Extract text from an assistant message
|
|
160
|
-
*/
|
|
161
|
-
export declare function getAssistantText(msg: SDKMessage): string | null;
|
|
162
|
-
/**
|
|
163
|
-
* Extract result from a result message
|
|
164
|
-
*/
|
|
165
|
-
export declare function getResultText(msg: SDKMessage): string | null;
|
|
166
|
-
export {};
|
|
167
|
-
//# sourceMappingURL=Session.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Session.d.ts","sourceRoot":"","sources":["../../src/client/Session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,qBAAqB,CAAC;AAErE,OAAO,KAAK,EAGV,UAAU,EAIX,MAAM,sBAAsB,CAAC;AAc9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAaD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,SA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