dsh-agent-enhancer 0.3.2 → 0.3.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"session-hook.d.ts","sourceRoot":"","sources":["../../../src/host/auto-route/session-hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AA2OvD,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,gBAAgB,CAAA;CAAE,GACrD,IAAI,CAsEN"}
1
+ {"version":3,"file":"session-hook.d.ts","sourceRoot":"","sources":["../../../src/host/auto-route/session-hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AA4PvD,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,gBAAgB,CAAA;CAAE,GACrD,IAAI,CAuEN"}
@@ -5,6 +5,10 @@ export interface SessionModelPick {
5
5
  readonly model: string;
6
6
  readonly reasoningEffort?: string;
7
7
  }
8
- /** Same priority as the main Auto session hook: pending selection, then last used, then host default. */
8
+ /**
9
+ * Prefer `agent.model.current()` (0.2.2 domain API) over deprecated
10
+ * `sessionProjections.stateOf(session, 'modelSelection')`.
11
+ * Same priority as AgentModel: pending → lastUsed → live options → host default.
12
+ */
9
13
  export declare function projectedSessionModel(ctx: Context, session: Session): SessionModelPick;
10
14
  //# sourceMappingURL=session-selection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-selection.d.ts","sourceRoot":"","sources":["../../../src/host/auto-route/session-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAEvD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAClC;AAOD,yGAAyG;AACzG,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAoBtF"}
1
+ {"version":3,"file":"session-selection.d.ts","sourceRoot":"","sources":["../../../src/host/auto-route/session-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAGvD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAClC;AAYD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB,CA0CtF"}
@@ -1 +1 @@
1
- {"version":3,"file":"dsh.d.ts","sourceRoot":"","sources":["../../../src/host/checkpoint/dsh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAsC5D,qBAAa,qBAAqB;IAGpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAFhC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgF;gBAE5E,GAAG,EAAE,OAAO;IAEzC,cAAc,GAAI,WAAW,SAAS,KAAG,wBAAwB,GAAG,SAAS,CAuC5E;CACF"}
1
+ {"version":3,"file":"dsh.d.ts","sourceRoot":"","sources":["../../../src/host/checkpoint/dsh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAkC5D,qBAAa,qBAAqB;IAGpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAFhC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgF;gBAE5E,GAAG,EAAE,OAAO;IAEzC,cAAc,GAAI,WAAW,SAAS,KAAG,wBAAwB,GAAG,SAAS,CAuC5E;CACF"}
package/lib/index.js CHANGED
@@ -247,9 +247,7 @@ async function buildAuxiliaryModelCatalog(ctx) {
247
247
  function syncIdleLastTurnFromProjection(ctx, agent) {
248
248
  if (agent.status !== "idle") return;
249
249
  const agents = ctx.agents;
250
- const fromAgents = agents.turnBoundaryOf?.(agent.session);
251
- const fromProjection = ctx.sessionProjections.stateOf(agent.session, "turnBoundary");
252
- const lastTurn = fromAgents?.lastTurn ?? fromProjection?.lastTurn;
250
+ const lastTurn = agents.turnBoundaryOf?.(agent.session)?.lastTurn;
253
251
  if (typeof lastTurn !== "number") return;
254
252
  const live = agent;
255
253
  if (live.phase?.kind !== "idle" || live.phase.lastTurn === lastTurn) return;
@@ -2923,10 +2921,24 @@ function clearSessionResolvedRoute(agent) {
2923
2921
  // src/host/auto-route/session-selection.ts
2924
2922
  function projectedSessionModel(ctx, session) {
2925
2923
  try {
2926
- const projections = ctx.get("sessionProjections");
2927
- const state = projections?.stateOf?.(session, "modelSelection");
2928
- if (state?.pending !== void 0 && state.pending !== null) return state.pending;
2929
- if (state?.lastUsed !== void 0 && state.lastUsed !== null) return state.lastUsed;
2924
+ const agents = ctx.get("agents");
2925
+ const agent = agents?.get?.(session.id);
2926
+ const fromModel = agent?.model?.current?.();
2927
+ if (fromModel !== void 0 && typeof fromModel.provider === "string" && fromModel.provider !== "" && typeof fromModel.model === "string" && fromModel.model !== "") {
2928
+ return {
2929
+ provider: fromModel.provider,
2930
+ model: fromModel.model,
2931
+ ...typeof fromModel.reasoningEffort === "string" ? { reasoningEffort: fromModel.reasoningEffort } : {}
2932
+ };
2933
+ }
2934
+ const options = agent?.options;
2935
+ if (typeof options?.provider === "string" && options.provider !== "" && typeof options.model === "string" && options.model !== "") {
2936
+ return {
2937
+ provider: options.provider,
2938
+ model: options.model,
2939
+ ...typeof options.reasoningEffort === "string" ? { reasoningEffort: options.reasoningEffort } : {}
2940
+ };
2941
+ }
2930
2942
  } catch {
2931
2943
  }
2932
2944
  try {
@@ -3623,6 +3635,13 @@ function concreteRoute(selection) {
3623
3635
  };
3624
3636
  }
3625
3637
  function projectedSelection(ctx, agent) {
3638
+ try {
3639
+ const fromModel = agent?.model?.current?.();
3640
+ if (fromModel !== void 0 && typeof fromModel.provider === "string" && fromModel.provider !== "" && typeof fromModel.model === "string" && fromModel.model !== "") {
3641
+ return fromModel;
3642
+ }
3643
+ } catch {
3644
+ }
3626
3645
  const session = agent?.session;
3627
3646
  if (session === void 0) return void 0;
3628
3647
  try {
@@ -3633,17 +3652,26 @@ function projectedSelection(ctx, agent) {
3633
3652
  }
3634
3653
  function fallbackRoute(ctx, agent) {
3635
3654
  try {
3655
+ const projected = concreteRoute(projectedSelection(ctx, agent));
3656
+ if (projected !== void 0) return projected;
3636
3657
  const options = agent?.options;
3637
3658
  const fromOptions = typeof options?.provider === "string" && typeof options.model === "string" ? concreteRoute({ provider: options.provider, model: options.model }) : void 0;
3638
3659
  if (fromOptions !== void 0) return fromOptions;
3639
- const projected = concreteRoute(projectedSelection(ctx, agent));
3640
- if (projected !== void 0) return projected;
3641
3660
  const defaults = softService(ctx, "agentDefaultModel");
3642
3661
  return concreteRoute(defaults?.currentSelection?.());
3643
3662
  } catch {
3644
3663
  return void 0;
3645
3664
  }
3646
3665
  }
3666
+ function shouldRemapAuto(config, agent) {
3667
+ if (isAutoModel(config)) return true;
3668
+ try {
3669
+ const seat = agent?.model?.current?.();
3670
+ return seat !== void 0 && isAutoModel(seat);
3671
+ } catch {
3672
+ return false;
3673
+ }
3674
+ }
3647
3675
  function routeConfig(config, mapped) {
3648
3676
  const { reasoningEffort: _effort, ...rest } = config;
3649
3677
  void _effort;
@@ -3700,10 +3728,12 @@ function installAutoSessionRoute(ctx, options) {
3700
3728
  const llm = ctx.llm;
3701
3729
  const inner = llm.prepareCall.bind(llm);
3702
3730
  const wrapped = async (config, signal, configure) => {
3703
- const keyProbe = activeAgent(ctx) ?? config;
3704
- const depth = resolving.get(keyProbe) ?? 0;
3705
- if (depth > 0 || !isAutoModel(config)) return inner(config, signal, configure);
3706
3731
  const agent = activeAgent(ctx);
3732
+ const keyProbe = agent ?? config;
3733
+ const depth = resolving.get(keyProbe) ?? 0;
3734
+ if (depth > 0 || !shouldRemapAuto(config, asAgent(agent))) {
3735
+ return inner(config, signal, configure);
3736
+ }
3707
3737
  const key = agent ?? config;
3708
3738
  resolving.set(key, (resolving.get(key) ?? 0) + 1);
3709
3739
  try {
@@ -3725,9 +3755,9 @@ function installAutoSessionRoute(ctx, options) {
3725
3755
  if (agent !== void 0) setSessionResolvedRoute(agent, mapped);
3726
3756
  return await inner(routeConfig(config, mapped), signal, configure);
3727
3757
  } finally {
3728
- const next = (resolving.get(key) ?? 1) - 1;
3729
- if (next <= 0) resolving.delete(key);
3730
- else resolving.set(key, next);
3758
+ const nextDepth = (resolving.get(key) ?? 1) - 1;
3759
+ if (nextDepth <= 0) resolving.delete(key);
3760
+ else resolving.set(key, nextDepth);
3731
3761
  }
3732
3762
  };
3733
3763
  llm.prepareCall = wrapped;