@pasko70/pibo 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -183
- package/context/codex-base-prompt.md +148 -148
- package/context/compute-worker.md +23 -23
- package/context/pibo-compaction-prompt.md +100 -100
- package/context/pibo-native-tooling.md +18 -18
- package/context/pibo-system-prompt.md +77 -77
- package/dist/apps/chat/agent-store.js +82 -82
- package/dist/apps/chat/data/project-service.js +166 -166
- package/dist/apps/chat/data/read-state-service.js +18 -18
- package/dist/apps/chat/data/timeline-query-service.js +8 -8
- package/dist/apps/chat/model-catalog.js +5 -1
- package/dist/apps/chat/static-assets.js +853 -853
- package/dist/apps/chat/workflow-persistence.js +255 -255
- package/dist/apps/chat-ui/assets/{dist-7YaJd19a.js → dist-B2BEpL7n.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CiYeO8nN.js → dist-BAGS_xkV.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BIvPnn_C.js → dist-BAXNalar.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CjSI6y5z.js → dist-BwUvs6Ph.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-Ubstha8t.js → dist-C0zsJ8II.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-KXCMNKIL.js → dist-C3PnEkhb.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CVQU42Fn.js → dist-CYPL-B2Z.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BbNE72h8.js → dist-CiDSXgtg.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-D7TCkoFT.js → dist-DnACFKyO.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-ChSZNqKE.js → dist-ZB1-ui2y.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-8Noo5eCN.js → dist-vKlxFkTa.js} +1 -1
- package/dist/apps/chat-ui/assets/{index-CmxtUVG1.js → index-0x7tuTNX.js} +3 -3
- package/dist/apps/chat-ui/assets/{index-C25VYnyb.css → index-B-qaya1G.css} +1 -1
- package/dist/apps/chat-ui/index.html +18 -18
- package/dist/apps/chat-ui/manifest.webmanifest +25 -25
- package/dist/apps/chat-ui/sw.js +41 -41
- package/dist/apps/chat-vscode-web/index.html +12 -12
- package/dist/apps/cli-ui/cliSessionsCommand.js +23 -23
- package/dist/apps/context-files-ui/index.html +11 -11
- package/dist/apps/vscode-artifacts/latest.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.4.2.vsix +0 -0
- package/dist/bin/pibo.js +0 -0
- package/dist/bin/rg.js +0 -0
- package/dist/cli.js +35 -35
- package/dist/compute/cli.js +54 -54
- package/dist/core/runtime.js +2 -0
- package/dist/core/session-router.js +1 -0
- package/dist/cron/cli.js +15 -15
- package/dist/cron/store.js +49 -49
- package/dist/data/cli.js +23 -23
- package/dist/data/event-log.js +23 -23
- package/dist/data/message-store.js +20 -20
- package/dist/data/navigation-store.js +9 -9
- package/dist/data/observation-store.js +4 -4
- package/dist/data/payload-store.js +17 -17
- package/dist/data/schema.js +429 -429
- package/dist/data/session-store.js +4 -4
- package/dist/data/telemetry-queries.js +54 -54
- package/dist/data/telemetry.js +156 -156
- package/dist/debug/events.js +12 -12
- package/dist/debug/failures.js +6 -6
- package/dist/debug/index.js +207 -207
- package/dist/debug/messages.js +6 -6
- package/dist/debug/pty.js +124 -124
- package/dist/debug/session.js +29 -29
- package/dist/debug/tools.js +5 -5
- package/dist/debug/web-snapshot-browser-scripts.js +294 -294
- package/dist/debug/web-streaming-browser-library.js +925 -925
- package/dist/debug/web-streaming-browser-scripts.js +232 -232
- package/dist/debug/web-streaming-provider-telemetry.js +4 -4
- package/dist/debug/web.js +93 -93
- package/dist/gateway/cli.js +19 -19
- package/dist/mcp/config-command.js +53 -53
- package/dist/mcp/index.js +21 -21
- package/dist/mcp/registry.js +11 -11
- package/dist/pi-packages/cli.js +11 -11
- package/dist/plugins/context-files-store.js +110 -110
- package/dist/plugins/context-files.js +4 -4
- package/dist/providers/glm.js +59 -0
- package/dist/ralph/cli.js +18 -18
- package/dist/ralph/templates.js +140 -140
- package/dist/reliability/store.js +226 -226
- package/dist/sessions/pibo-data-store.js +16 -16
- package/dist/sessions/sqlite-store.js +53 -53
- package/dist/setup/cli.js +58 -58
- package/dist/tools/agent-browser-wrapper.js +80 -80
- package/dist/tools/browser-use-cdp.js +12 -12
- package/dist/tools/browser-use-wrapper.js +762 -762
- package/dist/tools/guides.js +455 -455
- package/dist/tools/index.js +99 -99
- package/dist/tools/runtime/node-worker-source.js +205 -205
- package/dist/tools/runtime/python-worker-source.js +177 -177
- package/dist/vscode/cli.js +9 -9
- package/dist/web-annotations/cdp.js +900 -900
- package/dist/web-annotations/store.js +96 -96
- package/docs/README.md +23 -23
- package/docs/ops/install-developer-host.md +112 -112
- package/docs/ops/install-user-host.md +96 -96
- package/docs/ops/upgrade-user-to-developer-host.md +69 -69
- package/docs/ops/vscode-extension-release.md +160 -160
- package/package.json +1 -1
- package/skills/builtin/pi-agent-harness/SKILL.md +319 -319
- package/skills/builtin/pi-agent-harness/agents/openai.yaml +4 -4
- package/skills/builtin/pibo-docker-system/SKILL.md +170 -170
- package/skills/builtin/pibo-spec-writing/SKILL.md +330 -330
- package/skills/builtin/prd/SKILL.md +143 -143
- package/skills/builtin/ralph-loop/SKILL.md +359 -359
- package/skills/builtin/ralph-prd-json/SKILL.md +123 -123
- package/skills/builtin/skill-creator/LICENSE.txt +201 -201
- package/skills/builtin/skill-creator/SKILL.md +513 -513
- package/skills/builtin/skill-creator/agents/analyzer.md +274 -274
- package/skills/builtin/skill-creator/agents/comparator.md +202 -202
- package/skills/builtin/skill-creator/agents/grader.md +223 -223
- package/skills/builtin/skill-creator/assets/eval_review.html +146 -146
- package/skills/builtin/skill-creator/eval-viewer/generate_review.py +471 -471
- package/skills/builtin/skill-creator/eval-viewer/viewer.html +1325 -1325
- package/skills/builtin/skill-creator/references/schemas.md +430 -430
- package/skills/builtin/skill-creator/scripts/aggregate_benchmark.py +401 -401
- package/skills/builtin/skill-creator/scripts/generate_report.py +326 -326
- package/skills/builtin/skill-creator/scripts/improve_description.py +247 -247
- package/skills/builtin/skill-creator/scripts/package_skill.py +136 -136
- package/skills/builtin/skill-creator/scripts/quick_validate.py +102 -102
- package/skills/builtin/skill-creator/scripts/run_eval.py +310 -310
- package/skills/builtin/skill-creator/scripts/run_loop.py +328 -328
- package/skills/builtin/skill-creator/scripts/utils.py +47 -47
- package/skills/builtin/web-annotations/SKILL.md +93 -93
- package/src/mcp/LICENSE.mcp-cli +21 -21
- package/dist/apps/vscode-artifacts/pibo-vscode-1.3.0.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.3.3.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.3.4.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.3.5.vsix +0 -0
- package/dist/core/shared-app.js +0 -17
- package/dist/data/final-app-space-cutover-migration.js +0 -728
- package/dist/data/shared-app-migration.js +0 -757
- package/dist/session-ui/ownerViewModel.js +0 -27
- package/dist/shared-app.js +0 -4
|
@@ -47,10 +47,10 @@ export class SessionStore {
|
|
|
47
47
|
"updated_at = excluded.updated_at",
|
|
48
48
|
"last_activity_at = excluded.last_activity_at",
|
|
49
49
|
];
|
|
50
|
-
this.db.prepare(`
|
|
51
|
-
INSERT INTO sessions (${baseColumns.join(", ")})
|
|
52
|
-
VALUES (${baseColumns.map(() => "?").join(", ")})
|
|
53
|
-
ON CONFLICT(id) DO UPDATE SET ${assignments.join(", ")}
|
|
50
|
+
this.db.prepare(`
|
|
51
|
+
INSERT INTO sessions (${baseColumns.join(", ")})
|
|
52
|
+
VALUES (${baseColumns.map(() => "?").join(", ")})
|
|
53
|
+
ON CONFLICT(id) DO UPDATE SET ${assignments.join(", ")}
|
|
54
54
|
`).run(...values);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -6,15 +6,15 @@ export function listTelemetrySessions(db, input = {}) {
|
|
|
6
6
|
const limit = normalizeTelemetryListLimit(input.limit);
|
|
7
7
|
const nowMs = Date.parse(input.now ?? new Date().toISOString());
|
|
8
8
|
const thresholdMs = input.thresholdMs ?? DEFAULT_STALE_THRESHOLD_MS;
|
|
9
|
-
const rows = db.prepare(`
|
|
10
|
-
SELECT t.*, counts.turn_count AS turn_count FROM telemetry_turns t
|
|
11
|
-
JOIN (
|
|
12
|
-
SELECT pibo_session_id, MAX(updated_at) AS max_updated, COUNT(*) AS turn_count
|
|
13
|
-
FROM telemetry_turns
|
|
14
|
-
GROUP BY pibo_session_id
|
|
15
|
-
) counts ON counts.pibo_session_id = t.pibo_session_id AND counts.max_updated = t.updated_at
|
|
16
|
-
ORDER BY t.updated_at DESC
|
|
17
|
-
LIMIT ?
|
|
9
|
+
const rows = db.prepare(`
|
|
10
|
+
SELECT t.*, counts.turn_count AS turn_count FROM telemetry_turns t
|
|
11
|
+
JOIN (
|
|
12
|
+
SELECT pibo_session_id, MAX(updated_at) AS max_updated, COUNT(*) AS turn_count
|
|
13
|
+
FROM telemetry_turns
|
|
14
|
+
GROUP BY pibo_session_id
|
|
15
|
+
) counts ON counts.pibo_session_id = t.pibo_session_id AND counts.max_updated = t.updated_at
|
|
16
|
+
ORDER BY t.updated_at DESC
|
|
17
|
+
LIMIT ?
|
|
18
18
|
`).all(limit);
|
|
19
19
|
return rows.map((row) => telemetrySessionSummaryFromTurnRow(db, row, Number(row.turn_count), nowMs, thresholdMs));
|
|
20
20
|
}
|
|
@@ -41,11 +41,11 @@ export function getTelemetryTurnTimeline(db, turnIdOrEventId, input = {}) {
|
|
|
41
41
|
if (!turn)
|
|
42
42
|
return undefined;
|
|
43
43
|
const limit = normalizeTelemetryListLimit(input.limit);
|
|
44
|
-
const phaseRows = db.prepare(`
|
|
45
|
-
SELECT * FROM telemetry_phases
|
|
46
|
-
WHERE turn_id = ?
|
|
47
|
-
ORDER BY started_at ASC, created_at ASC
|
|
48
|
-
LIMIT ?
|
|
44
|
+
const phaseRows = db.prepare(`
|
|
45
|
+
SELECT * FROM telemetry_phases
|
|
46
|
+
WHERE turn_id = ?
|
|
47
|
+
ORDER BY started_at ASC, created_at ASC
|
|
48
|
+
LIMIT ?
|
|
49
49
|
`).all(turn.turnId, limit);
|
|
50
50
|
const phases = phaseRows.map(phaseFromRow);
|
|
51
51
|
const providerRequests = listTelemetryProviderRequestsForTurn(db, turn.turnId, input);
|
|
@@ -61,11 +61,11 @@ export function getTelemetryTurnTimeline(db, turnIdOrEventId, input = {}) {
|
|
|
61
61
|
export function listTelemetryProviderEventsPage(db, providerRequestId, input = {}) {
|
|
62
62
|
const limit = normalizeTelemetryListLimit(input.limit);
|
|
63
63
|
const afterSequence = input.afterSequence ?? -1;
|
|
64
|
-
const rows = db.prepare(`
|
|
65
|
-
SELECT * FROM telemetry_provider_events
|
|
66
|
-
WHERE provider_request_id = ? AND sequence > ?
|
|
67
|
-
ORDER BY sequence ASC
|
|
68
|
-
LIMIT ?
|
|
64
|
+
const rows = db.prepare(`
|
|
65
|
+
SELECT * FROM telemetry_provider_events
|
|
66
|
+
WHERE provider_request_id = ? AND sequence > ?
|
|
67
|
+
ORDER BY sequence ASC
|
|
68
|
+
LIMIT ?
|
|
69
69
|
`).all(providerRequestId, afterSequence, limit + 1);
|
|
70
70
|
const hasMore = rows.length > limit;
|
|
71
71
|
const pageRows = rows.slice(0, limit).map(providerEventFromRow);
|
|
@@ -84,11 +84,11 @@ export function listTelemetryStaleWork(db, input = {}) {
|
|
|
84
84
|
const limit = normalizeTelemetryListLimit(input.limit);
|
|
85
85
|
const thresholdMs = input.thresholdMs ?? DEFAULT_STALE_THRESHOLD_MS;
|
|
86
86
|
const nowMs = Date.parse(input.now ?? new Date().toISOString());
|
|
87
|
-
const rows = db.prepare(`
|
|
88
|
-
SELECT * FROM telemetry_phases
|
|
89
|
-
WHERE status = 'open'
|
|
90
|
-
ORDER BY COALESCE(last_progress_at, started_at) ASC
|
|
91
|
-
LIMIT ?
|
|
87
|
+
const rows = db.prepare(`
|
|
88
|
+
SELECT * FROM telemetry_phases
|
|
89
|
+
WHERE status = 'open'
|
|
90
|
+
ORDER BY COALESCE(last_progress_at, started_at) ASC
|
|
91
|
+
LIMIT ?
|
|
92
92
|
`).all(MAX_TELEMETRY_LIST_LIMIT);
|
|
93
93
|
return rows.map(phaseFromRow)
|
|
94
94
|
.map((phase) => {
|
|
@@ -117,56 +117,56 @@ function getTelemetryTurn(db, turnId) {
|
|
|
117
117
|
}
|
|
118
118
|
function listTelemetryTurnsForSession(db, piboSessionId, input = {}) {
|
|
119
119
|
const limit = normalizeTelemetryListLimit(input.limit);
|
|
120
|
-
const rows = db.prepare(`
|
|
121
|
-
SELECT * FROM telemetry_turns
|
|
122
|
-
WHERE pibo_session_id = ?
|
|
123
|
-
ORDER BY updated_at DESC
|
|
124
|
-
LIMIT ?
|
|
120
|
+
const rows = db.prepare(`
|
|
121
|
+
SELECT * FROM telemetry_turns
|
|
122
|
+
WHERE pibo_session_id = ?
|
|
123
|
+
ORDER BY updated_at DESC
|
|
124
|
+
LIMIT ?
|
|
125
125
|
`).all(piboSessionId, limit);
|
|
126
126
|
return rows.map(turnFromRow);
|
|
127
127
|
}
|
|
128
128
|
function getTelemetryTurnByEventId(db, eventId) {
|
|
129
|
-
const row = db.prepare(`
|
|
130
|
-
SELECT * FROM telemetry_turns
|
|
131
|
-
WHERE event_id = ? OR input_event_id = ?
|
|
132
|
-
ORDER BY updated_at DESC
|
|
133
|
-
LIMIT 1
|
|
129
|
+
const row = db.prepare(`
|
|
130
|
+
SELECT * FROM telemetry_turns
|
|
131
|
+
WHERE event_id = ? OR input_event_id = ?
|
|
132
|
+
ORDER BY updated_at DESC
|
|
133
|
+
LIMIT 1
|
|
134
134
|
`).get(eventId, eventId);
|
|
135
135
|
return row ? turnFromRow(row) : undefined;
|
|
136
136
|
}
|
|
137
137
|
function getTelemetryActivePhaseForSession(db, piboSessionId, turnId) {
|
|
138
138
|
const row = turnId
|
|
139
|
-
? db.prepare(`
|
|
140
|
-
SELECT * FROM telemetry_phases
|
|
141
|
-
WHERE pibo_session_id = ? AND turn_id = ? AND status = 'open'
|
|
142
|
-
ORDER BY COALESCE(last_progress_at, started_at) DESC
|
|
143
|
-
LIMIT 1
|
|
139
|
+
? db.prepare(`
|
|
140
|
+
SELECT * FROM telemetry_phases
|
|
141
|
+
WHERE pibo_session_id = ? AND turn_id = ? AND status = 'open'
|
|
142
|
+
ORDER BY COALESCE(last_progress_at, started_at) DESC
|
|
143
|
+
LIMIT 1
|
|
144
144
|
`).get(piboSessionId, turnId)
|
|
145
|
-
: db.prepare(`
|
|
146
|
-
SELECT * FROM telemetry_phases
|
|
147
|
-
WHERE pibo_session_id = ? AND status = 'open'
|
|
148
|
-
ORDER BY COALESCE(last_progress_at, started_at) DESC
|
|
149
|
-
LIMIT 1
|
|
145
|
+
: db.prepare(`
|
|
146
|
+
SELECT * FROM telemetry_phases
|
|
147
|
+
WHERE pibo_session_id = ? AND status = 'open'
|
|
148
|
+
ORDER BY COALESCE(last_progress_at, started_at) DESC
|
|
149
|
+
LIMIT 1
|
|
150
150
|
`).get(piboSessionId);
|
|
151
151
|
return row ? phaseFromRow(row) : undefined;
|
|
152
152
|
}
|
|
153
153
|
function listTelemetryProviderRequestsForTurn(db, turnId, input = {}) {
|
|
154
154
|
const limit = normalizeTelemetryListLimit(input.limit);
|
|
155
|
-
const rows = db.prepare(`
|
|
156
|
-
SELECT * FROM telemetry_provider_requests
|
|
157
|
-
WHERE turn_id = ?
|
|
158
|
-
ORDER BY started_at ASC
|
|
159
|
-
LIMIT ?
|
|
155
|
+
const rows = db.prepare(`
|
|
156
|
+
SELECT * FROM telemetry_provider_requests
|
|
157
|
+
WHERE turn_id = ?
|
|
158
|
+
ORDER BY started_at ASC
|
|
159
|
+
LIMIT ?
|
|
160
160
|
`).all(turnId, limit);
|
|
161
161
|
return rows.map(providerRequestFromRow);
|
|
162
162
|
}
|
|
163
163
|
function listTelemetryToolCallsForTurn(db, turnId, input = {}) {
|
|
164
164
|
const limit = normalizeTelemetryListLimit(input.limit);
|
|
165
|
-
const rows = db.prepare(`
|
|
166
|
-
SELECT * FROM telemetry_tool_calls
|
|
167
|
-
WHERE turn_id = ?
|
|
168
|
-
ORDER BY COALESCE(args_started_at, created_at) ASC
|
|
169
|
-
LIMIT ?
|
|
165
|
+
const rows = db.prepare(`
|
|
166
|
+
SELECT * FROM telemetry_tool_calls
|
|
167
|
+
WHERE turn_id = ?
|
|
168
|
+
ORDER BY COALESCE(args_started_at, created_at) ASC
|
|
169
|
+
LIMIT ?
|
|
170
170
|
`).all(turnId, limit);
|
|
171
171
|
return rows.map(toolCallFromRow);
|
|
172
172
|
}
|
package/dist/data/telemetry.js
CHANGED
|
@@ -34,33 +34,33 @@ export class TelemetryStore {
|
|
|
34
34
|
const turnId = input.turnId ?? `turn_${randomUUID()}`;
|
|
35
35
|
const existing = input.turnId ? this.getTurn(input.turnId) : undefined;
|
|
36
36
|
const queuedAt = input.queuedAt ?? existing?.queuedAt ?? now;
|
|
37
|
-
this.db.prepare(`
|
|
38
|
-
INSERT INTO telemetry_turns (
|
|
39
|
-
turn_id, pibo_session_id, root_session_id, room_id, input_event_id, event_id, event_stream_id,
|
|
40
|
-
payload_ref, run_id, source, status, current_phase, queued_at, started_at, completed_at,
|
|
41
|
-
last_progress_at, queued_behind, queue_depth, summary, retention_class, created_at, updated_at, metadata_json
|
|
42
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
43
|
-
ON CONFLICT(turn_id) DO UPDATE SET
|
|
44
|
-
pibo_session_id = excluded.pibo_session_id,
|
|
45
|
-
root_session_id = COALESCE(excluded.root_session_id, telemetry_turns.root_session_id),
|
|
46
|
-
room_id = COALESCE(excluded.room_id, telemetry_turns.room_id),
|
|
47
|
-
input_event_id = COALESCE(excluded.input_event_id, telemetry_turns.input_event_id),
|
|
48
|
-
event_id = COALESCE(excluded.event_id, telemetry_turns.event_id),
|
|
49
|
-
event_stream_id = COALESCE(excluded.event_stream_id, telemetry_turns.event_stream_id),
|
|
50
|
-
payload_ref = COALESCE(excluded.payload_ref, telemetry_turns.payload_ref),
|
|
51
|
-
run_id = COALESCE(excluded.run_id, telemetry_turns.run_id),
|
|
52
|
-
source = excluded.source,
|
|
53
|
-
status = excluded.status,
|
|
54
|
-
current_phase = COALESCE(excluded.current_phase, telemetry_turns.current_phase),
|
|
55
|
-
started_at = COALESCE(excluded.started_at, telemetry_turns.started_at),
|
|
56
|
-
completed_at = COALESCE(excluded.completed_at, telemetry_turns.completed_at),
|
|
57
|
-
last_progress_at = COALESCE(excluded.last_progress_at, telemetry_turns.last_progress_at),
|
|
58
|
-
queued_behind = COALESCE(excluded.queued_behind, telemetry_turns.queued_behind),
|
|
59
|
-
queue_depth = COALESCE(excluded.queue_depth, telemetry_turns.queue_depth),
|
|
60
|
-
summary = COALESCE(excluded.summary, telemetry_turns.summary),
|
|
61
|
-
retention_class = excluded.retention_class,
|
|
62
|
-
updated_at = excluded.updated_at,
|
|
63
|
-
metadata_json = COALESCE(excluded.metadata_json, telemetry_turns.metadata_json)
|
|
37
|
+
this.db.prepare(`
|
|
38
|
+
INSERT INTO telemetry_turns (
|
|
39
|
+
turn_id, pibo_session_id, root_session_id, room_id, input_event_id, event_id, event_stream_id,
|
|
40
|
+
payload_ref, run_id, source, status, current_phase, queued_at, started_at, completed_at,
|
|
41
|
+
last_progress_at, queued_behind, queue_depth, summary, retention_class, created_at, updated_at, metadata_json
|
|
42
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
43
|
+
ON CONFLICT(turn_id) DO UPDATE SET
|
|
44
|
+
pibo_session_id = excluded.pibo_session_id,
|
|
45
|
+
root_session_id = COALESCE(excluded.root_session_id, telemetry_turns.root_session_id),
|
|
46
|
+
room_id = COALESCE(excluded.room_id, telemetry_turns.room_id),
|
|
47
|
+
input_event_id = COALESCE(excluded.input_event_id, telemetry_turns.input_event_id),
|
|
48
|
+
event_id = COALESCE(excluded.event_id, telemetry_turns.event_id),
|
|
49
|
+
event_stream_id = COALESCE(excluded.event_stream_id, telemetry_turns.event_stream_id),
|
|
50
|
+
payload_ref = COALESCE(excluded.payload_ref, telemetry_turns.payload_ref),
|
|
51
|
+
run_id = COALESCE(excluded.run_id, telemetry_turns.run_id),
|
|
52
|
+
source = excluded.source,
|
|
53
|
+
status = excluded.status,
|
|
54
|
+
current_phase = COALESCE(excluded.current_phase, telemetry_turns.current_phase),
|
|
55
|
+
started_at = COALESCE(excluded.started_at, telemetry_turns.started_at),
|
|
56
|
+
completed_at = COALESCE(excluded.completed_at, telemetry_turns.completed_at),
|
|
57
|
+
last_progress_at = COALESCE(excluded.last_progress_at, telemetry_turns.last_progress_at),
|
|
58
|
+
queued_behind = COALESCE(excluded.queued_behind, telemetry_turns.queued_behind),
|
|
59
|
+
queue_depth = COALESCE(excluded.queue_depth, telemetry_turns.queue_depth),
|
|
60
|
+
summary = COALESCE(excluded.summary, telemetry_turns.summary),
|
|
61
|
+
retention_class = excluded.retention_class,
|
|
62
|
+
updated_at = excluded.updated_at,
|
|
63
|
+
metadata_json = COALESCE(excluded.metadata_json, telemetry_turns.metadata_json)
|
|
64
64
|
`).run(turnId, input.piboSessionId, input.rootSessionId ?? null, input.roomId ?? null, input.inputEventId ?? null, input.eventId ?? null, input.eventStreamId ?? null, input.payloadRef ?? null, input.runId ?? null, input.source ?? existing?.source ?? "user", input.status ?? existing?.status ?? "queued", input.currentPhase ?? null, queuedAt, input.startedAt ?? null, input.completedAt ?? null, input.lastProgressAt ?? null, input.queuedBehind ?? null, input.queueDepth ?? null, input.summary ?? null, input.retentionClass ?? existing?.retentionClass ?? "diagnostic", input.createdAt ?? existing?.createdAt ?? now, now, JSON.stringify(input.metadata ?? existing?.metadata ?? {}));
|
|
65
65
|
return this.getTurn(turnId) ?? fail(`Failed to upsert telemetry turn ${turnId}`);
|
|
66
66
|
}
|
|
@@ -69,32 +69,32 @@ export class TelemetryStore {
|
|
|
69
69
|
const phaseId = input.phaseId ?? `phase_${randomUUID()}`;
|
|
70
70
|
const existing = input.phaseId ? this.getPhase(input.phaseId) : undefined;
|
|
71
71
|
const startedAt = input.startedAt ?? existing?.startedAt ?? now;
|
|
72
|
-
this.db.prepare(`
|
|
73
|
-
INSERT INTO telemetry_phases (
|
|
74
|
-
phase_id, turn_id, pibo_session_id, root_session_id, room_id, name, status, started_at, ended_at,
|
|
75
|
-
last_progress_at, duration_ms, provider_request_id, tool_call_id, event_stream_id, event_id,
|
|
76
|
-
payload_ref, run_id, counters_json, summary, retention_class, created_at, updated_at
|
|
77
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
78
|
-
ON CONFLICT(phase_id) DO UPDATE SET
|
|
79
|
-
turn_id = excluded.turn_id,
|
|
80
|
-
pibo_session_id = excluded.pibo_session_id,
|
|
81
|
-
root_session_id = COALESCE(excluded.root_session_id, telemetry_phases.root_session_id),
|
|
82
|
-
room_id = COALESCE(excluded.room_id, telemetry_phases.room_id),
|
|
83
|
-
name = excluded.name,
|
|
84
|
-
status = excluded.status,
|
|
85
|
-
ended_at = COALESCE(excluded.ended_at, telemetry_phases.ended_at),
|
|
86
|
-
last_progress_at = COALESCE(excluded.last_progress_at, telemetry_phases.last_progress_at),
|
|
87
|
-
duration_ms = COALESCE(excluded.duration_ms, telemetry_phases.duration_ms),
|
|
88
|
-
provider_request_id = COALESCE(excluded.provider_request_id, telemetry_phases.provider_request_id),
|
|
89
|
-
tool_call_id = COALESCE(excluded.tool_call_id, telemetry_phases.tool_call_id),
|
|
90
|
-
event_stream_id = COALESCE(excluded.event_stream_id, telemetry_phases.event_stream_id),
|
|
91
|
-
event_id = COALESCE(excluded.event_id, telemetry_phases.event_id),
|
|
92
|
-
payload_ref = COALESCE(excluded.payload_ref, telemetry_phases.payload_ref),
|
|
93
|
-
run_id = COALESCE(excluded.run_id, telemetry_phases.run_id),
|
|
94
|
-
counters_json = COALESCE(excluded.counters_json, telemetry_phases.counters_json),
|
|
95
|
-
summary = COALESCE(excluded.summary, telemetry_phases.summary),
|
|
96
|
-
retention_class = excluded.retention_class,
|
|
97
|
-
updated_at = excluded.updated_at
|
|
72
|
+
this.db.prepare(`
|
|
73
|
+
INSERT INTO telemetry_phases (
|
|
74
|
+
phase_id, turn_id, pibo_session_id, root_session_id, room_id, name, status, started_at, ended_at,
|
|
75
|
+
last_progress_at, duration_ms, provider_request_id, tool_call_id, event_stream_id, event_id,
|
|
76
|
+
payload_ref, run_id, counters_json, summary, retention_class, created_at, updated_at
|
|
77
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
78
|
+
ON CONFLICT(phase_id) DO UPDATE SET
|
|
79
|
+
turn_id = excluded.turn_id,
|
|
80
|
+
pibo_session_id = excluded.pibo_session_id,
|
|
81
|
+
root_session_id = COALESCE(excluded.root_session_id, telemetry_phases.root_session_id),
|
|
82
|
+
room_id = COALESCE(excluded.room_id, telemetry_phases.room_id),
|
|
83
|
+
name = excluded.name,
|
|
84
|
+
status = excluded.status,
|
|
85
|
+
ended_at = COALESCE(excluded.ended_at, telemetry_phases.ended_at),
|
|
86
|
+
last_progress_at = COALESCE(excluded.last_progress_at, telemetry_phases.last_progress_at),
|
|
87
|
+
duration_ms = COALESCE(excluded.duration_ms, telemetry_phases.duration_ms),
|
|
88
|
+
provider_request_id = COALESCE(excluded.provider_request_id, telemetry_phases.provider_request_id),
|
|
89
|
+
tool_call_id = COALESCE(excluded.tool_call_id, telemetry_phases.tool_call_id),
|
|
90
|
+
event_stream_id = COALESCE(excluded.event_stream_id, telemetry_phases.event_stream_id),
|
|
91
|
+
event_id = COALESCE(excluded.event_id, telemetry_phases.event_id),
|
|
92
|
+
payload_ref = COALESCE(excluded.payload_ref, telemetry_phases.payload_ref),
|
|
93
|
+
run_id = COALESCE(excluded.run_id, telemetry_phases.run_id),
|
|
94
|
+
counters_json = COALESCE(excluded.counters_json, telemetry_phases.counters_json),
|
|
95
|
+
summary = COALESCE(excluded.summary, telemetry_phases.summary),
|
|
96
|
+
retention_class = excluded.retention_class,
|
|
97
|
+
updated_at = excluded.updated_at
|
|
98
98
|
`).run(phaseId, input.turnId, input.piboSessionId, input.rootSessionId ?? null, input.roomId ?? null, input.name, input.status ?? existing?.status ?? "open", startedAt, input.endedAt ?? null, input.lastProgressAt ?? null, input.durationMs ?? null, input.providerRequestId ?? null, input.toolCallId ?? null, input.eventStreamId ?? null, input.eventId ?? null, input.payloadRef ?? null, input.runId ?? null, JSON.stringify(input.counters ?? existing?.counters ?? {}), input.summary ?? null, input.retentionClass ?? existing?.retentionClass ?? "diagnostic", input.createdAt ?? existing?.createdAt ?? now, now);
|
|
99
99
|
return this.getPhase(phaseId) ?? fail(`Failed to upsert telemetry phase ${phaseId}`);
|
|
100
100
|
}
|
|
@@ -123,48 +123,48 @@ export class TelemetryStore {
|
|
|
123
123
|
const providerRequestId = input.providerRequestId ?? `pr_${randomUUID()}`;
|
|
124
124
|
const existing = input.providerRequestId ? this.getProviderRequest(input.providerRequestId) : undefined;
|
|
125
125
|
const startedAt = input.startedAt ?? existing?.startedAt ?? now;
|
|
126
|
-
this.db.prepare(`
|
|
127
|
-
INSERT INTO telemetry_provider_requests (
|
|
128
|
-
provider_request_id, pibo_session_id, root_session_id, room_id, turn_id, phase_id, provider, api, model,
|
|
129
|
-
transport, service_tier, status, started_at, response_headers_at, first_byte_at, last_raw_event_at,
|
|
130
|
-
last_normalized_event_at, completed_at, http_status, upstream_response_id, raw_event_count,
|
|
131
|
-
normalized_event_count, parse_error_count, unknown_event_count, bytes_received, event_type_counts_json,
|
|
132
|
-
event_stream_id, event_id, payload_ref, error_category, error_message, capture_mode, retention_class,
|
|
133
|
-
created_at, updated_at
|
|
134
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
135
|
-
ON CONFLICT(provider_request_id) DO UPDATE SET
|
|
136
|
-
pibo_session_id = excluded.pibo_session_id,
|
|
137
|
-
root_session_id = COALESCE(excluded.root_session_id, telemetry_provider_requests.root_session_id),
|
|
138
|
-
room_id = COALESCE(excluded.room_id, telemetry_provider_requests.room_id),
|
|
139
|
-
turn_id = excluded.turn_id,
|
|
140
|
-
phase_id = COALESCE(excluded.phase_id, telemetry_provider_requests.phase_id),
|
|
141
|
-
provider = excluded.provider,
|
|
142
|
-
api = excluded.api,
|
|
143
|
-
model = excluded.model,
|
|
144
|
-
transport = excluded.transport,
|
|
145
|
-
service_tier = COALESCE(excluded.service_tier, telemetry_provider_requests.service_tier),
|
|
146
|
-
status = excluded.status,
|
|
147
|
-
response_headers_at = COALESCE(excluded.response_headers_at, telemetry_provider_requests.response_headers_at),
|
|
148
|
-
first_byte_at = COALESCE(excluded.first_byte_at, telemetry_provider_requests.first_byte_at),
|
|
149
|
-
last_raw_event_at = COALESCE(excluded.last_raw_event_at, telemetry_provider_requests.last_raw_event_at),
|
|
150
|
-
last_normalized_event_at = COALESCE(excluded.last_normalized_event_at, telemetry_provider_requests.last_normalized_event_at),
|
|
151
|
-
completed_at = COALESCE(excluded.completed_at, telemetry_provider_requests.completed_at),
|
|
152
|
-
http_status = COALESCE(excluded.http_status, telemetry_provider_requests.http_status),
|
|
153
|
-
upstream_response_id = COALESCE(excluded.upstream_response_id, telemetry_provider_requests.upstream_response_id),
|
|
154
|
-
raw_event_count = excluded.raw_event_count,
|
|
155
|
-
normalized_event_count = excluded.normalized_event_count,
|
|
156
|
-
parse_error_count = excluded.parse_error_count,
|
|
157
|
-
unknown_event_count = excluded.unknown_event_count,
|
|
158
|
-
bytes_received = COALESCE(excluded.bytes_received, telemetry_provider_requests.bytes_received),
|
|
159
|
-
event_type_counts_json = excluded.event_type_counts_json,
|
|
160
|
-
event_stream_id = COALESCE(excluded.event_stream_id, telemetry_provider_requests.event_stream_id),
|
|
161
|
-
event_id = COALESCE(excluded.event_id, telemetry_provider_requests.event_id),
|
|
162
|
-
payload_ref = COALESCE(excluded.payload_ref, telemetry_provider_requests.payload_ref),
|
|
163
|
-
error_category = COALESCE(excluded.error_category, telemetry_provider_requests.error_category),
|
|
164
|
-
error_message = COALESCE(excluded.error_message, telemetry_provider_requests.error_message),
|
|
165
|
-
capture_mode = excluded.capture_mode,
|
|
166
|
-
retention_class = excluded.retention_class,
|
|
167
|
-
updated_at = excluded.updated_at
|
|
126
|
+
this.db.prepare(`
|
|
127
|
+
INSERT INTO telemetry_provider_requests (
|
|
128
|
+
provider_request_id, pibo_session_id, root_session_id, room_id, turn_id, phase_id, provider, api, model,
|
|
129
|
+
transport, service_tier, status, started_at, response_headers_at, first_byte_at, last_raw_event_at,
|
|
130
|
+
last_normalized_event_at, completed_at, http_status, upstream_response_id, raw_event_count,
|
|
131
|
+
normalized_event_count, parse_error_count, unknown_event_count, bytes_received, event_type_counts_json,
|
|
132
|
+
event_stream_id, event_id, payload_ref, error_category, error_message, capture_mode, retention_class,
|
|
133
|
+
created_at, updated_at
|
|
134
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
135
|
+
ON CONFLICT(provider_request_id) DO UPDATE SET
|
|
136
|
+
pibo_session_id = excluded.pibo_session_id,
|
|
137
|
+
root_session_id = COALESCE(excluded.root_session_id, telemetry_provider_requests.root_session_id),
|
|
138
|
+
room_id = COALESCE(excluded.room_id, telemetry_provider_requests.room_id),
|
|
139
|
+
turn_id = excluded.turn_id,
|
|
140
|
+
phase_id = COALESCE(excluded.phase_id, telemetry_provider_requests.phase_id),
|
|
141
|
+
provider = excluded.provider,
|
|
142
|
+
api = excluded.api,
|
|
143
|
+
model = excluded.model,
|
|
144
|
+
transport = excluded.transport,
|
|
145
|
+
service_tier = COALESCE(excluded.service_tier, telemetry_provider_requests.service_tier),
|
|
146
|
+
status = excluded.status,
|
|
147
|
+
response_headers_at = COALESCE(excluded.response_headers_at, telemetry_provider_requests.response_headers_at),
|
|
148
|
+
first_byte_at = COALESCE(excluded.first_byte_at, telemetry_provider_requests.first_byte_at),
|
|
149
|
+
last_raw_event_at = COALESCE(excluded.last_raw_event_at, telemetry_provider_requests.last_raw_event_at),
|
|
150
|
+
last_normalized_event_at = COALESCE(excluded.last_normalized_event_at, telemetry_provider_requests.last_normalized_event_at),
|
|
151
|
+
completed_at = COALESCE(excluded.completed_at, telemetry_provider_requests.completed_at),
|
|
152
|
+
http_status = COALESCE(excluded.http_status, telemetry_provider_requests.http_status),
|
|
153
|
+
upstream_response_id = COALESCE(excluded.upstream_response_id, telemetry_provider_requests.upstream_response_id),
|
|
154
|
+
raw_event_count = excluded.raw_event_count,
|
|
155
|
+
normalized_event_count = excluded.normalized_event_count,
|
|
156
|
+
parse_error_count = excluded.parse_error_count,
|
|
157
|
+
unknown_event_count = excluded.unknown_event_count,
|
|
158
|
+
bytes_received = COALESCE(excluded.bytes_received, telemetry_provider_requests.bytes_received),
|
|
159
|
+
event_type_counts_json = excluded.event_type_counts_json,
|
|
160
|
+
event_stream_id = COALESCE(excluded.event_stream_id, telemetry_provider_requests.event_stream_id),
|
|
161
|
+
event_id = COALESCE(excluded.event_id, telemetry_provider_requests.event_id),
|
|
162
|
+
payload_ref = COALESCE(excluded.payload_ref, telemetry_provider_requests.payload_ref),
|
|
163
|
+
error_category = COALESCE(excluded.error_category, telemetry_provider_requests.error_category),
|
|
164
|
+
error_message = COALESCE(excluded.error_message, telemetry_provider_requests.error_message),
|
|
165
|
+
capture_mode = excluded.capture_mode,
|
|
166
|
+
retention_class = excluded.retention_class,
|
|
167
|
+
updated_at = excluded.updated_at
|
|
168
168
|
`).run(providerRequestId, input.piboSessionId, input.rootSessionId ?? null, input.roomId ?? null, input.turnId, input.phaseId ?? null, input.provider, input.api, input.model, input.transport ?? existing?.transport ?? "unknown", input.serviceTier ?? null, input.status ?? existing?.status ?? "started", startedAt, input.responseHeadersAt ?? null, input.firstByteAt ?? null, input.lastRawEventAt ?? null, input.lastNormalizedEventAt ?? null, input.completedAt ?? null, input.httpStatus ?? null, input.upstreamResponseId ?? null, input.rawEventCount ?? existing?.rawEventCount ?? 0, input.normalizedEventCount ?? existing?.normalizedEventCount ?? 0, input.parseErrorCount ?? existing?.parseErrorCount ?? 0, input.unknownEventCount ?? existing?.unknownEventCount ?? 0, input.bytesReceived ?? existing?.bytesReceived ?? null, JSON.stringify(input.eventTypeCounts ?? existing?.eventTypeCounts ?? {}), input.eventStreamId ?? null, input.eventId ?? null, input.payloadRef ?? null, input.errorCategory ?? null, input.errorMessage ?? null, input.captureMode ?? existing?.captureMode ?? "metadata_only", input.retentionClass ?? existing?.retentionClass ?? "diagnostic", input.createdAt ?? existing?.createdAt ?? now, now);
|
|
169
169
|
return this.getProviderRequest(providerRequestId) ?? fail(`Failed to upsert telemetry provider request ${providerRequestId}`);
|
|
170
170
|
}
|
|
@@ -176,32 +176,32 @@ export class TelemetryStore {
|
|
|
176
176
|
const sequence = input.sequence ?? existingEvent?.sequence ?? this.nextProviderEventSequence(input.providerRequestId);
|
|
177
177
|
const byteSize = input.byteSize ?? 0;
|
|
178
178
|
const parseStatus = input.parseStatus ?? "ok";
|
|
179
|
-
this.db.prepare(`
|
|
180
|
-
INSERT INTO telemetry_provider_events (
|
|
181
|
-
raw_event_id, provider_request_id, pibo_session_id, turn_id, phase_id, sequence, received_at,
|
|
182
|
-
event_type, byte_size, parse_status, normalized_type, event_stream_id, event_id, item_id,
|
|
183
|
-
tool_call_id, payload_ref, payload_preview_ref, safe_fields_json, retention_class, created_at, updated_at
|
|
184
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
185
|
-
ON CONFLICT(raw_event_id) DO UPDATE SET
|
|
186
|
-
provider_request_id = excluded.provider_request_id,
|
|
187
|
-
pibo_session_id = COALESCE(excluded.pibo_session_id, telemetry_provider_events.pibo_session_id),
|
|
188
|
-
turn_id = COALESCE(excluded.turn_id, telemetry_provider_events.turn_id),
|
|
189
|
-
phase_id = COALESCE(excluded.phase_id, telemetry_provider_events.phase_id),
|
|
190
|
-
sequence = excluded.sequence,
|
|
191
|
-
received_at = excluded.received_at,
|
|
192
|
-
event_type = excluded.event_type,
|
|
193
|
-
byte_size = excluded.byte_size,
|
|
194
|
-
parse_status = excluded.parse_status,
|
|
195
|
-
normalized_type = COALESCE(excluded.normalized_type, telemetry_provider_events.normalized_type),
|
|
196
|
-
event_stream_id = COALESCE(excluded.event_stream_id, telemetry_provider_events.event_stream_id),
|
|
197
|
-
event_id = COALESCE(excluded.event_id, telemetry_provider_events.event_id),
|
|
198
|
-
item_id = COALESCE(excluded.item_id, telemetry_provider_events.item_id),
|
|
199
|
-
tool_call_id = COALESCE(excluded.tool_call_id, telemetry_provider_events.tool_call_id),
|
|
200
|
-
payload_ref = COALESCE(excluded.payload_ref, telemetry_provider_events.payload_ref),
|
|
201
|
-
payload_preview_ref = COALESCE(excluded.payload_preview_ref, telemetry_provider_events.payload_preview_ref),
|
|
202
|
-
safe_fields_json = excluded.safe_fields_json,
|
|
203
|
-
retention_class = excluded.retention_class,
|
|
204
|
-
updated_at = excluded.updated_at
|
|
179
|
+
this.db.prepare(`
|
|
180
|
+
INSERT INTO telemetry_provider_events (
|
|
181
|
+
raw_event_id, provider_request_id, pibo_session_id, turn_id, phase_id, sequence, received_at,
|
|
182
|
+
event_type, byte_size, parse_status, normalized_type, event_stream_id, event_id, item_id,
|
|
183
|
+
tool_call_id, payload_ref, payload_preview_ref, safe_fields_json, retention_class, created_at, updated_at
|
|
184
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
185
|
+
ON CONFLICT(raw_event_id) DO UPDATE SET
|
|
186
|
+
provider_request_id = excluded.provider_request_id,
|
|
187
|
+
pibo_session_id = COALESCE(excluded.pibo_session_id, telemetry_provider_events.pibo_session_id),
|
|
188
|
+
turn_id = COALESCE(excluded.turn_id, telemetry_provider_events.turn_id),
|
|
189
|
+
phase_id = COALESCE(excluded.phase_id, telemetry_provider_events.phase_id),
|
|
190
|
+
sequence = excluded.sequence,
|
|
191
|
+
received_at = excluded.received_at,
|
|
192
|
+
event_type = excluded.event_type,
|
|
193
|
+
byte_size = excluded.byte_size,
|
|
194
|
+
parse_status = excluded.parse_status,
|
|
195
|
+
normalized_type = COALESCE(excluded.normalized_type, telemetry_provider_events.normalized_type),
|
|
196
|
+
event_stream_id = COALESCE(excluded.event_stream_id, telemetry_provider_events.event_stream_id),
|
|
197
|
+
event_id = COALESCE(excluded.event_id, telemetry_provider_events.event_id),
|
|
198
|
+
item_id = COALESCE(excluded.item_id, telemetry_provider_events.item_id),
|
|
199
|
+
tool_call_id = COALESCE(excluded.tool_call_id, telemetry_provider_events.tool_call_id),
|
|
200
|
+
payload_ref = COALESCE(excluded.payload_ref, telemetry_provider_events.payload_ref),
|
|
201
|
+
payload_preview_ref = COALESCE(excluded.payload_preview_ref, telemetry_provider_events.payload_preview_ref),
|
|
202
|
+
safe_fields_json = excluded.safe_fields_json,
|
|
203
|
+
retention_class = excluded.retention_class,
|
|
204
|
+
updated_at = excluded.updated_at
|
|
205
205
|
`).run(rawEventId, input.providerRequestId, input.piboSessionId ?? null, input.turnId ?? null, input.phaseId ?? null, sequence, receivedAt, input.eventType, byteSize, parseStatus, input.normalizedType ?? null, input.eventStreamId ?? null, input.eventId ?? null, input.itemId ?? null, input.toolCallId ?? null, input.payloadRef ?? null, input.payloadPreviewRef ?? null, JSON.stringify(input.safeFields ?? {}), input.retentionClass ?? "provider_event", input.createdAt ?? now, now);
|
|
206
206
|
const normalizedDelta = input.normalizedEventDelta ?? (input.normalizedType ? 1 : 0);
|
|
207
207
|
if (!existingEvent)
|
|
@@ -211,41 +211,41 @@ export class TelemetryStore {
|
|
|
211
211
|
upsertToolCall(input) {
|
|
212
212
|
const now = input.updatedAt ?? new Date().toISOString();
|
|
213
213
|
const existing = this.getToolCall(input.toolCallId);
|
|
214
|
-
this.db.prepare(`
|
|
215
|
-
INSERT INTO telemetry_tool_calls (
|
|
216
|
-
tool_call_id, pibo_session_id, root_session_id, room_id, turn_id, provider_request_id, provider_item_id,
|
|
217
|
-
output_index, tool_name, status, args_started_at, first_delta_at, last_delta_at, args_completed_at,
|
|
218
|
-
execution_started_at, execution_ended_at, duration_ms, args_bytes, parse_status, safe_arg_keys_json,
|
|
219
|
-
event_stream_id, event_id, payload_ref, run_id, error_category, error_message, retention_class, created_at, updated_at
|
|
220
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
221
|
-
ON CONFLICT(tool_call_id) DO UPDATE SET
|
|
222
|
-
pibo_session_id = excluded.pibo_session_id,
|
|
223
|
-
root_session_id = COALESCE(excluded.root_session_id, telemetry_tool_calls.root_session_id),
|
|
224
|
-
room_id = COALESCE(excluded.room_id, telemetry_tool_calls.room_id),
|
|
225
|
-
turn_id = excluded.turn_id,
|
|
226
|
-
provider_request_id = COALESCE(excluded.provider_request_id, telemetry_tool_calls.provider_request_id),
|
|
227
|
-
provider_item_id = COALESCE(excluded.provider_item_id, telemetry_tool_calls.provider_item_id),
|
|
228
|
-
output_index = COALESCE(excluded.output_index, telemetry_tool_calls.output_index),
|
|
229
|
-
tool_name = excluded.tool_name,
|
|
230
|
-
status = excluded.status,
|
|
231
|
-
args_started_at = COALESCE(excluded.args_started_at, telemetry_tool_calls.args_started_at),
|
|
232
|
-
first_delta_at = COALESCE(excluded.first_delta_at, telemetry_tool_calls.first_delta_at),
|
|
233
|
-
last_delta_at = COALESCE(excluded.last_delta_at, telemetry_tool_calls.last_delta_at),
|
|
234
|
-
args_completed_at = COALESCE(excluded.args_completed_at, telemetry_tool_calls.args_completed_at),
|
|
235
|
-
execution_started_at = COALESCE(excluded.execution_started_at, telemetry_tool_calls.execution_started_at),
|
|
236
|
-
execution_ended_at = COALESCE(excluded.execution_ended_at, telemetry_tool_calls.execution_ended_at),
|
|
237
|
-
duration_ms = COALESCE(excluded.duration_ms, telemetry_tool_calls.duration_ms),
|
|
238
|
-
args_bytes = excluded.args_bytes,
|
|
239
|
-
parse_status = excluded.parse_status,
|
|
240
|
-
safe_arg_keys_json = excluded.safe_arg_keys_json,
|
|
241
|
-
event_stream_id = COALESCE(excluded.event_stream_id, telemetry_tool_calls.event_stream_id),
|
|
242
|
-
event_id = COALESCE(excluded.event_id, telemetry_tool_calls.event_id),
|
|
243
|
-
payload_ref = COALESCE(excluded.payload_ref, telemetry_tool_calls.payload_ref),
|
|
244
|
-
run_id = COALESCE(excluded.run_id, telemetry_tool_calls.run_id),
|
|
245
|
-
error_category = COALESCE(excluded.error_category, telemetry_tool_calls.error_category),
|
|
246
|
-
error_message = COALESCE(excluded.error_message, telemetry_tool_calls.error_message),
|
|
247
|
-
retention_class = excluded.retention_class,
|
|
248
|
-
updated_at = excluded.updated_at
|
|
214
|
+
this.db.prepare(`
|
|
215
|
+
INSERT INTO telemetry_tool_calls (
|
|
216
|
+
tool_call_id, pibo_session_id, root_session_id, room_id, turn_id, provider_request_id, provider_item_id,
|
|
217
|
+
output_index, tool_name, status, args_started_at, first_delta_at, last_delta_at, args_completed_at,
|
|
218
|
+
execution_started_at, execution_ended_at, duration_ms, args_bytes, parse_status, safe_arg_keys_json,
|
|
219
|
+
event_stream_id, event_id, payload_ref, run_id, error_category, error_message, retention_class, created_at, updated_at
|
|
220
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
221
|
+
ON CONFLICT(tool_call_id) DO UPDATE SET
|
|
222
|
+
pibo_session_id = excluded.pibo_session_id,
|
|
223
|
+
root_session_id = COALESCE(excluded.root_session_id, telemetry_tool_calls.root_session_id),
|
|
224
|
+
room_id = COALESCE(excluded.room_id, telemetry_tool_calls.room_id),
|
|
225
|
+
turn_id = excluded.turn_id,
|
|
226
|
+
provider_request_id = COALESCE(excluded.provider_request_id, telemetry_tool_calls.provider_request_id),
|
|
227
|
+
provider_item_id = COALESCE(excluded.provider_item_id, telemetry_tool_calls.provider_item_id),
|
|
228
|
+
output_index = COALESCE(excluded.output_index, telemetry_tool_calls.output_index),
|
|
229
|
+
tool_name = excluded.tool_name,
|
|
230
|
+
status = excluded.status,
|
|
231
|
+
args_started_at = COALESCE(excluded.args_started_at, telemetry_tool_calls.args_started_at),
|
|
232
|
+
first_delta_at = COALESCE(excluded.first_delta_at, telemetry_tool_calls.first_delta_at),
|
|
233
|
+
last_delta_at = COALESCE(excluded.last_delta_at, telemetry_tool_calls.last_delta_at),
|
|
234
|
+
args_completed_at = COALESCE(excluded.args_completed_at, telemetry_tool_calls.args_completed_at),
|
|
235
|
+
execution_started_at = COALESCE(excluded.execution_started_at, telemetry_tool_calls.execution_started_at),
|
|
236
|
+
execution_ended_at = COALESCE(excluded.execution_ended_at, telemetry_tool_calls.execution_ended_at),
|
|
237
|
+
duration_ms = COALESCE(excluded.duration_ms, telemetry_tool_calls.duration_ms),
|
|
238
|
+
args_bytes = excluded.args_bytes,
|
|
239
|
+
parse_status = excluded.parse_status,
|
|
240
|
+
safe_arg_keys_json = excluded.safe_arg_keys_json,
|
|
241
|
+
event_stream_id = COALESCE(excluded.event_stream_id, telemetry_tool_calls.event_stream_id),
|
|
242
|
+
event_id = COALESCE(excluded.event_id, telemetry_tool_calls.event_id),
|
|
243
|
+
payload_ref = COALESCE(excluded.payload_ref, telemetry_tool_calls.payload_ref),
|
|
244
|
+
run_id = COALESCE(excluded.run_id, telemetry_tool_calls.run_id),
|
|
245
|
+
error_category = COALESCE(excluded.error_category, telemetry_tool_calls.error_category),
|
|
246
|
+
error_message = COALESCE(excluded.error_message, telemetry_tool_calls.error_message),
|
|
247
|
+
retention_class = excluded.retention_class,
|
|
248
|
+
updated_at = excluded.updated_at
|
|
249
249
|
`).run(input.toolCallId, input.piboSessionId, input.rootSessionId ?? null, input.roomId ?? null, input.turnId, input.providerRequestId ?? null, input.providerItemId ?? null, input.outputIndex ?? null, input.toolName, input.status ?? existing?.status ?? "args_started", input.argsStartedAt ?? null, input.firstDeltaAt ?? null, input.lastDeltaAt ?? null, input.argsCompletedAt ?? null, input.executionStartedAt ?? null, input.executionEndedAt ?? null, input.durationMs ?? null, input.argsBytes ?? existing?.argsBytes ?? 0, input.parseStatus ?? existing?.parseStatus ?? "empty", JSON.stringify(input.safeArgKeys ?? existing?.safeArgKeys ?? []), input.eventStreamId ?? null, input.eventId ?? null, input.payloadRef ?? null, input.runId ?? null, input.errorCategory ?? null, input.errorMessage ?? null, input.retentionClass ?? existing?.retentionClass ?? "diagnostic", input.createdAt ?? existing?.createdAt ?? now, now);
|
|
250
250
|
return this.getToolCall(input.toolCallId) ?? fail(`Failed to upsert telemetry tool call ${input.toolCallId}`);
|
|
251
251
|
}
|
package/dist/debug/events.js
CHANGED
|
@@ -17,12 +17,12 @@ export function inspectDebugEvents(piboSessionId, store, options = {}) {
|
|
|
17
17
|
values.push(options.type);
|
|
18
18
|
}
|
|
19
19
|
const rows = db
|
|
20
|
-
.prepare(`
|
|
21
|
-
SELECT stream_id, session_id, session_sequence, event_id, type, created_at, preview_text, attributes_json
|
|
22
|
-
FROM event_log
|
|
23
|
-
WHERE ${clauses.join(" AND ")}
|
|
24
|
-
ORDER BY stream_id DESC
|
|
25
|
-
LIMIT ?
|
|
20
|
+
.prepare(`
|
|
21
|
+
SELECT stream_id, session_id, session_sequence, event_id, type, created_at, preview_text, attributes_json
|
|
22
|
+
FROM event_log
|
|
23
|
+
WHERE ${clauses.join(" AND ")}
|
|
24
|
+
ORDER BY stream_id DESC
|
|
25
|
+
LIMIT ?
|
|
26
26
|
`)
|
|
27
27
|
.all(...values, limit + 1);
|
|
28
28
|
const limited = rows.length > limit;
|
|
@@ -167,16 +167,16 @@ function formatEventRow(row, fields) {
|
|
|
167
167
|
function findEventRow(db, piboSessionId, selector) {
|
|
168
168
|
const numeric = Number(selector);
|
|
169
169
|
if (Number.isInteger(numeric)) {
|
|
170
|
-
const row = db.prepare(`
|
|
171
|
-
SELECT stream_id, session_id, session_sequence, event_id, type, created_at, preview_text, attributes_json
|
|
172
|
-
FROM event_log WHERE session_id = ? AND stream_id = ?
|
|
170
|
+
const row = db.prepare(`
|
|
171
|
+
SELECT stream_id, session_id, session_sequence, event_id, type, created_at, preview_text, attributes_json
|
|
172
|
+
FROM event_log WHERE session_id = ? AND stream_id = ?
|
|
173
173
|
`).get(piboSessionId, numeric);
|
|
174
174
|
if (row)
|
|
175
175
|
return row;
|
|
176
176
|
}
|
|
177
|
-
return db.prepare(`
|
|
178
|
-
SELECT stream_id, session_id, session_sequence, event_id, type, created_at, preview_text, attributes_json
|
|
179
|
-
FROM event_log WHERE session_id = ? AND event_id = ? ORDER BY stream_id DESC LIMIT 1
|
|
177
|
+
return db.prepare(`
|
|
178
|
+
SELECT stream_id, session_id, session_sequence, event_id, type, created_at, preview_text, attributes_json
|
|
179
|
+
FROM event_log WHERE session_id = ? AND event_id = ? ORDER BY stream_id DESC LIMIT 1
|
|
180
180
|
`).get(piboSessionId, selector);
|
|
181
181
|
}
|
|
182
182
|
function buildListNextCommands(piboSessionId, rows) {
|
package/dist/debug/failures.js
CHANGED
|
@@ -64,12 +64,12 @@ function readToolFailures(piboSessionId, store, limit) {
|
|
|
64
64
|
try {
|
|
65
65
|
if (!tableExists(db, "event_log"))
|
|
66
66
|
return [];
|
|
67
|
-
const rows = db.prepare(`
|
|
68
|
-
SELECT stream_id, session_id, session_sequence, event_id, type, created_at, preview_text, attributes_json
|
|
69
|
-
FROM event_log
|
|
70
|
-
WHERE session_id = ? AND type = 'tool_execution_finished'
|
|
71
|
-
ORDER BY stream_id DESC
|
|
72
|
-
LIMIT ?
|
|
67
|
+
const rows = db.prepare(`
|
|
68
|
+
SELECT stream_id, session_id, session_sequence, event_id, type, created_at, preview_text, attributes_json
|
|
69
|
+
FROM event_log
|
|
70
|
+
WHERE session_id = ? AND type = 'tool_execution_finished'
|
|
71
|
+
ORDER BY stream_id DESC
|
|
72
|
+
LIMIT ?
|
|
73
73
|
`).all(piboSessionId, limit + 1);
|
|
74
74
|
return rows.flatMap((row) => {
|
|
75
75
|
const payload = eventPayload(row);
|