@astroanywhere/agent 0.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/LICENSE +76 -0
- package/README.md +178 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +401 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +9 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/mcp.d.ts +16 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +19 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/setup.d.ts +20 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +585 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/start.d.ts +16 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +638 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +5 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +63 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/stop.d.ts +5 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +85 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/execution/direct-strategy.d.ts +18 -0
- package/dist/execution/direct-strategy.d.ts.map +1 -0
- package/dist/execution/direct-strategy.js +156 -0
- package/dist/execution/direct-strategy.js.map +1 -0
- package/dist/execution/docker-strategy.d.ts +26 -0
- package/dist/execution/docker-strategy.d.ts.map +1 -0
- package/dist/execution/docker-strategy.js +222 -0
- package/dist/execution/docker-strategy.js.map +1 -0
- package/dist/execution/index.d.ts +14 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +13 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/kubernetes-exec-strategy.d.ts +23 -0
- package/dist/execution/kubernetes-exec-strategy.d.ts.map +1 -0
- package/dist/execution/kubernetes-exec-strategy.js +232 -0
- package/dist/execution/kubernetes-exec-strategy.js.map +1 -0
- package/dist/execution/registry.d.ts +41 -0
- package/dist/execution/registry.d.ts.map +1 -0
- package/dist/execution/registry.js +84 -0
- package/dist/execution/registry.js.map +1 -0
- package/dist/execution/slurm-strategy.d.ts +22 -0
- package/dist/execution/slurm-strategy.d.ts.map +1 -0
- package/dist/execution/slurm-strategy.js +219 -0
- package/dist/execution/slurm-strategy.js.map +1 -0
- package/dist/execution/types.d.ts +72 -0
- package/dist/execution/types.d.ts.map +1 -0
- package/dist/execution/types.js +10 -0
- package/dist/execution/types.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api-client.d.ts +35 -0
- package/dist/lib/api-client.d.ts.map +1 -0
- package/dist/lib/api-client.js +126 -0
- package/dist/lib/api-client.js.map +1 -0
- package/dist/lib/config.d.ts +174 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +399 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/copy-worktree.d.ts +73 -0
- package/dist/lib/copy-worktree.d.ts.map +1 -0
- package/dist/lib/copy-worktree.js +374 -0
- package/dist/lib/copy-worktree.js.map +1 -0
- package/dist/lib/git-pr.d.ts +63 -0
- package/dist/lib/git-pr.d.ts.map +1 -0
- package/dist/lib/git-pr.js +224 -0
- package/dist/lib/git-pr.js.map +1 -0
- package/dist/lib/hardware-id.d.ts +25 -0
- package/dist/lib/hardware-id.d.ts.map +1 -0
- package/dist/lib/hardware-id.js +186 -0
- package/dist/lib/hardware-id.js.map +1 -0
- package/dist/lib/hpc-context.d.ts +35 -0
- package/dist/lib/hpc-context.d.ts.map +1 -0
- package/dist/lib/hpc-context.js +167 -0
- package/dist/lib/hpc-context.js.map +1 -0
- package/dist/lib/prompt-templates.d.ts +195 -0
- package/dist/lib/prompt-templates.d.ts.map +1 -0
- package/dist/lib/prompt-templates.js +353 -0
- package/dist/lib/prompt-templates.js.map +1 -0
- package/dist/lib/providers.d.ts +27 -0
- package/dist/lib/providers.d.ts.map +1 -0
- package/dist/lib/providers.js +372 -0
- package/dist/lib/providers.js.map +1 -0
- package/dist/lib/repo-context.d.ts +18 -0
- package/dist/lib/repo-context.d.ts.map +1 -0
- package/dist/lib/repo-context.js +61 -0
- package/dist/lib/repo-context.js.map +1 -0
- package/dist/lib/repo-utils.d.ts +35 -0
- package/dist/lib/repo-utils.d.ts.map +1 -0
- package/dist/lib/repo-utils.js +222 -0
- package/dist/lib/repo-utils.js.map +1 -0
- package/dist/lib/resources.d.ts +17 -0
- package/dist/lib/resources.d.ts.map +1 -0
- package/dist/lib/resources.js +227 -0
- package/dist/lib/resources.js.map +1 -0
- package/dist/lib/slurm-detect.d.ts +15 -0
- package/dist/lib/slurm-detect.d.ts.map +1 -0
- package/dist/lib/slurm-detect.js +148 -0
- package/dist/lib/slurm-detect.js.map +1 -0
- package/dist/lib/slurm-executor.d.ts +70 -0
- package/dist/lib/slurm-executor.d.ts.map +1 -0
- package/dist/lib/slurm-executor.js +402 -0
- package/dist/lib/slurm-executor.js.map +1 -0
- package/dist/lib/slurm-job-monitor.d.ts +52 -0
- package/dist/lib/slurm-job-monitor.d.ts.map +1 -0
- package/dist/lib/slurm-job-monitor.js +212 -0
- package/dist/lib/slurm-job-monitor.js.map +1 -0
- package/dist/lib/ssh-discovery.d.ts +17 -0
- package/dist/lib/ssh-discovery.d.ts.map +1 -0
- package/dist/lib/ssh-discovery.js +287 -0
- package/dist/lib/ssh-discovery.js.map +1 -0
- package/dist/lib/ssh-installer.d.ts +69 -0
- package/dist/lib/ssh-installer.d.ts.map +1 -0
- package/dist/lib/ssh-installer.js +230 -0
- package/dist/lib/ssh-installer.js.map +1 -0
- package/dist/lib/streaming-prompt.d.ts +48 -0
- package/dist/lib/streaming-prompt.d.ts.map +1 -0
- package/dist/lib/streaming-prompt.js +91 -0
- package/dist/lib/streaming-prompt.js.map +1 -0
- package/dist/lib/task-executor.d.ts +114 -0
- package/dist/lib/task-executor.d.ts.map +1 -0
- package/dist/lib/task-executor.js +753 -0
- package/dist/lib/task-executor.js.map +1 -0
- package/dist/lib/websocket-client.d.ts +200 -0
- package/dist/lib/websocket-client.d.ts.map +1 -0
- package/dist/lib/websocket-client.js +781 -0
- package/dist/lib/websocket-client.js.map +1 -0
- package/dist/lib/workdir-safety.d.ts +63 -0
- package/dist/lib/workdir-safety.d.ts.map +1 -0
- package/dist/lib/workdir-safety.js +247 -0
- package/dist/lib/workdir-safety.js.map +1 -0
- package/dist/lib/worktree-include.d.ts +14 -0
- package/dist/lib/worktree-include.d.ts.map +1 -0
- package/dist/lib/worktree-include.js +68 -0
- package/dist/lib/worktree-include.js.map +1 -0
- package/dist/lib/worktree-setup.d.ts +18 -0
- package/dist/lib/worktree-setup.d.ts.map +1 -0
- package/dist/lib/worktree-setup.js +60 -0
- package/dist/lib/worktree-setup.js.map +1 -0
- package/dist/lib/worktree.d.ts +37 -0
- package/dist/lib/worktree.d.ts.map +1 -0
- package/dist/lib/worktree.js +411 -0
- package/dist/lib/worktree.js.map +1 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +8 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +45 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +153 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/session-bridge.d.ts +87 -0
- package/dist/mcp/session-bridge.d.ts.map +1 -0
- package/dist/mcp/session-bridge.js +317 -0
- package/dist/mcp/session-bridge.js.map +1 -0
- package/dist/mcp/tools.d.ts +70 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +234 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/types.d.ts +197 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +16 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/providers/base-adapter.d.ts +56 -0
- package/dist/providers/base-adapter.d.ts.map +1 -0
- package/dist/providers/base-adapter.js +5 -0
- package/dist/providers/base-adapter.js.map +1 -0
- package/dist/providers/claude-code-adapter.d.ts +27 -0
- package/dist/providers/claude-code-adapter.d.ts.map +1 -0
- package/dist/providers/claude-code-adapter.js +298 -0
- package/dist/providers/claude-code-adapter.js.map +1 -0
- package/dist/providers/claude-sdk-adapter.d.ts +60 -0
- package/dist/providers/claude-sdk-adapter.d.ts.map +1 -0
- package/dist/providers/claude-sdk-adapter.js +632 -0
- package/dist/providers/claude-sdk-adapter.js.map +1 -0
- package/dist/providers/codex-adapter.d.ts +21 -0
- package/dist/providers/codex-adapter.d.ts.map +1 -0
- package/dist/providers/codex-adapter.js +197 -0
- package/dist/providers/codex-adapter.js.map +1 -0
- package/dist/providers/index.d.ts +26 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +58 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/slurm-adapter.d.ts +26 -0
- package/dist/providers/slurm-adapter.d.ts.map +1 -0
- package/dist/providers/slurm-adapter.js +146 -0
- package/dist/providers/slurm-adapter.js.map +1 -0
- package/dist/types.d.ts +592 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tools for Astro Session Bridge
|
|
3
|
+
*
|
|
4
|
+
* Provides tools that Claude Code can use to:
|
|
5
|
+
* - astro_attach: Attach the current session to an Astro task
|
|
6
|
+
* - astro_detach: Detach from the current task
|
|
7
|
+
* - astro_status: Check the current attachment status
|
|
8
|
+
* - astro_send: Send a message/event to Astro
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Tool Schemas
|
|
13
|
+
// ============================================================================
|
|
14
|
+
/** Schema for astro_attach tool input */
|
|
15
|
+
export const attachSchema = z.object({
|
|
16
|
+
taskId: z.string().describe('Task identifier to attach to (e.g., "RES-13", "PROJ-42")'),
|
|
17
|
+
});
|
|
18
|
+
/** Schema for astro_detach tool input */
|
|
19
|
+
export const detachSchema = z.object({});
|
|
20
|
+
/** Schema for astro_status tool input */
|
|
21
|
+
export const statusSchema = z.object({});
|
|
22
|
+
/** Schema for astro_send tool input */
|
|
23
|
+
export const sendSchema = z.object({
|
|
24
|
+
message: z.string().describe('Message or event content to send to Astro'),
|
|
25
|
+
eventType: z
|
|
26
|
+
.enum(['tool_call', 'tool_result', 'file_change', 'message', 'error'])
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Optional event type (default: message)'),
|
|
29
|
+
});
|
|
30
|
+
export const toolDefinitions = [
|
|
31
|
+
{
|
|
32
|
+
name: 'astro_attach',
|
|
33
|
+
description: 'Attach this Claude Code session to an Astro task. Once attached, your activity ' +
|
|
34
|
+
'(tool calls, file changes, messages) will be streamed to Astro for monitoring. ' +
|
|
35
|
+
'The task must already exist in Astro. Example: astro_attach("RES-13")',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
taskId: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Task identifier to attach to (e.g., "RES-13", "PROJ-42")',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: ['taskId'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'astro_detach',
|
|
49
|
+
description: 'Detach from the currently attached Astro task. ' +
|
|
50
|
+
'After detaching, session activity will no longer be streamed to Astro.',
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'astro_status',
|
|
58
|
+
description: 'Check the current Astro attachment status. ' +
|
|
59
|
+
'Returns whether a session is attached, which task it is attached to, ' +
|
|
60
|
+
'and how many events have been sent.',
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'astro_send',
|
|
68
|
+
description: 'Send a message or event to the attached Astro task. ' +
|
|
69
|
+
'This can be used to send progress updates, status messages, or custom events. ' +
|
|
70
|
+
'Requires an active attachment.',
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
message: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
description: 'Message or event content to send to Astro',
|
|
77
|
+
},
|
|
78
|
+
eventType: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
enum: ['tool_call', 'tool_result', 'file_change', 'message', 'error'],
|
|
81
|
+
description: 'Optional event type (default: message)',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
required: ['message'],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
// ============================================================================
|
|
89
|
+
// Tool Handlers
|
|
90
|
+
// ============================================================================
|
|
91
|
+
export class ToolHandlers {
|
|
92
|
+
bridge;
|
|
93
|
+
constructor(bridge) {
|
|
94
|
+
this.bridge = bridge;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Handle astro_attach tool call
|
|
98
|
+
*/
|
|
99
|
+
async attach(input) {
|
|
100
|
+
try {
|
|
101
|
+
const success = await this.bridge.attach(input.taskId);
|
|
102
|
+
const status = this.bridge.getStatus();
|
|
103
|
+
if (success) {
|
|
104
|
+
return {
|
|
105
|
+
success: true,
|
|
106
|
+
message: `Successfully attached to task ${input.taskId}`,
|
|
107
|
+
sessionId: status.sessionId,
|
|
108
|
+
taskId: input.taskId,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
message: `Failed to attach to task ${input.taskId}`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
message: `Error attaching to task: ${error instanceof Error ? error.message : String(error)}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Handle astro_detach tool call
|
|
127
|
+
*/
|
|
128
|
+
async detach() {
|
|
129
|
+
try {
|
|
130
|
+
const status = this.bridge.getStatus();
|
|
131
|
+
const eventCount = status.eventCount;
|
|
132
|
+
await this.bridge.detach();
|
|
133
|
+
return {
|
|
134
|
+
success: true,
|
|
135
|
+
message: 'Successfully detached from Astro task',
|
|
136
|
+
eventsSent: eventCount,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
return {
|
|
141
|
+
success: false,
|
|
142
|
+
message: `Error detaching: ${error instanceof Error ? error.message : String(error)}`,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Handle astro_status tool call
|
|
148
|
+
*/
|
|
149
|
+
status() {
|
|
150
|
+
const bridgeStatus = this.bridge.getStatus();
|
|
151
|
+
return {
|
|
152
|
+
success: true,
|
|
153
|
+
message: bridgeStatus.state === 'attached'
|
|
154
|
+
? `Attached to task ${bridgeStatus.taskId}`
|
|
155
|
+
: bridgeStatus.state === 'disconnected'
|
|
156
|
+
? 'Not attached to any task'
|
|
157
|
+
: `State: ${bridgeStatus.state}`,
|
|
158
|
+
state: bridgeStatus.state,
|
|
159
|
+
taskId: bridgeStatus.taskId,
|
|
160
|
+
sessionId: bridgeStatus.sessionId,
|
|
161
|
+
attachedAt: bridgeStatus.attachedAt?.toISOString(),
|
|
162
|
+
eventCount: bridgeStatus.eventCount,
|
|
163
|
+
relayConnected: bridgeStatus.relayConnected,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Handle astro_send tool call
|
|
168
|
+
*/
|
|
169
|
+
send(input) {
|
|
170
|
+
if (!this.bridge.isAttached()) {
|
|
171
|
+
return {
|
|
172
|
+
success: false,
|
|
173
|
+
message: 'Not attached to any task. Use astro_attach first.',
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const eventType = input.eventType ?? 'message';
|
|
177
|
+
// Create the appropriate event based on type
|
|
178
|
+
let event;
|
|
179
|
+
switch (eventType) {
|
|
180
|
+
case 'message':
|
|
181
|
+
event = {
|
|
182
|
+
type: 'message',
|
|
183
|
+
role: 'assistant',
|
|
184
|
+
content: input.message,
|
|
185
|
+
};
|
|
186
|
+
break;
|
|
187
|
+
case 'error':
|
|
188
|
+
event = {
|
|
189
|
+
type: 'error',
|
|
190
|
+
error: input.message,
|
|
191
|
+
};
|
|
192
|
+
break;
|
|
193
|
+
default:
|
|
194
|
+
// For other event types, send as a generic message
|
|
195
|
+
event = {
|
|
196
|
+
type: 'message',
|
|
197
|
+
role: 'assistant',
|
|
198
|
+
content: `[${eventType}] ${input.message}`,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const sent = this.bridge.sendEvent(event);
|
|
202
|
+
if (sent) {
|
|
203
|
+
return {
|
|
204
|
+
success: true,
|
|
205
|
+
message: 'Event sent to Astro',
|
|
206
|
+
eventId: `evt-${Date.now()}`,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
return {
|
|
211
|
+
success: false,
|
|
212
|
+
message: 'Failed to send event. Check connection status.',
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Handle tool call by name
|
|
218
|
+
*/
|
|
219
|
+
async handleToolCall(name, args) {
|
|
220
|
+
switch (name) {
|
|
221
|
+
case 'astro_attach':
|
|
222
|
+
return this.attach(attachSchema.parse(args));
|
|
223
|
+
case 'astro_detach':
|
|
224
|
+
return this.detach();
|
|
225
|
+
case 'astro_status':
|
|
226
|
+
return this.status();
|
|
227
|
+
case 'astro_send':
|
|
228
|
+
return this.send(sendSchema.parse(args));
|
|
229
|
+
default:
|
|
230
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E,yCAAyC;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;CACxF,CAAC,CAAC;AAEH,yCAAyC;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzC,yCAAyC;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzC,uCAAuC;AACvC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IACzE,SAAS,EAAE,CAAC;SACT,IAAI,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;SACrE,QAAQ,EAAE;SACV,QAAQ,CAAC,wCAAwC,CAAC;CACtD,CAAC,CAAC;AAgBH,MAAM,CAAC,MAAM,eAAe,GAAqB;IAC/C;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EACT,i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gBACE,mDAAmD;gBACnD,KAAK,GAAG;oBACN,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,IAAI,SAAS,KAAK,KAAK,CAAC,OAAO,EAAE;iBAC3C,CAAC;QACN,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAE1C,IAAI,IAAI,EAAE,CAAC;YACT,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,qBAAqB;gBAC9B,OAAO,EAAE,OAAO,IAAI,CAAC,GAAG,EAAE,EAAE;aAC7B,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,gDAAgD;aAC1D,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAClB,IAAY,EACZ,IAA6B;QAE7B,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/C,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,KAAK,YAAY;gBACf,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3C;gBACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Astro MCP Bridge
|
|
3
|
+
*
|
|
4
|
+
* This MCP server allows existing Claude Code sessions to connect to Astro
|
|
5
|
+
* and link their activity to specific tasks.
|
|
6
|
+
*/
|
|
7
|
+
/** State of an MCP session attachment */
|
|
8
|
+
export type SessionAttachmentState = 'disconnected' | 'connecting' | 'attached' | 'error';
|
|
9
|
+
/** Session attachment information */
|
|
10
|
+
export interface SessionAttachment {
|
|
11
|
+
/** Task identifier in Astro (e.g., "RES-13") */
|
|
12
|
+
taskId: string;
|
|
13
|
+
/** Unique session ID for this attachment */
|
|
14
|
+
sessionId: string;
|
|
15
|
+
/** Current state of the attachment */
|
|
16
|
+
state: SessionAttachmentState;
|
|
17
|
+
/** When the session was attached */
|
|
18
|
+
attachedAt?: Date;
|
|
19
|
+
/** Error message if state is 'error' */
|
|
20
|
+
error?: string;
|
|
21
|
+
/** Number of events sent to Astro */
|
|
22
|
+
eventCount: number;
|
|
23
|
+
}
|
|
24
|
+
/** Session event types that can be sent to Astro */
|
|
25
|
+
export type SessionEventType = 'tool_call' | 'tool_result' | 'file_change' | 'message' | 'error';
|
|
26
|
+
/** Base session event */
|
|
27
|
+
export interface BaseSessionEvent {
|
|
28
|
+
type: SessionEventType;
|
|
29
|
+
timestamp: Date;
|
|
30
|
+
sessionId: string;
|
|
31
|
+
taskId: string;
|
|
32
|
+
}
|
|
33
|
+
/** Tool call event from Claude Code */
|
|
34
|
+
export interface ToolCallEvent extends BaseSessionEvent {
|
|
35
|
+
type: 'tool_call';
|
|
36
|
+
toolName: string;
|
|
37
|
+
toolInput: unknown;
|
|
38
|
+
}
|
|
39
|
+
/** Tool result event from Claude Code */
|
|
40
|
+
export interface ToolResultEvent extends BaseSessionEvent {
|
|
41
|
+
type: 'tool_result';
|
|
42
|
+
toolName: string;
|
|
43
|
+
toolResult: unknown;
|
|
44
|
+
success: boolean;
|
|
45
|
+
duration?: number;
|
|
46
|
+
}
|
|
47
|
+
/** File change event */
|
|
48
|
+
export interface FileChangeEvent extends BaseSessionEvent {
|
|
49
|
+
type: 'file_change';
|
|
50
|
+
path: string;
|
|
51
|
+
action: 'created' | 'modified' | 'deleted';
|
|
52
|
+
linesAdded?: number;
|
|
53
|
+
linesRemoved?: number;
|
|
54
|
+
diff?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Message event (user or assistant messages) */
|
|
57
|
+
export interface MessageEvent extends BaseSessionEvent {
|
|
58
|
+
type: 'message';
|
|
59
|
+
role: 'user' | 'assistant';
|
|
60
|
+
content: string;
|
|
61
|
+
}
|
|
62
|
+
/** Error event */
|
|
63
|
+
export interface ErrorEvent extends BaseSessionEvent {
|
|
64
|
+
type: 'error';
|
|
65
|
+
error: string;
|
|
66
|
+
stack?: string;
|
|
67
|
+
}
|
|
68
|
+
/** Union of all session event types */
|
|
69
|
+
export type SessionEvent = ToolCallEvent | ToolResultEvent | FileChangeEvent | MessageEvent | ErrorEvent;
|
|
70
|
+
/** Input for creating a message event */
|
|
71
|
+
export interface MessageEventInput {
|
|
72
|
+
type: 'message';
|
|
73
|
+
role: 'user' | 'assistant';
|
|
74
|
+
content: string;
|
|
75
|
+
}
|
|
76
|
+
/** Input for creating an error event */
|
|
77
|
+
export interface ErrorEventInput {
|
|
78
|
+
type: 'error';
|
|
79
|
+
error: string;
|
|
80
|
+
stack?: string;
|
|
81
|
+
}
|
|
82
|
+
/** Input for creating a tool call event */
|
|
83
|
+
export interface ToolCallEventInput {
|
|
84
|
+
type: 'tool_call';
|
|
85
|
+
toolName: string;
|
|
86
|
+
toolInput: unknown;
|
|
87
|
+
}
|
|
88
|
+
/** Input for creating a tool result event */
|
|
89
|
+
export interface ToolResultEventInput {
|
|
90
|
+
type: 'tool_result';
|
|
91
|
+
toolName: string;
|
|
92
|
+
toolResult: unknown;
|
|
93
|
+
success: boolean;
|
|
94
|
+
duration?: number;
|
|
95
|
+
}
|
|
96
|
+
/** Input for creating a file change event */
|
|
97
|
+
export interface FileChangeEventInput {
|
|
98
|
+
type: 'file_change';
|
|
99
|
+
path: string;
|
|
100
|
+
action: 'created' | 'modified' | 'deleted';
|
|
101
|
+
linesAdded?: number;
|
|
102
|
+
linesRemoved?: number;
|
|
103
|
+
diff?: string;
|
|
104
|
+
}
|
|
105
|
+
/** Union of all session event input types (without sessionId, taskId, timestamp) */
|
|
106
|
+
export type SessionEventInput = MessageEventInput | ErrorEventInput | ToolCallEventInput | ToolResultEventInput | FileChangeEventInput;
|
|
107
|
+
/** Input for astro_attach tool */
|
|
108
|
+
export interface AttachInput {
|
|
109
|
+
/** Task identifier to attach to (e.g., "RES-13") */
|
|
110
|
+
taskId: string;
|
|
111
|
+
}
|
|
112
|
+
/** Input for astro_send tool */
|
|
113
|
+
export interface SendInput {
|
|
114
|
+
/** Message or event to send to Astro */
|
|
115
|
+
message: string;
|
|
116
|
+
/** Optional event type */
|
|
117
|
+
eventType?: SessionEventType;
|
|
118
|
+
}
|
|
119
|
+
/** Base response for MCP tools */
|
|
120
|
+
export interface McpToolResponse {
|
|
121
|
+
success: boolean;
|
|
122
|
+
message: string;
|
|
123
|
+
}
|
|
124
|
+
/** Response from astro_attach */
|
|
125
|
+
export interface AttachResponse extends McpToolResponse {
|
|
126
|
+
sessionId?: string;
|
|
127
|
+
taskId?: string;
|
|
128
|
+
}
|
|
129
|
+
/** Response from astro_detach */
|
|
130
|
+
export interface DetachResponse extends McpToolResponse {
|
|
131
|
+
eventsSent?: number;
|
|
132
|
+
}
|
|
133
|
+
/** Response from astro_status */
|
|
134
|
+
export interface StatusResponse extends McpToolResponse {
|
|
135
|
+
state: SessionAttachmentState;
|
|
136
|
+
taskId?: string;
|
|
137
|
+
sessionId?: string;
|
|
138
|
+
attachedAt?: string;
|
|
139
|
+
eventCount?: number;
|
|
140
|
+
relayConnected?: boolean;
|
|
141
|
+
}
|
|
142
|
+
/** Response from astro_send */
|
|
143
|
+
export interface SendResponse extends McpToolResponse {
|
|
144
|
+
eventId?: string;
|
|
145
|
+
}
|
|
146
|
+
/** Session attach request to relay */
|
|
147
|
+
export interface SessionAttachMessage {
|
|
148
|
+
type: 'session.attach';
|
|
149
|
+
taskId: string;
|
|
150
|
+
sessionId: string;
|
|
151
|
+
machineId: string;
|
|
152
|
+
timestamp: Date;
|
|
153
|
+
}
|
|
154
|
+
/** Session attach acknowledgment from relay */
|
|
155
|
+
export interface SessionAttachAckMessage {
|
|
156
|
+
type: 'session.attach.ack';
|
|
157
|
+
taskId: string;
|
|
158
|
+
sessionId: string;
|
|
159
|
+
success: boolean;
|
|
160
|
+
error?: string;
|
|
161
|
+
timestamp: Date;
|
|
162
|
+
}
|
|
163
|
+
/** Session detach message */
|
|
164
|
+
export interface SessionDetachMessage {
|
|
165
|
+
type: 'session.detach';
|
|
166
|
+
sessionId: string;
|
|
167
|
+
reason?: string;
|
|
168
|
+
timestamp: Date;
|
|
169
|
+
}
|
|
170
|
+
/** Session event message (sent to relay) */
|
|
171
|
+
export interface SessionEventMessage {
|
|
172
|
+
type: 'session.event';
|
|
173
|
+
sessionId: string;
|
|
174
|
+
taskId: string;
|
|
175
|
+
event: SessionEvent;
|
|
176
|
+
timestamp: Date;
|
|
177
|
+
}
|
|
178
|
+
/** Union of session-related WebSocket messages */
|
|
179
|
+
export type SessionRelayMessage = SessionAttachMessage | SessionAttachAckMessage | SessionDetachMessage | SessionEventMessage;
|
|
180
|
+
/** MCP Bridge configuration */
|
|
181
|
+
export interface McpBridgeConfig {
|
|
182
|
+
/** Relay server WebSocket URL */
|
|
183
|
+
relayUrl: string;
|
|
184
|
+
/** Machine ID for authentication */
|
|
185
|
+
machineId: string;
|
|
186
|
+
/** WebSocket authentication token */
|
|
187
|
+
wsToken?: string;
|
|
188
|
+
/** Auto-reconnect on disconnect */
|
|
189
|
+
autoReconnect: boolean;
|
|
190
|
+
/** Reconnect delay in milliseconds */
|
|
191
|
+
reconnectDelay: number;
|
|
192
|
+
/** Maximum reconnect attempts (-1 for infinite) */
|
|
193
|
+
maxReconnectAttempts: number;
|
|
194
|
+
}
|
|
195
|
+
/** Default MCP Bridge configuration */
|
|
196
|
+
export declare const DEFAULT_MCP_BRIDGE_CONFIG: McpBridgeConfig;
|
|
197
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1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EAAE,OAAO,CAAC;IACvB,sCAAsC;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,uCAAuC;AACvC,eAAO,MAAM,yBAAyB,EAAE,eAOvC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Astro MCP Bridge
|
|
3
|
+
*
|
|
4
|
+
* This MCP server allows existing Claude Code sessions to connect to Astro
|
|
5
|
+
* and link their activity to specific tasks.
|
|
6
|
+
*/
|
|
7
|
+
/** Default MCP Bridge configuration */
|
|
8
|
+
export const DEFAULT_MCP_BRIDGE_CONFIG = {
|
|
9
|
+
relayUrl: 'ws://localhost:3002',
|
|
10
|
+
machineId: '',
|
|
11
|
+
wsToken: undefined,
|
|
12
|
+
autoReconnect: true,
|
|
13
|
+
reconnectDelay: 1000,
|
|
14
|
+
maxReconnectAttempts: -1,
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/mcp/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsQH,uCAAuC;AACvC,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACxD,QAAQ,EAAE,qBAAqB;IAC/B,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,SAAS;IAClB,aAAa,EAAE,IAAI;IACnB,cAAc,EAAE,IAAI;IACpB,oBAAoB,EAAE,CAAC,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base adapter interface for agent providers
|
|
3
|
+
*/
|
|
4
|
+
import type { Task, TaskResult, TaskStatus } from '../types.js';
|
|
5
|
+
export interface TaskOutputStream {
|
|
6
|
+
stdout: (data: string) => void;
|
|
7
|
+
stderr: (data: string) => void;
|
|
8
|
+
status: (status: TaskStatus, progress?: number, message?: string) => void;
|
|
9
|
+
toolTrace: (toolName: string, toolInput?: unknown, toolResult?: unknown, success?: boolean) => void;
|
|
10
|
+
/** Structured text output (bypasses stdout throttle) */
|
|
11
|
+
text: (data: string) => void;
|
|
12
|
+
/** Structured tool use event */
|
|
13
|
+
toolUse: (toolName: string, toolInput: unknown) => void;
|
|
14
|
+
/** Structured tool result event */
|
|
15
|
+
toolResult: (toolName: string, result: unknown, success: boolean) => void;
|
|
16
|
+
/** Structured file change event */
|
|
17
|
+
fileChange: (path: string, action: 'created' | 'modified' | 'deleted', linesAdded?: number, linesRemoved?: number, diff?: string) => void;
|
|
18
|
+
/** Structured session init event */
|
|
19
|
+
sessionInit: (sessionId: string, model?: string) => void;
|
|
20
|
+
/** Request user approval/decision - returns a promise that resolves with user's answers */
|
|
21
|
+
approvalRequest: (question: string, options: string[]) => Promise<{
|
|
22
|
+
answered: boolean;
|
|
23
|
+
answer?: string;
|
|
24
|
+
message?: string;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export interface ProviderAdapter {
|
|
28
|
+
/**
|
|
29
|
+
* Provider type identifier
|
|
30
|
+
*/
|
|
31
|
+
readonly type: string;
|
|
32
|
+
/**
|
|
33
|
+
* Provider display name
|
|
34
|
+
*/
|
|
35
|
+
readonly name: string;
|
|
36
|
+
/**
|
|
37
|
+
* Check if the provider is available and ready
|
|
38
|
+
*/
|
|
39
|
+
isAvailable(): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Execute a task using this provider
|
|
42
|
+
*/
|
|
43
|
+
execute(task: Task, stream: TaskOutputStream, signal: AbortSignal): Promise<TaskResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Get provider status/health
|
|
46
|
+
*/
|
|
47
|
+
getStatus(): Promise<ProviderStatus>;
|
|
48
|
+
}
|
|
49
|
+
export interface ProviderStatus {
|
|
50
|
+
available: boolean;
|
|
51
|
+
version: string | null;
|
|
52
|
+
activeTasks: number;
|
|
53
|
+
maxTasks: number;
|
|
54
|
+
lastError?: string;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=base-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-adapter.d.ts","sourceRoot":"","sources":["../../src/providers/base-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1E,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACpG,wDAAwD;IACxD,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,gCAAgC;IAChC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD,mCAAmC;IACnC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1E,mCAAmC;IACnC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1I,oCAAoC;IACpC,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,2FAA2F;IAC3F,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7H;AAED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhC;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAExF;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-adapter.js","sourceRoot":"","sources":["../../src/providers/base-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code provider adapter
|
|
3
|
+
*
|
|
4
|
+
* Executes tasks using the Claude Code CLI (claude command)
|
|
5
|
+
*/
|
|
6
|
+
import type { Task, TaskResult } from '../types.js';
|
|
7
|
+
import type { ProviderAdapter, TaskOutputStream, ProviderStatus } from './base-adapter.js';
|
|
8
|
+
export declare class ClaudeCodeAdapter implements ProviderAdapter {
|
|
9
|
+
readonly type = "claude-code";
|
|
10
|
+
readonly name = "Claude Code";
|
|
11
|
+
private activeTasks;
|
|
12
|
+
private maxTasks;
|
|
13
|
+
private lastError?;
|
|
14
|
+
private claudePath;
|
|
15
|
+
private lastResultMetrics?;
|
|
16
|
+
isAvailable(): Promise<boolean>;
|
|
17
|
+
execute(task: Task, stream: TaskOutputStream, signal: AbortSignal): Promise<TaskResult>;
|
|
18
|
+
getStatus(): Promise<ProviderStatus>;
|
|
19
|
+
private runClaude;
|
|
20
|
+
/**
|
|
21
|
+
* Handle a single JSON line from Claude Code's stream-json output.
|
|
22
|
+
* Extracts human-readable text and structured events, forwarding only
|
|
23
|
+
* meaningful content to the stream (not raw JSON).
|
|
24
|
+
*/
|
|
25
|
+
private handleStreamLine;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=claude-code-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code-adapter.d.ts","sourceRoot":"","sources":["../../src/providers/claude-code-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAgB,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAG3F,qBAAa,iBAAkB,YAAW,eAAe;IACvD,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,IAAI,iBAAiB;IAE9B,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,iBAAiB,CAAC,CAAwB;IAE5C,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAS/B,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IA4DvF,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC;IAa1C,OAAO,CAAC,SAAS;IAgIjB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;CA0GzB"}
|