@crewx/cli 0.9.0-rc.146 → 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
|
@@ -1,134 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Lightweight Slack file downloader for CLI bot mode.
|
|
4
|
-
* Ported from cli-bak SlackFileDownloadService, stripped of NestJS deps.
|
|
5
|
-
* Uses Node.js built-in https for API calls.
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.downloadInboundFiles = downloadInboundFiles;
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
const path = __importStar(require("path"));
|
|
44
|
-
const https = __importStar(require("https"));
|
|
45
|
-
const MAX_FILE_SIZE = 50 * 1024 * 1024;
|
|
46
|
-
async function downloadInboundFiles(botToken, files, threadId) {
|
|
47
|
-
if (!files || files.length === 0)
|
|
48
|
-
return [];
|
|
49
|
-
const results = [];
|
|
50
|
-
const downloadDir = path.join(process.cwd(), '.crewx', 'slack-files');
|
|
51
|
-
const safeThreadDir = threadId.replace(/:/g, '_');
|
|
52
|
-
for (const file of files) {
|
|
53
|
-
if (!file.url_private)
|
|
54
|
-
continue;
|
|
55
|
-
const sanitizedName = sanitizeFileName(file.name || 'unnamed_file');
|
|
56
|
-
const saveDir = path.join(downloadDir, safeThreadDir);
|
|
57
|
-
const savePath = path.join(saveDir, sanitizedName);
|
|
58
|
-
try {
|
|
59
|
-
if (fs.existsSync(savePath)) {
|
|
60
|
-
const stats = fs.statSync(savePath);
|
|
61
|
-
results.push({
|
|
62
|
-
fileId: '',
|
|
63
|
-
fileName: sanitizedName,
|
|
64
|
-
filePath: savePath,
|
|
65
|
-
fileSize: stats.size,
|
|
66
|
-
threadId,
|
|
67
|
-
});
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
await fs.promises.mkdir(saveDir, { recursive: true });
|
|
71
|
-
const buffer = await fetchUrl(botToken, file.url_private);
|
|
72
|
-
if (buffer.length > MAX_FILE_SIZE) {
|
|
73
|
-
console.error(`File too large: ${sanitizedName} (${formatSize(buffer.length)})`);
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
await fs.promises.writeFile(savePath, new Uint8Array(buffer));
|
|
77
|
-
results.push({
|
|
78
|
-
fileId: '',
|
|
79
|
-
fileName: sanitizedName,
|
|
80
|
-
filePath: savePath,
|
|
81
|
-
fileSize: buffer.length,
|
|
82
|
-
threadId,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
console.error(`Failed to download file ${sanitizedName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return results;
|
|
90
|
-
}
|
|
91
|
-
function fetchUrl(token, url) {
|
|
92
|
-
const parsed = new URL(url);
|
|
93
|
-
return new Promise((resolve, reject) => {
|
|
94
|
-
const options = {
|
|
95
|
-
hostname: parsed.hostname,
|
|
96
|
-
path: parsed.pathname + parsed.search,
|
|
97
|
-
method: 'GET',
|
|
98
|
-
headers: { Authorization: `Bearer ${token}` },
|
|
99
|
-
};
|
|
100
|
-
const req = https.request(options, (res) => {
|
|
101
|
-
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
102
|
-
const location = res.headers.location;
|
|
103
|
-
if (location) {
|
|
104
|
-
fetchUrl(token, location).then(resolve).catch(reject);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (res.statusCode !== 200) {
|
|
109
|
-
reject(new Error(`HTTP ${res.statusCode}`));
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const chunks = [];
|
|
113
|
-
res.on('data', (chunk) => chunks.push(chunk));
|
|
114
|
-
res.on('end', () => resolve(Buffer.concat(chunks)));
|
|
115
|
-
res.on('error', reject);
|
|
116
|
-
});
|
|
117
|
-
req.on('error', reject);
|
|
118
|
-
req.setTimeout(30000, () => { req.destroy(); reject(new Error('Timeout')); });
|
|
119
|
-
req.end();
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
function sanitizeFileName(name) {
|
|
123
|
-
let safe = name.replace(/[/\\]/g, '_').replace(/\.\./g, '_');
|
|
124
|
-
safe = safe.replace(/[\x00-\x1f\x80-\x9f<>:"|?*]/g, '_');
|
|
125
|
-
safe = safe.replace(/^\.+|\.+$/g, '').trim();
|
|
126
|
-
return safe || 'unnamed_file';
|
|
127
|
-
}
|
|
128
|
-
function formatSize(bytes) {
|
|
129
|
-
if (bytes < 1024)
|
|
130
|
-
return `${bytes}B`;
|
|
131
|
-
if (bytes < 1024 * 1024)
|
|
132
|
-
return `${(bytes / 1024).toFixed(1)}KB`;
|
|
133
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
134
|
-
}
|
|
1
|
+
"use strict";var g=exports&&exports.__createBinding||(Object.create?(function(t,e,i,n){if(n===void 0)n=i;var r=Object.getOwnPropertyDescriptor(e,i);if(!r||("get"in r?!e.__esModule:r.writable||r.configurable)){r={enumerable:true,get:function(){return e[i]}}}Object.defineProperty(t,n,r)}):(function(t,e,i,n){if(n===void 0)n=i;t[n]=e[i]}));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 d=exports&&exports.__importStar||(function(){var t=function(e){t=Object.getOwnPropertyNames||function(i){var n=[];for(var r in i)if(Object.prototype.hasOwnProperty.call(i,r))n[n.length]=r;return n};return t(e)};return function(e){if(e&&e.__esModule)return e;var i={};if(e!=null){for(var n=t(e),r=0;r<n.length;r++)if(n[r]!=="default")g(i,e,n[r])}w(i,e);return i}})();Object.defineProperty(exports,"__esModule",{value:true});exports.downloadInboundFiles=b;const f=d(require("fs"));const h=d(require("path"));const m=d(require("https"));const v=50*1024*1024;async function b(t,e,i){if(!e||e.length===0)return[];const n=[];const r=h.join(process.cwd(),".crewx","slack-files");const l=i.replace(/:/g,"_");for(const u of e){if(!u.url_private)continue;const o=O(u.name||"unnamed_file");const s=h.join(r,l);const a=h.join(s,o);try{if(f.existsSync(a)){const p=f.statSync(a);n.push({fileId:"",fileName:o,filePath:a,fileSize:p.size,threadId:i});continue}await f.promises.mkdir(s,{recursive:true});const c=await _(t,u.url_private);if(c.length>v){console.error(`File too large: ${o} (${P(c.length)})`);continue}await f.promises.writeFile(a,new Uint8Array(c));n.push({fileId:"",fileName:o,filePath:a,fileSize:c.length,threadId:i})}catch(c){console.error(`Failed to download file ${o}: ${c instanceof Error?c.message:String(c)}`)}}return n}function _(t,e){const i=new URL(e);return new Promise((n,r)=>{const l={hostname:i.hostname,path:i.pathname+i.search,method:"GET",headers:{Authorization:`Bearer ${t}`}};const u=m.request(l,o=>{if(o.statusCode===301||o.statusCode===302){const a=o.headers.location;if(a){_(t,a).then(n).catch(r);return}}if(o.statusCode!==200){r(new Error(`HTTP ${o.statusCode}`));return}const s=[];o.on("data",a=>s.push(a));o.on("end",()=>n(Buffer.concat(s)));o.on("error",r)});u.on("error",r);u.setTimeout(3e4,()=>{u.destroy();r(new Error("Timeout"))});u.end()})}function O(t){let e=t.replace(/[/\\]/g,"_").replace(/\.\./g,"_");e=e.replace(/[\x00-\x1f\x80-\x9f<>:"|?*]/g,"_");e=e.replace(/^\.+|\.+$/g,"").trim();return e||"unnamed_file"}function P(t){if(t<1024)return`${t}B`;if(t<1024*1024)return`${(t/1024).toFixed(1)}KB`;return`${(t/(1024*1024)).toFixed(1)}MB`}
|
package/dist/slack/markdown.js
CHANGED
|
@@ -1,33 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Lightweight Markdown → Slack mrkdwn converter.
|
|
4
|
-
* Ported from cli-bak formatters, stripped of NestJS / md-to-slack deps.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.markdownToMrkdwn = markdownToMrkdwn;
|
|
8
|
-
const HEADING_RE = /^(#{1,6})\s+(.+)$/gm;
|
|
9
|
-
const BOLD_RE = /\*\*([^*]+)\*\*/g;
|
|
10
|
-
const ITALIC_RE = /(?<!\*)\*([^*]+)\*(?!\*)/g;
|
|
11
|
-
const CODE_BLOCK_RE = /```(\w*)\n([\s\S]*?)```/g;
|
|
12
|
-
const INLINE_CODE_RE = /`([^`]+)`/g;
|
|
13
|
-
const LINK_RE = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
14
|
-
const UNORDERED_LIST_RE = /^[\s]*[-*]\s+/gm;
|
|
15
|
-
const ORDERED_LIST_RE = /^[\s]*(\d+)\.\s+/gm;
|
|
16
|
-
function markdownToMrkdwn(text) {
|
|
17
|
-
if (!text)
|
|
18
|
-
return '';
|
|
19
|
-
let result = text;
|
|
20
|
-
result = result.replace(CODE_BLOCK_RE, (_match, _lang, code) => {
|
|
21
|
-
return `\`\`\`${code.trim()}\`\`\``;
|
|
22
|
-
});
|
|
23
|
-
result = result.replace(INLINE_CODE_RE, '`$1`');
|
|
24
|
-
result = result.replace(HEADING_RE, (_match, _hashes, content) => {
|
|
25
|
-
return `*${content.trim()}*`;
|
|
26
|
-
});
|
|
27
|
-
result = result.replace(BOLD_RE, '*$1*');
|
|
28
|
-
result = result.replace(ITALIC_RE, '_$1_');
|
|
29
|
-
result = result.replace(LINK_RE, '<$2|$1>');
|
|
30
|
-
result = result.replace(UNORDERED_LIST_RE, '• ');
|
|
31
|
-
result = result.replace(ORDERED_LIST_RE, '$1. ');
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.markdownToMrkdwn=g;const s=/^(#{1,6})\s+(.+)$/gm;const _=/\*\*([^*]+)\*\*/g;const E=/(?<!\*)\*([^*]+)\*(?!\*)/g;const a=/```(\w*)\n([\s\S]*?)```/g;const o=/`([^`]+)`/g;const l=/\[([^\]]+)\]\(([^)]+)\)/g;const R=/^[\s]*[-*]\s+/gm;const u=/^[\s]*(\d+)\.\s+/gm;function g(t){if(!t)return"";let e=t;e=e.replace(a,(c,n,r)=>{return`\`\`\`${r.trim()}\`\`\``});e=e.replace(o,"`$1`");e=e.replace(s,(c,n,r)=>{return`*${r.trim()}*`});e=e.replace(_,"*$1*");e=e.replace(E,"_$1_");e=e.replace(l,"<$2|$1>");e=e.replace(R,"\u2022 ");e=e.replace(u,"$1. ");return e}
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveCrewxCli = resolveCrewxCli;
|
|
4
|
-
exports.resolveCrewxWorkspace = resolveCrewxWorkspace;
|
|
5
|
-
/**
|
|
6
|
-
* CREWX_* environment variable defaults for CLI bootstrap.
|
|
7
|
-
* Routed through the SDK compatibility accessor for older SDK installations.
|
|
8
|
-
*/
|
|
9
|
-
const sdk_compat_1 = require("./sdk-compat");
|
|
10
|
-
function resolveCrewxCli() {
|
|
11
|
-
return sdk_compat_1.sdkCompat.resolveCrewxCli();
|
|
12
|
-
}
|
|
13
|
-
function resolveCrewxWorkspace() {
|
|
14
|
-
return sdk_compat_1.sdkCompat.resolveCrewxWorkspace();
|
|
15
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.resolveCrewxCli=r;exports.resolveCrewxWorkspace=o;const e=require("./sdk-compat");function r(){return e.sdkCompat.resolveCrewxCli()}function o(){return e.sdkCompat.resolveCrewxWorkspace()}
|
|
@@ -1,65 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.consumeInheritedRunnerIdentity = consumeInheritedRunnerIdentity;
|
|
4
|
-
exports.resetInheritedRunnerIdentityForTests = resetInheritedRunnerIdentityForTests;
|
|
5
|
-
exports.readInheritedTrace = readInheritedTrace;
|
|
6
|
-
exports.readRunnerAssignment = readRunnerAssignment;
|
|
7
|
-
exports.isDetachedRunner = isDetachedRunner;
|
|
8
|
-
let inheritedRunnerIdentity;
|
|
9
|
-
/**
|
|
10
|
-
* Consume the runner-only identity exactly once.
|
|
11
|
-
*
|
|
12
|
-
* These variables are a one-hop capability, not trace context. Keeping the
|
|
13
|
-
* values in this module lets the current CLI process use them while deleting
|
|
14
|
-
* them from process.env prevents later child processes from inheriting the
|
|
15
|
-
* receipt runner identity.
|
|
16
|
-
*/
|
|
17
|
-
function consumeInheritedRunnerIdentity() {
|
|
18
|
-
if (inheritedRunnerIdentity !== undefined)
|
|
19
|
-
return inheritedRunnerIdentity;
|
|
20
|
-
const assignedTaskId = process.env['CREWX_ASSIGNED_TASK_ID']?.trim() || undefined;
|
|
21
|
-
const detachedRunner = process.env['CREWX_DETACHED_RUNNER'] === '1';
|
|
22
|
-
delete process.env['CREWX_ASSIGNED_TASK_ID'];
|
|
23
|
-
delete process.env['CREWX_DETACHED_RUNNER'];
|
|
24
|
-
inheritedRunnerIdentity = { assignedTaskId, detachedRunner };
|
|
25
|
-
return inheritedRunnerIdentity;
|
|
26
|
-
}
|
|
27
|
-
/** Test-only reset for the module-level one-shot cache. */
|
|
28
|
-
function resetInheritedRunnerIdentityForTests() {
|
|
29
|
-
inheritedRunnerIdentity = undefined;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Read cross-process trace context from inherited environment variables.
|
|
33
|
-
*
|
|
34
|
-
* This is the ONLY place in the CLI that reads CREWX_PARENT_TASK_ID /
|
|
35
|
-
* CREWX_TRACE_ID / CREWX_CALLER_AGENT_ID. The values are passed as
|
|
36
|
-
* options.trace into crewx.query/execute so the SDK's ALS takes over
|
|
37
|
-
* from there — no direct env reads inside SDK code.
|
|
38
|
-
*
|
|
39
|
-
* Returns undefined when none of the three vars are set (root invocation).
|
|
40
|
-
*/
|
|
41
|
-
function readInheritedTrace() {
|
|
42
|
-
const parentTaskId = process.env['CREWX_PARENT_TASK_ID'] || null;
|
|
43
|
-
const rootTraceId = process.env['CREWX_TRACE_ID'] || null;
|
|
44
|
-
const callerAgentId = process.env['CREWX_CALLER_AGENT_ID'] || null;
|
|
45
|
-
if (!parentTaskId && !rootTraceId && !callerAgentId)
|
|
46
|
-
return undefined;
|
|
47
|
-
return {
|
|
48
|
-
parentTaskId,
|
|
49
|
-
rootTraceId: rootTraceId ?? (parentTaskId ?? ''),
|
|
50
|
-
callerAgentId,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Read the pre-assigned task id carried only by a detached runner.
|
|
55
|
-
*
|
|
56
|
-
* This is deliberately separate from readInheritedTrace(): trace variables
|
|
57
|
-
* describe the caller's chain and must not be used as this task's identity.
|
|
58
|
-
*/
|
|
59
|
-
function readRunnerAssignment() {
|
|
60
|
-
return consumeInheritedRunnerIdentity().assignedTaskId;
|
|
61
|
-
}
|
|
62
|
-
/** Return true only for the final detached runner process. */
|
|
63
|
-
function isDetachedRunner() {
|
|
64
|
-
return consumeInheritedRunnerIdentity().detachedRunner;
|
|
65
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.consumeInheritedRunnerIdentity=t;exports.resetInheritedRunnerIdentityForTests=d;exports.readInheritedTrace=u;exports.readRunnerAssignment=i;exports.isDetachedRunner=c;let n;function t(){if(n!==void 0)return n;const e=process.env["CREWX_ASSIGNED_TASK_ID"]?.trim()||void 0;const r=process.env["CREWX_DETACHED_RUNNER"]==="1";delete process.env["CREWX_ASSIGNED_TASK_ID"];delete process.env["CREWX_DETACHED_RUNNER"];n={assignedTaskId:e,detachedRunner:r};return n}function d(){n=void 0}function u(){const e=process.env["CREWX_PARENT_TASK_ID"]||null;const r=process.env["CREWX_TRACE_ID"]||null;const s=process.env["CREWX_CALLER_AGENT_ID"]||null;if(!e&&!r&&!s)return void 0;return{parentTaskId:e,rootTraceId:r??(e??""),callerAgentId:s}}function i(){return t().assignedTaskId}function c(){return t().detachedRunner}
|
|
@@ -1,39 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveProductRootFromCliEntry = resolveProductRootFromCliEntry;
|
|
4
|
-
const node_fs_1 = require("node:fs");
|
|
5
|
-
const node_path_1 = require("node:path");
|
|
6
|
-
const PRODUCT_BUNDLE_HELPER = (0, node_path_1.join)('dist-server', 'common', 'product-app-bundle.js');
|
|
7
|
-
/**
|
|
8
|
-
* Finds the installed product root from the CLI entry file that is running.
|
|
9
|
-
* The real CLI path is walked to the first package named `crewx`, which must
|
|
10
|
-
* contain the compiled bundle helper. cwd and environment are deliberately ignored.
|
|
11
|
-
*/
|
|
12
|
-
function resolveProductRootFromCliEntry(cliEntryPath) {
|
|
13
|
-
if (typeof cliEntryPath !== 'string' || cliEntryPath.trim().length === 0)
|
|
14
|
-
return undefined;
|
|
15
|
-
let realCliEntryPath;
|
|
16
|
-
try {
|
|
17
|
-
realCliEntryPath = (0, node_fs_1.realpathSync)(cliEntryPath);
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
let current = (0, node_path_1.dirname)(realCliEntryPath);
|
|
23
|
-
while (true) {
|
|
24
|
-
try {
|
|
25
|
-
const packageJson = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(current, 'package.json'), 'utf8'));
|
|
26
|
-
if (packageJson.name === 'crewx') {
|
|
27
|
-
return (0, node_fs_1.existsSync)((0, node_path_1.join)(current, PRODUCT_BUNDLE_HELPER)) ? current : undefined;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
// Continue to the next ancestor when this directory has no valid package manifest.
|
|
32
|
-
}
|
|
33
|
-
const parent = (0, node_path_1.dirname)(current);
|
|
34
|
-
if (parent === current)
|
|
35
|
-
return undefined;
|
|
36
|
-
current = parent;
|
|
37
|
-
}
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.resolveProductRootFromCliEntry=c;const t=require("node:fs");const n=require("node:path");const d=(0,n.join)("dist-server","common","product-app-bundle.js");function c(r){if(typeof r!=="string"||r.trim().length===0)return void 0;let o;try{o=(0,t.realpathSync)(r)}catch{return void 0}let e=(0,n.dirname)(o);while(true){try{const u=JSON.parse((0,t.readFileSync)((0,n.join)(e,"package.json"),"utf8"));if(u.name==="crewx"){return(0,t.existsSync)((0,n.join)(e,d))?e:void 0}}catch{}const i=(0,n.dirname)(e);if(i===e)return void 0;e=i}return void 0}
|
package/dist/utils/sdk-compat.js
CHANGED
|
@@ -1,120 +1 @@
|
|
|
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.sdkCompat = void 0;
|
|
37
|
-
exports.createSdkCompat = createSdkCompat;
|
|
38
|
-
const sdk = __importStar(require("@crewx/sdk"));
|
|
39
|
-
function formatLegacyArgv(argv) {
|
|
40
|
-
const formatter = sdk.formatCrewxExecutableArgv;
|
|
41
|
-
if (typeof formatter === 'function')
|
|
42
|
-
return formatter(argv);
|
|
43
|
-
// Older SDKs may expose the argv resolver before exposing its formatter.
|
|
44
|
-
// Keep this compatibility-only fallback one-way and quote every token.
|
|
45
|
-
if (process.platform === 'win32') {
|
|
46
|
-
return argv
|
|
47
|
-
.map((value) => {
|
|
48
|
-
const escaped = value
|
|
49
|
-
.replace(/(\\*)"/g, '$1$1\\"')
|
|
50
|
-
.replace(/(\\+)$/g, '$1$1');
|
|
51
|
-
return `"${escaped}"`;
|
|
52
|
-
})
|
|
53
|
-
.join(' ');
|
|
54
|
-
}
|
|
55
|
-
return argv.map((value) => `'${value.replace(/'/g, `'\\''`)}'`).join(' ');
|
|
56
|
-
}
|
|
57
|
-
const FALLBACK_CREWX_CLI_DISPLAY = 'crewx';
|
|
58
|
-
function missingCliResolver() {
|
|
59
|
-
return {
|
|
60
|
-
ok: false,
|
|
61
|
-
reason: 'The installed SDK does not expose the argv-based CrewX CLI resolver.',
|
|
62
|
-
attempts: [
|
|
63
|
-
{ stage: 'env', reason: 'argv resolver capability is unavailable' },
|
|
64
|
-
{ stage: 'self', reason: 'argv resolver capability is unavailable' },
|
|
65
|
-
{ stage: 'workspace', reason: 'argv resolver capability is unavailable' },
|
|
66
|
-
{ stage: 'module', reason: 'argv resolver capability is unavailable' },
|
|
67
|
-
{ stage: 'path', reason: 'argv resolver capability is unavailable' },
|
|
68
|
-
],
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Create the CLI bootstrap capability accessor for the installed SDK.
|
|
73
|
-
*
|
|
74
|
-
* SDK exports are additive across compatible majors, so an older SDK may not
|
|
75
|
-
* expose every capability that a newer CLI knows about. Optional capabilities
|
|
76
|
-
* are checked here rather than at each bootstrap call site.
|
|
77
|
-
*/
|
|
78
|
-
function createSdkCompat(sdkLike = sdk) {
|
|
79
|
-
return {
|
|
80
|
-
resolveCrewxCli: () => {
|
|
81
|
-
const configured = process.env.CREWX_CLI;
|
|
82
|
-
if (configured?.trim())
|
|
83
|
-
return configured;
|
|
84
|
-
if (typeof sdkLike.resolveCrewxCliArgv === 'function') {
|
|
85
|
-
const resolution = sdkLike.resolveCrewxCliArgv();
|
|
86
|
-
if (resolution.ok)
|
|
87
|
-
return formatLegacyArgv(resolution.argv);
|
|
88
|
-
}
|
|
89
|
-
if (typeof sdkLike.resolveCrewxCli === 'function') {
|
|
90
|
-
const value = sdkLike.resolveCrewxCli();
|
|
91
|
-
if (value.trim())
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
|
-
return FALLBACK_CREWX_CLI_DISPLAY;
|
|
95
|
-
},
|
|
96
|
-
resolveCrewxCliArgv: () => {
|
|
97
|
-
if (typeof sdkLike.resolveCrewxCliArgv === 'function') {
|
|
98
|
-
return sdkLike.resolveCrewxCliArgv();
|
|
99
|
-
}
|
|
100
|
-
return missingCliResolver();
|
|
101
|
-
},
|
|
102
|
-
resolveCrewxWorkspace: () => {
|
|
103
|
-
if (typeof sdkLike.resolveCrewxWorkspace === 'function') {
|
|
104
|
-
return sdkLike.resolveCrewxWorkspace();
|
|
105
|
-
}
|
|
106
|
-
return process.env.CREWX_WORKSPACE || process.cwd();
|
|
107
|
-
},
|
|
108
|
-
initPricingRemote: () => {
|
|
109
|
-
if (typeof sdkLike.initPricingRemote !== 'function')
|
|
110
|
-
return;
|
|
111
|
-
try {
|
|
112
|
-
void Promise.resolve(sdkLike.initPricingRemote()).catch(() => undefined);
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
// Remote pricing is optional and must not block CLI startup.
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
exports.sdkCompat = createSdkCompat();
|
|
1
|
+
"use strict";var l=exports&&exports.__createBinding||(Object.create?(function(e,r,t,n){if(n===void 0)n=t;var i=Object.getOwnPropertyDescriptor(r,t);if(!i||("get"in i?!r.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return r[t]}}}Object.defineProperty(e,n,i)}):(function(e,r,t,n){if(n===void 0)n=t;e[n]=r[t]}));var u=exports&&exports.__setModuleDefault||(Object.create?(function(e,r){Object.defineProperty(e,"default",{enumerable:true,value:r})}):function(e,r){e["default"]=r});var c=exports&&exports.__importStar||(function(){var e=function(r){e=Object.getOwnPropertyNames||function(t){var n=[];for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i))n[n.length]=i;return n};return e(r)};return function(r){if(r&&r.__esModule)return r;var t={};if(r!=null){for(var n=e(r),i=0;i<n.length;i++)if(n[i]!=="default")l(t,r,n[i])}u(t,r);return t}})();Object.defineProperty(exports,"__esModule",{value:true});exports.sdkCompat=void 0;exports.createSdkCompat=o;const a=c(require("@crewx/sdk"));function s(e){const r=a.formatCrewxExecutableArgv;if(typeof r==="function")return r(e);if(process.platform==="win32"){return e.map(t=>{const n=t.replace(/(\\*)"/g,'$1$1\\"').replace(/(\\+)$/g,"$1$1");return`"${n}"`}).join(" ")}return e.map(t=>`'${t.replace(/'/g,`'\\''`)}'`).join(" ")}const f="crewx";function v(){return{ok:false,reason:"The installed SDK does not expose the argv-based CrewX CLI resolver.",attempts:[{stage:"env",reason:"argv resolver capability is unavailable"},{stage:"self",reason:"argv resolver capability is unavailable"},{stage:"workspace",reason:"argv resolver capability is unavailable"},{stage:"module",reason:"argv resolver capability is unavailable"},{stage:"path",reason:"argv resolver capability is unavailable"}]}}function o(e=a){return{resolveCrewxCli:()=>{const r=process.env.CREWX_CLI;if(r?.trim())return r;if(typeof e.resolveCrewxCliArgv==="function"){const t=e.resolveCrewxCliArgv();if(t.ok)return s(t.argv)}if(typeof e.resolveCrewxCli==="function"){const t=e.resolveCrewxCli();if(t.trim())return t}return f},resolveCrewxCliArgv:()=>{if(typeof e.resolveCrewxCliArgv==="function"){return e.resolveCrewxCliArgv()}return v()},resolveCrewxWorkspace:()=>{if(typeof e.resolveCrewxWorkspace==="function"){return e.resolveCrewxWorkspace()}return process.env.CREWX_WORKSPACE||process.cwd()},initPricingRemote:()=>{if(typeof e.initPricingRemote!=="function")return;try{void Promise.resolve(e.initPricingRemote()).catch(()=>void 0)}catch{}}}}exports.sdkCompat=o();
|
package/dist/utils/version.js
CHANGED
|
@@ -1,28 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLI_VERSION = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
/**
|
|
7
|
-
* Return the installed @crewx/cli package version.
|
|
8
|
-
*
|
|
9
|
-
* Resolution strategy (mirrors cli-bak version.ts):
|
|
10
|
-
* 1. Read the package.json that is co-located with the compiled dist tree.
|
|
11
|
-
* At runtime __dirname resolves to dist/utils/, so ../../package.json
|
|
12
|
-
* reaches the package root — both in development and in an npm-installed
|
|
13
|
-
* deployment (node_modules/@crewx/cli/package.json).
|
|
14
|
-
* 2. Fall back to '0.0.0' on any I/O or parse error.
|
|
15
|
-
*
|
|
16
|
-
* Result is cached in the module-level constant to avoid repeated disk reads.
|
|
17
|
-
*/
|
|
18
|
-
function readVersion() {
|
|
19
|
-
try {
|
|
20
|
-
const pkgPath = (0, path_1.join)(__dirname, '../../package.json');
|
|
21
|
-
const pkg = JSON.parse((0, fs_1.readFileSync)(pkgPath, 'utf8'));
|
|
22
|
-
return pkg.version ?? '0.0.0';
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
return '0.0.0';
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.CLI_VERSION = readVersion();
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CLI_VERSION=void 0;const t=require("fs");const n=require("path");function o(){try{const e=(0,n.join)(__dirname,"../../package.json");const r=JSON.parse((0,t.readFileSync)(e,"utf8"));return r.version??"0.0.0"}catch{return"0.0.0"}}exports.CLI_VERSION=o();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewx/cli",
|
|
3
|
-
"version": "0.9.0-rc.
|
|
3
|
+
"version": "0.9.0-rc.147",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19.0"
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"better-sqlite3": "*",
|
|
26
26
|
"dotenv": "17.2.3",
|
|
27
27
|
"isomorphic-git": "1.37.1",
|
|
28
|
-
"@crewx/
|
|
29
|
-
"@crewx/
|
|
30
|
-
"@crewx/
|
|
31
|
-
"@crewx/
|
|
32
|
-
"@crewx/cron": "0.1.10-rc.
|
|
33
|
-
"@crewx/
|
|
34
|
-
"@crewx/
|
|
35
|
-
"@crewx/
|
|
36
|
-
"@crewx/
|
|
37
|
-
"@crewx/chromex": "0.1.0-rc.
|
|
38
|
-
"@crewx/shared": "0.0.6-rc.
|
|
39
|
-
"@crewx/app": "0.1.0-rc.
|
|
40
|
-
"@crewx/
|
|
41
|
-
"@crewx/
|
|
28
|
+
"@crewx/sdk": "0.9.0-rc.147",
|
|
29
|
+
"@crewx/knowledge-core": "0.1.17-rc.157",
|
|
30
|
+
"@crewx/search": "0.1.10-rc.143",
|
|
31
|
+
"@crewx/doc": "0.1.9-rc.140",
|
|
32
|
+
"@crewx/cron": "0.1.10-rc.182",
|
|
33
|
+
"@crewx/workflow": "0.3.22-rc.193",
|
|
34
|
+
"@crewx/memory": "0.1.23-rc.164",
|
|
35
|
+
"@crewx/skill": "0.1.20-rc.41",
|
|
36
|
+
"@crewx/wbs": "0.1.10-rc.173",
|
|
37
|
+
"@crewx/chromex": "0.1.0-rc.180",
|
|
38
|
+
"@crewx/shared": "0.0.6-rc.62",
|
|
39
|
+
"@crewx/app": "0.1.0-rc.28",
|
|
40
|
+
"@crewx/notify": "0.1.0-rc.118",
|
|
41
|
+
"@crewx/wi": "0.1.10-rc.167"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/better-sqlite3": "*",
|