@muxoai/platform 1.4.2 → 1.4.3
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 +2 -2
- package/README.md +1 -1
- package/dist/cli.js +88 -0
- package/dist/durable-workflow.d.ts +71 -4
- package/dist/durable-workflow.js +199 -5
- package/dist/engine.d.ts +64 -2
- package/dist/engine.js +147 -6
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/mcp-schema.js +22 -1
- package/dist/mcp.js +62 -3
- package/dist/memory-graph.d.ts +26 -2
- package/dist/memory-graph.js +127 -7
- package/dist/oss-suite.d.ts +217 -0
- package/dist/oss-suite.js +836 -0
- package/dist/sdk.d.ts +24 -1
- package/dist/sdk.js +53 -2
- package/dist/server.js +128 -3
- package/dist/types.d.ts +19 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/plugins/muxo/.claude-plugin/plugin.json +1 -1
- package/plugins/muxo/.codex-plugin/plugin.json +2 -2
- package/plugins/muxo/.cursor-plugin/plugin.json +1 -1
- package/plugins/muxo/plugin.json +2 -2
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"plugins": [
|
|
7
7
|
{
|
|
8
8
|
"name": "muxo",
|
|
9
|
-
"version": "1.4.
|
|
9
|
+
"version": "1.4.3",
|
|
10
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",
|
|
@@ -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.4.
|
|
11
|
+
"version": "1.4.3"
|
|
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.4.
|
|
22
|
+
"version": "1.4.3",
|
|
23
23
|
"category": "Productivity",
|
|
24
24
|
"skills": [
|
|
25
25
|
"./plugins/muxo/skills/muxo",
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Muxo (`@muxoai/platform` / `@muxoai/cli` / `@muxoai/sdk`)
|
|
2
2
|
|
|
3
|
-
Muxo (`v1.4.
|
|
3
|
+
Muxo (`v1.4.3`) is the unified execution, cloud infrastructure provisioning, contextual memory, and cryptographic governance platform for AI agents and applications. Customers and their agents interact exclusively with **Muxo** — either via structured tool slugs or free-form **Natural Language** (`muxo do`, `POST /api/v1/do`, `client.do()`, and MCP `plan_action`).
|
|
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
|
|
package/dist/cli.js
CHANGED
|
@@ -2321,6 +2321,90 @@ async function runCli() {
|
|
|
2321
2321
|
console.log(JSON.stringify(result, null, 2));
|
|
2322
2322
|
return;
|
|
2323
2323
|
}
|
|
2324
|
+
if (cmd === "playbooks" || cmd === "playbook") {
|
|
2325
|
+
const sub = positional[1];
|
|
2326
|
+
if (sub === "run") {
|
|
2327
|
+
const slug = positional[2] ||
|
|
2328
|
+
flags.slug ||
|
|
2329
|
+
"fullstack-cloud-bootstrap";
|
|
2330
|
+
const input = flags.input
|
|
2331
|
+
? JSON.parse(String(flags.input))
|
|
2332
|
+
: {};
|
|
2333
|
+
if (remoteUrl) {
|
|
2334
|
+
const res = await remoteFetch(`/api/v1/playbooks/${encodeURIComponent(slug)}/run`, {
|
|
2335
|
+
method: "POST",
|
|
2336
|
+
body: { input },
|
|
2337
|
+
});
|
|
2338
|
+
console.log(JSON.stringify(res, null, 2));
|
|
2339
|
+
return;
|
|
2340
|
+
}
|
|
2341
|
+
const { engine, ctx } = getLocalContext();
|
|
2342
|
+
const res = engine.runCommercialPlaybook(ctx, { slug, input });
|
|
2343
|
+
console.log(JSON.stringify(res, null, 2));
|
|
2344
|
+
return;
|
|
2345
|
+
}
|
|
2346
|
+
if (remoteUrl) {
|
|
2347
|
+
const res = await remoteFetch("/api/v1/playbooks");
|
|
2348
|
+
console.log(JSON.stringify(res, null, 2));
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
2351
|
+
const { engine } = getLocalContext();
|
|
2352
|
+
const playbooks = engine.listCommercialPlaybooks();
|
|
2353
|
+
console.log(JSON.stringify({ ok: true, count: playbooks.length, playbooks }, null, 2));
|
|
2354
|
+
return;
|
|
2355
|
+
}
|
|
2356
|
+
if (cmd === "roi") {
|
|
2357
|
+
if (remoteUrl) {
|
|
2358
|
+
const res = await remoteFetch("/api/v1/analytics/roi");
|
|
2359
|
+
console.log(JSON.stringify(res, null, 2));
|
|
2360
|
+
return;
|
|
2361
|
+
}
|
|
2362
|
+
const { engine, ctx } = getLocalContext();
|
|
2363
|
+
console.log(JSON.stringify({ ok: true, ...engine.getCommercialRoiReport(ctx) }, null, 2));
|
|
2364
|
+
return;
|
|
2365
|
+
}
|
|
2366
|
+
if (cmd === "cedar") {
|
|
2367
|
+
const sub = positional[1];
|
|
2368
|
+
if (sub === "evaluate" || sub === "eval") {
|
|
2369
|
+
const toolSlug = positional[2] || flags.tool || "instant.web.search";
|
|
2370
|
+
const input = flags.input
|
|
2371
|
+
? JSON.parse(String(flags.input))
|
|
2372
|
+
: {};
|
|
2373
|
+
if (remoteUrl) {
|
|
2374
|
+
const res = await remoteFetch("/api/v1/governance/cedar/evaluate", {
|
|
2375
|
+
method: "POST",
|
|
2376
|
+
body: { toolSlug, input },
|
|
2377
|
+
});
|
|
2378
|
+
console.log(JSON.stringify(res, null, 2));
|
|
2379
|
+
return;
|
|
2380
|
+
}
|
|
2381
|
+
const { engine, ctx } = getLocalContext();
|
|
2382
|
+
console.log(JSON.stringify({
|
|
2383
|
+
ok: true,
|
|
2384
|
+
...engine.evaluatePolicyAsCode(ctx, { toolSlug, input }),
|
|
2385
|
+
}, null, 2));
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2388
|
+
if (remoteUrl) {
|
|
2389
|
+
const res = await remoteFetch("/api/v1/governance/cedar");
|
|
2390
|
+
console.log(JSON.stringify(res, null, 2));
|
|
2391
|
+
return;
|
|
2392
|
+
}
|
|
2393
|
+
const { engine, ctx } = getLocalContext();
|
|
2394
|
+
console.log(JSON.stringify({ ok: true, ...engine.getPolicyAsCodeBundle(ctx) }, null, 2));
|
|
2395
|
+
return;
|
|
2396
|
+
}
|
|
2397
|
+
if (cmd === "telemetry" || cmd === "otel") {
|
|
2398
|
+
const limit = flags.limit ? Number(flags.limit) : 25;
|
|
2399
|
+
if (remoteUrl) {
|
|
2400
|
+
const res = await remoteFetch(`/api/v1/telemetry/otlp?limit=${limit}`);
|
|
2401
|
+
console.log(JSON.stringify(res, null, 2));
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
const { engine, ctx } = getLocalContext();
|
|
2405
|
+
console.log(JSON.stringify({ ok: true, ...engine.exportOtelTraces(ctx, limit) }, null, 2));
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2324
2408
|
console.log(`
|
|
2325
2409
|
Muxo CLI — Unified Agent Execution, Cloud Infrastructure, Memory & Safety Platform
|
|
2326
2410
|
|
|
@@ -2365,6 +2449,10 @@ Core Commands:
|
|
|
2365
2449
|
muxo governance scan <text> Check text for prompt injection before storing or sending it
|
|
2366
2450
|
muxo governance policy [--mode enforce|monitor] [--ring 0-3] [--require-approval write,admin|none]
|
|
2367
2451
|
[--block-destructive-sql true|false] [--max-credits <n>]
|
|
2452
|
+
muxo cedar [evaluate <tool_slug>] Compile or evaluate AWS Cedar 4.x & OPA Rego v1 policy-as-code
|
|
2453
|
+
muxo telemetry [--limit 25] Export OpenTelemetry GenAI / MCP OTLP & Langfuse trace spans
|
|
2454
|
+
muxo playbooks [run <slug>] List or execute Temporal-compatible commercial Saga playbooks
|
|
2455
|
+
muxo roi Compute FinOps unit economics, BYOK savings, and engineering ROI
|
|
2368
2456
|
muxo harness Check API, MCP, auth, governance and catalog; print MCP config
|
|
2369
2457
|
muxo serve [--port 4310] Start unified HTTP Console, Landing, OAuth Callback & MCP server
|
|
2370
2458
|
muxo mcp Run stdio MCP server (19 canonical tools)
|
|
@@ -1,22 +1,54 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Temporal-compatible Durable Workflows, Saga Compensations, Signals, and Cloudflare Workflows primitives,
|
|
3
|
+
* shared by the Node engine (src/engine.ts) and the Cloudflare Edge Worker (worker/index.ts).
|
|
4
|
+
*/
|
|
2
5
|
import { MuxoToolError } from "./mcp-schema.js";
|
|
3
|
-
export type DurableWorkflowStepStatus = "completed" | "waiting" | "pending";
|
|
6
|
+
export type DurableWorkflowStepStatus = "completed" | "waiting" | "pending" | "failed" | "compensated";
|
|
4
7
|
export interface DurableWorkflowStep {
|
|
5
8
|
name: string;
|
|
6
9
|
primitive: "step.do" | "step.waitForEvent" | "step.sleep";
|
|
7
10
|
status: DurableWorkflowStepStatus;
|
|
8
11
|
output?: Record<string, unknown>;
|
|
9
12
|
completedAt?: string;
|
|
13
|
+
compensationAction?: string;
|
|
14
|
+
compensatedAt?: string;
|
|
15
|
+
}
|
|
16
|
+
export type TemporalEventType = "EVENT_TYPE_WORKFLOW_EXECUTION_STARTED" | "EVENT_TYPE_ACTIVITY_TASK_SCHEDULED" | "EVENT_TYPE_ACTIVITY_TASK_COMPLETED" | "EVENT_TYPE_ACTIVITY_TASK_FAILED" | "EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED" | "EVENT_TYPE_TIMER_STARTED" | "EVENT_TYPE_TIMER_FIRED" | "EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED" | "EVENT_TYPE_WORKFLOW_EXECUTION_CANCELED" | "EVENT_TYPE_WORKFLOW_EXECUTION_FAILED";
|
|
17
|
+
export interface TemporalHistoryEvent {
|
|
18
|
+
eventId: number;
|
|
19
|
+
eventTime: string;
|
|
20
|
+
eventType: TemporalEventType;
|
|
21
|
+
taskQueue: string;
|
|
22
|
+
attributes: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface SagaCompensationRecord {
|
|
25
|
+
stepName: string;
|
|
26
|
+
compensationAction: string;
|
|
27
|
+
status: "registered" | "executed" | "skipped";
|
|
28
|
+
description: string;
|
|
29
|
+
output?: Record<string, unknown>;
|
|
30
|
+
executedAt?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface DurableWorkflowSignalRecord {
|
|
33
|
+
signalName: string;
|
|
34
|
+
payload: Record<string, unknown>;
|
|
35
|
+
receivedAt: string;
|
|
10
36
|
}
|
|
11
37
|
export interface DurableWorkflow {
|
|
12
38
|
id: string;
|
|
39
|
+
runId?: string;
|
|
13
40
|
workspaceId: string;
|
|
14
|
-
workflowType: "cloud_provisioning_pipeline" | "approval_handoff_pipeline";
|
|
15
|
-
|
|
41
|
+
workflowType: "cloud_provisioning_pipeline" | "approval_handoff_pipeline" | "commercial_playbook_saga";
|
|
42
|
+
playbookSlug?: string | null;
|
|
43
|
+
status: "running" | "waiting_for_event" | "completed" | "failed" | "rolled_back";
|
|
16
44
|
provider: string;
|
|
17
45
|
serviceRef: string;
|
|
18
46
|
resourceId: string | null;
|
|
19
47
|
steps: DurableWorkflowStep[];
|
|
48
|
+
compensations?: SagaCompensationRecord[];
|
|
49
|
+
signals?: DurableWorkflowSignalRecord[];
|
|
50
|
+
temporalEventHistory?: TemporalHistoryEvent[];
|
|
51
|
+
rollbackReason?: string | null;
|
|
20
52
|
createdAt: string;
|
|
21
53
|
updatedAt: string;
|
|
22
54
|
}
|
|
@@ -43,3 +75,38 @@ export declare function completeCloudProvisioningWorkflow(wf: DurableWorkflow, p
|
|
|
43
75
|
secretKeys: string[];
|
|
44
76
|
triggerEvent?: unknown;
|
|
45
77
|
}): DurableWorkflow;
|
|
78
|
+
/**
|
|
79
|
+
* Executes LIFO Saga Compensations on a DurableWorkflow, rolling back completed steps in reverse order
|
|
80
|
+
* and recording Temporal compensation activity events.
|
|
81
|
+
*/
|
|
82
|
+
export declare function rollbackDurableWorkflow(wf: DurableWorkflow, params?: {
|
|
83
|
+
reason?: string;
|
|
84
|
+
failedStepName?: string;
|
|
85
|
+
failedStep?: string;
|
|
86
|
+
}): DurableWorkflow;
|
|
87
|
+
/**
|
|
88
|
+
* Sends a named Temporal signal to a DurableWorkflow (`human.approval.granted`, `oauth.connection.active`,
|
|
89
|
+
* `saga.abort`, or `v2.provisioning.resource.completed`).
|
|
90
|
+
*/
|
|
91
|
+
export declare function signalDurableWorkflow(wf: DurableWorkflow, params: {
|
|
92
|
+
signalName: string;
|
|
93
|
+
payload?: Record<string, unknown>;
|
|
94
|
+
secretKeys?: string[];
|
|
95
|
+
}): DurableWorkflow;
|
|
96
|
+
/**
|
|
97
|
+
* Exports a DurableWorkflow in Temporal Web UI / `temporal workflow show` compatible EventHistory JSON format.
|
|
98
|
+
*/
|
|
99
|
+
export declare function exportTemporalEventHistory(wf: DurableWorkflow): {
|
|
100
|
+
namespace: string;
|
|
101
|
+
workflowExecution: {
|
|
102
|
+
workflowId: string;
|
|
103
|
+
runId: string;
|
|
104
|
+
};
|
|
105
|
+
workflowType: {
|
|
106
|
+
name: string;
|
|
107
|
+
};
|
|
108
|
+
status: DurableWorkflow["status"];
|
|
109
|
+
eventsCount: number;
|
|
110
|
+
compensationsCount: number;
|
|
111
|
+
events: TemporalHistoryEvent[];
|
|
112
|
+
};
|
package/dist/durable-workflow.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Temporal-compatible Durable Workflows, Saga Compensations, Signals, and Cloudflare Workflows primitives,
|
|
3
|
+
* shared by the Node engine (src/engine.ts) and the Cloudflare Edge Worker (worker/index.ts).
|
|
4
|
+
*/
|
|
2
5
|
import { MuxoToolError } from "./mcp-schema.js";
|
|
3
6
|
export const WORKFLOW_RESOURCE_COMPLETED_EVENT = "v2.provisioning.resource.completed";
|
|
4
7
|
export function workflowNotFoundError(workflowId) {
|
|
@@ -14,12 +17,70 @@ export function normalizeWorkflowTarget(params) {
|
|
|
14
17
|
serviceRef: (params.serviceRef || "postgres").toLowerCase().trim(),
|
|
15
18
|
};
|
|
16
19
|
}
|
|
20
|
+
function appendTemporalEvent(history, eventType, attributes, now = new Date().toISOString()) {
|
|
21
|
+
history.push({
|
|
22
|
+
eventId: history.length + 1,
|
|
23
|
+
eventTime: now,
|
|
24
|
+
eventType,
|
|
25
|
+
taskQueue: "muxo-durable-execution-queue",
|
|
26
|
+
attributes,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
17
29
|
export function createCloudProvisioningWorkflow(params) {
|
|
18
30
|
const now = new Date().toISOString();
|
|
31
|
+
const region = params.region || "aws-us-east-1";
|
|
32
|
+
const apiVersion = params.apiVersion || "2026-09-30.preview";
|
|
33
|
+
const history = [];
|
|
34
|
+
appendTemporalEvent(history, "EVENT_TYPE_WORKFLOW_EXECUTION_STARTED", {
|
|
35
|
+
workflowType: "cloud_provisioning_pipeline",
|
|
36
|
+
workflowId: params.id,
|
|
37
|
+
workspaceId: params.workspaceId,
|
|
38
|
+
provider: params.provider,
|
|
39
|
+
serviceRef: params.serviceRef,
|
|
40
|
+
region,
|
|
41
|
+
}, now);
|
|
42
|
+
appendTemporalEvent(history, "EVENT_TYPE_ACTIVITY_TASK_COMPLETED", {
|
|
43
|
+
activityName: "check_stripe_v2_eligibility",
|
|
44
|
+
result: { status: "eligible", apiVersion },
|
|
45
|
+
}, now);
|
|
46
|
+
appendTemporalEvent(history, "EVENT_TYPE_ACTIVITY_TASK_COMPLETED", {
|
|
47
|
+
activityName: "ensure_payment_profile_and_provider_connection",
|
|
48
|
+
result: { provider: params.provider, paymentProfileStatus: "active" },
|
|
49
|
+
}, now);
|
|
50
|
+
appendTemporalEvent(history, "EVENT_TYPE_ACTIVITY_TASK_COMPLETED", {
|
|
51
|
+
activityName: "create_v2_provisioning_resource",
|
|
52
|
+
result: {
|
|
53
|
+
resourceId: params.resourceId,
|
|
54
|
+
provider: params.provider,
|
|
55
|
+
service_ref: params.serviceRef,
|
|
56
|
+
region,
|
|
57
|
+
},
|
|
58
|
+
compensationAction: `resource.${params.provider}.remove`,
|
|
59
|
+
}, now);
|
|
60
|
+
appendTemporalEvent(history, "EVENT_TYPE_TIMER_STARTED", {
|
|
61
|
+
waitingForSignal: WORKFLOW_RESOURCE_COMPLETED_EVENT,
|
|
62
|
+
resourceId: params.resourceId,
|
|
63
|
+
}, now);
|
|
64
|
+
const compensations = [
|
|
65
|
+
{
|
|
66
|
+
stepName: "ensure_payment_profile_and_provider_connection",
|
|
67
|
+
compensationAction: `provisioning.provider_connection.unlink`,
|
|
68
|
+
status: "registered",
|
|
69
|
+
description: `Unlink provider connection for ${params.provider} if downstream provisioning aborts`,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
stepName: "create_v2_provisioning_resource",
|
|
73
|
+
compensationAction: `resource.${params.provider}.remove`,
|
|
74
|
+
status: "registered",
|
|
75
|
+
description: `Deprovision ${params.provider}/${params.serviceRef} (${params.resourceId}) and release reservation`,
|
|
76
|
+
},
|
|
77
|
+
];
|
|
19
78
|
return {
|
|
20
79
|
id: params.id,
|
|
80
|
+
runId: `run_${params.id}`,
|
|
21
81
|
workspaceId: params.workspaceId,
|
|
22
82
|
workflowType: "cloud_provisioning_pipeline",
|
|
83
|
+
playbookSlug: null,
|
|
23
84
|
status: "waiting_for_event",
|
|
24
85
|
provider: params.provider,
|
|
25
86
|
serviceRef: params.serviceRef,
|
|
@@ -29,7 +90,7 @@ export function createCloudProvisioningWorkflow(params) {
|
|
|
29
90
|
name: "check_stripe_v2_eligibility",
|
|
30
91
|
primitive: "step.do",
|
|
31
92
|
status: "completed",
|
|
32
|
-
output: { status: "eligible", apiVersion
|
|
93
|
+
output: { status: "eligible", apiVersion },
|
|
33
94
|
completedAt: now,
|
|
34
95
|
},
|
|
35
96
|
{
|
|
@@ -38,6 +99,7 @@ export function createCloudProvisioningWorkflow(params) {
|
|
|
38
99
|
status: "completed",
|
|
39
100
|
output: { provider: params.provider, paymentProfileStatus: "active" },
|
|
40
101
|
completedAt: now,
|
|
102
|
+
compensationAction: "provisioning.provider_connection.unlink",
|
|
41
103
|
},
|
|
42
104
|
{
|
|
43
105
|
name: "create_v2_provisioning_resource",
|
|
@@ -47,22 +109,31 @@ export function createCloudProvisioningWorkflow(params) {
|
|
|
47
109
|
resourceId: params.resourceId,
|
|
48
110
|
provider: params.provider,
|
|
49
111
|
service_ref: params.serviceRef,
|
|
50
|
-
region
|
|
112
|
+
region,
|
|
51
113
|
},
|
|
52
114
|
completedAt: now,
|
|
115
|
+
compensationAction: `resource.${params.provider}.remove`,
|
|
53
116
|
},
|
|
54
117
|
{
|
|
55
118
|
name: "wait_for_v2_provisioning_resource_completed",
|
|
56
119
|
primitive: "step.waitForEvent",
|
|
57
120
|
status: "waiting",
|
|
58
|
-
output: {
|
|
121
|
+
output: {
|
|
122
|
+
expectedEvent: WORKFLOW_RESOURCE_COMPLETED_EVENT,
|
|
123
|
+
resourceId: params.resourceId,
|
|
124
|
+
},
|
|
59
125
|
},
|
|
60
126
|
{
|
|
61
127
|
name: "reveal_access_configuration_and_seal_vault",
|
|
62
128
|
primitive: "step.do",
|
|
63
129
|
status: "pending",
|
|
130
|
+
compensationAction: "vault.revoke_secrets",
|
|
64
131
|
},
|
|
65
132
|
],
|
|
133
|
+
compensations,
|
|
134
|
+
signals: [],
|
|
135
|
+
temporalEventHistory: history,
|
|
136
|
+
rollbackReason: null,
|
|
66
137
|
createdAt: now,
|
|
67
138
|
updatedAt: now,
|
|
68
139
|
};
|
|
@@ -70,6 +141,12 @@ export function createCloudProvisioningWorkflow(params) {
|
|
|
70
141
|
/** Completes every outstanding step once the resource-completed event (or a manual advance) arrives. */
|
|
71
142
|
export function completeCloudProvisioningWorkflow(wf, params) {
|
|
72
143
|
const now = new Date().toISOString();
|
|
144
|
+
const history = wf.temporalEventHistory || [];
|
|
145
|
+
const trigger = String(params.triggerEvent || WORKFLOW_RESOURCE_COMPLETED_EVENT);
|
|
146
|
+
appendTemporalEvent(history, "EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED", {
|
|
147
|
+
signalName: trigger,
|
|
148
|
+
resourceId: wf.resourceId,
|
|
149
|
+
}, now);
|
|
73
150
|
for (const step of wf.steps) {
|
|
74
151
|
if (step.status === "completed")
|
|
75
152
|
continue;
|
|
@@ -80,11 +157,128 @@ export function completeCloudProvisioningWorkflow(wf, params) {
|
|
|
80
157
|
vaultEncrypted: true,
|
|
81
158
|
cipher: "AES-256-GCM",
|
|
82
159
|
secretKeys: params.secretKeys,
|
|
83
|
-
triggerEvent:
|
|
160
|
+
triggerEvent: trigger,
|
|
84
161
|
};
|
|
85
162
|
}
|
|
163
|
+
appendTemporalEvent(history, "EVENT_TYPE_ACTIVITY_TASK_COMPLETED", {
|
|
164
|
+
activityName: step.name,
|
|
165
|
+
result: step.output || { status: "completed" },
|
|
166
|
+
}, now);
|
|
86
167
|
}
|
|
168
|
+
appendTemporalEvent(history, "EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED", {
|
|
169
|
+
workflowId: wf.id,
|
|
170
|
+
status: "completed",
|
|
171
|
+
secretKeysSealed: params.secretKeys,
|
|
172
|
+
}, now);
|
|
173
|
+
wf.temporalEventHistory = history;
|
|
87
174
|
wf.status = "completed";
|
|
88
175
|
wf.updatedAt = now;
|
|
89
176
|
return wf;
|
|
90
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Executes LIFO Saga Compensations on a DurableWorkflow, rolling back completed steps in reverse order
|
|
180
|
+
* and recording Temporal compensation activity events.
|
|
181
|
+
*/
|
|
182
|
+
export function rollbackDurableWorkflow(wf, params) {
|
|
183
|
+
const now = new Date().toISOString();
|
|
184
|
+
const failedStepName = params?.failedStepName || params?.failedStep;
|
|
185
|
+
const reason = params?.reason ||
|
|
186
|
+
"Saga rollback requested by operator or downstream step failure";
|
|
187
|
+
const history = wf.temporalEventHistory || [];
|
|
188
|
+
const compensations = wf.compensations || [];
|
|
189
|
+
if (failedStepName) {
|
|
190
|
+
appendTemporalEvent(history, "EVENT_TYPE_ACTIVITY_TASK_FAILED", {
|
|
191
|
+
activityName: failedStepName,
|
|
192
|
+
reason,
|
|
193
|
+
}, now);
|
|
194
|
+
}
|
|
195
|
+
// Execute registered compensations in reverse (LIFO) order
|
|
196
|
+
for (let i = compensations.length - 1; i >= 0; i--) {
|
|
197
|
+
const comp = compensations[i];
|
|
198
|
+
if (comp.status === "executed")
|
|
199
|
+
continue;
|
|
200
|
+
comp.status = "executed";
|
|
201
|
+
comp.executedAt = now;
|
|
202
|
+
comp.output = {
|
|
203
|
+
rolledBack: true,
|
|
204
|
+
action: comp.compensationAction,
|
|
205
|
+
resourceId: wf.resourceId,
|
|
206
|
+
reason,
|
|
207
|
+
};
|
|
208
|
+
appendTemporalEvent(history, "EVENT_TYPE_ACTIVITY_TASK_COMPLETED", {
|
|
209
|
+
activityName: `compensate:${comp.stepName}`,
|
|
210
|
+
compensationAction: comp.compensationAction,
|
|
211
|
+
result: comp.output,
|
|
212
|
+
}, now);
|
|
213
|
+
}
|
|
214
|
+
for (const step of wf.steps) {
|
|
215
|
+
if (step.status === "completed" && step.compensationAction) {
|
|
216
|
+
step.status = "compensated";
|
|
217
|
+
step.compensatedAt = now;
|
|
218
|
+
}
|
|
219
|
+
else if (step.status === "waiting" || step.status === "pending") {
|
|
220
|
+
step.status = "failed";
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
appendTemporalEvent(history, "EVENT_TYPE_WORKFLOW_EXECUTION_CANCELED", {
|
|
224
|
+
workflowId: wf.id,
|
|
225
|
+
status: "rolled_back",
|
|
226
|
+
reason,
|
|
227
|
+
compensatedStepsCount: compensations.filter((c) => c.status === "executed")
|
|
228
|
+
.length,
|
|
229
|
+
}, now);
|
|
230
|
+
wf.compensations = compensations;
|
|
231
|
+
wf.temporalEventHistory = history;
|
|
232
|
+
wf.rollbackReason = reason;
|
|
233
|
+
wf.status = "rolled_back";
|
|
234
|
+
wf.updatedAt = now;
|
|
235
|
+
return wf;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Sends a named Temporal signal to a DurableWorkflow (`human.approval.granted`, `oauth.connection.active`,
|
|
239
|
+
* `saga.abort`, or `v2.provisioning.resource.completed`).
|
|
240
|
+
*/
|
|
241
|
+
export function signalDurableWorkflow(wf, params) {
|
|
242
|
+
const now = new Date().toISOString();
|
|
243
|
+
const signalName = String(params.signalName || WORKFLOW_RESOURCE_COMPLETED_EVENT).trim();
|
|
244
|
+
const payload = params.payload || {};
|
|
245
|
+
wf.signals = wf.signals || [];
|
|
246
|
+
wf.signals.push({
|
|
247
|
+
signalName,
|
|
248
|
+
payload,
|
|
249
|
+
receivedAt: now,
|
|
250
|
+
});
|
|
251
|
+
if (signalName === "saga.abort" ||
|
|
252
|
+
signalName === "human.approval.rejected" ||
|
|
253
|
+
payload.action === "rollback") {
|
|
254
|
+
return rollbackDurableWorkflow(wf, {
|
|
255
|
+
reason: String(payload.reason || `Rolled back via signal ${signalName}`),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
return completeCloudProvisioningWorkflow(wf, {
|
|
259
|
+
secretKeys: params.secretKeys || ["DATABASE_URL"],
|
|
260
|
+
triggerEvent: signalName,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Exports a DurableWorkflow in Temporal Web UI / `temporal workflow show` compatible EventHistory JSON format.
|
|
265
|
+
*/
|
|
266
|
+
export function exportTemporalEventHistory(wf) {
|
|
267
|
+
const events = wf.temporalEventHistory || [];
|
|
268
|
+
return {
|
|
269
|
+
namespace: `muxo.${wf.workspaceId}`,
|
|
270
|
+
workflowExecution: {
|
|
271
|
+
workflowId: wf.id,
|
|
272
|
+
runId: wf.runId || `run_${wf.id}`,
|
|
273
|
+
},
|
|
274
|
+
workflowType: {
|
|
275
|
+
name: wf.playbookSlug
|
|
276
|
+
? `MuxoPlaybookSaga::${wf.playbookSlug}`
|
|
277
|
+
: `MuxoWorkflow::${wf.workflowType}`,
|
|
278
|
+
},
|
|
279
|
+
status: wf.status,
|
|
280
|
+
eventsCount: events.length,
|
|
281
|
+
compensationsCount: (wf.compensations || []).length,
|
|
282
|
+
events,
|
|
283
|
+
};
|
|
284
|
+
}
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MuxoConfig } from "./config.js";
|
|
2
2
|
import { type DurableWorkflow } from "./durable-workflow.js";
|
|
3
|
+
import { type CommercialPlaybookDefinition, type CommercialRoiReport, type CompiledPolicyAsCodeBundle, type OtelTraceExportBundle, type PolicyAsCodeEvaluationResult } from "./oss-suite.js";
|
|
3
4
|
import { type NaturalLanguageResolution } from "./nl.js";
|
|
4
5
|
import { describePolicyInPlainEnglish, type GuardrailCompileOptions, type LlmPolicyAndGovernanceBrief, type ParsedNaturalLanguageGuardrail, type PolicySimulationResult } from "./policy.js";
|
|
5
6
|
import { ComposioInstantAdapter } from "./providers/composio-instant.js";
|
|
@@ -191,9 +192,15 @@ export declare class MuxoEngine {
|
|
|
191
192
|
}>;
|
|
192
193
|
/**
|
|
193
194
|
* Synthesizes a Bi-Temporal Knowledge Graph (entities, active relationships, superseded historical relationships,
|
|
194
|
-
* Mermaid diagram, and human + technical explanations)
|
|
195
|
+
* Mermaid diagram, point-in-time `asOf` time-travel, 2-hop BFS subgraph, and human + technical explanations)
|
|
196
|
+
* directly from SQLite temporal_facts, memories, resources, and connections.
|
|
195
197
|
*/
|
|
196
|
-
getMemoryGraph(ctx: ExecutionContext,
|
|
198
|
+
getMemoryGraph(ctx: ExecutionContext, queryOrOptions?: string | {
|
|
199
|
+
query?: string;
|
|
200
|
+
asOf?: string | null;
|
|
201
|
+
focalEntity?: string | null;
|
|
202
|
+
maxHops?: number;
|
|
203
|
+
}): Promise<MemoryKnowledgeGraph>;
|
|
197
204
|
activateWorkspaceKillSwitch(ctx: ExecutionContext, params: {
|
|
198
205
|
reason: string;
|
|
199
206
|
action?: "terminate" | "quarantine" | "suspend";
|
|
@@ -417,6 +424,61 @@ export declare class MuxoEngine {
|
|
|
417
424
|
}): Promise<DurableWorkflow>;
|
|
418
425
|
advanceDurableWorkflow(ctx: ExecutionContext, workflowId: string, eventPayload?: Record<string, unknown>): Promise<DurableWorkflow>;
|
|
419
426
|
listDurableWorkflows(workspaceId: string): DurableWorkflow[];
|
|
427
|
+
getDurableWorkflow(ctx: ExecutionContext, workflowId: string): DurableWorkflow;
|
|
428
|
+
getDurableWorkflowHistory(ctx: ExecutionContext, workflowId: string): {
|
|
429
|
+
namespace: string;
|
|
430
|
+
workflowExecution: {
|
|
431
|
+
workflowId: string;
|
|
432
|
+
runId: string;
|
|
433
|
+
};
|
|
434
|
+
workflowType: {
|
|
435
|
+
name: string;
|
|
436
|
+
};
|
|
437
|
+
status: DurableWorkflow["status"];
|
|
438
|
+
eventsCount: number;
|
|
439
|
+
compensationsCount: number;
|
|
440
|
+
events: import("./durable-workflow.js").TemporalHistoryEvent[];
|
|
441
|
+
};
|
|
442
|
+
signalDurableWorkflow(ctx: ExecutionContext, workflowId: string, params: {
|
|
443
|
+
signalName: string;
|
|
444
|
+
payload?: Record<string, unknown>;
|
|
445
|
+
}): DurableWorkflow;
|
|
446
|
+
rollbackDurableWorkflow(ctx: ExecutionContext, workflowId: string, params?: {
|
|
447
|
+
reason?: string;
|
|
448
|
+
failedStep?: string;
|
|
449
|
+
}): DurableWorkflow;
|
|
450
|
+
/**
|
|
451
|
+
* AWS Cedar & Open Policy Agent (OPA / Rego) Policy-as-Code Compiler & Evaluator.
|
|
452
|
+
*/
|
|
453
|
+
getPolicyAsCodeBundle(ctx: ExecutionContext): CompiledPolicyAsCodeBundle;
|
|
454
|
+
evaluatePolicyAsCode(ctx: ExecutionContext, params: {
|
|
455
|
+
toolSlug: string;
|
|
456
|
+
input?: Record<string, unknown>;
|
|
457
|
+
riskLevel?: RiskLevel;
|
|
458
|
+
creditCost?: number;
|
|
459
|
+
lane?: string;
|
|
460
|
+
}): Promise<PolicyAsCodeEvaluationResult>;
|
|
461
|
+
/**
|
|
462
|
+
* OpenTelemetry (OTel GenAI / MCP Semantic Conventions) & Langfuse Trace Exporter.
|
|
463
|
+
*/
|
|
464
|
+
exportOtelTraces(ctx: ExecutionContext, limit?: number): OtelTraceExportBundle;
|
|
465
|
+
/**
|
|
466
|
+
* Turnkey Commercial Business Saga Playbooks.
|
|
467
|
+
*/
|
|
468
|
+
listCommercialPlaybooks(): CommercialPlaybookDefinition[];
|
|
469
|
+
runCommercialPlaybook(ctx: ExecutionContext, params: {
|
|
470
|
+
slug: string;
|
|
471
|
+
input?: Record<string, unknown>;
|
|
472
|
+
}): {
|
|
473
|
+
ok: true;
|
|
474
|
+
playbook: CommercialPlaybookDefinition;
|
|
475
|
+
workflow: DurableWorkflow;
|
|
476
|
+
temporalFact: import("./types.js").TemporalGraphFact;
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* FinOps & Commercial ROI Unit-Economics Analytics.
|
|
480
|
+
*/
|
|
481
|
+
getCommercialRoiReport(ctx: ExecutionContext): CommercialRoiReport;
|
|
420
482
|
/**
|
|
421
483
|
* Hybrid Semantic Vector + Bi-Temporal Recall (`@cf/baai/bge-base-en-v1.5` + Vectorize model).
|
|
422
484
|
*/
|