@kl-c/matrixos 0.3.48 → 0.3.49

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.49",
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,1117 @@ 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). Ctrl-C or 'matrixos cron stop' to exit.");
165982
+ process.stdin.resume();
165983
+ } else {
165984
+ console.log("[cron] scheduler started. Jobs will fire per their schedule. Press Ctrl-C to stop.");
165985
+ }
165986
+ return 0;
165987
+ }
165988
+ function cronStop() {
165989
+ console.log("[cron] stop is handled by terminating the scheduler process (Ctrl-C / systemd stop).");
165990
+ return 0;
165991
+ }
165992
+ var store2;
165993
+ var init_cron = __esm(() => {
165994
+ init_store();
165995
+ store2 = createCronStore();
164848
165996
  });
164849
165997
 
164850
165998
  // packages/task-ledger-core/src/schema.ts
@@ -165097,9 +166245,9 @@ var init_ledger = __esm(() => {
165097
166245
  });
165098
166246
 
165099
166247
  // packages/task-ledger-core/src/sqlite.ts
165100
- import { Database as Database2 } from "bun:sqlite";
166248
+ import { Database as Database3 } from "bun:sqlite";
165101
166249
  function createSqliteDatabase(dbPath) {
165102
- const db = new Database2(dbPath);
166250
+ const db = new Database3(dbPath);
165103
166251
  db.exec("PRAGMA journal_mode = WAL");
165104
166252
  db.exec("PRAGMA foreign_keys = ON");
165105
166253
  return {
@@ -165142,7 +166290,7 @@ __export(exports_generate, {
165142
166290
  ProfileNotFoundError: () => ProfileNotFoundError
165143
166291
  });
165144
166292
  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";
166293
+ import { dirname as dirname30, isAbsolute as isAbsolute6, join as join78, resolve as resolve17 } from "path";
165146
166294
  function profilesDirFor(opts) {
165147
166295
  if (opts.profilesDir)
165148
166296
  return opts.profilesDir;
@@ -165183,7 +166331,7 @@ function runGenerate(options) {
165183
166331
  profilesDir: options.profilesDir,
165184
166332
  fs: options.fs
165185
166333
  });
165186
- const targetDir = isAbsolute6(options.targetDir) ? options.targetDir : resolve16(process.cwd(), options.targetDir);
166334
+ const targetDir = isAbsolute6(options.targetDir) ? options.targetDir : resolve17(process.cwd(), options.targetDir);
165187
166335
  return generateMiniOS({
165188
166336
  profile: profile2,
165189
166337
  targetDir,
@@ -165238,7 +166386,7 @@ var REPO_ROOT, defaultFS2, PROFILES_RELATIVE = "assets/profiles", ProfileNotFoun
165238
166386
  var init_generate = __esm(() => {
165239
166387
  init_src5();
165240
166388
  init_src5();
165241
- REPO_ROOT = resolve16(dirname30(new URL(import.meta.url).pathname), "..", "..", "..", "..", "..");
166389
+ REPO_ROOT = resolve17(dirname30(new URL(import.meta.url).pathname), "..", "..", "..", "..", "..");
165242
166390
  defaultFS2 = { existsSync: existsSync72, readFileSync: readFileSync59, realpathSync: realpathSync10 };
165243
166391
  ProfileNotFoundError = class ProfileNotFoundError extends Error {
165244
166392
  profileName;
@@ -165357,7 +166505,7 @@ var exports_cost_report = {};
165357
166505
  __export(exports_cost_report, {
165358
166506
  executeCostReportCommand: () => executeCostReportCommand
165359
166507
  });
165360
- import { Database as Database6 } from "bun:sqlite";
166508
+ import { Database as Database7 } from "bun:sqlite";
165361
166509
  import { existsSync as existsSync73 } from "fs";
165362
166510
  import * as path28 from "path";
165363
166511
  import * as os14 from "os";
@@ -165373,7 +166521,7 @@ function executeCostReportCommand(args) {
165373
166521
  ` };
165374
166522
  }
165375
166523
  try {
165376
- const db = new Database6(dbPath);
166524
+ const db = new Database7(dbPath);
165377
166525
  const rows = queryReport(db, period);
165378
166526
  if (args.options.json) {
165379
166527
  return { exitCode: 0, stdout: JSON.stringify(rows, null, 2) + `
@@ -165494,7 +166642,7 @@ __export(exports_profile_resolve, {
165494
166642
  executeProfileResolveCommand: () => executeProfileResolveCommand
165495
166643
  });
165496
166644
  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";
166645
+ import { join as join81, resolve as resolve18, dirname as dirname31 } from "path";
165498
166646
  function executeProfileResolveCommand(args) {
165499
166647
  if (args.options.help) {
165500
166648
  return {
@@ -165592,7 +166740,7 @@ function executeProfileResolveCommand(args) {
165592
166740
  var REPO_ROOT2, PROFILES_RELATIVE2 = "assets/profiles";
165593
166741
  var init_profile_resolve = __esm(() => {
165594
166742
  init_src5();
165595
- REPO_ROOT2 = resolve17(dirname31(new URL(import.meta.url).pathname), "..", "..", "..", "..");
166743
+ REPO_ROOT2 = resolve18(dirname31(new URL(import.meta.url).pathname), "..", "..", "..", "..");
165596
166744
  });
165597
166745
 
165598
166746
  // packages/omo-opencode/src/cli/export.ts
@@ -165603,7 +166751,7 @@ __export(exports_export, {
165603
166751
  executeExportCommand: () => executeExportCommand
165604
166752
  });
165605
166753
  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";
166754
+ import { isAbsolute as isAbsolute7, join as join82, resolve as resolve19, dirname as dirname32 } from "path";
165607
166755
  import { spawnSync as spawnSync4 } from "child_process";
165608
166756
  function setShell(shell) {
165609
166757
  activeShell = shell;
@@ -165630,7 +166778,7 @@ function executeExportCommand(args) {
165630
166778
  ` };
165631
166779
  }
165632
166780
  const targetDir = args.options.targetDir ?? `./${name2}-mini-os`;
165633
- const absoluteTargetDir = isAbsolute7(targetDir) ? targetDir : resolve18(process.cwd(), targetDir);
166781
+ const absoluteTargetDir = isAbsolute7(targetDir) ? targetDir : resolve19(process.cwd(), targetDir);
165634
166782
  let result;
165635
166783
  try {
165636
166784
  result = runGenerate({
@@ -165687,7 +166835,7 @@ ${packResult.stdout}
165687
166835
  let tgzPath = join82(absoluteTargetDir, tgzName);
165688
166836
  if (args.options.output) {
165689
166837
  const outputPath = args.options.output;
165690
- const absoluteOutput = isAbsolute7(outputPath) ? outputPath : resolve18(process.cwd(), outputPath);
166838
+ const absoluteOutput = isAbsolute7(outputPath) ? outputPath : resolve19(process.cwd(), outputPath);
165691
166839
  const outputDir = dirname32(absoluteOutput);
165692
166840
  if (!fs24.existsSync(outputDir)) {
165693
166841
  fs24.mkdirSync(outputDir, { recursive: true });
@@ -166002,7 +167150,7 @@ import { chmod } from "fs/promises";
166002
167150
  import { createInterface as createInterface4 } from "readline";
166003
167151
  async function askMasked(prompt) {
166004
167152
  const rl = createInterface4({ input: process.stdin, output: process.stdout });
166005
- const answer = await new Promise((resolve19) => {
167153
+ const answer = await new Promise((resolve20) => {
166006
167154
  process.stdout.write(prompt);
166007
167155
  process.stdin.setRawMode?.(true);
166008
167156
  process.stdin.resume();
@@ -166017,7 +167165,7 @@ async function askMasked(prompt) {
166017
167165
  process.stdout.write(`
166018
167166
  `);
166019
167167
  rl.close();
166020
- resolve19(value);
167168
+ resolve20(value);
166021
167169
  return;
166022
167170
  } else if (ch === "\x03") {
166023
167171
  process.exit(130);
@@ -166039,10 +167187,10 @@ async function askMasked(prompt) {
166039
167187
  async function ask(question, defaultValue) {
166040
167188
  const rl = createInterface4({ input: process.stdin, output: process.stdout });
166041
167189
  const d = defaultValue ? ` (${defaultValue})` : "";
166042
- const answer = await new Promise((resolve19) => {
167190
+ const answer = await new Promise((resolve20) => {
166043
167191
  rl.question(`${question}${d}: `, (a2) => {
166044
167192
  rl.close();
166045
- resolve19(a2);
167193
+ resolve20(a2);
166046
167194
  });
166047
167195
  });
166048
167196
  return answer.trim() || defaultValue || "";
@@ -166145,7 +167293,7 @@ function isValidType(type2) {
166145
167293
  return VALID_TYPES.includes(type2);
166146
167294
  }
166147
167295
  async function readMaskedToken(prompt) {
166148
- return new Promise((resolve19, reject) => {
167296
+ return new Promise((resolve20, reject) => {
166149
167297
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
166150
167298
  reject(new Error("Interactive mode requires a TTY. Use --token <value> instead."));
166151
167299
  return;
@@ -166165,7 +167313,7 @@ async function readMaskedToken(prompt) {
166165
167313
  process.stdin.setRawMode(false);
166166
167314
  process.stdin.pause();
166167
167315
  process.stdin.off("data", onData);
166168
- resolve19(token);
167316
+ resolve20(token);
166169
167317
  return;
166170
167318
  }
166171
167319
  if (code === 127 || code === 8) {
@@ -166350,13 +167498,13 @@ function isTelegramAdoptCommand(env5) {
166350
167498
  }
166351
167499
  async function runCliCommand(args, replyMsg) {
166352
167500
  const started = Date.now();
166353
- return new Promise((resolve19) => {
167501
+ return new Promise((resolve20) => {
166354
167502
  let settled = false;
166355
167503
  const finish = (result) => {
166356
167504
  if (settled)
166357
167505
  return;
166358
167506
  settled = true;
166359
- resolve19({ ...result, durationMs: Date.now() - started });
167507
+ resolve20({ ...result, durationMs: Date.now() - started });
166360
167508
  };
166361
167509
  let child;
166362
167510
  try {
@@ -166382,7 +167530,7 @@ async function handleGatewayMessage(env5, opts = {}) {
166382
167530
  const cwd = opts.cwd ?? process.cwd();
166383
167531
  const timeoutMs = opts.timeoutMs ?? 120000;
166384
167532
  const started = Date.now();
166385
- return new Promise((resolve19) => {
167533
+ return new Promise((resolve20) => {
166386
167534
  let stdout2 = "";
166387
167535
  let stderr = "";
166388
167536
  let settled = false;
@@ -166390,7 +167538,7 @@ async function handleGatewayMessage(env5, opts = {}) {
166390
167538
  if (settled)
166391
167539
  return;
166392
167540
  settled = true;
166393
- resolve19({ ...result, durationMs: Date.now() - started });
167541
+ resolve20({ ...result, durationMs: Date.now() - started });
166394
167542
  };
166395
167543
  let child;
166396
167544
  try {
@@ -166471,7 +167619,7 @@ __export(exports_gateway_start, {
166471
167619
  buildGatewayConfig: () => buildGatewayConfig
166472
167620
  });
166473
167621
  import { readFileSync as readFileSync64, existsSync as existsSync79 } from "fs";
166474
- import { resolve as resolve19 } from "path";
167622
+ import { resolve as resolve20 } from "path";
166475
167623
  import { execSync as execSync2 } from "child_process";
166476
167624
  function resolveMatrixosCommand(fallback = "matrixos") {
166477
167625
  try {
@@ -166611,7 +167759,7 @@ var ENV_PATH, DEFAULT_MATRIXOS_COMMAND;
166611
167759
  var init_gateway_start = __esm(() => {
166612
167760
  init_src4();
166613
167761
  init_gateway_handler();
166614
- ENV_PATH = resolve19(process.cwd(), ".klc-gateway.env");
167762
+ ENV_PATH = resolve20(process.cwd(), ".klc-gateway.env");
166615
167763
  DEFAULT_MATRIXOS_COMMAND = resolveMatrixosCommand();
166616
167764
  });
166617
167765
 
@@ -166633,18 +167781,18 @@ var init_deployment_core = __esm(() => {
166633
167781
  // packages/omo-opencode/src/deployment/deploy-static.ts
166634
167782
  import { spawn as spawn6 } from "child_process";
166635
167783
  import { existsSync as existsSync80 } from "fs";
166636
- import { resolve as resolve20 } from "path";
167784
+ import { resolve as resolve21 } from "path";
166637
167785
  function pushStage(stage, message, ok = true) {
166638
167786
  return { stage, message, ok };
166639
167787
  }
166640
167788
  function run2(cmd, args, cwd) {
166641
- return new Promise((resolve21) => {
167789
+ return new Promise((resolve22) => {
166642
167790
  let output = "";
166643
167791
  let error51 = "";
166644
167792
  const child = spawn6(cmd, args, { cwd, shell: false });
166645
167793
  child.stdout.on("data", (d) => output += d.toString());
166646
167794
  child.stderr.on("data", (d) => error51 += d.toString());
166647
- child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
167795
+ child.on("close", (code) => resolve22({ ok: code === 0, output, error: error51 }));
166648
167796
  });
166649
167797
  }
166650
167798
  var deployStatic;
@@ -166653,7 +167801,7 @@ var init_deploy_static = __esm(() => {
166653
167801
  name: "static",
166654
167802
  async deploy(ctx, params) {
166655
167803
  const stages = [];
166656
- const buildDir = resolve20(ctx.projectRoot, params.buildDir ?? "dist");
167804
+ const buildDir = resolve21(ctx.projectRoot, params.buildDir ?? "dist");
166657
167805
  const destination = params.destination;
166658
167806
  const prebuild = params.prebuild ?? "bun run build";
166659
167807
  try {
@@ -166726,13 +167874,13 @@ function pushStage2(stage, message, ok = true) {
166726
167874
  return { stage, message, ok };
166727
167875
  }
166728
167876
  function run3(cmd, args, cwd, env5) {
166729
- return new Promise((resolve21) => {
167877
+ return new Promise((resolve22) => {
166730
167878
  let output = "";
166731
167879
  let error51 = "";
166732
167880
  const child = spawn7(cmd, args, { cwd, env: { ...process.env, ...env5 }, shell: false });
166733
167881
  child.stdout.on("data", (d) => output += d.toString());
166734
167882
  child.stderr.on("data", (d) => error51 += d.toString());
166735
- child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
167883
+ child.on("close", (code) => resolve22({ ok: code === 0, output, error: error51 }));
166736
167884
  });
166737
167885
  }
166738
167886
  var deployVercel;
@@ -166798,13 +167946,13 @@ function pushStage3(stage, message, ok = true) {
166798
167946
  return { stage, message, ok };
166799
167947
  }
166800
167948
  function run4(cmd, args, cwd, env5) {
166801
- return new Promise((resolve21) => {
167949
+ return new Promise((resolve22) => {
166802
167950
  let output = "";
166803
167951
  let error51 = "";
166804
167952
  const child = spawn8(cmd, args, { cwd, env: { ...process.env, ...env5 }, shell: false });
166805
167953
  child.stdout.on("data", (d) => output += d.toString());
166806
167954
  child.stderr.on("data", (d) => error51 += d.toString());
166807
- child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
167955
+ child.on("close", (code) => resolve22({ ok: code === 0, output, error: error51 }));
166808
167956
  });
166809
167957
  }
166810
167958
  var deployVps;
@@ -166886,7 +168034,7 @@ var init_deploy_vps = __esm(() => {
166886
168034
  });
166887
168035
 
166888
168036
  // packages/omo-opencode/src/deployment/deploy-cli.ts
166889
- import { resolve as resolve21 } from "path";
168037
+ import { resolve as resolve22 } from "path";
166890
168038
  async function runDeploy(options) {
166891
168039
  const target = getTarget(options.target);
166892
168040
  if (!target) {
@@ -166899,7 +168047,7 @@ async function runDeploy(options) {
166899
168047
  console.error("No active project. Run `matrixos project switch <slug>` or pass --project-root.");
166900
168048
  return 1;
166901
168049
  }
166902
- const projectRoot = resolve21(options.projectRoot ?? getProjectDir(project.slug));
168050
+ const projectRoot = resolve22(options.projectRoot ?? getProjectDir(project.slug));
166903
168051
  const ctx = {
166904
168052
  projectRoot,
166905
168053
  projectSlug: project?.slug,
@@ -167374,6 +168522,26 @@ WantedBy=${opts.user ? "default.target" : "multi-user.target"}
167374
168522
  `;
167375
168523
  writeFileEnsureDir(path29.join(unitDir, "matrixos-gateway.service"), unit);
167376
168524
  }
168525
+ if (opts.cron !== false) {
168526
+ const unit = `[Unit]
168527
+ Description=MaTrixOS Cron Scheduler
168528
+ After=network.target
168529
+
168530
+ [Service]
168531
+ Type=simple
168532
+ User=${os15.userInfo().username}
168533
+ WorkingDirectory=${os15.homedir()}
168534
+ Environment=PATH=${envPath}
168535
+ Environment=HOME=${os15.homedir()}
168536
+ ExecStart=${bin} cron start --daemon
168537
+ Restart=always
168538
+ RestartSec=5
168539
+
168540
+ [Install]
168541
+ WantedBy=${opts.user ? "default.target" : "multi-user.target"}
168542
+ `;
168543
+ writeFileEnsureDir(path29.join(unitDir, "matrixos-cron.service"), unit);
168544
+ }
167377
168545
  console.log("[service] reloading systemd...");
167378
168546
  if (scope) {
167379
168547
  execSync3(`${scope} systemctl --user daemon-reload`, { stdio: "inherit" });
@@ -167381,20 +168549,28 @@ WantedBy=${opts.user ? "default.target" : "multi-user.target"}
167381
168549
  execSync3(`${scope} systemctl --user enable matrixos-dashboard.service`, { stdio: "inherit" });
167382
168550
  if (opts.gateway !== false)
167383
168551
  execSync3(`${scope} systemctl --user enable matrixos-gateway.service`, { stdio: "inherit" });
168552
+ if (opts.cron !== false)
168553
+ execSync3(`${scope} systemctl --user enable matrixos-cron.service`, { stdio: "inherit" });
167384
168554
  if (opts.dashboard !== false)
167385
168555
  execSync3(`${scope} systemctl --user start matrixos-dashboard.service`, { stdio: "inherit" });
167386
168556
  if (opts.gateway !== false)
167387
168557
  execSync3(`${scope} systemctl --user start matrixos-gateway.service`, { stdio: "inherit" });
168558
+ if (opts.cron !== false)
168559
+ execSync3(`${scope} systemctl --user start matrixos-cron.service`, { stdio: "inherit" });
167388
168560
  } else {
167389
168561
  execSync3("systemctl daemon-reload", { stdio: "inherit" });
167390
168562
  if (opts.dashboard !== false)
167391
168563
  execSync3("systemctl enable matrixos-dashboard.service", { stdio: "inherit" });
167392
168564
  if (opts.gateway !== false)
167393
168565
  execSync3("systemctl enable matrixos-gateway.service", { stdio: "inherit" });
168566
+ if (opts.cron !== false)
168567
+ execSync3("systemctl enable matrixos-cron.service", { stdio: "inherit" });
167394
168568
  if (opts.dashboard !== false)
167395
168569
  execSync3("systemctl start matrixos-dashboard.service", { stdio: "inherit" });
167396
168570
  if (opts.gateway !== false)
167397
168571
  execSync3("systemctl start matrixos-gateway.service", { stdio: "inherit" });
168572
+ if (opts.cron !== false)
168573
+ execSync3("systemctl start matrixos-cron.service", { stdio: "inherit" });
167398
168574
  }
167399
168575
  console.log("[service] systemd units installed and started.");
167400
168576
  }
@@ -182097,52 +183273,8 @@ async function boulder(options) {
182097
183273
  `);
182098
183274
  return 0;
182099
183275
  }
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
- }
183276
+ // packages/omo-opencode/src/cli/runtime-commands.ts
183277
+ init_cron();
182146
183278
 
182147
183279
  // packages/daily-brief-core/src/schema.ts
182148
183280
  init_zod();
@@ -182541,13 +183673,13 @@ function isValidTransition(from, to) {
182541
183673
  }
182542
183674
  function createKanbanStore() {
182543
183675
  const cards = new Map;
182544
- let counter = 0;
183676
+ let counter2 = 0;
182545
183677
  return {
182546
183678
  add(input) {
182547
- counter += 1;
183679
+ counter2 += 1;
182548
183680
  const now = new Date().toISOString();
182549
183681
  const card = {
182550
- id: `kanban-${counter}`,
183682
+ id: `kanban-${counter2}`,
182551
183683
  title: input.title,
182552
183684
  description: input.description ?? "",
182553
183685
  status: input.status ?? "backlog",
@@ -182693,8 +183825,8 @@ import { basename as basename12, dirname as dirname24, join as join60 } from "pa
182693
183825
 
182694
183826
  // packages/skills-loader-core/src/shared/opencode-config-dir.ts
182695
183827
  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";
183828
+ import { homedir as homedir23 } from "os";
183829
+ import { join as join59, posix as posix5, resolve as resolve13, win32 as win325 } from "path";
182698
183830
 
182699
183831
  // packages/skills-loader-core/src/shared/plugin-identity.ts
182700
183832
  init_src();
@@ -182727,14 +183859,14 @@ function getTauriConfigDir2(identifier) {
182727
183859
  const platform2 = process.platform;
182728
183860
  switch (platform2) {
182729
183861
  case "darwin":
182730
- return join59(homedir22(), "Library", "Application Support", identifier);
183862
+ return join59(homedir23(), "Library", "Application Support", identifier);
182731
183863
  case "win32": {
182732
- const appData = process.env.APPDATA || join59(homedir22(), "AppData", "Roaming");
183864
+ const appData = process.env.APPDATA || join59(homedir23(), "AppData", "Roaming");
182733
183865
  return win325.join(appData, identifier);
182734
183866
  }
182735
183867
  case "linux":
182736
183868
  default: {
182737
- const xdgConfig = process.env.XDG_CONFIG_HOME || join59(homedir22(), ".config");
183869
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join59(homedir23(), ".config");
182738
183870
  return join59(xdgConfig, identifier);
182739
183871
  }
182740
183872
  }
@@ -182743,7 +183875,7 @@ function resolveConfigPath3(pathValue) {
182743
183875
  if (isWslEnvironment2() && pathValue.startsWith("/")) {
182744
183876
  return posix5.normalize(pathValue);
182745
183877
  }
182746
- const resolvedPath = resolve12(pathValue);
183878
+ const resolvedPath = resolve13(pathValue);
182747
183879
  if (!existsSync64(resolvedPath))
182748
183880
  return resolvedPath;
182749
183881
  try {
@@ -182778,7 +183910,7 @@ function getWslLinuxHomeDir2(windowsConfigRoot) {
182778
183910
  function getCliDefaultConfigDir2() {
182779
183911
  const envXdgConfig = process.env.XDG_CONFIG_HOME?.trim();
182780
183912
  const shouldIgnoreWindowsXdg = envXdgConfig !== undefined && envXdgConfig.length > 0 && isWslEnvironment2() && isWindowsUserConfigRoot2(envXdgConfig);
182781
- const xdgConfig = shouldIgnoreWindowsXdg ? posix5.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join59(homedir22(), ".config");
183913
+ const xdgConfig = shouldIgnoreWindowsXdg ? posix5.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join59(homedir23(), ".config");
182782
183914
  const configDir = isWslEnvironment2() ? posix5.join(xdgConfig, "opencode") : join59(xdgConfig, "opencode");
182783
183915
  return resolveConfigPath3(configDir);
182784
183916
  }
@@ -182845,10 +183977,10 @@ function getOpenCodeSkillDirs2(options) {
182845
183977
  // packages/skills-loader-core/src/shared/project-discovery-dirs.ts
182846
183978
  import { execFileSync as execFileSync2 } from "child_process";
182847
183979
  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";
183980
+ import { dirname as dirname25, join as join61, resolve as resolve14, win32 as win326 } from "path";
182849
183981
  var worktreePathCache2 = new Map;
182850
183982
  function normalizePath2(path18) {
182851
- const resolvedPath = process.platform !== "win32" && win326.isAbsolute(path18) ? path18 : resolve13(path18);
183983
+ const resolvedPath = process.platform !== "win32" && win326.isAbsolute(path18) ? path18 : resolve14(path18);
182852
183984
  if (!existsSync65(resolvedPath)) {
182853
183985
  return resolvedPath;
182854
183986
  }
@@ -182903,7 +184035,7 @@ function findAncestorDirectories(startDirectory, targetPaths, stopDirectory) {
182903
184035
  }
182904
184036
  }
182905
184037
  function detectWorktreePath(directory) {
182906
- const resolvedDirectory = resolve13(directory);
184038
+ const resolvedDirectory = resolve14(directory);
182907
184039
  const cacheKey = pathKey2(normalizePath2(resolvedDirectory));
182908
184040
  if (worktreePathCache2.has(cacheKey)) {
182909
184041
  return worktreePathCache2.get(cacheKey);
@@ -186354,7 +187486,7 @@ function applySnapshotRetention(options) {
186354
187486
  }
186355
187487
 
186356
187488
  // packages/omo-opencode/src/cli/snapshot/snapshot.ts
186357
- import { Database as Database3 } from "bun:sqlite";
187489
+ import { Database as Database4 } from "bun:sqlite";
186358
187490
  import {
186359
187491
  existsSync as existsSync67,
186360
187492
  mkdirSync as mkdirSync21,
@@ -186385,7 +187517,7 @@ async function snapshotCli(options = {}) {
186385
187517
  };
186386
187518
  const sqlitePort = {
186387
187519
  vacuumInto(source, dest) {
186388
- const db = new Database3(source);
187520
+ const db = new Database4(source);
186389
187521
  try {
186390
187522
  db.run(`VACUUM INTO '${dest.replace(/'/g, "''")}'`);
186391
187523
  } finally {
@@ -186848,7 +187980,7 @@ function printHumanReadable2(r2) {
186848
187980
  init_data_path();
186849
187981
  import * as path23 from "path";
186850
187982
  import { writeFileSync as writeFileSync23 } from "fs";
186851
- import { Database as Database4 } from "bun:sqlite";
187983
+ import { Database as Database5 } from "bun:sqlite";
186852
187984
  function defaultDbPath() {
186853
187985
  return path23.join(getDataDir(), "opencode", "opencode.db");
186854
187986
  }
@@ -186912,7 +188044,7 @@ function summarizeMessage(row) {
186912
188044
  return { label: text, role, agent: agent2, detail: row.id };
186913
188045
  }
186914
188046
  function buildTrace(dbPath, rootSessionId, options = {}) {
186915
- const db = new Database4(dbPath, { readonly: true });
188047
+ const db = new Database5(dbPath, { readonly: true });
186916
188048
  try {
186917
188049
  const sessions = readSessions(db);
186918
188050
  const anomalies = [];
@@ -187088,8 +188220,9 @@ import { readFileSync as readFileSync58 } from "fs";
187088
188220
  import * as os12 from "os";
187089
188221
  import * as fs21 from "fs";
187090
188222
  import * as path24 from "path";
187091
- import { Database as Database5 } from "bun:sqlite";
188223
+ import { Database as Database6 } from "bun:sqlite";
187092
188224
  init_config_context();
188225
+ init_store();
187093
188226
  var BUILTIN_AGENT_NAMES2 = BuiltinAgentNameSchema.options.map((v) => v);
187094
188227
  var AGENT_DISPLAY_NAMES2 = {
187095
188228
  morpheus: "Morpheus",
@@ -187183,7 +188316,7 @@ function getDb() {
187183
188316
  if (!fs21.existsSync(OPENCODE_DB_PATH))
187184
188317
  return;
187185
188318
  try {
187186
- return new Database5(OPENCODE_DB_PATH, { readonly: true });
188319
+ return new Database6(OPENCODE_DB_PATH, { readonly: true });
187187
188320
  } catch {
187188
188321
  return;
187189
188322
  }
@@ -187192,7 +188325,7 @@ function getDbWrite() {
187192
188325
  if (!fs21.existsSync(OPENCODE_DB_PATH))
187193
188326
  return;
187194
188327
  try {
187195
- const db = new Database5(OPENCODE_DB_PATH);
188328
+ const db = new Database6(OPENCODE_DB_PATH);
187196
188329
  db.exec("PRAGMA journal_mode = WAL");
187197
188330
  return db;
187198
188331
  } catch {
@@ -187817,6 +188950,35 @@ ${row.description ? `Description: ${row.description}
187817
188950
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
187818
188951
  }
187819
188952
  },
188953
+ listCron() {
188954
+ try {
188955
+ return createCronStore().list();
188956
+ } catch {
188957
+ return [];
188958
+ }
188959
+ },
188960
+ addCron(input) {
188961
+ try {
188962
+ const job = createCronStore().add({
188963
+ name: input.name,
188964
+ schedule: input.schedule,
188965
+ command: input.command,
188966
+ channel: input.channel ?? undefined,
188967
+ enabled: true
188968
+ });
188969
+ return { ok: true, id: job.id };
188970
+ } catch (e) {
188971
+ return { ok: false, error: e instanceof Error ? e.message : String(e) };
188972
+ }
188973
+ },
188974
+ removeCron(id) {
188975
+ try {
188976
+ const ok = createCronStore().remove(id);
188977
+ return ok ? { ok: true } : { ok: false, error: "not found" };
188978
+ } catch (e) {
188979
+ return { ok: false, error: e instanceof Error ? e.message : String(e) };
188980
+ }
188981
+ },
187820
188982
  async getIncidents(limit = 50) {
187821
188983
  const lines = readJsonl("anti-loop.jsonl");
187822
188984
  if (lines.length === 0) {
@@ -187928,7 +189090,7 @@ ${row.description ? `Description: ${row.description}
187928
189090
  const dbPath = path24.resolve(os12.homedir(), ".matrixos", "memory", "episodic.db");
187929
189091
  try {
187930
189092
  if (fs21.existsSync(dbPath)) {
187931
- const db = new Database5(dbPath);
189093
+ const db = new Database6(dbPath);
187932
189094
  const tables = db.query("SELECT name FROM sqlite_master WHERE type='table'").all();
187933
189095
  const tableNames = tables.map((t2) => String(t2.name ?? ""));
187934
189096
  if (tableNames.includes("memories")) {
@@ -188224,8 +189386,25 @@ function createDashboardServer(dataProvider, config5) {
188224
189386
  }
188225
189387
  case "/api/memory":
188226
189388
  return Response.json(dataProvider.getMemory(), { headers: jsonHeaders });
188227
- case "/api/skills":
188228
- return Response.json(dataProvider.getSkills(), { headers: jsonHeaders });
189389
+ case "/api/cron": {
189390
+ if (req.method === "POST") {
189391
+ const body = await req.json();
189392
+ if (!body.name || !body.schedule || !body.command) {
189393
+ return Response.json({ ok: false, error: "name, schedule and command required" }, { status: 400, headers: jsonHeaders });
189394
+ }
189395
+ const result = dataProvider.addCron(body);
189396
+ return Response.json(result, { status: result.ok ? 201 : 500, headers: jsonHeaders });
189397
+ }
189398
+ if (req.method === "DELETE") {
189399
+ const id = url3.searchParams.get("id");
189400
+ if (!id) {
189401
+ return Response.json({ ok: false, error: "id required" }, { status: 400, headers: jsonHeaders });
189402
+ }
189403
+ const result = dataProvider.removeCron(id);
189404
+ return Response.json(result, { status: result.ok ? 200 : 500, headers: jsonHeaders });
189405
+ }
189406
+ return Response.json(dataProvider.listCron(), { headers: jsonHeaders });
189407
+ }
188229
189408
  case "/api/skills/create": {
188230
189409
  if (req.method !== "POST") {
188231
189410
  return new Response("Method Not Allowed", { status: 405, headers: corsHeaders });
@@ -188337,14 +189516,14 @@ async function dashboardCli(options) {
188337
189516
  console.log(`[dashboard] ready \u2014 http://${host}:${port3}`);
188338
189517
  if (!options.daemon) {
188339
189518
  console.log("[dashboard] press Ctrl+C to stop");
188340
- await new Promise((resolve16) => {
189519
+ await new Promise((resolve17) => {
188341
189520
  process.on("SIGINT", () => {
188342
189521
  server2.stop();
188343
- resolve16();
189522
+ resolve17();
188344
189523
  });
188345
189524
  process.on("SIGTERM", () => {
188346
189525
  server2.stop();
188347
- resolve16();
189526
+ resolve17();
188348
189527
  });
188349
189528
  });
188350
189529
  } else {
@@ -189094,6 +190273,43 @@ For channel-specific setup, use:
189094
190273
  function runCli() {
189095
190274
  program2.parse();
189096
190275
  }
190276
+ var cron3 = program2.command("cron").description("Cron / Scheduled jobs (durable, SQLite-backed)");
190277
+ 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", `
190278
+ Examples:
190279
+ $ matrixos cron add "daily brief" "0 9 * * *" "matrixos run --agent TheOracle 'daily brief'"
190280
+ $ matrixos cron add "weekly audit" "0 22 * * 0" "matrixos self-audit" --channel telegram
190281
+ `).action(async (name2, schedule2, command, options) => {
190282
+ const { cronAdd: cronAdd2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190283
+ const code = cronAdd2({
190284
+ name: name2,
190285
+ schedule: schedule2,
190286
+ command,
190287
+ channel: options.channel,
190288
+ recipient: options.recipient,
190289
+ enabled: !options.disabled
190290
+ });
190291
+ process.exit(code);
190292
+ });
190293
+ 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) => {
190294
+ const { cronList: cronList2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190295
+ const code = cronList2({ enabled: options.enabled, channel: options.channel, json: options.json });
190296
+ process.exit(code);
190297
+ });
190298
+ cron3.command("remove <id>").description("Remove a scheduled job by id").action(async (id) => {
190299
+ const { cronRemove: cronRemove2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190300
+ const code = cronRemove2({ id });
190301
+ process.exit(code);
190302
+ });
190303
+ 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) => {
190304
+ const { cronStart: cronStart2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190305
+ const code = cronStart2({ daemon: options.daemon });
190306
+ process.exit(code);
190307
+ });
190308
+ cron3.command("stop").description("Stop the cron scheduler (terminates the running scheduler process)").action(async () => {
190309
+ const { cronStop: cronStop2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190310
+ const code = cronStop2();
190311
+ process.exit(code);
190312
+ });
189097
190313
  var rgpd = program2.command("rgpd").description("RGPD compliance commands \u2014 consent, forget, export (\xA718.2)");
189098
190314
  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
190315
  Examples:
@@ -189157,7 +190373,7 @@ Examples:
189157
190373
  process.stdout.write(result.stdout);
189158
190374
  process.exit(result.exitCode);
189159
190375
  });
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) => {
190376
+ 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
190377
  if (action !== "install" && action !== "uninstall") {
189162
190378
  console.error(`[service] unknown action: ${action}. Use 'install' or 'uninstall'.`);
189163
190379
  process.exit(1);
@@ -189170,6 +190386,7 @@ program2.command("service").description("Install MaTrixOS as a persistent OS ser
189170
190386
  const exitCode = await serviceInstallCommand2({
189171
190387
  dashboard: options.dashboard ?? true,
189172
190388
  gateway: options.gateway ?? true,
190389
+ cron: options.cron ?? true,
189173
190390
  user: options.user ?? false
189174
190391
  });
189175
190392
  process.exit(exitCode);