@vendian/cli 0.0.16 → 0.0.18
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/cli-wrapper.mjs +138 -12
- package/package.json +1 -1
package/cli-wrapper.mjs
CHANGED
|
@@ -36675,21 +36675,27 @@ async function forwardToPythonVendian(args, { env: env3 = process.env, platform:
|
|
|
36675
36675
|
recordForwardedDocsCommand(args, code, { env: env3, platform: platform2 });
|
|
36676
36676
|
process.exitCode = code;
|
|
36677
36677
|
}
|
|
36678
|
-
async function preparePythonVendianInvocation(args, { env: env3 = process.env, platform: platform2 = process.platform } = {}) {
|
|
36678
|
+
async function preparePythonVendianInvocation(args, { env: env3 = process.env, platform: platform2 = process.platform, onProgress = null } = {}) {
|
|
36679
36679
|
const venvPath = managedVenvPath(env3, platform2);
|
|
36680
36680
|
const vendianPath = venvVendian(venvPath, platform2);
|
|
36681
|
+
reportProgress(onProgress, "Checking managed Python runtime");
|
|
36681
36682
|
if (!fs8.existsSync(vendianPath)) {
|
|
36682
36683
|
throw new Error("Vendian is not set up yet. Run `vendian login` first.");
|
|
36683
36684
|
}
|
|
36684
36685
|
const loadedConfig = loadConfig(env3, platform2);
|
|
36685
36686
|
const requiresPackageAccess = commandNeedsPackageAccess(args);
|
|
36687
|
+
if (requiresPackageAccess) {
|
|
36688
|
+
reportProgress(onProgress, "Refreshing package access");
|
|
36689
|
+
}
|
|
36686
36690
|
const refreshed = requiresPackageAccess ? await refreshPackageAccessFromCloudAuth({ config: loadedConfig, env: env3, platform: platform2 }) : { config: loadedConfig };
|
|
36687
|
-
maybeAutoUpdateManagedEnv({ env: env3, platform: platform2, venvPath });
|
|
36691
|
+
maybeAutoUpdateManagedEnv({ env: env3, platform: platform2, venvPath, onProgress });
|
|
36688
36692
|
const config = refreshed.config;
|
|
36693
|
+
reportProgress(onProgress, "Preparing package indexes");
|
|
36689
36694
|
const registry = registryConfig(config, env3, platform2);
|
|
36690
36695
|
if (requiresPackageAccess && !registry.token) {
|
|
36691
36696
|
throw new Error("Package access is missing. Run `vendian login` or `vendian update` before starting local agents.");
|
|
36692
36697
|
}
|
|
36698
|
+
reportProgress(onProgress, "Launching local serve daemon");
|
|
36693
36699
|
return {
|
|
36694
36700
|
command: vendianPath,
|
|
36695
36701
|
args,
|
|
@@ -36738,7 +36744,8 @@ function maybeAutoUpdateManagedEnv({
|
|
|
36738
36744
|
save = saveConfig,
|
|
36739
36745
|
installPackages = installVendianPackages,
|
|
36740
36746
|
refreshDocs = refreshAgentDocsWorkspaces,
|
|
36741
|
-
now = Date.now()
|
|
36747
|
+
now = Date.now(),
|
|
36748
|
+
onProgress = null
|
|
36742
36749
|
} = {}) {
|
|
36743
36750
|
if (env3.VENDIAN_SKIP_AUTO_UPDATE === "1") {
|
|
36744
36751
|
return false;
|
|
@@ -36760,10 +36767,13 @@ function maybeAutoUpdateManagedEnv({
|
|
|
36760
36767
|
if (log) {
|
|
36761
36768
|
console.error("[vendian] Checking managed CLI/runtime updates...");
|
|
36762
36769
|
}
|
|
36770
|
+
reportProgress(onProgress, "Installing managed CLI/runtime updates");
|
|
36763
36771
|
installPackages({ pythonPath, venvPath, config, env: env3, platform: platform2 });
|
|
36764
36772
|
const next = { ...config, lastManagedUpdateAt: new Date(now).toISOString() };
|
|
36765
36773
|
save(next, env3, platform2);
|
|
36774
|
+
reportProgress(onProgress, "Refreshing generated agent docs");
|
|
36766
36775
|
refreshDocs({ config: next, venvPath, env: env3, platform: platform2 });
|
|
36776
|
+
reportProgress(onProgress, "Managed CLI/runtime ready");
|
|
36767
36777
|
return true;
|
|
36768
36778
|
} catch (error) {
|
|
36769
36779
|
const message = error && typeof error.message === "string" ? error.message : String(error);
|
|
@@ -36773,13 +36783,18 @@ function maybeAutoUpdateManagedEnv({
|
|
|
36773
36783
|
return false;
|
|
36774
36784
|
}
|
|
36775
36785
|
}
|
|
36786
|
+
function reportProgress(onProgress, message) {
|
|
36787
|
+
if (typeof onProgress === "function") {
|
|
36788
|
+
onProgress(message);
|
|
36789
|
+
}
|
|
36790
|
+
}
|
|
36776
36791
|
|
|
36777
36792
|
// src/tui.js
|
|
36778
36793
|
import fs12 from "node:fs";
|
|
36779
36794
|
import readlinePromises from "node:readline/promises";
|
|
36780
36795
|
|
|
36781
36796
|
// src/version.js
|
|
36782
|
-
var CLI_VERSION = true ? "0.0.
|
|
36797
|
+
var CLI_VERSION = true ? "0.0.18" : process.env.npm_package_version || "0.0.0-dev";
|
|
36783
36798
|
|
|
36784
36799
|
// src/npm-update.js
|
|
36785
36800
|
var NPM_CHECK_INTERVAL_MS = 30 * 60 * 1e3;
|
|
@@ -37182,8 +37197,43 @@ function applyServeEvent(state, event) {
|
|
|
37182
37197
|
activity: "Daemon registered"
|
|
37183
37198
|
};
|
|
37184
37199
|
}
|
|
37200
|
+
if (event.type === "agent_prepare_plan") {
|
|
37201
|
+
const agentCount = Number(event.agentCount || 0);
|
|
37202
|
+
const environmentCount = Number(event.environmentCount || 0);
|
|
37203
|
+
return {
|
|
37204
|
+
...next,
|
|
37205
|
+
activity: `Analyzing ${agentCount} agent${agentCount === 1 ? "" : "s"}: ${environmentCount} dependency set${environmentCount === 1 ? "" : "s"}`
|
|
37206
|
+
};
|
|
37207
|
+
}
|
|
37185
37208
|
if (event.type === "agent_prepare_started") {
|
|
37186
|
-
|
|
37209
|
+
const relativePath = agentLabel(event);
|
|
37210
|
+
const timestamp = event.timestamp || (/* @__PURE__ */ new Date()).toISOString();
|
|
37211
|
+
return {
|
|
37212
|
+
...next,
|
|
37213
|
+
agentLogs: appendAgentLog(state.agentLogs, event),
|
|
37214
|
+
agentRunState: setAgentRunState(state.agentRunState, relativePath, {
|
|
37215
|
+
status: "preparing",
|
|
37216
|
+
lastEventAt: timestamp,
|
|
37217
|
+
progressMessage: "Preparing agent"
|
|
37218
|
+
}),
|
|
37219
|
+
activity: `Preparing ${relativePath}`
|
|
37220
|
+
};
|
|
37221
|
+
}
|
|
37222
|
+
if (event.type === "agent_prepare_progress") {
|
|
37223
|
+
const relativePath = agentLabel(event);
|
|
37224
|
+
const timestamp = event.timestamp || (/* @__PURE__ */ new Date()).toISOString();
|
|
37225
|
+
const message = stringValue(event.message || event.stage || "Preparing agent");
|
|
37226
|
+
return {
|
|
37227
|
+
...next,
|
|
37228
|
+
agentLogs: appendAgentLog(state.agentLogs, event),
|
|
37229
|
+
agentRunState: setAgentRunState(state.agentRunState, relativePath, {
|
|
37230
|
+
status: "preparing",
|
|
37231
|
+
lastEventAt: timestamp,
|
|
37232
|
+
progressStage: stringValue(event.stage),
|
|
37233
|
+
progressMessage: message
|
|
37234
|
+
}),
|
|
37235
|
+
activity: `${relativePath}: ${message}`
|
|
37236
|
+
};
|
|
37187
37237
|
}
|
|
37188
37238
|
if (event.type === "agent_prepare_completed") {
|
|
37189
37239
|
const isError = event.status === "error";
|
|
@@ -37197,10 +37247,16 @@ function applyServeEvent(state, event) {
|
|
|
37197
37247
|
lastEventAt: event.timestamp || (/* @__PURE__ */ new Date()).toISOString(),
|
|
37198
37248
|
disabledReason: stringValue(event.disabledReason || event.warning || "System dependency not met"),
|
|
37199
37249
|
resolutionHints: Array.isArray(event.resolutionHints) ? event.resolutionHints : []
|
|
37200
|
-
}) : state.agentRunState
|
|
37250
|
+
}) : setAgentRunState(state.agentRunState, agentLabel(event), {
|
|
37251
|
+
status: "ready",
|
|
37252
|
+
lastEventAt: event.timestamp || (/* @__PURE__ */ new Date()).toISOString(),
|
|
37253
|
+
progressMessage: null,
|
|
37254
|
+
progressStage: null
|
|
37255
|
+
});
|
|
37201
37256
|
const activityLabel = isError ? `${agentLabel(event)} needs setup` : isDisabled ? `${agentLabel(event)} disabled (deps not met locally)` : `${agentLabel(event)} ready`;
|
|
37202
37257
|
return {
|
|
37203
37258
|
...next,
|
|
37259
|
+
agentLogs: appendAgentLog(state.agentLogs, event),
|
|
37204
37260
|
activity: activityLabel,
|
|
37205
37261
|
agentRunState: runState,
|
|
37206
37262
|
errors: isError && event.error ? appendError(state.errors, agentLabel(event), event.error) : state.errors
|
|
@@ -37515,6 +37571,25 @@ function serveEventAgentLogEntry(event) {
|
|
|
37515
37571
|
}
|
|
37516
37572
|
};
|
|
37517
37573
|
}
|
|
37574
|
+
if (type === "agent_prepare_started" || type === "agent_prepare_progress" || type === "agent_prepare_completed") {
|
|
37575
|
+
const success = type === "agent_prepare_completed" ? event.status !== "error" : null;
|
|
37576
|
+
return {
|
|
37577
|
+
relativePath,
|
|
37578
|
+
entry: {
|
|
37579
|
+
timestamp,
|
|
37580
|
+
runId: "",
|
|
37581
|
+
eventType: type,
|
|
37582
|
+
level: event.status === "error" ? "error" : "info",
|
|
37583
|
+
message: agentPrepareLogMessage(event),
|
|
37584
|
+
stepId: stringValue(event.stage || type),
|
|
37585
|
+
current: null,
|
|
37586
|
+
total: null,
|
|
37587
|
+
success,
|
|
37588
|
+
error: event.error ?? null,
|
|
37589
|
+
jobType: null
|
|
37590
|
+
}
|
|
37591
|
+
};
|
|
37592
|
+
}
|
|
37518
37593
|
if (type === "process_exit" || type === "daemon_exit") {
|
|
37519
37594
|
const message = stringValue(event.message || processExitMessage(event));
|
|
37520
37595
|
return {
|
|
@@ -37548,6 +37623,9 @@ function agentRuntimeStatus(agent, agentRunState = {}) {
|
|
|
37548
37623
|
if (run2?.status === "running") {
|
|
37549
37624
|
return { status: "running", label: "running", run: run2 };
|
|
37550
37625
|
}
|
|
37626
|
+
if (run2?.status === "preparing") {
|
|
37627
|
+
return { status: "preparing", label: "preparing", run: run2 };
|
|
37628
|
+
}
|
|
37551
37629
|
if (run2?.status === "error" || inventoryStatus === "error") {
|
|
37552
37630
|
return { status: "error", label: "error", run: run2 };
|
|
37553
37631
|
}
|
|
@@ -37702,6 +37780,17 @@ function processExitMessage(event) {
|
|
|
37702
37780
|
}
|
|
37703
37781
|
return "Agent serve exited";
|
|
37704
37782
|
}
|
|
37783
|
+
function agentPrepareLogMessage(event) {
|
|
37784
|
+
if (event.type === "agent_prepare_started") {
|
|
37785
|
+
return "Preparing agent";
|
|
37786
|
+
}
|
|
37787
|
+
if (event.type === "agent_prepare_completed") {
|
|
37788
|
+
if (event.status === "error") return stringValue(event.error || event.errorMessage || "Agent setup failed");
|
|
37789
|
+
if (event.status === "disabled") return stringValue(event.warning || event.disabledReason || "Agent disabled locally");
|
|
37790
|
+
return "Agent ready";
|
|
37791
|
+
}
|
|
37792
|
+
return stringValue(event.message || event.stage || "Preparing agent");
|
|
37793
|
+
}
|
|
37705
37794
|
function textTail(value, limit = 800) {
|
|
37706
37795
|
const text = String(value || "").trim().replace(/\s+/g, " ");
|
|
37707
37796
|
return text.length > limit ? text.slice(-limit) : text;
|
|
@@ -37717,9 +37806,10 @@ async function spawnLocalServeEventStream({
|
|
|
37717
37806
|
agentsDir = "./agents",
|
|
37718
37807
|
collectionId = "",
|
|
37719
37808
|
env: env3 = process.env,
|
|
37720
|
-
platform: platform2 = process.platform
|
|
37809
|
+
platform: platform2 = process.platform,
|
|
37810
|
+
onProgress = null
|
|
37721
37811
|
} = {}) {
|
|
37722
|
-
const invocation = await preparePythonVendianInvocation(buildLocalServeEventStreamArgs({ agentsDir, collectionId }), { env: env3, platform: platform2 });
|
|
37812
|
+
const invocation = await preparePythonVendianInvocation(buildLocalServeEventStreamArgs({ agentsDir, collectionId }), { env: env3, platform: platform2, onProgress });
|
|
37723
37813
|
return spawn2(invocation.command, invocation.args, {
|
|
37724
37814
|
env: invocation.env,
|
|
37725
37815
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -38273,12 +38363,24 @@ function Header({ env: env3, platform: platform2, serveState, screen }) {
|
|
|
38273
38363
|
serveState?.daemonId && h(StatusRow, {
|
|
38274
38364
|
status: serveState.connected ? "ok" : "warning",
|
|
38275
38365
|
label: "Daemon",
|
|
38276
|
-
value: serveState
|
|
38366
|
+
value: serveHeaderLabel(serveState),
|
|
38277
38367
|
width: inner
|
|
38278
38368
|
}),
|
|
38279
38369
|
h(Text2, { color: colors.muted }, `${fig.bottomLeft}${fig.horizontal.repeat(inner)}${fig.bottomRight}`)
|
|
38280
38370
|
);
|
|
38281
38371
|
}
|
|
38372
|
+
function serveHeaderSnapshot(state) {
|
|
38373
|
+
return {
|
|
38374
|
+
connected: Boolean(state?.connected),
|
|
38375
|
+
daemonId: String(state?.daemonId || ""),
|
|
38376
|
+
stopped: Boolean(state?.stopped)
|
|
38377
|
+
};
|
|
38378
|
+
}
|
|
38379
|
+
function serveHeaderLabel(state) {
|
|
38380
|
+
if (state?.stopped) return "Stopped";
|
|
38381
|
+
if (state?.connected) return "Running";
|
|
38382
|
+
return "Starting";
|
|
38383
|
+
}
|
|
38282
38384
|
function StatusRow({ status, label, value, width }) {
|
|
38283
38385
|
const dotColor = status === "ok" ? colors.success : status === "warning" ? colors.warning : colors.error;
|
|
38284
38386
|
const dot = status === "ok" ? fig.dot : status === "warning" ? fig.dot : fig.dot;
|
|
@@ -38460,8 +38562,15 @@ function ServeScreen({ env: env3, platform: platform2, input, onBack, onState, o
|
|
|
38460
38562
|
const [startupError, setStartupError] = useState5("");
|
|
38461
38563
|
const exitTimer = useRef2(null);
|
|
38462
38564
|
const lastInterruptAt = useRef2(0);
|
|
38565
|
+
const lastPublishedHeaderState = useRef2(null);
|
|
38463
38566
|
useEffect6(() => {
|
|
38464
|
-
|
|
38567
|
+
const snapshot = serveHeaderSnapshot(state);
|
|
38568
|
+
const previous = lastPublishedHeaderState.current;
|
|
38569
|
+
if (previous && previous.daemonId === snapshot.daemonId && previous.connected === snapshot.connected && previous.stopped === snapshot.stopped) {
|
|
38570
|
+
return;
|
|
38571
|
+
}
|
|
38572
|
+
lastPublishedHeaderState.current = snapshot;
|
|
38573
|
+
onState(snapshot.daemonId ? snapshot : null);
|
|
38465
38574
|
}, [state, onState]);
|
|
38466
38575
|
useEffect6(() => () => {
|
|
38467
38576
|
if (exitTimer.current) {
|
|
@@ -38541,6 +38650,7 @@ function ServeScreen({ env: env3, platform: platform2, input, onBack, onState, o
|
|
|
38541
38650
|
setStarted(true);
|
|
38542
38651
|
setStartupError("");
|
|
38543
38652
|
try {
|
|
38653
|
+
setState((current) => ({ ...current, activity: "Loading previous agent logs" }));
|
|
38544
38654
|
const logStore = createServeLogStore({ agentsDir: serveRoot, collectionId, env: env3, platform: platform2 });
|
|
38545
38655
|
const historicalLogs = logStore.load();
|
|
38546
38656
|
if (historicalLogs.length > 0) {
|
|
@@ -38556,7 +38666,17 @@ function ServeScreen({ env: env3, platform: platform2, input, onBack, onState, o
|
|
|
38556
38666
|
};
|
|
38557
38667
|
});
|
|
38558
38668
|
}
|
|
38559
|
-
|
|
38669
|
+
setState((current) => ({ ...current, activity: "Preparing managed runtime" }));
|
|
38670
|
+
const nextChild = await spawnLocalServeEventStream({
|
|
38671
|
+
agentsDir: serveRoot,
|
|
38672
|
+
collectionId,
|
|
38673
|
+
env: env3,
|
|
38674
|
+
platform: platform2,
|
|
38675
|
+
onProgress: (message) => {
|
|
38676
|
+
setState((current) => ({ ...current, activity: message || "Preparing managed runtime" }));
|
|
38677
|
+
}
|
|
38678
|
+
});
|
|
38679
|
+
setState((current) => ({ ...current, activity: "Waiting for daemon events" }));
|
|
38560
38680
|
setChild(nextChild);
|
|
38561
38681
|
attachServeChild(nextChild, setState, setStartupError, ({ message } = {}) => {
|
|
38562
38682
|
setState((current) => current.stopped ? current : { ...current, stopped: true, activity: message ? "Runtime update required" : "Process exited" });
|
|
@@ -38815,6 +38935,7 @@ function DisabledAgentsFooter({ agents, agentRunState = {} }) {
|
|
|
38815
38935
|
}
|
|
38816
38936
|
function runtimeStatusColor(status) {
|
|
38817
38937
|
if (status === "running") return colors.accent;
|
|
38938
|
+
if (status === "preparing") return colors.brand;
|
|
38818
38939
|
if (status === "ready" || status === "completed") return colors.success;
|
|
38819
38940
|
if (status === "disabled") return colors.warning;
|
|
38820
38941
|
if (status === "error") return colors.error;
|
|
@@ -38822,6 +38943,7 @@ function runtimeStatusColor(status) {
|
|
|
38822
38943
|
}
|
|
38823
38944
|
function runtimeStatusIcon(status) {
|
|
38824
38945
|
if (status === "running") return fig.arrow;
|
|
38946
|
+
if (status === "preparing") return fig.dotEmpty;
|
|
38825
38947
|
if (status === "ready" || status === "completed") return fig.dot;
|
|
38826
38948
|
if (status === "disabled") return fig.warning;
|
|
38827
38949
|
if (status === "error") return fig.cross;
|
|
@@ -39276,6 +39398,7 @@ function attachServeChild(child, setState, setStartupError, onExit, logStore = n
|
|
|
39276
39398
|
buffer += chunk;
|
|
39277
39399
|
const lines = buffer.split(/\r?\n/);
|
|
39278
39400
|
buffer = lines.pop() || "";
|
|
39401
|
+
const events = [];
|
|
39279
39402
|
for (const line of lines) {
|
|
39280
39403
|
try {
|
|
39281
39404
|
const event = parseServeEventLine(line);
|
|
@@ -39284,12 +39407,15 @@ function attachServeChild(child, setState, setStartupError, onExit, logStore = n
|
|
|
39284
39407
|
logStore?.append(event);
|
|
39285
39408
|
} catch {
|
|
39286
39409
|
}
|
|
39287
|
-
|
|
39410
|
+
events.push(event);
|
|
39288
39411
|
}
|
|
39289
39412
|
} catch (error) {
|
|
39290
39413
|
setStartupError(`Invalid event stream payload: ${errorMessage2(error)}`);
|
|
39291
39414
|
}
|
|
39292
39415
|
}
|
|
39416
|
+
if (events.length > 0) {
|
|
39417
|
+
setState((current) => events.reduce((next, event) => applyServeEvent(next, event), current));
|
|
39418
|
+
}
|
|
39293
39419
|
});
|
|
39294
39420
|
child.stderr.setEncoding("utf8");
|
|
39295
39421
|
child.stderr.on("data", (chunk) => {
|