replicas-engine 0.1.888 → 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.
@@ -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-4DGHCMBQ.js";
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-5RULOJKJ.js";
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
  `);
@@ -11,7 +11,7 @@ import {
11
11
  relaySubagentResponseSchema,
12
12
  spawnRelaySubagentRequestSchema,
13
13
  waitRelaySubagentRequestSchema
14
- } from "./chunk-5RULOJKJ.js";
14
+ } from "./chunk-OBAGPETY.js";
15
15
  import "./chunk-VEQXQN22.js";
16
16
 
17
17
  // src/relay-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.888",
3
+ "version": "0.1.891",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -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
- const args = toolInputs.get(input.callID);
78
- toolInputs.delete(input.callID);
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
  });