@frumu/tandem-client 0.3.28 → 0.4.3

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
@@ -65,8 +65,15 @@ var jsonFallback = import_zod.z.any().transform((val) => val);
65
65
  var jsonObjectFallback = import_zod.z.record(import_zod.z.string(), import_zod.z.any()).transform((val) => val);
66
66
  var SystemHealthSchema = import_zod.z.object({
67
67
  ready: import_zod.z.boolean().optional(),
68
- phase: import_zod.z.string().optional()
69
- }).passthrough();
68
+ phase: import_zod.z.string().optional(),
69
+ workspace_root: import_zod.z.string().optional(),
70
+ workspaceRoot: import_zod.z.string().optional()
71
+ }).passthrough().transform(
72
+ (val) => ({
73
+ ...val,
74
+ workspaceRoot: val.workspace_root ?? val.workspaceRoot
75
+ })
76
+ );
70
77
  var SessionRecordSchema = import_zod.z.object({
71
78
  id: import_zod.z.string(),
72
79
  title: import_zod.z.string(),
@@ -370,13 +377,21 @@ var TandemClient = class {
370
377
  this.providers = new Providers(req);
371
378
  this.identity = new Identity(req);
372
379
  this.channels = new Channels(req);
373
- this.mcp = new Mcp(req);
374
- this.routines = new Routines(req);
375
- this.automations = new Automations(req);
376
- this.automationsV2 = new AutomationsV2(req);
380
+ this.mcp = new Mcp(req, this._requestText.bind(this));
381
+ const getToken = () => this.token;
382
+ this.routines = new Routines(this.baseUrl, getToken, req);
383
+ this.automations = new Automations(this.baseUrl, getToken, req);
384
+ this.automationsV2 = new AutomationsV2(this.baseUrl, getToken, req);
385
+ this.workflowPlans = new WorkflowPlans(req);
377
386
  this.memory = new Memory(req);
378
387
  this.skills = new Skills(req);
379
- this.resources = new Resources(req);
388
+ this.packs = new Packs(req);
389
+ this.capabilities = new Capabilities(req);
390
+ this.resources = new Resources(this.baseUrl, getToken, req);
391
+ this.browser = new Browser(req);
392
+ this.workflows = new Workflows(this.baseUrl, getToken, req);
393
+ this.bugMonitor = new BugMonitor(req);
394
+ this.coder = new Coder(req);
380
395
  this.agentTeams = new AgentTeams(req);
381
396
  this.missions = new Missions(req);
382
397
  }
@@ -491,6 +506,239 @@ var TandemClient = class {
491
506
  }
492
507
  return res.json();
493
508
  }
509
+ async _requestText(path, init = {}) {
510
+ const controller = new AbortController();
511
+ const timer = setTimeout(() => controller.abort(), this.timeoutMs);
512
+ let res;
513
+ try {
514
+ res = await fetch(`${this.baseUrl}${path}`, {
515
+ ...init,
516
+ headers: {
517
+ Authorization: `Bearer ${this.token}`,
518
+ ...init.headers ?? {}
519
+ },
520
+ signal: controller.signal
521
+ });
522
+ } catch (err) {
523
+ if (err instanceof Error && err.name === "AbortError") {
524
+ throw new Error(`Request timed out after ${this.timeoutMs}ms: ${path}`);
525
+ }
526
+ throw err;
527
+ } finally {
528
+ clearTimeout(timer);
529
+ }
530
+ if (!res.ok) {
531
+ const body = await res.text().catch(() => "");
532
+ throw new Error(`Request failed (${res.status} ${res.statusText}): ${body}`);
533
+ }
534
+ return res.text();
535
+ }
536
+ };
537
+ var Browser = class {
538
+ constructor(req) {
539
+ this.req = req;
540
+ }
541
+ async status() {
542
+ return this.req("/browser/status");
543
+ }
544
+ async install() {
545
+ return this.req("/browser/install", { method: "POST" });
546
+ }
547
+ async smokeTest(options) {
548
+ return this.req("/browser/smoke-test", {
549
+ method: "POST",
550
+ body: JSON.stringify(options ?? {})
551
+ });
552
+ }
553
+ };
554
+ var Workflows = class {
555
+ constructor(baseUrl, getToken, req) {
556
+ this.baseUrl = baseUrl;
557
+ this.getToken = getToken;
558
+ this.req = req;
559
+ }
560
+ async list() {
561
+ const raw = await this.req("/workflows");
562
+ const asObj = raw ?? {};
563
+ const workflows = Array.isArray(asObj.workflows) ? asObj.workflows : [];
564
+ return { workflows, count: typeof asObj.count === "number" ? asObj.count : workflows.length };
565
+ }
566
+ async get(id) {
567
+ const raw = await this.req(
568
+ `/workflows/${encodeURIComponent(id)}`
569
+ );
570
+ return raw.workflow ?? {};
571
+ }
572
+ async validate(payload) {
573
+ return this.req("/workflows/validate", {
574
+ method: "POST",
575
+ body: JSON.stringify(payload ?? {})
576
+ });
577
+ }
578
+ async simulate(payload) {
579
+ return this.req("/workflows/simulate", {
580
+ method: "POST",
581
+ body: JSON.stringify(payload)
582
+ });
583
+ }
584
+ events(options) {
585
+ const params = new URLSearchParams();
586
+ const workflowId = options?.workflow_id ?? options?.workflowId;
587
+ const runId = options?.run_id ?? options?.runId;
588
+ if (workflowId) params.set("workflow_id", workflowId);
589
+ if (runId) params.set("run_id", runId);
590
+ const qs = params.toString() ? `?${params.toString()}` : "";
591
+ return streamSse(`${this.baseUrl}/workflows/events${qs}`, this.getToken(), {
592
+ signal: options?.signal
593
+ });
594
+ }
595
+ async listRuns(options) {
596
+ const params = new URLSearchParams();
597
+ const workflowId = options?.workflow_id ?? options?.workflowId;
598
+ if (workflowId) params.set("workflow_id", workflowId);
599
+ if (options?.limit !== void 0) params.set("limit", String(options.limit));
600
+ const qs = params.toString() ? `?${params.toString()}` : "";
601
+ const raw = await this.req(`/workflows/runs${qs}`);
602
+ const asObj = raw ?? {};
603
+ const runs = Array.isArray(asObj.runs) ? asObj.runs : [];
604
+ return { runs, count: typeof asObj.count === "number" ? asObj.count : runs.length };
605
+ }
606
+ async getRun(id) {
607
+ const raw = await this.req(
608
+ `/workflows/runs/${encodeURIComponent(id)}`
609
+ );
610
+ return raw.run ?? {};
611
+ }
612
+ async run(id, payload) {
613
+ return this.req(`/workflows/${encodeURIComponent(id)}/run`, {
614
+ method: "POST",
615
+ body: JSON.stringify(payload ?? {})
616
+ });
617
+ }
618
+ async listHooks(options) {
619
+ const params = new URLSearchParams();
620
+ const workflowId = options?.workflow_id ?? options?.workflowId;
621
+ if (workflowId) params.set("workflow_id", workflowId);
622
+ const qs = params.toString() ? `?${params.toString()}` : "";
623
+ const raw = await this.req(`/workflow-hooks${qs}`);
624
+ const asObj = raw ?? {};
625
+ const hooks = Array.isArray(asObj.hooks) ? asObj.hooks : [];
626
+ return { hooks, count: typeof asObj.count === "number" ? asObj.count : hooks.length };
627
+ }
628
+ async patchHook(id, patch) {
629
+ return this.req(`/workflow-hooks/${encodeURIComponent(id)}`, {
630
+ method: "PATCH",
631
+ body: JSON.stringify(patch)
632
+ });
633
+ }
634
+ };
635
+ var BugMonitor = class {
636
+ constructor(req) {
637
+ this.req = req;
638
+ }
639
+ async getConfig() {
640
+ return this.req("/config/bug-monitor");
641
+ }
642
+ async patchConfig(config) {
643
+ return this.req("/config/bug-monitor", {
644
+ method: "PATCH",
645
+ body: JSON.stringify(config)
646
+ });
647
+ }
648
+ async getStatus() {
649
+ return this.req("/bug-monitor/status");
650
+ }
651
+ async recomputeStatus() {
652
+ return this.req("/bug-monitor/status/recompute", {
653
+ method: "POST"
654
+ });
655
+ }
656
+ async pause() {
657
+ return this.req("/bug-monitor/pause", { method: "POST" });
658
+ }
659
+ async resume() {
660
+ return this.req("/bug-monitor/resume", { method: "POST" });
661
+ }
662
+ async debug() {
663
+ return this.req("/bug-monitor/debug");
664
+ }
665
+ async listIncidents(options) {
666
+ const qs = options?.limit !== void 0 ? `?limit=${options.limit}` : "";
667
+ return this.req(`/bug-monitor/incidents${qs}`);
668
+ }
669
+ async getIncident(id) {
670
+ const raw = await this.req(
671
+ `/bug-monitor/incidents/${encodeURIComponent(id)}`
672
+ );
673
+ return raw.incident ?? {};
674
+ }
675
+ async replayIncident(id, payload) {
676
+ return this.req(`/bug-monitor/incidents/${encodeURIComponent(id)}/replay`, {
677
+ method: "POST",
678
+ body: JSON.stringify(payload ?? {})
679
+ });
680
+ }
681
+ async listDrafts(options) {
682
+ const qs = options?.limit !== void 0 ? `?limit=${options.limit}` : "";
683
+ return this.req(`/bug-monitor/drafts${qs}`);
684
+ }
685
+ async listPosts(options) {
686
+ const qs = options?.limit !== void 0 ? `?limit=${options.limit}` : "";
687
+ return this.req(`/bug-monitor/posts${qs}`);
688
+ }
689
+ async getDraft(id) {
690
+ const raw = await this.req(
691
+ `/bug-monitor/drafts/${encodeURIComponent(id)}`
692
+ );
693
+ return raw.draft ?? {};
694
+ }
695
+ async approveDraft(id, reason) {
696
+ return this.req(`/bug-monitor/drafts/${encodeURIComponent(id)}/approve`, {
697
+ method: "POST",
698
+ body: JSON.stringify({ reason })
699
+ });
700
+ }
701
+ async denyDraft(id, reason) {
702
+ return this.req(`/bug-monitor/drafts/${encodeURIComponent(id)}/deny`, {
703
+ method: "POST",
704
+ body: JSON.stringify({ reason })
705
+ });
706
+ }
707
+ async report(payload) {
708
+ return this.req("/bug-monitor/report", {
709
+ method: "POST",
710
+ body: JSON.stringify(payload)
711
+ });
712
+ }
713
+ async createTriageRun(id) {
714
+ return this.req(`/bug-monitor/drafts/${encodeURIComponent(id)}/triage-run`, {
715
+ method: "POST"
716
+ });
717
+ }
718
+ async createTriageSummary(id, payload) {
719
+ return this.req(`/bug-monitor/drafts/${encodeURIComponent(id)}/triage-summary`, {
720
+ method: "POST",
721
+ body: JSON.stringify(payload)
722
+ });
723
+ }
724
+ async createIssueDraft(id, payload) {
725
+ return this.req(`/bug-monitor/drafts/${encodeURIComponent(id)}/issue-draft`, {
726
+ method: "POST",
727
+ body: JSON.stringify(payload ?? {})
728
+ });
729
+ }
730
+ async publishDraft(id, payload) {
731
+ return this.req(`/bug-monitor/drafts/${encodeURIComponent(id)}/publish`, {
732
+ method: "POST",
733
+ body: JSON.stringify(payload ?? {})
734
+ });
735
+ }
736
+ async recheckMatch(id, payload) {
737
+ return this.req(`/bug-monitor/drafts/${encodeURIComponent(id)}/recheck-match`, {
738
+ method: "POST",
739
+ body: JSON.stringify(payload ?? {})
740
+ });
741
+ }
494
742
  };
