@sowonai/crewx-cli 0.8.0-rc.0 → 0.8.0-rc.10
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/README.md +2 -2
- package/dist/app.module.js +4 -0
- package/dist/app.module.js.map +1 -1
- package/dist/cli/agent.handler.js +45 -1
- package/dist/cli/agent.handler.js.map +1 -1
- package/dist/cli/cli.handler.js +4 -0
- package/dist/cli/cli.handler.js.map +1 -1
- package/dist/cli/init.handler.js +1 -1
- package/dist/cli/skill.handler.d.ts +2 -0
- package/dist/cli/skill.handler.js +143 -0
- package/dist/cli/skill.handler.js.map +1 -0
- package/dist/cli-options.d.ts +4 -0
- package/dist/cli-options.js +19 -0
- package/dist/cli-options.js.map +1 -1
- package/dist/crewx.tool.d.ts +1 -0
- package/dist/crewx.tool.js +49 -0
- package/dist/crewx.tool.js.map +1 -1
- package/dist/main.js +6 -1
- package/dist/main.js.map +1 -1
- package/dist/providers/dynamic-provider.factory.js +2 -0
- package/dist/providers/dynamic-provider.factory.js.map +1 -1
- package/dist/services/skill.service.d.ts +66 -0
- package/dist/services/skill.service.js +584 -0
- package/dist/services/skill.service.js.map +1 -0
- package/dist/services/skill.service.spec.d.ts +1 -0
- package/dist/services/skill.service.spec.js +35 -0
- package/dist/services/skill.service.spec.js.map +1 -0
- package/dist/services/tracing.service.d.ts +95 -0
- package/dist/services/tracing.service.js +422 -0
- package/dist/services/tracing.service.js.map +1 -0
- package/dist/slack/formatters/message.formatter.d.ts +4 -0
- package/dist/slack/formatters/message.formatter.js +93 -49
- package/dist/slack/formatters/message.formatter.js.map +1 -1
- package/dist/utils/template-processor.js +18 -1
- package/dist/utils/template-processor.js.map +1 -1
- package/package.json +4 -2
- package/templates/agents/default.yaml +2 -0
- package/templates/documents/conversation-history-default.hbs +17 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
2
|
+
export declare enum TaskStatus {
|
|
3
|
+
PENDING = "pending",
|
|
4
|
+
RUNNING = "running",
|
|
5
|
+
SUCCESS = "success",
|
|
6
|
+
FAILED = "failed"
|
|
7
|
+
}
|
|
8
|
+
export declare enum SpanKind {
|
|
9
|
+
INTERNAL = "internal",
|
|
10
|
+
CLIENT = "client",
|
|
11
|
+
SERVER = "server",
|
|
12
|
+
PRODUCER = "producer",
|
|
13
|
+
CONSUMER = "consumer"
|
|
14
|
+
}
|
|
15
|
+
export interface TaskRecord {
|
|
16
|
+
id: string;
|
|
17
|
+
agent_id: string;
|
|
18
|
+
user_id?: string;
|
|
19
|
+
prompt: string;
|
|
20
|
+
mode: 'query' | 'execute';
|
|
21
|
+
status: TaskStatus;
|
|
22
|
+
result?: string;
|
|
23
|
+
error?: string;
|
|
24
|
+
started_at: string;
|
|
25
|
+
completed_at?: string;
|
|
26
|
+
duration_ms?: number;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export interface SpanRecord {
|
|
30
|
+
id: string;
|
|
31
|
+
task_id: string;
|
|
32
|
+
parent_span_id?: string;
|
|
33
|
+
name: string;
|
|
34
|
+
kind: SpanKind;
|
|
35
|
+
status: 'ok' | 'error';
|
|
36
|
+
started_at: string;
|
|
37
|
+
completed_at?: string;
|
|
38
|
+
duration_ms?: number;
|
|
39
|
+
input?: string;
|
|
40
|
+
output?: string;
|
|
41
|
+
error?: string;
|
|
42
|
+
attributes?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
export interface CreateTaskInput {
|
|
45
|
+
agent_id: string;
|
|
46
|
+
user_id?: string;
|
|
47
|
+
prompt: string;
|
|
48
|
+
mode: 'query' | 'execute';
|
|
49
|
+
metadata?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
export interface CreateSpanInput {
|
|
52
|
+
task_id: string;
|
|
53
|
+
parent_span_id?: string;
|
|
54
|
+
name: string;
|
|
55
|
+
kind?: SpanKind;
|
|
56
|
+
input?: string;
|
|
57
|
+
attributes?: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
export interface TracingServiceOptions {
|
|
60
|
+
dbPath?: string;
|
|
61
|
+
}
|
|
62
|
+
export declare class TracingService implements OnModuleInit, OnModuleDestroy {
|
|
63
|
+
private readonly logger;
|
|
64
|
+
private db;
|
|
65
|
+
private dbPath;
|
|
66
|
+
constructor(options?: TracingServiceOptions);
|
|
67
|
+
onModuleInit(): void;
|
|
68
|
+
onModuleDestroy(): void;
|
|
69
|
+
private initializeDatabase;
|
|
70
|
+
close(): void;
|
|
71
|
+
private generateId;
|
|
72
|
+
private now;
|
|
73
|
+
createTask(input: CreateTaskInput): string | null;
|
|
74
|
+
completeTask(taskId: string, result?: string): boolean;
|
|
75
|
+
failTask(taskId: string, error: string): boolean;
|
|
76
|
+
getTask(taskId: string): TaskRecord | null;
|
|
77
|
+
listTasks(options?: {
|
|
78
|
+
limit?: number;
|
|
79
|
+
offset?: number;
|
|
80
|
+
agentId?: string;
|
|
81
|
+
}): TaskRecord[];
|
|
82
|
+
createSpan(input: CreateSpanInput): string | null;
|
|
83
|
+
completeSpan(spanId: string, output?: string): boolean;
|
|
84
|
+
failSpan(spanId: string, error: string): boolean;
|
|
85
|
+
getSpansForTask(taskId: string): SpanRecord[];
|
|
86
|
+
getSpan(spanId: string): SpanRecord | null;
|
|
87
|
+
cleanupOldTasks(daysToKeep?: number): number;
|
|
88
|
+
getStats(): {
|
|
89
|
+
taskCount: number;
|
|
90
|
+
spanCount: number;
|
|
91
|
+
dbSizeBytes: number;
|
|
92
|
+
} | null;
|
|
93
|
+
isEnabled(): boolean;
|
|
94
|
+
getDbPath(): string;
|
|
95
|
+
}
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
var TracingService_1;
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.TracingService = exports.SpanKind = exports.TaskStatus = void 0;
|
|
53
|
+
const common_1 = require("@nestjs/common");
|
|
54
|
+
const fs = __importStar(require("fs"));
|
|
55
|
+
const path = __importStar(require("path"));
|
|
56
|
+
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
|
57
|
+
var TaskStatus;
|
|
58
|
+
(function (TaskStatus) {
|
|
59
|
+
TaskStatus["PENDING"] = "pending";
|
|
60
|
+
TaskStatus["RUNNING"] = "running";
|
|
61
|
+
TaskStatus["SUCCESS"] = "success";
|
|
62
|
+
TaskStatus["FAILED"] = "failed";
|
|
63
|
+
})(TaskStatus || (exports.TaskStatus = TaskStatus = {}));
|
|
64
|
+
var SpanKind;
|
|
65
|
+
(function (SpanKind) {
|
|
66
|
+
SpanKind["INTERNAL"] = "internal";
|
|
67
|
+
SpanKind["CLIENT"] = "client";
|
|
68
|
+
SpanKind["SERVER"] = "server";
|
|
69
|
+
SpanKind["PRODUCER"] = "producer";
|
|
70
|
+
SpanKind["CONSUMER"] = "consumer";
|
|
71
|
+
})(SpanKind || (exports.SpanKind = SpanKind = {}));
|
|
72
|
+
let TracingService = TracingService_1 = class TracingService {
|
|
73
|
+
constructor(options) {
|
|
74
|
+
this.logger = new common_1.Logger(TracingService_1.name);
|
|
75
|
+
this.db = null;
|
|
76
|
+
if (options?.dbPath) {
|
|
77
|
+
this.dbPath = options.dbPath;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const crewxDir = path.join(process.cwd(), '.crewx');
|
|
81
|
+
this.dbPath = path.join(crewxDir, 'traces.db');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
onModuleInit() {
|
|
85
|
+
this.initializeDatabase();
|
|
86
|
+
}
|
|
87
|
+
onModuleDestroy() {
|
|
88
|
+
this.close();
|
|
89
|
+
}
|
|
90
|
+
initializeDatabase() {
|
|
91
|
+
try {
|
|
92
|
+
const dir = path.dirname(this.dbPath);
|
|
93
|
+
if (!fs.existsSync(dir)) {
|
|
94
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
95
|
+
}
|
|
96
|
+
this.db = new better_sqlite3_1.default(this.dbPath);
|
|
97
|
+
this.db.pragma('journal_mode = WAL');
|
|
98
|
+
this.db.exec(`
|
|
99
|
+
CREATE TABLE IF NOT EXISTS tasks (
|
|
100
|
+
id TEXT PRIMARY KEY,
|
|
101
|
+
agent_id TEXT NOT NULL,
|
|
102
|
+
user_id TEXT,
|
|
103
|
+
prompt TEXT NOT NULL,
|
|
104
|
+
mode TEXT NOT NULL CHECK (mode IN ('query', 'execute')),
|
|
105
|
+
status TEXT NOT NULL CHECK (status IN ('pending', 'running', 'success', 'failed')),
|
|
106
|
+
result TEXT,
|
|
107
|
+
error TEXT,
|
|
108
|
+
started_at TEXT NOT NULL,
|
|
109
|
+
completed_at TEXT,
|
|
110
|
+
duration_ms INTEGER,
|
|
111
|
+
metadata TEXT
|
|
112
|
+
)
|
|
113
|
+
`);
|
|
114
|
+
this.db.exec(`
|
|
115
|
+
CREATE TABLE IF NOT EXISTS spans (
|
|
116
|
+
id TEXT PRIMARY KEY,
|
|
117
|
+
task_id TEXT NOT NULL,
|
|
118
|
+
parent_span_id TEXT,
|
|
119
|
+
name TEXT NOT NULL,
|
|
120
|
+
kind TEXT NOT NULL CHECK (kind IN ('internal', 'client', 'server', 'producer', 'consumer')),
|
|
121
|
+
status TEXT NOT NULL CHECK (status IN ('ok', 'error')),
|
|
122
|
+
started_at TEXT NOT NULL,
|
|
123
|
+
completed_at TEXT,
|
|
124
|
+
duration_ms INTEGER,
|
|
125
|
+
input TEXT,
|
|
126
|
+
output TEXT,
|
|
127
|
+
error TEXT,
|
|
128
|
+
attributes TEXT,
|
|
129
|
+
FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE,
|
|
130
|
+
FOREIGN KEY (parent_span_id) REFERENCES spans(id) ON DELETE SET NULL
|
|
131
|
+
)
|
|
132
|
+
`);
|
|
133
|
+
this.db.exec(`
|
|
134
|
+
CREATE INDEX IF NOT EXISTS idx_tasks_agent_id ON tasks(agent_id);
|
|
135
|
+
CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(status);
|
|
136
|
+
CREATE INDEX IF NOT EXISTS idx_tasks_started_at ON tasks(started_at);
|
|
137
|
+
CREATE INDEX IF NOT EXISTS idx_spans_task_id ON spans(task_id);
|
|
138
|
+
CREATE INDEX IF NOT EXISTS idx_spans_parent_span_id ON spans(parent_span_id);
|
|
139
|
+
`);
|
|
140
|
+
this.logger.log(`Tracing database initialized at ${this.dbPath}`);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
this.logger.error(`Failed to initialize tracing database: ${error instanceof Error ? error.message : String(error)}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
close() {
|
|
147
|
+
if (this.db) {
|
|
148
|
+
this.db.close();
|
|
149
|
+
this.db = null;
|
|
150
|
+
this.logger.log('Tracing database connection closed');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
generateId() {
|
|
154
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
155
|
+
const r = (Math.random() * 16) | 0;
|
|
156
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
157
|
+
return v.toString(16);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
now() {
|
|
161
|
+
return new Date().toISOString();
|
|
162
|
+
}
|
|
163
|
+
createTask(input) {
|
|
164
|
+
if (!this.db) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
const id = this.generateId();
|
|
168
|
+
const now = this.now();
|
|
169
|
+
try {
|
|
170
|
+
const stmt = this.db.prepare(`
|
|
171
|
+
INSERT INTO tasks (id, agent_id, user_id, prompt, mode, status, started_at, metadata)
|
|
172
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
173
|
+
`);
|
|
174
|
+
stmt.run(id, input.agent_id, input.user_id ?? null, input.prompt, input.mode, TaskStatus.RUNNING, now, input.metadata ? JSON.stringify(input.metadata) : null);
|
|
175
|
+
this.logger.debug(`Task created: ${id} for agent ${input.agent_id}`);
|
|
176
|
+
return id;
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
this.logger.error(`Failed to create task: ${error instanceof Error ? error.message : String(error)}`);
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
completeTask(taskId, result) {
|
|
184
|
+
if (!this.db) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
const now = this.now();
|
|
189
|
+
const stmt = this.db.prepare(`
|
|
190
|
+
UPDATE tasks
|
|
191
|
+
SET status = ?, result = ?, completed_at = ?,
|
|
192
|
+
duration_ms = CAST((julianday(?) - julianday(started_at)) * 86400000 AS INTEGER)
|
|
193
|
+
WHERE id = ?
|
|
194
|
+
`);
|
|
195
|
+
const info = stmt.run(TaskStatus.SUCCESS, result ?? null, now, now, taskId);
|
|
196
|
+
return info.changes > 0;
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
this.logger.error(`Failed to complete task ${taskId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
failTask(taskId, error) {
|
|
204
|
+
if (!this.db) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
const now = this.now();
|
|
209
|
+
const stmt = this.db.prepare(`
|
|
210
|
+
UPDATE tasks
|
|
211
|
+
SET status = ?, error = ?, completed_at = ?,
|
|
212
|
+
duration_ms = CAST((julianday(?) - julianday(started_at)) * 86400000 AS INTEGER)
|
|
213
|
+
WHERE id = ?
|
|
214
|
+
`);
|
|
215
|
+
const info = stmt.run(TaskStatus.FAILED, error, now, now, taskId);
|
|
216
|
+
return info.changes > 0;
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
this.logger.error(`Failed to fail task ${taskId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
getTask(taskId) {
|
|
224
|
+
if (!this.db) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
const stmt = this.db.prepare('SELECT * FROM tasks WHERE id = ?');
|
|
229
|
+
const row = stmt.get(taskId);
|
|
230
|
+
if (!row) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
...row,
|
|
235
|
+
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
this.logger.error(`Failed to get task ${taskId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
listTasks(options) {
|
|
244
|
+
if (!this.db) {
|
|
245
|
+
return [];
|
|
246
|
+
}
|
|
247
|
+
const limit = options?.limit ?? 20;
|
|
248
|
+
const offset = options?.offset ?? 0;
|
|
249
|
+
try {
|
|
250
|
+
let query = 'SELECT * FROM tasks';
|
|
251
|
+
const params = [];
|
|
252
|
+
if (options?.agentId) {
|
|
253
|
+
query += ' WHERE agent_id = ?';
|
|
254
|
+
params.push(options.agentId);
|
|
255
|
+
}
|
|
256
|
+
query += ' ORDER BY started_at DESC LIMIT ? OFFSET ?';
|
|
257
|
+
params.push(limit, offset);
|
|
258
|
+
const stmt = this.db.prepare(query);
|
|
259
|
+
const rows = stmt.all(...params);
|
|
260
|
+
return rows.map((row) => ({
|
|
261
|
+
...row,
|
|
262
|
+
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
this.logger.error(`Failed to list tasks: ${error instanceof Error ? error.message : String(error)}`);
|
|
267
|
+
return [];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
createSpan(input) {
|
|
271
|
+
if (!this.db) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
const id = this.generateId();
|
|
275
|
+
const now = this.now();
|
|
276
|
+
try {
|
|
277
|
+
const stmt = this.db.prepare(`
|
|
278
|
+
INSERT INTO spans (id, task_id, parent_span_id, name, kind, status, started_at, input, attributes)
|
|
279
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
280
|
+
`);
|
|
281
|
+
stmt.run(id, input.task_id, input.parent_span_id ?? null, input.name, input.kind ?? SpanKind.INTERNAL, 'ok', now, input.input ?? null, input.attributes ? JSON.stringify(input.attributes) : null);
|
|
282
|
+
this.logger.debug(`Span created: ${id} for task ${input.task_id}`);
|
|
283
|
+
return id;
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
this.logger.error(`Failed to create span: ${error instanceof Error ? error.message : String(error)}`);
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
completeSpan(spanId, output) {
|
|
291
|
+
if (!this.db) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
try {
|
|
295
|
+
const now = this.now();
|
|
296
|
+
const stmt = this.db.prepare(`
|
|
297
|
+
UPDATE spans
|
|
298
|
+
SET status = 'ok', output = ?, completed_at = ?,
|
|
299
|
+
duration_ms = CAST((julianday(?) - julianday(started_at)) * 86400000 AS INTEGER)
|
|
300
|
+
WHERE id = ?
|
|
301
|
+
`);
|
|
302
|
+
const info = stmt.run(output ?? null, now, now, spanId);
|
|
303
|
+
return info.changes > 0;
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
this.logger.error(`Failed to complete span ${spanId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
failSpan(spanId, error) {
|
|
311
|
+
if (!this.db) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
const now = this.now();
|
|
316
|
+
const stmt = this.db.prepare(`
|
|
317
|
+
UPDATE spans
|
|
318
|
+
SET status = 'error', error = ?, completed_at = ?,
|
|
319
|
+
duration_ms = CAST((julianday(?) - julianday(started_at)) * 86400000 AS INTEGER)
|
|
320
|
+
WHERE id = ?
|
|
321
|
+
`);
|
|
322
|
+
const info = stmt.run(error, now, now, spanId);
|
|
323
|
+
return info.changes > 0;
|
|
324
|
+
}
|
|
325
|
+
catch (error) {
|
|
326
|
+
this.logger.error(`Failed to fail span ${spanId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
getSpansForTask(taskId) {
|
|
331
|
+
if (!this.db) {
|
|
332
|
+
return [];
|
|
333
|
+
}
|
|
334
|
+
try {
|
|
335
|
+
const stmt = this.db.prepare('SELECT * FROM spans WHERE task_id = ? ORDER BY started_at ASC');
|
|
336
|
+
const rows = stmt.all(taskId);
|
|
337
|
+
return rows.map((row) => ({
|
|
338
|
+
...row,
|
|
339
|
+
attributes: row.attributes ? JSON.parse(row.attributes) : undefined,
|
|
340
|
+
}));
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
this.logger.error(`Failed to get spans for task ${taskId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
344
|
+
return [];
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
getSpan(spanId) {
|
|
348
|
+
if (!this.db) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
try {
|
|
352
|
+
const stmt = this.db.prepare('SELECT * FROM spans WHERE id = ?');
|
|
353
|
+
const row = stmt.get(spanId);
|
|
354
|
+
if (!row) {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
return {
|
|
358
|
+
...row,
|
|
359
|
+
attributes: row.attributes ? JSON.parse(row.attributes) : undefined,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
this.logger.error(`Failed to get span ${spanId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
cleanupOldTasks(daysToKeep = 30) {
|
|
368
|
+
if (!this.db) {
|
|
369
|
+
return 0;
|
|
370
|
+
}
|
|
371
|
+
try {
|
|
372
|
+
const cutoffDate = new Date();
|
|
373
|
+
cutoffDate.setDate(cutoffDate.getDate() - daysToKeep);
|
|
374
|
+
const cutoff = cutoffDate.toISOString();
|
|
375
|
+
const stmt = this.db.prepare('DELETE FROM tasks WHERE started_at < ?');
|
|
376
|
+
const info = stmt.run(cutoff);
|
|
377
|
+
if (info.changes > 0) {
|
|
378
|
+
this.logger.log(`Cleaned up ${info.changes} old tasks`);
|
|
379
|
+
}
|
|
380
|
+
return info.changes;
|
|
381
|
+
}
|
|
382
|
+
catch (error) {
|
|
383
|
+
this.logger.error(`Failed to cleanup old tasks: ${error instanceof Error ? error.message : String(error)}`);
|
|
384
|
+
return 0;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
getStats() {
|
|
388
|
+
if (!this.db) {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
try {
|
|
392
|
+
const taskCountStmt = this.db.prepare('SELECT COUNT(*) as count FROM tasks');
|
|
393
|
+
const spanCountStmt = this.db.prepare('SELECT COUNT(*) as count FROM spans');
|
|
394
|
+
const taskCount = taskCountStmt.get().count;
|
|
395
|
+
const spanCount = spanCountStmt.get().count;
|
|
396
|
+
let dbSizeBytes = 0;
|
|
397
|
+
if (fs.existsSync(this.dbPath)) {
|
|
398
|
+
const stats = fs.statSync(this.dbPath);
|
|
399
|
+
dbSizeBytes = stats.size;
|
|
400
|
+
}
|
|
401
|
+
return { taskCount, spanCount, dbSizeBytes };
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
this.logger.error(`Failed to get stats: ${error instanceof Error ? error.message : String(error)}`);
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
isEnabled() {
|
|
409
|
+
return this.db !== null;
|
|
410
|
+
}
|
|
411
|
+
getDbPath() {
|
|
412
|
+
return this.dbPath;
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
exports.TracingService = TracingService;
|
|
416
|
+
exports.TracingService = TracingService = TracingService_1 = __decorate([
|
|
417
|
+
(0, common_1.Injectable)(),
|
|
418
|
+
__param(0, (0, common_1.Optional)()),
|
|
419
|
+
__param(0, (0, common_1.Inject)('TRACING_OPTIONS')),
|
|
420
|
+
__metadata("design:paramtypes", [Object])
|
|
421
|
+
], TracingService);
|
|
422
|
+
//# sourceMappingURL=tracing.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracing.service.js","sourceRoot":"","sources":["../../src/services/tracing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAqG;AACrG,uCAAyB;AACzB,2CAA6B;AAC7B,oEAAsC;AAKtC,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,iCAAmB,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C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC/B,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvC,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC;YAC3B,CAAC;YAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,wBAAwB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACjF,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAKD,SAAS;QACP,OAAO,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC;IAC1B,CAAC;IAKD,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF,CAAA;AAxfY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;;GAN7B,cAAc,CAwf1B"}
|
|
@@ -25,4 +25,8 @@ export declare class SlackMessageFormatter extends BaseMessageFormatter {
|
|
|
25
25
|
formatSimpleMessage(message: string, emoji?: string): (Block | KnownBlock)[];
|
|
26
26
|
private validateBlockCount;
|
|
27
27
|
private splitIntoSections;
|
|
28
|
+
private forceSplitLongLine;
|
|
29
|
+
private findBestBreakPoint;
|
|
30
|
+
private ensureMaxLength;
|
|
31
|
+
private truncateAtMrkdwnLevel;
|
|
28
32
|
}
|