@pellux/goodvibes-agent 0.1.13 → 0.1.15

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to GoodVibes Agent will be recorded here.
4
4
 
5
+ ## 0.1.15 - 2026-05-31
6
+
7
+ - 67de700 Restrict remote and channel tools in agent runtime
8
+
9
+ ## 0.1.14 - 2026-05-31
10
+
11
+ - d128004 Block background exec in agent runtime
12
+
5
13
  ## 0.1.13 - 2026-05-31
6
14
 
7
15
  - 989b048 Block local coding tools in agent runtime
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pellux/goodvibes-agent",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "private": false,
5
5
  "description": "Near-fork GoodVibes operator assistant with the GoodVibes TUI shell, renderer, input, fullscreen workspace, and daemon-connected Agent product brain.",
6
6
  "type": "module",
@@ -6,11 +6,32 @@ type AgentToolArgs = {
6
6
  readonly [key: string]: unknown;
7
7
  };
8
8
 
9
+ type ExecCommandArgs = {
10
+ readonly cmd?: unknown;
11
+ readonly background?: unknown;
12
+ readonly until?: unknown;
13
+ readonly [key: string]: unknown;
14
+ };
15
+
16
+ type ExecToolArgs = {
17
+ readonly commands?: unknown;
18
+ readonly parallel?: unknown;
19
+ readonly file_ops?: unknown;
20
+ readonly [key: string]: unknown;
21
+ };
22
+
23
+ type ModeToolArgs = {
24
+ readonly mode?: unknown;
25
+ readonly createIfMissing?: unknown;
26
+ readonly [key: string]: unknown;
27
+ };
28
+
9
29
  type AgentToolPolicyGuardOptions = {
10
30
  readonly getLastUserMessage?: () => string | null;
11
31
  };
12
32
 
13
33
  const BLOCKED_MAIN_CONVERSATION_TOOL_NAMES = ['write', 'edit', 'workflow', 'repl'] as const;
34
+ const AGENT_EXEC_BACKGROUND_COMMAND = /^\s*bg_(?:status|output|stop)\b/;
14
35
 
