@aid-framework/cli 0.1.63 → 0.1.64
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/.tsbuildinfo +1 -1
- package/dist/commands/cost.d.ts +1 -1
- package/dist/commands/cost.d.ts.map +1 -1
- package/dist/commands/cost.js +15 -83
- package/dist/commands/cost.js.map +1 -1
- package/dist/commands/trace.d.ts +31 -0
- package/dist/commands/trace.d.ts.map +1 -0
- package/dist/commands/trace.js +240 -0
- package/dist/commands/trace.js.map +1 -0
- package/dist/diagnostics.d.ts +4 -0
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +6 -0
- package/dist/diagnostics.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +16 -0
- package/dist/main.js.map +1 -1
- package/dist/output.d.ts +12 -0
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +29 -0
- package/dist/output.js.map +1 -1
- package/dist/trace-dir.d.ts +75 -0
- package/dist/trace-dir.d.ts.map +1 -0
- package/dist/trace-dir.js +139 -0
- package/dist/trace-dir.js.map +1 -0
- package/dist/trace.d.ts +71 -0
- package/dist/trace.d.ts.map +1 -1
- package/dist/trace.js +157 -0
- package/dist/trace.js.map +1 -1
- package/package.json +6 -6
package/dist/main.js
CHANGED
|
@@ -23,6 +23,7 @@ import { infra } from './commands/infra.js';
|
|
|
23
23
|
import { ingest } from './commands/ingest.js';
|
|
24
24
|
import { init } from './commands/init.js';
|
|
25
25
|
import { migrate } from './commands/migrate.js';
|
|
26
|
+
import { trace } from './commands/trace.js';
|
|
26
27
|
import { validate } from './commands/validate.js';
|
|
27
28
|
import { EXIT_OK, EXIT_USAGE } from './exit.js';
|
|
28
29
|
import { emit } from './output.js';
|
|
@@ -174,6 +175,21 @@ export const COMMANDS = [
|
|
|
174
175
|
since: args.values.get('since'),
|
|
175
176
|
}),
|
|
176
177
|
},
|
|
178
|
+
{
|
|
179
|
+
name: 'trace',
|
|
180
|
+
summary: 'inspect a traced run: the span tree, timings, models, tokens and cost',
|
|
181
|
+
usage: 'trace [run] [--dir <dir>] [--all]',
|
|
182
|
+
flags: [
|
|
183
|
+
valueFlag('dir', 'dir', 'the trace directory to read (default: $AID_TRACE_DIR)'),
|
|
184
|
+
booleanFlag('all', 'print every run in the directory, not just the run list'),
|
|
185
|
+
JSON_FLAG,
|
|
186
|
+
],
|
|
187
|
+
run: (context, args) => trace(context, {
|
|
188
|
+
run: args.positionals[0],
|
|
189
|
+
dir: args.values.get('dir'),
|
|
190
|
+
all: args.booleans.has('all'),
|
|
191
|
+
}),
|
|
192
|
+
},
|
|
177
193
|
{
|
|
178
194
|
name: 'doctor',
|
|
179
195
|
summary: 'diagnose the tree against the spec: drift, versions, missing files',
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,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AAI,CAAC,WAAW,CAAC,MAAM,GAAG,cAAc,EAAE,CAAC;QACpD,wFAAwF;QACxF,qFAAqF;QACrF,MAAM,KAAK,GAAG,cAAc,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,cAAc,YAAY,CAAC;QAChF,OAAO,UAAU,CACf,OAAO,EACP,SAAS,OAAO,CAAC,IAAI,oBAAoB,KAAK,SAAS,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EACvF,YAAY,CAAC,OAAO,CAAC,CACtB,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
|
package/dist/output.d.ts
CHANGED
|
@@ -35,6 +35,18 @@ export interface OutcomeInit {
|
|
|
35
35
|
readonly text?: string;
|
|
36
36
|
readonly stderr?: string;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Group digits so a reader can count them: `1234567` becomes `1,234,567`.
|
|
40
|
+
*
|
|
41
|
+
* `toLocaleString` would follow the host's locale, which makes a golden test — and a
|
|
42
|
+
* pasted CI log — depend on where the machine thinks it is. This does not.
|
|
43
|
+
*/
|
|
44
|
+
export declare function group(value: number): string;
|
|
45
|
+
/**
|
|
46
|
+
* Money, rounded for reading. `digits` is the default of two cents for a total, and callers
|
|
47
|
+
* showing a single cheap model call pass more, because `$0.00` for a real charge is a lie.
|
|
48
|
+
*/
|
|
49
|
+
export declare function usd(value: number, digits?: number): string;
|
|
38
50
|
export declare function outcome(init: OutcomeInit): CommandOutcome;
|
|
39
51
|
/**
|
|
40
52
|
* Print an outcome and hand back its exit code.
|
package/dist/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG1C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,CAAC;IAC/C,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,cAAc,CAczD;AAED;;;;;;;GAOG;AACH,wBAAgB,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,MAAM,CAOrD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,cAAc,CAczD;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,QAAQ,CAa1F"}
|
package/dist/output.js
CHANGED
|
@@ -9,6 +9,35 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { formatDiagnostics } from '@aid-framework/spec';
|
|
11
11
|
import { EXIT_OK } from './exit.js';
|
|
12
|
+
/**
|
|
13
|
+
* Group digits so a reader can count them: `1234567` becomes `1,234,567`.
|
|
14
|
+
*
|
|
15
|
+
* `toLocaleString` would follow the host's locale, which makes a golden test — and a
|
|
16
|
+
* pasted CI log — depend on where the machine thinks it is. This does not.
|
|
17
|
+
*/
|
|
18
|
+
export function group(value) {
|
|
19
|
+
const digits = String(Math.trunc(Math.abs(value)));
|
|
20
|
+
const sign = value < 0 ? '-' : '';
|
|
21
|
+
let out = '';
|
|
22
|
+
for (let index = 0; index < digits.length; index += 1) {
|
|
23
|
+
if (index > 0 && (digits.length - index) % 3 === 0)
|
|
24
|
+
out += ',';
|
|
25
|
+
out += digits[index];
|
|
26
|
+
}
|
|
27
|
+
return sign + out;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Money, rounded for reading. `digits` is the default of two cents for a total, and callers
|
|
31
|
+
* showing a single cheap model call pass more, because `$0.00` for a real charge is a lie.
|
|
32
|
+
*/
|
|
33
|
+
export function usd(value, digits = 2) {
|
|
34
|
+
const scale = 10 ** digits;
|
|
35
|
+
const rounded = Math.round(Math.abs(value) * scale) / scale;
|
|
36
|
+
const [whole = '0', fraction = ''] = rounded.toFixed(digits).split('.');
|
|
37
|
+
const negative = value < 0 && rounded !== 0;
|
|
38
|
+
const tail = digits === 0 ? '' : `.${fraction}`;
|
|
39
|
+
return `${negative ? '-' : ''}$${group(Number(whole))}${tail}`;
|
|
40
|
+
}
|
|
12
41
|
export function outcome(init) {
|
|
13
42
|
const diagnostics = init.diagnostics ?? [];
|
|
14
43
|
return {
|
package/dist/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6BpC,MAAM,UAAU,OAAO,CAAC,IAAiB;IACvC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;IAC3C,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,WAAW;QACX,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;QACrB,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7D,MAAM,EAAE;YACN,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,EAAE,EAAE,IAAI,CAAC,QAAQ,KAAK,OAAO;YAC7B,GAAG,IAAI,CAAC,MAAM;YACd,WAAW;SACZ;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,OAAmB,EAAE,IAAa,EAAE,OAAuB;IAC9E,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;SAAM,IAAI,OAAO,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;QAC/B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,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|
2
|
+
* Finding the directory `aid cost` and `aid trace` both read.
|
|
3
|
+
*
|
|
4
|
+
* The two commands answer different questions about the same files, so they must agree
|
|
5
|
+
* on which files those are. Discovery lives here rather than in either command: if one
|
|
6
|
+
* of them grew its own default, `cost` could report a directory `trace` refused, and
|
|
7
|
+
* nothing would explain the difference.
|
|
8
|
+
*
|
|
9
|
+
* Both outcomes are wrong invocations, so both exit `2`: no directory was named and
|
|
10
|
+
* `AID_TRACE_DIR` is unset, or the named path is not a directory. Neither says anything
|
|
11
|
+
* about the project, which is why neither is `1`.
|
|
12
|
+
*/
|
|
13
|
+
import type { CliContext } from './context.js';
|
|
14
|
+
import type { CommandOutcome } from './output.js';
|
|
15
|
+
import type { TraceSpan } from './trace.js';
|
|
16
|
+
/** The variable the runtimes read. Named here, not imported, because it is a runtime knob. */
|
|
17
|
+
export declare const TRACE_DIR_ENV = "AID_TRACE_DIR";
|
|
18
|
+
/** Everything one trace directory yielded, with failures counted rather than thrown. */
|
|
19
|
+
export interface TraceDir {
|
|
20
|
+
/** The `.jsonl` entries, sorted, so two reads of one directory agree on order. */
|
|
21
|
+
readonly files: readonly string[];
|
|
22
|
+
readonly spans: readonly TraceSpan[];
|
|
23
|
+
/** Lines that were not a span. */
|
|
24
|
+
readonly skipped: number;
|
|
25
|
+
/** Files that existed but could not be read. */
|
|
26
|
+
readonly unreadable: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Read every `.jsonl` file directly inside `absolute`.
|
|
30
|
+
*
|
|
31
|
+
* A file that cannot be read is **counted and skipped**, for the same reason a bad line
|
|
32
|
+
* is: one unreadable file must not hide the spans in the others, and the caller decides
|
|
33
|
+
* whether the count fails the run. Subdirectories are ignored -- the sink writes flat
|
|
34
|
+
* files, and walking a tree would silently mix in traces the caller did not point at.
|
|
35
|
+
*
|
|
36
|
+
* The exception is the directory itself: `readdirSync` throws when it is missing or is
|
|
37
|
+
* not a directory, and the caller has to have checked that before it can say anything
|
|
38
|
+
* useful about it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function readTraceDir(absolute: string): TraceDir;
|
|
41
|
+
/** A directory relative to the cwd when it is below it, else the absolute path. */
|
|
42
|
+
export declare function displayPath(cwd: string, absolute: string): string;
|
|
43
|
+
export type TraceDirResolution = {
|
|
44
|
+
readonly kind: 'ok';
|
|
45
|
+
readonly absolute: string;
|
|
46
|
+
readonly shown: string;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'refused';
|
|
49
|
+
readonly outcome: CommandOutcome;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Where the directory is, before asking whether it exists.
|
|
53
|
+
*
|
|
54
|
+
* Split from the existence check so `cost` can validate `--since` in the order it always
|
|
55
|
+
* has: a missing directory is reported first, then a bad date, then a path that is not a
|
|
56
|
+
* directory. A command that showed those in a different order would be telling the caller
|
|
57
|
+
* to fix the second thing while the first is still wrong.
|
|
58
|
+
*
|
|
59
|
+
* An all-whitespace variable is treated as unset: a shell that exported an empty value
|
|
60
|
+
* meant "nothing", and resolving it to the cwd would read whatever happened to be there.
|
|
61
|
+
*/
|
|
62
|
+
export declare function locateTraceDir(context: CliContext, argument: string | undefined, command: string, usage?: string): TraceDirResolution;
|
|
63
|
+
/**
|
|
64
|
+
* Confirm a located directory is one, refusing with `2` when it is not.
|
|
65
|
+
*
|
|
66
|
+
* A path that exists but is a file is refused the same way as one that does not: neither
|
|
67
|
+
* is a directory this command can read, and the fix is the same.
|
|
68
|
+
*/
|
|
69
|
+
export declare function confirmTraceDir(located: {
|
|
70
|
+
readonly absolute: string;
|
|
71
|
+
readonly shown: string;
|
|
72
|
+
}, command: string): TraceDirResolution;
|
|
73
|
+
/** Locate and confirm in one call, for a command that has nothing to check in between. */
|
|
74
|
+
export declare function resolveTraceDir(context: CliContext, argument: string | undefined, command: string, usage?: string): TraceDirResolution;
|
|
75
|
+
//# sourceMappingURL=trace-dir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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AED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC9D,OAAO,EAAE,MAAM,GACd,kBAAkB,CA6BpB;AAED,0FAA0F;AAC1F,wBAAgB,eAAe,CAC7B,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,EAAE,MAAM,EACf,KAAK,SAAU,GACd,kBAAkB,CAIpB"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding the directory `aid cost` and `aid trace` both read.
|
|
3
|
+
*
|
|
4
|
+
* The two commands answer different questions about the same files, so they must agree
|
|
5
|
+
* on which files those are. Discovery lives here rather than in either command: if one
|
|
6
|
+
* of them grew its own default, `cost` could report a directory `trace` refused, and
|
|
7
|
+
* nothing would explain the difference.
|
|
8
|
+
*
|
|
9
|
+
* Both outcomes are wrong invocations, so both exit `2`: no directory was named and
|
|
10
|
+
* `AID_TRACE_DIR` is unset, or the named path is not a directory. Neither says anything
|
|
11
|
+
* about the project, which is why neither is `1`.
|
|
12
|
+
*/
|
|
13
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
14
|
+
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
15
|
+
import { CLI_DIAGNOSTIC_CODES, cliError } from './diagnostics.js';
|
|
16
|
+
import { EXIT_USAGE } from './exit.js';
|
|
17
|
+
import { outcome } from './output.js';
|
|
18
|
+
import { parseTraceLines } from './trace.js';
|
|
19
|
+
/** The variable the runtimes read. Named here, not imported, because it is a runtime knob. */
|
|
20
|
+
export const TRACE_DIR_ENV = 'AID_TRACE_DIR';
|
|
21
|
+
/**
|
|
22
|
+
* Read every `.jsonl` file directly inside `absolute`.
|
|
23
|
+
*
|
|
24
|
+
* A file that cannot be read is **counted and skipped**, for the same reason a bad line
|
|
25
|
+
* is: one unreadable file must not hide the spans in the others, and the caller decides
|
|
26
|
+
* whether the count fails the run. Subdirectories are ignored -- the sink writes flat
|
|
27
|
+
* files, and walking a tree would silently mix in traces the caller did not point at.
|
|
28
|
+
*
|
|
29
|
+
* The exception is the directory itself: `readdirSync` throws when it is missing or is
|
|
30
|
+
* not a directory, and the caller has to have checked that before it can say anything
|
|
31
|
+
* useful about it.
|
|
32
|
+
*/
|
|
33
|
+
export function readTraceDir(absolute) {
|
|
34
|
+
const files = readdirSync(absolute, { withFileTypes: true })
|
|
35
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith('.jsonl'))
|
|
36
|
+
.map((entry) => entry.name)
|
|
37
|
+
.sort();
|
|
38
|
+
const spans = [];
|
|
39
|
+
let skipped = 0;
|
|
40
|
+
let unreadable = 0;
|
|
41
|
+
for (const name of files) {
|
|
42
|
+
let text;
|
|
43
|
+
try {
|
|
44
|
+
text = readFileSync(join(absolute, name), 'utf8');
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
unreadable += 1;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const parsed = parseTraceLines(text);
|
|
51
|
+
spans.push(...parsed.spans);
|
|
52
|
+
skipped += parsed.skipped;
|
|
53
|
+
}
|
|
54
|
+
return { files, spans, skipped, unreadable };
|
|
55
|
+
}
|
|
56
|
+
/** A directory relative to the cwd when it is below it, else the absolute path. */
|
|
57
|
+
export function displayPath(cwd, absolute) {
|
|
58
|
+
const path = relative(cwd, absolute);
|
|
59
|
+
if (path === '')
|
|
60
|
+
return '.';
|
|
61
|
+
if (path.startsWith('..') || isAbsolute(path))
|
|
62
|
+
return absolute;
|
|
63
|
+
return path.split(sep).join('/');
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Where the directory is, before asking whether it exists.
|
|
67
|
+
*
|
|
68
|
+
* Split from the existence check so `cost` can validate `--since` in the order it always
|
|
69
|
+
* has: a missing directory is reported first, then a bad date, then a path that is not a
|
|
70
|
+
* directory. A command that showed those in a different order would be telling the caller
|
|
71
|
+
* to fix the second thing while the first is still wrong.
|
|
72
|
+
*
|
|
73
|
+
* An all-whitespace variable is treated as unset: a shell that exported an empty value
|
|
74
|
+
* meant "nothing", and resolving it to the cwd would read whatever happened to be there.
|
|
75
|
+
*/
|
|
76
|
+
export function locateTraceDir(context, argument, command, usage = '<dir>') {
|
|
77
|
+
const configured = argument ?? context.env[TRACE_DIR_ENV]?.trim();
|
|
78
|
+
if (configured === undefined || configured.trim() === '') {
|
|
79
|
+
return {
|
|
80
|
+
kind: 'refused',
|
|
81
|
+
outcome: outcome({
|
|
82
|
+
command,
|
|
83
|
+
exitCode: EXIT_USAGE,
|
|
84
|
+
diagnostics: [
|
|
85
|
+
cliError({
|
|
86
|
+
code: CLI_DIAGNOSTIC_CODES.traceDirMissing,
|
|
87
|
+
message: `no trace directory: \`aid ${command}\` needs one to read.`,
|
|
88
|
+
hint: `Pass it as \`aid ${command} ${usage}\`, or set ${TRACE_DIR_ENV} to the directory the runtime writes to.`,
|
|
89
|
+
}),
|
|
90
|
+
],
|
|
91
|
+
text: `aid: no trace directory. Pass one, or set ${TRACE_DIR_ENV}.\n`,
|
|
92
|
+
}),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const absolute = resolve(context.cwd, configured);
|
|
96
|
+
return { kind: 'ok', absolute, shown: displayPath(context.cwd, absolute) };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Confirm a located directory is one, refusing with `2` when it is not.
|
|
100
|
+
*
|
|
101
|
+
* A path that exists but is a file is refused the same way as one that does not: neither
|
|
102
|
+
* is a directory this command can read, and the fix is the same.
|
|
103
|
+
*/
|
|
104
|
+
export function confirmTraceDir(located, command) {
|
|
105
|
+
const { absolute, shown } = located;
|
|
106
|
+
let isDirectory = false;
|
|
107
|
+
try {
|
|
108
|
+
isDirectory = statSync(absolute).isDirectory();
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
isDirectory = false;
|
|
112
|
+
}
|
|
113
|
+
if (!isDirectory) {
|
|
114
|
+
return {
|
|
115
|
+
kind: 'refused',
|
|
116
|
+
outcome: outcome({
|
|
117
|
+
command,
|
|
118
|
+
exitCode: EXIT_USAGE,
|
|
119
|
+
diagnostics: [
|
|
120
|
+
cliError({
|
|
121
|
+
code: CLI_DIAGNOSTIC_CODES.traceDirNotFound,
|
|
122
|
+
message: `"${shown}" is not a directory.`,
|
|
123
|
+
hint: `Point \`aid ${command}\` at the directory ${TRACE_DIR_ENV} names, or unset it to be told which is missing.`,
|
|
124
|
+
}),
|
|
125
|
+
],
|
|
126
|
+
text: `aid: "${shown}" is not a directory.\n`,
|
|
127
|
+
}),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return { kind: 'ok', absolute, shown };
|
|
131
|
+
}
|
|
132
|
+
/** Locate and confirm in one call, for a command that has nothing to check in between. */
|
|
133
|
+
export function resolveTraceDir(context, argument, command, usage = '<dir>') {
|
|
134
|
+
const located = locateTraceDir(context, argument, command, usage);
|
|
135
|
+
if (located.kind === 'refused')
|
|
136
|
+
return located;
|
|
137
|
+
return confirmTraceDir(located, command);
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=trace-dir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-dir.js","sourceRoot":"","sources":["../src/trace-dir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGrE,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,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D,EAC9D,OAAe;IAEf,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEpC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,CAAC;QACH,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,WAAW,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO;YACL,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,OAAO,CAAC;gBACf,OAAO;gBACP,QAAQ,EAAE,UAAU;gBACpB,WAAW,EAAE;oBACX,QAAQ,CAAC;wBACP,IAAI,EAAE,oBAAoB,CAAC,gBAAgB;wBAC3C,OAAO,EAAE,IAAI,KAAK,uBAAuB;wBACzC,IAAI,EAAE,eAAe,OAAO,uBAAuB,aAAa,kDAAkD;qBACnH,CAAC;iBACH;gBACD,IAAI,EAAE,SAAS,KAAK,yBAAyB;aAC9C,CAAC;SACH,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACzC,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,eAAe,CAC7B,OAAmB,EACnB,QAA4B,EAC5B,OAAe,EACf,KAAK,GAAG,OAAO;IAEf,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAClE,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IAC/C,OAAO,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/trace.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface TraceSpan {
|
|
|
28
28
|
readonly attributes?: Readonly<Record<string, unknown>>;
|
|
29
29
|
readonly status?: {
|
|
30
30
|
readonly code?: string;
|
|
31
|
+
readonly message?: string | null;
|
|
31
32
|
} | null;
|
|
32
33
|
}
|
|
33
34
|
export interface ParsedTrace {
|
|
@@ -86,4 +87,74 @@ export interface CostSummary {
|
|
|
86
87
|
export declare function summariseSpans(spans: readonly TraceSpan[], options?: {
|
|
87
88
|
readonly since?: string;
|
|
88
89
|
}): CostSummary;
|
|
90
|
+
/** One trace: the spans that share a `trace_id`, and what a reader asks about it. */
|
|
91
|
+
export interface TraceRun {
|
|
92
|
+
readonly traceId: string;
|
|
93
|
+
readonly spans: readonly TraceSpan[];
|
|
94
|
+
/**
|
|
95
|
+
* The span the others hang from, when the trace has exactly one. A trace assembled
|
|
96
|
+
* from several exports can have none, or several; a reader that guessed would draw a
|
|
97
|
+
* hierarchy the data does not claim.
|
|
98
|
+
*/
|
|
99
|
+
readonly root?: TraceSpan;
|
|
100
|
+
/** The earliest `started_at` in the run, in the sink's own format. */
|
|
101
|
+
readonly startedAt: string;
|
|
102
|
+
/** Wall time from the earliest start to the latest end. */
|
|
103
|
+
readonly durationMs: number;
|
|
104
|
+
readonly errors: number;
|
|
105
|
+
readonly costUsd: number;
|
|
106
|
+
readonly unpricedSpans: number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Group spans into runs, newest first.
|
|
110
|
+
*
|
|
111
|
+
* A run is **one `trace_id`**, because that is the only identifier the sink writes that
|
|
112
|
+
* covers a whole request: `span_id` is one step, and there is no separate run record. The
|
|
113
|
+
* cost, error and unpriced counts come from {@link summariseSpans} rather than a second
|
|
114
|
+
* summation here, so one span set can never price two ways.
|
|
115
|
+
*
|
|
116
|
+
* A span whose parent is absent is treated as top-level. That happens legitimately -- a
|
|
117
|
+
* trace can be exported in pieces, or a parent can fail before it records -- and the
|
|
118
|
+
* alternative, dropping it, would hide a span that did run.
|
|
119
|
+
*/
|
|
120
|
+
export declare function runsOf(spans: readonly TraceSpan[]): readonly TraceRun[];
|
|
121
|
+
/** Children of each span in one run, keyed by parent id, in start order. */
|
|
122
|
+
export declare function childrenOf(spans: readonly TraceSpan[]): ReadonlyMap<string, readonly TraceSpan[]>;
|
|
123
|
+
/**
|
|
124
|
+
* One span as a tree row: where it sits, when it began relative to the run, and what the
|
|
125
|
+
* record says about it.
|
|
126
|
+
*/
|
|
127
|
+
export interface SpanRow {
|
|
128
|
+
readonly span: TraceSpan;
|
|
129
|
+
/** Nesting level; a span whose parent is missing sits at the top, not in limbo. */
|
|
130
|
+
readonly depth: number;
|
|
131
|
+
/** Milliseconds after the run's earliest start; absent when the timestamp is unusable. */
|
|
132
|
+
readonly offsetMs?: number;
|
|
133
|
+
readonly facts: SpanFacts;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Flatten a run into print order: depth first, every child after its parent.
|
|
137
|
+
*
|
|
138
|
+
* Roots are spans with no parent *in this run*. Anything unreachable from a root -- only
|
|
139
|
+
* possible when parent links form a cycle, which a writer bug could produce -- is appended
|
|
140
|
+
* at depth zero rather than dropped, because a span that recorded is a span that ran.
|
|
141
|
+
*/
|
|
142
|
+
export declare function treeRowsOf(run: TraceRun): readonly SpanRow[];
|
|
143
|
+
/**
|
|
144
|
+
* What one span line can say without guessing.
|
|
145
|
+
*
|
|
146
|
+
* The attribute keys stay in this module so a reader never has to know them: `trace`
|
|
147
|
+
* prints usage and cost from the same fields `cost` sums, which is what makes the two
|
|
148
|
+
* commands agree about a run.
|
|
149
|
+
*/
|
|
150
|
+
export interface SpanFacts {
|
|
151
|
+
readonly durationMs?: number;
|
|
152
|
+
readonly costUsd?: number;
|
|
153
|
+
readonly inputTokens?: number;
|
|
154
|
+
readonly outputTokens?: number;
|
|
155
|
+
/** The pinned alias, else the model the provider served. Absent when neither is recorded. */
|
|
156
|
+
readonly model?: string;
|
|
157
|
+
readonly error: boolean;
|
|
158
|
+
}
|
|
159
|
+
export declare function factsOf(span: TraceSpan): SpanFacts;
|
|
89
160
|
//# sourceMappingURL=trace.d.ts.map
|
package/dist/trace.d.ts.map
CHANGED
|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AS,CAAC;IACzB,mFAAmF;IACnF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0FAA0F;IAC1F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,OAAO,EAAE,CAgC5D;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAkBlD"}
|
package/dist/trace.js
CHANGED
|
@@ -209,4 +209,161 @@ export function summariseSpans(spans, options = {}) {
|
|
|
209
209
|
};
|
|
210
210
|
return summary;
|
|
211
211
|
}
|
|
212
|
+
/** A span's start as epoch milliseconds, or `undefined` when the timestamp is unreadable. */
|
|
213
|
+
function instantOf(value) {
|
|
214
|
+
const parsed = Date.parse(value);
|
|
215
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
216
|
+
}
|
|
217
|
+
/** Start order, with the span id as a tiebreak so equal timestamps still print one way. */
|
|
218
|
+
function byStart(left, right) {
|
|
219
|
+
const leftAt = instantOf(left.started_at);
|
|
220
|
+
const rightAt = instantOf(right.started_at);
|
|
221
|
+
if (leftAt !== undefined && rightAt !== undefined && leftAt !== rightAt)
|
|
222
|
+
return leftAt - rightAt;
|
|
223
|
+
if (leftAt === undefined && rightAt !== undefined)
|
|
224
|
+
return 1;
|
|
225
|
+
if (leftAt !== undefined && rightAt === undefined)
|
|
226
|
+
return -1;
|
|
227
|
+
return left.span_id < right.span_id ? -1 : left.span_id > right.span_id ? 1 : 0;
|
|
228
|
+
}
|
|
229
|
+
/** Wall time the run covered: earliest start to latest end, not the sum of the spans. */
|
|
230
|
+
function runDurationOf(spans) {
|
|
231
|
+
let earliest = Number.POSITIVE_INFINITY;
|
|
232
|
+
let latest = Number.NEGATIVE_INFINITY;
|
|
233
|
+
let longest = 0;
|
|
234
|
+
for (const span of spans) {
|
|
235
|
+
const duration = typeof span.duration_ms === 'number' &&
|
|
236
|
+
Number.isFinite(span.duration_ms) &&
|
|
237
|
+
span.duration_ms > 0
|
|
238
|
+
? span.duration_ms
|
|
239
|
+
: 0;
|
|
240
|
+
if (duration > longest)
|
|
241
|
+
longest = duration;
|
|
242
|
+
const begun = instantOf(span.started_at);
|
|
243
|
+
if (begun === undefined)
|
|
244
|
+
continue;
|
|
245
|
+
earliest = Math.min(earliest, begun);
|
|
246
|
+
latest = Math.max(latest, begun + duration);
|
|
247
|
+
}
|
|
248
|
+
const measured = earliest === Number.POSITIVE_INFINITY ? longest : latest - earliest;
|
|
249
|
+
return Math.round(measured * 1000) / 1000;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Group spans into runs, newest first.
|
|
253
|
+
*
|
|
254
|
+
* A run is **one `trace_id`**, because that is the only identifier the sink writes that
|
|
255
|
+
* covers a whole request: `span_id` is one step, and there is no separate run record. The
|
|
256
|
+
* cost, error and unpriced counts come from {@link summariseSpans} rather than a second
|
|
257
|
+
* summation here, so one span set can never price two ways.
|
|
258
|
+
*
|
|
259
|
+
* A span whose parent is absent is treated as top-level. That happens legitimately -- a
|
|
260
|
+
* trace can be exported in pieces, or a parent can fail before it records -- and the
|
|
261
|
+
* alternative, dropping it, would hide a span that did run.
|
|
262
|
+
*/
|
|
263
|
+
export function runsOf(spans) {
|
|
264
|
+
const grouped = new Map();
|
|
265
|
+
for (const span of spans) {
|
|
266
|
+
const members = grouped.get(span.trace_id);
|
|
267
|
+
if (members === undefined)
|
|
268
|
+
grouped.set(span.trace_id, [span]);
|
|
269
|
+
else
|
|
270
|
+
members.push(span);
|
|
271
|
+
}
|
|
272
|
+
const runs = [];
|
|
273
|
+
for (const [traceId, members] of grouped) {
|
|
274
|
+
const ordered = [...members].sort(byStart);
|
|
275
|
+
const ids = new Set(members.map((span) => span.span_id));
|
|
276
|
+
const tops = ordered.filter((span) => span.parent_span_id == null || !ids.has(span.parent_span_id));
|
|
277
|
+
const summary = summariseSpans(members);
|
|
278
|
+
const first = ordered[0];
|
|
279
|
+
runs.push({
|
|
280
|
+
traceId,
|
|
281
|
+
spans: ordered,
|
|
282
|
+
...(tops.length === 1 && tops[0] !== undefined ? { root: tops[0] } : {}),
|
|
283
|
+
startedAt: first?.started_at ?? '',
|
|
284
|
+
durationMs: runDurationOf(members),
|
|
285
|
+
errors: summary.errors,
|
|
286
|
+
costUsd: summary.costUsd,
|
|
287
|
+
unpricedSpans: summary.unpricedSpans,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
// Newest first, then by id, so two runs over one directory list in one order whatever
|
|
291
|
+
// order their files happened to be read in.
|
|
292
|
+
return runs.sort((left, right) => {
|
|
293
|
+
const leftAt = instantOf(left.startedAt) ?? Number.NEGATIVE_INFINITY;
|
|
294
|
+
const rightAt = instantOf(right.startedAt) ?? Number.NEGATIVE_INFINITY;
|
|
295
|
+
if (leftAt !== rightAt)
|
|
296
|
+
return rightAt - leftAt;
|
|
297
|
+
return left.traceId < right.traceId ? -1 : left.traceId > right.traceId ? 1 : 0;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
/** Children of each span in one run, keyed by parent id, in start order. */
|
|
301
|
+
export function childrenOf(spans) {
|
|
302
|
+
const ids = new Set(spans.map((span) => span.span_id));
|
|
303
|
+
const children = new Map();
|
|
304
|
+
for (const span of [...spans].sort(byStart)) {
|
|
305
|
+
const parent = span.parent_span_id;
|
|
306
|
+
if (parent == null || !ids.has(parent))
|
|
307
|
+
continue;
|
|
308
|
+
const existing = children.get(parent);
|
|
309
|
+
if (existing === undefined)
|
|
310
|
+
children.set(parent, [span]);
|
|
311
|
+
else
|
|
312
|
+
existing.push(span);
|
|
313
|
+
}
|
|
314
|
+
return children;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Flatten a run into print order: depth first, every child after its parent.
|
|
318
|
+
*
|
|
319
|
+
* Roots are spans with no parent *in this run*. Anything unreachable from a root -- only
|
|
320
|
+
* possible when parent links form a cycle, which a writer bug could produce -- is appended
|
|
321
|
+
* at depth zero rather than dropped, because a span that recorded is a span that ran.
|
|
322
|
+
*/
|
|
323
|
+
export function treeRowsOf(run) {
|
|
324
|
+
const children = childrenOf(run.spans);
|
|
325
|
+
const ids = new Set(run.spans.map((span) => span.span_id));
|
|
326
|
+
const roots = run.spans.filter((span) => span.parent_span_id == null || !ids.has(span.parent_span_id));
|
|
327
|
+
const earliest = Math.min(...run.spans.map((span) => instantOf(span.started_at) ?? Number.POSITIVE_INFINITY));
|
|
328
|
+
const base = Number.isFinite(earliest) ? earliest : undefined;
|
|
329
|
+
const rows = [];
|
|
330
|
+
const seen = new Set();
|
|
331
|
+
const walk = (span, depth) => {
|
|
332
|
+
if (seen.has(span.span_id))
|
|
333
|
+
return;
|
|
334
|
+
seen.add(span.span_id);
|
|
335
|
+
const begun = instantOf(span.started_at);
|
|
336
|
+
rows.push({
|
|
337
|
+
span,
|
|
338
|
+
depth,
|
|
339
|
+
...(base === undefined || begun === undefined ? {} : { offsetMs: begun - base }),
|
|
340
|
+
facts: factsOf(span),
|
|
341
|
+
});
|
|
342
|
+
for (const child of children.get(span.span_id) ?? [])
|
|
343
|
+
walk(child, depth + 1);
|
|
344
|
+
};
|
|
345
|
+
for (const root of roots)
|
|
346
|
+
walk(root, 0);
|
|
347
|
+
for (const span of run.spans)
|
|
348
|
+
walk(span, 0);
|
|
349
|
+
return rows;
|
|
350
|
+
}
|
|
351
|
+
export function factsOf(span) {
|
|
352
|
+
const attributes = span.attributes ?? {};
|
|
353
|
+
const duration = span.duration_ms;
|
|
354
|
+
const input = numeric(attributes[ATTRIBUTES.inputTokens]);
|
|
355
|
+
const output = numeric(attributes[ATTRIBUTES.outputTokens]);
|
|
356
|
+
const cost = numeric(attributes[ATTRIBUTES.costUsd]);
|
|
357
|
+
const model = modelOf(span);
|
|
358
|
+
return {
|
|
359
|
+
...(typeof duration === 'number' && Number.isFinite(duration) && duration >= 0
|
|
360
|
+
? { durationMs: duration }
|
|
361
|
+
: {}),
|
|
362
|
+
...(cost === undefined ? {} : { costUsd: cost }),
|
|
363
|
+
...(input === undefined ? {} : { inputTokens: input }),
|
|
364
|
+
...(output === undefined ? {} : { outputTokens: output }),
|
|
365
|
+
...(model === UNKNOWN_MODEL ? {} : { model }),
|
|
366
|
+
error: span.status?.code === 'ERROR',
|
|
367
|
+
};
|
|
368
|
+
}
|
|
212
369
|
//# sourceMappingURL=trace.js.map
|