@markus-global/cli 0.7.3-rc.0 → 0.7.3-rc.2

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/markus.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env -S node --disable-warning=ExperimentalWarning
2
- import { createRequire } from 'module';
3
- const require = createRequire(import.meta.url);
2
+ import { createRequire as _createRequire } from 'module';
3
+ const require = _createRequire(import.meta.url);
4
4
  var __create = Object.create;
5
5
  var __defProp = Object.defineProperty;
6
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -56416,7 +56416,7 @@ async function runMcpTest() {
56416
56416
  let requestId = 1;
56417
56417
  const pending = /* @__PURE__ */ new Map();
56418
56418
  let cleaned = false;
56419
- const cleanup2 = () => {
56419
+ const cleanup = () => {
56420
56420
  if (cleaned)
56421
56421
  return;
56422
56422
  cleaned = true;
@@ -56426,13 +56426,13 @@ async function runMcpTest() {
56426
56426
  }
56427
56427
  };
56428
56428
  const timeout = setTimeout(() => {
56429
- cleanup2();
56429
+ cleanup();
56430
56430
  const stderr = stderrChunks.join("").slice(0, 300);
56431
56431
  rejectTest(new Error(`MCP test timed out after 60s${stderr ? ` (stderr: ${stderr})` : ""}`));
56432
56432
  }, 6e4);
56433
56433
  proc.on("error", (err) => {
56434
56434
  clearTimeout(timeout);
56435
- cleanup2();
56435
+ cleanup();
56436
56436
  rejectTest(err);
56437
56437
  });
56438
56438
  proc.stderr?.on("data", (data) => {
@@ -56498,11 +56498,11 @@ async function runMcpTest() {
56498
56498
  const text = navResult?.content?.[0]?.text ?? "";
56499
56499
  const navigated = !text.toLowerCase().includes("error");
56500
56500
  clearTimeout(timeout);
56501
- cleanup2();
56501
+ cleanup();
56502
56502
  resolveTest({ navigated, title: navigated ? "example.com" : void 0 });
56503
56503
  } catch (err) {
56504
56504
  clearTimeout(timeout);
56505
- cleanup2();
56505
+ cleanup();
56506
56506
  rejectTest(err instanceof Error ? err : new Error(String(err)));
56507
56507
  }
56508
56508
  })();
@@ -83415,7 +83415,7 @@ ${cleanText}`,
83415
83415
  }
83416
83416
  if (action === "message") {
83417
83417
  const body = await this.readBody(req);
83418
- const stream2 = body["stream"];
83418
+ const stream = body["stream"];
83419
83419
  const senderId = authUser.userId;
83420
83420
  const sessionId = body["sessionId"] ?? void 0;
83421
83421
  const images = body["images"]?.filter(Boolean);
@@ -83449,7 +83449,7 @@ ${cleanText}`,
83449
83449
  }
83450
83450
  return dbSessId;
83451
83451
  };
