@robota-sdk/agent-command 3.0.0-beta.79 → 3.0.0-beta.82
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 +11 -2
- package/dist/node/index.cjs +77 -38
- package/dist/node/index.d.cts +946 -0
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.d.ts +564 -51
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +77 -38
- package/dist/node/index.js.map +1 -1
- package/package.json +39 -16
- package/src/advisor/advisor-command-module.ts +47 -0
- package/src/advisor/advisor-command.test.ts +102 -0
- package/src/advisor/advisor-command.ts +55 -0
- package/src/advisor/advisor-cost-functional.test.ts +92 -0
- package/src/advisor/index.ts +6 -0
- package/src/agent/__tests__/agent-command.test.ts +39 -8
- package/src/agent/agent-command-module.ts +14 -7
- package/src/agent/agent-command-parser.ts +1 -1
- package/src/agent/agent-command.ts +3 -3
- package/src/background/__tests__/background-command-module.test.ts +59 -52
- package/src/background/background-command-module.ts +2 -1
- package/src/background/background-command.ts +3 -3
- package/src/command-module-utils.ts +33 -0
- package/src/compact/__tests__/compact-command-module.test.ts +31 -23
- package/src/compact/compact-command-module.ts +10 -1
- package/src/compact/compact-command.ts +6 -3
- package/src/context/__tests__/context-command-module.test.ts +214 -63
- package/src/context/auto-compact-format.ts +25 -0
- package/src/context/context-breakdown.ts +295 -0
- package/src/context/context-command-module.ts +45 -14
- package/src/context/context-command.ts +34 -257
- package/src/default/__tests__/__snapshots__/model-exposure.test.ts.snap +110 -0
- package/src/default/__tests__/default-command-modules.test.ts +59 -7
- package/src/default/__tests__/model-exposure.test.ts +241 -0
- package/src/default/__tests__/org-policy-forwarding.test.ts +98 -0
- package/src/default/default-command-modules.ts +130 -18
- package/src/default/index.ts +4 -1
- package/src/devices/__tests__/devices-command-module.test.ts +212 -0
- package/src/devices/devices-command-module.ts +224 -0
- package/src/devices/devices-command-port.ts +82 -0
- package/src/devices/index.ts +11 -0
- package/src/doctor/__tests__/doctor-command-module.test.ts +145 -0
- package/src/doctor/__tests__/doctor-display-vocabulary.test.ts +38 -0
- package/src/doctor/__tests__/doctor-fixture.ts +145 -0
- package/src/doctor/__tests__/doctor-redaction.test.ts +29 -0
- package/src/doctor/__tests__/doctor-runner.test.ts +464 -0
- package/src/doctor/doctor-command-module.ts +132 -0
- package/src/doctor/doctor-extensions-probe.ts +299 -0
- package/src/doctor/doctor-node-deps.ts +89 -0
- package/src/doctor/doctor-redaction.ts +99 -0
- package/src/doctor/doctor-render.ts +70 -0
- package/src/doctor/doctor-repair.ts +136 -0
- package/src/doctor/doctor-runner.ts +122 -0
- package/src/doctor/doctor-settings-probe.ts +239 -0
- package/src/doctor/doctor-storage-probe.ts +187 -0
- package/src/doctor/doctor-types.ts +109 -0
- package/src/doctor/index.ts +32 -0
- package/src/editor/__tests__/editor-command-functional.test.ts +49 -16
- package/src/editor/editor-command-module.ts +6 -5
- package/src/editor/editor-command.ts +10 -5
- package/src/effort/effort-command-module.ts +51 -0
- package/src/effort/effort-command.test.ts +140 -0
- package/src/effort/effort-command.ts +122 -0
- package/src/effort/index.ts +6 -0
- package/src/exit/__tests__/exit-command-module.test.ts +16 -9
- package/src/exit/exit-command-module.ts +2 -1
- package/src/exit/exit-command.ts +6 -6
- package/src/fork/__tests__/fork-command.test.ts +184 -0
- package/src/fork/fork-command-module.ts +61 -0
- package/src/fork/fork-command.ts +162 -0
- package/src/fork/index.ts +8 -0
- package/src/git/__tests__/fake-git-port.ts +28 -0
- package/src/git/__tests__/git-command-module.test.ts +103 -0
- package/src/git/__tests__/git-commit.test.ts +185 -0
- package/src/git/__tests__/git-diff.test.ts +125 -0
- package/src/git/__tests__/git-process.test.ts +221 -0
- package/src/git/__tests__/git-status.test.ts +117 -0
- package/src/git/git-command-module.ts +139 -0
- package/src/git/git-commit.ts +251 -0
- package/src/git/git-diff.ts +129 -0
- package/src/git/git-process.ts +169 -0
- package/src/git/git-status.ts +134 -0
- package/src/git/index.ts +17 -0
- package/src/goal/__tests__/goal-command.test.ts +9 -4
- package/src/goal/goal-command-module.ts +2 -1
- package/src/goal/goal-command.ts +6 -9
- package/src/handoff/__tests__/handoff-command-module.test.ts +24 -0
- package/src/handoff/__tests__/handoff-command.test.ts +218 -0
- package/src/handoff/handoff-command-module.ts +49 -0
- package/src/handoff/handoff-command.ts +187 -0
- package/src/handoff/index.ts +6 -0
- package/src/help/__tests__/help-command-module.test.ts +63 -40
- package/src/help/__tests__/help-command.test.ts +46 -37
- package/src/help/help-command-module.ts +2 -1
- package/src/help/help-command.ts +3 -3
- package/src/index.ts +124 -2
- package/src/keybindings/__tests__/keybindings-command-module.test.ts +57 -0
- package/src/keybindings/index.ts +6 -0
- package/src/keybindings/keybindings-command-module.ts +74 -0
- package/src/language/__tests__/language-command-module.test.ts +33 -28
- package/src/language/language-command-module.ts +2 -1
- package/src/language/language-command.ts +8 -6
- package/src/mcp-activation/__tests__/mcp-activation-command.test.ts +630 -0
- package/src/mcp-activation/__tests__/mcp-model-view.test.ts +211 -0
- package/src/mcp-activation/index.ts +12 -0
- package/src/mcp-activation/mcp-activation-command-module.ts +92 -0
- package/src/mcp-activation/mcp-activation-command.ts +448 -0
- package/src/mcp-activation/mcp-model-notice.ts +85 -0
- package/src/mcp-activation/mcp-model-status.ts +99 -0
- package/src/memory/__tests__/memory-command-module.test.ts +167 -74
- package/src/memory/memory-command-module.ts +18 -1
- package/src/memory/memory-command.ts +38 -38
- package/src/mode/__tests__/mode-command-module.test.ts +51 -38
- package/src/mode/mode-command-module.ts +2 -1
- package/src/mode/mode-command.ts +15 -7
- package/src/output-style/__tests__/output-style-command.test.ts +96 -0
- package/src/output-style/index.ts +6 -0
- package/src/output-style/output-style-command-module.ts +143 -0
- package/src/peers/__tests__/peers-command.test.ts +321 -0
- package/src/peers/index.ts +9 -0
- package/src/peers/peers-command-module.ts +49 -0
- package/src/peers/peers-command.ts +191 -0
- package/src/permissions/__tests__/permissions-command-module.test.ts +149 -37
- package/src/permissions/permissions-command-module.ts +2 -1
- package/src/permissions/permissions-command.ts +46 -4
- package/src/plan/__tests__/plan-command.test.ts +129 -0
- package/src/plan/index.ts +9 -0
- package/src/plan/plan-command-module.ts +49 -0
- package/src/plan/plan-command.ts +92 -0
- package/src/plugin/__tests__/plugin-command-module.test.ts +46 -40
- package/src/plugin/__tests__/plugin-host-boundary.test.ts +11 -0
- package/src/plugin/plugin-command-module.ts +3 -1
- package/src/plugin/plugin-command.ts +17 -16
- package/src/preset/__tests__/host-supplied-preset-registry.test.ts +98 -0
- package/src/preset/__tests__/preset-command-module.test.ts +102 -56
- package/src/preset/preset-command-module.ts +26 -8
- package/src/preset/preset-command.ts +85 -27
- package/src/provider/__tests__/org-policy.test.ts +4 -5
- package/src/provider/__tests__/provider-command-module.test.ts +11 -14
- package/src/provider/__tests__/provider-startup-host-settings.test.ts +16 -0
- package/src/provider/__tests__/scripted-interaction.ts +7 -5
- package/src/provider/provider-command-execution.ts +4 -4
- package/src/provider/provider-command-module.ts +2 -1
- package/src/provider/provider-command-profile-lifecycle.ts +4 -4
- package/src/provider/provider-command-profile-operations.ts +3 -3
- package/src/provider/provider-command-profile.ts +1 -1
- package/src/provider/provider-command-setup.ts +4 -4
- package/src/provider/provider-startup.ts +62 -35
- package/src/remote-control/__tests__/remote-control-command-module.test.ts +36 -0
- package/src/remote-control/__tests__/remote-control-command.test.ts +216 -0
- package/src/remote-control/index.ts +8 -0
- package/src/remote-control/remote-control-command-module.ts +61 -0
- package/src/remote-control/remote-control-command.ts +138 -0
- package/src/reset/__tests__/reset-command-module.test.ts +5 -5
- package/src/reset/reset-command-module.ts +2 -1
- package/src/reset/reset-command.ts +3 -4
- package/src/rewind/__tests__/rewind-command-module.test.ts +40 -0
- package/src/rewind/rewind-command-module.ts +2 -1
- package/src/rewind/rewind-command.ts +73 -6
- package/src/sandbox/__tests__/sandbox-command.test.ts +80 -0
- package/src/sandbox/index.ts +2 -0
- package/src/sandbox/sandbox-command-module.ts +56 -0
- package/src/sandbox/sandbox-command.ts +94 -0
- package/src/schedule/__tests__/loop-command-functional.test.ts +386 -0
- package/src/schedule/__tests__/loop-command.test.ts +360 -0
- package/src/schedule/__tests__/loop-jitter.test.ts +25 -0
- package/src/schedule/__tests__/monitor-model-permission-functional.test.ts +126 -0
- package/src/schedule/__tests__/schedule-command.test.ts +143 -3
- package/src/schedule/__tests__/schedule-redos.test.ts +81 -0
- package/src/schedule/index.ts +3 -0
- package/src/schedule/loop-command.ts +333 -0
- package/src/schedule/loop-jitter.ts +41 -0
- package/src/schedule/schedule-command-module.ts +92 -14
- package/src/schedule/schedule-command.ts +98 -9
- package/src/schedule/schedule-spec-parser.ts +5 -1
- package/src/session/__tests__/rename-host-persistence.test.ts +72 -0
- package/src/session/__tests__/session-command-module.test.ts +210 -45
- package/src/session/session-command-module.ts +68 -37
- package/src/session/session-command.ts +147 -80
- package/src/settings/settings-command-module.ts +3 -2
- package/src/shell/__tests__/resolve-shell-host.test.ts +11 -0
- package/src/shell/__tests__/shell-command-functional.test.ts +23 -1
- package/src/shell/resolve-shell.ts +2 -2
- package/src/shell/shell-command-module.ts +6 -5
- package/src/shell/shell-command.ts +9 -5
- package/src/skills/__tests__/skills-command-module.test.ts +69 -28
- package/src/skills/index.ts +1 -0
- package/src/skills/skills-command-module.ts +22 -5
- package/src/skills/skills-command.ts +14 -13
- package/src/statusline/__tests__/statusline-command-module.test.ts +5 -4
- package/src/statusline/statusline-command-module.ts +2 -1
- package/src/statusline/statusline-command.ts +4 -4
- package/src/theme/__tests__/theme-command.test.ts +204 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/theme-command-module.ts +211 -0
- package/src/user-local/__tests__/user-local-command.test.ts +145 -110
- package/src/user-local/user-local-command-constants.ts +1 -1
- package/src/user-local/user-local-command-module.ts +6 -5
- package/src/user-local/user-local-command.ts +12 -6
- package/src/user-local/user-local-memory-command.ts +17 -7
- package/src/plugins/default-plugin-command-adapter.ts +0 -164
- package/src/plugins/default-plugin-command-source-loader.ts +0 -31
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { USER_LOCAL_COMMAND_USAGE } from './user-local-command-constants.js';
|
|
10
10
|
|
|
11
11
|
import type { TUserLocalMemoryCategory } from '@robota-sdk/agent-framework';
|
|
12
|
-
import type { ICommandResult } from '@robota-sdk/agent-interface-
|
|
12
|
+
import type { ICommandResult } from '@robota-sdk/agent-interface-command';
|
|
13
13
|
|
|
14
14
|
export interface IUserLocalMemoryCommandArgs {
|
|
15
15
|
readonly action?: string;
|
|
@@ -39,9 +39,10 @@ function parseMemoryCategory(value: string | undefined): TUserLocalMemoryCategor
|
|
|
39
39
|
|
|
40
40
|
async function executeMemoryListCommand(
|
|
41
41
|
activeRepositoryRoot: string,
|
|
42
|
+
storageRoot: string,
|
|
42
43
|
parsed: IUserLocalMemoryCommandArgs,
|
|
43
44
|
): Promise<ICommandResult> {
|
|
44
|
-
const list = await listUserLocalMemoryItems({ activeRepositoryRoot });
|
|
45
|
+
const list = await listUserLocalMemoryItems({ activeRepositoryRoot, storageRoot });
|
|
45
46
|
return {
|
|
46
47
|
message:
|
|
47
48
|
parsed.format === 'json' ? JSON.stringify(list, null, 2) : formatMemoryListText(list.items),
|
|
@@ -52,11 +53,13 @@ async function executeMemoryListCommand(
|
|
|
52
53
|
|
|
53
54
|
async function executeMemorySetCommand(
|
|
54
55
|
activeRepositoryRoot: string,
|
|
56
|
+
storageRoot: string,
|
|
55
57
|
parsed: IUserLocalMemoryCommandArgs,
|
|
56
58
|
): Promise<ICommandResult> {
|
|
57
59
|
const [category, key, value] = parsed.positional;
|
|
58
60
|
const item = await setUserLocalMemoryItem({
|
|
59
61
|
activeRepositoryRoot,
|
|
62
|
+
storageRoot,
|
|
60
63
|
category: parseMemoryCategory(category),
|
|
61
64
|
key: key ?? '',
|
|
62
65
|
value: value ?? '',
|
|
@@ -72,11 +75,13 @@ async function executeMemorySetCommand(
|
|
|
72
75
|
|
|
73
76
|
async function executeMemoryInspectCommand(
|
|
74
77
|
activeRepositoryRoot: string,
|
|
78
|
+
storageRoot: string,
|
|
75
79
|
parsed: IUserLocalMemoryCommandArgs,
|
|
76
80
|
): Promise<ICommandResult> {
|
|
77
81
|
const [category, key] = parsed.positional;
|
|
78
82
|
const item = await inspectUserLocalMemoryItem({
|
|
79
83
|
activeRepositoryRoot,
|
|
84
|
+
storageRoot,
|
|
80
85
|
category: parseMemoryCategory(category),
|
|
81
86
|
key: key ?? '',
|
|
82
87
|
});
|
|
@@ -92,11 +97,13 @@ async function executeMemoryInspectCommand(
|
|
|
92
97
|
|
|
93
98
|
async function executeMemoryDisableCommand(
|
|
94
99
|
activeRepositoryRoot: string,
|
|
100
|
+
storageRoot: string,
|
|
95
101
|
parsed: IUserLocalMemoryCommandArgs,
|
|
96
102
|
): Promise<ICommandResult> {
|
|
97
103
|
const [category, key] = parsed.positional;
|
|
98
104
|
const item = await disableUserLocalMemoryItem({
|
|
99
105
|
activeRepositoryRoot,
|
|
106
|
+
storageRoot,
|
|
100
107
|
category: parseMemoryCategory(category),
|
|
101
108
|
key: key ?? '',
|
|
102
109
|
});
|
|
@@ -109,11 +116,13 @@ async function executeMemoryDisableCommand(
|
|
|
109
116
|
|
|
110
117
|
async function executeMemoryDeleteCommand(
|
|
111
118
|
activeRepositoryRoot: string,
|
|
119
|
+
storageRoot: string,
|
|
112
120
|
parsed: IUserLocalMemoryCommandArgs,
|
|
113
121
|
): Promise<ICommandResult> {
|
|
114
122
|
const [category, key] = parsed.positional;
|
|
115
123
|
const result = await deleteUserLocalMemoryItem({
|
|
116
124
|
activeRepositoryRoot,
|
|
125
|
+
storageRoot,
|
|
117
126
|
category: parseMemoryCategory(category),
|
|
118
127
|
key: key ?? '',
|
|
119
128
|
});
|
|
@@ -126,22 +135,23 @@ async function executeMemoryDeleteCommand(
|
|
|
126
135
|
|
|
127
136
|
export async function executeMemoryCommand(
|
|
128
137
|
cwd: string,
|
|
138
|
+
storageRoot: string,
|
|
129
139
|
parsed: IUserLocalMemoryCommandArgs,
|
|
130
140
|
): Promise<ICommandResult> {
|
|
131
141
|
if ((parsed.action ?? 'list') === 'list') {
|
|
132
|
-
return executeMemoryListCommand(cwd, parsed);
|
|
142
|
+
return executeMemoryListCommand(cwd, storageRoot, parsed);
|
|
133
143
|
}
|
|
134
144
|
if (parsed.action === 'set') {
|
|
135
|
-
return executeMemorySetCommand(cwd, parsed);
|
|
145
|
+
return executeMemorySetCommand(cwd, storageRoot, parsed);
|
|
136
146
|
}
|
|
137
147
|
if (parsed.action === 'inspect') {
|
|
138
|
-
return executeMemoryInspectCommand(cwd, parsed);
|
|
148
|
+
return executeMemoryInspectCommand(cwd, storageRoot, parsed);
|
|
139
149
|
}
|
|
140
150
|
if (parsed.action === 'disable') {
|
|
141
|
-
return executeMemoryDisableCommand(cwd, parsed);
|
|
151
|
+
return executeMemoryDisableCommand(cwd, storageRoot, parsed);
|
|
142
152
|
}
|
|
143
153
|
if (parsed.action === 'delete') {
|
|
144
|
-
return executeMemoryDeleteCommand(cwd, parsed);
|
|
154
|
+
return executeMemoryDeleteCommand(cwd, storageRoot, parsed);
|
|
145
155
|
}
|
|
146
156
|
return {
|
|
147
157
|
message: USER_LOCAL_COMMAND_USAGE,
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process';
|
|
2
|
-
import { homedir } from 'node:os';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
BundlePluginInstaller,
|
|
7
|
-
BundlePluginLoader,
|
|
8
|
-
MarketplaceClient,
|
|
9
|
-
PluginSettingsStore,
|
|
10
|
-
} from '@robota-sdk/agent-framework';
|
|
11
|
-
|
|
12
|
-
import type { IMarketplaceManifest } from '@robota-sdk/agent-framework';
|
|
13
|
-
import type {
|
|
14
|
-
ICommandAvailablePlugin,
|
|
15
|
-
ICommandInstalledPlugin,
|
|
16
|
-
ICommandMarketplaceSource,
|
|
17
|
-
ICommandPluginAdapter,
|
|
18
|
-
TPluginInstallScope,
|
|
19
|
-
} from '@robota-sdk/agent-interface-transport';
|
|
20
|
-
|
|
21
|
-
interface IPluginServices {
|
|
22
|
-
cwd: string;
|
|
23
|
-
marketplace: MarketplaceClient;
|
|
24
|
-
installer: BundlePluginInstaller;
|
|
25
|
-
loader: BundlePluginLoader;
|
|
26
|
-
settingsStore: PluginSettingsStore;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function createPluginServices(cwd: string): IPluginServices {
|
|
30
|
-
const home = homedir();
|
|
31
|
-
const pluginsDir = join(home, '.robota', 'plugins');
|
|
32
|
-
const userSettingsPath = join(home, '.robota', 'settings.json');
|
|
33
|
-
|
|
34
|
-
const exec = (command: string, options: { timeout: number; stdio?: string }): Buffer =>
|
|
35
|
-
execSync(command, {
|
|
36
|
-
timeout: options.timeout,
|
|
37
|
-
stdio: (options.stdio ?? 'pipe') as 'pipe' | 'inherit' | 'ignore',
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const settingsStore = new PluginSettingsStore(userSettingsPath);
|
|
41
|
-
const marketplace = new MarketplaceClient({ pluginsDir, exec });
|
|
42
|
-
const installer = new BundlePluginInstaller({
|
|
43
|
-
pluginsDir,
|
|
44
|
-
settingsStore,
|
|
45
|
-
marketplaceClient: marketplace,
|
|
46
|
-
exec,
|
|
47
|
-
});
|
|
48
|
-
const loader = new BundlePluginLoader(pluginsDir);
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
cwd,
|
|
52
|
-
marketplace,
|
|
53
|
-
installer,
|
|
54
|
-
loader,
|
|
55
|
-
settingsStore,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function listInstalledPlugins(
|
|
60
|
-
services: IPluginServices,
|
|
61
|
-
): Promise<readonly ICommandInstalledPlugin[]> {
|
|
62
|
-
const plugins = await services.loader.loadAll();
|
|
63
|
-
const enabledMap = services.settingsStore.getEnabledPlugins();
|
|
64
|
-
return plugins.map((plugin) => {
|
|
65
|
-
const parts = plugin.pluginDir.split('/');
|
|
66
|
-
const cacheIdx = parts.indexOf('cache');
|
|
67
|
-
const marketplaceName = cacheIdx >= 0 ? (parts[cacheIdx + 1] ?? '') : '';
|
|
68
|
-
const fullId = marketplaceName
|
|
69
|
-
? `${plugin.manifest.name}@${marketplaceName}`
|
|
70
|
-
: plugin.manifest.name;
|
|
71
|
-
return {
|
|
72
|
-
name: fullId,
|
|
73
|
-
description: plugin.manifest.description,
|
|
74
|
-
enabled: enabledMap[fullId] !== false && enabledMap[plugin.manifest.name] !== false,
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async function listAvailablePlugins(
|
|
80
|
-
services: IPluginServices,
|
|
81
|
-
marketplaceName: string,
|
|
82
|
-
): Promise<readonly ICommandAvailablePlugin[]> {
|
|
83
|
-
let manifest: IMarketplaceManifest;
|
|
84
|
-
try {
|
|
85
|
-
manifest = services.marketplace.fetchManifest(marketplaceName);
|
|
86
|
-
} catch {
|
|
87
|
-
// allow-fallback: marketplace manifest fetch failure is non-fatal — return empty list
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
const installed = services.installer.getInstalledPlugins();
|
|
91
|
-
const installedNames = new Set(Object.values(installed).map((record) => record.pluginName));
|
|
92
|
-
return manifest.plugins.map((plugin) => ({
|
|
93
|
-
name: plugin.name,
|
|
94
|
-
description: plugin.description,
|
|
95
|
-
installed: installedNames.has(plugin.name),
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function installPlugin(
|
|
100
|
-
services: IPluginServices,
|
|
101
|
-
pluginId: string,
|
|
102
|
-
scope?: TPluginInstallScope,
|
|
103
|
-
): Promise<void> {
|
|
104
|
-
const [name, marketplaceName] = pluginId.split('@');
|
|
105
|
-
if (!name || !marketplaceName) {
|
|
106
|
-
throw new Error('Plugin ID must be in format: name@marketplace');
|
|
107
|
-
}
|
|
108
|
-
if (scope === 'project') {
|
|
109
|
-
const projectPluginsDir = join(services.cwd, '.robota', 'plugins');
|
|
110
|
-
const projectExec = (command: string, options: { timeout: number; stdio?: string }): Buffer =>
|
|
111
|
-
execSync(command, {
|
|
112
|
-
timeout: options.timeout,
|
|
113
|
-
stdio: (options.stdio ?? 'pipe') as 'pipe' | 'inherit' | 'ignore',
|
|
114
|
-
});
|
|
115
|
-
const projectInstaller = new BundlePluginInstaller({
|
|
116
|
-
pluginsDir: projectPluginsDir,
|
|
117
|
-
settingsStore: services.settingsStore,
|
|
118
|
-
marketplaceClient: services.marketplace,
|
|
119
|
-
exec: projectExec,
|
|
120
|
-
});
|
|
121
|
-
await projectInstaller.install(name, marketplaceName);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
await services.installer.install(name, marketplaceName);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async function removeMarketplace(services: IPluginServices, name: string): Promise<void> {
|
|
128
|
-
const installedFromMarketplace = services.installer.getPluginsByMarketplace(name);
|
|
129
|
-
for (const record of installedFromMarketplace) {
|
|
130
|
-
await services.installer.uninstall(`${record.pluginName}@${record.marketplace}`);
|
|
131
|
-
}
|
|
132
|
-
services.marketplace.removeMarketplace(name);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function listMarketplaces(services: IPluginServices): readonly ICommandMarketplaceSource[] {
|
|
136
|
-
return services.marketplace.listMarketplaces().map((marketplaceEntry) => ({
|
|
137
|
-
name: marketplaceEntry.name,
|
|
138
|
-
type: marketplaceEntry.source.type,
|
|
139
|
-
}));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function createDefaultPluginCommandAdapter(cwd: string): ICommandPluginAdapter {
|
|
143
|
-
const services = createPluginServices(cwd);
|
|
144
|
-
return {
|
|
145
|
-
listInstalled: () => listInstalledPlugins(services),
|
|
146
|
-
listAvailablePlugins: (marketplaceName) => listAvailablePlugins(services, marketplaceName),
|
|
147
|
-
install: (pluginId, scope) => installPlugin(services, pluginId, scope),
|
|
148
|
-
uninstall: async (pluginId) => services.installer.uninstall(pluginId),
|
|
149
|
-
enable: async (pluginId) => services.installer.enable(pluginId),
|
|
150
|
-
disable: async (pluginId) => services.installer.disable(pluginId),
|
|
151
|
-
marketplaceAdd: async (source) => {
|
|
152
|
-
if (source.includes('/') && !source.includes(':')) {
|
|
153
|
-
return services.marketplace.addMarketplace({ type: 'github', repo: source });
|
|
154
|
-
}
|
|
155
|
-
return services.marketplace.addMarketplace({ type: 'git', url: source });
|
|
156
|
-
},
|
|
157
|
-
marketplaceRemove: (name) => removeMarketplace(services, name),
|
|
158
|
-
marketplaceUpdate: async (name) => services.marketplace.updateMarketplace(name),
|
|
159
|
-
marketplaceList: async () => listMarketplaces(services),
|
|
160
|
-
reloadPlugins: async () => ({
|
|
161
|
-
loadedPluginCount: (await services.loader.loadAll()).length,
|
|
162
|
-
}),
|
|
163
|
-
};
|
|
164
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { homedir } from 'node:os';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
import { BundlePluginLoader, PluginCommandSource } from '@robota-sdk/agent-framework';
|
|
5
|
-
|
|
6
|
-
import type { CommandRegistry } from '@robota-sdk/agent-framework';
|
|
7
|
-
|
|
8
|
-
const PLUGIN_SOURCE_NAME = 'plugin';
|
|
9
|
-
|
|
10
|
-
function getHomeDir(): string {
|
|
11
|
-
return process.env.HOME ?? homedir();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function reloadPluginCommandSource(registry: CommandRegistry): number {
|
|
15
|
-
const pluginsDir = join(getHomeDir(), '.robota', 'plugins');
|
|
16
|
-
const loader = new BundlePluginLoader(pluginsDir);
|
|
17
|
-
try {
|
|
18
|
-
// allow-fallback: plugin load failure is non-fatal — clear source and return empty
|
|
19
|
-
const plugins = loader.loadPluginsSync();
|
|
20
|
-
if (plugins.length === 0) {
|
|
21
|
-
registry.replaceSource(PLUGIN_SOURCE_NAME);
|
|
22
|
-
return 0;
|
|
23
|
-
}
|
|
24
|
-
registry.replaceSource(PLUGIN_SOURCE_NAME, new PluginCommandSource(plugins));
|
|
25
|
-
return plugins.length;
|
|
26
|
-
} catch {
|
|
27
|
-
// allow-fallback: plugin load failure is non-fatal — clear source and return empty
|
|
28
|
-
registry.replaceSource(PLUGIN_SOURCE_NAME);
|
|
29
|
-
return 0;
|
|
30
|
-
}
|
|
31
|
-
}
|