@alook/cli 0.0.6 → 0.0.7

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 CHANGED
@@ -13903,7 +13903,8 @@ var PollRequestSchema = exports_external.object({
13903
13903
  max_tasks: exports_external.number().int().min(1).default(1)
13904
13904
  });
13905
13905
  var PollResponseSchema = exports_external.object({
13906
- tasks: exports_external.array(TaskApiSchema)
13906
+ tasks: exports_external.array(TaskApiSchema),
13907
+ evicted: exports_external.boolean().optional()
13907
13908
  });
13908
13909
  var RegisterResponseSchema = exports_external.object({
13909
13910
  runtimes: exports_external.array(exports_external.object({ id: exports_external.string() }))
@@ -15659,7 +15660,7 @@ class DaemonClient {
15659
15660
  async poll(token, daemonId, maxTasks) {
15660
15661
  const raw = await this.request("POST", "/api/daemon/tasks/poll", token, { daemon_id: daemonId, max_tasks: maxTasks });
15661
15662
  const resp = PollResponseSchema.parse(raw);
15662
- return resp.tasks;
15663
+ return { tasks: resp.tasks, evicted: resp.evicted ?? false };
15663
15664
  }
15664
15665
  startTask(token, taskId) {
15665
15666
  return this.request("POST", `/api/daemon/tasks/${taskId}/start`, token);
@@ -16114,12 +16115,30 @@ async function startDaemon(profile, serverUrl) {
16114
16115
  }
16115
16116
  } catch {}
16116
16117
  }
16118
+ function evictWorkspace(workspaceId) {
16119
+ const idx = workspaceStates.findIndex((ws2) => ws2.workspaceId === workspaceId);
16120
+ if (idx === -1)
16121
+ return;
16122
+ const ws = workspaceStates[idx];
16123
+ for (const rid of ws.runtimeIds) {
16124
+ runtimeIndex.delete(rid);
16125
+ }
16126
+ workspaceStates.splice(idx, 1);
16127
+ health.setRuntimeCount(workspaceStates.reduce((sum, w) => sum + w.runtimeIds.length, 0));
16128
+ try {
16129
+ const cfg = loadCLIConfigForProfile(profile);
16130
+ cfg.watched_workspaces = (cfg.watched_workspaces || []).filter((w) => w.id !== workspaceId);
16131
+ saveCLIConfigForProfile(profile, cfg);
16132
+ } catch {}
16133
+ log.info(`Workspace ${workspaceId} evicted — runtimes removed server-side`);
16134
+ }
16117
16135
  const pollCycle = async () => {
16118
16136
  let remaining = config2.maxConcurrentTasks - activeTasks.size;
16119
16137
  if (remaining <= 0)
16120
16138
  return;
16121
16139
  const N = workspaceStates.length;
16122
16140
  const staggerMs = N > 1 ? Math.floor(config2.pollInterval / N) : 0;
16141
+ const evictedIds = [];
16123
16142
  for (let i = 0;i < N; i++) {
16124
16143
  if (remaining <= 0)
16125
16144
  break;
@@ -16128,8 +16147,12 @@ async function startDaemon(profile, serverUrl) {
16128
16147
  await new Promise((r) => setTimeout(r, staggerMs));
16129
16148
  }
16130
16149
  try {
16131
- const tasks = await client.poll(ws.token, config2.daemonId, remaining);
16132
- for (const apiTask of tasks) {
16150
+ const { tasks: apiTasks, evicted } = await client.poll(ws.token, config2.daemonId, remaining);
16151
+ if (evicted) {
16152
+ evictedIds.push(ws.workspaceId);
16153
+ continue;
16154
+ }
16155
+ for (const apiTask of apiTasks) {
16133
16156
  const task = fromApiTask(apiTask);
16134
16157
  syncAgentId(task.agentId, ws.workspaceId);
16135
16158
  activeTasks.add(task.id);
@@ -16143,6 +16166,13 @@ async function startDaemon(profile, serverUrl) {
16143
16166
  log.debug("Poll error", e);
16144
16167
  }
16145
16168
  }
16169
+ for (const id of evictedIds) {
16170
+ evictWorkspace(id);
16171
+ }
16172
+ if (workspaceStates.length === 0) {
16173
+ log.info("All workspaces evicted — shutting down");
16174
+ shutdown();
16175
+ }
16146
16176
  };
16147
16177
  const pollTimer = setInterval(pollCycle, config2.pollInterval);
16148
16178
  let shuttingDown = false;
@@ -13620,7 +13620,8 @@ var PollRequestSchema = exports_external.object({
13620
13620
  max_tasks: exports_external.number().int().min(1).default(1)
13621
13621
  });
13622
13622
  var PollResponseSchema = exports_external.object({
13623
- tasks: exports_external.array(TaskApiSchema)
13623
+ tasks: exports_external.array(TaskApiSchema),
13624
+ evicted: exports_external.boolean().optional()
13624
13625
  });
13625
13626
  var RegisterResponseSchema = exports_external.object({
13626
13627
  runtimes: exports_external.array(exports_external.object({ id: exports_external.string() }))
@@ -15379,7 +15380,7 @@ class DaemonClient {
15379
15380
  async poll(token, daemonId, maxTasks) {
15380
15381
  const raw = await this.request("POST", "/api/daemon/tasks/poll", token, { daemon_id: daemonId, max_tasks: maxTasks });
15381
15382
  const resp = PollResponseSchema.parse(raw);
15382
- return resp.tasks;
15383
+ return { tasks: resp.tasks, evicted: resp.evicted ?? false };
15383
15384
  }
15384
15385
  startTask(token, taskId) {
15385
15386
  return this.request("POST", `/api/daemon/tasks/${taskId}/start`, token);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alook/cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Alook CLI — register and run always-on AI coding agents.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/alookai/alook#readme",