@vendian/cli 0.0.15 → 0.0.17
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 +243 -15
- 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.17" : 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;
|
|
@@ -37153,11 +37168,12 @@ function serveProcessExitMessage({ stderr = "", code = 0, signal = "" } = {}) {
|
|
|
37153
37168
|
if (/unrecognized arguments:\s*--event-stream/i.test(text)) {
|
|
37154
37169
|
return "Managed Vendian runtime is too old for the local serve dashboard. Run `vendian update`, then start Serve Agents again.";
|
|
37155
37170
|
}
|
|
37171
|
+
const detail = textTail(text);
|
|
37156
37172
|
if (code && code !== 0) {
|
|
37157
|
-
return `Local serve exited with code ${code}
|
|
37173
|
+
return `Local serve exited with code ${code}${detail ? `: ${detail}` : ""}`;
|
|
37158
37174
|
}
|
|
37159
37175
|
if (signal && signal !== "SIGINT" && signal !== "SIGTERM") {
|
|
37160
|
-
return `Local serve exited from ${signal}
|
|
37176
|
+
return `Local serve exited from ${signal}${detail ? `: ${detail}` : ""}`;
|
|
37161
37177
|
}
|
|
37162
37178
|
return "";
|
|
37163
37179
|
}
|
|
@@ -37181,8 +37197,43 @@ function applyServeEvent(state, event) {
|
|
|
37181
37197
|
activity: "Daemon registered"
|
|
37182
37198
|
};
|
|
37183
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: `Preparing ${agentCount} agent${agentCount === 1 ? "" : "s"} across ${environmentCount} dependency set${environmentCount === 1 ? "" : "s"}`
|
|
37206
|
+
};
|
|
37207
|
+
}
|
|
37184
37208
|
if (event.type === "agent_prepare_started") {
|
|
37185
|
-
|
|
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
|
+
};
|
|
37186
37237
|
}
|
|
37187
37238
|
if (event.type === "agent_prepare_completed") {
|
|
37188
37239
|
const isError = event.status === "error";
|
|
@@ -37196,10 +37247,16 @@ function applyServeEvent(state, event) {
|
|
|
37196
37247
|
lastEventAt: event.timestamp || (/* @__PURE__ */ new Date()).toISOString(),
|
|
37197
37248
|
disabledReason: stringValue(event.disabledReason || event.warning || "System dependency not met"),
|
|
37198
37249
|
resolutionHints: Array.isArray(event.resolutionHints) ? event.resolutionHints : []
|
|
37199
|
-
}) : 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
|
+
});
|
|
37200
37256
|
const activityLabel = isError ? `${agentLabel(event)} needs setup` : isDisabled ? `${agentLabel(event)} disabled (deps not met locally)` : `${agentLabel(event)} ready`;
|
|
37201
37257
|
return {
|
|
37202
37258
|
...next,
|
|
37259
|
+
agentLogs: appendAgentLog(state.agentLogs, event),
|
|
37203
37260
|
activity: activityLabel,
|
|
37204
37261
|
agentRunState: runState,
|
|
37205
37262
|
errors: isError && event.error ? appendError(state.errors, agentLabel(event), event.error) : state.errors
|
|
@@ -37296,6 +37353,22 @@ function applyServeEvent(state, event) {
|
|
|
37296
37353
|
jobsRun: Number(event.jobsRun ?? state.jobsRun)
|
|
37297
37354
|
};
|
|
37298
37355
|
}
|
|
37356
|
+
if (event.type === "process_exit" || event.type === "daemon_exit") {
|
|
37357
|
+
const timestamp = event.timestamp || (/* @__PURE__ */ new Date()).toISOString();
|
|
37358
|
+
const message = stringValue(event.message || processExitMessage(event));
|
|
37359
|
+
const relativePath = stringValue(event.relativePath || "");
|
|
37360
|
+
const runState = failRunningAgents(state.agentRunState, message, timestamp, relativePath);
|
|
37361
|
+
return {
|
|
37362
|
+
...next,
|
|
37363
|
+
stopped: true,
|
|
37364
|
+
connected: false,
|
|
37365
|
+
currentJob: null,
|
|
37366
|
+
activity: "Process exited",
|
|
37367
|
+
agentLogs: appendProcessExitAgentLogs(state.agentLogs, event, state.agentRunState, relativePath),
|
|
37368
|
+
agentRunState: runState,
|
|
37369
|
+
errors: appendError(state.errors, "Local daemon", message)
|
|
37370
|
+
};
|
|
37371
|
+
}
|
|
37299
37372
|
if (event.type === "run_log") {
|
|
37300
37373
|
const entry = serveEventAgentLogEntry(event);
|
|
37301
37374
|
const nextRunState = entry && entry.entry.eventType === "completion" ? setAgentRunState(state.agentRunState, entry.relativePath, {
|
|
@@ -37498,6 +37571,49 @@ function serveEventAgentLogEntry(event) {
|
|
|
37498
37571
|
}
|
|
37499
37572
|
};
|
|
37500
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
|
+
}
|
|
37593
|
+
if (type === "process_exit" || type === "daemon_exit") {
|
|
37594
|
+
const message = stringValue(event.message || processExitMessage(event));
|
|
37595
|
+
return {
|
|
37596
|
+
relativePath,
|
|
37597
|
+
entry: {
|
|
37598
|
+
timestamp,
|
|
37599
|
+
runId: stringValue(event.runId || event.sessionId || "daemon"),
|
|
37600
|
+
eventType: type,
|
|
37601
|
+
level: "error",
|
|
37602
|
+
message,
|
|
37603
|
+
stepId: null,
|
|
37604
|
+
current: null,
|
|
37605
|
+
total: null,
|
|
37606
|
+
success: false,
|
|
37607
|
+
error: {
|
|
37608
|
+
message,
|
|
37609
|
+
code: event.code ?? null,
|
|
37610
|
+
signal: event.signal ?? null,
|
|
37611
|
+
stderrTail: event.stderrTail ?? null
|
|
37612
|
+
},
|
|
37613
|
+
jobType: event.jobType ? stringValue(event.jobType) : null
|
|
37614
|
+
}
|
|
37615
|
+
};
|
|
37616
|
+
}
|
|
37501
37617
|
return null;
|
|
37502
37618
|
}
|
|
37503
37619
|
function agentRuntimeStatus(agent, agentRunState = {}) {
|
|
@@ -37507,6 +37623,9 @@ function agentRuntimeStatus(agent, agentRunState = {}) {
|
|
|
37507
37623
|
if (run2?.status === "running") {
|
|
37508
37624
|
return { status: "running", label: "running", run: run2 };
|
|
37509
37625
|
}
|
|
37626
|
+
if (run2?.status === "preparing") {
|
|
37627
|
+
return { status: "preparing", label: "preparing", run: run2 };
|
|
37628
|
+
}
|
|
37510
37629
|
if (run2?.status === "error" || inventoryStatus === "error") {
|
|
37511
37630
|
return { status: "error", label: "error", run: run2 };
|
|
37512
37631
|
}
|
|
@@ -37540,6 +37659,46 @@ function setAgentRunState(agentRunState, relativePath, patch) {
|
|
|
37540
37659
|
}
|
|
37541
37660
|
};
|
|
37542
37661
|
}
|
|
37662
|
+
function failRunningAgents(agentRunState, message, timestamp, relativePath = "") {
|
|
37663
|
+
let next = agentRunState || {};
|
|
37664
|
+
for (const [path8, run2] of Object.entries(agentRunState || {})) {
|
|
37665
|
+
if (run2?.status !== "running") continue;
|
|
37666
|
+
next = setAgentRunState(next, path8, {
|
|
37667
|
+
status: "error",
|
|
37668
|
+
completedAt: timestamp,
|
|
37669
|
+
lastEventAt: timestamp,
|
|
37670
|
+
errorMessage: message
|
|
37671
|
+
});
|
|
37672
|
+
}
|
|
37673
|
+
if (relativePath) {
|
|
37674
|
+
next = setAgentRunState(next, relativePath, {
|
|
37675
|
+
status: "error",
|
|
37676
|
+
completedAt: timestamp,
|
|
37677
|
+
lastEventAt: timestamp,
|
|
37678
|
+
errorMessage: message
|
|
37679
|
+
});
|
|
37680
|
+
}
|
|
37681
|
+
return next;
|
|
37682
|
+
}
|
|
37683
|
+
function appendProcessExitAgentLogs(agentLogs, event, agentRunState, relativePath = "") {
|
|
37684
|
+
const paths = /* @__PURE__ */ new Set();
|
|
37685
|
+
if (relativePath) {
|
|
37686
|
+
paths.add(relativePath);
|
|
37687
|
+
}
|
|
37688
|
+
for (const [path8, run2] of Object.entries(agentRunState || {})) {
|
|
37689
|
+
if (run2?.status === "running") {
|
|
37690
|
+
paths.add(path8);
|
|
37691
|
+
}
|
|
37692
|
+
}
|
|
37693
|
+
if (paths.size === 0) {
|
|
37694
|
+
return appendAgentLog(agentLogs, event);
|
|
37695
|
+
}
|
|
37696
|
+
let next = agentLogs || {};
|
|
37697
|
+
for (const path8 of paths) {
|
|
37698
|
+
next = appendAgentLog(next, { ...event, relativePath: path8 });
|
|
37699
|
+
}
|
|
37700
|
+
return next;
|
|
37701
|
+
}
|
|
37543
37702
|
function reconcileInventoryRunState(agentRunState, agents, timestamp) {
|
|
37544
37703
|
let next = agentRunState || {};
|
|
37545
37704
|
for (const agent of agents || []) {
|
|
@@ -37612,6 +37771,30 @@ function jobLabel(event) {
|
|
|
37612
37771
|
function stringValue(value) {
|
|
37613
37772
|
return value == null ? "" : String(value);
|
|
37614
37773
|
}
|
|
37774
|
+
function processExitMessage(event) {
|
|
37775
|
+
if (event?.code && Number(event.code) !== 0) {
|
|
37776
|
+
return `Agent serve exited with code ${event.code}`;
|
|
37777
|
+
}
|
|
37778
|
+
if (event?.signal) {
|
|
37779
|
+
return `Agent serve exited from ${event.signal}`;
|
|
37780
|
+
}
|
|
37781
|
+
return "Agent serve exited";
|
|
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
|
+
}
|
|
37794
|
+
function textTail(value, limit = 800) {
|
|
37795
|
+
const text = String(value || "").trim().replace(/\s+/g, " ");
|
|
37796
|
+
return text.length > limit ? text.slice(-limit) : text;
|
|
37797
|
+
}
|
|
37615
37798
|
function formatSeconds(value) {
|
|
37616
37799
|
const numeric = Number(value);
|
|
37617
37800
|
return Number.isFinite(numeric) ? `${numeric.toFixed(1)}s` : "";
|
|
@@ -37623,9 +37806,10 @@ async function spawnLocalServeEventStream({
|
|
|
37623
37806
|
agentsDir = "./agents",
|
|
37624
37807
|
collectionId = "",
|
|
37625
37808
|
env: env3 = process.env,
|
|
37626
|
-
platform: platform2 = process.platform
|
|
37809
|
+
platform: platform2 = process.platform,
|
|
37810
|
+
onProgress = null
|
|
37627
37811
|
} = {}) {
|
|
37628
|
-
const invocation = await preparePythonVendianInvocation(buildLocalServeEventStreamArgs({ agentsDir, collectionId }), { env: env3, platform: platform2 });
|
|
37812
|
+
const invocation = await preparePythonVendianInvocation(buildLocalServeEventStreamArgs({ agentsDir, collectionId }), { env: env3, platform: platform2, onProgress });
|
|
37629
37813
|
return spawn2(invocation.command, invocation.args, {
|
|
37630
37814
|
env: invocation.env,
|
|
37631
37815
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -38447,6 +38631,7 @@ function ServeScreen({ env: env3, platform: platform2, input, onBack, onState, o
|
|
|
38447
38631
|
setStarted(true);
|
|
38448
38632
|
setStartupError("");
|
|
38449
38633
|
try {
|
|
38634
|
+
setState((current) => ({ ...current, activity: "Loading previous agent logs" }));
|
|
38450
38635
|
const logStore = createServeLogStore({ agentsDir: serveRoot, collectionId, env: env3, platform: platform2 });
|
|
38451
38636
|
const historicalLogs = logStore.load();
|
|
38452
38637
|
if (historicalLogs.length > 0) {
|
|
@@ -38462,7 +38647,17 @@ function ServeScreen({ env: env3, platform: platform2, input, onBack, onState, o
|
|
|
38462
38647
|
};
|
|
38463
38648
|
});
|
|
38464
38649
|
}
|
|
38465
|
-
|
|
38650
|
+
setState((current) => ({ ...current, activity: "Preparing managed runtime" }));
|
|
38651
|
+
const nextChild = await spawnLocalServeEventStream({
|
|
38652
|
+
agentsDir: serveRoot,
|
|
38653
|
+
collectionId,
|
|
38654
|
+
env: env3,
|
|
38655
|
+
platform: platform2,
|
|
38656
|
+
onProgress: (message) => {
|
|
38657
|
+
setState((current) => ({ ...current, activity: message || "Preparing managed runtime" }));
|
|
38658
|
+
}
|
|
38659
|
+
});
|
|
38660
|
+
setState((current) => ({ ...current, activity: "Waiting for daemon events" }));
|
|
38466
38661
|
setChild(nextChild);
|
|
38467
38662
|
attachServeChild(nextChild, setState, setStartupError, ({ message } = {}) => {
|
|
38468
38663
|
setState((current) => current.stopped ? current : { ...current, stopped: true, activity: message ? "Runtime update required" : "Process exited" });
|
|
@@ -38721,6 +38916,7 @@ function DisabledAgentsFooter({ agents, agentRunState = {} }) {
|
|
|
38721
38916
|
}
|
|
38722
38917
|
function runtimeStatusColor(status) {
|
|
38723
38918
|
if (status === "running") return colors.accent;
|
|
38919
|
+
if (status === "preparing") return colors.brand;
|
|
38724
38920
|
if (status === "ready" || status === "completed") return colors.success;
|
|
38725
38921
|
if (status === "disabled") return colors.warning;
|
|
38726
38922
|
if (status === "error") return colors.error;
|
|
@@ -38728,6 +38924,7 @@ function runtimeStatusColor(status) {
|
|
|
38728
38924
|
}
|
|
38729
38925
|
function runtimeStatusIcon(status) {
|
|
38730
38926
|
if (status === "running") return fig.arrow;
|
|
38927
|
+
if (status === "preparing") return fig.dotEmpty;
|
|
38731
38928
|
if (status === "ready" || status === "completed") return fig.dot;
|
|
38732
38929
|
if (status === "disabled") return fig.warning;
|
|
38733
38930
|
if (status === "error") return fig.cross;
|
|
@@ -39210,13 +39407,44 @@ function attachServeChild(child, setState, setStartupError, onExit, logStore = n
|
|
|
39210
39407
|
});
|
|
39211
39408
|
child.on("error", (error) => setStartupError(errorMessage2(error)));
|
|
39212
39409
|
child.on("exit", (code, signal) => {
|
|
39213
|
-
try {
|
|
39214
|
-
logStore?.compact();
|
|
39215
|
-
} catch {
|
|
39216
|
-
}
|
|
39217
39410
|
const message = serveProcessExitMessage({ stderr: stderrChunks.join("\n"), code, signal });
|
|
39218
39411
|
if (message) {
|
|
39219
39412
|
setStartupError(message);
|
|
39413
|
+
setState((current) => {
|
|
39414
|
+
const currentJob = current?.currentJob || {};
|
|
39415
|
+
const event = {
|
|
39416
|
+
type: "process_exit",
|
|
39417
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
39418
|
+
code,
|
|
39419
|
+
signal,
|
|
39420
|
+
message,
|
|
39421
|
+
stderrTail: stderrChunks.join("\n").slice(-2e3),
|
|
39422
|
+
relativePath: currentJob.relativePath || currentJob.localPath || currentJob.path || "",
|
|
39423
|
+
runId: currentJob.runId || currentJob.deployRequestId || currentJob.testRunId || "",
|
|
39424
|
+
sessionId: currentJob.sessionId || "",
|
|
39425
|
+
jobType: currentJob.jobType || ""
|
|
39426
|
+
};
|
|
39427
|
+
try {
|
|
39428
|
+
const runningPaths = Object.entries(current?.agentRunState || {}).filter(([, run2]) => run2?.status === "running").map(([path8]) => path8).filter(Boolean);
|
|
39429
|
+
const paths = new Set(runningPaths);
|
|
39430
|
+
if (event.relativePath) {
|
|
39431
|
+
paths.add(event.relativePath);
|
|
39432
|
+
}
|
|
39433
|
+
if (paths.size === 0) {
|
|
39434
|
+
logStore?.append(event);
|
|
39435
|
+
} else {
|
|
39436
|
+
for (const relativePath of paths) {
|
|
39437
|
+
logStore?.append({ ...event, relativePath });
|
|
39438
|
+
}
|
|
39439
|
+
}
|
|
39440
|
+
} catch {
|
|
39441
|
+
}
|
|
39442
|
+
return applyServeEvent(current, event);
|
|
39443
|
+
});
|
|
39444
|
+
}
|
|
39445
|
+
try {
|
|
39446
|
+
logStore?.compact();
|
|
39447
|
+
} catch {
|
|
39220
39448
|
}
|
|
39221
39449
|
onExit({ code, signal, message });
|
|
39222
39450
|
});
|