@adhdev/daemon-core 0.9.82-rc.312 → 0.9.82-rc.314
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/upgrade-helper.d.ts +12 -0
- package/dist/index.js +84 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/commands/upgrade-helper.ts +52 -30
- package/src/providers/provider-loader.ts +78 -0
- package/src/providers/spec/cli-adapter.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhdev/daemon-core",
|
|
3
|
-
"version": "0.9.82-rc.
|
|
3
|
+
"version": "0.9.82-rc.314",
|
|
4
4
|
"description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"author": "vilmire",
|
|
47
47
|
"license": "AGPL-3.0-or-later",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@adhdev/mesh-shared": "0.9.82-rc.
|
|
49
|
+
"@adhdev/mesh-shared": "0.9.82-rc.314",
|
|
50
50
|
"@adhdev/session-host-core": "*",
|
|
51
51
|
"@agentclientprotocol/sdk": "^0.16.1",
|
|
52
52
|
"ajv": "^8.20.0",
|
|
@@ -321,42 +321,64 @@ function removeDaemonPidFile(): void {
|
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
324
|
+
/**
|
|
325
|
+
* Best-effort removal of a leftover npm staging entry.
|
|
326
|
+
*
|
|
327
|
+
* A stale staging dir can hold a locked native binary — e.g. `ghostty-vt.dll`
|
|
328
|
+
* from `@adhdev/ghostty-vt-node` still mapped by a lingering session-host
|
|
329
|
+
* process — which makes `rmSync` throw `EPERM` on Windows. Staging cleanup is
|
|
330
|
+
* only housekeeping: the leftover is inert and npm creates its own fresh
|
|
331
|
+
* staging dir for the real install, so a lock on an old leftover must NOT abort
|
|
332
|
+
* the upgrade. Log and continue instead of letting the error propagate.
|
|
333
|
+
*/
|
|
334
|
+
export function safeRemoveStaleEntry(target: string, label: string): void {
|
|
335
|
+
try {
|
|
336
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
337
|
+
appendUpgradeLog(`${label}: ${target}`);
|
|
338
|
+
} catch (error: any) {
|
|
339
|
+
appendUpgradeLog(`Skipped locked stale entry (${error?.code || 'error'}): ${target} — ${error?.message || String(error)}`);
|
|
335
340
|
}
|
|
341
|
+
}
|
|
336
342
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
343
|
+
export function cleanupStaleGlobalInstallDirs(pkgName: string, surface: CurrentGlobalInstallSurface): void {
|
|
344
|
+
// The whole routine is housekeeping — never let it throw out and abort the
|
|
345
|
+
// upgrade (npm root/prefix probing or readdir can fail for unrelated reasons).
|
|
346
|
+
try {
|
|
347
|
+
const prefixArgs = surface.installPrefix ? ['--prefix', surface.installPrefix] : [];
|
|
348
|
+
const npmRoot = String(execNpmCommandSync(['root', '-g', ...prefixArgs], { encoding: 'utf8' }, surface)).trim();
|
|
349
|
+
if (!npmRoot) return;
|
|
350
|
+
const npmPrefix = surface.installPrefix
|
|
351
|
+
|| String(execNpmCommandSync(['prefix', '-g', ...prefixArgs], { encoding: 'utf8' }, surface)).trim();
|
|
352
|
+
const binDir = process.platform === 'win32' ? npmPrefix : path.join(npmPrefix, 'bin');
|
|
353
|
+
const packageBaseName = pkgName.startsWith('@') ? pkgName.split('/')[1] : pkgName;
|
|
354
|
+
const binNames = new Set<string>([packageBaseName]);
|
|
355
|
+
if (pkgName === '@adhdev/daemon-standalone') {
|
|
356
|
+
binNames.add('adhdev-standalone');
|
|
345
357
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
358
|
+
|
|
359
|
+
if (pkgName.startsWith('@')) {
|
|
360
|
+
const [scope, name] = pkgName.split('/');
|
|
361
|
+
const scopeDir = path.join(npmRoot, scope);
|
|
362
|
+
if (!fs.existsSync(scopeDir)) return;
|
|
363
|
+
for (const entry of fs.readdirSync(scopeDir)) {
|
|
364
|
+
if (!entry.startsWith(`.${name}-`)) continue;
|
|
365
|
+
safeRemoveStaleEntry(path.join(scopeDir, entry), 'Removed stale scoped staging dir');
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
for (const entry of fs.readdirSync(npmRoot)) {
|
|
369
|
+
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
370
|
+
safeRemoveStaleEntry(path.join(npmRoot, entry), 'Removed stale staging dir');
|
|
371
|
+
}
|
|
351
372
|
}
|
|
352
|
-
}
|
|
353
373
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
374
|
+
if (fs.existsSync(binDir)) {
|
|
375
|
+
for (const entry of fs.readdirSync(binDir)) {
|
|
376
|
+
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
377
|
+
safeRemoveStaleEntry(path.join(binDir, entry), 'Removed stale bin staging entry');
|
|
378
|
+
}
|
|
359
379
|
}
|
|
380
|
+
} catch (error: any) {
|
|
381
|
+
appendUpgradeLog(`Stale staging cleanup skipped (${error?.code || 'error'}): ${error?.message || String(error)}`);
|
|
360
382
|
}
|
|
361
383
|
}
|
|
362
384
|
|
|
@@ -22,6 +22,7 @@ import { LOG } from '../logging/logger.js';
|
|
|
22
22
|
import { VersionArchive } from './version-archive.js';
|
|
23
23
|
import type {
|
|
24
24
|
ProviderCompatibilityEntry,
|
|
25
|
+
ProviderControlDef,
|
|
25
26
|
ProviderModule,
|
|
26
27
|
ProviderCategory,
|
|
27
28
|
ProviderScripts,
|
|
@@ -87,6 +88,70 @@ export interface MachineProviderConfig {
|
|
|
87
88
|
lastVerification?: MachineProviderCheckResult;
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Translate a spec `control_bar` array into the web-facing
|
|
93
|
+
* `ProviderControlDef[]` shape the dashboard renders.
|
|
94
|
+
*
|
|
95
|
+
* The two shapes are distinct: `control_bar` entries are daemon-side
|
|
96
|
+
* `{ id, label, visible_when_state, action }` records driving
|
|
97
|
+
* SpecCliAdapter.invokeScript, while the dashboard's chat bar reads
|
|
98
|
+
* `ProviderControlDef` (`{ id, type, label, placement, ... }`). Spec
|
|
99
|
+
* providers (claude-cli / codex-cli) historically declared *only*
|
|
100
|
+
* `control_bar`, so the dashboard saw no controls at all — the Model / Mode
|
|
101
|
+
* pickers never rendered. This bridges that gap without changing how the
|
|
102
|
+
* controls actually dispatch.
|
|
103
|
+
*
|
|
104
|
+
* Script-name contract: the dashboard sends the control's
|
|
105
|
+
* `listScript` / `setScript` / `invokeScript` name through
|
|
106
|
+
* `invoke_provider_script`, which gates on `provider.scripts[<name>]` and then
|
|
107
|
+
* routes to `SpecCliAdapter.invokeScript(<name>)` — which matches the name
|
|
108
|
+
* against `control_bar[].id`. So every synthesized script name MUST equal the
|
|
109
|
+
* control id (the loader stubs `provider.scripts[id]` from the same source).
|
|
110
|
+
*
|
|
111
|
+
* Mapping:
|
|
112
|
+
* open_picker → select (dynamic): list + set both keyed on the control id;
|
|
113
|
+
* the adapter distinguishes LIST vs SELECT by the presence of
|
|
114
|
+
* a choice arg, so one id serves both roles.
|
|
115
|
+
* send_keys → action: one-shot keystroke (stop, cycle_mode).
|
|
116
|
+
* attach_image → skipped: it needs an image blob from a file picker, not a
|
|
117
|
+
* bare bar button; surfacing it as an `action` would only
|
|
118
|
+
* produce a button that errors with "requires args.blob".
|
|
119
|
+
*/
|
|
120
|
+
function synthesizeControlsFromControlBar(specControls: any[]): ProviderControlDef[] {
|
|
121
|
+
const out: ProviderControlDef[] = [];
|
|
122
|
+
specControls.forEach((ctl, index) => {
|
|
123
|
+
const id = typeof ctl?.id === 'string' ? ctl.id.trim() : '';
|
|
124
|
+
const actionType = ctl?.action?.type;
|
|
125
|
+
if (!id || !actionType) return;
|
|
126
|
+
const label = typeof ctl?.label === 'string' && ctl.label.trim() ? ctl.label : id;
|
|
127
|
+
if (actionType === 'open_picker') {
|
|
128
|
+
out.push({
|
|
129
|
+
id,
|
|
130
|
+
type: 'select',
|
|
131
|
+
label,
|
|
132
|
+
placement: 'bar',
|
|
133
|
+
dynamic: true,
|
|
134
|
+
listScript: id,
|
|
135
|
+
setScript: id,
|
|
136
|
+
readFrom: id,
|
|
137
|
+
order: index,
|
|
138
|
+
});
|
|
139
|
+
} else if (actionType === 'send_keys') {
|
|
140
|
+
out.push({
|
|
141
|
+
id,
|
|
142
|
+
type: 'action',
|
|
143
|
+
label,
|
|
144
|
+
placement: 'bar',
|
|
145
|
+
invokeScript: id,
|
|
146
|
+
resultDisplay: 'none',
|
|
147
|
+
order: index,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// attach_image intentionally skipped — see fn doc.
|
|
151
|
+
});
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
|
|
90
155
|
type CliDetectionEntry = {
|
|
91
156
|
id: string;
|
|
92
157
|
displayName: string;
|
|
@@ -1271,6 +1336,19 @@ export class ProviderLoader {
|
|
|
1271
1336
|
});
|
|
1272
1337
|
}
|
|
1273
1338
|
}
|
|
1339
|
+
// Bridge the spec control_bar into the web-facing controls schema so
|
|
1340
|
+
// the dashboard chat bar actually renders Model/Mode pickers. Only
|
|
1341
|
+
// synthesize when the provider hasn't already declared its own
|
|
1342
|
+
// `controls` in provider.v1.json (e.g. hermes-cli) — an explicit
|
|
1343
|
+
// declaration wins and must not be clobbered.
|
|
1344
|
+
const hasDeclaredControls = Array.isArray((resolved as any).controls)
|
|
1345
|
+
&& (resolved as any).controls.length > 0;
|
|
1346
|
+
if (!hasDeclaredControls) {
|
|
1347
|
+
const synthesized = synthesizeControlsFromControlBar(specControls);
|
|
1348
|
+
if (synthesized.length > 0) {
|
|
1349
|
+
resolved.controls = synthesized;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1274
1352
|
}
|
|
1275
1353
|
if (nh) {
|
|
1276
1354
|
let reader: ((input: any) => any) | null = null;
|
|
@@ -355,8 +355,14 @@ export class SpecCliAdapter implements CliAdapter {
|
|
|
355
355
|
const choiceIndex = typeof flat.choiceIndex === 'number' ? flat.choiceIndex
|
|
356
356
|
: typeof flat.choiceIndex === 'string' && flat.choiceIndex.trim() ? Number(flat.choiceIndex)
|
|
357
357
|
: undefined;
|
|
358
|
+
// `value` is the arg the dashboard's generic value-control set path
|
|
359
|
+
// sends ({ value: <chosen option> }). control_bar pickers are
|
|
360
|
+
// surfaced to the dashboard as dynamic `select` controls whose
|
|
361
|
+
// option values are the screen-parsed labels, so a bare `value`
|
|
362
|
+
// is just a label to match against the live choices.
|
|
358
363
|
const choiceLabel = typeof flat.choiceLabel === 'string' ? flat.choiceLabel
|
|
359
364
|
: typeof flat.choice === 'string' ? flat.choice
|
|
365
|
+
: typeof flat.value === 'string' ? flat.value
|
|
360
366
|
: undefined;
|
|
361
367
|
if ((typeof choiceIndex === 'number' && Number.isFinite(choiceIndex)) || (choiceLabel && choiceLabel.trim())) {
|
|
362
368
|
return this.selectPickerChoice(ctl, action, choiceIndex, choiceLabel);
|