@pasko70/pibo 1.8.0 → 1.8.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/dist/apps/chat/workflow-manual-trigger-runtime.js +13 -4
- package/dist/core/compaction-prompt.js +87 -52
- package/dist/core/provider-recovery.js +64 -0
- package/dist/core/provider-telemetry.js +40 -2
- package/dist/core/routed-session.js +97 -19
- package/dist/core/runtime-telemetry.js +84 -46
- package/dist/core/runtime.js +5 -3
- package/dist/core/session-errors.js +14 -1
- package/dist/core/session-router.js +74 -22
- package/dist/data/telemetry-writer.js +114 -0
- package/dist/data/telemetry.js +14 -0
- package/dist/gateway/request.js +17 -8
- package/dist/ralph/service.js +3 -5
- package/package.json +1 -1
package/dist/data/telemetry.js
CHANGED
|
@@ -8,6 +8,20 @@ export class TelemetryStore {
|
|
|
8
8
|
constructor(db) {
|
|
9
9
|
this.db = db;
|
|
10
10
|
}
|
|
11
|
+
transaction(action) {
|
|
12
|
+
if (this.db.isTransaction)
|
|
13
|
+
return action();
|
|
14
|
+
this.db.exec("BEGIN IMMEDIATE");
|
|
15
|
+
try {
|
|
16
|
+
const result = action();
|
|
17
|
+
this.db.exec("COMMIT");
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
this.db.exec("ROLLBACK");
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
11
25
|
listSessions(input = {}) {
|
|
12
26
|
return listTelemetrySessions(this.db, input);
|
|
13
27
|
}
|
package/dist/gateway/request.js
CHANGED
|
@@ -75,6 +75,7 @@ export async function sendGatewayMessageAndWaitForReply(event, options = {}) {
|
|
|
75
75
|
let settled = false;
|
|
76
76
|
let response;
|
|
77
77
|
let reply;
|
|
78
|
+
let messageFinished = false;
|
|
78
79
|
const timeout = setTimeout(() => {
|
|
79
80
|
finish(new Error(`Timed out waiting for assistant reply from session "${event.piboSessionId}"`));
|
|
80
81
|
}, timeoutMs);
|
|
@@ -91,14 +92,21 @@ export async function sendGatewayMessageAndWaitForReply(event, options = {}) {
|
|
|
91
92
|
resolve(result);
|
|
92
93
|
}
|
|
93
94
|
};
|
|
95
|
+
const finishCompletedReply = () => {
|
|
96
|
+
if (!response?.ok || !messageFinished)
|
|
97
|
+
return;
|
|
98
|
+
finish(reply
|
|
99
|
+
? { response, reply }
|
|
100
|
+
: new Error(`Session "${eventWithId.piboSessionId}" finished without an assistant reply`));
|
|
101
|
+
};
|
|
94
102
|
const handleFrame = (frame) => {
|
|
95
103
|
if (frame.type === "res" && frame.id === id) {
|
|
96
104
|
response = frame;
|
|
97
105
|
if (!frame.ok) {
|
|
98
106
|
finish(new Error(frame.error?.message ?? "Gateway rejected the message"));
|
|
99
107
|
}
|
|
100
|
-
else
|
|
101
|
-
|
|
108
|
+
else {
|
|
109
|
+
finishCompletedReply();
|
|
102
110
|
}
|
|
103
111
|
return;
|
|
104
112
|
}
|
|
@@ -111,13 +119,14 @@ export async function sendGatewayMessageAndWaitForReply(event, options = {}) {
|
|
|
111
119
|
finish(new Error(output.error));
|
|
112
120
|
return;
|
|
113
121
|
}
|
|
114
|
-
if (output.
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
if (output.piboSessionId !== eventWithId.piboSessionId || !("eventId" in output) || output.eventId !== eventWithId.id)
|
|
123
|
+
return;
|
|
124
|
+
if (output.type === "assistant_message") {
|
|
117
125
|
reply = output;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
126
|
+
}
|
|
127
|
+
else if (output.type === "message_finished") {
|
|
128
|
+
messageFinished = true;
|
|
129
|
+
finishCompletedReply();
|
|
121
130
|
}
|
|
122
131
|
};
|
|
123
132
|
socket.once("connect", () => {
|
package/dist/ralph/service.js
CHANGED
|
@@ -252,7 +252,7 @@ export class PiboRalphService {
|
|
|
252
252
|
},
|
|
253
253
|
});
|
|
254
254
|
this.store.attachRunSession(job.id, run.id, session.id);
|
|
255
|
-
const finalAnswer = await this.emitMessageAndWait(session.id, buildRalphPrompt(job)
|
|
255
|
+
const finalAnswer = await this.emitMessageAndWait(session.id, buildRalphPrompt(job));
|
|
256
256
|
return { piboSessionId: session.id, finalAnswer };
|
|
257
257
|
}
|
|
258
258
|
resolveTarget(job) { if (job.target.kind === 'room') {
|
|
@@ -263,7 +263,7 @@ export class PiboRalphService {
|
|
|
263
263
|
throw new Error('Target room is archived');
|
|
264
264
|
return { roomId: room.id, workspace: room.workspace ?? getDefaultPiboWorkspace() };
|
|
265
265
|
} const room = this.roomService.ensureDefaultRoom({ name: 'Shared Chat' }); return { roomId: room.id, workspace: room.workspace ?? getDefaultPiboWorkspace() }; }
|
|
266
|
-
async emitMessageAndWait(piboSessionId, text
|
|
266
|
+
async emitMessageAndWait(piboSessionId, text) {
|
|
267
267
|
const eventId = `ralph_msg_${randomUUID()}`;
|
|
268
268
|
return await new Promise((resolve, reject) => {
|
|
269
269
|
let settled = false;
|
|
@@ -308,9 +308,7 @@ export class PiboRalphService {
|
|
|
308
308
|
finish(lastSessionError ? new Error(lastSessionError) : undefined);
|
|
309
309
|
if (event.type === 'session_error') {
|
|
310
310
|
lastSessionError = event.error;
|
|
311
|
-
|
|
312
|
-
if (!providerAttempt || options.isCancelled?.())
|
|
313
|
-
finish(new Error(event.error));
|
|
311
|
+
finish(new Error(event.error));
|
|
314
312
|
}
|
|
315
313
|
});
|
|
316
314
|
this.options.context.emit({ type: 'message', piboSessionId, id: eventId, source: 'service', text }).catch((error) => finish(error instanceof Error ? error : new Error(String(error))));
|