@praxis-ai/praxis 0.1.1 → 0.1.2

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 (48) hide show
  1. package/dist/agentCore/index.d.ts +45 -6
  2. package/dist/agentCore/index.js +14 -2
  3. package/dist/applicationLayer/applicationContract.d.ts +2 -0
  4. package/dist/applicationLayer/applicationRuntime.d.ts +6 -1
  5. package/dist/applicationLayer/applicationRuntime.js +37 -3
  6. package/dist/applicationLayer/index.d.ts +1 -0
  7. package/dist/basetool/core/shellRun.js +6 -1
  8. package/dist/rax_packageManager/raxCli.js +42 -1
  9. package/dist/runtimeImplementation/praxisRuntimeKernel.d.ts +6 -0
  10. package/dist/runtimeImplementation/praxisRuntimeKernel.js +165 -14
  11. package/dist/runtimeImplementation/runtime.componentPlane/runtimeComponentRegistry.d.ts +1 -1
  12. package/dist/runtimeImplementation/runtime.componentPlane/runtimeComponentRegistry.js +2 -2
  13. package/dist/runtimeImplementation/runtime.dependencyPlane/dependencySourceRegistry.d.ts +1 -1
  14. package/dist/runtimeImplementation/runtime.dependencyPlane/dependencySourceRegistry.js +12 -0
  15. package/dist/runtimeImplementation/runtime.dependencyPlane/dependencyTypes.js +2 -0
  16. package/dist/runtimeImplementation/runtime.execEngine/baseToolExecutorPortFactory.d.ts +3 -0
  17. package/dist/runtimeImplementation/runtime.execEngine/baseToolExecutorPortFactory.js +45 -7
  18. package/dist/runtimeImplementation/runtime.execEngine/mcpRuntimeAdapter.js +56 -0
  19. package/dist/runtimeImplementation/runtime.mcpPlane/index.d.ts +114 -0
  20. package/dist/runtimeImplementation/runtime.mcpPlane/index.js +167 -0
  21. package/dist/runtimeImplementation/runtime.sandboxPlane/baseToolSandboxPlanner.js +0 -2
  22. package/dist/runtimeImplementation/runtime.sandboxPlane/raxcellSandboxProvider.d.ts +19 -0
  23. package/dist/runtimeImplementation/runtime.sandboxPlane/raxcellSandboxProvider.js +172 -0
  24. package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxCommandRunner.d.ts +13 -1
  25. package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxCommandRunner.js +230 -186
  26. package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxPolicyMiddleware.d.ts +175 -0
  27. package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxPolicyMiddleware.js +142 -0
  28. package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxRuntimeProvider.d.ts +9 -0
  29. package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxRuntimeProvider.js +115 -205
  30. package/dist/runtimeImplementation/runtimeAgentManifest.js +7 -3
  31. package/package.json +3 -1
  32. package/raxode-tui/dist/raxode-cli/backend/agents/codingAgent/agent.js +3 -3
  33. package/raxode-tui/dist/raxode-cli/backend/application/backendModuleInventory.js +3 -3
  34. package/raxode-tui/dist/raxode-cli/backend/application/localReadinessProbe.d.ts +1 -0
  35. package/raxode-tui/dist/raxode-cli/backend/application/localReadinessProbe.js +50 -4
  36. package/raxode-tui/dist/raxode-cli/backend/application/raxcellSandboxProvider.d.ts +12 -0
  37. package/raxode-tui/dist/raxode-cli/backend/application/raxcellSandboxProvider.js +58 -0
  38. package/raxode-tui/dist/raxode-cli/backend/application/runtimeReadiness.d.ts +1 -0
  39. package/raxode-tui/dist/raxode-cli/backend/application/runtimeReadiness.js +3 -1
  40. package/raxode-tui/dist/raxode-cli/backend/application/stdioApplicationServer.d.ts +2 -0
  41. package/raxode-tui/dist/raxode-cli/backend/application/stdioApplicationServer.js +7 -0
  42. package/raxode-tui/dist/raxode-cli/backend/directApplicationBackend.d.ts +2 -0
  43. package/raxode-tui/dist/raxode-cli/backend/directApplicationBackend.js +21 -1
  44. package/raxode-tui/dist/raxode-cli/backend/raxodeBackend.d.ts +1 -1
  45. package/raxode-tui/dist/raxode-cli/backend/raxodeBackend.js +8 -0
  46. package/raxode-tui/dist/raxode-cli/frontend/tui/cli/raxode-cli.js +19 -1
  47. package/raxode-tui/package.json +2 -1
  48. package/tsconfig.json +16 -1
