@idapt/browser-app-sdk 0.1.0 → 0.3.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
@@ -665,6 +665,151 @@ function errorEvent(payload) {
665
665
  return event;
666
666
  }
667
667
 
668
+ // ../sdk/src/api/automations.ts
669
+ var AutomationsApi = class {
670
+ constructor(ctx) {
671
+ this.ctx = ctx;
672
+ }
673
+ // ---------------------------------------------------------------------------
674
+ // CRUD
675
+ // ---------------------------------------------------------------------------
676
+ async list(query = {}, opts = {}) {
677
+ const res = await request(this.ctx, {
678
+ method: "GET",
679
+ path: "/api/v1/automations",
680
+ query,
681
+ signal: opts.signal
682
+ });
683
+ return res.data;
684
+ }
685
+ /**
686
+ * Create an automation. `workspace_id` is passed in the request BODY
687
+ * 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.
692
+ *
693
+ * For a webhook automation the response additionally carries a one-time
694
+ * plaintext `secret` (use `AutomationWithSecret`); other automation types
695
+ * resolve to a plain `Automation`.
696
+ */
697
+ async create(workspaceId, input, opts = {}) {
698
+ const res = await request(this.ctx, {
699
+ method: "POST",
700
+ path: "/api/v1/automations",
701
+ body: { workspace_id: workspaceId, ...input },
702
+ signal: opts.signal
703
+ });
704
+ return res.data;
705
+ }
706
+ async get(id, opts = {}) {
707
+ const res = await request(this.ctx, {
708
+ method: "GET",
709
+ path: `/api/v1/automations/${id}`,
710
+ signal: opts.signal
711
+ });
712
+ return res.data;
713
+ }
714
+ async update(id, input, opts = {}) {
715
+ const res = await request(this.ctx, {
716
+ method: "PATCH",
717
+ path: `/api/v1/automations/${id}`,
718
+ body: input,
719
+ signal: opts.signal
720
+ });
721
+ return res.data;
722
+ }
723
+ async delete(id, opts = {}) {
724
+ return request(this.ctx, {
725
+ method: "DELETE",
726
+ path: `/api/v1/automations/${id}`,
727
+ signal: opts.signal
728
+ });
729
+ }
730
+ async archive(id, opts = {}) {
731
+ const res = await request(this.ctx, {
732
+ method: "POST",
733
+ path: `/api/v1/automations/${id}/archive`,
734
+ signal: opts.signal
735
+ });
736
+ return res.data;
737
+ }
738
+ async unarchive(id, opts = {}) {
739
+ const res = await request(this.ctx, {
740
+ method: "POST",
741
+ path: `/api/v1/automations/${id}/unarchive`,
742
+ signal: opts.signal
743
+ });
744
+ return res.data;
745
+ }
746
+ // ---------------------------------------------------------------------------
747
+ // Fire + rotate-secret + runs
748
+ // ---------------------------------------------------------------------------
749
+ /**
750
+ * Fire an automation via its webhook secret. This endpoint does NOT use the
751
+ * client's `ap_` key — the bearer is the automation's secret — so we build a
752
+ * one-off HttpContext for it rather than mutating the shared one.
753
+ *
754
+ * Responds HTTP 202. The response identifies the fired automation via `id`
755
+ * only.
756
+ */
757
+ async fire(id, input, opts = {}) {
758
+ const localCtx = {
759
+ apiUrl: this.ctx.apiUrl,
760
+ key: input.secret,
761
+ fetch: this.ctx.fetch
762
+ };
763
+ const res = await request(localCtx, {
764
+ method: "POST",
765
+ path: `/api/v1/automations/${id}/fire`,
766
+ body: input.body ?? {},
767
+ signal: opts.signal
768
+ });
769
+ return res.data;
770
+ }
771
+ /**
772
+ * Rotate the webhook secret. Returns the automation with a fresh one-time
773
+ * plaintext `secret` populated (`AutomationWithSecret`). The old secret
774
+ * immediately stops working.
775
+ */
776
+ async rotateSecret(id, opts = {}) {
777
+ const res = await request(this.ctx, {
778
+ method: "POST",
779
+ path: `/api/v1/automations/${id}/rotate-secret`,
780
+ signal: opts.signal
781
+ });
782
+ return res.data;
783
+ }
784
+ /** Recent fires + their success/error outcome. */
785
+ async listRuns(id, query = {}, opts = {}) {
786
+ const res = await request(this.ctx, {
787
+ method: "GET",
788
+ path: `/api/v1/automations/${id}/runs`,
789
+ query,
790
+ signal: opts.signal
791
+ });
792
+ return res.data;
793
+ }
794
+ async getCostStats(id, opts = {}) {
795
+ const res = await request(this.ctx, {
796
+ method: "GET",
797
+ path: `/api/v1/automations/${id}/cost-stats`,
798
+ signal: opts.signal
799
+ });
800
+ return res.data;
801
+ }
802
+ async getCostStatsMap(query = {}, opts = {}) {
803
+ const res = await request(this.ctx, {
804
+ method: "GET",
805
+ path: "/api/v1/automations/cost-stats",
806
+ query,
807
+ signal: opts.signal
808
+ });
809
+ return res.data.by_id;
810
+ }
811
+ };
812
+
668
813
  // ../sdk/src/api/blobs.ts
