@solidactions/cli 3.18.0 → 3.20.0
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 +34 -4
- package/dist/command-manifest.json +254 -1
- package/dist/commands/database-export.js +512 -0
- package/dist/commands/role-pull.js +215 -0
- package/dist/commands/role-push.js +226 -44
- package/dist/commands/skill-publish.js +12 -4
- package/dist/commands/skill-pull.js +144 -66
- package/dist/commands/skill-push.js +89 -24
- package/dist/index.js +40 -0
- package/dist/utils/atomic-dir.js +111 -0
- package/dist/utils/crew.js +31 -0
- package/dist/utils/mcp.js +129 -19
- package/dist/utils/mutating-commands.js +4 -0
- package/dist/utils/skill-snapshot.js +15 -6
- package/package.json +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.writeDirAtomic = writeDirAtomic;
|
|
37
|
+
exports.assertReplaceableDir = assertReplaceableDir;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
/**
|
|
41
|
+
* Replace `dest` with a folder holding exactly `files` (relative path -> content),
|
|
42
|
+
* as a unit: the result is either the old complete folder or the new complete one,
|
|
43
|
+
* never a mix, and no stale files survive. Files go into a sibling temp dir first,
|
|
44
|
+
* then the temp dir is swapped in by rename. If any step fails the temp dir is removed and
|
|
45
|
+
* the old folder (if any) is left in place. `opts.stamp` fixes the temp/old name suffix
|
|
46
|
+
* (default pid-time); it exists so tests can force a rename failure.
|
|
47
|
+
*/
|
|
48
|
+
function writeDirAtomic(dest, files, opts = {}) {
|
|
49
|
+
dest = path.resolve(dest); // a trailing slash would otherwise put the temp dir inside dest
|
|
50
|
+
for (const rel of Object.keys(files)) {
|
|
51
|
+
if (path.isAbsolute(rel) || rel.split(/[\\/]/).includes('..'))
|
|
52
|
+
throw new Error(`unsafe path: ${rel}`);
|
|
53
|
+
}
|
|
54
|
+
const stamp = opts.stamp ?? `${process.pid}-${Date.now()}`;
|
|
55
|
+
const tmp = `${dest}.tmp-${stamp}`;
|
|
56
|
+
fs.mkdirSync(tmp, { recursive: true });
|
|
57
|
+
try {
|
|
58
|
+
for (const [rel, content] of Object.entries(files)) {
|
|
59
|
+
const target = path.join(tmp, rel);
|
|
60
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
61
|
+
fs.writeFileSync(target, content);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
66
|
+
throw e;
|
|
67
|
+
}
|
|
68
|
+
const old = `${dest}.old-${stamp}`;
|
|
69
|
+
const hadOld = fs.existsSync(dest);
|
|
70
|
+
let movedAside = false;
|
|
71
|
+
try {
|
|
72
|
+
if (hadOld) {
|
|
73
|
+
fs.renameSync(dest, old);
|
|
74
|
+
movedAside = true;
|
|
75
|
+
}
|
|
76
|
+
fs.renameSync(tmp, dest);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
// Put the old folder back if it was already moved aside, and never leave the staged dir behind.
|
|
80
|
+
if (movedAside)
|
|
81
|
+
fs.renameSync(old, dest);
|
|
82
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
83
|
+
throw e;
|
|
84
|
+
}
|
|
85
|
+
if (hadOld)
|
|
86
|
+
fs.rmSync(old, { recursive: true, force: true });
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Guard for callers that replace a whole folder with writeDirAtomic. Throws unless
|
|
90
|
+
* `dest` is safe to swap out: it must not be the current directory or one of its
|
|
91
|
+
* parents, must not be a file, and if it already holds anything it must contain
|
|
92
|
+
* `marker` directly (proof that a previous pull created it). A missing or empty
|
|
93
|
+
* dest is fine. `cwd` exists so tests can avoid process.chdir; `kind` names the noun in the refusal.
|
|
94
|
+
*/
|
|
95
|
+
function assertReplaceableDir(dest, marker, cwd = process.cwd(), kind = 'skill') {
|
|
96
|
+
const resolved = path.resolve(dest);
|
|
97
|
+
const exists = fs.existsSync(resolved);
|
|
98
|
+
const real = exists ? fs.realpathSync(resolved) : resolved;
|
|
99
|
+
const rel = path.relative(real, fs.realpathSync(cwd));
|
|
100
|
+
if (rel === '' || (rel !== '..' && !rel.startsWith('..' + path.sep) && !path.isAbsolute(rel))) {
|
|
101
|
+
throw new Error(`refusing to replace ${dest}: it is the current directory or one of its parents`);
|
|
102
|
+
}
|
|
103
|
+
if (!exists)
|
|
104
|
+
return;
|
|
105
|
+
if (!fs.statSync(resolved).isDirectory()) {
|
|
106
|
+
throw new Error(`refusing to replace ${dest}: it exists and is not a directory`);
|
|
107
|
+
}
|
|
108
|
+
if (fs.readdirSync(resolved).length > 0 && !fs.existsSync(path.join(resolved, marker))) {
|
|
109
|
+
throw new Error(`refusing to replace ${dest}: it exists and is not a pulled ${kind} (no ${marker}); remove it or choose another destination`);
|
|
110
|
+
}
|
|
111
|
+
}
|
package/dist/utils/crew.js
CHANGED
|
@@ -12,6 +12,8 @@ exports.fetchCrews = fetchCrews;
|
|
|
12
12
|
exports.resolveCrewId = resolveCrewId;
|
|
13
13
|
exports.resolveRoleCrewPath = resolveRoleCrewPath;
|
|
14
14
|
exports.crewIdForPath = crewIdForPath;
|
|
15
|
+
exports.crewErrorHint = crewErrorHint;
|
|
16
|
+
exports.normalizeCrewPath = normalizeCrewPath;
|
|
15
17
|
const axios_1 = __importDefault(require("axios"));
|
|
16
18
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
19
|
const api_1 = require("./api");
|
|
@@ -118,3 +120,32 @@ async function crewIdForPath(config, crewPath) {
|
|
|
118
120
|
console.error(chalk_1.default.red(`Could not resolve crew "${crewPath}" to a crew id (matched ${byPath.length} by path, ${byName.length} by name).`));
|
|
119
121
|
process.exit(1);
|
|
120
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Map crew-scoping server error codes to an actionable CLI message, or null when
|
|
125
|
+
* the code is not crew-related. `crew_required`: a role create with no crew.
|
|
126
|
+
* `ambiguous_role`: the role name exists in several crews. The live server answers a
|
|
127
|
+
* create that omits in_crew entirely with `invalid_parameter` ("Required for create:
|
|
128
|
+
* in_crew") and reserves `crew_required` for an empty/null in_crew, so both map to
|
|
129
|
+
* the same hint.
|
|
130
|
+
*/
|
|
131
|
+
function crewErrorHint(code, roleName, message) {
|
|
132
|
+
const missingInCrew = code === 'invalid_parameter' && typeof message === 'string' && /required for create:\s*in_crew/i.test(message);
|
|
133
|
+
if (code === 'crew_required' || missingInCrew) {
|
|
134
|
+
return 'this role must live in a crew: pass --in-crew CREW';
|
|
135
|
+
}
|
|
136
|
+
if (code === 'ambiguous_role') {
|
|
137
|
+
return `role${roleName ? ` '${roleName}'` : ''} exists in multiple crews: pass --in-crew CREW to choose one`;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Canonical spelling of a crew path for comparison: split on '/', trim each segment, drop empty
|
|
143
|
+
* segments, rejoin. Mirrors how the server resolves crew paths (it trims segments and ignores
|
|
144
|
+
* empty ones), so 'acme/', ' acme ' and 'acme' are the same crew. Blank or non-string => null.
|
|
145
|
+
*/
|
|
146
|
+
function normalizeCrewPath(value) {
|
|
147
|
+
if (typeof value !== 'string')
|
|
148
|
+
return null;
|
|
149
|
+
const path = value.split('/').map((seg) => seg.trim()).filter((seg) => seg !== '').join('/');
|
|
150
|
+
return path === '' ? null : path;
|
|
151
|
+
}
|
package/dist/utils/mcp.js
CHANGED
|
@@ -40,6 +40,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
40
40
|
};
|
|
41
41
|
})();
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.McpRpcError = void 0;
|
|
44
|
+
exports.retryAfterSeconds = retryAfterSeconds;
|
|
45
|
+
exports.resolveCrewsCall = resolveCrewsCall;
|
|
43
46
|
exports.callCrewsTool = callCrewsTool;
|
|
44
47
|
exports.callDocsTool = callDocsTool;
|
|
45
48
|
exports.callCrewsToolContent = callCrewsToolContent;
|
|
@@ -50,6 +53,42 @@ const api_1 = require("./api");
|
|
|
50
53
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
51
54
|
const pkg = require('../../package.json');
|
|
52
55
|
const CLI_VERSION = pkg.version;
|
|
56
|
+
/** A JSON-RPC `error` member in the server's response (protocol-level failure, not a tool isError). */
|
|
57
|
+
class McpRpcError extends Error {
|
|
58
|
+
code;
|
|
59
|
+
constructor(code, message) {
|
|
60
|
+
super(message);
|
|
61
|
+
this.code = code;
|
|
62
|
+
this.name = 'McpRpcError';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.McpRpcError = McpRpcError;
|
|
66
|
+
/** Total HTTP attempts for one call when the server answers 429 (the first try plus 2 retries). */
|
|
67
|
+
const RATE_LIMIT_MAX_ATTEMPTS = 3;
|
|
68
|
+
/** Wait used when a 429 carries no usable Retry-After. */
|
|
69
|
+
const RATE_LIMIT_DEFAULT_WAIT_SEC = 5;
|
|
70
|
+
/** No single wait exceeds this, whatever the server asks for. */
|
|
71
|
+
const RATE_LIMIT_MAX_WAIT_SEC = 60;
|
|
72
|
+
/** Seconds to wait for a Retry-After value (integer seconds or HTTP-date, RFC 9110); default when missing/invalid; capped. */
|
|
73
|
+
function retryAfterSeconds(header) {
|
|
74
|
+
const value = (Array.isArray(header) ? header[0] : header)?.trim();
|
|
75
|
+
let sec = RATE_LIMIT_DEFAULT_WAIT_SEC;
|
|
76
|
+
if (value) {
|
|
77
|
+
if (/^\d+$/.test(value)) {
|
|
78
|
+
sec = parseInt(value, 10);
|
|
79
|
+
}
|
|
80
|
+
else if (/^[+-]?\d+(\.\d+)?$/.test(value)) {
|
|
81
|
+
// Signed or fractional numbers are not valid Retry-After; wait at least 1s (only a literal "0" waits 0).
|
|
82
|
+
sec = Math.max(1, Math.ceil(Number(value)));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const at = Date.parse(value);
|
|
86
|
+
if (!Number.isNaN(at))
|
|
87
|
+
sec = Math.max(1, Math.ceil((at - Date.now()) / 1000));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return Math.min(sec, RATE_LIMIT_MAX_WAIT_SEC);
|
|
91
|
+
}
|
|
53
92
|
/** Internal: POST one tools/call and return the raw result envelope (isError + content blocks). */
|
|
54
93
|
async function postMcpTool(config, endpointPath, toolName, args) {
|
|
55
94
|
const baseHeaders = (0, api_1.getApiHeaders)(config, 'application/json');
|
|
@@ -66,7 +105,7 @@ async function postMcpTool(config, endpointPath, toolName, args) {
|
|
|
66
105
|
const parsed = new url_1.URL(`${config.host}${endpointPath}`);
|
|
67
106
|
const isHttps = parsed.protocol === 'https:';
|
|
68
107
|
const transport = isHttps ? https : http;
|
|
69
|
-
const
|
|
108
|
+
const attempt = () => new Promise((resolve, reject) => {
|
|
70
109
|
const options = {
|
|
71
110
|
hostname: parsed.hostname,
|
|
72
111
|
port: parsed.port || (isHttps ? 443 : 80),
|
|
@@ -75,24 +114,38 @@ async function postMcpTool(config, endpointPath, toolName, args) {
|
|
|
75
114
|
headers: { ...headers, 'Content-Length': Buffer.byteLength(body) },
|
|
76
115
|
};
|
|
77
116
|
const req = transport.request(options, (res) => {
|
|
78
|
-
|
|
79
|
-
|
|
117
|
+
// Collect bytes and decode once: appending Buffer chunks to a string decodes
|
|
118
|
+
// each chunk separately and corrupts multibyte UTF-8 split across chunks.
|
|
119
|
+
const chunks = [];
|
|
120
|
+
res.on('data', (chunk) => { chunks.push(chunk); });
|
|
80
121
|
res.on('end', () => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
resolve(raw);
|
|
89
|
-
}
|
|
122
|
+
resolve({
|
|
123
|
+
status: res.statusCode ?? 0,
|
|
124
|
+
retryAfter: res.headers['retry-after'],
|
|
125
|
+
raw: Buffer.concat(chunks).toString('utf8'),
|
|
126
|
+
});
|
|
90
127
|
});
|
|
91
128
|
});
|
|
92
129
|
req.on('error', reject);
|
|
93
130
|
req.write(body);
|
|
94
131
|
req.end();
|
|
95
132
|
});
|
|
133
|
+
let last;
|
|
134
|
+
for (let n = 1;; n++) {
|
|
135
|
+
last = await attempt();
|
|
136
|
+
if (last.status !== 429 || n >= RATE_LIMIT_MAX_ATTEMPTS)
|
|
137
|
+
break;
|
|
138
|
+
const waitSec = retryAfterSeconds(last.retryAfter);
|
|
139
|
+
process.stderr.write(`solidactions: rate limited by server (429); retrying in ${waitSec}s (attempt ${n + 1}/${RATE_LIMIT_MAX_ATTEMPTS})\n`);
|
|
140
|
+
await new Promise((resolve) => setTimeout(resolve, waitSec * 1000));
|
|
141
|
+
}
|
|
142
|
+
if (last.status === 404) {
|
|
143
|
+
throw new Error(`MCP request failed: ${parsed.host} has no ${endpointPath} endpoint — the server may be older or newer than this CLI (${CLI_VERSION}). Raw: HTTP 404 ${last.raw}`);
|
|
144
|
+
}
|
|
145
|
+
if (last.status >= 400) {
|
|
146
|
+
throw new Error(`MCP request failed with HTTP ${last.status}: ${last.raw}`);
|
|
147
|
+
}
|
|
148
|
+
const responseData = last.raw;
|
|
96
149
|
let parsed2;
|
|
97
150
|
try {
|
|
98
151
|
parsed2 = JSON.parse(responseData);
|
|
@@ -100,6 +153,9 @@ async function postMcpTool(config, endpointPath, toolName, args) {
|
|
|
100
153
|
catch {
|
|
101
154
|
throw new Error(`MCP server returned non-JSON response: ${responseData}`);
|
|
102
155
|
}
|
|
156
|
+
if (parsed2?.error) {
|
|
157
|
+
throw new McpRpcError(parsed2.error.code ?? -1, `MCP ${toolName}: ${parsed2.error.message ?? JSON.stringify(parsed2.error)}`);
|
|
158
|
+
}
|
|
103
159
|
const result = parsed2?.result;
|
|
104
160
|
return { isError: result?.isError === true, content: result?.content ?? [] };
|
|
105
161
|
}
|
|
@@ -110,7 +166,10 @@ async function postMcpTool(config, endpointPath, toolName, args) {
|
|
|
110
166
|
*/
|
|
111
167
|
async function callMcpTool(config, endpointPath, toolName, args) {
|
|
112
168
|
const raw = await postMcpTool(config, endpointPath, toolName, args);
|
|
113
|
-
|
|
169
|
+
if (!raw.content || raw.content.length === 0) {
|
|
170
|
+
return { ok: false, data: { code: 'empty_result', message: `MCP ${toolName} returned no content` } };
|
|
171
|
+
}
|
|
172
|
+
const textContent = raw.content[0]?.text ?? '{}';
|
|
114
173
|
let toolData;
|
|
115
174
|
try {
|
|
116
175
|
toolData = JSON.parse(textContent);
|
|
@@ -121,14 +180,64 @@ async function callMcpTool(config, endpointPath, toolName, args) {
|
|
|
121
180
|
return { ok: !raw.isError, data: toolData };
|
|
122
181
|
}
|
|
123
182
|
const UNIFIED_MCP_PATH = '/mcp';
|
|
124
|
-
//
|
|
125
|
-
|
|
183
|
+
// Current catalog (solidactions-app ToolCatalog.php): the public tool depends on the action.
|
|
184
|
+
// Only actions the CLI actually sends are routed; anything else throws in resolveCrewsCall.
|
|
185
|
+
const CREWS_ROUTES = {
|
|
186
|
+
skills: {
|
|
187
|
+
list: { tool: 'crews_skills_read' },
|
|
188
|
+
read: { tool: 'crews_skills_read' },
|
|
189
|
+
read_reference_file: { tool: 'crews_skills_read' },
|
|
190
|
+
create: { tool: 'crews_skills_manage' },
|
|
191
|
+
edit: { tool: 'crews_skills_manage' },
|
|
192
|
+
delete: { tool: 'crews_delete', action: 'delete_skill' },
|
|
193
|
+
sandbox_exec: { tool: 'crews_sandbox', action: 'skill_exec', rename: { environment: 'skill_exec_environment' } },
|
|
194
|
+
},
|
|
195
|
+
roles: {
|
|
196
|
+
list: { tool: 'crews_roles_read' },
|
|
197
|
+
read: { tool: 'crews_roles_read' },
|
|
198
|
+
list_skills: { tool: 'crews_roles_read' },
|
|
199
|
+
read_skill: { tool: 'crews_roles_read' },
|
|
200
|
+
read_reference_file: { tool: 'crews_roles_read' },
|
|
201
|
+
create: { tool: 'crews_roles_manage' },
|
|
202
|
+
edit: { tool: 'crews_roles_manage' },
|
|
203
|
+
create_skill: { tool: 'crews_roles_manage' },
|
|
204
|
+
edit_skill: { tool: 'crews_roles_manage' },
|
|
205
|
+
sandbox_exec: { tool: 'crews_sandbox', action: 'role_exec', rename: { environment: 'role_exec_environment' } },
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Map a CLI-level crews call (group + action) to the public MCP tool, action and
|
|
210
|
+
* param names of the current catalog. Throws for an action the CLI has no route for.
|
|
211
|
+
*/
|
|
212
|
+
function resolveCrewsCall(group, args) {
|
|
213
|
+
const action = String(args.action ?? '');
|
|
214
|
+
const route = CREWS_ROUTES[group][action];
|
|
215
|
+
if (!route)
|
|
216
|
+
throw new Error(`unsupported crews action: ${group}.${action}`);
|
|
217
|
+
const out = {};
|
|
218
|
+
for (const [k, v] of Object.entries(args)) {
|
|
219
|
+
if (v === undefined)
|
|
220
|
+
continue;
|
|
221
|
+
out[route.rename?.[k] ?? k] = v;
|
|
222
|
+
}
|
|
223
|
+
if (route.action)
|
|
224
|
+
out.action = route.action;
|
|
225
|
+
return { tool: route.tool, args: out };
|
|
226
|
+
}
|
|
227
|
+
function isCrewsGroup(name) {
|
|
228
|
+
return name === 'skills' || name === 'roles';
|
|
229
|
+
}
|
|
126
230
|
/**
|
|
127
|
-
* Call a
|
|
128
|
-
*
|
|
231
|
+
* Call a crews MCP tool on the unified /mcp endpoint. 'skills' / 'roles' are CLI
|
|
232
|
+
* groups resolved per action via resolveCrewsCall; any other name (e.g.
|
|
233
|
+
* 'crews_history_manage') is passed through unchanged.
|
|
129
234
|
*/
|
|
130
235
|
async function callCrewsTool(config, toolName, args) {
|
|
131
|
-
|
|
236
|
+
if (isCrewsGroup(toolName)) {
|
|
237
|
+
const r = resolveCrewsCall(toolName, args);
|
|
238
|
+
return callMcpTool(config, UNIFIED_MCP_PATH, r.tool, r.args);
|
|
239
|
+
}
|
|
240
|
+
return callMcpTool(config, UNIFIED_MCP_PATH, toolName, args);
|
|
132
241
|
}
|
|
133
242
|
/**
|
|
134
243
|
* Call a single MCP tool on the unified /mcp endpoint.
|
|
@@ -143,6 +252,7 @@ async function callDocsTool(config, toolName, args) {
|
|
|
143
252
|
* (callCrewsTool) would throw on those.
|
|
144
253
|
*/
|
|
145
254
|
async function callCrewsToolContent(config, toolName, args) {
|
|
146
|
-
const
|
|
255
|
+
const r = isCrewsGroup(toolName) ? resolveCrewsCall(toolName, args) : { tool: toolName, args };
|
|
256
|
+
const raw = await postMcpTool(config, UNIFIED_MCP_PATH, r.tool, r.args);
|
|
147
257
|
return { ok: !raw.isError, content: raw.content };
|
|
148
258
|
}
|
|
@@ -50,6 +50,9 @@ exports.MUTATING_COMMANDS = new Set([
|
|
|
50
50
|
'database import',
|
|
51
51
|
'database push',
|
|
52
52
|
'database ingest',
|
|
53
|
+
// Export creates durable operation rows and temporary R2 objects and may
|
|
54
|
+
// wake billed compute, even though authorization is read-capability based.
|
|
55
|
+
'database export',
|
|
53
56
|
'database drop-table',
|
|
54
57
|
// `optimize` dispatches a real server-side operation that rewrites the
|
|
55
58
|
// database's stored files (`StartOptimizeOperation` — a job, not just a
|
|
@@ -149,6 +152,7 @@ exports.READONLY_COMMANDS = new Set([
|
|
|
149
152
|
'ai init',
|
|
150
153
|
'ai examples',
|
|
151
154
|
'skill pull',
|
|
155
|
+
'role pull',
|
|
152
156
|
'skill list',
|
|
153
157
|
'skill view',
|
|
154
158
|
// Fetches crew variables (read) and runs the working copy locally, like
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Composes two existing MCP actions: crews_skills.read resolves a skill name to
|
|
6
6
|
* its doc_id and reports whether the current revision is unpublished, and
|
|
7
|
-
*
|
|
7
|
+
* crews_history_manage.take_doc_snapshot promotes that revision to all agents.
|
|
8
8
|
*/
|
|
9
9
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -15,11 +15,11 @@ exports.publishSkillByName = publishSkillByName;
|
|
|
15
15
|
exports.emitPublishOutcome = emitPublishOutcome;
|
|
16
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
17
|
const mcp_1 = require("./mcp");
|
|
18
|
-
/** Snapshot a skill by its doc_id (
|
|
18
|
+
/** Snapshot a skill by its doc_id (crews_history_manage.take_doc_snapshot). */
|
|
19
19
|
async function publishSkillByDocId(config, docId) {
|
|
20
20
|
let result;
|
|
21
21
|
try {
|
|
22
|
-
result = await (0, mcp_1.callCrewsTool)(config, '
|
|
22
|
+
result = await (0, mcp_1.callCrewsTool)(config, 'crews_history_manage', { action: 'take_doc_snapshot', doc_id: docId });
|
|
23
23
|
}
|
|
24
24
|
catch (e) {
|
|
25
25
|
return { status: 'error', code: 'mcp_request_failed', message: e.message };
|
|
@@ -35,10 +35,19 @@ async function publishSkillByDocId(config, docId) {
|
|
|
35
35
|
* read response, NOT the take_snapshot error code (the server maps both
|
|
36
36
|
* "nothing to snapshot" and "live-mode" to the same not_snapshotable code).
|
|
37
37
|
*/
|
|
38
|
-
async function publishSkillByName(config, name) {
|
|
38
|
+
async function publishSkillByName(config, name, opts = {}) {
|
|
39
39
|
let read;
|
|
40
40
|
try {
|
|
41
|
-
|
|
41
|
+
if (opts.role) {
|
|
42
|
+
// Role-scoped skill: addressed by role + name (in_crew disambiguates the role).
|
|
43
|
+
const args = { action: 'read_skill', role: opts.role, name };
|
|
44
|
+
if (opts.inCrew)
|
|
45
|
+
args.in_crew = opts.inCrew;
|
|
46
|
+
read = await (0, mcp_1.callCrewsTool)(config, 'roles', args);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
read = await (0, mcp_1.callCrewsTool)(config, 'skills', { action: 'read', identifier: name });
|
|
50
|
+
}
|
|
42
51
|
}
|
|
43
52
|
catch (e) {
|
|
44
53
|
return { status: 'error', code: 'mcp_request_failed', message: e.message };
|
|
@@ -81,7 +90,7 @@ function emitPublishOutcome(name, outcome, opts = {}) {
|
|
|
81
90
|
const prefix = opts.pushed ? 'pushed, but publish failed — ' : '';
|
|
82
91
|
process.stderr.write(chalk_1.default.red(`${prefix}${outcome.code}: ${outcome.message}\n`));
|
|
83
92
|
if (opts.pushed) {
|
|
84
|
-
process.stderr.write(chalk_1.default.yellow(` The skill was pushed. Retry: solidactions skill publish ${name}\n`));
|
|
93
|
+
process.stderr.write(chalk_1.default.yellow(` The skill was pushed. Retry: solidactions skill publish ${name}${opts.role ? ` --role ${opts.role}` : ''}${opts.role && opts.inCrew ? ` --in-crew ${opts.inCrew}` : ''}\n`));
|
|
85
94
|
}
|
|
86
95
|
process.exit(1);
|
|
87
96
|
}
|