@@ -0,0 +1,167 @@
1
+ /*
2
+ * 文件定位:Runtime MCP Plane / 官方 MCP 与 MCP+ 组件接入面。
3
+ * 核心目的:把标准 MCP server 声明、MCP+ exposure policy、runtime server profile、
4
+ * dynamic harness tools 和 application view 串成一条 OAO 可编译、可检查、可挂载的合同。
5
+ */
6
+ import { compileMcpPlusManifest, lowerExposurePlanToMcpSurface, planExposure, } from "@praxis-ai/mcp-plus";
7
+ export function mcpServer(serverId, input) {
8
+ return {
9
+ ...input,
10
+ serverId,
11
+ mode: input.mode ?? (input.manifest === undefined ? "native" : "mcp-plus"),
12
+ };
13
+ }
14
+ export const mcp = {
15
+ module(input) {
16
+ return {
17
+ kind: "praxis.mcp.module",
18
+ version: "praxis.mcp.v1",
19
+ servers: input.servers,
20
+ recommended: true,
21
+ metadata: input.metadata,
22
+ };
23
+ },
24
+ stdio(serverId, input) {
25
+ return mcpServer(serverId, { ...input, transport: "stdio" });
26
+ },
27
+ http(serverId, input) {
28
+ return mcpServer(serverId, { ...input, transport: "http" });
29
+ },
30
+ sse(serverId, input) {
31
+ return mcpServer(serverId, { ...input, transport: "sse" });
32
+ },
33
+ recommendedTools() {
34
+ return [
35
+ {
36
+ toolId: "mcp.use",
37
+ metadata: { source: "praxis.mcp.recommendedTools", toolProviderKind: "mcp-static" },
38
+ },
39
+ {
40
+ toolId: "mcp.resources",
41
+ metadata: { source: "praxis.mcp.recommendedTools", toolProviderKind: "mcp-static" },
42
+ },
43
+ ];
44
+ },
45
+ };
46
+ export function isMcpHarnessModuleSpec(value) {
47
+ if (typeof value !== "object" || value === null || Array.isArray(value))
48
+ return false;
49
+ const record = value;
50
+ return record.kind === "praxis.mcp.module" && Array.isArray(record.servers);
51
+ }
52
+ export function mcpHarnessModuleFrom(input) {
53
+ const candidate = input.modules?.mcp;
54
+ return isMcpHarnessModuleSpec(candidate) ? candidate : undefined;
55
+ }
56
+ export function runtimeRequirementsForMcpModule(module) {
57
+ return module === undefined || module.servers.length === 0 ? [] : ["runtime.mcp"];
58
+ }
59
+ export function toMcpRuntimeServerProfile(server) {
60
+ if (server.transport === "stdio") {
61
+ return {
62
+ serverId: server.serverId,
63
+ transport: "stdio",
64
+ command: server.command,
65
+ args: server.args,
66
+ cwd: server.cwd,
67
+ env: server.env,
68
+ timeoutMs: server.timeoutMs,
69
+ framing: server.framing,
70
+ };
71
+ }
72
+ return {
73
+ serverId: server.serverId,
74
+ transport: server.transport,
75
+ url: server.url,
76
+ sseUrl: server.sseUrl,
77
+ headers: server.headers,
78
+ timeoutMs: server.timeoutMs,
79
+ };
80
+ }
81
+ export function buildMcpServerProfilesFromManifest(input) {
82
+ const module = mcpHarnessModuleFrom(input.harness);
83
+ return (module?.servers ?? []).map(toMcpRuntimeServerProfile);
84
+ }
85
+ export function createMcpApplicationStateView(module) {
86
+ return {
87
+ servers: (module?.servers ?? []).map((server) => ({
88
+ serverId: server.serverId,
89
+ mode: server.mode,
90
+ transport: server.transport,
91
+ title: server.title ?? server.manifest?.server.title,
92
+ summary: server.summary ?? server.manifest?.server.summary,
93
+ manifestPresent: server.manifest !== undefined,
94
+ status: "declared",
95
+ publicSafe: true,
96
+ })),
97
+ recommendedMode: "mcp-plus",
98
+ nativeCompatible: true,
99
+ publicSafe: true,
100
+ };
101
+ }
102
+ function toolIdPart(value) {
103
+ return value.replace(/[^a-zA-Z0-9_-]+/gu, ".").replace(/^\.+|\.+$/gu, "") || "tool";
104
+ }
105
+ function dynamicToolSpecForNativeTool(serverId, tool) {
106
+ return {
107
+ toolId: `mcp.${toolIdPart(serverId)}.${toolIdPart(tool.name)}`,
108
+ family: "mcp",
109
+ group: serverId,
110
+ description: tool.description,
111
+ inputSchema: tool.inputSchema,
112
+ metadata: {
113
+ toolProviderKind: "mcp-static",
114
+ serverId,
115
+ nativeToolName: tool.name,
116
+ runtimeToolId: "mcp.use",
117
+ runtimeArguments: { serverId, toolName: tool.name },
118
+ source: "runtime.mcpPlane.dynamicTool",
119
+ },
120
+ };
121
+ }
122
+ function dynamicToolSpecsForSurface(serverId, surface) {
123
+ return surface.tools
124
+ .filter((tool) => tool.name !== "mcp_plus.expand")
125
+ .map((tool) => dynamicToolSpecForNativeTool(serverId, tool));
126
+ }
127
+ export function planMcpHarnessExposure(manifest, nativeToolInventoryByServerId, stateByServerId = {}) {
128
+ const module = mcpHarnessModuleFrom(manifest.harness);
129
+ const servers = (module?.servers ?? []).map((server) => {
130
+ const nativeTools = [...(nativeToolInventoryByServerId[server.serverId] ?? [])];
131
+ if (server.mode !== "mcp-plus" || server.manifest === undefined) {
132
+ const surface = {
133
+ tools: nativeTools,
134
+ sidecar: {
135
+ serverCard: {
136
+ id: server.serverId,
137
+ title: server.title ?? server.serverId,
138
+ summary: server.summary ?? "Native MCP server.",
139
+ mode: "expanded",
140
+ },
141
+ toolIndex: [],
142
+ skillIndex: [],
143
+ },
144
+ };
145
+ return {
146
+ serverId: server.serverId,
147
+ mode: "native",
148
+ surface,
149
+ dynamicToolSpecs: nativeTools.map((tool) => dynamicToolSpecForNativeTool(server.serverId, tool)),
150
+ };
151
+ }
152
+ const graph = compileMcpPlusManifest(server.manifest, nativeTools);
153
+ const state = {
154
+ serverId: server.serverId,
155
+ mode: stateByServerId[server.serverId]?.mode ?? "expanded",
156
+ activeTools: stateByServerId[server.serverId]?.activeTools ?? [],
157
+ };
158
+ const surface = lowerExposurePlanToMcpSurface(planExposure(graph, state));
159
+ return {
160
+ serverId: server.serverId,
161
+ mode: "mcp-plus",
162
+ surface,
163
+ dynamicToolSpecs: dynamicToolSpecsForSurface(server.serverId, surface),
164
+ };
165
+ });
166
+ return { servers };
167
+ }
@@ -4,8 +4,6 @@
4
4
  * 边界:只规划沙箱强度和降级,不真正执行工具或回滚。
