@ai-matrx/desktop-protocol 0.17.12 → 0.18.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
@@ -297,9 +297,23 @@ __export(src_exports, {
297
297
  RequestMsg: () => RequestMsg,
298
298
  ResourceId: () => ResourceId,
299
299
  ResourceInfo: () => ResourceInfo,
300
+ ResourcesActivityParams: () => ResourcesActivityParams,
301
+ ResourcesActivityResult: () => ResourcesActivityResult,
300
302
  ResourcesDisk: () => ResourcesDisk,
303
+ ResourcesIncident: () => ResourcesIncident,
304
+ ResourcesIncidentsParams: () => ResourcesIncidentsParams,
305
+ ResourcesIncidentsResult: () => ResourcesIncidentsResult,
306
+ ResourcesJob: () => ResourcesJob,
307
+ ResourcesJobKind: () => ResourcesJobKind,
308
+ ResourcesPressure: () => ResourcesPressure,
309
+ ResourcesProcess: () => ResourcesProcess,
310
+ ResourcesSample: () => ResourcesSample,
301
311
  ResourcesSnapshotParams: () => ResourcesSnapshotParams,
302
312
  ResourcesSnapshotResult: () => ResourcesSnapshotResult,
313
+ ResourcesStopJobParams: () => ResourcesStopJobParams,
314
+ ResourcesStopJobResult: () => ResourcesStopJobResult,
315
+ ResourcesStrain: () => ResourcesStrain,
316
+ ResourcesVerdict: () => ResourcesVerdict,
303
317
  ResponseMsg: () => ResponseMsg,
304
318
  SERVICES: () => SERVICES,
305
319
  SERVICE_MAX_FRAME_BYTES: () => SERVICE_MAX_FRAME_BYTES,
@@ -421,13 +435,14 @@ module.exports = __toCommonJS(src_exports);
421
435
 
422
436
  // src/schema/primitives.ts
423
437
  var import_zod = require("zod");
438
+ var import_uuid = require("@ai-matrx/kit/uuid");
424
439
  var PROTOCOL_MAJOR = 1;
425
- var PROTOCOL_MINOR = 16;
440
+ var PROTOCOL_MINOR = 17;
426
441
  var PROTOCOL_VERSION = `${PROTOCOL_MAJOR}.${PROTOCOL_MINOR}`;
427
442
  var ProtocolVersion = import_zod.z.string().regex(/^[1-9][0-9]{0,2}\.[0-9]{1,3}$/);
428
443
  var RequestId = import_zod.z.string().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/);
429
444
  var ResourceId = import_zod.z.string().regex(/^(pty|watch)_[A-Za-z0-9]{16,40}$/);
430
- var DeviceId = import_zod.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}$/);
445
+ var DeviceId = import_zod.z.string().regex(import_uuid.UUID_SHAPE_PATTERN);
431
446
  var AbsPath = import_zod.z.string().min(1).max(4096).regex(/^(\/|[A-Za-z]:\/)[^\\\u0000]*$/);
432
447
  var u32 = import_zod.z.int().min(0).max(4294967295);
433
448
  var nonNegInt = import_zod.z.int().min(0);
@@ -1222,8 +1237,9 @@ var ModelsProgressEvent = import_zod10.z.strictObject({ request_id: RequestId, p
1222
1237
 
1223
1238
  // src/schema/apps.ts
1224
1239
  var import_zod11 = require("zod");
1240
+ var import_uuid2 = require("@ai-matrx/kit/uuid");
1225
1241
  var AppKey = import_zod11.z.string().regex(/^[a-z][a-z0-9_-]{0,39}$/);
1226
- 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}$/);
1242
+ var AppProfileId = import_zod11.z.string().regex(import_uuid2.UUID_SHAPE_PATTERN);
1227
1243
  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}$/);
1228
1244
  var AppSupport = import_zod11.z.enum(["supported", "partial", "unsupported"]);
