@muxoai/sdk 1.3.0 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.agents/plugins/marketplace.json +2 -2
  2. package/.claude-plugin/marketplace.json +19 -4
  3. package/.codex/config.toml +9 -2
  4. package/ARCHITECTURE.md +16 -6
  5. package/README.md +69 -24
  6. package/dist/clerk.d.ts +35 -0
  7. package/dist/clerk.js +201 -0
  8. package/dist/cli.js +1677 -103
  9. package/dist/composio-catalog.d.ts +234 -0
  10. package/dist/composio-catalog.js +1894 -0
  11. package/dist/config.d.ts +16 -0
  12. package/dist/config.js +27 -1
  13. package/dist/durable-workflow.d.ts +112 -0
  14. package/dist/durable-workflow.js +284 -0
  15. package/dist/engine.d.ts +377 -6
  16. package/dist/engine.js +1919 -94
  17. package/dist/index.d.ts +3 -0
  18. package/dist/index.js +3 -0
  19. package/dist/mcp-schema.d.ts +286 -0
  20. package/dist/mcp-schema.js +2580 -0
  21. package/dist/mcp.d.ts +2 -25
  22. package/dist/mcp.js +1008 -507
  23. package/dist/memory-graph.d.ts +45 -0
  24. package/dist/memory-graph.js +293 -0
  25. package/dist/nl.js +214 -35
  26. package/dist/oauth.d.ts +32 -0
  27. package/dist/oauth.js +134 -0
  28. package/dist/oss-suite.d.ts +217 -0
  29. package/dist/oss-suite.js +836 -0
  30. package/dist/policy.d.ts +190 -0
  31. package/dist/policy.js +1597 -0
  32. package/dist/providers/composio-instant.d.ts +4 -0
  33. package/dist/providers/composio-instant.js +890 -535
  34. package/dist/providers/composio-sdk.d.ts +126 -5
  35. package/dist/providers/composio-sdk.js +902 -79
  36. package/dist/providers/microsoft-governance.d.ts +89 -3
  37. package/dist/providers/microsoft-governance.js +673 -26
  38. package/dist/providers/stripe-billing.d.ts +42 -0
  39. package/dist/providers/stripe-billing.js +244 -5
  40. package/dist/providers/stripe-projects.d.ts +459 -4
  41. package/dist/providers/stripe-projects.js +2674 -122
  42. package/dist/providers/supermemory.d.ts +102 -6
  43. package/dist/providers/supermemory.js +609 -55
  44. package/dist/provisioning-managed.d.ts +50 -0
  45. package/dist/provisioning-managed.js +155 -0
  46. package/dist/sdk.d.ts +728 -7
  47. package/dist/sdk.js +539 -10
  48. package/dist/server.js +2744 -321
  49. package/dist/store.d.ts +138 -6
  50. package/dist/store.js +932 -58
  51. package/dist/types.d.ts +330 -4
  52. package/dist/ui/console-html.d.ts +62 -0
  53. package/dist/ui/console-html.js +3742 -2228
  54. package/dist/ui/design-tokens.d.ts +177 -0
  55. package/dist/ui/design-tokens.js +210 -0
  56. package/dist/version.d.ts +1 -0
  57. package/dist/version.js +1 -0
  58. package/package.json +6 -5
  59. package/plugins/muxo/.app.json +1 -1
  60. package/plugins/muxo/.claude-plugin/plugin.json +3 -3
  61. package/plugins/muxo/.codex-plugin/plugin.json +19 -10
  62. package/plugins/muxo/.cursor-plugin/plugin.json +30 -0
  63. package/plugins/muxo/.mcp.json +1 -33
  64. package/plugins/muxo/assets/logo.png +0 -0
  65. package/plugins/muxo/hooks/session-start.sh +16 -4
  66. package/plugins/muxo/hooks/user-prompt-submit.sh +14 -1
  67. package/plugins/muxo/mcp.json +0 -10
  68. package/plugins/muxo/plugin.json +65 -8
  69. package/plugins/muxo/skills/muxo/SKILL.md +142 -14
  70. package/plugins/muxo/skills/muxo/agents/openai.yaml +12 -0
  71. package/plugins/muxo/skills/muxo/references/cli.md +9 -3
  72. package/plugins/muxo/skills/muxo/references/mcp.md +22 -10
  73. package/plugins/muxo/skills/muxo-activity-summary/SKILL.md +81 -0
  74. package/plugins/muxo/skills/setup/SKILL.md +17 -3
  75. package/plugins/muxo/skills/setup/agents/openai.yaml +12 -0
  76. package/src/catalogues/stripe-projects-catalog.json +140 -0