83452
- if (stream2) {
83452
+ if (stream) {
83453
83453
  const sseHandler = new SSEHandler({
83454
83454
  agentId: agentId2,
83455
83455
  agent,
@@ -86072,8 +86072,8 @@ EXPLANATION_END`;
86072
86072
  const senderInfo = this.orgService.resolveHumanIdentity(senderId);
86073
86073
  const agent = this.orgService.getAgentManager().getAgent(targetAgentId);
86074
86074
  this.ws.broadcastAgentUpdate(targetAgentId, "working");
86075
- const stream2 = body["stream"];
86076
- if (stream2) {
86075
+ const stream = body["stream"];
86076
+ if (stream) {
86077
86077
  const userText = body["text"];
86078
86078
  const sseHandler = new SSEHandler({
86079
86079
  agentId: targetAgentId,
@@ -98985,135 +98985,22 @@ var init_init = __esm({
98985
98985
  }
98986
98986
  });
98987
98987
 
98988
- // ../../node_modules/.pnpm/node-datachannel@0.12.0/node_modules/node-datachannel/lib/node-datachannel.js
98989
- import { createRequire } from "module";
98990
- var require2, nodeDataChannel, node_datachannel_default;
98991
- var init_node_datachannel = __esm({
98992
- "../../node_modules/.pnpm/node-datachannel@0.12.0/node_modules/node-datachannel/lib/node-datachannel.js"() {
98993
- require2 = createRequire(import.meta.url);
98994
- nodeDataChannel = require2("../build/Release/node_datachannel.node");
98995
- node_datachannel_default = nodeDataChannel;
98996
- }
98997
- });
98998
-
98999
- // ../../node_modules/.pnpm/node-datachannel@0.12.0/node_modules/node-datachannel/lib/datachannel-stream.js
99000
- import stream from "stream";
99001
- var DataChannelStream;
99002
- var init_datachannel_stream = __esm({
99003
- "../../node_modules/.pnpm/node-datachannel@0.12.0/node_modules/node-datachannel/lib/datachannel-stream.js"() {
99004
- DataChannelStream = class extends stream.Duplex {
99005
- constructor(rawChannel, streamOptions) {
99006
- super({
99007
- allowHalfOpen: false,
99008
- // Default to autoclose on end().
99009
- ...streamOptions,
99010
- objectMode: true
99011
- // Preserve the string/buffer distinction (WebRTC treats them differently)
99012
- });
99013
- this._rawChannel = rawChannel;
99014
- this._readActive = true;
99015
- rawChannel.onMessage((msg) => {
99016
- if (!this._readActive) return;
99017
- this._readActive = this.push(msg);
99018
- });
99019
- rawChannel.onClosed(() => {
99020
- this.push(null);
99021
- this.destroy();
99022
- });
99023
- rawChannel.onError((errMsg) => {
99024
- this.destroy(new Error(`DataChannel error: ${errMsg}`));
99025
- });
99026
- if (!rawChannel.isOpen()) {
99027
- this.cork();
99028
- rawChannel.onOpen(() => this.uncork());
99029
- }
99030
- }
99031
- _read() {
99032
- this._readActive = true;
99033
- }
99034
- _write(chunk, encoding, callback) {
99035
- let sentOk;
99036
- try {
99037
- if (Buffer.isBuffer(chunk)) {
99038
- sentOk = this._rawChannel.sendMessageBinary(chunk);
99039
- } else if (typeof chunk === "string") {
99040
- sentOk = this._rawChannel.sendMessage(chunk);
99041
- } else {
99042
- const typeName = chunk.constructor.name || typeof chunk;
99043
- throw new Error(`Cannot write ${typeName} to DataChannel stream`);
99044
- }
99045
- } catch (err) {
99046
- return callback(err);
99047
- }
99048
- if (sentOk) {
99049
- callback(null);
99050
- } else {
99051
- callback(new Error("Failed to write to DataChannel"));
99052
- }
99053
- }
99054
- _final(callback) {
99055
- if (!this.allowHalfOpen) this.destroy();
99056
- callback(null);
99057
- }
99058
- _destroy(maybeErr, callback) {
99059
- this._rawChannel.close();
99060
- callback(maybeErr);
99061
- }
99062
- get label() {
99063
- return this._rawChannel.getLabel();
99064
- }
99065
- get id() {
99066
- return this._rawChannel.getId();
99067
- }
99068
- get protocol() {
99069
- return this._rawChannel.getProtocol();
99070
- }
99071
- };
99072
- }
99073
- });
99074
-
99075
- // ../../node_modules/.pnpm/node-datachannel@0.12.0/node_modules/node-datachannel/lib/websocket-server.js
99076
- var init_websocket_server = __esm({
99077
- "../../node_modules/.pnpm/node-datachannel@0.12.0/node_modules/node-datachannel/lib/websocket-server.js"() {
99078
- init_node_datachannel();
99079
- }
99080
- });
99081
-
99082
- // ../../node_modules/.pnpm/node-datachannel@0.12.0/node_modules/node-datachannel/lib/index.js
99083
- var initLogger, cleanup, preload, setSctpSettings, RtcpReceivingSession, Track, Video, Audio, DataChannel, PeerConnection, WebSocket2, DescriptionType;
99084
- var init_lib = __esm({
99085
- "../../node_modules/.pnpm/node-datachannel@0.12.0/node_modules/node-datachannel/lib/index.js"() {
99086
- init_node_datachannel();
99087
- init_datachannel_stream();
99088
- init_websocket_server();
99089
- ({
99090
- initLogger,
99091
- cleanup,
99092
- preload,
99093
- setSctpSettings,
99094
- RtcpReceivingSession,
99095
- Track,
99096
- Video,
99097
- Audio,
99098
- DataChannel,
99099
- PeerConnection,
99100
- WebSocket: WebSocket2
99101
- } = node_datachannel_default);
99102
- DescriptionType = {
99103
- Unspec: "unspec",
99104
- Offer: "offer",
99105
- Answer: "answer",
99106
- Pranswer: "pranswer",
99107
- Rollback: "rollback"
99108
- };
99109
- }
99110
- });
99111
-
99112
98988
  // ../remote/dist/agent.js
99113
- import { WebSocket as WebSocket3 } from "ws";
98989
+ import { WebSocket as WebSocket2 } from "ws";
99114
98990
  import { request as httpRequest } from "node:http";
99115
98991
  import { request as httpsRequest } from "node:https";
99116
98992
  import { createHmac as createHmac2 } from "node:crypto";
98993
+ async function loadRtcModule() {
98994
+ if (!_rtcModule) {
98995
+ _rtcModule = await import("node-datachannel");
98996
+ }
98997
+ return _rtcModule;
98998
+ }
98999
+ function getRtcModule() {
99000
+ if (!_rtcModule)
99001
+ throw new Error("node-datachannel not loaded \u2014 call loadRtcModule() first");
99002
+ return _rtcModule;
99003
+ }
99117
99004
  function base64url(buf) {
99118
99005
  return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
99119
99006
  }
@@ -99123,13 +99010,13 @@ function signJwt(payload, secret) {
99123
99010
  const sig = base64url(createHmac2("sha256", secret).update(`${header}.${body}`).digest());
99124
99011
  return `${header}.${body}.${sig}`;
99125
99012
  }
99126
- var log86, STUN_SERVERS, RECONNECT_BASE_MS, RECONNECT_MAX_MS, HEARTBEAT_INTERVAL_MS, PEER_PING_INTERVAL_MS, PEER_PING_TIMEOUT_MS, RELAY_INACTIVITY_TIMEOUT_MS, RemoteAccessAgent;
99013
+ var log86, _rtcModule, STUN_SERVERS, RECONNECT_BASE_MS, RECONNECT_MAX_MS, HEARTBEAT_INTERVAL_MS, PEER_PING_INTERVAL_MS, PEER_PING_TIMEOUT_MS, RELAY_INACTIVITY_TIMEOUT_MS, RemoteAccessAgent;
99127
99014
  var init_agent3 = __esm({
99128
99015
  "../remote/dist/agent.js"() {
99129
99016
  "use strict";
99130
99017
  init_dist();
99131
- init_lib();
99132
99018
  log86 = createLogger("remote");
99019
+ _rtcModule = null;
99133
99020
  STUN_SERVERS = [
99134
99021
  "stun:stun.l.google.com:19302",
99135
99022
  "stun:stun.cloudflare.com:3478"
@@ -99153,12 +99040,13 @@ var init_agent3 = __esm({
99153
99040
  statusListeners = /* @__PURE__ */ new Set();
99154
99041
  constructor(config) {
99155
99042
  this.config = config;
99156
- initLogger("Warning");
99157
99043
  }
99158
99044
  // ── Public API ────────────────────────────────────────────────────────────
99159
99045
  async start() {
99160
99046
  this.destroyed = false;
99161
99047
  log86.info("Starting remote access agent...");
99048
+ const rtc = await loadRtcModule();
99049
+ rtc.initLogger("Warning");
99162
99050
  await this.discoverLocalOwner();
99163
99051
  try {
99164
99052
  this.registration = await this.registerInstance();
@@ -99231,7 +99119,7 @@ var init_agent3 = __esm({
99231
99119
  log86.info("Remote access agent stopped");
99232
99120
  }
99233
99121
  getStatus() {
99234
- const wsOpen = this.ws?.readyState === WebSocket3.OPEN;
99122
+ const wsOpen = this.ws?.readyState === WebSocket2.OPEN;
99235
99123
  let state = "idle";
99236
99124
  if (!this.destroyed) {
99237
99125
  if (wsOpen)
@@ -99338,7 +99226,7 @@ var init_agent3 = __esm({
99338
99226
  const { signalUrl, signalingToken } = this.registration;
99339
99227
  const wsUrl = `${signalUrl}?token=${encodeURIComponent(signalingToken)}`;
99340
99228
  log86.info("Connecting to signal server...", { signalUrl });
99341
- const ws = new WebSocket3(wsUrl);
99229
+ const ws = new WebSocket2(wsUrl);
99342
99230
  this.ws = ws;
99343
99231
  ws.on("open", () => {
99344
99232
  log86.info("Signal server connected");
@@ -99430,7 +99318,7 @@ var init_agent3 = __esm({
99430
99318
  } else {
99431
99319
  log86.info("Received offer for existing peer (ICE restart)", { peerId });
99432
99320
  }
99433
- session.pc.setRemoteDescription(sdp, DescriptionType.Offer);
99321
+ session.pc.setRemoteDescription(sdp, getRtcModule().DescriptionType.Offer);
99434
99322
  }
99435
99323
  handleIce(peerId, candidate, mid) {
99436
99324
  const session = this.peers.get(peerId);
@@ -99466,6 +99354,7 @@ var init_agent3 = __esm({
99466
99354
  }
99467
99355
  }
99468
99356
  }
99357
+ const { PeerConnection } = getRtcModule();
99469
99358
  const pc = new PeerConnection(`markus-${peerId}`, {
99470
99359
  iceServers
99471
99360
  });
@@ -99731,7 +99620,7 @@ var init_agent3 = __esm({
99731
99620
  if (session?.markusToken) {
99732
99621
  headers["cookie"] = `markus_token=${session.markusToken}`;
99733
99622
  }
99734
- const ws = new WebSocket3(wsUrl, { headers });
99623
+ const ws = new WebSocket2(wsUrl, { headers });
99735
99624
  const key2 = `${peerId}:${wsId}`;
99736
99625
  ws.on("open", () => {
99737
99626
  this.wsConnections.set(key2, ws);
@@ -99757,7 +99646,7 @@ var init_agent3 = __esm({
99757
99646
  const wsId = msg.wsId;
99758
99647
  const key2 = `${peerId}:${wsId}`;
99759
99648
  const ws = this.wsConnections.get(key2);
99760
- if (ws?.readyState === WebSocket3.OPEN) {
99649
+ if (ws?.readyState === WebSocket2.OPEN) {
99761
99650
  ws.send(msg.data);
99762
99651
  }
99763
99652
  }
@@ -99805,14 +99694,14 @@ var init_agent3 = __esm({
99805
99694
  log86.warn("DataChannel send failed, falling back to relay", { peerId, error: String(err) });
99806
99695
  }
99807
99696
  }
99808
- if (this.ws?.readyState === WebSocket3.OPEN) {
99697
+ if (this.ws?.readyState === WebSocket2.OPEN) {
99809
99698
  this.send({ type: "relay_frame", peerId, data });
99810
99699
  return;
99811
99700
  }
99812
99701
  log86.warn("No transport available for peer", { peerId });
99813
99702
  }
99814
99703
  send(msg) {
99815
- if (this.ws?.readyState === WebSocket3.OPEN) {
99704
+ if (this.ws?.readyState === WebSocket2.OPEN) {
99816
99705
  this.ws.send(JSON.stringify(msg));
99817
99706
  }
99818
99707
  }
package/dist/tray.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  /**
2
2
  * Cross-platform system tray controller for Markus.
3
- * Provides start/stop controls and quick access to the Web UI.
4
- *
5
- * Launched by the desktop shortcut / .app instead of `markus start` directly.
3
+ * Launches the server on start, provides "Open Console" and "Quit" controls.
6
4
  */
7
5
  export {};
8
6
  //# sourceMappingURL=tray.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tray.d.ts","sourceRoot":"","sources":["../src/tray.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
1
+ {"version":3,"file":"tray.d.ts","sourceRoot":"","sources":["../src/tray.ts"],"names":[],"mappings":"AAAA;;;GAGG"}