@ai-matrx/desktop-protocol 0.15.0 → 0.16.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.0 (protocol 1.5)
4
+
5
+ - `coding.history.import_missing`: every Claude Code session on the device that AI Matrx lacks
6
+ (missing) or is behind on (changed after the last turn AI Matrx received), imported by Matrx 2's
7
+ `coding` Python service through the shared importer (matrx-local `packages/matrx-coding-history`).
8
+ Result: counts, up to 20 failures, and one honest `summary` line; `state` is `done`, `blocked`
9
+ (with a `CodingHistoryBlocked` reason) or `cancelled`. Progress: `coding.history.progress`.
10
+ - The `coding` Python service (`ServiceName`): `coding.plan_missing` / `coding.import_next`, each a
11
+ bounded step carrying `CodingServiceCredentials` that the core fills from its own sign-in.
12
+
13
+ Consumer action: none (new ops only; an older app answers UNKNOWN_OPERATION). Matrx 2 regenerates
14
+ its Python contract (`node scripts/python-contract.mjs`).
15
+
3
16
  ## 0.15.0 (protocol 1.4)
4
17
 
5
18
  - Computer control: `system.open_url` / `system.open_path` / `system.notify`; `screen.list` /
package/dist/client.cjs CHANGED
@@ -126,7 +126,7 @@ var import_zod2 = require("zod");
126
126
  // src/schema/primitives.ts
127
127
  var import_zod = require("zod");
128
128
  var PROTOCOL_MAJOR = 1;
129
- var PROTOCOL_MINOR = 4;
129
+ var PROTOCOL_MINOR = 5;
130
130
  var PROTOCOL_VERSION = `${PROTOCOL_MAJOR}.${PROTOCOL_MINOR}`;
131
131
  var ProtocolVersion = import_zod.z.string().regex(/^[1-9][0-9]{0,2}\.[0-9]{1,3}$/);
132
132
  var RequestId = import_zod.z.string().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/);
