@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.
package/dist/cli/index.js CHANGED
@@ -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",
@@ -164733,15 +164733,35 @@ var require_picomatch2 = __commonJS((exports2, module2) => {
164733
164733
  });
164734
164734
 
164735
164735
  // packages/omo-opencode/src/features/cron/store.ts
164736
+ import { Database as Database2 } from "bun:sqlite";
164737
+ import { homedir as homedir22 } from "os";
164738
+ import { resolve as resolve12 } from "path";
164739
+ function openDb() {
164740
+ const db = new Database2(DB_PATH);
164741
+ db.run(`CREATE TABLE IF NOT EXISTS matrixos_cron (
164742
+ id TEXT PRIMARY KEY,
164743
+ name TEXT NOT NULL,
164744
+ schedule TEXT NOT NULL,
164745
+ command TEXT NOT NULL,
164746
+ channel TEXT,
164747
+ recipient TEXT,
164748
+ enabled INTEGER NOT NULL DEFAULT 1,
164749
+ created_at TEXT NOT NULL,
164750
+ updated_at TEXT NOT NULL
164751
+ )`);
164752
+ return db;
164753
+ }
164754
+ function nextId() {
164755
+ counter += 1;
164756
+ return `cron-${Date.now()}-${counter}`;
164757
+ }
164736
164758
  function createCronStore() {
164737
- const jobs = new Map;
164738
- let counter = 0;
164759
+ const db = openDb();
164739
164760
  return {
164740
164761
  add(input) {
164741
- counter += 1;
164742
164762
  const now = new Date().toISOString();
164743
164763
  const job = {
164744
- id: `cron-${counter}`,
164764
+ id: nextId(),
164745
164765
  name: input.name,
164746
164766
  schedule: input.schedule,
164747
164767
  command: input.command,
@@ -164752,15 +164772,17 @@ function createCronStore() {
164752
164772
  updatedAt: now
164753
164773
  };
164754
164774
  CronJobSchema.parse(job);
164755
- jobs.set(job.id, job);
164775
+ db.query(`INSERT INTO matrixos_cron (id, name, schedule, command, channel, recipient, enabled, created_at, updated_at)
164776
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(job.id, job.name, job.schedule, job.command, job.channel ?? null, job.recipient ?? null, job.enabled ? 1 : 0, job.createdAt, job.updatedAt);
164756
164777
  return job;
164757
164778
  },
164758
164779
  get(id) {
164759
- return jobs.get(id);
164780
+ const row = db.query("SELECT * FROM matrixos_cron WHERE id = ?").get(id);
164781
+ return row ? rowToJob(row) : undefined;
164760
164782
  },
164761
164783
  list(filter) {
164762
- const all = Array.from(jobs.values());
164763
- return all.filter((j) => {
164784
+ const all = db.query("SELECT * FROM matrixos_cron ORDER BY created_at DESC").all();
164785
+ return all.map(rowToJob).filter((j) => {
164764
164786
  if (filter?.enabled !== undefined && j.enabled !== filter.enabled)
164765
164787
  return false;
164766
164788
  if (filter?.channel && j.channel !== filter.channel)
@@ -164769,14 +164791,29 @@ function createCronStore() {
164769
164791
  });
164770
164792
  },
164771
164793
  remove(id) {
164772
- return jobs.delete(id);
164794
+ const res = db.query("DELETE FROM matrixos_cron WHERE id = ?").run(id);
164795
+ return res.changes > 0;
164773
164796
  },
164774
164797
  size() {
164775
- return jobs.size;
164798
+ const row = db.query("SELECT COUNT(*) as c FROM matrixos_cron").get();
164799
+ return row.c;
164776
164800
  }
164777
164801
  };
164778
164802
  }
164779
- var CronJobSchema;
164803
+ function rowToJob(row) {
164804
+ return {
164805
+ id: String(row.id),
164806
+ name: String(row.name),
164807
+ schedule: String(row.schedule),
164808
+ command: String(row.command),
164809
+ channel: row.channel ? row.channel : undefined,
164810
+ recipient: row.recipient ? String(row.recipient) : undefined,
164811
+ enabled: Number(row.enabled) === 1,
164812
+ createdAt: String(row.created_at),
164813
+ updatedAt: String(row.updated_at)
164814
+ };
164815
+ }
164816
+ var CronJobSchema, DB_PATH, counter = 0;
164780
164817
  var init_store = __esm(() => {
164781
164818
  init_zod();
164782
164819
  CronJobSchema = object({
@@ -164790,6 +164827,1125 @@ var init_store = __esm(() => {
164790
164827
  createdAt: string2(),
164791
164828
  updatedAt: string2()
164792
164829
  }).strict();
164830
+ DB_PATH = resolve12(homedir22(), ".local", "share", "opencode", "opencode.db");
164831
+ });
164832
+
164833
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/task.js
164834
+ var require_task = __commonJS((exports2, module2) => {
164835
+ var EventEmitter = __require("events");
164836
+
164837
+ class Task extends EventEmitter {
164838
+ constructor(execution) {
164839
+ super();
164840
+ if (typeof execution !== "function") {
164841
+ throw "execution must be a function";
164842
+ }
164843
+ this._execution = execution;
164844
+ }
164845
+ execute(now) {
164846
+ let exec2;
164847
+ try {
164848
+ exec2 = this._execution(now);
164849
+ } catch (error51) {
164850
+ return this.emit("task-failed", error51);
164851
+ }
164852
+ if (exec2 instanceof Promise) {
164853
+ return exec2.then(() => this.emit("task-finished")).catch((error51) => this.emit("task-failed", error51));
164854
+ } else {
164855
+ this.emit("task-finished");
164856
+ return exec2;
164857
+ }
164858
+ }
164859
+ }
164860
+ module2.exports = Task;
164861
+ });
164862
+
164863
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/month-names-conversion.js
164864
+ var require_month_names_conversion = __commonJS((exports2, module2) => {
164865
+ module2.exports = (() => {
164866
+ const months = [
164867
+ "january",
164868
+ "february",
164869
+ "march",
164870
+ "april",
164871
+ "may",
164872
+ "june",
164873
+ "july",
164874
+ "august",
164875
+ "september",
164876
+ "october",
164877
+ "november",
164878
+ "december"
164879
+ ];
164880
+ const shortMonths = [
164881
+ "jan",
164882
+ "feb",
164883
+ "mar",
164884
+ "apr",
164885
+ "may",
164886
+ "jun",
164887
+ "jul",
164888
+ "aug",
164889
+ "sep",
164890
+ "oct",
164891
+ "nov",
164892
+ "dec"
164893
+ ];
164894
+ function convertMonthName(expression, items) {
164895
+ for (let i3 = 0;i3 < items.length; i3++) {
164896
+ expression = expression.replace(new RegExp(items[i3], "gi"), parseInt(i3, 10) + 1);
164897
+ }
164898
+ return expression;
164899
+ }
164900
+ function interprete(monthExpression) {
164901
+ monthExpression = convertMonthName(monthExpression, months);
164902
+ monthExpression = convertMonthName(monthExpression, shortMonths);
164903
+ return monthExpression;
164904
+ }
164905
+ return interprete;
164906
+ })();
164907
+ });
164908
+
164909
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/week-day-names-conversion.js
164910
+ var require_week_day_names_conversion = __commonJS((exports2, module2) => {
164911
+ module2.exports = (() => {
164912
+ const weekDays = [
164913
+ "sunday",
164914
+ "monday",
164915
+ "tuesday",
164916
+ "wednesday",
164917
+ "thursday",
164918
+ "friday",
164919
+ "saturday"
164920
+ ];
164921
+ const shortWeekDays = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
164922
+ function convertWeekDayName(expression, items) {
164923
+ for (let i3 = 0;i3 < items.length; i3++) {
164924
+ expression = expression.replace(new RegExp(items[i3], "gi"), parseInt(i3, 10));
164925
+ }
164926
+ return expression;
164927
+ }
164928
+ function convertWeekDays(expression) {
164929
+ expression = expression.replace("7", "0");
164930
+ expression = convertWeekDayName(expression, weekDays);
164931
+ return convertWeekDayName(expression, shortWeekDays);
164932
+ }
164933
+ return convertWeekDays;
164934
+ })();
164935
+ });
164936
+
164937
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/asterisk-to-range-conversion.js
164938
+ var require_asterisk_to_range_conversion = __commonJS((exports2, module2) => {
164939
+ module2.exports = (() => {
164940
+ function convertAsterisk(expression, replecement) {
164941
+ if (expression.indexOf("*") !== -1) {
164942
+ return expression.replace("*", replecement);
164943
+ }
164944
+ return expression;
164945
+ }
164946
+ function convertAsterisksToRanges(expressions) {
164947
+ expressions[0] = convertAsterisk(expressions[0], "0-59");
164948
+ expressions[1] = convertAsterisk(expressions[1], "0-59");
164949
+ expressions[2] = convertAsterisk(expressions[2], "0-23");
164950
+ expressions[3] = convertAsterisk(expressions[3], "1-31");
164951
+ expressions[4] = convertAsterisk(expressions[4], "1-12");
164952
+ expressions[5] = convertAsterisk(expressions[5], "0-6");
164953
+ return expressions;
164954
+ }
164955
+ return convertAsterisksToRanges;
164956
+ })();
164957
+ });
164958
+
164959
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/range-conversion.js
164960
+ var require_range_conversion = __commonJS((exports2, module2) => {
164961
+ module2.exports = (() => {
164962
+ function replaceWithRange(expression, text, init, end) {
164963
+ const numbers = [];
164964
+ let last = parseInt(end);
164965
+ let first = parseInt(init);
164966
+ if (first > last) {
164967
+ last = parseInt(init);
164968
+ first = parseInt(end);
164969
+ }
164970
+ for (let i3 = first;i3 <= last; i3++) {
164971
+ numbers.push(i3);
164972
+ }
164973
+ return expression.replace(new RegExp(text, "i"), numbers.join());
164974
+ }
164975
+ function convertRange(expression) {
164976
+ const rangeRegEx = /(\d+)-(\d+)/;
164977
+ let match = rangeRegEx.exec(expression);
164978
+ while (match !== null && match.length > 0) {
164979
+ expression = replaceWithRange(expression, match[0], match[1], match[2]);
164980
+ match = rangeRegEx.exec(expression);
164981
+ }
164982
+ return expression;
164983
+ }
164984
+ function convertAllRanges(expressions) {
164985
+ for (let i3 = 0;i3 < expressions.length; i3++) {
164986
+ expressions[i3] = convertRange(expressions[i3]);
164987
+ }
164988
+ return expressions;
164989
+ }
164990
+ return convertAllRanges;
164991
+ })();
164992
+ });
164993
+
164994
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/step-values-conversion.js
164995
+ var require_step_values_conversion = __commonJS((exports2, module2) => {
164996
+ module2.exports = (() => {
164997
+ function convertSteps(expressions) {
164998
+ var stepValuePattern = /^(.+)\/(\w+)$/;
164999
+ for (var i3 = 0;i3 < expressions.length; i3++) {
165000
+ var match = stepValuePattern.exec(expressions[i3]);
165001
+ var isStepValue = match !== null && match.length > 0;
165002
+ if (isStepValue) {
165003
+ var baseDivider = match[2];
165004
+ if (isNaN(baseDivider)) {
165005
+ throw baseDivider + " is not a valid step value";
165006
+ }
165007
+ var values = match[1].split(",");
165008
+ var stepValues = [];
165009
+ var divider = parseInt(baseDivider, 10);
165010
+ for (var j = 0;j <= values.length; j++) {
165011
+ var value = parseInt(values[j], 10);
165012
+ if (value % divider === 0) {
165013
+ stepValues.push(value);
165014
+ }
165015
+ }
165016
+ expressions[i3] = stepValues.join(",");
165017
+ }
165018
+ }
165019
+ return expressions;
165020
+ }
165021
+ return convertSteps;
165022
+ })();
165023
+ });
165024
+
165025
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/convert-expression/index.js
165026
+ var require_convert_expression = __commonJS((exports2, module2) => {
165027
+ var monthNamesConversion = require_month_names_conversion();
165028
+ var weekDayNamesConversion = require_week_day_names_conversion();
165029
+ var convertAsterisksToRanges = require_asterisk_to_range_conversion();
165030
+ var convertRanges = require_range_conversion();
165031
+ var convertSteps = require_step_values_conversion();
165032
+ module2.exports = (() => {
165033
+ function appendSeccondExpression(expressions) {
165034
+ if (expressions.length === 5) {
165035
+ return ["0"].concat(expressions);
165036
+ }
165037
+ return expressions;
165038
+ }
165039
+ function removeSpaces(str3) {
165040
+ return str3.replace(/\s{2,}/g, " ").trim();
165041
+ }
165042
+ function normalizeIntegers(expressions) {
165043
+ for (let i3 = 0;i3 < expressions.length; i3++) {
165044
+ const numbers = expressions[i3].split(",");
165045
+ for (let j = 0;j < numbers.length; j++) {
165046
+ numbers[j] = parseInt(numbers[j]);
165047
+ }
165048
+ expressions[i3] = numbers;
165049
+ }
165050
+ return expressions;
165051
+ }
165052
+ function interprete(expression) {
165053
+ let expressions = removeSpaces(expression).split(" ");
165054
+ expressions = appendSeccondExpression(expressions);
165055
+ expressions[4] = monthNamesConversion(expressions[4]);
165056
+ expressions[5] = weekDayNamesConversion(expressions[5]);
165057
+ expressions = convertAsterisksToRanges(expressions);
165058
+ expressions = convertRanges(expressions);
165059
+ expressions = convertSteps(expressions);
165060
+ expressions = normalizeIntegers(expressions);
165061
+ return expressions.join(" ");
165062
+ }
165063
+ return interprete;
165064
+ })();
165065
+ });
165066
+
165067
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/pattern-validation.js
165068
+ var require_pattern_validation = __commonJS((exports2, module2) => {
165069
+ var convertExpression = require_convert_expression();
165070
+ var validationRegex = /^(?:\d+|\*|\*\/\d+)$/;
165071
+ function isValidExpression(expression, min2, max2) {
165072
+ const options = expression.split(",");
165073
+ for (const option of options) {
165074
+ const optionAsInt = parseInt(option, 10);
165075
+ if (!Number.isNaN(optionAsInt) && (optionAsInt < min2 || optionAsInt > max2) || !validationRegex.test(option))
165076
+ return false;
165077
+ }
165078
+ return true;
165079
+ }
165080
+ function isInvalidSecond(expression) {
165081
+ return !isValidExpression(expression, 0, 59);
165082
+ }
165083
+ function isInvalidMinute(expression) {
165084
+ return !isValidExpression(expression, 0, 59);
165085
+ }
165086
+ function isInvalidHour(expression) {
165087
+ return !isValidExpression(expression, 0, 23);
165088
+ }
165089
+ function isInvalidDayOfMonth(expression) {
165090
+ return !isValidExpression(expression, 1, 31);
165091
+ }
165092
+ function isInvalidMonth(expression) {
165093
+ return !isValidExpression(expression, 1, 12);
165094
+ }
165095
+ function isInvalidWeekDay(expression) {
165096
+ return !isValidExpression(expression, 0, 7);
165097
+ }
165098
+ function validateFields(patterns, executablePatterns) {
165099
+ if (isInvalidSecond(executablePatterns[0]))
165100
+ throw new Error(`${patterns[0]} is a invalid expression for second`);
165101
+ if (isInvalidMinute(executablePatterns[1]))
165102
+ throw new Error(`${patterns[1]} is a invalid expression for minute`);
165103
+ if (isInvalidHour(executablePatterns[2]))
165104
+ throw new Error(`${patterns[2]} is a invalid expression for hour`);
165105
+ if (isInvalidDayOfMonth(executablePatterns[3]))
165106
+ throw new Error(`${patterns[3]} is a invalid expression for day of month`);
165107
+ if (isInvalidMonth(executablePatterns[4]))
165108
+ throw new Error(`${patterns[4]} is a invalid expression for month`);
165109
+ if (isInvalidWeekDay(executablePatterns[5]))
165110
+ throw new Error(`${patterns[5]} is a invalid expression for week day`);
165111
+ }
165112
+ function validate(pattern) {
165113
+ if (typeof pattern !== "string")
165114
+ throw new TypeError("pattern must be a string!");
165115
+ const patterns = pattern.split(" ");
165116
+ const executablePatterns = convertExpression(pattern).split(" ");
165117
+ if (patterns.length === 5)
165118
+ patterns.unshift("0");
165119
+ validateFields(patterns, executablePatterns);
165120
+ }
165121
+ module2.exports = validate;
165122
+ });
165123
+
165124
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/time-matcher.js
165125
+ var require_time_matcher = __commonJS((exports2, module2) => {
165126
+ var validatePattern = require_pattern_validation();
165127
+ var convertExpression = require_convert_expression();
165128
+ function matchPattern(pattern, value) {
165129
+ if (pattern.indexOf(",") !== -1) {
165130
+ const patterns = pattern.split(",");
165131
+ return patterns.indexOf(value.toString()) !== -1;
165132
+ }
165133
+ return pattern === value.toString();
165134
+ }
165135
+
165136
+ class TimeMatcher {
165137
+ constructor(pattern, timezone) {
165138
+ validatePattern(pattern);
165139
+ this.pattern = convertExpression(pattern);
165140
+ this.timezone = timezone;
165141
+ this.expressions = this.pattern.split(" ");
165142
+ this.dtf = this.timezone ? new Intl.DateTimeFormat("en-US", {
165143
+ year: "numeric",
165144
+ month: "2-digit",
165145
+ day: "2-digit",
165146
+ hour: "2-digit",
165147
+ minute: "2-digit",
165148
+ second: "2-digit",
165149
+ hourCycle: "h23",
165150
+ fractionalSecondDigits: 3,
165151
+ timeZone: this.timezone
165152
+ }) : null;
165153
+ }
165154
+ match(date5) {
165155
+ date5 = this.apply(date5);
165156
+ const runOnSecond = matchPattern(this.expressions[0], date5.getSeconds());
165157
+ const runOnMinute = matchPattern(this.expressions[1], date5.getMinutes());
165158
+ const runOnHour = matchPattern(this.expressions[2], date5.getHours());
165159
+ const runOnDay = matchPattern(this.expressions[3], date5.getDate());
165160
+ const runOnMonth = matchPattern(this.expressions[4], date5.getMonth() + 1);
165161
+ const runOnWeekDay = matchPattern(this.expressions[5], date5.getDay());
165162
+ return runOnSecond && runOnMinute && runOnHour && runOnDay && runOnMonth && runOnWeekDay;
165163
+ }
165164
+ apply(date5) {
165165
+ if (this.dtf) {
165166
+ return new Date(this.dtf.format(date5));
165167
+ }
165168
+ return date5;
165169
+ }
165170
+ }
165171
+ module2.exports = TimeMatcher;
165172
+ });
165173
+
165174
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/scheduler.js
165175
+ var require_scheduler = __commonJS((exports2, module2) => {
165176
+ var EventEmitter = __require("events");
165177
+ var TimeMatcher = require_time_matcher();
165178
+
165179
+ class Scheduler extends EventEmitter {
165180
+ constructor(pattern, timezone, autorecover) {
165181
+ super();
165182
+ this.timeMatcher = new TimeMatcher(pattern, timezone);
165183
+ this.autorecover = autorecover;
165184
+ }
165185
+ start() {
165186
+ this.stop();
165187
+ let lastCheck = process.hrtime();
165188
+ let lastExecution = this.timeMatcher.apply(new Date);
165189
+ const matchTime = () => {
165190
+ const delay = 1000;
165191
+ const elapsedTime = process.hrtime(lastCheck);
165192
+ const elapsedMs = (elapsedTime[0] * 1e9 + elapsedTime[1]) / 1e6;
165193
+ const missedExecutions = Math.floor(elapsedMs / 1000);
165194
+ for (let i3 = missedExecutions;i3 >= 0; i3--) {
165195
+ const date5 = new Date(new Date().getTime() - i3 * 1000);
165196
+ let date_tmp = this.timeMatcher.apply(date5);
165197
+ if (lastExecution.getTime() < date_tmp.getTime() && (i3 === 0 || this.autorecover) && this.timeMatcher.match(date5)) {
165198
+ this.emit("scheduled-time-matched", date_tmp);
165199
+ date_tmp.setMilliseconds(0);
165200
+ lastExecution = date_tmp;
165201
+ }
165202
+ }
165203
+ lastCheck = process.hrtime();
165204
+ this.timeout = setTimeout(matchTime, delay);
165205
+ };
165206
+ matchTime();
165207
+ }
165208
+ stop() {
165209
+ if (this.timeout) {
165210
+ clearTimeout(this.timeout);
165211
+ }
165212
+ this.timeout = null;
165213
+ }
165214
+ }
165215
+ module2.exports = Scheduler;
165216
+ });
165217
+
165218
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/rng.js
165219
+ var require_rng = __commonJS((exports2) => {
165220
+ Object.defineProperty(exports2, "__esModule", {
165221
+ value: true
165222
+ });
165223
+ exports2.default = rng;
165224
+ var _crypto = _interopRequireDefault(__require("crypto"));
165225
+ function _interopRequireDefault(obj) {
165226
+ return obj && obj.__esModule ? obj : { default: obj };
165227
+ }
165228
+ var rnds8Pool = new Uint8Array(256);
165229
+ var poolPtr = rnds8Pool.length;
165230
+ function rng() {
165231
+ if (poolPtr > rnds8Pool.length - 16) {
165232
+ _crypto.default.randomFillSync(rnds8Pool);
165233
+ poolPtr = 0;
165234
+ }
165235
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
165236
+ }
165237
+ });
165238
+
165239
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/regex.js
165240
+ var require_regex = __commonJS((exports2) => {
165241
+ Object.defineProperty(exports2, "__esModule", {
165242
+ value: true
165243
+ });
165244
+ exports2.default = undefined;
165245
+ 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;
165246
+ exports2.default = _default4;
165247
+ });
165248
+
165249
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/validate.js
165250
+ var require_validate = __commonJS((exports2) => {
165251
+ Object.defineProperty(exports2, "__esModule", {
165252
+ value: true
165253
+ });
165254
+ exports2.default = undefined;
165255
+ var _regex2 = _interopRequireDefault(require_regex());
165256
+ function _interopRequireDefault(obj) {
165257
+ return obj && obj.__esModule ? obj : { default: obj };
165258
+ }
165259
+ function validate(uuid3) {
165260
+ return typeof uuid3 === "string" && _regex2.default.test(uuid3);
165261
+ }
165262
+ var _default4 = validate;
165263
+ exports2.default = _default4;
165264
+ });
165265
+
165266
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/stringify.js
165267
+ var require_stringify = __commonJS((exports2) => {
165268
+ Object.defineProperty(exports2, "__esModule", {
165269
+ value: true
165270
+ });
165271
+ exports2.default = undefined;
165272
+ var _validate = _interopRequireDefault(require_validate());
165273
+ function _interopRequireDefault(obj) {
165274
+ return obj && obj.__esModule ? obj : { default: obj };
165275
+ }
165276
+ var byteToHex = [];
165277
+ for (let i3 = 0;i3 < 256; ++i3) {
165278
+ byteToHex.push((i3 + 256).toString(16).substr(1));
165279
+ }
165280
+ function stringify(arr, offset = 0) {
165281
+ 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();
165282
+ if (!(0, _validate.default)(uuid3)) {
165283
+ throw TypeError("Stringified UUID is invalid");
165284
+ }
165285
+ return uuid3;
165286
+ }
165287
+ var _default4 = stringify;
165288
+ exports2.default = _default4;
165289
+ });
165290
+
165291
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/v1.js
165292
+ var require_v1 = __commonJS((exports2) => {
165293
+ Object.defineProperty(exports2, "__esModule", {
165294
+ value: true
165295
+ });
165296
+ exports2.default = undefined;
165297
+ var _rng = _interopRequireDefault(require_rng());
165298
+ var _stringify = _interopRequireDefault(require_stringify());
165299
+ function _interopRequireDefault(obj) {
165300
+ return obj && obj.__esModule ? obj : { default: obj };
165301
+ }
165302
+ var _nodeId;
165303
+ var _clockseq;
165304
+ var _lastMSecs = 0;
165305
+ var _lastNSecs = 0;
165306
+ function v1(options, buf, offset) {
165307
+ let i3 = buf && offset || 0;
165308
+ const b2 = buf || new Array(16);
165309
+ options = options || {};
165310
+ let node = options.node || _nodeId;
165311
+ let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
165312
+ if (node == null || clockseq == null) {
165313
+ const seedBytes = options.random || (options.rng || _rng.default)();
165314
+ if (node == null) {
165315
+ node = _nodeId = [seedBytes[0] | 1, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
165316
+ }
165317
+ if (clockseq == null) {
165318
+ clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383;
165319
+ }
165320
+ }
165321
+ let msecs = options.msecs !== undefined ? options.msecs : Date.now();
165322
+ let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
165323
+ const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4;
165324
+ if (dt < 0 && options.clockseq === undefined) {
165325
+ clockseq = clockseq + 1 & 16383;
165326
+ }
165327
+ if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
165328
+ nsecs = 0;
165329
+ }
165330
+ if (nsecs >= 1e4) {
165331
+ throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
165332
+ }
165333
+ _lastMSecs = msecs;
165334
+ _lastNSecs = nsecs;
165335
+ _clockseq = clockseq;
165336
+ msecs += 12219292800000;
165337
+ const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
165338
+ b2[i3++] = tl >>> 24 & 255;
165339
+ b2[i3++] = tl >>> 16 & 255;
165340
+ b2[i3++] = tl >>> 8 & 255;
165341
+ b2[i3++] = tl & 255;
165342
+ const tmh = msecs / 4294967296 * 1e4 & 268435455;
165343
+ b2[i3++] = tmh >>> 8 & 255;
165344
+ b2[i3++] = tmh & 255;
165345
+ b2[i3++] = tmh >>> 24 & 15 | 16;
165346
+ b2[i3++] = tmh >>> 16 & 255;
165347
+ b2[i3++] = clockseq >>> 8 | 128;
165348
+ b2[i3++] = clockseq & 255;
165349
+ for (let n3 = 0;n3 < 6; ++n3) {
165350
+ b2[i3 + n3] = node[n3];
165351
+ }
165352
+ return buf || (0, _stringify.default)(b2);
165353
+ }
165354
+ var _default4 = v1;
165355
+ exports2.default = _default4;
165356
+ });
165357
+
165358
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/parse.js
165359
+ var require_parse4 = __commonJS((exports2) => {
165360
+ Object.defineProperty(exports2, "__esModule", {
165361
+ value: true
165362
+ });
165363
+ exports2.default = undefined;
165364
+ var _validate = _interopRequireDefault(require_validate());
165365
+ function _interopRequireDefault(obj) {
165366
+ return obj && obj.__esModule ? obj : { default: obj };
165367
+ }
165368
+ function parse8(uuid3) {
165369
+ if (!(0, _validate.default)(uuid3)) {
165370
+ throw TypeError("Invalid UUID");
165371
+ }
165372
+ let v;
165373
+ const arr = new Uint8Array(16);
165374
+ arr[0] = (v = parseInt(uuid3.slice(0, 8), 16)) >>> 24;
165375
+ arr[1] = v >>> 16 & 255;
165376
+ arr[2] = v >>> 8 & 255;
165377
+ arr[3] = v & 255;
165378
+ arr[4] = (v = parseInt(uuid3.slice(9, 13), 16)) >>> 8;
165379
+ arr[5] = v & 255;
165380
+ arr[6] = (v = parseInt(uuid3.slice(14, 18), 16)) >>> 8;
165381
+ arr[7] = v & 255;
165382
+ arr[8] = (v = parseInt(uuid3.slice(19, 23), 16)) >>> 8;
165383
+ arr[9] = v & 255;
165384
+ arr[10] = (v = parseInt(uuid3.slice(24, 36), 16)) / 1099511627776 & 255;
165385
+ arr[11] = v / 4294967296 & 255;
165386
+ arr[12] = v >>> 24 & 255;
165387
+ arr[13] = v >>> 16 & 255;
165388
+ arr[14] = v >>> 8 & 255;
165389
+ arr[15] = v & 255;
165390
+ return arr;
165391
+ }
165392
+ var _default4 = parse8;
165393
+ exports2.default = _default4;
165394
+ });
165395
+
165396
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/v35.js
165397
+ var require_v35 = __commonJS((exports2) => {
165398
+ Object.defineProperty(exports2, "__esModule", {
165399
+ value: true
165400
+ });
165401
+ exports2.default = _default4;
165402
+ exports2.URL = exports2.DNS = undefined;
165403
+ var _stringify = _interopRequireDefault(require_stringify());
165404
+ var _parse2 = _interopRequireDefault(require_parse4());
165405
+ function _interopRequireDefault(obj) {
165406
+ return obj && obj.__esModule ? obj : { default: obj };
165407
+ }
165408
+ function stringToBytes(str3) {
165409
+ str3 = unescape(encodeURIComponent(str3));
165410
+ const bytes = [];
165411
+ for (let i3 = 0;i3 < str3.length; ++i3) {
165412
+ bytes.push(str3.charCodeAt(i3));
165413
+ }
165414
+ return bytes;
165415
+ }
165416
+ var DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
165417
+ exports2.DNS = DNS;
165418
+ var URL2 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
165419
+ exports2.URL = URL2;
165420
+ function _default4(name2, version3, hashfunc) {
165421
+ function generateUUID(value, namespace, buf, offset) {
165422
+ if (typeof value === "string") {
165423
+ value = stringToBytes(value);
165424
+ }
165425
+ if (typeof namespace === "string") {
165426
+ namespace = (0, _parse2.default)(namespace);
165427
+ }
165428
+ if (namespace.length !== 16) {
165429
+ throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
165430
+ }
165431
+ let bytes = new Uint8Array(16 + value.length);
165432
+ bytes.set(namespace);
165433
+ bytes.set(value, namespace.length);
165434
+ bytes = hashfunc(bytes);
165435
+ bytes[6] = bytes[6] & 15 | version3;
165436
+ bytes[8] = bytes[8] & 63 | 128;
165437
+ if (buf) {
165438
+ offset = offset || 0;
165439
+ for (let i3 = 0;i3 < 16; ++i3) {
165440
+ buf[offset + i3] = bytes[i3];
165441
+ }
165442
+ return buf;
165443
+ }
165444
+ return (0, _stringify.default)(bytes);
165445
+ }
165446
+ try {
165447
+ generateUUID.name = name2;
165448
+ } catch (err) {}
165449
+ generateUUID.DNS = DNS;
165450
+ generateUUID.URL = URL2;
165451
+ return generateUUID;
165452
+ }
165453
+ });
165454
+
165455
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/md5.js
165456
+ var require_md5 = __commonJS((exports2) => {
165457
+ Object.defineProperty(exports2, "__esModule", {
165458
+ value: true
165459
+ });
165460
+ exports2.default = undefined;
165461
+ var _crypto = _interopRequireDefault(__require("crypto"));
165462
+ function _interopRequireDefault(obj) {
165463
+ return obj && obj.__esModule ? obj : { default: obj };
165464
+ }
165465
+ function md5(bytes) {
165466
+ if (Array.isArray(bytes)) {
165467
+ bytes = Buffer.from(bytes);
165468
+ } else if (typeof bytes === "string") {
165469
+ bytes = Buffer.from(bytes, "utf8");
165470
+ }
165471
+ return _crypto.default.createHash("md5").update(bytes).digest();
165472
+ }
165473
+ var _default4 = md5;
165474
+ exports2.default = _default4;
165475
+ });
165476
+
165477
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/v3.js
165478
+ var require_v3 = __commonJS((exports2) => {
165479
+ Object.defineProperty(exports2, "__esModule", {
165480
+ value: true
165481
+ });
165482
+ exports2.default = undefined;
165483
+ var _v = _interopRequireDefault(require_v35());
165484
+ var _md = _interopRequireDefault(require_md5());
165485
+ function _interopRequireDefault(obj) {
165486
+ return obj && obj.__esModule ? obj : { default: obj };
165487
+ }
165488
+ var v3 = (0, _v.default)("v3", 48, _md.default);
165489
+ var _default4 = v3;
165490
+ exports2.default = _default4;
165491
+ });
165492
+
165493
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/v4.js
165494
+ var require_v4 = __commonJS((exports2) => {
165495
+ Object.defineProperty(exports2, "__esModule", {
165496
+ value: true
165497
+ });
165498
+ exports2.default = undefined;
165499
+ var _rng = _interopRequireDefault(require_rng());
165500
+ var _stringify = _interopRequireDefault(require_stringify());
165501
+ function _interopRequireDefault(obj) {
165502
+ return obj && obj.__esModule ? obj : { default: obj };
165503
+ }
165504
+ function v4(options, buf, offset) {
165505
+ options = options || {};
165506
+ const rnds = options.random || (options.rng || _rng.default)();
165507
+ rnds[6] = rnds[6] & 15 | 64;
165508
+ rnds[8] = rnds[8] & 63 | 128;
165509
+ if (buf) {
165510
+ offset = offset || 0;
165511
+ for (let i3 = 0;i3 < 16; ++i3) {
165512
+ buf[offset + i3] = rnds[i3];
165513
+ }
165514
+ return buf;
165515
+ }
165516
+ return (0, _stringify.default)(rnds);
165517
+ }
165518
+ var _default4 = v4;
165519
+ exports2.default = _default4;
165520
+ });
165521
+
165522
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/sha1.js
165523
+ var require_sha1 = __commonJS((exports2) => {
165524
+ Object.defineProperty(exports2, "__esModule", {
165525
+ value: true
165526
+ });
165527
+ exports2.default = undefined;
165528
+ var _crypto = _interopRequireDefault(__require("crypto"));
165529
+ function _interopRequireDefault(obj) {
165530
+ return obj && obj.__esModule ? obj : { default: obj };
165531
+ }
165532
+ function sha1(bytes) {
165533
+ if (Array.isArray(bytes)) {
165534
+ bytes = Buffer.from(bytes);
165535
+ } else if (typeof bytes === "string") {
165536
+ bytes = Buffer.from(bytes, "utf8");
165537
+ }
165538
+ return _crypto.default.createHash("sha1").update(bytes).digest();
165539
+ }
165540
+ var _default4 = sha1;
165541
+ exports2.default = _default4;
165542
+ });
165543
+
165544
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/v5.js
165545
+ var require_v5 = __commonJS((exports2) => {
165546
+ Object.defineProperty(exports2, "__esModule", {
165547
+ value: true
165548
+ });
165549
+ exports2.default = undefined;
165550
+ var _v = _interopRequireDefault(require_v35());
165551
+ var _sha = _interopRequireDefault(require_sha1());
165552
+ function _interopRequireDefault(obj) {
165553
+ return obj && obj.__esModule ? obj : { default: obj };
165554
+ }
165555
+ var v5 = (0, _v.default)("v5", 80, _sha.default);
165556
+ var _default4 = v5;
165557
+ exports2.default = _default4;
165558
+ });
165559
+
165560
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/nil.js
165561
+ var require_nil = __commonJS((exports2) => {
165562
+ Object.defineProperty(exports2, "__esModule", {
165563
+ value: true
165564
+ });
165565
+ exports2.default = undefined;
165566
+ var _default4 = "00000000-0000-0000-0000-000000000000";
165567
+ exports2.default = _default4;
165568
+ });
165569
+
165570
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/version.js
165571
+ var require_version = __commonJS((exports2) => {
165572
+ Object.defineProperty(exports2, "__esModule", {
165573
+ value: true
165574
+ });
165575
+ exports2.default = undefined;
165576
+ var _validate = _interopRequireDefault(require_validate());
165577
+ function _interopRequireDefault(obj) {
165578
+ return obj && obj.__esModule ? obj : { default: obj };
165579
+ }
165580
+ function version3(uuid3) {
165581
+ if (!(0, _validate.default)(uuid3)) {
165582
+ throw TypeError("Invalid UUID");
165583
+ }
165584
+ return parseInt(uuid3.substr(14, 1), 16);
165585
+ }
165586
+ var _default4 = version3;
165587
+ exports2.default = _default4;
165588
+ });
165589
+
165590
+ // node_modules/.bun/uuid@8.3.2/node_modules/uuid/dist/index.js
165591
+ var require_dist11 = __commonJS((exports2) => {
165592
+ Object.defineProperty(exports2, "__esModule", {
165593
+ value: true
165594
+ });
165595
+ Object.defineProperty(exports2, "v1", {
165596
+ enumerable: true,
165597
+ get: function() {
165598
+ return _v.default;
165599
+ }
165600
+ });
165601
+ Object.defineProperty(exports2, "v3", {
165602
+ enumerable: true,
165603
+ get: function() {
165604
+ return _v2.default;
165605
+ }
165606
+ });
165607
+ Object.defineProperty(exports2, "v4", {
165608
+ enumerable: true,
165609
+ get: function() {
165610
+ return _v3.default;
165611
+ }
165612
+ });
165613
+ Object.defineProperty(exports2, "v5", {
165614
+ enumerable: true,
165615
+ get: function() {
165616
+ return _v4.default;
165617
+ }
165618
+ });
165619
+ Object.defineProperty(exports2, "NIL", {
165620
+ enumerable: true,
165621
+ get: function() {
165622
+ return _nil.default;
165623
+ }
165624
+ });
165625
+ Object.defineProperty(exports2, "version", {
165626
+ enumerable: true,
165627
+ get: function() {
165628
+ return _version.default;
165629
+ }
165630
+ });
165631
+ Object.defineProperty(exports2, "validate", {
165632
+ enumerable: true,
165633
+ get: function() {
165634
+ return _validate.default;
165635
+ }
165636
+ });
165637
+ Object.defineProperty(exports2, "stringify", {
165638
+ enumerable: true,
165639
+ get: function() {
165640
+ return _stringify.default;
165641
+ }
165642
+ });
165643
+ Object.defineProperty(exports2, "parse", {
165644
+ enumerable: true,
165645
+ get: function() {
165646
+ return _parse2.default;
165647
+ }
165648
+ });
165649
+ var _v = _interopRequireDefault(require_v1());
165650
+ var _v2 = _interopRequireDefault(require_v3());
165651
+ var _v3 = _interopRequireDefault(require_v4());
165652
+ var _v4 = _interopRequireDefault(require_v5());
165653
+ var _nil = _interopRequireDefault(require_nil());
165654
+ var _version = _interopRequireDefault(require_version());
165655
+ var _validate = _interopRequireDefault(require_validate());
165656
+ var _stringify = _interopRequireDefault(require_stringify());
165657
+ var _parse2 = _interopRequireDefault(require_parse4());
165658
+ function _interopRequireDefault(obj) {
165659
+ return obj && obj.__esModule ? obj : { default: obj };
165660
+ }
165661
+ });
165662
+
165663
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/scheduled-task.js
165664
+ var require_scheduled_task = __commonJS((exports2, module2) => {
165665
+ var EventEmitter = __require("events");
165666
+ var Task = require_task();
165667
+ var Scheduler = require_scheduler();
165668
+ var uuid3 = require_dist11();
165669
+
165670
+ class ScheduledTask extends EventEmitter {
165671
+ constructor(cronExpression, func, options) {
165672
+ super();
165673
+ if (!options) {
165674
+ options = {
165675
+ scheduled: true,
165676
+ recoverMissedExecutions: false
165677
+ };
165678
+ }
165679
+ this.options = options;
165680
+ this.options.name = this.options.name || uuid3.v4();
165681
+ this._task = new Task(func);
165682
+ this._scheduler = new Scheduler(cronExpression, options.timezone, options.recoverMissedExecutions);
165683
+ this._scheduler.on("scheduled-time-matched", (now) => {
165684
+ this.now(now);
165685
+ });
165686
+ if (options.scheduled !== false) {
165687
+ this._scheduler.start();
165688
+ }
165689
+ if (options.runOnInit === true) {
165690
+ this.now("init");
165691
+ }
165692
+ }
165693
+ now(now = "manual") {
165694
+ let result = this._task.execute(now);
165695
+ this.emit("task-done", result);
165696
+ }
165697
+ start() {
165698
+ this._scheduler.start();
165699
+ }
165700
+ stop() {
165701
+ this._scheduler.stop();
165702
+ }
165703
+ }
165704
+ module2.exports = ScheduledTask;
165705
+ });
165706
+
165707
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/background-scheduled-task/index.js
165708
+ var require_background_scheduled_task = __commonJS((exports2, module2) => {
165709
+ var __dirname = "/root/Projets/MaTrixOS/node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/background-scheduled-task";
165710
+ var EventEmitter = __require("events");
165711
+ var path18 = __require("path");
165712
+ var { fork } = __require("child_process");
165713
+ var uuid3 = require_dist11();
165714
+ var daemonPath = `${__dirname}/daemon.js`;
165715
+
165716
+ class BackgroundScheduledTask extends EventEmitter {
165717
+ constructor(cronExpression, taskPath, options) {
165718
+ super();
165719
+ if (!options) {
165720
+ options = {
165721
+ scheduled: true,
165722
+ recoverMissedExecutions: false
165723
+ };
165724
+ }
165725
+ this.cronExpression = cronExpression;
165726
+ this.taskPath = taskPath;
165727
+ this.options = options;
165728
+ this.options.name = this.options.name || uuid3.v4();
165729
+ if (options.scheduled) {
165730
+ this.start();
165731
+ }
165732
+ }
165733
+ start() {
165734
+ this.stop();
165735
+ this.forkProcess = fork(daemonPath);
165736
+ this.forkProcess.on("message", (message) => {
165737
+ switch (message.type) {
165738
+ case "task-done":
165739
+ this.emit("task-done", message.result);
165740
+ break;
165741
+ }
165742
+ });
165743
+ let options = this.options;
165744
+ options.scheduled = true;
165745
+ this.forkProcess.send({
165746
+ type: "register",
165747
+ path: path18.resolve(this.taskPath),
165748
+ cron: this.cronExpression,
165749
+ options
165750
+ });
165751
+ }
165752
+ stop() {
165753
+ if (this.forkProcess) {
165754
+ this.forkProcess.kill();
165755
+ }
165756
+ }
165757
+ pid() {
165758
+ if (this.forkProcess) {
165759
+ return this.forkProcess.pid;
165760
+ }
165761
+ }
165762
+ isRunning() {
165763
+ return !this.forkProcess.killed;
165764
+ }
165765
+ }
165766
+ module2.exports = BackgroundScheduledTask;
165767
+ });
165768
+
165769
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/storage.js
165770
+ var require_storage = __commonJS((exports2, module2) => {
165771
+ module2.exports = (() => {
165772
+ if (!global.scheduledTasks) {
165773
+ global.scheduledTasks = new Map;
165774
+ }
165775
+ return {
165776
+ save: (task2) => {
165777
+ if (!task2.options) {
165778
+ const uuid3 = require_dist11();
165779
+ task2.options = {};
165780
+ task2.options.name = uuid3.v4();
165781
+ }
165782
+ global.scheduledTasks.set(task2.options.name, task2);
165783
+ },
165784
+ getTasks: () => {
165785
+ return global.scheduledTasks;
165786
+ }
165787
+ };
165788
+ })();
165789
+ });
165790
+
165791
+ // node_modules/.bun/node-cron@3.0.3/node_modules/node-cron/src/node-cron.js
165792
+ var require_node_cron = __commonJS((exports2, module2) => {
165793
+ var ScheduledTask = require_scheduled_task();
165794
+ var BackgroundScheduledTask = require_background_scheduled_task();
165795
+ var validation = require_pattern_validation();
165796
+ var storage3 = require_storage();
165797
+ function schedule(expression, func, options) {
165798
+ const task2 = createTask(expression, func, options);
165799
+ storage3.save(task2);
165800
+ return task2;
165801
+ }
165802
+ function createTask(expression, func, options) {
165803
+ if (typeof func === "string")
165804
+ return new BackgroundScheduledTask(expression, func, options);
165805
+ return new ScheduledTask(expression, func, options);
165806
+ }
165807
+ function validate(expression) {
165808
+ try {
165809
+ validation(expression);
165810
+ return true;
165811
+ } catch (_2) {
165812
+ return false;
165813
+ }
165814
+ }
165815
+ function getTasks() {
165816
+ return storage3.getTasks();
165817
+ }
165818
+ module2.exports = { schedule, validate, getTasks };
165819
+ });
165820
+
165821
+ // packages/omo-opencode/src/features/cron/runner.ts
165822
+ var exports_runner = {};
165823
+ __export(exports_runner, {
165824
+ CronRunner: () => CronRunner
165825
+ });
165826
+
165827
+ class CronRunner {
165828
+ store;
165829
+ deps;
165830
+ tasks = [];
165831
+ constructor(store2, deps) {
165832
+ this.store = store2;
165833
+ this.deps = deps;
165834
+ }
165835
+ start() {
165836
+ const jobs = this.store.list({ enabled: true });
165837
+ for (const job of jobs) {
165838
+ if (cron2.validate(job.schedule)) {
165839
+ const task2 = cron2.schedule(job.schedule, () => {
165840
+ this.deps.onTick(job);
165841
+ });
165842
+ this.tasks.push(task2);
165843
+ }
165844
+ }
165845
+ }
165846
+ stop() {
165847
+ for (const t2 of this.tasks) {
165848
+ t2.stop();
165849
+ }
165850
+ this.tasks = [];
165851
+ }
165852
+ }
165853
+ var cron2;
165854
+ var init_runner3 = __esm(() => {
165855
+ cron2 = __toESM(require_node_cron(), 1);
165856
+ });
165857
+
165858
+ // packages/omo-opencode/src/cli/cron.ts
165859
+ var exports_cron = {};
165860
+ __export(exports_cron, {
165861
+ cronStop: () => cronStop,
165862
+ cronStart: () => cronStart,
165863
+ cronRemove: () => cronRemove,
165864
+ cronList: () => cronList,
165865
+ cronAdd: () => cronAdd
165866
+ });
165867
+ function cronAdd(options) {
165868
+ const job = store2.add({
165869
+ name: options.name,
165870
+ schedule: options.schedule,
165871
+ command: options.command,
165872
+ channel: options.channel,
165873
+ recipient: options.recipient,
165874
+ enabled: options.enabled ?? true
165875
+ });
165876
+ console.log(`Added: ${job.id} \u2014 ${job.name} [${job.schedule}]`);
165877
+ return 0;
165878
+ }
165879
+ function cronList(options = {}) {
165880
+ const jobs = store2.list({
165881
+ enabled: options.enabled,
165882
+ channel: options.channel
165883
+ });
165884
+ if (options.json) {
165885
+ console.log(JSON.stringify(jobs, null, 2));
165886
+ } else {
165887
+ if (jobs.length === 0) {
165888
+ console.log("No cron jobs.");
165889
+ return 0;
165890
+ }
165891
+ for (const j of jobs) {
165892
+ const status2 = j.enabled ? "enabled" : "disabled";
165893
+ const delivery = j.channel ? ` \u2192 ${j.channel}/${j.recipient ?? "*"}` : "";
165894
+ console.log(` ${j.id.padEnd(14)} ${status2.padEnd(9)} ${j.schedule.padEnd(12)} ${j.name}${delivery}`);
165895
+ }
165896
+ console.log(`
165897
+ Total: ${jobs.length}`);
165898
+ }
165899
+ return 0;
165900
+ }
165901
+ function cronRemove(options) {
165902
+ const ok = store2.remove(options.id);
165903
+ if (ok) {
165904
+ console.log(`Removed: ${options.id}`);
165905
+ return 0;
165906
+ }
165907
+ console.error(`Not found: ${options.id}`);
165908
+ return 1;
165909
+ }
165910
+ function cronStart(options = {}) {
165911
+ const { CronRunner: CronRunner2 } = (init_runner3(), __toCommonJS(exports_runner));
165912
+ const runner3 = new CronRunner2(store2, {
165913
+ onTick: async (job) => {
165914
+ const { spawnSync: spawnSync4 } = __require("child_process");
165915
+ console.log(`[cron] firing ${job.name} \u2192 ${job.command}`);
165916
+ const res = spawnSync4("bash", ["-lc", job.command], { encoding: "utf-8" });
165917
+ if (res.status !== 0) {
165918
+ console.error(`[cron] ${job.name} failed:`, res.stderr || res.stdout);
165919
+ } else if (job.channel) {
165920
+ console.log(`[cron] ${job.name} done (delivery to ${job.channel} not yet wired)`);
165921
+ }
165922
+ }
165923
+ });
165924
+ runner3.start();
165925
+ if (options.daemon) {
165926
+ console.log("[cron] scheduler started (daemon). Running until stopped.");
165927
+ setInterval(() => {}, 1 << 30);
165928
+ process.on("SIGTERM", () => {
165929
+ runner3.stop();
165930
+ process.exit(0);
165931
+ });
165932
+ process.on("SIGINT", () => {
165933
+ runner3.stop();
165934
+ process.exit(0);
165935
+ });
165936
+ } else {
165937
+ console.log("[cron] scheduler started. Jobs will fire per their schedule. Press Ctrl-C to stop.");
165938
+ }
165939
+ return 0;
165940
+ }
165941
+ function cronStop() {
165942
+ console.log("[cron] stop is handled by terminating the scheduler process (Ctrl-C / systemd stop).");
165943
+ return 0;
165944
+ }
165945
+ var store2;
165946
+ var init_cron = __esm(() => {
165947
+ init_store();
165948
+ store2 = createCronStore();
164793
165949
  });
164794
165950
 
164795
165951
  // packages/task-ledger-core/src/schema.ts
@@ -165042,9 +166198,9 @@ var init_ledger = __esm(() => {
165042
166198
  });
165043
166199
 
165044
166200
  // packages/task-ledger-core/src/sqlite.ts
165045
- import { Database as Database2 } from "bun:sqlite";
166201
+ import { Database as Database3 } from "bun:sqlite";
165046
166202
  function createSqliteDatabase(dbPath) {
165047
- const db = new Database2(dbPath);
166203
+ const db = new Database3(dbPath);
165048
166204
  db.exec("PRAGMA journal_mode = WAL");
165049
166205
  db.exec("PRAGMA foreign_keys = ON");
165050
166206
  return {
@@ -165087,7 +166243,7 @@ __export(exports_generate, {
165087
166243
  ProfileNotFoundError: () => ProfileNotFoundError
165088
166244
  });
165089
166245
  import { existsSync as existsSync72, readFileSync as readFileSync59, realpathSync as realpathSync10 } from "fs";
165090
- import { dirname as dirname30, isAbsolute as isAbsolute6, join as join78, resolve as resolve16 } from "path";
166246
+ import { dirname as dirname30, isAbsolute as isAbsolute6, join as join78, resolve as resolve17 } from "path";
165091
166247
  function profilesDirFor(opts) {
165092
166248
  if (opts.profilesDir)
165093
166249
  return opts.profilesDir;
@@ -165128,7 +166284,7 @@ function runGenerate(options) {
165128
166284
  profilesDir: options.profilesDir,
165129
166285
  fs: options.fs
165130
166286
  });
165131
- const targetDir = isAbsolute6(options.targetDir) ? options.targetDir : resolve16(process.cwd(), options.targetDir);
166287
+ const targetDir = isAbsolute6(options.targetDir) ? options.targetDir : resolve17(process.cwd(), options.targetDir);
165132
166288
  return generateMiniOS({
165133
166289
  profile: profile2,
165134
166290
  targetDir,
@@ -165183,7 +166339,7 @@ var REPO_ROOT, defaultFS2, PROFILES_RELATIVE = "assets/profiles", ProfileNotFoun
165183
166339
  var init_generate = __esm(() => {
165184
166340
  init_src5();
165185
166341
  init_src5();
165186
- REPO_ROOT = resolve16(dirname30(new URL(import.meta.url).pathname), "..", "..", "..", "..", "..");
166342
+ REPO_ROOT = resolve17(dirname30(new URL(import.meta.url).pathname), "..", "..", "..", "..", "..");
165187
166343
  defaultFS2 = { existsSync: existsSync72, readFileSync: readFileSync59, realpathSync: realpathSync10 };
165188
166344
  ProfileNotFoundError = class ProfileNotFoundError extends Error {
165189
166345
  profileName;
@@ -165302,7 +166458,7 @@ var exports_cost_report = {};
165302
166458
  __export(exports_cost_report, {
165303
166459
  executeCostReportCommand: () => executeCostReportCommand
165304
166460
  });
165305
- import { Database as Database6 } from "bun:sqlite";
166461
+ import { Database as Database7 } from "bun:sqlite";
165306
166462
  import { existsSync as existsSync73 } from "fs";
165307
166463
  import * as path28 from "path";
165308
166464
  import * as os14 from "os";
@@ -165318,7 +166474,7 @@ function executeCostReportCommand(args) {
165318
166474
  ` };
165319
166475
  }
165320
166476
  try {
165321
- const db = new Database6(dbPath);
166477
+ const db = new Database7(dbPath);
165322
166478
  const rows = queryReport(db, period);
165323
166479
  if (args.options.json) {
165324
166480
  return { exitCode: 0, stdout: JSON.stringify(rows, null, 2) + `
@@ -165439,7 +166595,7 @@ __export(exports_profile_resolve, {
165439
166595
  executeProfileResolveCommand: () => executeProfileResolveCommand
165440
166596
  });
165441
166597
  import { existsSync as existsSync74, readdirSync as readdirSync16, readFileSync as readFileSync60 } from "fs";
165442
- import { join as join81, resolve as resolve17, dirname as dirname31 } from "path";
166598
+ import { join as join81, resolve as resolve18, dirname as dirname31 } from "path";
165443
166599
  function executeProfileResolveCommand(args) {
165444
166600
  if (args.options.help) {
165445
166601
  return {
@@ -165537,7 +166693,7 @@ function executeProfileResolveCommand(args) {
165537
166693
  var REPO_ROOT2, PROFILES_RELATIVE2 = "assets/profiles";
165538
166694
  var init_profile_resolve = __esm(() => {
165539
166695
  init_src5();
165540
- REPO_ROOT2 = resolve17(dirname31(new URL(import.meta.url).pathname), "..", "..", "..", "..");
166696
+ REPO_ROOT2 = resolve18(dirname31(new URL(import.meta.url).pathname), "..", "..", "..", "..");
165541
166697
  });
165542
166698
 
165543
166699
  // packages/omo-opencode/src/cli/export.ts
@@ -165548,7 +166704,7 @@ __export(exports_export, {
165548
166704
  executeExportCommand: () => executeExportCommand
165549
166705
  });
165550
166706
  import { existsSync as existsSync75, readFileSync as readFileSync61, writeFileSync as writeFileSync26, copyFileSync as copyFileSync8, realpathSync as realpathSync11, mkdirSync as mkdirSync27 } from "fs";
165551
- import { isAbsolute as isAbsolute7, join as join82, resolve as resolve18, dirname as dirname32 } from "path";
166707
+ import { isAbsolute as isAbsolute7, join as join82, resolve as resolve19, dirname as dirname32 } from "path";
165552
166708
  import { spawnSync as spawnSync4 } from "child_process";
165553
166709
  function setShell(shell) {
165554
166710
  activeShell = shell;
@@ -165575,7 +166731,7 @@ function executeExportCommand(args) {
165575
166731
  ` };
165576
166732
  }
165577
166733
  const targetDir = args.options.targetDir ?? `./${name2}-mini-os`;
165578
- const absoluteTargetDir = isAbsolute7(targetDir) ? targetDir : resolve18(process.cwd(), targetDir);
166734
+ const absoluteTargetDir = isAbsolute7(targetDir) ? targetDir : resolve19(process.cwd(), targetDir);
165579
166735
  let result;
165580
166736
  try {
165581
166737
  result = runGenerate({
@@ -165632,7 +166788,7 @@ ${packResult.stdout}
165632
166788
  let tgzPath = join82(absoluteTargetDir, tgzName);
165633
166789
  if (args.options.output) {
165634
166790
  const outputPath = args.options.output;
165635
- const absoluteOutput = isAbsolute7(outputPath) ? outputPath : resolve18(process.cwd(), outputPath);
166791
+ const absoluteOutput = isAbsolute7(outputPath) ? outputPath : resolve19(process.cwd(), outputPath);
165636
166792
  const outputDir = dirname32(absoluteOutput);
165637
166793
  if (!fs24.existsSync(outputDir)) {
165638
166794
  fs24.mkdirSync(outputDir, { recursive: true });
@@ -165947,7 +167103,7 @@ import { chmod } from "fs/promises";
165947
167103
  import { createInterface as createInterface4 } from "readline";
165948
167104
  async function askMasked(prompt) {
165949
167105
  const rl = createInterface4({ input: process.stdin, output: process.stdout });
165950
- const answer = await new Promise((resolve19) => {
167106
+ const answer = await new Promise((resolve20) => {
165951
167107
  process.stdout.write(prompt);
165952
167108
  process.stdin.setRawMode?.(true);
165953
167109
  process.stdin.resume();
@@ -165962,7 +167118,7 @@ async function askMasked(prompt) {
165962
167118
  process.stdout.write(`
165963
167119
  `);
165964
167120
  rl.close();
165965
- resolve19(value);
167121
+ resolve20(value);
165966
167122
  return;
165967
167123
  } else if (ch === "\x03") {
165968
167124
  process.exit(130);
@@ -165984,10 +167140,10 @@ async function askMasked(prompt) {
165984
167140
  async function ask(question, defaultValue) {
165985
167141
  const rl = createInterface4({ input: process.stdin, output: process.stdout });
165986
167142
  const d = defaultValue ? ` (${defaultValue})` : "";
165987
- const answer = await new Promise((resolve19) => {
167143
+ const answer = await new Promise((resolve20) => {
165988
167144
  rl.question(`${question}${d}: `, (a2) => {
165989
167145
  rl.close();
165990
- resolve19(a2);
167146
+ resolve20(a2);
165991
167147
  });
165992
167148
  });
165993
167149
  return answer.trim() || defaultValue || "";
@@ -166090,7 +167246,7 @@ function isValidType(type2) {
166090
167246
  return VALID_TYPES.includes(type2);
166091
167247
  }
166092
167248
  async function readMaskedToken(prompt) {
166093
- return new Promise((resolve19, reject) => {
167249
+ return new Promise((resolve20, reject) => {
166094
167250
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
166095
167251
  reject(new Error("Interactive mode requires a TTY. Use --token <value> instead."));
166096
167252
  return;
@@ -166110,7 +167266,7 @@ async function readMaskedToken(prompt) {
166110
167266
  process.stdin.setRawMode(false);
166111
167267
  process.stdin.pause();
166112
167268
  process.stdin.off("data", onData);
166113
- resolve19(token);
167269
+ resolve20(token);
166114
167270
  return;
166115
167271
  }
166116
167272
  if (code === 127 || code === 8) {
@@ -166295,13 +167451,13 @@ function isTelegramAdoptCommand(env5) {
166295
167451
  }
166296
167452
  async function runCliCommand(args, replyMsg) {
166297
167453
  const started = Date.now();
166298
- return new Promise((resolve19) => {
167454
+ return new Promise((resolve20) => {
166299
167455
  let settled = false;
166300
167456
  const finish = (result) => {
166301
167457
  if (settled)
166302
167458
  return;
166303
167459
  settled = true;
166304
- resolve19({ ...result, durationMs: Date.now() - started });
167460
+ resolve20({ ...result, durationMs: Date.now() - started });
166305
167461
  };
166306
167462
  let child;
166307
167463
  try {
@@ -166327,7 +167483,7 @@ async function handleGatewayMessage(env5, opts = {}) {
166327
167483
  const cwd = opts.cwd ?? process.cwd();
166328
167484
  const timeoutMs = opts.timeoutMs ?? 120000;
166329
167485
  const started = Date.now();
166330
- return new Promise((resolve19) => {
167486
+ return new Promise((resolve20) => {
166331
167487
  let stdout2 = "";
166332
167488
  let stderr = "";
166333
167489
  let settled = false;
@@ -166335,7 +167491,7 @@ async function handleGatewayMessage(env5, opts = {}) {
166335
167491
  if (settled)
166336
167492
  return;
166337
167493
  settled = true;
166338
- resolve19({ ...result, durationMs: Date.now() - started });
167494
+ resolve20({ ...result, durationMs: Date.now() - started });
166339
167495
  };
166340
167496
  let child;
166341
167497
  try {
@@ -166416,7 +167572,7 @@ __export(exports_gateway_start, {
166416
167572
  buildGatewayConfig: () => buildGatewayConfig
166417
167573
  });
166418
167574
  import { readFileSync as readFileSync64, existsSync as existsSync79 } from "fs";
166419
- import { resolve as resolve19 } from "path";
167575
+ import { resolve as resolve20 } from "path";
166420
167576
  import { execSync as execSync2 } from "child_process";
166421
167577
  function resolveMatrixosCommand(fallback = "matrixos") {
166422
167578
  try {
@@ -166556,7 +167712,7 @@ var ENV_PATH, DEFAULT_MATRIXOS_COMMAND;
166556
167712
  var init_gateway_start = __esm(() => {
166557
167713
  init_src4();
166558
167714
  init_gateway_handler();
166559
- ENV_PATH = resolve19(process.cwd(), ".klc-gateway.env");
167715
+ ENV_PATH = resolve20(process.cwd(), ".klc-gateway.env");
166560
167716
  DEFAULT_MATRIXOS_COMMAND = resolveMatrixosCommand();
166561
167717
  });
166562
167718
 
@@ -166578,18 +167734,18 @@ var init_deployment_core = __esm(() => {
166578
167734
  // packages/omo-opencode/src/deployment/deploy-static.ts
166579
167735
  import { spawn as spawn6 } from "child_process";
166580
167736
  import { existsSync as existsSync80 } from "fs";
166581
- import { resolve as resolve20 } from "path";
167737
+ import { resolve as resolve21 } from "path";
166582
167738
  function pushStage(stage, message, ok = true) {
166583
167739
  return { stage, message, ok };
166584
167740
  }
166585
167741
  function run2(cmd, args, cwd) {
166586
- return new Promise((resolve21) => {
167742
+ return new Promise((resolve22) => {
166587
167743
  let output = "";
166588
167744
  let error51 = "";
166589
167745
  const child = spawn6(cmd, args, { cwd, shell: false });
166590
167746
  child.stdout.on("data", (d) => output += d.toString());
166591
167747
  child.stderr.on("data", (d) => error51 += d.toString());
166592
- child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
167748
+ child.on("close", (code) => resolve22({ ok: code === 0, output, error: error51 }));
166593
167749
  });
166594
167750
  }
166595
167751
  var deployStatic;
@@ -166598,7 +167754,7 @@ var init_deploy_static = __esm(() => {
166598
167754
  name: "static",
166599
167755
  async deploy(ctx, params) {
166600
167756
  const stages = [];
166601
- const buildDir = resolve20(ctx.projectRoot, params.buildDir ?? "dist");
167757
+ const buildDir = resolve21(ctx.projectRoot, params.buildDir ?? "dist");
166602
167758
  const destination = params.destination;
166603
167759
  const prebuild = params.prebuild ?? "bun run build";
166604
167760
  try {
@@ -166671,13 +167827,13 @@ function pushStage2(stage, message, ok = true) {
166671
167827
  return { stage, message, ok };
166672
167828
  }
166673
167829
  function run3(cmd, args, cwd, env5) {
166674
- return new Promise((resolve21) => {
167830
+ return new Promise((resolve22) => {
166675
167831
  let output = "";
166676
167832
  let error51 = "";
166677
167833
  const child = spawn7(cmd, args, { cwd, env: { ...process.env, ...env5 }, shell: false });
166678
167834
  child.stdout.on("data", (d) => output += d.toString());
166679
167835
  child.stderr.on("data", (d) => error51 += d.toString());
166680
- child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
167836
+ child.on("close", (code) => resolve22({ ok: code === 0, output, error: error51 }));
166681
167837
  });
166682
167838
  }
166683
167839
  var deployVercel;
@@ -166743,13 +167899,13 @@ function pushStage3(stage, message, ok = true) {
166743
167899
  return { stage, message, ok };
166744
167900
  }
166745
167901
  function run4(cmd, args, cwd, env5) {
166746
- return new Promise((resolve21) => {
167902
+ return new Promise((resolve22) => {
166747
167903
  let output = "";
166748
167904
  let error51 = "";
166749
167905
  const child = spawn8(cmd, args, { cwd, env: { ...process.env, ...env5 }, shell: false });
166750
167906
  child.stdout.on("data", (d) => output += d.toString());
166751
167907
  child.stderr.on("data", (d) => error51 += d.toString());
166752
- child.on("close", (code) => resolve21({ ok: code === 0, output, error: error51 }));
167908
+ child.on("close", (code) => resolve22({ ok: code === 0, output, error: error51 }));
166753
167909
  });
166754
167910
  }
166755
167911
  var deployVps;
@@ -166831,7 +167987,7 @@ var init_deploy_vps = __esm(() => {
166831
167987
  });
166832
167988
 
166833
167989
  // packages/omo-opencode/src/deployment/deploy-cli.ts
166834
- import { resolve as resolve21 } from "path";
167990
+ import { resolve as resolve22 } from "path";
166835
167991
  async function runDeploy(options) {
166836
167992
  const target = getTarget(options.target);
166837
167993
  if (!target) {
@@ -166844,7 +168000,7 @@ async function runDeploy(options) {
166844
168000
  console.error("No active project. Run `matrixos project switch <slug>` or pass --project-root.");
166845
168001
  return 1;
166846
168002
  }
166847
- const projectRoot = resolve21(options.projectRoot ?? getProjectDir(project.slug));
168003
+ const projectRoot = resolve22(options.projectRoot ?? getProjectDir(project.slug));
166848
168004
  const ctx = {
166849
168005
  projectRoot,
166850
168006
  projectSlug: project?.slug,
@@ -167319,6 +168475,26 @@ WantedBy=${opts.user ? "default.target" : "multi-user.target"}
167319
168475
  `;
167320
168476
  writeFileEnsureDir(path29.join(unitDir, "matrixos-gateway.service"), unit);
167321
168477
  }
168478
+ if (opts.cron !== false) {
168479
+ const unit = `[Unit]
168480
+ Description=MaTrixOS Cron Scheduler
168481
+ After=network.target
168482
+
168483
+ [Service]
168484
+ Type=simple
168485
+ User=${os15.userInfo().username}
168486
+ WorkingDirectory=${os15.homedir()}
168487
+ Environment=PATH=${envPath}
168488
+ Environment=HOME=${os15.homedir()}
168489
+ ExecStart=${bin} cron start --daemon
168490
+ Restart=always
168491
+ RestartSec=5
168492
+
168493
+ [Install]
168494
+ WantedBy=${opts.user ? "default.target" : "multi-user.target"}
168495
+ `;
168496
+ writeFileEnsureDir(path29.join(unitDir, "matrixos-cron.service"), unit);
168497
+ }
167322
168498
  console.log("[service] reloading systemd...");
167323
168499
  if (scope) {
167324
168500
  execSync3(`${scope} systemctl --user daemon-reload`, { stdio: "inherit" });
@@ -167326,20 +168502,28 @@ WantedBy=${opts.user ? "default.target" : "multi-user.target"}
167326
168502
  execSync3(`${scope} systemctl --user enable matrixos-dashboard.service`, { stdio: "inherit" });
167327
168503
  if (opts.gateway !== false)
167328
168504
  execSync3(`${scope} systemctl --user enable matrixos-gateway.service`, { stdio: "inherit" });
168505
+ if (opts.cron !== false)
168506
+ execSync3(`${scope} systemctl --user enable matrixos-cron.service`, { stdio: "inherit" });
167329
168507
  if (opts.dashboard !== false)
167330
168508
  execSync3(`${scope} systemctl --user start matrixos-dashboard.service`, { stdio: "inherit" });
167331
168509
  if (opts.gateway !== false)
167332
168510
  execSync3(`${scope} systemctl --user start matrixos-gateway.service`, { stdio: "inherit" });
168511
+ if (opts.cron !== false)
168512
+ execSync3(`${scope} systemctl --user start matrixos-cron.service`, { stdio: "inherit" });
167333
168513
  } else {
167334
168514
  execSync3("systemctl daemon-reload", { stdio: "inherit" });
167335
168515
  if (opts.dashboard !== false)
167336
168516
  execSync3("systemctl enable matrixos-dashboard.service", { stdio: "inherit" });
167337
168517
  if (opts.gateway !== false)
167338
168518
  execSync3("systemctl enable matrixos-gateway.service", { stdio: "inherit" });
168519
+ if (opts.cron !== false)
168520
+ execSync3("systemctl enable matrixos-cron.service", { stdio: "inherit" });
167339
168521
  if (opts.dashboard !== false)
167340
168522
  execSync3("systemctl start matrixos-dashboard.service", { stdio: "inherit" });
167341
168523
  if (opts.gateway !== false)
167342
168524
  execSync3("systemctl start matrixos-gateway.service", { stdio: "inherit" });
168525
+ if (opts.cron !== false)
168526
+ execSync3("systemctl start matrixos-cron.service", { stdio: "inherit" });
167343
168527
  }
167344
168528
  console.log("[service] systemd units installed and started.");
167345
168529
  }
@@ -182042,52 +183226,8 @@ async function boulder(options) {
182042
183226
  `);
182043
183227
  return 0;
182044
183228
  }
182045
- // packages/omo-opencode/src/cli/cron.ts
182046
- init_store();
182047
- var store2 = createCronStore();
182048
- function cronAdd(options) {
182049
- const job = store2.add({
182050
- name: options.name,
182051
- schedule: options.schedule,
182052
- command: options.command,
182053
- channel: options.channel,
182054
- recipient: options.recipient,
182055
- enabled: options.enabled ?? true
182056
- });
182057
- console.log(`Added: ${job.id} \u2014 ${job.name} [${job.schedule}]`);
182058
- return 0;
182059
- }
182060
- function cronList(options = {}) {
182061
- const jobs = store2.list({
182062
- enabled: options.enabled,
182063
- channel: options.channel
182064
- });
182065
- if (options.json) {
182066
- console.log(JSON.stringify(jobs, null, 2));
182067
- } else {
182068
- if (jobs.length === 0) {
182069
- console.log("No cron jobs.");
182070
- return 0;
182071
- }
182072
- for (const j of jobs) {
182073
- const status2 = j.enabled ? "enabled" : "disabled";
182074
- const delivery = j.channel ? ` \u2192 ${j.channel}/${j.recipient ?? "*"}` : "";
182075
- console.log(` ${j.id.padEnd(14)} ${status2.padEnd(9)} ${j.schedule.padEnd(12)} ${j.name}${delivery}`);
182076
- }
182077
- console.log(`
182078
- Total: ${jobs.length}`);
182079
- }
182080
- return 0;
182081
- }
182082
- function cronRemove(options) {
182083
- const ok = store2.remove(options.id);
182084
- if (ok) {
182085
- console.log(`Removed: ${options.id}`);
182086
- return 0;
182087
- }
182088
- console.error(`Not found: ${options.id}`);
182089
- return 1;
182090
- }
183229
+ // packages/omo-opencode/src/cli/runtime-commands.ts
183230
+ init_cron();
182091
183231
 
182092
183232
  // packages/daily-brief-core/src/schema.ts
182093
183233
  init_zod();
@@ -182486,13 +183626,13 @@ function isValidTransition(from, to) {
182486
183626
  }
182487
183627
  function createKanbanStore() {
182488
183628
  const cards = new Map;
182489
- let counter = 0;
183629
+ let counter2 = 0;
182490
183630
  return {
182491
183631
  add(input) {
182492
- counter += 1;
183632
+ counter2 += 1;
182493
183633
  const now = new Date().toISOString();
182494
183634
  const card = {
182495
- id: `kanban-${counter}`,
183635
+ id: `kanban-${counter2}`,
182496
183636
  title: input.title,
182497
183637
  description: input.description ?? "",
182498
183638
  status: input.status ?? "backlog",
@@ -182638,8 +183778,8 @@ import { basename as basename12, dirname as dirname24, join as join60 } from "pa
182638
183778
 
182639
183779
  // packages/skills-loader-core/src/shared/opencode-config-dir.ts
182640
183780
  import { existsSync as existsSync64, realpathSync as realpathSync8 } from "fs";
182641
- import { homedir as homedir22 } from "os";
182642
- import { join as join59, posix as posix5, resolve as resolve12, win32 as win325 } from "path";
183781
+ import { homedir as homedir23 } from "os";
183782
+ import { join as join59, posix as posix5, resolve as resolve13, win32 as win325 } from "path";
182643
183783
 
182644
183784
  // packages/skills-loader-core/src/shared/plugin-identity.ts
182645
183785
  init_src();
@@ -182672,14 +183812,14 @@ function getTauriConfigDir2(identifier) {
182672
183812
  const platform2 = process.platform;
182673
183813
  switch (platform2) {
182674
183814
  case "darwin":
182675
- return join59(homedir22(), "Library", "Application Support", identifier);
183815
+ return join59(homedir23(), "Library", "Application Support", identifier);
182676
183816
  case "win32": {
182677
- const appData = process.env.APPDATA || join59(homedir22(), "AppData", "Roaming");
183817
+ const appData = process.env.APPDATA || join59(homedir23(), "AppData", "Roaming");
182678
183818
  return win325.join(appData, identifier);
182679
183819
  }
182680
183820
  case "linux":
182681
183821
  default: {
182682
- const xdgConfig = process.env.XDG_CONFIG_HOME || join59(homedir22(), ".config");
183822
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join59(homedir23(), ".config");
182683
183823
  return join59(xdgConfig, identifier);
182684
183824
  }
182685
183825
  }
@@ -182688,7 +183828,7 @@ function resolveConfigPath3(pathValue) {
182688
183828
  if (isWslEnvironment2() && pathValue.startsWith("/")) {
182689
183829
  return posix5.normalize(pathValue);
182690
183830
  }
182691
- const resolvedPath = resolve12(pathValue);
183831
+ const resolvedPath = resolve13(pathValue);
182692
183832
  if (!existsSync64(resolvedPath))
182693
183833
  return resolvedPath;
182694
183834
  try {
@@ -182723,7 +183863,7 @@ function getWslLinuxHomeDir2(windowsConfigRoot) {
182723
183863
  function getCliDefaultConfigDir2() {
182724
183864
  const envXdgConfig = process.env.XDG_CONFIG_HOME?.trim();
182725
183865
  const shouldIgnoreWindowsXdg = envXdgConfig !== undefined && envXdgConfig.length > 0 && isWslEnvironment2() && isWindowsUserConfigRoot2(envXdgConfig);
182726
- const xdgConfig = shouldIgnoreWindowsXdg ? posix5.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join59(homedir22(), ".config");
183866
+ const xdgConfig = shouldIgnoreWindowsXdg ? posix5.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join59(homedir23(), ".config");
182727
183867
  const configDir = isWslEnvironment2() ? posix5.join(xdgConfig, "opencode") : join59(xdgConfig, "opencode");
182728
183868
  return resolveConfigPath3(configDir);
182729
183869
  }
@@ -182790,10 +183930,10 @@ function getOpenCodeSkillDirs2(options) {
182790
183930
  // packages/skills-loader-core/src/shared/project-discovery-dirs.ts
182791
183931
  import { execFileSync as execFileSync2 } from "child_process";
182792
183932
  import { existsSync as existsSync65, realpathSync as realpathSync9 } from "fs";
182793
- import { dirname as dirname25, join as join61, resolve as resolve13, win32 as win326 } from "path";
183933
+ import { dirname as dirname25, join as join61, resolve as resolve14, win32 as win326 } from "path";
182794
183934
  var worktreePathCache2 = new Map;
182795
183935
  function normalizePath2(path18) {
182796
- const resolvedPath = process.platform !== "win32" && win326.isAbsolute(path18) ? path18 : resolve13(path18);
183936
+ const resolvedPath = process.platform !== "win32" && win326.isAbsolute(path18) ? path18 : resolve14(path18);
182797
183937
  if (!existsSync65(resolvedPath)) {
182798
183938
  return resolvedPath;
182799
183939
  }
@@ -182848,7 +183988,7 @@ function findAncestorDirectories(startDirectory, targetPaths, stopDirectory) {
182848
183988
  }
182849
183989
  }
182850
183990
  function detectWorktreePath(directory) {
182851
- const resolvedDirectory = resolve13(directory);
183991
+ const resolvedDirectory = resolve14(directory);
182852
183992
  const cacheKey = pathKey2(normalizePath2(resolvedDirectory));
182853
183993
  if (worktreePathCache2.has(cacheKey)) {
182854
183994
  return worktreePathCache2.get(cacheKey);
@@ -186299,7 +187439,7 @@ function applySnapshotRetention(options) {
186299
187439
  }
186300
187440
 
186301
187441
  // packages/omo-opencode/src/cli/snapshot/snapshot.ts
186302
- import { Database as Database3 } from "bun:sqlite";
187442
+ import { Database as Database4 } from "bun:sqlite";
186303
187443
  import {
186304
187444
  existsSync as existsSync67,
186305
187445
  mkdirSync as mkdirSync21,
@@ -186330,7 +187470,7 @@ async function snapshotCli(options = {}) {
186330
187470
  };
186331
187471
  const sqlitePort = {
186332
187472
  vacuumInto(source, dest) {
186333
- const db = new Database3(source);
187473
+ const db = new Database4(source);
186334
187474
  try {
186335
187475
  db.run(`VACUUM INTO '${dest.replace(/'/g, "''")}'`);
186336
187476
  } finally {
@@ -186793,7 +187933,7 @@ function printHumanReadable2(r2) {
186793
187933
  init_data_path();
186794
187934
  import * as path23 from "path";
186795
187935
  import { writeFileSync as writeFileSync23 } from "fs";
186796
- import { Database as Database4 } from "bun:sqlite";
187936
+ import { Database as Database5 } from "bun:sqlite";
186797
187937
  function defaultDbPath() {
186798
187938
  return path23.join(getDataDir(), "opencode", "opencode.db");
186799
187939
  }
@@ -186857,7 +187997,7 @@ function summarizeMessage(row) {
186857
187997
  return { label: text, role, agent: agent2, detail: row.id };
186858
187998
  }
186859
187999
  function buildTrace(dbPath, rootSessionId, options = {}) {
186860
- const db = new Database4(dbPath, { readonly: true });
188000
+ const db = new Database5(dbPath, { readonly: true });
186861
188001
  try {
186862
188002
  const sessions = readSessions(db);
186863
188003
  const anomalies = [];
@@ -187033,8 +188173,9 @@ import { readFileSync as readFileSync58 } from "fs";
187033
188173
  import * as os12 from "os";
187034
188174
  import * as fs21 from "fs";
187035
188175
  import * as path24 from "path";
187036
- import { Database as Database5 } from "bun:sqlite";
188176
+ import { Database as Database6 } from "bun:sqlite";
187037
188177
  init_config_context();
188178
+ init_store();
187038
188179
  var BUILTIN_AGENT_NAMES2 = BuiltinAgentNameSchema.options.map((v) => v);
187039
188180
  var AGENT_DISPLAY_NAMES2 = {
187040
188181
  morpheus: "Morpheus",
@@ -187128,7 +188269,7 @@ function getDb() {
187128
188269
  if (!fs21.existsSync(OPENCODE_DB_PATH))
187129
188270
  return;
187130
188271
  try {
187131
- return new Database5(OPENCODE_DB_PATH, { readonly: true });
188272
+ return new Database6(OPENCODE_DB_PATH, { readonly: true });
187132
188273
  } catch {
187133
188274
  return;
187134
188275
  }
@@ -187137,7 +188278,7 @@ function getDbWrite() {
187137
188278
  if (!fs21.existsSync(OPENCODE_DB_PATH))
187138
188279
  return;
187139
188280
  try {
187140
- const db = new Database5(OPENCODE_DB_PATH);
188281
+ const db = new Database6(OPENCODE_DB_PATH);
187141
188282
  db.exec("PRAGMA journal_mode = WAL");
187142
188283
  return db;
187143
188284
  } catch {
@@ -187762,6 +188903,35 @@ ${row.description ? `Description: ${row.description}
187762
188903
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
187763
188904
  }
187764
188905
  },
188906
+ listCron() {
188907
+ try {
188908
+ return createCronStore().list();
188909
+ } catch {
188910
+ return [];
188911
+ }
188912
+ },
188913
+ addCron(input) {
188914
+ try {
188915
+ const job = createCronStore().add({
188916
+ name: input.name,
188917
+ schedule: input.schedule,
188918
+ command: input.command,
188919
+ channel: input.channel ?? undefined,
188920
+ enabled: true
188921
+ });
188922
+ return { ok: true, id: job.id };
188923
+ } catch (e) {
188924
+ return { ok: false, error: e instanceof Error ? e.message : String(e) };
188925
+ }
188926
+ },
188927
+ removeCron(id) {
188928
+ try {
188929
+ const ok = createCronStore().remove(id);
188930
+ return ok ? { ok: true } : { ok: false, error: "not found" };
188931
+ } catch (e) {
188932
+ return { ok: false, error: e instanceof Error ? e.message : String(e) };
188933
+ }
188934
+ },
187765
188935
  async getIncidents(limit = 50) {
187766
188936
  const lines = readJsonl("anti-loop.jsonl");
187767
188937
  if (lines.length === 0) {
@@ -187873,7 +189043,7 @@ ${row.description ? `Description: ${row.description}
187873
189043
  const dbPath = path24.resolve(os12.homedir(), ".matrixos", "memory", "episodic.db");
187874
189044
  try {
187875
189045
  if (fs21.existsSync(dbPath)) {
187876
- const db = new Database5(dbPath);
189046
+ const db = new Database6(dbPath);
187877
189047
  const tables = db.query("SELECT name FROM sqlite_master WHERE type='table'").all();
187878
189048
  const tableNames = tables.map((t2) => String(t2.name ?? ""));
187879
189049
  if (tableNames.includes("memories")) {
@@ -188169,8 +189339,25 @@ function createDashboardServer(dataProvider, config5) {
188169
189339
  }
188170
189340
  case "/api/memory":
188171
189341
  return Response.json(dataProvider.getMemory(), { headers: jsonHeaders });
188172
- case "/api/skills":
188173
- return Response.json(dataProvider.getSkills(), { headers: jsonHeaders });
189342
+ case "/api/cron": {
189343
+ if (req.method === "POST") {
189344
+ const body = await req.json();
189345
+ if (!body.name || !body.schedule || !body.command) {
189346
+ return Response.json({ ok: false, error: "name, schedule and command required" }, { status: 400, headers: jsonHeaders });
189347
+ }
189348
+ const result = dataProvider.addCron(body);
189349
+ return Response.json(result, { status: result.ok ? 201 : 500, headers: jsonHeaders });
189350
+ }
189351
+ if (req.method === "DELETE") {
189352
+ const id = url3.searchParams.get("id");
189353
+ if (!id) {
189354
+ return Response.json({ ok: false, error: "id required" }, { status: 400, headers: jsonHeaders });
189355
+ }
189356
+ const result = dataProvider.removeCron(id);
189357
+ return Response.json(result, { status: result.ok ? 200 : 500, headers: jsonHeaders });
189358
+ }
189359
+ return Response.json(dataProvider.listCron(), { headers: jsonHeaders });
189360
+ }
188174
189361
  case "/api/skills/create": {
188175
189362
  if (req.method !== "POST") {
188176
189363
  return new Response("Method Not Allowed", { status: 405, headers: corsHeaders });
@@ -188282,14 +189469,14 @@ async function dashboardCli(options) {
188282
189469
  console.log(`[dashboard] ready \u2014 http://${host}:${port3}`);
188283
189470
  if (!options.daemon) {
188284
189471
  console.log("[dashboard] press Ctrl+C to stop");
188285
- await new Promise((resolve16) => {
189472
+ await new Promise((resolve17) => {
188286
189473
  process.on("SIGINT", () => {
188287
189474
  server2.stop();
188288
- resolve16();
189475
+ resolve17();
188289
189476
  });
188290
189477
  process.on("SIGTERM", () => {
188291
189478
  server2.stop();
188292
- resolve16();
189479
+ resolve17();
188293
189480
  });
188294
189481
  });
188295
189482
  } else {
@@ -189039,6 +190226,43 @@ For channel-specific setup, use:
189039
190226
  function runCli() {
189040
190227
  program2.parse();
189041
190228
  }
190229
+ var cron3 = program2.command("cron").description("Cron / Scheduled jobs (durable, SQLite-backed)");
190230
+ 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", `
190231
+ Examples:
190232
+ $ matrixos cron add "daily brief" "0 9 * * *" "matrixos run --agent TheOracle 'daily brief'"
190233
+ $ matrixos cron add "weekly audit" "0 22 * * 0" "matrixos self-audit" --channel telegram
190234
+ `).action(async (name2, schedule2, command, options) => {
190235
+ const { cronAdd: cronAdd2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190236
+ const code = cronAdd2({
190237
+ name: name2,
190238
+ schedule: schedule2,
190239
+ command,
190240
+ channel: options.channel,
190241
+ recipient: options.recipient,
190242
+ enabled: !options.disabled
190243
+ });
190244
+ process.exit(code);
190245
+ });
190246
+ 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) => {
190247
+ const { cronList: cronList2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190248
+ const code = cronList2({ enabled: options.enabled, channel: options.channel, json: options.json });
190249
+ process.exit(code);
190250
+ });
190251
+ cron3.command("remove <id>").description("Remove a scheduled job by id").action(async (id) => {
190252
+ const { cronRemove: cronRemove2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190253
+ const code = cronRemove2({ id });
190254
+ process.exit(code);
190255
+ });
190256
+ 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) => {
190257
+ const { cronStart: cronStart2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190258
+ const code = cronStart2({ daemon: options.daemon });
190259
+ process.exit(code);
190260
+ });
190261
+ cron3.command("stop").description("Stop the cron scheduler (terminates the running scheduler process)").action(async () => {
190262
+ const { cronStop: cronStop2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
190263
+ const code = cronStop2();
190264
+ process.exit(code);
190265
+ });
189042
190266
  var rgpd = program2.command("rgpd").description("RGPD compliance commands \u2014 consent, forget, export (\xA718.2)");
189043
190267
  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", `
189044
190268
  Examples:
@@ -189102,7 +190326,7 @@ Examples:
189102
190326
  process.stdout.write(result.stdout);
189103
190327
  process.exit(result.exitCode);
189104
190328
  });
189105
- 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) => {
190329
+ 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) => {
189106
190330
  if (action !== "install" && action !== "uninstall") {
189107
190331
  console.error(`[service] unknown action: ${action}. Use 'install' or 'uninstall'.`);
189108
190332
  process.exit(1);
@@ -189115,6 +190339,7 @@ program2.command("service").description("Install MaTrixOS as a persistent OS ser
189115
190339
  const exitCode = await serviceInstallCommand2({
189116
190340
  dashboard: options.dashboard ?? true,
189117
190341
  gateway: options.gateway ?? true,
190342
+ cron: options.cron ?? true,
189118
190343
  user: options.user ?? false
189119
190344
  });
189120
190345
  process.exit(exitCode);