@chosengeneration/light-code 0.132.0 → 0.134.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/cli.cjs
3
- size: 49594454 bytes
4
- sha256: 6a5cfce656108346df75662a968ad43932fe79a85050392ef2f53a0d96847b53
3
+ size: 49608472 bytes
4
+ sha256: 91709ff30de177d4f3ddd968e415055593674f398a0971bdfbbc131afaecd616
package/dist/server.cjs CHANGED
@@ -24126,7 +24126,7 @@ var require_cross_spawn = __commonJS({
24126
24126
  var cp = require("child_process");
24127
24127
  var parse3 = require_parse2();
24128
24128
  var enoent = require_enoent();
24129
- function spawn14(command, args, options) {
24129
+ function spawn13(command, args, options) {
24130
24130
  const parsed = parse3(command, args, options);
24131
24131
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
24132
24132
  enoent.hookChildProcess(spawned, parsed);
@@ -24138,8 +24138,8 @@ var require_cross_spawn = __commonJS({
24138
24138
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
24139
24139
  return result;
24140
24140
  }
24141
- module2.exports = spawn14;
24142
- module2.exports.spawn = spawn14;
24141
+ module2.exports = spawn13;
24142
+ module2.exports.spawn = spawn13;
24143
24143
  module2.exports.sync = spawnSync;
24144
24144
  module2.exports._parse = parse3;
24145
24145
  module2.exports._enoent = enoent;
@@ -59090,9 +59090,9 @@ async function detectBareInterpreter(configuredPath) {
59090
59090
  return void 0;
59091
59091
  }
59092
59092
  async function pythonVersion(program) {
59093
- const { spawn: spawn14 } = await import("node:child_process");
59093
+ const { spawn: spawn13 } = await import("node:child_process");
59094
59094
  return new Promise((resolve) => {
59095
- const child = spawn14(program, ["-c", 'import sys; print("%d.%d.%d" % sys.version_info[:3])'], {
59095
+ const child = spawn13(program, ["-c", 'import sys; print("%d.%d.%d" % sys.version_info[:3])'], {
59096
59096
  shell: false,
59097
59097
  env: minimalPythonEnv()
59098
59098
  });
@@ -62789,7 +62789,7 @@ function gatewayFromSettings(input, stored) {
62789
62789
 
62790
62790
  // ../../packages/core/dist/host/bridge.js
62791
62791
  var import_node_fs9 = require("node:fs");
62792
- var import_node_child_process15 = require("node:child_process");
62792
+ var import_node_child_process14 = require("node:child_process");
62793
62793
  var import_promises25 = __toESM(require("node:fs/promises"), 1);
62794
62794
 
62795
62795
  // ../../packages/core/dist/jupyter/spec.js
@@ -74785,12 +74785,14 @@ var UsageLog = class {
74785
74785
  storageDir;
74786
74786
  queueDir;
74787
74787
  manifestFile;
74788
+ rolledFile;
74788
74789
  legacyFile;
74789
74790
  session;
74790
74791
  constructor(storageDir, session) {
74791
74792
  this.storageDir = storageDir;
74792
74793
  this.queueDir = import_node_path43.default.join(storageDir, "usage", "queue");
74793
74794
  this.manifestFile = import_node_path43.default.join(storageDir, "usage", "pushed.json");
74795
+ this.rolledFile = import_node_path43.default.join(storageDir, "usage", "rolled.json");
74794
74796
  this.legacyFile = import_node_path43.default.join(storageDir, "usage-events.jsonl");
74795
74797
  this.session = session ?? (0, import_node_crypto12.randomBytes)(6).toString("hex");
74796
74798
  }
@@ -74883,6 +74885,22 @@ var UsageLog = class {
74883
74885
  const days = { ...await this.pushed(target), [day]: signature };
74884
74886
  await writeFileAtomically(this.manifestFile, JSON.stringify({ target, days }));
74885
74887
  }
74888
+ /** Months this install has rolled up in `target` (`usage/rollup.ts`): their late days go into the month. */
74889
+ async rolledMonths(target) {
74890
+ try {
74891
+ const saved = JSON.parse(await import_node_fs6.promises.readFile(this.rolledFile, "utf8"));
74892
+ return new Set(saved.target === target && Array.isArray(saved.months) ? saved.months.filter((month) => typeof month === "string") : []);
74893
+ } catch {
74894
+ return /* @__PURE__ */ new Set();
74895
+ }
74896
+ }
74897
+ async markRolled(target, month) {
74898
+ const months = await this.rolledMonths(target);
74899
+ if (months.has(month))
74900
+ return;
74901
+ months.add(month);
74902
+ await writeFileAtomically(this.rolledFile, JSON.stringify({ target, months: [...months].sort() }));
74903
+ }
74886
74904
  /** Deletes whole files of days older than `keepDays` that were pushed as they are. */
74887
74905
  async prune(target, keepDays, now = Date.now()) {
74888
74906
  const cutoff = usageDay(now - keepDays * 864e5);
@@ -74956,12 +74974,45 @@ function parseShardName(name) {
74956
74974
  const match = /^(\d{4}-\d{2}-\d{2})__([A-Za-z0-9]+)\.jsonl$/.exec(name);
74957
74975
  return match === null ? void 0 : { day: match[1], instance: match[2] };
74958
74976
  }
74977
+ function parseMonthName(name) {
74978
+ const match = /^(\d{4}-\d{2})__([A-Za-z0-9]+)\.jsonl$/.exec(name);
74979
+ return match === null ? void 0 : { month: match[1], instance: match[2] };
74980
+ }
74981
+ function shardFileName(shard) {
74982
+ return `${shard.day ?? shard.month ?? ""}__${shard.instance}.jsonl`;
74983
+ }
74984
+ function selectShards(files, fromDay, toDay) {
74985
+ const rolled = /* @__PURE__ */ new Set();
74986
+ for (const file2 of files) {
74987
+ const month = parseMonthName(file2.name);
74988
+ if (month !== void 0)
74989
+ rolled.add(`${file2.user}|${month.month}|${month.instance}`);
74990
+ }
74991
+ return files.filter((file2) => {
74992
+ const month = parseMonthName(file2.name);
74993
+ if (month !== void 0)
74994
+ return month.month >= fromDay.slice(0, 7) && month.month <= toDay.slice(0, 7);
74995
+ const day = parseShardName(file2.name);
74996
+ if (day === void 0 || day.day < fromDay || day.day > toDay)
74997
+ return false;
74998
+ return !rolled.has(`${file2.user}|${day.day.slice(0, 7)}|${day.instance}`);
74999
+ });
75000
+ }
75001
+ function ownShards(files, instance) {
75002
+ const own = [];
75003
+ for (const file2 of files) {
75004
+ const day = parseShardName(file2.name);
75005
+ if (day !== void 0 && day.instance === instance)
75006
+ own.push({ user: file2.user, day: day.day, instance });
75007
+ const month = parseMonthName(file2.name);
75008
+ if (month !== void 0 && month.instance === instance)
75009
+ own.push({ user: file2.user, month: month.month, instance });
75010
+ }
75011
+ return own;
75012
+ }
74959
75013
  function shardText(events) {
74960
75014
  return events.map((event) => JSON.stringify(event)).join("\n") + "\n";
74961
75015
  }
74962
- function inRange(day, fromDay, toDay) {
74963
- return day >= fromDay && day <= toDay;
74964
- }
74965
75016
  async function pooled(items, width, work) {
74966
75017
  const results = new Array(items.length);
74967
75018
  let next = 0;
@@ -75020,6 +75071,16 @@ var FolderShardStore = class {
75020
75071
  }
75021
75072
  return (Array.isArray(answer["events"]) ? answer["events"] : []).filter(isUsageEvent);
75022
75073
  }
75074
+ const files = await this.listFiles();
75075
+ const wanted = selectShards(files, fromDay, toDay);
75076
+ const texts = await pooled(wanted, 8, (file2) => import_node_fs7.promises.readFile(import_node_path44.default.join(this.root, file2.user, file2.name), "utf8").catch((error51) => {
75077
+ this.lastProblems.push(`${import_node_path44.default.join(this.root, file2.user, file2.name)}: ${error51 instanceof Error ? error51.message : String(error51)}`);
75078
+ return "";
75079
+ }));
75080
+ return texts.flatMap(parseUsageLines);
75081
+ }
75082
+ /** Every shard file, as `{ user, name }` - the person's folder and the file in it. */
75083
+ async listFiles() {
75023
75084
  let users;
75024
75085
  try {
75025
75086
  users = (await import_node_fs7.promises.readdir(this.root, { withFileTypes: true })).filter((entry) => entry.isDirectory() && entry.name !== "_profiles").map((entry) => entry.name);
@@ -75038,17 +75099,29 @@ var FolderShardStore = class {
75038
75099
  names = [];
75039
75100
  this.lastProblems.push(`${folder}: ${error51 instanceof Error ? error51.message : String(error51)}`);
75040
75101
  }
75041
- for (const name of names) {
75042
- const parsed = parseShardName(name);
75043
- if (parsed !== void 0 && inRange(parsed.day, fromDay, toDay))
75044
- files.push(import_node_path44.default.join(folder, name));
75045
- }
75102
+ for (const name of names)
75103
+ if (parseShardName(name) !== void 0 || parseMonthName(name) !== void 0)
75104
+ files.push({ user, name });
75046
75105
  }
75047
- const texts = await pooled(files, 8, (file2) => import_node_fs7.promises.readFile(file2, "utf8").catch((error51) => {
75048
- this.lastProblems.push(`${file2}: ${error51 instanceof Error ? error51.message : String(error51)}`);
75049
- return "";
75050
- }));
75051
- return texts.flatMap(parseUsageLines);
75106
+ return files;
75107
+ }
75108
+ async listOwn(instance) {
75109
+ return ownShards(await this.listFiles(), instance);
75110
+ }
75111
+ async readShard(shard) {
75112
+ try {
75113
+ return parseUsageLines(await import_node_fs7.promises.readFile(import_node_path44.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), "utf8"));
75114
+ } catch (error51) {
75115
+ if (error51.code === "ENOENT")
75116
+ return void 0;
75117
+ throw error51;
75118
+ }
75119
+ }
75120
+ async putMonth(shard, events) {
75121
+ await this.writeAtomically(import_node_path44.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), shardText(events));
75122
+ }
75123
+ async removeShard(shard) {
75124
+ await import_node_fs7.promises.rm(import_node_path44.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), { force: true });
75052
75125
  }
75053
75126
  async putProfile(user, profile) {
75054
75127
  this.profilesFromRead = void 0;
@@ -75091,15 +75164,45 @@ var S3ShardStore = class {
75091
75164
  const key2 = `${this.base}${shardSegment(shard.user)}/${shard.day}__${shard.instance}.jsonl`;
75092
75165
  await this.client.put(key2, Buffer.from(shardText(events), "utf8"), "application/x-ndjson");
75093
75166
  }
75094
- async read(fromDay, toDay) {
75167
+ /** Every shard object, as `{ user, name, key }`. */
75168
+ async listFiles() {
75095
75169
  const objects = await this.client.list(this.base, 2e5);
75096
- const wanted = objects.filter((object3) => {
75097
- const parsed = parseShardName(object3.key.slice(object3.key.lastIndexOf("/") + 1));
75098
- return parsed !== void 0 && inRange(parsed.day, fromDay, toDay);
75099
- });
75100
- const texts = await pooled(wanted, 8, async (object3) => (await this.client.get(object3.key)).toString("utf8"));
75170
+ return objects.map((object3) => {
75171
+ const rest = object3.key.slice(this.base.length);
75172
+ const slash = rest.indexOf("/");
75173
+ return { user: rest.slice(0, slash), name: rest.slice(slash + 1), key: object3.key };
75174
+ }).filter((file2) => file2.user.length > 0 && file2.user !== "_profiles" && !file2.name.includes("/"));
75175
+ }
75176
+ async read(fromDay, toDay) {
75177
+ const wanted = selectShards(await this.listFiles(), fromDay, toDay);
75178
+ const texts = await pooled(wanted, 8, async (file2) => (await this.client.get(file2.key)).toString("utf8"));
75101
75179
  return texts.flatMap(parseUsageLines);
75102
75180
  }
75181
+ keyOf(shard) {
75182
+ return `${this.base}${shardSegment(shard.user)}/${shardFileName(shard)}`;
75183
+ }
75184
+ async listOwn(instance) {
75185
+ return ownShards(await this.listFiles(), instance);
75186
+ }
75187
+ async readShard(shard) {
75188
+ try {
75189
+ return parseUsageLines((await this.client.get(this.keyOf(shard))).toString("utf8"));
75190
+ } catch (error51) {
75191
+ if (/\b404\b|NoSuchKey|not found/i.test(error51 instanceof Error ? error51.message : String(error51)))
75192
+ return void 0;
75193
+ throw error51;
75194
+ }
75195
+ }
75196
+ async putMonth(shard, events) {
75197
+ await this.client.put(this.keyOf(shard), Buffer.from(shardText(events), "utf8"), "application/x-ndjson");
75198
+ }
75199
+ /**
75200
+ * The second caller of `S3Client.remove` (§13 kept it to `s3/remove.ts`): only this install's own usage
75201
+ * day shards, only after the month that replaces them was written and read back complete.
75202
+ */
75203
+ async removeShard(shard) {
75204
+ await this.client.remove(this.keyOf(shard));
75205
+ }
75103
75206
  async putProfile(user, profile) {
75104
75207
  await this.client.put(`${this.base}_profiles/${shardSegment(user)}.json`, Buffer.from(JSON.stringify(cleanProfile(profile)), "utf8"), "application/json");
75105
75208
  }
@@ -75160,14 +75263,37 @@ var VectorShardStore = class {
75160
75263
  }
75161
75264
  ]);
75162
75265
  }
75163
- async read(fromDay, toDay) {
75164
- const events = [];
75266
+ /** Every shard document, as `{ user, name, text }` from its `usage/<user>/<name>` path. */
75267
+ async listFiles() {
75268
+ const files = [];
75165
75269
  await this.scanAll((document) => {
75166
- const parsed = parseShardName(document.path.slice(document.path.lastIndexOf("/") + 1));
75167
- if (parsed !== void 0 && inRange(parsed.day, fromDay, toDay))
75168
- events.push(...parseUsageLines(document.text));
75270
+ const match = /^usage\/([^/]+)\/([^/]+)$/.exec(document.path);
75271
+ if (match === null || match[1] === "_profiles")
75272
+ return;
75273
+ files.push({ user: match[1], name: match[2], text: document.text });
75169
75274
  });
75170
- return events;
75275
+ return files;
75276
+ }
75277
+ async read(fromDay, toDay) {
75278
+ return selectShards(await this.listFiles(), fromDay, toDay).flatMap((file2) => parseUsageLines(file2.text));
75279
+ }
75280
+ async listOwn(instance) {
75281
+ return ownShards(await this.listFiles(), instance);
75282
+ }
75283
+ async readShard(shard) {
75284
+ const name = shardFileName(shard);
75285
+ const found2 = (await this.listFiles()).find((file2) => file2.user === shardSegment(shard.user) && file2.name === name);
75286
+ return found2 === void 0 ? void 0 : parseUsageLines(found2.text);
75287
+ }
75288
+ async putMonth(shard, events) {
75289
+ await this.ensure();
75290
+ const user = shardSegment(shard.user);
75291
+ await this.writer.upsert(this.collection, [
75292
+ { id: `usage-month:${user}:${shard.month}:${shard.instance}`, text: shardText(events), path: `usage/${user}/${shardFileName(shard)}`, startLine: 0, endLine: 0, vector: [1, 0], owner: shard.user }
75293
+ ]);
75294
+ }
75295
+ async removeShard(shard) {
75296
+ await this.writer.deleteByPaths(this.collection, [`usage/${shardSegment(shard.user)}/${shardFileName(shard)}`]);
75171
75297
  }
75172
75298
  async putProfile(user, profile) {
75173
75299
  await this.ensure();
@@ -75196,6 +75322,7 @@ async function pushUsage(options) {
75196
75322
  const pushedDays = /* @__PURE__ */ new Set();
75197
75323
  const again = new Set(options.recheck ?? []);
75198
75324
  let events = 0;
75325
+ const rolled = await options.log.rolledMonths(options.target);
75199
75326
  for (let round2 = 0; round2 < (options.maxRounds ?? 5); round2++) {
75200
75327
  const days = await options.log.days();
75201
75328
  const pushed = await options.log.pushed(options.target);
@@ -75208,8 +75335,16 @@ async function pushUsage(options) {
75208
75335
  const byUser = /* @__PURE__ */ new Map();
75209
75336
  for (const event of ofDay)
75210
75337
  byUser.set(event.u, [...byUser.get(event.u) ?? [], event]);
75211
- for (const [user, userEvents] of byUser)
75212
- await options.store.put({ user, day, instance: options.instance }, userEvents);
75338
+ const month = day.slice(0, 7);
75339
+ for (const [user, userEvents] of byUser) {
75340
+ if (rolled.has(month)) {
75341
+ const shard = { user, month, instance: options.instance };
75342
+ const kept = (await options.store.readShard(shard) ?? []).filter((event) => usageDay(event.t) !== day);
75343
+ await options.store.putMonth(shard, [...kept, ...userEvents].sort((a, b) => a.t - b.t));
75344
+ } else {
75345
+ await options.store.put({ user, day, instance: options.instance }, userEvents);
75346
+ }
75347
+ }
75213
75348
  const after = await options.log.daySignature(day);
75214
75349
  if (after === before) {
75215
75350
  await options.log.markPushed(options.target, day, after);
@@ -75226,6 +75361,70 @@ async function pushUsage(options) {
75226
75361
  return { pushedDays: pushedDays.size, events };
75227
75362
  }
75228
75363
 
75364
+ // ../../packages/core/dist/usage/rollup.js
75365
+ async function rollUpMonths(options) {
75366
+ const now = options.now ?? Date.now();
75367
+ const grace = (options.graceDays ?? 3) * 864e5;
75368
+ const currentMonth = usageDay(now).slice(0, 7);
75369
+ const monthEnd = (month) => {
75370
+ const [year, number5] = month.split("-").map(Number);
75371
+ return Date.UTC(year, number5, 1);
75372
+ };
75373
+ const eligible = (month) => month < currentMonth && now >= monthEnd(month) + grace;
75374
+ const pushed = await options.log.pushed(options.target);
75375
+ const blocked = /* @__PURE__ */ new Set();
75376
+ for (const [day, entry] of await options.log.days())
75377
+ if (pushed[day] !== entry.signature)
75378
+ blocked.add(day.slice(0, 7));
75379
+ const groups = /* @__PURE__ */ new Map();
75380
+ for (const shard of await options.store.listOwn(options.instance)) {
75381
+ const month = shard.month ?? shard.day?.slice(0, 7);
75382
+ if (month === void 0)
75383
+ continue;
75384
+ const key2 = `${shard.user}|${month}`;
75385
+ const group = groups.get(key2) ?? { user: shard.user, month, days: [] };
75386
+ if (shard.month !== void 0)
75387
+ group.monthShard = shard;
75388
+ else
75389
+ group.days.push(shard);
75390
+ groups.set(key2, group);
75391
+ }
75392
+ let months = 0;
75393
+ let removed = 0;
75394
+ const problems = [];
75395
+ for (const group of groups.values()) {
75396
+ if (group.monthShard !== void 0)
75397
+ await options.log.markRolled(options.target, group.month);
75398
+ if (group.days.length === 0 || !eligible(group.month) || blocked.has(group.month))
75399
+ continue;
75400
+ const monthShard = { user: group.user, month: group.month, instance: options.instance };
75401
+ const covered = /* @__PURE__ */ new Set();
75402
+ const fromDays = [];
75403
+ for (const shard of group.days) {
75404
+ const events = await options.store.readShard(shard);
75405
+ if (events === void 0)
75406
+ continue;
75407
+ covered.add(shard.day);
75408
+ fromDays.push(...events);
75409
+ }
75410
+ const existing = await options.store.readShard(monthShard) ?? [];
75411
+ const merged = [...existing.filter((event) => !covered.has(usageDay(event.t))), ...fromDays].sort((a, b) => a.t - b.t);
75412
+ await options.store.putMonth(monthShard, merged);
75413
+ const back = await options.store.readShard(monthShard);
75414
+ if (back === void 0 || back.length !== merged.length) {
75415
+ problems.push(`${group.user} ${group.month}: the month read back with ${String(back?.length ?? 0)} of ${String(merged.length)} events, so its days were kept.`);
75416
+ continue;
75417
+ }
75418
+ await options.log.markRolled(options.target, group.month);
75419
+ for (const shard of group.days) {
75420
+ await options.store.removeShard(shard);
75421
+ removed++;
75422
+ }
75423
+ months++;
75424
+ }
75425
+ return { months, removed, problems };
75426
+ }
75427
+
75229
75428
  // ../../packages/core/dist/usage/dashboard.js
75230
75429
  var HOUR = 36e5;
75231
75430
  var DAY = 24 * HOUR;
@@ -76056,7 +76255,6 @@ ${describe5(profile)}` };
76056
76255
  }
76057
76256
 
76058
76257
  // ../../packages/core/dist/usage/directory.js
76059
- var import_node_child_process14 = require("node:child_process");
76060
76258
  var ATTRIBUTE_MAP = [
76061
76259
  ["displayName", "displayName"],
76062
76260
  ["mail", "email"],
@@ -76066,25 +76264,6 @@ var ATTRIBUTE_MAP = [
76066
76264
  ["company", "company"],
76067
76265
  ["sAMAccountName", "account"]
76068
76266
  ];
76069
- function accountPart(name) {
76070
- return name.split("\\").pop() ?? name;
76071
- }
76072
- function entryMatches(entry, name) {
76073
- const wanted = name.toLowerCase();
76074
- const account = accountPart(name).toLowerCase();
76075
- const field2 = (key2) => entry[key2]?.toLowerCase();
76076
- const upn = field2("userPrincipalName");
76077
- return field2("sAMAccountName") === account || upn === wanted || upn !== void 0 && upn.split("@")[0] === account || field2("mail") === wanted || field2("displayName") === wanted;
76078
- }
76079
- function personFromEntry(entry) {
76080
- const person = {};
76081
- for (const [from, to] of ATTRIBUTE_MAP) {
76082
- const value = entry[from]?.trim();
76083
- if (value !== void 0 && value.length > 0)
76084
- person[to] = value.slice(0, 200);
76085
- }
76086
- return person;
76087
- }
76088
76267
  function profileFromPerson(person) {
76089
76268
  return {
76090
76269
  ...person.displayName !== void 0 ? { displayName: person.displayName } : {},
@@ -76095,107 +76274,29 @@ function profileFromPerson(person) {
76095
76274
  source: "company directory"
76096
76275
  };
76097
76276
  }
76098
- var DIRECTORY_SCRIPT = String.raw`
76099
- $ErrorActionPreference = 'Stop'
76100
- $names = @(([Console]::In.ReadToEnd() | ConvertFrom-Json).names)
76101
- function Esc([string]$s) { return $s.Replace('\', '\5c').Replace('*', '\2a').Replace('(', '\28').Replace(')', '\29').Replace([string][char]0, '\00') }
76102
- $attrs = @('sAMAccountName', 'userPrincipalName', 'mail', 'displayName', 'department', 'title', 'physicalDeliveryOfficeName', 'company')
76103
- try {
76104
- $entries = New-Object System.Collections.ArrayList
76105
- for ($i = 0; $i -lt $names.Count; $i += 20) {
76106
- $last = [Math]::Min($i + 19, $names.Count - 1)
76107
- $clauses = ''
76108
- foreach ($n in $names[$i..$last]) {
76109
- $account = Esc (($n -split '\\')[-1])
76110
- $whole = Esc $n
76111
- $clauses += "(sAMAccountName=$account)(userPrincipalName=$whole)(mail=$whole)(displayName=$whole)"
76112
- }
76113
- $searcher = New-Object System.DirectoryServices.DirectorySearcher
76114
- $searcher.Filter = "(&(objectCategory=person)(objectClass=user)(|$clauses))"
76115
- $searcher.SizeLimit = 200
76116
- $searcher.ClientTimeout = [TimeSpan]::FromSeconds(15)
76117
- $searcher.ReferralChasing = [System.DirectoryServices.ReferralChasingOption]::None
76118
- foreach ($a in $attrs) { [void]$searcher.PropertiesToLoad.Add($a) }
76119
- foreach ($r in $searcher.FindAll()) {
76120
- $e = @{}
76121
- foreach ($a in $attrs) {
76122
- $v = $r.Properties[$a]
76123
- if ($v -ne $null -and $v.Count -gt 0) { $e[$a] = [string]$v[0] }
76124
- }
76125
- [void]$entries.Add($e)
76126
- }
76127
- }
76128
- $out = @{ ok = $true; available = $true; entries = @($entries) }
76129
- } catch {
76130
- $out = @{ ok = $true; available = $false; reason = $_.Exception.Message.Trim() }
76131
- }
76132
- 'LCJSON:' + ($out | ConvertTo-Json -Depth 5 -Compress)
76133
- `;
76134
- var runWindowsPowerShell = (script, stdin) => new Promise((resolve, reject2) => {
76135
- const encoded = Buffer.from(script, "utf16le").toString("base64");
76136
- const child = (0, import_node_child_process14.spawn)("powershell.exe", ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-EncodedCommand", encoded], { windowsHide: true });
76137
- let out = "";
76138
- let err = "";
76139
- const timer = setTimeout(() => {
76140
- child.kill();
76141
- reject2(new Error("The directory lookup took longer than a minute."));
76142
- }, 6e4);
76143
- child.stdout.setEncoding("utf8").on("data", (chunk) => out += chunk);
76144
- child.stderr.setEncoding("utf8").on("data", (chunk) => err += chunk);
76145
- child.on("error", (error51) => {
76146
- clearTimeout(timer);
76147
- reject2(error51);
76148
- });
76149
- child.on("close", () => {
76150
- clearTimeout(timer);
76151
- resolve(out.length > 0 ? out : err);
76152
- });
76153
- child.stdin.end(stdin);
76154
- });
76155
- function fromEntries(names, entries) {
76156
- const people = {};
76157
- const notFound = [];
76158
- for (const name of names) {
76159
- const entry = entries.find((candidate) => entryMatches(candidate, name));
76160
- if (entry === void 0)
76161
- notFound.push(name);
76162
- else
76163
- people[name] = personFromEntry(entry);
76164
- }
76165
- return { people, notFound };
76166
- }
76167
76277
  async function lookupDirectory(names, options = {}) {
76168
76278
  const wanted = [...new Set(names.map((name) => name.trim()).filter((name) => name.length > 0 && name.length <= 200))].slice(0, 500);
76169
76279
  if ((options.platform ?? process.platform) !== "win32")
76170
76280
  return { available: false, reason: "The company directory is read through Windows; this is not Windows.", via: "none" };
76281
+ if (options.helper === void 0) {
76282
+ return { available: false, reason: "The company directory is read through the Rust helper, and none is available here.", via: "none" };
76283
+ }
76171
76284
  if (wanted.length === 0)
76172
- return { available: true, people: {}, notFound: [], via: options.helper !== void 0 ? "rust" : "powershell" };
76173
- if (options.helper !== void 0) {
76174
- const answer = await options.helper({ op: "directory", names: wanted });
76175
- if (answer["ok"] === true) {
76176
- if (answer["available"] !== true)
76177
- return { available: false, reason: String(answer["reason"] ?? "The directory could not be reached."), via: "rust" };
76178
- const people = {};
76179
- for (const [name, value] of Object.entries(answer["people"] ?? {})) {
76180
- const person = {};
76181
- for (const [, field2] of ATTRIBUTE_MAP)
76182
- if (typeof value[field2] === "string")
76183
- person[field2] = value[field2];
76184
- people[name] = person;
76185
- }
76186
- return { available: true, people, notFound: answer["notFound"] ?? [], via: "rust" };
76187
- }
76188
- }
76189
- const run3 = options.runPowerShell ?? runWindowsPowerShell;
76190
- const output = await run3(DIRECTORY_SCRIPT, JSON.stringify({ names: wanted }));
76191
- const line = output.split(/\r?\n/).find((each) => each.startsWith("LCJSON:"));
76192
- if (line === void 0)
76193
- return { available: false, reason: `The directory lookup gave no answer${output.trim().length > 0 ? `: ${output.trim().slice(0, 200)}` : "."}`, via: "powershell" };
76194
- const parsed = JSON.parse(line.slice("LCJSON:".length));
76195
- if (parsed.available !== true)
76196
- return { available: false, reason: parsed.reason ?? "The directory could not be reached.", via: "powershell" };
76197
- const entries = Array.isArray(parsed.entries) ? parsed.entries : parsed.entries !== void 0 ? [parsed.entries] : [];
76198
- return { available: true, ...fromEntries(wanted, entries), via: "powershell" };
76285
+ return { available: true, people: {}, notFound: [], via: "rust" };
76286
+ const answer = await options.helper({ op: "directory", names: wanted });
76287
+ if (answer["ok"] !== true)
76288
+ return { available: false, reason: String(answer["error"] ?? "The Rust helper has no directory lookup."), via: "rust" };
76289
+ if (answer["available"] !== true)
76290
+ return { available: false, reason: String(answer["reason"] ?? "The directory could not be reached."), via: "rust" };
76291
+ const people = {};
76292
+ for (const [name, value] of Object.entries(answer["people"] ?? {})) {
76293
+ const person = {};
76294
+ for (const [, field2] of ATTRIBUTE_MAP)
76295
+ if (typeof value[field2] === "string")
76296
+ person[field2] = value[field2];
76297
+ people[name] = person;
76298
+ }
76299
+ return { available: true, people, notFound: answer["notFound"] ?? [], via: "rust" };
76199
76300
  }
76200
76301
 
76201
76302
  // ../../packages/core/dist/host/bridge.js
@@ -76443,6 +76544,7 @@ ${preview.text}` } : {}
76443
76544
  let cachedUsageChoice;
76444
76545
  let usageKicked = false;
76445
76546
  let usageRechecked = false;
76547
+ let usageLastRollUp = 0;
76446
76548
  let cachedProfileFresh;
76447
76549
  let directoryChecked = false;
76448
76550
  let lastToolNames;
@@ -79186,7 +79288,7 @@ ${direction}` : attachMentions(text, mentions);
79186
79288
  if (typeof fromHub === "string")
79187
79289
  throw new Error(fromHub);
79188
79290
  const git = (args) => new Promise((resolve) => {
79189
- const child = (0, import_node_child_process15.spawn)("git", ["--no-optional-locks", "-C", root, ...args], {
79291
+ const child = (0, import_node_child_process14.spawn)("git", ["--no-optional-locks", "-C", root, ...args], {
79190
79292
  env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
79191
79293
  windowsHide: true
79192
79294
  });
@@ -81296,7 +81398,7 @@ ${redact(shown2, cachedSecretValues)}` }
81296
81398
  return withoutRipgrep();
81297
81399
  try {
81298
81400
  const listed = await new Promise((resolve, reject2) => {
81299
- const child = (0, import_node_child_process15.spawn)(ripgrepPath, ["--files", "--hidden", "--glob", "!.git"], {
81401
+ const child = (0, import_node_child_process14.spawn)(ripgrepPath, ["--files", "--hidden", "--glob", "!.git"], {
81300
81402
  cwd: workspaceRoot
81301
81403
  });
81302
81404
  let out = "";
@@ -81788,7 +81890,7 @@ ${redact(shown2, cachedSecretValues)}` }
81788
81890
  if (relative.startsWith("..") || import_node_path46.default.isAbsolute(relative))
81789
81891
  return found2;
81790
81892
  const output = await new Promise((resolve) => {
81791
- const child = (0, import_node_child_process15.spawn)("git", ["-c", "core.quotePath=false", "log", "--diff-filter=A", "--relative", "--format=@@%an", "--name-only", "--", relative.length > 0 ? relative : "."], {
81893
+ const child = (0, import_node_child_process14.spawn)("git", ["-c", "core.quotePath=false", "log", "--diff-filter=A", "--relative", "--format=@@%an", "--name-only", "--", relative.length > 0 ? relative : "."], {
81792
81894
  cwd: root,
81793
81895
  windowsHide: true
81794
81896
  });
@@ -82424,8 +82526,16 @@ ${redact(shown2, cachedSecretValues)}` }
82424
82526
  ...usageRechecked ? {} : { recheck: [usageDay(Date.now()), usageDay(Date.now() - 864e5)] }
82425
82527
  });
82426
82528
  usageRechecked = true;
82529
+ if (Date.now() - usageLastRollUp > 864e5) {
82530
+ usageLastRollUp = Date.now();
82531
+ const rolled = await rollUpMonths({ log: usageLog, store: resolved.store, target: resolved.target, instance: usageInstance });
82532
+ for (const problem of rolled.problems)
82533
+ logger.warn(`usage: roll-up: ${problem}`);
82534
+ if (rolled.months > 0)
82535
+ logger.info(`usage: rolled up ${String(rolled.months)} month(s), removing ${String(rolled.removed)} day files`);
82536
+ }
82427
82537
  usageLastProblem = void 0;
82428
- void enrichFromDirectory(namesToEnrich(await usageLog.all()));
82538
+ void enrichFromDirectory([]);
82429
82539
  await usageLog.prune(resolved.target, 14);
82430
82540
  } catch (error51) {
82431
82541
  usageLastProblem = `Could not write to ${resolved.store.label}: ${error51 instanceof Error ? error51.message : String(error51)}`;
@@ -84397,7 +84507,8 @@ ${redact(shown2, cachedSecretValues)}` }
84397
84507
  reportFailure("handleClearAssessment", handleClearAssessment(message4.model, message4.profileLabel));
84398
84508
  } else if (message4.type === "restartScheduler") {
84399
84509
  restartScheduleTimer();
84400
- logger.info("schedule timer restarted by the user");
84510
+ if (services.runsSchedules !== false)
84511
+ logger.info("schedule timer restarted by the user");
84401
84512
  reportFailure("postSchedules", postSchedules());
84402
84513
  } else if (message4.type === "deleteScheduleRun") {
84403
84514
  reportFailure("handleDeleteScheduleRun", handleDeleteScheduleRun(message4.id, message4.at));
@@ -84802,7 +84913,8 @@ ${contents}
84802
84913
  ...runningScheduleId !== void 0 ? { runningId: runningScheduleId } : {},
84803
84914
  scheduler: {
84804
84915
  running: scheduleTimer !== void 0,
84805
- ...lastScheduleTickAt === void 0 ? {} : { lastTickAt: lastScheduleTickAt }
84916
+ ...lastScheduleTickAt === void 0 ? {} : { lastTickAt: lastScheduleTickAt },
84917
+ ...services.runsSchedules === false ? { elsewhere: true } : {}
84806
84918
  }
84807
84919
  });
84808
84920
  }
@@ -85082,6 +85194,8 @@ ${contents}
85082
85194
  return "";
85083
85195
  }
85084
85196
  function restartScheduleTimer() {
85197
+ if (services.runsSchedules === false)
85198
+ return;
85085
85199
  if (scheduleTimer !== void 0) {
85086
85200
  clearInterval(scheduleTimer);
85087
85201
  scheduleTimer = void 0;
@@ -85633,7 +85747,7 @@ function searchPath(command, env2) {
85633
85747
  }
85634
85748
 
85635
85749
  // ../../packages/core/dist/lsp/client.js
85636
- var import_node_child_process16 = require("node:child_process");
85750
+ var import_node_child_process15 = require("node:child_process");
85637
85751
  var import_node_url = require("node:url");
85638
85752
  function keyFor(uri) {
85639
85753
  try {
@@ -85663,7 +85777,7 @@ var LspClient = class {
85663
85777
  this.root = root;
85664
85778
  this.log = log;
85665
85779
  const shim = /\.(cmd|bat)$/i.test(executable);
85666
- this.child = shim ? (0, import_node_child_process16.spawn)(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", `"${executable}"`, ...args], { cwd: root, windowsHide: true, windowsVerbatimArguments: true }) : (0, import_node_child_process16.spawn)(executable, args, { cwd: root, windowsHide: true });
85780
+ this.child = shim ? (0, import_node_child_process15.spawn)(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", `"${executable}"`, ...args], { cwd: root, windowsHide: true, windowsVerbatimArguments: true }) : (0, import_node_child_process15.spawn)(executable, args, { cwd: root, windowsHide: true });
85667
85781
  this.child.stdout?.on("data", (chunk) => this.onData(chunk));
85668
85782
  this.child.stderr?.on("data", (chunk) => {
85669
85783
  const text = chunk.toString("utf8").trim();
@@ -87535,10 +87649,13 @@ Node. It runs once per install.
87535
87649
 
87536
87650
  **People instead of login names.** On a Windows machine on a company domain, names come from the
87537
87651
  **company directory** first - display name, email, department (shown as the team), title and office -
87538
- read in the background as you (Windows' own sign-in, nothing to configure), for you, every author named
87539
- on a skill or tool, and every colleague in the numbers. With Fire Code installed its Rust helper reads the
87540
- directory; otherwise a fixed PowerShell script does. Only searches, only those fields, only while usage is
87541
- collected; answers are kept for 30 days. Off a domain, or for someone the directory does not list, the
87652
+ read as you (Windows' own sign-in, nothing to configure). In the background only **you** are looked up;
87653
+ every author named on a skill or tool and every colleague in the numbers are looked up when the dashboard
87654
+ is opened. The Rust helper reads the directory through Windows' own LDAP client - Fire Code's, or the one
87655
+ the Windows VS Code package carries. **PowerShell is never used for it**: that way raised a security alert
87656
+ on a managed machine. With no helper (a plain Node host without Fire Code, or not Windows) the directory
87657
+ is simply not used. Only searches, only those fields, only while usage is collected; answers are kept for
87658
+ 30 days. Off a domain, or for someone the directory does not list, the
87542
87659
  **second way** is used: if a tool that looks users up is available - an MCP or Python tool named like
87543
87660
  \`whoami\`, \`user_info\` or \`employee_lookup\`, the one named in the panel, or failing those a
87544
87661
  **skill** named like \`who-am-i\` or \`user-info\` that describes how - the assistant does it once
@@ -87581,8 +87698,13 @@ own user.
87581
87698
 
87582
87699
  **In a shared folder the statistics are plain files**: one JSON Lines file per person, per day, per
87583
87700
  install (\`<folder>\\<user>\\2026-10-10__<install>.jsonl\`, one event per line) and one small JSON file
87584
- per person in \`_profiles\`. No database and no locks: each file is written whole and swapped in,
87585
- so readers never see half of one, and nothing is ever deleted.
87701
+ per person in \`_profiles\`. No database and no locks: each file is written whole and swapped in, so
87702
+ readers never see half of one. **Each month is rolled up**: three days after a month ends, each machine
87703
+ merges its own day files for it into one month file (\`2026-09__<install>.jsonl\`), reads it back to
87704
+ check every event is there, and only then deletes those day files - so a year is about a dozen files per
87705
+ person and machine rather than a few hundred. Only a machine's own files are ever merged or deleted. In a
87706
+ bucket the layout is the same under \`usage/\`; in OpenSearch, Qdrant or Chroma each file is one document
87707
+ (its text the events, its vector a placeholder - nothing is searched by meaning there).
87586
87708
 
87587
87709
  **What is collected**: the skill or tool name, who, when, the project, the author named on the skill or
87588
87710
  tool, whether a tool call failed and how long it took. Never arguments, file contents or results. A
@@ -87639,10 +87761,13 @@ delete those from Settings \u2192 Skills or Python.
87639
87761
  "move files",
87640
87762
  "zip",
87641
87763
  "vs code rust",
87642
- "tools in vs code"
87764
+ "tools in vs code",
87765
+ "bundled helper",
87766
+ "without fire code"
87643
87767
  ],
87644
87768
  body: `
87645
- Fire Code ships a Rust helper (\`fire-fs.exe\`) that runs file and data work on every CPU core. Its tools:
87769
+ A Rust helper (\`fire-fs.exe\`) runs file and data work on every CPU core. Fire Code ships the full one;
87770
+ the Windows VS Code package carries a slim one with every tool below except \`dataframe\`. Its tools:
87646
87771
 
87647
87772
  - \`find_files\` - find files by name, type, size or date across drives and shares; summarise a folder; find
87648
87773
  duplicate files by content.
@@ -87662,11 +87787,13 @@ Fire Code ships a Rust helper (\`fire-fs.exe\`) that runs file and data work on
87662
87787
 
87663
87788
  **Where they are available**
87664
87789
  - **Fire Code**: always.
87665
- - **VS Code (and \`light-code\` run on its own)**: when Fire Code is installed on the same machine. The
87666
- extension finds Fire Code's helper by itself - nothing to configure - and offers the tools that helper
87667
- has (an older Fire Code offers fewer). Reload the VS Code window after installing or updating Fire Code.
87668
- - **Not**: without Fire Code installed, on a shared server (\`--server\`), or on a platform other than
87669
- Windows. There the built-in tools (read_file, search_files, list_files) do the work.
87790
+ - **VS Code on Windows**: always - every tool but \`dataframe\`, from the helper bundled with the
87791
+ extension. With Fire Code installed on the same machine, its full helper is used instead and
87792
+ \`dataframe\` is there too. Nothing to configure; reload the VS Code window after installing or
87793
+ updating Fire Code.
87794
+ - **\`light-code\` run on its own (Node host)**: when Fire Code is installed on the same machine.
87795
+ - **Not**: on a shared server (\`--server\`), on a platform other than Windows, or in the Node host
87796
+ without Fire Code. There the built-in tools (read_file, search_files, list_files) do the work.
87670
87797
 
87671
87798
  To see whether they are on right now, look at the tool list in Settings \u2192 Tools, or ask "which tools do
87672
87799
  you have?" - the assistant answers from the tools it was actually given.
@@ -88868,7 +88995,7 @@ function createLightCodeHelpTool() {
88868
88995
  }
88869
88996
 
88870
88997
  // ../../packages/core/dist/tools/listFiles.js
88871
- var import_node_child_process17 = require("node:child_process");
88998
+ var import_node_child_process16 = require("node:child_process");
88872
88999
  var import_node_path49 = __toESM(require("node:path"), 1);
88873
89000
 
88874
89001
  // ../../packages/core/dist/tools/ripgrepError.js
@@ -88902,7 +89029,7 @@ function isRipgrepNoMatchError(error51) {
88902
89029
  }
88903
89030
  function runRipgrepFiles(rgPath, dir, signal, includeIgnored) {
88904
89031
  return new Promise((resolve, reject2) => {
88905
- (0, import_node_child_process17.execFile)(rgPath, [
89032
+ (0, import_node_child_process16.execFile)(rgPath, [
88906
89033
  "--files",
88907
89034
  "--hidden",
88908
89035
  ...includeIgnored ? ["--no-ignore-vcs"] : [],
@@ -89111,7 +89238,7 @@ var readDocumentTool = {
89111
89238
  };
89112
89239
 
89113
89240
  // ../../packages/core/dist/tools/searchFiles.js
89114
- var import_node_child_process18 = require("node:child_process");
89241
+ var import_node_child_process17 = require("node:child_process");
89115
89242
  var paramsSchema22 = external_exports.object({
89116
89243
  path: external_exports.string().min(1).default(".").describe("Directory to search, relative to the workspace root."),
89117
89244
  pattern: external_exports.string().min(1).describe("Regular expression to search for."),
@@ -89130,7 +89257,7 @@ function runRipgrepSearch(rgPath, dir, pattern, filePattern, signal, includeIgno
89130
89257
  args.push("-g", filePattern);
89131
89258
  args.push("--regexp", pattern, ".");
89132
89259
  return new Promise((resolve, reject2) => {
89133
- (0, import_node_child_process18.execFile)(rgPath, args, { cwd: dir, signal, maxBuffer: 10 * 1024 * 1024 }, (error51, stdout) => {
89260
+ (0, import_node_child_process17.execFile)(rgPath, args, { cwd: dir, signal, maxBuffer: 10 * 1024 * 1024 }, (error51, stdout) => {
89134
89261
  if (error51 && !isRipgrepNoMatchError2(error51)) {
89135
89262
  reject2(error51);
89136
89263
  return;
@@ -91236,7 +91363,7 @@ var import_promises31 = __toESM(require("node:fs/promises"), 1);
91236
91363
  var import_node_path56 = __toESM(require("node:path"), 1);
91237
91364
 
91238
91365
  // src/credentialTool.ts
91239
- var import_node_child_process19 = require("node:child_process");
91366
+ var import_node_child_process18 = require("node:child_process");
91240
91367
  var import_node_path55 = __toESM(require("node:path"), 1);
91241
91368
  var CREDENTIAL_PREFIX2 = "tool:";
91242
91369
  var WRAPPER = [
@@ -91257,7 +91384,7 @@ async function fetchCredential(options, reference) {
91257
91384
  if (name.length === 0) return { problem: "A credential reference needs a name: tool:<name>." };
91258
91385
  const budget = options.timeoutMs ?? 3e4;
91259
91386
  const run3 = await new Promise((resolve) => {
91260
- const child = (0, import_node_child_process19.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path55.default.resolve(options.file), name], {
91387
+ const child = (0, import_node_child_process18.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path55.default.resolve(options.file), name], {
91261
91388
  windowsHide: true,
91262
91389
  // The environment this was started in, as with the identity function: the libraries that
91263
91390
  // hold credentials are configured through it, and nothing here is model-authored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chosengeneration/light-code",
3
- "version": "0.132.0",
3
+ "version": "0.134.0",
4
4
  "description": "A minimal agentic coding assistant, served to your browser from a local Node server",
5
5
  "license": "MIT",
6
6
  "type": "module",