@muxoai/platform 1.4.0 → 1.4.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 (62) 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 +2 -2
  5. package/dist/cli.js +323 -13
  6. package/dist/composio-catalog.d.ts +234 -0
  7. package/dist/composio-catalog.js +1894 -0
  8. package/dist/config.d.ts +16 -0
  9. package/dist/config.js +27 -1
  10. package/dist/durable-workflow.d.ts +45 -0
  11. package/dist/durable-workflow.js +90 -0
  12. package/dist/engine.d.ts +293 -5
  13. package/dist/engine.js +1502 -88
  14. package/dist/mcp-schema.d.ts +286 -0
  15. package/dist/mcp-schema.js +2559 -0
  16. package/dist/mcp.d.ts +2 -30
  17. package/dist/mcp.js +913 -558
  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 +182 -1
  24. package/dist/policy.js +1524 -0
  25. package/dist/providers/composio-instant.js +262 -7
  26. package/dist/providers/composio-sdk.d.ts +125 -5
  27. package/dist/providers/composio-sdk.js +901 -82
  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 +455 -3
  33. package/dist/providers/stripe-projects.js +2570 -129
  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 +440 -3
  39. package/dist/sdk.js +305 -3
  40. package/dist/server.js +2343 -264
  41. package/dist/store.d.ts +113 -6
  42. package/dist/store.js +677 -52
  43. package/dist/types.d.ts +207 -3
  44. package/dist/ui/console-html.d.ts +40 -1
  45. package/dist/ui/console-html.js +1813 -629
  46. package/dist/ui/design-tokens.js +1 -1
  47. package/dist/version.d.ts +1 -1
  48. package/dist/version.js +1 -1
  49. package/package.json +4 -3
  50. package/plugins/muxo/.claude-plugin/plugin.json +2 -2
  51. package/plugins/muxo/.codex-plugin/plugin.json +15 -8
  52. package/plugins/muxo/.cursor-plugin/plugin.json +30 -0
  53. package/plugins/muxo/hooks/session-start.sh +15 -3
  54. package/plugins/muxo/hooks/user-prompt-submit.sh +14 -1
  55. package/plugins/muxo/mcp.json +0 -10
  56. package/plugins/muxo/plugin.json +4 -4
  57. package/plugins/muxo/skills/muxo/SKILL.md +59 -9
  58. package/plugins/muxo/skills/muxo/references/cli.md +5 -1
  59. package/plugins/muxo/skills/muxo/references/mcp.md +13 -7
  60. package/plugins/muxo/skills/muxo-activity-summary/SKILL.md +81 -0
  61. package/plugins/muxo/skills/setup/SKILL.md +9 -1
  62. package/src/catalogues/stripe-projects-catalog.json +140 -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.2",
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.2"
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.2",
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.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`).
3
+ Muxo (`v1.4.2`) 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
 
@@ -116,7 +116,7 @@ Muxo ships a portable OpenAI Plugin (`plugins/muxo/plugin.json` & `plugins/muxo/
116
116
  | `src/store.ts` | SQLite (`node:sqlite`) store, AES-256-GCM secret vault, credit/settlement ledger, memories, agent claims, and HMAC-SHA256 receipt chain |
117
117
  | `src/providers/composio-sdk.ts` | Live Composio v3 Connected Apps adapter (catalog search, OAuth sessions/links, tool execution) |
118
118
  | `src/providers/composio-instant.ts` | Live Composio Instant adapter (`search`, `scrape`, `crawl`, `seo.audit`, `hackernews`, `github.repo_intel`, `dns.lookup`, `workbench`) |
119
- | `src/providers/stripe-projects.ts` | Live Stripe Projects CLI bridge (`status`, `catalog`, `add`, `rotate`, `remove`, `env --pull`) |
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
120
  | `src/providers/stripe-billing.ts` | Live Stripe Checkout billing (Starter `$29/mo`, Pro `$99/mo`, yearly billing & credit packs with volume discounts) |
121
121
  | `src/providers/microsoft-governance.ts` | Microsoft Agent Governance Toolkit v5.0.0 (`McpSecurityScanner`, `PolicyEngine`, `AgentIdentity` Ed25519 DID, `AuditLogger`) |
122
122
  | `src/providers/supermemory.ts` | Supermemory v5 Contextual Brain (`profile`, hybrid `search`, secret-redacted `add`, `delete`) |
