@crewx/cli 0.9.0-rc.1 ā 0.9.0-rc.100
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 +58 -0
- package/dist/bootstrap/codex-writable-roots.js +113 -0
- package/dist/bootstrap/crewx-cli.js +8 -1
- package/dist/builtin.js +1 -0
- package/dist/commands/agent.js +0 -58
- 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 +65 -0
- package/dist/commands/detached.js +507 -0
- package/dist/commands/doctor.d.ts +53 -0
- package/dist/commands/doctor.js +391 -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 +121 -16
- 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 +60 -63
- package/dist/commands/hook/status.js +3 -3
- package/dist/commands/hook/uninstall.js +2 -2
- package/dist/commands/init.js +22 -1
- 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 +8 -2
- package/dist/commands/parse-common-flags.js +12 -3
- package/dist/commands/ps.d.ts +2 -2
- package/dist/commands/ps.js +69 -11
- 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 +114 -11
- package/dist/commands/registry.js +4 -2
- package/dist/commands/restart.js +20 -6
- 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/logging.d.ts +1 -1
- package/dist/logging.js +3 -2
- package/dist/main.d.ts +3 -2
- package/dist/main.js +70 -14
- 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 +13 -10
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI-layer policy: inject CrewX home as an extra writable root for Codex
|
|
3
|
+
* `workspace-write` sandbox invocations.
|
|
4
|
+
*
|
|
5
|
+
* Why this lives in packages/cli (not packages/sdk):
|
|
6
|
+
* CrewX home (`~/.crewx` by default) is a product-specific path. The SDK's
|
|
7
|
+
* `additionalArgsProvider` extension point (WI-20260703-001) exists precisely
|
|
8
|
+
* so that product layers like this CLI can inject such paths without the SDK
|
|
9
|
+
* knowing about them.
|
|
10
|
+
*
|
|
11
|
+
* Why `-c sandbox_workspace_write.writable_roots=[...]` instead of `--add-dir`:
|
|
12
|
+
* Verified against codex-cli 0.139.0 (`codex exec --help` / `codex exec resume --help`):
|
|
13
|
+
* - `codex exec` supports `--add-dir <DIR>`.
|
|
14
|
+
* - `codex exec resume` does NOT support `--add-dir` (only `-c/--config`).
|
|
15
|
+
* Using the `-c` config-override form works identically for both `exec` and
|
|
16
|
+
* `exec resume`, avoiding a resume-incompatible flag.
|
|
17
|
+
*/
|
|
18
|
+
import type { AdditionalArgsProvider } from '@crewx/sdk';
|
|
19
|
+
/**
|
|
20
|
+
* Resolve CrewX home directory.
|
|
21
|
+
* Priority: `CREWX_HOME` env var ā `~/.crewx`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveCrewxHome(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Escape a string for embedding inside a TOML basic string (`"..."`).
|
|
26
|
+
* Sufficient for filesystem paths: handles backslash (Windows paths),
|
|
27
|
+
* double-quote, and control characters that could otherwise break TOML
|
|
28
|
+
* parsing of the `-c key="value"` override.
|
|
29
|
+
*/
|
|
30
|
+
export declare function escapeTomlBasicString(value: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Build the `-c sandbox_workspace_write.writable_roots=["<path>"]` arg pair.
|
|
33
|
+
* Works for both `codex exec` and `codex exec resume` (config-override form).
|
|
34
|
+
*/
|
|
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;
|
|
49
|
+
/**
|
|
50
|
+
* Create an `AdditionalArgsProvider` (SDK extension point, WI-20260703-001)
|
|
51
|
+
* that injects CrewX home as a Codex writable root for `workspace-write`
|
|
52
|
+
* equivalent modes (`agent`, `auto`, `undefined`).
|
|
53
|
+
*
|
|
54
|
+
* No-ops for:
|
|
55
|
+
* - Non-codex providers.
|
|
56
|
+
* - Modes in {@link NO_INJECT_MODES} (read-only/plan/agent-full-access/yolo/danger-full-access).
|
|
57
|
+
*/
|
|
58
|
+
export declare function createCodexWritableRootsProvider(crewxHome?: string): AdditionalArgsProvider;
|
|
@@ -0,0 +1,113 @@
|
|
|
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.createCodexSkipGitRepoCheckProvider = createCodexSkipGitRepoCheckProvider;
|
|
24
|
+
exports.composeAdditionalArgsProviders = composeAdditionalArgsProviders;
|
|
25
|
+
exports.createCodexWritableRootsProvider = createCodexWritableRootsProvider;
|
|
26
|
+
const os_1 = require("os");
|
|
27
|
+
const path_1 = require("path");
|
|
28
|
+
/**
|
|
29
|
+
* crewx.yaml / query-option `mode` values for which Codex is NOT running in
|
|
30
|
+
* (or being pushed into) a `workspace-write`-equivalent sandbox. Injecting an
|
|
31
|
+
* extra writable root is meaningless (read-only/plan) or redundant
|
|
32
|
+
* (full-access variants already allow writes everywhere) in these modes.
|
|
33
|
+
*/
|
|
34
|
+
const NO_INJECT_MODES = new Set([
|
|
35
|
+
'read-only',
|
|
36
|
+
'plan',
|
|
37
|
+
'agent-full-access',
|
|
38
|
+
'yolo',
|
|
39
|
+
'danger-full-access',
|
|
40
|
+
]);
|
|
41
|
+
/**
|
|
42
|
+
* Resolve CrewX home directory.
|
|
43
|
+
* Priority: `CREWX_HOME` env var ā `~/.crewx`.
|
|
44
|
+
*/
|
|
45
|
+
function resolveCrewxHome() {
|
|
46
|
+
return process.env.CREWX_HOME ?? (0, path_1.join)((0, os_1.homedir)(), '.crewx');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Escape a string for embedding inside a TOML basic string (`"..."`).
|
|
50
|
+
* Sufficient for filesystem paths: handles backslash (Windows paths),
|
|
51
|
+
* double-quote, and control characters that could otherwise break TOML
|
|
52
|
+
* parsing of the `-c key="value"` override.
|
|
53
|
+
*/
|
|
54
|
+
function escapeTomlBasicString(value) {
|
|
55
|
+
return value
|
|
56
|
+
.replace(/\\/g, '\\\\')
|
|
57
|
+
.replace(/"/g, '\\"')
|
|
58
|
+
.replace(/\n/g, '\\n')
|
|
59
|
+
.replace(/\r/g, '\\r')
|
|
60
|
+
.replace(/\t/g, '\\t');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Build the `-c sandbox_workspace_write.writable_roots=["<path>"]` arg pair.
|
|
64
|
+
* Works for both `codex exec` and `codex exec resume` (config-override form).
|
|
65
|
+
*/
|
|
66
|
+
function buildCodexWritableRootArgs(crewxHome) {
|
|
67
|
+
const escaped = escapeTomlBasicString(crewxHome);
|
|
68
|
+
return ['-c', `sandbox_workspace_write.writable_roots=["${escaped}"]`];
|
|
69
|
+
}
|
|
70
|
+
function isCodexProvider(ctx) {
|
|
71
|
+
return ctx.providerId === 'codex' || ctx.providerStr === 'cli/codex';
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Create an `AdditionalArgsProvider` that skips Codex's git repository trust
|
|
75
|
+
* check for a resolved workspace.
|
|
76
|
+
*
|
|
77
|
+
* The workspace is resolved by the product layer, so an unavailable workspace
|
|
78
|
+
* must not fall back to the host cwd. The flag is independent of execution
|
|
79
|
+
* mode because it controls repository trust rather than filesystem access.
|
|
80
|
+
*/
|
|
81
|
+
function createCodexSkipGitRepoCheckProvider(workspaceRoot) {
|
|
82
|
+
return (ctx) => {
|
|
83
|
+
if (!isCodexProvider(ctx))
|
|
84
|
+
return [];
|
|
85
|
+
if (!workspaceRoot)
|
|
86
|
+
return [];
|
|
87
|
+
return ['--skip-git-repo-check'];
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Compose product-layer argument providers while preserving their order.
|
|
92
|
+
*/
|
|
93
|
+
function composeAdditionalArgsProviders(...providers) {
|
|
94
|
+
return (ctx) => providers.flatMap((provider) => provider(ctx));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create an `AdditionalArgsProvider` (SDK extension point, WI-20260703-001)
|
|
98
|
+
* that injects CrewX home as a Codex writable root for `workspace-write`
|
|
99
|
+
* equivalent modes (`agent`, `auto`, `undefined`).
|
|
100
|
+
*
|
|
101
|
+
* No-ops for:
|
|
102
|
+
* - Non-codex providers.
|
|
103
|
+
* - Modes in {@link NO_INJECT_MODES} (read-only/plan/agent-full-access/yolo/danger-full-access).
|
|
104
|
+
*/
|
|
105
|
+
function createCodexWritableRootsProvider(crewxHome = resolveCrewxHome()) {
|
|
106
|
+
return (ctx) => {
|
|
107
|
+
if (!isCodexProvider(ctx))
|
|
108
|
+
return [];
|
|
109
|
+
if (ctx.mode !== undefined && NO_INJECT_MODES.has(ctx.mode))
|
|
110
|
+
return [];
|
|
111
|
+
return buildCodexWritableRootArgs(crewxHome);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -9,6 +9,8 @@ const plugins_1 = require("@crewx/sdk/plugins");
|
|
|
9
9
|
const repository_1 = require("@crewx/sdk/repository");
|
|
10
10
|
const register_builtin_tools_1 = require("../register-builtin-tools");
|
|
11
11
|
const version_1 = require("../utils/version");
|
|
12
|
+
const inherited_trace_1 = require("../utils/inherited-trace");
|
|
13
|
+
const codex_writable_roots_1 = require("./codex-writable-roots");
|
|
12
14
|
/**
|
|
13
15
|
* Build a Crewx instance with CLI-standard plugins (FileLogger + SqliteTracing)
|
|
14
16
|
* and built-in tools registered. Use this from any CLI command that needs a
|
|
@@ -39,6 +41,7 @@ async function createCliCrewx(configPath = process.env.CREWX_CONFIG ?? 'crewx.ya
|
|
|
39
41
|
else {
|
|
40
42
|
yamlPath = undefined;
|
|
41
43
|
}
|
|
44
|
+
const skipRoot = yamlPath !== undefined ? (0, path_1.dirname)(absConfigPath) : undefined;
|
|
42
45
|
// Run drizzle migrations once at bootstrap ā plugin relies on this guarantee.
|
|
43
46
|
const dbDir = (0, path_1.join)((0, os_1.homedir)(), '.crewx');
|
|
44
47
|
(0, fs_1.mkdirSync)(dbDir, { recursive: true });
|
|
@@ -52,10 +55,14 @@ async function createCliCrewx(configPath = process.env.CREWX_CONFIG ?? 'crewx.ya
|
|
|
52
55
|
}
|
|
53
56
|
const crewx = await sdk_1.Crewx.loadYaml(yamlPath, {
|
|
54
57
|
remoteFactory: createCliCrewx,
|
|
58
|
+
additionalArgsProvider: (0, codex_writable_roots_1.composeAdditionalArgsProviders)((0, codex_writable_roots_1.createCodexWritableRootsProvider)(), (0, codex_writable_roots_1.createCodexSkipGitRepoCheckProvider)(skipRoot)),
|
|
55
59
|
});
|
|
56
60
|
(0, register_builtin_tools_1.registerBuiltinToolsIfNeeded)(crewx);
|
|
57
61
|
await crewx.use(new plugins_1.ConversationPlugin());
|
|
58
62
|
await crewx.use(new plugins_1.FileLoggerPlugin({ version: version_1.CLI_VERSION, workspaceRoot }));
|
|
59
|
-
await crewx.use(new plugins_1.SqliteTracingPlugin({
|
|
63
|
+
await crewx.use(new plugins_1.SqliteTracingPlugin({
|
|
64
|
+
version: version_1.CLI_VERSION,
|
|
65
|
+
runnerIdentity: (0, inherited_trace_1.consumeInheritedRunnerIdentity)(),
|
|
66
|
+
}));
|
|
60
67
|
return crewx;
|
|
61
68
|
}
|
package/dist/builtin.js
CHANGED
|
@@ -55,6 +55,7 @@ const BUILTIN_MAP = {
|
|
|
55
55
|
dreaming: () => Promise.resolve().then(() => __importStar(require('@crewx/dreaming/cli'))),
|
|
56
56
|
wi: () => Promise.resolve().then(() => __importStar(require('@crewx/wi/cli'))),
|
|
57
57
|
chromex: () => Promise.resolve().then(() => __importStar(require('@crewx/chromex/cli'))),
|
|
58
|
+
notify: () => Promise.resolve().then(() => __importStar(require('@crewx/notify/cli'))),
|
|
58
59
|
};
|
|
59
60
|
exports.BUILTIN_COMMANDS = new Set(Object.keys(BUILTIN_MAP));
|
|
60
61
|
// Load skill-tracer for observability (graceful degradation if unavailable)
|
package/dist/commands/agent.js
CHANGED
|
@@ -3,46 +3,11 @@
|
|
|
3
3
|
* crewx agent handler.
|
|
4
4
|
* Dispatches `crewx agent ls` and `crewx agent prompt` subcommands.
|
|
5
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
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
7
|
exports.handleAgent = handleAgent;
|
|
41
|
-
const path = __importStar(require("path"));
|
|
42
8
|
const fs_1 = require("fs");
|
|
43
9
|
const crewx_cli_1 = require("../bootstrap/crewx-cli");
|
|
44
10
|
const sdk_1 = require("@crewx/sdk");
|
|
45
|
-
const skill_1 = require("@crewx/skill");
|
|
46
11
|
/**
|
|
47
12
|
* Parse a flag from args array.
|
|
48
13
|
* Supports both `--flag=value` and `--flag value` forms.
|
|
@@ -135,11 +100,9 @@ async function handleAgentPrompt(crewx, args) {
|
|
|
135
100
|
process.exit(1);
|
|
136
101
|
}
|
|
137
102
|
try {
|
|
138
|
-
const skills = loadAgentSkills();
|
|
139
103
|
const rendered = await crewx.renderAgentPromptFull(agentIdRaw, {
|
|
140
104
|
env: process.env,
|
|
141
105
|
session: { mode: 'query', platform: 'cli' },
|
|
142
|
-
skills,
|
|
143
106
|
});
|
|
144
107
|
const displayId = agentIdRaw.startsWith('@') ? agentIdRaw.slice(1) : agentIdRaw;
|
|
145
108
|
console.log(`\nš¤ **Rendered Prompt for Agent: ${displayId}**\n`);
|
|
@@ -197,27 +160,6 @@ async function handleAgent(args) {
|
|
|
197
160
|
process.exit(1);
|
|
198
161
|
}
|
|
199
162
|
}
|
|
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
163
|
function printAgentHelp() {
|
|
222
164
|
console.log(`
|
|
223
165
|
CrewX Agent Management
|
|
@@ -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,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WAIT_LADDER_SECONDS = void 0;
|
|
4
|
+
exports.suggestWaitSeconds = suggestWaitSeconds;
|
|
5
|
+
exports.writeCalFooter = writeCalFooter;
|
|
6
|
+
const knowledge_core_1 = require("@crewx/knowledge-core");
|
|
7
|
+
/** Suggested wait rungs in seconds. 540 is the safe caller-harness cap. */
|
|
8
|
+
exports.WAIT_LADDER_SECONDS = [60, 300, 540];
|
|
9
|
+
function toTimestamp(value) {
|
|
10
|
+
if (value instanceof Date) {
|
|
11
|
+
return Number.isFinite(value.getTime()) ? value.getTime() : undefined;
|
|
12
|
+
}
|
|
13
|
+
if (typeof value === 'number') {
|
|
14
|
+
return Number.isFinite(value) ? value : undefined;
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === 'string') {
|
|
17
|
+
const timestamp = Date.parse(value);
|
|
18
|
+
return Number.isFinite(timestamp) ? timestamp : undefined;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Select the next safe result wait based on task runtime without stepping
|
|
24
|
+
* down from the wait value the caller just used.
|
|
25
|
+
*/
|
|
26
|
+
function suggestWaitSeconds(options) {
|
|
27
|
+
const now = Number.isFinite(options.now) ? options.now : Date.now();
|
|
28
|
+
const startedAt = toTimestamp(options.startedAt);
|
|
29
|
+
const elapsedSeconds = startedAt === undefined
|
|
30
|
+
? 0
|
|
31
|
+
: Math.max(0, (now - startedAt) / 1000);
|
|
32
|
+
const rung = exports.WAIT_LADDER_SECONDS.find(seconds => seconds > elapsedSeconds)
|
|
33
|
+
?? exports.WAIT_LADDER_SECONDS[exports.WAIT_LADDER_SECONDS.length - 1];
|
|
34
|
+
const lastWaitSeconds = Number.isFinite(options.lastWaitSeconds)
|
|
35
|
+
? Math.max(0, options.lastWaitSeconds)
|
|
36
|
+
: 0;
|
|
37
|
+
return Math.min(exports.WAIT_LADDER_SECONDS[exports.WAIT_LADDER_SECONDS.length - 1], Math.max(rung, lastWaitSeconds));
|
|
38
|
+
}
|
|
39
|
+
/** Write a human-only CAL footer without contaminating command stdout. */
|
|
40
|
+
function writeCalFooter(context) {
|
|
41
|
+
const block = (0, knowledge_core_1.formatActions)((0, knowledge_core_1.generateNextActions)(context));
|
|
42
|
+
if (block)
|
|
43
|
+
process.stderr.write(`${block}\n`);
|
|
44
|
+
}
|
package/dist/commands/db.d.ts
CHANGED
|
@@ -6,4 +6,6 @@
|
|
|
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 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
11
|
export declare function handleDb(args: string[]): Promise<void>;
|