@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,335 +0,0 @@
|
|
|
1
|
-
const READ_PLAN_TOOLS = new Set([
|
|
2
|
-
'Read',
|
|
3
|
-
'read_file',
|
|
4
|
-
'grep',
|
|
5
|
-
'list_dir',
|
|
6
|
-
'search',
|
|
7
|
-
'codebase_search',
|
|
8
|
-
'ToolSearch',
|
|
9
|
-
'web_search',
|
|
10
|
-
'web_fetch',
|
|
11
|
-
'WebSearch',
|
|
12
|
-
'FetchURL',
|
|
13
|
-
'TaskCreate',
|
|
14
|
-
'todo_write',
|
|
15
|
-
]);
|
|
16
|
-
const WRITE_EDIT_TOOLS = new Set([
|
|
17
|
-
'Edit',
|
|
18
|
-
'Write',
|
|
19
|
-
'search_replace',
|
|
20
|
-
'write',
|
|
21
|
-
'notebookedit',
|
|
22
|
-
'multiedit',
|
|
23
|
-
]);
|
|
24
|
-
const HUMAN_FACING_TOOLS = new Set(['AskUserQuestion', 'SendMessage', 'wait']);
|
|
25
|
-
const SHELL_TOOLS = new Set([
|
|
26
|
-
'Bash',
|
|
27
|
-
'run_terminal_command',
|
|
28
|
-
'exec_command',
|
|
29
|
-
'exec',
|
|
30
|
-
'shell',
|
|
31
|
-
'Execute',
|
|
32
|
-
]);
|
|
33
|
-
const OUTCOME_SIGNALS = [
|
|
34
|
-
{ type: 'merge', pattern: /\bgh pr merge\b|\bmerged?\b.*\b(PR|pull request|branch)\b|\brebase-?merge\b/i },
|
|
35
|
-
{ type: 'merge', pattern: /\bmerge\b.*\bsucceeded\b|\bsuccessfully\s+merged\b/i },
|
|
36
|
-
{ type: 'test', pattern: /\b(bun test|npm test|yarn test|pnpm test|pytest|jest|vitest|cargo test|go test)\b/i },
|
|
37
|
-
{ type: 'test', pattern: /\btsc\s+--noEmit\b|\blint\b|\btest\.sh\b/i },
|
|
38
|
-
{ type: 'env', pattern: /\bbun install\b|\bnpm install\b|\byarn install\b|\bpnpm install\b|\bpip install\b/i },
|
|
39
|
-
{ type: 'env', pattern: /\bnode_modules\b|\bmissing\b|\bnot found\b|\bpermission denied\b|\bcommand not found\b/i },
|
|
40
|
-
{ type: 'env', pattern: /\bssh.*key\b|\bclone\b.*\bfailed\b/i },
|
|
41
|
-
{ type: 'revert', pattern: /\brevert\b|\bgit checkout\b|\breset\s+--hard\b/i },
|
|
42
|
-
];
|
|
43
|
-
function isToolStep(step) {
|
|
44
|
-
return step.kind === 'tool';
|
|
45
|
-
}
|
|
46
|
-
function substantiveSteps(session) {
|
|
47
|
-
return session.steps.filter((s) => isToolStep(s) && !HUMAN_FACING_TOOLS.has(s.tool ?? s.lane));
|
|
48
|
-
}
|
|
49
|
-
function firstStepOrdinalOf(session, predicate) {
|
|
50
|
-
for (const step of session.steps) {
|
|
51
|
-
if (predicate(step))
|
|
52
|
-
return step.ordinal;
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
function lastStepOrdinalOf(session, predicate) {
|
|
57
|
-
let last;
|
|
58
|
-
for (const step of session.steps) {
|
|
59
|
-
if (predicate(step))
|
|
60
|
-
last = step.ordinal;
|
|
61
|
-
}
|
|
62
|
-
return last;
|
|
63
|
-
}
|
|
64
|
-
function stepText(step) {
|
|
65
|
-
return `${step.label ?? ''} ${step.detail ?? ''}`.trim().toLowerCase();
|
|
66
|
-
}
|
|
67
|
-
function isShellStep(step) {
|
|
68
|
-
return SHELL_TOOLS.has(step.tool ?? step.lane);
|
|
69
|
-
}
|
|
70
|
-
function hasSignal(session, type, toolFilter) {
|
|
71
|
-
for (const step of session.steps) {
|
|
72
|
-
if (toolFilter && !toolFilter.has(step.tool ?? step.lane))
|
|
73
|
-
continue;
|
|
74
|
-
const text = stepText(step);
|
|
75
|
-
for (const signal of OUTCOME_SIGNALS) {
|
|
76
|
-
if (signal.type === type && signal.pattern.test(text))
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
function signalCounts(session) {
|
|
83
|
-
const counts = { merge: 0, test: 0, env: 0, revert: 0 };
|
|
84
|
-
for (const step of session.steps) {
|
|
85
|
-
const text = stepText(step);
|
|
86
|
-
for (const signal of OUTCOME_SIGNALS) {
|
|
87
|
-
if ((signal.type === 'merge' || signal.type === 'test') && !isShellStep(step))
|
|
88
|
-
continue;
|
|
89
|
-
if (signal.pattern.test(text))
|
|
90
|
-
counts[signal.type]++;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return counts;
|
|
94
|
-
}
|
|
95
|
-
function isFailureToAct(session) {
|
|
96
|
-
if (session.meta.tools === 0 && session.meta.turns <= 2)
|
|
97
|
-
return true;
|
|
98
|
-
const substantive = substantiveSteps(session);
|
|
99
|
-
return substantive.length === 0;
|
|
100
|
-
}
|
|
101
|
-
function reasonFailureToAct(session) {
|
|
102
|
-
if (session.meta.tools === 0 && session.meta.turns <= 2) {
|
|
103
|
-
return `no tool use (${session.meta.tools} tools, ${session.meta.turns} turns)`;
|
|
104
|
-
}
|
|
105
|
-
return 'no substantive tool steps';
|
|
106
|
-
}
|
|
107
|
-
function isOutOfOrder(session) {
|
|
108
|
-
const firstWrite = firstStepOrdinalOf(session, (s) => WRITE_EDIT_TOOLS.has(s.tool ?? s.lane));
|
|
109
|
-
if (firstWrite === undefined)
|
|
110
|
-
return false;
|
|
111
|
-
const firstReadPlan = firstStepOrdinalOf(session, (s) => READ_PLAN_TOOLS.has(s.tool ?? s.lane));
|
|
112
|
-
if (firstReadPlan === undefined)
|
|
113
|
-
return true;
|
|
114
|
-
return firstWrite < firstReadPlan;
|
|
115
|
-
}
|
|
116
|
-
function reasonOutOfOrder(session) {
|
|
117
|
-
const tool = session.steps.find((s) => WRITE_EDIT_TOOLS.has(s.tool ?? s.lane));
|
|
118
|
-
return `write/edit step ${tool?.tool ?? tool?.lane ?? ''} preceded any read/plan`;
|
|
119
|
-
}
|
|
120
|
-
function workSignature(step) {
|
|
121
|
-
const tool = step.tool ?? step.lane;
|
|
122
|
-
if (SHELL_TOOLS.has(tool) && step.program)
|
|
123
|
-
return `${tool}:${step.program}`;
|
|
124
|
-
return tool;
|
|
125
|
-
}
|
|
126
|
-
export function recoveredAfterErrors(session) {
|
|
127
|
-
const substantive = substantiveSteps(session);
|
|
128
|
-
if (substantive.length === 0)
|
|
129
|
-
return false;
|
|
130
|
-
const last = substantive[substantive.length - 1];
|
|
131
|
-
if (last.outcome === 'error')
|
|
132
|
-
return false;
|
|
133
|
-
const lastErrorOrdinal = lastStepOrdinalOf(session, (s) => s.outcome === 'error');
|
|
134
|
-
if (lastErrorOrdinal === undefined)
|
|
135
|
-
return true;
|
|
136
|
-
const failedSignatures = new Set();
|
|
137
|
-
for (const s of session.steps) {
|
|
138
|
-
if (s.outcome === 'error')
|
|
139
|
-
failedSignatures.add(workSignature(s));
|
|
140
|
-
}
|
|
141
|
-
return substantive.some((s) => s.ordinal > lastErrorOrdinal &&
|
|
142
|
-
s.outcome === 'ok' &&
|
|
143
|
-
!HUMAN_FACING_TOOLS.has(s.tool ?? s.lane) &&
|
|
144
|
-
failedSignatures.has(workSignature(s)));
|
|
145
|
-
}
|
|
146
|
-
function isFalseTermination(session) {
|
|
147
|
-
if (session.meta.outcome !== 'errored')
|
|
148
|
-
return false;
|
|
149
|
-
if (session.meta.errorCount === 0)
|
|
150
|
-
return false;
|
|
151
|
-
return !recoveredAfterErrors(session);
|
|
152
|
-
}
|
|
153
|
-
function reasonFalseTermination(session) {
|
|
154
|
-
const substantive = substantiveSteps(session);
|
|
155
|
-
if (substantive.length === 0)
|
|
156
|
-
return 'errored with no substantive steps';
|
|
157
|
-
const last = substantive[substantive.length - 1];
|
|
158
|
-
if (last.outcome === 'error') {
|
|
159
|
-
return `last substantive step ${last.tool ?? last.lane} ended in error`;
|
|
160
|
-
}
|
|
161
|
-
return 'errored with no successful recovery after the last error';
|
|
162
|
-
}
|
|
163
|
-
function isPrematureCompletion(session) {
|
|
164
|
-
if (session.meta.outcome !== 'completed')
|
|
165
|
-
return false;
|
|
166
|
-
const didWriteEdit = session.steps.some((s) => WRITE_EDIT_TOOLS.has(s.tool ?? s.lane));
|
|
167
|
-
if (!didWriteEdit)
|
|
168
|
-
return false;
|
|
169
|
-
const verified = session.steps.some((s) => {
|
|
170
|
-
if (!SHELL_TOOLS.has(s.tool ?? s.lane))
|
|
171
|
-
return false;
|
|
172
|
-
const text = stepText(s);
|
|
173
|
-
return /\b(bun test|npm test|yarn test|pnpm test|pytest|jest|vitest|cargo test|go test|tsc\s+--noEmit|lint|build|verify)\b/.test(text);
|
|
174
|
-
});
|
|
175
|
-
return !verified;
|
|
176
|
-
}
|
|
177
|
-
function reasonPrematureCompletion(_session) {
|
|
178
|
-
return 'engineering work completed without a test/build/lint verification step';
|
|
179
|
-
}
|
|
180
|
-
const PHENOTYPE_RULES = [
|
|
181
|
-
{ key: 'failure-to-act', score: isFailureToAct, reason: reasonFailureToAct },
|
|
182
|
-
{ key: 'out-of-order', score: isOutOfOrder, reason: reasonOutOfOrder },
|
|
183
|
-
{ key: 'false-termination', score: isFalseTermination, reason: reasonFalseTermination },
|
|
184
|
-
{ key: 'premature-completion', score: isPrematureCompletion, reason: reasonPrematureCompletion },
|
|
185
|
-
];
|
|
186
|
-
function isMerged(session) {
|
|
187
|
-
return session.meta.outcome === 'completed' && hasSignal(session, 'merge', SHELL_TOOLS);
|
|
188
|
-
}
|
|
189
|
-
function mergedReason(session) {
|
|
190
|
-
return 'explicit merge signal present and session completed';
|
|
191
|
-
}
|
|
192
|
-
function isTestsGreen(session) {
|
|
193
|
-
if (session.meta.outcome !== 'completed')
|
|
194
|
-
return false;
|
|
195
|
-
const testSteps = session.steps.filter((s) => {
|
|
196
|
-
if (!isShellStep(s))
|
|
197
|
-
return false;
|
|
198
|
-
const text = stepText(s);
|
|
199
|
-
return OUTCOME_SIGNALS.some((sig) => sig.type === 'test' && sig.pattern.test(text));
|
|
200
|
-
});
|
|
201
|
-
if (testSteps.length === 0)
|
|
202
|
-
return false;
|
|
203
|
-
const lastTest = testSteps[testSteps.length - 1];
|
|
204
|
-
if (lastTest.outcome === 'ok')
|
|
205
|
-
return true;
|
|
206
|
-
return session.meta.errorCount === 0;
|
|
207
|
-
}
|
|
208
|
-
function testsGreenConfidence(session) {
|
|
209
|
-
const testSteps = session.steps.filter((s) => {
|
|
210
|
-
if (!isShellStep(s))
|
|
211
|
-
return false;
|
|
212
|
-
const text = stepText(s);
|
|
213
|
-
return OUTCOME_SIGNALS.some((sig) => sig.type === 'test' && sig.pattern.test(text));
|
|
214
|
-
});
|
|
215
|
-
const lastTest = testSteps[testSteps.length - 1];
|
|
216
|
-
return lastTest?.outcome === 'ok' ? 'high' : 'medium';
|
|
217
|
-
}
|
|
218
|
-
function testsGreenReason(session) {
|
|
219
|
-
const confidence = testsGreenConfidence(session);
|
|
220
|
-
return confidence === 'high'
|
|
221
|
-
? 'last test/build/lint step returned ok'
|
|
222
|
-
: 'completed cleanly with test steps (step outcomes unavailable)';
|
|
223
|
-
}
|
|
224
|
-
function isHumanTakeover(session) {
|
|
225
|
-
const tools = session.steps.filter((s) => isToolStep(s));
|
|
226
|
-
if (tools.length === 0)
|
|
227
|
-
return false;
|
|
228
|
-
const last = tools[tools.length - 1];
|
|
229
|
-
return HUMAN_FACING_TOOLS.has(last.tool ?? last.lane);
|
|
230
|
-
}
|
|
231
|
-
function humanTakeoverReason(session) {
|
|
232
|
-
const tools = session.steps.filter((s) => isToolStep(s));
|
|
233
|
-
const last = tools[tools.length - 1];
|
|
234
|
-
return `final tool step is ${last.tool ?? last.lane}`;
|
|
235
|
-
}
|
|
236
|
-
function isInvalidEnv(session) {
|
|
237
|
-
const envSteps = session.steps.filter((s) => {
|
|
238
|
-
const text = stepText(s);
|
|
239
|
-
return OUTCOME_SIGNALS.some((sig) => sig.type === 'env' && sig.pattern.test(text));
|
|
240
|
-
});
|
|
241
|
-
const envErrors = envSteps.filter((s) => s.outcome === 'error').length;
|
|
242
|
-
const totalErrors = session.meta.errorCount;
|
|
243
|
-
if (totalErrors > 0 && envErrors >= 2 && envErrors / totalErrors >= 0.5)
|
|
244
|
-
return true;
|
|
245
|
-
if (session.meta.outcome === 'errored' && envSteps.length >= 3 && envErrors / envSteps.length >= 0.5)
|
|
246
|
-
return true;
|
|
247
|
-
const substantive = substantiveSteps(session);
|
|
248
|
-
const firstError = substantive.find((s) => s.outcome === 'error');
|
|
249
|
-
if (session.meta.outcome === 'errored' &&
|
|
250
|
-
firstError &&
|
|
251
|
-
OUTCOME_SIGNALS.some((sig) => sig.type === 'env' && sig.pattern.test(stepText(firstError)))) {
|
|
252
|
-
const firstErrorIndex = substantive.indexOf(firstError);
|
|
253
|
-
const after = substantive.slice(firstErrorIndex + 1);
|
|
254
|
-
const recovered = after.some((s) => s.outcome === 'ok' && !HUMAN_FACING_TOOLS.has(s.tool ?? s.lane));
|
|
255
|
-
if (!recovered)
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
function invalidEnvReason(session) {
|
|
261
|
-
const envSteps = session.steps.filter((s) => {
|
|
262
|
-
const text = stepText(s);
|
|
263
|
-
return OUTCOME_SIGNALS.some((sig) => sig.type === 'env' && sig.pattern.test(text));
|
|
264
|
-
});
|
|
265
|
-
const envErrors = envSteps.filter((s) => s.outcome === 'error').length;
|
|
266
|
-
const totalErrors = session.meta.errorCount;
|
|
267
|
-
if (totalErrors > 0 && envErrors >= 2 && envErrors / totalErrors >= 0.5) {
|
|
268
|
-
return `${envErrors}/${totalErrors} errors are environment/setup related`;
|
|
269
|
-
}
|
|
270
|
-
return 'environment/setup failures dominated the early session and blocked recovery';
|
|
271
|
-
}
|
|
272
|
-
function isAbandoned(session) {
|
|
273
|
-
if (session.meta.outcome !== 'errored')
|
|
274
|
-
return false;
|
|
275
|
-
const hasStall = session.gaps.some((g) => g.durationMs >= 120_000);
|
|
276
|
-
const substantive = substantiveSteps(session);
|
|
277
|
-
if (substantive.length === 0)
|
|
278
|
-
return hasStall || session.meta.errorCount > 0;
|
|
279
|
-
const lastErrorOrdinal = lastStepOrdinalOf(session, (s) => s.outcome === 'error');
|
|
280
|
-
if (lastErrorOrdinal === undefined)
|
|
281
|
-
return false;
|
|
282
|
-
const recoveryAfter = substantive.some((s) => s.ordinal > lastErrorOrdinal && s.outcome === 'ok' && !HUMAN_FACING_TOOLS.has(s.tool ?? s.lane));
|
|
283
|
-
return !recoveryAfter || hasStall;
|
|
284
|
-
}
|
|
285
|
-
function abandonedReason(session) {
|
|
286
|
-
const hasStall = session.gaps.some((g) => g.durationMs >= 120_000);
|
|
287
|
-
return hasStall ? 'errored with a long stall and no recovery' : 'errored with no successful recovery';
|
|
288
|
-
}
|
|
289
|
-
function isPartial(_session) {
|
|
290
|
-
return true;
|
|
291
|
-
}
|
|
292
|
-
function partialReason(session) {
|
|
293
|
-
const counts = signalCounts(session);
|
|
294
|
-
if (session.meta.outcome === 'completed') {
|
|
295
|
-
if (counts.test > 0)
|
|
296
|
-
return 'tests ran but final test step did not return ok';
|
|
297
|
-
if (counts.merge > 0)
|
|
298
|
-
return 'merge-related activity but no confirmed merge';
|
|
299
|
-
return 'completed without a landing or test signal';
|
|
300
|
-
}
|
|
301
|
-
return 'incomplete work with no higher-confidence outcome signal';
|
|
302
|
-
}
|
|
303
|
-
function ruleConfidence(rule, session) {
|
|
304
|
-
return typeof rule.confidence === 'function' ? rule.confidence(session) : rule.confidence;
|
|
305
|
-
}
|
|
306
|
-
const OUTCOME_RULES = [
|
|
307
|
-
{ key: 'merged', confidence: 'high', score: isMerged, reason: mergedReason },
|
|
308
|
-
{ key: 'tests-green', confidence: testsGreenConfidence, score: isTestsGreen, reason: testsGreenReason },
|
|
309
|
-
{ key: 'human-takeover', confidence: 'medium', score: isHumanTakeover, reason: humanTakeoverReason },
|
|
310
|
-
{ key: 'invalid-env', confidence: 'medium', score: isInvalidEnv, reason: invalidEnvReason },
|
|
311
|
-
{ key: 'abandoned', confidence: 'medium', score: isAbandoned, reason: abandonedReason },
|
|
312
|
-
{ key: 'partial', confidence: 'low', score: isPartial, reason: partialReason },
|
|
313
|
-
];
|
|
314
|
-
export function classifyPhenotype(session) {
|
|
315
|
-
return classifyPhenotypeDetailed(session).phenotype;
|
|
316
|
-
}
|
|
317
|
-
export function classifyPhenotypeDetailed(session) {
|
|
318
|
-
for (const rule of PHENOTYPE_RULES) {
|
|
319
|
-
if (rule.score(session)) {
|
|
320
|
-
return { phenotype: rule.key, reason: rule.reason(session) };
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
return { phenotype: null, reason: 'no failure phenotype matched' };
|
|
324
|
-
}
|
|
325
|
-
export function deriveOutcome(session) {
|
|
326
|
-
return deriveOutcomeDetailed(session).outcome;
|
|
327
|
-
}
|
|
328
|
-
export function deriveOutcomeDetailed(session) {
|
|
329
|
-
for (const rule of OUTCOME_RULES) {
|
|
330
|
-
if (rule.score(session)) {
|
|
331
|
-
return { outcome: rule.key, confidence: ruleConfidence(rule, session), reason: rule.reason(session) };
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
return { outcome: 'partial', confidence: 'low', reason: 'no outcome signal matched' };
|
|
335
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type CloudflareRequester } from '../cloudflare/provision.js';
|
|
2
|
-
interface ProvisionOptions {
|
|
3
|
-
request?: CloudflareRequester;
|
|
4
|
-
}
|
|
5
|
-
interface ProvisionTracesOptions extends ProvisionOptions {
|
|
6
|
-
apiToken: string;
|
|
7
|
-
accountId: string;
|
|
8
|
-
workerName: string;
|
|
9
|
-
bucketName: string;
|
|
10
|
-
phoenixIdBase: string;
|
|
11
|
-
domain?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function provisionTraces(opts: ProvisionTracesOptions): Promise<{
|
|
14
|
-
baseUrl: string;
|
|
15
|
-
}>;
|
|
16
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import { addCustomDomain, createBucket, deployWorker, enableWorkersDev, findZoneId, putWorkerSecret, } from '../cloudflare/provision.js';
|
|
3
|
-
import { DEFAULT_TRACES_DOMAIN } from './backend.js';
|
|
4
|
-
import { renderTracesWorkerScript } from './worker-template.js';
|
|
5
|
-
async function setPhoenixIdBaseSecret(apiToken, accountId, workerName, phoenixIdBase, opts = {}) {
|
|
6
|
-
const normalized = phoenixIdBase.replace(/\/+$/, '').trim();
|
|
7
|
-
if (!normalized)
|
|
8
|
-
throw new Error('PHOENIX_ID_BASE is required to verify trace requests.');
|
|
9
|
-
await putWorkerSecret(apiToken, accountId, workerName, 'PHOENIX_ID_BASE', normalized, opts);
|
|
10
|
-
}
|
|
11
|
-
export async function provisionTraces(opts) {
|
|
12
|
-
const domain = opts.domain ?? DEFAULT_TRACES_DOMAIN;
|
|
13
|
-
const requestOpts = opts.request ? { request: opts.request } : {};
|
|
14
|
-
await createBucket(opts.apiToken, opts.accountId, opts.bucketName, requestOpts);
|
|
15
|
-
await deployWorker(opts.apiToken, opts.accountId, opts.workerName, renderTracesWorkerScript(), opts.bucketName, requestOpts);
|
|
16
|
-
await putWorkerSecret(opts.apiToken, opts.accountId, opts.workerName, 'WRITE_TOKEN', randomBytes(32).toString('hex'), requestOpts);
|
|
17
|
-
await setPhoenixIdBaseSecret(opts.apiToken, opts.accountId, opts.workerName, opts.phoenixIdBase, requestOpts);
|
|
18
|
-
const workersDevSubdomain = await enableWorkersDev(opts.apiToken, opts.accountId, opts.workerName, requestOpts);
|
|
19
|
-
const zoneId = await findZoneId(opts.apiToken, domain, requestOpts);
|
|
20
|
-
if (!zoneId) {
|
|
21
|
-
return { baseUrl: `https://${opts.workerName}.${workersDevSubdomain}.workers.dev` };
|
|
22
|
-
}
|
|
23
|
-
await addCustomDomain(opts.apiToken, opts.accountId, opts.workerName, zoneId, domain, requestOpts);
|
|
24
|
-
return { baseUrl: `https://${domain}` };
|
|
25
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type BashCategory as ClassifierCategory } from '@phnx-labs/sessions-cli/reader';
|
|
2
|
-
import { type SessionTrajectory } from '@phnx-labs/sessions-cli/reader';
|
|
3
|
-
import type { SessionEvent } from '@phnx-labs/sessions-cli/reader';
|
|
4
|
-
import type { BashAction, BashCategory, SessionStepV2 } from './schema2.js';
|
|
5
|
-
import { activeMsFromTrajectory, type SessionDetail } from './sync.js';
|
|
6
|
-
export interface SessionDetailV2 {
|
|
7
|
-
schema: 2;
|
|
8
|
-
id: string;
|
|
9
|
-
meta: SessionDetail['meta'];
|
|
10
|
-
steps: SessionStepV2[];
|
|
11
|
-
gaps: SessionTrajectory['gaps'];
|
|
12
|
-
truncatedSteps: number;
|
|
13
|
-
whereItWentWrong: string | null;
|
|
14
|
-
surfacedToolFailures: Array<{
|
|
15
|
-
tool?: string;
|
|
16
|
-
label: string;
|
|
17
|
-
detail?: string;
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
20
|
-
export declare function unwrapShellExec(command: string): string;
|
|
21
|
-
export declare function mapBashCategory(cat: ClassifierCategory, argv: string[]): BashCategory;
|
|
22
|
-
export declare function buildBashActions(unwrapped: string): BashAction[];
|
|
23
|
-
interface BuildDetailV2Options {
|
|
24
|
-
redact?: boolean;
|
|
25
|
-
knownSecrets?: readonly string[];
|
|
26
|
-
}
|
|
27
|
-
export declare function buildSessionDetailV2(traj: SessionTrajectory, events: SessionEvent[], options?: BuildDetailV2Options): SessionDetailV2;
|
|
28
|
-
export { activeMsFromTrajectory };
|