@gajae-gateway/cli 0.1.3 → 0.1.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/dist/main.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare function socketPath(home?: string | undefined): string;
10
10
  * never after, so the list is checked up front.
11
11
  */
12
12
  export declare const COMMANDS: readonly ["status", "shutdown", "chat", "daemon", "sessions", "ops", "memory", "monitors", "work", "services"];
13
- export declare const CLI_USAGE = "usage: gajaeway [--socket PATH] status|shutdown|chat|daemon run|sessions list [--json] [--fields a,b,c] [--limit N] [--offset N]|sessions inspect <originKey-or-index>|memory audit|memory search <query>|monitors ... (test <id> [--type T] [--payload J] [--wait[=SECONDS]])|work run|start <name> [--cwd DIR] [--resume] [--model ID|--preset NAME] <text>|work status <name>|work steer <name> <text>|work retire <name>|work jobs|ops backup <path>|ops redeliver <deliveryId>|ops redeliver --since <iso>|ops cycle [--json]|ops integrity|ops restore <backupPath>|ops restart-stack [--status]|services install|repair --bin-dir DIR [--launch-agents-dir DIR] [--unit-dir DIR] [--platform darwin|linux] (work run waits for a response; caller timeout does not end the attempt)";
13
+ export declare const CLI_USAGE = "usage: gajaeway [--socket PATH] status|shutdown|chat|daemon run|sessions list [--json] [--fields a,b,c] [--limit N] [--offset N]|sessions inspect <originKey-or-index>|memory audit|memory search <query>|monitors ... (test <id> [--type T] [--payload J] [--wait[=SECONDS]])|work run|start <name> [--cwd DIR] [--resume] [--model ID|--preset NAME] <text>|work status <name>|work steer <name> <text>|work retire [--force] <name>|work retire --all-dead|work jobs|ops backup <path>|ops redeliver <deliveryId>|ops redeliver --since <iso>|ops cycle [--json]|ops integrity|ops restore <backupPath>|ops restart-stack [--status]|services install|repair --bin-dir DIR [--launch-agents-dir DIR] [--unit-dir DIR] [--platform darwin|linux] (work run waits for a response; caller timeout does not end the attempt)";
14
14
  /** Usage errors exit 2, as `gajaeway-gateway` does; 1 stays a runtime failure. */
15
15
  export declare const USAGE_EXIT_CODE = 2;
16
16
  /** The usage text when `command` cannot be dispatched, undefined when it can. */
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAIX,cAAc,EAQd,MAAM,yBAAyB,CAAC;AAYjC,OAAO,EAEN,KAAK,oBAAoB,EAEzB,KAAK,iBAAiB,EAItB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,sBAAsB,EAAmB,KAAK,eAAe,EAAgB,MAAM,YAAY,CAAC;AAE9G,wBAAgB,UAAU,CAAC,IAAI,qBAA4B,GAAG,MAAM,CAEnE;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,gHAWX,CAAC;AAEX,eAAO,MAAM,SAAS,+vBACuuB,CAAC;AAE9vB,kFAAkF;AAClF,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,iFAAiF;AACjF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAExE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAQ9F;AAMD,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,iBAAiB,GAAG,WAAW,CAAC,CAAC;IAClF,oFAAoF;IACpF,QAAQ,CAAC,YAAY,CAAC,EAAE;QACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QACrD,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;KACtD,CAAC;CACF;AAED,MAAM,MAAM,cAAc,GAAG,SAAS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AkB,CA8B7E;AAqID;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,EAAE,CA+C3D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAE3D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAwB9D;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,SAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2B7E;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvF;AA8DD,wBAAsB,IAAI,CAAC,IAAI,WAAwB,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4ZjG"}
package/dist/main.js CHANGED
@@ -673,7 +673,7 @@ var COMMANDS = [
673
673
  "work",
674
674
  "services"
675
675
  ];
