adhdev 0.8.50 → 0.8.54
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/cli/index.js +2115 -853
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +1391 -613
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/vendor/session-host-daemon/index.d.mts +3 -0
- package/vendor/session-host-daemon/index.d.ts +3 -0
- package/vendor/session-host-daemon/index.js +33 -2
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +34 -2
- package/vendor/session-host-daemon/index.mjs.map +1 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.d.mts +16 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.d.ts +16 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js +59 -0
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js.map +1 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs +54 -0
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs.map +1 -1
- package/vendor/terminal-mux-cli/index.d.mts +1 -0
- package/vendor/terminal-mux-cli/index.d.ts +1 -0
- package/vendor/terminal-mux-cli/index.js +2070 -0
- package/vendor/terminal-mux-cli/index.mjs +2062 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.d.mts +442 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.d.ts +442 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.js +676 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.js.map +1 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.mjs +627 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.mjs.map +1 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/package.json +7 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.d.mts +16 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.d.ts +16 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.js +206 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.mjs +17 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-7RNMRPVZ.mjs +183 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-R4EFW6W3.mjs +46 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-XZWWVN5W.mjs +164 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.d.mts +35 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.d.ts +35 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.js +219 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.mjs +13 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.d.mts +5 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.d.ts +5 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.js +427 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.mjs +34 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/package.json +33 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.d.mts +49 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.d.ts +49 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.js +222 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.mjs +16 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.d.mts +164 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.d.ts +164 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.js +993 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.mjs +957 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/package.json +7 -0
package/dist/index.js
CHANGED
|
@@ -649,17 +649,17 @@ function checkPathExists(paths) {
|
|
|
649
649
|
return null;
|
|
650
650
|
}
|
|
651
651
|
async function detectIDEs(providerLoader) {
|
|
652
|
-
const
|
|
652
|
+
const os25 = (0, import_os2.platform)();
|
|
653
653
|
const results = [];
|
|
654
654
|
for (const def of getMergedDefinitions()) {
|
|
655
655
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
656
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
656
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os25] || []) || []);
|
|
657
657
|
let resolvedCli = cliPath;
|
|
658
|
-
if (!resolvedCli && appPath &&
|
|
658
|
+
if (!resolvedCli && appPath && os25 === "darwin") {
|
|
659
659
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
660
660
|
if ((0, import_fs3.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
661
661
|
}
|
|
662
|
-
if (!resolvedCli && appPath &&
|
|
662
|
+
if (!resolvedCli && appPath && os25 === "win32") {
|
|
663
663
|
const { dirname: dirname9 } = await import("path");
|
|
664
664
|
const appDir = dirname9(appPath);
|
|
665
665
|
const candidates = [
|
|
@@ -676,7 +676,7 @@ async function detectIDEs(providerLoader) {
|
|
|
676
676
|
}
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
|
-
const installed =
|
|
679
|
+
const installed = os25 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
680
680
|
const version2 = resolvedCli ? getIdeVersion(resolvedCli) : null;
|
|
681
681
|
results.push({
|
|
682
682
|
id: def.id,
|
|
@@ -2599,6 +2599,61 @@ function normalizeProviderEffects(data) {
|
|
|
2599
2599
|
}
|
|
2600
2600
|
return effects;
|
|
2601
2601
|
}
|
|
2602
|
+
function normalizeControlListResult(data) {
|
|
2603
|
+
if (data && typeof data === "object" && Array.isArray(data.options)) {
|
|
2604
|
+
return {
|
|
2605
|
+
options: normalizeControlOptions(data.options),
|
|
2606
|
+
...isScalarControlValue(data.currentValue) ? { currentValue: data.currentValue } : {},
|
|
2607
|
+
...typeof data.error === "string" ? { error: data.error } : {}
|
|
2608
|
+
};
|
|
2609
|
+
}
|
|
2610
|
+
const rawOptions = Array.isArray(data?.models) ? data.models : Array.isArray(data?.modes) ? data.modes : Array.isArray(data?.options) ? data.options : [];
|
|
2611
|
+
const options = normalizeControlOptions(rawOptions);
|
|
2612
|
+
return {
|
|
2613
|
+
options,
|
|
2614
|
+
...isScalarControlValue(data?.current) ? { currentValue: data.current } : {},
|
|
2615
|
+
...isScalarControlValue(data?.currentValue) ? { currentValue: data.currentValue } : {},
|
|
2616
|
+
...typeof data?.error === "string" ? { error: data.error } : {}
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
function normalizeControlSetResult(data) {
|
|
2620
|
+
const currentValue = isScalarControlValue(data?.currentValue) ? data.currentValue : isScalarControlValue(data?.value) ? data.value : void 0;
|
|
2621
|
+
return {
|
|
2622
|
+
ok: data?.ok === true || data?.success === true,
|
|
2623
|
+
...currentValue !== void 0 ? { currentValue } : {},
|
|
2624
|
+
...Array.isArray(data?.effects) ? { effects: normalizeProviderEffects(data) } : {},
|
|
2625
|
+
...typeof data?.error === "string" ? { error: data.error } : {}
|
|
2626
|
+
};
|
|
2627
|
+
}
|
|
2628
|
+
function normalizeControlInvokeResult(data) {
|
|
2629
|
+
const currentValue = isScalarControlValue(data?.currentValue) ? data.currentValue : isScalarControlValue(data?.value) ? data.value : void 0;
|
|
2630
|
+
return {
|
|
2631
|
+
ok: data?.ok === true || data?.success === true,
|
|
2632
|
+
...currentValue !== void 0 ? { currentValue } : {},
|
|
2633
|
+
...Array.isArray(data?.effects) ? { effects: normalizeProviderEffects(data) } : {},
|
|
2634
|
+
...typeof data?.error === "string" ? { error: data.error } : {}
|
|
2635
|
+
};
|
|
2636
|
+
}
|
|
2637
|
+
function normalizeControlOptions(options) {
|
|
2638
|
+
return options.map((option) => normalizeControlOption(option)).filter((option) => !!option);
|
|
2639
|
+
}
|
|
2640
|
+
function normalizeControlOption(option) {
|
|
2641
|
+
if (typeof option === "string") {
|
|
2642
|
+
return { value: option, label: option };
|
|
2643
|
+
}
|
|
2644
|
+
if (!option || typeof option !== "object") return null;
|
|
2645
|
+
const record2 = option;
|
|
2646
|
+
const value = typeof record2.value === "string" ? record2.value : typeof record2.id === "string" ? record2.id : null;
|
|
2647
|
+
if (!value) return null;
|
|
2648
|
+
const label = typeof record2.label === "string" ? record2.label : typeof record2.name === "string" ? record2.name : value;
|
|
2649
|
+
const normalized = { value, label };
|
|
2650
|
+
if (typeof record2.description === "string") normalized.description = record2.description;
|
|
2651
|
+
if (typeof record2.group === "string") normalized.group = record2.group;
|
|
2652
|
+
return normalized;
|
|
2653
|
+
}
|
|
2654
|
+
function isScalarControlValue(value) {
|
|
2655
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
2656
|
+
}
|
|
2602
2657
|
function normalizeControlValue(value) {
|
|
2603
2658
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
2604
2659
|
return value;
|
|
@@ -4656,50 +4711,6 @@ function isCdpConnected(cdpManagers, key) {
|
|
|
4656
4711
|
}
|
|
4657
4712
|
return false;
|
|
4658
4713
|
}
|
|
4659
|
-
function buildFallbackControls(providerControls, serverModel, serverMode, acpConfigOptions, acpModes) {
|
|
4660
|
-
if (providerControls && providerControls.length > 0) return providerControls;
|
|
4661
|
-
const controls = [];
|
|
4662
|
-
const isAcp = !!(acpConfigOptions || acpModes);
|
|
4663
|
-
const modelFromAcp = acpConfigOptions?.find((c) => c.category === "model");
|
|
4664
|
-
if (!isAcp || modelFromAcp) {
|
|
4665
|
-
controls.push({
|
|
4666
|
-
id: "model",
|
|
4667
|
-
type: "select",
|
|
4668
|
-
label: "Model",
|
|
4669
|
-
icon: "\u{1F916}",
|
|
4670
|
-
placement: "bar",
|
|
4671
|
-
dynamic: !modelFromAcp,
|
|
4672
|
-
listScript: "listModels",
|
|
4673
|
-
setScript: "setModel",
|
|
4674
|
-
readFrom: "model",
|
|
4675
|
-
...modelFromAcp && {
|
|
4676
|
-
options: modelFromAcp.options.map((o) => ({ value: o.value, label: o.name || o.value }))
|
|
4677
|
-
}
|
|
4678
|
-
});
|
|
4679
|
-
}
|
|
4680
|
-
const modeFromAcp = acpModes && acpModes.length > 0;
|
|
4681
|
-
const thoughtFromAcp = !modeFromAcp && acpConfigOptions?.find((c) => c.category !== "model");
|
|
4682
|
-
if (!isAcp || modeFromAcp || thoughtFromAcp) {
|
|
4683
|
-
controls.push({
|
|
4684
|
-
id: "mode",
|
|
4685
|
-
type: thoughtFromAcp ? "cycle" : "select",
|
|
4686
|
-
label: thoughtFromAcp ? "Thinking" : "Mode",
|
|
4687
|
-
icon: thoughtFromAcp ? "\u{1F9E0}" : "\u26A1",
|
|
4688
|
-
placement: "bar",
|
|
4689
|
-
dynamic: !modeFromAcp && !thoughtFromAcp,
|
|
4690
|
-
listScript: "listModes",
|
|
4691
|
-
setScript: thoughtFromAcp ? "setThinkingLevel" : "setMode",
|
|
4692
|
-
readFrom: "mode",
|
|
4693
|
-
...modeFromAcp && {
|
|
4694
|
-
options: acpModes.map((m) => ({ value: m.id, label: m.name || m.id }))
|
|
4695
|
-
},
|
|
4696
|
-
...thoughtFromAcp && {
|
|
4697
|
-
options: thoughtFromAcp.options.map((o) => ({ value: o.value, label: o.name || o.value }))
|
|
4698
|
-
}
|
|
4699
|
-
});
|
|
4700
|
-
}
|
|
4701
|
-
return controls;
|
|
4702
|
-
}
|
|
4703
4714
|
function buildIdeWorkspaceSession(state, cdpManagers, options) {
|
|
4704
4715
|
const profile = options.profile || "full";
|
|
4705
4716
|
const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
|
|
@@ -4726,11 +4737,7 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
|
|
|
4726
4737
|
currentAutoApprove: state.currentAutoApprove,
|
|
4727
4738
|
...includeSessionControls && {
|
|
4728
4739
|
controlValues: state.controlValues,
|
|
4729
|
-
providerControls:
|
|
4730
|
-
state.providerControls,
|
|
4731
|
-
state.currentModel,
|
|
4732
|
-
state.currentPlan
|
|
4733
|
-
)
|
|
4740
|
+
providerControls: state.providerControls
|
|
4734
4741
|
},
|
|
4735
4742
|
errorMessage: state.errorMessage,
|
|
4736
4743
|
errorReason: state.errorReason,
|
|
@@ -4760,11 +4767,7 @@ function buildExtensionAgentSession(parent, ext, options) {
|
|
|
4760
4767
|
currentPlan: ext.currentPlan,
|
|
4761
4768
|
...includeSessionControls && {
|
|
4762
4769
|
controlValues: ext.controlValues,
|
|
4763
|
-
providerControls:
|
|
4764
|
-
ext.providerControls,
|
|
4765
|
-
ext.currentModel,
|
|
4766
|
-
ext.currentPlan
|
|
4767
|
-
)
|
|
4770
|
+
providerControls: ext.providerControls
|
|
4768
4771
|
},
|
|
4769
4772
|
errorMessage: ext.errorMessage,
|
|
4770
4773
|
errorReason: ext.errorReason,
|
|
@@ -4805,9 +4808,7 @@ function buildCliSession(state, options) {
|
|
|
4805
4808
|
},
|
|
4806
4809
|
...includeSessionControls && {
|
|
4807
4810
|
controlValues: state.controlValues,
|
|
4808
|
-
providerControls:
|
|
4809
|
-
state.providerControls
|
|
4810
|
-
)
|
|
4811
|
+
providerControls: state.providerControls
|
|
4811
4812
|
},
|
|
4812
4813
|
errorMessage: state.errorMessage,
|
|
4813
4814
|
errorReason: state.errorReason,
|
|
@@ -4839,13 +4840,7 @@ function buildAcpSession(state, options) {
|
|
|
4839
4840
|
acpConfigOptions: state.acpConfigOptions,
|
|
4840
4841
|
acpModes: state.acpModes,
|
|
4841
4842
|
controlValues: state.controlValues,
|
|
4842
|
-
providerControls:
|
|
4843
|
-
state.providerControls,
|
|
4844
|
-
state.currentModel,
|
|
4845
|
-
state.currentPlan,
|
|
4846
|
-
state.acpConfigOptions,
|
|
4847
|
-
state.acpModes
|
|
4848
|
-
)
|
|
4843
|
+
providerControls: state.providerControls
|
|
4849
4844
|
},
|
|
4850
4845
|
errorMessage: state.errorMessage,
|
|
4851
4846
|
errorReason: state.errorReason,
|
|
@@ -4979,14 +4974,228 @@ var init_reconcile = __esm({
|
|
|
4979
4974
|
}
|
|
4980
4975
|
});
|
|
4981
4976
|
|
|
4977
|
+
// ../../oss/packages/daemon-core/src/providers/io-contracts.ts
|
|
4978
|
+
function normalizeInputEnvelope(input) {
|
|
4979
|
+
const normalized = normalizeInputEnvelopePayload(input);
|
|
4980
|
+
const textFallback = normalized.textFallback ?? flattenInputParts(normalized.parts);
|
|
4981
|
+
return {
|
|
4982
|
+
parts: normalized.parts,
|
|
4983
|
+
textFallback,
|
|
4984
|
+
...normalized.metadata ? { metadata: normalized.metadata } : {}
|
|
4985
|
+
};
|
|
4986
|
+
}
|
|
4987
|
+
function normalizeMessageParts(content) {
|
|
4988
|
+
if (typeof content === "string") return [{ type: "text", text: content }];
|
|
4989
|
+
if (!Array.isArray(content)) {
|
|
4990
|
+
if (content && typeof content === "object" && typeof content.text === "string") {
|
|
4991
|
+
return [{ type: "text", text: String(content.text) }];
|
|
4992
|
+
}
|
|
4993
|
+
return [];
|
|
4994
|
+
}
|
|
4995
|
+
const parts = [];
|
|
4996
|
+
for (const raw of content) {
|
|
4997
|
+
if (typeof raw === "string") {
|
|
4998
|
+
parts.push({ type: "text", text: raw });
|
|
4999
|
+
continue;
|
|
5000
|
+
}
|
|
5001
|
+
if (!raw || typeof raw !== "object") continue;
|
|
5002
|
+
const part = normalizeMessagePartObject(raw);
|
|
5003
|
+
if (part) parts.push(part);
|
|
5004
|
+
}
|
|
5005
|
+
return parts;
|
|
5006
|
+
}
|
|
5007
|
+
function flattenMessageParts(parts) {
|
|
5008
|
+
return parts.map((part) => {
|
|
5009
|
+
if (part.type === "text") return part.text;
|
|
5010
|
+
if (part.type === "resource") return part.resource.text || "";
|
|
5011
|
+
return "";
|
|
5012
|
+
}).filter((value) => value.length > 0).join("\n");
|
|
5013
|
+
}
|
|
5014
|
+
function normalizeInputEnvelopePayload(input) {
|
|
5015
|
+
if (typeof input === "string") {
|
|
5016
|
+
return { parts: [{ type: "text", text: input }], textFallback: input };
|
|
5017
|
+
}
|
|
5018
|
+
if (!input || typeof input !== "object") {
|
|
5019
|
+
return { parts: [], textFallback: "" };
|
|
5020
|
+
}
|
|
5021
|
+
const record2 = input;
|
|
5022
|
+
const nestedInput = record2.input;
|
|
5023
|
+
if (nestedInput && typeof nestedInput === "object") {
|
|
5024
|
+
const nested = nestedInput;
|
|
5025
|
+
return {
|
|
5026
|
+
parts: normalizeInputParts(nested.parts ?? nested.prompt),
|
|
5027
|
+
textFallback: typeof nested.textFallback === "string" ? nested.textFallback : void 0,
|
|
5028
|
+
metadata: normalizeInputMetadata(nested.metadata)
|
|
5029
|
+
};
|
|
5030
|
+
}
|
|
5031
|
+
const directText = typeof record2.text === "string" ? record2.text : typeof record2.message === "string" ? record2.message : void 0;
|
|
5032
|
+
if (directText !== void 0) {
|
|
5033
|
+
return { parts: [{ type: "text", text: directText }], textFallback: directText };
|
|
5034
|
+
}
|
|
5035
|
+
const directParts = normalizeInputParts(record2.parts ?? record2.prompt);
|
|
5036
|
+
return {
|
|
5037
|
+
parts: directParts,
|
|
5038
|
+
textFallback: typeof record2.textFallback === "string" ? record2.textFallback : void 0,
|
|
5039
|
+
metadata: normalizeInputMetadata(record2.metadata)
|
|
5040
|
+
};
|
|
5041
|
+
}
|
|
5042
|
+
function normalizeInputMetadata(value) {
|
|
5043
|
+
if (!value || typeof value !== "object") return void 0;
|
|
5044
|
+
const record2 = value;
|
|
5045
|
+
const metadata = {};
|
|
5046
|
+
if (record2.source === "dashboard" || record2.source === "shortcut_api" || record2.source === "provider_script" || record2.source === "session_replay") {
|
|
5047
|
+
metadata.source = record2.source;
|
|
5048
|
+
}
|
|
5049
|
+
if (typeof record2.clientTimestamp === "number" && Number.isFinite(record2.clientTimestamp)) {
|
|
5050
|
+
metadata.clientTimestamp = record2.clientTimestamp;
|
|
5051
|
+
}
|
|
5052
|
+
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
5053
|
+
}
|
|
5054
|
+
function normalizeInputParts(value) {
|
|
5055
|
+
if (!Array.isArray(value)) return [];
|
|
5056
|
+
const parts = [];
|
|
5057
|
+
for (const raw of value) {
|
|
5058
|
+
if (typeof raw === "string") {
|
|
5059
|
+
parts.push({ type: "text", text: raw });
|
|
5060
|
+
continue;
|
|
5061
|
+
}
|
|
5062
|
+
if (!raw || typeof raw !== "object") continue;
|
|
5063
|
+
const part = normalizeInputPartObject(raw);
|
|
5064
|
+
if (part) parts.push(part);
|
|
5065
|
+
}
|
|
5066
|
+
return parts;
|
|
5067
|
+
}
|
|
5068
|
+
function normalizeInputPartObject(raw) {
|
|
5069
|
+
const type = raw.type;
|
|
5070
|
+
if (type === "text" && typeof raw.text === "string") {
|
|
5071
|
+
return { type, text: raw.text };
|
|
5072
|
+
}
|
|
5073
|
+
if (type === "image" && typeof raw.mimeType === "string") {
|
|
5074
|
+
return {
|
|
5075
|
+
type,
|
|
5076
|
+
mimeType: raw.mimeType,
|
|
5077
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
5078
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
5079
|
+
...typeof raw.alt === "string" ? { alt: raw.alt } : {}
|
|
5080
|
+
};
|
|
5081
|
+
}
|
|
5082
|
+
if (type === "audio" && typeof raw.mimeType === "string") {
|
|
5083
|
+
return {
|
|
5084
|
+
type,
|
|
5085
|
+
mimeType: raw.mimeType,
|
|
5086
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
5087
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
5088
|
+
...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
|
|
5089
|
+
};
|
|
5090
|
+
}
|
|
5091
|
+
if (type === "video" && typeof raw.mimeType === "string") {
|
|
5092
|
+
return {
|
|
5093
|
+
type,
|
|
5094
|
+
mimeType: raw.mimeType,
|
|
5095
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
5096
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
5097
|
+
...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
|
|
5098
|
+
};
|
|
5099
|
+
}
|
|
5100
|
+
if (type === "resource" && typeof raw.uri === "string") {
|
|
5101
|
+
return {
|
|
5102
|
+
type,
|
|
5103
|
+
uri: raw.uri,
|
|
5104
|
+
...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
|
|
5105
|
+
...typeof raw.name === "string" ? { name: raw.name } : {},
|
|
5106
|
+
...typeof raw.text === "string" ? { text: raw.text } : {},
|
|
5107
|
+
...typeof raw.data === "string" ? { data: raw.data } : {}
|
|
5108
|
+
};
|
|
5109
|
+
}
|
|
5110
|
+
if (type === "resource_link" && typeof raw.uri === "string") {
|
|
5111
|
+
return {
|
|
5112
|
+
type: "resource",
|
|
5113
|
+
uri: raw.uri,
|
|
5114
|
+
...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
|
|
5115
|
+
...typeof raw.name === "string" ? { name: raw.name } : {}
|
|
5116
|
+
};
|
|
5117
|
+
}
|
|
5118
|
+
return null;
|
|
5119
|
+
}
|
|
5120
|
+
function normalizeMessagePartObject(raw) {
|
|
5121
|
+
const type = raw.type;
|
|
5122
|
+
if (type === "text" && typeof raw.text === "string") {
|
|
5123
|
+
return { type, text: raw.text };
|
|
5124
|
+
}
|
|
5125
|
+
if (type === "image" && typeof raw.mimeType === "string") {
|
|
5126
|
+
return {
|
|
5127
|
+
type,
|
|
5128
|
+
mimeType: raw.mimeType,
|
|
5129
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
5130
|
+
...typeof raw.data === "string" ? { data: raw.data } : {}
|
|
5131
|
+
};
|
|
5132
|
+
}
|
|
5133
|
+
if (type === "audio" && typeof raw.mimeType === "string") {
|
|
5134
|
+
return {
|
|
5135
|
+
type,
|
|
5136
|
+
mimeType: raw.mimeType,
|
|
5137
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
5138
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
5139
|
+
...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
|
|
5140
|
+
};
|
|
5141
|
+
}
|
|
5142
|
+
if (type === "video" && typeof raw.mimeType === "string") {
|
|
5143
|
+
return {
|
|
5144
|
+
type,
|
|
5145
|
+
mimeType: raw.mimeType,
|
|
5146
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
5147
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
5148
|
+
...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
|
|
5149
|
+
};
|
|
5150
|
+
}
|
|
5151
|
+
if (type === "resource_link" && typeof raw.uri === "string" && typeof raw.name === "string") {
|
|
5152
|
+
return {
|
|
5153
|
+
type,
|
|
5154
|
+
uri: raw.uri,
|
|
5155
|
+
name: raw.name,
|
|
5156
|
+
...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
|
|
5157
|
+
...typeof raw.size === "number" ? { size: raw.size } : {}
|
|
5158
|
+
};
|
|
5159
|
+
}
|
|
5160
|
+
if (type === "resource" && raw.resource && typeof raw.resource === "object") {
|
|
5161
|
+
const resource = raw.resource;
|
|
5162
|
+
if (typeof resource.uri !== "string") return null;
|
|
5163
|
+
return {
|
|
5164
|
+
type,
|
|
5165
|
+
resource: {
|
|
5166
|
+
uri: resource.uri,
|
|
5167
|
+
...typeof resource.mimeType === "string" || resource.mimeType === null ? { mimeType: resource.mimeType } : {},
|
|
5168
|
+
...typeof resource.text === "string" ? { text: resource.text } : {},
|
|
5169
|
+
...typeof resource.blob === "string" ? { blob: resource.blob } : {}
|
|
5170
|
+
}
|
|
5171
|
+
};
|
|
5172
|
+
}
|
|
5173
|
+
return null;
|
|
5174
|
+
}
|
|
5175
|
+
function flattenInputParts(parts) {
|
|
5176
|
+
return parts.map((part) => {
|
|
5177
|
+
if (part.type === "text") return part.text;
|
|
5178
|
+
if (part.type === "audio") return part.transcript || "";
|
|
5179
|
+
if (part.type === "resource") return part.text || "";
|
|
5180
|
+
return "";
|
|
5181
|
+
}).filter((value) => value.length > 0).join("\n");
|
|
5182
|
+
}
|
|
5183
|
+
var init_io_contracts = __esm({
|
|
5184
|
+
"../../oss/packages/daemon-core/src/providers/io-contracts.ts"() {
|
|
5185
|
+
"use strict";
|
|
5186
|
+
}
|
|
5187
|
+
});
|
|
5188
|
+
|
|
4982
5189
|
// ../../oss/packages/daemon-core/src/providers/contracts.ts
|
|
4983
5190
|
function flattenContent(content) {
|
|
4984
5191
|
if (typeof content === "string") return content;
|
|
4985
|
-
return
|
|
5192
|
+
return flattenMessageParts(normalizeMessageParts(content));
|
|
4986
5193
|
}
|
|
4987
5194
|
var init_contracts = __esm({
|
|
4988
5195
|
"../../oss/packages/daemon-core/src/providers/contracts.ts"() {
|
|
4989
5196
|
"use strict";
|
|
5197
|
+
init_io_contracts();
|
|
5198
|
+
init_io_contracts();
|
|
4990
5199
|
}
|
|
4991
5200
|
});
|
|
4992
5201
|
|
|
@@ -5184,6 +5393,9 @@ function buildRecentSendKey(h, args, provider, text) {
|
|
|
5184
5393
|
const target = args?.targetSessionId || args?.agentType || h.currentSession?.providerType || h.currentProviderType || h.currentManagerKey || "unknown";
|
|
5185
5394
|
return `${transport}:${target}:${text.trim()}`;
|
|
5186
5395
|
}
|
|
5396
|
+
function getSendChatInputEnvelope(args) {
|
|
5397
|
+
return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
5398
|
+
}
|
|
5187
5399
|
function getHistorySessionId(h, args) {
|
|
5188
5400
|
const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
|
|
5189
5401
|
if (explicit) return explicit;
|
|
@@ -5588,7 +5800,8 @@ async function handleReadChat(h, args) {
|
|
|
5588
5800
|
return buildReadChatCommandResult({ messages: [], status: "idle" }, args);
|
|
5589
5801
|
}
|
|
5590
5802
|
async function handleSendChat(h, args) {
|
|
5591
|
-
const
|
|
5803
|
+
const input = getSendChatInputEnvelope(args);
|
|
5804
|
+
const text = input.textFallback;
|
|
5592
5805
|
if (!text) return { success: false, error: "text required" };
|
|
5593
5806
|
const _log = (msg) => LOG.debug("Command", `[send_chat] ${msg}`);
|
|
5594
5807
|
const provider = h.getProvider(args?.agentType);
|
|
@@ -6502,6 +6715,21 @@ function listDirectoryEntriesSafe(dirPath) {
|
|
|
6502
6715
|
}
|
|
6503
6716
|
return files;
|
|
6504
6717
|
}
|
|
6718
|
+
function listWindowsDriveEntries(excludePath) {
|
|
6719
|
+
const excluded = typeof excludePath === "string" ? excludePath.toLowerCase() : "";
|
|
6720
|
+
const drives = [];
|
|
6721
|
+
for (let code = 65; code <= 90; code += 1) {
|
|
6722
|
+
const letter = String.fromCharCode(code);
|
|
6723
|
+
const root = `${letter}:\\`;
|
|
6724
|
+
try {
|
|
6725
|
+
if (!fs4.existsSync(root)) continue;
|
|
6726
|
+
if (excluded && root.toLowerCase() === excluded) continue;
|
|
6727
|
+
drives.push({ name: `${letter}:`, type: "directory", path: root });
|
|
6728
|
+
} catch {
|
|
6729
|
+
}
|
|
6730
|
+
}
|
|
6731
|
+
return drives;
|
|
6732
|
+
}
|
|
6505
6733
|
async function handleFileRead(h, args) {
|
|
6506
6734
|
try {
|
|
6507
6735
|
const filePath = resolveSafePath(args?.path);
|
|
@@ -6534,6 +6762,14 @@ async function handleFileListBrowse(h, args) {
|
|
|
6534
6762
|
try {
|
|
6535
6763
|
const dirPath = resolveSafePath(args?.path || ".");
|
|
6536
6764
|
const files = listDirectoryEntriesSafe(dirPath).filter((entry) => entry.type === "directory").sort((a, b) => a.name.localeCompare(b.name));
|
|
6765
|
+
if (process.platform === "win32" && /^[A-Za-z]:\\?$/.test(dirPath)) {
|
|
6766
|
+
const driveEntries = listWindowsDriveEntries(dirPath);
|
|
6767
|
+
return {
|
|
6768
|
+
success: true,
|
|
6769
|
+
files: [...driveEntries, ...files],
|
|
6770
|
+
path: dirPath
|
|
6771
|
+
};
|
|
6772
|
+
}
|
|
6537
6773
|
return { success: true, files, path: dirPath };
|
|
6538
6774
|
} catch (e) {
|
|
6539
6775
|
return { success: false, error: e.message };
|
|
@@ -6584,6 +6820,42 @@ var init_cdp_commands = __esm({
|
|
|
6584
6820
|
}
|
|
6585
6821
|
});
|
|
6586
6822
|
|
|
6823
|
+
// ../../oss/packages/daemon-core/src/providers/cli-script-results.ts
|
|
6824
|
+
function parseCliScriptResult(result) {
|
|
6825
|
+
if (typeof result === "string") {
|
|
6826
|
+
try {
|
|
6827
|
+
const parsed = JSON.parse(result);
|
|
6828
|
+
if (parsed && typeof parsed === "object" && parsed.success === false) {
|
|
6829
|
+
return { success: false, payload: parsed };
|
|
6830
|
+
}
|
|
6831
|
+
return { success: true, payload: parsed };
|
|
6832
|
+
} catch {
|
|
6833
|
+
return { success: true, payload: { result } };
|
|
6834
|
+
}
|
|
6835
|
+
}
|
|
6836
|
+
if (result && typeof result === "object" && "success" in result && result.success === false) {
|
|
6837
|
+
return { success: false, payload: result };
|
|
6838
|
+
}
|
|
6839
|
+
return { success: true, payload: result };
|
|
6840
|
+
}
|
|
6841
|
+
function getCliScriptCommand(payload) {
|
|
6842
|
+
if (!payload || typeof payload !== "object") return null;
|
|
6843
|
+
if (typeof payload.sendMessage === "string" && payload.sendMessage.trim()) {
|
|
6844
|
+
return { type: "send_message", text: payload.sendMessage.trim() };
|
|
6845
|
+
}
|
|
6846
|
+
const command = payload.command;
|
|
6847
|
+
if (!command || typeof command !== "object") return null;
|
|
6848
|
+
if (command.type !== "send_message" && command.type !== "pty_write") return null;
|
|
6849
|
+
const text = typeof command.text === "string" ? command.text.trim() : typeof command.message === "string" ? command.message.trim() : "";
|
|
6850
|
+
if (!text) return null;
|
|
6851
|
+
return { type: command.type, text };
|
|
6852
|
+
}
|
|
6853
|
+
var init_cli_script_results = __esm({
|
|
6854
|
+
"../../oss/packages/daemon-core/src/providers/cli-script-results.ts"() {
|
|
6855
|
+
"use strict";
|
|
6856
|
+
}
|
|
6857
|
+
});
|
|
6858
|
+
|
|
6587
6859
|
// ../../oss/packages/daemon-core/src/commands/stream-commands.ts
|
|
6588
6860
|
function getCliPresentationMode(h, targetSessionId) {
|
|
6589
6861
|
if (!targetSessionId) return null;
|
|
@@ -6673,34 +6945,19 @@ function normalizeProviderScriptArgs(args) {
|
|
|
6673
6945
|
}
|
|
6674
6946
|
return normalizedArgs;
|
|
6675
6947
|
}
|
|
6676
|
-
function
|
|
6677
|
-
if (typeof
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
if (parsed && typeof parsed === "object" && parsed.success === false) {
|
|
6681
|
-
return { success: false, payload: parsed };
|
|
6682
|
-
}
|
|
6683
|
-
return { success: true, payload: parsed };
|
|
6684
|
-
} catch {
|
|
6685
|
-
return { success: true, payload: { result } };
|
|
6686
|
-
}
|
|
6948
|
+
function buildControlScriptResult(scriptName, payload) {
|
|
6949
|
+
if (!payload || typeof payload !== "object") return {};
|
|
6950
|
+
if (Array.isArray(payload.options) || Array.isArray(payload.models) || Array.isArray(payload.modes)) {
|
|
6951
|
+
return { controlResult: normalizeControlListResult(payload) };
|
|
6687
6952
|
}
|
|
6688
|
-
|
|
6689
|
-
|
|
6953
|
+
const looksLikeValueMutation = /^set|^change/i.test(scriptName) || payload.currentValue !== void 0 || payload.value !== void 0;
|
|
6954
|
+
if (looksLikeValueMutation) {
|
|
6955
|
+
return { controlResult: normalizeControlSetResult(payload) };
|
|
6690
6956
|
}
|
|
6691
|
-
|
|
6692
|
-
}
|
|
6693
|
-
function getCliScriptCommand(payload) {
|
|
6694
|
-
if (!payload || typeof payload !== "object") return null;
|
|
6695
|
-
if (typeof payload.sendMessage === "string" && payload.sendMessage.trim()) {
|
|
6696
|
-
return { type: "send_message", text: payload.sendMessage.trim() };
|
|
6957
|
+
if (payload.ok !== void 0 || payload.success !== void 0 || Array.isArray(payload.effects)) {
|
|
6958
|
+
return { controlResult: normalizeControlInvokeResult(payload) };
|
|
6697
6959
|
}
|
|
6698
|
-
|
|
6699
|
-
if (!command || typeof command !== "object") return null;
|
|
6700
|
-
if (command.type !== "send_message" && command.type !== "pty_write") return null;
|
|
6701
|
-
const text = typeof command.text === "string" ? command.text.trim() : typeof command.message === "string" ? command.message.trim() : "";
|
|
6702
|
-
if (!text) return null;
|
|
6703
|
-
return { type: command.type, text };
|
|
6960
|
+
return {};
|
|
6704
6961
|
}
|
|
6705
6962
|
function applyProviderPatch(h, args, payload) {
|
|
6706
6963
|
if (!payload || typeof payload !== "object") return;
|
|
@@ -6734,7 +6991,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
6734
6991
|
}
|
|
6735
6992
|
try {
|
|
6736
6993
|
const raw = await adapter.invokeScript(actualScriptName, normalizedArgs);
|
|
6737
|
-
const parsed =
|
|
6994
|
+
const parsed = parseCliScriptResult(raw);
|
|
6738
6995
|
if (!parsed.success) {
|
|
6739
6996
|
return { success: false, ...parsed.payload || {} };
|
|
6740
6997
|
}
|
|
@@ -6745,7 +7002,11 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
6745
7002
|
adapter.writeRaw(cliCommand.text + "\r");
|
|
6746
7003
|
}
|
|
6747
7004
|
applyProviderPatch(h, args, parsed.payload);
|
|
6748
|
-
return {
|
|
7005
|
+
return {
|
|
7006
|
+
success: true,
|
|
7007
|
+
...parsed.payload && typeof parsed.payload === "object" ? parsed.payload : { result: parsed.payload },
|
|
7008
|
+
...buildControlScriptResult(scriptName, parsed.payload)
|
|
7009
|
+
};
|
|
6749
7010
|
} catch (e) {
|
|
6750
7011
|
return { success: false, error: `Script execution failed: ${e.message}` };
|
|
6751
7012
|
}
|
|
@@ -6808,7 +7069,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
6808
7069
|
if (parsed && typeof parsed === "object" && parsed.success === false) {
|
|
6809
7070
|
return { success: false, ...parsed };
|
|
6810
7071
|
}
|
|
6811
|
-
return { success: true, ...parsed };
|
|
7072
|
+
return { success: true, ...parsed, ...buildControlScriptResult(scriptName, parsed) };
|
|
6812
7073
|
} catch {
|
|
6813
7074
|
return { success: true, result };
|
|
6814
7075
|
}
|
|
@@ -6819,9 +7080,6 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
6819
7080
|
return { success: false, error: `Script execution failed: ${e.message}` };
|
|
6820
7081
|
}
|
|
6821
7082
|
}
|
|
6822
|
-
async function handleExtensionScript(h, args, scriptName) {
|
|
6823
|
-
return executeProviderScript(h, args, scriptName);
|
|
6824
|
-
}
|
|
6825
7083
|
async function handleProviderScript(h, args) {
|
|
6826
7084
|
const scriptName = typeof args?.scriptName === "string" ? args.scriptName.trim() : "";
|
|
6827
7085
|
if (!scriptName) return { success: false, error: "scriptName is required" };
|
|
@@ -6871,6 +7129,8 @@ function handleSetIdeExtension(h, args) {
|
|
|
6871
7129
|
var init_stream_commands = __esm({
|
|
6872
7130
|
"../../oss/packages/daemon-core/src/commands/stream-commands.ts"() {
|
|
6873
7131
|
"use strict";
|
|
7132
|
+
init_cli_script_results();
|
|
7133
|
+
init_control_effects();
|
|
6874
7134
|
init_logger();
|
|
6875
7135
|
}
|
|
6876
7136
|
});
|
|
@@ -7289,11 +7549,7 @@ var init_handler = __esm({
|
|
|
7289
7549
|
"focus_session",
|
|
7290
7550
|
"pty_input",
|
|
7291
7551
|
"pty_resize",
|
|
7292
|
-
"invoke_provider_script"
|
|
7293
|
-
"list_extension_models",
|
|
7294
|
-
"set_extension_model",
|
|
7295
|
-
"list_extension_modes",
|
|
7296
|
-
"set_extension_mode"
|
|
7552
|
+
"invoke_provider_script"
|
|
7297
7553
|
]);
|
|
7298
7554
|
if (this._currentRoute.sessionLookupFailed && sessionScopedCommands.has(cmd)) {
|
|
7299
7555
|
const result2 = {
|
|
@@ -7405,17 +7661,9 @@ var init_handler = __esm({
|
|
|
7405
7661
|
return handleGetIdeExtensions(this, args);
|
|
7406
7662
|
case "set_ide_extension":
|
|
7407
7663
|
return handleSetIdeExtension(this, args);
|
|
7408
|
-
// ───
|
|
7664
|
+
// ─── Provider control execution (stream-commands.ts) ──────────
|
|
7409
7665
|
case "invoke_provider_script":
|
|
7410
7666
|
return handleProviderScript(this, args);
|
|
7411
|
-
case "list_extension_models":
|
|
7412
|
-
return handleExtensionScript(this, args, "listModels");
|
|
7413
|
-
case "set_extension_model":
|
|
7414
|
-
return handleExtensionScript(this, args, "setModel");
|
|
7415
|
-
case "list_extension_modes":
|
|
7416
|
-
return handleExtensionScript(this, args, "listModes");
|
|
7417
|
-
case "set_extension_mode":
|
|
7418
|
-
return handleExtensionScript(this, args, "setMode");
|
|
7419
7667
|
// ─── Provider Auto-Fix / Clone (DevServer proxy) ──────────
|
|
7420
7668
|
case "provider_auto_fix":
|
|
7421
7669
|
return this.proxyDevServerPost(args, "auto-implement");
|
|
@@ -7860,14 +8108,14 @@ function applyTerminalColorEnv(env) {
|
|
|
7860
8108
|
function ensureNodePtySpawnHelperPermissions(logFn) {
|
|
7861
8109
|
if (os22.platform() === "win32") return;
|
|
7862
8110
|
try {
|
|
7863
|
-
const
|
|
8111
|
+
const fs19 = __require("fs");
|
|
7864
8112
|
const ptyDir = path32.resolve(path32.dirname(__require.resolve("node-pty")), "..");
|
|
7865
8113
|
const platformArch = `${os22.platform()}-${os22.arch()}`;
|
|
7866
8114
|
const helper = path32.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
7867
|
-
if (
|
|
7868
|
-
const stat4 =
|
|
8115
|
+
if (fs19.existsSync(helper)) {
|
|
8116
|
+
const stat4 = fs19.statSync(helper);
|
|
7869
8117
|
if (!(stat4.mode & 73)) {
|
|
7870
|
-
|
|
8118
|
+
fs19.chmodSync(helper, stat4.mode | 493);
|
|
7871
8119
|
logFn?.(`Fixed spawn-helper permissions: ${helper}`);
|
|
7872
8120
|
}
|
|
7873
8121
|
}
|
|
@@ -8059,8 +8307,8 @@ var init_pty_transport = __esm({
|
|
|
8059
8307
|
let cwd = options.cwd;
|
|
8060
8308
|
if (cwd) {
|
|
8061
8309
|
try {
|
|
8062
|
-
const
|
|
8063
|
-
const stat4 =
|
|
8310
|
+
const fs19 = require("fs");
|
|
8311
|
+
const stat4 = fs19.statSync(cwd);
|
|
8064
8312
|
if (!stat4.isDirectory()) cwd = os8.homedir();
|
|
8065
8313
|
} catch {
|
|
8066
8314
|
cwd = os8.homedir();
|
|
@@ -8158,12 +8406,12 @@ function findBinary(name) {
|
|
|
8158
8406
|
function isScriptBinary(binaryPath) {
|
|
8159
8407
|
if (!path9.isAbsolute(binaryPath)) return false;
|
|
8160
8408
|
try {
|
|
8161
|
-
const
|
|
8162
|
-
const resolved =
|
|
8409
|
+
const fs19 = require("fs");
|
|
8410
|
+
const resolved = fs19.realpathSync(binaryPath);
|
|
8163
8411
|
const head = Buffer.alloc(8);
|
|
8164
|
-
const fd =
|
|
8165
|
-
|
|
8166
|
-
|
|
8412
|
+
const fd = fs19.openSync(resolved, "r");
|
|
8413
|
+
fs19.readSync(fd, head, 0, 8, 0);
|
|
8414
|
+
fs19.closeSync(fd);
|
|
8167
8415
|
let i = 0;
|
|
8168
8416
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
8169
8417
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -8174,12 +8422,12 @@ function isScriptBinary(binaryPath) {
|
|
|
8174
8422
|
function looksLikeMachOOrElf(filePath) {
|
|
8175
8423
|
if (!path9.isAbsolute(filePath)) return false;
|
|
8176
8424
|
try {
|
|
8177
|
-
const
|
|
8178
|
-
const resolved =
|
|
8425
|
+
const fs19 = require("fs");
|
|
8426
|
+
const resolved = fs19.realpathSync(filePath);
|
|
8179
8427
|
const buf = Buffer.alloc(8);
|
|
8180
|
-
const fd =
|
|
8181
|
-
|
|
8182
|
-
|
|
8428
|
+
const fd = fs19.openSync(resolved, "r");
|
|
8429
|
+
fs19.readSync(fd, buf, 0, 8, 0);
|
|
8430
|
+
fs19.closeSync(fd);
|
|
8183
8431
|
let i = 0;
|
|
8184
8432
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
8185
8433
|
const b = buf.subarray(i);
|
|
@@ -10293,6 +10541,23 @@ function getDatabaseSync() {
|
|
|
10293
10541
|
}
|
|
10294
10542
|
return CachedDatabaseSync;
|
|
10295
10543
|
}
|
|
10544
|
+
function getForcedNewSessionScriptName(provider, launchMode) {
|
|
10545
|
+
if (!provider || launchMode !== "new") return null;
|
|
10546
|
+
const resume = provider.resume;
|
|
10547
|
+
if (!resume?.supported) return null;
|
|
10548
|
+
if (Array.isArray(resume.newSessionArgs) && resume.newSessionArgs.length > 0) return null;
|
|
10549
|
+
const controls = Array.isArray(provider.controls) ? provider.controls : [];
|
|
10550
|
+
for (const control of controls) {
|
|
10551
|
+
if (control?.type !== "action") continue;
|
|
10552
|
+
const invokeScript = typeof control?.invokeScript === "string" ? control.invokeScript.trim() : "";
|
|
10553
|
+
if (!invokeScript) continue;
|
|
10554
|
+
const controlId = typeof control?.id === "string" ? control.id.trim() : "";
|
|
10555
|
+
if (controlId === "new_session" || /^new.?session$/i.test(invokeScript)) {
|
|
10556
|
+
return invokeScript;
|
|
10557
|
+
}
|
|
10558
|
+
}
|
|
10559
|
+
return null;
|
|
10560
|
+
}
|
|
10296
10561
|
var os12, path11, crypto3, fs5, import_node_module, CachedDatabaseSync, CliProviderInstance;
|
|
10297
10562
|
var init_cli_provider_instance = __esm({
|
|
10298
10563
|
"../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
|
|
@@ -10302,12 +10567,14 @@ var init_cli_provider_instance = __esm({
|
|
|
10302
10567
|
crypto3 = __toESM(require("crypto"));
|
|
10303
10568
|
fs5 = __toESM(require("fs"));
|
|
10304
10569
|
import_node_module = require("module");
|
|
10570
|
+
init_contracts();
|
|
10305
10571
|
init_provider_cli_adapter();
|
|
10306
10572
|
init_status_monitor();
|
|
10307
10573
|
init_chat_history();
|
|
10308
10574
|
init_logger();
|
|
10309
10575
|
init_control_effects();
|
|
10310
10576
|
init_approval_utils();
|
|
10577
|
+
init_cli_script_results();
|
|
10311
10578
|
CachedDatabaseSync = null;
|
|
10312
10579
|
CliProviderInstance = class {
|
|
10313
10580
|
constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory, options) {
|
|
@@ -10367,6 +10634,7 @@ var init_cli_provider_instance = __esm({
|
|
|
10367
10634
|
this.detectStatusTransition();
|
|
10368
10635
|
});
|
|
10369
10636
|
await this.adapter.spawn();
|
|
10637
|
+
await this.enforceFreshSessionLaunchIfNeeded();
|
|
10370
10638
|
this.maybeAppendRuntimeRecoveryMessage(this.adapter.getRuntimeMetadata());
|
|
10371
10639
|
if (this.providerSessionId) {
|
|
10372
10640
|
this.historyWriter.compactHistorySession(this.type, this.providerSessionId);
|
|
@@ -10558,10 +10826,13 @@ var init_cli_provider_instance = __esm({
|
|
|
10558
10826
|
});
|
|
10559
10827
|
}
|
|
10560
10828
|
onEvent(event, data) {
|
|
10561
|
-
if (event === "send_message"
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10829
|
+
if (event === "send_message") {
|
|
10830
|
+
const input = normalizeInputEnvelope(data);
|
|
10831
|
+
if (input.textFallback) {
|
|
10832
|
+
void this.adapter.sendMessage(input.textFallback).catch((e) => {
|
|
10833
|
+
LOG.warn("CLI", `[${this.type}] send_message failed: ${e?.message || e}`);
|
|
10834
|
+
});
|
|
10835
|
+
}
|
|
10565
10836
|
} else if (event === "server_connected" && data?.serverConn) {
|
|
10566
10837
|
this.adapter.setServerConn(data.serverConn);
|
|
10567
10838
|
} else if (event === "resolve_action" && data) {
|
|
@@ -10579,6 +10850,23 @@ var init_cli_provider_instance = __esm({
|
|
|
10579
10850
|
}
|
|
10580
10851
|
completedDebounceTimer = null;
|
|
10581
10852
|
completedDebouncePending = null;
|
|
10853
|
+
async enforceFreshSessionLaunchIfNeeded() {
|
|
10854
|
+
const scriptName = getForcedNewSessionScriptName(this.provider, this.launchMode);
|
|
10855
|
+
if (!scriptName) return;
|
|
10856
|
+
LOG.info("CLI", `[${this.type}] forcing fresh session launch via script: ${scriptName}`);
|
|
10857
|
+
const raw = await this.adapter.invokeScript(scriptName, {});
|
|
10858
|
+
const parsed = parseCliScriptResult(raw);
|
|
10859
|
+
if (!parsed.success) {
|
|
10860
|
+
throw new Error(parsed.payload?.error || `Failed to invoke fresh-session script '${scriptName}'`);
|
|
10861
|
+
}
|
|
10862
|
+
const cliCommand = getCliScriptCommand(parsed.payload);
|
|
10863
|
+
if (cliCommand?.type === "send_message" && cliCommand.text) {
|
|
10864
|
+
await this.adapter.sendMessage(cliCommand.text);
|
|
10865
|
+
} else if (cliCommand?.type === "pty_write" && cliCommand.text) {
|
|
10866
|
+
this.adapter.writeRaw(cliCommand.text + "\r");
|
|
10867
|
+
}
|
|
10868
|
+
this.applyProviderResponse(parsed.payload, { phase: "immediate" });
|
|
10869
|
+
}
|
|
10582
10870
|
detectStatusTransition() {
|
|
10583
10871
|
const now = Date.now();
|
|
10584
10872
|
const adapterStatus = this.adapter.getStatus();
|
|
@@ -11216,10 +11504,10 @@ function mergeDefs(...defs) {
|
|
|
11216
11504
|
function cloneDef(schema) {
|
|
11217
11505
|
return mergeDefs(schema._zod.def);
|
|
11218
11506
|
}
|
|
11219
|
-
function getElementAtPath(obj,
|
|
11220
|
-
if (!
|
|
11507
|
+
function getElementAtPath(obj, path28) {
|
|
11508
|
+
if (!path28)
|
|
11221
11509
|
return obj;
|
|
11222
|
-
return
|
|
11510
|
+
return path28.reduce((acc, key) => acc?.[key], obj);
|
|
11223
11511
|
}
|
|
11224
11512
|
function promiseAllObject(promisesObj) {
|
|
11225
11513
|
const keys = Object.keys(promisesObj);
|
|
@@ -11531,11 +11819,11 @@ function aborted(x, startIndex = 0) {
|
|
|
11531
11819
|
}
|
|
11532
11820
|
return false;
|
|
11533
11821
|
}
|
|
11534
|
-
function prefixIssues(
|
|
11822
|
+
function prefixIssues(path28, issues) {
|
|
11535
11823
|
return issues.map((iss) => {
|
|
11536
11824
|
var _a2;
|
|
11537
11825
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
11538
|
-
iss.path.unshift(
|
|
11826
|
+
iss.path.unshift(path28);
|
|
11539
11827
|
return iss;
|
|
11540
11828
|
});
|
|
11541
11829
|
}
|
|
@@ -11778,7 +12066,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
11778
12066
|
}
|
|
11779
12067
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
11780
12068
|
const result = { errors: [] };
|
|
11781
|
-
const processError = (error49,
|
|
12069
|
+
const processError = (error49, path28 = []) => {
|
|
11782
12070
|
var _a2, _b;
|
|
11783
12071
|
for (const issue2 of error49.issues) {
|
|
11784
12072
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -11788,7 +12076,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
11788
12076
|
} else if (issue2.code === "invalid_element") {
|
|
11789
12077
|
processError({ issues: issue2.issues }, issue2.path);
|
|
11790
12078
|
} else {
|
|
11791
|
-
const fullpath = [...
|
|
12079
|
+
const fullpath = [...path28, ...issue2.path];
|
|
11792
12080
|
if (fullpath.length === 0) {
|
|
11793
12081
|
result.errors.push(mapper(issue2));
|
|
11794
12082
|
continue;
|
|
@@ -11820,8 +12108,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
11820
12108
|
}
|
|
11821
12109
|
function toDotPath(_path) {
|
|
11822
12110
|
const segs = [];
|
|
11823
|
-
const
|
|
11824
|
-
for (const seg of
|
|
12111
|
+
const path28 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
12112
|
+
for (const seg of path28) {
|
|
11825
12113
|
if (typeof seg === "number")
|
|
11826
12114
|
segs.push(`[${seg}]`);
|
|
11827
12115
|
else if (typeof seg === "symbol")
|
|
@@ -24585,13 +24873,13 @@ function resolveRef(ref, ctx) {
|
|
|
24585
24873
|
if (!ref.startsWith("#")) {
|
|
24586
24874
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
24587
24875
|
}
|
|
24588
|
-
const
|
|
24589
|
-
if (
|
|
24876
|
+
const path28 = ref.slice(1).split("/").filter(Boolean);
|
|
24877
|
+
if (path28.length === 0) {
|
|
24590
24878
|
return ctx.rootSchema;
|
|
24591
24879
|
}
|
|
24592
24880
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
24593
|
-
if (
|
|
24594
|
-
const key =
|
|
24881
|
+
if (path28[0] === defsKey) {
|
|
24882
|
+
const key = path28[1];
|
|
24595
24883
|
if (!key || !ctx.defs[key]) {
|
|
24596
24884
|
throw new Error(`Reference not found: ${ref}`);
|
|
24597
24885
|
}
|
|
@@ -27265,10 +27553,106 @@ var init_acp = __esm({
|
|
|
27265
27553
|
});
|
|
27266
27554
|
|
|
27267
27555
|
// ../../oss/packages/daemon-core/src/providers/acp-provider-instance.ts
|
|
27268
|
-
|
|
27556
|
+
function getPromptCapabilityFlags(agentCapabilities) {
|
|
27557
|
+
const prompt = agentCapabilities?.promptCapabilities || {};
|
|
27558
|
+
return {
|
|
27559
|
+
image: prompt.image === true,
|
|
27560
|
+
audio: prompt.audio === true,
|
|
27561
|
+
embeddedContext: prompt.embeddedContext === true
|
|
27562
|
+
};
|
|
27563
|
+
}
|
|
27564
|
+
function getResourceNameFromUri(uri, fallback) {
|
|
27565
|
+
try {
|
|
27566
|
+
if (uri.startsWith("file://")) {
|
|
27567
|
+
return path12.basename(new URL(uri).pathname) || fallback;
|
|
27568
|
+
}
|
|
27569
|
+
return path12.basename(uri) || fallback;
|
|
27570
|
+
} catch {
|
|
27571
|
+
return fallback;
|
|
27572
|
+
}
|
|
27573
|
+
}
|
|
27574
|
+
function inputPartToResourceLink(part, fallbackName) {
|
|
27575
|
+
if (!part.uri) return null;
|
|
27576
|
+
return {
|
|
27577
|
+
type: "resource_link",
|
|
27578
|
+
uri: part.uri,
|
|
27579
|
+
name: getResourceNameFromUri(part.uri, fallbackName),
|
|
27580
|
+
...part.mimeType ? { mimeType: part.mimeType } : {}
|
|
27581
|
+
};
|
|
27582
|
+
}
|
|
27583
|
+
function appendPromptText(promptParts, text) {
|
|
27584
|
+
const normalized = typeof text === "string" ? text.trim() : "";
|
|
27585
|
+
if (!normalized) return;
|
|
27586
|
+
const last = promptParts[promptParts.length - 1];
|
|
27587
|
+
if (last?.type === "text" && last.text === normalized) return;
|
|
27588
|
+
promptParts.push({ type: "text", text: normalized });
|
|
27589
|
+
}
|
|
27590
|
+
function buildAcpPromptParts(input, agentCapabilities) {
|
|
27591
|
+
const caps = getPromptCapabilityFlags(agentCapabilities);
|
|
27592
|
+
const promptParts = [];
|
|
27593
|
+
for (const part of input.parts) {
|
|
27594
|
+
if (part.type === "text") {
|
|
27595
|
+
promptParts.push({ type: "text", text: part.text });
|
|
27596
|
+
continue;
|
|
27597
|
+
}
|
|
27598
|
+
if (part.type === "image") {
|
|
27599
|
+
if (caps.image && part.data) {
|
|
27600
|
+
promptParts.push({
|
|
27601
|
+
type: "image",
|
|
27602
|
+
data: part.data,
|
|
27603
|
+
mimeType: part.mimeType,
|
|
27604
|
+
...part.uri ? { uri: part.uri } : {}
|
|
27605
|
+
});
|
|
27606
|
+
continue;
|
|
27607
|
+
}
|
|
27608
|
+
const fallback = inputPartToResourceLink(part, "image");
|
|
27609
|
+
if (fallback) promptParts.push(fallback);
|
|
27610
|
+
appendPromptText(promptParts, part.alt || (!part.uri ? `Attached image (${part.mimeType})` : void 0));
|
|
27611
|
+
continue;
|
|
27612
|
+
}
|
|
27613
|
+
if (part.type === "audio") {
|
|
27614
|
+
if (caps.audio && part.data) {
|
|
27615
|
+
promptParts.push({
|
|
27616
|
+
type: "audio",
|
|
27617
|
+
data: part.data,
|
|
27618
|
+
mimeType: part.mimeType
|
|
27619
|
+
});
|
|
27620
|
+
continue;
|
|
27621
|
+
}
|
|
27622
|
+
const fallback = inputPartToResourceLink(part, "audio");
|
|
27623
|
+
if (fallback) promptParts.push(fallback);
|
|
27624
|
+
appendPromptText(promptParts, part.transcript || (!part.uri ? `Attached audio (${part.mimeType})` : void 0));
|
|
27625
|
+
continue;
|
|
27626
|
+
}
|
|
27627
|
+
if (part.type === "resource") {
|
|
27628
|
+
if (caps.embeddedContext && (part.text || part.data)) {
|
|
27629
|
+
promptParts.push({
|
|
27630
|
+
type: "resource",
|
|
27631
|
+
resource: part.text ? { uri: part.uri, text: part.text, mimeType: part.mimeType ?? null } : { uri: part.uri, blob: part.data || "", mimeType: part.mimeType ?? null }
|
|
27632
|
+
});
|
|
27633
|
+
continue;
|
|
27634
|
+
}
|
|
27635
|
+
const fallback = inputPartToResourceLink(part, part.name || "resource");
|
|
27636
|
+
if (fallback) promptParts.push(fallback);
|
|
27637
|
+
appendPromptText(promptParts, part.text || (!part.uri && part.name ? part.name : void 0));
|
|
27638
|
+
continue;
|
|
27639
|
+
}
|
|
27640
|
+
if (part.type === "video") {
|
|
27641
|
+
const fallback = inputPartToResourceLink(part, "video");
|
|
27642
|
+
if (fallback) promptParts.push(fallback);
|
|
27643
|
+
appendPromptText(promptParts, !part.uri ? `Attached video (${part.mimeType})` : void 0);
|
|
27644
|
+
}
|
|
27645
|
+
}
|
|
27646
|
+
if (!promptParts.some((part) => part.type === "text") && input.textFallback) {
|
|
27647
|
+
promptParts.unshift({ type: "text", text: input.textFallback });
|
|
27648
|
+
}
|
|
27649
|
+
return promptParts;
|
|
27650
|
+
}
|
|
27651
|
+
var path12, import_stream, import_child_process5, AcpProviderInstance;
|
|
27269
27652
|
var init_acp_provider_instance = __esm({
|
|
27270
27653
|
"../../oss/packages/daemon-core/src/providers/acp-provider-instance.ts"() {
|
|
27271
27654
|
"use strict";
|
|
27655
|
+
path12 = __toESM(require("path"));
|
|
27272
27656
|
import_stream = require("stream");
|
|
27273
27657
|
import_child_process5 = require("child_process");
|
|
27274
27658
|
init_acp();
|
|
@@ -27403,8 +27787,10 @@ var init_acp_provider_instance = __esm({
|
|
|
27403
27787
|
};
|
|
27404
27788
|
}
|
|
27405
27789
|
onEvent(event, data) {
|
|
27406
|
-
if (event === "send_message"
|
|
27407
|
-
|
|
27790
|
+
if (event === "send_message") {
|
|
27791
|
+
const input = normalizeInputEnvelope(data);
|
|
27792
|
+
const promptParts = buildAcpPromptParts(input, this.agentCapabilities);
|
|
27793
|
+
this.sendPrompt(input.textFallback, promptParts.length > 0 ? promptParts : void 0).catch(
|
|
27408
27794
|
(e) => this.log.warn(`[${this.type}] sendPrompt error: ${e?.message}`)
|
|
27409
27795
|
);
|
|
27410
27796
|
} else if (event === "resolve_action") {
|
|
@@ -27829,18 +28215,34 @@ var init_acp_provider_instance = __esm({
|
|
|
27829
28215
|
this.log.warn(`[${this.type}] Cannot send prompt: no active connection/session`);
|
|
27830
28216
|
return;
|
|
27831
28217
|
}
|
|
27832
|
-
|
|
27833
|
-
|
|
27834
|
-
|
|
27835
|
-
|
|
27836
|
-
|
|
27837
|
-
|
|
27838
|
-
|
|
27839
|
-
|
|
27840
|
-
|
|
27841
|
-
|
|
27842
|
-
|
|
27843
|
-
|
|
28218
|
+
const promptParts = contentBlocks && contentBlocks.length > 0 ? contentBlocks.map((b) => {
|
|
28219
|
+
if (b.type === "text") return { type: "text", text: b.text };
|
|
28220
|
+
if (b.type === "image") {
|
|
28221
|
+
return {
|
|
28222
|
+
type: "image",
|
|
28223
|
+
data: b.data,
|
|
28224
|
+
mimeType: b.mimeType,
|
|
28225
|
+
...b.uri ? { uri: b.uri } : {}
|
|
28226
|
+
};
|
|
28227
|
+
}
|
|
28228
|
+
if (b.type === "audio") {
|
|
28229
|
+
return {
|
|
28230
|
+
type: "audio",
|
|
28231
|
+
data: b.data,
|
|
28232
|
+
mimeType: b.mimeType
|
|
28233
|
+
};
|
|
28234
|
+
}
|
|
28235
|
+
if (b.type === "resource_link") {
|
|
28236
|
+
return {
|
|
28237
|
+
type: "resource_link",
|
|
28238
|
+
uri: b.uri,
|
|
28239
|
+
name: b.name,
|
|
28240
|
+
...b.mimeType ? { mimeType: b.mimeType } : {}
|
|
28241
|
+
};
|
|
28242
|
+
}
|
|
28243
|
+
if (b.type === "resource") return { type: "resource", resource: b.resource };
|
|
28244
|
+
return { type: "text", text: flattenContent([b]) };
|
|
28245
|
+
}) : [{ type: "text", text }];
|
|
27844
28246
|
this.messages.push({
|
|
27845
28247
|
role: "user",
|
|
27846
28248
|
content: contentBlocks && contentBlocks.length > 0 ? contentBlocks : text,
|
|
@@ -27904,6 +28306,13 @@ var init_acp_provider_instance = __esm({
|
|
|
27904
28306
|
this.partialBlocks.push({
|
|
27905
28307
|
type: "image",
|
|
27906
28308
|
data: content.data,
|
|
28309
|
+
mimeType: content.mimeType,
|
|
28310
|
+
...content.uri ? { uri: content.uri } : {}
|
|
28311
|
+
});
|
|
28312
|
+
} else if (content.type === "audio") {
|
|
28313
|
+
this.partialBlocks.push({
|
|
28314
|
+
type: "audio",
|
|
28315
|
+
data: content.data,
|
|
27907
28316
|
mimeType: content.mimeType
|
|
27908
28317
|
});
|
|
27909
28318
|
} else if (content.type === "resource_link") {
|
|
@@ -28182,6 +28591,19 @@ var init_acp_provider_instance = __esm({
|
|
|
28182
28591
|
}
|
|
28183
28592
|
});
|
|
28184
28593
|
|
|
28594
|
+
// ../../oss/packages/daemon-core/src/commands/hosted-runtime-restore.ts
|
|
28595
|
+
function shouldRestoreHostedRuntime(record2, managerTag) {
|
|
28596
|
+
if (!managerTag) return true;
|
|
28597
|
+
const managedBy = typeof record2.managedBy === "string" ? record2.managedBy.trim() : "";
|
|
28598
|
+
if (!managedBy) return true;
|
|
28599
|
+
return managedBy === managerTag;
|
|
28600
|
+
}
|
|
28601
|
+
var init_hosted_runtime_restore = __esm({
|
|
28602
|
+
"../../oss/packages/daemon-core/src/commands/hosted-runtime-restore.ts"() {
|
|
28603
|
+
"use strict";
|
|
28604
|
+
}
|
|
28605
|
+
});
|
|
28606
|
+
|
|
28185
28607
|
// ../../oss/packages/daemon-core/src/commands/cli-manager.ts
|
|
28186
28608
|
function colorize(color, text) {
|
|
28187
28609
|
const fn = chalkApi?.[color];
|
|
@@ -28284,7 +28706,7 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
28284
28706
|
};
|
|
28285
28707
|
}
|
|
28286
28708
|
if (!supportsExplicitSessionStart(resume)) {
|
|
28287
|
-
return { cliArgs: baseArgs, launchMode: "
|
|
28709
|
+
return { cliArgs: baseArgs, launchMode: "new" };
|
|
28288
28710
|
}
|
|
28289
28711
|
const providerSessionId = crypto4.randomUUID();
|
|
28290
28712
|
const newSessionArgs = expandResumeArgs(resume.newSessionArgs, providerSessionId);
|
|
@@ -28294,12 +28716,12 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
28294
28716
|
launchMode: "new"
|
|
28295
28717
|
};
|
|
28296
28718
|
}
|
|
28297
|
-
var os13,
|
|
28719
|
+
var os13, path13, crypto4, import_chalk, chalkModule, chalkApi, DaemonCliManager;
|
|
28298
28720
|
var init_cli_manager = __esm({
|
|
28299
28721
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
28300
28722
|
"use strict";
|
|
28301
28723
|
os13 = __toESM(require("os"));
|
|
28302
|
-
|
|
28724
|
+
path13 = __toESM(require("path"));
|
|
28303
28725
|
crypto4 = __toESM(require("crypto"));
|
|
28304
28726
|
import_chalk = __toESM(require("chalk"));
|
|
28305
28727
|
init_provider_cli_adapter();
|
|
@@ -28311,7 +28733,9 @@ var init_cli_manager = __esm({
|
|
|
28311
28733
|
init_saved_sessions();
|
|
28312
28734
|
init_cli_provider_instance();
|
|
28313
28735
|
init_acp_provider_instance();
|
|
28736
|
+
init_contracts();
|
|
28314
28737
|
init_logger();
|
|
28738
|
+
init_hosted_runtime_restore();
|
|
28315
28739
|
chalkModule = import_chalk.default;
|
|
28316
28740
|
chalkApi = typeof chalkModule.yellow === "function" ? chalkModule : chalkModule.default || null;
|
|
28317
28741
|
DaemonCliManager = class {
|
|
@@ -28452,7 +28876,7 @@ var init_cli_manager = __esm({
|
|
|
28452
28876
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
28453
28877
|
const trimmed = (workingDir || "").trim();
|
|
28454
28878
|
if (!trimmed) throw new Error("working directory required");
|
|
28455
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) :
|
|
28879
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path13.resolve(trimmed);
|
|
28456
28880
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
28457
28881
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
28458
28882
|
const key = crypto4.randomUUID();
|
|
@@ -28500,7 +28924,8 @@ ${installInfo}`
|
|
|
28500
28924
|
instanceManager2.removeInstance(key);
|
|
28501
28925
|
},
|
|
28502
28926
|
sendMessage: async (text) => {
|
|
28503
|
-
|
|
28927
|
+
const input = normalizeInputEnvelope(text);
|
|
28928
|
+
acpInstance.onEvent("send_message", { input });
|
|
28504
28929
|
},
|
|
28505
28930
|
getStatus: () => {
|
|
28506
28931
|
const state = acpInstance.getState();
|
|
@@ -28696,8 +29121,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
28696
29121
|
const sessions = records || await this.deps.listHostedCliRuntimes?.() || [];
|
|
28697
29122
|
let restored = 0;
|
|
28698
29123
|
const restoredBindings = /* @__PURE__ */ new Set();
|
|
29124
|
+
const managerTag = this.deps.hostedRuntimeManagerTag;
|
|
28699
29125
|
for (const record2 of sessions) {
|
|
28700
29126
|
if (!record2?.runtimeId || !record2?.cliType || !record2?.workspace) continue;
|
|
29127
|
+
if (!shouldRestoreHostedRuntime(record2, managerTag)) {
|
|
29128
|
+
LOG.info(
|
|
29129
|
+
"CLI",
|
|
29130
|
+
`\u21B7 Skipping hosted runtime restore owned by ${record2.managedBy}: ${record2.runtimeKey || record2.runtimeId}`
|
|
29131
|
+
);
|
|
29132
|
+
continue;
|
|
29133
|
+
}
|
|
28701
29134
|
if (this.adapters.has(record2.runtimeId) || instanceManager.getInstance(record2.runtimeId)) continue;
|
|
28702
29135
|
const normalizedType = this.providerLoader.resolveAlias(record2.cliType);
|
|
28703
29136
|
const providerMeta = this.providerLoader.getMeta(normalizedType);
|
|
@@ -28901,7 +29334,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
28901
29334
|
if (!found) throw new Error(`CLI agent not running: ${agentType}`);
|
|
28902
29335
|
const { adapter, key } = found;
|
|
28903
29336
|
if (action === "send_chat") {
|
|
28904
|
-
const
|
|
29337
|
+
const input = normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
29338
|
+
const message = input.textFallback;
|
|
28905
29339
|
if (!message) throw new Error("message required for send_chat");
|
|
28906
29340
|
await adapter.sendMessage(message);
|
|
28907
29341
|
return { success: true, status: "generating" };
|
|
@@ -29025,7 +29459,7 @@ var init_readdirp = __esm({
|
|
|
29025
29459
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
29026
29460
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
29027
29461
|
if (wantBigintFsStats) {
|
|
29028
|
-
this._stat = (
|
|
29462
|
+
this._stat = (path28) => statMethod(path28, { bigint: true });
|
|
29029
29463
|
} else {
|
|
29030
29464
|
this._stat = statMethod;
|
|
29031
29465
|
}
|
|
@@ -29050,8 +29484,8 @@ var init_readdirp = __esm({
|
|
|
29050
29484
|
const par = this.parent;
|
|
29051
29485
|
const fil = par && par.files;
|
|
29052
29486
|
if (fil && fil.length > 0) {
|
|
29053
|
-
const { path:
|
|
29054
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
29487
|
+
const { path: path28, depth } = par;
|
|
29488
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path28));
|
|
29055
29489
|
const awaited = await Promise.all(slice);
|
|
29056
29490
|
for (const entry of awaited) {
|
|
29057
29491
|
if (!entry)
|
|
@@ -29091,21 +29525,21 @@ var init_readdirp = __esm({
|
|
|
29091
29525
|
this.reading = false;
|
|
29092
29526
|
}
|
|
29093
29527
|
}
|
|
29094
|
-
async _exploreDir(
|
|
29528
|
+
async _exploreDir(path28, depth) {
|
|
29095
29529
|
let files;
|
|
29096
29530
|
try {
|
|
29097
|
-
files = await (0, import_promises.readdir)(
|
|
29531
|
+
files = await (0, import_promises.readdir)(path28, this._rdOptions);
|
|
29098
29532
|
} catch (error48) {
|
|
29099
29533
|
this._onError(error48);
|
|
29100
29534
|
}
|
|
29101
|
-
return { files, depth, path:
|
|
29535
|
+
return { files, depth, path: path28 };
|
|
29102
29536
|
}
|
|
29103
|
-
async _formatEntry(dirent,
|
|
29537
|
+
async _formatEntry(dirent, path28) {
|
|
29104
29538
|
let entry;
|
|
29105
|
-
const
|
|
29539
|
+
const basename9 = this._isDirent ? dirent.name : dirent;
|
|
29106
29540
|
try {
|
|
29107
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
29108
|
-
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename:
|
|
29541
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path28, basename9));
|
|
29542
|
+
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename9 };
|
|
29109
29543
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
29110
29544
|
} catch (err) {
|
|
29111
29545
|
this._onError(err);
|
|
@@ -29161,16 +29595,16 @@ var init_readdirp = __esm({
|
|
|
29161
29595
|
});
|
|
29162
29596
|
|
|
29163
29597
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
29164
|
-
function createFsWatchInstance(
|
|
29598
|
+
function createFsWatchInstance(path28, options, listener, errHandler, emitRaw) {
|
|
29165
29599
|
const handleEvent = (rawEvent, evPath) => {
|
|
29166
|
-
listener(
|
|
29167
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
29168
|
-
if (evPath &&
|
|
29169
|
-
fsWatchBroadcast(sp.resolve(
|
|
29600
|
+
listener(path28);
|
|
29601
|
+
emitRaw(rawEvent, evPath, { watchedPath: path28 });
|
|
29602
|
+
if (evPath && path28 !== evPath) {
|
|
29603
|
+
fsWatchBroadcast(sp.resolve(path28, evPath), KEY_LISTENERS, sp.join(path28, evPath));
|
|
29170
29604
|
}
|
|
29171
29605
|
};
|
|
29172
29606
|
try {
|
|
29173
|
-
return (0, import_node_fs.watch)(
|
|
29607
|
+
return (0, import_node_fs.watch)(path28, {
|
|
29174
29608
|
persistent: options.persistent
|
|
29175
29609
|
}, handleEvent);
|
|
29176
29610
|
} catch (error48) {
|
|
@@ -29519,12 +29953,12 @@ var init_handler2 = __esm({
|
|
|
29519
29953
|
listener(val1, val2, val3);
|
|
29520
29954
|
});
|
|
29521
29955
|
};
|
|
29522
|
-
setFsWatchListener = (
|
|
29956
|
+
setFsWatchListener = (path28, fullPath, options, handlers) => {
|
|
29523
29957
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
29524
29958
|
let cont = FsWatchInstances.get(fullPath);
|
|
29525
29959
|
let watcher;
|
|
29526
29960
|
if (!options.persistent) {
|
|
29527
|
-
watcher = createFsWatchInstance(
|
|
29961
|
+
watcher = createFsWatchInstance(path28, options, listener, errHandler, rawEmitter);
|
|
29528
29962
|
if (!watcher)
|
|
29529
29963
|
return;
|
|
29530
29964
|
return watcher.close.bind(watcher);
|
|
@@ -29535,7 +29969,7 @@ var init_handler2 = __esm({
|
|
|
29535
29969
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
29536
29970
|
} else {
|
|
29537
29971
|
watcher = createFsWatchInstance(
|
|
29538
|
-
|
|
29972
|
+
path28,
|
|
29539
29973
|
options,
|
|
29540
29974
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
29541
29975
|
errHandler,
|
|
@@ -29550,7 +29984,7 @@ var init_handler2 = __esm({
|
|
|
29550
29984
|
cont.watcherUnusable = true;
|
|
29551
29985
|
if (isWindows && error48.code === "EPERM") {
|
|
29552
29986
|
try {
|
|
29553
|
-
const fd = await (0, import_promises2.open)(
|
|
29987
|
+
const fd = await (0, import_promises2.open)(path28, "r");
|
|
29554
29988
|
await fd.close();
|
|
29555
29989
|
broadcastErr(error48);
|
|
29556
29990
|
} catch (err) {
|
|
@@ -29581,7 +30015,7 @@ var init_handler2 = __esm({
|
|
|
29581
30015
|
};
|
|
29582
30016
|
};
|
|
29583
30017
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
29584
|
-
setFsWatchFileListener = (
|
|
30018
|
+
setFsWatchFileListener = (path28, fullPath, options, handlers) => {
|
|
29585
30019
|
const { listener, rawEmitter } = handlers;
|
|
29586
30020
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
29587
30021
|
const copts = cont && cont.options;
|
|
@@ -29603,7 +30037,7 @@ var init_handler2 = __esm({
|
|
|
29603
30037
|
});
|
|
29604
30038
|
const currmtime = curr.mtimeMs;
|
|
29605
30039
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
29606
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
30040
|
+
foreach(cont.listeners, (listener2) => listener2(path28, curr));
|
|
29607
30041
|
}
|
|
29608
30042
|
})
|
|
29609
30043
|
};
|
|
@@ -29633,13 +30067,13 @@ var init_handler2 = __esm({
|
|
|
29633
30067
|
* @param listener on fs change
|
|
29634
30068
|
* @returns closer for the watcher instance
|
|
29635
30069
|
*/
|
|
29636
|
-
_watchWithNodeFs(
|
|
30070
|
+
_watchWithNodeFs(path28, listener) {
|
|
29637
30071
|
const opts = this.fsw.options;
|
|
29638
|
-
const directory = sp.dirname(
|
|
29639
|
-
const
|
|
30072
|
+
const directory = sp.dirname(path28);
|
|
30073
|
+
const basename9 = sp.basename(path28);
|
|
29640
30074
|
const parent = this.fsw._getWatchedDir(directory);
|
|
29641
|
-
parent.add(
|
|
29642
|
-
const absolutePath = sp.resolve(
|
|
30075
|
+
parent.add(basename9);
|
|
30076
|
+
const absolutePath = sp.resolve(path28);
|
|
29643
30077
|
const options = {
|
|
29644
30078
|
persistent: opts.persistent
|
|
29645
30079
|
};
|
|
@@ -29648,13 +30082,13 @@ var init_handler2 = __esm({
|
|
|
29648
30082
|
let closer;
|
|
29649
30083
|
if (opts.usePolling) {
|
|
29650
30084
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
29651
|
-
options.interval = enableBin && isBinaryPath(
|
|
29652
|
-
closer = setFsWatchFileListener(
|
|
30085
|
+
options.interval = enableBin && isBinaryPath(basename9) ? opts.binaryInterval : opts.interval;
|
|
30086
|
+
closer = setFsWatchFileListener(path28, absolutePath, options, {
|
|
29653
30087
|
listener,
|
|
29654
30088
|
rawEmitter: this.fsw._emitRaw
|
|
29655
30089
|
});
|
|
29656
30090
|
} else {
|
|
29657
|
-
closer = setFsWatchListener(
|
|
30091
|
+
closer = setFsWatchListener(path28, absolutePath, options, {
|
|
29658
30092
|
listener,
|
|
29659
30093
|
errHandler: this._boundHandleError,
|
|
29660
30094
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -29671,12 +30105,12 @@ var init_handler2 = __esm({
|
|
|
29671
30105
|
return;
|
|
29672
30106
|
}
|
|
29673
30107
|
const dirname9 = sp.dirname(file2);
|
|
29674
|
-
const
|
|
30108
|
+
const basename9 = sp.basename(file2);
|
|
29675
30109
|
const parent = this.fsw._getWatchedDir(dirname9);
|
|
29676
30110
|
let prevStats = stats;
|
|
29677
|
-
if (parent.has(
|
|
30111
|
+
if (parent.has(basename9))
|
|
29678
30112
|
return;
|
|
29679
|
-
const listener = async (
|
|
30113
|
+
const listener = async (path28, newStats) => {
|
|
29680
30114
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
29681
30115
|
return;
|
|
29682
30116
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -29690,18 +30124,18 @@ var init_handler2 = __esm({
|
|
|
29690
30124
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
29691
30125
|
}
|
|
29692
30126
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
29693
|
-
this.fsw._closeFile(
|
|
30127
|
+
this.fsw._closeFile(path28);
|
|
29694
30128
|
prevStats = newStats2;
|
|
29695
30129
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
29696
30130
|
if (closer2)
|
|
29697
|
-
this.fsw._addPathCloser(
|
|
30131
|
+
this.fsw._addPathCloser(path28, closer2);
|
|
29698
30132
|
} else {
|
|
29699
30133
|
prevStats = newStats2;
|
|
29700
30134
|
}
|
|
29701
30135
|
} catch (error48) {
|
|
29702
|
-
this.fsw._remove(dirname9,
|
|
30136
|
+
this.fsw._remove(dirname9, basename9);
|
|
29703
30137
|
}
|
|
29704
|
-
} else if (parent.has(
|
|
30138
|
+
} else if (parent.has(basename9)) {
|
|
29705
30139
|
const at = newStats.atimeMs;
|
|
29706
30140
|
const mt = newStats.mtimeMs;
|
|
29707
30141
|
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
|
@@ -29726,7 +30160,7 @@ var init_handler2 = __esm({
|
|
|
29726
30160
|
* @param item basename of this item
|
|
29727
30161
|
* @returns true if no more processing is needed for this entry.
|
|
29728
30162
|
*/
|
|
29729
|
-
async _handleSymlink(entry, directory,
|
|
30163
|
+
async _handleSymlink(entry, directory, path28, item) {
|
|
29730
30164
|
if (this.fsw.closed) {
|
|
29731
30165
|
return;
|
|
29732
30166
|
}
|
|
@@ -29736,7 +30170,7 @@ var init_handler2 = __esm({
|
|
|
29736
30170
|
this.fsw._incrReadyCount();
|
|
29737
30171
|
let linkPath;
|
|
29738
30172
|
try {
|
|
29739
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
30173
|
+
linkPath = await (0, import_promises2.realpath)(path28);
|
|
29740
30174
|
} catch (e) {
|
|
29741
30175
|
this.fsw._emitReady();
|
|
29742
30176
|
return true;
|
|
@@ -29746,12 +30180,12 @@ var init_handler2 = __esm({
|
|
|
29746
30180
|
if (dir.has(item)) {
|
|
29747
30181
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
29748
30182
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
29749
|
-
this.fsw._emit(EV.CHANGE,
|
|
30183
|
+
this.fsw._emit(EV.CHANGE, path28, entry.stats);
|
|
29750
30184
|
}
|
|
29751
30185
|
} else {
|
|
29752
30186
|
dir.add(item);
|
|
29753
30187
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
29754
|
-
this.fsw._emit(EV.ADD,
|
|
30188
|
+
this.fsw._emit(EV.ADD, path28, entry.stats);
|
|
29755
30189
|
}
|
|
29756
30190
|
this.fsw._emitReady();
|
|
29757
30191
|
return true;
|
|
@@ -29781,9 +30215,9 @@ var init_handler2 = __esm({
|
|
|
29781
30215
|
return;
|
|
29782
30216
|
}
|
|
29783
30217
|
const item = entry.path;
|
|
29784
|
-
let
|
|
30218
|
+
let path28 = sp.join(directory, item);
|
|
29785
30219
|
current.add(item);
|
|
29786
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
30220
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path28, item)) {
|
|
29787
30221
|
return;
|
|
29788
30222
|
}
|
|
29789
30223
|
if (this.fsw.closed) {
|
|
@@ -29792,8 +30226,8 @@ var init_handler2 = __esm({
|
|
|
29792
30226
|
}
|
|
29793
30227
|
if (item === target || !target && !previous.has(item)) {
|
|
29794
30228
|
this.fsw._incrReadyCount();
|
|
29795
|
-
|
|
29796
|
-
this._addToNodeFs(
|
|
30229
|
+
path28 = sp.join(dir, sp.relative(dir, path28));
|
|
30230
|
+
this._addToNodeFs(path28, initialAdd, wh, depth + 1);
|
|
29797
30231
|
}
|
|
29798
30232
|
}).on(EV.ERROR, this._boundHandleError);
|
|
29799
30233
|
return new Promise((resolve16, reject) => {
|
|
@@ -29862,13 +30296,13 @@ var init_handler2 = __esm({
|
|
|
29862
30296
|
* @param depth Child path actually targeted for watch
|
|
29863
30297
|
* @param target Child path actually targeted for watch
|
|
29864
30298
|
*/
|
|
29865
|
-
async _addToNodeFs(
|
|
30299
|
+
async _addToNodeFs(path28, initialAdd, priorWh, depth, target) {
|
|
29866
30300
|
const ready = this.fsw._emitReady;
|
|
29867
|
-
if (this.fsw._isIgnored(
|
|
30301
|
+
if (this.fsw._isIgnored(path28) || this.fsw.closed) {
|
|
29868
30302
|
ready();
|
|
29869
30303
|
return false;
|
|
29870
30304
|
}
|
|
29871
|
-
const wh = this.fsw._getWatchHelpers(
|
|
30305
|
+
const wh = this.fsw._getWatchHelpers(path28);
|
|
29872
30306
|
if (priorWh) {
|
|
29873
30307
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
29874
30308
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -29884,8 +30318,8 @@ var init_handler2 = __esm({
|
|
|
29884
30318
|
const follow = this.fsw.options.followSymlinks;
|
|
29885
30319
|
let closer;
|
|
29886
30320
|
if (stats.isDirectory()) {
|
|
29887
|
-
const absPath = sp.resolve(
|
|
29888
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
30321
|
+
const absPath = sp.resolve(path28);
|
|
30322
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path28) : path28;
|
|
29889
30323
|
if (this.fsw.closed)
|
|
29890
30324
|
return;
|
|
29891
30325
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -29895,29 +30329,29 @@ var init_handler2 = __esm({
|
|
|
29895
30329
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
29896
30330
|
}
|
|
29897
30331
|
} else if (stats.isSymbolicLink()) {
|
|
29898
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
30332
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path28) : path28;
|
|
29899
30333
|
if (this.fsw.closed)
|
|
29900
30334
|
return;
|
|
29901
30335
|
const parent = sp.dirname(wh.watchPath);
|
|
29902
30336
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
29903
30337
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
29904
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
30338
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path28, wh, targetPath);
|
|
29905
30339
|
if (this.fsw.closed)
|
|
29906
30340
|
return;
|
|
29907
30341
|
if (targetPath !== void 0) {
|
|
29908
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
30342
|
+
this.fsw._symlinkPaths.set(sp.resolve(path28), targetPath);
|
|
29909
30343
|
}
|
|
29910
30344
|
} else {
|
|
29911
30345
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
29912
30346
|
}
|
|
29913
30347
|
ready();
|
|
29914
30348
|
if (closer)
|
|
29915
|
-
this.fsw._addPathCloser(
|
|
30349
|
+
this.fsw._addPathCloser(path28, closer);
|
|
29916
30350
|
return false;
|
|
29917
30351
|
} catch (error48) {
|
|
29918
30352
|
if (this.fsw._handleError(error48)) {
|
|
29919
30353
|
ready();
|
|
29920
|
-
return
|
|
30354
|
+
return path28;
|
|
29921
30355
|
}
|
|
29922
30356
|
}
|
|
29923
30357
|
}
|
|
@@ -29952,24 +30386,24 @@ function createPattern(matcher) {
|
|
|
29952
30386
|
}
|
|
29953
30387
|
return () => false;
|
|
29954
30388
|
}
|
|
29955
|
-
function normalizePath(
|
|
29956
|
-
if (typeof
|
|
30389
|
+
function normalizePath(path28) {
|
|
30390
|
+
if (typeof path28 !== "string")
|
|
29957
30391
|
throw new Error("string expected");
|
|
29958
|
-
|
|
29959
|
-
|
|
30392
|
+
path28 = sp2.normalize(path28);
|
|
30393
|
+
path28 = path28.replace(/\\/g, "/");
|
|
29960
30394
|
let prepend = false;
|
|
29961
|
-
if (
|
|
30395
|
+
if (path28.startsWith("//"))
|
|
29962
30396
|
prepend = true;
|
|
29963
|
-
|
|
30397
|
+
path28 = path28.replace(DOUBLE_SLASH_RE, "/");
|
|
29964
30398
|
if (prepend)
|
|
29965
|
-
|
|
29966
|
-
return
|
|
30399
|
+
path28 = "/" + path28;
|
|
30400
|
+
return path28;
|
|
29967
30401
|
}
|
|
29968
30402
|
function matchPatterns(patterns, testString, stats) {
|
|
29969
|
-
const
|
|
30403
|
+
const path28 = normalizePath(testString);
|
|
29970
30404
|
for (let index = 0; index < patterns.length; index++) {
|
|
29971
30405
|
const pattern = patterns[index];
|
|
29972
|
-
if (pattern(
|
|
30406
|
+
if (pattern(path28, stats)) {
|
|
29973
30407
|
return true;
|
|
29974
30408
|
}
|
|
29975
30409
|
}
|
|
@@ -30032,19 +30466,19 @@ var init_chokidar = __esm({
|
|
|
30032
30466
|
}
|
|
30033
30467
|
return str;
|
|
30034
30468
|
};
|
|
30035
|
-
normalizePathToUnix = (
|
|
30036
|
-
normalizeIgnored = (cwd = "") => (
|
|
30037
|
-
if (typeof
|
|
30038
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
30469
|
+
normalizePathToUnix = (path28) => toUnix(sp2.normalize(toUnix(path28)));
|
|
30470
|
+
normalizeIgnored = (cwd = "") => (path28) => {
|
|
30471
|
+
if (typeof path28 === "string") {
|
|
30472
|
+
return normalizePathToUnix(sp2.isAbsolute(path28) ? path28 : sp2.join(cwd, path28));
|
|
30039
30473
|
} else {
|
|
30040
|
-
return
|
|
30474
|
+
return path28;
|
|
30041
30475
|
}
|
|
30042
30476
|
};
|
|
30043
|
-
getAbsolutePath = (
|
|
30044
|
-
if (sp2.isAbsolute(
|
|
30045
|
-
return
|
|
30477
|
+
getAbsolutePath = (path28, cwd) => {
|
|
30478
|
+
if (sp2.isAbsolute(path28)) {
|
|
30479
|
+
return path28;
|
|
30046
30480
|
}
|
|
30047
|
-
return sp2.join(cwd,
|
|
30481
|
+
return sp2.join(cwd, path28);
|
|
30048
30482
|
};
|
|
30049
30483
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
30050
30484
|
DirEntry = class {
|
|
@@ -30109,10 +30543,10 @@ var init_chokidar = __esm({
|
|
|
30109
30543
|
dirParts;
|
|
30110
30544
|
followSymlinks;
|
|
30111
30545
|
statMethod;
|
|
30112
|
-
constructor(
|
|
30546
|
+
constructor(path28, follow, fsw) {
|
|
30113
30547
|
this.fsw = fsw;
|
|
30114
|
-
const watchPath =
|
|
30115
|
-
this.path =
|
|
30548
|
+
const watchPath = path28;
|
|
30549
|
+
this.path = path28 = path28.replace(REPLACER_RE, "");
|
|
30116
30550
|
this.watchPath = watchPath;
|
|
30117
30551
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
30118
30552
|
this.dirParts = [];
|
|
@@ -30252,20 +30686,20 @@ var init_chokidar = __esm({
|
|
|
30252
30686
|
this._closePromise = void 0;
|
|
30253
30687
|
let paths = unifyPaths(paths_);
|
|
30254
30688
|
if (cwd) {
|
|
30255
|
-
paths = paths.map((
|
|
30256
|
-
const absPath = getAbsolutePath(
|
|
30689
|
+
paths = paths.map((path28) => {
|
|
30690
|
+
const absPath = getAbsolutePath(path28, cwd);
|
|
30257
30691
|
return absPath;
|
|
30258
30692
|
});
|
|
30259
30693
|
}
|
|
30260
|
-
paths.forEach((
|
|
30261
|
-
this._removeIgnoredPath(
|
|
30694
|
+
paths.forEach((path28) => {
|
|
30695
|
+
this._removeIgnoredPath(path28);
|
|
30262
30696
|
});
|
|
30263
30697
|
this._userIgnored = void 0;
|
|
30264
30698
|
if (!this._readyCount)
|
|
30265
30699
|
this._readyCount = 0;
|
|
30266
30700
|
this._readyCount += paths.length;
|
|
30267
|
-
Promise.all(paths.map(async (
|
|
30268
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
30701
|
+
Promise.all(paths.map(async (path28) => {
|
|
30702
|
+
const res = await this._nodeFsHandler._addToNodeFs(path28, !_internal, void 0, 0, _origAdd);
|
|
30269
30703
|
if (res)
|
|
30270
30704
|
this._emitReady();
|
|
30271
30705
|
return res;
|
|
@@ -30287,17 +30721,17 @@ var init_chokidar = __esm({
|
|
|
30287
30721
|
return this;
|
|
30288
30722
|
const paths = unifyPaths(paths_);
|
|
30289
30723
|
const { cwd } = this.options;
|
|
30290
|
-
paths.forEach((
|
|
30291
|
-
if (!sp2.isAbsolute(
|
|
30724
|
+
paths.forEach((path28) => {
|
|
30725
|
+
if (!sp2.isAbsolute(path28) && !this._closers.has(path28)) {
|
|
30292
30726
|
if (cwd)
|
|
30293
|
-
|
|
30294
|
-
|
|
30727
|
+
path28 = sp2.join(cwd, path28);
|
|
30728
|
+
path28 = sp2.resolve(path28);
|
|
30295
30729
|
}
|
|
30296
|
-
this._closePath(
|
|
30297
|
-
this._addIgnoredPath(
|
|
30298
|
-
if (this._watched.has(
|
|
30730
|
+
this._closePath(path28);
|
|
30731
|
+
this._addIgnoredPath(path28);
|
|
30732
|
+
if (this._watched.has(path28)) {
|
|
30299
30733
|
this._addIgnoredPath({
|
|
30300
|
-
path:
|
|
30734
|
+
path: path28,
|
|
30301
30735
|
recursive: true
|
|
30302
30736
|
});
|
|
30303
30737
|
}
|
|
@@ -30361,38 +30795,38 @@ var init_chokidar = __esm({
|
|
|
30361
30795
|
* @param stats arguments to be passed with event
|
|
30362
30796
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
30363
30797
|
*/
|
|
30364
|
-
async _emit(event,
|
|
30798
|
+
async _emit(event, path28, stats) {
|
|
30365
30799
|
if (this.closed)
|
|
30366
30800
|
return;
|
|
30367
30801
|
const opts = this.options;
|
|
30368
30802
|
if (isWindows)
|
|
30369
|
-
|
|
30803
|
+
path28 = sp2.normalize(path28);
|
|
30370
30804
|
if (opts.cwd)
|
|
30371
|
-
|
|
30372
|
-
const args = [
|
|
30805
|
+
path28 = sp2.relative(opts.cwd, path28);
|
|
30806
|
+
const args = [path28];
|
|
30373
30807
|
if (stats != null)
|
|
30374
30808
|
args.push(stats);
|
|
30375
30809
|
const awf = opts.awaitWriteFinish;
|
|
30376
30810
|
let pw;
|
|
30377
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
30811
|
+
if (awf && (pw = this._pendingWrites.get(path28))) {
|
|
30378
30812
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
30379
30813
|
return this;
|
|
30380
30814
|
}
|
|
30381
30815
|
if (opts.atomic) {
|
|
30382
30816
|
if (event === EVENTS.UNLINK) {
|
|
30383
|
-
this._pendingUnlinks.set(
|
|
30817
|
+
this._pendingUnlinks.set(path28, [event, ...args]);
|
|
30384
30818
|
setTimeout(() => {
|
|
30385
|
-
this._pendingUnlinks.forEach((entry,
|
|
30819
|
+
this._pendingUnlinks.forEach((entry, path29) => {
|
|
30386
30820
|
this.emit(...entry);
|
|
30387
30821
|
this.emit(EVENTS.ALL, ...entry);
|
|
30388
|
-
this._pendingUnlinks.delete(
|
|
30822
|
+
this._pendingUnlinks.delete(path29);
|
|
30389
30823
|
});
|
|
30390
30824
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
30391
30825
|
return this;
|
|
30392
30826
|
}
|
|
30393
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
30827
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path28)) {
|
|
30394
30828
|
event = EVENTS.CHANGE;
|
|
30395
|
-
this._pendingUnlinks.delete(
|
|
30829
|
+
this._pendingUnlinks.delete(path28);
|
|
30396
30830
|
}
|
|
30397
30831
|
}
|
|
30398
30832
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -30410,16 +30844,16 @@ var init_chokidar = __esm({
|
|
|
30410
30844
|
this.emitWithAll(event, args);
|
|
30411
30845
|
}
|
|
30412
30846
|
};
|
|
30413
|
-
this._awaitWriteFinish(
|
|
30847
|
+
this._awaitWriteFinish(path28, awf.stabilityThreshold, event, awfEmit);
|
|
30414
30848
|
return this;
|
|
30415
30849
|
}
|
|
30416
30850
|
if (event === EVENTS.CHANGE) {
|
|
30417
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
30851
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path28, 50);
|
|
30418
30852
|
if (isThrottled)
|
|
30419
30853
|
return this;
|
|
30420
30854
|
}
|
|
30421
30855
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
30422
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
30856
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path28) : path28;
|
|
30423
30857
|
let stats2;
|
|
30424
30858
|
try {
|
|
30425
30859
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -30450,23 +30884,23 @@ var init_chokidar = __esm({
|
|
|
30450
30884
|
* @param timeout duration of time to suppress duplicate actions
|
|
30451
30885
|
* @returns tracking object or false if action should be suppressed
|
|
30452
30886
|
*/
|
|
30453
|
-
_throttle(actionType,
|
|
30887
|
+
_throttle(actionType, path28, timeout) {
|
|
30454
30888
|
if (!this._throttled.has(actionType)) {
|
|
30455
30889
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
30456
30890
|
}
|
|
30457
30891
|
const action = this._throttled.get(actionType);
|
|
30458
30892
|
if (!action)
|
|
30459
30893
|
throw new Error("invalid throttle");
|
|
30460
|
-
const actionPath = action.get(
|
|
30894
|
+
const actionPath = action.get(path28);
|
|
30461
30895
|
if (actionPath) {
|
|
30462
30896
|
actionPath.count++;
|
|
30463
30897
|
return false;
|
|
30464
30898
|
}
|
|
30465
30899
|
let timeoutObject;
|
|
30466
30900
|
const clear = () => {
|
|
30467
|
-
const item = action.get(
|
|
30901
|
+
const item = action.get(path28);
|
|
30468
30902
|
const count = item ? item.count : 0;
|
|
30469
|
-
action.delete(
|
|
30903
|
+
action.delete(path28);
|
|
30470
30904
|
clearTimeout(timeoutObject);
|
|
30471
30905
|
if (item)
|
|
30472
30906
|
clearTimeout(item.timeoutObject);
|
|
@@ -30474,7 +30908,7 @@ var init_chokidar = __esm({
|
|
|
30474
30908
|
};
|
|
30475
30909
|
timeoutObject = setTimeout(clear, timeout);
|
|
30476
30910
|
const thr = { timeoutObject, clear, count: 0 };
|
|
30477
|
-
action.set(
|
|
30911
|
+
action.set(path28, thr);
|
|
30478
30912
|
return thr;
|
|
30479
30913
|
}
|
|
30480
30914
|
_incrReadyCount() {
|
|
@@ -30488,44 +30922,44 @@ var init_chokidar = __esm({
|
|
|
30488
30922
|
* @param event
|
|
30489
30923
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
30490
30924
|
*/
|
|
30491
|
-
_awaitWriteFinish(
|
|
30925
|
+
_awaitWriteFinish(path28, threshold, event, awfEmit) {
|
|
30492
30926
|
const awf = this.options.awaitWriteFinish;
|
|
30493
30927
|
if (typeof awf !== "object")
|
|
30494
30928
|
return;
|
|
30495
30929
|
const pollInterval = awf.pollInterval;
|
|
30496
30930
|
let timeoutHandler;
|
|
30497
|
-
let fullPath =
|
|
30498
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
30499
|
-
fullPath = sp2.join(this.options.cwd,
|
|
30931
|
+
let fullPath = path28;
|
|
30932
|
+
if (this.options.cwd && !sp2.isAbsolute(path28)) {
|
|
30933
|
+
fullPath = sp2.join(this.options.cwd, path28);
|
|
30500
30934
|
}
|
|
30501
30935
|
const now = /* @__PURE__ */ new Date();
|
|
30502
30936
|
const writes = this._pendingWrites;
|
|
30503
30937
|
function awaitWriteFinishFn(prevStat) {
|
|
30504
30938
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
30505
|
-
if (err || !writes.has(
|
|
30939
|
+
if (err || !writes.has(path28)) {
|
|
30506
30940
|
if (err && err.code !== "ENOENT")
|
|
30507
30941
|
awfEmit(err);
|
|
30508
30942
|
return;
|
|
30509
30943
|
}
|
|
30510
30944
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
30511
30945
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
30512
|
-
writes.get(
|
|
30946
|
+
writes.get(path28).lastChange = now2;
|
|
30513
30947
|
}
|
|
30514
|
-
const pw = writes.get(
|
|
30948
|
+
const pw = writes.get(path28);
|
|
30515
30949
|
const df = now2 - pw.lastChange;
|
|
30516
30950
|
if (df >= threshold) {
|
|
30517
|
-
writes.delete(
|
|
30951
|
+
writes.delete(path28);
|
|
30518
30952
|
awfEmit(void 0, curStat);
|
|
30519
30953
|
} else {
|
|
30520
30954
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
30521
30955
|
}
|
|
30522
30956
|
});
|
|
30523
30957
|
}
|
|
30524
|
-
if (!writes.has(
|
|
30525
|
-
writes.set(
|
|
30958
|
+
if (!writes.has(path28)) {
|
|
30959
|
+
writes.set(path28, {
|
|
30526
30960
|
lastChange: now,
|
|
30527
30961
|
cancelWait: () => {
|
|
30528
|
-
writes.delete(
|
|
30962
|
+
writes.delete(path28);
|
|
30529
30963
|
clearTimeout(timeoutHandler);
|
|
30530
30964
|
return event;
|
|
30531
30965
|
}
|
|
@@ -30536,8 +30970,8 @@ var init_chokidar = __esm({
|
|
|
30536
30970
|
/**
|
|
30537
30971
|
* Determines whether user has asked to ignore this path.
|
|
30538
30972
|
*/
|
|
30539
|
-
_isIgnored(
|
|
30540
|
-
if (this.options.atomic && DOT_RE.test(
|
|
30973
|
+
_isIgnored(path28, stats) {
|
|
30974
|
+
if (this.options.atomic && DOT_RE.test(path28))
|
|
30541
30975
|
return true;
|
|
30542
30976
|
if (!this._userIgnored) {
|
|
30543
30977
|
const { cwd } = this.options;
|
|
@@ -30547,17 +30981,17 @@ var init_chokidar = __esm({
|
|
|
30547
30981
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
30548
30982
|
this._userIgnored = anymatch(list, void 0);
|
|
30549
30983
|
}
|
|
30550
|
-
return this._userIgnored(
|
|
30984
|
+
return this._userIgnored(path28, stats);
|
|
30551
30985
|
}
|
|
30552
|
-
_isntIgnored(
|
|
30553
|
-
return !this._isIgnored(
|
|
30986
|
+
_isntIgnored(path28, stat4) {
|
|
30987
|
+
return !this._isIgnored(path28, stat4);
|
|
30554
30988
|
}
|
|
30555
30989
|
/**
|
|
30556
30990
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
30557
30991
|
* @param path file or directory pattern being watched
|
|
30558
30992
|
*/
|
|
30559
|
-
_getWatchHelpers(
|
|
30560
|
-
return new WatchHelper(
|
|
30993
|
+
_getWatchHelpers(path28) {
|
|
30994
|
+
return new WatchHelper(path28, this.options.followSymlinks, this);
|
|
30561
30995
|
}
|
|
30562
30996
|
// Directory helpers
|
|
30563
30997
|
// -----------------
|
|
@@ -30589,63 +31023,63 @@ var init_chokidar = __esm({
|
|
|
30589
31023
|
* @param item base path of item/directory
|
|
30590
31024
|
*/
|
|
30591
31025
|
_remove(directory, item, isDirectory) {
|
|
30592
|
-
const
|
|
30593
|
-
const fullPath = sp2.resolve(
|
|
30594
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
30595
|
-
if (!this._throttle("remove",
|
|
31026
|
+
const path28 = sp2.join(directory, item);
|
|
31027
|
+
const fullPath = sp2.resolve(path28);
|
|
31028
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path28) || this._watched.has(fullPath);
|
|
31029
|
+
if (!this._throttle("remove", path28, 100))
|
|
30596
31030
|
return;
|
|
30597
31031
|
if (!isDirectory && this._watched.size === 1) {
|
|
30598
31032
|
this.add(directory, item, true);
|
|
30599
31033
|
}
|
|
30600
|
-
const wp = this._getWatchedDir(
|
|
31034
|
+
const wp = this._getWatchedDir(path28);
|
|
30601
31035
|
const nestedDirectoryChildren = wp.getChildren();
|
|
30602
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
31036
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path28, nested));
|
|
30603
31037
|
const parent = this._getWatchedDir(directory);
|
|
30604
31038
|
const wasTracked = parent.has(item);
|
|
30605
31039
|
parent.remove(item);
|
|
30606
31040
|
if (this._symlinkPaths.has(fullPath)) {
|
|
30607
31041
|
this._symlinkPaths.delete(fullPath);
|
|
30608
31042
|
}
|
|
30609
|
-
let relPath =
|
|
31043
|
+
let relPath = path28;
|
|
30610
31044
|
if (this.options.cwd)
|
|
30611
|
-
relPath = sp2.relative(this.options.cwd,
|
|
31045
|
+
relPath = sp2.relative(this.options.cwd, path28);
|
|
30612
31046
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
30613
31047
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
30614
31048
|
if (event === EVENTS.ADD)
|
|
30615
31049
|
return;
|
|
30616
31050
|
}
|
|
30617
|
-
this._watched.delete(
|
|
31051
|
+
this._watched.delete(path28);
|
|
30618
31052
|
this._watched.delete(fullPath);
|
|
30619
31053
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
30620
|
-
if (wasTracked && !this._isIgnored(
|
|
30621
|
-
this._emit(eventName,
|
|
30622
|
-
this._closePath(
|
|
31054
|
+
if (wasTracked && !this._isIgnored(path28))
|
|
31055
|
+
this._emit(eventName, path28);
|
|
31056
|
+
this._closePath(path28);
|
|
30623
31057
|
}
|
|
30624
31058
|
/**
|
|
30625
31059
|
* Closes all watchers for a path
|
|
30626
31060
|
*/
|
|
30627
|
-
_closePath(
|
|
30628
|
-
this._closeFile(
|
|
30629
|
-
const dir = sp2.dirname(
|
|
30630
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
31061
|
+
_closePath(path28) {
|
|
31062
|
+
this._closeFile(path28);
|
|
31063
|
+
const dir = sp2.dirname(path28);
|
|
31064
|
+
this._getWatchedDir(dir).remove(sp2.basename(path28));
|
|
30631
31065
|
}
|
|
30632
31066
|
/**
|
|
30633
31067
|
* Closes only file-specific watchers
|
|
30634
31068
|
*/
|
|
30635
|
-
_closeFile(
|
|
30636
|
-
const closers = this._closers.get(
|
|
31069
|
+
_closeFile(path28) {
|
|
31070
|
+
const closers = this._closers.get(path28);
|
|
30637
31071
|
if (!closers)
|
|
30638
31072
|
return;
|
|
30639
31073
|
closers.forEach((closer) => closer());
|
|
30640
|
-
this._closers.delete(
|
|
31074
|
+
this._closers.delete(path28);
|
|
30641
31075
|
}
|
|
30642
|
-
_addPathCloser(
|
|
31076
|
+
_addPathCloser(path28, closer) {
|
|
30643
31077
|
if (!closer)
|
|
30644
31078
|
return;
|
|
30645
|
-
let list = this._closers.get(
|
|
31079
|
+
let list = this._closers.get(path28);
|
|
30646
31080
|
if (!list) {
|
|
30647
31081
|
list = [];
|
|
30648
|
-
this._closers.set(
|
|
31082
|
+
this._closers.set(path28, list);
|
|
30649
31083
|
}
|
|
30650
31084
|
list.push(closer);
|
|
30651
31085
|
}
|
|
@@ -30670,17 +31104,152 @@ var init_chokidar = __esm({
|
|
|
30670
31104
|
}
|
|
30671
31105
|
});
|
|
30672
31106
|
|
|
31107
|
+
// ../../oss/packages/daemon-core/src/providers/provider-schema.ts
|
|
31108
|
+
function validateProviderDefinition(raw) {
|
|
31109
|
+
const errors = [];
|
|
31110
|
+
const warnings = [];
|
|
31111
|
+
if (!raw || typeof raw !== "object") {
|
|
31112
|
+
return { errors: ["Provider definition must be an object"], warnings };
|
|
31113
|
+
}
|
|
31114
|
+
const provider = raw;
|
|
31115
|
+
if (!provider.type) errors.push("Missing required field: type");
|
|
31116
|
+
if (!provider.name) errors.push("Missing required field: name");
|
|
31117
|
+
if (!provider.category) {
|
|
31118
|
+
errors.push("Missing required field: category");
|
|
31119
|
+
} else if (!["ide", "extension", "cli", "acp"].includes(String(provider.category))) {
|
|
31120
|
+
errors.push(`Invalid category: ${String(provider.category)}`);
|
|
31121
|
+
}
|
|
31122
|
+
for (const key of Object.keys(provider)) {
|
|
31123
|
+
if (!KNOWN_PROVIDER_FIELDS.has(key)) {
|
|
31124
|
+
warnings.push(`Unknown provider field: ${key}`);
|
|
31125
|
+
}
|
|
31126
|
+
}
|
|
31127
|
+
const category = provider.category;
|
|
31128
|
+
if (category === "cli" || category === "acp") {
|
|
31129
|
+
const spawn5 = provider.spawn;
|
|
31130
|
+
const command = spawn5 && typeof spawn5 === "object" ? spawn5.command : void 0;
|
|
31131
|
+
if (!spawn5 || typeof spawn5 !== "object") {
|
|
31132
|
+
errors.push(`${String(category).toUpperCase()}/CLI providers must have spawn config`);
|
|
31133
|
+
} else if (typeof command !== "string" || !command.trim()) {
|
|
31134
|
+
errors.push("spawn.command is required");
|
|
31135
|
+
}
|
|
31136
|
+
}
|
|
31137
|
+
if ((category === "ide" || category === "extension") && provider.cdpPorts !== void 0) {
|
|
31138
|
+
if (!Array.isArray(provider.cdpPorts) || provider.cdpPorts.length === 0) {
|
|
31139
|
+
warnings.push("IDE/Extension providers should have cdpPorts");
|
|
31140
|
+
}
|
|
31141
|
+
}
|
|
31142
|
+
if (category === "extension" && !provider.extensionId) {
|
|
31143
|
+
warnings.push("Extension providers should have extensionId");
|
|
31144
|
+
}
|
|
31145
|
+
for (const control of Array.isArray(provider.controls) ? provider.controls : []) {
|
|
31146
|
+
validateControl(control, errors);
|
|
31147
|
+
}
|
|
31148
|
+
return { errors, warnings };
|
|
31149
|
+
}
|
|
31150
|
+
function validateControl(control, errors) {
|
|
31151
|
+
if (!control || typeof control !== "object") {
|
|
31152
|
+
errors.push("controls: each control must be an object");
|
|
31153
|
+
return;
|
|
31154
|
+
}
|
|
31155
|
+
const id = typeof control.id === "string" && control.id.trim() ? control.id.trim() : "unknown";
|
|
31156
|
+
const prefix = `controls.${id}`;
|
|
31157
|
+
if (!control.id || !String(control.id).trim()) errors.push(`${prefix}: id is required`);
|
|
31158
|
+
if (!control.type) errors.push(`${prefix}: type is required`);
|
|
31159
|
+
if (!control.label || !String(control.label).trim()) errors.push(`${prefix}: label is required`);
|
|
31160
|
+
if (!control.placement) errors.push(`${prefix}: placement is required`);
|
|
31161
|
+
if (control.dynamic && !control.listScript) {
|
|
31162
|
+
errors.push(`${prefix}: dynamic controls require listScript`);
|
|
31163
|
+
}
|
|
31164
|
+
if (VALUE_CONTROL_TYPES.has(control.type) && !control.setScript) {
|
|
31165
|
+
errors.push(`${prefix}: ${control.type} controls require setScript`);
|
|
31166
|
+
}
|
|
31167
|
+
if (control.type === "action" && !control.invokeScript) {
|
|
31168
|
+
errors.push(`${prefix}: action controls require invokeScript`);
|
|
31169
|
+
}
|
|
31170
|
+
if (control.type === "slider") {
|
|
31171
|
+
if (typeof control.min !== "number" || typeof control.max !== "number") {
|
|
31172
|
+
errors.push(`${prefix}: slider controls require numeric min and max`);
|
|
31173
|
+
} else if (control.min > control.max) {
|
|
31174
|
+
errors.push(`${prefix}: slider min cannot exceed max`);
|
|
31175
|
+
}
|
|
31176
|
+
}
|
|
31177
|
+
if (control.readFrom !== void 0 && (typeof control.readFrom !== "string" || !control.readFrom.trim())) {
|
|
31178
|
+
errors.push(`${prefix}: readFrom must be a non-empty string when provided`);
|
|
31179
|
+
}
|
|
31180
|
+
}
|
|
31181
|
+
var KNOWN_PROVIDER_FIELDS, VALUE_CONTROL_TYPES;
|
|
31182
|
+
var init_provider_schema = __esm({
|
|
31183
|
+
"../../oss/packages/daemon-core/src/providers/provider-schema.ts"() {
|
|
31184
|
+
"use strict";
|
|
31185
|
+
KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
|
|
31186
|
+
"type",
|
|
31187
|
+
"name",
|
|
31188
|
+
"category",
|
|
31189
|
+
"aliases",
|
|
31190
|
+
"cdpPorts",
|
|
31191
|
+
"targetFilter",
|
|
31192
|
+
"cli",
|
|
31193
|
+
"icon",
|
|
31194
|
+
"displayName",
|
|
31195
|
+
"install",
|
|
31196
|
+
"versionCommand",
|
|
31197
|
+
"testedVersions",
|
|
31198
|
+
"processNames",
|
|
31199
|
+
"launch",
|
|
31200
|
+
"paths",
|
|
31201
|
+
"extensionId",
|
|
31202
|
+
"extensionIdPattern",
|
|
31203
|
+
"extensionIdPattern_flags",
|
|
31204
|
+
"compatibility",
|
|
31205
|
+
"defaultScriptDir",
|
|
31206
|
+
"binary",
|
|
31207
|
+
"spawn",
|
|
31208
|
+
"approvalKeys",
|
|
31209
|
+
"patterns",
|
|
31210
|
+
"cleanOutput",
|
|
31211
|
+
"resume",
|
|
31212
|
+
"sessionProbe",
|
|
31213
|
+
"approvalPositiveHints",
|
|
31214
|
+
"scripts",
|
|
31215
|
+
"vscodeCommands",
|
|
31216
|
+
"inputMethod",
|
|
31217
|
+
"inputSelector",
|
|
31218
|
+
"webviewMatchText",
|
|
31219
|
+
"os",
|
|
31220
|
+
"versions",
|
|
31221
|
+
"overrides",
|
|
31222
|
+
"settings",
|
|
31223
|
+
"controls",
|
|
31224
|
+
"staticConfigOptions",
|
|
31225
|
+
"spawnArgBuilder",
|
|
31226
|
+
"auth",
|
|
31227
|
+
"contractVersion",
|
|
31228
|
+
"capabilities",
|
|
31229
|
+
"providerVersion",
|
|
31230
|
+
"status",
|
|
31231
|
+
"details",
|
|
31232
|
+
"sendDelayMs",
|
|
31233
|
+
"sendKey",
|
|
31234
|
+
"submitStrategy",
|
|
31235
|
+
"disableUpstream"
|
|
31236
|
+
]);
|
|
31237
|
+
VALUE_CONTROL_TYPES = /* @__PURE__ */ new Set(["select", "toggle", "cycle", "slider"]);
|
|
31238
|
+
}
|
|
31239
|
+
});
|
|
31240
|
+
|
|
30673
31241
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
30674
|
-
var fs6,
|
|
31242
|
+
var fs6, path14, os14, ProviderLoader;
|
|
30675
31243
|
var init_provider_loader = __esm({
|
|
30676
31244
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
30677
31245
|
"use strict";
|
|
30678
31246
|
fs6 = __toESM(require("fs"));
|
|
30679
|
-
|
|
31247
|
+
path14 = __toESM(require("path"));
|
|
30680
31248
|
os14 = __toESM(require("os"));
|
|
30681
31249
|
init_chokidar();
|
|
30682
31250
|
init_ide_detector();
|
|
30683
31251
|
init_logger();
|
|
31252
|
+
init_provider_schema();
|
|
30684
31253
|
ProviderLoader = class _ProviderLoader {
|
|
30685
31254
|
providers = /* @__PURE__ */ new Map();
|
|
30686
31255
|
providerAvailability = /* @__PURE__ */ new Map();
|
|
@@ -30699,12 +31268,12 @@ var init_provider_loader = __esm({
|
|
|
30699
31268
|
static META_FILE = ".meta.json";
|
|
30700
31269
|
constructor(options) {
|
|
30701
31270
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
30702
|
-
const defaultProvidersDir =
|
|
31271
|
+
const defaultProvidersDir = path14.join(os14.homedir(), ".adhdev", "providers");
|
|
30703
31272
|
if (options?.userDir) {
|
|
30704
31273
|
this.userDir = options.userDir;
|
|
30705
31274
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
30706
31275
|
} else {
|
|
30707
|
-
const localRepoPath =
|
|
31276
|
+
const localRepoPath = path14.resolve(__dirname, "../../../../../adhdev-providers");
|
|
30708
31277
|
if (fs6.existsSync(localRepoPath)) {
|
|
30709
31278
|
this.userDir = localRepoPath;
|
|
30710
31279
|
this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
|
|
@@ -30713,7 +31282,7 @@ var init_provider_loader = __esm({
|
|
|
30713
31282
|
this.log(`Using default user providers directory: ${this.userDir}`);
|
|
30714
31283
|
}
|
|
30715
31284
|
}
|
|
30716
|
-
this.upstreamDir =
|
|
31285
|
+
this.upstreamDir = path14.join(defaultProvidersDir, ".upstream");
|
|
30717
31286
|
this.disableUpstream = options?.disableUpstream ?? false;
|
|
30718
31287
|
}
|
|
30719
31288
|
log(msg) {
|
|
@@ -30743,7 +31312,7 @@ var init_provider_loader = __esm({
|
|
|
30743
31312
|
* Canonical provider directory shape for a given root.
|
|
30744
31313
|
*/
|
|
30745
31314
|
getProviderDir(root, category, type) {
|
|
30746
|
-
return
|
|
31315
|
+
return path14.join(root, category, type);
|
|
30747
31316
|
}
|
|
30748
31317
|
/**
|
|
30749
31318
|
* Canonical user override directory for a provider.
|
|
@@ -30770,7 +31339,7 @@ var init_provider_loader = __esm({
|
|
|
30770
31339
|
resolveProviderFile(type, ...segments) {
|
|
30771
31340
|
const dir = this.findProviderDirInternal(type);
|
|
30772
31341
|
if (!dir) return null;
|
|
30773
|
-
return
|
|
31342
|
+
return path14.join(dir, ...segments);
|
|
30774
31343
|
}
|
|
30775
31344
|
/**
|
|
30776
31345
|
* Load all providers (3-tier priority)
|
|
@@ -30809,7 +31378,7 @@ var init_provider_loader = __esm({
|
|
|
30809
31378
|
if (!fs6.existsSync(this.upstreamDir)) return false;
|
|
30810
31379
|
try {
|
|
30811
31380
|
return fs6.readdirSync(this.upstreamDir).some(
|
|
30812
|
-
(d) => fs6.statSync(
|
|
31381
|
+
(d) => fs6.statSync(path14.join(this.upstreamDir, d)).isDirectory()
|
|
30813
31382
|
);
|
|
30814
31383
|
} catch {
|
|
30815
31384
|
return false;
|
|
@@ -31124,8 +31693,8 @@ var init_provider_loader = __esm({
|
|
|
31124
31693
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
31125
31694
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
31126
31695
|
if (providerDir) {
|
|
31127
|
-
const fullDir =
|
|
31128
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
31696
|
+
const fullDir = path14.join(providerDir, entry.scriptDir);
|
|
31697
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
31129
31698
|
}
|
|
31130
31699
|
matched = true;
|
|
31131
31700
|
}
|
|
@@ -31140,8 +31709,8 @@ var init_provider_loader = __esm({
|
|
|
31140
31709
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
31141
31710
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
31142
31711
|
if (providerDir) {
|
|
31143
|
-
const fullDir =
|
|
31144
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
31712
|
+
const fullDir = path14.join(providerDir, base.defaultScriptDir);
|
|
31713
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
31145
31714
|
}
|
|
31146
31715
|
}
|
|
31147
31716
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -31158,8 +31727,8 @@ var init_provider_loader = __esm({
|
|
|
31158
31727
|
resolved._resolvedScriptDir = dirOverride;
|
|
31159
31728
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
31160
31729
|
if (providerDir) {
|
|
31161
|
-
const fullDir =
|
|
31162
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
31730
|
+
const fullDir = path14.join(providerDir, dirOverride);
|
|
31731
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
31163
31732
|
}
|
|
31164
31733
|
}
|
|
31165
31734
|
} else if (override.scripts) {
|
|
@@ -31175,8 +31744,8 @@ var init_provider_loader = __esm({
|
|
|
31175
31744
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
31176
31745
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
31177
31746
|
if (providerDir) {
|
|
31178
|
-
const fullDir =
|
|
31179
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
31747
|
+
const fullDir = path14.join(providerDir, base.defaultScriptDir);
|
|
31748
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
31180
31749
|
}
|
|
31181
31750
|
}
|
|
31182
31751
|
}
|
|
@@ -31201,14 +31770,14 @@ var init_provider_loader = __esm({
|
|
|
31201
31770
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
31202
31771
|
return null;
|
|
31203
31772
|
}
|
|
31204
|
-
const dir =
|
|
31773
|
+
const dir = path14.join(providerDir, scriptDir);
|
|
31205
31774
|
if (!fs6.existsSync(dir)) {
|
|
31206
31775
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
31207
31776
|
return null;
|
|
31208
31777
|
}
|
|
31209
31778
|
const cached2 = this.scriptsCache.get(dir);
|
|
31210
31779
|
if (cached2) return cached2;
|
|
31211
|
-
const scriptsJs =
|
|
31780
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
31212
31781
|
if (fs6.existsSync(scriptsJs)) {
|
|
31213
31782
|
try {
|
|
31214
31783
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -31250,7 +31819,7 @@ var init_provider_loader = __esm({
|
|
|
31250
31819
|
return;
|
|
31251
31820
|
}
|
|
31252
31821
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
31253
|
-
this.log(`File changed: ${
|
|
31822
|
+
this.log(`File changed: ${path14.basename(filePath)}, reloading...`);
|
|
31254
31823
|
this.reload();
|
|
31255
31824
|
}
|
|
31256
31825
|
};
|
|
@@ -31305,7 +31874,7 @@ var init_provider_loader = __esm({
|
|
|
31305
31874
|
}
|
|
31306
31875
|
const https = require("https");
|
|
31307
31876
|
const { execSync: execSync7 } = require("child_process");
|
|
31308
|
-
const metaPath =
|
|
31877
|
+
const metaPath = path14.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
31309
31878
|
let prevEtag = "";
|
|
31310
31879
|
let prevTimestamp = 0;
|
|
31311
31880
|
try {
|
|
@@ -31365,17 +31934,17 @@ var init_provider_loader = __esm({
|
|
|
31365
31934
|
return { updated: false };
|
|
31366
31935
|
}
|
|
31367
31936
|
this.log("Downloading latest providers from GitHub...");
|
|
31368
|
-
const tmpTar =
|
|
31369
|
-
const tmpExtract =
|
|
31937
|
+
const tmpTar = path14.join(os14.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
31938
|
+
const tmpExtract = path14.join(os14.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
31370
31939
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
31371
31940
|
fs6.mkdirSync(tmpExtract, { recursive: true });
|
|
31372
31941
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
31373
31942
|
const extracted = fs6.readdirSync(tmpExtract);
|
|
31374
31943
|
const rootDir = extracted.find(
|
|
31375
|
-
(d) => fs6.statSync(
|
|
31944
|
+
(d) => fs6.statSync(path14.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
31376
31945
|
);
|
|
31377
31946
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
31378
|
-
const sourceDir =
|
|
31947
|
+
const sourceDir = path14.join(tmpExtract, rootDir);
|
|
31379
31948
|
const backupDir = this.upstreamDir + ".bak";
|
|
31380
31949
|
if (fs6.existsSync(this.upstreamDir)) {
|
|
31381
31950
|
if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -31450,8 +32019,8 @@ var init_provider_loader = __esm({
|
|
|
31450
32019
|
copyDirRecursive(src, dest) {
|
|
31451
32020
|
fs6.mkdirSync(dest, { recursive: true });
|
|
31452
32021
|
for (const entry of fs6.readdirSync(src, { withFileTypes: true })) {
|
|
31453
|
-
const srcPath =
|
|
31454
|
-
const destPath =
|
|
32022
|
+
const srcPath = path14.join(src, entry.name);
|
|
32023
|
+
const destPath = path14.join(dest, entry.name);
|
|
31455
32024
|
if (entry.isDirectory()) {
|
|
31456
32025
|
this.copyDirRecursive(srcPath, destPath);
|
|
31457
32026
|
} else {
|
|
@@ -31462,7 +32031,7 @@ var init_provider_loader = __esm({
|
|
|
31462
32031
|
/** .meta.json save */
|
|
31463
32032
|
writeMeta(metaPath, etag, timestamp) {
|
|
31464
32033
|
try {
|
|
31465
|
-
fs6.mkdirSync(
|
|
32034
|
+
fs6.mkdirSync(path14.dirname(metaPath), { recursive: true });
|
|
31466
32035
|
fs6.writeFileSync(metaPath, JSON.stringify({
|
|
31467
32036
|
etag,
|
|
31468
32037
|
timestamp,
|
|
@@ -31479,7 +32048,7 @@ var init_provider_loader = __esm({
|
|
|
31479
32048
|
const scan = (d) => {
|
|
31480
32049
|
try {
|
|
31481
32050
|
for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
|
|
31482
|
-
if (entry.isDirectory()) scan(
|
|
32051
|
+
if (entry.isDirectory()) scan(path14.join(d, entry.name));
|
|
31483
32052
|
else if (entry.name === "provider.json") count++;
|
|
31484
32053
|
}
|
|
31485
32054
|
} catch {
|
|
@@ -31664,17 +32233,17 @@ var init_provider_loader = __esm({
|
|
|
31664
32233
|
for (const root of searchRoots) {
|
|
31665
32234
|
if (!fs6.existsSync(root)) continue;
|
|
31666
32235
|
const candidate = this.getProviderDir(root, cat, type);
|
|
31667
|
-
if (fs6.existsSync(
|
|
31668
|
-
const catDir =
|
|
32236
|
+
if (fs6.existsSync(path14.join(candidate, "provider.json"))) return candidate;
|
|
32237
|
+
const catDir = path14.join(root, cat);
|
|
31669
32238
|
if (fs6.existsSync(catDir)) {
|
|
31670
32239
|
try {
|
|
31671
32240
|
for (const entry of fs6.readdirSync(catDir, { withFileTypes: true })) {
|
|
31672
32241
|
if (!entry.isDirectory()) continue;
|
|
31673
|
-
const jsonPath =
|
|
32242
|
+
const jsonPath = path14.join(catDir, entry.name, "provider.json");
|
|
31674
32243
|
if (fs6.existsSync(jsonPath)) {
|
|
31675
32244
|
try {
|
|
31676
32245
|
const data = JSON.parse(fs6.readFileSync(jsonPath, "utf-8"));
|
|
31677
|
-
if (data.type === type) return
|
|
32246
|
+
if (data.type === type) return path14.join(catDir, entry.name);
|
|
31678
32247
|
} catch {
|
|
31679
32248
|
}
|
|
31680
32249
|
}
|
|
@@ -31691,7 +32260,7 @@ var init_provider_loader = __esm({
|
|
|
31691
32260
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
31692
32261
|
*/
|
|
31693
32262
|
buildScriptWrappersFromDir(dir) {
|
|
31694
|
-
const scriptsJs =
|
|
32263
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
31695
32264
|
if (fs6.existsSync(scriptsJs)) {
|
|
31696
32265
|
try {
|
|
31697
32266
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -31705,7 +32274,7 @@ var init_provider_loader = __esm({
|
|
|
31705
32274
|
for (const file2 of fs6.readdirSync(dir)) {
|
|
31706
32275
|
if (!file2.endsWith(".js")) continue;
|
|
31707
32276
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
31708
|
-
const filePath =
|
|
32277
|
+
const filePath = path14.join(dir, file2);
|
|
31709
32278
|
result[scriptName] = (...args) => {
|
|
31710
32279
|
try {
|
|
31711
32280
|
let content = fs6.readFileSync(filePath, "utf-8");
|
|
@@ -31765,24 +32334,28 @@ var init_provider_loader = __esm({
|
|
|
31765
32334
|
}
|
|
31766
32335
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
31767
32336
|
if (hasJson) {
|
|
31768
|
-
const jsonPath =
|
|
32337
|
+
const jsonPath = path14.join(d, "provider.json");
|
|
31769
32338
|
try {
|
|
31770
32339
|
const raw = fs6.readFileSync(jsonPath, "utf-8");
|
|
31771
32340
|
const mod = JSON.parse(raw);
|
|
31772
|
-
if (
|
|
31773
|
-
|
|
32341
|
+
if (typeof mod.extensionIdPattern === "string") {
|
|
32342
|
+
const flags = mod.extensionIdPattern_flags || "";
|
|
32343
|
+
mod.extensionIdPattern = new RegExp(mod.extensionIdPattern, flags);
|
|
32344
|
+
}
|
|
32345
|
+
const { extensionIdPattern_flags, extensionIdPattern, ...providerFields } = mod;
|
|
32346
|
+
const normalizedProvider = {
|
|
32347
|
+
...providerFields,
|
|
32348
|
+
...extensionIdPattern instanceof RegExp ? { extensionIdPattern } : {}
|
|
32349
|
+
};
|
|
32350
|
+
const validation = validateProviderDefinition(normalizedProvider);
|
|
32351
|
+
for (const warning of validation.warnings) {
|
|
32352
|
+
this.log(`\u26A0 ${jsonPath}: ${warning}`);
|
|
32353
|
+
}
|
|
32354
|
+
if (validation.errors.length > 0) {
|
|
32355
|
+
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
31774
32356
|
} else {
|
|
31775
|
-
if (typeof mod.extensionIdPattern === "string") {
|
|
31776
|
-
const flags = mod.extensionIdPattern_flags || "";
|
|
31777
|
-
mod.extensionIdPattern = new RegExp(mod.extensionIdPattern, flags);
|
|
31778
|
-
}
|
|
31779
|
-
const { extensionIdPattern_flags, extensionIdPattern, ...providerFields } = mod;
|
|
31780
|
-
const normalizedProvider = {
|
|
31781
|
-
...providerFields,
|
|
31782
|
-
...extensionIdPattern instanceof RegExp ? { extensionIdPattern } : {}
|
|
31783
|
-
};
|
|
31784
32357
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
31785
|
-
const scriptsPath =
|
|
32358
|
+
const scriptsPath = path14.join(d, "scripts.js");
|
|
31786
32359
|
if (!hasCompatibility && fs6.existsSync(scriptsPath)) {
|
|
31787
32360
|
try {
|
|
31788
32361
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -31808,7 +32381,7 @@ var init_provider_loader = __esm({
|
|
|
31808
32381
|
if (!entry.isDirectory()) continue;
|
|
31809
32382
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
31810
32383
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
31811
|
-
scan(
|
|
32384
|
+
scan(path14.join(d, entry.name));
|
|
31812
32385
|
}
|
|
31813
32386
|
}
|
|
31814
32387
|
};
|
|
@@ -32063,17 +32636,17 @@ function detectCurrentWorkspace(ideId) {
|
|
|
32063
32636
|
}
|
|
32064
32637
|
} else if (plat === "win32") {
|
|
32065
32638
|
try {
|
|
32066
|
-
const
|
|
32639
|
+
const fs19 = require("fs");
|
|
32067
32640
|
const appNameMap = getMacAppIdentifiers();
|
|
32068
32641
|
const appName = appNameMap[ideId];
|
|
32069
32642
|
if (appName) {
|
|
32070
|
-
const storagePath =
|
|
32071
|
-
process.env.APPDATA ||
|
|
32643
|
+
const storagePath = path15.join(
|
|
32644
|
+
process.env.APPDATA || path15.join(os15.homedir(), "AppData", "Roaming"),
|
|
32072
32645
|
appName,
|
|
32073
32646
|
"storage.json"
|
|
32074
32647
|
);
|
|
32075
|
-
if (
|
|
32076
|
-
const data = JSON.parse(
|
|
32648
|
+
if (fs19.existsSync(storagePath)) {
|
|
32649
|
+
const data = JSON.parse(fs19.readFileSync(storagePath, "utf-8"));
|
|
32077
32650
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
32078
32651
|
if (workspaces.length > 0) {
|
|
32079
32652
|
const recent = workspaces[0];
|
|
@@ -32239,14 +32812,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
32239
32812
|
function getAvailableIdeIds() {
|
|
32240
32813
|
return getProviderLoader().getAvailableIdeTypes();
|
|
32241
32814
|
}
|
|
32242
|
-
var import_child_process6, net2, os15,
|
|
32815
|
+
var import_child_process6, net2, os15, path15, _providerLoader;
|
|
32243
32816
|
var init_launch = __esm({
|
|
32244
32817
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
32245
32818
|
"use strict";
|
|
32246
32819
|
import_child_process6 = require("child_process");
|
|
32247
32820
|
net2 = __toESM(require("net"));
|
|
32248
32821
|
os15 = __toESM(require("os"));
|
|
32249
|
-
|
|
32822
|
+
path15 = __toESM(require("path"));
|
|
32250
32823
|
init_ide_detector();
|
|
32251
32824
|
init_provider_loader();
|
|
32252
32825
|
_providerLoader = null;
|
|
@@ -32277,7 +32850,7 @@ function checkRotation() {
|
|
|
32277
32850
|
const today = getDateStr2();
|
|
32278
32851
|
if (today !== currentDate2) {
|
|
32279
32852
|
currentDate2 = today;
|
|
32280
|
-
currentFile =
|
|
32853
|
+
currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
32281
32854
|
cleanOldFiles();
|
|
32282
32855
|
}
|
|
32283
32856
|
}
|
|
@@ -32291,7 +32864,7 @@ function cleanOldFiles() {
|
|
|
32291
32864
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
32292
32865
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
32293
32866
|
try {
|
|
32294
|
-
fs7.unlinkSync(
|
|
32867
|
+
fs7.unlinkSync(path16.join(LOG_DIR2, file2));
|
|
32295
32868
|
} catch {
|
|
32296
32869
|
}
|
|
32297
32870
|
}
|
|
@@ -32360,14 +32933,14 @@ function getRecentCommands(count = 50) {
|
|
|
32360
32933
|
return [];
|
|
32361
32934
|
}
|
|
32362
32935
|
}
|
|
32363
|
-
var fs7,
|
|
32936
|
+
var fs7, path16, os16, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
32364
32937
|
var init_command_log = __esm({
|
|
32365
32938
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
32366
32939
|
"use strict";
|
|
32367
32940
|
fs7 = __toESM(require("fs"));
|
|
32368
|
-
|
|
32941
|
+
path16 = __toESM(require("path"));
|
|
32369
32942
|
os16 = __toESM(require("os"));
|
|
32370
|
-
LOG_DIR2 = process.platform === "win32" ?
|
|
32943
|
+
LOG_DIR2 = process.platform === "win32" ? path16.join(process.env.LOCALAPPDATA || process.env.APPDATA || path16.join(os16.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path16.join(os16.homedir(), "Library", "Logs", "adhdev") : path16.join(os16.homedir(), ".local", "share", "adhdev", "logs");
|
|
32371
32944
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
32372
32945
|
MAX_DAYS = 7;
|
|
32373
32946
|
try {
|
|
@@ -32386,7 +32959,7 @@ var init_command_log = __esm({
|
|
|
32386
32959
|
"text"
|
|
32387
32960
|
]);
|
|
32388
32961
|
currentDate2 = getDateStr2();
|
|
32389
|
-
currentFile =
|
|
32962
|
+
currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
32390
32963
|
writeCount2 = 0;
|
|
32391
32964
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
32392
32965
|
"heartbeat",
|
|
@@ -32644,9 +33217,9 @@ var init_snapshot = __esm({
|
|
|
32644
33217
|
// ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
|
|
32645
33218
|
function getUpgradeLogPath() {
|
|
32646
33219
|
const home = os18.homedir();
|
|
32647
|
-
const dir =
|
|
33220
|
+
const dir = path17.join(home, ".adhdev");
|
|
32648
33221
|
fs8.mkdirSync(dir, { recursive: true });
|
|
32649
|
-
return
|
|
33222
|
+
return path17.join(dir, "daemon-upgrade.log");
|
|
32650
33223
|
}
|
|
32651
33224
|
function appendUpgradeLog(message) {
|
|
32652
33225
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
@@ -32686,7 +33259,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
32686
33259
|
}
|
|
32687
33260
|
}
|
|
32688
33261
|
function stopSessionHostProcesses(appName) {
|
|
32689
|
-
const pidFile =
|
|
33262
|
+
const pidFile = path17.join(os18.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
32690
33263
|
try {
|
|
32691
33264
|
if (fs8.existsSync(pidFile)) {
|
|
32692
33265
|
const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
|
|
@@ -32715,7 +33288,7 @@ function stopSessionHostProcesses(appName) {
|
|
|
32715
33288
|
}
|
|
32716
33289
|
}
|
|
32717
33290
|
function removeDaemonPidFile() {
|
|
32718
|
-
const pidFile =
|
|
33291
|
+
const pidFile = path17.join(os18.homedir(), ".adhdev", "daemon.pid");
|
|
32719
33292
|
try {
|
|
32720
33293
|
fs8.unlinkSync(pidFile);
|
|
32721
33294
|
} catch {
|
|
@@ -32726,7 +33299,7 @@ function cleanupStaleGlobalInstallDirs(pkgName) {
|
|
|
32726
33299
|
const npmRoot = (0, import_child_process7.execFileSync)(getNpmExecutable(), ["root", "-g"], { encoding: "utf8", ...npmExecOpts }).trim();
|
|
32727
33300
|
if (!npmRoot) return;
|
|
32728
33301
|
const npmPrefix = (0, import_child_process7.execFileSync)(getNpmExecutable(), ["prefix", "-g"], { encoding: "utf8", ...npmExecOpts }).trim();
|
|
32729
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
33302
|
+
const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
|
|
32730
33303
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
32731
33304
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
32732
33305
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -32734,25 +33307,25 @@ function cleanupStaleGlobalInstallDirs(pkgName) {
|
|
|
32734
33307
|
}
|
|
32735
33308
|
if (pkgName.startsWith("@")) {
|
|
32736
33309
|
const [scope, name] = pkgName.split("/");
|
|
32737
|
-
const scopeDir =
|
|
33310
|
+
const scopeDir = path17.join(npmRoot, scope);
|
|
32738
33311
|
if (!fs8.existsSync(scopeDir)) return;
|
|
32739
33312
|
for (const entry of fs8.readdirSync(scopeDir)) {
|
|
32740
33313
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
32741
|
-
fs8.rmSync(
|
|
32742
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
33314
|
+
fs8.rmSync(path17.join(scopeDir, entry), { recursive: true, force: true });
|
|
33315
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path17.join(scopeDir, entry)}`);
|
|
32743
33316
|
}
|
|
32744
33317
|
} else {
|
|
32745
33318
|
for (const entry of fs8.readdirSync(npmRoot)) {
|
|
32746
33319
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
32747
|
-
fs8.rmSync(
|
|
32748
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
33320
|
+
fs8.rmSync(path17.join(npmRoot, entry), { recursive: true, force: true });
|
|
33321
|
+
appendUpgradeLog(`Removed stale staging dir: ${path17.join(npmRoot, entry)}`);
|
|
32749
33322
|
}
|
|
32750
33323
|
}
|
|
32751
33324
|
if (fs8.existsSync(binDir)) {
|
|
32752
33325
|
for (const entry of fs8.readdirSync(binDir)) {
|
|
32753
33326
|
if (![...binNames].some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
32754
|
-
fs8.rmSync(
|
|
32755
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
33327
|
+
fs8.rmSync(path17.join(binDir, entry), { recursive: true, force: true });
|
|
33328
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path17.join(binDir, entry)}`);
|
|
32756
33329
|
}
|
|
32757
33330
|
}
|
|
32758
33331
|
}
|
|
@@ -32827,7 +33400,7 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
32827
33400
|
process.exit(1);
|
|
32828
33401
|
}
|
|
32829
33402
|
}
|
|
32830
|
-
var import_child_process7, import_child_process8, fs8, os18,
|
|
33403
|
+
var import_child_process7, import_child_process8, fs8, os18, path17, UPGRADE_HELPER_ENV;
|
|
32831
33404
|
var init_upgrade_helper = __esm({
|
|
32832
33405
|
"../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
|
|
32833
33406
|
"use strict";
|
|
@@ -32835,7 +33408,7 @@ var init_upgrade_helper = __esm({
|
|
|
32835
33408
|
import_child_process8 = require("child_process");
|
|
32836
33409
|
fs8 = __toESM(require("fs"));
|
|
32837
33410
|
os18 = __toESM(require("os"));
|
|
32838
|
-
|
|
33411
|
+
path17 = __toESM(require("path"));
|
|
32839
33412
|
UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
32840
33413
|
}
|
|
32841
33414
|
});
|
|
@@ -34780,7 +35353,7 @@ function checkPathExists2(paths) {
|
|
|
34780
35353
|
for (const p of paths) {
|
|
34781
35354
|
if (p.includes("*")) {
|
|
34782
35355
|
const home = os19.homedir();
|
|
34783
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
35356
|
+
const resolved = p.replace(/\*/g, home.split(path18.sep).pop() || "");
|
|
34784
35357
|
if (fs10.existsSync(resolved)) return resolved;
|
|
34785
35358
|
} else {
|
|
34786
35359
|
if (fs10.existsSync(p)) return p;
|
|
@@ -34790,7 +35363,7 @@ function checkPathExists2(paths) {
|
|
|
34790
35363
|
}
|
|
34791
35364
|
function getMacAppVersion(appPath) {
|
|
34792
35365
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
34793
|
-
const plistPath =
|
|
35366
|
+
const plistPath = path18.join(appPath, "Contents", "Info.plist");
|
|
34794
35367
|
if (!fs10.existsSync(plistPath)) return null;
|
|
34795
35368
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
34796
35369
|
return raw || null;
|
|
@@ -34816,7 +35389,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
34816
35389
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
34817
35390
|
let resolvedBin = cliBin;
|
|
34818
35391
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
34819
|
-
const bundled =
|
|
35392
|
+
const bundled = path18.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
34820
35393
|
if (provider.cli && fs10.existsSync(bundled)) resolvedBin = bundled;
|
|
34821
35394
|
}
|
|
34822
35395
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -34853,16 +35426,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
34853
35426
|
}
|
|
34854
35427
|
return results;
|
|
34855
35428
|
}
|
|
34856
|
-
var fs10,
|
|
35429
|
+
var fs10, path18, os19, import_child_process9, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
34857
35430
|
var init_version_archive = __esm({
|
|
34858
35431
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
34859
35432
|
"use strict";
|
|
34860
35433
|
fs10 = __toESM(require("fs"));
|
|
34861
|
-
|
|
35434
|
+
path18 = __toESM(require("path"));
|
|
34862
35435
|
os19 = __toESM(require("os"));
|
|
34863
35436
|
import_child_process9 = require("child_process");
|
|
34864
35437
|
import_os3 = require("os");
|
|
34865
|
-
ARCHIVE_PATH =
|
|
35438
|
+
ARCHIVE_PATH = path18.join(os19.homedir(), ".adhdev", "version-history.json");
|
|
34866
35439
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
34867
35440
|
VersionArchive = class {
|
|
34868
35441
|
history = {};
|
|
@@ -34909,7 +35482,7 @@ var init_version_archive = __esm({
|
|
|
34909
35482
|
}
|
|
34910
35483
|
save() {
|
|
34911
35484
|
try {
|
|
34912
|
-
fs10.mkdirSync(
|
|
35485
|
+
fs10.mkdirSync(path18.dirname(ARCHIVE_PATH), { recursive: true });
|
|
34913
35486
|
fs10.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
34914
35487
|
} catch {
|
|
34915
35488
|
}
|
|
@@ -35430,17 +36003,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
35430
36003
|
return;
|
|
35431
36004
|
}
|
|
35432
36005
|
let scriptsPath = "";
|
|
35433
|
-
const directScripts =
|
|
36006
|
+
const directScripts = path19.join(dir, "scripts.js");
|
|
35434
36007
|
if (fs11.existsSync(directScripts)) {
|
|
35435
36008
|
scriptsPath = directScripts;
|
|
35436
36009
|
} else {
|
|
35437
|
-
const scriptsDir =
|
|
36010
|
+
const scriptsDir = path19.join(dir, "scripts");
|
|
35438
36011
|
if (fs11.existsSync(scriptsDir)) {
|
|
35439
36012
|
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
35440
|
-
return fs11.statSync(
|
|
36013
|
+
return fs11.statSync(path19.join(scriptsDir, d)).isDirectory();
|
|
35441
36014
|
}).sort().reverse();
|
|
35442
36015
|
for (const ver of versions) {
|
|
35443
|
-
const p =
|
|
36016
|
+
const p = path19.join(scriptsDir, ver, "scripts.js");
|
|
35444
36017
|
if (fs11.existsSync(p)) {
|
|
35445
36018
|
scriptsPath = p;
|
|
35446
36019
|
break;
|
|
@@ -36266,12 +36839,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
36266
36839
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
36267
36840
|
}
|
|
36268
36841
|
}
|
|
36269
|
-
var fs11,
|
|
36842
|
+
var fs11, path19;
|
|
36270
36843
|
var init_dev_cdp_handlers = __esm({
|
|
36271
36844
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
36272
36845
|
"use strict";
|
|
36273
36846
|
fs11 = __toESM(require("fs"));
|
|
36274
|
-
|
|
36847
|
+
path19 = __toESM(require("path"));
|
|
36275
36848
|
init_logger();
|
|
36276
36849
|
}
|
|
36277
36850
|
});
|
|
@@ -36286,11 +36859,11 @@ function getCliFixtureDir(ctx, type) {
|
|
|
36286
36859
|
if (!providerDir) {
|
|
36287
36860
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
36288
36861
|
}
|
|
36289
|
-
return
|
|
36862
|
+
return path20.join(providerDir, "fixtures");
|
|
36290
36863
|
}
|
|
36291
36864
|
function readCliFixture(ctx, type, name) {
|
|
36292
36865
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
36293
|
-
const filePath =
|
|
36866
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
36294
36867
|
if (!fs12.existsSync(filePath)) {
|
|
36295
36868
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
36296
36869
|
}
|
|
@@ -37058,7 +37631,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
37058
37631
|
},
|
|
37059
37632
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
37060
37633
|
};
|
|
37061
|
-
const filePath =
|
|
37634
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
37062
37635
|
fs12.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
37063
37636
|
ctx.json(res, 200, {
|
|
37064
37637
|
saved: true,
|
|
@@ -37082,7 +37655,7 @@ async function handleCliFixtureList(ctx, type, _req, res) {
|
|
|
37082
37655
|
return;
|
|
37083
37656
|
}
|
|
37084
37657
|
const fixtures = fs12.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
37085
|
-
const fullPath =
|
|
37658
|
+
const fullPath = path20.join(fixtureDir, file2);
|
|
37086
37659
|
try {
|
|
37087
37660
|
const raw = JSON.parse(fs12.readFileSync(fullPath, "utf-8"));
|
|
37088
37661
|
return {
|
|
@@ -37215,12 +37788,12 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
37215
37788
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
37216
37789
|
}
|
|
37217
37790
|
}
|
|
37218
|
-
var fs12,
|
|
37791
|
+
var fs12, path20;
|
|
37219
37792
|
var init_dev_cli_debug = __esm({
|
|
37220
37793
|
"../../oss/packages/daemon-core/src/daemon/dev-cli-debug.ts"() {
|
|
37221
37794
|
"use strict";
|
|
37222
37795
|
fs12 = __toESM(require("fs"));
|
|
37223
|
-
|
|
37796
|
+
path20 = __toESM(require("path"));
|
|
37224
37797
|
}
|
|
37225
37798
|
});
|
|
37226
37799
|
|
|
@@ -37280,22 +37853,22 @@ function getLatestScriptVersionDir(scriptsDir) {
|
|
|
37280
37853
|
if (!fs13.existsSync(scriptsDir)) return null;
|
|
37281
37854
|
const versions = fs13.readdirSync(scriptsDir).filter((d) => {
|
|
37282
37855
|
try {
|
|
37283
|
-
return fs13.statSync(
|
|
37856
|
+
return fs13.statSync(path21.join(scriptsDir, d)).isDirectory();
|
|
37284
37857
|
} catch {
|
|
37285
37858
|
return false;
|
|
37286
37859
|
}
|
|
37287
37860
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
37288
37861
|
if (versions.length === 0) return null;
|
|
37289
|
-
return
|
|
37862
|
+
return path21.join(scriptsDir, versions[0]);
|
|
37290
37863
|
}
|
|
37291
37864
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
37292
|
-
const canonicalUserDir =
|
|
37293
|
-
const desiredDir = requestedDir ?
|
|
37294
|
-
const upstreamRoot =
|
|
37295
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
37865
|
+
const canonicalUserDir = path21.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
37866
|
+
const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
|
|
37867
|
+
const upstreamRoot = path21.resolve(ctx.providerLoader.getUpstreamDir());
|
|
37868
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
|
|
37296
37869
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
37297
37870
|
}
|
|
37298
|
-
if (
|
|
37871
|
+
if (path21.basename(desiredDir) !== type) {
|
|
37299
37872
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
37300
37873
|
}
|
|
37301
37874
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -37303,11 +37876,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
37303
37876
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
37304
37877
|
}
|
|
37305
37878
|
if (!fs13.existsSync(desiredDir)) {
|
|
37306
|
-
fs13.mkdirSync(
|
|
37879
|
+
fs13.mkdirSync(path21.dirname(desiredDir), { recursive: true });
|
|
37307
37880
|
fs13.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
37308
37881
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
37309
37882
|
}
|
|
37310
|
-
const providerJson =
|
|
37883
|
+
const providerJson = path21.join(desiredDir, "provider.json");
|
|
37311
37884
|
if (!fs13.existsSync(providerJson)) {
|
|
37312
37885
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
37313
37886
|
}
|
|
@@ -37330,13 +37903,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
|
37330
37903
|
const refDir = ctx.findProviderDir(referenceType);
|
|
37331
37904
|
if (!refDir || !fs13.existsSync(refDir)) return {};
|
|
37332
37905
|
const referenceScripts = {};
|
|
37333
|
-
const scriptsDir =
|
|
37906
|
+
const scriptsDir = path21.join(refDir, "scripts");
|
|
37334
37907
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
37335
37908
|
if (!latestDir) return referenceScripts;
|
|
37336
37909
|
for (const file2 of fs13.readdirSync(latestDir)) {
|
|
37337
37910
|
if (!file2.endsWith(".js")) continue;
|
|
37338
37911
|
try {
|
|
37339
|
-
referenceScripts[file2] = fs13.readFileSync(
|
|
37912
|
+
referenceScripts[file2] = fs13.readFileSync(path21.join(latestDir, file2), "utf-8");
|
|
37340
37913
|
} catch {
|
|
37341
37914
|
}
|
|
37342
37915
|
}
|
|
@@ -37444,9 +38017,9 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
37444
38017
|
});
|
|
37445
38018
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
37446
38019
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
37447
|
-
const tmpDir =
|
|
38020
|
+
const tmpDir = path21.join(os20.tmpdir(), "adhdev-autoimpl");
|
|
37448
38021
|
if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
|
|
37449
|
-
const promptFile =
|
|
38022
|
+
const promptFile = path21.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
37450
38023
|
fs13.writeFileSync(promptFile, prompt, "utf-8");
|
|
37451
38024
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
37452
38025
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -37883,7 +38456,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
37883
38456
|
setMode: "set_mode.js"
|
|
37884
38457
|
};
|
|
37885
38458
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
37886
|
-
const scriptsDir =
|
|
38459
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
37887
38460
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
37888
38461
|
if (latestScriptsDir) {
|
|
37889
38462
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -37894,7 +38467,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
37894
38467
|
for (const file2 of fs13.readdirSync(latestScriptsDir)) {
|
|
37895
38468
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
37896
38469
|
try {
|
|
37897
|
-
const content = fs13.readFileSync(
|
|
38470
|
+
const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
37898
38471
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
37899
38472
|
lines.push("```javascript");
|
|
37900
38473
|
lines.push(content);
|
|
@@ -37911,7 +38484,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
37911
38484
|
lines.push("");
|
|
37912
38485
|
for (const file2 of refFiles) {
|
|
37913
38486
|
try {
|
|
37914
|
-
const content = fs13.readFileSync(
|
|
38487
|
+
const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
37915
38488
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
37916
38489
|
lines.push("```javascript");
|
|
37917
38490
|
lines.push(content);
|
|
@@ -37952,10 +38525,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
37952
38525
|
lines.push("");
|
|
37953
38526
|
}
|
|
37954
38527
|
}
|
|
37955
|
-
const docsDir =
|
|
38528
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
37956
38529
|
const loadGuide = (name) => {
|
|
37957
38530
|
try {
|
|
37958
|
-
const p =
|
|
38531
|
+
const p = path21.join(docsDir, name);
|
|
37959
38532
|
if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
|
|
37960
38533
|
} catch {
|
|
37961
38534
|
}
|
|
@@ -38192,7 +38765,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
38192
38765
|
parseApproval: "parse_approval.js"
|
|
38193
38766
|
};
|
|
38194
38767
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
38195
|
-
const scriptsDir =
|
|
38768
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
38196
38769
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
38197
38770
|
if (latestScriptsDir) {
|
|
38198
38771
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -38204,7 +38777,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
38204
38777
|
if (!file2.endsWith(".js")) continue;
|
|
38205
38778
|
if (!targetFileNames.has(file2)) continue;
|
|
38206
38779
|
try {
|
|
38207
|
-
const content = fs13.readFileSync(
|
|
38780
|
+
const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
38208
38781
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
38209
38782
|
lines.push("```javascript");
|
|
38210
38783
|
lines.push(content);
|
|
@@ -38220,7 +38793,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
38220
38793
|
lines.push("");
|
|
38221
38794
|
for (const file2 of refFiles) {
|
|
38222
38795
|
try {
|
|
38223
|
-
const content = fs13.readFileSync(
|
|
38796
|
+
const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
38224
38797
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
38225
38798
|
lines.push("```javascript");
|
|
38226
38799
|
lines.push(content);
|
|
@@ -38253,10 +38826,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
38253
38826
|
lines.push("");
|
|
38254
38827
|
}
|
|
38255
38828
|
}
|
|
38256
|
-
const docsDir =
|
|
38829
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
38257
38830
|
const loadGuide = (name) => {
|
|
38258
38831
|
try {
|
|
38259
|
-
const p =
|
|
38832
|
+
const p = path21.join(docsDir, name);
|
|
38260
38833
|
if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
|
|
38261
38834
|
} catch {
|
|
38262
38835
|
}
|
|
@@ -38568,12 +39141,12 @@ data: ${JSON.stringify(msg.data)}
|
|
|
38568
39141
|
}
|
|
38569
39142
|
}
|
|
38570
39143
|
}
|
|
38571
|
-
var fs13,
|
|
39144
|
+
var fs13, path21, os20;
|
|
38572
39145
|
var init_dev_auto_implement = __esm({
|
|
38573
39146
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
38574
39147
|
"use strict";
|
|
38575
39148
|
fs13 = __toESM(require("fs"));
|
|
38576
|
-
|
|
39149
|
+
path21 = __toESM(require("path"));
|
|
38577
39150
|
os20 = __toESM(require("os"));
|
|
38578
39151
|
init_dev_server();
|
|
38579
39152
|
init_dev_cli_debug();
|
|
@@ -38613,13 +39186,14 @@ function toProviderListEntry(provider) {
|
|
|
38613
39186
|
}
|
|
38614
39187
|
return base;
|
|
38615
39188
|
}
|
|
38616
|
-
var http2, fs14,
|
|
39189
|
+
var http2, fs14, path23, DEV_SERVER_PORT, DevServer;
|
|
38617
39190
|
var init_dev_server = __esm({
|
|
38618
39191
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
38619
39192
|
"use strict";
|
|
38620
39193
|
http2 = __toESM(require("http"));
|
|
38621
39194
|
fs14 = __toESM(require("fs"));
|
|
38622
|
-
|
|
39195
|
+
path23 = __toESM(require("path"));
|
|
39196
|
+
init_provider_schema();
|
|
38623
39197
|
init_scaffold_template();
|
|
38624
39198
|
init_version_archive();
|
|
38625
39199
|
init_logger();
|
|
@@ -38724,8 +39298,8 @@ var init_dev_server = __esm({
|
|
|
38724
39298
|
}
|
|
38725
39299
|
getEndpointList() {
|
|
38726
39300
|
return this.routes.map((r) => {
|
|
38727
|
-
const
|
|
38728
|
-
return `${r.method.padEnd(5)} ${
|
|
39301
|
+
const path28 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
39302
|
+
return `${r.method.padEnd(5)} ${path28}`;
|
|
38729
39303
|
});
|
|
38730
39304
|
}
|
|
38731
39305
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -38980,12 +39554,12 @@ var init_dev_server = __esm({
|
|
|
38980
39554
|
// ─── DevConsole SPA ───
|
|
38981
39555
|
getConsoleDistDir() {
|
|
38982
39556
|
const candidates = [
|
|
38983
|
-
|
|
38984
|
-
|
|
38985
|
-
|
|
39557
|
+
path23.resolve(__dirname, "../../web-devconsole/dist"),
|
|
39558
|
+
path23.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
39559
|
+
path23.join(process.cwd(), "packages/web-devconsole/dist")
|
|
38986
39560
|
];
|
|
38987
39561
|
for (const dir of candidates) {
|
|
38988
|
-
if (fs14.existsSync(
|
|
39562
|
+
if (fs14.existsSync(path23.join(dir, "index.html"))) return dir;
|
|
38989
39563
|
}
|
|
38990
39564
|
return null;
|
|
38991
39565
|
}
|
|
@@ -38995,7 +39569,7 @@ var init_dev_server = __esm({
|
|
|
38995
39569
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
38996
39570
|
return;
|
|
38997
39571
|
}
|
|
38998
|
-
const htmlPath =
|
|
39572
|
+
const htmlPath = path23.join(distDir, "index.html");
|
|
38999
39573
|
try {
|
|
39000
39574
|
const html = fs14.readFileSync(htmlPath, "utf-8");
|
|
39001
39575
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -39020,15 +39594,15 @@ var init_dev_server = __esm({
|
|
|
39020
39594
|
this.json(res, 404, { error: "Not found" });
|
|
39021
39595
|
return;
|
|
39022
39596
|
}
|
|
39023
|
-
const safePath =
|
|
39024
|
-
const filePath =
|
|
39597
|
+
const safePath = path23.normalize(pathname).replace(/^\.\.\//, "");
|
|
39598
|
+
const filePath = path23.join(distDir, safePath);
|
|
39025
39599
|
if (!filePath.startsWith(distDir)) {
|
|
39026
39600
|
this.json(res, 403, { error: "Forbidden" });
|
|
39027
39601
|
return;
|
|
39028
39602
|
}
|
|
39029
39603
|
try {
|
|
39030
39604
|
const content = fs14.readFileSync(filePath);
|
|
39031
|
-
const ext =
|
|
39605
|
+
const ext = path23.extname(filePath);
|
|
39032
39606
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
39033
39607
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
39034
39608
|
res.end(content);
|
|
@@ -39141,9 +39715,9 @@ var init_dev_server = __esm({
|
|
|
39141
39715
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
39142
39716
|
if (entry.isDirectory()) {
|
|
39143
39717
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
39144
|
-
scan(
|
|
39718
|
+
scan(path23.join(d, entry.name), rel);
|
|
39145
39719
|
} else {
|
|
39146
|
-
const stat4 = fs14.statSync(
|
|
39720
|
+
const stat4 = fs14.statSync(path23.join(d, entry.name));
|
|
39147
39721
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
39148
39722
|
}
|
|
39149
39723
|
}
|
|
@@ -39166,7 +39740,7 @@ var init_dev_server = __esm({
|
|
|
39166
39740
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
39167
39741
|
return;
|
|
39168
39742
|
}
|
|
39169
|
-
const fullPath =
|
|
39743
|
+
const fullPath = path23.resolve(dir, path23.normalize(filePath));
|
|
39170
39744
|
if (!fullPath.startsWith(dir)) {
|
|
39171
39745
|
this.json(res, 403, { error: "Forbidden" });
|
|
39172
39746
|
return;
|
|
@@ -39191,14 +39765,14 @@ var init_dev_server = __esm({
|
|
|
39191
39765
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
39192
39766
|
return;
|
|
39193
39767
|
}
|
|
39194
|
-
const fullPath =
|
|
39768
|
+
const fullPath = path23.resolve(dir, path23.normalize(filePath));
|
|
39195
39769
|
if (!fullPath.startsWith(dir)) {
|
|
39196
39770
|
this.json(res, 403, { error: "Forbidden" });
|
|
39197
39771
|
return;
|
|
39198
39772
|
}
|
|
39199
39773
|
try {
|
|
39200
39774
|
if (fs14.existsSync(fullPath)) fs14.copyFileSync(fullPath, fullPath + ".bak");
|
|
39201
|
-
fs14.mkdirSync(
|
|
39775
|
+
fs14.mkdirSync(path23.dirname(fullPath), { recursive: true });
|
|
39202
39776
|
fs14.writeFileSync(fullPath, content, "utf-8");
|
|
39203
39777
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
39204
39778
|
this.providerLoader.reload();
|
|
@@ -39215,7 +39789,7 @@ var init_dev_server = __esm({
|
|
|
39215
39789
|
return;
|
|
39216
39790
|
}
|
|
39217
39791
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
39218
|
-
const p =
|
|
39792
|
+
const p = path23.join(dir, name);
|
|
39219
39793
|
if (fs14.existsSync(p)) {
|
|
39220
39794
|
const source = fs14.readFileSync(p, "utf-8");
|
|
39221
39795
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -39236,8 +39810,8 @@ var init_dev_server = __esm({
|
|
|
39236
39810
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
39237
39811
|
return;
|
|
39238
39812
|
}
|
|
39239
|
-
const target = fs14.existsSync(
|
|
39240
|
-
const targetPath =
|
|
39813
|
+
const target = fs14.existsSync(path23.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
39814
|
+
const targetPath = path23.join(dir, target);
|
|
39241
39815
|
try {
|
|
39242
39816
|
if (fs14.existsSync(targetPath)) fs14.copyFileSync(targetPath, targetPath + ".bak");
|
|
39243
39817
|
fs14.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -39265,22 +39839,9 @@ var init_dev_server = __esm({
|
|
|
39265
39839
|
const warnings = [];
|
|
39266
39840
|
try {
|
|
39267
39841
|
const config2 = typeof content === "string" ? JSON.parse(content) : content;
|
|
39268
|
-
|
|
39269
|
-
|
|
39270
|
-
|
|
39271
|
-
else if (!["ide", "extension", "cli", "acp"].includes(config2.category)) errors.push(`Invalid category: ${config2.category}`);
|
|
39272
|
-
if (config2.category === "ide" || config2.category === "extension") {
|
|
39273
|
-
if (!config2.cdpPorts || !Array.isArray(config2.cdpPorts) || config2.cdpPorts.length === 0)
|
|
39274
|
-
warnings.push("IDE/Extension providers should have cdpPorts");
|
|
39275
|
-
if (config2.category === "extension" && !config2.extensionId)
|
|
39276
|
-
warnings.push("Extension providers should have extensionId");
|
|
39277
|
-
}
|
|
39278
|
-
if (config2.category === "acp" || config2.category === "cli") {
|
|
39279
|
-
if (!config2.spawn) errors.push("ACP/CLI providers must have spawn config");
|
|
39280
|
-
else {
|
|
39281
|
-
if (!config2.spawn.command) errors.push("spawn.command is required");
|
|
39282
|
-
}
|
|
39283
|
-
}
|
|
39842
|
+
const validation = validateProviderDefinition(config2);
|
|
39843
|
+
errors.push(...validation.errors);
|
|
39844
|
+
warnings.push(...validation.warnings);
|
|
39284
39845
|
if (config2.settings) {
|
|
39285
39846
|
for (const [key, val] of Object.entries(config2.settings)) {
|
|
39286
39847
|
const s = val;
|
|
@@ -39397,7 +39958,7 @@ var init_dev_server = __esm({
|
|
|
39397
39958
|
}
|
|
39398
39959
|
let targetDir;
|
|
39399
39960
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
39400
|
-
const jsonPath =
|
|
39961
|
+
const jsonPath = path23.join(targetDir, "provider.json");
|
|
39401
39962
|
if (fs14.existsSync(jsonPath)) {
|
|
39402
39963
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
39403
39964
|
return;
|
|
@@ -39409,8 +39970,8 @@ var init_dev_server = __esm({
|
|
|
39409
39970
|
const createdFiles = ["provider.json"];
|
|
39410
39971
|
if (result.files) {
|
|
39411
39972
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
39412
|
-
const fullPath =
|
|
39413
|
-
fs14.mkdirSync(
|
|
39973
|
+
const fullPath = path23.join(targetDir, relPath);
|
|
39974
|
+
fs14.mkdirSync(path23.dirname(fullPath), { recursive: true });
|
|
39414
39975
|
fs14.writeFileSync(fullPath, content, "utf-8");
|
|
39415
39976
|
createdFiles.push(relPath);
|
|
39416
39977
|
}
|
|
@@ -39463,22 +40024,22 @@ var init_dev_server = __esm({
|
|
|
39463
40024
|
if (!fs14.existsSync(scriptsDir)) return null;
|
|
39464
40025
|
const versions = fs14.readdirSync(scriptsDir).filter((d) => {
|
|
39465
40026
|
try {
|
|
39466
|
-
return fs14.statSync(
|
|
40027
|
+
return fs14.statSync(path23.join(scriptsDir, d)).isDirectory();
|
|
39467
40028
|
} catch {
|
|
39468
40029
|
return false;
|
|
39469
40030
|
}
|
|
39470
40031
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
39471
40032
|
if (versions.length === 0) return null;
|
|
39472
|
-
return
|
|
40033
|
+
return path23.join(scriptsDir, versions[0]);
|
|
39473
40034
|
}
|
|
39474
40035
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
39475
|
-
const canonicalUserDir =
|
|
39476
|
-
const desiredDir = requestedDir ?
|
|
39477
|
-
const upstreamRoot =
|
|
39478
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
40036
|
+
const canonicalUserDir = path23.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
40037
|
+
const desiredDir = requestedDir ? path23.resolve(requestedDir) : canonicalUserDir;
|
|
40038
|
+
const upstreamRoot = path23.resolve(this.providerLoader.getUpstreamDir());
|
|
40039
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path23.sep}`)) {
|
|
39479
40040
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
39480
40041
|
}
|
|
39481
|
-
if (
|
|
40042
|
+
if (path23.basename(desiredDir) !== type) {
|
|
39482
40043
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
39483
40044
|
}
|
|
39484
40045
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -39486,11 +40047,11 @@ var init_dev_server = __esm({
|
|
|
39486
40047
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
39487
40048
|
}
|
|
39488
40049
|
if (!fs14.existsSync(desiredDir)) {
|
|
39489
|
-
fs14.mkdirSync(
|
|
40050
|
+
fs14.mkdirSync(path23.dirname(desiredDir), { recursive: true });
|
|
39490
40051
|
fs14.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
39491
40052
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
39492
40053
|
}
|
|
39493
|
-
const providerJson =
|
|
40054
|
+
const providerJson = path23.join(desiredDir, "provider.json");
|
|
39494
40055
|
if (!fs14.existsSync(providerJson)) {
|
|
39495
40056
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
39496
40057
|
}
|
|
@@ -39538,7 +40099,7 @@ var init_dev_server = __esm({
|
|
|
39538
40099
|
setMode: "set_mode.js"
|
|
39539
40100
|
};
|
|
39540
40101
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
39541
|
-
const scriptsDir =
|
|
40102
|
+
const scriptsDir = path23.join(providerDir, "scripts");
|
|
39542
40103
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
39543
40104
|
if (latestScriptsDir) {
|
|
39544
40105
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -39549,7 +40110,7 @@ var init_dev_server = __esm({
|
|
|
39549
40110
|
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
39550
40111
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
39551
40112
|
try {
|
|
39552
|
-
const content = fs14.readFileSync(
|
|
40113
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
39553
40114
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
39554
40115
|
lines.push("```javascript");
|
|
39555
40116
|
lines.push(content);
|
|
@@ -39566,7 +40127,7 @@ var init_dev_server = __esm({
|
|
|
39566
40127
|
lines.push("");
|
|
39567
40128
|
for (const file2 of refFiles) {
|
|
39568
40129
|
try {
|
|
39569
|
-
const content = fs14.readFileSync(
|
|
40130
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
39570
40131
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
39571
40132
|
lines.push("```javascript");
|
|
39572
40133
|
lines.push(content);
|
|
@@ -39607,10 +40168,10 @@ var init_dev_server = __esm({
|
|
|
39607
40168
|
lines.push("");
|
|
39608
40169
|
}
|
|
39609
40170
|
}
|
|
39610
|
-
const docsDir =
|
|
40171
|
+
const docsDir = path23.join(providerDir, "../../docs");
|
|
39611
40172
|
const loadGuide = (name) => {
|
|
39612
40173
|
try {
|
|
39613
|
-
const p =
|
|
40174
|
+
const p = path23.join(docsDir, name);
|
|
39614
40175
|
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
39615
40176
|
} catch {
|
|
39616
40177
|
}
|
|
@@ -39784,7 +40345,7 @@ var init_dev_server = __esm({
|
|
|
39784
40345
|
parseApproval: "parse_approval.js"
|
|
39785
40346
|
};
|
|
39786
40347
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
39787
|
-
const scriptsDir =
|
|
40348
|
+
const scriptsDir = path23.join(providerDir, "scripts");
|
|
39788
40349
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
39789
40350
|
if (latestScriptsDir) {
|
|
39790
40351
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -39796,7 +40357,7 @@ var init_dev_server = __esm({
|
|
|
39796
40357
|
if (!file2.endsWith(".js")) continue;
|
|
39797
40358
|
if (!targetFileNames.has(file2)) continue;
|
|
39798
40359
|
try {
|
|
39799
|
-
const content = fs14.readFileSync(
|
|
40360
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
39800
40361
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
39801
40362
|
lines.push("```javascript");
|
|
39802
40363
|
lines.push(content);
|
|
@@ -39812,7 +40373,7 @@ var init_dev_server = __esm({
|
|
|
39812
40373
|
lines.push("");
|
|
39813
40374
|
for (const file2 of refFiles) {
|
|
39814
40375
|
try {
|
|
39815
|
-
const content = fs14.readFileSync(
|
|
40376
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
39816
40377
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
39817
40378
|
lines.push("```javascript");
|
|
39818
40379
|
lines.push(content);
|
|
@@ -39845,10 +40406,10 @@ var init_dev_server = __esm({
|
|
|
39845
40406
|
lines.push("");
|
|
39846
40407
|
}
|
|
39847
40408
|
}
|
|
39848
|
-
const docsDir =
|
|
40409
|
+
const docsDir = path23.join(providerDir, "../../docs");
|
|
39849
40410
|
const loadGuide = (name) => {
|
|
39850
40411
|
try {
|
|
39851
|
-
const p =
|
|
40412
|
+
const p = path23.join(docsDir, name);
|
|
39852
40413
|
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
39853
40414
|
} catch {
|
|
39854
40415
|
}
|
|
@@ -40554,7 +41115,8 @@ async function listHostedCliRuntimes(endpoint) {
|
|
|
40554
41115
|
cliType: record2.providerType,
|
|
40555
41116
|
workspace: record2.workspace,
|
|
40556
41117
|
cliArgs: Array.isArray(record2.meta?.cliArgs) ? record2.meta.cliArgs : [],
|
|
40557
|
-
providerSessionId: typeof record2.meta?.providerSessionId === "string" ? String(record2.meta.providerSessionId) : void 0
|
|
41118
|
+
providerSessionId: typeof record2.meta?.providerSessionId === "string" ? String(record2.meta.providerSessionId) : void 0,
|
|
41119
|
+
managedBy: typeof record2.meta?.managedBy === "string" ? String(record2.meta.managedBy) : void 0
|
|
40558
41120
|
}));
|
|
40559
41121
|
} finally {
|
|
40560
41122
|
await client.close().catch(() => {
|
|
@@ -40571,6 +41133,78 @@ var init_runtime_support = __esm({
|
|
|
40571
41133
|
}
|
|
40572
41134
|
});
|
|
40573
41135
|
|
|
41136
|
+
// ../../oss/packages/daemon-core/src/session-host/runtime-surface.ts
|
|
41137
|
+
function isSessionHostLiveRuntime(record2) {
|
|
41138
|
+
const lifecycle = String(record2?.lifecycle || "").trim();
|
|
41139
|
+
return LIVE_LIFECYCLES.has(lifecycle);
|
|
41140
|
+
}
|
|
41141
|
+
function getSessionHostRecoveryLabel(meta3) {
|
|
41142
|
+
const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
|
|
41143
|
+
if (!recoveryState) return null;
|
|
41144
|
+
if (recoveryState === "auto_resumed") return "restored after restart";
|
|
41145
|
+
if (recoveryState === "resume_failed") return "restore failed";
|
|
41146
|
+
if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
|
|
41147
|
+
if (recoveryState === "orphan_snapshot") return "snapshot recovered";
|
|
41148
|
+
return recoveryState.replace(/_/g, " ");
|
|
41149
|
+
}
|
|
41150
|
+
function isSessionHostRecoverySnapshot(record2) {
|
|
41151
|
+
if (!record2) return false;
|
|
41152
|
+
if (isSessionHostLiveRuntime(record2)) return false;
|
|
41153
|
+
const lifecycle = String(record2.lifecycle || "").trim();
|
|
41154
|
+
if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
|
|
41155
|
+
return false;
|
|
41156
|
+
}
|
|
41157
|
+
const meta3 = record2.meta || void 0;
|
|
41158
|
+
if (meta3?.restoredFromStorage === true) return true;
|
|
41159
|
+
return getSessionHostRecoveryLabel(meta3) !== null;
|
|
41160
|
+
}
|
|
41161
|
+
function getSessionHostSurfaceKind(record2) {
|
|
41162
|
+
if (isSessionHostLiveRuntime(record2)) return "live_runtime";
|
|
41163
|
+
if (isSessionHostRecoverySnapshot(record2)) return "recovery_snapshot";
|
|
41164
|
+
return "inactive_record";
|
|
41165
|
+
}
|
|
41166
|
+
function partitionSessionHostRecords(records) {
|
|
41167
|
+
const liveRuntimes = [];
|
|
41168
|
+
const recoverySnapshots = [];
|
|
41169
|
+
const inactiveRecords = [];
|
|
41170
|
+
for (const record2 of records) {
|
|
41171
|
+
const kind = getSessionHostSurfaceKind(record2);
|
|
41172
|
+
if (kind === "live_runtime") {
|
|
41173
|
+
liveRuntimes.push(record2);
|
|
41174
|
+
} else if (kind === "recovery_snapshot") {
|
|
41175
|
+
recoverySnapshots.push(record2);
|
|
41176
|
+
} else {
|
|
41177
|
+
inactiveRecords.push(record2);
|
|
41178
|
+
}
|
|
41179
|
+
}
|
|
41180
|
+
return {
|
|
41181
|
+
liveRuntimes,
|
|
41182
|
+
recoverySnapshots,
|
|
41183
|
+
inactiveRecords
|
|
41184
|
+
};
|
|
41185
|
+
}
|
|
41186
|
+
function partitionSessionHostDiagnosticsSessions(records) {
|
|
41187
|
+
return partitionSessionHostRecords(records || []);
|
|
41188
|
+
}
|
|
41189
|
+
var LIVE_LIFECYCLES;
|
|
41190
|
+
var init_runtime_surface = __esm({
|
|
41191
|
+
"../../oss/packages/daemon-core/src/session-host/runtime-surface.ts"() {
|
|
41192
|
+
"use strict";
|
|
41193
|
+
LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
|
|
41194
|
+
}
|
|
41195
|
+
});
|
|
41196
|
+
|
|
41197
|
+
// ../../oss/packages/daemon-core/src/session-host/startup-restore-policy.js
|
|
41198
|
+
function shouldAutoRestoreHostedSessionsOnStartup(env = process.env) {
|
|
41199
|
+
const raw = typeof env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP === "string" ? env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP.trim().toLowerCase() : "";
|
|
41200
|
+
return raw === "1" || raw === "true" || raw === "yes";
|
|
41201
|
+
}
|
|
41202
|
+
var init_startup_restore_policy = __esm({
|
|
41203
|
+
"../../oss/packages/daemon-core/src/session-host/startup-restore-policy.js"() {
|
|
41204
|
+
"use strict";
|
|
41205
|
+
}
|
|
41206
|
+
});
|
|
41207
|
+
|
|
40574
41208
|
// ../../oss/packages/daemon-core/src/installer.ts
|
|
40575
41209
|
function isExtensionInstalled(ide, marketplaceId) {
|
|
40576
41210
|
if (!ide.cliCommand) return false;
|
|
@@ -40612,8 +41246,8 @@ async function installExtension(ide, extension) {
|
|
|
40612
41246
|
const res = await fetch(extension.vsixUrl);
|
|
40613
41247
|
if (res.ok) {
|
|
40614
41248
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
40615
|
-
const
|
|
40616
|
-
|
|
41249
|
+
const fs19 = await import("fs");
|
|
41250
|
+
fs19.writeFileSync(vsixPath, buffer);
|
|
40617
41251
|
return new Promise((resolve16) => {
|
|
40618
41252
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
40619
41253
|
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
@@ -41110,6 +41744,7 @@ __export(src_exports, {
|
|
|
41110
41744
|
detectIDEs: () => detectIDEs,
|
|
41111
41745
|
ensureSessionHostReady: () => ensureSessionHostReady,
|
|
41112
41746
|
findCdpManager: () => findCdpManager,
|
|
41747
|
+
flattenMessageParts: () => flattenMessageParts,
|
|
41113
41748
|
forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
|
|
41114
41749
|
getAIExtensions: () => getAIExtensions,
|
|
41115
41750
|
getAvailableIdeIds: () => getAvailableIdeIds,
|
|
@@ -41123,6 +41758,8 @@ __export(src_exports, {
|
|
|
41123
41758
|
getRecentDebugTrace: () => getRecentDebugTrace,
|
|
41124
41759
|
getRecentLogs: () => getRecentLogs,
|
|
41125
41760
|
getSavedProviderSessions: () => getSavedProviderSessions,
|
|
41761
|
+
getSessionHostRecoveryLabel: () => getSessionHostRecoveryLabel,
|
|
41762
|
+
getSessionHostSurfaceKind: () => getSessionHostSurfaceKind,
|
|
41126
41763
|
getWorkspaceState: () => getWorkspaceState,
|
|
41127
41764
|
hasCdpManager: () => hasCdpManager,
|
|
41128
41765
|
initDaemonComponents: () => initDaemonComponents,
|
|
@@ -41133,6 +41770,8 @@ __export(src_exports, {
|
|
|
41133
41770
|
isIdeRunning: () => isIdeRunning,
|
|
41134
41771
|
isManagedStatusWaiting: () => isManagedStatusWaiting,
|
|
41135
41772
|
isManagedStatusWorking: () => isManagedStatusWorking,
|
|
41773
|
+
isSessionHostLiveRuntime: () => isSessionHostLiveRuntime,
|
|
41774
|
+
isSessionHostRecoverySnapshot: () => isSessionHostRecoverySnapshot,
|
|
41136
41775
|
isSetupComplete: () => isSetupComplete,
|
|
41137
41776
|
killIdeProcess: () => killIdeProcess,
|
|
41138
41777
|
launchIDE: () => launchIDE,
|
|
@@ -41144,7 +41783,11 @@ __export(src_exports, {
|
|
|
41144
41783
|
markSetupComplete: () => markSetupComplete,
|
|
41145
41784
|
maybeRunDaemonUpgradeHelperFromEnv: () => maybeRunDaemonUpgradeHelperFromEnv,
|
|
41146
41785
|
normalizeActiveChatData: () => normalizeActiveChatData,
|
|
41786
|
+
normalizeInputEnvelope: () => normalizeInputEnvelope,
|
|
41147
41787
|
normalizeManagedStatus: () => normalizeManagedStatus,
|
|
41788
|
+
normalizeMessageParts: () => normalizeMessageParts,
|
|
41789
|
+
partitionSessionHostDiagnosticsSessions: () => partitionSessionHostDiagnosticsSessions,
|
|
41790
|
+
partitionSessionHostRecords: () => partitionSessionHostRecords,
|
|
41148
41791
|
probeCdpPort: () => probeCdpPort,
|
|
41149
41792
|
readChatHistory: () => readChatHistory,
|
|
41150
41793
|
recordDebugTrace: () => recordDebugTrace,
|
|
@@ -41159,6 +41802,7 @@ __export(src_exports, {
|
|
|
41159
41802
|
setDebugRuntimeConfig: () => setDebugRuntimeConfig,
|
|
41160
41803
|
setLogLevel: () => setLogLevel,
|
|
41161
41804
|
setupIdeInstance: () => setupIdeInstance,
|
|
41805
|
+
shouldAutoRestoreHostedSessionsOnStartup: () => shouldAutoRestoreHostedSessionsOnStartup,
|
|
41162
41806
|
shouldCollectTraceCategory: () => shouldCollectTraceCategory,
|
|
41163
41807
|
shutdownDaemonComponents: () => shutdownDaemonComponents,
|
|
41164
41808
|
spawnDetachedDaemonUpgradeHelper: () => spawnDetachedDaemonUpgradeHelper,
|
|
@@ -41205,6 +41849,7 @@ var init_src = __esm({
|
|
|
41205
41849
|
init_ide_provider_instance();
|
|
41206
41850
|
init_cli_provider_instance();
|
|
41207
41851
|
init_acp_provider_instance();
|
|
41852
|
+
init_io_contracts();
|
|
41208
41853
|
init_version_archive();
|
|
41209
41854
|
init_dev_server();
|
|
41210
41855
|
init_provider_cli_adapter();
|
|
@@ -41212,6 +41857,8 @@ var init_src = __esm({
|
|
|
41212
41857
|
init_session_host_transport();
|
|
41213
41858
|
init_app_name();
|
|
41214
41859
|
init_runtime_support();
|
|
41860
|
+
init_runtime_surface();
|
|
41861
|
+
init_startup_restore_policy();
|
|
41215
41862
|
init_installer();
|
|
41216
41863
|
init_daemon_lifecycle();
|
|
41217
41864
|
}
|
|
@@ -42255,12 +42902,12 @@ var init_peer_connection_manager = __esm({
|
|
|
42255
42902
|
});
|
|
42256
42903
|
|
|
42257
42904
|
// src/daemon-p2p/index.ts
|
|
42258
|
-
var fs15,
|
|
42905
|
+
var fs15, path24, import_node_module2, esmRequire, DaemonP2PSender;
|
|
42259
42906
|
var init_daemon_p2p = __esm({
|
|
42260
42907
|
"src/daemon-p2p/index.ts"() {
|
|
42261
42908
|
"use strict";
|
|
42262
42909
|
fs15 = __toESM(require("fs"));
|
|
42263
|
-
|
|
42910
|
+
path24 = __toESM(require("path"));
|
|
42264
42911
|
import_node_module2 = require("module");
|
|
42265
42912
|
init_data_channel_router();
|
|
42266
42913
|
init_screenshot_sender();
|
|
@@ -42333,15 +42980,15 @@ ${e?.stack || ""}`);
|
|
|
42333
42980
|
const prebuildKey = `${platform12}-${arch3}`;
|
|
42334
42981
|
try {
|
|
42335
42982
|
const candidates = [
|
|
42336
|
-
|
|
42337
|
-
|
|
42338
|
-
|
|
42983
|
+
path24.join(__dirname, "node_modules", "node-datachannel"),
|
|
42984
|
+
path24.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
42985
|
+
path24.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
42339
42986
|
];
|
|
42340
42987
|
for (const candidate of candidates) {
|
|
42341
|
-
const prebuildPath =
|
|
42988
|
+
const prebuildPath = path24.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
42342
42989
|
if (fs15.existsSync(prebuildPath)) {
|
|
42343
|
-
const targetDir =
|
|
42344
|
-
const targetPath =
|
|
42990
|
+
const targetDir = path24.join(candidate, "build", "Release");
|
|
42991
|
+
const targetPath = path24.join(targetDir, "node_datachannel.node");
|
|
42345
42992
|
fs15.mkdirSync(targetDir, { recursive: true });
|
|
42346
42993
|
fs15.copyFileSync(prebuildPath, targetPath);
|
|
42347
42994
|
try {
|
|
@@ -42659,27 +43306,27 @@ var require_process = __commonJS({
|
|
|
42659
43306
|
var require_filesystem = __commonJS({
|
|
42660
43307
|
"../../node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
|
|
42661
43308
|
"use strict";
|
|
42662
|
-
var
|
|
43309
|
+
var fs19 = require("fs");
|
|
42663
43310
|
var LDD_PATH = "/usr/bin/ldd";
|
|
42664
43311
|
var SELF_PATH = "/proc/self/exe";
|
|
42665
43312
|
var MAX_LENGTH = 2048;
|
|
42666
|
-
var
|
|
42667
|
-
const fd =
|
|
43313
|
+
var readFileSync18 = (path28) => {
|
|
43314
|
+
const fd = fs19.openSync(path28, "r");
|
|
42668
43315
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
42669
|
-
const bytesRead =
|
|
42670
|
-
|
|
43316
|
+
const bytesRead = fs19.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
43317
|
+
fs19.close(fd, () => {
|
|
42671
43318
|
});
|
|
42672
43319
|
return buffer.subarray(0, bytesRead);
|
|
42673
43320
|
};
|
|
42674
|
-
var readFile = (
|
|
42675
|
-
|
|
43321
|
+
var readFile = (path28) => new Promise((resolve16, reject) => {
|
|
43322
|
+
fs19.open(path28, "r", (err, fd) => {
|
|
42676
43323
|
if (err) {
|
|
42677
43324
|
reject(err);
|
|
42678
43325
|
} else {
|
|
42679
43326
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
42680
|
-
|
|
43327
|
+
fs19.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
42681
43328
|
resolve16(buffer.subarray(0, bytesRead));
|
|
42682
|
-
|
|
43329
|
+
fs19.close(fd, () => {
|
|
42683
43330
|
});
|
|
42684
43331
|
});
|
|
42685
43332
|
}
|
|
@@ -42688,7 +43335,7 @@ var require_filesystem = __commonJS({
|
|
|
42688
43335
|
module2.exports = {
|
|
42689
43336
|
LDD_PATH,
|
|
42690
43337
|
SELF_PATH,
|
|
42691
|
-
readFileSync:
|
|
43338
|
+
readFileSync: readFileSync18,
|
|
42692
43339
|
readFile
|
|
42693
43340
|
};
|
|
42694
43341
|
}
|
|
@@ -42737,7 +43384,7 @@ var require_detect_libc = __commonJS({
|
|
|
42737
43384
|
"use strict";
|
|
42738
43385
|
var childProcess = require("child_process");
|
|
42739
43386
|
var { isLinux: isLinux2, getReport } = require_process();
|
|
42740
|
-
var { LDD_PATH, SELF_PATH, readFile, readFileSync:
|
|
43387
|
+
var { LDD_PATH, SELF_PATH, readFile, readFileSync: readFileSync18 } = require_filesystem();
|
|
42741
43388
|
var { interpreterPath } = require_elf();
|
|
42742
43389
|
var cachedFamilyInterpreter;
|
|
42743
43390
|
var cachedFamilyFilesystem;
|
|
@@ -42791,11 +43438,11 @@ var require_detect_libc = __commonJS({
|
|
|
42791
43438
|
}
|
|
42792
43439
|
return null;
|
|
42793
43440
|
};
|
|
42794
|
-
var familyFromInterpreterPath = (
|
|
42795
|
-
if (
|
|
42796
|
-
if (
|
|
43441
|
+
var familyFromInterpreterPath = (path28) => {
|
|
43442
|
+
if (path28) {
|
|
43443
|
+
if (path28.includes("/ld-musl-")) {
|
|
42797
43444
|
return MUSL;
|
|
42798
|
-
} else if (
|
|
43445
|
+
} else if (path28.includes("/ld-linux-")) {
|
|
42799
43446
|
return GLIBC;
|
|
42800
43447
|
}
|
|
42801
43448
|
}
|
|
@@ -42829,7 +43476,7 @@ var require_detect_libc = __commonJS({
|
|
|
42829
43476
|
}
|
|
42830
43477
|
cachedFamilyFilesystem = null;
|
|
42831
43478
|
try {
|
|
42832
|
-
const lddContent =
|
|
43479
|
+
const lddContent = readFileSync18(LDD_PATH);
|
|
42833
43480
|
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
|
42834
43481
|
} catch (e) {
|
|
42835
43482
|
}
|
|
@@ -42842,8 +43489,8 @@ var require_detect_libc = __commonJS({
|
|
|
42842
43489
|
cachedFamilyInterpreter = null;
|
|
42843
43490
|
try {
|
|
42844
43491
|
const selfContent = await readFile(SELF_PATH);
|
|
42845
|
-
const
|
|
42846
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
43492
|
+
const path28 = interpreterPath(selfContent);
|
|
43493
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path28);
|
|
42847
43494
|
} catch (e) {
|
|
42848
43495
|
}
|
|
42849
43496
|
return cachedFamilyInterpreter;
|
|
@@ -42854,9 +43501,9 @@ var require_detect_libc = __commonJS({
|
|
|
42854
43501
|
}
|
|
42855
43502
|
cachedFamilyInterpreter = null;
|
|
42856
43503
|
try {
|
|
42857
|
-
const selfContent =
|
|
42858
|
-
const
|
|
42859
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
43504
|
+
const selfContent = readFileSync18(SELF_PATH);
|
|
43505
|
+
const path28 = interpreterPath(selfContent);
|
|
43506
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path28);
|
|
42860
43507
|
} catch (e) {
|
|
42861
43508
|
}
|
|
42862
43509
|
return cachedFamilyInterpreter;
|
|
@@ -42918,7 +43565,7 @@ var require_detect_libc = __commonJS({
|
|
|
42918
43565
|
}
|
|
42919
43566
|
cachedVersionFilesystem = null;
|
|
42920
43567
|
try {
|
|
42921
|
-
const lddContent =
|
|
43568
|
+
const lddContent = readFileSync18(LDD_PATH);
|
|
42922
43569
|
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
|
42923
43570
|
if (versionMatch) {
|
|
42924
43571
|
cachedVersionFilesystem = versionMatch[1];
|
|
@@ -44575,18 +45222,18 @@ var require_sharp = __commonJS({
|
|
|
44575
45222
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
44576
45223
|
"@img/sharp-wasm32/sharp.node"
|
|
44577
45224
|
];
|
|
44578
|
-
var
|
|
45225
|
+
var path28;
|
|
44579
45226
|
var sharp;
|
|
44580
45227
|
var errors = [];
|
|
44581
|
-
for (
|
|
45228
|
+
for (path28 of paths) {
|
|
44582
45229
|
try {
|
|
44583
|
-
sharp = require(
|
|
45230
|
+
sharp = require(path28);
|
|
44584
45231
|
break;
|
|
44585
45232
|
} catch (err) {
|
|
44586
45233
|
errors.push(err);
|
|
44587
45234
|
}
|
|
44588
45235
|
}
|
|
44589
|
-
if (sharp &&
|
|
45236
|
+
if (sharp && path28.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
44590
45237
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
44591
45238
|
err.code = "Unsupported CPU";
|
|
44592
45239
|
errors.push(err);
|
|
@@ -44595,7 +45242,7 @@ var require_sharp = __commonJS({
|
|
|
44595
45242
|
if (sharp) {
|
|
44596
45243
|
module2.exports = sharp;
|
|
44597
45244
|
} else {
|
|
44598
|
-
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((
|
|
45245
|
+
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((os25) => runtimePlatform.startsWith(os25));
|
|
44599
45246
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
44600
45247
|
errors.forEach((err) => {
|
|
44601
45248
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -44612,15 +45259,15 @@ var require_sharp = __commonJS({
|
|
|
44612
45259
|
` Requires ${expected}`
|
|
44613
45260
|
);
|
|
44614
45261
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
44615
|
-
const [
|
|
44616
|
-
const libc =
|
|
45262
|
+
const [os25, cpu] = runtimePlatform.split("-");
|
|
45263
|
+
const libc = os25.endsWith("musl") ? " --libc=musl" : "";
|
|
44617
45264
|
help.push(
|
|
44618
45265
|
"- Ensure optional dependencies can be installed:",
|
|
44619
45266
|
" npm install --include=optional sharp",
|
|
44620
45267
|
"- Ensure your package manager supports multi-platform installation:",
|
|
44621
45268
|
" See https://sharp.pixelplumbing.com/install#cross-platform",
|
|
44622
45269
|
"- Add platform-specific dependencies:",
|
|
44623
|
-
` npm install --os=${
|
|
45270
|
+
` npm install --os=${os25.replace("musl", "")}${libc} --cpu=${cpu} sharp`
|
|
44624
45271
|
);
|
|
44625
45272
|
} else {
|
|
44626
45273
|
help.push(
|
|
@@ -47495,15 +48142,15 @@ var require_color = __commonJS({
|
|
|
47495
48142
|
};
|
|
47496
48143
|
}
|
|
47497
48144
|
function wrapConversion(toModel, graph) {
|
|
47498
|
-
const
|
|
48145
|
+
const path28 = [graph[toModel].parent, toModel];
|
|
47499
48146
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
47500
48147
|
let cur = graph[toModel].parent;
|
|
47501
48148
|
while (graph[cur].parent) {
|
|
47502
|
-
|
|
48149
|
+
path28.unshift(graph[cur].parent);
|
|
47503
48150
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
47504
48151
|
cur = graph[cur].parent;
|
|
47505
48152
|
}
|
|
47506
|
-
fn.conversion =
|
|
48153
|
+
fn.conversion = path28;
|
|
47507
48154
|
return fn;
|
|
47508
48155
|
}
|
|
47509
48156
|
function route(fromModel) {
|
|
@@ -48120,7 +48767,7 @@ var require_channel = __commonJS({
|
|
|
48120
48767
|
var require_output = __commonJS({
|
|
48121
48768
|
"../../node_modules/sharp/lib/output.js"(exports2, module2) {
|
|
48122
48769
|
"use strict";
|
|
48123
|
-
var
|
|
48770
|
+
var path28 = require("path");
|
|
48124
48771
|
var is = require_is();
|
|
48125
48772
|
var sharp = require_sharp();
|
|
48126
48773
|
var formats = /* @__PURE__ */ new Map([
|
|
@@ -48151,9 +48798,9 @@ var require_output = __commonJS({
|
|
|
48151
48798
|
let err;
|
|
48152
48799
|
if (!is.string(fileOut)) {
|
|
48153
48800
|
err = new Error("Missing output file path");
|
|
48154
|
-
} else if (is.string(this.options.input.file) &&
|
|
48801
|
+
} else if (is.string(this.options.input.file) && path28.resolve(this.options.input.file) === path28.resolve(fileOut)) {
|
|
48155
48802
|
err = new Error("Cannot use same file for input and output");
|
|
48156
|
-
} else if (jp2Regex.test(
|
|
48803
|
+
} else if (jp2Regex.test(path28.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
48157
48804
|
err = errJp2Save();
|
|
48158
48805
|
}
|
|
48159
48806
|
if (err) {
|
|
@@ -49350,6 +49997,98 @@ var init_screenshot_controller = __esm({
|
|
|
49350
49997
|
}
|
|
49351
49998
|
});
|
|
49352
49999
|
|
|
50000
|
+
// src/session-host-hygiene.ts
|
|
50001
|
+
function formatTimestamp(date5) {
|
|
50002
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
50003
|
+
return [
|
|
50004
|
+
date5.getUTCFullYear(),
|
|
50005
|
+
pad(date5.getUTCMonth() + 1),
|
|
50006
|
+
pad(date5.getUTCDate()),
|
|
50007
|
+
"-",
|
|
50008
|
+
pad(date5.getUTCHours()),
|
|
50009
|
+
pad(date5.getUTCMinutes()),
|
|
50010
|
+
pad(date5.getUTCSeconds())
|
|
50011
|
+
].join("");
|
|
50012
|
+
}
|
|
50013
|
+
function defaultPidRunning(pid) {
|
|
50014
|
+
try {
|
|
50015
|
+
process.kill(pid, 0);
|
|
50016
|
+
return true;
|
|
50017
|
+
} catch {
|
|
50018
|
+
return false;
|
|
50019
|
+
}
|
|
50020
|
+
}
|
|
50021
|
+
function shouldSkipForExplicitOverride(env) {
|
|
50022
|
+
const explicit = typeof env?.ADHDEV_SESSION_HOST_NAME === "string" ? env.ADHDEV_SESSION_HOST_NAME.trim() : "";
|
|
50023
|
+
return explicit.length > 0;
|
|
50024
|
+
}
|
|
50025
|
+
function isActiveStandaloneRecord(record2, isPidRunning) {
|
|
50026
|
+
const managerTag = typeof record2?.meta?.managedBy === "string" ? record2.meta.managedBy.trim() : "";
|
|
50027
|
+
if (managerTag !== LEGACY_STANDALONE_MANAGER_TAG) return false;
|
|
50028
|
+
const lifecycle = typeof record2?.lifecycle === "string" ? record2.lifecycle.trim() : "";
|
|
50029
|
+
const pid = Number(record2?.osPid);
|
|
50030
|
+
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
50031
|
+
if (lifecycle !== "running" && lifecycle !== "starting" && lifecycle !== "interrupted") return false;
|
|
50032
|
+
return isPidRunning(pid);
|
|
50033
|
+
}
|
|
50034
|
+
function quarantineLegacyStandaloneSessions(options) {
|
|
50035
|
+
const env = options.env || process.env;
|
|
50036
|
+
if (options.appName !== DEFAULT_SESSION_HOST_APP_NAME) {
|
|
50037
|
+
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
50038
|
+
}
|
|
50039
|
+
if (shouldSkipForExplicitOverride(env)) {
|
|
50040
|
+
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
50041
|
+
}
|
|
50042
|
+
const homeDir = options.homeDir || os21.homedir();
|
|
50043
|
+
const now = options.now || (() => /* @__PURE__ */ new Date());
|
|
50044
|
+
const isPidRunning = options.isPidRunning || defaultPidRunning;
|
|
50045
|
+
const runtimesDir = path25.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
|
|
50046
|
+
if (!fs16.existsSync(runtimesDir)) {
|
|
50047
|
+
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
50048
|
+
}
|
|
50049
|
+
const candidates = fs16.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path25.join(runtimesDir, name));
|
|
50050
|
+
let movedCount = 0;
|
|
50051
|
+
let skippedActiveCount = 0;
|
|
50052
|
+
let backupDir = null;
|
|
50053
|
+
for (const sourcePath of candidates) {
|
|
50054
|
+
let parsed;
|
|
50055
|
+
try {
|
|
50056
|
+
parsed = JSON.parse(fs16.readFileSync(sourcePath, "utf8"));
|
|
50057
|
+
} catch {
|
|
50058
|
+
continue;
|
|
50059
|
+
}
|
|
50060
|
+
const managerTag = typeof parsed?.meta?.managedBy === "string" ? parsed.meta.managedBy.trim() : "";
|
|
50061
|
+
if (managerTag !== LEGACY_STANDALONE_MANAGER_TAG) continue;
|
|
50062
|
+
if (isActiveStandaloneRecord(parsed, isPidRunning)) {
|
|
50063
|
+
skippedActiveCount += 1;
|
|
50064
|
+
continue;
|
|
50065
|
+
}
|
|
50066
|
+
if (!backupDir) {
|
|
50067
|
+
backupDir = path25.join(
|
|
50068
|
+
homeDir,
|
|
50069
|
+
".adhdev",
|
|
50070
|
+
"session-host-backups",
|
|
50071
|
+
`legacy-standalone-${options.appName}-${formatTimestamp(now())}`
|
|
50072
|
+
);
|
|
50073
|
+
fs16.mkdirSync(path25.join(backupDir, "runtimes"), { recursive: true });
|
|
50074
|
+
}
|
|
50075
|
+
fs16.renameSync(sourcePath, path25.join(backupDir, "runtimes", path25.basename(sourcePath)));
|
|
50076
|
+
movedCount += 1;
|
|
50077
|
+
}
|
|
50078
|
+
return { movedCount, skippedActiveCount, backupDir };
|
|
50079
|
+
}
|
|
50080
|
+
var fs16, os21, path25, LEGACY_STANDALONE_MANAGER_TAG;
|
|
50081
|
+
var init_session_host_hygiene = __esm({
|
|
50082
|
+
"src/session-host-hygiene.ts"() {
|
|
50083
|
+
"use strict";
|
|
50084
|
+
fs16 = __toESM(require("fs"));
|
|
50085
|
+
os21 = __toESM(require("os"));
|
|
50086
|
+
path25 = __toESM(require("path"));
|
|
50087
|
+
init_src();
|
|
50088
|
+
LEGACY_STANDALONE_MANAGER_TAG = "adhdev-standalone";
|
|
50089
|
+
}
|
|
50090
|
+
});
|
|
50091
|
+
|
|
49353
50092
|
// src/session-host.ts
|
|
49354
50093
|
function buildSessionHostEnv(baseEnv) {
|
|
49355
50094
|
const env = sanitizeSpawnEnv(baseEnv);
|
|
@@ -49358,18 +50097,18 @@ function buildSessionHostEnv(baseEnv) {
|
|
|
49358
50097
|
}
|
|
49359
50098
|
function resolveSessionHostEntry() {
|
|
49360
50099
|
const packagedCandidates = [
|
|
49361
|
-
|
|
49362
|
-
|
|
50100
|
+
path26.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
50101
|
+
path26.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
49363
50102
|
];
|
|
49364
50103
|
for (const candidate of packagedCandidates) {
|
|
49365
|
-
if (
|
|
50104
|
+
if (fs17.existsSync(candidate)) {
|
|
49366
50105
|
return candidate;
|
|
49367
50106
|
}
|
|
49368
50107
|
}
|
|
49369
50108
|
return require.resolve("@adhdev/session-host-daemon");
|
|
49370
50109
|
}
|
|
49371
50110
|
function getSessionHostPidFile() {
|
|
49372
|
-
return
|
|
50111
|
+
return path26.join(os23.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
49373
50112
|
}
|
|
49374
50113
|
function killPid2(pid) {
|
|
49375
50114
|
try {
|
|
@@ -49412,12 +50151,12 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
49412
50151
|
}
|
|
49413
50152
|
return null;
|
|
49414
50153
|
}
|
|
49415
|
-
function
|
|
50154
|
+
function stopManagedSessionHostProcess() {
|
|
49416
50155
|
let stopped = false;
|
|
49417
50156
|
const pidFile = getSessionHostPidFile();
|
|
49418
50157
|
try {
|
|
49419
|
-
if (
|
|
49420
|
-
const pid = Number.parseInt(
|
|
50158
|
+
if (fs17.existsSync(pidFile)) {
|
|
50159
|
+
const pid = Number.parseInt(fs17.readFileSync(pidFile, "utf8").trim(), 10);
|
|
49421
50160
|
if (Number.isFinite(pid) && pid !== process.pid) {
|
|
49422
50161
|
stopped = killPid2(pid) || stopped;
|
|
49423
50162
|
}
|
|
@@ -49425,10 +50164,14 @@ function stopSessionHost() {
|
|
|
49425
50164
|
} catch {
|
|
49426
50165
|
} finally {
|
|
49427
50166
|
try {
|
|
49428
|
-
|
|
50167
|
+
fs17.unlinkSync(pidFile);
|
|
49429
50168
|
} catch {
|
|
49430
50169
|
}
|
|
49431
50170
|
}
|
|
50171
|
+
return stopped;
|
|
50172
|
+
}
|
|
50173
|
+
function stopSessionHost() {
|
|
50174
|
+
let stopped = stopManagedSessionHostProcess();
|
|
49432
50175
|
if (process.platform === "win32") {
|
|
49433
50176
|
try {
|
|
49434
50177
|
const raw = (0, import_child_process11.execFileSync)("tasklist", ["/FO", "CSV", "/NH", "/FI", "IMAGENAME eq node.exe"], {
|
|
@@ -49464,11 +50207,27 @@ function stopSessionHost() {
|
|
|
49464
50207
|
return stopped;
|
|
49465
50208
|
}
|
|
49466
50209
|
async function ensureSessionHostReady2() {
|
|
50210
|
+
const quarantine = quarantineLegacyStandaloneSessions({
|
|
50211
|
+
appName: SESSION_HOST_APP_NAME,
|
|
50212
|
+
env: process.env
|
|
50213
|
+
});
|
|
50214
|
+
if (quarantine.movedCount > 0) {
|
|
50215
|
+
LOG.warn(
|
|
50216
|
+
"SessionHost",
|
|
50217
|
+
`quarantined ${quarantine.movedCount} legacy standalone runtime file(s) from ${SESSION_HOST_APP_NAME}` + (quarantine.backupDir ? ` \u2192 ${quarantine.backupDir}` : "")
|
|
50218
|
+
);
|
|
50219
|
+
}
|
|
50220
|
+
if (quarantine.skippedActiveCount > 0) {
|
|
50221
|
+
LOG.warn(
|
|
50222
|
+
"SessionHost",
|
|
50223
|
+
`detected ${quarantine.skippedActiveCount} active standalone runtime(s) still using the ${SESSION_HOST_APP_NAME} namespace; leaving them untouched`
|
|
50224
|
+
);
|
|
50225
|
+
}
|
|
49467
50226
|
const spawnHost = () => {
|
|
49468
50227
|
const entry = resolveSessionHostEntry();
|
|
49469
|
-
const logDir =
|
|
49470
|
-
|
|
49471
|
-
const logFd =
|
|
50228
|
+
const logDir = path26.join(os23.homedir(), ".adhdev", "logs");
|
|
50229
|
+
fs17.mkdirSync(logDir, { recursive: true });
|
|
50230
|
+
const logFd = fs17.openSync(path26.join(logDir, "session-host.log"), "a");
|
|
49472
50231
|
const child = (0, import_child_process11.spawn)(process.execPath, [entry], {
|
|
49473
50232
|
detached: true,
|
|
49474
50233
|
stdio: ["ignore", logFd, logFd],
|
|
@@ -49477,7 +50236,7 @@ async function ensureSessionHostReady2() {
|
|
|
49477
50236
|
});
|
|
49478
50237
|
child.unref();
|
|
49479
50238
|
try {
|
|
49480
|
-
|
|
50239
|
+
fs17.closeSync(logFd);
|
|
49481
50240
|
} catch {
|
|
49482
50241
|
}
|
|
49483
50242
|
};
|
|
@@ -49503,17 +50262,18 @@ async function ensureSessionHostReady2() {
|
|
|
49503
50262
|
async function listHostedCliRuntimes2(endpoint) {
|
|
49504
50263
|
return listHostedCliRuntimes(endpoint);
|
|
49505
50264
|
}
|
|
49506
|
-
var import_child_process11,
|
|
50265
|
+
var import_child_process11, fs17, os23, path26, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
|
|
49507
50266
|
var init_session_host = __esm({
|
|
49508
50267
|
"src/session-host.ts"() {
|
|
49509
50268
|
"use strict";
|
|
49510
50269
|
import_child_process11 = require("child_process");
|
|
49511
|
-
|
|
49512
|
-
|
|
49513
|
-
|
|
50270
|
+
fs17 = __toESM(require("fs"));
|
|
50271
|
+
os23 = __toESM(require("os"));
|
|
50272
|
+
path26 = __toESM(require("path"));
|
|
49514
50273
|
init_src();
|
|
49515
50274
|
init_dist();
|
|
49516
|
-
|
|
50275
|
+
init_session_host_hygiene();
|
|
50276
|
+
SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || DEFAULT_SESSION_HOST_APP_NAME;
|
|
49517
50277
|
SESSION_HOST_START_TIMEOUT_MS = 15e3;
|
|
49518
50278
|
}
|
|
49519
50279
|
});
|
|
@@ -49746,31 +50506,36 @@ function buildSessionModalDeliverySignature(payload) {
|
|
|
49746
50506
|
Array.isArray(payload.modalButtons) ? payload.modalButtons.join("") : ""
|
|
49747
50507
|
]);
|
|
49748
50508
|
}
|
|
49749
|
-
function
|
|
49750
|
-
|
|
49751
|
-
|
|
49752
|
-
|
|
50509
|
+
function resolveDaemonPort(ref = {}) {
|
|
50510
|
+
return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
|
|
50511
|
+
}
|
|
50512
|
+
function getDaemonPidFile(ref = {}) {
|
|
50513
|
+
const dir = path27.join(ref.homeDir || os24.homedir(), ".adhdev");
|
|
50514
|
+
if (!fs18.existsSync(dir)) fs18.mkdirSync(dir, { recursive: true });
|
|
50515
|
+
const port = resolveDaemonPort(ref);
|
|
50516
|
+
return path27.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
|
|
49753
50517
|
}
|
|
49754
|
-
function writeDaemonPid(pid) {
|
|
49755
|
-
const pidFile = getDaemonPidFile();
|
|
50518
|
+
function writeDaemonPid(pid, ref = {}) {
|
|
50519
|
+
const pidFile = getDaemonPidFile(ref);
|
|
49756
50520
|
try {
|
|
49757
|
-
|
|
50521
|
+
fs18.writeFileSync(pidFile, String(pid), { encoding: "utf-8", flag: "wx" });
|
|
49758
50522
|
} catch {
|
|
49759
|
-
|
|
50523
|
+
fs18.writeFileSync(pidFile, String(pid), "utf-8");
|
|
49760
50524
|
}
|
|
49761
50525
|
}
|
|
49762
|
-
function removeDaemonPid() {
|
|
50526
|
+
function removeDaemonPid(ref = {}) {
|
|
49763
50527
|
try {
|
|
49764
|
-
|
|
50528
|
+
fs18.unlinkSync(getDaemonPidFile(ref));
|
|
49765
50529
|
} catch (e) {
|
|
49766
50530
|
}
|
|
49767
50531
|
}
|
|
49768
|
-
function isDaemonRunning() {
|
|
50532
|
+
function isDaemonRunning(ref = {}) {
|
|
50533
|
+
const port = resolveDaemonPort(ref);
|
|
49769
50534
|
try {
|
|
49770
50535
|
const { execFileSync: execFileSync3 } = require("child_process");
|
|
49771
50536
|
const probe = `
|
|
49772
50537
|
const http = require('http');
|
|
49773
|
-
const req = http.get('http://127.0.0.1:${
|
|
50538
|
+
const req = http.get('http://127.0.0.1:${port}/health', { timeout: 1500 }, (res) => {
|
|
49774
50539
|
process.stdout.write(String(res.statusCode));
|
|
49775
50540
|
res.resume();
|
|
49776
50541
|
});
|
|
@@ -49785,18 +50550,18 @@ function isDaemonRunning() {
|
|
|
49785
50550
|
if (result === "200") return true;
|
|
49786
50551
|
} catch {
|
|
49787
50552
|
}
|
|
49788
|
-
const pidFile = getDaemonPidFile();
|
|
50553
|
+
const pidFile = getDaemonPidFile(ref);
|
|
49789
50554
|
try {
|
|
49790
|
-
if (!
|
|
49791
|
-
const pid = parseInt(
|
|
50555
|
+
if (!fs18.existsSync(pidFile)) return false;
|
|
50556
|
+
const pid = parseInt(fs18.readFileSync(pidFile, "utf-8").trim());
|
|
49792
50557
|
process.kill(pid, 0);
|
|
49793
50558
|
if (!isAdhdevProcess(pid)) {
|
|
49794
|
-
removeDaemonPid();
|
|
50559
|
+
removeDaemonPid(ref);
|
|
49795
50560
|
return false;
|
|
49796
50561
|
}
|
|
49797
50562
|
return true;
|
|
49798
50563
|
} catch {
|
|
49799
|
-
removeDaemonPid();
|
|
50564
|
+
removeDaemonPid(ref);
|
|
49800
50565
|
return false;
|
|
49801
50566
|
}
|
|
49802
50567
|
}
|
|
@@ -49830,30 +50595,30 @@ function isAdhdevProcess(pid) {
|
|
|
49830
50595
|
return true;
|
|
49831
50596
|
}
|
|
49832
50597
|
}
|
|
49833
|
-
function getDaemonPid() {
|
|
49834
|
-
const pidFile = getDaemonPidFile();
|
|
50598
|
+
function getDaemonPid(ref = {}) {
|
|
50599
|
+
const pidFile = getDaemonPidFile(ref);
|
|
49835
50600
|
try {
|
|
49836
|
-
if (!
|
|
49837
|
-
const pid = parseInt(
|
|
50601
|
+
if (!fs18.existsSync(pidFile)) return null;
|
|
50602
|
+
const pid = parseInt(fs18.readFileSync(pidFile, "utf-8").trim(), 10);
|
|
49838
50603
|
return Number.isFinite(pid) ? pid : null;
|
|
49839
50604
|
} catch {
|
|
49840
50605
|
return null;
|
|
49841
50606
|
}
|
|
49842
50607
|
}
|
|
49843
|
-
function stopDaemon() {
|
|
49844
|
-
const pidFile = getDaemonPidFile();
|
|
50608
|
+
function stopDaemon(ref = {}) {
|
|
50609
|
+
const pidFile = getDaemonPidFile(ref);
|
|
49845
50610
|
try {
|
|
49846
|
-
if (!
|
|
49847
|
-
const pid = parseInt(
|
|
50611
|
+
if (!fs18.existsSync(pidFile)) return false;
|
|
50612
|
+
const pid = parseInt(fs18.readFileSync(pidFile, "utf-8").trim());
|
|
49848
50613
|
process.kill(pid, "SIGTERM");
|
|
49849
|
-
removeDaemonPid();
|
|
50614
|
+
removeDaemonPid(ref);
|
|
49850
50615
|
return true;
|
|
49851
50616
|
} catch {
|
|
49852
|
-
removeDaemonPid();
|
|
50617
|
+
removeDaemonPid(ref);
|
|
49853
50618
|
return false;
|
|
49854
50619
|
}
|
|
49855
50620
|
}
|
|
49856
|
-
var
|
|
50621
|
+
var os24, fs18, path27, import_http, import_ws3, import_chalk2, pkgVersion, ACTIVE_CHAT_POLL_STATUSES, AdhdevDaemon;
|
|
49857
50622
|
var init_adhdev_daemon = __esm({
|
|
49858
50623
|
"src/adhdev-daemon.ts"() {
|
|
49859
50624
|
"use strict";
|
|
@@ -49862,16 +50627,17 @@ var init_adhdev_daemon = __esm({
|
|
|
49862
50627
|
init_daemon_p2p2();
|
|
49863
50628
|
init_screenshot_controller();
|
|
49864
50629
|
init_session_host();
|
|
50630
|
+
init_startup_restore_policy();
|
|
49865
50631
|
init_dist();
|
|
49866
50632
|
init_session_host_controller();
|
|
49867
|
-
|
|
49868
|
-
|
|
49869
|
-
|
|
50633
|
+
os24 = __toESM(require("os"));
|
|
50634
|
+
fs18 = __toESM(require("fs"));
|
|
50635
|
+
path27 = __toESM(require("path"));
|
|
49870
50636
|
import_http = require("http");
|
|
49871
50637
|
import_ws3 = require("ws");
|
|
49872
50638
|
import_chalk2 = __toESM(require("chalk"));
|
|
49873
50639
|
init_version();
|
|
49874
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
50640
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.54" });
|
|
49875
50641
|
ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
|
|
49876
50642
|
"generating",
|
|
49877
50643
|
"waiting_approval",
|
|
@@ -50300,13 +51066,13 @@ ${err?.stack || ""}`);
|
|
|
50300
51066
|
const workingDir = options.workingDir || process.cwd();
|
|
50301
51067
|
let pidWritten = false;
|
|
50302
51068
|
try {
|
|
50303
|
-
if (isDaemonRunning()) {
|
|
51069
|
+
if (isDaemonRunning({ port: this.localPort })) {
|
|
50304
51070
|
console.log(import_chalk2.default.yellow("\n\u26A0 ADHDev Daemon is already running."));
|
|
50305
51071
|
console.log(import_chalk2.default.gray(` Stop with: adhdev daemon:stop
|
|
50306
51072
|
`));
|
|
50307
51073
|
return;
|
|
50308
51074
|
}
|
|
50309
|
-
writeDaemonPid(process.pid);
|
|
51075
|
+
writeDaemonPid(process.pid, { port: this.localPort });
|
|
50310
51076
|
pidWritten = true;
|
|
50311
51077
|
const config2 = loadConfig();
|
|
50312
51078
|
const authToken = config2.machineSecret;
|
|
@@ -50340,6 +51106,7 @@ ${err?.stack || ""}`);
|
|
|
50340
51106
|
}),
|
|
50341
51107
|
onStatusChange: () => this.statusReporter?.onStatusChange(),
|
|
50342
51108
|
removeAgentTracking: (key) => this.statusReporter?.removeAgentTracking(key),
|
|
51109
|
+
hostedRuntimeManagerTag: "adhdev-cloud",
|
|
50343
51110
|
createPtyTransportFactory: ({ runtimeId, providerType, workspace, cliArgs, providerSessionId, attachExisting }) => new SessionHostPtyTransportFactory({
|
|
50344
51111
|
endpoint: sessionHostEndpoint,
|
|
50345
51112
|
ensureReady: async () => {
|
|
@@ -50350,12 +51117,13 @@ ${err?.stack || ""}`);
|
|
|
50350
51117
|
runtimeId,
|
|
50351
51118
|
providerType,
|
|
50352
51119
|
workspace,
|
|
51120
|
+
attachExisting,
|
|
50353
51121
|
appName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev",
|
|
50354
51122
|
meta: {
|
|
50355
51123
|
cliArgs,
|
|
50356
|
-
providerSessionId
|
|
50357
|
-
|
|
50358
|
-
|
|
51124
|
+
providerSessionId,
|
|
51125
|
+
managedBy: "adhdev-cloud"
|
|
51126
|
+
}
|
|
50359
51127
|
}),
|
|
50360
51128
|
listHostedCliRuntimes: async () => listHostedCliRuntimes2(sessionHostEndpoint)
|
|
50361
51129
|
},
|
|
@@ -50377,7 +51145,9 @@ ${err?.stack || ""}`);
|
|
|
50377
51145
|
forwardAgentStreamsToIdeInstance(this.components.instanceManager, ideType, streams);
|
|
50378
51146
|
}
|
|
50379
51147
|
});
|
|
50380
|
-
|
|
51148
|
+
if (shouldAutoRestoreHostedSessionsOnStartup(process.env)) {
|
|
51149
|
+
await this.components.cliManager.restoreHostedSessions();
|
|
51150
|
+
}
|
|
50381
51151
|
this.components.providerLoader.fetchLatest().then(({ updated }) => {
|
|
50382
51152
|
if (updated) {
|
|
50383
51153
|
this.components.providerLoader.reload();
|
|
@@ -50393,8 +51163,8 @@ ${err?.stack || ""}`);
|
|
|
50393
51163
|
cliInfo: {
|
|
50394
51164
|
type: "adhdev-daemon",
|
|
50395
51165
|
version: pkgVersion,
|
|
50396
|
-
platform:
|
|
50397
|
-
hostname:
|
|
51166
|
+
platform: os24.platform(),
|
|
51167
|
+
hostname: os24.hostname(),
|
|
50398
51168
|
machineId: config2.machineId,
|
|
50399
51169
|
instanceId
|
|
50400
51170
|
}
|
|
@@ -50547,7 +51317,7 @@ ${err?.stack || ""}`);
|
|
|
50547
51317
|
}
|
|
50548
51318
|
} catch (error48) {
|
|
50549
51319
|
if (!this.running && pidWritten) {
|
|
50550
|
-
removeDaemonPid();
|
|
51320
|
+
removeDaemonPid({ port: this.localPort });
|
|
50551
51321
|
}
|
|
50552
51322
|
throw error48;
|
|
50553
51323
|
}
|
|
@@ -50857,6 +51627,18 @@ ${err?.stack || ""}`);
|
|
|
50857
51627
|
* Daemon cleanup (release all resources)
|
|
50858
51628
|
* @param exitProcess If true, exit after cleanup process.exit(0), if false, cleanup only
|
|
50859
51629
|
*/
|
|
51630
|
+
async stopManagedSessionHost() {
|
|
51631
|
+
try {
|
|
51632
|
+
await this.sessionHostController?.stop();
|
|
51633
|
+
} catch {
|
|
51634
|
+
} finally {
|
|
51635
|
+
this.sessionHostController = null;
|
|
51636
|
+
}
|
|
51637
|
+
try {
|
|
51638
|
+
stopManagedSessionHostProcess();
|
|
51639
|
+
} catch {
|
|
51640
|
+
}
|
|
51641
|
+
}
|
|
50860
51642
|
async stop(exitProcess = true) {
|
|
50861
51643
|
if (!this.running) return;
|
|
50862
51644
|
this.running = false;
|
|
@@ -50884,11 +51666,7 @@ ${err?.stack || ""}`);
|
|
|
50884
51666
|
this.serverConn?.disconnect();
|
|
50885
51667
|
} catch {
|
|
50886
51668
|
}
|
|
50887
|
-
|
|
50888
|
-
await this.sessionHostController?.stop();
|
|
50889
|
-
this.sessionHostController = null;
|
|
50890
|
-
} catch {
|
|
50891
|
-
}
|
|
51669
|
+
await this.stopManagedSessionHost();
|
|
50892
51670
|
try {
|
|
50893
51671
|
for (const client of this.localClients) {
|
|
50894
51672
|
client.close();
|
|
@@ -50906,7 +51684,7 @@ ${err?.stack || ""}`);
|
|
|
50906
51684
|
});
|
|
50907
51685
|
} catch {
|
|
50908
51686
|
}
|
|
50909
|
-
removeDaemonPid();
|
|
51687
|
+
removeDaemonPid({ port: this.localPort });
|
|
50910
51688
|
console.log(import_chalk2.default.green(" \u2713 ADHDev Daemon stopped.\n"));
|
|
50911
51689
|
if (exitProcess) {
|
|
50912
51690
|
process.exit(0);
|
|
@@ -51098,15 +51876,15 @@ async function loginFlow() {
|
|
|
51098
51876
|
let verificationUrl;
|
|
51099
51877
|
try {
|
|
51100
51878
|
const config2 = loadConfig();
|
|
51101
|
-
const
|
|
51879
|
+
const os25 = await import("os");
|
|
51102
51880
|
const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
|
|
51103
51881
|
method: "POST",
|
|
51104
51882
|
headers: { "Content-Type": "application/json" },
|
|
51105
51883
|
body: JSON.stringify({
|
|
51106
51884
|
clientMachineId: config2.machineId,
|
|
51107
|
-
hostname:
|
|
51108
|
-
platform:
|
|
51109
|
-
arch:
|
|
51885
|
+
hostname: os25.hostname(),
|
|
51886
|
+
platform: os25.platform(),
|
|
51887
|
+
arch: os25.arch()
|
|
51110
51888
|
})
|
|
51111
51889
|
});
|
|
51112
51890
|
if (!res.ok) {
|
|
@@ -51211,8 +51989,8 @@ async function startDaemonFlow() {
|
|
|
51211
51989
|
const { execSync: execSync7 } = await import("child_process");
|
|
51212
51990
|
const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
51213
51991
|
const logPath = getCurrentDaemonLogPath2();
|
|
51214
|
-
const
|
|
51215
|
-
const platform12 =
|
|
51992
|
+
const os25 = await import("os");
|
|
51993
|
+
const platform12 = os25.platform();
|
|
51216
51994
|
try {
|
|
51217
51995
|
if (platform12 === "win32") {
|
|
51218
51996
|
execSync7("start /B adhdev daemon >NUL 2>&1", {
|