repoburg 1.3.317 → 1.3.319
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 +487 -162
- package/agent-pane/backend/dist/server.js +487 -162
- package/agent-pane/frontend/dist/assets/{TerminalView-D3fkOngy.js → TerminalView-D5Hg3Fzf.js} +1 -1
- package/agent-pane/frontend/dist/assets/index-C1m0abtH.css +1 -0
- package/agent-pane/frontend/dist/assets/index-Cckb2tlY.js +852 -0
- package/agent-pane/frontend/dist/index.html +2 -2
- package/backend/dist/src/application-state/application-state.service.d.ts +5 -0
- package/backend/dist/src/application-state/application-state.service.js +18 -0
- package/backend/dist/src/application-state/application-state.service.js.map +1 -1
- package/backend/dist/src/core-entities/enums.d.ts +1 -0
- package/backend/dist/src/core-entities/enums.js +1 -0
- package/backend/dist/src/core-entities/enums.js.map +1 -1
- package/backend/dist/src/global-config/global-config.service.d.ts +1 -0
- package/backend/dist/src/global-config/global-config.service.js +15 -1
- package/backend/dist/src/global-config/global-config.service.js.map +1 -1
- package/backend/dist/src/llm-provider/alibaba-llm.provider.d.ts +18 -2
- package/backend/dist/src/llm-provider/alibaba-llm.provider.js +155 -17
- package/backend/dist/src/llm-provider/alibaba-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-provider/credential-check.d.ts +3 -0
- package/backend/dist/src/llm-provider/credential-check.js +27 -0
- package/backend/dist/src/llm-provider/credential-check.js.map +1 -0
- package/backend/dist/src/llm-provider/dto/set-inference-credentials.dto.d.ts +5 -0
- package/backend/dist/src/llm-provider/dto/set-inference-credentials.dto.js +46 -0
- package/backend/dist/src/llm-provider/dto/set-inference-credentials.dto.js.map +1 -0
- package/backend/dist/src/llm-provider/inference-credentials.service.d.ts +24 -0
- package/backend/dist/src/llm-provider/inference-credentials.service.js +120 -0
- package/backend/dist/src/llm-provider/inference-credentials.service.js.map +1 -0
- package/backend/dist/src/llm-provider/inference-registry.d.ts +15 -0
- package/backend/dist/src/llm-provider/inference-registry.js +68 -0
- package/backend/dist/src/llm-provider/inference-registry.js.map +1 -0
- package/backend/dist/src/llm-provider/llm-provider.controller.d.ts +15 -1
- package/backend/dist/src/llm-provider/llm-provider.controller.js +75 -3
- package/backend/dist/src/llm-provider/llm-provider.controller.js.map +1 -1
- package/backend/dist/src/llm-provider/llm-provider.interface.d.ts +34 -1
- package/backend/dist/src/llm-provider/llm-provider.interface.js +8 -1
- package/backend/dist/src/llm-provider/llm-provider.interface.js.map +1 -1
- package/backend/dist/src/llm-provider/llm-provider.module.js +5 -1
- package/backend/dist/src/llm-provider/llm-provider.module.js.map +1 -1
- package/backend/dist/src/llm-provider/ollama-llm.provider.d.ts +14 -6
- package/backend/dist/src/llm-provider/ollama-llm.provider.js +208 -80
- package/backend/dist/src/llm-provider/ollama-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-provider/openai-llm.provider.d.ts +7 -2
- package/backend/dist/src/llm-provider/openai-llm.provider.js +50 -8
- package/backend/dist/src/llm-provider/openai-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-provider/openrouter-llm.provider.d.ts +21 -2
- package/backend/dist/src/llm-provider/openrouter-llm.provider.js +124 -14
- package/backend/dist/src/llm-provider/openrouter-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-provider/proxy-llm.provider.d.ts +4 -11
- package/backend/dist/src/llm-provider/proxy-llm.provider.js +17 -47
- package/backend/dist/src/llm-provider/proxy-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-provider/reasoning.d.ts +9 -0
- package/backend/dist/src/llm-provider/reasoning.js +73 -0
- package/backend/dist/src/llm-provider/reasoning.js.map +1 -0
- package/backend/dist/src/llm-provider/zai-llm.provider.d.ts +24 -2
- package/backend/dist/src/llm-provider/zai-llm.provider.js +134 -17
- package/backend/dist/src/llm-provider/zai-llm.provider.js.map +1 -1
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/tabtape/extension/dist/build-info.json +3 -3
- package/tabtape/extension/dist/manifest.json +1 -1
- package/tabtape/ui/dist/build-info.json +3 -3
- package/agent-pane/frontend/dist/assets/index-Bb9z3drP.js +0 -852
- package/agent-pane/frontend/dist/assets/index-nEHdBY3j.css +0 -1
|
@@ -11485,7 +11485,7 @@ var require_reply = __commonJS({
|
|
|
11485
11485
|
}
|
|
11486
11486
|
return serialize2;
|
|
11487
11487
|
};
|
|
11488
|
-
Reply.prototype.compileSerializationSchema = function(schema,
|
|
11488
|
+
Reply.prototype.compileSerializationSchema = function(schema, httpStatus2 = null, contentType = null) {
|
|
11489
11489
|
const { request } = this;
|
|
11490
11490
|
const { method, url: url2 } = request;
|
|
11491
11491
|
if (this[kRouteContext][kReplyCacheSerializeFns]?.has(schema)) {
|
|
@@ -11498,7 +11498,7 @@ var require_reply = __commonJS({
|
|
|
11498
11498
|
schema,
|
|
11499
11499
|
method,
|
|
11500
11500
|
url: url2,
|
|
11501
|
-
httpStatus,
|
|
11501
|
+
httpStatus: httpStatus2,
|
|
11502
11502
|
contentType
|
|
11503
11503
|
});
|
|
11504
11504
|
if (this[kRouteContext][kReplyCacheSerializeFns] == null) {
|
|
@@ -11507,26 +11507,26 @@ var require_reply = __commonJS({
|
|
|
11507
11507
|
this[kRouteContext][kReplyCacheSerializeFns].set(schema, serializeFn);
|
|
11508
11508
|
return serializeFn;
|
|
11509
11509
|
};
|
|
11510
|
-
Reply.prototype.serializeInput = function(input, schema,
|
|
11511
|
-
const possibleContentType =
|
|
11510
|
+
Reply.prototype.serializeInput = function(input, schema, httpStatus2, contentType) {
|
|
11511
|
+
const possibleContentType = httpStatus2;
|
|
11512
11512
|
let serialize2;
|
|
11513
|
-
|
|
11514
|
-
contentType =
|
|
11515
|
-
if (
|
|
11513
|
+
httpStatus2 = typeof schema === "string" || typeof schema === "number" ? schema : httpStatus2;
|
|
11514
|
+
contentType = httpStatus2 && possibleContentType !== httpStatus2 ? possibleContentType : contentType;
|
|
11515
|
+
if (httpStatus2 != null) {
|
|
11516
11516
|
if (contentType != null) {
|
|
11517
|
-
serialize2 = this[kRouteContext][kSchemaResponse]?.[
|
|
11517
|
+
serialize2 = this[kRouteContext][kSchemaResponse]?.[httpStatus2]?.[contentType];
|
|
11518
11518
|
} else {
|
|
11519
|
-
serialize2 = this[kRouteContext][kSchemaResponse]?.[
|
|
11519
|
+
serialize2 = this[kRouteContext][kSchemaResponse]?.[httpStatus2];
|
|
11520
11520
|
}
|
|
11521
11521
|
if (serialize2 == null) {
|
|
11522
|
-
if (contentType) throw new FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN(
|
|
11523
|
-
throw new FST_ERR_MISSING_SERIALIZATION_FN(
|
|
11522
|
+
if (contentType) throw new FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN(httpStatus2, contentType);
|
|
11523
|
+
throw new FST_ERR_MISSING_SERIALIZATION_FN(httpStatus2);
|
|
11524
11524
|
}
|
|
11525
11525
|
} else {
|
|
11526
11526
|
if (this[kRouteContext][kReplyCacheSerializeFns]?.has(schema)) {
|
|
11527
11527
|
serialize2 = this[kRouteContext][kReplyCacheSerializeFns].get(schema);
|
|
11528
11528
|
} else {
|
|
11529
|
-
serialize2 = this.compileSerializationSchema(schema,
|
|
11529
|
+
serialize2 = this.compileSerializationSchema(schema, httpStatus2, contentType);
|
|
11530
11530
|
}
|
|
11531
11531
|
}
|
|
11532
11532
|
return serialize2(input);
|
|
@@ -41180,6 +41180,9 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
|
|
|
41180
41180
|
if (!sessColumns.some((c) => c.name === "pre_rewind_thread_id")) {
|
|
41181
41181
|
database.exec("ALTER TABLE sessions ADD COLUMN pre_rewind_thread_id TEXT");
|
|
41182
41182
|
}
|
|
41183
|
+
if (!sessColumns.some((c) => c.name === "pre_rewind_turn_ids")) {
|
|
41184
|
+
database.exec("ALTER TABLE sessions ADD COLUMN pre_rewind_turn_ids TEXT");
|
|
41185
|
+
}
|
|
41183
41186
|
if (!sessColumns.some((c) => c.name === "context_usage")) {
|
|
41184
41187
|
database.exec("ALTER TABLE sessions ADD COLUMN context_usage TEXT");
|
|
41185
41188
|
}
|
|
@@ -41931,6 +41934,80 @@ function recomputeSessionRunning(db2, sessionId, idleStatus = "active", hasUnrev
|
|
|
41931
41934
|
}
|
|
41932
41935
|
}
|
|
41933
41936
|
|
|
41937
|
+
// src/routes/rewind-state.ts
|
|
41938
|
+
function forkPoint(db2, sessionId, target) {
|
|
41939
|
+
const row = db2.prepare(
|
|
41940
|
+
`SELECT external_turn_id FROM turns
|
|
41941
|
+
WHERE session_id = ? AND thread_id IS NULL AND external_turn_id IS NOT NULL
|
|
41942
|
+
AND status NOT IN ('pending', 'running') AND (id = ? OR created_at < ?)
|
|
41943
|
+
ORDER BY created_at DESC, rowid DESC LIMIT 1`
|
|
41944
|
+
).get(sessionId, target.id, target.created_at);
|
|
41945
|
+
return row?.external_turn_id ?? null;
|
|
41946
|
+
}
|
|
41947
|
+
function snapshotTurnIds(db2, sessionId) {
|
|
41948
|
+
const rows = db2.prepare("SELECT id, external_turn_id FROM turns WHERE session_id = ? AND thread_id IS NULL").all(sessionId);
|
|
41949
|
+
return JSON.stringify(Object.fromEntries(rows.map((r) => [r.id, r.external_turn_id])));
|
|
41950
|
+
}
|
|
41951
|
+
function restoreTurnIds(db2, sessionId, snapshot) {
|
|
41952
|
+
if (!snapshot) return;
|
|
41953
|
+
let ids;
|
|
41954
|
+
try {
|
|
41955
|
+
ids = JSON.parse(snapshot);
|
|
41956
|
+
} catch {
|
|
41957
|
+
return;
|
|
41958
|
+
}
|
|
41959
|
+
const update = db2.prepare("UPDATE turns SET external_turn_id = ? WHERE id = ? AND session_id = ?");
|
|
41960
|
+
for (const [turnId, externalId] of Object.entries(ids)) update.run(externalId, turnId, sessionId);
|
|
41961
|
+
}
|
|
41962
|
+
function applyTurnIdMap(db2, sessionId, map2, upToCreatedAt = null) {
|
|
41963
|
+
if (map2.size === 0) return;
|
|
41964
|
+
const rows = db2.prepare(
|
|
41965
|
+
`SELECT id, external_turn_id FROM turns
|
|
41966
|
+
WHERE session_id = ? AND thread_id IS NULL AND external_turn_id IS NOT NULL` + (upToCreatedAt ? " AND created_at <= ?" : "")
|
|
41967
|
+
).all(...upToCreatedAt ? [sessionId, upToCreatedAt] : [sessionId]);
|
|
41968
|
+
const update = db2.prepare("UPDATE turns SET external_turn_id = ? WHERE id = ?");
|
|
41969
|
+
for (const row of rows) {
|
|
41970
|
+
const mapped = map2.get(row.external_turn_id);
|
|
41971
|
+
if (mapped) update.run(mapped, row.id);
|
|
41972
|
+
}
|
|
41973
|
+
}
|
|
41974
|
+
function dropRewoundTurns(db2, sessionId) {
|
|
41975
|
+
const session = db2.prepare("SELECT rewound_at_turn_id FROM sessions WHERE id = ?").get(sessionId);
|
|
41976
|
+
if (!session?.rewound_at_turn_id) return null;
|
|
41977
|
+
const target = db2.prepare("SELECT created_at FROM turns WHERE id = ?").get(session.rewound_at_turn_id);
|
|
41978
|
+
let threadIds = [];
|
|
41979
|
+
db2.transaction(() => {
|
|
41980
|
+
if (target) {
|
|
41981
|
+
const hidden = "SELECT id FROM turns WHERE session_id = ? AND thread_id IS NULL AND created_at > ?";
|
|
41982
|
+
threadIds = db2.prepare(`SELECT id FROM discussion_threads WHERE session_id = ? AND turn_id IN (${hidden})`).all(sessionId, sessionId, target.created_at).map((r) => r.id);
|
|
41983
|
+
for (const threadId of threadIds) {
|
|
41984
|
+
db2.prepare("DELETE FROM items WHERE turn_id IN (SELECT id FROM turns WHERE thread_id = ?)").run(threadId);
|
|
41985
|
+
db2.prepare("DELETE FROM turns WHERE thread_id = ?").run(threadId);
|
|
41986
|
+
db2.prepare("DELETE FROM discussion_threads WHERE id = ?").run(threadId);
|
|
41987
|
+
}
|
|
41988
|
+
db2.prepare(`DELETE FROM items WHERE turn_id IN (${hidden})`).run(sessionId, target.created_at);
|
|
41989
|
+
db2.prepare("DELETE FROM turns WHERE session_id = ? AND thread_id IS NULL AND created_at > ?").run(
|
|
41990
|
+
sessionId,
|
|
41991
|
+
target.created_at
|
|
41992
|
+
);
|
|
41993
|
+
}
|
|
41994
|
+
db2.prepare(
|
|
41995
|
+
"UPDATE sessions SET rewound_at_turn_id = NULL, pre_rewind_turn_ids = NULL, updated_at = ? WHERE id = ?"
|
|
41996
|
+
).run((/* @__PURE__ */ new Date()).toISOString(), sessionId);
|
|
41997
|
+
})();
|
|
41998
|
+
return { threadIds };
|
|
41999
|
+
}
|
|
42000
|
+
function commitRewind(db2, sessionId, clearThreadBranch4) {
|
|
42001
|
+
const dropped = dropRewoundTurns(db2, sessionId);
|
|
42002
|
+
if (!dropped) return;
|
|
42003
|
+
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
|
|
42004
|
+
broadcast("session:updated", { session });
|
|
42005
|
+
for (const threadId of dropped.threadIds) {
|
|
42006
|
+
clearThreadBranch4?.(sessionId, threadId);
|
|
42007
|
+
broadcast("thread:deleted", { sessionId, threadId });
|
|
42008
|
+
}
|
|
42009
|
+
}
|
|
42010
|
+
|
|
41934
42011
|
// src/routes/session-touch.ts
|
|
41935
42012
|
function markSessionTouched(db2, sessionId) {
|
|
41936
42013
|
const { changes } = db2.prepare("UPDATE sessions SET user_touched = 1 WHERE id = ? AND user_touched = 0").run(sessionId);
|
|
@@ -41940,17 +42017,20 @@ function markSessionTouched(db2, sessionId) {
|
|
|
41940
42017
|
}
|
|
41941
42018
|
|
|
41942
42019
|
// src/routes/session-actions.ts
|
|
42020
|
+
function blankToNull(value) {
|
|
42021
|
+
return value === "" ? null : value;
|
|
42022
|
+
}
|
|
41943
42023
|
function createSession(db2, input) {
|
|
41944
42024
|
const {
|
|
41945
42025
|
title = null,
|
|
41946
42026
|
runtime_type = "codex",
|
|
41947
|
-
model = null,
|
|
41948
|
-
model_reasoning_effort = null,
|
|
41949
42027
|
cwd = null,
|
|
41950
42028
|
runtime_config = null,
|
|
41951
42029
|
origin_app_id = null,
|
|
41952
42030
|
origin_app_workspace = null
|
|
41953
42031
|
} = input;
|
|
42032
|
+
const model = blankToNull(input.model ?? null);
|
|
42033
|
+
const model_reasoning_effort = blankToNull(input.model_reasoning_effort ?? null);
|
|
41954
42034
|
const id = v4_default();
|
|
41955
42035
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41956
42036
|
const maxOrder = db2.prepare("SELECT COALESCE(MAX(sort_order), 0) AS m FROM sessions WHERE cwd = ?").get(cwd ?? null);
|
|
@@ -41982,6 +42062,7 @@ var SessionBusyError = class extends Error {
|
|
|
41982
42062
|
function startTurn(db2, session, { prompt, attachments, originAppId }) {
|
|
41983
42063
|
if (isSessionBusy(db2, session, { mainOnly: true })) throw new SessionBusyError();
|
|
41984
42064
|
const provider = getProvider(session.runtime_type);
|
|
42065
|
+
commitRewind(db2, session.id, provider.clearThreadBranch?.bind(provider));
|
|
41985
42066
|
const turnId = v4_default();
|
|
41986
42067
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41987
42068
|
const attachmentsJson = attachments && attachments.length > 0 ? JSON.stringify(attachments) : null;
|
|
@@ -42160,19 +42241,29 @@ async function registerSessionRoutes(fastify) {
|
|
|
42160
42241
|
}
|
|
42161
42242
|
}, async (request, reply) => {
|
|
42162
42243
|
const { id } = request.params;
|
|
42163
|
-
const
|
|
42244
|
+
const body = request.body || {};
|
|
42245
|
+
const { title, lifecycle, has_unreviewed, runtime_config, runtime_type, cwd, starred } = body;
|
|
42246
|
+
const model = body.model === void 0 ? void 0 : blankToNull(body.model);
|
|
42247
|
+
const model_reasoning_effort = body.model_reasoning_effort === void 0 ? void 0 : blankToNull(body.model_reasoning_effort);
|
|
42164
42248
|
const db2 = getDb();
|
|
42165
42249
|
const existing = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
42166
42250
|
if (!existing) {
|
|
42167
42251
|
return reply.code(404).send({ error: "Session not found" });
|
|
42168
42252
|
}
|
|
42169
|
-
|
|
42170
|
-
|
|
42253
|
+
const providerChanged = runtime_type !== void 0 && runtime_type !== existing.runtime_type;
|
|
42254
|
+
if (providerChanged) {
|
|
42255
|
+
if (existing.is_running) {
|
|
42256
|
+
return reply.code(409).send({ error: "Cannot switch provider while a turn is running" });
|
|
42257
|
+
}
|
|
42258
|
+
if (db2.prepare("SELECT 1 FROM turns WHERE session_id = ? LIMIT 1").get(id)) {
|
|
42259
|
+
return reply.code(409).send({
|
|
42260
|
+
error: "The provider cannot change once the session has turns \u2014 start a new session to use another provider"
|
|
42261
|
+
});
|
|
42262
|
+
}
|
|
42171
42263
|
}
|
|
42172
42264
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42173
42265
|
const updates = ["updated_at = ?"];
|
|
42174
42266
|
const params = [now];
|
|
42175
|
-
let providerChanged = false;
|
|
42176
42267
|
if (title !== void 0) {
|
|
42177
42268
|
updates.push("title = ?");
|
|
42178
42269
|
params.push(title);
|
|
@@ -42189,8 +42280,7 @@ async function registerSessionRoutes(fastify) {
|
|
|
42189
42280
|
updates.push("starred = ?");
|
|
42190
42281
|
params.push(starred);
|
|
42191
42282
|
}
|
|
42192
|
-
if (
|
|
42193
|
-
providerChanged = true;
|
|
42283
|
+
if (providerChanged) {
|
|
42194
42284
|
updates.push("runtime_type = ?");
|
|
42195
42285
|
params.push(runtime_type);
|
|
42196
42286
|
if (model === void 0) {
|
|
@@ -42228,6 +42318,12 @@ async function registerSessionRoutes(fastify) {
|
|
|
42228
42318
|
if (model_reasoning_effort !== void 0) {
|
|
42229
42319
|
updates.push("model_reasoning_effort = ?");
|
|
42230
42320
|
params.push(model_reasoning_effort);
|
|
42321
|
+
if (model_reasoning_effort !== existing.model_reasoning_effort && !providerChanged) {
|
|
42322
|
+
const provider = getProvider(existing.runtime_type);
|
|
42323
|
+
provider.setEffort?.(id, model_reasoning_effort).catch((err) => {
|
|
42324
|
+
console.error(`[patch] setEffort failed for session ${id}:`, err);
|
|
42325
|
+
});
|
|
42326
|
+
}
|
|
42231
42327
|
}
|
|
42232
42328
|
if (runtime_config !== void 0) {
|
|
42233
42329
|
updates.push("runtime_config = ?");
|
|
@@ -42236,10 +42332,14 @@ async function registerSessionRoutes(fastify) {
|
|
|
42236
42332
|
db2.prepare(`UPDATE sessions SET ${updates.join(", ")} WHERE id = ?`).run(...params, id);
|
|
42237
42333
|
if (title !== void 0) markSessionTouched(db2, id);
|
|
42238
42334
|
if (providerChanged || workspaceChanged) {
|
|
42239
|
-
|
|
42240
|
-
|
|
42241
|
-
|
|
42242
|
-
|
|
42335
|
+
const provider = getProvider(existing.runtime_type);
|
|
42336
|
+
commitRewind(db2, id, provider.clearThreadBranch?.bind(provider));
|
|
42337
|
+
db2.prepare(
|
|
42338
|
+
`UPDATE sessions SET external_thread_id = NULL, rewound_at_turn_id = NULL, pre_rewind_thread_id = NULL,
|
|
42339
|
+
pre_rewind_turn_ids = NULL, context_usage = NULL, updated_at = ? WHERE id = ?`
|
|
42340
|
+
).run(now, id);
|
|
42341
|
+
db2.prepare("UPDATE turns SET external_turn_id = NULL WHERE session_id = ? AND thread_id IS NULL").run(id);
|
|
42342
|
+
provider.clearThread(id);
|
|
42243
42343
|
}
|
|
42244
42344
|
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
42245
42345
|
broadcast("session:updated", { session });
|
|
@@ -42276,6 +42376,9 @@ async function registerSessionRoutes(fastify) {
|
|
|
42276
42376
|
if (!targetTurnFull) {
|
|
42277
42377
|
return reply.code(404).send({ error: "Turn not found" });
|
|
42278
42378
|
}
|
|
42379
|
+
if (targetTurnFull.thread_id != null) {
|
|
42380
|
+
return reply.code(400).send({ error: "Cannot rewind to a discussion thread turn" });
|
|
42381
|
+
}
|
|
42279
42382
|
const provider = getProvider(session.runtime_type);
|
|
42280
42383
|
if (provider.rewindRuntime) {
|
|
42281
42384
|
await provider.rewindRuntime(session, targetTurnFull);
|
|
@@ -42288,37 +42391,48 @@ async function registerSessionRoutes(fastify) {
|
|
|
42288
42391
|
targetTurnFull.created_at
|
|
42289
42392
|
);
|
|
42290
42393
|
db2.prepare(
|
|
42291
|
-
"UPDATE sessions SET rewound_at_turn_id = NULL, pre_rewind_thread_id = NULL, updated_at = ? WHERE id = ?"
|
|
42394
|
+
"UPDATE sessions SET rewound_at_turn_id = NULL, pre_rewind_thread_id = NULL, pre_rewind_turn_ids = NULL, updated_at = ? WHERE id = ?"
|
|
42292
42395
|
).run(now2, id);
|
|
42293
42396
|
markSessionTouched(db2, id);
|
|
42294
42397
|
const truncated = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
42295
42398
|
return truncated;
|
|
42296
42399
|
}
|
|
42297
|
-
|
|
42298
|
-
|
|
42299
|
-
db2.prepare(
|
|
42300
|
-
"UPDATE sessions SET rewound_at_turn_id = ?, pre_rewind_thread_id = ?, updated_at = ? WHERE id = ?"
|
|
42301
|
-
).run(turn_id, session.external_thread_id, now, id);
|
|
42302
|
-
console.log(`[rewind] saved pre_rewind_thread_id=${session.external_thread_id} for session ${id}`);
|
|
42303
|
-
} else {
|
|
42304
|
-
db2.prepare(
|
|
42305
|
-
"UPDATE sessions SET rewound_at_turn_id = ?, updated_at = ? WHERE id = ?"
|
|
42306
|
-
).run(turn_id, now, id);
|
|
42307
|
-
console.log(`[rewind] pre_rewind_thread_id already set (${session.pre_rewind_thread_id}) or external_thread_id is null for session ${id}`);
|
|
42308
|
-
}
|
|
42400
|
+
let forkedId = session.external_thread_id;
|
|
42401
|
+
let turnIds = /* @__PURE__ */ new Map();
|
|
42309
42402
|
if (provider.forkSession) {
|
|
42310
42403
|
try {
|
|
42311
|
-
|
|
42312
|
-
if (forkedId) {
|
|
42313
|
-
db2.prepare("UPDATE sessions SET external_thread_id = ?, updated_at = ? WHERE id = ?").run(forkedId, now, id);
|
|
42314
|
-
console.log(`[rewind] forked to ${forkedId} for session ${id}`);
|
|
42315
|
-
} else {
|
|
42316
|
-
console.warn(`[rewind] forkSession returned null for session ${id} (external_thread_id=${session.external_thread_id}, upToMessageId=${targetTurnFull.external_turn_id})`);
|
|
42317
|
-
}
|
|
42404
|
+
forkedId = await provider.forkSession(session, targetTurnFull);
|
|
42318
42405
|
} catch (err) {
|
|
42319
42406
|
console.error(`[rewind] forkSession threw for session ${id}:`, err);
|
|
42407
|
+
return reply.code(409).send({
|
|
42408
|
+
error: `Cannot rewind to this turn: the runtime could not fork its conversation there (${err.message})`
|
|
42409
|
+
});
|
|
42410
|
+
}
|
|
42411
|
+
if (forkedId && provider.forkedTurnIds) {
|
|
42412
|
+
turnIds = await provider.forkedTurnIds(session, forkedId).catch((err) => {
|
|
42413
|
+
console.warn(`[rewind] could not read the turn ids of fork ${forkedId}:`, err);
|
|
42414
|
+
return /* @__PURE__ */ new Map();
|
|
42415
|
+
});
|
|
42320
42416
|
}
|
|
42321
42417
|
}
|
|
42418
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42419
|
+
db2.transaction(() => {
|
|
42420
|
+
if (!session.rewound_at_turn_id) {
|
|
42421
|
+
db2.prepare("UPDATE sessions SET pre_rewind_thread_id = ?, pre_rewind_turn_ids = ? WHERE id = ?").run(
|
|
42422
|
+
session.external_thread_id,
|
|
42423
|
+
snapshotTurnIds(db2, id),
|
|
42424
|
+
id
|
|
42425
|
+
);
|
|
42426
|
+
}
|
|
42427
|
+
db2.prepare("UPDATE sessions SET rewound_at_turn_id = ?, external_thread_id = ?, updated_at = ? WHERE id = ?").run(
|
|
42428
|
+
turn_id,
|
|
42429
|
+
forkedId,
|
|
42430
|
+
now,
|
|
42431
|
+
id
|
|
42432
|
+
);
|
|
42433
|
+
applyTurnIdMap(db2, id, turnIds, targetTurnFull.created_at);
|
|
42434
|
+
})();
|
|
42435
|
+
console.log(`[rewind] session ${id} rewound to ${turn_id}, runtime thread ${forkedId ?? "(none)"}`);
|
|
42322
42436
|
provider.clearThread(id);
|
|
42323
42437
|
markSessionTouched(db2, id);
|
|
42324
42438
|
const updated = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
@@ -42340,10 +42454,17 @@ async function registerSessionRoutes(fastify) {
|
|
|
42340
42454
|
error: "Restore is not available for repoburg sessions \u2014 the rewind permanently deleted the runtime history."
|
|
42341
42455
|
});
|
|
42342
42456
|
}
|
|
42457
|
+
if (session.is_running) {
|
|
42458
|
+
return reply.code(409).send({ error: "Cannot restore while a turn is running" });
|
|
42459
|
+
}
|
|
42343
42460
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42344
|
-
db2.
|
|
42345
|
-
|
|
42346
|
-
|
|
42461
|
+
db2.transaction(() => {
|
|
42462
|
+
restoreTurnIds(db2, id, session.pre_rewind_turn_ids);
|
|
42463
|
+
db2.prepare(
|
|
42464
|
+
`UPDATE sessions SET rewound_at_turn_id = NULL, pre_rewind_thread_id = NULL, pre_rewind_turn_ids = NULL,
|
|
42465
|
+
external_thread_id = COALESCE(pre_rewind_thread_id, external_thread_id), updated_at = ? WHERE id = ?`
|
|
42466
|
+
).run(now, id);
|
|
42467
|
+
})();
|
|
42347
42468
|
getProvider(session.runtime_type).clearThread(id);
|
|
42348
42469
|
markSessionTouched(db2, id);
|
|
42349
42470
|
const updated = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
@@ -42381,78 +42502,88 @@ async function registerSessionRoutes(fastify) {
|
|
|
42381
42502
|
if (targetTurn.thread_id != null) {
|
|
42382
42503
|
return reply.code(400).send({ error: "Cannot branch from a discussion thread turn" });
|
|
42383
42504
|
}
|
|
42505
|
+
const provider = getProvider(session.runtime_type);
|
|
42506
|
+
let forkedId = null;
|
|
42507
|
+
let turnIds = /* @__PURE__ */ new Map();
|
|
42508
|
+
if (provider.forkSession) {
|
|
42509
|
+
const targetTurnFull = db2.prepare("SELECT * FROM turns WHERE id = ?").get(turn_id);
|
|
42510
|
+
try {
|
|
42511
|
+
forkedId = await provider.forkSession(session, targetTurnFull);
|
|
42512
|
+
} catch (err) {
|
|
42513
|
+
console.error(`[branch] forkSession threw for session ${id}:`, err);
|
|
42514
|
+
return reply.code(409).send({
|
|
42515
|
+
error: `Cannot branch from this turn: the runtime could not fork its conversation there (${err.message})`
|
|
42516
|
+
});
|
|
42517
|
+
}
|
|
42518
|
+
if (forkedId && provider.forkedTurnIds) {
|
|
42519
|
+
turnIds = await provider.forkedTurnIds(session, forkedId).catch((err) => {
|
|
42520
|
+
console.warn(`[branch] could not read the turn ids of fork ${forkedId}:`, err);
|
|
42521
|
+
return /* @__PURE__ */ new Map();
|
|
42522
|
+
});
|
|
42523
|
+
}
|
|
42524
|
+
}
|
|
42384
42525
|
const newSessionId = v4_default();
|
|
42385
42526
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42386
42527
|
const newTitle = title || `Branch of ${session.title || session.id.slice(0, 8)}`;
|
|
42387
|
-
db2.
|
|
42388
|
-
`INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status, is_running, lifecycle, has_unreviewed, created_at, updated_at, runtime_config)
|
|
42389
|
-
VALUES (?, ?, ?, ?, ?, ?, NULL, 'active', 0, 'working', 0, ?, ?, ?)`
|
|
42390
|
-
).run(
|
|
42391
|
-
newSessionId,
|
|
42392
|
-
newTitle,
|
|
42393
|
-
session.runtime_type,
|
|
42394
|
-
session.model,
|
|
42395
|
-
session.model_reasoning_effort,
|
|
42396
|
-
session.cwd,
|
|
42397
|
-
now,
|
|
42398
|
-
now,
|
|
42399
|
-
session.runtime_config
|
|
42400
|
-
);
|
|
42401
|
-
const turnRows = db2.prepare(
|
|
42402
|
-
"SELECT * FROM turns WHERE session_id = ? AND thread_id IS NULL AND created_at <= ? ORDER BY created_at ASC"
|
|
42403
|
-
).all(id, targetTurn.created_at);
|
|
42404
|
-
for (const turn of turnRows) {
|
|
42405
|
-
const newTurnId = v4_default();
|
|
42528
|
+
db2.transaction(() => {
|
|
42406
42529
|
db2.prepare(
|
|
42407
|
-
`INSERT INTO
|
|
42408
|
-
VALUES (?, ?, ?, ?, ?, ?, ?,
|
|
42530
|
+
`INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status, is_running, lifecycle, has_unreviewed, created_at, updated_at, runtime_config)
|
|
42531
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, 'active', 0, 'working', 0, ?, ?, ?)`
|
|
42409
42532
|
).run(
|
|
42410
|
-
newTurnId,
|
|
42411
42533
|
newSessionId,
|
|
42412
|
-
|
|
42413
|
-
|
|
42414
|
-
|
|
42415
|
-
|
|
42416
|
-
|
|
42417
|
-
|
|
42418
|
-
|
|
42419
|
-
|
|
42420
|
-
|
|
42421
|
-
turn.origin_name ?? null,
|
|
42422
|
-
turn.created_at,
|
|
42423
|
-
turn.updated_at
|
|
42534
|
+
newTitle,
|
|
42535
|
+
session.runtime_type,
|
|
42536
|
+
session.model,
|
|
42537
|
+
session.model_reasoning_effort,
|
|
42538
|
+
session.cwd,
|
|
42539
|
+
forkedId,
|
|
42540
|
+
now,
|
|
42541
|
+
now,
|
|
42542
|
+
session.runtime_config
|
|
42424
42543
|
);
|
|
42425
|
-
const
|
|
42426
|
-
|
|
42427
|
-
|
|
42544
|
+
const turnRows = db2.prepare(
|
|
42545
|
+
"SELECT * FROM turns WHERE session_id = ? AND thread_id IS NULL AND created_at <= ? ORDER BY created_at ASC"
|
|
42546
|
+
).all(id, targetTurn.created_at);
|
|
42547
|
+
for (const turn of turnRows) {
|
|
42548
|
+
const newTurnId = v4_default();
|
|
42428
42549
|
db2.prepare(
|
|
42429
|
-
`INSERT INTO
|
|
42430
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
|
|
42550
|
+
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, attachments, origin, origin_name, created_at, updated_at)
|
|
42551
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
42431
42552
|
).run(
|
|
42432
|
-
newItemId,
|
|
42433
42553
|
newTurnId,
|
|
42434
|
-
|
|
42435
|
-
|
|
42436
|
-
|
|
42437
|
-
|
|
42438
|
-
|
|
42439
|
-
|
|
42554
|
+
newSessionId,
|
|
42555
|
+
turn.user_prompt,
|
|
42556
|
+
turn.agent_response,
|
|
42557
|
+
turn.thoughts,
|
|
42558
|
+
turn.token_usage,
|
|
42559
|
+
(turn.external_turn_id && turnIds.get(turn.external_turn_id)) ?? turn.external_turn_id,
|
|
42560
|
+
turn.status,
|
|
42561
|
+
turn.error,
|
|
42562
|
+
turn.attachments,
|
|
42563
|
+
turn.origin ?? null,
|
|
42564
|
+
turn.origin_name ?? null,
|
|
42565
|
+
turn.created_at,
|
|
42566
|
+
turn.updated_at
|
|
42440
42567
|
);
|
|
42441
|
-
|
|
42442
|
-
|
|
42443
|
-
|
|
42444
|
-
|
|
42445
|
-
|
|
42446
|
-
|
|
42447
|
-
|
|
42448
|
-
|
|
42449
|
-
|
|
42568
|
+
const itemRows = db2.prepare("SELECT * FROM items WHERE turn_id = ? ORDER BY created_at ASC").all(turn.id);
|
|
42569
|
+
for (const item of itemRows) {
|
|
42570
|
+
const newItemId = v4_default();
|
|
42571
|
+
db2.prepare(
|
|
42572
|
+
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
42573
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
|
|
42574
|
+
).run(
|
|
42575
|
+
newItemId,
|
|
42576
|
+
newTurnId,
|
|
42577
|
+
item.external_item_id,
|
|
42578
|
+
item.type,
|
|
42579
|
+
item.data,
|
|
42580
|
+
item.status,
|
|
42581
|
+
item.created_at,
|
|
42582
|
+
item.updated_at
|
|
42583
|
+
);
|
|
42450
42584
|
}
|
|
42451
|
-
} catch (forkError) {
|
|
42452
|
-
db2.prepare("DELETE FROM sessions WHERE id = ?").run(newSessionId);
|
|
42453
|
-
throw forkError;
|
|
42454
42585
|
}
|
|
42455
|
-
}
|
|
42586
|
+
})();
|
|
42456
42587
|
const newSession = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(newSessionId);
|
|
42457
42588
|
return newSession;
|
|
42458
42589
|
}
|
|
@@ -43819,7 +43950,26 @@ async function registerProviderRoutes(fastify) {
|
|
|
43819
43950
|
);
|
|
43820
43951
|
}
|
|
43821
43952
|
|
|
43953
|
+
// src/providers/runtime-provider.ts
|
|
43954
|
+
var InferenceCredentialsError = class extends Error {
|
|
43955
|
+
};
|
|
43956
|
+
|
|
43822
43957
|
// src/routes/models.ts
|
|
43958
|
+
function inferenceRuntime(id, reply) {
|
|
43959
|
+
const provider = hasProvider(id) ? getProvider(id) : void 0;
|
|
43960
|
+
if (!provider?.getInferenceProviders) {
|
|
43961
|
+
void reply.code(404).send({ error: `Provider ${id} has no inference providers` });
|
|
43962
|
+
return void 0;
|
|
43963
|
+
}
|
|
43964
|
+
return provider;
|
|
43965
|
+
}
|
|
43966
|
+
function sendInferenceError(reply, error51) {
|
|
43967
|
+
if (error51 instanceof InferenceCredentialsError) {
|
|
43968
|
+
return reply.code(400).send({ error: error51.message });
|
|
43969
|
+
}
|
|
43970
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
43971
|
+
return reply.code(503).send({ error: message });
|
|
43972
|
+
}
|
|
43823
43973
|
async function registerModelRoutes(fastify) {
|
|
43824
43974
|
fastify.get(
|
|
43825
43975
|
"/api/providers/:id/models",
|
|
@@ -43831,6 +43981,54 @@ async function registerModelRoutes(fastify) {
|
|
|
43831
43981
|
return getProvider(id).getModels(request.query.cwd);
|
|
43832
43982
|
}
|
|
43833
43983
|
);
|
|
43984
|
+
fastify.get(
|
|
43985
|
+
"/api/providers/:id/inference",
|
|
43986
|
+
async (request, reply) => {
|
|
43987
|
+
const provider = inferenceRuntime(request.params.id, reply);
|
|
43988
|
+
if (!provider) return reply;
|
|
43989
|
+
try {
|
|
43990
|
+
return await provider.getInferenceProviders(request.query.cwd);
|
|
43991
|
+
} catch (error51) {
|
|
43992
|
+
return sendInferenceError(reply, error51);
|
|
43993
|
+
}
|
|
43994
|
+
}
|
|
43995
|
+
);
|
|
43996
|
+
fastify.put(
|
|
43997
|
+
"/api/providers/:id/inference/:inferenceId/credentials",
|
|
43998
|
+
async (request, reply) => {
|
|
43999
|
+
const provider = inferenceRuntime(request.params.id, reply);
|
|
44000
|
+
if (!provider) return reply;
|
|
44001
|
+
if (!provider.setInferenceCredentials) {
|
|
44002
|
+
return reply.code(404).send({ error: "This provider cannot save keys" });
|
|
44003
|
+
}
|
|
44004
|
+
const body = request.body ?? {};
|
|
44005
|
+
const field = (value) => typeof value === "string" ? value : void 0;
|
|
44006
|
+
try {
|
|
44007
|
+
return await provider.setInferenceCredentials(request.params.inferenceId, {
|
|
44008
|
+
apiKey: field(body.apiKey),
|
|
44009
|
+
baseUrl: field(body.baseUrl),
|
|
44010
|
+
cwd: field(body.cwd)
|
|
44011
|
+
});
|
|
44012
|
+
} catch (error51) {
|
|
44013
|
+
return sendInferenceError(reply, error51);
|
|
44014
|
+
}
|
|
44015
|
+
}
|
|
44016
|
+
);
|
|
44017
|
+
fastify.delete(
|
|
44018
|
+
"/api/providers/:id/inference/:inferenceId/credentials",
|
|
44019
|
+
async (request, reply) => {
|
|
44020
|
+
const provider = inferenceRuntime(request.params.id, reply);
|
|
44021
|
+
if (!provider) return reply;
|
|
44022
|
+
if (!provider.removeInferenceCredentials) {
|
|
44023
|
+
return reply.code(404).send({ error: "This provider cannot remove keys" });
|
|
44024
|
+
}
|
|
44025
|
+
try {
|
|
44026
|
+
return await provider.removeInferenceCredentials(request.params.inferenceId, request.query.cwd);
|
|
44027
|
+
} catch (error51) {
|
|
44028
|
+
return sendInferenceError(reply, error51);
|
|
44029
|
+
}
|
|
44030
|
+
}
|
|
44031
|
+
);
|
|
43834
44032
|
}
|
|
43835
44033
|
|
|
43836
44034
|
// src/routes/skills.ts
|
|
@@ -119686,7 +119884,7 @@ function threadParams(session, cwd, browserInstructions) {
|
|
|
119686
119884
|
cwd,
|
|
119687
119885
|
approvalPolicy: "never",
|
|
119688
119886
|
sandbox: sandboxType(config3),
|
|
119689
|
-
model: session.model
|
|
119887
|
+
model: session.model || void 0,
|
|
119690
119888
|
config: threadConfig(config3),
|
|
119691
119889
|
...threadInstructionParams(cwd, browserInstructions)
|
|
119692
119890
|
};
|
|
@@ -120225,8 +120423,8 @@ async function sendTurnRequest(session, entry, threadId, request) {
|
|
|
120225
120423
|
input: request.input,
|
|
120226
120424
|
approvalPolicy: "never",
|
|
120227
120425
|
...policy ? { sandboxPolicy: policy } : {},
|
|
120228
|
-
model: session.model
|
|
120229
|
-
effort: session.model_reasoning_effort
|
|
120426
|
+
model: session.model || void 0,
|
|
120427
|
+
effort: session.model_reasoning_effort || void 0
|
|
120230
120428
|
});
|
|
120231
120429
|
return result.turn.id;
|
|
120232
120430
|
}
|
|
@@ -120695,15 +120893,6 @@ async function getModels() {
|
|
|
120695
120893
|
async function getCommands() {
|
|
120696
120894
|
return CODEX_COMMANDS;
|
|
120697
120895
|
}
|
|
120698
|
-
function forkPoint(db2, sessionId, target) {
|
|
120699
|
-
const row = db2.prepare(
|
|
120700
|
-
`SELECT external_turn_id FROM turns
|
|
120701
|
-
WHERE session_id = ? AND thread_id IS NULL AND external_turn_id IS NOT NULL
|
|
120702
|
-
AND status NOT IN ('pending', 'running') AND (id = ? OR created_at < ?)
|
|
120703
|
-
ORDER BY created_at DESC, rowid DESC LIMIT 1`
|
|
120704
|
-
).get(sessionId, target.id, target.created_at);
|
|
120705
|
-
return row?.external_turn_id ?? null;
|
|
120706
|
-
}
|
|
120707
120896
|
async function forkSession(session, targetTurn) {
|
|
120708
120897
|
const threadId = session.external_thread_id;
|
|
120709
120898
|
if (!threadId) return null;
|
|
@@ -121222,7 +121411,7 @@ var codexProvider = {
|
|
|
121222
121411
|
};
|
|
121223
121412
|
|
|
121224
121413
|
// src/claude/claude-provider.ts
|
|
121225
|
-
import { query, forkSession as sdkForkSession } from "@anthropic-ai/claude-agent-sdk";
|
|
121414
|
+
import { query, forkSession as sdkForkSession, importSessionToStore } from "@anthropic-ai/claude-agent-sdk";
|
|
121226
121415
|
import { readFileSync as readFileSync4 } from "fs";
|
|
121227
121416
|
import { tmpdir } from "os";
|
|
121228
121417
|
import { join as join5 } from "path";
|
|
@@ -121983,7 +122172,7 @@ async function ensureSessionStarted(session, mapKey, resumeSessionId, resume, ad
|
|
|
121983
122172
|
}
|
|
121984
122173
|
const options = {
|
|
121985
122174
|
cwd,
|
|
121986
|
-
model: session.model
|
|
122175
|
+
model: session.model || void 0,
|
|
121987
122176
|
permissionMode: "bypassPermissions",
|
|
121988
122177
|
allowDangerouslySkipPermissions: true,
|
|
121989
122178
|
includePartialMessages: true,
|
|
@@ -122193,6 +122382,7 @@ function openPeerTurn(entry, sessionId, peer, db2) {
|
|
|
122193
122382
|
}
|
|
122194
122383
|
if (previous) streamingMessageIds.delete(previous);
|
|
122195
122384
|
const threadId = entry.threadId ?? null;
|
|
122385
|
+
if (!threadId) commitRewind(db2, sessionId, clearThreadBranch2);
|
|
122196
122386
|
const turnId = v4_default();
|
|
122197
122387
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
122198
122388
|
const inputIds = peer.uuid ? JSON.stringify([peer.uuid]) : null;
|
|
@@ -123029,9 +123219,14 @@ function sweepFinishedSessions(now = Date.now()) {
|
|
|
123029
123219
|
async function setModel(sessionId, model) {
|
|
123030
123220
|
const entry = sessionMap2.get(sessionId);
|
|
123031
123221
|
if (!entry) return;
|
|
123032
|
-
await entry.query.setModel(model);
|
|
123222
|
+
await entry.query.setModel(model || void 0);
|
|
123033
123223
|
void refreshContext(entry, sessionId, getDb());
|
|
123034
123224
|
}
|
|
123225
|
+
async function setEffort(sessionId, effort) {
|
|
123226
|
+
const entry = sessionMap2.get(sessionId);
|
|
123227
|
+
if (!entry) return;
|
|
123228
|
+
await entry.query.applyFlagSettings({ effortLevel: effort || null });
|
|
123229
|
+
}
|
|
123035
123230
|
async function stopTask2(sessionId, taskId) {
|
|
123036
123231
|
const entry = sessionMap2.get(sessionId);
|
|
123037
123232
|
if (!entry) return;
|
|
@@ -123055,7 +123250,9 @@ function loadCatalog() {
|
|
|
123055
123250
|
slug: m.value,
|
|
123056
123251
|
displayName: m.displayName,
|
|
123057
123252
|
description: m.description,
|
|
123058
|
-
|
|
123253
|
+
// The SDK names no default effort (its levels list starts at 'low'):
|
|
123254
|
+
// '' = the CLI's own default for the model.
|
|
123255
|
+
defaultReasoning: "",
|
|
123059
123256
|
reasoningLevels: (m.supportedEffortLevels ?? []).map((e) => ({
|
|
123060
123257
|
effort: e,
|
|
123061
123258
|
label: EFFORT_LABELS2[e] ?? e
|
|
@@ -123266,16 +123463,32 @@ async function summarizeClaudeThread(session, thread, transcript, directives) {
|
|
|
123266
123463
|
}
|
|
123267
123464
|
async function forkClaudeSession(session, targetTurn) {
|
|
123268
123465
|
if (!session.external_thread_id) return null;
|
|
123269
|
-
|
|
123270
|
-
|
|
123271
|
-
|
|
123272
|
-
|
|
123273
|
-
|
|
123274
|
-
|
|
123275
|
-
|
|
123276
|
-
|
|
123277
|
-
|
|
123466
|
+
const upToMessageId = forkPoint(getDb(), session.id, targetTurn);
|
|
123467
|
+
if (!upToMessageId) return null;
|
|
123468
|
+
const result = await sdkForkSession(session.external_thread_id, {
|
|
123469
|
+
dir: session.cwd ?? process.cwd(),
|
|
123470
|
+
upToMessageId
|
|
123471
|
+
});
|
|
123472
|
+
return result.sessionId;
|
|
123473
|
+
}
|
|
123474
|
+
async function forkedTurnIds(session, forkedId) {
|
|
123475
|
+
const entries = [];
|
|
123476
|
+
await importSessionToStore(
|
|
123477
|
+
forkedId,
|
|
123478
|
+
{
|
|
123479
|
+
append: async (_key, batch) => {
|
|
123480
|
+
entries.push(...batch);
|
|
123481
|
+
},
|
|
123482
|
+
load: async () => null
|
|
123483
|
+
},
|
|
123484
|
+
{ dir: session.cwd ?? process.cwd(), includeSubagents: false }
|
|
123485
|
+
);
|
|
123486
|
+
const ids = /* @__PURE__ */ new Map();
|
|
123487
|
+
for (const entry of entries) {
|
|
123488
|
+
const source = entry.forkedFrom?.messageUuid;
|
|
123489
|
+
if (typeof source === "string" && entry.uuid) ids.set(source, entry.uuid);
|
|
123278
123490
|
}
|
|
123491
|
+
return ids;
|
|
123279
123492
|
}
|
|
123280
123493
|
var REPLAY_WAIT_MS2 = 3e4;
|
|
123281
123494
|
function startReplay(entry) {
|
|
@@ -123394,8 +123607,15 @@ function describeExit2(exit) {
|
|
|
123394
123607
|
function deadEntry(session, row) {
|
|
123395
123608
|
const gone = () => Promise.reject(new Error("the CLI is gone"));
|
|
123396
123609
|
const entry = {
|
|
123397
|
-
query: {
|
|
123398
|
-
|
|
123610
|
+
query: {
|
|
123611
|
+
getContextUsage: gone,
|
|
123612
|
+
interrupt: gone,
|
|
123613
|
+
setModel: gone,
|
|
123614
|
+
applyFlagSettings: gone,
|
|
123615
|
+
stopTask: gone,
|
|
123616
|
+
close: () => {
|
|
123617
|
+
}
|
|
123618
|
+
},
|
|
123399
123619
|
sessionId: row.external_id,
|
|
123400
123620
|
turnId: row.turn_id,
|
|
123401
123621
|
cwd: session.cwd ?? process.cwd(),
|
|
@@ -123494,8 +123714,10 @@ var claudeProvider = {
|
|
|
123494
123714
|
getModels: getModels2,
|
|
123495
123715
|
getCommands: getCommands2,
|
|
123496
123716
|
forkSession: forkClaudeSession,
|
|
123717
|
+
forkedTurnIds,
|
|
123497
123718
|
summarizeThread: summarizeClaudeThread,
|
|
123498
123719
|
setModel,
|
|
123720
|
+
setEffort,
|
|
123499
123721
|
stopTask: stopTask2,
|
|
123500
123722
|
listBackgroundTasks: listBackgroundTasks2,
|
|
123501
123723
|
resumeInterruptedTurn: resumeInterruptedTurn2,
|
|
@@ -123504,6 +123726,22 @@ var claudeProvider = {
|
|
|
123504
123726
|
};
|
|
123505
123727
|
|
|
123506
123728
|
// src/repoburg/repoburg-client.ts
|
|
123729
|
+
var RepoburgHttpError = class extends Error {
|
|
123730
|
+
constructor(message, status, detail) {
|
|
123731
|
+
super(message);
|
|
123732
|
+
this.status = status;
|
|
123733
|
+
this.detail = detail;
|
|
123734
|
+
}
|
|
123735
|
+
};
|
|
123736
|
+
function errorDetail(body) {
|
|
123737
|
+
const parsed = body;
|
|
123738
|
+
const message = parsed?.error && typeof parsed.error === "object" ? parsed.error.message : parsed?.message;
|
|
123739
|
+
if (typeof message === "string") return message || null;
|
|
123740
|
+
if (Array.isArray(message)) {
|
|
123741
|
+
return message.filter((m) => typeof m === "string").join("; ") || null;
|
|
123742
|
+
}
|
|
123743
|
+
return null;
|
|
123744
|
+
}
|
|
123507
123745
|
function defaultRepoburgBaseUrl() {
|
|
123508
123746
|
return process.env.REPOBURG_BACKEND_URL || "http://localhost:3000";
|
|
123509
123747
|
}
|
|
@@ -123531,7 +123769,12 @@ var RepoburgHttpClient = class {
|
|
|
123531
123769
|
`${method} ${path21} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
123532
123770
|
);
|
|
123533
123771
|
}
|
|
123534
|
-
|
|
123772
|
+
let detail = null;
|
|
123773
|
+
try {
|
|
123774
|
+
detail = errorDetail(JSON.parse(text2));
|
|
123775
|
+
} catch {
|
|
123776
|
+
}
|
|
123777
|
+
throw new RepoburgHttpError(`${method} ${path21} failed: ${response.status} ${text2}`, response.status, detail);
|
|
123535
123778
|
}
|
|
123536
123779
|
if (text2.length === 0) return void 0;
|
|
123537
123780
|
try {
|
|
@@ -123587,6 +123830,26 @@ var RepoburgHttpClient = class {
|
|
|
123587
123830
|
const result = await this.request("GET", "/llm-provider/models");
|
|
123588
123831
|
return result.models ?? [];
|
|
123589
123832
|
}
|
|
123833
|
+
async getInferenceProviders() {
|
|
123834
|
+
const result = await this.request(
|
|
123835
|
+
"GET",
|
|
123836
|
+
"/llm-provider/inference-providers"
|
|
123837
|
+
);
|
|
123838
|
+
return result.providers ?? [];
|
|
123839
|
+
}
|
|
123840
|
+
async setInferenceCredentials(id, dto) {
|
|
123841
|
+
return this.request(
|
|
123842
|
+
"PUT",
|
|
123843
|
+
`/llm-provider/inference-providers/${encodeURIComponent(id)}/credentials`,
|
|
123844
|
+
dto
|
|
123845
|
+
);
|
|
123846
|
+
}
|
|
123847
|
+
async removeInferenceCredentials(id) {
|
|
123848
|
+
return this.request(
|
|
123849
|
+
"DELETE",
|
|
123850
|
+
`/llm-provider/inference-providers/${encodeURIComponent(id)}/credentials`
|
|
123851
|
+
);
|
|
123852
|
+
}
|
|
123590
123853
|
async getSlashCommands() {
|
|
123591
123854
|
return this.request("GET", "/slash-commands");
|
|
123592
123855
|
}
|
|
@@ -124761,22 +125024,27 @@ function cleanTitle(raw) {
|
|
|
124761
125024
|
}
|
|
124762
125025
|
|
|
124763
125026
|
// src/repoburg/repoburg-provider.ts
|
|
124764
|
-
var
|
|
125027
|
+
var FALLBACK_REASONING_LEVELS = [
|
|
124765
125028
|
{ effort: "low", label: "Low" },
|
|
124766
125029
|
{ effort: "medium", label: "Medium" },
|
|
124767
125030
|
{ effort: "high", label: "High" },
|
|
124768
125031
|
{ effort: "xhigh", label: "Extra High" }
|
|
124769
125032
|
];
|
|
124770
|
-
var
|
|
124771
|
-
|
|
124772
|
-
|
|
124773
|
-
|
|
124774
|
-
|
|
124775
|
-
|
|
124776
|
-
|
|
124777
|
-
|
|
124778
|
-
|
|
124779
|
-
|
|
125033
|
+
var FALLBACK_OLLAMA_LEVELS = FALLBACK_REASONING_LEVELS.filter((l) => l.effort !== "xhigh");
|
|
125034
|
+
var RUNTIME_EFFORTS = /* @__PURE__ */ new Set(["none", "minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
125035
|
+
function mapReasoningEffort(effort) {
|
|
125036
|
+
return effort && RUNTIME_EFFORTS.has(effort) ? effort : void 0;
|
|
125037
|
+
}
|
|
125038
|
+
var INFERENCE_PROVIDER_IDS = /* @__PURE__ */ new Set(["ollama", "zai", "alibaba", "openrouter", "openai"]);
|
|
125039
|
+
function inferenceProviderOf(modelId) {
|
|
125040
|
+
const slash = modelId.indexOf("/");
|
|
125041
|
+
if (slash <= 0) return void 0;
|
|
125042
|
+
const prefix = modelId.slice(0, slash);
|
|
125043
|
+
return INFERENCE_PROVIDER_IDS.has(prefix) ? prefix : "openrouter";
|
|
125044
|
+
}
|
|
125045
|
+
function httpStatus(error51) {
|
|
125046
|
+
const status = error51?.status;
|
|
125047
|
+
return typeof status === "number" ? status : void 0;
|
|
124780
125048
|
}
|
|
124781
125049
|
var sessionMap3 = /* @__PURE__ */ new Map();
|
|
124782
125050
|
var STALLED_STREAM_MS = 6e4;
|
|
@@ -124798,7 +125066,7 @@ async function ensureSession(session, client, baseUrl) {
|
|
|
124798
125066
|
repoburgSessionId: session.external_thread_id,
|
|
124799
125067
|
client,
|
|
124800
125068
|
baseUrl,
|
|
124801
|
-
modelId: session.model
|
|
125069
|
+
modelId: session.model || null,
|
|
124802
125070
|
// undefined forces a re-push on the next turn — heals sessions created
|
|
124803
125071
|
// before unsafe effort values (e.g. ollama xhigh) were clamped.
|
|
124804
125072
|
reasoningEffort: void 0,
|
|
@@ -124810,10 +125078,10 @@ async function ensureSession(session, client, baseUrl) {
|
|
|
124810
125078
|
sessionMap3.set(session.id, entry2);
|
|
124811
125079
|
return entry2;
|
|
124812
125080
|
}
|
|
124813
|
-
const mappedEffort = mapReasoningEffort(session.
|
|
125081
|
+
const mappedEffort = mapReasoningEffort(session.model_reasoning_effort);
|
|
124814
125082
|
const created = await client.createSession({
|
|
124815
125083
|
session_title: session.title ?? void 0,
|
|
124816
|
-
model_id: session.model
|
|
125084
|
+
model_id: session.model || void 0,
|
|
124817
125085
|
reasoning_effort: mappedEffort
|
|
124818
125086
|
});
|
|
124819
125087
|
const db2 = getDb();
|
|
@@ -124828,7 +125096,7 @@ async function ensureSession(session, client, baseUrl) {
|
|
|
124828
125096
|
repoburgSessionId: created.id,
|
|
124829
125097
|
client,
|
|
124830
125098
|
baseUrl,
|
|
124831
|
-
modelId: session.model
|
|
125099
|
+
modelId: session.model || null,
|
|
124832
125100
|
reasoningEffort: mappedEffort,
|
|
124833
125101
|
threadId: null,
|
|
124834
125102
|
contextWindow: null,
|
|
@@ -124848,8 +125116,8 @@ async function ensureThreadSession(session, turn, client, baseUrl) {
|
|
|
124848
125116
|
if (!runtimeId) {
|
|
124849
125117
|
const created = await client.createSession({
|
|
124850
125118
|
session_title: session.title ? `Discussion: ${session.title}` : "Discussion",
|
|
124851
|
-
model_id: session.model
|
|
124852
|
-
reasoning_effort: mapReasoningEffort(session.
|
|
125119
|
+
model_id: session.model || void 0,
|
|
125120
|
+
reasoning_effort: mapReasoningEffort(session.model_reasoning_effort)
|
|
124853
125121
|
});
|
|
124854
125122
|
runtimeId = created.id;
|
|
124855
125123
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -124864,7 +125132,7 @@ async function ensureThreadSession(session, turn, client, baseUrl) {
|
|
|
124864
125132
|
repoburgSessionId: runtimeId,
|
|
124865
125133
|
client,
|
|
124866
125134
|
baseUrl,
|
|
124867
|
-
modelId: session.model
|
|
125135
|
+
modelId: session.model || null,
|
|
124868
125136
|
reasoningEffort: void 0,
|
|
124869
125137
|
// re-pushed on the first thread turn
|
|
124870
125138
|
threadId: turn.thread_id,
|
|
@@ -125054,8 +125322,8 @@ async function startTurn4(session, turn) {
|
|
|
125054
125322
|
entry.baseUrl = baseUrl;
|
|
125055
125323
|
entry.client = client;
|
|
125056
125324
|
}
|
|
125057
|
-
const wantedModel = session.model
|
|
125058
|
-
const wantedEffort = mapReasoningEffort(session.
|
|
125325
|
+
const wantedModel = session.model || null;
|
|
125326
|
+
const wantedEffort = mapReasoningEffort(session.model_reasoning_effort);
|
|
125059
125327
|
if (wantedModel !== entry.modelId || wantedEffort !== entry.reasoningEffort) {
|
|
125060
125328
|
try {
|
|
125061
125329
|
await entry.client.patchSession(entry.repoburgSessionId, {
|
|
@@ -125335,18 +125603,72 @@ async function getModels3(cwd) {
|
|
|
125335
125603
|
const resolved = await resolveBackendUrl(cwd ?? process.cwd(), { autoStart: false });
|
|
125336
125604
|
if (!resolved) return [];
|
|
125337
125605
|
const models = await new RepoburgHttpClient(resolved.baseUrl).getModels();
|
|
125338
|
-
return models.map((m) =>
|
|
125339
|
-
|
|
125340
|
-
|
|
125341
|
-
|
|
125342
|
-
|
|
125343
|
-
|
|
125344
|
-
|
|
125345
|
-
|
|
125606
|
+
return models.map((m) => {
|
|
125607
|
+
const levels = m.reasoning_levels ?? (m.id.startsWith("ollama/") ? FALLBACK_OLLAMA_LEVELS : FALLBACK_REASONING_LEVELS);
|
|
125608
|
+
const inferenceProvider = m.provider ?? inferenceProviderOf(m.id);
|
|
125609
|
+
return {
|
|
125610
|
+
slug: m.id,
|
|
125611
|
+
displayName: m.name,
|
|
125612
|
+
description: m.description ?? "Repoburg backend",
|
|
125613
|
+
// '' = the model's own default, which the runtime does not name.
|
|
125614
|
+
defaultReasoning: m.default_reasoning ?? (m.reasoning_levels ? "" : "medium"),
|
|
125615
|
+
reasoningLevels: levels,
|
|
125616
|
+
...inferenceProvider ? { inferenceProvider } : {},
|
|
125617
|
+
...m.aliases?.length ? { aliases: m.aliases } : {},
|
|
125618
|
+
...m.capabilities ? { capabilities: m.capabilities } : {},
|
|
125619
|
+
...m.context_window ? { contextWindow: m.context_window } : {}
|
|
125620
|
+
};
|
|
125621
|
+
});
|
|
125346
125622
|
} catch {
|
|
125347
125623
|
return [];
|
|
125348
125624
|
}
|
|
125349
125625
|
}
|
|
125626
|
+
async function runtimeFor(cwd) {
|
|
125627
|
+
const resolved = await resolveBackendUrl(cwd ?? process.cwd(), { autoStart: Boolean(cwd) });
|
|
125628
|
+
if (!resolved) {
|
|
125629
|
+
throw new Error("Repoburg is not running for this workspace.");
|
|
125630
|
+
}
|
|
125631
|
+
return new RepoburgHttpClient(resolved.baseUrl);
|
|
125632
|
+
}
|
|
125633
|
+
async function getInferenceProviders(cwd) {
|
|
125634
|
+
const client = await runtimeFor(cwd);
|
|
125635
|
+
try {
|
|
125636
|
+
return await client.getInferenceProviders();
|
|
125637
|
+
} catch (error51) {
|
|
125638
|
+
if (httpStatus(error51) === 404) return [];
|
|
125639
|
+
throw error51;
|
|
125640
|
+
}
|
|
125641
|
+
}
|
|
125642
|
+
async function setInferenceCredentials(id, input) {
|
|
125643
|
+
const client = await runtimeFor(input.cwd);
|
|
125644
|
+
try {
|
|
125645
|
+
return await client.setInferenceCredentials(id, {
|
|
125646
|
+
...input.apiKey ? { apiKey: input.apiKey } : {},
|
|
125647
|
+
...input.baseUrl ? { baseUrl: input.baseUrl } : {}
|
|
125648
|
+
});
|
|
125649
|
+
} catch (error51) {
|
|
125650
|
+
throw credentialsError(error51);
|
|
125651
|
+
}
|
|
125652
|
+
}
|
|
125653
|
+
async function removeInferenceCredentials(id, cwd) {
|
|
125654
|
+
const client = await runtimeFor(cwd);
|
|
125655
|
+
try {
|
|
125656
|
+
return await client.removeInferenceCredentials(id);
|
|
125657
|
+
} catch (error51) {
|
|
125658
|
+
throw credentialsError(error51);
|
|
125659
|
+
}
|
|
125660
|
+
}
|
|
125661
|
+
function credentialsError(error51) {
|
|
125662
|
+
const status = httpStatus(error51);
|
|
125663
|
+
if (status === 400) {
|
|
125664
|
+
const detail = error51.detail;
|
|
125665
|
+
return new InferenceCredentialsError(detail || "The provider refused the key.");
|
|
125666
|
+
}
|
|
125667
|
+
if (status === 404) {
|
|
125668
|
+
return new InferenceCredentialsError("This Repoburg version cannot save keys here. Update Repoburg.");
|
|
125669
|
+
}
|
|
125670
|
+
return error51;
|
|
125671
|
+
}
|
|
125350
125672
|
async function getCommands3(cwd) {
|
|
125351
125673
|
try {
|
|
125352
125674
|
const resolved = await resolveBackendUrl(cwd ?? process.cwd(), { autoStart: false });
|
|
@@ -125371,6 +125693,9 @@ var repoburgProvider = {
|
|
|
125371
125693
|
clearThreadBranch: clearThreadBranch3,
|
|
125372
125694
|
clearAllThreads: clearAllThreads3,
|
|
125373
125695
|
getModels: getModels3,
|
|
125696
|
+
getInferenceProviders,
|
|
125697
|
+
setInferenceCredentials,
|
|
125698
|
+
removeInferenceCredentials,
|
|
125374
125699
|
getCommands: getCommands3,
|
|
125375
125700
|
rewindRuntime,
|
|
125376
125701
|
forkSession: forkSession2,
|