@phnx-labs/agents-cli 1.23.13 → 1.23.14
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/CHANGELOG.md +38 -0
- package/README.md +30 -59
- package/dist/cli/command-registry.js +0 -24
- package/dist/commands/accounts.js +3 -3
- package/dist/commands/daemon.js +5 -147
- package/dist/commands/doctor.js +7 -0
- package/dist/commands/events-logs.d.ts +2 -0
- package/dist/commands/{logs.js → events-logs.js} +28 -127
- package/dist/commands/events.js +3 -1
- package/dist/commands/exec.d.ts +0 -1
- package/dist/commands/exec.js +3 -11
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +4 -7
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/menubar.js +12 -226
- package/dist/commands/projects.js +1 -2
- package/dist/commands/{trash.d.ts → prune-trash.d.ts} +1 -1
- package/dist/commands/{trash.js → prune-trash.js} +8 -8
- package/dist/commands/prune.js +3 -1
- package/dist/commands/send.js +2 -5
- package/dist/commands/sessions.js +1 -1
- package/dist/commands/ssh.js +2 -2
- package/dist/commands/utils.d.ts +1 -5
- package/dist/commands/utils.js +1 -7
- package/dist/lib/agent-spec/agents.d.ts +0 -2
- package/dist/lib/agent-spec/agents.js +0 -12
- package/dist/lib/agent-spec/index.d.ts +0 -4
- package/dist/lib/agent-spec/index.js +0 -4
- package/dist/lib/commands.d.ts +1 -5
- package/dist/lib/commands.js +2 -69
- package/dist/lib/comms-render.d.ts +0 -7
- package/dist/lib/comms-render.js +0 -41
- package/dist/lib/config-keys.d.ts +1 -1
- package/dist/lib/config-keys.js +8 -0
- package/dist/lib/daemon/daemon.js +1 -6
- package/dist/lib/daemon-services.d.ts +1 -1
- package/dist/lib/daemon-services.js +0 -5
- package/dist/lib/device-config.d.ts +2 -0
- package/dist/lib/device-config.js +81 -8
- package/dist/lib/devices/doctor-findings.d.ts +6 -1
- package/dist/lib/devices/doctor-findings.js +34 -1
- package/dist/lib/git.d.ts +1 -0
- package/dist/lib/git.js +5 -0
- package/dist/lib/hooks/install.d.ts +0 -7
- package/dist/lib/hooks/install.js +0 -55
- package/dist/lib/hosts/passthrough.js +2 -4
- package/dist/lib/hosts/progress.js +2 -2
- package/dist/lib/hosts/remote-cmd.js +0 -1
- package/dist/lib/installations/migrate.d.ts +1 -0
- package/dist/lib/installations/migrate.js +18 -1
- package/dist/lib/installations/versions.js +2 -2
- package/dist/lib/loop.js +1 -1
- package/dist/lib/mailbox-target.d.ts +0 -31
- package/dist/lib/mailbox-target.js +0 -37
- package/dist/lib/mcp-lookup.d.ts +7 -0
- package/dist/lib/mcp-lookup.js +71 -0
- package/dist/lib/mcp.d.ts +0 -8
- package/dist/lib/mcp.js +0 -47
- package/dist/lib/menubar/install-menubar.d.ts +0 -15
- package/dist/lib/menubar/install-menubar.js +24 -118
- package/dist/lib/menubar/resolve-version.d.ts +9 -10
- package/dist/lib/menubar/resolve-version.js +70 -30
- package/dist/lib/paths.d.ts +0 -1
- package/dist/lib/paths.js +0 -18
- package/dist/lib/plugins/skills.d.ts +0 -10
- package/dist/lib/plugins/skills.js +2 -165
- package/dist/lib/project-pull.js +1 -2
- package/dist/lib/resources.d.ts +1 -1
- package/dist/lib/routines-project.js +1 -1
- package/dist/lib/session/local-tmux-attach.js +2 -2
- package/dist/lib/startup/command-registry.js +20 -7
- package/dist/lib/teams/agents.js +1 -1
- package/dist/lib/triggers/webhook.d.ts +2 -59
- package/dist/lib/triggers/webhook.js +2 -422
- package/package.json +2 -1
- package/dist/commands/funnel.d.ts +0 -2
- package/dist/commands/funnel.js +0 -77
- package/dist/commands/logs.d.ts +0 -2
- package/dist/commands/mailboxes.d.ts +0 -2
- package/dist/commands/mailboxes.js +0 -400
- package/dist/commands/message.d.ts +0 -2
- package/dist/commands/message.js +0 -259
- package/dist/commands/packages-materialize.d.ts +0 -6
- package/dist/commands/packages-materialize.js +0 -90
- package/dist/commands/packages.d.ts +0 -5
- package/dist/commands/packages.js +0 -763
- package/dist/commands/route.d.ts +0 -2
- package/dist/commands/route.js +0 -259
- package/dist/commands/testdata/feed-hub.d.ts +0 -1
- package/dist/commands/testdata/feed-hub.js +0 -11
- package/dist/commands/tmux.d.ts +0 -7
- package/dist/commands/tmux.js +0 -529
- package/dist/commands/traces.d.ts +0 -2
- package/dist/commands/traces.js +0 -204
- package/dist/commands/webhook.d.ts +0 -5
- package/dist/commands/webhook.js +0 -105
- package/dist/lib/agent-spec/materialize.d.ts +0 -3
- package/dist/lib/agent-spec/materialize.js +0 -277
- package/dist/lib/agent-spec/package-resolve.d.ts +0 -4
- package/dist/lib/agent-spec/package-resolve.js +0 -231
- package/dist/lib/agent-spec/package-schema.d.ts +0 -3
- package/dist/lib/agent-spec/package-schema.js +0 -136
- package/dist/lib/agent-spec/package-types.d.ts +0 -94
- package/dist/lib/agent-spec/package-types.js +0 -10
- package/dist/lib/daemon/testdata/process-view-daemon.d.ts +0 -1
- package/dist/lib/daemon/testdata/process-view-daemon.js +0 -12
- package/dist/lib/daemon/testdata/process-view-start.d.ts +0 -1
- package/dist/lib/daemon/testdata/process-view-start.js +0 -41
- package/dist/lib/daemon/webhook-receiver-service.d.ts +0 -8
- package/dist/lib/daemon/webhook-receiver-service.js +0 -16
- package/dist/lib/daemon-webhooks.d.ts +0 -48
- package/dist/lib/daemon-webhooks.js +0 -177
- package/dist/lib/funnel.d.ts +0 -6
- package/dist/lib/funnel.js +0 -31
- package/dist/lib/net-close.d.ts +0 -2
- package/dist/lib/net-close.js +0 -20
- package/dist/lib/packages/output-home.d.ts +0 -9
- package/dist/lib/packages/output-home.js +0 -89
- package/dist/lib/registry.d.ts +0 -65
- package/dist/lib/registry.js +0 -432
- package/dist/lib/routers.d.ts +0 -25
- package/dist/lib/routers.js +0 -122
- package/dist/lib/run-trace-sync.d.ts +0 -7
- package/dist/lib/run-trace-sync.js +0 -35
- package/dist/lib/session/testdata/pid-registry-namespace.d.ts +0 -1
- package/dist/lib/session/testdata/pid-registry-namespace.js +0 -25
- package/dist/lib/session/testdata/process-view-namespace.d.ts +0 -1
- package/dist/lib/session/testdata/process-view-namespace.js +0 -56
- package/dist/lib/session/testdata/process-view-private.d.ts +0 -1
- package/dist/lib/session/testdata/process-view-private.js +0 -11
- package/dist/lib/testdata/daemon-health-writer.d.ts +0 -1
- package/dist/lib/testdata/daemon-health-writer.js +0 -8
- package/dist/lib/testdata/owner-notify-api.d.ts +0 -23
- package/dist/lib/testdata/owner-notify-api.js +0 -82
- package/dist/lib/testdata/refresh-coordinator-worker.d.ts +0 -1
- package/dist/lib/testdata/refresh-coordinator-worker.js +0 -23
- package/dist/lib/traces/backend.d.ts +0 -8
- package/dist/lib/traces/backend.js +0 -33
- package/dist/lib/traces/classify.d.ts +0 -40
- package/dist/lib/traces/classify.js +0 -70
- package/dist/lib/traces/config.d.ts +0 -2
- package/dist/lib/traces/config.js +0 -2
- package/dist/lib/traces/insights.d.ts +0 -30
- package/dist/lib/traces/insights.js +0 -198
- package/dist/lib/traces/phenotype.d.ts +0 -18
- package/dist/lib/traces/phenotype.js +0 -335
- package/dist/lib/traces/provision.d.ts +0 -16
- package/dist/lib/traces/provision.js +0 -25
- package/dist/lib/traces/schema2-build.d.ts +0 -28
- package/dist/lib/traces/schema2-build.js +0 -496
- package/dist/lib/traces/schema2-danger.d.ts +0 -7
- package/dist/lib/traces/schema2-danger.js +0 -123
- package/dist/lib/traces/schema2.d.ts +0 -139
- package/dist/lib/traces/schema2.js +0 -20
- package/dist/lib/traces/segments.d.ts +0 -73
- package/dist/lib/traces/segments.js +0 -236
- package/dist/lib/traces/sync.d.ts +0 -197
- package/dist/lib/traces/sync.js +0 -654
- package/dist/lib/traces/worker-template.d.ts +0 -1
- package/dist/lib/traces/worker-template.js +0 -292
- package/dist/lib/triggers/handlers.d.ts +0 -66
- package/dist/lib/triggers/handlers.js +0 -383
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
export type StepOutcome = 'ok' | 'error' | 'running' | 'unknown';
|
|
2
|
-
interface SessionStepBase {
|
|
3
|
-
ordinal: number;
|
|
4
|
-
startMs: number;
|
|
5
|
-
durationMs: number;
|
|
6
|
-
durationEstimated: boolean;
|
|
7
|
-
outcome: StepOutcome;
|
|
8
|
-
label: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ThinkingStep extends SessionStepBase {
|
|
11
|
-
kind: 'thinking';
|
|
12
|
-
lane: 'think';
|
|
13
|
-
outcome: 'ok' | 'running' | 'unknown';
|
|
14
|
-
}
|
|
15
|
-
interface ExecutionBase extends SessionStepBase {
|
|
16
|
-
kind: 'execution';
|
|
17
|
-
lane: string;
|
|
18
|
-
callId?: string;
|
|
19
|
-
targetCallId?: string;
|
|
20
|
-
}
|
|
21
|
-
type ToolExecutionType = 'bash' | 'edit' | 'write' | 'read' | 'grep' | 'generic';
|
|
22
|
-
interface ToolExecutionBase extends ExecutionBase {
|
|
23
|
-
executionType: ToolExecutionType;
|
|
24
|
-
tool: string;
|
|
25
|
-
result: ExecutionResult;
|
|
26
|
-
}
|
|
27
|
-
export interface ExecutionResult {
|
|
28
|
-
exitCode?: number;
|
|
29
|
-
statusCode?: number;
|
|
30
|
-
errorCode?: string;
|
|
31
|
-
stdout?: TextPreview;
|
|
32
|
-
stderr?: TextPreview;
|
|
33
|
-
combined?: TextPreview;
|
|
34
|
-
}
|
|
35
|
-
export interface TextPreview {
|
|
36
|
-
text: string;
|
|
37
|
-
truncated: boolean;
|
|
38
|
-
originalBytes: number;
|
|
39
|
-
}
|
|
40
|
-
export type BashCategory = 'build' | 'test' | 'git' | 'network' | 'other';
|
|
41
|
-
export type BashDanger = 'normal' | 'potentially-destructive' | 'DESTRUCTIVE';
|
|
42
|
-
export interface BashAction {
|
|
43
|
-
ordinal: number;
|
|
44
|
-
source: string;
|
|
45
|
-
argv: string[];
|
|
46
|
-
argvComplete: boolean;
|
|
47
|
-
program?: string;
|
|
48
|
-
categories: BashCategory[];
|
|
49
|
-
danger: BashDanger;
|
|
50
|
-
destructiveOperation?: string;
|
|
51
|
-
}
|
|
52
|
-
export interface BashExecution extends ToolExecutionBase {
|
|
53
|
-
executionType: 'bash';
|
|
54
|
-
command: string;
|
|
55
|
-
unwrappedCommand: string;
|
|
56
|
-
parseStatus: 'parsed' | 'partial' | 'unparseable';
|
|
57
|
-
parseDiagnostics: string[];
|
|
58
|
-
actions: BashAction[];
|
|
59
|
-
}
|
|
60
|
-
export type FileOperation = 'create' | 'update' | 'overwrite' | 'delete' | 'rename' | 'unknown';
|
|
61
|
-
export interface FileHunk {
|
|
62
|
-
id: string;
|
|
63
|
-
oldStart?: number;
|
|
64
|
-
oldLines?: number;
|
|
65
|
-
newStart?: number;
|
|
66
|
-
newLines?: number;
|
|
67
|
-
addedLines: number;
|
|
68
|
-
removedLines: number;
|
|
69
|
-
beforeHash?: string;
|
|
70
|
-
afterHash?: string;
|
|
71
|
-
before?: TextPreview;
|
|
72
|
-
after?: TextPreview;
|
|
73
|
-
revertedByStep?: number;
|
|
74
|
-
}
|
|
75
|
-
export interface FileMutation {
|
|
76
|
-
path: string;
|
|
77
|
-
operation: FileOperation;
|
|
78
|
-
hunks: FileHunk[];
|
|
79
|
-
revertedByStep?: number;
|
|
80
|
-
}
|
|
81
|
-
export interface RevertLink {
|
|
82
|
-
revertedStep: number;
|
|
83
|
-
path: string;
|
|
84
|
-
revertedHunkIds: string[];
|
|
85
|
-
}
|
|
86
|
-
export interface EditExecution extends ToolExecutionBase {
|
|
87
|
-
executionType: 'edit';
|
|
88
|
-
files: FileMutation[];
|
|
89
|
-
reverts: RevertLink[];
|
|
90
|
-
}
|
|
91
|
-
export interface WriteExecution extends ToolExecutionBase {
|
|
92
|
-
executionType: 'write';
|
|
93
|
-
files: FileMutation[];
|
|
94
|
-
reverts: RevertLink[];
|
|
95
|
-
}
|
|
96
|
-
export interface CountResult {
|
|
97
|
-
value: number;
|
|
98
|
-
relation: 'exact' | 'at-least';
|
|
99
|
-
}
|
|
100
|
-
export interface ReadExecution extends ToolExecutionBase {
|
|
101
|
-
executionType: 'read';
|
|
102
|
-
file: string;
|
|
103
|
-
offset?: number;
|
|
104
|
-
limit?: number;
|
|
105
|
-
returnedLines?: CountResult;
|
|
106
|
-
returnedBytes?: CountResult;
|
|
107
|
-
}
|
|
108
|
-
export interface GrepExecution extends ToolExecutionBase {
|
|
109
|
-
executionType: 'grep';
|
|
110
|
-
query: string;
|
|
111
|
-
path?: string;
|
|
112
|
-
glob?: string;
|
|
113
|
-
outputMode?: 'content' | 'files' | 'count' | 'unknown';
|
|
114
|
-
hits?: CountResult;
|
|
115
|
-
}
|
|
116
|
-
export interface GenericToolExecution extends ToolExecutionBase {
|
|
117
|
-
executionType: 'generic';
|
|
118
|
-
input?: TextPreview;
|
|
119
|
-
}
|
|
120
|
-
export interface PermissionExecution extends ExecutionBase {
|
|
121
|
-
executionType: 'permission';
|
|
122
|
-
lane: 'permission';
|
|
123
|
-
requestId?: string;
|
|
124
|
-
permissionKind: 'command' | 'filesystem' | 'network' | 'mcp' | 'other';
|
|
125
|
-
decision: 'approved' | 'denied' | 'cancelled' | 'pending';
|
|
126
|
-
scope?: string;
|
|
127
|
-
reason?: TextPreview;
|
|
128
|
-
}
|
|
129
|
-
export interface HookExecution extends ExecutionBase {
|
|
130
|
-
executionType: 'hook';
|
|
131
|
-
lane: 'hook';
|
|
132
|
-
hookName?: string;
|
|
133
|
-
hookEvent?: string;
|
|
134
|
-
phase: 'pre' | 'post' | 'session' | 'other';
|
|
135
|
-
decision: 'allowed' | 'blocked' | 'error' | 'unknown';
|
|
136
|
-
result: ExecutionResult;
|
|
137
|
-
}
|
|
138
|
-
export type SessionStepV2 = ThinkingStep | BashExecution | EditExecution | WriteExecution | ReadExecution | GrepExecution | GenericToolExecution | PermissionExecution | HookExecution;
|
|
139
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* ────────────────────────────────────────────────────────────────────────
|
|
2
|
-
* Schema 2 — canonical ToolExecution session detail (PHNX-3442, producer side).
|
|
3
|
-
*
|
|
4
|
-
* This is the PRODUCER's authoring contract for the `schema: 2` per-session
|
|
5
|
-
* detail shard. It mirrors, field for field, the CONSUMER contract already
|
|
6
|
-
* shipped and live in `prix/web/lib/traces/types.ts` (SessionDetailV2). The
|
|
7
|
-
* split is deliberate: the command / patch / output PARSING lives here in
|
|
8
|
-
* agents-cli — the worker stores the shard opaquely and the console reads the
|
|
9
|
-
* union directly and NEVER reparses (spec §3, §5).
|
|
10
|
-
*
|
|
11
|
-
* Step 1 (the consumer decoder that reads BOTH schema 1 and schema 2) is merged
|
|
12
|
-
* and live in prod, so emitting schema 2 from here is safe: an old console
|
|
13
|
-
* would still read it, a new one reads it richly.
|
|
14
|
-
*
|
|
15
|
-
* This module is TYPES ONLY. The per-tool mappers that populate these shapes
|
|
16
|
-
* (bash argv + classification, edit/write hunks + the cross-step revert ledger,
|
|
17
|
-
* read/grep counts, first-class permission/hook steps) land in follow-up
|
|
18
|
-
* increments alongside `buildSessionDetailV2`.
|
|
19
|
-
* ──────────────────────────────────────────────────────────────────────── */
|
|
20
|
-
export {};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export declare const TASK_TYPES: readonly ["bugfix", "feature", "refactor", "test", "chore", "other"];
|
|
2
|
-
export type TaskType = (typeof TASK_TYPES)[number];
|
|
3
|
-
declare const FAILURE_TIMINGS: readonly ["early", "mid", "late"];
|
|
4
|
-
type FailureTiming = (typeof FAILURE_TIMINGS)[number];
|
|
5
|
-
interface SegmentAgent {
|
|
6
|
-
model: string;
|
|
7
|
-
harness: string;
|
|
8
|
-
}
|
|
9
|
-
export interface SegmentFile {
|
|
10
|
-
path: string;
|
|
11
|
-
action: 'new' | 'edit';
|
|
12
|
-
}
|
|
13
|
-
export interface SegmentStep {
|
|
14
|
-
startMs: number;
|
|
15
|
-
durationMs?: number;
|
|
16
|
-
outcome?: 'ok' | 'error' | 'unknown' | string;
|
|
17
|
-
tool?: string;
|
|
18
|
-
kind?: 'tool' | 'thinking' | string;
|
|
19
|
-
label?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface SegmentSession {
|
|
22
|
-
id?: string;
|
|
23
|
-
prompt?: string | null;
|
|
24
|
-
gitBranch?: string | null;
|
|
25
|
-
topic?: string | null;
|
|
26
|
-
label?: string | null;
|
|
27
|
-
mode?: string | null;
|
|
28
|
-
agent?: string | null;
|
|
29
|
-
harness?: string | null;
|
|
30
|
-
model?: string | null;
|
|
31
|
-
spanMs?: number | null;
|
|
32
|
-
files?: readonly SegmentFile[] | null;
|
|
33
|
-
meta?: {
|
|
34
|
-
agent?: string | null;
|
|
35
|
-
model?: string | null;
|
|
36
|
-
spanMs?: number | null;
|
|
37
|
-
repo?: string | null;
|
|
38
|
-
tools?: number | null;
|
|
39
|
-
} | null;
|
|
40
|
-
steps?: readonly SegmentStep[] | null;
|
|
41
|
-
whereItWentWrong?: string | null;
|
|
42
|
-
}
|
|
43
|
-
export interface Percentiles {
|
|
44
|
-
p50: number;
|
|
45
|
-
p90: number;
|
|
46
|
-
p99: number;
|
|
47
|
-
max: number;
|
|
48
|
-
}
|
|
49
|
-
export interface LatencyInsight {
|
|
50
|
-
firstToolMs: Percentiles;
|
|
51
|
-
}
|
|
52
|
-
interface SegmentDimensions {
|
|
53
|
-
agent: SegmentAgent;
|
|
54
|
-
taskType: TaskType;
|
|
55
|
-
failureTiming: FailureTiming | null;
|
|
56
|
-
}
|
|
57
|
-
type DiffShape = {
|
|
58
|
-
files: readonly SegmentFile[];
|
|
59
|
-
testOnly: boolean;
|
|
60
|
-
newOnly: boolean;
|
|
61
|
-
choreOnly: boolean;
|
|
62
|
-
};
|
|
63
|
-
export declare const TASK_TYPE_RULES: ReadonlyArray<{
|
|
64
|
-
type: Exclude<TaskType, 'other'>;
|
|
65
|
-
patterns: readonly RegExp[];
|
|
66
|
-
shape?: keyof Pick<DiffShape, 'testOnly' | 'newOnly' | 'choreOnly'>;
|
|
67
|
-
}>;
|
|
68
|
-
export declare function deriveAgent(session: SegmentSession): SegmentAgent;
|
|
69
|
-
export declare function classifyTaskType(session: SegmentSession): TaskType;
|
|
70
|
-
export declare function failureTiming(session: SegmentSession): FailureTiming | null;
|
|
71
|
-
export declare function computeLatency(sessions: readonly SegmentSession[]): LatencyInsight;
|
|
72
|
-
export declare function deriveDimensions(session: SegmentSession): SegmentDimensions;
|
|
73
|
-
export {};
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
export const TASK_TYPES = ['bugfix', 'feature', 'refactor', 'test', 'chore', 'other'];
|
|
2
|
-
const FAILURE_TIMINGS = ['early', 'mid', 'late'];
|
|
3
|
-
const FILE_ACTION_TOOLS = [
|
|
4
|
-
{ action: 'new', tools: ['write', 'write_file', 'create_file', 'create'] },
|
|
5
|
-
{ action: 'edit', tools: ['edit', 'strreplace', 'apply_patch', 'applypatch', 'notebookedit'] },
|
|
6
|
-
];
|
|
7
|
-
const TEST_PATH_PATTERN = /(?:^|\/)(?:__tests__|testdata|test)\/|\.(?:test|spec)\.[cm]?[jt]sx?$|_test\.(?:go|py|rs)$/i;
|
|
8
|
-
const CHORE_PATH_PATTERN = /(?:^|\/)(?:package(?:-lock)?\.json|bun\.lockb?|pnpm-lock\.yaml|yarn\.lock|Cargo\.lock|go\.sum|Dockerfile|Makefile|\.github\/|CHANGELOG[^/]*|README[^/]*|\.gitignore)$/i;
|
|
9
|
-
const DIFF_SHAPE_MATCHERS = [
|
|
10
|
-
{
|
|
11
|
-
key: 'testOnly',
|
|
12
|
-
match: (files) => files.length > 0 && files.every((f) => TEST_PATH_PATTERN.test(f.path)),
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
key: 'newOnly',
|
|
16
|
-
match: (files) => files.length > 0 && files.every((f) => f.action === 'new'),
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
key: 'choreOnly',
|
|
20
|
-
match: (files) => files.length > 0 && files.every((f) => CHORE_PATH_PATTERN.test(f.path)),
|
|
21
|
-
},
|
|
22
|
-
];
|
|
23
|
-
export const TASK_TYPE_RULES = [
|
|
24
|
-
{
|
|
25
|
-
type: 'test',
|
|
26
|
-
patterns: [
|
|
27
|
-
/\bunit tests?\b/,
|
|
28
|
-
/\bintegration tests?\b/,
|
|
29
|
-
/\btestdata\b/,
|
|
30
|
-
/\bcoverage\b/,
|
|
31
|
-
/\b(?:add|write|update|fix)\s+tests?\b/,
|
|
32
|
-
/\btest[- ]only\b/,
|
|
33
|
-
/(?:^|\/)tests?\//,
|
|
34
|
-
/^test\//,
|
|
35
|
-
/\.(?:test|spec)\./,
|
|
36
|
-
],
|
|
37
|
-
shape: 'testOnly',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
type: 'bugfix',
|
|
41
|
-
patterns: [
|
|
42
|
-
/\bbugfix(?:es)?\b/,
|
|
43
|
-
/\bhot[- ]?fix(?:es)?\b/,
|
|
44
|
-
/\bfixes\b/,
|
|
45
|
-
/\bfixing\b/,
|
|
46
|
-
/\bfix\b/,
|
|
47
|
-
/\bbugs?\b/,
|
|
48
|
-
/\bregression\b/,
|
|
49
|
-
/\bcrash(?:es|ed|ing)?\b/,
|
|
50
|
-
/\bbroken\b/,
|
|
51
|
-
/(?:^|\/)fix(?:es)?\//,
|
|
52
|
-
/^bugfix\//,
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
type: 'refactor',
|
|
57
|
-
patterns: [
|
|
58
|
-
/\brefactor(?:s|ing|ed)?\b/,
|
|
59
|
-
/\bclean[- ]?ups?\b/,
|
|
60
|
-
/\bextract(?:s|ing|ed)?\b/,
|
|
61
|
-
/\brename(?:s|d|ing)?\b/,
|
|
62
|
-
/(?:^|\/)refactor\//,
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
type: 'chore',
|
|
67
|
-
patterns: [
|
|
68
|
-
/\bchore\b/,
|
|
69
|
-
/\bdependenc(?:y|ies)\b/,
|
|
70
|
-
/\bbump\b/,
|
|
71
|
-
/\blint(?:ing|er)?\b/,
|
|
72
|
-
/\bformat(?:ting)?\b/,
|
|
73
|
-
/(?:^|\/)chore\//,
|
|
74
|
-
/\b(?:ci|cd)[-_/]/,
|
|
75
|
-
],
|
|
76
|
-
shape: 'choreOnly',
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
type: 'feature',
|
|
80
|
-
patterns: [
|
|
81
|
-
/\bfeat(?:ure)?s?\b/,
|
|
82
|
-
/\bimplement(?:s|ing|ed)?\b/,
|
|
83
|
-
/\bnew feature\b/,
|
|
84
|
-
/(?:^|\/)feat(?:ure)?\//,
|
|
85
|
-
],
|
|
86
|
-
shape: 'newOnly',
|
|
87
|
-
},
|
|
88
|
-
];
|
|
89
|
-
const FAILURE_TIMING_BUCKETS = [
|
|
90
|
-
{ timing: 'early', maxExclusive: 1 / 3 },
|
|
91
|
-
{ timing: 'mid', maxExclusive: 2 / 3 },
|
|
92
|
-
{ timing: 'late', maxExclusive: Number.POSITIVE_INFINITY },
|
|
93
|
-
];
|
|
94
|
-
const AGENT_FIELDS = {
|
|
95
|
-
model: [
|
|
96
|
-
(s) => s.meta?.model,
|
|
97
|
-
(s) => s.model,
|
|
98
|
-
],
|
|
99
|
-
harness: [
|
|
100
|
-
(s) => s.meta?.agent,
|
|
101
|
-
(s) => s.harness,
|
|
102
|
-
(s) => s.agent,
|
|
103
|
-
],
|
|
104
|
-
};
|
|
105
|
-
export function deriveAgent(session) {
|
|
106
|
-
return {
|
|
107
|
-
model: firstPresent(AGENT_FIELDS.model.map((read) => read(session))),
|
|
108
|
-
harness: firstPresent(AGENT_FIELDS.harness.map((read) => read(session))),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
export function classifyTaskType(session) {
|
|
112
|
-
const haystack = taskHaystack(session);
|
|
113
|
-
const shape = inferDiffShape(session);
|
|
114
|
-
for (const rule of TASK_TYPE_RULES) {
|
|
115
|
-
if (rule.patterns.some((pattern) => pattern.test(haystack)))
|
|
116
|
-
return rule.type;
|
|
117
|
-
if (rule.shape && shape[rule.shape])
|
|
118
|
-
return rule.type;
|
|
119
|
-
}
|
|
120
|
-
return 'other';
|
|
121
|
-
}
|
|
122
|
-
export function failureTiming(session) {
|
|
123
|
-
const firstFailure = (session.steps ?? []).find((step) => step.outcome === 'error');
|
|
124
|
-
if (!firstFailure)
|
|
125
|
-
return null;
|
|
126
|
-
const span = sessionSpanMs(session);
|
|
127
|
-
const position = span > 0 ? firstFailure.startMs / span : 0;
|
|
128
|
-
return FAILURE_TIMING_BUCKETS.find((bucket) => position < bucket.maxExclusive)?.timing ?? null;
|
|
129
|
-
}
|
|
130
|
-
export function computeLatency(sessions) {
|
|
131
|
-
const samples = [];
|
|
132
|
-
for (const session of sessions) {
|
|
133
|
-
const steps = session.steps ?? [];
|
|
134
|
-
if (steps.length === 0)
|
|
135
|
-
continue;
|
|
136
|
-
const startMs = steps[0]?.startMs;
|
|
137
|
-
if (typeof startMs !== 'number' || !Number.isFinite(startMs))
|
|
138
|
-
continue;
|
|
139
|
-
samples.push(startMs);
|
|
140
|
-
}
|
|
141
|
-
return {
|
|
142
|
-
firstToolMs: {
|
|
143
|
-
p50: percentileNearest(samples, 0.5),
|
|
144
|
-
p90: percentileNearest(samples, 0.9),
|
|
145
|
-
p99: percentileNearest(samples, 0.99),
|
|
146
|
-
max: samples.length === 0 ? 0 : Math.max(...samples),
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
export function deriveDimensions(session) {
|
|
151
|
-
return {
|
|
152
|
-
agent: deriveAgent(session),
|
|
153
|
-
taskType: classifyTaskType(session),
|
|
154
|
-
failureTiming: failureTiming(session),
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
function firstPresent(values) {
|
|
158
|
-
for (const value of values) {
|
|
159
|
-
if (typeof value === 'string' && value.length > 0)
|
|
160
|
-
return value;
|
|
161
|
-
}
|
|
162
|
-
return 'unknown';
|
|
163
|
-
}
|
|
164
|
-
function taskHaystack(session) {
|
|
165
|
-
const filePaths = inferFiles(session).map((file) => file.path);
|
|
166
|
-
const writeLabels = (session.steps ?? [])
|
|
167
|
-
.filter((step) => fileActionForTool(step.tool) !== undefined)
|
|
168
|
-
.map((step) => step.label ?? '');
|
|
169
|
-
return [
|
|
170
|
-
session.prompt,
|
|
171
|
-
session.gitBranch,
|
|
172
|
-
session.topic,
|
|
173
|
-
session.label,
|
|
174
|
-
session.meta?.repo,
|
|
175
|
-
...filePaths,
|
|
176
|
-
...writeLabels,
|
|
177
|
-
]
|
|
178
|
-
.filter((value) => typeof value === 'string' && value.length > 0)
|
|
179
|
-
.join('\n')
|
|
180
|
-
.toLowerCase();
|
|
181
|
-
}
|
|
182
|
-
function inferFiles(session) {
|
|
183
|
-
if (session.files && session.files.length > 0)
|
|
184
|
-
return session.files;
|
|
185
|
-
const files = [];
|
|
186
|
-
for (const step of session.steps ?? []) {
|
|
187
|
-
const action = fileActionForTool(step.tool);
|
|
188
|
-
if (!action)
|
|
189
|
-
continue;
|
|
190
|
-
const path = filePathFromLabel(step.label);
|
|
191
|
-
if (!path)
|
|
192
|
-
continue;
|
|
193
|
-
files.push({ path, action });
|
|
194
|
-
}
|
|
195
|
-
return files;
|
|
196
|
-
}
|
|
197
|
-
function fileActionForTool(tool) {
|
|
198
|
-
if (!tool)
|
|
199
|
-
return undefined;
|
|
200
|
-
const name = tool.toLowerCase();
|
|
201
|
-
for (const row of FILE_ACTION_TOOLS) {
|
|
202
|
-
if (row.tools.includes(name))
|
|
203
|
-
return row.action;
|
|
204
|
-
}
|
|
205
|
-
return undefined;
|
|
206
|
-
}
|
|
207
|
-
function filePathFromLabel(label) {
|
|
208
|
-
if (!label)
|
|
209
|
-
return undefined;
|
|
210
|
-
const match = label.match(/(?:^|[\s`'"])(\/?[\w.@-]+(?:\/[\w.@-]+)+\.[A-Za-z][\w.]*)/);
|
|
211
|
-
return match?.[1];
|
|
212
|
-
}
|
|
213
|
-
function inferDiffShape(session) {
|
|
214
|
-
const files = inferFiles(session);
|
|
215
|
-
const shape = { files, testOnly: false, newOnly: false, choreOnly: false };
|
|
216
|
-
for (const matcher of DIFF_SHAPE_MATCHERS) {
|
|
217
|
-
shape[matcher.key] = matcher.match(files);
|
|
218
|
-
}
|
|
219
|
-
return shape;
|
|
220
|
-
}
|
|
221
|
-
function sessionSpanMs(session) {
|
|
222
|
-
const declared = session.meta?.spanMs ?? session.spanMs ?? 0;
|
|
223
|
-
if (declared > 0)
|
|
224
|
-
return declared;
|
|
225
|
-
let max = 0;
|
|
226
|
-
for (const step of session.steps ?? []) {
|
|
227
|
-
max = Math.max(max, step.startMs + (step.durationMs ?? 0));
|
|
228
|
-
}
|
|
229
|
-
return max;
|
|
230
|
-
}
|
|
231
|
-
function percentileNearest(values, ratio) {
|
|
232
|
-
if (values.length === 0)
|
|
233
|
-
return 0;
|
|
234
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
235
|
-
return sorted[Math.min(sorted.length - 1, Math.ceil(sorted.length * ratio) - 1)];
|
|
236
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { type SessionTrajectory } from '@phnx-labs/sessions-cli/reader';
|
|
2
|
-
import { type BucketStats, type DriftSignal, type TraceFailureCause, type TraceTopicGroup } from './classify.js';
|
|
3
|
-
import { type FailurePattern } from './insights.js';
|
|
4
|
-
import type { LatencyInsight } from './segments.js';
|
|
5
|
-
import { buildSessionDetailV2 } from './schema2-build.js';
|
|
6
|
-
import type { SessionEvent } from '@phnx-labs/sessions-cli/reader';
|
|
7
|
-
export declare function buildSessionShard(traj: SessionTrajectory, events: SessionEvent[], knownSecrets: readonly string[] | undefined): ReturnType<typeof buildSessionDetailV2>;
|
|
8
|
-
export interface SyncOpts {
|
|
9
|
-
limit?: number;
|
|
10
|
-
skipIndex?: boolean;
|
|
11
|
-
dryRun?: boolean;
|
|
12
|
-
outDir?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface SyncResult {
|
|
15
|
-
uploaded: number;
|
|
16
|
-
skipped: number;
|
|
17
|
-
errors: number;
|
|
18
|
-
transcriptUnavailable: number;
|
|
19
|
-
parseFailed: number;
|
|
20
|
-
uploadFailed: number;
|
|
21
|
-
indexError?: string;
|
|
22
|
-
}
|
|
23
|
-
export declare function syncTraces(opts?: SyncOpts): Promise<SyncResult>;
|
|
24
|
-
export interface TracesIndexShard {
|
|
25
|
-
schema: 1;
|
|
26
|
-
device: string;
|
|
27
|
-
syncedAt: number;
|
|
28
|
-
owner: string;
|
|
29
|
-
stats: {
|
|
30
|
-
sessionsImported: number;
|
|
31
|
-
medianMs: number;
|
|
32
|
-
p90Ms: number;
|
|
33
|
-
agentMedianMs: number;
|
|
34
|
-
agentP90Ms: number;
|
|
35
|
-
interactiveMedianMs: number;
|
|
36
|
-
measuredFraction: number;
|
|
37
|
-
needAttention: number;
|
|
38
|
-
toolErrorRate: number;
|
|
39
|
-
};
|
|
40
|
-
utilityCount: number;
|
|
41
|
-
needsAttention: IndexedSession[];
|
|
42
|
-
topics: TopicItem[];
|
|
43
|
-
failures: {
|
|
44
|
-
byToolError: Array<{
|
|
45
|
-
tool: string;
|
|
46
|
-
desc: string;
|
|
47
|
-
cause: TraceFailureCause;
|
|
48
|
-
count: number;
|
|
49
|
-
}>;
|
|
50
|
-
byCause: Record<TraceFailureCause, number>;
|
|
51
|
-
};
|
|
52
|
-
bucketHistory: BucketStats[][];
|
|
53
|
-
driftSignals: DriftSignal[];
|
|
54
|
-
failurePatterns: FailurePattern[];
|
|
55
|
-
wastedMsTotal: number;
|
|
56
|
-
latency: LatencyInsight;
|
|
57
|
-
sessions?: SessionRosterRow[];
|
|
58
|
-
}
|
|
59
|
-
export interface SessionRosterRow {
|
|
60
|
-
id: string;
|
|
61
|
-
title: string;
|
|
62
|
-
harness: string;
|
|
63
|
-
model: string;
|
|
64
|
-
repo: string;
|
|
65
|
-
mode: 'interactive' | 'headless';
|
|
66
|
-
projectType: TraceTopicGroup;
|
|
67
|
-
startedAt: number;
|
|
68
|
-
durationMs: number;
|
|
69
|
-
toolCount: number;
|
|
70
|
-
errorCount: number;
|
|
71
|
-
needsAttention: boolean;
|
|
72
|
-
costUsd?: number;
|
|
73
|
-
}
|
|
74
|
-
export interface IndexedSession {
|
|
75
|
-
id: string;
|
|
76
|
-
title: string;
|
|
77
|
-
repo: string;
|
|
78
|
-
device: string;
|
|
79
|
-
agent: string;
|
|
80
|
-
model: string;
|
|
81
|
-
kind: SessionKind;
|
|
82
|
-
severity: number;
|
|
83
|
-
flags: string[];
|
|
84
|
-
}
|
|
85
|
-
interface TopicSessionRef {
|
|
86
|
-
id: string;
|
|
87
|
-
title: string;
|
|
88
|
-
kind: SessionKind;
|
|
89
|
-
harness: string;
|
|
90
|
-
}
|
|
91
|
-
type SessionKind = 'utility' | 'agent';
|
|
92
|
-
export declare function classifySessionKind(row: Pick<SyncRow, 'topic' | 'label' | 'message_count' | 'tool_call_count'>, toolCallCount: number): SessionKind;
|
|
93
|
-
export interface TopicItem {
|
|
94
|
-
key: string;
|
|
95
|
-
label: string;
|
|
96
|
-
count: number;
|
|
97
|
-
group: TraceTopicGroup;
|
|
98
|
-
sessions: TopicSessionRef[];
|
|
99
|
-
}
|
|
100
|
-
export interface ToolCallRow {
|
|
101
|
-
session_id: string;
|
|
102
|
-
ordinal: number;
|
|
103
|
-
timestamp: string;
|
|
104
|
-
end_timestamp?: string | null;
|
|
105
|
-
tool: string;
|
|
106
|
-
outcome: string;
|
|
107
|
-
exit_code: number | null;
|
|
108
|
-
status_code: number | null;
|
|
109
|
-
error_code: string | null;
|
|
110
|
-
error: string | null;
|
|
111
|
-
parse_error: string | null;
|
|
112
|
-
}
|
|
113
|
-
export declare function sessionActiveMs(spanMs: number, sessionCalls: ToolCallRow[], sessionStartMs: number): number;
|
|
114
|
-
export declare function activeMsFromTrajectory(traj: SessionTrajectory): number;
|
|
115
|
-
export declare function failureDescription(call: ToolCallRow, cause: TraceFailureCause): string;
|
|
116
|
-
export declare function buildIndexShard(rows: SyncRow[], device: string, owner: string, prevShard?: TracesIndexShard | null): TracesIndexShard;
|
|
117
|
-
export interface SessionDetail {
|
|
118
|
-
schema: 1;
|
|
119
|
-
id: string;
|
|
120
|
-
meta: {
|
|
121
|
-
spanMs: number;
|
|
122
|
-
activeMs: number;
|
|
123
|
-
turns: number;
|
|
124
|
-
tools: number;
|
|
125
|
-
errorCount: number;
|
|
126
|
-
tokens: number;
|
|
127
|
-
costUsd: number;
|
|
128
|
-
outcome: string;
|
|
129
|
-
repo: string;
|
|
130
|
-
agent: string;
|
|
131
|
-
model: string;
|
|
132
|
-
};
|
|
133
|
-
steps: SessionTrajectory['steps'];
|
|
134
|
-
gaps: SessionTrajectory['gaps'];
|
|
135
|
-
truncatedSteps: number;
|
|
136
|
-
whereItWentWrong: string | null;
|
|
137
|
-
surfacedToolFailures: Array<{
|
|
138
|
-
tool?: string;
|
|
139
|
-
label: string;
|
|
140
|
-
detail?: string;
|
|
141
|
-
}>;
|
|
142
|
-
}
|
|
143
|
-
export declare function buildWhereItWentWrong(traj: SessionTrajectory): string | null;
|
|
144
|
-
export declare function deriveRunOutcome(traj: SessionTrajectory): 'completed' | 'errored';
|
|
145
|
-
export declare function buildDetailMeta(traj: SessionTrajectory): SessionDetail['meta'];
|
|
146
|
-
export declare function buildSessionDetail(traj: SessionTrajectory): SessionDetail;
|
|
147
|
-
export type SyncFailureKind = 'transcript-unavailable' | 'parse-failed' | 'upload-failed';
|
|
148
|
-
export interface SyncFailure {
|
|
149
|
-
id: string;
|
|
150
|
-
mtimeMs: number;
|
|
151
|
-
kind: SyncFailureKind;
|
|
152
|
-
detail: string;
|
|
153
|
-
firstSeen: number;
|
|
154
|
-
attempts: number;
|
|
155
|
-
}
|
|
156
|
-
interface SyncLedger {
|
|
157
|
-
lastSyncMtime?: number;
|
|
158
|
-
failures?: SyncFailure[];
|
|
159
|
-
}
|
|
160
|
-
export declare function readSyncLedger(): SyncLedger;
|
|
161
|
-
export declare function hasSyncedBefore(): boolean;
|
|
162
|
-
export interface SyncRow {
|
|
163
|
-
id: string;
|
|
164
|
-
short_id: string;
|
|
165
|
-
agent: string;
|
|
166
|
-
origin: string | null;
|
|
167
|
-
routine_name: string | null;
|
|
168
|
-
routine_run_id: string | null;
|
|
169
|
-
version: string | null;
|
|
170
|
-
account: string | null;
|
|
171
|
-
account_key: string | null;
|
|
172
|
-
account_org: string | null;
|
|
173
|
-
mode: string | null;
|
|
174
|
-
timestamp: string;
|
|
175
|
-
last_activity: string | null;
|
|
176
|
-
project: string | null;
|
|
177
|
-
cwd: string | null;
|
|
178
|
-
git_branch: string | null;
|
|
179
|
-
topic: string | null;
|
|
180
|
-
label: string | null;
|
|
181
|
-
message_count: number | null;
|
|
182
|
-
token_count: number | null;
|
|
183
|
-
output_tokens: number | null;
|
|
184
|
-
input_tokens: number | null;
|
|
185
|
-
cache_read_tokens: number | null;
|
|
186
|
-
cache_write_tokens: number | null;
|
|
187
|
-
cost_usd: number | null;
|
|
188
|
-
cost_usd_nocache: number | null;
|
|
189
|
-
duration_ms: number | null;
|
|
190
|
-
model: string | null;
|
|
191
|
-
tool_call_count: number | null;
|
|
192
|
-
file_path: string;
|
|
193
|
-
file_mtime_ms: number | null;
|
|
194
|
-
file_size: number | null;
|
|
195
|
-
machine: string | null;
|
|
196
|
-
}
|
|
197
|
-
export {};
|