package/dist/cli.js CHANGED
@@ -5,8 +5,8 @@ import path from "node:path";
5
5
  import readline from "node:readline";
6
6
  import { getConfig } from "./config.js";
7
7
  import { MuxoEngine } from "./engine.js";
8
- import { handleJsonRpcMcpRequest } from "./mcp.js";
9
- import { sanitizePolicyPatch } from "./policy.js";
8
+ import { handleJsonRpcMcpRequest, LATEST_MCP_PROTOCOL_VERSION } from "./mcp.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";
@@ -337,17 +337,27 @@ async function runCli() {
337
337
  ? flags["api-key"].trim()
338
338
  : typeof flags.key === "string"
339
339
  ? flags.key.trim()
340
- : "";
340
+ : positional[1]?.startsWith("mk_")
341
+ ? positional[1].trim()
342
+ : "";
341
343
  let activeConfig = savedCliConfig;
342
344
  if (explicitKey) {
343
345
  const agentName = typeof flags.name === "string" ? flags.name : "Muxo Agent";
344
346
  if (remoteUrl) {
345
347
  apiKeyFlag = explicitKey;
346
- 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(() => ({})));
347
356
  const org = orgRes?.organization || orgRes?.workspace || {};
348
357
  activeConfig = {
349
358
  authenticated: true,
350
359
  apiKey: explicitKey,
360
+ apiUrl: remoteUrl,
351
361
  workspaceId: org.id || "ws_remote",
352
362
  workspaceName: org.name || agentName,
353
363
  agentId: "usr_remote",
@@ -522,6 +532,9 @@ async function runCli() {
522
532
  if (mcpSessionId) {
523
533
  headers["Mcp-Session-Id"] = mcpSessionId;
524
534
  }
535
+ if (typeof rpc.method === "string" && rpc.method.trim()) {
536
+ headers["Mcp-Method"] = rpc.method.trim();
537
+ }
525
538
  const res = await fetch(`${remoteUrl}/mcp`, {
526
539
  method: "POST",
527
540
  headers,
@@ -644,7 +657,7 @@ async function runCli() {
644
657
  });
645
658
  await runCheck("mcp_initialize", "MCP server accepts a session", async () => {
646
659
  const result = await mcpCall(1, "initialize", {
647
- protocolVersion: "2025-06-18",
660
+ protocolVersion: LATEST_MCP_PROTOCOL_VERSION,
648
661
  capabilities: {},
649
662
  clientInfo: { name: "muxo-cli-harness", version: MUXO_VERSION },
650
663
  });
@@ -700,7 +713,7 @@ async function runCli() {
700
713
  jsonrpc: "2.0",
701
714
  id: 1,
702
715
  method: "initialize",
703
- params: { protocolVersion: "2025-06-18", capabilities: {} },
716
+ params: { protocolVersion: LATEST_MCP_PROTOCOL_VERSION, capabilities: {} },
704
717
  });
705
718
  const info = res?.result?.serverInfo;
706
719
  assertCheck(info?.name, "initialize returned no serverInfo");
@@ -995,7 +1008,7 @@ async function runCli() {
995
1008
  provider,
996
1009
  timeoutSeconds,
997
1010
  });
998
- console.log(JSON.stringify({ ok: true, ...waited }, null, 2));
1011
+ console.log(JSON.stringify(waited, null, 2));
999
1012
  return;
1000
1013
  }
1001
1014
  if (cmd === "plan") {
@@ -1229,17 +1242,17 @@ async function runCli() {
1229
1242
  console.log(JSON.stringify(res, null, 2));
1230
1243
  }
1231
1244
  else {
1232
- const runsRes = await remoteFetch("/api/v1/runs");
1233
- console.log(JSON.stringify(runsRes.runs || runsRes, null, 2));
1245
+ const res = await remoteFetch("/api/v1/receipts?limit=20");
1246
+ console.log(JSON.stringify(res, null, 2));
1234
1247
  }
1235
1248
  return;
1236
1249
  }
1237
- const { store, engine, ctx } = getLocalContext();
1250
+ const { engine, ctx } = getLocalContext();
1238
1251
  if (receiptId) {
1239
1252
  console.log(JSON.stringify(engine.getReceipt(ctx, receiptId), null, 2));
1240
1253
  }
1241
1254
  else {
1242
- console.log(JSON.stringify(store.listReceipts(ctx.workspace.id, 20), null, 2));
1255
+ console.log(JSON.stringify({ ok: true, ...engine.listReceipts(ctx, 20) }, null, 2));
1243
1256
  }
1244
1257
  return;
1245
1258
  }
@@ -1833,6 +1846,125 @@ async function runCli() {
1833
1846
  }, null, 2));
1834
1847
  return;
1835
1848
  }
