@muxoai/platform 1.3.1 → 1.3.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.
package/dist/sdk.d.ts CHANGED
@@ -1,4 +1,10 @@
1
- import type { ActionPlan, ByokKeyRecord, ConnectionRecord, ExecutionReceipt, ExecutionRun, MuxoTool, ProviderLane, ProvisionedResource, RiskLevel, SupplierSettlementSummary, Workspace, WorkspaceMemoryRecord } from "./types.js";
1
+ import type { ActionPlan, ByokKeyRecord, ConnectionRecord, ExecutionReceipt, ExecutionRun, GovernancePolicy, MuxoTool, ProviderLane, ProvisionedResource, RiskLevel, SupplierSettlementSummary, TemporalGraphFact, Workspace, WorkspaceMemoryRecord } from "./types.js";
2
+ export interface MuxoTrustScore {
3
+ overall: number;
4
+ tier: string;
5
+ reliability?: number;
6
+ consistency?: number;
7
+ }
2
8
  export interface MuxoClientOptions {
3
9
  baseUrl?: string;
4
10
  apiKey?: string | (() => string | Promise<string>);
@@ -28,6 +34,50 @@ export declare class MuxoClient {
28
34
  governanceDid: string;
29
35
  supermemoryNamespace: string;
30
36
  }>;
37
+ static register(params: {
38
+ email: string;
39
+ password: string;
40
+ name?: string;
41
+ workspaceName?: string;
42
+ }, baseUrl?: string): Promise<{
43
+ ok: true;
44
+ user: Record<string, unknown>;
45
+ workspace: Workspace;
46
+ apiKey: string;
47
+ token: string;
48
+ }>;
49
+ static login(params: {
50
+ email: string;
51
+ password: string;
52
+ }, baseUrl?: string): Promise<{
53
+ ok: true;
54
+ user: Record<string, unknown>;
55
+ workspace: Workspace;
56
+ apiKey: string;
57
+ token: string;
58
+ }>;
59
+ register(params: {
60
+ email: string;
61
+ password: string;
62
+ name?: string;
63
+ workspaceName?: string;
64
+ }): Promise<{
65
+ ok: true;
66
+ user: Record<string, unknown>;
67
+ workspace: Workspace;
68
+ apiKey: string;
69
+ token: string;
70
+ }>;
71
+ login(params: {
72
+ email: string;
73
+ password: string;
74
+ }): Promise<{
75
+ ok: true;
76
+ user: Record<string, unknown>;
77
+ workspace: Workspace;
78
+ apiKey: string;
79
+ token: string;
80
+ }>;
31
81
  signupAgent(params: {
32
82
  agentName?: string;
33
83
  harness?: string;
@@ -65,6 +115,7 @@ export declare class MuxoClient {
65
115
  toolSlug: string;
66
116
  input: Record<string, unknown>;
67
117
  reason?: string;
118
+ fundingMode?: "muxo_funded" | "byok";
68
119
  }): Promise<{
69
120
  ok: true;
70
121
  plan: ActionPlan;
@@ -79,6 +130,10 @@ export declare class MuxoClient {
79
130
  instructions: string;
80
131
  };
81
132
  }>;
133
+ getPlan(planId: string): Promise<{
134
+ ok: true;
135
+ plan: ActionPlan;
136
+ }>;
82
137
  approvePlan(planId: string): Promise<{
83
138
  ok: true;
84
139
  plan: ActionPlan;
@@ -88,9 +143,19 @@ export declare class MuxoClient {
88
143
  run: ExecutionRun;
89
144
  receipt: ExecutionReceipt;
90
145
  }>;
146
+ getRun(runId: string): Promise<{
147
+ ok: true;
148
+ run: ExecutionRun;
149
+ }>;
150
+ cancelRun(runId: string, reason?: string): Promise<{
151
+ ok: true;
152
+ run: ExecutionRun;
153
+ receipt: ExecutionReceipt;
154
+ }>;
91
155
  exec(toolSlug: string, input?: Record<string, unknown>, options?: {
92
156
  reason?: string;
93
157
  approve?: boolean;
158
+ fundingMode?: "muxo_funded" | "byok";
94
159
  }): Promise<{
95
160
  ok: true;
96
161
  plan: ActionPlan;
@@ -152,6 +217,11 @@ export declare class MuxoClient {
152
217
  }>;
153
218
  getBillingStatus(): Promise<{
154
219
  ok: true;
220
+ workspace?: Workspace;
221
+ creditsBalance?: number;
222
+ creditBalance?: number;
223
+ tier?: string;
224
+ byokKeys?: ByokKeyRecord[];
155
225
  settlementSummary: SupplierSettlementSummary & {
156
226
  totalCustomerChargedCredits?: number;
157
227
  };
@@ -173,11 +243,105 @@ export declare class MuxoClient {
173
243
  ok: true;
174
244
  namespace: string;
175
245
  records: WorkspaceMemoryRecord[];
246
+ recentMemories?: WorkspaceMemoryRecord[];
247
+ memories?: WorkspaceMemoryRecord[];
248
+ }>;
249
+ addMemory(paramsOrContent: string | {
250
+ title?: string;
251
+ content: string;
252
+ kind?: WorkspaceMemoryRecord["kind"];
253
+ subject?: string;
254
+ predicate?: string;
255
+ object?: string;
256
+ confidence?: number;
257
+ metadata?: Record<string, unknown>;
258
+ }): Promise<{
259
+ ok: true;
260
+ memory: WorkspaceMemoryRecord;
261
+ temporalFacts?: Array<Record<string, unknown>>;
262
+ fundingSource?: string;
263
+ }>;
264
+ deleteMemory(id: string): Promise<{
265
+ ok: true;
266
+ deleted: boolean;
267
+ record: WorkspaceMemoryRecord | null;
268
+ }>;
269
+ getMemoryFacts(options?: boolean | {
270
+ includeHistorical?: boolean;
271
+ query?: string;
272
+ subject?: string;
273
+ predicate?: string;
274
+ limit?: number;
275
+ }): Promise<{
276
+ ok: true;
277
+ activeFacts: TemporalGraphFact[];
278
+ historicalFacts: TemporalGraphFact[];
279
+ facts: TemporalGraphFact[];
280
+ }>;
281
+ listTemporalFacts(options?: Parameters<MuxoClient["getMemoryFacts"]>[0]): Promise<{
282
+ ok: true;
283
+ activeFacts: TemporalGraphFact[];
284
+ historicalFacts: TemporalGraphFact[];
285
+ facts: TemporalGraphFact[];
286
+ }>;
287
+ forgetMemory(queryOrParams: string | {
288
+ query: string;
289
+ }): Promise<{
290
+ ok: true;
291
+ query: string;
292
+ deletedLocalCount: number;
293
+ invalidatedFactsCount: number;
294
+ deletedRemoteIds: string[];
295
+ deletedMemories: WorkspaceMemoryRecord[];
296
+ invalidatedFacts: TemporalGraphFact[];
297
+ }>;
298
+ getGovernanceStatus(): Promise<{
299
+ ok: true;
300
+ governance: Record<string, unknown> & {
301
+ modules?: unknown;
302
+ trustScore?: MuxoTrustScore;
303
+ killSwitch?: Record<string, unknown> | null;
304
+ auditChain?: Record<string, unknown>;
305
+ };
306
+ workspacePolicy: GovernancePolicy;
307
+ }>;
308
+ setKillSwitch(action: "quarantine" | "terminate" | "suspend" | "resume", reason?: string): Promise<{
309
+ ok: true;
310
+ activated?: boolean;
311
+ resumed?: boolean;
312
+ killSwitch?: Record<string, unknown>;
313
+ policy: GovernancePolicy;
314
+ trustScore: MuxoTrustScore;
315
+ }>;
316
+ scanContext(contentOrParams: string | {
317
+ content: string;
318
+ sessionId?: string;
319
+ role?: "user" | "assistant" | "tool" | "system";
320
+ }): Promise<{
321
+ ok: true;
322
+ scan: {
323
+ safe: boolean;
324
+ riskLevel: "none" | "low" | "medium" | "high" | "critical";
325
+ findingsCount: number;
326
+ findings: Array<{
327
+ patternId: string;
328
+ patternName: string;
329
+ severity: string;
330
+ description: string;
331
+ }>;
332
+ integrityValid: boolean;
333
+ };
334
+ }>;
335
+ updatePolicy(policy: Partial<Omit<GovernancePolicy, "killSwitchActive" | "killSwitchReason">>): Promise<{
336
+ ok: true;
337
+ workspace: Workspace;
176
338
  }>;
177
339
  do(prompt: string, options?: {
178
340
  input?: Record<string, unknown>;
179
341
  autoApprove?: boolean;
180
342
  dryRun?: boolean;
343
+ planOnly?: boolean;
344
+ fundingMode?: "muxo_funded" | "byok";
181
345
  }): Promise<{
182
346
  ok: boolean;
183
347
  executed: boolean;
@@ -199,6 +363,8 @@ export declare class MuxoClient {
199
363
  input?: Record<string, unknown>;
200
364
  autoApprove?: boolean;
201
365
  dryRun?: boolean;
366
+ planOnly?: boolean;
367
+ fundingMode?: "muxo_funded" | "byok";
202
368
  }): Promise<{
203
369
  ok: boolean;
204
370
  executed: boolean;
@@ -238,11 +404,13 @@ export declare class MuxoClient {
238
404
  workspace: Workspace;
239
405
  settlementSummary: SupplierSettlementSummary;
240
406
  }>;
241
- createCheckoutSession(kind?: "starter_subscription" | "credit_topup"): Promise<{
407
+ createCheckoutSession(kind?: "starter_subscription" | "credit_topup", credits?: number): Promise<{
242
408
  ok: true;
243
409
  sessionId: string;
244
410
  url: string;
245
411
  mode?: string;
412
+ kind?: string;
413
+ credits?: number;
246
414
  }>;
247
415
  verifyCheckoutSession(sessionId: string): Promise<{
248
416
  ok: true;
package/dist/sdk.js CHANGED
@@ -52,6 +52,26 @@ export class MuxoClient {
52
52
  harness: params.harness || "muxo-sdk",
53
53
  });
54
54
  }
55
+ static async register(params, baseUrl = "https://app.muxo.ai") {
56
+ const client = new MuxoClient({ baseUrl });
57
+ return client.register(params);
58
+ }
59
+ static async login(params, baseUrl = "https://app.muxo.ai") {
60
+ const client = new MuxoClient({ baseUrl });
61
+ return client.login(params);
62
+ }
63
+ async register(params) {
64
+ return this.request("/api/v1/auth/register", {
65
+ method: "POST",
66
+ body: params,
67
+ });
68
+ }
69
+ async login(params) {
70
+ return this.request("/api/v1/auth/login", {
71
+ method: "POST",
72
+ body: params,
73
+ });
74
+ }
55
75
  async signupAgent(params) {
56
76
  return this.request("/api/v1/agents/signup", {
57
77
  method: "POST",
@@ -80,6 +100,10 @@ export class MuxoClient {
80
100
  if (rpcRes.error) {
81
101
  throw new Error(rpcRes.error.message || "MCP call failed");
82
102
  }
103
+ if (rpcRes.result?.isError) {
104
+ const errObj = rpcRes.result.structuredContent;
105
+ throw new Error(String(errObj?.error || rpcRes.result.content?.[0]?.text || "MCP tool execution failed"));
106
+ }
83
107
  if (rpcRes.result?.structuredContent) {
84
108
  return rpcRes.result.structuredContent;
85
109
  }
@@ -111,6 +135,9 @@ export class MuxoClient {
111
135
  body: params,
112
136
  });
113
137
  }
138
+ async getPlan(planId) {
139
+ return this.request(`/api/v1/plans/${encodeURIComponent(planId)}`);
140
+ }
114
141
  async approvePlan(planId) {
115
142
  return this.request(`/api/v1/plans/${encodeURIComponent(planId)}/approve`, {
116
143
  method: "POST",
@@ -121,11 +148,21 @@ export class MuxoClient {
121
148
  method: "POST",
122
149
  });
123
150
  }
151
+ async getRun(runId) {
152
+ return this.request(`/api/v1/runs/${encodeURIComponent(runId)}`);
153
+ }
154
+ async cancelRun(runId, reason) {
155
+ return this.request(`/api/v1/runs/${encodeURIComponent(runId)}/cancel`, {
156
+ method: "POST",
157
+ body: reason ? { reason } : {},
158
+ });
159
+ }
124
160
  async exec(toolSlug, input = {}, options = {}) {
125
161
  const planned = await this.planAction({
126
162
  toolSlug,
127
163
  input,
128
164
  reason: options.reason,
165
+ fundingMode: options.fundingMode,
129
166
  });
130
167
  let plan = planned.plan;
131
168
  if (plan.approvalStatus === "pending_approval" && options.approve) {
@@ -199,7 +236,13 @@ export class MuxoClient {
199
236
  };
200
237
  }
201
238
  async getBillingStatus() {
202
- return this.getSettlements();
239
+ const res = await this.request("/api/v1/billing/status");
240
+ if (res.settlementSummary &&
241
+ res.settlementSummary.totalCustomerChargedCredits === undefined) {
242
+ res.settlementSummary.totalCustomerChargedCredits =
243
+ res.settlementSummary.totalCreditsConsumed;
244
+ }
245
+ return res;
203
246
  }
204
247
  async settlements() {
205
248
  const res = await this.getSettlements();
@@ -221,14 +264,82 @@ export class MuxoClient {
221
264
  const suffix = query ? `?query=${encodeURIComponent(query)}` : "";
222
265
  return this.request(`/api/v1/memory${suffix}`);
223
266
  }
267
+ async addMemory(paramsOrContent) {
268
+ const body = typeof paramsOrContent === "string"
269
+ ? { title: paramsOrContent.slice(0, 60), content: paramsOrContent }
270
+ : paramsOrContent;
271
+ return this.request("/api/v1/memory", {
272
+ method: "POST",
273
+ body,
274
+ });
275
+ }
276
+ async deleteMemory(id) {
277
+ return this.request(`/api/v1/memory/${encodeURIComponent(id)}`, {
278
+ method: "DELETE",
279
+ });
280
+ }
281
+ async getMemoryFacts(options = {}) {
282
+ const opts = typeof options === "boolean" ? { includeHistorical: options } : options;
283
+ const params = new URLSearchParams();
284
+ params.set("historical", opts.includeHistorical === false ? "false" : "true");
285
+ if (opts.query)
286
+ params.set("query", opts.query);
287
+ if (opts.subject)
288
+ params.set("subject", opts.subject);
289
+ if (opts.predicate)
290
+ params.set("predicate", opts.predicate);
291
+ if (opts.limit)
292
+ params.set("limit", String(opts.limit));
293
+ return this.request(`/api/v1/memory/facts?${params.toString()}`);
294
+ }
295
+ async listTemporalFacts(options) {
296
+ return this.getMemoryFacts(options);
297
+ }
298
+ async forgetMemory(queryOrParams) {
299
+ const query = (typeof queryOrParams === "string" ? queryOrParams : queryOrParams.query)?.trim();
300
+ if (!query) {
301
+ throw new Error("forgetMemory requires a non-empty query");
302
+ }
303
+ return this.request("/api/v1/memory/forget", {
304
+ method: "POST",
305
+ body: { query },
306
+ });
307
+ }
308
+ async getGovernanceStatus() {
309
+ return this.request("/api/v1/governance");
310
+ }
311
+ async setKillSwitch(action, reason) {
312
+ return this.request("/api/v1/governance/kill-switch", {
313
+ method: "POST",
314
+ body: reason ? { action, reason } : { action },
315
+ });
316
+ }
317
+ async scanContext(contentOrParams) {
318
+ const body = typeof contentOrParams === "string"
319
+ ? { content: contentOrParams }
320
+ : contentOrParams;
321
+ return this.request("/api/v1/governance/scan-context", {
322
+ method: "POST",
323
+ body,
324
+ });
325
+ }
326
+ async updatePolicy(policy) {
327
+ return this.request("/api/v1/policy", {
328
+ method: "POST",
329
+ body: policy,
330
+ });
331
+ }
224
332
  async do(prompt, options = {}) {
333
+ const isDryRun = options.dryRun === true || options.planOnly === true;
225
334
  return this.request("/api/v1/do", {
226
335
  method: "POST",
227
336
  body: {
228
337
  prompt,
229
338
  input: options.input,
230
339
  autoApprove: options.autoApprove !== false,
231
- dryRun: options.dryRun === true,
340
+ dryRun: isDryRun,
341
+ planOnly: isDryRun,
342
+ fundingMode: options.fundingMode,
232
343
  },
233
344
  });
234
345
  }
@@ -255,10 +366,10 @@ export class MuxoClient {
255
366
  body: {},
256
367
  });
257
368
  }
258
- async createCheckoutSession(kind = "credit_topup") {
369
+ async createCheckoutSession(kind = "credit_topup", credits) {
259
370
  return this.request("/api/v1/billing/checkout", {
260
371
  method: "POST",
261
- body: { kind },
372
+ body: credits === undefined ? { kind } : { kind, credits },
262
373
  });
263
374
  }
264
375
  async verifyCheckoutSession(sessionId) {