@muxoai/platform 1.2.3 → 1.3.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.
- package/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/marketplace.json +19 -4
- package/.codex/config.toml +9 -2
- package/README.md +72 -28
- package/dist/cli.js +1047 -43
- package/dist/engine.d.ts +29 -0
- package/dist/engine.js +221 -16
- package/dist/mcp.d.ts +6 -1
- package/dist/mcp.js +120 -26
- package/dist/nl.d.ts +34 -0
- package/dist/nl.js +601 -0
- package/dist/providers/composio-instant.d.ts +1 -0
- package/dist/providers/composio-instant.js +6 -5
- package/dist/providers/composio-sdk.d.ts +1 -0
- package/dist/providers/composio-sdk.js +6 -2
- package/dist/providers/stripe-billing.d.ts +13 -3
- package/dist/providers/stripe-billing.js +250 -36
- package/dist/providers/stripe-projects.js +61 -4
- package/dist/providers/supermemory.d.ts +2 -0
- package/dist/providers/supermemory.js +58 -40
- package/dist/sdk.d.ts +77 -1
- package/dist/sdk.js +46 -0
- package/dist/server.js +202 -29
- package/dist/store.d.ts +19 -2
- package/dist/store.js +216 -11
- package/dist/types.d.ts +14 -2
- package/dist/ui/console-html.js +329 -119
- package/package.json +1 -1
- package/plugins/muxo/.app.json +1 -1
- package/plugins/muxo/.claude-plugin/plugin.json +2 -2
- package/plugins/muxo/.codex-plugin/plugin.json +7 -5
- package/plugins/muxo/.mcp.json +1 -33
- package/plugins/muxo/assets/logo.png +0 -0
- package/plugins/muxo/hooks/session-start.sh +1 -1
- package/plugins/muxo/plugin.json +63 -6
- package/plugins/muxo/skills/muxo/SKILL.md +92 -14
- package/plugins/muxo/skills/muxo/agents/openai.yaml +12 -0
- package/plugins/muxo/skills/muxo/references/cli.md +4 -2
- package/plugins/muxo/skills/muxo/references/mcp.md +15 -9
- package/plugins/muxo/skills/setup/SKILL.md +8 -2
- package/plugins/muxo/skills/setup/agents/openai.yaml +12 -0
package/dist/engine.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MuxoConfig } from "./config.js";
|
|
2
|
+
import { type NaturalLanguageResolution } from "./nl.js";
|
|
2
3
|
import { ComposioInstantAdapter } from "./providers/composio-instant.js";
|
|
3
4
|
import { ComposioSdkAdapter } from "./providers/composio-sdk.js";
|
|
4
5
|
import { MicrosoftGovernanceAdapter } from "./providers/microsoft-governance.js";
|
|
@@ -34,6 +35,7 @@ export declare class MuxoEngine {
|
|
|
34
35
|
tools: MuxoTool[];
|
|
35
36
|
total: number;
|
|
36
37
|
}>;
|
|
38
|
+
listAllCatalogTools(): Promise<MuxoTool[]>;
|
|
37
39
|
inspectTool(slug: string): Promise<MuxoTool>;
|
|
38
40
|
connectionStatus(ctx: ExecutionContext, params?: {
|
|
39
41
|
provider?: string;
|
|
@@ -93,6 +95,7 @@ export declare class MuxoEngine {
|
|
|
93
95
|
}>;
|
|
94
96
|
getPlan(ctx: ExecutionContext, planId: string): ActionPlan;
|
|
95
97
|
approvePlan(ctx: ExecutionContext, planId: string, decision?: "approved" | "rejected"): ActionPlan;
|
|
98
|
+
private enrichMemoryContext;
|
|
96
99
|
getRunContext(ctx: ExecutionContext, query?: string): Promise<Record<string, unknown>>;
|
|
97
100
|
getMemoryOverview(ctx: ExecutionContext, query?: string): Promise<{
|
|
98
101
|
enabled: boolean;
|
|
@@ -125,4 +128,30 @@ export declare class MuxoEngine {
|
|
|
125
128
|
signatureValid: boolean;
|
|
126
129
|
governanceSignatureValid: boolean;
|
|
127
130
|
};
|
|
131
|
+
doNaturalLanguage(ctx: ExecutionContext, params: {
|
|
132
|
+
prompt: string;
|
|
133
|
+
input?: Record<string, unknown>;
|
|
134
|
+
autoApprove?: boolean;
|
|
135
|
+
dryRun?: boolean;
|
|
136
|
+
planOnly?: boolean;
|
|
137
|
+
fundingMode?: "muxo_funded" | "byok";
|
|
138
|
+
}): Promise<{
|
|
139
|
+
ok: boolean;
|
|
140
|
+
executed: boolean;
|
|
141
|
+
status: "executed" | "planned_dry_run" | "awaiting_approval" | "awaiting_oauth_connection" | "missing_inputs" | "unresolved";
|
|
142
|
+
intent: NaturalLanguageResolution;
|
|
143
|
+
resolution: NaturalLanguageResolution;
|
|
144
|
+
plan?: ActionPlan;
|
|
145
|
+
run?: ExecutionRun;
|
|
146
|
+
receipt?: ExecutionReceipt;
|
|
147
|
+
authHandoff?: Record<string, unknown>;
|
|
148
|
+
byokPrompt?: {
|
|
149
|
+
needed: boolean;
|
|
150
|
+
provider: string;
|
|
151
|
+
envVarName: string;
|
|
152
|
+
cliCommand: string;
|
|
153
|
+
message: string;
|
|
154
|
+
};
|
|
155
|
+
humanMessage: string;
|
|
156
|
+
}>;
|
|
128
157
|
}
|
package/dist/engine.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveNaturalLanguageIntent, } from "./nl.js";
|
|
1
2
|
import { ComposioInstantAdapter } from "./providers/composio-instant.js";
|
|
2
3
|
import { ComposioSdkAdapter } from "./providers/composio-sdk.js";
|
|
3
4
|
import { MicrosoftGovernanceAdapter } from "./providers/microsoft-governance.js";
|
|
@@ -25,10 +26,14 @@ export class MuxoEngine {
|
|
|
25
26
|
}
|
|
26
27
|
// 1. get_profile
|
|
27
28
|
getProfile(ctx) {
|
|
29
|
+
const nickname = (ctx.user.email || "").split("@")[0] ||
|
|
30
|
+
ctx.user.name.toLowerCase().replace(/\s+/g, ".") ||
|
|
31
|
+
ctx.user.id;
|
|
28
32
|
return {
|
|
29
33
|
id: ctx.user.id,
|
|
30
34
|
name: ctx.user.name,
|
|
31
35
|
email: ctx.user.email,
|
|
36
|
+
nickname,
|
|
32
37
|
user: ctx.user,
|
|
33
38
|
actorId: ctx.actorId,
|
|
34
39
|
authType: ctx.authType,
|
|
@@ -79,6 +84,14 @@ export class MuxoEngine {
|
|
|
79
84
|
}
|
|
80
85
|
if (lane === "all" || lane === "stripe_projects") {
|
|
81
86
|
results.push(...this.stripeProjects.searchTools(query, limit));
|
|
87
|
+
const billingTools = this.stripeBilling.listTools().filter((t) => {
|
|
88
|
+
if (!query)
|
|
89
|
+
return true;
|
|
90
|
+
const q = query.toLowerCase();
|
|
91
|
+
const hay = `${t.slug} ${t.name} ${t.description} ${t.categories.join(" ")}`.toLowerCase();
|
|
92
|
+
return q.split(/\s+/).some((tok) => hay.includes(tok));
|
|
93
|
+
});
|
|
94
|
+
results.push(...billingTools);
|
|
82
95
|
}
|
|
83
96
|
const filtered = params.riskLevel
|
|
84
97
|
? results.filter((t) => t.riskLevel === params.riskLevel)
|
|
@@ -88,9 +101,22 @@ export class MuxoEngine {
|
|
|
88
101
|
total: filtered.length,
|
|
89
102
|
};
|
|
90
103
|
}
|
|
104
|
+
async listAllCatalogTools() {
|
|
105
|
+
const instant = this.composioInstant.searchTools(undefined, 100);
|
|
106
|
+
const sdk = await this.composioSdk.searchTools(undefined, 100);
|
|
107
|
+
const proj = this.stripeProjects.searchTools(undefined, 100);
|
|
108
|
+
const billing = this.stripeBilling.listTools();
|
|
109
|
+
return [...instant, ...billing, ...sdk, ...proj];
|
|
110
|
+
}
|
|
91
111
|
// 4. inspect_tool
|
|
92
112
|
async inspectTool(slug) {
|
|
93
113
|
const normalized = slug.trim();
|
|
114
|
+
const billing = this.stripeBilling
|
|
115
|
+
.listTools()
|
|
116
|
+
.find((t) => t.slug.toLowerCase() === normalized.toLowerCase() ||
|
|
117
|
+
t.upstreamSlug.toLowerCase() === normalized.toLowerCase());
|
|
118
|
+
if (billing)
|
|
119
|
+
return billing;
|
|
94
120
|
const instant = this.composioInstant.inspectTool(normalized);
|
|
95
121
|
if (instant)
|
|
96
122
|
return instant;
|
|
@@ -346,15 +372,40 @@ export class MuxoEngine {
|
|
|
346
372
|
// 7. plan_action
|
|
347
373
|
async planAction(ctx, params) {
|
|
348
374
|
const ws = this.store.getWorkspace(ctx.workspace.id);
|
|
349
|
-
|
|
375
|
+
let tool;
|
|
376
|
+
let resolvedInput = { ...(params.input || {}) };
|
|
377
|
+
let resolvedReason = params.reason || `Planned execution of ${params.toolSlug}`;
|
|
378
|
+
try {
|
|
379
|
+
tool = await this.inspectTool(params.toolSlug);
|
|
380
|
+
}
|
|
381
|
+
catch (inspectErr) {
|
|
382
|
+
// Natural-language fallback: if an agent or human passed plain English as toolSlug/instruction, resolve it!
|
|
383
|
+
const nlSource = `${params.toolSlug} ${params.reason || ""}`.trim();
|
|
384
|
+
const allTools = await this.listAllCatalogTools();
|
|
385
|
+
const byokEnv = this.store.getDecryptedWorkspaceEnv(ws.id);
|
|
386
|
+
const nl = await resolveNaturalLanguageIntent({
|
|
387
|
+
prompt: nlSource,
|
|
388
|
+
tools: allTools,
|
|
389
|
+
explicitInput: resolvedInput,
|
|
390
|
+
byokKeys: byokEnv,
|
|
391
|
+
});
|
|
392
|
+
if (!nl.resolved || !nl.tool) {
|
|
393
|
+
throw inspectErr;
|
|
394
|
+
}
|
|
395
|
+
tool = nl.tool;
|
|
396
|
+
resolvedInput = nl.input;
|
|
397
|
+
resolvedReason = params.reason || nl.reason || nlSource;
|
|
398
|
+
}
|
|
399
|
+
const byokActive = this.store.hasByokForLane(ws.id, tool.lane, tool.slug);
|
|
400
|
+
const effectiveCreditCost = byokActive ? 0 : tool.creditCost;
|
|
350
401
|
if (ws.monthlyActionsUsed >= ws.monthlyActionsLimit) {
|
|
351
402
|
throw new Error(`Monthly action limit reached (${ws.monthlyActionsUsed}/${ws.monthlyActionsLimit}). Upgrade to Starter ($29/mo) to unlock 5,000 actions/mo.`);
|
|
352
403
|
}
|
|
353
|
-
if (
|
|
354
|
-
throw new Error(`Insufficient workspace credits for ${tool.slug} (requires ${
|
|
404
|
+
if (effectiveCreditCost > ws.creditsBalance) {
|
|
405
|
+
throw new Error(`Insufficient workspace credits for ${tool.slug} (requires ${effectiveCreditCost}, available ${ws.creditsBalance}). Top up credits or configure a BYOK key.`);
|
|
355
406
|
}
|
|
356
|
-
if (
|
|
357
|
-
throw new Error(`Tool credit cost (${
|
|
407
|
+
if (effectiveCreditCost > ws.policy.maxCreditsPerRun) {
|
|
408
|
+
throw new Error(`Tool credit cost (${effectiveCreditCost}) exceeds workspace policy maxCreditsPerRun (${ws.policy.maxCreditsPerRun}).`);
|
|
358
409
|
}
|
|
359
410
|
// 1. Evaluate Microsoft Agent Governance Pipeline:
|
|
360
411
|
// Agent -> McpSecurityScanner -> PolicyEngine -> AgentIdentity (Ed25519 DID) -> AuditLogger -> DecisionRecord
|
|
@@ -362,15 +413,15 @@ export class MuxoEngine {
|
|
|
362
413
|
workspace: ws,
|
|
363
414
|
actorId: ctx.actorId,
|
|
364
415
|
tool,
|
|
365
|
-
input:
|
|
366
|
-
reason:
|
|
416
|
+
input: resolvedInput,
|
|
417
|
+
reason: resolvedReason,
|
|
367
418
|
});
|
|
368
419
|
if (decisionRecord.verdict === "deny") {
|
|
369
420
|
throw new Error(`Microsoft Agent Governance denied plan for ${tool.slug} (rule: ${decisionRecord.matchedRule}): ${decisionRecord.reason}`);
|
|
370
421
|
}
|
|
371
422
|
// 2. Recall Supermemory v5 contextual brain for this workspace + tool intent
|
|
372
|
-
const memoryQuery = `${tool.slug} ${tool.name} ${
|
|
373
|
-
const memoryContext = await this.supermemory.getContextForWorkspace(ws.id, memoryQuery);
|
|
423
|
+
const memoryQuery = `${tool.slug} ${tool.name} ${resolvedReason}`.trim();
|
|
424
|
+
const memoryContext = await this.enrichMemoryContext(ws.id, await this.supermemory.getContextForWorkspace(ws.id, memoryQuery));
|
|
374
425
|
const requiresHumanApproval = decisionRecord.verdict === "escalate" ||
|
|
375
426
|
(ws.policy.mode === "enforce" &&
|
|
376
427
|
ws.policy.requireApprovalFor.includes(tool.riskLevel));
|
|
@@ -384,9 +435,9 @@ export class MuxoEngine {
|
|
|
384
435
|
upstreamSlug: tool.upstreamSlug,
|
|
385
436
|
lane: tool.lane,
|
|
386
437
|
riskLevel: tool.riskLevel,
|
|
387
|
-
input:
|
|
388
|
-
reason:
|
|
389
|
-
creditCost:
|
|
438
|
+
input: resolvedInput,
|
|
439
|
+
reason: resolvedReason,
|
|
440
|
+
creditCost: effectiveCreditCost,
|
|
390
441
|
approvalStatus,
|
|
391
442
|
decisionRecord,
|
|
392
443
|
memoryContext,
|
|
@@ -459,6 +510,38 @@ export class MuxoEngine {
|
|
|
459
510
|
approvedBy: ctx.user.email,
|
|
460
511
|
});
|
|
461
512
|
}
|
|
513
|
+
async enrichMemoryContext(workspaceId, ctx) {
|
|
514
|
+
if (ctx.recalledMemories.length > 0 && ctx.staticFacts.length > 0) {
|
|
515
|
+
return ctx;
|
|
516
|
+
}
|
|
517
|
+
const localRecords = this.store.listMemoryRecords(workspaceId, 8);
|
|
518
|
+
if (localRecords.length === 0)
|
|
519
|
+
return ctx;
|
|
520
|
+
const recalled = ctx.recalledMemories.length > 0
|
|
521
|
+
? ctx.recalledMemories
|
|
522
|
+
: localRecords.slice(0, 5).map((r) => ({
|
|
523
|
+
documentId: r.documentId,
|
|
524
|
+
title: r.title,
|
|
525
|
+
snippet: r.content.slice(0, 240),
|
|
526
|
+
similarity: 1,
|
|
527
|
+
}));
|
|
528
|
+
const staticFacts = ctx.staticFacts.length > 0
|
|
529
|
+
? ctx.staticFacts
|
|
530
|
+
: localRecords
|
|
531
|
+
.filter((r) => r.kind === "fact" || r.kind === "preference")
|
|
532
|
+
.slice(0, 5)
|
|
533
|
+
.map((r) => `${r.title}: ${r.content.slice(0, 140)}`);
|
|
534
|
+
return {
|
|
535
|
+
...ctx,
|
|
536
|
+
staticFacts,
|
|
537
|
+
recalledMemories: recalled,
|
|
538
|
+
relevantMemories: recalled,
|
|
539
|
+
profile: {
|
|
540
|
+
...ctx.profile,
|
|
541
|
+
static: staticFacts,
|
|
542
|
+
},
|
|
543
|
+
};
|
|
544
|
+
}
|
|
462
545
|
// 9. get_run_context
|
|
463
546
|
async getRunContext(ctx, query) {
|
|
464
547
|
const ws = this.store.getWorkspace(ctx.workspace.id);
|
|
@@ -469,7 +552,7 @@ export class MuxoEngine {
|
|
|
469
552
|
redactedEnv[k] =
|
|
470
553
|
v.length > 8 ? `${v.slice(0, 4)}••••${v.slice(-3)}` : "••••••••";
|
|
471
554
|
}
|
|
472
|
-
const memoryContext = await this.supermemory.getContextForWorkspace(ws.id, query);
|
|
555
|
+
const memoryContext = await this.enrichMemoryContext(ws.id, await this.supermemory.getContextForWorkspace(ws.id, query));
|
|
473
556
|
return {
|
|
474
557
|
workspaceId: ws.id,
|
|
475
558
|
workspaceSlug: ws.slug,
|
|
@@ -486,7 +569,7 @@ export class MuxoEngine {
|
|
|
486
569
|
}
|
|
487
570
|
// Supermemory Workspace Brain Operations
|
|
488
571
|
async getMemoryOverview(ctx, query) {
|
|
489
|
-
const context = await this.supermemory.getContextForWorkspace(ctx.workspace.id, query);
|
|
572
|
+
const context = await this.enrichMemoryContext(ctx.workspace.id, await this.supermemory.getContextForWorkspace(ctx.workspace.id, query));
|
|
490
573
|
const recentMemories = this.store.listMemoryRecords(ctx.workspace.id, 25);
|
|
491
574
|
return {
|
|
492
575
|
enabled: context.enabled,
|
|
@@ -549,6 +632,14 @@ export class MuxoEngine {
|
|
|
549
632
|
}
|
|
550
633
|
const ws = this.store.getWorkspace(ctx.workspace.id);
|
|
551
634
|
const tool = await this.inspectTool(plan.toolSlug);
|
|
635
|
+
const byokActive = this.store.hasByokForLane(ws.id, tool.lane, tool.slug);
|
|
636
|
+
const effectiveCreditCost = byokActive ? 0 : plan.creditCost;
|
|
637
|
+
if (ws.monthlyActionsUsed >= ws.monthlyActionsLimit) {
|
|
638
|
+
throw new Error(`Monthly action limit reached (${ws.monthlyActionsUsed}/${ws.monthlyActionsLimit}). Upgrade to Starter ($29/mo) to unlock 5,000 actions/mo.`);
|
|
639
|
+
}
|
|
640
|
+
if (effectiveCreditCost > ws.creditsBalance) {
|
|
641
|
+
throw new Error(`Insufficient workspace credits to execute plan '${plan.id}' for ${tool.slug} (requires ${effectiveCreditCost}, available ${ws.creditsBalance}). Top up credits or configure a BYOK key.`);
|
|
642
|
+
}
|
|
552
643
|
const execDecisionRecord = this.governance.evaluateExecution({
|
|
553
644
|
workspace: ws,
|
|
554
645
|
actorId: ctx.actorId,
|
|
@@ -583,19 +674,31 @@ export class MuxoEngine {
|
|
|
583
674
|
const startedMs = Date.now();
|
|
584
675
|
try {
|
|
585
676
|
let output;
|
|
586
|
-
if (plan.
|
|
677
|
+
if (plan.toolSlug.startsWith("billing.")) {
|
|
678
|
+
output = await this.stripeBilling.executeTool({
|
|
679
|
+
workspace: ws,
|
|
680
|
+
customerEmail: ctx.user.email,
|
|
681
|
+
toolSlug: plan.toolSlug,
|
|
682
|
+
input: plan.input,
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
else if (plan.lane === "composio_instant") {
|
|
686
|
+
const composioByok = this.store.getByokKey(ctx.workspace.id, "composio");
|
|
587
687
|
output = await this.composioInstant.executeTool({
|
|
588
688
|
workspaceId: ctx.workspace.id,
|
|
589
689
|
tool,
|
|
590
690
|
input: plan.input,
|
|
691
|
+
composioApiKey: composioByok,
|
|
591
692
|
});
|
|
592
693
|
}
|
|
593
694
|
else if (plan.lane === "composio_sdk") {
|
|
695
|
+
const composioByok = this.store.getByokKey(ctx.workspace.id, "composio");
|
|
594
696
|
output = await this.composioSdk.executeTool({
|
|
595
697
|
workspaceId: ctx.workspace.id,
|
|
596
698
|
tool,
|
|
597
699
|
input: plan.input,
|
|
598
700
|
connectedAccountId: activeConnId,
|
|
701
|
+
composioApiKey: composioByok,
|
|
599
702
|
});
|
|
600
703
|
}
|
|
601
704
|
else if (plan.lane === "stripe_projects") {
|
|
@@ -622,7 +725,7 @@ export class MuxoEngine {
|
|
|
622
725
|
status: "succeeded",
|
|
623
726
|
output,
|
|
624
727
|
actionsMetered: 1,
|
|
625
|
-
creditsMetered:
|
|
728
|
+
creditsMetered: effectiveCreditCost,
|
|
626
729
|
durationMs,
|
|
627
730
|
decisionRecord: execDecisionRecord,
|
|
628
731
|
});
|
|
@@ -716,4 +819,106 @@ export class MuxoEngine {
|
|
|
716
819
|
: true;
|
|
717
820
|
return { receipt, signatureValid, governanceSignatureValid };
|
|
718
821
|
}
|
|
822
|
+
// 19. Natural Language Router & End-to-End Executor (`muxo do` / `POST /api/v1/do`)
|
|
823
|
+
async doNaturalLanguage(ctx, params) {
|
|
824
|
+
const allTools = await this.listAllCatalogTools();
|
|
825
|
+
const byokEnv = this.store.getDecryptedWorkspaceEnv(ctx.workspace.id);
|
|
826
|
+
const activeConns = new Set(this.store
|
|
827
|
+
.listConnections(ctx.workspace.id)
|
|
828
|
+
.filter((c) => c.status === "active")
|
|
829
|
+
.map((c) => c.providerSlug.toLowerCase()));
|
|
830
|
+
const resolution = await resolveNaturalLanguageIntent({
|
|
831
|
+
prompt: params.prompt,
|
|
832
|
+
tools: allTools,
|
|
833
|
+
explicitInput: params.input,
|
|
834
|
+
byokKeys: byokEnv,
|
|
835
|
+
activeConnectionProviders: activeConns,
|
|
836
|
+
});
|
|
837
|
+
if (!resolution.resolved || !resolution.tool) {
|
|
838
|
+
return {
|
|
839
|
+
ok: false,
|
|
840
|
+
executed: false,
|
|
841
|
+
status: "unresolved",
|
|
842
|
+
intent: resolution,
|
|
843
|
+
resolution,
|
|
844
|
+
byokPrompt: {
|
|
845
|
+
needed: !byokEnv.OPENAI_API_KEY && !byokEnv.ANTHROPIC_API_KEY && !byokEnv.OPENROUTER_API_KEY,
|
|
846
|
+
provider: "openai",
|
|
847
|
+
envVarName: "OPENAI_API_KEY",
|
|
848
|
+
cliCommand: "muxo byok set openai <sk-...>",
|
|
849
|
+
message: "Tip: Add an OpenAI, Anthropic, or OpenRouter BYOK key (`muxo byok set openai <key>`) for unrestricted natural-language LLM routing.",
|
|
850
|
+
},
|
|
851
|
+
humanMessage: resolution.humanSummary,
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
if (resolution.missingInputs.length > 0) {
|
|
855
|
+
return {
|
|
856
|
+
ok: false,
|
|
857
|
+
executed: false,
|
|
858
|
+
status: "missing_inputs",
|
|
859
|
+
intent: resolution,
|
|
860
|
+
resolution,
|
|
861
|
+
humanMessage: `Matched ${resolution.tool.name} (${resolution.tool.slug}), but missing required parameter(s): ${resolution.missingInputs.join(", ")}. Please include them in your request.`,
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
const planned = await this.planAction(ctx, {
|
|
865
|
+
toolSlug: resolution.tool.slug,
|
|
866
|
+
input: resolution.input,
|
|
867
|
+
reason: params.prompt,
|
|
868
|
+
});
|
|
869
|
+
if (planned.authHandoff?.required) {
|
|
870
|
+
return {
|
|
871
|
+
ok: false,
|
|
872
|
+
executed: false,
|
|
873
|
+
status: "awaiting_oauth_connection",
|
|
874
|
+
intent: resolution,
|
|
875
|
+
resolution,
|
|
876
|
+
plan: planned.plan,
|
|
877
|
+
authHandoff: planned.authHandoff,
|
|
878
|
+
humanMessage: planned.authHandoff.instructions,
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
if (params.dryRun || params.planOnly) {
|
|
882
|
+
return {
|
|
883
|
+
ok: true,
|
|
884
|
+
executed: false,
|
|
885
|
+
status: "planned_dry_run",
|
|
886
|
+
intent: resolution,
|
|
887
|
+
resolution,
|
|
888
|
+
plan: planned.plan,
|
|
889
|
+
humanMessage: `Planned ${planned.tool.name} (${planned.plan.id}) with risk=${planned.plan.riskLevel} and cost=${planned.plan.creditCost} credits.`,
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
let currentPlan = planned.plan;
|
|
893
|
+
if (currentPlan.approvalStatus === "pending_approval" &&
|
|
894
|
+
params.autoApprove !== false) {
|
|
895
|
+
currentPlan = this.approvePlan(ctx, currentPlan.id, "approved");
|
|
896
|
+
}
|
|
897
|
+
if (currentPlan.approvalStatus === "pending_approval") {
|
|
898
|
+
return {
|
|
899
|
+
ok: true,
|
|
900
|
+
executed: false,
|
|
901
|
+
status: "awaiting_approval",
|
|
902
|
+
intent: resolution,
|
|
903
|
+
resolution,
|
|
904
|
+
plan: currentPlan,
|
|
905
|
+
humanMessage: `Plan ${currentPlan.id} (${currentPlan.toolSlug}, risk=${currentPlan.riskLevel}) requires owner approval. Run 'muxo approve ${currentPlan.id}' or pass --yes to auto-approve.`,
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
const executed = await this.executePlanForRisk(ctx, currentPlan.id, currentPlan.riskLevel);
|
|
909
|
+
const isSuccess = executed.run.status === "succeeded";
|
|
910
|
+
return {
|
|
911
|
+
ok: isSuccess,
|
|
912
|
+
executed: isSuccess,
|
|
913
|
+
status: "executed",
|
|
914
|
+
intent: resolution,
|
|
915
|
+
resolution,
|
|
916
|
+
plan: currentPlan,
|
|
917
|
+
run: executed.run,
|
|
918
|
+
receipt: executed.receipt,
|
|
919
|
+
humanMessage: isSuccess
|
|
920
|
+
? `Completed ${resolution.tool.name} (${resolution.tool.slug}) in ${executed.run.durationMs ?? 0}ms [receipt: ${executed.receipt.id}, funding: ${executed.receipt.supplierSettlement?.fundingMode || "muxo_funded"}].`
|
|
921
|
+
: `Execution of ${resolution.tool.slug} failed: ${executed.run.error || "Unknown error"}`,
|
|
922
|
+
};
|
|
923
|
+
}
|
|
719
924
|
}
|
package/dist/mcp.d.ts
CHANGED
|
@@ -4,12 +4,17 @@ export interface McpToolAnnotations {
|
|
|
4
4
|
destructiveHint: boolean;
|
|
5
5
|
openWorldHint: boolean;
|
|
6
6
|
}
|
|
7
|
+
export interface McpToolSecurityScheme {
|
|
8
|
+
type: "noauth" | "oauth2";
|
|
9
|
+
scopes?: string[];
|
|
10
|
+
}
|
|
7
11
|
export interface McpToolDefinition {
|
|
8
12
|
name: string;
|
|
9
13
|
title: string;
|
|
10
14
|
description: string;
|
|
11
15
|
inputSchema: Record<string, unknown>;
|
|
12
16
|
outputSchema?: Record<string, unknown>;
|
|
17
|
+
securitySchemes?: McpToolSecurityScheme[];
|
|
13
18
|
annotations: McpToolAnnotations;
|
|
14
19
|
_meta?: Record<string, unknown>;
|
|
15
20
|
}
|
|
@@ -17,7 +22,7 @@ export interface McpToolDefinition {
|
|
|
17
22
|
* Concise server instructions (<512 chars) per OpenAI Plugin MCP Server specification:
|
|
18
23
|
* https://developers.openai.com/plugins/build/mcp-server
|
|
19
24
|
*/
|
|
20
|
-
export declare const MUXO_MCP_SERVER_INSTRUCTIONS = "Muxo governs SaaS actions (
|
|
25
|
+
export declare const MUXO_MCP_SERVER_INSTRUCTIONS = "Muxo governs SaaS actions (Connected Apps: app.*), Instant tools (instant.*), Cloud Infrastructure (resource.*), Workspace Memory recall, and verifiable audit records. Workflow: 1) search_tools & inspect_tool. 2) plan_action to get a plan_*. 3) If authHandoff.required is true, show redirectUrl and call wait_for_connection. 4) Execute via the matching risk tool (execute_read/write/admin/financial/provisioning/destructive). 5) Verify via get_receipt.";
|
|
21
26
|
export declare const MUXO_MCP_TOOLS: McpToolDefinition[];
|
|
22
27
|
/**
|
|
23
28
|
* OpenAI Company Knowledge standard `search` and `fetch` tool definitions
|