@moxt-ai/mobius 0.0.466 → 0.0.468

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 (47) hide show
  1. package/dist/{chunk-7P2QHD5S.js → chunk-EQCEQBVF.js} +173 -68
  2. package/dist/{chunk-7P2QHD5S.js.map → chunk-EQCEQBVF.js.map} +3 -3
  3. package/dist/{chunk-CP7CJWBV.js → chunk-F2UGQLBO.js} +2 -2
  4. package/dist/{chunk-CP7CJWBV.js.map → chunk-F2UGQLBO.js.map} +1 -1
  5. package/dist/{cli-6REFJJ5X.js → cli-CMAJVOVM.js} +3 -3
  6. package/dist/cli.js +2 -2
  7. package/dist/engine/acp/adapter/codex/agent-connection.d.ts.map +1 -1
  8. package/dist/engine/acp/adapter/codex/agent-connection.js +2 -0
  9. package/dist/engine/acp/adapter/codex/agent-connection.js.map +1 -1
  10. package/dist/engine/acp/adapter/execution-connections.d.ts.map +1 -1
  11. package/dist/engine/acp/adapter/execution-connections.js +1 -0
  12. package/dist/engine/acp/adapter/execution-connections.js.map +1 -1
  13. package/dist/engine/acp/adapter/session-events.d.ts +3 -1
  14. package/dist/engine/acp/adapter/session-events.d.ts.map +1 -1
  15. package/dist/engine/acp/adapter/session-events.js +1 -0
  16. package/dist/engine/acp/adapter/session-events.js.map +1 -1
  17. package/dist/engine/acp/agent/agent-definition.d.ts +1 -0
  18. package/dist/engine/acp/agent/agent-definition.d.ts.map +1 -1
  19. package/dist/engine/acp/agent/agent-definition.js +8 -1
  20. package/dist/engine/acp/agent/agent-definition.js.map +1 -1
  21. package/dist/engine/acp/agent/in-process-endpoint.d.ts +5 -0
  22. package/dist/engine/acp/agent/in-process-endpoint.d.ts.map +1 -1
  23. package/dist/engine/acp/connection/agent-connection.d.ts +3 -1
  24. package/dist/engine/acp/connection/agent-connection.d.ts.map +1 -1
  25. package/dist/engine/acp/harness/codex/agent.d.ts.map +1 -1
  26. package/dist/engine/acp/harness/codex/agent.js +18 -9
  27. package/dist/engine/acp/harness/codex/agent.js.map +1 -1
  28. package/dist/engine/acp/harness/codex/app-server-protocol.d.ts +8 -0
  29. package/dist/engine/acp/harness/codex/app-server-protocol.d.ts.map +1 -1
  30. package/dist/engine/acp/harness/codex/app-server-protocol.js +5 -2
  31. package/dist/engine/acp/harness/codex/app-server-protocol.js.map +1 -1
  32. package/dist/engine/acp/harness/codex/owned-agent.d.ts +2 -1
  33. package/dist/engine/acp/harness/codex/owned-agent.d.ts.map +1 -1
  34. package/dist/engine/acp/harness/codex/owned-agent.js +100 -31
  35. package/dist/engine/acp/harness/codex/owned-agent.js.map +1 -1
  36. package/dist/engine/acp/harness/codex/session-update.d.ts +3 -1
  37. package/dist/engine/acp/harness/codex/session-update.d.ts.map +1 -1
  38. package/dist/engine/acp/harness/codex/session-update.js.map +1 -1
  39. package/dist/engine/runtime/run.d.ts.map +1 -1
  40. package/dist/engine/runtime/run.js +1 -3
  41. package/dist/engine/runtime/run.js.map +1 -1
  42. package/dist/engine/session/live/agent-session.d.ts.map +1 -1
  43. package/dist/engine/session/live/agent-session.js +29 -10
  44. package/dist/engine/session/live/agent-session.js.map +1 -1
  45. package/dist/engine.js +2 -2
  46. package/package.json +1 -1
  47. /package/dist/{cli-6REFJJ5X.js.map → cli-CMAJVOVM.js.map} +0 -0