@@ -1211,23 +1211,98 @@ var ExecJobInfo = import_zod20.z.strictObject({
1211
1211
  var ExecJobListParams = import_zod20.z.strictObject({});
1212
1212
  var ExecJobListResult = import_zod20.z.strictObject({ jobs: import_zod20.z.array(ExecJobInfo).max(64) });
1213
1213
 
1214
- // src/schema/apps.ts
1214
+ // src/schema/coding.ts
1215
1215
  var import_zod21 = require("zod");
1216
- var AppKey = import_zod21.z.string().regex(/^[a-z][a-z0-9_-]{0,39}$/);
1217
- var AppProfileId = import_zod21.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}$/);
1218
- var AppProfileLocator = import_zod21.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}$/);
1219
- var AppSupport = import_zod21.z.enum(["supported", "partial", "unsupported"]);
1220
- var AppFeatureStatus = import_zod21.z.strictObject({
1216
+ var CodingServiceCredentials = import_zod21.z.strictObject({
1217
+ access_token: import_zod21.z.string().min(16).max(16384),
1218
+ user_id: import_zod21.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}$/),
1219
+ /** The AI Matrx server this app talks to (production, or a local server on the nightly copy). */
1220
+ server_url: import_zod21.z.string().min(1).max(2048).regex(/^https?:\/\/[^\s/?#]+(\/[^\s?#]*)?$/)
1221
+ });
1222
+ var CodingHistoryBlocked = import_zod21.z.enum([
1223
+ "signed_out",
1224
+ "offline",
1225
+ "organization_required",
1226
+ "claude_unavailable",
1227
+ "cloud_list_unavailable",
1228
+ "history_too_large"
1229
+ ]);
1230
+ var CodingHistoryFailure = import_zod21.z.strictObject({
1231
+ session_id: import_zod21.z.string().max(64),
1232
+ reason: import_zod21.z.string().max(300)
1233
+ });
1234
+ var CodingHistoryRun = import_zod21.z.strictObject({
1235
+ /** Claude Code sessions found on this computer. */
1236
+ local_sessions: nonNegInt,
1237
+ /** Of those, already complete in AI Matrx. */
1238
+ in_cloud: nonNegInt,
1239
+ /** In AI Matrx under neither of its identities. */
1240
+ missing: nonNegInt,
1241
+ /** In AI Matrx, but changed here after the last turn AI Matrx received (turns the hook lost). */
1242
+ behind: nonNegInt,
1243
+ /** Over the importer's size cap; never imported. */
1244
+ too_large: nonNegInt,
1245
+ imported: nonNegInt,
1246
+ /** Changed while being read; a later run takes them. */
1247
+ changed: nonNegInt,
1248
+ failed: nonNegInt,
1249
+ failures: import_zod21.z.array(CodingHistoryFailure).max(20),
1250
+ /** Candidates not reached yet. */
1251
+ remaining: nonNegInt,
1252
+ /** The one line a person reads, e.g. "Imported 12 of 14 sessions. 140 already in AI Matrx." */
1253
+ summary: import_zod21.z.string().max(400)
1254
+ });
1255
+ var CodingHistoryStep = import_zod21.z.strictObject({
1256
+ /** Null when the run could not start (blocked before a plan existed). */
1257
+ plan_id: import_zod21.z.string().regex(/^[0-9a-f]{32}$/).nullable(),
1258
+ finished: import_zod21.z.boolean(),
1259
+ blocked: CodingHistoryBlocked.nullable(),
1260
+ run: CodingHistoryRun
1261
+ });
1262
+ var CodingPlanMissingParams = import_zod21.z.strictObject({ credentials: CodingServiceCredentials });
1263
+ var CodingImportNextParams = import_zod21.z.strictObject({
1264
+ plan_id: import_zod21.z.string().regex(/^[0-9a-f]{32}$/),
1265
+ credentials: CodingServiceCredentials
1266
+ });
1267
+ var CodingServiceProgress = import_zod21.z.strictObject({
1268
+ phase: import_zod21.z.enum(["checking", "importing"]),
1269
+ done: nonNegInt,
1270
+ total: nonNegInt
1271
+ });
1272
+ var CodingHistoryImportMissingParams = import_zod21.z.strictObject({});
1273
+ var CodingHistoryImportMissingResult = import_zod21.z.strictObject({
1274
+ state: import_zod21.z.enum(["done", "blocked", "cancelled"]),
1275
+ blocked: CodingHistoryBlocked.nullable(),
1276
+ run: CodingHistoryRun,
1277
+ elapsed_ms: nonNegInt
1278
+ });
1279
+ var CodingHistoryProgressEvent = import_zod21.z.strictObject({
1280
+ request_id: RequestId,
1281
+ phase: import_zod21.z.enum(["checking", "importing"]),
1282
+ /** Sessions settled so far, of `total` candidates (0 of 0 while checking). */
1283
+ done: nonNegInt,
1284
+ total: nonNegInt,
1285
+ imported: nonNegInt,
1286
+ failed: nonNegInt
1287
+ });
1288
+
1289
+ // src/schema/apps.ts
1290
+ var import_zod22 = require("zod");
1291
+ var AppKey = import_zod22.z.string().regex(/^[a-z][a-z0-9_-]{0,39}$/);
1292
+ var AppProfileId = import_zod22.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}$/);
1293
+ var AppProfileLocator = import_zod22.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}$/);
1294
+ var AppSupport = import_zod22.z.enum(["supported", "partial", "unsupported"]);
1295
+ var AppFeatureStatus = import_zod22.z.strictObject({
1221
1296
  status: AppSupport,
1222
1297
  /** One line, set whenever status is not "supported". */
1223
- reason: import_zod21.z.string().max(140).nullable()
1298
+ reason: import_zod22.z.string().max(140).nullable()
1224
1299
  });
