@ipab/cli 0.1.0-rc.0 → 0.1.0-rc.1

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 (70) hide show
  1. package/README.md +7 -1
  2. package/dist/app-authoring.d.ts +1 -2
  3. package/dist/app-authoring.d.ts.map +1 -1
  4. package/dist/app-authoring.js +8 -9
  5. package/dist/app-authoring.js.map +1 -1
  6. package/dist/app-definition.d.ts +0 -6
  7. package/dist/app-definition.d.ts.map +1 -1
  8. package/dist/app-definition.js +1 -7
  9. package/dist/app-definition.js.map +1 -1
  10. package/dist/app-templates.d.ts.map +1 -1
  11. package/dist/app-templates.js +8 -0
  12. package/dist/app-templates.js.map +1 -1
  13. package/dist/authoring.d.ts +5 -14
  14. package/dist/authoring.d.ts.map +1 -1
  15. package/dist/authoring.js +10 -39
  16. package/dist/authoring.js.map +1 -1
  17. package/dist/builtins/template.node.car +0 -0
  18. package/dist/builtins/template.web-app.car +0 -0
  19. package/dist/builtins.d.ts.map +1 -1
  20. package/dist/builtins.js +5 -10
  21. package/dist/builtins.js.map +1 -1
  22. package/dist/cli.d.ts.map +1 -1
  23. package/dist/cli.js +124 -86
  24. package/dist/cli.js.map +1 -1
  25. package/dist/config.d.ts +3 -3
  26. package/dist/config.d.ts.map +1 -1
  27. package/dist/config.js +15 -17
  28. package/dist/config.js.map +1 -1
  29. package/dist/context.d.ts +1 -0
  30. package/dist/context.d.ts.map +1 -1
  31. package/dist/context.js +10 -0
  32. package/dist/context.js.map +1 -1
  33. package/dist/ipc.d.ts +2 -1
  34. package/dist/ipc.d.ts.map +1 -1
  35. package/dist/ipc.js +10 -1
  36. package/dist/ipc.js.map +1 -1
  37. package/dist/pins.d.ts +9 -9
  38. package/dist/pins.d.ts.map +1 -1
  39. package/dist/pins.js +10 -28
  40. package/dist/pins.js.map +1 -1
  41. package/dist/runtime.d.ts.map +1 -1
  42. package/dist/runtime.js +1 -1
  43. package/dist/runtime.js.map +1 -1
  44. package/dist/source-bundle.d.ts +0 -1
  45. package/dist/source-bundle.d.ts.map +1 -1
  46. package/dist/source-bundle.js +0 -1
  47. package/dist/source-bundle.js.map +1 -1
  48. package/dist/state.d.ts +20 -10
  49. package/dist/state.d.ts.map +1 -1
  50. package/dist/state.js +27 -16
  51. package/dist/state.js.map +1 -1
  52. package/dist/template-definition.d.ts +0 -17
  53. package/dist/template-definition.d.ts.map +1 -1
  54. package/dist/template-definition.js +1 -10
  55. package/dist/template-definition.js.map +1 -1
  56. package/package.json +10 -10
  57. package/src/app-authoring.ts +15 -13
  58. package/src/app-definition.ts +1 -7
  59. package/src/app-templates.ts +13 -0
  60. package/src/authoring.ts +22 -55
  61. package/src/builtins.ts +5 -11
  62. package/src/cli.ts +152 -107
  63. package/src/config.ts +21 -20
  64. package/src/context.ts +10 -0
  65. package/src/ipc.ts +8 -0
  66. package/src/pins.ts +14 -28
  67. package/src/runtime.ts +1 -0
  68. package/src/source-bundle.ts +0 -1
  69. package/src/state.ts +40 -26
  70. package/src/template-definition.ts +1 -10