@@ -5,7 +5,7 @@ import {
5
5
  __toESM,
6
6
  __using,
7
7
  package_default
8
- } from "./chunk-CP7CJWBV.js";
8
+ } from "./chunk-F2UGQLBO.js";
9
9
 
10
10
  // ../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js
11
11
  var require_ignore = __commonJS({
@@ -77808,12 +77808,16 @@ var threadTurnsSchema = external_exports.array(threadTurnSchema).max(1e5);
77808
77808
  var collaborationModeSchema = external_exports.object({
77809
77809
  mode: external_exports.enum(["default", "plan"])
77810
77810
  });
77811
+ var threadTitleSchema = external_exports.string().transform((value) => value.slice(0, 500));
77812
+ var threadNameResponseSchema = external_exports.object({
77813
+ thread: external_exports.object({ id: boundedText(256), name: threadTitleSchema.nullish() })
77814
+ });
77811
77815
  var threadLifecycleResponseSchema = external_exports.object({
77812
77816
  collaborationMode: collaborationModeSchema.nullish(),
77813
77817
  model: boundedText(256).nullish(),
77814
77818
  reasoningEffort: boundedText(256).nullish(),
77815
77819
  serviceTier: boundedText(256).nullish(),
77816
- thread: external_exports.object({ id: boundedText(256), turns: threadTurnsSchema })
77820
+ thread: threadNameResponseSchema.shape.thread.extend({ turns: threadTurnsSchema })
77817
77821
  });
77818
77822
  var CODEX_HISTORY_TURN_PAGE_LIMIT = 20;
77819
77823
  var threadTurnsPageSchema = external_exports.object({
@@ -77822,7 +77826,6 @@ var threadTurnsPageSchema = external_exports.object({
77822
77826
  });
77823
77827
  var threadResumeResponseSchema = threadLifecycleResponseSchema;
77824
77828
  var threadForkResponseSchema = threadLifecycleResponseSchema;
77825
- var threadTitleSchema = external_exports.string().transform((value) => value.slice(0, 500));
77826
77829
  var threadSummarySchema = external_exports.object({
77827
77830
  cwd: boundedText(2048),
77828
77831
  id: boundedText(256),
@@ -78401,6 +78404,8 @@ var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
78401
78404
  var COMPACT_TIMEOUT_MILLISECONDS = 36e5;
78402
78405
  var COMPACT_ITEM_WAIT_MILLISECONDS = 6e5;
78403
78406
  var NEXT_PROMPT_INSTRUCTION = "Predict the next message the user will send in this conversation. Reply with only that message, written in the user's own voice as they would type it, in one short sentence. Do not use tools. If there is no clear next step, reply with nothing.";
78407
+ var TITLE_INSTRUCTION = "Generate a concise title for this conversation based on what the user wants to accomplish. Ignore setup instructions and tool output. Use the user's language and at most 10 words. Return only the title on one line, without quotes or markdown. Do not use tools.";
78408
+ var TITLE_CHARACTER_LIMIT2 = 80;
78404
78409
  var HOOK_EVENTS_A_SAMPLE_SKIPS = /* @__PURE__ */ new Set([
78405
78410
  "permissionRequest",
78406
78411
  "postToolUse",
@@ -78555,6 +78560,7 @@ var CodexOwnedAcpAgent = class {
78555
78560
  #turnSettledCompaction = false;
78556
78561
  /** The next-prompt sample running for the latest completed turn; a later turn or closing cancels it. */
78557
78562
  #sampling = null;
78563
+ #title = { kind: "untitled" };
78558
78564
  constructor(context) {
78559
78565
  this.#context = context;
78560
78566
  this.#appServer = context.client;
@@ -78563,6 +78569,7 @@ var CodexOwnedAcpAgent = class {
78563
78569
  nativeTurnId = () => this.#nativeTurnId;
78564
78570
  onTerminated = (termination) => {
78565
78571
  this.#cancelSampling();
78572
+ this.#settleTitle();
78566
78573
  if (this.#turn !== null) {
78567
78574
  this.#turn.steeringContent.clear();
78568
78575
  }
@@ -78571,6 +78578,7 @@ var CodexOwnedAcpAgent = class {
78571
78578
  };
78572
78579
  close = async () => {
78573
78580
  this.#cancelSampling();
78581
+ this.#settleTitle();
78574
78582
  if (this.#turn !== null) {
78575
78583
  this.#turn.steeringContent.clear();
78576
78584
  }
@@ -78629,6 +78637,7 @@ var CodexOwnedAcpAgent = class {
78629
78637
  "session_busy"
78630
78638
  );
78631
78639
  }
78640
+ this.#cancelTitleSample();
78632
78641
  const completion = Promise.withResolvers();
78633
78642
  void completion.promise.catch(() => {
78634
78643
  });
@@ -78739,7 +78748,8 @@ var CodexOwnedAcpAgent = class {
78739
78748
  }
78740
78749
  if (method === "thread/name/updated") {
78741
78750
  const threadName = params.threadName;
78742
- if (typeof threadName === "string" && threadName.length > 0) {
78751
+ if (typeof threadName === "string" && threadName.trim().length > 0) {
78752
+ this.#settleTitle();
78743
78753
  await this.#enqueue(async () => {
78744
78754
  await this.#context.emit({ sessionUpdate: "session_info_update", title: threadName });
78745
78755
  });
@@ -79039,6 +79049,7 @@ var CodexOwnedAcpAgent = class {
79039
79049
  throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
79040
79050
  }
79041
79051
  this.#cancelSampling();
79052
+ this.#cancelTitleSample();
79042
79053
  const completion = Promise.withResolvers();
79043
79054
  void completion.promise.catch(() => {
79044
79055
  });
@@ -79080,8 +79091,11 @@ var CodexOwnedAcpAgent = class {
79080
79091
  }
79081
79092
  try {
79082
79093
  const result = await completion.promise;
79083
- if (promptSuggestionTurnId !== void 0 && result.stopReason === "end_turn") {
79084
- this.#sampleNextPrompt(promptSuggestionTurnId, turn.turn.id);
79094
+ if (result.stopReason === "end_turn") {
79095
+ this.#maybeGenerateTitle(turn.turn.id);
79096
+ if (promptSuggestionTurnId !== void 0) {
79097
+ this.#sampleNextPrompt(promptSuggestionTurnId, turn.turn.id);
79098
+ }
79085
79099
  }
79086
79100
  return turn.input.kind === "identified" ? await promptResultWithMessageId2(Promise.resolve(result), turn.input.messageId) : result;
79087
79101
  } catch (cause) {
@@ -79180,51 +79194,107 @@ var CodexOwnedAcpAgent = class {
79180
79194
  const sampling = new AbortController();
79181
79195
  this.#sampling = sampling;
79182
79196
  const signal = AbortSignal.any([sampling.signal, AbortSignal.timeout(SAMPLE_TIMEOUT_MILLISECONDS)]);
79183
- const sample = async () => {
79184
- if (sourceTurnId.length === 0) {
79185
- return { kind: "failed" };
79186
- }
79187
- try {
79188
- const configured = hooksListResponseSchema.parse(
79189
- await this.#appServer.request("hooks/list", { cwds: [this.#context.cwd()] }, signal)
79190
- );
79191
- if (configured.data.some(
79192
- (entry) => entry.hooks.some((hook) => hook.enabled && !HOOK_EVENTS_A_SAMPLE_SKIPS.has(hook.eventName))
79193
- )) {
79194
- return { kind: "unsupported" };
79195
- }
79196
- const response = threadSampleResponseSchema.parse(
79197
- await this.#appServer.request(
79198
- "thread/sample",
79199
- {
79200
- effort: "low",
79201
- expectedTurnId: sourceTurnId,
79202
- prompt: NEXT_PROMPT_INSTRUCTION,
79203
- threadId: this.#context.threadId()
79204
- },
79205
- signal,
79206
- (requestId) => {
79207
- void this.#appServer.request(
79208
- "thread/sample/cancel",
79209
- { requestId },
79210
- AbortSignal.timeout(SAMPLE_CANCEL_TIMEOUT_MILLISECONDS)
79211
- ).catch(() => void 0);
79212
- }
79213
- )
79214
- );
79215
- const text2 = response.text?.trim() ?? "";
79216
- return text2.length === 0 ? { kind: "none" } : { kind: "suggested", text: text2 };
79217
- } catch {
79218
- return { kind: "failed" };
79219
- }
79220
- };
79221
- void sample().then((outcome) => {
79197
+ void this.#sampleText(NEXT_PROMPT_INSTRUCTION, sourceTurnId, signal).then((outcome) => {
79222
79198
  if (this.#sampling === sampling) {
79223
79199
  this.#sampling = null;
79224
79200
  this.#context.onPromptSuggestion?.({ outcome, turnId });
79225
79201
  }
79226
79202
  });
79227
79203
  };
79204
+ #sampleText = async (instruction, sourceTurnId, signal) => {
79205
+ if (sourceTurnId.length === 0) {
79206
+ return { kind: "failed" };
79207
+ }
79208
+ try {
79209
+ const configured = hooksListResponseSchema.parse(
79210
+ await this.#appServer.request("hooks/list", { cwds: [this.#context.cwd()] }, signal)
79211
+ );
79212
+ if (configured.data.some(
79213
+ (entry) => entry.hooks.some((hook) => hook.enabled && !HOOK_EVENTS_A_SAMPLE_SKIPS.has(hook.eventName))
79214
+ )) {
79215
+ return { kind: "unsupported" };
79216
+ }
79217
+ const response = threadSampleResponseSchema.parse(
79218
+ await this.#appServer.request(
79219
+ "thread/sample",
79220
+ {
79221
+ effort: "low",
79222
+ expectedTurnId: sourceTurnId,
79223
+ prompt: instruction,
79224
+ threadId: this.#context.threadId()
79225
+ },
79226
+ signal,
79227
+ (requestId) => {
79228
+ void this.#appServer.request(
79229
+ "thread/sample/cancel",
79230
+ { requestId },
79231
+ AbortSignal.timeout(SAMPLE_CANCEL_TIMEOUT_MILLISECONDS)
79232
+ ).catch(() => void 0);
79233
+ }
79234
+ )
79235
+ );
79236
+ const text2 = response.text?.trim() ?? "";
79237
+ return text2.length === 0 ? { kind: "none" } : { kind: "suggested", text: text2 };
79238
+ } catch {
79239
+ return { kind: "failed" };
79240
+ }
79241
+ };
79242
+ #cancelTitleSample = () => {
79243
+ if (this.#title.kind === "pending") {
79244
+ this.#title.request.abort();
79245
+ this.#title = { kind: "untitled" };
79246
+ }
79247
+ };
79248
+ #settleTitle = () => {
79249
+ this.#cancelTitleSample();
79250
+ this.#title = { kind: "settled" };
79251
+ };
79252
+ #maybeGenerateTitle = (sourceTurnId) => {
79253
+ const target = this.#context.automaticTitle?.();
79254
+ if (target === void 0 || target.signal.aborted || this.#title.kind !== "untitled") {
79255
+ return;
79256
+ }
79257
+ const request = new AbortController();
79258
+ this.#title = { kind: "pending", request };
79259
+ const signal = AbortSignal.any([
79260
+ target.signal,
79261
+ request.signal,
79262
+ AbortSignal.timeout(SAMPLE_TIMEOUT_MILLISECONDS)
79263
+ ]);
79264
+ const threadId = this.#context.threadId();
79265
+ const generate = async () => {
79266
+ const outcome = await this.#sampleText(TITLE_INSTRUCTION, sourceTurnId, signal);
79267
+ if (outcome.kind === "unsupported" && !signal.aborted) {
79268
+ this.#settleTitle();
79269
+ }
79270
+ if (outcome.kind !== "suggested") {
79271
+ return;
79272
+ }
79273
+ const name2 = Array.from(outcome.text.replace(/\s+/gu, " ")).slice(0, TITLE_CHARACTER_LIMIT2).join("").trim();
79274
+ const saved = threadNameResponseSchema.parse(
79275
+ await this.#appServer.request("thread/read", { threadId, includeTurns: false }, signal)
79276
+ );
79277
+ signal.throwIfAborted();
79278
+ if (saved.thread.id !== threadId) {
79279
+ throw new AcpExecutionError("Codex returned a different thread", {}, "invalid_agent_session");
79280
+ }
79281
+ if (!saved.thread.name?.trim()) {
79282
+ await target.publish(name2);
79283
+ }
79284
+ if (this.#title.kind === "pending" && this.#title.request === request) {
79285
+ this.#settleTitle();
79286
+ }
79287
+ };
79288
+ void generate().catch(() => {
79289
+ if (!signal.aborted) {
79290
+ console.warn("Codex could not publish the automatic session title");
79291
+ }
79292
+ }).finally(() => {
79293
+ if (this.#title.kind === "pending" && this.#title.request === request) {
79294
+ this.#title = { kind: "untitled" };
79295
+ }
79296
+ });
79297
+ };
79228
79298
  #completeTurn = async (turn) => {
79229
79299
  const active = this.#turn;
79230
79300
  if (active === null || active.turn.id !== turn.id) {
@@ -80705,6 +80775,7 @@ function promptSuggestionTurn2(meta3) {
80705
80775
  }
80706
80776
  var CodexAcpAgent = class {
80707
80777
  #app;
80778
+ #threadOverrides;
80708
80779
  #appServer;
80709
80780
  terminated;
80710
80781
  #closePromise = null;
@@ -80715,12 +80786,14 @@ var CodexAcpAgent = class {
80715
80786
  #onPromptDelegation;
80716
80787
  #onPromptSuggestion;
80717
80788
  #onUsageQuota;
80718
- /** Whether this app-server serves `thread/sample`, which predicts the member's next prompt. */
80719
- #promptSampling = false;
80789
+ /** Whether this app-server serves `thread/sample` for background title and prompt generation. */
80790
+ #threadSampling = false;
80791
+ #nativeTitlePresent = false;
80720
80792
  #nativeSessionId = "";
80721
80793
  #threadCwd = "";
80722
80794
  #sessionAgent;
80723
80795
  constructor(options) {
80796
+ this.#threadOverrides = options.sessionEnvironment ? { config: { shell_environment_policy: { set: options.sessionEnvironment } } } : {};
80724
80797
  this.#onSessionUpdate = options.onSessionUpdate;
80725
80798
  this.#onBackgroundActivity = options.onBackgroundActivity;
80726
80799
  this.#onPromptDelegation = options.onPromptDelegation;
@@ -80751,6 +80824,7 @@ var CodexAcpAgent = class {
80751
80824
  settings: this.#settings,
80752
80825
  threadId: () => this.#nativeSessionId,
80753
80826
  cwd: () => this.#threadCwd,
80827
+ automaticTitle: () => this.#threadSampling && !this.#nativeTitlePresent ? options.automaticTitle : void 0,
80754
80828
  connection: () => this.#connection,
80755
80829
  emit: this.#emit,
80756
80830
  onBackgroundActivity: (activity) => {
@@ -80777,7 +80851,7 @@ var CodexAcpAgent = class {
80777
80851
  this.#app = agent({ name: "mobius-codex" }).onConnect((connection) => {
80778
80852
  this.#connection = connection;
80779
80853
  }).onRequest(methods.agent.initialize, async () => ({
80780
- _meta: { promptSuggestions: { supported: this.#promptSampling }, steering: { supported: true } },
80854
+ _meta: { promptSuggestions: { supported: this.#threadSampling }, steering: { supported: true } },
80781
80855
  agentCapabilities: {
80782
80856
  loadSession: true,
80783
80857
  promptCapabilities: { embeddedContext: true, image: true },
@@ -80790,7 +80864,7 @@ var CodexAcpAgent = class {
80790
80864
  const created = threadStartResponseSchema.parse(
80791
80865
  await this.#appServer.request(
80792
80866
  "thread/start",
80793
- { cwd: context.params.cwd },
80867
+ { cwd: context.params.cwd, ...this.#threadOverrides },
80794
80868
  AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS3)])
80795
80869
  )
80796
80870
  );
@@ -80820,6 +80894,7 @@ var CodexAcpAgent = class {
80820
80894
  "thread/fork",
80821
80895
  {
80822
80896
  cwd: context.params.cwd,
80897
+ ...this.#threadOverrides,
80823
80898
  // Fork keeps the native context; its response only needs the new identity
80824
80899
  // and settings. History is read through the separate history boundary.
80825
80900
  excludeTurns: true,
@@ -80843,7 +80918,7 @@ var CodexAcpAgent = class {
80843
80918
  };
80844
80919
  }).onRequest(methods.agent.session.prompt, async (context) => {
80845
80920
  const promptSuggestionTurnId = promptSuggestionTurn2(context.params._meta);
80846
- const samples = this.#promptSampling && this.#sessionAgent.runsTurns && !isCompactCommand(context.params.prompt);
80921
+ const samples = this.#threadSampling && this.#sessionAgent.runsTurns && !isCompactCommand(context.params.prompt);
80847
80922
  if (promptSuggestionTurnId !== void 0 && !samples) {
80848
80923
  this.#onPromptSuggestion?.({ outcome: { kind: "unsupported" }, turnId: promptSuggestionTurnId });
80849
80924
  }
@@ -80900,13 +80975,13 @@ var CodexAcpAgent = class {
80900
80975
  initialize = async (signal) => {
80901
80976
  await this.#appServer.initialize(signal);
80902
80977
  await this.#settings.loadModels(signal);
80903
- this.#promptSampling = await this.#probePromptSampling(signal);
80978
+ this.#threadSampling = await this.#probeThreadSampling(signal);
80904
80979
  };
80905
80980
  /**
80906
80981
  * Asks the app-server itself whether it serves `thread/sample`: cancelling a sample that does not exist succeeds
80907
80982
  * there and fails as an unknown method on a release without sampling.
80908
80983
  */
80909
- #probePromptSampling = async (signal) => {
80984
+ #probeThreadSampling = async (signal) => {
80910
80985
  try {
80911
80986
  await this.#appServer.request(
80912
80987
  "thread/sample/cancel",
@@ -80949,7 +81024,7 @@ var CodexAcpAgent = class {
80949
81024
  return threadResumeResponseSchema.parse(
80950
81025
  await this.#appServer.request(
80951
81026
  "thread/resume",
80952
- { cwd, excludeTurns: true, threadId },
81027
+ { cwd, excludeTurns: true, threadId, ...this.#threadOverrides },
80953
81028
  AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS3)])
80954
81029
  )
80955
81030
  );
@@ -80989,13 +81064,14 @@ var CodexAcpAgent = class {
80989
81064
  return;
80990
81065
  }
80991
81066
  this.#nativeSessionId = resumed.thread.id;
81067
+ this.#nativeTitlePresent = Boolean(resumed.thread.name?.trim());
80992
81068
  this.#threadCwd = cwd;
80993
81069
  this.#settings.selectRestoredThread(resumed);
80994
81070
  await this.#settings.probeCollaborationMode(this.#nativeSessionId, signal);
80995
81071
  };
80996
81072
  /** What the session response tells Mobius about the session behavior selected while opening it. */
80997
81073
  #sessionMeta = () => ({
80998
- promptSuggestions: { supported: this.#promptSampling && this.#sessionAgent.runsTurns },
81074
+ promptSuggestions: { supported: this.#threadSampling && this.#sessionAgent.runsTurns },
80999
81075
  steering: { supported: this.#sessionAgent.steeringSupported },
81000
81076
  codex: { runsTurns: this.#sessionAgent.runsTurns }
81001
81077
  });
@@ -81042,6 +81118,8 @@ var CodexAgentConnection = class extends EndpointAgentConnection {
81042
81118
  command: options.command,
81043
81119
  cwd: options.cwd,
81044
81120
  environment: options.environment,
81121
+ ...options.automaticTitle === void 0 ? {} : { automaticTitle: options.automaticTitle },
81122
+ ...options.sessionEnvironment && { sessionEnvironment: options.sessionEnvironment },
81045
81123
  onSessionUpdate: options.client.onUpdate,
81046
81124
  onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity),
81047
81125
  onPromptDelegation: async (stage) => await options.onPromptDelegation?.(stage),
@@ -85420,11 +85498,19 @@ var AcpAgentDefinition = class _AcpAgentDefinition {
85420
85498
  this.#connectionFactory = createConnection;
85421
85499
  }
85422
85500
  createConnection = (options) => this.#connectionFactory({ ...options, command: this.command, environment: this.environment });
85423
- withEnvironment = (environment) => new _AcpAgentDefinition(
85501
+ withEnvironment = (environment) => this.#copy(environment, this.#connectionFactory);
85502
+ withSessionEnvironment = (values) => {
85503
+ const sessionEnvironment = Object.freeze({ ...values });
85504
+ return this.#copy(
85505
+ { ...this.environment, ...sessionEnvironment },
85506
+ (options) => this.#connectionFactory({ ...options, sessionEnvironment })
85507
+ );
85508
+ };
85509
+ #copy = (environment, createConnection) => new _AcpAgentDefinition(
85424
85510
  this.id,
85425
85511
  this.label,
85426
85512
  this.command,
85427
- this.#connectionFactory,
85513
+ createConnection,
85428
85514
  environment,
85429
85515
  this.agentVersion,
85430
85516
  this.agentIdentity,
@@ -87148,6 +87234,7 @@ var AdapterSessionConnection = class {
87148
87234
  this.#connection = options.agent.createConnection({
87149
87235
  cwd: options.cwd,
87150
87236
  client: client2,
87237
+ ...options.automaticTitle === void 0 ? {} : { automaticTitle: options.automaticTitle },
87151
87238
  onBackgroundActivity: (activity) => {
87152
87239
  if (this.#lifetime.signal.aborted) {
87153
87240
  return;
@@ -87354,6 +87441,7 @@ var AcpExecutionConnections = class {
87354
87441
  const connection = new AdapterSessionConnection(
87355
87442
  {
87356
87443
  agent: params.scope.agent,
87444
+ ...params.automaticTitle === void 0 ? {} : { automaticTitle: params.automaticTitle },
87357
87445
  cwd: params.scope.cwd,
87358
87446
  ...params.scope.externalizeUpdate === void 0 ? {} : { externalizeUpdate: params.scope.externalizeUpdate },
87359
87447
  onEvent: (event) => params.onSessionEvent(connection.events.sessionId(), event),
@@ -96964,6 +97052,7 @@ var AgentSession = class _AgentSession {
96964
97052
  #restored = false;
96965
97053
  #sessionTitle = null;
96966
97054
  #generateTitle;
97055
+ #automaticTitle = new AbortController();
96967
97056
  #sessionUpdatedAt = "";
96968
97057
  constructor(agent2, cwd, additionalDirectories, mobiusSessionId, getObserver, agentCommand, store, metrics, adapter, externalize, promptSuggestions, timer, titlePolicy) {
96969
97058
  this.#agentCommand = () => agentCommand(this.#mobiusSessionId);
@@ -96996,6 +97085,7 @@ var AgentSession = class _AgentSession {
96996
97085
  ...externalize === void 0 ? {} : { externalizeUpdate: (update, signal) => externalize(this.#mobiusSessionId, update, signal) }
96997
97086
  };
96998
97087
  this.#subscriber = {
97088
+ ...this.#generateTitle ? { automaticTitle: { signal: this.#automaticTitle.signal, publish: this.#publishAutomaticTitle } } : {},
96999
97089
  onSessionEvent: async (nativeSessionId, event) => {
97000
97090
  if (this.#nativeSessionId.length === 0) {
97001
97091
  this.selectNativeSession(nativeSessionId);
@@ -97641,7 +97731,29 @@ var AgentSession = class _AgentSession {
97641
97731
  this.#nativeIdentity = { kind: "bound", nativeSessionId: sessionId };
97642
97732
  this.#nativeHistoryOwnership = { kind: "agent-owned" };
97643
97733
  };
97734
+ #publishAutomaticTitle = async (title) => {
97735
+ if (this.#automaticTitle.signal.aborted) {
97736
+ return;
97737
+ }
97738
+ await this.#processEvent({
97739
+ kind: "info",
97740
+ changes: [{ kind: "title", value: title }],
97741
+ payload: { sessionUpdate: "session_info_update", title }
97742
+ });
97743
+ };
97644
97744
  #processEvent = async (event) => {
97745
+ if (event.kind === "info") {
97746
+ for (const change of event.changes) {
97747
+ switch (change.kind) {
97748
+ case "title":
97749
+ this.setSessionTitle(change.value);
97750
+ break;
97751
+ case "updated-at":
97752
+ this.#sessionUpdatedAt = change.value;
97753
+ break;
97754
+ }
97755
+ }
97756
+ }
97645
97757
  if (event.kind === "configuration" || event.kind === "mode") {
97646
97758
  this.#configOptions = event.kind === "configuration" ? event.configOptions : this.#configOptions.map(
97647
97759
  (option) => option.category === "mode" ? { ...option, currentValue: event.modeId } : option
@@ -97672,16 +97784,6 @@ var AgentSession = class _AgentSession {
97672
97784
  await this.emitConfigUpdate();
97673
97785
  return;
97674
97786
  case "info":
97675
- for (const change of event.changes) {
97676
- switch (change.kind) {
97677
- case "title":
97678
- this.#sessionTitle = change.value;
97679
- break;
97680
- case "updated-at":
97681
- this.#sessionUpdatedAt = change.value;
97682
- break;
97683
- }
97684
- }
97685
97787
  if (this.#nativeSessionId.length > 0) {
97686
97788
  this.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
97687
97789
  }
@@ -98055,6 +98157,9 @@ var AgentSession = class _AgentSession {
98055
98157
  }
98056
98158
  setSessionTitle(title) {
98057
98159
  this.#sessionTitle = title;
98160
+ if (title.trim().length > 0) {
98161
+ this.#automaticTitle.abort();
98162
+ }
98058
98163
  }
98059
98164
  assertNativeSession = (sessionId) => {
98060
98165
  if (sessionId !== this.#nativeSessionId) {
@@ -105698,7 +105803,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
105698
105803
  const resolveAgent = async (agentId, resolveSignal, sessionId) => {
105699
105804
  const catalogAgent = await resolveCatalogAgent(config2, agentId, resolveSignal);
105700
105805
  const environment = sessionId === void 0 ? void 0 : config2.sessionEnvironment?.({ sessionId, agentId });
105701
- const agent2 = environment === void 0 ? catalogAgent : catalogAgent.withEnvironment({ ...catalogAgent.environment, ...environment });
105806
+ const agent2 = environment === void 0 ? catalogAgent : catalogAgent.withSessionEnvironment(environment);
105702
105807
  return {
105703
105808
  agent: agent2,
105704
105809
  adapter: adapters.resolve(catalogAgent),
@@ -106096,4 +106201,4 @@ export {
106096
106201
  * MIT Licensed
106097
106202
  *)
106098
106203
  */
106099
- //# sourceMappingURL=chunk-7P2QHD5S.js.map
106204
+ //# sourceMappingURL=chunk-EQCEQBVF.js.map