@pellux/goodvibes-agent 0.1.14 → 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 +4 -0
- package/package.json +1 -1
- package/src/tools/wrfc-agent-guard.ts +104 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pellux/goodvibes-agent",
|
|
3
|
-
"version": "0.1.
|
|
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",
|
|
@@ -20,6 +20,12 @@ type ExecToolArgs = {
|
|
|
20
20
|
readonly [key: string]: unknown;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
type ModeToolArgs = {
|
|
24
|
+
readonly mode?: unknown;
|
|
25
|
+
readonly createIfMissing?: unknown;
|
|
26
|
+
readonly [key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
|
|
23
29
|
type AgentToolPolicyGuardOptions = {
|
|
24
30
|
readonly getLastUserMessage?: () => string | null;
|
|
25
31
|
};
|
|
@@ -42,6 +48,11 @@ const READ_ONLY_AGENT_TOOL_MODES = [
|
|
|
42
48
|
const READ_ONLY_AGENT_TOOL_MODE_SET = new Set<string>(READ_ONLY_AGENT_TOOL_MODES);
|
|
43
49
|
const BLOCKED_MAIN_CONVERSATION_TOOL_NAME_SET = new Set<string>(BLOCKED_MAIN_CONVERSATION_TOOL_NAMES);
|
|
44
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
|
+
|
|
45
56
|
const LOCAL_AGENT_DENIAL = [
|
|
46
57
|
'GoodVibes Agent does not spawn local Engineer/Reviewer/Tester/Verifier roots or run local WRFC chains.',
|
|
47
58
|
'Keep ordinary assistant work serial in the main conversation.',
|
|
@@ -60,6 +71,18 @@ const BACKGROUND_EXEC_DENIAL = [
|
|
|
60
71
|
'For long-running build/fix/review work, delegate one request to GoodVibes TUI through the public shared-session/build-delegation contract.',
|
|
61
72
|
].join(' ');
|
|
62
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
|
+
|
|
63
86
|
export function installAgentToolPolicyGuard(registry: ToolRegistry, options: AgentToolPolicyGuardOptions = {}): void {
|
|
64
87
|
const agentTool = registry.list().find((tool) => tool.definition.name === 'agent');
|
|
65
88
|
if (!agentTool) throw new Error('Agent tool policy guard could not find the agent tool.');
|
|
@@ -67,6 +90,18 @@ export function installAgentToolPolicyGuard(registry: ToolRegistry, options: Age
|
|
|
67
90
|
for (const tool of registry.list()) {
|
|
68
91
|
if (tool.definition.name === 'exec') {
|
|
69
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);
|
|
70
105
|
} else if (BLOCKED_MAIN_CONVERSATION_TOOL_NAME_SET.has(tool.definition.name)) {
|
|
71
106
|
wrapBlockedMainConversationToolForAgentPolicy(tool);
|
|
72
107
|
}
|
|
@@ -134,11 +169,60 @@ export function validateExecToolInvocationForAgentPolicy(args: ExecToolArgs): st
|
|
|
134
169
|
return null;
|
|
135
170
|
}
|
|
136
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
|
+
|
|
137
217
|
export const AGENT_LOCAL_SPAWN_DENIAL_MESSAGE = LOCAL_AGENT_DENIAL;
|
|
138
218
|
export const AGENT_READ_ONLY_TOOL_MODES = READ_ONLY_AGENT_TOOL_MODES;
|
|
139
219
|
export const AGENT_BLOCKED_MAIN_CONVERSATION_TOOL_NAMES = BLOCKED_MAIN_CONVERSATION_TOOL_NAMES;
|
|
140
220
|
export const AGENT_MAIN_CONVERSATION_TOOL_DENIAL_MESSAGE = LOCAL_CODING_TOOL_DENIAL;
|
|
141
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;
|
|
142
226
|
|
|
143
227
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
144
228
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -189,6 +273,26 @@ function narrowExecToolDefinitionForAgentPolicy(tool: Tool): void {
|
|
|
189
273
|
}
|
|
190
274
|
}
|
|
191
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
|
+
|
|
192
296
|
// Compatibility exports for copied TUI tests/imports during the near-fork phase.
|
|
193
297
|
export const installWrfcAgentToolGuard = installAgentToolPolicyGuard;
|
|
194
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.
|
|
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 {
|