package/src/cli.ts CHANGED
@@ -25,12 +25,7 @@ import {
25
25
  import { execute } from "./runtime.js";
26
26
  import { validatedBundle } from "./space.js";
27
27
  import { exactCid, pinName, State, type RunRecord } from "./state.js";
28
- import {
29
- buildBundle,
30
- initBundle,
31
- inspectBundle,
32
- importBundle,
33
- } from "./authoring.js";
28
+ import { buildBundle, inspectBundle, importBundle } from "./authoring.js";
34
29
  import { buildApp, initApp } from "./app-authoring.js";
35
30
  import { schemaAlias } from "./app-definition.js";
36
31
  import { addPin, deletePin, pinDetails, renamePin } from "./pins.js";
@@ -72,7 +67,6 @@ export const processIO: IO = {
72
67
  const commands: Record<string, string> = {
73
68
  init: "init NAME [DIR] [OPTIONS]",
74
69
  build: "build [DIR] [OPTIONS]",
75
- "bundle init": "bundle init TYPE DIR",
76
70
  "bundle build": "bundle build SOURCE [OPTIONS]",
77
71
  "bundle inspect": "bundle inspect SOURCE",
78
72
  "bundle import": "bundle import FILE.car",
@@ -80,7 +74,7 @@ const commands: Record<string, string> = {
80
74
  open: "open [--log] CONTENT",
81
75
  "pin add": "pin add NAME CID",
82
76
  "pin delete": "pin delete NAME",
83
- "pin list": "pin list [--kind bundle|schema] [--type TYPE]",
77
+ "pin list": "pin list [--type TYPE]",
84
78
  "pin show": "pin show NAME",
85
79
  "pin rename": "pin rename OLD_NAME NEW_NAME",
86
80
  "register list": "register list",
@@ -89,6 +83,8 @@ const commands: Record<string, string> = {
89
83
  "config get": "config get [KEY]",
90
84
  "config set": "config set KEY VALUE",
91
85
  "config reset": "config reset KEY",
86
+ "store usage": "store usage",
87
+ "store gc": "store gc",
92
88
  "history list": "history list [OPTIONS]",
93
89
  "history show": "history show RUN_ID",
94
90
  "history remove":
@@ -99,6 +95,7 @@ const groups: Record<string, string> = {
99
95
  pin: "Retain content and manage short names",
100
96
  register: "Associate content types with Apps",
101
97
  config: "Manage local configuration",
98
+ store: "Query local storage and collect unreferenced blocks",
102
99
  history: "View and remove execution history",
103
100
  };
104
101
  const commandHelp: Record<
@@ -111,8 +108,24 @@ const commandHelp: Record<
111
108
  notes?: string[];
112
109
  }
113
110
  > = {
111
+ "store usage": {
112
+ summary: "Query cached and recursively pinned block bytes",
113
+ examples: ["ipab store usage", "ipab --json store usage"],
114
+ notes: [
115
+ "Local Store only; excludes metadata, temporary files and disk allocation overhead.",
116
+ "Pinned DAGs include all descendants, with shared blocks counted once.",
117
+ ],
118
+ },
119
+ "store gc": {
120
+ summary: "Delete unprotected blocks from the entire selected local Store",
121
+ examples: ["ipab store gc", "ipab --json store gc"],
122
+ notes: [
123
+ "Preserves pins, all participating owners, pending operations and staged imports.",
124
+ "Does not unpin, clear history, delete unknown files or request Kubo daemon GC.",
125
+ ],
126
+ },
114
127
  init: {
115
- summary: "Create a private TypeScript App project",
128
+ summary: "Create files from a Template Bundle (default: Node App project)",
116
129
  arguments: ["NAME Project name; DIR defaults to NAME (new/empty only)."],
117
130
  options: [
118
131
  "--template TEMPLATE node (default), web-app, directory, CAR, CID or pin.",
@@ -145,15 +158,6 @@ const commandHelp: Record<
145
158
  "Store failures preserve the CAR; retry with ipab bundle import FILE.car.",
146
159
  ],
147
160
  },
148
- "bundle init": {
149
- summary: "Create content from a Bundle type",
150
- arguments: [
151
- "TYPE Definition file, type CAR, exact type CID or Schema pin.",
152
- "DIR New or empty destination directory.",
153
- ],
154
- examples: ["ipab bundle init types\\dist\\schema.car note"],
155
- notes: ["Writes .bundle.yaml, .bundle-ignore and the default entry."],
156
- },
157
161
  "bundle build": {
158
162
  summary: "Build a content or type CAR without compiling code",
159
163
  arguments: ["SOURCE Bundle directory or definition file."],
@@ -220,14 +224,14 @@ const commandHelp: Record<
220
224
  ],
221
225
  },
222
226
  "pin add": {
223
- summary: "Verify, retain and name content",
227
+ summary: "Verify, retain and name a Bundle",
224
228
  arguments: [
225
229
  "NAME Unused short name.",
226
- "CID Exact content CID, not another pin name.",
230
+ "CID Exact Bundle CID, not another pin name or a standalone type block.",
227
231
  ],
228
232
  examples: ["ipab pin add reader APP_CID"],
229
233
  notes: [
230
- "Verifies the full DAG and retains it in the configured Store.",
234
+ "Validates a complete Bundle and retains its full DAG in the configured Store.",
231
235
  "Does not execute or trust Apps, install dependencies or start a daemon.",
232
236
  "The builtin namespace is read-only.",
233
237
  ],
@@ -243,15 +247,12 @@ const commandHelp: Record<
243
247
  "pin list": {
244
248
  summary: "List user and built-in pins",
245
249
  options: [
246
- "--kind bundle|schema Filter by kind; omit to include ordinary content.",
247
- "--type TYPE Exact schema CID, Schema pin or builtin shortcut.",
248
- ],
249
- examples: [
250
- "ipab pin list",
251
- "ipab pin list --kind bundle --type builtin:node-app.v1",
250
+ "--type TYPE Exact type CID or the name of a Bundle pin of that type.",
252
251
  ],
252
+ examples: ["ipab pin list", "ipab pin list --type reader"],
253
253
  notes: [
254
- "Filters combine with AND. Unfinished user operations are reported separately.",
254
+ "Unfinished operations and legacy non-Bundle pins are reported separately.",
255
+ "Legacy retention is preserved; use pin delete to explicitly release it.",
255
256
  "Reads local registrations and packaged built-ins, not live node status.",
256
257
  ],
257
258
  },
@@ -300,21 +301,21 @@ const commandHelp: Record<
300
301
  "config get": {
301
302
  summary: "Show effective configuration",
302
303
  arguments: ["KEY Optional configuration key; omit to show all values."],
303
- examples: ["ipab config get", "ipab config get store.rpc"],
304
+ examples: ["ipab config get", "ipab config get store.gateway"],
304
305
  },
305
306
  "config set": {
306
307
  summary: "Save a local configuration value",
307
308
  examples: [
308
- "ipab config set store.rpc http://127.0.0.1:5001",
309
+ "ipab config set store.gateway http://127.0.0.1:8080",
309
310
  "ipab config set history.enabled false",
310
311
  ],
311
312
  notes: [
312
- "store.rpc is a Kubo RPC API URL, not a gateway; no daemon is started.",
313
+ "store.gateway is a read-only HTTP gateway; blocks, pins and GC remain local.",
313
314
  ],
314
315
  },
315
316
  "config reset": {
316
317
  summary: "Remove a saved configuration override",
317
- examples: ["ipab config reset store.rpc"],
318
+ examples: ["ipab config reset store.gateway"],
318
319
  },
319
320
  "history list": {
320
321
  summary: "List execution history",
@@ -363,7 +364,7 @@ const commandHelp: Record<
363
364
  export function help(path = ""): string {
364
365
  const globalOptions = `Global options (before COMMAND):
365
366
  --state-dir PATH Set the local state directory
366
- --store-rpc URL Use a Kubo RPC endpoint
367
+ --store-gateway URL Use a read-only upstream HTTP gateway
367
368
  --json Output management/development metadata, not App stdio`;
368
369
  const footer =
369
370
  "Full reference: https://github.com/silvermoon-work/ipab/blob/main/docs/reference.md";
@@ -385,6 +386,7 @@ Manage:
385
386
  pin ${groups.pin}
386
387
  register ${groups.register}
387
388
  config ${groups.config}
389
+ store ${groups.store}
388
390
  history ${groups.history}
389
391
 
390
392
  ${globalOptions}
@@ -461,6 +463,20 @@ function runDuration(record: Pick<RunRecord, "startedAt" | "endedAt">): string {
461
463
  return `${Math.floor(duration / 1000)}s`;
462
464
  }
463
465
 
466
+ function storageBytes(bytes: number): string {
467
+ const units = ["B", "KB", "MB", "GB", "TB", "PB"];
468
+ let scaled = bytes;
469
+ let unit = 0;
470
+ while (scaled >= 1000 && unit < units.length - 1) {
471
+ scaled /= 1000;
472
+ unit++;
473
+ }
474
+ const exact = bytes.toLocaleString("en-US");
475
+ return unit === 0
476
+ ? `${exact} bytes`
477
+ : `${scaled.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${units[unit]} (${exact} bytes)`;
478
+ }
479
+
464
480
  function table(headers: string[], rows: string[][], empty: string): string {
465
481
  if (!rows.length) return empty;
466
482
  const cells = rows.map((row) => row.map(printable));
@@ -566,12 +582,16 @@ export function parse(argv: readonly string[]): Parsed {
566
582
  };
567
583
  }
568
584
  if (flag === "--json") flags.json = true;
569
- else if (flag === "--state-dir" || flag === "--store-rpc") {
585
+ else if (flag === "--store-rpc")
586
+ syntax(
587
+ "Store RPC is no longer supported. Use --store-gateway with an HTTP gateway URL; existing Kubo pins are not migrated.",
588
+ );
589
+ else if (flag === "--state-dir" || flag === "--store-gateway") {
570
590
  const value = tokens.shift();
571
591
  if (!value || value.startsWith("-")) syntax(`${flag} needs a value.`);
572
592
  if (flag === "--state-dir") flags.stateDir = value;
573
593
  else {
574
- flags.storeRpc = publicUrl(value);
594
+ flags.storeGateway = publicUrl(value);
575
595
  }
576
596
  } else syntax(`Unknown global option "${flag}".`);
577
597
  }
@@ -601,7 +621,11 @@ export function parse(argv: readonly string[]): Parsed {
601
621
  return result;
602
622
  }
603
623
  if (!["open", "init", "build"].includes(group)) {
604
- if (!["bundle", "pin", "register", "config", "history"].includes(group))
624
+ if (
625
+ !["bundle", "pin", "register", "config", "history", "store"].includes(
626
+ group,
627
+ )
628
+ )
605
629
  syntax(`Unknown command "${group}".`);
606
630
  if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
607
631
  result.help = true;
@@ -640,7 +664,7 @@ export function parse(argv: readonly string[]): Parsed {
640
664
  : result.path === "history remove"
641
665
  ? ["app", "status", "since", "until"]
642
666
  : result.path === "pin list"
643
- ? ["kind", "type"]
667
+ ? ["type"]
644
668
  : [];
645
669
  while (tokens.length) {
646
670
  const value = tokens.shift()!;
@@ -666,7 +690,6 @@ export function parse(argv: readonly string[]): Parsed {
666
690
  const counts: Record<string, [number, number]> = {
667
691
  init: [1, 2],
668
692
  build: [0, 1],
669
- "bundle init": [2, 2],
670
693
  "bundle build": [1, 1],
671
694
  "bundle inspect": [1, 1],
672
695
  "bundle import": [1, 1],
@@ -682,6 +705,8 @@ export function parse(argv: readonly string[]): Parsed {
682
705
  "config get": [0, 1],
683
706
  "config set": [2, 2],
684
707
  "config reset": [1, 1],
708
+ "store usage": [0, 0],
709
+ "store gc": [0, 0],
685
710
  "history list": [0, 0],
686
711
  "history show": [1, 1],
687
712
  "history remove": [0, Number.MAX_SAFE_INTEGER],
@@ -712,13 +737,11 @@ export function parse(argv: readonly string[]): Parsed {
712
737
  if (result.path === "pin add") exactCid(result.positional[1]!);
713
738
  if (result.path === "pin rename") pinName(result.positional[1]!);
714
739
  }
715
- if (
716
- result.options.kind !== undefined &&
717
- !["bundle", "schema"].includes(String(result.options.kind))
718
- )
719
- syntax("--kind must be bundle or schema.");
720
740
  if (result.path.startsWith("config ") && result.positional[0]) {
721
- if (!(result.path === "config get" && result.positional[0] === "state-dir"))
741
+ if (
742
+ !(result.path === "config get" && result.positional[0] === "state-dir") &&
743
+ !(result.path === "config reset" && result.positional[0] === "store.rpc")
744
+ )
722
745
  configKey(result.positional[0]);
723
746
  if (result.path === "config set")
724
747
  parseValue(configKey(result.positional[0]), result.positional[1], true);
@@ -760,6 +783,18 @@ async function performCli(
760
783
  syntax("Non-interactive history remove requires --yes.");
761
784
  const builtins = await builtinContent();
762
785
  state = new State(stateLocation(parsed.flags, env).path, builtins.pins);
786
+ if (
787
+ parsed.path === "config reset" &&
788
+ parsed.positional[0] === "store.rpc"
789
+ ) {
790
+ state.resetConfig("store.rpc");
791
+ io.out(
792
+ parsed.flags.json
793
+ ? JSON.stringify({ reset: ["store.rpc"] })
794
+ : "Removed legacy store.rpc configuration. Existing Kubo pins and content are unchanged.",
795
+ );
796
+ return 0;
797
+ }
763
798
  const items = effectiveConfig(state.config(), parsed.flags, env);
764
799
  const value = (key: string) =>
765
800
  items.find((item) => item.key === key)!.value;
@@ -771,9 +806,26 @@ async function performCli(
771
806
  ? filters(state, parsed.options)
772
807
  : {};
773
808
  switch (parsed.path) {
809
+ case "store usage":
810
+ case "store gc": {
811
+ store = new IpfsStore(await storeConfiguration(value("store.gateway")));
812
+ if (parsed.path === "store usage") {
813
+ const result = await store.usage();
814
+ emit(
815
+ result,
816
+ `Cached blocks: ${storageBytes(result.cachedBytes)}\nPinned blocks (deduplicated): ${storageBytes(result.pinnedBytes)}`,
817
+ );
818
+ } else {
819
+ const result = await store.gc();
820
+ emit(
821
+ result,
822
+ `Removed ${result.removedBlocks} blocks; reclaimed ${storageBytes(result.reclaimedBytes)}.`,
823
+ );
824
+ }
825
+ break;
826
+ }
774
827
  case "init":
775
828
  case "build":
776
- case "bundle init":
777
829
  case "bundle build":
778
830
  case "bundle inspect":
779
831
  case "bundle import": {
@@ -792,7 +844,7 @@ async function performCli(
792
844
  try {
793
845
  let pendingStore: Promise<IpfsStore> | undefined;
794
846
  const getStore = () => {
795
- pendingStore ??= storeConfiguration(value("store.rpc")).then(
847
+ pendingStore ??= storeConfiguration(value("store.gateway")).then(
796
848
  (configuration) => {
797
849
  store = new IpfsStore(configuration);
798
850
  return store;
@@ -856,21 +908,19 @@ async function performCli(
856
908
  : {}),
857
909
  outputDir: String(value("bundle.outputDir")),
858
910
  })
859
- : parsed.path === "bundle init"
860
- ? await initBundle(source!, second!, request)
861
- : parsed.path === "bundle build"
862
- ? await buildBundle(source!, {
863
- ...request,
864
- schemaOnly: Boolean(parsed.options["schema-only"]),
865
- replace: Boolean(parsed.options.replace),
866
- ...(typeof parsed.options.output === "string"
867
- ? { output: parsed.options.output }
868
- : {}),
869
- outputDir: String(value("bundle.outputDir")),
870
- })
871
- : parsed.path === "bundle import"
872
- ? await importBundle(first!, getStore, request)
873
- : await inspectBundle(source!, request);
911
+ : parsed.path === "bundle build"
912
+ ? await buildBundle(source!, {
913
+ ...request,
914
+ schemaOnly: Boolean(parsed.options["schema-only"]),
915
+ replace: Boolean(parsed.options.replace),
916
+ ...(typeof parsed.options.output === "string"
917
+ ? { output: parsed.options.output }
918
+ : {}),
919
+ outputDir: String(value("bundle.outputDir")),
920
+ })
921
+ : parsed.path === "bundle import"
922
+ ? await importBundle(first!, getStore, request)
923
+ : await inspectBundle(source!, request);
874
924
  const importing = "output" in result && !parsed.options["no-import"];
875
925
  if (importing) {
876
926
  io.err("Importing build result into Store (without pinning)...");
@@ -894,33 +944,34 @@ async function performCli(
894
944
  if ("output" in result)
895
945
  emit(
896
946
  { ...result, imported: importing },
897
- `CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${"source" in result ? `\nSource CID: ${result.source.cid}\nSource CAR: ${result.source.output} (not imported or pinned)` : ""}\nStore: ${importing ? "imported (not pinned)" : "not imported (--no-import)"}`,
947
+ `CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${result.validation !== undefined ? `\nEntry validation: ${result.validation?.status ?? "not-applicable"}` : ""}${"source" in result ? `\nSource CID: ${result.source.cid}\nSource CAR: ${result.source.output} (not imported or pinned)` : ""}\nStore: ${importing ? "imported (not pinned)" : "not imported (--no-import)"}`,
898
948
  );
899
949
  else if (result.kind === "bundle-import")
900
950
  emit(
901
951
  result,
902
- `Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}`,
952
+ `Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}\nEntry validation: ${result.validation?.status ?? "not-applicable"}`,
903
953
  );
904
- else if (result.kind === "app-init") {
954
+ else if (result.kind === "project-init") {
905
955
  emit(
906
956
  result,
907
- `Created App project: ${result.directory}\nSchema CID: ${result.schemaCid}`,
908
- );
909
- io.err(
910
- `Next: install declared dependencies in ${JSON.stringify(result.directory)}; then ipab build ${JSON.stringify(result.directory)} (requires locally linked ipab).`,
911
- );
912
- } else if ("directory" in result) {
913
- emit(
914
- result,
915
- `Created: ${result.directory}\nSchema CID: ${result.schemaCid}\nEntry: ${result.entry.path} (${result.entry.contentType})`,
916
- );
917
- io.err(
918
- `Next: ipab bundle build ${JSON.stringify(result.directory)}`,
957
+ `Created project: ${result.directory}${result.templateCid ? `\nTemplate CID: ${result.templateCid}` : ""}`,
919
958
  );
959
+ if (
960
+ result.files.includes("package.json") &&
961
+ (result.files.includes("ipab.yaml") ||
962
+ result.files.includes("ipab.json"))
963
+ )
964
+ io.err(
965
+ `Next: install declared dependencies in ${JSON.stringify(result.directory)}; then ipab build ${JSON.stringify(result.directory)} (requires locally linked ipab).`,
966
+ );
967
+ else if (result.files.includes(".bundle.yaml"))
968
+ io.err(
969
+ `Next: ipab bundle build ${JSON.stringify(result.directory)}`,
970
+ );
920
971
  } else
921
972
  emit(
922
973
  result,
923
- `Kind: ${result.kind}\nName: ${printable(result.name)}\nSchema CID: ${result.schemaCid}\nEntry: ${result.entry.path} (${result.entry.contentType})\nValidation: passed`,
974
+ `Kind: ${result.kind}\nName: ${printable(result.name)}\nSchema CID: ${result.schemaCid}\nEntry: ${result.entry.path} (${result.entry.contentType})\nDefinition validation: passed\nStorage verification: ${result.validation.storage}\nEntry validation: ${result.validation.entry?.status ?? "not-applicable"}`,
924
975
  );
925
976
  } catch (cause) {
926
977
  if (cancelled)
@@ -938,58 +989,52 @@ async function performCli(
938
989
  break;
939
990
  }
940
991
  case "pin list": {
941
- if (typeof parsed.options.type === "string") {
942
- const named = state.pin(parsed.options.type);
943
- if (named && pinDetails(named).kind !== "schema")
944
- throw new HostError(
945
- "--type short names must identify a Schema pin.",
946
- );
947
- }
948
992
  const type =
949
993
  typeof parsed.options.type === "string"
950
- ? state.resolve(schemaAlias(parsed.options.type), true)
994
+ ? state.resolve(parsed.options.type, true)
951
995
  : undefined;
952
996
  const pins = state.pins();
953
997
  const listed = pins
954
- .filter((pin) => pin.status === "ready")
998
+ .filter(
999
+ (pin) => pin.status === "ready" && pin.metadata?.kind === "bundle",
1000
+ )
955
1001
  .map(pinDetails)
1002
+ .filter((pin) => type === undefined || pin.schemaCid === type);
1003
+ const invalid = pins
956
1004
  .filter(
957
- (pin) =>
958
- (!parsed.options.kind || pin.kind === parsed.options.kind) &&
959
- (type === undefined || pin.schemaCid === type),
960
- );
1005
+ (pin) => pin.status === "ready" && pin.metadata?.kind !== "bundle",
1006
+ )
1007
+ .map(({ name, cid, metadata }) => ({
1008
+ name,
1009
+ cid,
1010
+ kind: metadata?.kind,
1011
+ reason:
1012
+ "Not a Bundle pin; retention is preserved. Use pin delete to release it.",
1013
+ }));
961
1014
  const pending = pins
962
1015
  .filter((pin) => pin.status !== "ready")
963
1016
  .map(({ name, cid, status }) => ({ name, cid, status }));
964
- const legacyAliases = state.aliases();
965
1017
  if (pending.length)
966
1018
  io.err(
967
1019
  `Unfinished pin operations (not usable pins): ${JSON.stringify(pending)}. Retry pin add/delete.`,
968
1020
  );
969
- if (legacyAliases.length)
1021
+ if (invalid.length)
970
1022
  io.err(
971
- "Legacy Alias metadata is preserved but is not pinned. Use the listed exact CIDs with pin add to migrate.",
1023
+ `Legacy non-Bundle pins (not usable pins): ${JSON.stringify(invalid)}. Retention is unchanged; delete explicitly and wrap content in a Bundle before pinning again.`,
972
1024
  );
973
1025
  emit(
974
- { items: listed, pending, legacyAliases },
1026
+ { items: listed, pending, invalid },
975
1027
  table(
976
1028
  ["NAME", "CID", "KIND", "BUNDLE TYPE", "SOURCE"],
977
1029
  listed.map((pin) => [
978
1030
  pin.name,
979
1031
  pin.cid,
980
1032
  pin.kind,
981
- pin.typeName ?? "(no Bundle type metadata)",
1033
+ pin.typeName,
982
1034
  pin.builtin ? "built-in (read-only)" : "user",
983
1035
  ]),
984
1036
  "No named pins.",
985
- ) +
986
- (legacyAliases.length
987
- ? `\nLegacy Aliases (not pinned):\n${table(
988
- ["NAME", "CID"],
989
- legacyAliases.map((alias) => [alias.name, alias.cid]),
990
- "",
991
- )}`
992
- : ""),
1037
+ ),
993
1038
  );
994
1039
  break;
995
1040
  }
@@ -999,11 +1044,11 @@ async function performCli(
999
1044
  state,
1000
1045
  first!,
1001
1046
  second!,
1002
- await storeConfiguration(value("store.rpc")),
1047
+ await storeConfiguration(value("store.gateway")),
1003
1048
  );
1004
1049
  emit(
1005
1050
  result,
1006
- `${result.name} → ${result.cid}\nKind: ${result.kind}\nBundle type: ${printable(result.typeName ?? "(no Bundle type metadata)")}`,
1051
+ `${result.name} → ${result.cid}\nBundle type: ${printable(result.typeName)}`,
1007
1052
  );
1008
1053
  break;
1009
1054
  }
@@ -1024,7 +1069,7 @@ async function performCli(
1024
1069
  const result = pinDetails(pin);
1025
1070
  emit(
1026
1071
  result,
1027
- `Name: ${printable(result.name)}\nCID: ${result.cid}\nKind: ${result.kind}\nBundle type: ${printable(result.typeName ?? "(no Bundle type metadata)")}${result.schemaCid ? `\nSchema CID: ${result.schemaCid}` : ""}\nSource: ${result.builtin ? "built-in (read-only; content bundled with IPAB)" : "local registration (not live node verification)"}`,
1072
+ `Name: ${printable(result.name)}\nCID: ${result.cid}\nBundle type: ${printable(result.typeName)}\nSchema CID: ${result.schemaCid}\nSource: ${result.builtin ? "built-in (read-only; content bundled with IPAB)" : "local registration (not live node verification)"}`,
1028
1073
  );
1029
1074
  break;
1030
1075
  }
@@ -1191,7 +1236,7 @@ async function performCli(
1191
1236
  );
1192
1237
  const target = state.resolve(first!);
1193
1238
  await recoverInactive(state);
1194
- store = new IpfsStore(await storeConfiguration(value("store.rpc")));
1239
+ store = new IpfsStore(await storeConfiguration(value("store.gateway")));
1195
1240
  let appCid: string;
1196
1241
  let appArgv: string[];
1197
1242
  if (parsed.path === "open") {
package/src/config.ts CHANGED
@@ -5,7 +5,7 @@ import type { StoreConfiguration } from "@ipab/ipfs-store";
5
5
  import { HostError, object, syntax } from "./errors.js";
6
6
 
7
7
  export type ConfigKey =
8
- | "store.rpc"
8
+ | "store.gateway"
9
9
  | "history.enabled"
10
10
  | "history.limit"
11
11
  | "output.retention"
@@ -14,7 +14,7 @@ export type ConfigValue = string | boolean | number | null;
14
14
  export type Source = "flag" | "env" | "user" | "default";
15
15
  export interface GlobalOptions {
16
16
  stateDir?: string;
17
- storeRpc?: string;
17
+ storeGateway?: string;
18
18
  json: boolean;
19
19
  }
20
20
  export interface ConfigItem {
@@ -23,14 +23,14 @@ export interface ConfigItem {
23
23
  source: Source;
24
24
  }
25
25
  export const defaults: Record<ConfigKey, ConfigValue> = {
26
- "store.rpc": null,
26
+ "store.gateway": null,
27
27
  "history.enabled": true,
28
28
  "history.limit": 20,
29
29
  "output.retention": "history",
30
30
  "bundle.outputDir": "dist",
31
31
  };
32
32
  const environments: Record<ConfigKey, string> = {
33
- "store.rpc": "IPAB_STORE_RPC",
33
+ "store.gateway": "IPAB_STORE_GATEWAY",
34
34
  "history.enabled": "IPAB_HISTORY_ENABLED",
35
35
  "history.limit": "IPAB_HISTORY_LIMIT",
36
36
  "output.retention": "IPAB_OUTPUT_RETENTION",
@@ -77,9 +77,9 @@ export function parseValue(
77
77
  }
78
78
  if (key === "history.limit" && /^[1-9]\d*$/.test(value))
79
79
  value = Number(value);
80
- if (key === "store.rpc" && value === "default") return null;
80
+ if (key === "store.gateway" && value === "default") return null;
81
81
  }
82
- if (key === "store.rpc" && value === null) return null;
82
+ if (key === "store.gateway" && value === null) return null;
83
83
  if (
84
84
  key === "bundle.outputDir" &&
85
85
  typeof value === "string" &&
@@ -87,7 +87,8 @@ export function parseValue(
87
87
  !value.includes("\0")
88
88
  )
89
89
  return value;
90
- if (key === "store.rpc" && typeof value === "string") return publicUrl(value);
90
+ if (key === "store.gateway" && typeof value === "string")
91
+ return publicUrl(value);
91
92
  if (key === "history.enabled" && typeof value === "boolean") return value;
92
93
  if (
93
94
  key === "history.limit" &&
@@ -163,10 +164,14 @@ export function effectiveConfig(
163
164
  flags: GlobalOptions,
164
165
  env: NodeJS.ProcessEnv = process.env,
165
166
  ): ConfigItem[] {
167
+ if (env.IPAB_STORE_RPC !== undefined)
168
+ syntax(
169
+ "IPAB_STORE_RPC is no longer supported. Remove it and use IPAB_STORE_GATEWAY with an HTTP gateway URL.",
170
+ );
166
171
  const result = (Object.keys(defaults) as ConfigKey[]).map(
167
172
  (key): ConfigItem => {
168
173
  const variable = env[environments[key]];
169
- const flag = key === "store.rpc" ? flags.storeRpc : undefined;
174
+ const flag = key === "store.gateway" ? flags.storeGateway : undefined;
170
175
  // Invalid lower layers are not hidden by a higher-priority override.
171
176
  const environmental =
172
177
  variable === undefined ? undefined : parseValue(key, variable, true);
@@ -201,20 +206,16 @@ export function effectiveConfig(
201
206
  }
202
207
 
203
208
  export async function storeConfiguration(
204
- rpc: ConfigValue,
209
+ gateway: ConfigValue,
205
210
  ): Promise<StoreConfiguration> {
206
- const config =
207
- rpc === null
208
- ? await readContentConfiguration()
209
- : { backend: "kubo" as const, apiUrl: publicUrl(String(rpc)) };
210
- const urls =
211
- config.backend === "kubo"
212
- ? [config.apiUrl]
211
+ const config = await readContentConfiguration(
212
+ gateway === null ? {} : { gateway: publicUrl(String(gateway)) },
213
+ );
214
+ const urls = config.gateway
215
+ ? typeof config.gateway === "string"
216
+ ? [config.gateway]
213
217
  : config.gateway
214
- ? typeof config.gateway === "string"
215
- ? [config.gateway]
216
- : config.gateway
217
- : [];
218
+ : [];
218
219
  for (const url of urls) publicUrl(url);
219
220
  return config;
220
221
  }
package/src/context.ts CHANGED
@@ -3,6 +3,7 @@ import { CHUNK_BYTES, relativePath } from "./space.js";
3
3
 
4
4
  export interface AppContext {
5
5
  readonly appCid: string;
6
+ resolvePin(name: string): Promise<string | undefined>;
6
7
  readFile(
7
8
  rootCid: string,
8
9
  path: string,
@@ -126,6 +127,15 @@ export function createContext(port: Port): {
126
127
  }
127
128
  };
128
129
  const context: AppContext = {
130
+ async resolvePin(name) {
131
+ if (!name || name.length > 256)
132
+ throw new HostError("Pin name must contain 1..256 characters.");
133
+ const result = await rpc("resolvePin", name);
134
+ if (result === null) return undefined;
135
+ if (typeof result !== "string")
136
+ throw new HostError("Invalid pin lookup response.");
137
+ return result;
138
+ },
129
139
  get appCid() {
130
140
  if (!appCid)
131
141
  throw new HostError("IPAB context identity is not initialized.");
package/src/ipc.ts CHANGED
@@ -75,6 +75,9 @@ export class ContextServer {
75
75
  readonly output: OutputSpace,
76
76
  readonly fatal: (error: Error) => void,
77
77
  readonly appCid: string,
78
+ readonly resolvePin: (name: string) => string | undefined = () => {
79
+ throw new HostError("Pin lookup is unavailable in this context.");
80
+ },
78
81
  ) {
79
82
  child.on("message", this.receive);
80
83
  }
@@ -153,6 +156,11 @@ export class ContextServer {
153
156
  ): Promise<unknown> {
154
157
  signal.throwIfAborted();
155
158
  if (operation === "identity") return this.appCid;
159
+ if (operation === "resolvePin") {
160
+ if (typeof args !== "string" || !args || args.length > 256)
161
+ throw new HostError("Pin name must contain 1..256 characters.");
162
+ return this.resolvePin(args) ?? null;
163
+ }
156
164
  if (operation === "read") {
157
165
  if (this.reads.size + this.writes.size + this.openingReads >= 32)
158
166
  throw new HostError("Context stream capacity exceeded.");