@chosengeneration/light-code 0.190.0 → 0.192.0
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/dist/cli.cjs +568 -21
- package/dist/server.cjs +564 -18
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -61547,14 +61547,17 @@ async function sameFile(a, b) {
|
|
|
61547
61547
|
return false;
|
|
61548
61548
|
}
|
|
61549
61549
|
}
|
|
61550
|
-
async function loadSkills(dirs) {
|
|
61550
|
+
async function loadSkills(dirs, onFolder) {
|
|
61551
61551
|
const ordered = (typeof dirs === "string" ? [dirs] : dirs).map((dir) => import_node_path21.default.resolve(dir));
|
|
61552
61552
|
const unique = ordered.filter((dir, index) => ordered.indexOf(dir) === index);
|
|
61553
61553
|
const skills = [];
|
|
61554
61554
|
const issues = [];
|
|
61555
61555
|
const claimed = /* @__PURE__ */ new Map();
|
|
61556
61556
|
for (const dir of unique) {
|
|
61557
|
+
onFolder?.(dir);
|
|
61558
|
+
const started = Date.now();
|
|
61557
61559
|
const loaded = await loadOneDirectory(dir);
|
|
61560
|
+
onFolder?.(dir, Date.now() - started);
|
|
61558
61561
|
issues.push(...loaded.issues);
|
|
61559
61562
|
for (const skill of loaded.skills) {
|
|
61560
61563
|
const winner = claimed.get(skill.name);
|
|
@@ -62737,7 +62740,7 @@ function describeIssue(issue2) {
|
|
|
62737
62740
|
return `"${issue2.name}" was declined, so it is not loaded. Restore it to review it again.`;
|
|
62738
62741
|
}
|
|
62739
62742
|
}
|
|
62740
|
-
async function loadRegistries(dirs, worker, logger, declined, trusted) {
|
|
62743
|
+
async function loadRegistries(dirs, worker, logger, declined, trusted, onFolder) {
|
|
62741
62744
|
const ordered = dirs.map((dir) => import_node_path25.default.resolve(dir));
|
|
62742
62745
|
const seen = /* @__PURE__ */ new Set();
|
|
62743
62746
|
const unique = ordered.filter((dir) => {
|
|
@@ -62752,7 +62755,10 @@ async function loadRegistries(dirs, worker, logger, declined, trusted) {
|
|
|
62752
62755
|
const approvedElsewhere = [];
|
|
62753
62756
|
const claimed = /* @__PURE__ */ new Map();
|
|
62754
62757
|
for (const dir of unique) {
|
|
62758
|
+
onFolder?.(dir);
|
|
62759
|
+
const started = Date.now();
|
|
62755
62760
|
const loaded = await loadRegistry(dir, worker, logger, declined, trusted);
|
|
62761
|
+
onFolder?.(dir, Date.now() - started);
|
|
62756
62762
|
issues.push(...loaded.issues);
|
|
62757
62763
|
approvedElsewhere.push(...loaded.approvedElsewhere ?? []);
|
|
62758
62764
|
for (const tool of loaded.tools) {
|
|
@@ -63463,6 +63469,18 @@ var PythonManager = class {
|
|
|
63463
63469
|
constructor(options) {
|
|
63464
63470
|
this.options = options;
|
|
63465
63471
|
}
|
|
63472
|
+
progressStep;
|
|
63473
|
+
/** Reports the step starting now (undefined when done), and how long the one before took. */
|
|
63474
|
+
progress(step, finished, tookMs) {
|
|
63475
|
+
const before = this.progressStep;
|
|
63476
|
+
if (finished !== void 0 && tookMs !== void 0)
|
|
63477
|
+
this.options.onProgress?.(finished, tookMs);
|
|
63478
|
+
else if (before !== void 0)
|
|
63479
|
+
this.options.onProgress?.(before.step, Date.now() - before.at);
|
|
63480
|
+
this.progressStep = step === void 0 ? void 0 : { step, at: Date.now() };
|
|
63481
|
+
if (step !== void 0)
|
|
63482
|
+
this.options.onProgress?.(step);
|
|
63483
|
+
}
|
|
63466
63484
|
/**
|
|
63467
63485
|
* Applies config and brings the environment up if it is on.
|
|
63468
63486
|
*
|
|
@@ -63512,15 +63530,20 @@ var PythonManager = class {
|
|
|
63512
63530
|
this.indexUrl = config2.indexUrl;
|
|
63513
63531
|
this.extraIndexUrls = config2.extraIndexUrls ?? [];
|
|
63514
63532
|
this.offline = config2.offline === true;
|
|
63515
|
-
if (this.uv === void 0)
|
|
63533
|
+
if (this.uv === void 0) {
|
|
63534
|
+
this.progress("checking for uv");
|
|
63516
63535
|
this.uv = await detectUv(config2.uvPath);
|
|
63536
|
+
}
|
|
63517
63537
|
if (this.uv === void 0) {
|
|
63538
|
+
this.progress("finding a Python interpreter");
|
|
63518
63539
|
await this.startWithoutUv(config2, this.options.workspaceRoot);
|
|
63540
|
+
this.progress(void 0);
|
|
63519
63541
|
return;
|
|
63520
63542
|
}
|
|
63521
63543
|
try {
|
|
63522
63544
|
const env2 = await this.childEnv();
|
|
63523
63545
|
let interpreter;
|
|
63546
|
+
this.progress("checking the virtual environment");
|
|
63524
63547
|
if (config2.venvPath !== void 0 && config2.venvPath.trim().length > 0) {
|
|
63525
63548
|
this.venvPath = config2.venvPath.trim();
|
|
63526
63549
|
this.venvSource = "configured";
|
|
@@ -63559,6 +63582,7 @@ var PythonManager = class {
|
|
|
63559
63582
|
...this.readCredential() !== void 0 ? { readCredential: this.readCredential() } : {}
|
|
63560
63583
|
});
|
|
63561
63584
|
await this.refresh();
|
|
63585
|
+
this.progress(void 0);
|
|
63562
63586
|
this.ready = true;
|
|
63563
63587
|
this.detail = this.venvSource === "workspace" ? `Ready \u2014 using this project's virtualenv${this.venvIsUvManaged ? " (uv-managed)" : ""}. Tool dependencies install into it.` : this.venvSource === "configured" ? `Ready \u2014 using the configured virtualenv. uv ${this.uv.version}.` : `Ready \u2014 created a private virtualenv. uv ${this.uv.version}.`;
|
|
63564
63588
|
} catch (error51) {
|
|
@@ -63657,7 +63681,7 @@ var PythonManager = class {
|
|
|
63657
63681
|
async refresh() {
|
|
63658
63682
|
if (!this.enabled || this.toolsDir.length === 0)
|
|
63659
63683
|
return;
|
|
63660
|
-
const loaded = await loadRegistries(this.toolDirectories(), this.worker, this.options.logger, this.declinedTools, this.options.machineApprovals);
|
|
63684
|
+
const loaded = await loadRegistries(this.toolDirectories(), this.worker, this.options.logger, this.declinedTools, this.options.machineApprovals, (dir, tookMs) => tookMs === void 0 ? this.progress(`reading tools in ${dir}`) : this.progress(void 0, `reading tools in ${dir}`, tookMs));
|
|
63661
63685
|
if (loaded.approvedElsewhere !== void 0)
|
|
63662
63686
|
this.options.onApprovedElsewhere?.(loaded.approvedElsewhere);
|
|
63663
63687
|
this.registered = loaded.tools;
|
|
@@ -77033,6 +77057,247 @@ function describeRun2(run3, now = /* @__PURE__ */ new Date()) {
|
|
|
77033
77057
|
return `${parts.join(" \xB7 ")} - ${how}`;
|
|
77034
77058
|
}
|
|
77035
77059
|
|
|
77060
|
+
// ../../packages/core/dist/atlassian/autosysInsight.js
|
|
77061
|
+
function quantile(sorted, q) {
|
|
77062
|
+
if (sorted.length === 0)
|
|
77063
|
+
return 0;
|
|
77064
|
+
const position = (sorted.length - 1) * q;
|
|
77065
|
+
const below = Math.floor(position);
|
|
77066
|
+
const above = Math.ceil(position);
|
|
77067
|
+
const low = sorted[below] ?? 0;
|
|
77068
|
+
const high = sorted[above] ?? low;
|
|
77069
|
+
return low + (high - low) * (position - below);
|
|
77070
|
+
}
|
|
77071
|
+
function runDurations(runs) {
|
|
77072
|
+
const finished = runs.filter((run3) => run3.start !== void 0 && run3.end !== void 0 && run3.end > run3.start);
|
|
77073
|
+
const succeeded = finished.filter((run3) => run3.status.toUpperCase() === "SUCCESS");
|
|
77074
|
+
const chosen = succeeded.length > 0 ? succeeded : finished;
|
|
77075
|
+
return { durations: chosen.map((run3) => (run3.end ?? 0) - (run3.start ?? 0)), onlySuccess: succeeded.length > 0 };
|
|
77076
|
+
}
|
|
77077
|
+
function durationStats(durations) {
|
|
77078
|
+
if (durations.length === 0)
|
|
77079
|
+
return void 0;
|
|
77080
|
+
const sorted = [...durations].sort((a, b) => a - b);
|
|
77081
|
+
return {
|
|
77082
|
+
count: sorted.length,
|
|
77083
|
+
meanMs: sorted.reduce((sum, value) => sum + value, 0) / sorted.length,
|
|
77084
|
+
medianMs: quantile(sorted, 0.5),
|
|
77085
|
+
p10Ms: quantile(sorted, 0.1),
|
|
77086
|
+
p90Ms: quantile(sorted, 0.9),
|
|
77087
|
+
minMs: sorted[0] ?? 0,
|
|
77088
|
+
maxMs: sorted[sorted.length - 1] ?? 0
|
|
77089
|
+
};
|
|
77090
|
+
}
|
|
77091
|
+
function formatDuration(ms) {
|
|
77092
|
+
const seconds = Math.max(0, Math.round(ms / 1e3));
|
|
77093
|
+
if (seconds < 60)
|
|
77094
|
+
return `${String(seconds)} s`;
|
|
77095
|
+
const minutes = Math.floor(seconds / 60);
|
|
77096
|
+
if (minutes < 60)
|
|
77097
|
+
return `${String(minutes)} min ${String(seconds % 60).padStart(2, "0")} s`;
|
|
77098
|
+
const hours = Math.floor(minutes / 60);
|
|
77099
|
+
return `${String(hours)} h ${String(minutes % 60).padStart(2, "0")} min`;
|
|
77100
|
+
}
|
|
77101
|
+
function localTime(at, now = /* @__PURE__ */ new Date()) {
|
|
77102
|
+
const date5 = new Date(at);
|
|
77103
|
+
const time4 = `${String(date5.getHours()).padStart(2, "0")}:${String(date5.getMinutes()).padStart(2, "0")}`;
|
|
77104
|
+
if (date5.toDateString() === now.toDateString())
|
|
77105
|
+
return time4;
|
|
77106
|
+
const tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);
|
|
77107
|
+
if (date5.toDateString() === tomorrow.toDateString())
|
|
77108
|
+
return `${time4} tomorrow`;
|
|
77109
|
+
return `${date5.getFullYear()}-${String(date5.getMonth() + 1).padStart(2, "0")}-${String(date5.getDate()).padStart(2, "0")} ${time4}`;
|
|
77110
|
+
}
|
|
77111
|
+
function localZone(now = /* @__PURE__ */ new Date()) {
|
|
77112
|
+
try {
|
|
77113
|
+
return new Intl.DateTimeFormat(void 0, { timeZoneName: "short" }).formatToParts(now).find((part) => part.type === "timeZoneName")?.value ?? "local time";
|
|
77114
|
+
} catch {
|
|
77115
|
+
return "local time";
|
|
77116
|
+
}
|
|
77117
|
+
}
|
|
77118
|
+
function etaFor(startedAt, stats, now = Date.now()) {
|
|
77119
|
+
const elapsedMs = Math.max(0, now - startedAt);
|
|
77120
|
+
return {
|
|
77121
|
+
elapsedMs,
|
|
77122
|
+
expected: startedAt + stats.medianMs,
|
|
77123
|
+
latest: startedAt + Math.max(stats.p90Ms, stats.medianMs),
|
|
77124
|
+
overrun: elapsedMs > Math.max(stats.p90Ms, stats.medianMs)
|
|
77125
|
+
};
|
|
77126
|
+
}
|
|
77127
|
+
function minuteOfDay(at) {
|
|
77128
|
+
const date5 = new Date(at);
|
|
77129
|
+
return date5.getHours() * 60 + date5.getMinutes() + date5.getSeconds() / 60;
|
|
77130
|
+
}
|
|
77131
|
+
function clockOfMinute(minute) {
|
|
77132
|
+
const wrapped = (Math.round(minute) % 1440 + 1440) % 1440;
|
|
77133
|
+
return `${String(Math.floor(wrapped / 60)).padStart(2, "0")}:${String(wrapped % 60).padStart(2, "0")}`;
|
|
77134
|
+
}
|
|
77135
|
+
function timeOfDayStats(moments) {
|
|
77136
|
+
if (moments.length === 0)
|
|
77137
|
+
return void 0;
|
|
77138
|
+
const minutes = moments.map(minuteOfDay);
|
|
77139
|
+
const angle = (minute) => minute / 1440 * 2 * Math.PI;
|
|
77140
|
+
const sin = minutes.reduce((sum, minute) => sum + Math.sin(angle(minute)), 0);
|
|
77141
|
+
const cos = minutes.reduce((sum, minute) => sum + Math.cos(angle(minute)), 0);
|
|
77142
|
+
const centre = (Math.atan2(sin, cos) / (2 * Math.PI) * 1440 % 1440 + 1440) % 1440;
|
|
77143
|
+
const offsets = minutes.map((minute) => {
|
|
77144
|
+
let offset = minute - centre;
|
|
77145
|
+
if (offset > 720)
|
|
77146
|
+
offset -= 1440;
|
|
77147
|
+
if (offset < -720)
|
|
77148
|
+
offset += 1440;
|
|
77149
|
+
return offset;
|
|
77150
|
+
}).sort((a, b) => a - b);
|
|
77151
|
+
const early = centre + quantile(offsets, 0.1);
|
|
77152
|
+
const late = centre + quantile(offsets, 0.9);
|
|
77153
|
+
return { count: minutes.length, typical: centre + quantile(offsets, 0.5), early, late, spreadMinutes: late - early };
|
|
77154
|
+
}
|
|
77155
|
+
function ownStarts(runs) {
|
|
77156
|
+
return runs.filter((run3) => run3.start !== void 0 && !(run3.tryNum !== void 0 && run3.tryNum > 1) && run3.how !== "manual" && run3.how !== "retry").map((run3) => run3.start ?? 0);
|
|
77157
|
+
}
|
|
77158
|
+
async function tracePredecessors(source, root, limits = {}) {
|
|
77159
|
+
const maxJobs = limits.maxJobs ?? 200;
|
|
77160
|
+
const maxDepth = limits.maxDepth ?? 30;
|
|
77161
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
77162
|
+
let level2 = [root];
|
|
77163
|
+
let depth = 0;
|
|
77164
|
+
let truncated = false;
|
|
77165
|
+
while (level2.length > 0 && depth <= maxDepth) {
|
|
77166
|
+
const fresh = [...new Set(level2)].filter((name) => !nodes.has(name.toLowerCase()));
|
|
77167
|
+
const room = maxJobs - nodes.size;
|
|
77168
|
+
if (fresh.length > room)
|
|
77169
|
+
truncated = true;
|
|
77170
|
+
const batch = fresh.slice(0, Math.max(0, room));
|
|
77171
|
+
const read = await Promise.all(batch.map(async (name) => {
|
|
77172
|
+
const [definition, state] = await Promise.all([source.definition(name).catch(() => void 0), source.status(name).catch(() => ({ status: "unknown" }))]);
|
|
77173
|
+
if (definition === void 0)
|
|
77174
|
+
return { name, status: state.status, top: false, unreadable: "definition not readable", predecessors: [] };
|
|
77175
|
+
const condition2 = source.field(definition, "condition");
|
|
77176
|
+
const box = source.field(definition, "boxName", "box_name");
|
|
77177
|
+
const references = [...box !== void 0 ? [{ kind: "box", job: box }] : [], ...condition2 !== void 0 ? source.parseConditions(condition2) : []];
|
|
77178
|
+
const predecessors = await Promise.all(references.map(async (reference) => {
|
|
77179
|
+
if (reference.instance !== void 0)
|
|
77180
|
+
return { reference, met: void 0, onOtherInstance: true };
|
|
77181
|
+
const other = await source.status(reference.job).catch(() => ({ status: "unknown" }));
|
|
77182
|
+
const met = reference.kind === "box" ? other.status.toUpperCase() === "RUNNING" : source.conditionMet(reference.kind, other.status);
|
|
77183
|
+
return { reference, met, onOtherInstance: false };
|
|
77184
|
+
}));
|
|
77185
|
+
return {
|
|
77186
|
+
name,
|
|
77187
|
+
status: state.status,
|
|
77188
|
+
...state.lastStart !== void 0 ? { lastStart: state.lastStart } : {},
|
|
77189
|
+
...state.lastEnd !== void 0 ? { lastEnd: state.lastEnd } : {},
|
|
77190
|
+
...condition2 !== void 0 ? { condition: condition2 } : {},
|
|
77191
|
+
...box !== void 0 ? { box } : {},
|
|
77192
|
+
...source.schedule(definition) !== void 0 ? { schedule: source.schedule(definition) } : {},
|
|
77193
|
+
top: condition2 === void 0 && box === void 0,
|
|
77194
|
+
predecessors
|
|
77195
|
+
};
|
|
77196
|
+
}));
|
|
77197
|
+
for (const node of read)
|
|
77198
|
+
nodes.set(node.name.toLowerCase(), node);
|
|
77199
|
+
const next = [];
|
|
77200
|
+
for (const node of read)
|
|
77201
|
+
for (const each of node.predecessors)
|
|
77202
|
+
if (!each.onOtherInstance && !nodes.has(each.reference.job.toLowerCase()))
|
|
77203
|
+
next.push(each.reference.job);
|
|
77204
|
+
if (next.length > 0 && depth === maxDepth)
|
|
77205
|
+
truncated = true;
|
|
77206
|
+
level2 = next;
|
|
77207
|
+
depth += next.length > 0 ? 1 : 0;
|
|
77208
|
+
}
|
|
77209
|
+
const tops = [...nodes.values()].filter((node) => node.top).map((node) => node.name);
|
|
77210
|
+
return { root, nodes, tops, truncated, depth };
|
|
77211
|
+
}
|
|
77212
|
+
var KIND_WORDS = { s: "success of", f: "failure of", d: "completion of", n: "not running:", t: "termination of", e: "exit code of", box: "inside box" };
|
|
77213
|
+
function describeTrace(trace, extra) {
|
|
77214
|
+
const lines2 = [];
|
|
77215
|
+
const shown2 = /* @__PURE__ */ new Set();
|
|
77216
|
+
const line = (node, name, indent2, via) => {
|
|
77217
|
+
const key3 = name.toLowerCase();
|
|
77218
|
+
if (node === void 0) {
|
|
77219
|
+
lines2.push(`${indent2}${via}${name} - not traced (limit reached)`);
|
|
77220
|
+
return;
|
|
77221
|
+
}
|
|
77222
|
+
if (shown2.has(key3)) {
|
|
77223
|
+
lines2.push(`${indent2}${via}${name} [${node.status}] (traced above)`);
|
|
77224
|
+
return;
|
|
77225
|
+
}
|
|
77226
|
+
shown2.add(key3);
|
|
77227
|
+
const facts = [
|
|
77228
|
+
`[${node.status}]`,
|
|
77229
|
+
node.lastStart !== void 0 ? `last start ${node.lastStart}` : void 0,
|
|
77230
|
+
node.lastEnd !== void 0 ? `last end ${node.lastEnd}` : void 0,
|
|
77231
|
+
node.top ? `TOP${node.schedule !== void 0 ? ` - starts ${node.schedule}` : " - no condition, no box, no start schedule (started by hand or by another instance)"}` : void 0,
|
|
77232
|
+
node.unreadable,
|
|
77233
|
+
extra?.(node)
|
|
77234
|
+
].filter((part) => part !== void 0);
|
|
77235
|
+
lines2.push(`${indent2}${via}${name} ${facts.join(" \xB7 ")}`);
|
|
77236
|
+
if (node.condition !== void 0)
|
|
77237
|
+
lines2.push(`${indent2} condition: ${node.condition}`);
|
|
77238
|
+
for (const each of node.predecessors) {
|
|
77239
|
+
const word = KIND_WORDS[each.reference.kind] ?? each.reference.kind;
|
|
77240
|
+
const state = each.onOtherInstance ? "on another instance - not checked" : each.met === void 0 ? "check the exit code" : each.met ? "met" : "NOT met";
|
|
77241
|
+
const label = `${word} (${state}${each.reference.comparison !== void 0 ? `, ${each.reference.comparison}` : ""}) `;
|
|
77242
|
+
if (each.onOtherInstance) {
|
|
77243
|
+
lines2.push(`${indent2} ${label}${each.reference.job}^${each.reference.instance ?? ""}`);
|
|
77244
|
+
continue;
|
|
77245
|
+
}
|
|
77246
|
+
line(trace.nodes.get(each.reference.job.toLowerCase()), each.reference.job, `${indent2} `, label);
|
|
77247
|
+
}
|
|
77248
|
+
};
|
|
77249
|
+
line(trace.nodes.get(trace.root.toLowerCase()), trace.root, "", "");
|
|
77250
|
+
const all = [...trace.nodes.values()];
|
|
77251
|
+
const notMet = all.flatMap((node) => node.predecessors.filter((each) => each.met === false).map((each) => `${node.name} waits on ${KIND_WORDS[each.reference.kind] ?? each.reference.kind} ${each.reference.job}`));
|
|
77252
|
+
const failed2 = all.filter((node) => ["FAILURE", "TERMINATED"].includes(node.status.toUpperCase())).map((node) => `${node.name} [${node.status}]`);
|
|
77253
|
+
lines2.push("", `${String(all.length - 1)} predecessor job(s) over ${String(trace.depth)} level(s). Topmost: ${trace.tops.filter((name) => name.toLowerCase() !== trace.root.toLowerCase()).join(", ") || "none (it is the top itself)"}.`, ...failed2.length > 0 ? [`Failed or terminated: ${failed2.join(", ")}.`] : [], ...notMet.length > 0 ? ["Not met now:", ...notMet.slice(0, 40).map((entry) => `- ${entry}`)] : [], ...trace.truncated ? ["The walk stopped at its limit; raise maxJobs or maxDepth to go further."] : []);
|
|
77254
|
+
return lines2.join("\n");
|
|
77255
|
+
}
|
|
77256
|
+
function expectedStartFromDefinitions(trace, durations, startMinutes) {
|
|
77257
|
+
const memo = /* @__PURE__ */ new Map();
|
|
77258
|
+
const missing = /* @__PURE__ */ new Set();
|
|
77259
|
+
const via = /* @__PURE__ */ new Map();
|
|
77260
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
77261
|
+
const startOf = (name) => {
|
|
77262
|
+
const key3 = name.toLowerCase();
|
|
77263
|
+
if (memo.has(key3))
|
|
77264
|
+
return memo.get(key3);
|
|
77265
|
+
if (visiting.has(key3))
|
|
77266
|
+
return void 0;
|
|
77267
|
+
visiting.add(key3);
|
|
77268
|
+
const node = trace.nodes.get(key3);
|
|
77269
|
+
let result;
|
|
77270
|
+
const own = startMinutes.get(key3);
|
|
77271
|
+
if (own !== void 0) {
|
|
77272
|
+
result = own;
|
|
77273
|
+
via.set(key3, [`${name} starts at ${clockOfMinute(own)}`]);
|
|
77274
|
+
} else if (node === void 0 || node.top) {
|
|
77275
|
+
missing.add(`${name} (no start time)`);
|
|
77276
|
+
} else {
|
|
77277
|
+
const finishes = node.predecessors.filter((each) => !each.onOtherInstance && ["s", "d", "box"].includes(each.reference.kind)).map((each) => {
|
|
77278
|
+
const before = startOf(each.reference.job);
|
|
77279
|
+
if (each.reference.kind === "box")
|
|
77280
|
+
return { name: each.reference.job, at: before };
|
|
77281
|
+
const took = durations.get(each.reference.job.toLowerCase());
|
|
77282
|
+
if (took === void 0)
|
|
77283
|
+
missing.add(`${each.reference.job} (no run history)`);
|
|
77284
|
+
return { name: each.reference.job, at: before === void 0 || took === void 0 ? void 0 : before + took / 6e4 };
|
|
77285
|
+
});
|
|
77286
|
+
if (finishes.length > 0 && finishes.every((each) => each.at !== void 0)) {
|
|
77287
|
+
const last = finishes.reduce((latest, each) => (each.at ?? 0) > (latest.at ?? 0) ? each : latest);
|
|
77288
|
+
result = last.at;
|
|
77289
|
+
via.set(key3, [...via.get(last.name.toLowerCase()) ?? [], `${name} after ${last.name} (${clockOfMinute(last.at ?? 0)})`]);
|
|
77290
|
+
} else if (finishes.length === 0)
|
|
77291
|
+
missing.add(`${name} (waits only on conditions that do not say when)`);
|
|
77292
|
+
}
|
|
77293
|
+
visiting.delete(key3);
|
|
77294
|
+
memo.set(key3, result);
|
|
77295
|
+
return result;
|
|
77296
|
+
};
|
|
77297
|
+
const start = startOf(trace.root);
|
|
77298
|
+
return { start, missing: [...missing], via: via.get(trace.root.toLowerCase()) ?? [] };
|
|
77299
|
+
}
|
|
77300
|
+
|
|
77036
77301
|
// ../../packages/core/dist/atlassian/autosys.js
|
|
77037
77302
|
var DEFAULT_AUTOSYS_PATHS = {
|
|
77038
77303
|
jobs: "/job?filter={filter:name}",
|
|
@@ -77950,7 +78215,7 @@ function conditionMet(kind, status2) {
|
|
|
77950
78215
|
return void 0;
|
|
77951
78216
|
}
|
|
77952
78217
|
}
|
|
77953
|
-
var
|
|
78218
|
+
var KIND_WORDS2 = {
|
|
77954
78219
|
s: "success of",
|
|
77955
78220
|
f: "failure of",
|
|
77956
78221
|
d: "completion of",
|
|
@@ -78011,12 +78276,12 @@ function createAutosysDependenciesTool(options) {
|
|
|
78011
78276
|
lines2.push(`${indent2}condition: ${condition2}`);
|
|
78012
78277
|
for (const reference of parseConditions(condition2)) {
|
|
78013
78278
|
if (reference.instance !== void 0) {
|
|
78014
|
-
lines2.push(`${indent2}- ${
|
|
78279
|
+
lines2.push(`${indent2}- ${KIND_WORDS2[reference.kind]} ${reference.job} on instance ${reference.instance} (another instance: status not checked)`);
|
|
78015
78280
|
continue;
|
|
78016
78281
|
}
|
|
78017
78282
|
const status2 = await statusOf(reference.job);
|
|
78018
78283
|
const met = conditionMet(reference.kind, status2);
|
|
78019
|
-
lines2.push(`${indent2}- ${
|
|
78284
|
+
lines2.push(`${indent2}- ${KIND_WORDS2[reference.kind]} ${reference.job}${reference.comparison !== void 0 ? ` ${reference.comparison}` : ""}: ${status2} \u2014 ${met === void 0 ? "check the exit code" : met ? "met" : "NOT met"}`);
|
|
78020
78285
|
if (met === false && level2 < (params3.depth ?? 3))
|
|
78021
78286
|
await walk(reference.job, level2 + 1, `${indent2} `);
|
|
78022
78287
|
}
|
|
@@ -78331,13 +78596,218 @@ function createAutosysRunsTool(options) {
|
|
|
78331
78596
|
}
|
|
78332
78597
|
};
|
|
78333
78598
|
}
|
|
78599
|
+
async function recentRuns(client, name, days) {
|
|
78600
|
+
const history = await client.runHistory(name);
|
|
78601
|
+
if (history === void 0)
|
|
78602
|
+
return void 0;
|
|
78603
|
+
const since2 = Date.now() - days * 864e5;
|
|
78604
|
+
return history.map(toPastRun).filter((run3) => run3.start === void 0 || run3.start >= since2).sort((a, b) => (a.start ?? 0) - (b.start ?? 0));
|
|
78605
|
+
}
|
|
78606
|
+
var NO_HISTORY = "This server did not answer for run history at the configured address - set config:autosys (paths.runHistory).";
|
|
78607
|
+
var runStatsSchema = external_exports.object({
|
|
78608
|
+
jobs: external_exports.array(external_exports.string().min(1)).min(1).max(30).describe("Exact job names."),
|
|
78609
|
+
days: external_exports.number().int().min(1).max(365).optional().describe("How far back to look in the run history. Default 30.")
|
|
78610
|
+
});
|
|
78611
|
+
function createAutosysRunStatsTool(options) {
|
|
78612
|
+
return {
|
|
78613
|
+
name: "autosys_run_stats",
|
|
78614
|
+
group: "read",
|
|
78615
|
+
description: 'How long AutoSys jobs usually run, from their run history: typical (median), average, fastest and slowest, and nine runs in ten - successful runs only when there are any. For a job RUNNING now, an ETA in local time: when it should finish at its typical run time, the likely latest, and whether it is already running longer than usual. Answers "how long does PAY_LOAD take?" and "when will it finish?".',
|
|
78616
|
+
parametersSchema: runStatsSchema,
|
|
78617
|
+
async execute(params3) {
|
|
78618
|
+
try {
|
|
78619
|
+
const client = await options.client();
|
|
78620
|
+
const days = params3.days ?? 30;
|
|
78621
|
+
const now = /* @__PURE__ */ new Date();
|
|
78622
|
+
let historyMissing = false;
|
|
78623
|
+
const sections = await inBatches2([...new Set(params3.jobs.map((job) => job.trim()))], async (name) => {
|
|
78624
|
+
try {
|
|
78625
|
+
const [runs, current] = await Promise.all([recentRuns(client, name, days), client.runInfo(name).catch(() => [])]);
|
|
78626
|
+
if (runs === void 0)
|
|
78627
|
+
historyMissing = true;
|
|
78628
|
+
const latest = current[0];
|
|
78629
|
+
const { durations, onlySuccess } = runDurations(runs ?? []);
|
|
78630
|
+
const stats = durationStats(durations);
|
|
78631
|
+
const lines2 = [`${name}: now ${latest?.status ?? "unknown"}${latest?.lastStart !== void 0 ? `, last started ${latest.lastStart}` : ""}`];
|
|
78632
|
+
if (stats === void 0) {
|
|
78633
|
+
lines2.push(` no finished run in the last ${String(days)} days${runs === void 0 ? " (no run history here)" : ""} - nothing to base a run time on.`);
|
|
78634
|
+
} else {
|
|
78635
|
+
lines2.push(` over ${String(stats.count)} ${onlySuccess ? "successful" : "finished (none succeeded)"} run(s) in ${String(days)} days: typically ${formatDuration(stats.medianMs)}, average ${formatDuration(stats.meanMs)}, fastest ${formatDuration(stats.minMs)}, slowest ${formatDuration(stats.maxMs)}; nine in ten within ${formatDuration(stats.p90Ms)}.`);
|
|
78636
|
+
}
|
|
78637
|
+
const startedAt = parseAutosysTime(latest?.lastStart);
|
|
78638
|
+
if (latest !== void 0 && latest.status.toUpperCase() === "RUNNING" && startedAt !== void 0) {
|
|
78639
|
+
if (stats === void 0) {
|
|
78640
|
+
lines2.push(` running for ${formatDuration(now.getTime() - startedAt)}; no history to estimate when it will finish.`);
|
|
78641
|
+
} else {
|
|
78642
|
+
const eta = etaFor(startedAt, stats, now.getTime());
|
|
78643
|
+
lines2.push(` RUNNING for ${formatDuration(eta.elapsedMs)} (since ${localTime(startedAt, now)}). ` + (eta.overrun ? `Already longer than nine runs in ten (${formatDuration(stats.p90Ms)}) - running long; it should have finished by ${localTime(eta.latest, now)}.` : `ETA ${localTime(eta.expected, now)} at its typical run time${eta.expected < now.getTime() ? " (already past)" : ""}, by ${localTime(eta.latest, now)} at the latest in nine runs in ten.`));
|
|
78644
|
+
}
|
|
78645
|
+
}
|
|
78646
|
+
return lines2.join("\n");
|
|
78647
|
+
} catch (error51) {
|
|
78648
|
+
return `${name}: ${error51 instanceof Error ? error51.message : String(error51)}`;
|
|
78649
|
+
}
|
|
78650
|
+
});
|
|
78651
|
+
return { content: [...sections, `Times are local (${localZone(now)}).`, ...historyMissing ? [NO_HISTORY] : []].join("\n\n") };
|
|
78652
|
+
} catch (error51) {
|
|
78653
|
+
return errorResult3(error51);
|
|
78654
|
+
}
|
|
78655
|
+
}
|
|
78656
|
+
};
|
|
78657
|
+
}
|
|
78658
|
+
function predecessorSource(client) {
|
|
78659
|
+
const definitions = /* @__PURE__ */ new Map();
|
|
78660
|
+
const statuses = /* @__PURE__ */ new Map();
|
|
78661
|
+
return {
|
|
78662
|
+
definitions,
|
|
78663
|
+
async definition(name) {
|
|
78664
|
+
const key3 = name.toLowerCase();
|
|
78665
|
+
if (!definitions.has(key3))
|
|
78666
|
+
definitions.set(key3, await client.job(name).catch(() => void 0));
|
|
78667
|
+
return definitions.get(key3);
|
|
78668
|
+
},
|
|
78669
|
+
status(name) {
|
|
78670
|
+
const key3 = name.toLowerCase();
|
|
78671
|
+
let found2 = statuses.get(key3);
|
|
78672
|
+
if (found2 === void 0) {
|
|
78673
|
+
found2 = client.runInfo(name).then((runs) => {
|
|
78674
|
+
const run3 = runs[0];
|
|
78675
|
+
return run3 === void 0 ? { status: "unknown" } : { status: run3.status, ...run3.lastStart !== void 0 ? { lastStart: run3.lastStart } : {}, ...run3.lastEnd !== void 0 ? { lastEnd: run3.lastEnd } : {} };
|
|
78676
|
+
}).catch(() => ({ status: "unknown" }));
|
|
78677
|
+
statuses.set(key3, found2);
|
|
78678
|
+
}
|
|
78679
|
+
return found2;
|
|
78680
|
+
},
|
|
78681
|
+
parseConditions,
|
|
78682
|
+
conditionMet: (kind, status2) => conditionMet(kind, status2),
|
|
78683
|
+
field,
|
|
78684
|
+
schedule(definition) {
|
|
78685
|
+
const schedule = jobSchedule(definition);
|
|
78686
|
+
if (schedule === void 0)
|
|
78687
|
+
return void 0;
|
|
78688
|
+
const at = [
|
|
78689
|
+
...schedule.times.length > 0 ? [`at ${schedule.times.join(", ")}`] : [],
|
|
78690
|
+
...schedule.minutesPastHour.length > 0 ? [`hourly at :${schedule.minutesPastHour.map((m) => String(m).padStart(2, "0")).join(", :")}`] : [],
|
|
78691
|
+
...schedule.runCalendar !== void 0 ? [`on calendar ${schedule.runCalendar}`] : []
|
|
78692
|
+
];
|
|
78693
|
+
return `${at.join(" ")} ${describeDays(schedule.days)}${schedule.timezone !== void 0 ? ` (${schedule.timezone})` : ""}`;
|
|
78694
|
+
}
|
|
78695
|
+
};
|
|
78696
|
+
}
|
|
78697
|
+
var usualStartSchema = external_exports.object({
|
|
78698
|
+
jobs: external_exports.array(external_exports.string().min(1)).min(1).max(20).describe("Exact job names."),
|
|
78699
|
+
days: external_exports.number().int().min(1).max(365).optional().describe("How far back to look in the run history. Default 30."),
|
|
78700
|
+
fromDefinitions: external_exports.boolean().optional().describe("For a job started by a condition: also work its start out from its predecessors' definitions and run times. Default true.")
|
|
78701
|
+
});
|
|
78702
|
+
function createAutosysUsualStartTool(options) {
|
|
78703
|
+
return {
|
|
78704
|
+
name: "autosys_usual_start",
|
|
78705
|
+
group: "read",
|
|
78706
|
+
description: `When AutoSys jobs normally start, in local time - especially jobs with no start time of their own, started by a dependency or their box. Two answers: from the job's own run history (the usual time of day around the clock, and the range nine starts in ten fall in; manual starts and retries left out), and from the job definitions (the chain of predecessors up to jobs with start times, each with its typical run time). Answers "what time does PAY_LOAD usually start?".`,
|
|
78707
|
+
parametersSchema: usualStartSchema,
|
|
78708
|
+
async execute(params3) {
|
|
78709
|
+
try {
|
|
78710
|
+
const client = await options.client();
|
|
78711
|
+
const days = params3.days ?? 30;
|
|
78712
|
+
const now = /* @__PURE__ */ new Date();
|
|
78713
|
+
let historyMissing = false;
|
|
78714
|
+
const sections = await inBatches2([...new Set(params3.jobs.map((job) => job.trim()))], async (name) => {
|
|
78715
|
+
try {
|
|
78716
|
+
const source = predecessorSource(client);
|
|
78717
|
+
const definition = await source.definition(name);
|
|
78718
|
+
if (definition === void 0)
|
|
78719
|
+
return `${name}: the definition could not be read.`;
|
|
78720
|
+
const lines2 = [`${name}:`];
|
|
78721
|
+
const own = source.schedule(definition);
|
|
78722
|
+
const condition2 = field(definition, "condition");
|
|
78723
|
+
const box = field(definition, "boxName", "box_name");
|
|
78724
|
+
const startedBy = [condition2 !== void 0 ? `when: ${condition2}` : void 0, box !== void 0 ? `with its box ${box}` : void 0].filter((part) => part !== void 0);
|
|
78725
|
+
lines2.push(own !== void 0 ? ` its definition starts it ${own}.` : ` no start time of its own - started ${startedBy.join(", and ") || "by hand or by another instance"}.`);
|
|
78726
|
+
const [runs, eventRecords] = await Promise.all([recentRuns(client, name, days), client.eventHistory(name).catch(() => void 0)]);
|
|
78727
|
+
if (runs === void 0)
|
|
78728
|
+
historyMissing = true;
|
|
78729
|
+
const classified = classifyRuns(runs ?? [], eventRecords?.map(toJobEvent));
|
|
78730
|
+
const observed = timeOfDayStats(ownStarts(classified));
|
|
78731
|
+
lines2.push(observed === void 0 ? ` observed: no runs in the last ${String(days)} days to go by.` : ` observed over ${String(observed.count)} run(s): usually starts around ${clockOfMinute(observed.typical)}; nine in ten between ${clockOfMinute(observed.early)} and ${clockOfMinute(observed.late)}${observed.spreadMinutes > 180 ? " - spread over hours, so there is no single habit" : ""}${eventRecords === void 0 ? " (manual starts could not be left out: no event history)" : ""}.`);
|
|
78732
|
+
if (own === void 0 && params3.fromDefinitions !== false) {
|
|
78733
|
+
const trace = await tracePredecessors(source, name, { maxJobs: 60, maxDepth: 15 });
|
|
78734
|
+
const durations = /* @__PURE__ */ new Map();
|
|
78735
|
+
const startMinutes = /* @__PURE__ */ new Map();
|
|
78736
|
+
await inBatches2([...trace.nodes.values()], async (node) => {
|
|
78737
|
+
const key3 = node.name.toLowerCase();
|
|
78738
|
+
const found2 = source.definitions.get(key3);
|
|
78739
|
+
const first = found2 === void 0 ? void 0 : jobSchedule(found2)?.times[0];
|
|
78740
|
+
if (first !== void 0 && key3 !== name.toLowerCase()) {
|
|
78741
|
+
const [hour, minute] = first.split(":").map(Number);
|
|
78742
|
+
startMinutes.set(key3, (hour ?? 0) * 60 + (minute ?? 0));
|
|
78743
|
+
}
|
|
78744
|
+
const stats = durationStats(runDurations(await recentRuns(client, node.name, days).catch(() => void 0) ?? []).durations);
|
|
78745
|
+
if (stats !== void 0)
|
|
78746
|
+
durations.set(key3, stats.medianMs);
|
|
78747
|
+
});
|
|
78748
|
+
const expected = expectedStartFromDefinitions(trace, durations, startMinutes);
|
|
78749
|
+
lines2.push(expected.start !== void 0 ? ` from the definitions: about ${clockOfMinute(expected.start)}${expected.start >= 1440 ? " (the next day)" : ""} - ${expected.via.join(" -> ")}.` : ` from the definitions: cannot be worked out - ${expected.missing.slice(0, 6).join("; ") || "no predecessor with a start time"}.`);
|
|
78750
|
+
}
|
|
78751
|
+
return lines2.join("\n");
|
|
78752
|
+
} catch (error51) {
|
|
78753
|
+
return `${name}: ${error51 instanceof Error ? error51.message : String(error51)}`;
|
|
78754
|
+
}
|
|
78755
|
+
});
|
|
78756
|
+
return { content: [...sections, `Times are local (${localZone(now)}).`, ...historyMissing ? [NO_HISTORY] : []].join("\n\n") };
|
|
78757
|
+
} catch (error51) {
|
|
78758
|
+
return errorResult3(error51);
|
|
78759
|
+
}
|
|
78760
|
+
}
|
|
78761
|
+
};
|
|
78762
|
+
}
|
|
78763
|
+
var predecessorsSchema = external_exports.object({
|
|
78764
|
+
job: external_exports.string().min(1).describe("The exact job name."),
|
|
78765
|
+
maxDepth: external_exports.number().int().min(1).max(50).optional().describe("How many levels up to follow. Default 30 - effectively to the top."),
|
|
78766
|
+
maxJobs: external_exports.number().int().min(1).max(500).optional().describe("Stop after reading this many jobs. Default 200."),
|
|
78767
|
+
eta: external_exports.boolean().optional().describe("For predecessors RUNNING now, also say when each should finish (reads their run history). Default false.")
|
|
78768
|
+
});
|
|
78769
|
+
function createAutosysPredecessorsTool(options) {
|
|
78770
|
+
return {
|
|
78771
|
+
name: "autosys_predecessors",
|
|
78772
|
+
group: "read",
|
|
78773
|
+
description: 'Every predecessor of an AutoSys job, recursively up to the topmost jobs, from the job definitions: each job its condition names (met or not) and the box it sits in, then theirs - each with its status, last start and end, and whether its condition is met; topmost jobs with their start schedule. Ends with what is not met and what failed. Answers "what does PAY_LOAD depend on, all the way up, and where is it stuck?". With eta, running predecessors get an ETA in local time.',
|
|
78774
|
+
parametersSchema: predecessorsSchema,
|
|
78775
|
+
async execute(params3) {
|
|
78776
|
+
try {
|
|
78777
|
+
const client = await options.client();
|
|
78778
|
+
const now = /* @__PURE__ */ new Date();
|
|
78779
|
+
const source = predecessorSource(client);
|
|
78780
|
+
const trace = await tracePredecessors(source, params3.job.trim(), { maxJobs: params3.maxJobs ?? 200, maxDepth: params3.maxDepth ?? 30 });
|
|
78781
|
+
const etas = /* @__PURE__ */ new Map();
|
|
78782
|
+
if (params3.eta === true) {
|
|
78783
|
+
const running = [...trace.nodes.values()].filter((node) => node.status.toUpperCase() === "RUNNING" && parseAutosysTime(node.lastStart) !== void 0);
|
|
78784
|
+
await inBatches2(running, async (node) => {
|
|
78785
|
+
const stats = durationStats(runDurations(await recentRuns(client, node.name, 30).catch(() => void 0) ?? []).durations);
|
|
78786
|
+
const started = parseAutosysTime(node.lastStart) ?? now.getTime();
|
|
78787
|
+
if (stats === void 0)
|
|
78788
|
+
return;
|
|
78789
|
+
const eta = etaFor(started, stats, now.getTime());
|
|
78790
|
+
etas.set(node.name.toLowerCase(), eta.overrun ? `running long - nine in ten finish within ${formatDuration(stats.p90Ms)}` : `ETA ${localTime(eta.expected, now)} (latest ${localTime(eta.latest, now)})`);
|
|
78791
|
+
});
|
|
78792
|
+
}
|
|
78793
|
+
return { content: `${describeTrace(trace, (node) => etas.get(node.name.toLowerCase()))}${params3.eta === true ? `
|
|
78794
|
+
Times are local (${localZone(now)}).` : ""}` };
|
|
78795
|
+
} catch (error51) {
|
|
78796
|
+
return errorResult3(error51);
|
|
78797
|
+
}
|
|
78798
|
+
}
|
|
78799
|
+
};
|
|
78800
|
+
}
|
|
78334
78801
|
function createAutosysTools(options) {
|
|
78335
78802
|
return [
|
|
78336
78803
|
createAutosysFindJobsTool(options),
|
|
78337
78804
|
createAutosysJobTool(options),
|
|
78338
78805
|
createAutosysStatusTool(options),
|
|
78339
78806
|
createAutosysRunsTool(options),
|
|
78807
|
+
createAutosysRunStatsTool(options),
|
|
78808
|
+
createAutosysUsualStartTool(options),
|
|
78340
78809
|
createAutosysDependenciesTool(options),
|
|
78810
|
+
createAutosysPredecessorsTool(options),
|
|
78341
78811
|
createAutosysLogTool(options),
|
|
78342
78812
|
createAutosysMachinesTool(options),
|
|
78343
78813
|
createAutosysGlobalVariablesTool(options),
|
|
@@ -86617,6 +87087,13 @@ function wireChatBridge(services) {
|
|
|
86617
87087
|
const python = new PythonManager({
|
|
86618
87088
|
workspaceRoot,
|
|
86619
87089
|
storageDir,
|
|
87090
|
+
// The step Python is on, for the startup bar; a slow one is named in the log.
|
|
87091
|
+
onProgress: (step, tookMs) => {
|
|
87092
|
+
if (tookMs === void 0)
|
|
87093
|
+
startupStep("Python tools", step);
|
|
87094
|
+
else
|
|
87095
|
+
noteSlowStep(`Python tools: ${step}`, tookMs);
|
|
87096
|
+
},
|
|
86620
87097
|
...personalToolsDir !== void 0 ? { personalToolsDir, sharedWith: () => sharedWith("tools") } : {},
|
|
86621
87098
|
...services.codebaseDir !== void 0 ? { venvRoot: services.codebaseDir } : {},
|
|
86622
87099
|
logger,
|
|
@@ -86768,6 +87245,19 @@ ${preview.text}` } : {}
|
|
|
86768
87245
|
indexNames.set(client, { at: Date.now(), names });
|
|
86769
87246
|
return names;
|
|
86770
87247
|
}
|
|
87248
|
+
async function boundedWait(work, label, seconds = 20) {
|
|
87249
|
+
let timer;
|
|
87250
|
+
const late = await Promise.race([
|
|
87251
|
+
work.then(() => false, (error51) => {
|
|
87252
|
+
throw error51;
|
|
87253
|
+
}),
|
|
87254
|
+
new Promise((resolve) => {
|
|
87255
|
+
timer = setTimeout(() => resolve(true), seconds * 1e3);
|
|
87256
|
+
})
|
|
87257
|
+
]).finally(() => clearTimeout(timer));
|
|
87258
|
+
if (late)
|
|
87259
|
+
logger.info(`[startup] replying without waiting longer for ${label} (still loading after ${String(seconds)}s)`);
|
|
87260
|
+
}
|
|
86771
87261
|
function early(promise2) {
|
|
86772
87262
|
promise2.catch(() => void 0);
|
|
86773
87263
|
return promise2;
|
|
@@ -86828,7 +87318,13 @@ ${preview.text}` } : {}
|
|
|
86828
87318
|
const dirs = skillSearchPath();
|
|
86829
87319
|
if (dirs.length === 0)
|
|
86830
87320
|
return;
|
|
86831
|
-
const loaded = await loadSkills(dirs)
|
|
87321
|
+
const loaded = await loadSkills(dirs, (dir, tookMs) => {
|
|
87322
|
+
if (tookMs === void 0)
|
|
87323
|
+
startupStep("Skills", `reading ${dir}`);
|
|
87324
|
+
else
|
|
87325
|
+
noteSlowStep(`Skills: reading ${dir}`, tookMs);
|
|
87326
|
+
});
|
|
87327
|
+
startupStep("Skills", void 0);
|
|
86832
87328
|
skills = loaded.skills;
|
|
86833
87329
|
skillIssues = loaded.issues;
|
|
86834
87330
|
const signature = loaded.issues.map((issue2) => `${issue2.filePath}\0${issue2.detail}`).join("\n");
|
|
@@ -88266,6 +88762,18 @@ ${preview.text}` } : {}
|
|
|
88266
88762
|
mcpJson = JSON.stringify({ mcpServers: servers }, null, 2);
|
|
88267
88763
|
}
|
|
88268
88764
|
const startupWaits = /* @__PURE__ */ new Map();
|
|
88765
|
+
const startupDetails = /* @__PURE__ */ new Map();
|
|
88766
|
+
function startupStep(label, detail) {
|
|
88767
|
+
if (detail === void 0)
|
|
88768
|
+
startupDetails.delete(label);
|
|
88769
|
+
else
|
|
88770
|
+
startupDetails.set(label, detail);
|
|
88771
|
+
postStartupProgress();
|
|
88772
|
+
}
|
|
88773
|
+
function noteSlowStep(step, tookMs) {
|
|
88774
|
+
if (tookMs >= 2e3)
|
|
88775
|
+
logger.info(`[startup] ${step} took ${(tookMs / 1e3).toFixed(1)}s`);
|
|
88776
|
+
}
|
|
88269
88777
|
const mcpStartingSince = /* @__PURE__ */ new Map();
|
|
88270
88778
|
let lastStartupPosted = "";
|
|
88271
88779
|
function postStartupProgress(force = false) {
|
|
@@ -88284,7 +88792,7 @@ ${preview.text}` } : {}
|
|
|
88284
88792
|
mcpStartingSince.set(name, now);
|
|
88285
88793
|
const waiting = [
|
|
88286
88794
|
...[...mcpStartingSince].map(([name, since2]) => ({ label: `MCP server "${name}" starting`, since: since2 })),
|
|
88287
|
-
...[...startupWaits].map(([label, since2]) => ({ label, since: since2 }))
|
|
88795
|
+
...[...startupWaits].map(([label, since2]) => ({ label: startupDetails.has(label) ? `${label} - ${startupDetails.get(label) ?? ""}` : label, since: since2 }))
|
|
88288
88796
|
].sort((a, b) => a.since - b.since);
|
|
88289
88797
|
const key3 = JSON.stringify(waiting);
|
|
88290
88798
|
if (!force && key3 === lastStartupPosted)
|
|
@@ -88297,6 +88805,7 @@ ${preview.text}` } : {}
|
|
|
88297
88805
|
postStartupProgress();
|
|
88298
88806
|
return work.finally(() => {
|
|
88299
88807
|
startupWaits.delete(label);
|
|
88808
|
+
startupDetails.delete(label);
|
|
88300
88809
|
postStartupProgress();
|
|
88301
88810
|
});
|
|
88302
88811
|
}
|
|
@@ -89871,7 +90380,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89871
90380
|
void postStrategies();
|
|
89872
90381
|
}
|
|
89873
90382
|
const pendingSteeringPath = () => workspaceRoot === void 0 ? void 0 : pendingSteeringFile(storageDir, workspaceRoot);
|
|
89874
|
-
async function startNewTask() {
|
|
90383
|
+
async function startNewTask(options = {}) {
|
|
89875
90384
|
conversation.reset();
|
|
89876
90385
|
crashResumes = 0;
|
|
89877
90386
|
readFiles.clear();
|
|
@@ -89885,7 +90394,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89885
90394
|
truncationStore.startTask();
|
|
89886
90395
|
activePlan = void 0;
|
|
89887
90396
|
activePlanProgress = {};
|
|
89888
|
-
activeStrategy =
|
|
90397
|
+
activeStrategy = options.keepStrategy;
|
|
89889
90398
|
strategyProgress = {};
|
|
89890
90399
|
strategyExchanges = [];
|
|
89891
90400
|
strategyLastRole = void 0;
|
|
@@ -89893,8 +90402,12 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89893
90402
|
stopRoleProcesses();
|
|
89894
90403
|
await setActiveTaskId(void 0);
|
|
89895
90404
|
const pending = pendingSteeringPath();
|
|
89896
|
-
if (pending !== void 0 && backgroundRun !== true)
|
|
89897
|
-
|
|
90405
|
+
if (pending !== void 0 && backgroundRun !== true) {
|
|
90406
|
+
if (options.keepStrategy !== void 0)
|
|
90407
|
+
await persistActiveTask();
|
|
90408
|
+
else
|
|
90409
|
+
await clearPendingSteering(pending);
|
|
90410
|
+
}
|
|
89898
90411
|
post({ type: "taskRestored", taskId: void 0, entries: [] });
|
|
89899
90412
|
post({ type: "plan", plan: "" });
|
|
89900
90413
|
postPlanProgress();
|
|
@@ -90117,7 +90630,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
90117
90630
|
const mailCollection = config2.mail?.enabled === true ? mailCollectionName(config2) : void 0;
|
|
90118
90631
|
const mailSearch = mailCollection === void 0 ? void 0 : await resolveMailSearch(config2);
|
|
90119
90632
|
const searchIndexes = search?.opensearch !== void 0 ? await indexNamesFor(search.opensearch) : [];
|
|
90120
|
-
await skillsReady;
|
|
90633
|
+
await boundedWait(skillsReady, "Skills");
|
|
90121
90634
|
const codebaseInstructions = renderCodebaseInstructions(await instructionsReady);
|
|
90122
90635
|
const activeMode = findMode(config2.modeId);
|
|
90123
90636
|
juniorTurnWithoutExpert = activeMode.id === "junior" && schedule === void 0;
|
|
@@ -90244,7 +90757,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
90244
90757
|
});
|
|
90245
90758
|
if (conversation.systemPrompt() !== desiredPrompt)
|
|
90246
90759
|
conversation.setSystemPrompt(desiredPrompt);
|
|
90247
|
-
await toolsReady;
|
|
90760
|
+
await boundedWait(toolsReady, "Tools", 45);
|
|
90248
90761
|
const toolContext = {
|
|
90249
90762
|
fs: new NodeFileSystem(),
|
|
90250
90763
|
// The shell the user chose, or the platform default. Read per turn, so changing it
|
|
@@ -97024,7 +97537,7 @@ ${notes.join("\n")}` : forMain };
|
|
|
97024
97537
|
} else if (message6.type === "deleteTask") {
|
|
97025
97538
|
reportFailure("deleteTask", deleteTask(message6.id));
|
|
97026
97539
|
} else if (message6.type === "newTask") {
|
|
97027
|
-
reportFailure("startNewTask", startNewTask());
|
|
97540
|
+
reportFailure("startNewTask", startNewTask({ keepStrategy: activeStrategy }));
|
|
97028
97541
|
} else if (message6.type === "startHandoff") {
|
|
97029
97542
|
reportFailure("handleHandoff", handleHandoff());
|
|
97030
97543
|
} else if (message6.type === "cancelHandoff") {
|
|
@@ -97173,6 +97686,12 @@ ${notes.join("\n")}` : forMain };
|
|
|
97173
97686
|
} else if (message6.type === "useStrategy") {
|
|
97174
97687
|
reportFailure("useStrategy", (async () => {
|
|
97175
97688
|
const config2 = (await configManager.load()).config;
|
|
97689
|
+
const carried = message6.strategy === void 0 ? void 0 : strategySchema.safeParse(message6.strategy);
|
|
97690
|
+
if (carried !== void 0) {
|
|
97691
|
+
if (carried.success)
|
|
97692
|
+
await useStrategy(carried.data);
|
|
97693
|
+
return;
|
|
97694
|
+
}
|
|
97176
97695
|
await useStrategy(message6.id === void 0 ? void 0 : (config2.strategies ?? []).find((each) => each.id === message6.id));
|
|
97177
97696
|
})());
|
|
97178
97697
|
} else if (message6.type === "requestTeam") {
|
|
@@ -100425,6 +100944,15 @@ an access token as a Bearer token, leave the user id empty and paste that token
|
|
|
100425
100944
|
"job dependencies",
|
|
100426
100945
|
"condition",
|
|
100427
100946
|
"box",
|
|
100947
|
+
"average run time",
|
|
100948
|
+
"how long does",
|
|
100949
|
+
"eta",
|
|
100950
|
+
"when will it finish",
|
|
100951
|
+
"usual start time",
|
|
100952
|
+
"normal start time",
|
|
100953
|
+
"predecessors",
|
|
100954
|
+
"upstream jobs",
|
|
100955
|
+
"top most job",
|
|
100428
100956
|
"why has my job not started",
|
|
100429
100957
|
"job failed",
|
|
100430
100958
|
"job log",
|
|
@@ -100571,6 +101099,19 @@ with the section \`autosysAddresses\`), for example next to an onboarding page.
|
|
|
100571
101099
|
It needs the server's run history and event history; where those live elsewhere set
|
|
100572
101100
|
config:autosys (paths) runHistory and eventHistory, and the tool names which one is missing. A run
|
|
100573
101101
|
with no event record is reported as "not known", never guessed as scheduled.
|
|
101102
|
+
- \`autosys_run_stats\` \u2014 **how long a job usually runs**, from its run history (last 30 days, or as many as you
|
|
101103
|
+
say): typical (median), average, fastest, slowest, and the time nine runs in ten finish within - successful runs
|
|
101104
|
+
only when there are any. For a job **running now**, an **ETA in local time**: when it should finish at its typical
|
|
101105
|
+
run time, the likely latest, and whether it is already running longer than usual.
|
|
101106
|
+
- \`autosys_usual_start\` \u2014 **when a job normally starts**, in local time, especially one with no start time that a
|
|
101107
|
+
dependency or its box starts. Two answers side by side: what its run history shows (the usual time of day,
|
|
101108
|
+
measured around the clock so a midnight job comes out right, and the range nine starts in ten fall in; manual
|
|
101109
|
+
starts and retries left out), and what its **definitions** imply (its predecessors up to jobs with start times,
|
|
101110
|
+
each with its typical run time - "GL_EXTRACT starts at 01:00 -> PAY_LOAD after it (01:30) -> this job (02:10)").
|
|
101111
|
+
- \`autosys_predecessors\` \u2014 **every predecessor of a job, all the way up**, from the job definitions: each job its
|
|
101112
|
+
condition names (met or not) and the box it sits in, then theirs, until the topmost jobs (no condition, no box),
|
|
101113
|
+
each with its status, last start and end, and its start schedule at the top. Ends with what is not met and what
|
|
101114
|
+
failed. With eta, predecessors running now get an ETA too - "when will my job start?".
|
|
100574
101115
|
- Ask it to **follow a job until it finishes**: it checks the status, waits, and checks again.
|
|
100575
101116
|
- \`autosys_job_log\` \u2014 a job's stderr or stdout, the end of it or matching lines. If the server
|
|
100576
101117
|
offers no log endpoint, it says which file on which machine the job writes to instead.
|
|
@@ -102252,7 +102793,10 @@ without waiting for the servers; a server keeps starting in the background, and
|
|
|
102252
102793
|
tools waits for it. A server with no remembered list is waited for at most 45 seconds, after which the
|
|
102253
102794
|
reply goes ahead and its tools join the next message. While anything is still getting ready, a bar over
|
|
102254
102795
|
the message box names it with how long it has taken - each MCP server still starting, Python tools, skills, the model
|
|
102255
|
-
gateway's sign-in - and
|
|
102796
|
+
gateway's sign-in - and, for skills and Python tools, which folder or step is under way; it goes when nothing is left.
|
|
102797
|
+
A message sent meanwhile waits at most 20 seconds for skills and 45 for tools, then is answered with what has loaded;
|
|
102798
|
+
the rest joins the next message. When that keeps happening, a slow folder (often a network share or a disconnected
|
|
102799
|
+
drive) is the usual cause - the log names it. The agent log
|
|
102256
102800
|
(\`host.log\`) also names each slow part with a \`[startup]\` line.
|
|
102257
102801
|
|
|
102258
102802
|
**Not in Fire Code**: editor file pickers \u2014 paths are typed. Fire Code's
|
|
@@ -102627,7 +103171,9 @@ connectors between them, else as drawn. A box of either kind can be switched on
|
|
|
102627
103171
|
"Run as a group").
|
|
102628
103172
|
|
|
102629
103173
|
**A strategy belongs to its chat.** Each chat keeps its own strategy, or none: choosing one with **Save and use in
|
|
102630
|
-
this chat** sets it for that chat only
|
|
103174
|
+
this chat** sets it for that chat only. A new chat started from it - **+**, New chat, or in Fire Code a new tab -
|
|
103175
|
+
keeps the same strategy with its loops starting afresh; a chat with no strategy gives a new chat with none, and **Stop
|
|
103176
|
+
using** takes it off. It is saved with the chat
|
|
102631
103177
|
and comes back whenever the chat does - reopened from History, after the window reloads, when a Fire Code chat wakes
|
|
102632
103178
|
from sleep or restarts after a crash - and it is kept even if you chose it before sending anything. **New chat with a
|
|
102633
103179
|
handoff** carries it into the new chat. **Stop using** in the Strategy window takes it off the chat. Every request in
|