@crewx/cli 0.8.0-rc.66 → 0.8.0-rc.82
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/bin/crewx +2 -0
- package/dist/bootstrap/crewx-cli.d.ts +11 -0
- package/dist/bootstrap/crewx-cli.js +31 -0
- package/dist/builtin.d.ts +15 -0
- package/dist/{cli/builtin.handler.js → builtin.js} +21 -7
- package/dist/commands/agent.d.ts +12 -0
- package/dist/commands/agent.js +246 -0
- package/dist/commands/doctor.d.ts +12 -0
- package/dist/commands/doctor.js +190 -0
- package/dist/commands/execute.d.ts +21 -0
- package/dist/commands/execute.js +117 -0
- package/dist/commands/hook/install.d.ts +21 -0
- package/dist/commands/hook/install.js +175 -0
- package/dist/commands/hook/paths.d.ts +19 -0
- package/dist/commands/hook/paths.js +94 -0
- package/dist/commands/hook/status.d.ts +7 -0
- package/dist/commands/hook/status.js +86 -0
- package/dist/commands/hook/uninstall.d.ts +8 -0
- package/dist/commands/hook/uninstall.js +71 -0
- package/dist/commands/hook-dispatch.d.ts +15 -0
- package/dist/commands/hook-dispatch.js +180 -0
- package/dist/commands/init.d.ts +24 -0
- package/dist/commands/init.js +133 -0
- package/dist/commands/kill.d.ts +12 -0
- package/dist/commands/kill.js +49 -0
- package/dist/commands/log.d.ts +13 -0
- package/dist/commands/log.js +97 -0
- package/dist/commands/parse-agent-message.d.ts +31 -0
- package/dist/commands/parse-agent-message.js +52 -0
- package/dist/commands/parse-common-flags.d.ts +36 -0
- package/dist/commands/parse-common-flags.js +105 -0
- package/dist/commands/ps.d.ts +12 -0
- package/dist/commands/ps.js +71 -0
- package/dist/commands/query.d.ts +21 -0
- package/dist/commands/query.js +117 -0
- package/dist/commands/result.d.ts +13 -0
- package/dist/commands/result.js +73 -0
- package/dist/commands/slack.d.ts +12 -0
- package/dist/commands/slack.js +559 -0
- package/dist/commands/task-db.d.ts +33 -0
- package/dist/commands/task-db.js +107 -0
- package/dist/examples/deny-secrets-plugin.d.ts +22 -0
- package/dist/examples/deny-secrets-plugin.js +40 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/logging.d.ts +21 -0
- package/dist/logging.js +86 -0
- package/dist/main.d.ts +10 -0
- package/dist/main.js +246 -256
- package/dist/plugins/examples/echo-hook.d.ts +24 -0
- package/dist/plugins/examples/echo-hook.js +60 -0
- package/dist/plugins/examples/verify-echo-hook.d.ts +8 -0
- package/dist/plugins/examples/verify-echo-hook.js +47 -0
- package/dist/plugins/sqlite-tracing.d.ts +13 -0
- package/dist/plugins/sqlite-tracing.js +20 -0
- package/dist/register-builtin-tools.d.ts +5 -0
- package/dist/register-builtin-tools.js +9 -0
- package/dist/slack/file-download.d.ts +17 -0
- package/dist/slack/file-download.js +134 -0
- package/dist/slack/markdown.d.ts +5 -0
- package/dist/slack/markdown.js +33 -0
- package/dist/utils/env-defaults.d.ts +5 -0
- package/dist/utils/env-defaults.js +10 -0
- package/dist/utils/version.d.ts +1 -0
- package/dist/utils/version.js +28 -0
- package/package.json +32 -115
- package/README.md +0 -663
- package/dist/ai-provider.service.d.ts +0 -36
- package/dist/ai-provider.service.js +0 -315
- package/dist/ai-provider.service.js.map +0 -1
- package/dist/ai.service.d.ts +0 -17
- package/dist/ai.service.js +0 -51
- package/dist/ai.service.js.map +0 -1
- package/dist/app.module.d.ts +0 -5
- package/dist/app.module.js +0 -165
- package/dist/app.module.js.map +0 -1
- package/dist/cli/agent.handler.d.ts +0 -2
- package/dist/cli/agent.handler.js +0 -186
- package/dist/cli/agent.handler.js.map +0 -1
- package/dist/cli/builtin.handler.d.ts +0 -3
- package/dist/cli/builtin.handler.js.map +0 -1
- package/dist/cli/chat.handler.d.ts +0 -20
- package/dist/cli/chat.handler.js +0 -446
- package/dist/cli/chat.handler.js.map +0 -1
- package/dist/cli/cli.handler.d.ts +0 -4
- package/dist/cli/cli.handler.js +0 -119
- package/dist/cli/cli.handler.js.map +0 -1
- package/dist/cli/doctor.handler.d.ts +0 -38
- package/dist/cli/doctor.handler.js +0 -495
- package/dist/cli/doctor.handler.js.map +0 -1
- package/dist/cli/execute.handler.d.ts +0 -2
- package/dist/cli/execute.handler.js +0 -376
- package/dist/cli/execute.handler.js.map +0 -1
- package/dist/cli/help.handler.d.ts +0 -2
- package/dist/cli/help.handler.js +0 -10
- package/dist/cli/help.handler.js.map +0 -1
- package/dist/cli/init.handler.d.ts +0 -26
- package/dist/cli/init.handler.js +0 -450
- package/dist/cli/init.handler.js.map +0 -1
- package/dist/cli/log.handler.d.ts +0 -2
- package/dist/cli/log.handler.js +0 -69
- package/dist/cli/log.handler.js.map +0 -1
- package/dist/cli/mcp.handler.d.ts +0 -3
- package/dist/cli/mcp.handler.js +0 -121
- package/dist/cli/mcp.handler.js.map +0 -1
- package/dist/cli/query.handler.d.ts +0 -2
- package/dist/cli/query.handler.js +0 -392
- package/dist/cli/query.handler.js.map +0 -1
- package/dist/cli/skill.handler.d.ts +0 -2
- package/dist/cli/skill.handler.js +0 -252
- package/dist/cli/skill.handler.js.map +0 -1
- package/dist/cli/slack-files.handler.d.ts +0 -2
- package/dist/cli/slack-files.handler.js +0 -291
- package/dist/cli/slack-files.handler.js.map +0 -1
- package/dist/cli/template.handler.d.ts +0 -2
- package/dist/cli/template.handler.js +0 -188
- package/dist/cli/template.handler.js.map +0 -1
- package/dist/cli/templates.handler.d.ts +0 -2
- package/dist/cli/templates.handler.js +0 -100
- package/dist/cli/templates.handler.js.map +0 -1
- package/dist/cli-options.d.ts +0 -40
- package/dist/cli-options.js +0 -371
- package/dist/cli-options.js.map +0 -1
- package/dist/config/timeout.config.d.ts +0 -14
- package/dist/config/timeout.config.js +0 -34
- package/dist/config/timeout.config.js.map +0 -1
- package/dist/conversation/base-conversation-history.provider.d.ts +0 -12
- package/dist/conversation/base-conversation-history.provider.js +0 -45
- package/dist/conversation/base-conversation-history.provider.js.map +0 -1
- package/dist/conversation/cli-box-reader.adapter.d.ts +0 -6
- package/dist/conversation/cli-box-reader.adapter.js +0 -10
- package/dist/conversation/cli-box-reader.adapter.js.map +0 -1
- package/dist/conversation/cli-conversation-history.provider.d.ts +0 -16
- package/dist/conversation/cli-conversation-history.provider.js +0 -112
- package/dist/conversation/cli-conversation-history.provider.js.map +0 -1
- package/dist/conversation/cli-task-reader.adapter.d.ts +0 -6
- package/dist/conversation/cli-task-reader.adapter.js +0 -25
- package/dist/conversation/cli-task-reader.adapter.js.map +0 -1
- package/dist/conversation/conversation-provider.factory.d.ts +0 -10
- package/dist/conversation/conversation-provider.factory.js +0 -50
- package/dist/conversation/conversation-provider.factory.js.map +0 -1
- package/dist/conversation/index.d.ts +0 -8
- package/dist/conversation/index.js +0 -29
- package/dist/conversation/index.js.map +0 -1
- package/dist/conversation/slack-conversation-history.provider.d.ts +0 -29
- package/dist/conversation/slack-conversation-history.provider.js +0 -302
- package/dist/conversation/slack-conversation-history.provider.js.map +0 -1
- package/dist/crewx.tool.d.ts +0 -360
- package/dist/crewx.tool.js +0 -2531
- package/dist/crewx.tool.js.map +0 -1
- package/dist/crewx.tool.spec.d.ts +0 -1
- package/dist/crewx.tool.spec.js +0 -222
- package/dist/crewx.tool.spec.js.map +0 -1
- package/dist/guards/bearer-auth.guard.d.ts +0 -7
- package/dist/guards/bearer-auth.guard.js +0 -44
- package/dist/guards/bearer-auth.guard.js.map +0 -1
- package/dist/health.controller.d.ts +0 -6
- package/dist/health.controller.js +0 -32
- package/dist/health.controller.js.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/mcp.controller.d.ts +0 -8
- package/dist/mcp.controller.js +0 -62
- package/dist/mcp.controller.js.map +0 -1
- package/dist/package.json +0 -3
- package/dist/providers/dynamic-provider.factory.d.ts +0 -17
- package/dist/providers/dynamic-provider.factory.js +0 -138
- package/dist/providers/dynamic-provider.factory.js.map +0 -1
- package/dist/providers/logger.adapter.d.ts +0 -7
- package/dist/providers/logger.adapter.js +0 -107
- package/dist/providers/logger.adapter.js.map +0 -1
- package/dist/services/agent-loader.service.d.ts +0 -35
- package/dist/services/agent-loader.service.js +0 -623
- package/dist/services/agent-loader.service.js.map +0 -1
- package/dist/services/auth.service.d.ts +0 -9
- package/dist/services/auth.service.js +0 -47
- package/dist/services/auth.service.js.map +0 -1
- package/dist/services/config-validator.service.d.ts +0 -29
- package/dist/services/config-validator.service.js +0 -483
- package/dist/services/config-validator.service.js.map +0 -1
- package/dist/services/config.service.d.ts +0 -45
- package/dist/services/config.service.js +0 -352
- package/dist/services/config.service.js.map +0 -1
- package/dist/services/document-loader.service.d.ts +0 -26
- package/dist/services/document-loader.service.js +0 -186
- package/dist/services/document-loader.service.js.map +0 -1
- package/dist/services/help.service.d.ts +0 -5
- package/dist/services/help.service.js +0 -139
- package/dist/services/help.service.js.map +0 -1
- package/dist/services/intelligent-compression.service.d.ts +0 -20
- package/dist/services/intelligent-compression.service.js +0 -179
- package/dist/services/intelligent-compression.service.js.map +0 -1
- package/dist/services/mcp-client.service.d.ts +0 -26
- package/dist/services/mcp-client.service.js +0 -81
- package/dist/services/mcp-client.service.js.map +0 -1
- package/dist/services/parallel-processing.service.d.ts +0 -108
- package/dist/services/parallel-processing.service.js +0 -333
- package/dist/services/parallel-processing.service.js.map +0 -1
- package/dist/services/provider-bridge.service.d.ts +0 -35
- package/dist/services/provider-bridge.service.js +0 -224
- package/dist/services/provider-bridge.service.js.map +0 -1
- package/dist/services/remote-agent.service.d.ts +0 -50
- package/dist/services/remote-agent.service.js +0 -171
- package/dist/services/remote-agent.service.js.map +0 -1
- package/dist/services/result-formatter.service.d.ts +0 -27
- package/dist/services/result-formatter.service.js +0 -126
- package/dist/services/result-formatter.service.js.map +0 -1
- package/dist/services/skill-loader.service.d.ts +0 -15
- package/dist/services/skill-loader.service.js +0 -278
- package/dist/services/skill-loader.service.js.map +0 -1
- package/dist/services/skill.service.d.ts +0 -69
- package/dist/services/skill.service.js +0 -779
- package/dist/services/skill.service.js.map +0 -1
- package/dist/services/skill.service.spec.d.ts +0 -1
- package/dist/services/skill.service.spec.js +0 -168
- package/dist/services/skill.service.spec.js.map +0 -1
- package/dist/services/task-management.service.d.ts +0 -71
- package/dist/services/task-management.service.js +0 -324
- package/dist/services/task-management.service.js.map +0 -1
- package/dist/services/template.service.d.ts +0 -61
- package/dist/services/template.service.js +0 -416
- package/dist/services/template.service.js.map +0 -1
- package/dist/services/tool-call.service.d.ts +0 -16
- package/dist/services/tool-call.service.js +0 -302
- package/dist/services/tool-call.service.js.map +0 -1
- package/dist/services/tracing.service.d.ts +0 -197
- package/dist/services/tracing.service.js +0 -1267
- package/dist/services/tracing.service.js.map +0 -1
- package/dist/slack/formatters/message.formatter.d.ts +0 -43
- package/dist/slack/formatters/message.formatter.js +0 -505
- package/dist/slack/formatters/message.formatter.js.map +0 -1
- package/dist/slack/services/slack-file-download.service.d.ts +0 -58
- package/dist/slack/services/slack-file-download.service.js +0 -558
- package/dist/slack/services/slack-file-download.service.js.map +0 -1
- package/dist/slack/slack-bot.d.ts +0 -33
- package/dist/slack/slack-bot.js +0 -568
- package/dist/slack/slack-bot.js.map +0 -1
- package/dist/stderr.logger.d.ts +0 -8
- package/dist/stderr.logger.js +0 -26
- package/dist/stderr.logger.js.map +0 -1
- package/dist/types/usage.types.d.ts +0 -107
- package/dist/types/usage.types.js +0 -3
- package/dist/types/usage.types.js.map +0 -1
- package/dist/utils/config-utils.d.ts +0 -15
- package/dist/utils/config-utils.js +0 -69
- package/dist/utils/config-utils.js.map +0 -1
- package/dist/utils/extract-text.d.ts +0 -1
- package/dist/utils/extract-text.js +0 -15
- package/dist/utils/extract-text.js.map +0 -1
- package/dist/utils/mcp-installer.d.ts +0 -20
- package/dist/utils/mcp-installer.js +0 -199
- package/dist/utils/mcp-installer.js.map +0 -1
- package/dist/utils/project-hash.d.ts +0 -6
- package/dist/utils/project-hash.js +0 -70
- package/dist/utils/project-hash.js.map +0 -1
- package/dist/utils/simple-security.d.ts +0 -3
- package/dist/utils/simple-security.js +0 -20
- package/dist/utils/simple-security.js.map +0 -1
- package/dist/utils/stdin-utils.d.ts +0 -6
- package/dist/utils/stdin-utils.js +0 -109
- package/dist/utils/stdin-utils.js.map +0 -1
- package/dist/utils/template-processor.d.ts +0 -27
- package/dist/utils/template-processor.js +0 -395
- package/dist/utils/template-processor.js.map +0 -1
- package/dist/utils/terminal-message-formatter.d.ts +0 -23
- package/dist/utils/terminal-message-formatter.js +0 -136
- package/dist/utils/terminal-message-formatter.js.map +0 -1
- package/dist/version.d.ts +0 -1
- package/dist/version.js +0 -17
- package/dist/version.js.map +0 -1
- package/dist/workspace.service.d.ts +0 -44
- package/dist/workspace.service.js +0 -299
- package/dist/workspace.service.js.map +0 -1
- package/scripts/backfill-tokens.js +0 -218
- package/scripts/postbuild-cli.mjs +0 -88
- package/scripts/postinstall-cli.mjs +0 -30
- package/templates/agents/default.yaml +0 -490
- package/templates/agents/minimal.yaml +0 -16
- package/templates/documents/conversation-history-default.hbs +0 -17
- package/templates/documents/crewx-manual.md +0 -2278
- package/templates/documents/crewx-quick-guide.md +0 -147
- package/templates/versions.json +0 -19
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared SQLite helper for ps/kill/result CLI commands.
|
|
4
|
+
* Reads from (or writes to) the global ~/.crewx/crewx.db
|
|
5
|
+
* populated by SqliteTracingPlugin.
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.getDbPath = getDbPath;
|
|
12
|
+
exports.openDb = openDb;
|
|
13
|
+
exports.getRunningTasks = getRunningTasks;
|
|
14
|
+
exports.getAllTasks = getAllTasks;
|
|
15
|
+
exports.getTask = getTask;
|
|
16
|
+
exports.killTask = killTask;
|
|
17
|
+
const fs_1 = require("fs");
|
|
18
|
+
const path_1 = require("path");
|
|
19
|
+
const os_1 = require("os");
|
|
20
|
+
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
|
21
|
+
function getDbPath(dbRoot) {
|
|
22
|
+
return (0, path_1.join)(dbRoot ?? (0, os_1.homedir)(), '.crewx', 'crewx.db');
|
|
23
|
+
}
|
|
24
|
+
function openDb(readonly = true, dbRoot) {
|
|
25
|
+
const dbPath = getDbPath(dbRoot);
|
|
26
|
+
if (!(0, fs_1.existsSync)(dbPath))
|
|
27
|
+
return null;
|
|
28
|
+
return new better_sqlite3_1.default(dbPath, { readonly });
|
|
29
|
+
}
|
|
30
|
+
/** Return all tasks with status='running'. */
|
|
31
|
+
function getRunningTasks(dbRoot) {
|
|
32
|
+
const db = openDb(true, dbRoot);
|
|
33
|
+
if (!db)
|
|
34
|
+
return [];
|
|
35
|
+
try {
|
|
36
|
+
return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
|
|
37
|
+
result, error, duration_ms
|
|
38
|
+
FROM tasks WHERE status = 'running' ORDER BY started_at DESC`).all();
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
db.close();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Return all tasks ordered by started_at desc. */
|
|
45
|
+
function getAllTasks(dbRoot) {
|
|
46
|
+
const db = openDb(true, dbRoot);
|
|
47
|
+
if (!db)
|
|
48
|
+
return [];
|
|
49
|
+
try {
|
|
50
|
+
return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
|
|
51
|
+
result, error, duration_ms
|
|
52
|
+
FROM tasks ORDER BY started_at DESC`).all();
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
db.close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Return a single task by id, or undefined if not found. */
|
|
59
|
+
function getTask(id, dbRoot) {
|
|
60
|
+
const db = openDb(true, dbRoot);
|
|
61
|
+
if (!db)
|
|
62
|
+
return undefined;
|
|
63
|
+
try {
|
|
64
|
+
return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
|
|
65
|
+
result, error, duration_ms
|
|
66
|
+
FROM tasks WHERE id = ?`).get(id);
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
db.close();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Send SIGTERM to the task's pid and mark it failed. Returns ok/message. */
|
|
73
|
+
function killTask(id, dbRoot) {
|
|
74
|
+
const db = openDb(false, dbRoot);
|
|
75
|
+
if (!db)
|
|
76
|
+
return { ok: false, message: `crewx.db not found — no running tasks.` };
|
|
77
|
+
try {
|
|
78
|
+
const task = db.prepare(`SELECT id, status, pid FROM tasks WHERE id = ?`).get(id);
|
|
79
|
+
if (!task) {
|
|
80
|
+
return { ok: false, message: `Task not found: ${id}` };
|
|
81
|
+
}
|
|
82
|
+
if (task.status !== 'running') {
|
|
83
|
+
return { ok: false, message: `Task ${id} is not running (status: ${task.status})` };
|
|
84
|
+
}
|
|
85
|
+
if (task.pid) {
|
|
86
|
+
try {
|
|
87
|
+
process.kill(task.pid, 'SIGTERM');
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
const code = err.code;
|
|
91
|
+
if (code !== 'ESRCH') {
|
|
92
|
+
return {
|
|
93
|
+
ok: false,
|
|
94
|
+
message: `Failed to kill PID ${task.pid}: ${err instanceof Error ? err.message : String(err)}`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// ESRCH = process already gone — still clean up the record
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
db.prepare(`UPDATE tasks SET status='failed', error='killed by user',
|
|
101
|
+
completed_at=?, pid=NULL WHERE id=?`).run(new Date().toISOString(), id);
|
|
102
|
+
return { ok: true, message: `Killed task ${id}${task.pid ? ` (PID: ${task.pid})` : ''}` };
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
db.close();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DenyIfTouchesSecretsPlugin — Phase 0 demo HookPlugin.
|
|
3
|
+
*
|
|
4
|
+
* Denies Bash tool calls whose command string contains ".env".
|
|
5
|
+
* Pure string matching — trivially bypassable (see README).
|
|
6
|
+
*
|
|
7
|
+
* SECURITY NOTE:
|
|
8
|
+
* Do NOT include tool.input content in deny reasons.
|
|
9
|
+
* Use static messages only to prevent prompt injection.
|
|
10
|
+
* ✅ return ctx.deny('Secrets-related command');
|
|
11
|
+
* ❌ return ctx.deny(`Blocked: ${cmd}`);
|
|
12
|
+
*/
|
|
13
|
+
import { HookPlugin } from '@crewx/sdk/hooks';
|
|
14
|
+
import type { HookContext, HookResult } from '@crewx/sdk/hooks';
|
|
15
|
+
export declare class DenyIfTouchesSecretsPlugin extends HookPlugin {
|
|
16
|
+
readonly name = "deny-secrets";
|
|
17
|
+
readonly version = "0.1.0";
|
|
18
|
+
readonly capabilities: {
|
|
19
|
+
required: readonly ["deny"];
|
|
20
|
+
};
|
|
21
|
+
run(ctx: HookContext): Promise<HookResult>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DenyIfTouchesSecretsPlugin — Phase 0 demo HookPlugin.
|
|
4
|
+
*
|
|
5
|
+
* Denies Bash tool calls whose command string contains ".env".
|
|
6
|
+
* Pure string matching — trivially bypassable (see README).
|
|
7
|
+
*
|
|
8
|
+
* SECURITY NOTE:
|
|
9
|
+
* Do NOT include tool.input content in deny reasons.
|
|
10
|
+
* Use static messages only to prevent prompt injection.
|
|
11
|
+
* ✅ return ctx.deny('Secrets-related command');
|
|
12
|
+
* ❌ return ctx.deny(`Blocked: ${cmd}`);
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DenyIfTouchesSecretsPlugin = void 0;
|
|
16
|
+
const hooks_1 = require("@crewx/sdk/hooks");
|
|
17
|
+
const SECRET_PATTERNS = ['.env', 'credentials.json', 'service-account-key.json'];
|
|
18
|
+
const SHELL_TOOL_NAMES = new Set(['Bash', 'shell', 'local_shell']);
|
|
19
|
+
class DenyIfTouchesSecretsPlugin extends hooks_1.HookPlugin {
|
|
20
|
+
name = 'deny-secrets';
|
|
21
|
+
version = '0.1.0';
|
|
22
|
+
capabilities = { required: ['deny'] };
|
|
23
|
+
async run(ctx) {
|
|
24
|
+
if (!SHELL_TOOL_NAMES.has(ctx.tool.rawName) && ctx.tool.name !== 'shell') {
|
|
25
|
+
return ctx.pass();
|
|
26
|
+
}
|
|
27
|
+
const input = ctx.tool.input;
|
|
28
|
+
const command = input?.command;
|
|
29
|
+
if (typeof command !== 'string') {
|
|
30
|
+
return ctx.pass();
|
|
31
|
+
}
|
|
32
|
+
for (const pattern of SECRET_PATTERNS) {
|
|
33
|
+
if (command.includes(pattern)) {
|
|
34
|
+
return ctx.deny('Secrets-related command');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return ctx.pass();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.DenyIfTouchesSecretsPlugin = DenyIfTouchesSecretsPlugin;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { handleInit, type InitResult } from './commands/init';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI file-based logging for CrewX SDK events.
|
|
3
|
+
*
|
|
4
|
+
* Subscribe to task:start / task:end events from a Crewx instance
|
|
5
|
+
* and write structured log files to .crewx/logs/ in the workspace root.
|
|
6
|
+
*
|
|
7
|
+
* File name format: {YYYYMMDDTHHmmss}_{traceId}.log
|
|
8
|
+
* e.g. 20260412T145044_tsk_AbCdEfGh.log
|
|
9
|
+
*
|
|
10
|
+
* Format mirrors cli-bak TaskManagementService for backward compatibility.
|
|
11
|
+
*/
|
|
12
|
+
import type { Crewx } from '@crewx/sdk';
|
|
13
|
+
/**
|
|
14
|
+
* Attach file-based logging to a Crewx instance.
|
|
15
|
+
* Subscribes to task:start and task:end events and writes log files.
|
|
16
|
+
*
|
|
17
|
+
* @param crewx - The Crewx instance to attach logging to
|
|
18
|
+
* @param workspaceRoot - Root directory for .crewx/logs/ (default: process.cwd())
|
|
19
|
+
* @returns Cleanup function that removes all event listeners
|
|
20
|
+
*/
|
|
21
|
+
export declare function attachFileLogger(crewx: Crewx, workspaceRoot?: string): () => void;
|
package/dist/logging.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CLI file-based logging for CrewX SDK events.
|
|
4
|
+
*
|
|
5
|
+
* Subscribe to task:start / task:end events from a Crewx instance
|
|
6
|
+
* and write structured log files to .crewx/logs/ in the workspace root.
|
|
7
|
+
*
|
|
8
|
+
* File name format: {YYYYMMDDTHHmmss}_{traceId}.log
|
|
9
|
+
* e.g. 20260412T145044_tsk_AbCdEfGh.log
|
|
10
|
+
*
|
|
11
|
+
* Format mirrors cli-bak TaskManagementService for backward compatibility.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.attachFileLogger = attachFileLogger;
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const CREWX_VERSION = '0.9.0-alpha.1';
|
|
18
|
+
/** Format Date as YYYYMMDDTHHmmss (local time) */
|
|
19
|
+
function formatTimestamp(date) {
|
|
20
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
21
|
+
return (`${date.getFullYear()}` +
|
|
22
|
+
`${pad(date.getMonth() + 1)}` +
|
|
23
|
+
`${pad(date.getDate())}` +
|
|
24
|
+
`T${pad(date.getHours())}` +
|
|
25
|
+
`${pad(date.getMinutes())}` +
|
|
26
|
+
`${pad(date.getSeconds())}`);
|
|
27
|
+
}
|
|
28
|
+
function ensureLogsDir(logsDir) {
|
|
29
|
+
if (!(0, fs_1.existsSync)(logsDir)) {
|
|
30
|
+
(0, fs_1.mkdirSync)(logsDir, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Attach file-based logging to a Crewx instance.
|
|
35
|
+
* Subscribes to task:start and task:end events and writes log files.
|
|
36
|
+
*
|
|
37
|
+
* @param crewx - The Crewx instance to attach logging to
|
|
38
|
+
* @param workspaceRoot - Root directory for .crewx/logs/ (default: process.cwd())
|
|
39
|
+
* @returns Cleanup function that removes all event listeners
|
|
40
|
+
*/
|
|
41
|
+
function attachFileLogger(crewx, workspaceRoot) {
|
|
42
|
+
const logsDir = (0, path_1.join)(workspaceRoot ?? process.cwd(), '.crewx', 'logs');
|
|
43
|
+
// traceId → absolute log file path (in-memory map for the process lifetime)
|
|
44
|
+
const logFiles = new Map();
|
|
45
|
+
const unsubStart = crewx.on('task:start', (event) => {
|
|
46
|
+
try {
|
|
47
|
+
ensureLogsDir(logsDir);
|
|
48
|
+
const ts = formatTimestamp(event.timestamp);
|
|
49
|
+
const logFile = (0, path_1.join)(logsDir, `${ts}_${event.traceId}.log`);
|
|
50
|
+
logFiles.set(event.traceId, logFile);
|
|
51
|
+
const header = `=== TASK LOG: ${event.traceId} ===\n` +
|
|
52
|
+
`CrewX Version: ${CREWX_VERSION}\n` +
|
|
53
|
+
`Mode: ${event.mode}\n` +
|
|
54
|
+
`Agent: ${event.agentRef}\n` +
|
|
55
|
+
`Started: ${event.timestamp.toLocaleString()}\n` +
|
|
56
|
+
`Message: ${event.message}\n` +
|
|
57
|
+
`\n`;
|
|
58
|
+
(0, fs_1.writeFileSync)(logFile, header, { encoding: 'utf8', mode: 0o600 });
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// Non-fatal: CLI logging must never crash the main process
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const unsubEnd = crewx.on('task:end', (event) => {
|
|
65
|
+
try {
|
|
66
|
+
const logFile = logFiles.get(event.traceId);
|
|
67
|
+
if (!logFile)
|
|
68
|
+
return;
|
|
69
|
+
const ts = new Date().toLocaleString();
|
|
70
|
+
const status = event.error
|
|
71
|
+
? `failed: ${event.error.message}`
|
|
72
|
+
: 'completed successfully';
|
|
73
|
+
const completion = `[${ts}] INFO: Task ${status} in ${event.durationMs}ms\n` +
|
|
74
|
+
`[${ts}] INFO: Process closed with exit code: ${event.error ? 1 : 0}\n`;
|
|
75
|
+
(0, fs_1.appendFileSync)(logFile, completion, 'utf8');
|
|
76
|
+
logFiles.delete(event.traceId);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Non-fatal
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return () => {
|
|
83
|
+
unsubStart();
|
|
84
|
+
unsubEnd();
|
|
85
|
+
};
|
|
86
|
+
}
|
package/dist/main.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CrewX CLI entry point.
|
|
4
|
+
* Dispatches commands to the appropriate handler.
|
|
5
|
+
*
|
|
6
|
+
* Boot sequence:
|
|
7
|
+
* 1. Inject CREWX_CLI / CREWX_WORKSPACE env defaults (must be first)
|
|
8
|
+
* 2. Parse command
|
|
9
|
+
* 3. Dispatch to handler
|
|
10
|
+
*/
|
|
1
11
|
export {};
|