orquesta-cli 0.2.119 → 0.2.121
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/constants.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export declare const DOCS_DIR: string;
|
|
|
5
5
|
export declare const BACKUPS_DIR: string;
|
|
6
6
|
export declare const PROJECTS_DIR: string;
|
|
7
7
|
export declare function cwdToProjectSegment(cwd?: string): string;
|
|
8
|
-
export declare const APP_VERSION = "0.2.
|
|
8
|
+
export declare const APP_VERSION = "0.2.121";
|
|
9
9
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -7,6 +7,9 @@ let currentSequence = 0;
|
|
|
7
7
|
export function getCurrentPromptId() {
|
|
8
8
|
return currentPromptId;
|
|
9
9
|
}
|
|
10
|
+
function dispatchedPromptId() {
|
|
11
|
+
return process.env['ORQUESTA_PROMPT_ID'] || null;
|
|
12
|
+
}
|
|
10
13
|
export async function reportPromptStart(content, context) {
|
|
11
14
|
if (process.env['ORQUESTA_PROMPT_ID']) {
|
|
12
15
|
return null;
|
|
@@ -149,14 +152,16 @@ export async function reportTodos(todos, label = 'Plan') {
|
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
154
|
export async function reportToolUse(toolName, args, result) {
|
|
152
|
-
const promptId = currentPromptId;
|
|
155
|
+
const promptId = currentPromptId ?? dispatchedPromptId();
|
|
153
156
|
if (!promptId || !configManager.getReportingToken()) {
|
|
154
157
|
return;
|
|
155
158
|
}
|
|
156
159
|
try {
|
|
157
160
|
const truncate = (s, max) => s.length > max ? `${s.slice(0, max)}…` : s;
|
|
158
|
-
const
|
|
159
|
-
const
|
|
161
|
+
const adopted = !currentPromptId;
|
|
162
|
+
const now = Date.now();
|
|
163
|
+
const callSeq = adopted ? now : (currentSequence += 1);
|
|
164
|
+
const resultSeq = adopted ? now + 1 : (currentSequence += 1);
|
|
160
165
|
const logs = [
|
|
161
166
|
{
|
|
162
167
|
type: 'tool_call',
|
|
@@ -4,6 +4,33 @@ import { dirname, join } from 'path';
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { PROJECTS_DIR, cwdToProjectSegment } from '../constants.js';
|
|
6
6
|
const FLUSH_INTERVAL_MS = 1000;
|
|
7
|
+
function safeStringify(value, space) {
|
|
8
|
+
const seen = new WeakSet();
|
|
9
|
+
return JSON.stringify(value, function (_key, val) {
|
|
10
|
+
if (val instanceof Error) {
|
|
11
|
+
return { name: val.name, message: val.message, stack: val.stack };
|
|
12
|
+
}
|
|
13
|
+
if (typeof val === 'bigint') {
|
|
14
|
+
return val.toString();
|
|
15
|
+
}
|
|
16
|
+
if (typeof val === 'function') {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
if (typeof val === 'object' && val !== null) {
|
|
20
|
+
const ctor = val.constructor?.name;
|
|
21
|
+
if (ctor === 'TLSSocket' || ctor === 'Socket' || ctor === 'ClientRequest' ||
|
|
22
|
+
ctor === 'IncomingMessage' || ctor === 'HTTPParser' || ctor === 'Agent' ||
|
|
23
|
+
ctor === 'Server' || ctor === 'ReadStream' || ctor === 'WriteStream') {
|
|
24
|
+
return `[${ctor}]`;
|
|
25
|
+
}
|
|
26
|
+
if (seen.has(val)) {
|
|
27
|
+
return '[Circular]';
|
|
28
|
+
}
|
|
29
|
+
seen.add(val);
|
|
30
|
+
}
|
|
31
|
+
return val;
|
|
32
|
+
}, space);
|
|
33
|
+
}
|
|
7
34
|
function getLogCategory(type) {
|
|
8
35
|
switch (type) {
|
|
9
36
|
case 'user_input':
|
|
@@ -241,20 +268,21 @@ export class JsonStreamLogger {
|
|
|
241
268
|
if (!this.writeStream || this.buffer.length === 0) {
|
|
242
269
|
return;
|
|
243
270
|
}
|
|
244
|
-
|
|
245
|
-
|
|
271
|
+
const entries = this.buffer;
|
|
272
|
+
this.buffer = [];
|
|
273
|
+
for (const entry of entries) {
|
|
274
|
+
try {
|
|
246
275
|
if (!this.isFirstEntry) {
|
|
247
276
|
this.writeStream.write(',\n');
|
|
248
277
|
}
|
|
249
278
|
this.isFirstEntry = false;
|
|
250
|
-
const json =
|
|
279
|
+
const json = safeStringify(entry, 2);
|
|
251
280
|
const indentedJson = json.split('\n').map(line => ' ' + line).join('\n');
|
|
252
281
|
this.writeStream.write(indentedJson);
|
|
253
282
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
console.error(chalk.red('Failed to write to JSON stream:'), error);
|
|
283
|
+
catch (error) {
|
|
284
|
+
console.error(chalk.red('Failed to write to JSON stream:'), error);
|
|
285
|
+
}
|
|
258
286
|
}
|
|
259
287
|
}
|
|
260
288
|
async initializeErrorStream() {
|
|
@@ -292,20 +320,21 @@ export class JsonStreamLogger {
|
|
|
292
320
|
if (!this.errorWriteStream || this.errorBuffer.length === 0) {
|
|
293
321
|
return;
|
|
294
322
|
}
|
|
295
|
-
|
|
296
|
-
|
|
323
|
+
const entries = this.errorBuffer;
|
|
324
|
+
this.errorBuffer = [];
|
|
325
|
+
for (const entry of entries) {
|
|
326
|
+
try {
|
|
297
327
|
if (!this.isFirstErrorEntry) {
|
|
298
328
|
this.errorWriteStream.write(',\n');
|
|
299
329
|
}
|
|
300
330
|
this.isFirstErrorEntry = false;
|
|
301
|
-
const json =
|
|
331
|
+
const json = safeStringify(entry, 2);
|
|
302
332
|
const indentedJson = json.split('\n').map(line => ' ' + line).join('\n');
|
|
303
333
|
this.errorWriteStream.write(indentedJson);
|
|
304
334
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
console.error(chalk.red('Failed to write to error JSON stream:'), error);
|
|
335
|
+
catch (error) {
|
|
336
|
+
console.error(chalk.red('Failed to write to error JSON stream:'), error);
|
|
337
|
+
}
|
|
309
338
|
}
|
|
310
339
|
}
|
|
311
340
|
flushCategories() {
|
|
@@ -313,20 +342,21 @@ export class JsonStreamLogger {
|
|
|
313
342
|
if (!streamInfo.stream || !streamInfo.stream.writable || streamInfo.buffer.length === 0) {
|
|
314
343
|
continue;
|
|
315
344
|
}
|
|
316
|
-
|
|
317
|
-
|
|
345
|
+
const entries = streamInfo.buffer;
|
|
346
|
+
streamInfo.buffer = [];
|
|
347
|
+
for (const entry of entries) {
|
|
348
|
+
try {
|
|
318
349
|
if (!streamInfo.isFirstEntry) {
|
|
319
350
|
streamInfo.stream.write(',\n');
|
|
320
351
|
}
|
|
321
352
|
streamInfo.isFirstEntry = false;
|
|
322
|
-
const json =
|
|
353
|
+
const json = safeStringify(entry, 2);
|
|
323
354
|
const indentedJson = json.split('\n').map(line => ' ' + line).join('\n');
|
|
324
355
|
streamInfo.stream.write(indentedJson);
|
|
325
356
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
console.error(chalk.red(`Failed to write to category stream:`), error);
|
|
357
|
+
catch (error) {
|
|
358
|
+
console.error(chalk.red(`Failed to write to category stream:`), error);
|
|
359
|
+
}
|
|
330
360
|
}
|
|
331
361
|
}
|
|
332
362
|
}
|
|
@@ -371,8 +401,8 @@ export class JsonStreamLogger {
|
|
|
371
401
|
}
|
|
372
402
|
else if (typeof error === 'object' && error !== null) {
|
|
373
403
|
try {
|
|
374
|
-
errorMessage =
|
|
375
|
-
errorDetails =
|
|
404
|
+
errorMessage = safeStringify(error, 2);
|
|
405
|
+
errorDetails = JSON.parse(errorMessage);
|
|
376
406
|
}
|
|
377
407
|
catch {
|
|
378
408
|
errorMessage = String(error);
|
|
@@ -88,7 +88,16 @@ export async function runCliUpdate(version, onProgress) {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
|
-
|
|
91
|
+
const errLines = err
|
|
92
|
+
.split('\n')
|
|
93
|
+
.map(l => l.replace(/\r$/, ''))
|
|
94
|
+
.filter(l => /npm (error|ERR!)/i.test(l) && !/A complete log of this run/i.test(l))
|
|
95
|
+
.map(l => l.replace(/^npm (error|ERR!)\s?/i, '').trim())
|
|
96
|
+
.filter(Boolean);
|
|
97
|
+
const reason = errLines.length
|
|
98
|
+
? errLines.slice(0, 6).join('\n')
|
|
99
|
+
: (err.replace(/npm notice.*$/gim, '').trim().slice(-300).trim() || `npm exited with code ${code}`);
|
|
100
|
+
resolve({ success: false, error: reason });
|
|
92
101
|
}
|
|
93
102
|
});
|
|
94
103
|
child.on('error', (e) => resolve({ success: false, error: e.message }));
|