@pellux/goodvibes-agent 1.0.2 → 1.0.3

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/docs/README.md CHANGED
@@ -22,7 +22,7 @@ Important baseline constraints:
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, 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, 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.
@@ -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, slash-command discovery, command policy metadata, command execution with confirmation, model tool discovery, settings inspection/mutation, and connected-host posture. 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, 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.
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
 
@@ -43,14 +43,18 @@ 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 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 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.
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; `commands` and `command` return 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; `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
+ `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
+
57
+ 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.
54
58
 
55
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.
56
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pellux/goodvibes-agent",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
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",
package/src/cli/help.ts CHANGED
@@ -131,6 +131,15 @@ type CommandHelp = {
131
131
  readonly examples?: readonly string[];
132
132
  };
133
133
 
134
+ export interface GoodVibesCommandHelpDescriptor {
135
+ readonly command: string;
136
+ readonly aliases: readonly string[];
137
+ readonly summary: string;
138
+ readonly usage: readonly string[];
139
+ readonly subcommands: readonly string[];
140
+ readonly examples: readonly string[];
141
+ }
142
+
134
143
  const COMMAND_HELP: Record<string, CommandHelp> = {
135
144
  run: {
136
145
  usage: ['run [prompt] [--output text|json|stream-json]', 'exec [prompt]'],
@@ -416,6 +425,23 @@ export function hasGoodVibesCommandHelp(topic: string): boolean {
416
425
  return COMMAND_HELP[normalizeHelpTopic(topic)] !== undefined;
417
426
  }
418
427
 
428
+ export function describeGoodVibesCommandHelp(topic: string): GoodVibesCommandHelpDescriptor | null {
429
+ const normalized = normalizeHelpTopic(topic);
430
+ const help = COMMAND_HELP[normalized];
431
+ if (!help) return null;
432
+ return {
433
+ command: normalized,
434
+ aliases: Object.entries(HELP_ALIASES)
435
+ .filter(([, target]) => target === normalized)
436
+ .map(([alias]) => alias)
437
+ .sort(),
438
+ summary: help.summary,
439
+ usage: help.usage,
440
+ subcommands: help.subcommands ?? [],
441
+ examples: help.examples ?? [],
442
+ };
443
+ }
444
+
419
445
  export function renderGoodVibesCommandHelp(topic: string, binary = 'goodvibes-agent'): string {
420
446
  const normalized = normalizeHelpTopic(topic);
421
447
  const help = COMMAND_HELP[normalized];
@@ -0,0 +1,152 @@
1
+ import type { GoodVibesCliCommand } from '../cli/types.ts';
2
+ import { describeGoodVibesCommandHelp } from '../cli/help.ts';
3
+ import {
4
+ listBlockedGoodVibesCliCommandTokens,
5
+ listGoodVibesCliCommandTokens,
6
+ listGoodVibesCliCommands,
7
+ parseGoodVibesCli,
8
+ } from '../cli/parser.ts';
9
+ import { describeCliCommandPolicy } from './agent-harness-metadata.ts';
10
+
11
+ export interface AgentHarnessCliArgs {
12
+ readonly query?: unknown;
13
+ readonly command?: unknown;
14
+ readonly cliCommand?: unknown;
15
+ readonly commandName?: unknown;
16
+ readonly limit?: unknown;
17
+ }
18
+
19
+ function readString(value: unknown): string {
20
+ return typeof value === 'string' ? value.trim() : '';
21
+ }
22
+
23
+ function readLimit(value: unknown, fallback: number): number {
24
+ const parsed = typeof value === 'string' && value.trim() ? Number(value) : value;
25
+ if (typeof parsed !== 'number' || !Number.isFinite(parsed)) return fallback;
26
+ return Math.max(1, Math.min(500, Math.trunc(parsed)));
27
+ }
28
+
29
+ function cliCommandTokens(command: GoodVibesCliCommand): readonly string[] {
30
+ if (command === 'unknown') return [];
31
+ if (command === 'tui') return ['(no command)'];
32
+ return listGoodVibesCliCommandTokens()
33
+ .filter((token) => parseGoodVibesCli([token]).command === command)
34
+ .sort();
35
+ }
36
+
37
+ function fallbackCliSummary(command: GoodVibesCliCommand): string {
38
+ if (command === 'tui') return 'Launch the interactive Agent TUI.';
39
+ if (command === 'help') return 'Print top-level or command-specific help.';
40
+ if (command === 'version') return 'Print the installed Agent package version.';
41
+ return 'Inspect the CLI help for this Agent package command.';
42
+ }
43
+
44
+ function describeCliCommand(command: GoodVibesCliCommand): Record<string, unknown> {
45
+ const help = describeGoodVibesCommandHelp(command);
46
+ const tokens = cliCommandTokens(command);
47
+ return {
48
+ name: command,
49
+ tokens,
50
+ invocation: command === 'tui' ? 'goodvibes-agent' : `goodvibes-agent ${tokens[0] ?? command}`,
51
+ helpTopic: help?.command ?? command,
52
+ summary: help?.summary ?? fallbackCliSummary(command),
53
+ usage: help?.usage ?? (command === 'tui' ? ['goodvibes-agent [OPTIONS]'] : [`goodvibes-agent ${command} [ARGS]`]),
54
+ aliases: help?.aliases ?? tokens.filter((token) => token !== command),
55
+ subcommands: help?.subcommands ?? [],
56
+ examples: help?.examples ?? [],
57
+ policy: describeCliCommandPolicy(command),
58
+ };
59
+ }
60
+
61
+ function cliCommandMatches(command: Record<string, unknown>, query: string): boolean {
62
+ if (!query) return true;
63
+ return [
64
+ command.name,
65
+ command.tokens,
66
+ command.summary,
67
+ command.usage,
68
+ command.aliases,
69
+ command.subcommands,
70
+ command.examples,
71
+ command.policy,
72
+ ].map((value) => JSON.stringify(value)).join('\n').toLowerCase().includes(query.toLowerCase());
73
+ }
74
+
75
+ export function totalHarnessCliCommands(): number {
76
+ return listGoodVibesCliCommands().filter((command) => command !== 'unknown').length;
77
+ }
78
+
79
+ export function blockedHarnessCliCommandTokens(): readonly string[] {
80
+ return listBlockedGoodVibesCliCommandTokens();
81
+ }
82
+
83
+ export function listHarnessCliCommands(args: AgentHarnessCliArgs): readonly Record<string, unknown>[] {
84
+ const query = readString(args.query);
85
+ const limit = readLimit(args.limit, 200);
86
+ return listGoodVibesCliCommands()
87
+ .filter((command) => command !== 'unknown')
88
+ .map(describeCliCommand)
89
+ .filter((command) => cliCommandMatches(command, query))
90
+ .sort((a, b) => String(a.name).localeCompare(String(b.name)))
91
+ .slice(0, limit);
92
+ }
93
+
94
+ function cliTokensFromArgs(args: AgentHarnessCliArgs): readonly string[] {
95
+ const raw = readString(args.cliCommand) || readString(args.command) || readString(args.commandName) || readString(args.query);
96
+ if (!raw) return [];
97
+ const tokens = raw.split(/\s+/).filter((token) => token.length > 0);
98
+ if (tokens[0] === 'goodvibes-agent' || tokens[0]?.endsWith('/goodvibes-agent')) return tokens.slice(1);
99
+ return tokens;
100
+ }
101
+
102
+ export function describeHarnessCliCommand(args: AgentHarnessCliArgs): Record<string, unknown> {
103
+ const tokens = cliTokensFromArgs(args);
104
+ if (tokens.length === 0) return describeCliCommand('tui');
105
+ const parsed = parseGoodVibesCli(tokens);
106
+ if (parsed.command === 'unknown') {
107
+ return {
108
+ supported: false,
109
+ token: parsed.rawCommand ?? tokens[0],
110
+ errors: parsed.errors,
111
+ blockedTokens: blockedHarnessCliCommandTokens(),
112
+ policy: describeCliCommandPolicy(parsed.rawCommand ?? tokens[0] ?? 'unknown'),
113
+ };
114
+ }
115
+ return {
116
+ ...describeCliCommand(parsed.command),
117
+ parsed: {
118
+ command: parsed.command,
119
+ rawCommand: parsed.rawCommand,
120
+ commandArgs: parsed.commandArgs,
121
+ positionals: parsed.positionals,
122
+ flags: {
123
+ provider: parsed.flags.provider,
124
+ model: parsed.flags.model,
125
+ agentProfile: parsed.flags.agentProfile,
126
+ runtimeUrl: parsed.flags.runtimeUrl,
127
+ workingDir: parsed.flags.workingDir,
128
+ help: parsed.flags.help,
129
+ version: parsed.flags.version,
130
+ print: parsed.flags.print,
131
+ outputFormat: parsed.flags.outputFormat,
132
+ configOverrides: parsed.flags.configOverrides.map((override) => {
133
+ const index = override.indexOf('=');
134
+ return index < 0 ? override : `${override.slice(0, index)}=<redacted>`;
135
+ }),
136
+ enableFeatures: parsed.flags.enableFeatures,
137
+ disableFeatures: parsed.flags.disableFeatures,
138
+ noAltScreen: parsed.flags.noAltScreen,
139
+ port: parsed.flags.port,
140
+ hostname: parsed.flags.hostname,
141
+ open: parsed.flags.open,
142
+ continueLast: parsed.flags.continueLast,
143
+ resume: parsed.flags.resume,
144
+ session: parsed.flags.session,
145
+ fork: parsed.flags.fork,
146
+ rawOutput: parsed.flags.rawOutput,
147
+ acceptRawOutputRisk: parsed.flags.acceptRawOutputRisk,
148
+ },
149
+ errors: parsed.errors,
150
+ },
151
+ };
152
+ }
@@ -1,4 +1,6 @@
1
1
  import type { ToolRegistry } from '@pellux/goodvibes-sdk/platform/tools';
2
+ import type { CommandContext } from '../input/command-registry.ts';
3
+ import { resolveAgentConnectedHostConnection } from '../agent/routine-schedule-promotion.ts';
2
4
 
3
5
  export interface CommandExecutionPolicy {
4
6
  readonly effect: 'read-only' | 'local-state' | 'connected-host-state' | 'external-network' | 'ui-navigation' | 'session-lifecycle' | 'delegated-work' | 'mixed' | 'unknown';
@@ -132,6 +134,96 @@ export function describeCommandPolicy(commandName: string): CommandExecutionPoli
132
134
  };
133
135
  }
134
136
 
137
+ export function describeCliCommandPolicy(commandName: string): CommandExecutionPolicy {
138
+ const root = commandName.trim().toLowerCase();
139
+ const confirmation = 'agent_harness CLI command modes are discovery-only. Use first-class model tools, workspace actions, slash-command mirrors, or an explicit external shell request to execute equivalent CLI workflows.';
140
+ if ([
141
+ 'app',
142
+ 'bridge',
143
+ 'control-plane',
144
+ 'controlplane',
145
+ 'cp',
146
+ 'daemon',
147
+ 'http-listener',
148
+ 'launch',
149
+ 'listener',
150
+ 'remote',
151
+ 'serve',
152
+ 'server',
153
+ 'service',
154
+ 'services',
155
+ 'start',
156
+ 'surface',
157
+ 'surfaces',
158
+ 'web',
159
+ 'webhook',
160
+ ].includes(root)) {
161
+ return {
162
+ effect: 'unknown',
163
+ confirmation,
164
+ boundary: 'Blocked package CLI token. Agent can launch its own TUI and use public connected-host routes, but it does not manage connected-host lifecycle, listeners, servers, bridges, remotes, web surfaces, or webhook listeners.',
165
+ };
166
+ }
167
+ if (root === 'tui' || root === 'onboarding' || root === 'help' || root === 'version' || root === 'completion') {
168
+ return {
169
+ effect: root === 'tui' || root === 'onboarding' ? 'ui-navigation' : 'read-only',
170
+ confirmation,
171
+ preferredModelTool: root === 'onboarding' || root === 'tui' ? 'agent_harness workspace/workspace_actions' : 'agent_harness cli_commands/cli_command',
172
+ boundary: 'Top-level CLI launch, setup, help, version, and completion commands are package entrypoint surfaces; use in-process workspace and slash-command bridges from the model when operating inside the TUI.',
173
+ };
174
+ }
175
+ if (root === 'run') {
176
+ return {
177
+ effect: 'mixed',
178
+ confirmation,
179
+ boundary: 'The CLI run command starts a non-interactive Agent turn from a process entrypoint. Do not create hidden nested turns from agent_harness; answer the user directly in the current conversation.',
180
+ };
181
+ }
182
+ if (root === 'status' || root === 'doctor' || root === 'auth' || root === 'compat' || root === 'models' || root === 'providers' || root === 'tasks') {
183
+ return {
184
+ effect: 'read-only',
185
+ confirmation,
186
+ preferredModelTool: root === 'tasks' ? 'agent_operator_briefing' : 'agent_harness connected_host/settings/tools',
187
+ boundary: 'Diagnostics and posture commands are readable from Agent-owned settings, provider, model, and connected-host capability surfaces without taking connected-host lifecycle ownership.',
188
+ };
189
+ }
190
+ if (root === 'profiles' || root === 'personas' || root === 'skills' || root === 'memory' || root === 'routines' || root === 'sessions' || root === 'bundle') {
191
+ return {
192
+ effect: 'local-state',
193
+ confirmation,
194
+ preferredModelTool: root === 'profiles' ? 'agent_harness workspace_actions/run_workspace_action' : 'agent_local_registry',
195
+ boundary: 'Local library/profile/session/bundle CLI commands operate on Agent-local data. Mutations require explicit user intent and should use first-class Agent-local tools where available.',
196
+ };
197
+ }
198
+ if (root === 'knowledge' || root === 'ask' || root === 'search') {
199
+ return {
200
+ effect: 'mixed',
201
+ confirmation,
202
+ preferredModelTool: root === 'knowledge' ? 'agent_knowledge or agent_knowledge_ingest' : 'agent_knowledge',
203
+ boundary: 'Agent Knowledge CLI commands must stay on isolated Agent Knowledge routes and never fall back to default or non-Agent knowledge spaces.',
204
+ };
205
+ }
206
+ if (root === 'delegate') {
207
+ return {
208
+ effect: 'delegated-work',
209
+ confirmation,
210
+ boundary: 'Delegation is explicit user-directed work only; no hidden background review or separate Agent job should be created implicitly.',
211
+ };
212
+ }
213
+ if (root === 'subscription' || root === 'secrets' || root === 'pair') {
214
+ return {
215
+ effect: root === 'pair' ? 'external-network' : 'mixed',
216
+ confirmation,
217
+ boundary: 'Provider subscription, secret, and pairing flows can expose credentials or external account state. Use only explicit user-directed flows and prefer secret refs over raw values.',
218
+ };
219
+ }
220
+ return {
221
+ effect: 'unknown',
222
+ confirmation,
223
+ boundary: 'Inspect the CLI help, parser result, and preferred model routes before using an equivalent command path.',
224
+ };
225
+ }
226
+
135
227
  function toolIsAvailable(toolRegistry: ToolRegistry, toolName: string): boolean {
136
228
  return toolRegistry.getToolDefinitions().some((tool) => tool.name === toolName);
137
229
  }
@@ -264,6 +356,22 @@ export function connectedHostRouteFamilies(): readonly Record<string, unknown>[]
264
356
  ];
265
357
  }
