@mplp/sdk-ts 1.0.1 → 1.0.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +29 -0
  3. package/dist/builders/confirm-builder.d.ts +4 -8
  4. package/dist/builders/confirm-builder.js +6 -10
  5. package/dist/builders/context-builder.d.ts +4 -8
  6. package/dist/builders/context-builder.js +6 -10
  7. package/dist/builders/plan-builder.d.ts +4 -8
  8. package/dist/builders/plan-builder.js +6 -10
  9. package/dist/builders/trace-builder.d.ts +4 -8
  10. package/dist/builders/trace-builder.js +6 -10
  11. package/dist/client/runtime-client.d.ts +4 -8
  12. package/dist/client/runtime-client.js +6 -10
  13. package/dist/coordination/index.d.ts +8 -0
  14. package/dist/coordination/index.js +11 -0
  15. package/dist/core/index.d.ts +28 -0
  16. package/dist/core/index.js +21 -0
  17. package/dist/core/validators/index.d.ts +12 -0
  18. package/dist/core/validators/index.js +22 -0
  19. package/dist/index.d.ts +4 -8
  20. package/dist/index.js +7 -11
  21. package/dist/runtime/index.d.ts +11 -0
  22. package/dist/runtime/index.js +14 -0
  23. package/dist/runtime-minimal/index.d.ts +52 -0
  24. package/dist/runtime-minimal/index.js +28 -0
  25. package/dist/types/index.d.ts +21 -0
  26. package/dist/types/index.js +2 -0
  27. package/package.json +55 -14
  28. package/schemas/common/common-types.schema.json +55 -0
  29. package/schemas/common/events.schema.json +72 -0
  30. package/schemas/common/identifiers.schema.json +19 -0
  31. package/schemas/common/learning-sample.schema.json +200 -0
  32. package/schemas/common/metadata.schema.json +119 -0
  33. package/schemas/common/trace-base.schema.json +49 -0
  34. package/schemas/events/mplp-event-core.schema.json +64 -0
  35. package/schemas/events/mplp-graph-update-event.schema.json +64 -0
  36. package/schemas/events/mplp-map-event.schema.json +153 -0
  37. package/schemas/events/mplp-pipeline-stage-event.schema.json +62 -0
  38. package/schemas/events/mplp-runtime-execution-event.schema.json +64 -0
  39. package/schemas/events/mplp-sa-event.schema.json +115 -0
  40. package/schemas/integration/mplp-ci-event.schema.json +136 -0
  41. package/schemas/integration/mplp-file-update-event.schema.json +76 -0
  42. package/schemas/integration/mplp-git-event.schema.json +104 -0
  43. package/schemas/integration/mplp-tool-event.schema.json +89 -0
  44. package/schemas/invariants/integration-invariants.yaml +147 -0
  45. package/schemas/invariants/learning-invariants.yaml +106 -0
  46. package/schemas/invariants/map-invariants.yaml +73 -0
  47. package/schemas/invariants/observability-invariants.yaml +106 -0
  48. package/schemas/invariants/sa-invariants.yaml +72 -0
  49. package/schemas/learning/mplp-learning-sample-core.schema.json +100 -0
  50. package/schemas/learning/mplp-learning-sample-delta.schema.json +143 -0
  51. package/schemas/learning/mplp-learning-sample-intent.schema.json +125 -0
  52. package/schemas/mplp-collab.schema.json +249 -0
  53. package/schemas/mplp-confirm.schema.json +232 -0
  54. package/schemas/mplp-context.schema.json +252 -0
  55. package/schemas/mplp-core.schema.json +189 -0
  56. package/schemas/mplp-dialog.schema.json +204 -0
  57. package/schemas/mplp-extension.schema.json +185 -0
  58. package/schemas/mplp-network.schema.json +236 -0
  59. package/schemas/mplp-plan.schema.json +199 -0
  60. package/schemas/mplp-role.schema.json +145 -0
  61. package/schemas/mplp-trace.schema.json +222 -0
  62. package/src/builders/confirm-builder.ts +0 -44
  63. package/src/builders/context-builder.ts +0 -56
  64. package/src/builders/plan-builder.ts +0 -56
  65. package/src/builders/trace-builder.ts +0 -55
  66. package/src/client/runtime-client.ts +0 -103
  67. package/src/index.ts +0 -18
  68. package/tests/builders.test.ts +0 -80
  69. package/tests/client-single-agent.test.ts +0 -48
  70. package/tsconfig.json +0 -23
