@spectratools/assembly-cli 0.4.0 → 0.4.3

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.
Files changed (2) hide show
  1. package/dist/cli.js +109 -33
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
+ import { realpathSync } from "fs";
4
5
  import { fileURLToPath } from "url";
5
6
  import { Cli as Cli6, z as z6 } from "incur";
6
7
 
@@ -26,6 +27,19 @@ function relTime(unixSeconds) {
26
27
  const label = h > 0 ? `${h}h ${m}m` : `${m}m`;
27
28
  return delta >= 0 ? `in ${label}` : `${label} ago`;
28
29
  }
30
+ function isoTime(unixSeconds) {
31
+ const ts = typeof unixSeconds === "bigint" ? Number(unixSeconds) : unixSeconds;
32
+ if (!Number.isFinite(ts) || ts <= 0) return "n/a";
33
+ try {
34
+ return new Date(ts * 1e3).toISOString().replace(".000Z", "Z");
35
+ } catch {
36
+ return "n/a";
37
+ }
38
+ }
39
+ function timeValue(unixSeconds, format) {
40
+ if (format === "json" || format === "jsonl") return isoTime(unixSeconds);
41
+ return typeof unixSeconds === "bigint" ? Number(unixSeconds) : unixSeconds;
42
+ }
29
43
  function asNum(value) {
30
44
  return Number(value);
31
45
  }
