@mplp/runtime-minimal 1.0.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 (59) hide show
  1. package/LICENSE.txt +201 -0
  2. package/dist/ael/index.d.ts +41 -0
  3. package/dist/ael/index.js +30 -0
  4. package/dist/index.d.ts +17 -0
  5. package/dist/index.js +33 -0
  6. package/dist/orchestrator/error-recovery.d.ts +12 -0
  7. package/dist/orchestrator/error-recovery.js +18 -0
  8. package/dist/orchestrator/index.d.ts +15 -0
  9. package/dist/orchestrator/index.js +32 -0
  10. package/dist/orchestrator/multi-agent.d.ts +12 -0
  11. package/dist/orchestrator/multi-agent.js +18 -0
  12. package/dist/orchestrator/risk-confirmation.d.ts +12 -0
  13. package/dist/orchestrator/risk-confirmation.js +18 -0
  14. package/dist/orchestrator/single-agent.d.ts +25 -0
  15. package/dist/orchestrator/single-agent.js +116 -0
  16. package/dist/registry/modules-registry.d.ts +25 -0
  17. package/dist/registry/modules-registry.js +40 -0
  18. package/dist/types/runtime-context.d.ts +28 -0
  19. package/dist/types/runtime-context.js +13 -0
  20. package/dist/types/runtime-result.d.ts +22 -0
  21. package/dist/types/runtime-result.js +13 -0
  22. package/dist/vsl/index.d.ts +32 -0
  23. package/dist/vsl/index.js +39 -0
  24. package/package.json +23 -0
  25. package/src/ael/index.d.ts +42 -0
  26. package/src/ael/index.js +31 -0
  27. package/src/ael/index.ts +47 -0
  28. package/src/index.d.ts +18 -0
  29. package/src/index.js +34 -0
  30. package/src/index.ts +18 -0
  31. package/src/orchestrator/error-recovery.d.ts +13 -0
  32. package/src/orchestrator/error-recovery.js +19 -0
  33. package/src/orchestrator/error-recovery.ts +16 -0
  34. package/src/orchestrator/index.d.ts +16 -0
  35. package/src/orchestrator/index.js +33 -0
  36. package/src/orchestrator/index.ts +17 -0
  37. package/src/orchestrator/multi-agent.d.ts +13 -0
  38. package/src/orchestrator/multi-agent.js +19 -0
  39. package/src/orchestrator/multi-agent.ts +16 -0
  40. package/src/orchestrator/risk-confirmation.d.ts +13 -0
  41. package/src/orchestrator/risk-confirmation.js +19 -0
  42. package/src/orchestrator/risk-confirmation.ts +16 -0
  43. package/src/orchestrator/single-agent.d.ts +26 -0
  44. package/src/orchestrator/single-agent.js +117 -0
  45. package/src/orchestrator/single-agent.ts +139 -0
  46. package/src/registry/modules-registry.d.ts +26 -0
  47. package/src/registry/modules-registry.js +41 -0
  48. package/src/registry/modules-registry.ts +67 -0
  49. package/src/types/runtime-context.d.ts +29 -0
  50. package/src/types/runtime-context.js +14 -0
  51. package/src/types/runtime-context.ts +32 -0
  52. package/src/types/runtime-result.d.ts +23 -0
  53. package/src/types/runtime-result.js +14 -0
  54. package/src/types/runtime-result.ts +25 -0
  55. package/src/vsl/index.d.ts +33 -0
  56. package/src/vsl/index.js +40 -0
  57. package/src/vsl/index.ts +48 -0
  58. package/tests/single-agent.runtime.test.ts +131 -0
  59. package/tsconfig.json +23 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ import type { FlowContract, MplpEvent } from "@mplp/coordination";
