@nice-code/commander 0.81.0 → 0.83.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/build/cli.mjs CHANGED
@@ -149,7 +149,7 @@ function validStartStamp(value) {
149
149
  function isInstanceRecord(value) {
150
150
  if (value == null || typeof value !== "object" || Array.isArray(value)) return false;
151
151
  const record = value;
152
- return record.service === "nice-commander" && boundedString(record.instanceId) && boundedInt(record.generation, 0, Number.MAX_SAFE_INTEGER) && boundedInt(record.pid, 1, Number.MAX_SAFE_INTEGER) && boundedInt(record.port, 1, 65535) && boundedString(record.token) && boundedString(record.configKey) && boundedString(record.configRevisionHash) && boundedString(record.configPath) && boundedString(record.packageVersion) && boundedString(record.realmSchemaHash) && validStartStamp(record.startStamp) && record.protocolVersion === 3;
152
+ return record.service === "nice-commander" && boundedString(record.instanceId) && boundedInt(record.generation, 0, Number.MAX_SAFE_INTEGER) && boundedInt(record.pid, 1, Number.MAX_SAFE_INTEGER) && boundedInt(record.port, 1, 65535) && boundedString(record.token) && boundedString(record.configKey) && boundedString(record.configRevisionHash) && boundedString(record.configPath) && boundedString(record.packageVersion) && boundedString(record.realmSchemaHash) && validStartStamp(record.startStamp) && record.protocolVersion === 4;
153
153
  }
154
154
  async function writeInstanceRecord(path, record) {
155
155
  await mkdir(dirname(path), {
@@ -199,7 +199,7 @@ async function readSkewedInstanceRecord(path, expectedRealmSchemaHash) {
199
199
  if (!boundedInt(record["protocolVersion"], 0, Number.MAX_SAFE_INTEGER)) return null;
200
200
  if (!boundedInt(record["pid"], 1, Number.MAX_SAFE_INTEGER)) return null;
201
201
  if (!boundedInt(record["port"], 1, 65535)) return null;
202
- const sameProtocol = record["protocolVersion"] === 3;
202
+ const sameProtocol = record["protocolVersion"] === 4;
203
203
  const sameRealm = boundedString(record["realmSchemaHash"]) && record["realmSchemaHash"] === expectedRealmSchemaHash;
204
204
  if (sameProtocol && sameRealm) return null;
205
205
  return {
@@ -23093,6 +23093,7 @@ const commanderStatusRealm = defineRealm({
23093
23093
  avatars: { viewer: { persistentId: t.string() } },
23094
23094
  state: {
23095
23095
  generation: t.number(),
23096
+ configName: t.string(),
23096
23097
  configRevisionHash: t.string(),
23097
23098
  configError: t.array(t.string()),
23098
23099
  processes: t.record(t.id("processId"), t.object({
@@ -23108,6 +23109,11 @@ const commanderStatusRealm = defineRealm({
23108
23109
  endedAt: t.number(),
23109
23110
  durationMs: t.optional(t.number())
23110
23111
  })),
23112
+ recentRuns: t.array(t.object({
23113
+ startedAt: t.number(),
23114
+ endedAt: t.optional(t.number()),
23115
+ outcome: t.optional(t.union(t.literal("succeeded"), t.literal("failed"), t.literal("stopped"), t.literal("crashed"), t.literal("timedOut")))
23116
+ })),
23111
23117
  restarts: t.number(),
23112
23118
  lastExit: t.optional(t.object({
23113
23119
  code: t.optional(t.number()),
@@ -23131,6 +23137,7 @@ const commanderStatusRealm = defineRealm({
23131
23137
  cwd: t.string(),
23132
23138
  dependsOn: t.array(t.string()),
23133
23139
  ready: t.optional(t.string()),
23140
+ timeoutMs: t.optional(t.number()),
23134
23141
  endpoints: t.array(t.object({
23135
23142
  name: t.string(),
23136
23143
  protocol: t.string(),
@@ -23283,7 +23290,7 @@ var CommanderDaemonBootError = class extends Error {
23283
23290
  * a live dev environment, and an upgrade must never be the thing that kills one.
23284
23291
  */
23285
23292
  async function replaceSkewedDaemon(paths, skewed) {
23286
- const daemonLabel = `the daemon for this config (pid ${skewed.pid}, build ${skewed.packageVersion}, protocol v${skewed.protocolVersion}) predates this CLI (protocol v3${skewed.skew === "realm-schema" ? ", different status schema" : ""})`;
23293
+ const daemonLabel = `the daemon for this config (pid ${skewed.pid}, build ${skewed.packageVersion}, protocol v${skewed.protocolVersion}) predates this CLI (protocol v4${skewed.skew === "realm-schema" ? ", different status schema" : ""})`;
23287
23294
  let liveIds = [];
23288
23295
  try {
23289
23296
  liveIds = (await openProcessLedger({
@@ -23603,7 +23610,7 @@ async function findDaemon(config) {
23603
23610
  async function findSkewedDaemon(config) {
23604
23611
  const skewed = await readSkewedInstanceRecord(commanderStatePaths(resolveCommanderDataDir(), config.configKey).instanceRecordPath, commanderStatusRealm.schemaHash);
23605
23612
  if (skewed == null || !pidAlive$1(skewed.pid)) return null;
23606
- const difference = skewed.skew === "protocol" ? `speaks protocol v${skewed.protocolVersion}; this build speaks v3` : "was started before an upgrade changed the status schema";
23613
+ const difference = skewed.skew === "protocol" ? `speaks protocol v${skewed.protocolVersion}; this build speaks v4` : "was started before an upgrade changed the status schema";
23607
23614
  return {
23608
23615
  message: `the daemon for this config (pid ${skewed.pid}, port ${skewed.port}, build ${skewed.packageVersion}) ${difference} — this CLI (build ${await commanderPackageVersion()}) cannot talk to it. Run \`nice-commander shutdown\` (it stops a daemon from any build), then retry.`,
23609
23616
  pid: skewed.pid,
@@ -23699,7 +23706,7 @@ async function connectDaemon(handle) {
23699
23706
  const payload = await (await runtime.handleActionPayload(request)).waitForResultPayload();
23700
23707
  if (!payload.result.ok) throw new CliExit(EXIT.failure, `action "${action}" rejected by the daemon`);
23701
23708
  const report = parseActionReport(payload.result.output);
23702
- if (report == null) throw new CliExit(EXIT.failure, `the daemon answered "${action}" with something this CLI does not recognise — protocol ${record.protocolVersion} vs 3`);
23709
+ if (report == null) throw new CliExit(EXIT.failure, `the daemon answered "${action}" with something this CLI does not recognise — protocol ${record.protocolVersion} vs 4`);
23703
23710
  return report;
23704
23711
  },
23705
23712
  setEnv: async (input) => {
@@ -25059,7 +25066,7 @@ function renderTable(out, state) {
25059
25066
  String(proc.restarts),
25060
25067
  notesFor(proc, now)
25061
25068
  ]);
25062
- const head = `generation ${state.generation} · revision ${state.configRevisionHash}`;
25069
+ const head = `${state.configName} · generation ${state.generation} · revision ${state.configRevisionHash}`;
25063
25070
  const configError = state.configError.length > 0 ? `\nconfig error (last-good kept): ${state.configError[0]}` : "";
25064
25071
  return `${out.paint("gray", head)}\n${out.table([
25065
25072
  "ID",
@@ -25268,7 +25275,7 @@ async function withTimeout(ctx, run) {
25268
25275
  async function main() {
25269
25276
  const argv = process.argv.slice(2);
25270
25277
  if (argv[0] === "daemon") {
25271
- const { runCommanderDaemon } = await import("./main-DyR1LyM-.mjs");
25278
+ const { runCommanderDaemon } = await import("./main-BegwVMLM.mjs");
25272
25279
  return runCommanderDaemon(argv.slice(1));
25273
25280
  }
25274
25281
  const parsed = parseCliArgs(argv);