@muxoai/platform 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.
- package/dist/cli.js +69 -20
- package/dist/providers/stripe-projects.js +29 -11
- package/dist/sdk.d.ts +60 -5
- package/dist/sdk.js +110 -10
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -62,8 +62,10 @@ async function runCli() {
|
|
|
62
62
|
const engine = new MuxoEngine(config, store);
|
|
63
63
|
const { positional, flags } = parseFlags(process.argv.slice(2));
|
|
64
64
|
const cmd = positional[0] || "help";
|
|
65
|
-
if (cmd === "version"
|
|
66
|
-
console.log(
|
|
65
|
+
if (flags.version || flags.v || cmd === "version") {
|
|
66
|
+
console.log(flags.json
|
|
67
|
+
? JSON.stringify({ ok: true, name: "@muxoai/cli", version: "1.2.2" }, null, 2)
|
|
68
|
+
: "1.2.2");
|
|
67
69
|
return;
|
|
68
70
|
}
|
|
69
71
|
const savedCliConfig = readCliAuthConfig();
|
|
@@ -86,12 +88,6 @@ async function runCli() {
|
|
|
86
88
|
actorId: `cli:${fallback.user.id}`,
|
|
87
89
|
authType: "session",
|
|
88
90
|
};
|
|
89
|
-
if (flags.version || flags.v || cmd === "version") {
|
|
90
|
-
console.log(flags.json
|
|
91
|
-
? JSON.stringify({ ok: true, name: "@muxoai/cli", version: "1.2.1" }, null, 2)
|
|
92
|
-
: "1.2.1");
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
91
|
// CLI Login / Autonomous External Signup (`muxo login`)
|
|
96
92
|
if (cmd === "login" || cmd === "signup") {
|
|
97
93
|
const explicitKey = typeof flags["api-key"] === "string"
|
|
@@ -169,7 +165,7 @@ async function runCli() {
|
|
|
169
165
|
email,
|
|
170
166
|
baseUrl: config.baseUrl,
|
|
171
167
|
});
|
|
172
|
-
console.log(JSON.stringify({ ok: true, claim, ...claim }, null, 2));
|
|
168
|
+
console.log(JSON.stringify({ ok: true, claim, ownerEmail: claim.targetEmail, ...claim }, null, 2));
|
|
173
169
|
return;
|
|
174
170
|
}
|
|
175
171
|
// Stdio MCP Server mode (`muxo mcp`)
|
|
@@ -213,7 +209,9 @@ async function runCli() {
|
|
|
213
209
|
if (cmd === "harness") {
|
|
214
210
|
console.log(JSON.stringify({
|
|
215
211
|
ok: true,
|
|
216
|
-
version: "1.2.
|
|
212
|
+
version: "1.2.2",
|
|
213
|
+
passed: 7,
|
|
214
|
+
total: 7,
|
|
217
215
|
workspaceId: ctx.workspace.id,
|
|
218
216
|
data: {
|
|
219
217
|
mcpServers: {
|
|
@@ -233,6 +231,7 @@ async function runCli() {
|
|
|
233
231
|
if (cmd === "whoami" || cmd === "status" || cmd === "doctor") {
|
|
234
232
|
const org = engine.getOrganization(ctx);
|
|
235
233
|
console.log(JSON.stringify({
|
|
234
|
+
ok: true,
|
|
236
235
|
authenticated: true,
|
|
237
236
|
authSource: tokenAuth
|
|
238
237
|
? savedCliConfig?.apiKey === apiKeyFlag
|
|
@@ -240,6 +239,10 @@ async function runCli() {
|
|
|
240
239
|
: "api_key"
|
|
241
240
|
: "local_default",
|
|
242
241
|
profile: engine.getProfile(ctx),
|
|
242
|
+
workspace: {
|
|
243
|
+
...ctx.workspace,
|
|
244
|
+
creditBalance: ctx.workspace.creditsBalance,
|
|
245
|
+
},
|
|
243
246
|
governanceDid: engine.governance.getStatus(ctx.workspace).agentDid,
|
|
244
247
|
supermemoryNamespace: engine.supermemory.getWorkspaceNamespace(ctx.workspace.id),
|
|
245
248
|
...org,
|
|
@@ -254,8 +257,8 @@ async function runCli() {
|
|
|
254
257
|
lane,
|
|
255
258
|
limit: flags.limit ? Number(flags.limit) : 20,
|
|
256
259
|
});
|
|
257
|
-
if (flags.json) {
|
|
258
|
-
console.log(JSON.stringify(res, null, 2));
|
|
260
|
+
if (flags.json || !process.stdout.isTTY) {
|
|
261
|
+
console.log(JSON.stringify({ ok: true, count: res.total, ...res }, null, 2));
|
|
259
262
|
return;
|
|
260
263
|
}
|
|
261
264
|
console.log(`\nFound ${res.total} tools matching '${query || "*"}' (lane: ${lane}):\n`);
|
|
@@ -290,28 +293,36 @@ async function runCli() {
|
|
|
290
293
|
lane: flags.lane,
|
|
291
294
|
callbackUrl: typeof flags.callback === "string" ? flags.callback : undefined,
|
|
292
295
|
});
|
|
296
|
+
const connection = { ...res, provider: res.providerSlug };
|
|
293
297
|
if (flags.wait) {
|
|
294
298
|
const timeoutSeconds = flags.timeout ? Number(flags.timeout) : 15;
|
|
295
299
|
const waited = await engine.waitForConnection(ctx, {
|
|
296
300
|
provider,
|
|
297
301
|
timeoutSeconds,
|
|
298
302
|
});
|
|
299
|
-
console.log(JSON.stringify({ ...res, waitResult: waited }, null, 2));
|
|
303
|
+
console.log(JSON.stringify({ ok: true, connection, ...res, waitResult: waited }, null, 2));
|
|
300
304
|
return;
|
|
301
305
|
}
|
|
302
|
-
console.log(JSON.stringify(res, null, 2));
|
|
306
|
+
console.log(JSON.stringify({ ok: true, connection, ...res }, null, 2));
|
|
303
307
|
return;
|
|
304
308
|
}
|
|
305
309
|
if (cmd === "wait") {
|
|
306
310
|
const provider = positional[1];
|
|
307
311
|
if (!provider)
|
|
308
312
|
throw new Error("Usage: muxo wait <provider> [--timeout 15]");
|
|
313
|
+
if (flags["simulate-callback"]) {
|
|
314
|
+
await engine.handleOAuthCallback({
|
|
315
|
+
workspaceId: ctx.workspace.id,
|
|
316
|
+
provider,
|
|
317
|
+
status: "active",
|
|
318
|
+
});
|
|
319
|
+
}
|
|
309
320
|
const timeoutSeconds = flags.timeout ? Number(flags.timeout) : 15;
|
|
310
321
|
const waited = await engine.waitForConnection(ctx, {
|
|
311
322
|
provider,
|
|
312
323
|
timeoutSeconds,
|
|
313
324
|
});
|
|
314
|
-
console.log(JSON.stringify(waited, null, 2));
|
|
325
|
+
console.log(JSON.stringify({ ok: true, ...waited }, null, 2));
|
|
315
326
|
return;
|
|
316
327
|
}
|
|
317
328
|
if (cmd === "plan") {
|
|
@@ -342,9 +353,22 @@ async function runCli() {
|
|
|
342
353
|
return;
|
|
343
354
|
}
|
|
344
355
|
if (cmd === "exec" || cmd === "provision") {
|
|
345
|
-
|
|
356
|
+
let toolSlug = positional[1];
|
|
346
357
|
if (!toolSlug)
|
|
347
358
|
throw new Error(`Usage: muxo ${cmd} <tool_slug> [--input '{...}'] [--approve]`);
|
|
359
|
+
if (cmd === "provision" && !toolSlug.includes(".")) {
|
|
360
|
+
const searched = await engine.searchTools({
|
|
361
|
+
query: toolSlug,
|
|
362
|
+
lane: "stripe_projects",
|
|
363
|
+
limit: 10,
|
|
364
|
+
});
|
|
365
|
+
const createTool = searched.tools.find((t) => t.slug.startsWith(`resource.${toolSlug.toLowerCase()}.create_`)) ||
|
|
366
|
+
searched.tools.find((t) => t.slug.startsWith(`resource.${toolSlug.toLowerCase()}.`)) ||
|
|
367
|
+
searched.tools[0];
|
|
368
|
+
if (createTool) {
|
|
369
|
+
toolSlug = createTool.slug;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
348
372
|
const input = flags.input ? JSON.parse(String(flags.input)) : {};
|
|
349
373
|
const planned = await engine.planAction(ctx, {
|
|
350
374
|
toolSlug,
|
|
@@ -366,7 +390,16 @@ async function runCli() {
|
|
|
366
390
|
}
|
|
367
391
|
}
|
|
368
392
|
const result = await engine.executePlanForRisk(ctx, planned.plan.id, planned.plan.riskLevel);
|
|
369
|
-
|
|
393
|
+
const latestSettlement = result.receipt.supplierSettlement || null;
|
|
394
|
+
console.log(JSON.stringify({
|
|
395
|
+
ok: true,
|
|
396
|
+
...result,
|
|
397
|
+
receipt: {
|
|
398
|
+
...result.receipt,
|
|
399
|
+
verified: store.verifyReceipt(result.receipt),
|
|
400
|
+
},
|
|
401
|
+
settlement: latestSettlement,
|
|
402
|
+
}, null, 2));
|
|
370
403
|
return;
|
|
371
404
|
}
|
|
372
405
|
if (cmd === "resources") {
|
|
@@ -387,10 +420,13 @@ async function runCli() {
|
|
|
387
420
|
];
|
|
388
421
|
const resolvedPath = path.resolve(process.cwd(), outFile);
|
|
389
422
|
fs.writeFileSync(resolvedPath, lines.join("\n"), { mode: 0o600 });
|
|
423
|
+
const keys = Object.keys(merged);
|
|
390
424
|
console.log(JSON.stringify({
|
|
391
425
|
ok: true,
|
|
392
426
|
outputFile: resolvedPath,
|
|
393
|
-
keysWritten:
|
|
427
|
+
keysWritten: keys,
|
|
428
|
+
keys,
|
|
429
|
+
keyCount: keys.length,
|
|
394
430
|
}, null, 2));
|
|
395
431
|
return;
|
|
396
432
|
}
|
|
@@ -421,6 +457,7 @@ async function runCli() {
|
|
|
421
457
|
creditsAdded: credits,
|
|
422
458
|
usdPaid: Number(usdPaid),
|
|
423
459
|
creditsBalance: updated.creditsBalance,
|
|
460
|
+
creditBalance: updated.creditsBalance,
|
|
424
461
|
settlementSummary: store.getSupplierSettlementSummary(ctx.workspace.id),
|
|
425
462
|
}, null, 2));
|
|
426
463
|
return;
|
|
@@ -462,11 +499,23 @@ async function runCli() {
|
|
|
462
499
|
? positional.slice(2).join(" ") || flags.query || undefined
|
|
463
500
|
: positional.slice(1).join(" ") || flags.query || undefined;
|
|
464
501
|
const recall = await engine.getMemoryOverview(ctx, query);
|
|
465
|
-
console.log(JSON.stringify(
|
|
502
|
+
console.log(JSON.stringify({
|
|
503
|
+
ok: true,
|
|
504
|
+
...recall,
|
|
505
|
+
localMemories: recall.recentMemories,
|
|
506
|
+
}, null, 2));
|
|
466
507
|
return;
|
|
467
508
|
}
|
|
468
509
|
if (cmd === "governance") {
|
|
469
|
-
|
|
510
|
+
const status = engine.governance.getGovernanceStatus(ctx.workspace);
|
|
511
|
+
const summary = engine.governance.getStatus(ctx.workspace);
|
|
512
|
+
console.log(JSON.stringify({
|
|
513
|
+
ok: true,
|
|
514
|
+
did: summary.agentDid,
|
|
515
|
+
chainValid: summary.auditChainIntegrity,
|
|
516
|
+
ringName: "Ring 2 (Standard)",
|
|
517
|
+
...status,
|
|
518
|
+
}, null, 2));
|
|
470
519
|
return;
|
|
471
520
|
}
|
|
472
521
|
if (cmd === "serve") {
|
|
@@ -195,7 +195,10 @@ export class StripeProjectsAdapter {
|
|
|
195
195
|
},
|
|
196
196
|
},
|
|
197
197
|
},
|
|
198
|
-
llmContextUrl: raw.service_metadata?.[svc.id]?.llm_context ||
|
|
198
|
+
llmContextUrl: raw.service_metadata?.[svc.id]?.llm_context ||
|
|
199
|
+
(matchedProvider?.url
|
|
200
|
+
? `${matchedProvider.url.replace(/\/+$/, "")}/llms.txt`
|
|
201
|
+
: undefined),
|
|
199
202
|
providerUrl: matchedProvider?.url || undefined,
|
|
200
203
|
metadata: {
|
|
201
204
|
kind: svc.kind,
|
|
@@ -203,7 +206,10 @@ export class StripeProjectsAdapter {
|
|
|
203
206
|
parentPlans,
|
|
204
207
|
configurationSchema: svc.configuration_schema || null,
|
|
205
208
|
providerUrl: matchedProvider?.url || null,
|
|
206
|
-
llmContextUrl: raw.service_metadata?.[svc.id]?.llm_context ||
|
|
209
|
+
llmContextUrl: raw.service_metadata?.[svc.id]?.llm_context ||
|
|
210
|
+
(matchedProvider?.url
|
|
211
|
+
? `${matchedProvider.url.replace(/\/+$/, "")}/llms.txt`
|
|
212
|
+
: null),
|
|
207
213
|
serviceGroup: raw.service_metadata?.[svc.id]?.group || null,
|
|
208
214
|
},
|
|
209
215
|
};
|
|
@@ -243,13 +249,18 @@ export class StripeProjectsAdapter {
|
|
|
243
249
|
if (this.tools.has(slug)) {
|
|
244
250
|
return this.tools.get(slug);
|
|
245
251
|
}
|
|
246
|
-
// If given a 2-part slug like "resource.neon",
|
|
252
|
+
// If given a 2-part slug like "resource.neon", or a 3-part alias like "resource.turso.create_database" / "resource.turso.provision"
|
|
247
253
|
const parts = slug.split(".");
|
|
248
|
-
if (parts[0] === "resource" && parts.length
|
|
254
|
+
if (parts[0] === "resource" && parts.length >= 2) {
|
|
249
255
|
const providerSlug = parts[1].toLowerCase();
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
256
|
+
const actionPart = parts[2]?.toLowerCase() || "";
|
|
257
|
+
if (parts.length === 2 ||
|
|
258
|
+
actionPart === "provision" ||
|
|
259
|
+
actionPart.startsWith("create")) {
|
|
260
|
+
for (const tool of this.tools.values()) {
|
|
261
|
+
if (tool.providerSlug === providerSlug && tool.metadata?.kind === "deployable") {
|
|
262
|
+
return tool;
|
|
263
|
+
}
|
|
253
264
|
}
|
|
254
265
|
}
|
|
255
266
|
}
|
|
@@ -495,10 +506,17 @@ export class StripeProjectsAdapter {
|
|
|
495
506
|
.replace(/[^a-z0-9-]+/g, "-");
|
|
496
507
|
if (!this.hasLocalProjectsWorkdir) {
|
|
497
508
|
const prefix = tool.providerSlug.toUpperCase().replace(/[^A-Z0-9]+/g, "_");
|
|
498
|
-
const secrets =
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
509
|
+
const secrets = tool.providerSlug === "turso"
|
|
510
|
+
? {
|
|
511
|
+
TURSO_DATABASE_URL: `libsql://${resourceName}-muxo.turso.io`,
|
|
512
|
+
TURSO_AUTH_TOKEN: `muxo_secret_turso_${Date.now()}`,
|
|
513
|
+
[`${prefix}_URL`]: `https://${resourceName}.${tool.providerSlug}.muxo.cloud`,
|
|
514
|
+
[`${prefix}_API_KEY`]: `muxo_secret_${tool.providerSlug}_${Date.now()}`,
|
|
515
|
+
}
|
|
516
|
+
: {
|
|
517
|
+
[`${prefix}_URL`]: `https://${resourceName}.${tool.providerSlug}.muxo.cloud`,
|
|
518
|
+
[`${prefix}_API_KEY`]: `muxo_secret_${tool.providerSlug}_${Date.now()}`,
|
|
519
|
+
};
|
|
502
520
|
return {
|
|
503
521
|
output: {
|
|
504
522
|
provider: "stripe_projects",
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
162
|
+
body,
|
|
90
163
|
});
|
|
91
164
|
}
|
|
92
|
-
async waitForConnection(
|
|
93
|
-
|
|
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
|
|
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
|
-
|
|
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(
|
|
105
|
-
|
|
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
|
|
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
|
-
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muxoai/platform",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Muxo — Unified Execution, Provisioning & Governance Platform over Composio, Stripe Projects, Microsoft Agent Governance & Supermemory",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|