@chosengeneration/light-code 0.147.0 → 0.148.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.
Files changed (3) hide show
  1. package/dist/cli.cjs +841 -138
  2. package/dist/server.cjs +838 -135
  3. package/package.json +1 -1
package/dist/server.cjs CHANGED
@@ -11294,9 +11294,9 @@ var require_headers = __commonJS({
11294
11294
  // https://fetch.spec.whatwg.org/#dom-headers-getsetcookie
11295
11295
  getSetCookie() {
11296
11296
  webidl.brandCheck(this, _Headers);
11297
- const list = this[kHeadersList].cookies;
11298
- if (list) {
11299
- return [...list];
11297
+ const list2 = this[kHeadersList].cookies;
11298
+ if (list2) {
11299
+ return [...list2];
11300
11300
  }
11301
11301
  return [];
11302
11302
  }
@@ -23623,8 +23623,8 @@ var require_dist = __commonJS({
23623
23623
  return ajv;
23624
23624
  }
23625
23625
  const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
23626
- const list = opts.formats || formats_1.formatNames;
23627
- addFormats(ajv, list, formats, exportName);
23626
+ const list2 = opts.formats || formats_1.formatNames;
23627
+ addFormats(ajv, list2, formats, exportName);
23628
23628
  if (opts.keywords)
23629
23629
  (0, limit_1.default)(ajv);
23630
23630
  return ajv;
@@ -23636,11 +23636,11 @@ var require_dist = __commonJS({
23636
23636
  throw new Error(`Unknown format "${name}"`);
23637
23637
  return f;
23638
23638
  };
23639
- function addFormats(ajv, list, fs41, exportName) {
23639
+ function addFormats(ajv, list2, fs41, exportName) {
23640
23640
  var _a3;
23641
23641
  var _b;
23642
23642
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
23643
- for (const f of list)
23643
+ for (const f of list2)
23644
23644
  ajv.addFormat(f, fs41[f]);
23645
23645
  }
23646
23646
  module2.exports = exports2 = formatsPlugin;
@@ -40447,7 +40447,13 @@ var atlassianConnectionShape = {
40447
40447
  baseUrl: external_exports.string().url(),
40448
40448
  tokenRef: external_exports.string().min(1),
40449
40449
  caFile: external_exports.string().min(1),
40450
- rejectUnauthorized: external_exports.boolean()
40450
+ rejectUnauthorized: external_exports.boolean(),
40451
+ /**
40452
+ * The user has read access only. Every tool that would change something on this site is left out
40453
+ * and the readers say the access is read-only (`atlassian/readOnly.ts`), so the agent neither tries
40454
+ * a change the server will refuse nor asks the user to approve one.
40455
+ */
40456
+ readOnly: external_exports.boolean()
40451
40457
  };
40452
40458
  var usageStoreSchema = external_exports.object({
40453
40459
  kind: external_exports.enum(["folder", "s3", "vector"]),
@@ -40596,7 +40602,9 @@ var configSchema = external_exports.object({
40596
40602
  /** Extra CA for this site. Adds to the global roots rather than replacing them (§19). */
40597
40603
  caFile: external_exports.string().min(1),
40598
40604
  /** The escape hatch, never the fix — see the provider profile's own `tls` (§10). */
40599
- rejectUnauthorized: external_exports.boolean()
40605
+ rejectUnauthorized: external_exports.boolean(),
40606
+ /** Read access only: the writing tool is left out (`atlassian/readOnly.ts`). */
40607
+ readOnly: external_exports.boolean()
40600
40608
  }).partial(),
40601
40609
  /**
40602
40610
  * Jira Data Center / Server. Same connection shape as `confluence`, same reasons for being
@@ -40638,7 +40646,12 @@ var configSchema = external_exports.object({
40638
40646
  boxMembers: external_exports.string().min(1),
40639
40647
  event: external_exports.string().min(1),
40640
40648
  jil: external_exports.string().min(1),
40641
- log: external_exports.string().min(1)
40649
+ log: external_exports.string().min(1),
40650
+ machines: external_exports.string().min(1),
40651
+ machine: external_exports.string().min(1),
40652
+ globalVariables: external_exports.string().min(1),
40653
+ calendar: external_exports.string().min(1),
40654
+ extendedCalendar: external_exports.string().min(1)
40642
40655
  }).partial()
40643
40656
  }).partial(),
40644
40657
  /** Bitbucket Data Center / Server. As `jira`. */
@@ -42730,9 +42743,9 @@ function resolveModelCapabilities(modelId, overrides) {
42730
42743
  var WINDOW_FIELDS = ["max_model_len", "context_length", "context_window", "max_context_length", "inputTokenLimit", "max_input_tokens"];
42731
42744
  function extractContextWindows(payload) {
42732
42745
  const container = payload;
42733
- const list = Array.isArray(container?.data) ? container.data : Array.isArray(container?.models) ? container.models : [];
42746
+ const list2 = Array.isArray(container?.data) ? container.data : Array.isArray(container?.models) ? container.models : [];
42734
42747
  const windows = {};
42735
- for (const entry of list) {
42748
+ for (const entry of list2) {
42736
42749
  const record2 = entry;
42737
42750
  if (record2 === null || typeof record2 !== "object")
42738
42751
  continue;
@@ -42771,9 +42784,9 @@ function withReportedWindow(capabilities, reported, overrides) {
42771
42784
  }
42772
42785
  function extractModelIds(payload) {
42773
42786
  const container = payload;
42774
- const list = Array.isArray(container?.data) ? container.data : Array.isArray(container?.models) ? container.models : Array.isArray(payload) ? payload : [];
42787
+ const list2 = Array.isArray(container?.data) ? container.data : Array.isArray(container?.models) ? container.models : Array.isArray(payload) ? payload : [];
42775
42788
  const ids = [];
42776
- for (const entry of list) {
42789
+ for (const entry of list2) {
42777
42790
  if (typeof entry === "string") {
42778
42791
  ids.push(entry);
42779
42792
  continue;
@@ -46754,12 +46767,12 @@ function buildExpertBriefing(input) {
46754
46767
 
46755
46768
  // ../../packages/core/dist/expert/assessments.js
46756
46769
  function allAssessments(expert) {
46757
- const list = [...expert.assessments ?? []];
46770
+ const list2 = [...expert.assessments ?? []];
46758
46771
  const legacy = expert.assessment;
46759
- if (legacy !== void 0 && !list.some((entry) => sameSubject(entry, legacy))) {
46760
- list.push(legacy);
46772
+ if (legacy !== void 0 && !list2.some((entry) => sameSubject(entry, legacy))) {
46773
+ list2.push(legacy);
46761
46774
  }
46762
- return list.sort((a, b) => b.assessedAt - a.assessedAt);
46775
+ return list2.sort((a, b) => b.assessedAt - a.assessedAt);
46763
46776
  }
46764
46777
  function assessmentFor(all, model, profileLabel) {
46765
46778
  if (model.length === 0)
@@ -50055,10 +50068,10 @@ function decodeEntities2(text) {
50055
50068
  }
50056
50069
  function formattingOf(tag) {
50057
50070
  const style = /style\s*=\s*"([^"]*)"/i.exec(tag)?.[1] ?? /style\s*=\s*'([^']*)'/i.exec(tag)?.[1] ?? "";
50058
- const attribute = /\bcolor\s*=\s*"([^"]*)"/i.exec(tag)?.[1] ?? /\bcolor\s*=\s*'([^']*)'/i.exec(tag)?.[1];
50071
+ const attribute2 = /\bcolor\s*=\s*"([^"]*)"/i.exec(tag)?.[1] ?? /\bcolor\s*=\s*'([^']*)'/i.exec(tag)?.[1];
50059
50072
  const declared = /(?:^|;)\s*color\s*:\s*([^;]+)/i.exec(style)?.[1];
50060
50073
  const background = /(?:^|;)\s*background(?:-color)?\s*:\s*([^;]+)/i.exec(style)?.[1] ?? /(?:^|;)\s*mso-highlight\s*:\s*([^;]+)/i.exec(style)?.[1];
50061
- const colour = describeColour(declared ?? attribute ?? "");
50074
+ const colour = describeColour(declared ?? attribute2 ?? "");
50062
50075
  const highlight = describeColour(background ?? "");
50063
50076
  return {
50064
50077
  ...colour === void 0 ? {} : { colour },
@@ -50433,9 +50446,9 @@ function createExcelTraceTool(options) {
50433
50446
  return { content: `Nothing found at ${result.start} \u2014 the cell may be empty.` };
50434
50447
  }
50435
50448
  const lines2 = result.nodes.map((node) => {
50436
- const indent = " ".repeat(Number(node.depth ?? 0));
50449
+ const indent2 = " ".repeat(Number(node.depth ?? 0));
50437
50450
  const feeds = Array.isArray(node.feeds) && node.feeds.length > 0 ? ` <- ${node.feeds.join(", ")}` : "";
50438
- return `${indent}${renderCell(node)}${feeds}`;
50451
+ return `${indent2}${renderCell(node)}${feeds}`;
50439
50452
  });
50440
50453
  return {
50441
50454
  content: [
@@ -65125,7 +65138,7 @@ async function plan(runtime, context, params3) {
65125
65138
  } catch {
65126
65139
  return { ok: false, message: `${params3.file} does not exist.` };
65127
65140
  }
65128
- const excerpt = script.length > SCRIPT_PREVIEW_CHARS ? `${script.slice(0, SCRIPT_PREVIEW_CHARS)}
65141
+ const excerpt2 = script.length > SCRIPT_PREVIEW_CHARS ? `${script.slice(0, SCRIPT_PREVIEW_CHARS)}
65129
65142
  \u2026 (${String(script.length)} characters in all)` : script;
65130
65143
  return {
65131
65144
  ok: true,
@@ -65133,7 +65146,7 @@ async function plan(runtime, context, params3) {
65133
65146
  shown: `python ${[where.remote, ...params3.args ?? []].join(" ")}
65134
65147
 
65135
65148
  --- ${where.remote} ---
65136
- ${excerpt}`,
65149
+ ${excerpt2}`,
65137
65150
  where: `the hub, in ${folder2 || "the top folder"}`,
65138
65151
  local: where.local
65139
65152
  };
@@ -66504,7 +66517,7 @@ ${scanned}${answer.limitReached === true ? " The limit was reached; more match."
66504
66517
  }
66505
66518
  if (params3.action === "summary") {
66506
66519
  const ext = answer.byExtension ?? [];
66507
- const list = (key2) => {
66520
+ const list2 = (key2) => {
66508
66521
  const items = answer[key2] ?? [];
66509
66522
  return items.filter((i) => !isSecretPath(i.path)).map((i) => ` ${formatBytes(i.size)} ${when(i.modified)} ${i.path}`).join("\n");
66510
66523
  };
@@ -66515,10 +66528,10 @@ By type:
66515
66528
  ${ext.map((e) => ` .${e.extension} ${String(e.files)} files ${formatBytes(e.bytes)}`).join("\n")}
66516
66529
 
66517
66530
  Largest:
66518
- ${list("largest")}
66531
+ ${list2("largest")}
66519
66532
 
66520
66533
  Newest:
66521
- ${list("newest")}
66534
+ ${list2("newest")}
66522
66535
 
66523
66536
  ${scanned}`
66524
66537
  };
@@ -67488,9 +67501,9 @@ function unwrap(name, args) {
67488
67501
  }
67489
67502
  function handoffFacts(messages) {
67490
67503
  const facts = { userMessages: [], filesRead: [], filesChanged: [], commands: [] };
67491
- const add = (list, value) => {
67492
- if (typeof value === "string" && value.trim().length > 0 && !list.includes(value.trim()))
67493
- list.push(value.trim());
67504
+ const add = (list2, value) => {
67505
+ if (typeof value === "string" && value.trim().length > 0 && !list2.includes(value.trim()))
67506
+ list2.push(value.trim());
67494
67507
  };
67495
67508
  for (const message4 of messages) {
67496
67509
  if (message4.role === "user") {
@@ -67580,14 +67593,14 @@ function composeHandoff(note, facts, previousTitle) {
67580
67593
  for (const text of kept)
67581
67594
  lines2.push("", ...text.split("\n").map((line) => `> ${line}`));
67582
67595
  }
67583
- const list = (title, items, code) => {
67596
+ const list2 = (title, items, code) => {
67584
67597
  if (items.length === 0)
67585
67598
  return;
67586
67599
  lines2.push("", `## ${title}`, ...items.map((item) => `- ${code ? `\`${item.replace(/`/g, "'")}\`` : item}`));
67587
67600
  };
67588
- list("Files changed", facts.filesChanged, true);
67589
- list("Files read", facts.filesRead, true);
67590
- list("Commands run", facts.commands, true);
67601
+ list2("Files changed", facts.filesChanged, true);
67602
+ list2("Files read", facts.filesRead, true);
67603
+ list2("Commands run", facts.commands, true);
67591
67604
  return lines2.join("\n");
67592
67605
  }
67593
67606
 
@@ -71110,11 +71123,11 @@ function describeAtlassianFailure(product, doing, status2, body) {
71110
71123
  case 400:
71111
71124
  return `${label} refused ${doing}.${said}` + (product === "confluence" && /xhtml/i.test(message4) ? " The page body is not valid storage format \u2014 every tag must be closed and every macro well formed." : "");
71112
71125
  case 401:
71113
- return `${label} did not accept the personal access token while ${doing}. It may have expired or been revoked: create a new one and save it in Settings \u2192 DevOps \u2192 ${label}.`;
71126
+ return product === "autosys" || product === "jenkins" ? `${label} answered HTTP 401 (not signed in) while ${doing}: it did not accept the credentials sent.${said} Check the user and password or token in Settings \u2192 DevOps \u2192 ${label} - and, through an API gateway, its consumer key and secret. Test connection's Details show exactly what was sent.` : `${label} answered HTTP 401 (not signed in) while ${doing}: it did not accept the personal access token.${said} It may have expired or been revoked: create a new one and save it in Settings \u2192 DevOps \u2192 ${label}.`;
71114
71127
  case 403:
71115
- return `The token's owner is not allowed to do this (${doing}).${said} Ask an administrator for permission.`;
71128
+ return `${label} answered HTTP 403 (forbidden) while ${doing}: the sign-in was recognised, but the account it was sent as is not allowed to do this.${said} Ask the ${label} administrators to grant that account access - Test connection's Details show which account and address were used.`;
71116
71129
  case 404:
71117
- return `${label} found nothing while ${doing}.${said} Check the key, id or path.`;
71130
+ return `${label} answered HTTP 404 (not found) while ${doing}.${said} Check the key, id or path - or, for an address that differs on this server, the site address.`;
71118
71131
  case 409:
71119
71132
  return `Someone changed it while ${doing}, so nothing was overwritten.${said} Read it again and redo the change against the current version.`;
71120
71133
  default:
@@ -71202,9 +71215,9 @@ function boxFor(label, note, face = "regular", size = "normal") {
71202
71215
  function backEdges(spec) {
71203
71216
  const outgoing = /* @__PURE__ */ new Map();
71204
71217
  for (const [index, edge] of spec.edges.entries()) {
71205
- const list = outgoing.get(edge.from) ?? [];
71206
- list.push({ to: edge.to, index });
71207
- outgoing.set(edge.from, list);
71218
+ const list2 = outgoing.get(edge.from) ?? [];
71219
+ list2.push({ to: edge.to, index });
71220
+ outgoing.set(edge.from, list2);
71208
71221
  }
71209
71222
  const back = /* @__PURE__ */ new Set();
71210
71223
  const state = /* @__PURE__ */ new Map();
@@ -71264,9 +71277,9 @@ function order(spec, ranks, back) {
71264
71277
  for (const [index, edge] of spec.edges.entries()) {
71265
71278
  if (back.has(index))
71266
71279
  continue;
71267
- const list = parents.get(edge.to) ?? [];
71268
- list.push(edge.from);
71269
- parents.set(edge.to, list);
71280
+ const list2 = parents.get(edge.to) ?? [];
71281
+ list2.push(edge.from);
71282
+ parents.set(edge.to, list2);
71270
71283
  }
71271
71284
  for (let depth = 1; depth < byRank.length; depth += 1) {
71272
71285
  const above = byRank[depth - 1] ?? [];
@@ -72126,13 +72139,13 @@ function createBitbucketPullRequestsTool(options) {
72126
72139
  async execute(params3) {
72127
72140
  try {
72128
72141
  const repo = resolveRepo(options, params3);
72129
- const list = await (await options.client()).pullRequests(repo, params3.state ?? "OPEN", params3.limit ?? 20);
72130
- if (list.length === 0)
72142
+ const list2 = await (await options.client()).pullRequests(repo, params3.state ?? "OPEN", params3.limit ?? 20);
72143
+ if (list2.length === 0)
72131
72144
  return { content: `No ${(params3.state ?? "OPEN").toLowerCase()} pull requests in ${repo.project}/${repo.repo}.` };
72132
72145
  return {
72133
72146
  content: [
72134
- `${String(list.length)} pull request(s) in ${repo.project}/${repo.repo}:`,
72135
- ...list.map((pr) => `- #${String(pr.id)} [${pr.state}] ${pr.title} \u2014 ${pr.author}, ${pr.from} \u2192 ${pr.to} ${pr.url}`)
72147
+ `${String(list2.length)} pull request(s) in ${repo.project}/${repo.repo}:`,
72148
+ ...list2.map((pr) => `- #${String(pr.id)} [${pr.state}] ${pr.title} \u2014 ${pr.author}, ${pr.from} \u2192 ${pr.to} ${pr.url}`)
72136
72149
  ].join("\n")
72137
72150
  };
72138
72151
  } catch (error51) {
@@ -73110,6 +73123,122 @@ function createJenkinsTools(options) {
73110
73123
  ];
73111
73124
  }
73112
73125
 
73126
+ // ../../packages/core/dist/atlassian/autosysSchedule.js
73127
+ function wildcardMatches(pattern, value) {
73128
+ if (value === void 0)
73129
+ return false;
73130
+ const source = pattern.trim().split("").map((c2) => c2 === "*" ? ".*" : c2 === "?" ? "." : c2.replace(/[.+^${}()|[\]\\]/g, "\\$&")).join("");
73131
+ return new RegExp(`^${source}$`, "i").test(value.trim());
73132
+ }
73133
+ function parseAutosysTime(value) {
73134
+ if (value === void 0)
73135
+ return void 0;
73136
+ const text = value.trim();
73137
+ if (text.length === 0 || /^-+$/.test(text))
73138
+ return void 0;
73139
+ if (/^\d+$/.test(text)) {
73140
+ const n = Number(text);
73141
+ if (n <= 0)
73142
+ return void 0;
73143
+ return n < 1e11 ? n * 1e3 : n;
73144
+ }
73145
+ const autorep = /^(\d{1,2})\/(\d{1,2})\/(\d{4})\s+(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(text);
73146
+ if (autorep !== null) {
73147
+ const [, month, day, year, hour, minute, second] = autorep;
73148
+ return new Date(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), Number(second ?? "0")).getTime();
73149
+ }
73150
+ const parsed = Date.parse(text);
73151
+ return Number.isNaN(parsed) ? void 0 : parsed;
73152
+ }
73153
+ var WEEKDAYS = ["su", "mo", "tu", "we", "th", "fr", "sa"];
73154
+ function attribute(definition, snake) {
73155
+ const camel = snake.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
73156
+ for (const key2 of [snake, camel]) {
73157
+ const value = definition[key2];
73158
+ if (value === void 0 || value === null || value === "")
73159
+ continue;
73160
+ return Array.isArray(value) ? value.map(String).join(",") : String(value);
73161
+ }
73162
+ return void 0;
73163
+ }
73164
+ function list(value) {
73165
+ return (value ?? "").replace(/"/g, "").split(/[,\s]+/).map((part) => part.trim()).filter((part) => part.length > 0);
73166
+ }
73167
+ function jobSchedule(definition) {
73168
+ const times = list(attribute(definition, "start_times")).map((time3) => /^(\d{1,2}):(\d{2})$/.exec(time3)).filter((match) => match !== null).map((match) => `${(match[1] ?? "0").padStart(2, "0")}:${match[2] ?? "00"}`).sort();
73169
+ const minutesPastHour = list(attribute(definition, "start_mins")).map(Number).filter((minute) => Number.isInteger(minute) && minute >= 0 && minute < 60).sort((a, b) => a - b);
73170
+ const runCalendar = attribute(definition, "run_calendar");
73171
+ if (times.length === 0 && minutesPastHour.length === 0 && runCalendar === void 0)
73172
+ return void 0;
73173
+ const dayWords = list(attribute(definition, "days_of_week")).map((day) => day.toLowerCase().slice(0, 2));
73174
+ const days = dayWords.length === 0 || dayWords.includes("al") ? void 0 : WEEKDAYS.filter((day) => dayWords.includes(day));
73175
+ return {
73176
+ times,
73177
+ minutesPastHour,
73178
+ ...days !== void 0 ? { days } : {},
73179
+ ...runCalendar !== void 0 ? { runCalendar } : {},
73180
+ ...attribute(definition, "exclude_calendar") !== void 0 ? { excludeCalendar: attribute(definition, "exclude_calendar") } : {},
73181
+ ...attribute(definition, "run_window") !== void 0 ? { runWindow: attribute(definition, "run_window") } : {},
73182
+ ...attribute(definition, "timezone") !== void 0 ? { timezone: attribute(definition, "timezone") } : {}
73183
+ };
73184
+ }
73185
+ function minutesOf(time3) {
73186
+ const [hour, minute] = time3.split(":").map(Number);
73187
+ return (hour ?? 0) * 60 + (minute ?? 0);
73188
+ }
73189
+ function startsInWindow(schedule, from, to, day) {
73190
+ if (day !== void 0 && schedule.days !== void 0 && !schedule.days.includes(day))
73191
+ return [];
73192
+ const start = minutesOf(from);
73193
+ const end = minutesOf(to);
73194
+ const inWindow = (minute) => start <= end ? minute >= start && minute <= end : minute >= start || minute <= end;
73195
+ const hourly = [];
73196
+ for (let hour = 0; hour < 24; hour++) {
73197
+ for (const minute of schedule.minutesPastHour)
73198
+ hourly.push(`${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`);
73199
+ }
73200
+ return [.../* @__PURE__ */ new Set([...schedule.times, ...hourly])].filter((time3) => inWindow(minutesOf(time3))).sort();
73201
+ }
73202
+ function describeDays(days) {
73203
+ if (days === void 0)
73204
+ return "every day";
73205
+ const names = { su: "Sun", mo: "Mon", tu: "Tue", we: "Wed", th: "Thu", fr: "Fri", sa: "Sat" };
73206
+ return days.map((day) => names[day]).join(", ");
73207
+ }
73208
+ function weekdayOf(text, now = /* @__PURE__ */ new Date()) {
73209
+ const word = text.trim().toLowerCase();
73210
+ if (word === "today")
73211
+ return WEEKDAYS[now.getDay()];
73212
+ if (word === "tomorrow")
73213
+ return WEEKDAYS[(now.getDay() + 1) % 7];
73214
+ const short = word.slice(0, 2);
73215
+ if (WEEKDAYS.includes(short) && /^[a-z]+$/.test(word))
73216
+ return short;
73217
+ const date5 = /^(\d{4})-(\d{2})-(\d{2})$/.exec(word);
73218
+ if (date5 !== null)
73219
+ return WEEKDAYS[new Date(Number(date5[1]), Number(date5[2]) - 1, Number(date5[3])).getDay()];
73220
+ return void 0;
73221
+ }
73222
+ function calendarDates(records) {
73223
+ const found2 = /* @__PURE__ */ new Set();
73224
+ const visit = (value) => {
73225
+ if (typeof value === "string" || typeof value === "number") {
73226
+ const text = String(value).trim();
73227
+ const iso = /^(\d{4})-(\d{2})-(\d{2})/.exec(text);
73228
+ const us = /^(\d{1,2})\/(\d{1,2})\/(\d{4})/.exec(text);
73229
+ if (iso !== null)
73230
+ found2.add(`${iso[1] ?? ""}-${iso[2] ?? ""}-${iso[3] ?? ""}`);
73231
+ else if (us !== null)
73232
+ found2.add(`${us[3] ?? ""}-${(us[1] ?? "").padStart(2, "0")}-${(us[2] ?? "").padStart(2, "0")}`);
73233
+ } else if (Array.isArray(value))
73234
+ value.forEach(visit);
73235
+ else if (value !== null && typeof value === "object")
73236
+ Object.values(value).forEach(visit);
73237
+ };
73238
+ records.forEach(visit);
73239
+ return [...found2].sort();
73240
+ }
73241
+
73113
73242
  // ../../packages/core/dist/atlassian/autosys.js
73114
73243
  var DEFAULT_AUTOSYS_PATHS = {
73115
73244
  jobs: "/AEWS/job?filter={filter:name}",
@@ -73119,7 +73248,12 @@ var DEFAULT_AUTOSYS_PATHS = {
73119
73248
  boxMembers: "/AEWS/job?filter={filter:boxName}",
73120
73249
  event: "/AEWS/event",
73121
73250
  jil: "/AEWS/jil",
73122
- log: "/AEWS/job-log/{job}?runNum={runNum}&type={type}"
73251
+ log: "/AEWS/job-log/{job}?runNum={runNum}&type={type}",
73252
+ machines: "/AEWS/machine?filter={filter:name}",
73253
+ machine: "/AEWS/machine/{machine}",
73254
+ globalVariables: "/AEWS/global-variable?filter={filter:name}",
73255
+ calendar: "/AEWS/calendar/standard/{calendar}",
73256
+ extendedCalendar: "/AEWS/calendar/extended/{calendar}"
73123
73257
  };
73124
73258
  function isAutosysName(name, pattern = false) {
73125
73259
  return (pattern ? /^[A-Za-z0-9._#*-]{1,64}$/ : /^[A-Za-z0-9._#-]{1,64}$/).test(name);
@@ -73152,15 +73286,15 @@ function field(record2, ...names) {
73152
73286
  }
73153
73287
  return void 0;
73154
73288
  }
73155
- function renderDefinition(record2, indent = "") {
73289
+ function renderDefinition(record2, indent2 = "") {
73156
73290
  const lines2 = [];
73157
73291
  for (const [key2, value] of Object.entries(record2)) {
73158
73292
  if (value === null || value === void 0 || value === "")
73159
73293
  continue;
73160
73294
  if (typeof value === "object" && !Array.isArray(value)) {
73161
- lines2.push(`${indent}${key2}:`, ...renderDefinition(value, `${indent} `));
73295
+ lines2.push(`${indent2}${key2}:`, ...renderDefinition(value, `${indent2} `));
73162
73296
  } else {
73163
- lines2.push(`${indent}${key2}: ${Array.isArray(value) ? value.map(String).join(", ") : String(value)}`);
73297
+ lines2.push(`${indent2}${key2}: ${Array.isArray(value) ? value.map(String).join(", ") : String(value)}`);
73164
73298
  }
73165
73299
  }
73166
73300
  return lines2;
@@ -73258,6 +73392,42 @@ var AutosysClient = class {
73258
73392
  throw error51;
73259
73393
  }
73260
73394
  }
73395
+ /**
73396
+ * Something this server may not offer at the documented address: undefined for a 404, so a tool can
73397
+ * say which setting (`autosys.paths`) points elsewhere, rather than reporting "found nothing".
73398
+ */
73399
+ async optional(doing, path61, signal) {
73400
+ try {
73401
+ return asList(await this.rest.json(doing, path61, { method: "GET" }, signal));
73402
+ } catch (error51) {
73403
+ if (error51 instanceof AtlassianError && error51.status === 404)
73404
+ return void 0;
73405
+ throw error51;
73406
+ }
73407
+ }
73408
+ /** Machines matching a pattern, or one machine by name. Undefined: no machine endpoint here. */
73409
+ async machines(pattern, signal) {
73410
+ if (!isAutosysName(pattern, true))
73411
+ throw new AtlassianError(`"${pattern}" is not a machine name or pattern - letters, digits, . _ - # and * only.`);
73412
+ return pattern.includes("*") ? this.optional(`listing machines ${pattern}`, fill(this.paths.machines, { pattern }), signal) : this.optional(`reading machine ${pattern}`, fill(this.paths.machine, { machine: pattern }), signal);
73413
+ }
73414
+ async globalVariables(pattern, signal) {
73415
+ if (!isAutosysName(pattern, true))
73416
+ throw new AtlassianError(`"${pattern}" is not a variable name or pattern.`);
73417
+ return this.optional(`reading global variables ${pattern}`, fill(this.paths.globalVariables, { pattern }), signal);
73418
+ }
73419
+ /** A calendar, standard first, then extended. Undefined: neither answered. */
73420
+ async calendar(name, signal) {
73421
+ if (!isAutosysName(name))
73422
+ throw new AtlassianError(`"${name}" is not a calendar name.`);
73423
+ const standard = await this.optional(`reading calendar ${name}`, fill(this.paths.calendar, { calendar: name }), signal);
73424
+ if (standard !== void 0 && standard.length > 0)
73425
+ return { kind: "standard", records: standard };
73426
+ const extended = await this.optional(`reading extended calendar ${name}`, fill(this.paths.extendedCalendar, { calendar: name }), signal);
73427
+ if (extended !== void 0 && extended.length > 0)
73428
+ return { kind: "extended", records: extended };
73429
+ return standard === void 0 && extended === void 0 ? void 0 : { kind: "standard", records: [] };
73430
+ }
73261
73431
  async sendEvent(event, name, extra, signal) {
73262
73432
  if (!isAutosysName(name))
73263
73433
  throw new AtlassianError(`"${name}" is not a job name.`);
@@ -73284,28 +73454,67 @@ function errorResult3(error51) {
73284
73454
  }
73285
73455
  var findSchema3 = external_exports.object({
73286
73456
  pattern: external_exports.string().optional().describe("Job name, with * wildcards \u2014 e.g. PAY_* or *_EOD_*."),
73457
+ machine: external_exports.string().optional().describe("Only jobs defined to run on this machine (* wildcards)."),
73458
+ owner: external_exports.string().optional().describe("Only jobs owned by this user (* wildcards), e.g. svc_batch or svc_*."),
73459
+ box: external_exports.string().optional().describe("Only jobs inside this box (* wildcards)."),
73460
+ type: external_exports.string().optional().describe("Only this job type: CMD, BOX, FW (file watcher), FT, and so on."),
73461
+ calendar: external_exports.string().optional().describe("Only jobs whose run or exclude calendar is this one (* wildcards)."),
73462
+ commandContains: external_exports.string().optional().describe("Only jobs whose command contains this text, e.g. a script name."),
73287
73463
  limit: external_exports.number().int().min(1).max(200).optional().describe("How many. Default 50.")
73288
73464
  });
73465
+ function definitionMatches(definition, filters) {
73466
+ const at = (...names) => field(definition, ...names);
73467
+ if (filters.machine !== void 0 && !wildcardMatches(filters.machine, at("machine")))
73468
+ return false;
73469
+ if (filters.owner !== void 0 && !wildcardMatches(filters.owner, at("owner")))
73470
+ return false;
73471
+ if (filters.box !== void 0 && !wildcardMatches(filters.box, at("boxName", "box_name")))
73472
+ return false;
73473
+ if (filters.type !== void 0) {
73474
+ const type = (at("jobType", "job_type", "type") ?? "").toUpperCase();
73475
+ const wanted = filters.type.trim().toUpperCase();
73476
+ const same2 = type === wanted || (type.length === 1 || wanted.length === 1) && type.charAt(0) === wanted.charAt(0);
73477
+ if (!same2)
73478
+ return false;
73479
+ }
73480
+ if (filters.calendar !== void 0) {
73481
+ const calendars = [at("runCalendar", "run_calendar"), at("excludeCalendar", "exclude_calendar")];
73482
+ if (!calendars.some((name) => wildcardMatches(filters.calendar ?? "", name)))
73483
+ return false;
73484
+ }
73485
+ if (filters.commandContains !== void 0) {
73486
+ const command = at("command") ?? "";
73487
+ if (!command.toLowerCase().includes(filters.commandContains.toLowerCase()))
73488
+ return false;
73489
+ }
73490
+ return true;
73491
+ }
73289
73492
  function createAutosysFindJobsTool(options) {
73290
73493
  return {
73291
73494
  name: "autosys_find_jobs",
73292
73495
  group: "read",
73293
- description: "Find AutoSys jobs by name pattern (* wildcards), with each job\u2019s type, box and machine." + (options.defaultPattern !== void 0 ? ` Defaults to ${options.defaultPattern}.` : ""),
73496
+ description: 'Find AutoSys jobs by name pattern (* wildcards), with each job\u2019s type, box, machine and owner - and narrow them by what their definitions say: the machine they run on, owner, box, type, a calendar they use, or text in their command (e.g. "which jobs call load_gl.sh", "which jobs are defined on host X").' + (options.defaultPattern !== void 0 ? ` Defaults to ${options.defaultPattern}.` : ""),
73294
73497
  parametersSchema: findSchema3,
73295
73498
  async execute(params3) {
73296
73499
  try {
73297
73500
  const pattern = params3.pattern ?? options.defaultPattern ?? "*";
73298
- const jobs = await (await options.client()).findJobs(pattern);
73299
- if (jobs.length === 0)
73300
- return { content: `No AutoSys jobs match ${pattern}.` };
73501
+ const all = await (await options.client()).findJobs(pattern);
73502
+ const jobs = all.filter((job) => definitionMatches(job, params3));
73503
+ if (jobs.length === 0) {
73504
+ return {
73505
+ content: all.length === 0 ? `No AutoSys jobs match ${pattern}.` : `None of the ${String(all.length)} job(s) matching ${pattern} pass those filters.`
73506
+ };
73507
+ }
73301
73508
  const shown2 = jobs.slice(0, params3.limit ?? 50);
73509
+ const matched = jobs.length === all.length ? `match ${pattern}` : `of the ${String(all.length)} matching ${pattern} pass the filters`;
73302
73510
  return {
73303
73511
  content: [
73304
- `${String(jobs.length)} job(s) match ${pattern}${jobs.length > shown2.length ? `, showing ${String(shown2.length)}` : ""}:`,
73512
+ `${String(jobs.length)} job(s) ${matched}${jobs.length > shown2.length ? `, showing ${String(shown2.length)}` : ""}:`,
73305
73513
  ...shown2.map((job) => {
73306
73514
  const box = field(job, "boxName", "box_name");
73307
73515
  const machine = field(job, "machine");
73308
- return `- ${field(job, "name", "jobName") ?? "?"} (${field(job, "jobType", "job_type", "type") ?? "?"}${box !== void 0 ? `, in box ${box}` : ""}${machine !== void 0 ? `, on ${machine}` : ""})`;
73516
+ const owner = field(job, "owner");
73517
+ return `- ${field(job, "name", "jobName") ?? "?"} (${field(job, "jobType", "job_type", "type") ?? "?"}${box !== void 0 ? `, in box ${box}` : ""}${machine !== void 0 ? `, on ${machine}` : ""}${owner !== void 0 ? `, owner ${owner}` : ""})`;
73309
73518
  })
73310
73519
  ].join("\n")
73311
73520
  };
@@ -73456,8 +73665,36 @@ function createAutosysJobTool(options) {
73456
73665
  var statusSchema = external_exports.object({
73457
73666
  pattern: external_exports.string().optional().describe("Job name or pattern (* wildcards). Defaults to the configured pattern."),
73458
73667
  jobs: external_exports.array(external_exports.string().min(1)).max(MAX_JOBS).optional().describe('Several job names or patterns at once, e.g. ["PAY_LOAD", "GL_*"].'),
73459
- only: external_exports.union([external_exports.enum(STATUSES), external_exports.array(external_exports.enum(STATUSES)).min(1)]).optional().describe('Only jobs in this status (or any of these), e.g. FAILURE, or ["FAILURE", "TERMINATED"].')
73668
+ only: external_exports.union([external_exports.enum(STATUSES), external_exports.array(external_exports.enum(STATUSES)).min(1)]).optional().describe('Only jobs in this status (or any of these), e.g. FAILURE, or ["FAILURE", "TERMINATED"].'),
73669
+ machine: external_exports.string().optional().describe('Only jobs running (or last run) on this machine, * wildcards. With only: RUNNING answers "what is running on host X".'),
73670
+ withinHours: external_exports.number().positive().max(24 * 31).optional().describe("Only jobs that started or ended in the last this-many hours, e.g. 6 with only: FAILURE."),
73671
+ runningLongerThanMinutes: external_exports.number().int().positive().optional().describe("Only jobs still RUNNING that started more than this many minutes ago - long runners.")
73460
73672
  });
73673
+ function runMatches(run3, filters, now = Date.now()) {
73674
+ if (filters.machine !== void 0 && !wildcardMatches(filters.machine, run3.machine))
73675
+ return false;
73676
+ if (filters.withinHours !== void 0) {
73677
+ const since2 = now - filters.withinHours * 36e5;
73678
+ const times = [parseAutosysTime(run3.lastStart), parseAutosysTime(run3.lastEnd)].filter((time3) => time3 !== void 0);
73679
+ if (!times.some((time3) => time3 >= since2))
73680
+ return false;
73681
+ }
73682
+ if (filters.runningLongerThanMinutes !== void 0) {
73683
+ if (run3.status.toUpperCase() !== "RUNNING")
73684
+ return false;
73685
+ const started = parseAutosysTime(run3.lastStart);
73686
+ if (started === void 0 || now - started < filters.runningLongerThanMinutes * 6e4)
73687
+ return false;
73688
+ }
73689
+ return true;
73690
+ }
73691
+ function runningFor(run3, now = Date.now()) {
73692
+ const started = parseAutosysTime(run3.lastStart);
73693
+ if (run3.status.toUpperCase() !== "RUNNING" || started === void 0)
73694
+ return "";
73695
+ const minutes = Math.max(0, Math.round((now - started) / 6e4));
73696
+ return ` \xB7 running for ${minutes >= 60 ? `${String(Math.floor(minutes / 60))} h ${String(minutes % 60)} min` : `${String(minutes)} min`}`;
73697
+ }
73461
73698
  var STATUS_ORDER = ["FAILURE", "TERMINATED", "RUNNING", "STARTING", "RESTART", "ON_HOLD", "ON_ICE"];
73462
73699
  var statusRank = (status2) => {
73463
73700
  const at = STATUS_ORDER.indexOf(status2.toUpperCase());
@@ -73467,7 +73704,7 @@ function createAutosysStatusTool(options) {
73467
73704
  return {
73468
73705
  name: "autosys_status",
73469
73706
  group: "read",
73470
- description: "Current status of AutoSys jobs \u2014 like autorep -J: status, last start and end, exit code, run number and machine \u2014 for one job, a pattern, or many at once (`jobs`), with a count by status first. Use only: FAILURE to see what failed. To follow a job until it finishes, check, `wait`, and check again.",
73707
+ description: 'Current status of AutoSys jobs \u2014 like autorep -J: status, last start and end, exit code, run number and machine \u2014 for one job, a pattern, or many at once (`jobs`), with a count by status first. Use only: FAILURE to see what failed. Narrow by machine ("what is running on host X": machine with only: RUNNING), by time (withinHours: "what failed in the last 6 hours"), or find long runners (runningLongerThanMinutes). To follow a job until it finishes, check, `wait`, and check again.',
73471
73708
  parametersSchema: statusSchema,
73472
73709
  async execute(params3) {
73473
73710
  try {
@@ -73490,24 +73727,35 @@ function createAutosysStatusTool(options) {
73490
73727
  byName.set(run3.name, run3);
73491
73728
  const only = params3.only === void 0 ? void 0 : (Array.isArray(params3.only) ? params3.only : [params3.only]).map((status2) => status2.toUpperCase());
73492
73729
  const all = [...byName.values()];
73493
- const runs = all.filter((run3) => only === void 0 || only.includes(run3.status.toUpperCase()));
73730
+ const filtered = params3.machine !== void 0 || params3.withinHours !== void 0 || params3.runningLongerThanMinutes !== void 0;
73731
+ const runs = all.filter((run3) => (only === void 0 || only.includes(run3.status.toUpperCase())) && runMatches(run3, params3));
73732
+ if (params3.machine !== void 0 && all.length > 0 && all.every((run3) => run3.machine === void 0)) {
73733
+ return {
73734
+ content: "This AutoSys server's status answers do not say which machine a job ran on, so they cannot be filtered by machine. Use autosys_machines (the jobs defined on and running on a machine) or autosys_find_jobs with machine instead."
73735
+ };
73736
+ }
73494
73737
  const asked = wanted.join(", ");
73495
73738
  const unreadable = problems.length > 0 ? ["", "Could not read:", ...problems.map((problem) => `- ${problem}`)] : [];
73496
73739
  if (runs.length === 0) {
73497
73740
  return {
73498
73741
  content: [
73499
- all.length === 0 ? `No jobs match ${asked}.` : `None of the ${String(all.length)} job(s) matching ${asked} are ${(only ?? []).join(" or ")} (${statusSummary(all)}).`,
73742
+ all.length === 0 ? `No jobs match ${asked}.` : `None of the ${String(all.length)} job(s) matching ${asked} are ${[
73743
+ ...only !== void 0 ? [only.join(" or ")] : [],
73744
+ ...params3.machine !== void 0 ? [`on ${params3.machine}`] : [],
73745
+ ...params3.withinHours !== void 0 ? [`active in the last ${String(params3.withinHours)} h`] : [],
73746
+ ...params3.runningLongerThanMinutes !== void 0 ? [`running over ${String(params3.runningLongerThanMinutes)} min`] : []
73747
+ ].join(", ")} (${statusSummary(all)}).`,
73500
73748
  ...unreadable
73501
73749
  ].join("\n"),
73502
73750
  ...problems.length > 0 && all.length === 0 ? { isError: true } : {}
73503
73751
  };
73504
73752
  }
73505
73753
  const sorted = [...runs].sort((a, b) => statusRank(a.status) - statusRank(b.status) || a.name.localeCompare(b.name));
73506
- const heading = only === void 0 ? `${String(runs.length)} job(s) \u2014 ${statusSummary(runs)}:` : `${String(runs.length)} of the ${String(all.length)} matching job(s) are ${only.join(" or ")} (all: ${statusSummary(all)}):`;
73754
+ const heading = only === void 0 && !filtered ? `${String(runs.length)} job(s) \u2014 ${statusSummary(runs)}:` : only !== void 0 && !filtered ? `${String(runs.length)} of the ${String(all.length)} matching job(s) are ${only.join(" or ")} (all: ${statusSummary(all)}):` : `${String(runs.length)} of the ${String(all.length)} matching job(s) pass the filters - ${statusSummary(runs)} (all: ${statusSummary(all)}):`;
73507
73755
  return {
73508
73756
  content: [
73509
73757
  heading,
73510
- ...sorted.slice(0, MAX_JOBS).map((run3) => `- ${describeRun2(run3)}`),
73758
+ ...sorted.slice(0, MAX_JOBS).map((run3) => `- ${describeRun2(run3)}${runningFor(run3)}`),
73511
73759
  ...sorted.length > MAX_JOBS ? [`\u2026 and ${String(sorted.length - MAX_JOBS)} more; narrow the pattern or use only.`] : [],
73512
73760
  ...unreadable
73513
73761
  ].join("\n")
@@ -73751,37 +73999,37 @@ function createAutosysDependenciesTool(options) {
73751
73999
  return status2;
73752
74000
  };
73753
74001
  const visited = /* @__PURE__ */ new Set();
73754
- const walk = async (name, level, indent) => {
74002
+ const walk = async (name, level, indent2) => {
73755
74003
  if (visited.has(name)) {
73756
- lines2.push(`${indent}(${name} already shown above)`);
74004
+ lines2.push(`${indent2}(${name} already shown above)`);
73757
74005
  return;
73758
74006
  }
73759
74007
  visited.add(name);
73760
74008
  const definition = await client.job(name).catch(() => void 0);
73761
74009
  if (definition === void 0) {
73762
- lines2.push(`${indent}(${name}: definition not readable)`);
74010
+ lines2.push(`${indent2}(${name}: definition not readable)`);
73763
74011
  return;
73764
74012
  }
73765
74013
  const condition = field(definition, "condition");
73766
74014
  const box = field(definition, "boxName", "box_name");
73767
74015
  if (box !== void 0)
73768
- lines2.push(`${indent}- in box ${box} [${await statusOf(box)}] \u2014 runs only while its box is running`);
74016
+ lines2.push(`${indent2}- in box ${box} [${await statusOf(box)}] \u2014 runs only while its box is running`);
73769
74017
  if (condition === void 0) {
73770
74018
  if (box === void 0)
73771
- lines2.push(`${indent}- no starting condition: it runs on its own schedule${field(definition, "startTimes", "start_times") !== void 0 ? ` (${field(definition, "startTimes", "start_times") ?? ""})` : ""}`);
74019
+ lines2.push(`${indent2}- no starting condition: it runs on its own schedule${field(definition, "startTimes", "start_times") !== void 0 ? ` (${field(definition, "startTimes", "start_times") ?? ""})` : ""}`);
73772
74020
  return;
73773
74021
  }
73774
- lines2.push(`${indent}condition: ${condition}`);
74022
+ lines2.push(`${indent2}condition: ${condition}`);
73775
74023
  for (const reference of parseConditions(condition)) {
73776
74024
  if (reference.instance !== void 0) {
73777
- lines2.push(`${indent}- ${KIND_WORDS[reference.kind]} ${reference.job} on instance ${reference.instance} (another instance: status not checked)`);
74025
+ lines2.push(`${indent2}- ${KIND_WORDS[reference.kind]} ${reference.job} on instance ${reference.instance} (another instance: status not checked)`);
73778
74026
  continue;
73779
74027
  }
73780
74028
  const status2 = await statusOf(reference.job);
73781
74029
  const met = conditionMet(reference.kind, status2);
73782
- lines2.push(`${indent}- ${KIND_WORDS[reference.kind]} ${reference.job}${reference.comparison !== void 0 ? ` ${reference.comparison}` : ""}: ${status2} \u2014 ${met === void 0 ? "check the exit code" : met ? "met" : "NOT met"}`);
74030
+ lines2.push(`${indent2}- ${KIND_WORDS[reference.kind]} ${reference.job}${reference.comparison !== void 0 ? ` ${reference.comparison}` : ""}: ${status2} \u2014 ${met === void 0 ? "check the exit code" : met ? "met" : "NOT met"}`);
73783
74031
  if (met === false && level < (params3.depth ?? 3))
73784
- await walk(reference.job, level + 1, `${indent} `);
74032
+ await walk(reference.job, level + 1, `${indent2} `);
73785
74033
  }
73786
74034
  };
73787
74035
  await walk(params3.job, 1, " ");
@@ -73810,6 +74058,228 @@ function createAutosysDependenciesTool(options) {
73810
74058
  }
73811
74059
  };
73812
74060
  }
74061
+ function notOffered(what, pathKey) {
74062
+ return `This AutoSys server did not answer for ${what} at the documented address. Its web services may not offer it, or answer at a different path - set it in config:autosys (paths.${pathKey}).`;
74063
+ }
74064
+ var machinesSchema = external_exports.object({
74065
+ machine: external_exports.string().optional().describe("A machine name, or a pattern with * wildcards. Default every machine."),
74066
+ jobs: external_exports.boolean().optional().describe("Also list the jobs defined on each machine and those running on it now. Default true for one machine, false for a pattern."),
74067
+ jobPattern: external_exports.string().optional().describe("Which jobs to look through for those (* wildcards). Defaults to the configured pattern, else all.")
74068
+ });
74069
+ function createAutosysMachinesTool(options) {
74070
+ return {
74071
+ name: "autosys_machines",
74072
+ group: "read",
74073
+ description: 'AutoSys machines (agents), like autorep -M: each machine\u2019s definition and status - and, for one machine, the jobs defined on it and the jobs running on it right now, with their status. Answers "what is running on host X", "which jobs use this machine", "is the agent on X online".',
74074
+ parametersSchema: machinesSchema,
74075
+ async execute(params3) {
74076
+ try {
74077
+ const client = await options.client();
74078
+ const pattern = params3.machine?.trim() || "*";
74079
+ const sections = [];
74080
+ const machines = await client.machines(pattern);
74081
+ if (machines === void 0)
74082
+ sections.push(notOffered("machines", pattern.includes("*") ? "machines" : "machine"));
74083
+ else if (machines.length === 0)
74084
+ sections.push(`No AutoSys machines match ${pattern}.`);
74085
+ else {
74086
+ sections.push([
74087
+ `${String(machines.length)} machine(s) match ${pattern}:`,
74088
+ ...machines.slice(0, MAX_JOBS).flatMap((machine) => machines.length === 1 ? renderDefinition(machine).map((line) => ` ${line}`) : [`- ${describeMachine(machine)}`])
74089
+ ].join("\n"));
74090
+ }
74091
+ const wantJobs = params3.jobs ?? !pattern.includes("*");
74092
+ if (wantJobs) {
74093
+ const jobPattern = params3.jobPattern ?? options.defaultPattern ?? "*";
74094
+ const [definitions, runs] = await Promise.all([
74095
+ client.findJobs(jobPattern).catch(() => []),
74096
+ client.runInfo(jobPattern).catch(() => [])
74097
+ ]);
74098
+ const statusOf = new Map(runs.map((run3) => [run3.name, run3]));
74099
+ const defined = definitions.filter((job) => wildcardMatches(pattern, field(job, "machine")));
74100
+ const running = runs.filter((run3) => run3.status.toUpperCase() === "RUNNING" && wildcardMatches(pattern, run3.machine));
74101
+ sections.push(running.length === 0 ? `Nothing among ${jobPattern} is running on ${pattern} now.` : [`Running on ${pattern} now (${String(running.length)}):`, ...running.slice(0, MAX_JOBS).map((run3) => `- ${describeRun2(run3)}${runningFor(run3)}`)].join("\n"));
74102
+ sections.push(defined.length === 0 ? `No job among ${jobPattern} is defined to run on ${pattern}.` : [
74103
+ `Defined to run on ${pattern} (${String(defined.length)}):`,
74104
+ ...defined.slice(0, MAX_JOBS).map((job) => {
74105
+ const name = field(job, "name", "jobName", "job_name") ?? "?";
74106
+ const run3 = statusOf.get(name);
74107
+ return `- ${run3 !== void 0 ? describeRun2(run3) : `${name}: status not available`}`;
74108
+ })
74109
+ ].join("\n"));
74110
+ }
74111
+ return { content: sections.join("\n\n") };
74112
+ } catch (error51) {
74113
+ return errorResult3(error51);
74114
+ }
74115
+ }
74116
+ };
74117
+ }
74118
+ function describeMachine(machine) {
74119
+ return [
74120
+ field(machine, "name", "machineName", "machine") ?? "?",
74121
+ field(machine, "status", "machineStatus", "state"),
74122
+ field(machine, "type", "machineType"),
74123
+ field(machine, "nodeName", "node_name") !== void 0 ? `node ${field(machine, "nodeName", "node_name") ?? ""}` : void 0,
74124
+ field(machine, "maxLoad", "max_load") !== void 0 ? `max load ${field(machine, "maxLoad", "max_load") ?? ""}` : void 0
74125
+ ].filter((part) => part !== void 0).join(" \xB7 ");
74126
+ }
74127
+ var variablesSchema = external_exports.object({
74128
+ name: external_exports.string().optional().describe("A variable name or pattern (* wildcards). Default every variable."),
74129
+ valueContains: external_exports.string().optional().describe("Only variables whose value contains this text.")
74130
+ });
74131
+ function createAutosysGlobalVariablesTool(options) {
74132
+ return {
74133
+ name: "autosys_global_variables",
74134
+ group: "read",
74135
+ description: 'AutoSys global variables, like autorep -G: name, value and when last set. Job conditions such as v(RUN_DATE) = "..." and commands using $VAR read these, so this answers "what is RUN_DATE set to" and "why is the condition on v(...) not met".',
74136
+ parametersSchema: variablesSchema,
74137
+ async execute(params3) {
74138
+ try {
74139
+ const pattern = params3.name?.trim() || "*";
74140
+ const variables = await (await options.client()).globalVariables(pattern);
74141
+ if (variables === void 0)
74142
+ return { content: notOffered("global variables", "globalVariables"), isError: true };
74143
+ const wanted = variables.filter((variable) => params3.valueContains === void 0 ? true : (field(variable, "value") ?? "").toLowerCase().includes(params3.valueContains.toLowerCase()));
74144
+ if (wanted.length === 0)
74145
+ return { content: `No global variables match ${pattern}${params3.valueContains !== void 0 ? ` with a value containing "${params3.valueContains}"` : ""}.` };
74146
+ return {
74147
+ content: [
74148
+ `${String(wanted.length)} global variable(s):`,
74149
+ ...wanted.slice(0, MAX_JOBS).map((variable) => {
74150
+ const changed = field(variable, "lastChanged", "last_changed", "lastUpdate", "modified");
74151
+ return `- ${field(variable, "name", "variableName") ?? "?"} = ${field(variable, "value") ?? "(empty)"}${changed !== void 0 ? ` (set ${changed})` : ""}`;
74152
+ })
74153
+ ].join("\n")
74154
+ };
74155
+ } catch (error51) {
74156
+ return errorResult3(error51);
74157
+ }
74158
+ }
74159
+ };
74160
+ }
74161
+ var calendarSchema = external_exports.object({
74162
+ calendar: external_exports.string().min(1).describe("The calendar name, as a job\u2019s run_calendar or exclude_calendar names it."),
74163
+ from: external_exports.string().optional().describe("Only dates from this day, YYYY-MM-DD."),
74164
+ to: external_exports.string().optional().describe("Only dates up to this day, YYYY-MM-DD."),
74165
+ date: external_exports.string().optional().describe("Just answer whether this day (YYYY-MM-DD) is in the calendar.")
74166
+ });
74167
+ function createAutosysCalendarTool(options) {
74168
+ return {
74169
+ name: "autosys_calendar",
74170
+ group: "read",
74171
+ description: 'An AutoSys calendar - the dates in a standard calendar, or an extended calendar\u2019s rules - optionally between two dates, or whether one date is in it. With autosys_job\u2019s run_calendar and exclude_calendar this answers "will this job run on the 31st?".',
74172
+ parametersSchema: calendarSchema,
74173
+ async execute(params3) {
74174
+ try {
74175
+ const found2 = await (await options.client()).calendar(params3.calendar);
74176
+ if (found2 === void 0)
74177
+ return { content: notOffered(`calendar ${params3.calendar}`, "calendar"), isError: true };
74178
+ if (found2.records.length === 0)
74179
+ return { content: `No AutoSys calendar called ${params3.calendar}.`, isError: true };
74180
+ if (found2.kind === "extended") {
74181
+ return { content: [`${params3.calendar} is an extended calendar (rules, not a date list):`, ...found2.records.flatMap((record2) => renderDefinition(record2)).map((line) => ` ${line}`)].join("\n") };
74182
+ }
74183
+ const dates = calendarDates(found2.records);
74184
+ if (params3.date !== void 0) {
74185
+ return { content: `${params3.date} ${dates.includes(params3.date) ? "is" : "is not"} in calendar ${params3.calendar} (${String(dates.length)} date(s) in it).` };
74186
+ }
74187
+ const shown2 = dates.filter((date5) => (params3.from === void 0 || date5 >= params3.from) && (params3.to === void 0 || date5 <= params3.to));
74188
+ if (shown2.length === 0)
74189
+ return { content: `Calendar ${params3.calendar} has no dates${params3.from !== void 0 || params3.to !== void 0 ? " in that range" : ""}.` };
74190
+ return {
74191
+ content: [
74192
+ `Calendar ${params3.calendar}: ${String(shown2.length)} date(s)${shown2.length !== dates.length ? ` of ${String(dates.length)}` : ""}${shown2.length > 400 ? ", first 400 shown" : ""}:`,
74193
+ shown2.slice(0, 400).join(", ")
74194
+ ].join("\n")
74195
+ };
74196
+ } catch (error51) {
74197
+ return errorResult3(error51);
74198
+ }
74199
+ }
74200
+ };
74201
+ }
74202
+ var scheduleSchema2 = external_exports.object({
74203
+ pattern: external_exports.string().optional().describe("Which jobs to look through (* wildcards). Defaults to the configured pattern, else all."),
74204
+ from: external_exports.string().regex(/^\d{1,2}:\d{2}$/).optional().describe("Window start, HH:MM (24 h). Default 00:00."),
74205
+ to: external_exports.string().regex(/^\d{1,2}:\d{2}$/).optional().describe("Window end, HH:MM. Default 23:59. A window past midnight (22:00 to 02:00) wraps."),
74206
+ day: external_exports.string().optional().describe("Only jobs that run on this day: a weekday (mon, saturday), today, tomorrow, or a date YYYY-MM-DD."),
74207
+ machine: external_exports.string().optional().describe("Only jobs defined on this machine (* wildcards)."),
74208
+ withStatus: external_exports.boolean().optional().describe("Add each job\u2019s current status. Default false.")
74209
+ });
74210
+ function createAutosysScheduleTool(options) {
74211
+ return {
74212
+ name: "autosys_schedule",
74213
+ group: "read",
74214
+ description: 'When AutoSys jobs are scheduled to start, read from their definitions (start_times, start_mins, days_of_week, run_calendar): which jobs start in a time window and on which day, in start order. Answers "what runs between 2 and 4 am", "what is scheduled on Saturday", "what starts on host X tonight". Jobs started only by a condition or by their box have no start time of their own and are counted, not listed.',
74215
+ parametersSchema: scheduleSchema2,
74216
+ async execute(params3) {
74217
+ try {
74218
+ const client = await options.client();
74219
+ const pattern = params3.pattern ?? options.defaultPattern ?? "*";
74220
+ const from = params3.from ?? "00:00";
74221
+ const to = params3.to ?? "23:59";
74222
+ const day = params3.day !== void 0 ? weekdayOf(params3.day) : void 0;
74223
+ if (params3.day !== void 0 && day === void 0) {
74224
+ return { content: `"${params3.day}" is not a day - use a weekday, today, tomorrow or YYYY-MM-DD.`, isError: true };
74225
+ }
74226
+ const definitions = (await client.findJobs(pattern)).filter((job) => params3.machine === void 0 || wildcardMatches(params3.machine, field(job, "machine")));
74227
+ const starts = [];
74228
+ const byCalendar = [];
74229
+ let unscheduled = 0;
74230
+ for (const job of definitions) {
74231
+ const name = field(job, "name", "jobName", "job_name") ?? "?";
74232
+ const schedule = jobSchedule(job);
74233
+ if (schedule === void 0) {
74234
+ unscheduled++;
74235
+ continue;
74236
+ }
74237
+ const times = startsInWindow(schedule, from, to, day);
74238
+ const where = [
74239
+ field(job, "boxName", "box_name") !== void 0 ? `in ${field(job, "boxName", "box_name") ?? ""}` : void 0,
74240
+ field(job, "machine") !== void 0 ? `on ${field(job, "machine") ?? ""}` : void 0,
74241
+ schedule.runCalendar !== void 0 ? `calendar ${schedule.runCalendar}` : describeDays(schedule.days),
74242
+ schedule.excludeCalendar !== void 0 ? `except calendar ${schedule.excludeCalendar}` : void 0,
74243
+ schedule.timezone !== void 0 ? `time zone ${schedule.timezone}` : void 0
74244
+ ].filter((part) => part !== void 0).join(", ");
74245
+ if (times.length === 0 && schedule.runCalendar !== void 0 && schedule.times.length === 0 && schedule.minutesPastHour.length === 0) {
74246
+ byCalendar.push(`- ${name} (${where})`);
74247
+ continue;
74248
+ }
74249
+ for (const time3 of times)
74250
+ starts.push({ time: time3, name, line: `${time3} ${name} (${where})` });
74251
+ }
74252
+ starts.sort((a, b) => a.time.localeCompare(b.time) || a.name.localeCompare(b.name));
74253
+ const statuses = /* @__PURE__ */ new Map();
74254
+ if (params3.withStatus === true && starts.length > 0) {
74255
+ const runs = await client.runInfo(pattern).catch(() => []);
74256
+ for (const run3 of runs)
74257
+ statuses.set(run3.name, run3);
74258
+ }
74259
+ const window = `${from}-${to}${params3.day !== void 0 ? ` on ${params3.day}` : ""}`;
74260
+ const lines2 = [
74261
+ starts.length === 0 ? `No job among ${pattern} is scheduled to start ${window}.` : `${String(new Set(starts.map((entry) => entry.name)).size)} job(s) among ${pattern} start ${window} (${String(starts.length)} start(s)):`,
74262
+ ...starts.slice(0, 400).map((entry) => {
74263
+ const run3 = statuses.get(entry.name);
74264
+ return `- ${entry.line}${run3 !== void 0 ? ` - now ${run3.status}` : ""}`;
74265
+ }),
74266
+ ...starts.length > 400 ? [`... and ${String(starts.length - 400)} more; narrow the window or the pattern.`] : []
74267
+ ];
74268
+ if (byCalendar.length > 0) {
74269
+ lines2.push("", "Run by calendar with no start time of their own (read the calendar with autosys_calendar):", ...byCalendar.slice(0, 100));
74270
+ }
74271
+ if (unscheduled > 0)
74272
+ lines2.push("", `${String(unscheduled)} job(s) have no start schedule - started by a condition, by their box, or by hand.`);
74273
+ if (day !== void 0 && starts.some((entry) => entry.line.includes("calendar "))) {
74274
+ lines2.push("", "Jobs on a run calendar run on that calendar\u2019s dates; check the date with autosys_calendar.");
74275
+ }
74276
+ return { content: lines2.join("\n") };
74277
+ } catch (error51) {
74278
+ return errorResult3(error51);
74279
+ }
74280
+ }
74281
+ };
74282
+ }
73813
74283
  function createAutosysTools(options) {
73814
74284
  return [
73815
74285
  createAutosysFindJobsTool(options),
@@ -73817,11 +74287,177 @@ function createAutosysTools(options) {
73817
74287
  createAutosysStatusTool(options),
73818
74288
  createAutosysDependenciesTool(options),
73819
74289
  createAutosysLogTool(options),
74290
+ createAutosysMachinesTool(options),
74291
+ createAutosysGlobalVariablesTool(options),
74292
+ createAutosysCalendarTool(options),
74293
+ createAutosysScheduleTool(options),
73820
74294
  createAutosysSendEventTool(options),
73821
74295
  createAutosysApplyJilTool(options)
73822
74296
  ];
73823
74297
  }
73824
74298
 
74299
+ // ../../packages/core/dist/atlassian/readOnly.js
74300
+ function readOnlyNote(label) {
74301
+ return ` Access to ${label} here is read-only: nothing in ${label} can be changed from this chat. If asked to change something, say so and give the exact change for someone with access to make; do not try another way.`;
74302
+ }
74303
+ function toolsForAccess(tools, readOnly, label) {
74304
+ if (!readOnly)
74305
+ return [...tools];
74306
+ const note = readOnlyNote(label);
74307
+ return tools.filter((tool) => tool.group === "read").map((tool) => ({ ...tool, description: tool.description + note }));
74308
+ }
74309
+
74310
+ // ../../packages/core/dist/platform/httpTrace.js
74311
+ var SECRET_NAME = /secret|password|passwd|token|api[-_]?key|assertion|credential|session|signature|cookie/i;
74312
+ var MASK = "\u2022\u2022\u2022";
74313
+ var BODY_EXCERPT = 1500;
74314
+ function maskAuthorization(value) {
74315
+ const [scheme, ...rest] = value.trim().split(/\s+/);
74316
+ const credential = rest.join(" ");
74317
+ if (scheme === void 0 || credential.length === 0)
74318
+ return `${MASK} (${String(value.length)} characters)`;
74319
+ if (/^basic$/i.test(scheme)) {
74320
+ try {
74321
+ const decoded = Buffer.from(credential, "base64").toString("utf8");
74322
+ const at = decoded.indexOf(":");
74323
+ if (at > 0)
74324
+ return `${scheme} ${decoded.slice(0, at)}:${MASK} (base64 of user:password)`;
74325
+ } catch {
74326
+ }
74327
+ }
74328
+ return `${scheme} ${MASK} (${String(credential.length)} characters)`;
74329
+ }
74330
+ function maskHeaders(headers, knownSecrets = []) {
74331
+ const out = {};
74332
+ for (const [name, value] of Object.entries(headers)) {
74333
+ if (/authorization/i.test(name))
74334
+ out[name] = maskAuthorization(value);
74335
+ else if (/^(set-)?cookie$/i.test(name))
74336
+ out[name] = value.replace(/=([^;,\s]*)/g, `=${MASK}`);
74337
+ else if (SECRET_NAME.test(name))
74338
+ out[name] = `${MASK} (${String(value.length)} characters)`;
74339
+ else
74340
+ out[name] = redact(value, knownSecrets);
74341
+ }
74342
+ return out;
74343
+ }
74344
+ function maskUrl(url2) {
74345
+ try {
74346
+ const parsed = new URL(url2);
74347
+ if (parsed.username !== "" || parsed.password !== "") {
74348
+ parsed.password = parsed.password === "" ? "" : MASK;
74349
+ }
74350
+ for (const key2 of [...parsed.searchParams.keys()])
74351
+ if (SECRET_NAME.test(key2))
74352
+ parsed.searchParams.set(key2, MASK);
74353
+ return decodeURI(parsed.toString());
74354
+ } catch {
74355
+ return url2;
74356
+ }
74357
+ }
74358
+ function maskBody(body, knownSecrets = []) {
74359
+ const trimmed = body.trim();
74360
+ let masked = body;
74361
+ if (/^[\w.-]+=[^&]*(&[\w.-]+=[^&]*)*$/.test(trimmed)) {
74362
+ masked = trimmed.split("&").map((pair) => {
74363
+ const at = pair.indexOf("=");
74364
+ return at > 0 && SECRET_NAME.test(decodeURIComponent(pair.slice(0, at))) ? `${pair.slice(0, at)}=${MASK}` : pair;
74365
+ }).join("&");
74366
+ } else if (/^[{[]/.test(trimmed)) {
74367
+ try {
74368
+ const walk = (value) => {
74369
+ if (Array.isArray(value))
74370
+ return value.map(walk);
74371
+ if (value !== null && typeof value === "object") {
74372
+ return Object.fromEntries(Object.entries(value).map(([key2, inner]) => [key2, SECRET_NAME.test(key2) && typeof inner !== "object" ? MASK : walk(inner)]));
74373
+ }
74374
+ return value;
74375
+ };
74376
+ masked = JSON.stringify(walk(JSON.parse(trimmed)), null, 1);
74377
+ } catch {
74378
+ }
74379
+ }
74380
+ return redact(masked, knownSecrets);
74381
+ }
74382
+ function excerpt(text) {
74383
+ return text.length > BODY_EXCERPT ? `${text.slice(0, BODY_EXCERPT)}
74384
+ \u2026 (${String(text.length - BODY_EXCERPT)} more characters)` : text;
74385
+ }
74386
+ function errorChain(error51) {
74387
+ const parts = [];
74388
+ let current = error51;
74389
+ for (let depth = 0; depth < 5 && current !== void 0 && current !== null; depth++) {
74390
+ const message4 = current instanceof Error ? `${current.name === "Error" ? "" : `${current.name}: `}${current.message}` : String(current);
74391
+ const code = current.code;
74392
+ parts.push(typeof code === "string" ? `${message4} [${code}]` : message4);
74393
+ current = current.cause;
74394
+ }
74395
+ return parts.join(" <- ");
74396
+ }
74397
+ function tracingHttpClient(inner, entries, knownSecrets = []) {
74398
+ return {
74399
+ async request(url2, options = {}) {
74400
+ const started = Date.now();
74401
+ const entry = {
74402
+ method: (options.method ?? "GET").toUpperCase(),
74403
+ url: maskUrl(url2),
74404
+ requestHeaders: maskHeaders(options.headers ?? {}, knownSecrets),
74405
+ ...options.body !== void 0 ? { requestBody: excerpt(maskBody(options.body, knownSecrets)) } : {},
74406
+ ...options.bodyBytes !== void 0 ? { requestBody: `(${String(options.bodyBytes.length)} bytes)` } : {},
74407
+ millis: 0
74408
+ };
74409
+ entries.push(entry);
74410
+ let response;
74411
+ try {
74412
+ response = await inner.request(url2, options);
74413
+ } catch (error51) {
74414
+ entry.error = redact(errorChain(error51), knownSecrets);
74415
+ entry.millis = Date.now() - started;
74416
+ throw error51;
74417
+ }
74418
+ const bytes = await readBody(response);
74419
+ const text = bytes.toString("utf8");
74420
+ entry.status = response.status;
74421
+ entry.responseHeaders = maskHeaders(response.headers, knownSecrets);
74422
+ entry.responseBody = excerpt(maskBody(text, knownSecrets));
74423
+ entry.millis = Date.now() - started;
74424
+ return {
74425
+ status: response.status,
74426
+ headers: response.headers,
74427
+ body: null,
74428
+ text: async () => text,
74429
+ json: async () => JSON.parse(text)
74430
+ };
74431
+ },
74432
+ ...inner.openWebSocket !== void 0 ? { openWebSocket: inner.openWebSocket.bind(inner) } : {}
74433
+ };
74434
+ }
74435
+ function renderTrace(entries) {
74436
+ if (entries.length === 0)
74437
+ return "No request was sent - the test stopped before reaching the network (see the message above).";
74438
+ return entries.map((entry, index) => {
74439
+ const lines2 = [`#${String(index + 1)} ${entry.method} ${entry.url}`];
74440
+ const headers = Object.entries(entry.requestHeaders);
74441
+ if (headers.length > 0)
74442
+ lines2.push("Request headers:", ...headers.map(([name, value]) => ` ${name}: ${value}`));
74443
+ if (entry.requestBody !== void 0 && entry.requestBody.length > 0)
74444
+ lines2.push("Request body:", indent(entry.requestBody));
74445
+ if (entry.error !== void 0) {
74446
+ lines2.push(`No response after ${String(entry.millis)} ms: ${entry.error}`);
74447
+ } else {
74448
+ lines2.push(`Response: HTTP ${String(entry.status ?? "?")} after ${String(entry.millis)} ms`);
74449
+ const back = Object.entries(entry.responseHeaders ?? {});
74450
+ if (back.length > 0)
74451
+ lines2.push("Response headers:", ...back.map(([name, value]) => ` ${name}: ${value}`));
74452
+ lines2.push("Response body:", entry.responseBody !== void 0 && entry.responseBody.length > 0 ? indent(entry.responseBody) : " (empty)");
74453
+ }
74454
+ return lines2.join("\n");
74455
+ }).join("\n\n");
74456
+ }
74457
+ function indent(text) {
74458
+ return text.split("\n").map((line) => ` ${line}`).join("\n");
74459
+ }
74460
+
73825
74461
  // ../../packages/core/dist/atlassian/jira.js
73826
74462
  var SHOWN_FIELDS = /* @__PURE__ */ new Set([
73827
74463
  "summary",
@@ -74199,16 +74835,16 @@ function createJiraReadIssueTool(options) {
74199
74835
  skipped.push(`${attachment.name} (${error51 instanceof Error ? error51.message : String(error51)})`);
74200
74836
  }
74201
74837
  }
74202
- const list = (label, values) => values.length > 0 ? [`${label}: ${values.join(", ")}`] : [];
74838
+ const list2 = (label, values) => values.length > 0 ? [`${label}: ${values.join(", ")}`] : [];
74203
74839
  return {
74204
74840
  content: [
74205
74841
  `${issue2.key}: ${issue2.summary}`,
74206
74842
  `Status: ${issue2.status} Type: ${issue2.type} Priority: ${issue2.priority ?? "\u2014"}`,
74207
74843
  `Assignee: ${issue2.assignee ?? "unassigned"} Reporter: ${issue2.reporter ?? "\u2014"}`,
74208
- ...list("Labels", issue2.labels),
74209
- ...list("Components", issue2.components),
74210
- ...list("Fix versions", issue2.fixVersions),
74211
- ...list("Affects versions", issue2.affectsVersions),
74844
+ ...list2("Labels", issue2.labels),
74845
+ ...list2("Components", issue2.components),
74846
+ ...list2("Fix versions", issue2.fixVersions),
74847
+ ...list2("Affects versions", issue2.affectsVersions),
74212
74848
  ...issue2.dueDate !== void 0 ? [`Due: ${issue2.dueDate}`] : [],
74213
74849
  ...issue2.parent !== void 0 ? [`Parent: ${issue2.parent}`] : [],
74214
74850
  `Link: ${issue2.url}`,
@@ -74614,7 +75250,7 @@ var ATLASSIAN_PRODUCTS = [
74614
75250
  tokenHint: "The password for the user below, as you sign in to AutoSys web services. Kept in secure storage, never in the settings file, and never sent back to this panel.",
74615
75251
  tokenRef: "autosys:password",
74616
75252
  sitePlaceholder: "https://autosys.example.com:9443",
74617
- does: "find jobs, read job definitions, status and run logs, and \u2014 always shown to you first \u2014 send events such as force-start, kill, hold and ice, or apply JIL",
75253
+ does: "find jobs and machines, read job definitions, status, schedules, calendars, global variables and run logs, and \u2014 always shown to you first, and only without read-only access \u2014 send events such as force-start, kill, hold and ice, or apply JIL",
74618
75254
  defaults: [
74619
75255
  {
74620
75256
  key: "username",
@@ -74668,8 +75304,8 @@ ${blockQuote(quote.excerpt)}`;
74668
75304
  }
74669
75305
  function describeReactions(reactions) {
74670
75306
  const lines2 = reactions.map((item) => {
74671
- const excerpt = clipQuote(item.quote.excerpt, MAX_REACTION_QUOTE_CHARS).replace(/\s+/g, " ");
74672
- return `- ${REACTION_LABELS[item.reaction]}: "${excerpt}"${sourceNote(item.quote)}`;
75307
+ const excerpt2 = clipQuote(item.quote.excerpt, MAX_REACTION_QUOTE_CHARS).replace(/\s+/g, " ");
75308
+ return `- ${REACTION_LABELS[item.reaction]}: "${excerpt2}"${sourceNote(item.quote)}`;
74673
75309
  });
74674
75310
  return `[My reactions to what you wrote \u2014 weigh them in what you do next]
74675
75311
  ${lines2.join("\n")}`;
@@ -75262,9 +75898,9 @@ function createOutlookDraftTool(options) {
75262
75898
  ["Cc", params3.cc],
75263
75899
  ["Bcc", params3.bcc]
75264
75900
  ];
75265
- for (const [label, list] of recipients) {
75266
- if (list !== void 0 && list.length > 0)
75267
- lines2.push(`${label}: ${list.join(", ")}`);
75901
+ for (const [label, list2] of recipients) {
75902
+ if (list2 !== void 0 && list2.length > 0)
75903
+ lines2.push(`${label}: ${list2.join(", ")}`);
75268
75904
  }
75269
75905
  if (params3.to === void 0 || params3.to.length === 0) {
75270
75906
  lines2.push("To: (nobody \u2014 you will fill this in)");
@@ -79652,33 +80288,32 @@ ${preview.text}` } : {}
79652
80288
  client: confluenceClient,
79653
80289
  ...cachedConfluence.defaultSpace !== void 0 ? { defaultSpace: cachedConfluence.defaultSpace } : {}
79654
80290
  };
79655
- combined.register(createConfluenceSearchTool(confluenceOptions));
79656
- combined.register(createConfluenceReadPageTool(confluenceOptions));
79657
- combined.register(createConfluenceWritePageTool(confluenceOptions));
80291
+ for (const tool of toolsForAccess([createConfluenceSearchTool(confluenceOptions), createConfluenceReadPageTool(confluenceOptions), createConfluenceWritePageTool(confluenceOptions)], cachedConfluence.readOnly === true, "Confluence")) {
80292
+ combined.register(tool);
80293
+ }
79658
80294
  }
79659
80295
  if (cachedJira?.enabled === true && cachedJira.baseUrl !== void 0) {
79660
80296
  const jiraOptions = {
79661
80297
  client: jiraClient,
79662
80298
  ...cachedJira.defaultProject !== void 0 ? { defaultProject: cachedJira.defaultProject } : {}
79663
80299
  };
79664
- combined.register(createJiraSearchTool(jiraOptions));
79665
- combined.register(createJiraReadIssueTool(jiraOptions));
79666
- combined.register(createJiraProjectTool(jiraOptions));
79667
- combined.register(createJiraWriteIssueTool(jiraOptions));
80300
+ for (const tool of toolsForAccess([createJiraSearchTool(jiraOptions), createJiraReadIssueTool(jiraOptions), createJiraProjectTool(jiraOptions), createJiraWriteIssueTool(jiraOptions)], cachedJira.readOnly === true, "Jira")) {
80301
+ combined.register(tool);
80302
+ }
79668
80303
  }
79669
80304
  if (cachedJenkins?.enabled === true && cachedJenkins.baseUrl !== void 0) {
79670
- for (const tool of createJenkinsTools({
80305
+ for (const tool of toolsForAccess(createJenkinsTools({
79671
80306
  client: jenkinsClient,
79672
80307
  ...cachedJenkins.defaultJob !== void 0 ? { defaultJob: cachedJenkins.defaultJob } : {}
79673
- })) {
80308
+ }), cachedJenkins.readOnly === true, "Jenkins")) {
79674
80309
  combined.register(tool);
79675
80310
  }
79676
80311
  }
79677
80312
  if (cachedAutosys?.enabled === true && cachedAutosys.baseUrl !== void 0) {
79678
- for (const tool of createAutosysTools({
80313
+ for (const tool of toolsForAccess(createAutosysTools({
79679
80314
  client: autosysClient,
79680
80315
  ...cachedAutosys.defaultPattern !== void 0 ? { defaultPattern: cachedAutosys.defaultPattern } : {}
79681
- })) {
80316
+ }), cachedAutosys.readOnly === true, "AutoSys")) {
79682
80317
  combined.register(tool);
79683
80318
  }
79684
80319
  }
@@ -79688,11 +80323,15 @@ ${preview.text}` } : {}
79688
80323
  ...cachedBitbucket.defaultProject !== void 0 ? { defaultProject: cachedBitbucket.defaultProject } : {},
79689
80324
  ...cachedBitbucket.defaultRepo !== void 0 ? { defaultRepo: cachedBitbucket.defaultRepo } : {}
79690
80325
  };
79691
- combined.register(createBitbucketPullRequestsTool(bitbucketOptions));
79692
- combined.register(createBitbucketReadPullRequestTool(bitbucketOptions));
79693
- combined.register(createBitbucketReadFileTool(bitbucketOptions));
79694
- combined.register(createBitbucketWritePullRequestTool(bitbucketOptions));
79695
- combined.register(createBitbucketMergePullRequestTool(bitbucketOptions));
80326
+ for (const tool of toolsForAccess([
80327
+ createBitbucketPullRequestsTool(bitbucketOptions),
80328
+ createBitbucketReadPullRequestTool(bitbucketOptions),
80329
+ createBitbucketReadFileTool(bitbucketOptions),
80330
+ createBitbucketWritePullRequestTool(bitbucketOptions),
80331
+ createBitbucketMergePullRequestTool(bitbucketOptions)
80332
+ ], cachedBitbucket.readOnly === true, "Bitbucket")) {
80333
+ combined.register(tool);
80334
+ }
79696
80335
  }
79697
80336
  combined.register(createExportConfigTool({ loadConfig: async () => (await configManager.load()).config }), { dispatchOnly: dispatcher });
79698
80337
  if (dispatcher && docs !== void 0) {
@@ -80349,7 +80988,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
80349
80988
  const teamSkillsResolved = resolveTeamSkills(config2, search, embedder);
80350
80989
  const mailCollection = config2.mail?.enabled === true ? mailCollectionName(config2) : void 0;
80351
80990
  const mailSearch = mailCollection === void 0 ? void 0 : await resolveMailSearch(config2);
80352
- const searchIndexes = search?.opensearch !== void 0 ? await search.opensearch.listIndexes().then((list) => list.map((i) => i.name)).catch(() => []) : [];
80991
+ const searchIndexes = search?.opensearch !== void 0 ? await search.opensearch.listIndexes().then((list2) => list2.map((i) => i.name)).catch(() => []) : [];
80353
80992
  await refreshSkills();
80354
80993
  const codebaseInstructions = renderCodebaseInstructions(await readCodebaseInstructions(codebaseInstructionsFile));
80355
80994
  const activeMode = findMode(config2.modeId);
@@ -82449,7 +83088,7 @@ ${redact(shown2, cachedSecretValues)}` }
82449
83088
  });
82450
83089
  }
82451
83090
  let autosysGateway;
82452
- async function autosysGatewayAuth(config2, tls2) {
83091
+ async function autosysGatewayAuth(config2, tls2, http = httpClient) {
82453
83092
  const auth2 = config2.autosys?.auth ?? {};
82454
83093
  if (auth2.tokenUrl === void 0) {
82455
83094
  throw new AtlassianError("AutoSys uses the API gateway but no token URL is set. Settings \u2192 DevOps \u2192 AutoSys \u2192 API gateway: enter it and save.");
@@ -82458,11 +83097,12 @@ ${redact(shown2, cachedSecretValues)}` }
82458
83097
  throw new AtlassianError("AutoSys uses the API gateway but the client id or secret is missing. Settings \u2192 DevOps \u2192 AutoSys \u2192 API gateway: enter both and save.");
82459
83098
  }
82460
83099
  const key2 = JSON.stringify({ auth: auth2, baseUrl: config2.autosys?.baseUrl, tls: tls2 === void 0 ? 0 : (0, import_node_crypto15.createHash)("sha256").update(JSON.stringify(tls2)).digest("hex") });
82461
- if (autosysGateway?.key === key2)
83100
+ const testing = http !== httpClient;
83101
+ if (!testing && autosysGateway?.key === key2)
82462
83102
  return autosysGateway.strategy;
82463
83103
  const secretRef = auth2.clientSecretRef;
82464
83104
  const strategy = new ApigeeMtlsAuthStrategy(
82465
- httpClient,
83105
+ http,
82466
83106
  {
82467
83107
  tokenUrl: auth2.tokenUrl,
82468
83108
  clientId: auth2.clientId,
@@ -82484,10 +83124,11 @@ ${redact(shown2, cachedSecretValues)}` }
82484
83124
  // The same certificate for the token request as for the API: one gateway, one identity.
82485
83125
  async () => tls2
82486
83126
  );
82487
- autosysGateway = { key: key2, strategy };
83127
+ if (!testing)
83128
+ autosysGateway = { key: key2, strategy };
82488
83129
  return strategy;
82489
83130
  }
82490
- async function atlassianConnection(product) {
83131
+ async function atlassianConnection(product, http = httpClient) {
82491
83132
  const info = atlassianProduct(product);
82492
83133
  const { config: config2 } = await configManager.load();
82493
83134
  const settings = config2[product];
@@ -82519,7 +83160,7 @@ ${redact(shown2, cachedSecretValues)}` }
82519
83160
  baseUrl: settings.baseUrl,
82520
83161
  token: "",
82521
83162
  auth: await (async () => {
82522
- const gatewayAuth = await autosysGatewayAuth(config2, tls3);
83163
+ const gatewayAuth = await autosysGatewayAuth(config2, tls3, http);
82523
83164
  if (auth2.sendBasic !== true)
82524
83165
  return gatewayAuth;
82525
83166
  if (auth2.basicHeaderValueRef !== void 0) {
@@ -82569,22 +83210,22 @@ ${redact(shown2, cachedSecretValues)}` }
82569
83210
  ...tls2 !== void 0 ? { tls: tls2 } : {}
82570
83211
  };
82571
83212
  }
82572
- async function confluenceClient() {
82573
- return new ConfluenceClient(httpClient, await atlassianConnection("confluence"));
83213
+ async function confluenceClient(http = httpClient) {
83214
+ return new ConfluenceClient(http, await atlassianConnection("confluence", http));
82574
83215
  }
82575
- async function jiraClient() {
82576
- return new JiraClient(httpClient, await atlassianConnection("jira"));
83216
+ async function jiraClient(http = httpClient) {
83217
+ return new JiraClient(http, await atlassianConnection("jira", http));
82577
83218
  }
82578
- async function bitbucketClient() {
82579
- return new BitbucketClient(httpClient, await atlassianConnection("bitbucket"));
83219
+ async function bitbucketClient(http = httpClient) {
83220
+ return new BitbucketClient(http, await atlassianConnection("bitbucket", http));
82580
83221
  }
82581
- async function jenkinsClient() {
82582
- return new JenkinsClient(httpClient, await atlassianConnection("jenkins"));
83222
+ async function jenkinsClient(http = httpClient) {
83223
+ return new JenkinsClient(http, await atlassianConnection("jenkins", http));
82583
83224
  }
82584
- async function autosysClient() {
83225
+ async function autosysClient(http = httpClient) {
82585
83226
  const { config: config2 } = await configManager.load();
82586
83227
  const paths = Object.fromEntries(Object.entries(config2.autosys?.paths ?? {}).filter(([, value]) => value !== void 0));
82587
- return new AutosysClient(httpClient, await atlassianConnection("autosys"), paths);
83228
+ return new AutosysClient(http, await atlassianConnection("autosys", http), paths);
82588
83229
  }
82589
83230
  async function postAtlassian() {
82590
83231
  const { config: config2 } = await configManager.load();
@@ -82603,6 +83244,7 @@ ${redact(shown2, cachedSecretValues)}` }
82603
83244
  baseUrl: settings.baseUrl ?? "",
82604
83245
  caFile: settings.caFile ?? "",
82605
83246
  rejectUnauthorized: settings.rejectUnauthorized !== false,
83247
+ readOnly: settings.readOnly === true,
82606
83248
  defaults
82607
83249
  },
82608
83250
  hasToken,
@@ -82654,7 +83296,9 @@ ${redact(shown2, cachedSecretValues)}` }
82654
83296
  ...defaults,
82655
83297
  ...input.caFile.trim().length > 0 ? { caFile: input.caFile.trim() } : {},
82656
83298
  // Stored only when switched off, so the default stays the safe one.
82657
- ...input.rejectUnauthorized ? {} : { rejectUnauthorized: false }
83299
+ ...input.rejectUnauthorized ? {} : { rejectUnauthorized: false },
83300
+ // Stored only when ticked; an older panel that sends no value keeps full access.
83301
+ ...input.readOnly === true ? { readOnly: true } : {}
82658
83302
  }
82659
83303
  });
82660
83304
  if (product === "autosys" && gateway !== void 0) {
@@ -82732,11 +83376,26 @@ ${redact(shown2, cachedSecretValues)}` }
82732
83376
  await postAtlassian();
82733
83377
  }
82734
83378
  async function handleTestAtlassian(product) {
83379
+ const entries = [];
83380
+ const { config: config2 } = await configManager.load();
83381
+ const settings = config2[product];
83382
+ const refs = [
83383
+ settings?.tokenRef,
83384
+ ...product === "autosys" ? [config2.autosys?.auth?.clientSecretRef, config2.autosys?.auth?.basicHeaderValueRef, config2.autosys?.auth?.passphraseRef] : []
83385
+ ].filter((ref) => ref !== void 0);
83386
+ const knownSecrets = (await Promise.all(refs.map(async (ref) => await secrets.get(ref) ?? ""))).filter((value) => value.length >= 4);
83387
+ const http = tracingHttpClient(httpClient, entries, knownSecrets);
82735
83388
  try {
82736
- const who = product === "confluence" ? await (await confluenceClient()).currentUser() : product === "jira" ? await (await jiraClient()).currentUser() : product === "jenkins" ? await (await jenkinsClient()).currentUser() : product === "autosys" ? (await configManager.load()).config.autosys?.auth?.type === "apigee" ? `the gateway client ${await (await autosysClient()).probe((await configManager.load()).config.autosys?.auth?.clientId ?? "")}` : await (await autosysClient()).probe((await configManager.load()).config.autosys?.username ?? "") : await (await bitbucketClient()).currentUser();
82737
- post({ type: "atlassianTest", product, ok: true, detail: `Connected as ${who}.` });
83389
+ const who = product === "confluence" ? await (await confluenceClient(http)).currentUser() : product === "jira" ? await (await jiraClient(http)).currentUser() : product === "jenkins" ? await (await jenkinsClient(http)).currentUser() : product === "autosys" ? config2.autosys?.auth?.type === "apigee" ? `the gateway client ${await (await autosysClient(http)).probe(config2.autosys.auth.clientId ?? "")}` : await (await autosysClient(http)).probe(config2.autosys?.username ?? "") : await (await bitbucketClient(http)).currentUser();
83390
+ post({ type: "atlassianTest", product, ok: true, detail: `Connected as ${who}.`, diagnostics: renderTrace(entries) });
82738
83391
  } catch (error51) {
82739
- post({ type: "atlassianTest", product, ok: false, detail: error51 instanceof Error ? error51.message : String(error51) });
83392
+ post({
83393
+ type: "atlassianTest",
83394
+ product,
83395
+ ok: false,
83396
+ detail: error51 instanceof Error ? error51.message : String(error51),
83397
+ diagnostics: renderTrace(entries)
83398
+ });
82740
83399
  }
82741
83400
  }
82742
83401
  async function postS3() {
@@ -83618,20 +84277,20 @@ ${redact(shown2, cachedSecretValues)}` }
83618
84277
  }
83619
84278
  }
83620
84279
  async function handleInstallPythonPackages(packages) {
83621
- const list = [...new Set(packages.map((entry) => entry.trim()).filter((entry) => entry.length > 0))];
83622
- post({ type: "pythonInstall", running: true, packages: list });
84280
+ const list2 = [...new Set(packages.map((entry) => entry.trim()).filter((entry) => entry.length > 0))];
84281
+ post({ type: "pythonInstall", running: true, packages: list2 });
83623
84282
  try {
83624
- const result = await python.installPackages(list);
84283
+ const result = await python.installPackages(list2);
83625
84284
  await postPython();
83626
84285
  post({
83627
84286
  type: "pythonInstall",
83628
84287
  running: false,
83629
- packages: list,
84288
+ packages: list2,
83630
84289
  installed: result.installed,
83631
84290
  ...result.error !== void 0 ? { error: result.error } : {}
83632
84291
  });
83633
84292
  } catch (error51) {
83634
- post({ type: "pythonInstall", running: false, packages: list, error: error51 instanceof Error ? error51.message : String(error51) });
84293
+ post({ type: "pythonInstall", running: false, packages: list2, error: error51 instanceof Error ? error51.message : String(error51) });
83635
84294
  }
83636
84295
  }
83637
84296
  async function postProject() {
@@ -87894,9 +88553,9 @@ var LspClient = class {
87894
88553
  const version2 = (this.versions.get(uri) ?? 0) + 1;
87895
88554
  this.versions.set(uri, version2);
87896
88555
  const arrived = new Promise((resolve) => {
87897
- const list = this.waiters.get(key2) ?? [];
87898
- list.push(() => resolve(true));
87899
- this.waiters.set(key2, list);
88556
+ const list2 = this.waiters.get(key2) ?? [];
88557
+ list2.push(() => resolve(true));
88558
+ this.waiters.set(key2, list2);
87900
88559
  setTimeout(() => resolve(false), timeoutMs);
87901
88560
  });
87902
88561
  if (version2 === 1) {
@@ -89283,14 +89942,41 @@ There is no tool that changes a job's configuration.
89283
89942
  "client secret",
89284
89943
  "oauth",
89285
89944
  "consumer key",
89286
- "consumer secret"
89945
+ "consumer secret",
89946
+ "machine",
89947
+ "agent",
89948
+ "running on",
89949
+ "jobs on host",
89950
+ "long running",
89951
+ "global variable",
89952
+ "calendar",
89953
+ "run calendar",
89954
+ "what runs at",
89955
+ "scheduled",
89956
+ "start times",
89957
+ "read only",
89958
+ "read-only",
89959
+ "readonly access",
89960
+ "403",
89961
+ "forbidden",
89962
+ "test connection details",
89963
+ "service account"
89287
89964
  ],
89288
89965
  body: `
89289
89966
  **Settings \u2192 DevOps \u2192 AutoSys**: the web services address (for example
89290
89967
  \`https://autosys.example.com:9443\`), your **username** and **password**, and optionally a default
89291
89968
  job pattern such as \`PAY_*\`, a CA file and the skip-verify escape hatch. Off until switched on;
89292
89969
  **user-scope only** (config:autosys). The password is kept in secure storage. **Test connection**
89293
- signs in without listing any jobs.
89970
+ signs in without listing any jobs. Under its result, **Details** shows every request it made and what
89971
+ came back - the address, HTTP status, response headers and the start of the body, the gateway's token
89972
+ request first - with passwords, tokens and secrets masked; open by default when the test failed, with a
89973
+ **Copy details** button for whoever runs the service. Error messages name the HTTP status (401 not signed
89974
+ in, 403 forbidden - signed in but that account is not allowed) so they can be compared with Postman.
89975
+
89976
+ **Read-only access?** Tick **My access is read-only** in the panel. The tools that change things
89977
+ (\`autosys_send_event\`, \`autosys_apply_jil\`) are then left out entirely and the reading tools tell
89978
+ the assistant the access is read-only, so it explains what someone with access would need to do instead
89979
+ of trying. The same tick box is on Confluence, Jira, Bitbucket and Jenkins (config:autosys (readOnly)).
89294
89980
 
89295
89981
  **Behind an API gateway (Apigee)?** Fill in **API gateway (Apigee)** in the same panel \u2014 typing a
89296
89982
  token URL ticks "Sign in through the gateway" \u2014 and press the panel's one **Save**, which stores the
@@ -89322,16 +90008,21 @@ and extra token parameters (config:autosys).
89322
90008
  Without a gateway, it talks to AutoSys's REST web services (AEWS) with HTTP Basic. Paths follow the documented layout
89323
90009
  (\`/AEWS/job\`, \`/AEWS/job-run-info\`, \`/AEWS/event\`, \`/AEWS/jil\`); a server that answers
89324
90010
  elsewhere can be pointed at with config:autosys (paths) \u2014 one template each for jobs, job,
89325
- runInfo, jobRunInfo, boxMembers, event, jil and log.
90011
+ runInfo, jobRunInfo, boxMembers, event, jil, log, machines, machine, globalVariables, calendar and
90012
+ extendedCalendar. A tool whose address this server does not answer says which of these to set.
89326
90013
 
89327
90014
  **Reading** \u2014 ordinary read tools, which you may set to always allow:
89328
- - \`autosys_find_jobs\` \u2014 jobs matching a name pattern, with type, box and machine.
90015
+ - \`autosys_find_jobs\` \u2014 jobs matching a name pattern, with type, box, machine and owner, narrowed by
90016
+ what their definitions say: the **machine** they run on, **owner**, **box**, **type**, a **calendar**
90017
+ they use, or text in their **command** ("which jobs call load_gl.sh").
89329
90018
  - \`autosys_job\` \u2014 job definitions in JIL terms with each job's status, and a box's members. One
89330
90019
  job, a list, or a **pattern** for every matching job; for many jobs ask for just the attributes
89331
90020
  you need ("the command and start times of every PAY_* job").
89332
90021
  - \`autosys_status\` \u2014 like autorep: status, last start and end, exit code, run number. One job, a
89333
90022
  pattern, or **several at once** ("PAY_LOAD and every GL_* job"), with a count by status first and
89334
- failures at the top; \`only\` narrows to FAILURE, or to several statuses at once.
90023
+ failures at the top; \`only\` narrows to FAILURE, or to several statuses at once. Also by
90024
+ **machine** ("what is running on host X"), by **time** ("what failed in the last 6 hours"), and
90025
+ **long runners** ("running longer than 2 hours", each with how long it has run).
89335
90026
  - Ask it to **follow a job until it finishes**: it checks the status, waits, and checks again.
89336
90027
  - \`autosys_job_log\` \u2014 a job's stderr or stdout, the end of it or matching lines. If the server
89337
90028
  offers no log endpoint, it says which file on which machine the job writes to instead.
@@ -89339,6 +90030,18 @@ runInfo, jobRunInfo, boxMembers, event, jil and log.
89339
90030
  (success, failure, done, notrunning, terminated, exit code) with its status and whether the
89340
90031
  condition is met, following unmet ones further up, and the box it runs in. Downstream: the jobs
89341
90032
  whose conditions name it, and a box's members.
90033
+ - \`autosys_machines\` \u2014 machines (agents) like autorep -M: definition and status, and for one machine
90034
+ the jobs **running on it now** and the jobs **defined on it**, each with its status.
90035
+ - \`autosys_schedule\` \u2014 **what starts when**, from the definitions' start times, start minutes, days and
90036
+ run calendar: "what runs between 2 and 4 am", "what is scheduled on Saturday", "what starts on host X
90037
+ tonight", in start order, optionally with each job's current status. Jobs started only by a condition
90038
+ or their box are counted rather than listed.
90039
+ - \`autosys_calendar\` \u2014 a calendar's dates (between two days, or whether one day is in it), or an
90040
+ extended calendar's rules: "will this job run on the 31st?".
90041
+ - \`autosys_global_variables\` \u2014 global variables like autorep -G, for conditions such as
90042
+ \`v(RUN_DATE)\`.
90043
+ - There is no run-history tool: the web services report each job's latest run; earlier runs are in
90044
+ AutoSys's own reports.
89342
90045
 
89343
90046
  **Changing** \u2014 asked **every time**, and cannot be set to always allow; never available to a
89344
90047
  schedule:
@@ -94743,8 +95446,8 @@ async function startServer(options) {
94743
95446
  if (options.credentialsFile === void 0) return [];
94744
95447
  try {
94745
95448
  const parsed = JSON.parse(await import_promises34.default.readFile(options.credentialsFile, "utf8"));
94746
- const list = Array.isArray(parsed.credentials) ? parsed.credentials : [];
94747
- return list.flatMap((entry) => {
95449
+ const list2 = Array.isArray(parsed.credentials) ? parsed.credentials : [];
95450
+ return list2.flatMap((entry) => {
94748
95451
  const c2 = entry;
94749
95452
  if (typeof c2.id !== "string" || typeof c2.label !== "string") return [];
94750
95453
  return [{ id: c2.id, label: c2.label, kind: c2.kind === "login" ? "login" : "secret", ...typeof c2.note === "string" ? { note: c2.note } : {} }];