@kl-c/matrixos 0.3.10 → 0.3.11

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.10",
2166
+ version: "0.3.11",
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",
@@ -84953,14 +84953,11 @@ class MatrixGateway {
84953
84953
  return adapter.send(env2);
84954
84954
  }
84955
84955
  async handleInbound(env2) {
84956
- console.error("[gateway] handleInbound", env2.id, env2.sender.id, env2.content.text?.slice(0, 30));
84957
84956
  if (this.seenIds.has(env2.id)) {
84958
- console.error("[gateway] dedupe rejected", env2.id);
84959
84957
  return;
84960
84958
  }
84961
84959
  this.seenIds.add(env2.id);
84962
84960
  if (this.isLoop(env2)) {
84963
- console.error("[gateway] loop detected");
84964
84961
  this.audit({
84965
84962
  timestamp: new Date().toISOString(),
84966
84963
  type: "loop_detected",
@@ -84972,7 +84969,6 @@ class MatrixGateway {
84972
84969
  return;
84973
84970
  }
84974
84971
  if (this.isRateLimited(env2)) {
84975
- console.error("[gateway] rate limited");
84976
84972
  this.audit({
84977
84973
  timestamp: new Date().toISOString(),
84978
84974
  type: "rate_limited",
@@ -84984,7 +84980,6 @@ class MatrixGateway {
84984
84980
  }
84985
84981
  const allowResult = this.isAllowed(env2);
84986
84982
  if (!allowResult.ok) {
84987
- console.error("[gateway] security denied:", allowResult.reason);
84988
84983
  this.audit({
84989
84984
  timestamp: new Date().toISOString(),
84990
84985
  type: "message_denied",
@@ -84996,10 +84991,7 @@ class MatrixGateway {
84996
84991
  return;
84997
84992
  }
84998
84993
  if (this.handler) {
84999
- console.error("[gateway] invoking handler for", env2.id);
85000
84994
  await this.handler(env2);
85001
- } else {
85002
- console.error("[gateway] no handler registered");
85003
84995
  }
85004
84996
  this.audit({
85005
84997
  timestamp: new Date().toISOString(),
@@ -166121,21 +166113,17 @@ async function runCliCommand(args, replyMsg) {
166121
166113
  }
166122
166114
  async function handleGatewayMessage(env5, opts = {}) {
166123
166115
  const text = env5.content.text ?? "";
166124
- console.error("[gateway-handler] received text:", text.slice(0, 50));
166125
166116
  if (isReadoptCommand(env5)) {
166126
- console.error("[gateway-handler] readopt command");
166127
166117
  return runCliCommand(["adopt"], "Re-adoption MaTrixOS lancee. Suis le wizard localement.");
166128
166118
  }
166129
166119
  if (isTelegramAdoptCommand(env5)) {
166130
- console.error("[gateway-handler] telegram-adopt command");
166131
166120
  return runCliCommand(["gateway", "adopt", "telegram"], "Configuration Telegram lancee. Colle ton bot token quand demande (jamais par chat).");
166132
166121
  }
166133
166122
  const command = opts.command ?? "matrixos";
166134
- const argsTemplate = opts.args ?? ["run", text];
166123
+ const argsTemplate = opts.args ?? ["run", "--json", "{text}"];
166135
166124
  const args = argsTemplate.map((a2) => a2 === "{text}" ? text : a2);
166136
166125
  const cwd = opts.cwd ?? process.cwd();
166137
- const timeoutMs = opts.timeoutMs ?? 30000;
166138
- console.error("[gateway-handler] spawn:", command, args, "cwd:", cwd, "timeout:", timeoutMs);
166126
+ const timeoutMs = opts.timeoutMs ?? 120000;
166139
166127
  const started = Date.now();
166140
166128
  return new Promise((resolve19) => {
166141
166129
  let stdout2 = "";
@@ -166174,14 +166162,11 @@ async function handleGatewayMessage(env5, opts = {}) {
166174
166162
  }, timeoutMs);
166175
166163
  child.stdout?.on("data", (chunk) => {
166176
166164
  const s = chunk.toString("utf8");
166177
- console.error("[gateway-handler] stdout chunk:", s.slice(0, 120).replace(/\n/g, "\\n"));
166178
166165
  stdout2 += s;
166179
166166
  opts.onPartial?.(s);
166180
166167
  });
166181
166168
  child.stderr?.on("data", (chunk) => {
166182
- const s = chunk.toString("utf8");
166183
- console.error("[gateway-handler] stderr chunk:", s.slice(0, 120).replace(/\n/g, "\\n"));
166184
- stderr += s;
166169
+ stderr += chunk.toString("utf8");
166185
166170
  });
166186
166171
  child.on("error", (err) => {
166187
166172
  clearTimeout(timer);
@@ -166193,13 +166178,23 @@ async function handleGatewayMessage(env5, opts = {}) {
166193
166178
  });
166194
166179
  child.on("close", (code) => {
166195
166180
  clearTimeout(timer);
166196
- console.error("[gateway-handler] child close code:", code, "stdout len:", stdout2.length, "stderr len:", stderr.length);
166181
+ let reply = stdout2.trim();
166182
+ const lastBrace = reply.lastIndexOf("{");
166183
+ if (lastBrace >= 0) {
166184
+ try {
166185
+ const json3 = JSON.parse(reply.slice(lastBrace));
166186
+ if (typeof json3.summary === "string")
166187
+ reply = json3.summary;
166188
+ else if (typeof json3.message === "string")
166189
+ reply = json3.message;
166190
+ } catch {}
166191
+ }
166197
166192
  if (code === 0) {
166198
- finish({ ok: true, reply: stdout2.trim() || "(empty reply)", exitCode: code });
166193
+ finish({ ok: true, reply: reply || "(empty reply)", exitCode: code });
166199
166194
  } else {
166200
166195
  finish({
166201
166196
  ok: false,
166202
- reply: stdout2.trim() || `handler: exit ${code}
166197
+ reply: reply || `handler: exit ${code}
166203
166198
  ${maskSecrets(stderr.trim())}`,
166204
166199
  exitCode: code
166205
166200
  });
@@ -166308,7 +166303,6 @@ async function runGatewayStart(opts = {}) {
166308
166303
  args: opts.args,
166309
166304
  timeoutMs: opts.timeoutMs
166310
166305
  });
166311
- console.error("[gateway-start] handler result:", r2.ok, "reply len:", r2.reply.length, "duration:", r2.durationMs, "exitCode:", r2.exitCode);
166312
166306
  if (env6.content.text && r2.ok) {
166313
166307
  const reply = {
166314
166308
  id: "reply-" + env6.id,
@@ -166324,10 +166318,7 @@ async function runGatewayStart(opts = {}) {
166324
166318
  };
166325
166319
  try {
166326
166320
  await gateway2.send(reply);
166327
- console.error("[gateway-start] reply sent");
166328
- } catch (e) {
166329
- console.error("[gateway-start] reply failed:", e instanceof Error ? e.message : String(e));
166330
- }
166321
+ } catch {}
166331
166322
  }
166332
166323
  });
166333
166324
  await gateway2.start();
@@ -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.10",
2166
+ version: "0.3.11",
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",
@@ -85008,14 +85008,11 @@ class MatrixGateway {
85008
85008
  return adapter.send(env2);
85009
85009
  }
85010
85010
  async handleInbound(env2) {
85011
- console.error("[gateway] handleInbound", env2.id, env2.sender.id, env2.content.text?.slice(0, 30));
85012
85011
  if (this.seenIds.has(env2.id)) {
85013
- console.error("[gateway] dedupe rejected", env2.id);
85014
85012
  return;
85015
85013
  }
85016
85014
  this.seenIds.add(env2.id);
85017
85015
  if (this.isLoop(env2)) {
85018
- console.error("[gateway] loop detected");
85019
85016
  this.audit({
85020
85017
  timestamp: new Date().toISOString(),
85021
85018
  type: "loop_detected",
@@ -85027,7 +85024,6 @@ class MatrixGateway {
85027
85024
  return;
85028
85025
  }
85029
85026
  if (this.isRateLimited(env2)) {
85030
- console.error("[gateway] rate limited");
85031
85027
  this.audit({
85032
85028
  timestamp: new Date().toISOString(),
85033
85029
  type: "rate_limited",
@@ -85039,7 +85035,6 @@ class MatrixGateway {
85039
85035
  }
85040
85036
  const allowResult = this.isAllowed(env2);
85041
85037
  if (!allowResult.ok) {
85042
- console.error("[gateway] security denied:", allowResult.reason);
85043
85038
  this.audit({
85044
85039
  timestamp: new Date().toISOString(),
85045
85040
  type: "message_denied",
@@ -85051,10 +85046,7 @@ class MatrixGateway {
85051
85046
  return;
85052
85047
  }
85053
85048
  if (this.handler) {
85054
- console.error("[gateway] invoking handler for", env2.id);
85055
85049
  await this.handler(env2);
85056
- } else {
85057
- console.error("[gateway] no handler registered");
85058
85050
  }
85059
85051
  this.audit({
85060
85052
  timestamp: new Date().toISOString(),
@@ -166176,21 +166168,17 @@ async function runCliCommand(args, replyMsg) {
166176
166168
  }
166177
166169
  async function handleGatewayMessage(env5, opts = {}) {
166178
166170
  const text = env5.content.text ?? "";
166179
- console.error("[gateway-handler] received text:", text.slice(0, 50));
166180
166171
  if (isReadoptCommand(env5)) {
166181
- console.error("[gateway-handler] readopt command");
166182
166172
  return runCliCommand(["adopt"], "Re-adoption MaTrixOS lancee. Suis le wizard localement.");
166183
166173
  }
166184
166174
  if (isTelegramAdoptCommand(env5)) {
166185
- console.error("[gateway-handler] telegram-adopt command");
166186
166175
  return runCliCommand(["gateway", "adopt", "telegram"], "Configuration Telegram lancee. Colle ton bot token quand demande (jamais par chat).");
166187
166176
  }
166188
166177
  const command = opts.command ?? "matrixos";
166189
- const argsTemplate = opts.args ?? ["run", text];
166178
+ const argsTemplate = opts.args ?? ["run", "--json", "{text}"];
166190
166179
  const args = argsTemplate.map((a2) => a2 === "{text}" ? text : a2);
166191
166180
  const cwd = opts.cwd ?? process.cwd();
166192
- const timeoutMs = opts.timeoutMs ?? 30000;
166193
- console.error("[gateway-handler] spawn:", command, args, "cwd:", cwd, "timeout:", timeoutMs);
166181
+ const timeoutMs = opts.timeoutMs ?? 120000;
166194
166182
  const started = Date.now();
166195
166183
  return new Promise((resolve19) => {
166196
166184
  let stdout2 = "";
@@ -166229,14 +166217,11 @@ async function handleGatewayMessage(env5, opts = {}) {
166229
166217
  }, timeoutMs);
166230
166218
  child.stdout?.on("data", (chunk) => {
166231
166219
  const s = chunk.toString("utf8");
166232
- console.error("[gateway-handler] stdout chunk:", s.slice(0, 120).replace(/\n/g, "\\n"));
166233
166220
  stdout2 += s;
166234
166221
  opts.onPartial?.(s);
166235
166222
  });
166236
166223
  child.stderr?.on("data", (chunk) => {
166237
- const s = chunk.toString("utf8");
166238
- console.error("[gateway-handler] stderr chunk:", s.slice(0, 120).replace(/\n/g, "\\n"));
166239
- stderr += s;
166224
+ stderr += chunk.toString("utf8");
166240
166225
  });
166241
166226
  child.on("error", (err) => {
166242
166227
  clearTimeout(timer);
@@ -166248,13 +166233,23 @@ async function handleGatewayMessage(env5, opts = {}) {
166248
166233
  });
166249
166234
  child.on("close", (code) => {
166250
166235
  clearTimeout(timer);
166251
- console.error("[gateway-handler] child close code:", code, "stdout len:", stdout2.length, "stderr len:", stderr.length);
166236
+ let reply = stdout2.trim();
166237
+ const lastBrace = reply.lastIndexOf("{");
166238
+ if (lastBrace >= 0) {
166239
+ try {
166240
+ const json3 = JSON.parse(reply.slice(lastBrace));
166241
+ if (typeof json3.summary === "string")
166242
+ reply = json3.summary;
166243
+ else if (typeof json3.message === "string")
166244
+ reply = json3.message;
166245
+ } catch {}
166246
+ }
166252
166247
  if (code === 0) {
166253
- finish({ ok: true, reply: stdout2.trim() || "(empty reply)", exitCode: code });
166248
+ finish({ ok: true, reply: reply || "(empty reply)", exitCode: code });
166254
166249
  } else {
166255
166250
  finish({
166256
166251
  ok: false,
166257
- reply: stdout2.trim() || `handler: exit ${code}
166252
+ reply: reply || `handler: exit ${code}
166258
166253
  ${maskSecrets(stderr.trim())}`,
166259
166254
  exitCode: code
166260
166255
  });
@@ -166363,7 +166358,6 @@ async function runGatewayStart(opts = {}) {
166363
166358
  args: opts.args,
166364
166359
  timeoutMs: opts.timeoutMs
166365
166360
  });
166366
- console.error("[gateway-start] handler result:", r2.ok, "reply len:", r2.reply.length, "duration:", r2.durationMs, "exitCode:", r2.exitCode);
166367
166361
  if (env6.content.text && r2.ok) {
166368
166362
  const reply = {
166369
166363
  id: "reply-" + env6.id,
@@ -166379,10 +166373,7 @@ async function runGatewayStart(opts = {}) {
166379
166373
  };
166380
166374
  try {
166381
166375
  await gateway2.send(reply);
166382
- console.error("[gateway-start] reply sent");
166383
- } catch (e) {
166384
- console.error("[gateway-start] reply failed:", e instanceof Error ? e.message : String(e));
166385
- }
166376
+ } catch {}
166386
166377
  }
166387
166378
  });
166388
166379
  await gateway2.start();
package/dist/index.js CHANGED
@@ -368019,7 +368019,7 @@ function getCachedVersion(options = {}) {
368019
368019
  // package.json
368020
368020
  var package_default = {
368021
368021
  name: "@kl-c/matrixos",
368022
- version: "0.3.10",
368022
+ version: "0.3.11",
368023
368023
  description: "MaTrixOS \u2014 Agentic OS for OpenCode. Personalizable, communicating, self-improving, resilient.",
368024
368024
  main: "./dist/index.js",
368025
368025
  types: "dist/index.d.ts",
@@ -443312,14 +443312,11 @@ class MatrixGateway {
443312
443312
  return adapter.send(env2);
443313
443313
  }
443314
443314
  async handleInbound(env2) {
443315
- console.error("[gateway] handleInbound", env2.id, env2.sender.id, env2.content.text?.slice(0, 30));
443316
443315
  if (this.seenIds.has(env2.id)) {
443317
- console.error("[gateway] dedupe rejected", env2.id);
443318
443316
  return;
443319
443317
  }
443320
443318
  this.seenIds.add(env2.id);
443321
443319
  if (this.isLoop(env2)) {
443322
- console.error("[gateway] loop detected");
443323
443320
  this.audit({
443324
443321
  timestamp: new Date().toISOString(),
443325
443322
  type: "loop_detected",
@@ -443331,7 +443328,6 @@ class MatrixGateway {
443331
443328
  return;
443332
443329
  }
443333
443330
  if (this.isRateLimited(env2)) {
443334
- console.error("[gateway] rate limited");
443335
443331
  this.audit({
443336
443332
  timestamp: new Date().toISOString(),
443337
443333
  type: "rate_limited",
@@ -443343,7 +443339,6 @@ class MatrixGateway {
443343
443339
  }
443344
443340
  const allowResult = this.isAllowed(env2);
443345
443341
  if (!allowResult.ok) {
443346
- console.error("[gateway] security denied:", allowResult.reason);
443347
443342
  this.audit({
443348
443343
  timestamp: new Date().toISOString(),
443349
443344
  type: "message_denied",
@@ -443355,10 +443350,7 @@ class MatrixGateway {
443355
443350
  return;
443356
443351
  }
443357
443352
  if (this.handler) {
443358
- console.error("[gateway] invoking handler for", env2.id);
443359
443353
  await this.handler(env2);
443360
- } else {
443361
- console.error("[gateway] no handler registered");
443362
443354
  }
443363
443355
  this.audit({
443364
443356
  timestamp: new Date().toISOString(),
package/dist/tui.js CHANGED
@@ -20763,14 +20763,11 @@ class MatrixGateway {
20763
20763
  return adapter.send(env2);
20764
20764
  }
20765
20765
  async handleInbound(env2) {
20766
- console.error("[gateway] handleInbound", env2.id, env2.sender.id, env2.content.text?.slice(0, 30));
20767
20766
  if (this.seenIds.has(env2.id)) {
20768
- console.error("[gateway] dedupe rejected", env2.id);
20769
20767
  return;
20770
20768
  }
20771
20769
  this.seenIds.add(env2.id);
20772
20770
  if (this.isLoop(env2)) {
20773
- console.error("[gateway] loop detected");
20774
20771
  this.audit({
20775
20772
  timestamp: new Date().toISOString(),
20776
20773
  type: "loop_detected",
@@ -20782,7 +20779,6 @@ class MatrixGateway {
20782
20779
  return;
20783
20780
  }
20784
20781
  if (this.isRateLimited(env2)) {
20785
- console.error("[gateway] rate limited");
20786
20782
  this.audit({
20787
20783
  timestamp: new Date().toISOString(),
20788
20784
  type: "rate_limited",
@@ -20794,7 +20790,6 @@ class MatrixGateway {
20794
20790
  }
20795
20791
  const allowResult = this.isAllowed(env2);
20796
20792
  if (!allowResult.ok) {
20797
- console.error("[gateway] security denied:", allowResult.reason);
20798
20793
  this.audit({
20799
20794
  timestamp: new Date().toISOString(),
20800
20795
  type: "message_denied",
@@ -20806,10 +20801,7 @@ class MatrixGateway {
20806
20801
  return;
20807
20802
  }
20808
20803
  if (this.handler) {
20809
- console.error("[gateway] invoking handler for", env2.id);
20810
20804
  await this.handler(env2);
20811
- } else {
20812
- console.error("[gateway] no handler registered");
20813
20805
  }
20814
20806
  this.audit({
20815
20807
  timestamp: new Date().toISOString(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kl-c/matrixos",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "MaTrixOS — Agentic OS for OpenCode. Personalizable, communicating, self-improving, resilient.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "dist/index.d.ts",