1229
1245
  var AppFeatureStatus = import_zod11.z.strictObject({
@@ -2061,6 +2077,8 @@ var import_zod23 = require("zod");
2061
2077
  var ResourcesDisk = import_zod23.z.strictObject({
2062
2078
  /** Where it is mounted ("/", "C:"). */
2063
2079
  mount: import_zod23.z.string().max(512),
2080
+ /** The volume's name as the file manager shows it ("Macintosh HD", "Local Disk (C:)"). Since 1.17. */
2081
+ name: import_zod23.z.string().max(256).optional(),
2064
2082
  /** The file system ("apfs", "NTFS", "ext4"). */
2065
2083
  fs: import_zod23.z.string().max(64),
2066
2084
  size_bytes: nonNegInt,
@@ -2081,6 +2099,117 @@ var ResourcesSnapshotResult = import_zod23.z.strictObject({
2081
2099
  disks: import_zod23.z.array(ResourcesDisk).max(64),
2082
2100
  uptime_seconds: nonNegInt
2083
2101
  });
2102
+ var ResourcesJobKind = import_zod23.z.enum(["type-check", "tests", "build", "lint", "dev server", "language server", "search"]);
2103
+ var ResourcesStrain = import_zod23.z.enum(["good", "strain", "overloaded"]);
2104
+ var ResourcesPressure = import_zod23.z.enum(["normal", "warning", "critical"]);
2105
+ var ResourcesJob = import_zod23.z.strictObject({
2106
+ /** The job's root process (Stop takes its whole tree). */
2107
+ pid: import_zod23.z.int().min(0),
2108
+ kind: ResourcesJobKind,
2109
+ /** Its heaviest process's command line, shortened ("…/lib/tsc --noEmit -p tsconfig.json"). */
2110
+ command: import_zod23.z.string().max(256),
2111
+ /** Who started it: "Claude Code", "Codex", "Cursor", "VS Code", "Terminal", "local stack", "detached"; null when unknown. */
2112
+ started_by: import_zod23.z.string().max(64).nullable(),
2113
+ /** Whatever started it is gone and nothing waits for it. */
2114
+ orphan: import_zod23.z.boolean(),
2115
+ /** A type-check queued for its turn (no compiler running yet). */
2116
+ waiting: import_zod23.z.boolean(),
2117
+ /** The project folder it runs in ("matrx-frontend"); null when not in one. */
2118
+ folder: import_zod23.z.string().max(256).nullable(),
2119
+ /** The same command in the same folder, running this many times (1 = no duplicate). */
2120
+ duplicates: import_zod23.z.int().min(1),
2121
+ processes: import_zod23.z.int().min(1),
2122
+ /** Sum over the tree, as `ps` reports it: 100 = one full core. */
2123
+ cpu_percent: import_zod23.z.number().min(0),
2124
+ /** Real memory (macOS: the physical footprint Activity Monitor shows, compressed included). */
2125
+ memory_bytes: nonNegInt,
2126
+ started_at_ms: epochMs.nullable(),
2127
+ /** False for an app, an agent session, a terminal, a system process, the local stack or Matrx 2 itself. */
2128
+ stoppable: import_zod23.z.boolean()
2129
+ });
2130
+ var ResourcesProcess = import_zod23.z.strictObject({
2131
+ pid: import_zod23.z.int().min(0),
2132
+ /** The command line, shortened. */
2133
+ name: import_zod23.z.string().max(256),
2134
+ cpu_percent: import_zod23.z.number().min(0),
2135
+ memory_bytes: nonNegInt,
2136
+ started_by: import_zod23.z.string().max(64).nullable(),
2137
+ /** The job it belongs to ("type-check in aidream"); null when none. */
2138
+ job: import_zod23.z.string().max(256).nullable(),
2139
+ started_at_ms: epochMs.nullable()
2140
+ });
2141
+ var ResourcesVerdict = import_zod23.z.strictObject({
2142
+ level: ResourcesStrain,
2143
+ /** One sentence ("Your Mac is under strain. 3 type-checks are running at once."). */
2144
+ text: import_zod23.z.string().max(256),
2145
+ /** The biggest jobs behind it; null when all is well. */
2146
+ cause: import_zod23.z.string().max(1024).nullable()
2147
+ });
2148
+ var ResourcesSample = import_zod23.z.strictObject({
2149
+ at_ms: epochMs,
2150
+ /** The 1-minute load average. */
2151
+ load: import_zod23.z.number().min(0),
2152
+ memory_used_bytes: nonNegInt,
2153
+ typechecks: nonNegInt
2154
+ });
2155
+ var ResourcesActivityParams = import_zod23.z.strictObject({});
2156
+ var ResourcesActivityResult = import_zod23.z.strictObject({
2157
+ /** False until the first reading (a second or two after start). */
2158
+ ready: import_zod23.z.boolean(),
2159
+ sampled_at_ms: epochMs.nullable(),
2160
+ cores: import_zod23.z.int().min(1),
2161
+ /** 1, 5 and 15 minute load averages. */
2162
+ load: import_zod23.z.array(import_zod23.z.number().min(0)).length(3),
2163
+ memory: import_zod23.z.strictObject({
2164
+ total_bytes: nonNegInt,
2165
+ /** Activity Monitor's Memory Used: app memory + wired + compressed. */
2166
+ used_bytes: nonNegInt,
2167
+ /** Data held compressed, and the memory the compressor takes to hold it. */
2168
+ compressed_bytes: nonNegInt,
2169
+ compressor_bytes: nonNegInt,
2170
+ swap_used_bytes: nonNegInt,
2171
+ pressure: ResourcesPressure.nullable()
2172
+ }),
2173
+ verdict: ResourcesVerdict,
2174
+ typechecks: import_zod23.z.strictObject({ running: nonNegInt, waiting: nonNegInt, comfort: nonNegInt }),
2175
+ /** Heaviest first (1 GB weighs as much as 16 % of a core). */
2176
+ jobs: import_zod23.z.array(ResourcesJob).max(200),
2177
+ /** The 15 heaviest by memory and the 15 busiest by CPU, together. */
2178
+ top: import_zod23.z.array(ResourcesProcess).max(30),
2179
+ /** The last hour, oldest first. */
2180
+ history: import_zod23.z.array(ResourcesSample).max(1200)
2181
+ });
2182
+ var ResourcesStopJobParams = import_zod23.z.strictObject({ pid: import_zod23.z.int().min(1) });
2183
+ var ResourcesStopJobResult = import_zod23.z.strictObject({
2184
+ /** Processes signalled; whatever is still running 5 seconds later is force-stopped. */
2185
+ processes: nonNegInt,
2186
+ /** It had finished before the request arrived. */
2187
+ already_finished: import_zod23.z.boolean()
2188
+ });
2189
+ var ResourcesIncident = import_zod23.z.strictObject({
2190
+ at_ms: epochMs,
2191
+ verdict: ResourcesVerdict,
2192
+ load: import_zod23.z.number().min(0),
2193
+ memory_used_bytes: nonNegInt,
2194
+ compressed_bytes: nonNegInt,
2195
+ pressure: ResourcesPressure.nullable(),
2196
+ jobs: import_zod23.z.array(
2197
+ import_zod23.z.strictObject({
2198
+ kind: ResourcesJobKind,
2199
+ started_by: import_zod23.z.string().max(64).nullable(),
2200
+ folder: import_zod23.z.string().max(256).nullable(),
2201
+ command: import_zod23.z.string().max(256),
2202
+ cpu_percent: import_zod23.z.number().min(0),
2203
+ memory_bytes: nonNegInt,
2204
+ duplicates: import_zod23.z.int().min(1)
2205
+ })
2206
+ ).max(8)
2207
+ });
2208
+ var ResourcesIncidentsParams = import_zod23.z.strictObject({ limit: import_zod23.z.int().min(1).max(200).default(50) });
2209
+ var ResourcesIncidentsResult = import_zod23.z.strictObject({
2210
+ /** Newest first; at most one a minute is written. */
2211
+ incidents: import_zod23.z.array(ResourcesIncident).max(200)
2212
+ });
2084
2213
 
2085
2214
  // src/schema/stack.ts
2086
2215
  var import_zod24 = require("zod");
@@ -2276,9 +2405,10 @@ var ExecJobListResult = import_zod27.z.strictObject({ jobs: import_zod27.z.array
2276
2405
 
2277
2406
  // src/schema/coding.ts
2278
2407
  var import_zod28 = require("zod");
2408
+ var import_uuid3 = require("@ai-matrx/kit/uuid");
2279
2409
  var CodingServiceCredentials = import_zod28.z.strictObject({
2280
2410
  access_token: import_zod28.z.string().min(16).max(16384),
2281
- user_id: import_zod28.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}$/),
2411
+ user_id: import_zod28.z.string().regex(import_uuid3.UUID_SHAPE_PATTERN),
2282
2412
  /** The AI Matrx server this app talks to (production, or a local server on the nightly copy). */
2283
2413
  server_url: import_zod28.z.string().min(1).max(2048).regex(/^https?:\/\/[^\s/?#]+(\/[^\s?#]*)?$/)
2284
2414
  });
@@ -2443,6 +2573,9 @@ var OPS = {
2443
2573
  "power.status": { params: PowerStatusParams, result: PowerStatusResult, kind: "unary", since: "1.4", errors: ["INTERNAL"] },
2444
2574
  "power.prevent_sleep": { params: PowerPreventSleepParams, result: PowerPreventSleepResult, kind: "unary", since: "1.4", errors: ["PERMISSION_DENIED_OS", "PLATFORM_UNSUPPORTED", "INTERNAL"] },
2445
2575
  "resources.snapshot": { params: ResourcesSnapshotParams, result: ResourcesSnapshotResult, kind: "unary", since: "1.4", errors: ["INTERNAL"] },
2576
+ "resources.activity": { params: ResourcesActivityParams, result: ResourcesActivityResult, kind: "unary", since: "1.17", errors: ["PLATFORM_UNSUPPORTED", "INTERNAL"] },
2577
+ "resources.stop_job": { params: ResourcesStopJobParams, result: ResourcesStopJobResult, kind: "unary", since: "1.17", errors: ["NOT_FOUND", "CONFLICT", "AUTH_FORBIDDEN", "PLATFORM_UNSUPPORTED", "INTERNAL"] },
2578
+ "resources.incidents": { params: ResourcesIncidentsParams, result: ResourcesIncidentsResult, kind: "unary", since: "1.17", errors: ["INTERNAL"] },
2446
2579
  "audio.devices": { params: AudioDevicesParams, result: AudioDevicesResult, kind: "unary", since: "1.6", errors: ["PLATFORM_UNSUPPORTED", "INTERNAL"] },
2447
2580
  "audio.record": { params: AudioRecordParams, result: AudioRecordResult, kind: "unary", since: "1.6", errors: ["NOT_FOUND", "PERMISSION_DENIED_OS", "PLATFORM_UNSUPPORTED", "RESOURCE_BUSY", "INTERNAL"] },
2448
2581
  "audio.play": { params: AudioPlayParams, result: AudioPlayResult, kind: "unary", since: "1.6", errors: ["NOT_FOUND", "INVALID_PARAMS", "PLATFORM_UNSUPPORTED", "INTERNAL"] },
@@ -2677,6 +2810,20 @@ var NAMED_SCHEMAS = {
2677
2810
  ResourcesDisk,
2678
2811
  ResourcesSnapshotParams,
2679
2812
  ResourcesSnapshotResult,
2813
+ ResourcesJobKind,
2814
+ ResourcesStrain,
2815
+ ResourcesPressure,
2816
+ ResourcesVerdict,
2817
+ ResourcesSample,
2818
+ ResourcesJob,
2819
+ ResourcesProcess,
2820
+ ResourcesActivityParams,
2821
+ ResourcesActivityResult,
2822
+ ResourcesStopJobParams,
2823
+ ResourcesStopJobResult,
2824
+ ResourcesIncident,
2825
+ ResourcesIncidentsParams,
2826
+ ResourcesIncidentsResult,
2680
2827
  AudioDevice,
2681
2828
  AudioDevicesParams,
2682
2829
  AudioDevicesResult,
@@ -2828,7 +2975,8 @@ var FIELDS_SINCE = {
2828
2975
  AppsAccountsUsageResult: { problem: "1.12" },
2829
2976
  AppsAccountsResetsResult: { problem: "1.12" },
2830
2977
  ChatRow: { app_project: "1.13", tokens: "1.13", original_title: "1.14", title_source: "1.14", title_override: "1.14", archived: "1.15" },
2831
- AccountUsage: { plan: "1.13", credits: "1.13" }
2978
+ AccountUsage: { plan: "1.13", credits: "1.13" },
2979
+ ResourcesDisk: { name: "1.17" }
2832
2980
  };
2833
2981
  var NULL_SINCE = {
2834
2982
  "RelayDeviceStatusEvent.since_ms": { since: "1.1", olderPeersGet: 0 }
@@ -2895,7 +3043,8 @@ var NESTED_RESULTS = /* @__PURE__ */ new Map([
2895
3043
  ["apps.projects.move", [["chat", "ChatRow"]]],
2896
3044
  ["apps.chats.star", [["chat", "ChatRow"]]],
2897
3045
  ["apps.chats.place", [["chat", "ChatRow"]]],
2898
- ["apps.accounts.usage", [["accounts", "AccountUsage"]]]
3046
+ ["apps.accounts.usage", [["accounts", "AccountUsage"]]],
3047
+ ["resources.snapshot", [["disks", "ResourcesDisk"]]]
2899
3048
  ]);
2900
3049
  function stripNested(value, nested, version) {
2901
3050
  if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
@@ -2956,7 +3105,7 @@ function forPeer(op, part, value, version) {
2956
3105
  var VERSIONED_RESULT_OPS = [.../* @__PURE__ */ new Set([...RESULT_PATH.keys(), ...WINDOW_RESULTS.keys(), ...NESTED_RESULTS.keys()])];
2957
3106
 
2958
3107
  // src/contract.ts
2959
- var CONTRACT_SHA256 = "ee6873cbbdcba3960248ff0c5c71fe47c663b54c6e657d62d1ed5e04e51f17e2";
3108
+ var CONTRACT_SHA256 = "cdfad283c689005856b4161f28a37892d1c3356db077f685a4a659fc2c8fc657";
2960
3109
 
2961
3110
  // src/close-policy.ts
2962
3111
  var CLOSE_RULES = {
@@ -3016,7 +3165,7 @@ var TOOL_CATALOG = [
3016
3165
  { name: "desktop_input", group: "os_control", state: "built", path: "device_op", ops: ["input.type_text", "input.hotkey", "input.mouse_click", "input.mouse_move"], platforms: ALL, summary: "Keyboard and mouse" },
3017
3166
  { name: "desktop_audio", group: "os_control", state: "built", path: "device_op", ops: ["audio.devices", "audio.record", "audio.play"], platforms: ALL, summary: "Audio devices, record, play" },
3018
3167
  { name: "desktop_power", group: "os_control", state: "built", path: "device_op", ops: ["power.status", "power.prevent_sleep"], platforms: ALL, summary: "Battery and keep awake" },
3019
- { name: "desktop_resources", group: "os_control", state: "built", path: "device_op", ops: ["resources.snapshot"], platforms: ALL, summary: "CPU, memory and disk use" },
3168
+ { name: "desktop_resources", group: "os_control", state: "built", path: "device_op", ops: ["resources.snapshot", "resources.activity", "resources.stop_job", "resources.incidents"], platforms: ALL, summary: "CPU, memory and disk use; what is using them, grouped into jobs; stop a job; the slowdown log" },
3020
3169
  { name: "fs_watch", group: "os_control", state: "built", path: "device_op", ops: ["fs.watch.start", "fs.watch.events", "fs.watch.stop"], platforms: ALL, summary: "Watch a folder; read what changed" },
3021
3170
  // ── 3. Personal apps and automation ──────────────────────────────────────────────────────────
3022
3171
  { 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" },