replicas-engine 0.1.889 → 0.1.891
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/src/{asp-host-7TTLBO5M.js → asp-host-RKLHLTPR.js} +4 -4
- package/dist/src/{chunk-WMRZEQIH.js → chunk-4NFLZXZX.js} +2 -2
- package/dist/src/{chunk-RG6ZP2EU.js → chunk-DG4VIQXA.js} +1 -1
- package/dist/src/{chunk-F33TXACU.js → chunk-EDLDRUYW.js} +2 -2
- package/dist/src/{chunk-ISNWC7OA.js → chunk-IB2SHITZ.js} +9 -4
- package/dist/src/{chunk-45I2CJU6.js → chunk-OBAGPETY.js} +56 -0
- package/dist/src/{chunk-N7JSMN3R.js → chunk-TDLEF5FU.js} +5 -5
- package/dist/src/chunk-U2T2QCYP.js +54 -0
- package/dist/src/command-protection-hook.js +3 -3
- package/dist/src/deepseek-command-protection-plugin.js +5 -4
- package/dist/src/headless-agent.js +2 -2
- package/dist/src/index.js +283 -201
- package/dist/src/post-tool-pr-hook.js +4 -3
- package/dist/src/relay-mcp.js +1 -1
- package/package.json +1 -1
- package/scripts/opencode-command-protection-plugin.ts +10 -9
|
@@ -3,11 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
notifyPostToolUse
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IB2SHITZ.js";
|
|
7
|
+
import "./chunk-U2T2QCYP.js";
|
|
7
8
|
import {
|
|
8
9
|
isRecord
|
|
9
10
|
} from "./chunk-UZSNFLDQ.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-OBAGPETY.js";
|
|
11
12
|
import "./chunk-VEQXQN22.js";
|
|
12
13
|
|
|
13
14
|
// src/post-tool-pr-hook.ts
|
|
@@ -19,7 +20,7 @@ async function main() {
|
|
|
19
20
|
const record = isRecord(input) ? input : {};
|
|
20
21
|
const toolName = [record.tool_name, record.tool, record.name].find((value) => typeof value === "string") ?? "";
|
|
21
22
|
const toolInput = record.tool_input ?? record.arguments ?? record.args ?? ("command" in record ? { command: record.command } : record);
|
|
22
|
-
await notifyPostToolUse(toolName, toolInput);
|
|
23
|
+
await notifyPostToolUse(toolName, toolInput, process.argv[2] === "opencode" ? { output: record.output, success: record.success === true } : void 0);
|
|
23
24
|
} catch (error) {
|
|
24
25
|
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
25
26
|
`);
|
package/dist/src/relay-mcp.js
CHANGED
package/package.json
CHANGED
|
@@ -16,10 +16,9 @@ interface ToolExecuteBeforeOutput {
|
|
|
16
16
|
|
|
17
17
|
interface ToolExecuteAfterOutput {
|
|
18
18
|
output: string;
|
|
19
|
+
metadata: Record<string, unknown>;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const toolInputs = new Map<string, unknown>();
|
|
22
|
-
|
|
23
22
|
function evaluate(tool: string, args: unknown, callId: string, cwd: string): Promise<PolicyResult> {
|
|
24
23
|
return new Promise((resolve) => {
|
|
25
24
|
let settled = false;
|
|
@@ -71,22 +70,24 @@ export const ReplicasCommandProtection = async ({ directory }: { directory: stri
|
|
|
71
70
|
'tool.execute.before': async (input: ToolExecuteBeforeInput, output: ToolExecuteBeforeOutput) => {
|
|
72
71
|
const result = await evaluate(input.tool, output.args, input.callID, directory);
|
|
73
72
|
if (!result.allowed) throw new Error(result.reason ?? 'Blocked by Replicas command protection.');
|
|
74
|
-
toolInputs.set(input.callID, output.args);
|
|
75
73
|
},
|
|
76
|
-
'tool.execute.after': async (input: ToolExecuteBeforeInput, output: ToolExecuteAfterOutput) => {
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
'tool.execute.after': async (input: ToolExecuteBeforeInput & { args: unknown }, output: ToolExecuteAfterOutput | undefined) => {
|
|
75
|
+
if (!output) return;
|
|
76
|
+
const exitCode = output.metadata?.exit ?? output.metadata?.exitCode;
|
|
77
|
+
const success = input.tool === 'bash' || input.tool === 'shell'
|
|
78
|
+
? exitCode === 0
|
|
79
|
+
: output.metadata?.isError !== true;
|
|
79
80
|
const hookPath = process.env.REPLICAS_POST_TOOL_PR_HOOK_PATH;
|
|
80
81
|
const runtimePath = process.env.REPLICAS_COMMAND_PROTECTION_RUNTIME_PATH;
|
|
81
82
|
if (!hookPath || !runtimePath) return;
|
|
82
83
|
const hookArgs = hookPath.endsWith('.ts') && !runtimePath.endsWith('/bun')
|
|
83
|
-
? ['--import', 'tsx', hookPath]
|
|
84
|
-
: [hookPath];
|
|
84
|
+
? ['--import', 'tsx', hookPath, 'opencode']
|
|
85
|
+
: [hookPath, 'opencode'];
|
|
85
86
|
await new Promise<void>((resolve) => {
|
|
86
87
|
const child = spawn(runtimePath, hookArgs, { cwd: directory, stdio: ['pipe', 'ignore', 'ignore'] });
|
|
87
88
|
child.on('error', () => resolve());
|
|
88
89
|
child.on('exit', () => resolve());
|
|
89
|
-
child.stdin.end(JSON.stringify({ tool: input.tool, args, output: output.output }));
|
|
90
|
+
child.stdin.end(JSON.stringify({ tool: input.tool, args: input.args, output: output.output, success }));
|
|
90
91
|
});
|
|
91
92
|
},
|
|
92
93
|
});
|