676
- var CLI_USAGE = "usage: gajaeway [--socket PATH] status|shutdown|chat|daemon run|sessions list [--json] [--fields a,b,c] [--limit N] [--offset N]|sessions inspect <originKey-or-index>|memory audit|memory search <query>|monitors ... (test <id> [--type T] [--payload J] [--wait[=SECONDS]])|work run|start <name> [--cwd DIR] [--resume] [--model ID|--preset NAME] <text>|work status <name>|work steer <name> <text>|work retire <name>|work jobs|ops backup <path>|ops redeliver <deliveryId>|ops redeliver --since <iso>|ops cycle [--json]|ops integrity|ops restore <backupPath>|ops restart-stack [--status]|services install|repair --bin-dir DIR [--launch-agents-dir DIR] [--unit-dir DIR] [--platform darwin|linux] (work run waits for a response; caller timeout does not end the attempt)";
676
+ var CLI_USAGE = "usage: gajaeway [--socket PATH] status|shutdown|chat|daemon run|sessions list [--json] [--fields a,b,c] [--limit N] [--offset N]|sessions inspect <originKey-or-index>|memory audit|memory search <query>|monitors ... (test <id> [--type T] [--payload J] [--wait[=SECONDS]])|work run|start <name> [--cwd DIR] [--resume] [--model ID|--preset NAME] <text>|work status <name>|work steer <name> <text>|work retire [--force] <name>|work retire --all-dead|work jobs|ops backup <path>|ops redeliver <deliveryId>|ops redeliver --since <iso>|ops cycle [--json]|ops integrity|ops restore <backupPath>|ops restart-stack [--status]|services install|repair --bin-dir DIR [--launch-agents-dir DIR] [--unit-dir DIR] [--platform darwin|linux] (work run waits for a response; caller timeout does not end the attempt)";
677
677
  var USAGE_EXIT_CODE = 2;