1225
- var AppInfo = import_zod21.z.strictObject({
1300
+ var AppInfo = import_zod22.z.strictObject({
1226
1301
  app_key: AppKey,
1227
- name: import_zod21.z.string().max(64),
1228
- installed: import_zod21.z.boolean(),
1302
+ name: import_zod22.z.string().max(64),
1303
+ installed: import_zod22.z.boolean(),
1229
1304
  /** The app's own version string, or null when it is not installed or does not say. */
1230
- version: import_zod21.z.string().max(64).nullable(),
1305
+ version: import_zod22.z.string().max(64).nullable(),
1231
1306
  /** The install found (an .app bundle, an .exe, a binary), or null. */
1232
1307
  location: AbsPath.nullable(),
1233
1308
  /** Open the app at all on this OS. */
@@ -1237,69 +1312,69 @@ var AppInfo = import_zod21.z.strictObject({
1237
1312
  /** Plan usage read from the app's own files on this OS. */
1238
1313
  usage: AppFeatureStatus
1239
1314
  });
1240
- var AppUsageReading = import_zod21.z.strictObject({
1241
- window: import_zod21.z.enum(["five_hour", "weekly", "extra"]),
1315
+ var AppUsageReading = import_zod22.z.strictObject({
1316
+ window: import_zod22.z.enum(["five_hour", "weekly", "extra"]),
1242
1317
  /** 0–100 for five_hour and weekly; extra-usage spend as a percent of its cap (may pass 100). */
1243
- percent: import_zod21.z.number().min(0).max(1e4),
1318
+ percent: import_zod22.z.number().min(0).max(1e4),
1244
1319
  /** When the app recorded it. */
1245
1320
  sampled_at_ms: epochMs,
1246
1321
  /** True when the window has rolled over since the sample, so the figure has reset. */
1247
- reset_since: import_zod21.z.boolean()
1322
+ reset_since: import_zod22.z.boolean()
1248
1323
  });
1249
- var AppProfile = import_zod21.z.strictObject({
1324
+ var AppProfile = import_zod22.z.strictObject({
1250
1325
  /** The row's id; null for a folder found on disk that no row names yet. */
1251
1326
  id: AppProfileId.nullable(),
1252
1327
  app_key: AppKey,
1253
- display_name: import_zod21.z.string().min(1).max(120),
1328
+ display_name: import_zod22.z.string().min(1).max(120),
1254
1329
  /** The account the person means to be signed in here; null when not stated (never guessed). */
1255
- account_identity: import_zod21.z.string().min(3).max(320).nullable(),
1330
+ account_identity: import_zod22.z.string().min(3).max(320).nullable(),
1256
1331
  profile_locator: AppProfileLocator.nullable(),
1257
1332
  /** The device the row is tied to; null when the row names none. */
1258
1333
  device_id: DeviceId.nullable(),
1259
1334
  /** The folder this profile resolves to on this device; null for a row tied to another device. */
1260
1335
  folder: AbsPath.nullable(),
1261
1336
  /** The folder exists on this device. */
1262
- on_disk: import_zod21.z.boolean(),
1337
+ on_disk: import_zod22.z.boolean(),
1263
1338
  /** An instance with this profile is running; null when it could not be determined. */
1264
- running: import_zod21.z.boolean().nullable(),
1339
+ running: import_zod22.z.boolean().nullable(),
1265
1340
  /** Usage the app recorded for this profile; null when the app exposes none here. */
1266
- usage: import_zod21.z.array(AppUsageReading).nullable(),
1341
+ usage: import_zod22.z.array(AppUsageReading).nullable(),
1267
1342
  last_opened_ms: epochMs.nullable()
1268
1343
  });
1269
- var AppsListParams = import_zod21.z.strictObject({});
1270
- var AppsListResult = import_zod21.z.strictObject({ apps: import_zod21.z.array(AppInfo) });
1271
- var AppsProfilesListParams = import_zod21.z.strictObject({
1344
+ var AppsListParams = import_zod22.z.strictObject({});
1345
+ var AppsListResult = import_zod22.z.strictObject({ apps: import_zod22.z.array(AppInfo) });
1346
+ var AppsProfilesListParams = import_zod22.z.strictObject({
1272
1347
  /** Only this app's profiles; every app's when absent. */
1273
1348
  app_key: AppKey.optional()
1274
1349
  });
1275
- var AppsProfilesListResult = import_zod21.z.strictObject({
1276
- profiles: import_zod21.z.array(AppProfile),
1350
+ var AppsProfilesListResult = import_zod22.z.strictObject({
1351
+ profiles: import_zod22.z.array(AppProfile),
1277
1352
  /**
1278
1353
  * Whether the saved rows could be read: false while signed out or offline, when only folders
1279
1354
  * found on disk are listed.
1280
1355
  */
1281
- registry: import_zod21.z.enum(["ok", "signed_out", "unavailable"])
1356
+ registry: import_zod22.z.enum(["ok", "signed_out", "unavailable"])
1282
1357
  });
1283
- var AppsProfilesSaveParams = import_zod21.z.strictObject({
1358
+ var AppsProfilesSaveParams = import_zod22.z.strictObject({
1284
1359
  id: AppProfileId.optional(),
1285
1360
  app_key: AppKey,
1286
- display_name: import_zod21.z.string().min(1).max(120),
1287
- account_identity: import_zod21.z.string().min(3).max(320).nullable(),
1361
+ display_name: import_zod22.z.string().min(1).max(120),
1362
+ account_identity: import_zod22.z.string().min(3).max(320).nullable(),
1288
1363
  /** On create: the folder to use (one found on disk), or null for the app's default profile. Ignored on update. */
1289
1364
  profile_locator: AppProfileLocator.nullable(),
1290
1365
  /** On create with profile_locator null: make a new folder named after display_name instead. */
1291
- new_folder: import_zod21.z.boolean().default(false)
1366
+ new_folder: import_zod22.z.boolean().default(false)
1292
1367
  });
1293
1368
  var AppsProfilesSaveResult = AppProfile;
1294
- var AppsProfilesRemoveParams = import_zod21.z.strictObject({ id: AppProfileId });
1295
- var AppsProfilesRemoveResult = import_zod21.z.strictObject({ removed: import_zod21.z.boolean() });
1296
- var AppsOpenParams = import_zod21.z.strictObject({
1369
+ var AppsProfilesRemoveParams = import_zod22.z.strictObject({ id: AppProfileId });
1370
+ var AppsProfilesRemoveResult = import_zod22.z.strictObject({ removed: import_zod22.z.boolean() });
1371
+ var AppsOpenParams = import_zod22.z.strictObject({
1297
1372
  app_key: AppKey,
1298
1373
  profile_id: AppProfileId.optional()
1299
1374
  });
1300
- var AppsOpenResult = import_zod21.z.strictObject({
1375
+ var AppsOpenResult = import_zod22.z.strictObject({
1301
1376
  /** True when an instance with this profile was already running; it is brought forward. */
1302
- already_running: import_zod21.z.boolean(),
1377
+ already_running: import_zod22.z.boolean(),
1303
1378
  folder: AbsPath.nullable()
1304
1379
  });
1305
1380
 
@@ -1367,7 +1442,9 @@ var OPS = {
1367
1442
  "input.mouse_click": { params: InputMouseClickParams, result: InputMouseClickResult, kind: "unary", since: "1.4", errors: ["INVALID_PARAMS", "PERMISSION_DENIED_OS", "PLATFORM_UNSUPPORTED", "INTERNAL"] },
1368
1443
  "power.status": { params: PowerStatusParams, result: PowerStatusResult, kind: "unary", since: "1.4", errors: ["INTERNAL"] },
1369
1444
  "power.prevent_sleep": { params: PowerPreventSleepParams, result: PowerPreventSleepResult, kind: "unary", since: "1.4", errors: ["PERMISSION_DENIED_OS", "PLATFORM_UNSUPPORTED", "INTERNAL"] },
1370
- "resources.snapshot": { params: ResourcesSnapshotParams, result: ResourcesSnapshotResult, kind: "unary", since: "1.4", errors: ["INTERNAL"] }
1445
+ "resources.snapshot": { params: ResourcesSnapshotParams, result: ResourcesSnapshotResult, kind: "unary", since: "1.4", errors: ["INTERNAL"] },
1446
+ // Claude Code history (SPEC §6 coding): served by the `coding` Python service through SERVICES below.
1447
+ "coding.history.import_missing": { params: CodingHistoryImportMissingParams, result: CodingHistoryImportMissingResult, kind: "unary", since: "1.5", errors: ["RESOURCE_BUSY", "RESOURCE_GONE", "CANCELLED", "INTERNAL"] }
1371
1448
  };
1372
1449
  var EVENTS = {
1373
1450
  "fs.changed": FsChangedEvent,
@@ -1376,6 +1453,7 @@ var EVENTS = {
1376
1453
  "exec.cwd": ExecCwdEvent,
1377
1454
  "session.control_changed": SessionControlChangedEvent,
1378
1455
  "models.progress": ModelsProgressEvent,
1456
+ "coding.history.progress": CodingHistoryProgressEvent,
1379
1457
  "relay.device_status": RelayDeviceStatusEvent,
1380
1458
  "relay.auth_expiring": RelayAuthExpiringEvent
1381
1459
  };