package/dist/sdk.js CHANGED
@@ -1,3 +1,21 @@
1
+ /** Error thrown for any non-OK Muxo API response. Carries the machine-readable code and payload. */
2
+ export class MuxoApiError extends Error {
3
+ status;
4
+ code;
5
+ url;
6
+ checkoutUrl;
7
+ data;
8
+ constructor(status, payload) {
9
+ super(String(payload.error || `Muxo request failed with HTTP ${status}`));
10
+ this.name = "MuxoApiError";
11
+ this.status = status;
12
+ this.code = typeof payload.code === "string" ? payload.code : undefined;
13
+ this.url = typeof payload.url === "string" ? payload.url : undefined;
14
+ this.checkoutUrl =
15
+ typeof payload.checkoutUrl === "string" ? payload.checkoutUrl : undefined;
16
+ this.data = payload;
17
+ }
18
+ }
1
19
  export class MuxoClient {
2
20
  baseUrl;
3
21
  apiKeyResolver;
@@ -41,7 +59,7 @@ export class MuxoClient {
41
59
  });
42
60
  const payload = (await res.json());
43
61
  if (!res.ok || payload.ok === false) {
44
- throw new Error(String(payload.error || `Muxo request failed with HTTP ${res.status}`));
62
+ throw new MuxoApiError(res.status, payload);
45
63
  }
46
64
  return payload;
47
65
  }
@@ -52,6 +70,26 @@ export class MuxoClient {
52
70
  harness: params.harness || "muxo-sdk",
53
71
  });
54
72
  }