669
814
  var enc = encodeURIComponent;
670
815
  var BlobsApi = class {
@@ -1130,46 +1275,6 @@ var ChatsApi = class {
1130
1275
  }
1131
1276
  };
1132
1277
 
1133
- // ../sdk/src/api/code.ts
1134
- var CodeRunsApi = class {
1135
- constructor(ctx) {
1136
- this.ctx = ctx;
1137
- }
1138
- /**
1139
- * Execute a code file. Returns the full `ExecutionRun` row — `id`,
1140
- * `status`, `stdout`, `stderr`, `exit_code`, and the run timestamps —
1141
- * the same shape as `GET /code-runs/:id`.
1142
- */
1143
- async run(input, opts = {}) {
1144
- const res = await request(this.ctx, {
1145
- method: "POST",
1146
- path: "/api/v1/code-runs",
1147
- body: input,
1148
- signal: opts.signal
1149
- });
1150
- return res.data;
1151
- }
1152
- /** List recent execution runs. */
1153
- async list(query = {}, opts = {}) {
1154
- const res = await request(this.ctx, {
1155
- method: "GET",
1156
- path: "/api/v1/code-runs",
1157
- query,
1158
- signal: opts.signal
1159
- });
1160
- return res.data;
1161
- }
1162
- /** Get a single execution run by id. */
1163
- async get(id, opts = {}) {
1164
- const res = await request(this.ctx, {
1165
- method: "GET",
1166
- path: `/api/v1/code-runs/${id}`,
1167
- signal: opts.signal
1168
- });
1169
- return res.data;
1170
- }
1171
- };
1172
-
1173
1278
  // ../sdk/src/api/computers.ts
