@istarry/dsh-chat-edit 0.1.0 → 0.1.1

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/lib/index.js +33 -14
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -576,10 +576,10 @@ async function createSeededSession(ctx, seed, sourceSessionId) {
576
576
  for (const event of seed) {
577
577
  if (event.type !== "model/selection") continue;
578
578
  const data = event.data;
579
- if (data?.next?.provider !== void 0 && data.next.model !== void 0) {
580
- provider = data.next.provider;
581
- model = data.next.model;
582
- reasoningEffort = data.next.reasoningEffort;
579
+ if (data?.provider !== void 0 && data.model !== void 0) {
580
+ provider = data.provider;
581
+ model = data.model;
582
+ reasoningEffort = data.reasoningEffort;
583
583
  }
584
584
  }
585
585
  if (provider === void 0 || model === void 0) {
@@ -591,17 +591,36 @@ async function createSeededSession(ctx, seed, sourceSessionId) {
591
591
  reasoningEffort = sel?.reasoningEffort;
592
592
  } catch {}
593
593
  }
594
- let agentPreset;
595
- let setup;
596
594
  const query = ctx.get("sessionQuery");
597
- if (query !== void 0 && typeof agents.presetForObservation === "function" && typeof agents.composeAgent === "function") try {
598
- const observation = await query.observeSession(SessionId(sourceSessionId));
599
- const composition = await agents.composeAgent(agents.presetForObservation(observation));
600
- agentPreset = composition.agentPreset;
601
- setup = composition.setup;
602
- } catch (reason) {
603
- console.warn("reply-edit: agent composition failed, falling back to defaults:", reason);
604
- }
595
+ const composer = ctx.get("sessionController")?.agents;
596
+ const presets = ctx.get("agentPresets");
597
+ if (query === void 0 || composer === void 0 && presets === void 0) throw new RemoteError("gateway/internal", "reply-edit: cannot compose an Agent preset for the new session; refusing to create a crippled session", {});
598
+ const composition = await (async () => {
599
+ const env_2 = {
600
+ stack: [],
601
+ error: void 0,
602
+ hasError: false
603
+ };
604
+ try {
605
+ const observation = __addDisposableResource(env_2, await query.observeSession(SessionId(sourceSessionId)), false);
606
+ if (composer !== void 0 && typeof composer.composeAgent === "function" && typeof composer.presetForObservation === "function") return await composer.composeAgent(composer.presetForObservation(observation));
607
+ if (presets === void 0) throw new RemoteError("gateway/internal", "reply-edit: no Agent preset service; refusing to create a crippled session", {});
608
+ const projected = observation;
609
+ const resolvedId = (await presets.resolve(projected.projections?.values?.agentPreset)).id;
610
+ return {
611
+ agentPreset: resolvedId,
612
+ setup: (agentCtx) => presets.mount(agentCtx, resolvedId)
613
+ };
614
+ } catch (e_2) {
615
+ env_2.error = e_2;
616
+ env_2.hasError = true;
617
+ } finally {
618
+ __disposeResources(env_2);
619
+ }
620
+ })();
621
+ const agentPreset = composition.agentPreset;
622
+ const setup = composition.setup;
623
+ if (setup === void 0) throw new RemoteError("gateway/internal", "reply-edit: Agent composition produced no setup; refusing to create a crippled session", {});
605
624
  const childId = `session-${randomUUID()}`;
606
625
  let inheritedEventCount = seed.length;
607
626
  for (const [index, event] of seed.entries()) if (event.type === "session/end-seed" && event.data.inherited === true) inheritedEventCount = index;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@istarry/dsh-chat-edit",
3
3
  "description": "DSH 对话编辑:用户消息改完即重新生成,AI 回复的正文也能改——改完开一条新对话从改过的内容继续,原对话结构一点不动",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",