@crewx/cli 0.9.0-rc.13 ā 0.9.0-rc.130
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.d.ts +1 -1
- package/dist/builtin.js +7 -2
- 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 +95 -0
- package/dist/commands/detached.js +620 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.js +475 -22
- package/dist/commands/emit-trailer.d.ts +25 -0
- package/dist/commands/emit-trailer.js +33 -0
- package/dist/commands/execute.d.ts +8 -4
- package/dist/commands/execute.js +201 -49
- 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 +132 -59
- 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 +7 -1
- package/dist/commands/parse-common-flags.js +37 -4
- 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 +7 -2
- package/dist/commands/query.js +196 -46
- package/dist/commands/registry.js +4 -2
- package/dist/commands/resolve-prompt.js +23 -1
- package/dist/commands/resolve-recipient.d.ts +14 -0
- package/dist/commands/resolve-recipient.js +47 -0
- 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 +96 -24
- 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/product-package-root.d.ts +6 -0
- package/dist/utils/product-package-root.js +39 -0
- package/dist/utils/sdk-compat.d.ts +24 -0
- package/dist/utils/sdk-compat.js +120 -0
- package/package.json +16 -12
|
@@ -33,6 +33,19 @@ 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`
|
|
@@ -20,6 +20,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
20
20
|
exports.resolveCrewxHome = resolveCrewxHome;
|
|
21
21
|
exports.escapeTomlBasicString = escapeTomlBasicString;
|
|
22
22
|
exports.buildCodexWritableRootArgs = buildCodexWritableRootArgs;
|
|
23
|
+
exports.createCodexSkipGitRepoCheckProvider = createCodexSkipGitRepoCheckProvider;
|
|
24
|
+
exports.composeAdditionalArgsProviders = composeAdditionalArgsProviders;
|
|
23
25
|
exports.createCodexWritableRootsProvider = createCodexWritableRootsProvider;
|
|
24
26
|
const os_1 = require("os");
|
|
25
27
|
const path_1 = require("path");
|
|
@@ -68,6 +70,29 @@ function buildCodexWritableRootArgs(crewxHome) {
|
|
|
68
70
|
function isCodexProvider(ctx) {
|
|
69
71
|
return ctx.providerId === 'codex' || ctx.providerStr === 'cli/codex';
|
|
70
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
|
+
}
|
|
71
96
|
/**
|
|
72
97
|
* Create an `AdditionalArgsProvider` (SDK extension point, WI-20260703-001)
|
|
73
98
|
* that injects CrewX home as a Codex writable root for `workspace-write`
|
|
@@ -5,10 +5,12 @@ const fs_1 = require("fs");
|
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const os_1 = require("os");
|
|
7
7
|
const sdk_1 = require("@crewx/sdk");
|
|
8
|
+
const list_1 = require("@crewx/workflow/list");
|
|
8
9
|
const plugins_1 = require("@crewx/sdk/plugins");
|
|
9
10
|
const repository_1 = require("@crewx/sdk/repository");
|
|
10
11
|
const register_builtin_tools_1 = require("../register-builtin-tools");
|
|
11
12
|
const version_1 = require("../utils/version");
|
|
13
|
+
const inherited_trace_1 = require("../utils/inherited-trace");
|
|
12
14
|
const codex_writable_roots_1 = require("./codex-writable-roots");
|
|
13
15
|
/**
|
|
14
16
|
* Build a Crewx instance with CLI-standard plugins (FileLogger + SqliteTracing)
|
|
@@ -40,10 +42,10 @@ async function createCliCrewx(configPath = process.env.CREWX_CONFIG ?? 'crewx.ya
|
|
|
40
42
|
else {
|
|
41
43
|
yamlPath = undefined;
|
|
42
44
|
}
|
|
45
|
+
const skipRoot = yamlPath !== undefined ? (0, path_1.dirname)(absConfigPath) : undefined;
|
|
43
46
|
// Run drizzle migrations once at bootstrap ā plugin relies on this guarantee.
|
|
44
|
-
const
|
|
45
|
-
(0, fs_1.mkdirSync)(
|
|
46
|
-
const dbPath = (0, path_1.join)(dbDir, 'crewx.db');
|
|
47
|
+
const dbPath = process.env.CREWX_DB || (0, path_1.join)((0, os_1.homedir)(), '.crewx', 'crewx.db');
|
|
48
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(dbPath), { recursive: true });
|
|
47
49
|
const handle = (0, repository_1.openDrizzleDb)(dbPath);
|
|
48
50
|
try {
|
|
49
51
|
(0, repository_1.runMigrations)(handle.db);
|
|
@@ -53,11 +55,30 @@ async function createCliCrewx(configPath = process.env.CREWX_CONFIG ?? 'crewx.ya
|
|
|
53
55
|
}
|
|
54
56
|
const crewx = await sdk_1.Crewx.loadYaml(yamlPath, {
|
|
55
57
|
remoteFactory: createCliCrewx,
|
|
56
|
-
|
|
58
|
+
inheritWorktreeOwner: true,
|
|
59
|
+
additionalArgsProvider: (0, codex_writable_roots_1.composeAdditionalArgsProviders)((0, codex_writable_roots_1.createCodexWritableRootsProvider)(), (0, codex_writable_roots_1.createCodexSkipGitRepoCheckProvider)(skipRoot)),
|
|
57
60
|
});
|
|
58
61
|
(0, register_builtin_tools_1.registerBuiltinToolsIfNeeded)(crewx);
|
|
59
|
-
|
|
62
|
+
crewx.registerPromptListProvider(sdk_1.Crewx.createAgentListPromptResolver(yamlPath));
|
|
63
|
+
crewx.registerPromptListProvider((0, list_1.createWorkflowListPromptResolver)(yamlPath));
|
|
64
|
+
await crewx.use(new plugins_1.ConversationPlugin({ dbPath }));
|
|
60
65
|
await crewx.use(new plugins_1.FileLoggerPlugin({ version: version_1.CLI_VERSION, workspaceRoot }));
|
|
61
|
-
await crewx.use(new plugins_1.SqliteTracingPlugin({
|
|
66
|
+
await crewx.use(new plugins_1.SqliteTracingPlugin({
|
|
67
|
+
version: version_1.CLI_VERSION,
|
|
68
|
+
runnerIdentity: (0, inherited_trace_1.consumeInheritedRunnerIdentity)(),
|
|
69
|
+
inheritWorktreeOwner: true,
|
|
70
|
+
}));
|
|
71
|
+
const projectRoot = yamlPath !== undefined ? (0, path_1.dirname)(yamlPath) : workspaceRoot;
|
|
72
|
+
const normalizedProjectRoot = (0, sdk_1.normalizeWorkspacePath)(projectRoot);
|
|
73
|
+
const ownerPath = (0, sdk_1.resolveWorkspaceOwnerPath)(projectRoot);
|
|
74
|
+
if (ownerPath !== normalizedProjectRoot
|
|
75
|
+
&& ((0, fs_1.existsSync)((0, path_1.join)(ownerPath, 'crewx.yaml')) || (0, fs_1.existsSync)((0, path_1.join)(ownerPath, 'crewx.yml')))) {
|
|
76
|
+
try {
|
|
77
|
+
new repository_1.WorkspaceRepository().registerWorkspace(ownerPath);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Workspace registration is visibility support; never make CLI execution fatal.
|
|
81
|
+
}
|
|
82
|
+
}
|
|
62
83
|
return crewx;
|
|
63
84
|
}
|
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
|
@@ -55,6 +55,8 @@ 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'))),
|
|
59
|
+
app: () => Promise.resolve().then(() => __importStar(require('@crewx/app/cli'))),
|
|
58
60
|
};
|
|
59
61
|
exports.BUILTIN_COMMANDS = new Set(Object.keys(BUILTIN_MAP));
|
|
60
62
|
// Load skill-tracer for observability (graceful degradation if unavailable)
|
|
@@ -104,7 +106,7 @@ async function wrapWithTracer(builtinName, main, args) {
|
|
|
104
106
|
}
|
|
105
107
|
await main(args);
|
|
106
108
|
}
|
|
107
|
-
async function handleBuiltin(builtinName, args) {
|
|
109
|
+
async function handleBuiltin(builtinName, args, productPackageRoot) {
|
|
108
110
|
const loader = BUILTIN_MAP[builtinName];
|
|
109
111
|
if (!loader) {
|
|
110
112
|
console.error(`Unknown built-in tool: ${builtinName}`);
|
|
@@ -112,7 +114,10 @@ async function handleBuiltin(builtinName, args) {
|
|
|
112
114
|
}
|
|
113
115
|
try {
|
|
114
116
|
const mod = await loader();
|
|
115
|
-
|
|
117
|
+
const main = builtinName === 'skill'
|
|
118
|
+
? (skillArgs) => mod.main(skillArgs, { productPackageRoot })
|
|
119
|
+
: mod.main.bind(mod);
|
|
120
|
+
await wrapWithTracer(builtinName, main, args);
|
|
116
121
|
}
|
|
117
122
|
catch (err) {
|
|
118
123
|
const code = err.code;
|
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.
|
|
@@ -60,56 +25,8 @@ function parseFlag(args, flag) {
|
|
|
60
25
|
}
|
|
61
26
|
return undefined;
|
|
62
27
|
}
|
|
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
28
|
function printAgentList(agents, total, isFiltered) {
|
|
73
|
-
|
|
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
|
-
}
|
|
29
|
+
console.log((0, sdk_1.formatAgentList)({ agents, total, isFiltered, configPath: process.env.CREWX_CONFIG ?? null }));
|
|
113
30
|
}
|
|
114
31
|
/**
|
|
115
32
|
* Handle `crewx agent ls` ā list agents with optional filters.
|
|
@@ -135,11 +52,9 @@ async function handleAgentPrompt(crewx, args) {
|
|
|
135
52
|
process.exit(1);
|
|
136
53
|
}
|
|
137
54
|
try {
|
|
138
|
-
const skills = loadAgentSkills();
|
|
139
55
|
const rendered = await crewx.renderAgentPromptFull(agentIdRaw, {
|
|
140
56
|
env: process.env,
|
|
141
57
|
session: { mode: 'query', platform: 'cli' },
|
|
142
|
-
skills,
|
|
143
58
|
});
|
|
144
59
|
const displayId = agentIdRaw.startsWith('@') ? agentIdRaw.slice(1) : agentIdRaw;
|
|
145
60
|
console.log(`\nš¤ **Rendered Prompt for Agent: ${displayId}**\n`);
|
|
@@ -197,27 +112,6 @@ async function handleAgent(args) {
|
|
|
197
112
|
process.exit(1);
|
|
198
113
|
}
|
|
199
114
|
}
|
|
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
115
|
function printAgentHelp() {
|
|
222
116
|
console.log(`
|
|
223
117
|
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>;
|