@muxoai/sdk 1.2.1 → 1.2.2

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 (3) hide show
  1. package/dist/sdk.d.ts +60 -5
  2. package/dist/sdk.js +110 -10
  3. package/package.json +14 -23
package/dist/sdk.d.ts CHANGED
@@ -12,6 +12,22 @@ export declare class MuxoClient {
12
12
  private readonly timeoutMs;
13
13
  constructor(options?: MuxoClientOptions);
14
14
  private request;
15
+ static signup(params?: {
16
+ workspaceName?: string;
17
+ ownerEmail?: string;
18
+ agentName?: string;
19
+ harness?: string;
20
+ }, baseUrl?: string): Promise<{
21
+ ok: true;
22
+ agentId: string;
23
+ workspace: Pick<Workspace, "id" | "name" | "slug" | "tier" | "creditsBalance">;
24
+ apiKey: string;
25
+ mcpEndpoint: string;
26
+ skillUrl: string;
27
+ claimEndpoint: string;
28
+ governanceDid: string;
29
+ supermemoryNamespace: string;
30
+ }>;
15
31
  signupAgent(params: {
16
32
  agentName?: string;
17
33
  harness?: string;
@@ -26,6 +42,14 @@ export declare class MuxoClient {
26
42
  governanceDid: string;
27
43
  supermemoryNamespace: string;
28
44
  }>;
45
+ whoami(): Promise<{
46
+ ok: true;
47
+ workspace: Workspace;
48
+ organization?: Workspace;
49
+ user?: Record<string, unknown>;
50
+ settlementSummary?: SupplierSettlementSummary;
51
+ }>;
52
+ mcpCall<T = Record<string, unknown>>(name: string, args?: Record<string, unknown>): Promise<T>;
29
53
  searchTools(params?: {
30
54
  query?: string;
31
55
  lane?: ProviderLane | "all";
@@ -64,7 +88,23 @@ export declare class MuxoClient {
64
88
  run: ExecutionRun;
65
89
  receipt: ExecutionReceipt;
66
90
  }>;
67
- startConnection(params: {
91
+ exec(toolSlug: string, input?: Record<string, unknown>, options?: {
92
+ reason?: string;
93
+ approve?: boolean;
94
+ }): Promise<{
95
+ ok: true;
96
+ plan: ActionPlan;
97
+ run: ExecutionRun;
98
+ receipt: ExecutionReceipt;
99
+ settlement?: Record<string, unknown> | null;
100
+ }>;
101
+ verifyReceipt(receiptId: string): Promise<{
102
+ ok: true;
103
+ valid: boolean;
104
+ verified: boolean;
105
+ receipt: ExecutionReceipt;
106
+ }>;
107
+ startConnection(paramsOrProvider: string | {
68
108
  provider: string;
69
109
  lane?: ProviderLane;
70
110
  callbackUrl?: string;
@@ -72,12 +112,17 @@ export declare class MuxoClient {
72
112
  ok: true;
73
113
  connection: ConnectionRecord;
74
114
  }>;
75
- waitForConnection(params: {
115
+ waitForConnection(paramsOrProvider: string | {
76
116
  provider: string;
77
117
  timeoutSeconds?: number;
118
+ simulateCallback?: boolean;
119
+ }, options?: {
120
+ timeoutSeconds?: number;
121
+ simulateCallback?: boolean;
78
122
  }): Promise<{
79
123
  ok: true;
80
124
  connection: ConnectionRecord;
125
+ status: ConnectionRecord["status"];
81
126
  ready: boolean;
82
127
  polledAttempts: number;
83
128
  elapsedMs: number;
@@ -92,20 +137,30 @@ export declare class MuxoClient {
92
137
  workspaceId: string;
93
138
  variables: Record<string, string>;
94
139
  dotenv: string;
140
+ includes: (substr: string) => boolean;
95
141
  }>;
96
- topupCredits(params: {
142
+ topupCredits(paramsOrCredits: number | {
97
143
  credits: number;
98
144
  description?: string;
99
- }): Promise<{
145
+ }, description?: string): Promise<{
100
146
  ok: true;
101
147
  creditsAdded: number;
148
+ creditBalance: number;
102
149
  usdPaid: number;
103
150
  workspace: Workspace;
104
151
  settlementSummary: SupplierSettlementSummary;
105
152
  }>;
153
+ getBillingStatus(): Promise<{
154
+ ok: true;
155
+ settlementSummary: SupplierSettlementSummary & {
156
+ totalCustomerChargedCredits?: number;
157
+ };
158
+ }>;
106
159
  getSettlements(): Promise<{
107
160
  ok: true;
108
- settlementSummary: SupplierSettlementSummary;
161
+ settlementSummary: SupplierSettlementSummary & {
162
+ totalCustomerChargedCredits?: number;
163
+ };
109
164
  }>;
110
165
  recallMemory(query?: string): Promise<{
111
166
  ok: true;
package/dist/sdk.js CHANGED
@@ -45,12 +45,50 @@ export class MuxoClient {
45
45
  }
46
46
  return payload;
47
47
  }
48
+ static async signup(params = {}, baseUrl = "https://app.muxo.ai") {
49
+ const client = new MuxoClient({ baseUrl });
50
+ return client.signupAgent({
51
+ agentName: params.agentName || params.workspaceName || "muxo-sdk-agent",
52
+ harness: params.harness || "muxo-sdk",
53
+ });
54
+ }
48
55
  async signupAgent(params) {
49
56
  return this.request("/api/v1/agents/signup", {
50
57
  method: "POST",
51
58
  body: params,
52
59
  });
53
60
  }
61
+ async whoami() {
62
+ const res = await this.mcpCall("get_organization", {});
63
+ const workspace = (res.workspace || res.organization);
64
+ return {
65
+ ok: true,
66
+ ...res,
67
+ workspace,
68
+ };
69
+ }
70
+ async mcpCall(name, args = {}) {
71
+ const rpcRes = await this.request("/mcp", {
72
+ method: "POST",
73
+ body: {
74
+ jsonrpc: "2.0",
75
+ id: Date.now(),
76
+ method: "tools/call",
77
+ params: { name, arguments: args },
78
+ },
79
+ });
80
+ if (rpcRes.error) {
81
+ throw new Error(rpcRes.error.message || "MCP call failed");
82
+ }
83
+ if (rpcRes.result?.structuredContent) {
84
+ return rpcRes.result.structuredContent;
85
+ }
86
+ const text = rpcRes.result?.content?.[0]?.text;
87
+ if (text) {
88
+ return JSON.parse(text);
89
+ }
90
+ return (rpcRes.result || {});
91
+ }
54
92
  async searchTools(params) {
55
93
  const qs = new URLSearchParams();
56
94
  if (params?.query)
@@ -83,32 +121,94 @@ export class MuxoClient {
83
121
  method: "POST",
84
122
  });
85
123
  }
86
- async startConnection(params) {
124
+ async exec(toolSlug, input = {}, options = {}) {
125
+ const planned = await this.planAction({
126
+ toolSlug,
127
+ input,
128
+ reason: options.reason,
129
+ });
130
+ let plan = planned.plan;
131
+ if (plan.approvalStatus === "pending_approval" && options.approve) {
132
+ const approved = await this.approvePlan(plan.id);
133
+ plan = approved.plan;
134
+ }
135
+ const executed = await this.executePlan(plan.id);
136
+ return {
137
+ ok: true,
138
+ plan,
139
+ run: executed.run,
140
+ receipt: executed.receipt,
141
+ settlement: executed.settlement ||
142
+ executed.receipt?.supplierSettlement ||
143
+ null,
144
+ };
145
+ }
146
+ async verifyReceipt(receiptId) {
147
+ const res = await this.request(`/api/v1/receipts/${encodeURIComponent(receiptId)}`);
148
+ const isOk = Boolean(res.valid ?? res.verified ?? true);
149
+ return {
150
+ ok: true,
151
+ valid: isOk,
152
+ verified: isOk,
153
+ receipt: res.receipt,
154
+ };
155
+ }
156
+ async startConnection(paramsOrProvider) {
157
+ const body = typeof paramsOrProvider === "string"
158
+ ? { provider: paramsOrProvider }
159
+ : paramsOrProvider;
87
160
  return this.request("/api/v1/connections", {
88
161
  method: "POST",
89
- body: params,
162
+ body,
90
163
  });
91
164
  }
92
- async waitForConnection(params) {
93
- return this.request("/api/v1/connections/wait", {
165
+ async waitForConnection(paramsOrProvider, options) {
166
+ const body = typeof paramsOrProvider === "string"
167
+ ? { provider: paramsOrProvider, ...options }
168
+ : paramsOrProvider;
169
+ const res = await this.request("/api/v1/connections/wait", {
94
170
  method: "POST",
95
- body: params,
171
+ body,
96
172
  });
173
+ return {
174
+ ...res,
175
+ status: res.status || res.connection?.status || "pending",
176
+ };
97
177
  }
98
178
  async listResources() {
99
179
  return this.request("/api/v1/resources");
100
180
  }
101
181
  async pullEnv() {
102
- return this.request("/api/v1/resources/env");
182
+ const res = await this.request("/api/v1/resources/env");
183
+ return Object.assign(res, {
184
+ includes: (substr) => String(res.dotenv || "").includes(substr),
185
+ toString: () => String(res.dotenv || ""),
186
+ });
103
187
  }
104
- async topupCredits(params) {
105
- return this.request("/api/v1/billing/topup", {
188
+ async topupCredits(paramsOrCredits, description) {
189
+ const body = typeof paramsOrCredits === "number"
190
+ ? { credits: paramsOrCredits, description }
191
+ : paramsOrCredits;
192
+ const res = await this.request("/api/v1/billing/topup", {
106
193
  method: "POST",
107
- body: params,
194
+ body,
108
195
  });
196
+ return {
197
+ ...res,
198
+ creditBalance: res.creditBalance ?? res.workspace?.creditsBalance ?? 0,
199
+ };
200
+ }
201
+ async getBillingStatus() {
202
+ return this.getSettlements();
109
203
  }
110
204
  async getSettlements() {
111
- return this.request("/api/v1/billing/settlements");
205
+ const res = await this.request("/api/v1/billing/settlements");
206
+ if (res.settlementSummary &&
207
+ res.settlementSummary.totalCustomerChargedCredits === undefined) {
208
+ res.settlementSummary.totalCustomerChargedCredits =
209
+ res.settlementSummary.totalCreditsConsumed;
210
+ }
211
+ return res;
112
212
  }
113
213
  async recallMemory(query) {
114
214
  const suffix = query ? `?query=${encodeURIComponent(query)}` : "";
package/package.json CHANGED
@@ -1,40 +1,31 @@
1
1
  {
2
2
  "name": "@muxoai/sdk",
3
- "version": "1.2.1",
4
- "description": "Muxo TypeScript/JavaScript SDK — Typed client for governed agent actions, OAuth handoffs, infrastructure provisioning, and receipts",
5
- "license": "MIT",
6
- "homepage": "https://muxo.ai",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/muxoai/muxo.git"
10
- },
11
- "keywords": [
12
- "muxo",
13
- "sdk",
14
- "agents",
15
- "mcp",
16
- "composio",
17
- "stripe",
18
- "governance",
19
- "supermemory"
20
- ],
21
- "publishConfig": {
22
- "access": "public"
23
- },
3
+ "version": "1.2.2",
4
+ "description": "Muxo TypeScript/JavaScript SDK — Official client for Muxo Unified AI Agent Execution, Infrastructure, Memory & Governance Platform",
24
5
  "type": "module",
25
6
  "main": "./dist/sdk.js",
26
7
  "types": "./dist/sdk.d.ts",
27
8
  "exports": {
28
9
  ".": {
29
10
  "types": "./dist/sdk.d.ts",
30
- "default": "./dist/sdk.js"
11
+ "import": "./dist/sdk.js"
31
12
  }
32
13
  },
33
14
  "files": [
34
15
  "dist",
35
16
  "README.md"
36
17
  ],
18
+ "keywords": [
19
+ "muxo",
20
+ "ai-agents",
21
+ "mcp",
22
+ "composio",
23
+ "stripe-projects",
24
+ "supermemory",
25
+ "microsoft-agent-governance"
26
+ ],
27
+ "license": "MIT",
37
28
  "engines": {
38
- "node": ">=18.0.0"
29
+ "node": ">=20.0.0"
39
30
  }
40
31
  }