@rkat/sdk 0.5.0 → 0.5.2

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/client.js CHANGED
@@ -252,21 +252,39 @@ export class MeerkatClient {
252
252
  return new DeferredSession(this, String(raw.session_id ?? ""), raw.session_ref != null ? String(raw.session_ref) : undefined);
253
253
  }
254
254
  // -- Session queries ----------------------------------------------------
255
- async listSessions() {
256
- const result = await this.request("session/list", {});
255
+ async listSessions(options) {
256
+ const params = {};
257
+ if (options?.labels)
258
+ params.labels = options.labels;
259
+ if (options?.limit !== undefined)
260
+ params.limit = options.limit;
261
+ if (options?.offset !== undefined)
262
+ params.offset = options.offset;
263
+ const result = await this.request("session/list", params);
257
264
  const sessions = result.sessions ?? [];
258
- return sessions.map((s) => ({
259
- sessionId: String(s.session_id ?? ""),
260
- sessionRef: s.session_ref != null ? String(s.session_ref) : undefined,
261
- createdAt: String(s.created_at ?? ""),
262
- updatedAt: String(s.updated_at ?? ""),
263
- messageCount: Number(s.message_count ?? 0),
264
- totalTokens: Number(s.total_tokens ?? 0),
265
- isActive: Boolean(s.is_active),
266
- }));
265
+ return sessions.map((s) => MeerkatClient.parseSessionInfo(s));
267
266
  }
268
267
  async readSession(sessionId) {
269
- return this.request("session/read", { session_id: sessionId });
268
+ const raw = await this.request("session/read", { session_id: sessionId });
269
+ return MeerkatClient.parseSessionInfo(raw);
270
+ }
271
+ async sendExternalEvent(sessionId, payload, options) {
272
+ const params = { session_id: sessionId, payload };
273
+ if (options?.source !== undefined) {
274
+ params.source = options.source;
275
+ }
276
+ return this.request("session/external_event", params);
277
+ }
278
+ async injectContext(sessionId, text, options) {
279
+ const params = { session_id: sessionId, text };
280
+ if (options?.source !== undefined) {
281
+ params.source = options.source;
282
+ }
283
+ if (options?.idempotencyKey !== undefined) {
284
+ params.idempotency_key = options.idempotencyKey;
285
+ }
286
+ const result = await this.request("session/inject_context", params);
287
+ return { status: String(result.status ?? "") };
270
288
  }
271
289
  async readSessionHistory(sessionId, options) {
272
290
  const params = {
@@ -286,8 +304,7 @@ export class MeerkatClient {
286
304
  hasCapability(capabilityId) {
287
305
  if (capabilityId === "mob") {
288
306
  return (this._methods.has("mob/create")
289
- || this._methods.has("mob/list")
290
- || this._methods.has("mob/call"));
307
+ || this._methods.has("mob/list"));
291
308
  }
292
309
  return this._capabilities.some((c) => c.id === capabilityId && c.status === "Available");
293
310
  }
@@ -298,21 +315,24 @@ export class MeerkatClient {
298
315
  }
299
316
  // -- Config -------------------------------------------------------------
300
317
  async getConfig() {
301
- return this.request("config/get", {});
318
+ const raw = await this.request("config/get", {});
319
+ return MeerkatClient.parseConfigEnvelope(raw);
302
320
  }
303
321
  async setConfig(config, options) {
304
322
  const params = { config };
305
323
  if (options?.expectedGeneration !== undefined) {
306
324
  params.expected_generation = options.expectedGeneration;
307
325
  }
308
- return this.request("config/set", params);
326
+ const raw = await this.request("config/set", params);
327
+ return MeerkatClient.parseConfigEnvelope(raw);
309
328
  }
310
329
  async patchConfig(patch, options) {
311
330
  const params = { patch };
312
331
  if (options?.expectedGeneration !== undefined) {
313
332
  params.expected_generation = options.expectedGeneration;
314
333
  }
315
- return this.request("config/patch", params);
334
+ const raw = await this.request("config/patch", params);
335
+ return MeerkatClient.parseConfigEnvelope(raw);
316
336
  }
317
337
  async mcpAdd(params) {
318
338
  const raw = await this.request("mcp/add", params);
@@ -356,21 +376,74 @@ export class MeerkatClient {
356
376
  dataBase64: String(result.data ?? ""),
357
377
  };
358
378
  }
359
- async listMobPrefabs() {
360
- const result = await this.request("mob/prefabs", {});
361
- return result.prefabs ?? [];
379
+ async getModelsCatalog() {
380
+ const result = await this.request("models/catalog", {});
381
+ return MeerkatClient.parseModelsCatalog(result);
382
+ }
383
+ async createSchedule(request) {
384
+ const result = await this.request("schedule/create", MeerkatClient.toWireCreateScheduleRequest(request));
385
+ return MeerkatClient.parseSchedule(result);
386
+ }
387
+ async getSchedule(scheduleId) {
388
+ const result = await this.request("schedule/get", { schedule_id: scheduleId });
389
+ return MeerkatClient.parseSchedule(result);
390
+ }
391
+ async listSchedules(_options) {
392
+ const params = {};
393
+ if (_options?.labels)
394
+ params.labels = _options.labels;
395
+ if (_options?.limit !== undefined)
396
+ params.limit = _options.limit;
397
+ if (_options?.offset !== undefined)
398
+ params.offset = _options.offset;
399
+ const result = await this.request("schedule/list", params);
400
+ const schedules = Array.isArray(result.schedules)
401
+ ? result.schedules
402
+ : [];
403
+ return schedules.map((schedule) => MeerkatClient.parseSchedule(schedule));
362
404
  }
363
- async list_mob_prefabs() {
364
- return this.listMobPrefabs();
405
+ async updateSchedule(request) {
406
+ const params = {
407
+ schedule_id: request.scheduleId,
408
+ ...MeerkatClient.toWireUpdateSchedulePatch(request.update),
409
+ };
410
+ const result = await this.request("schedule/update", params);
411
+ return MeerkatClient.parseSchedule(result);
365
412
  }
366
- async listMobTools() {
367
- const result = await this.request("mob/tools", {});
368
- return result.tools ?? [];
413
+ async pauseSchedule(scheduleId) {
414
+ const result = await this.request("schedule/pause", { schedule_id: scheduleId });
415
+ return MeerkatClient.parseSchedule(result);
369
416
  }
370
- async callMobTool(name, argumentsPayload) {
371
- return this.request("mob/call", {
372
- name,
373
- arguments: argumentsPayload ?? {},
417
+ async resumeSchedule(scheduleId) {
418
+ const result = await this.request("schedule/resume", { schedule_id: scheduleId });
419
+ return MeerkatClient.parseSchedule(result);
420
+ }
421
+ async deleteSchedule(scheduleId) {
422
+ const result = await this.request("schedule/delete", { schedule_id: scheduleId });
423
+ return MeerkatClient.parseSchedule(result);
424
+ }
425
+ async listScheduleOccurrences(scheduleId, options) {
426
+ const params = { schedule_id: scheduleId };
427
+ if (options?.includeTerminal !== undefined) {
428
+ params.include_terminal = options.includeTerminal;
429
+ }
430
+ const result = await this.request("schedule/occurrences", params);
431
+ const occurrences = Array.isArray(result.occurrences)
432
+ ? result.occurrences.map((occurrence) => MeerkatClient.parseScheduleOccurrence(occurrence))
433
+ : [];
434
+ return { occurrences };
435
+ }
436
+ async listScheduleTools() {
437
+ const result = await this.request("schedule/tools", {});
438
+ const tools = Array.isArray(result.tools)
439
+ ? result.tools
440
+ : [];
441
+ return { tools };
442
+ }
443
+ async callScheduleTool(request) {
444
+ return this.request("schedule/call", {
445
+ name: request.name,
446
+ arguments: request.arguments ?? {},
374
447
  });
375
448
  }
376
449
  async subscribeSessionEvents(sessionId) {
@@ -433,6 +506,28 @@ export class MeerkatClient {
433
506
  : undefined,
434
507
  }));
435
508
  }
509
+ async sendMobMemberContent(mobId, meerkatId, content, options) {
510
+ const result = await this.request("mob/member_send", {
511
+ mob_id: mobId,
512
+ meerkat_id: meerkatId,
513
+ content,
514
+ handling_mode: options?.handlingMode,
515
+ render_metadata: options?.renderMetadata,
516
+ });
517
+ const sessionId = result.session_id;
518
+ if (typeof sessionId !== "string" || sessionId.length === 0) {
519
+ throw new MeerkatError("INVALID_RESPONSE", "Invalid mob/member_send response: missing session_id");
520
+ }
521
+ return {
522
+ memberId: typeof result.member_id === "string" && result.member_id.length > 0
523
+ ? result.member_id
524
+ : meerkatId,
525
+ sessionId,
526
+ handlingMode: result.handling_mode === "steer" || result.handling_mode === "queue"
527
+ ? result.handling_mode
528
+ : (options?.handlingMode ?? "queue"),
529
+ };
530
+ }
436
531
  async spawnMobMember(mobId, options) {
437
532
  return this.request("mob/spawn", {
438
533
  mob_id: mobId,
@@ -447,6 +542,33 @@ export class MeerkatClient {
447
542
  additional_instructions: options.additionalInstructions,
448
543
  });
449
544
  }
545
+ async spawnMobMembers(mobId, specs) {
546
+ const result = await this.request("mob/spawn_many", {
547
+ mob_id: mobId,
548
+ specs: specs.map((spec) => ({
549
+ profile: spec.profile,
550
+ meerkat_id: spec.meerkatId,
551
+ initial_message: spec.initialMessage,
552
+ runtime_mode: spec.runtimeMode,
553
+ backend: spec.backend,
554
+ resume_session_id: spec.resumeSessionId,
555
+ labels: spec.labels,
556
+ context: spec.context,
557
+ additional_instructions: spec.additionalInstructions,
558
+ })),
559
+ });
560
+ const entries = Array.isArray(result.results)
561
+ ? result.results
562
+ : [];
563
+ return entries.map((entry) => ({
564
+ ok: Boolean(entry.ok),
565
+ memberRef: entry.member_ref && typeof entry.member_ref === "object"
566
+ ? entry.member_ref
567
+ : undefined,
568
+ sessionId: entry.session_id != null ? String(entry.session_id) : undefined,
569
+ error: entry.error != null ? String(entry.error) : undefined,
570
+ }));
571
+ }
450
572
  async retireMobMember(mobId, meerkatId) {
451
573
  await this.request("mob/retire", { mob_id: mobId, meerkat_id: meerkatId });
452
574
  }
@@ -551,11 +673,12 @@ export class MeerkatClient {
551
673
  return this.waitMobKickoff(mobId, options);
552
674
  }
553
675
  async spawnMobHelper(mobId, prompt, options) {
676
+ const roleName = options?.roleName ?? options?.profileName;
554
677
  const result = await this.request("mob/spawn_helper", {
555
678
  mob_id: mobId,
556
679
  prompt,
557
680
  meerkat_id: options?.meerkatId,
558
- profile_name: options?.profileName,
681
+ role_name: roleName,
559
682
  runtime_mode: options?.runtimeMode,
560
683
  backend: options?.backend,
561
684
  });
@@ -566,12 +689,13 @@ export class MeerkatClient {
566
689
  };
567
690
  }
568
691
  async forkMobHelper(mobId, sourceMemberId, prompt, options) {
692
+ const roleName = options?.roleName ?? options?.profileName;
569
693
  const result = await this.request("mob/fork_helper", {
570
694
  mob_id: mobId,
571
695
  source_member_id: sourceMemberId,
572
696
  prompt,
573
697
  meerkat_id: options?.meerkatId,
574
- profile_name: options?.profileName,
698
+ role_name: roleName,
575
699
  fork_context: options?.forkContext,
576
700
  runtime_mode: options?.runtimeMode,
577
701
  backend: options?.backend,
@@ -597,24 +721,6 @@ export class MeerkatClient {
597
721
  async mobLifecycle(mobId, action) {
598
722
  await this.request("mob/lifecycle", { mob_id: mobId, action });
599
723
  }
600
- async sendMobMemberContent(mobId, meerkatId, content, options) {
601
- const result = await this.request("mob/send", {
602
- mob_id: mobId,
603
- meerkat_id: meerkatId,
604
- content,
605
- handling_mode: options?.handlingMode ?? "queue",
606
- render_metadata: options?.renderMetadata,
607
- });
608
- const sessionId = result.session_id;
609
- if (typeof sessionId !== "string" || sessionId.length === 0) {
610
- throw new MeerkatError("INVALID_RESPONSE", "Invalid mob/send response: missing session_id");
611
- }
612
- return {
613
- memberId: String(result.member_id ?? meerkatId),
614
- sessionId,
615
- handlingMode: String(result.handling_mode ?? options?.handlingMode ?? "queue"),
616
- };
617
- }
618
724
  async appendMobSystemContext(mobId, meerkatId, text, options) {
619
725
  return this.request("mob/append_system_context", {
620
726
  mob_id: mobId,
@@ -624,6 +730,56 @@ export class MeerkatClient {
624
730
  idempotency_key: options?.idempotencyKey,
625
731
  });
626
732
  }
733
+ async readMobEvents(mobId, options) {
734
+ const params = { mob_id: mobId };
735
+ if (options?.afterCursor !== undefined) {
736
+ params.after_cursor = options.afterCursor;
737
+ }
738
+ if (options?.limit !== undefined) {
739
+ params.limit = options.limit;
740
+ }
741
+ const result = await this.request("mob/events", params);
742
+ const events = Array.isArray(result.events)
743
+ ? result.events
744
+ : [];
745
+ return { events };
746
+ }
747
+ async createMobProfile(name, profile) {
748
+ const raw = await this.request("mob/profile/create", {
749
+ name,
750
+ profile,
751
+ });
752
+ return MeerkatClient.parseMobProfileLookup(raw);
753
+ }
754
+ async getMobProfile(name) {
755
+ const raw = await this.request("mob/profile/get", { name });
756
+ return MeerkatClient.parseMobProfileLookup(raw);
757
+ }
758
+ async listMobProfiles() {
759
+ const raw = await this.request("mob/profile/list", {});
760
+ const profiles = Array.isArray(raw.profiles)
761
+ ? raw.profiles
762
+ : [];
763
+ return profiles.map((profile) => MeerkatClient.parseMobProfileLookup(profile));
764
+ }
765
+ async updateMobProfile(name, profile, expectedRevision) {
766
+ const raw = await this.request("mob/profile/update", {
767
+ name,
768
+ profile,
769
+ expected_revision: expectedRevision,
770
+ });
771
+ return MeerkatClient.parseMobProfileLookup(raw);
772
+ }
773
+ async deleteMobProfile(name, expectedRevision) {
774
+ const raw = await this.request("mob/profile/delete", {
775
+ name,
776
+ expected_revision: expectedRevision,
777
+ });
778
+ return {
779
+ name: String(raw.name ?? name),
780
+ deletedRevision: Number(raw.deleted_revision ?? expectedRevision),
781
+ };
782
+ }
627
783
  async listMobFlows(mobId) {
628
784
  const result = await this.request("mob/flows", { mob_id: mobId });
629
785
  return result.flows ?? [];
@@ -714,6 +870,9 @@ export class MeerkatClient {
714
870
  blocked_tools: options.flowToolOverlay.blockedTools,
715
871
  };
716
872
  }
873
+ if (options?.additionalInstructions != null) {
874
+ params.additional_instructions = options.additionalInstructions;
875
+ }
717
876
  if (options?.keepAlive != null)
718
877
  params.keep_alive = options.keepAlive;
719
878
  if (options?.model)
@@ -758,6 +917,26 @@ export class MeerkatClient {
758
917
  blocked_tools: options.flowToolOverlay.blockedTools,
759
918
  };
760
919
  }
920
+ if (options?.additionalInstructions != null) {
921
+ params.additional_instructions = options.additionalInstructions;
922
+ }
923
+ if (options?.keepAlive != null)
924
+ params.keep_alive = options.keepAlive;
925
+ if (options?.model)
926
+ params.model = options.model;
927
+ if (options?.provider)
928
+ params.provider = options.provider;
929
+ if (options?.maxTokens)
930
+ params.max_tokens = options.maxTokens;
931
+ if (options?.systemPrompt)
932
+ params.system_prompt = options.systemPrompt;
933
+ if (options?.outputSchema)
934
+ params.output_schema = options.outputSchema;
935
+ if (options?.structuredOutputRetries != null) {
936
+ params.structured_output_retries = options.structuredOutputRetries;
937
+ }
938
+ if (options?.providerParams)
939
+ params.provider_params = options.providerParams;
761
940
  const rpcRequest = { jsonrpc: "2.0", id: requestId, method: "turn/start", params };
762
941
  this.process.stdin.write(JSON.stringify(rpcRequest) + "\n");
763
942
  return new EventStream({
@@ -785,7 +964,8 @@ export class MeerkatClient {
785
964
  return this.peers(sessionId);
786
965
  }
787
966
  async send(sessionId, command) {
788
- return this.request("comms/send", { session_id: sessionId, ...command });
967
+ const result = await this.request("comms/send", { session_id: sessionId, ...command });
968
+ return MeerkatClient.parseCommsSendReceipt(result);
789
969
  }
790
970
  async peers(sessionId) {
791
971
  return this.request("comms/peers", { session_id: sessionId });
@@ -1049,6 +1229,234 @@ export class MeerkatClient {
1049
1229
  skillDiagnostics: MeerkatClient.parseSkillDiagnostics(data.skill_diagnostics),
1050
1230
  };
1051
1231
  }
1232
+ static parseSessionInfo(data) {
1233
+ const labelsRaw = data.labels && typeof data.labels === "object"
1234
+ ? data.labels
1235
+ : {};
1236
+ const labels = Object.fromEntries(Object.entries(labelsRaw).map(([key, value]) => [key, String(value)]));
1237
+ return {
1238
+ sessionId: String(data.session_id ?? ""),
1239
+ sessionRef: data.session_ref != null ? String(data.session_ref) : undefined,
1240
+ createdAt: Number(data.created_at ?? 0),
1241
+ updatedAt: Number(data.updated_at ?? 0),
1242
+ messageCount: Number(data.message_count ?? 0),
1243
+ isActive: Boolean(data.is_active),
1244
+ totalTokens: data.total_tokens != null ? Number(data.total_tokens) : undefined,
1245
+ model: data.model != null ? String(data.model) : undefined,
1246
+ provider: data.provider != null ? String(data.provider) : undefined,
1247
+ lastAssistantText: data.last_assistant_text != null ? String(data.last_assistant_text) : undefined,
1248
+ labels,
1249
+ };
1250
+ }
1251
+ static parseConfigEnvelope(data) {
1252
+ const rawConfig = data.config && typeof data.config === "object"
1253
+ ? data.config
1254
+ : {};
1255
+ const rawResolvedPaths = data.resolved_paths && typeof data.resolved_paths === "object"
1256
+ ? data.resolved_paths
1257
+ : undefined;
1258
+ const resolvedPaths = rawResolvedPaths
1259
+ ? Object.fromEntries(Object.entries(rawResolvedPaths).map(([key, value]) => [key, String(value)]))
1260
+ : undefined;
1261
+ return {
1262
+ config: rawConfig,
1263
+ generation: Number(data.generation ?? 0),
1264
+ realmId: data.realm_id != null ? String(data.realm_id) : undefined,
1265
+ instanceId: data.instance_id != null ? String(data.instance_id) : undefined,
1266
+ backend: data.backend != null ? String(data.backend) : undefined,
1267
+ resolvedPaths,
1268
+ };
1269
+ }
1270
+ static parseCommsSendReceipt(data) {
1271
+ return {
1272
+ ...data,
1273
+ requestId: data.request_id != null ? String(data.request_id) : undefined,
1274
+ interactionId: data.interaction_id != null ? String(data.interaction_id) : undefined,
1275
+ inputId: data.input_id != null ? String(data.input_id) : undefined,
1276
+ };
1277
+ }
1278
+ static parseModelsCatalog(data) {
1279
+ const providersRaw = Array.isArray(data.providers)
1280
+ ? data.providers
1281
+ : [];
1282
+ let contractVersion = { major: 0, minor: 0, patch: 0 };
1283
+ if (data.contract_version && typeof data.contract_version === "object") {
1284
+ const contractVersionRaw = data.contract_version;
1285
+ contractVersion = {
1286
+ major: Number(contractVersionRaw.major ?? 0),
1287
+ minor: Number(contractVersionRaw.minor ?? 0),
1288
+ patch: Number(contractVersionRaw.patch ?? 0),
1289
+ };
1290
+ }
1291
+ else if (typeof data.contract_version === "string") {
1292
+ const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(data.contract_version);
1293
+ if (match) {
1294
+ contractVersion = {
1295
+ major: Number(match[1]),
1296
+ minor: Number(match[2]),
1297
+ patch: Number(match[3]),
1298
+ };
1299
+ }
1300
+ }
1301
+ return {
1302
+ contractVersion,
1303
+ providers: providersRaw.map((provider) => ({
1304
+ provider: String(provider.provider ?? ""),
1305
+ defaultModelId: String(provider.default_model_id ?? ""),
1306
+ models: Array.isArray(provider.models)
1307
+ ? provider.models.map((model) => ({
1308
+ id: String(model.id ?? ""),
1309
+ displayName: String(model.display_name ?? ""),
1310
+ tier: String(model.tier ?? "supported") === "recommended"
1311
+ ? "recommended"
1312
+ : "supported",
1313
+ contextWindow: model.context_window != null ? Number(model.context_window) : undefined,
1314
+ maxOutputTokens: model.max_output_tokens != null ? Number(model.max_output_tokens) : undefined,
1315
+ serverId: model.server_id != null ? String(model.server_id) : undefined,
1316
+ profile: model.profile && typeof model.profile === "object"
1317
+ ? {
1318
+ modelFamily: String(model.profile.model_family ?? ""),
1319
+ supportsTemperature: Boolean(model.profile.supports_temperature),
1320
+ supportsThinking: Boolean(model.profile.supports_thinking),
1321
+ supportsReasoning: Boolean(model.profile.supports_reasoning),
1322
+ inlineVideo: Boolean(model.profile.inline_video),
1323
+ paramsSchema: model.profile.params_schema,
1324
+ }
1325
+ : undefined,
1326
+ }))
1327
+ : [],
1328
+ })),
1329
+ };
1330
+ }
1331
+ static parseSchedule(data) {
1332
+ const labelsRaw = data.labels && typeof data.labels === "object"
1333
+ ? data.labels
1334
+ : {};
1335
+ return {
1336
+ scheduleId: String(data.schedule_id ?? ""),
1337
+ phase: String(data.phase ?? ""),
1338
+ revision: typeof data.revision === "object" && data.revision !== null
1339
+ ? Number(data.revision["0"] ?? 0)
1340
+ : Number(data.revision ?? 0),
1341
+ name: data.name != null ? String(data.name) : undefined,
1342
+ description: data.description != null ? String(data.description) : undefined,
1343
+ trigger: data.trigger && typeof data.trigger === "object"
1344
+ ? data.trigger
1345
+ : {},
1346
+ target: data.target && typeof data.target === "object"
1347
+ ? data.target
1348
+ : {},
1349
+ misfirePolicy: data.misfire_policy != null
1350
+ ? data.misfire_policy
1351
+ : undefined,
1352
+ overlapPolicy: data.overlap_policy != null ? String(data.overlap_policy) : undefined,
1353
+ missingTargetPolicy: data.missing_target_policy != null ? String(data.missing_target_policy) : undefined,
1354
+ planningHorizonDays: data.planning_horizon_days != null ? Number(data.planning_horizon_days) : undefined,
1355
+ planningHorizonOccurrences: data.planning_horizon_occurrences != null
1356
+ ? Number(data.planning_horizon_occurrences)
1357
+ : undefined,
1358
+ nextOccurrenceOrdinal: typeof data.next_occurrence_ordinal === "object"
1359
+ ? Number(data.next_occurrence_ordinal["0"] ?? 0)
1360
+ : data.next_occurrence_ordinal != null
1361
+ ? Number(data.next_occurrence_ordinal)
1362
+ : undefined,
1363
+ planningCursorUtc: data.planning_cursor_utc != null ? String(data.planning_cursor_utc) : undefined,
1364
+ createdAtUtc: data.created_at_utc != null ? String(data.created_at_utc) : undefined,
1365
+ updatedAtUtc: data.updated_at_utc != null ? String(data.updated_at_utc) : undefined,
1366
+ deletedAtUtc: data.deleted_at_utc != null ? String(data.deleted_at_utc) : undefined,
1367
+ labels: Object.fromEntries(Object.entries(labelsRaw).map(([key, value]) => [key, String(value)])),
1368
+ };
1369
+ }
1370
+ static parseScheduleOccurrence(data) {
1371
+ return {
1372
+ occurrenceId: String(data.occurrence_id ?? ""),
1373
+ scheduleId: String(data.schedule_id ?? ""),
1374
+ scheduleRevision: typeof data.schedule_revision === "object" && data.schedule_revision !== null
1375
+ ? Number(data.schedule_revision["0"] ?? 0)
1376
+ : Number(data.schedule_revision ?? 0),
1377
+ occurrenceOrdinal: typeof data.occurrence_ordinal === "object" && data.occurrence_ordinal !== null
1378
+ ? Number(data.occurrence_ordinal["0"] ?? 0)
1379
+ : Number(data.occurrence_ordinal ?? 0),
1380
+ phase: String(data.phase ?? ""),
1381
+ dueAtUtc: String(data.due_at_utc ?? ""),
1382
+ triggerSnapshot: data.trigger_snapshot && typeof data.trigger_snapshot === "object"
1383
+ ? data.trigger_snapshot
1384
+ : {},
1385
+ targetSnapshot: data.target_snapshot && typeof data.target_snapshot === "object"
1386
+ ? data.target_snapshot
1387
+ : {},
1388
+ misfirePolicy: data.misfire_policy != null
1389
+ ? data.misfire_policy
1390
+ : undefined,
1391
+ overlapPolicy: data.overlap_policy != null ? String(data.overlap_policy) : undefined,
1392
+ missingTargetPolicy: data.missing_target_policy != null ? String(data.missing_target_policy) : undefined,
1393
+ claimedBy: data.claimed_by != null ? String(data.claimed_by) : undefined,
1394
+ leaseExpiresAtUtc: data.lease_expires_at_utc != null ? String(data.lease_expires_at_utc) : undefined,
1395
+ deliveryCorrelationId: data.delivery_correlation_id != null ? String(data.delivery_correlation_id) : undefined,
1396
+ lastReceipt: data.last_receipt && typeof data.last_receipt === "object"
1397
+ ? data.last_receipt
1398
+ : undefined,
1399
+ failureClass: data.failure_class != null ? String(data.failure_class) : undefined,
1400
+ failureDetail: data.failure_detail != null ? String(data.failure_detail) : undefined,
1401
+ attemptCount: data.attempt_count != null ? Number(data.attempt_count) : undefined,
1402
+ createdAtUtc: data.created_at_utc != null ? String(data.created_at_utc) : undefined,
1403
+ claimedAtUtc: data.claimed_at_utc != null ? String(data.claimed_at_utc) : undefined,
1404
+ dispatchedAtUtc: data.dispatched_at_utc != null ? String(data.dispatched_at_utc) : undefined,
1405
+ completedAtUtc: data.completed_at_utc != null ? String(data.completed_at_utc) : undefined,
1406
+ supersededByRevision: typeof data.superseded_by_revision === "object" && data.superseded_by_revision !== null
1407
+ ? Number(data.superseded_by_revision["0"] ?? 0)
1408
+ : data.superseded_by_revision != null
1409
+ ? Number(data.superseded_by_revision)
1410
+ : undefined,
1411
+ };
1412
+ }
1413
+ static parseMobProfileLookup(data) {
1414
+ if (Boolean(data.not_found)) {
1415
+ return {
1416
+ notFound: true,
1417
+ name: String(data.name ?? ""),
1418
+ };
1419
+ }
1420
+ return {
1421
+ notFound: false,
1422
+ name: String(data.name ?? ""),
1423
+ profile: data.profile && typeof data.profile === "object"
1424
+ ? data.profile
1425
+ : undefined,
1426
+ revision: data.revision != null ? Number(data.revision) : undefined,
1427
+ createdAt: data.created_at != null ? String(data.created_at) : undefined,
1428
+ updatedAt: data.updated_at != null ? String(data.updated_at) : undefined,
1429
+ };
1430
+ }
1431
+ static toWireCreateScheduleRequest(request) {
1432
+ return {
1433
+ name: request.name,
1434
+ description: request.description,
1435
+ trigger: request.trigger,
1436
+ target: request.target,
1437
+ misfire_policy: request.misfirePolicy,
1438
+ overlap_policy: request.overlapPolicy,
1439
+ missing_target_policy: request.missingTargetPolicy,
1440
+ labels: request.labels,
1441
+ planning_horizon_days: request.planningHorizonDays,
1442
+ planning_horizon_occurrences: request.planningHorizonOccurrences,
1443
+ };
1444
+ }
1445
+ static toWireUpdateSchedulePatch(update) {
1446
+ return {
1447
+ expected_revision: update.expectedRevision,
1448
+ name: update.name,
1449
+ description: update.description,
1450
+ trigger: update.trigger,
1451
+ target: update.target,
1452
+ misfire_policy: update.misfirePolicy,
1453
+ overlap_policy: update.overlapPolicy,
1454
+ missing_target_policy: update.missingTargetPolicy,
1455
+ planning_horizon_days: update.planningHorizonDays,
1456
+ planning_horizon_occurrences: update.planningHorizonOccurrences,
1457
+ labels: update.labels,
1458
+ };
1459
+ }
1052
1460
  static parseSessionHistory(data) {
1053
1461
  const rawMessages = Array.isArray(data.messages)
1054
1462
  ? data.messages
@@ -1064,6 +1472,10 @@ export class MeerkatClient {
1064
1472
  };
1065
1473
  }
1066
1474
  static parseSessionMessage(data) {
1475
+ const role = String(data.role ?? "");
1476
+ const contentValue = role === "system_notice" && data.content == null && data.body != null
1477
+ ? String(data.body)
1478
+ : data.content;
1067
1479
  const rawToolCalls = Array.isArray(data.tool_calls)
1068
1480
  ? data.tool_calls
1069
1481
  : [];
@@ -1074,8 +1486,8 @@ export class MeerkatClient {
1074
1486
  ? data.results
1075
1487
  : [];
1076
1488
  return {
1077
- role: String(data.role ?? ""),
1078
- content: data.content != null ? MeerkatClient.parseContentInput(data.content) : undefined,
1489
+ role,
1490
+ content: contentValue != null ? MeerkatClient.parseContentInput(contentValue) : undefined,
1079
1491
  toolCalls: rawToolCalls.map((toolCall) => ({
1080
1492
  id: String(toolCall.id ?? ""),
1081
1493
  name: String(toolCall.name ?? ""),
@@ -1120,6 +1532,15 @@ export class MeerkatClient {
1120
1532
  data: String(data.data ?? ""),
1121
1533
  };
1122
1534
  }
1535
+ if (type === "video") {
1536
+ return {
1537
+ type: "video",
1538
+ media_type: String(data.media_type ?? ""),
1539
+ duration_ms: Number(data.duration_ms ?? 0),
1540
+ source: "inline",
1541
+ data: String(data.data ?? ""),
1542
+ };
1543
+ }
1123
1544
  return { type: "text", text: "" };
1124
1545
  }
1125
1546
  static parseSessionAssistantBlock(data) {
@@ -1238,6 +1659,17 @@ export class MeerkatClient {
1238
1659
  params.skill_refs = wireRefs;
1239
1660
  if (options.skillReferences != null)
1240
1661
  params.skill_references = options.skillReferences;
1662
+ if (options.labels != null)
1663
+ params.labels = options.labels;
1664
+ if (options.additionalInstructions != null) {
1665
+ params.additional_instructions = options.additionalInstructions;
1666
+ }
1667
+ if (options.appContext !== undefined)
1668
+ params.app_context = options.appContext;
1669
+ if (options.shellEnv != null)
1670
+ params.shell_env = options.shellEnv;
1671
+ if (options.externalTools != null)
1672
+ params.external_tools = options.externalTools;
1241
1673
  return params;
1242
1674
  }
1243
1675
  // -- Binary resolution --------------------------------------------------