@muxoai/platform 1.3.3 → 1.4.1

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 (54) hide show
  1. package/.agents/plugins/marketplace.json +2 -2
  2. package/.claude-plugin/marketplace.json +2 -2
  3. package/ARCHITECTURE.md +16 -6
  4. package/README.md +7 -5
  5. package/dist/cli.js +393 -13
  6. package/dist/composio-catalog.d.ts +58 -0
  7. package/dist/composio-catalog.js +474 -0
  8. package/dist/config.d.ts +10 -0
  9. package/dist/config.js +16 -0
  10. package/dist/durable-workflow.d.ts +45 -0
  11. package/dist/durable-workflow.js +90 -0
  12. package/dist/engine.d.ts +276 -5
  13. package/dist/engine.js +1261 -71
  14. package/dist/mcp-schema.d.ts +125 -0
  15. package/dist/mcp-schema.js +1076 -0
  16. package/dist/mcp.d.ts +2 -30
  17. package/dist/mcp.js +505 -539
  18. package/dist/memory-graph.d.ts +21 -0
  19. package/dist/memory-graph.js +173 -0
  20. package/dist/nl.js +155 -0
  21. package/dist/oauth.d.ts +32 -0
  22. package/dist/oauth.js +134 -0
  23. package/dist/policy.d.ts +75 -1
  24. package/dist/policy.js +1119 -0
  25. package/dist/providers/composio-instant.js +225 -5
  26. package/dist/providers/composio-sdk.d.ts +68 -5
  27. package/dist/providers/composio-sdk.js +683 -78
  28. package/dist/providers/microsoft-governance.d.ts +28 -1
  29. package/dist/providers/microsoft-governance.js +224 -11
  30. package/dist/providers/stripe-billing.d.ts +42 -0
  31. package/dist/providers/stripe-billing.js +230 -1
  32. package/dist/providers/stripe-projects.d.ts +451 -3
  33. package/dist/providers/stripe-projects.js +2106 -87
  34. package/dist/providers/supermemory.d.ts +74 -1
  35. package/dist/providers/supermemory.js +426 -0
  36. package/dist/provisioning-managed.d.ts +50 -0
  37. package/dist/provisioning-managed.js +155 -0
  38. package/dist/sdk.d.ts +538 -8
  39. package/dist/sdk.js +377 -10
  40. package/dist/server.js +1841 -232
  41. package/dist/store.d.ts +113 -6
  42. package/dist/store.js +675 -52
  43. package/dist/types.d.ts +212 -5
  44. package/dist/ui/console-html.d.ts +10 -1
  45. package/dist/ui/console-html.js +1188 -462
  46. package/dist/version.d.ts +1 -1
  47. package/dist/version.js +1 -1
  48. package/package.json +2 -2
  49. package/plugins/muxo/.claude-plugin/plugin.json +1 -1
  50. package/plugins/muxo/.codex-plugin/plugin.json +1 -1
  51. package/plugins/muxo/plugin.json +2 -2
  52. package/plugins/muxo/skills/muxo/SKILL.md +42 -1
  53. package/plugins/muxo/skills/muxo/references/mcp.md +3 -2
  54. package/plugins/muxo/skills/setup/SKILL.md +8 -0
