@crewx/cli 0.9.0-rc.145 → 0.9.0-rc.147
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/dist/bootstrap/codex-writable-roots.js +1 -113
- package/dist/bootstrap/crewx-cli.js +1 -84
- package/dist/builtin.js +5 -132
- package/dist/commands/agent.js +4 -118
- package/dist/commands/cal.js +2 -44
- package/dist/commands/db.js +4 -602
- package/dist/commands/detached.js +15 -620
- package/dist/commands/doctor.js +4 -649
- package/dist/commands/emit-trailer.js +2 -33
- package/dist/commands/execute.js +15 -294
- package/dist/commands/hook/command-marker.js +1 -5
- package/dist/commands/hook/install.js +8 -189
- package/dist/commands/hook/paths.js +1 -94
- package/dist/commands/hook/status.js +1 -86
- package/dist/commands/hook/uninstall.js +1 -71
- package/dist/commands/hook-dispatch.js +2 -180
- package/dist/commands/init.js +31 -437
- package/dist/commands/kill.js +1 -11
- package/dist/commands/log.js +3 -96
- package/dist/commands/parse-agent-message.js +1 -52
- package/dist/commands/parse-common-flags.js +3 -212
- package/dist/commands/ps.js +2 -117
- package/dist/commands/publish.js +7 -283
- package/dist/commands/query.js +16 -292
- package/dist/commands/registry.js +1 -33
- package/dist/commands/resolve-prompt.js +3 -76
- package/dist/commands/resolve-recipient.js +3 -47
- package/dist/commands/restart.js +18 -172
- package/dist/commands/result.js +1 -209
- package/dist/commands/shortcut.js +4 -253
- package/dist/commands/slack.js +16 -560
- package/dist/commands/stop.js +8 -119
- package/dist/commands/write-output.js +1 -24
- package/dist/index.js +1 -8
- package/dist/logging.js +10 -87
- package/dist/main.js +6 -289
- package/dist/register-builtin-tools.js +1 -9
- package/dist/slack/file-download.js +1 -134
- package/dist/slack/markdown.js +1 -33
- package/dist/utils/env-defaults.js +1 -15
- package/dist/utils/inherited-trace.js +1 -65
- package/dist/utils/product-package-root.js +1 -39
- package/dist/utils/sdk-compat.js +1 -120
- package/dist/utils/version.js +1 -28
- package/package.json +15 -15
package/dist/commands/publish.js
CHANGED
|
@@ -1,119 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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.handlePublish = handlePublish;
|
|
37
|
-
/**
|
|
38
|
-
* crewx publish handler — thin CLI wrapper over @crewx/sdk/publish.
|
|
39
|
-
*
|
|
40
|
-
* Usage:
|
|
41
|
-
* crewx publish [dir] [--dry-run] [--version <semver>] [--json] [--upload]
|
|
42
|
-
*
|
|
43
|
-
* All scanning, exclusion-rule judgment, secret detection, hashing, and
|
|
44
|
-
* tar.gz packing lives in @crewx/sdk/publish (planPublish / packTemplate).
|
|
45
|
-
* Submit+upload (WI-SHR-20260806-013) lives in the same package
|
|
46
|
-
* (uploadToMarketplace) for the same reason — see that module's header.
|
|
47
|
-
* This command only parses argv, forwards options, asks the SDK SessionManager
|
|
48
|
-
* for a valid account bearer when upload is requested, and renders the result.
|
|
49
|
-
*/
|
|
50
|
-
const fs = __importStar(require("fs"));
|
|
51
|
-
const account_1 = require("@crewx/sdk/account");
|
|
52
|
-
const publish_1 = require("@crewx/sdk/publish");
|
|
53
|
-
const parse_common_flags_1 = require("./parse-common-flags");
|
|
54
|
-
function parsePublishFlags(args) {
|
|
55
|
-
const flags = { dryRun: false, json: false, help: false, upload: false };
|
|
56
|
-
for (let i = 0; i < args.length; i++) {
|
|
57
|
-
const arg = args[i];
|
|
58
|
-
if (arg === '--help' || arg === '-h') {
|
|
59
|
-
flags.help = true;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (arg === '--dry-run') {
|
|
63
|
-
flags.dryRun = true;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (arg === '--json') {
|
|
67
|
-
flags.json = true;
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (arg === '--upload') {
|
|
71
|
-
flags.upload = true;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (arg === '--version') {
|
|
75
|
-
const value = args[i + 1];
|
|
76
|
-
if (value === undefined)
|
|
77
|
-
throw new parse_common_flags_1.UnknownOptionError('--version requires a value');
|
|
78
|
-
flags.version = value;
|
|
79
|
-
i++;
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
if (arg.startsWith('--version=')) {
|
|
83
|
-
flags.version = arg.slice('--version='.length);
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (arg.startsWith('-')) {
|
|
87
|
-
throw new parse_common_flags_1.UnknownOptionError(`Unknown option: ${arg}`);
|
|
88
|
-
}
|
|
89
|
-
if (flags.dir === undefined) {
|
|
90
|
-
flags.dir = arg;
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
throw new parse_common_flags_1.UnknownOptionError(`Unknown option: ${arg}`);
|
|
94
|
-
}
|
|
95
|
-
return flags;
|
|
96
|
-
}
|
|
97
|
-
function resolveWorkspaceDir(flags) {
|
|
98
|
-
return flags.dir ?? process.env['CREWX_WORKSPACE'] ?? process.cwd();
|
|
99
|
-
}
|
|
100
|
-
function printJson(payload) {
|
|
101
|
-
console.log(JSON.stringify(payload));
|
|
102
|
-
}
|
|
103
|
-
/** Prints the error and exits 1. Never returns (matches `process.exit`'s `never` type). */
|
|
104
|
-
function failWithError(err, json) {
|
|
105
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
106
|
-
if (json) {
|
|
107
|
-
printJson({ success: false, error: message });
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
console.error(`✗ ${message}`);
|
|
111
|
-
}
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
114
|
-
function printHelp() {
|
|
115
|
-
console.log(`
|
|
116
|
-
crewx publish — package a workspace as a distributable template archive
|
|
1
|
+
"use strict";var v=exports&&exports.__createBinding||(Object.create?(function(t,e,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(e,r);if(!s||("get"in s?!e.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return e[r]}}}Object.defineProperty(t,n,s)}):(function(t,e,r,n){if(n===void 0)n=r;t[n]=e[r]}));var w=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:true,value:e})}):function(t,e){t["default"]=e});var b=exports&&exports.__importStar||(function(){var t=function(e){t=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n};return t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null){for(var n=t(e),s=0;s<n.length;s++)if(n[s]!=="default")v(r,e,n[s])}w(r,e);return r}})();Object.defineProperty(exports,"__esModule",{value:true});exports.handlePublish=j;const _=b(require("fs"));const u=require("@crewx/sdk/account");const f=require("@crewx/sdk/publish");const h=require("./parse-common-flags");function y(t){const e={dryRun:false,json:false,help:false,upload:false};for(let r=0;r<t.length;r++){const n=t[r];if(n==="--help"||n==="-h"){e.help=true;continue}if(n==="--dry-run"){e.dryRun=true;continue}if(n==="--json"){e.json=true;continue}if(n==="--upload"){e.upload=true;continue}if(n==="--version"){const s=t[r+1];if(s===void 0)throw new h.UnknownOptionError("--version requires a value");e.version=s;r++;continue}if(n.startsWith("--version=")){e.version=n.slice("--version=".length);continue}if(n.startsWith("-")){throw new h.UnknownOptionError(`Unknown option: ${n}`)}if(e.dir===void 0){e.dir=n;continue}throw new h.UnknownOptionError(`Unknown option: ${n}`)}return e}function E(t){return t.dir??process.env["CREWX_WORKSPACE"]??process.cwd()}function d(t){console.log(JSON.stringify(t))}function c(t,e){const r=t instanceof Error?t.message:String(t);if(e){d({success:false,error:r})}else{console.error(`\u2717 ${r}`)}process.exit(1)}function $(){console.log(`
|
|
2
|
+
crewx publish \u2014 package a workspace as a distributable template archive
|
|
117
3
|
|
|
118
4
|
Usage:
|
|
119
5
|
crewx publish [dir] [--dry-run] [--version <semver>] [--json] [--upload]
|
|
@@ -134,170 +20,8 @@ Notes:
|
|
|
134
20
|
Without --upload, this command only scans the workspace, applies
|
|
135
21
|
exclusion rules, checks for secrets, and packs a local
|
|
136
22
|
.crewx/publish/<name>-<version>.tgz archive.
|
|
137
|
-
`.trim());
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const url = (0, account_1.resolveMarketplaceUrl)();
|
|
143
|
-
(0, account_1.assertAccountTargetNotMixed)();
|
|
144
|
-
return url;
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
const code = typeof error === 'object' && error !== null && 'code' in error
|
|
148
|
-
? error.code
|
|
149
|
-
: undefined;
|
|
150
|
-
if (code === 'ACCOUNT_TARGET_INVALID' ||
|
|
151
|
-
code === 'ACCOUNT_TARGET_MIXED' ||
|
|
152
|
-
code === 'MARKETPLACE_DISABLED' ||
|
|
153
|
-
code === 'MARKETPLACE_URL_INVALID') {
|
|
154
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
155
|
-
throw new Error(`publish: [${code}] ${message}`);
|
|
156
|
-
}
|
|
157
|
-
throw error;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function isMarketplaceUnauthorized(err) {
|
|
161
|
-
return err instanceof Error
|
|
162
|
-
&& err.message.includes('publish: [E_AUTH_EXPIRED]')
|
|
163
|
-
&& /HTTP 401\b/.test(err.message);
|
|
164
|
-
}
|
|
165
|
-
async function uploadWithSessionRefresh(sessionManager, options, accessToken) {
|
|
166
|
-
try {
|
|
167
|
-
return await (0, publish_1.uploadToMarketplace)({ ...options, accessToken });
|
|
168
|
-
}
|
|
169
|
-
catch (err) {
|
|
170
|
-
if (!isMarketplaceUnauthorized(err))
|
|
171
|
-
throw err;
|
|
172
|
-
const refreshedSession = await sessionManager.refresh();
|
|
173
|
-
return (0, publish_1.uploadToMarketplace)({ ...options, accessToken: refreshedSession.access_token });
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
async function handlePublish(args) {
|
|
177
|
-
const flags = parsePublishFlags(args);
|
|
178
|
-
if (flags.help) {
|
|
179
|
-
printHelp();
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
const dir = resolveWorkspaceDir(flags);
|
|
183
|
-
process.stderr.write(`[publish] scanning ${dir}...\n`);
|
|
184
|
-
let plan;
|
|
185
|
-
try {
|
|
186
|
-
plan = await (0, publish_1.planPublish)(dir, { version: flags.version });
|
|
187
|
-
}
|
|
188
|
-
catch (err) {
|
|
189
|
-
failWithError(err, flags.json);
|
|
190
|
-
}
|
|
191
|
-
if (plan.secretFindings.length > 0) {
|
|
192
|
-
if (flags.json) {
|
|
193
|
-
printJson({ success: false, error: 'secret findings detected', findings: plan.secretFindings });
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
console.error('✗ secret findings detected — publish aborted');
|
|
197
|
-
for (const f of plan.secretFindings) {
|
|
198
|
-
console.error(` ${f.path}:${f.line} (${f.rule})`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
process.exit(1);
|
|
202
|
-
}
|
|
203
|
-
if (flags.dryRun) {
|
|
204
|
-
if (flags.json) {
|
|
205
|
-
printJson({
|
|
206
|
-
success: true,
|
|
207
|
-
dryRun: true,
|
|
208
|
-
workspace: dir,
|
|
209
|
-
manifest: plan.manifest,
|
|
210
|
-
included: plan.included,
|
|
211
|
-
excluded: plan.excluded,
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
console.log('✓ dry-run — no archive written');
|
|
216
|
-
console.log(` workspace: ${dir}`);
|
|
217
|
-
console.log(` name: ${plan.manifest.name} version: ${plan.manifest.version}`);
|
|
218
|
-
console.log(` included: ${plan.included.length} files`);
|
|
219
|
-
console.log(` excluded: ${plan.excluded.length} entries`);
|
|
220
|
-
for (const e of plan.excluded) {
|
|
221
|
-
console.log(` ${e.path} (${e.rule})`);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
// Resolved before packing (not after) so a doomed --upload run (no
|
|
227
|
-
// marketplace url / no session) never writes a stray .tgz to the
|
|
228
|
-
// workspace — WI-SHR-20260806-013 AC-U5.
|
|
229
|
-
let marketplaceUrl = '';
|
|
230
|
-
let accessToken = '';
|
|
231
|
-
let sessionManager;
|
|
232
|
-
if (flags.upload) {
|
|
233
|
-
try {
|
|
234
|
-
marketplaceUrl = requireMarketplaceUrl();
|
|
235
|
-
sessionManager = new account_1.SessionManager({ authClient: new account_1.AuthClient() });
|
|
236
|
-
accessToken = await sessionManager.getAccessToken();
|
|
237
|
-
}
|
|
238
|
-
catch (err) {
|
|
239
|
-
if (err instanceof Error && !err.message.startsWith('publish: [')) {
|
|
240
|
-
failWithError(new Error(`publish: [E_AUTH_EXPIRED] Authentication is missing or expired — please log in again — ${err.message}`), flags.json);
|
|
241
|
-
}
|
|
242
|
-
failWithError(err, flags.json);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
process.stderr.write(`[publish] packing ${plan.manifest.name}@${plan.manifest.version}...\n`);
|
|
246
|
-
let packed;
|
|
247
|
-
try {
|
|
248
|
-
packed = await (0, publish_1.packTemplate)(dir, { version: flags.version });
|
|
249
|
-
}
|
|
250
|
-
catch (err) {
|
|
251
|
-
failWithError(err, flags.json);
|
|
252
|
-
}
|
|
253
|
-
const fileCount = packed.manifest.files.length;
|
|
254
|
-
const totalBytes = fs.statSync(packed.tgzPath).size;
|
|
255
|
-
let uploadResult;
|
|
256
|
-
if (flags.upload) {
|
|
257
|
-
process.stderr.write(`[publish] uploading ${packed.manifest.name}@${packed.manifest.version} to ${marketplaceUrl}...\n`);
|
|
258
|
-
try {
|
|
259
|
-
if (!sessionManager)
|
|
260
|
-
throw new Error('publish: [E_AUTH_EXPIRED] Account session is unavailable');
|
|
261
|
-
uploadResult = await uploadWithSessionRefresh(sessionManager, {
|
|
262
|
-
tgzPath: packed.tgzPath,
|
|
263
|
-
manifest: packed.manifest,
|
|
264
|
-
baseUrl: marketplaceUrl,
|
|
265
|
-
}, accessToken);
|
|
266
|
-
}
|
|
267
|
-
catch (err) {
|
|
268
|
-
failWithError(err, flags.json);
|
|
269
|
-
}
|
|
270
|
-
process.stderr.write(`[publish] submit -> ${uploadResult.submitOutcome}\n`);
|
|
271
|
-
}
|
|
272
|
-
if (flags.json) {
|
|
273
|
-
printJson({
|
|
274
|
-
success: true,
|
|
275
|
-
tgzPath: packed.tgzPath,
|
|
276
|
-
fileCount,
|
|
277
|
-
totalBytes,
|
|
278
|
-
manifest: packed.manifest,
|
|
279
|
-
...(uploadResult
|
|
280
|
-
? {
|
|
281
|
-
slug: uploadResult.slug,
|
|
282
|
-
version: uploadResult.version,
|
|
283
|
-
artifactChecksum: uploadResult.artifactChecksum,
|
|
284
|
-
artifactSizeBytes: uploadResult.artifactSizeBytes,
|
|
285
|
-
submitOutcome: uploadResult.submitOutcome,
|
|
286
|
-
versionUpdate: uploadResult.versionUpdate,
|
|
287
|
-
serverVersionBefore: uploadResult.serverVersionBefore,
|
|
288
|
-
}
|
|
289
|
-
: {}),
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
console.log(`✓ packed: ${packed.tgzPath}`);
|
|
294
|
-
console.log(` files: ${fileCount} bytes: ${totalBytes}`);
|
|
295
|
-
if (uploadResult) {
|
|
296
|
-
console.log(`✓ uploaded: ${uploadResult.slug}@${uploadResult.version} (${uploadResult.submitOutcome})`);
|
|
297
|
-
console.log(` artifactChecksum: ${uploadResult.artifactChecksum} artifactSizeBytes: ${uploadResult.artifactSizeBytes}`);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
if (!flags.upload) {
|
|
301
|
-
console.error('⚠ To upload, use --upload — check the generated file path');
|
|
302
|
-
}
|
|
303
|
-
}
|
|
23
|
+
`.trim())}function O(){try{const t=(0,u.resolveMarketplaceUrl)();(0,u.assertAccountTargetNotMixed)();return t}catch(t){const e=typeof t==="object"&&t!==null&&"code"in t?t.code:void 0;if(e==="ACCOUNT_TARGET_INVALID"||e==="ACCOUNT_TARGET_MIXED"||e==="MARKETPLACE_DISABLED"||e==="MARKETPLACE_URL_INVALID"){const r=t instanceof Error?t.message:String(t);throw new Error(`publish: [${e}] ${r}`)}throw t}}function k(t){return t instanceof Error&&t.message.includes("publish: [E_AUTH_EXPIRED]")&&/HTTP 401\b/.test(t.message)}async function P(t,e,r){try{return await(0,f.uploadToMarketplace)({...e,accessToken:r})}catch(n){if(!k(n))throw n;const s=await t.refresh();return(0,f.uploadToMarketplace)({...e,accessToken:s.access_token})}}async function j(t){const e=y(t);if(e.help){$();return}const r=E(e);process.stderr.write(`[publish] scanning ${r}...
|
|
24
|
+
`);let n;try{n=await(0,f.planPublish)(r,{version:e.version})}catch(i){c(i,e.json)}if(n.secretFindings.length>0){if(e.json){d({success:false,error:"secret findings detected",findings:n.secretFindings})}else{console.error("\u2717 secret findings detected \u2014 publish aborted");for(const i of n.secretFindings){console.error(` ${i.path}:${i.line} (${i.rule})`)}}process.exit(1)}if(e.dryRun){if(e.json){d({success:true,dryRun:true,workspace:r,manifest:n.manifest,included:n.included,excluded:n.excluded})}else{console.log("\u2713 dry-run \u2014 no archive written");console.log(` workspace: ${r}`);console.log(` name: ${n.manifest.name} version: ${n.manifest.version}`);console.log(` included: ${n.included.length} files`);console.log(` excluded: ${n.excluded.length} entries`);for(const i of n.excluded){console.log(` ${i.path} (${i.rule})`)}}return}let s="";let p="";let l;if(e.upload){try{s=O();l=new u.SessionManager({authClient:new u.AuthClient});p=await l.getAccessToken()}catch(i){if(i instanceof Error&&!i.message.startsWith("publish: [")){c(new Error(`publish: [E_AUTH_EXPIRED] Authentication is missing or expired \u2014 please log in again \u2014 ${i.message}`),e.json)}c(i,e.json)}}process.stderr.write(`[publish] packing ${n.manifest.name}@${n.manifest.version}...
|
|
25
|
+
`);let a;try{a=await(0,f.packTemplate)(r,{version:e.version})}catch(i){c(i,e.json)}const g=a.manifest.files.length;const m=_.statSync(a.tgzPath).size;let o;if(e.upload){process.stderr.write(`[publish] uploading ${a.manifest.name}@${a.manifest.version} to ${s}...
|
|
26
|
+
`);try{if(!l)throw new Error("publish: [E_AUTH_EXPIRED] Account session is unavailable");o=await P(l,{tgzPath:a.tgzPath,manifest:a.manifest,baseUrl:s},p)}catch(i){c(i,e.json)}process.stderr.write(`[publish] submit -> ${o.submitOutcome}
|
|
27
|
+
`)}if(e.json){d({success:true,tgzPath:a.tgzPath,fileCount:g,totalBytes:m,manifest:a.manifest,...o?{slug:o.slug,version:o.version,artifactChecksum:o.artifactChecksum,artifactSizeBytes:o.artifactSizeBytes,submitOutcome:o.submitOutcome,versionUpdate:o.versionUpdate,serverVersionBefore:o.serverVersionBefore}:{}})}else{console.log(`\u2713 packed: ${a.tgzPath}`);console.log(` files: ${g} bytes: ${m}`);if(o){console.log(`\u2713 uploaded: ${o.slug}@${o.version} (${o.submitOutcome})`);console.log(` artifactChecksum: ${o.artifactChecksum} artifactSizeBytes: ${o.artifactSizeBytes}`)}}if(!e.upload){console.error("\u26A0 To upload, use --upload \u2014 check the generated file path")}}
|
package/dist/commands/query.js
CHANGED
|
@@ -1,292 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* -f/--prompt-file <path> Read prompt body from file (bypasses cmd.exe argv truncation)
|
|
18
|
-
* --detach/--async Persist a receipt and launch a detached runner
|
|
19
|
-
* --wait Force synchronous execution
|
|
20
|
-
*
|
|
21
|
-
* Stdin support:
|
|
22
|
-
* Pipe or redirect content into crewx q to supply the prompt body via stdin.
|
|
23
|
-
* e.g. cat brief.md | crewx q --to agent label
|
|
24
|
-
* Stdin is ignored when running in an interactive TTY.
|
|
25
|
-
*/
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.handleQuery = handleQuery;
|
|
28
|
-
const sdk_1 = require("@crewx/sdk");
|
|
29
|
-
const repository_1 = require("@crewx/sdk/repository");
|
|
30
|
-
const parse_agent_message_1 = require("./parse-agent-message");
|
|
31
|
-
const parse_common_flags_1 = require("./parse-common-flags");
|
|
32
|
-
const resolve_recipient_1 = require("./resolve-recipient");
|
|
33
|
-
const resolve_prompt_1 = require("./resolve-prompt");
|
|
34
|
-
const crewx_cli_1 = require("../bootstrap/crewx-cli");
|
|
35
|
-
const inherited_trace_1 = require("../utils/inherited-trace");
|
|
36
|
-
const write_output_1 = require("./write-output");
|
|
37
|
-
const detached_1 = require("./detached");
|
|
38
|
-
const emit_trailer_1 = require("./emit-trailer");
|
|
39
|
-
/**
|
|
40
|
-
* Handle `crewx query <agentRef> <message>` command.
|
|
41
|
-
*
|
|
42
|
-
* Default output: raw agent response only (stdout).
|
|
43
|
-
* --verbose: debug info written to stderr, response to stdout.
|
|
44
|
-
*/
|
|
45
|
-
async function handleQuery(args, command = 'query', emitState = (0, emit_trailer_1.createDelegationEmitState)()) {
|
|
46
|
-
// The private middle-hop marker is consumed before public flag parsing. An
|
|
47
|
-
// invalid direct use remains an unknown option and is rejected normally.
|
|
48
|
-
const middleHop = (0, detached_1.readDetachedMiddleHop)(args);
|
|
49
|
-
if (middleHop) {
|
|
50
|
-
await (0, detached_1.runDetachedMiddle)(command, middleHop);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const receiptFlags = (0, detached_1.extractReceiptFlags)(args);
|
|
54
|
-
const receiptMode = (0, detached_1.resolveReceiptMode)({
|
|
55
|
-
detach: receiptFlags.detach,
|
|
56
|
-
wait: receiptFlags.wait,
|
|
57
|
-
detachedRunner: (0, inherited_trace_1.isDetachedRunner)(),
|
|
58
|
-
agentContext: Boolean(process.env['CREWX_AGENT_ID']),
|
|
59
|
-
});
|
|
60
|
-
if (receiptMode.receipt) {
|
|
61
|
-
await (0, detached_1.runDetached)(command, receiptFlags.rest, receiptMode.reason, args);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
let parsedFlags;
|
|
65
|
-
try {
|
|
66
|
-
parsedFlags = (0, parse_common_flags_1.parseCommonFlags)(receiptFlags.rest);
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
(0, emit_trailer_1.emitDelegationResult)({ command, isError: true, state: emitState });
|
|
70
|
-
throw err;
|
|
71
|
-
}
|
|
72
|
-
const { thread, provider, model, metadata, verbose, config, outputFormat, effort, promptFile, overdrive, vars, out, rest, to } = parsedFlags;
|
|
73
|
-
const inheritedTrace = (0, inherited_trace_1.readInheritedTrace)();
|
|
74
|
-
let parsedAgentRef;
|
|
75
|
-
let message;
|
|
76
|
-
let finalMessage;
|
|
77
|
-
try {
|
|
78
|
-
({ agentRef: parsedAgentRef, message } = (0, parse_agent_message_1.parseAgentMessage)(rest));
|
|
79
|
-
// Resolve final prompt: argv | stdin pipe | --prompt-file (or combination)
|
|
80
|
-
finalMessage = await (0, resolve_prompt_1.resolvePrompt)(message, promptFile);
|
|
81
|
-
}
|
|
82
|
-
catch (err) {
|
|
83
|
-
(0, emit_trailer_1.emitDelegationResult)({ command, trace: inheritedTrace, isError: true, state: emitState });
|
|
84
|
-
throw err;
|
|
85
|
-
}
|
|
86
|
-
let agentRef;
|
|
87
|
-
try {
|
|
88
|
-
({ agentRef } = (0, resolve_recipient_1.resolveRecipient)({
|
|
89
|
-
positionalRef: parsedAgentRef,
|
|
90
|
-
toFlag: to,
|
|
91
|
-
agentContext: Boolean(process.env['CREWX_AGENT_ID']),
|
|
92
|
-
bodyForHint: finalMessage,
|
|
93
|
-
command,
|
|
94
|
-
invocationArgs: args,
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
catch (err) {
|
|
98
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
99
|
-
process.stderr.write(`Error: ${message}\n`);
|
|
100
|
-
(0, emit_trailer_1.emitDelegationResult)({ command, trace: inheritedTrace, isError: true, state: emitState });
|
|
101
|
-
process.exit(2);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (!finalMessage) {
|
|
105
|
-
console.error('Usage: crewx query --to <agent> <message> [options]');
|
|
106
|
-
console.error(' crewx q --to <agent> <message> [options]');
|
|
107
|
-
console.error(' Human-terminal shorthand: crewx q "@agent <message>"');
|
|
108
|
-
console.error('');
|
|
109
|
-
console.error(' Agent calls require --to or a positional @agent recipient.');
|
|
110
|
-
console.error(' Human terminal and cron calls default to @crewx when omitted.');
|
|
111
|
-
console.error(' Prompt can also be supplied via stdin pipe or --prompt-file.');
|
|
112
|
-
console.error('');
|
|
113
|
-
console.error('Examples:');
|
|
114
|
-
console.error(' crewx q --to agent "hello"');
|
|
115
|
-
console.error(' crewx q --to agent -f brief.md');
|
|
116
|
-
console.error(' Prompt files contain only the body; set the recipient separately with --to.');
|
|
117
|
-
console.error('');
|
|
118
|
-
console.error('Options:');
|
|
119
|
-
console.error(' --to <agent> Explicit agent recipient');
|
|
120
|
-
console.error(' --thread <name> Conversation thread name');
|
|
121
|
-
console.error(' --provider <cli/xxx> Provider override');
|
|
122
|
-
console.error(' --model <name> Model override (e.g. claude-sonnet-5)');
|
|
123
|
-
console.error(' --metadata <json> Extra metadata (JSON object, double-quoted).');
|
|
124
|
-
console.error(' Propagated to events/hooks/tracing.');
|
|
125
|
-
console.error(' Invalid JSON aborts with exit code 2.');
|
|
126
|
-
console.error(' e.g. --metadata=\'{"workflow_id":"wf-1"}\'');
|
|
127
|
-
console.error(' --verbose Debug output mode');
|
|
128
|
-
console.error(' --config/-c <path> Config file path');
|
|
129
|
-
console.error(' --output-format <fmt> Output format (json|text|stream-json)');
|
|
130
|
-
console.error(' --out/-o <path> Save result to file (stdout suppressed)');
|
|
131
|
-
console.error(' --effort <level> Model effort (high|medium|low)');
|
|
132
|
-
console.error(' -f/--prompt-file <path> Read body only from file; set recipient separately with --to');
|
|
133
|
-
console.error(' --var key=value Template variable (repeatable)');
|
|
134
|
-
console.error(' --overdrive Activate overdrive (boost) profile for this request');
|
|
135
|
-
(0, emit_trailer_1.emitDelegationResult)({ command, trace: inheritedTrace, isError: true, state: emitState });
|
|
136
|
-
process.exit(1);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const configPath = config ?? process.env.CREWX_CONFIG ?? 'crewx.yaml';
|
|
140
|
-
// Only show exec audit span JSON in verbose mode
|
|
141
|
-
(0, sdk_1.setAuditVerbose)(verbose);
|
|
142
|
-
let crewx;
|
|
143
|
-
try {
|
|
144
|
-
crewx = await (0, crewx_cli_1.createCliCrewx)(configPath);
|
|
145
|
-
}
|
|
146
|
-
catch (err) {
|
|
147
|
-
(0, emit_trailer_1.emitDelegationResult)({ command, trace: inheritedTrace, isError: true, state: emitState });
|
|
148
|
-
throw err;
|
|
149
|
-
}
|
|
150
|
-
// file:// remote agent delegation is handled transparently inside Crewx.query/execute.
|
|
151
|
-
if (verbose) {
|
|
152
|
-
process.stderr.write(`mode=sync reason=${receiptMode.reason}\n`);
|
|
153
|
-
process.stderr.write(`📋 Task: ${finalMessage}\n`);
|
|
154
|
-
process.stderr.write(`🤖 Agent: ${agentRef}\n`);
|
|
155
|
-
if (thread)
|
|
156
|
-
process.stderr.write(`🔗 Thread: ${thread}\n`);
|
|
157
|
-
if (provider)
|
|
158
|
-
process.stderr.write(`🔌 Provider: ${provider}\n`);
|
|
159
|
-
if (model)
|
|
160
|
-
process.stderr.write(`🧠 Model: ${model}\n`);
|
|
161
|
-
if (outputFormat)
|
|
162
|
-
process.stderr.write(`📄 Output-format: ${outputFormat}\n`);
|
|
163
|
-
if (effort)
|
|
164
|
-
process.stderr.write(`⚡ Effort: ${effort}\n`);
|
|
165
|
-
if (overdrive)
|
|
166
|
-
process.stderr.write(`🚀 Overdrive: ON\n`);
|
|
167
|
-
process.stderr.write('─'.repeat(60) + '\n');
|
|
168
|
-
}
|
|
169
|
-
let parsedMetadata = {};
|
|
170
|
-
try {
|
|
171
|
-
parsedMetadata = (0, parse_common_flags_1.parseMetadata)(metadata);
|
|
172
|
-
}
|
|
173
|
-
catch (err) {
|
|
174
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
175
|
-
process.stderr.write(`Error: ${msg}\n`);
|
|
176
|
-
(0, emit_trailer_1.emitDelegationResult)({ command, trace: inheritedTrace, isError: true, state: emitState });
|
|
177
|
-
process.exit(2);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
const actor = (0, detached_1.resolveCliTaskActor)(parsedMetadata);
|
|
181
|
-
// Only the detached runner may adopt a pre-issued task row. Trace variables
|
|
182
|
-
// describe the caller chain and are never used as this task's identity.
|
|
183
|
-
const detachedRunner = (0, inherited_trace_1.isDetachedRunner)();
|
|
184
|
-
const assignedTaskId = (0, inherited_trace_1.readRunnerAssignment)();
|
|
185
|
-
let selfTaskId;
|
|
186
|
-
let taskActor;
|
|
187
|
-
if (assignedTaskId !== undefined) {
|
|
188
|
-
const taskRepo = new repository_1.TaskRepository();
|
|
189
|
-
const adoption = (0, detached_1.adoptAssignedTask)(taskRepo, assignedTaskId, detachedRunner);
|
|
190
|
-
if (adoption.kind === 'failed') {
|
|
191
|
-
(0, emit_trailer_1.emitDelegationResult)({ command, trace: inheritedTrace, isError: true, state: emitState });
|
|
192
|
-
process.exit(1);
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (adoption.kind === 'adopted') {
|
|
196
|
-
selfTaskId = adoption.taskId;
|
|
197
|
-
taskActor = (0, detached_1.readAssignedTaskActor)(taskRepo, adoption.taskId);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
// A synchronous `crewx q` runs in this same process, but this process is
|
|
201
|
-
// still separate from the embedded server and never sees its in-memory
|
|
202
|
-
// UpdateGateService (WI-CTO-20260919-004 R2 finding #1) — only the durable
|
|
203
|
-
// marker it writes. Reserve-then-check before calling into the SDK below,
|
|
204
|
-
// not after; see admitDurableTask()'s own doc comment. Never checked for
|
|
205
|
-
// an adopted receipt (selfTaskId set): that work was already admitted by
|
|
206
|
-
// whichever process first created its pending DB row.
|
|
207
|
-
let admission;
|
|
208
|
-
if (selfTaskId === undefined) {
|
|
209
|
-
admission = (0, sdk_1.admitDurableTask)(`direct-cli:${command}`);
|
|
210
|
-
if (!admission.ok) {
|
|
211
|
-
(0, detached_1.reportAdmissionBlocked)(admission);
|
|
212
|
-
(0, emit_trailer_1.emitDelegationResult)({ command, trace: inheritedTrace, isError: true, state: emitState });
|
|
213
|
-
process.exit(1);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
let exitCode = 0;
|
|
218
|
-
let result;
|
|
219
|
-
try {
|
|
220
|
-
try {
|
|
221
|
-
result = await crewx.query(agentRef, finalMessage, {
|
|
222
|
-
provider,
|
|
223
|
-
model,
|
|
224
|
-
effort: effort || undefined,
|
|
225
|
-
overdrive: overdrive || undefined,
|
|
226
|
-
threadId: thread,
|
|
227
|
-
taskId: selfTaskId,
|
|
228
|
-
actor: selfTaskId === undefined ? actor : taskActor,
|
|
229
|
-
metadata: Object.keys(parsedMetadata).length > 0 ? parsedMetadata : undefined,
|
|
230
|
-
vars: Object.keys(vars).length > 0 ? vars : undefined,
|
|
231
|
-
trace: inheritedTrace,
|
|
232
|
-
});
|
|
233
|
-
if (!result.ok) {
|
|
234
|
-
const errMsg = result.error?.message ?? 'Query failed';
|
|
235
|
-
console.error(errMsg);
|
|
236
|
-
(0, write_output_1.appendError)(out, errMsg);
|
|
237
|
-
exitCode = 1;
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
if (verbose) {
|
|
241
|
-
process.stderr.write(`\n📊 Results from ${agentRef}:\n`);
|
|
242
|
-
process.stderr.write('═'.repeat(60) + '\n');
|
|
243
|
-
process.stderr.write('🟢 Status: Success\n');
|
|
244
|
-
process.stderr.write(`🤖 Provider: ${result.meta.provider}\n`);
|
|
245
|
-
process.stderr.write(`⏱️ Duration: ${result.meta.durationMs}ms\n`);
|
|
246
|
-
process.stderr.write('\n📄 Response:\n');
|
|
247
|
-
process.stderr.write('─'.repeat(40) + '\n');
|
|
248
|
-
}
|
|
249
|
-
(0, write_output_1.writeResult)(out, result.data);
|
|
250
|
-
if (verbose) {
|
|
251
|
-
process.stderr.write('\n✅ Query completed successfully\n');
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
catch (err) {
|
|
256
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
257
|
-
console.error(`Error: ${errMsg}`);
|
|
258
|
-
(0, write_output_1.appendError)(out, `Error: ${errMsg}`);
|
|
259
|
-
exitCode = 1;
|
|
260
|
-
}
|
|
261
|
-
finally {
|
|
262
|
-
try {
|
|
263
|
-
await crewx.close();
|
|
264
|
-
}
|
|
265
|
-
catch (err) {
|
|
266
|
-
(0, emit_trailer_1.emitDelegationResult)({
|
|
267
|
-
command,
|
|
268
|
-
trace: inheritedTrace,
|
|
269
|
-
taskId: result?.meta.taskId,
|
|
270
|
-
agentId: result?.meta.agentId,
|
|
271
|
-
isError: true,
|
|
272
|
-
state: emitState,
|
|
273
|
-
});
|
|
274
|
-
throw err;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
finally {
|
|
279
|
-
if (admission?.ok)
|
|
280
|
-
admission.release();
|
|
281
|
-
}
|
|
282
|
-
(0, emit_trailer_1.emitDelegationResult)({
|
|
283
|
-
command,
|
|
284
|
-
trace: inheritedTrace,
|
|
285
|
-
taskId: result?.meta.taskId,
|
|
286
|
-
agentId: result?.meta.agentId,
|
|
287
|
-
isError: exitCode !== 0 || result?.ok === false,
|
|
288
|
-
state: emitState,
|
|
289
|
-
});
|
|
290
|
-
if (exitCode !== 0)
|
|
291
|
-
process.exit(exitCode);
|
|
292
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.handleQuery=L;const F=require("@crewx/sdk");const J=require("@crewx/sdk/repository");const U=require("./parse-agent-message");const P=require("./parse-common-flags");const V=require("./resolve-recipient");const z=require("./resolve-prompt");const K=require("../bootstrap/crewx-cli");const m=require("../utils/inherited-trace");const q=require("./write-output");const i=require("./detached");const s=require("./emit-trailer");async function L(p,r="query",a=(0,s.createDelegationEmitState)()){const D=(0,i.readDetachedMiddleHop)(p);if(D){await(0,i.runDetachedMiddle)(r,D);return}const u=(0,i.extractReceiptFlags)(p);const v=(0,i.resolveReceiptMode)({detach:u.detach,wait:u.wait,detachedRunner:(0,m.isDetachedRunner)(),agentContext:Boolean(process.env["CREWX_AGENT_ID"])});if(v.receipt){await(0,i.runDetached)(r,u.rest,v.reason,p);return}let b;try{b=(0,P.parseCommonFlags)(u.rest)}catch(e){(0,s.emitDelegationResult)({command:r,isError:true,state:a});throw e}const{thread:y,provider:R,model:k,metadata:j,verbose:f,config:N,outputFormat:I,effort:E,promptFile:H,overdrive:A,vars:$,out:_,rest:Q,to:B}=b;const n=(0,m.readInheritedTrace)();let M;let T;let c;try{({agentRef:M,message:T}=(0,U.parseAgentMessage)(Q));c=await(0,z.resolvePrompt)(T,H)}catch(e){(0,s.emitDelegationResult)({command:r,trace:n,isError:true,state:a});throw e}let g;try{({agentRef:g}=(0,V.resolveRecipient)({positionalRef:M,toFlag:B,agentContext:Boolean(process.env["CREWX_AGENT_ID"]),bodyForHint:c,command:r,invocationArgs:p}))}catch(e){const o=e instanceof Error?e.message:String(e);process.stderr.write(`Error: ${o}
|
|
2
|
+
`);(0,s.emitDelegationResult)({command:r,trace:n,isError:true,state:a});process.exit(2);return}if(!c){console.error("Usage: crewx query --to <agent> <message> [options]");console.error(" crewx q --to <agent> <message> [options]");console.error(' Human-terminal shorthand: crewx q "@agent <message>"');console.error("");console.error(" Agent calls require --to or a positional @agent recipient.");console.error(" Human terminal and cron calls default to @crewx when omitted.");console.error(" Prompt can also be supplied via stdin pipe or --prompt-file.");console.error("");console.error("Examples:");console.error(' crewx q --to agent "hello"');console.error(" crewx q --to agent -f brief.md");console.error(" Prompt files contain only the body; set the recipient separately with --to.");console.error("");console.error("Options:");console.error(" --to <agent> Explicit agent recipient");console.error(" --thread <name> Conversation thread name");console.error(" --provider <cli/xxx> Provider override");console.error(" --model <name> Model override (e.g. claude-sonnet-5)");console.error(" --metadata <json> Extra metadata (JSON object, double-quoted).");console.error(" Propagated to events/hooks/tracing.");console.error(" Invalid JSON aborts with exit code 2.");console.error(` e.g. --metadata='{"workflow_id":"wf-1"}'`);console.error(" --verbose Debug output mode");console.error(" --config/-c <path> Config file path");console.error(" --output-format <fmt> Output format (json|text|stream-json)");console.error(" --out/-o <path> Save result to file (stdout suppressed)");console.error(" --effort <level> Model effort (high|medium|low)");console.error(" -f/--prompt-file <path> Read body only from file; set recipient separately with --to");console.error(" --var key=value Template variable (repeatable)");console.error(" --overdrive Activate overdrive (boost) profile for this request");(0,s.emitDelegationResult)({command:r,trace:n,isError:true,state:a});process.exit(1);return}const G=N??process.env.CREWX_CONFIG??"crewx.yaml";(0,F.setAuditVerbose)(f);let x;try{x=await(0,K.createCliCrewx)(G)}catch(e){(0,s.emitDelegationResult)({command:r,trace:n,isError:true,state:a});throw e}if(f){process.stderr.write(`mode=sync reason=${v.reason}
|
|
3
|
+
`);process.stderr.write(`\u{1F4CB} Task: ${c}
|
|
4
|
+
`);process.stderr.write(`\u{1F916} Agent: ${g}
|
|
5
|
+
`);if(y)process.stderr.write(`\u{1F517} Thread: ${y}
|
|
6
|
+
`);if(R)process.stderr.write(`\u{1F50C} Provider: ${R}
|
|
7
|
+
`);if(k)process.stderr.write(`\u{1F9E0} Model: ${k}
|
|
8
|
+
`);if(I)process.stderr.write(`\u{1F4C4} Output-format: ${I}
|
|
9
|
+
`);if(E)process.stderr.write(`\u26A1 Effort: ${E}
|
|
10
|
+
`);if(A)process.stderr.write(`\u{1F680} Overdrive: ON
|
|
11
|
+
`);process.stderr.write("\u2500".repeat(60)+"\n")}let w={};try{w=(0,P.parseMetadata)(j)}catch(e){const o=e instanceof Error?e.message:String(e);process.stderr.write(`Error: ${o}
|
|
12
|
+
`);(0,s.emitDelegationResult)({command:r,trace:n,isError:true,state:a});process.exit(2);return}const W=(0,i.resolveCliTaskActor)(w);const X=(0,m.isDetachedRunner)();const C=(0,m.readRunnerAssignment)();let h;let O;if(C!==void 0){const e=new J.TaskRepository;const o=(0,i.adoptAssignedTask)(e,C,X);if(o.kind==="failed"){(0,s.emitDelegationResult)({command:r,trace:n,isError:true,state:a});process.exit(1);return}if(o.kind==="adopted"){h=o.taskId;O=(0,i.readAssignedTaskActor)(e,o.taskId)}}let l;if(h===void 0){l=(0,F.admitDurableTask)(`direct-cli:${r}`);if(!l.ok){(0,i.reportAdmissionBlocked)(l);(0,s.emitDelegationResult)({command:r,trace:n,isError:true,state:a});process.exit(1);return}}let d=0;let t;try{try{t=await x.query(g,c,{provider:R,model:k,effort:E||void 0,overdrive:A||void 0,threadId:y,taskId:h,actor:h===void 0?W:O,metadata:Object.keys(w).length>0?w:void 0,vars:Object.keys($).length>0?$:void 0,trace:n});if(!t.ok){const e=t.error?.message??"Query failed";console.error(e);(0,q.appendError)(_,e);d=1}else{if(f){process.stderr.write(`
|
|
13
|
+
\u{1F4CA} Results from ${g}:
|
|
14
|
+
`);process.stderr.write("\u2550".repeat(60)+"\n");process.stderr.write("\u{1F7E2} Status: Success\n");process.stderr.write(`\u{1F916} Provider: ${t.meta.provider}
|
|
15
|
+
`);process.stderr.write(`\u23F1\uFE0F Duration: ${t.meta.durationMs}ms
|
|
16
|
+
`);process.stderr.write("\n\u{1F4C4} Response:\n");process.stderr.write("\u2500".repeat(40)+"\n")}(0,q.writeResult)(_,t.data);if(f){process.stderr.write("\n\u2705 Query completed successfully\n")}}}catch(e){const o=e instanceof Error?e.message:String(e);console.error(`Error: ${o}`);(0,q.appendError)(_,`Error: ${o}`);d=1}finally{try{await x.close()}catch(e){(0,s.emitDelegationResult)({command:r,trace:n,taskId:t?.meta.taskId,agentId:t?.meta.agentId,isError:true,state:a});throw e}}}finally{if(l?.ok)l.release()}(0,s.emitDelegationResult)({command:r,trace:n,taskId:t?.meta.taskId,agentId:t?.meta.agentId,isError:d!==0||t?.ok===false,state:a});if(d!==0)process.exit(d)}
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* CLI command registry — SSOT for commands handled by the CLI engine.
|
|
4
|
-
*
|
|
5
|
-
* Consumed by:
|
|
6
|
-
* - main.ts dispatch (to avoid switch/case literal drift)
|
|
7
|
-
* - bin/__tests__/crewx-entrypoint.test.ts (SSOT assertion vs CLI_SUBCOMMANDS)
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.NOT_YET_MIGRATED = exports.BUILTIN_COMMAND_NAMES = exports.KNOWN_COMMANDS = void 0;
|
|
11
|
-
/** Core commands handled by the main.ts switch/case or hook routing. */
|
|
12
|
-
exports.KNOWN_COMMANDS = new Set([
|
|
13
|
-
'q', 'query',
|
|
14
|
-
'x', 'execute',
|
|
15
|
-
'agent',
|
|
16
|
-
'ps', 'stop', 'kill', 'result', 'log', 'restart',
|
|
17
|
-
'doctor', 'init',
|
|
18
|
-
'db',
|
|
19
|
-
'help',
|
|
20
|
-
'shortcut',
|
|
21
|
-
'publish',
|
|
22
|
-
'slack', 'slack:files',
|
|
23
|
-
'hook', 'hook-dispatch',
|
|
24
|
-
]);
|
|
25
|
-
/** Built-in tool commands routed via handleBuiltin(). */
|
|
26
|
-
exports.BUILTIN_COMMAND_NAMES = new Set([
|
|
27
|
-
'memory', 'search', 'doc', 'wbs', 'cron', 'workflow', 'skill', 'dreaming',
|
|
28
|
-
'wi', 'chromex', 'notify', 'app',
|
|
29
|
-
]);
|
|
30
|
-
/** Commands not yet migrated from cli-bak — show a migration message. */
|
|
31
|
-
exports.NOT_YET_MIGRATED = new Set([
|
|
32
|
-
'template', 'templates', 'chat', 'mcp',
|
|
33
|
-
]);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.NOT_YET_MIGRATED=exports.BUILTIN_COMMAND_NAMES=exports.KNOWN_COMMANDS=void 0;exports.KNOWN_COMMANDS=new Set(["q","query","x","execute","agent","ps","stop","kill","result","log","restart","doctor","init","db","help","shortcut","publish","slack","slack:files","hook","hook-dispatch"]);exports.BUILTIN_COMMAND_NAMES=new Set(["memory","search","doc","wbs","cron","workflow","skill","dreaming","wi","chromex","notify","app"]);exports.NOT_YET_MIGRATED=new Set(["template","templates","chat","mcp"]);
|