@chosengeneration/light-code 0.165.0 → 0.170.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 +428 -42
  2. package/dist/server.cjs +417 -38
  3. package/package.json +1 -1
package/dist/server.cjs CHANGED
@@ -62015,6 +62015,47 @@ var PythonManager = class {
62015
62015
  findTool(name) {
62016
62016
  return this.registered.find((tool) => tool.name === name);
62017
62017
  }
62018
+ /**
62019
+ * Which of these modules the tools' environment has, without importing any (`importlib.util.find_spec`).
62020
+ * Undefined when Python is not running, so nobody is told a module is missing that was never looked for.
62021
+ */
62022
+ async hasModules(modules) {
62023
+ if (!this.ready || this.interpreter.length === 0 || modules.length === 0)
62024
+ return void 0;
62025
+ try {
62026
+ const answer = await interpreterCheck(this.interpreter, await this.childEnv())({ modules: [...modules], distributions: [] });
62027
+ return Object.fromEntries(modules.map((module2) => [module2, !answer.missingModules.includes(module2)]));
62028
+ } catch {
62029
+ return void 0;
62030
+ }
62031
+ }
62032
+ /**
62033
+ * What the Python tab can show at once, before Python starts: the tools already approved in each folder,
62034
+ * from its `.registry.json` (no interpreter, no import). Reported as slow on a managed machine, where
62035
+ * starting uv and Python costs seconds and the tab used to stay empty until both had.
62036
+ *
62037
+ * Issues are left out on purpose: deciding that a tool needs approval may take adopting an approval
62038
+ * made elsewhere on this machine, which loads the tool in the worker - so a guess here would flash an
62039
+ * approval request for something already approved.
62040
+ */
62041
+ async previewStatus(folders) {
62042
+ const current = this.status();
62043
+ if (current.ready || this.options.workspaceRoot === void 0)
62044
+ return current;
62045
+ const toolsDir = folders.toolsDir ?? defaultPythonToolsDir(this.options.workspaceRoot);
62046
+ const dirs = [toolsDir, ...folders.extraToolDirs ?? []].filter((dir) => dir.length > 0);
62047
+ const loaded = await loadRegistries(dirs, void 0, this.options.logger, this.declinedTools, void 0);
62048
+ return {
62049
+ ...current,
62050
+ enabled: true,
62051
+ ready: false,
62052
+ starting: true,
62053
+ toolsDir,
62054
+ detail: "Starting Python\u2026 the tools below were approved before; anything new to review is listed once it is running.",
62055
+ tools: loaded.tools.map((tool) => ({ name: tool.name, description: tool.description, filePath: tool.filePath, sourceDir: tool.sourceDir })),
62056
+ issues: []
62057
+ };
62058
+ }
62018
62059
  async refresh() {
62019
62060
  if (!this.enabled || this.toolsDir.length === 0)
62020
62061
  return;
@@ -66429,6 +66470,15 @@ var toMs = (value) => {
66429
66470
  const ms = Date.parse(value);
66430
66471
  return Number.isNaN(ms) ? void 0 : ms;
66431
66472
  };
66473
+ var RECORDS = external_exports.boolean().optional().describe("Answer as a JSON list of records (one per file, hit or row; numbers as numbers, times as ISO) - for a Fire Code monitor's source or for dataframe. Default: text for reading.");
66474
+ function asRecords(records, answer) {
66475
+ if (answer.timedOut === true)
66476
+ return { content: "Stopped at the time limit, so the answer is partial - narrow the folders, names or dates.", isError: true };
66477
+ return { content: JSON.stringify(records) };
66478
+ }
66479
+ var iso = (ms) => typeof ms === "number" && Number.isFinite(ms) ? new Date(ms).toISOString() : null;
66480
+ var ageMinutes = (ms) => typeof ms === "number" && Number.isFinite(ms) ? Math.max(0, Math.round((Date.now() - ms) / 6e4)) : null;
66481
+ var keyed = (columns, rows) => rows.map((row) => Object.fromEntries(columns.map((c2, i) => [c2, row[i] ?? null])));
66432
66482
  var grepSchema = external_exports.object({
66433
66483
  pattern: external_exports.string().min(1).describe("A regular expression (or plain text with literal: true). Case-insensitive unless it has a capital letter."),
66434
66484
  roots: external_exports.array(external_exports.string().min(1)).min(1).max(20).describe("Folders or files to search: workspace-relative, absolute, another drive, or shares like \\\\server\\share\\folder - several at once."),
@@ -66709,7 +66759,7 @@ function allFastFsTools(exe, options = {}) {
66709
66759
  name: "find_files",
66710
66760
  group: "read",
66711
66761
  description: 'Find files fast across whole folders, drives and network shares, using every CPU core: by name pattern, extension, size and modified date (action "find"); summarise a folder tree \u2014 total size, size by file type, largest and newest files ("summary"); or find identical files by content ("duplicates"). Read-only. Prefer this to list_files for anything larger than one folder.',
66712
- parametersSchema: findSchema,
66762
+ parametersSchema: findSchema.extend({ records: RECORDS }),
66713
66763
  async execute(input, context) {
66714
66764
  const params3 = { ...input, action: input.action ?? "find" };
66715
66765
  const roots = [];
@@ -66742,6 +66792,9 @@ ${(answer.unreadablePaths ?? []).map((u) => ` ${u}`).join("\n")}` : ".");
66742
66792
  if (params3.action === "find") {
66743
66793
  const matches = answer.matches ?? [];
66744
66794
  const keep = await allowedResults(context, matches.map((m) => m.path));
66795
+ if (params3.records === true) {
66796
+ return asRecords(matches.filter((m) => keep.has(m.path)).map((m) => ({ path: m.path, name: m.path.split(/[\\/]/).pop() ?? m.path, folder: m.directory, sizeBytes: m.directory ? null : m.size, modified: iso(m.modified), ageMinutes: ageMinutes(m.modified) })), answer);
66797
+ }
66745
66798
  const lines2 = matches.filter((m) => keep.has(m.path)).map((m) => `${m.path} ${m.directory ? "folder" : formatBytes(m.size)} ${when(m.modified)}`);
66746
66799
  return { content: `${lines2.length === 0 ? "Nothing matched." : lines2.join("\n")}
66747
66800
 
@@ -66817,7 +66870,7 @@ ${refused.join("\n")}`] : []].join("\n\n") };
66817
66870
  name: "big_file",
66818
66871
  group: "read",
66819
66872
  description: 'Work through a large file \u2014 a log, a data export, a CSV of millions of rows \u2014 without loading it: "inspect" gives size, line count, the first lines and (for CSV/Excel) the columns and types; "lines" reads any window; "tail" reads the end; "search" runs a regular expression over the whole file on every CPU core and returns matching lines with numbers and context. Start with inspect, then read or search part by part.',
66820
- parametersSchema: bigFileSchema,
66873
+ parametersSchema: bigFileSchema.extend({ records: RECORDS }),
66821
66874
  async execute(params3, context) {
66822
66875
  const r = await readable(context, params3.path);
66823
66876
  if (!r.ok)
@@ -66845,6 +66898,8 @@ ${refused.join("\n")}`] : []].join("\n\n") };
66845
66898
  }
66846
66899
  if (params3.action === "search") {
66847
66900
  const matches = answer.matches ?? [];
66901
+ if (params3.records === true)
66902
+ return { ...asRecords(matches.map((m) => ({ line: m.line, text: m.text })), answer), path: params3.path };
66848
66903
  const text2 = matches.map((m) => [...m.before.map((b, i) => `${String(m.line - m.before.length + i).padStart(8)} ${b}`), `${String(m.line).padStart(8)}> ${m.text}`, ...m.after.map((a, i) => `${String(m.line + 1 + i).padStart(8)} ${a}`)].join("\n")).join("\n--\n");
66849
66904
  return { content: `${matches.length === 0 ? "No matches." : text2}
66850
66905
 
@@ -66865,8 +66920,9 @@ ${answer.limitReached === true ? `At least ${String(answer.matchCount)} matches`
66865
66920
  name: "query_table",
66866
66921
  group: "read",
66867
66922
  description: "Query a CSV/TSV file or an Excel sheet of any size without reading it all: choose columns, filter rows, group with count/sum/avg/min/max/distinct, sort, and page with offset/limit. Runs on every CPU core and returns only the small result. Use big_file inspect first to learn the column names.",
66868
- parametersSchema: tableSchema,
66869
- async execute(params3, context) {
66923
+ parametersSchema: tableSchema.extend({ records: RECORDS }),
66924
+ async execute(input, context) {
66925
+ const { records: asJson, ...params3 } = input;
66870
66926
  const r = await readable(context, params3.path);
66871
66927
  if (!r.ok)
66872
66928
  return { content: r.message, isError: true, path: params3.path };
@@ -66875,6 +66931,8 @@ ${answer.limitReached === true ? `At least ${String(answer.matchCount)} matches`
66875
66931
  return { content: answer.error ?? "The query failed.", isError: true, path: params3.path };
66876
66932
  const columns = answer.columns ?? [];
66877
66933
  const rows = answer.rows ?? [];
66934
+ if (asJson === true)
66935
+ return { ...asRecords(keyed(columns, rows), answer), path: params3.path };
66878
66936
  const cell = (v) => v === null || v === void 0 ? "" : typeof v === "number" ? String(Math.round(v * 1e6) / 1e6) : String(v).replace(/\|/g, "\\|");
66879
66937
  const table = [`| ${columns.join(" | ")} |`, `|${columns.map(() => " --- ").join("|")}|`, ...rows.map((row) => `| ${row.map(cell).join(" | ")} |`)].join("\n");
66880
66938
  const offset = answer.offset ?? 0;
@@ -66890,7 +66948,7 @@ Rows ${String(offset + 1)}\u2013${String(offset + rows.length)} of ${String(answ
66890
66948
  name: "grep_files",
66891
66949
  group: "read",
66892
66950
  description: "Search the contents of files for text or a regular expression across several folders, drives and network shares at once, on every CPU core - filtered by file name, extension and date first. Reads UTF-16 files too, and names every file or folder it could not read and why. Use for searching outside the workspace or across many roots; search_files is fine inside the workspace.",
66893
- parametersSchema: grepSchema,
66951
+ parametersSchema: grepSchema.extend({ records: RECORDS }),
66894
66952
  async execute(params3, context) {
66895
66953
  const roots = [];
66896
66954
  for (const root of params3.roots) {
@@ -66920,21 +66978,32 @@ Rows ${String(offset + 1)}\u2013${String(offset + rows.length)} of ${String(answ
66920
66978
  }, context.signal);
66921
66979
  if (answer.ok !== true)
66922
66980
  return { content: answer.error ?? "The search failed.", isError: true };
66923
- return { content: formatGrepAnswer(answer, await allowedResults(context, (answer.files ?? []).map((f) => f.path))) };
66981
+ const allowed = await allowedResults(context, (answer.files ?? []).map((f) => f.path));
66982
+ if (params3.records === true) {
66983
+ const files = (answer.files ?? []).filter((f) => allowed.has(f.path));
66984
+ return asRecords(files.flatMap((f) => f.hits.length === 0 ? [{ path: f.path, matches: f.matches }] : f.hits.map((h) => ({ path: f.path, line: h.line, text: h.text, matches: f.matches }))), answer);
66985
+ }
66986
+ return { content: formatGrepAnswer(answer, allowed) };
66924
66987
  }
66925
66988
  };
66926
66989
  const sqliteTool = {
66927
66990
  name: "query_sqlite",
66928
66991
  group: "read",
66929
66992
  description: "Read a SQLite database without creating it and without blocking the program that uses it: schema (tables, columns, indexes, row counts), query (one read-only SQL statement), scan (filter/group/sort a big table on every CPU core), search (text anywhere in the database). Use instead of python or a sqlite3 shell. A missing file is reported, never created; writes are refused.",
66930
- parametersSchema: sqliteSchema,
66931
- async execute(params3, context) {
66993
+ parametersSchema: sqliteSchema.extend({ records: RECORDS }),
66994
+ async execute(input, context) {
66995
+ const { records: asJson, ...params3 } = input;
66932
66996
  const r = await readable(context, params3.path);
66933
66997
  if (!r.ok)
66934
66998
  return { content: r.message, isError: true, path: params3.path };
66935
66999
  const answer = await runHelper(exe, { op: "sqlite", ...params3, path: r.path }, context.signal);
66936
67000
  if (answer.ok !== true)
66937
67001
  return { content: answer.error ?? "The SQLite read failed.", isError: true, path: params3.path };
67002
+ if (asJson === true && (params3.action === "query" || params3.action === "scan")) {
67003
+ if (answer.consistent === false)
67004
+ return { content: "The database was being written throughout the read; check again.", isError: true, path: params3.path };
67005
+ return { ...asRecords(keyed(answer.columns ?? [], answer.rows ?? []), answer), path: params3.path };
67006
+ }
66938
67007
  return { content: formatSqliteAnswer(params3, answer), path: params3.path };
66939
67008
  }
66940
67009
  };
@@ -66942,8 +67011,9 @@ Rows ${String(offset + 1)}\u2013${String(offset + rows.length)} of ${String(answ
66942
67011
  name: "dataframe",
66943
67012
  group: "read",
66944
67013
  description: "Data analysis with Polars (Rust, every CPU core) over CSV/delimited files, Excel sheets, the clipboard, JSON files, SQLite tables or queries, and records you already have (`rows`: e.g. results from another tool) - name each source and query them together with SQL: joins across sources, GROUP BY, window functions - and pivot. Reading is forgiving: every value is kept, and a column becomes numbers or dates only when all of it converts (the answer says which columns stayed text and why). Use instead of writing pandas or opening Excel.",
66945
- parametersSchema: dataframeSchema,
66946
- async execute(params3, context) {
67014
+ parametersSchema: dataframeSchema.extend({ records: RECORDS }),
67015
+ async execute(input, context) {
67016
+ const { records: asJson, ...params3 } = input;
66947
67017
  const sources = [];
66948
67018
  for (const source of params3.sources) {
66949
67019
  if (source.path !== void 0) {
@@ -66968,6 +67038,10 @@ Rows ${String(offset + 1)}\u2013${String(offset + rows.length)} of ${String(answ
66968
67038
  const answer = await runHelper(exe, { op: "dataframe", ...params3, sources }, context.signal);
66969
67039
  if (answer.ok !== true)
66970
67040
  return { content: answer.error ?? "The dataframe operation failed.", isError: true };
67041
+ if (asJson === true && params3.action !== "describe") {
67042
+ const columns = (answer.columns ?? []).map((c2) => c2.name);
67043
+ return asRecords(keyed(columns, answer.rows ?? []), answer);
67044
+ }
66971
67045
  return { content: formatDataframeAnswer(params3.action, answer) };
66972
67046
  }
66973
67047
  };
@@ -71518,13 +71592,13 @@ function order(spec, ranks, back) {
71518
71592
  const above = byRank[depth - 1] ?? [];
71519
71593
  const positions = new Map(above.map((id, index) => [id, index]));
71520
71594
  const row = byRank[depth] ?? [];
71521
- const keyed = row.map((id, index) => {
71595
+ const keyed2 = row.map((id, index) => {
71522
71596
  const known = (parents.get(id) ?? []).map((parent) => positions.get(parent)).filter((value) => value !== void 0);
71523
71597
  const barycentre = known.length === 0 ? index : known.reduce((a, b) => a + b, 0) / known.length;
71524
71598
  return { id, barycentre, index };
71525
71599
  });
71526
- keyed.sort((a, b) => a.barycentre - b.barycentre || a.index - b.index);
71527
- byRank[depth] = keyed.map((entry) => entry.id);
71600
+ keyed2.sort((a, b) => a.barycentre - b.barycentre || a.index - b.index);
71601
+ byRank[depth] = keyed2.map((entry) => entry.id);
71528
71602
  }
71529
71603
  return byRank;
71530
71604
  }
@@ -73928,10 +74002,10 @@ function calendarDates(records) {
73928
74002
  const visit = (value) => {
73929
74003
  if (typeof value === "string" || typeof value === "number") {
73930
74004
  const text2 = String(value).trim();
73931
- const iso = /^(\d{4})-(\d{2})-(\d{2})/.exec(text2);
74005
+ const iso2 = /^(\d{4})-(\d{2})-(\d{2})/.exec(text2);
73932
74006
  const us = /^(\d{1,2})\/(\d{1,2})\/(\d{4})/.exec(text2);
73933
- if (iso !== null)
73934
- found2.add(`${iso[1] ?? ""}-${iso[2] ?? ""}-${iso[3] ?? ""}`);
74007
+ if (iso2 !== null)
74008
+ found2.add(`${iso2[1] ?? ""}-${iso2[2] ?? ""}-${iso2[3] ?? ""}`);
73935
74009
  else if (us !== null)
73936
74010
  found2.add(`${us[3] ?? ""}-${(us[1] ?? "").padStart(2, "0")}-${(us[2] ?? "").padStart(2, "0")}`);
73937
74011
  } else if (Array.isArray(value))
@@ -75626,6 +75700,8 @@ var MAPPING = {
75626
75700
  level: { type: "keyword" },
75627
75701
  alertIds: { type: "keyword" },
75628
75702
  alertKeys: { type: "keyword" },
75703
+ /** A shared grid's content hash (Fire Code 0.65.0). */
75704
+ hash: { type: "keyword" },
75629
75705
  payload: { type: "object", enabled: false }
75630
75706
  }
75631
75707
  }
@@ -75694,9 +75770,46 @@ var MonitorHistoryStore = class {
75694
75770
  const type = json2["error"]?.type;
75695
75771
  if (status2 >= 300 && type !== "resource_already_exists_exception")
75696
75772
  this.fail("creating the monitoring index", status2, json2);
75773
+ if (type === "resource_already_exists_exception") {
75774
+ const added = await this.send("PUT", "/_mapping", { properties: { hash: MAPPING.mappings.properties.hash } });
75775
+ if (added.status >= 300)
75776
+ this.fail("updating the monitoring index", added.status, added.json);
75777
+ }
75697
75778
  this.ensured = true;
75698
75779
  }
75699
75780
  /** True when this Fire Code may run `monitor` for interval `slot`; false when a team member already is. */
75781
+ /**
75782
+ * A check's whole grid, shared once per distinct grid and day (asked: every member must see the same rows, not
75783
+ * only the alerted ones). Named by the grid's content hash, so unchanged data adds nothing; created once - a
75784
+ * second writer the same day gets "already there", which is success.
75785
+ */
75786
+ async writeGrid(monitor, hash3, evaluation) {
75787
+ await this.ensureIndex();
75788
+ const day = Math.floor(Date.now() / 864e5);
75789
+ const { status: status2, json: json2 } = await this.send("PUT", `/_create/${encodeURIComponent(docId("grid", monitor, hash3, day))}`, {
75790
+ kind: "grid",
75791
+ monitor,
75792
+ by: this.by,
75793
+ at: Math.floor(Date.now() / 1e3),
75794
+ hash: hash3,
75795
+ payload: { evaluation }
75796
+ });
75797
+ if (status2 === 409)
75798
+ return;
75799
+ if (status2 >= 300)
75800
+ this.fail(`sharing the grid of ${monitor}`, status2, json2);
75801
+ }
75802
+ /** A shared grid by its hash: the newest copy, or undefined when no member shared it (or it was cleaned up). */
75803
+ async grid(monitor, hash3) {
75804
+ const json2 = await this.search({
75805
+ size: 1,
75806
+ sort: [{ at: "desc" }],
75807
+ _source: ["payload"],
75808
+ query: { bool: { filter: [{ term: { kind: "grid" } }, { term: { monitor } }, { term: { hash: hash3 } }] } }
75809
+ });
75810
+ const hits = json2["hits"]?.hits ?? [];
75811
+ return hits[0]?._source.payload.evaluation;
75812
+ }
75700
75813
  async claim(monitor, slot) {
75701
75814
  await this.ensureIndex();
75702
75815
  const { status: status2, json: json2 } = await this.send("PUT", `/_create/${encodeURIComponent(docId("claim", monitor, slot))}`, {
@@ -75755,16 +75868,26 @@ var MonitorHistoryStore = class {
75755
75868
  return out;
75756
75869
  }
75757
75870
  /** A monitor's checks since `since` (epoch seconds), newest first, by anyone. */
75758
- async history(monitor, since2, limit = 500) {
75871
+ /** Checks from `since`, newest first; with `until`, only before then (one day's, from the History view). */
75872
+ async history(monitor, since2, limit = 500, until) {
75759
75873
  const json2 = await this.search({
75760
75874
  size: Math.min(Math.max(limit, 1), 2e3),
75761
75875
  sort: [{ at: "desc" }],
75762
75876
  _source: ["payload"],
75763
- query: { bool: { filter: [{ term: { kind: "check" } }, { term: { monitor } }, { range: { at: { gte: since2 } } }] } }
75877
+ query: { bool: { filter: [{ term: { kind: "check" } }, { term: { monitor } }, { range: { at: { gte: since2, ...until !== void 0 ? { lt: until } : {} } } }] } }
75764
75878
  });
75765
75879
  const hits = json2["hits"]?.hits ?? [];
75766
75880
  return hits.map((h) => h._source.payload);
75767
75881
  }
75882
+ /** Removes one check of this person's - the History view's "Delete this check". A colleague's stays theirs. */
75883
+ async deleteCheck(monitor, at) {
75884
+ await this.ensureIndex();
75885
+ const filter = [{ term: { kind: "check" } }, { term: { monitor } }, { term: { at } }, { term: { by: this.by } }];
75886
+ const { status: status2, json: json2 } = await this.send("POST", "/_delete_by_query?conflicts=proceed", { query: { bool: { filter } } });
75887
+ if (status2 >= 300)
75888
+ this.fail("deleting a check", status2, json2);
75889
+ return Number(json2["deleted"] ?? 0);
75890
+ }
75768
75891
  /** Removes this person's checks and claims older than `before` - only theirs. How many went. */
75769
75892
  async prune(before, monitor) {
75770
75893
  await this.ensureIndex();
@@ -75932,6 +76055,12 @@ from datetime import datetime, timezone
75932
76055
 
75933
76056
  import light_code
75934
76057
 
76058
+ # Big or tabular data: use Polars when it is installed (monitor_check_tool says whether it is) - filter and
76059
+ # aggregate there and return df.to_dicts(). Fall back to plain Python (or pandas) only when it is not:
76060
+ # import polars as pl
76061
+ # df = pl.read_csv(path).filter(pl.col("status") != "OK").select(["job", "status", "minutes"])
76062
+ # return df.to_dicts()
76063
+
75935
76064
  # Tools this one calls with light_code.call_tool - MCP tools, other Python tools, and Fire Code's
75936
76065
  # reading tools (autosys_status, jira_search, ...). Reviewed with the tool; in a monitor they run unasked.
75937
76066
  __tool_calls__ = ["server__query_jobs"]
@@ -75947,7 +76076,8 @@ def run(pattern: str = "PAY_*") -> list[dict]:
75947
76076
  """
75948
76077
  # Either read the source directly, or call an existing tool (its answer is text - json.loads it
75949
76078
  # when the tool answers JSON). Let it RAISE when the data cannot be read - the tile turns purple.
75950
- items = json.loads(light_code.call_tool("server__query_jobs", {"pattern": pattern}))
76079
+ # Arguments are keywords: call_tool("server__query_jobs", pattern=pattern) - never a dict.
76080
+ items = json.loads(light_code.call_tool("server__query_jobs", pattern=pattern))
75951
76081
  rows = []
75952
76082
  for item in items:
75953
76083
  rows.append({
@@ -75961,7 +76091,7 @@ def run(pattern: str = "PAY_*") -> list[dict]:
75961
76091
  `.trim();
75962
76092
 
75963
76093
  // ../../packages/core/dist/monitoring/tools.js
75964
- var MONITOR_TOOL_FORMAT = `FORMAT a monitor reads: make the Python tool's run() return a LIST OF DICTS - one dict per thing watched (a job, a host, a feed), the same keys in each; flat values (str, int, float, bool or None - a nested dict is read with a dotted key such as "owner.name"); numbers as numbers, never "1,250" or "84 min" strings; timestamps as ISO 8601 ("2026-10-25T14:05:00Z") or epoch seconds, so olderThan/newerThan rules work; one key that names the row (job, host) for the monitor's "key"; a status as a short fixed word (FAILURE, OK) rules can match. Return [] when there is nothing to report - never a message saying so. RAISE an exception when the data cannot be read, so the tile turns purple (cannot tell) instead of green. Keep it fast (seconds) and read-only. {"rows": [...]} and {"columns": [...], "rows": [[...]]} are read too. Try it with monitor_create tryOnly: true before saving.`;
76094
+ var MONITOR_TOOL_FORMAT = `FORMAT a monitor reads: make the Python tool's run() return a LIST OF DICTS - one dict per thing watched (a job, a host, a feed), the same keys in each; flat values (str, int, float, bool or None - a nested dict is read with a dotted key such as "owner.name"); numbers as numbers, never "1,250" or "84 min" strings; timestamps as ISO 8601 ("2026-10-25T14:05:00Z") or epoch seconds, so olderThan/newerThan rules work; one key that names the row (job, host) for the monitor's "key"; a status as a short fixed word (FAILURE, OK) rules can match. Return [] when there is nothing to report - never a message saying so. RAISE an exception when the data cannot be read, so the tile turns purple (cannot tell) instead of green. Keep it fast (seconds) and read-only. {"rows": [...]} and {"columns": [...], "rows": [[...]]} are read too. Try it with monitor_create tryOnly: true before saving. FOR SPEED: when Polars is installed in the tools' environment (monitor_check_tool says), use it rather than pandas - read, filter and aggregate in Polars (lazy scans for big files) and return df.to_dicts(); return only the rows and fields the rules need. light_code.call_tool takes keyword arguments: call_tool("name", job="X"), never a dict.`;
75965
76095
  var condition = external_exports.lazy(() => external_exports.union([
75966
76096
  external_exports.object({ all: external_exports.array(condition) }),
75967
76097
  external_exports.object({ any: external_exports.array(condition) }),
@@ -75973,7 +76103,7 @@ var sourceSchema = external_exports.union([
75973
76103
  external_exports.object({ tool: external_exports.string(), args: external_exports.record(external_exports.string(), external_exports.unknown()).optional() }),
75974
76104
  external_exports.object({ sqlite: external_exports.string(), sql: external_exports.string() }),
75975
76105
  external_exports.object({ files: external_exports.union([external_exports.string(), external_exports.array(external_exports.union([external_exports.string(), external_exports.object({ name: external_exports.string().optional(), path: external_exports.string() })]))]), sql: external_exports.string() })
75976
- ]).describe('Where the rows come from. {"tool": "py__name", "args": {...}}: a Python tool (returning a list of records), an MCP tool or a read tool - runs in the background with the settings Fire Code monitoring uses. {"sqlite": "C:\\\\full\\\\path.db", "sql": "select ..."}: read by Fire Code itself, never locked. {"files": ["C:\\\\full\\\\path.csv"], "sql": "select ... from data"}: CSV, TSV, Excel or JSON, queried with SQL (the first file is the table "data", the second "data2").');
76106
+ ]).describe(`Where the rows come from - PREFER, IN THIS ORDER: (1) {"sqlite": ...} or {"files": ...} when the data is a database or a file - Fire Code reads it itself; (2) one of Fire Code's Rust tools with "records": true in its args, for files, folders, logs and tables - Rust collects and judges, no Python: find_files (a feed file late or missing: ageMinutes, sizeBytes), grep_files (ERROR lines across logs or shares: path, line, text), big_file action "search" (one huge log: line, text), query_table (a CSV or Excel sheet, filtered and grouped), query_sqlite (action "query"), dataframe (SQL across several files) - e.g. {"tool": "find_files", "args": {"roots": ["//fileserver/feeds"], "names": ["prices_*.csv"], "records": true}}; (3) an existing Python or MCP tool that already returns records; (4) only then a new Python tool - for an API or logic the others cannot do, calling the Rust tools for the heavy lifting. {"tool": "py__name", "args": {...}}: a Python tool (returning a list of records), an MCP tool or a read tool - runs in the background with the settings Fire Code monitoring uses. {"sqlite": "C:\\\\full\\\\path.db", "sql": "select ..."}: read by Fire Code itself, never locked. {"files": ["C:\\\\full\\\\path.csv"], "sql": "select ... from data"}: CSV, TSV, Excel or JSON, queried with SQL (the first file is the table "data", the second "data2").`);
75977
76107
  var createSchema2 = external_exports.object({
75978
76108
  name: external_exports.string().describe('kebab-case, e.g. "overnight-batch" - the monitor and its skill file.'),
75979
76109
  title: external_exports.string().describe('What the tile says, a few words: "Overnight batch".'),
@@ -76177,7 +76307,7 @@ function createMonitorCheckToolTool(options) {
76177
76307
  return {
76178
76308
  name: "monitor_check_tool",
76179
76309
  group: "command",
76180
- description: 'Run a tool once and check its answer is what a Fire Code monitor needs: a list of records with one type per field, numbers as numbers, ISO timestamps, a field naming each row, failures raised rather than returned. Says PASS or FAIL with what to change, the fields it found, and the "columns" and "key" to give monitor_create. HOW TO MAKE A MONITORING TOOL: (1) reuse a tool that already returns the data if one passes this check; (2) otherwise write a Python tool with create_python_tool (audience "team" for a team monitor, "me" for a personal one) starting from this template, reading the real source - use light_code.credential("name") for a saved credential, never a password in the code:\n' + MONITOR_TOOL_TEMPLATE + '\n(3) call monitor_check_tool and fix the tool until it says PASS; (4) only then call monitor_create with the "columns" and "key" it suggests.',
76310
+ description: 'Run a tool once and check its answer is what a Fire Code monitor needs: a list of records with one type per field, numbers as numbers, ISO timestamps, a field naming each row, failures raised rather than returned. Says PASS or FAIL with what to change, the fields it found, and the "columns" and "key" to give monitor_create. FIRST consider no new tool at all: a SQLite or file source, or a Rust tool with "records": true (find_files, grep_files, big_file search, query_table, query_sqlite, dataframe) - check those with this tool too. HOW TO MAKE A MONITORING TOOL when one is needed: (1) reuse a tool that already returns the data if one passes this check - it must only read, since a monitor runs it unattended; (2) otherwise write a Python tool with create_python_tool (audience "team" for a team monitor, "me" for a personal one) starting from this template, reading the real source - use light_code.credential("name") for a saved credential, never a password in the code:\n' + MONITOR_TOOL_TEMPLATE + '\n(3) call monitor_check_tool and fix the tool until it says PASS; (4) only then call monitor_create with the "columns" and "key" it suggests.',
76181
76311
  parametersSchema: checkToolSchema,
76182
76312
  async preview(params3) {
76183
76313
  return { kind: "text", text: `Run ${params3.tool}(${JSON.stringify(params3.args ?? {}, null, 2)}) once and check what it returns.` };
@@ -76193,10 +76323,20 @@ That is what a monitor shows as purple (cannot tell). Fix the tool and check aga
76193
76323
  isError: true
76194
76324
  };
76195
76325
  }
76196
- return { content: describeRowsCheck(checkMonitorRows(result.content)) };
76326
+ return { content: `${describeRowsCheck(checkMonitorRows(result.content))}
76327
+
76328
+ ${await polarsNote(options)}` };
76197
76329
  }
76198
76330
  };
76199
76331
  }
76332
+ async function polarsNote(options) {
76333
+ const has2 = await options.hasModule?.("polars").catch(() => void 0);
76334
+ if (has2 === true)
76335
+ return "Polars is installed in the tools' environment: use it rather than pandas for reading, filtering and aggregating (return df.to_dicts()).";
76336
+ if (has2 === false)
76337
+ return "Polars is not installed in the tools' environment: plain Python (or pandas, if installed) it is. If the data is big, ask the user whether to install polars (install_python_packages).";
76338
+ return "Could not tell whether Polars is installed; if `import polars` works, prefer it to pandas.";
76339
+ }
76200
76340
  var statusSchema2 = external_exports.object({
76201
76341
  name: external_exports.string().optional().describe("One monitor, for its alerts and rows. Omit for every monitor."),
76202
76342
  rows: external_exports.number().int().min(0).max(1e3).optional().describe("How many rows of one monitor to include. Default 50."),
@@ -82873,7 +83013,8 @@ ${preview.text}` } : {}
82873
83013
  const monitorOptions = {
82874
83014
  channel: services.monitoring,
82875
83015
  writeSkill,
82876
- runTool: (name, args, toolContext) => executeForMonitor(name, args, toolContext)
83016
+ runTool: (name, args, toolContext) => executeForMonitor(name, args, toolContext),
83017
+ hasModule: async (module2) => (await python.hasModules([module2]))?.[module2]
82877
83018
  };
82878
83019
  combined.register(createMonitorCreateTool(monitorOptions));
82879
83020
  combined.register(createMonitorStatusTool(monitorOptions));
@@ -85955,7 +86096,7 @@ ${redact(shown2, cachedSecretValues)}` }
85955
86096
  return [];
85956
86097
  }
85957
86098
  }
85958
- async function executeForMonitor(name, args, given, signal) {
86099
+ async function monitorToolHere(name) {
85959
86100
  const { config: config2 } = await configManager.load();
85960
86101
  if (!monitorSettingsLoaded) {
85961
86102
  monitorSettingsLoaded = true;
@@ -85966,9 +86107,22 @@ ${redact(shown2, cachedSecretValues)}` }
85966
86107
  await python.configure({ ...config2.python ?? {}, ...pythonFolders(config2) });
85967
86108
  const registry2 = currentToolRegistry();
85968
86109
  const tool = registry2.get(name) ?? registry2.get(`py__${name}`);
86110
+ if (tool === void 0) {
86111
+ const bare = name.replace(/^py__/, "");
86112
+ const waiting = python.status().issues.find((issue2) => issue2.name === bare);
86113
+ if (waiting !== void 0)
86114
+ return { refusal: `${name} is on this computer but not loaded: ${waiting.detail}` };
86115
+ }
85969
86116
  const refusal = monitorToolRefusal(tool, name);
85970
86117
  if (refusal !== void 0 || tool === void 0)
85971
- return { content: refusal ?? `No tool called "${name}".`, isError: true };
86118
+ return { refusal: refusal ?? `No tool called "${name}".` };
86119
+ return { tool };
86120
+ }
86121
+ async function executeForMonitor(name, args, given, signal) {
86122
+ const here = await monitorToolHere(name);
86123
+ if ("refusal" in here)
86124
+ return { content: here.refusal, isError: true };
86125
+ const tool = here.tool;
85972
86126
  const parsed = tool.parametersSchema.safeParse(args);
85973
86127
  if (!parsed.success)
85974
86128
  return { content: `The arguments do not fit ${tool.name}: ${parsed.error.message}`, isError: true };
@@ -86025,12 +86179,19 @@ ${redact(shown2, cachedSecretValues)}` }
86025
86179
  case "write":
86026
86180
  await store.write(args["record"]);
86027
86181
  return { by: store.by };
86182
+ case "writeGrid":
86183
+ await store.writeGrid(monitor, String(args["hash"] ?? ""), args["evaluation"]);
86184
+ return { by: store.by };
86185
+ case "grid":
86186
+ return await store.grid(monitor, String(args["hash"] ?? "")) ?? null;
86028
86187
  case "latest":
86029
86188
  return store.latest(Array.isArray(args["monitors"]) ? args["monitors"] : []);
86030
86189
  case "history":
86031
- return store.history(monitor, Number(args["since"] ?? 0), Number(args["limit"] ?? 500));
86190
+ return store.history(monitor, Number(args["since"] ?? 0), Number(args["limit"] ?? 500), typeof args["until"] === "number" ? args["until"] : void 0);
86032
86191
  case "prune":
86033
86192
  return { deleted: await store.prune(Number(args["before"] ?? 0), monitor.length > 0 ? monitor : void 0) };
86193
+ case "deleteCheck":
86194
+ return { deleted: await store.deleteCheck(monitor, Number(args["at"] ?? 0)) };
86034
86195
  case "test":
86035
86196
  await store.ensureIndex();
86036
86197
  return { index: store.index, by: store.by };
@@ -86064,6 +86225,14 @@ ${redact(shown2, cachedSecretValues)}` }
86064
86225
  return { ok: true, data: await answerMonitorStore(request.op, await monitorStore(request.storeId, request.index), request.args) };
86065
86226
  case "explain":
86066
86227
  return { ok: true, data: await explainForMonitor(request.context) };
86228
+ case "probe": {
86229
+ const here = await monitorToolHere(request.tool);
86230
+ return { ok: true, data: "refusal" in here ? { ready: false, reason: here.refusal } : { ready: true } };
86231
+ }
86232
+ case "skill": {
86233
+ const done = request.op === "write" ? await writeTeamMonitorSkill(request.file, request.content ?? "") : await deleteEverywhere(await planDeleteEverywhere("skill", request.name));
86234
+ return done.ok ? { ok: true, data: done.message } : { ok: false, error: done.message };
86235
+ }
86067
86236
  }
86068
86237
  } catch (error51) {
86069
86238
  return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
@@ -86540,7 +86709,17 @@ ${redact(shown2, cachedSecretValues)}` }
86540
86709
  }
86541
86710
  async function handleDeleteEverywhere(requested2) {
86542
86711
  const { kind, name } = requested2;
86543
- const done = (ok, message5) => post({ type: "deleteEverywhereDone", kind, name, ok, message: message5 });
86712
+ const result = await deleteEverywhere(requested2);
86713
+ post({ type: "deleteEverywhereDone", kind, name, ok: result.ok, message: result.message });
86714
+ }
86715
+ async function deleteEverywhere(requested2) {
86716
+ const { kind, name } = requested2;
86717
+ if (requested2.error !== void 0)
86718
+ return { ok: false, message: requested2.error };
86719
+ let answer = { ok: false, message: "Nothing was done." };
86720
+ const done = (ok, message5) => {
86721
+ answer = { ok, message: message5 };
86722
+ };
86544
86723
  try {
86545
86724
  const config2 = await loadSettings();
86546
86725
  const team = teamRepoPlan(config2);
@@ -86562,7 +86741,7 @@ ${redact(shown2, cachedSecretValues)}` }
86562
86741
  });
86563
86742
  if (result.failed !== void 0) {
86564
86743
  done(false, `Not deleted: the repository refused ${result.failed.path} (${result.failed.problem}). Nothing else was removed, so it stays consistent - try again.`);
86565
- return;
86744
+ return answer;
86566
86745
  }
86567
86746
  parts.push(`Marked deleted in the team repository ${fresh.repoLabel ?? ""} (${String(result.done.length)} file(s)); colleagues' copies go at their next sync.`);
86568
86747
  }
@@ -86606,6 +86785,64 @@ ${redact(shown2, cachedSecretValues)}` }
86606
86785
  } catch (error51) {
86607
86786
  done(false, error51 instanceof Error ? error51.message : String(error51));
86608
86787
  }
86788
+ return answer;
86789
+ }
86790
+ async function writeTeamMonitorSkill(file2, content) {
86791
+ const config2 = await loadSettings();
86792
+ const norm2 = (value) => process.platform === "win32" ? import_node_path52.default.resolve(value).toLowerCase() : import_node_path52.default.resolve(value);
86793
+ const inside = (dir) => {
86794
+ const target = norm2(file2);
86795
+ const root = norm2(dir);
86796
+ return target.startsWith(root + import_node_path52.default.sep) ? import_node_path52.default.relative(import_node_path52.default.resolve(dir), import_node_path52.default.resolve(file2)) : void 0;
86797
+ };
86798
+ const saveIn = async (dir, relative) => {
86799
+ const destination = import_node_path52.default.join(dir, relative);
86800
+ const enabled = cachedSkillMirrors.filter((each) => each.enabled === true);
86801
+ const mirror = enabled.find((_, i) => samePath(mirroredSkillsDirs[i], dir));
86802
+ const target = mirror !== void 0 ? targetById(cachedS3, mirror.connectionId) : void 0;
86803
+ if (mirror !== void 0 && (target === void 0 || target.readOnly === true)) {
86804
+ throw new Error(`${target?.label ?? mirror.connectionId} is read-only here, so this team monitor cannot be changed from this computer - ask whoever owns that bucket.`);
86805
+ }
86806
+ await import_promises29.default.mkdir(import_node_path52.default.dirname(destination), { recursive: true });
86807
+ await writeFileAtomically(destination, content);
86808
+ if (mirror !== void 0 && target !== void 0) {
86809
+ await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: relative.split(import_node_path52.default.sep).join("/"), contents: Buffer.from(content, "utf8") });
86810
+ return `uploaded to the bucket ${target.label}`;
86811
+ }
86812
+ return `saved in ${dir}`;
86813
+ };
86814
+ try {
86815
+ for (const dir of mirroredSkillsDirs) {
86816
+ const relative = inside(dir);
86817
+ if (relative !== void 0) {
86818
+ const where = await saveIn(dir, relative);
86819
+ await refreshSkills();
86820
+ return { ok: true, message: `Saved and ${where}; colleagues get it at their next sync and approve it once.` };
86821
+ }
86822
+ }
86823
+ const team = teamRepoPlan(config2);
86824
+ if ("dirs" in team) {
86825
+ const relative = inside(team.dirs.skills);
86826
+ if (relative !== void 0) {
86827
+ if (skillsDir === void 0)
86828
+ throw new Error("There is no folder to save skills in, so the change cannot reach the team repository.");
86829
+ const where = await saveIn(skillsDir, relative);
86830
+ await handleTeamRepoSync("a monitor changed on the dashboard");
86831
+ const problem = teamRepoStatus?.error ?? teamRepoStatus?.conflicts.find((c2) => c2.path.endsWith(relative.split(import_node_path52.default.sep).join("/")))?.reason;
86832
+ if (problem !== void 0) {
86833
+ return { ok: false, message: `Saved here (${where}), but not committed to the team repository: ${problem}. Nothing was overwritten - see Settings \u2192 DevOps \u2192 Team repository.` };
86834
+ }
86835
+ await refreshSkills();
86836
+ return { ok: true, message: `Saved and committed to the team repository ${cachedTeamRepoLabel ?? ""}; colleagues get it at their next sync and approve it once.` };
86837
+ }
86838
+ }
86839
+ return {
86840
+ ok: false,
86841
+ message: `${file2} is not in a bucket folder or the team repository that the settings monitoring runs with know about. Choose the codebase that has them in Fire Code \u2192 Settings \u2192 Monitoring ("Run tools with the settings of").`
86842
+ };
86843
+ } catch (error51) {
86844
+ return { ok: false, message: error51 instanceof Error ? error51.message : String(error51) };
86845
+ }
86609
86846
  }
86610
86847
  let cachedTeamRepoLabel;
86611
86848
  function sharedWith(kind) {
@@ -88317,6 +88554,45 @@ ${last}` : ""}`);
88317
88554
  };
88318
88555
  }
88319
88556
  }
88557
+ async function showPythonTab() {
88558
+ if (!python.status().ready && !userTurnRunning && runningScheduleId === void 0) {
88559
+ const config2 = await loadSettings();
88560
+ if (config2.python?.dynamicTools === "on")
88561
+ await postPython(await python.previewStatus(pythonFolders(config2)));
88562
+ }
88563
+ await configurePythonFromSettings();
88564
+ await postPython();
88565
+ }
88566
+ async function handleCheckTeamTools() {
88567
+ const { config: config2 } = await configManager.load();
88568
+ const bucket = (config2.s3?.tools ?? []).some((mirror) => mirror.enabled === true);
88569
+ const repo = config2.teamRepo?.enabled === true;
88570
+ if (!bucket && !repo) {
88571
+ post({ type: "teamToolsChecked", ok: false, message: "No team bucket folder for tools (Settings \u2192 S3) and no team repository (Settings \u2192 DevOps) is set up here, so there is nothing to pull." });
88572
+ return;
88573
+ }
88574
+ const waitingBefore = new Set(python.status().issues.filter((issue2) => issue2.recoverable).map((issue2) => issue2.filePath));
88575
+ const notes = [];
88576
+ if (bucket) {
88577
+ await handleSyncS3("tools");
88578
+ if (lastSync.tools !== void 0)
88579
+ notes.push(lastSync.tools);
88580
+ }
88581
+ if (repo) {
88582
+ await handleTeamRepoSync("checked by hand");
88583
+ if (teamRepoStatus?.error !== void 0)
88584
+ notes.push(`Team repository: ${teamRepoStatus.error}`);
88585
+ else if (teamRepoStatus !== void 0)
88586
+ notes.push(`Team repository: ${String(teamRepoStatus.pulled.length)} file(s) came down.`);
88587
+ }
88588
+ await configurePythonFromSettings();
88589
+ await python.refresh();
88590
+ await postPython();
88591
+ const waiting = python.status().issues.filter((issue2) => issue2.recoverable);
88592
+ const fresh = waiting.filter((issue2) => !waitingBefore.has(issue2.filePath));
88593
+ const summary = fresh.length > 0 ? `${String(fresh.length)} new tool(s) to review: ${fresh.map((issue2) => issue2.name).join(", ")}.` : waiting.length > 0 ? `Nothing new; ${String(waiting.length)} tool(s) still waiting for your approval.` : "No new tools waiting for approval.";
88594
+ post({ type: "teamToolsChecked", ok: true, message: [summary, ...notes].join(" ") });
88595
+ }
88320
88596
  async function configurePythonFromSettings() {
88321
88597
  if (userTurnRunning || runningScheduleId !== void 0)
88322
88598
  return;
@@ -88876,11 +89152,11 @@ ${last}` : ""}`);
88876
89152
  if (usageCollecting())
88877
89153
  void pushUsageNow();
88878
89154
  }
88879
- async function postPython() {
89155
+ async function postPython(preview) {
88880
89156
  const saved = await configManager.load().then((loaded) => loaded.config.python, () => void 0) ?? {};
88881
89157
  post({
88882
89158
  type: "python",
88883
- status: python.status(),
89159
+ status: preview ?? python.status(),
88884
89160
  settings: {
88885
89161
  dynamicTools: saved.dynamicTools ?? "off",
88886
89162
  ...saved.uvPath !== void 0 ? { uvPath: saved.uvPath } : {},
@@ -90609,7 +90885,9 @@ ${last}` : ""}`);
90609
90885
  } else if (message5.type === "deleteSkillFile") {
90610
90886
  reportFailure("handleDeleteSkillFile", handleDeleteSkillFile(message5.name));
90611
90887
  } else if (message5.type === "requestPython") {
90612
- reportFailure("postPython", configurePythonFromSettings().then(postPython));
90888
+ reportFailure("postPython", showPythonTab());
90889
+ } else if (message5.type === "checkTeamTools") {
90890
+ reportFailure("handleCheckTeamTools", handleCheckTeamTools());
90613
90891
  } else if (message5.type === "setPython") {
90614
90892
  reportFailure("handleSetPython", handleSetPython(message5));
90615
90893
  } else if (message5.type === "requestUsage") {
@@ -92910,6 +93188,11 @@ git is the main defence.
92910
93188
  "dynamic",
92911
93189
  "registry",
92912
93190
  "missing package",
93191
+ "new team tools",
93192
+ "check for new tools",
93193
+ "pull tools",
93194
+ "tools not showing for approval",
93195
+ "python tab slow",
92913
93196
  "install package",
92914
93197
  "module not found",
92915
93198
  "library",
@@ -92950,6 +93233,12 @@ installed or removed: that environment belongs to whatever built it.
92950
93233
  as an ImportError from inside the worker. config:python.indexUrl points at an internal mirror and
92951
93234
  config:python.offline refuses the network.
92952
93235
 
93236
+ **A colleague's new tool, now**: Settings \u2192 Python \u2192 **Check for new team tools** pulls the team's bucket tool
93237
+ folders and the team repository straight away (instead of at the next sync, every 15 minutes by default) and
93238
+ says what came down; anything new appears above the chat for approval. The Python tab shows the tools already
93239
+ approved at once, marked "Starting Python\u2026", and fills in the rest once Python is running - starting uv and
93240
+ Python can take seconds on a managed machine.
93241
+
92953
93242
  **Missing packages are spotted before they fail.** Tools arriving from a bucket often need packages
92954
93243
  this machine's environment lacks. Light Code checks every tool's declared dependencies and imports
92955
93244
  against the environment; a tool that needs something missing says so in its description, the
@@ -94266,7 +94555,9 @@ the Windows VS Code package carries a slim one with every tool below except \`da
94266
94555
 
94267
94556
  To see whether they are on right now, look at the tool list in Settings \u2192 Tools, or ask "which tools do
94268
94557
  you have?" - the assistant answers from the tools it was actually given.
94269
- `
94558
+
94559
+
94560
+ **For a monitor**: find_files, grep_files, big_file (search), query_table, query_sqlite and dataframe take \`"records": true\` and answer as a JSON list of records, so a Fire Code monitor can use them as its source directly - Rust collects, Rust judges, no Python in between. See the Monitoring topic.`
94270
94561
  },
94271
94562
  {
94272
94563
  id: "confluence",
@@ -94515,7 +94806,42 @@ edits made outside the agent (in VS Code, say) are saved with \`hub_sync\` "push
94515
94806
  "monitor schedule",
94516
94807
  "schedule of a monitor",
94517
94808
  "monitor check",
94518
- "monitoring check"
94809
+ "monitoring check",
94810
+ "snooze until",
94811
+ "snooze row",
94812
+ "review all",
94813
+ "approve several monitors",
94814
+ "run history",
94815
+ "past failures",
94816
+ "polars",
94817
+ "team monitors",
94818
+ "approve monitors",
94819
+ "approve the team monitors",
94820
+ "offline",
94821
+ "runs elsewhere",
94822
+ "claim",
94823
+ "who runs the check",
94824
+ "not shared",
94825
+ "team checks",
94826
+ "my checks",
94827
+ "checks offline",
94828
+ "past failure",
94829
+ "specific date",
94830
+ "grid as it was",
94831
+ "delete a check",
94832
+ "delete one check",
94833
+ "rust tools",
94834
+ "find_files",
94835
+ "grep_files",
94836
+ "records",
94837
+ "only alerted rows",
94838
+ "all rows",
94839
+ "lazy load",
94840
+ "many rows",
94841
+ "older than",
94842
+ "delete old history",
94843
+ "delete history older than",
94844
+ "clean up history"
94519
94845
  ],
94520
94846
  body: `
94521
94847
  **Fire Code only.** Settings \u2192 Monitoring switches it on; a Monitoring button then appears at the top of the
@@ -94557,7 +94883,8 @@ while it stays red or amber, a quiet word when it clears, and quiet hours when o
94557
94883
  Each monitor can override it (right-click \u2192 How this one notifies), and its own \`notify\` sets the least
94558
94884
  severe level that notifies. Notifications have Open, Acknowledge and Snooze buttons.
94559
94885
 
94560
- **When checks run**: \`every\` ("15m") for an interval, kept to \`activeHours\` ("07:00-19:00", or "09:00-" for not
94886
+ **When checks run**: \`every\` ("15m") for an interval - once in each window of the clock (every 10 minutes is
94887
+ 10:00, 10:10, 10:20 ..., windows counted from UTC so a team across time zones agrees), whoever joined when, kept to \`activeHours\` ("07:00-19:00", or "09:00-" for not
94561
94888
  before nine, "-17:00" for until five); \`at\` for exact times of day ("07:30" - once a day - or ["07:30", "12:00",
94562
94889
  "18:00"]); \`days\` for the days of the week, for both. A time missed while Fire Code was closed is not made up the
94563
94890
  next day.
@@ -94569,8 +94896,49 @@ every 10 minutes on weekdays"); you approve the change as a diff.
94569
94896
 
94570
94897
  **Delete a monitor for good**: right-click its tile \u2192 Delete this monitor\u2026 (or \u22EF \u2192 Delete in its window). Its skill
94571
94898
  file, its results and history here, and your own checks in the team history go; Pause stops it for a while instead.
94572
- A copy synced from the team's bucket or repository cannot be changed or deleted from the dashboard - the next sync
94573
- would put it back - so ask the agent, or delete it for everyone in Settings \u2192 Skills.
94899
+ A copy synced from the team's bucket or repository is changed or deleted **where the team keeps it** - uploaded
94900
+ to the bucket or committed to the repository (a deletion goes from the repository, the bucket and this computer,
94901
+ like Delete everywhere in Settings \u2192 Skills) - so the next sync does not put the old one back. Colleagues get the
94902
+ change at their next sync and approve it once. This uses the bucket and repository of the codebase chosen under
94903
+ Settings \u2192 Monitoring ("Run tools with the settings of").
94904
+
94905
+ **Snooze**: right-click a tile \u2192 Snooze 1 hour / until tomorrow / **Snooze until\u2026** (a date and time, up to 30 days),
94906
+ or the Snooze button in its window. **One row**: right-click the row in the grid (or **Snooze row** in its details)
94907
+ \u2192 1 hour, 4 hours, until tomorrow 09:00, or until a date and time - its alerts stop counting until then, unless one
94908
+ gets worse, which counts again at once.
94909
+
94910
+ **Reviewing a colleague's monitors**: a blue banner on the dashboard says how many wait for your review; **Review
94911
+ all\u2026** lists each with its definition and a tick box - approve the ones you ticked (Select all ticks every one).
94912
+
94913
+ **Run history**: the wide button across the bottom of each tile shows the last checks as bars, oldest on the left.
94914
+ Press it for the monitor's History - every check kept, earlier days too (24 hours to 90 days, or **On** a chosen
94915
+ date); press one bar to open on that check. Choosing a check shows, under the bars: its time, result, who ran it,
94916
+ rows read, how long it took, and **its whole grid as it was** - every row, coloured as it was - straight away;
94917
+ **Open in grid view** for filters and sorting, read-only, with **Back to now**. Whole grids are kept from Fire Code
94918
+ 0.64.0 on, once per distinct grid, for as long as its history; a **team** check's grid is also shared in the team
94919
+ index (from 0.65.0), so **every member sees every row** of the newest check and of past ones, whoever ran it. A grid
94920
+ over 5,000 rows or about 2 MB is not shared - members then see its alerted rows, and an older check says why.
94921
+
94922
+ **Big grids** are drawn as you scroll: the first 200 rows at once, more as the bottom comes near - filters, search,
94923
+ sorting and counts cover every row. **Delete this check**
94924
+ removes one check: here, and your own record of it in the team history.
94925
+
94926
+ **A team check is collected once, not once per person**: each scheduled run is claimed in the team index first, so
94927
+ one member's Fire Code runs it and everyone sees that result ("checked by \u2026"); **Run now** claims a two-minute slot, so
94928
+ people pressing it together get one check. The full history is stored once, in the team index; each computer keeps
94929
+ only the newest 200 checks of a team monitor, for its tile.
94930
+
94931
+ **Only a computer that can run it claims it.** Before claiming, Fire Code checks the monitor can run here: a SQLite
94932
+ or file source's path is reachable, a tool exists, is approved here and is allowed for monitors (checked without
94933
+ running it, re-checked every 10 minutes). A computer that cannot leaves it to colleagues, and its tile says **Runs
94934
+ elsewhere** with the reason on hover. A check that **failed** here (a credential, a network route) makes this computer
94935
+ step back for three windows (at least 30 minutes) while a colleague's runs succeed - unless nobody has checked it for
94936
+ a window, when it tries again rather than leave it unrun.
94937
+
94938
+ **Offline**: when the team history cannot be reached, a team monitor still runs on this computer - its tile, colours
94939
+ and notifications stay current - and the tile says **Offline \xB7 N not shared**. Once the history answers again, each
94940
+ offline check claims its window: written if nobody had it, dropped if a colleague already checked that window. At
94941
+ most 50 per monitor are kept for this, on disk.
94574
94942
 
94575
94943
  **Personal monitors need nothing set up.** Ask for "a personal check" (or just a check, before team history exists)
94576
94944
  and the agent makes one only on this computer.
@@ -94585,7 +94953,10 @@ the newest check, saying who ran it. Writes never overwrite each other, and clea
94585
94953
  alert's pattern - **new** today, **ongoing** since when, **recurring** on several days ("usually starting around
94586
94954
  02:00"), comes and goes, or cleared; and any past check's alerted rows. A check keeps its colour, headline and the
94587
94955
  rows that had an alert. **Kept 90 days** by default (30 days to a year), cleaned every few hours; **Clean up now** in
94588
- Settings \u2192 Monitoring, and **Delete its history** on a tile's right-click menu. A snoozed or paused monitor keeps its
94956
+ Settings \u2192 Monitoring, and **Delete its history** on a tile's right-click menu - **everything, or only checks older
94957
+ than 7, 30, 90 or any number of days**; **Clean up\u2026** takes the same choice for every monitor. Both remove checks on
94958
+ this computer (with the grids they kept) and **your own** records in the team index; a colleague's records are theirs
94959
+ and stay until their Fire Code cleans them up. A snoozed or paused monitor keeps its
94589
94960
  colour on its tile but no longer colours the Monitoring button.
94590
94961
 
94591
94962
  **An alert explained**: double-click a coloured row. The author's advice for that rule comes first (asked for when
@@ -94593,6 +94964,14 @@ the monitor is created), then **the agent's explanation** - what is wrong, wheth
94593
94964
  history, what to do. **Start a chat** opens a chat named after the alert in the codebase you pick (the first by
94594
94965
  default), with what is known already in the message box - press Enter to send it.
94595
94966
 
94967
+ **Fast data collection**: a monitor that reads SQLite or a CSV/Excel/JSON file is read by Fire Code's Rust helper
94968
+ (Polars) - no Python at all. Fire Code's Rust tools can be a monitor's source too, with \`"records": true\` (a JSON list
94969
+ of records): find_files (a feed file late or missing - ageMinutes, sizeBytes), grep_files (ERROR lines across logs or
94970
+ shares), big_file search (one huge log), query_table, query_sqlite and dataframe. Prefer, in order: a SQLite or file
94971
+ source, a Rust tool, an existing Python or MCP tool that returns records, and only then a new Python tool. Reusing an
94972
+ existing Python tool is fine when it only reads and is approved on each member's computer. A Python tool source is Python: the agent is told whether Polars is installed in the tools'
94973
+ environment and to prefer it to pandas (filter and aggregate there, return df.to_dicts()). Rust then judges the rows.
94974
+
94596
94975
  **Tools can call tools**: a Python tool lists what it calls in \`__tool_calls__ = ["server__query", "autosys_status"]\`
94597
94976
  - MCP tools, other Python tools and Fire Code's reading tools. That line is part of the approved code; in a
94598
94977
  monitor's check those calls run without asking - the same when the agent tries the monitor in a chat - and nothing