@rkat/sdk 0.5.1 → 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 = {
@@ -297,21 +315,24 @@ export class MeerkatClient {
297
315
  }
298
316
  // -- Config -------------------------------------------------------------
299
317
  async getConfig() {
300
- return this.request("config/get", {});
318
+ const raw = await this.request("config/get", {});
319
+ return MeerkatClient.parseConfigEnvelope(raw);
301
320
  }
302
321
  async setConfig(config, options) {
303
322
  const params = { config };
304
323
  if (options?.expectedGeneration !== undefined) {
305
324
  params.expected_generation = options.expectedGeneration;
306
325
  }
307
- return this.request("config/set", params);
326
+ const raw = await this.request("config/set", params);
327
+ return MeerkatClient.parseConfigEnvelope(raw);
308
328
  }
309
329
  async patchConfig(patch, options) {
310
330
  const params = { patch };
311
331
  if (options?.expectedGeneration !== undefined) {
312
332
  params.expected_generation = options.expectedGeneration;
313
333
  }
314
- return this.request("config/patch", params);
334
+ const raw = await this.request("config/patch", params);
335
+ return MeerkatClient.parseConfigEnvelope(raw);
315
336
  }
316
337
  async mcpAdd(params) {
317
338
  const raw = await this.request("mcp/add", params);
@@ -355,6 +376,76 @@ export class MeerkatClient {
355
376
  dataBase64: String(result.data ?? ""),
356
377
  };
357
378
  }
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));
404
+ }
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);
412
+ }
413
+ async pauseSchedule(scheduleId) {
414
+ const result = await this.request("schedule/pause", { schedule_id: scheduleId });
415
+ return MeerkatClient.parseSchedule(result);
416
+ }
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 ?? {},
447
+ });
448
+ }
358
449
  async subscribeSessionEvents(sessionId) {
359
450
  return this.openEventSubscription("session/stream_open", { session_id: sessionId }, "session/stream_close", MeerkatClient.parseAgentEventEnvelope);
360
451
  }
@@ -451,6 +542,33 @@ export class MeerkatClient {
451
542
  additional_instructions: options.additionalInstructions,
452
543
  });
453
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
+ }
454
572
  async retireMobMember(mobId, meerkatId) {
455
573
  await this.request("mob/retire", { mob_id: mobId, meerkat_id: meerkatId });
456
574
  }
@@ -555,11 +673,12 @@ export class MeerkatClient {
555
673
  return this.waitMobKickoff(mobId, options);
556
674
  }
557
675
  async spawnMobHelper(mobId, prompt, options) {
676
+ const roleName = options?.roleName ?? options?.profileName;
558
677
  const result = await this.request("mob/spawn_helper", {
559
678
  mob_id: mobId,
560
679
  prompt,
561
680
  meerkat_id: options?.meerkatId,
562
- profile_name: options?.profileName,
681
+ role_name: roleName,
563
682
  runtime_mode: options?.runtimeMode,
564
683
  backend: options?.backend,
565
684
  });
@@ -570,12 +689,13 @@ export class MeerkatClient {
570
689
  };
571
690
  }
572
691
  async forkMobHelper(mobId, sourceMemberId, prompt, options) {
692
+ const roleName = options?.roleName ?? options?.profileName;
573
693
  const result = await this.request("mob/fork_helper", {
574
694
  mob_id: mobId,
575
695
  source_member_id: sourceMemberId,
576
696
  prompt,
577
697
  meerkat_id: options?.meerkatId,
578
- profile_name: options?.profileName,
698
+ role_name: roleName,
579
699
  fork_context: options?.forkContext,
580
700
  runtime_mode: options?.runtimeMode,
581
701
  backend: options?.backend,
@@ -610,6 +730,56 @@ export class MeerkatClient {
610
730
  idempotency_key: options?.idempotencyKey,
611
731
  });
612
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
+ }
613
783
  async listMobFlows(mobId) {
614
784
  const result = await this.request("mob/flows", { mob_id: mobId });
615
785
  return result.flows ?? [];
@@ -700,6 +870,9 @@ export class MeerkatClient {
700
870
  blocked_tools: options.flowToolOverlay.blockedTools,
701
871
  };
702
872
  }
873
+ if (options?.additionalInstructions != null) {
874
+ params.additional_instructions = options.additionalInstructions;
875
+ }
703
876
  if (options?.keepAlive != null)
704
877
  params.keep_alive = options.keepAlive;
705
878
  if (options?.model)
@@ -744,6 +917,26 @@ export class MeerkatClient {
744
917
  blocked_tools: options.flowToolOverlay.blockedTools,
745
918
  };
746
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;
747
940
  const rpcRequest = { jsonrpc: "2.0", id: requestId, method: "turn/start", params };
748
941
  this.process.stdin.write(JSON.stringify(rpcRequest) + "\n");
749
942
  return new EventStream({
@@ -771,7 +964,8 @@ export class MeerkatClient {
771
964
  return this.peers(sessionId);
772
965
  }
773
966
  async send(sessionId, command) {
774
- 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);
775
969
  }
776
970
  async peers(sessionId) {
777
971
  return this.request("comms/peers", { session_id: sessionId });
@@ -1035,6 +1229,234 @@ export class MeerkatClient {
1035
1229
  skillDiagnostics: MeerkatClient.parseSkillDiagnostics(data.skill_diagnostics),
1036
1230
  };
1037
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
+ }
1038
1460
  static parseSessionHistory(data) {
1039
1461
  const rawMessages = Array.isArray(data.messages)
1040
1462
  ? data.messages
@@ -1050,6 +1472,10 @@ export class MeerkatClient {
1050
1472
  };
1051
1473
  }
1052
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;
1053
1479
  const rawToolCalls = Array.isArray(data.tool_calls)
1054
1480
  ? data.tool_calls
1055
1481
  : [];
@@ -1060,8 +1486,8 @@ export class MeerkatClient {
1060
1486
  ? data.results
1061
1487
  : [];
1062
1488
  return {
1063
- role: String(data.role ?? ""),
1064
- content: data.content != null ? MeerkatClient.parseContentInput(data.content) : undefined,
1489
+ role,
1490
+ content: contentValue != null ? MeerkatClient.parseContentInput(contentValue) : undefined,
1065
1491
  toolCalls: rawToolCalls.map((toolCall) => ({
1066
1492
  id: String(toolCall.id ?? ""),
1067
1493
  name: String(toolCall.name ?? ""),
@@ -1233,6 +1659,17 @@ export class MeerkatClient {
1233
1659
  params.skill_refs = wireRefs;
1234
1660
  if (options.skillReferences != null)
1235
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;
1236
1673
  return params;
1237
1674
  }
1238
1675
  // -- Binary resolution --------------------------------------------------