@crewx/cli 0.9.0-rc.15 ā 0.9.0-rc.150
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 +20 -1
- package/dist/bootstrap/codex-writable-roots.js +1 -88
- package/dist/bootstrap/crewx-cli.js +1 -63
- package/dist/builtin.d.ts +1 -1
- package/dist/builtin.js +5 -127
- package/dist/commands/agent.js +4 -224
- package/dist/commands/cal.d.ts +15 -0
- package/dist/commands/cal.js +2 -0
- package/dist/commands/db.d.ts +3 -0
- package/dist/commands/db.js +59 -125
- package/dist/commands/detached.d.ts +95 -0
- package/dist/commands/detached.js +15 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.js +4 -196
- package/dist/commands/emit-trailer.d.ts +25 -0
- package/dist/commands/emit-trailer.js +2 -0
- package/dist/commands/execute.d.ts +8 -4
- package/dist/commands/execute.js +15 -146
- package/dist/commands/hook/command-marker.d.ts +2 -0
- package/dist/commands/hook/command-marker.js +1 -0
- package/dist/commands/hook/install.d.ts +0 -1
- package/dist/commands/hook/install.js +8 -175
- 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.d.ts +34 -0
- package/dist/commands/init.js +37 -370
- package/dist/commands/kill.d.ts +2 -8
- package/dist/commands/kill.js +1 -52
- package/dist/commands/log.js +3 -95
- package/dist/commands/parse-agent-message.js +1 -52
- package/dist/commands/parse-common-flags.d.ts +5 -1
- package/dist/commands/parse-common-flags.js +3 -181
- package/dist/commands/ps.d.ts +2 -2
- package/dist/commands/ps.js +2 -107
- package/dist/commands/publish.d.ts +1 -0
- package/dist/commands/publish.js +27 -0
- package/dist/commands/query.d.ts +7 -2
- package/dist/commands/query.js +16 -146
- package/dist/commands/registry.js +1 -31
- package/dist/commands/resolve-prompt.js +3 -54
- package/dist/commands/resolve-recipient.d.ts +14 -0
- package/dist/commands/resolve-recipient.js +3 -0
- package/dist/commands/restart.d.ts +3 -1
- package/dist/commands/restart.js +18 -162
- package/dist/commands/result.d.ts +8 -3
- package/dist/commands/result.js +1 -70
- package/dist/commands/shortcut.d.ts +1 -0
- package/dist/commands/shortcut.js +18 -0
- package/dist/commands/slack.js +16 -559
- package/dist/commands/stop.d.ts +8 -0
- package/dist/commands/stop.js +8 -0
- package/dist/commands/write-output.js +1 -24
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -5
- package/dist/logging.d.ts +1 -1
- package/dist/logging.js +10 -86
- package/dist/main.d.ts +3 -2
- package/dist/main.js +44 -253
- 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.d.ts +2 -5
- package/dist/utils/env-defaults.js +1 -10
- package/dist/utils/inherited-trace.d.ts +24 -0
- package/dist/utils/inherited-trace.js +1 -25
- package/dist/utils/product-package-root.d.ts +6 -0
- package/dist/utils/product-package-root.js +1 -0
- package/dist/utils/sdk-compat.d.ts +24 -0
- package/dist/utils/sdk-compat.js +1 -0
- package/dist/utils/version.js +1 -28
- package/package.json +16 -12
|
@@ -33,10 +33,29 @@ export declare function escapeTomlBasicString(value: string): string;
|
|
|
33
33
|
* Works for both `codex exec` and `codex exec resume` (config-override form).
|
|
34
34
|
*/
|
|
35
35
|
export declare function buildCodexWritableRootArgs(crewxHome: string): string[];
|
|
36
|
+
/**
|
|
37
|
+
* Create an `AdditionalArgsProvider` that skips Codex's git repository trust
|
|
38
|
+
* check for a resolved workspace.
|
|
39
|
+
*
|
|
40
|
+
* The workspace is resolved by the product layer, so an unavailable workspace
|
|
41
|
+
* must not fall back to the host cwd. The flag is independent of execution
|
|
42
|
+
* mode because it controls repository trust rather than filesystem access.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createCodexSkipGitRepoCheckProvider(workspaceRoot: string | undefined): AdditionalArgsProvider;
|
|
45
|
+
/**
|
|
46
|
+
* Compose product-layer argument providers while preserving their order.
|
|
47
|
+
*/
|
|
48
|
+
export declare function composeAdditionalArgsProviders(...providers: AdditionalArgsProvider[]): AdditionalArgsProvider;
|
|
36
49
|
/**
|
|
37
50
|
* Create an `AdditionalArgsProvider` (SDK extension point, WI-20260703-001)
|
|
38
51
|
* that injects CrewX home as a Codex writable root for `workspace-write`
|
|
39
|
-
* equivalent modes (`agent`, `auto`, `undefined`).
|
|
52
|
+
* equivalent modes (`agent`, `auto`, `undefined`). Only explicit `agent`
|
|
53
|
+
* also receives a permission profile allowing localhost network access and
|
|
54
|
+
* writes to the same CrewX home. `auto`/`undefined` keep their existing policy.
|
|
55
|
+
*
|
|
56
|
+
* All overrides use `-c`, supported by both `exec` and `exec resume`. Keep
|
|
57
|
+
* writable_roots for older Codex versions that ignore permission profiles
|
|
58
|
+
* and fall back to the closed workspace-write sandbox. No version gate.
|
|
40
59
|
*
|
|
41
60
|
* No-ops for:
|
|
42
61
|
* - Non-codex providers.
|
|
@@ -1,88 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* CLI-layer policy: inject CrewX home as an extra writable root for Codex
|
|
4
|
-
* `workspace-write` sandbox invocations.
|
|
5
|
-
*
|
|
6
|
-
* Why this lives in packages/cli (not packages/sdk):
|
|
7
|
-
* CrewX home (`~/.crewx` by default) is a product-specific path. The SDK's
|
|
8
|
-
* `additionalArgsProvider` extension point (WI-20260703-001) exists precisely
|
|
9
|
-
* so that product layers like this CLI can inject such paths without the SDK
|
|
10
|
-
* knowing about them.
|
|
11
|
-
*
|
|
12
|
-
* Why `-c sandbox_workspace_write.writable_roots=[...]` instead of `--add-dir`:
|
|
13
|
-
* Verified against codex-cli 0.139.0 (`codex exec --help` / `codex exec resume --help`):
|
|
14
|
-
* - `codex exec` supports `--add-dir <DIR>`.
|
|
15
|
-
* - `codex exec resume` does NOT support `--add-dir` (only `-c/--config`).
|
|
16
|
-
* Using the `-c` config-override form works identically for both `exec` and
|
|
17
|
-
* `exec resume`, avoiding a resume-incompatible flag.
|
|
18
|
-
*/
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.resolveCrewxHome = resolveCrewxHome;
|
|
21
|
-
exports.escapeTomlBasicString = escapeTomlBasicString;
|
|
22
|
-
exports.buildCodexWritableRootArgs = buildCodexWritableRootArgs;
|
|
23
|
-
exports.createCodexWritableRootsProvider = createCodexWritableRootsProvider;
|
|
24
|
-
const os_1 = require("os");
|
|
25
|
-
const path_1 = require("path");
|
|
26
|
-
/**
|
|
27
|
-
* crewx.yaml / query-option `mode` values for which Codex is NOT running in
|
|
28
|
-
* (or being pushed into) a `workspace-write`-equivalent sandbox. Injecting an
|
|
29
|
-
* extra writable root is meaningless (read-only/plan) or redundant
|
|
30
|
-
* (full-access variants already allow writes everywhere) in these modes.
|
|
31
|
-
*/
|
|
32
|
-
const NO_INJECT_MODES = new Set([
|
|
33
|
-
'read-only',
|
|
34
|
-
'plan',
|
|
35
|
-
'agent-full-access',
|
|
36
|
-
'yolo',
|
|
37
|
-
'danger-full-access',
|
|
38
|
-
]);
|
|
39
|
-
/**
|
|
40
|
-
* Resolve CrewX home directory.
|
|
41
|
-
* Priority: `CREWX_HOME` env var ā `~/.crewx`.
|
|
42
|
-
*/
|
|
43
|
-
function resolveCrewxHome() {
|
|
44
|
-
return process.env.CREWX_HOME ?? (0, path_1.join)((0, os_1.homedir)(), '.crewx');
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Escape a string for embedding inside a TOML basic string (`"..."`).
|
|
48
|
-
* Sufficient for filesystem paths: handles backslash (Windows paths),
|
|
49
|
-
* double-quote, and control characters that could otherwise break TOML
|
|
50
|
-
* parsing of the `-c key="value"` override.
|
|
51
|
-
*/
|
|
52
|
-
function escapeTomlBasicString(value) {
|
|
53
|
-
return value
|
|
54
|
-
.replace(/\\/g, '\\\\')
|
|
55
|
-
.replace(/"/g, '\\"')
|
|
56
|
-
.replace(/\n/g, '\\n')
|
|
57
|
-
.replace(/\r/g, '\\r')
|
|
58
|
-
.replace(/\t/g, '\\t');
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Build the `-c sandbox_workspace_write.writable_roots=["<path>"]` arg pair.
|
|
62
|
-
* Works for both `codex exec` and `codex exec resume` (config-override form).
|
|
63
|
-
*/
|
|
64
|
-
function buildCodexWritableRootArgs(crewxHome) {
|
|
65
|
-
const escaped = escapeTomlBasicString(crewxHome);
|
|
66
|
-
return ['-c', `sandbox_workspace_write.writable_roots=["${escaped}"]`];
|
|
67
|
-
}
|
|
68
|
-
function isCodexProvider(ctx) {
|
|
69
|
-
return ctx.providerId === 'codex' || ctx.providerStr === 'cli/codex';
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Create an `AdditionalArgsProvider` (SDK extension point, WI-20260703-001)
|
|
73
|
-
* that injects CrewX home as a Codex writable root for `workspace-write`
|
|
74
|
-
* equivalent modes (`agent`, `auto`, `undefined`).
|
|
75
|
-
*
|
|
76
|
-
* No-ops for:
|
|
77
|
-
* - Non-codex providers.
|
|
78
|
-
* - Modes in {@link NO_INJECT_MODES} (read-only/plan/agent-full-access/yolo/danger-full-access).
|
|
79
|
-
*/
|
|
80
|
-
function createCodexWritableRootsProvider(crewxHome = resolveCrewxHome()) {
|
|
81
|
-
return (ctx) => {
|
|
82
|
-
if (!isCodexProvider(ctx))
|
|
83
|
-
return [];
|
|
84
|
-
if (ctx.mode !== undefined && NO_INJECT_MODES.has(ctx.mode))
|
|
85
|
-
return [];
|
|
86
|
-
return buildCodexWritableRootArgs(crewxHome);
|
|
87
|
-
};
|
|
88
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.resolveCrewxHome=i;exports.escapeTomlBasicString=t;exports.buildCodexWritableRootArgs=s;exports.createCodexSkipGitRepoCheckProvider=u;exports.composeAdditionalArgsProviders=p;exports.createCodexWritableRootsProvider=w;const a=require("os");const d=require("path");const l=new Set(["read-only","plan","agent-full-access","yolo","danger-full-access"]);function i(){return process.env.CREWX_HOME??(0,d.join)((0,a.homedir)(),".crewx")}function t(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function s(e){const r=t(e);return["-c",`sandbox_workspace_write.writable_roots=["${r}"]`]}function n(e){return e.providerId==="codex"||e.providerStr==="cli/codex"}function u(e){return r=>{if(!n(r))return[];if(!e)return[];return["--skip-git-repo-check"]}}function p(...e){return r=>e.flatMap(o=>o(r))}function w(e=i()){return r=>{if(!n(r))return[];if(r.mode!==void 0&&l.has(r.mode))return[];const o=s(e);if(r.mode==="agent"){const c=t(e);o.push("-c","default_permissions=crewx","-c",'permissions.crewx.extends=":workspace"',"-c","features.network_proxy=true","-c","permissions.crewx.network.enabled=true","-c","permissions.crewx.network.allow_local_binding=true","-c",'permissions.crewx.network.domains={"localhost"="allow","127.0.0.1"="allow"}',"-c",`permissions.crewx.filesystem={"${c}"="write"}`)}return o}}
|
|
@@ -1,63 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCliCrewx = createCliCrewx;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const os_1 = require("os");
|
|
7
|
-
const sdk_1 = require("@crewx/sdk");
|
|
8
|
-
const plugins_1 = require("@crewx/sdk/plugins");
|
|
9
|
-
const repository_1 = require("@crewx/sdk/repository");
|
|
10
|
-
const register_builtin_tools_1 = require("../register-builtin-tools");
|
|
11
|
-
const version_1 = require("../utils/version");
|
|
12
|
-
const codex_writable_roots_1 = require("./codex-writable-roots");
|
|
13
|
-
/**
|
|
14
|
-
* Build a Crewx instance with CLI-standard plugins (FileLogger + SqliteTracing)
|
|
15
|
-
* and built-in tools registered. Use this from any CLI command that needs a
|
|
16
|
-
* Crewx instance ā keeps environment consistent across query / execute / slack / agent.
|
|
17
|
-
*
|
|
18
|
-
* workspaceRoot is always process.cwd()-based so that per-workspace logs land
|
|
19
|
-
* in {cwd}/.crewx/logs/. Critical for file:// remote agent delegation.
|
|
20
|
-
*
|
|
21
|
-
* Behavior:
|
|
22
|
-
* - If configPath resolves to an existing file ā load it (with built-ins merged)
|
|
23
|
-
* - If configPath is NOT set via CREWX_CONFIG env AND the file doesn't exist ā
|
|
24
|
-
* fall back to built-in-only mode (no user yaml required)
|
|
25
|
-
* - If CREWX_CONFIG is explicitly set AND the file doesn't exist ā throw
|
|
26
|
-
*/
|
|
27
|
-
async function createCliCrewx(configPath = process.env.CREWX_CONFIG ?? 'crewx.yaml') {
|
|
28
|
-
const absConfigPath = (0, path_1.resolve)(configPath);
|
|
29
|
-
// workspaceRoot is always cwd-based, never package-internal
|
|
30
|
-
const workspaceRoot = process.cwd();
|
|
31
|
-
const isExplicitConfig = Boolean(process.env.CREWX_CONFIG);
|
|
32
|
-
const fileExists = (0, fs_1.existsSync)(absConfigPath);
|
|
33
|
-
let yamlPath;
|
|
34
|
-
if (fileExists) {
|
|
35
|
-
yamlPath = absConfigPath;
|
|
36
|
-
}
|
|
37
|
-
else if (isExplicitConfig) {
|
|
38
|
-
throw new Error(`[crewx] Config file not found: ${absConfigPath} (set via CREWX_CONFIG)`);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
yamlPath = undefined;
|
|
42
|
-
}
|
|
43
|
-
// Run drizzle migrations once at bootstrap ā plugin relies on this guarantee.
|
|
44
|
-
const dbDir = (0, path_1.join)((0, os_1.homedir)(), '.crewx');
|
|
45
|
-
(0, fs_1.mkdirSync)(dbDir, { recursive: true });
|
|
46
|
-
const dbPath = (0, path_1.join)(dbDir, 'crewx.db');
|
|
47
|
-
const handle = (0, repository_1.openDrizzleDb)(dbPath);
|
|
48
|
-
try {
|
|
49
|
-
(0, repository_1.runMigrations)(handle.db);
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
handle.close();
|
|
53
|
-
}
|
|
54
|
-
const crewx = await sdk_1.Crewx.loadYaml(yamlPath, {
|
|
55
|
-
remoteFactory: createCliCrewx,
|
|
56
|
-
additionalArgsProvider: (0, codex_writable_roots_1.createCodexWritableRootsProvider)(),
|
|
57
|
-
});
|
|
58
|
-
(0, register_builtin_tools_1.registerBuiltinToolsIfNeeded)(crewx);
|
|
59
|
-
await crewx.use(new plugins_1.ConversationPlugin());
|
|
60
|
-
await crewx.use(new plugins_1.FileLoggerPlugin({ version: version_1.CLI_VERSION, workspaceRoot }));
|
|
61
|
-
await crewx.use(new plugins_1.SqliteTracingPlugin({ version: version_1.CLI_VERSION }));
|
|
62
|
-
return crewx;
|
|
63
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createCliCrewx=C;const n=require("fs");const o=require("path");const x=require("os");const s=require("@crewx/sdk");const y=require("@crewx/workflow/list");const a=require("@crewx/sdk/plugins");const l=require("@crewx/sdk/repository");const h=require("../register-builtin-tools");const _=require("../utils/version");const R=require("../utils/inherited-trace");const d=require("./codex-writable-roots");async function C(P=process.env.CREWX_CONFIG??"crewx.yaml"){const t=(0,o.resolve)(P);const u=process.cwd();const v=Boolean(process.env.CREWX_CONFIG);const f=(0,n.existsSync)(t);let e;if(f){e=t}else if(v){throw new Error(`[crewx] Config file not found: ${t} (set via CREWX_CONFIG)`)}else{e=void 0}const g=e!==void 0?(0,o.dirname)(t):void 0;const c=process.env.CREWX_DB||(0,o.join)((0,x.homedir)(),".crewx","crewx.db");(0,n.mkdirSync)((0,o.dirname)(c),{recursive:true});const w=(0,l.openDrizzleDb)(c);try{(0,l.runMigrations)(w.db)}finally{w.close()}const r=await s.Crewx.loadYaml(e,{remoteFactory:C,inheritWorktreeOwner:true,additionalArgsProvider:(0,d.composeAdditionalArgsProviders)((0,d.createCodexWritableRootsProvider)(),(0,d.createCodexSkipGitRepoCheckProvider)(g))});(0,h.registerBuiltinToolsIfNeeded)(r);r.registerPromptListProvider(s.Crewx.createAgentListPromptResolver(e));r.registerPromptListProvider((0,y.createWorkflowListPromptResolver)(e));await r.use(new a.ConversationPlugin({dbPath:c}));await r.use(new a.FileLoggerPlugin({version:_.CLI_VERSION,workspaceRoot:u}));await r.use(new a.SqliteTracingPlugin({version:_.CLI_VERSION,runnerIdentity:(0,R.consumeInheritedRunnerIdentity)(),inheritWorktreeOwner:true}));const p=e!==void 0?(0,o.dirname)(e):u;const m=(0,s.normalizeWorkspacePath)(p);const i=(0,s.resolveWorkspaceOwnerPath)(p);if(i!==m&&((0,n.existsSync)((0,o.join)(i,"crewx.yaml"))||(0,n.existsSync)((0,o.join)(i,"crewx.yml")))){try{new l.WorkspaceRepository().registerWorkspace(i)}catch{}}return r}
|
package/dist/builtin.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ export declare const BUILTIN_COMMANDS: Set<string>;
|
|
|
12
12
|
* Falls back to direct main() call on any tracer failure.
|
|
13
13
|
*/
|
|
14
14
|
export declare function wrapWithTracer(builtinName: string, main: (args?: string[]) => Promise<void>, args: string[]): Promise<void>;
|
|
15
|
-
export declare function handleBuiltin(builtinName: string, args: string[]): Promise<void>;
|
|
15
|
+
export declare function handleBuiltin(builtinName: string, args: string[], productPackageRoot?: string): Promise<void>;
|
package/dist/builtin.js
CHANGED
|
@@ -1,127 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* @crewx/* package CLI entry points.
|
|
7
|
-
*
|
|
8
|
-
* Copied and adapted from packages/cli-bak/src/cli/builtin.handler.ts.
|
|
9
|
-
*/
|
|
10
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}) : (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
o[k2] = m[k];
|
|
20
|
-
}));
|
|
21
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
-
}) : function(o, v) {
|
|
24
|
-
o["default"] = v;
|
|
25
|
-
});
|
|
26
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
-
var ownKeys = function(o) {
|
|
28
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
-
var ar = [];
|
|
30
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
return ownKeys(o);
|
|
34
|
-
};
|
|
35
|
-
return function (mod) {
|
|
36
|
-
if (mod && mod.__esModule) return mod;
|
|
37
|
-
var result = {};
|
|
38
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
-
__setModuleDefault(result, mod);
|
|
40
|
-
return result;
|
|
41
|
-
};
|
|
42
|
-
})();
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.BUILTIN_COMMANDS = void 0;
|
|
45
|
-
exports.wrapWithTracer = wrapWithTracer;
|
|
46
|
-
exports.handleBuiltin = handleBuiltin;
|
|
47
|
-
const BUILTIN_MAP = {
|
|
48
|
-
memory: () => Promise.resolve().then(() => __importStar(require('@crewx/memory/cli'))),
|
|
49
|
-
search: () => Promise.resolve().then(() => __importStar(require('@crewx/search/cli'))),
|
|
50
|
-
doc: () => Promise.resolve().then(() => __importStar(require('@crewx/doc/cli'))),
|
|
51
|
-
wbs: () => Promise.resolve().then(() => __importStar(require('@crewx/wbs/cli'))),
|
|
52
|
-
cron: () => Promise.resolve().then(() => __importStar(require('@crewx/cron/cli'))),
|
|
53
|
-
workflow: () => Promise.resolve().then(() => __importStar(require('@crewx/workflow/cli'))),
|
|
54
|
-
skill: () => Promise.resolve().then(() => __importStar(require('@crewx/skill/cli'))),
|
|
55
|
-
dreaming: () => Promise.resolve().then(() => __importStar(require('@crewx/dreaming/cli'))),
|
|
56
|
-
wi: () => Promise.resolve().then(() => __importStar(require('@crewx/wi/cli'))),
|
|
57
|
-
chromex: () => Promise.resolve().then(() => __importStar(require('@crewx/chromex/cli'))),
|
|
58
|
-
};
|
|
59
|
-
exports.BUILTIN_COMMANDS = new Set(Object.keys(BUILTIN_MAP));
|
|
60
|
-
// Load skill-tracer for observability (graceful degradation if unavailable)
|
|
61
|
-
async function loadTracer() {
|
|
62
|
-
try {
|
|
63
|
-
return await Promise.resolve().then(() => __importStar(require('@crewx/shared/skill-tracer')));
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Wrap main() with tracer.run() if tracer is available.
|
|
71
|
-
* Falls back to direct main() call on any tracer failure.
|
|
72
|
-
*/
|
|
73
|
-
async function wrapWithTracer(builtinName, main, args) {
|
|
74
|
-
let tracer = null;
|
|
75
|
-
try {
|
|
76
|
-
tracer = await loadTracer();
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
// tracer unavailable ā proceed without it
|
|
80
|
-
}
|
|
81
|
-
if (tracer) {
|
|
82
|
-
let mainError = null;
|
|
83
|
-
let mainCompleted = false;
|
|
84
|
-
try {
|
|
85
|
-
await tracer.run(`crewx/${builtinName}`, async () => {
|
|
86
|
-
try {
|
|
87
|
-
await main(args);
|
|
88
|
-
mainCompleted = true;
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
mainError = err;
|
|
92
|
-
throw err;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
catch {
|
|
98
|
-
if (mainError)
|
|
99
|
-
throw mainError;
|
|
100
|
-
if (mainCompleted)
|
|
101
|
-
return;
|
|
102
|
-
// tracer setup error ā fall back
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
await main(args);
|
|
106
|
-
}
|
|
107
|
-
async function handleBuiltin(builtinName, args) {
|
|
108
|
-
const loader = BUILTIN_MAP[builtinName];
|
|
109
|
-
if (!loader) {
|
|
110
|
-
console.error(`Unknown built-in tool: ${builtinName}`);
|
|
111
|
-
process.exit(1);
|
|
112
|
-
}
|
|
113
|
-
try {
|
|
114
|
-
const mod = await loader();
|
|
115
|
-
await wrapWithTracer(builtinName, mod.main.bind(mod), args);
|
|
116
|
-
}
|
|
117
|
-
catch (err) {
|
|
118
|
-
const code = err.code;
|
|
119
|
-
if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
|
|
120
|
-
console.error(`\n Built-in tool '${builtinName}' is not installed.\n`);
|
|
121
|
-
console.error(` Install it with:\n`);
|
|
122
|
-
console.error(` npm install @crewx/${builtinName}\n`);
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
125
|
-
throw err;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
1
|
+
"use strict";var u=exports&&exports.__createBinding||(Object.create?(function(n,r,i,t){if(t===void 0)t=i;var e=Object.getOwnPropertyDescriptor(r,i);if(!e||("get"in e?!r.__esModule:e.writable||e.configurable)){e={enumerable:true,get:function(){return r[i]}}}Object.defineProperty(n,t,e)}):(function(n,r,i,t){if(t===void 0)t=i;n[t]=r[i]}));var f=exports&&exports.__setModuleDefault||(Object.create?(function(n,r){Object.defineProperty(n,"default",{enumerable:true,value:r})}):function(n,r){n["default"]=r});var o=exports&&exports.__importStar||(function(){var n=function(r){n=Object.getOwnPropertyNames||function(i){var t=[];for(var e in i)if(Object.prototype.hasOwnProperty.call(i,e))t[t.length]=e;return t};return n(r)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null){for(var t=n(r),e=0;e<t.length;e++)if(t[e]!=="default")u(i,r,t[e])}f(i,r);return i}})();Object.defineProperty(exports,"__esModule",{value:true});exports.BUILTIN_COMMANDS=void 0;exports.wrapWithTracer=s;exports.handleBuiltin=w;const l={memory:()=>Promise.resolve().then(()=>o(require("@crewx/memory/cli"))),search:()=>Promise.resolve().then(()=>o(require("@crewx/search/cli"))),doc:()=>Promise.resolve().then(()=>o(require("@crewx/doc/cli"))),wbs:()=>Promise.resolve().then(()=>o(require("@crewx/wbs/cli"))),cron:()=>Promise.resolve().then(()=>o(require("@crewx/cron/cli"))),workflow:()=>Promise.resolve().then(()=>o(require("@crewx/workflow/cli"))),skill:()=>Promise.resolve().then(()=>o(require("@crewx/skill/cli"))),dreaming:()=>Promise.resolve().then(()=>o(require("@crewx/dreaming/cli"))),wi:()=>Promise.resolve().then(()=>o(require("@crewx/wi/cli"))),chromex:()=>Promise.resolve().then(()=>o(require("@crewx/chromex/cli"))),notify:()=>Promise.resolve().then(()=>o(require("@crewx/notify/cli"))),app:()=>Promise.resolve().then(()=>o(require("@crewx/app/cli")))};exports.BUILTIN_COMMANDS=new Set(Object.keys(l));async function h(){try{return await Promise.resolve().then(()=>o(require("@crewx/shared/skill-tracer")))}catch{return null}}async function s(n,r,i){let t=null;try{t=await h()}catch{}if(t){let e=null;let a=false;try{await t.run(`crewx/${n}`,async()=>{try{await r(i);a=true}catch(c){e=c;throw c}});return}catch{if(e)throw e;if(a)return}}await r(i)}async function w(n,r,i){const t=l[n];if(!t){console.error(`Unknown built-in tool: ${n}`);process.exit(1)}try{const e=await t();const a=n==="skill"?c=>e.main(c,{productPackageRoot:i}):e.main.bind(e);await s(n,a,r)}catch(e){const a=e.code;if(a==="MODULE_NOT_FOUND"||a==="ERR_MODULE_NOT_FOUND"){console.error(`
|
|
2
|
+
Built-in tool '${n}' is not installed.
|
|
3
|
+
`);console.error(` Install it with:
|
|
4
|
+
`);console.error(` npm install @crewx/${n}
|
|
5
|
+
`);process.exit(1)}throw e}}
|
package/dist/commands/agent.js
CHANGED
|
@@ -1,225 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Dispatches `crewx agent ls` and `crewx agent prompt` subcommands.
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.handleAgent = handleAgent;
|
|
41
|
-
const path = __importStar(require("path"));
|
|
42
|
-
const fs_1 = require("fs");
|
|
43
|
-
const crewx_cli_1 = require("../bootstrap/crewx-cli");
|
|
44
|
-
const sdk_1 = require("@crewx/sdk");
|
|
45
|
-
const skill_1 = require("@crewx/skill");
|
|
46
|
-
/**
|
|
47
|
-
* Parse a flag from args array.
|
|
48
|
-
* Supports both `--flag=value` and `--flag value` forms.
|
|
49
|
-
* Returns undefined if flag is not present.
|
|
50
|
-
*/
|
|
51
|
-
function parseFlag(args, flag) {
|
|
52
|
-
const prefix = `--${flag}=`;
|
|
53
|
-
for (let i = 0; i < args.length; i++) {
|
|
54
|
-
if (args[i].startsWith(prefix)) {
|
|
55
|
-
return args[i].slice(prefix.length);
|
|
56
|
-
}
|
|
57
|
-
if (args[i] === `--${flag}` && i + 1 < args.length) {
|
|
58
|
-
return args[i + 1];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Format provider field for display.
|
|
65
|
-
*/
|
|
66
|
-
function formatProvider(provider) {
|
|
67
|
-
return Array.isArray(provider) ? provider.join(', ') : provider;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Print the agent list.
|
|
71
|
-
*/
|
|
72
|
-
function printAgentList(agents, total, isFiltered) {
|
|
73
|
-
const configPath = process.env.CREWX_CONFIG ?? null;
|
|
74
|
-
if (agents.length === 0) {
|
|
75
|
-
console.log('WARNING: No agents configured.');
|
|
76
|
-
if (!configPath) {
|
|
77
|
-
console.log('Set CREWX_CONFIG to point to your crewx.yaml configuration file.');
|
|
78
|
-
}
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const headerCount = isFiltered ? `${agents.length} / ${total}` : `${total}`;
|
|
82
|
-
console.log(`Available Agents (${headerCount})\n`);
|
|
83
|
-
agents.forEach((agent, index) => {
|
|
84
|
-
const headerParts = [`@${agent.id}`];
|
|
85
|
-
if (agent.name && agent.name !== agent.id) {
|
|
86
|
-
headerParts.push(agent.name);
|
|
87
|
-
}
|
|
88
|
-
console.log(`${index + 1}. ${headerParts.join(' - ')}`);
|
|
89
|
-
console.log(` Provider: ${formatProvider(agent.provider)}`);
|
|
90
|
-
const workDir = agent.working_directory ?? agent.workingDirectory ?? '.';
|
|
91
|
-
console.log(` Working Dir: ${workDir}`);
|
|
92
|
-
if (agent.role) {
|
|
93
|
-
console.log(` Role: ${agent.role}`);
|
|
94
|
-
}
|
|
95
|
-
if (agent.team) {
|
|
96
|
-
console.log(` Team: ${agent.team}`);
|
|
97
|
-
}
|
|
98
|
-
if (agent.description) {
|
|
99
|
-
console.log(` Description: ${agent.description}`);
|
|
100
|
-
}
|
|
101
|
-
if (index < agents.length - 1) {
|
|
102
|
-
console.log('');
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
const configSource = configPath ? 'External YAML file' : 'Default hardcoded values';
|
|
106
|
-
console.log(`\nConfiguration Source: ${configSource}`);
|
|
107
|
-
if (configPath) {
|
|
108
|
-
console.log(`Config Path: ${configPath}`);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
console.log('Tip: Set CREWX_CONFIG to point to your crewx.yaml file to customize agents.');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Handle `crewx agent ls` ā list agents with optional filters.
|
|
116
|
-
*/
|
|
117
|
-
async function handleAgentList(crewx, args) {
|
|
118
|
-
const role = parseFlag(args, 'role');
|
|
119
|
-
const team = parseFlag(args, 'team');
|
|
120
|
-
const provider = parseFlag(args, 'provider');
|
|
121
|
-
const isFiltered = !!(role || team || provider);
|
|
122
|
-
const total = crewx.agents.size;
|
|
123
|
-
const filtered = crewx.filterAgents({ role, team, provider });
|
|
124
|
-
printAgentList(filtered, total, isFiltered);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Handle `crewx agent prompt <agentId>` ā print fully rendered system prompt.
|
|
128
|
-
* Renders Handlebars template variables via Crewx.renderAgentPromptFull().
|
|
129
|
-
*/
|
|
130
|
-
async function handleAgentPrompt(crewx, args) {
|
|
131
|
-
// Find the agent id argument (first non-flag arg after 'prompt')
|
|
132
|
-
const agentIdRaw = args.find(a => !a.startsWith('--'));
|
|
133
|
-
if (!agentIdRaw) {
|
|
134
|
-
console.error('Missing agent ID. Usage: crewx agent prompt @agent_name');
|
|
135
|
-
process.exit(1);
|
|
136
|
-
}
|
|
137
|
-
try {
|
|
138
|
-
const skills = loadAgentSkills();
|
|
139
|
-
const rendered = await crewx.renderAgentPromptFull(agentIdRaw, {
|
|
140
|
-
env: process.env,
|
|
141
|
-
session: { mode: 'query', platform: 'cli' },
|
|
142
|
-
skills,
|
|
143
|
-
});
|
|
144
|
-
const displayId = agentIdRaw.startsWith('@') ? agentIdRaw.slice(1) : agentIdRaw;
|
|
145
|
-
console.log(`\nš¤ **Rendered Prompt for Agent: ${displayId}**\n`);
|
|
146
|
-
console.log('--- BEGIN PROMPT ---');
|
|
147
|
-
console.log(rendered);
|
|
148
|
-
console.log('--- END PROMPT ---');
|
|
149
|
-
}
|
|
150
|
-
catch (err) {
|
|
151
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
152
|
-
console.error(`Failed to get agent prompt: ${message}`);
|
|
153
|
-
process.exit(1);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Handle `crewx agent [subcommand] [options]`.
|
|
158
|
-
*
|
|
159
|
-
* Subcommands:
|
|
160
|
-
* ls | list | (none) ā list agents (default)
|
|
161
|
-
* prompt <agentId> ā print rendered system prompt
|
|
162
|
-
*/
|
|
163
|
-
async function handleAgent(args) {
|
|
164
|
-
const configPath = process.env.CREWX_CONFIG ?? 'crewx.yaml';
|
|
165
|
-
let crewx;
|
|
166
|
-
try {
|
|
167
|
-
crewx = await (0, crewx_cli_1.createCliCrewx)(configPath);
|
|
168
|
-
}
|
|
169
|
-
catch (err) {
|
|
170
|
-
if (err instanceof sdk_1.ConfigLoadError && !(0, fs_1.existsSync)(configPath)) {
|
|
171
|
-
const subcommand = (args[0] ?? '').toLowerCase();
|
|
172
|
-
if (!subcommand || subcommand === 'ls' || subcommand === 'list') {
|
|
173
|
-
console.log('WARNING: No agents configured.');
|
|
174
|
-
console.log(`No crewx.yaml found. Run 'crewx init' to create one.`);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
throw err;
|
|
179
|
-
}
|
|
180
|
-
const subcommand = (args[0] ?? '').toLowerCase();
|
|
181
|
-
switch (subcommand) {
|
|
182
|
-
case 'ls':
|
|
183
|
-
case 'list':
|
|
184
|
-
await handleAgentList(crewx, args.slice(1));
|
|
185
|
-
return;
|
|
186
|
-
case '':
|
|
187
|
-
// Default: no subcommand ā ls
|
|
188
|
-
await handleAgentList(crewx, args.slice(1));
|
|
189
|
-
return;
|
|
190
|
-
case 'prompt':
|
|
191
|
-
case 'p':
|
|
192
|
-
await handleAgentPrompt(crewx, args.slice(1));
|
|
193
|
-
return;
|
|
194
|
-
default:
|
|
195
|
-
console.error(`Unknown agent subcommand: ${subcommand}`);
|
|
196
|
-
printAgentHelp();
|
|
197
|
-
process.exit(1);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Discover available skills and convert to SkillEntry format for template rendering.
|
|
202
|
-
* Searches skills/ and node_modules/@crewx directories.
|
|
203
|
-
*/
|
|
204
|
-
function loadAgentSkills() {
|
|
205
|
-
try {
|
|
206
|
-
const engine = new skill_1.SkillEngine(process.cwd());
|
|
207
|
-
const discovered = engine.discover();
|
|
208
|
-
return discovered.map(s => ({
|
|
209
|
-
metadata: {
|
|
210
|
-
name: s.name,
|
|
211
|
-
version: s.version ?? '0.0.0',
|
|
212
|
-
description: s.description ?? '',
|
|
213
|
-
},
|
|
214
|
-
filePath: s.skillMdPath ?? path.join(s.dir, 'SKILL.md'),
|
|
215
|
-
}));
|
|
216
|
-
}
|
|
217
|
-
catch {
|
|
218
|
-
return [];
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
function printAgentHelp() {
|
|
222
|
-
console.log(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.handleAgent=f;const d=require("fs");const p=require("../bootstrap/crewx-cli");const c=require("@crewx/sdk");function a(t,r){const n=`--${r}=`;for(let e=0;e<t.length;e++){if(t[e].startsWith(n)){return t[e].slice(n.length)}if(t[e]===`--${r}`&&e+1<t.length){return t[e+1]}}return void 0}function u(t,r,n){console.log((0,c.formatAgentList)({agents:t,total:r,isFiltered:n,configPath:process.env.CREWX_CONFIG??null}))}async function l(t,r){const n=a(r,"role");const e=a(r,"team");const o=a(r,"provider");const s=!!(n||e||o);const i=t.agents.size;const g=t.filterAgents({role:n,team:e,provider:o});u(g,i,s)}async function m(t,r){const n=r.find(e=>!e.startsWith("--"));if(!n){console.error("Missing agent ID. Usage: crewx agent prompt @agent_name");process.exit(1)}try{const e=await t.renderAgentPromptFull(n,{env:process.env,session:{mode:"query",platform:"cli"}});const o=n.startsWith("@")?n.slice(1):n;console.log(`
|
|
2
|
+
\u{1F916} **Rendered Prompt for Agent: ${o}**
|
|
3
|
+
`);console.log("--- BEGIN PROMPT ---");console.log(e);console.log("--- END PROMPT ---")}catch(e){const o=e instanceof Error?e.message:String(e);console.error(`Failed to get agent prompt: ${o}`);process.exit(1)}}async function f(t){const r=process.env.CREWX_CONFIG??"crewx.yaml";let n;try{n=await(0,p.createCliCrewx)(r)}catch(o){if(o instanceof c.ConfigLoadError&&!(0,d.existsSync)(r)){const s=(t[0]??"").toLowerCase();if(!s||s==="ls"||s==="list"){console.log("WARNING: No agents configured.");console.log(`No crewx.yaml found. Run 'crewx init' to create one.`);return}}throw o}const e=(t[0]??"").toLowerCase();switch(e){case"ls":case"list":await l(n,t.slice(1));return;case"":await l(n,t.slice(1));return;case"prompt":case"p":await m(n,t.slice(1));return;default:console.error(`Unknown agent subcommand: ${e}`);w();process.exit(1)}}function w(){console.log(`
|
|
223
4
|
CrewX Agent Management
|
|
224
5
|
|
|
225
6
|
Usage:
|
|
@@ -242,5 +23,4 @@ Examples:
|
|
|
242
23
|
crewx agent ls --role=PM --provider=claude
|
|
243
24
|
crewx agent ls --role=PM,general
|
|
244
25
|
CREWX_CONFIG=./crewx.yaml crewx agent list
|
|
245
|
-
`.trim())
|
|
246
|
-
}
|
|
26
|
+
`.trim())}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ActionContext } from '@crewx/knowledge-core';
|
|
2
|
+
/** Suggested wait rungs in seconds. 540 is the safe caller-harness cap. */
|
|
3
|
+
export declare const WAIT_LADDER_SECONDS: readonly [60, 300, 540];
|
|
4
|
+
export interface SuggestWaitSecondsOptions {
|
|
5
|
+
startedAt?: string | number | Date | null;
|
|
6
|
+
lastWaitSeconds?: number;
|
|
7
|
+
now?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Select the next safe result wait based on task runtime without stepping
|
|
11
|
+
* down from the wait value the caller just used.
|
|
12
|
+
*/
|
|
13
|
+
export declare function suggestWaitSeconds(options: SuggestWaitSecondsOptions): number;
|
|
14
|
+
/** Write a human-only CAL footer without contaminating command stdout. */
|
|
15
|
+
export declare function writeCalFooter(context: ActionContext): void;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.WAIT_LADDER_SECONDS=void 0;exports.suggestWaitSeconds=D;exports.writeCalFooter=a;const i=require("@crewx/knowledge-core");exports.WAIT_LADDER_SECONDS=[60,300,540];function d(e){if(e instanceof Date){return Number.isFinite(e.getTime())?e.getTime():void 0}if(typeof e==="number"){return Number.isFinite(e)?e:void 0}if(typeof e==="string"){const t=Date.parse(e);return Number.isFinite(t)?t:void 0}return void 0}function D(e){const t=Number.isFinite(e.now)?e.now:Date.now();const n=d(e.startedAt);const r=n===void 0?0:Math.max(0,(t-n)/1e3);const s=exports.WAIT_LADDER_SECONDS.find(c=>c>r)??exports.WAIT_LADDER_SECONDS[exports.WAIT_LADDER_SECONDS.length-1];const o=Number.isFinite(e.lastWaitSeconds)?Math.max(0,e.lastWaitSeconds):0;return Math.min(exports.WAIT_LADDER_SECONDS[exports.WAIT_LADDER_SECONDS.length-1],Math.max(s,o))}function a(e){const t=(0,i.formatActions)((0,i.generateNextActions)(e));if(t)process.stderr.write(`${t}
|
|
2
|
+
`)}
|
package/dist/commands/db.d.ts
CHANGED
|
@@ -6,4 +6,7 @@
|
|
|
6
6
|
* crewx db push --force Apply without confirmation + reset migration history
|
|
7
7
|
* crewx db push --dry-run Show preview only, no changes
|
|
8
8
|
*/
|
|
9
|
+
export declare const TASK_LOG_MIGRATION_HELP = "Usage:\n crewx db migrate-task-logs --dry-run [--db PATH]\n crewx db migrate-task-logs --apply [--db PATH] [--batch-tasks N]\n crewx db migrate-task-logs --verify [--db PATH]\n\nModes:\n --dry-run Read and validate legacy blobs without writing or creating a backup.\n --apply Create a consistent SQLite backup, then migrate one task per transaction.\n --verify Check source invariants, event sequences, counts, and orphan rows.\n\nApply policy:\n Only blob tasks with status success, failed, or completed are migrated.\n pending, running, paused, and unknown statuses are deferred for a later run.\n There is no --force or --include-active option. Apply requires the estimated\n database/event growth plus a 10 GiB free-space reserve.\n\nExit codes:\n 0 Completed with no malformed rows or invariant failures.\n 1 Safe tasks completed but a row/invariant failed, or apply was blocked.\n 2 Invalid command-line arguments.\n\nThe command never runs automatically at server startup and never runs VACUUM.";
|
|
10
|
+
export declare const REQUEST_LOG_MIGRATION_HELP = "Usage:\n crewx db migrate-request-logs [--batch N] [--dry-run]\n\nMoves the request log rows still stored in crewx.db into logs.db, the file next\nto it. Each distinct request/response body is stored once in logs.db, keyed by\nits SHA-256; a row points to its bodies by hash, so nothing is dropped.\n\nOptions:\n --batch N Rows per batch (default 250; a batch is also capped at about 8 MB).\n --dry-run Count rows and distinct bodies without writing anything (logs.db is not created).\n\nSafe while crewx is running: each batch is committed to logs.db, verified there,\nand only then deleted from crewx.db in one short transaction. Interrupt it and run\nit again at any time. The database is chosen like everywhere else (CREWX_DB, else\n~/.crewx/crewx.db). No VACUUM and no DROP: crewx.db keeps its size until a later compaction.\n\nExit codes:\n 0 Every row is in logs.db and none is left in crewx.db (or the dry run finished).\n 1 Rows are still in crewx.db, or an error stopped the move (progress is kept).\n 2 Invalid command-line arguments.";
|
|
11
|
+
export declare const USAGE_BACKFILL_HELP = "Usage:\n crewx db backfill-usage [--dry-run|--apply|--verify] [--db PATH] [--backup PATH]\n crewx db backfill-usage --restore SNAPSHOT [--db PATH]\n\nModes:\n --dry-run Show provider/reason recovery plans without changing the database (default).\n --apply Create a row-level undo snapshot, then account one task per transaction.\n --verify Recheck remaining targets and usageAccounting markers without changing the database.\n --restore Restore rows from SNAPSHOT when their current values still match the snapshot after-state.\n\nApply policy:\n Only success, failed, and completed tasks with zero recorded usage are considered.\n Workflow/MCP anchors and plugin/mock rows are excluded. Rows completed within 24 hours\n are not marked unavailable when their logs do not contain usage.\n\nExit codes:\n 0 Completed successfully.\n 1 Apply was blocked or one or more task updates failed.\n 2 Invalid command-line arguments.";
|
|
9
12
|
export declare function handleDb(args: string[]): Promise<void>;
|