5
5
  */
6
6
  function requestedModeFor(profile) {
7
- if (profile === "bapr")
8
- return "none";
9
7
  if (profile === "yolo")
10
8
  return "workspace-rollback";
11
9
  return "isolated";
@@ -0,0 +1,19 @@
1
+ import { RaxcellClient } from "@praxis-ai/raxcell";
2
+ import type { RunRequest } from "@praxis-ai/raxcell";
3
+ import type { SandboxExecutionProviderPort, SandboxProviderRunRequest } from "./sandboxPolicyMiddleware.js";
4
+ export type RaxcellClientLike = Pick<RaxcellClient, "prepareRun" | "run">;
5
+ export type RaxcellSandboxProviderOptions = {
6
+ client: RaxcellClientLike;
7
+ providerId?: string;
8
+ } | {
9
+ binaryPath: string;
10
+ providerId?: string;
11
+ };
12
+ export declare const raxcellSandboxProviderDescriptor: {
13
+ readonly surface: "runtime.sandboxPlane.raxcellSandboxProvider";
14
+ readonly providerFamily: "linux-bubblewrap";
15
+ readonly policyOwner: "praxis";
16
+ readonly role: "environment-and-execution";
17
+ };
18
+ export declare function mapSandboxProviderRequestToRaxcell(request: SandboxProviderRunRequest): RunRequest;
19
+ export declare function createRaxcellSandboxProvider(options: RaxcellSandboxProviderOptions): SandboxExecutionProviderPort;
@@ -0,0 +1,172 @@
1
+ /*
2
+ * 文件定位:Agent 运行态实现层 / Raxcell 官方沙箱 provider。
3
+ * 核心目的:把 Praxis sandbox provider-neutral request 映射到 Raxcell prepareRun/run 协议。
4
+ * 边界:Raxcell 只提供环境事实与执行;策略、审批、fallback 决策仍归 Praxis middleware。
5
+ */
6
+ import { RaxcellClient } from "@praxis-ai/raxcell";
7
+ export const raxcellSandboxProviderDescriptor = {
8
+ surface: "runtime.sandboxPlane.raxcellSandboxProvider",
9
+ providerFamily: "linux-bubblewrap",
10
+ policyOwner: "praxis",
11
+ role: "environment-and-execution",
12
+ };
13
+ function clientFromOptions(options) {
14
+ if ("client" in options)
15
+ return options.client;
16
+ return new RaxcellClient({ binaryPath: options.binaryPath });
17
+ }
18
+ function cleanEnv(env) {
19
+ const output = {};
20
+ for (const [key, value] of Object.entries(env)) {
21
+ if (value !== undefined)
22
+ output[key] = value;
23
+ }
24
+ return output;
25
+ }
26
+ function networkForRaxcell(value) {
27
+ if (value === "allow" || value === "deny")
28
+ return value;
29
+ return "deny";
30
+ }
31
+ function grantForRaxcell(grant) {
32
+ return {
33
+ reason: grant.reason,
34
+ path: grant.path,
35
+ access: grant.access === undefined ? undefined : [...grant.access],
36
+ grantedBy: grant.grantedBy ?? null,
37
+ };
38
+ }
39
+ export function mapSandboxProviderRequestToRaxcell(request) {
40
+ return {
41
+ kind: "raxcell.run.v1",
42
+ backendPreference: ["linux-bubblewrap"],
43
+ policyGrants: request.policyGrants.map(grantForRaxcell),
44
+ action: {
45
+ actionId: request.action.actionId,
46
+ ownerRuntime: request.action.ownerRuntime,
47
+ intentLabel: request.action.intentLabel,
48
+ metadata: {
49
+ runtimeId: request.action.runtimeId,
50
+ sessionId: request.action.sessionId,
51
+ toolId: request.action.toolId,
52
+ policyProfile: request.policy.profile,
53
+ sandboxId: request.policy.sandboxId,
54
+ sandboxMode: request.policy.sandboxMode,
55
+ ...request.action.metadata,
56
+ ...request.metadata,
57
+ },
58
+ },
59
+ command: {
60
+ argv: [...request.command.argv],
61
+ cwd: request.command.cwd,
62
+ env: cleanEnv(request.command.env),
63
+ stdin: request.command.stdin,
64
+ },
65
+ enforcement: {
66
+ profile: request.policy.profile,
67
+ filesystem: {
68
+ read: [...request.filesystem.read],
69
+ write: [...request.filesystem.write],
70
+ },
71
+ network: networkForRaxcell(request.policy.network),
72
+ process: request.policy.process,
73
+ resources: request.policy.resources,
74
+ },
75
+ fallback: request.fallback,
76
+ };
77
+ }
78
+ function providerFamily(value) {
79
+ if (value === "linux-bubblewrap")
80
+ return "linux-bubblewrap";
81
+ if (value === "host-observed")
82
+ return "host-observed";
83
+ if (value === "external")
84
+ return "external";
85
+ return "external";
86
+ }
87
+ function denial(value) {
88
+ if (value === null || value === undefined)
89
+ return null;
90
+ return {
91
+ code: value.code,
92
+ message: value.message,
93
+ publicSafe: true,
94
+ };
95
+ }
96
+ function environmentGap(value) {
97
+ if (value === null || value === undefined)
98
+ return null;
99
+ return {
100
+ reason: value.reason,
101
+ path: value.path ?? "",
102
+ required: value.required,
103
+ publicSafeMessage: value.publicSafeMessage,
104
+ };
105
+ }
106
+ function filesystemLowering(value) {
107
+ if (value === null || value === undefined)
108
+ return null;
109
+ return {
110
+ declaredRoots: value.declaredRoots,
111
+ runtimeRoots: value.runtimeRoots,
112
+ policyGrants: value.policyGrants,
113
+ warnings: value.warnings,
114
+ effects: value.effects,
115
+ };
116
+ }
117
+ function backendArtifacts(value) {
118
+ return value.map((artifact) => ({
119
+ backend: providerFamily(artifact.backend),
120
+ format: artifact.format,
121
+ arguments: artifact.arguments,
122
+ data: artifact.data,
123
+ warnings: artifact.warnings,
124
+ }));
125
+ }
126
+ function prepareResult(value) {
127
+ return {
128
+ kind: "runtime.sandboxPlane.provider.prepareRunResult",
129
+ ok: value.ok,
130
+ providerFamily: providerFamily(value.backend),
131
+ denial: denial(value.denial),
132
+ environmentGap: environmentGap(value.environmentGap ?? value.policyDecision),
133
+ filesystemLowering: filesystemLowering(value.filesystemLowering),
134
+ backendArtifacts: backendArtifacts(value.backendArtifacts),
135
+ metadata: {
136
+ raxcellKind: value.kind,
137
+ capabilityReport: value.capabilityReport,
138
+ },
139
+ };
140
+ }
141
+ function runResult(value) {
142
+ return {
143
+ kind: "runtime.sandboxPlane.provider.runResult",
144
+ ok: value.ok,
145
+ providerFamily: providerFamily(value.backend),
146
+ exitCode: value.exitCode,
147
+ stdout: value.stdout,
148
+ stderr: value.stderr,
149
+ timedOut: value.timedOut,
150
+ denial: denial(value.denial),
151
+ environmentGap: environmentGap(value.environmentGap ?? value.policyDecision),
152
+ filesystemLowering: filesystemLowering(value.filesystemLowering),
153
+ metadata: {
154
+ raxcellKind: value.kind,
155
+ fallback: value.fallback,
156
+ capabilityReport: value.capabilityReport,
157
+ },
158
+ };
159
+ }
160
+ export function createRaxcellSandboxProvider(options) {
161
+ const client = clientFromOptions(options);
162
+ return {
163
+ providerId: options.providerId ?? "raxcell",
164
+ providerFamily: "linux-bubblewrap",
165
+ async prepareRun(request) {
166
+ return prepareResult(await client.prepareRun(mapSandboxProviderRequestToRaxcell(request)));
167
+ },
168
+ async run(request) {
169
+ return runResult(await client.run(mapSandboxProviderRequestToRaxcell(request)));
170
+ },
171
+ };
172
+ }
@@ -1,5 +1,6 @@
1
1
  import type { BaseToolPolicyProfile, SandboxSpec } from "../runtimeAgentManifest.js";
2
- import type { SandboxRuntimePrepareResult } from "./sandboxRuntimeProvider.js";
2
+ import { type SandboxRuntimePrepareResult } from "./sandboxRuntimeProvider.js";
3
+ import { type SandboxExecutionProviderPort, type SandboxPolicyMiddlewareAuditEvent, type SandboxPolicyMiddlewareEnvironmentGapDecision, type SandboxProviderEnvironmentGap, type SandboxProviderPolicyGrant, type SandboxProviderRunRequest } from "./sandboxPolicyMiddleware.js";
3
4
  import { type WorkspaceRollbackFinalizeResult, type WorkspaceRollbackSnapshot } from "./workspaceRollbackSandbox.js";
4
5
  export type SandboxCommandProviderFamily = "host-observed" | "workspace-policy" | "workspace-rollback" | "linux-bubblewrap" | "macos-containerization" | "windows-sandbox" | "remote-worker";
5
6
  export type SandboxCommandNetworkPolicy = "deny" | "allow" | "approval" | "provider-policy";
@@ -28,6 +29,11 @@ export type SandboxCommandRequest = {
28
29
  sandboxMode?: "none" | "workspace-rollback" | "isolated";
29
30
  filesystem?: Partial<SandboxCommandFilesystemPolicy>;
30
31
  network?: SandboxCommandNetworkPolicy;
32
+ policyGrants?: readonly SandboxProviderPolicyGrant[];
33
+ approval?: {
34
+ accepted: boolean;
35
+ grantedBy?: string;
36
+ };
31
37
  metadata?: Readonly<Record<string, unknown>>;
32
38
  };
33
39
  export type SandboxCommandPlan = {
@@ -95,6 +101,12 @@ export type SandboxRemoteWorkerAdapter = (request: SandboxCommandRequest, plan:
95
101
  }>;
96
102
  export type SandboxCommandRunnerOptions = {
97
103
  remoteWorker?: SandboxRemoteWorkerAdapter;
104
+ sandboxProvider?: SandboxExecutionProviderPort;
105
+ decideEnvironmentGap?: (context: {
106
+ request: SandboxProviderRunRequest;
107
+ environmentGap: SandboxProviderEnvironmentGap;
108
+ }) => Promise<SandboxPolicyMiddlewareEnvironmentGapDecision> | SandboxPolicyMiddlewareEnvironmentGapDecision;
109
+ audit?: (event: SandboxPolicyMiddlewareAuditEvent) => Promise<void> | void;
98
110
  };
99
111
  export declare const sandboxCommandRunnerDescriptor: {
100
112
  readonly surface: "runtime.sandboxPlane.sandboxCommandRunner";