repoburg 1.3.211 → 1.3.212

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.
@@ -45026,6 +45026,7 @@ async function ensureSession(session, client, baseUrl) {
45026
45026
  // undefined forces a re-push on the next turn — heals sessions created
45027
45027
  // before unsafe effort values (e.g. ollama xhigh) were clamped.
45028
45028
  reasoningEffort: void 0,
45029
+ threadId: null,
45029
45030
  activeTurn: null
45030
45031
  };
45031
45032
  sessionMap3.set(session.id, entry2);
@@ -45051,11 +45052,47 @@ async function ensureSession(session, client, baseUrl) {
45051
45052
  baseUrl,
45052
45053
  modelId: session.model ?? null,
45053
45054
  reasoningEffort: mappedEffort,
45055
+ threadId: null,
45054
45056
  activeTurn: null
45055
45057
  };
45056
45058
  sessionMap3.set(session.id, entry);
45057
45059
  return entry;
45058
45060
  }
45061
+ async function ensureThreadSession(session, turn, client, baseUrl) {
45062
+ const mapKey = `${session.id}:thread:${turn.thread_id}`;
45063
+ const existing = sessionMap3.get(mapKey);
45064
+ if (existing) return existing;
45065
+ const db2 = getDb();
45066
+ const thread = db2.prepare("SELECT external_thread_id FROM discussion_threads WHERE id = ?").get(turn.thread_id);
45067
+ let runtimeId = thread?.external_thread_id ?? null;
45068
+ if (!runtimeId) {
45069
+ const created = await client.createSession({
45070
+ session_title: session.title ? `Discussion: ${session.title}` : "Discussion",
45071
+ model_id: session.model ?? void 0,
45072
+ reasoning_effort: mapReasoningEffort(session.model, session.model_reasoning_effort)
45073
+ });
45074
+ runtimeId = created.id;
45075
+ const now = (/* @__PURE__ */ new Date()).toISOString();
45076
+ db2.prepare("UPDATE discussion_threads SET external_thread_id = ?, updated_at = ? WHERE id = ?").run(
45077
+ runtimeId,
45078
+ now,
45079
+ turn.thread_id
45080
+ );
45081
+ }
45082
+ const entry = {
45083
+ agentPaneSessionId: session.id,
45084
+ repoburgSessionId: runtimeId,
45085
+ client,
45086
+ baseUrl,
45087
+ modelId: session.model ?? null,
45088
+ reasoningEffort: void 0,
45089
+ // re-pushed on the first thread turn
45090
+ threadId: turn.thread_id,
45091
+ activeTurn: null
45092
+ };
45093
+ sessionMap3.set(mapKey, entry);
45094
+ return entry;
45095
+ }
45059
45096
  function failTurnBeforeStart(db2, sessionId, turnId, error) {
45060
45097
  const now = (/* @__PURE__ */ new Date()).toISOString();
45061
45098
  db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
@@ -45152,7 +45189,7 @@ async function startTurn3(session, turn) {
45152
45189
  }
45153
45190
  let entry;
45154
45191
  try {
45155
- entry = await ensureSession(session, client, baseUrl);
45192
+ entry = turn.thread_id ? await ensureThreadSession(session, turn, client, baseUrl) : await ensureSession(session, client, baseUrl);
45156
45193
  } catch (err) {
45157
45194
  if (isConnectionError(err)) invalidateBackend(baseUrl);
45158
45195
  failTurnBeforeStart(db2, session.id, turn.id, `Failed to create repoburg session: ${err.message}`);
@@ -45200,7 +45237,15 @@ async function startTurn3(session, turn) {
45200
45237
  }
45201
45238
  }
45202
45239
  async function interruptTurn3(sessionId) {
45203
- const entry = sessionMap3.get(sessionId);
45240
+ let entry = sessionMap3.get(sessionId);
45241
+ if (!entry?.activeTurn) {
45242
+ for (const [key, threadEntry] of sessionMap3) {
45243
+ if (key.startsWith(`${sessionId}:thread:`) && threadEntry.activeTurn) {
45244
+ entry = threadEntry;
45245
+ break;
45246
+ }
45247
+ }
45248
+ }
45204
45249
  const active = entry?.activeTurn;
45205
45250
  if (!entry || !active) return false;
45206
45251
  active.cancelled = true;
@@ -45222,14 +45267,29 @@ async function interruptTurn3(sessionId) {
45222
45267
  return true;
45223
45268
  }
45224
45269
  function clearThread3(sessionId) {
45225
- const entry = sessionMap3.get(sessionId);
45226
- if (entry?.activeTurn) {
45227
- const active = entry.activeTurn;
45228
- entry.activeTurn = null;
45229
- active.projector.close();
45230
- active.sseAbort.abort();
45270
+ for (const [key, entry] of sessionMap3) {
45271
+ if (key !== sessionId && !key.startsWith(`${sessionId}:thread:`)) continue;
45272
+ if (entry.activeTurn) {
45273
+ const active = entry.activeTurn;
45274
+ entry.activeTurn = null;
45275
+ active.projector.close();
45276
+ active.sseAbort.abort();
45277
+ }
45278
+ sessionMap3.delete(key);
45279
+ }
45280
+ }
45281
+ function clearThreadBranch2(sessionId, threadId) {
45282
+ const key = `${sessionId}:thread:${threadId}`;
45283
+ const entry = sessionMap3.get(key);
45284
+ if (entry) {
45285
+ if (entry.activeTurn) {
45286
+ const active = entry.activeTurn;
45287
+ entry.activeTurn = null;
45288
+ active.projector.close();
45289
+ active.sseAbort.abort();
45290
+ }
45291
+ sessionMap3.delete(key);
45231
45292
  }
45232
- sessionMap3.delete(sessionId);
45233
45293
  }
45234
45294
  function parseRuntimeInputIds(turn) {
45235
45295
  const raw = turn.runtime_input_ids;
@@ -45314,6 +45374,7 @@ var repoburgProvider = {
45314
45374
  startTurn: startTurn3,
45315
45375
  interruptTurn: interruptTurn3,
45316
45376
  clearThread: clearThread3,
45377
+ clearThreadBranch: clearThreadBranch2,
45317
45378
  clearAllThreads: clearAllThreads3,
45318
45379
  getModels: getModels3,
45319
45380
  rewindRuntime,
@@ -45013,6 +45013,7 @@ async function ensureSession(session, client, baseUrl) {
45013
45013
  // undefined forces a re-push on the next turn — heals sessions created
45014
45014
  // before unsafe effort values (e.g. ollama xhigh) were clamped.
45015
45015
  reasoningEffort: void 0,
45016
+ threadId: null,
45016
45017
  activeTurn: null
45017
45018
  };
45018
45019
  sessionMap3.set(session.id, entry2);
@@ -45038,11 +45039,47 @@ async function ensureSession(session, client, baseUrl) {
45038
45039
  baseUrl,
45039
45040
  modelId: session.model ?? null,
45040
45041
  reasoningEffort: mappedEffort,
45042
+ threadId: null,
45041
45043
  activeTurn: null
45042
45044
  };
45043
45045
  sessionMap3.set(session.id, entry);
45044
45046
  return entry;
45045
45047
  }
45048
+ async function ensureThreadSession(session, turn, client, baseUrl) {
45049
+ const mapKey = `${session.id}:thread:${turn.thread_id}`;
45050
+ const existing = sessionMap3.get(mapKey);
45051
+ if (existing) return existing;
45052
+ const db2 = getDb();
45053
+ const thread = db2.prepare("SELECT external_thread_id FROM discussion_threads WHERE id = ?").get(turn.thread_id);
45054
+ let runtimeId = thread?.external_thread_id ?? null;
45055
+ if (!runtimeId) {
45056
+ const created = await client.createSession({
45057
+ session_title: session.title ? `Discussion: ${session.title}` : "Discussion",
45058
+ model_id: session.model ?? void 0,
45059
+ reasoning_effort: mapReasoningEffort(session.model, session.model_reasoning_effort)
45060
+ });
45061
+ runtimeId = created.id;
45062
+ const now = (/* @__PURE__ */ new Date()).toISOString();
45063
+ db2.prepare("UPDATE discussion_threads SET external_thread_id = ?, updated_at = ? WHERE id = ?").run(
45064
+ runtimeId,
45065
+ now,
45066
+ turn.thread_id
45067
+ );
45068
+ }
45069
+ const entry = {
45070
+ agentPaneSessionId: session.id,
45071
+ repoburgSessionId: runtimeId,
45072
+ client,
45073
+ baseUrl,
45074
+ modelId: session.model ?? null,
45075
+ reasoningEffort: void 0,
45076
+ // re-pushed on the first thread turn
45077
+ threadId: turn.thread_id,
45078
+ activeTurn: null
45079
+ };
45080
+ sessionMap3.set(mapKey, entry);
45081
+ return entry;
45082
+ }
45046
45083
  function failTurnBeforeStart(db2, sessionId, turnId, error) {
45047
45084
  const now = (/* @__PURE__ */ new Date()).toISOString();
45048
45085
  db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
@@ -45139,7 +45176,7 @@ async function startTurn3(session, turn) {
45139
45176
  }
45140
45177
  let entry;
45141
45178
  try {
45142
- entry = await ensureSession(session, client, baseUrl);
45179
+ entry = turn.thread_id ? await ensureThreadSession(session, turn, client, baseUrl) : await ensureSession(session, client, baseUrl);
45143
45180
  } catch (err) {
45144
45181
  if (isConnectionError(err)) invalidateBackend(baseUrl);
45145
45182
  failTurnBeforeStart(db2, session.id, turn.id, `Failed to create repoburg session: ${err.message}`);
@@ -45187,7 +45224,15 @@ async function startTurn3(session, turn) {
45187
45224
  }
45188
45225
  }
45189
45226
  async function interruptTurn3(sessionId) {
45190
- const entry = sessionMap3.get(sessionId);
45227
+ let entry = sessionMap3.get(sessionId);
45228
+ if (!entry?.activeTurn) {
45229
+ for (const [key, threadEntry] of sessionMap3) {
45230
+ if (key.startsWith(`${sessionId}:thread:`) && threadEntry.activeTurn) {
45231
+ entry = threadEntry;
45232
+ break;
45233
+ }
45234
+ }
45235
+ }
45191
45236
  const active = entry?.activeTurn;
45192
45237
  if (!entry || !active) return false;
45193
45238
  active.cancelled = true;
@@ -45209,14 +45254,29 @@ async function interruptTurn3(sessionId) {
45209
45254
  return true;
45210
45255
  }
45211
45256
  function clearThread3(sessionId) {
45212
- const entry = sessionMap3.get(sessionId);
45213
- if (entry?.activeTurn) {
45214
- const active = entry.activeTurn;
45215
- entry.activeTurn = null;
45216
- active.projector.close();
45217
- active.sseAbort.abort();
45257
+ for (const [key, entry] of sessionMap3) {
45258
+ if (key !== sessionId && !key.startsWith(`${sessionId}:thread:`)) continue;
45259
+ if (entry.activeTurn) {
45260
+ const active = entry.activeTurn;
45261
+ entry.activeTurn = null;
45262
+ active.projector.close();
45263
+ active.sseAbort.abort();
45264
+ }
45265
+ sessionMap3.delete(key);
45266
+ }
45267
+ }
45268
+ function clearThreadBranch2(sessionId, threadId) {
45269
+ const key = `${sessionId}:thread:${threadId}`;
45270
+ const entry = sessionMap3.get(key);
45271
+ if (entry) {
45272
+ if (entry.activeTurn) {
45273
+ const active = entry.activeTurn;
45274
+ entry.activeTurn = null;
45275
+ active.projector.close();
45276
+ active.sseAbort.abort();
45277
+ }
45278
+ sessionMap3.delete(key);
45218
45279
  }
45219
- sessionMap3.delete(sessionId);
45220
45280
  }
45221
45281
  function parseRuntimeInputIds(turn) {
45222
45282
  const raw = turn.runtime_input_ids;
@@ -45301,6 +45361,7 @@ var repoburgProvider = {
45301
45361
  startTurn: startTurn3,
45302
45362
  interruptTurn: interruptTurn3,
45303
45363
  clearThread: clearThread3,
45364
+ clearThreadBranch: clearThreadBranch2,
45304
45365
  clearAllThreads: clearAllThreads3,
45305
45366
  getModels: getModels3,
45306
45367
  rewindRuntime,