495
743
  var Sessions = class {
496
744
  constructor(baseUrl, token, timeoutMs, req) {
@@ -854,8 +1102,9 @@ var Channels = class {
854
1102
  }
855
1103
  };
856
1104
  var Mcp = class {
857
- constructor(req) {
1105
+ constructor(req, reqText) {
858
1106
  this.req = req;
1107
+ this.reqText = reqText;
859
1108
  }
860
1109
  /** List registered MCP servers. */
861
1110
  async list() {
@@ -910,6 +1159,38 @@ var Mcp = class {
910
1159
  body: JSON.stringify({ enabled })
911
1160
  });
912
1161
  }
1162
+ async delete(name) {
1163
+ return this.req(`/mcp/${encodeURIComponent(name)}`, {
1164
+ method: "DELETE"
1165
+ });
1166
+ }
1167
+ async auth(name, payload) {
1168
+ return this.req(`/mcp/${encodeURIComponent(name)}/auth`, {
1169
+ method: "POST",
1170
+ body: JSON.stringify(payload ?? {})
1171
+ });
1172
+ }
1173
+ async deleteAuth(name) {
1174
+ return this.req(`/mcp/${encodeURIComponent(name)}/auth`, {
1175
+ method: "DELETE"
1176
+ });
1177
+ }
1178
+ async authCallback(name, payload) {
1179
+ return this.req(`/mcp/${encodeURIComponent(name)}/auth/callback`, {
1180
+ method: "POST",
1181
+ body: JSON.stringify(payload)
1182
+ });
1183
+ }
1184
+ async authenticate(name, payload) {
1185
+ return this.req(`/mcp/${encodeURIComponent(name)}/auth/authenticate`, {
1186
+ method: "POST",
1187
+ body: JSON.stringify(payload ?? {})
1188
+ });
1189
+ }
1190
+ async catalogToml(slug) {
1191
+ if (!this.reqText) throw new Error("Text request helper unavailable");
1192
+ return this.reqText(`/mcp/catalog/${encodeURIComponent(slug)}/toml`);
1193
+ }
913
1194
  };
914
1195
  var Memory = class {
915
1196
  constructor(req) {
@@ -1013,16 +1294,30 @@ var Skills = class {
1013
1294
  }
1014
1295
  /** Import a skill from YAML content or a file path. */
1015
1296
  async import(options) {
1297
+ const payload = {
1298
+ content: options.content,
1299
+ file_or_path: options.file_or_path ?? options.fileOrPath,
1300
+ location: options.location,
1301
+ namespace: options.namespace,
1302
+ conflict_policy: options.conflict_policy ?? options.conflictPolicy
1303
+ };
1016
1304
  return this.req("/skills/import", {
1017
1305
  method: "POST",
1018
- body: JSON.stringify(options)
1306
+ body: JSON.stringify(payload)
1019
1307
  });
1020
1308
  }
1021
1309
  /** Preview a skill import (dry run). */
1022
1310
  async preview(options) {
1311
+ const payload = {
1312
+ content: options.content,
1313
+ file_or_path: options.file_or_path ?? options.fileOrPath,
1314
+ location: options.location,
1315
+ namespace: options.namespace,
1316
+ conflict_policy: options.conflict_policy ?? options.conflictPolicy
1317
+ };
1023
1318
  return this.req("/skills/import/preview", {
1024
1319
  method: "POST",
1025
- body: JSON.stringify(options)
1320
+ body: JSON.stringify(payload)
1026
1321
  });
1027
1322
  }
1028
1323
  /** List available skill templates shipped with the engine. */
@@ -1031,11 +1326,220 @@ var Skills = class {
1031
1326
  if (Array.isArray(raw)) return { templates: raw, count: raw.length };
1032
1327
  return raw;
1033
1328
  }
1329
+ /** List enriched skill catalog records. */
1330
+ async catalog() {
1331
+ const raw = await this.req("/skills/catalog");
1332
+ const rows = Array.isArray(raw) ? raw : [];
1333
+ return { skills: rows, count: rows.length };
1334
+ }
1335
+ /** Validate SKILL.md content or a local path/zip. */
1336
+ async validate(options) {
1337
+ const payload = {
1338
+ content: options.content,
1339
+ file_or_path: options.file_or_path ?? options.fileOrPath
1340
+ };
1341
+ return this.req("/skills/validate", {
1342
+ method: "POST",
1343
+ body: JSON.stringify(payload)
1344
+ });
1345
+ }
1346
+ /** Match a user goal to the best skill candidate. */
1347
+ async match(options) {
1348
+ const payload = {
1349
+ goal: options.goal,
1350
+ max_matches: options.max_matches ?? options.maxMatches,
1351
+ threshold: options.threshold
1352
+ };
1353
+ return this.req("/skills/router/match", {
1354
+ method: "POST",
1355
+ body: JSON.stringify(payload)
1356
+ });
1357
+ }
1358
+ /** Evaluate routing against benchmark cases. */
1359
+ async evalBenchmark(options) {
1360
+ const payload = {
1361
+ threshold: options.threshold,
1362
+ cases: options.cases.map((row) => ({
1363
+ prompt: row.prompt,
1364
+ expected_skill: row.expected_skill ?? row.expectedSkill
1365
+ }))
1366
+ };
1367
+ return this.req("/skills/evals/benchmark", {
1368
+ method: "POST",
1369
+ body: JSON.stringify(payload)
1370
+ });
1371
+ }
1372
+ /** Evaluate trigger quality for a single target skill. */
1373
+ async evalTriggers(options) {
1374
+ const payload = {
1375
+ skill_name: options.skill_name ?? options.skillName,
1376
+ prompts: options.prompts,
1377
+ threshold: options.threshold
1378
+ };
1379
+ return this.req("/skills/evals/triggers", {
1380
+ method: "POST",
1381
+ body: JSON.stringify(payload)
1382
+ });
1383
+ }
1384
+ /** Compile a selected or routed skill into an execution summary. */
1385
+ async compile(options) {
1386
+ const payload = {
1387
+ skill_name: options.skill_name ?? options.skillName,
1388
+ goal: options.goal,
1389
+ threshold: options.threshold,
1390
+ max_matches: options.max_matches ?? options.maxMatches,
1391
+ schedule: options.schedule
1392
+ };
1393
+ return this.req("/skills/compile", {
1394
+ method: "POST",
1395
+ body: JSON.stringify(payload)
1396
+ });
1397
+ }
1398
+ /** Generate scaffold skill artifacts from a natural-language prompt. */
1399
+ async generate(options) {
1400
+ return this.req("/skills/generate", {
1401
+ method: "POST",
1402
+ body: JSON.stringify(options)
1403
+ });
1404
+ }
1405
+ /** Install generated or custom artifacts into local skills. */
1406
+ async generateInstall(options) {
1407
+ const payload = {
1408
+ prompt: options.prompt,
1409
+ threshold: options.threshold,
1410
+ location: options.location,
1411
+ conflict_policy: options.conflictPolicy,
1412
+ artifacts: options.artifacts ? {
1413
+ "SKILL.md": options.artifacts["SKILL.md"],
1414
+ "workflow.yaml": options.artifacts["workflow.yaml"],
1415
+ "automation.example.yaml": options.artifacts["automation.example.yaml"]
1416
+ } : void 0
1417
+ };
1418
+ return this.req("/skills/generate/install", {
1419
+ method: "POST",
1420
+ body: JSON.stringify(payload)
1421
+ });
1422
+ }
1034
1423
  };
1035
- var Resources = class {
1424
+ var Packs = class {
1425
+ constructor(req) {
1426
+ this.req = req;
1427
+ }
1428
+ /** List installed tandem packs. */
1429
+ async list() {
1430
+ return this.req("/packs");
1431
+ }
1432
+ /** Inspect an installed pack by `pack_id` or `name`. */
1433
+ async inspect(selector) {
1434
+ return this.req(`/packs/${encodeURIComponent(selector)}`);
1435
+ }
1436
+ /** Install a pack from local path or URL. */
1437
+ async install(options) {
1438
+ return this.req("/packs/install", {
1439
+ method: "POST",
1440
+ body: JSON.stringify(options)
1441
+ });
1442
+ }
1443
+ /** Install a pack from a downloaded attachment path. */
1444
+ async installFromAttachment(options) {
1445
+ return this.req("/packs/install_from_attachment", {
1446
+ method: "POST",
1447
+ body: JSON.stringify(options)
1448
+ });
1449
+ }
1450
+ /** Uninstall a pack by `pack_id` or `name` (+ optional version). */
1451
+ async uninstall(options) {
1452
+ return this.req("/packs/uninstall", {
1453
+ method: "POST",
1454
+ body: JSON.stringify(options)
1455
+ });
1456
+ }
1457
+ /** Export an installed pack to zip. */
1458
+ async export(options) {
1459
+ return this.req("/packs/export", {
1460
+ method: "POST",
1461
+ body: JSON.stringify(options)
1462
+ });
1463
+ }
1464
+ /** Detect `tandempack.yaml` marker in zip path. */
1465
+ async detect(options) {
1466
+ return this.req("/packs/detect", {
1467
+ method: "POST",
1468
+ body: JSON.stringify(options)
1469
+ });
1470
+ }
1471
+ /** Check available updates for a pack (stub endpoint in v0.4.0). */
1472
+ async updates(selector) {
1473
+ const raw = await this.req(`/packs/${encodeURIComponent(selector)}/updates`);
1474
+ const asObj = raw || {};
1475
+ const updates = Array.isArray(asObj.updates) ? asObj.updates : [];
1476
+ return {
1477
+ pack_id: asString(asObj.pack_id) ?? void 0,
1478
+ name: asString(asObj.name) ?? void 0,
1479
+ current_version: asString(asObj.current_version) ?? void 0,
1480
+ updates
1481
+ };
1482
+ }
1483
+ /** Apply a pack update (stub endpoint in v0.4.0). */
1484
+ async update(selector, options) {
1485
+ const raw = await this.req(`/packs/${encodeURIComponent(selector)}/update`, {
1486
+ method: "POST",
1487
+ body: JSON.stringify(options ?? {})
1488
+ });
1489
+ return {
1490
+ updated: Boolean(raw.updated),
1491
+ pack_id: asString(raw.pack_id) ?? void 0,
1492
+ name: asString(raw.name) ?? void 0,
1493
+ current_version: asString(raw.current_version) ?? void 0,
1494
+ target_version: asString(raw.target_version) ?? void 0,
1495
+ reason: asString(raw.reason) ?? void 0
1496
+ };
1497
+ }
1498
+ };
1499
+ var Capabilities = class {
1036
1500
  constructor(req) {
1037
1501
  this.req = req;
1038
1502
  }
1503
+ /** Get current capability bindings file. */
1504
+ async getBindings() {
1505
+ const raw = await this.req("/capabilities/bindings");
1506
+ return raw.bindings;
1507
+ }
1508
+ /** Replace capability bindings file. */
1509
+ async setBindings(bindings) {
1510
+ return this.req("/capabilities/bindings", {
1511
+ method: "PUT",
1512
+ body: JSON.stringify(bindings)
1513
+ });
1514
+ }
1515
+ /** Discover provider tools available for resolution. */
1516
+ async discovery() {
1517
+ return this.req("/capabilities/discovery");
1518
+ }
1519
+ /**
1520
+ * Resolve capability IDs to provider tools.
1521
+ * Returns resolver payload on success; throws on HTTP errors (including 409 missing capability).
1522
+ */
1523
+ async resolve(input) {
1524
+ return this.req("/capabilities/resolve", {
1525
+ method: "POST",
1526
+ body: JSON.stringify(input)
1527
+ });
1528
+ }
1529
+ /** Evaluate runtime readiness for required capabilities and return blocking issues. */
1530
+ async readiness(input) {
1531
+ return this.req("/capabilities/readiness", {
1532
+ method: "POST",
1533
+ body: JSON.stringify(input)
1534
+ });
1535
+ }
1536
+ };
1537
+ var Resources = class {
1538
+ constructor(baseUrl, getToken, req) {
1539
+ this.baseUrl = baseUrl;
1540
+ this.getToken = getToken;
1541
+ this.req = req;
1542
+ }
1039
1543
  /** List stored resource records. */
1040
1544
  async list(options) {
1041
1545
  const params = new URLSearchParams();
@@ -1062,6 +1566,24 @@ var Resources = class {
1062
1566
  body: JSON.stringify(options)
1063
1567
  });
1064
1568
  }
1569
+ async get(key) {
1570
+ const raw = await this.req(`/resource/${encodeURIComponent(key)}`);
1571
+ return parseResponse(ResourceRecordSchema, raw, `/resource/${key}`, 200);
1572
+ }
1573
+ async putKey(key, value, options) {
1574
+ const raw = await this.req(`/resource/${encodeURIComponent(key)}`, {
1575
+ method: "PUT",
1576
+ body: JSON.stringify({ value, ...options ?? {} })
1577
+ });
1578
+ return parseResponse(ResourceWriteResponseSchema, raw, `/resource/${key}`, 200);
1579
+ }
1580
+ async patchKey(key, patch) {
1581
+ const raw = await this.req(`/resource/${encodeURIComponent(key)}`, {
1582
+ method: "PATCH",
1583
+ body: JSON.stringify(patch)
1584
+ });
1585
+ return parseResponse(ResourceWriteResponseSchema, raw, `/resource/${key}`, 200);
1586
+ }
1065
1587
  /** Delete a resource entry. */
1066
1588
  async delete(key, options) {
1067
1589
  return this.req("/resource", {
@@ -1069,11 +1591,247 @@ var Resources = class {
1069
1591
  body: JSON.stringify({ key, ...options })
1070
1592
  });
1071
1593
  }
1594
+ async deleteKey(key) {
1595
+ return this.req(`/resource/${encodeURIComponent(key)}`, {
1596
+ method: "DELETE"
1597
+ });
1598
+ }
1599
+ events(options) {
1600
+ const params = new URLSearchParams();
1601
+ if (options?.sinceSeq !== void 0) params.set("since_seq", String(options.sinceSeq));
1602
+ if (options?.tail !== void 0) params.set("tail", String(options.tail));
1603
+ const qs = params.toString() ? `?${params.toString()}` : "";
1604
+ return streamSse(`${this.baseUrl}/resource/events${qs}`, this.getToken());
1605
+ }
1072
1606
  };
1073
- var Routines = class {
1607
+ var Coder = class {
1074
1608
  constructor(req) {
1075
1609
  this.req = req;
1076
1610
  }
1611
+ /** Create a coder workflow run. */
1612
+ async createRun(payload) {
1613
+ return this.req("/coder/runs", {
1614
+ method: "POST",
1615
+ body: JSON.stringify(payload)
1616
+ });
1617
+ }
1618
+ /** List coder runs with optional filters. */
1619
+ async listRuns(options) {
1620
+ const params = new URLSearchParams();
1621
+ if (options?.limit !== void 0) params.set("limit", String(options.limit));
1622
+ const workflowMode = options?.workflow_mode ?? options?.workflowMode;
1623
+ const repoSlug = options?.repo_slug ?? options?.repoSlug;
1624
+ if (workflowMode) params.set("workflow_mode", workflowMode);
1625
+ if (repoSlug) params.set("repo_slug", repoSlug);
1626
+ const qs = params.toString() ? `?${params.toString()}` : "";
1627
+ const raw = await this.req(`/coder/runs${qs}`);
1628
+ const asObj = raw ?? {};
1629
+ const runs = Array.isArray(asObj.runs) ? asObj.runs : [];
1630
+ return {
1631
+ runs,
1632
+ count: typeof asObj.count === "number" ? asObj.count : runs.length
1633
+ };
1634
+ }
1635
+ /** Get a single coder run plus linked context run details. */
1636
+ async getRun(runId) {
1637
+ const raw = await this.req(`/coder/runs/${encodeURIComponent(runId)}`);
1638
+ const asObj = raw ?? {};
1639
+ return {
1640
+ ...asObj,
1641
+ coderRun: asObj.coder_run ?? void 0,
1642
+ coder_run: asObj.coder_run ?? void 0,
1643
+ run: asObj.run ?? void 0
1644
+ };
1645
+ }
1646
+ /** Execute the next runnable task in a coder workflow. */
1647
+ async executeNext(runId, payload) {
1648
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/execute-next`, {
1649
+ method: "POST",
1650
+ body: JSON.stringify(payload ?? {})
1651
+ });
1652
+ }
1653
+ /** Continue executing runnable tasks until the run stops or completes. */
1654
+ async executeAll(runId, payload) {
1655
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/execute-all`, {
1656
+ method: "POST",
1657
+ body: JSON.stringify(payload ?? {})
1658
+ });
1659
+ }
1660
+ /** Spawn a follow-on coder workflow from an existing run. */
1661
+ async createFollowOnRun(runId, payload) {
1662
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/follow-on-run`, {
1663
+ method: "POST",
1664
+ body: JSON.stringify(payload)
1665
+ });
1666
+ }
1667
+ /** Approve a coder run that is waiting on human review. */
1668
+ async approveRun(runId, reason) {
1669
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/approve`, {
1670
+ method: "POST",
1671
+ body: JSON.stringify({ reason })
1672
+ });
1673
+ }
1674
+ /** Cancel a coder run. */
1675
+ async cancelRun(runId, reason) {
1676
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/cancel`, {
1677
+ method: "POST",
1678
+ body: JSON.stringify({ reason })
1679
+ });
1680
+ }
1681
+ /** List artifacts emitted by a coder run. */
1682
+ async listArtifacts(runId) {
1683
+ const raw = await this.req(`/coder/runs/${encodeURIComponent(runId)}/artifacts`);
1684
+ const asObj = raw ?? {};
1685
+ const artifacts = Array.isArray(asObj.artifacts) ? asObj.artifacts : [];
1686
+ return {
1687
+ ...asObj,
1688
+ artifacts,
1689
+ count: typeof asObj.count === "number" ? asObj.count : artifacts.length
1690
+ };
1691
+ }
1692
+ /** Inspect ranked memory hits for a coder run. */
1693
+ async getMemoryHits(runId, options) {
1694
+ const params = new URLSearchParams();
1695
+ if (options?.query) params.set("q", options.query);
1696
+ if (options?.limit !== void 0) params.set("limit", String(options.limit));
1697
+ const qs = params.toString() ? `?${params.toString()}` : "";
1698
+ const raw = await this.req(
1699
+ `/coder/runs/${encodeURIComponent(runId)}/memory-hits${qs}`
1700
+ );
1701
+ const asObj = raw ?? {};
1702
+ const hits = Array.isArray(asObj.hits) ? asObj.hits : [];
1703
+ return {
1704
+ ...asObj,
1705
+ hits,
1706
+ count: typeof asObj.count === "number" ? asObj.count : hits.length
1707
+ };
1708
+ }
1709
+ /** Create a triage inspection report artifact. */
1710
+ async createTriageInspectionReport(runId, payload) {
1711
+ return this.req(
1712
+ `/coder/runs/${encodeURIComponent(runId)}/triage-inspection-report`,
1713
+ {
1714
+ method: "POST",
1715
+ body: JSON.stringify(payload)
1716
+ }
1717
+ );
1718
+ }
1719
+ /** Create a triage reproduction report artifact. */
1720
+ async createTriageReproductionReport(runId, payload) {
1721
+ return this.req(
1722
+ `/coder/runs/${encodeURIComponent(runId)}/triage-reproduction-report`,
1723
+ {
1724
+ method: "POST",
1725
+ body: JSON.stringify(payload)
1726
+ }
1727
+ );
1728
+ }
1729
+ /** Create a triage summary artifact. */
1730
+ async createTriageSummary(runId, payload) {
1731
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/triage-summary`, {
1732
+ method: "POST",
1733
+ body: JSON.stringify(payload)
1734
+ });
1735
+ }
1736
+ /** Create PR review evidence for a coder run. */
1737
+ async createPrReviewEvidence(runId, payload) {
1738
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/pr-review-evidence`, {
1739
+ method: "POST",
1740
+ body: JSON.stringify(payload)
1741
+ });
1742
+ }
1743
+ /** Create a PR review summary artifact. */
1744
+ async createPrReviewSummary(runId, payload) {
1745
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/pr-review-summary`, {
1746
+ method: "POST",
1747
+ body: JSON.stringify(payload)
1748
+ });
1749
+ }
1750
+ /** Create an issue-fix validation report artifact. */
1751
+ async createIssueFixValidationReport(runId, payload) {
1752
+ return this.req(
1753
+ `/coder/runs/${encodeURIComponent(runId)}/issue-fix-validation-report`,
1754
+ {
1755
+ method: "POST",
1756
+ body: JSON.stringify(payload)
1757
+ }
1758
+ );
1759
+ }
1760
+ /** Create an issue-fix summary artifact. */
1761
+ async createIssueFixSummary(runId, payload) {
1762
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/issue-fix-summary`, {
1763
+ method: "POST",
1764
+ body: JSON.stringify(payload)
1765
+ });
1766
+ }
1767
+ /** Draft a pull request for an issue-fix coder run. */
1768
+ async createPrDraft(runId, payload) {
1769
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/pr-draft`, {
1770
+ method: "POST",
1771
+ body: JSON.stringify(payload ?? {})
1772
+ });
1773
+ }
1774
+ /** Submit a pull request for an issue-fix coder run. */
1775
+ async submitPr(runId, payload) {
1776
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/pr-submit`, {
1777
+ method: "POST",
1778
+ body: JSON.stringify(payload ?? {})
1779
+ });
1780
+ }
1781
+ /** Create a merge readiness report artifact. */
1782
+ async createMergeReadinessReport(runId, payload) {
1783
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/merge-readiness-report`, {
1784
+ method: "POST",
1785
+ body: JSON.stringify(payload)
1786
+ });
1787
+ }
1788
+ /** Create a merge recommendation summary artifact. */
1789
+ async createMergeRecommendationSummary(runId, payload) {
1790
+ return this.req(
1791
+ `/coder/runs/${encodeURIComponent(runId)}/merge-recommendation-summary`,
1792
+ {
1793
+ method: "POST",
1794
+ body: JSON.stringify(payload)
1795
+ }
1796
+ );
1797
+ }
1798
+ /** List pending or emitted memory candidates for a coder run. */
1799
+ async listMemoryCandidates(runId) {
1800
+ const raw = await this.req(
1801
+ `/coder/runs/${encodeURIComponent(runId)}/memory-candidates`
1802
+ );
1803
+ const asObj = raw ?? {};
1804
+ const candidates = Array.isArray(asObj.candidates) ? asObj.candidates : [];
1805
+ return {
1806
+ ...asObj,
1807
+ candidates,
1808
+ count: typeof asObj.count === "number" ? asObj.count : candidates.length
1809
+ };
1810
+ }
1811
+ /** Persist a memory candidate generated by a coder workflow. */
1812
+ async createMemoryCandidate(runId, payload) {
1813
+ return this.req(`/coder/runs/${encodeURIComponent(runId)}/memory-candidates`, {
1814
+ method: "POST",
1815
+ body: JSON.stringify(payload)
1816
+ });
1817
+ }
1818
+ /** Promote a reviewed memory candidate into governed memory. */
1819
+ async promoteMemoryCandidate(runId, candidateId, payload) {
1820
+ return this.req(
1821
+ `/coder/runs/${encodeURIComponent(runId)}/memory-candidates/${encodeURIComponent(candidateId)}/promote`,
1822
+ {
1823
+ method: "POST",
1824
+ body: JSON.stringify(payload ?? {})
1825
+ }
1826
+ );
1827
+ }
1828
+ };
1829
+ var Routines = class {
1830
+ constructor(baseUrl, getToken, req) {
1831
+ this.baseUrl = baseUrl;
1832
+ this.getToken = getToken;
1833
+ this.req = req;
1834
+ }
1077
1835
  /** List all scheduled routines. */
1078
1836
  async list() {
1079
1837
  return this.req("/routines");
@@ -1175,11 +1933,90 @@ var Routines = class {
1175
1933
  if (Array.isArray(raw)) return { history: raw, count: raw.length };
1176
1934
  return raw;
1177
1935
  }
1936
+ events(options) {
1937
+ const params = new URLSearchParams();
1938
+ const routineId = options?.routine_id ?? options?.routineId;
1939
+ if (routineId) params.set("routine_id", routineId);
1940
+ const qs = params.toString() ? `?${params.toString()}` : "";
1941
+ return streamSse(`${this.baseUrl}/routines/events${qs}`, this.getToken(), {
1942
+ signal: options?.signal
1943
+ });
1944
+ }
1945
+ addArtifact(runId, payload) {
1946
+ return this.req(`/routines/runs/${encodeURIComponent(runId)}/artifacts`, {
1947
+ method: "POST",
1948
+ body: JSON.stringify(payload)
1949
+ });
1950
+ }
1178
1951
  };
1179
- var Automations = class {
1952
+ var WorkflowPlans = class {
1180
1953
  constructor(req) {
1181
1954
  this.req = req;
1182
1955
  }
1956
+ async preview(options) {
1957
+ return this.req("/workflow-plans/preview", {
1958
+ method: "POST",
1959
+ body: JSON.stringify({
1960
+ prompt: options.prompt,
1961
+ schedule: options.schedule,
1962
+ plan_source: options.plan_source ?? options.planSource,
1963
+ allowed_mcp_servers: options.allowed_mcp_servers ?? options.allowedMcpServers,
1964
+ workspace_root: options.workspace_root ?? options.workspaceRoot,
1965
+ operator_preferences: options.operator_preferences ?? options.operatorPreferences
1966
+ })
1967
+ });
1968
+ }
1969
+ async apply(options) {
1970
+ return this.req("/workflow-plans/apply", {
1971
+ method: "POST",
1972
+ body: JSON.stringify({
1973
+ plan_id: options.plan_id ?? options.planId,
1974
+ plan: options.plan,
1975
+ creator_id: options.creator_id ?? options.creatorId,
1976
+ pack_builder_export: options.pack_builder_export ?? options.packBuilderExport
1977
+ })
1978
+ });
1979
+ }
1980
+ async chatStart(options) {
1981
+ return this.req("/workflow-plans/chat/start", {
1982
+ method: "POST",
1983
+ body: JSON.stringify({
1984
+ prompt: options.prompt,
1985
+ schedule: options.schedule,
1986
+ plan_source: options.plan_source ?? options.planSource,
1987
+ allowed_mcp_servers: options.allowed_mcp_servers ?? options.allowedMcpServers,
1988
+ workspace_root: options.workspace_root ?? options.workspaceRoot,
1989
+ operator_preferences: options.operator_preferences ?? options.operatorPreferences
1990
+ })
1991
+ });
1992
+ }
1993
+ async get(planId) {
1994
+ return this.req(`/workflow-plans/${encodeURIComponent(planId)}`);
1995
+ }
1996
+ async chatMessage(options) {
1997
+ return this.req("/workflow-plans/chat/message", {
1998
+ method: "POST",
1999
+ body: JSON.stringify({
2000
+ plan_id: options.plan_id ?? options.planId,
2001
+ message: options.message
2002
+ })
2003
+ });
2004
+ }
2005
+ async chatReset(options) {
2006
+ return this.req("/workflow-plans/chat/reset", {
2007
+ method: "POST",
2008
+ body: JSON.stringify({
2009
+ plan_id: options.plan_id ?? options.planId
2010
+ })
2011
+ });
2012
+ }
2013
+ };
2014
+ var Automations = class {
2015
+ constructor(baseUrl, getToken, req) {
2016
+ this.baseUrl = baseUrl;
2017
+ this.getToken = getToken;
2018
+ this.req = req;
2019
+ }
1183
2020
  /** List all automations. */
1184
2021
  async list() {
1185
2022
  return this.req("/automations");
@@ -1286,9 +2123,28 @@ var Automations = class {
1286
2123
  if (Array.isArray(raw)) return { history: raw, count: raw.length };
1287
2124
  return raw;
1288
2125
  }
2126
+ events(options) {
2127
+ const params = new URLSearchParams();
2128
+ const automationId = options?.automation_id ?? options?.automationId;
2129
+ const runId = options?.run_id ?? options?.runId;
2130
+ if (automationId) params.set("automation_id", automationId);
2131
+ if (runId) params.set("run_id", runId);
2132
+ const qs = params.toString() ? `?${params.toString()}` : "";
2133
+ return streamSse(`${this.baseUrl}/automations/events${qs}`, this.getToken(), {
2134
+ signal: options?.signal
2135
+ });
2136
+ }
2137
+ addArtifact(runId, payload) {
2138
+ return this.req(`/automations/runs/${encodeURIComponent(runId)}/artifacts`, {
2139
+ method: "POST",
2140
+ body: JSON.stringify(payload)
2141
+ });
2142
+ }
1289
2143
  };
1290
2144
  var AutomationsV2 = class {
1291
- constructor(req) {
2145
+ constructor(baseUrl, getToken, req) {
2146
+ this.baseUrl = baseUrl;
2147
+ this.getToken = getToken;
1292
2148
  this.req = req;
1293
2149
  }
1294
2150
  async create(spec) {
@@ -1361,6 +2217,17 @@ var AutomationsV2 = class {
1361
2217
  { method: "POST", body: JSON.stringify({ reason: reason ?? "" }) }
1362
2218
  );
1363
2219
  }
2220
+ events(options) {
2221
+ const params = new URLSearchParams();
2222
+ const automationId = options?.automation_id ?? options?.automationId;
2223
+ const runId = options?.run_id ?? options?.runId;
2224
+ if (automationId) params.set("automation_id", automationId);
2225
+ if (runId) params.set("run_id", runId);
2226
+ const qs = params.toString() ? `?${params.toString()}` : "";
2227
+ return streamSse(`${this.baseUrl}/automations/v2/events${qs}`, this.getToken(), {
2228
+ signal: options?.signal
2229
+ });
2230
+ }
1364
2231
  };
1365
2232
  var AgentTeams = class {
1366
2233
  constructor(req) {