@adhdev/mesh-shared 1.0.58-rc.6 → 1.0.58-rc.7

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,
@@ -742,6 +749,7 @@ function interpolateString(template, ctx) {
742
749
  // src/mesh-tool-names.ts
743
750
  var CANONICAL_MESH_TOOL_NAMES = [
744
751
  "mesh_status",
752
+ "mesh_route_preview",
745
753
  "mesh_list_nodes",
746
754
  // GRAPH-ORCHESTRATION Phase F — batch before task, mirroring ALL_MESH_TOOLS.
747
755
  "mesh_enqueue_batch",
@@ -995,11 +1003,88 @@ var MeshChunkAssembler = class {
995
1003
  }
996
1004
  }
997
1005
  };
1006
+
1007
+ // src/semver-compare.ts
1008
+ var SEMVER_PATTERN = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
1009
+ var NUMERIC_IDENTIFIER = /^\d+$/;
1010
+ function parseSemver(version) {
1011
+ if (typeof version !== "string") return null;
1012
+ const match = version.trim().replace(/^v/, "").match(SEMVER_PATTERN);
1013
+ if (!match) return null;
1014
+ return {
1015
+ major: Number(match[1]),
1016
+ minor: Number(match[2]),
1017
+ patch: Number(match[3]),
1018
+ prerelease: match[4] ? match[4].split(".") : []
1019
+ };
1020
+ }
1021
+ function comparePrerelease(a, b) {
1022
+ if (a.length === 0 && b.length === 0) return 0;
1023
+ if (a.length === 0) return 1;
1024
+ if (b.length === 0) return -1;
1025
+ for (let i = 0; i < Math.min(a.length, b.length); i += 1) {
1026
+ const idA = a[i];
1027
+ const idB = b[i];
1028
+ if (idA === idB) continue;
1029
+ const numA = NUMERIC_IDENTIFIER.test(idA);
1030
+ const numB = NUMERIC_IDENTIFIER.test(idB);
1031
+ if (numA && numB) return Number(idA) < Number(idB) ? -1 : 1;
1032
+ if (numA) return -1;
1033
+ if (numB) return 1;
1034
+ return idA < idB ? -1 : 1;
1035
+ }
1036
+ return a.length === b.length ? 0 : a.length < b.length ? -1 : 1;
1037
+ }
1038
+ function compareSemver(a, b) {
1039
+ const pa = parseSemver(a);
1040
+ const pb = parseSemver(b);
1041
+ if (!pa || !pb) return null;
1042
+ if (pa.major !== pb.major) return pa.major < pb.major ? -1 : 1;
1043
+ if (pa.minor !== pb.minor) return pa.minor < pb.minor ? -1 : 1;
1044
+ if (pa.patch !== pb.patch) return pa.patch < pb.patch ? -1 : 1;
1045
+ return comparePrerelease(pa.prerelease, pb.prerelease);
1046
+ }
1047
+ function isDowngrade(current, target) {
1048
+ const direction = compareSemver(target, current);
1049
+ if (direction === null) return false;
1050
+ return direction < 0;
1051
+ }
1052
+
1053
+ // src/ws-protocol.ts
1054
+ var DAEMON_TO_SERVER_WS_MSGS = [
1055
+ "auth",
1056
+ "status_report",
1057
+ "status_heartbeat",
1058
+ "status_event",
1059
+ "command_result",
1060
+ "error",
1061
+ "agent_event",
1062
+ "log"
1063
+ ];
1064
+ var SERVER_TO_DAEMON_WS_MSGS = [
1065
+ "auth_ok",
1066
+ "auth_error",
1067
+ "machine_evicted",
1068
+ "force_disconnect",
1069
+ "token_revoked",
1070
+ "version_mismatch",
1071
+ "force_update_required",
1072
+ "command",
1073
+ "agent_command",
1074
+ "resolve_action"
1075
+ ];
1076
+ function isDaemonToServerWsMsg(value) {
1077
+ return typeof value === "string" && DAEMON_TO_SERVER_WS_MSGS.includes(value);
1078
+ }
1079
+ function isServerToDaemonWsMsg(value) {
1080
+ return typeof value === "string" && SERVER_TO_DAEMON_WS_MSGS.includes(value);
1081
+ }
998
1082
  // Annotate the CommonJS export names for ESM import in node:
999
1083
  0 && (module.exports = {
1000
1084
  CANONICAL_MESH_TOOL_COUNT,
1001
1085
  CANONICAL_MESH_TOOL_NAMES,
1002
1086
  CLI_SLOT_RECIPES,
1087
+ DAEMON_TO_SERVER_WS_MSGS,
1003
1088
  DEFAULT_DIFFICULTY_BRAINS,
1004
1089
  MAGI_RAW_ANSWER_CAP,
1005
1090
  MESH_CHUNK_KIND,
@@ -1011,12 +1096,14 @@ var MeshChunkAssembler = class {
1011
1096
  MESH_TASK_DIFFICULTIES,
1012
1097
  MeshChunkAssembler,
1013
1098
  QUOTA_SUPPORTED_PROVIDERS,
1099
+ SERVER_TO_DAEMON_WS_MSGS,
1014
1100
  STATUS_PROBE_ARG_KEY,
1015
1101
  UNKNOWN_CLI_SLOT_RECIPE,
1016
1102
  argsCarryStatusProbeMarker,
1017
1103
  buildMagiPanelProposal,
1018
1104
  buildSlotProposal,
1019
1105
  canonicalDaemonId,
1106
+ compareSemver,
1020
1107
  daemonIdsEquivalent,
1021
1108
  deriveProviderPriorityFromSlots,
1022
1109
  deriveSlotsFromLegacy,
@@ -1025,9 +1112,12 @@ var MeshChunkAssembler = class {
1025
1112
  hasGitStatusEvidence,
1026
1113
  interpolateArgs,
1027
1114
  interpolateString,
1115
+ isDaemonToServerWsMsg,
1116
+ isDowngrade,
1028
1117
  isMeshTaskDifficulty,
1029
1118
  isPhantomDaemonEntry,
1030
1119
  isRawDaemonDoId,
1120
+ isServerToDaemonWsMsg,
1031
1121
  joinRepoPath,
1032
1122
  machineCoreFromDaemonId,
1033
1123
  measureWorstCaseChunkEnvelopeBytes,
@@ -1046,6 +1136,7 @@ var MeshChunkAssembler = class {
1046
1136
  normalizeNodeCapabilitySlots,
1047
1137
  normalizeThinkingLevel,
1048
1138
  parseJsonRecord,
1139
+ parseSemver,
1049
1140
  pickBestTransitGitStatus,
1050
1141
  readBoolean,
1051
1142
  readGitSubmodules,