1174
1279
  var ComputersApi = class {
1175
1280
  constructor(ctx) {
@@ -1533,59 +1638,85 @@ var ComputersApi = class {
1533
1638
  return res.data;
1534
1639
  }
1535
1640
  // ---------------------------------------------------------------------------
1536
- // Workspace links (share LOCAL INFERENCE into other workspaces)
1641
+ // Workspace exposures (expose an actor-owned machine into a workspace) +
1642
+ // ownership transfer
1537
1643
  // ---------------------------------------------------------------------------
1538
1644
  /**
1539
- * List the workspaces a computer's LOCAL INFERENCE is shared into. The home
1540
- * workspace is never listed (it already has full access). The route returns
1541
- * the links under a `links` key (not a standard list envelope).
1645
+ * Expose an actor-owned machine INTO a workspace (Layer 2) with a
1646
+ * per-capability grant, so that workspace's members can use it. Requires
1647
+ * machine-admin and membership of the target workspace. Rejects a duplicate
1648
+ * exposure. (CLI verb: `computer add-exposure` — the bare `expose`/`unexpose`
1649
+ * verbs are the tunnel port commands.)
1542
1650
  */
1543
- async listWorkspaceLinks(id, opts = {}) {
1544
- const res = await request(this.ctx, {
1545
- method: "GET",
1546
- path: `/api/v1/computers/${id}/workspace-links`,
1547
- signal: opts.signal
1548
- });
1549
- return res.data.links;
1651
+ async expose(id, input, opts = {}) {
1652
+ const res = await request(
1653
+ this.ctx,
1654
+ {
1655
+ method: "POST",
1656
+ path: `/api/v1/computers/${id}/expose`,
1657
+ body: input,
1658
+ signal: opts.signal
1659
+ }
1660
+ );
1661
+ return res.data.exposure;
1550
1662
  }
1551
1663
  /**
1552
- * Share a computer's LOCAL INFERENCE into another workspace (never shell /
1553
- * files / tunnels). `workspaceId` is the target workspace's `ws_…`
1554
- * resourceId or slug. Requires EDIT on the computer's home workspace and
1555
- * membership of the target. Rejects the home workspace and duplicates.
1664
+ * Replace the capability grant on an existing exposure. `workspaceId` is the
1665
+ * exposed workspace's `ws_…` resourceId. Requires machine-admin.
1666
+ * (CLI verb: `computer update-exposure`.)
1556
1667
  */
1557
- async linkWorkspace(id, workspaceId, opts = {}) {
1668
+ async updateExposure(id, workspaceId, capabilities, opts = {}) {
1558
1669
  const res = await request(
1559
1670
  this.ctx,
1560
1671
  {
1561
- method: "POST",
1562
- path: `/api/v1/computers/${id}/workspace-links`,
1563
- body: { workspace_id: workspaceId },
1672
+ method: "PATCH",
1673
+ path: `/api/v1/computers/${id}/expose/${workspaceId}`,
1674
+ body: { capabilities },
1564
1675
  signal: opts.signal
1565
1676
  }
1566
1677
  );
1567
- return res.data.link;
1678
+ return res.data.exposure;
1568
1679
  }
1569
1680
  /**
1570
- * Stop sharing a computer's local inference into a workspace. `workspaceId`
1571
- * is the target workspace's `ws_…` resourceId. Idempotent unlinking a
1572
- * non-existent link still succeeds.
1681
+ * Stop exposing a machine into a workspace. `workspaceId` is the exposed
1682
+ * workspace's `ws_…` resourceId. Allowed for machine-admin OR an admin of the
1683
+ * exposed workspace. Idempotent. (CLI verb: `computer remove-exposure`.)
1573
1684
  */
1574
- async unlinkWorkspace(id, workspaceId, opts = {}) {
1575
- const res = await request(this.ctx, {
1576
- method: "DELETE",
1577
- path: `/api/v1/computers/${id}/workspace-links/${workspaceId}`,
1578
- signal: opts.signal
1579
- });
1685
+ async unexpose(id, workspaceId, opts = {}) {
1686
+ const res = await request(
1687
+ this.ctx,
1688
+ {
1689
+ method: "DELETE",
1690
+ path: `/api/v1/computers/${id}/expose/${workspaceId}`,
1691
+ signal: opts.signal
1692
+ }
1693
+ );
1580
1694
  return res.data;
1581
1695
  }
1696
+ /**
1697
+ * Transfer an actor-owned machine to a new owner (self, or an org the caller
1698
+ * administers). `owner` is the target profile's resourceId; existing workspace
1699
+ * exposures are kept. Requires machine-admin. (CLI verb: `computer transfer`.)
1700
+ */
1701
+ async transfer(id, owner, opts = {}) {
1702
+ const res = await request(
1703
+ this.ctx,
1704
+ {
1705
+ method: "POST",
1706
+ path: `/api/v1/computers/${id}/transfer`,
1707
+ body: { owner },
1708
+ signal: opts.signal
1709
+ }
1710
+ );
1711
+ return res.data.computer;
1712
+ }
1582
1713
  // ---------------------------------------------------------------------------
1583
1714
  // Pair-token redemption (daemon bootstrap)
1584
1715
  // ---------------------------------------------------------------------------
1585
1716
  /**
1586
1717
  * Redeem a one-time pair token for a long-lived computer identity. The
1587
1718
  * token itself is the auth — we swap the bearer for the token on this
1588
- * call only (same pattern as `triggers.fire`).
1719
+ * call only (same pattern as `automations.fire`).
1589
1720
  *
1590
1721
  * Used by `idapt up --token` to bootstrap a daemon. The request body is
1591
1722
  * snake_case; the response is wrapped in the standard `{data:{…}}`
@@ -1806,6 +1937,156 @@ var FilesApi = class {
1806
1937
  }
1807
1938
  };
1808
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
+ };
2089
+
1809
2090
  // ../sdk/src/api/guide.ts
1810
2091
  var GuideApi = class {
1811
2092
  constructor(ctx) {
@@ -2108,7 +2389,7 @@ var ProviderEndpointsApi = class {
2108
2389
  };
2109
2390
 
2110
2391
  // ../sdk/src/api/realtime.ts
2111
- var enc3 = encodeURIComponent;
2392
+ var enc4 = encodeURIComponent;
2112
2393
  var RECONNECT_MIN_MS = 1e3;
2113
2394
  var RECONNECT_MAX_MS = 3e4;
2114
2395
  var RealtimeApi = class {
@@ -2119,7 +2400,7 @@ var RealtimeApi = class {
2119
2400
  async broadcast(channel, message, opts = {}) {
2120
2401
  const res = await request(this.ctx, {
2121
2402
  method: "POST",
2122
- path: `/api/v1/realtime/${enc3(channel)}/broadcast`,
2403
+ path: `/api/v1/realtime/${enc4(channel)}/broadcast`,
2123
2404
  body: { message },
2124
2405
  signal: opts.signal
2125
2406
  });
@@ -2129,7 +2410,7 @@ var RealtimeApi = class {
2129
2410
  async heartbeat(channel, opts = {}) {
2130
2411
  const res = await request(this.ctx, {
2131
2412
  method: "POST",
2132
- path: `/api/v1/realtime/${enc3(channel)}/presence`,
2413
+ path: `/api/v1/realtime/${enc4(channel)}/presence`,
2133
2414
  body: { meta: opts.meta, ttl_seconds: opts.ttlSeconds },
2134
2415
  signal: opts.signal
2135
2416
  });
@@ -2139,7 +2420,7 @@ var RealtimeApi = class {
2139
2420
  async presence(channel, opts = {}) {
2140
2421
  const res = await request(this.ctx, {
2141
2422
  method: "GET",
2142
- path: `/api/v1/realtime/${enc3(channel)}/presence`,
2423
+ path: `/api/v1/realtime/${enc4(channel)}/presence`,
2143
2424
  signal: opts.signal
2144
2425
  });
2145
2426
  return res.data;
@@ -2546,7 +2827,7 @@ var SubscriptionApi = class {
2546
2827
  };
2547
2828
 
2548
2829
  // ../sdk/src/api/tables.ts
2549
- var enc4 = encodeURIComponent;
2830
+ var enc5 = encodeURIComponent;
2550
2831
  var TablesApi = class {
2551
2832
  constructor(ctx) {
2552
2833
  this.ctx = ctx;
@@ -2567,7 +2848,7 @@ var TablesApi = class {
2567
2848
  async get(id, opts = {}) {
2568
2849
  const res = await request(this.ctx, {
2569
2850
  method: "GET",
2570
- path: `/api/v1/tables/${enc4(id)}`,
2851
+ path: `/api/v1/tables/${enc5(id)}`,
2571
2852
  signal: opts.signal
2572
2853
  });
2573
2854
  return res.data;
@@ -2584,7 +2865,7 @@ var TablesApi = class {
2584
2865
  async update(id, input, opts = {}) {
2585
2866
  const res = await request(this.ctx, {
2586
2867
  method: "PATCH",
2587
- path: `/api/v1/tables/${enc4(id)}`,
2868
+ path: `/api/v1/tables/${enc5(id)}`,
2588
2869
  body: input,
2589
2870
  signal: opts.signal
2590
2871
  });
@@ -2593,7 +2874,7 @@ var TablesApi = class {
2593
2874
  async delete(id, opts = {}) {
2594
2875
  return request(this.ctx, {
2595
2876
  method: "DELETE",
2596
- path: `/api/v1/tables/${enc4(id)}`,
2877
+ path: `/api/v1/tables/${enc5(id)}`,
2597
2878
  signal: opts.signal
2598
2879
  });
2599
2880
  }
@@ -2601,7 +2882,7 @@ var TablesApi = class {
2601
2882
  async query(id, query = {}, opts = {}) {
2602
2883
  const res = await request(this.ctx, {
2603
2884
  method: "POST",
2604
- path: `/api/v1/tables/${enc4(id)}/query`,
2885
+ path: `/api/v1/tables/${enc5(id)}/query`,
2605
2886
  body: query,
2606
2887
  signal: opts.signal
2607
2888
  });
@@ -2610,7 +2891,7 @@ var TablesApi = class {
2610
2891
  async createRecord(id, values, opts = {}) {
2611
2892
  const res = await request(this.ctx, {
2612
2893
  method: "POST",
2613
- path: `/api/v1/tables/${enc4(id)}/records`,
2894
+ path: `/api/v1/tables/${enc5(id)}/records`,
2614
2895
  body: { values },
2615
2896
  signal: opts.signal
2616
2897
  });
@@ -2619,7 +2900,7 @@ var TablesApi = class {
2619
2900
  async getRecord(id, recordId, opts = {}) {
2620
2901
  const res = await request(this.ctx, {
2621
2902
  method: "GET",
2622
- path: `/api/v1/tables/${enc4(id)}/records/${enc4(recordId)}`,
2903
+ path: `/api/v1/tables/${enc5(id)}/records/${enc5(recordId)}`,
2623
2904
  signal: opts.signal
2624
2905
  });
2625
2906
  return res.data;
@@ -2627,7 +2908,7 @@ var TablesApi = class {
2627
2908
  async updateRecord(id, recordId, values, opts = {}) {
2628
2909
  const res = await request(this.ctx, {
2629
2910
  method: "PATCH",
2630
- path: `/api/v1/tables/${enc4(id)}/records/${enc4(recordId)}`,
2911
+ path: `/api/v1/tables/${enc5(id)}/records/${enc5(recordId)}`,
2631
2912
  body: { values },
2632
2913
  signal: opts.signal
2633
2914
  });
@@ -2636,7 +2917,7 @@ var TablesApi = class {
2636
2917
  async deleteRecord(id, recordId, opts = {}) {
2637
2918
  return request(this.ctx, {
2638
2919
  method: "DELETE",
2639
- path: `/api/v1/tables/${enc4(id)}/records/${enc4(recordId)}`,
2920
+ path: `/api/v1/tables/${enc5(id)}/records/${enc5(recordId)}`,
2640
2921
  signal: opts.signal
2641
2922
  });
2642
2923
  }
@@ -2644,7 +2925,7 @@ var TablesApi = class {
2644
2925
  async exportCsv(id, opts = {}) {
2645
2926
  const res = await requestRaw(this.ctx, {
2646
2927
  method: "GET",
2647
- path: `/api/v1/tables/${enc4(id)}/export`,
2928
+ path: `/api/v1/tables/${enc5(id)}/export`,
2648
2929
  signal: opts.signal,
2649
2930
  expectJson: false
2650
2931
  });
@@ -2654,7 +2935,7 @@ var TablesApi = class {
2654
2935
  async importCsv(id, csv, opts = {}) {
2655
2936
  const res = await request(this.ctx, {
2656
2937
  method: "POST",
2657
- path: `/api/v1/tables/${enc4(id)}/import`,
2938
+ path: `/api/v1/tables/${enc5(id)}/import`,
2658
2939
  body: { csv },
2659
2940
  signal: opts.signal
2660
2941
  });
@@ -2662,154 +2943,6 @@ var TablesApi = class {
2662
2943
  }
2663
2944
  };
2664
2945
 
2665
- // ../sdk/src/api/triggers.ts
2666
- var TriggersApi = class {
2667
- constructor(ctx) {
2668
- this.ctx = ctx;
2669
- }
2670
- // ---------------------------------------------------------------------------
2671
- // CRUD
2672
- // ---------------------------------------------------------------------------
2673
- async list(query = {}, opts = {}) {
2674
- const res = await request(this.ctx, {
2675
- method: "GET",
2676
- path: "/api/v1/triggers",
2677
- query,
2678
- signal: opts.signal
2679
- });
2680
- return res.data;
2681
- }
2682
- /**
2683
- * Create a trigger. `workspace_id` is passed in the request BODY (alongside
2684
- * the flat trigger definition) — it is not a query param. The request
2685
- * body is flat: every scheduling field (`cron_expression`, …) and every
2686
- * action field (`agent_id`, `prompt_template`, `file_id`, …) sits at the
2687
- * top level — there are no nested `trigger_config` / `action_config`
2688
- * objects any more.
2689
- *
2690
- * For a `webhook` trigger the response additionally carries a one-time
2691
- * plaintext `secret` (use `TriggerWithSecret`); other trigger types
2692
- * resolve to a plain `Trigger`.
2693
- */
2694
- async create(workspaceId, input, opts = {}) {
2695
- const res = await request(
2696
- this.ctx,
2697
- {
2698
- method: "POST",
2699
- path: "/api/v1/triggers",
2700
- body: { workspace_id: workspaceId, ...input },
2701
- signal: opts.signal
2702
- }
2703
- );
2704
- return res.data;
2705
- }
2706
- async get(id, opts = {}) {
2707
- const res = await request(this.ctx, {
2708
- method: "GET",
2709
- path: `/api/v1/triggers/${id}`,
2710
- signal: opts.signal
2711
- });
2712
- return res.data;
2713
- }
2714
- async update(id, input, opts = {}) {
2715
- const res = await request(this.ctx, {
2716
- method: "PATCH",
2717
- path: `/api/v1/triggers/${id}`,
2718
- body: input,
2719
- signal: opts.signal
2720
- });
2721
- return res.data;
2722
- }
2723
- async delete(id, opts = {}) {
2724
- return request(this.ctx, {
2725
- method: "DELETE",
2726
- path: `/api/v1/triggers/${id}`,
2727
- signal: opts.signal
2728
- });
2729
- }
2730
- async archive(id, opts = {}) {
2731
- const res = await request(this.ctx, {
2732
- method: "POST",
2733
- path: `/api/v1/triggers/${id}/archive`,
2734
- signal: opts.signal
2735
- });
2736
- return res.data;
2737
- }
2738
- async unarchive(id, opts = {}) {
2739
- const res = await request(this.ctx, {
2740
- method: "POST",
2741
- path: `/api/v1/triggers/${id}/unarchive`,
2742
- signal: opts.signal
2743
- });
2744
- return res.data;
2745
- }
2746
- // ---------------------------------------------------------------------------
2747
- // Fire + rotate-secret + runs
2748
- // ---------------------------------------------------------------------------
2749
- /**
2750
- * Fire a trigger via its webhook secret. This endpoint does NOT use the
2751
- * client's `ap_` key — the bearer is the trigger's secret — so we build a
2752
- * one-off HttpContext for it rather than mutating the shared one.
2753
- *
2754
- * Responds HTTP 202. The response identifies the fired trigger via `id`
2755
- * only.
2756
- */
2757
- async fire(id, input, opts = {}) {
2758
- const localCtx = {
2759
- apiUrl: this.ctx.apiUrl,
2760
- key: input.secret,
2761
- fetch: this.ctx.fetch
2762
- };
2763
- const res = await request(localCtx, {
2764
- method: "POST",
2765
- path: `/api/v1/triggers/${id}/fire`,
2766
- body: input.body ?? {},
2767
- signal: opts.signal
2768
- });
2769
- return res.data;
2770
- }
2771
- /**
2772
- * Rotate the webhook secret. Returns the trigger with a fresh one-time
2773
- * plaintext `secret` populated (`TriggerWithSecret`). The old secret
2774
- * immediately stops working.
2775
- */
2776
- async rotateSecret(id, opts = {}) {
2777
- const res = await request(this.ctx, {
2778
- method: "POST",
2779
- path: `/api/v1/triggers/${id}/rotate-secret`,
2780
- signal: opts.signal
2781
- });
2782
- return res.data;
2783
- }
2784
- /** Recent fires + their success/error outcome. */
2785
- async listRuns(id, query = {}, opts = {}) {
2786
- const res = await request(this.ctx, {
2787
- method: "GET",
2788
- path: `/api/v1/triggers/${id}/runs`,
2789
- query,
2790
- signal: opts.signal
2791
- });
2792
- return res.data;
2793
- }
2794
- async getCostStats(id, opts = {}) {
2795
- const res = await request(this.ctx, {
2796
- method: "GET",
2797
- path: `/api/v1/triggers/${id}/cost-stats`,
2798
- signal: opts.signal
2799
- });
2800
- return res.data;
2801
- }
2802
- async getCostStatsMap(query = {}, opts = {}) {
2803
- const res = await request(this.ctx, {
2804
- method: "GET",
2805
- path: "/api/v1/triggers/cost-stats",
2806
- query,
2807
- signal: opts.signal
2808
- });
2809
- return res.data.by_id;
2810
- }
2811
- };
2812
-
2813
2946
  // ../sdk/src/api/user.ts
2814
2947
  var UserApi = class {
2815
2948
  constructor(ctx) {
@@ -3506,7 +3639,7 @@ var IdaptClient2 = class {
3506
3639
  this.agents = new AgentsApi(v1Ctx);
3507
3640
  this.chats = new ChatsApi(v1Ctx);
3508
3641
  this.workspaces = new WorkspacesApi(v1Ctx);
3509
- this.triggers = new TriggersApi(v1Ctx);
3642
+ this.automations = new AutomationsApi(v1Ctx);
3510
3643
  this.computers = new ComputersApi(v1Ctx);
3511
3644
  this.secrets = new SecretsApi(v1Ctx);
3512
3645
  this.kv = new DatastoreApi(v1Ctx);
@@ -3523,7 +3656,7 @@ var IdaptClient2 = class {
3523
3656
  this.providerEndpoints = new ProviderEndpointsApi(v1Ctx);
3524
3657
  this.images = new ImagesApi(v1Ctx);
3525
3658
  this.audio = new AudioApi(v1Ctx);
3526
- this.code = new CodeRunsApi(v1Ctx);
3659
+ this.functions = new FunctionsApi(v1Ctx);
3527
3660
  this.search = new SearchApi(v1Ctx);
3528
3661
  this.web = new WebSearchApi(v1Ctx);
3529
3662
  this.guide = new GuideApi(v1Ctx);