266
358
 
359
+ export function connectedHostSummary(context: CommandContext, toolRegistry: ToolRegistry): Record<string, unknown> {
360
+ const shellPaths = context.workspace.shellPaths;
361
+ const homeDirectory = shellPaths?.homeDirectory ?? context.platform.configManager.getHomeDirectory() ?? '';
362
+ const connection = resolveAgentConnectedHostConnection(context.platform.configManager, homeDirectory);
363
+ return {
364
+ baseUrl: connection.baseUrl,
365
+ operatorToken: connection.token ? 'configured' : 'missing',
366
+ tokenPath: connection.tokenPath,
367
+ ownership: 'external-connected-host',
368
+ lifecycle: 'GoodVibes Agent can use public connected-host operator routes, but does not start, stop, restart, install, expose, or mutate the host listener.',
369
+ routeFamilies: connectedHostRouteFamilies(),
370
+ capabilities: connectedHostCapabilityMap(toolRegistry),
371
+ blockedCapabilities: blockedConnectedHostCapabilities(),
372
+ };
373
+ }
374
+
267
375
  export function blockedConnectedHostCapabilities(): readonly Record<string, unknown>[] {
268
376
  return [
269
377
  {
@@ -0,0 +1,36 @@
1
+ import type { ToolRegistry } from '@pellux/goodvibes-sdk/platform/tools';
2
+
3
+ export interface AgentHarnessModelToolCatalogArgs {
4
+ readonly query?: unknown;
5
+ readonly includeParameters?: unknown;
6
+ readonly limit?: unknown;
7
+ }
8
+
9
+ function readString(value: unknown): string {
10
+ return typeof value === 'string' ? value.trim() : '';
11
+ }
12
+
13
+ function readLimit(value: unknown, fallback: number): number {
14
+ const parsed = typeof value === 'string' && value.trim() ? Number(value) : value;
15
+ if (typeof parsed !== 'number' || !Number.isFinite(parsed)) return fallback;
16
+ return Math.max(1, Math.min(500, Math.trunc(parsed)));
17
+ }
18
+
19
+ export function listHarnessModelTools(toolRegistry: ToolRegistry, args: AgentHarnessModelToolCatalogArgs): readonly Record<string, unknown>[] {
20
+ const query = readString(args.query).toLowerCase();
21
+ const includeParameters = args.includeParameters === true;
22
+ const limit = readLimit(args.limit, 200);
23
+ return toolRegistry.getToolDefinitions()
24
+ .filter((tool) => !query || [tool.name, tool.description, ...(tool.sideEffects ?? [])].join('\n').toLowerCase().includes(query))
25
+ .sort((a, b) => a.name.localeCompare(b.name))
26
+ .slice(0, limit)
27
+ .map((tool) => ({
28
+ name: tool.name,
29
+ description: tool.description,
30
+ sideEffects: tool.sideEffects ?? [],
31
+ concurrency: tool.concurrency ?? 'parallel',
32
+ supportsProgress: tool.supportsProgress ?? false,
33
+ supportsStreamingOutput: tool.supportsStreamingOutput ?? false,
34
+ ...(includeParameters ? { parameters: tool.parameters } : {}),
35
+ }));
36
+ }
@@ -0,0 +1,121 @@
1
+ import type { CommandContext } from '../input/command-registry.ts';
2
+ import { agentWorkspaceCategoryForPanel, agentWorkspaceCommandForPanel } from '../input/agent-workspace-panel-route.ts';
3
+ import type { PanelRegistration } from '../panels/types.ts';
4
+
5
+ export interface AgentHarnessPanelArgs {
6
+ readonly query?: unknown;
7
+ readonly panelId?: unknown;
8
+ readonly category?: unknown;
9
+ readonly limit?: unknown;
10
+ readonly pane?: unknown;
11
+ }
12
+
13
+ function readString(value: unknown): string {
14
+ return typeof value === 'string' ? value.trim() : '';
15
+ }
16
+
17
+ function readLimit(value: unknown, fallback: number): number {
18
+ const parsed = typeof value === 'string' && value.trim() ? Number(value) : value;
19
+ if (typeof parsed !== 'number' || !Number.isFinite(parsed)) return fallback;
20
+ return Math.max(1, Math.min(500, Math.trunc(parsed)));
21
+ }
22
+
23
+ function panelManager(context: CommandContext) {
24
+ return context.workspace.panelManager ?? null;
25
+ }
26
+
27
+ function panelMatches(panel: Record<string, unknown>, query: string): boolean {
28
+ if (!query) return true;
29
+ return [
30
+ panel.id,
31
+ panel.name,
32
+ panel.category,
33
+ panel.description,
34
+ panel.workspaceRoute,
35
+ ].map((value) => String(value ?? '')).join('\n').toLowerCase().includes(query.toLowerCase());
36
+ }
37
+
38
+ function describePanelRegistration(context: CommandContext, registration: PanelRegistration): Record<string, unknown> {
39
+ const manager = panelManager(context);
40
+ const openPanel = manager?.getPanel(registration.id) ?? null;
41
+ const pane = manager?.getPaneOf(registration.id) ?? null;
42
+ const activePanel = manager?.getActivePanel() ?? null;
43
+ return {
44
+ id: registration.id,
45
+ name: registration.name,
46
+ icon: registration.icon,
47
+ category: registration.category,
48
+ description: registration.description,
49
+ preload: registration.preload === true,
50
+ open: openPanel !== null,
51
+ pane,
52
+ active: activePanel?.id === registration.id,
53
+ focused: activePanel?.id === registration.id,
54
+ workspaceRoute: {
55
+ categoryId: agentWorkspaceCategoryForPanel(registration.id),
56
+ command: agentWorkspaceCommandForPanel(registration.id),
57
+ },
58
+ policy: {
59
+ effect: 'ui-navigation',
60
+ confirmation: 'agent_harness mode:"open_panel" requires confirm:true and explicitUserRequest.',
61
+ boundary: 'Panels are Agent/TUI operator views. The model can inspect panel catalog/open state; panel routing uses the existing Agent workspace bridge and does not mutate connected-host lifecycle.',
62
+ },
63
+ };
64
+ }
65
+
66
+ export function totalHarnessPanels(context: CommandContext): number {
67
+ return panelManager(context)?.getRegisteredTypes().length ?? 0;
68
+ }
69
+
70
+ export function listHarnessPanels(context: CommandContext, args: AgentHarnessPanelArgs): readonly Record<string, unknown>[] {
71
+ const manager = panelManager(context);
72
+ if (!manager) return [];
73
+ const query = readString(args.query);
74
+ const category = readString(args.category);
75
+ const limit = readLimit(args.limit, 200);
76
+ return manager.getRegisteredTypes()
77
+ .map((registration) => describePanelRegistration(context, registration))
78
+ .filter((panel) => !category || panel.category === category)
79
+ .filter((panel) => panelMatches(panel, query))
80
+ .sort((a, b) => String(a.id).localeCompare(String(b.id)))
81
+ .slice(0, limit);
82
+ }
83
+
84
+ export function describeHarnessPanel(context: CommandContext, args: AgentHarnessPanelArgs): Record<string, unknown> | null {
85
+ const manager = panelManager(context);
86
+ if (!manager) return null;
87
+ const panelId = readString(args.panelId || args.query);
88
+ if (!panelId) return null;
89
+ const registration = manager.getRegisteredTypes().find((panel) => (
90
+ panel.id === panelId
91
+ || panel.name.toLowerCase() === panelId.toLowerCase()
92
+ ));
93
+ return registration ? describePanelRegistration(context, registration) : null;
94
+ }
95
+
96
+ export function openHarnessPanel(context: CommandContext, args: AgentHarnessPanelArgs): Record<string, unknown> {
97
+ const panel = describeHarnessPanel(context, args);
98
+ if (!panel) {
99
+ return {
100
+ status: 'unknown_panel',
101
+ panelId: readString(args.panelId || args.query) || '<missing>',
102
+ availablePanels: listHarnessPanels(context, { limit: 50 }).map((entry) => entry.id),
103
+ };
104
+ }
105
+ const requestedPane = readString(args.pane);
106
+ const pane = requestedPane === 'bottom' || requestedPane === 'top' ? requestedPane : undefined;
107
+ if (!context.showPanel) {
108
+ return {
109
+ status: 'route_unavailable',
110
+ panel,
111
+ note: 'The current runtime did not provide showPanel. Use the returned workspaceRoute from the TUI.',
112
+ };
113
+ }
114
+ context.showPanel(String(panel.id), pane);
115
+ return {
116
+ status: 'routed',
117
+ panel,
118
+ pane: pane ?? 'default',
119
+ note: 'Panel routing was handed to the current Agent shell bridge.',
120
+ };
121
+ }