@vibedeckx/linux-x64 0.2.1 → 0.2.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.
Files changed (2) hide show
  1. package/dist/bin.js +149 -48
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -223716,6 +223716,17 @@ var AgentSessionManager = class {
223716
223716
  setEventBus(eventBus) {
223717
223717
  this.eventBus = eventBus;
223718
223718
  }
223719
+ /**
223720
+ * Broadcast a freshly-generated title on the global event bus so the sidebar
223721
+ * (`useResidentSessions`) updates regardless of which workspace is currently
223722
+ * focused. The per-session WS `titleUpdated` broadcast only reaches the one
223723
+ * mounted AgentConversation, which is lost when the user navigates to another
223724
+ * workspace before the ~1-2s title generation completes. Used by both the
223725
+ * local title path and the remote proxy path.
223726
+ */
223727
+ emitSessionTitle(projectId, branch, sessionId, title) {
223728
+ this.eventBus?.emit({ type: "session:title", projectId, branch, sessionId, title });
223729
+ }
223719
223730
  /**
223720
223731
  * Single emit path for `branch:activity` events. Derives the current
223721
223732
  * activity from local DB state (the source of truth — see
@@ -225146,7 +225157,7 @@ ${details}`;
225146
225157
  * Returns the new session id, or null when the source is unknown or has
225147
225158
  * no persisted history to copy.
225148
225159
  */
225149
- async branchSession(sourceSessionId, agentTypeOverride) {
225160
+ async branchSession(sourceSessionId, agentTypeOverride, opts = {}) {
225150
225161
  const source = this.sessions.get(sourceSessionId);
225151
225162
  const sourceRow = await this.storage.agentSessions.getById(sourceSessionId);
225152
225163
  if (!source && !sourceRow) return null;
@@ -225158,7 +225169,7 @@ ${details}`;
225158
225169
  const branch = source?.branch ?? (sourceRow.branch || null);
225159
225170
  const permissionMode = source?.permissionMode ?? (sourceRow?.permission_mode === "plan" ? "plan" : "edit");
225160
225171
  const agentType = agentTypeOverride ?? source?.agentType ?? (sourceRow?.agent_type || "claude-code");
225161
- const newId = randomUUID();
225172
+ const newId = opts.sessionId ?? randomUUID();
225162
225173
  await this.storage.agentSessions.create({
225163
225174
  id: newId,
225164
225175
  project_id: projectId,
@@ -225204,7 +225215,8 @@ ${details}`;
225204
225215
  eventChain: Promise.resolve(),
225205
225216
  bgSpawnHintsThisTurn: 0,
225206
225217
  taskStartedThisTurn: 0,
225207
- lastActiveAt: Date.now()
225218
+ lastActiveAt: Date.now(),
225219
+ crossRemoteMcp: opts.crossRemoteMcp
225208
225220
  };
225209
225221
  this.sessions.set(newId, branched);
225210
225222
  await this.emitDerivedBranchActivity(projectId, branch);
@@ -225249,6 +225261,7 @@ ${details}`;
225249
225261
  if (!dbRow || dbRow.title !== null && dbRow.title !== void 0) return;
225250
225262
  await this.storage.agentSessions.updateTitle(session.id, finalTitle);
225251
225263
  this.broadcastRaw(session.id, { titleUpdated: { title: finalTitle } });
225264
+ this.emitSessionTitle(session.projectId, session.branch, session.id, finalTitle);
225252
225265
  } catch (error48) {
225253
225266
  console.error(`[AgentSession] Failed to persist generated title for ${session.id}:`, error48);
225254
225267
  }
@@ -225868,6 +225881,12 @@ async function generateAndPushRemoteSessionTitle(deps, localSessionId, userText,
225868
225881
  localSessionId,
225869
225882
  JSON.stringify({ titleUpdated: { title: finalTitle } })
225870
225883
  );
225884
+ deps.agentSessionManager.emitSessionTitle(
225885
+ projectIdFromRemoteSessionId(localSessionId, remoteInfo),
225886
+ remoteInfo.branch ?? null,
225887
+ localSessionId,
225888
+ finalTitle
225889
+ );
225871
225890
  }
225872
225891
 
225873
225892
  // src/chat-session-manager.ts
@@ -231843,6 +231862,15 @@ function isAncestor(repoPath, ancestor, descendant) {
231843
231862
  return false;
231844
231863
  }
231845
231864
  }
231865
+ function branchContentContainedInTarget(repoPath, branch, target) {
231866
+ try {
231867
+ const mergedTree = git(repoPath, ["merge-tree", "--write-tree", target, branch]).split("\n", 1)[0].trim();
231868
+ const targetTree = revParse(repoPath, `${target}^{tree}`);
231869
+ return targetTree !== null && mergedTree === targetTree;
231870
+ } catch {
231871
+ return false;
231872
+ }
231873
+ }
231846
231874
  function computeBranchMergeStatus(repoPath, branch, target) {
231847
231875
  const branchTip = revParse(repoPath, `refs/heads/${branch}`);
231848
231876
  const targetTip = revParse(repoPath, `refs/heads/${target}`);
@@ -231868,6 +231896,10 @@ function computeBranchMergeStatus(repoPath, branch, target) {
231868
231896
  else if (unmergedCount === 0) status = "merged";
231869
231897
  else if (unmergedCount < lines.length) status = "partial";
231870
231898
  else status = "unmerged";
231899
+ if (unmergedCount > 0 && branchContentContainedInTarget(repoPath, branch, target)) {
231900
+ status = "merged";
231901
+ unmergedCount = 0;
231902
+ }
231871
231903
  }
231872
231904
  statusCache.set(cacheKey, { branchTip, targetTip, status, unmergedCount });
231873
231905
  return { status, unmergedCount };
@@ -233112,6 +233144,41 @@ var routes11 = async (fastify2) => {
233112
233144
  if (!project) return null;
233113
233145
  return remoteInfo;
233114
233146
  }
233147
+ async function performLocalBranch(sourceSessionId, userId, opts) {
233148
+ const sourceRow = await fastify2.storage.agentSessions.getById(sourceSessionId);
233149
+ if (!sourceRow || !await fastify2.storage.projects.getById(sourceRow.project_id, userId)) {
233150
+ return { ok: false, code: 404, error: "Session not found" };
233151
+ }
233152
+ const newSessionId = await fastify2.agentSessionManager.branchSession(
233153
+ sourceSessionId,
233154
+ opts.agentType,
233155
+ { sessionId: opts.sessionId, crossRemoteMcp: opts.crossRemoteMcp }
233156
+ );
233157
+ if (!newSessionId) {
233158
+ return { ok: false, code: 404, error: "Session not found or has no history to branch" };
233159
+ }
233160
+ const session = fastify2.agentSessionManager.getSession(newSessionId);
233161
+ const messages = fastify2.agentSessionManager.getMessages(newSessionId);
233162
+ const dbRow = await fastify2.storage.agentSessions.getById(newSessionId);
233163
+ return {
233164
+ ok: true,
233165
+ payload: {
233166
+ session: {
233167
+ id: newSessionId,
233168
+ projectId: session?.projectId,
233169
+ branch: session?.branch ?? null,
233170
+ status: session?.status || "stopped",
233171
+ permissionMode: session?.permissionMode || "edit",
233172
+ agentType: session?.agentType || "claude-code",
233173
+ title: dbRow?.title ?? null
233174
+ },
233175
+ messages
233176
+ }
233177
+ };
233178
+ }
233179
+ function broadcastRenamedTitle(sessionId, projectId, branch, title) {
233180
+ fastify2.agentSessionManager.emitSessionTitle(projectId, branch, sessionId, title);
233181
+ }
233115
233182
  fastify2.get("/api/agent-providers", async (_req, reply) => {
233116
233183
  const providers2 = getAllProviders().map((provider) => ({
233117
233184
  type: provider.getAgentType(),
@@ -233840,81 +233907,100 @@ var routes11 = async (fastify2) => {
233840
233907
  "/api/agent-sessions/:sessionId/branch",
233841
233908
  async (req, reply) => {
233842
233909
  const { agentType } = req.body || {};
233910
+ const userId = requireAuth(req, reply);
233911
+ if (userId === null) return;
233843
233912
  if (req.params.sessionId.startsWith("remote-")) {
233844
- const userId = requireAuth(req, reply);
233845
- if (userId === null) return;
233846
233913
  const remoteInfo = await getAuthorizedRemoteSessionInfo(req.params.sessionId, userId);
233847
233914
  if (!remoteInfo) {
233848
233915
  return reply.code(404).send({ error: "Remote session not found" });
233849
233916
  }
233917
+ const projectId = projectIdFromRemoteSessionId(req.params.sessionId, remoteInfo);
233918
+ const newRemoteSessionId = randomUUID14();
233919
+ const localSessionId = `remote-${remoteInfo.remoteServerId}-${projectId}-${newRemoteSessionId}`;
233920
+ const crossRemoteMcp2 = await mintCrossRemoteMcpConfig(
233921
+ { storage: fastify2.storage },
233922
+ { userId, sessionId: localSessionId, sourceRemoteServerId: remoteInfo.remoteServerId }
233923
+ );
233850
233924
  const result = await proxyAuto(
233851
233925
  remoteInfo.remoteServerId,
233852
233926
  remoteInfo.remoteUrl,
233853
233927
  remoteInfo.remoteApiKey,
233854
233928
  "POST",
233855
- `/api/agent-sessions/${remoteInfo.remoteSessionId}/branch`,
233856
- { agentType }
233929
+ `/api/path/agent-sessions/${remoteInfo.remoteSessionId}/branch`,
233930
+ { agentType, sessionId: newRemoteSessionId, crossRemoteMcp: crossRemoteMcp2 }
233857
233931
  );
233858
233932
  if (!result.ok) {
233859
233933
  return reply.code(proxyStatus(result)).send(result.data);
233860
233934
  }
233861
233935
  const remoteData = result.data;
233862
- const projectId = projectIdFromRemoteSessionId(req.params.sessionId, remoteInfo);
233863
- const localSessionId = `remote-${remoteInfo.remoteServerId}-${projectId}-${remoteData.session.id}`;
233936
+ if (remoteData.session.id !== newRemoteSessionId) {
233937
+ return reply.code(409).send({ error: "Remote returned an unexpected session id; upgrade the remote" });
233938
+ }
233864
233939
  fastify2.remoteSessionMap.set(localSessionId, {
233865
233940
  remoteServerId: remoteInfo.remoteServerId,
233866
233941
  remoteUrl: remoteInfo.remoteUrl,
233867
233942
  remoteApiKey: remoteInfo.remoteApiKey,
233868
- remoteSessionId: remoteData.session.id,
233943
+ remoteSessionId: newRemoteSessionId,
233869
233944
  branch: remoteInfo.branch ?? null
233870
233945
  });
233871
- await fastify2.storage.remoteSessionMappings.upsert(
233872
- localSessionId,
233873
- projectId,
233874
- remoteInfo.remoteServerId,
233875
- remoteData.session.id,
233876
- remoteInfo.branch ?? null
233877
- );
233878
- await fastify2.storage.remoteSessionMappings.markTitleResolved(localSessionId);
233879
- fastify2.agentSessionManager.markTitleResolved(localSessionId);
233880
- if (remoteData.messages && remoteData.messages.length > 0) {
233881
- const cacheEntry = fastify2.remotePatchCache.getOrCreate(localSessionId);
233882
- if (cacheEntry.messages.length === 0) {
233883
- for (let i = 0; i < remoteData.messages.length; i++) {
233884
- const patch = ConversationPatch.addEntry(i, remoteData.messages[i]);
233885
- fastify2.remotePatchCache.appendMessage(localSessionId, JSON.stringify({ JsonPatch: patch }), true);
233946
+ try {
233947
+ await fastify2.storage.remoteSessionMappings.upsert(
233948
+ localSessionId,
233949
+ projectId,
233950
+ remoteInfo.remoteServerId,
233951
+ newRemoteSessionId,
233952
+ remoteInfo.branch ?? null
233953
+ );
233954
+ await fastify2.storage.remoteSessionMappings.markTitleResolved(localSessionId);
233955
+ fastify2.agentSessionManager.markTitleResolved(localSessionId);
233956
+ if (remoteData.messages && remoteData.messages.length > 0) {
233957
+ const cacheEntry = fastify2.remotePatchCache.getOrCreate(localSessionId);
233958
+ if (cacheEntry.messages.length === 0) {
233959
+ for (let i = 0; i < remoteData.messages.length; i++) {
233960
+ const patch = ConversationPatch.addEntry(i, remoteData.messages[i]);
233961
+ fastify2.remotePatchCache.appendMessage(localSessionId, JSON.stringify({ JsonPatch: patch }), true);
233962
+ }
233886
233963
  }
233887
233964
  }
233965
+ } catch (err) {
233966
+ fastify2.remoteSessionMap.delete(localSessionId);
233967
+ throw err;
233888
233968
  }
233889
233969
  return reply.code(200).send({
233890
233970
  session: { ...remoteData.session, id: localSessionId, projectId },
233891
233971
  messages: remoteData.messages
233892
233972
  });
233893
233973
  }
233894
- const newSessionId = await fastify2.agentSessionManager.branchSession(
233895
- req.params.sessionId,
233896
- agentType
233974
+ const preSessionId = randomUUID14();
233975
+ const crossRemoteMcp = await mintCrossRemoteMcpConfig(
233976
+ { storage: fastify2.storage },
233977
+ { userId, sessionId: preSessionId, sourceRemoteServerId: null }
233897
233978
  );
233898
- if (!newSessionId) {
233899
- return reply.code(404).send({ error: "Session not found or has no history to branch" });
233900
- }
233901
- const session = fastify2.agentSessionManager.getSession(newSessionId);
233902
- const messages = fastify2.agentSessionManager.getMessages(newSessionId);
233903
- const dbRow = await fastify2.storage.agentSessions.getById(newSessionId);
233904
- return reply.code(200).send({
233905
- session: {
233906
- id: newSessionId,
233907
- projectId: session?.projectId,
233908
- branch: session?.branch ?? null,
233909
- status: session?.status || "stopped",
233910
- permissionMode: session?.permissionMode || "edit",
233911
- agentType: session?.agentType || "claude-code",
233912
- title: dbRow?.title ?? null
233913
- },
233914
- messages
233979
+ const branched = await performLocalBranch(req.params.sessionId, userId, {
233980
+ agentType,
233981
+ sessionId: preSessionId,
233982
+ crossRemoteMcp
233915
233983
  });
233984
+ if (!branched.ok) {
233985
+ return reply.code(branched.code).send({ error: branched.error });
233986
+ }
233987
+ return reply.code(200).send(branched.payload);
233916
233988
  }
233917
233989
  );
233990
+ fastify2.post("/api/path/agent-sessions/:sessionId/branch", async (req, reply) => {
233991
+ const { agentType, sessionId, crossRemoteMcp } = req.body || {};
233992
+ const userId = requireAuth(req, reply);
233993
+ if (userId === null) return;
233994
+ const branched = await performLocalBranch(req.params.sessionId, userId, {
233995
+ agentType,
233996
+ sessionId,
233997
+ crossRemoteMcp
233998
+ });
233999
+ if (!branched.ok) {
234000
+ return reply.code(branched.code).send({ error: branched.error });
234001
+ }
234002
+ return reply.code(200).send(branched.payload);
234003
+ });
233918
234004
  fastify2.post(
233919
234005
  "/api/agent-sessions/:sessionId/switch-mode",
233920
234006
  async (req, reply) => {
@@ -234073,6 +234159,7 @@ var routes11 = async (fastify2) => {
234073
234159
  if (title !== null && (typeof title !== "string" || title.length > 200)) {
234074
234160
  return reply.code(400).send({ error: "title must be null or a string up to 200 chars" });
234075
234161
  }
234162
+ const normalizedTitle = title && title.trim().length > 0 ? title.trim() : null;
234076
234163
  if (req.params.sessionId.startsWith("remote-")) {
234077
234164
  const userId = requireAuth(req, reply);
234078
234165
  if (userId === null) return;
@@ -234084,14 +234171,28 @@ var routes11 = async (fastify2) => {
234084
234171
  remoteInfo.remoteApiKey,
234085
234172
  "PATCH",
234086
234173
  `/api/agent-sessions/${remoteInfo.remoteSessionId}/title`,
234087
- { title }
234174
+ { title: normalizedTitle }
234088
234175
  );
234176
+ if (result.ok) {
234177
+ broadcastRenamedTitle(
234178
+ req.params.sessionId,
234179
+ projectIdFromRemoteSessionId(req.params.sessionId, remoteInfo),
234180
+ remoteInfo.branch ?? null,
234181
+ normalizedTitle
234182
+ );
234183
+ }
234089
234184
  return reply.code(proxyStatus(result)).send(result.data);
234090
234185
  }
234091
234186
  const session = await fastify2.storage.agentSessions.getById(req.params.sessionId);
234092
234187
  if (!session) return reply.code(404).send({ error: "Session not found" });
234093
- await fastify2.storage.agentSessions.updateTitle(req.params.sessionId, title);
234094
- return reply.code(200).send({ success: true, title });
234188
+ await fastify2.storage.agentSessions.updateTitle(req.params.sessionId, normalizedTitle);
234189
+ broadcastRenamedTitle(
234190
+ req.params.sessionId,
234191
+ session.project_id,
234192
+ session.branch,
234193
+ normalizedTitle
234194
+ );
234195
+ return reply.code(200).send({ success: true, title: normalizedTitle });
234095
234196
  });
234096
234197
  fastify2.patch("/api/agent-sessions/:sessionId/favorite", async (req, reply) => {
234097
234198
  const { favorited } = req.body;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibedeckx/linux-x64",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Vibedeckx platform binaries for Linux x64",
5
5
  "os": [
6
6
  "linux"