678
678
  function usageFor(command) {
679
679
  return command !== undefined && COMMANDS.includes(command) ? undefined : CLI_USAGE;
@@ -1259,20 +1259,55 @@ async function main(args = process.argv.slice(2), options = {}) {
1259
1259
  break;
1260
1260
  }
1261
1261
  if (command === "retire" || command === "jobs") {
1262
- if (command === "retire" ? args2.length !== 1 || !args2[0] || args2[0].startsWith("--") : args2.length !== 0)
1262
+ let force = false;
1263
+ let allDead = false;
1264
+ let name2;
1265
+ if (command === "retire") {
1266
+ for (let i = 0;i < args2.length; i++) {
1267
+ const arg = args2[i];
1268
+ if (arg === "--force") {
1269
+ if (force)
1270
+ throw new Error(usage2);
1271
+ force = true;
1272
+ } else if (arg === "--all-dead") {
1273
+ if (allDead)
1274
+ throw new Error(usage2);
1275
+ allDead = true;
1276
+ } else if (!arg.startsWith("--")) {
1277
+ if (name2)
1278
+ throw new Error(usage2);
1279
+ name2 = arg;
1280
+ } else
1281
+ throw new Error(usage2);
1282
+ }
1283
+ if (!allDead && !name2)
1284
+ throw new Error(usage2);
1285
+ if (allDead && name2)
1286
+ throw new Error(usage2);
1287
+ } else if (args2.length !== 0) {
1263
1288
  throw new Error(usage2);
1289
+ }
1264
1290
  const client2 = await GajaewayClient.connectSocket(parsed.socket);
1265
1291
  try {
1266
1292
  if (command === "retire") {
1267
- const result = await client2.request("work.retire", { name: args2[0] });
1268
- console.log(result.retired ? `retired: ${result.sessionKey} session=${result.sessionId} closed=${result.closed}` : `not retired: ${result.reason}`);
1293
+ const result = await client2.request("work.retire", {
1294
+ ...name2 !== undefined ? { name: name2 } : {},
1295
+ ...force ? { force } : {},
1296
+ ...allDead ? { allDead } : {}
1297
+ });
1298
+ if (allDead) {
1299
+ console.log(`Retired all dead lanes`);
1300
+ } else {
1301
+ const forced = result.retired && result.forced ? " (forced)" : "";
1302
+ console.log(result.retired ? `retired: ${result.sessionKey} session=${result.sessionId} closed=${result.closed}${forced}` : `not retired: ${result.reason}`);
1303
+ }
1269
1304
  } else {
1270
1305
  const result = await client2.request("work.jobs");
1271
1306
  for (const job of result.jobs) {
1272
- const name2 = job.lane_key.startsWith("work-") ? job.lane_key.slice("work-".length) : job.lane_key;
1307
+ const name3 = job.lane_key.startsWith("work-") ? job.lane_key.slice("work-".length) : job.lane_key;
1273
1308
  const state = job.quarantined ? `HELD: quarantined reason=${job.reason} historical_state=${job.state}` : job.state;
1274
1309
  const head = job.last_commit ? `${job.last_commit.sha.slice(0, 7)}@${job.last_commit.committed_at} ${JSON.stringify(job.last_commit.subject)}` : "-";
1275
- console.log(`${name2} ${state} session=${job.session_id || "-"} accepted=${job.accepted_at || "-"} op=${job.attempt?.op_ref || "-"} last=${job.last_activity_at || "-"} head=${head} ${job.worktree_path}${job.reports && (job.reports.pending !== 0 || job.reports.claimed !== 0 || job.reports.held !== 0 || job.reports.undeliverable !== 0) ? ` reports=p:${job.reports.pending} c:${job.reports.claimed} h:${job.reports.held} u:${job.reports.undeliverable}` : ""}`);
1310
+ console.log(`${name3} ${state} session=${job.session_id || "-"} accepted=${job.accepted_at || "-"} op=${job.attempt?.op_ref || "-"} last=${job.last_activity_at || "-"} head=${head} ${job.worktree_path}${job.reports && (job.reports.pending !== 0 || job.reports.claimed !== 0 || job.reports.held !== 0 || job.reports.undeliverable !== 0) ? ` reports=p:${job.reports.pending} c:${job.reports.claimed} h:${job.reports.held} u:${job.reports.undeliverable}` : ""}`);
1276
1311
  }
1277
1312
  }
1278
1313
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gajae-gateway/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "description": "Owner CLI for the gajaeway gateway: status, sessions, chat, monitors, and worker lanes over the gateway socket. Requires the Bun runtime (uses Bun.file/Bun.spawn).",
6
6
  "license": "AGPL-3.0-only",
@@ -41,8 +41,8 @@
41
41
  "prepublishOnly": "bun run build"
42
42
  },
43
43
  "dependencies": {
44
- "@gajae-gateway/sdk": "0.1.3",
45
- "@gajae-gateway/protocol": "0.1.3"
44
+ "@gajae-gateway/sdk": "0.1.4",
45
+ "@gajae-gateway/protocol": "0.1.4"
46
46
  },
47
47
  "engines": {
48
48
  "bun": ">=1.4.0"
package/src/main.ts CHANGED
@@ -61,7 +61,7 @@ export const COMMANDS = [
61
61
  ] as const;
62
62
 
63
63
  export const CLI_USAGE =
64
- "usage: gajaeway [--socket PATH] status|shutdown|chat|daemon run|sessions list [--json] [--fields a,b,c] [--limit N] [--offset N]|sessions inspect <originKey-or-index>|memory audit|memory search <query>|monitors ... (test <id> [--type T] [--payload J] [--wait[=SECONDS]])|work run|start <name> [--cwd DIR] [--resume] [--model ID|--preset NAME] <text>|work status <name>|work steer <name> <text>|work retire <name>|work jobs|ops backup <path>|ops redeliver <deliveryId>|ops redeliver --since <iso>|ops cycle [--json]|ops integrity|ops restore <backupPath>|ops restart-stack [--status]|services install|repair --bin-dir DIR [--launch-agents-dir DIR] [--unit-dir DIR] [--platform darwin|linux] (work run waits for a response; caller timeout does not end the attempt)";
64
+ "usage: gajaeway [--socket PATH] status|shutdown|chat|daemon run|sessions list [--json] [--fields a,b,c] [--limit N] [--offset N]|sessions inspect <originKey-or-index>|memory audit|memory search <query>|monitors ... (test <id> [--type T] [--payload J] [--wait[=SECONDS]])|work run|start <name> [--cwd DIR] [--resume] [--model ID|--preset NAME] <text>|work status <name>|work steer <name> <text>|work retire [--force] <name>|work retire --all-dead|work jobs|ops backup <path>|ops redeliver <deliveryId>|ops redeliver --since <iso>|ops cycle [--json]|ops integrity|ops restore <backupPath>|ops restart-stack [--status]|services install|repair --bin-dir DIR [--launch-agents-dir DIR] [--unit-dir DIR] [--platform darwin|linux] (work run waits for a response; caller timeout does not end the attempt)";
65
65
 
66
66
  /** Usage errors exit 2, as `gajaeway-gateway` does; 1 stays a runtime failure. */
67
67
  export const USAGE_EXIT_CODE = 2;
@@ -753,17 +753,46 @@ export async function main(args = process.argv.slice(2), options: MainOptions =
753
753
  break;
754
754
  }
755
755
  if (command === "retire" || command === "jobs") {
756
- if (command === "retire" ? args.length !== 1 || !args[0] || args[0].startsWith("--") : args.length !== 0)
756
+ let force = false;
757
+ let allDead = false;
758
+ let name: string | undefined;
759
+ if (command === "retire") {
760
+ for (let i = 0; i < args.length; i++) {
761
+ const arg = args[i];
762
+ if (arg === "--force") {
763
+ if (force) throw new Error(usage);
764
+ force = true;
765
+ } else if (arg === "--all-dead") {
766
+ if (allDead) throw new Error(usage);
767
+ allDead = true;
768
+ } else if (!arg.startsWith("--")) {
769
+ if (name) throw new Error(usage); // Already have a name, reject duplicate
770
+ name = arg;
771
+ } else throw new Error(usage);
772
+ }
773
+ if (!allDead && !name) throw new Error(usage);
774
+ if (allDead && name) throw new Error(usage);
775
+ } else if (args.length !== 0) {
757
776
  throw new Error(usage);
777
+ }
758
778
  const client = await GajaewayClient.connectSocket(parsed.socket);
759
779
  try {
760
780
  if (command === "retire") {
761
- const result = await client.request<WorkRetireResult>("work.retire", { name: args[0] });
762
- console.log(
763
- result.retired
764
- ? `retired: ${result.sessionKey} session=${result.sessionId} closed=${result.closed}`
765
- : `not retired: ${result.reason}`,
766
- );
781
+ const result = await client.request<WorkRetireResult>("work.retire", {
782
+ ...(name !== undefined ? { name } : {}),
783
+ ...(force ? { force } : {}),
784
+ ...(allDead ? { allDead } : {}),
785
+ });
786
+ if (allDead) {
787
+ console.log(`Retired all dead lanes`);
788
+ } else {
789
+ const forced = result.retired && result.forced ? " (forced)" : "";
790
+ console.log(
791
+ result.retired
792
+ ? `retired: ${result.sessionKey} session=${result.sessionId} closed=${result.closed}${forced}`
793
+ : `not retired: ${result.reason}`,
794
+ );
795
+ }
767
796
  } else {
768
797
  const result = await client.request<WorkJobsResult>("work.jobs");
769
798
  for (const job of result.jobs) {