@hediet/linkrpc-cli 0.0.3-next.20260926.3 → 0.0.3-next.20260926.5

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.
@@ -24,7 +24,7 @@ import * as readline from "node:readline";
24
24
  import { emitKeypressEvents } from "node:readline";
25
25
  import { connectJsonRpcTransports, connectRawJsonRpcTransport, createNdjsonJsonRpcTransport, jsonRpcConnectionInterface } from "@hediet/linkrpc-infra/json-rpc";
26
26
  import { CapabilityProposalIssuer, candidatesForSlot, durationToExp } from "@hediet/linkrpc-hub/hub/server";
27
- import { GRAPH_INTERFACE_TAG, IMMUTABLE_GRAPH_INTERFACE_ID, ROOT_WATCH_INTERFACE_ID, isGraphRef, standardGraphRuntimeOptions, validateGraphInterfaceSchema } from "@hediet/linkrpc-infra/graph";
27
+ import { GRAPH_INTERFACE_TAG, IMMUTABLE_GRAPH_INTERFACE_ID, ROOT_WATCH_INTERFACE_ID, evaluateGraphPresentation, graphPresentationInterface, graphPresentationSchema, isGraphRef, standardGraphRuntimeOptions, validateGraphInterfaceSchema } from "@hediet/linkrpc-infra/graph";
28
28
  import React from "react";
29
29
  import { Box, Text, measureElement, render } from "ink";
30
30
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -3577,7 +3577,10 @@ async function discoverViewTargets(channel, view, options = {}) {
3577
3577
  });
3578
3578
  }
3579
3579
  return {
3580
- targets: targets.filter((target) => matchesTarget(target, view)).sort((a, b) => a.id.localeCompare(b.id)),
3580
+ targets: targets.filter((target) => matchesTarget(target, view)).map((target) => ({
3581
+ ...target,
3582
+ serviceInterfaces: listings.filter((listing) => listing.serviceId === target.serviceId && listing.discoveredFrom === target.discoveredFrom)
3583
+ })).sort((a, b) => a.id.localeCompare(b.id)),
3581
3584
  warnings
3582
3585
  };
3583
3586
  } finally {
@@ -3713,7 +3716,7 @@ function formatGraphTreeRows(lines, showObjectIds) {
3713
3716
  ancestors[line.depth] = line;
3714
3717
  ancestorIndices[line.depth] = index;
3715
3718
  const marker = line.targetKey !== void 0 ? "↪" : line.expandable ? line.expanded && line.loaded ? "▾" : "▸" : " ";
3716
- const content = line.ref === void 0 ? line.text.slice(line.key.length).replace(/^ = /, " ") : ` ${line.ref.kind}${showObjectIds ? `:${line.ref.id}` : ""}` + (line.summary === void 0 ? "" : ` ${line.summary}`) + (line.loaded ? "" : " [fetch on expand]") + (line.targetKey === void 0 ? "" : ` [link to ${line.targetKey}]`);
3719
+ const content = line.ref === void 0 ? line.text.slice(line.key.length).replace(/^ = /, " ") : ` ${line.ref.kind}${showObjectIds ? `:${line.ref.id}` : ""}` + (line.summary === void 0 ? "" : ` ${line.summary}`) + (line.description === void 0 ? "" : ` — ${line.description}`) + (line.loaded ? "" : " [fetch on expand]") + (line.targetKey === void 0 ? "" : ` [link to ${line.targetKey}]`);
3717
3720
  return `${line.depth === 0 ? "" : ancestorIndices.slice(1, line.depth).map((ancestor) => hasSibling[ancestor] ? "│ " : " ").join("") + (hasSibling[index] ? "├─ " : "└─ ")}${marker} ${label}${content}`;
3718
3721
  });
3719
3722
  }
@@ -4071,10 +4074,20 @@ var GraphLoader = class {
4071
4074
  }
4072
4075
  }
4073
4076
  };