1849
+ if (cmd === "context") {
1850
+ const query = positional.slice(1).join(" ") ||
1851
+ (typeof flags.query === "string" ? flags.query : "") ||
1852
+ undefined;
1853
+ if (remoteUrl) {
1854
+ const suffix = query ? `?query=${encodeURIComponent(query)}` : "";
1855
+ const res = await remoteFetch(`/api/v1/context${suffix}`);
1856
+ console.log(JSON.stringify(res, null, 2));
1857
+ return;
1858
+ }
1859
+ const { engine, ctx } = getLocalContext();
1860
+ const runContext = await engine.getRunContext(ctx, query);
1861
+ console.log(JSON.stringify({ ok: true, ...runContext }, null, 2));
1862
+ return;
1863
+ }
1864
+ if (cmd === "guardrails" || cmd === "guardrail") {
1865
+ const sub = positional[1];
1866
+ if (sub === "set" || sub === "add") {
1867
+ const prompt = positional.slice(2).join(" ").trim() ||
1868
+ String(flags.prompt || flags.rule || "").trim();
1869
+ const rawRulesJson = typeof flags["rules-json"] === "string"
1870
+ ? flags["rules-json"]
1871
+ : typeof flags.rules === "string"
1872
+ ? flags.rules
1873
+ : undefined;
1874
+ const parsedParamRules = rawRulesJson
1875
+ ? JSON.parse(rawRulesJson)
1876
+ : undefined;
1877
+ if (!prompt && (!parsedParamRules || parsedParamRules.length === 0)) {
1878
+ 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")');
1879
+ }
1880
+ if (remoteUrl) {
1881
+ const res = await remoteFetch("/api/v1/guardrails", {
1882
+ method: "POST",
1883
+ body: {
1884
+ prompt,
1885
+ ...(parsedParamRules ? { parameterRules: parsedParamRules } : {}),
1886
+ },
1887
+ });
1888
+ console.log(JSON.stringify(res, null, 2));
1889
+ return;
1890
+ }
1891
+ const { engine, ctx } = getLocalContext();
1892
+ const applied = await engine.applyNaturalLanguageGuardrail(ctx, prompt, {
1893
+ parameterRules: parsedParamRules,
1894
+ source: parsedParamRules ? "mcp_harness" : "deterministic",
1895
+ });
1896
+ console.log(JSON.stringify({
1897
+ ...applied,
1898
+ humanMessage: `Guardrail active: ${applied.guardrail.summary}`,
1899
+ }, null, 2));
1900
+ return;
1901
+ }
1902
+ if (sub === "reset") {
1903
+ if (remoteUrl) {
1904
+ const res = await remoteFetch("/api/v1/guardrails", {
1905
+ method: "POST",
1906
+ body: { reset: true },
1907
+ });
1908
+ console.log(JSON.stringify(res, null, 2));
1909
+ return;
1910
+ }
1911
+ const { store, ctx } = getLocalContext();
1912
+ const updated = store.updateWorkspacePolicy(ctx.workspace.id, DEFAULT_WORKSPACE_POLICY);
1913
+ console.log(JSON.stringify({
1914
+ ok: true,
1915
+ workspace: updated,
1916
+ plainEnglish: describePolicyInPlainEnglish(updated.policy),
1917
+ humanMessage: "Reset workspace guardrails to Safe Default.",
1918
+ }, null, 2));
1919
+ return;
1920
+ }
1921
+ if (remoteUrl) {
1922
+ const res = await remoteFetch("/api/v1/guardrails");
1923
+ console.log(JSON.stringify(res, null, 2));
1924
+ return;
1925
+ }
1926
+ const { engine, ctx } = getLocalContext();
1927
+ const summary = engine.getGuardrailsSummary(ctx);
1928
+ console.log(JSON.stringify({ ok: true, ...summary }, null, 2));
1929
+ return;
1930
+ }
1931
+ if (cmd === "policy") {
1932
+ const nlText = positional.slice(1).join(" ").trim() ||
1933
+ String(flags.rule || flags.prompt || "").trim();
1934
+ if (nlText) {
1935
+ if (remoteUrl) {
1936
+ const res = await remoteFetch("/api/v1/guardrails", {
1937
+ method: "POST",
1938
+ body: { prompt: nlText },
1939
+ });
1940
+ console.log(JSON.stringify(res, null, 2));
1941
+ return;
1942
+ }
1943
+ const { engine, ctx } = getLocalContext();
1944
+ const applied = await engine.applyNaturalLanguageGuardrail(ctx, nlText);
1945
+ console.log(JSON.stringify({
1946
+ ...applied,
1947
+ humanMessage: `Guardrail active: ${applied.guardrail.summary}`,
1948
+ }, null, 2));
1949
+ return;
1950
+ }
1951
+ if (remoteUrl) {
1952
+ const res = await remoteFetch("/api/v1/policy");
1953
+ console.log(JSON.stringify(res, null, 2));
1954
+ return;
1955
+ }
1956
+ const { engine, ctx } = getLocalContext();
1957
+ const summary = engine.getGuardrailsSummary(ctx);
1958
+ console.log(JSON.stringify({
1959
+ ok: true,
1960
+ policy: summary.policy,
1961
+ plainEnglish: summary.plainEnglish,
1962
+ explanation: summary.plainEnglish.explanation,
1963
+ activeDefaults: summary.activeDefaults,
1964
+ activeGuardrails: summary.activeGuardrails,
1965
+ }, null, 2));
1966
+ return;
1967
+ }
1836
1968
  if (cmd === "governance") {
1837
1969
  const sub = positional[1];
1838
1970
  const ringLabel = (policy) => policy?.executionRing !== undefined
@@ -1957,6 +2089,178 @@ async function runCli() {
1957
2089
  }, null, 2));
