@agentconnect.md/daemon 1.0.0-rc.81 → 1.0.0-rc.83

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/dist/index.js CHANGED
@@ -13853,7 +13853,7 @@ async function cloneRepo(agent) {
13853
13853
  return p;
13854
13854
  }
13855
13855
  //#endregion
13856
- //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.0.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/schema/index.js
13856
+ //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.1.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/schema/index.js
13857
13857
  const AGENT_METHODS = {
13858
13858
  initialize: "initialize",
13859
13859
  authenticate: "authenticate",
@@ -13902,7 +13902,7 @@ const CLIENT_METHODS = {
13902
13902
  };
13903
13903
  const PROTOCOL_METHODS = { cancel_request: "$/cancel_request" };
13904
13904
  //#endregion
13905
- //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.0.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.js
13905
+ //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.1.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.js
13906
13906
  const skippedItem = Symbol("skippedItem");
13907
13907
  function defaultOnError(schema, fallback) {
13908
13908
  return schema.catch(fallback);
@@ -13922,7 +13922,7 @@ function vecSkipError(itemSchema) {
13922
13922
  return array(itemSchema.catch(skippedItem)).transform((items) => items.filter((item) => item !== skippedItem));
13923
13923
  }
13924
13924
  //#endregion
13925
- //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.0.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js
13925
+ //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.1.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js
13926
13926
  /**
13927
13927
  * JSON RPC Request Id
13928
13928
  *
@@ -16424,7 +16424,7 @@ object({
16424
16424
  _meta: record(string(), unknown()).nullish()
16425
16425
  });
16426
16426
  //#endregion
16427
- //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.0.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/stream.js
16427
+ //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.1.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/stream.js
16428
16428
  /**
16429
16429
  * Creates an ACP Stream from a pair of newline-delimited JSON streams.
16430
16430
  *
@@ -16505,7 +16505,7 @@ function ndJsonStream(output, input) {
16505
16505
  };
16506
16506
  }
16507
16507
  //#endregion
16508
- //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.0.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js
16508
+ //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.1.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js
16509
16509
  const CANCEL_REQUEST_METHOD = "$/cancel_request";
16510
16510
  function isRecord(value) {
16511
16511
  return typeof value === "object" && value !== null;
@@ -17160,7 +17160,7 @@ var RequestError = class RequestError extends Error {
17160
17160
  }
17161
17161
  };
17162
17162
  //#endregion
17163
- //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.0.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/acp.js
17163
+ //#region ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.1.0_zod@4.4.3/node_modules/@agentclientprotocol/sdk/dist/acp.js
17164
17164
  function emptyObjectResponse(response) {
17165
17165
  return response ?? {};
17166
17166
  }
@@ -17249,9 +17249,20 @@ const methods = {
17249
17249
  const startActiveSession = Symbol("startActiveSession");
17250
17250
  var AcpContext = class {
17251
17251
  cx;
17252
+ currentRequestId;
17252
17253
  /** @internal */
17253
- constructor(cx) {
17254
+ constructor(cx, currentRequestId) {
17254
17255
  this.cx = cx;
17256
+ this.currentRequestId = currentRequestId;
17257
+ }
17258
+ /**
17259
+ * JSON-RPC id of the request currently being handled.
17260
+ *
17261
+ * This is `undefined` for notification handlers and for contexts created
17262
+ * outside an inbound request, such as `connect(...)` and `connectWith(...)`.
17263
+ */
17264
+ get requestId() {
17265
+ return this.currentRequestId;
17255
17266
  }
17256
17267
  /** @internal */
17257
17268
  get connectionContext() {
@@ -17277,12 +17288,12 @@ var AcpContext = class {
17277
17288
  * requests such as `session/prompt`.
17278
17289
  */
17279
17290
  var AgentContext = class AgentContext extends AcpContext {
17280
- constructor(cx) {
17281
- super(cx);
17291
+ constructor(cx, requestId) {
17292
+ super(cx, requestId);
17282
17293
  }
17283
17294
  /** @internal */
17284
- static create(cx) {
17285
- return new AgentContext(cx);
17295
+ static create(cx, requestId) {
17296
+ return new AgentContext(cx, requestId);
17286
17297
  }
17287
17298
  request(method, params, options) {
17288
17299
  const spec = clientRequestSpecsByMethod[method];
@@ -17299,12 +17310,12 @@ var AgentContext = class AgentContext extends AcpContext {
17299
17310
  * receive one as `ctx.agent` when they need to call back into the agent.
17300
17311
  */
17301
17312
  var ClientContext = class ClientContext extends AcpContext {
17302
- constructor(cx) {
17303
- super(cx);
17313
+ constructor(cx, requestId) {
17314
+ super(cx, requestId);
17304
17315
  }
17305
17316
  /** @internal */
17306
- static create(cx) {
17307
- return new ClientContext(cx);
17317
+ static create(cx, requestId) {
17318
+ return new ClientContext(cx, requestId);
17308
17319
  }
17309
17320
  /** @internal */
17310
17321
  [startActiveSession](params, options) {
@@ -17664,7 +17675,7 @@ function notificationSpec(method, params) {
17664
17675
  }
17665
17676
  function registerAppRequest(builder, spec, context, handler) {
17666
17677
  builder.onReceiveRequest(spec.method, (params) => parseParams(spec.params, params), async (params, responder, cx) => {
17667
- const response = await handler(context(params, cx, responder.signal));
17678
+ const response = await handler(context(params, cx, responder.signal, responder.id));
17668
17679
  await responder.respond(spec.mapResponse ? spec.mapResponse(response) : response);
17669
17680
  });
17670
17681
  }
@@ -17726,7 +17737,15 @@ const agentRequestSpecsByMethod = specsByMethod(agentRequestSpecs);
17726
17737
  specsByMethod(agentNotificationSpecs);
17727
17738
  const clientRequestSpecsByMethod = specsByMethod(clientRequestSpecs);
17728
17739
  const clientNotificationSpecsByMethod = specsByMethod(clientNotificationSpecs);
17729
- function clientHandlerContext(params, agent, signal) {
17740
+ function clientRequestContext(params, agent, signal, requestId) {
17741
+ return {
17742
+ params,
17743
+ requestId,
17744
+ signal,
17745
+ agent
17746
+ };
17747
+ }
17748
+ function clientNotificationContext(params, agent, signal) {
17730
17749
  return {
17731
17750
  params,
17732
17751
  signal,
@@ -17854,11 +17873,11 @@ var ClientApp = class {
17854
17873
  return this.notification(spec, handlerOrParams);
17855
17874
  }
17856
17875
  request(spec, handler) {
17857
- registerAppRequest(this.builder, spec, (params, cx, signal) => clientHandlerContext(params, ClientContext.create(cx), signal), handler);
17876
+ registerAppRequest(this.builder, spec, (params, cx, signal, requestId) => clientRequestContext(params, ClientContext.create(cx, requestId), signal, requestId), handler);
17858
17877
  return this;
17859
17878
  }
17860
17879
  notification(spec, handler) {
17861
- registerAppNotification(this.builder, spec, (params, cx, signal) => clientHandlerContext(params, ClientContext.create(cx), signal), handler);
17880
+ registerAppNotification(this.builder, spec, (params, cx, signal) => clientNotificationContext(params, ClientContext.create(cx), signal), handler);
17862
17881
  return this;
17863
17882
  }
17864
17883
  connectConnection(target) {
@@ -18021,6 +18040,22 @@ function installedRuntimes(runtimes, env = process.env) {
18021
18040
  //#region src/acp/acp-host.ts
18022
18041
  const PROTOCOL_VERSION = 1;
18023
18042
  /**
18043
+ * Resolve how to apply `desired` to the select config option tagged `category`.
18044
+ * `{skip}` (with the reason) means nothing should be sent: the runtime
18045
+ * advertises no such selector, doesn't offer the value, or already has it set.
18046
+ */
18047
+ function planConfigSelection(configOptions, category, desired) {
18048
+ const opt = configOptions?.find((o) => o.category === category && o.type === "select");
18049
+ if (!opt || opt.type !== "select") return { skip: `runtime advertises no ${category} selector` };
18050
+ const values = opt.options.flatMap((o) => "group" in o ? o.options : [o]).map((o) => o.value);
18051
+ if (!values.includes(desired)) return { skip: `value "${desired}" not offered (available: ${values.join(", ")})` };
18052
+ if (opt.currentValue === desired) return { skip: `already "${desired}"` };
18053
+ return {
18054
+ configId: opt.id,
18055
+ value: desired
18056
+ };
18057
+ }
18058
+ /**
18024
18059
  * Extract the model selector from a session's `configOptions`. ACP models are an
18025
18060
  * (experimental) session config option tagged `category: "model"`, `type:
18026
18061
  * "select"`; the selectable values (optionally grouped) are the model list.
@@ -18113,10 +18148,42 @@ var AcpHost = class {
18113
18148
  cwd,
18114
18149
  mcpServers
18115
18150
  });
18116
- this.lastModelOptions = modelOptionsFrom(res.configOptions);
18117
18151
  this.live.add(res.sessionId);
18152
+ const configOptions = await this.applySessionConfig(res.sessionId, res.configOptions);
18153
+ this.lastModelOptions = modelOptionsFrom(configOptions);
18118
18154
  return res.sessionId;
18119
18155
  }
18156
+ /**
18157
+ * Apply the desired model / reasoning effort to a fresh session via ACP
18158
+ * `session/set_config_option`. Model first — the effort vocabulary depends on
18159
+ * the selected model, and each response returns the reconciled option set the
18160
+ * next step plans against. Best-effort by design: a runtime without the
18161
+ * selector, an unoffered value, or a failed request logs and moves on — the
18162
+ * session still runs on the runtime's defaults. Returns the final option set.
18163
+ */
18164
+ async applySessionConfig(sessionId, initial) {
18165
+ let options = initial;
18166
+ const prefs = [["model", this.opts.configPrefs?.model], ["thought_level", this.opts.configPrefs?.reasoningEffort]];
18167
+ for (const [category, desired] of prefs) {
18168
+ if (!desired) continue;
18169
+ const plan = planConfigSelection(options, category, desired);
18170
+ if ("skip" in plan) {
18171
+ this.opts.log?.debug(`acp: session config ${category}="${desired}" not applied — ${plan.skip}`);
18172
+ continue;
18173
+ }
18174
+ try {
18175
+ options = (await this.conn.agent.request(methods.agent.session.setConfigOption, {
18176
+ sessionId,
18177
+ configId: plan.configId,
18178
+ value: plan.value
18179
+ })).configOptions;
18180
+ this.opts.log?.info(`acp: session config ${category} set to "${desired}"`);
18181
+ } catch (err) {
18182
+ this.opts.log?.warn(`acp: failed to set session config ${category}="${desired}": ${err.message}`);
18183
+ }
18184
+ }
18185
+ return options;
18186
+ }
18120
18187
  /** The model selector advertised by the most recent session/new, or null if the
18121
18188
  * agent exposed none. Used by the runtime probe to report available models. */
18122
18189
  modelOptions() {
@@ -18142,12 +18209,13 @@ var AcpHost = class {
18142
18209
  async loadSession(sessionId, cwd) {
18143
18210
  this.loadingSessions.add(sessionId);
18144
18211
  try {
18145
- await this.conn.agent.request(methods.agent.session.load, {
18212
+ const res = await this.conn.agent.request(methods.agent.session.load, {
18146
18213
  sessionId,
18147
18214
  cwd,
18148
18215
  mcpServers: []
18149
18216
  });
18150
18217
  this.live.add(sessionId);
18218
+ await this.applySessionConfig(sessionId, res.configOptions);
18151
18219
  this.opts.log?.info(`acp: resumed session ${sessionId} via session/load`);
18152
18220
  } catch (err) {
18153
18221
  this.opts.log?.debug(`acp: session/load failed for ${sessionId} (${err.message}) — will recreate`);
@@ -18229,7 +18297,11 @@ async function runChat(opts) {
18229
18297
  }
18230
18298
  const host = new AcpHost(runtime, {
18231
18299
  onUpdate: renderUpdate(out),
18232
- env: agentChildEnv(agent)
18300
+ env: agentChildEnv(agent),
18301
+ configPrefs: {
18302
+ model: agent.runtimeOverrides?.model,
18303
+ reasoningEffort: agent.reasoningEffort
18304
+ }
18233
18305
  });
18234
18306
  await host.start();
18235
18307
  try {
@@ -23799,11 +23871,15 @@ function watch$1(paths, options = {}) {
23799
23871
  //#endregion
23800
23872
  //#region src/agents/cp-overlay.ts
23801
23873
  /**
23802
- * Runtime config the daemon can only surface to an ACP child as environment
23803
- * variables: ACP `session/new`/`initialize` carry no model or system-prompt
23804
- * field (SDK v1), so model / reasoning / prompt are exposed under `AGENTCONNECT_*`
23805
- * for runtimes that read them. (`runtimeOverrides.env` is applied separately by
23806
- * `agentChildEnv`.) Only emits a key when the value is set.
23874
+ * Runtime config surfaced to the ACP child as environment variables, under
23875
+ * `AGENTCONNECT_*` for runtimes that read them. ACP `session/new`/`initialize`
23876
+ * carry no model / effort / system-prompt field (SDK v1); model + reasoning
23877
+ * effort are additionally applied per session via ACP session config options
23878
+ * (`session/set_config_option`) when the runtime advertises the selectors —
23879
+ * see AcpHost.applySessionConfig — which is how claude-acp actually honors
23880
+ * them. The env remains the only channel for the system prompt and for
23881
+ * runtimes without config options. (`runtimeOverrides.env` is applied
23882
+ * separately by `agentChildEnv`.) Only emits a key when the value is set.
23807
23883
  */
23808
23884
  function cpRuntimeEnv(agent) {
23809
23885
  const out = {};
@@ -23825,9 +23901,11 @@ function signature(a) {
23825
23901
  return JSON.stringify(rest);
23826
23902
  }
23827
23903
  /** Sub-signature over the dimensions that determine the ACP host subprocess —
23828
- * the spawn binary (`runtime`) and the child env / system-prompt seed knobs that
23829
- * are baked into the host at spawn (agentChildEnv + cpRuntimeEnv). A change here
23830
- * means the cached host must be evicted so the next session respawns it fresh. */
23904
+ * the spawn binary (`runtime`) and the knobs baked into the host at construction:
23905
+ * child env / system-prompt seed (agentChildEnv + cpRuntimeEnv) and the session
23906
+ * config prefs (model / reasoningEffort, applied per session via ACP
23907
+ * set_config_option). A change here means the cached host must be evicted so
23908
+ * the next session respawns it fresh. */
23831
23909
  function hostSpawnSig(a) {
23832
23910
  return JSON.stringify({
23833
23911
  runtime: a.runtime,
@@ -84313,6 +84391,10 @@ var Daemon = class Daemon {
84313
84391
  ...agentChildEnv(agent),
84314
84392
  ...cpRuntimeEnv(agent)
84315
84393
  },
84394
+ configPrefs: {
84395
+ model: agent.runtimeOverrides?.model,
84396
+ reasoningEffort: agent.reasoningEffort
84397
+ },
84316
84398
  log: this.log
84317
84399
  });
84318
84400
  }