@ai-matrx/desktop-protocol 0.7.0 → 0.10.0

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.cjs CHANGED
@@ -21,15 +21,36 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  AbsPath: () => AbsPath,
24
+ AppFeatureStatus: () => AppFeatureStatus,
25
+ AppInfo: () => AppInfo,
26
+ AppKey: () => AppKey,
27
+ AppProfile: () => AppProfile,
28
+ AppProfileId: () => AppProfileId,
29
+ AppProfileLocator: () => AppProfileLocator,
30
+ AppSupport: () => AppSupport,
31
+ AppUsageReading: () => AppUsageReading,
32
+ AppsListParams: () => AppsListParams,
33
+ AppsListResult: () => AppsListResult,
34
+ AppsOpenParams: () => AppsOpenParams,
35
+ AppsOpenResult: () => AppsOpenResult,
36
+ AppsProfilesListParams: () => AppsProfilesListParams,
37
+ AppsProfilesListResult: () => AppsProfilesListResult,
38
+ AppsProfilesRemoveParams: () => AppsProfilesRemoveParams,
39
+ AppsProfilesRemoveResult: () => AppsProfilesRemoveResult,
40
+ AppsProfilesSaveParams: () => AppsProfilesSaveParams,
41
+ AppsProfilesSaveResult: () => AppsProfilesSaveResult,
24
42
  BEARER_PREFIX: () => BEARER_PREFIX,
25
43
  BROADCAST_CID: () => BROADCAST_CID,
26
44
  CLOSE_RULES: () => CLOSE_RULES,
45
+ CONTRACT_SHA256: () => CONTRACT_SHA256,
27
46
  CancelMsg: () => CancelMsg,
28
47
  ClientToCoreMsg: () => ClientToCoreMsg,
29
48
  ClientType: () => ClientType,
30
49
  CloseCode: () => CloseCode,
31
50
  CloseCodeValue: () => CloseCodeValue,
51
+ ContractHash: () => ContractHash,
32
52
  CoreToClientMsg: () => CoreToClientMsg,
53
+ CoreToServiceMsg: () => CoreToServiceMsg,
33
54
  CreditMsg: () => CreditMsg,
34
55
  DEFAULT_MAX_FRAME_PAYLOAD_BYTES: () => DEFAULT_MAX_FRAME_PAYLOAD_BYTES,
35
56
  DEFAULT_MAX_MESSAGE_BYTES: () => DEFAULT_MAX_MESSAGE_BYTES,
