@vendian/cli 0.0.19 → 0.0.21

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/cli-wrapper.mjs +135 -13
  2. package/package.json +1 -1
package/cli-wrapper.mjs CHANGED
@@ -35807,11 +35807,12 @@ function runCapture(command, args, options = {}) {
35807
35807
  shell: false,
35808
35808
  ...options
35809
35809
  });
35810
+ const errorMessage3 = result.error && typeof result.error.message === "string" ? result.error.message : "";
35810
35811
  return {
35811
- ok: result.status === 0,
35812
+ ok: !result.error && result.status === 0,
35812
35813
  status: result.status ?? 1,
35813
35814
  stdout: result.stdout || "",
35814
- stderr: result.stderr || ""
35815
+ stderr: result.stderr || errorMessage3
35815
35816
  };
35816
35817
  }
35817
35818
  function runInherit(command, args, options = {}) {
@@ -35916,10 +35917,12 @@ function verifyVendianImports(pythonPath) {
35916
35917
  import { spawnSync as spawnSync2 } from "node:child_process";
35917
35918
  var SERVICE = "Vendian CLI";
35918
35919
  var PACKAGE_TOKEN_ACCOUNT = "gitlab-package-token";
35920
+ var SECRET_STORE_TIMEOUT_MS = 5e3;
35919
35921
  function run(command, args, options = {}) {
35920
35922
  return spawnSync2(command, args, {
35921
35923
  encoding: "utf8",
35922
35924
  shell: false,
35925
+ timeout: SECRET_STORE_TIMEOUT_MS,
35923
35926
  ...options
35924
35927
  });
35925
35928
  }
@@ -36675,7 +36678,12 @@ async function forwardToPythonVendian(args, { env: env3 = process.env, platform:
36675
36678
  recordForwardedDocsCommand(args, code, { env: env3, platform: platform2 });
36676
36679
  process.exitCode = code;
36677
36680
  }
36678
- async function preparePythonVendianInvocation(args, { env: env3 = process.env, platform: platform2 = process.platform, onProgress = null } = {}) {
36681
+ async function preparePythonVendianInvocation(args, {
36682
+ env: env3 = process.env,
36683
+ platform: platform2 = process.platform,
36684
+ onProgress = null,
36685
+ skipAutoUpdate = false
36686
+ } = {}) {
36679
36687
  const venvPath = managedVenvPath(env3, platform2);
36680
36688
  const vendianPath = venvVendian(venvPath, platform2);
36681
36689
  reportProgress(onProgress, "Checking managed Python runtime");
@@ -36688,7 +36696,9 @@ async function preparePythonVendianInvocation(args, { env: env3 = process.env, p
36688
36696
  reportProgress(onProgress, "Refreshing package access");
36689
36697
  }
36690
36698
  const refreshed = requiresPackageAccess ? await refreshPackageAccessFromCloudAuth({ config: loadedConfig, env: env3, platform: platform2 }) : { config: loadedConfig };
36691
- maybeAutoUpdateManagedEnv({ env: env3, platform: platform2, venvPath, onProgress });
36699
+ if (!skipAutoUpdate) {
36700
+ maybeAutoUpdateManagedEnv({ env: env3, platform: platform2, venvPath, onProgress });
36701
+ }
36692
36702
  const config = refreshed.config;
36693
36703
  reportProgress(onProgress, "Preparing package indexes");
36694
36704
  const registry = registryConfig(config, env3, platform2);
@@ -36794,7 +36804,7 @@ import fs12 from "node:fs";
36794
36804
  import readlinePromises from "node:readline/promises";
36795
36805
 
36796
36806
  // src/version.js
36797
- var CLI_VERSION = true ? "0.0.19" : process.env.npm_package_version || "0.0.0-dev";
36807
+ var CLI_VERSION = true ? "0.0.21" : process.env.npm_package_version || "0.0.0-dev";
36798
36808
 
36799
36809
  // src/npm-update.js
36800
36810
  var NPM_CHECK_INTERVAL_MS = 30 * 60 * 1e3;
@@ -37002,6 +37012,34 @@ function findAgentDirectoryCandidates({
37002
37012
  function defaultAgentsDir(candidates = []) {
37003
37013
  return candidates[0]?.path || "./agents";
37004
37014
  }
37015
+ function findAgentFolders(root, {
37016
+ cwd: cwd2 = process.cwd(),
37017
+ maxDepth = 6,
37018
+ maxDirs = 1e3,
37019
+ limit = 100
37020
+ } = {}) {
37021
+ const start = path6.resolve(cwd2);
37022
+ const resolvedRoot = safeResolve(root || ".");
37023
+ if (!resolvedRoot) {
37024
+ return [];
37025
+ }
37026
+ const seen = /* @__PURE__ */ new Set();
37027
+ const folders = [];
37028
+ for (const manifest of findManifestFiles(resolvedRoot, { maxDepth, maxDirs, limit })) {
37029
+ const folder = path6.dirname(manifest);
37030
+ const resolved = safeResolve(folder);
37031
+ if (!resolved || seen.has(resolved)) {
37032
+ continue;
37033
+ }
37034
+ seen.add(resolved);
37035
+ folders.push({
37036
+ path: displayPath(resolved, start),
37037
+ absolutePath: resolved,
37038
+ name: path6.basename(resolved) || displayPath(resolved, start)
37039
+ });
37040
+ }
37041
+ return folders.sort((a, b) => a.path.localeCompare(b.path)).slice(0, limit);
37042
+ }
37005
37043
  function countAgentManifests(root, { maxDepth = 6, maxDirs = 1e3, limit = 100 } = {}) {
37006
37044
  let count = 0;
37007
37045
  for (const _manifest of findManifestFiles(root, { maxDepth, maxDirs, limit })) {
@@ -37730,10 +37768,12 @@ function reconcileInventoryRunState(agentRunState, agents, timestamp) {
37730
37768
  disabledReason: stringValue(agent.disabledReason || "System dependency not met locally"),
37731
37769
  resolutionHints: Array.isArray(agent.resolutionHints) ? agent.resolutionHints : []
37732
37770
  });
37733
- } else if (agent?.status === "online" && (current?.status === "error" || current?.status === "disabled") && !current?.runId) {
37771
+ } else if (agent?.status === "online" && ["preparing", "error", "disabled"].includes(current?.status) && !current?.runId) {
37734
37772
  next = setAgentRunState(next, path8, {
37735
37773
  status: "ready",
37736
37774
  lastEventAt: timestamp || (/* @__PURE__ */ new Date()).toISOString(),
37775
+ progressMessage: null,
37776
+ progressStage: null,
37737
37777
  errorMessage: null,
37738
37778
  disabledReason: null,
37739
37779
  resolutionHints: null
@@ -37957,10 +37997,21 @@ async function listCloudWorkspaces({
37957
37997
  env: env3 = process.env,
37958
37998
  platform: platform2 = process.platform,
37959
37999
  prepareInvocation = preparePythonVendianInvocation,
37960
- run: run2 = runCapture
38000
+ run: run2 = runCapture,
38001
+ onProgress = null,
38002
+ timeoutMs = 2e4
37961
38003
  } = {}) {
37962
- const invocation = await prepareInvocation(["cloud", "collections", "list", "--json"], { env: env3, platform: platform2 });
37963
- const result = run2(invocation.command, invocation.args, { env: invocation.env });
38004
+ const progress = typeof onProgress === "function" ? onProgress : () => {
38005
+ };
38006
+ progress("Checking managed Python runtime");
38007
+ const invocation = await prepareInvocation(["cloud", "collections", "list", "--json"], {
38008
+ env: env3,
38009
+ platform: platform2,
38010
+ onProgress: progress,
38011
+ skipAutoUpdate: true
38012
+ });
38013
+ progress("Loading workspaces from Vendian");
38014
+ const result = run2(invocation.command, invocation.args, { env: invocation.env, timeout: timeoutMs });
37964
38015
  if (!result.ok) {
37965
38016
  return {
37966
38017
  ok: false,
@@ -38565,6 +38616,7 @@ function ServeScreen({ env: env3, platform: platform2, input, onBack, onState, o
38565
38616
  const [selectingDir, setSelectingDir] = useState5(() => agentDirCandidates.length > 0);
38566
38617
  const [workspaceChoices, setWorkspaceChoices] = useState5([]);
38567
38618
  const [pendingAgentsDir, setPendingAgentsDir] = useState5("");
38619
+ const [serveScopeChoice, setServeScopeChoice] = useState5(null);
38568
38620
  const [loadingWorkspaces, setLoadingWorkspaces] = useState5(false);
38569
38621
  const [started, setStarted] = useState5(false);
38570
38622
  const [state, setState] = useState5(initialServeState());
@@ -38705,7 +38757,13 @@ function ServeScreen({ env: env3, platform: platform2, input, onBack, onState, o
38705
38757
  setStartupError("");
38706
38758
  setLoadingWorkspaces(true);
38707
38759
  try {
38708
- const result = await listCloudWorkspaces({ env: env3, platform: platform2 });
38760
+ const result = await listCloudWorkspaces({
38761
+ env: env3,
38762
+ platform: platform2,
38763
+ onProgress: (message) => {
38764
+ setState((current) => ({ ...current, activity: message || "Loading workspaces" }));
38765
+ }
38766
+ });
38709
38767
  if (!result.ok) {
38710
38768
  setStartupError(result.error || "Could not list workspaces.");
38711
38769
  return;
@@ -38721,7 +38779,68 @@ function ServeScreen({ env: env3, platform: platform2, input, onBack, onState, o
38721
38779
  setLoadingWorkspaces(false);
38722
38780
  }
38723
38781
  }
38782
+ function chooseServeScope(candidate) {
38783
+ if (!candidate || candidate.value === "__custom__" || candidate.value === "__back__") {
38784
+ return candidate?.value;
38785
+ }
38786
+ return chooseServePath(candidate.path, {
38787
+ absolutePath: candidate.absolutePath,
38788
+ agentCount: candidate.agentCount
38789
+ });
38790
+ }
38791
+ function chooseServePath(selectedPath, { absolutePath = selectedPath, agentCount = null } = {}) {
38792
+ const normalizedPath = selectedPath || "./agents";
38793
+ if (agentCount !== null && Number(agentCount || 0) <= 1) {
38794
+ chooseWorkspaceThenStart(normalizedPath);
38795
+ return "started";
38796
+ }
38797
+ const folders = findAgentFolders(absolutePath || normalizedPath);
38798
+ if (folders.length <= 1) {
38799
+ chooseWorkspaceThenStart(normalizedPath);
38800
+ return "started";
38801
+ }
38802
+ setServeScopeChoice({
38803
+ rootPath: normalizedPath,
38804
+ agentCount: agentCount ?? folders.length,
38805
+ folders
38806
+ });
38807
+ return "scope";
38808
+ }
38724
38809
  if (!started) {
38810
+ if (serveScopeChoice) {
38811
+ const scopeItems = [
38812
+ {
38813
+ label: `All agents in ${serveScopeChoice.rootPath} (${serveScopeChoice.agentCount} agents)`,
38814
+ value: serveScopeChoice.rootPath
38815
+ },
38816
+ ...serveScopeChoice.folders.map((folder) => ({
38817
+ label: `One: ${folder.path}`,
38818
+ value: folder.path
38819
+ })),
38820
+ { label: "Back", value: "__back__" }
38821
+ ];
38822
+ return h(
38823
+ Box2,
38824
+ { flexDirection: "column" },
38825
+ h(Text2, { bold: true }, "Serve one or many agents:"),
38826
+ h(SelectInput2, {
38827
+ items: scopeItems,
38828
+ onSelect: (item) => {
38829
+ if (item.value === "__back__") {
38830
+ setServeScopeChoice(null);
38831
+ return;
38832
+ }
38833
+ chooseWorkspaceThenStart(item.value);
38834
+ }
38835
+ }),
38836
+ h(Text2, null, ""),
38837
+ h(FooterBar, { items: [
38838
+ { key: "\u2191\u2193", label: "Navigate" },
38839
+ { key: "\u23CE", label: "Select" },
38840
+ { key: "esc", label: "Back" }
38841
+ ] })
38842
+ );
38843
+ }
38725
38844
  if (workspaceChoices.length > 1) {
38726
38845
  return h(
38727
38846
  Box2,
@@ -38754,7 +38873,10 @@ function ServeScreen({ env: env3, platform: platform2, input, onBack, onState, o
38754
38873
  const items = [
38755
38874
  ...agentDirCandidates.map((candidate) => ({
38756
38875
  label: `${candidate.path} (${candidate.agentCount} ${candidate.agentCount === 1 ? "agent" : "agents"})`,
38757
- value: candidate.path
38876
+ value: candidate.path,
38877
+ path: candidate.path,
38878
+ absolutePath: candidate.absolutePath,
38879
+ agentCount: candidate.agentCount
38758
38880
  })),
38759
38881
  { label: "Custom path", value: "__custom__" },
38760
38882
  { label: "Back", value: "__back__" }
@@ -38776,14 +38898,14 @@ function ServeScreen({ env: env3, platform: platform2, input, onBack, onState, o
38776
38898
  return;
38777
38899
  }
38778
38900
  setAgentsDir(item.value);
38779
- chooseWorkspaceThenStart(item.value);
38901
+ chooseServeScope(item);
38780
38902
  }
38781
38903
  }),
38782
38904
  !selectingDir && h(TextInput2, {
38783
38905
  value: agentsDir,
38784
38906
  placeholder: "./agents",
38785
38907
  onChange: setAgentsDir,
38786
- onSubmit: (value) => chooseWorkspaceThenStart(value)
38908
+ onSubmit: (value) => chooseServePath(value)
38787
38909
  }),
38788
38910
  loadingWorkspaces && h(
38789
38911
  Box2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendian/cli",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "Public Vendian CLI bootstrapper and launcher",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,