chatroom-cli 1.17.4 → 1.18.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/dist/index.js +77 -4
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -17174,6 +17174,64 @@ var init_on_daemon_shutdown = __esm(() => {
|
|
|
17174
17174
|
init_api3();
|
|
17175
17175
|
});
|
|
17176
17176
|
|
|
17177
|
+
// src/infrastructure/local-actions/execute-local-action.ts
|
|
17178
|
+
import { access as access2 } from "node:fs/promises";
|
|
17179
|
+
function resolveOpenCommand2(platform) {
|
|
17180
|
+
switch (platform) {
|
|
17181
|
+
case "darwin":
|
|
17182
|
+
return "open";
|
|
17183
|
+
case "win32":
|
|
17184
|
+
return "explorer";
|
|
17185
|
+
default:
|
|
17186
|
+
return "xdg-open";
|
|
17187
|
+
}
|
|
17188
|
+
}
|
|
17189
|
+
async function executeLocalAction(action, workingDir) {
|
|
17190
|
+
try {
|
|
17191
|
+
await access2(workingDir);
|
|
17192
|
+
} catch {
|
|
17193
|
+
return { success: false, error: `Directory not found: ${workingDir}` };
|
|
17194
|
+
}
|
|
17195
|
+
switch (action) {
|
|
17196
|
+
case "open-vscode": {
|
|
17197
|
+
const available = await isCliAvailable("code");
|
|
17198
|
+
if (!available) {
|
|
17199
|
+
return {
|
|
17200
|
+
success: false,
|
|
17201
|
+
error: "VS Code CLI (code) not found. Install via: VS Code → Cmd+Shift+P → 'Shell Command: Install code in PATH'"
|
|
17202
|
+
};
|
|
17203
|
+
}
|
|
17204
|
+
execFireAndForget(`code ${escapeShellArg(workingDir)}`, "open-vscode");
|
|
17205
|
+
return { success: true };
|
|
17206
|
+
}
|
|
17207
|
+
case "open-finder": {
|
|
17208
|
+
const cmd = resolveOpenCommand2(process.platform);
|
|
17209
|
+
execFireAndForget(`${cmd} ${escapeShellArg(workingDir)}`, "open-finder");
|
|
17210
|
+
return { success: true };
|
|
17211
|
+
}
|
|
17212
|
+
case "open-github-desktop": {
|
|
17213
|
+
const available = await isCliAvailable("github");
|
|
17214
|
+
if (!available) {
|
|
17215
|
+
return { success: false, error: "GitHub Desktop CLI not found" };
|
|
17216
|
+
}
|
|
17217
|
+
execFireAndForget(`github ${escapeShellArg(workingDir)}`, "open-github-desktop");
|
|
17218
|
+
return { success: true };
|
|
17219
|
+
}
|
|
17220
|
+
default: {
|
|
17221
|
+
const _exhaustive = action;
|
|
17222
|
+
return { success: false, error: `Unknown action: ${_exhaustive}` };
|
|
17223
|
+
}
|
|
17224
|
+
}
|
|
17225
|
+
}
|
|
17226
|
+
var init_execute_local_action = __esm(() => {
|
|
17227
|
+
init_shared_utils();
|
|
17228
|
+
});
|
|
17229
|
+
|
|
17230
|
+
// src/infrastructure/local-actions/index.ts
|
|
17231
|
+
var init_local_actions = __esm(() => {
|
|
17232
|
+
init_execute_local_action();
|
|
17233
|
+
});
|
|
17234
|
+
|
|
17177
17235
|
// src/commands/machine/daemon-start/command-loop.ts
|
|
17178
17236
|
async function refreshModels(ctx) {
|
|
17179
17237
|
if (!ctx.config)
|
|
@@ -17196,7 +17254,7 @@ async function refreshModels(ctx) {
|
|
|
17196
17254
|
console.warn(`[${formatTimestamp()}] ⚠️ Model refresh failed: ${getErrorMessage(error)}`);
|
|
17197
17255
|
}
|
|
17198
17256
|
}
|
|
17199
|
-
function evictStaleDedupEntries(processedCommandIds, processedPingIds, processedGitRefreshIds) {
|
|
17257
|
+
function evictStaleDedupEntries(processedCommandIds, processedPingIds, processedGitRefreshIds, processedLocalActionIds) {
|
|
17200
17258
|
const evictBefore = Date.now() - AGENT_REQUEST_DEADLINE_MS;
|
|
17201
17259
|
for (const [id, ts2] of processedCommandIds) {
|
|
17202
17260
|
if (ts2 < evictBefore)
|
|
@@ -17210,8 +17268,12 @@ function evictStaleDedupEntries(processedCommandIds, processedPingIds, processed
|
|
|
17210
17268
|
if (ts2 < evictBefore)
|
|
17211
17269
|
processedGitRefreshIds.delete(id);
|
|
17212
17270
|
}
|
|
17271
|
+
for (const [id, ts2] of processedLocalActionIds) {
|
|
17272
|
+
if (ts2 < evictBefore)
|
|
17273
|
+
processedLocalActionIds.delete(id);
|
|
17274
|
+
}
|
|
17213
17275
|
}
|
|
17214
|
-
async function dispatchCommandEvent(ctx, event, processedCommandIds, processedPingIds, processedGitRefreshIds) {
|
|
17276
|
+
async function dispatchCommandEvent(ctx, event, processedCommandIds, processedPingIds, processedGitRefreshIds, processedLocalActionIds) {
|
|
17215
17277
|
const eventId = event._id.toString();
|
|
17216
17278
|
if (event.type === "agent.requestStart") {
|
|
17217
17279
|
if (processedCommandIds.has(eventId))
|
|
@@ -17241,6 +17303,15 @@ async function dispatchCommandEvent(ctx, event, processedCommandIds, processedPi
|
|
|
17241
17303
|
ctx.lastPushedGitState.delete(stateKey);
|
|
17242
17304
|
console.log(`[${formatTimestamp()}] \uD83D\uDD04 Git refresh requested for ${event.workingDir}`);
|
|
17243
17305
|
await pushGitState(ctx);
|
|
17306
|
+
} else if (event.type === "daemon.localAction") {
|
|
17307
|
+
if (processedLocalActionIds.has(eventId))
|
|
17308
|
+
return;
|
|
17309
|
+
processedLocalActionIds.set(eventId, Date.now());
|
|
17310
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDDA5️ Local action: ${event.action} → ${event.workingDir}`);
|
|
17311
|
+
const result = await executeLocalAction(event.action, event.workingDir);
|
|
17312
|
+
if (!result.success) {
|
|
17313
|
+
console.warn(`[${formatTimestamp()}] ⚠️ Local action failed: ${result.error}`);
|
|
17314
|
+
}
|
|
17244
17315
|
}
|
|
17245
17316
|
}
|
|
17246
17317
|
async function startCommandLoop(ctx) {
|
|
@@ -17287,17 +17358,18 @@ Listening for commands...`);
|
|
|
17287
17358
|
const processedCommandIds = new Map;
|
|
17288
17359
|
const processedPingIds = new Map;
|
|
17289
17360
|
const processedGitRefreshIds = new Map;
|
|
17361
|
+
const processedLocalActionIds = new Map;
|
|
17290
17362
|
wsClient2.onUpdate(api.machines.getCommandEvents, {
|
|
17291
17363
|
sessionId: ctx.sessionId,
|
|
17292
17364
|
machineId: ctx.machineId
|
|
17293
17365
|
}, async (result) => {
|
|
17294
17366
|
if (!result.events || result.events.length === 0)
|
|
17295
17367
|
return;
|
|
17296
|
-
evictStaleDedupEntries(processedCommandIds, processedPingIds, processedGitRefreshIds);
|
|
17368
|
+
evictStaleDedupEntries(processedCommandIds, processedPingIds, processedGitRefreshIds, processedLocalActionIds);
|
|
17297
17369
|
for (const event of result.events) {
|
|
17298
17370
|
try {
|
|
17299
17371
|
console.log(`[${formatTimestamp()}] \uD83D\uDCE1 Stream command event: ${event.type} (id: ${event._id})`);
|
|
17300
|
-
await dispatchCommandEvent(ctx, event, processedCommandIds, processedPingIds, processedGitRefreshIds);
|
|
17372
|
+
await dispatchCommandEvent(ctx, event, processedCommandIds, processedPingIds, processedGitRefreshIds, processedLocalActionIds);
|
|
17301
17373
|
} catch (err) {
|
|
17302
17374
|
console.error(`[${formatTimestamp()}] ❌ Stream command event failed: ${getErrorMessage(err)}`);
|
|
17303
17375
|
}
|
|
@@ -17322,6 +17394,7 @@ var init_command_loop = __esm(() => {
|
|
|
17322
17394
|
init_api3();
|
|
17323
17395
|
init_on_daemon_shutdown();
|
|
17324
17396
|
init_client2();
|
|
17397
|
+
init_local_actions();
|
|
17325
17398
|
init_machine();
|
|
17326
17399
|
init_convex_error();
|
|
17327
17400
|
MODEL_REFRESH_INTERVAL_MS = 5 * 60 * 1000;
|