@@ -99,7 +120,24 @@ __export(src_exports, {
99
120
  FsWriteParams: () => FsWriteParams,
100
121
  FsWriteResult: () => FsWriteResult,
101
122
  HelloMsg: () => HelloMsg,
123
+ LEGACY_ACTIONS: () => LEGACY_ACTIONS,
124
+ LEGACY_DISPATCHERS: () => LEGACY_DISPATCHERS,
102
125
  Limits: () => Limits,
126
+ MlInstallPhase: () => MlInstallPhase,
127
+ MlInstallProgress: () => MlInstallProgress,
128
+ MlProgress: () => MlProgress,
129
+ MlRuntimeState: () => MlRuntimeState,
130
+ MlServiceState: () => MlServiceState,
131
+ MlServiceStatus: () => MlServiceStatus,
132
+ MlStatusParams: () => MlStatusParams,
133
+ MlStatusResult: () => MlStatusResult,
134
+ ModelsInstallParams: () => ModelsInstallParams,
135
+ ModelsInstallResult: () => ModelsInstallResult,
136
+ ModelsProgressEvent: () => ModelsProgressEvent,
137
+ ModelsStatusParams: () => ModelsStatusParams,
138
+ ModelsStatusResult: () => ModelsStatusResult,
139
+ ModelsTranscribeParams: () => ModelsTranscribeParams,
140
+ ModelsTranscribeResult: () => ModelsTranscribeResult,
103
141
  NAMED_SCHEMAS: () => NAMED_SCHEMAS,
104
142
  NULL_SINCE: () => NULL_SINCE,
105
143
  OPS: () => OPS,
@@ -113,6 +151,7 @@ __export(src_exports, {
113
151
  ProtocolErrorBody: () => ProtocolErrorBody,
114
152
  ProtocolVersion: () => ProtocolVersion,
115
153
  PtyInfo: () => PtyInfo,
154
+ REASONS_SINCE: () => REASONS_SINCE,
116
155
  RELAY_CALL_HELLO_ID: () => RELAY_CALL_HELLO_ID,
117
156
  RELAY_CALL_REQUEST_ID: () => RELAY_CALL_REQUEST_ID,
118
157
  RELAY_CALL_VERSION_HEADER: () => RELAY_CALL_VERSION_HEADER,
@@ -131,7 +170,22 @@ __export(src_exports, {
131
170
  ResourceId: () => ResourceId,
132
171
  ResourceInfo: () => ResourceInfo,
133
172
  ResponseMsg: () => ResponseMsg,
173
+ SERVICES: () => SERVICES,
174
+ SERVICE_MAX_FRAME_BYTES: () => SERVICE_MAX_FRAME_BYTES,
134
175
  SUBPROTOCOL: () => SUBPROTOCOL,
176
+ ServiceCancel: () => ServiceCancel,
177
+ ServiceErrorMsg: () => ServiceErrorMsg,
178
+ ServiceHello: () => ServiceHello,
179
+ ServiceName: () => ServiceName,
180
+ ServicePing: () => ServicePing,
181
+ ServicePong: () => ServicePong,
182
+ ServiceProgressMsg: () => ServiceProgressMsg,
183
+ ServiceRequest: () => ServiceRequest,
184
+ ServiceResponse: () => ServiceResponse,
185
+ ServiceShutdown: () => ServiceShutdown,
186
+ ServiceToCoreMsg: () => ServiceToCoreMsg,
187
+ ServiceToken: () => ServiceToken,
188
+ ServiceWelcome: () => ServiceWelcome,
135
189
  SessionAttachParams: () => SessionAttachParams,
136
190
  SessionAttachResult: () => SessionAttachResult,
137
191
  SessionControlChangedEvent: () => SessionControlChangedEvent,
@@ -146,10 +200,26 @@ __export(src_exports, {
146
200
  StreamMsg: () => StreamMsg,
147
201
  SysinfoGetParams: () => SysinfoGetParams,
148
202
  SysinfoGetResult: () => SysinfoGetResult,
203
+ TOOL_CATALOG: () => TOOL_CATALOG,
204
+ TOOL_GROUPS: () => TOOL_GROUPS,
205
+ TOOL_LEVELS: () => TOOL_LEVELS,
206
+ TOOL_PLATFORMS: () => TOOL_PLATFORMS,
207
+ ToolLevel: () => ToolLevel,
208
+ ToolLevelResult: () => ToolLevelResult,
209
+ ToolName: () => ToolName,
210
+ ToolOutcome: () => ToolOutcome,
211
+ ToolPlatform: () => ToolPlatform,
212
+ ToolResultsFile: () => ToolResultsFile,
213
+ ToolTransport: () => ToolTransport,
214
+ TranscriptSegment: () => TranscriptSegment,
215
+ TranscriptionModelId: () => TranscriptionModelId,
216
+ TranscriptionModelInfo: () => TranscriptionModelInfo,
149
217
  VERSIONED_RESULT_OPS: () => VERSIONED_RESULT_OPS,
150
218
  Welcome: () => Welcome,
151
219
  announcedVersion: () => announcedVersion,
152
220
  assertFrameHeader: () => assertFrameHeader,
221
+ buildToolStatus: () => buildToolStatus,
222
+ builtOps: () => builtOps,
153
223
  closeRule: () => closeRule,
154
224
  compareVersions: () => compareVersions,
155
225
  connectionEndFrame: () => connectionEndFrame,
@@ -165,6 +235,7 @@ __export(src_exports, {
165
235
  negotiate: () => negotiate,
166
236
  nonNegInt: () => nonNegInt,
167
237
  readCid: () => readCid,
238
+ renderToolStatusMarkdown: () => renderToolStatusMarkdown,
168
239
  stampCid: () => stampCid,
169
240
  statusForPeer: () => statusForPeer,
170
241
  u32: () => u32,
@@ -175,7 +246,7 @@ module.exports = __toCommonJS(src_exports);
175
246
  // src/schema/primitives.ts
176
247
  var import_zod = require("zod");
177
248
  var PROTOCOL_MAJOR = 1;
178
- var PROTOCOL_MINOR = 1;
249
+ var PROTOCOL_MINOR = 2;
179
250
  var PROTOCOL_VERSION = `${PROTOCOL_MAJOR}.${PROTOCOL_MINOR}`;
180
251
  var ProtocolVersion = import_zod.z.string().regex(/^[1-9][0-9]{0,2}\.[0-9]{1,3}$/);
181
252
  var RequestId = import_zod.z.string().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/);
@@ -234,7 +305,22 @@ var ErrorReason = import_zod2.z.enum([
234
305
  "resource_expired",
235
306
  "control_taken",
236
307
  // another client of the same user took control
237
- "window_exhausted"
308
+ "window_exhausted",
309
+ // 1.2 (REASONS_SINCE): the `models` capability and its supervised Python service
310
+ "runtime_not_installed",
311
+ // NOT_FOUND: install the inference runtime first (models.install)
312
+ "model_not_installed",
313
+ // NOT_FOUND: that model's weights are not on the device
314
+ "unsupported_media",
315
+ // INVALID_PARAMS: the file is not audio or video the decoder reads
316
+ "download_failed",
317
+ // install could not fetch a package or model file
318
+ "service_starting",
319
+ // RESOURCE_BUSY (retryable): the service is starting or restarting
320
+ "service_restarted",
321
+ // RESOURCE_GONE: the service died while this request ran
322
+ "service_failed"
323
+ // INTERNAL: the service could not be started (see models.status)
238
324
  ]);
239
325
  var FsPatchEditFailure = import_zod2.z.strictObject({ edit_index: nonNegInt, reason: import_zod2.z.string().max(300) });
240
326
  var ProtocolErrorBody = import_zod2.z.strictObject({
@@ -860,6 +946,254 @@ var RelayCallEnvelope = import_zod9.z.strictObject({
860
946
  });
861
947
  var RelayStatusResponse = RelayDeviceStatusEvent;
862
948
 
949
+ // src/schema/models.ts
950
+ var import_zod10 = require("zod");
951
+ var TranscriptionModelId = import_zod10.z.enum(["tiny", "base", "small", "large-v3-turbo"]);
952
+ var MlRuntimeState = import_zod10.z.enum(["not_installed", "installing", "installed", "failed"]);
953
+ var MlInstallPhase = import_zod10.z.enum(["packages", "model", "verifying"]);
954
+ var MlInstallProgress = import_zod10.z.strictObject({
955
+ phase: MlInstallPhase,
956
+ /** What is being fetched now: a package or a model file name. */
957
+ item: import_zod10.z.string().max(200),
958
+ bytes_done: nonNegInt,
959
+ /** Null while the total is not known yet. */
960
+ bytes_total: nonNegInt.nullable()
961
+ });
962
+ var TranscriptionModelInfo = import_zod10.z.strictObject({
963
+ id: TranscriptionModelId,
964
+ /** Download size of the weights. */
965
+ size_bytes: nonNegInt,
966
+ multilingual: import_zod10.z.boolean(),
967
+ installed: import_zod10.z.boolean()
968
+ });
969
+ var TranscriptSegment = import_zod10.z.strictObject({
970
+ start_s: import_zod10.z.number().min(0),
971
+ end_s: import_zod10.z.number().min(0),
972
+ text: import_zod10.z.string().max(4e3)
973
+ });
974
+ var MlStatusParams = import_zod10.z.strictObject({});
975
+ var MlStatusResult = import_zod10.z.strictObject({
976
+ runtime: MlRuntimeState,
977
+ /** Non-null while runtime or model files are being installed. */
978
+ install: MlInstallProgress.nullable(),
979
+ /** The last install failure, one human line; null when the last install succeeded or none ran. */
980
+ error: import_zod10.z.string().max(300).nullable(),
981
+ /** Where inference runs once the runtime is installed: `cuda` only when a usable GPU is present. */
982
+ accelerator: import_zod10.z.enum(["cpu", "cuda"]),
983
+ models: import_zod10.z.array(TranscriptionModelInfo).max(16),
984
+ default_model: TranscriptionModelId
985
+ });
986
+ var ModelsInstallParams = import_zod10.z.strictObject({ model: TranscriptionModelId.optional() });
987
+ var ModelsInstallResult = import_zod10.z.strictObject({ model: TranscriptionModelId, elapsed_ms: nonNegInt });
988
+ var ModelsTranscribeParams = import_zod10.z.strictObject({
989
+ path: AbsPath,
990
+ model: TranscriptionModelId.optional(),
991
+ language: import_zod10.z.string().regex(/^[a-z]{2,3}$/).optional(),
992
+ task: import_zod10.z.enum(["transcribe", "translate"]).default("transcribe")
993
+ });
994
+ var ModelsTranscribeResult = import_zod10.z.strictObject({
995
+ text: import_zod10.z.string().max(4e5),
996
+ language: import_zod10.z.string().max(8),
997
+ language_probability: import_zod10.z.number().min(0).max(1),
998
+ duration_s: import_zod10.z.number().min(0),
999
+ model: TranscriptionModelId,
1000
+ segments: import_zod10.z.array(TranscriptSegment).max(2e4),
1001
+ elapsed_ms: nonNegInt
1002
+ });
1003
+ var MlProgress = import_zod10.z.strictObject({
1004
+ kind: import_zod10.z.enum(["install", "transcribe"]),
1005
+ /** 0–1 when known (transcribe: audio covered so far; install: bytes so far). */
1006
+ fraction: import_zod10.z.number().min(0).max(1).nullable(),
1007
+ install: MlInstallProgress.nullable(),
1008
+ /** The segment just transcribed (transcribe only): text appears as it is recognised. */
1009
+ segment: TranscriptSegment.nullable()
1010
+ });
1011
+ var MlServiceState = import_zod10.z.enum(["starting", "ready", "restarting", "failed", "stopped"]);
1012
+ var MlServiceStatus = import_zod10.z.strictObject({
1013
+ state: MlServiceState,
1014
+ pid: nonNegInt.nullable(),
1015
+ /** Restarts since the app started (crashes, missed health checks). */
1016
+ restarts: nonNegInt,
1017
+ /** The bundled interpreter's version once the service has answered, e.g. "3.13.15". */
1018
+ python: import_zod10.z.string().max(32).nullable(),
1019
+ /** Why the service is restarting or failed, one human line. */
1020
+ error: import_zod10.z.string().max(300).nullable()
1021
+ });
1022
+ var ModelsStatusParams = import_zod10.z.strictObject({});
1023
+ var ModelsStatusResult = import_zod10.z.strictObject({
1024
+ service: MlServiceStatus,
1025
+ /** Null until the service has answered (starting, restarting, failed). */
1026
+ transcription: MlStatusResult.nullable()
1027
+ });
1028
+ var ModelsProgressEvent = import_zod10.z.strictObject({ request_id: RequestId, progress: MlProgress });
1029
+
1030
+ // src/schema/apps.ts
1031
+ var import_zod11 = require("zod");
1032
+ var AppKey = import_zod11.z.string().regex(/^[a-z][a-z0-9_-]{0,39}$/);
1033
+ var AppProfileId = import_zod11.z.string().regex(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/);
1034
+ var AppProfileLocator = import_zod11.z.string().min(1).max(512).regex(/^[A-Za-z0-9 _()+@,-][A-Za-z0-9 ._()+@,-]{0,127}(\/[A-Za-z0-9 _()+@,-][A-Za-z0-9 ._()+@,-]{0,127}){0,7}$/);
1035
+ var AppSupport = import_zod11.z.enum(["supported", "partial", "unsupported"]);
1036
+ var AppFeatureStatus = import_zod11.z.strictObject({
1037
+ status: AppSupport,
1038
+ /** One line, set whenever status is not "supported". */
1039
+ reason: import_zod11.z.string().max(140).nullable()
1040
+ });
1041
+ var AppInfo = import_zod11.z.strictObject({
1042
+ app_key: AppKey,
1043
+ name: import_zod11.z.string().max(64),
1044
+ installed: import_zod11.z.boolean(),
1045
+ /** The app's own version string, or null when it is not installed or does not say. */
1046
+ version: import_zod11.z.string().max(64).nullable(),
1047
+ /** The install found (an .app bundle, an .exe, a binary), or null. */
1048
+ location: AbsPath.nullable(),
1049
+ /** Open the app at all on this OS. */
1050
+ open: AppFeatureStatus,
1051
+ /** Separate profiles (one account each) on this OS. */
1052
+ profiles: AppFeatureStatus,
1053
+ /** Plan usage read from the app's own files on this OS. */
1054
+ usage: AppFeatureStatus
1055
+ });
1056
+ var AppUsageReading = import_zod11.z.strictObject({
1057
+ window: import_zod11.z.enum(["five_hour", "weekly", "extra"]),
1058
+ /** 0–100 for five_hour and weekly; extra-usage spend as a percent of its cap (may pass 100). */
1059
+ percent: import_zod11.z.number().min(0).max(1e4),
1060
+ /** When the app recorded it. */
1061
+ sampled_at_ms: epochMs,
1062
+ /** True when the window has rolled over since the sample, so the figure has reset. */
1063
+ reset_since: import_zod11.z.boolean()
1064
+ });
1065
+ var AppProfile = import_zod11.z.strictObject({
1066
+ /** The row's id; null for a folder found on disk that no row names yet. */
1067
+ id: AppProfileId.nullable(),
1068
+ app_key: AppKey,
1069
+ display_name: import_zod11.z.string().min(1).max(120),
1070
+ /** The account the person means to be signed in here; null when not stated (never guessed). */
1071
+ account_identity: import_zod11.z.string().min(3).max(320).nullable(),
1072
+ profile_locator: AppProfileLocator.nullable(),
1073
+ /** The device the row is tied to; null when the row names none. */
1074
+ device_id: DeviceId.nullable(),
1075
+ /** The folder this profile resolves to on this device; null for a row tied to another device. */
1076
+ folder: AbsPath.nullable(),
1077
+ /** The folder exists on this device. */
1078
+ on_disk: import_zod11.z.boolean(),
1079
+ /** An instance with this profile is running; null when it could not be determined. */
1080
+ running: import_zod11.z.boolean().nullable(),
1081
+ /** Usage the app recorded for this profile; null when the app exposes none here. */
1082
+ usage: import_zod11.z.array(AppUsageReading).nullable(),
1083
+ last_opened_ms: epochMs.nullable()
1084
+ });
1085
+ var AppsListParams = import_zod11.z.strictObject({});
1086
+ var AppsListResult = import_zod11.z.strictObject({ apps: import_zod11.z.array(AppInfo) });
1087
+ var AppsProfilesListParams = import_zod11.z.strictObject({
1088
+ /** Only this app's profiles; every app's when absent. */
1089
+ app_key: AppKey.optional()
1090
+ });
1091
+ var AppsProfilesListResult = import_zod11.z.strictObject({
1092
+ profiles: import_zod11.z.array(AppProfile),
1093
+ /**
1094
+ * Whether the saved rows could be read: false while signed out or offline, when only folders
1095
+ * found on disk are listed.
1096
+ */
1097
+ registry: import_zod11.z.enum(["ok", "signed_out", "unavailable"])
1098
+ });
1099
+ var AppsProfilesSaveParams = import_zod11.z.strictObject({
1100
+ id: AppProfileId.optional(),
1101
+ app_key: AppKey,
1102
+ display_name: import_zod11.z.string().min(1).max(120),
1103
+ account_identity: import_zod11.z.string().min(3).max(320).nullable(),
1104
+ /** On create: the folder to use (one found on disk), or null for the app's default profile. Ignored on update. */
1105
+ profile_locator: AppProfileLocator.nullable(),
1106
+ /** On create with profile_locator null: make a new folder named after display_name instead. */
1107
+ new_folder: import_zod11.z.boolean().default(false)
1108
+ });
1109
+ var AppsProfilesSaveResult = AppProfile;
1110
+ var AppsProfilesRemoveParams = import_zod11.z.strictObject({ id: AppProfileId });
1111
+ var AppsProfilesRemoveResult = import_zod11.z.strictObject({ removed: import_zod11.z.boolean() });
1112
+ var AppsOpenParams = import_zod11.z.strictObject({
1113
+ app_key: AppKey,
1114
+ profile_id: AppProfileId.optional()
1115
+ });
1116
+ var AppsOpenResult = import_zod11.z.strictObject({
1117
+ /** True when an instance with this profile was already running; it is brought forward. */
1118
+ already_running: import_zod11.z.boolean(),
1119
+ folder: AbsPath.nullable()
1120
+ });
1121
+
1122
+ // src/schema/service.ts
1123
+ var import_zod12 = require("zod");
1124
+ var SERVICE_MAX_FRAME_BYTES = 16777216;
1125
+ var ServiceName = import_zod12.z.enum(["ml"]);
1126
+ var ContractHash = import_zod12.z.string().regex(/^[0-9a-f]{64}$/);
1127
+ var ServiceToken = import_zod12.z.string().regex(/^[A-Za-z0-9_-]{43}$/);
1128
+ var ServiceRequestId = u32;
1129
+ var ServiceHello = import_zod12.z.strictObject({ type: import_zod12.z.literal("hello"), token: ServiceToken, contract: ContractHash });
1130
+ var ServiceWelcome = import_zod12.z.strictObject({
1131
+ type: import_zod12.z.literal("welcome"),
1132
+ service: ServiceName,
1133
+ contract: ContractHash,
1134
+ pid: nonNegInt,
1135
+ /** The interpreter's version, e.g. "3.13.15". */
1136
+ python: import_zod12.z.string().max(32),
1137
+ /** Every op this service serves; must equal SERVICES[service] exactly. */
1138
+ ops: import_zod12.z.array(import_zod12.z.string().min(1).max(64)).max(64)
1139
+ });
1140
+ var ServiceRequest = import_zod12.z.strictObject({
1141
+ type: import_zod12.z.literal("request"),
1142
+ id: ServiceRequestId,
1143
+ op: import_zod12.z.string().min(1).max(64),
1144
+ params: import_zod12.z.unknown()
1145
+ // validated by the service against SERVICES[service][op].params
1146
+ });
1147
+ var ServiceResponse = import_zod12.z.strictObject({
1148
+ type: import_zod12.z.literal("response"),
1149
+ id: ServiceRequestId,
1150
+ result: import_zod12.z.unknown()
1151
+ // validated by the core against SERVICES[service][op].result
1152
+ });
1153
+ var ServiceErrorMsg = import_zod12.z.strictObject({ type: import_zod12.z.literal("error"), id: ServiceRequestId, error: ProtocolErrorBody });
1154
+ var ServiceProgressMsg = import_zod12.z.strictObject({ type: import_zod12.z.literal("progress"), id: ServiceRequestId, progress: import_zod12.z.unknown() });
1155
+ var ServiceCancel = import_zod12.z.strictObject({ type: import_zod12.z.literal("cancel"), id: ServiceRequestId });
1156
+ var ServicePing = import_zod12.z.strictObject({ type: import_zod12.z.literal("ping"), id: ServiceRequestId });
1157
+ var ServicePong = import_zod12.z.strictObject({
1158
+ type: import_zod12.z.literal("pong"),
1159
+ id: ServiceRequestId,
1160
+ /** Requests running now. */
1161
+ busy: nonNegInt
1162
+ });
1163
+ var ServiceShutdown = import_zod12.z.strictObject({ type: import_zod12.z.literal("shutdown") });
1164
+ var CoreToServiceMsg = import_zod12.z.discriminatedUnion("type", [ServiceHello, ServiceRequest, ServiceCancel, ServicePing, ServiceShutdown]);
1165
+ var ServiceToCoreMsg = import_zod12.z.discriminatedUnion("type", [ServiceWelcome, ServiceResponse, ServiceErrorMsg, ServiceProgressMsg, ServicePong]);
1166
+
1167
+ // src/schema/tools.ts
1168
+ var import_zod13 = require("zod");
1169
+ var ToolLevel = import_zod13.z.enum(["programmatic", "protocol", "chat"]);
1170
+ var ToolOutcome = import_zod13.z.enum(["pass", "fail", "skip"]);
1171
+ var ToolPlatform = import_zod13.z.enum(["darwin", "win32", "linux"]);
1172
+ var ToolTransport = import_zod13.z.enum(["in_process", "localhost", "relay", "agent"]);
1173
+ var ToolName = import_zod13.z.string().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/);
1174
+ var ToolLevelResult = import_zod13.z.strictObject({
1175
+ tool: ToolName,
1176
+ level: ToolLevel,
1177
+ platform: ToolPlatform,
1178
+ transport: ToolTransport,
1179
+ outcome: ToolOutcome,
1180
+ /** True when the caller sat on a different network from the device (a phone on cellular, CI). */
1181
+ remote_network: import_zod13.z.boolean(),
1182
+ /** One line: what was asserted, or why it failed. Never a token, a file's contents or a path under a real home. */
1183
+ detail: import_zod13.z.string().max(500),
1184
+ /** The harness that produced it, e.g. `matrx-desktop test/tools/programmatic.test.ts`. */
1185
+ suite: import_zod13.z.string().min(1).max(200),
1186
+ /** The test case inside the suite. */
1187
+ test: import_zod13.z.string().min(1).max(300),
1188
+ run_at_ms: import_zod13.z.int().min(0)
1189
+ });
1190
+ var ToolResultsFile = import_zod13.z.strictObject({
1191
+ schema: import_zod13.z.literal("matrx.tool-results.v1"),
1192
+ /** The producing repo's commit (short or full SHA). */
1193
+ commit: import_zod13.z.string().min(4).max(64),
1194
+ results: import_zod13.z.array(ToolLevelResult).max(1e4)
1195
+ });
1196
+
863
1197
  // src/schema/registry.ts
864
1198
  var FS_ERR = ["NOT_FOUND", "PERMISSION_DENIED_OS", "INVALID_PARAMS", "RESOURCE_BUSY", "INTERNAL"];
865
1199
  var OPS = {
@@ -886,7 +1220,17 @@ var OPS = {
886
1220
  "session.attach": { params: SessionAttachParams, result: SessionAttachResult, kind: "stream", since: "1.0", errors: ["RESOURCE_GONE", "AUTH_FORBIDDEN", "RESOURCE_BUSY"] },
887
1221
  "session.detach": { params: SessionDetachParams, result: SessionDetachResult, kind: "unary", since: "1.0", errors: ["RESOURCE_GONE"] },
888
1222
  "session.release": { params: SessionReleaseParams, result: SessionReleaseResult, kind: "unary", since: "1.0", errors: ["RESOURCE_GONE", "AUTH_FORBIDDEN"] },
889
- "session.list": { params: SessionListParams, result: SessionListResult, kind: "unary", since: "1.0", errors: ["INTERNAL"] }
1223
+ "session.list": { params: SessionListParams, result: SessionListResult, kind: "unary", since: "1.0", errors: ["INTERNAL"] },
1224
+ // Local models (SPEC §6), served by the `ml` Python service through SERVICES below.
1225
+ "models.status": { params: ModelsStatusParams, result: ModelsStatusResult, kind: "unary", since: "1.2", errors: ["INTERNAL"] },
1226
+ "models.install": { params: ModelsInstallParams, result: ModelsInstallResult, kind: "unary", since: "1.2", errors: ["RESOURCE_BUSY", "RESOURCE_GONE", "TIMEOUT", "CANCELLED", "INTERNAL"] },
1227
+ "models.transcribe": { params: ModelsTranscribeParams, result: ModelsTranscribeResult, kind: "unary", since: "1.2", errors: ["NOT_FOUND", "INVALID_PARAMS", "PERMISSION_DENIED_OS", "RESOURCE_BUSY", "RESOURCE_GONE", "CANCELLED", "PAYLOAD_TOO_LARGE", "INTERNAL"] },
1228
+ // Desktop apps and their profiles (SPEC §6 apps); profiles are rows in users.desktop_app_profile.
1229
+ "apps.list": { params: AppsListParams, result: AppsListResult, kind: "unary", since: "1.2", errors: ["INTERNAL"] },
1230
+ "apps.profiles.list": { params: AppsProfilesListParams, result: AppsProfilesListResult, kind: "unary", since: "1.2", errors: ["NOT_FOUND", "INVALID_PARAMS", "INTERNAL"] },
1231
+ "apps.profiles.save": { params: AppsProfilesSaveParams, result: AppsProfilesSaveResult, kind: "unary", since: "1.2", errors: ["AUTH_REQUIRED", "AUTH_FORBIDDEN", "NOT_FOUND", "INVALID_PARAMS", "CONFLICT", "PLATFORM_UNSUPPORTED", "DEVICE_OFFLINE", "INTERNAL"] },
1232
+ "apps.profiles.remove": { params: AppsProfilesRemoveParams, result: AppsProfilesRemoveResult, kind: "unary", since: "1.2", errors: ["AUTH_REQUIRED", "AUTH_FORBIDDEN", "NOT_FOUND", "DEVICE_OFFLINE", "INTERNAL"] },
1233
+ "apps.open": { params: AppsOpenParams, result: AppsOpenResult, kind: "unary", since: "1.2", errors: ["NOT_FOUND", "PLATFORM_UNSUPPORTED", "AUTH_REQUIRED", "DEVICE_OFFLINE", "INTERNAL"] }
890
1234
  };
891
1235
  var EVENTS = {
892
1236
  "fs.changed": FsChangedEvent,
@@ -894,9 +1238,20 @@ var EVENTS = {
894
1238
  "exec.title": ExecTitleEvent,
895
1239
  "exec.cwd": ExecCwdEvent,
896
1240
  "session.control_changed": SessionControlChangedEvent,
1241
+ "models.progress": ModelsProgressEvent,
897
1242
  "relay.device_status": RelayDeviceStatusEvent,
898
1243
  "relay.auth_expiring": RelayAuthExpiringEvent
899
1244
  };
1245
+ var SERVICES = {
1246
+ ml: {
1247
+ progress: MlProgress,
1248
+ ops: {
1249
+ "ml.status": { params: MlStatusParams, result: MlStatusResult },
1250
+ "ml.install": { params: ModelsInstallParams, result: ModelsInstallResult },
1251
+ "ml.transcribe": { params: ModelsTranscribeParams, result: ModelsTranscribeResult }
1252
+ }
1253
+ }
1254
+ };
900
1255
  var NAMED_SCHEMAS = {
901
1256
  ProtocolVersion,
902
1257
  RequestId,
@@ -985,6 +1340,39 @@ var NAMED_SCHEMAS = {
985
1340
  SessionListParams,
986
1341
  SessionListResult,
987
1342
  SessionControlChangedEvent,
1343
+ TranscriptionModelId,
1344
+ MlRuntimeState,
1345
+ MlInstallPhase,
1346
+ MlInstallProgress,
1347
+ TranscriptionModelInfo,
1348
+ TranscriptSegment,
1349
+ MlStatusParams,
1350
+ MlStatusResult,
1351
+ ModelsInstallParams,
1352
+ ModelsInstallResult,
1353
+ ModelsTranscribeParams,
1354
+ ModelsTranscribeResult,
1355
+ MlProgress,
1356
+ MlServiceState,
1357
+ MlServiceStatus,
1358
+ ModelsStatusParams,
1359
+ ModelsStatusResult,
1360
+ ModelsProgressEvent,
1361
+ ServiceName,
1362
+ ContractHash,
1363
+ ServiceToken,
1364
+ ServiceHello,
1365
+ ServiceWelcome,
1366
+ ServiceRequest,
1367
+ ServiceResponse,
1368
+ ServiceErrorMsg,
1369
+ ServiceProgressMsg,
1370
+ ServiceCancel,
1371
+ ServicePing,
1372
+ ServicePong,
1373
+ ServiceShutdown,
1374
+ CoreToServiceMsg,
1375
+ ServiceToCoreMsg,
988
1376
  RelayDeviceStatusEvent,
989
1377
  RelayAuthExpiringEvent,
990
1378
  RelayCallRequest,
@@ -993,7 +1381,31 @@ var NAMED_SCHEMAS = {
993
1381
  RelayCallEnvelope,
994
1382
  RelayHopEnvelopeHeader,
995
1383
  RelayHopConnectionEnd,
996
- CloseCodeValue
1384
+ CloseCodeValue,
1385
+ ToolLevel,
1386
+ ToolOutcome,
1387
+ ToolPlatform,
1388
+ ToolTransport,
1389
+ ToolName,
1390
+ ToolLevelResult,
1391
+ ToolResultsFile,
1392
+ AppKey,
1393
+ AppProfileId,
1394
+ AppProfileLocator,
1395
+ AppSupport,
1396
+ AppFeatureStatus,
1397
+ AppInfo,
1398
+ AppUsageReading,
1399
+ AppProfile,
1400
+ AppsListParams,
1401
+ AppsListResult,
1402
+ AppsProfilesListParams,
1403
+ AppsProfilesListResult,
1404
+ AppsProfilesSaveParams,
1405
+ AppsProfilesRemoveParams,
1406
+ AppsProfilesRemoveResult,
1407
+ AppsOpenParams,
1408
+ AppsOpenResult
997
1409
  };
998
1410
 
999
1411
  // src/versioning.ts
@@ -1006,6 +1418,15 @@ var FIELDS_SINCE = {
1006
1418
  var NULL_SINCE = {
1007
1419
  "RelayDeviceStatusEvent.since_ms": { since: "1.1", olderPeersGet: 0 }
1008
1420
  };
1421
+ var REASONS_SINCE = {
1422
+ runtime_not_installed: "1.2",
1423
+ model_not_installed: "1.2",
1424
+ unsupported_media: "1.2",
1425
+ download_failed: "1.2",
1426
+ service_starting: "1.2",
1427
+ service_restarted: "1.2",
1428
+ service_failed: "1.2"
1429
+ };
1009
1430
  function statusForPeer(status, version) {
1010
1431
  const rule = NULL_SINCE["RelayDeviceStatusEvent.since_ms"];
1011
1432
  return status.since_ms === null && !knows(version, rule.since) ? { ...status, since_ms: rule.olderPeersGet } : status;
@@ -1054,11 +1475,20 @@ function forPeer(op, part, value, version) {
1054
1475
  if (value === null || typeof value !== "object") return value;
1055
1476
  const body = value;
1056
1477
  if (body.data === void 0) return value;
1057
- const data = strip(body.data, FIELDS_SINCE["ProtocolErrorBody.data"], version);
1478
+ let data = strip(body.data, FIELDS_SINCE["ProtocolErrorBody.data"], version);
1479
+ const reason = data.reason;
1480
+ const reasonSince = typeof reason === "string" ? REASONS_SINCE[reason] : void 0;
1481
+ if (reasonSince && !knows(version, reasonSince)) {
1482
+ const { reason: _dropped, ...rest } = data;
1483
+ data = rest;
1484
+ }
1058
1485
  return data === body.data ? value : { ...body, data };
1059
1486
  }
1060
1487
  var VERSIONED_RESULT_OPS = [...RESULT_PATH.keys()];
1061
1488
 
1489
+ // src/contract.ts
1490
+ var CONTRACT_SHA256 = "ef9fd8c8ab611bf450730452a6cf48a4ebd566218b6e17e2834ef030fc2044cb";
1491
+
1062
1492
  // src/close-policy.ts
1063
1493
  var CLOSE_RULES = {
1064
1494
  [CloseCode.NORMAL]: { action: "reconnect", error: ["DEVICE_OFFLINE", "Connection closed"] },
@@ -1084,4 +1514,316 @@ function closeRule(code) {
1084
1514
  function isTerminalClose(code) {
1085
1515
  return closeRule(code).action === "stop";
1086
1516
  }
1517
+
1518
+ // src/tools/catalog.ts
1519
+ var TOOL_GROUPS = [
1520
+ { id: "files_shell", order: 1, title: "Files and shell", owner: "core" },
1521
+ { id: "os_control", order: 2, title: "Computer control", owner: "core" },
1522
+ { id: "personal_automation", order: 3, title: "Personal apps and automation", owner: "core" },
1523
+ { id: "tools_service", order: 4, title: "Documents, OCR and entities", owner: "python_tools" },
1524
+ { id: "ml_service", order: 5, title: "Speech", owner: "python_ml" },
1525
+ { id: "windows_admin", order: 6, title: "Windows administration", owner: "core" }
1526
+ ];
1527
+ var ALL = ["darwin", "win32", "linux"];
1528
+ var TOOL_CATALOG = [
1529
+ // ── 1. Files and shell (core `fs`, `exec`; the cloud sandbox's agent tools) ──────────────────
1530
+ { name: "fs_read", group: "files_shell", state: "built", path: "sandbox_proxy", ops: ["fs.read"], platforms: ALL, summary: "Read a file, paged" },
1531
+ { name: "fs_write", group: "files_shell", state: "built", path: "sandbox_proxy", ops: ["fs.read", "fs.write"], platforms: ALL, summary: "Create or overwrite a file" },
1532
+ { name: "fs_edit", group: "files_shell", state: "built", path: "sandbox_proxy", ops: ["fs.read", "fs.patch"], platforms: ALL, summary: "Replace one exact string" },
1533
+ { name: "fs_patch", group: "files_shell", state: "built", path: "sandbox_proxy", ops: ["fs.read", "fs.patch"], platforms: ALL, summary: "Apply several exact edits at once" },
1534
+ { name: "fs_list", group: "files_shell", state: "built", path: "sandbox_proxy", ops: ["fs.list"], platforms: ALL, summary: "List a folder" },
1535
+ { name: "fs_mkdir", group: "files_shell", state: "built", path: "sandbox_proxy", ops: ["fs.mkdir"], platforms: ALL, summary: "Create a folder" },
1536
+ { name: "fs_search", group: "files_shell", state: "built", path: "sandbox_proxy", ops: ["fs.search_paths", "fs.search_content"], platforms: ALL, summary: "Find files by name or content" },
1537
+ { name: "shell_execute", group: "files_shell", state: "built", path: "sandbox_proxy", ops: ["exec.run"], platforms: ALL, summary: "Run a command in a folder" },
1538
+ { name: "shell_python", group: "files_shell", state: "built", path: "sandbox_proxy", ops: ["exec.run"], platforms: ALL, summary: "Run a Python script" },
1539
+ {
1540
+ name: "git_ingest",
1541
+ group: "files_shell",
1542
+ state: "broken",
1543
+ path: "server",
1544
+ ops: [],
1545
+ platforms: ALL,
1546
+ summary: "Digest a repository",
1547
+ note: "Armed with the files tools, but a local path is read on the server, not the bound device"
1548
+ },
1549
+ { name: "shell_job", group: "files_shell", state: "planned", path: "device_op", ops: ["exec.job.start", "exec.job.output", "exec.job.stop"], platforms: ALL, summary: "Background commands: start, read output, stop" },
1550
+ // ── 2. Computer control (TS owners) ──────────────────────────────────────────────────────────
1551
+ { name: "desktop_process", group: "os_control", state: "planned", path: "device_op", ops: ["proc.list", "proc.ports", "proc.kill", "proc.launch_app", "proc.focus_app", "proc.installed_apps"], platforms: ALL, summary: "Processes, ports and apps" },
1552
+ { name: "desktop_system", group: "os_control", state: "planned", path: "device_op", ops: ["sysinfo.get", "system.open_url", "system.open_path", "system.notify"], platforms: ALL, summary: "System facts, open, notify" },
1553
+ { name: "desktop_clipboard", group: "os_control", state: "planned", path: "device_op", ops: ["clipboard.read", "clipboard.write"], platforms: ALL, summary: "Read and write the clipboard" },
1554
+ { name: "desktop_screen", group: "os_control", state: "planned", path: "device_op", ops: ["screen.list", "screen.capture"], platforms: ALL, summary: "Displays and screenshots" },
1555
+ { name: "desktop_window", group: "os_control", state: "planned", path: "device_op", ops: ["window.list", "window.focus", "window.move", "window.minimize"], platforms: ALL, summary: "Find, focus and arrange windows" },
1556
+ { name: "desktop_input", group: "os_control", state: "planned", path: "device_op", ops: ["input.type_text", "input.hotkey", "input.mouse_click", "input.mouse_move"], platforms: ALL, summary: "Keyboard and mouse" },
1557
+ { name: "desktop_audio", group: "os_control", state: "planned", path: "device_op", ops: ["audio.devices", "audio.record", "audio.play"], platforms: ALL, summary: "Audio devices, record, play" },
1558
+ { name: "desktop_power", group: "os_control", state: "planned", path: "device_op", ops: ["power.status", "power.prevent_sleep"], platforms: ALL, summary: "Battery and keep awake" },
1559
+ { name: "desktop_resources", group: "os_control", state: "planned", path: "device_op", ops: ["resources.snapshot", "resources.top"], platforms: ALL, summary: "CPU, memory and disk use" },
1560
+ { name: "fs_watch", group: "os_control", state: "planned", path: "device_op", ops: ["fs.watch"], platforms: ALL, summary: "Watch a folder for changes" },
1561
+ // ── 3. Personal apps and automation ──────────────────────────────────────────────────────────
1562
+ { name: "desktop_automation", group: "personal_automation", state: "planned", path: "device_op", ops: ["automation.script"], platforms: ["darwin", "win32"], summary: "AppleScript on a Mac, PowerShell on Windows" },
1563
+ { name: "desktop_mail", group: "personal_automation", state: "planned", path: "device_op", ops: ["mail.accounts", "mail.list", "mail.send"], platforms: ["darwin"], summary: "The Mail app" },
1564
+ { name: "desktop_messages", group: "personal_automation", state: "planned", path: "device_op", ops: ["messages.conversations", "messages.list", "messages.send"], platforms: ["darwin"], summary: "The Messages app" },
1565
+ { name: "desktop_contacts", group: "personal_automation", state: "planned", path: "device_op", ops: ["contacts.search", "contacts.get"], platforms: ["darwin"], summary: "Contacts" },
1566
+ { name: "desktop_calendar", group: "personal_automation", state: "planned", path: "device_op", ops: ["calendar.list", "calendar.create", "reminders.list", "reminders.create"], platforms: ["darwin"], summary: "Calendar and reminders" },
1567
+ { name: "desktop_photos", group: "personal_automation", state: "planned", path: "device_op", ops: ["photos.search", "photos.get"], platforms: ["darwin"], summary: "Photos library" },
1568
+ { name: "desktop_location", group: "personal_automation", state: "planned", path: "device_op", ops: ["location.get"], platforms: ["darwin", "win32"], summary: "Where the computer is" },
1569
+ { name: "desktop_net", group: "personal_automation", state: "planned", path: "device_op", ops: ["net.info", "net.wifi", "net.bluetooth", "net.devices", "net.mdns", "net.scan", "net.download"], platforms: ALL, summary: "Local network and downloads" },
1570
+ // ── 4. Python `tools` service ────────────────────────────────────────────────────────────────
1571
+ { name: "desktop_documents", group: "tools_service", state: "planned", path: "device_op", ops: ["tools.pdf_extract", "tools.office_generate", "tools.ocr", "tools.image_resize"], platforms: ALL, summary: "PDF text, Office files, OCR, images" },
1572
+ { name: "desktop_entities", group: "tools_service", state: "planned", path: "device_op", ops: ["tools.ner", "tools.pii"], platforms: ALL, summary: "Names and private data, found on the device" },
1573
+ // ── 5. Python `ml` service ───────────────────────────────────────────────────────────────────
1574
+ { name: "desktop_transcribe", group: "ml_service", state: "planned", path: "device_op", ops: ["models.transcribe", "models.speech_locales"], platforms: ALL, summary: "Speech to text on the device" },
1575
+ // ── 6. Windows administration ────────────────────────────────────────────────────────────────
1576
+ { name: "desktop_windows_admin", group: "windows_admin", state: "planned", path: "device_op", ops: ["windows.registry_read", "windows.registry_write", "windows.services", "windows.service_control", "windows.event_log", "windows.features"], platforms: ["win32"], summary: "Registry, services, event log" }
1577
+ ];
1578
+ var tool = (name) => ({ kind: "tool", tool: name });
1579
+ var dropped = (reason) => ({ kind: "dropped", reason });
1580
+ var SHELL_COVERS = "Done with shell_execute (mv, cp, rm, tar), as every coding agent does";
1581
+ var CLOUD_SCRAPER = "The cloud scraper and research tools run with this computer as their network (the `proxy` capability)";
1582
+ var LEGACY_ACTIONS = {
1583
+ "local_file.read": tool("fs_read"),
1584
+ "local_file.write": tool("fs_write"),
1585
+ "local_file.edit": tool("fs_edit"),
1586
+ "local_file.move": dropped(SHELL_COVERS),
1587
+ "local_file.copy": dropped(SHELL_COVERS),
1588
+ "local_file.delete": dropped(SHELL_COVERS),
1589
+ "local_file.rename": dropped(SHELL_COVERS),
1590
+ "local_file.mkdir": tool("fs_mkdir"),
1591
+ "local_file.glob": tool("fs_search"),
1592
+ "local_file.grep": tool("fs_search"),
1593
+ "local_file.list": tool("fs_list"),
1594
+ "local_file.places": dropped("The device's home and folders reach the agent in its binding briefing (sysinfo.get)"),
1595
+ "local_file.find": tool("fs_search"),
1596
+ "local_file.semantic_find": dropped("Needs a local embedding index; returns with file sync's index, not before"),
1597
+ "local_shell.run": tool("shell_execute"),
1598
+ "local_shell.output": tool("shell_job"),
1599
+ "local_shell.stop": tool("shell_job"),
1600
+ "local_window.list": tool("desktop_window"),
1601
+ "local_window.focus": tool("desktop_window"),
1602
+ "local_window.move": tool("desktop_window"),
1603
+ "local_window.minimize": tool("desktop_window"),
1604
+ "local_process.list": tool("desktop_process"),
1605
+ "local_process.ports": tool("desktop_process"),
1606
+ "local_process.launch_app": tool("desktop_process"),
1607
+ "local_process.kill": tool("desktop_process"),
1608
+ "local_process.focus_app": tool("desktop_process"),
1609
+ "local_process.terminals": dropped("Matrx 2 terminals are exec sessions; the person's own terminal windows are not the agent's"),
1610
+ "local_process.tail_terminal": dropped("Matrx 2 terminals are exec sessions; the person's own terminal windows are not the agent's"),
1611
+ "local_process.installed_apps": tool("desktop_process"),
1612
+ "local_input.type_text": tool("desktop_input"),
1613
+ "local_input.hotkey": tool("desktop_input"),
1614
+ "local_input.mouse_click": tool("desktop_input"),
1615
+ "local_input.mouse_move": tool("desktop_input"),
1616
+ "local_audio.devices": tool("desktop_audio"),
1617
+ "local_audio.record": tool("desktop_audio"),
1618
+ "local_audio.play": tool("desktop_audio"),
1619
+ "local_audio.transcribe": tool("desktop_transcribe"),
1620
+ "local_audio.transcribe_with_speech": tool("desktop_transcribe"),
1621
+ "local_audio.speech_locales": tool("desktop_transcribe"),
1622
+ "local_clipboard.read": tool("desktop_clipboard"),
1623
+ "local_clipboard.write": tool("desktop_clipboard"),
1624
+ "local_screen.screenshot": tool("desktop_screen"),
1625
+ "local_screen.list": tool("desktop_screen"),
1626
+ "local_screen.capture_book": dropped("A one-off loop of screenshot plus page turn; the agent composes it from desktop_screen and desktop_input"),
1627
+ "local_system.info": tool("desktop_system"),
1628
+ "local_system.open_url": tool("desktop_system"),
1629
+ "local_system.open_path": tool("desktop_system"),
1630
+ "local_system.notify": tool("desktop_system"),
1631
+ "local_browser.navigate": dropped("The browser agent is the extension (matrx-extend) and the cloud browser; a second Playwright on the device duplicates it"),
1632
+ "local_browser.click": dropped("The browser agent is the extension (matrx-extend) and the cloud browser"),
1633
+ "local_browser.type_text": dropped("The browser agent is the extension (matrx-extend) and the cloud browser"),
1634
+ "local_browser.extract": dropped("The browser agent is the extension (matrx-extend) and the cloud browser"),
1635
+ "local_browser.screenshot": dropped("The browser agent is the extension (matrx-extend) and the cloud browser"),
1636
+ "local_browser.eval": dropped("The browser agent is the extension (matrx-extend) and the cloud browser"),
1637
+ "local_browser.tabs": dropped("The browser agent is the extension (matrx-extend) and the cloud browser"),
1638
+ "local_browser.close": dropped("The browser agent is the extension (matrx-extend) and the cloud browser"),
1639
+ "local_web.fetch": dropped(CLOUD_SCRAPER),
1640
+ "local_web.fetch_with_browser": dropped(CLOUD_SCRAPER),
1641
+ "local_web.scrape": dropped(CLOUD_SCRAPER),
1642
+ "local_web.search": dropped(CLOUD_SCRAPER),
1643
+ "local_web.research": dropped(CLOUD_SCRAPER),
1644
+ "local_web.download": tool("desktop_net"),
1645
+ "local_web.upload": dropped("Uploads are cloud files (matrx-files) and file sync, one upload path"),
1646
+ "local_net.info": tool("desktop_net"),
1647
+ "local_net.scan": tool("desktop_net"),
1648
+ "local_net.port_scan": tool("desktop_net"),
1649
+ "local_net.mdns_discover": tool("desktop_net"),
1650
+ "local_net.wifi_networks": tool("desktop_net"),
1651
+ "local_net.bluetooth_devices": tool("desktop_net"),
1652
+ "local_net.connected_devices": tool("desktop_net"),
1653
+ "local_monitor.resources": tool("desktop_resources"),
1654
+ "local_monitor.battery": tool("desktop_power"),
1655
+ "local_monitor.disk_usage": tool("desktop_resources"),
1656
+ "local_monitor.top_processes": tool("desktop_resources"),
1657
+ "local_monitor.watch_directory": tool("fs_watch"),
1658
+ "local_monitor.watch_events": tool("fs_watch"),
1659
+ "local_monitor.stop_watch": tool("fs_watch"),
1660
+ "local_monitor.heartbeat": dropped("The relay's device status replaces the heartbeat"),
1661
+ "local_schedule.create": dropped("One scheduler: the platform's runs the agent on time and reaches the device through the relay"),
1662
+ "local_schedule.list": dropped("One scheduler: the platform's runs the agent on time and reaches the device through the relay"),
1663
+ "local_schedule.cancel": dropped("One scheduler: the platform's runs the agent on time and reaches the device through the relay"),
1664
+ "local_schedule.prevent_sleep": tool("desktop_power"),
1665
+ "local_documents.list": dropped("matrx-local's private document store is gone; documents are files (fs_*) or cloud Knowledge"),
1666
+ "local_documents.folders": dropped("matrx-local's private document store is gone; documents are files (fs_*) or cloud Knowledge"),
1667
+ "local_documents.read": dropped("matrx-local's private document store is gone; documents are files (fs_*) or cloud Knowledge"),
1668
+ "local_documents.write": dropped("matrx-local's private document store is gone; documents are files (fs_*) or cloud Knowledge"),
1669
+ "local_documents.search": dropped("matrx-local's private document store is gone; documents are files (fs_*) or cloud Knowledge"),
1670
+ "local_media.ocr": tool("desktop_documents"),
1671
+ "local_media.resize": tool("desktop_documents"),
1672
+ "local_media.pdf_extract": tool("desktop_documents"),
1673
+ "local_media.office_generate": tool("desktop_documents"),
1674
+ "local_media.archive_create": dropped(SHELL_COVERS),
1675
+ "local_media.archive_extract": dropped(SHELL_COVERS),
1676
+ "local_ner.entities": tool("desktop_entities"),
1677
+ "local_ner.pii": tool("desktop_entities"),
1678
+ "local_mac_apps.applescript": tool("desktop_automation"),
1679
+ "local_mac_apps.list_emails": tool("desktop_mail"),
1680
+ "local_mac_apps.send_email": tool("desktop_mail"),
1681
+ "local_mac_apps.email_accounts": tool("desktop_mail"),
1682
+ "local_mac_apps.list_messages": tool("desktop_messages"),
1683
+ "local_mac_apps.list_conversations": tool("desktop_messages"),
1684
+ "local_mac_apps.send_message": tool("desktop_messages"),
1685
+ "local_mac_apps.search_contacts": tool("desktop_contacts"),
1686
+ "local_mac_apps.get_contact": tool("desktop_contacts"),
1687
+ "local_mac_apps.list_events": tool("desktop_calendar"),
1688
+ "local_mac_apps.create_event": tool("desktop_calendar"),
1689
+ "local_mac_apps.list_reminders": tool("desktop_calendar"),
1690
+ "local_mac_apps.create_reminder": tool("desktop_calendar"),
1691
+ "local_mac_apps.search_photos": tool("desktop_photos"),
1692
+ "local_mac_apps.get_photo": tool("desktop_photos"),
1693
+ "local_mac_apps.location": tool("desktop_location"),
1694
+ "local_windows_ps.run": tool("desktop_automation"),
1695
+ "local_windows_ps.get_env": dropped("Read with shell_execute; a per-command env rides exec.run"),
1696
+ "local_windows_ps.set_env": dropped("Changing the person's persistent environment is not an agent tool"),
1697
+ "local_windows_ps.registry_read": tool("desktop_windows_admin"),
1698
+ "local_windows_ps.registry_write": tool("desktop_windows_admin"),
1699
+ "local_windows_ps.service_list": tool("desktop_windows_admin"),
1700
+ "local_windows_ps.service_control": tool("desktop_windows_admin"),
1701
+ "local_windows_ps.event_log": tool("desktop_windows_admin"),
1702
+ "local_windows_ps.windows_features": tool("desktop_windows_admin")
1703
+ };
1704
+ var LEGACY_DISPATCHERS = [
1705
+ "local_file",
1706
+ "local_shell",
1707
+ "local_window",
1708
+ "local_process",
1709
+ "local_input",
1710
+ "local_audio",
1711
+ "local_clipboard",
1712
+ "local_screen",
1713
+ "local_system",
1714
+ "local_browser",
1715
+ "local_web",
1716
+ "local_net",
1717
+ "local_monitor",
1718
+ "local_schedule",
1719
+ "local_documents",
1720
+ "local_media",
1721
+ "local_ner",
1722
+ "local_mac_apps",
1723
+ "local_windows_ps"
1724
+ ];
1725
+ function builtOps() {
1726
+ return TOOL_CATALOG.filter((t) => t.state === "built").flatMap((t) => t.ops);
1727
+ }
1728
+
1729
+ // src/tools/status.ts
1730
+ var TOOL_LEVELS = ["programmatic", "protocol", "chat"];
1731
+ var TOOL_PLATFORMS = ["darwin", "win32", "linux"];
1732
+ var REQUIRED = {
1733
+ programmatic: [{ label: "in process", ok: (e) => e.transport === "in_process" }],
1734
+ protocol: [
1735
+ { label: "localhost", ok: (e) => e.transport === "localhost" },
1736
+ { label: "relay", ok: (e) => e.transport === "relay" },
1737
+ { label: "relay from another network", ok: (e) => e.transport === "relay" && e.remote_network }
1738
+ ],
1739
+ chat: [{ label: "a real agent in a real chat", ok: (e) => e.transport === "agent" }]
1740
+ };
1741
+ function cellFor(tool2, platform, level, evidence) {
1742
+ if (!tool2.platforms.includes(platform)) return { state: "unsupported", missing: [], last_run_at_ms: null, evidence: [] };
1743
+ const latest = /* @__PURE__ */ new Map();
1744
+ for (const e of evidence) {
1745
+ const key = `${e.suite}\0${e.test}\0${e.transport}\0${e.remote_network}`;
1746
+ const prev = latest.get(key);
1747
+ if (!prev || prev.run_at_ms < e.run_at_ms) latest.set(key, e);
1748
+ }
1749
+ const runs = [...latest.values()].filter((e) => e.outcome !== "skip").sort((a, b) => b.run_at_ms - a.run_at_ms);
1750
+ const last = runs[0]?.run_at_ms ?? null;
1751
+ if (tool2.state === "planned" && runs.length === 0) return { state: "not_built", missing: [], last_run_at_ms: null, evidence: [] };
1752
+ if (runs.length === 0) return { state: "untested", missing: REQUIRED[level].map((r) => r.label), last_run_at_ms: null, evidence: [...latest.values()] };
1753
+ if (runs.some((e) => e.outcome === "fail")) return { state: "fail", missing: [], last_run_at_ms: last, evidence: runs };
1754
+ const missing = REQUIRED[level].filter((r) => !runs.some((e) => e.outcome === "pass" && r.ok(e))).map((r) => r.label);
1755
+ return { state: missing.length === 0 ? "pass" : "partial", missing, last_run_at_ms: last, evidence: runs };
1756
+ }
1757
+ function buildToolStatus(files, opts) {
1758
+ const parsed = files.map((f, i) => {
1759
+ const r = ToolResultsFile.safeParse(f);
1760
+ if (!r.success) throw new Error(`tool results file #${i} is off-contract: ${r.error.issues[0]?.path.join(".")} ${r.error.issues[0]?.message}`);
1761
+ return r.data;
1762
+ });
1763
+ const known = new Set(TOOL_CATALOG.map((t) => t.name));
1764
+ const byKey = /* @__PURE__ */ new Map();
1765
+ for (const file of parsed) {
1766
+ for (const r of file.results) {
1767
+ if (!known.has(r.tool)) throw new Error(`a result names ${r.tool}, which is not in the tool catalog`);
1768
+ const key = `${r.tool}|${r.platform}|${r.level}`;
1769
+ const list = byKey.get(key) ?? [];
1770
+ list.push({ suite: r.suite, test: r.test, transport: r.transport, outcome: r.outcome, remote_network: r.remote_network, commit: file.commit, run_at_ms: r.run_at_ms, detail: r.detail });
1771
+ byKey.set(key, list);
1772
+ }
1773
+ }
1774
+ const groupOrder = new Map(TOOL_GROUPS.map((g) => [g.id, g.order]));
1775
+ const tools = [...TOOL_CATALOG].sort((a, b) => (groupOrder.get(a.group) ?? 99) - (groupOrder.get(b.group) ?? 99));
1776
+ const rows2 = tools.map((tool2) => {
1777
+ const cells = {};
1778
+ const working = {};
1779
+ for (const platform of TOOL_PLATFORMS) {
1780
+ const perLevel = {};
1781
+ for (const level of TOOL_LEVELS) perLevel[level] = cellFor(tool2, platform, level, byKey.get(`${tool2.name}|${platform}|${level}`) ?? []);
1782
+ cells[platform] = perLevel;
1783
+ working[platform] = TOOL_LEVELS.every((l) => perLevel[l].state === "pass");
1784
+ }
1785
+ return { tool: tool2.name, group: tool2.group, tool_state: tool2.state, summary: tool2.summary, note: tool2.note ?? null, cells, working };
1786
+ });
1787
+ const totals = {};
1788
+ for (const platform of TOOL_PLATFORMS) {
1789
+ const onPlatform = TOOL_CATALOG.filter((t) => t.platforms.includes(platform));
1790
+ totals[platform] = {
1791
+ working: rows2.filter((r) => r.working[platform]).length,
1792
+ built: onPlatform.filter((t) => t.state !== "planned").length,
1793
+ tools: onPlatform.length
1794
+ };
1795
+ }
1796
+ const commits = [...new Set(parsed.map((f) => f.commit))].sort();
1797
+ return { schema: "matrx.tool-status.v1", generated_at_ms: opts.generatedAtMs, commits, rows: rows2, totals };
1798
+ }
1799
+ var MARK = { pass: "\u2713", partial: "\u25D0", fail: "\u2717", untested: "\xB7", not_built: "\u2014", unsupported: " " };
1800
+ function renderToolStatusMarkdown(status) {
1801
+ const lines = [
1802
+ "<!-- GENERATED by `pnpm tools:status` from test results. Never edit by hand. -->",
1803
+ "# Local tools: status",
1804
+ "",
1805
+ `Generated ${new Date(status.generated_at_ms).toISOString()} from commits ${status.commits.join(", ") || "none"}.`,
1806
+ "",
1807
+ "\u2713 pass \xB7 \u25D0 passing so far, a required proof missing \xB7 \u2717 fail \xB7 `\xB7` untested \xB7 \u2014 not built. Levels: P programmatic, R protocol, C chat.",
1808
+ "",
1809
+ "| Platform | Working | Built | Tools |",
1810
+ "|---|---|---|---|",
1811
+ ...TOOL_PLATFORMS.map((p) => `| ${p} | ${status.totals[p].working} | ${status.totals[p].built} | ${status.totals[p].tools} |`),
1812
+ ""
1813
+ ];
1814
+ for (const group of TOOL_GROUPS) {
1815
+ const rows2 = status.rows.filter((r) => r.group === group.id);
1816
+ if (rows2.length === 0) continue;
1817
+ lines.push(`## ${group.order}. ${group.title}`, "", "| Tool | darwin P R C | win32 P R C | linux P R C | Missing |", "|---|---|---|---|---|");
1818
+ for (const r of rows2) {
1819
+ const cols2 = TOOL_PLATFORMS.map((p) => TOOL_LEVELS.map((l) => MARK[r.cells[p][l].state]).join(" "));
1820
+ const missing = /* @__PURE__ */ new Set();
1821
+ for (const p of TOOL_PLATFORMS) for (const l of TOOL_LEVELS) for (const m of r.cells[p][l].missing) if (r.cells[p][l].state !== "untested") missing.add(`${p} ${l}: ${m}`);
1822
+ const name = r.tool_state === "broken" ? `${r.tool} (broken: ${r.note ?? ""})` : r.tool;
1823
+ lines.push(`| ${name} | ${cols2.join(" | ")} | ${[...missing].join("; ")} |`);
1824
+ }
1825
+ lines.push("");
1826
+ }
1827
+ return lines.join("\n");
1828
+ }
1087
1829
  //# sourceMappingURL=index.cjs.map