1958
2090
  return;
1959
2091
  }
2092
+ if (cmd === "workspaces" || cmd === "workspace") {
2093
+ const sub = positional[1] || "list";
2094
+ if (sub === "list" || sub === "ls") {
2095
+ if (remoteUrl) {
2096
+ const res = await remoteFetch("/api/v1/workspaces");
2097
+ console.log(JSON.stringify(res, null, 2));
2098
+ return;
2099
+ }
2100
+ const { store, ctx } = getLocalContext();
2101
+ const workspaces = store.listUserWorkspaces(ctx.user.id, ctx.workspace.id);
2102
+ console.log(JSON.stringify({ ok: true, currentWorkspaceId: ctx.workspace.id, workspaces }, null, 2));
2103
+ return;
2104
+ }
2105
+ if (sub === "create" || sub === "new") {
2106
+ const name = positional.slice(2).join(" ").trim() ||
2107
+ (typeof flags.name === "string" ? flags.name.trim() : "");
2108
+ if (!name) {
2109
+ throw new Error("Usage: muxo workspaces create <name> [--team <teamName>]");
2110
+ }
2111
+ const teamName = typeof flags.team === "string" ? flags.team.trim() : undefined;
2112
+ if (remoteUrl) {
2113
+ const res = await remoteFetch("/api/v1/workspaces", {
2114
+ method: "POST",
2115
+ body: { name, teamName },
2116
+ });
2117
+ console.log(JSON.stringify(res, null, 2));
2118
+ return;
2119
+ }
2120
+ const { store, ctx } = getLocalContext();
2121
+ const created = store.createWorkspaceForUser({
2122
+ userId: ctx.user.id,
2123
+ name,
2124
+ teamName,
2125
+ });
2126
+ console.log(JSON.stringify({
2127
+ ok: true,
2128
+ workspace: created.workspace,
2129
+ apiKey: created.apiKey,
2130
+ workspaces: store.listUserWorkspaces(ctx.user.id, created.workspace.id),
2131
+ }, null, 2));
2132
+ return;
2133
+ }
2134
+ if (sub === "switch" || sub === "use") {
2135
+ const workspaceId = positional[2]?.trim() ||
2136
+ (typeof flags.id === "string" ? flags.id.trim() : "");
2137
+ if (!workspaceId) {
2138
+ throw new Error("Usage: muxo workspaces switch <workspace_id>");
2139
+ }
2140
+ if (remoteUrl) {
2141
+ const res = await remoteFetch("/api/v1/workspaces/switch", {
2142
+ method: "POST",
2143
+ body: { workspaceId },
2144
+ });
2145
+ console.log(JSON.stringify(res, null, 2));
2146
+ return;
2147
+ }
2148
+ const { store, ctx } = getLocalContext();
2149
+ const switched = store.switchUserWorkspace(ctx.user.id, workspaceId);
2150
+ if (!switched) {
2151
+ throw new Error(`Workspace '${workspaceId}' not found or not accessible.`);
2152
+ }
2153
+ console.log(JSON.stringify({
2154
+ ok: true,
2155
+ workspace: switched.workspace,
2156
+ workspaces: store.listUserWorkspaces(ctx.user.id, switched.workspace.id),
2157
+ }, null, 2));
2158
+ return;
2159
+ }
2160
+ if (sub === "join") {
2161
+ const keyToJoin = positional[2]?.trim() ||
2162
+ (typeof flags["api-key"] === "string"
2163
+ ? flags["api-key"].trim()
2164
+ : typeof flags.key === "string"
2165
+ ? flags.key.trim()
2166
+ : "");
2167
+ if (!keyToJoin) {
2168
+ throw new Error("Usage: muxo workspaces join <mk_live_...>");
2169
+ }
2170
+ if (remoteUrl) {
2171
+ const res = await remoteFetch("/api/v1/workspaces/join", {
2172
+ method: "POST",
2173
+ body: { apiKey: keyToJoin },
2174
+ });
2175
+ const ws = res.workspace || {};
2176
+ writeCliAuthConfig({
2177
+ authenticated: true,
2178
+ apiKey: keyToJoin,
2179
+ apiUrl: remoteUrl,
2180
+ workspaceId: String(ws.id || "ws_remote"),
2181
+ workspaceName: String(ws.name || "Muxo Workspace"),
2182
+ agentId: "usr_remote",
2183
+ governanceDid: `did:muxo:${ws.id || "ws_remote"}`,
2184
+ supermemoryNamespace: `muxo_${ws.id || "ws_remote"}`,
2185
+ updatedAt: new Date().toISOString(),
2186
+ });
2187
+ console.log(JSON.stringify(res, null, 2));
2188
+ return;
2189
+ }
2190
+ const { store, ctx, engine } = getLocalContext();
2191
+ const joined = store.joinWorkspaceWithApiKey({
2192
+ apiKey: keyToJoin,
2193
+ userId: ctx.user.id,
2194
+ });
2195
+ if (!joined) {
2196
+ throw new Error("Invalid or revoked Muxo API key.");
2197
+ }
2198
+ writeCliAuthConfig({
2199
+ authenticated: true,
2200
+ apiKey: keyToJoin,
2201
+ workspaceId: joined.workspace.id,
2202
+ workspaceName: joined.workspace.name,
2203
+ agentId: ctx.user.id,
2204
+ governanceDid: engine.governance.getStatus(joined.workspace).agentDid,
2205
+ supermemoryNamespace: engine.supermemory.getWorkspaceNamespace(joined.workspace.id),
2206
+ updatedAt: new Date().toISOString(),
2207
+ });
2208
+ console.log(JSON.stringify({
2209
+ ok: true,
2210
+ mode: "api_key_join",
2211
+ workspace: joined.workspace,
2212
+ keyRecord: joined.keyRecord,
2213
+ membership: joined.membership,
2214
+ }, null, 2));
2215
+ return;
2216
+ }
2217
+ }
2218
+ if (cmd === "team" || cmd === "teams") {
2219
+ const sub = positional[1] || "onboard";
2220
+ const teamName = (sub === "onboard" || sub === "invite" || sub === "add"
2221
+ ? positional.slice(2).join(" ")
2222
+ : positional.slice(1).join(" ")).trim() ||
2223
+ (typeof flags.name === "string" ? flags.name.trim() : "") ||
2224
+ (typeof flags.team === "string" ? flags.team.trim() : "");
2225
+ if (!teamName) {
2226
+ throw new Error('Usage: muxo team onboard "<team_name>" [--mode shared|dedicated] [--role operator|admin|member]');
2227
+ }
2228
+ const rawMode = typeof flags.mode === "string" ? flags.mode.trim() : "";
2229
+ const mode = rawMode === "dedicated" || rawMode === "dedicated_workspace"
2230
+ ? "dedicated_workspace"
2231
+ : "shared_workspace";
2232
+ const role = typeof flags.role === "string" &&
2233
+ ["owner", "admin", "operator", "member"].includes(flags.role)
2234
+ ? flags.role
2235
+ : "operator";
2236
+ const environment = flags.test ? "test" : "live";
2237
+ if (remoteUrl) {
2238
+ const res = await remoteFetch("/api/v1/workspaces/onboard-team", {
2239
+ method: "POST",
2240
+ body: { teamName, mode, role, environment },
2241
+ });
2242
+ console.log(JSON.stringify(res, null, 2));
2243
+ return;
2244
+ }
2245
+ const { store, ctx } = getLocalContext();
2246
+ const kit = store.onboardTeam({
2247
+ userId: ctx.user.id,
2248
+ userEmail: ctx.user.email,
2249
+ currentWorkspaceId: ctx.workspace.id,
2250
+ teamName,
2251
+ role,
2252
+ mode,
2253
+ environment,
2254
+ baseUrl: config.baseUrl,
2255
+ });
2256
+ console.log(JSON.stringify({
2257
+ ok: true,
2258
+ kit,
2259
+ workspace: kit.workspace,
2260
+ apiKey: kit.apiKey,
2261
+ }, null, 2));
2262
+ return;
2263
+ }
1960
2264
  if (cmd === "serve") {
1961
2265
  const { createMuxoServer } = await import("./server.js");
1962
2266
  const port = flags.port ? Number(flags.port) : config.port;
@@ -2021,12 +2325,17 @@ async function runCli() {
2021
2325
  Muxo CLI — Unified Agent Execution, Cloud Infrastructure, Memory & Safety Platform
2022
2326
 
2023
2327
  Natural Language & Interactive TUI:
2024
- muxo setup 1-command auto-signup + MCP setup (.mcp.json + ~/.muxo/config.json)
2328
+ muxo setup [--api-key <key>] 1-command auto-signup (or join via team API key) + MCP setup
2025
2329
  muxo do "<instruction>" Execute any goal in plain English (LLM/semantic router -> plan -> execute)
2026
2330
  muxo ask "<instruction>" [--plan-only] Alias for 'muxo do' (pass --plan-only to inspect plan before running)
2027
2331
  muxo tui Launch interactive Terminal UI dashboard (BYOK, Billing, OAuth, Infra)
2028
2332
  muxo byok [list|set|delete] [<provider>] Manage BYOK API keys in AES-256-GCM Vault (0 credit cost when active)
2029
2333
 
2334
+ Workspaces & Team Onboarding:
2335
+ muxo workspaces [list|create|switch|join] List, create, switch, or join workspaces via API key
2336
+ muxo team onboard "<team>" [--mode shared|dedicated] [--role operator|admin|member]
2337
+ Mint a scoped team API key & onboarding kit for another team
2338
+
2030
2339
  Core Commands:
2031
2340
  muxo login [--api-key <key> | --signup] Sign in or create an autonomous workspace (~/.muxo/config.json)
2032
2341
  muxo logout Remove saved CLI authentication config
@@ -2042,6 +2351,7 @@ Core Commands:
2042
2351
  muxo approve <plan_id> Approve a pending high-risk plan
2043
2352
  muxo run <plan_id> Execute an approved plan and issue a verifiable audit record
2044
2353
  muxo exec <tool_slug> --input '{...}' Plan and execute in one step (pass --approve for high-risk)
2354
+ muxo provision <provider> [--name <name>] Provision cloud infrastructure (e.g., turso, neon, supabase, upstash)
2045
2355
  muxo resources List provisioned Muxo Cloud Infrastructure resources
2046
2356
  muxo env pull [--out .env.muxo] Decrypt and write provisioned credentials to local .env
2047
2357
  muxo receipts [<receipt_id>] List or verify execution audit records
@@ -2057,7 +2367,7 @@ Core Commands:
2057
2367
  [--block-destructive-sql true|false] [--max-credits <n>]
2058
2368
  muxo harness Check API, MCP, auth, governance and catalog; print MCP config
2059
2369
  muxo serve [--port 4310] Start unified HTTP Console, Landing, OAuth Callback & MCP server
2060
- muxo mcp Run stdio MCP server (20 canonical tools)
2370
+ muxo mcp Run stdio MCP server (19 canonical tools)
2061
2371
  `);
2062
2372
  }
2063
2373
  runCli()