15
36
  const READ_ONLY_AGENT_TOOL_MODES = [
16
37
  'status',
@@ -27,6 +48,11 @@ const READ_ONLY_AGENT_TOOL_MODES = [
27
48
  const READ_ONLY_AGENT_TOOL_MODE_SET = new Set<string>(READ_ONLY_AGENT_TOOL_MODES);
28
49
  const BLOCKED_MAIN_CONVERSATION_TOOL_NAME_SET = new Set<string>(BLOCKED_MAIN_CONVERSATION_TOOL_NAMES);
29
50
 
51
+ const READ_ONLY_REMOTE_TOOL_MODES = ['pools', 'contracts', 'artifacts', 'review'] as const;
52
+ const READ_ONLY_CHANNEL_TOOL_MODES = ['accounts', 'directory', 'resolve_target', 'capabilities', 'tools', 'agent_tools', 'actions'] as const;
53
+ const READ_ONLY_REMOTE_TOOL_MODE_SET = new Set<string>(READ_ONLY_REMOTE_TOOL_MODES);
54
+ const READ_ONLY_CHANNEL_TOOL_MODE_SET = new Set<string>(READ_ONLY_CHANNEL_TOOL_MODES);
55
+
30
56
  const LOCAL_AGENT_DENIAL = [
31
57
  'GoodVibes Agent does not spawn local Engineer/Reviewer/Tester/Verifier roots or run local WRFC chains.',
32
58
  'Keep ordinary assistant work serial in the main conversation.',
@@ -39,12 +65,44 @@ const LOCAL_CODING_TOOL_DENIAL = [
39
65
  'For durable Agent memory, skills, personas, routines, and knowledge, use the Agent-owned commands and isolated Agent Knowledge routes.',
40
66
  ].join(' ');
41
67
 
68
+ const BACKGROUND_EXEC_DENIAL = [
69
+ 'GoodVibes Agent only runs foreground, serial command-line work from the main conversation.',
70
+ 'Background processes, parallel command batches, background process controls, and exec pre-command file operations are disabled here.',
71
+ 'For long-running build/fix/review work, delegate one request to GoodVibes TUI through the public shared-session/build-delegation contract.',
72
+ ].join(' ');
73
+
74
+ const REMOTE_MUTATION_DENIAL = [
75
+ 'GoodVibes Agent only inspects remote runner pools, contracts, artifacts, and review summaries from the main conversation.',
76
+ 'Remote pool creation, assignment, unassignment, and artifact import are disabled here.',
77
+ 'Use explicit GoodVibes TUI delegation or a future Agent approval flow for remote execution changes.',
78
+ ].join(' ');
79
+
80
+ const CHANNEL_ACTION_DENIAL = [
81
+ 'GoodVibes Agent only inspects channel accounts, directories, capabilities, tools, and actions from the main conversation.',
82
+ 'Channel account actions, tool runs, operator action runs, authorization, and target auto-creation are disabled here.',
83
+ 'External channel side effects require an explicit Agent approval flow before they can run.',
84
+ ].join(' ');
85
+
42
86
  export function installAgentToolPolicyGuard(registry: ToolRegistry, options: AgentToolPolicyGuardOptions = {}): void {
43
87
  const agentTool = registry.list().find((tool) => tool.definition.name === 'agent');
44
88
  if (!agentTool) throw new Error('Agent tool policy guard could not find the agent tool.');
45
89
  wrapAgentToolForAgentPolicy(agentTool, options);
46
90
  for (const tool of registry.list()) {
47
- if (BLOCKED_MAIN_CONVERSATION_TOOL_NAME_SET.has(tool.definition.name)) {
91
+ if (tool.definition.name === 'exec') {
92
+ wrapExecToolForAgentPolicy(tool);
93
+ } else if (tool.definition.name === 'remote') {
94
+ wrapModeRestrictedToolForAgentPolicy(tool, {
95
+ allowedModes: READ_ONLY_REMOTE_TOOL_MODES,
96
+ modeSet: READ_ONLY_REMOTE_TOOL_MODE_SET,
97
+ description: [
98
+ 'Read-only remote runner inspection for GoodVibes Agent.',
99
+ 'Pool creation, runner assignment, unassignment, and artifact import are disabled in the main conversation.',
100
+ ].join(' '),
101
+ denial: REMOTE_MUTATION_DENIAL,
102
+ });
103
+ } else if (tool.definition.name === 'channel') {
104
+ wrapChannelToolForAgentPolicy(tool);
105
+ } else if (BLOCKED_MAIN_CONVERSATION_TOOL_NAME_SET.has(tool.definition.name)) {
48
106
  wrapBlockedMainConversationToolForAgentPolicy(tool);
49
107
  }
50
108
  }
@@ -79,10 +137,92 @@ export function wrapBlockedMainConversationToolForAgentPolicy(tool: Tool): void
79
137
  tool.execute = async () => ({ success: false, error: LOCAL_CODING_TOOL_DENIAL });
80
138
  }
81
139
 
140
+ export function wrapExecToolForAgentPolicy(tool: Tool): void {
141
+ narrowExecToolDefinitionForAgentPolicy(tool);
142
+ const originalExecute = tool.execute.bind(tool);
143
+ tool.execute = async (args) => {
144
+ const denial = validateExecToolInvocationForAgentPolicy(args as ExecToolArgs);
145
+ if (denial) return { success: false, error: denial };
146
+ return originalExecute(args);
147
+ };
148
+ }
149
+
150
+ export function validateExecToolInvocationForAgentPolicy(args: ExecToolArgs): string | null {
151
+ if (args.parallel === true) return BACKGROUND_EXEC_DENIAL;
152
+ if (Array.isArray(args.file_ops) && args.file_ops.length > 0) return BACKGROUND_EXEC_DENIAL;
153
+ if (args.file_ops !== undefined && !Array.isArray(args.file_ops)) return BACKGROUND_EXEC_DENIAL;
154
+ if (!Array.isArray(args.commands)) return null;
155
+
156
+ for (const command of args.commands) {
157
+ if (!isRecord(command)) continue;
158
+ const commandArgs = command as ExecCommandArgs;
159
+ if (commandArgs.background === true) return BACKGROUND_EXEC_DENIAL;
160
+ if (typeof commandArgs.cmd === 'string' && AGENT_EXEC_BACKGROUND_COMMAND.test(commandArgs.cmd)) {
161
+ return BACKGROUND_EXEC_DENIAL;
162
+ }
163
+ if (isRecord(commandArgs.until)) {
164
+ const killAfter = commandArgs.until.kill_after;
165
+ if (killAfter !== true) return BACKGROUND_EXEC_DENIAL;
166
+ }
167
+ }
168
+
169
+ return null;
170
+ }
171
+
172
+ type ModeRestrictedToolPolicy = {
173
+ readonly allowedModes: readonly string[];
174
+ readonly modeSet: ReadonlySet<string>;
175
+ readonly description: string;
176
+ readonly denial: string;
177
+ };
178
+
179
+ export function wrapModeRestrictedToolForAgentPolicy(tool: Tool, policy: ModeRestrictedToolPolicy): void {
180
+ narrowModeToolDefinitionForAgentPolicy(tool, policy.allowedModes, policy.description);
181
+ const originalExecute = tool.execute.bind(tool);
182
+ tool.execute = async (args) => {
183
+ const denial = validateModeRestrictedToolInvocationForAgentPolicy(args as ModeToolArgs, policy.modeSet, policy.denial);
184
+ if (denial) return { success: false, error: denial };
185
+ return originalExecute(args);
186
+ };
187
+ }
188
+
189
+ export function wrapChannelToolForAgentPolicy(tool: Tool): void {
190
+ narrowModeToolDefinitionForAgentPolicy(tool, READ_ONLY_CHANNEL_TOOL_MODES, [
191
+ 'Read-only channel inspection for GoodVibes Agent.',
192
+ 'Running channel tools/actions, account lifecycle actions, authorization, and target creation are disabled in the main conversation.',
193
+ ].join(' '));
194
+ const originalExecute = tool.execute.bind(tool);
195
+ tool.execute = async (args) => {
196
+ const denial = validateModeRestrictedToolInvocationForAgentPolicy(args as ModeToolArgs, READ_ONLY_CHANNEL_TOOL_MODE_SET, CHANNEL_ACTION_DENIAL)
197
+ ?? validateChannelToolInvocationForAgentPolicy(args as ModeToolArgs);
198
+ if (denial) return { success: false, error: denial };
199
+ return originalExecute(args);
200
+ };
201
+ }
202
+
203
+ export function validateModeRestrictedToolInvocationForAgentPolicy(
204
+ args: ModeToolArgs,
205
+ modeSet: ReadonlySet<string>,
206
+ denial: string,
207
+ ): string | null {
208
+ if (typeof args.mode === 'string' && !modeSet.has(args.mode)) return denial;
209
+ return null;
210
+ }
211
+
212
+ export function validateChannelToolInvocationForAgentPolicy(args: ModeToolArgs): string | null {
213
+ if (args.mode === 'resolve_target' && args.createIfMissing === true) return CHANNEL_ACTION_DENIAL;
214
+ return null;
215
+ }
216
+
82
217
  export const AGENT_LOCAL_SPAWN_DENIAL_MESSAGE = LOCAL_AGENT_DENIAL;
83
218
  export const AGENT_READ_ONLY_TOOL_MODES = READ_ONLY_AGENT_TOOL_MODES;
84
219
  export const AGENT_BLOCKED_MAIN_CONVERSATION_TOOL_NAMES = BLOCKED_MAIN_CONVERSATION_TOOL_NAMES;
85
220
  export const AGENT_MAIN_CONVERSATION_TOOL_DENIAL_MESSAGE = LOCAL_CODING_TOOL_DENIAL;
221
+ export const AGENT_EXEC_BACKGROUND_DENIAL_MESSAGE = BACKGROUND_EXEC_DENIAL;
222
+ export const AGENT_READ_ONLY_REMOTE_TOOL_MODES = READ_ONLY_REMOTE_TOOL_MODES;
223
+ export const AGENT_READ_ONLY_CHANNEL_TOOL_MODES = READ_ONLY_CHANNEL_TOOL_MODES;
224
+ export const AGENT_REMOTE_MUTATION_DENIAL_MESSAGE = REMOTE_MUTATION_DENIAL;
225
+ export const AGENT_CHANNEL_ACTION_DENIAL_MESSAGE = CHANNEL_ACTION_DENIAL;
86
226
 
87
227
  function isRecord(value: unknown): value is Record<string, unknown> {
88
228
  return typeof value === 'object' && value !== null && !Array.isArray(value);
@@ -104,6 +244,55 @@ function narrowAgentToolDefinitionForAgentPolicy(tool: Tool): void {
104
244
  modeProperty.description = 'Read-only Agent inspection mode. Local spawn, batch-spawn, cancel, message, wait, and plan modes are disabled in GoodVibes Agent.';
105
245
  }
106
246
 
247
+ function narrowExecToolDefinitionForAgentPolicy(tool: Tool): void {
248
+ tool.definition.description = [
249
+ 'Execute foreground shell commands serially for GoodVibes Agent main-conversation work.',
250
+ 'Background processes, parallel batches, background process controls, and exec file_ops are disabled by Agent policy.',
251
+ 'Delegate long-running build/fix/review execution to GoodVibes TUI instead.',
252
+ ].join(' ');
253
+
254
+ const properties = tool.definition.parameters.properties;
255
+ if (!isRecord(properties)) return;
256
+ delete properties.parallel;
257
+ delete properties.file_ops;
258
+
259
+ const commandsProperty = properties.commands;
260
+ if (!isRecord(commandsProperty)) return;
261
+ const itemSchema = commandsProperty.items;
262
+ if (!isRecord(itemSchema)) return;
263
+ const commandProperties = itemSchema.properties;
264
+ if (!isRecord(commandProperties)) return;
265
+
266
+ delete commandProperties.background;
267
+ const untilProperty = commandProperties.until;
268
+ if (isRecord(untilProperty)) {
269
+ untilProperty.description = [
270
+ 'Pattern-based early termination.',
271
+ 'GoodVibes Agent requires kill_after:true so until-mode does not promote the process to background.',
272
+ ].join(' ');
273
+ }
274
+ }
275
+
276
+ function narrowModeToolDefinitionForAgentPolicy(tool: Tool, allowedModes: readonly string[], description: string): void {
277
+ tool.definition.description = description;
278
+
279
+ const properties = tool.definition.parameters.properties;
280
+ if (!isRecord(properties)) return;
281
+ const modeProperty = properties.mode;
282
+ if (isRecord(modeProperty)) {
283
+ modeProperty.enum = [...allowedModes];
284
+ modeProperty.description = 'Read-only modes allowed by GoodVibes Agent main-conversation policy.';
285
+ }
286
+
287
+ if (tool.definition.name === 'channel') {
288
+ delete properties.accountAction;
289
+ delete properties.toolId;
290
+ delete properties.actionId;
291
+ delete properties.actorId;
292
+ delete properties.createIfMissing;
293
+ }
294
+ }
295
+
107
296
  // Compatibility exports for copied TUI tests/imports during the near-fork phase.
108
297
  export const installWrfcAgentToolGuard = installAgentToolPolicyGuard;
109
298
  export const wrapWrfcAgentTool = wrapAgentToolForAgentPolicy;
package/src/version.ts CHANGED
@@ -6,7 +6,7 @@ import { join } from 'node:path';
6
6
  // The prebuild script updates the fallback value before compilation.
7
7
  // Uses import.meta.dir (Bun) to locate package.json relative to this file,
8
8
  // which is correct regardless of the process working directory.
9
- let _version = '0.1.13';
9
+ let _version = '0.1.15';
10
10
  let _sdkVersion = '0.33.35';
11
11
  try {
12
12
  const pkg = JSON.parse(readFileSync(join(import.meta.dir, '..', 'package.json'), 'utf-8')) as {