14
+ import type { SingleAgentFlowOutput } from "@mplp/coordination";
15
+ import type { RuntimeContext } from "../types/runtime-context";
16
+ import type { RuntimeResult } from "../types/runtime-result";
17
+ import type { RuntimeModuleRegistry } from "../registry/modules-registry";
18
+ import type { ValueStateLayer } from "../vsl";
19
+ export interface SingleAgentRunParams {
20
+ flow: FlowContract<SingleAgentFlowOutput>;
21
+ runtimeContext: RuntimeContext;
22
+ modules: RuntimeModuleRegistry;
23
+ vsl: ValueStateLayer;
24
+ emitEvent?: (event: MplpEvent) => void;
25
+ }
26
+ export declare function runSingleAgentFlow(params: SingleAgentRunParams): Promise<RuntimeResult<SingleAgentFlowOutput>>;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.runSingleAgentFlow = runSingleAgentFlow;
16
+ const modules_registry_1 = require("../registry/modules-registry");
17
+ async function runSingleAgentFlow(params) {
18
+ const { flow, runtimeContext, modules, vsl, emitEvent } = params;
19
+ let ctx = { ...runtimeContext };
20
+ const localEmit = (event) => {
21
+ ctx.events.push(event);
22
+ if (emitEvent)
23
+ emitEvent(event);
24
+ };
25
+ try {
26
+ await vsl.saveSnapshot(ctx.ids.runId, ctx);
27
+ for (const step of flow.steps) {
28
+ const handler = (0, modules_registry_1.getModuleHandler)(modules, step.module);
29
+ if (!handler) {
30
+ return {
31
+ success: false,
32
+ context: ctx,
33
+ error: {
34
+ code: "MODULE_NOT_REGISTERED",
35
+ message: `No handler registered for module "${step.module}"`
36
+ }
37
+ };
38
+ }
39
+ localEmit({
40
+ id: `${ctx.ids.runId}:${step.module}:start`,
41
+ kind: "pipeline.stage",
42
+ timestamp: new Date().toISOString(),
43
+ runId: ctx.ids.runId,
44
+ module: step.module,
45
+ payload: {
46
+ stage: step.module,
47
+ status: "started"
48
+ }
49
+ });
50
+ const result = await handler({
51
+ input: step.input,
52
+ ctx: ctx.coordination,
53
+ emitEvent: localEmit
54
+ });
55
+ if (step.module === "context") {
56
+ ctx.coordination.context = result.output.context;
57
+ }
58
+ else if (step.module === "plan") {
59
+ ctx.coordination.plan = result.output.plan;
60
+ }
61
+ else if (step.module === "confirm") {
62
+ ctx.coordination.confirm = result.output.confirm;
63
+ }
64
+ else if (step.module === "trace") {
65
+ ctx.coordination.trace = result.output.trace;
66
+ }
67
+ if (result.events && result.events.length > 0) {
68
+ await vsl.appendEvents(ctx.ids.runId, result.events);
69
+ ctx.events.push(...result.events);
70
+ }
71
+ localEmit({
72
+ id: `${ctx.ids.runId}:${step.module}:completed`,
73
+ kind: "pipeline.stage",
74
+ timestamp: new Date().toISOString(),
75
+ runId: ctx.ids.runId,
76
+ module: step.module,
77
+ payload: {
78
+ stage: step.module,
79
+ status: "completed"
80
+ }
81
+ });
82
+ await vsl.saveSnapshot(ctx.ids.runId, ctx);
83
+ }
84
+ const output = {
85
+ context: ctx.coordination.context,
86
+ plan: ctx.coordination.plan,
87
+ confirm: ctx.coordination.confirm,
88
+ trace: ctx.coordination.trace
89
+ };
90
+ return {
91
+ success: true,
92
+ context: ctx,
93
+ output
94
+ };
95
+ }
96
+ catch (err) {
97
+ localEmit({
98
+ id: `${ctx.ids.runId}:runtime:error`,
99
+ kind: "runtime.error",
100
+ timestamp: new Date().toISOString(),
101
+ runId: ctx.ids.runId,
102
+ payload: {
103
+ code: "RUNTIME_EXCEPTION",
104
+ message: String(err?.message ?? err),
105
+ stack: err?.stack
106
+ }
107
+ });
108
+ return {
109
+ success: false,
110
+ context: ctx,
111
+ error: {
112
+ code: "RUNTIME_EXCEPTION",
113
+ message: String(err?.message ?? err)
114
+ }
115
+ };
116
+ }
117
+ }
@@ -0,0 +1,139 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ import type { FlowContract, MplpEvent } from "@mplp/coordination";
14
+ import type { SingleAgentFlowOutput } from "@mplp/coordination";
15
+ import type { RuntimeContext } from "../types/runtime-context";
16
+ import type { RuntimeResult } from "../types/runtime-result";
17
+ import type { RuntimeModuleRegistry } from "../registry/modules-registry";
18
+ import { getModuleHandler } from "../registry/modules-registry";
19
+ import type { ValueStateLayer } from "../vsl";
20
+ import type { EmitEvent } from "@mplp/coordination";
21
+
22
+ export interface SingleAgentRunParams {
23
+ flow: FlowContract<SingleAgentFlowOutput>;
24
+ runtimeContext: RuntimeContext;
25
+ modules: RuntimeModuleRegistry;
26
+ vsl: ValueStateLayer;
27
+ emitEvent?: (event: MplpEvent) => void;
28
+ }
29
+
30
+ export async function runSingleAgentFlow(
31
+ params: SingleAgentRunParams
32
+ ): Promise<RuntimeResult<SingleAgentFlowOutput>> {
33
+ const { flow, runtimeContext, modules, vsl, emitEvent } = params;
34
+ let ctx = { ...runtimeContext };
35
+
36
+ const localEmit: EmitEvent = (event) => {
37
+ ctx.events.push(event);
38
+ if (emitEvent) emitEvent(event);
39
+ };
40
+
41
+ try {
42
+ await vsl.saveSnapshot(ctx.ids.runId, ctx);
43
+
44
+ for (const step of flow.steps) {
45
+ const handler: any = getModuleHandler(modules, step.module);
46
+ if (!handler) {
47
+ return {
48
+ success: false,
49
+ context: ctx,
50
+ error: {
51
+ code: "MODULE_NOT_REGISTERED",
52
+ message: `No handler registered for module "${step.module}"`
53
+ }
54
+ };
55
+ }
56
+
57
+ localEmit({
58
+ id: `${ctx.ids.runId}:${step.module}:start`,
59
+ kind: "pipeline.stage",
60
+ timestamp: new Date().toISOString(),
61
+ runId: ctx.ids.runId,
62
+ module: step.module,
63
+ payload: {
64
+ stage: step.module,
65
+ status: "started"
66
+ }
67
+ } as any);
68
+
69
+ const result = await handler({
70
+ input: step.input,
71
+ ctx: ctx.coordination,
72
+ emitEvent: localEmit
73
+ });
74
+
75
+ if (step.module === "context") {
76
+ ctx.coordination.context = (result as any).output.context;
77
+ } else if (step.module === "plan") {
78
+ ctx.coordination.plan = (result as any).output.plan;
79
+ } else if (step.module === "confirm") {
80
+ ctx.coordination.confirm = (result as any).output.confirm;
81
+ } else if (step.module === "trace") {
82
+ ctx.coordination.trace = (result as any).output.trace;
83
+ }
84
+
85
+ if (result.events && result.events.length > 0) {
86
+ await vsl.appendEvents(ctx.ids.runId, result.events);
87
+ ctx.events.push(...result.events);
88
+ }
89
+
90
+ localEmit({
91
+ id: `${ctx.ids.runId}:${step.module}:completed`,
92
+ kind: "pipeline.stage",
93
+ timestamp: new Date().toISOString(),
94
+ runId: ctx.ids.runId,
95
+ module: step.module,
96
+ payload: {
97
+ stage: step.module,
98
+ status: "completed"
99
+ }
100
+ } as any);
101
+
102
+ await vsl.saveSnapshot(ctx.ids.runId, ctx);
103
+ }
104
+
105
+ const output: SingleAgentFlowOutput = {
106
+ context: ctx.coordination.context!,
107
+ plan: ctx.coordination.plan!,
108
+ confirm: ctx.coordination.confirm!,
109
+ trace: ctx.coordination.trace!
110
+ };
111
+
112
+ return {
113
+ success: true,
114
+ context: ctx,
115
+ output
116
+ };
117
+ } catch (err: any) {
118
+ localEmit({
119
+ id: `${ctx.ids.runId}:runtime:error`,
120
+ kind: "runtime.error",
121
+ timestamp: new Date().toISOString(),
122
+ runId: ctx.ids.runId,
123
+ payload: {
124
+ code: "RUNTIME_EXCEPTION",
125
+ message: String(err?.message ?? err),
126
+ stack: err?.stack
127
+ }
128
+ } as any);
129
+
130
+ return {
131
+ success: false,
132
+ context: ctx,
133
+ error: {
134
+ code: "RUNTIME_EXCEPTION",
135
+ message: String(err?.message ?? err)
136
+ }
137
+ };
138
+ }
139
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ import type { ContextModuleHandler, PlanModuleHandler, ConfirmModuleHandler, TraceModuleHandler, RoleModuleHandler, ExtensionModuleHandler, DialogModuleHandler, CollabModuleHandler, CoreModuleHandler, NetworkModuleHandler } from "@mplp/coordination";
14
+ export interface RuntimeModuleRegistry {
15
+ context?: ContextModuleHandler;
16
+ plan?: PlanModuleHandler;
17
+ confirm?: ConfirmModuleHandler;
18
+ trace?: TraceModuleHandler;
19
+ role?: RoleModuleHandler;
20
+ extension?: ExtensionModuleHandler;
21
+ dialog?: DialogModuleHandler;
22
+ collab?: CollabModuleHandler;
23
+ core?: CoreModuleHandler;
24
+ network?: NetworkModuleHandler;
25
+ }
26
+ export declare function getModuleHandler(registry: RuntimeModuleRegistry, moduleName: string): unknown;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getModuleHandler = getModuleHandler;
16
+ function getModuleHandler(registry, moduleName) {
17
+ switch (moduleName) {
18
+ case "context":
19
+ return registry.context;
20
+ case "plan":
21
+ return registry.plan;
22
+ case "confirm":
23
+ return registry.confirm;
24
+ case "trace":
25
+ return registry.trace;
26
+ case "role":
27
+ return registry.role;
28
+ case "extension":
29
+ return registry.extension;
30
+ case "dialog":
31
+ return registry.dialog;
32
+ case "collab":
33
+ return registry.collab;
34
+ case "core":
35
+ return registry.core;
36
+ case "network":
37
+ return registry.network;
38
+ default:
39
+ return undefined;
40
+ }
41
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ import type {
14
+ ContextModuleHandler,
15
+ PlanModuleHandler,
16
+ ConfirmModuleHandler,
17
+ TraceModuleHandler,
18
+ RoleModuleHandler,
19
+ ExtensionModuleHandler,
20
+ DialogModuleHandler,
21
+ CollabModuleHandler,
22
+ CoreModuleHandler,
23
+ NetworkModuleHandler
24
+ } from "@mplp/coordination";
25
+
26
+ export interface RuntimeModuleRegistry {
27
+ context?: ContextModuleHandler;
28
+ plan?: PlanModuleHandler;
29
+ confirm?: ConfirmModuleHandler;
30
+ trace?: TraceModuleHandler;
31
+ role?: RoleModuleHandler;
32
+ extension?: ExtensionModuleHandler;
33
+ dialog?: DialogModuleHandler;
34
+ collab?: CollabModuleHandler;
35
+ core?: CoreModuleHandler;
36
+ network?: NetworkModuleHandler;
37
+ }
38
+
39
+ export function getModuleHandler(
40
+ registry: RuntimeModuleRegistry,
41
+ moduleName: string
42
+ ): unknown {
43
+ switch (moduleName) {
44
+ case "context":
45
+ return registry.context;
46
+ case "plan":
47
+ return registry.plan;
48
+ case "confirm":
49
+ return registry.confirm;
50
+ case "trace":
51
+ return registry.trace;
52
+ case "role":
53
+ return registry.role;
54
+ case "extension":
55
+ return registry.extension;
56
+ case "dialog":
57
+ return registry.dialog;
58
+ case "collab":
59
+ return registry.collab;
60
+ case "core":
61
+ return registry.core;
62
+ case "network":
63
+ return registry.network;
64
+ default:
65
+ return undefined;
66
+ }
67
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ import type { CoordinationContext } from "@mplp/coordination";
14
+ import type { MplpEvent } from "@mplp/coordination";
15
+ export interface RuntimeIds {
16
+ runId: string;
17
+ projectId?: string;
18
+ correlationId?: string;
19
+ }
20
+ export interface RuntimeOptions {
21
+ maxRetries?: number;
22
+ snapshotEveryStep?: boolean;
23
+ }
24
+ export interface RuntimeContext {
25
+ ids: RuntimeIds;
26
+ coordination: CoordinationContext;
27
+ events: MplpEvent[];
28
+ options?: RuntimeOptions;
29
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,32 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ import type { CoordinationContext } from "@mplp/coordination";
14
+ import type { MplpEvent } from "@mplp/coordination";
15
+
16
+ export interface RuntimeIds {
17
+ runId: string;
18
+ projectId?: string;
19
+ correlationId?: string;
20
+ }
21
+
22
+ export interface RuntimeOptions {
23
+ maxRetries?: number;
24
+ snapshotEveryStep?: boolean;
25
+ }
26
+
27
+ export interface RuntimeContext {
28
+ ids: RuntimeIds;
29
+ coordination: CoordinationContext;
30
+ events: MplpEvent[];
31
+ options?: RuntimeOptions;
32
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ import type { RuntimeContext } from "./runtime-context";
14
+ export interface RuntimeErrorInfo {
15
+ code: string;
16
+ message: string;
17
+ }
18
+ export interface RuntimeResult<TOutput = unknown> {
19
+ success: boolean;
20
+ output?: TOutput;
21
+ context: RuntimeContext;
22
+ error?: RuntimeErrorInfo;
23
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,25 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ import type { RuntimeContext } from "./runtime-context";
14
+
15
+ export interface RuntimeErrorInfo {
16
+ code: string;
17
+ message: string;
18
+ }
19
+
20
+ export interface RuntimeResult<TOutput = unknown> {
21
+ success: boolean;
22
+ output?: TOutput;
23
+ context: RuntimeContext;
24
+ error?: RuntimeErrorInfo;
25
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ import type { RuntimeContext } from "../types/runtime-context";
14
+ import type { MplpEvent } from "@mplp/coordination";
15
+ export interface ValueStateLayer {
16
+ saveSnapshot(runId: string, context: RuntimeContext): Promise<void>;
17
+ loadSnapshot(runId: string): Promise<RuntimeContext | null>;
18
+ appendEvents(runId: string, events: MplpEvent[]): Promise<void>;
19
+ getEvents(runId: string): Promise<MplpEvent[]>;
20
+ }
21
+ /**
22
+ * InMemoryVSL
23
+ *
24
+ * Simple in-memory implementation for reference and tests.
25
+ */
26
+ export declare class InMemoryVSL implements ValueStateLayer {
27
+ private snapshots;
28
+ private events;
29
+ saveSnapshot(runId: string, context: RuntimeContext): Promise<void>;
30
+ loadSnapshot(runId: string): Promise<RuntimeContext | null>;
31
+ appendEvents(runId: string, newEvents: MplpEvent[]): Promise<void>;
32
+ getEvents(runId: string): Promise<MplpEvent[]>;
33
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.InMemoryVSL = void 0;
16
+ /**
17
+ * InMemoryVSL
18
+ *
19
+ * Simple in-memory implementation for reference and tests.
20
+ */
21
+ class InMemoryVSL {
22
+ constructor() {
23
+ this.snapshots = new Map();
24
+ this.events = new Map();
25
+ }
26
+ async saveSnapshot(runId, context) {
27
+ this.snapshots.set(runId, { ...context });
28
+ }
29
+ async loadSnapshot(runId) {
30
+ return this.snapshots.get(runId) ?? null;
31
+ }
32
+ async appendEvents(runId, newEvents) {
33
+ const existing = this.events.get(runId) ?? [];
34
+ this.events.set(runId, existing.concat(newEvents));
35
+ }
36
+ async getEvents(runId) {
37
+ return this.events.get(runId) ?? [];
38
+ }
39
+ }
40
+ exports.InMemoryVSL = InMemoryVSL;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * MPLP Protocol v1.0.0 — Frozen Specification
3
+ * Freeze Date: 2025-12-03
4
+ * Status: FROZEN (no breaking changes permitted)
5
+ * Governance: MPLP Protocol Governance Committee (MPGC)
6
+ *
7
+ * © 2025 邦士(北京)网络科技有限公司. All rights reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ import type { RuntimeContext } from "../types/runtime-context";
14
+ import type { MplpEvent } from "@mplp/coordination";
15
+
16
+ export interface ValueStateLayer {
17
+ saveSnapshot(runId: string, context: RuntimeContext): Promise<void>;
18
+ loadSnapshot(runId: string): Promise<RuntimeContext | null>;
19
+ appendEvents(runId: string, events: MplpEvent[]): Promise<void>;
20
+ getEvents(runId: string): Promise<MplpEvent[]>;
21
+ }
22
+
23
+ /**
24
+ * InMemoryVSL
25
+ *
26
+ * Simple in-memory implementation for reference and tests.
27
+ */
28
+ export class InMemoryVSL implements ValueStateLayer {
29
+ private snapshots = new Map<string, RuntimeContext>();
30
+ private events = new Map<string, MplpEvent[]>();
31
+
32
+ async saveSnapshot(runId: string, context: RuntimeContext): Promise<void> {
33
+ this.snapshots.set(runId, { ...context });
34
+ }
35
+
36
+ async loadSnapshot(runId: string): Promise<RuntimeContext | null> {
37
+ return this.snapshots.get(runId) ?? null;
38
+ }
39
+
40
+ async appendEvents(runId: string, newEvents: MplpEvent[]): Promise<void> {
41
+ const existing = this.events.get(runId) ?? [];
42
+ this.events.set(runId, existing.concat(newEvents));
43
+ }
44
+
45
+ async getEvents(runId: string): Promise<MplpEvent[]> {
46
+ return this.events.get(runId) ?? [];
47
+ }
48
+ }