73
+ static async register(params, baseUrl = "https://app.muxo.ai") {
74
+ const client = new MuxoClient({ baseUrl });
75
+ return client.register(params);
76
+ }
77
+ static async login(params, baseUrl = "https://app.muxo.ai") {
78
+ const client = new MuxoClient({ baseUrl });
79
+ return client.login(params);
80
+ }
81
+ async register(params) {
82
+ return this.request("/api/v1/auth/register", {
83
+ method: "POST",
84
+ body: params,
85
+ });
86
+ }
87
+ async login(params) {
88
+ return this.request("/api/v1/auth/login", {
89
+ method: "POST",
90
+ body: params,
91
+ });
92
+ }
55
93
  async signupAgent(params) {
56
94
  return this.request("/api/v1/agents/signup", {
57
95
  method: "POST",
@@ -80,6 +118,10 @@ export class MuxoClient {
80
118
  if (rpcRes.error) {
81
119
  throw new Error(rpcRes.error.message || "MCP call failed");
82
120
  }
121
+ if (rpcRes.result?.isError) {
122
+ const errObj = rpcRes.result.structuredContent;
123
+ throw new Error(String(errObj?.error || rpcRes.result.content?.[0]?.text || "MCP tool execution failed"));
124
+ }
83
125
  if (rpcRes.result?.structuredContent) {
84
126
  return rpcRes.result.structuredContent;
85
127
  }
@@ -111,9 +153,26 @@ export class MuxoClient {
111
153
  body: params,
112
154
  });
113
155
  }
114
- async approvePlan(planId) {
156
+ async getPlan(planId, options) {
157
+ const qs = new URLSearchParams();
158
+ if (options?.waitForApproval)
159
+ qs.set("wait_for_approval", "true");
160
+ if (options?.timeoutSeconds !== undefined) {
161
+ qs.set("timeout_seconds", String(options.timeoutSeconds));
162
+ }
163
+ const suffix = qs.toString() ? `?${qs.toString()}` : "";
164
+ return this.request(`/api/v1/plans/${encodeURIComponent(planId)}${suffix}`);
165
+ }
166
+ async waitForPlanApproval(planId, timeoutSeconds = 25) {
167
+ return this.request(`/api/v1/plans/${encodeURIComponent(planId)}/wait`, {
168
+ method: "POST",
169
+ body: { timeoutSeconds },
170
+ });
171
+ }
172
+ async approvePlan(planId, decision = "approved") {
115
173
  return this.request(`/api/v1/plans/${encodeURIComponent(planId)}/approve`, {
116
174
  method: "POST",
175
+ body: { decision },
117
176
  });
118
177
  }
119
178
  async executePlan(planId) {
@@ -121,16 +180,39 @@ export class MuxoClient {
121
180
  method: "POST",
122
181
  });
123
182
  }
183
+ async getRun(runId) {
184
+ return this.request(`/api/v1/runs/${encodeURIComponent(runId)}`);
185
+ }
186
+ async cancelRun(runId, reason) {
187
+ return this.request(`/api/v1/runs/${encodeURIComponent(runId)}/cancel`, {
188
+ method: "POST",
189
+ body: reason ? { reason } : {},
190
+ });
191
+ }
124
192
  async exec(toolSlug, input = {}, options = {}) {
125
193
  const planned = await this.planAction({
126
194
  toolSlug,
127
195
  input,
128
196
  reason: options.reason,
197
+ fundingMode: options.fundingMode,
129
198
  });
130
199
  let plan = planned.plan;
131
200
  if (plan.approvalStatus === "pending_approval" && options.approve) {
132
- const approved = await this.approvePlan(plan.id);
133
- plan = approved.plan;
201
+ try {
202
+ const approved = await this.approvePlan(plan.id);
203
+ plan = approved.plan;
204
+ }
205
+ catch (err) {
206
+ if (err instanceof MuxoApiError && err.code === "human_required") {
207
+ throw new MuxoApiError(err.status, {
208
+ ...err.data,
209
+ planId: plan.id,
210
+ approvalUrl: err.url,
211
+ error: `Plan ${plan.id} needs approval from a signed-in person at ${err.url || "the Muxo console"}; API keys cannot approve plans.`,
212
+ });
213
+ }
214
+ throw err;
215
+ }
134
216
  }
135
217
  const executed = await this.executePlan(plan.id);
136
218
  return {
@@ -151,8 +233,29 @@ export class MuxoClient {
151
233
  valid: isOk,
152
234
  verified: isOk,
153
235
  receipt: res.receipt,
236
+ agenticReceiptValid: res.agenticReceiptValid,
237
+ explanation: res.explanation,
154
238
  };
155
239
  }
240
+ async verifyReceiptChain(limit = 100) {
241
+ return this.request(`/api/v1/receipts/verify-chain?limit=${encodeURIComponent(String(limit))}`);
242
+ }
243
+ async getMemoryGraph(queryOrOptions) {
244
+ const opts = typeof queryOrOptions === "string"
245
+ ? { query: queryOrOptions }
246
+ : queryOrOptions || {};
247
+ const qs = new URLSearchParams();
248
+ if (opts.query)
249
+ qs.set("query", opts.query);
250
+ if (opts.asOf)
251
+ qs.set("as_of", opts.asOf);
252
+ if (opts.focalEntity)
253
+ qs.set("focal_entity", opts.focalEntity);
254
+ if (opts.maxHops !== undefined)
255
+ qs.set("max_hops", String(opts.maxHops));
256
+ const suffix = qs.toString() ? `?${qs.toString()}` : "";
257
+ return this.request(`/api/v1/memory/graph${suffix}`);
258
+ }
156
259
  async startConnection(paramsOrProvider) {
157
260
  const body = typeof paramsOrProvider === "string"
158
261
  ? { provider: paramsOrProvider }
@@ -199,7 +302,13 @@ export class MuxoClient {
199
302
  };
200
303
  }
201
304
  async getBillingStatus() {
202
- return this.getSettlements();
305
+ const res = await this.request("/api/v1/billing/status");
306
+ if (res.settlementSummary &&
307
+ res.settlementSummary.totalCustomerChargedCredits === undefined) {
308
+ res.settlementSummary.totalCustomerChargedCredits =
309
+ res.settlementSummary.totalCreditsConsumed;
310
+ }
311
+ return res;
203
312
  }
204
313
  async settlements() {
205
314
  const res = await this.getSettlements();
@@ -221,14 +330,116 @@ export class MuxoClient {
221
330
  const suffix = query ? `?query=${encodeURIComponent(query)}` : "";
222
331
  return this.request(`/api/v1/memory${suffix}`);
223
332
  }
333
+ async addMemory(paramsOrContent) {
334
+ const body = typeof paramsOrContent === "string"
335
+ ? { title: paramsOrContent.slice(0, 60), content: paramsOrContent }
336
+ : paramsOrContent;
337
+ return this.request("/api/v1/memory", {
338
+ method: "POST",
339
+ body,
340
+ });
341
+ }
342
+ async deleteMemory(id) {
343
+ return this.request(`/api/v1/memory/${encodeURIComponent(id)}`, {
344
+ method: "DELETE",
345
+ });
346
+ }
347
+ async getMemoryFacts(options = {}) {
348
+ const opts = typeof options === "boolean" ? { includeHistorical: options } : options;
349
+ const params = new URLSearchParams();
350
+ params.set("historical", opts.includeHistorical === false ? "false" : "true");
351
+ if (opts.query)
352
+ params.set("query", opts.query);
353
+ if (opts.subject)
354
+ params.set("subject", opts.subject);
355
+ if (opts.predicate)
356
+ params.set("predicate", opts.predicate);
357
+ if (opts.limit)
358
+ params.set("limit", String(opts.limit));
359
+ return this.request(`/api/v1/memory/facts?${params.toString()}`);
360
+ }
361
+ async listTemporalFacts(options) {
362
+ return this.getMemoryFacts(options);
363
+ }
364
+ async forgetMemory(queryOrParams) {
365
+ const query = (typeof queryOrParams === "string" ? queryOrParams : queryOrParams.query)?.trim();
366
+ if (!query) {
367
+ throw new Error("forgetMemory requires a non-empty query");
368
+ }
369
+ return this.request("/api/v1/memory/forget", {
370
+ method: "POST",
371
+ body: { query },
372
+ });
373
+ }
374
+ async getGovernanceStatus() {
375
+ return this.request("/api/v1/governance");
376
+ }
377
+ async getGuardrails() {
378
+ return this.request("/api/v1/guardrails");
379
+ }
380
+ async setGuardrail(promptOrParams) {
381
+ const prompt = typeof promptOrParams === "string"
382
+ ? promptOrParams
383
+ : promptOrParams.prompt;
384
+ return this.request("/api/v1/guardrails", {
385
+ method: "POST",
386
+ body: { prompt },
387
+ });
388
+ }
389
+ async resetGuardrails() {
390
+ return this.request("/api/v1/guardrails", {
391
+ method: "POST",
392
+ body: { reset: true },
393
+ });
394
+ }
395
+ async setKillSwitch(action, reason) {
396
+ return this.request("/api/v1/governance/kill-switch", {
397
+ method: "POST",
398
+ body: reason ? { action, reason } : { action },
399
+ });
400
+ }
401
+ async scanContext(contentOrParams) {
402
+ const body = typeof contentOrParams === "string"
403
+ ? { content: contentOrParams }
404
+ : contentOrParams;
405
+ return this.request("/api/v1/governance/scan-context", {
406
+ method: "POST",
407
+ body,
408
+ });
409
+ }
410
+ async updatePolicy(policy) {
411
+ return this.request("/api/v1/policy", {
412
+ method: "POST",
413
+ body: policy,
414
+ });
415
+ }
416
+ async getPolicy() {
417
+ return this.request("/api/v1/policy");
418
+ }
419
+ async getContext(query) {
420
+ const suffix = query ? `?query=${encodeURIComponent(query)}` : "";
421
+ return this.request(`/api/v1/context${suffix}`);
422
+ }
423
+ async listReceipts(limit = 25) {
424
+ return this.request(`/api/v1/receipts?limit=${encodeURIComponent(String(limit))}`);
425
+ }
426
+ async remember(instruction) {
427
+ return this.request("/api/v1/memory", {
428
+ method: "POST",
429
+ body: { prompt: instruction },
430
+ });
431
+ }
224
432
  async do(prompt, options = {}) {
433
+ const isDryRun = options.dryRun === true || options.planOnly === true;
225
434
  return this.request("/api/v1/do", {
226
435
  method: "POST",
227
436
  body: {
228
437
  prompt,
229
438
  input: options.input,
230
439
  autoApprove: options.autoApprove !== false,
231
- dryRun: options.dryRun === true,
440
+ dryRun: isDryRun,
441
+ planOnly: isDryRun,
442
+ fundingMode: options.fundingMode,
232
443
  },
233
444
  });
234
445
  }
@@ -249,16 +460,50 @@ export class MuxoClient {
249
460
  method: "DELETE",
250
461
  });
251
462
  }
252
- async upgradePlan() {
253
- return this.request("/api/v1/billing/upgrade", {
463
+ /** Lists plans, prices, and credit packs. No auth required. */
464
+ async getPlans() {
465
+ return this.request("/api/v1/billing/plans");
466
+ }
467
+ /**
468
+ * Moves the workspace to a plan. A first subscription returns a Stripe checkout URL
469
+ * (`payment_required`); changing an existing subscription returns a billing-portal URL.
470
+ * Plan changes are confirmed by a signed-in person; API keys get `human_required`.
471
+ */
472
+ async upgradePlan(options = {}) {
473
+ try {
474
+ return await this.request("/api/v1/billing/upgrade", {
475
+ method: "POST",
476
+ body: {
477
+ tier: options.tier || "starter",
478
+ interval: options.interval || "month",
479
+ },
480
+ });
481
+ }
482
+ catch (err) {
483
+ if (err instanceof MuxoApiError &&
484
+ (err.code === "payment_required" || err.code === "human_required")) {
485
+ return err.data;
486
+ }
487
+ throw err;
488
+ }
489
+ }
490
+ /**
491
+ * Opens the Stripe billing portal to manage payment details, switch plans, or cancel.
492
+ * Signed-in people only; API keys get a `human_required` MuxoApiError.
493
+ */
494
+ async openBillingPortal() {
495
+ return this.request("/api/v1/billing/portal", {
254
496
  method: "POST",
255
497
  body: {},
256
498
  });
257
499
  }
258
- async createCheckoutSession(kind = "credit_topup") {
500
+ async createCheckoutSession(kind = "credit_topup", optionsOrCredits) {
501
+ const opts = typeof optionsOrCredits === "number"
502
+ ? { credits: optionsOrCredits }
503
+ : optionsOrCredits || {};
259
504
  return this.request("/api/v1/billing/checkout", {
260
505
  method: "POST",
261
- body: { kind },
506
+ body: { kind, ...opts },
262
507
  });
263
508
  }
264
509
  async verifyCheckoutSession(sessionId) {
@@ -267,4 +512,288 @@ export class MuxoClient {
267
512
  body: { sessionId },
268
513
  });
269
514
  }
515
+ // Stripe v2 Provisioning API (`Stripe-Version: 2026-09-30.preview`) SDK Methods
516
+ async createProvisioningConnectedAccount(params) {
517
+ return this.request("/api/v1/provisioning/connected_accounts", {
518
+ method: "POST",
519
+ body: params || {},
520
+ });
521
+ }
522
+ async getProvisioningConnectedAccount(accountId) {
523
+ if (accountId) {
524
+ return this.request(`/api/v1/provisioning/connected_accounts/${encodeURIComponent(accountId)}`);
525
+ }
526
+ return this.request("/api/v1/provisioning/connected_accounts");
527
+ }
528
+ async createProvisioningConnectedAccountLink(params) {
529
+ return this.request("/api/v1/provisioning/connected_account_links", {
530
+ method: "POST",
531
+ body: params || {},
532
+ });
533
+ }
534
+ async createProvisioningConnectedAccountSession(params) {
535
+ return this.request("/api/v1/provisioning/connected_account_sessions", {
536
+ method: "POST",
537
+ body: params || {},
538
+ });
539
+ }
540
+ async checkProvisioningEligibility() {
541
+ return this.request("/api/v1/provisioning/eligibility");
542
+ }
543
+ async listProvisioningProviders(params) {
544
+ const qs = new URLSearchParams();
545
+ if (params?.catalog)
546
+ qs.set("catalog", params.catalog);
547
+ if (params?.limit)
548
+ qs.set("limit", String(params.limit));
549
+ if (params?.page)
550
+ qs.set("page", params.page);
551
+ const suffix = qs.toString() ? `?${qs.toString()}` : "";
552
+ return this.request(`/api/v1/provisioning/catalog/providers${suffix}`);
553
+ }
554
+ async listProvisioningServices(params) {
555
+ const qs = new URLSearchParams();
556
+ if (params?.catalog)
557
+ qs.set("catalog", params.catalog);
558
+ if (params?.provider_name)
559
+ qs.set("provider_name", params.provider_name);
560
+ if (params?.provider_id)
561
+ qs.set("provider_id", params.provider_id);
562
+ if (params?.limit)
563
+ qs.set("limit", String(params.limit));
564
+ if (params?.page)
565
+ qs.set("page", params.page);
566
+ const suffix = qs.toString() ? `?${qs.toString()}` : "";
567
+ return this.request(`/api/v1/provisioning/catalog/services${suffix}`);
568
+ }
569
+ async getProvisioningPaymentProfile(params) {
570
+ const qs = new URLSearchParams();
571
+ if (params?.provider)
572
+ qs.set("provider", params.provider);
573
+ if (params?.livemode !== undefined)
574
+ qs.set("livemode", String(params.livemode));
575
+ const suffix = qs.toString() ? `?${qs.toString()}` : "";
576
+ return this.request(`/api/v1/provisioning/payment_profile${suffix}`);
577
+ }
578
+ async createProvisioningPaymentMethodRequest(params) {
579
+ return this.request("/api/v1/provisioning/payment_method_requests", {
580
+ method: "POST",
581
+ body: params || {},
582
+ });
583
+ }
584
+ async listProvisioningProviderConnections(params) {
585
+ const qs = new URLSearchParams();
586
+ if (params?.provider)
587
+ qs.set("provider", params.provider);
588
+ if (params?.limit)
589
+ qs.set("limit", String(params.limit));
590
+ if (params?.page)
591
+ qs.set("page", params.page);
592
+ const suffix = qs.toString() ? `?${qs.toString()}` : "";
593
+ return this.request(`/api/v1/provisioning/provider_connections${suffix}`);
594
+ }
595
+ async createProvisioningProviderConnectionRequest(params) {
596
+ return this.request("/api/v1/provisioning/provider_connection_requests", {
597
+ method: "POST",
598
+ body: params,
599
+ });
600
+ }
601
+ async listProvisioningProjects(params) {
602
+ const qs = new URLSearchParams();
603
+ if (params?.limit)
604
+ qs.set("limit", String(params.limit));
605
+ if (params?.page)
606
+ qs.set("page", params.page);
607
+ const suffix = qs.toString() ? `?${qs.toString()}` : "";
608
+ return this.request(`/api/v1/provisioning/projects${suffix}`);
609
+ }
610
+ async createProvisioningProject(params) {
611
+ return this.request("/api/v1/provisioning/projects", {
612
+ method: "POST",
613
+ body: params,
614
+ });
615
+ }
616
+ async listProvisioningResources(params) {
617
+ const qs = new URLSearchParams();
618
+ if (params?.project)
619
+ qs.set("project", params.project);
620
+ if (params?.provider)
621
+ qs.set("provider", params.provider);
622
+ if (params?.limit)
623
+ qs.set("limit", String(params.limit));
624
+ if (params?.page)
625
+ qs.set("page", params.page);
626
+ const suffix = qs.toString() ? `?${qs.toString()}` : "";
627
+ return this.request(`/api/v1/provisioning/resources${suffix}`);
628
+ }
629
+ async createProvisioningResource(params) {
630
+ return this.request("/api/v1/provisioning/resources", {
631
+ method: "POST",
632
+ body: params,
633
+ });
634
+ }
635
+ async revealResourceAccessConfiguration(resourceId) {
636
+ return this.request(`/api/v1/provisioning/resources/${encodeURIComponent(resourceId)}/reveal_access_configuration`, {
637
+ method: "POST",
638
+ body: {},
639
+ });
640
+ }
641
+ async getResourceSecrets(resourceId) {
642
+ return this.request(`/api/v1/resources/${encodeURIComponent(resourceId)}/secrets`);
643
+ }
644
+ // ---------------------------------------------------------------------------
645
+ // Multi-Workspace & Team API Key Onboarding
646
+ // ---------------------------------------------------------------------------
647
+ async listWorkspaces() {
648
+ return this.request("/api/v1/workspaces");
649
+ }
650
+ async createWorkspace(params) {
651
+ return this.request("/api/v1/workspaces", {
652
+ method: "POST",
653
+ body: params,
654
+ });
655
+ }
656
+ async switchWorkspace(workspaceId) {
657
+ return this.request("/api/v1/workspaces/switch", {
658
+ method: "POST",
659
+ body: { workspaceId },
660
+ });
661
+ }
662
+ async joinWorkspaceWithApiKey(apiKey) {
663
+ return this.request("/api/v1/workspaces/join", {
664
+ method: "POST",
665
+ body: { apiKey },
666
+ });
667
+ }
668
+ async onboardTeam(params) {
669
+ return this.request("/api/v1/workspaces/onboard-team", {
670
+ method: "POST",
671
+ body: params,
672
+ });
673
+ }
674
+ // ---------------------------------------------------------------------------
675
+ // Stripe v2 Billing Meter Streams, Event Destinations, Composio Toolkits/Triggers, & Cloudflare Workflows
676
+ // ---------------------------------------------------------------------------
677
+ async updateProvisioningSpendLimit(params) {
678
+ return this.request("/api/v1/provisioning/payment_profile/update_limit", {
679
+ method: "POST",
680
+ body: {
681
+ usage_limits: {
682
+ max_amount: String(params.max_amount),
683
+ currency: params.currency || "usd",
684
+ recurring_interval: params.recurring_interval || "month",
685
+ },
686
+ provider: params.provider,
687
+ },
688
+ });
689
+ }
690
+ async createProvisioningEventDestination(params) {
691
+ return this.request("/api/v1/provisioning/event_destinations", {
692
+ method: "POST",
693
+ body: params,
694
+ });
695
+ }
696
+ async recordBillingMeterEvent(params) {
697
+ return this.request("/api/v1/billing/meter_events", {
698
+ method: "POST",
699
+ body: params,
700
+ });
701
+ }
702
+ async listBillingMeterEvents(limit = 50) {
703
+ return this.request(`/api/v1/billing/meter_events?limit=${limit}`);
704
+ }
705
+ async listToolkits(params) {
706
+ const qs = new URLSearchParams();
707
+ if (params?.category)
708
+ qs.set("category", params.category);
709
+ if (params?.search)
710
+ qs.set("search", params.search);
711
+ const suffix = qs.toString() ? `?${qs.toString()}` : "";
712
+ return this.request(`/api/v1/toolkits${suffix}`);
713
+ }
714
+ async createCustomAuthConfig(params) {
715
+ return this.request("/api/v1/connections/auth-configs", {
716
+ method: "POST",
717
+ body: params,
718
+ });
719
+ }
720
+ async listTriggers(provider) {
721
+ const suffix = provider ? `?provider=${encodeURIComponent(provider)}` : "";
722
+ return this.request(`/api/v1/triggers${suffix}`);
723
+ }
724
+ async enableTrigger(params) {
725
+ return this.request("/api/v1/triggers", {
726
+ method: "POST",
727
+ body: params,
728
+ });
729
+ }
730
+ async ingestTriggerWebhook(params) {
731
+ return this.request("/api/v1/triggers/webhook", {
732
+ method: "POST",
733
+ body: params,
734
+ });
735
+ }
736
+ async executeBatchPlans(params) {
737
+ return this.request("/api/v1/plans/batch", {
738
+ method: "POST",
739
+ body: params,
740
+ });
741
+ }
742
+ async searchMemoryHybrid(query, limit = 10) {
743
+ return this.request(`/api/v1/memory/hybrid?query=${encodeURIComponent(query)}&limit=${limit}`);
744
+ }
745
+ async startDurableWorkflow(params) {
746
+ return this.request("/api/v1/workflows", {
747
+ method: "POST",
748
+ body: params,
749
+ });
750
+ }
751
+ async advanceDurableWorkflow(workflowId, eventPayload) {
752
+ return this.request(`/api/v1/workflows/${encodeURIComponent(workflowId)}/advance`, {
753
+ method: "POST",
754
+ body: eventPayload || {},
755
+ });
756
+ }
757
+ async exportGovernanceArchive() {
758
+ return this.request("/api/v1/governance/archive");
759
+ }
760
+ async getWorkflowHistory(workflowId) {
761
+ return this.request(`/api/v1/workflows/${encodeURIComponent(workflowId)}/history`);
762
+ }
763
+ async signalDurableWorkflow(workflowId, signalName, payload) {
764
+ return this.request(`/api/v1/workflows/${encodeURIComponent(workflowId)}/signal`, {
765
+ method: "POST",
766
+ body: { signalName, payload: payload || {} },
767
+ });
768
+ }
769
+ async rollbackDurableWorkflow(workflowId, params) {
770
+ return this.request(`/api/v1/workflows/${encodeURIComponent(workflowId)}/rollback`, {
771
+ method: "POST",
772
+ body: params || {},
773
+ });
774
+ }
775
+ async getCedarPolicy() {
776
+ return this.request("/api/v1/governance/cedar");
777
+ }
778
+ async evaluateCedarPolicy(params) {
779
+ return this.request("/api/v1/governance/cedar/evaluate", {
780
+ method: "POST",
781
+ body: params,
782
+ });
783
+ }
784
+ async getOtelTraces(limit = 25) {
785
+ return this.request(`/api/v1/telemetry/otlp?limit=${limit}`);
786
+ }
787
+ async listPlaybooks() {
788
+ return this.request("/api/v1/playbooks");
789
+ }
790
+ async runPlaybook(slug, input) {
791
+ return this.request(`/api/v1/playbooks/${encodeURIComponent(slug)}/run`, {
792
+ method: "POST",
793
+ body: { input: input || {} },
794
+ });
795
+ }
796
+ async getRoiAnalytics() {
797
+ return this.request("/api/v1/analytics/roi");
798
+ }
270
799
  }