@adhdev/mesh-shared 1.0.57 → 1.0.58-rc.10

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/index.d.ts CHANGED
@@ -25,3 +25,5 @@ export * from './interpolation';
25
25
  export * from './mesh-tool-names';
26
26
  export * from './mesh-status-probe';
27
27
  export * from './rpc-chunking';
28
+ export * from './semver-compare';
29
+ export * from './ws-protocol';
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __export(index_exports, {
23
23
  CANONICAL_MESH_TOOL_COUNT: () => CANONICAL_MESH_TOOL_COUNT,
24
24
  CANONICAL_MESH_TOOL_NAMES: () => CANONICAL_MESH_TOOL_NAMES,
25
25
  CLI_SLOT_RECIPES: () => CLI_SLOT_RECIPES,
26
+ DAEMON_TO_SERVER_WS_MSGS: () => DAEMON_TO_SERVER_WS_MSGS,
26
27
  DEFAULT_DIFFICULTY_BRAINS: () => DEFAULT_DIFFICULTY_BRAINS,
27
28
  MAGI_RAW_ANSWER_CAP: () => MAGI_RAW_ANSWER_CAP,
28
29
  MESH_CHUNK_KIND: () => MESH_CHUNK_KIND,
@@ -34,12 +35,14 @@ __export(index_exports, {
34
35
  MESH_TASK_DIFFICULTIES: () => MESH_TASK_DIFFICULTIES,
35
36
  MeshChunkAssembler: () => MeshChunkAssembler,
36
37
  QUOTA_SUPPORTED_PROVIDERS: () => QUOTA_SUPPORTED_PROVIDERS,
38
+ SERVER_TO_DAEMON_WS_MSGS: () => SERVER_TO_DAEMON_WS_MSGS,
37
39
  STATUS_PROBE_ARG_KEY: () => STATUS_PROBE_ARG_KEY,
38
40
  UNKNOWN_CLI_SLOT_RECIPE: () => UNKNOWN_CLI_SLOT_RECIPE,
39
41
  argsCarryStatusProbeMarker: () => argsCarryStatusProbeMarker,
40
42
  buildMagiPanelProposal: () => buildMagiPanelProposal,
41
43
  buildSlotProposal: () => buildSlotProposal,
42
44
  canonicalDaemonId: () => canonicalDaemonId,
45
+ compareSemver: () => compareSemver,
43
46
  daemonIdsEquivalent: () => daemonIdsEquivalent,
44
47
  deriveProviderPriorityFromSlots: () => deriveProviderPriorityFromSlots,
45
48
  deriveSlotsFromLegacy: () => deriveSlotsFromLegacy,
@@ -48,9 +51,12 @@ __export(index_exports, {
48
51
  hasGitStatusEvidence: () => hasGitStatusEvidence,
49
52
  interpolateArgs: () => interpolateArgs,
50
53
  interpolateString: () => interpolateString,
54
+ isDaemonToServerWsMsg: () => isDaemonToServerWsMsg,
55
+ isDowngrade: () => isDowngrade,
51
56
  isMeshTaskDifficulty: () => isMeshTaskDifficulty,
52
57
  isPhantomDaemonEntry: () => isPhantomDaemonEntry,
53
58
  isRawDaemonDoId: () => isRawDaemonDoId,
59
+ isServerToDaemonWsMsg: () => isServerToDaemonWsMsg,
54
60
  joinRepoPath: () => joinRepoPath,
55
61
  machineCoreFromDaemonId: () => machineCoreFromDaemonId,
56
62
  measureWorstCaseChunkEnvelopeBytes: () => measureWorstCaseChunkEnvelopeBytes,
@@ -69,6 +75,7 @@ __export(index_exports, {
69
75
  normalizeNodeCapabilitySlots: () => normalizeNodeCapabilitySlots,
70
76
  normalizeThinkingLevel: () => normalizeThinkingLevel,
71
77
  parseJsonRecord: () => parseJsonRecord,
78
+ parseSemver: () => parseSemver,
72
79
  pickBestTransitGitStatus: () => pickBestTransitGitStatus,
73
80
  readBoolean: () => readBoolean,
74
81
  readGitSubmodules: () => readGitSubmodules,
@@ -345,6 +352,7 @@ var QUOTA_SUPPORTED_PROVIDERS = [
345
352
  "antigravity-cli",
346
353
  "claude-cli",
347
354
  "codex-cli",
355
+ "cursor-cli",
348
356
  "grok-cli",
349
357
  "kimi",
350
358
  "opencode"
@@ -742,6 +750,7 @@ function interpolateString(template, ctx) {
742
750
  // src/mesh-tool-names.ts
743
751
  var CANONICAL_MESH_TOOL_NAMES = [
744
752
  "mesh_status",
753
+ "mesh_route_preview",
745
754
  "mesh_list_nodes",
746
755
  // GRAPH-ORCHESTRATION Phase F — batch before task, mirroring ALL_MESH_TOOLS.
747
756
  "mesh_enqueue_batch",
@@ -995,11 +1004,88 @@ var MeshChunkAssembler = class {
995
1004
  }
996
1005
  }
997
1006
  };
1007
+
1008
+ // src/semver-compare.ts
1009
+ var SEMVER_PATTERN = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
1010
+ var NUMERIC_IDENTIFIER = /^\d+$/;
1011
+ function parseSemver(version) {
1012
+ if (typeof version !== "string") return null;
1013
+ const match = version.trim().replace(/^v/, "").match(SEMVER_PATTERN);
1014
+ if (!match) return null;
1015
+ return {
1016
+ major: Number(match[1]),
1017
+ minor: Number(match[2]),
1018
+ patch: Number(match[3]),
1019
+ prerelease: match[4] ? match[4].split(".") : []
1020
+ };
1021
+ }
1022
+ function comparePrerelease(a, b) {
1023
+ if (a.length === 0 && b.length === 0) return 0;
1024
+ if (a.length === 0) return 1;
1025
+ if (b.length === 0) return -1;
1026
+ for (let i = 0; i < Math.min(a.length, b.length); i += 1) {
1027
+ const idA = a[i];
1028
+ const idB = b[i];
1029
+ if (idA === idB) continue;
1030
+ const numA = NUMERIC_IDENTIFIER.test(idA);
1031
+ const numB = NUMERIC_IDENTIFIER.test(idB);
1032
+ if (numA && numB) return Number(idA) < Number(idB) ? -1 : 1;
1033
+ if (numA) return -1;
1034
+ if (numB) return 1;
1035
+ return idA < idB ? -1 : 1;
1036
+ }
1037
+ return a.length === b.length ? 0 : a.length < b.length ? -1 : 1;
1038
+ }
1039
+ function compareSemver(a, b) {
1040
+ const pa = parseSemver(a);
1041
+ const pb = parseSemver(b);
1042
+ if (!pa || !pb) return null;
1043
+ if (pa.major !== pb.major) return pa.major < pb.major ? -1 : 1;
1044
+ if (pa.minor !== pb.minor) return pa.minor < pb.minor ? -1 : 1;
1045
+ if (pa.patch !== pb.patch) return pa.patch < pb.patch ? -1 : 1;
1046
+ return comparePrerelease(pa.prerelease, pb.prerelease);
1047
+ }
1048
+ function isDowngrade(current, target) {
1049
+ const direction = compareSemver(target, current);
1050
+ if (direction === null) return false;
1051
+ return direction < 0;
1052
+ }
1053
+
1054
+ // src/ws-protocol.ts
1055
+ var DAEMON_TO_SERVER_WS_MSGS = [
1056
+ "auth",
1057
+ "status_report",
1058
+ "status_heartbeat",
1059
+ "status_event",
1060
+ "command_result",
1061
+ "error",
1062
+ "agent_event",
1063
+ "log"
1064
+ ];
1065
+ var SERVER_TO_DAEMON_WS_MSGS = [
1066
+ "auth_ok",
1067
+ "auth_error",
1068
+ "machine_evicted",
1069
+ "force_disconnect",
1070
+ "token_revoked",
1071
+ "version_mismatch",
1072
+ "force_update_required",
1073
+ "command",
1074
+ "agent_command",
1075
+ "resolve_action"
1076
+ ];
1077
+ function isDaemonToServerWsMsg(value) {
1078
+ return typeof value === "string" && DAEMON_TO_SERVER_WS_MSGS.includes(value);
1079
+ }
1080
+ function isServerToDaemonWsMsg(value) {
1081
+ return typeof value === "string" && SERVER_TO_DAEMON_WS_MSGS.includes(value);
1082
+ }
998
1083
  // Annotate the CommonJS export names for ESM import in node:
999
1084
  0 && (module.exports = {
1000
1085
  CANONICAL_MESH_TOOL_COUNT,
1001
1086
  CANONICAL_MESH_TOOL_NAMES,
1002
1087
  CLI_SLOT_RECIPES,
1088
+ DAEMON_TO_SERVER_WS_MSGS,
1003
1089
  DEFAULT_DIFFICULTY_BRAINS,
1004
1090
  MAGI_RAW_ANSWER_CAP,
1005
1091
  MESH_CHUNK_KIND,
@@ -1011,12 +1097,14 @@ var MeshChunkAssembler = class {
1011
1097
  MESH_TASK_DIFFICULTIES,
1012
1098
  MeshChunkAssembler,
1013
1099
  QUOTA_SUPPORTED_PROVIDERS,
1100
+ SERVER_TO_DAEMON_WS_MSGS,
1014
1101
  STATUS_PROBE_ARG_KEY,
1015
1102
  UNKNOWN_CLI_SLOT_RECIPE,
1016
1103
  argsCarryStatusProbeMarker,
1017
1104
  buildMagiPanelProposal,
1018
1105
  buildSlotProposal,
1019
1106
  canonicalDaemonId,
1107
+ compareSemver,
1020
1108
  daemonIdsEquivalent,
1021
1109
  deriveProviderPriorityFromSlots,
1022
1110
  deriveSlotsFromLegacy,
@@ -1025,9 +1113,12 @@ var MeshChunkAssembler = class {
1025
1113
  hasGitStatusEvidence,
1026
1114
  interpolateArgs,
1027
1115
  interpolateString,
1116
+ isDaemonToServerWsMsg,
1117
+ isDowngrade,
1028
1118
  isMeshTaskDifficulty,
1029
1119
  isPhantomDaemonEntry,
1030
1120
  isRawDaemonDoId,
1121
+ isServerToDaemonWsMsg,
1031
1122
  joinRepoPath,
1032
1123
  machineCoreFromDaemonId,
1033
1124
  measureWorstCaseChunkEnvelopeBytes,
@@ -1046,6 +1137,7 @@ var MeshChunkAssembler = class {
1046
1137
  normalizeNodeCapabilitySlots,
1047
1138
  normalizeThinkingLevel,
1048
1139
  parseJsonRecord,
1140
+ parseSemver,
1049
1141
  pickBestTransitGitStatus,
1050
1142
  readBoolean,
1051
1143
  readGitSubmodules,