@@ -1,56 +0,0 @@
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 { Plan, Context, validatePlan } from "@mplp/core";
14
- import { v4 as uuidv4 } from "uuid";
15
-
16
- export interface CreatePlanOptions {
17
- title: string;
18
- objective: string;
19
- steps: Array<{
20
- description: string;
21
- toolName?: string;
22
- parameters?: Record<string, any>;
23
- }>;
24
- }
25
-
26
- export function createPlan(context: Context, options: CreatePlanOptions): Plan {
27
- const plan: Plan = {
28
- meta: {
29
- protocol_version: "1.0.0",
30
- schema_version: "1.0.0",
31
- created_at: new Date().toISOString()
32
- },
33
- plan_id: uuidv4(),
34
- context_id: context.context_id,
35
- title: options.title,
36
- objective: options.objective,
37
- status: "draft",
38
- steps: options.steps.map(step => ({
39
- step_id: uuidv4(),
40
- description: step.description,
41
- status: "pending",
42
- // Optional fields if supported by schema, but keeping it minimal for now
43
- // toolName and parameters might need to go into specific step structure if schema supports it
44
- // checking schema... PlanStepCore has step_id, description, status.
45
- // If we want tool info, it might be in description or we need to check if schema allows extra props or specific step types.
46
- // For now, let's stick to core fields.
47
- }))
48
- };
49
-
50
- const validation = validatePlan(plan);
51
- if (!validation.ok) {
52
- throw new Error(`Invalid Plan generated: ${JSON.stringify(validation.errors)}`);
53
- }
54
-
55
- return plan;
56
- }
@@ -1,55 +0,0 @@
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 { Trace, Context, Plan, validateTrace } from "@mplp/core";
14
- import { v4 as uuidv4 } from "uuid";
15
-
16
- export interface AppendTraceOptions {
17
- status: "completed" | "failed" | "running";
18
- spans?: Array<{
19
- name: string;
20
- status: "completed" | "failed";
21
- }>;
22
- }
23
-
24
- export function appendTrace(context: Context, plan: Plan, options: AppendTraceOptions): Trace {
25
- const traceId = uuidv4();
26
- const rootSpanId = uuidv4();
27
-
28
- const trace: Trace = {
29
- meta: {
30
- protocol_version: "1.0.0",
31
- schema_version: "1.0.0",
32
- created_at: new Date().toISOString()
33
- },
34
- trace_id: traceId,
35
- context_id: context.context_id,
36
- plan_id: plan.plan_id,
37
- status: options.status,
38
- root_span: {
39
- trace_id: traceId,
40
- span_id: rootSpanId,
41
- context_id: context.context_id
42
- }
43
- };
44
-
45
- // Note: The current Trace schema is quite minimal.
46
- // If we want to add child spans, we would need a more complex builder that constructs the tree.
47
- // For this basic builder, we just create the root trace object.
48
-
49
- const validation = validateTrace(trace);
50
- if (!validation.ok) {
51
- throw new Error(`Invalid Trace generated: ${JSON.stringify(validation.errors)}`);
52
- }
53
-
54
- return trace;
55
- }
@@ -1,103 +0,0 @@
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 {
14
- RuntimeContext,
15
- runSingleAgentFlow,
16
- RuntimeResult,
17
- InMemoryAEL,
18
- InMemoryVSL,
19
- RuntimeModuleRegistry,
20
- ValueStateLayer,
21
- ActionExecutionLayer
22
- } from "@mplp/runtime-minimal";
23
- import { SingleAgentFlowContract } from "@mplp/coordination";
24
- import { createContext, CreateContextOptions } from "../builders/context-builder";
25
- import { createPlan, CreatePlanOptions } from "../builders/plan-builder";
26
- import { createConfirm, CreateConfirmOptions } from "../builders/confirm-builder";
27
- import { appendTrace, AppendTraceOptions } from "../builders/trace-builder";
28
- import { v4 as uuidv4 } from "uuid";
29
-
30
- export interface MplpRuntimeClientOptions {
31
- modules?: RuntimeModuleRegistry;
32
- vsl?: ValueStateLayer;
33
- ael?: ActionExecutionLayer;
34
- }
35
-
36
- export interface RunSingleAgentFlowInput {
37
- contextOptions: CreateContextOptions;
38
- planOptions: CreatePlanOptions;
39
- confirmOptions: CreateConfirmOptions;
40
- traceOptions: AppendTraceOptions;
41
- }
42
-
43
- export class MplpRuntimeClient {
44
- private modules: RuntimeModuleRegistry;
45
- private vsl: ValueStateLayer;
46
- private ael: ActionExecutionLayer;
47
-
48
- constructor(options: MplpRuntimeClientOptions = {}) {
49
- this.modules = options.modules || {};
50
- this.vsl = options.vsl || new InMemoryVSL();
51
- this.ael = options.ael || new InMemoryAEL();
52
- }
53
-
54
- async runSingleAgentFlow(input: RunSingleAgentFlowInput): Promise<RuntimeResult> {
55
- const runId = uuidv4();
56
-
57
- // Default handlers that use the builders and provided options
58
- const defaultModules: RuntimeModuleRegistry = {
59
- context: async () => {
60
- const context = createContext(input.contextOptions);
61
- return { output: { context }, events: [] };
62
- },
63
- plan: async ({ ctx }) => {
64
- if (!ctx.context) throw new Error("Context missing in coordination state");
65
- const plan = createPlan(ctx.context, input.planOptions);
66
- return { output: { plan }, events: [] };
67
- },
68
- confirm: async ({ ctx }) => {
69
- if (!ctx.plan) throw new Error("Plan missing in coordination state");
70
- const confirm = createConfirm(ctx.plan, input.confirmOptions);
71
- return { output: { confirm }, events: [] };
72
- },
73
- trace: async ({ ctx }) => {
74
- if (!ctx.context || !ctx.plan) throw new Error("Context or Plan missing in coordination state");
75
- const trace = appendTrace(ctx.context, ctx.plan, input.traceOptions);
76
- return { output: { trace }, events: [] };
77
- }
78
- };
79
-
80
- // Merge modules: User provided modules override defaults
81
- // This allows partial overriding (e.g. use default context/plan, but custom confirm)
82
- const modules: RuntimeModuleRegistry = {
83
- ...defaultModules,
84
- ...this.modules
85
- };
86
-
87
- const runtimeContext: RuntimeContext = {
88
- ids: { runId },
89
- coordination: {
90
- ids: { runId },
91
- metadata: {}
92
- },
93
- events: []
94
- };
95
-
96
- return await runSingleAgentFlow({
97
- flow: SingleAgentFlowContract,
98
- runtimeContext,
99
- modules,
100
- vsl: this.vsl
101
- });
102
- }
103
- }
package/src/index.ts DELETED
@@ -1,18 +0,0 @@
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
- export * from "@mplp/core";
14
- export * from "./builders/context-builder";
15
- export * from "./builders/plan-builder";
16
- export * from "./builders/confirm-builder";
17
- export * from "./builders/trace-builder";
18
- export * from "./client/runtime-client";
@@ -1,80 +0,0 @@
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 { describe, it, expect } from 'vitest';
14
- import { createContext } from '../src/builders/context-builder';
15
- import { createPlan } from '../src/builders/plan-builder';
16
- import { createConfirm } from '../src/builders/confirm-builder';
17
- import { appendTrace } from '../src/builders/trace-builder';
18
-
19
- describe('SDK Builders', () => {
20
- it('should build a valid Context', () => {
21
- const context = createContext({
22
- title: 'Test Context',
23
- root: { domain: 'test', environment: 'dev' }
24
- });
25
- expect(context.context_id).toBeDefined();
26
- expect(context.title).toBe('Test Context');
27
- expect(context.status).toBe('active');
28
- });
29
-
30
- it('should build a valid Plan', () => {
31
- const context = createContext({
32
- title: 'Test Context',
33
- root: { domain: 'test', environment: 'dev' }
34
- });
35
- const plan = createPlan(context, {
36
- title: 'Test Plan',
37
- objective: 'Test Objective',
38
- steps: [{ description: 'Step 1' }]
39
- });
40
- expect(plan.plan_id).toBeDefined();
41
- expect(plan.context_id).toBe(context.context_id);
42
- expect(plan.steps).toHaveLength(1);
43
- });
44
-
45
- it('should build a valid Confirm', () => {
46
- const context = createContext({
47
- title: 'Test Context',
48
- root: { domain: 'test', environment: 'dev' }
49
- });
50
- const plan = createPlan(context, {
51
- title: 'Test Plan',
52
- objective: 'Test Objective',
53
- steps: [{ description: 'Step 1' }]
54
- });
55
- const confirm = createConfirm(plan, {
56
- status: 'approved'
57
- });
58
- expect(confirm.confirm_id).toBeDefined();
59
- expect(confirm.target_id).toBe(plan.plan_id);
60
- expect(confirm.status).toBe('approved');
61
- });
62
-
63
- it('should build a valid Trace', () => {
64
- const context = createContext({
65
- title: 'Test Context',
66
- root: { domain: 'test', environment: 'dev' }
67
- });
68
- const plan = createPlan(context, {
69
- title: 'Test Plan',
70
- objective: 'Test Objective',
71
- steps: [{ description: 'Step 1' }]
72
- });
73
- const trace = appendTrace(context, plan, {
74
- status: 'completed'
75
- });
76
- expect(trace.trace_id).toBeDefined();
77
- expect(trace.context_id).toBe(context.context_id);
78
- expect(trace.status).toBe('completed');
79
- });
80
- });
@@ -1,48 +0,0 @@
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 { describe, it, expect } from 'vitest';
14
- import { MplpRuntimeClient } from '../src/client/runtime-client';
15
- import { SingleAgentFlowOutput } from '@mplp/coordination';
16
-
17
- describe('MplpRuntimeClient', () => {
18
- it('should run a single agent flow with default builders', async () => {
19
- const client = new MplpRuntimeClient();
20
-
21
- const result = await client.runSingleAgentFlow({
22
- contextOptions: {
23
- title: 'Integration Test',
24
- root: { domain: 'test', environment: 'ci' }
25
- },
26
- planOptions: {
27
- title: 'Test Plan',
28
- objective: 'Verify Client',
29
- steps: [{ description: 'Do something' }]
30
- },
31
- confirmOptions: {
32
- status: 'approved'
33
- },
34
- traceOptions: {
35
- status: 'completed'
36
- }
37
- });
38
-
39
- expect(result.success).toBe(true);
40
- if (result.success) {
41
- const output = result.output as SingleAgentFlowOutput;
42
- expect(output.context.title).toBe('Integration Test');
43
- expect(output.plan.title).toBe('Test Plan');
44
- expect(output.confirm.status).toBe('approved');
45
- expect(output.trace.status).toBe('completed');
46
- }
47
- });
48
- });
package/tsconfig.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "$comment": "MPLP Protocol v1.0.0 — Frozen Specification\nFreeze Date: 2025-12-03\nStatus: FROZEN (no breaking changes permitted)\nGovernance: MPLP Protocol Governance Committee (MPGC)\nCopyright: © 2025 邦士(北京)网络科技有限公司\nLicense: Apache-2.0\nAny normative change requires a new protocol version.",
3
- "compilerOptions": {
4
- "target": "ES2020",
5
- "module": "commonjs",
6
- "lib": [
7
- "ES2020"
8
- ],
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "resolveJsonModule": true,
14
- "declaration": true,
15
- "moduleResolution": "node",
16
- "downlevelIteration": true,
17
- "outDir": "dist",
18
- "rootDir": "src"
19
- },
20
- "include": [
21
- "src"
22
- ]
23
- }