@pellux/goodvibes-agent 1.0.3 → 1.0.4
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 +6 -0
- package/README.md +2 -2
- package/dist/package/main.js +378 -92
- package/docs/README.md +2 -2
- package/docs/getting-started.md +2 -2
- package/docs/tools-and-commands.md +5 -3
- package/package.json +1 -1
- package/src/tools/agent-harness-keybinding-metadata.ts +262 -0
- package/src/tools/agent-harness-tool.ts +51 -50
- package/src/version.ts +1 -1
package/docs/README.md
CHANGED
|
@@ -17,12 +17,12 @@ Current package docs:
|
|
|
17
17
|
Important baseline constraints:
|
|
18
18
|
|
|
19
19
|
- Agent installs one executable: `goodvibes-agent`.
|
|
20
|
-
- Current package version is recorded in `package.json` and `CHANGELOG.md`; the latest completed `1.0.x` release in this tree is `1.0.
|
|
20
|
+
- Current package version is recorded in `package.json` and `CHANGELOG.md`; the latest completed `1.0.x` release in this tree is `1.0.3`.
|
|
21
21
|
- Agent uses Bun `1.3.10` or newer and TypeScript-authored source.
|
|
22
22
|
- Agent depends on `@pellux/goodvibes-sdk@0.33.35`.
|
|
23
23
|
- Agent connects to a GoodVibes host owned outside this product.
|
|
24
24
|
- Agent does not start, stop, restart, install, uninstall, or own the connected GoodVibes host.
|
|
25
|
-
- User-facing Agent workspace actions, built-in panels, top-level CLI mirrors, slash commands, command policy metadata, model tools, settings, local registries, and connected-host capability boundaries are model-visible through Agent-owned tools. Mutations remain explicit and confirmation-gated.
|
|
25
|
+
- User-facing Agent workspace actions, built-in panels, top-level CLI mirrors, fixed shortcuts, configurable keybindings, slash commands, command policy metadata, model tools, settings, local registries, and connected-host capability boundaries are model-visible through Agent-owned tools. Mutations remain explicit and confirmation-gated.
|
|
26
26
|
- Agent Knowledge uses only `/api/goodvibes-agent/knowledge/*`; there is no default knowledge or non-Agent product fallback.
|
|
27
27
|
- Agent supports isolated Agent homes with `GOODVIBES_AGENT_HOME=<path>` and named profile homes with `goodvibes-agent profiles create <name> --template <starter> --yes` plus `--agent-profile <name>`.
|
|
28
28
|
- Agent supports connected-host URL overrides with `--runtime-url http://host:port` or `GOODVIBES_AGENT_RUNTIME_URL=http://host:port`; these only change the Agent connection target.
|
package/docs/getting-started.md
CHANGED
|
@@ -44,7 +44,7 @@ After setup has been applied once, the TUI opens directly into the Agent operato
|
|
|
44
44
|
|
|
45
45
|
Press `/` inside the Agent workspace to search every workspace action by name, category, command, or detail. Use that finder before reaching for shell commands; CLI subcommands are scriptable mirrors of these TUI workflows.
|
|
46
46
|
|
|
47
|
-
The model can inspect and use the same harness surface through Agent-owned tools. `agent_harness` exposes workspace action discovery, built-in panel discovery/routing, top-level CLI mirror discovery, slash-command discovery, command policy metadata, command execution with confirmation, model tool discovery, settings inspection/mutation, and connected-host posture. CLI mirror modes are read-only catalog/parser inspection and point the model to the matching in-process tool, workspace action, setting mode, or slash-command mirror. Panel modes expose catalog/open state and route visible panel/workspace changes through the current Agent shell bridge with confirmation. Workspace action discovery can include editor field schemas with `includeParameters:true`, including starter-template defaults for profile creation and selected-routine defaults for routine schedule promotion when `recordId` is supplied. Selection-based local workspace actions accept a local `recordId`, so the model can use the same note promotion and local registry flows as the TUI. First-class model tools cover the main product workflows directly: Agent Knowledge, Agent Knowledge ingest, Agent-local memory/notes/personas/skills/routines, operator actions, notifications, channel sends, reminders, generated media, and work plans.
|
|
47
|
+
The model can inspect and use the same harness surface through Agent-owned tools. `agent_harness` exposes workspace action discovery, built-in panel discovery/routing, top-level CLI mirror discovery, fixed shortcut and configurable keybinding discovery, keybinding mutation with confirmation, slash-command discovery, command policy metadata, command execution with confirmation, model tool discovery, settings inspection/mutation, and connected-host posture. CLI mirror modes are read-only catalog/parser inspection and point the model to the matching in-process tool, workspace action, setting mode, or slash-command mirror. Panel modes expose catalog/open state and route visible panel/workspace changes through the current Agent shell bridge with confirmation. Shortcut modes expose the fixed runtime/editor shortcuts and the live keybindings table; confirmed keybinding edits write the same `keybindings.json` file the user edits and reload the runtime manager. Workspace action discovery can include editor field schemas with `includeParameters:true`, including starter-template defaults for profile creation and selected-routine defaults for routine schedule promotion when `recordId` is supplied. Selection-based local workspace actions accept a local `recordId`, so the model can use the same note promotion and local registry flows as the TUI. First-class model tools cover the main product workflows directly: Agent Knowledge, Agent Knowledge ingest, Agent-local memory/notes/personas/skills/routines, operator actions, notifications, channel sends, reminders, generated media, and work plans.
|
|
48
48
|
|
|
49
49
|
Use the Artifacts area for concrete files and generated output: attach images to prompts, export conversations or saved sessions, ingest local source files and URL lists into Agent Knowledge, import bookmarks or browser history, inspect source records, and generate media artifacts from confirmed prompts.
|
|
50
50
|
|
|
@@ -122,7 +122,7 @@ Use `/channels` inside the TUI for channel readiness and exact confirmed sends.
|
|
|
122
122
|
|
|
123
123
|
The main assistant conversation can perform narrow confirmed operator actions when the user explicitly asks for a specific target: approve/deny/cancel one approval, run/pause/resume one automation job, cancel/retry one automation run, or run one schedule. Those calls use only public connected-host routes, require confirmation, and do not create, edit, or delete automation definitions.
|
|
124
124
|
|
|
125
|
-
When the main assistant conversation needs to change Agent settings or run a user-facing harness action, it should use `agent_harness` rather than generic SDK context/settings tools. Setting descriptors report writability, workspace visibility, and lock reasons; secret-backed settings store raw values through the secret manager; connected-host lifecycle settings stay read-only in Agent; and destructive local record deletion requires explicit confirmation.
|
|
125
|
+
When the main assistant conversation needs to change Agent settings, change Agent keybindings, or run a user-facing harness action, it should use `agent_harness` rather than generic SDK context/settings tools. Setting descriptors report writability, workspace visibility, and lock reasons; keybinding descriptors report fixed shortcuts, resolved bindings, defaults, custom state, and config path; secret-backed settings store raw values through the secret manager; connected-host lifecycle settings stay read-only in Agent; and destructive local record deletion requires explicit confirmation.
|
|
126
126
|
|
|
127
127
|
## Connected GoodVibes Host
|
|
128
128
|
|
|
@@ -43,20 +43,22 @@ Host-management and coding-first commands that would imply connected-host lifecy
|
|
|
43
43
|
|
|
44
44
|
The main Agent model has an Agent-owned harness bridge rather than generic SDK settings/context control. Use these model tools as the supported parity layer:
|
|
45
45
|
|
|
46
|
-
- `agent_harness`: inspect workspace categories/actions, inspect built-in panels, inspect top-level CLI mirrors, inspect slash commands and command policy metadata, run concrete workspace or slash-command mirrors with confirmation, inspect model tools, inspect or change Agent settings, and inspect connected-host posture.
|
|
46
|
+
- `agent_harness`: inspect workspace categories/actions, inspect built-in panels, inspect top-level CLI mirrors, inspect fixed shortcuts and configurable keybindings, inspect slash commands and command policy metadata, run concrete workspace or slash-command mirrors with confirmation, inspect model tools, inspect or change Agent settings/keybindings, and inspect connected-host posture.
|
|
47
47
|
- `agent_local_registry`: inspect and maintain Agent-local memory, notes, personas, skills, skill bundles, and routines. Deleting local records requires `confirm:true` and `explicitUserRequest`.
|
|
48
48
|
- `agent_knowledge` and `agent_knowledge_ingest`: ask/search and ingest into the isolated Agent Knowledge segment.
|
|
49
49
|
- `agent_operator_briefing` and `agent_operator_action`: inspect connected work/approval/automation posture, or run exact confirmed approval/automation actions.
|
|
50
50
|
- `agent_work_plan`: keep the visible Agent-local work plan current from the conversation.
|
|
51
51
|
- `agent_channel_send`, `agent_notify`, `agent_reminder_schedule`, and `agent_media_generate`: perform confirmed external delivery, notification, reminder, or media actions when the user explicitly asks.
|
|
52
52
|
|
|
53
|
-
`agent_harness` discovery modes are read-only. `summary` reports the model access map; `panels` and `panel` return the built-in panel catalog, current open/focused state, and each panel's matching Agent workspace route; `cli_commands` and `cli_command` return top-level package CLI mirror metadata, parser output, blocked command tokens, and preferred in-process model routes; `commands` and `command` return slash-command descriptions plus effect/confirmation/preferred-tool/boundary policy metadata; `workspace_actions` lists Agent workspace actions and can inline editor field schemas with `includeParameters:true`; `workspace_action` returns one action with its editor schema; `tools` can inline model tool JSON schemas with `includeParameters:true`; `settings` returns setting descriptors plus setting policy; and `connected_host` returns the connected-host route families, allowed capabilities, blocked capabilities, and first-class tool availability.
|
|
53
|
+
`agent_harness` discovery modes are read-only. `summary` reports the model access map; `panels` and `panel` return the built-in panel catalog, current open/focused state, and each panel's matching Agent workspace route; `cli_commands` and `cli_command` return top-level package CLI mirror metadata, parser output, blocked command tokens, and preferred in-process model routes; `shortcuts` returns fixed runtime/editor shortcuts plus configurable keybindings; `keybindings` and `keybinding` return the live resolved keybinding table, default bindings, custom state, and config path; `commands` and `command` return slash-command descriptions plus effect/confirmation/preferred-tool/boundary policy metadata; `workspace_actions` lists Agent workspace actions and can inline editor field schemas with `includeParameters:true`; `workspace_action` returns one action with its editor schema; `tools` can inline model tool JSON schemas with `includeParameters:true`; `settings` returns setting descriptors plus setting policy; and `connected_host` returns the connected-host route families, allowed capabilities, blocked capabilities, and first-class tool availability.
|
|
54
|
+
|
|
55
|
+
`set_keybinding` and `reset_keybinding` are confirmation-gated control modes. They write the same Agent `keybindings.json` file exposed by `/keybindings`, reload the runtime keybinding manager, and leave fixed runtime/editor shortcuts read-only.
|
|
54
56
|
|
|
55
57
|
`open_panel` is a confirmation-gated UI routing mode. It hands a visible panel/workspace route to the current Agent shell bridge and does not mutate connected-host lifecycle, listener posture, or external accounts.
|
|
56
58
|
|
|
57
59
|
CLI mirror modes are catalog and parser inspection only. When the user asks the model to operate from inside the main conversation, use the returned first-class model tool, workspace action, setting mode, or confirmed slash-command mirror instead of launching a hidden nested `goodvibes-agent` process.
|
|
58
60
|
|
|
59
|
-
Setting writes, setting resets, slash-command invocation, workspace-action invocation, local record deletion, channel sends, notifications, reminders, media generation, and connected-host operator mutations require explicit user request and confirmation. Secret-backed settings are stored through the secret manager, and connected-host lifecycle/listener settings remain read-only in Agent.
|
|
61
|
+
Setting writes, setting resets, keybinding writes/resets, slash-command invocation, workspace-action invocation, local record deletion, channel sends, notifications, reminders, media generation, and connected-host operator mutations require explicit user request and confirmation. Secret-backed settings are stored through the secret manager, and connected-host lifecycle/listener settings remain read-only in Agent.
|
|
60
62
|
|
|
61
63
|
Selection-based local workspace actions use the same bridge. `agent_harness` reports the required model tool for each local action; for actions that depend on the TUI selection, call `run_workspace_action` with the selected local `recordId`. Note promotion actions can prefill and create memory, personas, skills, routines, or isolated Agent Knowledge URL ingests through the matching first-class model tool. Profile creation schemas include the current runtime starter-template inventory, and routine schedule schemas prefill the selected routine when `recordId` or a `routineId` field matches a local routine.
|
|
62
64
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pellux/goodvibes-agent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "GoodVibes personal operator assistant TUI with a proactive Agent product brain, isolated Agent Knowledge, local profiles, routines, skills, personas, and explicit build delegation.",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import type { CommandContext } from '../input/command-registry.ts';
|
|
4
|
+
import {
|
|
5
|
+
ACTION_DESCRIPTIONS,
|
|
6
|
+
DEFAULT_KEYBINDINGS,
|
|
7
|
+
type KeyAction,
|
|
8
|
+
type KeyCombo,
|
|
9
|
+
type KeybindingsManager,
|
|
10
|
+
} from '../input/keybindings.ts';
|
|
11
|
+
|
|
12
|
+
const FIXED_SHORTCUTS: readonly Record<string, string>[] = [
|
|
13
|
+
{ key: 'Enter', description: 'Send prompt' },
|
|
14
|
+
{ key: 'Shift+Enter / Ctrl+J', description: 'Insert newline' },
|
|
15
|
+
{ key: 'Up / Down', description: 'Navigate input history, lists, and scrollable overlays' },
|
|
16
|
+
{ key: 'Tab', description: 'Autocomplete slash command or file mention' },
|
|
17
|
+
{ key: 'Esc', description: 'Close overlays, pickers, and transient input modes' },
|
|
18
|
+
{ key: '? / F1', description: 'Toggle help overlay' },
|
|
19
|
+
{ key: 'F2 / /shortcuts', description: 'Open keyboard shortcut reference' },
|
|
20
|
+
{ key: '/keybindings', description: 'List configurable keybindings and config path' },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
interface HarnessKeybindingArgs {
|
|
24
|
+
readonly query?: unknown;
|
|
25
|
+
readonly actionId?: unknown;
|
|
26
|
+
readonly key?: unknown;
|
|
27
|
+
readonly fields?: unknown;
|
|
28
|
+
readonly combo?: unknown;
|
|
29
|
+
readonly combos?: unknown;
|
|
30
|
+
readonly value?: unknown;
|
|
31
|
+
readonly limit?: unknown;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type KeybindingsOverrideFile = Record<string, unknown>;
|
|
35
|
+
|
|
36
|
+
function readString(value: unknown): string {
|
|
37
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function readLimit(value: unknown, fallback: number): number {
|
|
41
|
+
const parsed = typeof value === 'string' && value.trim() ? Number(value) : value;
|
|
42
|
+
if (typeof parsed !== 'number' || !Number.isFinite(parsed)) return fallback;
|
|
43
|
+
return Math.max(1, Math.min(500, Math.trunc(parsed)));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function readFieldMap(value: unknown): Readonly<Record<string, string>> {
|
|
47
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) return {};
|
|
48
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, typeof entry === 'string' ? entry : String(entry)]));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function requireKeybindingsManager(context: CommandContext): KeybindingsManager {
|
|
52
|
+
const manager = context.workspace.keybindingsManager;
|
|
53
|
+
if (!manager) throw new Error('workspace.keybindingsManager is unavailable in this Agent runtime');
|
|
54
|
+
return manager;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isKeyAction(action: string): action is KeyAction {
|
|
58
|
+
return Object.hasOwn(ACTION_DESCRIPTIONS, action);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function actionFromArgs(args: HarnessKeybindingArgs): KeyAction | null {
|
|
62
|
+
const action = readString(args.actionId || args.key || args.query);
|
|
63
|
+
return action && isKeyAction(action) ? action : null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function readBoolean(value: unknown): boolean | undefined {
|
|
67
|
+
if (typeof value === 'boolean') return value;
|
|
68
|
+
if (typeof value !== 'string') return undefined;
|
|
69
|
+
const normalized = value.trim().toLowerCase();
|
|
70
|
+
if (['true', 'yes', 'y', '1', 'on'].includes(normalized)) return true;
|
|
71
|
+
if (['false', 'no', 'n', '0', 'off'].includes(normalized)) return false;
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function normalizeCombo(value: unknown): KeyCombo | null {
|
|
76
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) return null;
|
|
77
|
+
const raw = value as Record<string, unknown>;
|
|
78
|
+
const key = readString(raw.key);
|
|
79
|
+
if (!key) return null;
|
|
80
|
+
const combo: KeyCombo = { key };
|
|
81
|
+
const ctrl = readBoolean(raw.ctrl);
|
|
82
|
+
const shift = readBoolean(raw.shift);
|
|
83
|
+
const alt = readBoolean(raw.alt);
|
|
84
|
+
if (ctrl !== undefined) combo.ctrl = ctrl;
|
|
85
|
+
if (shift !== undefined) combo.shift = shift;
|
|
86
|
+
if (alt !== undefined) combo.alt = alt;
|
|
87
|
+
return combo;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function parseComboLabel(value: string): KeyCombo | null {
|
|
91
|
+
const parts = value.split('+').map((part) => part.trim()).filter(Boolean);
|
|
92
|
+
if (parts.length === 0) return null;
|
|
93
|
+
const key = parts.at(-1);
|
|
94
|
+
if (!key) return null;
|
|
95
|
+
const combo: KeyCombo = { key: key.length === 1 ? key.toLowerCase() : key.toLowerCase() };
|
|
96
|
+
for (const part of parts.slice(0, -1)) {
|
|
97
|
+
const normalized = part.toLowerCase();
|
|
98
|
+
if (normalized === 'ctrl' || normalized === 'control') combo.ctrl = true;
|
|
99
|
+
else if (normalized === 'shift') combo.shift = true;
|
|
100
|
+
else if (normalized === 'alt' || normalized === 'option') combo.alt = true;
|
|
101
|
+
else return null;
|
|
102
|
+
}
|
|
103
|
+
return combo;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function combosFromArgs(args: HarnessKeybindingArgs): KeyCombo[] {
|
|
107
|
+
if (Array.isArray(args.combos)) {
|
|
108
|
+
const combos = args.combos.map(normalizeCombo);
|
|
109
|
+
if (combos.every((combo): combo is KeyCombo => combo !== null)) return combos;
|
|
110
|
+
throw new Error('set_keybinding combos must be objects with key and optional boolean ctrl/shift/alt fields.');
|
|
111
|
+
}
|
|
112
|
+
const combo = normalizeCombo(args.combo);
|
|
113
|
+
if (combo) return [combo];
|
|
114
|
+
const fields = readFieldMap(args.fields);
|
|
115
|
+
const fieldCombo = normalizeCombo(fields);
|
|
116
|
+
if (fieldCombo) return [fieldCombo];
|
|
117
|
+
const labelCombo = parseComboLabel(readString(args.value));
|
|
118
|
+
if (labelCombo) return [labelCombo];
|
|
119
|
+
throw new Error('set_keybinding requires combo, combos, fields.key, or a value such as "Ctrl+G".');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function comboFingerprint(combo: KeyCombo): string {
|
|
123
|
+
return `${combo.key}:${combo.ctrl ? 1 : 0}:${combo.shift ? 1 : 0}:${combo.alt ? 1 : 0}`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function combosEqual(left: readonly KeyCombo[], right: readonly KeyCombo[]): boolean {
|
|
127
|
+
if (left.length !== right.length) return false;
|
|
128
|
+
return left.every((combo, index) => comboFingerprint(combo) === comboFingerprint(right[index]));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function describeCombo(manager: KeybindingsManager, combo: KeyCombo): Record<string, unknown> {
|
|
132
|
+
return {
|
|
133
|
+
key: combo.key,
|
|
134
|
+
ctrl: combo.ctrl === true,
|
|
135
|
+
shift: combo.shift === true,
|
|
136
|
+
alt: combo.alt === true,
|
|
137
|
+
label: manager.formatCombo(combo),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function bindingMatches(entry: { readonly action: KeyAction; readonly description: string; readonly combos: KeyCombo[] }, query: string): boolean {
|
|
142
|
+
if (!query) return true;
|
|
143
|
+
const haystack = [
|
|
144
|
+
entry.action,
|
|
145
|
+
entry.description,
|
|
146
|
+
...entry.combos.map((combo) => comboFingerprint(combo)),
|
|
147
|
+
].join('\n').toLowerCase();
|
|
148
|
+
return haystack.includes(query.toLowerCase());
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function describeBinding(manager: KeybindingsManager, action: KeyAction, combos: KeyCombo[]): Record<string, unknown> {
|
|
152
|
+
const defaults = DEFAULT_KEYBINDINGS[action];
|
|
153
|
+
const customized = !combosEqual(combos, defaults);
|
|
154
|
+
return {
|
|
155
|
+
action,
|
|
156
|
+
description: ACTION_DESCRIPTIONS[action],
|
|
157
|
+
bindings: combos.map((combo) => describeCombo(manager, combo)),
|
|
158
|
+
labels: combos.map((combo) => manager.formatCombo(combo)),
|
|
159
|
+
defaultBindings: defaults.map((combo) => describeCombo(manager, combo)),
|
|
160
|
+
customized,
|
|
161
|
+
source: customized ? 'custom' : 'default',
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function readOverrideFile(configPath: string): KeybindingsOverrideFile {
|
|
166
|
+
if (!existsSync(configPath)) return {};
|
|
167
|
+
const parsed = JSON.parse(readFileSync(configPath, 'utf-8')) as unknown;
|
|
168
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
169
|
+
throw new Error(`Keybindings config ${configPath} must contain a JSON object.`);
|
|
170
|
+
}
|
|
171
|
+
return parsed as KeybindingsOverrideFile;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function writeOverrideFile(configPath: string, overrides: KeybindingsOverrideFile): void {
|
|
175
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
176
|
+
writeFileSync(configPath, `${JSON.stringify(overrides, null, 2)}\n`, 'utf-8');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function totalHarnessKeybindings(context: CommandContext): number {
|
|
180
|
+
return context.workspace.keybindingsManager?.getAll().length ?? 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function totalHarnessShortcuts(context: CommandContext): number {
|
|
184
|
+
return totalHarnessKeybindings(context) + FIXED_SHORTCUTS.length;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function listHarnessShortcuts(context: CommandContext, args: HarnessKeybindingArgs): Record<string, unknown> {
|
|
188
|
+
const keybindings = listHarnessKeybindings(context, args);
|
|
189
|
+
const query = readString(args.query).toLowerCase();
|
|
190
|
+
const fixed = FIXED_SHORTCUTS
|
|
191
|
+
.filter((shortcut) => !query || `${shortcut.key}\n${shortcut.description}`.toLowerCase().includes(query))
|
|
192
|
+
.slice(0, readLimit(args.limit, 200))
|
|
193
|
+
.map((shortcut) => ({ ...shortcut, source: 'fixed', userEditable: false }));
|
|
194
|
+
return {
|
|
195
|
+
configPath: keybindings.configPath,
|
|
196
|
+
fixedShortcuts: fixed,
|
|
197
|
+
configurableKeybindings: keybindings.keybindings,
|
|
198
|
+
returned: fixed.length + Number(keybindings.returned ?? 0),
|
|
199
|
+
total: totalHarnessShortcuts(context),
|
|
200
|
+
policy: 'Fixed shortcuts are runtime/editor controls. Configurable keybindings can be changed with set_keybinding/reset_keybinding.',
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function listHarnessKeybindings(context: CommandContext, args: HarnessKeybindingArgs): Record<string, unknown> {
|
|
205
|
+
const manager = requireKeybindingsManager(context);
|
|
206
|
+
const query = readString(args.query);
|
|
207
|
+
const entries = manager.getAll()
|
|
208
|
+
.filter((entry) => bindingMatches(entry, query))
|
|
209
|
+
.slice(0, readLimit(args.limit, 200))
|
|
210
|
+
.map((entry) => describeBinding(manager, entry.action, entry.combos));
|
|
211
|
+
return {
|
|
212
|
+
configPath: manager.getConfigPath(),
|
|
213
|
+
keybindings: entries,
|
|
214
|
+
returned: entries.length,
|
|
215
|
+
total: manager.getAll().length,
|
|
216
|
+
policy: 'Reads the live resolved keybindings. set_keybinding/reset_keybinding write the same keybindings.json file the user can edit and reload the runtime manager.',
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function describeHarnessKeybinding(context: CommandContext, args: HarnessKeybindingArgs): Record<string, unknown> | null {
|
|
221
|
+
const manager = requireKeybindingsManager(context);
|
|
222
|
+
const action = actionFromArgs(args);
|
|
223
|
+
if (!action) return null;
|
|
224
|
+
const entry = manager.getAll().find((candidate) => candidate.action === action);
|
|
225
|
+
return entry ? {
|
|
226
|
+
configPath: manager.getConfigPath(),
|
|
227
|
+
...describeBinding(manager, entry.action, entry.combos),
|
|
228
|
+
} : null;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export function setHarnessKeybinding(context: CommandContext, args: HarnessKeybindingArgs): Record<string, unknown> {
|
|
232
|
+
const manager = requireKeybindingsManager(context);
|
|
233
|
+
const action = actionFromArgs(args);
|
|
234
|
+
if (!action) throw new Error('set_keybinding requires a valid keybinding action id.');
|
|
235
|
+
const combos = combosFromArgs(args);
|
|
236
|
+
const configPath = manager.getConfigPath();
|
|
237
|
+
const overrides = readOverrideFile(configPath);
|
|
238
|
+
overrides[action] = combos.length === 1 ? combos[0] : combos;
|
|
239
|
+
writeOverrideFile(configPath, overrides);
|
|
240
|
+
manager.loadFromDisk();
|
|
241
|
+
return {
|
|
242
|
+
status: 'updated',
|
|
243
|
+
configPath,
|
|
244
|
+
keybinding: describeHarnessKeybinding(context, { actionId: action }),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function resetHarnessKeybinding(context: CommandContext, args: HarnessKeybindingArgs): Record<string, unknown> {
|
|
249
|
+
const manager = requireKeybindingsManager(context);
|
|
250
|
+
const action = actionFromArgs(args);
|
|
251
|
+
if (!action) throw new Error('reset_keybinding requires a valid keybinding action id.');
|
|
252
|
+
const configPath = manager.getConfigPath();
|
|
253
|
+
const overrides = readOverrideFile(configPath);
|
|
254
|
+
delete overrides[action];
|
|
255
|
+
writeOverrideFile(configPath, overrides);
|
|
256
|
+
manager.loadFromDisk();
|
|
257
|
+
return {
|
|
258
|
+
status: 'reset',
|
|
259
|
+
configPath,
|
|
260
|
+
keybinding: describeHarnessKeybinding(context, { actionId: action }),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
} from '../input/agent-workspace-types.ts';
|
|
19
19
|
import { parseSlashCommand } from '../input/slash-command-parser.ts';
|
|
20
20
|
import { blockedHarnessCliCommandTokens, describeHarnessCliCommand, listHarnessCliCommands, totalHarnessCliCommands } from './agent-harness-cli-metadata.ts';
|
|
21
|
+
import { describeHarnessKeybinding, listHarnessKeybindings, listHarnessShortcuts, resetHarnessKeybinding, setHarnessKeybinding, totalHarnessKeybindings, totalHarnessShortcuts } from './agent-harness-keybinding-metadata.ts';
|
|
21
22
|
import { describeHarnessPanel, listHarnessPanels, openHarnessPanel, totalHarnessPanels } from './agent-harness-panel-metadata.ts';
|
|
22
23
|
import { describeLocalWorkspaceModelExecution, runLocalWorkspaceAction } from './agent-harness-local-operations.ts';
|
|
23
24
|
import { listHarnessModelTools } from './agent-harness-model-tool-catalog.ts';
|
|
@@ -34,27 +35,15 @@ import {
|
|
|
34
35
|
setHarnessSetting,
|
|
35
36
|
} from '../agent/harness-control.ts';
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
| 'run_command'
|
|
47
|
-
| 'settings'
|
|
48
|
-
| 'get_setting'
|
|
49
|
-
| 'set_setting'
|
|
50
|
-
| 'reset_setting'
|
|
51
|
-
| 'workspace'
|
|
52
|
-
| 'workspace_categories'
|
|
53
|
-
| 'workspace_actions'
|
|
54
|
-
| 'workspace_action'
|
|
55
|
-
| 'run_workspace_action'
|
|
56
|
-
| 'tools'
|
|
57
|
-
| 'connected_host';
|
|
38
|
+
const MODES = [
|
|
39
|
+
'summary', 'cli_commands', 'cli_command', 'panels', 'panel', 'open_panel',
|
|
40
|
+
'shortcuts', 'keybindings', 'keybinding', 'set_keybinding', 'reset_keybinding',
|
|
41
|
+
'commands', 'command', 'run_command', 'settings', 'get_setting', 'set_setting',
|
|
42
|
+
'reset_setting', 'workspace', 'workspace_categories', 'workspace_actions',
|
|
43
|
+
'workspace_action', 'run_workspace_action', 'tools', 'connected_host',
|
|
44
|
+
] as const;
|
|
45
|
+
|
|
46
|
+
type AgentHarnessMode = typeof MODES[number];
|
|
58
47
|
|
|
59
48
|
interface AgentHarnessToolArgs {
|
|
60
49
|
readonly mode?: unknown;
|
|
@@ -68,6 +57,8 @@ interface AgentHarnessToolArgs {
|
|
|
68
57
|
readonly actionId?: unknown;
|
|
69
58
|
readonly recordId?: unknown;
|
|
70
59
|
readonly fields?: unknown;
|
|
60
|
+
readonly combo?: unknown;
|
|
61
|
+
readonly combos?: unknown;
|
|
71
62
|
readonly key?: unknown;
|
|
72
63
|
readonly value?: unknown;
|
|
73
64
|
readonly category?: unknown;
|
|
@@ -91,29 +82,6 @@ interface WorkspaceEditorContext {
|
|
|
91
82
|
readonly selectedRoutine: AgentWorkspaceLocalLibraryItem | null;
|
|
92
83
|
}
|
|
93
84
|
|
|
94
|
-
const MODES: readonly AgentHarnessMode[] = [
|
|
95
|
-
'summary',
|
|
96
|
-
'cli_commands',
|
|
97
|
-
'cli_command',
|
|
98
|
-
'panels',
|
|
99
|
-
'panel',
|
|
100
|
-
'open_panel',
|
|
101
|
-
'commands',
|
|
102
|
-
'command',
|
|
103
|
-
'run_command',
|
|
104
|
-
'settings',
|
|
105
|
-
'get_setting',
|
|
106
|
-
'set_setting',
|
|
107
|
-
'reset_setting',
|
|
108
|
-
'workspace',
|
|
109
|
-
'workspace_categories',
|
|
110
|
-
'workspace_actions',
|
|
111
|
-
'workspace_action',
|
|
112
|
-
'run_workspace_action',
|
|
113
|
-
'tools',
|
|
114
|
-
'connected_host',
|
|
115
|
-
];
|
|
116
|
-
|
|
117
85
|
function isMode(value: unknown): value is AgentHarnessMode {
|
|
118
86
|
return typeof value === 'string' && MODES.includes(value as AgentHarnessMode);
|
|
119
87
|
}
|
|
@@ -145,9 +113,14 @@ function output(value: unknown): { readonly success: true; readonly output: stri
|
|
|
145
113
|
};
|
|
146
114
|
}
|
|
147
115
|
|
|
148
|
-
function error(message: string): { readonly success: false; readonly error: string } {
|
|
149
|
-
|
|
150
|
-
|
|
116
|
+
function error(message: string): { readonly success: false; readonly error: string } { return { success: false, error: message }; }
|
|
117
|
+
|
|
118
|
+
const KEY_COMBO_PARAMETER_SCHEMA = {
|
|
119
|
+
type: 'object',
|
|
120
|
+
properties: { key: { type: 'string' }, ctrl: { type: 'boolean' }, shift: { type: 'boolean' }, alt: { type: 'boolean' } },
|
|
121
|
+
required: ['key'],
|
|
122
|
+
additionalProperties: false,
|
|
123
|
+
} as const;
|
|
151
124
|
|
|
152
125
|
function commandMatches(command: SlashCommand, query: string): boolean {
|
|
153
126
|
if (!query) return true;
|
|
@@ -541,8 +514,8 @@ export function createAgentHarnessTool(deps: AgentHarnessToolDeps): Tool {
|
|
|
541
514
|
name: 'agent_harness',
|
|
542
515
|
description: [
|
|
543
516
|
'Discover and operate the GoodVibes Agent harness from the main conversation.',
|
|
544
|
-
'Use this tool to inspect Agent workspace actions, built-in panels, top-level CLI mirrors, slash commands with policy metadata, model tools, connected-host capabilities, and Agent settings, or to invoke a workspace action/command through the same in-process command registry the user uses in the TUI.',
|
|
545
|
-
'Discovery modes are read-only. Setting writes, resets, slash command invocation, and workspace action invocation require confirm:true plus explicitUserRequest.',
|
|
517
|
+
'Use this tool to inspect Agent workspace actions, built-in panels, top-level CLI mirrors, keybindings, slash commands with policy metadata, model tools, connected-host capabilities, and Agent settings, or to invoke a workspace action/command through the same in-process command registry the user uses in the TUI.',
|
|
518
|
+
'Discovery modes are read-only. Setting/keybinding writes, resets, slash command invocation, and workspace action invocation require confirm:true plus explicitUserRequest.',
|
|
546
519
|
'This tool preserves Agent product boundaries: connected-host lifecycle and listener posture stay externally owned, connected-host mode reports allowed and blocked route families, and secret-backed settings store raw values through the secret manager while config receives only a secret reference.',
|
|
547
520
|
].join(' '),
|
|
548
521
|
parameters: {
|
|
@@ -584,13 +557,22 @@ export function createAgentHarnessTool(deps: AgentHarnessToolDeps): Tool {
|
|
|
584
557
|
},
|
|
585
558
|
actionId: {
|
|
586
559
|
type: 'string',
|
|
587
|
-
description: 'Agent workspace action id for workspace_action or run_workspace_action.',
|
|
560
|
+
description: 'Agent workspace action id for workspace_action or run_workspace_action, or keybinding action id for keybinding/set_keybinding/reset_keybinding.',
|
|
588
561
|
},
|
|
589
562
|
fields: {
|
|
590
563
|
type: 'object',
|
|
591
564
|
additionalProperties: { type: 'string' },
|
|
592
565
|
description: 'Field values for run_workspace_action when the workspace action opens an editor form.',
|
|
593
566
|
},
|
|
567
|
+
combo: {
|
|
568
|
+
...KEY_COMBO_PARAMETER_SCHEMA,
|
|
569
|
+
description: 'Single key combo for set_keybinding, for example { "key": "g", "ctrl": true }.',
|
|
570
|
+
},
|
|
571
|
+
combos: {
|
|
572
|
+
type: 'array',
|
|
573
|
+
items: KEY_COMBO_PARAMETER_SCHEMA,
|
|
574
|
+
description: 'Multiple key combos for set_keybinding.',
|
|
575
|
+
},
|
|
594
576
|
recordId: {
|
|
595
577
|
type: 'string',
|
|
596
578
|
description: 'Selected Agent-local record id for selection-based local workspace operations.',
|
|
@@ -656,6 +638,8 @@ export function createAgentHarnessTool(deps: AgentHarnessToolDeps): Tool {
|
|
|
656
638
|
cliCommands: totalHarnessCliCommands(),
|
|
657
639
|
blockedCliCommandTokens: blockedHarnessCliCommandTokens(),
|
|
658
640
|
panels: totalHarnessPanels(deps.commandContext),
|
|
641
|
+
shortcuts: totalHarnessShortcuts(deps.commandContext),
|
|
642
|
+
keybindings: totalHarnessKeybindings(deps.commandContext),
|
|
659
643
|
commands: deps.commandRegistry.list().length,
|
|
660
644
|
settings: deps.commandContext.platform.configManager.getSchema().length,
|
|
661
645
|
workspaceCategories: AGENT_WORKSPACE_CATEGORIES.length,
|
|
@@ -664,6 +648,7 @@ export function createAgentHarnessTool(deps: AgentHarnessToolDeps): Tool {
|
|
|
664
648
|
modelAccess: {
|
|
665
649
|
cliCommands: 'Use mode:"cli_commands" and mode:"cli_command" to inspect package CLI mirrors and their preferred in-process model routes. CLI modes are discovery-only.',
|
|
666
650
|
panels: 'Use mode:"panels" and mode:"panel" to inspect built-in panel catalog/open state; use mode:"open_panel" with confirm:true plus explicitUserRequest to route a visible panel/workspace change.',
|
|
651
|
+
shortcuts: 'Use mode:"shortcuts" to inspect fixed shortcuts plus configurable keybindings. Use mode:"set_keybinding" and mode:"reset_keybinding" with confirm:true plus explicitUserRequest to edit the same config file the user edits.',
|
|
667
652
|
slashCommands: 'Use mode:"commands" and mode:"command" to inspect; use mode:"run_command" with confirm:true plus explicitUserRequest to execute.',
|
|
668
653
|
workspace: 'Use mode:"workspace_actions" to list and mode:"workspace_action" for editor schemas; set includeParameters:true on workspace_actions to inline editor schemas.',
|
|
669
654
|
settings: 'Use mode:"settings", mode:"get_setting", mode:"set_setting", and mode:"reset_setting".',
|
|
@@ -705,6 +690,22 @@ export function createAgentHarnessTool(deps: AgentHarnessToolDeps): Tool {
|
|
|
705
690
|
if (confirmationError) return error(confirmationError);
|
|
706
691
|
return output(openHarnessPanel(deps.commandContext, args));
|
|
707
692
|
}
|
|
693
|
+
if (args.mode === 'shortcuts') return output(listHarnessShortcuts(deps.commandContext, args));
|
|
694
|
+
if (args.mode === 'keybindings') return output(listHarnessKeybindings(deps.commandContext, args));
|
|
695
|
+
if (args.mode === 'keybinding') {
|
|
696
|
+
const binding = describeHarnessKeybinding(deps.commandContext, args);
|
|
697
|
+
return binding ? output(binding) : error(`Unknown keybinding action ${readString(args.actionId || args.key || args.query) || '<missing>'}.`);
|
|
698
|
+
}
|
|
699
|
+
if (args.mode === 'set_keybinding') {
|
|
700
|
+
const confirmationError = requireConfirmedAction(args, 'Keybinding mutation');
|
|
701
|
+
if (confirmationError) return error(confirmationError);
|
|
702
|
+
return output(setHarnessKeybinding(deps.commandContext, args));
|
|
703
|
+
}
|
|
704
|
+
if (args.mode === 'reset_keybinding') {
|
|
705
|
+
const confirmationError = requireConfirmedAction(args, 'Keybinding reset');
|
|
706
|
+
if (confirmationError) return error(confirmationError);
|
|
707
|
+
return output(resetHarnessKeybinding(deps.commandContext, args));
|
|
708
|
+
}
|
|
708
709
|
if (args.mode === 'commands') {
|
|
709
710
|
const commands = listCommands(deps.commandRegistry, args);
|
|
710
711
|
return output({ commands, returned: commands.length, total: deps.commandRegistry.list().length });
|
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 = '1.0.
|
|
9
|
+
let _version = '1.0.4';
|
|
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 {
|