@robota-sdk/agent-command 3.0.0-beta.65 → 3.0.0-beta.66
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/README.md +74 -0
- package/dist/node/index.cjs +28 -28
- package/dist/node/index.d.ts +35 -5
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +28 -28
- package/dist/node/index.js.map +1 -1
- package/package.json +5 -3
- package/src/agent/agent-command-module.ts +2 -1
- package/src/agent/agent-command.ts +4 -2
- package/src/background/background-command-module.ts +7 -5
- package/src/background/background-command.ts +2 -1
- package/src/compact/compact-command-module.ts +2 -1
- package/src/compact/compact-command.ts +2 -1
- package/src/context/context-command-module.ts +2 -1
- package/src/context/context-command.ts +7 -6
- package/src/default/default-command-modules.ts +64 -0
- package/src/default/index.ts +2 -0
- package/src/exit/exit-command-module.ts +4 -2
- package/src/exit/exit-command.ts +2 -1
- package/src/help/help-command-module.ts +4 -2
- package/src/help/help-command.ts +2 -1
- package/src/index.ts +3 -0
- package/src/language/language-command-module.ts +8 -6
- package/src/language/language-command.ts +2 -1
- package/src/memory/memory-command-module.ts +8 -6
- package/src/memory/memory-command.ts +9 -8
- package/src/mode/mode-command-module.ts +8 -6
- package/src/mode/mode-command.ts +2 -1
- package/src/model/model-command-module.ts +8 -6
- package/src/model/model-command.ts +2 -1
- package/src/permissions/permissions-command-module.ts +8 -6
- package/src/permissions/permissions-command.ts +2 -1
- package/src/plugin/plugin-command-module.ts +8 -6
- package/src/plugin/plugin-command.ts +6 -5
- package/src/plugins/default-plugin-command-adapter.ts +164 -0
- package/src/plugins/default-plugin-command-source-loader.ts +31 -0
- package/src/provider/__tests__/provider-setup-flow.test.ts +204 -3
- package/src/provider/index.ts +2 -0
- package/src/provider/provider-command-execution.ts +11 -6
- package/src/provider/provider-command-module.ts +2 -1
- package/src/provider/provider-command-profile-lifecycle.ts +11 -6
- package/src/provider/provider-command-profile-operations.ts +11 -9
- package/src/provider/provider-command-profile.ts +12 -10
- package/src/provider/provider-command-setup.ts +10 -8
- package/src/provider/provider-setup-flow.ts +3 -2
- package/src/provider/provider-startup.ts +117 -0
- package/src/reset/reset-command-module.ts +2 -1
- package/src/rewind/rewind-command-module.ts +8 -6
- package/src/rewind/rewind-command.ts +7 -6
- package/src/session/session-command-module.ts +8 -6
- package/src/session/session-command.ts +2 -1
- package/src/skills/skills-command-module.ts +7 -7
- package/src/statusline/statusline-command-module.ts +8 -6
- package/src/statusline/statusline-command.ts +2 -1
- package/src/user-local/user-local-command-module.ts +6 -5
- package/src/user-local/user-local-command.ts +4 -2
- package/src/user-local/user-local-memory-command.ts +3 -1
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["formatError","SUBCOMMAND_INDEX","usage","formatError","formatList","usage","PROVIDER_RESTART_EFFECT","YES","PROVIDER_RESTART_EFFECT","executeMemoryCommand","executeMemoryCommand"],"sources":["../../src/agent/agent-command-parser.ts","../../src/agent/agent-command.ts","../../src/agent/agent-command-module.ts","../../src/background/background-command.ts","../../src/background/background-command-module.ts","../../src/compact/compact-command.ts","../../src/compact/compact-command-module.ts","../../src/context/context-command.ts","../../src/context/context-command-module.ts","../../src/exit/exit-command.ts","../../src/exit/exit-command-module.ts","../../src/help/help-command.ts","../../src/help/help-command-module.ts","../../src/language/language-command.ts","../../src/language/language-command-module.ts","../../src/memory/memory-command.ts","../../src/memory/memory-command-module.ts","../../src/mode/mode-command.ts","../../src/mode/mode-command-module.ts","../../src/model/model-command.ts","../../src/model/model-command-module.ts","../../src/permissions/permissions-command.ts","../../src/permissions/permissions-command-module.ts","../../src/plugin/plugin-command.ts","../../src/plugin/plugin-command-module.ts","../../src/provider/provider-setup-flow.ts","../../src/provider/provider-command-setup.ts","../../src/provider/provider-command-profile-operations.ts","../../src/provider/provider-command-profile-lifecycle.ts","../../src/provider/provider-command-profile.ts","../../src/provider/provider-command-execution.ts","../../src/provider/provider-command-module.ts","../../src/reset/reset-command.ts","../../src/reset/reset-command-module.ts","../../src/rewind/rewind-command.ts","../../src/rewind/rewind-command-module.ts","../../src/session/session-command.ts","../../src/session/session-command-module.ts","../../src/settings/settings-command-module.ts","../../src/skills/skills-command.ts","../../src/skills/skills-command-module.ts","../../src/statusline/statusline-command.ts","../../src/statusline/statusline-command-module.ts","../../src/user-local/user-local-command-constants.ts","../../src/user-local/user-local-memory-command.ts","../../src/user-local/user-local-command.ts","../../src/user-local/user-local-command-module.ts"],"sourcesContent":["import type { TBackgroundTaskIsolation } from '@robota-sdk/agent-framework';\n\nexport const DEFAULT_AGENT_TYPE = 'general-purpose';\n\nexport type TAgentMode = 'background';\n\nexport interface IAgentRunRequest {\n readonly agentType: string;\n readonly label: string;\n readonly mode: TAgentMode;\n readonly prompt: string;\n readonly model?: string;\n readonly isolation?: TBackgroundTaskIsolation;\n}\n\ninterface IParsedAgentOptions {\n readonly agentType?: string;\n readonly model?: string;\n readonly isolation?: TBackgroundTaskIsolation;\n readonly positional: string[];\n}\n\nexport function tokenizeArgs(args: string): string[] {\n const tokens: string[] = [];\n let current = '';\n let quote: '\"' | \"'\" | undefined;\n let escaped = false;\n\n for (const char of args) {\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n if (quote && char === '\\\\') {\n escaped = true;\n continue;\n }\n if (quote) {\n if (char === quote) quote = undefined;\n else current += char;\n continue;\n }\n if (char === '\"' || char === \"'\") {\n quote = char;\n continue;\n }\n if (/\\s/.test(char)) {\n if (current.length > 0) {\n tokens.push(current);\n current = '';\n }\n continue;\n }\n current += char;\n }\n\n if (current.length > 0) tokens.push(current);\n return tokens;\n}\n\nfunction parseOptions(tokens: readonly string[]): IParsedAgentOptions {\n const positional: string[] = [];\n let agentType: string | undefined;\n let model: string | undefined;\n let isolation: TBackgroundTaskIsolation | undefined;\n\n for (let index = 0; index < tokens.length; index += 1) {\n const token = tokens[index];\n if (token === '--background') {\n continue;\n }\n if (token === '--agent' || token === '--type' || token === '-a') {\n agentType = tokens[index + 1];\n index += 1;\n continue;\n }\n if (token === '--model') {\n model = tokens[index + 1];\n index += 1;\n continue;\n }\n if (token === '--isolation') {\n const value = tokens[index + 1];\n if (value === 'none' || value === 'worktree') isolation = value;\n index += 1;\n continue;\n }\n if (token !== undefined) positional.push(token);\n }\n\n return {\n positional,\n ...(agentType ? { agentType } : {}),\n ...(model ? { model } : {}),\n ...(isolation ? { isolation } : {}),\n };\n}\n\nfunction createRequest(\n options: IParsedAgentOptions,\n agentType: string,\n label: string,\n prompt: string,\n): IAgentRunRequest {\n return {\n agentType,\n label,\n mode: 'background',\n prompt,\n ...(options.model ? { model: options.model } : {}),\n ...(options.isolation ? { isolation: options.isolation } : {}),\n };\n}\n\nexport function parseRunRequest(\n tokens: readonly string[],\n availableAgentNames: ReadonlySet<string>,\n): IAgentRunRequest | undefined {\n const options = parseOptions(tokens);\n const [first, ...rest] = options.positional;\n let agentType = options.agentType ?? DEFAULT_AGENT_TYPE;\n let promptParts = options.positional;\n\n if (!options.agentType && first && availableAgentNames.has(first)) {\n agentType = first;\n promptParts = rest;\n }\n\n const prompt = promptParts.join(' ').trim();\n if (!prompt) return undefined;\n return createRequest(options, agentType, agentType, prompt);\n}\n\nexport function parseParallelRequests(\n tokens: readonly string[],\n availableAgentNames: ReadonlySet<string>,\n): IAgentRunRequest[] {\n const options = parseOptions(tokens);\n return options.positional\n .map((token) => parseAgentJobToken(token, options, availableAgentNames))\n .filter((job): job is IAgentRunRequest => job !== undefined);\n}\n\nfunction parseAgentJobToken(\n token: string,\n options: IParsedAgentOptions,\n availableAgentNames: ReadonlySet<string>,\n): IAgentRunRequest | undefined {\n const equalsIndex = token.indexOf('=');\n if (equalsIndex > 0) {\n const label = token.slice(0, equalsIndex);\n const spec = token.slice(equalsIndex + 1);\n return parseAgentPromptSpec(label, spec, options, availableAgentNames);\n }\n\n const colonIndex = token.indexOf(':');\n if (colonIndex <= 0 || colonIndex === token.length - 1) return undefined;\n const head = token.slice(0, colonIndex);\n const prompt = token.slice(colonIndex + 1);\n const agentType =\n options.agentType ?? (availableAgentNames.has(head) ? head : DEFAULT_AGENT_TYPE);\n return createRequest(options, agentType, head, prompt);\n}\n\nfunction parseAgentPromptSpec(\n label: string,\n spec: string,\n options: IParsedAgentOptions,\n availableAgentNames: ReadonlySet<string>,\n): IAgentRunRequest | undefined {\n const colonIndex = spec.indexOf(':');\n if (colonIndex === -1) {\n const agentType =\n options.agentType ?? (availableAgentNames.has(label) ? label : DEFAULT_AGENT_TYPE);\n return createRequest(options, agentType, label, spec);\n }\n if (colonIndex === 0 || colonIndex === spec.length - 1) return undefined;\n return createRequest(options, spec.slice(0, colonIndex), label, spec.slice(colonIndex + 1));\n}\n","import { summarizeBackgroundJobGroup } from '@robota-sdk/agent-framework';\nimport type {\n IAgentJobHostContext,\n ICommandResult,\n ISubagentJobState,\n} from '@robota-sdk/agent-framework';\nimport { parseParallelRequests, parseRunRequest, tokenizeArgs } from './agent-command-parser.js';\nimport type { IAgentRunRequest } from './agent-command-parser.js';\n\nfunction formatError<TError>(error: TError): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction getAvailableAgentNames(session: IAgentJobHostContext): ReadonlySet<string> {\n return new Set(session.listAgentDefinitions().map((agent) => agent.name));\n}\n\nfunction validateAgentType(\n session: IAgentJobHostContext,\n agentType: string,\n): ICommandResult | undefined {\n const agents = session.listAgentDefinitions();\n if (agents.some((agent) => agent.name === agentType)) return undefined;\n return {\n message: `Unknown agent type: ${agentType}\\nAvailable agents: ${agents.map((agent) => agent.name).join(', ')}`,\n success: false,\n };\n}\n\nasync function spawnAgentJob(\n session: IAgentJobHostContext,\n request: IAgentRunRequest,\n): Promise<ICommandResult | { state: ISubagentJobState }> {\n const invalid = validateAgentType(session, request.agentType);\n if (invalid) return invalid;\n try {\n return { state: await session.spawnAgentJob(request) };\n } catch (error) {\n return { message: formatError(error), success: false };\n }\n}\n\nfunction executeOpenSwitcher(): ICommandResult {\n return { message: '', effects: [{ type: 'agent-switcher-requested' }], success: true };\n}\n\nasync function executeList(session: IAgentJobHostContext): Promise<ICommandResult> {\n const agents = session.listAgentDefinitions();\n const jobs = session.listAgentJobs();\n const lines = [\n 'Available agents:',\n ...agents.map((agent) => ` ${agent.name} - ${agent.description}`),\n '',\n jobs.length === 0 ? 'No active agent jobs.' : 'Agent jobs:',\n ...jobs.map((job) => ` ${formatAgentJobLine(job)}`),\n ];\n return {\n message: lines.join('\\n'),\n success: true,\n data: { agents: agents.length, jobs: jobs.length },\n };\n}\n\nfunction formatAgentJobLine(job: ISubagentJobState): string {\n const worktree = [\n job.worktreePath ? `worktree=${job.worktreePath}` : undefined,\n job.branchName ? `branch=${job.branchName}` : undefined,\n ].filter((segment): segment is string => segment !== undefined);\n const metadata = worktree.length > 0 ? ` ${worktree.join(' ')}` : '';\n return `${job.id} [${job.status}${metadata}] ${job.label} - ${job.promptPreview}`;\n}\n\nasync function executeRun(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const request = parseRunRequest(tokens, getAvailableAgentNames(session));\n if (!request) {\n return {\n message: 'Usage: agent run [AGENT_NAME] [--agent AGENT_NAME] PROMPT',\n success: false,\n };\n }\n\n const spawned = await spawnAgentJob(session, request);\n if ('success' in spawned) return spawned;\n const { state } = spawned;\n\n return {\n message: `Started agent job: ${state.id}`,\n success: true,\n data: { agentId: state.id, status: state.status },\n };\n}\n\nasync function executeParallel(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const wait = tokens.includes('--wait') || !tokens.includes('--detach');\n const commandTokens = tokens.filter((token) => token !== '--wait' && token !== '--detach');\n const jobs = parseParallelRequests(commandTokens, getAvailableAgentNames(session));\n\n if (jobs.length === 0) {\n return {\n message: 'Usage: agent parallel [--wait|--detach] LABEL:\"PROMPT\" [LABEL=AGENT_NAME:\"PROMPT\"]',\n success: false,\n };\n }\n\n const invalid = jobs\n .map((job) => validateAgentType(session, job.agentType))\n .find((result): result is ICommandResult => result !== undefined);\n if (invalid) return invalid;\n\n let states: ISubagentJobState[];\n try {\n states = await Promise.all(jobs.map((job) => session.spawnAgentJob(job)));\n } catch (error) {\n return { message: formatError(error), success: false };\n }\n const group = session.createBackgroundJobGroup({\n waitPolicy: 'wait_all',\n taskIds: states.map((state) => state.id),\n label: 'agent parallel',\n });\n\n if (wait) {\n const completed = await session.waitBackgroundJobGroup(group.id);\n const summary = summarizeBackgroundJobGroup(completed);\n return {\n message: formatGroupSummary(summary),\n success: true,\n data: { agentIds: states.map((state) => state.id), groupId: group.id, summary },\n };\n }\n\n return {\n message: ['Started agent jobs:', ...states.map((state) => `${state.label}: ${state.id}`)].join(\n '\\n',\n ),\n success: true,\n data: { agentIds: states.map((state) => state.id), groupId: group.id },\n };\n}\n\nasync function executeWait(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const [groupId] = tokens;\n if (!groupId) return { message: 'Usage: agent wait GROUP_ID', success: false };\n const completed = await session.waitBackgroundJobGroup(groupId);\n const summary = summarizeBackgroundJobGroup(completed);\n return {\n message: formatGroupSummary(summary),\n success: true,\n data: { groupId, summary },\n };\n}\n\nasync function executeRead(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const [agentId, offset] = tokens;\n if (!agentId) return { message: 'Usage: agent read AGENT_ID [OFFSET]', success: false };\n const cursor = offset ? { offset: Number.parseInt(offset, 10) } : undefined;\n const page = await session.readBackgroundTaskLog(agentId, cursor);\n const next = page.nextCursor ? `\\nNext offset: ${page.nextCursor.offset}` : '';\n return {\n message: page.lines.length > 0 ? `${page.lines.join('\\n')}${next}` : `No log lines: ${agentId}`,\n success: true,\n data: { agentId, nextOffset: page.nextCursor?.offset },\n };\n}\n\nasync function executeSend(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const [agentId, ...promptParts] = tokens;\n const prompt = promptParts.join(' ').trim();\n if (!agentId || !prompt) {\n return { message: 'Usage: agent send AGENT_ID PROMPT', success: false };\n }\n await session.sendAgentJob(agentId, prompt);\n return { message: `Sent input to agent job: ${agentId}`, success: true, data: { agentId } };\n}\n\nasync function executeStop(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const [agentId, ...reasonParts] = tokens;\n if (!agentId) return { message: 'Usage: agent stop AGENT_ID [REASON]', success: false };\n await session.cancelAgentJob(agentId, reasonParts.join(' ') || undefined);\n return { message: `Agent job stopped: ${agentId}`, success: true, data: { agentId } };\n}\n\nasync function executeClose(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const [agentId] = tokens;\n if (!agentId) return { message: 'Usage: agent close AGENT_ID', success: false };\n await session.closeAgentJob(agentId);\n return { message: `Agent job closed: ${agentId}`, success: true, data: { agentId } };\n}\n\nexport async function executeAgentCommand(\n session: IAgentJobHostContext,\n args: string,\n): Promise<ICommandResult> {\n try {\n if (args.trim() === '') return executeOpenSwitcher();\n const [action = 'list', ...tokens] = tokenizeArgs(args);\n if (action === 'list' && tokens.length === 0) return executeList(session);\n if (action === 'run') return executeRun(session, tokens);\n if (action === 'parallel') return executeParallel(session, tokens);\n if (action === 'wait') return executeWait(session, tokens);\n if (action === 'read' || action === 'open') return executeRead(session, tokens);\n if (action === 'send') return executeSend(session, tokens);\n if (action === 'stop' || action === 'cancel') return executeStop(session, tokens);\n if (action === 'close') return executeClose(session, tokens);\n return executeRun(session, [action, ...tokens]);\n } catch (error) {\n return { message: formatError(error), success: false };\n }\n}\n\nfunction formatGroupSummary(summary: ReturnType<typeof summarizeBackgroundJobGroup>): string {\n const header = `Background job group ${summary.groupId}: ${summary.status} (${summary.completed}/${summary.total} completed, ${summary.failed} failed, ${summary.cancelled} cancelled, ${summary.pending} pending)`;\n return [header, ...summary.lines].join('\\n');\n}\n","import type {\n IAgentJobHostContext,\n ICommand,\n ICommandHostContext,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport { executeAgentCommand } from './agent-command.js';\n\nfunction getAgentHostContext(context: ICommandHostContext): IAgentJobHostContext {\n const cap = context.getAgentJobCapability?.();\n if (!cap) throw new Error('Agent job capability is not available in this context.');\n return cap;\n}\n\nfunction createAgentSubcommands(): ICommand[] {\n return [\n { name: 'list', description: 'List available agents and active jobs', source: 'agent' },\n { name: 'run', description: 'Start one background agent job', source: 'agent' },\n { name: 'parallel', description: 'Run multiple agents in parallel', source: 'agent' },\n { name: 'wait', description: 'Wait for a background agent group summary', source: 'agent' },\n { name: 'read', description: 'Read an agent job log page', source: 'agent' },\n { name: 'send', description: 'Send follow-up input to an agent job', source: 'agent' },\n { name: 'stop', description: 'Cancel a running agent job', source: 'agent' },\n { name: 'close', description: 'Dismiss a terminal agent job', source: 'agent' },\n { name: 'open', description: 'Focus an agent job detail view when supported', source: 'agent' },\n ];\n}\n\nexport function createAgentCommandEntry(): ICommand {\n return {\n name: 'agent',\n description: [\n 'Subagent jobs command.',\n 'Natural-language arguments start one background agent job.',\n 'When the user explicitly asks to create, run, spawn, delegate to, or use agents/subagents, start the requested agent command immediately and do not ask a follow-up question unless execution is impossible or unsafe.',\n 'If the target item is unspecified, include target selection inside the agent prompt instead of delaying execution.',\n 'The parallel form starts multiple background agent jobs as a wait_all group and returns a consolidated group summary unless --detach is present.',\n 'list, wait, read, send, stop, close, and open manage existing agent jobs.',\n ].join(' '),\n source: 'agent',\n modelInvocable: true,\n argumentHint:\n 'PROMPT | AGENT_NAME PROMPT | list | parallel [--wait|--detach] LABEL:\"PROMPT\" [LABEL=AGENT_NAME:\"PROMPT\"] | wait GROUP_ID | read AGENT_ID [OFFSET] | send AGENT_ID PROMPT | stop AGENT_ID | close AGENT_ID',\n safety: 'background-agent',\n subcommands: createAgentSubcommands(),\n };\n}\n\nexport function createAgentSystemCommand(): ISystemCommand {\n const entry = createAgentCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n execute: (context, args) => executeAgentCommand(getAgentHostContext(context), args),\n ...(entry.modelInvocable !== undefined ? { modelInvocable: entry.modelInvocable } : {}),\n ...(entry.userInvocable !== undefined ? { userInvocable: entry.userInvocable } : {}),\n ...(entry.argumentHint !== undefined ? { argumentHint: entry.argumentHint } : {}),\n ...(entry.safety !== undefined ? { safety: entry.safety } : {}),\n };\n}\n\nexport class AgentCommandSource implements ICommandSource {\n readonly name = 'agent';\n\n getCommands(): ICommand[] {\n return [createAgentCommandEntry()];\n }\n}\n\nexport function createAgentCommandModule(): ICommandModule {\n return {\n name: 'agent-command-agent',\n commandSources: [new AgentCommandSource()],\n systemCommands: [createAgentSystemCommand()],\n sessionRequirements: ['agent-runtime'],\n };\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\nimport {\n BACKGROUND_COMMAND_USAGE,\n cancelCommandBackgroundTask,\n closeCommandBackgroundTask,\n formatCommandBackgroundTaskList,\n listCommandBackgroundTasks,\n parseCommandBackgroundLogCursor,\n readCommandBackgroundTaskLog,\n} from '@robota-sdk/agent-framework';\n\nfunction parseCommandParts(args: string): string[] {\n return args.trim().split(/\\s+/).filter(Boolean);\n}\n\nexport async function executeBackgroundCommand(\n context: ICommandHostContext,\n args: string,\n): Promise<ICommandResult> {\n const [action = 'list', taskId, ...reasonParts] = parseCommandParts(args);\n if (action === 'list') {\n const tasks = listCommandBackgroundTasks(context);\n return {\n message: formatCommandBackgroundTaskList(tasks),\n success: true,\n data: { count: tasks.length },\n };\n }\n\n if (!taskId) {\n return {\n message: BACKGROUND_COMMAND_USAGE,\n success: false,\n };\n }\n\n if (action === 'read' || action === 'log' || action === 'open') {\n const page = await readCommandBackgroundTaskLog(\n context,\n taskId,\n parseCommandBackgroundLogCursor(reasonParts[0]),\n );\n const next = page.nextCursor ? `\\nNext offset: ${page.nextCursor.offset}` : '';\n return {\n message:\n page.lines.length > 0 ? `${page.lines.join('\\n')}${next}` : `No log lines: ${taskId}`,\n success: true,\n data: { taskId, nextOffset: page.nextCursor?.offset },\n };\n }\n\n if (action === 'cancel' || action === 'stop') {\n await cancelCommandBackgroundTask(context, taskId, reasonParts.join(' ') || undefined);\n return { message: `Background task cancelled: ${taskId}`, success: true, data: { taskId } };\n }\n\n if (action === 'close' || action === 'dismiss') {\n await closeCommandBackgroundTask(context, taskId);\n return { message: `Background task closed: ${taskId}`, success: true, data: { taskId } };\n }\n\n return { message: `Unknown background action: ${action}`, success: false };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n BACKGROUND_COMMAND_DESCRIPTION,\n buildBackgroundCommandSubcommands,\n} from '@robota-sdk/agent-framework';\nimport { executeBackgroundCommand } from './background-command.js';\n\nexport function createBackgroundCommandEntry(): ICommand {\n return {\n name: 'background',\n description: BACKGROUND_COMMAND_DESCRIPTION,\n source: 'background',\n modelInvocable: false,\n subcommands: buildBackgroundCommandSubcommands(),\n };\n}\n\nfunction createBackgroundSystemCommand(): ISystemCommand {\n const entry = createBackgroundCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n subcommands: entry.subcommands,\n execute: executeBackgroundCommand,\n };\n}\n\nexport class BackgroundCommandSource implements ICommandSource {\n readonly name = 'background';\n\n getCommands(): ICommand[] {\n return [createBackgroundCommandEntry()];\n }\n}\n\nexport function createBackgroundCommandModule(): ICommandModule {\n return {\n name: 'agent-command-background',\n commandSources: [new BackgroundCommandSource()],\n systemCommands: [createBackgroundSystemCommand()],\n };\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\nimport { compactCommandContext } from '@robota-sdk/agent-framework';\n\nfunction parseInstructions(args: string): string | undefined {\n const instructions = args.trim();\n return instructions.length > 0 ? instructions : undefined;\n}\n\nexport async function executeCompactCommand(\n context: ICommandHostContext,\n args: string,\n): Promise<ICommandResult> {\n const result = await compactCommandContext(context, parseInstructions(args));\n const before = result.before.usedPercentage;\n const after = result.after.usedPercentage;\n return {\n message: `Context compacted: ${Math.round(before)}% -> ${Math.round(after)}%`,\n success: true,\n data: { before, after },\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport { executeCompactCommand } from './compact-command.js';\n\nexport function createCompactCommandEntry(): ICommand {\n return {\n name: 'compact',\n description: 'Compress context window',\n source: 'compact',\n modelInvocable: true,\n argumentHint: '[instructions]',\n safety: 'write',\n };\n}\n\nfunction createCompactSystemCommand(): ISystemCommand {\n const entry = createCompactCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: entry.modelInvocable,\n argumentHint: entry.argumentHint,\n safety: entry.safety,\n lifecycle: 'blocking',\n execute: executeCompactCommand,\n };\n}\n\nexport class CompactCommandSource implements ICommandSource {\n readonly name = 'compact';\n\n getCommands(): ICommand[] {\n return [createCompactCommandEntry()];\n }\n}\n\nexport function createCompactCommandModule(): ICommandModule {\n return {\n name: 'agent-command-compact',\n commandSources: [new CompactCommandSource()],\n systemCommands: [createCompactSystemCommand()],\n };\n}\n","import type {\n ICommandHostContext,\n ICommandResult,\n TAutoCompactThreshold,\n TAutoCompactThresholdSource,\n} from '@robota-sdk/agent-framework';\nimport {\n addCommandContextReference,\n clearCommandContextReferences,\n DEFAULT_AUTO_COMPACT_THRESHOLD,\n listCommandContextReferences,\n readAutoCompactThreshold,\n readAutoCompactThresholdSource,\n readCommandContextState,\n removeCommandContextReference,\n resetAutoCompactThresholdSetting,\n setCommandAutoCompactThreshold,\n writeAutoCompactThresholdSetting,\n} from '@robota-sdk/agent-framework';\nimport type { IContextReferenceItem } from '@robota-sdk/agent-framework';\n\nconst PERCENT = 100;\nconst USAGE = [\n 'Usage: /context [list] | add <path> | remove <path> | clear | auto on | off | <percent> | reset',\n 'Examples: /context list, /context add AGENTS.md, /context remove AGENTS.md, /context auto 85%',\n].join('\\n');\n\nfunction formatThreshold(threshold: TAutoCompactThreshold): string {\n if (threshold === false) {\n return 'disabled';\n }\n return `${Math.round(threshold * PERCENT)}%`;\n}\n\nfunction formatAutoCompactLine(\n threshold: TAutoCompactThreshold,\n source: TAutoCompactThresholdSource,\n): string {\n if (threshold === false) {\n return `Auto compact: disabled (${source})`;\n }\n return `Auto compact: ${formatThreshold(threshold)} (${source})`;\n}\n\nfunction formatPersistenceSuffix(persisted: boolean): string {\n return persisted ? 'settings' : 'current session only';\n}\n\nexport async function executeContextCommand(\n context: ICommandHostContext,\n args: string,\n): Promise<ICommandResult> {\n const parts = args\n .trim()\n .split(/\\s+/)\n .filter((part) => part.length > 0);\n\n if (parts.length > 0) {\n return executeContextSubcommand(context, parts);\n }\n\n const state = readCommandContextState(context);\n const autoCompactThreshold = readAutoCompactThreshold(context);\n const autoCompactThresholdSource = readAutoCompactThresholdSource(context);\n return {\n message: [\n `Context: ${state.usedTokens.toLocaleString()} / ${state.maxTokens.toLocaleString()} tokens (${Math.round(state.usedPercentage)}%)`,\n formatAutoCompactLine(autoCompactThreshold, autoCompactThresholdSource),\n formatContextReferenceSummary(listCommandContextReferences(context)),\n ].join('\\n'),\n success: true,\n data: {\n usedTokens: state.usedTokens,\n maxTokens: state.maxTokens,\n percentage: state.usedPercentage,\n autoCompactThreshold,\n autoCompactThresholdSource,\n references: listCommandContextReferences(context),\n },\n };\n}\n\nasync function executeContextSubcommand(\n context: ICommandHostContext,\n parts: readonly string[],\n): Promise<ICommandResult> {\n const [subcommand, ...rest] = parts;\n if (subcommand === 'list') {\n if (rest.length > 0) return { success: false, message: USAGE };\n return formatContextReferenceList(listCommandContextReferences(context));\n }\n if (subcommand === 'add') {\n return executeAddContextReference(context, rest);\n }\n if (subcommand === 'remove') {\n return executeRemoveContextReference(context, rest);\n }\n if (subcommand === 'clear') {\n if (rest.length > 0) return { success: false, message: USAGE };\n const result = clearCommandContextReferences(context);\n return {\n success: true,\n message: `Context references cleared: ${result.removed.length} removed.`,\n data: { removed: result.removed },\n };\n }\n if (subcommand !== 'auto') {\n return { success: false, message: USAGE };\n }\n return executeAutoContextSubcommand(context, rest);\n}\n\nfunction executeAutoContextSubcommand(\n context: ICommandHostContext,\n parts: readonly string[],\n): ICommandResult {\n const [action, extra] = parts;\n if (extra !== undefined) return { success: false, message: USAGE };\n if (action === undefined) {\n const threshold = readAutoCompactThreshold(context);\n const source = readAutoCompactThresholdSource(context);\n return {\n success: true,\n message: [formatAutoCompactLine(threshold, source), USAGE].join('\\n'),\n data: { autoCompactThreshold: threshold, autoCompactThresholdSource: source },\n };\n }\n\n if (action === 'on') {\n return applyAutoCompactThreshold(context, DEFAULT_AUTO_COMPACT_THRESHOLD, 'enabled');\n }\n if (action === 'off') {\n return applyAutoCompactThreshold(context, false, 'disabled');\n }\n if (action === 'reset') {\n const persisted = resetAutoCompactThresholdSetting(context);\n setCommandAutoCompactThreshold(context, DEFAULT_AUTO_COMPACT_THRESHOLD, 'default');\n return {\n success: true,\n message: `Auto compact reset to default: ${formatThreshold(DEFAULT_AUTO_COMPACT_THRESHOLD)} (${formatPersistenceSuffix(persisted)}).`,\n data: {\n autoCompactThreshold: DEFAULT_AUTO_COMPACT_THRESHOLD,\n autoCompactThresholdSource: 'default',\n persisted,\n },\n };\n }\n\n const parsed = parseThreshold(action);\n if (!parsed.success) {\n return { success: false, message: `${parsed.message}\\n${USAGE}` };\n }\n return applyAutoCompactThreshold(context, parsed.threshold, 'threshold set');\n}\n\nasync function executeAddContextReference(\n context: ICommandHostContext,\n args: readonly string[],\n): Promise<ICommandResult> {\n const path = args.join(' ').trim();\n if (!path) return { success: false, message: USAGE };\n\n const result = await addCommandContextReference(context, path);\n if (!result.reference) {\n return {\n success: false,\n message: result.diagnostics.join('\\n') || `Context reference not found: ${path}`,\n data: { diagnostics: result.diagnostics },\n };\n }\n\n return {\n success: true,\n message: [\n `Context reference added: ${formatContextReferenceLine(result.reference)}.`,\n ...(result.evicted.length > 0\n ? [`Evicted ${result.evicted.length} older context reference(s).`]\n : []),\n ].join('\\n'),\n data: { reference: result.reference, evicted: result.evicted },\n };\n}\n\nfunction executeRemoveContextReference(\n context: ICommandHostContext,\n args: readonly string[],\n): ICommandResult {\n const path = args.join(' ').trim();\n if (!path) return { success: false, message: USAGE };\n\n const result = removeCommandContextReference(context, path);\n if (!result.removed) {\n return {\n success: false,\n message: `Context reference not found: ${path}`,\n };\n }\n\n return {\n success: true,\n message: `Context reference removed: ${formatContextReferenceLine(result.removed)}.`,\n data: { removed: result.removed },\n };\n}\n\nfunction applyAutoCompactThreshold(\n context: ICommandHostContext,\n threshold: TAutoCompactThreshold,\n action: 'enabled' | 'disabled' | 'threshold set',\n): ICommandResult {\n const persisted = writeAutoCompactThresholdSetting(context, threshold);\n const source: TAutoCompactThresholdSource = persisted ? 'settings' : 'session';\n setCommandAutoCompactThreshold(context, threshold, source);\n\n return {\n success: true,\n message: formatApplyMessage(action, threshold, persisted),\n data: {\n autoCompactThreshold: threshold,\n autoCompactThresholdSource: source,\n persisted,\n },\n };\n}\n\nfunction formatApplyMessage(\n action: 'enabled' | 'disabled' | 'threshold set',\n threshold: TAutoCompactThreshold,\n persisted: boolean,\n): string {\n const suffix = formatPersistenceSuffix(persisted);\n if (action === 'disabled') {\n return `Auto compact disabled (${suffix}).`;\n }\n if (action === 'enabled') {\n return `Auto compact enabled at ${formatThreshold(threshold)} (${suffix}).`;\n }\n return `Auto compact threshold set to ${formatThreshold(threshold)} (${suffix}).`;\n}\n\ntype TParseThresholdResult =\n | { success: true; threshold: number }\n | { success: false; message: string };\n\nfunction parseThreshold(raw: string): TParseThresholdResult {\n if (raw.endsWith('%')) {\n const percent = Number(raw.slice(0, -1));\n if (!Number.isFinite(percent) || percent <= 0 || percent > PERCENT) {\n return {\n success: false,\n message: 'Auto compact percentage must be greater than 0% and at most 100%.',\n };\n }\n return { success: true, threshold: percent / PERCENT };\n }\n\n if (raw.includes('.')) {\n const fraction = Number(raw);\n if (!Number.isFinite(fraction) || fraction <= 0 || fraction > 1) {\n return {\n success: false,\n message: 'Auto compact fraction must be greater than 0 and at most 1.',\n };\n }\n return { success: true, threshold: fraction };\n }\n\n return {\n success: false,\n message: 'Use a percentage such as 85% or a fraction such as 0.85.',\n };\n}\n\nfunction formatContextReferenceSummary(references: readonly IContextReferenceItem[]): string {\n const active = references.filter((reference) => reference.status === 'active').length;\n const observed = references.filter((reference) => reference.status === 'observed').length;\n return `References: ${active} active, ${observed} observed`;\n}\n\nfunction formatContextReferenceList(references: readonly IContextReferenceItem[]): ICommandResult {\n if (references.length === 0) {\n return { success: true, message: 'No context references.', data: { references } };\n }\n\n return {\n success: true,\n message: ['Context references:', ...references.map(formatContextReferenceLine)].join('\\n'),\n data: { references },\n };\n}\n\nfunction formatContextReferenceLine(reference: IContextReferenceItem): string {\n return [\n reference.relativePath,\n `[${reference.loadType}, ${reference.status}]`,\n `${reference.byteLength.toLocaleString()} B`,\n ].join(' ');\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport { executeContextCommand } from './context-command.js';\n\nexport function createContextCommandEntry(): ICommand {\n return {\n name: 'context',\n description: 'Context window info, reference inventory, and auto-compact controls',\n source: 'context',\n modelInvocable: false,\n argumentHint: 'list | add <path> | remove <path> | clear | auto ...',\n subcommands: [\n { name: 'list', description: 'List loaded context references', source: 'context' },\n { name: 'add', description: 'Add a file to active context references', source: 'context' },\n { name: 'remove', description: 'Remove a context reference', source: 'context' },\n { name: 'clear', description: 'Clear context references', source: 'context' },\n { name: 'auto', description: 'Inspect or change auto-compact policy', source: 'context' },\n ],\n };\n}\n\nfunction createContextSystemCommand(): ISystemCommand {\n const entry = createContextCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n execute: executeContextCommand,\n };\n}\n\nexport class ContextCommandSource implements ICommandSource {\n readonly name = 'context';\n\n getCommands(): ICommand[] {\n return [createContextCommandEntry()];\n }\n}\n\nexport function createContextCommandModule(): ICommandModule {\n return {\n name: 'agent-command-context',\n commandSources: [new ContextCommandSource()],\n systemCommands: [createContextSystemCommand()],\n };\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\nimport { createSessionExitRequestedEffect } from '@robota-sdk/agent-framework';\n\nexport function executeExitCommand(_context: ICommandHostContext, _args: string): ICommandResult {\n return {\n success: true,\n message: 'Exit requested.',\n effects: [createSessionExitRequestedEffect()],\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport { EXIT_COMMAND_DESCRIPTION } from '@robota-sdk/agent-framework';\nimport { executeExitCommand } from './exit-command.js';\n\nexport function createExitCommandEntry(): ICommand {\n return {\n name: 'exit',\n description: EXIT_COMMAND_DESCRIPTION,\n source: 'exit',\n modelInvocable: false,\n };\n}\n\nfunction createExitSystemCommand(): ISystemCommand {\n const entry = createExitCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeExitCommand,\n };\n}\n\nexport class ExitCommandSource implements ICommandSource {\n readonly name = 'exit';\n\n getCommands(): ICommand[] {\n return [createExitCommandEntry()];\n }\n}\n\nexport function createExitCommandModule(): ICommandModule {\n return {\n name: 'agent-command-exit',\n commandSources: [new ExitCommandSource()],\n systemCommands: [createExitSystemCommand()],\n };\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\nimport { formatCommandHelpMessage } from '@robota-sdk/agent-framework';\n\nexport function executeHelpCommand(context: ICommandHostContext, _args: string): ICommandResult {\n return {\n success: true,\n message: formatCommandHelpMessage(context),\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport { HELP_COMMAND_DESCRIPTION } from '@robota-sdk/agent-framework';\nimport { executeHelpCommand } from './help-command.js';\n\nexport function createHelpCommandEntry(): ICommand {\n return {\n name: 'help',\n description: HELP_COMMAND_DESCRIPTION,\n source: 'help',\n modelInvocable: false,\n };\n}\n\nfunction createHelpSystemCommand(): ISystemCommand {\n const entry = createHelpCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeHelpCommand,\n };\n}\n\nexport class HelpCommandSource implements ICommandSource {\n readonly name = 'help';\n\n getCommands(): ICommand[] {\n return [createHelpCommandEntry()];\n }\n}\n\nexport function createHelpCommandModule(): ICommandModule {\n return {\n name: 'agent-command-help',\n commandSources: [new HelpCommandSource()],\n systemCommands: [createHelpSystemCommand()],\n };\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\nimport { formatLanguageUsageMessage, parseLanguageArgument } from '@robota-sdk/agent-framework';\n\nexport function executeLanguageCommand(\n _context: ICommandHostContext,\n args: string,\n): ICommandResult {\n const language = parseLanguageArgument(args);\n if (language === undefined) {\n return {\n message: formatLanguageUsageMessage(),\n success: false,\n };\n }\n\n return {\n message: `Language set to \"${language}\".`,\n success: true,\n data: { language },\n effects: [{ type: 'language-change-requested', language }],\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n buildLanguageCommandSubcommands,\n LANGUAGE_COMMAND_ARGUMENT_HINT,\n LANGUAGE_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\nimport { executeLanguageCommand } from './language-command.js';\n\nexport function createLanguageCommandEntry(): ICommand {\n return {\n name: 'language',\n description: LANGUAGE_COMMAND_DESCRIPTION,\n source: 'language',\n argumentHint: LANGUAGE_COMMAND_ARGUMENT_HINT,\n subcommands: buildLanguageCommandSubcommands('language'),\n modelInvocable: false,\n };\n}\n\nfunction createLanguageSystemCommand(): ISystemCommand {\n const entry = createLanguageCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n lifecycle: 'inline',\n execute: executeLanguageCommand,\n };\n}\n\nexport class LanguageCommandSource implements ICommandSource {\n readonly name = 'language';\n\n getCommands(): ICommand[] {\n return [createLanguageCommandEntry()];\n }\n}\n\nexport function createLanguageCommandModule(): ICommandModule {\n return {\n name: 'agent-command-language',\n commandSources: [new LanguageCommandSource()],\n systemCommands: [createLanguageSystemCommand()],\n };\n}\n","import type {\n IAppendMemoryInput,\n ICommandHostContext,\n ICommandPendingMemoryStore,\n ICommandProjectMemoryStore,\n ICommandResult,\n IMemoryEvent,\n} from '@robota-sdk/agent-framework';\nimport {\n MEMORY_COMMAND_USAGE,\n createCommandMemoryStores,\n hasSensitiveCommandMemoryContent,\n isCommandMemoryType,\n listCommandUsedMemoryReferences,\n recordCommandMemoryEvent,\n} from '@robota-sdk/agent-framework';\n\nconst SUBCOMMAND_INDEX = 0;\nconst TYPE_INDEX = 1;\nconst TOPIC_INDEX = 2;\nconst TEXT_START_INDEX = 3;\n\nfunction usage(): ICommandResult {\n return {\n message: MEMORY_COMMAND_USAGE,\n success: false,\n };\n}\n\nfunction formatError(error: Error | string): ICommandResult {\n return {\n message: error instanceof Error ? error.message : String(error),\n success: false,\n };\n}\n\nfunction formatList(store: ICommandProjectMemoryStore): ICommandResult {\n const summary = store.list();\n const topics =\n summary.topics.length > 0\n ? summary.topics.map((topic) => `- ${topic.name}: ${topic.path}`).join('\\n')\n : '(none)';\n\n return {\n message: [\n `Memory index: ${summary.indexPath}`,\n `Topics directory: ${summary.topicsPath}`,\n 'Topics:',\n topics,\n ].join('\\n'),\n success: true,\n data: {\n indexPath: summary.indexPath,\n topicsPath: summary.topicsPath,\n topicCount: summary.topics.length,\n },\n };\n}\n\nfunction formatShow(store: ICommandProjectMemoryStore, topic?: string): ICommandResult {\n if (!topic || topic === 'index') {\n const memory = store.loadStartupMemory();\n return {\n message: memory.content || '(empty memory index)',\n success: true,\n data: {\n path: memory.path,\n lineCount: memory.lineCount,\n truncated: memory.truncated,\n },\n };\n }\n\n const content = store.readTopic(topic);\n return {\n message: content || `(empty memory topic: ${topic})`,\n success: true,\n data: { topic },\n };\n}\n\nfunction parseAdd(args: readonly string[]): IAppendMemoryInput | undefined {\n const type = args[TYPE_INDEX];\n const topic = args[TOPIC_INDEX];\n const text = args.slice(TEXT_START_INDEX).join(' ').trim();\n\n if (!type || !isCommandMemoryType(type) || !topic || text.length === 0) return undefined;\n return { type, topic, text };\n}\n\nfunction formatPending(store: ICommandPendingMemoryStore): ICommandResult {\n const records = store.list('pending');\n const lines =\n records.length > 0\n ? records.map(\n (record) =>\n `- ${record.id} ${record.type}/${record.topic} confidence=${record.confidence}: ${record.text}`,\n )\n : ['(no pending memory candidates)'];\n\n return {\n message: ['Pending memory candidates:', ...lines].join('\\n'),\n success: true,\n data: { count: records.length },\n };\n}\n\nfunction recordEvent(context: ICommandHostContext, event: Omit<IMemoryEvent, 'at'>): void {\n recordCommandMemoryEvent(context, event);\n}\n\nfunction approvePending(\n context: ICommandHostContext,\n pendingStore: ICommandPendingMemoryStore,\n memoryStore: ICommandProjectMemoryStore,\n id: string | undefined,\n): ICommandResult {\n if (!id) return usage();\n try {\n const approved = pendingStore.mark(id, 'approved', 'approved-by-user');\n const saved = memoryStore.append(approved);\n const record = pendingStore.mark(id, 'saved', 'approved-and-saved');\n recordEvent(context, {\n type: 'memory_candidate_approved',\n candidateId: record.id,\n topic: record.topic,\n reason: 'approved-by-user',\n });\n recordEvent(context, {\n type: 'memory_candidate_saved',\n candidateId: record.id,\n topic: record.topic,\n reason: saved.deduplicated ? 'deduplicated' : 'approved-and-saved',\n });\n return {\n message: saved.deduplicated\n ? `Saved memory candidate ${id} was already present in ${saved.topicPath}`\n : `Saved memory candidate ${id} to ${saved.topicPath}`,\n success: true,\n data: {\n id,\n status: record.status,\n topic: saved.topic,\n topicPath: saved.topicPath,\n deduplicated: saved.deduplicated,\n },\n };\n } catch (error) {\n return formatError(error instanceof Error ? error : String(error));\n }\n}\n\nfunction rejectPending(\n context: ICommandHostContext,\n pendingStore: ICommandPendingMemoryStore,\n id: string | undefined,\n): ICommandResult {\n if (!id) return usage();\n try {\n const record = pendingStore.mark(id, 'rejected', 'rejected-by-user');\n recordEvent(context, {\n type: 'memory_candidate_rejected',\n candidateId: record.id,\n topic: record.topic,\n reason: 'rejected-by-user',\n });\n return {\n message: `Rejected memory candidate ${id}`,\n success: true,\n data: { id, status: record.status },\n };\n } catch (error) {\n return formatError(error instanceof Error ? error : String(error));\n }\n}\n\nfunction formatUsed(context: ICommandHostContext): ICommandResult {\n const references = listCommandUsedMemoryReferences(context);\n const lines =\n references.length > 0\n ? references.map((reference) => {\n const suffix = reference.truncated ? ' truncated=true' : '';\n return `- ${reference.topic} score=${reference.score}${suffix}: ${reference.path}`;\n })\n : ['(no memory used in current turn)'];\n\n return {\n message: ['Used memory references:', ...lines].join('\\n'),\n success: true,\n data: { count: references.length, references: [...references] },\n };\n}\n\nexport function executeMemoryCommand(\n context: ICommandHostContext,\n rawArgs: string,\n): ICommandResult {\n const args = rawArgs.trim().split(/\\s+/).filter(Boolean);\n const subcommand = args[SUBCOMMAND_INDEX] ?? 'list';\n const stores = createCommandMemoryStores(context);\n\n if (subcommand === 'list') return formatList(stores.project);\n if (subcommand === 'show') return formatShow(stores.project, args[TYPE_INDEX]);\n if (subcommand === 'pending') return formatPending(stores.pending);\n if (subcommand === 'approve')\n return approvePending(context, stores.pending, stores.project, args[TYPE_INDEX]);\n if (subcommand === 'reject') return rejectPending(context, stores.pending, args[TYPE_INDEX]);\n if (subcommand === 'used') return formatUsed(context);\n if (subcommand === 'add') {\n const input = parseAdd(args);\n if (!input) return usage();\n if (hasSensitiveCommandMemoryContent(input.text)) {\n return {\n message: 'Refusing to save sensitive memory content.',\n success: false,\n };\n }\n const result = stores.project.append(input);\n return {\n message: result.deduplicated\n ? `${input.type} memory already exists in ${result.topicPath}`\n : `Saved ${input.type} memory to ${result.topicPath}`,\n success: true,\n data: {\n indexPath: result.indexPath,\n topicPath: result.topicPath,\n topic: result.topic,\n deduplicated: result.deduplicated,\n },\n };\n }\n\n return usage();\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n MEMORY_COMMAND_ARGUMENT_HINT,\n MEMORY_COMMAND_DESCRIPTION,\n buildMemoryCommandSubcommands,\n} from '@robota-sdk/agent-framework';\nimport { executeMemoryCommand } from './memory-command.js';\n\nexport function createMemoryCommandEntry(): ICommand {\n return {\n name: 'memory',\n description: MEMORY_COMMAND_DESCRIPTION,\n source: 'memory',\n argumentHint: MEMORY_COMMAND_ARGUMENT_HINT,\n modelInvocable: true,\n safety: 'write',\n subcommands: buildMemoryCommandSubcommands(),\n };\n}\n\nfunction createMemorySystemCommand(): ISystemCommand {\n const entry = createMemoryCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: true,\n argumentHint: entry.argumentHint,\n safety: entry.safety,\n subcommands: entry.subcommands,\n execute: executeMemoryCommand,\n };\n}\n\nexport class MemoryCommandSource implements ICommandSource {\n readonly name = 'memory';\n\n getCommands(): ICommand[] {\n return [createMemoryCommandEntry()];\n }\n}\n\nexport function createMemoryCommandModule(): ICommandModule {\n return {\n name: 'agent-command-memory',\n commandSources: [new MemoryCommandSource()],\n systemCommands: [createMemorySystemCommand()],\n };\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\nimport {\n formatInvalidPermissionModeMessage,\n isPermissionMode,\n parsePermissionModeArgument,\n readCommandPermissionMode,\n writeCommandPermissionMode,\n} from '@robota-sdk/agent-framework';\n\nexport function executeModeCommand(context: ICommandHostContext, args: string): ICommandResult {\n const arg = parsePermissionModeArgument(args);\n if (arg === undefined) {\n const mode = readCommandPermissionMode(context);\n return {\n message: `Current mode: ${mode}`,\n success: true,\n data: { mode },\n };\n }\n\n if (!isPermissionMode(arg)) {\n return {\n message: formatInvalidPermissionModeMessage(),\n success: false,\n };\n }\n\n writeCommandPermissionMode(context, arg);\n return {\n message: `Permission mode set to: ${arg}`,\n success: true,\n data: { mode: arg },\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n buildPermissionModeSubcommands,\n PERMISSION_MODE_ARGUMENT_HINT,\n PERMISSION_MODE_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\nimport { executeModeCommand } from './mode-command.js';\n\nexport function createModeCommandEntry(): ICommand {\n return {\n name: 'mode',\n description: PERMISSION_MODE_COMMAND_DESCRIPTION,\n source: 'mode',\n argumentHint: PERMISSION_MODE_ARGUMENT_HINT,\n subcommands: buildPermissionModeSubcommands('mode'),\n modelInvocable: false,\n };\n}\n\nfunction createModeSystemCommand(): ISystemCommand {\n const entry = createModeCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n lifecycle: 'inline',\n execute: executeModeCommand,\n };\n}\n\nexport class ModeCommandSource implements ICommandSource {\n readonly name = 'mode';\n\n getCommands(): ICommand[] {\n return [createModeCommandEntry()];\n }\n}\n\nexport function createModeCommandModule(): ICommandModule {\n return {\n name: 'agent-command-mode',\n commandSources: [new ModeCommandSource()],\n systemCommands: [createModeSystemCommand()],\n };\n}\n","import type {\n ICommandHostContext,\n ICommandResult,\n IModelCommandModuleOptions,\n} from '@robota-sdk/agent-framework';\nimport { formatModelCommandUsageMessageAsync } from '@robota-sdk/agent-framework';\n\nfunction parseModelId(args: string): string | undefined {\n const modelId = args.trim().split(/\\s+/)[0];\n return modelId !== undefined && modelId.length > 0 ? modelId : undefined;\n}\n\nexport async function executeModelCommand(\n _context: ICommandHostContext,\n args: string,\n options?: IModelCommandModuleOptions,\n): Promise<ICommandResult> {\n const modelId = parseModelId(args);\n if (modelId === undefined) {\n return {\n message: await formatModelCommandUsageMessageAsync({\n ...(options?.settings !== undefined\n ? { settings: options.settings.readMergedSettings() }\n : {}),\n ...(options?.providerDefinitions !== undefined\n ? { providerDefinitions: options.providerDefinitions }\n : {}),\n refresh: true,\n }),\n success: false,\n };\n }\n\n return {\n message: `Model change requested: ${modelId}`,\n success: true,\n data: { modelId },\n effects: [{ type: 'model-change-requested', modelId }],\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n IModelCommandModuleOptions,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n buildModelCommandSubcommands,\n MODEL_COMMAND_ARGUMENT_HINT,\n MODEL_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\nimport { executeModelCommand } from './model-command.js';\n\nexport function createModelCommandEntry(options?: IModelCommandModuleOptions): ICommand {\n return {\n name: 'model',\n description: MODEL_COMMAND_DESCRIPTION,\n source: 'model',\n argumentHint: MODEL_COMMAND_ARGUMENT_HINT,\n subcommands: buildModelSubcommands(options),\n };\n}\n\nfunction createModelSystemCommand(options?: IModelCommandModuleOptions): ISystemCommand {\n const entry = createModelCommandEntry(options);\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n lifecycle: 'inline',\n execute: (context, args) => executeModelCommand(context, args, options),\n };\n}\n\nexport class ModelCommandSource implements ICommandSource {\n readonly name = 'model';\n\n constructor(private readonly options?: IModelCommandModuleOptions) {}\n\n getCommands(): ICommand[] {\n return [createModelCommandEntry(this.options)];\n }\n}\n\nexport function createModelCommandModule(options?: IModelCommandModuleOptions): ICommandModule {\n return {\n name: 'agent-command-model',\n commandSources: [new ModelCommandSource(options)],\n systemCommands: [createModelSystemCommand(options)],\n };\n}\n\nfunction buildModelSubcommands(options?: IModelCommandModuleOptions): ICommand[] {\n if (options === undefined) {\n return buildModelCommandSubcommands('model');\n }\n return buildModelCommandSubcommands({\n source: 'model',\n providerDefinitions: options.providerDefinitions,\n settings: options.settings.readMergedSettings(),\n });\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\nimport {\n formatCommandPermissionsMessage,\n formatInvalidPermissionModeMessage,\n isPermissionMode,\n parsePermissionModeArgument,\n readCommandPermissionsState,\n writeCommandPermissionMode,\n} from '@robota-sdk/agent-framework';\n\nexport function executePermissionsCommand(\n context: ICommandHostContext,\n args: string,\n): ICommandResult {\n const arg = parsePermissionModeArgument(args);\n if (arg !== undefined) {\n if (!isPermissionMode(arg)) {\n return {\n message: formatInvalidPermissionModeMessage(),\n success: false,\n };\n }\n\n writeCommandPermissionMode(context, arg);\n const state = readCommandPermissionsState(context);\n return {\n message: `Permission mode set to: ${arg}\\n${formatCommandPermissionsMessage(state)}`,\n success: true,\n data: {\n mode: state.mode,\n sessionAllowed: state.sessionAllowed,\n },\n };\n }\n\n const state = readCommandPermissionsState(context);\n return {\n message: formatCommandPermissionsMessage(state),\n success: true,\n data: {\n mode: state.mode,\n sessionAllowed: state.sessionAllowed,\n },\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n buildPermissionModeSubcommands,\n PERMISSION_MODE_ARGUMENT_HINT,\n PERMISSIONS_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\nimport { executePermissionsCommand } from './permissions-command.js';\n\nexport function createPermissionsCommandEntry(): ICommand {\n return {\n name: 'permissions',\n description: PERMISSIONS_COMMAND_DESCRIPTION,\n source: 'permissions',\n argumentHint: PERMISSION_MODE_ARGUMENT_HINT,\n subcommands: buildPermissionModeSubcommands('permissions'),\n modelInvocable: false,\n };\n}\n\nfunction createPermissionsSystemCommand(): ISystemCommand {\n const entry = createPermissionsCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n lifecycle: 'inline',\n execute: executePermissionsCommand,\n };\n}\n\nexport class PermissionsCommandSource implements ICommandSource {\n readonly name = 'permissions';\n\n getCommands(): ICommand[] {\n return [createPermissionsCommandEntry()];\n }\n}\n\nexport function createPermissionsCommandModule(): ICommandModule {\n return {\n name: 'agent-command-permissions',\n commandSources: [new PermissionsCommandSource()],\n systemCommands: [createPermissionsSystemCommand()],\n };\n}\n","import type {\n ICommandHostContext,\n ICommandPluginAdapter,\n ICommandResult,\n} from '@robota-sdk/agent-framework';\nimport {\n createPluginRegistryReloadRequestedEffect,\n createPluginTuiRequestedEffect,\n resolvePluginCommandAdapter,\n} from '@robota-sdk/agent-framework';\n\nfunction getSubcommandParts(args: string): { subcommand: string; subArgs: string } {\n const parts = args\n .trim()\n .split(/\\s+/)\n .filter((part) => part.length > 0);\n return {\n subcommand: parts[0] ?? '',\n subArgs: parts.slice(1).join(' ').trim(),\n };\n}\n\nfunction usage(message: string): ICommandResult {\n return {\n success: false,\n message,\n };\n}\n\nfunction getPluginAdapter(context: ICommandHostContext): ICommandPluginAdapter | undefined {\n return resolvePluginCommandAdapter(context);\n}\n\nasync function executePluginOperation(\n context: ICommandHostContext,\n operation: (adapter: ICommandPluginAdapter) => Promise<string>,\n): Promise<ICommandResult> {\n const adapter = getPluginAdapter(context);\n if (adapter === undefined) {\n return {\n success: false,\n message: 'Plugin management is not available.',\n };\n }\n\n try {\n return {\n success: true,\n message: await operation(adapter),\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n success: false,\n message: `Plugin error: ${message}`,\n };\n }\n}\n\nasync function executeMarketplaceCommand(\n context: ICommandHostContext,\n subArgs: string,\n): Promise<ICommandResult> {\n const { subcommand, subArgs: marketplaceArgs } = getSubcommandParts(subArgs);\n\n if (subcommand === 'add' && marketplaceArgs.length > 0) {\n return executePluginOperation(context, async (adapter) => {\n const registeredName = await adapter.marketplaceAdd(marketplaceArgs);\n return `Added marketplace: \"${registeredName}\" (from ${marketplaceArgs})\\nInstall plugins with: /plugin install <name>@${registeredName}`;\n });\n }\n\n if (subcommand === 'remove' && marketplaceArgs.length > 0) {\n return executePluginOperation(context, async (adapter) => {\n await adapter.marketplaceRemove(marketplaceArgs);\n return `Removed marketplace \"${marketplaceArgs}\" and uninstalled its plugins.`;\n });\n }\n\n if (subcommand === 'update' && marketplaceArgs.length > 0) {\n return executePluginOperation(context, async (adapter) => {\n await adapter.marketplaceUpdate(marketplaceArgs);\n return `Updated marketplace \"${marketplaceArgs}\".`;\n });\n }\n\n if (subcommand === 'list') {\n return executePluginOperation(context, async (adapter) => {\n const sources = await adapter.marketplaceList();\n if (sources.length === 0) {\n return 'No marketplace sources configured.';\n }\n const lines = sources.map((source) => ` ${source.name} (${source.type})`);\n return `Marketplace sources:\\n${lines.join('\\n')}`;\n });\n }\n\n return usage('Usage: /plugin marketplace add <source> | remove <name> | update <name> | list');\n}\n\ntype TPluginIdOperation = (\n adapter: ICommandPluginAdapter,\n pluginId: string,\n) => Promise<string> | string;\n\nfunction executePluginIdOperation(\n context: ICommandHostContext,\n pluginId: string,\n usageMessage: string,\n operation: TPluginIdOperation,\n): Promise<ICommandResult> {\n if (pluginId.length === 0) {\n return Promise.resolve(usage(usageMessage));\n }\n return executePluginOperation(context, (adapter) =>\n Promise.resolve(operation(adapter, pluginId)),\n );\n}\n\nfunction executePluginManager(): ICommandResult {\n return {\n success: true,\n message: 'Opening plugin manager...',\n effects: [createPluginTuiRequestedEffect()],\n };\n}\n\nfunction executeInstallCommand(\n context: ICommandHostContext,\n pluginId: string,\n): Promise<ICommandResult> {\n return executePluginIdOperation(\n context,\n pluginId,\n 'Usage: /plugin install <name>@<marketplace>',\n async (adapter, targetPluginId) => {\n await adapter.install(targetPluginId);\n return `Installed plugin: ${targetPluginId}`;\n },\n );\n}\n\nfunction executeUninstallCommand(\n context: ICommandHostContext,\n pluginId: string,\n): Promise<ICommandResult> {\n return executePluginIdOperation(\n context,\n pluginId,\n 'Usage: /plugin uninstall <name>@<marketplace>',\n async (adapter, targetPluginId) => {\n await adapter.uninstall(targetPluginId);\n return `Uninstalled plugin: ${targetPluginId}`;\n },\n );\n}\n\nfunction executeEnableCommand(\n context: ICommandHostContext,\n pluginId: string,\n): Promise<ICommandResult> {\n return executePluginIdOperation(\n context,\n pluginId,\n 'Usage: /plugin enable <name>@<marketplace>',\n async (adapter, targetPluginId) => {\n await adapter.enable(targetPluginId);\n return `Enabled plugin: ${targetPluginId}`;\n },\n );\n}\n\nfunction executeDisableCommand(\n context: ICommandHostContext,\n pluginId: string,\n): Promise<ICommandResult> {\n return executePluginIdOperation(\n context,\n pluginId,\n 'Usage: /plugin disable <name>@<marketplace>',\n async (adapter, targetPluginId) => {\n await adapter.disable(targetPluginId);\n return `Disabled plugin: ${targetPluginId}`;\n },\n );\n}\n\nexport async function executePluginCommand(\n context: ICommandHostContext,\n args: string,\n): Promise<ICommandResult> {\n const { subcommand, subArgs } = getSubcommandParts(args);\n switch (subcommand) {\n case '':\n case 'manage':\n return executePluginManager();\n case 'install':\n return executeInstallCommand(context, subArgs);\n case 'uninstall':\n return executeUninstallCommand(context, subArgs);\n case 'enable':\n return executeEnableCommand(context, subArgs);\n case 'disable':\n return executeDisableCommand(context, subArgs);\n case 'marketplace':\n return executeMarketplaceCommand(context, subArgs);\n default:\n return usage(`Unknown plugin subcommand: ${subcommand}`);\n }\n}\n\nexport async function executeReloadPluginsCommand(\n context: ICommandHostContext,\n _args: string,\n): Promise<ICommandResult> {\n return executePluginOperation(context, async (adapter) => {\n const result = await adapter.reloadPlugins();\n const suffix =\n result.loadedPluginCount === 1\n ? '1 plugin resource'\n : `${result.loadedPluginCount} plugin resources`;\n return `Reloaded ${suffix}.`;\n }).then((result) => {\n if (!result.success) return result;\n return {\n ...result,\n effects: [createPluginRegistryReloadRequestedEffect()],\n };\n });\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n buildPluginCommandSubcommands,\n PLUGIN_COMMAND_ARGUMENT_HINT,\n PLUGIN_COMMAND_DESCRIPTION,\n RELOAD_PLUGINS_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\nimport { executePluginCommand, executeReloadPluginsCommand } from './plugin-command.js';\n\nexport function createPluginCommandEntry(): ICommand {\n return {\n name: 'plugin',\n description: PLUGIN_COMMAND_DESCRIPTION,\n source: 'plugin-manager',\n modelInvocable: false,\n argumentHint: PLUGIN_COMMAND_ARGUMENT_HINT,\n subcommands: buildPluginCommandSubcommands(),\n };\n}\n\nexport function createReloadPluginsCommandEntry(): ICommand {\n return {\n name: 'reload-plugins',\n description: RELOAD_PLUGINS_COMMAND_DESCRIPTION,\n source: 'plugin-manager',\n modelInvocable: false,\n };\n}\n\nfunction createPluginSystemCommand(): ISystemCommand {\n const entry = createPluginCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n lifecycle: 'inline',\n subcommands: entry.subcommands,\n execute: executePluginCommand,\n };\n}\n\nfunction createReloadPluginsSystemCommand(): ISystemCommand {\n const entry = createReloadPluginsCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeReloadPluginsCommand,\n };\n}\n\nexport class PluginManagerCommandSource implements ICommandSource {\n readonly name = 'plugin-manager';\n\n getCommands(): ICommand[] {\n return [createPluginCommandEntry(), createReloadPluginsCommandEntry()];\n }\n}\n\nexport function createPluginCommandModule(): ICommandModule {\n return {\n name: 'agent-command-plugin',\n commandSources: [new PluginManagerCommandSource()],\n systemCommands: [createPluginSystemCommand(), createReloadPluginsSystemCommand()],\n };\n}\n","import type {\n IProviderDefinition,\n IProviderSetupHelpLink,\n IProviderSetupStepDefinition,\n TProviderSetupField,\n} from '@robota-sdk/agent-core';\nimport { findProviderDefinition, formatSupportedProviderTypes } from '@robota-sdk/agent-core';\nimport type { IProviderSetupInput } from '@robota-sdk/agent-framework';\nimport { suggestProviderProfileName } from '@robota-sdk/agent-framework';\n\nexport type TProviderSetupType = string;\nexport type TPromptInput = (label: string, masked?: boolean) => Promise<string>;\n\nexport interface IProviderSetupPromptStep extends IProviderSetupStepDefinition {\n key: TProviderSetupField;\n}\n\nexport interface IProviderSetupFlowState {\n type: TProviderSetupType;\n steps: readonly IProviderSetupPromptStep[];\n setupHelpLinks: readonly IProviderSetupHelpLink[];\n stepIndex: number;\n values: Partial<Record<TProviderSetupField, string>>;\n existingProfileNames: readonly string[];\n profileName?: string;\n setCurrent?: boolean;\n}\n\nexport interface IProviderSetupFlowOptions {\n existingProfileNames?: readonly string[];\n initialValues?: Partial<Record<TProviderSetupField, string>>;\n profileName?: string;\n setCurrent?: boolean;\n}\n\nexport type TProviderSetupFlowSubmitResult =\n | {\n status: 'next';\n state: IProviderSetupFlowState;\n }\n | {\n status: 'complete';\n input: IProviderSetupInput;\n }\n | {\n status: 'error';\n state: IProviderSetupFlowState;\n message: string;\n };\n\nexport function createProviderSetupFlow(\n type: TProviderSetupType,\n providerDefinitions: readonly IProviderDefinition[],\n options: IProviderSetupFlowOptions = {},\n): IProviderSetupFlowState {\n const definition = getProviderSetupDefinition(type, providerDefinitions);\n return {\n type,\n steps: applyProviderSetupInitialValues(\n getProviderSetupSteps(definition),\n options.initialValues,\n ),\n setupHelpLinks: definition.setupHelpLinks ?? [],\n stepIndex: 0,\n values: {},\n existingProfileNames: options.existingProfileNames ?? [],\n ...(options.profileName !== undefined ? { profileName: options.profileName } : {}),\n ...(options.setCurrent !== undefined ? { setCurrent: options.setCurrent } : {}),\n };\n}\n\nexport function formatProviderSetupSelectionPrompt(\n providerDefinitions: readonly IProviderDefinition[],\n): string {\n if (providerDefinitions.length === 0) {\n return ' No providers are available.';\n }\n const lines = [\n ' Select provider:',\n ...providerDefinitions.map(\n (definition, index) => ` ${index + 1}. ${formatProviderSetupChoiceLabel(definition)}`,\n ),\n ` Provider [1-${providerDefinitions.length}] (default: 1): `,\n ];\n return lines.join('\\n');\n}\n\nexport function resolveProviderSetupSelection(\n rawValue: string,\n providerDefinitions: readonly IProviderDefinition[],\n): TProviderSetupType {\n const value = rawValue.trim();\n const selectedValue = value.length > 0 ? value : '1';\n const index = parseProviderSelectionIndex(selectedValue);\n if (index !== undefined) {\n const definition = providerDefinitions[index];\n if (definition !== undefined) {\n return definition.type;\n }\n throw new Error(\n `Provider selection ${selectedValue} is out of range. Currently supported: ${formatSupportedProviderTypes(providerDefinitions)}`,\n );\n }\n const definition = findProviderDefinition(providerDefinitions, selectedValue);\n if (definition === undefined) {\n throw new Error(\n `Unknown provider: ${selectedValue}. Currently supported: ${formatSupportedProviderTypes(providerDefinitions)}`,\n );\n }\n return definition.type;\n}\n\nexport function getProviderSetupStep(state: IProviderSetupFlowState): IProviderSetupPromptStep {\n const step = state.steps[state.stepIndex];\n if (step === undefined) {\n throw new Error(`Provider setup step ${state.stepIndex} is out of range`);\n }\n return step;\n}\n\nexport function submitProviderSetupValue(\n state: IProviderSetupFlowState,\n rawValue: string,\n): TProviderSetupFlowSubmitResult {\n const step = getProviderSetupStep(state);\n const value = rawValue.trim() || step.defaultValue || '';\n const validationMessage = validateProviderSetupValue(step, value);\n if (validationMessage !== undefined) {\n return { status: 'error', state, message: validationMessage };\n }\n\n const nextState = {\n ...state,\n stepIndex: state.stepIndex + 1,\n values: { ...state.values, [step.key]: value },\n };\n if (nextState.stepIndex < state.steps.length) {\n return { status: 'next', state: nextState };\n }\n return { status: 'complete', input: buildProviderSetupInput(nextState) };\n}\n\nexport async function runProviderSetupPromptFlow(\n type: TProviderSetupType,\n promptInput: TPromptInput,\n providerDefinitions: readonly IProviderDefinition[],\n options: IProviderSetupFlowOptions = {},\n): Promise<IProviderSetupInput> {\n let state = createProviderSetupFlow(type, providerDefinitions, options);\n const stepCount = state.steps.length;\n while (state.stepIndex < stepCount) {\n const step = getProviderSetupStep(state);\n const value = await promptInput(\n formatProviderSetupPromptLabel(step, state.setupHelpLinks),\n step.masked === true,\n );\n const result = submitProviderSetupValue(state, value);\n if (result.status === 'complete') {\n return result.input;\n }\n if (result.status === 'error') {\n throw new Error(result.message);\n }\n state = result.state;\n }\n throw new Error('Provider setup flow ended without completion');\n}\n\nexport function formatProviderSetupPromptLabel(\n step: IProviderSetupPromptStep,\n setupHelpLinks: readonly IProviderSetupHelpLink[] = [],\n): string {\n const suffix = step.defaultValue !== undefined ? ` (default: ${step.defaultValue})` : '';\n const setupHelp = formatProviderSetupHelpLinks(setupHelpLinks);\n const prefix = setupHelp.length > 0 ? `${setupHelp}\\n` : '';\n return `${prefix} ${step.title}${suffix}: `;\n}\n\nexport function formatProviderSetupChoiceLabel(definition: IProviderDefinition): string {\n const label =\n definition.displayName !== undefined\n ? `${definition.displayName} (${definition.type})`\n : definition.type;\n return definition.description !== undefined ? `${label} - ${definition.description}` : label;\n}\n\nexport function formatProviderSetupHelpLinks(\n setupHelpLinks: readonly IProviderSetupHelpLink[] = [],\n): string {\n if (setupHelpLinks.length === 0) {\n return '';\n }\n return setupHelpLinks\n .map(\n (link) =>\n ` Setup help: ${formatProviderSetupHelpLinkKind(link.kind)}: ${link.label} - ${link.url}`,\n )\n .join('\\n');\n}\n\nfunction parseProviderSelectionIndex(value: string): number | undefined {\n if (!/^\\d+$/.test(value)) {\n return undefined;\n }\n return Number(value) - 1;\n}\n\nexport function validateProviderSetupValue(\n step: IProviderSetupPromptStep,\n value: string,\n): string | undefined {\n if (step.required === true && value.length === 0) {\n return 'Required';\n }\n return undefined;\n}\n\nfunction getProviderSetupDefinition(\n type: TProviderSetupType,\n providerDefinitions: readonly IProviderDefinition[],\n): IProviderDefinition {\n const definition = findProviderDefinition(providerDefinitions, type);\n if (definition === undefined) {\n throw new Error(\n `Unknown provider: ${type}. Currently supported: ${formatSupportedProviderTypes(providerDefinitions)}`,\n );\n }\n return definition;\n}\n\nfunction getProviderSetupSteps(definition: IProviderDefinition): IProviderSetupPromptStep[] {\n if (definition.setupSteps !== undefined) {\n return [...definition.setupSteps];\n }\n\n const steps: IProviderSetupPromptStep[] = [\n {\n key: 'model',\n title: `${definition.type} model`,\n defaultValue: definition.defaults?.model,\n required: definition.defaults?.model === undefined,\n },\n ];\n if (definition.defaults?.baseURL !== undefined) {\n steps.unshift({\n key: 'baseURL',\n title: `${definition.type} base URL`,\n defaultValue: definition.defaults.baseURL,\n });\n }\n if (definition.requiresApiKey === true) {\n steps.push({\n key: 'apiKey',\n title: `${definition.type} API key`,\n defaultValue: definition.defaults?.apiKey,\n required: definition.defaults?.apiKey === undefined,\n masked: true,\n });\n }\n return steps;\n}\n\nfunction formatProviderSetupHelpLinkKind(kind: IProviderSetupHelpLink['kind']): string {\n if (kind === 'api-key') {\n return 'API key';\n }\n if (kind === 'console') {\n return 'Console';\n }\n return 'Official';\n}\n\nfunction applyProviderSetupInitialValues(\n steps: readonly IProviderSetupPromptStep[],\n initialValues: Partial<Record<TProviderSetupField, string>> | undefined,\n): IProviderSetupPromptStep[] {\n if (initialValues === undefined) {\n return [...steps];\n }\n return steps.map((step) => {\n const initialValue = initialValues[step.key];\n if (initialValue === undefined) {\n return step;\n }\n return {\n ...step,\n defaultValue: initialValue,\n required: false,\n };\n });\n}\n\nfunction buildProviderSetupInput(state: IProviderSetupFlowState): IProviderSetupInput {\n const profile =\n state.profileName ??\n suggestProviderProfileName(\n { type: state.type },\n { existingProfileNames: state.existingProfileNames },\n );\n const apiKey = state.values.apiKey;\n return {\n profile,\n type: state.type,\n model: state.values.model,\n ...(apiKey !== undefined && apiKey.length > 0 && { apiKey }),\n ...(state.values.baseURL !== undefined && { baseURL: state.values.baseURL }),\n setCurrent: state.setCurrent ?? true,\n };\n}\n","import type {\n ICommandInteraction,\n ICommandResult,\n IProviderCommandModuleOptions,\n IProviderSetupInput,\n TCommandInteractionPrompt,\n} from '@robota-sdk/agent-framework';\nimport { buildProviderSetupPatch, mergeProviderPatch } from '@robota-sdk/agent-framework';\nimport type { IProviderSetupFlowState } from './provider-setup-flow.js';\nimport {\n createProviderSetupFlow,\n formatProviderSetupHelpLinks,\n getProviderSetupStep,\n submitProviderSetupValue,\n validateProviderSetupValue,\n} from './provider-setup-flow.js';\n\nconst PROVIDER_RESTART_EFFECT = {\n type: 'session-restart-requested',\n reason: 'other',\n} as const;\n\nexport function createSetupFlow(\n type: string,\n options: IProviderCommandModuleOptions,\n): IProviderSetupFlowState {\n return createProviderSetupFlow(type, options.providerDefinitions, {\n existingProfileNames: Object.keys(options.settings.readMergedSettings().providers ?? {}),\n });\n}\n\nexport function createProviderSetupInteraction(\n flow: IProviderSetupFlowState,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: toProviderSetupStepPrompt(flow),\n submit: (value) => submitProviderSetupInteractionValue(flow, value, options),\n cancel: () => ({ message: 'Provider setup cancelled.', success: true }),\n };\n}\n\nexport function toProviderSetupStepPrompt(\n flow: IProviderSetupFlowState,\n): TCommandInteractionPrompt {\n const step = getProviderSetupStep(flow);\n const placeholder =\n step.masked === true && step.defaultValue !== undefined ? '(unchanged)' : step.defaultValue;\n return {\n kind: 'text',\n title: step.title,\n ...toProviderSetupPromptDescription(flow),\n ...(placeholder !== undefined ? { placeholder } : {}),\n ...(step.defaultValue !== undefined ? { allowEmpty: true } : {}),\n ...(step.masked !== undefined ? { masked: step.masked } : {}),\n validate: (value) => validateProviderSetupValue(step, value),\n };\n}\n\nexport function toProviderSetupPromptDescription(\n flow: IProviderSetupFlowState,\n): { description: string } | Record<string, never> {\n const description = formatProviderSetupHelpLinks(flow.setupHelpLinks);\n return description.length > 0 ? { description } : {};\n}\n\nfunction submitProviderSetupInteractionValue(\n flow: IProviderSetupFlowState,\n value: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const result = submitProviderSetupValue(flow, value);\n if (result.status === 'error') {\n return {\n message: result.message,\n success: false,\n interaction: createProviderSetupInteraction(flow, options),\n };\n }\n if (result.status === 'complete') {\n return completeProviderSetup(result.input, options);\n }\n return {\n message: '',\n success: true,\n interaction: createProviderSetupInteraction(result.state, options),\n };\n}\n\nexport function completeProviderSetup(\n input: IProviderSetupInput,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const target = options.settings.readTargetSettings();\n const patch = buildProviderSetupPatch(input, {\n providerDefinitions: options.providerDefinitions,\n });\n options.settings.writeTargetSettings(mergeProviderPatch(target, patch));\n return {\n message: `Provider ${input.profile} configured. Restarting...`,\n success: true,\n effects: [{ ...PROVIDER_RESTART_EFFECT, message: 'Provider setup restart' }],\n };\n}\n","import type {\n ICommandInteraction,\n ICommandResult,\n IProviderCommandModuleOptions,\n IProviderProfileSettings,\n IProviderSetupInput,\n} from '@robota-sdk/agent-framework';\nimport {\n buildProviderSetupPatch,\n setCurrentProvider,\n upsertProviderProfile,\n} from '@robota-sdk/agent-framework';\nimport { createProviderSetupFlow, submitProviderSetupValue } from './provider-setup-flow.js';\nimport type { IProviderSetupFlowState } from './provider-setup-flow.js';\nimport {\n createProviderSetupInteraction,\n toProviderSetupStepPrompt,\n} from './provider-command-setup.js';\n\nconst YES = 'yes';\nconst PROVIDER_RESTART_EFFECT = {\n type: 'session-restart-requested',\n reason: 'other',\n} as const;\n\nexport function formatProviderChoiceLabel(\n name: string,\n profile: IProviderProfileSettings,\n currentProvider: string | undefined,\n): string {\n const marker = name === currentProvider ? '* ' : '';\n return `${marker}${name}: ${profile.type ?? 'unknown'} ${profile.model ?? '(no model)'}`;\n}\n\nexport function buildProviderSwitch(\n providers: Record<string, IProviderProfileSettings> | undefined,\n profileName: string | undefined,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n if (!profileName) {\n return { message: 'Usage: provider use <profile>', success: false };\n }\n if (!providers?.[profileName]) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n if (options.settings.readMergedSettings().currentProvider === profileName) {\n return { message: `Provider profile \"${profileName}\" is already current.`, success: true };\n }\n return {\n message: `Provider change requested: ${profileName}`,\n success: true,\n interaction: createProviderSwitchInteraction(profileName, options),\n };\n}\n\nfunction createProviderSwitchInteraction(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'choice',\n title: `Change provider to ${profileName}? This will restart the session.`,\n options: [\n { value: YES, label: 'Yes' },\n { value: 'no', label: 'No' },\n ],\n },\n submit: (value) => {\n if (value !== YES) {\n return { message: 'Provider change cancelled.', success: true };\n }\n const merged = options.settings.readMergedSettings();\n const target = options.settings.readTargetSettings();\n const next =\n target.providers?.[profileName] !== undefined ||\n merged.providers?.[profileName] !== undefined\n ? { ...target, currentProvider: profileName }\n : setCurrentProvider(target, profileName);\n options.settings.writeTargetSettings(next);\n return {\n message: `Provider changed to ${profileName}. Restarting...`,\n success: true,\n effects: [{ ...PROVIDER_RESTART_EFFECT, message: 'Provider change restart' }],\n };\n },\n cancel: () => ({ message: 'Provider change cancelled.', success: true }),\n };\n}\n\nexport function buildProviderEdit(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n const profile = settings.providers?.[profileName];\n if (!profile) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n if (!profile.type) {\n return { message: `Provider profile \"${profileName}\" is missing type.`, success: false };\n }\n try {\n const flow = createProviderSetupFlow(profile.type, options.providerDefinitions, {\n profileName,\n setCurrent: false,\n initialValues: getProviderProfileSetupValues(profile),\n });\n return {\n message: `Provider edit requested: ${profileName}`,\n success: true,\n interaction: createProviderEditInteraction(flow, profileName, options),\n };\n } catch (error) {\n return { message: error instanceof Error ? error.message : String(error), success: false };\n }\n}\n\nfunction getProviderProfileSetupValues(profile: IProviderProfileSettings): {\n model?: string;\n apiKey?: string;\n baseURL?: string;\n} {\n return {\n ...(typeof profile.model === 'string' ? { model: profile.model } : {}),\n ...(typeof profile.apiKey === 'string' ? { apiKey: profile.apiKey } : {}),\n ...(typeof profile.baseURL === 'string' ? { baseURL: profile.baseURL } : {}),\n };\n}\n\nexport function createProviderEditInteraction(\n flow: IProviderSetupFlowState,\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: toProviderSetupStepPrompt(flow),\n submit: (value) => submitProviderEditInteractionValue(flow, profileName, value, options),\n cancel: () => ({ message: 'Provider edit cancelled.', success: true }),\n };\n}\n\nfunction submitProviderEditInteractionValue(\n flow: IProviderSetupFlowState,\n profileName: string,\n value: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const result = submitProviderSetupValue(flow, value);\n if (result.status === 'error') {\n return {\n message: result.message,\n success: false,\n interaction: createProviderEditInteraction(flow, profileName, options),\n };\n }\n if (result.status === 'complete') {\n return completeProviderEdit(result.input, profileName, options);\n }\n return {\n message: '',\n success: true,\n interaction: createProviderEditInteraction(result.state, profileName, options),\n };\n}\n\nfunction completeProviderEdit(\n input: IProviderSetupInput,\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const merged = options.settings.readMergedSettings();\n const currentProfile = merged.providers?.[profileName];\n if (!currentProfile) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n const target = options.settings.readTargetSettings();\n const patch = buildProviderSetupPatch(input, {\n providerDefinitions: options.providerDefinitions,\n });\n const updatedProfile = patch.providers[profileName];\n if (!updatedProfile) {\n return { message: `Provider profile \"${profileName}\" was not updated.`, success: false };\n }\n options.settings.writeTargetSettings(\n upsertProviderProfile(target, profileName, { ...currentProfile, ...updatedProfile }),\n );\n const isCurrent = merged.currentProvider === profileName;\n return {\n message: isCurrent\n ? `Provider ${profileName} updated. Restarting...`\n : `Provider ${profileName} updated.`,\n success: true,\n ...(isCurrent\n ? { effects: [{ ...PROVIDER_RESTART_EFFECT, message: 'Provider edit restart' }] }\n : {}),\n };\n}\n","import type {\n ICommandInteraction,\n ICommandResult,\n IProviderCommandModuleOptions,\n} from '@robota-sdk/agent-framework';\nimport {\n deleteProviderProfile,\n sanitizeProviderProfileName,\n upsertProviderProfile,\n} from '@robota-sdk/agent-framework';\nimport { formatProviderChoiceLabel } from './provider-command-profile-operations.js';\n\nconst YES = 'yes';\nconst MAX_DUPLICATE_PROFILE_SUFFIX = 1000;\nconst PROVIDER_RESTART_EFFECT = {\n type: 'session-restart-requested',\n reason: 'other',\n} as const;\n\nexport function buildProviderDuplicate(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n if (!settings.providers?.[profileName]) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n const defaultName = suggestDuplicateProfileName(profileName, Object.keys(settings.providers));\n return {\n message: `Provider duplicate requested: ${profileName}`,\n success: true,\n interaction: createProviderDuplicateInteraction(profileName, defaultName, options),\n };\n}\n\nfunction createProviderDuplicateInteraction(\n profileName: string,\n defaultName: string,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'text',\n title: `Duplicate ${profileName} as`,\n placeholder: defaultName,\n allowEmpty: true,\n validate: (value) => validateDuplicateProfileName(value, defaultName, options),\n },\n submit: (value) => completeProviderDuplicate(profileName, value, defaultName, options),\n cancel: () => ({ message: 'Provider duplicate cancelled.', success: true }),\n };\n}\n\nfunction validateDuplicateProfileName(\n value: string,\n defaultName: string,\n options: IProviderCommandModuleOptions,\n): string | undefined {\n const name = normalizeProfileName(value, defaultName);\n if (name.length === 0) {\n return 'Required';\n }\n if (options.settings.readMergedSettings().providers?.[name] !== undefined) {\n return `Provider profile \"${name}\" already exists`;\n }\n return undefined;\n}\n\nfunction completeProviderDuplicate(\n profileName: string,\n value: string,\n defaultName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n const sourceProfile = settings.providers?.[profileName];\n if (!sourceProfile) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n const targetName = normalizeProfileName(value, defaultName);\n const validationMessage = validateDuplicateProfileName(targetName, defaultName, options);\n if (validationMessage !== undefined) {\n return { message: validationMessage, success: false };\n }\n options.settings.writeTargetSettings(\n upsertProviderProfile(options.settings.readTargetSettings(), targetName, { ...sourceProfile }),\n );\n return {\n message: `Provider profile duplicated: ${profileName} -> ${targetName}.`,\n success: true,\n };\n}\n\nexport function buildProviderDelete(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n const providers = settings.providers ?? {};\n if (!providers[profileName]) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n if (Object.keys(providers).length <= 1) {\n return { message: 'Cannot delete the only provider profile.', success: false };\n }\n if (options.settings.readTargetSettings().providers?.[profileName] === undefined) {\n return {\n message: `Provider profile \"${profileName}\" is not stored in the active write target; edit its source settings file or override it before deleting.`,\n success: false,\n };\n }\n return {\n message: `Provider delete requested: ${profileName}`,\n success: true,\n interaction: createProviderDeleteConfirmationInteraction(profileName, options),\n };\n}\n\nfunction createProviderDeleteConfirmationInteraction(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'choice',\n title: `Delete provider profile ${profileName}?`,\n options: [\n { value: YES, label: 'Yes' },\n { value: 'no', label: 'No' },\n ],\n },\n submit: (value) => {\n if (value !== YES) {\n return { message: 'Provider delete cancelled.', success: true };\n }\n return confirmProviderDelete(profileName, options);\n },\n cancel: () => ({ message: 'Provider delete cancelled.', success: true }),\n };\n}\n\nfunction confirmProviderDelete(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n if (settings.currentProvider !== profileName) {\n options.settings.writeTargetSettings(\n deleteProviderProfile(options.settings.readTargetSettings(), profileName),\n );\n return { message: `Provider profile deleted: ${profileName}.`, success: true };\n }\n const replacementOptions = Object.entries(settings.providers ?? {})\n .filter(([name]) => name !== profileName)\n .map(([name, profile]) => ({\n value: name,\n label: formatProviderChoiceLabel(name, profile, settings.currentProvider),\n }));\n return {\n message: `Select a replacement provider before deleting ${profileName}.`,\n success: true,\n interaction: {\n prompt: {\n kind: 'choice',\n title: `Replacement provider for ${profileName}`,\n options: replacementOptions,\n maxVisible: 8,\n },\n submit: (replacementName) =>\n completeActiveProviderDelete(profileName, replacementName, options),\n cancel: () => ({ message: 'Provider delete cancelled.', success: true }),\n },\n };\n}\n\nfunction completeActiveProviderDelete(\n profileName: string,\n replacementName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n if (settings.providers?.[replacementName] === undefined || replacementName === profileName) {\n return { message: `Provider profile \"${replacementName}\" was not found.`, success: false };\n }\n const target = deleteProviderProfile(options.settings.readTargetSettings(), profileName);\n options.settings.writeTargetSettings({ ...target, currentProvider: replacementName });\n return {\n message: `Provider profile deleted: ${profileName}. Restarting with ${replacementName}...`,\n success: true,\n effects: [{ ...PROVIDER_RESTART_EFFECT, message: 'Provider delete restart' }],\n };\n}\n\nfunction suggestDuplicateProfileName(profileName: string, existingProfileNames: readonly string[]) {\n const base = sanitizeProviderProfileName(`${profileName}-copy`) ?? 'provider-copy';\n if (!existingProfileNames.includes(base)) {\n return base;\n }\n for (let index = 2; index < MAX_DUPLICATE_PROFILE_SUFFIX; index += 1) {\n const candidate = `${base}-${index}`;\n if (!existingProfileNames.includes(candidate)) {\n return candidate;\n }\n }\n return `${base}-${Date.now()}`;\n}\n\nfunction normalizeProfileName(value: string, defaultName: string): string {\n const raw = value.trim() || defaultName;\n return sanitizeProviderProfileName(raw) ?? '';\n}\n","import type {\n ICommandInteraction,\n ICommandResult,\n IProviderCommandModuleOptions,\n IProviderProfileSettings,\n} from '@robota-sdk/agent-framework';\nimport { testProviderProfileCommand } from '@robota-sdk/agent-framework';\nimport {\n buildProviderEdit,\n buildProviderSwitch,\n formatProviderChoiceLabel,\n} from './provider-command-profile-operations.js';\nimport {\n buildProviderDelete,\n buildProviderDuplicate,\n} from './provider-command-profile-lifecycle.js';\n\nconst ACTION_SWITCH = 'switch';\nconst ACTION_EDIT = 'edit';\nconst ACTION_TEST = 'test';\nconst ACTION_DUPLICATE = 'duplicate';\nconst ACTION_DELETE = 'delete';\nconst ACTION_CANCEL = 'cancel';\n\nexport function createProviderProfileSelectionInteraction(\n currentProvider: string | undefined,\n providers: Record<string, IProviderProfileSettings> | undefined,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'choice',\n title: 'Select provider profile',\n options: Object.entries(providers ?? {}).map(([name, profile]) => ({\n value: name,\n label: formatProviderChoiceLabel(name, profile, currentProvider),\n })),\n maxVisible: 8,\n },\n submit: (value) => buildProviderProfileActionMenu(value, options),\n cancel: () => ({ message: 'Provider profile selection cancelled.', success: true }),\n };\n}\n\nfunction buildProviderProfileActionMenu(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n if (!settings.providers?.[profileName]) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n return {\n message: `Provider profile selected: ${profileName}`,\n success: true,\n interaction: createProviderProfileActionInteraction(profileName, options),\n };\n}\n\nfunction createProviderProfileActionInteraction(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'choice',\n title: `Provider profile: ${profileName}`,\n options: [\n { value: ACTION_SWITCH, label: 'Switch' },\n { value: ACTION_EDIT, label: 'Edit' },\n { value: ACTION_TEST, label: 'Test' },\n { value: ACTION_DUPLICATE, label: 'Duplicate' },\n { value: ACTION_DELETE, label: 'Delete' },\n { value: ACTION_CANCEL, label: 'Cancel' },\n ],\n },\n submit: (value) => executeProviderProfileAction(profileName, value, options),\n cancel: () => ({ message: 'Provider profile action cancelled.', success: true }),\n };\n}\n\nasync function executeProviderProfileAction(\n profileName: string,\n action: string,\n options: IProviderCommandModuleOptions,\n): Promise<ICommandResult> {\n const settings = options.settings.readMergedSettings();\n switch (action) {\n case ACTION_SWITCH:\n return buildProviderSwitch(settings.providers, profileName, options);\n case ACTION_EDIT:\n return buildProviderEdit(profileName, options);\n case ACTION_TEST:\n return await testProviderProfileCommand(\n settings.currentProvider,\n settings.providers,\n profileName,\n options,\n );\n case ACTION_DUPLICATE:\n return buildProviderDuplicate(profileName, options);\n case ACTION_DELETE:\n return buildProviderDelete(profileName, options);\n case ACTION_CANCEL:\n return { message: 'Provider profile action cancelled.', success: true };\n default:\n return { message: `Unknown provider profile action \"${action}\".`, success: false };\n }\n}\n","import { findProviderDefinition, formatSupportedProviderTypes } from '@robota-sdk/agent-core';\nimport type {\n ICommandResult,\n IProviderCommandModuleOptions,\n IProviderProfileSettings,\n} from '@robota-sdk/agent-framework';\nimport { testProviderProfileCommand } from '@robota-sdk/agent-framework';\nimport { formatProviderSetupChoiceLabel } from './provider-setup-flow.js';\nimport { createSetupFlow, createProviderSetupInteraction } from './provider-command-setup.js';\nimport { buildProviderSwitch } from './provider-command-profile-operations.js';\nimport { createProviderProfileSelectionInteraction } from './provider-command-profile.js';\n\nexport async function executeProviderCommand(\n args: string,\n options: IProviderCommandModuleOptions,\n): Promise<ICommandResult> {\n const settings = options.settings.readMergedSettings();\n const trimmedArgs = args.trim();\n if (trimmedArgs.length === 0) {\n return buildProviderProfilePicker(settings.currentProvider, settings.providers, options);\n }\n const [subcommand = 'current', profileArg] = trimmedArgs.split(/\\s+/);\n\n if (subcommand === 'list') {\n return buildProviderProfilePicker(settings.currentProvider, settings.providers, options);\n }\n if (subcommand === 'current' || subcommand === '') {\n return {\n message: formatCurrentProvider(settings.currentProvider, settings.providers),\n success: true,\n };\n }\n if (subcommand === 'use') {\n return buildProviderSwitch(settings.providers, profileArg, options);\n }\n if (subcommand === 'test') {\n return await testProviderProfileCommand(\n settings.currentProvider,\n settings.providers,\n profileArg,\n options,\n );\n }\n if (subcommand === 'add') {\n return buildProviderSetup(profileArg, options);\n }\n\n return {\n message: 'Usage: provider [current|list|use <profile>|add <type>|test [profile]]',\n success: false,\n };\n}\n\nfunction buildProviderProfilePicker(\n currentProvider: string | undefined,\n providers: Record<string, IProviderProfileSettings> | undefined,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const message = formatProviderList(currentProvider, providers);\n if (Object.keys(providers ?? {}).length === 0) {\n return { message, success: true };\n }\n return {\n message,\n success: true,\n interaction: createProviderProfileSelectionInteraction(currentProvider, providers, options),\n };\n}\n\nfunction formatProviderList(\n currentProvider: string | undefined,\n providers: Record<string, IProviderProfileSettings> | undefined,\n): string {\n const entries = Object.entries(providers ?? {});\n if (entries.length === 0) {\n return 'No provider profiles configured.';\n }\n return entries\n .map(([name, profile]) => {\n const marker = name === currentProvider ? '*' : '-';\n return `${marker} ${name}: ${profile.type ?? 'unknown'} ${profile.model ?? '(no model)'}`;\n })\n .join('\\n');\n}\n\nfunction formatCurrentProvider(\n currentProvider: string | undefined,\n providers: Record<string, IProviderProfileSettings> | undefined,\n): string {\n if (!currentProvider) {\n return 'No current provider configured.';\n }\n const profile = providers?.[currentProvider];\n if (!profile) {\n return `Current provider \"${currentProvider}\" was not found in providers.`;\n }\n return [\n `Current provider: ${currentProvider}`,\n `Type: ${profile.type ?? 'unknown'}`,\n `Model: ${profile.model ?? '(no model)'}`,\n ...(profile.baseURL ? [`Base URL: ${profile.baseURL}`] : []),\n ].join('\\n');\n}\n\nfunction buildProviderSetup(\n type: string | undefined,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n if (type === undefined || type.length === 0) {\n return {\n message: 'Provider setup requested. Select a provider to continue.',\n success: true,\n interaction: createProviderSelectionInteraction(options),\n };\n }\n if (findProviderDefinition(options.providerDefinitions, type) === undefined) {\n return {\n message: `Usage: provider add <type>. Supported: ${formatSupportedProviderTypes(options.providerDefinitions)}`,\n success: false,\n };\n }\n return {\n message: `Provider setup requested: ${type}`,\n success: true,\n interaction: createProviderSetupInteraction(createSetupFlow(type, options), options),\n };\n}\n\nfunction createProviderSelectionInteraction(options: IProviderCommandModuleOptions) {\n return {\n prompt: {\n kind: 'choice' as const,\n title: 'Select provider',\n options: options.providerDefinitions.map((definition) => ({\n value: definition.type,\n label: formatProviderSetupChoiceLabel(definition),\n })),\n maxVisible: 6,\n },\n submit: (value: string) => {\n const flow = createSetupFlow(value, options);\n return {\n message: `Provider setup requested: ${value}`,\n success: true,\n interaction: createProviderSetupInteraction(flow, options),\n };\n },\n cancel: () => ({ message: 'Provider setup cancelled.', success: true }),\n };\n}\n","import type {\n ICommand,\n ICommandModule as TCommandModule,\n ICommandSource,\n IProviderCommandModuleOptions,\n IProviderCommandSettingsAdapter,\n ISystemCommand as TSystemCommand,\n} from '@robota-sdk/agent-framework';\nimport { executeProviderCommand } from './provider-command-execution.js';\nexport type { IProviderCommandModuleOptions, IProviderCommandSettingsAdapter };\n\nfunction buildProviderSubcommands(): ICommand[] {\n return [\n { name: 'current', description: 'Show current provider', source: 'provider' },\n { name: 'list', description: 'List provider profiles', source: 'provider' },\n { name: 'use', description: 'Switch provider profile', source: 'provider' },\n { name: 'add', description: 'Configure a provider profile', source: 'provider' },\n { name: 'test', description: 'Test provider profile', source: 'provider' },\n ];\n}\n\nexport function createProviderCommandEntry(): ICommand {\n return {\n name: 'provider',\n description: 'Manage provider profiles',\n source: 'provider',\n modelInvocable: false,\n argumentHint: 'current | list | use <profile> | add [type] | test [profile]',\n subcommands: buildProviderSubcommands(),\n };\n}\n\nexport class ProviderCommandSource implements ICommandSource {\n readonly name = 'provider';\n\n getCommands(): ICommand[] {\n return [createProviderCommandEntry()];\n }\n}\n\nfunction createProviderSystemCommand(options: IProviderCommandModuleOptions): TSystemCommand {\n const entry = createProviderCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n execute: async (_session, args) => executeProviderCommand(args, options),\n };\n}\n\nexport function createProviderCommandModule(\n options: IProviderCommandModuleOptions,\n): TCommandModule {\n return {\n name: 'agent-command-provider',\n commandSources: [new ProviderCommandSource()],\n systemCommands: [createProviderSystemCommand(options)],\n };\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\n\nexport function executeResetCommand(_context: ICommandHostContext, _args: string): ICommandResult {\n return {\n success: true,\n message: 'Reset requested.',\n data: { resetRequested: true },\n effects: [{ type: 'settings-reset-requested' }],\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport { executeResetCommand } from './reset-command.js';\n\nconst RESET_COMMAND_DESCRIPTION = 'Delete settings';\n\nexport function createResetCommandEntry(): ICommand {\n return {\n name: 'reset',\n description: RESET_COMMAND_DESCRIPTION,\n source: 'reset',\n modelInvocable: false,\n };\n}\n\nfunction createResetSystemCommand(): ISystemCommand {\n const entry = createResetCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeResetCommand,\n };\n}\n\nexport class ResetCommandSource implements ICommandSource {\n readonly name = 'reset';\n\n getCommands(): ICommand[] {\n return [createResetCommandEntry()];\n }\n}\n\nexport function createResetCommandModule(): ICommandModule {\n return {\n name: 'agent-command-reset',\n commandSources: [new ResetCommandSource()],\n systemCommands: [createResetSystemCommand()],\n };\n}\n","import type {\n ICommandHostContext,\n ICommandResult,\n IEditCheckpointInspection,\n IEditCheckpointRestoreResult,\n IEditCheckpointSummary,\n} from '@robota-sdk/agent-framework';\nimport {\n inspectCommandEditCheckpoint,\n listCommandEditCheckpoints,\n restoreCommandEditCheckpoint,\n rollbackCommandEditCheckpoint,\n} from '@robota-sdk/agent-framework';\n\nconst SUBCOMMAND_INDEX = 0;\nconst CHECKPOINT_ID_INDEX = 1;\nconst PROMPT_PREVIEW_LENGTH = 120;\nconst ELLIPSIS_LENGTH = 3;\n\nfunction usage(): ICommandResult {\n return {\n message:\n 'Usage: rewind [list] | rewind inspect <checkpoint-id> | rewind restore <checkpoint-id> | rewind code <checkpoint-id> | rewind rollback <checkpoint-id>',\n success: false,\n };\n}\n\nfunction formatPrompt(prompt: string): string {\n const compact = prompt.replace(/\\s+/g, ' ').trim();\n if (compact.length <= PROMPT_PREVIEW_LENGTH) return compact;\n return `${compact.slice(0, PROMPT_PREVIEW_LENGTH - ELLIPSIS_LENGTH)}...`;\n}\n\nfunction formatList(checkpoints: readonly IEditCheckpointSummary[]): ICommandResult {\n const lines =\n checkpoints.length > 0\n ? checkpoints.map(\n (checkpoint) =>\n `- ${checkpoint.id} files=${checkpoint.fileCount} ${checkpoint.createdAt} ${formatPrompt(\n checkpoint.prompt,\n )}`,\n )\n : ['(no edit checkpoints)'];\n\n return {\n message: ['Edit checkpoints:', ...lines].join('\\n'),\n success: true,\n data: { count: checkpoints.length, checkpoints: [...checkpoints] },\n };\n}\n\nfunction formatCheckpointIds(ids: readonly string[]): string {\n return ids.length > 0 ? ids.join(', ') : '(none)';\n}\n\nfunction formatInspection(inspection: IEditCheckpointInspection): ICommandResult {\n const fileLines =\n inspection.capturedFiles.length > 0\n ? inspection.capturedFiles.map((file) => {\n const size =\n file.snapshotSizeBytes === undefined ? '' : ` size=${file.snapshotSizeBytes}B`;\n return `- ${file.relativePath} action=${file.restoreAction} snapshot=${String(\n file.snapshotAvailable,\n )}${size}`;\n })\n : ['(no files captured)'];\n\n return {\n message: [\n `Checkpoint ${inspection.target.id}`,\n `Prompt: ${formatPrompt(inspection.target.prompt)}`,\n 'Captured files:',\n ...fileLines,\n `Restore later checkpoints: files=${inspection.restoreToCheckpoint.fileCount} checkpoints=${formatCheckpointIds(\n inspection.restoreToCheckpoint.checkpointIds,\n )}`,\n `Rollback through checkpoint: files=${inspection.rollbackThroughCheckpoint.fileCount} checkpoints=${formatCheckpointIds(\n inspection.rollbackThroughCheckpoint.checkpointIds,\n )}`,\n ].join('\\n'),\n success: true,\n data: { inspection },\n };\n}\n\nfunction formatRestoreResult(result: IEditCheckpointRestoreResult): ICommandResult {\n return {\n message: [\n `Restored code to ${result.target.id}.`,\n `Restored files: ${result.restoredFileCount}`,\n `Rolled back checkpoints: ${result.restoredCheckpointCount}`,\n ].join('\\n'),\n success: true,\n data: {\n target: result.target,\n restoredCheckpointCount: result.restoredCheckpointCount,\n restoredFileCount: result.restoredFileCount,\n removedCheckpointCount: result.removedCheckpointCount,\n },\n };\n}\n\nfunction formatRollbackResult(result: IEditCheckpointRestoreResult): ICommandResult {\n return {\n message: [\n `Rolled back code through ${result.target.id}.`,\n `Restored files: ${result.restoredFileCount}`,\n `Removed checkpoints: ${result.removedCheckpointCount}`,\n ].join('\\n'),\n success: true,\n data: {\n target: result.target,\n restoredCheckpointCount: result.restoredCheckpointCount,\n restoredFileCount: result.restoredFileCount,\n removedCheckpointCount: result.removedCheckpointCount,\n },\n };\n}\n\nfunction formatError(error: Error | string): ICommandResult {\n return {\n message: error instanceof Error ? error.message : String(error),\n success: false,\n };\n}\n\nfunction inspect(context: ICommandHostContext, checkpointId: string | undefined): ICommandResult {\n if (!checkpointId) return usage();\n try {\n return formatInspection(inspectCommandEditCheckpoint(context, checkpointId));\n } catch (error) {\n return formatError(error instanceof Error ? error : String(error));\n }\n}\n\nasync function restore(\n context: ICommandHostContext,\n checkpointId: string | undefined,\n): Promise<ICommandResult> {\n if (!checkpointId) return usage();\n try {\n return formatRestoreResult(await restoreCommandEditCheckpoint(context, checkpointId));\n } catch (error) {\n return formatError(error instanceof Error ? error : String(error));\n }\n}\n\nasync function rollback(\n context: ICommandHostContext,\n checkpointId: string | undefined,\n): Promise<ICommandResult> {\n if (!checkpointId) return usage();\n try {\n return formatRollbackResult(await rollbackCommandEditCheckpoint(context, checkpointId));\n } catch (error) {\n return formatError(error instanceof Error ? error : String(error));\n }\n}\n\nexport async function executeRewindCommand(\n context: ICommandHostContext,\n rawArgs: string,\n): Promise<ICommandResult> {\n const args = rawArgs.trim().split(/\\s+/).filter(Boolean);\n const subcommand = args[SUBCOMMAND_INDEX] ?? 'list';\n\n if (subcommand === 'list') {\n return formatList(listCommandEditCheckpoints(context));\n }\n\n if (subcommand === 'inspect') {\n return inspect(context, args[CHECKPOINT_ID_INDEX]);\n }\n\n if (subcommand === 'restore' || subcommand === 'code') {\n return restore(context, args[CHECKPOINT_ID_INDEX]);\n }\n\n if (subcommand === 'rollback') {\n return rollback(context, args[CHECKPOINT_ID_INDEX]);\n }\n\n return usage();\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n REWIND_COMMAND_ARGUMENT_HINT,\n REWIND_COMMAND_DESCRIPTION,\n buildRewindCommandSubcommands,\n} from '@robota-sdk/agent-framework';\nimport { executeRewindCommand } from './rewind-command.js';\n\nexport function createRewindCommandEntry(): ICommand {\n return {\n name: 'rewind',\n description: REWIND_COMMAND_DESCRIPTION,\n source: 'rewind',\n argumentHint: REWIND_COMMAND_ARGUMENT_HINT,\n modelInvocable: false,\n safety: 'write',\n subcommands: buildRewindCommandSubcommands(),\n };\n}\n\nfunction createRewindSystemCommand(): ISystemCommand {\n const entry = createRewindCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n argumentHint: entry.argumentHint,\n userInvocable: true,\n modelInvocable: false,\n safety: 'write',\n subcommands: entry.subcommands,\n execute: executeRewindCommand,\n };\n}\n\nexport class RewindCommandSource implements ICommandSource {\n readonly name = 'rewind';\n\n getCommands(): ICommand[] {\n return [createRewindCommandEntry()];\n }\n}\n\nexport function createRewindCommandModule(): ICommandModule {\n return {\n name: 'agent-command-rewind',\n commandSources: [new RewindCommandSource()],\n systemCommands: [createRewindSystemCommand()],\n };\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\nimport {\n RENAME_COMMAND_USAGE,\n clearConversationHistory,\n createSessionPickerRequestedEffect,\n createSessionRenamedEffect,\n formatCommandSessionReplayValidationReport,\n parseSessionNameArgument,\n readCommandSessionInfo,\n validateCommandSessionReplayLog,\n} from '@robota-sdk/agent-framework';\n\nexport const CLEAR_COMMAND_MESSAGE = 'Conversation cleared.';\n\nexport function executeClearCommand(context: ICommandHostContext, _args: string): ICommandResult {\n clearConversationHistory(context);\n return {\n success: true,\n message: CLEAR_COMMAND_MESSAGE,\n effects: [{ type: 'conversation-history-cleared' }],\n };\n}\n\nexport function executeRenameCommand(_context: ICommandHostContext, args: string): ICommandResult {\n const name = parseSessionNameArgument(args);\n if (name === undefined) {\n return { success: false, message: RENAME_COMMAND_USAGE };\n }\n\n return {\n success: true,\n message: `Session renamed to \"${name}\".`,\n data: { name },\n effects: [createSessionRenamedEffect(name)],\n };\n}\n\nexport function executeResumeCommand(_context: ICommandHostContext, _args: string): ICommandResult {\n return {\n success: true,\n message: 'Opening session picker...',\n data: { triggerResumePicker: true },\n effects: [createSessionPickerRequestedEffect()],\n };\n}\n\nexport function executeCostCommand(context: ICommandHostContext, _args: string): ICommandResult {\n const sessionInfo = readCommandSessionInfo(context);\n return {\n success: true,\n message: `Session: ${sessionInfo.sessionId}\\nMessages: ${sessionInfo.messageCount}`,\n data: {\n sessionId: sessionInfo.sessionId,\n messageCount: sessionInfo.messageCount,\n },\n };\n}\n\nexport function executeValidateSessionCommand(\n context: ICommandHostContext,\n _args: string,\n): ICommandResult {\n const report = validateCommandSessionReplayLog(context);\n return {\n success: report.validation.ok,\n message: formatCommandSessionReplayValidationReport(report),\n data: {\n logFile: report.logFile,\n entryCount: report.entryCount,\n issueCount: report.validation.issues.length,\n ok: report.validation.ok,\n },\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n CLEAR_COMMAND_DESCRIPTION,\n COST_COMMAND_DESCRIPTION,\n RENAME_COMMAND_DESCRIPTION,\n RESUME_COMMAND_DESCRIPTION,\n VALIDATE_SESSION_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\nimport {\n executeClearCommand,\n executeCostCommand,\n executeRenameCommand,\n executeResumeCommand,\n executeValidateSessionCommand,\n} from './session-command.js';\n\nexport function createClearCommandEntry(): ICommand {\n return {\n name: 'clear',\n description: CLEAR_COMMAND_DESCRIPTION,\n source: 'session',\n modelInvocable: false,\n };\n}\n\nexport function createRenameCommandEntry(): ICommand {\n return {\n name: 'rename',\n description: RENAME_COMMAND_DESCRIPTION,\n source: 'session',\n modelInvocable: false,\n };\n}\n\nexport function createResumeCommandEntry(): ICommand {\n return {\n name: 'resume',\n description: RESUME_COMMAND_DESCRIPTION,\n source: 'session',\n modelInvocable: false,\n };\n}\n\nexport function createCostCommandEntry(): ICommand {\n return {\n name: 'cost',\n description: COST_COMMAND_DESCRIPTION,\n source: 'session',\n modelInvocable: false,\n };\n}\n\nexport function createValidateSessionCommandEntry(): ICommand {\n return {\n name: 'validate-session',\n description: VALIDATE_SESSION_COMMAND_DESCRIPTION,\n source: 'session',\n modelInvocable: false,\n };\n}\n\nfunction createClearSystemCommand(): ISystemCommand {\n const entry = createClearCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeClearCommand,\n };\n}\n\nfunction createRenameSystemCommand(): ISystemCommand {\n const entry = createRenameCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeRenameCommand,\n };\n}\n\nfunction createResumeSystemCommand(): ISystemCommand {\n const entry = createResumeCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeResumeCommand,\n };\n}\n\nfunction createCostSystemCommand(): ISystemCommand {\n const entry = createCostCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeCostCommand,\n };\n}\n\nfunction createValidateSessionSystemCommand(): ISystemCommand {\n const entry = createValidateSessionCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeValidateSessionCommand,\n };\n}\n\nexport class SessionCommandSource implements ICommandSource {\n readonly name = 'session';\n\n getCommands(): ICommand[] {\n return [\n createClearCommandEntry(),\n createRenameCommandEntry(),\n createResumeCommandEntry(),\n createCostCommandEntry(),\n createValidateSessionCommandEntry(),\n ];\n }\n}\n\nexport function createSessionCommandModule(): ICommandModule {\n return {\n name: 'agent-command-session',\n commandSources: [new SessionCommandSource()],\n systemCommands: [\n createClearSystemCommand(),\n createRenameSystemCommand(),\n createResumeSystemCommand(),\n createCostSystemCommand(),\n createValidateSessionSystemCommand(),\n ],\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createSettingsCommandEntry(): ICommand {\n return {\n name: 'settings',\n description: 'Open transport settings — enable/disable transports and configure options',\n source: 'settings',\n modelInvocable: false,\n };\n}\n\nfunction createSettingsSystemCommand(): ISystemCommand {\n const entry = createSettingsCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: async () => ({\n success: true,\n message: 'Opening settings...',\n effects: [{ type: 'settings-tui-requested' as const }],\n }),\n };\n}\n\nexport class SettingsCommandSource implements ICommandSource {\n readonly name = 'settings';\n\n getCommands(): ICommand[] {\n return [createSettingsCommandEntry()];\n }\n}\n\nexport function createSettingsCommandModule(): ICommandModule {\n return {\n name: 'agent-command-settings',\n commandSources: [new SettingsCommandSource()],\n systemCommands: [createSettingsSystemCommand()],\n };\n}\n","import type {\n ICommandHostContext,\n ICommandResult,\n ICommandSkillListEntry,\n} from '@robota-sdk/agent-framework';\n\nexport const SKILLS_COMMAND_DESCRIPTION =\n 'Skill command. Before following a matching registered skill from the system prompt Skills section, invoke the projected skills command tool with args \"<skill-name> [args]\". Without arguments, list registered skills. With a skill name, activate that skill. Slash syntax is a UI input/display concern; the SDK command identity is \"skills\".';\n\ninterface IParsedSkillsArgs {\n readonly action: 'list' | 'activate';\n readonly skillName?: string;\n readonly skillArgs: string;\n}\n\nfunction formatSkillFlags(skill: ICommandSkillListEntry): string {\n const flags: string[] = [];\n if (!skill.modelInvocable) flags.push('model-disabled');\n if (!skill.userInvocable) flags.push('model-only');\n if (skill.context) flags.push(`context:${skill.context}`);\n if (skill.agent) flags.push(`agent:${skill.agent}`);\n return flags.length > 0 ? ` [${flags.join(', ')}]` : '';\n}\n\nfunction formatSkillLine(skill: ICommandSkillListEntry): string {\n const hint = skill.argumentHint ? ` ${skill.argumentHint}` : '';\n return `- ${skill.name}${hint}: ${skill.description}${formatSkillFlags(skill)}`;\n}\n\nfunction formatSkillsMessage(skills: readonly ICommandSkillListEntry[]): string {\n if (skills.length === 0) {\n return [\n 'No skills are registered for this session.',\n '',\n 'Skills are metadata until activated. Do not invent or imitate a skill workflow when no matching registered skill exists.',\n ].join('\\n');\n }\n\n return [\n 'Registered skills:',\n ...skills.map(formatSkillLine),\n '',\n 'Activation contract:',\n '- Use /skills <skill-name> [args] to activate a matching skill.',\n '- Treat /<skill-name> as a virtual alias for /skills <skill-name>.',\n '- The system prompt Skills section is skill selection metadata.',\n '- Treat descriptions as selection metadata only, not as loaded SKILL.md content.',\n '- Do not answer by merely naming, recommending, or imitating a matching skill.',\n '- If no listed skill matches the task, continue without claiming a skill was activated.',\n ].join('\\n');\n}\n\nfunction parseSkillsArgs(args: string): IParsedSkillsArgs {\n const trimmed = args.trim();\n if (trimmed.length === 0 || trimmed === 'list') {\n return { action: 'list', skillArgs: '' };\n }\n\n const [skillName = '', ...rest] = trimmed.split(/\\s+/);\n if (skillName.length === 0) {\n return { action: 'list', skillArgs: '' };\n }\n\n return {\n action: 'activate',\n skillName,\n skillArgs: rest.join(' '),\n };\n}\n\nexport async function executeSkillsCommand(\n context: ICommandHostContext,\n args = '',\n): Promise<ICommandResult> {\n const parsed = parseSkillsArgs(args);\n if (parsed.action === 'activate' && parsed.skillName !== undefined) {\n if (!context.executeSkillCommandByName) {\n return {\n success: false,\n message: 'Skill activation is not available in this session.',\n };\n }\n const displayInput = `/${parsed.skillName}${parsed.skillArgs ? ` ${parsed.skillArgs}` : ''}`;\n const result = await context.executeSkillCommandByName(parsed.skillName, parsed.skillArgs, {\n invocationSource: context.getCommandInvocationSource?.() ?? 'user',\n displayInput,\n rawInput: displayInput,\n });\n return (\n result ?? {\n success: false,\n message: `Unknown skill: ${parsed.skillName}`,\n }\n );\n }\n\n const skills = context.listSkills?.() ?? [];\n return {\n success: true,\n message: formatSkillsMessage(skills),\n data: {\n skills,\n activationContract: {\n activateWith: '/skills <skill-name> [args]',\n activationRequiredBeforeWorkflow: true,\n metadataIsNotSkillContent: true,\n },\n },\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport { SkillCommandSource } from '@robota-sdk/agent-framework';\nimport { executeSkillsCommand, SKILLS_COMMAND_DESCRIPTION } from './skills-command.js';\n\nexport interface ISkillsCommandModuleOptions {\n readonly cwd?: string;\n}\n\nexport function createSkillsCommandEntry(): ICommand {\n return {\n name: 'skills',\n description: SKILLS_COMMAND_DESCRIPTION,\n source: 'skills',\n modelInvocable: true,\n userInvocable: true,\n argumentHint: '[list | <skill-name> [args]]',\n safety: 'read-only',\n };\n}\n\nfunction createSkillsSystemCommand(): ISystemCommand {\n const entry = createSkillsCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: true,\n argumentHint: entry.argumentHint,\n safety: entry.safety,\n lifecycle: 'inline',\n execute: executeSkillsCommand,\n };\n}\n\nexport class SkillsCommandSource implements ICommandSource {\n readonly name = 'skills';\n\n getCommands(): ICommand[] {\n return [createSkillsCommandEntry()];\n }\n}\n\nexport function createSkillsCommandModule(\n options: ISkillsCommandModuleOptions = {},\n): ICommandModule {\n const commandSources: ICommandSource[] = [new SkillsCommandSource()];\n commandSources.push(new SkillCommandSource(options.cwd ?? process.cwd()));\n\n return {\n name: 'agent-command-skills',\n commandSources,\n systemCommands: [createSkillsSystemCommand()],\n };\n}\n","import type {\n ICommandHostContext,\n ICommandResult,\n TStatusLineCommandSettingsPatch,\n} from '@robota-sdk/agent-framework';\nimport { DEFAULT_STATUS_LINE_COMMAND_SETTINGS } from '@robota-sdk/agent-framework';\n\ninterface IStatusLineCommandSuccessAction {\n success: true;\n message: string;\n patch: TStatusLineCommandSettingsPatch;\n}\n\ninterface IStatusLineCommandFailureAction {\n success: false;\n message: string;\n}\n\ntype TStatusLineCommandAction = IStatusLineCommandSuccessAction | IStatusLineCommandFailureAction;\n\nexport const STATUSLINE_USAGE = [\n 'Usage: /statusline on | off | reset | git on | git off',\n 'Fields: model, context, permission mode, message count, session name, thinking state, git branch.',\n].join('\\n');\n\nfunction parseStatusLineArgs(args: string): TStatusLineCommandAction {\n const parts = args\n .trim()\n .toLowerCase()\n .split(/\\s+/)\n .filter((part) => part.length > 0);\n const [first, second] = parts;\n\n if (first === 'on' && second === undefined) {\n return { success: true, message: 'Status line enabled.', patch: { enabled: true } };\n }\n if (first === 'off' && second === undefined) {\n return { success: true, message: 'Status line disabled.', patch: { enabled: false } };\n }\n if (first === 'reset' && second === undefined) {\n return {\n success: true,\n message: 'Status line settings reset.',\n patch: { ...DEFAULT_STATUS_LINE_COMMAND_SETTINGS },\n };\n }\n if (first === 'git' && second === 'on' && parts.length === 2) {\n return {\n success: true,\n message: 'Status line git branch shown.',\n patch: { gitBranch: true },\n };\n }\n if (first === 'git' && second === 'off' && parts.length === 2) {\n return {\n success: true,\n message: 'Status line git branch hidden.',\n patch: { gitBranch: false },\n };\n }\n\n return { success: false, message: STATUSLINE_USAGE };\n}\n\nexport function executeStatusLineCommand(\n _context: ICommandHostContext,\n args: string,\n): ICommandResult {\n const action = parseStatusLineArgs(args);\n if (!action.success) {\n return { success: false, message: action.message };\n }\n\n return {\n success: true,\n message: action.message,\n effects: [{ type: 'statusline-settings-patch', patch: action.patch }],\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n buildStatusLineCommandSubcommands,\n STATUSLINE_COMMAND_ARGUMENT_HINT,\n STATUSLINE_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\nimport { executeStatusLineCommand } from './statusline-command.js';\n\nexport function createStatusLineCommandEntry(): ICommand {\n return {\n name: 'statusline',\n description: STATUSLINE_COMMAND_DESCRIPTION,\n source: 'statusline',\n argumentHint: STATUSLINE_COMMAND_ARGUMENT_HINT,\n subcommands: buildStatusLineCommandSubcommands('statusline'),\n modelInvocable: false,\n };\n}\n\nfunction createStatusLineSystemCommand(): ISystemCommand {\n const entry = createStatusLineCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n lifecycle: 'inline',\n execute: executeStatusLineCommand,\n };\n}\n\nexport class StatusLineCommandSource implements ICommandSource {\n readonly name = 'statusline';\n\n getCommands(): ICommand[] {\n return [createStatusLineCommandEntry()];\n }\n}\n\nexport function createStatusLineCommandModule(): ICommandModule {\n return {\n name: 'agent-command-statusline',\n commandSources: [new StatusLineCommandSource()],\n systemCommands: [createStatusLineSystemCommand()],\n };\n}\n","export const USER_LOCAL_COMMAND_DESCRIPTION = 'Inspect Robota user-local storage and memory state.';\nexport const USER_LOCAL_COMMAND_ARGUMENT_HINT =\n 'storage list [--format json] | memory set/list/inspect/disable/delete';\nexport const USER_LOCAL_COMMAND_USAGE =\n 'Usage: user-local storage list [--format json] | user-local memory set <category> <key> <value> --summary <summary> --source <source> | user-local memory list [--format json] | user-local memory inspect <category> <key> [--format json] | user-local memory disable <category> <key> | user-local memory delete <category> <key>';\n","import type { ICommandResult, TUserLocalMemoryCategory } from '@robota-sdk/agent-framework';\nimport {\n deleteUserLocalMemoryItem,\n disableUserLocalMemoryItem,\n inspectUserLocalMemoryItem,\n listUserLocalMemoryItems,\n setUserLocalMemoryItem,\n} from '@robota-sdk/agent-framework';\nimport { USER_LOCAL_COMMAND_USAGE } from './user-local-command-constants.js';\n\nexport interface IUserLocalMemoryCommandArgs {\n readonly action?: string;\n readonly positional: readonly string[];\n readonly format: 'text' | 'json';\n readonly summary?: string;\n readonly source?: string;\n}\n\nfunction formatMemoryListText(\n items: readonly { category: string; key: string; enabled: boolean }[],\n): string {\n if (items.length === 0) {\n return 'No user-local memory items.';\n }\n return items\n .map((item) => `- ${item.category}/${item.key} (${item.enabled ? 'enabled' : 'disabled'})`)\n .join('\\n');\n}\n\nfunction parseMemoryCategory(value: string | undefined): TUserLocalMemoryCategory {\n if (value === undefined) {\n throw new Error('User-local memory category is required.');\n }\n return value as TUserLocalMemoryCategory;\n}\n\nasync function executeMemoryListCommand(\n activeRepositoryRoot: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n const list = await listUserLocalMemoryItems({ activeRepositoryRoot });\n return {\n message:\n parsed.format === 'json' ? JSON.stringify(list, null, 2) : formatMemoryListText(list.items),\n success: true,\n data: { list },\n };\n}\n\nasync function executeMemorySetCommand(\n activeRepositoryRoot: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n const [category, key, value] = parsed.positional;\n const item = await setUserLocalMemoryItem({\n activeRepositoryRoot,\n category: parseMemoryCategory(category),\n key: key ?? '',\n value: value ?? '',\n summary: parsed.summary ?? '',\n source: parsed.source ?? '',\n });\n return {\n message: `Stored user-local memory item ${item.category}/${item.key} at ${item.storageLocation}`,\n success: true,\n data: { item },\n };\n}\n\nasync function executeMemoryInspectCommand(\n activeRepositoryRoot: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n const [category, key] = parsed.positional;\n const item = await inspectUserLocalMemoryItem({\n activeRepositoryRoot,\n category: parseMemoryCategory(category),\n key: key ?? '',\n });\n return {\n message:\n parsed.format === 'json'\n ? JSON.stringify(item, null, 2)\n : `${item.category}/${item.key}: ${item.summary}`,\n success: true,\n data: { item },\n };\n}\n\nasync function executeMemoryDisableCommand(\n activeRepositoryRoot: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n const [category, key] = parsed.positional;\n const item = await disableUserLocalMemoryItem({\n activeRepositoryRoot,\n category: parseMemoryCategory(category),\n key: key ?? '',\n });\n return {\n message: `Disabled user-local memory item ${item.category}/${item.key}`,\n success: true,\n data: { item },\n };\n}\n\nasync function executeMemoryDeleteCommand(\n activeRepositoryRoot: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n const [category, key] = parsed.positional;\n const result = await deleteUserLocalMemoryItem({\n activeRepositoryRoot,\n category: parseMemoryCategory(category),\n key: key ?? '',\n });\n return {\n message: `Deleted user-local memory item ${result.category}/${result.key}`,\n success: true,\n data: { result },\n };\n}\n\nexport async function executeMemoryCommand(\n cwd: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n if ((parsed.action ?? 'list') === 'list') {\n return executeMemoryListCommand(cwd, parsed);\n }\n if (parsed.action === 'set') {\n return executeMemorySetCommand(cwd, parsed);\n }\n if (parsed.action === 'inspect') {\n return executeMemoryInspectCommand(cwd, parsed);\n }\n if (parsed.action === 'disable') {\n return executeMemoryDisableCommand(cwd, parsed);\n }\n if (parsed.action === 'delete') {\n return executeMemoryDeleteCommand(cwd, parsed);\n }\n return {\n message: USER_LOCAL_COMMAND_USAGE,\n success: false,\n };\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\nimport { inspectUserLocalStorage } from '@robota-sdk/agent-framework';\nimport { executeMemoryCommand } from './user-local-memory-command.js';\nimport { USER_LOCAL_COMMAND_USAGE } from './user-local-command-constants.js';\nexport {\n USER_LOCAL_COMMAND_ARGUMENT_HINT,\n USER_LOCAL_COMMAND_DESCRIPTION,\n USER_LOCAL_COMMAND_USAGE,\n} from './user-local-command-constants.js';\n\ntype TUserLocalOutputFormat = 'text' | 'json';\n\nexport interface IUserLocalDirectCommandOptions {\n readonly cwd: string;\n readonly argv: readonly string[];\n readonly format?: string;\n readonly summary?: string;\n readonly source?: string;\n}\n\ninterface IParsedUserLocalCommand {\n readonly target?: string;\n readonly action?: string;\n readonly positional: readonly string[];\n readonly format: TUserLocalOutputFormat;\n readonly summary?: string;\n readonly source?: string;\n}\n\ninterface IParsedUserLocalOption {\n readonly format?: string;\n readonly summary?: string;\n readonly source?: string;\n readonly nextIndex: number;\n}\n\nfunction parseOutputFormat(value: string | undefined): TUserLocalOutputFormat {\n if (value === undefined || value === 'text') {\n return 'text';\n }\n if (value === 'json') {\n return 'json';\n }\n throw new Error(`Unsupported user-local output format: ${value}`);\n}\n\nfunction parseUserLocalOption(\n arg: string,\n argv: readonly string[],\n index: number,\n): IParsedUserLocalOption | null {\n if (arg === '--format') {\n return { format: argv[index + 1], nextIndex: index + 1 };\n }\n if (arg.startsWith('--format=')) {\n return { format: arg.slice('--format='.length), nextIndex: index };\n }\n if (arg === '--summary') {\n return { summary: argv[index + 1], nextIndex: index + 1 };\n }\n if (arg.startsWith('--summary=')) {\n return { summary: arg.slice('--summary='.length), nextIndex: index };\n }\n if (arg === '--source') {\n return { source: argv[index + 1], nextIndex: index + 1 };\n }\n if (arg.startsWith('--source=')) {\n return { source: arg.slice('--source='.length), nextIndex: index };\n }\n return null;\n}\n\nfunction parseUserLocalArgs(\n argv: readonly string[],\n directOptions: {\n readonly format?: string;\n readonly summary?: string;\n readonly source?: string;\n } = {},\n): IParsedUserLocalCommand {\n let format = directOptions.format;\n let summary = directOptions.summary;\n let source = directOptions.source;\n const positional: string[] = [];\n\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index];\n const option = parseUserLocalOption(arg, argv, index);\n if (option !== null) {\n format = option.format ?? format;\n summary = option.summary ?? summary;\n source = option.source ?? source;\n index = option.nextIndex;\n continue;\n }\n positional.push(arg);\n }\n\n return {\n target: positional[0],\n action: positional[1],\n positional: positional.slice(2),\n format: parseOutputFormat(format),\n summary,\n source,\n };\n}\n\nfunction splitRawArgs(rawArgs: string): readonly string[] {\n return rawArgs.trim().split(/\\s+/).filter(Boolean);\n}\n\nfunction formatStorageInspectionText(\n root: string,\n categories: readonly { category: string }[],\n): string {\n const categoryLines = categories.map((item) => `- ${item.category}`);\n return [`User-local storage root: ${root}`, 'Categories:', ...categoryLines].join('\\n');\n}\n\nasync function executeStorageCommand(\n cwd: string,\n parsed: IParsedUserLocalCommand,\n): Promise<ICommandResult> {\n if ((parsed.action ?? 'list') !== 'list') {\n return {\n message: USER_LOCAL_COMMAND_USAGE,\n success: false,\n };\n }\n\n const inspection = await inspectUserLocalStorage({ activeRepositoryRoot: cwd });\n return {\n message:\n parsed.format === 'json'\n ? JSON.stringify(inspection, null, 2)\n : formatStorageInspectionText(inspection.root, inspection.categories),\n success: true,\n data: {\n root: inspection.root,\n categories: inspection.categories,\n inspection,\n },\n };\n}\n\nasync function executeParsedUserLocalCommand(\n cwd: string,\n parsed: IParsedUserLocalCommand,\n): Promise<ICommandResult> {\n if (parsed.target === 'storage') {\n return executeStorageCommand(cwd, parsed);\n }\n if (parsed.target === 'memory') {\n return executeMemoryCommand(cwd, parsed);\n }\n return {\n message: USER_LOCAL_COMMAND_USAGE,\n success: false,\n };\n}\n\nfunction formatCommandErrorMessage(errorMessage: string): string {\n if (errorMessage.includes('ENOENT')) {\n return 'User-local memory item not found.';\n }\n return errorMessage;\n}\n\nexport async function executeUserLocalDirectCommand(\n options: IUserLocalDirectCommandOptions,\n): Promise<ICommandResult> {\n try {\n return await executeParsedUserLocalCommand(\n options.cwd,\n parseUserLocalArgs(options.argv, {\n format: options.format,\n summary: options.summary,\n source: options.source,\n }),\n );\n } catch (error) {\n return {\n message: formatCommandErrorMessage(error instanceof Error ? error.message : String(error)),\n success: false,\n };\n }\n}\n\nexport async function executeUserLocalCommand(\n context: ICommandHostContext,\n rawArgs: string,\n): Promise<ICommandResult> {\n try {\n return await executeParsedUserLocalCommand(\n context.getCwd(),\n parseUserLocalArgs(splitRawArgs(rawArgs)),\n );\n } catch (error) {\n return {\n message: formatCommandErrorMessage(error instanceof Error ? error.message : String(error)),\n success: false,\n };\n }\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport {\n USER_LOCAL_COMMAND_ARGUMENT_HINT,\n USER_LOCAL_COMMAND_DESCRIPTION,\n executeUserLocalCommand,\n} from './user-local-command.js';\n\nexport function createUserLocalCommandEntry(): ICommand {\n return {\n name: 'user-local',\n description: USER_LOCAL_COMMAND_DESCRIPTION,\n source: 'user-local',\n argumentHint: USER_LOCAL_COMMAND_ARGUMENT_HINT,\n modelInvocable: false,\n safety: 'read-only',\n subcommands: [\n {\n name: 'storage',\n description: 'Inspect user-local storage categories',\n source: 'user-local',\n },\n {\n name: 'memory',\n description: 'Inspect and manage user-local memory items',\n source: 'user-local',\n },\n ],\n };\n}\n\nfunction createUserLocalSystemCommand(): ISystemCommand {\n const entry = createUserLocalCommandEntry();\n return {\n name: entry.name,\n description: entry.description,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n safety: entry.safety,\n subcommands: entry.subcommands,\n execute: executeUserLocalCommand,\n };\n}\n\nexport class UserLocalCommandSource implements ICommandSource {\n readonly name = 'user-local';\n\n getCommands(): ICommand[] {\n return [createUserLocalCommandEntry()];\n }\n}\n\nexport function createUserLocalCommandModule(): ICommandModule {\n return {\n name: 'agent-command-user-local',\n commandSources: [new UserLocalCommandSource()],\n systemCommands: [createUserLocalSystemCommand()],\n };\n}\n"],"mappings":"8gHAsBA,SAAgB,GAAa,EAAwB,CACnD,IAAM,EAAmB,CAAC,EACtB,EAAU,GACV,EACA,EAAU,GAEd,IAAK,IAAM,KAAQ,EAAM,CACvB,GAAI,EAAS,CACX,GAAW,EACX,EAAU,GACV,QACF,CACA,GAAI,GAAS,IAAS,KAAM,CAC1B,EAAU,GACV,QACF,CACA,GAAI,EAAO,CACL,IAAS,EAAO,EAAQ,IAAA,GACvB,GAAW,EAChB,QACF,CACA,GAAI,IAAS,KAAO,IAAS,IAAK,CAChC,EAAQ,EACR,QACF,CACA,GAAI,KAAK,KAAK,CAAI,EAAG,CACf,EAAQ,OAAS,IACnB,EAAO,KAAK,CAAO,EACnB,EAAU,IAEZ,QACF,CACA,GAAW,CACb,CAGA,OADI,EAAQ,OAAS,GAAG,EAAO,KAAK,CAAO,EACpC,CACT,CAEA,SAAS,GAAa,EAAgD,CACpE,IAAM,EAAuB,CAAC,EAC1B,EACA,EACA,EAEJ,IAAK,IAAI,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aACN,YAAa,GACb,OAAQ,aACR,aAAc,GACd,eAAgB,GAChB,OAAQ,YACR,YAAa,CACX,CACE,KAAM,UACN,YAAa,wCACb,OAAQ,YACV,EACA,CACE,KAAM,SACN,YAAa,6CACb,OAAQ,YACV,CACF,CACF,CACF,CAEA,SAAS,IAA+C,CACtD,IAAM,EAAQ,GAA4B,EAC1C,MAAO,CACL,KAAM,EAAM,KACZ,YAAa,EAAM,YACnB,cAAe,GACf,eAAgB,GAChB,aAAc,EAAM,aACpB,OAAQ,EAAM,OACd,YAAa,EAAM,YACnB,QAAS,EACX,CACF,CAEA,IAAa,GAAb,KAA8D,CAC5D,KAAgB,aAEhB,aAA0B,CACxB,MAAO,CAAC,GAA4B,CAAC,CACvC,CACF,EAEA,SAAgB,IAA+C,CAC7D,MAAO,CACL,KAAM,2BACN,eAAgB,CAAC,IAAI,EAAwB,EAC7C,eAAgB,CAAC,GAA6B,CAAC,CACjD,CACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["formatError","SUBCOMMAND_INDEX","usage","formatError","formatList","usage","PROVIDER_RESTART_EFFECT","YES","PROVIDER_RESTART_EFFECT","executeMemoryCommand","executeMemoryCommand"],"sources":["../../src/agent/agent-command-parser.ts","../../src/agent/agent-command.ts","../../src/agent/agent-command-module.ts","../../src/background/background-command.ts","../../src/background/background-command-module.ts","../../src/compact/compact-command.ts","../../src/compact/compact-command-module.ts","../../src/context/context-command.ts","../../src/context/context-command-module.ts","../../src/exit/exit-command.ts","../../src/exit/exit-command-module.ts","../../src/help/help-command.ts","../../src/help/help-command-module.ts","../../src/language/language-command.ts","../../src/language/language-command-module.ts","../../src/memory/memory-command.ts","../../src/memory/memory-command-module.ts","../../src/mode/mode-command.ts","../../src/mode/mode-command-module.ts","../../src/model/model-command.ts","../../src/model/model-command-module.ts","../../src/permissions/permissions-command.ts","../../src/permissions/permissions-command-module.ts","../../src/plugin/plugin-command.ts","../../src/plugin/plugin-command-module.ts","../../src/provider/provider-setup-flow.ts","../../src/provider/provider-command-setup.ts","../../src/provider/provider-command-profile-operations.ts","../../src/provider/provider-command-profile-lifecycle.ts","../../src/provider/provider-command-profile.ts","../../src/provider/provider-command-execution.ts","../../src/provider/provider-command-module.ts","../../src/provider/provider-startup.ts","../../src/reset/reset-command.ts","../../src/reset/reset-command-module.ts","../../src/rewind/rewind-command.ts","../../src/rewind/rewind-command-module.ts","../../src/session/session-command.ts","../../src/session/session-command-module.ts","../../src/settings/settings-command-module.ts","../../src/skills/skills-command.ts","../../src/skills/skills-command-module.ts","../../src/statusline/statusline-command.ts","../../src/statusline/statusline-command-module.ts","../../src/user-local/user-local-command-constants.ts","../../src/user-local/user-local-memory-command.ts","../../src/user-local/user-local-command.ts","../../src/user-local/user-local-command-module.ts","../../src/default/default-command-modules.ts","../../src/plugins/default-plugin-command-adapter.ts","../../src/plugins/default-plugin-command-source-loader.ts"],"sourcesContent":["import type { TBackgroundTaskIsolation } from '@robota-sdk/agent-framework';\n\nexport const DEFAULT_AGENT_TYPE = 'general-purpose';\n\nexport type TAgentMode = 'background';\n\nexport interface IAgentRunRequest {\n readonly agentType: string;\n readonly label: string;\n readonly mode: TAgentMode;\n readonly prompt: string;\n readonly model?: string;\n readonly isolation?: TBackgroundTaskIsolation;\n}\n\ninterface IParsedAgentOptions {\n readonly agentType?: string;\n readonly model?: string;\n readonly isolation?: TBackgroundTaskIsolation;\n readonly positional: string[];\n}\n\nexport function tokenizeArgs(args: string): string[] {\n const tokens: string[] = [];\n let current = '';\n let quote: '\"' | \"'\" | undefined;\n let escaped = false;\n\n for (const char of args) {\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n if (quote && char === '\\\\') {\n escaped = true;\n continue;\n }\n if (quote) {\n if (char === quote) quote = undefined;\n else current += char;\n continue;\n }\n if (char === '\"' || char === \"'\") {\n quote = char;\n continue;\n }\n if (/\\s/.test(char)) {\n if (current.length > 0) {\n tokens.push(current);\n current = '';\n }\n continue;\n }\n current += char;\n }\n\n if (current.length > 0) tokens.push(current);\n return tokens;\n}\n\nfunction parseOptions(tokens: readonly string[]): IParsedAgentOptions {\n const positional: string[] = [];\n let agentType: string | undefined;\n let model: string | undefined;\n let isolation: TBackgroundTaskIsolation | undefined;\n\n for (let index = 0; index < tokens.length; index += 1) {\n const token = tokens[index];\n if (token === '--background') {\n continue;\n }\n if (token === '--agent' || token === '--type' || token === '-a') {\n agentType = tokens[index + 1];\n index += 1;\n continue;\n }\n if (token === '--model') {\n model = tokens[index + 1];\n index += 1;\n continue;\n }\n if (token === '--isolation') {\n const value = tokens[index + 1];\n if (value === 'none' || value === 'worktree') isolation = value;\n index += 1;\n continue;\n }\n if (token !== undefined) positional.push(token);\n }\n\n return {\n positional,\n ...(agentType ? { agentType } : {}),\n ...(model ? { model } : {}),\n ...(isolation ? { isolation } : {}),\n };\n}\n\nfunction createRequest(\n options: IParsedAgentOptions,\n agentType: string,\n label: string,\n prompt: string,\n): IAgentRunRequest {\n return {\n agentType,\n label,\n mode: 'background',\n prompt,\n ...(options.model ? { model: options.model } : {}),\n ...(options.isolation ? { isolation: options.isolation } : {}),\n };\n}\n\nexport function parseRunRequest(\n tokens: readonly string[],\n availableAgentNames: ReadonlySet<string>,\n): IAgentRunRequest | undefined {\n const options = parseOptions(tokens);\n const [first, ...rest] = options.positional;\n let agentType = options.agentType ?? DEFAULT_AGENT_TYPE;\n let promptParts = options.positional;\n\n if (!options.agentType && first && availableAgentNames.has(first)) {\n agentType = first;\n promptParts = rest;\n }\n\n const prompt = promptParts.join(' ').trim();\n if (!prompt) return undefined;\n return createRequest(options, agentType, agentType, prompt);\n}\n\nexport function parseParallelRequests(\n tokens: readonly string[],\n availableAgentNames: ReadonlySet<string>,\n): IAgentRunRequest[] {\n const options = parseOptions(tokens);\n return options.positional\n .map((token) => parseAgentJobToken(token, options, availableAgentNames))\n .filter((job): job is IAgentRunRequest => job !== undefined);\n}\n\nfunction parseAgentJobToken(\n token: string,\n options: IParsedAgentOptions,\n availableAgentNames: ReadonlySet<string>,\n): IAgentRunRequest | undefined {\n const equalsIndex = token.indexOf('=');\n if (equalsIndex > 0) {\n const label = token.slice(0, equalsIndex);\n const spec = token.slice(equalsIndex + 1);\n return parseAgentPromptSpec(label, spec, options, availableAgentNames);\n }\n\n const colonIndex = token.indexOf(':');\n if (colonIndex <= 0 || colonIndex === token.length - 1) return undefined;\n const head = token.slice(0, colonIndex);\n const prompt = token.slice(colonIndex + 1);\n const agentType =\n options.agentType ?? (availableAgentNames.has(head) ? head : DEFAULT_AGENT_TYPE);\n return createRequest(options, agentType, head, prompt);\n}\n\nfunction parseAgentPromptSpec(\n label: string,\n spec: string,\n options: IParsedAgentOptions,\n availableAgentNames: ReadonlySet<string>,\n): IAgentRunRequest | undefined {\n const colonIndex = spec.indexOf(':');\n if (colonIndex === -1) {\n const agentType =\n options.agentType ?? (availableAgentNames.has(label) ? label : DEFAULT_AGENT_TYPE);\n return createRequest(options, agentType, label, spec);\n }\n if (colonIndex === 0 || colonIndex === spec.length - 1) return undefined;\n return createRequest(options, spec.slice(0, colonIndex), label, spec.slice(colonIndex + 1));\n}\n","import { summarizeBackgroundJobGroup } from '@robota-sdk/agent-framework';\n\nimport { parseParallelRequests, parseRunRequest, tokenizeArgs } from './agent-command-parser.js';\n\nimport type { IAgentRunRequest } from './agent-command-parser.js';\nimport type {\n IAgentJobHostContext,\n ICommandResult,\n ISubagentJobState,\n} from '@robota-sdk/agent-framework';\n\nfunction formatError<TError>(error: TError): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction getAvailableAgentNames(session: IAgentJobHostContext): ReadonlySet<string> {\n return new Set(session.listAgentDefinitions().map((agent) => agent.name));\n}\n\nfunction validateAgentType(\n session: IAgentJobHostContext,\n agentType: string,\n): ICommandResult | undefined {\n const agents = session.listAgentDefinitions();\n if (agents.some((agent) => agent.name === agentType)) return undefined;\n return {\n message: `Unknown agent type: ${agentType}\\nAvailable agents: ${agents.map((agent) => agent.name).join(', ')}`,\n success: false,\n };\n}\n\nasync function spawnAgentJob(\n session: IAgentJobHostContext,\n request: IAgentRunRequest,\n): Promise<ICommandResult | { state: ISubagentJobState }> {\n const invalid = validateAgentType(session, request.agentType);\n if (invalid) return invalid;\n try {\n return { state: await session.spawnAgentJob(request) };\n } catch (error) {\n return { message: formatError(error), success: false };\n }\n}\n\nfunction executeOpenSwitcher(): ICommandResult {\n return { message: '', effects: [{ type: 'agent-switcher-requested' }], success: true };\n}\n\nasync function executeList(session: IAgentJobHostContext): Promise<ICommandResult> {\n const agents = session.listAgentDefinitions();\n const jobs = session.listAgentJobs();\n const lines = [\n 'Available agents:',\n ...agents.map((agent) => ` ${agent.name} - ${agent.description}`),\n '',\n jobs.length === 0 ? 'No active agent jobs.' : 'Agent jobs:',\n ...jobs.map((job) => ` ${formatAgentJobLine(job)}`),\n ];\n return {\n message: lines.join('\\n'),\n success: true,\n data: { agents: agents.length, jobs: jobs.length },\n };\n}\n\nfunction formatAgentJobLine(job: ISubagentJobState): string {\n const worktree = [\n job.worktreePath ? `worktree=${job.worktreePath}` : undefined,\n job.branchName ? `branch=${job.branchName}` : undefined,\n ].filter((segment): segment is string => segment !== undefined);\n const metadata = worktree.length > 0 ? ` ${worktree.join(' ')}` : '';\n return `${job.id} [${job.status}${metadata}] ${job.label} - ${job.promptPreview}`;\n}\n\nasync function executeRun(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const request = parseRunRequest(tokens, getAvailableAgentNames(session));\n if (!request) {\n return {\n message: 'Usage: agent run [AGENT_NAME] [--agent AGENT_NAME] PROMPT',\n success: false,\n };\n }\n\n const spawned = await spawnAgentJob(session, request);\n if ('success' in spawned) return spawned;\n const { state } = spawned;\n\n return {\n message: `Started agent job: ${state.id}`,\n success: true,\n data: { agentId: state.id, status: state.status },\n };\n}\n\nasync function executeParallel(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const wait = tokens.includes('--wait') || !tokens.includes('--detach');\n const commandTokens = tokens.filter((token) => token !== '--wait' && token !== '--detach');\n const jobs = parseParallelRequests(commandTokens, getAvailableAgentNames(session));\n\n if (jobs.length === 0) {\n return {\n message: 'Usage: agent parallel [--wait|--detach] LABEL:\"PROMPT\" [LABEL=AGENT_NAME:\"PROMPT\"]',\n success: false,\n };\n }\n\n const invalid = jobs\n .map((job) => validateAgentType(session, job.agentType))\n .find((result): result is ICommandResult => result !== undefined);\n if (invalid) return invalid;\n\n let states: ISubagentJobState[];\n try {\n states = await Promise.all(jobs.map((job) => session.spawnAgentJob(job)));\n } catch (error) {\n return { message: formatError(error), success: false };\n }\n const group = session.createBackgroundJobGroup({\n waitPolicy: 'wait_all',\n taskIds: states.map((state) => state.id),\n label: 'agent parallel',\n });\n\n if (wait) {\n const completed = await session.waitBackgroundJobGroup(group.id);\n const summary = summarizeBackgroundJobGroup(completed);\n return {\n message: formatGroupSummary(summary),\n success: true,\n data: { agentIds: states.map((state) => state.id), groupId: group.id, summary },\n };\n }\n\n return {\n message: ['Started agent jobs:', ...states.map((state) => `${state.label}: ${state.id}`)].join(\n '\\n',\n ),\n success: true,\n data: { agentIds: states.map((state) => state.id), groupId: group.id },\n };\n}\n\nasync function executeWait(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const [groupId] = tokens;\n if (!groupId) return { message: 'Usage: agent wait GROUP_ID', success: false };\n const completed = await session.waitBackgroundJobGroup(groupId);\n const summary = summarizeBackgroundJobGroup(completed);\n return {\n message: formatGroupSummary(summary),\n success: true,\n data: { groupId, summary },\n };\n}\n\nasync function executeRead(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const [agentId, offset] = tokens;\n if (!agentId) return { message: 'Usage: agent read AGENT_ID [OFFSET]', success: false };\n const cursor = offset ? { offset: Number.parseInt(offset, 10) } : undefined;\n const page = await session.readBackgroundTaskLog(agentId, cursor);\n const next = page.nextCursor ? `\\nNext offset: ${page.nextCursor.offset}` : '';\n return {\n message: page.lines.length > 0 ? `${page.lines.join('\\n')}${next}` : `No log lines: ${agentId}`,\n success: true,\n data: { agentId, nextOffset: page.nextCursor?.offset },\n };\n}\n\nasync function executeSend(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const [agentId, ...promptParts] = tokens;\n const prompt = promptParts.join(' ').trim();\n if (!agentId || !prompt) {\n return { message: 'Usage: agent send AGENT_ID PROMPT', success: false };\n }\n await session.sendAgentJob(agentId, prompt);\n return { message: `Sent input to agent job: ${agentId}`, success: true, data: { agentId } };\n}\n\nasync function executeStop(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const [agentId, ...reasonParts] = tokens;\n if (!agentId) return { message: 'Usage: agent stop AGENT_ID [REASON]', success: false };\n await session.cancelAgentJob(agentId, reasonParts.join(' ') || undefined);\n return { message: `Agent job stopped: ${agentId}`, success: true, data: { agentId } };\n}\n\nasync function executeClose(\n session: IAgentJobHostContext,\n tokens: readonly string[],\n): Promise<ICommandResult> {\n const [agentId] = tokens;\n if (!agentId) return { message: 'Usage: agent close AGENT_ID', success: false };\n await session.closeAgentJob(agentId);\n return { message: `Agent job closed: ${agentId}`, success: true, data: { agentId } };\n}\n\nexport async function executeAgentCommand(\n session: IAgentJobHostContext,\n args: string,\n): Promise<ICommandResult> {\n try {\n if (args.trim() === '') return executeOpenSwitcher();\n const [action = 'list', ...tokens] = tokenizeArgs(args);\n if (action === 'list' && tokens.length === 0) return executeList(session);\n if (action === 'run') return executeRun(session, tokens);\n if (action === 'parallel') return executeParallel(session, tokens);\n if (action === 'wait') return executeWait(session, tokens);\n if (action === 'read' || action === 'open') return executeRead(session, tokens);\n if (action === 'send') return executeSend(session, tokens);\n if (action === 'stop' || action === 'cancel') return executeStop(session, tokens);\n if (action === 'close') return executeClose(session, tokens);\n return executeRun(session, [action, ...tokens]);\n } catch (error) {\n return { message: formatError(error), success: false };\n }\n}\n\nfunction formatGroupSummary(summary: ReturnType<typeof summarizeBackgroundJobGroup>): string {\n const header = `Background job group ${summary.groupId}: ${summary.status} (${summary.completed}/${summary.total} completed, ${summary.failed} failed, ${summary.cancelled} cancelled, ${summary.pending} pending)`;\n return [header, ...summary.lines].join('\\n');\n}\n","import { executeAgentCommand } from './agent-command.js';\n\nimport type {\n IAgentJobHostContext,\n ICommand,\n ICommandHostContext,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nfunction getAgentHostContext(context: ICommandHostContext): IAgentJobHostContext {\n const cap = context.getAgentJobCapability?.();\n if (!cap) throw new Error('Agent job capability is not available in this context.');\n return cap;\n}\n\nfunction createAgentSubcommands(): ICommand[] {\n return [\n { name: 'list', description: 'List available agents and active jobs', source: 'agent' },\n { name: 'run', description: 'Start one background agent job', source: 'agent' },\n { name: 'parallel', description: 'Run multiple agents in parallel', source: 'agent' },\n { name: 'wait', description: 'Wait for a background agent group summary', source: 'agent' },\n { name: 'read', description: 'Read an agent job log page', source: 'agent' },\n { name: 'send', description: 'Send follow-up input to an agent job', source: 'agent' },\n { name: 'stop', description: 'Cancel a running agent job', source: 'agent' },\n { name: 'close', description: 'Dismiss a terminal agent job', source: 'agent' },\n { name: 'open', description: 'Focus an agent job detail view when supported', source: 'agent' },\n ];\n}\n\nexport function createAgentCommandEntry(): ICommand {\n return {\n name: 'agent',\n displayName: 'Agent Jobs',\n description: [\n 'Subagent jobs command.',\n 'Natural-language arguments start one background agent job.',\n 'When the user explicitly asks to create, run, spawn, delegate to, or use agents/subagents, start the requested agent command immediately and do not ask a follow-up question unless execution is impossible or unsafe.',\n 'If the target item is unspecified, include target selection inside the agent prompt instead of delaying execution.',\n 'The parallel form starts multiple background agent jobs as a wait_all group and returns a consolidated group summary unless --detach is present.',\n 'list, wait, read, send, stop, close, and open manage existing agent jobs.',\n ].join(' '),\n source: 'agent',\n modelInvocable: true,\n argumentHint:\n 'PROMPT | AGENT_NAME PROMPT | list | parallel [--wait|--detach] LABEL:\"PROMPT\" [LABEL=AGENT_NAME:\"PROMPT\"] | wait GROUP_ID | read AGENT_ID [OFFSET] | send AGENT_ID PROMPT | stop AGENT_ID | close AGENT_ID',\n safety: 'background-agent',\n subcommands: createAgentSubcommands(),\n };\n}\n\nexport function createAgentSystemCommand(): ISystemCommand {\n const entry = createAgentCommandEntry();\n return {\n name: entry.name,\n ...(entry.displayName !== undefined ? { displayName: entry.displayName } : {}),\n description: entry.description,\n requiresPermission: false,\n execute: (context, args) => executeAgentCommand(getAgentHostContext(context), args),\n ...(entry.modelInvocable !== undefined ? { modelInvocable: entry.modelInvocable } : {}),\n ...(entry.userInvocable !== undefined ? { userInvocable: entry.userInvocable } : {}),\n ...(entry.argumentHint !== undefined ? { argumentHint: entry.argumentHint } : {}),\n ...(entry.safety !== undefined ? { safety: entry.safety } : {}),\n };\n}\n\nexport class AgentCommandSource implements ICommandSource {\n readonly name = 'agent';\n\n getCommands(): ICommand[] {\n return [createAgentCommandEntry()];\n }\n}\n\nexport function createAgentCommandModule(): ICommandModule {\n return {\n name: 'agent-command-agent',\n commandSources: [new AgentCommandSource()],\n systemCommands: [createAgentSystemCommand()],\n sessionRequirements: ['agent-runtime'],\n };\n}\n","import {\n BACKGROUND_COMMAND_USAGE,\n cancelCommandBackgroundTask,\n closeCommandBackgroundTask,\n formatCommandBackgroundTaskList,\n listCommandBackgroundTasks,\n parseCommandBackgroundLogCursor,\n readCommandBackgroundTaskLog,\n} from '@robota-sdk/agent-framework';\n\nimport type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\n\nfunction parseCommandParts(args: string): string[] {\n return args.trim().split(/\\s+/).filter(Boolean);\n}\n\nexport async function executeBackgroundCommand(\n context: ICommandHostContext,\n args: string,\n): Promise<ICommandResult> {\n const [action = 'list', taskId, ...reasonParts] = parseCommandParts(args);\n if (action === 'list') {\n const tasks = listCommandBackgroundTasks(context);\n return {\n message: formatCommandBackgroundTaskList(tasks),\n success: true,\n data: { count: tasks.length },\n };\n }\n\n if (!taskId) {\n return {\n message: BACKGROUND_COMMAND_USAGE,\n success: false,\n };\n }\n\n if (action === 'read' || action === 'log' || action === 'open') {\n const page = await readCommandBackgroundTaskLog(\n context,\n taskId,\n parseCommandBackgroundLogCursor(reasonParts[0]),\n );\n const next = page.nextCursor ? `\\nNext offset: ${page.nextCursor.offset}` : '';\n return {\n message:\n page.lines.length > 0 ? `${page.lines.join('\\n')}${next}` : `No log lines: ${taskId}`,\n success: true,\n data: { taskId, nextOffset: page.nextCursor?.offset },\n };\n }\n\n if (action === 'cancel' || action === 'stop') {\n await cancelCommandBackgroundTask(context, taskId, reasonParts.join(' ') || undefined);\n return { message: `Background task cancelled: ${taskId}`, success: true, data: { taskId } };\n }\n\n if (action === 'close' || action === 'dismiss') {\n await closeCommandBackgroundTask(context, taskId);\n return { message: `Background task closed: ${taskId}`, success: true, data: { taskId } };\n }\n\n return { message: `Unknown background action: ${action}`, success: false };\n}\n","import {\n BACKGROUND_COMMAND_DESCRIPTION,\n buildBackgroundCommandSubcommands,\n} from '@robota-sdk/agent-framework';\n\nimport { executeBackgroundCommand } from './background-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createBackgroundCommandEntry(): ICommand {\n return {\n name: 'background',\n displayName: 'Background Tasks',\n description: BACKGROUND_COMMAND_DESCRIPTION,\n source: 'background',\n modelInvocable: false,\n subcommands: buildBackgroundCommandSubcommands(),\n };\n}\n\nfunction createBackgroundSystemCommand(): ISystemCommand {\n const entry = createBackgroundCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n subcommands: entry.subcommands,\n execute: executeBackgroundCommand,\n };\n}\n\nexport class BackgroundCommandSource implements ICommandSource {\n readonly name = 'background';\n\n getCommands(): ICommand[] {\n return [createBackgroundCommandEntry()];\n }\n}\n\nexport function createBackgroundCommandModule(): ICommandModule {\n return {\n name: 'agent-command-background',\n commandSources: [new BackgroundCommandSource()],\n systemCommands: [createBackgroundSystemCommand()],\n };\n}\n","import { compactCommandContext } from '@robota-sdk/agent-framework';\n\nimport type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\n\nfunction parseInstructions(args: string): string | undefined {\n const instructions = args.trim();\n return instructions.length > 0 ? instructions : undefined;\n}\n\nexport async function executeCompactCommand(\n context: ICommandHostContext,\n args: string,\n): Promise<ICommandResult> {\n const result = await compactCommandContext(context, parseInstructions(args));\n const before = result.before.usedPercentage;\n const after = result.after.usedPercentage;\n return {\n message: `Context compacted: ${Math.round(before)}% -> ${Math.round(after)}%`,\n success: true,\n data: { before, after },\n };\n}\n","import { executeCompactCommand } from './compact-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createCompactCommandEntry(): ICommand {\n return {\n name: 'compact',\n displayName: 'Compact Context',\n description: 'Compress context window',\n source: 'compact',\n modelInvocable: true,\n argumentHint: '[instructions]',\n safety: 'write',\n };\n}\n\nfunction createCompactSystemCommand(): ISystemCommand {\n const entry = createCompactCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: entry.modelInvocable,\n argumentHint: entry.argumentHint,\n safety: entry.safety,\n lifecycle: 'blocking',\n execute: executeCompactCommand,\n };\n}\n\nexport class CompactCommandSource implements ICommandSource {\n readonly name = 'compact';\n\n getCommands(): ICommand[] {\n return [createCompactCommandEntry()];\n }\n}\n\nexport function createCompactCommandModule(): ICommandModule {\n return {\n name: 'agent-command-compact',\n commandSources: [new CompactCommandSource()],\n systemCommands: [createCompactSystemCommand()],\n };\n}\n","import {\n addCommandContextReference,\n clearCommandContextReferences,\n DEFAULT_AUTO_COMPACT_THRESHOLD,\n listCommandContextReferences,\n readAutoCompactThreshold,\n readAutoCompactThresholdSource,\n readCommandContextState,\n removeCommandContextReference,\n resetAutoCompactThresholdSetting,\n setCommandAutoCompactThreshold,\n writeAutoCompactThresholdSetting,\n} from '@robota-sdk/agent-framework';\n\nimport type {\n ICommandHostContext,\n ICommandResult,\n TAutoCompactThreshold,\n TAutoCompactThresholdSource,\n} from '@robota-sdk/agent-framework';\nimport type { IContextReferenceItem } from '@robota-sdk/agent-framework';\n\nconst PERCENT = 100;\nconst USAGE = [\n 'Usage: /context [list] | add <path> | remove <path> | clear | auto on | off | <percent> | reset',\n 'Examples: /context list, /context add AGENTS.md, /context remove AGENTS.md, /context auto 85%',\n].join('\\n');\n\nfunction formatThreshold(threshold: TAutoCompactThreshold): string {\n if (threshold === false) {\n return 'disabled';\n }\n return `${Math.round(threshold * PERCENT)}%`;\n}\n\nfunction formatAutoCompactLine(\n threshold: TAutoCompactThreshold,\n source: TAutoCompactThresholdSource,\n): string {\n if (threshold === false) {\n return `Auto compact: disabled (${source})`;\n }\n return `Auto compact: ${formatThreshold(threshold)} (${source})`;\n}\n\nfunction formatPersistenceSuffix(persisted: boolean): string {\n return persisted ? 'settings' : 'current session only';\n}\n\nexport async function executeContextCommand(\n context: ICommandHostContext,\n args: string,\n): Promise<ICommandResult> {\n const parts = args\n .trim()\n .split(/\\s+/)\n .filter((part) => part.length > 0);\n\n if (parts.length > 0) {\n return executeContextSubcommand(context, parts);\n }\n\n const state = readCommandContextState(context);\n const autoCompactThreshold = readAutoCompactThreshold(context);\n const autoCompactThresholdSource = readAutoCompactThresholdSource(context);\n return {\n message: [\n `Context: ${state.usedTokens.toLocaleString()} / ${state.maxTokens.toLocaleString()} tokens (${Math.round(state.usedPercentage)}%)`,\n formatAutoCompactLine(autoCompactThreshold, autoCompactThresholdSource),\n formatContextReferenceSummary(listCommandContextReferences(context)),\n ].join('\\n'),\n success: true,\n data: {\n usedTokens: state.usedTokens,\n maxTokens: state.maxTokens,\n percentage: state.usedPercentage,\n autoCompactThreshold,\n autoCompactThresholdSource,\n references: listCommandContextReferences(context),\n },\n };\n}\n\nasync function executeContextSubcommand(\n context: ICommandHostContext,\n parts: readonly string[],\n): Promise<ICommandResult> {\n const [subcommand, ...rest] = parts;\n if (subcommand === 'list') {\n if (rest.length > 0) return { success: false, message: USAGE };\n return formatContextReferenceList(listCommandContextReferences(context));\n }\n if (subcommand === 'add') {\n return executeAddContextReference(context, rest);\n }\n if (subcommand === 'remove') {\n return executeRemoveContextReference(context, rest);\n }\n if (subcommand === 'clear') {\n if (rest.length > 0) return { success: false, message: USAGE };\n const result = clearCommandContextReferences(context);\n return {\n success: true,\n message: `Context references cleared: ${result.removed.length} removed.`,\n data: { removed: result.removed },\n };\n }\n if (subcommand !== 'auto') {\n return { success: false, message: USAGE };\n }\n return executeAutoContextSubcommand(context, rest);\n}\n\nfunction executeAutoContextSubcommand(\n context: ICommandHostContext,\n parts: readonly string[],\n): ICommandResult {\n const [action, extra] = parts;\n if (extra !== undefined) return { success: false, message: USAGE };\n if (action === undefined) {\n const threshold = readAutoCompactThreshold(context);\n const source = readAutoCompactThresholdSource(context);\n return {\n success: true,\n message: [formatAutoCompactLine(threshold, source), USAGE].join('\\n'),\n data: { autoCompactThreshold: threshold, autoCompactThresholdSource: source },\n };\n }\n\n if (action === 'on') {\n return applyAutoCompactThreshold(context, DEFAULT_AUTO_COMPACT_THRESHOLD, 'enabled');\n }\n if (action === 'off') {\n return applyAutoCompactThreshold(context, false, 'disabled');\n }\n if (action === 'reset') {\n const persisted = resetAutoCompactThresholdSetting(context);\n setCommandAutoCompactThreshold(context, DEFAULT_AUTO_COMPACT_THRESHOLD, 'default');\n return {\n success: true,\n message: `Auto compact reset to default: ${formatThreshold(DEFAULT_AUTO_COMPACT_THRESHOLD)} (${formatPersistenceSuffix(persisted)}).`,\n data: {\n autoCompactThreshold: DEFAULT_AUTO_COMPACT_THRESHOLD,\n autoCompactThresholdSource: 'default',\n persisted,\n },\n };\n }\n\n const parsed = parseThreshold(action);\n if (!parsed.success) {\n return { success: false, message: `${parsed.message}\\n${USAGE}` };\n }\n return applyAutoCompactThreshold(context, parsed.threshold, 'threshold set');\n}\n\nasync function executeAddContextReference(\n context: ICommandHostContext,\n args: readonly string[],\n): Promise<ICommandResult> {\n const path = args.join(' ').trim();\n if (!path) return { success: false, message: USAGE };\n\n const result = await addCommandContextReference(context, path);\n if (!result.reference) {\n return {\n success: false,\n message: result.diagnostics.join('\\n') || `Context reference not found: ${path}`,\n data: { diagnostics: result.diagnostics },\n };\n }\n\n return {\n success: true,\n message: [\n `Context reference added: ${formatContextReferenceLine(result.reference)}.`,\n ...(result.evicted.length > 0\n ? [`Evicted ${result.evicted.length} older context reference(s).`]\n : []),\n ].join('\\n'),\n data: { reference: result.reference, evicted: result.evicted },\n };\n}\n\nfunction executeRemoveContextReference(\n context: ICommandHostContext,\n args: readonly string[],\n): ICommandResult {\n const path = args.join(' ').trim();\n if (!path) return { success: false, message: USAGE };\n\n const result = removeCommandContextReference(context, path);\n if (!result.removed) {\n return {\n success: false,\n message: `Context reference not found: ${path}`,\n };\n }\n\n return {\n success: true,\n message: `Context reference removed: ${formatContextReferenceLine(result.removed)}.`,\n data: { removed: result.removed },\n };\n}\n\nfunction applyAutoCompactThreshold(\n context: ICommandHostContext,\n threshold: TAutoCompactThreshold,\n action: 'enabled' | 'disabled' | 'threshold set',\n): ICommandResult {\n const persisted = writeAutoCompactThresholdSetting(context, threshold);\n const source: TAutoCompactThresholdSource = persisted ? 'settings' : 'session';\n setCommandAutoCompactThreshold(context, threshold, source);\n\n return {\n success: true,\n message: formatApplyMessage(action, threshold, persisted),\n data: {\n autoCompactThreshold: threshold,\n autoCompactThresholdSource: source,\n persisted,\n },\n };\n}\n\nfunction formatApplyMessage(\n action: 'enabled' | 'disabled' | 'threshold set',\n threshold: TAutoCompactThreshold,\n persisted: boolean,\n): string {\n const suffix = formatPersistenceSuffix(persisted);\n if (action === 'disabled') {\n return `Auto compact disabled (${suffix}).`;\n }\n if (action === 'enabled') {\n return `Auto compact enabled at ${formatThreshold(threshold)} (${suffix}).`;\n }\n return `Auto compact threshold set to ${formatThreshold(threshold)} (${suffix}).`;\n}\n\ntype TParseThresholdResult =\n | { success: true; threshold: number }\n | { success: false; message: string };\n\nfunction parseThreshold(raw: string): TParseThresholdResult {\n if (raw.endsWith('%')) {\n const percent = Number(raw.slice(0, -1));\n if (!Number.isFinite(percent) || percent <= 0 || percent > PERCENT) {\n return {\n success: false,\n message: 'Auto compact percentage must be greater than 0% and at most 100%.',\n };\n }\n return { success: true, threshold: percent / PERCENT };\n }\n\n if (raw.includes('.')) {\n const fraction = Number(raw);\n if (!Number.isFinite(fraction) || fraction <= 0 || fraction > 1) {\n return {\n success: false,\n message: 'Auto compact fraction must be greater than 0 and at most 1.',\n };\n }\n return { success: true, threshold: fraction };\n }\n\n return {\n success: false,\n message: 'Use a percentage such as 85% or a fraction such as 0.85.',\n };\n}\n\nfunction formatContextReferenceSummary(references: readonly IContextReferenceItem[]): string {\n const active = references.filter((reference) => reference.status === 'active').length;\n const observed = references.filter((reference) => reference.status === 'observed').length;\n return `References: ${active} active, ${observed} observed`;\n}\n\nfunction formatContextReferenceList(references: readonly IContextReferenceItem[]): ICommandResult {\n if (references.length === 0) {\n return { success: true, message: 'No context references.', data: { references } };\n }\n\n return {\n success: true,\n message: ['Context references:', ...references.map(formatContextReferenceLine)].join('\\n'),\n data: { references },\n };\n}\n\nfunction formatContextReferenceLine(reference: IContextReferenceItem): string {\n return [\n reference.relativePath,\n `[${reference.loadType}, ${reference.status}]`,\n `${reference.byteLength.toLocaleString()} B`,\n ].join(' ');\n}\n","import { executeContextCommand } from './context-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createContextCommandEntry(): ICommand {\n return {\n name: 'context',\n displayName: 'Context References',\n description: 'Context window info, reference inventory, and auto-compact controls',\n source: 'context',\n modelInvocable: false,\n argumentHint: 'list | add <path> | remove <path> | clear | auto ...',\n subcommands: [\n { name: 'list', description: 'List loaded context references', source: 'context' },\n { name: 'add', description: 'Add a file to active context references', source: 'context' },\n { name: 'remove', description: 'Remove a context reference', source: 'context' },\n { name: 'clear', description: 'Clear context references', source: 'context' },\n { name: 'auto', description: 'Inspect or change auto-compact policy', source: 'context' },\n ],\n };\n}\n\nfunction createContextSystemCommand(): ISystemCommand {\n const entry = createContextCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n execute: executeContextCommand,\n };\n}\n\nexport class ContextCommandSource implements ICommandSource {\n readonly name = 'context';\n\n getCommands(): ICommand[] {\n return [createContextCommandEntry()];\n }\n}\n\nexport function createContextCommandModule(): ICommandModule {\n return {\n name: 'agent-command-context',\n commandSources: [new ContextCommandSource()],\n systemCommands: [createContextSystemCommand()],\n };\n}\n","import { createSessionExitRequestedEffect } from '@robota-sdk/agent-framework';\n\nimport type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\n\nexport function executeExitCommand(_context: ICommandHostContext, _args: string): ICommandResult {\n return {\n success: true,\n message: 'Exit requested.',\n effects: [createSessionExitRequestedEffect()],\n };\n}\n","import { EXIT_COMMAND_DESCRIPTION } from '@robota-sdk/agent-framework';\n\nimport { executeExitCommand } from './exit-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createExitCommandEntry(): ICommand {\n return {\n name: 'exit',\n displayName: 'Exit Session',\n description: EXIT_COMMAND_DESCRIPTION,\n source: 'exit',\n modelInvocable: false,\n };\n}\n\nfunction createExitSystemCommand(): ISystemCommand {\n const entry = createExitCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: true,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeExitCommand,\n };\n}\n\nexport class ExitCommandSource implements ICommandSource {\n readonly name = 'exit';\n\n getCommands(): ICommand[] {\n return [createExitCommandEntry()];\n }\n}\n\nexport function createExitCommandModule(): ICommandModule {\n return {\n name: 'agent-command-exit',\n commandSources: [new ExitCommandSource()],\n systemCommands: [createExitSystemCommand()],\n };\n}\n","import { formatCommandHelpMessage } from '@robota-sdk/agent-framework';\n\nimport type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\n\nexport function executeHelpCommand(context: ICommandHostContext, _args: string): ICommandResult {\n return {\n success: true,\n message: formatCommandHelpMessage(context),\n };\n}\n","import { HELP_COMMAND_DESCRIPTION } from '@robota-sdk/agent-framework';\n\nimport { executeHelpCommand } from './help-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createHelpCommandEntry(): ICommand {\n return {\n name: 'help',\n displayName: 'Help',\n description: HELP_COMMAND_DESCRIPTION,\n source: 'help',\n modelInvocable: false,\n };\n}\n\nfunction createHelpSystemCommand(): ISystemCommand {\n const entry = createHelpCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeHelpCommand,\n };\n}\n\nexport class HelpCommandSource implements ICommandSource {\n readonly name = 'help';\n\n getCommands(): ICommand[] {\n return [createHelpCommandEntry()];\n }\n}\n\nexport function createHelpCommandModule(): ICommandModule {\n return {\n name: 'agent-command-help',\n commandSources: [new HelpCommandSource()],\n systemCommands: [createHelpSystemCommand()],\n };\n}\n","import { formatLanguageUsageMessage, parseLanguageArgument } from '@robota-sdk/agent-framework';\n\nimport type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\n\nexport function executeLanguageCommand(\n _context: ICommandHostContext,\n args: string,\n): ICommandResult {\n const language = parseLanguageArgument(args);\n if (language === undefined) {\n return {\n message: formatLanguageUsageMessage(),\n success: false,\n };\n }\n\n return {\n message: `Language set to \"${language}\".`,\n success: true,\n data: { language },\n effects: [{ type: 'language-change-requested', language }],\n };\n}\n","import {\n buildLanguageCommandSubcommands,\n LANGUAGE_COMMAND_ARGUMENT_HINT,\n LANGUAGE_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\n\nimport { executeLanguageCommand } from './language-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createLanguageCommandEntry(): ICommand {\n return {\n name: 'language',\n displayName: 'Language',\n description: LANGUAGE_COMMAND_DESCRIPTION,\n source: 'language',\n argumentHint: LANGUAGE_COMMAND_ARGUMENT_HINT,\n subcommands: buildLanguageCommandSubcommands('language'),\n modelInvocable: false,\n };\n}\n\nfunction createLanguageSystemCommand(): ISystemCommand {\n const entry = createLanguageCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n lifecycle: 'inline',\n execute: executeLanguageCommand,\n };\n}\n\nexport class LanguageCommandSource implements ICommandSource {\n readonly name = 'language';\n\n getCommands(): ICommand[] {\n return [createLanguageCommandEntry()];\n }\n}\n\nexport function createLanguageCommandModule(): ICommandModule {\n return {\n name: 'agent-command-language',\n commandSources: [new LanguageCommandSource()],\n systemCommands: [createLanguageSystemCommand()],\n };\n}\n","import {\n MEMORY_COMMAND_USAGE,\n createCommandMemoryStores,\n hasSensitiveCommandMemoryContent,\n isCommandMemoryType,\n listCommandUsedMemoryReferences,\n recordCommandMemoryEvent,\n} from '@robota-sdk/agent-framework';\n\nimport type {\n IAppendMemoryInput,\n ICommandHostContext,\n ICommandPendingMemoryStore,\n ICommandProjectMemoryStore,\n ICommandResult,\n IMemoryEvent,\n} from '@robota-sdk/agent-framework';\n\nconst SUBCOMMAND_INDEX = 0;\nconst TYPE_INDEX = 1;\nconst TOPIC_INDEX = 2;\nconst TEXT_START_INDEX = 3;\n\nfunction usage(): ICommandResult {\n return {\n message: MEMORY_COMMAND_USAGE,\n success: false,\n };\n}\n\nfunction formatError(error: Error | string): ICommandResult {\n return {\n message: error instanceof Error ? error.message : String(error),\n success: false,\n };\n}\n\nfunction formatList(store: ICommandProjectMemoryStore): ICommandResult {\n const summary = store.list();\n const topics =\n summary.topics.length > 0\n ? summary.topics.map((topic) => `- ${topic.name}: ${topic.path}`).join('\\n')\n : '(none)';\n\n return {\n message: [\n `Memory index: ${summary.indexPath}`,\n `Topics directory: ${summary.topicsPath}`,\n 'Topics:',\n topics,\n ].join('\\n'),\n success: true,\n data: {\n indexPath: summary.indexPath,\n topicsPath: summary.topicsPath,\n topicCount: summary.topics.length,\n },\n };\n}\n\nfunction formatShow(store: ICommandProjectMemoryStore, topic?: string): ICommandResult {\n if (!topic || topic === 'index') {\n const memory = store.loadStartupMemory();\n return {\n message: memory.content || '(empty memory index)',\n success: true,\n data: {\n path: memory.path,\n lineCount: memory.lineCount,\n truncated: memory.truncated,\n },\n };\n }\n\n const content = store.readTopic(topic);\n return {\n message: content || `(empty memory topic: ${topic})`,\n success: true,\n data: { topic },\n };\n}\n\nfunction parseAdd(args: readonly string[]): IAppendMemoryInput | undefined {\n const type = args[TYPE_INDEX];\n const topic = args[TOPIC_INDEX];\n const text = args.slice(TEXT_START_INDEX).join(' ').trim();\n\n if (!type || !isCommandMemoryType(type) || !topic || text.length === 0) return undefined;\n return { type, topic, text };\n}\n\nfunction formatPending(store: ICommandPendingMemoryStore): ICommandResult {\n const records = store.list('pending');\n const lines =\n records.length > 0\n ? records.map(\n (record) =>\n `- ${record.id} ${record.type}/${record.topic} confidence=${record.confidence}: ${record.text}`,\n )\n : ['(no pending memory candidates)'];\n\n return {\n message: ['Pending memory candidates:', ...lines].join('\\n'),\n success: true,\n data: { count: records.length },\n };\n}\n\nfunction recordEvent(context: ICommandHostContext, event: Omit<IMemoryEvent, 'at'>): void {\n recordCommandMemoryEvent(context, event);\n}\n\nfunction approvePending(\n context: ICommandHostContext,\n pendingStore: ICommandPendingMemoryStore,\n memoryStore: ICommandProjectMemoryStore,\n id: string | undefined,\n): ICommandResult {\n if (!id) return usage();\n try {\n const approved = pendingStore.mark(id, 'approved', 'approved-by-user');\n const saved = memoryStore.append(approved);\n const record = pendingStore.mark(id, 'saved', 'approved-and-saved');\n recordEvent(context, {\n type: 'memory_candidate_approved',\n candidateId: record.id,\n topic: record.topic,\n reason: 'approved-by-user',\n });\n recordEvent(context, {\n type: 'memory_candidate_saved',\n candidateId: record.id,\n topic: record.topic,\n reason: saved.deduplicated ? 'deduplicated' : 'approved-and-saved',\n });\n return {\n message: saved.deduplicated\n ? `Saved memory candidate ${id} was already present in ${saved.topicPath}`\n : `Saved memory candidate ${id} to ${saved.topicPath}`,\n success: true,\n data: {\n id,\n status: record.status,\n topic: saved.topic,\n topicPath: saved.topicPath,\n deduplicated: saved.deduplicated,\n },\n };\n } catch (error) {\n return formatError(error instanceof Error ? error : String(error));\n }\n}\n\nfunction rejectPending(\n context: ICommandHostContext,\n pendingStore: ICommandPendingMemoryStore,\n id: string | undefined,\n): ICommandResult {\n if (!id) return usage();\n try {\n const record = pendingStore.mark(id, 'rejected', 'rejected-by-user');\n recordEvent(context, {\n type: 'memory_candidate_rejected',\n candidateId: record.id,\n topic: record.topic,\n reason: 'rejected-by-user',\n });\n return {\n message: `Rejected memory candidate ${id}`,\n success: true,\n data: { id, status: record.status },\n };\n } catch (error) {\n return formatError(error instanceof Error ? error : String(error));\n }\n}\n\nfunction formatUsed(context: ICommandHostContext): ICommandResult {\n const references = listCommandUsedMemoryReferences(context);\n const lines =\n references.length > 0\n ? references.map((reference) => {\n const suffix = reference.truncated ? ' truncated=true' : '';\n return `- ${reference.topic} score=${reference.score}${suffix}: ${reference.path}`;\n })\n : ['(no memory used in current turn)'];\n\n return {\n message: ['Used memory references:', ...lines].join('\\n'),\n success: true,\n data: { count: references.length, references: [...references] },\n };\n}\n\nexport function executeMemoryCommand(\n context: ICommandHostContext,\n rawArgs: string,\n): ICommandResult {\n const args = rawArgs.trim().split(/\\s+/).filter(Boolean);\n const subcommand = args[SUBCOMMAND_INDEX] ?? 'list';\n const stores = createCommandMemoryStores(context);\n\n if (subcommand === 'list') return formatList(stores.project);\n if (subcommand === 'show') return formatShow(stores.project, args[TYPE_INDEX]);\n if (subcommand === 'pending') return formatPending(stores.pending);\n if (subcommand === 'approve')\n return approvePending(context, stores.pending, stores.project, args[TYPE_INDEX]);\n if (subcommand === 'reject') return rejectPending(context, stores.pending, args[TYPE_INDEX]);\n if (subcommand === 'used') return formatUsed(context);\n if (subcommand === 'add') {\n const input = parseAdd(args);\n if (!input) return usage();\n if (hasSensitiveCommandMemoryContent(input.text)) {\n return {\n message: 'Refusing to save sensitive memory content.',\n success: false,\n };\n }\n const result = stores.project.append(input);\n return {\n message: result.deduplicated\n ? `${input.type} memory already exists in ${result.topicPath}`\n : `Saved ${input.type} memory to ${result.topicPath}`,\n success: true,\n data: {\n indexPath: result.indexPath,\n topicPath: result.topicPath,\n topic: result.topic,\n deduplicated: result.deduplicated,\n },\n };\n }\n\n return usage();\n}\n","import {\n MEMORY_COMMAND_ARGUMENT_HINT,\n MEMORY_COMMAND_DESCRIPTION,\n buildMemoryCommandSubcommands,\n} from '@robota-sdk/agent-framework';\n\nimport { executeMemoryCommand } from './memory-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createMemoryCommandEntry(): ICommand {\n return {\n name: 'memory',\n displayName: 'Memory',\n description: MEMORY_COMMAND_DESCRIPTION,\n source: 'memory',\n argumentHint: MEMORY_COMMAND_ARGUMENT_HINT,\n modelInvocable: true,\n safety: 'write',\n subcommands: buildMemoryCommandSubcommands(),\n };\n}\n\nfunction createMemorySystemCommand(): ISystemCommand {\n const entry = createMemoryCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: true,\n argumentHint: entry.argumentHint,\n safety: entry.safety,\n subcommands: entry.subcommands,\n execute: executeMemoryCommand,\n };\n}\n\nexport class MemoryCommandSource implements ICommandSource {\n readonly name = 'memory';\n\n getCommands(): ICommand[] {\n return [createMemoryCommandEntry()];\n }\n}\n\nexport function createMemoryCommandModule(): ICommandModule {\n return {\n name: 'agent-command-memory',\n commandSources: [new MemoryCommandSource()],\n systemCommands: [createMemorySystemCommand()],\n };\n}\n","import {\n formatInvalidPermissionModeMessage,\n isPermissionMode,\n parsePermissionModeArgument,\n readCommandPermissionMode,\n writeCommandPermissionMode,\n} from '@robota-sdk/agent-framework';\n\nimport type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\n\nexport function executeModeCommand(context: ICommandHostContext, args: string): ICommandResult {\n const arg = parsePermissionModeArgument(args);\n if (arg === undefined) {\n const mode = readCommandPermissionMode(context);\n return {\n message: `Current mode: ${mode}`,\n success: true,\n data: { mode },\n };\n }\n\n if (!isPermissionMode(arg)) {\n return {\n message: formatInvalidPermissionModeMessage(),\n success: false,\n };\n }\n\n writeCommandPermissionMode(context, arg);\n return {\n message: `Permission mode set to: ${arg}`,\n success: true,\n data: { mode: arg },\n };\n}\n","import {\n buildPermissionModeSubcommands,\n PERMISSION_MODE_ARGUMENT_HINT,\n PERMISSION_MODE_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\n\nimport { executeModeCommand } from './mode-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createModeCommandEntry(): ICommand {\n return {\n name: 'mode',\n displayName: 'Interaction Mode',\n description: PERMISSION_MODE_COMMAND_DESCRIPTION,\n source: 'mode',\n argumentHint: PERMISSION_MODE_ARGUMENT_HINT,\n subcommands: buildPermissionModeSubcommands('mode'),\n modelInvocable: false,\n };\n}\n\nfunction createModeSystemCommand(): ISystemCommand {\n const entry = createModeCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n lifecycle: 'inline',\n execute: executeModeCommand,\n };\n}\n\nexport class ModeCommandSource implements ICommandSource {\n readonly name = 'mode';\n\n getCommands(): ICommand[] {\n return [createModeCommandEntry()];\n }\n}\n\nexport function createModeCommandModule(): ICommandModule {\n return {\n name: 'agent-command-mode',\n commandSources: [new ModeCommandSource()],\n systemCommands: [createModeSystemCommand()],\n };\n}\n","import { formatModelCommandUsageMessageAsync } from '@robota-sdk/agent-framework';\n\nimport type {\n ICommandHostContext,\n ICommandResult,\n IModelCommandModuleOptions,\n} from '@robota-sdk/agent-framework';\n\nfunction parseModelId(args: string): string | undefined {\n const modelId = args.trim().split(/\\s+/)[0];\n return modelId !== undefined && modelId.length > 0 ? modelId : undefined;\n}\n\nexport async function executeModelCommand(\n _context: ICommandHostContext,\n args: string,\n options?: IModelCommandModuleOptions,\n): Promise<ICommandResult> {\n const modelId = parseModelId(args);\n if (modelId === undefined) {\n return {\n message: await formatModelCommandUsageMessageAsync({\n ...(options?.settings !== undefined\n ? { settings: options.settings.readMergedSettings() }\n : {}),\n ...(options?.providerDefinitions !== undefined\n ? { providerDefinitions: options.providerDefinitions }\n : {}),\n refresh: true,\n }),\n success: false,\n };\n }\n\n return {\n message: `Model change requested: ${modelId}`,\n success: true,\n data: { modelId },\n effects: [{ type: 'model-change-requested', modelId }],\n };\n}\n","import {\n buildModelCommandSubcommands,\n MODEL_COMMAND_ARGUMENT_HINT,\n MODEL_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\n\nimport { executeModelCommand } from './model-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n IModelCommandModuleOptions,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createModelCommandEntry(options?: IModelCommandModuleOptions): ICommand {\n return {\n name: 'model',\n displayName: 'Change Model',\n description: MODEL_COMMAND_DESCRIPTION,\n source: 'model',\n argumentHint: MODEL_COMMAND_ARGUMENT_HINT,\n subcommands: buildModelSubcommands(options),\n };\n}\n\nfunction createModelSystemCommand(options?: IModelCommandModuleOptions): ISystemCommand {\n const entry = createModelCommandEntry(options);\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: true,\n userInvocable: true,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n lifecycle: 'inline',\n execute: (context, args) => executeModelCommand(context, args, options),\n };\n}\n\nexport class ModelCommandSource implements ICommandSource {\n readonly name = 'model';\n\n constructor(private readonly options?: IModelCommandModuleOptions) {}\n\n getCommands(): ICommand[] {\n return [createModelCommandEntry(this.options)];\n }\n}\n\nexport function createModelCommandModule(options?: IModelCommandModuleOptions): ICommandModule {\n return {\n name: 'agent-command-model',\n commandSources: [new ModelCommandSource(options)],\n systemCommands: [createModelSystemCommand(options)],\n };\n}\n\nfunction buildModelSubcommands(options?: IModelCommandModuleOptions): ICommand[] {\n if (options === undefined) {\n return buildModelCommandSubcommands('model');\n }\n return buildModelCommandSubcommands({\n source: 'model',\n providerDefinitions: options.providerDefinitions,\n settings: options.settings.readMergedSettings(),\n });\n}\n","import {\n formatCommandPermissionsMessage,\n formatInvalidPermissionModeMessage,\n isPermissionMode,\n parsePermissionModeArgument,\n readCommandPermissionsState,\n writeCommandPermissionMode,\n} from '@robota-sdk/agent-framework';\n\nimport type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\n\nexport function executePermissionsCommand(\n context: ICommandHostContext,\n args: string,\n): ICommandResult {\n const arg = parsePermissionModeArgument(args);\n if (arg !== undefined) {\n if (!isPermissionMode(arg)) {\n return {\n message: formatInvalidPermissionModeMessage(),\n success: false,\n };\n }\n\n writeCommandPermissionMode(context, arg);\n const state = readCommandPermissionsState(context);\n return {\n message: `Permission mode set to: ${arg}\\n${formatCommandPermissionsMessage(state)}`,\n success: true,\n data: {\n mode: state.mode,\n sessionAllowed: state.sessionAllowed,\n },\n };\n }\n\n const state = readCommandPermissionsState(context);\n return {\n message: formatCommandPermissionsMessage(state),\n success: true,\n data: {\n mode: state.mode,\n sessionAllowed: state.sessionAllowed,\n },\n };\n}\n","import {\n buildPermissionModeSubcommands,\n PERMISSION_MODE_ARGUMENT_HINT,\n PERMISSIONS_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\n\nimport { executePermissionsCommand } from './permissions-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createPermissionsCommandEntry(): ICommand {\n return {\n name: 'permissions',\n displayName: 'Permissions',\n description: PERMISSIONS_COMMAND_DESCRIPTION,\n source: 'permissions',\n argumentHint: PERMISSION_MODE_ARGUMENT_HINT,\n subcommands: buildPermissionModeSubcommands('permissions'),\n modelInvocable: false,\n };\n}\n\nfunction createPermissionsSystemCommand(): ISystemCommand {\n const entry = createPermissionsCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: true,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n lifecycle: 'inline',\n execute: executePermissionsCommand,\n };\n}\n\nexport class PermissionsCommandSource implements ICommandSource {\n readonly name = 'permissions';\n\n getCommands(): ICommand[] {\n return [createPermissionsCommandEntry()];\n }\n}\n\nexport function createPermissionsCommandModule(): ICommandModule {\n return {\n name: 'agent-command-permissions',\n commandSources: [new PermissionsCommandSource()],\n systemCommands: [createPermissionsSystemCommand()],\n };\n}\n","import {\n createPluginRegistryReloadRequestedEffect,\n createPluginTuiRequestedEffect,\n resolvePluginCommandAdapter,\n} from '@robota-sdk/agent-framework';\n\nimport type {\n ICommandHostContext,\n ICommandPluginAdapter,\n ICommandResult,\n} from '@robota-sdk/agent-framework';\n\nfunction getSubcommandParts(args: string): { subcommand: string; subArgs: string } {\n const parts = args\n .trim()\n .split(/\\s+/)\n .filter((part) => part.length > 0);\n return {\n subcommand: parts[0] ?? '',\n subArgs: parts.slice(1).join(' ').trim(),\n };\n}\n\nfunction usage(message: string): ICommandResult {\n return {\n success: false,\n message,\n };\n}\n\nfunction getPluginAdapter(context: ICommandHostContext): ICommandPluginAdapter | undefined {\n return resolvePluginCommandAdapter(context);\n}\n\nasync function executePluginOperation(\n context: ICommandHostContext,\n operation: (adapter: ICommandPluginAdapter) => Promise<string>,\n): Promise<ICommandResult> {\n const adapter = getPluginAdapter(context);\n if (adapter === undefined) {\n return {\n success: false,\n message: 'Plugin management is not available.',\n };\n }\n\n try {\n return {\n success: true,\n message: await operation(adapter),\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n success: false,\n message: `Plugin error: ${message}`,\n };\n }\n}\n\nasync function executeMarketplaceCommand(\n context: ICommandHostContext,\n subArgs: string,\n): Promise<ICommandResult> {\n const { subcommand, subArgs: marketplaceArgs } = getSubcommandParts(subArgs);\n\n if (subcommand === 'add' && marketplaceArgs.length > 0) {\n return executePluginOperation(context, async (adapter) => {\n const registeredName = await adapter.marketplaceAdd(marketplaceArgs);\n return `Added marketplace: \"${registeredName}\" (from ${marketplaceArgs})\\nInstall plugins with: /plugin install <name>@${registeredName}`;\n });\n }\n\n if (subcommand === 'remove' && marketplaceArgs.length > 0) {\n return executePluginOperation(context, async (adapter) => {\n await adapter.marketplaceRemove(marketplaceArgs);\n return `Removed marketplace \"${marketplaceArgs}\" and uninstalled its plugins.`;\n });\n }\n\n if (subcommand === 'update' && marketplaceArgs.length > 0) {\n return executePluginOperation(context, async (adapter) => {\n await adapter.marketplaceUpdate(marketplaceArgs);\n return `Updated marketplace \"${marketplaceArgs}\".`;\n });\n }\n\n if (subcommand === 'list') {\n return executePluginOperation(context, async (adapter) => {\n const sources = await adapter.marketplaceList();\n if (sources.length === 0) {\n return 'No marketplace sources configured.';\n }\n const lines = sources.map((source) => ` ${source.name} (${source.type})`);\n return `Marketplace sources:\\n${lines.join('\\n')}`;\n });\n }\n\n return usage('Usage: /plugin marketplace add <source> | remove <name> | update <name> | list');\n}\n\ntype TPluginIdOperation = (\n adapter: ICommandPluginAdapter,\n pluginId: string,\n) => Promise<string> | string;\n\nfunction executePluginIdOperation(\n context: ICommandHostContext,\n pluginId: string,\n usageMessage: string,\n operation: TPluginIdOperation,\n): Promise<ICommandResult> {\n if (pluginId.length === 0) {\n return Promise.resolve(usage(usageMessage));\n }\n return executePluginOperation(context, (adapter) =>\n Promise.resolve(operation(adapter, pluginId)),\n );\n}\n\nfunction executePluginManager(): ICommandResult {\n return {\n success: true,\n message: 'Opening plugin manager...',\n effects: [createPluginTuiRequestedEffect()],\n };\n}\n\nfunction executeInstallCommand(\n context: ICommandHostContext,\n pluginId: string,\n): Promise<ICommandResult> {\n return executePluginIdOperation(\n context,\n pluginId,\n 'Usage: /plugin install <name>@<marketplace>',\n async (adapter, targetPluginId) => {\n await adapter.install(targetPluginId);\n return `Installed plugin: ${targetPluginId}`;\n },\n );\n}\n\nfunction executeUninstallCommand(\n context: ICommandHostContext,\n pluginId: string,\n): Promise<ICommandResult> {\n return executePluginIdOperation(\n context,\n pluginId,\n 'Usage: /plugin uninstall <name>@<marketplace>',\n async (adapter, targetPluginId) => {\n await adapter.uninstall(targetPluginId);\n return `Uninstalled plugin: ${targetPluginId}`;\n },\n );\n}\n\nfunction executeEnableCommand(\n context: ICommandHostContext,\n pluginId: string,\n): Promise<ICommandResult> {\n return executePluginIdOperation(\n context,\n pluginId,\n 'Usage: /plugin enable <name>@<marketplace>',\n async (adapter, targetPluginId) => {\n await adapter.enable(targetPluginId);\n return `Enabled plugin: ${targetPluginId}`;\n },\n );\n}\n\nfunction executeDisableCommand(\n context: ICommandHostContext,\n pluginId: string,\n): Promise<ICommandResult> {\n return executePluginIdOperation(\n context,\n pluginId,\n 'Usage: /plugin disable <name>@<marketplace>',\n async (adapter, targetPluginId) => {\n await adapter.disable(targetPluginId);\n return `Disabled plugin: ${targetPluginId}`;\n },\n );\n}\n\nexport async function executePluginCommand(\n context: ICommandHostContext,\n args: string,\n): Promise<ICommandResult> {\n const { subcommand, subArgs } = getSubcommandParts(args);\n switch (subcommand) {\n case '':\n case 'manage':\n return executePluginManager();\n case 'install':\n return executeInstallCommand(context, subArgs);\n case 'uninstall':\n return executeUninstallCommand(context, subArgs);\n case 'enable':\n return executeEnableCommand(context, subArgs);\n case 'disable':\n return executeDisableCommand(context, subArgs);\n case 'marketplace':\n return executeMarketplaceCommand(context, subArgs);\n default:\n return usage(`Unknown plugin subcommand: ${subcommand}`);\n }\n}\n\nexport async function executeReloadPluginsCommand(\n context: ICommandHostContext,\n _args: string,\n): Promise<ICommandResult> {\n return executePluginOperation(context, async (adapter) => {\n const result = await adapter.reloadPlugins();\n const suffix =\n result.loadedPluginCount === 1\n ? '1 plugin resource'\n : `${result.loadedPluginCount} plugin resources`;\n return `Reloaded ${suffix}.`;\n }).then((result) => {\n if (!result.success) return result;\n return {\n ...result,\n effects: [createPluginRegistryReloadRequestedEffect()],\n };\n });\n}\n","import {\n buildPluginCommandSubcommands,\n PLUGIN_COMMAND_ARGUMENT_HINT,\n PLUGIN_COMMAND_DESCRIPTION,\n RELOAD_PLUGINS_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\n\nimport { executePluginCommand, executeReloadPluginsCommand } from './plugin-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createPluginCommandEntry(): ICommand {\n return {\n name: 'plugin',\n displayName: 'Plugins',\n description: PLUGIN_COMMAND_DESCRIPTION,\n source: 'plugin-manager',\n modelInvocable: false,\n argumentHint: PLUGIN_COMMAND_ARGUMENT_HINT,\n subcommands: buildPluginCommandSubcommands(),\n };\n}\n\nexport function createReloadPluginsCommandEntry(): ICommand {\n return {\n name: 'reload-plugins',\n displayName: 'Reload Plugins',\n description: RELOAD_PLUGINS_COMMAND_DESCRIPTION,\n source: 'plugin-manager',\n modelInvocable: false,\n };\n}\n\nfunction createPluginSystemCommand(): ISystemCommand {\n const entry = createPluginCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n lifecycle: 'inline',\n subcommands: entry.subcommands,\n execute: executePluginCommand,\n };\n}\n\nfunction createReloadPluginsSystemCommand(): ISystemCommand {\n const entry = createReloadPluginsCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeReloadPluginsCommand,\n };\n}\n\nexport class PluginManagerCommandSource implements ICommandSource {\n readonly name = 'plugin-manager';\n\n getCommands(): ICommand[] {\n return [createPluginCommandEntry(), createReloadPluginsCommandEntry()];\n }\n}\n\nexport function createPluginCommandModule(): ICommandModule {\n return {\n name: 'agent-command-plugin',\n commandSources: [new PluginManagerCommandSource()],\n systemCommands: [createPluginSystemCommand(), createReloadPluginsSystemCommand()],\n };\n}\n","import { findProviderDefinition, formatSupportedProviderTypes } from '@robota-sdk/agent-core';\nimport { suggestProviderProfileName } from '@robota-sdk/agent-framework';\n\nimport type {\n IProviderDefinition,\n IProviderSetupHelpLink,\n IProviderSetupStepDefinition,\n TProviderSetupField,\n} from '@robota-sdk/agent-core';\nimport type { IProviderSetupInput } from '@robota-sdk/agent-framework';\n\nexport type TProviderSetupType = string;\nexport type TPromptInput = (label: string, masked?: boolean) => Promise<string>;\n\nexport interface IProviderSetupPromptStep extends IProviderSetupStepDefinition {\n key: TProviderSetupField;\n}\n\nexport interface IProviderSetupFlowState {\n type: TProviderSetupType;\n steps: readonly IProviderSetupPromptStep[];\n setupHelpLinks: readonly IProviderSetupHelpLink[];\n stepIndex: number;\n values: Partial<Record<TProviderSetupField, string>>;\n existingProfileNames: readonly string[];\n profileName?: string;\n setCurrent?: boolean;\n}\n\nexport interface IProviderSetupFlowOptions {\n existingProfileNames?: readonly string[];\n initialValues?: Partial<Record<TProviderSetupField, string>>;\n profileName?: string;\n setCurrent?: boolean;\n}\n\nexport type TProviderSetupFlowSubmitResult =\n | {\n status: 'next';\n state: IProviderSetupFlowState;\n }\n | {\n status: 'complete';\n input: IProviderSetupInput;\n }\n | {\n status: 'error';\n state: IProviderSetupFlowState;\n message: string;\n };\n\nexport function createProviderSetupFlow(\n type: TProviderSetupType,\n providerDefinitions: readonly IProviderDefinition[],\n options: IProviderSetupFlowOptions = {},\n): IProviderSetupFlowState {\n const definition = getProviderSetupDefinition(type, providerDefinitions);\n return {\n type,\n steps: applyProviderSetupInitialValues(\n getProviderSetupSteps(definition),\n options.initialValues,\n ),\n setupHelpLinks: definition.setupHelpLinks ?? [],\n stepIndex: 0,\n values: {},\n existingProfileNames: options.existingProfileNames ?? [],\n ...(options.profileName !== undefined ? { profileName: options.profileName } : {}),\n ...(options.setCurrent !== undefined ? { setCurrent: options.setCurrent } : {}),\n };\n}\n\nexport function formatProviderSetupSelectionPrompt(\n providerDefinitions: readonly IProviderDefinition[],\n): string {\n if (providerDefinitions.length === 0) {\n return ' No providers are available.';\n }\n const lines = [\n ' Select provider:',\n ...providerDefinitions.map(\n (definition, index) => ` ${index + 1}. ${formatProviderSetupChoiceLabel(definition)}`,\n ),\n ` Provider [1-${providerDefinitions.length}] (default: 1): `,\n ];\n return lines.join('\\n');\n}\n\nexport function resolveProviderSetupSelection(\n rawValue: string,\n providerDefinitions: readonly IProviderDefinition[],\n): TProviderSetupType {\n const value = rawValue.trim();\n const selectedValue = value.length > 0 ? value : '1';\n const index = parseProviderSelectionIndex(selectedValue);\n if (index !== undefined) {\n const definition = providerDefinitions[index];\n if (definition !== undefined) {\n return definition.type;\n }\n throw new Error(\n `Provider selection ${selectedValue} is out of range. Currently supported: ${formatSupportedProviderTypes(providerDefinitions)}`,\n );\n }\n const definition = findProviderDefinition(providerDefinitions, selectedValue);\n if (definition === undefined) {\n throw new Error(\n `Unknown provider: ${selectedValue}. Currently supported: ${formatSupportedProviderTypes(providerDefinitions)}`,\n );\n }\n return definition.type;\n}\n\nexport function getProviderSetupStep(state: IProviderSetupFlowState): IProviderSetupPromptStep {\n const step = state.steps[state.stepIndex];\n if (step === undefined) {\n throw new Error(`Provider setup step ${state.stepIndex} is out of range`);\n }\n return step;\n}\n\nexport function submitProviderSetupValue(\n state: IProviderSetupFlowState,\n rawValue: string,\n): TProviderSetupFlowSubmitResult {\n const step = getProviderSetupStep(state);\n const value = rawValue.trim() || step.defaultValue || '';\n const validationMessage = validateProviderSetupValue(step, value);\n if (validationMessage !== undefined) {\n return { status: 'error', state, message: validationMessage };\n }\n\n const nextState = {\n ...state,\n stepIndex: state.stepIndex + 1,\n values: { ...state.values, [step.key]: value },\n };\n if (nextState.stepIndex < state.steps.length) {\n return { status: 'next', state: nextState };\n }\n return { status: 'complete', input: buildProviderSetupInput(nextState) };\n}\n\nexport async function runProviderSetupPromptFlow(\n type: TProviderSetupType,\n promptInput: TPromptInput,\n providerDefinitions: readonly IProviderDefinition[],\n options: IProviderSetupFlowOptions = {},\n): Promise<IProviderSetupInput> {\n let state = createProviderSetupFlow(type, providerDefinitions, options);\n const stepCount = state.steps.length;\n while (state.stepIndex < stepCount) {\n const step = getProviderSetupStep(state);\n const value = await promptInput(\n formatProviderSetupPromptLabel(step, state.setupHelpLinks),\n step.masked === true,\n );\n const result = submitProviderSetupValue(state, value);\n if (result.status === 'complete') {\n return result.input;\n }\n if (result.status === 'error') {\n throw new Error(result.message);\n }\n state = result.state;\n }\n throw new Error('Provider setup flow ended without completion');\n}\n\nexport function formatProviderSetupPromptLabel(\n step: IProviderSetupPromptStep,\n setupHelpLinks: readonly IProviderSetupHelpLink[] = [],\n): string {\n const suffix = step.defaultValue !== undefined ? ` (default: ${step.defaultValue})` : '';\n const setupHelp = formatProviderSetupHelpLinks(setupHelpLinks);\n const prefix = setupHelp.length > 0 ? `${setupHelp}\\n` : '';\n return `${prefix} ${step.title}${suffix}: `;\n}\n\nexport function formatProviderSetupChoiceLabel(definition: IProviderDefinition): string {\n const label =\n definition.displayName !== undefined\n ? `${definition.displayName} (${definition.type})`\n : definition.type;\n return definition.description !== undefined ? `${label} - ${definition.description}` : label;\n}\n\nexport function formatProviderSetupHelpLinks(\n setupHelpLinks: readonly IProviderSetupHelpLink[] = [],\n): string {\n if (setupHelpLinks.length === 0) {\n return '';\n }\n return setupHelpLinks\n .map(\n (link) =>\n ` Setup help: ${formatProviderSetupHelpLinkKind(link.kind)}: ${link.label} - ${link.url}`,\n )\n .join('\\n');\n}\n\nfunction parseProviderSelectionIndex(value: string): number | undefined {\n if (!/^\\d+$/.test(value)) {\n return undefined;\n }\n return Number(value) - 1;\n}\n\nexport function validateProviderSetupValue(\n step: IProviderSetupPromptStep,\n value: string,\n): string | undefined {\n if (step.required === true && value.length === 0) {\n return 'Required';\n }\n return undefined;\n}\n\nfunction getProviderSetupDefinition(\n type: TProviderSetupType,\n providerDefinitions: readonly IProviderDefinition[],\n): IProviderDefinition {\n const definition = findProviderDefinition(providerDefinitions, type);\n if (definition === undefined) {\n throw new Error(\n `Unknown provider: ${type}. Currently supported: ${formatSupportedProviderTypes(providerDefinitions)}`,\n );\n }\n return definition;\n}\n\nfunction getProviderSetupSteps(definition: IProviderDefinition): IProviderSetupPromptStep[] {\n if (definition.setupSteps !== undefined) {\n return [...definition.setupSteps];\n }\n\n const steps: IProviderSetupPromptStep[] = [\n {\n key: 'model',\n title: `${definition.type} model`,\n defaultValue: definition.defaults?.model,\n required: definition.defaults?.model === undefined,\n },\n ];\n if (definition.defaults?.baseURL !== undefined) {\n steps.unshift({\n key: 'baseURL',\n title: `${definition.type} base URL`,\n defaultValue: definition.defaults.baseURL,\n });\n }\n if (definition.requiresApiKey === true) {\n steps.push({\n key: 'apiKey',\n title: `${definition.type} API key`,\n defaultValue: definition.defaults?.apiKey,\n required: definition.defaults?.apiKey === undefined,\n masked: true,\n });\n }\n return steps;\n}\n\nfunction formatProviderSetupHelpLinkKind(kind: IProviderSetupHelpLink['kind']): string {\n if (kind === 'api-key') {\n return 'API key';\n }\n if (kind === 'console') {\n return 'Console';\n }\n return 'Official';\n}\n\nfunction applyProviderSetupInitialValues(\n steps: readonly IProviderSetupPromptStep[],\n initialValues: Partial<Record<TProviderSetupField, string>> | undefined,\n): IProviderSetupPromptStep[] {\n if (initialValues === undefined) {\n return [...steps];\n }\n return steps.map((step) => {\n const initialValue = initialValues[step.key];\n if (initialValue === undefined) {\n return step;\n }\n return {\n ...step,\n defaultValue: initialValue,\n required: false,\n };\n });\n}\n\nfunction buildProviderSetupInput(state: IProviderSetupFlowState): IProviderSetupInput {\n const profile =\n state.profileName ??\n suggestProviderProfileName(\n { type: state.type },\n { existingProfileNames: state.existingProfileNames },\n );\n const apiKey = state.values.apiKey;\n return {\n profile,\n type: state.type,\n model: state.values.model,\n ...(apiKey !== undefined && apiKey.length > 0 && { apiKey }),\n ...(state.values.baseURL !== undefined && { baseURL: state.values.baseURL }),\n setCurrent: state.setCurrent ?? true,\n };\n}\n","import { buildProviderSetupPatch, mergeProviderPatch } from '@robota-sdk/agent-framework';\n\nimport {\n createProviderSetupFlow,\n formatProviderSetupHelpLinks,\n getProviderSetupStep,\n submitProviderSetupValue,\n validateProviderSetupValue,\n} from './provider-setup-flow.js';\n\nimport type { IProviderSetupFlowState } from './provider-setup-flow.js';\nimport type {\n ICommandInteraction,\n ICommandResult,\n IProviderCommandModuleOptions,\n IProviderSetupInput,\n TCommandInteractionPrompt,\n} from '@robota-sdk/agent-framework';\n\nconst PROVIDER_RESTART_EFFECT = {\n type: 'session-restart-requested',\n reason: 'other',\n} as const;\n\nexport function createSetupFlow(\n type: string,\n options: IProviderCommandModuleOptions,\n): IProviderSetupFlowState {\n return createProviderSetupFlow(type, options.providerDefinitions, {\n existingProfileNames: Object.keys(options.settings.readMergedSettings().providers ?? {}),\n });\n}\n\nexport function createProviderSetupInteraction(\n flow: IProviderSetupFlowState,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: toProviderSetupStepPrompt(flow),\n submit: (value) => submitProviderSetupInteractionValue(flow, value, options),\n cancel: () => ({ message: 'Provider setup cancelled.', success: true }),\n };\n}\n\nexport function toProviderSetupStepPrompt(\n flow: IProviderSetupFlowState,\n): TCommandInteractionPrompt {\n const step = getProviderSetupStep(flow);\n const placeholder =\n step.masked === true && step.defaultValue !== undefined ? '(unchanged)' : step.defaultValue;\n return {\n kind: 'text',\n title: step.title,\n ...toProviderSetupPromptDescription(flow),\n ...(placeholder !== undefined ? { placeholder } : {}),\n ...(step.defaultValue !== undefined ? { allowEmpty: true } : {}),\n ...(step.masked !== undefined ? { masked: step.masked } : {}),\n validate: (value) => validateProviderSetupValue(step, value),\n };\n}\n\nexport function toProviderSetupPromptDescription(\n flow: IProviderSetupFlowState,\n): { description: string } | Record<string, never> {\n const description = formatProviderSetupHelpLinks(flow.setupHelpLinks);\n return description.length > 0 ? { description } : {};\n}\n\nfunction submitProviderSetupInteractionValue(\n flow: IProviderSetupFlowState,\n value: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const result = submitProviderSetupValue(flow, value);\n if (result.status === 'error') {\n return {\n message: result.message,\n success: false,\n interaction: createProviderSetupInteraction(flow, options),\n };\n }\n if (result.status === 'complete') {\n return completeProviderSetup(result.input, options);\n }\n return {\n message: '',\n success: true,\n interaction: createProviderSetupInteraction(result.state, options),\n };\n}\n\nexport function completeProviderSetup(\n input: IProviderSetupInput,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const target = options.settings.readTargetSettings();\n const patch = buildProviderSetupPatch(input, {\n providerDefinitions: options.providerDefinitions,\n });\n options.settings.writeTargetSettings(mergeProviderPatch(target, patch));\n return {\n message: `Provider ${input.profile} configured. Restarting...`,\n success: true,\n effects: [{ ...PROVIDER_RESTART_EFFECT, message: 'Provider setup restart' }],\n };\n}\n","import {\n buildProviderSetupPatch,\n setCurrentProvider,\n upsertProviderProfile,\n} from '@robota-sdk/agent-framework';\n\nimport {\n createProviderSetupInteraction,\n toProviderSetupStepPrompt,\n} from './provider-command-setup.js';\nimport { createProviderSetupFlow, submitProviderSetupValue } from './provider-setup-flow.js';\n\nimport type { IProviderSetupFlowState } from './provider-setup-flow.js';\nimport type {\n ICommandInteraction,\n ICommandResult,\n IProviderCommandModuleOptions,\n IProviderProfileSettings,\n IProviderSetupInput,\n} from '@robota-sdk/agent-framework';\n\nconst YES = 'yes';\nconst PROVIDER_RESTART_EFFECT = {\n type: 'session-restart-requested',\n reason: 'other',\n} as const;\n\nexport function formatProviderChoiceLabel(\n name: string,\n profile: IProviderProfileSettings,\n currentProvider: string | undefined,\n): string {\n const marker = name === currentProvider ? '* ' : '';\n return `${marker}${name}: ${profile.type ?? 'unknown'} ${profile.model ?? '(no model)'}`;\n}\n\nexport function buildProviderSwitch(\n providers: Record<string, IProviderProfileSettings> | undefined,\n profileName: string | undefined,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n if (!profileName) {\n return { message: 'Usage: provider use <profile>', success: false };\n }\n if (!providers?.[profileName]) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n if (options.settings.readMergedSettings().currentProvider === profileName) {\n return { message: `Provider profile \"${profileName}\" is already current.`, success: true };\n }\n return {\n message: `Provider change requested: ${profileName}`,\n success: true,\n interaction: createProviderSwitchInteraction(profileName, options),\n };\n}\n\nfunction createProviderSwitchInteraction(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'choice',\n title: `Change provider to ${profileName}? This will restart the session.`,\n options: [\n { value: YES, label: 'Yes' },\n { value: 'no', label: 'No' },\n ],\n },\n submit: (value) => {\n if (value !== YES) {\n return { message: 'Provider change cancelled.', success: true };\n }\n const merged = options.settings.readMergedSettings();\n const target = options.settings.readTargetSettings();\n const next =\n target.providers?.[profileName] !== undefined ||\n merged.providers?.[profileName] !== undefined\n ? { ...target, currentProvider: profileName }\n : setCurrentProvider(target, profileName);\n options.settings.writeTargetSettings(next);\n return {\n message: `Provider changed to ${profileName}. Restarting...`,\n success: true,\n effects: [{ ...PROVIDER_RESTART_EFFECT, message: 'Provider change restart' }],\n };\n },\n cancel: () => ({ message: 'Provider change cancelled.', success: true }),\n };\n}\n\nexport function buildProviderEdit(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n const profile = settings.providers?.[profileName];\n if (!profile) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n if (!profile.type) {\n return { message: `Provider profile \"${profileName}\" is missing type.`, success: false };\n }\n try {\n const flow = createProviderSetupFlow(profile.type, options.providerDefinitions, {\n profileName,\n setCurrent: false,\n initialValues: getProviderProfileSetupValues(profile),\n });\n return {\n message: `Provider edit requested: ${profileName}`,\n success: true,\n interaction: createProviderEditInteraction(flow, profileName, options),\n };\n } catch (error) {\n return { message: error instanceof Error ? error.message : String(error), success: false };\n }\n}\n\nfunction getProviderProfileSetupValues(profile: IProviderProfileSettings): {\n model?: string;\n apiKey?: string;\n baseURL?: string;\n} {\n return {\n ...(typeof profile.model === 'string' ? { model: profile.model } : {}),\n ...(typeof profile.apiKey === 'string' ? { apiKey: profile.apiKey } : {}),\n ...(typeof profile.baseURL === 'string' ? { baseURL: profile.baseURL } : {}),\n };\n}\n\nexport function createProviderEditInteraction(\n flow: IProviderSetupFlowState,\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: toProviderSetupStepPrompt(flow),\n submit: (value) => submitProviderEditInteractionValue(flow, profileName, value, options),\n cancel: () => ({ message: 'Provider edit cancelled.', success: true }),\n };\n}\n\nfunction submitProviderEditInteractionValue(\n flow: IProviderSetupFlowState,\n profileName: string,\n value: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const result = submitProviderSetupValue(flow, value);\n if (result.status === 'error') {\n return {\n message: result.message,\n success: false,\n interaction: createProviderEditInteraction(flow, profileName, options),\n };\n }\n if (result.status === 'complete') {\n return completeProviderEdit(result.input, profileName, options);\n }\n return {\n message: '',\n success: true,\n interaction: createProviderEditInteraction(result.state, profileName, options),\n };\n}\n\nfunction completeProviderEdit(\n input: IProviderSetupInput,\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const merged = options.settings.readMergedSettings();\n const currentProfile = merged.providers?.[profileName];\n if (!currentProfile) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n const target = options.settings.readTargetSettings();\n const patch = buildProviderSetupPatch(input, {\n providerDefinitions: options.providerDefinitions,\n });\n const updatedProfile = patch.providers[profileName];\n if (!updatedProfile) {\n return { message: `Provider profile \"${profileName}\" was not updated.`, success: false };\n }\n options.settings.writeTargetSettings(\n upsertProviderProfile(target, profileName, { ...currentProfile, ...updatedProfile }),\n );\n const isCurrent = merged.currentProvider === profileName;\n return {\n message: isCurrent\n ? `Provider ${profileName} updated. Restarting...`\n : `Provider ${profileName} updated.`,\n success: true,\n ...(isCurrent\n ? { effects: [{ ...PROVIDER_RESTART_EFFECT, message: 'Provider edit restart' }] }\n : {}),\n };\n}\n","import {\n deleteProviderProfile,\n sanitizeProviderProfileName,\n upsertProviderProfile,\n} from '@robota-sdk/agent-framework';\n\nimport { formatProviderChoiceLabel } from './provider-command-profile-operations.js';\n\nimport type {\n ICommandInteraction,\n ICommandResult,\n IProviderCommandModuleOptions,\n} from '@robota-sdk/agent-framework';\n\nconst YES = 'yes';\nconst MAX_DUPLICATE_PROFILE_SUFFIX = 1000;\nconst PROVIDER_RESTART_EFFECT = {\n type: 'session-restart-requested',\n reason: 'other',\n} as const;\n\nexport function buildProviderDuplicate(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n if (!settings.providers?.[profileName]) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n const defaultName = suggestDuplicateProfileName(profileName, Object.keys(settings.providers));\n return {\n message: `Provider duplicate requested: ${profileName}`,\n success: true,\n interaction: createProviderDuplicateInteraction(profileName, defaultName, options),\n };\n}\n\nfunction createProviderDuplicateInteraction(\n profileName: string,\n defaultName: string,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'text',\n title: `Duplicate ${profileName} as`,\n placeholder: defaultName,\n allowEmpty: true,\n validate: (value) => validateDuplicateProfileName(value, defaultName, options),\n },\n submit: (value) => completeProviderDuplicate(profileName, value, defaultName, options),\n cancel: () => ({ message: 'Provider duplicate cancelled.', success: true }),\n };\n}\n\nfunction validateDuplicateProfileName(\n value: string,\n defaultName: string,\n options: IProviderCommandModuleOptions,\n): string | undefined {\n const name = normalizeProfileName(value, defaultName);\n if (name.length === 0) {\n return 'Required';\n }\n if (options.settings.readMergedSettings().providers?.[name] !== undefined) {\n return `Provider profile \"${name}\" already exists`;\n }\n return undefined;\n}\n\nfunction completeProviderDuplicate(\n profileName: string,\n value: string,\n defaultName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n const sourceProfile = settings.providers?.[profileName];\n if (!sourceProfile) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n const targetName = normalizeProfileName(value, defaultName);\n const validationMessage = validateDuplicateProfileName(targetName, defaultName, options);\n if (validationMessage !== undefined) {\n return { message: validationMessage, success: false };\n }\n options.settings.writeTargetSettings(\n upsertProviderProfile(options.settings.readTargetSettings(), targetName, { ...sourceProfile }),\n );\n return {\n message: `Provider profile duplicated: ${profileName} -> ${targetName}.`,\n success: true,\n };\n}\n\nexport function buildProviderDelete(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n const providers = settings.providers ?? {};\n if (!providers[profileName]) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n if (Object.keys(providers).length <= 1) {\n return { message: 'Cannot delete the only provider profile.', success: false };\n }\n if (options.settings.readTargetSettings().providers?.[profileName] === undefined) {\n return {\n message: `Provider profile \"${profileName}\" is not stored in the active write target; edit its source settings file or override it before deleting.`,\n success: false,\n };\n }\n return {\n message: `Provider delete requested: ${profileName}`,\n success: true,\n interaction: createProviderDeleteConfirmationInteraction(profileName, options),\n };\n}\n\nfunction createProviderDeleteConfirmationInteraction(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'choice',\n title: `Delete provider profile ${profileName}?`,\n options: [\n { value: YES, label: 'Yes' },\n { value: 'no', label: 'No' },\n ],\n },\n submit: (value) => {\n if (value !== YES) {\n return { message: 'Provider delete cancelled.', success: true };\n }\n return confirmProviderDelete(profileName, options);\n },\n cancel: () => ({ message: 'Provider delete cancelled.', success: true }),\n };\n}\n\nfunction confirmProviderDelete(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n if (settings.currentProvider !== profileName) {\n options.settings.writeTargetSettings(\n deleteProviderProfile(options.settings.readTargetSettings(), profileName),\n );\n return { message: `Provider profile deleted: ${profileName}.`, success: true };\n }\n const replacementOptions = Object.entries(settings.providers ?? {})\n .filter(([name]) => name !== profileName)\n .map(([name, profile]) => ({\n value: name,\n label: formatProviderChoiceLabel(name, profile, settings.currentProvider),\n }));\n return {\n message: `Select a replacement provider before deleting ${profileName}.`,\n success: true,\n interaction: {\n prompt: {\n kind: 'choice',\n title: `Replacement provider for ${profileName}`,\n options: replacementOptions,\n maxVisible: 8,\n },\n submit: (replacementName) =>\n completeActiveProviderDelete(profileName, replacementName, options),\n cancel: () => ({ message: 'Provider delete cancelled.', success: true }),\n },\n };\n}\n\nfunction completeActiveProviderDelete(\n profileName: string,\n replacementName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n if (settings.providers?.[replacementName] === undefined || replacementName === profileName) {\n return { message: `Provider profile \"${replacementName}\" was not found.`, success: false };\n }\n const target = deleteProviderProfile(options.settings.readTargetSettings(), profileName);\n options.settings.writeTargetSettings({ ...target, currentProvider: replacementName });\n return {\n message: `Provider profile deleted: ${profileName}. Restarting with ${replacementName}...`,\n success: true,\n effects: [{ ...PROVIDER_RESTART_EFFECT, message: 'Provider delete restart' }],\n };\n}\n\nfunction suggestDuplicateProfileName(\n profileName: string,\n existingProfileNames: readonly string[],\n): string {\n const base = sanitizeProviderProfileName(`${profileName}-copy`) ?? 'provider-copy';\n if (!existingProfileNames.includes(base)) {\n return base;\n }\n for (let index = 2; index < MAX_DUPLICATE_PROFILE_SUFFIX; index += 1) {\n const candidate = `${base}-${index}`;\n if (!existingProfileNames.includes(candidate)) {\n return candidate;\n }\n }\n return `${base}-${Date.now()}`;\n}\n\nfunction normalizeProfileName(value: string, defaultName: string): string {\n const raw = value.trim() || defaultName;\n return sanitizeProviderProfileName(raw) ?? '';\n}\n","import { testProviderProfileCommand } from '@robota-sdk/agent-framework';\n\nimport {\n buildProviderDelete,\n buildProviderDuplicate,\n} from './provider-command-profile-lifecycle.js';\nimport {\n buildProviderEdit,\n buildProviderSwitch,\n formatProviderChoiceLabel,\n} from './provider-command-profile-operations.js';\n\nimport type {\n ICommandInteraction,\n ICommandResult,\n IProviderCommandModuleOptions,\n IProviderProfileSettings,\n} from '@robota-sdk/agent-framework';\n\nconst ACTION_SWITCH = 'switch';\nconst ACTION_EDIT = 'edit';\nconst ACTION_TEST = 'test';\nconst ACTION_DUPLICATE = 'duplicate';\nconst ACTION_DELETE = 'delete';\nconst ACTION_CANCEL = 'cancel';\n\nexport function createProviderProfileSelectionInteraction(\n currentProvider: string | undefined,\n providers: Record<string, IProviderProfileSettings> | undefined,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'choice',\n title: 'Select provider profile',\n options: Object.entries(providers ?? {}).map(([name, profile]) => ({\n value: name,\n label: formatProviderChoiceLabel(name, profile, currentProvider),\n })),\n maxVisible: 8,\n },\n submit: (value) => buildProviderProfileActionMenu(value, options),\n cancel: () => ({ message: 'Provider profile selection cancelled.', success: true }),\n };\n}\n\nfunction buildProviderProfileActionMenu(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const settings = options.settings.readMergedSettings();\n if (!settings.providers?.[profileName]) {\n return { message: `Provider profile \"${profileName}\" was not found.`, success: false };\n }\n return {\n message: `Provider profile selected: ${profileName}`,\n success: true,\n interaction: createProviderProfileActionInteraction(profileName, options),\n };\n}\n\nfunction createProviderProfileActionInteraction(\n profileName: string,\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'choice',\n title: `Provider profile: ${profileName}`,\n options: [\n { value: ACTION_SWITCH, label: 'Switch' },\n { value: ACTION_EDIT, label: 'Edit' },\n { value: ACTION_TEST, label: 'Test' },\n { value: ACTION_DUPLICATE, label: 'Duplicate' },\n { value: ACTION_DELETE, label: 'Delete' },\n { value: ACTION_CANCEL, label: 'Cancel' },\n ],\n },\n submit: (value) => executeProviderProfileAction(profileName, value, options),\n cancel: () => ({ message: 'Provider profile action cancelled.', success: true }),\n };\n}\n\nasync function executeProviderProfileAction(\n profileName: string,\n action: string,\n options: IProviderCommandModuleOptions,\n): Promise<ICommandResult> {\n const settings = options.settings.readMergedSettings();\n switch (action) {\n case ACTION_SWITCH:\n return buildProviderSwitch(settings.providers, profileName, options);\n case ACTION_EDIT:\n return buildProviderEdit(profileName, options);\n case ACTION_TEST:\n return await testProviderProfileCommand(\n settings.currentProvider,\n settings.providers,\n profileName,\n options,\n );\n case ACTION_DUPLICATE:\n return buildProviderDuplicate(profileName, options);\n case ACTION_DELETE:\n return buildProviderDelete(profileName, options);\n case ACTION_CANCEL:\n return { message: 'Provider profile action cancelled.', success: true };\n default:\n return { message: `Unknown provider profile action \"${action}\".`, success: false };\n }\n}\n","import { findProviderDefinition, formatSupportedProviderTypes } from '@robota-sdk/agent-core';\nimport { testProviderProfileCommand } from '@robota-sdk/agent-framework';\n\nimport { buildProviderSwitch } from './provider-command-profile-operations.js';\nimport { createProviderProfileSelectionInteraction } from './provider-command-profile.js';\nimport { createSetupFlow, createProviderSetupInteraction } from './provider-command-setup.js';\nimport { formatProviderSetupChoiceLabel } from './provider-setup-flow.js';\n\nimport type {\n ICommandInteraction,\n ICommandResult,\n IProviderCommandModuleOptions,\n IProviderProfileSettings,\n} from '@robota-sdk/agent-framework';\n\nexport async function executeProviderCommand(\n args: string,\n options: IProviderCommandModuleOptions,\n): Promise<ICommandResult> {\n const settings = options.settings.readMergedSettings();\n const trimmedArgs = args.trim();\n if (trimmedArgs.length === 0) {\n return buildProviderProfilePicker(settings.currentProvider, settings.providers, options);\n }\n const [subcommand = 'current', profileArg] = trimmedArgs.split(/\\s+/);\n\n if (subcommand === 'list') {\n return buildProviderProfilePicker(settings.currentProvider, settings.providers, options);\n }\n if (subcommand === 'current' || subcommand === '') {\n return {\n message: formatCurrentProvider(settings.currentProvider, settings.providers),\n success: true,\n };\n }\n if (subcommand === 'use') {\n return buildProviderSwitch(settings.providers, profileArg, options);\n }\n if (subcommand === 'test') {\n return await testProviderProfileCommand(\n settings.currentProvider,\n settings.providers,\n profileArg,\n options,\n );\n }\n if (subcommand === 'add') {\n return buildProviderSetup(profileArg, options);\n }\n\n return {\n message: 'Usage: provider [current|list|use <profile>|add <type>|test [profile]]',\n success: false,\n };\n}\n\nfunction buildProviderProfilePicker(\n currentProvider: string | undefined,\n providers: Record<string, IProviderProfileSettings> | undefined,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n const message = formatProviderList(currentProvider, providers);\n if (Object.keys(providers ?? {}).length === 0) {\n return { message, success: true };\n }\n return {\n message,\n success: true,\n interaction: createProviderProfileSelectionInteraction(currentProvider, providers, options),\n };\n}\n\nfunction formatProviderList(\n currentProvider: string | undefined,\n providers: Record<string, IProviderProfileSettings> | undefined,\n): string {\n const entries = Object.entries(providers ?? {});\n if (entries.length === 0) {\n return 'No provider profiles configured.';\n }\n return entries\n .map(([name, profile]) => {\n const marker = name === currentProvider ? '*' : '-';\n return `${marker} ${name}: ${profile.type ?? 'unknown'} ${profile.model ?? '(no model)'}`;\n })\n .join('\\n');\n}\n\nfunction formatCurrentProvider(\n currentProvider: string | undefined,\n providers: Record<string, IProviderProfileSettings> | undefined,\n): string {\n if (!currentProvider) {\n return 'No current provider configured.';\n }\n const profile = providers?.[currentProvider];\n if (!profile) {\n return `Current provider \"${currentProvider}\" was not found in providers.`;\n }\n return [\n `Current provider: ${currentProvider}`,\n `Type: ${profile.type ?? 'unknown'}`,\n `Model: ${profile.model ?? '(no model)'}`,\n ...(profile.baseURL ? [`Base URL: ${profile.baseURL}`] : []),\n ].join('\\n');\n}\n\nfunction buildProviderSetup(\n type: string | undefined,\n options: IProviderCommandModuleOptions,\n): ICommandResult {\n if (type === undefined || type.length === 0) {\n return {\n message: 'Provider setup requested. Select a provider to continue.',\n success: true,\n interaction: createProviderSelectionInteraction(options),\n };\n }\n if (findProviderDefinition(options.providerDefinitions, type) === undefined) {\n return {\n message: `Usage: provider add <type>. Supported: ${formatSupportedProviderTypes(options.providerDefinitions)}`,\n success: false,\n };\n }\n return {\n message: `Provider setup requested: ${type}`,\n success: true,\n interaction: createProviderSetupInteraction(createSetupFlow(type, options), options),\n };\n}\n\nfunction createProviderSelectionInteraction(\n options: IProviderCommandModuleOptions,\n): ICommandInteraction {\n return {\n prompt: {\n kind: 'choice' as const,\n title: 'Select provider',\n options: options.providerDefinitions.map((definition) => ({\n value: definition.type,\n label: formatProviderSetupChoiceLabel(definition),\n })),\n maxVisible: 6,\n },\n submit: (value: string) => {\n const flow = createSetupFlow(value, options);\n return {\n message: `Provider setup requested: ${value}`,\n success: true,\n interaction: createProviderSetupInteraction(flow, options),\n };\n },\n cancel: () => ({ message: 'Provider setup cancelled.', success: true }),\n };\n}\n","import { executeProviderCommand } from './provider-command-execution.js';\n\nimport type {\n ICommand,\n ICommandModule as TCommandModule,\n ICommandSource,\n IProviderCommandModuleOptions,\n IProviderCommandSettingsAdapter,\n ISystemCommand as TSystemCommand,\n} from '@robota-sdk/agent-framework';\nexport type { IProviderCommandModuleOptions, IProviderCommandSettingsAdapter };\n\nfunction buildProviderSubcommands(): ICommand[] {\n return [\n { name: 'current', description: 'Show current provider', source: 'provider' },\n { name: 'list', description: 'List provider profiles', source: 'provider' },\n { name: 'use', description: 'Switch provider profile', source: 'provider' },\n { name: 'add', description: 'Configure a provider profile', source: 'provider' },\n { name: 'test', description: 'Test provider profile', source: 'provider' },\n ];\n}\n\nexport function createProviderCommandEntry(): ICommand {\n return {\n name: 'provider',\n displayName: 'Provider Setup',\n description: 'Manage provider profiles',\n source: 'provider',\n modelInvocable: false,\n argumentHint: 'current | list | use <profile> | add [type] | test [profile]',\n subcommands: buildProviderSubcommands(),\n };\n}\n\nexport class ProviderCommandSource implements ICommandSource {\n readonly name = 'provider';\n\n getCommands(): ICommand[] {\n return [createProviderCommandEntry()];\n }\n}\n\nfunction createProviderSystemCommand(options: IProviderCommandModuleOptions): TSystemCommand {\n const entry = createProviderCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n execute: async (_session, args) => executeProviderCommand(args, options),\n };\n}\n\nexport function createProviderCommandModule(\n options: IProviderCommandModuleOptions,\n): TCommandModule {\n return {\n name: 'agent-command-provider',\n commandSources: [new ProviderCommandSource()],\n systemCommands: [createProviderSystemCommand(options)],\n };\n}\n","import { join } from 'node:path';\n\nimport {\n checkSettingsDocument,\n readMergedProviderSettings,\n readSettings,\n writeSettings,\n resolveSettingsPathForScope,\n getProviderSettingsPaths,\n applyProviderConfiguration,\n} from '@robota-sdk/agent-framework';\n\nimport {\n formatProviderSetupSelectionPrompt,\n resolveProviderSetupSelection,\n runProviderSetupPromptFlow,\n type TPromptInput,\n} from './provider-setup-flow.js';\n\nimport type { IProviderDefinition } from '@robota-sdk/agent-core';\nimport type { ITerminalOutput } from '@robota-sdk/agent-core';\nimport type { TSettingsScope } from '@robota-sdk/agent-framework';\n\nexport interface IProviderStartupContext {\n provider?: string;\n settingsScope?: TSettingsScope;\n}\n\nexport interface IEnsureProviderConfigOptions {\n formatError: (defs: readonly IProviderDefinition[]) => string;\n isInteractive?: () => boolean;\n}\n\nexport async function runProviderStartupSetup(\n cwd: string,\n ctx: IProviderStartupContext,\n promptInput: TPromptInput,\n terminal: ITerminalOutput,\n providerDefinitions: readonly IProviderDefinition[],\n): Promise<void> {\n const providerChoice = await promptInput(formatProviderSetupSelectionPrompt(providerDefinitions));\n const type = resolveProviderSetupSelection(providerChoice, providerDefinitions);\n const settingsPath = resolveSettingsPathForScope(cwd, ctx.settingsScope);\n const input = await runProviderSetupPromptFlow(type, promptInput, providerDefinitions, {\n existingProfileNames: Object.keys(readMergedProviderSettings(cwd).providers ?? {}),\n });\n applyProviderConfiguration(settingsPath, input, { providerDefinitions });\n const language = await promptInput(' Response language (ko/en/ja/zh, default: en): ');\n if (language) {\n const settings = readSettings(settingsPath);\n settings.language = language;\n writeSettings(settingsPath, settings);\n }\n terminal.writeLine(`\\n Config saved to ${settingsPath}\\n`);\n}\n\nexport async function ensureProviderConfig(\n cwd: string,\n ctx: IProviderStartupContext,\n promptInput: TPromptInput,\n terminal: ITerminalOutput,\n providerDefinitions: readonly IProviderDefinition[],\n options: IEnsureProviderConfigOptions,\n): Promise<void> {\n const merged = readMergedProviderSettings(cwd);\n const selectedSettings =\n ctx.provider !== undefined ? { ...merged, currentProvider: ctx.provider } : merged;\n if (checkSettingsDocument(selectedSettings, providerDefinitions) === 'valid') {\n return;\n }\n const checkInteractive = options.isInteractive ?? (() => false);\n if (!checkInteractive()) {\n throw new Error(options.formatError(providerDefinitions));\n }\n await runProviderStartupSetup(\n cwd,\n selectStartupContext(cwd, ctx),\n promptInput,\n terminal,\n providerDefinitions,\n );\n const updated = readMergedProviderSettings(cwd);\n const updatedSettings =\n ctx.provider !== undefined ? { ...updated, currentProvider: ctx.provider } : updated;\n if (checkSettingsDocument(updatedSettings, providerDefinitions) !== 'valid') {\n throw new Error(options.formatError(providerDefinitions));\n }\n}\n\nfunction selectStartupContext(cwd: string, ctx: IProviderStartupContext): IProviderStartupContext {\n if (ctx.settingsScope !== undefined || ctx.provider !== undefined) return ctx;\n const currentProviderPath = findHighestPriorityCurrentProviderPath(getProviderSettingsPaths(cwd));\n if (currentProviderPath === undefined) return ctx;\n const projectSettingsPath = join(cwd, '.robota', 'settings.json');\n const projectLocalSettingsPath = join(cwd, '.robota', 'settings.local.json');\n if (\n currentProviderPath === projectSettingsPath ||\n currentProviderPath === projectLocalSettingsPath\n ) {\n return { ...ctx, settingsScope: 'project-local' };\n }\n return ctx;\n}\n\nfunction findHighestPriorityCurrentProviderPath(\n settingsPaths: readonly string[],\n): string | undefined {\n for (let index = settingsPaths.length - 1; index >= 0; index -= 1) {\n const settingsPath = settingsPaths[index];\n if (settingsPath === undefined) continue;\n const settings = readSettings(settingsPath);\n if (typeof settings.currentProvider === 'string') {\n return settingsPath;\n }\n }\n return undefined;\n}\n","import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\n\nexport function executeResetCommand(_context: ICommandHostContext, _args: string): ICommandResult {\n return {\n success: true,\n message: 'Reset requested.',\n data: { resetRequested: true },\n effects: [{ type: 'settings-reset-requested' }],\n };\n}\n","import { executeResetCommand } from './reset-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nconst RESET_COMMAND_DESCRIPTION = 'Delete settings';\n\nexport function createResetCommandEntry(): ICommand {\n return {\n name: 'reset',\n displayName: 'Reset Settings',\n description: RESET_COMMAND_DESCRIPTION,\n source: 'reset',\n modelInvocable: false,\n };\n}\n\nfunction createResetSystemCommand(): ISystemCommand {\n const entry = createResetCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: true,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeResetCommand,\n };\n}\n\nexport class ResetCommandSource implements ICommandSource {\n readonly name = 'reset';\n\n getCommands(): ICommand[] {\n return [createResetCommandEntry()];\n }\n}\n\nexport function createResetCommandModule(): ICommandModule {\n return {\n name: 'agent-command-reset',\n commandSources: [new ResetCommandSource()],\n systemCommands: [createResetSystemCommand()],\n };\n}\n","import {\n inspectCommandEditCheckpoint,\n listCommandEditCheckpoints,\n restoreCommandEditCheckpoint,\n rollbackCommandEditCheckpoint,\n} from '@robota-sdk/agent-framework';\n\nimport type {\n ICommandHostContext,\n ICommandResult,\n IEditCheckpointInspection,\n IEditCheckpointRestoreResult,\n IEditCheckpointSummary,\n} from '@robota-sdk/agent-framework';\n\nconst SUBCOMMAND_INDEX = 0;\nconst CHECKPOINT_ID_INDEX = 1;\nconst PROMPT_PREVIEW_LENGTH = 120;\nconst ELLIPSIS_LENGTH = 3;\n\nfunction usage(): ICommandResult {\n return {\n message:\n 'Usage: rewind [list] | rewind inspect <checkpoint-id> | rewind restore <checkpoint-id> | rewind code <checkpoint-id> | rewind rollback <checkpoint-id>',\n success: false,\n };\n}\n\nfunction formatPrompt(prompt: string): string {\n const compact = prompt.replace(/\\s+/g, ' ').trim();\n if (compact.length <= PROMPT_PREVIEW_LENGTH) return compact;\n return `${compact.slice(0, PROMPT_PREVIEW_LENGTH - ELLIPSIS_LENGTH)}...`;\n}\n\nfunction formatList(checkpoints: readonly IEditCheckpointSummary[]): ICommandResult {\n const lines =\n checkpoints.length > 0\n ? checkpoints.map(\n (checkpoint) =>\n `- ${checkpoint.id} files=${checkpoint.fileCount} ${checkpoint.createdAt} ${formatPrompt(\n checkpoint.prompt,\n )}`,\n )\n : ['(no edit checkpoints)'];\n\n return {\n message: ['Edit checkpoints:', ...lines].join('\\n'),\n success: true,\n data: { count: checkpoints.length, checkpoints: [...checkpoints] },\n };\n}\n\nfunction formatCheckpointIds(ids: readonly string[]): string {\n return ids.length > 0 ? ids.join(', ') : '(none)';\n}\n\nfunction formatInspection(inspection: IEditCheckpointInspection): ICommandResult {\n const fileLines =\n inspection.capturedFiles.length > 0\n ? inspection.capturedFiles.map((file) => {\n const size =\n file.snapshotSizeBytes === undefined ? '' : ` size=${file.snapshotSizeBytes}B`;\n return `- ${file.relativePath} action=${file.restoreAction} snapshot=${String(\n file.snapshotAvailable,\n )}${size}`;\n })\n : ['(no files captured)'];\n\n return {\n message: [\n `Checkpoint ${inspection.target.id}`,\n `Prompt: ${formatPrompt(inspection.target.prompt)}`,\n 'Captured files:',\n ...fileLines,\n `Restore later checkpoints: files=${inspection.restoreToCheckpoint.fileCount} checkpoints=${formatCheckpointIds(\n inspection.restoreToCheckpoint.checkpointIds,\n )}`,\n `Rollback through checkpoint: files=${inspection.rollbackThroughCheckpoint.fileCount} checkpoints=${formatCheckpointIds(\n inspection.rollbackThroughCheckpoint.checkpointIds,\n )}`,\n ].join('\\n'),\n success: true,\n data: { inspection },\n };\n}\n\nfunction formatRestoreResult(result: IEditCheckpointRestoreResult): ICommandResult {\n return {\n message: [\n `Restored code to ${result.target.id}.`,\n `Restored files: ${result.restoredFileCount}`,\n `Rolled back checkpoints: ${result.restoredCheckpointCount}`,\n ].join('\\n'),\n success: true,\n data: {\n target: result.target,\n restoredCheckpointCount: result.restoredCheckpointCount,\n restoredFileCount: result.restoredFileCount,\n removedCheckpointCount: result.removedCheckpointCount,\n },\n };\n}\n\nfunction formatRollbackResult(result: IEditCheckpointRestoreResult): ICommandResult {\n return {\n message: [\n `Rolled back code through ${result.target.id}.`,\n `Restored files: ${result.restoredFileCount}`,\n `Removed checkpoints: ${result.removedCheckpointCount}`,\n ].join('\\n'),\n success: true,\n data: {\n target: result.target,\n restoredCheckpointCount: result.restoredCheckpointCount,\n restoredFileCount: result.restoredFileCount,\n removedCheckpointCount: result.removedCheckpointCount,\n },\n };\n}\n\nfunction formatError(error: Error | string): ICommandResult {\n return {\n message: error instanceof Error ? error.message : String(error),\n success: false,\n };\n}\n\nfunction inspect(context: ICommandHostContext, checkpointId: string | undefined): ICommandResult {\n if (!checkpointId) return usage();\n try {\n return formatInspection(inspectCommandEditCheckpoint(context, checkpointId));\n } catch (error) {\n return formatError(error instanceof Error ? error : String(error));\n }\n}\n\nasync function restore(\n context: ICommandHostContext,\n checkpointId: string | undefined,\n): Promise<ICommandResult> {\n if (!checkpointId) return usage();\n try {\n return formatRestoreResult(await restoreCommandEditCheckpoint(context, checkpointId));\n } catch (error) {\n return formatError(error instanceof Error ? error : String(error));\n }\n}\n\nasync function rollback(\n context: ICommandHostContext,\n checkpointId: string | undefined,\n): Promise<ICommandResult> {\n if (!checkpointId) return usage();\n try {\n return formatRollbackResult(await rollbackCommandEditCheckpoint(context, checkpointId));\n } catch (error) {\n return formatError(error instanceof Error ? error : String(error));\n }\n}\n\nexport async function executeRewindCommand(\n context: ICommandHostContext,\n rawArgs: string,\n): Promise<ICommandResult> {\n const args = rawArgs.trim().split(/\\s+/).filter(Boolean);\n const subcommand = args[SUBCOMMAND_INDEX] ?? 'list';\n\n if (subcommand === 'list') {\n return formatList(listCommandEditCheckpoints(context));\n }\n\n if (subcommand === 'inspect') {\n return inspect(context, args[CHECKPOINT_ID_INDEX]);\n }\n\n if (subcommand === 'restore' || subcommand === 'code') {\n return restore(context, args[CHECKPOINT_ID_INDEX]);\n }\n\n if (subcommand === 'rollback') {\n return rollback(context, args[CHECKPOINT_ID_INDEX]);\n }\n\n return usage();\n}\n","import {\n REWIND_COMMAND_ARGUMENT_HINT,\n REWIND_COMMAND_DESCRIPTION,\n buildRewindCommandSubcommands,\n} from '@robota-sdk/agent-framework';\n\nimport { executeRewindCommand } from './rewind-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createRewindCommandEntry(): ICommand {\n return {\n name: 'rewind',\n displayName: 'Rewind History',\n description: REWIND_COMMAND_DESCRIPTION,\n source: 'rewind',\n argumentHint: REWIND_COMMAND_ARGUMENT_HINT,\n modelInvocable: false,\n safety: 'write',\n subcommands: buildRewindCommandSubcommands(),\n };\n}\n\nfunction createRewindSystemCommand(): ISystemCommand {\n const entry = createRewindCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n argumentHint: entry.argumentHint,\n userInvocable: true,\n modelInvocable: false,\n safety: 'write',\n subcommands: entry.subcommands,\n execute: executeRewindCommand,\n };\n}\n\nexport class RewindCommandSource implements ICommandSource {\n readonly name = 'rewind';\n\n getCommands(): ICommand[] {\n return [createRewindCommandEntry()];\n }\n}\n\nexport function createRewindCommandModule(): ICommandModule {\n return {\n name: 'agent-command-rewind',\n commandSources: [new RewindCommandSource()],\n systemCommands: [createRewindSystemCommand()],\n };\n}\n","import {\n RENAME_COMMAND_USAGE,\n clearConversationHistory,\n createSessionPickerRequestedEffect,\n createSessionRenamedEffect,\n formatCommandSessionReplayValidationReport,\n parseSessionNameArgument,\n readCommandSessionInfo,\n validateCommandSessionReplayLog,\n} from '@robota-sdk/agent-framework';\n\nimport type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\n\nexport const CLEAR_COMMAND_MESSAGE = 'Conversation cleared.';\n\nexport function executeClearCommand(context: ICommandHostContext, _args: string): ICommandResult {\n clearConversationHistory(context);\n return {\n success: true,\n message: CLEAR_COMMAND_MESSAGE,\n effects: [{ type: 'conversation-history-cleared' }],\n };\n}\n\nexport function executeRenameCommand(_context: ICommandHostContext, args: string): ICommandResult {\n const name = parseSessionNameArgument(args);\n if (name === undefined) {\n return { success: false, message: RENAME_COMMAND_USAGE };\n }\n\n return {\n success: true,\n message: `Session renamed to \"${name}\".`,\n data: { name },\n effects: [createSessionRenamedEffect(name)],\n };\n}\n\nexport function executeResumeCommand(_context: ICommandHostContext, _args: string): ICommandResult {\n return {\n success: true,\n message: 'Opening session picker...',\n data: { triggerResumePicker: true },\n effects: [createSessionPickerRequestedEffect()],\n };\n}\n\nexport function executeCostCommand(context: ICommandHostContext, _args: string): ICommandResult {\n const sessionInfo = readCommandSessionInfo(context);\n return {\n success: true,\n message: `Session: ${sessionInfo.sessionId}\\nMessages: ${sessionInfo.messageCount}`,\n data: {\n sessionId: sessionInfo.sessionId,\n messageCount: sessionInfo.messageCount,\n },\n };\n}\n\nexport function executeValidateSessionCommand(\n context: ICommandHostContext,\n _args: string,\n): ICommandResult {\n const report = validateCommandSessionReplayLog(context);\n return {\n success: report.validation.ok,\n message: formatCommandSessionReplayValidationReport(report),\n data: {\n logFile: report.logFile,\n entryCount: report.entryCount,\n issueCount: report.validation.issues.length,\n ok: report.validation.ok,\n },\n };\n}\n","import {\n CLEAR_COMMAND_DESCRIPTION,\n COST_COMMAND_DESCRIPTION,\n RENAME_COMMAND_DESCRIPTION,\n RESUME_COMMAND_DESCRIPTION,\n VALIDATE_SESSION_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\n\nimport {\n executeClearCommand,\n executeCostCommand,\n executeRenameCommand,\n executeResumeCommand,\n executeValidateSessionCommand,\n} from './session-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createClearCommandEntry(): ICommand {\n return {\n name: 'clear',\n displayName: 'Clear History',\n description: CLEAR_COMMAND_DESCRIPTION,\n source: 'session',\n modelInvocable: false,\n };\n}\n\nexport function createRenameCommandEntry(): ICommand {\n return {\n name: 'rename',\n displayName: 'Rename Session',\n description: RENAME_COMMAND_DESCRIPTION,\n source: 'session',\n modelInvocable: false,\n };\n}\n\nexport function createResumeCommandEntry(): ICommand {\n return {\n name: 'resume',\n displayName: 'Resume Session',\n description: RESUME_COMMAND_DESCRIPTION,\n source: 'session',\n modelInvocable: false,\n };\n}\n\nexport function createCostCommandEntry(): ICommand {\n return {\n name: 'cost',\n displayName: 'Session Cost',\n description: COST_COMMAND_DESCRIPTION,\n source: 'session',\n modelInvocable: false,\n };\n}\n\nexport function createValidateSessionCommandEntry(): ICommand {\n return {\n name: 'validate-session',\n displayName: 'Validate Session',\n description: VALIDATE_SESSION_COMMAND_DESCRIPTION,\n source: 'session',\n modelInvocable: false,\n };\n}\n\nfunction createClearSystemCommand(): ISystemCommand {\n const entry = createClearCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeClearCommand,\n };\n}\n\nfunction createRenameSystemCommand(): ISystemCommand {\n const entry = createRenameCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeRenameCommand,\n };\n}\n\nfunction createResumeSystemCommand(): ISystemCommand {\n const entry = createResumeCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeResumeCommand,\n };\n}\n\nfunction createCostSystemCommand(): ISystemCommand {\n const entry = createCostCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeCostCommand,\n };\n}\n\nfunction createValidateSessionSystemCommand(): ISystemCommand {\n const entry = createValidateSessionCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: executeValidateSessionCommand,\n };\n}\n\nexport class SessionCommandSource implements ICommandSource {\n readonly name = 'session';\n\n getCommands(): ICommand[] {\n return [\n createClearCommandEntry(),\n createRenameCommandEntry(),\n createResumeCommandEntry(),\n createCostCommandEntry(),\n createValidateSessionCommandEntry(),\n ];\n }\n}\n\nexport function createSessionCommandModule(): ICommandModule {\n return {\n name: 'agent-command-session',\n commandSources: [new SessionCommandSource()],\n systemCommands: [\n createClearSystemCommand(),\n createRenameSystemCommand(),\n createResumeSystemCommand(),\n createCostSystemCommand(),\n createValidateSessionSystemCommand(),\n ],\n };\n}\n","import type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createSettingsCommandEntry(): ICommand {\n return {\n name: 'settings',\n displayName: 'Settings',\n description: 'Open transport settings — enable/disable transports and configure options',\n source: 'settings',\n modelInvocable: false,\n };\n}\n\nfunction createSettingsSystemCommand(): ISystemCommand {\n const entry = createSettingsCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n lifecycle: 'inline',\n execute: async () => ({\n success: true,\n message: 'Opening settings...',\n effects: [{ type: 'settings-tui-requested' as const }],\n }),\n };\n}\n\nexport class SettingsCommandSource implements ICommandSource {\n readonly name = 'settings';\n\n getCommands(): ICommand[] {\n return [createSettingsCommandEntry()];\n }\n}\n\nexport function createSettingsCommandModule(): ICommandModule {\n return {\n name: 'agent-command-settings',\n commandSources: [new SettingsCommandSource()],\n systemCommands: [createSettingsSystemCommand()],\n };\n}\n","import type {\n ICommandHostContext,\n ICommandResult,\n ICommandSkillListEntry,\n} from '@robota-sdk/agent-framework';\n\nexport const SKILLS_COMMAND_DESCRIPTION =\n 'Skill command. Before following a matching registered skill from the system prompt Skills section, invoke the projected skills command tool with args \"<skill-name> [args]\". Without arguments, list registered skills. With a skill name, activate that skill. Slash syntax is a UI input/display concern; the SDK command identity is \"skills\".';\n\ninterface IParsedSkillsArgs {\n readonly action: 'list' | 'activate';\n readonly skillName?: string;\n readonly skillArgs: string;\n}\n\nfunction formatSkillFlags(skill: ICommandSkillListEntry): string {\n const flags: string[] = [];\n if (!skill.modelInvocable) flags.push('model-disabled');\n if (!skill.userInvocable) flags.push('model-only');\n if (skill.context) flags.push(`context:${skill.context}`);\n if (skill.agent) flags.push(`agent:${skill.agent}`);\n return flags.length > 0 ? ` [${flags.join(', ')}]` : '';\n}\n\nfunction formatSkillLine(skill: ICommandSkillListEntry): string {\n const hint = skill.argumentHint ? ` ${skill.argumentHint}` : '';\n return `- ${skill.name}${hint}: ${skill.description}${formatSkillFlags(skill)}`;\n}\n\nfunction formatSkillsMessage(skills: readonly ICommandSkillListEntry[]): string {\n if (skills.length === 0) {\n return [\n 'No skills are registered for this session.',\n '',\n 'Skills are metadata until activated. Do not invent or imitate a skill workflow when no matching registered skill exists.',\n ].join('\\n');\n }\n\n return [\n 'Registered skills:',\n ...skills.map(formatSkillLine),\n '',\n 'Activation contract:',\n '- Use /skills <skill-name> [args] to activate a matching skill.',\n '- Treat /<skill-name> as a virtual alias for /skills <skill-name>.',\n '- The system prompt Skills section is skill selection metadata.',\n '- Treat descriptions as selection metadata only, not as loaded SKILL.md content.',\n '- Do not answer by merely naming, recommending, or imitating a matching skill.',\n '- If no listed skill matches the task, continue without claiming a skill was activated.',\n ].join('\\n');\n}\n\nfunction parseSkillsArgs(args: string): IParsedSkillsArgs {\n const trimmed = args.trim();\n if (trimmed.length === 0 || trimmed === 'list') {\n return { action: 'list', skillArgs: '' };\n }\n\n const [skillName = '', ...rest] = trimmed.split(/\\s+/);\n if (skillName.length === 0) {\n return { action: 'list', skillArgs: '' };\n }\n\n return {\n action: 'activate',\n skillName,\n skillArgs: rest.join(' '),\n };\n}\n\nexport async function executeSkillsCommand(\n context: ICommandHostContext,\n args = '',\n): Promise<ICommandResult> {\n const parsed = parseSkillsArgs(args);\n if (parsed.action === 'activate' && parsed.skillName !== undefined) {\n if (!context.executeSkillCommandByName) {\n return {\n success: false,\n message: 'Skill activation is not available in this session.',\n };\n }\n const displayInput = `/${parsed.skillName}${parsed.skillArgs ? ` ${parsed.skillArgs}` : ''}`;\n const result = await context.executeSkillCommandByName(parsed.skillName, parsed.skillArgs, {\n invocationSource: context.getCommandInvocationSource?.() ?? 'user',\n displayInput,\n rawInput: displayInput,\n });\n return (\n result ?? {\n success: false,\n message: `Unknown skill: ${parsed.skillName}`,\n }\n );\n }\n\n const skills = context.listSkills?.() ?? [];\n return {\n success: true,\n message: formatSkillsMessage(skills),\n data: {\n skills,\n activationContract: {\n activateWith: '/skills <skill-name> [args]',\n activationRequiredBeforeWorkflow: true,\n metadataIsNotSkillContent: true,\n },\n },\n };\n}\n","import { SkillCommandSource } from '@robota-sdk/agent-framework';\n\nimport { executeSkillsCommand, SKILLS_COMMAND_DESCRIPTION } from './skills-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport interface ISkillsCommandModuleOptions {\n readonly cwd: string;\n}\n\nexport function createSkillsCommandEntry(): ICommand {\n return {\n name: 'skills',\n displayName: 'Skills',\n description: SKILLS_COMMAND_DESCRIPTION,\n source: 'skills',\n modelInvocable: true,\n userInvocable: true,\n argumentHint: '[list | <skill-name> [args]]',\n safety: 'read-only',\n };\n}\n\nfunction createSkillsSystemCommand(): ISystemCommand {\n const entry = createSkillsCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: true,\n argumentHint: entry.argumentHint,\n safety: entry.safety,\n lifecycle: 'inline',\n execute: executeSkillsCommand,\n };\n}\n\nexport class SkillsCommandSource implements ICommandSource {\n readonly name = 'skills';\n\n getCommands(): ICommand[] {\n return [createSkillsCommandEntry()];\n }\n}\n\nexport function createSkillsCommandModule(options: ISkillsCommandModuleOptions): ICommandModule {\n const commandSources: ICommandSource[] = [new SkillsCommandSource()];\n commandSources.push(new SkillCommandSource(options.cwd));\n\n return {\n name: 'agent-command-skills',\n commandSources,\n systemCommands: [createSkillsSystemCommand()],\n };\n}\n","import { DEFAULT_STATUS_LINE_COMMAND_SETTINGS } from '@robota-sdk/agent-framework';\n\nimport type {\n ICommandHostContext,\n ICommandResult,\n TStatusLineCommandSettingsPatch,\n} from '@robota-sdk/agent-framework';\n\ninterface IStatusLineCommandSuccessAction {\n success: true;\n message: string;\n patch: TStatusLineCommandSettingsPatch;\n}\n\ninterface IStatusLineCommandFailureAction {\n success: false;\n message: string;\n}\n\ntype TStatusLineCommandAction = IStatusLineCommandSuccessAction | IStatusLineCommandFailureAction;\n\nexport const STATUSLINE_USAGE = [\n 'Usage: /statusline on | off | reset | git on | git off',\n 'Fields: model, context, permission mode, message count, session name, thinking state, git branch.',\n].join('\\n');\n\nfunction parseStatusLineArgs(args: string): TStatusLineCommandAction {\n const parts = args\n .trim()\n .toLowerCase()\n .split(/\\s+/)\n .filter((part) => part.length > 0);\n const [first, second] = parts;\n\n if (first === 'on' && second === undefined) {\n return { success: true, message: 'Status line enabled.', patch: { enabled: true } };\n }\n if (first === 'off' && second === undefined) {\n return { success: true, message: 'Status line disabled.', patch: { enabled: false } };\n }\n if (first === 'reset' && second === undefined) {\n return {\n success: true,\n message: 'Status line settings reset.',\n patch: { ...DEFAULT_STATUS_LINE_COMMAND_SETTINGS },\n };\n }\n if (first === 'git' && second === 'on' && parts.length === 2) {\n return {\n success: true,\n message: 'Status line git branch shown.',\n patch: { gitBranch: true },\n };\n }\n if (first === 'git' && second === 'off' && parts.length === 2) {\n return {\n success: true,\n message: 'Status line git branch hidden.',\n patch: { gitBranch: false },\n };\n }\n\n return { success: false, message: STATUSLINE_USAGE };\n}\n\nexport function executeStatusLineCommand(\n _context: ICommandHostContext,\n args: string,\n): ICommandResult {\n const action = parseStatusLineArgs(args);\n if (!action.success) {\n return { success: false, message: action.message };\n }\n\n return {\n success: true,\n message: action.message,\n effects: [{ type: 'statusline-settings-patch', patch: action.patch }],\n };\n}\n","import {\n buildStatusLineCommandSubcommands,\n STATUSLINE_COMMAND_ARGUMENT_HINT,\n STATUSLINE_COMMAND_DESCRIPTION,\n} from '@robota-sdk/agent-framework';\n\nimport { executeStatusLineCommand } from './statusline-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createStatusLineCommandEntry(): ICommand {\n return {\n name: 'statusline',\n displayName: 'Status Line',\n description: STATUSLINE_COMMAND_DESCRIPTION,\n source: 'statusline',\n argumentHint: STATUSLINE_COMMAND_ARGUMENT_HINT,\n subcommands: buildStatusLineCommandSubcommands('statusline'),\n modelInvocable: false,\n };\n}\n\nfunction createStatusLineSystemCommand(): ISystemCommand {\n const entry = createStatusLineCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n subcommands: entry.subcommands,\n lifecycle: 'inline',\n execute: executeStatusLineCommand,\n };\n}\n\nexport class StatusLineCommandSource implements ICommandSource {\n readonly name = 'statusline';\n\n getCommands(): ICommand[] {\n return [createStatusLineCommandEntry()];\n }\n}\n\nexport function createStatusLineCommandModule(): ICommandModule {\n return {\n name: 'agent-command-statusline',\n commandSources: [new StatusLineCommandSource()],\n systemCommands: [createStatusLineSystemCommand()],\n };\n}\n","export const USER_LOCAL_COMMAND_DESCRIPTION = 'Inspect Robota user-local storage and memory state.';\nexport const USER_LOCAL_COMMAND_ARGUMENT_HINT =\n 'storage list [--format json] | memory set/list/inspect/disable/delete';\nexport const USER_LOCAL_COMMAND_USAGE =\n 'Usage: user-local storage list [--format json] | user-local memory set <category> <key> <value> --summary <summary> --source <source> | user-local memory list [--format json] | user-local memory inspect <category> <key> [--format json] | user-local memory disable <category> <key> | user-local memory delete <category> <key>';\n","import {\n deleteUserLocalMemoryItem,\n disableUserLocalMemoryItem,\n inspectUserLocalMemoryItem,\n listUserLocalMemoryItems,\n setUserLocalMemoryItem,\n} from '@robota-sdk/agent-framework';\n\nimport { USER_LOCAL_COMMAND_USAGE } from './user-local-command-constants.js';\n\nimport type { ICommandResult, TUserLocalMemoryCategory } from '@robota-sdk/agent-framework';\n\nexport interface IUserLocalMemoryCommandArgs {\n readonly action?: string;\n readonly positional: readonly string[];\n readonly format: 'text' | 'json';\n readonly summary?: string;\n readonly source?: string;\n}\n\nfunction formatMemoryListText(\n items: readonly { category: string; key: string; enabled: boolean }[],\n): string {\n if (items.length === 0) {\n return 'No user-local memory items.';\n }\n return items\n .map((item) => `- ${item.category}/${item.key} (${item.enabled ? 'enabled' : 'disabled'})`)\n .join('\\n');\n}\n\nfunction parseMemoryCategory(value: string | undefined): TUserLocalMemoryCategory {\n if (value === undefined) {\n throw new Error('User-local memory category is required.');\n }\n return value as TUserLocalMemoryCategory;\n}\n\nasync function executeMemoryListCommand(\n activeRepositoryRoot: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n const list = await listUserLocalMemoryItems({ activeRepositoryRoot });\n return {\n message:\n parsed.format === 'json' ? JSON.stringify(list, null, 2) : formatMemoryListText(list.items),\n success: true,\n data: { list },\n };\n}\n\nasync function executeMemorySetCommand(\n activeRepositoryRoot: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n const [category, key, value] = parsed.positional;\n const item = await setUserLocalMemoryItem({\n activeRepositoryRoot,\n category: parseMemoryCategory(category),\n key: key ?? '',\n value: value ?? '',\n summary: parsed.summary ?? '',\n source: parsed.source ?? '',\n });\n return {\n message: `Stored user-local memory item ${item.category}/${item.key} at ${item.storageLocation}`,\n success: true,\n data: { item },\n };\n}\n\nasync function executeMemoryInspectCommand(\n activeRepositoryRoot: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n const [category, key] = parsed.positional;\n const item = await inspectUserLocalMemoryItem({\n activeRepositoryRoot,\n category: parseMemoryCategory(category),\n key: key ?? '',\n });\n return {\n message:\n parsed.format === 'json'\n ? JSON.stringify(item, null, 2)\n : `${item.category}/${item.key}: ${item.summary}`,\n success: true,\n data: { item },\n };\n}\n\nasync function executeMemoryDisableCommand(\n activeRepositoryRoot: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n const [category, key] = parsed.positional;\n const item = await disableUserLocalMemoryItem({\n activeRepositoryRoot,\n category: parseMemoryCategory(category),\n key: key ?? '',\n });\n return {\n message: `Disabled user-local memory item ${item.category}/${item.key}`,\n success: true,\n data: { item },\n };\n}\n\nasync function executeMemoryDeleteCommand(\n activeRepositoryRoot: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n const [category, key] = parsed.positional;\n const result = await deleteUserLocalMemoryItem({\n activeRepositoryRoot,\n category: parseMemoryCategory(category),\n key: key ?? '',\n });\n return {\n message: `Deleted user-local memory item ${result.category}/${result.key}`,\n success: true,\n data: { result },\n };\n}\n\nexport async function executeMemoryCommand(\n cwd: string,\n parsed: IUserLocalMemoryCommandArgs,\n): Promise<ICommandResult> {\n if ((parsed.action ?? 'list') === 'list') {\n return executeMemoryListCommand(cwd, parsed);\n }\n if (parsed.action === 'set') {\n return executeMemorySetCommand(cwd, parsed);\n }\n if (parsed.action === 'inspect') {\n return executeMemoryInspectCommand(cwd, parsed);\n }\n if (parsed.action === 'disable') {\n return executeMemoryDisableCommand(cwd, parsed);\n }\n if (parsed.action === 'delete') {\n return executeMemoryDeleteCommand(cwd, parsed);\n }\n return {\n message: USER_LOCAL_COMMAND_USAGE,\n success: false,\n };\n}\n","import { inspectUserLocalStorage } from '@robota-sdk/agent-framework';\n\nimport { USER_LOCAL_COMMAND_USAGE } from './user-local-command-constants.js';\nimport { executeMemoryCommand } from './user-local-memory-command.js';\n\nimport type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';\nexport {\n USER_LOCAL_COMMAND_ARGUMENT_HINT,\n USER_LOCAL_COMMAND_DESCRIPTION,\n USER_LOCAL_COMMAND_USAGE,\n} from './user-local-command-constants.js';\n\ntype TUserLocalOutputFormat = 'text' | 'json';\n\nexport interface IUserLocalDirectCommandOptions {\n readonly cwd: string;\n readonly argv: readonly string[];\n readonly format?: string;\n readonly summary?: string;\n readonly source?: string;\n}\n\ninterface IParsedUserLocalCommand {\n readonly target?: string;\n readonly action?: string;\n readonly positional: readonly string[];\n readonly format: TUserLocalOutputFormat;\n readonly summary?: string;\n readonly source?: string;\n}\n\ninterface IParsedUserLocalOption {\n readonly format?: string;\n readonly summary?: string;\n readonly source?: string;\n readonly nextIndex: number;\n}\n\nfunction parseOutputFormat(value: string | undefined): TUserLocalOutputFormat {\n if (value === undefined || value === 'text') {\n return 'text';\n }\n if (value === 'json') {\n return 'json';\n }\n throw new Error(`Unsupported user-local output format: ${value}`);\n}\n\nfunction parseUserLocalOption(\n arg: string,\n argv: readonly string[],\n index: number,\n): IParsedUserLocalOption | null {\n if (arg === '--format') {\n return { format: argv[index + 1], nextIndex: index + 1 };\n }\n if (arg.startsWith('--format=')) {\n return { format: arg.slice('--format='.length), nextIndex: index };\n }\n if (arg === '--summary') {\n return { summary: argv[index + 1], nextIndex: index + 1 };\n }\n if (arg.startsWith('--summary=')) {\n return { summary: arg.slice('--summary='.length), nextIndex: index };\n }\n if (arg === '--source') {\n return { source: argv[index + 1], nextIndex: index + 1 };\n }\n if (arg.startsWith('--source=')) {\n return { source: arg.slice('--source='.length), nextIndex: index };\n }\n return null;\n}\n\nfunction parseUserLocalArgs(\n argv: readonly string[],\n directOptions: {\n readonly format?: string;\n readonly summary?: string;\n readonly source?: string;\n } = {},\n): IParsedUserLocalCommand {\n let format = directOptions.format;\n let summary = directOptions.summary;\n let source = directOptions.source;\n const positional: string[] = [];\n\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index];\n const option = parseUserLocalOption(arg, argv, index);\n if (option !== null) {\n format = option.format ?? format;\n summary = option.summary ?? summary;\n source = option.source ?? source;\n index = option.nextIndex;\n continue;\n }\n positional.push(arg);\n }\n\n return {\n target: positional[0],\n action: positional[1],\n positional: positional.slice(2),\n format: parseOutputFormat(format),\n summary,\n source,\n };\n}\n\nfunction splitRawArgs(rawArgs: string): readonly string[] {\n return rawArgs.trim().split(/\\s+/).filter(Boolean);\n}\n\nfunction formatStorageInspectionText(\n root: string,\n categories: readonly { category: string }[],\n): string {\n const categoryLines = categories.map((item) => `- ${item.category}`);\n return [`User-local storage root: ${root}`, 'Categories:', ...categoryLines].join('\\n');\n}\n\nasync function executeStorageCommand(\n cwd: string,\n parsed: IParsedUserLocalCommand,\n): Promise<ICommandResult> {\n if ((parsed.action ?? 'list') !== 'list') {\n return {\n message: USER_LOCAL_COMMAND_USAGE,\n success: false,\n };\n }\n\n const inspection = await inspectUserLocalStorage({ activeRepositoryRoot: cwd });\n return {\n message:\n parsed.format === 'json'\n ? JSON.stringify(inspection, null, 2)\n : formatStorageInspectionText(inspection.root, inspection.categories),\n success: true,\n data: {\n root: inspection.root,\n categories: inspection.categories,\n inspection,\n },\n };\n}\n\nasync function executeParsedUserLocalCommand(\n cwd: string,\n parsed: IParsedUserLocalCommand,\n): Promise<ICommandResult> {\n if (parsed.target === 'storage') {\n return executeStorageCommand(cwd, parsed);\n }\n if (parsed.target === 'memory') {\n return executeMemoryCommand(cwd, parsed);\n }\n return {\n message: USER_LOCAL_COMMAND_USAGE,\n success: false,\n };\n}\n\nfunction formatCommandErrorMessage(errorMessage: string): string {\n if (errorMessage.includes('ENOENT')) {\n return 'User-local memory item not found.';\n }\n return errorMessage;\n}\n\nexport async function executeUserLocalDirectCommand(\n options: IUserLocalDirectCommandOptions,\n): Promise<ICommandResult> {\n try {\n return await executeParsedUserLocalCommand(\n options.cwd,\n parseUserLocalArgs(options.argv, {\n format: options.format,\n summary: options.summary,\n source: options.source,\n }),\n );\n } catch (error) {\n return {\n message: formatCommandErrorMessage(error instanceof Error ? error.message : String(error)),\n success: false,\n };\n }\n}\n\nexport async function executeUserLocalCommand(\n context: ICommandHostContext,\n rawArgs: string,\n): Promise<ICommandResult> {\n try {\n return await executeParsedUserLocalCommand(\n context.getCwd(),\n parseUserLocalArgs(splitRawArgs(rawArgs)),\n );\n } catch (error) {\n return {\n message: formatCommandErrorMessage(error instanceof Error ? error.message : String(error)),\n success: false,\n };\n }\n}\n","import {\n USER_LOCAL_COMMAND_ARGUMENT_HINT,\n USER_LOCAL_COMMAND_DESCRIPTION,\n executeUserLocalCommand,\n} from './user-local-command.js';\n\nimport type {\n ICommand,\n ICommandModule,\n ICommandSource,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\n\nexport function createUserLocalCommandEntry(): ICommand {\n return {\n name: 'user-local',\n displayName: 'User Config',\n description: USER_LOCAL_COMMAND_DESCRIPTION,\n source: 'user-local',\n argumentHint: USER_LOCAL_COMMAND_ARGUMENT_HINT,\n modelInvocable: false,\n safety: 'read-only',\n subcommands: [\n {\n name: 'storage',\n description: 'Inspect user-local storage categories',\n source: 'user-local',\n },\n {\n name: 'memory',\n description: 'Inspect and manage user-local memory items',\n source: 'user-local',\n },\n ],\n };\n}\n\nfunction createUserLocalSystemCommand(): ISystemCommand {\n const entry = createUserLocalCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n argumentHint: entry.argumentHint,\n safety: entry.safety,\n subcommands: entry.subcommands,\n execute: executeUserLocalCommand,\n };\n}\n\nexport class UserLocalCommandSource implements ICommandSource {\n readonly name = 'user-local';\n\n getCommands(): ICommand[] {\n return [createUserLocalCommandEntry()];\n }\n}\n\nexport function createUserLocalCommandModule(): ICommandModule {\n return {\n name: 'agent-command-user-local',\n commandSources: [new UserLocalCommandSource()],\n systemCommands: [createUserLocalSystemCommand()],\n };\n}\n","import { createAgentCommandModule } from '../agent/index.js';\nimport { createBackgroundCommandModule } from '../background/index.js';\nimport { createCompactCommandModule } from '../compact/index.js';\nimport { createContextCommandModule } from '../context/index.js';\nimport { createExitCommandModule } from '../exit/index.js';\nimport { createHelpCommandModule } from '../help/index.js';\nimport { createLanguageCommandModule } from '../language/index.js';\nimport { createMemoryCommandModule } from '../memory/index.js';\nimport { createModeCommandModule } from '../mode/index.js';\nimport { createModelCommandModule } from '../model/index.js';\nimport { createPermissionsCommandModule } from '../permissions/index.js';\nimport { createPluginCommandModule } from '../plugin/index.js';\nimport { createProviderCommandModule } from '../provider/index.js';\nimport { createResetCommandModule } from '../reset/index.js';\nimport { createRewindCommandModule } from '../rewind/index.js';\nimport { createSessionCommandModule } from '../session/index.js';\nimport { createSettingsCommandModule } from '../settings/index.js';\nimport { createSkillsCommandModule } from '../skills/index.js';\nimport { createStatusLineCommandModule } from '../statusline/index.js';\nimport { createUserLocalCommandModule } from '../user-local/index.js';\n\nimport type { IProviderDefinition } from '@robota-sdk/agent-core';\nimport type { ICommandModule, IProviderCommandSettingsAdapter } from '@robota-sdk/agent-framework';\n\nexport interface IDefaultCommandModulesOptions {\n cwd: string;\n providerDefinitions: readonly IProviderDefinition[];\n providerSettingsAdapter: IProviderCommandSettingsAdapter;\n}\n\nexport function createDefaultCommandModules({\n cwd,\n providerDefinitions,\n providerSettingsAdapter,\n}: IDefaultCommandModulesOptions): readonly ICommandModule[] {\n return [\n createSkillsCommandModule({ cwd }),\n createHelpCommandModule(),\n createAgentCommandModule(),\n createModelCommandModule({\n providerDefinitions,\n settings: { readMergedSettings: () => providerSettingsAdapter.readMergedSettings() },\n }),\n createPermissionsCommandModule(),\n createModeCommandModule(),\n createLanguageCommandModule(),\n createBackgroundCommandModule(),\n createMemoryCommandModule(),\n createUserLocalCommandModule(),\n createCompactCommandModule(),\n createContextCommandModule(),\n createExitCommandModule(),\n createSessionCommandModule(),\n createResetCommandModule(),\n createRewindCommandModule(),\n createStatusLineCommandModule(),\n createPluginCommandModule(),\n createSettingsCommandModule(),\n createProviderCommandModule({\n providerDefinitions,\n settings: providerSettingsAdapter,\n }),\n ];\n}\n","import { execSync } from 'node:child_process';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\n\nimport {\n BundlePluginInstaller,\n BundlePluginLoader,\n MarketplaceClient,\n PluginSettingsStore,\n} from '@robota-sdk/agent-framework';\n\nimport type {\n ICommandAvailablePlugin,\n ICommandInstalledPlugin,\n ICommandMarketplaceSource,\n ICommandPluginAdapter,\n IMarketplaceManifest,\n TPluginInstallScope,\n} from '@robota-sdk/agent-framework';\n\ninterface IPluginServices {\n cwd: string;\n marketplace: MarketplaceClient;\n installer: BundlePluginInstaller;\n loader: BundlePluginLoader;\n settingsStore: PluginSettingsStore;\n}\n\nfunction createPluginServices(cwd: string): IPluginServices {\n const home = homedir();\n const pluginsDir = join(home, '.robota', 'plugins');\n const userSettingsPath = join(home, '.robota', 'settings.json');\n\n const exec = (command: string, options: { timeout: number; stdio?: string }): Buffer =>\n execSync(command, {\n timeout: options.timeout,\n stdio: (options.stdio ?? 'pipe') as 'pipe' | 'inherit' | 'ignore',\n });\n\n const settingsStore = new PluginSettingsStore(userSettingsPath);\n const marketplace = new MarketplaceClient({ pluginsDir, exec });\n const installer = new BundlePluginInstaller({\n pluginsDir,\n settingsStore,\n marketplaceClient: marketplace,\n exec,\n });\n const loader = new BundlePluginLoader(pluginsDir);\n\n return {\n cwd,\n marketplace,\n installer,\n loader,\n settingsStore,\n };\n}\n\nasync function listInstalledPlugins(\n services: IPluginServices,\n): Promise<readonly ICommandInstalledPlugin[]> {\n const plugins = await services.loader.loadAll();\n const enabledMap = services.settingsStore.getEnabledPlugins();\n return plugins.map((plugin) => {\n const parts = plugin.pluginDir.split('/');\n const cacheIdx = parts.indexOf('cache');\n const marketplaceName = cacheIdx >= 0 ? (parts[cacheIdx + 1] ?? '') : '';\n const fullId = marketplaceName\n ? `${plugin.manifest.name}@${marketplaceName}`\n : plugin.manifest.name;\n return {\n name: fullId,\n description: plugin.manifest.description,\n enabled: enabledMap[fullId] !== false && enabledMap[plugin.manifest.name] !== false,\n };\n });\n}\n\nasync function listAvailablePlugins(\n services: IPluginServices,\n marketplaceName: string,\n): Promise<readonly ICommandAvailablePlugin[]> {\n let manifest: IMarketplaceManifest;\n try {\n manifest = services.marketplace.fetchManifest(marketplaceName);\n } catch {\n // allow-fallback: marketplace manifest fetch failure is non-fatal — return empty list\n return [];\n }\n const installed = services.installer.getInstalledPlugins();\n const installedNames = new Set(Object.values(installed).map((record) => record.pluginName));\n return manifest.plugins.map((plugin) => ({\n name: plugin.name,\n description: plugin.description,\n installed: installedNames.has(plugin.name),\n }));\n}\n\nasync function installPlugin(\n services: IPluginServices,\n pluginId: string,\n scope?: TPluginInstallScope,\n): Promise<void> {\n const [name, marketplaceName] = pluginId.split('@');\n if (!name || !marketplaceName) {\n throw new Error('Plugin ID must be in format: name@marketplace');\n }\n if (scope === 'project') {\n const projectPluginsDir = join(services.cwd, '.robota', 'plugins');\n const projectExec = (command: string, options: { timeout: number; stdio?: string }): Buffer =>\n execSync(command, {\n timeout: options.timeout,\n stdio: (options.stdio ?? 'pipe') as 'pipe' | 'inherit' | 'ignore',\n });\n const projectInstaller = new BundlePluginInstaller({\n pluginsDir: projectPluginsDir,\n settingsStore: services.settingsStore,\n marketplaceClient: services.marketplace,\n exec: projectExec,\n });\n await projectInstaller.install(name, marketplaceName);\n return;\n }\n await services.installer.install(name, marketplaceName);\n}\n\nasync function removeMarketplace(services: IPluginServices, name: string): Promise<void> {\n const installedFromMarketplace = services.installer.getPluginsByMarketplace(name);\n for (const record of installedFromMarketplace) {\n await services.installer.uninstall(`${record.pluginName}@${record.marketplace}`);\n }\n services.marketplace.removeMarketplace(name);\n}\n\nfunction listMarketplaces(services: IPluginServices): readonly ICommandMarketplaceSource[] {\n return services.marketplace.listMarketplaces().map((marketplaceEntry) => ({\n name: marketplaceEntry.name,\n type: marketplaceEntry.source.type,\n }));\n}\n\nexport function createDefaultPluginCommandAdapter(cwd: string): ICommandPluginAdapter {\n const services = createPluginServices(cwd);\n return {\n listInstalled: () => listInstalledPlugins(services),\n listAvailablePlugins: (marketplaceName) => listAvailablePlugins(services, marketplaceName),\n install: (pluginId, scope) => installPlugin(services, pluginId, scope),\n uninstall: async (pluginId) => services.installer.uninstall(pluginId),\n enable: async (pluginId) => services.installer.enable(pluginId),\n disable: async (pluginId) => services.installer.disable(pluginId),\n marketplaceAdd: async (source) => {\n if (source.includes('/') && !source.includes(':')) {\n return services.marketplace.addMarketplace({ type: 'github', repo: source });\n }\n return services.marketplace.addMarketplace({ type: 'git', url: source });\n },\n marketplaceRemove: (name) => removeMarketplace(services, name),\n marketplaceUpdate: async (name) => services.marketplace.updateMarketplace(name),\n marketplaceList: async () => listMarketplaces(services),\n reloadPlugins: async () => ({\n loadedPluginCount: (await services.loader.loadAll()).length,\n }),\n };\n}\n","import { homedir } from 'node:os';\nimport { join } from 'node:path';\n\nimport { BundlePluginLoader, PluginCommandSource } from '@robota-sdk/agent-framework';\n\nimport type { CommandRegistry } from '@robota-sdk/agent-framework';\n\nconst PLUGIN_SOURCE_NAME = 'plugin';\n\nfunction getHomeDir(): string {\n return process.env.HOME ?? homedir();\n}\n\nexport function reloadPluginCommandSource(registry: CommandRegistry): number {\n const pluginsDir = join(getHomeDir(), '.robota', 'plugins');\n const loader = new BundlePluginLoader(pluginsDir);\n try {\n // allow-fallback: plugin load failure is non-fatal — clear source and return empty\n const plugins = loader.loadPluginsSync();\n if (plugins.length === 0) {\n registry.replaceSource(PLUGIN_SOURCE_NAME);\n return 0;\n }\n registry.replaceSource(PLUGIN_SOURCE_NAME, new PluginCommandSource(plugins));\n return plugins.length;\n } catch {\n // allow-fallback: plugin load failure is non-fatal — clear source and return empty\n registry.replaceSource(PLUGIN_SOURCE_NAME);\n return 0;\n }\n}\n"],"mappings":"s8HAsBA,SAAgB,GAAa,EAAwB,CACnD,IAAM,EAAmB,CAAC,EACtB,EAAU,GACV,EACA,EAAU,GAEd,IAAK,IAAM,KAAQ,EAAM,CACvB,GAAI,EAAS,CACX,GAAW,EACX,EAAU,GACV,QACF,CACA,GAAI,GAAS,IAAS,KAAM,CAC1B,EAAU,GACV,QACF,CACA,GAAI,EAAO,CACL,IAAS,EAAO,EAAQ,IAAA,GACvB,GAAW,EAChB,QACF,CACA,GAAI,IAAS,KAAO,IAAS,IAAK,CAChC,EAAQ,EACR,QACF,CACA,GAAI,KAAK,KAAK,CAAI,EAAG,CACf,EAAQ,OAAS,IACnB,EAAO,KAAK,CAAO,EACnB,EAAU,IAEZ,QACF,CACA,GAAW,CACb,CAGA,OADI,EAAQ,OAAS,GAAG,EAAO,KAAK,CAAO,EACpC,CACT,CAEA,SAAS,GAAa,EAAgD,CACpE,IAAM,EAAuB,CAAC,EAC1B,EACA,EACA,EAEJ,IAAK,IAAI,EAAQ,EAAG,E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