4074
- function createGraphTree(root, cache, expanded, maxDepth = Number.POSITIVE_INFINITY) {
4077
+ function createGraphTree(root, cache, expanded, maxDepth = Number.POSITIVE_INFINITY, presentation) {
4075
4078
  const lines = [];
4076
4079
  appendRef(root, "$", 0, /* @__PURE__ */ new Set(), lines, /* @__PURE__ */ new Map(), cache, expanded, maxDepth, []);
4077
- return lines;
4080
+ if (presentation === void 0) return lines;
4081
+ return lines.map((line) => {
4082
+ if (line.ref === void 0 || !Object.hasOwn(presentation.rules, line.ref.kind)) return line;
4083
+ const result = evaluateGraphPresentation(line.ref, presentation, (ref) => cache.get(ref));
4084
+ return {
4085
+ ...line,
4086
+ summary: result.label,
4087
+ description: result.secondary,
4088
+ presentationPending: result.pending
4089
+ };
4090
+ });
4078
4091
  }
4079
4092
  function graphRefsInValue(value) {
4080
4093
  const refs = /* @__PURE__ */ new Map();
@@ -4273,15 +4286,17 @@ var GraphExplorerModel = class {
4273
4286
  _loader;
4274
4287
  _maxDepth;
4275
4288
  _timings;
4289
+ _presentation;
4276
4290
  _expanded = observableValue(this, /* @__PURE__ */ new Set());
4277
4291
  _expandedPaths = observableValue(this, /* @__PURE__ */ new Set(["$"]));
4278
4292
  _selectedKey = observableValue(this, "$");
4279
4293
  _cachedTree;
4280
- constructor(root, _loader, _maxDepth = Number.POSITIVE_INFINITY, state, _timings) {
4294
+ constructor(root, _loader, _maxDepth = Number.POSITIVE_INFINITY, state, _timings, _presentation) {
4281
4295
  this.root = root;
4282
4296
  this._loader = _loader;
4283
4297
  this._maxDepth = _maxDepth;
4284
4298
  this._timings = _timings;
4299
+ this._presentation = _presentation;
4285
4300
  const expanded = new Set(state?.expanded);
4286
4301
  if (state?.expandedPaths === void 0 || state.expandedPaths.has("$")) expanded.add(graphRefKey(root));
4287
4302
  else expanded.delete(graphRefKey(root));
@@ -4293,7 +4308,7 @@ var GraphExplorerModel = class {
4293
4308
  const size = this._loader.cache.size;
4294
4309
  const expanded = this._expanded.get();
4295
4310
  if (this._cachedTree?.size !== size || this._cachedTree.expanded !== expanded) {
4296
- const build = () => createGraphTree(this.root, this._loader.cache, expanded, this._maxDepth);
4311
+ const build = () => createGraphTree(this.root, this._loader.cache, expanded, this._maxDepth, this._presentation);
4297
4312
  this._cachedTree = {
4298
4313
  size,
4299
4314
  expanded,
@@ -4363,6 +4378,19 @@ var GraphExplorerModel = class {
4363
4378
  paths: ["/"]
4364
4379
  }] : []);
4365
4380
  await this._loader.load(needs);
4381
+ await this.loadPresentation();
4382
+ }
4383
+ async loadPresentation() {
4384
+ for (let round = 0; round < 32; round++) {
4385
+ const refs = this.lines.flatMap((line) => line.presentationPending ?? []);
4386
+ if (refs.length === 0) return;
4387
+ const before = this._loader.cache.size;
4388
+ await this._loader.load(refs.map((ref) => ({
4389
+ ref,
4390
+ paths: ["/"]
4391
+ })));
4392
+ if (this._loader.cache.size === before) return;
4393
+ }
4366
4394
  }
4367
4395
  select(index) {
4368
4396
  const line = this.lines[index];
@@ -4443,7 +4471,9 @@ async function loadGraphDepth(root, loader, depth) {
4443
4471
  function renderGraphTree(model, options = {}) {
4444
4472
  const selectedIndex = model.selectedIndex;
4445
4473
  return model.lines.map((line, index) => {
4446
- return `${options.selected === true ? index === selectedIndex ? "> " : " " : ""}${" ".repeat(line.depth)}${line.text}`;
4474
+ const cursor = options.selected === true ? index === selectedIndex ? "> " : " " : "";
4475
+ const presentation = [line.summary, line.description].filter((value) => value !== void 0).join(" — ");
4476
+ return `${cursor}${" ".repeat(line.depth)}${line.text}${presentation ? ` ${safeTerminalText(presentation)}` : ""}`;
4447
4477
  }).join("\n");
4448
4478
  }
4449
4479
  function renderGraphJson(root, loader) {
@@ -4566,11 +4596,26 @@ async function inspectGraphCommand(channel, options) {
4566
4596
  if (navigable && currentModel !== void 0) await currentModel.prefetchExpanded(ref);
4567
4597
  await loadGraphDepth(ref, loader, options.depth ?? (navigable ? 0 : 2));
4568
4598
  }
4599
+ const presentation = options.json || target.presentationMethod === void 0 ? void 0 : await withTimeout(async (signal) => {
4600
+ const call = channel.sendRequestWithStream(target.presentationMethod, {});
4601
+ const cancel = () => {
4602
+ call.cancel("graph presentation cancelled");
4603
+ call.dispose?.();
4604
+ };
4605
+ signal.addEventListener("abort", cancel, { once: true });
4606
+ try {
4607
+ return graphPresentationSchema.parse(await call.result);
4608
+ } finally {
4609
+ signal.removeEventListener("abort", cancel);
4610
+ call.dispose?.();
4611
+ }
4612
+ }, options.timeoutMs ?? 5e3, "graph presentation", cancellation.signal);
4569
4613
  const model = new GraphExplorerModel(ref, loader, navigable ? void 0 : options.depth, navigable ? currentModel === void 0 ? void 0 : {
4570
4614
  selectedKey: currentModel.selectedKey,
4571
4615
  expanded: currentModel.expandedKeys,
4572
4616
  expandedPaths: currentModel.expandedPaths
4573
- } : { expanded: new Set(loader.cache.have().map((item) => graphRefKey(item.ref))) }, timings);
4617
+ } : { expanded: new Set(loader.cache.have().map((item) => graphRefKey(item.ref))) }, timings, presentation);
4618
+ await model.loadPresentation();
4574
4619
  cancellation.signal.throwIfAborted();
4575
4620
  if (options.onModel !== void 0) await options.onModel(model, version);
4576
4621
  else if (terminal !== void 0) {
@@ -5378,6 +5423,7 @@ async function runGraphTui(context, roots, options) {
5378
5423
  //#region src/infra/graph/contribution.ts
5379
5424
  function resolveGraphRoots(context) {
5380
5425
  return context.interfaces.flatMap((listing) => {
5426
+ const presentation = (context.target.serviceInterfaces ?? context.target.interfaces).find((candidate) => candidate.serviceId === listing.serviceId && candidate.interfaceId === graphPresentationInterface.info.id && candidate.hash === graphPresentationInterface.toSchema().hash);
5381
5427
  const { roots, stores } = graphDescriptorsFromSchema({
5382
5428
  ...listing,
5383
5429
  hash: listing.hash ?? ""
@@ -5392,7 +5438,12 @@ function resolveGraphRoots(context) {
5392
5438
  graphInterfaceId: store.interfaceId,
5393
5439
  watchMethod: route(root.watchMethod),
5394
5440
  batchMethod: route(store.batchMethod),
5395
- valueArgument: store.valueArgument
5441
+ valueArgument: store.valueArgument,
5442
+ ...presentation === void 0 ? {} : { presentationMethod: presentation.isDefault ? "get" : [
5443
+ presentation.serviceId,
5444
+ presentation.interfaceId,
5445
+ "get"
5446
+ ].filter(Boolean).join("::") }
5396
5447
  };
5397
5448
  });
5398
5449
  });
@@ -7199,7 +7250,7 @@ Batch options:
7199
7250
  process.once("SIGINT", onSignal);
7200
7251
  process.once("SIGTERM", onSignal);
7201
7252
  try {
7202
- const { runApprovalUi } = await import("./runApprovalUi-CzPirGRo.js");
7253
+ const { runApprovalUi } = await import("./runApprovalUi-Kt6FnH9y.js");
7203
7254
  await runApprovalUi({
7204
7255
  client,
7205
7256
  signal: stop.signal
@@ -7214,7 +7265,7 @@ Batch options:
7214
7265
  registerViewCommands(program, (action) => withChannel(endpoint, getPrincipalSpec(), action));
7215
7266
  program.command("ui").description("Launch the terminal UI (form-based browser of services + methods).").action(async () => {
7216
7267
  const acquired = await acquireConnection(endpoint);
7217
- const { runUi } = await import("./runUi-DvI4Tq4L.js");
7268
+ const { runUi } = await import("./runUi-DD7DYroJ.js");
7218
7269
  try {
7219
7270
  await runUi({
7220
7271
  endpoint: acquired.ep,
@@ -7647,4 +7698,4 @@ function safeJson(value) {
7647
7698
  //#endregion
7648
7699
  export { formatCommandLegend as a, safeTerminalText as c, interfaceTarget as d, matchesTarget as f, dispatchHostKey as i, resolveViewTarget as l, approvalDetailLines as m, views as n, hostCommands as o, targetId as p, ViewFrame as r, matchesKey as s, runCli as t, formatCondition as u };
7649
7700
 
7650
- //# sourceMappingURL=cli-CGKufid3.js.map
7701
+ //# sourceMappingURL=cli-IfKpF0E1.js.map