@kl-c/matrixos 0.3.48 → 0.3.50

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.
@@ -2163,7 +2163,7 @@ var package_default;
2163
2163
  var init_package = __esm(() => {
2164
2164
  package_default = {
2165
2165
  name: "@kl-c/matrixos",
2166
- version: "0.3.48",
2166
+ version: "0.3.50",
2167
2167
  description: "MaTrixOS \u2014 Agentic OS for OpenCode. Personalizable, communicating, self-improving, resilient.",
2168
2168
  main: "./dist/index.js",
2169
2169
  types: "dist/index.d.ts",
@@ -164788,15 +164788,35 @@ var require_picomatch2 = __commonJS((exports2, module2) => {
164788
164788
  });
164789
164789
 
164790
164790
  // packages/omo-opencode/src/features/cron/store.ts
164791
+ import { Database as Database2 } from "bun:sqlite";
164792
+ import { homedir as homedir22 } from "os";
164793
+ import { resolve as resolve12 } from "path";
164794
+ function openDb() {
164795
+ const db = new Database2(DB_PATH);
164796
+ db.run(`CREATE TABLE IF NOT EXISTS matrixos_cron (
164797
+ id TEXT PRIMARY KEY,
164798
+ name TEXT NOT NULL,
164799
+ schedule TEXT NOT NULL,
164800
+ command TEXT NOT NULL,
164801
+ channel TEXT,
164802
+ recipient TEXT,
164803
+ enabled INTEGER NOT NULL DEFAULT 1,
164804
+ created_at TEXT NOT NULL,
164805
+ updated_at TEXT NOT NULL
164806
+ )`);
164807
+ return db;
164808
+ }
164809
+ function nextId() {
164810
+ counter += 1;
164811
+ return `cron-${Date.now()}-${counter}`;
164812
+ }
164791
164813
  function createCronStore() {
164792
- const jobs = new Map;
164793
- let counter = 0;
164814
+ const db = openDb();
164794
164815
  return {
164795
164816
  add(input) {
164796
- counter += 1;
164797
164817
  const now = new Date().toISOString();
164798
164818
  const job = {
164799
- id: `cron-${counter}`,
164819
+ id: nextId(),
164800
164820
  name: input.name,
164801
164821
  schedule: input.schedule,
164802
164822
  command: input.command,
@@ -164807,15 +164827,17 @@ function createCronStore() {
164807
164827
  updatedAt: now
164808
164828
  };
164809
164829
  CronJobSchema.parse(job);
164810
- jobs.set(job.id, job);
164830
+ db.query(`INSERT INTO matrixos_cron (id, name, schedule, command, channel, recipient, enabled, created_at, updated_at)
164831
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(job.id, job.name, job.schedule, job.command, job.channel ?? null, job.recipient ?? null, job.enabled ? 1 : 0, job.createdAt, job.updatedAt);
164811
164832
  return job;
164812
164833
  },
164813
164834
  get(id) {
164814
- return jobs.get(id);
164835
+ const row = db.query("SELECT * FROM matrixos_cron WHERE id = ?").get(id);
164836
+ return row ? rowToJob(row) : undefined;
164815
164837
  },
164816
164838
  list(filter) {
164817
- const all = Array.from(jobs.values());
164818
- return all.filter((j) => {
164839
+ const all = db.query("SELECT * FROM matrixos_cron ORDER BY created_at DESC").all();
164840
+ return all.map(rowToJob).filter((j) => {
164819
164841
  if (filter?.enabled !== undefined && j.enabled !== filter.enabled)
164820
164842
  return false;
164821
164843
  if (filter?.channel && j.channel !== filter.channel)
@@ -164824,14 +164846,29 @@ function createCronStore() {
164824
164846
  });
164825
164847
  },
164826
164848
  remove(id) {
164827
- return jobs.delete(id);
164849
+ const res = db.query("DELETE FROM matrixos_cron WHERE id = ?").run(id);
164850
+ return res.changes > 0;
164828
164851
  },
164829
164852
  size() {
164830
- return jobs.size;
164853
+ const row = db.query("SELECT COUNT(*) as c FROM matrixos_cron").get();
164854
+ return row.c;
164831
164855
  }
164832
164856
  };
164833
164857
  }
164834
- var CronJobSchema;
164858
+ function rowToJob(row) {
164859
+ return {
164860
+ id: String(row.id),
164861
+ name: String(row.name),
164862
+ schedule: String(row.schedule),
164863
+ command: String(row.command),
164864
+ channel: row.channel ? row.channel : undefined,
164865
+ recipient: row.recipient ? String(row.recipient) : undefined,
164866
+ enabled: Number(row.enabled) === 1,
164867
+ createdAt: String(row.created_at),
164868
+ updatedAt: String(row.updated_at)
164869
+ };
164870
+ }
164871
+ var CronJobSchema, DB_PATH, counter = 0;
164835
164872
  var init_store = __esm(() => {
164836
164873
  init_zod();
164837
164874
  CronJobSchema = object({
@@ -164845,6 +164882,1125 @@ var init_store = __esm(() => {
164845
164882
  createdAt: string2(),
164846
164883
  updatedAt: string2()
164847
164884
  }).strict();
164885
+ DB_PATH = resolve12(homedir22(), ".local", "share", "opencode", "opencode.db");
164886
+ });
164887
+
164888
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/task.js
164889
+ var require_task = __commonJS((exports2, module2) => {
164890
+ var EventEmitter = __require("events");
164891
+
164892
+ class Task extends EventEmitter {
164893
+ constructor(execution) {
164894
+ super();
164895
+ if (typeof execution !== "function") {
164896
+ throw "execution must be a function";
164897
+ }
164898
+ this._execution = execution;
164899
+ }
164900
+ execute(now) {
164901
+ let exec2;
164902
+ try {
164903
+ exec2 = this._execution(now);
164904
+ } catch (error51) {
164905
+ return this.emit("task-failed", error51);
164906
+ }
164907
+ if (exec2 instanceof Promise) {
164908
+ return exec2.then(() => this.emit("task-finished")).catch((error51) => this.emit("task-failed", error51));
164909
+ } else {
164910
+ this.emit("task-finished");
164911
+ return exec2;
164912
+ }
164913
+ }
164914
+ }
164915
+ module2.exports = Task;
164916
+ });
164917
+
164918
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/month-names-conversion.js
164919
+ var require_month_names_conversion = __commonJS((exports2, module2) => {
164920
+ module2.exports = (() => {
164921
+ const months = [
164922
+ "january",
164923
+ "february",
164924
+ "march",
164925
+ "april",
164926
+ "may",
164927
+ "june",
164928
+ "july",
164929
+ "august",
164930
+ "september",
164931
+ "october",
164932
+ "november",
164933
+ "december"
164934
+ ];
164935
+ const shortMonths = [
164936
+ "jan",
164937
+ "feb",
164938
+ "mar",
164939
+ "apr",
164940
+ "may",
164941
+ "jun",
164942
+ "jul",
164943
+ "aug",
164944
+ "sep",
164945
+ "oct",
164946
+ "nov",
164947
+ "dec"
164948
+ ];
164949
+ function convertMonthName(expression, items) {
164950
+ for (let i3 = 0;i3 < items.length; i3++) {
164951
+ expression = expression.replace(new RegExp(items[i3], "gi"), parseInt(i3, 10) + 1);
164952
+ }
164953
+ return expression;
164954
+ }
164955
+ function interprete(monthExpression) {
164956
+ monthExpression = convertMonthName(monthExpression, months);
164957
+ monthExpression = convertMonthName(monthExpression, shortMonths);
164958
+ return monthExpression;
164959
+ }
164960
+ return interprete;
164961
+ })();
164962
+ });
164963
+
164964
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/week-day-names-conversion.js
164965
+ var require_week_day_names_conversion = __commonJS((exports2, module2) => {
164966
+ module2.exports = (() => {
164967
+ const weekDays = [
164968
+ "sunday",
164969
+ "monday",
164970
+ "tuesday",
164971
+ "wednesday",
164972
+ "thursday",
164973
+ "friday",
164974
+ "saturday"
164975
+ ];
164976
+ const shortWeekDays = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
164977
+ function convertWeekDayName(expression, items) {
164978
+ for (let i3 = 0;i3 < items.length; i3++) {
164979
+ expression = expression.replace(new RegExp(items[i3], "gi"), parseInt(i3, 10));
164980
+ }
164981
+ return expression;
164982
+ }
164983
+ function convertWeekDays(expression) {
164984
+ expression = expression.replace("7", "0");
164985
+ expression = convertWeekDayName(expression, weekDays);
164986
+ return convertWeekDayName(expression, shortWeekDays);
164987
+ }
164988
+ return convertWeekDays;
164989
+ })();
164990
+ });
164991
+
164992
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/asterisk-to-range-conversion.js
164993
+ var require_asterisk_to_range_conversion = __commonJS((exports2, module2) => {
164994
+ module2.exports = (() => {
164995
+ function convertAsterisk(expression, replecement) {
164996
+ if (expression.indexOf("*") !== -1) {
164997
+ return expression.replace("*", replecement);
164998
+ }
164999
+ return expression;
165000
+ }
165001
+ function convertAsterisksToRanges(expressions) {
165002
+ expressions[0] = convertAsterisk(expressions[0], "0-59");
165003
+ expressions[1] = convertAsterisk(expressions[1], "0-59");
165004
+ expressions[2] = convertAsterisk(expressions[2], "0-23");
165005
+ expressions[3] = convertAsterisk(expressions[3], "1-31");
165006
+ expressions[4] = convertAsterisk(expressions[4], "1-12");
165007
+ expressions[5] = convertAsterisk(expressions[5], "0-6");
165008
+ return expressions;
165009
+ }
165010
+ return convertAsterisksToRanges;
165011
+ })();
165012
+ });
165013
+
165014
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/range-conversion.js
165015
+ var require_range_conversion = __commonJS((exports2, module2) => {
165016
+ module2.exports = (() => {
165017
+ function replaceWithRange(expression, text, init, end) {
165018
+ const numbers = [];
165019
+ let last = parseInt(end);
165020
+ let first = parseInt(init);
165021
+ if (first > last) {
165022
+ last = parseInt(init);
165023
+ first = parseInt(end);
165024
+ }
165025
+ for (let i3 = first;i3 <= last; i3++) {
165026
+ numbers.push(i3);
165027
+ }
165028
+ return expression.replace(new RegExp(text, "i"), numbers.join());
165029
+ }
165030
+ function convertRange(expression) {
165031
+ const rangeRegEx = /(\d+)-(\d+)/;
165032
+ let match = rangeRegEx.exec(expression);
165033
+ while (match !== null && match.length > 0) {
165034
+ expression = replaceWithRange(expression, match[0], match[1], match[2]);
165035
+ match = rangeRegEx.exec(expression);
165036
+ }
165037
+ return expression;
165038
+ }
165039
+ function convertAllRanges(expressions) {
165040
+ for (let i3 = 0;i3 < expressions.length; i3++) {
165041
+ expressions[i3] = convertRange(expressions[i3]);
165042
+ }
165043
+ return expressions;
165044
+ }
165045
+ return convertAllRanges;
165046
+ })();
165047
+ });
165048
+
165049
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/step-values-conversion.js
165050
+ var require_step_values_conversion = __commonJS((exports2, module2) => {
165051
+ module2.exports = (() => {
165052
+ function convertSteps(expressions) {
165053
+ var stepValuePattern = /^(.+)\/(\w+)$/;
165054
+ for (var i3 = 0;i3 < expressions.length; i3++) {
165055
+ var match = stepValuePattern.exec(expressions[i3]);
165056
+ var isStepValue = match !== null && match.length > 0;
165057
+ if (isStepValue) {
165058
+ var baseDivider = match[2];
165059
+ if (isNaN(baseDivider)) {
165060
+ throw baseDivider + " is not a valid step value";
165061
+ }
165062
+ var values = match[1].split(",");
165063
+ var stepValues = [];
165064
+ var divider = parseInt(baseDivider, 10);
165065
+ for (var j = 0;j <= values.length; j++) {
165066
+ var value = parseInt(values[j], 10);
165067
+ if (value % divider === 0) {
165068
+ stepValues.push(value);
165069
+ }
165070
+ }
165071
+ expressions[i3] = stepValues.join(",");
165072
+ }
165073
+ }
165074
+ return expressions;
165075
+ }
165076
+ return convertSteps;
165077
+ })();
165078
+ });
165079
+
165080
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/index.js
165081
+ var require_convert_expression = __commonJS((exports2, module2) => {
165082
+ var monthNamesConversion = require_month_names_conversion();
165083
+ var weekDayNamesConversion = require_week_day_names_conversion();
165084
+ var convertAsterisksToRanges = require_asterisk_to_range_conversion();
165085
+ var convertRanges = require_range_conversion();
165086
+ var convertSteps = require_step_values_conversion();
165087
+ module2.exports = (() => {
165088
+ function appendSeccondExpression(expressions) {
165089
+ if (expressions.length === 5) {
165090
+ return ["0"].concat(expressions);
165091
+ }
165092
+ return expressions;
165093
+ }
165094
+ function removeSpaces(str3) {
165095
+ return str3.replace(/\s{2,}/g, " ").trim();
165096
+ }
165097
+ function normalizeIntegers(expressions) {
165098
+ for (let i3 = 0;i3 < expressions.length; i3++) {
165099
+ const numbers = expressions[i3].split(",");
165100
+ for (let j = 0;j < numbers.length; j++) {
165101
+ numbers[j] = parseInt(numbers[j]);
165102
+ }
165103
+ expressions[i3] = numbers;
165104
+ }
165105
+ return expressions;
165106
+ }
165107
+ function interprete(expression) {
165108
+ let expressions = removeSpaces(expression).split(" ");
165109
+ expressions = appendSeccondExpression(expressions);
165110
+ expressions[4] = monthNamesConversion(expressions[4]);
165111
+ expressions[5] = weekDayNamesConversion(expressions[5]);
165112
+ expressions = convertAsterisksToRanges(expressions);
165113
+ expressions = convertRanges(expressions);
165114
+ expressions = convertSteps(expressions);
165115
+ expressions = normalizeIntegers(expressions);
165116
+ return expressions.join(" ");
165117
+ }
165118
+ return interprete;
165119
+ })();
165120
+ });
165121
+
165122
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/pattern-validation.js
165123
+ var require_pattern_validation = __commonJS((exports2, module2) => {
165124
+ var convertExpression = require_convert_expression();
165125
+ var validationRegex = /^(?:\d+|\*|\*\/\d+)$/;
165126
+ function isValidExpression(expression, min2, max2) {
165127
+ const options = expression.split(",");
165128
+ for (const option of options) {
165129
+ const optionAsInt = parseInt(option, 10);
165130
+ if (!Number.isNaN(optionAsInt) && (optionAsInt < min2 || optionAsInt > max2) || !validationRegex.test(option))
165131
+ return false;
165132
+ }
165133
+ return true;
165134
+ }
165135
+ function isInvalidSecond(expression) {
165136
+ return !isValidExpression(expression, 0, 59);
165137
+ }
165138
+ function isInvalidMinute(expression) {
165139
+ return !isValidExpression(expression, 0, 59);
165140
+ }
165141
+ function isInvalidHour(expression) {
165142
+ return !isValidExpression(expression, 0, 23);
165143
+ }
165144
+ function isInvalidDayOfMonth(expression) {
165145
+ return !isValidExpression(expression, 1, 31);
165146
+ }
165147
+ function isInvalidMonth(expression) {
165148
+ return !isValidExpression(expression, 1, 12);
165149
+ }
165150
+ function isInvalidWeekDay(expression) {
165151
+ return !isValidExpression(expression, 0, 7);
165152
+ }
165153
+ function validateFields(patterns, executablePatterns) {
165154
+ if (isInvalidSecond(executablePatterns[0]))
165155
+ throw new Error(`${patterns[0]} is a invalid expression for second`);
165156
+ if (isInvalidMinute(executablePatterns[1]))
165157
+ throw new Error(`${patterns[1]} is a invalid expression for minute`);
165158
+ if (isInvalidHour(executablePatterns[2]))
165159
+ throw new Error(`${patterns[2]} is a invalid expression for hour`);
165160
+ if (isInvalidDayOfMonth(executablePatterns[3]))
165161
+ throw new Error(`${patterns[3]} is a invalid expression for day of month`);
165162
+ if (isInvalidMonth(executablePatterns[4]))
165163
+ throw new Error(`${patterns[4]} is a invalid expression for month`);
165164
+ if (isInvalidWeekDay(executablePatterns[5]))
165165
+ throw new Error(`${patterns[5]} is a invalid expression for week day`);
165166
+ }
165167
+ function validate(pattern) {
165168
+ if (typeof pattern !== "string")
165169
+ throw new TypeError("pattern must be a string!");
165170
+ const patterns = pattern.split(" ");
165171
+ const executablePatterns = convertExpression(pattern).split(" ");
165172
+ if (patterns.length === 5)
165173
+ patterns.unshift("0");
165174
+ validateFields(patterns, executablePatterns);
165175
+ }
165176
+ module2.exports = validate;
165177
+ });
165178
+
165179
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/time-matcher.js
165180
+ var require_time_matcher = __commonJS((exports2, module2) => {
165181
+ var validatePattern = require_pattern_validation();
165182
+ var convertExpression = require_convert_expression();
165183
+ function matchPattern(pattern, value) {
165184
+ if (pattern.indexOf(",") !== -1) {
165185
+ const patterns = pattern.split(",");
165186
+ return patterns.indexOf(value.toString()) !== -1;
165187
+ }
165188
+ return pattern === value.toString();
165189
+ }
165190
+
165191
+ class TimeMatcher {
165192
+ constructor(pattern, timezone) {
165193
+ validatePattern(pattern);
165194
+ this.pattern = convertExpression(pattern);
165195
+ this.timezone = timezone;
165196
+ this.expressions = this.pattern.split(" ");
165197
+ this.dtf = this.timezone ? new Intl.DateTimeFormat("en-US", {
165198
+ year: "numeric",
165199
+ month: "2-digit",
165200
+ day: "2-digit",
165201
+ hour: "2-digit",
165202
+ minute: "2-digit",
165203
+ second: "2-digit",
165204
+ hourCycle: "h23",
165205
+ fractionalSecondDigits: 3,
165206
+ timeZone: this.timezone
165207
+ }) : null;
165208
+ }
165209
+ match(date5) {
165210
+ date5 = this.apply(date5);
165211
+ const runOnSecond = matchPattern(this.expressions[0], date5.getSeconds());
165212
+ const runOnMinute = matchPattern(this.expressions[1], date5.getMinutes());
165213
+ const runOnHour = matchPattern(this.expressions[2], date5.getHours());
165214
+ const runOnDay = matchPattern(this.expressions[3], date5.getDate());
165215
+ const runOnMonth = matchPattern(this.expressions[4], date5.getMonth() + 1);
165216
+ const runOnWeekDay = matchPattern(this.expressions[5], date5.getDay());
165217
+ return runOnSecond && runOnMinute && runOnHour && runOnDay && runOnMonth && runOnWeekDay;
165218
+ }
165219
+ apply(date5) {
165220
+ if (this.dtf) {
165221
+ return new Date(this.dtf.format(date5));
165222
+ }
165223
+ return date5;
165224
+ }
165225
+ }
165226
+ module2.exports = TimeMatcher;
165227
+ });
165228
+
165229
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/scheduler.js
165230
+ var require_scheduler = __commonJS((exports2, module2) => {
165231
+ var EventEmitter = __require("events");
165232
+ var TimeMatcher = require_time_matcher();
165233
+
165234
+ class Scheduler extends EventEmitter {
165235
+ constructor(pattern, timezone, autorecover) {
165236
+ super();
165237
+ this.timeMatcher = new TimeMatcher(pattern, timezone);
165238
+ this.autorecover = autorecover;
165239
+ }
165240
+ start() {
165241
+ this.stop();
165242
+ let lastCheck = process.hrtime();
165243
+ let lastExecution = this.timeMatcher.apply(new Date);
165244
+ const matchTime = () => {
165245
+ const delay = 1000;
165246
+ const elapsedTime = process.hrtime(lastCheck);
165247
+ const elapsedMs = (elapsedTime[0] * 1e9 + elapsedTime[1]) / 1e6;
165248
+ const missedExecutions = Math.floor(elapsedMs / 1000);
165249
+ for (let i3 = missedExecutions;i3 >= 0; i3--) {
165250
+ const date5 = new Date(new Date().getTime() - i3 * 1000);
165251
+ let date_tmp = this.timeMatcher.apply(date5);
165252
+ if (lastExecution.getTime() < date_tmp.getTime() && (i3 === 0 || this.autorecover) && this.timeMatcher.match(date5)) {
165253
+ this.emit("scheduled-time-matched", date_tmp);
165254
+ date_tmp.setMilliseconds(0);
165255
+ lastExecution = date_tmp;
165256
+ }
165257
+ }
165258
+ lastCheck = process.hrtime();
165259
+ this.timeout = setTimeout(matchTime, delay);
165260
+ };
165261
+ matchTime();
165262
+ }
165263
+ stop() {
165264
+ if (this.timeout) {
165265
+ clearTimeout(this.timeout);
165266
+ }
165267
+ this.timeout = null;
165268
+ }
165269
+ }
165270
+ module2.exports = Scheduler;
165271
+ });
165272
+
165273
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/rng.js
165274
+ var require_rng = __commonJS((exports2) => {
165275
+ Object.defineProperty(exports2, "__esModule", {
165276
+ value: true
165277
+ });
165278
+ exports2.default = rng;
165279
+ var _crypto = _interopRequireDefault(__require("crypto"));
165280
+ function _interopRequireDefault(obj) {
165281
+ return obj && obj.__esModule ? obj : { default: obj };
165282
+ }
165283
+ var rnds8Pool = new Uint8Array(256);
165284
+ var poolPtr = rnds8Pool.length;
165285
+ function rng() {
165286
+ if (poolPtr > rnds8Pool.length - 16) {
165287
+ _crypto.default.randomFillSync(rnds8Pool);
165288
+ poolPtr = 0;
165289
+ }
165290
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
165291
+ }
165292
+ });
165293
+
165294
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/regex.js
165295
+ var require_regex = __commonJS((exports2) => {
165296
+ Object.defineProperty(exports2, "__esModule", {
165297
+ value: true
165298
+ });
165299
+ exports2.default = undefined;
165300
+ var _default4 = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
165301
+ exports2.default = _default4;
165302
+ });
165303
+
165304
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/validate.js
165305
+ var require_validate = __commonJS((exports2) => {
165306
+ Object.defineProperty(exports2, "__esModule", {
165307
+ value: true
165308
+ });
165309
+ exports2.default = undefined;
165310
+ var _regex2 = _interopRequireDefault(require_regex());
165311
+ function _interopRequireDefault(obj) {
165312
+ return obj && obj.__esModule ? obj : { default: obj };
165313
+ }
165314
+ function validate(uuid3) {
165315
+ return typeof uuid3 === "string" && _regex2.default.test(uuid3);
165316
+ }
165317
+ var _default4 = validate;
165318
+ exports2.default = _default4;
165319
+ });
165320
+
165321
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/stringify.js
165322
+ var require_stringify = __commonJS((exports2) => {
165323
+ Object.defineProperty(exports2, "__esModule", {
165324
+ value: true
165325
+ });
165326
+ exports2.default = undefined;
165327
+ var _validate = _interopRequireDefault(require_validate());
165328
+ function _interopRequireDefault(obj) {
165329
+ return obj && obj.__esModule ? obj : { default: obj };
165330
+ }
165331
+ var byteToHex = [];
165332
+ for (let i3 = 0;i3 < 256; ++i3) {
165333
+ byteToHex.push((i3 + 256).toString(16).substr(1));
165334
+ }
165335
+ function stringify(arr, offset = 0) {
165336
+ const uuid3 = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
165337
+ if (!(0, _validate.default)(uuid3)) {
165338
+ throw TypeError("Stringified UUID is invalid");
165339
+ }
165340
+ return uuid3;
165341
+ }
165342
+ var _default4 = stringify;
165343
+ exports2.default = _default4;
165344
+ });
165345
+
165346
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/v1.js
165347
+ var require_v1 = __commonJS((exports2) => {
165348
+ Object.defineProperty(exports2, "__esModule", {
165349
+ value: true
165350
+ });
165351
+ exports2.default = undefined;
165352
+ var _rng = _interopRequireDefault(require_rng());
165353
+ var _stringify = _interopRequireDefault(require_stringify());
165354
+ function _interopRequireDefault(obj) {
165355
+ return obj && obj.__esModule ? obj : { default: obj };
165356
+ }
165357
+ var _nodeId;
165358
+ var _clockseq;
165359
+ var _lastMSecs = 0;
165360
+ var _lastNSecs = 0;
165361
+ function v1(options, buf, offset) {
165362
+ let i3 = buf && offset || 0;
165363
+ const b2 = buf || new Array(16);
165364
+ options = options || {};
165365
+ let node = options.node || _nodeId;
165366
+ let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
165367
+ if (node == null || clockseq == null) {
165368
+ const seedBytes = options.random || (options.rng || _rng.default)();
165369
+ if (node == null) {
165370
+ node = _nodeId = [seedBytes[0] | 1, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
165371
+ }
165372
+ if (clockseq == null) {
165373
+ clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383;
165374
+ }
165375
+ }
165376
+ let msecs = options.msecs !== undefined ? options.msecs : Date.now();
165377
+ let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
165378
+ const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4;
165379
+ if (dt < 0 && options.clockseq === undefined) {
165380
+ clockseq = clockseq + 1 & 16383;
165381
+ }
165382
+ if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
165383
+ nsecs = 0;
165384
+ }
165385
+ if (nsecs >= 1e4) {
165386
+ throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
165387
+ }
165388
+ _lastMSecs = msecs;
165389
+ _lastNSecs = nsecs;
165390
+ _clockseq = clockseq;
165391
+ msecs += 12219292800000;
165392
+ const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
165393
+ b2[i3++] = tl >>> 24 & 255;
165394
+ b2[i3++] = tl >>> 16 & 255;
165395
+ b2[i3++] = tl >>> 8 & 255;
165396
+ b2[i3++] = tl & 255;
165397
+ const tmh = msecs / 4294967296 * 1e4 & 268435455;
165398
+ b2[i3++] = tmh >>> 8 & 255;
165399
+ b2[i3++] = tmh & 255;
165400
+ b2[i3++] = tmh >>> 24 & 15 | 16;
165401
+ b2[i3++] = tmh >>> 16 & 255;
165402
+ b2[i3++] = clockseq >>> 8 | 128;
165403
+ b2[i3++] = clockseq & 255;
165404
+ for (let n3 = 0;n3 < 6; ++n3) {
165405
+ b2[i3 + n3] = node[n3];
165406
+ }
165407
+ return buf || (0, _stringify.default)(b2);
165408
+ }
165409
+ var _default4 = v1;
165410
+ exports2.default = _default4;
165411
+ });
165412
+
165413
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/parse.js
165414
+ var require_parse4 = __commonJS((exports2) => {
165415
+ Object.defineProperty(exports2, "__esModule", {
165416
+ value: true
165417
+ });
165418
+ exports2.default = undefined;
165419
+ var _validate = _interopRequireDefault(require_validate());
165420
+ function _interopRequireDefault(obj) {
165421
+ return obj && obj.__esModule ? obj : { default: obj };
165422
+ }
165423
+ function parse8(uuid3) {
165424
+ if (!(0, _validate.default)(uuid3)) {
165425
+ throw TypeError("Invalid UUID");
165426
+ }
165427
+ let v;
165428
+ const arr = new Uint8Array(16);
165429
+ arr[0] = (v = parseInt(uuid3.slice(0, 8), 16)) >>> 24;
165430
+ arr[1] = v >>> 16 & 255;
165431
+ arr[2] = v >>> 8 & 255;
165432
+ arr[3] = v & 255;
165433
+ arr[4] = (v = parseInt(uuid3.slice(9, 13), 16)) >>> 8;
165434
+ arr[5] = v & 255;
165435
+ arr[6] = (v = parseInt(uuid3.slice(14, 18), 16)) >>> 8;
165436
+ arr[7] = v & 255;
165437
+ arr[8] = (v = parseInt(uuid3.slice(19, 23), 16)) >>> 8;
165438
+ arr[9] = v & 255;
165439
+ arr[10] = (v = parseInt(uuid3.slice(24, 36), 16)) / 1099511627776 & 255;
165440
+ arr[11] = v / 4294967296 & 255;
165441
+ arr[12] = v >>> 24 & 255;
165442
+ arr[13] = v >>> 16 & 255;
165443
+ arr[14] = v >>> 8 & 255;
165444
+ arr[15] = v & 255;
165445
+ return arr;
165446
+ }
165447
+ var _default4 = parse8;
165448
+ exports2.default = _default4;
165449
+ });
165450
+
165451
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/v35.js
165452
+ var require_v35 = __commonJS((exports2) => {
165453
+ Object.defineProperty(exports2, "__esModule", {
165454
+ value: true
165455
+ });
165456
+ exports2.default = _default4;
165457
+ exports2.URL = exports2.DNS = undefined;
165458
+ var _stringify = _interopRequireDefault(require_stringify());
165459
+ var _parse2 = _interopRequireDefault(require_parse4());
165460
+ function _interopRequireDefault(obj) {
165461
+ return obj && obj.__esModule ? obj : { default: obj };
165462
+ }
165463
+ function stringToBytes(str3) {
165464
+ str3 = unescape(encodeURIComponent(str3));
165465
+ const bytes = [];
165466
+ for (let i3 = 0;i3 < str3.length; ++i3) {
165467
+ bytes.push(str3.charCodeAt(i3));
165468
+ }
165469
+ return bytes;
165470
+ }
165471
+ var DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
165472
+ exports2.DNS = DNS;
165473
+ var URL2 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
165474
+ exports2.URL = URL2;
165475
+ function _default4(name2, version3, hashfunc) {
165476
+ function generateUUID(value, namespace, buf, offset) {
165477
+ if (typeof value === "string") {
165478
+ value = stringToBytes(value);
165479
+ }
165480
+ if (typeof namespace === "string") {
165481
+ namespace = (0, _parse2.default)(namespace);
165482
+ }
165483
+ if (namespace.length !== 16) {
165484
+ throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
165485
+ }
165486
+ let bytes = new Uint8Array(16 + value.length);
165487
+ bytes.set(namespace);
165488
+ bytes.set(value, namespace.length);
165489
+ bytes = hashfunc(bytes);
165490
+ bytes[6] = bytes[6] & 15 | version3;
165491
+ bytes[8] = bytes[8] & 63 | 128;
165492
+ if (buf) {
165493
+ offset = offset || 0;
165494
+ for (let i3 = 0;i3 < 16; ++i3) {
165495
+ buf[offset + i3] = bytes[i3];
165496
+ }
165497
+ return buf;
165498
+ }
165499
+ return (0, _stringify.default)(bytes);
165500
+ }
165501
+ try {
165502
+ generateUUID.name = name2;
165503
+ } catch (err) {}
165504
+ generateUUID.DNS = DNS;
165505
+ generateUUID.URL = URL2;
165506
+ return generateUUID;
165507
+ }
165508
+ });
165509
+
165510
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/md5.js
165511
+ var require_md5 = __commonJS((exports2) => {
165512
+ Object.defineProperty(exports2, "__esModule", {
165513
+ value: true
165514
+ });
165515
+ exports2.default = undefined;
165516
+ var _crypto = _interopRequireDefault(__require("crypto"));
165517
+ function _interopRequireDefault(obj) {
165518
+ return obj && obj.__esModule ? obj : { default: obj };
165519
+ }
165520
+ function md5(bytes) {
165521
+ if (Array.isArray(bytes)) {
165522
+ bytes = Buffer.from(bytes);
165523
+ } else if (typeof bytes === "string") {
165524
+ bytes = Buffer.from(bytes, "utf8");
165525
+ }
165526
+ return _crypto.default.createHash("md5").update(bytes).digest();
165527
+ }
165528
+ var _default4 = md5;
165529
+ exports2.default = _default4;
165530
+ });
165531
+
165532
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/v3.js
165533
+ var require_v3 = __commonJS((exports2) => {
165534
+ Object.defineProperty(exports2, "__esModule", {
165535
+ value: true
165536
+ });
165537
+ exports2.default = undefined;
165538
+ var _v = _interopRequireDefault(require_v35());
165539
+ var _md = _interopRequireDefault(require_md5());
165540
+ function _interopRequireDefault(obj) {
165541
+ return obj && obj.__esModule ? obj : { default: obj };
165542
+ }
165543
+ var v3 = (0, _v.default)("v3", 48, _md.default);
165544
+ var _default4 = v3;
165545
+ exports2.default = _default4;
165546
+ });
165547
+
165548
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/v4.js
165549
+ var require_v4 = __commonJS((exports2) => {
165550
+ Object.defineProperty(exports2, "__esModule", {
165551
+ value: true
165552
+ });
165553
+ exports2.default = undefined;
165554
+ var _rng = _interopRequireDefault(require_rng());
165555
+ var _stringify = _interopRequireDefault(require_stringify());
165556
+ function _interopRequireDefault(obj) {
165557
+ return obj && obj.__esModule ? obj : { default: obj };
165558
+ }
165559
+ function v4(options, buf, offset) {
165560
+ options = options || {};
165561
+ const rnds = options.random || (options.rng || _rng.default)();
165562
+ rnds[6] = rnds[6] & 15 | 64;
165563
+ rnds[8] = rnds[8] & 63 | 128;
165564
+ if (buf) {
165565
+ offset = offset || 0;
165566
+ for (let i3 = 0;i3 < 16; ++i3) {
165567
+ buf[offset + i3] = rnds[i3];
165568
+ }
165569
+ return buf;
165570
+ }
165571
+ return (0, _stringify.default)(rnds);
165572
+ }
165573
+ var _default4 = v4;
165574
+ exports2.default = _default4;
165575
+ });
165576
+
165577
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/sha1.js
165578
+ var require_sha1 = __commonJS((exports2) => {
165579
+ Object.defineProperty(exports2, "__esModule", {
165580
+ value: true
165581
+ });
165582
+ exports2.default = undefined;
165583
+ var _crypto = _interopRequireDefault(__require("crypto"));
165584
+ function _interopRequireDefault(obj) {
165585
+ return obj && obj.__esModule ? obj : { default: obj };
165586
+ }
165587
+ function sha1(bytes) {
165588
+ if (Array.isArray(bytes)) {
165589
+ bytes = Buffer.from(bytes);
165590
+ } else if (typeof bytes === "string") {
165591
+ bytes = Buffer.from(bytes, "utf8");
165592
+ }
165593
+ return _crypto.default.createHash("sha1").update(bytes).digest();
165594
+ }
165595
+ var _default4 = sha1;
165596
+ exports2.default = _default4;
165597
+ });
165598
+
165599
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/v5.js
165600
+ var require_v5 = __commonJS((exports2) => {
165601
+ Object.defineProperty(exports2, "__esModule", {
165602
+ value: true
165603
+ });
165604
+ exports2.default = undefined;
165605
+ var _v = _interopRequireDefault(require_v35());
165606
+ var _sha = _interopRequireDefault(require_sha1());
165607
+ function _interopRequireDefault(obj) {
165608
+ return obj && obj.__esModule ? obj : { default: obj };
165609
+ }
165610
+ var v5 = (0, _v.default)("v5", 80, _sha.default);
165611
+ var _default4 = v5;
165612
+ exports2.default = _default4;
165613
+ });
165614
+
165615
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/nil.js
165616
+ var require_nil = __commonJS((exports2) => {
165617
+ Object.defineProperty(exports2, "__esModule", {
165618
+ value: true
165619
+ });
165620
+ exports2.default = undefined;
165621
+ var _default4 = "00000000-0000-0000-0000-000000000000";
165622
+ exports2.default = _default4;
165623
+ });
165624
+
165625
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/version.js
165626
+ var require_version = __commonJS((exports2) => {
165627
+ Object.defineProperty(exports2, "__esModule", {
165628
+ value: true
165629
+ });
165630
+ exports2.default = undefined;
165631
+ var _validate = _interopRequireDefault(require_validate());
165632
+ function _interopRequireDefault(obj) {
165633
+ return obj && obj.__esModule ? obj : { default: obj };
165634
+ }
165635
+ function version3(uuid3) {
165636
+ if (!(0, _validate.default)(uuid3)) {
165637
+ throw TypeError("Invalid UUID");
165638
+ }
165639
+ return parseInt(uuid3.substr(14, 1), 16);
165640
+ }
165641
+ var _default4 = version3;
165642
+ exports2.default = _default4;
165643
+ });
165644
+
165645
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/index.js
165646
+ var require_dist11 = __commonJS((exports2) => {
165647
+ Object.defineProperty(exports2, "__esModule", {
165648
+ value: true
165649
+ });
165650
+ Object.defineProperty(exports2, "v1", {
165651
+ enumerable: true,
165652
+ get: function() {
165653
+ return _v.default;
165654
+ }
165655
+ });
165656
+ Object.defineProperty(exports2, "v3", {
165657
+ enumerable: true,
165658
+ get: function() {
165659
+ return _v2.default;
165660
+ }
165661
+ });
165662
+ Object.defineProperty(exports2, "v4", {
165663
+ enumerable: true,
165664
+ get: function() {
165665
+ return _v3.default;
165666
+ }
165667
+ });
165668
+ Object.defineProperty(exports2, "v5", {
165669
+ enumerable: true,
165670
+ get: function() {
165671
+ return _v4.default;
165672
+ }
165673
+ });
165674
+ Object.defineProperty(exports2, "NIL", {
165675
+ enumerable: true,
165676
+ get: function() {
165677
+ return _nil.default;
165678
+ }
165679
+ });
165680
+ Object.defineProperty(exports2, "version", {
165681
+ enumerable: true,
165682
+ get: function() {
165683
+ return _version.default;
165684
+ }
165685
+ });
165686
+ Object.defineProperty(exports2, "validate", {
165687
+ enumerable: true,
165688
+ get: function() {
165689
+ return _validate.default;
165690
+ }
165691
+ });
165692
+ Object.defineProperty(exports2, "stringify", {
165693
+ enumerable: true,
165694
+ get: function() {
165695
+ return _stringify.default;
165696
+ }
165697
+ });
165698
+ Object.defineProperty(exports2, "parse", {
165699
+ enumerable: true,
165700
+ get: function() {
165701
+ return _parse2.default;
165702
+ }
165703
+ });
165704
+ var _v = _interopRequireDefault(require_v1());
165705
+ var _v2 = _interopRequireDefault(require_v3());
165706
+ var _v3 = _interopRequireDefault(require_v4());
165707
+ var _v4 = _interopRequireDefault(require_v5());
165708
+ var _nil = _interopRequireDefault(require_nil());
165709
+ var _version = _interopRequireDefault(require_version());
165710
+ var _validate = _interopRequireDefault(require_validate());
165711
+ var _stringify = _interopRequireDefault(require_stringify());
165712
+ var _parse2 = _interopRequireDefault(require_parse4());
165713
+ function _interopRequireDefault(obj) {
165714
+ return obj && obj.__esModule ? obj : { default: obj };
165715
+ }
165716
+ });
165717
+
165718
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/scheduled-task.js
165719
+ var require_scheduled_task = __commonJS((exports2, module2) => {
165720
+ var EventEmitter = __require("events");
165721
+ var Task = require_task();
165722
+ var Scheduler = require_scheduler();
165723
+ var uuid3 = require_dist11();
165724
+
165725
+ class ScheduledTask extends EventEmitter {
165726
+ constructor(cronExpression, func, options) {
165727
+ super();
165728
+ if (!options) {
165729
+ options = {
165730
+ scheduled: true,
165731
+ recoverMissedExecutions: false
165732
+ };
165733
+ }
165734
+ this.options = options;
165735
+ this.options.name = this.options.name || uuid3.v4();
165736
+ this._task = new Task(func);
165737
+ this._scheduler = new Scheduler(cronExpression, options.timezone, options.recoverMissedExecutions);
165738
+ this._scheduler.on("scheduled-time-matched", (now) => {
165739
+ this.now(now);
165740
+ });
165741
+ if (options.scheduled !== false) {
165742
+ this._scheduler.start();
165743
+ }
165744
+ if (options.runOnInit === true) {
165745
+ this.now("init");
165746
+ }
165747
+ }
165748
+ now(now = "manual") {
165749
+ let result = this._task.execute(now);
165750
+ this.emit("task-done", result);
165751
+ }
165752
+ start() {
165753
+ this._scheduler.start();
165754
+ }
165755
+ stop() {
165756
+ this._scheduler.stop();
165757
+ }
165758
+ }
165759
+ module2.exports = ScheduledTask;
165760
+ });
165761
+
165762
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/background-scheduled-task/index.js
165763
+ var require_background_scheduled_task = __commonJS((exports2, module2) => {
165764
+ var __dirname = "/root/Projets/MaTrixOS/node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/background-scheduled-task";
165765
+ var EventEmitter = __require("events");
165766
+ var path18 = __require("path");
165767
+ var { fork } = __require("child_process");
165768
+ var uuid3 = require_dist11();
165769
+ var daemonPath = `${__dirname}/daemon.js`;
165770
+
165771
+ class BackgroundScheduledTask extends EventEmitter {
165772
+ constructor(cronExpression, taskPath, options) {
165773
+ super();
165774
+ if (!options) {
165775
+ options = {
165776
+ scheduled: true,
165777
+ recoverMissedExecutions: false
165778
+ };
165779
+ }
165780
+ this.cronExpression = cronExpression;
165781
+ this.taskPath = taskPath;
165782
+ this.options = options;
165783
+ this.options.name = this.options.name || uuid3.v4();
165784
+ if (options.scheduled) {
165785
+ this.start();
165786
+ }
165787
+ }
165788
+ start() {
165789
+ this.stop();
165790
+ this.forkProcess = fork(daemonPath);
165791
+ this.forkProcess.on("message", (message) => {
165792
+ switch (message.type) {
165793
+ case "task-done":
165794
+ this.emit("task-done", message.result);
165795
+ break;
165796
+ }
165797
+ });
165798
+ let options = this.options;
165799
+ options.scheduled = true;
165800
+ this.forkProcess.send({
165801
+ type: "register",
165802
+ path: path18.resolve(this.taskPath),
165803
+ cron: this.cronExpression,
165804
+ options
165805
+ });
165806
+ }
165807
+ stop() {
165808
+ if (this.forkProcess) {
165809
+ this.forkProcess.kill();
165810
+ }
165811
+ }
165812
+ pid() {
165813
+ if (this.forkProcess) {
165814
+ return this.forkProcess.pid;
165815
+ }
165816
+ }
165817
+ isRunning() {
165818
+ return !this.forkProcess.killed;
165819
+ }
165820
+ }
165821
+ module2.exports = BackgroundScheduledTask;
165822
+ });
165823
+
165824
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/storage.js
165825
+ var require_storage = __commonJS((exports2, module2) => {
165826
+ module2.exports = (() => {
165827
+ if (!global.scheduledTasks) {
165828
+ global.scheduledTasks = new Map;
165829
+ }
165830
+ return {
165831
+ save: (task2) => {
165832
+ if (!task2.options) {
165833
+ const uuid3 = require_dist11();
165834
+ task2.options = {};
165835
+ task2.options.name = uuid3.v4();
165836
+ }
165837
+ global.scheduledTasks.set(task2.options.name, task2);
165838
+ },
165839
+ getTasks: () => {
165840
+ return global.scheduledTasks;
165841
+ }
165842
+ };
165843
+ })();
165844
+ });
165845
+
165846
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/node-cron.js
165847
+ var require_node_cron = __commonJS((exports2, module2) => {
165848
+ var ScheduledTask = require_scheduled_task();
165849
+ var BackgroundScheduledTask = require_background_scheduled_task();
165850
+ var validation = require_pattern_validation();
165851
+ var storage3 = require_storage();
165852
+ function schedule(expression, func, options) {
165853
+ const task2 = createTask(expression, func, options);
165854
+ storage3.save(task2);
165855
+ return task2;
165856
+ }
165857
+ function createTask(expression, func, options) {
165858
+ if (typeof func === "string")
165859
+ return new BackgroundScheduledTask(expression, func, options);
165860
+ return new ScheduledTask(expression, func, options);
165861
+ }
165862
+ function validate(expression) {
165863
+ try {
165864
+ validation(expression);
165865
+ return true;
165866
+ } catch (_2) {
165867
+ return false;
165868
+ }
165869
+ }
165870
+ function getTasks() {
165871
+ return storage3.getTasks();
165872
+ }
165873
+ module2.exports = { schedule, validate, getTasks };
165874
+ });
165875
+
165876
+ // packages/omo-opencode/src/features/cron/runner.ts
165877
+ var exports_runner = {};
165878
+ __export(exports_runner, {
165879
+ CronRunner: () => CronRunner
165880
+ });
165881
+
165882
+ class CronRunner {
165883
+ store;
165884
+ deps;
165885
+ tasks = [];
165886
+ constructor(store2, deps) {
165887
+ this.store = store2;
165888
+ this.deps = deps;
165889
+ }
165890
+ start() {
165891
+ const jobs = this.store.list({ enabled: true });
165892
+ for (const job of jobs) {
165893
+ if (cron2.validate(job.schedule)) {
165894
+ const task2 = cron2.schedule(job.schedule, () => {
165895
+ this.deps.onTick(job);
165896
+ });
165897
+ this.tasks.push(task2);
165898
+ }
165899
+ }
165900
+ }
165901
+ stop() {
165902
+ for (const t2 of this.tasks) {
165903
+ t2.stop();
165904
+ }
165905
+ this.tasks = [];
165906
+ }
165907
+ }
165908
+ var cron2;
165909
+ var init_runner3 = __esm(() => {
165910
+ cron2 = __toESM(require_node_cron(), 1);
165911
+ });
165912
+
165913
+ // packages/omo-opencode/src/cli/cron.ts
165914
+ var exports_cron = {};
165915
+ __export(exports_cron, {
165916
+ cronStop: () => cronStop,
165917
+ cronStart: () => cronStart,
165918
+ cronRemove: () => cronRemove,
165919
+ cronList: () => cronList,
165920
+ cronAdd: () => cronAdd
165921
+ });
165922
+ function cronAdd(options) {
165923
+ const job = store2.add({
165924
+ name: options.name,
165925
+ schedule: options.schedule,
165926
+ command: options.command,
165927
+ channel: options.channel,
165928
+ recipient: options.recipient,
165929
+ enabled: options.enabled ?? true
165930
+ });
165931
+ console.log(`Added: ${job.id} \u2014 ${job.name} [${job.schedule}]`);
165932
+ return 0;
165933
+ }
165934
+ function cronList(options = {}) {
165935
+ const jobs = store2.list({
165936
+ enabled: options.enabled,
165937
+ channel: options.channel
165938
+ });
165939
+ if (options.json) {
165940
+ console.log(JSON.stringify(jobs, null, 2));
165941
+ } else {
165942
+ if (jobs.length === 0) {
165943
+ console.log("No cron jobs.");
165944
+ return 0;
165945
+ }
165946
+ for (const j of jobs) {
165947
+ const status2 = j.enabled ? "enabled" : "disabled";
165948
+ const delivery = j.channel ? ` \u2192 ${j.channel}/${j.recipient ?? "*"}` : "";
165949
+ console.log(` ${j.id.padEnd(14)} ${status2.padEnd(9)} ${j.schedule.padEnd(12)} ${j.name}${delivery}`);
165950
+ }
165951
+ console.log(`
165952
+ Total: ${jobs.length}`);
165953
+ }
165954
+ return 0;
165955
+ }
165956
+ function cronRemove(options) {
165957
+ const ok = store2.remove(options.id);
165958
+ if (ok) {
165959
+ console.log(`Removed: ${options.id}`);
165960
+ return 0;
165961
+ }
165962
+ console.error(`Not found: ${options.id}`);
165963
+ return 1;
165964
+ }
165965
+ function cronStart(options = {}) {
165966
+ const { CronRunner: CronRunner2 } = (init_runner3(), __toCommonJS(exports_runner));
165967
+ const runner3 = new CronRunner2(store2, {
165968
+ onTick: async (job) => {
165969
+ const { spawnSync: spawnSync4 } = __require("child_process");
165970
+ console.log(`[cron] firing ${job.name} \u2192 ${job.command}`);
165971
+ const res = spawnSync4("bash", ["-lc", job.command], { encoding: "utf-8" });
165972
+ if (res.status !== 0) {
165973
+ console.error(`[cron] ${job.name} failed:`, res.stderr || res.stdout);
165974
+ } else if (job.channel) {
165975
+ console.log(`[cron] ${job.name} done (delivery to ${job.channel} not yet wired)`);
165976
+ }
165977
+ }
165978
+ });
165979
+ runner3.start();
165980
+ if (options.daemon) {
165981
+ console.log("[cron] scheduler started (daemon). Running until stopped.");
165982
+ setInterval(() => {}, 1 << 30);
165983
+ process.on("SIGTERM", () => {
165984
+ runner3.stop();
165985
+ process.exit(0);
165986
+ });
165987
+ process.on("SIGINT", () => {
165988
+ runner3.stop();
165989
+ process.exit(0);
165990
+ });
165991
+ } else {
165992
+ console.log("[cron] scheduler started. Jobs will fire per their schedule. Press Ctrl-C to stop.");
165993
+ }
165994
+ return 0;
165995
+ }
165996
+ function cronStop() {
165997
+ console.log("[cron] stop is handled by terminating the scheduler process (Ctrl-C / systemd stop).");
165998
+ return 0;
165999
+ }
166000
+ var store2;
166001
+ var init_cron = __esm(() => {
166002
+ init_store();
166003
+ store2 = createCronStore();
164848
166004
  });
164849
166005
 
164850
166006
  // packages/task-ledger-core/src/schema.ts
@@ -165097,9 +166253,9 @@ var init_ledger = __esm(() => {
165097
166253
  });
165098
166254
 
165099
166255
  // packages/task-ledger-core/src/sqlite.ts
165100
- import { Database as Database2 } from "bun:sqlite";
166256
+ import { Database as Database3 } from "bun:sqlite";
165101
166257
  function createSqliteDatabase(dbPath) {
165102
- const db = new Database2(dbPath);
166258
+ const db = new Database3(dbPath);
165103
166259
  db.exec("PRAGMA journal_mode = WAL");
165104
166260
  db.exec("PRAGMA foreign_keys = ON");
165105
166261
  return {
@@ -165142,7 +166298,7 @@ __export(exports_generate, {
165142
166298
  ProfileNotFoundError: () => ProfileNotFoundError
165143
166299
  });
165144
166300
  import { existsSync as existsSync72, readFileSync as readFileSync59, realpathSync as realpathSync10 } from "fs";
165145
- import { dirname as dirname30, isAbsolute as isAbsolute6, join as join78, resolve as resolve16 } from "path";
166301
+ import { dirname as dirname30, isAbsolute as isAbsolute6, join as join78, resolve as resolve17 } from "path";
165146
166302
  function profilesDirFor(opts) {
165147
166303
  if (opts.profilesDir)
165148
166304
  return opts.profilesDir;
@@ -165183,7 +166339,7 @@ function runGenerate(options) {
165183
166339
  profilesDir: options.profilesDir,
165184
166340
  fs: options.fs
165185
166341
  });
165186
- const targetDir = isAbsolute6(options.targetDir) ? options.targetDir : resolve16(process.cwd(), options.targetDir);
166342
+ const targetDir = isAbsolute6(options.targetDir) ? options.targetDir : resolve17(process.cwd(), options.targetDir);
165187
166343
  return generateMiniOS({
165188
166344
  profile: profile2,
165189
166345
  targetDir,
@@ -165238,7 +166394,7 @@ var REPO_ROOT, defaultFS2, PROFILES_RELATIVE = "assets/profiles", ProfileNotFoun
165238
166394
  var init_generate = __esm(() => {
165239
166395
  init_src5();
165240
166396
  init_src5();
165241
- REPO_ROOT = resolve16(dirname30(new URL(import.meta.url).pathname), "..", "..", "..", "..", "..");
166397
+ REPO_ROOT = resolve17(dirname30(new URL(import.meta.url).pathname), "..", "..", "..", "..", "..");
165242
166398
  defaultFS2 = { existsSync: existsSync72, readFileSync: readFileSync59, realpathSync: realpathSync10 };
165243
166399
  ProfileNotFoundError = class ProfileNotFoundError extends Error {
165244
166400
  profileName;
@@ -165357,7 +166513,7 @@ var exports_cost_report = {};
165357
166513
  __export(exports_cost_report, {
165358
166514
  executeCostReportCommand: () => executeCostReportCommand
165359
166515
  });
165360
- import { Database as Database6 } from "bun:sqlite";
166516
+ import { Database as Database7 } from "bun:sqlite";
165361
166517
  import { existsSync as existsSync73 } from "fs";
165362
166518
  import * as path28 from "path";
165363
166519
  import * as os14 from "os";
@@ -165373,7 +166529,7 @@ function executeCostReportCommand(args) {
165373
166529
  ` };
165374
166530
  }
165375
166531
  try {
165376
- const db = new Database6(dbPath);
166532
+ const db = new Database7(dbPath);
165377
166533
  const rows = queryReport(db, period);
165378
166534
  if (args.options.json) {
165379
166535
  return { exitCode: 0, stdout: JSON.stringify(rows, null, 2) + `
@@ -165494,7 +166650,7 @@ __export(exports_profile_resolve, {
165494
166650
  executeProfileResolveCommand: () => executeProfileResolveCommand
165495
166651
  });
165496
166652
  import { existsSync as existsSync74, readdirSync as readdirSync16, readFileSync as readFileSync60 } from "fs";
165497
- import { join as join81, resolve as resolve17, dirname as dirname31 } from "path";
166653
+ import { join as join81, resolve as resolve18, dirname as dirname31 } from "path";
165498
166654
  function executeProfileResolveCommand(args) {
165499
166655
  if (args.options.help) {
165500
166656
  return {
@@ -165592,7 +166748,7 @@ function executeProfileResolveCommand(args) {
165592
166748
  var REPO_ROOT2, PROFILES_RELATIVE2 = "assets/profiles";
165593
166749
  var init_profile_resolve = __esm(() => {
165594
166750
  init_src5();
165595
- REPO_ROOT2 = resolve17(dirname31(new URL(import.meta.url).pathname), "..", "..", "..", "..");
166751
+ REPO_ROOT2 = resolve18(dirname31(new URL(import.meta.url).pathname), "..", "..", "..", "..");
165596
166752
  });
165597
166753
 
165598
166754
  // packages/omo-opencode/src/cli/export.ts
@@ -165603,7 +166759,7 @@ __export(exports_export, {
165603
166759
  executeExportCommand: () => executeExportCommand
165604
166760
  });
165605
166761
  import { existsSync as existsSync75, readFileSync as readFileSync61, writeFileSync as writeFileSync26, copyFileSync as copyFileSync8, realpathSync as realpathSync11, mkdirSync as mkdirSync27 } from "fs";
165606
- import { isAbsolute as isAbsolute7, join as join82, resolve as resolve18, dirname as dirname32 } from "path";
166762
+ import { isAbsolute as isAbsolute7, join as join82, resolve as resolve19, dirname as dirname32 } from "path";
165607
166763
  import { spawnSync as spawnSync4 } from "child_process";
165608
166764
  function setShell(shell) {
165609
166765
  activeShell = shell;
@@ -165630,7 +166786,7 @@ function executeExportCommand(args) {
165630
166786
  ` };
165631
166787
  }
165632
166788
  const targetDir = args.options.targetDir ?? `./${name2}-mini-os`;
165633
- const absoluteTargetDir = isAbsolute7(targetDir) ? targetDir : resolve18(process.cwd(), targetDir);
166789
+ const absoluteTargetDir = isAbsolute7(targetDir) ? targetDir : resolve19(process.cwd(), targetDir);
165634
166790
  let result;
165635
166791
  try {
165636
166792
  result = runGenerate({
@@ -165687,7 +166843,7 @@ ${packResult.stdout}
165687
166843
  let tgzPath = join82(absoluteTargetDir, tgzName);
165688
166844
  if (args.options.output) {
165689
166845
  const outputPath = args.options.output;
165690
- const absoluteOutput = isAbsolute7(outputPath) ? outputPath : resolve18(process.cwd(), outputPath);
166846
+ const absoluteOutput = isAbsolute7(outputPath) ? outputPath : resolve19(process.cwd(), outputPath);
165691
166847
  const outputDir = dirname32(absoluteOutput);
165692
166848
  if (!fs24.existsSync(outputDir)) {
165693
166849
  fs24.mkdirSync(outputDir, { recursive: true });
@@ -166002,7 +167158,7 @@ import { chmod } from "fs/promises";
166002
167158
  import { createInterface as createInterface4 } from "readline";
166003
167159
  async function askMasked(prompt) {
166004
167160
  const rl = createInterface4({ input: process.stdin, output: process.stdout });
166005
- const answer = await new Promise((resolve19) => {
167161
+ const answer = await new Promise((resolve20) => {
166006
167162
  process.stdout.write(prompt);
166007
167163
  process.stdin.setRawMode?.(true);
166008
167164
  process.stdin.resume();
@@ -166017,7 +167173,7 @@ async function askMasked(prompt) {
166017
167173
  process.stdout.write(`
166018
167174
  `);
166019
167175
  rl.close();
166020
- resolve19(value);
167176
+ resolve20(value);
166021
167177
  return;
166022
167178
  } else if (ch === "\x03") {
166023
167179
  process.exit(130);
@@ -166039,10 +167195,10 @@ async function askMasked(prompt) {
166039
167195
  async function ask(question, defaultValue) {
166040
167196
  const rl = createInterface4({ input: process.stdin, output: process.stdout });
166041
167197
  const d = defaultValue ? ` (${defaultValue})` : "";
166042
- const answer = await new Promise((resolve19) => {
167198
+ const answer = await new Promise((resolve20) => {
166043
167199
  rl.question(`${question}${d}: `, (a2) => {
166044
167200
  rl.close();
166045
- resolve19(a2);
167201
+ resolve20(a2);
166046
167202
  });
166047
167203
  });
166048
167204
  return answer.trim() || defaultValue || "";
@@ -166145,7 +167301,7 @@ function isValidType(type2) {
166145
167301
  return VALID_TYPES.includes(type2);
166146
167302
  }
166147
167303
  async function readMaskedToken(prompt) {
166148
- return new Promise((resolve19, reject) => {
167304
+ return new Promise((resolve20, reject) => {
166149
167305
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
166150
167306
  reject(new Error("Interactive mode requires a TTY. Use --token <value> instead."));
166151
167307
  return;
@@ -166165,7 +167321,7 @@ async function readMaskedToken(prompt) {
166165
167321
  process.stdin.setRawMode(false);
166166
167322
  process.stdin.pause();
166167
167323
  process.stdin.off("data", onData);
166168
- resolve19(token);
167324
+ resolve20(token);
166169
167325
  return;
166170
167326
  }
166171
167327
  if (code === 127 || code === 8) {
@@ -166350,13 +167506,13 @@ function isTelegramAdoptCommand(env5) {
166350
167506
  }
166351
167507
  async function runCliCommand(args, replyMsg) {
166352
167508
  const started = Date.now();
166353
- return new Promise((resolve19) => {
167509
+ return new Promise((resolve20) => {
166354
167510
  let settled = false;
166355
167511
  const finish = (result) => {
166356
167512
  if (settled)
166357
167513
  return;
166358
167514
  settled = true;
166359
- resolve19({ ...result, durationMs: Date.now() - started });
167515
+ resolve20({ ...result, durationMs: Date.now() - started });
166360
167516
  };
166361
167517
  let child;
166362
167518
  try {
@@ -166382,7 +167538,7 @@ async function handleGatewayMessage(env5, opts = {}) {
166382
167538
  const cwd = opts.cwd ?? process.cwd();
166383
167539
  const timeoutMs = opts.timeoutMs ?? 120000;
166384
167540
  const started = Date.now();
166385
- return new Promise((resolve19) => {
167541
+ return new Promise((resolve20) => {
166386
167542
  let stdout2 = "";
166387
167543
  let stderr = "";
166388
167544
  let settled = false;
@@ -166390,7 +167546,7 @@ async function handleGatewayMessage(env5, opts = {}) {
166390
167546
  if (settled)
166391
167547
  return;
166392
167548
  settled = true;
166393
- resolve19({ ...result, durationMs: Date.now() - started });
167549
+ resolve20({ ...result, durationMs: Date.now() - started });
166394
167550
  };
166395
167551
  let child;
166396
167552
  try {
@@ -166471,7 +167627,7 @@ __export(exports_gateway_start, {
166471
167627
  buildGatewayConfig: () => buildGatewayConfig
166472
167628
  });
166473
167629
  import { readFileSync as readFileSync64, existsSync as existsSync79 } from "fs";
166474
- import { resolve as resolve19 } from "path";
167630
+ import { resolve as resolve20 } from "path";
166475
167631
  import { execSync as execSync2 } from "child_process";
166476
167632
  function resolveMatrixosCommand(fallback = "matrixos") {
166477
167633
  try {
@@ -166611,7 +167767,7 @@ var ENV_PATH, DEFAULT_MATRIXOS_COMMAND;
166611
167767
  var init_gateway_start = __esm(() => {
166612
167768
  init_src4();
166613
167769
  init_gateway_handler();
166614
- ENV_PATH = resolve19(process.cwd(), ".klc-gateway.env");
167770
+ ENV_PATH = resolve20(process.cwd(), ".klc-gateway.env");
166615
167771
  DEFAULT_MATRIXOS_COMMAND = resolveMatrixosCommand();
166616
167772
  });
166617
167773
 
@@ -166633,18 +167789,18 @@ var init_deployment_core = __esm(() => {
166633
167789
  // packages/omo-opencode/src/deployment/deploy-static.ts
166634
167790
  import { spawn as spawn6 } from "child_process";
166635
167791
  import { existsSync as existsSync80 } from "fs";
166636
- import { resolve as resolve20 } from "path";
167792
+ import { resolve as resolve21 } from "path";
166637
167793
  function pushStage(stage, message, ok = true) {
166638
167794
  return { stage, message, ok };
166639
167795
  }
166640
167796
  function run2(cmd, args, cwd) {
166641
- return new Promise((resolve21) => {
167797
+ return new Promise((resolve22) => {
166642
167798
  let output = "";
166643
167799
  let error51 = "";
166644
167800
  const child = spawn6(cmd, args, { cwd, shell: false });
166645
167801
  child.stdout.on("data", (d) => output += d.toString());
166646
167802
  child.stderr.on("data", (d) => error51 += d.toString());
166647
- child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
167803
+ child.on("close", (code) => resolve22({ ok: code === 0, output, error: error51 }));
166648
167804
  });
166649
167805
  }
166650
167806
  var deployStatic;
@@ -166653,7 +167809,7 @@ var init_deploy_static = __esm(() => {
166653
167809
  name: "static",
166654
167810
  async deploy(ctx, params) {
166655
167811
  const stages = [];
166656
- const buildDir = resolve20(ctx.projectRoot, params.buildDir ?? "dist");
167812
+ const buildDir = resolve21(ctx.projectRoot, params.buildDir ?? "dist");
166657
167813
  const destination = params.destination;
166658
167814
  const prebuild = params.prebuild ?? "bun run build";
166659
167815
  try {
@@ -166726,13 +167882,13 @@ function pushStage2(stage, message, ok = true) {
166726
167882
  return { stage, message, ok };
166727
167883
  }
166728
167884
  function run3(cmd, args, cwd, env5) {
166729
- return new Promise((resolve21) => {
167885
+ return new Promise((resolve22) => {
166730
167886
  let output = "";
166731
167887
  let error51 = "";
166732
167888
  const child = spawn7(cmd, args, { cwd, env: { ...process.env, ...env5 }, shell: false });
166733
167889
  child.stdout.on("data", (d) => output += d.toString());
166734
167890
  child.stderr.on("data", (d) => error51 += d.toString());
166735
- child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
167891
+ child.on("close", (code) => resolve22({ ok: code === 0, output, error: error51 }));
166736
167892
  });
166737
167893
  }
166738
167894
  var deployVercel;
@@ -166798,13 +167954,13 @@ function pushStage3(stage, message, ok = true) {
166798
167954
  return { stage, message, ok };
166799
167955
  }
166800
167956
  function run4(cmd, args, cwd, env5) {
166801
- return new Promise((resolve21) => {
167957
+ return new Promise((resolve22) => {
166802
167958
  let output = "";
166803
167959
  let error51 = "";
166804
167960
  const child = spawn8(cmd, args, { cwd, env: { ...process.env, ...env5 }, shell: false });
166805
167961
  child.stdout.on("data", (d) => output += d.toString());
166806
167962
  child.stderr.on("data", (d) => error51 += d.toString());
166807
- child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
167963
+ child.on("close", (code) => resolve22({ ok: code === 0, output, error: error51 }));
166808
167964
  });
166809
167965
  }
166810
167966
  var deployVps;
@@ -166886,7 +168042,7 @@ var init_deploy_vps = __esm(() => {
166886
168042
  });
166887
168043
 
166888
168044
  // packages/omo-opencode/src/deployment/deploy-cli.ts
166889
- import { resolve as resolve21 } from "path";
168045
+ import { resolve as resolve22 } from "path";
166890
168046
  async function runDeploy(options) {
166891
168047
  const target = getTarget(options.target);
166892
168048
  if (!target) {
@@ -166899,7 +168055,7 @@ async function runDeploy(options) {
166899
168055
  console.error("No active project. Run `matrixos project switch <slug>` or pass --project-root.");
166900
168056
  return 1;
166901
168057
  }
166902
- const projectRoot = resolve21(options.projectRoot ?? getProjectDir(project.slug));
168058
+ const projectRoot = resolve22(options.projectRoot ?? getProjectDir(project.slug));
166903
168059
  const ctx = {
166904
168060
  projectRoot,
166905
168061
  projectSlug: project?.slug,
@@ -167374,6 +168530,26 @@ WantedBy=${opts.user ? "default.target" : "multi-user.target"}
167374
168530
  `;
167375
168531
  writeFileEnsureDir(path29.join(unitDir, "matrixos-gateway.service"), unit);
167376
168532
  }
168533
+ if (opts.cron !== false) {
168534
+ const unit = `[Unit]
168535
+ Description=MaTrixOS Cron Scheduler
168536
+ After=network.target
168537
+
168538
+ [Service]
168539
+ Type=simple
168540
+ User=${os15.userInfo().username}
168541
+ WorkingDirectory=${os15.homedir()}
168542
+ Environment=PATH=${envPath}
168543
+ Environment=HOME=${os15.homedir()}
168544
+ ExecStart=${bin} cron start --daemon
168545
+ Restart=always
168546
+ RestartSec=5
168547
+
168548
+ [Install]
168549
+ WantedBy=${opts.user ? "default.target" : "multi-user.target"}
168550
+ `;
168551
+ writeFileEnsureDir(path29.join(unitDir, "matrixos-cron.service"), unit);
168552
+ }
167377
168553
  console.log("[service] reloading systemd...");
167378
168554
  if (scope) {
167379
168555
  execSync3(`${scope} systemctl --user daemon-reload`, { stdio: "inherit" });
@@ -167381,20 +168557,28 @@ WantedBy=${opts.user ? "default.target" : "multi-user.target"}
167381
168557
  execSync3(`${scope} systemctl --user enable matrixos-dashboard.service`, { stdio: "inherit" });
167382
168558
  if (opts.gateway !== false)
167383
168559
  execSync3(`${scope} systemctl --user enable matrixos-gateway.service`, { stdio: "inherit" });
168560
+ if (opts.cron !== false)
168561
+ execSync3(`${scope} systemctl --user enable matrixos-cron.service`, { stdio: "inherit" });
167384
168562
  if (opts.dashboard !== false)
167385
168563
  execSync3(`${scope} systemctl --user start matrixos-dashboard.service`, { stdio: "inherit" });
167386
168564
  if (opts.gateway !== false)
167387
168565
  execSync3(`${scope} systemctl --user start matrixos-gateway.service`, { stdio: "inherit" });
168566
+ if (opts.cron !== false)
168567
+ execSync3(`${scope} systemctl --user start matrixos-cron.service`, { stdio: "inherit" });
167388
168568
  } else {
167389
168569
  execSync3("systemctl daemon-reload", { stdio: "inherit" });
167390
168570
  if (opts.dashboard !== false)
167391
168571
  execSync3("systemctl enable matrixos-dashboard.service", { stdio: "inherit" });
167392
168572
  if (opts.gateway !== false)
167393
168573
  execSync3("systemctl enable matrixos-gateway.service", { stdio: "inherit" });
168574
+ if (opts.cron !== false)
168575
+ execSync3("systemctl enable matrixos-cron.service", { stdio: "inherit" });
167394
168576
  if (opts.dashboard !== false)
167395
168577
  execSync3("systemctl start matrixos-dashboard.service", { stdio: "inherit" });
167396
168578
  if (opts.gateway !== false)
167397
168579
  execSync3("systemctl start matrixos-gateway.service", { stdio: "inherit" });
168580
+ if (opts.cron !== false)
168581
+ execSync3("systemctl start matrixos-cron.service", { stdio: "inherit" });
167398
168582
  }
167399
168583
  console.log("[service] systemd units installed and started.");
167400
168584
  }
@@ -182097,52 +183281,8 @@ async function boulder(options) {
182097
183281
  `);
182098
183282
  return 0;
182099
183283
  }
182100
- // packages/omo-opencode/src/cli/cron.ts
182101
- init_store();
182102
- var store2 = createCronStore();
182103
- function cronAdd(options) {
182104
- const job = store2.add({
182105
- name: options.name,
182106
- schedule: options.schedule,
182107
- command: options.command,
182108
- channel: options.channel,
182109
- recipient: options.recipient,
182110
- enabled: options.enabled ?? true
182111
- });
182112
- console.log(`Added: ${job.id} \u2014 ${job.name} [${job.schedule}]`);
182113
- return 0;
182114
- }
182115
- function cronList(options = {}) {
182116
- const jobs = store2.list({
182117
- enabled: options.enabled,
182118
- channel: options.channel
182119
- });
182120
- if (options.json) {
182121
- console.log(JSON.stringify(jobs, null, 2));
182122
- } else {
182123
- if (jobs.length === 0) {
182124
- console.log("No cron jobs.");
182125
- return 0;
182126
- }
182127
- for (const j of jobs) {
182128
- const status2 = j.enabled ? "enabled" : "disabled";
182129
- const delivery = j.channel ? ` \u2192 ${j.channel}/${j.recipient ?? "*"}` : "";
182130
- console.log(` ${j.id.padEnd(14)} ${status2.padEnd(9)} ${j.schedule.padEnd(12)} ${j.name}${delivery}`);
182131
- }
182132
- console.log(`
182133
- Total: ${jobs.length}`);
182134
- }
182135
- return 0;
182136
- }
182137
- function cronRemove(options) {
182138
- const ok = store2.remove(options.id);
182139
- if (ok) {
182140
- console.log(`Removed: ${options.id}`);
182141
- return 0;
182142
- }
182143
- console.error(`Not found: ${options.id}`);
182144
- return 1;
182145
- }
183284
+ // packages/omo-opencode/src/cli/runtime-commands.ts
183285
+ init_cron();
182146
183286
 
182147
183287
  // packages/daily-brief-core/src/schema.ts
182148
183288
  init_zod();
@@ -182541,13 +183681,13 @@ function isValidTransition(from, to) {
182541
183681
  }
182542
183682
  function createKanbanStore() {
182543
183683
  const cards = new Map;
182544
- let counter = 0;
183684
+ let counter2 = 0;
182545
183685
  return {
182546
183686
  add(input) {
182547
- counter += 1;
183687
+ counter2 += 1;
182548
183688
  const now = new Date().toISOString();
182549
183689
  const card = {
182550
- id: `kanban-${counter}`,
183690
+ id: `kanban-${counter2}`,
182551
183691
  title: input.title,
182552
183692
  description: input.description ?? "",
182553
183693
  status: input.status ?? "backlog",
@@ -182693,8 +183833,8 @@ import { basename as basename12, dirname as dirname24, join as join60 } from "pa
182693
183833
 
182694
183834
  // packages/skills-loader-core/src/shared/opencode-config-dir.ts
182695
183835
  import { existsSync as existsSync64, realpathSync as realpathSync8 } from "fs";
182696
- import { homedir as homedir22 } from "os";
182697
- import { join as join59, posix as posix5, resolve as resolve12, win32 as win325 } from "path";
183836
+ import { homedir as homedir23 } from "os";
183837
+ import { join as join59, posix as posix5, resolve as resolve13, win32 as win325 } from "path";
182698
183838
 
182699
183839
  // packages/skills-loader-core/src/shared/plugin-identity.ts
182700
183840
  init_src();
@@ -182727,14 +183867,14 @@ function getTauriConfigDir2(identifier) {
182727
183867
  const platform2 = process.platform;
182728
183868
  switch (platform2) {
182729
183869
  case "darwin":
182730
- return join59(homedir22(), "Library", "Application Support", identifier);
183870
+ return join59(homedir23(), "Library", "Application Support", identifier);
182731
183871
  case "win32": {
182732
- const appData = process.env.APPDATA || join59(homedir22(), "AppData", "Roaming");
183872
+ const appData = process.env.APPDATA || join59(homedir23(), "AppData", "Roaming");
182733
183873
  return win325.join(appData, identifier);
182734
183874
  }
182735
183875
  case "linux":
182736
183876
  default: {
182737
- const xdgConfig = process.env.XDG_CONFIG_HOME || join59(homedir22(), ".config");
183877
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join59(homedir23(), ".config");
182738
183878
  return join59(xdgConfig, identifier);
182739
183879
  }
182740
183880
  }
@@ -182743,7 +183883,7 @@ function resolveConfigPath3(pathValue) {
182743
183883
  if (isWslEnvironment2() && pathValue.startsWith("/")) {
182744
183884
  return posix5.normalize(pathValue);
182745
183885
  }
182746
- const resolvedPath = resolve12(pathValue);
183886
+ const resolvedPath = resolve13(pathValue);
182747
183887
  if (!existsSync64(resolvedPath))
182748
183888
  return resolvedPath;
182749
183889
  try {
@@ -182778,7 +183918,7 @@ function getWslLinuxHomeDir2(windowsConfigRoot) {
182778
183918
  function getCliDefaultConfigDir2() {
182779
183919
  const envXdgConfig = process.env.XDG_CONFIG_HOME?.trim();
182780
183920
  const shouldIgnoreWindowsXdg = envXdgConfig !== undefined && envXdgConfig.length > 0 && isWslEnvironment2() && isWindowsUserConfigRoot2(envXdgConfig);
182781
- const xdgConfig = shouldIgnoreWindowsXdg ? posix5.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join59(homedir22(), ".config");
183921
+ const xdgConfig = shouldIgnoreWindowsXdg ? posix5.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join59(homedir23(), ".config");
182782
183922
  const configDir = isWslEnvironment2() ? posix5.join(xdgConfig, "opencode") : join59(xdgConfig, "opencode");
182783
183923
  return resolveConfigPath3(configDir);
182784
183924
  }
@@ -182845,10 +183985,10 @@ function getOpenCodeSkillDirs2(options) {
182845
183985
  // packages/skills-loader-core/src/shared/project-discovery-dirs.ts
182846
183986
  import { execFileSync as execFileSync2 } from "child_process";
182847
183987
  import { existsSync as existsSync65, realpathSync as realpathSync9 } from "fs";
182848
- import { dirname as dirname25, join as join61, resolve as resolve13, win32 as win326 } from "path";
183988
+ import { dirname as dirname25, join as join61, resolve as resolve14, win32 as win326 } from "path";
182849
183989
  var worktreePathCache2 = new Map;
182850
183990
  function normalizePath2(path18) {
182851
- const resolvedPath = process.platform !== "win32" && win326.isAbsolute(path18) ? path18 : resolve13(path18);
183991
+ const resolvedPath = process.platform !== "win32" && win326.isAbsolute(path18) ? path18 : resolve14(path18);
182852
183992
  if (!existsSync65(resolvedPath)) {
182853
183993
  return resolvedPath;
182854
183994
  }
@@ -182903,7 +184043,7 @@ function findAncestorDirectories(startDirectory, targetPaths, stopDirectory) {
182903
184043
  }
182904
184044
  }
182905
184045
  function detectWorktreePath(directory) {
182906
- const resolvedDirectory = resolve13(directory);
184046
+ const resolvedDirectory = resolve14(directory);
182907
184047
  const cacheKey = pathKey2(normalizePath2(resolvedDirectory));
182908
184048
  if (worktreePathCache2.has(cacheKey)) {
182909
184049
  return worktreePathCache2.get(cacheKey);
@@ -186354,7 +187494,7 @@ function applySnapshotRetention(options) {
186354
187494
  }
186355
187495
 
186356
187496
  // packages/omo-opencode/src/cli/snapshot/snapshot.ts
186357
- import { Database as Database3 } from "bun:sqlite";
187497
+ import { Database as Database4 } from "bun:sqlite";
186358
187498
  import {
186359
187499
  existsSync as existsSync67,
186360
187500
  mkdirSync as mkdirSync21,
@@ -186385,7 +187525,7 @@ async function snapshotCli(options = {}) {
186385
187525
  };
186386
187526
  const sqlitePort = {
186387
187527
  vacuumInto(source, dest) {
186388
- const db = new Database3(source);
187528
+ const db = new Database4(source);
186389
187529
  try {
186390
187530
  db.run(`VACUUM INTO '${dest.replace(/'/g, "''")}'`);
186391
187531
  } finally {
@@ -186848,7 +187988,7 @@ function printHumanReadable2(r2) {
186848
187988
  init_data_path();
186849
187989
  import * as path23 from "path";
186850
187990
  import { writeFileSync as writeFileSync23 } from "fs";
186851
- import { Database as Database4 } from "bun:sqlite";
187991
+ import { Database as Database5 } from "bun:sqlite";
186852
187992
  function defaultDbPath() {
186853
187993
  return path23.join(getDataDir(), "opencode", "opencode.db");
186854
187994
  }
@@ -186912,7 +188052,7 @@ function summarizeMessage(row) {
186912
188052
  return { label: text, role, agent: agent2, detail: row.id };
186913
188053
  }
186914
188054
  function buildTrace(dbPath, rootSessionId, options = {}) {
186915
- const db = new Database4(dbPath, { readonly: true });
188055
+ const db = new Database5(dbPath, { readonly: true });
186916
188056
  try {
186917
188057
  const sessions = readSessions(db);
186918
188058
  const anomalies = [];
@@ -187088,8 +188228,9 @@ import { readFileSync as readFileSync58 } from "fs";
187088
188228
  import * as os12 from "os";
187089
188229
  import * as fs21 from "fs";
187090
188230
  import * as path24 from "path";
187091
- import { Database as Database5 } from "bun:sqlite";
188231
+ import { Database as Database6 } from "bun:sqlite";
187092
188232
  init_config_context();
188233
+ init_store();
187093
188234
  var BUILTIN_AGENT_NAMES2 = BuiltinAgentNameSchema.options.map((v) => v);
187094
188235
  var AGENT_DISPLAY_NAMES2 = {
187095
188236
  morpheus: "Morpheus",
@@ -187183,7 +188324,7 @@ function getDb() {
187183
188324
  if (!fs21.existsSync(OPENCODE_DB_PATH))
187184
188325
  return;
187185
188326
  try {
187186
- return new Database5(OPENCODE_DB_PATH, { readonly: true });
188327
+ return new Database6(OPENCODE_DB_PATH, { readonly: true });
187187
188328
  } catch {
187188
188329
  return;
187189
188330
  }
@@ -187192,7 +188333,7 @@ function getDbWrite() {
187192
188333
  if (!fs21.existsSync(OPENCODE_DB_PATH))
187193
188334
  return;
187194
188335
  try {
187195
- const db = new Database5(OPENCODE_DB_PATH);
188336
+ const db = new Database6(OPENCODE_DB_PATH);
187196
188337
  db.exec("PRAGMA journal_mode = WAL");
187197
188338
  return db;
187198
188339
  } catch {
@@ -187817,6 +188958,35 @@ ${row.description ? `Description: ${row.description}
187817
188958
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
187818
188959
  }
187819
188960
  },
188961
+ listCron() {
188962
+ try {
188963
+ return createCronStore().list();
188964
+ } catch {
188965
+ return [];
188966
+ }
188967
+ },
188968
+ addCron(input) {
188969
+ try {
188970
+ const job = createCronStore().add({
188971
+ name: input.name,
188972
+ schedule: input.schedule,
188973
+ command: input.command,
188974
+ channel: input.channel ?? undefined,
188975
+ enabled: true
188976
+ });
188977
+ return { ok: true, id: job.id };
188978
+ } catch (e) {
188979
+ return { ok: false, error: e instanceof Error ? e.message : String(e) };
188980
+ }
188981
+ },
188982
+ removeCron(id) {
188983
+ try {
188984
+ const ok = createCronStore().remove(id);
188985
+ return ok ? { ok: true } : { ok: false, error: "not found" };
188986
+ } catch (e) {
188987
+ return { ok: false, error: e instanceof Error ? e.message : String(e) };
188988
+ }
188989
+ },
187820
188990
  async getIncidents(limit = 50) {
187821
188991
  const lines = readJsonl("anti-loop.jsonl");
187822
188992
  if (lines.length === 0) {
@@ -187928,7 +189098,7 @@ ${row.description ? `Description: ${row.description}
187928
189098
  const dbPath = path24.resolve(os12.homedir(), ".matrixos", "memory", "episodic.db");
187929
189099
  try {
187930
189100
  if (fs21.existsSync(dbPath)) {
187931
- const db = new Database5(dbPath);
189101
+ const db = new Database6(dbPath);
187932
189102
  const tables = db.query("SELECT name FROM sqlite_master WHERE type='table'").all();
187933
189103
  const tableNames = tables.map((t2) => String(t2.name ?? ""));
187934
189104
  if (tableNames.includes("memories")) {
@@ -188224,8 +189394,25 @@ function createDashboardServer(dataProvider, config5) {
188224
189394
  }
188225
189395
  case "/api/memory":
188226
189396
  return Response.json(dataProvider.getMemory(), { headers: jsonHeaders });
188227
- case "/api/skills":
188228
- return Response.json(dataProvider.getSkills(), { headers: jsonHeaders });
189397
+ case "/api/cron": {
189398
+ if (req.method === "POST") {
189399
+ const body = await req.json();
189400
+ if (!body.name || !body.schedule || !body.command) {
189401
+ return Response.json({ ok: false, error: "name, schedule and command required" }, { status: 400, headers: jsonHeaders });
189402
+ }
189403
+ const result = dataProvider.addCron(body);
189404
+ return Response.json(result, { status: result.ok ? 201 : 500, headers: jsonHeaders });
189405
+ }
189406
+ if (req.method === "DELETE") {
189407
+ const id = url3.searchParams.get("id");
189408
+ if (!id) {
189409
+ return Response.json({ ok: false, error: "id required" }, { status: 400, headers: jsonHeaders });
189410
+ }
189411
+ const result = dataProvider.removeCron(id);
189412
+ return Response.json(result, { status: result.ok ? 200 : 500, headers: jsonHeaders });
189413
+ }
189414
+ return Response.json(dataProvider.listCron(), { headers: jsonHeaders });
189415
+ }
188229
189416
  case "/api/skills/create": {
188230
189417
  if (req.method !== "POST") {
188231
189418
  return new Response("Method Not Allowed", { status: 405, headers: corsHeaders });
@@ -188337,14 +189524,14 @@ async function dashboardCli(options) {
188337
189524
  console.log(`[dashboard] ready \u2014 http://${host}:${port3}`);
188338
189525
  if (!options.daemon) {
188339
189526
  console.log("[dashboard] press Ctrl+C to stop");
188340
- await new Promise((resolve16) => {
189527
+ await new Promise((resolve17) => {
188341
189528
  process.on("SIGINT", () => {
188342
189529
  server2.stop();
188343
- resolve16();
189530
+ resolve17();
188344
189531
  });
188345
189532
  process.on("SIGTERM", () => {
188346
189533
  server2.stop();
188347
- resolve16();
189534
+ resolve17();
188348
189535
  });
188349
189536
  });
188350
189537
  } else {
@@ -189094,6 +190281,43 @@ For channel-specific setup, use:
189094
190281
  function runCli() {
189095
190282
  program2.parse();
189096
190283
  }
190284
+ var cron3 = program2.command("cron").description("Cron / Scheduled jobs (durable, SQLite-backed)");
190285
+ cron3.command("add <name> <schedule> <command>").description("Add a scheduled job. Schedule is a cron expression, e.g. '0 9 * * 1'").option("-c, --channel <channel>", "Delivery channel (telegram/discord/whatsapp)").option("-r, --recipient <id>", "Delivery recipient id").option("--disabled", "Create disabled").option("--json", "Output as JSON").addHelpText("after", `
190286
+ Examples:
190287
+ $ matrixos cron add "daily brief" "0 9 * * *" "matrixos run --agent TheOracle 'daily brief'"
190288
+ $ matrixos cron add "weekly audit" "0 22 * * 0" "matrixos self-audit" --channel telegram
190289
+ `).action(async (name2, schedule2, command, options) => {
190290
+ const { cronAdd: cronAdd2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190291
+ const code = cronAdd2({
190292
+ name: name2,
190293
+ schedule: schedule2,
190294
+ command,
190295
+ channel: options.channel,
190296
+ recipient: options.recipient,
190297
+ enabled: !options.disabled
190298
+ });
190299
+ process.exit(code);
190300
+ });
190301
+ cron3.command("list").description("List scheduled jobs").option("--enabled", "Only enabled jobs").option("--channel <channel>", "Filter by channel").option("--json", "Output as JSON").action(async (options) => {
190302
+ const { cronList: cronList2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190303
+ const code = cronList2({ enabled: options.enabled, channel: options.channel, json: options.json });
190304
+ process.exit(code);
190305
+ });
190306
+ cron3.command("remove <id>").description("Remove a scheduled job by id").action(async (id) => {
190307
+ const { cronRemove: cronRemove2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190308
+ const code = cronRemove2({ id });
190309
+ process.exit(code);
190310
+ });
190311
+ cron3.command("start").description("Start the cron scheduler (runs in foreground; pair with systemd for daemon mode)").option("--daemon", "Park the event loop (for systemd service)").action(async (options) => {
190312
+ const { cronStart: cronStart2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190313
+ const code = cronStart2({ daemon: options.daemon });
190314
+ process.exit(code);
190315
+ });
190316
+ cron3.command("stop").description("Stop the cron scheduler (terminates the running scheduler process)").action(async () => {
190317
+ const { cronStop: cronStop2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190318
+ const code = cronStop2();
190319
+ process.exit(code);
190320
+ });
189097
190321
  var rgpd = program2.command("rgpd").description("RGPD compliance commands \u2014 consent, forget, export (\xA718.2)");
189098
190322
  rgpd.command("forget").description("Delete user data (right to erasure)").option("--all", "Full wipe of all MaTrixOS data").option("--session-id <id>", "Delete data related to a specific session ID").option("--user-id <id>", "Delete data related to a specific user/sender ID").option("--dry-run", "Simulate only \u2014 print what would be deleted").option("--json", "Output as JSON").addHelpText("after", `
189099
190323
  Examples:
@@ -189157,7 +190381,7 @@ Examples:
189157
190381
  process.stdout.write(result.stdout);
189158
190382
  process.exit(result.exitCode);
189159
190383
  });
189160
- program2.command("service").description("Install MaTrixOS as a persistent OS service (dashboard + gateway)").argument("<action>", "install | uninstall").option("--no-dashboard", "Skip dashboard service").option("--no-gateway", "Skip gateway service").option("--user", "Install as current user (systemd --user / launchd user agent)").action(async (action, options) => {
190384
+ program2.command("service").description("Install MaTrixOS as a persistent OS service (dashboard + gateway)").argument("<action>", "install | uninstall").option("--no-dashboard", "Skip dashboard service").option("--no-gateway", "Skip gateway service").option("--no-cron", "Skip cron scheduler service").option("--user", "Install as current user (systemd --user / launchd user agent)").action(async (action, options) => {
189161
190385
  if (action !== "install" && action !== "uninstall") {
189162
190386
  console.error(`[service] unknown action: ${action}. Use 'install' or 'uninstall'.`);
189163
190387
  process.exit(1);
@@ -189170,6 +190394,7 @@ program2.command("service").description("Install MaTrixOS as a persistent OS ser
189170
190394
  const exitCode = await serviceInstallCommand2({
189171
190395
  dashboard: options.dashboard ?? true,
189172
190396
  gateway: options.gateway ?? true,
190397
+ cron: options.cron ?? true,
189173
190398
  user: options.user ?? false
189174
190399
  });
189175
190400
  process.exit(exitCode);