@@ -4313,6 +4327,7 @@ function createAssemblyPublicClient(rpcUrl) {
4313
4327
  var env = z.object({
4314
4328
  ABSTRACT_RPC_URL: z.string().optional().describe("Abstract RPC URL override")
4315
4329
  });
4330
+ var timestampOutput = z.union([z.number(), z.string()]);
4316
4331
  function decodeSeat(value) {
4317
4332
  const [owner, startAt, endAt, forfeited] = value;
4318
4333
  return { owner, startAt, endAt, forfeited };
@@ -4336,9 +4351,9 @@ council.command("seats", {
4336
4351
  z.object({
4337
4352
  id: z.number(),
4338
4353
  owner: z.string(),
4339
- startAt: z.number(),
4354
+ startAt: timestampOutput,
4340
4355
  startAtRelative: z.string(),
4341
- endAt: z.number(),
4356
+ endAt: timestampOutput,
4342
4357
  endAtRelative: z.string(),
4343
4358
  forfeited: z.boolean()
4344
4359
  })
@@ -4366,9 +4381,9 @@ council.command("seats", {
4366
4381
  seats.map((seat, idx) => ({
4367
4382
  id: idx,
4368
4383
  owner: toChecksum(seat.owner),
4369
- startAt: asNum(seat.startAt),
4384
+ startAt: timeValue(seat.startAt, c.format),
4370
4385
  startAtRelative: relTime(seat.startAt),
4371
- endAt: asNum(seat.endAt),
4386
+ endAt: timeValue(seat.endAt, c.format),
4372
4387
  endAtRelative: relTime(seat.endAt),
4373
4388
  forfeited: seat.forfeited
4374
4389
  }))
@@ -4384,8 +4399,8 @@ council.command("seat", {
4384
4399
  output: z.object({
4385
4400
  id: z.number(),
4386
4401
  owner: z.string(),
4387
- startAt: z.number(),
4388
- endAt: z.number(),
4402
+ startAt: timestampOutput,
4403
+ endAt: timestampOutput,
4389
4404
  forfeited: z.boolean(),
4390
4405
  endAtRelative: z.string()
4391
4406
  }),
@@ -4414,8 +4429,8 @@ council.command("seat", {
4414
4429
  return c.ok({
4415
4430
  id: c.args.id,
4416
4431
  owner: toChecksum(seat.owner),
4417
- startAt: asNum(seat.startAt),
4418
- endAt: asNum(seat.endAt),
4432
+ startAt: timeValue(seat.startAt, c.format),
4433
+ endAt: timeValue(seat.endAt, c.format),
4419
4434
  forfeited: seat.forfeited,
4420
4435
  endAtRelative: relTime(seat.endAt)
4421
4436
  });
@@ -4538,7 +4553,7 @@ council.command("auctions", {
4538
4553
  highestBidder: z.string(),
4539
4554
  highestBid: z.string(),
4540
4555
  settled: z.boolean(),
4541
- windowEnd: z.number(),
4556
+ windowEnd: timestampOutput,
4542
4557
  windowEndRelative: z.string(),
4543
4558
  status: z.enum(["bidding", "closed", "settled"])
4544
4559
  })
@@ -4604,7 +4619,7 @@ council.command("auctions", {
4604
4619
  highestBidder: toChecksum(auctions[i].highestBidder),
4605
4620
  highestBid: eth(auctions[i].highestBid),
4606
4621
  settled: auctions[i].settled,
4607
- windowEnd: asNum(windowEnd),
4622
+ windowEnd: timeValue(windowEnd, c.format),
4608
4623
  windowEndRelative: relTime(windowEnd),
4609
4624
  status: deriveAuctionStatus({
4610
4625
  settled: auctions[i].settled,
@@ -4639,7 +4654,7 @@ council.command("auction", {
4639
4654
  highestBidder: z.string(),
4640
4655
  highestBid: z.string(),
4641
4656
  settled: z.boolean(),
4642
- windowEnd: z.number(),
4657
+ windowEnd: timestampOutput,
4643
4658
  windowEndRelative: z.string(),
4644
4659
  status: z.enum(["bidding", "closed", "settled"])
4645
4660
  }),
@@ -4670,7 +4685,7 @@ council.command("auction", {
4670
4685
  highestBidder: toChecksum(auction.highestBidder),
4671
4686
  highestBid: eth(auction.highestBid),
4672
4687
  settled: auction.settled,
4673
- windowEnd: asNum(windowEndTimestamp),
4688
+ windowEnd: timeValue(windowEndTimestamp, c.format),
4674
4689
  windowEndRelative: relTime(windowEndTimestamp),
4675
4690
  status: deriveAuctionStatus({
4676
4691
  settled: auction.settled,
@@ -4778,6 +4793,7 @@ import { Cli as Cli2, z as z2 } from "incur";
4778
4793
  var env2 = z2.object({
4779
4794
  ABSTRACT_RPC_URL: z2.string().optional().describe("Abstract RPC URL override")
4780
4795
  });
4796
+ var timestampOutput2 = z2.union([z2.number(), z2.string()]);
4781
4797
  function decodeThread(value) {
4782
4798
  const [id, kind, author, createdAt, category, title, body, proposalId, petitionId] = value;
4783
4799
  return {
@@ -4841,7 +4857,7 @@ forum.command("threads", {
4841
4857
  id: z2.number(),
4842
4858
  kind: z2.number(),
4843
4859
  author: z2.string(),
4844
- createdAt: z2.number(),
4860
+ createdAt: timestampOutput2,
4845
4861
  createdAtRelative: z2.string(),
4846
4862
  category: z2.string().nullable().optional(),
4847
4863
  title: z2.string().nullable().optional()
@@ -4872,7 +4888,7 @@ forum.command("threads", {
4872
4888
  id: x.id,
4873
4889
  kind: x.kind,
4874
4890
  author: x.author,
4875
- createdAt: x.createdAt,
4891
+ createdAt: timeValue(x.createdAt, c.format),
4876
4892
  createdAtRelative: relTime(x.createdAt),
4877
4893
  category: x.category ?? null,
4878
4894
  title: x.title ?? null
@@ -5157,6 +5173,48 @@ import { Cli as Cli3, z as z3 } from "incur";
5157
5173
  var env3 = z3.object({
5158
5174
  ABSTRACT_RPC_URL: z3.string().optional().describe("Abstract RPC URL override")
5159
5175
  });
5176
+ var timestampOutput3 = z3.union([z3.number(), z3.string()]);
5177
+ var proposalStatusLabels = {
5178
+ 0: "pending",
5179
+ 1: "active",
5180
+ 2: "passed",
5181
+ 3: "executed",
5182
+ 4: "defeated",
5183
+ 5: "cancelled"
5184
+ };
5185
+ function proposalStatus(status) {
5186
+ const statusCode = asNum(status);
5187
+ return {
5188
+ status: proposalStatusLabels[statusCode] ?? `unknown-${statusCode}`,
5189
+ statusCode
5190
+ };
5191
+ }
5192
+ var proposalOutputSchema = z3.object({
5193
+ kind: z3.number(),
5194
+ configRiskTier: z3.number(),
5195
+ origin: z3.number(),
5196
+ status: z3.string(),
5197
+ statusCode: z3.number(),
5198
+ proposer: z3.string(),
5199
+ threadId: z3.number(),
5200
+ petitionId: z3.number(),
5201
+ createdAt: z3.number(),
5202
+ deliberationEndsAt: z3.number(),
5203
+ voteStartAt: z3.number(),
5204
+ voteEndAt: z3.number(),
5205
+ timelockEndsAt: z3.number(),
5206
+ activeSeatsSnapshot: z3.number(),
5207
+ forVotes: z3.string(),
5208
+ againstVotes: z3.string(),
5209
+ abstainVotes: z3.string(),
5210
+ amount: z3.string(),
5211
+ snapshotAssetBalance: z3.string(),
5212
+ transferIntent: z3.boolean(),
5213
+ intentDeadline: z3.number(),
5214
+ intentMaxRiskTier: z3.number(),
5215
+ title: z3.string(),
5216
+ description: z3.string()
5217
+ });
5160
5218
  function decodeProposal(value) {
5161
5219
  const [
5162
5220
  kind,
@@ -5210,11 +5268,13 @@ function decodeProposal(value) {
5210
5268
  };
5211
5269
  }
5212
5270
  function serializeProposal(proposal) {
5271
+ const status = proposalStatus(proposal.status);
5213
5272
  return {
5214
5273
  kind: asNum(proposal.kind),
5215
5274
  configRiskTier: asNum(proposal.configRiskTier),
5216
5275
  origin: asNum(proposal.origin),
5217
- status: asNum(proposal.status),
5276
+ status: status.status,
5277
+ statusCode: status.statusCode,
5218
5278
  proposer: proposal.proposer,
5219
5279
  threadId: asNum(proposal.threadId),
5220
5280
  petitionId: asNum(proposal.petitionId),
@@ -5247,9 +5307,10 @@ governance.command("proposals", {
5247
5307
  z3.object({
5248
5308
  id: z3.number(),
5249
5309
  kind: z3.number(),
5250
- status: z3.number(),
5310
+ status: z3.string(),
5311
+ statusCode: z3.number(),
5251
5312
  title: z3.string().nullable().optional(),
5252
- voteEndAt: z3.number(),
5313
+ voteEndAt: timestampOutput3,
5253
5314
  voteEndRelative: z3.string()
5254
5315
  })
5255
5316
  ),
@@ -5275,11 +5336,11 @@ governance.command("proposals", {
5275
5336
  }) : [];
5276
5337
  const proposals = proposalTuples.map(decodeProposal);
5277
5338
  const items = proposals.map((p, i) => ({
5339
+ ...proposalStatus(p.status),
5278
5340
  id: i + 1,
5279
5341
  kind: asNum(p.kind),
5280
- status: asNum(p.status),
5281
5342
  title: p.title ?? null,
5282
- voteEndAt: asNum(p.voteEndAt),
5343
+ voteEndAt: timeValue(p.voteEndAt, c.format),
5283
5344
  voteEndRelative: relTime(p.voteEndAt)
5284
5345
  }));
5285
5346
  return c.ok(
@@ -5305,7 +5366,7 @@ governance.command("proposal", {
5305
5366
  id: z3.coerce.number().int().positive().describe("Proposal id (1-indexed)")
5306
5367
  }),
5307
5368
  env: env3,
5308
- output: z3.record(z3.string(), z3.unknown()),
5369
+ output: proposalOutputSchema,
5309
5370
  examples: [{ args: { id: 1 }, description: "Fetch proposal #1" }],
5310
5371
  async run(c) {
5311
5372
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
@@ -5436,6 +5497,7 @@ var env4 = z4.object({
5436
5497
  ABSTRACT_RPC_URL: z4.string().optional().describe("Abstract RPC URL override"),
5437
5498
  ASSEMBLY_INDEXER_URL: z4.string().optional().describe("Optional members snapshot endpoint (default: theaiassembly.org indexer)")
5438
5499
  });
5500
+ var timestampOutput4 = z4.union([z4.number(), z4.string()]);
5439
5501
  var memberSnapshotSchema = z4.array(z4.string());
5440
5502
  var AssemblyApiValidationError = class extends Error {
5441
5503
  constructor(details) {
@@ -5550,9 +5612,9 @@ members.command("list", {
5550
5612
  address: z4.string(),
5551
5613
  active: z4.boolean(),
5552
5614
  registered: z4.boolean(),
5553
- activeUntil: z4.number(),
5615
+ activeUntil: timestampOutput4,
5554
5616
  activeUntilRelative: z4.string(),
5555
- lastHeartbeatAt: z4.number(),
5617
+ lastHeartbeatAt: timestampOutput4,
5556
5618
  lastHeartbeatRelative: z4.string()
5557
5619
  })
5558
5620
  ),
@@ -5620,9 +5682,9 @@ members.command("list", {
5620
5682
  address: toChecksum(address),
5621
5683
  active,
5622
5684
  registered: info.registered,
5623
- activeUntil: Number(info.activeUntil),
5685
+ activeUntil: timeValue(info.activeUntil, c.format),
5624
5686
  activeUntilRelative: relTime(info.activeUntil),
5625
- lastHeartbeatAt: Number(info.lastHeartbeatAt),
5687
+ lastHeartbeatAt: timeValue(info.lastHeartbeatAt, c.format),
5626
5688
  lastHeartbeatRelative: relTime(info.lastHeartbeatAt)
5627
5689
  };
5628
5690
  });
@@ -5641,8 +5703,8 @@ members.command("info", {
5641
5703
  output: z4.object({
5642
5704
  address: z4.string(),
5643
5705
  active: z4.boolean(),
5644
- activeUntil: z4.number(),
5645
- lastHeartbeatAt: z4.number(),
5706
+ activeUntil: timestampOutput4,
5707
+ lastHeartbeatAt: timestampOutput4,
5646
5708
  activeUntilRelative: z4.string(),
5647
5709
  lastHeartbeatRelative: z4.string()
5648
5710
  }),
@@ -5671,8 +5733,8 @@ members.command("info", {
5671
5733
  return c.ok({
5672
5734
  address: toChecksum(c.args.address),
5673
5735
  active,
5674
- activeUntil: Number(member.activeUntil),
5675
- lastHeartbeatAt: Number(member.lastHeartbeatAt),
5736
+ activeUntil: timeValue(member.activeUntil, c.format),
5737
+ lastHeartbeatAt: timeValue(member.lastHeartbeatAt, c.format),
5676
5738
  activeUntilRelative: relTime(member.activeUntil),
5677
5739
  lastHeartbeatRelative: relTime(member.lastHeartbeatAt)
5678
5740
  });
@@ -5748,6 +5810,7 @@ import { Cli as Cli5, z as z5 } from "incur";
5748
5810
  var env5 = z5.object({
5749
5811
  ABSTRACT_RPC_URL: z5.string().optional().describe("Abstract RPC URL override")
5750
5812
  });
5813
+ var timestampOutput5 = z5.union([z5.number(), z5.string()]);
5751
5814
  var treasury = Cli5.create("treasury", {
5752
5815
  description: "Inspect treasury balances, execution status, and spend controls."
5753
5816
  });
@@ -5802,7 +5865,7 @@ treasury.command("major-spend-status", {
5802
5865
  env: env5,
5803
5866
  output: z5.object({
5804
5867
  majorSpendCooldownSeconds: z5.number(),
5805
- lastMajorSpendAt: z5.number(),
5868
+ lastMajorSpendAt: timestampOutput5,
5806
5869
  lastMajorSpendRelative: z5.string(),
5807
5870
  isMajorSpendAllowed: z5.boolean()
5808
5871
  }),
@@ -5830,7 +5893,7 @@ treasury.command("major-spend-status", {
5830
5893
  ]);
5831
5894
  return c.ok({
5832
5895
  majorSpendCooldownSeconds: asNum(cooldown),
5833
- lastMajorSpendAt: asNum(lastMajorSpendAt),
5896
+ lastMajorSpendAt: timeValue(lastMajorSpendAt, c.format),
5834
5897
  lastMajorSpendRelative: relTime(lastMajorSpendAt),
5835
5898
  isMajorSpendAllowed: allowed
5836
5899
  });
@@ -6010,6 +6073,7 @@ cli.command(treasury);
6010
6073
  var rootEnv = z6.object({
6011
6074
  ABSTRACT_RPC_URL: z6.string().optional().describe("Abstract RPC URL override")
6012
6075
  });
6076
+ var timestampOutput6 = z6.union([z6.number(), z6.string()]);
6013
6077
  cli.command("status", {
6014
6078
  description: "Get a cross-contract Assembly snapshot (members, council, governance, treasury).",
6015
6079
  env: rootEnv,
@@ -6078,7 +6142,8 @@ cli.command("health", {
6078
6142
  output: z6.object({
6079
6143
  address: z6.string(),
6080
6144
  isActive: z6.boolean(),
6081
- activeUntil: z6.number(),
6145
+ activeUntil: timestampOutput6,
6146
+ activeUntilRelative: z6.string(),
6082
6147
  isCouncilMember: z6.boolean(),
6083
6148
  pendingReturnsWei: z6.string(),
6084
6149
  votingPower: z6.number()
@@ -6126,7 +6191,8 @@ cli.command("health", {
6126
6191
  return c.ok({
6127
6192
  address: toChecksum(c.args.address),
6128
6193
  isActive,
6129
- activeUntil: Number(member.activeUntil),
6194
+ activeUntil: timeValue(member.activeUntil, c.format),
6195
+ activeUntilRelative: relTime(member.activeUntil),
6130
6196
  isCouncilMember,
6131
6197
  pendingReturnsWei: pendingReturns.toString(),
6132
6198
  votingPower: Number(votingPower)
@@ -6134,7 +6200,17 @@ cli.command("health", {
6134
6200
  }
6135
6201
  });
6136
6202
  applyFriendlyErrorHandling(cli);
6137
- var isMain = process.argv[1] === fileURLToPath(import.meta.url);
6203
+ var isMain = (() => {
6204
+ const entrypoint = process.argv[1];
6205
+ if (!entrypoint) {
6206
+ return false;
6207
+ }
6208
+ try {
6209
+ return realpathSync(entrypoint) === realpathSync(fileURLToPath(import.meta.url));
6210
+ } catch {
6211
+ return false;
6212
+ }
6213
+ })();
6138
6214
  if (isMain) {
6139
6215
  cli.serve();
6140
6216
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectratools/assembly-cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.3",
4
4
  "description": "CLI for Assembly governance on Abstract (members, council, forum, proposals, and treasury).",
5
5
  "type": "module",
6
6
  "license": "MIT",