@crewx/cli 0.9.0-rc.12 → 0.9.0-rc.121
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.d.ts +13 -0
- package/dist/bootstrap/codex-writable-roots.js +25 -0
- package/dist/bootstrap/crewx-cli.js +27 -6
- package/dist/builtin.js +2 -0
- package/dist/commands/agent.js +1 -107
- package/dist/commands/cal.d.ts +15 -0
- package/dist/commands/cal.js +44 -0
- package/dist/commands/db.d.ts +2 -0
- package/dist/commands/db.js +381 -1
- package/dist/commands/detached.d.ts +89 -0
- package/dist/commands/detached.js +592 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.js +474 -21
- package/dist/commands/emit-trailer.d.ts +25 -0
- package/dist/commands/emit-trailer.js +33 -0
- package/dist/commands/execute.d.ts +7 -4
- package/dist/commands/execute.js +171 -41
- package/dist/commands/hook/command-marker.d.ts +2 -0
- package/dist/commands/hook/command-marker.js +5 -0
- package/dist/commands/hook/install.d.ts +0 -1
- package/dist/commands/hook/install.js +75 -61
- package/dist/commands/hook/status.js +3 -3
- package/dist/commands/hook/uninstall.js +2 -2
- package/dist/commands/init.d.ts +34 -0
- package/dist/commands/init.js +130 -57
- package/dist/commands/kill.d.ts +2 -8
- package/dist/commands/kill.js +6 -47
- package/dist/commands/log.js +4 -3
- package/dist/commands/parse-common-flags.d.ts +5 -1
- package/dist/commands/parse-common-flags.js +6 -2
- package/dist/commands/ps.d.ts +2 -2
- package/dist/commands/ps.js +25 -15
- package/dist/commands/publish.d.ts +1 -0
- package/dist/commands/publish.js +303 -0
- package/dist/commands/query.d.ts +5 -1
- package/dist/commands/query.js +165 -37
- package/dist/commands/registry.js +4 -2
- package/dist/commands/result.d.ts +8 -3
- package/dist/commands/result.js +139 -7
- package/dist/commands/shortcut.d.ts +1 -0
- package/dist/commands/shortcut.js +267 -0
- package/dist/commands/slack.js +2 -1
- package/dist/commands/stop.d.ts +8 -0
- package/dist/commands/stop.js +119 -0
- package/dist/commands/write-output.d.ts +3 -0
- package/dist/commands/write-output.js +24 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -1
- package/dist/logging.d.ts +1 -1
- package/dist/logging.js +3 -2
- package/dist/main.d.ts +3 -2
- package/dist/main.js +84 -18
- package/dist/utils/env-defaults.d.ts +2 -5
- package/dist/utils/env-defaults.js +10 -5
- package/dist/utils/inherited-trace.d.ts +24 -0
- package/dist/utils/inherited-trace.js +40 -0
- package/dist/utils/sdk-compat.d.ts +24 -0
- package/dist/utils/sdk-compat.js +120 -0
- package/package.json +16 -12
package/dist/logging.js
CHANGED
|
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.attachFileLogger = attachFileLogger;
|
|
15
15
|
const fs_1 = require("fs");
|
|
16
16
|
const path_1 = require("path");
|
|
17
|
+
const sdk_1 = require("@crewx/sdk");
|
|
17
18
|
const CREWX_VERSION = '0.9.0-alpha.1';
|
|
18
19
|
/** Format Date as YYYYMMDDTHHmmss (local time) */
|
|
19
20
|
function formatTimestamp(date) {
|
|
@@ -52,7 +53,7 @@ function attachFileLogger(crewx, workspaceRoot) {
|
|
|
52
53
|
`CrewX Version: ${CREWX_VERSION}\n` +
|
|
53
54
|
`Mode: ${event.mode}\n` +
|
|
54
55
|
`Agent: ${event.agentRef}\n` +
|
|
55
|
-
`Started: ${event.timestamp
|
|
56
|
+
`Started: ${(0, sdk_1.formatDisplayTimestamp)(event.timestamp)}\n` +
|
|
56
57
|
`Message: ${event.message}\n` +
|
|
57
58
|
`\n`;
|
|
58
59
|
(0, fs_1.writeFileSync)(logFile, header, { encoding: 'utf8', mode: 0o600 });
|
|
@@ -66,7 +67,7 @@ function attachFileLogger(crewx, workspaceRoot) {
|
|
|
66
67
|
const logFile = logFiles.get(event.traceId);
|
|
67
68
|
if (!logFile)
|
|
68
69
|
return;
|
|
69
|
-
const ts = new Date()
|
|
70
|
+
const ts = (0, sdk_1.formatDisplayTimestamp)(new Date());
|
|
70
71
|
const status = event.error
|
|
71
72
|
? `failed: ${event.error.message}`
|
|
72
73
|
: 'completed successfully';
|
package/dist/main.d.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Boot sequence:
|
|
7
7
|
* 1. Inject CREWX_CLI / CREWX_WORKSPACE env defaults (must be first)
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
8
|
+
* 2. Load workspace and ~/.crewx .env files (does not override process.env)
|
|
9
|
+
* 3. Parse command
|
|
10
|
+
* 4. Dispatch to handler
|
|
10
11
|
*/
|
|
11
12
|
export {};
|
package/dist/main.js
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Boot sequence:
|
|
8
8
|
* 1. Inject CREWX_CLI / CREWX_WORKSPACE env defaults (must be first)
|
|
9
|
-
* 2.
|
|
10
|
-
* 3.
|
|
9
|
+
* 2. Load workspace and ~/.crewx .env files (does not override process.env)
|
|
10
|
+
* 3. Parse command
|
|
11
|
+
* 4. Dispatch to handler
|
|
11
12
|
*/
|
|
12
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
14
|
if (k2 === undefined) k2 = k;
|
|
@@ -45,26 +46,36 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
45
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
47
|
// ─── P0-1: Env Bootstrap ─────────────────────────────────────────────────────
|
|
47
48
|
// Must run before any other code that might use process.env.CREWX_CLI.
|
|
48
|
-
const
|
|
49
|
+
const sdk_compat_1 = require("./utils/sdk-compat");
|
|
50
|
+
const account_1 = require("@crewx/sdk/account");
|
|
49
51
|
const sdk_1 = require("@crewx/sdk");
|
|
50
|
-
|
|
51
|
-
process.env.
|
|
52
|
+
const inherited_trace_1 = require("./utils/inherited-trace");
|
|
53
|
+
process.env.CREWX_CLI ??= sdk_compat_1.sdkCompat.resolveCrewxCli();
|
|
54
|
+
process.env.CREWX_WORKSPACE ??= sdk_compat_1.sdkCompat.resolveCrewxWorkspace();
|
|
55
|
+
// Load workspace .env before ~/.crewx/.env. The SDK-owned loader keeps CLI and
|
|
56
|
+
// server bootstrap on the same process > workspace > home precedence contract.
|
|
57
|
+
(0, account_1.loadCrewxEnvFiles)();
|
|
58
|
+
// Receipt runner identity is a one-hop capability. Consume it before any
|
|
59
|
+
// command/provider code can spawn a child process.
|
|
60
|
+
(0, inherited_trace_1.consumeInheritedRunnerIdentity)();
|
|
52
61
|
// ─── Pricing remote override (WI-20260701-002) ───────────────────────────────
|
|
53
62
|
// Best-effort, non-blocking: fetch remote model registry so new models get
|
|
54
63
|
// accurate pricing without a CLI republish. Falls back to bundled table on
|
|
55
64
|
// failure / offline. Browser entry does not call this automatically.
|
|
56
|
-
|
|
65
|
+
sdk_compat_1.sdkCompat.initPricingRemote();
|
|
57
66
|
// ─── Command Imports ──────────────────────────────────────────────────────────
|
|
58
67
|
const query_1 = require("./commands/query");
|
|
59
68
|
const execute_1 = require("./commands/execute");
|
|
60
69
|
const agent_1 = require("./commands/agent");
|
|
61
70
|
const ps_1 = require("./commands/ps");
|
|
62
|
-
const
|
|
71
|
+
const stop_1 = require("./commands/stop");
|
|
63
72
|
const result_1 = require("./commands/result");
|
|
64
73
|
const restart_1 = require("./commands/restart");
|
|
65
74
|
const log_1 = require("./commands/log");
|
|
66
75
|
const doctor_1 = require("./commands/doctor");
|
|
67
76
|
const init_1 = require("./commands/init");
|
|
77
|
+
const shortcut_1 = require("./commands/shortcut");
|
|
78
|
+
const publish_1 = require("./commands/publish");
|
|
68
79
|
const builtin_1 = require("./builtin");
|
|
69
80
|
const slack_1 = require("./commands/slack");
|
|
70
81
|
const install_1 = require("./commands/hook/install");
|
|
@@ -75,6 +86,7 @@ const db_1 = require("./commands/db");
|
|
|
75
86
|
const parse_common_flags_1 = require("./commands/parse-common-flags");
|
|
76
87
|
const registry_1 = require("./commands/registry");
|
|
77
88
|
const version_1 = require("./utils/version");
|
|
89
|
+
const emit_trailer_1 = require("./commands/emit-trailer");
|
|
78
90
|
/**
|
|
79
91
|
* Dev-only SSOT assertion: bin/cli-commands.js must be the exact union of
|
|
80
92
|
* KNOWN_COMMANDS ∪ BUILTIN_COMMAND_NAMES ∪ NOT_YET_MIGRATED from registry.ts.
|
|
@@ -99,7 +111,7 @@ async function assertSsotParity() {
|
|
|
99
111
|
(extra.length ? ` CLI_SUBCOMMANDS has, registry missing: ${extra.join(', ')}` : ''));
|
|
100
112
|
}
|
|
101
113
|
}
|
|
102
|
-
async function main() {
|
|
114
|
+
async function main(emitState) {
|
|
103
115
|
if (process.env['NODE_ENV'] === 'development') {
|
|
104
116
|
await assertSsotParity();
|
|
105
117
|
}
|
|
@@ -119,11 +131,11 @@ async function main() {
|
|
|
119
131
|
// P0-2: q/x aliases
|
|
120
132
|
case 'q':
|
|
121
133
|
case 'query':
|
|
122
|
-
await (0, query_1.handleQuery)(args.slice(1));
|
|
134
|
+
await (0, query_1.handleQuery)(args.slice(1), command, emitState);
|
|
123
135
|
return;
|
|
124
136
|
case 'x':
|
|
125
137
|
case 'execute':
|
|
126
|
-
await (0, execute_1.handleExecute)(args.slice(1));
|
|
138
|
+
await (0, execute_1.handleExecute)(args.slice(1), command, emitState);
|
|
127
139
|
return;
|
|
128
140
|
case 'agent':
|
|
129
141
|
await (0, agent_1.handleAgent)(args.slice(1));
|
|
@@ -132,9 +144,12 @@ async function main() {
|
|
|
132
144
|
case 'ps':
|
|
133
145
|
await (0, ps_1.handlePs)(args.slice(1));
|
|
134
146
|
return;
|
|
135
|
-
//
|
|
147
|
+
// Task stop (kill is a compatibility alias)
|
|
148
|
+
case 'stop':
|
|
149
|
+
await (0, stop_1.handleStop)(args.slice(1), 'stop');
|
|
150
|
+
return;
|
|
136
151
|
case 'kill':
|
|
137
|
-
await (0,
|
|
152
|
+
await (0, stop_1.handleStop)(args.slice(1), 'kill');
|
|
138
153
|
return;
|
|
139
154
|
// P0-6: result
|
|
140
155
|
case 'result':
|
|
@@ -157,7 +172,8 @@ async function main() {
|
|
|
157
172
|
const initArgs = args.slice(1);
|
|
158
173
|
const force = initArgs.includes('--force') || initArgs.includes('-f');
|
|
159
174
|
try {
|
|
160
|
-
const
|
|
175
|
+
const provider = (0, init_1.parseInitProvider)(initArgs);
|
|
176
|
+
const r = await (0, init_1.handleInit)({ path: process.cwd(), force, provider });
|
|
161
177
|
if (r.skippedReason === 'yaml-exists') {
|
|
162
178
|
console.log('✓ crewx.yaml already exists (use --force to overwrite)');
|
|
163
179
|
}
|
|
@@ -167,6 +183,10 @@ async function main() {
|
|
|
167
183
|
if (r.errors.length > 0)
|
|
168
184
|
console.warn('Warnings:', r.errors.join('; '));
|
|
169
185
|
}
|
|
186
|
+
const profile = (0, sdk_1.getDefaultAgentProfile)(r.provider);
|
|
187
|
+
if (profile) {
|
|
188
|
+
console.log(`✓ default agents: ${r.provider} (${profile.planner.model} / ${profile.worker.model})`);
|
|
189
|
+
}
|
|
170
190
|
if (r.workspaceId)
|
|
171
191
|
console.log(`✓ workspace registered (id=${r.workspaceId}, slug=${r.slug})`);
|
|
172
192
|
console.log('✓ done');
|
|
@@ -181,6 +201,14 @@ async function main() {
|
|
|
181
201
|
case 'db':
|
|
182
202
|
await (0, db_1.handleDb)(args.slice(1));
|
|
183
203
|
return;
|
|
204
|
+
// Windows Desktop shortcut: crewx shortcut status|install|uninstall
|
|
205
|
+
case 'shortcut':
|
|
206
|
+
await (0, shortcut_1.handleShortcut)(args.slice(1));
|
|
207
|
+
return;
|
|
208
|
+
// crewx publish [dir] [--dry-run] [--version <semver>] [--json] [--upload]
|
|
209
|
+
case 'publish':
|
|
210
|
+
await (0, publish_1.handlePublish)(args.slice(1));
|
|
211
|
+
return;
|
|
184
212
|
// SDK-009: slack / slack:files
|
|
185
213
|
case 'slack':
|
|
186
214
|
case 'slack:files':
|
|
@@ -262,12 +290,19 @@ Query / Execute:
|
|
|
262
290
|
--verbose Debug output mode (default: raw response only)
|
|
263
291
|
--config/-c <path> Config file path (default: CREWX_CONFIG or crewx.yaml)
|
|
264
292
|
--output-format <fmt> Output format (json|text|stream-json)
|
|
293
|
+
--out/-o <path> Save result to file (stdout suppressed)
|
|
265
294
|
--effort <level> Model effort (high|medium|low)
|
|
266
295
|
-f/--prompt-file <path> Read task body from file (bypasses argv length limits)
|
|
267
296
|
--var key=value Template variable (repeatable). Accessible as {{key}} in agent prompt.
|
|
268
297
|
-- End of flags; remaining tokens treated as message text
|
|
269
298
|
e.g. crewx q "@agent label" -- --flag-in-message
|
|
270
299
|
|
|
300
|
+
q/query/x/execute:
|
|
301
|
+
--detach/--async Persist a receipt, launch a detached runner, and print task-id
|
|
302
|
+
(automatic inside an agent process; q/x stay synchronous elsewhere).
|
|
303
|
+
--wait Force synchronous execution, including inside an agent process.
|
|
304
|
+
e.g. crewx x "@agent label" --detach
|
|
305
|
+
|
|
271
306
|
Agent Management:
|
|
272
307
|
agent ls [options] List configured agents
|
|
273
308
|
--role <value> Filter by role (comma-separated for OR match)
|
|
@@ -277,20 +312,39 @@ Agent Management:
|
|
|
277
312
|
|
|
278
313
|
Task Management:
|
|
279
314
|
ps List running tasks
|
|
280
|
-
|
|
281
|
-
|
|
315
|
+
stop <task-id> Stop a running task (cooperative, then forced)
|
|
316
|
+
stop --all Stop all running tasks
|
|
317
|
+
kill <task-id> Alias for stop
|
|
282
318
|
result [task-id] Get task result (or list recent tasks)
|
|
319
|
+
--wait=N Poll (1s interval) up to N seconds for the task to
|
|
320
|
+
finish. Exit 124 on timeout. --wait=0 = single check.
|
|
283
321
|
restart <task-id> Restart a failed task as a new task
|
|
284
322
|
|
|
285
323
|
Logs & Diagnostics:
|
|
286
324
|
log [ls|<task-id>] View task logs
|
|
287
325
|
doctor [--config <path>] Run system diagnosis
|
|
288
|
-
init [--force] [--
|
|
326
|
+
init [--force] [--provider cli/claude|cli/codex] Initialize crewx.yaml
|
|
289
327
|
|
|
290
328
|
Database:
|
|
291
329
|
db push Sync DB schema to current code (additive only)
|
|
292
330
|
--force Reset migration history + skip confirmation
|
|
293
331
|
--dry-run Preview changes without applying
|
|
332
|
+
db migrate-task-logs Backfill legacy tasks.logs into task_log_events
|
|
333
|
+
--dry-run Validate and estimate without writing
|
|
334
|
+
--apply Consistent backup + resumable task-by-task apply
|
|
335
|
+
--verify Check event/source invariants and parity
|
|
336
|
+
|
|
337
|
+
Desktop Shortcut (Windows only):
|
|
338
|
+
shortcut status [--json] Show current shortcut status
|
|
339
|
+
shortcut install [--force] [--json] Install/repair the Desktop shortcut
|
|
340
|
+
shortcut uninstall [--json] Remove the Desktop shortcut
|
|
341
|
+
|
|
342
|
+
Publish:
|
|
343
|
+
publish [dir] [options] Package a workspace as a distributable template archive
|
|
344
|
+
--dry-run Scan + build manifest only; do not write a .tgz
|
|
345
|
+
--version <ver> Override manifest version (semver)
|
|
346
|
+
--json Print machine-readable JSON to stdout
|
|
347
|
+
--upload Submit + upload using the SDK account session
|
|
294
348
|
|
|
295
349
|
Built-in Tools:
|
|
296
350
|
memory <args> Memory tool
|
|
@@ -312,7 +366,19 @@ Global Options:
|
|
|
312
366
|
--version, -v Show version
|
|
313
367
|
`.trim());
|
|
314
368
|
}
|
|
315
|
-
|
|
369
|
+
function getProcessExitCode(error) {
|
|
370
|
+
if (error instanceof parse_common_flags_1.UnknownOptionError)
|
|
371
|
+
return 2;
|
|
372
|
+
if (typeof error === 'object' && error !== null && 'exitCode' in error) {
|
|
373
|
+
const exitCode = error.exitCode;
|
|
374
|
+
if (typeof exitCode === 'number')
|
|
375
|
+
return exitCode;
|
|
376
|
+
}
|
|
377
|
+
return 1;
|
|
378
|
+
}
|
|
379
|
+
const emitState = (0, emit_trailer_1.createDelegationEmitState)();
|
|
380
|
+
main(emitState).catch((err) => {
|
|
316
381
|
console.error(err instanceof Error ? err.message : String(err));
|
|
317
|
-
|
|
382
|
+
(0, emit_trailer_1.emitDelegationResult)({ command: process.argv[2], isError: true, state: emitState });
|
|
383
|
+
process.exit(getProcessExitCode(err));
|
|
318
384
|
});
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Re-exported from @crewx/sdk for convenience.
|
|
4
|
-
*/
|
|
5
|
-
export { resolveCrewxCli, resolveCrewxWorkspace } from '@crewx/sdk';
|
|
1
|
+
export declare function resolveCrewxCli(): string;
|
|
2
|
+
export declare function resolveCrewxWorkspace(): string;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveCrewxCli = resolveCrewxCli;
|
|
4
|
+
exports.resolveCrewxWorkspace = resolveCrewxWorkspace;
|
|
4
5
|
/**
|
|
5
6
|
* CREWX_* environment variable defaults for CLI bootstrap.
|
|
6
|
-
*
|
|
7
|
+
* Routed through the SDK compatibility accessor for older SDK installations.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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,4 +1,19 @@
|
|
|
1
1
|
import type { TraceContext } from '@crewx/sdk';
|
|
2
|
+
export interface InheritedRunnerIdentity {
|
|
3
|
+
assignedTaskId?: string;
|
|
4
|
+
detachedRunner: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Consume the runner-only identity exactly once.
|
|
8
|
+
*
|
|
9
|
+
* These variables are a one-hop capability, not trace context. Keeping the
|
|
10
|
+
* values in this module lets the current CLI process use them while deleting
|
|
11
|
+
* them from process.env prevents later child processes from inheriting the
|
|
12
|
+
* receipt runner identity.
|
|
13
|
+
*/
|
|
14
|
+
export declare function consumeInheritedRunnerIdentity(): InheritedRunnerIdentity;
|
|
15
|
+
/** Test-only reset for the module-level one-shot cache. */
|
|
16
|
+
export declare function resetInheritedRunnerIdentityForTests(): void;
|
|
2
17
|
/**
|
|
3
18
|
* Read cross-process trace context from inherited environment variables.
|
|
4
19
|
*
|
|
@@ -10,3 +25,12 @@ import type { TraceContext } from '@crewx/sdk';
|
|
|
10
25
|
* Returns undefined when none of the three vars are set (root invocation).
|
|
11
26
|
*/
|
|
12
27
|
export declare function readInheritedTrace(): TraceContext | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Read the pre-assigned task id carried only by a detached runner.
|
|
30
|
+
*
|
|
31
|
+
* This is deliberately separate from readInheritedTrace(): trace variables
|
|
32
|
+
* describe the caller's chain and must not be used as this task's identity.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readRunnerAssignment(): string | undefined;
|
|
35
|
+
/** Return true only for the final detached runner process. */
|
|
36
|
+
export declare function isDetachedRunner(): boolean;
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.consumeInheritedRunnerIdentity = consumeInheritedRunnerIdentity;
|
|
4
|
+
exports.resetInheritedRunnerIdentityForTests = resetInheritedRunnerIdentityForTests;
|
|
3
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
|
+
}
|
|
4
31
|
/**
|
|
5
32
|
* Read cross-process trace context from inherited environment variables.
|
|
6
33
|
*
|
|
@@ -23,3 +50,16 @@ function readInheritedTrace() {
|
|
|
23
50
|
callerAgentId,
|
|
24
51
|
};
|
|
25
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
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CrewxExecutableResolution } from '@crewx/sdk';
|
|
2
|
+
type PricingInitializer = () => Promise<unknown> | unknown;
|
|
3
|
+
export interface SdkLike {
|
|
4
|
+
resolveCrewxCli?: () => string;
|
|
5
|
+
resolveCrewxCliArgv?: () => CrewxExecutableResolution;
|
|
6
|
+
resolveCrewxWorkspace?: () => string;
|
|
7
|
+
initPricingRemote?: PricingInitializer;
|
|
8
|
+
}
|
|
9
|
+
export interface SdkCompat {
|
|
10
|
+
resolveCrewxCli(): string;
|
|
11
|
+
resolveCrewxCliArgv(): CrewxExecutableResolution;
|
|
12
|
+
resolveCrewxWorkspace(): string;
|
|
13
|
+
initPricingRemote(): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create the CLI bootstrap capability accessor for the installed SDK.
|
|
17
|
+
*
|
|
18
|
+
* SDK exports are additive across compatible majors, so an older SDK may not
|
|
19
|
+
* expose every capability that a newer CLI knows about. Optional capabilities
|
|
20
|
+
* are checked here rather than at each bootstrap call site.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createSdkCompat(sdkLike?: SdkLike): SdkCompat;
|
|
23
|
+
export declare const sdkCompat: SdkCompat;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
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();
|
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.121",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19.0"
|
|
@@ -23,18 +23,22 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@crewx/adapter-slack": "0.1.4",
|
|
25
25
|
"better-sqlite3": "*",
|
|
26
|
+
"dotenv": "17.2.3",
|
|
26
27
|
"isomorphic-git": "1.37.1",
|
|
27
|
-
"@crewx/sdk": "0.9.0-rc.
|
|
28
|
-
"@crewx/
|
|
29
|
-
"@crewx/
|
|
30
|
-
"@crewx/
|
|
31
|
-
"@crewx/
|
|
32
|
-
"@crewx/
|
|
33
|
-
"@crewx/
|
|
34
|
-
"@crewx/
|
|
35
|
-
"@crewx/
|
|
36
|
-
"@crewx/
|
|
37
|
-
"@crewx/
|
|
28
|
+
"@crewx/sdk": "0.9.0-rc.121",
|
|
29
|
+
"@crewx/knowledge-core": "0.1.17-rc.131",
|
|
30
|
+
"@crewx/memory": "0.1.23-rc.138",
|
|
31
|
+
"@crewx/search": "0.1.10-rc.117",
|
|
32
|
+
"@crewx/doc": "0.1.9-rc.114",
|
|
33
|
+
"@crewx/wbs": "0.1.10-rc.147",
|
|
34
|
+
"@crewx/workflow": "0.3.22-rc.167",
|
|
35
|
+
"@crewx/skill": "0.1.20-rc.15",
|
|
36
|
+
"@crewx/cron": "0.1.10-rc.156",
|
|
37
|
+
"@crewx/notify": "0.1.0-rc.92",
|
|
38
|
+
"@crewx/wi": "0.1.10-rc.141",
|
|
39
|
+
"@crewx/app": "0.1.0-rc.2",
|
|
40
|
+
"@crewx/chromex": "0.1.0-rc.154",
|
|
41
|
+
"@crewx/shared": "0.0.6-rc.36"
|
|
38
42
|
},
|
|
39
43
|
"devDependencies": {
|
|
40
44
|
"@types/better-sqlite3": "*",
|