@muxoai/sdk 1.2.3 → 1.3.0

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 (183) hide show
  1. package/.agents/plugins/marketplace.json +22 -0
  2. package/.claude-plugin/marketplace.json +17 -0
  3. package/.codex/config.toml +5 -0
  4. package/ARCHITECTURE.md +111 -0
  5. package/README.md +21 -12
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +894 -0
  8. package/dist/config.d.ts +20 -0
  9. package/dist/config.js +89 -0
  10. package/dist/engine.d.ts +156 -0
  11. package/dist/engine.js +876 -0
  12. package/dist/index.d.ts +7 -0
  13. package/dist/index.js +7 -0
  14. package/dist/mcp.d.ts +45 -0
  15. package/dist/mcp.js +914 -0
  16. package/dist/nl.d.ts +34 -0
  17. package/dist/nl.js +577 -0
  18. package/dist/providers/composio-instant.d.ts +14 -0
  19. package/dist/providers/composio-instant.js +814 -0
  20. package/dist/providers/composio-sdk.d.ts +41 -0
  21. package/dist/providers/composio-sdk.js +572 -0
  22. package/dist/providers/microsoft-governance.d.ts +66 -0
  23. package/dist/providers/microsoft-governance.js +415 -0
  24. package/dist/providers/stripe-billing.d.ts +41 -0
  25. package/dist/providers/stripe-billing.js +372 -0
  26. package/dist/providers/stripe-projects.d.ts +53 -0
  27. package/dist/providers/stripe-projects.js +636 -0
  28. package/dist/providers/supermemory.d.ts +64 -0
  29. package/dist/providers/supermemory.js +224 -0
  30. package/{index.d.ts → dist/sdk.d.ts} +77 -1
  31. package/dist/sdk.js +270 -0
  32. package/dist/server.d.ts +10 -0
  33. package/dist/server.js +1277 -0
  34. package/dist/store.d.ts +216 -0
  35. package/dist/store.js +1449 -0
  36. package/dist/types.d.ts +285 -0
  37. package/dist/types.js +1 -0
  38. package/dist/ui/console-html.d.ts +2 -0
  39. package/dist/ui/console-html.js +2343 -0
  40. package/package.json +66 -6
  41. package/plugins/muxo/.app.json +8 -0
  42. package/plugins/muxo/.claude-plugin/plugin.json +16 -0
  43. package/plugins/muxo/.codex-plugin/plugin.json +55 -0
  44. package/plugins/muxo/.mcp.json +40 -0
  45. package/plugins/muxo/assets/logo.png +0 -0
  46. package/plugins/muxo/assets/logo.svg +6 -0
  47. package/plugins/muxo/hooks/hooks.json +27 -0
  48. package/plugins/muxo/hooks/session-start.sh +85 -0
  49. package/plugins/muxo/hooks/user-prompt-submit.sh +45 -0
  50. package/plugins/muxo/mcp.json +38 -0
  51. package/plugins/muxo/plugin.json +59 -0
  52. package/plugins/muxo/skills/muxo/SKILL.md +25 -0
  53. package/plugins/muxo/skills/muxo/references/cli.md +57 -0
  54. package/plugins/muxo/skills/muxo/references/mcp.md +25 -0
  55. package/plugins/muxo/skills/setup/SKILL.md +28 -0
  56. package/src/catalogues/stripe-projects-catalog.json +9832 -0
  57. package/vendor/microsoft-governance/README.md +363 -0
  58. package/vendor/microsoft-governance/dist/audit.d.ts +26 -0
  59. package/vendor/microsoft-governance/dist/audit.d.ts.map +1 -0
  60. package/vendor/microsoft-governance/dist/audit.js +107 -0
  61. package/vendor/microsoft-governance/dist/audit.js.map +1 -0
  62. package/vendor/microsoft-governance/dist/cascade-containment.d.ts +84 -0
  63. package/vendor/microsoft-governance/dist/cascade-containment.d.ts.map +1 -0
  64. package/vendor/microsoft-governance/dist/cascade-containment.js +387 -0
  65. package/vendor/microsoft-governance/dist/cascade-containment.js.map +1 -0
  66. package/vendor/microsoft-governance/dist/client.d.ts +34 -0
  67. package/vendor/microsoft-governance/dist/client.d.ts.map +1 -0
  68. package/vendor/microsoft-governance/dist/client.js +112 -0
  69. package/vendor/microsoft-governance/dist/client.js.map +1 -0
  70. package/vendor/microsoft-governance/dist/context-poisoning.d.ts +58 -0
  71. package/vendor/microsoft-governance/dist/context-poisoning.d.ts.map +1 -0
  72. package/vendor/microsoft-governance/dist/context-poisoning.js +410 -0
  73. package/vendor/microsoft-governance/dist/context-poisoning.js.map +1 -0
  74. package/vendor/microsoft-governance/dist/credential-vault.d.ts +213 -0
  75. package/vendor/microsoft-governance/dist/credential-vault.d.ts.map +1 -0
  76. package/vendor/microsoft-governance/dist/credential-vault.js +567 -0
  77. package/vendor/microsoft-governance/dist/credential-vault.js.map +1 -0
  78. package/vendor/microsoft-governance/dist/discovery.d.ts +80 -0
  79. package/vendor/microsoft-governance/dist/discovery.d.ts.map +1 -0
  80. package/vendor/microsoft-governance/dist/discovery.js +404 -0
  81. package/vendor/microsoft-governance/dist/discovery.js.map +1 -0
  82. package/vendor/microsoft-governance/dist/encryption/channel.d.ts +29 -0
  83. package/vendor/microsoft-governance/dist/encryption/channel.d.ts.map +1 -0
  84. package/vendor/microsoft-governance/dist/encryption/channel.js +78 -0
  85. package/vendor/microsoft-governance/dist/encryption/channel.js.map +1 -0
  86. package/vendor/microsoft-governance/dist/encryption/index.d.ts +9 -0
  87. package/vendor/microsoft-governance/dist/encryption/index.d.ts.map +1 -0
  88. package/vendor/microsoft-governance/dist/encryption/index.js +23 -0
  89. package/vendor/microsoft-governance/dist/encryption/index.js.map +1 -0
  90. package/vendor/microsoft-governance/dist/encryption/mesh-client.d.ts +267 -0
  91. package/vendor/microsoft-governance/dist/encryption/mesh-client.d.ts.map +1 -0
  92. package/vendor/microsoft-governance/dist/encryption/mesh-client.js +1001 -0
  93. package/vendor/microsoft-governance/dist/encryption/mesh-client.js.map +1 -0
  94. package/vendor/microsoft-governance/dist/encryption/ratchet.d.ts +38 -0
  95. package/vendor/microsoft-governance/dist/encryption/ratchet.d.ts.map +1 -0
  96. package/vendor/microsoft-governance/dist/encryption/ratchet.js +223 -0
  97. package/vendor/microsoft-governance/dist/encryption/ratchet.js.map +1 -0
  98. package/vendor/microsoft-governance/dist/encryption/registry-client.d.ts +136 -0
  99. package/vendor/microsoft-governance/dist/encryption/registry-client.d.ts.map +1 -0
  100. package/vendor/microsoft-governance/dist/encryption/registry-client.js +369 -0
  101. package/vendor/microsoft-governance/dist/encryption/registry-client.js.map +1 -0
  102. package/vendor/microsoft-governance/dist/encryption/x3dh.d.ts +80 -0
  103. package/vendor/microsoft-governance/dist/encryption/x3dh.d.ts.map +1 -0
  104. package/vendor/microsoft-governance/dist/encryption/x3dh.js +238 -0
  105. package/vendor/microsoft-governance/dist/encryption/x3dh.js.map +1 -0
  106. package/vendor/microsoft-governance/dist/framework-adapter.d.ts +63 -0
  107. package/vendor/microsoft-governance/dist/framework-adapter.d.ts.map +1 -0
  108. package/vendor/microsoft-governance/dist/framework-adapter.js +253 -0
  109. package/vendor/microsoft-governance/dist/framework-adapter.js.map +1 -0
  110. package/vendor/microsoft-governance/dist/identity.d.ts +124 -0
  111. package/vendor/microsoft-governance/dist/identity.d.ts.map +1 -0
  112. package/vendor/microsoft-governance/dist/identity.js +446 -0
  113. package/vendor/microsoft-governance/dist/identity.js.map +1 -0
  114. package/vendor/microsoft-governance/dist/index.d.ts +39 -0
  115. package/vendor/microsoft-governance/dist/index.d.ts.map +1 -0
  116. package/vendor/microsoft-governance/dist/index.js +95 -0
  117. package/vendor/microsoft-governance/dist/index.js.map +1 -0
  118. package/vendor/microsoft-governance/dist/kill-switch.d.ts +22 -0
  119. package/vendor/microsoft-governance/dist/kill-switch.d.ts.map +1 -0
  120. package/vendor/microsoft-governance/dist/kill-switch.js +60 -0
  121. package/vendor/microsoft-governance/dist/kill-switch.js.map +1 -0
  122. package/vendor/microsoft-governance/dist/lifecycle.d.ts +50 -0
  123. package/vendor/microsoft-governance/dist/lifecycle.d.ts.map +1 -0
  124. package/vendor/microsoft-governance/dist/lifecycle.js +113 -0
  125. package/vendor/microsoft-governance/dist/lifecycle.js.map +1 -0
  126. package/vendor/microsoft-governance/dist/mcp.d.ts +41 -0
  127. package/vendor/microsoft-governance/dist/mcp.d.ts.map +1 -0
  128. package/vendor/microsoft-governance/dist/mcp.js +233 -0
  129. package/vendor/microsoft-governance/dist/mcp.js.map +1 -0
  130. package/vendor/microsoft-governance/dist/metrics.d.ts +123 -0
  131. package/vendor/microsoft-governance/dist/metrics.d.ts.map +1 -0
  132. package/vendor/microsoft-governance/dist/metrics.js +289 -0
  133. package/vendor/microsoft-governance/dist/metrics.js.map +1 -0
  134. package/vendor/microsoft-governance/dist/oci-manifest.d.ts +49 -0
  135. package/vendor/microsoft-governance/dist/oci-manifest.d.ts.map +1 -0
  136. package/vendor/microsoft-governance/dist/oci-manifest.js +182 -0
  137. package/vendor/microsoft-governance/dist/oci-manifest.js.map +1 -0
  138. package/vendor/microsoft-governance/dist/policy-backends/cedar.d.ts +15 -0
  139. package/vendor/microsoft-governance/dist/policy-backends/cedar.d.ts.map +1 -0
  140. package/vendor/microsoft-governance/dist/policy-backends/cedar.js +88 -0
  141. package/vendor/microsoft-governance/dist/policy-backends/cedar.js.map +1 -0
  142. package/vendor/microsoft-governance/dist/policy-backends/opa.d.ts +17 -0
  143. package/vendor/microsoft-governance/dist/policy-backends/opa.d.ts.map +1 -0
  144. package/vendor/microsoft-governance/dist/policy-backends/opa.js +74 -0
  145. package/vendor/microsoft-governance/dist/policy-backends/opa.js.map +1 -0
  146. package/vendor/microsoft-governance/dist/policy.d.ts +77 -0
  147. package/vendor/microsoft-governance/dist/policy.d.ts.map +1 -0
  148. package/vendor/microsoft-governance/dist/policy.js +760 -0
  149. package/vendor/microsoft-governance/dist/policy.js.map +1 -0
  150. package/vendor/microsoft-governance/dist/prompt-defense.d.ts +37 -0
  151. package/vendor/microsoft-governance/dist/prompt-defense.d.ts.map +1 -0
  152. package/vendor/microsoft-governance/dist/prompt-defense.js +229 -0
  153. package/vendor/microsoft-governance/dist/prompt-defense.js.map +1 -0
  154. package/vendor/microsoft-governance/dist/protocol-facets.d.ts +87 -0
  155. package/vendor/microsoft-governance/dist/protocol-facets.d.ts.map +1 -0
  156. package/vendor/microsoft-governance/dist/protocol-facets.js +728 -0
  157. package/vendor/microsoft-governance/dist/protocol-facets.js.map +1 -0
  158. package/vendor/microsoft-governance/dist/rings.d.ts +17 -0
  159. package/vendor/microsoft-governance/dist/rings.d.ts.map +1 -0
  160. package/vendor/microsoft-governance/dist/rings.js +61 -0
  161. package/vendor/microsoft-governance/dist/rings.js.map +1 -0
  162. package/vendor/microsoft-governance/dist/sandbox.d.ts +61 -0
  163. package/vendor/microsoft-governance/dist/sandbox.d.ts.map +1 -0
  164. package/vendor/microsoft-governance/dist/sandbox.js +199 -0
  165. package/vendor/microsoft-governance/dist/sandbox.js.map +1 -0
  166. package/vendor/microsoft-governance/dist/surface-parity.d.ts +45 -0
  167. package/vendor/microsoft-governance/dist/surface-parity.d.ts.map +1 -0
  168. package/vendor/microsoft-governance/dist/surface-parity.js +216 -0
  169. package/vendor/microsoft-governance/dist/surface-parity.js.map +1 -0
  170. package/vendor/microsoft-governance/dist/trust.d.ts +28 -0
  171. package/vendor/microsoft-governance/dist/trust.d.ts.map +1 -0
  172. package/vendor/microsoft-governance/dist/trust.js +209 -0
  173. package/vendor/microsoft-governance/dist/trust.js.map +1 -0
  174. package/vendor/microsoft-governance/dist/types.d.ts +422 -0
  175. package/vendor/microsoft-governance/dist/types.d.ts.map +1 -0
  176. package/vendor/microsoft-governance/dist/types.js +29 -0
  177. package/vendor/microsoft-governance/dist/types.js.map +1 -0
  178. package/vendor/microsoft-governance/dist/verify.d.ts +135 -0
  179. package/vendor/microsoft-governance/dist/verify.d.ts.map +1 -0
  180. package/vendor/microsoft-governance/dist/verify.js +356 -0
  181. package/vendor/microsoft-governance/dist/verify.js.map +1 -0
  182. package/vendor/microsoft-governance/package.json +64 -0
  183. package/index.js +0 -1
