@praxis-ai/praxis 0.1.1 → 0.1.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/dist/agentCore/index.d.ts +45 -6
- package/dist/agentCore/index.js +14 -2
- package/dist/applicationLayer/applicationContract.d.ts +2 -0
- package/dist/applicationLayer/applicationRuntime.d.ts +13 -1
- package/dist/applicationLayer/applicationRuntime.js +39 -3
- package/dist/applicationLayer/index.d.ts +2 -0
- package/dist/applicationLayer/index.js +1 -0
- package/dist/basetool/core/shellRun.js +6 -1
- package/dist/rax_packageManager/raxCli.js +42 -1
- package/dist/runtimeImplementation/praxisRuntimeKernel.d.ts +13 -0
- package/dist/runtimeImplementation/praxisRuntimeKernel.js +550 -15
- package/dist/runtimeImplementation/runtime.componentPlane/runtimeComponentRegistry.d.ts +1 -1
- package/dist/runtimeImplementation/runtime.componentPlane/runtimeComponentRegistry.js +2 -2
- package/dist/runtimeImplementation/runtime.dependencyPlane/dependencySourceRegistry.d.ts +1 -1
- package/dist/runtimeImplementation/runtime.dependencyPlane/dependencySourceRegistry.js +12 -0
- package/dist/runtimeImplementation/runtime.dependencyPlane/dependencyTypes.js +2 -0
- package/dist/runtimeImplementation/runtime.execEngine/baseToolExecutorPortFactory.d.ts +3 -0
- package/dist/runtimeImplementation/runtime.execEngine/baseToolExecutorPortFactory.js +45 -7
- package/dist/runtimeImplementation/runtime.execEngine/mcpRuntimeAdapter.js +56 -0
- package/dist/runtimeImplementation/runtime.mcpPlane/index.d.ts +225 -0
- package/dist/runtimeImplementation/runtime.mcpPlane/index.js +549 -0
- package/dist/runtimeImplementation/runtime.sandboxPlane/baseToolSandboxPlanner.js +0 -2
- package/dist/runtimeImplementation/runtime.sandboxPlane/raxcellSandboxProvider.d.ts +19 -0
- package/dist/runtimeImplementation/runtime.sandboxPlane/raxcellSandboxProvider.js +172 -0
- package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxCommandRunner.d.ts +13 -1
- package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxCommandRunner.js +230 -186
- package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxPolicyMiddleware.d.ts +175 -0
- package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxPolicyMiddleware.js +142 -0
- package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxRuntimeProvider.d.ts +9 -0
- package/dist/runtimeImplementation/runtime.sandboxPlane/sandboxRuntimeProvider.js +115 -205
- package/dist/runtimeImplementation/runtimeAgentManifest.js +7 -3
- package/package.json +3 -1
- package/raxode-tui/dist/raxode-cli/backend/agents/codingAgent/agent.js +3 -3
- package/raxode-tui/dist/raxode-cli/backend/application/backendModuleInventory.js +3 -3
- package/raxode-tui/dist/raxode-cli/backend/application/localReadinessProbe.d.ts +1 -0
- package/raxode-tui/dist/raxode-cli/backend/application/localReadinessProbe.js +50 -4
- package/raxode-tui/dist/raxode-cli/backend/application/raxcellSandboxProvider.d.ts +12 -0
- package/raxode-tui/dist/raxode-cli/backend/application/raxcellSandboxProvider.js +58 -0
- package/raxode-tui/dist/raxode-cli/backend/application/runtimeReadiness.d.ts +1 -0
- package/raxode-tui/dist/raxode-cli/backend/application/runtimeReadiness.js +3 -1
- package/raxode-tui/dist/raxode-cli/backend/application/stdioApplicationServer.d.ts +2 -0
- package/raxode-tui/dist/raxode-cli/backend/application/stdioApplicationServer.js +7 -0
- package/raxode-tui/dist/raxode-cli/backend/directApplicationBackend.d.ts +2 -0
- package/raxode-tui/dist/raxode-cli/backend/directApplicationBackend.js +21 -1
- package/raxode-tui/dist/raxode-cli/backend/raxodeBackend.d.ts +1 -1
- package/raxode-tui/dist/raxode-cli/backend/raxodeBackend.js +8 -0
- package/raxode-tui/dist/raxode-cli/frontend/tui/cli/raxode-cli.js +19 -1
- package/raxode-tui/package.json +2 -1
- package/tsconfig.json +16 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { BaseToolPolicyProfile } from "../runtimeAgentManifest.js";
|
|
2
|
+
import type { SandboxCommandNetworkPolicy } from "./sandboxCommandRunner.js";
|
|
3
|
+
export type SandboxProviderFamily = "host-observed" | "workspace-policy" | "workspace-rollback" | "linux-bubblewrap" | "macos-containerization" | "windows-sandbox" | "remote-worker" | "external";
|
|
4
|
+
export type SandboxProviderPolicyGrant = {
|
|
5
|
+
reason: string;
|
|
6
|
+
path: string;
|
|
7
|
+
access?: readonly string[];
|
|
8
|
+
grantedBy?: string | null;
|
|
9
|
+
};
|
|
10
|
+
export type SandboxProviderFilesystemLoweredRoot = {
|
|
11
|
+
path: string;
|
|
12
|
+
access: "read" | "write" | "runtime" | "scratch" | "runtime-link";
|
|
13
|
+
source: "declared" | "backend-runtime" | "policy-grant";
|
|
14
|
+
};
|
|
15
|
+
export type SandboxProviderFilesystemLoweringReport = {
|
|
16
|
+
declaredRoots: readonly SandboxProviderFilesystemLoweredRoot[];
|
|
17
|
+
runtimeRoots: readonly SandboxProviderFilesystemLoweredRoot[];
|
|
18
|
+
policyGrants: readonly SandboxProviderPolicyGrant[];
|
|
19
|
+
warnings: readonly {
|
|
20
|
+
code: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}[];
|
|
23
|
+
effects?: readonly {
|
|
24
|
+
path?: string;
|
|
25
|
+
pattern?: string;
|
|
26
|
+
rawToken: string;
|
|
27
|
+
access: "read" | "write" | "readwrite";
|
|
28
|
+
command: string;
|
|
29
|
+
reason: string;
|
|
30
|
+
confidence: "high" | "medium" | "low";
|
|
31
|
+
warning?: string;
|
|
32
|
+
}[];
|
|
33
|
+
};
|
|
34
|
+
export type SandboxProviderBackendArtifact = {
|
|
35
|
+
backend: SandboxProviderFamily;
|
|
36
|
+
format: string;
|
|
37
|
+
arguments: readonly string[];
|
|
38
|
+
data: Readonly<Record<string, unknown>>;
|
|
39
|
+
warnings: readonly {
|
|
40
|
+
code: string;
|
|
41
|
+
message: string;
|
|
42
|
+
}[];
|
|
43
|
+
};
|
|
44
|
+
export type SandboxProviderEnvironmentGap = {
|
|
45
|
+
reason: string;
|
|
46
|
+
path: string;
|
|
47
|
+
required?: readonly string[];
|
|
48
|
+
publicSafeMessage: string;
|
|
49
|
+
};
|
|
50
|
+
export type SandboxProviderDenial = {
|
|
51
|
+
code: string;
|
|
52
|
+
message: string;
|
|
53
|
+
publicSafe: true;
|
|
54
|
+
};
|
|
55
|
+
export type SandboxProviderRunRequest = {
|
|
56
|
+
kind: "runtime.sandboxPlane.provider.runRequest";
|
|
57
|
+
action: {
|
|
58
|
+
actionId: string;
|
|
59
|
+
runtimeId: string;
|
|
60
|
+
sessionId: string;
|
|
61
|
+
toolId: string;
|
|
62
|
+
ownerRuntime: "praxis" | string;
|
|
63
|
+
intentLabel: string;
|
|
64
|
+
metadata: Readonly<Record<string, unknown>>;
|
|
65
|
+
};
|
|
66
|
+
command: {
|
|
67
|
+
argv: readonly string[];
|
|
68
|
+
cwd: string;
|
|
69
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
70
|
+
stdin: string | null;
|
|
71
|
+
};
|
|
72
|
+
policy: {
|
|
73
|
+
profile: BaseToolPolicyProfile;
|
|
74
|
+
sandboxId: string;
|
|
75
|
+
sandboxMode: "none" | "workspace-rollback" | "isolated";
|
|
76
|
+
network: SandboxCommandNetworkPolicy;
|
|
77
|
+
process: Readonly<Record<string, unknown>>;
|
|
78
|
+
resources: Readonly<Record<string, unknown>>;
|
|
79
|
+
};
|
|
80
|
+
filesystem: {
|
|
81
|
+
workspaceRoot: string;
|
|
82
|
+
read: readonly string[];
|
|
83
|
+
write: readonly string[];
|
|
84
|
+
readonlyRoot: boolean;
|
|
85
|
+
protectSecrets: boolean;
|
|
86
|
+
};
|
|
87
|
+
policyGrants: readonly SandboxProviderPolicyGrant[];
|
|
88
|
+
fallback: {
|
|
89
|
+
mode: string;
|
|
90
|
+
};
|
|
91
|
+
metadata: Readonly<Record<string, unknown>>;
|
|
92
|
+
};
|
|
93
|
+
export type SandboxProviderPrepareRunResult = {
|
|
94
|
+
kind: "runtime.sandboxPlane.provider.prepareRunResult";
|
|
95
|
+
ok: boolean;
|
|
96
|
+
providerFamily: SandboxProviderFamily;
|
|
97
|
+
denial?: SandboxProviderDenial | null;
|
|
98
|
+
environmentGap?: SandboxProviderEnvironmentGap | null;
|
|
99
|
+
filesystemLowering?: SandboxProviderFilesystemLoweringReport | null;
|
|
100
|
+
backendArtifacts: readonly SandboxProviderBackendArtifact[];
|
|
101
|
+
metadata: Readonly<Record<string, unknown>>;
|
|
102
|
+
};
|
|
103
|
+
export type SandboxProviderRunResult = {
|
|
104
|
+
kind: "runtime.sandboxPlane.provider.runResult";
|
|
105
|
+
ok: boolean;
|
|
106
|
+
providerFamily: SandboxProviderFamily;
|
|
107
|
+
exitCode: number | null;
|
|
108
|
+
stdout: string;
|
|
109
|
+
stderr: string;
|
|
110
|
+
timedOut: boolean;
|
|
111
|
+
denial?: SandboxProviderDenial | null;
|
|
112
|
+
environmentGap?: SandboxProviderEnvironmentGap | null;
|
|
113
|
+
filesystemLowering?: SandboxProviderFilesystemLoweringReport | null;
|
|
114
|
+
metadata: Readonly<Record<string, unknown>>;
|
|
115
|
+
};
|
|
116
|
+
export type SandboxExecutionProviderPort = {
|
|
117
|
+
providerId: string;
|
|
118
|
+
providerFamily: SandboxProviderFamily;
|
|
119
|
+
prepareRun(request: SandboxProviderRunRequest): Promise<SandboxProviderPrepareRunResult>;
|
|
120
|
+
run(request: SandboxProviderRunRequest): Promise<SandboxProviderRunResult>;
|
|
121
|
+
};
|
|
122
|
+
export type SandboxPolicyMiddlewareEnvironmentGapDecision = {
|
|
123
|
+
type: "grant";
|
|
124
|
+
grants: readonly SandboxProviderPolicyGrant[];
|
|
125
|
+
} | {
|
|
126
|
+
type: "rewrite";
|
|
127
|
+
request: SandboxProviderRunRequest;
|
|
128
|
+
reason: string;
|
|
129
|
+
} | {
|
|
130
|
+
type: "deny";
|
|
131
|
+
reason: string;
|
|
132
|
+
};
|
|
133
|
+
export type SandboxPolicyMiddlewareResult = {
|
|
134
|
+
ok: true;
|
|
135
|
+
request: SandboxProviderRunRequest;
|
|
136
|
+
prepared: SandboxProviderPrepareRunResult;
|
|
137
|
+
result: SandboxProviderRunResult;
|
|
138
|
+
events: readonly string[];
|
|
139
|
+
} | {
|
|
140
|
+
ok: false;
|
|
141
|
+
request: SandboxProviderRunRequest;
|
|
142
|
+
prepared?: SandboxProviderPrepareRunResult;
|
|
143
|
+
error: {
|
|
144
|
+
code: "SANDBOX_PREPARE_FAILED" | "SANDBOX_DENIED" | "SANDBOX_RUN_FAILED";
|
|
145
|
+
message: string;
|
|
146
|
+
publicSafe: true;
|
|
147
|
+
denial?: SandboxProviderDenial | null;
|
|
148
|
+
};
|
|
149
|
+
events: readonly string[];
|
|
150
|
+
};
|
|
151
|
+
export type SandboxPolicyMiddlewareAuditEvent = {
|
|
152
|
+
type: string;
|
|
153
|
+
actionId: string;
|
|
154
|
+
sessionId: string;
|
|
155
|
+
toolId: string;
|
|
156
|
+
providerId: string;
|
|
157
|
+
providerFamily: SandboxProviderFamily;
|
|
158
|
+
payload: Readonly<Record<string, unknown>>;
|
|
159
|
+
};
|
|
160
|
+
export declare const sandboxPolicyMiddlewareDescriptor: {
|
|
161
|
+
readonly surface: "runtime.sandboxPlane.sandboxPolicyMiddleware";
|
|
162
|
+
readonly policyOwner: "praxis";
|
|
163
|
+
readonly providerRole: "environment-and-execution";
|
|
164
|
+
readonly publicSafe: true;
|
|
165
|
+
};
|
|
166
|
+
export declare function runSandboxPolicyMiddleware(input: {
|
|
167
|
+
provider: SandboxExecutionProviderPort;
|
|
168
|
+
request: SandboxProviderRunRequest;
|
|
169
|
+
decideEnvironmentGap?: (context: {
|
|
170
|
+
request: SandboxProviderRunRequest;
|
|
171
|
+
prepared: SandboxProviderPrepareRunResult;
|
|
172
|
+
environmentGap: SandboxProviderEnvironmentGap;
|
|
173
|
+
}) => Promise<SandboxPolicyMiddlewareEnvironmentGapDecision> | SandboxPolicyMiddlewareEnvironmentGapDecision;
|
|
174
|
+
audit?: (event: SandboxPolicyMiddlewareAuditEvent) => Promise<void> | void;
|
|
175
|
+
}): Promise<SandboxPolicyMiddlewareResult>;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 文件定位:Agent 运行态实现层 / 沙箱策略中间件。
|
|
3
|
+
* 核心目的:把 Praxis policy/governance/approval 的结果翻译给可插拔沙箱 provider。
|
|
4
|
+
* 边界:本文件不替代 policy matrix,不实现沙箱 backend;provider 只报告环境事实并执行。
|
|
5
|
+
*/
|
|
6
|
+
export const sandboxPolicyMiddlewareDescriptor = {
|
|
7
|
+
surface: "runtime.sandboxPlane.sandboxPolicyMiddleware",
|
|
8
|
+
policyOwner: "praxis",
|
|
9
|
+
providerRole: "environment-and-execution",
|
|
10
|
+
publicSafe: true,
|
|
11
|
+
};
|
|
12
|
+
function appendGrant(request, grants) {
|
|
13
|
+
return {
|
|
14
|
+
...request,
|
|
15
|
+
policyGrants: [...request.policyGrants, ...grants],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function prepareFailureMessage(prepared) {
|
|
19
|
+
return prepared.environmentGap?.publicSafeMessage
|
|
20
|
+
?? prepared.denial?.message
|
|
21
|
+
?? "sandbox provider prepareRun failed";
|
|
22
|
+
}
|
|
23
|
+
async function audit(input) {
|
|
24
|
+
await input.audit?.({
|
|
25
|
+
type: input.type,
|
|
26
|
+
actionId: input.request.action.actionId,
|
|
27
|
+
sessionId: input.request.action.sessionId,
|
|
28
|
+
toolId: input.request.action.toolId,
|
|
29
|
+
providerId: input.provider.providerId,
|
|
30
|
+
providerFamily: input.provider.providerFamily,
|
|
31
|
+
payload: input.payload,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export async function runSandboxPolicyMiddleware(input) {
|
|
35
|
+
let request = input.request;
|
|
36
|
+
const events = [];
|
|
37
|
+
let prepared = await input.provider.prepareRun(request);
|
|
38
|
+
events.push("runtime.sandbox.middleware.prepareRun");
|
|
39
|
+
await audit({
|
|
40
|
+
...input,
|
|
41
|
+
request,
|
|
42
|
+
type: "runtime.sandbox.middleware.prepareRun",
|
|
43
|
+
payload: {
|
|
44
|
+
ok: prepared.ok,
|
|
45
|
+
environmentGap: prepared.environmentGap ?? null,
|
|
46
|
+
denial: prepared.denial ?? null,
|
|
47
|
+
filesystemLowering: prepared.filesystemLowering ?? null,
|
|
48
|
+
backendArtifacts: prepared.backendArtifacts,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
if (!prepared.ok && prepared.environmentGap !== undefined && prepared.environmentGap !== null) {
|
|
52
|
+
const decision = await input.decideEnvironmentGap?.({
|
|
53
|
+
request,
|
|
54
|
+
prepared,
|
|
55
|
+
environmentGap: prepared.environmentGap,
|
|
56
|
+
}) ?? { type: "deny", reason: prepared.environmentGap.publicSafeMessage };
|
|
57
|
+
events.push(`runtime.sandbox.middleware.policyApplied.${decision.type}`);
|
|
58
|
+
await audit({
|
|
59
|
+
...input,
|
|
60
|
+
request,
|
|
61
|
+
type: "runtime.sandbox.middleware.policyApplied",
|
|
62
|
+
payload: {
|
|
63
|
+
decision: decision.type,
|
|
64
|
+
reason: "reason" in decision ? decision.reason : undefined,
|
|
65
|
+
grants: "grants" in decision ? decision.grants : undefined,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
if (decision.type === "deny") {
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
request,
|
|
72
|
+
prepared,
|
|
73
|
+
error: {
|
|
74
|
+
code: "SANDBOX_DENIED",
|
|
75
|
+
message: decision.reason,
|
|
76
|
+
publicSafe: true,
|
|
77
|
+
denial: prepared.denial,
|
|
78
|
+
},
|
|
79
|
+
events,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
request = decision.type === "grant" ? appendGrant(request, decision.grants) : decision.request;
|
|
83
|
+
prepared = await input.provider.prepareRun(request);
|
|
84
|
+
events.push("runtime.sandbox.middleware.prepareRun.afterPolicy");
|
|
85
|
+
await audit({
|
|
86
|
+
...input,
|
|
87
|
+
request,
|
|
88
|
+
type: "runtime.sandbox.middleware.prepareRun.afterPolicy",
|
|
89
|
+
payload: {
|
|
90
|
+
ok: prepared.ok,
|
|
91
|
+
environmentGap: prepared.environmentGap ?? null,
|
|
92
|
+
denial: prepared.denial ?? null,
|
|
93
|
+
filesystemLowering: prepared.filesystemLowering ?? null,
|
|
94
|
+
backendArtifacts: prepared.backendArtifacts,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (!prepared.ok) {
|
|
99
|
+
return {
|
|
100
|
+
ok: false,
|
|
101
|
+
request,
|
|
102
|
+
prepared,
|
|
103
|
+
error: {
|
|
104
|
+
code: "SANDBOX_PREPARE_FAILED",
|
|
105
|
+
message: prepareFailureMessage(prepared),
|
|
106
|
+
publicSafe: true,
|
|
107
|
+
denial: prepared.denial,
|
|
108
|
+
},
|
|
109
|
+
events,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const result = await input.provider.run(request);
|
|
113
|
+
events.push("runtime.sandbox.provider.run");
|
|
114
|
+
await audit({
|
|
115
|
+
...input,
|
|
116
|
+
request,
|
|
117
|
+
type: "runtime.sandbox.provider.run",
|
|
118
|
+
payload: {
|
|
119
|
+
ok: result.ok,
|
|
120
|
+
exitCode: result.exitCode,
|
|
121
|
+
timedOut: result.timedOut,
|
|
122
|
+
denial: result.denial ?? null,
|
|
123
|
+
environmentGap: result.environmentGap ?? null,
|
|
124
|
+
filesystemLowering: result.filesystemLowering ?? null,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
if (!result.ok) {
|
|
128
|
+
return {
|
|
129
|
+
ok: false,
|
|
130
|
+
request,
|
|
131
|
+
prepared,
|
|
132
|
+
error: {
|
|
133
|
+
code: "SANDBOX_RUN_FAILED",
|
|
134
|
+
message: result.denial?.message ?? "sandbox provider run failed",
|
|
135
|
+
publicSafe: true,
|
|
136
|
+
denial: result.denial,
|
|
137
|
+
},
|
|
138
|
+
events,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return { ok: true, request, prepared, result, events };
|
|
142
|
+
}
|
|
@@ -74,6 +74,7 @@ export type SandboxRuntimeProvider = {
|
|
|
74
74
|
prepare(spec: SandboxSpec, input?: {
|
|
75
75
|
cwd?: string;
|
|
76
76
|
runSmoke?: boolean;
|
|
77
|
+
providerReady?: boolean;
|
|
77
78
|
}): Promise<SandboxRuntimePrepareResult>;
|
|
78
79
|
runSmoke(spec: SandboxSpec, input?: {
|
|
79
80
|
cwd?: string;
|
|
@@ -87,8 +88,16 @@ export declare const sandboxRuntimeProviderDescriptor: {
|
|
|
87
88
|
readonly linuxLiveProvider: "linux-bubblewrap";
|
|
88
89
|
readonly unsafeSideEffects: false;
|
|
89
90
|
};
|
|
91
|
+
export declare function resolveRaxcellBinaryPath(input?: {
|
|
92
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
93
|
+
pathEnv?: string;
|
|
94
|
+
platform?: NodeJS.Platform;
|
|
95
|
+
fileExists?: (filePath: string) => boolean;
|
|
96
|
+
resolvePackage?: (packageName: string) => string | undefined;
|
|
97
|
+
}): string | undefined;
|
|
90
98
|
export declare function createSandboxRuntimeProvider(providerFamily: SandboxProviderFamily): SandboxRuntimeProvider;
|
|
91
99
|
export declare function prepareSandboxRuntime(spec: SandboxSpec, input?: {
|
|
92
100
|
cwd?: string;
|
|
93
101
|
runSmoke?: boolean;
|
|
102
|
+
providerReady?: boolean;
|
|
94
103
|
}): Promise<SandboxRuntimePrepareResult>;
|