repoburg 1.3.229 → 1.3.231
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/agent-pane/backend/dist/index.js +212 -123
- package/agent-pane/backend/dist/server.js +212 -123
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/daemon/dist/recorder/collector.js +6 -3
- package/daemon/dist/recorder/recorder.spec.js +2 -0
- package/package.json +1 -1
- package/recorder/dist/recorder.js +1 -1
|
@@ -43171,12 +43171,12 @@ Agent responded: "${truncatedResponse}"`;
|
|
|
43171
43171
|
});
|
|
43172
43172
|
const title = await titlePromise;
|
|
43173
43173
|
clearTimeout(timeout);
|
|
43174
|
-
const
|
|
43175
|
-
if (
|
|
43174
|
+
const cleanTitle2 = title.trim().replace(/^["']|["']$/g, "").slice(0, 100);
|
|
43175
|
+
if (cleanTitle2) {
|
|
43176
43176
|
const db2 = getDb();
|
|
43177
43177
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
43178
|
-
db2.prepare("UPDATE sessions SET title = ?, updated_at = ? WHERE id = ?").run(
|
|
43179
|
-
broadcast("session:title", { sessionId, title:
|
|
43178
|
+
db2.prepare("UPDATE sessions SET title = ?, updated_at = ? WHERE id = ?").run(cleanTitle2, now, sessionId);
|
|
43179
|
+
broadcast("session:title", { sessionId, title: cleanTitle2 });
|
|
43180
43180
|
}
|
|
43181
43181
|
} catch {
|
|
43182
43182
|
} finally {
|
|
@@ -44223,12 +44223,12 @@ Agent responded: "${truncatedResponse}"`;
|
|
|
44223
44223
|
}
|
|
44224
44224
|
}
|
|
44225
44225
|
}
|
|
44226
|
-
const
|
|
44227
|
-
if (
|
|
44226
|
+
const cleanTitle2 = titleResponse.trim().replace(/^["']|["']$/g, "").slice(0, 100);
|
|
44227
|
+
if (cleanTitle2) {
|
|
44228
44228
|
const db2 = getDb();
|
|
44229
44229
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
44230
|
-
db2.prepare("UPDATE sessions SET title = ?, updated_at = ? WHERE id = ?").run(
|
|
44231
|
-
broadcast("session:title", { sessionId, title:
|
|
44230
|
+
db2.prepare("UPDATE sessions SET title = ?, updated_at = ? WHERE id = ?").run(cleanTitle2, now, sessionId);
|
|
44231
|
+
broadcast("session:title", { sessionId, title: cleanTitle2 });
|
|
44232
44232
|
}
|
|
44233
44233
|
} catch {
|
|
44234
44234
|
} finally {
|
|
@@ -44333,6 +44333,8 @@ function isHtml(text) {
|
|
|
44333
44333
|
return /^\s*<(?:!doctype|html)/i.test(text);
|
|
44334
44334
|
}
|
|
44335
44335
|
var RepoburgHttpClient = class {
|
|
44336
|
+
/** Base URL of the repoburg backend (public — the projector opens the
|
|
44337
|
+
* agent-runtime SSE channel for the throwaway title session). */
|
|
44336
44338
|
baseUrl;
|
|
44337
44339
|
constructor(baseUrl = defaultRepoburgBaseUrl()) {
|
|
44338
44340
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
@@ -44389,6 +44391,9 @@ var RepoburgHttpClient = class {
|
|
|
44389
44391
|
`/sessions/${sessionId}/inputs/${anchorInputId}/until-here`
|
|
44390
44392
|
);
|
|
44391
44393
|
}
|
|
44394
|
+
async deleteSession(id) {
|
|
44395
|
+
await this.request("DELETE", `/sessions/${id}`);
|
|
44396
|
+
}
|
|
44392
44397
|
async forkSession(sessionId, untilInputId) {
|
|
44393
44398
|
return this.request("POST", `/sessions/${sessionId}/fork`, {
|
|
44394
44399
|
until_input_id: untilInputId ?? null
|
|
@@ -44760,9 +44765,121 @@ function completeItem(db2, sessionId, turnId, item, data, status) {
|
|
|
44760
44765
|
broadcast("item:completed", { sessionId, turnId, item: updated });
|
|
44761
44766
|
}
|
|
44762
44767
|
|
|
44768
|
+
// src/repoburg/agent-runtime-client.ts
|
|
44769
|
+
function parseSseFrame(frame) {
|
|
44770
|
+
const dataLines = [];
|
|
44771
|
+
for (const line of frame.split("\n")) {
|
|
44772
|
+
const trimmed = line.replace(/\r$/, "");
|
|
44773
|
+
if (trimmed.startsWith(":")) continue;
|
|
44774
|
+
if (trimmed.startsWith("data:")) {
|
|
44775
|
+
dataLines.push(trimmed.slice(5).replace(/^ /, ""));
|
|
44776
|
+
}
|
|
44777
|
+
}
|
|
44778
|
+
if (dataLines.length === 0) return null;
|
|
44779
|
+
return dataLines.join("\n");
|
|
44780
|
+
}
|
|
44781
|
+
function createSseParser() {
|
|
44782
|
+
let buffer = "";
|
|
44783
|
+
return (chunk) => {
|
|
44784
|
+
buffer += chunk.replace(/\r\n/g, "\n");
|
|
44785
|
+
const payloads = [];
|
|
44786
|
+
let boundary;
|
|
44787
|
+
while ((boundary = buffer.indexOf("\n\n")) !== -1) {
|
|
44788
|
+
const frame = buffer.slice(0, boundary);
|
|
44789
|
+
buffer = buffer.slice(boundary + 2);
|
|
44790
|
+
const data = parseSseFrame(frame);
|
|
44791
|
+
if (data !== null) payloads.push(data);
|
|
44792
|
+
}
|
|
44793
|
+
return payloads;
|
|
44794
|
+
};
|
|
44795
|
+
}
|
|
44796
|
+
async function streamAgentRuntimeMessages(baseUrl, sessionId, onMessage, opts = {}) {
|
|
44797
|
+
const deltas = opts.deltas !== false;
|
|
44798
|
+
const delayMs = opts.reconnectDelayMs ?? 2e3;
|
|
44799
|
+
const url = `${baseUrl.replace(/\/+$/, "")}/agent-runtime/sessions/${sessionId}/messages?stream=${deltas ? 1 : 0}`;
|
|
44800
|
+
for (; ; ) {
|
|
44801
|
+
if (opts.signal?.aborted) return "aborted";
|
|
44802
|
+
let response;
|
|
44803
|
+
try {
|
|
44804
|
+
response = await fetch(url, { method: "GET", signal: opts.signal });
|
|
44805
|
+
} catch (err) {
|
|
44806
|
+
if (opts.signal?.aborted || err.name === "AbortError") {
|
|
44807
|
+
return "aborted";
|
|
44808
|
+
}
|
|
44809
|
+
await reconnectDelay(delayMs, opts.signal);
|
|
44810
|
+
continue;
|
|
44811
|
+
}
|
|
44812
|
+
if (response.status === 404) return "session-not-found";
|
|
44813
|
+
if (!response.ok || !response.body) {
|
|
44814
|
+
await reconnectDelay(delayMs, opts.signal);
|
|
44815
|
+
continue;
|
|
44816
|
+
}
|
|
44817
|
+
const reason = await readBody(
|
|
44818
|
+
response.body,
|
|
44819
|
+
onMessage,
|
|
44820
|
+
opts
|
|
44821
|
+
);
|
|
44822
|
+
if (reason !== null) {
|
|
44823
|
+
await response.body.cancel().catch(() => {
|
|
44824
|
+
});
|
|
44825
|
+
return reason;
|
|
44826
|
+
}
|
|
44827
|
+
await reconnectDelay(delayMs, opts.signal);
|
|
44828
|
+
}
|
|
44829
|
+
}
|
|
44830
|
+
async function readBody(body, onMessage, opts) {
|
|
44831
|
+
const parse = createSseParser();
|
|
44832
|
+
const decoder = new TextDecoder();
|
|
44833
|
+
const reader = body.getReader();
|
|
44834
|
+
try {
|
|
44835
|
+
for (; ; ) {
|
|
44836
|
+
const { done, value } = await reader.read();
|
|
44837
|
+
if (done) return null;
|
|
44838
|
+
opts.onActivity?.();
|
|
44839
|
+
for (const payload of parse(decoder.decode(value, { stream: true }))) {
|
|
44840
|
+
let message = null;
|
|
44841
|
+
try {
|
|
44842
|
+
message = JSON.parse(payload);
|
|
44843
|
+
} catch {
|
|
44844
|
+
continue;
|
|
44845
|
+
}
|
|
44846
|
+
if (!message || typeof message.type !== "string") continue;
|
|
44847
|
+
onMessage(message);
|
|
44848
|
+
if (message.type === "result") return "result";
|
|
44849
|
+
}
|
|
44850
|
+
}
|
|
44851
|
+
} catch (err) {
|
|
44852
|
+
if (opts.signal?.aborted || err.name === "AbortError") {
|
|
44853
|
+
return "aborted";
|
|
44854
|
+
}
|
|
44855
|
+
return null;
|
|
44856
|
+
} finally {
|
|
44857
|
+
try {
|
|
44858
|
+
reader.releaseLock();
|
|
44859
|
+
} catch {
|
|
44860
|
+
}
|
|
44861
|
+
}
|
|
44862
|
+
}
|
|
44863
|
+
function reconnectDelay(delayMs, signal) {
|
|
44864
|
+
return new Promise((resolve) => {
|
|
44865
|
+
if (signal?.aborted) return resolve();
|
|
44866
|
+
const timer = setTimeout(resolve, delayMs);
|
|
44867
|
+
signal?.addEventListener(
|
|
44868
|
+
"abort",
|
|
44869
|
+
() => {
|
|
44870
|
+
clearTimeout(timer);
|
|
44871
|
+
resolve();
|
|
44872
|
+
},
|
|
44873
|
+
{ once: true }
|
|
44874
|
+
);
|
|
44875
|
+
});
|
|
44876
|
+
}
|
|
44877
|
+
|
|
44763
44878
|
// src/repoburg/turn-projector.ts
|
|
44764
44879
|
var RESULT_TIMEOUT_MS = 15 * 6e4;
|
|
44765
44880
|
var MAX_RESULT_EXTENSIONS = 3;
|
|
44881
|
+
var TITLE_TIMEOUT_MS = 9e4;
|
|
44882
|
+
var titleGenerating3 = /* @__PURE__ */ new Set();
|
|
44766
44883
|
var TurnProjector = class {
|
|
44767
44884
|
constructor(deps) {
|
|
44768
44885
|
this.deps = deps;
|
|
@@ -45082,7 +45199,10 @@ var TurnProjector = class {
|
|
|
45082
45199
|
this.deps.agentPaneSessionId
|
|
45083
45200
|
);
|
|
45084
45201
|
}
|
|
45085
|
-
/** Fire-and-forget: copy the runtime session title once (new sessions).
|
|
45202
|
+
/** Fire-and-forget: copy the runtime session title once (new sessions).
|
|
45203
|
+
* When the runtime produced no title (the backend's default agent no
|
|
45204
|
+
* longer sets one), generate a title with a throwaway runtime session —
|
|
45205
|
+
* the same title-generation pattern the Claude/Codex providers use. */
|
|
45086
45206
|
async syncTitle() {
|
|
45087
45207
|
try {
|
|
45088
45208
|
const db2 = getDb();
|
|
@@ -45092,15 +45212,82 @@ var TurnProjector = class {
|
|
|
45092
45212
|
if (!session || session.title) return;
|
|
45093
45213
|
const runtimeSession = await this.deps.client.getSession(this.deps.repoburgSessionId);
|
|
45094
45214
|
const title = (runtimeSession.session_title || "").trim();
|
|
45095
|
-
if (
|
|
45096
|
-
|
|
45097
|
-
|
|
45098
|
-
|
|
45099
|
-
|
|
45100
|
-
|
|
45215
|
+
if (title) {
|
|
45216
|
+
this.applyTitle(title);
|
|
45217
|
+
return;
|
|
45218
|
+
}
|
|
45219
|
+
await this.generateTitleFallback();
|
|
45220
|
+
} catch {
|
|
45221
|
+
}
|
|
45222
|
+
}
|
|
45223
|
+
/** Persist + broadcast a title. */
|
|
45224
|
+
applyTitle(title) {
|
|
45225
|
+
const db2 = getDb();
|
|
45226
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
45227
|
+
db2.prepare("UPDATE sessions SET title = ?, updated_at = ? WHERE id = ?").run(
|
|
45228
|
+
title,
|
|
45229
|
+
now,
|
|
45230
|
+
this.deps.agentPaneSessionId
|
|
45231
|
+
);
|
|
45232
|
+
broadcast("session:title", { sessionId: this.deps.agentPaneSessionId, title });
|
|
45233
|
+
}
|
|
45234
|
+
/** Title-generation pattern (Claude/Codex provider parity): run ONE prompt
|
|
45235
|
+
* on a THROWAWAY runtime session, take the reply as the title, delete the
|
|
45236
|
+
* session. The main runtime session is never touched. Silent on failure —
|
|
45237
|
+
* the session simply keeps a null title. */
|
|
45238
|
+
async generateTitleFallback() {
|
|
45239
|
+
const sessionId = this.deps.agentPaneSessionId;
|
|
45240
|
+
if (titleGenerating3.has(sessionId)) return;
|
|
45241
|
+
const db2 = getDb();
|
|
45242
|
+
const firstTurn = db2.prepare(
|
|
45243
|
+
"SELECT user_prompt, agent_response FROM turns WHERE session_id = ? ORDER BY created_at ASC LIMIT 1"
|
|
45244
|
+
).get(sessionId);
|
|
45245
|
+
if (!firstTurn) return;
|
|
45246
|
+
titleGenerating3.add(sessionId);
|
|
45247
|
+
let throwawayId = null;
|
|
45248
|
+
try {
|
|
45249
|
+
const pane = db2.prepare("SELECT model FROM sessions WHERE id = ?").get(sessionId);
|
|
45250
|
+
const created = await this.deps.client.createSession(
|
|
45251
|
+
pane?.model ? { model_id: pane.model } : {}
|
|
45101
45252
|
);
|
|
45102
|
-
|
|
45253
|
+
throwawayId = created.id;
|
|
45254
|
+
const controller = new AbortController();
|
|
45255
|
+
const timer = setTimeout(() => controller.abort(), TITLE_TIMEOUT_MS);
|
|
45256
|
+
try {
|
|
45257
|
+
await this.deps.client.createInput(throwawayId, {
|
|
45258
|
+
user_prompt: buildTitlePrompt(firstTurn.user_prompt, firstTurn.agent_response),
|
|
45259
|
+
execution_strategy: "auto_apply"
|
|
45260
|
+
});
|
|
45261
|
+
let reply = "";
|
|
45262
|
+
const consume = (message) => {
|
|
45263
|
+
if (message.type === "assistant") {
|
|
45264
|
+
reply += message.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
45265
|
+
} else if (message.type === "result" && !message.is_error && message.result) {
|
|
45266
|
+
reply = message.result;
|
|
45267
|
+
}
|
|
45268
|
+
};
|
|
45269
|
+
const reason = await streamAgentRuntimeMessages(
|
|
45270
|
+
this.deps.client.baseUrl,
|
|
45271
|
+
throwawayId,
|
|
45272
|
+
consume,
|
|
45273
|
+
{ signal: controller.signal, deltas: false }
|
|
45274
|
+
);
|
|
45275
|
+
if (reason === "aborted") {
|
|
45276
|
+
void this.deps.client.cancel(throwawayId).catch(() => {
|
|
45277
|
+
});
|
|
45278
|
+
}
|
|
45279
|
+
const title = cleanTitle(reply);
|
|
45280
|
+
if (title) this.applyTitle(title);
|
|
45281
|
+
} finally {
|
|
45282
|
+
clearTimeout(timer);
|
|
45283
|
+
}
|
|
45103
45284
|
} catch {
|
|
45285
|
+
} finally {
|
|
45286
|
+
if (throwawayId) {
|
|
45287
|
+
void this.deps.client.deleteSession(throwawayId).catch(() => {
|
|
45288
|
+
});
|
|
45289
|
+
}
|
|
45290
|
+
titleGenerating3.delete(sessionId);
|
|
45104
45291
|
}
|
|
45105
45292
|
}
|
|
45106
45293
|
finishFailed(error) {
|
|
@@ -45272,115 +45459,17 @@ function extractFinalPlain(input) {
|
|
|
45272
45459
|
);
|
|
45273
45460
|
return action?.plain ?? null;
|
|
45274
45461
|
}
|
|
45462
|
+
function buildTitlePrompt(userPrompt, agentResponse) {
|
|
45463
|
+
const truncatedPrompt = userPrompt.slice(0, 500);
|
|
45464
|
+
const truncatedResponse = (agentResponse ?? "").slice(0, 500);
|
|
45465
|
+
return `Generate a concise 3-5 word title for this conversation. Reply with only the title, nothing else.
|
|
45275
45466
|
|
|
45276
|
-
|
|
45277
|
-
|
|
45278
|
-
|
|
45279
|
-
for (const line of frame.split("\n")) {
|
|
45280
|
-
const trimmed = line.replace(/\r$/, "");
|
|
45281
|
-
if (trimmed.startsWith(":")) continue;
|
|
45282
|
-
if (trimmed.startsWith("data:")) {
|
|
45283
|
-
dataLines.push(trimmed.slice(5).replace(/^ /, ""));
|
|
45284
|
-
}
|
|
45285
|
-
}
|
|
45286
|
-
if (dataLines.length === 0) return null;
|
|
45287
|
-
return dataLines.join("\n");
|
|
45288
|
-
}
|
|
45289
|
-
function createSseParser() {
|
|
45290
|
-
let buffer = "";
|
|
45291
|
-
return (chunk) => {
|
|
45292
|
-
buffer += chunk.replace(/\r\n/g, "\n");
|
|
45293
|
-
const payloads = [];
|
|
45294
|
-
let boundary;
|
|
45295
|
-
while ((boundary = buffer.indexOf("\n\n")) !== -1) {
|
|
45296
|
-
const frame = buffer.slice(0, boundary);
|
|
45297
|
-
buffer = buffer.slice(boundary + 2);
|
|
45298
|
-
const data = parseSseFrame(frame);
|
|
45299
|
-
if (data !== null) payloads.push(data);
|
|
45300
|
-
}
|
|
45301
|
-
return payloads;
|
|
45302
|
-
};
|
|
45303
|
-
}
|
|
45304
|
-
async function streamAgentRuntimeMessages(baseUrl, sessionId, onMessage, opts = {}) {
|
|
45305
|
-
const deltas = opts.deltas !== false;
|
|
45306
|
-
const delayMs = opts.reconnectDelayMs ?? 2e3;
|
|
45307
|
-
const url = `${baseUrl.replace(/\/+$/, "")}/agent-runtime/sessions/${sessionId}/messages?stream=${deltas ? 1 : 0}`;
|
|
45308
|
-
for (; ; ) {
|
|
45309
|
-
if (opts.signal?.aborted) return "aborted";
|
|
45310
|
-
let response;
|
|
45311
|
-
try {
|
|
45312
|
-
response = await fetch(url, { method: "GET", signal: opts.signal });
|
|
45313
|
-
} catch (err) {
|
|
45314
|
-
if (opts.signal?.aborted || err.name === "AbortError") {
|
|
45315
|
-
return "aborted";
|
|
45316
|
-
}
|
|
45317
|
-
await reconnectDelay(delayMs, opts.signal);
|
|
45318
|
-
continue;
|
|
45319
|
-
}
|
|
45320
|
-
if (response.status === 404) return "session-not-found";
|
|
45321
|
-
if (!response.ok || !response.body) {
|
|
45322
|
-
await reconnectDelay(delayMs, opts.signal);
|
|
45323
|
-
continue;
|
|
45324
|
-
}
|
|
45325
|
-
const reason = await readBody(
|
|
45326
|
-
response.body,
|
|
45327
|
-
onMessage,
|
|
45328
|
-
opts
|
|
45329
|
-
);
|
|
45330
|
-
if (reason !== null) {
|
|
45331
|
-
await response.body.cancel().catch(() => {
|
|
45332
|
-
});
|
|
45333
|
-
return reason;
|
|
45334
|
-
}
|
|
45335
|
-
await reconnectDelay(delayMs, opts.signal);
|
|
45336
|
-
}
|
|
45337
|
-
}
|
|
45338
|
-
async function readBody(body, onMessage, opts) {
|
|
45339
|
-
const parse = createSseParser();
|
|
45340
|
-
const decoder = new TextDecoder();
|
|
45341
|
-
const reader = body.getReader();
|
|
45342
|
-
try {
|
|
45343
|
-
for (; ; ) {
|
|
45344
|
-
const { done, value } = await reader.read();
|
|
45345
|
-
if (done) return null;
|
|
45346
|
-
opts.onActivity?.();
|
|
45347
|
-
for (const payload of parse(decoder.decode(value, { stream: true }))) {
|
|
45348
|
-
let message = null;
|
|
45349
|
-
try {
|
|
45350
|
-
message = JSON.parse(payload);
|
|
45351
|
-
} catch {
|
|
45352
|
-
continue;
|
|
45353
|
-
}
|
|
45354
|
-
if (!message || typeof message.type !== "string") continue;
|
|
45355
|
-
onMessage(message);
|
|
45356
|
-
if (message.type === "result") return "result";
|
|
45357
|
-
}
|
|
45358
|
-
}
|
|
45359
|
-
} catch (err) {
|
|
45360
|
-
if (opts.signal?.aborted || err.name === "AbortError") {
|
|
45361
|
-
return "aborted";
|
|
45362
|
-
}
|
|
45363
|
-
return null;
|
|
45364
|
-
} finally {
|
|
45365
|
-
try {
|
|
45366
|
-
reader.releaseLock();
|
|
45367
|
-
} catch {
|
|
45368
|
-
}
|
|
45369
|
-
}
|
|
45467
|
+
User asked: "${truncatedPrompt}"
|
|
45468
|
+
|
|
45469
|
+
Agent responded: "${truncatedResponse}"`;
|
|
45370
45470
|
}
|
|
45371
|
-
function
|
|
45372
|
-
return
|
|
45373
|
-
if (signal?.aborted) return resolve();
|
|
45374
|
-
const timer = setTimeout(resolve, delayMs);
|
|
45375
|
-
signal?.addEventListener(
|
|
45376
|
-
"abort",
|
|
45377
|
-
() => {
|
|
45378
|
-
clearTimeout(timer);
|
|
45379
|
-
resolve();
|
|
45380
|
-
},
|
|
45381
|
-
{ once: true }
|
|
45382
|
-
);
|
|
45383
|
-
});
|
|
45471
|
+
function cleanTitle(raw) {
|
|
45472
|
+
return raw.trim().replace(/^["']|["']$/g, "").split("\n")[0].replace(/\s+/g, " ").trim().slice(0, 100);
|
|
45384
45473
|
}
|
|
45385
45474
|
|
|
45386
45475
|
// src/repoburg/repoburg-provider.ts
|