@pasko70/pibo 3.0.1 → 3.0.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 +20 -6
- package/dist/agent-runtime/context-build.js +26 -2
- package/dist/agent-runtime/routed-session.js +108 -9
- package/dist/agent-runtimes/codex-native/adapter.js +12 -0
- package/dist/agent-runtimes/codex-native/resource-delivery.js +35 -7
- package/dist/agent-runtimes/omp/adapter.js +3 -7
- package/dist/agent-runtimes/pi/adapter.js +5 -3
- package/dist/agent-runtimes/pi/routed-session.js +49 -8
- package/dist/agent-runtimes/pi/runtime.js +6 -0
- package/dist/apps/chat/agent-profiles.js +31 -2
- package/dist/apps/chat/agent-store.js +43 -3
- package/dist/apps/chat/chat-request-normalizers.js +31 -0
- package/dist/apps/chat/data/chat-data-mappers.js +61 -11
- package/dist/apps/chat/data/session-query-service.js +33 -10
- package/dist/apps/chat/data/timeline-query-service.js +60 -35
- package/dist/apps/chat/output-compactor.js +144 -21
- package/dist/apps/chat/output-event-policy.js +179 -2
- package/dist/apps/chat/stream.js +16 -7
- package/dist/apps/chat/trace-v2.js +1 -0
- package/dist/apps/chat/web-app.js +236 -64
- package/dist/apps/chat-ui/assets/{dist-BBDMeU5-.js → dist-B6GZgWSj.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-mqCviI-c.js → dist-BPotHecb.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-JnW4v8UE.js → dist-BzqQKeVO.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BDIATCQt.js → dist-CvaPTBTN.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-lRiLP9rr.js → dist-paagejNj.js} +1 -1
- package/dist/apps/chat-ui/assets/index-6JJV-eic.js +228 -0
- package/dist/apps/chat-ui/assets/index-CeL9JPP5.css +1 -0
- package/dist/apps/chat-ui/index.html +2 -2
- package/dist/apps/chat-vscode-web/assets/{index-Dtw2Z7jz.js → index-U-MSErGa.js} +4 -4
- package/dist/apps/chat-vscode-web/index.html +1 -1
- package/dist/apps/cli-ui/cliSessionsCommand.js +34 -8
- package/dist/cli-session/localSessionSource.js +153 -161
- package/dist/cli.js +7 -11
- package/dist/core/context-build.js +7 -16
- package/dist/core/output-persistence-retry.js +484 -0
- package/dist/core/output-render-sequence.js +331 -0
- package/dist/core/profiles.js +24 -0
- package/dist/core/provider-recovery.js +7 -1
- package/dist/core/session-model.js +37 -1
- package/dist/core/session-router.js +53 -13
- package/dist/data/ingest-service.js +91 -9
- package/dist/data/navigation-store.js +5 -5
- package/dist/data/schema.js +122 -2
- package/dist/data/session-store.js +3 -3
- package/dist/debug/index.js +44 -2
- package/dist/gateway/web.js +8 -8
- package/dist/local/client.js +3 -2
- package/dist/plugins/context-files-store.js +30 -0
- package/dist/plugins/context-files.js +52 -1
- package/dist/plugins/registry.js +2 -0
- package/dist/plugins/user-profile-resources.js +22 -0
- package/dist/reliability/store.js +246 -37
- package/dist/session-ui/terminalRows.js +6 -3
- package/dist/sessions/pibo-data-store.js +145 -0
- package/dist/sessions/store.js +42 -0
- package/dist/setup/cli.js +422 -6
- package/dist/setup/installation-profiles.js +464 -0
- package/dist/shared/deterministic-digest.js +94 -0
- package/dist/shared/trace-engine.js +54 -0
- package/dist/shared/trace-event-projection.js +124 -67
- package/dist/shared/trace-history.js +47 -12
- package/dist/shared/trace-live-reducer.js +23 -4
- package/dist/shared/trace-nodes.js +17 -28
- package/dist/shared/trace-order.js +41 -5
- package/dist/shared/trace-page-merge.js +44 -14
- package/dist/shared/trace-patch-nodes.js +2 -0
- package/dist/shared/trace-subagent-links.js +4 -1
- package/dist/shared/trace-tool-identity.js +15 -8
- package/dist/signals/projector.js +28 -6
- package/dist/subagents/tool.js +7 -3
- package/docs/ops/vscode-extension-release.md +9 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- package/dist/apps/chat-ui/assets/index-0XOOVxLP.js +0 -228
- package/dist/apps/chat-ui/assets/index-DV7_CgsC.css +0 -1
- package/dist/apps/vscode-artifacts/latest.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-ext-3.0.1.vsix +0 -0
|
@@ -100,6 +100,151 @@ export class PiboDataSessionStore {
|
|
|
100
100
|
`).run(updated.piSessionId || null, rootSessionId(updated), updated.parentId ?? null, updated.originId ?? null, updated.profile, updated.activeModel ? JSON.stringify(updated.activeModel) : null, updated.workspace ?? null, updated.title ?? "Untitled Session", JSON.stringify(updated.metadata ?? {}), updated.updatedAt, updated.updatedAt, id);
|
|
101
101
|
return this.get(id);
|
|
102
102
|
}
|
|
103
|
+
claimOutputRenderSequence(piboSessionId, minimum) {
|
|
104
|
+
return this.dataStore.transaction(() => {
|
|
105
|
+
const session = this.db.prepare("SELECT 1 AS present FROM sessions WHERE id = ? AND deleted_at IS NULL").get(piboSessionId);
|
|
106
|
+
if (!session)
|
|
107
|
+
return minimum;
|
|
108
|
+
const row = this.db.prepare("SELECT high_water FROM session_output_render_high_water WHERE pibo_session_id = ?").get(piboSessionId);
|
|
109
|
+
const current = Math.max(row?.high_water ?? 0, this.durableOutputRenderSequenceHighWater(piboSessionId));
|
|
110
|
+
const next = Math.max(minimum, current + 1);
|
|
111
|
+
this.db.prepare(`
|
|
112
|
+
INSERT INTO session_output_render_high_water (pibo_session_id, high_water, updated_at)
|
|
113
|
+
VALUES (?, ?, ?)
|
|
114
|
+
ON CONFLICT(pibo_session_id) DO UPDATE SET
|
|
115
|
+
high_water = MAX(session_output_render_high_water.high_water, excluded.high_water),
|
|
116
|
+
updated_at = CASE
|
|
117
|
+
WHEN excluded.high_water > session_output_render_high_water.high_water THEN excluded.updated_at
|
|
118
|
+
ELSE session_output_render_high_water.updated_at
|
|
119
|
+
END
|
|
120
|
+
`).run(piboSessionId, next, new Date().toISOString());
|
|
121
|
+
return next;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
durableOutputRenderSequenceHighWater(piboSessionId) {
|
|
125
|
+
const row = this.db.prepare(`
|
|
126
|
+
SELECT MAX(MAX(
|
|
127
|
+
COALESCE(CAST(json_extract(attributes_json, '$.renderSequence') AS INTEGER), 0),
|
|
128
|
+
COALESCE(session_sequence, 0)
|
|
129
|
+
)) AS high_water
|
|
130
|
+
FROM event_log
|
|
131
|
+
WHERE session_id = ?
|
|
132
|
+
`).get(piboSessionId);
|
|
133
|
+
const value = row?.high_water;
|
|
134
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : 0;
|
|
135
|
+
}
|
|
136
|
+
observeOutputRenderSequence(piboSessionId, sequence) {
|
|
137
|
+
this.dataStore.transaction(() => {
|
|
138
|
+
this.db.prepare(`
|
|
139
|
+
INSERT INTO session_output_render_high_water (pibo_session_id, high_water, updated_at)
|
|
140
|
+
SELECT id, ?, ? FROM sessions WHERE id = ? AND deleted_at IS NULL
|
|
141
|
+
ON CONFLICT(pibo_session_id) DO UPDATE SET
|
|
142
|
+
high_water = MAX(session_output_render_high_water.high_water, excluded.high_water),
|
|
143
|
+
updated_at = CASE
|
|
144
|
+
WHEN excluded.high_water > session_output_render_high_water.high_water THEN excluded.updated_at
|
|
145
|
+
ELSE session_output_render_high_water.updated_at
|
|
146
|
+
END
|
|
147
|
+
`).run(sequence, new Date().toISOString(), piboSessionId);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
claimOutputToolInvocationOrdinal(piboSessionId, eventId, toolCallId) {
|
|
151
|
+
return this.dataStore.transaction(() => {
|
|
152
|
+
const durable = this.db.prepare(`
|
|
153
|
+
SELECT MAX(COALESCE(CAST(json_extract(attributes_json, '$.toolInvocationOrdinal') AS INTEGER), 0)) AS maximum
|
|
154
|
+
FROM event_log
|
|
155
|
+
WHERE session_id = ? AND event_id = ? AND tool_call_id = ?
|
|
156
|
+
`).get(piboSessionId, eventId, toolCallId);
|
|
157
|
+
const minimumNextOrdinal = typeof durable.maximum === "number" && Number.isSafeInteger(durable.maximum)
|
|
158
|
+
? durable.maximum + 1
|
|
159
|
+
: 0;
|
|
160
|
+
const row = this.db.prepare(`
|
|
161
|
+
INSERT INTO session_tool_invocation_counters (
|
|
162
|
+
pibo_session_id, event_id, tool_call_id, next_ordinal, updated_at
|
|
163
|
+
) VALUES (?, ?, ?, ? + 1, ?)
|
|
164
|
+
ON CONFLICT(pibo_session_id, event_id, tool_call_id) DO UPDATE SET
|
|
165
|
+
next_ordinal = MAX(session_tool_invocation_counters.next_ordinal, ? ) + 1,
|
|
166
|
+
updated_at = excluded.updated_at
|
|
167
|
+
RETURNING next_ordinal - 1 AS ordinal
|
|
168
|
+
`).get(piboSessionId, eventId, toolCallId, minimumNextOrdinal, new Date().toISOString(), minimumNextOrdinal);
|
|
169
|
+
return row.ordinal;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
observeOutputToolInvocationOrdinal(piboSessionId, eventId, toolCallId, ordinal) {
|
|
173
|
+
this.dataStore.transaction(() => {
|
|
174
|
+
this.db.prepare(`
|
|
175
|
+
INSERT INTO session_tool_invocation_counters (
|
|
176
|
+
pibo_session_id, event_id, tool_call_id, next_ordinal, updated_at
|
|
177
|
+
) VALUES (?, ?, ?, ?, ?)
|
|
178
|
+
ON CONFLICT(pibo_session_id, event_id, tool_call_id) DO UPDATE SET
|
|
179
|
+
next_ordinal = MAX(session_tool_invocation_counters.next_ordinal, excluded.next_ordinal),
|
|
180
|
+
updated_at = CASE
|
|
181
|
+
WHEN excluded.next_ordinal > session_tool_invocation_counters.next_ordinal THEN excluded.updated_at
|
|
182
|
+
ELSE session_tool_invocation_counters.updated_at
|
|
183
|
+
END
|
|
184
|
+
`).run(piboSessionId, eventId, toolCallId, ordinal + 1, new Date().toISOString());
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
claimOrAttachOutputToolInvocation(input) {
|
|
188
|
+
return this.dataStore.transaction(() => {
|
|
189
|
+
const rows = this.db.prepare(`
|
|
190
|
+
SELECT invocation_ordinal, call_fingerprint, status, seen_call
|
|
191
|
+
FROM session_tool_invocations
|
|
192
|
+
WHERE pibo_session_id = ? AND event_id = ? AND tool_call_id = ?
|
|
193
|
+
ORDER BY invocation_ordinal DESC
|
|
194
|
+
`).all(input.piboSessionId, input.eventId, input.toolCallId);
|
|
195
|
+
const latestOpen = rows.find((row) => row.status === "open");
|
|
196
|
+
let ordinal;
|
|
197
|
+
if (input.eventType === "tool_call"
|
|
198
|
+
&& latestOpen
|
|
199
|
+
&& (latestOpen.seen_call === 0 || latestOpen.call_fingerprint === input.callFingerprint)) {
|
|
200
|
+
ordinal = latestOpen.invocation_ordinal;
|
|
201
|
+
}
|
|
202
|
+
else if (input.eventType !== "tool_call" && latestOpen) {
|
|
203
|
+
ordinal = latestOpen.invocation_ordinal;
|
|
204
|
+
}
|
|
205
|
+
else if (input.eventType !== "tool_call" && rows[0]) {
|
|
206
|
+
// A lifecycle replay after completion belongs to the last proven
|
|
207
|
+
// invocation. Only a new tool_call may cross a closed boundary.
|
|
208
|
+
ordinal = rows[0].invocation_ordinal;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
ordinal = this.claimOutputToolInvocationOrdinal(input.piboSessionId, input.eventId, input.toolCallId);
|
|
212
|
+
}
|
|
213
|
+
this.persistToolInvocationTransition(input, ordinal);
|
|
214
|
+
return ordinal;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
observeOutputToolInvocation(input) {
|
|
218
|
+
this.dataStore.transaction(() => {
|
|
219
|
+
this.observeOutputToolInvocationOrdinal(input.piboSessionId, input.eventId, input.toolCallId, input.ordinal);
|
|
220
|
+
this.persistToolInvocationTransition(input, input.ordinal);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
persistToolInvocationTransition(input, ordinal) {
|
|
224
|
+
const timestamp = new Date().toISOString();
|
|
225
|
+
const seenCall = input.eventType === "tool_call" ? 1 : 0;
|
|
226
|
+
const seenStarted = input.eventType === "tool_execution_started" ? 1 : 0;
|
|
227
|
+
const seenUpdated = input.eventType === "tool_execution_updated" ? 1 : 0;
|
|
228
|
+
const seenFinished = input.eventType === "tool_execution_finished" ? 1 : 0;
|
|
229
|
+
this.db.prepare(`
|
|
230
|
+
INSERT INTO session_tool_invocations (
|
|
231
|
+
pibo_session_id, event_id, tool_call_id, invocation_ordinal,
|
|
232
|
+
call_fingerprint, status, seen_call, seen_started, seen_updated, seen_finished,
|
|
233
|
+
created_at, updated_at
|
|
234
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
235
|
+
ON CONFLICT(pibo_session_id, event_id, tool_call_id, invocation_ordinal) DO UPDATE SET
|
|
236
|
+
call_fingerprint = COALESCE(session_tool_invocations.call_fingerprint, excluded.call_fingerprint),
|
|
237
|
+
status = CASE
|
|
238
|
+
WHEN session_tool_invocations.status = 'closed' OR excluded.status = 'closed' THEN 'closed'
|
|
239
|
+
ELSE 'open'
|
|
240
|
+
END,
|
|
241
|
+
seen_call = MAX(session_tool_invocations.seen_call, excluded.seen_call),
|
|
242
|
+
seen_started = MAX(session_tool_invocations.seen_started, excluded.seen_started),
|
|
243
|
+
seen_updated = MAX(session_tool_invocations.seen_updated, excluded.seen_updated),
|
|
244
|
+
seen_finished = MAX(session_tool_invocations.seen_finished, excluded.seen_finished),
|
|
245
|
+
updated_at = excluded.updated_at
|
|
246
|
+
`).run(input.piboSessionId, input.eventId, input.toolCallId, ordinal, input.callFingerprint ?? null, seenFinished ? "closed" : "open", seenCall, seenStarted, seenUpdated, seenFinished, timestamp, timestamp);
|
|
247
|
+
}
|
|
103
248
|
delete(id) {
|
|
104
249
|
const result = this.db.prepare("DELETE FROM sessions WHERE id = ?").run(id);
|
|
105
250
|
return Number(result.changes ?? 0) > 0;
|
package/dist/sessions/store.js
CHANGED
|
@@ -48,6 +48,8 @@ export class InMemoryPiboSessionStore {
|
|
|
48
48
|
byId = new Map();
|
|
49
49
|
byPiSessionId = new Map();
|
|
50
50
|
byNativeSession = new Map();
|
|
51
|
+
outputRenderHighWater = new Map();
|
|
52
|
+
outputToolInvocationNextOrdinal = new Map();
|
|
51
53
|
get(id) {
|
|
52
54
|
return this.byId.get(id);
|
|
53
55
|
}
|
|
@@ -101,6 +103,33 @@ export class InMemoryPiboSessionStore {
|
|
|
101
103
|
this.set(updated, existing.piSessionId, existing.runtimeBinding);
|
|
102
104
|
return updated;
|
|
103
105
|
}
|
|
106
|
+
claimOutputRenderSequence(piboSessionId, minimum) {
|
|
107
|
+
const session = this.byId.get(piboSessionId);
|
|
108
|
+
if (!session)
|
|
109
|
+
return minimum;
|
|
110
|
+
const current = Math.max(this.outputRenderHighWater.get(piboSessionId) ?? 0, outputRenderSequenceHighWater(session.metadata));
|
|
111
|
+
const next = Math.max(minimum, current + 1);
|
|
112
|
+
this.outputRenderHighWater.set(piboSessionId, next);
|
|
113
|
+
return next;
|
|
114
|
+
}
|
|
115
|
+
observeOutputRenderSequence(piboSessionId, sequence) {
|
|
116
|
+
const session = this.byId.get(piboSessionId);
|
|
117
|
+
if (!session)
|
|
118
|
+
return;
|
|
119
|
+
const current = Math.max(this.outputRenderHighWater.get(piboSessionId) ?? 0, outputRenderSequenceHighWater(session.metadata));
|
|
120
|
+
if (sequence > current)
|
|
121
|
+
this.outputRenderHighWater.set(piboSessionId, sequence);
|
|
122
|
+
}
|
|
123
|
+
claimOutputToolInvocationOrdinal(piboSessionId, eventId, toolCallId) {
|
|
124
|
+
const key = outputToolInvocationCounterKey(piboSessionId, eventId, toolCallId);
|
|
125
|
+
const ordinal = this.outputToolInvocationNextOrdinal.get(key) ?? 0;
|
|
126
|
+
this.outputToolInvocationNextOrdinal.set(key, ordinal + 1);
|
|
127
|
+
return ordinal;
|
|
128
|
+
}
|
|
129
|
+
observeOutputToolInvocationOrdinal(piboSessionId, eventId, toolCallId, ordinal) {
|
|
130
|
+
const key = outputToolInvocationCounterKey(piboSessionId, eventId, toolCallId);
|
|
131
|
+
this.outputToolInvocationNextOrdinal.set(key, Math.max(this.outputToolInvocationNextOrdinal.get(key) ?? 0, ordinal + 1));
|
|
132
|
+
}
|
|
104
133
|
getRuntimeBinding(id) {
|
|
105
134
|
const session = this.byId.get(id);
|
|
106
135
|
if (!session)
|
|
@@ -133,6 +162,12 @@ export class InMemoryPiboSessionStore {
|
|
|
133
162
|
const nativeKey = runtimeBindingNativeKey(existing.runtimeBinding);
|
|
134
163
|
if (nativeKey)
|
|
135
164
|
this.byNativeSession.delete(nativeKey);
|
|
165
|
+
this.outputRenderHighWater.delete(id);
|
|
166
|
+
const counterPrefix = `${JSON.stringify([id]).slice(0, -1)},`;
|
|
167
|
+
for (const key of this.outputToolInvocationNextOrdinal.keys()) {
|
|
168
|
+
if (key.startsWith(counterPrefix))
|
|
169
|
+
this.outputToolInvocationNextOrdinal.delete(key);
|
|
170
|
+
}
|
|
136
171
|
return true;
|
|
137
172
|
}
|
|
138
173
|
find(input) {
|
|
@@ -165,6 +200,13 @@ export class InMemoryPiboSessionStore {
|
|
|
165
200
|
return sessions.sort((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
166
201
|
}
|
|
167
202
|
}
|
|
203
|
+
function outputRenderSequenceHighWater(metadata) {
|
|
204
|
+
const value = metadata?.outputRenderSequenceHighWater;
|
|
205
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : 0;
|
|
206
|
+
}
|
|
207
|
+
function outputToolInvocationCounterKey(piboSessionId, eventId, toolCallId) {
|
|
208
|
+
return JSON.stringify([piboSessionId, eventId, toolCallId]);
|
|
209
|
+
}
|
|
168
210
|
export function matchesFindInput(session, input) {
|
|
169
211
|
if (input.ids && !input.ids.includes(session.id))
|
|
170
212
|
return false;
|