@@ -6,8 +6,8 @@
6
6
  "plugins": [
7
7
  {
8
8
  "name": "muxo",
9
- "version": "1.3.1",
10
- "description": "Governed execution across 1,000+ Connected Apps, Instant Tools (search, scrape, crawl, SEO audit), Cloud Infrastructure provisioning, Supermemory v5 recall, and Microsoft Agent Governance Ed25519 receipts.",
9
+ "version": "1.4.1",
10
+ "description": "Governed execution across 1,000+ Connected Apps, Instant Tools (search, scrape, crawl, SEO audit), Cloud Infrastructure provisioning, Workspace Memory recall, and cryptographic execution receipts.",
11
11
  "source": {
12
12
  "source": "local",
13
13
  "path": "./plugins/muxo"
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "metadata": {
10
10
  "description": "Official Muxo plugin marketplace for governed execution across Connected Apps, Instant Tools, Cloud Infrastructure, and Workspace Memory.",
11
- "version": "1.3.1"
11
+ "version": "1.4.1"
12
12
  },
13
13
  "plugins": [
14
14
  {
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "strict": false,
21
21
  "description": "Governed execution across 1,000+ Connected Apps, Instant Tools (search, scrape, crawl, SEO audit), Cloud Infrastructure provisioning, Workspace Memory recall, and verifiable audit records.",
22
- "version": "1.3.1",
22
+ "version": "1.4.1",
23
23
  "category": "Productivity",
24
24
  "skills": [
25
25
  "./plugins/muxo/skills/muxo",
package/ARCHITECTURE.md CHANGED
@@ -42,7 +42,7 @@ Across `muxoai` (gen 1) and `muxo2` (gen 2, 203,443 LOC), the biggest mistake wa
42
42
  | :--- | :--- | :--- | :--- |
43
43
  | **Composio SDK & Tool Router** (`backend.composio.dev/api/v3`) | **ADOPT (Core Lane)** | Provides 500+ managed OAuth integrations (`app.*`), user-scoped Connect Links, and schema discovery without Muxo maintaining custom OAuth apps for every SaaS provider. | Replaces custom per-provider OAuth brokers and bespoke SaaS connectors. |
44
44
  | **Composio Instant & `agents.composio.dev` Pattern** | **ADOPT (Core Lane + Onboarding)** | 1) Zero-setup `instant.*` tools work immediately on workspace creation.<br>2) We adopt the **`agents.composio.dev` 2-call autonomous signup pattern** (`POST /api/v1/agents/signup` + `POST /api/v1/agents/claim`) so an agent can self-provision a Muxo workspace in one HTTP call and later hand ownership over to its human via a claim slug. | Replaces complex multi-step human-only bootstrap ceremonies for CLI/agent onboarding. |
45
- | **Stripe Projects CLI** (`stripe projects` v0.50.0) | **ADOPT (Core Lane — Node Runtime)** | Provisions real databases, caches, and cloud services (`neon/postgres`, `upstash/redis`, `turso`, `supabase`, `supermemory/memory`, etc.) and pulls credentials (`stripe projects env --pull`) into Muxo's AES-256-GCM vault. | Replaces `muxo2`'s broken 4-worker Cloudflare Container + mTLS bridge (`projects-gateway` + `projects-executor`). See Section 3 below. |
45
+ | **Stripe v2 Provisioning REST API & CLI** (`https://api.stripe.com/v2/provisioning/*`, `Stripe-Version: 2026-09-30.preview` + `stripe projects` v0.50.0) | **ADOPT (Core Lane — HTTP v2 + Node Runtime)** | Provisions real databases, caches, and cloud services (`neon/postgres`, `upstash/redis`, `turso`, `supabase`, `supermemory/memory`, etc.) directly over HTTP via `POST /v2/provisioning/resources` and reveals secrets via `POST /v2/provisioning/resources/:id/reveal_access_configuration` (with automatic CLI/managed fallback) into Muxo's AES-256-GCM vault. Works natively in both Node.js and Cloudflare Workers V8 isolates! | Replaces `muxo2`'s broken 4-worker Cloudflare Container + mTLS bridge (`projects-gateway` + `projects-executor`). See Section 3 below. |
46
46
  | **Microsoft Agent Governance Toolkit** (`@microsoft/agent-governance-sdk` v5.0.0) | **ADOPT (Core Governance)** | A 40 KB, zero-dependency, MIT-licensed SDK providing `McpSecurityScanner` (prompt-injection & exfiltration detection), `PolicyEngine` (YAML/JSON rules + risk gates), `AgentIdentity` (Ed25519 DIDs), and `AuditLogger` (SHA-256 tamper-evident hash chain). | Replaces **~18,000 LOC** of custom authority seals, custom policy DSLs, and hand-rolled audit chains in `muxo2`. |
47
47
  | **Supermemory v5** (`supermemory` `^5.0.1`) | **ADOPT (Fail-Open Contextual Brain)** | Gives every Muxo workspace an isolated `/ns/muxo-v5-{hash}` brain with automatic `static` + `dynamic` profiles (`client.profile`), sub-50ms hybrid search (`client.search`), and governed post-run memory (`client.add`). Also natively deployable via Stripe Projects (`supermemory/memory`)! | Replaces **~25,000 LOC** of `muxoai/packages/brain` + Python `context-engine` (Graphiti + Neo4j + Vectorize + D1). |
48
48
  | **Mastra (`@mastra/mcp`), Pi (`pi`), Vercel AI SDK (`ai`), Google ADK** | **CLIENT ECOSYSTEM (Do Not Bundle Inside Server)** | These are **agent harnesses** that *consume* Muxo over `/mcp` and `/skill.md`. Bundling an agent framework inside the Muxo server violates "Existing-Agent First" and bloats the runtime. Instead, `app.muxo.ai` and `muxo mcp-config` generate instant copy-paste connectors for Mastra, Pi, Vercel AI SDK, Claude Code, Cursor, and Factory Droid. | Drops `muxoai/packages/harness` (`@cloudflare/think` + custom chat UI) from the core execution server. |
@@ -58,11 +58,21 @@ In `muxo2` (`projects-production-completion-plan.md`), the runtime was built on
58
58
  1. `muxo2` tried to wrap the Stripe CLI inside a separate **Cloudflare Container (`apps/projects-executor`)** behind a second **Cloudflare Worker (`apps/projects-gateway`)** with custom CA fingerprint pinning, UID=0 root directory checks, and 55-second container cold-start budgets.
59
59
  2. Inside the container, the `stripe-projects-cli` plugin was invoked directly without `PROJECTS_STANDALONE=1` or exceeded container memory/startup deadlines, resulting in `SIGKILL` and 9 consumed diagnostic attempts.
60
60
 
61
- ### Why It Works 100% Live in `muxo3`
62
- In `muxo3` (`src/providers/stripe-projects.ts`):
63
- 1. **Native Node.js 22 Runtime:** `muxo3` runs as a standard Node.js 22 process (locally or in a standard persistent Linux container on Railway/Fly.io/Render) and invokes `/Users/test/.local/bin/stripe projects ... --json` directly via `node:child_process`.
64
- 2. **Automatic Companion Plan Resolution:** When a deployable service (like `neon/postgres`) returns `PLAN_REQUIRED`, `StripeProjectsAdapter.provisionResource()` automatically inspects the provider catalog, provisions the free/default plan (`neon/free`), and completes `neon/postgres` provisioning in one seamless transaction.
65
- 3. **Encrypted Vault Custody:** Immediately after provisioning, `StripeProjectsAdapter` runs `stripe projects env --pull`, captures the real credentials (e.g., `NEON_POSTGRES_CONNECTION_STRING`), encrypts them with **AES-256-GCM** using a per-workspace HKDF-derived key in `MuxoStore` (`src/store.ts`), and exposes them only via explicit owner-authenticated `muxo env pull` or `GET /api/v1/resources/env`.
61
+ ### Why It Works 100% Live in `muxo3` (Native Stripe v2 Provisioning HTTP API + CLI)
62
+ In `muxo3` (`src/providers/stripe-projects.ts` and `worker/index.ts`), we integrate Stripe's gated **v2 Provisioning REST API** (`https://api.stripe.com/v2/provisioning/*` with header `Stripe-Version: 2026-09-30.preview`) alongside the local CLI:
63
+ 1. **Direct Stripe v2 Provisioning HTTP REST Client (Zero Container Required, V8 Isolate Ready):** Both `StripeProjectsAdapter` (Node.js) and `worker/index.ts` (Cloudflare Workers) call Stripe's `/v2/provisioning/*` REST endpoints directly over HTTPS using `Authorization: Bearer <sk_live_...|rk_live_...>` and `Stripe-Version: 2026-09-30.preview`:
64
+ - **Eligibilities:** `GET /v2/provisioning/eligibility` (`v2.provisioning.eligibility`)
65
+ - **Catalog Providers:** `GET /v2/provisioning/catalog/providers` (`v2.provisioning.provider`)
66
+ - **Catalog Service Details:** `GET /v2/provisioning/catalog/services` (`v2.provisioning.provider_service_detail`)
67
+ - **Payment Profiles & Spend Limits:** `GET /v2/provisioning/payment_profile` & `POST /v2/provisioning/payment_profile/update_limit` (`v2.provisioning.payment_profile`)
68
+ - **Payment Method Requests:** `POST /v2/provisioning/payment_method_requests` (`v2.provisioning.payment_method_request`)
69
+ - **Projects:** `POST /v2/provisioning/projects` (`v2.provisioning.project`)
70
+ - **Provider Connections:** `GET /v2/provisioning/provider_connections` & `POST /v2/provisioning/provider_connections/:id/unlink` (`v2.provisioning.provider_connection`)
71
+ - **Provider Connection Requests:** `POST /v2/provisioning/provider_connection_requests`, `GET /v2/provisioning/provider_connection_requests/:id`, & `POST /v2/provisioning/provider_connection_requests/:id/submit_information` (`v2.provisioning.provider_connection_request`)
72
+ - **Resources:** `POST /v2/provisioning/resources`, `POST /v2/provisioning/resources/link`, `GET /v2/provisioning/resources/:id`, `POST /v2/provisioning/resources/:id`, `POST /v2/provisioning/resources/:id/remove`, `POST /v2/provisioning/resources/:id/unlink`, `POST /v2/provisioning/resources/:id/rotate_credentials`, & `POST /v2/provisioning/resources/:id/submit_information` (`v2.provisioning.resource`)
73
+ - **Access Configurations (Secret Reveal):** `POST /v2/provisioning/resources/:id/reveal_access_configuration` (`v2.provisioning.resource.access_configuration` returning `{ configuration: Record<string, string>, expires_at }`)
74
+ 2. **Automatic Multi-Tier Fallback:** If the Stripe key does not yet have the `2026-09-30.preview` gate enabled, `StripeProjectsAdapter` transparently falls back to the local `stripe projects` CLI (when a `.projects` directory is present) or Muxo Cloud Managed Infrastructure.
75
+ 3. **Encrypted Vault Custody:** Immediately after `POST /v2/provisioning/resources` and `POST /v2/provisioning/resources/:id/reveal_access_configuration` (or `stripe projects env --pull`), `StripeProjectsAdapter` encrypts the returned credentials with **AES-256-GCM** using a per-workspace HKDF-derived key in `MuxoStore` (`src/store.ts`), exposing them only via owner-authenticated `muxo env pull`, `GET /api/v1/resources/env`, or `POST /api/v1/provisioning/resources/:id/reveal_access_configuration`.
66
76
 
67
77
  ---
68
78
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Muxo (`@muxoai/platform` / `@muxoai/cli` / `@muxoai/sdk`)
2
2
 
3
- Muxo (`v1.3.3`) is the unified execution, cloud infrastructure provisioning, contextual memory, and cryptographic governance platform for AI agents and applications. Customers and their agents interact exclusively with **Muxo** — either via structured tool slugs or free-form **Natural Language** (`muxo do`, `POST /api/v1/do`, `client.do()`, and MCP `plan_action`).
3
+ Muxo (`v1.4.0`) is the unified execution, cloud infrastructure provisioning, contextual memory, and cryptographic governance platform for AI agents and applications. Customers and their agents interact exclusively with **Muxo** — either via structured tool slugs or free-form **Natural Language** (`muxo do`, `POST /api/v1/do`, `client.do()`, and MCP `plan_action`).
4
4
 
5
5
  See [`ARCHITECTURE.md`](./ARCHITECTURE.md) for the complete internal engineering blueprint, open-source ecosystem Keep/Adopt/Drop matrix, and 4-pillar architecture.
6
6
 
@@ -37,10 +37,12 @@ muxo byok set openai # Interactive hidden/line prompt if key omitted
37
37
  muxo byok set composio # Executes app.* and instant.* tools at 0 Muxo credit cost
38
38
  muxo byok list
39
39
 
40
- # 6. Manage Billing, Credits & Starter Plan ($29/mo)
40
+ # 6. Manage Billing, Credits & Plans (Starter $29/mo, Pro $99/mo, yearly 2 months free)
41
41
  muxo billing status
42
+ muxo billing plans
42
43
  muxo billing topup 1000
43
- muxo billing upgrade
44
+ muxo billing upgrade --plan pro --yearly
45
+ muxo billing portal
44
46
 
45
47
  # 7. Connect an OAuth SaaS App (browser consent handoff) & Provision Live Cloud Infrastructure
46
48
  muxo link gmail --wait
@@ -114,8 +116,8 @@ Muxo ships a portable OpenAI Plugin (`plugins/muxo/plugin.json` & `plugins/muxo/
114
116
  | `src/store.ts` | SQLite (`node:sqlite`) store, AES-256-GCM secret vault, credit/settlement ledger, memories, agent claims, and HMAC-SHA256 receipt chain |
115
117
  | `src/providers/composio-sdk.ts` | Live Composio v3 Connected Apps adapter (catalog search, OAuth sessions/links, tool execution) |
116
118
  | `src/providers/composio-instant.ts` | Live Composio Instant adapter (`search`, `scrape`, `crawl`, `seo.audit`, `hackernews`, `github.repo_intel`, `dns.lookup`, `workbench`) |
117
- | `src/providers/stripe-projects.ts` | Live Stripe Projects CLI bridge (`status`, `catalog`, `add`, `rotate`, `remove`, `env --pull`) |
118
- | `src/providers/stripe-billing.ts` | Live Stripe Checkout billing (`$29/mo Starter Plan` & `$10 / +1,000 Credits Pack`) |
119
+ | `src/providers/stripe-projects.ts` | Live Stripe v2 Provisioning REST API (`2026-09-30.preview`) & Stripe Projects CLI bridge (`eligibility`, `catalog`, `payment_profile`, `provider_connections`, `resources`, `reveal_access_configuration`, `rotate`, `remove`, `env --pull`) |
120
+ | `src/providers/stripe-billing.ts` | Live Stripe Checkout billing (Starter `$29/mo`, Pro `$99/mo`, yearly billing & credit packs with volume discounts) |
119
121
  | `src/providers/microsoft-governance.ts` | Microsoft Agent Governance Toolkit v5.0.0 (`McpSecurityScanner`, `PolicyEngine`, `AgentIdentity` Ed25519 DID, `AuditLogger`) |
120
122
  | `src/providers/supermemory.ts` | Supermemory v5 Contextual Brain (`profile`, hybrid `search`, secret-redacted `add`, `delete`) |
121
123
  | `src/engine.ts` | Unified Governance, Memory & Execution Engine implementing all 19 canonical MCP operations |
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import readline from "node:readline";
6
6
  import { getConfig } from "./config.js";
7
7
  import { MuxoEngine } from "./engine.js";
8
8
  import { handleJsonRpcMcpRequest } from "./mcp.js";
9
- import { sanitizePolicyPatch } from "./policy.js";
9
+ import { DEFAULT_WORKSPACE_POLICY, describePolicyInPlainEnglish, sanitizePolicyPatch, } from "./policy.js";
10
10
  import { RING_LABELS } from "./providers/microsoft-governance.js";
11
11
  import { BYOK_PROVIDER_CATALOG, MuxoStore } from "./store.js";
12
12
  import { MUXO_VERSION } from "./version.js";
@@ -113,6 +113,9 @@ async function runCli() {
113
113
  if (opts?.acceptPaymentRequired && res.status === 402 && data.checkoutUrl) {
114
114
  return data;
115
115
  }
116
+ if (opts?.acceptHumanRequired && res.status === 403 && data.code === "human_required") {
117
+ return data;
118
+ }
116
119
  if (!res.ok && data.error) {
117
120
  throw new Error(String(data.error));
118
121
  }
@@ -177,6 +180,27 @@ async function runCli() {
177
180
  const maskKey = (key) => `${key.slice(0, 14)}…`;
178
181
  // Hosted Muxo answers purchases with 402 + a Stripe Checkout URL; a self-hosted dev server may grant credits directly.
179
182
  const printBillingResult = (data) => {
183
+ if (data.code === "human_required" || data.status === "human_required") {
184
+ console.log(JSON.stringify({
185
+ ok: false,
186
+ humanRequired: true,
187
+ url: data.url,
188
+ error: data.error,
189
+ next: "Open the url in a browser and sign in to the Muxo console to finish this step. Agent API keys cannot manage billing or approvals.",
190
+ }, null, 2));
191
+ return;
192
+ }
193
+ if (data.portalUrl) {
194
+ console.log(JSON.stringify({
195
+ ok: true,
196
+ actionRequired: true,
197
+ tier: data.tier,
198
+ interval: data.interval,
199
+ portalUrl: data.portalUrl,
200
+ next: data.nextStep || "Open portalUrl in a browser; a signed-in person confirms the plan change in the Stripe billing portal.",
201
+ }, null, 2));
202
+ return;
203
+ }
180
204
  if (!data.checkoutUrl) {
181
205
  console.log(JSON.stringify(data, null, 2));
182
206
  return;
@@ -313,17 +337,27 @@ async function runCli() {
313
337
  ? flags["api-key"].trim()
314
338
  : typeof flags.key === "string"
315
339
  ? flags.key.trim()
316
- : "";
340
+ : positional[1]?.startsWith("mk_")
341
+ ? positional[1].trim()
342
+ : "";
317
343
  let activeConfig = savedCliConfig;
318
344
  if (explicitKey) {
319
345
  const agentName = typeof flags.name === "string" ? flags.name : "Muxo Agent";
320
346
  if (remoteUrl) {
321
347
  apiKeyFlag = explicitKey;
322
- const orgRes = (await remoteFetch("/api/v1/organization").catch(() => ({})));
348
+ const joinRes = (await remoteFetch("/api/v1/workspaces/join", {
349
+ method: "POST",
350
+ body: { apiKey: explicitKey },
351
+ apiKey: explicitKey,
352
+ }).catch(() => null));
353
+ const orgRes = joinRes?.workspace
354
+ ? { organization: joinRes.workspace }
355
+ : (await remoteFetch("/api/v1/organization").catch(() => ({})));
323
356
  const org = orgRes?.organization || orgRes?.workspace || {};
324
357
  activeConfig = {
325
358
  authenticated: true,
326
359
  apiKey: explicitKey,
360
+ apiUrl: remoteUrl,
327
361
  workspaceId: org.id || "ws_remote",
328
362
  workspaceName: org.name || agentName,
329
363
  agentId: "usr_remote",
@@ -971,7 +1005,7 @@ async function runCli() {
971
1005
  provider,
972
1006
  timeoutSeconds,
973
1007
  });
974
- console.log(JSON.stringify({ ok: true, ...waited }, null, 2));
1008
+ console.log(JSON.stringify(waited, null, 2));
975
1009
  return;
976
1010
  }
977
1011
  if (cmd === "plan") {
@@ -998,7 +1032,18 @@ async function runCli() {
998
1032
  if (!planId)
999
1033
  throw new Error("Usage: muxo approve <plan_id>");
1000
1034
  if (remoteUrl) {
1001
- const approved = await remoteFetch(`/api/v1/plans/${encodeURIComponent(planId)}/approve`, { method: "POST", body: {} });
1035
+ const approved = await remoteFetch(`/api/v1/plans/${encodeURIComponent(planId)}/approve`, { method: "POST", body: {}, acceptHumanRequired: true });
1036
+ if (approved.code === "human_required") {
1037
+ console.log(JSON.stringify({
1038
+ ok: false,
1039
+ humanRequired: true,
1040
+ planId,
1041
+ approvalUrl: approved.url,
1042
+ error: approved.error,
1043
+ hint: "Open approvalUrl in a browser; a signed-in person approves the plan in the Muxo console. Agent API keys cannot approve plans.",
1044
+ }, null, 2));
1045
+ return;
1046
+ }
1002
1047
  console.log(JSON.stringify(approved.plan || approved, null, 2));
1003
1048
  return;
1004
1049
  }
@@ -1050,7 +1095,18 @@ async function runCli() {
1050
1095
  const plan = planned.plan || planned;
1051
1096
  if (plan.approvalStatus === "pending_approval") {
1052
1097
  if (flags.approve || cmd === "provision") {
1053
- await remoteFetch(`/api/v1/plans/${encodeURIComponent(plan.id)}/approve`, { method: "POST", body: {} });
1098
+ const approved = await remoteFetch(`/api/v1/plans/${encodeURIComponent(plan.id)}/approve`, { method: "POST", body: {}, acceptHumanRequired: true });
1099
+ if (approved.code === "human_required") {
1100
+ console.log(JSON.stringify({
1101
+ ok: false,
1102
+ status: "pending_approval",
1103
+ humanRequired: true,
1104
+ plan,
1105
+ approvalUrl: approved.url,
1106
+ hint: "This plan needs approval from a signed-in person. Open approvalUrl in a browser to approve it in the Muxo console; agent API keys cannot approve plans.",
1107
+ }, null, 2));
1108
+ return;
1109
+ }
1054
1110
  }
1055
1111
  else {
1056
1112
  console.log(JSON.stringify({
@@ -1183,17 +1239,17 @@ async function runCli() {
1183
1239
  console.log(JSON.stringify(res, null, 2));
1184
1240
  }
1185
1241
  else {
1186
- const runsRes = await remoteFetch("/api/v1/runs");
1187
- console.log(JSON.stringify(runsRes.runs || runsRes, null, 2));
1242
+ const res = await remoteFetch("/api/v1/receipts?limit=20");
1243
+ console.log(JSON.stringify(res, null, 2));
1188
1244
  }
1189
1245
  return;
1190
1246
  }
1191
- const { store, engine, ctx } = getLocalContext();
1247
+ const { engine, ctx } = getLocalContext();
1192
1248
  if (receiptId) {
1193
1249
  console.log(JSON.stringify(engine.getReceipt(ctx, receiptId), null, 2));
1194
1250
  }
1195
1251
  else {
1196
- console.log(JSON.stringify(store.listReceipts(ctx.workspace.id, 20), null, 2));
1252
+ console.log(JSON.stringify({ ok: true, ...engine.listReceipts(ctx, 20) }, null, 2));
1197
1253
  }
1198
1254
  return;
1199
1255
  }
@@ -1230,11 +1286,17 @@ async function runCli() {
1230
1286
  return;
1231
1287
  }
1232
1288
  if (sub === "upgrade") {
1289
+ const planArg = String(flags.plan || positional[2] || "starter").toLowerCase();
1290
+ const tier = planArg === "pro" ? "pro" : "starter";
1291
+ const interval = flags.yearly || flags.year || String(flags.interval || "").startsWith("y")
1292
+ ? "year"
1293
+ : "month";
1233
1294
  if (remoteUrl) {
1234
1295
  const data = await remoteFetch("/api/v1/billing/upgrade", {
1235
1296
  method: "POST",
1236
- body: { tier: "starter", bonusCredits: 1000 },
1297
+ body: { tier, interval },
1237
1298
  acceptPaymentRequired: true,
1299
+ acceptHumanRequired: true,
1238
1300
  });
1239
1301
  printBillingResult(data);
1240
1302
  return;
@@ -1282,6 +1344,27 @@ async function runCli() {
1282
1344
  console.log(JSON.stringify({ ok: true, kind, ...session }, null, 2));
1283
1345
  return;
1284
1346
  }
1347
+ if (sub === "plans") {
1348
+ const plansUrl = remoteUrl || config.baseUrl;
1349
+ const res = await fetch(`${plansUrl}/api/v1/billing/plans`, {
1350
+ headers: { Accept: "application/json" },
1351
+ });
1352
+ const data = (await res.json().catch(() => ({})));
1353
+ console.log(JSON.stringify(data, null, 2));
1354
+ return;
1355
+ }
1356
+ if (sub === "portal") {
1357
+ if (remoteUrl) {
1358
+ const data = await remoteFetch("/api/v1/billing/portal", {
1359
+ method: "POST",
1360
+ body: {},
1361
+ acceptHumanRequired: true,
1362
+ });
1363
+ printBillingResult(data);
1364
+ return;
1365
+ }
1366
+ throw new Error("muxo billing portal is only available for the hosted Muxo service (set --remote or log in first).");
1367
+ }
1285
1368
  if (sub === "verify") {
1286
1369
  const sessionId = positional[2] || String(flags.session || "");
1287
1370
  if (!sessionId)
@@ -1760,6 +1843,125 @@ async function runCli() {
1760
1843
  }, null, 2));
1761
1844
  return;
1762
1845
  }
1846
+ if (cmd === "context") {
1847
+ const query = positional.slice(1).join(" ") ||
1848
+ (typeof flags.query === "string" ? flags.query : "") ||
1849
+ undefined;
1850
+ if (remoteUrl) {
1851
+ const suffix = query ? `?query=${encodeURIComponent(query)}` : "";
1852
+ const res = await remoteFetch(`/api/v1/context${suffix}`);
1853
+ console.log(JSON.stringify(res, null, 2));
1854
+ return;
1855
+ }
1856
+ const { engine, ctx } = getLocalContext();
1857
+ const runContext = await engine.getRunContext(ctx, query);
1858
+ console.log(JSON.stringify({ ok: true, ...runContext }, null, 2));
1859
+ return;
1860
+ }
1861
+ if (cmd === "guardrails" || cmd === "guardrail") {
1862
+ const sub = positional[1];
1863
+ if (sub === "set" || sub === "add") {
1864
+ const prompt = positional.slice(2).join(" ").trim() ||
1865
+ String(flags.prompt || flags.rule || "").trim();
1866
+ const rawRulesJson = typeof flags["rules-json"] === "string"
1867
+ ? flags["rules-json"]
1868
+ : typeof flags.rules === "string"
1869
+ ? flags.rules
1870
+ : undefined;
1871
+ const parsedParamRules = rawRulesJson
1872
+ ? JSON.parse(rawRulesJson)
1873
+ : undefined;
1874
+ if (!prompt && (!parsedParamRules || parsedParamRules.length === 0)) {
1875
+ throw new Error('Usage: muxo guardrails set "<plain-English rule>" [--rules-json \'[...]\'] (e.g. muxo guardrails set "auto approve under $50 and require approval over $50")');
1876
+ }
1877
+ if (remoteUrl) {
1878
+ const res = await remoteFetch("/api/v1/guardrails", {
1879
+ method: "POST",
1880
+ body: {
1881
+ prompt,
1882
+ ...(parsedParamRules ? { parameterRules: parsedParamRules } : {}),
1883
+ },
1884
+ });
1885
+ console.log(JSON.stringify(res, null, 2));
1886
+ return;
1887
+ }
1888
+ const { engine, ctx } = getLocalContext();
1889
+ const applied = await engine.applyNaturalLanguageGuardrail(ctx, prompt, {
1890
+ parameterRules: parsedParamRules,
1891
+ source: parsedParamRules ? "mcp_harness" : "deterministic",
1892
+ });
1893
+ console.log(JSON.stringify({
1894
+ ...applied,
1895
+ humanMessage: `Guardrail active: ${applied.guardrail.summary}`,
1896
+ }, null, 2));
1897
+ return;
1898
+ }
1899
+ if (sub === "reset") {
1900
+ if (remoteUrl) {
1901
+ const res = await remoteFetch("/api/v1/guardrails", {
1902
+ method: "POST",
1903
+ body: { reset: true },
1904
+ });
1905
+ console.log(JSON.stringify(res, null, 2));
1906
+ return;
1907
+ }
1908
+ const { store, ctx } = getLocalContext();
1909
+ const updated = store.updateWorkspacePolicy(ctx.workspace.id, DEFAULT_WORKSPACE_POLICY);
1910
+ console.log(JSON.stringify({
1911
+ ok: true,
1912
+ workspace: updated,
1913
+ plainEnglish: describePolicyInPlainEnglish(updated.policy),
1914
+ humanMessage: "Reset workspace guardrails to Safe Default.",
1915
+ }, null, 2));
1916
+ return;
1917
+ }
1918
+ if (remoteUrl) {
1919
+ const res = await remoteFetch("/api/v1/guardrails");
1920
+ console.log(JSON.stringify(res, null, 2));
1921
+ return;
1922
+ }
1923
+ const { engine, ctx } = getLocalContext();
1924
+ const summary = engine.getGuardrailsSummary(ctx);
1925
+ console.log(JSON.stringify({ ok: true, ...summary }, null, 2));
1926
+ return;
1927
+ }
1928
+ if (cmd === "policy") {
1929
+ const nlText = positional.slice(1).join(" ").trim() ||
1930
+ String(flags.rule || flags.prompt || "").trim();
1931
+ if (nlText) {
1932
+ if (remoteUrl) {
1933
+ const res = await remoteFetch("/api/v1/guardrails", {
1934
+ method: "POST",
1935
+ body: { prompt: nlText },
1936
+ });
1937
+ console.log(JSON.stringify(res, null, 2));
1938
+ return;
1939
+ }
1940
+ const { engine, ctx } = getLocalContext();
1941
+ const applied = await engine.applyNaturalLanguageGuardrail(ctx, nlText);
1942
+ console.log(JSON.stringify({
1943
+ ...applied,
1944
+ humanMessage: `Guardrail active: ${applied.guardrail.summary}`,
1945
+ }, null, 2));
1946
+ return;
1947
+ }
1948
+ if (remoteUrl) {
1949
+ const res = await remoteFetch("/api/v1/policy");
1950
+ console.log(JSON.stringify(res, null, 2));
1951
+ return;
1952
+ }
1953
+ const { engine, ctx } = getLocalContext();
1954
+ const summary = engine.getGuardrailsSummary(ctx);
1955
+ console.log(JSON.stringify({
1956
+ ok: true,
1957
+ policy: summary.policy,
1958
+ plainEnglish: summary.plainEnglish,
1959
+ explanation: summary.plainEnglish.explanation,
1960
+ activeDefaults: summary.activeDefaults,
1961
+ activeGuardrails: summary.activeGuardrails,
1962
+ }, null, 2));
1963
+ return;
1964
+ }
1763
1965
  if (cmd === "governance") {
1764
1966
  const sub = positional[1];
1765
1967
  const ringLabel = (policy) => policy?.executionRing !== undefined
@@ -1884,6 +2086,178 @@ async function runCli() {
1884
2086
  }, null, 2));
1885
2087
  return;
1886
2088
  }
2089
+ if (cmd === "workspaces" || cmd === "workspace") {
2090
+ const sub = positional[1] || "list";
2091
+ if (sub === "list" || sub === "ls") {
2092
+ if (remoteUrl) {
2093
+ const res = await remoteFetch("/api/v1/workspaces");
2094
+ console.log(JSON.stringify(res, null, 2));
2095
+ return;
2096
+ }
2097
+ const { store, ctx } = getLocalContext();
2098
+ const workspaces = store.listUserWorkspaces(ctx.user.id, ctx.workspace.id);
2099
+ console.log(JSON.stringify({ ok: true, currentWorkspaceId: ctx.workspace.id, workspaces }, null, 2));
2100
+ return;
2101
+ }
2102
+ if (sub === "create" || sub === "new") {
2103
+ const name = positional.slice(2).join(" ").trim() ||
2104
+ (typeof flags.name === "string" ? flags.name.trim() : "");
2105
+ if (!name) {
2106
+ throw new Error("Usage: muxo workspaces create <name> [--team <teamName>]");
2107
+ }
2108
+ const teamName = typeof flags.team === "string" ? flags.team.trim() : undefined;
2109
+ if (remoteUrl) {
2110
+ const res = await remoteFetch("/api/v1/workspaces", {
2111
+ method: "POST",
2112
+ body: { name, teamName },
2113
+ });
2114
+ console.log(JSON.stringify(res, null, 2));
2115
+ return;
2116
+ }
2117
+ const { store, ctx } = getLocalContext();
2118
+ const created = store.createWorkspaceForUser({
2119
+ userId: ctx.user.id,
2120
+ name,
2121
+ teamName,
2122
+ });
2123
+ console.log(JSON.stringify({
2124
+ ok: true,
2125
+ workspace: created.workspace,
2126
+ apiKey: created.apiKey,
2127
+ workspaces: store.listUserWorkspaces(ctx.user.id, created.workspace.id),
2128
+ }, null, 2));
2129
+ return;
2130
+ }
2131
+ if (sub === "switch" || sub === "use") {
2132
+ const workspaceId = positional[2]?.trim() ||
2133
+ (typeof flags.id === "string" ? flags.id.trim() : "");
2134
+ if (!workspaceId) {
2135
+ throw new Error("Usage: muxo workspaces switch <workspace_id>");
2136
+ }
2137
+ if (remoteUrl) {
2138
+ const res = await remoteFetch("/api/v1/workspaces/switch", {
2139
+ method: "POST",
2140
+ body: { workspaceId },
2141
+ });
2142
+ console.log(JSON.stringify(res, null, 2));
2143
+ return;
2144
+ }
2145
+ const { store, ctx } = getLocalContext();
2146
+ const switched = store.switchUserWorkspace(ctx.user.id, workspaceId);
2147
+ if (!switched) {
2148
+ throw new Error(`Workspace '${workspaceId}' not found or not accessible.`);
2149
+ }
2150
+ console.log(JSON.stringify({
2151
+ ok: true,
2152
+ workspace: switched.workspace,
2153
+ workspaces: store.listUserWorkspaces(ctx.user.id, switched.workspace.id),
2154
+ }, null, 2));
2155
+ return;
2156
+ }
2157
+ if (sub === "join") {
2158
+ const keyToJoin = positional[2]?.trim() ||
2159
+ (typeof flags["api-key"] === "string"
2160
+ ? flags["api-key"].trim()
2161
+ : typeof flags.key === "string"
2162
+ ? flags.key.trim()
2163
+ : "");
2164
+ if (!keyToJoin) {
2165
+ throw new Error("Usage: muxo workspaces join <mk_live_...>");
2166
+ }
2167
+ if (remoteUrl) {
2168
+ const res = await remoteFetch("/api/v1/workspaces/join", {
2169
+ method: "POST",
2170
+ body: { apiKey: keyToJoin },
2171
+ });
2172
+ const ws = res.workspace || {};
2173
+ writeCliAuthConfig({
2174
+ authenticated: true,
2175
+ apiKey: keyToJoin,
2176
+ apiUrl: remoteUrl,
2177
+ workspaceId: String(ws.id || "ws_remote"),
2178
+ workspaceName: String(ws.name || "Muxo Workspace"),
2179
+ agentId: "usr_remote",
2180
+ governanceDid: `did:muxo:${ws.id || "ws_remote"}`,
2181
+ supermemoryNamespace: `muxo_${ws.id || "ws_remote"}`,
2182
+ updatedAt: new Date().toISOString(),
2183
+ });
2184
+ console.log(JSON.stringify(res, null, 2));
2185
+ return;
2186
+ }
2187
+ const { store, ctx, engine } = getLocalContext();
2188
+ const joined = store.joinWorkspaceWithApiKey({
2189
+ apiKey: keyToJoin,
2190
+ userId: ctx.user.id,
2191
+ });
2192
+ if (!joined) {
2193
+ throw new Error("Invalid or revoked Muxo API key.");
2194
+ }
2195
+ writeCliAuthConfig({
2196
+ authenticated: true,
2197
+ apiKey: keyToJoin,
2198
+ workspaceId: joined.workspace.id,
2199
+ workspaceName: joined.workspace.name,
2200
+ agentId: ctx.user.id,
2201
+ governanceDid: engine.governance.getStatus(joined.workspace).agentDid,
2202
+ supermemoryNamespace: engine.supermemory.getWorkspaceNamespace(joined.workspace.id),
2203
+ updatedAt: new Date().toISOString(),
2204
+ });
2205
+ console.log(JSON.stringify({
2206
+ ok: true,
2207
+ mode: "api_key_join",
2208
+ workspace: joined.workspace,
2209
+ keyRecord: joined.keyRecord,
2210
+ membership: joined.membership,
2211
+ }, null, 2));
2212
+ return;
2213
+ }
2214
+ }
2215
+ if (cmd === "team" || cmd === "teams") {
2216
+ const sub = positional[1] || "onboard";
2217
+ const teamName = (sub === "onboard" || sub === "invite" || sub === "add"
2218
+ ? positional.slice(2).join(" ")
2219
+ : positional.slice(1).join(" ")).trim() ||
2220
+ (typeof flags.name === "string" ? flags.name.trim() : "") ||
2221
+ (typeof flags.team === "string" ? flags.team.trim() : "");
2222
+ if (!teamName) {
2223
+ throw new Error('Usage: muxo team onboard "<team_name>" [--mode shared|dedicated] [--role operator|admin|member]');
2224
+ }
2225
+ const rawMode = typeof flags.mode === "string" ? flags.mode.trim() : "";
2226
+ const mode = rawMode === "dedicated" || rawMode === "dedicated_workspace"
2227
+ ? "dedicated_workspace"
2228
+ : "shared_workspace";
2229
+ const role = typeof flags.role === "string" &&
2230
+ ["owner", "admin", "operator", "member"].includes(flags.role)
2231
+ ? flags.role
2232
+ : "operator";
2233
+ const environment = flags.test ? "test" : "live";
2234
+ if (remoteUrl) {
2235
+ const res = await remoteFetch("/api/v1/workspaces/onboard-team", {
2236
+ method: "POST",
2237
+ body: { teamName, mode, role, environment },
2238
+ });
2239
+ console.log(JSON.stringify(res, null, 2));
2240
+ return;
2241
+ }
2242
+ const { store, ctx } = getLocalContext();
2243
+ const kit = store.onboardTeam({
2244
+ userId: ctx.user.id,
2245
+ userEmail: ctx.user.email,
2246
+ currentWorkspaceId: ctx.workspace.id,
2247
+ teamName,
2248
+ role,
2249
+ mode,
2250
+ environment,
2251
+ baseUrl: config.baseUrl,
2252
+ });
2253
+ console.log(JSON.stringify({
2254
+ ok: true,
2255
+ kit,
2256
+ workspace: kit.workspace,
2257
+ apiKey: kit.apiKey,
2258
+ }, null, 2));
2259
+ return;
2260
+ }
1887
2261
  if (cmd === "serve") {
1888
2262
  const { createMuxoServer } = await import("./server.js");
1889
2263
  const port = flags.port ? Number(flags.port) : config.port;
@@ -1948,12 +2322,17 @@ async function runCli() {
1948
2322
  Muxo CLI — Unified Agent Execution, Cloud Infrastructure, Memory & Safety Platform
1949
2323
 
1950
2324
  Natural Language & Interactive TUI:
1951
- muxo setup 1-command auto-signup + MCP setup (.mcp.json + ~/.muxo/config.json)
2325
+ muxo setup [--api-key <key>] 1-command auto-signup (or join via team API key) + MCP setup
1952
2326
  muxo do "<instruction>" Execute any goal in plain English (LLM/semantic router -> plan -> execute)
1953
2327
  muxo ask "<instruction>" [--plan-only] Alias for 'muxo do' (pass --plan-only to inspect plan before running)
1954
2328
  muxo tui Launch interactive Terminal UI dashboard (BYOK, Billing, OAuth, Infra)
1955
2329
  muxo byok [list|set|delete] [<provider>] Manage BYOK API keys in AES-256-GCM Vault (0 credit cost when active)
1956
2330
 
2331
+ Workspaces & Team Onboarding:
2332
+ muxo workspaces [list|create|switch|join] List, create, switch, or join workspaces via API key
2333
+ muxo team onboard "<team>" [--mode shared|dedicated] [--role operator|admin|member]
2334
+ Mint a scoped team API key & onboarding kit for another team
2335
+
1957
2336
  Core Commands:
1958
2337
  muxo login [--api-key <key> | --signup] Sign in or create an autonomous workspace (~/.muxo/config.json)
1959
2338
  muxo logout Remove saved CLI authentication config
@@ -1969,6 +2348,7 @@ Core Commands:
1969
2348
  muxo approve <plan_id> Approve a pending high-risk plan
1970
2349
  muxo run <plan_id> Execute an approved plan and issue a verifiable audit record
1971
2350
  muxo exec <tool_slug> --input '{...}' Plan and execute in one step (pass --approve for high-risk)
2351
+ muxo provision <provider> [--name <name>] Provision cloud infrastructure (e.g., turso, neon, supabase, upstash)
1972
2352
  muxo resources List provisioned Muxo Cloud Infrastructure resources
1973
2353
  muxo env pull [--out .env.muxo] Decrypt and write provisioned credentials to local .env
1974
2354
  muxo receipts [<receipt_id>] List or verify execution audit records
@@ -1984,7 +2364,7 @@ Core Commands:
1984
2364
  [--block-destructive-sql true|false] [--max-credits <n>]
1985
2365
  muxo harness Check API, MCP, auth, governance and catalog; print MCP config
1986
2366
  muxo serve [--port 4310] Start unified HTTP Console, Landing, OAuth Callback & MCP server
1987
- muxo mcp Run stdio MCP server (20 canonical tools)
2367
+ muxo mcp Run stdio MCP server (19 canonical tools)
1988
2368
  `);
1989
2369
  }
1990
2370
  runCli()