kroki 1.0.3 → 1.0.4
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/bin/kroki.js +39 -3
- package/package.json +1 -1
package/bin/kroki.js
CHANGED
|
@@ -160,10 +160,18 @@ class RealtimeConnection {
|
|
|
160
160
|
|
|
161
161
|
if (onEvent) onEvent(envelope);
|
|
162
162
|
|
|
163
|
-
if (
|
|
163
|
+
if (
|
|
164
|
+
envelope.kind === 'chat_task_complete' ||
|
|
165
|
+
envelope.kind === 'workflow_complete' ||
|
|
166
|
+
envelope.kind === 'pair_approved'
|
|
167
|
+
) {
|
|
164
168
|
clearTimeout(timer);
|
|
165
169
|
this.ws.removeEventListener('message', handler);
|
|
166
170
|
resolve(envelope.payload);
|
|
171
|
+
} else if (envelope.kind === 'pair_rejected') {
|
|
172
|
+
clearTimeout(timer);
|
|
173
|
+
this.ws.removeEventListener('message', handler);
|
|
174
|
+
reject(new Error('Pairing request was rejected in Kroki browser.'));
|
|
167
175
|
} else if (envelope.kind === 'error') {
|
|
168
176
|
clearTimeout(timer);
|
|
169
177
|
this.ws.removeEventListener('message', handler);
|
|
@@ -227,6 +235,28 @@ Requires an active \x1b[33mUltra\x1b[0m plan.
|
|
|
227
235
|
const conn = new RealtimeConnection(payload);
|
|
228
236
|
await conn.connect();
|
|
229
237
|
|
|
238
|
+
console.log(`\x1b[33mWaiting for confirmation in Kroki browser (click "Разрешить")...\x1b[0m`);
|
|
239
|
+
|
|
240
|
+
const pairCmd = {
|
|
241
|
+
v: 1,
|
|
242
|
+
id: `pair-${Date.now()}`,
|
|
243
|
+
kind: 'pair_request',
|
|
244
|
+
targetDeviceId: payload.deviceId,
|
|
245
|
+
taskId: `pair-${Date.now()}`,
|
|
246
|
+
issuedAt: Date.now(),
|
|
247
|
+
payload: {
|
|
248
|
+
clientName: 'Antigravity CLI',
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
try {
|
|
253
|
+
await conn.sendCommand(pairCmd, undefined, 60000);
|
|
254
|
+
} catch (err) {
|
|
255
|
+
conn.close();
|
|
256
|
+
console.error(`\x1b[31m✖ ${err.message}\x1b[0m`);
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
|
|
230
260
|
saveActiveSession({
|
|
231
261
|
...payload,
|
|
232
262
|
pairedAt: Date.now(),
|
|
@@ -268,13 +298,19 @@ async function taskCommand(taskText) {
|
|
|
268
298
|
console.log(`\x1b[36m[Kroki: ${session.deviceName || 'Browser'}]\x1b[0m Running: "${taskText}"...`);
|
|
269
299
|
const result = await conn.sendCommand(command, ev => {
|
|
270
300
|
if (ev.kind === 'execution') {
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
301
|
+
const details = ev.payload?.data?.details || ev.payload?.title || ev.payload?.type;
|
|
302
|
+
if (details && typeof details === 'string') {
|
|
303
|
+
const firstLine = details.split('\n')[0].trim();
|
|
304
|
+
if (firstLine) console.log(` \x1b[90m→ ${firstLine.slice(0, 80)}\x1b[0m`);
|
|
305
|
+
}
|
|
273
306
|
}
|
|
274
307
|
});
|
|
275
308
|
|
|
276
309
|
console.log('\x1b[32m✔ Task completed.\x1b[0m');
|
|
277
310
|
if (result && typeof result === 'object') {
|
|
311
|
+
if (result.message) {
|
|
312
|
+
console.log(`\n\x1b[1m${result.message}\x1b[0m\n`);
|
|
313
|
+
}
|
|
278
314
|
console.log(JSON.stringify(result, null, 2));
|
|
279
315
|
}
|
|
280
316
|
} finally {
|