@adhdev/daemon-core 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/commands/cli-manager.d.ts +2 -1
- package/dist/index.js +60 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -10
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +10 -1
- package/dist/providers/contracts.d.ts +79 -0
- package/dist/providers/provider-instance.d.ts +2 -0
- package/dist/shared-types.d.ts +4 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/commands/cli-manager.ts +43 -5
- package/src/providers/cli-provider-instance.ts +29 -2
- package/src/providers/contracts.ts +80 -0
- package/src/providers/provider-instance.ts +2 -0
- package/src/shared-types.ts +4 -0
- package/src/status/builders.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -4989,6 +4989,8 @@ function buildCliSession(state) {
|
|
|
4989
4989
|
runtimeWorkspaceLabel: state.runtime?.workspaceLabel,
|
|
4990
4990
|
runtimeWriteOwner: state.runtime?.writeOwner || null,
|
|
4991
4991
|
runtimeAttachedClients: state.runtime?.attachedClients || [],
|
|
4992
|
+
launchMode: state.launchMode,
|
|
4993
|
+
mode: state.mode,
|
|
4992
4994
|
resume: state.resume,
|
|
4993
4995
|
activeChat,
|
|
4994
4996
|
capabilities: PTY_SESSION_CAPABILITIES,
|
|
@@ -9066,12 +9068,14 @@ init_provider_cli_adapter();
|
|
|
9066
9068
|
import * as crypto3 from "crypto";
|
|
9067
9069
|
init_logger();
|
|
9068
9070
|
var CliProviderInstance = class {
|
|
9069
|
-
constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory) {
|
|
9071
|
+
constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory, launchModeId) {
|
|
9070
9072
|
this.provider = provider;
|
|
9071
9073
|
this.workingDir = workingDir;
|
|
9072
9074
|
this.cliArgs = cliArgs;
|
|
9073
9075
|
this.type = provider.type;
|
|
9074
9076
|
this.instanceId = instanceId || crypto3.randomUUID();
|
|
9077
|
+
this.launchMode = launchModeId && provider.launchModes?.find((m) => m.id === launchModeId) || null;
|
|
9078
|
+
this.resolvedOutputFormat = this.resolveOutputFormat();
|
|
9075
9079
|
this.adapter = new ProviderCliAdapter(provider, workingDir, cliArgs, transportFactory);
|
|
9076
9080
|
this.monitor = new StatusMonitor();
|
|
9077
9081
|
this.historyWriter = new ChatHistoryWriter();
|
|
@@ -9090,6 +9094,26 @@ var CliProviderInstance = class {
|
|
|
9090
9094
|
lastApprovalEventAt = 0;
|
|
9091
9095
|
historyWriter;
|
|
9092
9096
|
instanceId;
|
|
9097
|
+
launchMode;
|
|
9098
|
+
resolvedOutputFormat;
|
|
9099
|
+
/**
|
|
9100
|
+
* Determine output rendering format from:
|
|
9101
|
+
* 1. launchMode.outputFormat (explicit override)
|
|
9102
|
+
* 2. launchOptions[].outputFormatMap — check actual args for matching values
|
|
9103
|
+
* 3. Default: 'terminal'
|
|
9104
|
+
*/
|
|
9105
|
+
resolveOutputFormat() {
|
|
9106
|
+
if (this.launchMode?.outputFormat) return this.launchMode.outputFormat;
|
|
9107
|
+
if (this.provider.launchOptions?.length) {
|
|
9108
|
+
for (const opt of this.provider.launchOptions) {
|
|
9109
|
+
if (!opt.outputFormatMap) continue;
|
|
9110
|
+
for (const [val, fmt] of Object.entries(opt.outputFormatMap)) {
|
|
9111
|
+
if (this.cliArgs.includes(val)) return fmt;
|
|
9112
|
+
}
|
|
9113
|
+
}
|
|
9114
|
+
}
|
|
9115
|
+
return "terminal";
|
|
9116
|
+
}
|
|
9093
9117
|
// ─── Lifecycle ─────────────────────────────────
|
|
9094
9118
|
async init(context) {
|
|
9095
9119
|
this.context = context;
|
|
@@ -9129,7 +9153,8 @@ var CliProviderInstance = class {
|
|
|
9129
9153
|
name: this.provider.name,
|
|
9130
9154
|
category: "cli",
|
|
9131
9155
|
status: adapterStatus.status,
|
|
9132
|
-
mode: "terminal",
|
|
9156
|
+
mode: this.resolvedOutputFormat === "stream-json" ? "chat" : "terminal",
|
|
9157
|
+
launchMode: this.launchMode?.id,
|
|
9133
9158
|
activeChat: {
|
|
9134
9159
|
id: `${this.type}_${this.workingDir}`,
|
|
9135
9160
|
title: `${this.provider.name} \xB7 ${dirName}`,
|
|
@@ -10276,12 +10301,12 @@ var DaemonCliManager = class {
|
|
|
10276
10301
|
}
|
|
10277
10302
|
}, 3e3);
|
|
10278
10303
|
}
|
|
10279
|
-
async registerCliInstance(key, normalizedType, cliType, resolvedDir, cliArgs, provider, settings, attachExisting = false) {
|
|
10304
|
+
async registerCliInstance(key, normalizedType, cliType, resolvedDir, cliArgs, provider, settings, attachExisting = false, launchModeId) {
|
|
10280
10305
|
const instanceManager = this.deps.getInstanceManager();
|
|
10281
10306
|
const sessionRegistry = this.deps.getSessionRegistry?.() || null;
|
|
10282
10307
|
if (!instanceManager) throw new Error("InstanceManager not available");
|
|
10283
10308
|
const transportFactory = this.getTransportFactory(key, normalizedType, resolvedDir, cliArgs, attachExisting);
|
|
10284
|
-
const cliInstance = new CliProviderInstance(provider, resolvedDir, cliArgs, key, transportFactory);
|
|
10309
|
+
const cliInstance = new CliProviderInstance(provider, resolvedDir, cliArgs, key, transportFactory, launchModeId);
|
|
10285
10310
|
try {
|
|
10286
10311
|
await instanceManager.addInstance(key, cliInstance, {
|
|
10287
10312
|
serverConn: this.deps.getServerConn(),
|
|
@@ -10307,7 +10332,7 @@ var DaemonCliManager = class {
|
|
|
10307
10332
|
this.startCliExitMonitor(key, cliType);
|
|
10308
10333
|
}
|
|
10309
10334
|
// ─── Session start/management ──────────────────────────────
|
|
10310
|
-
async startSession(cliType, workingDir, cliArgs, initialModel) {
|
|
10335
|
+
async startSession(cliType, workingDir, cliArgs, initialModel, launchMode, launchOptionValues) {
|
|
10311
10336
|
const trimmed = (workingDir || "").trim();
|
|
10312
10337
|
if (!trimmed) throw new Error("working directory required");
|
|
10313
10338
|
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path10.resolve(trimmed);
|
|
@@ -10399,6 +10424,29 @@ ${installInfo}`
|
|
|
10399
10424
|
if (provider) {
|
|
10400
10425
|
console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
|
|
10401
10426
|
}
|
|
10427
|
+
let resolvedCliArgs = cliArgs;
|
|
10428
|
+
let resolvedLaunchMode = launchMode;
|
|
10429
|
+
const activeMode = provider?.launchModes?.length ? launchMode ? provider.launchModes.find((m) => m.id === launchMode) : provider.launchModes.find((m) => m.default) : void 0;
|
|
10430
|
+
if (activeMode) {
|
|
10431
|
+
resolvedLaunchMode = activeMode.id;
|
|
10432
|
+
}
|
|
10433
|
+
if (provider?.launchArgBuilder) {
|
|
10434
|
+
const defaults = {};
|
|
10435
|
+
for (const opt of provider.launchOptions || []) {
|
|
10436
|
+
if (opt.default !== void 0) defaults[opt.id] = opt.default;
|
|
10437
|
+
}
|
|
10438
|
+
const modeOptions = activeMode?.options || {};
|
|
10439
|
+
const userOptions = launchOptionValues || {};
|
|
10440
|
+
const merged = { ...defaults, ...modeOptions, ...userOptions };
|
|
10441
|
+
const extraArgs = provider.launchArgBuilder(merged);
|
|
10442
|
+
if (extraArgs.length) {
|
|
10443
|
+
resolvedCliArgs = [...cliArgs || [], ...extraArgs];
|
|
10444
|
+
console.log(colorize("cyan", ` \u{1F680} Launch options applied: ${extraArgs.join(" ")}`));
|
|
10445
|
+
}
|
|
10446
|
+
} else if (activeMode?.extraArgs?.length) {
|
|
10447
|
+
resolvedCliArgs = [...cliArgs || [], ...activeMode.extraArgs];
|
|
10448
|
+
console.log(colorize("cyan", ` \u{1F680} Launch mode '${activeMode.name}': appending args ${activeMode.extraArgs.join(" ")}`));
|
|
10449
|
+
}
|
|
10402
10450
|
const instanceManager = this.deps.getInstanceManager();
|
|
10403
10451
|
if (provider && instanceManager) {
|
|
10404
10452
|
const resolvedProvider = this.providerLoader.resolve(cliType, { version: cliInfo.version }) || provider;
|
|
@@ -10407,14 +10455,15 @@ ${installInfo}`
|
|
|
10407
10455
|
normalizedType,
|
|
10408
10456
|
cliType,
|
|
10409
10457
|
resolvedDir,
|
|
10410
|
-
|
|
10458
|
+
resolvedCliArgs,
|
|
10411
10459
|
resolvedProvider,
|
|
10412
10460
|
{},
|
|
10413
|
-
false
|
|
10461
|
+
false,
|
|
10462
|
+
resolvedLaunchMode
|
|
10414
10463
|
);
|
|
10415
10464
|
console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
|
|
10416
10465
|
} else {
|
|
10417
|
-
const adapter = this.createAdapter(cliType, resolvedDir,
|
|
10466
|
+
const adapter = this.createAdapter(cliType, resolvedDir, resolvedCliArgs, key, false);
|
|
10418
10467
|
try {
|
|
10419
10468
|
await adapter.spawn();
|
|
10420
10469
|
} catch (spawnErr) {
|
|
@@ -10522,7 +10571,8 @@ ${installInfo}`
|
|
|
10522
10571
|
record.cliArgs,
|
|
10523
10572
|
resolvedProvider,
|
|
10524
10573
|
{},
|
|
10525
|
-
true
|
|
10574
|
+
true,
|
|
10575
|
+
record.launchMode
|
|
10526
10576
|
);
|
|
10527
10577
|
restored += 1;
|
|
10528
10578
|
LOG.info("CLI", `\u267B Restored hosted runtime: ${record.runtimeKey || record.runtimeId} (${record.displayName || record.workspace})`);
|
|
@@ -10592,7 +10642,7 @@ ${installInfo}`
|
|
|
10592
10642
|
const dir = resolved.path;
|
|
10593
10643
|
const launchSource = resolved.source;
|
|
10594
10644
|
if (!cliType) throw new Error("cliType required");
|
|
10595
|
-
await this.startSession(cliType, dir, args?.cliArgs, args?.initialModel);
|
|
10645
|
+
await this.startSession(cliType, dir, args?.cliArgs, args?.initialModel, args?.launchMode, args?.launchOptionValues);
|
|
10596
10646
|
let newKey = null;
|
|
10597
10647
|
for (const [k, adapter] of this.adapters) {
|
|
10598
10648
|
if (adapter.cliType === cliType && adapter.workingDir === dir) {
|