@idapt/browser-app-sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -345,15 +345,6 @@ async function moveFile(ctx, id, parentId, opts = {}) {
345
345
  });
346
346
  return res.data;
347
347
  }
348
- async function runFile(ctx, id, input = {}, opts = {}) {
349
- const res = await request(ctx, {
350
- method: "POST",
351
- path: `/api/v1/drive/files/${id}/run`,
352
- body: input,
353
- signal: opts.signal
354
- });
355
- return res.data;
356
- }
357
348
 
358
349
  // ../sdk/src/api/agents.ts
359
350
  var AgentsApi = class {
@@ -519,151 +510,26 @@ var AudioApi = class {
519
510
  constructor(ctx) {
520
511
  this.ctx = ctx;
521
512
  }
522
- /** Text-to-speech. Responds HTTP 201 with the written file ref under `data`. */
523
- async speak(input, opts = {}) {
513
+ /** List the available TTS / transcription models. */
514
+ async listModels(opts = {}) {
524
515
  const res = await request(this.ctx, {
525
- method: "POST",
526
- path: "/api/v1/audio/speech",
527
- body: input,
516
+ method: "GET",
517
+ path: "/api/v1/audio/models",
528
518
  signal: opts.signal
529
519
  });
530
520
  return res.data;
531
521
  }
532
- async transcribe(input, opts = {}) {
533
- const form = new FormData();
534
- const filename = input.filename ?? (input.file instanceof File ? input.file.name : "audio");
535
- form.set("file", input.file, filename);
536
- if (input.model) form.set("model", input.model);
537
- if (input.language) form.set("language", input.language);
522
+ /** List the TTS voice catalog (filter by language / gender). */
523
+ async listVoices(input = {}, opts = {}) {
538
524
  const res = await request(this.ctx, {
539
- method: "POST",
540
- path: "/api/v1/audio/transcriptions",
541
- bodyRaw: form,
525
+ method: "GET",
526
+ path: "/api/v1/audio/voices",
527
+ query: input,
542
528
  signal: opts.signal
543
529
  });
544
530
  return res.data;
545
531
  }
546
- async *streamSpeech(input, opts = {}) {
547
- const res = await requestRaw(this.ctx, {
548
- method: "POST",
549
- path: "/api/v1/audio/speech/stream",
550
- body: input,
551
- signal: opts.signal,
552
- expectJson: false
553
- });
554
- yield* parseSpeechStream(res, opts.signal);
555
- }
556
- async *streamTranscribe(input, opts = {}) {
557
- const form = new FormData();
558
- const filename = input.filename ?? (input.file instanceof File ? input.file.name : "audio");
559
- form.set("file", input.file, filename);
560
- if (input.model) form.set("model", input.model);
561
- if (input.language) form.set("language", input.language);
562
- const res = await requestRaw(this.ctx, {
563
- method: "POST",
564
- path: "/api/v1/audio/transcriptions/stream",
565
- bodyRaw: form,
566
- signal: opts.signal,
567
- expectJson: false
568
- });
569
- yield* parseTranscriptionStream(res, opts.signal);
570
- }
571
532
  };
572
- async function* parseSpeechStream(response, signal) {
573
- for await (const frame of parseSse(response, signal)) {
574
- const payload = safeJson(frame.data);
575
- if (frame.event === "chunk") {
576
- const audio = payload?.audio;
577
- if (typeof audio === "string") yield { type: "chunk", audio };
578
- } else if (frame.event === "done") {
579
- const event = { type: "done" };
580
- const totalBytes = numberOrUndefined(payload?.totalBytes);
581
- const durationMs = numberOrUndefined(payload?.durationMs);
582
- const charCount = numberOrUndefined(payload?.charCount);
583
- if (totalBytes !== void 0) event.total_bytes = totalBytes;
584
- if (durationMs !== void 0) event.duration_ms = durationMs;
585
- if (charCount !== void 0) event.char_count = charCount;
586
- if (typeof payload?.cached === "boolean") event.cached = payload.cached;
587
- yield event;
588
- } else if (frame.event === "error") {
589
- yield errorEvent(payload);
590
- }
591
- }
592
- }
593
- async function* parseTranscriptionStream(response, signal) {
594
- for await (const frame of parseSse(response, signal)) {
595
- const payload = safeJson(frame.data);
596
- if (frame.event === "partial") {
597
- const text = payload?.text;
598
- if (typeof text === "string") yield { type: "partial", text };
599
- } else if (frame.event === "final") {
600
- const text = payload?.text;
601
- if (typeof text === "string") yield { type: "final", text };
602
- } else if (frame.event === "error") {
603
- yield errorEvent(payload);
604
- }
605
- }
606
- }
607
- async function* parseSse(response, signal) {
608
- if (!response.body) return;
609
- const reader = response.body.getReader();
610
- const decoder = new TextDecoder();
611
- let buffer = "";
612
- try {
613
- while (true) {
614
- if (signal?.aborted) return;
615
- const { done, value } = await reader.read();
616
- if (done) break;
617
- buffer += decoder.decode(value, { stream: true }).replace(/\r\n/g, "\n");
618
- while (true) {
619
- const boundary = buffer.indexOf("\n\n");
620
- if (boundary === -1) break;
621
- const block = buffer.slice(0, boundary);
622
- buffer = buffer.slice(boundary + 2);
623
- const parsed = parseSseBlock(block);
624
- if (parsed) yield parsed;
625
- }
626
- }
627
- } finally {
628
- try {
629
- reader.releaseLock();
630
- } catch {
631
- }
632
- }
633
- }
634
- function parseSseBlock(block) {
635
- let event = "message";
636
- let data = "";
637
- for (const line of block.split("\n")) {
638
- if (!line) continue;
639
- if (line.startsWith("event: ")) event = line.slice(7).trim();
640
- else if (line.startsWith("event:")) event = line.slice(6).trim();
641
- else if (line.startsWith("data: ")) data += line.slice(6);
642
- else if (line.startsWith("data:")) data += line.slice(5);
643
- }
644
- if (!data && event === "message") return null;
645
- return { event, data };
646
- }
647
- function safeJson(raw) {
648
- try {
649
- return JSON.parse(raw);
650
- } catch {
651
- return null;
652
- }
653
- }
654
- function numberOrUndefined(value) {
655
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
656
- }
657
- function errorEvent(payload) {
658
- const event = {
659
- type: "error"
660
- };
661
- const status = numberOrUndefined(payload?.status);
662
- const retryAfter = numberOrUndefined(payload?.retryAfter);
663
- if (status !== void 0) event.status = status;
664
- if (retryAfter !== void 0) event.retry_after = retryAfter;
665
- return event;
666
- }
667
533
 
668
534
  // ../sdk/src/api/automations.ts
669
535
  var AutomationsApi = class {
@@ -685,10 +551,9 @@ var AutomationsApi = class {
685
551
  /**
686
552
  * Create an automation. `workspace_id` is passed in the request BODY
687
553
  * alongside the flat automation definition — it is not a query param. The request
688
- * body is flat: every scheduling field (`cron_expression`, …) and every
689
- * action field (`agent_id`, `prompt_template`, `function_id`, …) sits at the
690
- * top level — there are no nested `trigger_config` / `action_config`
691
- * objects any more.
554
+ * body is flat: every scheduling field (`cron_expression`, …) and agent-run
555
+ * action field (`agent_id`, `prompt_template`, …) sits at the top level —
556
+ * there are no nested `trigger_config` / `action_config` objects.
692
557
  *
693
558
  * For a webhook automation the response additionally carries a one-time
694
559
  * plaintext `secret` (use `AutomationWithSecret`); other automation types
@@ -809,108 +674,6 @@ var AutomationsApi = class {
809
674
  return res.data.by_id;
810
675
  }
811
676
  };
812
-
813
- // ../sdk/src/api/blobs.ts
814
- var enc = encodeURIComponent;
815
- var BlobsApi = class {
816
- constructor(ctx) {
817
- this.ctx = ctx;
818
- }
819
- /** List objects in a namespace (prefix-filterable). */
820
- async list(namespace, opts = {}) {
821
- const q = new URLSearchParams();
822
- if (opts.prefix) q.set("prefix", opts.prefix);
823
- if (opts.cursor) q.set("cursor", opts.cursor);
824
- if (opts.limit) q.set("limit", String(opts.limit));
825
- const qs = q.toString() ? `?${q.toString()}` : "";
826
- const res = await request(this.ctx, {
827
- method: "GET",
828
- path: `/api/v1/blobs/${enc(namespace)}${qs}`,
829
- signal: opts.signal
830
- });
831
- return res.data;
832
- }
833
- /**
834
- * Upload (upsert) an object's bytes. Returns its metadata.
835
- *
836
- * Sent as `multipart/form-data` (the bytes ride a `file` part, with an
837
- * optional `content_type` field) — the same upload convention as
838
- * `client.files.upload`, so it flows through the one multipart transport and
839
- * is reachable identically via `client.call("blobs put", …)`. The SDK leaves
840
- * `Content-Type` unset so the runtime picks the multipart boundary.
841
- */
842
- async put(namespace, key, content, contentType, opts = {}) {
843
- const ct = contentType ?? (content instanceof Blob && content.type ? content.type : "application/octet-stream");
844
- const blob = content instanceof Blob ? content : new Blob([content], { type: ct });
845
- const form = new FormData();
846
- form.set("file", blob, key);
847
- form.set("content_type", ct);
848
- const res = await request(this.ctx, {
849
- method: "POST",
850
- path: `/api/v1/blobs/${enc(namespace)}/${enc(key)}`,
851
- // No explicit Content-Type — the runtime sets the multipart boundary.
852
- bodyRaw: form,
853
- signal: opts.signal
854
- });
855
- return res.data;
856
- }
857
- /**
858
- * Download an object's raw bytes (preserving its stored Content-Type).
859
- *
860
- * `GET /blobs/:ns/:key` returns JSON metadata + a signed URL by default (the
861
- * agent/CLI form); `?download=true` is the raw-bytes escape hatch this facade
862
- * uses. For the JSON reference instead, call `client.call("blobs get", …)`.
863
- */
864
- async get(namespace, key, opts = {}) {
865
- const res = await requestRaw(this.ctx, {
866
- method: "GET",
867
- path: `/api/v1/blobs/${enc(namespace)}/${enc(key)}?download=true`,
868
- signal: opts.signal,
869
- expectJson: false
870
- });
871
- const blob = await res.blob();
872
- return {
873
- blob,
874
- contentType: res.headers.get("content-type") ?? "application/octet-stream"
875
- };
876
- }
877
- /** Read an object's metadata (no bytes). */
878
- async head(namespace, key, opts = {}) {
879
- const res = await request(this.ctx, {
880
- method: "GET",
881
- path: `/api/v1/blobs/${enc(namespace)}/${enc(key)}/meta`,
882
- signal: opts.signal
883
- });
884
- return res.data;
885
- }
886
- /** Delete an object (idempotent). */
887
- async delete(namespace, key, opts = {}) {
888
- return request(this.ctx, {
889
- method: "DELETE",
890
- path: `/api/v1/blobs/${enc(namespace)}/${enc(key)}`,
891
- signal: opts.signal
892
- });
893
- }
894
- /** Mint a time-limited direct-download URL for an object. */
895
- async createSignedUrl(namespace, key, expiresIn, opts = {}) {
896
- const res = await request(this.ctx, {
897
- method: "POST",
898
- path: `/api/v1/blobs/${enc(namespace)}/${enc(key)}/signed-url`,
899
- body: { expires_in: expiresIn },
900
- signal: opts.signal
901
- });
902
- return res.data;
903
- }
904
- /** List the blob namespaces in the workspace. */
905
- async listNamespaces(opts = {}) {
906
- const res = await request(this.ctx, {
907
- method: "GET",
908
- path: "/api/v1/blobs",
909
- signal: opts.signal
910
- });
911
- return res.data.map((n) => n.namespace);
912
- }
913
- };
914
677
  function bindPath(binding, args) {
915
678
  let path = binding.path;
916
679
  const rest = { ...args };
@@ -960,7 +723,7 @@ function buildRequest(binding, path, rest, signal) {
960
723
  return base;
961
724
  }
962
725
  }
963
- async function* parseSse2(response, signal) {
726
+ async function* parseSse(response, signal) {
964
727
  if (!response.body) return;
965
728
  const reader = response.body.getReader();
966
729
  const decoder = new TextDecoder();
@@ -976,7 +739,7 @@ async function* parseSse2(response, signal) {
976
739
  if (boundary === -1) break;
977
740
  const block = buffer.slice(0, boundary);
978
741
  buffer = buffer.slice(boundary + 2);
979
- const frame = parseSseBlock2(block);
742
+ const frame = parseSseBlock(block);
980
743
  if (frame) yield frame;
981
744
  }
982
745
  }
@@ -987,7 +750,7 @@ async function* parseSse2(response, signal) {
987
750
  }
988
751
  }
989
752
  }
990
- function parseSseBlock2(block) {
753
+ function parseSseBlock(block) {
991
754
  let event = "message";
992
755
  let data = "";
993
756
  for (const line of block.split("\n")) {
@@ -1011,7 +774,7 @@ async function executeCommand(binding, args = {}, ctx, opts = {}) {
1011
774
  {
1012
775
  if (isSseBinding(binding) && !opts.bufferBinary) {
1013
776
  const res = await requestRaw(ctx, { ...req, expectJson: false });
1014
- return parseSse2(res, opts.signal);
777
+ return parseSse(res, opts.signal);
1015
778
  }
1016
779
  return await request(ctx, { ...req, expectBlob: true });
1017
780
  }
@@ -1385,7 +1148,7 @@ var ComputersApi = class {
1385
1148
  return res.data;
1386
1149
  }
1387
1150
  // ---------------------------------------------------------------------------
1388
- // Exec & tmux
1151
+ // Exec & terminals
1389
1152
  // ---------------------------------------------------------------------------
1390
1153
  async exec(id, input, opts = {}) {
1391
1154
  const res = await request(this.ctx, {
@@ -1397,56 +1160,57 @@ var ComputersApi = class {
1397
1160
  return res.data;
1398
1161
  }
1399
1162
  /**
1400
- * tmux dispatcher. Each `op` returns a different shape — see the route
1401
- * docs for the per-op payload. Common case: `op: "run"` starts a window,
1163
+ * Persistent-terminal dispatcher. Each `op` returns a different shape — see
1164
+ * the route docs for the per-op payload. Common case: `op: "run"` runs a
1165
+ * command to completion in a named window (state persists across runs),
1402
1166
  * `op: "capture"` reads its output.
1403
1167
  */
1404
- async tmux(id, input, opts = {}) {
1168
+ async terminal(id, input, opts = {}) {
1405
1169
  const res = await request(
1406
1170
  this.ctx,
1407
1171
  {
1408
1172
  method: "POST",
1409
- path: `/api/v1/computers/${id}/tmux`,
1173
+ path: `/api/v1/computers/${id}/terminal`,
1410
1174
  body: input,
1411
1175
  signal: opts.signal
1412
1176
  }
1413
1177
  );
1414
1178
  return res.data;
1415
1179
  }
1416
- /** Convenience over `tmux({ op: "list" })`. */
1417
- async listTmuxWindows(id, opts = {}) {
1418
- const result = await this.tmux(id, { op: "list" }, opts);
1180
+ /** Convenience over `terminal({ op: "list" })`. */
1181
+ async listTerminals(id, opts = {}) {
1182
+ const result = await this.terminal(id, { op: "list" }, opts);
1419
1183
  return result.windows ?? [];
1420
1184
  }
1421
1185
  // ---------------------------------------------------------------------------
1422
- // SFTP
1186
+ // FS
1423
1187
  // ---------------------------------------------------------------------------
1424
1188
  /**
1425
- * Unified SFTP dispatcher. Returns op-shaped payload. For streaming
1426
- * uploads/downloads use `sftpUpload` / `sftpDownload`.
1189
+ * Unified FS dispatcher. Returns op-shaped payload. For streaming
1190
+ * uploads/downloads use `fsUpload` / `fsDownload`.
1427
1191
  */
1428
- async sftp(id, input, opts = {}) {
1192
+ async fs(id, input, opts = {}) {
1429
1193
  const res = await request(
1430
1194
  this.ctx,
1431
1195
  {
1432
1196
  method: "POST",
1433
- path: `/api/v1/computers/${id}/sftp`,
1197
+ path: `/api/v1/computers/${id}/fs`,
1434
1198
  body: input,
1435
1199
  signal: opts.signal
1436
1200
  }
1437
1201
  );
1438
1202
  return res.data;
1439
1203
  }
1440
- /** Convenience: `sftp({op:"list"})` returning the entries array directly. */
1441
- async sftpList(id, path, opts = {}) {
1442
- const result = await this.sftp(id, { op: "list", path }, opts);
1204
+ /** Convenience: `fs({op:"list"})` returning the entries array directly. */
1205
+ async fsList(id, path, opts = {}) {
1206
+ const result = await this.fs(id, { op: "list", path }, opts);
1443
1207
  return result;
1444
1208
  }
1445
1209
  /**
1446
1210
  * Multipart upload of a file/folder member. Falls back to single-file mode
1447
1211
  * when `relative_path` is omitted.
1448
1212
  */
1449
- async sftpUpload(id, input, opts = {}) {
1213
+ async fsUpload(id, input, opts = {}) {
1450
1214
  const form = new FormData();
1451
1215
  form.append("file", input.file);
1452
1216
  form.append("path", input.path);
@@ -1456,7 +1220,7 @@ var ComputersApi = class {
1456
1220
  this.ctx,
1457
1221
  {
1458
1222
  method: "POST",
1459
- path: `/api/v1/computers/${id}/sftp/upload`,
1223
+ path: `/api/v1/computers/${id}/fs/upload`,
1460
1224
  bodyRaw: form,
1461
1225
  signal: opts.signal
1462
1226
  }
@@ -1467,10 +1231,10 @@ var ComputersApi = class {
1467
1231
  * Stream a remote file (or a folder as `tar.gz`) as a `Blob`. The server
1468
1232
  * sends the real MIME type on `Content-Type`.
1469
1233
  */
1470
- async sftpDownload(id, remotePath, opts = {}) {
1234
+ async fsDownload(id, remotePath, opts = {}) {
1471
1235
  return request(this.ctx, {
1472
1236
  method: "GET",
1473
- path: `/api/v1/computers/${id}/sftp/download`,
1237
+ path: `/api/v1/computers/${id}/fs/download`,
1474
1238
  query: { path: remotePath },
1475
1239
  expectBlob: true,
1476
1240
  signal: opts.signal
@@ -1738,117 +1502,6 @@ var ComputersApi = class {
1738
1502
  }
1739
1503
  };
1740
1504
 
1741
- // ../sdk/src/api/datastore.ts
1742
- var enc2 = encodeURIComponent;
1743
- var DatastoreApi = class {
1744
- constructor(ctx) {
1745
- this.ctx = ctx;
1746
- }
1747
- /** List keys in a namespace (prefix-filterable). */
1748
- async list(namespace, opts = {}) {
1749
- const q = new URLSearchParams();
1750
- if (opts.prefix) q.set("prefix", opts.prefix);
1751
- if (opts.cursor) q.set("cursor", opts.cursor);
1752
- if (opts.limit) q.set("limit", String(opts.limit));
1753
- const qs = q.toString() ? `?${q.toString()}` : "";
1754
- const res = await request(this.ctx, {
1755
- method: "GET",
1756
- path: `/api/v1/datastore/${enc2(namespace)}${qs}`,
1757
- signal: opts.signal
1758
- });
1759
- return res.data;
1760
- }
1761
- /** Read a KV entry. */
1762
- async get(namespace, key, opts = {}) {
1763
- const res = await request(this.ctx, {
1764
- method: "GET",
1765
- path: `/api/v1/datastore/${enc2(namespace)}/${enc2(key)}`,
1766
- signal: opts.signal
1767
- });
1768
- return res.data;
1769
- }
1770
- /** Upsert a KV entry (optionally with a TTL). */
1771
- async set(namespace, key, value, opts = {}) {
1772
- const res = await request(this.ctx, {
1773
- method: "POST",
1774
- path: `/api/v1/datastore/${enc2(namespace)}/${enc2(key)}`,
1775
- body: { value, ttl_seconds: opts.ttlSeconds },
1776
- signal: opts.signal
1777
- });
1778
- return res.data;
1779
- }
1780
- /** Delete a KV entry (idempotent). */
1781
- async delete(namespace, key, opts = {}) {
1782
- return request(this.ctx, {
1783
- method: "DELETE",
1784
- path: `/api/v1/datastore/${enc2(namespace)}/${enc2(key)}`,
1785
- signal: opts.signal
1786
- });
1787
- }
1788
- /** Atomically add `by` (default 1) to a numeric counter. */
1789
- async increment(namespace, key, by = 1, opts = {}) {
1790
- const res = await request(
1791
- this.ctx,
1792
- {
1793
- method: "POST",
1794
- path: `/api/v1/datastore/${enc2(namespace)}/${enc2(key)}/increment`,
1795
- body: { by },
1796
- signal: opts.signal
1797
- }
1798
- );
1799
- return res.data;
1800
- }
1801
- /** List the namespaces in the workspace. */
1802
- async listNamespaces(opts = {}) {
1803
- const res = await request(this.ctx, {
1804
- method: "GET",
1805
- path: "/api/v1/datastore",
1806
- signal: opts.signal
1807
- });
1808
- return res.data.map((n) => n.namespace);
1809
- }
1810
- /** Read several keys at once. */
1811
- async batchGet(namespace, keys, opts = {}) {
1812
- const res = await request(
1813
- this.ctx,
1814
- {
1815
- method: "POST",
1816
- path: `/api/v1/datastore/${enc2(namespace)}`,
1817
- body: { op: "get", keys },
1818
- signal: opts.signal
1819
- }
1820
- );
1821
- return res.data.entries ?? [];
1822
- }
1823
- /** Upsert several entries at once. */
1824
- async batchSet(namespace, entries, opts = {}) {
1825
- const res = await request(this.ctx, {
1826
- method: "POST",
1827
- path: `/api/v1/datastore/${enc2(namespace)}`,
1828
- body: {
1829
- op: "set",
1830
- entries: entries.map((e) => ({
1831
- key: e.key,
1832
- value: e.value,
1833
- ttl_seconds: e.ttlSeconds
1834
- }))
1835
- },
1836
- signal: opts.signal
1837
- });
1838
- return res.data.count ?? 0;
1839
- }
1840
- /** Delete several keys at once; returns the count removed. */
1841
- async batchDelete(namespace, keys, opts = {}) {
1842
- const res = await request(this.ctx, {
1843
- method: "POST",
1844
- path: `/api/v1/datastore/${enc2(namespace)}`,
1845
- body: { op: "delete", keys },
1846
- signal: opts.signal
1847
- });
1848
- return res.data.count ?? 0;
1849
- }
1850
- };
1851
-
1852
1505
  // ../sdk/src/api/docs.ts
1853
1506
  var DocsApi = class {
1854
1507
  constructor(ctx) {
@@ -1916,7 +1569,7 @@ var FilesApi = class {
1916
1569
  return permanentDeleteFile(this.ctx, id, opts);
1917
1570
  }
1918
1571
  // ---------------------------------------------------------------------------
1919
- // Folder / move / run
1572
+ // Folder / move
1920
1573
  // ---------------------------------------------------------------------------
1921
1574
  /**
1922
1575
  * Idempotent create-or-get a folder. Returns the existing folder (with
@@ -1928,163 +1581,6 @@ var FilesApi = class {
1928
1581
  move(id, parentId, opts = {}) {
1929
1582
  return moveFile(this.ctx, id, parentId, opts);
1930
1583
  }
1931
- /**
1932
- * Execute a code file (js/ts/py/sh) in a sandboxed Lambda. Returns the
1933
- * full `ExecutionRun` record (status, stdout/stderr, exit code, timestamps).
1934
- */
1935
- run(id, input = {}, opts = {}) {
1936
- return runFile(this.ctx, id, input, opts);
1937
- }
1938
- };
1939
-
1940
- // ../sdk/src/api/functions.ts
1941
- var enc3 = encodeURIComponent;
1942
- var FunctionRunsApi = class {
1943
- constructor(ctx) {
1944
- this.ctx = ctx;
1945
- }
1946
- /** List one-off function runs (cursor-paginated). */
1947
- async list(query = {}, opts = {}) {
1948
- const res = await request(this.ctx, {
1949
- method: "GET",
1950
- path: "/api/v1/functions/runs",
1951
- query,
1952
- signal: opts.signal
1953
- });
1954
- return res.data;
1955
- }
1956
- /** Get a single one-off run by id. */
1957
- async get(id, opts = {}) {
1958
- const res = await request(this.ctx, {
1959
- method: "GET",
1960
- path: `/api/v1/functions/runs/${enc3(id)}`,
1961
- signal: opts.signal
1962
- });
1963
- return res.data;
1964
- }
1965
- /**
1966
- * Interrupt a running run. Only computer-backed runs can be interrupted;
1967
- * Lambda-backed runs return 409 (`ConflictError`).
1968
- */
1969
- async interrupt(id, opts = {}) {
1970
- const res = await request(this.ctx, {
1971
- method: "POST",
1972
- path: `/api/v1/functions/runs/${enc3(id)}/interrupt`,
1973
- body: {},
1974
- signal: opts.signal
1975
- });
1976
- return res.data;
1977
- }
1978
- };
1979
- var FunctionsApi = class {
1980
- constructor(ctx) {
1981
- this.ctx = ctx;
1982
- this.runs = new FunctionRunsApi(ctx);
1983
- }
1984
- /**
1985
- * Run a script ONCE in the sandbox. Pass EITHER inline `script` (+ optional
1986
- * `language`) OR an existing Drive `file_id`. Returns the full `FunctionRun`
1987
- * row — `id`, `status`, `stdout`, `stderr`, `exit_code`, the run timestamps,
1988
- * and any `output_files` the script wrote under `/tmp/output/`.
1989
- */
1990
- async run(input, opts = {}) {
1991
- const res = await request(this.ctx, {
1992
- method: "POST",
1993
- path: "/api/v1/functions/runs",
1994
- body: input,
1995
- signal: opts.signal
1996
- });
1997
- return res.data;
1998
- }
1999
- /** List deployed functions in the workspace. */
2000
- async list(query = {}, opts = {}) {
2001
- const res = await request(this.ctx, {
2002
- method: "GET",
2003
- path: "/api/v1/functions",
2004
- query,
2005
- signal: opts.signal
2006
- });
2007
- return res.data;
2008
- }
2009
- /** Get a deployed function by its resourceId. */
2010
- async get(id, opts = {}) {
2011
- const res = await request(this.ctx, {
2012
- method: "GET",
2013
- path: `/api/v1/functions/${enc3(id)}`,
2014
- signal: opts.signal
2015
- });
2016
- return res.data;
2017
- }
2018
- /** Create a deployed function (config only — `deploy` adds a bundle). */
2019
- async create(input, opts = {}) {
2020
- const res = await request(this.ctx, {
2021
- method: "POST",
2022
- path: "/api/v1/functions",
2023
- body: input,
2024
- signal: opts.signal
2025
- });
2026
- return res.data;
2027
- }
2028
- /** Update a deployed function's config. */
2029
- async update(id, patch, opts = {}) {
2030
- const res = await request(this.ctx, {
2031
- method: "PATCH",
2032
- path: `/api/v1/functions/${enc3(id)}`,
2033
- body: patch,
2034
- signal: opts.signal
2035
- });
2036
- return res.data;
2037
- }
2038
- /** Delete a deployed function + all its deployments. */
2039
- async delete(id, opts = {}) {
2040
- return request(this.ctx, {
2041
- method: "DELETE",
2042
- path: `/api/v1/functions/${enc3(id)}`,
2043
- signal: opts.signal
2044
- });
2045
- }
2046
- /**
2047
- * Deploy a new bundle (inline base64 files). Promotes the new deployment to
2048
- * live immediately unless `promote: false`. Returns the new deployment.
2049
- */
2050
- async deploy(id, input, opts = {}) {
2051
- const res = await request(this.ctx, {
2052
- method: "POST",
2053
- path: `/api/v1/functions/${enc3(id)}/deploy`,
2054
- body: input,
2055
- signal: opts.signal
2056
- });
2057
- return res.data;
2058
- }
2059
- /** List a function's deployments (newest-first). */
2060
- async deployments(id, opts = {}) {
2061
- const res = await request(this.ctx, {
2062
- method: "GET",
2063
- path: `/api/v1/functions/${enc3(id)}/deployments`,
2064
- signal: opts.signal
2065
- });
2066
- return res.data;
2067
- }
2068
- /** Promote (or roll back to) a deployment — flips the active one. */
2069
- async promote(id, input, opts = {}) {
2070
- const res = await request(this.ctx, {
2071
- method: "POST",
2072
- path: `/api/v1/functions/${enc3(id)}/promote`,
2073
- body: input,
2074
- signal: opts.signal
2075
- });
2076
- return res.data;
2077
- }
2078
- /** Invoke a deployed function synchronously; returns its response. */
2079
- async invoke(id, input = {}, opts = {}) {
2080
- const res = await request(this.ctx, {
2081
- method: "POST",
2082
- path: `/api/v1/functions/${enc3(id)}/invoke`,
2083
- body: input,
2084
- signal: opts.signal
2085
- });
2086
- return res.data;
2087
- }
2088
1584
  };
2089
1585
 
2090
1586
  // ../sdk/src/api/guide.ts
@@ -2111,6 +1607,7 @@ var ImagesApi = class {
2111
1607
  constructor(ctx) {
2112
1608
  this.ctx = ctx;
2113
1609
  }
1610
+ /** List the available image-generation models. */
2114
1611
  async listModels(opts = {}) {
2115
1612
  const res = await request(this.ctx, {
2116
1613
  method: "GET",
@@ -2119,16 +1616,6 @@ var ImagesApi = class {
2119
1616
  });
2120
1617
  return res.data;
2121
1618
  }
2122
- /** Generate an image. Responds HTTP 201 with the written file ref under `data`. */
2123
- async generate(input, opts = {}) {
2124
- const res = await request(this.ctx, {
2125
- method: "POST",
2126
- path: "/api/v1/images/generations",
2127
- body: input,
2128
- signal: opts.signal
2129
- });
2130
- return res.data;
2131
- }
2132
1619
  };
2133
1620
 
2134
1621
  // ../sdk/src/api/models.ts
@@ -2389,7 +1876,7 @@ var ProviderEndpointsApi = class {
2389
1876
  };
2390
1877
 
2391
1878
  // ../sdk/src/api/realtime.ts
2392
- var enc4 = encodeURIComponent;
1879
+ var enc = encodeURIComponent;
2393
1880
  var RECONNECT_MIN_MS = 1e3;
2394
1881
  var RECONNECT_MAX_MS = 3e4;
2395
1882
  var RealtimeApi = class {
@@ -2400,7 +1887,7 @@ var RealtimeApi = class {
2400
1887
  async broadcast(channel, message, opts = {}) {
2401
1888
  const res = await request(this.ctx, {
2402
1889
  method: "POST",
2403
- path: `/api/v1/realtime/${enc4(channel)}/broadcast`,
1890
+ path: `/api/v1/realtime/${enc(channel)}/broadcast`,
2404
1891
  body: { message },
2405
1892
  signal: opts.signal
2406
1893
  });
@@ -2410,7 +1897,7 @@ var RealtimeApi = class {
2410
1897
  async heartbeat(channel, opts = {}) {
2411
1898
  const res = await request(this.ctx, {
2412
1899
  method: "POST",
2413
- path: `/api/v1/realtime/${enc4(channel)}/presence`,
1900
+ path: `/api/v1/realtime/${enc(channel)}/presence`,
2414
1901
  body: { meta: opts.meta, ttl_seconds: opts.ttlSeconds },
2415
1902
  signal: opts.signal
2416
1903
  });
@@ -2420,7 +1907,7 @@ var RealtimeApi = class {
2420
1907
  async presence(channel, opts = {}) {
2421
1908
  const res = await request(this.ctx, {
2422
1909
  method: "GET",
2423
- path: `/api/v1/realtime/${enc4(channel)}/presence`,
1910
+ path: `/api/v1/realtime/${enc(channel)}/presence`,
2424
1911
  signal: opts.signal
2425
1912
  });
2426
1913
  return res.data;
@@ -2514,7 +2001,7 @@ async function* parseSseStream(response, signal) {
2514
2001
  if (boundary === -1) break;
2515
2002
  const block = buffer.slice(0, boundary);
2516
2003
  buffer = buffer.slice(boundary + 2);
2517
- const parsed = parseSseBlock3(block);
2004
+ const parsed = parseSseBlock2(block);
2518
2005
  if (parsed) yield parsed;
2519
2006
  }
2520
2007
  }
@@ -2525,7 +2012,7 @@ async function* parseSseStream(response, signal) {
2525
2012
  }
2526
2013
  }
2527
2014
  }
2528
- function parseSseBlock3(block) {
2015
+ function parseSseBlock2(block) {
2529
2016
  let id;
2530
2017
  let data = "";
2531
2018
  let isHeartbeat = false;
@@ -2775,42 +2262,6 @@ var SharingApi = class {
2775
2262
  }
2776
2263
  };
2777
2264
 
2778
- // ../sdk/src/api/store.ts
2779
- var StoreApi = class {
2780
- constructor(ctx) {
2781
- this.ctx = ctx;
2782
- }
2783
- /**
2784
- * Search the hub. Open envelope — items are heterogeneous (skills carry
2785
- * version/license, agents carry icons/prompts, computer templates carry
2786
- * sizing) so we surface them as `StoreItem` with an open index signature.
2787
- */
2788
- async search(query = {}, opts = {}) {
2789
- const res = await request(this.ctx, {
2790
- method: "GET",
2791
- path: "/api/v1/store/search",
2792
- query,
2793
- signal: opts.signal
2794
- });
2795
- return res.data;
2796
- }
2797
- /**
2798
- * Install a hub item into one of the caller's workspaces. Returns whatever
2799
- * the per-template installer produces (folder ids, agent ids, ...) —
2800
- * `StoreInstallResult` carries the common fields and leaves the rest
2801
- * open.
2802
- */
2803
- async install(resourceId, input, opts = {}) {
2804
- const res = await request(this.ctx, {
2805
- method: "POST",
2806
- path: `/api/v1/store/${resourceId}/install`,
2807
- body: input,
2808
- signal: opts.signal
2809
- });
2810
- return res.data;
2811
- }
2812
- };
2813
-
2814
2265
  // ../sdk/src/api/subscription.ts
2815
2266
  var SubscriptionApi = class {
2816
2267
  constructor(ctx) {
@@ -2826,123 +2277,6 @@ var SubscriptionApi = class {
2826
2277
  }
2827
2278
  };
2828
2279
 
2829
- // ../sdk/src/api/tables.ts
2830
- var enc5 = encodeURIComponent;
2831
- var TablesApi = class {
2832
- constructor(ctx) {
2833
- this.ctx = ctx;
2834
- }
2835
- async list(opts = {}) {
2836
- const q = new URLSearchParams();
2837
- if (opts.workspaceId) q.set("workspace_id", opts.workspaceId);
2838
- if (opts.cursor) q.set("cursor", opts.cursor);
2839
- if (opts.limit) q.set("limit", String(opts.limit));
2840
- const qs = q.toString() ? `?${q.toString()}` : "";
2841
- const res = await request(this.ctx, {
2842
- method: "GET",
2843
- path: `/api/v1/tables${qs}`,
2844
- signal: opts.signal
2845
- });
2846
- return res.data;
2847
- }
2848
- async get(id, opts = {}) {
2849
- const res = await request(this.ctx, {
2850
- method: "GET",
2851
- path: `/api/v1/tables/${enc5(id)}`,
2852
- signal: opts.signal
2853
- });
2854
- return res.data;
2855
- }
2856
- async create(input, opts = {}) {
2857
- const res = await request(this.ctx, {
2858
- method: "POST",
2859
- path: "/api/v1/tables",
2860
- body: input,
2861
- signal: opts.signal
2862
- });
2863
- return res.data;
2864
- }
2865
- async update(id, input, opts = {}) {
2866
- const res = await request(this.ctx, {
2867
- method: "PATCH",
2868
- path: `/api/v1/tables/${enc5(id)}`,
2869
- body: input,
2870
- signal: opts.signal
2871
- });
2872
- return res.data;
2873
- }
2874
- async delete(id, opts = {}) {
2875
- return request(this.ctx, {
2876
- method: "DELETE",
2877
- path: `/api/v1/tables/${enc5(id)}`,
2878
- signal: opts.signal
2879
- });
2880
- }
2881
- /** Query a collection's records with the filter/sort/paginate DSL. */
2882
- async query(id, query = {}, opts = {}) {
2883
- const res = await request(this.ctx, {
2884
- method: "POST",
2885
- path: `/api/v1/tables/${enc5(id)}/query`,
2886
- body: query,
2887
- signal: opts.signal
2888
- });
2889
- return res.data;
2890
- }
2891
- async createRecord(id, values, opts = {}) {
2892
- const res = await request(this.ctx, {
2893
- method: "POST",
2894
- path: `/api/v1/tables/${enc5(id)}/records`,
2895
- body: { values },
2896
- signal: opts.signal
2897
- });
2898
- return res.data;
2899
- }
2900
- async getRecord(id, recordId, opts = {}) {
2901
- const res = await request(this.ctx, {
2902
- method: "GET",
2903
- path: `/api/v1/tables/${enc5(id)}/records/${enc5(recordId)}`,
2904
- signal: opts.signal
2905
- });
2906
- return res.data;
2907
- }
2908
- async updateRecord(id, recordId, values, opts = {}) {
2909
- const res = await request(this.ctx, {
2910
- method: "PATCH",
2911
- path: `/api/v1/tables/${enc5(id)}/records/${enc5(recordId)}`,
2912
- body: { values },
2913
- signal: opts.signal
2914
- });
2915
- return res.data;
2916
- }
2917
- async deleteRecord(id, recordId, opts = {}) {
2918
- return request(this.ctx, {
2919
- method: "DELETE",
2920
- path: `/api/v1/tables/${enc5(id)}/records/${enc5(recordId)}`,
2921
- signal: opts.signal
2922
- });
2923
- }
2924
- /** Export a collection's records as a CSV string (header row = field keys). */
2925
- async exportCsv(id, opts = {}) {
2926
- const res = await requestRaw(this.ctx, {
2927
- method: "GET",
2928
- path: `/api/v1/tables/${enc5(id)}/export`,
2929
- signal: opts.signal,
2930
- expectJson: false
2931
- });
2932
- return res.text();
2933
- }
2934
- /** Import records into a collection from a CSV string. Returns the count. */
2935
- async importCsv(id, csv, opts = {}) {
2936
- const res = await request(this.ctx, {
2937
- method: "POST",
2938
- path: `/api/v1/tables/${enc5(id)}/import`,
2939
- body: { csv },
2940
- signal: opts.signal
2941
- });
2942
- return res.data;
2943
- }
2944
- };
2945
-
2946
2280
  // ../sdk/src/api/user.ts
2947
2281
  var UserApi = class {
2948
2282
  constructor(ctx) {
@@ -3642,21 +2976,16 @@ var IdaptClient2 = class {
3642
2976
  this.automations = new AutomationsApi(v1Ctx);
3643
2977
  this.computers = new ComputersApi(v1Ctx);
3644
2978
  this.secrets = new SecretsApi(v1Ctx);
3645
- this.kv = new DatastoreApi(v1Ctx);
3646
- this.blobs = new BlobsApi(v1Ctx);
3647
- this.tables = new TablesApi(v1Ctx);
3648
2979
  this.realtime = new RealtimeApi(v1Ctx);
3649
2980
  this.apiKeys = new ApiKeysApi(v1Ctx);
3650
2981
  this.notifications = new NotificationsApi(v1Ctx);
3651
2982
  this.settings = new SettingsApi(v1Ctx);
3652
2983
  this.subscription = new SubscriptionApi(v1Ctx);
3653
2984
  this.sharing = new SharingApi(v1Ctx);
3654
- this.store = new StoreApi(v1Ctx);
3655
2985
  this.models = new ModelsApi(v1Ctx);
3656
2986
  this.providerEndpoints = new ProviderEndpointsApi(v1Ctx);
3657
2987
  this.images = new ImagesApi(v1Ctx);
3658
2988
  this.audio = new AudioApi(v1Ctx);
3659
- this.functions = new FunctionsApi(v1Ctx);
3660
2989
  this.search = new SearchApi(v1Ctx);
3661
2990
  this.web = new WebSearchApi(v1Ctx);
3662
2991
  this.guide = new GuideApi(v1Ctx);
@@ -4190,64 +3519,6 @@ function useDataFile(name, options = {}) {
4190
3519
  }, [client, load]);
4191
3520
  return { data, loading, error, save, refresh, remove };
4192
3521
  }
4193
- function useLiveQuery(collectionResId, dsl = {}) {
4194
- const client = useIdapt();
4195
- const [records, setRecords] = react.useState([]);
4196
- const [loading, setLoading] = react.useState(true);
4197
- const [error, setError] = react.useState(null);
4198
- const dslKey = JSON.stringify(dsl);
4199
- const dslRef = react.useRef(dsl);
4200
- dslRef.current = dsl;
4201
- const [nonce, setNonce] = react.useState(0);
4202
- react.useEffect(() => {
4203
- if (!client || !collectionResId) return;
4204
- let active = true;
4205
- let inflight = false;
4206
- let queued = false;
4207
- const runQuery = async () => {
4208
- if (inflight) {
4209
- queued = true;
4210
- return;
4211
- }
4212
- inflight = true;
4213
- try {
4214
- const rows = await client.tables.query(collectionResId, dslRef.current);
4215
- if (!active) return;
4216
- setRecords(rows);
4217
- setError(null);
4218
- } catch (err) {
4219
- if (!active) return;
4220
- setError(err instanceof Error ? err : new Error(String(err)));
4221
- } finally {
4222
- inflight = false;
4223
- if (active) setLoading(false);
4224
- if (active && queued) {
4225
- queued = false;
4226
- void runQuery();
4227
- }
4228
- }
4229
- };
4230
- setLoading(true);
4231
- void runQuery();
4232
- const unsubscribe = client.realtime.subscribe(
4233
- [`table:${collectionResId}`],
4234
- (event) => {
4235
- if (event.type !== "broadcast") void runQuery();
4236
- },
4237
- { onError: (err) => active && setError(err) }
4238
- );
4239
- return () => {
4240
- active = false;
4241
- unsubscribe();
4242
- };
4243
- }, [client, collectionResId, dslKey, nonce]);
4244
- return {
4245
- records,
4246
- loading,
4247
- error,
4248
- refresh: () => setNonce((n) => n + 1)
4249
- };
4250
- }
4251
3522
  var DEFAULT_INTERVAL_MS = 1e4;
4252
3523
  function usePresence(key, options = {}) {
4253
3524
  const client = useIdapt();
@@ -4294,7 +3565,6 @@ exports.useChannel = useChannel;
4294
3565
  exports.useDataFile = useDataFile;
4295
3566
  exports.useIdapt = useIdapt;
4296
3567
  exports.useIdaptError = useIdaptError;
4297
- exports.useLiveQuery = useLiveQuery;
4298
3568
  exports.usePresence = usePresence;
4299
3569
  //# sourceMappingURL=react.cjs.map
4300
3570
  //# sourceMappingURL=react.cjs.map