@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
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
checkSettingsDocument,
|
|
5
|
+
readMergedProviderSettings,
|
|
6
|
+
readSettings,
|
|
7
|
+
writeSettings,
|
|
8
|
+
resolveSettingsPathForScope,
|
|
9
|
+
getProviderSettingsPaths,
|
|
10
|
+
applyProviderConfiguration,
|
|
11
|
+
} from '@robota-sdk/agent-framework';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
formatProviderSetupSelectionPrompt,
|
|
15
|
+
resolveProviderSetupSelection,
|
|
16
|
+
runProviderSetupPromptFlow,
|
|
17
|
+
type TPromptInput,
|
|
18
|
+
} from './provider-setup-flow.js';
|
|
19
|
+
|
|
20
|
+
import type { IProviderDefinition } from '@robota-sdk/agent-core';
|
|
21
|
+
import type { ITerminalOutput } from '@robota-sdk/agent-core';
|
|
22
|
+
import type { TSettingsScope } from '@robota-sdk/agent-framework';
|
|
23
|
+
|
|
24
|
+
export interface IProviderStartupContext {
|
|
25
|
+
provider?: string;
|
|
26
|
+
settingsScope?: TSettingsScope;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface IEnsureProviderConfigOptions {
|
|
30
|
+
formatError: (defs: readonly IProviderDefinition[]) => string;
|
|
31
|
+
isInteractive?: () => boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function runProviderStartupSetup(
|
|
35
|
+
cwd: string,
|
|
36
|
+
ctx: IProviderStartupContext,
|
|
37
|
+
promptInput: TPromptInput,
|
|
38
|
+
terminal: ITerminalOutput,
|
|
39
|
+
providerDefinitions: readonly IProviderDefinition[],
|
|
40
|
+
): Promise<void> {
|
|
41
|
+
const providerChoice = await promptInput(formatProviderSetupSelectionPrompt(providerDefinitions));
|
|
42
|
+
const type = resolveProviderSetupSelection(providerChoice, providerDefinitions);
|
|
43
|
+
const settingsPath = resolveSettingsPathForScope(cwd, ctx.settingsScope);
|
|
44
|
+
const input = await runProviderSetupPromptFlow(type, promptInput, providerDefinitions, {
|
|
45
|
+
existingProfileNames: Object.keys(readMergedProviderSettings(cwd).providers ?? {}),
|
|
46
|
+
});
|
|
47
|
+
applyProviderConfiguration(settingsPath, input, { providerDefinitions });
|
|
48
|
+
const language = await promptInput(' Response language (ko/en/ja/zh, default: en): ');
|
|
49
|
+
if (language) {
|
|
50
|
+
const settings = readSettings(settingsPath);
|
|
51
|
+
settings.language = language;
|
|
52
|
+
writeSettings(settingsPath, settings);
|
|
53
|
+
}
|
|
54
|
+
terminal.writeLine(`\n Config saved to ${settingsPath}\n`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function ensureProviderConfig(
|
|
58
|
+
cwd: string,
|
|
59
|
+
ctx: IProviderStartupContext,
|
|
60
|
+
promptInput: TPromptInput,
|
|
61
|
+
terminal: ITerminalOutput,
|
|
62
|
+
providerDefinitions: readonly IProviderDefinition[],
|
|
63
|
+
options: IEnsureProviderConfigOptions,
|
|
64
|
+
): Promise<void> {
|
|
65
|
+
const merged = readMergedProviderSettings(cwd);
|
|
66
|
+
const selectedSettings =
|
|
67
|
+
ctx.provider !== undefined ? { ...merged, currentProvider: ctx.provider } : merged;
|
|
68
|
+
if (checkSettingsDocument(selectedSettings, providerDefinitions) === 'valid') {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const checkInteractive = options.isInteractive ?? (() => false);
|
|
72
|
+
if (!checkInteractive()) {
|
|
73
|
+
throw new Error(options.formatError(providerDefinitions));
|
|
74
|
+
}
|
|
75
|
+
await runProviderStartupSetup(
|
|
76
|
+
cwd,
|
|
77
|
+
selectStartupContext(cwd, ctx),
|
|
78
|
+
promptInput,
|
|
79
|
+
terminal,
|
|
80
|
+
providerDefinitions,
|
|
81
|
+
);
|
|
82
|
+
const updated = readMergedProviderSettings(cwd);
|
|
83
|
+
const updatedSettings =
|
|
84
|
+
ctx.provider !== undefined ? { ...updated, currentProvider: ctx.provider } : updated;
|
|
85
|
+
if (checkSettingsDocument(updatedSettings, providerDefinitions) !== 'valid') {
|
|
86
|
+
throw new Error(options.formatError(providerDefinitions));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function selectStartupContext(cwd: string, ctx: IProviderStartupContext): IProviderStartupContext {
|
|
91
|
+
if (ctx.settingsScope !== undefined || ctx.provider !== undefined) return ctx;
|
|
92
|
+
const currentProviderPath = findHighestPriorityCurrentProviderPath(getProviderSettingsPaths(cwd));
|
|
93
|
+
if (currentProviderPath === undefined) return ctx;
|
|
94
|
+
const projectSettingsPath = join(cwd, '.robota', 'settings.json');
|
|
95
|
+
const projectLocalSettingsPath = join(cwd, '.robota', 'settings.local.json');
|
|
96
|
+
if (
|
|
97
|
+
currentProviderPath === projectSettingsPath ||
|
|
98
|
+
currentProviderPath === projectLocalSettingsPath
|
|
99
|
+
) {
|
|
100
|
+
return { ...ctx, settingsScope: 'project-local' };
|
|
101
|
+
}
|
|
102
|
+
return ctx;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function findHighestPriorityCurrentProviderPath(
|
|
106
|
+
settingsPaths: readonly string[],
|
|
107
|
+
): string | undefined {
|
|
108
|
+
for (let index = settingsPaths.length - 1; index >= 0; index -= 1) {
|
|
109
|
+
const settingsPath = settingsPaths[index];
|
|
110
|
+
if (settingsPath === undefined) continue;
|
|
111
|
+
const settings = readSettings(settingsPath);
|
|
112
|
+
if (typeof settings.currentProvider === 'string') {
|
|
113
|
+
return settingsPath;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { executeResetCommand } from './reset-command.js';
|
|
2
|
+
|
|
1
3
|
import type {
|
|
2
4
|
ICommand,
|
|
3
5
|
ICommandModule,
|
|
4
6
|
ICommandSource,
|
|
5
7
|
ISystemCommand,
|
|
6
8
|
} from '@robota-sdk/agent-framework';
|
|
7
|
-
import { executeResetCommand } from './reset-command.js';
|
|
8
9
|
|
|
9
10
|
const RESET_COMMAND_DESCRIPTION = 'Delete settings';
|
|
10
11
|
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ICommand,
|
|
3
|
-
ICommandModule,
|
|
4
|
-
ICommandSource,
|
|
5
|
-
ISystemCommand,
|
|
6
|
-
} from '@robota-sdk/agent-framework';
|
|
7
1
|
import {
|
|
8
2
|
REWIND_COMMAND_ARGUMENT_HINT,
|
|
9
3
|
REWIND_COMMAND_DESCRIPTION,
|
|
10
4
|
buildRewindCommandSubcommands,
|
|
11
5
|
} from '@robota-sdk/agent-framework';
|
|
6
|
+
|
|
12
7
|
import { executeRewindCommand } from './rewind-command.js';
|
|
13
8
|
|
|
9
|
+
import type {
|
|
10
|
+
ICommand,
|
|
11
|
+
ICommandModule,
|
|
12
|
+
ICommandSource,
|
|
13
|
+
ISystemCommand,
|
|
14
|
+
} from '@robota-sdk/agent-framework';
|
|
15
|
+
|
|
14
16
|
export function createRewindCommandEntry(): ICommand {
|
|
15
17
|
return {
|
|
16
18
|
name: 'rewind',
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
inspectCommandEditCheckpoint,
|
|
3
|
+
listCommandEditCheckpoints,
|
|
4
|
+
restoreCommandEditCheckpoint,
|
|
5
|
+
rollbackCommandEditCheckpoint,
|
|
6
|
+
} from '@robota-sdk/agent-framework';
|
|
7
|
+
|
|
1
8
|
import type {
|
|
2
9
|
ICommandHostContext,
|
|
3
10
|
ICommandResult,
|
|
@@ -5,12 +12,6 @@ import type {
|
|
|
5
12
|
IEditCheckpointRestoreResult,
|
|
6
13
|
IEditCheckpointSummary,
|
|
7
14
|
} from '@robota-sdk/agent-framework';
|
|
8
|
-
import {
|
|
9
|
-
inspectCommandEditCheckpoint,
|
|
10
|
-
listCommandEditCheckpoints,
|
|
11
|
-
restoreCommandEditCheckpoint,
|
|
12
|
-
rollbackCommandEditCheckpoint,
|
|
13
|
-
} from '@robota-sdk/agent-framework';
|
|
14
15
|
|
|
15
16
|
const SUBCOMMAND_INDEX = 0;
|
|
16
17
|
const CHECKPOINT_ID_INDEX = 1;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ICommand,
|
|
3
|
-
ICommandModule,
|
|
4
|
-
ICommandSource,
|
|
5
|
-
ISystemCommand,
|
|
6
|
-
} from '@robota-sdk/agent-framework';
|
|
7
1
|
import {
|
|
8
2
|
CLEAR_COMMAND_DESCRIPTION,
|
|
9
3
|
COST_COMMAND_DESCRIPTION,
|
|
@@ -11,6 +5,7 @@ import {
|
|
|
11
5
|
RESUME_COMMAND_DESCRIPTION,
|
|
12
6
|
VALIDATE_SESSION_COMMAND_DESCRIPTION,
|
|
13
7
|
} from '@robota-sdk/agent-framework';
|
|
8
|
+
|
|
14
9
|
import {
|
|
15
10
|
executeClearCommand,
|
|
16
11
|
executeCostCommand,
|
|
@@ -19,6 +14,13 @@ import {
|
|
|
19
14
|
executeValidateSessionCommand,
|
|
20
15
|
} from './session-command.js';
|
|
21
16
|
|
|
17
|
+
import type {
|
|
18
|
+
ICommand,
|
|
19
|
+
ICommandModule,
|
|
20
|
+
ICommandSource,
|
|
21
|
+
ISystemCommand,
|
|
22
|
+
} from '@robota-sdk/agent-framework';
|
|
23
|
+
|
|
22
24
|
export function createClearCommandEntry(): ICommand {
|
|
23
25
|
return {
|
|
24
26
|
name: 'clear',
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';
|
|
2
1
|
import {
|
|
3
2
|
RENAME_COMMAND_USAGE,
|
|
4
3
|
clearConversationHistory,
|
|
@@ -10,6 +9,8 @@ import {
|
|
|
10
9
|
validateCommandSessionReplayLog,
|
|
11
10
|
} from '@robota-sdk/agent-framework';
|
|
12
11
|
|
|
12
|
+
import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';
|
|
13
|
+
|
|
13
14
|
export const CLEAR_COMMAND_MESSAGE = 'Conversation cleared.';
|
|
14
15
|
|
|
15
16
|
export function executeClearCommand(context: ICommandHostContext, _args: string): ICommandResult {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import { SkillCommandSource } from '@robota-sdk/agent-framework';
|
|
2
|
+
|
|
3
|
+
import { executeSkillsCommand, SKILLS_COMMAND_DESCRIPTION } from './skills-command.js';
|
|
4
|
+
|
|
1
5
|
import type {
|
|
2
6
|
ICommand,
|
|
3
7
|
ICommandModule,
|
|
4
8
|
ICommandSource,
|
|
5
9
|
ISystemCommand,
|
|
6
10
|
} from '@robota-sdk/agent-framework';
|
|
7
|
-
import { SkillCommandSource } from '@robota-sdk/agent-framework';
|
|
8
|
-
import { executeSkillsCommand, SKILLS_COMMAND_DESCRIPTION } from './skills-command.js';
|
|
9
11
|
|
|
10
12
|
export interface ISkillsCommandModuleOptions {
|
|
11
|
-
readonly cwd
|
|
13
|
+
readonly cwd: string;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export function createSkillsCommandEntry(): ICommand {
|
|
@@ -48,11 +50,9 @@ export class SkillsCommandSource implements ICommandSource {
|
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
export function createSkillsCommandModule(
|
|
52
|
-
options: ISkillsCommandModuleOptions = {},
|
|
53
|
-
): ICommandModule {
|
|
53
|
+
export function createSkillsCommandModule(options: ISkillsCommandModuleOptions): ICommandModule {
|
|
54
54
|
const commandSources: ICommandSource[] = [new SkillsCommandSource()];
|
|
55
|
-
commandSources.push(new SkillCommandSource(options.cwd
|
|
55
|
+
commandSources.push(new SkillCommandSource(options.cwd));
|
|
56
56
|
|
|
57
57
|
return {
|
|
58
58
|
name: 'agent-command-skills',
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ICommand,
|
|
3
|
-
ICommandModule,
|
|
4
|
-
ICommandSource,
|
|
5
|
-
ISystemCommand,
|
|
6
|
-
} from '@robota-sdk/agent-framework';
|
|
7
1
|
import {
|
|
8
2
|
buildStatusLineCommandSubcommands,
|
|
9
3
|
STATUSLINE_COMMAND_ARGUMENT_HINT,
|
|
10
4
|
STATUSLINE_COMMAND_DESCRIPTION,
|
|
11
5
|
} from '@robota-sdk/agent-framework';
|
|
6
|
+
|
|
12
7
|
import { executeStatusLineCommand } from './statusline-command.js';
|
|
13
8
|
|
|
9
|
+
import type {
|
|
10
|
+
ICommand,
|
|
11
|
+
ICommandModule,
|
|
12
|
+
ICommandSource,
|
|
13
|
+
ISystemCommand,
|
|
14
|
+
} from '@robota-sdk/agent-framework';
|
|
15
|
+
|
|
14
16
|
export function createStatusLineCommandEntry(): ICommand {
|
|
15
17
|
return {
|
|
16
18
|
name: 'statusline',
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { DEFAULT_STATUS_LINE_COMMAND_SETTINGS } from '@robota-sdk/agent-framework';
|
|
2
|
+
|
|
1
3
|
import type {
|
|
2
4
|
ICommandHostContext,
|
|
3
5
|
ICommandResult,
|
|
4
6
|
TStatusLineCommandSettingsPatch,
|
|
5
7
|
} from '@robota-sdk/agent-framework';
|
|
6
|
-
import { DEFAULT_STATUS_LINE_COMMAND_SETTINGS } from '@robota-sdk/agent-framework';
|
|
7
8
|
|
|
8
9
|
interface IStatusLineCommandSuccessAction {
|
|
9
10
|
success: true;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
USER_LOCAL_COMMAND_ARGUMENT_HINT,
|
|
3
|
+
USER_LOCAL_COMMAND_DESCRIPTION,
|
|
4
|
+
executeUserLocalCommand,
|
|
5
|
+
} from './user-local-command.js';
|
|
6
|
+
|
|
1
7
|
import type {
|
|
2
8
|
ICommand,
|
|
3
9
|
ICommandModule,
|
|
4
10
|
ICommandSource,
|
|
5
11
|
ISystemCommand,
|
|
6
12
|
} from '@robota-sdk/agent-framework';
|
|
7
|
-
import {
|
|
8
|
-
USER_LOCAL_COMMAND_ARGUMENT_HINT,
|
|
9
|
-
USER_LOCAL_COMMAND_DESCRIPTION,
|
|
10
|
-
executeUserLocalCommand,
|
|
11
|
-
} from './user-local-command.js';
|
|
12
13
|
|
|
13
14
|
export function createUserLocalCommandEntry(): ICommand {
|
|
14
15
|
return {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';
|
|
2
1
|
import { inspectUserLocalStorage } from '@robota-sdk/agent-framework';
|
|
3
|
-
|
|
2
|
+
|
|
4
3
|
import { USER_LOCAL_COMMAND_USAGE } from './user-local-command-constants.js';
|
|
4
|
+
import { executeMemoryCommand } from './user-local-memory-command.js';
|
|
5
|
+
|
|
6
|
+
import type { ICommandHostContext, ICommandResult } from '@robota-sdk/agent-framework';
|
|
5
7
|
export {
|
|
6
8
|
USER_LOCAL_COMMAND_ARGUMENT_HINT,
|
|
7
9
|
USER_LOCAL_COMMAND_DESCRIPTION,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ICommandResult, TUserLocalMemoryCategory } from '@robota-sdk/agent-framework';
|
|
2
1
|
import {
|
|
3
2
|
deleteUserLocalMemoryItem,
|
|
4
3
|
disableUserLocalMemoryItem,
|
|
@@ -6,8 +5,11 @@ import {
|
|
|
6
5
|
listUserLocalMemoryItems,
|
|
7
6
|
setUserLocalMemoryItem,
|
|
8
7
|
} from '@robota-sdk/agent-framework';
|
|
8
|
+
|
|
9
9
|
import { USER_LOCAL_COMMAND_USAGE } from './user-local-command-constants.js';
|
|
10
10
|
|
|
11
|
+
import type { ICommandResult, TUserLocalMemoryCategory } from '@robota-sdk/agent-framework';
|
|
12
|
+
|
|
11
13
|
export interface IUserLocalMemoryCommandArgs {
|
|
12
14
|
readonly action?: string;
|
|
13
15
|
readonly positional: readonly string[];
|