@muxoai/platform 1.3.1 → 1.3.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/README.md +10 -2
- package/dist/clerk.d.ts +33 -0
- package/dist/clerk.js +198 -0
- package/dist/cli.js +422 -26
- package/dist/engine.d.ts +21 -1
- package/dist/engine.js +245 -23
- package/dist/mcp.js +2 -1
- package/dist/policy.d.ts +9 -0
- package/dist/policy.js +73 -0
- package/dist/providers/composio-instant.d.ts +3 -0
- package/dist/providers/composio-instant.js +629 -530
- package/dist/providers/microsoft-governance.d.ts +61 -2
- package/dist/providers/microsoft-governance.js +458 -24
- package/dist/providers/stripe-projects.d.ts +4 -1
- package/dist/providers/stripe-projects.js +64 -10
- package/dist/providers/supermemory.d.ts +26 -5
- package/dist/providers/supermemory.js +136 -26
- package/dist/sdk.d.ts +167 -1
- package/dist/sdk.js +113 -2
- package/dist/server.js +176 -16
- package/dist/store.d.ts +25 -1
- package/dist/store.js +236 -3
- package/dist/types.d.ts +86 -0
- package/dist/ui/console-html.d.ts +16 -0
- package/dist/ui/console-html.js +2427 -2226
- package/dist/ui/design-tokens.d.ts +177 -0
- package/dist/ui/design-tokens.js +210 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Muxo (`@muxoai/platform` / `@muxoai/cli` / `@muxoai/sdk`)
|
|
2
2
|
|
|
3
|
-
Muxo (`v1.3.
|
|
3
|
+
Muxo (`v1.3.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
|
|
|
@@ -46,8 +46,16 @@ muxo billing upgrade
|
|
|
46
46
|
muxo link gmail --wait
|
|
47
47
|
muxo provision turso --input '{"database_name":"my-agent-db"}' --approve
|
|
48
48
|
muxo env pull --out .env.muxo
|
|
49
|
-
```
|
|
50
49
|
|
|
50
|
+
# 8. Check your setup, memory, and safety controls
|
|
51
|
+
muxo harness # API, MCP, auth, kill switch, audit chain, catalog (exit 1 on failure)
|
|
52
|
+
muxo memory facts # Facts with history; add --current for current facts only
|
|
53
|
+
muxo memory forget "old staging database" # Delete matching memories and retire their facts
|
|
54
|
+
muxo governance scan "text to check" # Prompt-injection check before storing or forwarding text
|
|
55
|
+
muxo governance pause "incident review" # Kill switch: stop all agent actions in the workspace
|
|
56
|
+
muxo governance resume
|
|
57
|
+
muxo governance policy --ring 2 --block-destructive-sql true --require-approval financial,destructive
|
|
58
|
+
```
|
|
51
59
|
## Official Plugins, Marketplaces & MCP Setup (`https://api.muxo.ai/mcp`)
|
|
52
60
|
|
|
53
61
|
Muxo ships a portable OpenAI Plugin (`plugins/muxo/plugin.json` & `plugins/muxo/mcp.json`), Claude Code Plugin (`plugins/muxo/.claude-plugin/plugin.json`), and Streamable HTTP MCP Server:
|
package/dist/clerk.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface ClerkConfig {
|
|
2
|
+
publishableKey: string;
|
|
3
|
+
frontendApi: string;
|
|
4
|
+
authorizedParties: string[];
|
|
5
|
+
jwtKey?: string;
|
|
6
|
+
secretKey?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ClerkSession {
|
|
9
|
+
userId: string;
|
|
10
|
+
sessionId: string;
|
|
11
|
+
email?: string;
|
|
12
|
+
emailVerified?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface ClerkProfile {
|
|
15
|
+
email: string | null;
|
|
16
|
+
emailVerified: boolean;
|
|
17
|
+
name: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface ClerkEnv {
|
|
20
|
+
CLERK_PUBLISHABLE_KEY?: string;
|
|
21
|
+
CLERK_SECRET_KEY?: string;
|
|
22
|
+
CLERK_JWT_KEY?: string;
|
|
23
|
+
CLERK_AUTHORIZED_PARTIES?: string;
|
|
24
|
+
}
|
|
25
|
+
/** Derives the Clerk Frontend API origin encoded in a publishable key (pk_live_/pk_test_). */
|
|
26
|
+
export declare function clerkFrontendApi(publishableKey: string): string | null;
|
|
27
|
+
export declare function readClerkConfig(env: ClerkEnv, fallbackAuthorizedParty?: string): ClerkConfig | null;
|
|
28
|
+
export declare function looksLikeJwt(token: string): boolean;
|
|
29
|
+
/** Verifies a Clerk session JWT (RS256) and returns the session identity, or null if invalid. */
|
|
30
|
+
export declare function verifyClerkSessionToken(token: string, config: ClerkConfig, nowSeconds?: number): Promise<ClerkSession | null>;
|
|
31
|
+
/** Reads the primary email and name for a Clerk user through the Backend API. */
|
|
32
|
+
export declare function fetchClerkProfile(userId: string, secretKey: string): Promise<ClerkProfile | null>;
|
|
33
|
+
export declare function clerkBrowserScriptUrl(frontendApi: string): string;
|
package/dist/clerk.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
const RS256 = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" };
|
|
2
|
+
const JWKS_TTL_MS = 10 * 60 * 1000;
|
|
3
|
+
const JWKS_RETRY_MS = 30 * 1000;
|
|
4
|
+
const CLOCK_SKEW_SECONDS = 5;
|
|
5
|
+
function base64UrlToBytes(input) {
|
|
6
|
+
const normalized = input.replace(/-/g, "+").replace(/_/g, "/");
|
|
7
|
+
const padded = normalized + "=".repeat((4 - (normalized.length % 4)) % 4);
|
|
8
|
+
const binary = atob(padded);
|
|
9
|
+
const bytes = new Uint8Array(new ArrayBuffer(binary.length));
|
|
10
|
+
for (let i = 0; i < binary.length; i++)
|
|
11
|
+
bytes[i] = binary.charCodeAt(i);
|
|
12
|
+
return bytes;
|
|
13
|
+
}
|
|
14
|
+
function decodeJsonSegment(segment) {
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(new TextDecoder().decode(base64UrlToBytes(segment)));
|
|
17
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Derives the Clerk Frontend API origin encoded in a publishable key (pk_live_/pk_test_). */
|
|
24
|
+
export function clerkFrontendApi(publishableKey) {
|
|
25
|
+
const match = /^pk_(?:live|test)_([A-Za-z0-9+/=_-]{4,512})$/.exec(publishableKey.trim());
|
|
26
|
+
if (!match)
|
|
27
|
+
return null;
|
|
28
|
+
let decoded;
|
|
29
|
+
try {
|
|
30
|
+
decoded = new TextDecoder().decode(base64UrlToBytes(match[1]));
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (!decoded.endsWith("$"))
|
|
36
|
+
return null;
|
|
37
|
+
const host = decoded.slice(0, -1);
|
|
38
|
+
if (!/^(?=.{4,253}$)([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i.test(host))
|
|
39
|
+
return null;
|
|
40
|
+
return `https://${host.toLowerCase()}`;
|
|
41
|
+
}
|
|
42
|
+
export function readClerkConfig(env, fallbackAuthorizedParty) {
|
|
43
|
+
const publishableKey = (env.CLERK_PUBLISHABLE_KEY || "").trim();
|
|
44
|
+
if (!publishableKey)
|
|
45
|
+
return null;
|
|
46
|
+
const frontendApi = clerkFrontendApi(publishableKey);
|
|
47
|
+
if (!frontendApi)
|
|
48
|
+
return null;
|
|
49
|
+
const configured = (env.CLERK_AUTHORIZED_PARTIES || "")
|
|
50
|
+
.split(",")
|
|
51
|
+
.map((s) => s.trim().replace(/\/+$/, ""))
|
|
52
|
+
.filter(Boolean);
|
|
53
|
+
const authorizedParties = configured.length
|
|
54
|
+
? configured
|
|
55
|
+
: fallbackAuthorizedParty
|
|
56
|
+
? [fallbackAuthorizedParty.replace(/\/+$/, "")]
|
|
57
|
+
: [];
|
|
58
|
+
return {
|
|
59
|
+
publishableKey,
|
|
60
|
+
frontendApi,
|
|
61
|
+
authorizedParties,
|
|
62
|
+
jwtKey: (env.CLERK_JWT_KEY || "").trim() || undefined,
|
|
63
|
+
secretKey: (env.CLERK_SECRET_KEY || "").trim() || undefined,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function looksLikeJwt(token) {
|
|
67
|
+
return /^eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(token);
|
|
68
|
+
}
|
|
69
|
+
async function importPemKey(pem) {
|
|
70
|
+
const body = pem
|
|
71
|
+
.replace(/\\n/g, "\n")
|
|
72
|
+
.replace(/-----BEGIN PUBLIC KEY-----/, "")
|
|
73
|
+
.replace(/-----END PUBLIC KEY-----/, "")
|
|
74
|
+
.replace(/\s+/g, "");
|
|
75
|
+
return crypto.subtle.importKey("spki", base64UrlToBytes(body), RS256, false, ["verify"]);
|
|
76
|
+
}
|
|
77
|
+
// Only public verification keys are cached; never tokens or user data.
|
|
78
|
+
const jwksCache = new Map();
|
|
79
|
+
const pemCache = new Map();
|
|
80
|
+
async function loadJwks(frontendApi) {
|
|
81
|
+
const res = await fetch(`${frontendApi}/.well-known/jwks.json`, {
|
|
82
|
+
headers: { Accept: "application/json" },
|
|
83
|
+
redirect: "manual",
|
|
84
|
+
});
|
|
85
|
+
if (res.status !== 200)
|
|
86
|
+
throw new Error(`Clerk JWKS unavailable (HTTP ${res.status})`);
|
|
87
|
+
const doc = (await res.json());
|
|
88
|
+
const keys = new Map();
|
|
89
|
+
for (const jwk of doc.keys || []) {
|
|
90
|
+
if (jwk.kty !== "RSA" || typeof jwk.kid !== "string")
|
|
91
|
+
continue;
|
|
92
|
+
if (jwk.use && jwk.use !== "sig")
|
|
93
|
+
continue;
|
|
94
|
+
const key = await crypto.subtle.importKey("jwk", { kty: "RSA", n: String(jwk.n), e: String(jwk.e), alg: "RS256", ext: true }, RS256, false, ["verify"]);
|
|
95
|
+
keys.set(jwk.kid, key);
|
|
96
|
+
}
|
|
97
|
+
return keys;
|
|
98
|
+
}
|
|
99
|
+
async function verificationKey(config, kid) {
|
|
100
|
+
if (config.jwtKey) {
|
|
101
|
+
let key = pemCache.get(config.jwtKey);
|
|
102
|
+
if (!key) {
|
|
103
|
+
key = await importPemKey(config.jwtKey);
|
|
104
|
+
pemCache.set(config.jwtKey, key);
|
|
105
|
+
}
|
|
106
|
+
return key;
|
|
107
|
+
}
|
|
108
|
+
if (!kid)
|
|
109
|
+
return null;
|
|
110
|
+
const now = Date.now();
|
|
111
|
+
const cached = jwksCache.get(config.frontendApi);
|
|
112
|
+
const fresh = cached && now - cached.fetchedAt < JWKS_TTL_MS;
|
|
113
|
+
if (cached?.keys.has(kid) && fresh)
|
|
114
|
+
return cached.keys.get(kid);
|
|
115
|
+
// Refetch for unknown kids (key rotation), but not more than once per retry window.
|
|
116
|
+
if (!cached || !fresh || now - cached.fetchedAt > JWKS_RETRY_MS) {
|
|
117
|
+
const keys = await loadJwks(config.frontendApi);
|
|
118
|
+
jwksCache.set(config.frontendApi, { keys, fetchedAt: now });
|
|
119
|
+
return keys.get(kid) || null;
|
|
120
|
+
}
|
|
121
|
+
return cached.keys.get(kid) || null;
|
|
122
|
+
}
|
|
123
|
+
/** Verifies a Clerk session JWT (RS256) and returns the session identity, or null if invalid. */
|
|
124
|
+
export async function verifyClerkSessionToken(token, config, nowSeconds = Math.floor(Date.now() / 1000)) {
|
|
125
|
+
if (!looksLikeJwt(token) || token.length > 16_384)
|
|
126
|
+
return null;
|
|
127
|
+
const [headerPart, payloadPart, signaturePart] = token.split(".");
|
|
128
|
+
const header = decodeJsonSegment(headerPart);
|
|
129
|
+
const payload = decodeJsonSegment(payloadPart);
|
|
130
|
+
if (!header || !payload || header.alg !== "RS256")
|
|
131
|
+
return null;
|
|
132
|
+
let key;
|
|
133
|
+
try {
|
|
134
|
+
key = await verificationKey(config, typeof header.kid === "string" ? header.kid : undefined);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
if (!key)
|
|
140
|
+
return null;
|
|
141
|
+
let valid = false;
|
|
142
|
+
try {
|
|
143
|
+
valid = await crypto.subtle.verify(RS256, key, base64UrlToBytes(signaturePart), new TextEncoder().encode(`${headerPart}.${payloadPart}`));
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
if (!valid)
|
|
149
|
+
return null;
|
|
150
|
+
if (payload.iss !== config.frontendApi)
|
|
151
|
+
return null;
|
|
152
|
+
if (typeof payload.exp !== "number" || payload.exp + CLOCK_SKEW_SECONDS < nowSeconds)
|
|
153
|
+
return null;
|
|
154
|
+
if (typeof payload.nbf === "number" && payload.nbf - CLOCK_SKEW_SECONDS > nowSeconds)
|
|
155
|
+
return null;
|
|
156
|
+
if (typeof payload.iat === "number" && payload.iat - CLOCK_SKEW_SECONDS > nowSeconds)
|
|
157
|
+
return null;
|
|
158
|
+
if (typeof payload.azp === "string" &&
|
|
159
|
+
config.authorizedParties.length > 0 &&
|
|
160
|
+
!config.authorizedParties.includes(payload.azp.replace(/\/+$/, ""))) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
if (payload.sts !== undefined && payload.sts !== "active")
|
|
164
|
+
return null;
|
|
165
|
+
if (typeof payload.sub !== "string" || !/^user_[A-Za-z0-9]{1,128}$/.test(payload.sub))
|
|
166
|
+
return null;
|
|
167
|
+
return {
|
|
168
|
+
userId: payload.sub,
|
|
169
|
+
sessionId: typeof payload.sid === "string" ? payload.sid : "",
|
|
170
|
+
email: typeof payload.email === "string" ? payload.email.toLowerCase() : undefined,
|
|
171
|
+
emailVerified: payload.email_verified === true,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/** Reads the primary email and name for a Clerk user through the Backend API. */
|
|
175
|
+
export async function fetchClerkProfile(userId, secretKey) {
|
|
176
|
+
try {
|
|
177
|
+
const res = await fetch(`https://api.clerk.com/v1/users/${encodeURIComponent(userId)}`, {
|
|
178
|
+
headers: { Authorization: `Bearer ${secretKey}`, Accept: "application/json" },
|
|
179
|
+
});
|
|
180
|
+
if (!res.ok)
|
|
181
|
+
return null;
|
|
182
|
+
const user = (await res.json());
|
|
183
|
+
const addresses = user.email_addresses || [];
|
|
184
|
+
const primary = addresses.find((e) => e.id === user.primary_email_address_id) || addresses[0];
|
|
185
|
+
const name = [user.first_name, user.last_name].filter(Boolean).join(" ").trim() || user.username || null;
|
|
186
|
+
return {
|
|
187
|
+
email: primary?.email_address ? primary.email_address.toLowerCase() : null,
|
|
188
|
+
emailVerified: primary?.verification?.status === "verified",
|
|
189
|
+
name,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
export function clerkBrowserScriptUrl(frontendApi) {
|
|
197
|
+
return `${frontendApi}/npm/@clerk/clerk-js@5/dist/clerk.browser.js`;
|
|
198
|
+
}
|