@@ -0,0 +1,64 @@
1
+ import type { MuxoConfig } from "../config.js";
2
+ import type { MemoryContextSummary, MemoryRecordKind } from "../types.js";
3
+ /**
4
+ * Supermemory v5 Contextual Brain & Context-Aware Tool Call Adapter.
5
+ * Uses deterministic per-workspace namespaces (`/ns/muxo-v5-<hash>/...`)
6
+ * and strict secret redaction so credentials never enter external memory.
7
+ */
8
+ export declare class SupermemoryAdapter {
9
+ private readonly config;
10
+ private readonly client;
11
+ constructor(config: MuxoConfig);
12
+ isEnabled(): boolean;
13
+ /**
14
+ * Derives a strict Supermemory v5 namespace (`^[a-zA-Z0-9_:-]+$`) scoped to a workspace.
15
+ */
16
+ namespaceForWorkspace(workspaceId: string): string;
17
+ getWorkspaceNamespace(workspaceId: string): string;
18
+ /**
19
+ * Strips any API keys, bearer tokens, connection strings, or .env secret assignments
20
+ * before content is stored in Supermemory (AGENTS.md Invariant #11 & #12).
21
+ */
22
+ sanitizeContent(raw: string): string;
23
+ /**
24
+ * Fetches the workspace's static + dynamic profile and optionally semantic search results
25
+ * in a single fail-open call.
26
+ */
27
+ getContextForWorkspace(workspaceIdOrParams: string | {
28
+ workspaceId: string;
29
+ query?: string;
30
+ limit?: number;
31
+ }, optionalQuery?: string): Promise<MemoryContextSummary>;
32
+ /**
33
+ * Stores a governed, secret-sanitized document/memory in the workspace's Supermemory v5 namespace.
34
+ */
35
+ addMemory(params: {
36
+ workspaceId: string;
37
+ documentId?: string;
38
+ title: string;
39
+ content: string;
40
+ kind: MemoryRecordKind;
41
+ metadata?: Record<string, unknown>;
42
+ }): Promise<{
43
+ documentId: string;
44
+ namespace: string;
45
+ status: string;
46
+ sanitizedContent: string;
47
+ }>;
48
+ recordExecutionMemory(params: {
49
+ workspaceId: string;
50
+ toolSlug: string;
51
+ lane: string;
52
+ riskLevel: string;
53
+ reason: string;
54
+ status: string;
55
+ summary: string;
56
+ }): Promise<string | null>;
57
+ /**
58
+ * Deletes/forgets a memory document from the workspace's Supermemory v5 namespace.
59
+ */
60
+ deleteMemory(workspaceId: string, documentId: string): Promise<{
61
+ deleted: boolean;
62
+ namespace: string;
63
+ }>;
64
+ }
@@ -0,0 +1,224 @@
1
+ import crypto from "node:crypto";
2
+ import Supermemory from "supermemory";
3
+ /**
4
+ * Supermemory v5 Contextual Brain & Context-Aware Tool Call Adapter.
5
+ * Uses deterministic per-workspace namespaces (`/ns/muxo-v5-<hash>/...`)
6
+ * and strict secret redaction so credentials never enter external memory.
7
+ */
8
+ export class SupermemoryAdapter {
9
+ config;
10
+ client;
11
+ constructor(config) {
12
+ this.config = config;
13
+ if (config.supermemoryApiKey) {
14
+ this.client = new Supermemory({
15
+ apiKey: config.supermemoryApiKey,
16
+ baseUrl: config.supermemoryBaseUrl,
17
+ maxRetries: 1,
18
+ });
19
+ }
20
+ else {
21
+ this.client = null;
22
+ }
23
+ }
24
+ isEnabled() {
25
+ return Boolean(this.client);
26
+ }
27
+ /**
28
+ * Derives a strict Supermemory v5 namespace (`^[a-zA-Z0-9_:-]+$`) scoped to a workspace.
29
+ */
30
+ namespaceForWorkspace(workspaceId) {
31
+ const hash = crypto
32
+ .createHash("sha256")
33
+ .update(`muxo-v5-ns:${workspaceId}`)
34
+ .digest("hex")
35
+ .slice(0, 24);
36
+ return `muxo-v5-${hash}`;
37
+ }
38
+ getWorkspaceNamespace(workspaceId) {
39
+ return this.namespaceForWorkspace(workspaceId);
40
+ }
41
+ /**
42
+ * Strips any API keys, bearer tokens, connection strings, or .env secret assignments
43
+ * before content is stored in Supermemory (AGENTS.md Invariant #11 & #12).
44
+ */
45
+ sanitizeContent(raw) {
46
+ return raw
47
+ .replace(/\b(sk_live_|sk_test_|mk_live_|mk_test_|sm_|ak_|uak_|rk_live_|rk_test_|whsec_|ghp_|xoxb-|xoxp-)[A-Za-z0-9_\-]{6,}/g, "[REDACTED_KEY]")
48
+ .replace(/\b(postgres(?:ql)?|mysql|redis|rediss|mongodb(?:\+srv)?):\/\/[^\s"'`]+/gi, "$1://[REDACTED_CONNECTION_URI]")
49
+ .replace(/\b([A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|API_KEY|PRIVATE_KEY|CONNECTION_STRING)[A-Z0-9_]*)\s*=\s*[^\s\n]+/g, "$1=[REDACTED]");
50
+ }
51
+ /**
52
+ * Fetches the workspace's static + dynamic profile and optionally semantic search results
53
+ * in a single fail-open call.
54
+ */
55
+ async getContextForWorkspace(workspaceIdOrParams, optionalQuery) {
56
+ const params = typeof workspaceIdOrParams === "string"
57
+ ? { workspaceId: workspaceIdOrParams, query: optionalQuery, limit: 5 }
58
+ : workspaceIdOrParams;
59
+ const namespace = this.namespaceForWorkspace(params.workspaceId);
60
+ if (!this.client) {
61
+ return {
62
+ enabled: false,
63
+ namespace,
64
+ staticFacts: [],
65
+ dynamicContext: [],
66
+ recalledMemories: [],
67
+ formattedPromptContext: "Supermemory v5 disabled (no API key configured).",
68
+ profile: { static: [], dynamic: [], preferences: [] },
69
+ relevantMemories: [],
70
+ };
71
+ }
72
+ const limit = Math.min(10, Math.max(1, Number(params.limit || 5)));
73
+ let staticFacts = [];
74
+ let dynamicFacts = [];
75
+ let preferences = [];
76
+ const relevantMemories = [];
77
+ try {
78
+ const profileRes = await this.client.profile(namespace, {
79
+ ...(params.query ? { q: params.query } : {}),
80
+ });
81
+ staticFacts = Array.isArray(profileRes?.profile?.static)
82
+ ? profileRes.profile.static.map(String)
83
+ : [];
84
+ dynamicFacts = Array.isArray(profileRes?.profile?.dynamic)
85
+ ? profileRes.profile.dynamic.map(String)
86
+ : [];
87
+ preferences = Array.isArray(profileRes?.profile?.buckets?.preferences)
88
+ ? profileRes.profile.buckets.preferences.map(String)
89
+ : [];
90
+ }
91
+ catch {
92
+ // Fail-open: never block tool planning if profile endpoint times out
93
+ }
94
+ if (params.query && params.query.trim().length > 0) {
95
+ try {
96
+ const searchRes = await this.client.search(namespace, {
97
+ query: params.query.trim(),
98
+ limit,
99
+ searchMode: "hybrid",
100
+ include: { documents: true, forgotten: false, related: false },
101
+ rewriteQuery: false,
102
+ });
103
+ for (const item of (searchRes?.results || []).slice(0, limit)) {
104
+ const doc = item.included?.document;
105
+ const title = String(doc?.metadata?.title ||
106
+ doc?.title ||
107
+ item.memory ||
108
+ item.chunk ||
109
+ "Workspace Memory").slice(0, 120);
110
+ const snippet = String(item.memory || item.chunk || doc?.metadata?.summary || "").slice(0, 300);
111
+ relevantMemories.push({
112
+ documentId: String(doc?.id || item.id || ""),
113
+ title,
114
+ snippet,
115
+ similarity: Number(item.similarity || 0),
116
+ });
117
+ }
118
+ }
119
+ catch {
120
+ // Fail-open
121
+ }
122
+ }
123
+ const promptLines = [
124
+ `[Supermemory Brain — Namespace: ${namespace}]`,
125
+ ];
126
+ if (staticFacts.length > 0) {
127
+ promptLines.push(`Static Facts: ${staticFacts.join(" | ")}`);
128
+ }
129
+ if (dynamicFacts.length > 0) {
130
+ promptLines.push(`Dynamic Context: ${dynamicFacts.join(" | ")}`);
131
+ }
132
+ if (relevantMemories.length > 0) {
133
+ promptLines.push(`Recalled Memories: ${relevantMemories.map((m) => `${m.title}: ${m.snippet}`).join(" | ")}`);
134
+ }
135
+ return {
136
+ enabled: true,
137
+ namespace,
138
+ staticFacts,
139
+ dynamicContext: dynamicFacts,
140
+ recalledMemories: relevantMemories,
141
+ formattedPromptContext: promptLines.join("\n"),
142
+ profile: {
143
+ static: staticFacts,
144
+ dynamic: dynamicFacts,
145
+ preferences,
146
+ },
147
+ relevantMemories,
148
+ };
149
+ }
150
+ /**
151
+ * Stores a governed, secret-sanitized document/memory in the workspace's Supermemory v5 namespace.
152
+ */
153
+ async addMemory(params) {
154
+ const namespace = this.namespaceForWorkspace(params.workspaceId);
155
+ const sanitizedContent = this.sanitizeContent(params.content);
156
+ const docId = params.documentId || `mem_${crypto.randomBytes(8).toString("hex")}`;
157
+ if (!this.client) {
158
+ return {
159
+ documentId: docId,
160
+ namespace,
161
+ status: "local_only",
162
+ sanitizedContent,
163
+ };
164
+ }
165
+ const res = await this.client.add(namespace, {
166
+ id: docId,
167
+ content: `${params.title}\n\n${sanitizedContent}`,
168
+ taskType: "memory",
169
+ metadata: {
170
+ title: params.title,
171
+ muxoWorkspaceId: params.workspaceId,
172
+ muxoKind: params.kind,
173
+ ...(params.metadata || {}),
174
+ },
175
+ });
176
+ return {
177
+ documentId: String(res.id || docId),
178
+ namespace,
179
+ status: String(res.status || "queued"),
180
+ sanitizedContent,
181
+ };
182
+ }
183
+ async recordExecutionMemory(params) {
184
+ try {
185
+ const added = await this.addMemory({
186
+ workspaceId: params.workspaceId,
187
+ title: `Execution: ${params.toolSlug} (${params.status})`,
188
+ content: params.summary,
189
+ kind: "execution_outcome",
190
+ metadata: {
191
+ toolSlug: params.toolSlug,
192
+ lane: params.lane,
193
+ riskLevel: params.riskLevel,
194
+ status: params.status,
195
+ },
196
+ });
197
+ return added.documentId;
198
+ }
199
+ catch {
200
+ return null;
201
+ }
202
+ }
203
+ /**
204
+ * Deletes/forgets a memory document from the workspace's Supermemory v5 namespace.
205
+ */
206
+ async deleteMemory(workspaceId, documentId) {
207
+ const namespace = this.namespaceForWorkspace(workspaceId);
208
+ if (!this.client) {
209
+ return { deleted: true, namespace };
210
+ }
211
+ try {
212
+ const res = await this.client.documents.delete(namespace, {
213
+ ids: [documentId],
214
+ });
215
+ return {
216
+ deleted: (res?.count || 0) >= 1,
217
+ namespace,
218
+ };
219
+ }
220
+ catch {
221
+ return { deleted: false, namespace };
222
+ }
223
+ }
224
+ }
@@ -1,4 +1,4 @@
1
- import type { ActionPlan, ConnectionRecord, ExecutionReceipt, ExecutionRun, MuxoTool, ProviderLane, ProvisionedResource, RiskLevel, SupplierSettlementSummary, Workspace, WorkspaceMemoryRecord } from "./types.js";
1
+ import type { ActionPlan, ByokKeyRecord, ConnectionRecord, ExecutionReceipt, ExecutionRun, MuxoTool, ProviderLane, ProvisionedResource, RiskLevel, SupplierSettlementSummary, Workspace, WorkspaceMemoryRecord } from "./types.js";
2
2
  export interface MuxoClientOptions {
3
3
  baseUrl?: string;
4
4
  apiKey?: string | (() => string | Promise<string>);
@@ -174,4 +174,80 @@ export declare class MuxoClient {
174
174
  namespace: string;
175
175
  records: WorkspaceMemoryRecord[];
176
176
  }>;
177
+ do(prompt: string, options?: {
178
+ input?: Record<string, unknown>;
179
+ autoApprove?: boolean;
180
+ dryRun?: boolean;
181
+ }): Promise<{
182
+ ok: boolean;
183
+ executed: boolean;
184
+ status: string;
185
+ intent: {
186
+ toolSlug: string | null;
187
+ input: Record<string, unknown>;
188
+ extractedInput: Record<string, unknown>;
189
+ reason: string;
190
+ confidence: number;
191
+ };
192
+ resolution: Record<string, unknown>;
193
+ plan?: ActionPlan;
194
+ run?: ExecutionRun;
195
+ receipt?: ExecutionReceipt;
196
+ humanMessage: string;
197
+ }>;
198
+ ask(prompt: string, options?: {
199
+ input?: Record<string, unknown>;
200
+ autoApprove?: boolean;
201
+ dryRun?: boolean;
202
+ }): Promise<{
203
+ ok: boolean;
204
+ executed: boolean;
205
+ status: string;
206
+ intent: {
207
+ toolSlug: string | null;
208
+ input: Record<string, unknown>;
209
+ extractedInput: Record<string, unknown>;
210
+ reason: string;
211
+ confidence: number;
212
+ };
213
+ resolution: Record<string, unknown>;
214
+ plan?: ActionPlan;
215
+ run?: ExecutionRun;
216
+ receipt?: ExecutionReceipt;
217
+ humanMessage: string;
218
+ }>;
219
+ listByokKeys(): Promise<{
220
+ ok: true;
221
+ workspaceId: string;
222
+ keys: ByokKeyRecord[];
223
+ }>;
224
+ setByokKey(provider: string, secretKey: string): Promise<{
225
+ ok: true;
226
+ key: ByokKeyRecord;
227
+ keys: ByokKeyRecord[];
228
+ }>;
229
+ deleteByokKey(provider: string): Promise<{
230
+ ok: true;
231
+ deleted: boolean;
232
+ provider: string;
233
+ keys: ByokKeyRecord[];
234
+ }>;
235
+ upgradePlan(): Promise<{
236
+ ok: true;
237
+ tier: string;
238
+ workspace: Workspace;
239
+ settlementSummary: SupplierSettlementSummary;
240
+ }>;
241
+ createCheckoutSession(kind?: "starter_subscription" | "credit_topup"): Promise<{
242
+ ok: true;
243
+ sessionId: string;
244
+ url: string;
245
+ mode?: string;
246
+ }>;
247
+ verifyCheckoutSession(sessionId: string): Promise<{
248
+ ok: true;
249
+ fulfilled: boolean;
250
+ workspace: Workspace | null;
251
+ kind: string;
252
+ }>;
177
253
  }
package/dist/sdk.js ADDED
@@ -0,0 +1,270 @@
1
+ export class MuxoClient {
2
+ baseUrl;
3
+ apiKeyResolver;
4
+ fetchImpl;
5
+ timeoutMs;
6
+ constructor(options = {}) {
7
+ this.baseUrl = (options.baseUrl ||
8
+ process.env.MUXO_BASE_URL ||
9
+ "https://app.muxo.ai").replace(/\/+$/, "");
10
+ if (typeof options.apiKey === "function") {
11
+ this.apiKeyResolver = options.apiKey;
12
+ }
13
+ else if (typeof options.apiKey === "string") {
14
+ const key = options.apiKey;
15
+ this.apiKeyResolver = () => key;
16
+ }
17
+ else if (process.env.MUXO_API_KEY) {
18
+ const key = process.env.MUXO_API_KEY;
19
+ this.apiKeyResolver = () => key;
20
+ }
21
+ this.fetchImpl = options.fetch || fetch;
22
+ this.timeoutMs = options.timeoutMs ?? 30000;
23
+ }
24
+ async request(path, init = {}) {
25
+ const headers = {
26
+ Accept: "application/json",
27
+ };
28
+ if (this.apiKeyResolver) {
29
+ const token = await this.apiKeyResolver();
30
+ if (token)
31
+ headers.Authorization = `Bearer ${token}`;
32
+ }
33
+ if (init.body !== undefined) {
34
+ headers["Content-Type"] = "application/json";
35
+ }
36
+ const res = await this.fetchImpl(`${this.baseUrl}${path}`, {
37
+ method: init.method || "GET",
38
+ headers,
39
+ body: init.body !== undefined ? JSON.stringify(init.body) : undefined,
40
+ signal: AbortSignal.timeout(this.timeoutMs),
41
+ });
42
+ const payload = (await res.json());
43
+ if (!res.ok || payload.ok === false) {
44
+ throw new Error(String(payload.error || `Muxo request failed with HTTP ${res.status}`));
45
+ }
46
+ return payload;
47
+ }
48
+ static async signup(params = {}, baseUrl = "https://app.muxo.ai") {
49
+ const client = new MuxoClient({ baseUrl });
50
+ return client.signupAgent({
51
+ agentName: params.agentName || params.workspaceName || "muxo-sdk-agent",
52
+ harness: params.harness || "muxo-sdk",
53
+ });
54
+ }
55
+ async signupAgent(params) {
56
+ return this.request("/api/v1/agents/signup", {
57
+ method: "POST",
58
+ body: params,
59
+ });
60
+ }
61
+ async whoami() {
62
+ const res = await this.mcpCall("get_organization", {});
63
+ const workspace = (res.workspace || res.organization);
64
+ return {
65
+ ok: true,
66
+ ...res,
67
+ workspace,
68
+ };
69
+ }
70
+ async mcpCall(name, args = {}) {
71
+ const rpcRes = await this.request("/mcp", {
72
+ method: "POST",
73
+ body: {
74
+ jsonrpc: "2.0",
75
+ id: Date.now(),
76
+ method: "tools/call",
77
+ params: { name, arguments: args },
78
+ },
79
+ });
80
+ if (rpcRes.error) {
81
+ throw new Error(rpcRes.error.message || "MCP call failed");
82
+ }
83
+ if (rpcRes.result?.structuredContent) {
84
+ return rpcRes.result.structuredContent;
85
+ }
86
+ const text = rpcRes.result?.content?.[0]?.text;
87
+ if (text) {
88
+ return JSON.parse(text);
89
+ }
90
+ return (rpcRes.result || {});
91
+ }
92
+ async searchTools(params) {
93
+ const qs = new URLSearchParams();
94
+ if (params?.query)
95
+ qs.set("query", params.query);
96
+ if (params?.lane)
97
+ qs.set("lane", params.lane);
98
+ if (params?.riskLevel)
99
+ qs.set("risk_level", params.riskLevel);
100
+ if (params?.limit)
101
+ qs.set("limit", String(params.limit));
102
+ const suffix = qs.toString() ? `?${qs.toString()}` : "";
103
+ return this.request(`/api/v1/tools${suffix}`);
104
+ }
105
+ async inspectTool(slug) {
106
+ return this.request(`/api/v1/tools/${encodeURIComponent(slug)}`);
107
+ }
108
+ async planAction(params) {
109
+ return this.request("/api/v1/plans", {
110
+ method: "POST",
111
+ body: params,
112
+ });
113
+ }
114
+ async approvePlan(planId) {
115
+ return this.request(`/api/v1/plans/${encodeURIComponent(planId)}/approve`, {
116
+ method: "POST",
117
+ });
118
+ }
119
+ async executePlan(planId) {
120
+ return this.request(`/api/v1/plans/${encodeURIComponent(planId)}/execute`, {
121
+ method: "POST",
122
+ });
123
+ }
124
+ async exec(toolSlug, input = {}, options = {}) {
125
+ const planned = await this.planAction({
126
+ toolSlug,
127
+ input,
128
+ reason: options.reason,
129
+ });
130
+ let plan = planned.plan;
131
+ if (plan.approvalStatus === "pending_approval" && options.approve) {
132
+ const approved = await this.approvePlan(plan.id);
133
+ plan = approved.plan;
134
+ }
135
+ const executed = await this.executePlan(plan.id);
136
+ return {
137
+ ok: true,
138
+ plan,
139
+ run: executed.run,
140
+ receipt: executed.receipt,
141
+ settlement: executed.settlement ||
142
+ executed.receipt?.supplierSettlement ||
143
+ null,
144
+ };
145
+ }
146
+ async verifyReceipt(receiptId) {
147
+ const res = await this.request(`/api/v1/receipts/${encodeURIComponent(receiptId)}`);
148
+ const isOk = Boolean(res.valid ?? res.verified ?? true);
149
+ return {
150
+ ok: true,
151
+ valid: isOk,
152
+ verified: isOk,
153
+ receipt: res.receipt,
154
+ };
155
+ }
156
+ async startConnection(paramsOrProvider) {
157
+ const body = typeof paramsOrProvider === "string"
158
+ ? { provider: paramsOrProvider }
159
+ : paramsOrProvider;
160
+ return this.request("/api/v1/connections", {
161
+ method: "POST",
162
+ body,
163
+ });
164
+ }
165
+ async waitForConnection(paramsOrProvider, options) {
166
+ const body = typeof paramsOrProvider === "string"
167
+ ? { provider: paramsOrProvider, ...options }
168
+ : paramsOrProvider;
169
+ const res = await this.request("/api/v1/connections/wait", {
170
+ method: "POST",
171
+ body,
172
+ });
173
+ return {
174
+ ...res,
175
+ status: res.status || res.connection?.status || "pending",
176
+ };
177
+ }
178
+ async listResources() {
179
+ return this.request("/api/v1/resources");
180
+ }
181
+ async pullEnv() {
182
+ const res = await this.request("/api/v1/resources/env");
183
+ return Object.assign(res, {
184
+ includes: (substr) => String(res.dotenv || "").includes(substr),
185
+ toString: () => String(res.dotenv || ""),
186
+ });
187
+ }
188
+ async topupCredits(paramsOrCredits, description) {
189
+ const body = typeof paramsOrCredits === "number"
190
+ ? { credits: paramsOrCredits, description }
191
+ : paramsOrCredits;
192
+ const res = await this.request("/api/v1/billing/topup", {
193
+ method: "POST",
194
+ body,
195
+ });
196
+ return {
197
+ ...res,
198
+ creditBalance: res.creditBalance ?? res.workspace?.creditsBalance ?? 0,
199
+ };
200
+ }
201
+ async getBillingStatus() {
202
+ return this.getSettlements();
203
+ }
204
+ async settlements() {
205
+ const res = await this.getSettlements();
206
+ return {
207
+ ...res,
208
+ summary: res.settlementSummary,
209
+ };
210
+ }
211
+ async getSettlements() {
212
+ const res = await this.request("/api/v1/billing/settlements");
213
+ if (res.settlementSummary &&
214
+ res.settlementSummary.totalCustomerChargedCredits === undefined) {
215
+ res.settlementSummary.totalCustomerChargedCredits =
216
+ res.settlementSummary.totalCreditsConsumed;
217
+ }
218
+ return res;
219
+ }
220
+ async recallMemory(query) {
221
+ const suffix = query ? `?query=${encodeURIComponent(query)}` : "";
222
+ return this.request(`/api/v1/memory${suffix}`);
223
+ }
224
+ async do(prompt, options = {}) {
225
+ return this.request("/api/v1/do", {
226
+ method: "POST",
227
+ body: {
228
+ prompt,
229
+ input: options.input,
230
+ autoApprove: options.autoApprove !== false,
231
+ dryRun: options.dryRun === true,
232
+ },
233
+ });
234
+ }
235
+ async ask(prompt, options) {
236
+ return this.do(prompt, options);
237
+ }
238
+ async listByokKeys() {
239
+ return this.request("/api/v1/byok");
240
+ }
241
+ async setByokKey(provider, secretKey) {
242
+ return this.request("/api/v1/byok", {
243
+ method: "POST",
244
+ body: { provider, secretKey },
245
+ });
246
+ }
247
+ async deleteByokKey(provider) {
248
+ return this.request(`/api/v1/byok/${encodeURIComponent(provider)}`, {
249
+ method: "DELETE",
250
+ });
251
+ }
252
+ async upgradePlan() {
253
+ return this.request("/api/v1/billing/upgrade", {
254
+ method: "POST",
255
+ body: {},
256
+ });
257
+ }
258
+ async createCheckoutSession(kind = "credit_topup") {
259
+ return this.request("/api/v1/billing/checkout", {
260
+ method: "POST",
261
+ body: { kind },
262
+ });
263
+ }
264
+ async verifyCheckoutSession(sessionId) {
265
+ return this.request("/api/v1/billing/verify-session", {
266
+ method: "POST",
267
+ body: { sessionId },
268
+ });
269
+ }
270
+ }
@@ -0,0 +1,10 @@
1
+ import http from "node:http";
2
+ import { type MuxoConfig } from "./config.js";
3
+ import { MuxoEngine } from "./engine.js";
4
+ import { MuxoStore } from "./store.js";
5
+ export declare function createMuxoServer(customConfig?: Partial<MuxoConfig>): {
6
+ server: http.Server;
7
+ engine: MuxoEngine;
8
+ store: MuxoStore;
9
+ defaultApiKey?: string;
10
+ };