@adhdev/daemon-standalone 0.7.40 → 0.7.41

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
@@ -23033,6 +23033,8 @@ function buildCliSession(state) {
23033
23033
  runtimeWorkspaceLabel: state.runtime?.workspaceLabel,
23034
23034
  runtimeWriteOwner: state.runtime?.writeOwner || null,
23035
23035
  runtimeAttachedClients: state.runtime?.attachedClients || [],
23036
+ launchMode: state.launchMode,
23037
+ mode: state.mode,
23036
23038
  resume: state.resume,
23037
23039
  activeChat,
23038
23040
  capabilities: PTY_SESSION_CAPABILITIES,
@@ -26838,12 +26840,14 @@ init_config();
26838
26840
  init_provider_cli_adapter();
26839
26841
  init_logger();
26840
26842
  var CliProviderInstance = class {
26841
- constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory) {
26843
+ constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory, launchModeId) {
26842
26844
  this.provider = provider;
26843
26845
  this.workingDir = workingDir;
26844
26846
  this.cliArgs = cliArgs;
26845
26847
  this.type = provider.type;
26846
26848
  this.instanceId = instanceId || crypto3.randomUUID();
26849
+ this.launchMode = launchModeId && provider.launchModes?.find((m) => m.id === launchModeId) || null;
26850
+ this.resolvedOutputFormat = this.resolveOutputFormat();
26847
26851
  this.adapter = new ProviderCliAdapter(provider, workingDir, cliArgs, transportFactory);
26848
26852
  this.monitor = new StatusMonitor();
26849
26853
  this.historyWriter = new ChatHistoryWriter();
@@ -26862,6 +26866,26 @@ var CliProviderInstance = class {
26862
26866
  lastApprovalEventAt = 0;
26863
26867
  historyWriter;
26864
26868
  instanceId;
26869
+ launchMode;
26870
+ resolvedOutputFormat;
26871
+ /**
26872
+ * Determine output rendering format from:
26873
+ * 1. launchMode.outputFormat (explicit override)
26874
+ * 2. launchOptions[].outputFormatMap — check actual args for matching values
26875
+ * 3. Default: 'terminal'
26876
+ */
26877
+ resolveOutputFormat() {
26878
+ if (this.launchMode?.outputFormat) return this.launchMode.outputFormat;
26879
+ if (this.provider.launchOptions?.length) {
26880
+ for (const opt of this.provider.launchOptions) {
26881
+ if (!opt.outputFormatMap) continue;
26882
+ for (const [val, fmt] of Object.entries(opt.outputFormatMap)) {
26883
+ if (this.cliArgs.includes(val)) return fmt;
26884
+ }
26885
+ }
26886
+ }
26887
+ return "terminal";
26888
+ }
26865
26889
  // ─── Lifecycle ─────────────────────────────────
26866
26890
  async init(context) {
26867
26891
  this.context = context;
@@ -26901,7 +26925,8 @@ var CliProviderInstance = class {
26901
26925
  name: this.provider.name,
26902
26926
  category: "cli",
26903
26927
  status: adapterStatus.status,
26904
- mode: "terminal",
26928
+ mode: this.resolvedOutputFormat === "stream-json" ? "chat" : "terminal",
26929
+ launchMode: this.launchMode?.id,
26905
26930
  activeChat: {
26906
26931
  id: `${this.type}_${this.workingDir}`,
26907
26932
  title: `${this.provider.name} \xB7 ${dirName}`,
@@ -28032,12 +28057,12 @@ var DaemonCliManager = class {
28032
28057
  }
28033
28058
  }, 3e3);
28034
28059
  }
28035
- async registerCliInstance(key, normalizedType, cliType, resolvedDir, cliArgs, provider, settings, attachExisting = false) {
28060
+ async registerCliInstance(key, normalizedType, cliType, resolvedDir, cliArgs, provider, settings, attachExisting = false, launchModeId) {
28036
28061
  const instanceManager = this.deps.getInstanceManager();
28037
28062
  const sessionRegistry = this.deps.getSessionRegistry?.() || null;
28038
28063
  if (!instanceManager) throw new Error("InstanceManager not available");
28039
28064
  const transportFactory = this.getTransportFactory(key, normalizedType, resolvedDir, cliArgs, attachExisting);
28040
- const cliInstance = new CliProviderInstance(provider, resolvedDir, cliArgs, key, transportFactory);
28065
+ const cliInstance = new CliProviderInstance(provider, resolvedDir, cliArgs, key, transportFactory, launchModeId);
28041
28066
  try {
28042
28067
  await instanceManager.addInstance(key, cliInstance, {
28043
28068
  serverConn: this.deps.getServerConn(),
@@ -28063,7 +28088,7 @@ var DaemonCliManager = class {
28063
28088
  this.startCliExitMonitor(key, cliType);
28064
28089
  }
28065
28090
  // ─── Session start/management ──────────────────────────────
28066
- async startSession(cliType, workingDir, cliArgs, initialModel) {
28091
+ async startSession(cliType, workingDir, cliArgs, initialModel, launchMode, launchOptionValues) {
28067
28092
  const trimmed = (workingDir || "").trim();
28068
28093
  if (!trimmed) throw new Error("working directory required");
28069
28094
  const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path10.resolve(trimmed);
@@ -28155,6 +28180,29 @@ ${installInfo}`
28155
28180
  if (provider) {
28156
28181
  console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
28157
28182
  }
28183
+ let resolvedCliArgs = cliArgs;
28184
+ let resolvedLaunchMode = launchMode;
28185
+ const activeMode = provider?.launchModes?.length ? launchMode ? provider.launchModes.find((m) => m.id === launchMode) : provider.launchModes.find((m) => m.default) : void 0;
28186
+ if (activeMode) {
28187
+ resolvedLaunchMode = activeMode.id;
28188
+ }
28189
+ if (provider?.launchArgBuilder) {
28190
+ const defaults = {};
28191
+ for (const opt of provider.launchOptions || []) {
28192
+ if (opt.default !== void 0) defaults[opt.id] = opt.default;
28193
+ }
28194
+ const modeOptions = activeMode?.options || {};
28195
+ const userOptions = launchOptionValues || {};
28196
+ const merged = { ...defaults, ...modeOptions, ...userOptions };
28197
+ const extraArgs = provider.launchArgBuilder(merged);
28198
+ if (extraArgs.length) {
28199
+ resolvedCliArgs = [...cliArgs || [], ...extraArgs];
28200
+ console.log(colorize("cyan", ` \u{1F680} Launch options applied: ${extraArgs.join(" ")}`));
28201
+ }
28202
+ } else if (activeMode?.extraArgs?.length) {
28203
+ resolvedCliArgs = [...cliArgs || [], ...activeMode.extraArgs];
28204
+ console.log(colorize("cyan", ` \u{1F680} Launch mode '${activeMode.name}': appending args ${activeMode.extraArgs.join(" ")}`));
28205
+ }
28158
28206
  const instanceManager = this.deps.getInstanceManager();
28159
28207
  if (provider && instanceManager) {
28160
28208
  const resolvedProvider = this.providerLoader.resolve(cliType, { version: cliInfo.version }) || provider;
@@ -28163,14 +28211,15 @@ ${installInfo}`
28163
28211
  normalizedType,
28164
28212
  cliType,
28165
28213
  resolvedDir,
28166
- cliArgs,
28214
+ resolvedCliArgs,
28167
28215
  resolvedProvider,
28168
28216
  {},
28169
- false
28217
+ false,
28218
+ resolvedLaunchMode
28170
28219
  );
28171
28220
  console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
28172
28221
  } else {
28173
- const adapter = this.createAdapter(cliType, resolvedDir, cliArgs, key, false);
28222
+ const adapter = this.createAdapter(cliType, resolvedDir, resolvedCliArgs, key, false);
28174
28223
  try {
28175
28224
  await adapter.spawn();
28176
28225
  } catch (spawnErr) {
@@ -28278,7 +28327,8 @@ ${installInfo}`
28278
28327
  record2.cliArgs,
28279
28328
  resolvedProvider,
28280
28329
  {},
28281
- true
28330
+ true,
28331
+ record2.launchMode
28282
28332
  );
28283
28333
  restored += 1;
28284
28334
  LOG.info("CLI", `\u267B Restored hosted runtime: ${record2.runtimeKey || record2.runtimeId} (${record2.displayName || record2.workspace})`);
@@ -28348,7 +28398,7 @@ ${installInfo}`
28348
28398
  const dir = resolved.path;
28349
28399
  const launchSource = resolved.source;
28350
28400
  if (!cliType) throw new Error("cliType required");
28351
- await this.startSession(cliType, dir, args?.cliArgs, args?.initialModel);
28401
+ await this.startSession(cliType, dir, args?.cliArgs, args?.initialModel, args?.launchMode, args?.launchOptionValues);
28352
28402
  let newKey = null;
28353
28403
  for (const [k, adapter] of this.adapters) {
28354
28404
  if (adapter.cliType === cliType && adapter.workingDir === dir) {