@sessionbus/dsh 0.1.0-pre.7 → 0.1.0-pre.9

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 (3) hide show
  1. package/install.mjs +11 -4
  2. package/package.json +1 -1
  3. package/plugin.cjs +11 -5
package/install.mjs CHANGED
@@ -141,7 +141,8 @@ export function install(profileNames = [], options = {}) {
141
141
  if (!validProfile(name)) throw new Error(`invalid profile name ${JSON.stringify(name)}`);
142
142
  const profile = path.join(home, "profiles", name);
143
143
  const manifestFile = path.join(profile, "package.json");
144
- let manifest = existsSync(manifestFile) ? JSON.parse(readFileSync(manifestFile, "utf8")) : null;
144
+ const existed = existsSync(manifestFile);
145
+ let manifest = existed ? JSON.parse(readFileSync(manifestFile, "utf8")) : null;
145
146
  if (!manifest?.dependencies?.["@sessionbus/dsh"]) {
146
147
  const result = run(["plugin", "--profile", name, "add", "@sessionbus/dsh"]);
147
148
  if (result.status !== 0) throw new Error(String(result.stderr || "dsh plugin add failed").trim());
@@ -153,12 +154,18 @@ export function install(profileNames = [], options = {}) {
153
154
  if (name !== "web") convergePatch(patch, noUploadsID, noUploadsPatch);
154
155
  continue;
155
156
  }
156
- manifest = {
157
- name: "dsh-profile-sessionbus",
158
- private: true,
157
+ if (!existed) manifest = {
158
+ name: "dsh-profile-sessionbus", private: true,
159
159
  dependencies: { "@sessionbus/dsh": manifest.dependencies["@sessionbus/dsh"] },
160
160
  dsh: { profile: { bundles: ["@deepseek-ai/dsh-base"], patchReload: "startup" } },
161
161
  };
162
+ else {
163
+ manifest.dsh ??= {};
164
+ manifest.dsh.profile ??= {};
165
+ manifest.dsh.profile.bundles ??= [];
166
+ if (!Array.isArray(manifest.dsh.profile.bundles)) throw new Error("sessionbus profile bundles must be an array");
167
+ if (!manifest.dsh.profile.bundles.includes("@deepseek-ai/dsh-base")) manifest.dsh.profile.bundles.push("@deepseek-ai/dsh-base");
168
+ }
162
169
  writeChanged(manifestFile, `${JSON.stringify(manifest, null, 2)}\n`);
163
170
  writeChanged(path.join(profile, "cordis.patch.yml"), profilePatch(laneProduct));
164
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sessionbus/dsh",
3
- "version": "0.1.0-pre.7",
3
+ "version": "0.1.0-pre.9",
4
4
  "type": "commonjs",
5
5
  "main": "plugin.cjs",
6
6
  "exports": "./plugin.cjs",
package/plugin.cjs CHANGED
@@ -268,13 +268,14 @@ class NativeSession {
268
268
  }
269
269
 
270
270
  function identity(ctx, agent, product, groups, title) {
271
- const sessionID = String(agent?.session?.id || agent?.id || "");
271
+ const sessionID = String(agent?.session?.id || "");
272
+ if (!text(sessionID)) return;
272
273
  const cwd = agent?.session?.header?.cwd;
273
- if (!text(sessionID) || !text(cwd)) throw new Error("DSH root identity is incomplete");
274
+ if (!text(cwd)) throw new Error("DSH root identity is incomplete");
274
275
  const current = title === undefined ? ctx.sessionTitle.get(agent.session)?.title : title;
275
276
  const provider = agent.options?.provider;
276
277
  const model = agent.options?.model;
277
- return { product, session_id: sessionID, name: text(current) ? current : sessionID, groups: [...groups], info: { cwd, ...(text(provider) && text(model) ? { model: `${provider}/${model}` } : {}) } };
278
+ return { product, session_id: sessionID, ...(text(current) ? { name: current } : {}), groups: [...groups], info: { cwd, ...(text(provider) && text(model) ? { model: `${provider}/${model}` } : {}) } };
278
279
  }
279
280
 
280
281
  function createRuntime(ctx, config, dependencies, prepared) {
@@ -294,6 +295,7 @@ function createRuntime(ctx, config, dependencies, prepared) {
294
295
  if (values.mode !== "peer" || !ready || !root(agent) || peers.has(agent)) return;
295
296
  try {
296
297
  const current = identity(ctx, agent, values.product, values.groups);
298
+ if (!current) return;
297
299
  const peer = dependencies.connectPeer(current, (cancel, request) => native.deliver(cancel, request, agent), connectionEnvironment(values));
298
300
  peers.set(agent, { peer, identity: current, rehello: Promise.resolve() });
299
301
  } catch (error) { warn(error); }
@@ -307,10 +309,14 @@ function createRuntime(ctx, config, dependencies, prepared) {
307
309
  if (event.type !== "session/title") return;
308
310
  const agent = ctx.agents.get(session.id);
309
311
  const record = peers.get(agent);
310
- if (!record || agent.session !== session) return;
312
+ if (!agent || agent.session !== session) return;
313
+ if (!record) return present(agent);
311
314
  const next = identity(ctx, agent, values.product, values.groups, event.data.title);
315
+ if (!next) return;
316
+ const replace = next.session_id !== record.identity.session_id;
312
317
  record.identity = next;
313
- record.rehello = record.rehello.then(() => record.peer.rehello({ name: next.name, info: next.info })).catch(warn);
318
+ // kit rehello is (signal, name, info); a changed durable id needs a full replacement.
319
+ record.rehello = record.rehello.then(() => replace ? record.peer.replace(next) : record.peer.rehello(undefined, next.name, next.info)).catch(warn);
314
320
  }, { global: true });
315
321
  }
316
322
  const caller = (agent) => worker && native.agent === agent ? worker.caller : peers.get(agent)?.peer.caller;