@ptkl/sdk 1.13.0 → 1.15.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.
@@ -100,6 +100,9 @@ var ProtokolSDK010 = (function (exports, axios) {
100
100
  this.env = null;
101
101
  this.token = null;
102
102
  this.host = null;
103
+ this.env = env;
104
+ this.token = token;
105
+ this.host = host;
103
106
  }
104
107
  }
105
108
 
@@ -117,6 +120,7 @@ var ProtokolSDK010 = (function (exports, axios) {
117
120
  if (opts && opts.stream === true) {
118
121
  let onMetaCallback = () => { };
119
122
  let onDataCallback = () => { };
123
+ let onCursorCallback = () => { };
120
124
  let onErrorCallback;
121
125
  let onEndCallback;
122
126
  let isFirstLine = true;
@@ -129,6 +133,10 @@ var ProtokolSDK010 = (function (exports, axios) {
129
133
  onDataCallback = callback;
130
134
  return chainable;
131
135
  },
136
+ onCursor: (callback) => {
137
+ onCursorCallback = callback;
138
+ return chainable;
139
+ },
132
140
  onError: (callback) => {
133
141
  onErrorCallback = callback;
134
142
  return chainable;
@@ -147,6 +155,11 @@ var ProtokolSDK010 = (function (exports, axios) {
147
155
  if (result instanceof Promise)
148
156
  await result;
149
157
  }
158
+ else if ('next_cursor' in doc && !('uuid' in doc)) {
159
+ const result = onCursorCallback(doc);
160
+ if (result instanceof Promise)
161
+ await result;
162
+ }
150
163
  else {
151
164
  const result = onDataCallback(doc);
152
165
  if (result instanceof Promise)
@@ -217,6 +230,8 @@ var ProtokolSDK010 = (function (exports, axios) {
217
230
  };
218
231
  if (ctx.only && ctx.only.length > 0)
219
232
  params.only = ctx.only;
233
+ if (ctx.cursor)
234
+ params.cursor = ctx.cursor;
220
235
  if (Object.keys(ctx.$adv || {}).length > 0)
221
236
  params.$adv = [(_b = ctx.$adv) !== null && _b !== void 0 ? _b : {}];
222
237
  if (ctx.$aggregate && ctx.$aggregate.length > 0)
@@ -883,11 +898,32 @@ var ProtokolSDK010 = (function (exports, axios) {
883
898
  }
884
899
  // Permissions & Roles
885
900
  /**
886
- * Get user permissions
901
+ * Get the current token's permissions.
902
+ *
903
+ * Returns the resolved permission set carried by the calling token. For a
904
+ * forge actor token this is the scoped intersection minted at launch time —
905
+ * see `getPrincipalPermissions()` for the underlying user's full set.
887
906
  */
888
907
  async getPermissions() {
889
908
  return await this.client.get("/v1/user/role/permissions");
890
909
  }
910
+ /**
911
+ * Get the FULL permissions of the user the current token is acting on behalf
912
+ * of (the "principal").
913
+ *
914
+ * When a forge app runs under an actor token, `getPermissions()` returns only
915
+ * the token's scoped permissions — the intersection of the app's declared
916
+ * runtime permissions and the user's permissions. This instead returns the
917
+ * complete permission set of the underlying user, so the app can check what
918
+ * that user is actually allowed to do, independent of what the app itself was
919
+ * granted. The token scope is unchanged: this exposes knowledge, not capability.
920
+ *
921
+ * For a normal user session (no actor token) it returns the caller's own
922
+ * permissions, identical to `getPermissions()`'s scope.
923
+ */
924
+ async getPrincipalPermissions() {
925
+ return await this.client.get("/v1/user/role/principal-permissions");
926
+ }
891
927
  /**
892
928
  * Get list of available permissions
893
929
  */
@@ -972,7 +1008,7 @@ var ProtokolSDK010 = (function (exports, axios) {
972
1008
  * @returns Promise resolving to the created/updated component
973
1009
  */
974
1010
  async setup(data) {
975
- return await this.client.post("/v3/system/component/setup", data);
1011
+ return await this.client.post("/v4/system/component/setup", data);
976
1012
  }
977
1013
  }
978
1014
 
@@ -1228,9 +1264,22 @@ var ProtokolSDK010 = (function (exports, axios) {
1228
1264
  }
1229
1265
  }
1230
1266
 
1267
+ /**
1268
+ * Sandbox client — spark (FaaS) functions/apps, long-running runtimes, and
1269
+ * their K8s deployments. All routes go through the `sandbox/…` gateway
1270
+ * prefix (`/luma/sandbox/v1/...`), matching the sandbox service's REST
1271
+ * surface (`internal/controllers/{spark.go,spark.v1.go,runtime.v1.go}` and
1272
+ * the deployment lifecycle in `internal/controllers/ecomm/deployment.go`).
1273
+ */
1231
1274
  class Sandbox extends PlatformBaseClient {
1275
+ // ---------------------------------------------------------------
1276
+ // Spark (FaaS functions / apps)
1277
+ // ---------------------------------------------------------------
1232
1278
  /**
1233
- * Call the sandbox service to execute a serverless function
1279
+ * Call the sandbox service to execute a serverless function.
1280
+ *
1281
+ * Kept for backwards compatibility — equivalent to
1282
+ * `execSpark(name, data)`.
1234
1283
  *
1235
1284
  * @param name
1236
1285
  * @param data
@@ -1242,6 +1291,143 @@ var ProtokolSDK010 = (function (exports, axios) {
1242
1291
  async spark(name, data) {
1243
1292
  return await this.client.post(`/luma/sandbox/v1/spark/exec/${name}`, data);
1244
1293
  }
1294
+ /**
1295
+ * Create a new spark (function or app).
1296
+ *
1297
+ * @example
1298
+ * const spark = await platform.sandbox().createSpark({ name: "myFunction", runtime: "node20", memory: 256 })
1299
+ */
1300
+ async createSpark(payload) {
1301
+ return await this.client.post(`/luma/sandbox/v1/spark`, payload);
1302
+ }
1303
+ /**
1304
+ * Get a spark by uuid.
1305
+ */
1306
+ async getSpark(uuid) {
1307
+ return await this.client.get(`/luma/sandbox/v1/spark/${uuid}`);
1308
+ }
1309
+ /**
1310
+ * Update a spark's memory/settings/env vars.
1311
+ */
1312
+ async updateSpark(uuid, payload) {
1313
+ return await this.client.patch(`/luma/sandbox/v1/spark/${uuid}`, payload);
1314
+ }
1315
+ /**
1316
+ * Delete a spark.
1317
+ */
1318
+ async deleteSpark(uuid) {
1319
+ return await this.client.delete(`/luma/sandbox/v1/spark/${uuid}`);
1320
+ }
1321
+ /**
1322
+ * List all sparks for the current project.
1323
+ */
1324
+ async listSparks() {
1325
+ return await this.client.get(`/luma/sandbox/v1/spark`);
1326
+ }
1327
+ /**
1328
+ * Deploy a specific spark version to the dev environment.
1329
+ */
1330
+ async deploySpark(uuid, version) {
1331
+ return await this.client.put(`/luma/sandbox/v1/spark/deploy/${uuid}/${version}`);
1332
+ }
1333
+ /**
1334
+ * Cancel an in-progress spark deployment.
1335
+ *
1336
+ * @param uuid
1337
+ * @param env - defaults to "dev" on the server if omitted
1338
+ */
1339
+ async cancelSpark(uuid, env) {
1340
+ return await this.client.put(`/luma/sandbox/v1/spark/cancel/${uuid}`, undefined, { params: env ? { env } : undefined });
1341
+ }
1342
+ /**
1343
+ * Release a deployed spark version to the live/public environment.
1344
+ */
1345
+ async releaseSpark(uuid, version) {
1346
+ return await this.client.put(`/luma/sandbox/v1/spark/release/${uuid}/${version}`);
1347
+ }
1348
+ /**
1349
+ * Execute a deployed spark by name. Mirrors `spark()` but accepts the
1350
+ * full request shape (method/query/headers) — the exec route accepts
1351
+ * GET/POST/PATCH/PUT/DELETE.
1352
+ *
1353
+ * @example
1354
+ * const result = await platform.sandbox().execSpark("myFunction", { foo: "bar" })
1355
+ * const result = await platform.sandbox().execSpark("myFunction", undefined, { method: "GET" })
1356
+ */
1357
+ async execSpark(name, data, options) {
1358
+ var _a;
1359
+ const method = ((_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : "POST").toLowerCase();
1360
+ return await this.client.request({
1361
+ url: `/luma/sandbox/v1/spark/exec/${name}`,
1362
+ method,
1363
+ data,
1364
+ params: options === null || options === void 0 ? void 0 : options.query,
1365
+ headers: options === null || options === void 0 ? void 0 : options.headers,
1366
+ });
1367
+ }
1368
+ /**
1369
+ * Fetch logs for a spark.
1370
+ */
1371
+ async sparkLogs(uuid, params) {
1372
+ return await this.client.get(`/luma/sandbox/v1/spark/logs/${uuid}`, { params });
1373
+ }
1374
+ /**
1375
+ * Get the current project's spark tier (plan/quota).
1376
+ */
1377
+ async sparkTier() {
1378
+ return await this.client.get(`/luma/sandbox/v1/spark/project/tier`);
1379
+ }
1380
+ // ---------------------------------------------------------------
1381
+ // Runtimes (long-running user API deployments)
1382
+ // ---------------------------------------------------------------
1383
+ /**
1384
+ * List all runtimes for the current project.
1385
+ */
1386
+ async listRuntimes() {
1387
+ return await this.client.get(`/luma/sandbox/v1/runtime`);
1388
+ }
1389
+ /**
1390
+ * Create a new runtime.
1391
+ */
1392
+ async createRuntime(payload) {
1393
+ return await this.client.post(`/luma/sandbox/v1/runtime`, payload);
1394
+ }
1395
+ /**
1396
+ * Get a runtime by ref (name/uuid).
1397
+ */
1398
+ async getRuntime(ref) {
1399
+ return await this.client.get(`/luma/sandbox/v1/runtime/${ref}`);
1400
+ }
1401
+ /**
1402
+ * Update a runtime's image/resources/env vars/tags.
1403
+ */
1404
+ async updateRuntime(ref, payload) {
1405
+ return await this.client.patch(`/luma/sandbox/v1/runtime/${ref}`, payload);
1406
+ }
1407
+ /**
1408
+ * Delete a runtime.
1409
+ */
1410
+ async deleteRuntime(ref) {
1411
+ return await this.client.delete(`/luma/sandbox/v1/runtime/${ref}`);
1412
+ }
1413
+ /**
1414
+ * (Re)deploy a runtime.
1415
+ */
1416
+ async deployRuntime(ref) {
1417
+ return await this.client.post(`/luma/sandbox/v1/runtime/${ref}/deploy`);
1418
+ }
1419
+ /**
1420
+ * Restart a running runtime.
1421
+ */
1422
+ async restartRuntime(ref) {
1423
+ return await this.client.post(`/luma/sandbox/v1/runtime/${ref}/restart`);
1424
+ }
1425
+ /**
1426
+ * Fetch logs for a runtime.
1427
+ */
1428
+ async runtimeLogs(ref, params) {
1429
+ return await this.client.get(`/luma/sandbox/v1/runtime/${ref}/logs`, { params });
1430
+ }
1245
1431
  }
1246
1432
 
1247
1433
  class System extends PlatformBaseClient {
@@ -1269,6 +1455,17 @@ var ProtokolSDK010 = (function (exports, axios) {
1269
1455
  }
1270
1456
  }
1271
1457
 
1458
+ function nodeControlQuery(options) {
1459
+ const params = new URLSearchParams();
1460
+ if ((options === null || options === void 0 ? void 0 : options.iterationIdx) !== undefined) {
1461
+ params.set('iteration_idx', String(options.iterationIdx));
1462
+ }
1463
+ if ((options === null || options === void 0 ? void 0 : options.parentNodeId) !== undefined) {
1464
+ params.set('parent_node_id', String(options.parentNodeId));
1465
+ }
1466
+ const qs = params.toString();
1467
+ return qs ? `?${qs}` : '';
1468
+ }
1272
1469
  class Workflow extends PlatformBaseClient {
1273
1470
  async create(data) {
1274
1471
  return await this.client.post(`/v1/project/workflow/workflow`, data);
@@ -1291,8 +1488,123 @@ var ProtokolSDK010 = (function (exports, axios) {
1291
1488
  async publish(event, data) {
1292
1489
  return await this.client.post(`/v1/project/workflow/workflow/event/${event}`, data);
1293
1490
  }
1491
+ /**
1492
+ * Install (create + publish) a workflow in one call.
1493
+ * Rejects if a workflow with the same name + integrator already exists.
1494
+ */
1495
+ async install(data) {
1496
+ return await this.client.post(`/v1/project/workflow/workflow/install`, data);
1497
+ }
1498
+ // --- Execution history ---
1499
+ async getHistory(query) {
1500
+ return await this.client.get(`/v1/project/workflow/workflows/history`, { params: query });
1501
+ }
1502
+ async getHistoryEntry(executionUuid) {
1503
+ return await this.client.get(`/v1/project/workflow/workflows/history/${executionUuid}`);
1504
+ }
1505
+ async getStats(query) {
1506
+ return await this.client.get(`/v1/project/workflow/workflows/stats`, { params: query });
1507
+ }
1508
+ // --- Running executions ---
1509
+ async getRunning(query) {
1510
+ return await this.client.get(`/v1/project/workflow/workflows/running`, { params: query });
1511
+ }
1512
+ async getRunningEntry(executionUuid) {
1513
+ return await this.client.get(`/v1/project/workflow/workflows/running/${executionUuid}`);
1514
+ }
1515
+ // --- Workflow execution control ---
1516
+ async pause(executionUuid) {
1517
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/pause`);
1518
+ }
1519
+ async resume(executionUuid) {
1520
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/resume`);
1521
+ }
1522
+ async kill(executionUuid) {
1523
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/kill`);
1524
+ }
1525
+ /**
1526
+ * Restart a failed/killed workflow execution from history.
1527
+ * `clearState: true` discards prior node state instead of a smart resume.
1528
+ */
1529
+ async restart(executionUuid, options) {
1530
+ const qs = (options === null || options === void 0 ? void 0 : options.clearState) ? '?clear_state=true' : '';
1531
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/restart${qs}`);
1532
+ }
1533
+ // --- Node-level control ---
1534
+ async pauseNode(executionUuid, nodeId, options) {
1535
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/nodes/${nodeId}/pause${nodeControlQuery(options)}`);
1536
+ }
1537
+ async resumeNode(executionUuid, nodeId, options) {
1538
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/nodes/${nodeId}/resume${nodeControlQuery(options)}`);
1539
+ }
1540
+ async killNode(executionUuid, nodeId, options) {
1541
+ return await this.client.post(`/v1/project/workflow/workflows/${executionUuid}/nodes/${nodeId}/kill${nodeControlQuery(options)}`);
1542
+ }
1543
+ // --- Errors ---
1544
+ async getErrors() {
1545
+ return await this.client.get(`/v1/project/workflow/errors`);
1546
+ }
1547
+ async removeError(id) {
1548
+ return await this.client.delete(`/v1/project/workflow/errors/${id}`);
1549
+ }
1550
+ async removeAllErrors() {
1551
+ return await this.client.delete(`/v1/project/workflow/errors`);
1552
+ }
1294
1553
  }
1295
1554
 
1555
+ /**
1556
+ * Resolve the current app's UUID from the ambient platform context.
1557
+ * The platform injects it per-installation: FORGE_APP_UUID in __ENV_VARIABLES__
1558
+ * for public views, and forge_app_uuid in sessionStorage for platform views.
1559
+ * Returns null outside the browser (e.g. Node/CLI), where the caller must pass
1560
+ * an explicit appUuid.
1561
+ */
1562
+ function resolveCurrentAppUuid() {
1563
+ var _a;
1564
+ if (!isBrowser)
1565
+ return null;
1566
+ // @ts-ignore
1567
+ const fromEnv = (_a = window.__ENV_VARIABLES__) === null || _a === void 0 ? void 0 : _a.FORGE_APP_UUID;
1568
+ if (fromEnv)
1569
+ return fromEnv;
1570
+ try {
1571
+ return sessionStorage.getItem("forge_app_uuid");
1572
+ }
1573
+ catch {
1574
+ return null;
1575
+ }
1576
+ }
1577
+ /**
1578
+ * Resolve a service target into { ref, serviceName }.
1579
+ *
1580
+ * Two forms, cleanly split:
1581
+ * - a bare service name (no "prn:" prefix) → the CURRENT app's service (the ref
1582
+ * is the current app's uuid, resolved from the platform context); or
1583
+ * - a service PRN `prn:forge:{ref}:service/{serviceName}` → ANOTHER app's service
1584
+ * (canonical PRN grammar: kind + name in the path, url-encoded).
1585
+ *
1586
+ * A PRN's `ref` may be an app **name** OR a uuid. Names aren't unique within a
1587
+ * project (a marketplace install and a custom app can share one), so the runtime
1588
+ * resolves a name deterministically **marketplace → custom**. Pass the uuid when
1589
+ * you need a *specific* app.
1590
+ */
1591
+ function parseServiceTarget(target) {
1592
+ if (!target.startsWith("prn:")) {
1593
+ // bare service name → the current app
1594
+ return { ref: resolveCurrentAppUuid(), serviceName: target };
1595
+ }
1596
+ // PRN → another app. Path form: prn:forge:{ref}:service/{serviceName}
1597
+ // (the PRN path segment is "service/{name}", with the name url-encoded).
1598
+ const [, type, ref, ...rest] = target.split(":");
1599
+ const path = rest.join(":"); // the PRN path, e.g. "service/{name}"
1600
+ const [kind, ...nameParts] = path.split("/");
1601
+ const serviceName = decodeURIComponent(nameParts.join("/"));
1602
+ if (type !== "forge" || kind !== "service" || !ref || !serviceName) {
1603
+ throw new Error(`runService: invalid service PRN "${target}" ` +
1604
+ `(expected prn:forge:{ref}:service/{serviceName}, where ref is an app name or uuid)`);
1605
+ }
1606
+ return { ref, serviceName };
1607
+ }
1296
1608
  class Forge extends PlatformBaseClient {
1297
1609
  // --- Management (appservice) ---
1298
1610
  async bundleUpload(buffer) {
@@ -1330,156 +1642,202 @@ var ProtokolSDK010 = (function (exports, axios) {
1330
1642
  return await this.client.patch(`/luma/appservice/v1/forge/${ref}/variables`, current);
1331
1643
  }
1332
1644
  // --- Service execution (forge-runtime) ---
1333
- async callService(appUuid, serviceName, options) {
1334
- var _a, _b, _c;
1645
+ /**
1646
+ * Run a Forge service: `runService(target, body?, { query?, headers? })`.
1647
+ * Mirrors `axios.post(url, data, config)` — the 2nd arg is the request payload.
1648
+ *
1649
+ * `target` is either:
1650
+ * - a bare service name — runs that service on the CURRENT app; or
1651
+ * - a service PRN `prn:forge:{ref}:service/{name}` — runs it on ANOTHER app,
1652
+ * where `ref` is the app's **name** or uuid. A name is resolved by the
1653
+ * runtime deterministically (marketplace → custom); use the uuid to pin a
1654
+ * specific app. This is the addressing to use where there's no ambient
1655
+ * "current app" — e.g. a workflow, which has no per-install uuid to hardcode.
1656
+ *
1657
+ * `body` is sent as the POST body; `options.query` / `options.headers` are optional.
1658
+ *
1659
+ * The current app's uuid (bare-name form) is resolved automatically from the
1660
+ * platform context (FORGE_APP_UUID for public views, forge_app_uuid in
1661
+ * sessionStorage for platform views), so app code never needs its own uuid.
1662
+ *
1663
+ * Resolving the app does NOT grant access. Execution is still authorized against
1664
+ * the caller's permissions — for a `platform`-access service the caller must hold
1665
+ * `service::{name} forge::{appUuid}`; `public`-access services require none. An
1666
+ * app's own runtime token is implicitly granted this for all of its own services.
1667
+ */
1668
+ async runService(target, body, options) {
1669
+ var _a;
1670
+ const { ref, serviceName } = parseServiceTarget(target);
1335
1671
  const queryString = (options === null || options === void 0 ? void 0 : options.query)
1336
1672
  ? '?' + new URLSearchParams(options.query).toString()
1337
1673
  : '';
1338
1674
  // @ts-ignore
1339
1675
  const devServiceUrl = isBrowser && ((_a = window.__ENV_VARIABLES__) === null || _a === void 0 ? void 0 : _a.FORGE_DEV_SERVICE_URL);
1340
1676
  if (devServiceUrl) {
1341
- return axios.post(`${devServiceUrl}/${serviceName}${queryString}`, (_b = options === null || options === void 0 ? void 0 : options.body) !== null && _b !== void 0 ? _b : {}, (options === null || options === void 0 ? void 0 : options.headers) ? { headers: options.headers } : undefined);
1677
+ // The dev service server routes by name; the ref is ignored.
1678
+ return axios.post(`${devServiceUrl}/${serviceName}${queryString}`, body !== null && body !== void 0 ? body : {}, (options === null || options === void 0 ? void 0 : options.headers) ? { headers: options.headers } : undefined);
1342
1679
  }
1343
- return await this.client.post(`/luma/forge-runtime/api/services/${appUuid}/${serviceName}${queryString}`, (_c = options === null || options === void 0 ? void 0 : options.body) !== null && _c !== void 0 ? _c : {}, (options === null || options === void 0 ? void 0 : options.headers) ? { headers: options.headers } : undefined);
1680
+ if (!ref) {
1681
+ throw new Error("runService: could not resolve the current app from the platform context. " +
1682
+ "Use a service PRN with an explicit ref: prn:forge:{name|uuid}:service/{serviceName}.");
1683
+ }
1684
+ // Service execution is owned by the forge runtime (forge-runtime gateway ->
1685
+ // platform-forge), which resolves the ref (name → uuid, marketplace → custom)
1686
+ // and executes the service, enforcing `service::{name} forge::{uuid}`
1687
+ // for platform-access services before running.
1688
+ return await this.client.post(`/luma/forge-runtime/api/services/${ref}/${serviceName}${queryString}`, body !== null && body !== void 0 ? body : {}, (options === null || options === void 0 ? void 0 : options.headers) ? { headers: options.headers } : undefined);
1344
1689
  }
1345
1690
  }
1346
1691
 
1347
- const BASE = '/luma/kortex/v1';
1692
+ const BASE$1 = '/luma/kortex/v1';
1348
1693
  class Kortex extends PlatformBaseClient {
1349
1694
  // ── Agents ──
1350
1695
  async createAgent(data) {
1351
- return await this.client.post(`${BASE}/agents`, data);
1696
+ return await this.client.post(`${BASE$1}/agents`, data);
1352
1697
  }
1353
1698
  async listAgents(params) {
1354
- return await this.client.get(`${BASE}/agents`, { params });
1699
+ return await this.client.get(`${BASE$1}/agents`, { params });
1355
1700
  }
1356
1701
  async getAgent(uuid) {
1357
- return await this.client.get(`${BASE}/agents/${uuid}`);
1702
+ return await this.client.get(`${BASE$1}/agents/${uuid}`);
1358
1703
  }
1359
1704
  async updateAgent(uuid, data) {
1360
- return await this.client.patch(`${BASE}/agents/${uuid}`, data);
1705
+ return await this.client.patch(`${BASE$1}/agents/${uuid}`, data);
1361
1706
  }
1362
1707
  async deleteAgent(uuid) {
1363
- return await this.client.delete(`${BASE}/agents/${uuid}`);
1708
+ return await this.client.delete(`${BASE$1}/agents/${uuid}`);
1364
1709
  }
1365
1710
  async listAgentKnowledgeBases(agentUUID) {
1366
- return await this.client.get(`${BASE}/agents/${agentUUID}/knowledge-bases`);
1711
+ return await this.client.get(`${BASE$1}/agents/${agentUUID}/knowledge-bases`);
1367
1712
  }
1368
1713
  // ── Knowledge Bases ──
1369
1714
  async createKnowledgeBase(data) {
1370
- return await this.client.post(`${BASE}/knowledge-bases`, data);
1715
+ return await this.client.post(`${BASE$1}/knowledge-bases`, data);
1371
1716
  }
1372
1717
  async listKnowledgeBases(params) {
1373
- return await this.client.get(`${BASE}/knowledge-bases`, { params });
1718
+ return await this.client.get(`${BASE$1}/knowledge-bases`, { params });
1374
1719
  }
1375
1720
  async getKnowledgeBase(uuid) {
1376
- return await this.client.get(`${BASE}/knowledge-bases/${uuid}`);
1721
+ return await this.client.get(`${BASE$1}/knowledge-bases/${uuid}`);
1377
1722
  }
1378
1723
  async updateKnowledgeBase(uuid, data) {
1379
- return await this.client.put(`${BASE}/knowledge-bases/${uuid}`, data);
1724
+ return await this.client.put(`${BASE$1}/knowledge-bases/${uuid}`, data);
1380
1725
  }
1381
1726
  async deleteKnowledgeBase(uuid) {
1382
- return await this.client.delete(`${BASE}/knowledge-bases/${uuid}`);
1727
+ return await this.client.delete(`${BASE$1}/knowledge-bases/${uuid}`);
1728
+ }
1729
+ // Searches the knowledge bases attached to `data.agent_uuid` (collections
1730
+ // are derived from the agent, not passed explicitly). `top_k` is clamped
1731
+ // to 1-10 server-side. Response is `{ chunks: KnowledgeBaseSearchChunk[] }`.
1732
+ async searchKnowledgeBase(data) {
1733
+ return await this.client.post(`${BASE$1}/knowledge-bases/search`, data);
1383
1734
  }
1384
1735
  // ── Documents ──
1385
1736
  async listDocuments(kbUUID, params) {
1386
- return await this.client.get(`${BASE}/knowledge-bases/${kbUUID}/documents`, { params });
1737
+ return await this.client.get(`${BASE$1}/knowledge-bases/${kbUUID}/documents`, { params });
1387
1738
  }
1388
1739
  async uploadDocument(kbUUID, formData) {
1389
- return await this.client.post(`${BASE}/knowledge-bases/${kbUUID}/documents`, formData, {
1740
+ return await this.client.post(`${BASE$1}/knowledge-bases/${kbUUID}/documents`, formData, {
1390
1741
  headers: { 'Content-Type': 'multipart/form-data' },
1391
1742
  timeout: 120000,
1392
1743
  });
1393
1744
  }
1394
1745
  async getDocument(kbUUID, uuid) {
1395
- return await this.client.get(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1746
+ return await this.client.get(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1396
1747
  }
1397
1748
  async deleteDocument(kbUUID, uuid) {
1398
- return await this.client.delete(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1749
+ return await this.client.delete(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}`);
1399
1750
  }
1400
1751
  async retryDocument(kbUUID, uuid) {
1401
- return await this.client.post(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}/retry`);
1752
+ return await this.client.post(`${BASE$1}/knowledge-bases/${kbUUID}/documents/${uuid}/retry`);
1402
1753
  }
1403
1754
  // ── Conversations ──
1404
1755
  async createConversation(data) {
1405
- return await this.client.post(`${BASE}/conversations`, data);
1756
+ return await this.client.post(`${BASE$1}/conversations`, data);
1406
1757
  }
1407
1758
  async listConversations(params) {
1408
- return await this.client.get(`${BASE}/conversations`, { params });
1759
+ return await this.client.get(`${BASE$1}/conversations`, { params });
1409
1760
  }
1410
1761
  async getConversation(uuid) {
1411
- return await this.client.get(`${BASE}/conversations/${uuid}`);
1762
+ return await this.client.get(`${BASE$1}/conversations/${uuid}`);
1412
1763
  }
1413
1764
  async updateConversation(uuid, data) {
1414
- return await this.client.put(`${BASE}/conversations/${uuid}`, data);
1765
+ return await this.client.put(`${BASE$1}/conversations/${uuid}`, data);
1415
1766
  }
1416
1767
  async deleteConversation(uuid) {
1417
- return await this.client.delete(`${BASE}/conversations/${uuid}`);
1768
+ return await this.client.delete(`${BASE$1}/conversations/${uuid}`);
1418
1769
  }
1419
1770
  async archiveConversation(uuid) {
1420
- return await this.client.post(`${BASE}/conversations/${uuid}/archive`);
1771
+ return await this.client.post(`${BASE$1}/conversations/${uuid}/archive`);
1421
1772
  }
1422
1773
  async unarchiveConversation(uuid) {
1423
- return await this.client.post(`${BASE}/conversations/${uuid}/unarchive`);
1774
+ return await this.client.post(`${BASE$1}/conversations/${uuid}/unarchive`);
1424
1775
  }
1425
1776
  async addParticipant(conversationUUID, data) {
1426
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/participants`, data);
1777
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/participants`, data);
1427
1778
  }
1428
1779
  async removeParticipant(conversationUUID, agentUUID) {
1429
- return await this.client.delete(`${BASE}/conversations/${conversationUUID}/participants/${agentUUID}`);
1780
+ return await this.client.delete(`${BASE$1}/conversations/${conversationUUID}/participants/${agentUUID}`);
1430
1781
  }
1431
1782
  // ── Messages / Completions ──
1432
1783
  async sendMessage(conversationUUID, data) {
1433
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages`, data);
1784
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages`, data);
1434
1785
  }
1435
1786
  async streamMessage(conversationUUID, data) {
1436
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages`, { ...data, stream: true }, {
1787
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages`, { ...data, stream: true }, {
1437
1788
  responseType: 'stream',
1438
1789
  timeout: 120000,
1439
1790
  });
1440
1791
  }
1441
1792
  async listMessages(conversationUUID, params) {
1442
- return await this.client.get(`${BASE}/conversations/${conversationUUID}/messages`, { params });
1793
+ return await this.client.get(`${BASE$1}/conversations/${conversationUUID}/messages`, { params });
1443
1794
  }
1444
1795
  async injectMessage(conversationUUID, data) {
1445
- return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages/inject`, data);
1796
+ return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages/inject`, data);
1446
1797
  }
1447
1798
  // ── OCR ──
1448
1799
  async ocr(data) {
1449
- return await this.client.post(`${BASE}/ocr`, data, { timeout: 120000 });
1800
+ return await this.client.post(`${BASE$1}/ocr`, data, { timeout: 120000 });
1801
+ }
1802
+ // ── Workflow ──
1803
+ async workflowComplete(data) {
1804
+ return await this.client.post(`${BASE$1}/workflow/complete`, data);
1805
+ }
1806
+ async workflowOcr(data) {
1807
+ return await this.client.post(`${BASE$1}/workflow/ocr`, data, { timeout: 120000 });
1450
1808
  }
1451
1809
  // ── User Access ──
1452
1810
  async createUserAccess(data) {
1453
- return await this.client.post(`${BASE}/user-access`, data);
1811
+ return await this.client.post(`${BASE$1}/user-access`, data);
1454
1812
  }
1455
1813
  async listUserAccess(params) {
1456
- return await this.client.get(`${BASE}/user-access`, { params });
1814
+ return await this.client.get(`${BASE$1}/user-access`, { params });
1457
1815
  }
1458
1816
  async getUserAccess(uuid) {
1459
- return await this.client.get(`${BASE}/user-access/${uuid}`);
1817
+ return await this.client.get(`${BASE$1}/user-access/${uuid}`);
1460
1818
  }
1461
1819
  async updateUserAccess(uuid, data) {
1462
- return await this.client.patch(`${BASE}/user-access/${uuid}`, data);
1820
+ return await this.client.patch(`${BASE$1}/user-access/${uuid}`, data);
1463
1821
  }
1464
1822
  async deleteUserAccess(uuid) {
1465
- return await this.client.delete(`${BASE}/user-access/${uuid}`);
1823
+ return await this.client.delete(`${BASE$1}/user-access/${uuid}`);
1466
1824
  }
1467
1825
  async getUserMonthlyUsage(uuid, params) {
1468
- return await this.client.get(`${BASE}/user-access/${uuid}/usage`, { params });
1826
+ return await this.client.get(`${BASE$1}/user-access/${uuid}/usage`, { params });
1469
1827
  }
1470
1828
  async getUserUsageBreakdown(uuid) {
1471
- return await this.client.get(`${BASE}/user-access/${uuid}/usage/breakdown`);
1829
+ return await this.client.get(`${BASE$1}/user-access/${uuid}/usage/breakdown`);
1472
1830
  }
1473
1831
  async getMyAccess() {
1474
- return await this.client.get(`${BASE}/my-access`);
1832
+ return await this.client.get(`${BASE$1}/my-access`);
1475
1833
  }
1476
1834
  // ── Usage (Admin) ──
1477
1835
  async listUsage(params) {
1478
- return await this.client.get(`${BASE}/usage`, { params });
1836
+ return await this.client.get(`${BASE$1}/usage`, { params });
1479
1837
  }
1480
1838
  // ── Tier ──
1481
1839
  async getTier() {
1482
- return await this.client.get(`${BASE}/tier`);
1840
+ return await this.client.get(`${BASE$1}/tier`);
1483
1841
  }
1484
1842
  }
1485
1843
 
@@ -1510,12 +1868,50 @@ var ProtokolSDK010 = (function (exports, axios) {
1510
1868
  return await this.client.patch("/v1/project/archive");
1511
1869
  }
1512
1870
  /**
1513
- * Invite a user to the project
1514
- * @param emails Array of emails
1515
- * @param roles Array of role UUIDs
1871
+ * Invite one or more users to the project.
1872
+ *
1873
+ * `POST /v1/project/invite` only accepts a single `email` per request
1874
+ * (see `InviteToProject` in platform-api's
1875
+ * `internal/project/controllers/invite.go`), so this method issues one
1876
+ * request per entry in `emails`, sequentially, with body
1877
+ * `{ email, role_uuid: roles, subject?, comment? }`.
1878
+ *
1879
+ * Return shape (always a single `AxiosResponse`, so existing callers
1880
+ * that do `(await project.invite(...)).data` keep compiling/working
1881
+ * unchanged):
1882
+ * - Exactly one email: the raw `AxiosResponse` from that single request
1883
+ * (`.data` is that invite's response body, as before).
1884
+ * - More than one email: a response shaped like the last request's
1885
+ * `AxiosResponse`, but with `.data` replaced by an array of each
1886
+ * individual request's `.data`, in the same order as `emails`.
1887
+ *
1888
+ * @param emails Array of email addresses to invite
1889
+ * @param roles Array of role UUIDs to grant every invitee
1890
+ * @param extra Optional subject/comment applied to every invite
1516
1891
  */
1517
- async invite(emails, roles) {
1518
- return await this.client.post("/v1/project/invite", { emails: emails.join(","), roles });
1892
+ async invite(emails, roles, extra) {
1893
+ const bodyExtra = {};
1894
+ if ((extra === null || extra === void 0 ? void 0 : extra.subject) !== undefined)
1895
+ bodyExtra.subject = extra.subject;
1896
+ if ((extra === null || extra === void 0 ? void 0 : extra.comment) !== undefined)
1897
+ bodyExtra.comment = extra.comment;
1898
+ const responses = [];
1899
+ for (const email of emails) {
1900
+ const res = await this.client.post("/v1/project/invite", {
1901
+ email,
1902
+ role_uuid: roles,
1903
+ ...bodyExtra,
1904
+ });
1905
+ responses.push(res);
1906
+ }
1907
+ if (responses.length === 1) {
1908
+ return responses[0];
1909
+ }
1910
+ const last = responses[responses.length - 1];
1911
+ return {
1912
+ ...last,
1913
+ data: responses.map((r) => r.data),
1914
+ };
1519
1915
  }
1520
1916
  /**
1521
1917
  * Get list of project invites
@@ -1645,25 +2041,49 @@ var ProtokolSDK010 = (function (exports, axios) {
1645
2041
  return await this.client.get("/v1/project/template/workspace");
1646
2042
  }
1647
2043
  /**
1648
- * Install a template
1649
- * @param data Installation data
2044
+ * Install a template.
2045
+ *
2046
+ * `POST /v1/project/template/install` decodes body `TemplateInstall = { id,
2047
+ * data, activation_code }` and resolves the target workspace from the
2048
+ * `X-Workspace-Uuid` request header (not the body) — see platform-api's
2049
+ * `template_install.go`. This method keeps the ergonomic object-arg
2050
+ * signature but maps it onto that contract: `template_id` becomes body
2051
+ * `id`, `workspace_uuid` is sent as the `X-Workspace-Uuid` header, and any
2052
+ * `data`/`activation_code` passed in are forwarded in the body as-is.
2053
+ *
2054
+ * @param data `{ template_id, workspace_uuid, data?, activation_code? }`
1650
2055
  */
1651
2056
  async installTemplate(data) {
1652
- return await this.client.post("/v1/project/template/install", data);
2057
+ const { template_id, workspace_uuid, ...rest } = data;
2058
+ return await this.client.post("/v1/project/template/install", { id: template_id, ...rest }, { headers: { "X-Workspace-Uuid": workspace_uuid } });
1653
2059
  }
1654
2060
  /**
1655
- * Uninstall a template
1656
- * @param data Uninstallation data
2061
+ * Uninstall a template.
2062
+ *
2063
+ * `POST /v1/project/template/uninstall` decodes body `TemplateInstall = {
2064
+ * id, data, activation_code }` and resolves the target workspace from the
2065
+ * `X-Workspace-Uuid` request header (not the body) — see platform-api's
2066
+ * `template_uninstall.go`. See `installTemplate` for the mapping.
2067
+ *
2068
+ * @param data `{ template_id, workspace_uuid, data?, activation_code? }`
1657
2069
  */
1658
2070
  async uninstallTemplate(data) {
1659
- return await this.client.post("/v1/project/template/uninstall", data);
2071
+ const { template_id, workspace_uuid, ...rest } = data;
2072
+ return await this.client.post("/v1/project/template/uninstall", { id: template_id, ...rest }, { headers: { "X-Workspace-Uuid": workspace_uuid } });
1660
2073
  }
1661
2074
  /**
1662
- * Upgrade a template
1663
- * @param data Upgrade data
2075
+ * Upgrade a template.
2076
+ *
2077
+ * `POST /v1/project/template/upgrade` decodes body `TemplateInstall = {
2078
+ * id, data, activation_code }` and resolves the target workspace from the
2079
+ * `X-Workspace-Uuid` request header (not the body) — see platform-api's
2080
+ * `template_upgrade.go`. See `installTemplate` for the mapping.
2081
+ *
2082
+ * @param data `{ template_id, workspace_uuid, data?, activation_code? }`
1664
2083
  */
1665
2084
  async upgradeTemplate(data) {
1666
- return await this.client.post("/v1/project/template/upgrade", data);
2085
+ const { template_id, workspace_uuid, ...rest } = data;
2086
+ return await this.client.post("/v1/project/template/upgrade", { id: template_id, ...rest }, { headers: { "X-Workspace-Uuid": workspace_uuid } });
1667
2087
  }
1668
2088
  }
1669
2089
 
@@ -1683,62 +2103,6 @@ var ProtokolSDK010 = (function (exports, axios) {
1683
2103
  }
1684
2104
  }
1685
2105
 
1686
- // apis
1687
- class Platform extends PlatformBaseClient {
1688
- getPlatformClient() {
1689
- return this.client;
1690
- }
1691
- getPlatformBaseURL() {
1692
- var _a;
1693
- return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
1694
- }
1695
- apiUser() {
1696
- return (new APIUser()).setClient(this.client);
1697
- }
1698
- function() {
1699
- return (new Functions()).setClient(this.client);
1700
- }
1701
- user() {
1702
- return (new Users()).setClient(this.client);
1703
- }
1704
- app(appType) {
1705
- return (new Apps(appType)).setClient(this.client);
1706
- }
1707
- forge() {
1708
- return (new Forge()).setClient(this.client);
1709
- }
1710
- kortex() {
1711
- return (new Kortex()).setClient(this.client);
1712
- }
1713
- component(ref) {
1714
- return (new Component(ref)).setClient(this.client);
1715
- }
1716
- componentUtils() {
1717
- return (new ComponentUtils()).setClient(this.client);
1718
- }
1719
- ratchet() {
1720
- return (new Ratchet()).setClient(this.client);
1721
- }
1722
- sandbox() {
1723
- return (new Sandbox()).setClient(this.client);
1724
- }
1725
- system() {
1726
- return (new System()).setClient(this.client);
1727
- }
1728
- workflow() {
1729
- return (new Workflow()).setClient(this.client);
1730
- }
1731
- thunder() {
1732
- return (new Thunder()).setClient(this.client);
1733
- }
1734
- project() {
1735
- return (new Project()).setClient(this.client);
1736
- }
1737
- config() {
1738
- return (new Config()).setClient(this.client);
1739
- }
1740
- }
1741
-
1742
2106
  class IntegrationsBaseClient extends BaseClient {
1743
2107
  constructor(options) {
1744
2108
  var _a, _b, _c, _d, _e, _f, _g;
@@ -2617,6 +2981,135 @@ var ProtokolSDK010 = (function (exports, axios) {
2617
2981
  timeout: 120000
2618
2982
  });
2619
2983
  }
2984
+ // ===================================================================
2985
+ // Backup (Library Export Archives)
2986
+ // ===================================================================
2987
+ /**
2988
+ * Create a library export archive (a snapshot of the project's library or a directory within it)
2989
+ *
2990
+ * The library is resolved server-side from the project in the auth context —
2991
+ * there is a single library per project.
2992
+ *
2993
+ * @param payload - Optional export scope/format options
2994
+ * @returns `{ mode, export }` when the export is queued asynchronously.
2995
+ * Depending on server-side sizing, the endpoint may instead stream the
2996
+ * archive back directly as a binary response body (not this JSON shape).
2997
+ *
2998
+ * @example
2999
+ * ```typescript
3000
+ * const result = await dms.createExport({ path: 'legal', format: 'zip' });
3001
+ * ```
3002
+ */
3003
+ async createExport(payload) {
3004
+ return this.request('POST', `library/exports`, { data: payload !== null && payload !== void 0 ? payload : {} });
3005
+ }
3006
+ /**
3007
+ * List export archives for the project's library
3008
+ */
3009
+ async listExports() {
3010
+ return this.request('GET', `library/exports`);
3011
+ }
3012
+ /**
3013
+ * Get a single export archive (an archived snapshot of a library/dir)
3014
+ *
3015
+ * @param exportUuid - Export UUID
3016
+ * @returns `{ export, download_url }`
3017
+ */
3018
+ async getExport(exportUuid) {
3019
+ return this.request('GET', `library/exports/${exportUuid}`);
3020
+ }
3021
+ // ===================================================================
3022
+ // Policies (Quota / File-Type / Notification, library & dir scope)
3023
+ // ===================================================================
3024
+ /**
3025
+ * Get the effective library-level policy for the project's library
3026
+ */
3027
+ async getLibraryPolicy() {
3028
+ return this.request('GET', `library/policy`);
3029
+ }
3030
+ /**
3031
+ * Set/update the library-level policy for the project's library
3032
+ *
3033
+ * @param payload - Policy fields to set
3034
+ */
3035
+ async setLibraryPolicy(payload) {
3036
+ return this.request('PUT', `library/policy`, { data: payload });
3037
+ }
3038
+ /**
3039
+ * Get the directory-level policy (resolves platform-default → library → dir)
3040
+ *
3041
+ * @param path - Directory path
3042
+ */
3043
+ async getDirPolicy(path) {
3044
+ return this.request('GET', `library/dir/policy`, { params: { path } });
3045
+ }
3046
+ /**
3047
+ * Set/update the directory-level policy
3048
+ *
3049
+ * @param path - Directory path
3050
+ * @param payload - Policy fields to set (only fields provided override the library policy)
3051
+ */
3052
+ async setDirPolicy(path, payload) {
3053
+ return this.request('PUT', `library/dir/policy`, { data: payload, params: { path } });
3054
+ }
3055
+ /**
3056
+ * Remove a directory-level policy override (directory falls back to the library policy)
3057
+ *
3058
+ * @param path - Directory path
3059
+ */
3060
+ async deleteDirPolicy(path) {
3061
+ return this.request('DELETE', `library/dir/policy`, { params: { path } });
3062
+ }
3063
+ // ===================================================================
3064
+ // Reminders (Notification Rules & Per-File Notifications)
3065
+ // ===================================================================
3066
+ /**
3067
+ * List notification rules for the project's library
3068
+ */
3069
+ async listNotificationRules() {
3070
+ return this.request('GET', `library/notification-rules`);
3071
+ }
3072
+ /**
3073
+ * Create a recurring reminder (notification rule) for a media file
3074
+ *
3075
+ * @param payload - Recurring reminder definition (media_uuid/file_key, frequency, start_at, ...)
3076
+ */
3077
+ async createNotificationRule(payload) {
3078
+ return this.request('POST', `library/notification-rules`, { data: payload });
3079
+ }
3080
+ /**
3081
+ * Delete a notification rule
3082
+ *
3083
+ * @param ruleUuid - Notification rule UUID
3084
+ */
3085
+ async deleteNotificationRule(ruleUuid) {
3086
+ return this.request('DELETE', `library/notification-rules/${ruleUuid}`);
3087
+ }
3088
+ /**
3089
+ * List custom reminders scheduled for a specific file
3090
+ *
3091
+ * @param mediaUuid - Media UUID
3092
+ */
3093
+ async listFileNotifications(mediaUuid) {
3094
+ return this.request('GET', `library/media/${mediaUuid}/notifications`);
3095
+ }
3096
+ /**
3097
+ * Create a custom reminder for a specific file
3098
+ *
3099
+ * @param mediaUuid - Media UUID
3100
+ * @param payload - Reminder details (note, notify_at, optional recipient)
3101
+ */
3102
+ async createFileNotification(mediaUuid, payload) {
3103
+ return this.request('POST', `library/media/${mediaUuid}/notifications`, { data: payload });
3104
+ }
3105
+ /**
3106
+ * Cancel/delete a custom file reminder
3107
+ *
3108
+ * @param notificationUuid - Notification UUID
3109
+ */
3110
+ async deleteFileNotification(notificationUuid) {
3111
+ return this.request('DELETE', `library/notifications/${notificationUuid}`);
3112
+ }
2620
3113
  async request(method, endpoint, params) {
2621
3114
  return await this.client.request({
2622
3115
  method: method,
@@ -3786,6 +4279,65 @@ var ProtokolSDK010 = (function (exports, axios) {
3786
4279
  const { data } = await this.client.get("/v1/integrations");
3787
4280
  return data.find((i) => i.id == id && i.status == "active") !== undefined;
3788
4281
  }
4282
+ /**
4283
+ * Install (integrate) an integration into the current project.
4284
+ * POST /v1/integrate
4285
+ */
4286
+ async install(id, data) {
4287
+ const { data: resp } = await this.client.post("/v1/integrate", {
4288
+ id,
4289
+ ...(data !== undefined ? { data } : {}),
4290
+ });
4291
+ return resp;
4292
+ }
4293
+ /**
4294
+ * Uninstall (remove) an integration from the current project.
4295
+ * PUT /v1/integrate
4296
+ */
4297
+ async uninstall(id) {
4298
+ const { data } = await this.client.put("/v1/integrate", { id });
4299
+ return data;
4300
+ }
4301
+ /**
4302
+ * Activate an installed integration.
4303
+ * POST /v1/integration/{id}/activate
4304
+ */
4305
+ async activate(id) {
4306
+ const { data } = await this.client.post(`/v1/integration/${encodeURIComponent(id)}/activate`);
4307
+ return data;
4308
+ }
4309
+ /**
4310
+ * Deactivate an installed integration.
4311
+ * POST /v1/integration/{id}/deactivate
4312
+ */
4313
+ async deactivate(id) {
4314
+ const { data } = await this.client.post(`/v1/integration/${encodeURIComponent(id)}/deactivate`);
4315
+ return data;
4316
+ }
4317
+ /**
4318
+ * Advance/update the onboarding state of an installed integration.
4319
+ * POST /v1/integration/{id}/onboarding
4320
+ */
4321
+ async onboarding(id, data) {
4322
+ const { data: resp } = await this.client.post(`/v1/integration/${encodeURIComponent(id)}/onboarding`, data);
4323
+ return resp;
4324
+ }
4325
+ /**
4326
+ * List marketplace-available integrations (subscription/geo aware).
4327
+ * GET /v1/marketplace/integrations
4328
+ */
4329
+ async marketplace() {
4330
+ const { data } = await this.client.get("/v1/marketplace/integrations");
4331
+ return data;
4332
+ }
4333
+ /**
4334
+ * List explorable integration templates (subscription/geo aware).
4335
+ * GET /v1/integrations/explore
4336
+ */
4337
+ async explore() {
4338
+ const { data } = await this.client.get("/v1/integrations/explore");
4339
+ return data;
4340
+ }
3789
4341
  getInterfaceOf(id) {
3790
4342
  try {
3791
4343
  return this.integrations[id];
@@ -3798,57 +4350,286 @@ var ProtokolSDK010 = (function (exports, axios) {
3798
4350
 
3799
4351
  class Satellites extends IntegrationsBaseClient {
3800
4352
  async list() {
3801
- const { data } = await this.client.get('/satellites/templates');
4353
+ const { data } = await this.client.get('/v1/satellites/templates');
3802
4354
  return data;
3803
4355
  }
3804
4356
  async create(payload) {
3805
- const { data } = await this.client.post('/satellites/templates', payload.template);
4357
+ const { data } = await this.client.post('/v1/satellites/templates', payload.template);
3806
4358
  if (payload.schema) {
3807
4359
  await this.createVersion(data.id, payload.schema);
3808
4360
  }
3809
4361
  return data;
3810
4362
  }
3811
4363
  async get(id) {
3812
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}`);
4364
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}`);
3813
4365
  return data;
3814
4366
  }
3815
4367
  async delete(id) {
3816
- const { data } = await this.client.delete(`/satellites/templates/${encodeURIComponent(id)}`);
4368
+ const { data } = await this.client.delete(`/v1/satellites/templates/${encodeURIComponent(id)}`);
3817
4369
  return data;
3818
4370
  }
3819
4371
  async createVersion(id, payload) {
3820
- const { data } = await this.client.post(`/satellites/templates/${encodeURIComponent(id)}/versions`, payload);
4372
+ const { data } = await this.client.post(`/v1/satellites/templates/${encodeURIComponent(id)}/versions`, payload);
3821
4373
  return data;
3822
4374
  }
3823
4375
  async versions(id) {
3824
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/versions`);
4376
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/versions`);
3825
4377
  return data;
3826
4378
  }
3827
4379
  async deploy(id, payload) {
3828
- const { data } = await this.client.post(`/satellites/templates/${encodeURIComponent(id)}/deploy`, payload);
4380
+ const { data } = await this.client.post(`/v1/satellites/templates/${encodeURIComponent(id)}/deploy`, payload);
3829
4381
  return data;
3830
4382
  }
3831
4383
  async rollback(id, payload) {
3832
- const { data } = await this.client.post(`/satellites/templates/${encodeURIComponent(id)}/rollback`, payload);
4384
+ const { data } = await this.client.post(`/v1/satellites/templates/${encodeURIComponent(id)}/rollback`, payload);
3833
4385
  return data;
3834
4386
  }
3835
4387
  async permissions(id) {
3836
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/permissions`);
4388
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/permissions`);
3837
4389
  return data;
3838
4390
  }
3839
4391
  async logs(id, params = {}) {
3840
4392
  const since = params.since instanceof Date ? params.since.toISOString() : params.since;
3841
- const { data } = await this.client.get(`/satellites/templates/${encodeURIComponent(id)}/logs`, {
4393
+ const { data } = await this.client.get(`/v1/satellites/templates/${encodeURIComponent(id)}/logs`, {
3842
4394
  params: since ? { since } : undefined,
3843
4395
  });
3844
4396
  return data;
3845
4397
  }
3846
4398
  async execute(id, command, payload = {}) {
3847
- const { data } = await this.client.post(`/satellites/${encodeURIComponent(id)}/commands/${encodeURIComponent(command)}/execute`, payload);
4399
+ const { data } = await this.client.post(`/v1/satellites/${encodeURIComponent(id)}/commands/${encodeURIComponent(command)}/execute`, payload);
3848
4400
  return data;
3849
4401
  }
3850
4402
  }
3851
4403
 
4404
+ const BASE = "/luma/transactions/v1";
4405
+ /**
4406
+ * Transactions client — billing/subscriptions, invoices, credits/balance,
4407
+ * usage pricing and per-project billing-mode overrides. All routes go
4408
+ * through the `transactions/…` gateway prefix (`/luma/transactions/v1/...`),
4409
+ * matching the transactions service's REST surface
4410
+ * (`internal/controllers/{subscription,invoices,topup,credit_history,billing_modes,prices,balance}.go`).
4411
+ *
4412
+ * This is the **billing** service — not distributed/database transactions.
4413
+ */
4414
+ class Transactions extends PlatformBaseClient {
4415
+ // ---------------------------------------------------------------
4416
+ // Subscriptions
4417
+ // ---------------------------------------------------------------
4418
+ /**
4419
+ * List all subscriptions (including expired) for the current project.
4420
+ *
4421
+ * @example
4422
+ * const subs = await platform.transactions().getSubscriptions()
4423
+ */
4424
+ async getSubscriptions() {
4425
+ return await this.client.get(`${BASE}/billing/subscription`);
4426
+ }
4427
+ /**
4428
+ * Renew an expired subscription (and any others sharing its bundle
4429
+ * `ref_no`) — creates a renewal invoice and returns a checkout link.
4430
+ */
4431
+ async renewSubscription(payload) {
4432
+ return await this.client.post(`${BASE}/subscription/renew`, payload);
4433
+ }
4434
+ /**
4435
+ * Cancel a subscription. Issues a refund automatically if still within
4436
+ * the refund period.
4437
+ */
4438
+ async cancelSubscription(payload) {
4439
+ return await this.client.post(`${BASE}/subscription/cancel`, payload);
4440
+ }
4441
+ // ---------------------------------------------------------------
4442
+ // Invoices
4443
+ // ---------------------------------------------------------------
4444
+ /**
4445
+ * List all invoices for the current project.
4446
+ */
4447
+ async getInvoices() {
4448
+ return await this.client.get(`${BASE}/billing/invoices`);
4449
+ }
4450
+ /**
4451
+ * Get a single invoice by uuid.
4452
+ */
4453
+ async getInvoice(uuid) {
4454
+ return await this.client.get(`${BASE}/billing/invoice/${uuid}`);
4455
+ }
4456
+ /**
4457
+ * Download an invoice as a PDF. Resolves with the raw PDF bytes
4458
+ * (`responseType: "arraybuffer"`).
4459
+ *
4460
+ * @example
4461
+ * const { data } = await platform.transactions().getInvoicePdf(uuid)
4462
+ * fs.writeFileSync("invoice.pdf", Buffer.from(data))
4463
+ */
4464
+ async getInvoicePdf(uuid) {
4465
+ return await this.client.get(`${BASE}/billing/invoice/${uuid}/pdf`, {
4466
+ responseType: "arraybuffer",
4467
+ });
4468
+ }
4469
+ // ---------------------------------------------------------------
4470
+ // Balance / credits / top-up
4471
+ // ---------------------------------------------------------------
4472
+ /**
4473
+ * Get the current project's credit balance.
4474
+ */
4475
+ async getBalance() {
4476
+ return await this.client.get(`${BASE}/billing/balance`);
4477
+ }
4478
+ /**
4479
+ * Generate a checkout link to manually top up the project's credit balance.
4480
+ */
4481
+ async topUp(payload) {
4482
+ return await this.client.post(`${BASE}/billing/topup`, payload);
4483
+ }
4484
+ /**
4485
+ * Get the project's credit activity (deductions/top-ups) history, paginated.
4486
+ */
4487
+ async getCreditsHistory(query) {
4488
+ return await this.client.get(`${BASE}/billing/credits/history`, {
4489
+ params: query,
4490
+ });
4491
+ }
4492
+ // ---------------------------------------------------------------
4493
+ // Prices
4494
+ // ---------------------------------------------------------------
4495
+ /**
4496
+ * Get the usage-based pricing table for a given currency.
4497
+ *
4498
+ * @param currency - ISO 4217 currency code, e.g. "USD" or "RSD".
4499
+ */
4500
+ async getPrices(currency) {
4501
+ return await this.client.get(`${BASE}/prices/${currency}`);
4502
+ }
4503
+ // ---------------------------------------------------------------
4504
+ // Billing modes (per-project usage billing overrides)
4505
+ // ---------------------------------------------------------------
4506
+ /**
4507
+ * Get the project's usage-billing-mode overrides plus platform defaults.
4508
+ */
4509
+ async getBillingModes() {
4510
+ return await this.client.get(`${BASE}/billing/billing-modes`);
4511
+ }
4512
+ /**
4513
+ * Set the billing mode ("credits" | "hybrid" | "invoice") for a usage
4514
+ * option code on the current project.
4515
+ */
4516
+ async updateBillingModes(payload) {
4517
+ return await this.client.put(`${BASE}/billing/billing-modes`, payload);
4518
+ }
4519
+ }
4520
+
4521
+ // apis
4522
+ class Platform extends PlatformBaseClient {
4523
+ getPlatformClient() {
4524
+ return this.client;
4525
+ }
4526
+ getPlatformBaseURL() {
4527
+ var _a;
4528
+ return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
4529
+ }
4530
+ apiUser() {
4531
+ return (new APIUser()).setClient(this.client);
4532
+ }
4533
+ function() {
4534
+ return (new Functions()).setClient(this.client);
4535
+ }
4536
+ user() {
4537
+ return (new Users()).setClient(this.client);
4538
+ }
4539
+ app(appType) {
4540
+ return (new Apps(appType)).setClient(this.client);
4541
+ }
4542
+ forge() {
4543
+ return (new Forge()).setClient(this.client);
4544
+ }
4545
+ kortex() {
4546
+ return (new Kortex()).setClient(this.client);
4547
+ }
4548
+ component(ref) {
4549
+ return (new Component(ref)).setClient(this.client);
4550
+ }
4551
+ componentUtils() {
4552
+ return (new ComponentUtils()).setClient(this.client);
4553
+ }
4554
+ ratchet() {
4555
+ return (new Ratchet()).setClient(this.client);
4556
+ }
4557
+ sandbox() {
4558
+ return (new Sandbox()).setClient(this.client);
4559
+ }
4560
+ system() {
4561
+ return (new System()).setClient(this.client);
4562
+ }
4563
+ workflow() {
4564
+ return (new Workflow()).setClient(this.client);
4565
+ }
4566
+ thunder() {
4567
+ return (new Thunder()).setClient(this.client);
4568
+ }
4569
+ project() {
4570
+ return (new Project()).setClient(this.client);
4571
+ }
4572
+ config() {
4573
+ return (new Config()).setClient(this.client);
4574
+ }
4575
+ /**
4576
+ * Convenience factory for the Integrations gateway façade.
4577
+ *
4578
+ * Integrations live behind a different gateway (`INTEGRATION_API` /
4579
+ * `host/luma/integrations`) than the rest of the platform API, so this
4580
+ * returns an independently-configured `Integrations` client (it does not
4581
+ * reuse `this.client`, whose base URL points at the platform host). The
4582
+ * Platform's resolved token/env/host are propagated so the child client
4583
+ * carries the same credentials.
4584
+ */
4585
+ integrations() {
4586
+ return new Integrations(this.getIntegrationsGatewayOptions());
4587
+ }
4588
+ /**
4589
+ * Convenience factory for the Satellites (custom JSON-RPC integrations) client.
4590
+ *
4591
+ * Same gateway note as `integrations()` — Satellites talks to the
4592
+ * integrations gateway, not the platform host, so a fresh, independently
4593
+ * configured client is returned, with the Platform's credentials propagated.
4594
+ */
4595
+ satellites() {
4596
+ return new Satellites(this.getIntegrationsGatewayOptions());
4597
+ }
4598
+ /**
4599
+ * Builds the options for a child integrations-gateway client (`Integrations`/
4600
+ * `Satellites`), propagating this Platform's resolved token/env, and deriving
4601
+ * the gateway host from this Platform's host when one was explicitly set.
4602
+ * When `this.host` is unset, `host` is left `undefined` so the child client's
4603
+ * own env-var/default resolution applies.
4604
+ */
4605
+ getIntegrationsGatewayOptions() {
4606
+ var _a, _b;
4607
+ return {
4608
+ token: (_a = this.token) !== null && _a !== void 0 ? _a : undefined,
4609
+ env: (_b = this.env) !== null && _b !== void 0 ? _b : undefined,
4610
+ host: this.host ? `${this.host.replace(/\/+$/, "")}/luma/integrations` : undefined,
4611
+ };
4612
+ }
4613
+ /**
4614
+ * Transactions (billing) client — subscriptions, invoices, credits/balance,
4615
+ * usage pricing and billing-mode overrides. Reached through the platform
4616
+ * gateway (`transactions/…`), so it reuses `this.client` like the other
4617
+ * native/proxied-service factories.
4618
+ *
4619
+ * This is the **billing** service — not distributed/database transactions.
4620
+ */
4621
+ transactions() {
4622
+ return (new Transactions()).setClient(this.client);
4623
+ }
4624
+ /**
4625
+ * Alias for `transactions()` — reads more naturally at call sites that
4626
+ * only care about billing (`platform.billing().getBalance()`).
4627
+ */
4628
+ billing() {
4629
+ return this.transactions();
4630
+ }
4631
+ }
4632
+
3852
4633
  // PRN — Protokol Resource Name
3853
4634
  //
3854
4635
  // Format:
@@ -4027,6 +4808,7 @@ var ProtokolSDK010 = (function (exports, axios) {
4027
4808
  exports.System = System;
4028
4809
  exports.Thunder = Thunder;
4029
4810
  exports.Timber = Timber;
4811
+ exports.Transactions = Transactions;
4030
4812
  exports.Users = Users;
4031
4813
  exports.VPFR = VPFR;
4032
4814
  exports.Workflow = Workflow;