adhdev 0.8.65 → 0.8.66
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 +815 -517
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +791 -493
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -3674,38 +3674,37 @@ function buildPersistedProviderEffectMessage(effect) {
|
|
|
3674
3674
|
return null;
|
|
3675
3675
|
}
|
|
3676
3676
|
function normalizeControlListResult(data) {
|
|
3677
|
-
if (data
|
|
3678
|
-
|
|
3679
|
-
options: normalizeControlOptions(data.options),
|
|
3680
|
-
...isScalarControlValue(data.currentValue) ? { currentValue: data.currentValue } : {},
|
|
3681
|
-
...typeof data.error === "string" ? { error: data.error } : {}
|
|
3682
|
-
};
|
|
3677
|
+
if (!data || typeof data !== "object" || !Array.isArray(data.options)) {
|
|
3678
|
+
throw new Error("Provider control list results must use the typed shape { options, currentValue?, error? }");
|
|
3683
3679
|
}
|
|
3684
|
-
const rawOptions = Array.isArray(data?.models) ? data.models : Array.isArray(data?.modes) ? data.modes : Array.isArray(data?.options) ? data.options : [];
|
|
3685
|
-
const options = normalizeControlOptions(rawOptions);
|
|
3686
3680
|
return {
|
|
3687
|
-
options,
|
|
3688
|
-
...isScalarControlValue(data
|
|
3689
|
-
...
|
|
3690
|
-
...typeof data?.error === "string" ? { error: data.error } : {}
|
|
3681
|
+
options: normalizeControlOptions(data.options),
|
|
3682
|
+
...isScalarControlValue(data.currentValue) ? { currentValue: data.currentValue } : {},
|
|
3683
|
+
...typeof data.error === "string" ? { error: data.error } : {}
|
|
3691
3684
|
};
|
|
3692
3685
|
}
|
|
3693
3686
|
function normalizeControlSetResult(data) {
|
|
3694
|
-
|
|
3687
|
+
if (!data || typeof data !== "object" || typeof data.ok !== "boolean") {
|
|
3688
|
+
throw new Error("Provider control set results must use the typed shape { ok, currentValue?, effects?, error? }");
|
|
3689
|
+
}
|
|
3690
|
+
const currentValue = isScalarControlValue(data.currentValue) ? data.currentValue : isScalarControlValue(data.value) ? data.value : void 0;
|
|
3695
3691
|
return {
|
|
3696
|
-
ok: data
|
|
3692
|
+
ok: data.ok,
|
|
3697
3693
|
...currentValue !== void 0 ? { currentValue } : {},
|
|
3698
|
-
...Array.isArray(data
|
|
3699
|
-
...typeof data
|
|
3694
|
+
...Array.isArray(data.effects) ? { effects: normalizeProviderEffects(data) } : {},
|
|
3695
|
+
...typeof data.error === "string" ? { error: data.error } : {}
|
|
3700
3696
|
};
|
|
3701
3697
|
}
|
|
3702
3698
|
function normalizeControlInvokeResult(data) {
|
|
3703
|
-
|
|
3699
|
+
if (!data || typeof data !== "object" || typeof data.ok !== "boolean") {
|
|
3700
|
+
throw new Error("Provider control invoke results must use the typed shape { ok, currentValue?, effects?, error? }");
|
|
3701
|
+
}
|
|
3702
|
+
const currentValue = isScalarControlValue(data.currentValue) ? data.currentValue : isScalarControlValue(data.value) ? data.value : void 0;
|
|
3704
3703
|
return {
|
|
3705
|
-
ok: data
|
|
3704
|
+
ok: data.ok,
|
|
3706
3705
|
...currentValue !== void 0 ? { currentValue } : {},
|
|
3707
|
-
...Array.isArray(data
|
|
3708
|
-
...typeof data
|
|
3706
|
+
...Array.isArray(data.effects) ? { effects: normalizeProviderEffects(data) } : {},
|
|
3707
|
+
...typeof data.error === "string" ? { error: data.error } : {}
|
|
3709
3708
|
};
|
|
3710
3709
|
}
|
|
3711
3710
|
function normalizeControlOptions(options) {
|
|
@@ -4625,19 +4624,37 @@ var init_extension_provider_instance = __esm({
|
|
|
4625
4624
|
);
|
|
4626
4625
|
}
|
|
4627
4626
|
}
|
|
4627
|
+
buildSyntheticTurnKey(message, occurrence) {
|
|
4628
|
+
const role = typeof message?.role === "string" ? message.role : "";
|
|
4629
|
+
const kind = typeof message?.kind === "string" ? message.kind : "";
|
|
4630
|
+
const senderName = typeof message?.senderName === "string" ? message.senderName : "";
|
|
4631
|
+
const content = flattenContent(message?.content).replace(/\s+/g, " ").trim().slice(0, 500);
|
|
4632
|
+
return `${role}|${kind}|${senderName}|${content}|${occurrence}`;
|
|
4633
|
+
}
|
|
4628
4634
|
/**
|
|
4629
|
-
* Assign stable receivedAt to extension messages.
|
|
4630
|
-
* Same
|
|
4631
|
-
*
|
|
4635
|
+
* Assign stable receivedAt / synthetic _turnKey to extension messages.
|
|
4636
|
+
* Same transcript should keep the same identity across polling cycles and
|
|
4637
|
+
* stream resets, while repeated identical text later in the transcript still
|
|
4638
|
+
* produces a distinct completion marker via the occurrence suffix.
|
|
4632
4639
|
*/
|
|
4633
4640
|
assignReceivedAt(messages) {
|
|
4634
4641
|
const now = Date.now();
|
|
4635
4642
|
const nextHashes = /* @__PURE__ */ new Map();
|
|
4643
|
+
const occurrenceByBaseKey = /* @__PURE__ */ new Map();
|
|
4636
4644
|
for (const msg of messages) {
|
|
4637
|
-
const
|
|
4638
|
-
const
|
|
4645
|
+
const explicitTurnKey = typeof msg?._turnKey === "string" && msg._turnKey.trim() ? msg._turnKey.trim() : "";
|
|
4646
|
+
const explicitId = typeof msg?.id === "string" && msg.id.trim() ? `id:${msg.id.trim()}` : "";
|
|
4647
|
+
const explicitIndex = typeof msg?.index === "number" && Number.isFinite(msg.index) ? `idx:${msg.index}` : "";
|
|
4648
|
+
const baseKey = explicitTurnKey || explicitId || explicitIndex || `${msg?.role || ""}:${flattenContent(msg?.content || "").slice(0, 500)}`;
|
|
4649
|
+
const occurrence = (occurrenceByBaseKey.get(baseKey) || 0) + 1;
|
|
4650
|
+
occurrenceByBaseKey.set(baseKey, occurrence);
|
|
4651
|
+
const syntheticTurnKey = explicitTurnKey || explicitId || explicitIndex || this.buildSyntheticTurnKey(msg, occurrence);
|
|
4652
|
+
if (!explicitTurnKey && !explicitId && !explicitIndex) {
|
|
4653
|
+
msg._turnKey = syntheticTurnKey;
|
|
4654
|
+
}
|
|
4655
|
+
const prevTime = this.prevMessageHashes.get(syntheticTurnKey);
|
|
4639
4656
|
msg.receivedAt = prevTime || now;
|
|
4640
|
-
nextHashes.set(
|
|
4657
|
+
nextHashes.set(syntheticTurnKey, msg.receivedAt);
|
|
4641
4658
|
}
|
|
4642
4659
|
this.prevMessageHashes = nextHashes;
|
|
4643
4660
|
return normalizeChatMessages(messages);
|
|
@@ -4714,6 +4731,128 @@ ${effect.notification.body || ""}`.trim();
|
|
|
4714
4731
|
}
|
|
4715
4732
|
});
|
|
4716
4733
|
|
|
4734
|
+
// ../../oss/packages/daemon-core/src/providers/read-chat-contract.ts
|
|
4735
|
+
function isPlainObject3(value) {
|
|
4736
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
4737
|
+
}
|
|
4738
|
+
function isFiniteNumber(value) {
|
|
4739
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
4740
|
+
}
|
|
4741
|
+
function validateStatus(status, source) {
|
|
4742
|
+
if (typeof status !== "string" || !VALID_STATUSES.includes(status)) {
|
|
4743
|
+
throw new Error(`${source}: status must be one of ${VALID_STATUSES.join(", ")}`);
|
|
4744
|
+
}
|
|
4745
|
+
return status;
|
|
4746
|
+
}
|
|
4747
|
+
function validateRole(role, source, index) {
|
|
4748
|
+
if (typeof role !== "string" || !VALID_ROLES.includes(role)) {
|
|
4749
|
+
throw new Error(`${source}: messages[${index}].role must be one of ${VALID_ROLES.join(", ")}`);
|
|
4750
|
+
}
|
|
4751
|
+
return role;
|
|
4752
|
+
}
|
|
4753
|
+
function validateMessageContent(content, source, index) {
|
|
4754
|
+
if (typeof content === "string") return content;
|
|
4755
|
+
if (Array.isArray(content)) return normalizeMessageParts(content);
|
|
4756
|
+
throw new Error(`${source}: messages[${index}].content must be a string or structured content array`);
|
|
4757
|
+
}
|
|
4758
|
+
function validateMessage(message, source, index) {
|
|
4759
|
+
if (!isPlainObject3(message)) {
|
|
4760
|
+
throw new Error(`${source}: messages[${index}] must be an object`);
|
|
4761
|
+
}
|
|
4762
|
+
const normalized = {
|
|
4763
|
+
role: validateRole(message.role, source, index),
|
|
4764
|
+
content: validateMessageContent(message.content, source, index)
|
|
4765
|
+
};
|
|
4766
|
+
if (typeof message.kind === "string") normalized.kind = message.kind;
|
|
4767
|
+
if (typeof message.id === "string") normalized.id = message.id;
|
|
4768
|
+
if (isFiniteNumber(message.index)) normalized.index = message.index;
|
|
4769
|
+
if (isFiniteNumber(message.timestamp)) normalized.timestamp = message.timestamp;
|
|
4770
|
+
if (isFiniteNumber(message.receivedAt)) normalized.receivedAt = message.receivedAt;
|
|
4771
|
+
if (Array.isArray(message.toolCalls)) normalized.toolCalls = message.toolCalls;
|
|
4772
|
+
if (isPlainObject3(message.meta)) normalized.meta = message.meta;
|
|
4773
|
+
if (typeof message.senderName === "string") normalized.senderName = message.senderName;
|
|
4774
|
+
if (typeof message._type === "string") normalized._type = message._type;
|
|
4775
|
+
if (typeof message._sub === "string") normalized._sub = message._sub;
|
|
4776
|
+
return normalized;
|
|
4777
|
+
}
|
|
4778
|
+
function validateModal(activeModal, status, source) {
|
|
4779
|
+
if (activeModal == null) {
|
|
4780
|
+
if (status === "waiting_approval") {
|
|
4781
|
+
throw new Error(`${source}: waiting_approval status requires activeModal with buttons`);
|
|
4782
|
+
}
|
|
4783
|
+
return activeModal === null ? null : void 0;
|
|
4784
|
+
}
|
|
4785
|
+
if (!isPlainObject3(activeModal)) {
|
|
4786
|
+
throw new Error(`${source}: activeModal must be an object when provided`);
|
|
4787
|
+
}
|
|
4788
|
+
if (typeof activeModal.message !== "string") {
|
|
4789
|
+
throw new Error(`${source}: activeModal.message must be a string`);
|
|
4790
|
+
}
|
|
4791
|
+
if (!Array.isArray(activeModal.buttons) || activeModal.buttons.some((button) => typeof button !== "string" || !button.trim())) {
|
|
4792
|
+
throw new Error(`${source}: activeModal.buttons must be a non-empty string array`);
|
|
4793
|
+
}
|
|
4794
|
+
const normalized = {
|
|
4795
|
+
message: activeModal.message,
|
|
4796
|
+
buttons: activeModal.buttons.map((button) => button.trim())
|
|
4797
|
+
};
|
|
4798
|
+
if (isFiniteNumber(activeModal.width)) normalized.width = activeModal.width;
|
|
4799
|
+
if (isFiniteNumber(activeModal.height)) normalized.height = activeModal.height;
|
|
4800
|
+
return normalized;
|
|
4801
|
+
}
|
|
4802
|
+
function validateControlValues(controlValues, source) {
|
|
4803
|
+
if (controlValues === void 0) return void 0;
|
|
4804
|
+
if (!isPlainObject3(controlValues)) {
|
|
4805
|
+
throw new Error(`${source}: controlValues must be an object when provided`);
|
|
4806
|
+
}
|
|
4807
|
+
const normalized = {};
|
|
4808
|
+
for (const [key, value] of Object.entries(controlValues)) {
|
|
4809
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
4810
|
+
throw new Error(`${source}: controlValues.${key} must be string, number, or boolean`);
|
|
4811
|
+
}
|
|
4812
|
+
normalized[key] = value;
|
|
4813
|
+
}
|
|
4814
|
+
return normalized;
|
|
4815
|
+
}
|
|
4816
|
+
function validateReadChatResultPayload(raw, source = "read_chat") {
|
|
4817
|
+
if (!isPlainObject3(raw)) {
|
|
4818
|
+
throw new Error(`${source}: payload must be an object`);
|
|
4819
|
+
}
|
|
4820
|
+
const status = validateStatus(raw.status, source);
|
|
4821
|
+
if (!Array.isArray(raw.messages)) {
|
|
4822
|
+
throw new Error(`${source}: messages must be an array`);
|
|
4823
|
+
}
|
|
4824
|
+
const messages = raw.messages.map((message, index) => validateMessage(message, source, index));
|
|
4825
|
+
const activeModal = validateModal(raw.activeModal, status, source);
|
|
4826
|
+
const controlValues = validateControlValues(raw.controlValues, source);
|
|
4827
|
+
const normalized = {
|
|
4828
|
+
status,
|
|
4829
|
+
messages
|
|
4830
|
+
};
|
|
4831
|
+
if (activeModal !== void 0) normalized.activeModal = activeModal;
|
|
4832
|
+
if (typeof raw.id === "string") normalized.id = raw.id;
|
|
4833
|
+
if (typeof raw.title === "string") normalized.title = raw.title;
|
|
4834
|
+
if (typeof raw.agentType === "string") normalized.agentType = raw.agentType;
|
|
4835
|
+
if (typeof raw.agentName === "string") normalized.agentName = raw.agentName;
|
|
4836
|
+
if (typeof raw.extensionId === "string") normalized.extensionId = raw.extensionId;
|
|
4837
|
+
if (typeof raw.inputContent === "string") normalized.inputContent = raw.inputContent;
|
|
4838
|
+
if (typeof raw.isVisible === "boolean") normalized.isVisible = raw.isVisible;
|
|
4839
|
+
if (typeof raw.isWelcomeScreen === "boolean") normalized.isWelcomeScreen = raw.isWelcomeScreen;
|
|
4840
|
+
if (controlValues) normalized.controlValues = controlValues;
|
|
4841
|
+
if (raw.summaryMetadata !== void 0) normalized.summaryMetadata = raw.summaryMetadata;
|
|
4842
|
+
if (Array.isArray(raw.effects)) normalized.effects = raw.effects;
|
|
4843
|
+
if (typeof raw.providerSessionId === "string") normalized.providerSessionId = raw.providerSessionId;
|
|
4844
|
+
return normalized;
|
|
4845
|
+
}
|
|
4846
|
+
var VALID_STATUSES, VALID_ROLES;
|
|
4847
|
+
var init_read_chat_contract = __esm({
|
|
4848
|
+
"../../oss/packages/daemon-core/src/providers/read-chat-contract.ts"() {
|
|
4849
|
+
"use strict";
|
|
4850
|
+
init_contracts();
|
|
4851
|
+
VALID_STATUSES = ["idle", "generating", "waiting_approval", "error", "panel_hidden", "streaming", "long_generating"];
|
|
4852
|
+
VALID_ROLES = ["user", "assistant", "system", "human"];
|
|
4853
|
+
}
|
|
4854
|
+
});
|
|
4855
|
+
|
|
4717
4856
|
// ../../oss/packages/daemon-core/src/providers/approval-utils.ts
|
|
4718
4857
|
function normalizeApprovalLabel(value) {
|
|
4719
4858
|
return String(value || "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
@@ -4779,6 +4918,7 @@ var init_ide_provider_instance = __esm({
|
|
|
4779
4918
|
init_chat_history();
|
|
4780
4919
|
init_logger();
|
|
4781
4920
|
init_control_effects();
|
|
4921
|
+
init_read_chat_contract();
|
|
4782
4922
|
init_approval_utils();
|
|
4783
4923
|
init_provider_patch_state();
|
|
4784
4924
|
init_chat_message_normalization();
|
|
@@ -5013,7 +5153,7 @@ var init_ide_provider_instance = __esm({
|
|
|
5013
5153
|
}
|
|
5014
5154
|
}
|
|
5015
5155
|
if (!raw || typeof raw !== "object") return;
|
|
5016
|
-
const chat = raw;
|
|
5156
|
+
const chat = validateReadChatResultPayload(raw, `${this.type} readChat`);
|
|
5017
5157
|
let { activeModal } = chat;
|
|
5018
5158
|
if (activeModal) {
|
|
5019
5159
|
const w = activeModal.width ?? Infinity;
|
|
@@ -6200,6 +6340,67 @@ var init_reconcile = __esm({
|
|
|
6200
6340
|
}
|
|
6201
6341
|
});
|
|
6202
6342
|
|
|
6343
|
+
// ../../oss/packages/daemon-core/src/providers/provider-input-support.ts
|
|
6344
|
+
function getProviderLabel(provider) {
|
|
6345
|
+
return provider?.name || provider?.type || "This provider";
|
|
6346
|
+
}
|
|
6347
|
+
function hasNonEmptyFallbackText(input) {
|
|
6348
|
+
return typeof input.textFallback === "string" && input.textFallback.trim().length > 0;
|
|
6349
|
+
}
|
|
6350
|
+
function getRequestedInputMediaTypes(input) {
|
|
6351
|
+
const types = /* @__PURE__ */ new Set();
|
|
6352
|
+
if (hasNonEmptyFallbackText(input) && !input.parts.some((part) => part.type === "text")) {
|
|
6353
|
+
types.add("text");
|
|
6354
|
+
}
|
|
6355
|
+
for (const part of input.parts) {
|
|
6356
|
+
if (VALID_INPUT_MEDIA_TYPES.has(part.type)) {
|
|
6357
|
+
types.add(part.type);
|
|
6358
|
+
}
|
|
6359
|
+
}
|
|
6360
|
+
return Array.from(types);
|
|
6361
|
+
}
|
|
6362
|
+
function getEffectiveSemanticPartCount(input) {
|
|
6363
|
+
let count = input.parts.length;
|
|
6364
|
+
if (hasNonEmptyFallbackText(input) && !input.parts.some((part) => part.type === "text")) {
|
|
6365
|
+
count += 1;
|
|
6366
|
+
}
|
|
6367
|
+
return count;
|
|
6368
|
+
}
|
|
6369
|
+
function assertTextOnlyInput(provider, input) {
|
|
6370
|
+
const unsupported = getRequestedInputMediaTypes(input).filter((type) => type !== "text");
|
|
6371
|
+
if (unsupported.length === 0) return;
|
|
6372
|
+
const label = getProviderLabel(provider);
|
|
6373
|
+
const suffix = unsupported.length === 1 ? "" : "s";
|
|
6374
|
+
throw new Error(`${label} only supports text input; unsupported input type${suffix}: ${unsupported.join(", ")}`);
|
|
6375
|
+
}
|
|
6376
|
+
function getDeclaredProviderInputSupport(provider) {
|
|
6377
|
+
const rawMediaTypes = Array.isArray(provider?.capabilities?.input?.mediaTypes) ? provider?.capabilities?.input?.mediaTypes.filter((type) => VALID_INPUT_MEDIA_TYPES.has(type)) : [];
|
|
6378
|
+
return {
|
|
6379
|
+
multipart: provider?.capabilities?.input?.multipart === true,
|
|
6380
|
+
mediaTypes: new Set(rawMediaTypes.length > 0 ? rawMediaTypes : ["text"])
|
|
6381
|
+
};
|
|
6382
|
+
}
|
|
6383
|
+
function assertProviderSupportsDeclaredInput(provider, input) {
|
|
6384
|
+
const label = getProviderLabel(provider);
|
|
6385
|
+
const support = getDeclaredProviderInputSupport(provider);
|
|
6386
|
+
const requestedTypes = getRequestedInputMediaTypes(input);
|
|
6387
|
+
const unsupported = requestedTypes.filter((type) => !support.mediaTypes.has(type));
|
|
6388
|
+
if (unsupported.length > 0) {
|
|
6389
|
+
const suffix = unsupported.length === 1 ? "" : "s";
|
|
6390
|
+
throw new Error(`${label} does not support input type${suffix}: ${unsupported.join(", ")}`);
|
|
6391
|
+
}
|
|
6392
|
+
if (getEffectiveSemanticPartCount(input) > 1 && !support.multipart) {
|
|
6393
|
+
throw new Error(`${label} does not support multipart input`);
|
|
6394
|
+
}
|
|
6395
|
+
}
|
|
6396
|
+
var VALID_INPUT_MEDIA_TYPES;
|
|
6397
|
+
var init_provider_input_support = __esm({
|
|
6398
|
+
"../../oss/packages/daemon-core/src/providers/provider-input-support.ts"() {
|
|
6399
|
+
"use strict";
|
|
6400
|
+
VALID_INPUT_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
|
|
6401
|
+
}
|
|
6402
|
+
});
|
|
6403
|
+
|
|
6203
6404
|
// ../../oss/packages/daemon-core/src/logging/debug-config.ts
|
|
6204
6405
|
function normalizeCategories(categories) {
|
|
6205
6406
|
if (!Array.isArray(categories)) return [];
|
|
@@ -6389,10 +6590,15 @@ function isCliLikeTransport(transport) {
|
|
|
6389
6590
|
function isExtensionTransport(transport) {
|
|
6390
6591
|
return transport === "cdp-webview";
|
|
6391
6592
|
}
|
|
6392
|
-
function buildRecentSendKey(h, args, provider,
|
|
6593
|
+
function buildRecentSendKey(h, args, provider, signature) {
|
|
6393
6594
|
const transport = getTargetTransport(h, provider) || "unknown";
|
|
6394
6595
|
const target = args?.targetSessionId || args?.agentType || h.currentSession?.providerType || h.currentProviderType || h.currentManagerKey || "unknown";
|
|
6395
|
-
return `${transport}:${target}:${
|
|
6596
|
+
return `${transport}:${target}:${signature.trim()}`;
|
|
6597
|
+
}
|
|
6598
|
+
function buildSendInputSignature(input) {
|
|
6599
|
+
const text = typeof input.textFallback === "string" ? input.textFallback.trim() : "";
|
|
6600
|
+
if (text) return text;
|
|
6601
|
+
return JSON.stringify(input.parts || []);
|
|
6396
6602
|
}
|
|
6397
6603
|
function getSendChatInputEnvelope(args) {
|
|
6398
6604
|
return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
@@ -6545,14 +6751,20 @@ function computeReadChatSync(messages, cursor) {
|
|
|
6545
6751
|
};
|
|
6546
6752
|
}
|
|
6547
6753
|
function buildReadChatCommandResult(payload, args) {
|
|
6548
|
-
|
|
6754
|
+
let validatedPayload;
|
|
6755
|
+
try {
|
|
6756
|
+
validatedPayload = validateReadChatResultPayload(payload, "read_chat command result");
|
|
6757
|
+
} catch (error48) {
|
|
6758
|
+
return { success: false, error: error48?.message || String(error48) };
|
|
6759
|
+
}
|
|
6760
|
+
const messages = normalizeReadChatMessages(validatedPayload);
|
|
6549
6761
|
const cursor = normalizeReadChatCursor(args);
|
|
6550
6762
|
if (!cursor.knownMessageCount && !cursor.lastMessageSignature && cursor.tailLimit > 0 && messages.length > cursor.tailLimit) {
|
|
6551
6763
|
const tailMessages = messages.slice(-cursor.tailLimit);
|
|
6552
6764
|
const lastMessageSignature = getChatMessageSignature(tailMessages[tailMessages.length - 1]);
|
|
6553
6765
|
return {
|
|
6554
6766
|
success: true,
|
|
6555
|
-
...
|
|
6767
|
+
...validatedPayload,
|
|
6556
6768
|
messages: tailMessages,
|
|
6557
6769
|
syncMode: "full",
|
|
6558
6770
|
replaceFrom: 0,
|
|
@@ -6563,7 +6775,7 @@ function buildReadChatCommandResult(payload, args) {
|
|
|
6563
6775
|
const sync = computeReadChatSync(messages, cursor);
|
|
6564
6776
|
return {
|
|
6565
6777
|
success: true,
|
|
6566
|
-
...
|
|
6778
|
+
...validatedPayload,
|
|
6567
6779
|
messages: sync.messages,
|
|
6568
6780
|
syncMode: sync.syncMode,
|
|
6569
6781
|
replaceFrom: sync.replaceFrom,
|
|
@@ -6642,12 +6854,18 @@ async function handleReadChat(h, args) {
|
|
|
6642
6854
|
const adapter = getTargetedCliAdapter(h, args, provider?.type);
|
|
6643
6855
|
if (adapter) {
|
|
6644
6856
|
_log(`${transport} adapter: ${adapter.cliType}`);
|
|
6645
|
-
const
|
|
6857
|
+
const parsedStatus = typeof adapter.getScriptParsedStatus === "function" ? parseMaybeJson(adapter.getScriptParsedStatus()) : null;
|
|
6858
|
+
const parsedRecord = parsedStatus && typeof parsedStatus === "object" ? parsedStatus : null;
|
|
6859
|
+
const status = parsedRecord || adapter.getStatus();
|
|
6860
|
+
const title = typeof parsedRecord?.title === "string" ? parsedRecord.title : void 0;
|
|
6861
|
+
const providerSessionId = typeof parsedRecord?.providerSessionId === "string" ? parsedRecord.providerSessionId : void 0;
|
|
6646
6862
|
if (status) {
|
|
6647
6863
|
return buildReadChatCommandResult({
|
|
6648
6864
|
messages: status.messages || [],
|
|
6649
6865
|
status: status.status,
|
|
6650
|
-
activeModal: status.activeModal
|
|
6866
|
+
activeModal: status.activeModal,
|
|
6867
|
+
...title ? { title } : {},
|
|
6868
|
+
...providerSessionId ? { providerSessionId } : {}
|
|
6651
6869
|
}, args);
|
|
6652
6870
|
}
|
|
6653
6871
|
}
|
|
@@ -6665,25 +6883,26 @@ async function handleReadChat(h, args) {
|
|
|
6665
6883
|
}
|
|
6666
6884
|
}
|
|
6667
6885
|
if (parsed && typeof parsed === "object") {
|
|
6668
|
-
|
|
6886
|
+
const validated = validateReadChatResultPayload(parsed, "extension read_chat");
|
|
6887
|
+
_log(`Extension OK: ${validated.messages?.length || 0} msgs`);
|
|
6669
6888
|
traceProviderEvent(args, "provider", "extension.read_chat.success", {
|
|
6670
6889
|
h,
|
|
6671
6890
|
provider,
|
|
6672
6891
|
payload: {
|
|
6673
6892
|
method: "evaluateProviderScript",
|
|
6674
6893
|
result: evalResult.result,
|
|
6675
|
-
parsed,
|
|
6676
|
-
messageCount: Array.isArray(
|
|
6894
|
+
parsed: validated,
|
|
6895
|
+
messageCount: Array.isArray(validated.messages) ? validated.messages.length : 0
|
|
6677
6896
|
}
|
|
6678
6897
|
});
|
|
6679
6898
|
h.historyWriter.appendNewMessages(
|
|
6680
6899
|
provider?.type || "unknown_extension",
|
|
6681
|
-
toHistoryPersistedMessages(normalizeReadChatMessages(
|
|
6682
|
-
|
|
6900
|
+
toHistoryPersistedMessages(normalizeReadChatMessages(validated)),
|
|
6901
|
+
validated.title,
|
|
6683
6902
|
args?.targetSessionId,
|
|
6684
6903
|
historySessionId
|
|
6685
6904
|
);
|
|
6686
|
-
return buildReadChatCommandResult(
|
|
6905
|
+
return buildReadChatCommandResult(validated, args);
|
|
6687
6906
|
}
|
|
6688
6907
|
}
|
|
6689
6908
|
} catch (e) {
|
|
@@ -6738,15 +6957,16 @@ async function handleReadChat(h, args) {
|
|
|
6738
6957
|
}
|
|
6739
6958
|
}
|
|
6740
6959
|
if (parsed && typeof parsed === "object") {
|
|
6741
|
-
|
|
6960
|
+
const validated = validateReadChatResultPayload(parsed, "webview read_chat");
|
|
6961
|
+
_log(`Webview OK: ${validated.messages?.length || 0} msgs`);
|
|
6742
6962
|
h.historyWriter.appendNewMessages(
|
|
6743
6963
|
provider?.type || getCurrentProviderType(h, "unknown_webview"),
|
|
6744
|
-
toHistoryPersistedMessages(normalizeReadChatMessages(
|
|
6745
|
-
|
|
6964
|
+
toHistoryPersistedMessages(normalizeReadChatMessages(validated)),
|
|
6965
|
+
validated.title,
|
|
6746
6966
|
args?.targetSessionId,
|
|
6747
6967
|
historySessionId
|
|
6748
6968
|
);
|
|
6749
|
-
return buildReadChatCommandResult(
|
|
6969
|
+
return buildReadChatCommandResult(validated, args);
|
|
6750
6970
|
}
|
|
6751
6971
|
}
|
|
6752
6972
|
} catch (e) {
|
|
@@ -6767,25 +6987,26 @@ async function handleReadChat(h, args) {
|
|
|
6767
6987
|
}
|
|
6768
6988
|
}
|
|
6769
6989
|
if (parsed && typeof parsed === "object" && parsed.messages?.length > 0) {
|
|
6770
|
-
|
|
6990
|
+
const validated = validateReadChatResultPayload(parsed, "ide read_chat");
|
|
6991
|
+
_log(`OK: ${validated.messages?.length} msgs`);
|
|
6771
6992
|
traceProviderEvent(args, "provider", "ide.read_chat.success", {
|
|
6772
6993
|
h,
|
|
6773
6994
|
provider,
|
|
6774
6995
|
payload: {
|
|
6775
6996
|
method: "evaluate",
|
|
6776
6997
|
result: evalResult.result,
|
|
6777
|
-
parsed,
|
|
6778
|
-
messageCount: Array.isArray(
|
|
6998
|
+
parsed: validated,
|
|
6999
|
+
messageCount: Array.isArray(validated.messages) ? validated.messages.length : 0
|
|
6779
7000
|
}
|
|
6780
7001
|
});
|
|
6781
7002
|
h.historyWriter.appendNewMessages(
|
|
6782
7003
|
provider?.type || getCurrentProviderType(h, "unknown_ide"),
|
|
6783
|
-
toHistoryPersistedMessages(normalizeReadChatMessages(
|
|
6784
|
-
|
|
7004
|
+
toHistoryPersistedMessages(normalizeReadChatMessages(validated)),
|
|
7005
|
+
validated.title,
|
|
6785
7006
|
args?.targetSessionId,
|
|
6786
7007
|
historySessionId
|
|
6787
7008
|
);
|
|
6788
|
-
return buildReadChatCommandResult(
|
|
7009
|
+
return buildReadChatCommandResult(validated, args);
|
|
6789
7010
|
}
|
|
6790
7011
|
}
|
|
6791
7012
|
} catch (e) {
|
|
@@ -6803,11 +7024,12 @@ async function handleReadChat(h, args) {
|
|
|
6803
7024
|
async function handleSendChat(h, args) {
|
|
6804
7025
|
const input = getSendChatInputEnvelope(args);
|
|
6805
7026
|
const text = input.textFallback;
|
|
6806
|
-
|
|
7027
|
+
const hasInput = input.parts.length > 0 || typeof text === "string" && text.trim().length > 0;
|
|
7028
|
+
if (!hasInput) return { success: false, error: "input required" };
|
|
6807
7029
|
const _log = (msg) => LOG.debug("Command", `[send_chat] ${msg}`);
|
|
6808
7030
|
const provider = h.getProvider(args?.agentType);
|
|
6809
7031
|
const transport = getTargetTransport(h, provider);
|
|
6810
|
-
const dedupeKey = buildRecentSendKey(h, args, provider,
|
|
7032
|
+
const dedupeKey = buildRecentSendKey(h, args, provider, buildSendInputSignature(input));
|
|
6811
7033
|
const _logSendSuccess = (method, targetAgent) => {
|
|
6812
7034
|
return { success: true, sent: true, method, targetAgent };
|
|
6813
7035
|
};
|
|
@@ -6815,11 +7037,26 @@ async function handleSendChat(h, args) {
|
|
|
6815
7037
|
_log(`Suppressed duplicate send for ${dedupeKey}`);
|
|
6816
7038
|
return { success: true, sent: false, deduplicated: true };
|
|
6817
7039
|
}
|
|
6818
|
-
if (
|
|
7040
|
+
if (transport === "acp") {
|
|
7041
|
+
const target = getTargetInstance(h, args);
|
|
7042
|
+
if (!target || target.category !== "acp") {
|
|
7043
|
+
return { success: false, error: `ACP instance not found for ${provider?.type || args?.agentType || "unknown"}` };
|
|
7044
|
+
}
|
|
7045
|
+
try {
|
|
7046
|
+
assertProviderSupportsDeclaredInput(provider, input);
|
|
7047
|
+
target.onEvent("send_message", { input });
|
|
7048
|
+
return _logSendSuccess("acp-instance", target.type);
|
|
7049
|
+
} catch (e) {
|
|
7050
|
+
return { success: false, error: `acp send failed: ${e.message}` };
|
|
7051
|
+
}
|
|
7052
|
+
}
|
|
7053
|
+
if (transport === "pty") {
|
|
6819
7054
|
const adapter = getTargetedCliAdapter(h, args, provider?.type);
|
|
6820
7055
|
if (adapter) {
|
|
6821
7056
|
_log(`${transport} adapter: ${adapter.cliType}`);
|
|
6822
7057
|
try {
|
|
7058
|
+
assertTextOnlyInput(provider, input);
|
|
7059
|
+
if (!text) return { success: false, error: "text required for PTY send" };
|
|
6823
7060
|
await adapter.sendMessage(text);
|
|
6824
7061
|
return _logSendSuccess(`${transport}-adapter`, adapter.cliType);
|
|
6825
7062
|
} catch (e) {
|
|
@@ -6827,6 +7064,8 @@ async function handleSendChat(h, args) {
|
|
|
6827
7064
|
}
|
|
6828
7065
|
}
|
|
6829
7066
|
}
|
|
7067
|
+
assertTextOnlyInput(provider, input);
|
|
7068
|
+
if (!text) return { success: false, error: "text required" };
|
|
6830
7069
|
if (isExtensionTransport(transport)) {
|
|
6831
7070
|
_log(`Extension: ${provider?.type || "unknown_extension"}`);
|
|
6832
7071
|
try {
|
|
@@ -7442,6 +7681,8 @@ var init_chat_commands = __esm({
|
|
|
7442
7681
|
"../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
|
|
7443
7682
|
"use strict";
|
|
7444
7683
|
init_contracts();
|
|
7684
|
+
init_provider_input_support();
|
|
7685
|
+
init_read_chat_contract();
|
|
7445
7686
|
init_chat_history();
|
|
7446
7687
|
init_logger();
|
|
7447
7688
|
init_debug_trace();
|
|
@@ -8016,14 +8257,14 @@ function normalizeProviderScriptArgs(args, scriptName) {
|
|
|
8016
8257
|
}
|
|
8017
8258
|
function buildControlScriptResult(scriptName, payload) {
|
|
8018
8259
|
if (!payload || typeof payload !== "object") return {};
|
|
8019
|
-
if (Array.isArray(payload.options)
|
|
8260
|
+
if (Array.isArray(payload.options)) {
|
|
8020
8261
|
return { controlResult: normalizeControlListResult(payload) };
|
|
8021
8262
|
}
|
|
8022
8263
|
const looksLikeValueMutation = /^set|^change/i.test(scriptName) || payload.currentValue !== void 0 || payload.value !== void 0;
|
|
8023
8264
|
if (looksLikeValueMutation) {
|
|
8024
8265
|
return { controlResult: normalizeControlSetResult(payload) };
|
|
8025
8266
|
}
|
|
8026
|
-
if (payload.ok !== void 0 ||
|
|
8267
|
+
if (payload.ok !== void 0 || Array.isArray(payload.effects) || typeof payload.error === "string") {
|
|
8027
8268
|
return { controlResult: normalizeControlInvokeResult(payload) };
|
|
8028
8269
|
}
|
|
8029
8270
|
return {};
|
|
@@ -10852,6 +11093,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
10852
11093
|
init_pty_transport();
|
|
10853
11094
|
init_provider_cli_shared();
|
|
10854
11095
|
init_chat_message_normalization();
|
|
11096
|
+
init_read_chat_contract();
|
|
10855
11097
|
init_provider_cli_parse();
|
|
10856
11098
|
init_provider_cli_config();
|
|
10857
11099
|
init_provider_cli_runtime();
|
|
@@ -11997,6 +12239,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
11997
12239
|
runtimeSettings: this.runtimeSettings
|
|
11998
12240
|
});
|
|
11999
12241
|
const parsed = this.cliScripts.parseOutput(input);
|
|
12242
|
+
if (parsed && typeof parsed === "object") {
|
|
12243
|
+
Object.assign(parsed, validateReadChatResultPayload(parsed, `${this.cliType} parseOutput`));
|
|
12244
|
+
}
|
|
12000
12245
|
const refinedStatus = this.refineDetectedStatus(typeof parsed?.status === "string" ? parsed.status : null, input.recentBuffer, input.screenText);
|
|
12001
12246
|
if (parsed && refinedStatus && parsed.status !== refinedStatus) {
|
|
12002
12247
|
parsed.status = refinedStatus;
|
|
@@ -12633,6 +12878,7 @@ var init_cli_provider_instance = __esm({
|
|
|
12633
12878
|
fs5 = __toESM(require("fs"));
|
|
12634
12879
|
import_node_module = require("module");
|
|
12635
12880
|
init_contracts();
|
|
12881
|
+
init_provider_input_support();
|
|
12636
12882
|
init_provider_cli_adapter();
|
|
12637
12883
|
init_status_monitor();
|
|
12638
12884
|
init_chat_history();
|
|
@@ -12893,6 +13139,7 @@ var init_cli_provider_instance = __esm({
|
|
|
12893
13139
|
onEvent(event, data) {
|
|
12894
13140
|
if (event === "send_message") {
|
|
12895
13141
|
const input = normalizeInputEnvelope(data);
|
|
13142
|
+
assertTextOnlyInput(this.provider, input);
|
|
12896
13143
|
if (input.textFallback) {
|
|
12897
13144
|
void this.adapter.sendMessage(input.textFallback).catch((e) => {
|
|
12898
13145
|
LOG.warn("CLI", `[${this.type}] send_message failed: ${e?.message || e}`);
|
|
@@ -13448,7 +13695,7 @@ __export(util_exports, {
|
|
|
13448
13695
|
getSizableOrigin: () => getSizableOrigin,
|
|
13449
13696
|
hexToUint8Array: () => hexToUint8Array,
|
|
13450
13697
|
isObject: () => isObject,
|
|
13451
|
-
isPlainObject: () =>
|
|
13698
|
+
isPlainObject: () => isPlainObject4,
|
|
13452
13699
|
issue: () => issue,
|
|
13453
13700
|
joinValues: () => joinValues,
|
|
13454
13701
|
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
@@ -13584,10 +13831,10 @@ function mergeDefs(...defs) {
|
|
|
13584
13831
|
function cloneDef(schema) {
|
|
13585
13832
|
return mergeDefs(schema._zod.def);
|
|
13586
13833
|
}
|
|
13587
|
-
function getElementAtPath(obj,
|
|
13588
|
-
if (!
|
|
13834
|
+
function getElementAtPath(obj, path35) {
|
|
13835
|
+
if (!path35)
|
|
13589
13836
|
return obj;
|
|
13590
|
-
return
|
|
13837
|
+
return path35.reduce((acc, key) => acc?.[key], obj);
|
|
13591
13838
|
}
|
|
13592
13839
|
function promiseAllObject(promisesObj) {
|
|
13593
13840
|
const keys = Object.keys(promisesObj);
|
|
@@ -13617,7 +13864,7 @@ function slugify(input) {
|
|
|
13617
13864
|
function isObject(data) {
|
|
13618
13865
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
13619
13866
|
}
|
|
13620
|
-
function
|
|
13867
|
+
function isPlainObject4(o) {
|
|
13621
13868
|
if (isObject(o) === false)
|
|
13622
13869
|
return false;
|
|
13623
13870
|
const ctor = o.constructor;
|
|
@@ -13634,7 +13881,7 @@ function isPlainObject3(o) {
|
|
|
13634
13881
|
return true;
|
|
13635
13882
|
}
|
|
13636
13883
|
function shallowClone(o) {
|
|
13637
|
-
if (
|
|
13884
|
+
if (isPlainObject4(o))
|
|
13638
13885
|
return { ...o };
|
|
13639
13886
|
if (Array.isArray(o))
|
|
13640
13887
|
return [...o];
|
|
@@ -13770,7 +14017,7 @@ function omit(schema, mask2) {
|
|
|
13770
14017
|
return clone(schema, def);
|
|
13771
14018
|
}
|
|
13772
14019
|
function extend(schema, shape) {
|
|
13773
|
-
if (!
|
|
14020
|
+
if (!isPlainObject4(shape)) {
|
|
13774
14021
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
13775
14022
|
}
|
|
13776
14023
|
const checks = schema._zod.def.checks;
|
|
@@ -13793,7 +14040,7 @@ function extend(schema, shape) {
|
|
|
13793
14040
|
return clone(schema, def);
|
|
13794
14041
|
}
|
|
13795
14042
|
function safeExtend(schema, shape) {
|
|
13796
|
-
if (!
|
|
14043
|
+
if (!isPlainObject4(shape)) {
|
|
13797
14044
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
13798
14045
|
}
|
|
13799
14046
|
const def = mergeDefs(schema._zod.def, {
|
|
@@ -13899,11 +14146,11 @@ function aborted(x, startIndex = 0) {
|
|
|
13899
14146
|
}
|
|
13900
14147
|
return false;
|
|
13901
14148
|
}
|
|
13902
|
-
function prefixIssues(
|
|
14149
|
+
function prefixIssues(path35, issues) {
|
|
13903
14150
|
return issues.map((iss) => {
|
|
13904
14151
|
var _a2;
|
|
13905
14152
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
13906
|
-
iss.path.unshift(
|
|
14153
|
+
iss.path.unshift(path35);
|
|
13907
14154
|
return iss;
|
|
13908
14155
|
});
|
|
13909
14156
|
}
|
|
@@ -14146,7 +14393,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
14146
14393
|
}
|
|
14147
14394
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
14148
14395
|
const result = { errors: [] };
|
|
14149
|
-
const processError = (error49,
|
|
14396
|
+
const processError = (error49, path35 = []) => {
|
|
14150
14397
|
var _a2, _b;
|
|
14151
14398
|
for (const issue2 of error49.issues) {
|
|
14152
14399
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -14156,7 +14403,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
14156
14403
|
} else if (issue2.code === "invalid_element") {
|
|
14157
14404
|
processError({ issues: issue2.issues }, issue2.path);
|
|
14158
14405
|
} else {
|
|
14159
|
-
const fullpath = [...
|
|
14406
|
+
const fullpath = [...path35, ...issue2.path];
|
|
14160
14407
|
if (fullpath.length === 0) {
|
|
14161
14408
|
result.errors.push(mapper(issue2));
|
|
14162
14409
|
continue;
|
|
@@ -14188,8 +14435,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
14188
14435
|
}
|
|
14189
14436
|
function toDotPath(_path) {
|
|
14190
14437
|
const segs = [];
|
|
14191
|
-
const
|
|
14192
|
-
for (const seg of
|
|
14438
|
+
const path35 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
14439
|
+
for (const seg of path35) {
|
|
14193
14440
|
if (typeof seg === "number")
|
|
14194
14441
|
segs.push(`[${seg}]`);
|
|
14195
14442
|
else if (typeof seg === "symbol")
|
|
@@ -15276,7 +15523,7 @@ function mergeValues(a, b) {
|
|
|
15276
15523
|
if (a instanceof Date && b instanceof Date && +a === +b) {
|
|
15277
15524
|
return { valid: true, data: a };
|
|
15278
15525
|
}
|
|
15279
|
-
if (
|
|
15526
|
+
if (isPlainObject4(a) && isPlainObject4(b)) {
|
|
15280
15527
|
const bKeys = Object.keys(b);
|
|
15281
15528
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
15282
15529
|
const newObj = { ...a, ...b };
|
|
@@ -16471,7 +16718,7 @@ var init_schemas = __esm({
|
|
|
16471
16718
|
$ZodType.init(inst, def);
|
|
16472
16719
|
inst._zod.parse = (payload, ctx) => {
|
|
16473
16720
|
const input = payload.value;
|
|
16474
|
-
if (!
|
|
16721
|
+
if (!isPlainObject4(input)) {
|
|
16475
16722
|
payload.issues.push({
|
|
16476
16723
|
expected: "record",
|
|
16477
16724
|
code: "invalid_type",
|
|
@@ -26953,13 +27200,13 @@ function resolveRef(ref, ctx) {
|
|
|
26953
27200
|
if (!ref.startsWith("#")) {
|
|
26954
27201
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
26955
27202
|
}
|
|
26956
|
-
const
|
|
26957
|
-
if (
|
|
27203
|
+
const path35 = ref.slice(1).split("/").filter(Boolean);
|
|
27204
|
+
if (path35.length === 0) {
|
|
26958
27205
|
return ctx.rootSchema;
|
|
26959
27206
|
}
|
|
26960
27207
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
26961
|
-
if (
|
|
26962
|
-
const key =
|
|
27208
|
+
if (path35[0] === defsKey) {
|
|
27209
|
+
const key = path35[1];
|
|
26963
27210
|
if (!key || !ctx.defs[key]) {
|
|
26964
27211
|
throw new Error(`Reference not found: ${ref}`);
|
|
26965
27212
|
}
|
|
@@ -29641,25 +29888,6 @@ function getPromptCapabilityFlags(agentCapabilities) {
|
|
|
29641
29888
|
embeddedContext: prompt2.embeddedContext === true
|
|
29642
29889
|
};
|
|
29643
29890
|
}
|
|
29644
|
-
function getResourceNameFromUri(uri, fallback2) {
|
|
29645
|
-
try {
|
|
29646
|
-
if (uri.startsWith("file://")) {
|
|
29647
|
-
return path13.basename(new URL(uri).pathname) || fallback2;
|
|
29648
|
-
}
|
|
29649
|
-
return path13.basename(uri) || fallback2;
|
|
29650
|
-
} catch {
|
|
29651
|
-
return fallback2;
|
|
29652
|
-
}
|
|
29653
|
-
}
|
|
29654
|
-
function inputPartToResourceLink(part, fallbackName) {
|
|
29655
|
-
if (!part.uri) return null;
|
|
29656
|
-
return {
|
|
29657
|
-
type: "resource_link",
|
|
29658
|
-
uri: part.uri,
|
|
29659
|
-
name: getResourceNameFromUri(part.uri, fallbackName),
|
|
29660
|
-
...part.mimeType ? { mimeType: part.mimeType } : {}
|
|
29661
|
-
};
|
|
29662
|
-
}
|
|
29663
29891
|
function appendPromptText(promptParts, text) {
|
|
29664
29892
|
const normalized = typeof text === "string" ? text.trim() : "";
|
|
29665
29893
|
if (!normalized) return;
|
|
@@ -29676,67 +29904,72 @@ function buildAcpPromptParts(input, agentCapabilities) {
|
|
|
29676
29904
|
continue;
|
|
29677
29905
|
}
|
|
29678
29906
|
if (part.type === "image") {
|
|
29679
|
-
if (caps.image
|
|
29680
|
-
|
|
29681
|
-
type: "image",
|
|
29682
|
-
data: part.data,
|
|
29683
|
-
mimeType: part.mimeType,
|
|
29684
|
-
...part.uri ? { uri: part.uri } : {}
|
|
29685
|
-
});
|
|
29686
|
-
continue;
|
|
29907
|
+
if (!caps.image) {
|
|
29908
|
+
throw new Error("ACP agent does not support input type: image");
|
|
29687
29909
|
}
|
|
29688
|
-
|
|
29689
|
-
|
|
29690
|
-
|
|
29910
|
+
if (!part.data) {
|
|
29911
|
+
throw new Error("ACP image input requires inline image data");
|
|
29912
|
+
}
|
|
29913
|
+
promptParts.push({
|
|
29914
|
+
type: "image",
|
|
29915
|
+
data: part.data,
|
|
29916
|
+
mimeType: part.mimeType,
|
|
29917
|
+
...part.uri ? { uri: part.uri } : {}
|
|
29918
|
+
});
|
|
29691
29919
|
continue;
|
|
29692
29920
|
}
|
|
29693
29921
|
if (part.type === "audio") {
|
|
29694
|
-
if (caps.audio
|
|
29695
|
-
|
|
29696
|
-
type: "audio",
|
|
29697
|
-
data: part.data,
|
|
29698
|
-
mimeType: part.mimeType
|
|
29699
|
-
});
|
|
29700
|
-
continue;
|
|
29922
|
+
if (!caps.audio) {
|
|
29923
|
+
throw new Error("ACP agent does not support input type: audio");
|
|
29701
29924
|
}
|
|
29702
|
-
|
|
29703
|
-
|
|
29704
|
-
|
|
29925
|
+
if (!part.data) {
|
|
29926
|
+
throw new Error("ACP audio input requires inline audio data");
|
|
29927
|
+
}
|
|
29928
|
+
promptParts.push({
|
|
29929
|
+
type: "audio",
|
|
29930
|
+
data: part.data,
|
|
29931
|
+
mimeType: part.mimeType
|
|
29932
|
+
});
|
|
29705
29933
|
continue;
|
|
29706
29934
|
}
|
|
29707
29935
|
if (part.type === "resource") {
|
|
29708
|
-
if (caps.embeddedContext
|
|
29936
|
+
if (!caps.embeddedContext) {
|
|
29937
|
+
throw new Error("ACP agent does not support input type: resource");
|
|
29938
|
+
}
|
|
29939
|
+
if (part.text) {
|
|
29709
29940
|
promptParts.push({
|
|
29710
29941
|
type: "resource",
|
|
29711
|
-
resource:
|
|
29942
|
+
resource: { uri: part.uri, text: part.text, mimeType: part.mimeType ?? null }
|
|
29712
29943
|
});
|
|
29713
29944
|
continue;
|
|
29714
29945
|
}
|
|
29715
|
-
|
|
29716
|
-
|
|
29717
|
-
|
|
29718
|
-
|
|
29946
|
+
if (part.data) {
|
|
29947
|
+
promptParts.push({
|
|
29948
|
+
type: "resource",
|
|
29949
|
+
resource: { uri: part.uri, blob: part.data, mimeType: part.mimeType ?? null }
|
|
29950
|
+
});
|
|
29951
|
+
continue;
|
|
29952
|
+
}
|
|
29953
|
+
throw new Error("ACP resource input requires embedded text or binary data");
|
|
29719
29954
|
}
|
|
29720
29955
|
if (part.type === "video") {
|
|
29721
|
-
|
|
29722
|
-
if (fallback2) promptParts.push(fallback2);
|
|
29723
|
-
appendPromptText(promptParts, !part.uri ? `Attached video (${part.mimeType})` : void 0);
|
|
29956
|
+
throw new Error("ACP agent does not support input type: video");
|
|
29724
29957
|
}
|
|
29725
29958
|
}
|
|
29726
29959
|
if (!promptParts.some((part) => part.type === "text") && input.textFallback) {
|
|
29727
|
-
promptParts
|
|
29960
|
+
appendPromptText(promptParts, input.textFallback);
|
|
29728
29961
|
}
|
|
29729
29962
|
return promptParts;
|
|
29730
29963
|
}
|
|
29731
|
-
var
|
|
29964
|
+
var import_stream, import_child_process5, AcpProviderInstance;
|
|
29732
29965
|
var init_acp_provider_instance = __esm({
|
|
29733
29966
|
"../../oss/packages/daemon-core/src/providers/acp-provider-instance.ts"() {
|
|
29734
29967
|
"use strict";
|
|
29735
|
-
path13 = __toESM(require("path"));
|
|
29736
29968
|
import_stream = require("stream");
|
|
29737
29969
|
import_child_process5 = require("child_process");
|
|
29738
29970
|
init_acp();
|
|
29739
29971
|
init_contracts();
|
|
29972
|
+
init_provider_input_support();
|
|
29740
29973
|
init_status_monitor();
|
|
29741
29974
|
init_summary_metadata();
|
|
29742
29975
|
init_chat_message_normalization();
|
|
@@ -29868,6 +30101,7 @@ var init_acp_provider_instance = __esm({
|
|
|
29868
30101
|
onEvent(event, data) {
|
|
29869
30102
|
if (event === "send_message") {
|
|
29870
30103
|
const input = normalizeInputEnvelope(data);
|
|
30104
|
+
assertProviderSupportsDeclaredInput(this.provider, input);
|
|
29871
30105
|
const promptParts = buildAcpPromptParts(input, this.agentCapabilities);
|
|
29872
30106
|
this.sendPrompt(input.textFallback, promptParts.length > 0 ? promptParts : void 0).catch(
|
|
29873
30107
|
(e) => this.log.warn(`[${this.type}] sendPrompt error: ${e?.message}`)
|
|
@@ -30927,12 +31161,12 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
30927
31161
|
launchMode: "new"
|
|
30928
31162
|
};
|
|
30929
31163
|
}
|
|
30930
|
-
var os15,
|
|
31164
|
+
var os15, path13, crypto4, chalkModule, chalkApi, DaemonCliManager;
|
|
30931
31165
|
var init_cli_manager = __esm({
|
|
30932
31166
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
30933
31167
|
"use strict";
|
|
30934
31168
|
os15 = __toESM(require("os"));
|
|
30935
|
-
|
|
31169
|
+
path13 = __toESM(require("path"));
|
|
30936
31170
|
crypto4 = __toESM(require("crypto"));
|
|
30937
31171
|
init_source2();
|
|
30938
31172
|
init_provider_cli_adapter();
|
|
@@ -30946,6 +31180,7 @@ var init_cli_manager = __esm({
|
|
|
30946
31180
|
init_cli_provider_instance();
|
|
30947
31181
|
init_acp_provider_instance();
|
|
30948
31182
|
init_contracts();
|
|
31183
|
+
init_provider_input_support();
|
|
30949
31184
|
init_logger();
|
|
30950
31185
|
init_hosted_runtime_restore();
|
|
30951
31186
|
chalkModule = source_default2;
|
|
@@ -31092,7 +31327,7 @@ var init_cli_manager = __esm({
|
|
|
31092
31327
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
31093
31328
|
const trimmed = (workingDir || "").trim();
|
|
31094
31329
|
if (!trimmed) throw new Error("working directory required");
|
|
31095
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os15.homedir()) :
|
|
31330
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os15.homedir()) : path13.resolve(trimmed);
|
|
31096
31331
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
31097
31332
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
31098
31333
|
const key = crypto4.randomUUID();
|
|
@@ -31551,6 +31786,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
31551
31786
|
const { adapter, key } = found;
|
|
31552
31787
|
if (action === "send_chat") {
|
|
31553
31788
|
const input = normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
31789
|
+
const provider = this.providerLoader.resolve(agentType) || this.providerLoader.getMeta(agentType);
|
|
31790
|
+
if (provider?.category === "acp") {
|
|
31791
|
+
assertProviderSupportsDeclaredInput(provider, input);
|
|
31792
|
+
} else {
|
|
31793
|
+
assertTextOnlyInput(provider, input);
|
|
31794
|
+
}
|
|
31554
31795
|
const message = input.textFallback;
|
|
31555
31796
|
if (!message) throw new Error("message required for send_chat");
|
|
31556
31797
|
await adapter.sendMessage(message);
|
|
@@ -31675,7 +31916,7 @@ var init_readdirp = __esm({
|
|
|
31675
31916
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
31676
31917
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
31677
31918
|
if (wantBigintFsStats) {
|
|
31678
|
-
this._stat = (
|
|
31919
|
+
this._stat = (path35) => statMethod(path35, { bigint: true });
|
|
31679
31920
|
} else {
|
|
31680
31921
|
this._stat = statMethod;
|
|
31681
31922
|
}
|
|
@@ -31700,8 +31941,8 @@ var init_readdirp = __esm({
|
|
|
31700
31941
|
const par = this.parent;
|
|
31701
31942
|
const fil = par && par.files;
|
|
31702
31943
|
if (fil && fil.length > 0) {
|
|
31703
|
-
const { path:
|
|
31704
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
31944
|
+
const { path: path35, depth } = par;
|
|
31945
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path35));
|
|
31705
31946
|
const awaited = await Promise.all(slice);
|
|
31706
31947
|
for (const entry of awaited) {
|
|
31707
31948
|
if (!entry)
|
|
@@ -31741,21 +31982,21 @@ var init_readdirp = __esm({
|
|
|
31741
31982
|
this.reading = false;
|
|
31742
31983
|
}
|
|
31743
31984
|
}
|
|
31744
|
-
async _exploreDir(
|
|
31985
|
+
async _exploreDir(path35, depth) {
|
|
31745
31986
|
let files;
|
|
31746
31987
|
try {
|
|
31747
|
-
files = await (0, import_promises.readdir)(
|
|
31988
|
+
files = await (0, import_promises.readdir)(path35, this._rdOptions);
|
|
31748
31989
|
} catch (error48) {
|
|
31749
31990
|
this._onError(error48);
|
|
31750
31991
|
}
|
|
31751
|
-
return { files, depth, path:
|
|
31992
|
+
return { files, depth, path: path35 };
|
|
31752
31993
|
}
|
|
31753
|
-
async _formatEntry(dirent,
|
|
31994
|
+
async _formatEntry(dirent, path35) {
|
|
31754
31995
|
let entry;
|
|
31755
|
-
const
|
|
31996
|
+
const basename9 = this._isDirent ? dirent.name : dirent;
|
|
31756
31997
|
try {
|
|
31757
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
31758
|
-
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename:
|
|
31998
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path35, basename9));
|
|
31999
|
+
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename9 };
|
|
31759
32000
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
31760
32001
|
} catch (err) {
|
|
31761
32002
|
this._onError(err);
|
|
@@ -31811,16 +32052,16 @@ var init_readdirp = __esm({
|
|
|
31811
32052
|
});
|
|
31812
32053
|
|
|
31813
32054
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
31814
|
-
function createFsWatchInstance(
|
|
32055
|
+
function createFsWatchInstance(path35, options, listener, errHandler, emitRaw) {
|
|
31815
32056
|
const handleEvent = (rawEvent, evPath) => {
|
|
31816
|
-
listener(
|
|
31817
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
31818
|
-
if (evPath &&
|
|
31819
|
-
fsWatchBroadcast(sp.resolve(
|
|
32057
|
+
listener(path35);
|
|
32058
|
+
emitRaw(rawEvent, evPath, { watchedPath: path35 });
|
|
32059
|
+
if (evPath && path35 !== evPath) {
|
|
32060
|
+
fsWatchBroadcast(sp.resolve(path35, evPath), KEY_LISTENERS, sp.join(path35, evPath));
|
|
31820
32061
|
}
|
|
31821
32062
|
};
|
|
31822
32063
|
try {
|
|
31823
|
-
return (0, import_node_fs.watch)(
|
|
32064
|
+
return (0, import_node_fs.watch)(path35, {
|
|
31824
32065
|
persistent: options.persistent
|
|
31825
32066
|
}, handleEvent);
|
|
31826
32067
|
} catch (error48) {
|
|
@@ -32169,12 +32410,12 @@ var init_handler2 = __esm({
|
|
|
32169
32410
|
listener(val1, val2, val3);
|
|
32170
32411
|
});
|
|
32171
32412
|
};
|
|
32172
|
-
setFsWatchListener = (
|
|
32413
|
+
setFsWatchListener = (path35, fullPath, options, handlers) => {
|
|
32173
32414
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
32174
32415
|
let cont = FsWatchInstances.get(fullPath);
|
|
32175
32416
|
let watcher;
|
|
32176
32417
|
if (!options.persistent) {
|
|
32177
|
-
watcher = createFsWatchInstance(
|
|
32418
|
+
watcher = createFsWatchInstance(path35, options, listener, errHandler, rawEmitter);
|
|
32178
32419
|
if (!watcher)
|
|
32179
32420
|
return;
|
|
32180
32421
|
return watcher.close.bind(watcher);
|
|
@@ -32185,7 +32426,7 @@ var init_handler2 = __esm({
|
|
|
32185
32426
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
32186
32427
|
} else {
|
|
32187
32428
|
watcher = createFsWatchInstance(
|
|
32188
|
-
|
|
32429
|
+
path35,
|
|
32189
32430
|
options,
|
|
32190
32431
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
32191
32432
|
errHandler,
|
|
@@ -32200,7 +32441,7 @@ var init_handler2 = __esm({
|
|
|
32200
32441
|
cont.watcherUnusable = true;
|
|
32201
32442
|
if (isWindows && error48.code === "EPERM") {
|
|
32202
32443
|
try {
|
|
32203
|
-
const fd = await (0, import_promises2.open)(
|
|
32444
|
+
const fd = await (0, import_promises2.open)(path35, "r");
|
|
32204
32445
|
await fd.close();
|
|
32205
32446
|
broadcastErr(error48);
|
|
32206
32447
|
} catch (err) {
|
|
@@ -32231,7 +32472,7 @@ var init_handler2 = __esm({
|
|
|
32231
32472
|
};
|
|
32232
32473
|
};
|
|
32233
32474
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
32234
|
-
setFsWatchFileListener = (
|
|
32475
|
+
setFsWatchFileListener = (path35, fullPath, options, handlers) => {
|
|
32235
32476
|
const { listener, rawEmitter } = handlers;
|
|
32236
32477
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
32237
32478
|
const copts = cont && cont.options;
|
|
@@ -32253,7 +32494,7 @@ var init_handler2 = __esm({
|
|
|
32253
32494
|
});
|
|
32254
32495
|
const currmtime = curr.mtimeMs;
|
|
32255
32496
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
32256
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
32497
|
+
foreach(cont.listeners, (listener2) => listener2(path35, curr));
|
|
32257
32498
|
}
|
|
32258
32499
|
})
|
|
32259
32500
|
};
|
|
@@ -32283,13 +32524,13 @@ var init_handler2 = __esm({
|
|
|
32283
32524
|
* @param listener on fs change
|
|
32284
32525
|
* @returns closer for the watcher instance
|
|
32285
32526
|
*/
|
|
32286
|
-
_watchWithNodeFs(
|
|
32527
|
+
_watchWithNodeFs(path35, listener) {
|
|
32287
32528
|
const opts = this.fsw.options;
|
|
32288
|
-
const directory = sp.dirname(
|
|
32289
|
-
const
|
|
32529
|
+
const directory = sp.dirname(path35);
|
|
32530
|
+
const basename9 = sp.basename(path35);
|
|
32290
32531
|
const parent = this.fsw._getWatchedDir(directory);
|
|
32291
|
-
parent.add(
|
|
32292
|
-
const absolutePath = sp.resolve(
|
|
32532
|
+
parent.add(basename9);
|
|
32533
|
+
const absolutePath = sp.resolve(path35);
|
|
32293
32534
|
const options = {
|
|
32294
32535
|
persistent: opts.persistent
|
|
32295
32536
|
};
|
|
@@ -32298,13 +32539,13 @@ var init_handler2 = __esm({
|
|
|
32298
32539
|
let closer;
|
|
32299
32540
|
if (opts.usePolling) {
|
|
32300
32541
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
32301
|
-
options.interval = enableBin && isBinaryPath(
|
|
32302
|
-
closer = setFsWatchFileListener(
|
|
32542
|
+
options.interval = enableBin && isBinaryPath(basename9) ? opts.binaryInterval : opts.interval;
|
|
32543
|
+
closer = setFsWatchFileListener(path35, absolutePath, options, {
|
|
32303
32544
|
listener,
|
|
32304
32545
|
rawEmitter: this.fsw._emitRaw
|
|
32305
32546
|
});
|
|
32306
32547
|
} else {
|
|
32307
|
-
closer = setFsWatchListener(
|
|
32548
|
+
closer = setFsWatchListener(path35, absolutePath, options, {
|
|
32308
32549
|
listener,
|
|
32309
32550
|
errHandler: this._boundHandleError,
|
|
32310
32551
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -32321,12 +32562,12 @@ var init_handler2 = __esm({
|
|
|
32321
32562
|
return;
|
|
32322
32563
|
}
|
|
32323
32564
|
const dirname10 = sp.dirname(file2);
|
|
32324
|
-
const
|
|
32565
|
+
const basename9 = sp.basename(file2);
|
|
32325
32566
|
const parent = this.fsw._getWatchedDir(dirname10);
|
|
32326
32567
|
let prevStats = stats;
|
|
32327
|
-
if (parent.has(
|
|
32568
|
+
if (parent.has(basename9))
|
|
32328
32569
|
return;
|
|
32329
|
-
const listener = async (
|
|
32570
|
+
const listener = async (path35, newStats) => {
|
|
32330
32571
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
32331
32572
|
return;
|
|
32332
32573
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -32340,18 +32581,18 @@ var init_handler2 = __esm({
|
|
|
32340
32581
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
32341
32582
|
}
|
|
32342
32583
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
32343
|
-
this.fsw._closeFile(
|
|
32584
|
+
this.fsw._closeFile(path35);
|
|
32344
32585
|
prevStats = newStats2;
|
|
32345
32586
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
32346
32587
|
if (closer2)
|
|
32347
|
-
this.fsw._addPathCloser(
|
|
32588
|
+
this.fsw._addPathCloser(path35, closer2);
|
|
32348
32589
|
} else {
|
|
32349
32590
|
prevStats = newStats2;
|
|
32350
32591
|
}
|
|
32351
32592
|
} catch (error48) {
|
|
32352
|
-
this.fsw._remove(dirname10,
|
|
32593
|
+
this.fsw._remove(dirname10, basename9);
|
|
32353
32594
|
}
|
|
32354
|
-
} else if (parent.has(
|
|
32595
|
+
} else if (parent.has(basename9)) {
|
|
32355
32596
|
const at = newStats.atimeMs;
|
|
32356
32597
|
const mt = newStats.mtimeMs;
|
|
32357
32598
|
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
|
@@ -32376,7 +32617,7 @@ var init_handler2 = __esm({
|
|
|
32376
32617
|
* @param item basename of this item
|
|
32377
32618
|
* @returns true if no more processing is needed for this entry.
|
|
32378
32619
|
*/
|
|
32379
|
-
async _handleSymlink(entry, directory,
|
|
32620
|
+
async _handleSymlink(entry, directory, path35, item) {
|
|
32380
32621
|
if (this.fsw.closed) {
|
|
32381
32622
|
return;
|
|
32382
32623
|
}
|
|
@@ -32386,7 +32627,7 @@ var init_handler2 = __esm({
|
|
|
32386
32627
|
this.fsw._incrReadyCount();
|
|
32387
32628
|
let linkPath;
|
|
32388
32629
|
try {
|
|
32389
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
32630
|
+
linkPath = await (0, import_promises2.realpath)(path35);
|
|
32390
32631
|
} catch (e) {
|
|
32391
32632
|
this.fsw._emitReady();
|
|
32392
32633
|
return true;
|
|
@@ -32396,12 +32637,12 @@ var init_handler2 = __esm({
|
|
|
32396
32637
|
if (dir.has(item)) {
|
|
32397
32638
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
32398
32639
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
32399
|
-
this.fsw._emit(EV.CHANGE,
|
|
32640
|
+
this.fsw._emit(EV.CHANGE, path35, entry.stats);
|
|
32400
32641
|
}
|
|
32401
32642
|
} else {
|
|
32402
32643
|
dir.add(item);
|
|
32403
32644
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
32404
|
-
this.fsw._emit(EV.ADD,
|
|
32645
|
+
this.fsw._emit(EV.ADD, path35, entry.stats);
|
|
32405
32646
|
}
|
|
32406
32647
|
this.fsw._emitReady();
|
|
32407
32648
|
return true;
|
|
@@ -32431,9 +32672,9 @@ var init_handler2 = __esm({
|
|
|
32431
32672
|
return;
|
|
32432
32673
|
}
|
|
32433
32674
|
const item = entry.path;
|
|
32434
|
-
let
|
|
32675
|
+
let path35 = sp.join(directory, item);
|
|
32435
32676
|
current.add(item);
|
|
32436
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
32677
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path35, item)) {
|
|
32437
32678
|
return;
|
|
32438
32679
|
}
|
|
32439
32680
|
if (this.fsw.closed) {
|
|
@@ -32442,8 +32683,8 @@ var init_handler2 = __esm({
|
|
|
32442
32683
|
}
|
|
32443
32684
|
if (item === target || !target && !previous.has(item)) {
|
|
32444
32685
|
this.fsw._incrReadyCount();
|
|
32445
|
-
|
|
32446
|
-
this._addToNodeFs(
|
|
32686
|
+
path35 = sp.join(dir, sp.relative(dir, path35));
|
|
32687
|
+
this._addToNodeFs(path35, initialAdd, wh, depth + 1);
|
|
32447
32688
|
}
|
|
32448
32689
|
}).on(EV.ERROR, this._boundHandleError);
|
|
32449
32690
|
return new Promise((resolve17, reject) => {
|
|
@@ -32512,13 +32753,13 @@ var init_handler2 = __esm({
|
|
|
32512
32753
|
* @param depth Child path actually targeted for watch
|
|
32513
32754
|
* @param target Child path actually targeted for watch
|
|
32514
32755
|
*/
|
|
32515
|
-
async _addToNodeFs(
|
|
32756
|
+
async _addToNodeFs(path35, initialAdd, priorWh, depth, target) {
|
|
32516
32757
|
const ready = this.fsw._emitReady;
|
|
32517
|
-
if (this.fsw._isIgnored(
|
|
32758
|
+
if (this.fsw._isIgnored(path35) || this.fsw.closed) {
|
|
32518
32759
|
ready();
|
|
32519
32760
|
return false;
|
|
32520
32761
|
}
|
|
32521
|
-
const wh = this.fsw._getWatchHelpers(
|
|
32762
|
+
const wh = this.fsw._getWatchHelpers(path35);
|
|
32522
32763
|
if (priorWh) {
|
|
32523
32764
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
32524
32765
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -32534,8 +32775,8 @@ var init_handler2 = __esm({
|
|
|
32534
32775
|
const follow = this.fsw.options.followSymlinks;
|
|
32535
32776
|
let closer;
|
|
32536
32777
|
if (stats.isDirectory()) {
|
|
32537
|
-
const absPath = sp.resolve(
|
|
32538
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
32778
|
+
const absPath = sp.resolve(path35);
|
|
32779
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path35) : path35;
|
|
32539
32780
|
if (this.fsw.closed)
|
|
32540
32781
|
return;
|
|
32541
32782
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -32545,29 +32786,29 @@ var init_handler2 = __esm({
|
|
|
32545
32786
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
32546
32787
|
}
|
|
32547
32788
|
} else if (stats.isSymbolicLink()) {
|
|
32548
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
32789
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path35) : path35;
|
|
32549
32790
|
if (this.fsw.closed)
|
|
32550
32791
|
return;
|
|
32551
32792
|
const parent = sp.dirname(wh.watchPath);
|
|
32552
32793
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
32553
32794
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
32554
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
32795
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path35, wh, targetPath);
|
|
32555
32796
|
if (this.fsw.closed)
|
|
32556
32797
|
return;
|
|
32557
32798
|
if (targetPath !== void 0) {
|
|
32558
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
32799
|
+
this.fsw._symlinkPaths.set(sp.resolve(path35), targetPath);
|
|
32559
32800
|
}
|
|
32560
32801
|
} else {
|
|
32561
32802
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
32562
32803
|
}
|
|
32563
32804
|
ready();
|
|
32564
32805
|
if (closer)
|
|
32565
|
-
this.fsw._addPathCloser(
|
|
32806
|
+
this.fsw._addPathCloser(path35, closer);
|
|
32566
32807
|
return false;
|
|
32567
32808
|
} catch (error48) {
|
|
32568
32809
|
if (this.fsw._handleError(error48)) {
|
|
32569
32810
|
ready();
|
|
32570
|
-
return
|
|
32811
|
+
return path35;
|
|
32571
32812
|
}
|
|
32572
32813
|
}
|
|
32573
32814
|
}
|
|
@@ -32602,24 +32843,24 @@ function createPattern(matcher) {
|
|
|
32602
32843
|
}
|
|
32603
32844
|
return () => false;
|
|
32604
32845
|
}
|
|
32605
|
-
function normalizePath(
|
|
32606
|
-
if (typeof
|
|
32846
|
+
function normalizePath(path35) {
|
|
32847
|
+
if (typeof path35 !== "string")
|
|
32607
32848
|
throw new Error("string expected");
|
|
32608
|
-
|
|
32609
|
-
|
|
32849
|
+
path35 = sp2.normalize(path35);
|
|
32850
|
+
path35 = path35.replace(/\\/g, "/");
|
|
32610
32851
|
let prepend = false;
|
|
32611
|
-
if (
|
|
32852
|
+
if (path35.startsWith("//"))
|
|
32612
32853
|
prepend = true;
|
|
32613
|
-
|
|
32854
|
+
path35 = path35.replace(DOUBLE_SLASH_RE, "/");
|
|
32614
32855
|
if (prepend)
|
|
32615
|
-
|
|
32616
|
-
return
|
|
32856
|
+
path35 = "/" + path35;
|
|
32857
|
+
return path35;
|
|
32617
32858
|
}
|
|
32618
32859
|
function matchPatterns(patterns, testString, stats) {
|
|
32619
|
-
const
|
|
32860
|
+
const path35 = normalizePath(testString);
|
|
32620
32861
|
for (let index = 0; index < patterns.length; index++) {
|
|
32621
32862
|
const pattern = patterns[index];
|
|
32622
|
-
if (pattern(
|
|
32863
|
+
if (pattern(path35, stats)) {
|
|
32623
32864
|
return true;
|
|
32624
32865
|
}
|
|
32625
32866
|
}
|
|
@@ -32682,19 +32923,19 @@ var init_chokidar = __esm({
|
|
|
32682
32923
|
}
|
|
32683
32924
|
return str;
|
|
32684
32925
|
};
|
|
32685
|
-
normalizePathToUnix = (
|
|
32686
|
-
normalizeIgnored = (cwd = "") => (
|
|
32687
|
-
if (typeof
|
|
32688
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
32926
|
+
normalizePathToUnix = (path35) => toUnix(sp2.normalize(toUnix(path35)));
|
|
32927
|
+
normalizeIgnored = (cwd = "") => (path35) => {
|
|
32928
|
+
if (typeof path35 === "string") {
|
|
32929
|
+
return normalizePathToUnix(sp2.isAbsolute(path35) ? path35 : sp2.join(cwd, path35));
|
|
32689
32930
|
} else {
|
|
32690
|
-
return
|
|
32931
|
+
return path35;
|
|
32691
32932
|
}
|
|
32692
32933
|
};
|
|
32693
|
-
getAbsolutePath = (
|
|
32694
|
-
if (sp2.isAbsolute(
|
|
32695
|
-
return
|
|
32934
|
+
getAbsolutePath = (path35, cwd) => {
|
|
32935
|
+
if (sp2.isAbsolute(path35)) {
|
|
32936
|
+
return path35;
|
|
32696
32937
|
}
|
|
32697
|
-
return sp2.join(cwd,
|
|
32938
|
+
return sp2.join(cwd, path35);
|
|
32698
32939
|
};
|
|
32699
32940
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
32700
32941
|
DirEntry = class {
|
|
@@ -32759,10 +33000,10 @@ var init_chokidar = __esm({
|
|
|
32759
33000
|
dirParts;
|
|
32760
33001
|
followSymlinks;
|
|
32761
33002
|
statMethod;
|
|
32762
|
-
constructor(
|
|
33003
|
+
constructor(path35, follow, fsw) {
|
|
32763
33004
|
this.fsw = fsw;
|
|
32764
|
-
const watchPath =
|
|
32765
|
-
this.path =
|
|
33005
|
+
const watchPath = path35;
|
|
33006
|
+
this.path = path35 = path35.replace(REPLACER_RE, "");
|
|
32766
33007
|
this.watchPath = watchPath;
|
|
32767
33008
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
32768
33009
|
this.dirParts = [];
|
|
@@ -32902,20 +33143,20 @@ var init_chokidar = __esm({
|
|
|
32902
33143
|
this._closePromise = void 0;
|
|
32903
33144
|
let paths = unifyPaths(paths_);
|
|
32904
33145
|
if (cwd) {
|
|
32905
|
-
paths = paths.map((
|
|
32906
|
-
const absPath = getAbsolutePath(
|
|
33146
|
+
paths = paths.map((path35) => {
|
|
33147
|
+
const absPath = getAbsolutePath(path35, cwd);
|
|
32907
33148
|
return absPath;
|
|
32908
33149
|
});
|
|
32909
33150
|
}
|
|
32910
|
-
paths.forEach((
|
|
32911
|
-
this._removeIgnoredPath(
|
|
33151
|
+
paths.forEach((path35) => {
|
|
33152
|
+
this._removeIgnoredPath(path35);
|
|
32912
33153
|
});
|
|
32913
33154
|
this._userIgnored = void 0;
|
|
32914
33155
|
if (!this._readyCount)
|
|
32915
33156
|
this._readyCount = 0;
|
|
32916
33157
|
this._readyCount += paths.length;
|
|
32917
|
-
Promise.all(paths.map(async (
|
|
32918
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
33158
|
+
Promise.all(paths.map(async (path35) => {
|
|
33159
|
+
const res = await this._nodeFsHandler._addToNodeFs(path35, !_internal, void 0, 0, _origAdd);
|
|
32919
33160
|
if (res)
|
|
32920
33161
|
this._emitReady();
|
|
32921
33162
|
return res;
|
|
@@ -32937,17 +33178,17 @@ var init_chokidar = __esm({
|
|
|
32937
33178
|
return this;
|
|
32938
33179
|
const paths = unifyPaths(paths_);
|
|
32939
33180
|
const { cwd } = this.options;
|
|
32940
|
-
paths.forEach((
|
|
32941
|
-
if (!sp2.isAbsolute(
|
|
33181
|
+
paths.forEach((path35) => {
|
|
33182
|
+
if (!sp2.isAbsolute(path35) && !this._closers.has(path35)) {
|
|
32942
33183
|
if (cwd)
|
|
32943
|
-
|
|
32944
|
-
|
|
33184
|
+
path35 = sp2.join(cwd, path35);
|
|
33185
|
+
path35 = sp2.resolve(path35);
|
|
32945
33186
|
}
|
|
32946
|
-
this._closePath(
|
|
32947
|
-
this._addIgnoredPath(
|
|
32948
|
-
if (this._watched.has(
|
|
33187
|
+
this._closePath(path35);
|
|
33188
|
+
this._addIgnoredPath(path35);
|
|
33189
|
+
if (this._watched.has(path35)) {
|
|
32949
33190
|
this._addIgnoredPath({
|
|
32950
|
-
path:
|
|
33191
|
+
path: path35,
|
|
32951
33192
|
recursive: true
|
|
32952
33193
|
});
|
|
32953
33194
|
}
|
|
@@ -33011,38 +33252,38 @@ var init_chokidar = __esm({
|
|
|
33011
33252
|
* @param stats arguments to be passed with event
|
|
33012
33253
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
33013
33254
|
*/
|
|
33014
|
-
async _emit(event,
|
|
33255
|
+
async _emit(event, path35, stats) {
|
|
33015
33256
|
if (this.closed)
|
|
33016
33257
|
return;
|
|
33017
33258
|
const opts = this.options;
|
|
33018
33259
|
if (isWindows)
|
|
33019
|
-
|
|
33260
|
+
path35 = sp2.normalize(path35);
|
|
33020
33261
|
if (opts.cwd)
|
|
33021
|
-
|
|
33022
|
-
const args = [
|
|
33262
|
+
path35 = sp2.relative(opts.cwd, path35);
|
|
33263
|
+
const args = [path35];
|
|
33023
33264
|
if (stats != null)
|
|
33024
33265
|
args.push(stats);
|
|
33025
33266
|
const awf = opts.awaitWriteFinish;
|
|
33026
33267
|
let pw;
|
|
33027
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
33268
|
+
if (awf && (pw = this._pendingWrites.get(path35))) {
|
|
33028
33269
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
33029
33270
|
return this;
|
|
33030
33271
|
}
|
|
33031
33272
|
if (opts.atomic) {
|
|
33032
33273
|
if (event === EVENTS.UNLINK) {
|
|
33033
|
-
this._pendingUnlinks.set(
|
|
33274
|
+
this._pendingUnlinks.set(path35, [event, ...args]);
|
|
33034
33275
|
setTimeout(() => {
|
|
33035
|
-
this._pendingUnlinks.forEach((entry,
|
|
33276
|
+
this._pendingUnlinks.forEach((entry, path36) => {
|
|
33036
33277
|
this.emit(...entry);
|
|
33037
33278
|
this.emit(EVENTS.ALL, ...entry);
|
|
33038
|
-
this._pendingUnlinks.delete(
|
|
33279
|
+
this._pendingUnlinks.delete(path36);
|
|
33039
33280
|
});
|
|
33040
33281
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
33041
33282
|
return this;
|
|
33042
33283
|
}
|
|
33043
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
33284
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path35)) {
|
|
33044
33285
|
event = EVENTS.CHANGE;
|
|
33045
|
-
this._pendingUnlinks.delete(
|
|
33286
|
+
this._pendingUnlinks.delete(path35);
|
|
33046
33287
|
}
|
|
33047
33288
|
}
|
|
33048
33289
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -33060,16 +33301,16 @@ var init_chokidar = __esm({
|
|
|
33060
33301
|
this.emitWithAll(event, args);
|
|
33061
33302
|
}
|
|
33062
33303
|
};
|
|
33063
|
-
this._awaitWriteFinish(
|
|
33304
|
+
this._awaitWriteFinish(path35, awf.stabilityThreshold, event, awfEmit);
|
|
33064
33305
|
return this;
|
|
33065
33306
|
}
|
|
33066
33307
|
if (event === EVENTS.CHANGE) {
|
|
33067
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
33308
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path35, 50);
|
|
33068
33309
|
if (isThrottled)
|
|
33069
33310
|
return this;
|
|
33070
33311
|
}
|
|
33071
33312
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
33072
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
33313
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path35) : path35;
|
|
33073
33314
|
let stats2;
|
|
33074
33315
|
try {
|
|
33075
33316
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -33100,23 +33341,23 @@ var init_chokidar = __esm({
|
|
|
33100
33341
|
* @param timeout duration of time to suppress duplicate actions
|
|
33101
33342
|
* @returns tracking object or false if action should be suppressed
|
|
33102
33343
|
*/
|
|
33103
|
-
_throttle(actionType,
|
|
33344
|
+
_throttle(actionType, path35, timeout) {
|
|
33104
33345
|
if (!this._throttled.has(actionType)) {
|
|
33105
33346
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
33106
33347
|
}
|
|
33107
33348
|
const action = this._throttled.get(actionType);
|
|
33108
33349
|
if (!action)
|
|
33109
33350
|
throw new Error("invalid throttle");
|
|
33110
|
-
const actionPath = action.get(
|
|
33351
|
+
const actionPath = action.get(path35);
|
|
33111
33352
|
if (actionPath) {
|
|
33112
33353
|
actionPath.count++;
|
|
33113
33354
|
return false;
|
|
33114
33355
|
}
|
|
33115
33356
|
let timeoutObject;
|
|
33116
33357
|
const clear = () => {
|
|
33117
|
-
const item = action.get(
|
|
33358
|
+
const item = action.get(path35);
|
|
33118
33359
|
const count = item ? item.count : 0;
|
|
33119
|
-
action.delete(
|
|
33360
|
+
action.delete(path35);
|
|
33120
33361
|
clearTimeout(timeoutObject);
|
|
33121
33362
|
if (item)
|
|
33122
33363
|
clearTimeout(item.timeoutObject);
|
|
@@ -33124,7 +33365,7 @@ var init_chokidar = __esm({
|
|
|
33124
33365
|
};
|
|
33125
33366
|
timeoutObject = setTimeout(clear, timeout);
|
|
33126
33367
|
const thr = { timeoutObject, clear, count: 0 };
|
|
33127
|
-
action.set(
|
|
33368
|
+
action.set(path35, thr);
|
|
33128
33369
|
return thr;
|
|
33129
33370
|
}
|
|
33130
33371
|
_incrReadyCount() {
|
|
@@ -33138,44 +33379,44 @@ var init_chokidar = __esm({
|
|
|
33138
33379
|
* @param event
|
|
33139
33380
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
33140
33381
|
*/
|
|
33141
|
-
_awaitWriteFinish(
|
|
33382
|
+
_awaitWriteFinish(path35, threshold, event, awfEmit) {
|
|
33142
33383
|
const awf = this.options.awaitWriteFinish;
|
|
33143
33384
|
if (typeof awf !== "object")
|
|
33144
33385
|
return;
|
|
33145
33386
|
const pollInterval = awf.pollInterval;
|
|
33146
33387
|
let timeoutHandler;
|
|
33147
|
-
let fullPath =
|
|
33148
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
33149
|
-
fullPath = sp2.join(this.options.cwd,
|
|
33388
|
+
let fullPath = path35;
|
|
33389
|
+
if (this.options.cwd && !sp2.isAbsolute(path35)) {
|
|
33390
|
+
fullPath = sp2.join(this.options.cwd, path35);
|
|
33150
33391
|
}
|
|
33151
33392
|
const now = /* @__PURE__ */ new Date();
|
|
33152
33393
|
const writes = this._pendingWrites;
|
|
33153
33394
|
function awaitWriteFinishFn(prevStat) {
|
|
33154
33395
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
33155
|
-
if (err || !writes.has(
|
|
33396
|
+
if (err || !writes.has(path35)) {
|
|
33156
33397
|
if (err && err.code !== "ENOENT")
|
|
33157
33398
|
awfEmit(err);
|
|
33158
33399
|
return;
|
|
33159
33400
|
}
|
|
33160
33401
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
33161
33402
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
33162
|
-
writes.get(
|
|
33403
|
+
writes.get(path35).lastChange = now2;
|
|
33163
33404
|
}
|
|
33164
|
-
const pw = writes.get(
|
|
33405
|
+
const pw = writes.get(path35);
|
|
33165
33406
|
const df = now2 - pw.lastChange;
|
|
33166
33407
|
if (df >= threshold) {
|
|
33167
|
-
writes.delete(
|
|
33408
|
+
writes.delete(path35);
|
|
33168
33409
|
awfEmit(void 0, curStat);
|
|
33169
33410
|
} else {
|
|
33170
33411
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
33171
33412
|
}
|
|
33172
33413
|
});
|
|
33173
33414
|
}
|
|
33174
|
-
if (!writes.has(
|
|
33175
|
-
writes.set(
|
|
33415
|
+
if (!writes.has(path35)) {
|
|
33416
|
+
writes.set(path35, {
|
|
33176
33417
|
lastChange: now,
|
|
33177
33418
|
cancelWait: () => {
|
|
33178
|
-
writes.delete(
|
|
33419
|
+
writes.delete(path35);
|
|
33179
33420
|
clearTimeout(timeoutHandler);
|
|
33180
33421
|
return event;
|
|
33181
33422
|
}
|
|
@@ -33186,8 +33427,8 @@ var init_chokidar = __esm({
|
|
|
33186
33427
|
/**
|
|
33187
33428
|
* Determines whether user has asked to ignore this path.
|
|
33188
33429
|
*/
|
|
33189
|
-
_isIgnored(
|
|
33190
|
-
if (this.options.atomic && DOT_RE.test(
|
|
33430
|
+
_isIgnored(path35, stats) {
|
|
33431
|
+
if (this.options.atomic && DOT_RE.test(path35))
|
|
33191
33432
|
return true;
|
|
33192
33433
|
if (!this._userIgnored) {
|
|
33193
33434
|
const { cwd } = this.options;
|
|
@@ -33197,17 +33438,17 @@ var init_chokidar = __esm({
|
|
|
33197
33438
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
33198
33439
|
this._userIgnored = anymatch(list, void 0);
|
|
33199
33440
|
}
|
|
33200
|
-
return this._userIgnored(
|
|
33441
|
+
return this._userIgnored(path35, stats);
|
|
33201
33442
|
}
|
|
33202
|
-
_isntIgnored(
|
|
33203
|
-
return !this._isIgnored(
|
|
33443
|
+
_isntIgnored(path35, stat4) {
|
|
33444
|
+
return !this._isIgnored(path35, stat4);
|
|
33204
33445
|
}
|
|
33205
33446
|
/**
|
|
33206
33447
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
33207
33448
|
* @param path file or directory pattern being watched
|
|
33208
33449
|
*/
|
|
33209
|
-
_getWatchHelpers(
|
|
33210
|
-
return new WatchHelper(
|
|
33450
|
+
_getWatchHelpers(path35) {
|
|
33451
|
+
return new WatchHelper(path35, this.options.followSymlinks, this);
|
|
33211
33452
|
}
|
|
33212
33453
|
// Directory helpers
|
|
33213
33454
|
// -----------------
|
|
@@ -33239,63 +33480,63 @@ var init_chokidar = __esm({
|
|
|
33239
33480
|
* @param item base path of item/directory
|
|
33240
33481
|
*/
|
|
33241
33482
|
_remove(directory, item, isDirectory) {
|
|
33242
|
-
const
|
|
33243
|
-
const fullPath = sp2.resolve(
|
|
33244
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
33245
|
-
if (!this._throttle("remove",
|
|
33483
|
+
const path35 = sp2.join(directory, item);
|
|
33484
|
+
const fullPath = sp2.resolve(path35);
|
|
33485
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path35) || this._watched.has(fullPath);
|
|
33486
|
+
if (!this._throttle("remove", path35, 100))
|
|
33246
33487
|
return;
|
|
33247
33488
|
if (!isDirectory && this._watched.size === 1) {
|
|
33248
33489
|
this.add(directory, item, true);
|
|
33249
33490
|
}
|
|
33250
|
-
const wp = this._getWatchedDir(
|
|
33491
|
+
const wp = this._getWatchedDir(path35);
|
|
33251
33492
|
const nestedDirectoryChildren = wp.getChildren();
|
|
33252
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
33493
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path35, nested));
|
|
33253
33494
|
const parent = this._getWatchedDir(directory);
|
|
33254
33495
|
const wasTracked = parent.has(item);
|
|
33255
33496
|
parent.remove(item);
|
|
33256
33497
|
if (this._symlinkPaths.has(fullPath)) {
|
|
33257
33498
|
this._symlinkPaths.delete(fullPath);
|
|
33258
33499
|
}
|
|
33259
|
-
let relPath =
|
|
33500
|
+
let relPath = path35;
|
|
33260
33501
|
if (this.options.cwd)
|
|
33261
|
-
relPath = sp2.relative(this.options.cwd,
|
|
33502
|
+
relPath = sp2.relative(this.options.cwd, path35);
|
|
33262
33503
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
33263
33504
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
33264
33505
|
if (event === EVENTS.ADD)
|
|
33265
33506
|
return;
|
|
33266
33507
|
}
|
|
33267
|
-
this._watched.delete(
|
|
33508
|
+
this._watched.delete(path35);
|
|
33268
33509
|
this._watched.delete(fullPath);
|
|
33269
33510
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
33270
|
-
if (wasTracked && !this._isIgnored(
|
|
33271
|
-
this._emit(eventName,
|
|
33272
|
-
this._closePath(
|
|
33511
|
+
if (wasTracked && !this._isIgnored(path35))
|
|
33512
|
+
this._emit(eventName, path35);
|
|
33513
|
+
this._closePath(path35);
|
|
33273
33514
|
}
|
|
33274
33515
|
/**
|
|
33275
33516
|
* Closes all watchers for a path
|
|
33276
33517
|
*/
|
|
33277
|
-
_closePath(
|
|
33278
|
-
this._closeFile(
|
|
33279
|
-
const dir = sp2.dirname(
|
|
33280
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
33518
|
+
_closePath(path35) {
|
|
33519
|
+
this._closeFile(path35);
|
|
33520
|
+
const dir = sp2.dirname(path35);
|
|
33521
|
+
this._getWatchedDir(dir).remove(sp2.basename(path35));
|
|
33281
33522
|
}
|
|
33282
33523
|
/**
|
|
33283
33524
|
* Closes only file-specific watchers
|
|
33284
33525
|
*/
|
|
33285
|
-
_closeFile(
|
|
33286
|
-
const closers = this._closers.get(
|
|
33526
|
+
_closeFile(path35) {
|
|
33527
|
+
const closers = this._closers.get(path35);
|
|
33287
33528
|
if (!closers)
|
|
33288
33529
|
return;
|
|
33289
33530
|
closers.forEach((closer) => closer());
|
|
33290
|
-
this._closers.delete(
|
|
33531
|
+
this._closers.delete(path35);
|
|
33291
33532
|
}
|
|
33292
|
-
_addPathCloser(
|
|
33533
|
+
_addPathCloser(path35, closer) {
|
|
33293
33534
|
if (!closer)
|
|
33294
33535
|
return;
|
|
33295
|
-
let list = this._closers.get(
|
|
33536
|
+
let list = this._closers.get(path35);
|
|
33296
33537
|
if (!list) {
|
|
33297
33538
|
list = [];
|
|
33298
|
-
this._closers.set(
|
|
33539
|
+
this._closers.set(path35, list);
|
|
33299
33540
|
}
|
|
33300
33541
|
list.push(closer);
|
|
33301
33542
|
}
|
|
@@ -33344,6 +33585,7 @@ function validateProviderDefinition(raw) {
|
|
|
33344
33585
|
warnings.push("disableUpstream is deprecated in provider definitions; use machine-level provider source policy instead");
|
|
33345
33586
|
}
|
|
33346
33587
|
const category = provider.category;
|
|
33588
|
+
const controls = Array.isArray(provider.controls) ? provider.controls : [];
|
|
33347
33589
|
if (category === "cli" || category === "acp") {
|
|
33348
33590
|
const spawn6 = provider.spawn;
|
|
33349
33591
|
const command = spawn6 && typeof spawn6 === "object" ? spawn6.command : void 0;
|
|
@@ -33361,11 +33603,61 @@ function validateProviderDefinition(raw) {
|
|
|
33361
33603
|
if (category === "extension" && !provider.extensionId) {
|
|
33362
33604
|
warnings.push("Extension providers should have extensionId");
|
|
33363
33605
|
}
|
|
33364
|
-
|
|
33606
|
+
validateCapabilities(provider, controls, errors);
|
|
33607
|
+
for (const control of controls) {
|
|
33365
33608
|
validateControl(control, errors);
|
|
33366
33609
|
}
|
|
33367
33610
|
return { errors, warnings };
|
|
33368
33611
|
}
|
|
33612
|
+
function validateCapabilities(provider, controls, errors) {
|
|
33613
|
+
const capabilities = provider.capabilities;
|
|
33614
|
+
if (provider.contractVersion === 2) {
|
|
33615
|
+
if (!capabilities || typeof capabilities !== "object") {
|
|
33616
|
+
errors.push("contractVersion 2 providers must declare capabilities");
|
|
33617
|
+
return;
|
|
33618
|
+
}
|
|
33619
|
+
}
|
|
33620
|
+
if (!capabilities || typeof capabilities !== "object") {
|
|
33621
|
+
return;
|
|
33622
|
+
}
|
|
33623
|
+
const input = capabilities.input;
|
|
33624
|
+
if (!input || typeof input !== "object") {
|
|
33625
|
+
errors.push("capabilities.input is required");
|
|
33626
|
+
} else {
|
|
33627
|
+
if (typeof input.multipart !== "boolean") {
|
|
33628
|
+
errors.push("capabilities.input.multipart must be boolean");
|
|
33629
|
+
}
|
|
33630
|
+
if (!Array.isArray(input.mediaTypes) || input.mediaTypes.length === 0) {
|
|
33631
|
+
errors.push("capabilities.input.mediaTypes must be a non-empty array");
|
|
33632
|
+
} else if (input.mediaTypes.some((type) => typeof type !== "string" || !VALID_CAPABILITY_MEDIA_TYPES.has(type))) {
|
|
33633
|
+
errors.push(`capabilities.input.mediaTypes must only include: ${Array.from(VALID_CAPABILITY_MEDIA_TYPES).join(", ")}`);
|
|
33634
|
+
}
|
|
33635
|
+
}
|
|
33636
|
+
const output = capabilities.output;
|
|
33637
|
+
if (!output || typeof output !== "object") {
|
|
33638
|
+
errors.push("capabilities.output is required");
|
|
33639
|
+
} else {
|
|
33640
|
+
if (typeof output.richContent !== "boolean") {
|
|
33641
|
+
errors.push("capabilities.output.richContent must be boolean");
|
|
33642
|
+
}
|
|
33643
|
+
if (!Array.isArray(output.mediaTypes) || output.mediaTypes.length === 0) {
|
|
33644
|
+
errors.push("capabilities.output.mediaTypes must be a non-empty array");
|
|
33645
|
+
} else if (output.mediaTypes.some((type) => typeof type !== "string" || !VALID_CAPABILITY_MEDIA_TYPES.has(type))) {
|
|
33646
|
+
errors.push(`capabilities.output.mediaTypes must only include: ${Array.from(VALID_CAPABILITY_MEDIA_TYPES).join(", ")}`);
|
|
33647
|
+
}
|
|
33648
|
+
}
|
|
33649
|
+
const controlCapabilities = capabilities.controls;
|
|
33650
|
+
if (!controlCapabilities || typeof controlCapabilities !== "object") {
|
|
33651
|
+
errors.push("capabilities.controls is required");
|
|
33652
|
+
return;
|
|
33653
|
+
}
|
|
33654
|
+
if (typeof controlCapabilities.typedResults !== "boolean") {
|
|
33655
|
+
errors.push("capabilities.controls.typedResults must be boolean");
|
|
33656
|
+
}
|
|
33657
|
+
if (controls.length > 0 && controlCapabilities.typedResults !== true) {
|
|
33658
|
+
errors.push("providers declaring controls must set capabilities.controls.typedResults=true");
|
|
33659
|
+
}
|
|
33660
|
+
}
|
|
33369
33661
|
function validateControl(control, errors) {
|
|
33370
33662
|
if (!control || typeof control !== "object") {
|
|
33371
33663
|
errors.push("controls: each control must be an object");
|
|
@@ -33397,10 +33689,11 @@ function validateControl(control, errors) {
|
|
|
33397
33689
|
errors.push(`${prefix}: readFrom must be a non-empty string when provided`);
|
|
33398
33690
|
}
|
|
33399
33691
|
}
|
|
33400
|
-
var KNOWN_PROVIDER_FIELDS, VALUE_CONTROL_TYPES;
|
|
33692
|
+
var VALID_CAPABILITY_MEDIA_TYPES, KNOWN_PROVIDER_FIELDS, VALUE_CONTROL_TYPES;
|
|
33401
33693
|
var init_provider_schema = __esm({
|
|
33402
33694
|
"../../oss/packages/daemon-core/src/providers/provider-schema.ts"() {
|
|
33403
33695
|
"use strict";
|
|
33696
|
+
VALID_CAPABILITY_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
|
|
33404
33697
|
KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
|
|
33405
33698
|
"type",
|
|
33406
33699
|
"name",
|
|
@@ -33451,6 +33744,7 @@ var init_provider_schema = __esm({
|
|
|
33451
33744
|
"sendDelayMs",
|
|
33452
33745
|
"sendKey",
|
|
33453
33746
|
"submitStrategy",
|
|
33747
|
+
"timeouts",
|
|
33454
33748
|
"disableUpstream"
|
|
33455
33749
|
]);
|
|
33456
33750
|
VALUE_CONTROL_TYPES = /* @__PURE__ */ new Set(["select", "toggle", "cycle", "slider"]);
|
|
@@ -33458,12 +33752,12 @@ var init_provider_schema = __esm({
|
|
|
33458
33752
|
});
|
|
33459
33753
|
|
|
33460
33754
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
33461
|
-
var fs6,
|
|
33755
|
+
var fs6, path14, os16, ProviderLoader;
|
|
33462
33756
|
var init_provider_loader = __esm({
|
|
33463
33757
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
33464
33758
|
"use strict";
|
|
33465
33759
|
fs6 = __toESM(require("fs"));
|
|
33466
|
-
|
|
33760
|
+
path14 = __toESM(require("path"));
|
|
33467
33761
|
os16 = __toESM(require("os"));
|
|
33468
33762
|
init_chokidar();
|
|
33469
33763
|
init_ide_detector();
|
|
@@ -33490,9 +33784,9 @@ var init_provider_loader = __esm({
|
|
|
33490
33784
|
static META_FILE = ".meta.json";
|
|
33491
33785
|
constructor(options) {
|
|
33492
33786
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
33493
|
-
this.defaultProvidersDir =
|
|
33787
|
+
this.defaultProvidersDir = path14.join(os16.homedir(), ".adhdev", "providers");
|
|
33494
33788
|
this.userDir = this.defaultProvidersDir;
|
|
33495
|
-
this.upstreamDir =
|
|
33789
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
33496
33790
|
this.disableUpstream = false;
|
|
33497
33791
|
this.applySourceConfig({
|
|
33498
33792
|
userDir: options?.userDir,
|
|
@@ -33540,7 +33834,7 @@ var init_provider_loader = __esm({
|
|
|
33540
33834
|
}
|
|
33541
33835
|
this.sourceMode = nextSourceMode;
|
|
33542
33836
|
this.userDir = this.explicitProviderDir || this.defaultProvidersDir;
|
|
33543
|
-
this.upstreamDir =
|
|
33837
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
33544
33838
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
33545
33839
|
if (this.explicitProviderDir) {
|
|
33546
33840
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -33554,7 +33848,7 @@ var init_provider_loader = __esm({
|
|
|
33554
33848
|
* Canonical provider directory shape for a given root.
|
|
33555
33849
|
*/
|
|
33556
33850
|
getProviderDir(root, category, type) {
|
|
33557
|
-
return
|
|
33851
|
+
return path14.join(root, category, type);
|
|
33558
33852
|
}
|
|
33559
33853
|
/**
|
|
33560
33854
|
* Canonical user override directory for a provider.
|
|
@@ -33581,7 +33875,7 @@ var init_provider_loader = __esm({
|
|
|
33581
33875
|
resolveProviderFile(type, ...segments) {
|
|
33582
33876
|
const dir = this.findProviderDirInternal(type);
|
|
33583
33877
|
if (!dir) return null;
|
|
33584
|
-
return
|
|
33878
|
+
return path14.join(dir, ...segments);
|
|
33585
33879
|
}
|
|
33586
33880
|
/**
|
|
33587
33881
|
* Load all providers (3-tier priority)
|
|
@@ -33620,7 +33914,7 @@ var init_provider_loader = __esm({
|
|
|
33620
33914
|
if (!fs6.existsSync(this.upstreamDir)) return false;
|
|
33621
33915
|
try {
|
|
33622
33916
|
return fs6.readdirSync(this.upstreamDir).some(
|
|
33623
|
-
(d) => fs6.statSync(
|
|
33917
|
+
(d) => fs6.statSync(path14.join(this.upstreamDir, d)).isDirectory()
|
|
33624
33918
|
);
|
|
33625
33919
|
} catch {
|
|
33626
33920
|
return false;
|
|
@@ -33935,8 +34229,8 @@ var init_provider_loader = __esm({
|
|
|
33935
34229
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
33936
34230
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
33937
34231
|
if (providerDir) {
|
|
33938
|
-
const fullDir =
|
|
33939
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
34232
|
+
const fullDir = path14.join(providerDir, entry.scriptDir);
|
|
34233
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
33940
34234
|
}
|
|
33941
34235
|
matched = true;
|
|
33942
34236
|
}
|
|
@@ -33951,8 +34245,8 @@ var init_provider_loader = __esm({
|
|
|
33951
34245
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
33952
34246
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
33953
34247
|
if (providerDir) {
|
|
33954
|
-
const fullDir =
|
|
33955
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
34248
|
+
const fullDir = path14.join(providerDir, base.defaultScriptDir);
|
|
34249
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
33956
34250
|
}
|
|
33957
34251
|
}
|
|
33958
34252
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -33969,8 +34263,8 @@ var init_provider_loader = __esm({
|
|
|
33969
34263
|
resolved._resolvedScriptDir = dirOverride;
|
|
33970
34264
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
33971
34265
|
if (providerDir) {
|
|
33972
|
-
const fullDir =
|
|
33973
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
34266
|
+
const fullDir = path14.join(providerDir, dirOverride);
|
|
34267
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
33974
34268
|
}
|
|
33975
34269
|
}
|
|
33976
34270
|
} else if (override.scripts) {
|
|
@@ -33986,8 +34280,8 @@ var init_provider_loader = __esm({
|
|
|
33986
34280
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
33987
34281
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
33988
34282
|
if (providerDir) {
|
|
33989
|
-
const fullDir =
|
|
33990
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
34283
|
+
const fullDir = path14.join(providerDir, base.defaultScriptDir);
|
|
34284
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
33991
34285
|
}
|
|
33992
34286
|
}
|
|
33993
34287
|
}
|
|
@@ -34012,14 +34306,14 @@ var init_provider_loader = __esm({
|
|
|
34012
34306
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
34013
34307
|
return null;
|
|
34014
34308
|
}
|
|
34015
|
-
const dir =
|
|
34309
|
+
const dir = path14.join(providerDir, scriptDir);
|
|
34016
34310
|
if (!fs6.existsSync(dir)) {
|
|
34017
34311
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
34018
34312
|
return null;
|
|
34019
34313
|
}
|
|
34020
34314
|
const cached2 = this.scriptsCache.get(dir);
|
|
34021
34315
|
if (cached2) return cached2;
|
|
34022
|
-
const scriptsJs =
|
|
34316
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
34023
34317
|
if (fs6.existsSync(scriptsJs)) {
|
|
34024
34318
|
try {
|
|
34025
34319
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -34061,7 +34355,7 @@ var init_provider_loader = __esm({
|
|
|
34061
34355
|
return;
|
|
34062
34356
|
}
|
|
34063
34357
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
34064
|
-
this.log(`File changed: ${
|
|
34358
|
+
this.log(`File changed: ${path14.basename(filePath)}, reloading...`);
|
|
34065
34359
|
this.reload();
|
|
34066
34360
|
}
|
|
34067
34361
|
};
|
|
@@ -34116,7 +34410,7 @@ var init_provider_loader = __esm({
|
|
|
34116
34410
|
}
|
|
34117
34411
|
const https = require("https");
|
|
34118
34412
|
const { execSync: execSync8 } = require("child_process");
|
|
34119
|
-
const metaPath =
|
|
34413
|
+
const metaPath = path14.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
34120
34414
|
let prevEtag = "";
|
|
34121
34415
|
let prevTimestamp = 0;
|
|
34122
34416
|
try {
|
|
@@ -34176,17 +34470,17 @@ var init_provider_loader = __esm({
|
|
|
34176
34470
|
return { updated: false };
|
|
34177
34471
|
}
|
|
34178
34472
|
this.log("Downloading latest providers from GitHub...");
|
|
34179
|
-
const tmpTar =
|
|
34180
|
-
const tmpExtract =
|
|
34473
|
+
const tmpTar = path14.join(os16.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
34474
|
+
const tmpExtract = path14.join(os16.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
34181
34475
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
34182
34476
|
fs6.mkdirSync(tmpExtract, { recursive: true });
|
|
34183
34477
|
execSync8(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
34184
34478
|
const extracted = fs6.readdirSync(tmpExtract);
|
|
34185
34479
|
const rootDir = extracted.find(
|
|
34186
|
-
(d) => fs6.statSync(
|
|
34480
|
+
(d) => fs6.statSync(path14.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
34187
34481
|
);
|
|
34188
34482
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
34189
|
-
const sourceDir =
|
|
34483
|
+
const sourceDir = path14.join(tmpExtract, rootDir);
|
|
34190
34484
|
const backupDir = this.upstreamDir + ".bak";
|
|
34191
34485
|
if (fs6.existsSync(this.upstreamDir)) {
|
|
34192
34486
|
if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -34261,8 +34555,8 @@ var init_provider_loader = __esm({
|
|
|
34261
34555
|
copyDirRecursive(src, dest) {
|
|
34262
34556
|
fs6.mkdirSync(dest, { recursive: true });
|
|
34263
34557
|
for (const entry of fs6.readdirSync(src, { withFileTypes: true })) {
|
|
34264
|
-
const srcPath =
|
|
34265
|
-
const destPath =
|
|
34558
|
+
const srcPath = path14.join(src, entry.name);
|
|
34559
|
+
const destPath = path14.join(dest, entry.name);
|
|
34266
34560
|
if (entry.isDirectory()) {
|
|
34267
34561
|
this.copyDirRecursive(srcPath, destPath);
|
|
34268
34562
|
} else {
|
|
@@ -34273,7 +34567,7 @@ var init_provider_loader = __esm({
|
|
|
34273
34567
|
/** .meta.json save */
|
|
34274
34568
|
writeMeta(metaPath, etag, timestamp) {
|
|
34275
34569
|
try {
|
|
34276
|
-
fs6.mkdirSync(
|
|
34570
|
+
fs6.mkdirSync(path14.dirname(metaPath), { recursive: true });
|
|
34277
34571
|
fs6.writeFileSync(metaPath, JSON.stringify({
|
|
34278
34572
|
etag,
|
|
34279
34573
|
timestamp,
|
|
@@ -34290,7 +34584,7 @@ var init_provider_loader = __esm({
|
|
|
34290
34584
|
const scan = (d) => {
|
|
34291
34585
|
try {
|
|
34292
34586
|
for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
|
|
34293
|
-
if (entry.isDirectory()) scan(
|
|
34587
|
+
if (entry.isDirectory()) scan(path14.join(d, entry.name));
|
|
34294
34588
|
else if (entry.name === "provider.json") count++;
|
|
34295
34589
|
}
|
|
34296
34590
|
} catch {
|
|
@@ -34475,17 +34769,17 @@ var init_provider_loader = __esm({
|
|
|
34475
34769
|
for (const root of searchRoots) {
|
|
34476
34770
|
if (!fs6.existsSync(root)) continue;
|
|
34477
34771
|
const candidate = this.getProviderDir(root, cat, type);
|
|
34478
|
-
if (fs6.existsSync(
|
|
34479
|
-
const catDir =
|
|
34772
|
+
if (fs6.existsSync(path14.join(candidate, "provider.json"))) return candidate;
|
|
34773
|
+
const catDir = path14.join(root, cat);
|
|
34480
34774
|
if (fs6.existsSync(catDir)) {
|
|
34481
34775
|
try {
|
|
34482
34776
|
for (const entry of fs6.readdirSync(catDir, { withFileTypes: true })) {
|
|
34483
34777
|
if (!entry.isDirectory()) continue;
|
|
34484
|
-
const jsonPath =
|
|
34778
|
+
const jsonPath = path14.join(catDir, entry.name, "provider.json");
|
|
34485
34779
|
if (fs6.existsSync(jsonPath)) {
|
|
34486
34780
|
try {
|
|
34487
34781
|
const data = JSON.parse(fs6.readFileSync(jsonPath, "utf-8"));
|
|
34488
|
-
if (data.type === type) return
|
|
34782
|
+
if (data.type === type) return path14.join(catDir, entry.name);
|
|
34489
34783
|
} catch {
|
|
34490
34784
|
}
|
|
34491
34785
|
}
|
|
@@ -34502,7 +34796,7 @@ var init_provider_loader = __esm({
|
|
|
34502
34796
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
34503
34797
|
*/
|
|
34504
34798
|
buildScriptWrappersFromDir(dir) {
|
|
34505
|
-
const scriptsJs =
|
|
34799
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
34506
34800
|
if (fs6.existsSync(scriptsJs)) {
|
|
34507
34801
|
try {
|
|
34508
34802
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -34516,7 +34810,7 @@ var init_provider_loader = __esm({
|
|
|
34516
34810
|
for (const file2 of fs6.readdirSync(dir)) {
|
|
34517
34811
|
if (!file2.endsWith(".js")) continue;
|
|
34518
34812
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
34519
|
-
const filePath =
|
|
34813
|
+
const filePath = path14.join(dir, file2);
|
|
34520
34814
|
result[scriptName] = (...args) => {
|
|
34521
34815
|
try {
|
|
34522
34816
|
let content = fs6.readFileSync(filePath, "utf-8");
|
|
@@ -34576,7 +34870,7 @@ var init_provider_loader = __esm({
|
|
|
34576
34870
|
}
|
|
34577
34871
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
34578
34872
|
if (hasJson) {
|
|
34579
|
-
const jsonPath =
|
|
34873
|
+
const jsonPath = path14.join(d, "provider.json");
|
|
34580
34874
|
try {
|
|
34581
34875
|
const raw = fs6.readFileSync(jsonPath, "utf-8");
|
|
34582
34876
|
const mod = JSON.parse(raw);
|
|
@@ -34597,7 +34891,7 @@ var init_provider_loader = __esm({
|
|
|
34597
34891
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
34598
34892
|
} else {
|
|
34599
34893
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
34600
|
-
const scriptsPath =
|
|
34894
|
+
const scriptsPath = path14.join(d, "scripts.js");
|
|
34601
34895
|
if (!hasCompatibility && fs6.existsSync(scriptsPath)) {
|
|
34602
34896
|
try {
|
|
34603
34897
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -34623,7 +34917,7 @@ var init_provider_loader = __esm({
|
|
|
34623
34917
|
if (!entry.isDirectory()) continue;
|
|
34624
34918
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
34625
34919
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
34626
|
-
scan(
|
|
34920
|
+
scan(path14.join(d, entry.name));
|
|
34627
34921
|
}
|
|
34628
34922
|
}
|
|
34629
34923
|
};
|
|
@@ -34882,8 +35176,8 @@ function detectCurrentWorkspace(ideId) {
|
|
|
34882
35176
|
const appNameMap = getMacAppIdentifiers();
|
|
34883
35177
|
const appName = appNameMap[ideId];
|
|
34884
35178
|
if (appName) {
|
|
34885
|
-
const storagePath =
|
|
34886
|
-
process.env.APPDATA ||
|
|
35179
|
+
const storagePath = path15.join(
|
|
35180
|
+
process.env.APPDATA || path15.join(os17.homedir(), "AppData", "Roaming"),
|
|
34887
35181
|
appName,
|
|
34888
35182
|
"storage.json"
|
|
34889
35183
|
);
|
|
@@ -35054,14 +35348,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
35054
35348
|
function getAvailableIdeIds() {
|
|
35055
35349
|
return getProviderLoader().getAvailableIdeTypes();
|
|
35056
35350
|
}
|
|
35057
|
-
var import_child_process6, net2, os17,
|
|
35351
|
+
var import_child_process6, net2, os17, path15, _providerLoader;
|
|
35058
35352
|
var init_launch = __esm({
|
|
35059
35353
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
35060
35354
|
"use strict";
|
|
35061
35355
|
import_child_process6 = require("child_process");
|
|
35062
35356
|
net2 = __toESM(require("net"));
|
|
35063
35357
|
os17 = __toESM(require("os"));
|
|
35064
|
-
|
|
35358
|
+
path15 = __toESM(require("path"));
|
|
35065
35359
|
init_ide_detector();
|
|
35066
35360
|
init_provider_loader();
|
|
35067
35361
|
_providerLoader = null;
|
|
@@ -35092,7 +35386,7 @@ function checkRotation() {
|
|
|
35092
35386
|
const today = getDateStr2();
|
|
35093
35387
|
if (today !== currentDate2) {
|
|
35094
35388
|
currentDate2 = today;
|
|
35095
|
-
currentFile =
|
|
35389
|
+
currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
35096
35390
|
cleanOldFiles();
|
|
35097
35391
|
}
|
|
35098
35392
|
}
|
|
@@ -35106,7 +35400,7 @@ function cleanOldFiles() {
|
|
|
35106
35400
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
35107
35401
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
35108
35402
|
try {
|
|
35109
|
-
fs7.unlinkSync(
|
|
35403
|
+
fs7.unlinkSync(path16.join(LOG_DIR2, file2));
|
|
35110
35404
|
} catch {
|
|
35111
35405
|
}
|
|
35112
35406
|
}
|
|
@@ -35175,14 +35469,14 @@ function getRecentCommands(count = 50) {
|
|
|
35175
35469
|
return [];
|
|
35176
35470
|
}
|
|
35177
35471
|
}
|
|
35178
|
-
var fs7,
|
|
35472
|
+
var fs7, path16, os18, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
35179
35473
|
var init_command_log = __esm({
|
|
35180
35474
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
35181
35475
|
"use strict";
|
|
35182
35476
|
fs7 = __toESM(require("fs"));
|
|
35183
|
-
|
|
35477
|
+
path16 = __toESM(require("path"));
|
|
35184
35478
|
os18 = __toESM(require("os"));
|
|
35185
|
-
LOG_DIR2 = process.platform === "win32" ?
|
|
35479
|
+
LOG_DIR2 = process.platform === "win32" ? path16.join(process.env.LOCALAPPDATA || process.env.APPDATA || path16.join(os18.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path16.join(os18.homedir(), "Library", "Logs", "adhdev") : path16.join(os18.homedir(), ".local", "share", "adhdev", "logs");
|
|
35186
35480
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
35187
35481
|
MAX_DAYS = 7;
|
|
35188
35482
|
try {
|
|
@@ -35201,7 +35495,7 @@ var init_command_log = __esm({
|
|
|
35201
35495
|
"text"
|
|
35202
35496
|
]);
|
|
35203
35497
|
currentDate2 = getDateStr2();
|
|
35204
|
-
currentFile =
|
|
35498
|
+
currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
35205
35499
|
writeCount2 = 0;
|
|
35206
35500
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
35207
35501
|
"heartbeat",
|
|
@@ -35561,9 +35855,9 @@ var init_snapshot = __esm({
|
|
|
35561
35855
|
// ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
|
|
35562
35856
|
function getUpgradeLogPath() {
|
|
35563
35857
|
const home = os20.homedir();
|
|
35564
|
-
const dir =
|
|
35858
|
+
const dir = path17.join(home, ".adhdev");
|
|
35565
35859
|
fs8.mkdirSync(dir, { recursive: true });
|
|
35566
|
-
return
|
|
35860
|
+
return path17.join(dir, "daemon-upgrade.log");
|
|
35567
35861
|
}
|
|
35568
35862
|
function appendUpgradeLog(message) {
|
|
35569
35863
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
@@ -35603,7 +35897,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
35603
35897
|
}
|
|
35604
35898
|
}
|
|
35605
35899
|
function stopSessionHostProcesses(appName) {
|
|
35606
|
-
const pidFile =
|
|
35900
|
+
const pidFile = path17.join(os20.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
35607
35901
|
try {
|
|
35608
35902
|
if (fs8.existsSync(pidFile)) {
|
|
35609
35903
|
const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
|
|
@@ -35632,7 +35926,7 @@ function stopSessionHostProcesses(appName) {
|
|
|
35632
35926
|
}
|
|
35633
35927
|
}
|
|
35634
35928
|
function removeDaemonPidFile() {
|
|
35635
|
-
const pidFile =
|
|
35929
|
+
const pidFile = path17.join(os20.homedir(), ".adhdev", "daemon.pid");
|
|
35636
35930
|
try {
|
|
35637
35931
|
fs8.unlinkSync(pidFile);
|
|
35638
35932
|
} catch {
|
|
@@ -35643,7 +35937,7 @@ function cleanupStaleGlobalInstallDirs(pkgName) {
|
|
|
35643
35937
|
const npmRoot = (0, import_child_process7.execFileSync)(getNpmExecutable(), ["root", "-g"], { encoding: "utf8", ...npmExecOpts }).trim();
|
|
35644
35938
|
if (!npmRoot) return;
|
|
35645
35939
|
const npmPrefix = (0, import_child_process7.execFileSync)(getNpmExecutable(), ["prefix", "-g"], { encoding: "utf8", ...npmExecOpts }).trim();
|
|
35646
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
35940
|
+
const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
|
|
35647
35941
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
35648
35942
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
35649
35943
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -35651,25 +35945,25 @@ function cleanupStaleGlobalInstallDirs(pkgName) {
|
|
|
35651
35945
|
}
|
|
35652
35946
|
if (pkgName.startsWith("@")) {
|
|
35653
35947
|
const [scope, name] = pkgName.split("/");
|
|
35654
|
-
const scopeDir =
|
|
35948
|
+
const scopeDir = path17.join(npmRoot, scope);
|
|
35655
35949
|
if (!fs8.existsSync(scopeDir)) return;
|
|
35656
35950
|
for (const entry of fs8.readdirSync(scopeDir)) {
|
|
35657
35951
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
35658
|
-
fs8.rmSync(
|
|
35659
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
35952
|
+
fs8.rmSync(path17.join(scopeDir, entry), { recursive: true, force: true });
|
|
35953
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path17.join(scopeDir, entry)}`);
|
|
35660
35954
|
}
|
|
35661
35955
|
} else {
|
|
35662
35956
|
for (const entry of fs8.readdirSync(npmRoot)) {
|
|
35663
35957
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
35664
|
-
fs8.rmSync(
|
|
35665
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
35958
|
+
fs8.rmSync(path17.join(npmRoot, entry), { recursive: true, force: true });
|
|
35959
|
+
appendUpgradeLog(`Removed stale staging dir: ${path17.join(npmRoot, entry)}`);
|
|
35666
35960
|
}
|
|
35667
35961
|
}
|
|
35668
35962
|
if (fs8.existsSync(binDir)) {
|
|
35669
35963
|
for (const entry of fs8.readdirSync(binDir)) {
|
|
35670
35964
|
if (![...binNames].some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
35671
|
-
fs8.rmSync(
|
|
35672
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
35965
|
+
fs8.rmSync(path17.join(binDir, entry), { recursive: true, force: true });
|
|
35966
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path17.join(binDir, entry)}`);
|
|
35673
35967
|
}
|
|
35674
35968
|
}
|
|
35675
35969
|
}
|
|
@@ -35744,7 +36038,7 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
35744
36038
|
process.exit(1);
|
|
35745
36039
|
}
|
|
35746
36040
|
}
|
|
35747
|
-
var import_child_process7, import_child_process8, fs8, os20,
|
|
36041
|
+
var import_child_process7, import_child_process8, fs8, os20, path17, UPGRADE_HELPER_ENV;
|
|
35748
36042
|
var init_upgrade_helper = __esm({
|
|
35749
36043
|
"../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
|
|
35750
36044
|
"use strict";
|
|
@@ -35752,7 +36046,7 @@ var init_upgrade_helper = __esm({
|
|
|
35752
36046
|
import_child_process8 = require("child_process");
|
|
35753
36047
|
fs8 = __toESM(require("fs"));
|
|
35754
36048
|
os20 = __toESM(require("os"));
|
|
35755
|
-
|
|
36049
|
+
path17 = __toESM(require("path"));
|
|
35756
36050
|
UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
35757
36051
|
}
|
|
35758
36052
|
});
|
|
@@ -36753,6 +37047,7 @@ var init_provider_adapter = __esm({
|
|
|
36753
37047
|
"../../oss/packages/daemon-core/src/agent-stream/provider-adapter.ts"() {
|
|
36754
37048
|
"use strict";
|
|
36755
37049
|
init_control_effects();
|
|
37050
|
+
init_read_chat_contract();
|
|
36756
37051
|
init_provider_patch_state();
|
|
36757
37052
|
init_chat_message_normalization();
|
|
36758
37053
|
ProviderStreamAdapter = class {
|
|
@@ -36859,26 +37154,29 @@ var init_provider_adapter = __esm({
|
|
|
36859
37154
|
}
|
|
36860
37155
|
return state2;
|
|
36861
37156
|
}
|
|
37157
|
+
const validated = validateReadChatResultPayload(data, `${this.agentType} readChat`);
|
|
37158
|
+
const validatedStatus = validated.status;
|
|
37159
|
+
const streamStatus = validatedStatus === "generating" || validatedStatus === "long_generating" ? "streaming" : validatedStatus;
|
|
36862
37160
|
const state = {
|
|
36863
37161
|
agentType: this.agentType,
|
|
36864
37162
|
agentName: this.agentName,
|
|
36865
37163
|
extensionId: this.extensionId,
|
|
36866
|
-
status:
|
|
36867
|
-
messages: normalizeChatMessages(
|
|
36868
|
-
inputContent:
|
|
36869
|
-
activeModal:
|
|
37164
|
+
status: streamStatus,
|
|
37165
|
+
messages: normalizeChatMessages(validated.messages),
|
|
37166
|
+
inputContent: typeof validated.inputContent === "string" ? validated.inputContent : "",
|
|
37167
|
+
...validated.activeModal ? { activeModal: validated.activeModal } : {}
|
|
36870
37168
|
};
|
|
36871
|
-
if (typeof
|
|
36872
|
-
state.title =
|
|
37169
|
+
if (typeof validated.title === "string" && validated.title.trim()) {
|
|
37170
|
+
state.title = validated.title.trim();
|
|
36873
37171
|
}
|
|
36874
|
-
const controlValues = extractProviderControlValues(this.provider.controls,
|
|
37172
|
+
const controlValues = extractProviderControlValues(this.provider.controls, validated);
|
|
36875
37173
|
const surface = resolveProviderStateSurface({
|
|
36876
37174
|
controlValues,
|
|
36877
|
-
summaryMetadata:
|
|
37175
|
+
summaryMetadata: validated.summaryMetadata
|
|
36878
37176
|
});
|
|
36879
37177
|
if (surface.controlValues) state.controlValues = surface.controlValues;
|
|
36880
37178
|
if (surface.summaryMetadata) state.summaryMetadata = surface.summaryMetadata;
|
|
36881
|
-
const effects = normalizeProviderEffects(
|
|
37179
|
+
const effects = normalizeProviderEffects(validated);
|
|
36882
37180
|
if (effects.length > 0) state.effects = effects;
|
|
36883
37181
|
if (state.messages.length > 0) {
|
|
36884
37182
|
this.lastSuccessState = state;
|
|
@@ -37815,7 +38113,7 @@ function checkPathExists2(paths) {
|
|
|
37815
38113
|
for (const p of paths) {
|
|
37816
38114
|
if (p.includes("*")) {
|
|
37817
38115
|
const home = os21.homedir();
|
|
37818
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
38116
|
+
const resolved = p.replace(/\*/g, home.split(path18.sep).pop() || "");
|
|
37819
38117
|
if (fs10.existsSync(resolved)) return resolved;
|
|
37820
38118
|
} else {
|
|
37821
38119
|
if (fs10.existsSync(p)) return p;
|
|
@@ -37825,7 +38123,7 @@ function checkPathExists2(paths) {
|
|
|
37825
38123
|
}
|
|
37826
38124
|
function getMacAppVersion(appPath) {
|
|
37827
38125
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
37828
|
-
const plistPath =
|
|
38126
|
+
const plistPath = path18.join(appPath, "Contents", "Info.plist");
|
|
37829
38127
|
if (!fs10.existsSync(plistPath)) return null;
|
|
37830
38128
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
37831
38129
|
return raw || null;
|
|
@@ -37851,7 +38149,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
37851
38149
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
37852
38150
|
let resolvedBin = cliBin;
|
|
37853
38151
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
37854
|
-
const bundled =
|
|
38152
|
+
const bundled = path18.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
37855
38153
|
if (provider.cli && fs10.existsSync(bundled)) resolvedBin = bundled;
|
|
37856
38154
|
}
|
|
37857
38155
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -37888,16 +38186,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
37888
38186
|
}
|
|
37889
38187
|
return results;
|
|
37890
38188
|
}
|
|
37891
|
-
var fs10,
|
|
38189
|
+
var fs10, path18, os21, import_child_process9, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
37892
38190
|
var init_version_archive = __esm({
|
|
37893
38191
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
37894
38192
|
"use strict";
|
|
37895
38193
|
fs10 = __toESM(require("fs"));
|
|
37896
|
-
|
|
38194
|
+
path18 = __toESM(require("path"));
|
|
37897
38195
|
os21 = __toESM(require("os"));
|
|
37898
38196
|
import_child_process9 = require("child_process");
|
|
37899
38197
|
import_os3 = require("os");
|
|
37900
|
-
ARCHIVE_PATH =
|
|
38198
|
+
ARCHIVE_PATH = path18.join(os21.homedir(), ".adhdev", "version-history.json");
|
|
37901
38199
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
37902
38200
|
VersionArchive = class {
|
|
37903
38201
|
history = {};
|
|
@@ -37944,7 +38242,7 @@ var init_version_archive = __esm({
|
|
|
37944
38242
|
}
|
|
37945
38243
|
save() {
|
|
37946
38244
|
try {
|
|
37947
|
-
fs10.mkdirSync(
|
|
38245
|
+
fs10.mkdirSync(path18.dirname(ARCHIVE_PATH), { recursive: true });
|
|
37948
38246
|
fs10.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
37949
38247
|
} catch {
|
|
37950
38248
|
}
|
|
@@ -38472,17 +38770,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
38472
38770
|
return;
|
|
38473
38771
|
}
|
|
38474
38772
|
let scriptsPath = "";
|
|
38475
|
-
const directScripts =
|
|
38773
|
+
const directScripts = path19.join(dir, "scripts.js");
|
|
38476
38774
|
if (fs11.existsSync(directScripts)) {
|
|
38477
38775
|
scriptsPath = directScripts;
|
|
38478
38776
|
} else {
|
|
38479
|
-
const scriptsDir =
|
|
38777
|
+
const scriptsDir = path19.join(dir, "scripts");
|
|
38480
38778
|
if (fs11.existsSync(scriptsDir)) {
|
|
38481
38779
|
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
38482
|
-
return fs11.statSync(
|
|
38780
|
+
return fs11.statSync(path19.join(scriptsDir, d)).isDirectory();
|
|
38483
38781
|
}).sort().reverse();
|
|
38484
38782
|
for (const ver of versions) {
|
|
38485
|
-
const p =
|
|
38783
|
+
const p = path19.join(scriptsDir, ver, "scripts.js");
|
|
38486
38784
|
if (fs11.existsSync(p)) {
|
|
38487
38785
|
scriptsPath = p;
|
|
38488
38786
|
break;
|
|
@@ -39308,12 +39606,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
39308
39606
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
39309
39607
|
}
|
|
39310
39608
|
}
|
|
39311
|
-
var fs11,
|
|
39609
|
+
var fs11, path19;
|
|
39312
39610
|
var init_dev_cdp_handlers = __esm({
|
|
39313
39611
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
39314
39612
|
"use strict";
|
|
39315
39613
|
fs11 = __toESM(require("fs"));
|
|
39316
|
-
|
|
39614
|
+
path19 = __toESM(require("path"));
|
|
39317
39615
|
init_logger();
|
|
39318
39616
|
}
|
|
39319
39617
|
});
|
|
@@ -39328,11 +39626,11 @@ function getCliFixtureDir(ctx, type) {
|
|
|
39328
39626
|
if (!providerDir) {
|
|
39329
39627
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
39330
39628
|
}
|
|
39331
|
-
return
|
|
39629
|
+
return path20.join(providerDir, "fixtures");
|
|
39332
39630
|
}
|
|
39333
39631
|
function readCliFixture(ctx, type, name) {
|
|
39334
39632
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
39335
|
-
const filePath =
|
|
39633
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
39336
39634
|
if (!fs12.existsSync(filePath)) {
|
|
39337
39635
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
39338
39636
|
}
|
|
@@ -40099,7 +40397,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
40099
40397
|
},
|
|
40100
40398
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
40101
40399
|
};
|
|
40102
|
-
const filePath =
|
|
40400
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
40103
40401
|
fs12.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
40104
40402
|
ctx.json(res, 200, {
|
|
40105
40403
|
saved: true,
|
|
@@ -40123,7 +40421,7 @@ async function handleCliFixtureList(ctx, type, _req, res) {
|
|
|
40123
40421
|
return;
|
|
40124
40422
|
}
|
|
40125
40423
|
const fixtures = fs12.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
40126
|
-
const fullPath =
|
|
40424
|
+
const fullPath = path20.join(fixtureDir, file2);
|
|
40127
40425
|
try {
|
|
40128
40426
|
const raw = JSON.parse(fs12.readFileSync(fullPath, "utf-8"));
|
|
40129
40427
|
return {
|
|
@@ -40256,12 +40554,12 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
40256
40554
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
40257
40555
|
}
|
|
40258
40556
|
}
|
|
40259
|
-
var fs12,
|
|
40557
|
+
var fs12, path20;
|
|
40260
40558
|
var init_dev_cli_debug = __esm({
|
|
40261
40559
|
"../../oss/packages/daemon-core/src/daemon/dev-cli-debug.ts"() {
|
|
40262
40560
|
"use strict";
|
|
40263
40561
|
fs12 = __toESM(require("fs"));
|
|
40264
|
-
|
|
40562
|
+
path20 = __toESM(require("path"));
|
|
40265
40563
|
}
|
|
40266
40564
|
});
|
|
40267
40565
|
|
|
@@ -40321,22 +40619,22 @@ function getLatestScriptVersionDir(scriptsDir) {
|
|
|
40321
40619
|
if (!fs13.existsSync(scriptsDir)) return null;
|
|
40322
40620
|
const versions = fs13.readdirSync(scriptsDir).filter((d) => {
|
|
40323
40621
|
try {
|
|
40324
|
-
return fs13.statSync(
|
|
40622
|
+
return fs13.statSync(path21.join(scriptsDir, d)).isDirectory();
|
|
40325
40623
|
} catch {
|
|
40326
40624
|
return false;
|
|
40327
40625
|
}
|
|
40328
40626
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
40329
40627
|
if (versions.length === 0) return null;
|
|
40330
|
-
return
|
|
40628
|
+
return path21.join(scriptsDir, versions[0]);
|
|
40331
40629
|
}
|
|
40332
40630
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
40333
|
-
const canonicalUserDir =
|
|
40334
|
-
const desiredDir = requestedDir ?
|
|
40335
|
-
const upstreamRoot =
|
|
40336
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
40631
|
+
const canonicalUserDir = path21.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
40632
|
+
const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
|
|
40633
|
+
const upstreamRoot = path21.resolve(ctx.providerLoader.getUpstreamDir());
|
|
40634
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
|
|
40337
40635
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
40338
40636
|
}
|
|
40339
|
-
if (
|
|
40637
|
+
if (path21.basename(desiredDir) !== type) {
|
|
40340
40638
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
40341
40639
|
}
|
|
40342
40640
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -40344,11 +40642,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
40344
40642
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
40345
40643
|
}
|
|
40346
40644
|
if (!fs13.existsSync(desiredDir)) {
|
|
40347
|
-
fs13.mkdirSync(
|
|
40645
|
+
fs13.mkdirSync(path21.dirname(desiredDir), { recursive: true });
|
|
40348
40646
|
fs13.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
40349
40647
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
40350
40648
|
}
|
|
40351
|
-
const providerJson =
|
|
40649
|
+
const providerJson = path21.join(desiredDir, "provider.json");
|
|
40352
40650
|
if (!fs13.existsSync(providerJson)) {
|
|
40353
40651
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
40354
40652
|
}
|
|
@@ -40359,13 +40657,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
|
40359
40657
|
const refDir = ctx.findProviderDir(referenceType);
|
|
40360
40658
|
if (!refDir || !fs13.existsSync(refDir)) return {};
|
|
40361
40659
|
const referenceScripts = {};
|
|
40362
|
-
const scriptsDir =
|
|
40660
|
+
const scriptsDir = path21.join(refDir, "scripts");
|
|
40363
40661
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
40364
40662
|
if (!latestDir) return referenceScripts;
|
|
40365
40663
|
for (const file2 of fs13.readdirSync(latestDir)) {
|
|
40366
40664
|
if (!file2.endsWith(".js")) continue;
|
|
40367
40665
|
try {
|
|
40368
|
-
referenceScripts[file2] = fs13.readFileSync(
|
|
40666
|
+
referenceScripts[file2] = fs13.readFileSync(path21.join(latestDir, file2), "utf-8");
|
|
40369
40667
|
} catch {
|
|
40370
40668
|
}
|
|
40371
40669
|
}
|
|
@@ -40473,9 +40771,9 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
40473
40771
|
});
|
|
40474
40772
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
40475
40773
|
const prompt2 = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
40476
|
-
const tmpDir =
|
|
40774
|
+
const tmpDir = path21.join(os23.tmpdir(), "adhdev-autoimpl");
|
|
40477
40775
|
if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
|
|
40478
|
-
const promptFile =
|
|
40776
|
+
const promptFile = path21.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
40479
40777
|
fs13.writeFileSync(promptFile, prompt2, "utf-8");
|
|
40480
40778
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt2.length} chars)`);
|
|
40481
40779
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -40912,7 +41210,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40912
41210
|
setMode: "set_mode.js"
|
|
40913
41211
|
};
|
|
40914
41212
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
40915
|
-
const scriptsDir =
|
|
41213
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
40916
41214
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
40917
41215
|
if (latestScriptsDir) {
|
|
40918
41216
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -40923,7 +41221,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40923
41221
|
for (const file2 of fs13.readdirSync(latestScriptsDir)) {
|
|
40924
41222
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
40925
41223
|
try {
|
|
40926
|
-
const content = fs13.readFileSync(
|
|
41224
|
+
const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
40927
41225
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
40928
41226
|
lines.push("```javascript");
|
|
40929
41227
|
lines.push(content);
|
|
@@ -40940,7 +41238,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40940
41238
|
lines.push("");
|
|
40941
41239
|
for (const file2 of refFiles) {
|
|
40942
41240
|
try {
|
|
40943
|
-
const content = fs13.readFileSync(
|
|
41241
|
+
const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
40944
41242
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
40945
41243
|
lines.push("```javascript");
|
|
40946
41244
|
lines.push(content);
|
|
@@ -40981,10 +41279,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40981
41279
|
lines.push("");
|
|
40982
41280
|
}
|
|
40983
41281
|
}
|
|
40984
|
-
const docsDir =
|
|
41282
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
40985
41283
|
const loadGuide = (name) => {
|
|
40986
41284
|
try {
|
|
40987
|
-
const p =
|
|
41285
|
+
const p = path21.join(docsDir, name);
|
|
40988
41286
|
if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
|
|
40989
41287
|
} catch {
|
|
40990
41288
|
}
|
|
@@ -41221,7 +41519,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41221
41519
|
parseApproval: "parse_approval.js"
|
|
41222
41520
|
};
|
|
41223
41521
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
41224
|
-
const scriptsDir =
|
|
41522
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
41225
41523
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
41226
41524
|
if (latestScriptsDir) {
|
|
41227
41525
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41233,7 +41531,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41233
41531
|
if (!file2.endsWith(".js")) continue;
|
|
41234
41532
|
if (!targetFileNames.has(file2)) continue;
|
|
41235
41533
|
try {
|
|
41236
|
-
const content = fs13.readFileSync(
|
|
41534
|
+
const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
41237
41535
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41238
41536
|
lines.push("```javascript");
|
|
41239
41537
|
lines.push(content);
|
|
@@ -41249,7 +41547,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41249
41547
|
lines.push("");
|
|
41250
41548
|
for (const file2 of refFiles) {
|
|
41251
41549
|
try {
|
|
41252
|
-
const content = fs13.readFileSync(
|
|
41550
|
+
const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
41253
41551
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41254
41552
|
lines.push("```javascript");
|
|
41255
41553
|
lines.push(content);
|
|
@@ -41282,10 +41580,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41282
41580
|
lines.push("");
|
|
41283
41581
|
}
|
|
41284
41582
|
}
|
|
41285
|
-
const docsDir =
|
|
41583
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
41286
41584
|
const loadGuide = (name) => {
|
|
41287
41585
|
try {
|
|
41288
|
-
const p =
|
|
41586
|
+
const p = path21.join(docsDir, name);
|
|
41289
41587
|
if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
|
|
41290
41588
|
} catch {
|
|
41291
41589
|
}
|
|
@@ -41597,12 +41895,12 @@ data: ${JSON.stringify(msg.data)}
|
|
|
41597
41895
|
}
|
|
41598
41896
|
}
|
|
41599
41897
|
}
|
|
41600
|
-
var fs13,
|
|
41898
|
+
var fs13, path21, os23;
|
|
41601
41899
|
var init_dev_auto_implement = __esm({
|
|
41602
41900
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
41603
41901
|
"use strict";
|
|
41604
41902
|
fs13 = __toESM(require("fs"));
|
|
41605
|
-
|
|
41903
|
+
path21 = __toESM(require("path"));
|
|
41606
41904
|
os23 = __toESM(require("os"));
|
|
41607
41905
|
init_dev_server();
|
|
41608
41906
|
init_dev_cli_debug();
|
|
@@ -41642,13 +41940,13 @@ function toProviderListEntry(provider) {
|
|
|
41642
41940
|
}
|
|
41643
41941
|
return base;
|
|
41644
41942
|
}
|
|
41645
|
-
var http2, fs14,
|
|
41943
|
+
var http2, fs14, path23, DEV_SERVER_PORT, DevServer;
|
|
41646
41944
|
var init_dev_server = __esm({
|
|
41647
41945
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
41648
41946
|
"use strict";
|
|
41649
41947
|
http2 = __toESM(require("http"));
|
|
41650
41948
|
fs14 = __toESM(require("fs"));
|
|
41651
|
-
|
|
41949
|
+
path23 = __toESM(require("path"));
|
|
41652
41950
|
init_provider_schema();
|
|
41653
41951
|
init_config();
|
|
41654
41952
|
init_provider_source_config();
|
|
@@ -41760,8 +42058,8 @@ var init_dev_server = __esm({
|
|
|
41760
42058
|
}
|
|
41761
42059
|
getEndpointList() {
|
|
41762
42060
|
return this.routes.map((r) => {
|
|
41763
|
-
const
|
|
41764
|
-
return `${r.method.padEnd(5)} ${
|
|
42061
|
+
const path35 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
42062
|
+
return `${r.method.padEnd(5)} ${path35}`;
|
|
41765
42063
|
});
|
|
41766
42064
|
}
|
|
41767
42065
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -42042,12 +42340,12 @@ var init_dev_server = __esm({
|
|
|
42042
42340
|
// ─── DevConsole SPA ───
|
|
42043
42341
|
getConsoleDistDir() {
|
|
42044
42342
|
const candidates = [
|
|
42045
|
-
|
|
42046
|
-
|
|
42047
|
-
|
|
42343
|
+
path23.resolve(__dirname, "../../web-devconsole/dist"),
|
|
42344
|
+
path23.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
42345
|
+
path23.join(process.cwd(), "packages/web-devconsole/dist")
|
|
42048
42346
|
];
|
|
42049
42347
|
for (const dir of candidates) {
|
|
42050
|
-
if (fs14.existsSync(
|
|
42348
|
+
if (fs14.existsSync(path23.join(dir, "index.html"))) return dir;
|
|
42051
42349
|
}
|
|
42052
42350
|
return null;
|
|
42053
42351
|
}
|
|
@@ -42057,7 +42355,7 @@ var init_dev_server = __esm({
|
|
|
42057
42355
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
42058
42356
|
return;
|
|
42059
42357
|
}
|
|
42060
|
-
const htmlPath =
|
|
42358
|
+
const htmlPath = path23.join(distDir, "index.html");
|
|
42061
42359
|
try {
|
|
42062
42360
|
const html = fs14.readFileSync(htmlPath, "utf-8");
|
|
42063
42361
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -42082,15 +42380,15 @@ var init_dev_server = __esm({
|
|
|
42082
42380
|
this.json(res, 404, { error: "Not found" });
|
|
42083
42381
|
return;
|
|
42084
42382
|
}
|
|
42085
|
-
const safePath =
|
|
42086
|
-
const filePath =
|
|
42383
|
+
const safePath = path23.normalize(pathname).replace(/^\.\.\//, "");
|
|
42384
|
+
const filePath = path23.join(distDir, safePath);
|
|
42087
42385
|
if (!filePath.startsWith(distDir)) {
|
|
42088
42386
|
this.json(res, 403, { error: "Forbidden" });
|
|
42089
42387
|
return;
|
|
42090
42388
|
}
|
|
42091
42389
|
try {
|
|
42092
42390
|
const content = fs14.readFileSync(filePath);
|
|
42093
|
-
const ext =
|
|
42391
|
+
const ext = path23.extname(filePath);
|
|
42094
42392
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
42095
42393
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
42096
42394
|
res.end(content);
|
|
@@ -42203,9 +42501,9 @@ var init_dev_server = __esm({
|
|
|
42203
42501
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
42204
42502
|
if (entry.isDirectory()) {
|
|
42205
42503
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
42206
|
-
scan(
|
|
42504
|
+
scan(path23.join(d, entry.name), rel);
|
|
42207
42505
|
} else {
|
|
42208
|
-
const stat4 = fs14.statSync(
|
|
42506
|
+
const stat4 = fs14.statSync(path23.join(d, entry.name));
|
|
42209
42507
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
42210
42508
|
}
|
|
42211
42509
|
}
|
|
@@ -42228,7 +42526,7 @@ var init_dev_server = __esm({
|
|
|
42228
42526
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42229
42527
|
return;
|
|
42230
42528
|
}
|
|
42231
|
-
const fullPath =
|
|
42529
|
+
const fullPath = path23.resolve(dir, path23.normalize(filePath));
|
|
42232
42530
|
if (!fullPath.startsWith(dir)) {
|
|
42233
42531
|
this.json(res, 403, { error: "Forbidden" });
|
|
42234
42532
|
return;
|
|
@@ -42253,14 +42551,14 @@ var init_dev_server = __esm({
|
|
|
42253
42551
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42254
42552
|
return;
|
|
42255
42553
|
}
|
|
42256
|
-
const fullPath =
|
|
42554
|
+
const fullPath = path23.resolve(dir, path23.normalize(filePath));
|
|
42257
42555
|
if (!fullPath.startsWith(dir)) {
|
|
42258
42556
|
this.json(res, 403, { error: "Forbidden" });
|
|
42259
42557
|
return;
|
|
42260
42558
|
}
|
|
42261
42559
|
try {
|
|
42262
42560
|
if (fs14.existsSync(fullPath)) fs14.copyFileSync(fullPath, fullPath + ".bak");
|
|
42263
|
-
fs14.mkdirSync(
|
|
42561
|
+
fs14.mkdirSync(path23.dirname(fullPath), { recursive: true });
|
|
42264
42562
|
fs14.writeFileSync(fullPath, content, "utf-8");
|
|
42265
42563
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
42266
42564
|
this.providerLoader.reload();
|
|
@@ -42277,7 +42575,7 @@ var init_dev_server = __esm({
|
|
|
42277
42575
|
return;
|
|
42278
42576
|
}
|
|
42279
42577
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
42280
|
-
const p =
|
|
42578
|
+
const p = path23.join(dir, name);
|
|
42281
42579
|
if (fs14.existsSync(p)) {
|
|
42282
42580
|
const source = fs14.readFileSync(p, "utf-8");
|
|
42283
42581
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -42298,8 +42596,8 @@ var init_dev_server = __esm({
|
|
|
42298
42596
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
42299
42597
|
return;
|
|
42300
42598
|
}
|
|
42301
|
-
const target = fs14.existsSync(
|
|
42302
|
-
const targetPath =
|
|
42599
|
+
const target = fs14.existsSync(path23.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
42600
|
+
const targetPath = path23.join(dir, target);
|
|
42303
42601
|
try {
|
|
42304
42602
|
if (fs14.existsSync(targetPath)) fs14.copyFileSync(targetPath, targetPath + ".bak");
|
|
42305
42603
|
fs14.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -42446,7 +42744,7 @@ var init_dev_server = __esm({
|
|
|
42446
42744
|
}
|
|
42447
42745
|
let targetDir;
|
|
42448
42746
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
42449
|
-
const jsonPath =
|
|
42747
|
+
const jsonPath = path23.join(targetDir, "provider.json");
|
|
42450
42748
|
if (fs14.existsSync(jsonPath)) {
|
|
42451
42749
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
42452
42750
|
return;
|
|
@@ -42458,8 +42756,8 @@ var init_dev_server = __esm({
|
|
|
42458
42756
|
const createdFiles = ["provider.json"];
|
|
42459
42757
|
if (result.files) {
|
|
42460
42758
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
42461
|
-
const fullPath =
|
|
42462
|
-
fs14.mkdirSync(
|
|
42759
|
+
const fullPath = path23.join(targetDir, relPath);
|
|
42760
|
+
fs14.mkdirSync(path23.dirname(fullPath), { recursive: true });
|
|
42463
42761
|
fs14.writeFileSync(fullPath, content, "utf-8");
|
|
42464
42762
|
createdFiles.push(relPath);
|
|
42465
42763
|
}
|
|
@@ -42512,22 +42810,22 @@ var init_dev_server = __esm({
|
|
|
42512
42810
|
if (!fs14.existsSync(scriptsDir)) return null;
|
|
42513
42811
|
const versions = fs14.readdirSync(scriptsDir).filter((d) => {
|
|
42514
42812
|
try {
|
|
42515
|
-
return fs14.statSync(
|
|
42813
|
+
return fs14.statSync(path23.join(scriptsDir, d)).isDirectory();
|
|
42516
42814
|
} catch {
|
|
42517
42815
|
return false;
|
|
42518
42816
|
}
|
|
42519
42817
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
42520
42818
|
if (versions.length === 0) return null;
|
|
42521
|
-
return
|
|
42819
|
+
return path23.join(scriptsDir, versions[0]);
|
|
42522
42820
|
}
|
|
42523
42821
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
42524
|
-
const canonicalUserDir =
|
|
42525
|
-
const desiredDir = requestedDir ?
|
|
42526
|
-
const upstreamRoot =
|
|
42527
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
42822
|
+
const canonicalUserDir = path23.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
42823
|
+
const desiredDir = requestedDir ? path23.resolve(requestedDir) : canonicalUserDir;
|
|
42824
|
+
const upstreamRoot = path23.resolve(this.providerLoader.getUpstreamDir());
|
|
42825
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path23.sep}`)) {
|
|
42528
42826
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
42529
42827
|
}
|
|
42530
|
-
if (
|
|
42828
|
+
if (path23.basename(desiredDir) !== type) {
|
|
42531
42829
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
42532
42830
|
}
|
|
42533
42831
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -42535,11 +42833,11 @@ var init_dev_server = __esm({
|
|
|
42535
42833
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
42536
42834
|
}
|
|
42537
42835
|
if (!fs14.existsSync(desiredDir)) {
|
|
42538
|
-
fs14.mkdirSync(
|
|
42836
|
+
fs14.mkdirSync(path23.dirname(desiredDir), { recursive: true });
|
|
42539
42837
|
fs14.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
42540
42838
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
42541
42839
|
}
|
|
42542
|
-
const providerJson =
|
|
42840
|
+
const providerJson = path23.join(desiredDir, "provider.json");
|
|
42543
42841
|
if (!fs14.existsSync(providerJson)) {
|
|
42544
42842
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
42545
42843
|
}
|
|
@@ -42575,7 +42873,7 @@ var init_dev_server = __esm({
|
|
|
42575
42873
|
setMode: "set_mode.js"
|
|
42576
42874
|
};
|
|
42577
42875
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
42578
|
-
const scriptsDir =
|
|
42876
|
+
const scriptsDir = path23.join(providerDir, "scripts");
|
|
42579
42877
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
42580
42878
|
if (latestScriptsDir) {
|
|
42581
42879
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -42586,7 +42884,7 @@ var init_dev_server = __esm({
|
|
|
42586
42884
|
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
42587
42885
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
42588
42886
|
try {
|
|
42589
|
-
const content = fs14.readFileSync(
|
|
42887
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
42590
42888
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
42591
42889
|
lines.push("```javascript");
|
|
42592
42890
|
lines.push(content);
|
|
@@ -42603,7 +42901,7 @@ var init_dev_server = __esm({
|
|
|
42603
42901
|
lines.push("");
|
|
42604
42902
|
for (const file2 of refFiles) {
|
|
42605
42903
|
try {
|
|
42606
|
-
const content = fs14.readFileSync(
|
|
42904
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
42607
42905
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
42608
42906
|
lines.push("```javascript");
|
|
42609
42907
|
lines.push(content);
|
|
@@ -42644,10 +42942,10 @@ var init_dev_server = __esm({
|
|
|
42644
42942
|
lines.push("");
|
|
42645
42943
|
}
|
|
42646
42944
|
}
|
|
42647
|
-
const docsDir =
|
|
42945
|
+
const docsDir = path23.join(providerDir, "../../docs");
|
|
42648
42946
|
const loadGuide = (name) => {
|
|
42649
42947
|
try {
|
|
42650
|
-
const p =
|
|
42948
|
+
const p = path23.join(docsDir, name);
|
|
42651
42949
|
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
42652
42950
|
} catch {
|
|
42653
42951
|
}
|
|
@@ -42821,7 +43119,7 @@ var init_dev_server = __esm({
|
|
|
42821
43119
|
parseApproval: "parse_approval.js"
|
|
42822
43120
|
};
|
|
42823
43121
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
42824
|
-
const scriptsDir =
|
|
43122
|
+
const scriptsDir = path23.join(providerDir, "scripts");
|
|
42825
43123
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
42826
43124
|
if (latestScriptsDir) {
|
|
42827
43125
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -42833,7 +43131,7 @@ var init_dev_server = __esm({
|
|
|
42833
43131
|
if (!file2.endsWith(".js")) continue;
|
|
42834
43132
|
if (!targetFileNames.has(file2)) continue;
|
|
42835
43133
|
try {
|
|
42836
|
-
const content = fs14.readFileSync(
|
|
43134
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
42837
43135
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
42838
43136
|
lines.push("```javascript");
|
|
42839
43137
|
lines.push(content);
|
|
@@ -42849,7 +43147,7 @@ var init_dev_server = __esm({
|
|
|
42849
43147
|
lines.push("");
|
|
42850
43148
|
for (const file2 of refFiles) {
|
|
42851
43149
|
try {
|
|
42852
|
-
const content = fs14.readFileSync(
|
|
43150
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
42853
43151
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
42854
43152
|
lines.push("```javascript");
|
|
42855
43153
|
lines.push(content);
|
|
@@ -42882,10 +43180,10 @@ var init_dev_server = __esm({
|
|
|
42882
43180
|
lines.push("");
|
|
42883
43181
|
}
|
|
42884
43182
|
}
|
|
42885
|
-
const docsDir =
|
|
43183
|
+
const docsDir = path23.join(providerDir, "../../docs");
|
|
42886
43184
|
const loadGuide = (name) => {
|
|
42887
43185
|
try {
|
|
42888
|
-
const p =
|
|
43186
|
+
const p = path23.join(docsDir, name);
|
|
42889
43187
|
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
42890
43188
|
} catch {
|
|
42891
43189
|
}
|
|
@@ -55793,15 +56091,15 @@ var require_route = __commonJS({
|
|
|
55793
56091
|
};
|
|
55794
56092
|
}
|
|
55795
56093
|
function wrapConversion(toModel, graph) {
|
|
55796
|
-
const
|
|
56094
|
+
const path35 = [graph[toModel].parent, toModel];
|
|
55797
56095
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
55798
56096
|
let cur = graph[toModel].parent;
|
|
55799
56097
|
while (graph[cur].parent) {
|
|
55800
|
-
|
|
56098
|
+
path35.unshift(graph[cur].parent);
|
|
55801
56099
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
55802
56100
|
cur = graph[cur].parent;
|
|
55803
56101
|
}
|
|
55804
|
-
fn.conversion =
|
|
56102
|
+
fn.conversion = path35;
|
|
55805
56103
|
return fn;
|
|
55806
56104
|
}
|
|
55807
56105
|
module2.exports = function(fromModel) {
|
|
@@ -73671,9 +73969,9 @@ var init_prompt = __esm({
|
|
|
73671
73969
|
init_utils();
|
|
73672
73970
|
init_baseUI();
|
|
73673
73971
|
_ = {
|
|
73674
|
-
set: (obj,
|
|
73972
|
+
set: (obj, path35 = "", value) => {
|
|
73675
73973
|
let pointer = obj;
|
|
73676
|
-
|
|
73974
|
+
path35.split(".").forEach((key, index, arr) => {
|
|
73677
73975
|
if (key === "__proto__" || key === "constructor") return;
|
|
73678
73976
|
if (index === arr.length - 1) {
|
|
73679
73977
|
pointer[key] = value;
|
|
@@ -73683,8 +73981,8 @@ var init_prompt = __esm({
|
|
|
73683
73981
|
pointer = pointer[key];
|
|
73684
73982
|
});
|
|
73685
73983
|
},
|
|
73686
|
-
get: (obj,
|
|
73687
|
-
const travel = (regexp) => String.prototype.split.call(
|
|
73984
|
+
get: (obj, path35 = "", defaultValue) => {
|
|
73985
|
+
const travel = (regexp) => String.prototype.split.call(path35, regexp).filter(Boolean).reduce(
|
|
73688
73986
|
// @ts-expect-error implicit any on res[key]
|
|
73689
73987
|
(res, key) => res !== null && res !== void 0 ? res[key] : res,
|
|
73690
73988
|
obj
|
|
@@ -76577,12 +76875,12 @@ var init_peer_connection_manager = __esm({
|
|
|
76577
76875
|
});
|
|
76578
76876
|
|
|
76579
76877
|
// src/daemon-p2p/index.ts
|
|
76580
|
-
var fs20,
|
|
76878
|
+
var fs20, path26, import_node_module2, esmRequire, DaemonP2PSender;
|
|
76581
76879
|
var init_daemon_p2p = __esm({
|
|
76582
76880
|
"src/daemon-p2p/index.ts"() {
|
|
76583
76881
|
"use strict";
|
|
76584
76882
|
fs20 = __toESM(require("fs"));
|
|
76585
|
-
|
|
76883
|
+
path26 = __toESM(require("path"));
|
|
76586
76884
|
import_node_module2 = require("module");
|
|
76587
76885
|
init_data_channel_router();
|
|
76588
76886
|
init_screenshot_sender();
|
|
@@ -76655,15 +76953,15 @@ ${e?.stack || ""}`);
|
|
|
76655
76953
|
const prebuildKey = `${platform13}-${arch4}`;
|
|
76656
76954
|
try {
|
|
76657
76955
|
const candidates = [
|
|
76658
|
-
|
|
76659
|
-
|
|
76660
|
-
|
|
76956
|
+
path26.join(__dirname, "node_modules", "node-datachannel"),
|
|
76957
|
+
path26.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
76958
|
+
path26.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
76661
76959
|
];
|
|
76662
76960
|
for (const candidate of candidates) {
|
|
76663
|
-
const prebuildPath =
|
|
76961
|
+
const prebuildPath = path26.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
76664
76962
|
if (fs20.existsSync(prebuildPath)) {
|
|
76665
|
-
const targetDir =
|
|
76666
|
-
const targetPath =
|
|
76963
|
+
const targetDir = path26.join(candidate, "build", "Release");
|
|
76964
|
+
const targetPath = path26.join(targetDir, "node_datachannel.node");
|
|
76667
76965
|
fs20.mkdirSync(targetDir, { recursive: true });
|
|
76668
76966
|
fs20.copyFileSync(prebuildPath, targetPath);
|
|
76669
76967
|
try {
|
|
@@ -76985,16 +77283,16 @@ var require_filesystem = __commonJS({
|
|
|
76985
77283
|
var LDD_PATH = "/usr/bin/ldd";
|
|
76986
77284
|
var SELF_PATH = "/proc/self/exe";
|
|
76987
77285
|
var MAX_LENGTH = 2048;
|
|
76988
|
-
var readFileSync20 = (
|
|
76989
|
-
const fd = fs27.openSync(
|
|
77286
|
+
var readFileSync20 = (path35) => {
|
|
77287
|
+
const fd = fs27.openSync(path35, "r");
|
|
76990
77288
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
76991
77289
|
const bytesRead = fs27.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
76992
77290
|
fs27.close(fd, () => {
|
|
76993
77291
|
});
|
|
76994
77292
|
return buffer.subarray(0, bytesRead);
|
|
76995
77293
|
};
|
|
76996
|
-
var readFile = (
|
|
76997
|
-
fs27.open(
|
|
77294
|
+
var readFile = (path35) => new Promise((resolve17, reject) => {
|
|
77295
|
+
fs27.open(path35, "r", (err, fd) => {
|
|
76998
77296
|
if (err) {
|
|
76999
77297
|
reject(err);
|
|
77000
77298
|
} else {
|
|
@@ -77113,11 +77411,11 @@ var require_detect_libc = __commonJS({
|
|
|
77113
77411
|
}
|
|
77114
77412
|
return null;
|
|
77115
77413
|
};
|
|
77116
|
-
var familyFromInterpreterPath = (
|
|
77117
|
-
if (
|
|
77118
|
-
if (
|
|
77414
|
+
var familyFromInterpreterPath = (path35) => {
|
|
77415
|
+
if (path35) {
|
|
77416
|
+
if (path35.includes("/ld-musl-")) {
|
|
77119
77417
|
return MUSL;
|
|
77120
|
-
} else if (
|
|
77418
|
+
} else if (path35.includes("/ld-linux-")) {
|
|
77121
77419
|
return GLIBC;
|
|
77122
77420
|
}
|
|
77123
77421
|
}
|
|
@@ -77164,8 +77462,8 @@ var require_detect_libc = __commonJS({
|
|
|
77164
77462
|
cachedFamilyInterpreter = null;
|
|
77165
77463
|
try {
|
|
77166
77464
|
const selfContent = await readFile(SELF_PATH);
|
|
77167
|
-
const
|
|
77168
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
77465
|
+
const path35 = interpreterPath(selfContent);
|
|
77466
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path35);
|
|
77169
77467
|
} catch (e) {
|
|
77170
77468
|
}
|
|
77171
77469
|
return cachedFamilyInterpreter;
|
|
@@ -77177,8 +77475,8 @@ var require_detect_libc = __commonJS({
|
|
|
77177
77475
|
cachedFamilyInterpreter = null;
|
|
77178
77476
|
try {
|
|
77179
77477
|
const selfContent = readFileSync20(SELF_PATH);
|
|
77180
|
-
const
|
|
77181
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
77478
|
+
const path35 = interpreterPath(selfContent);
|
|
77479
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path35);
|
|
77182
77480
|
} catch (e) {
|
|
77183
77481
|
}
|
|
77184
77482
|
return cachedFamilyInterpreter;
|
|
@@ -78897,18 +79195,18 @@ var require_sharp = __commonJS({
|
|
|
78897
79195
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
78898
79196
|
"@img/sharp-wasm32/sharp.node"
|
|
78899
79197
|
];
|
|
78900
|
-
var
|
|
79198
|
+
var path35;
|
|
78901
79199
|
var sharp;
|
|
78902
79200
|
var errors = [];
|
|
78903
|
-
for (
|
|
79201
|
+
for (path35 of paths) {
|
|
78904
79202
|
try {
|
|
78905
|
-
sharp = require(
|
|
79203
|
+
sharp = require(path35);
|
|
78906
79204
|
break;
|
|
78907
79205
|
} catch (err) {
|
|
78908
79206
|
errors.push(err);
|
|
78909
79207
|
}
|
|
78910
79208
|
}
|
|
78911
|
-
if (sharp &&
|
|
79209
|
+
if (sharp && path35.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
78912
79210
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
78913
79211
|
err.code = "Unsupported CPU";
|
|
78914
79212
|
errors.push(err);
|
|
@@ -81817,15 +82115,15 @@ var require_color = __commonJS({
|
|
|
81817
82115
|
};
|
|
81818
82116
|
}
|
|
81819
82117
|
function wrapConversion(toModel, graph) {
|
|
81820
|
-
const
|
|
82118
|
+
const path35 = [graph[toModel].parent, toModel];
|
|
81821
82119
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
81822
82120
|
let cur = graph[toModel].parent;
|
|
81823
82121
|
while (graph[cur].parent) {
|
|
81824
|
-
|
|
82122
|
+
path35.unshift(graph[cur].parent);
|
|
81825
82123
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
81826
82124
|
cur = graph[cur].parent;
|
|
81827
82125
|
}
|
|
81828
|
-
fn.conversion =
|
|
82126
|
+
fn.conversion = path35;
|
|
81829
82127
|
return fn;
|
|
81830
82128
|
}
|
|
81831
82129
|
function route(fromModel) {
|
|
@@ -82442,7 +82740,7 @@ var require_channel = __commonJS({
|
|
|
82442
82740
|
var require_output = __commonJS({
|
|
82443
82741
|
"../../node_modules/sharp/lib/output.js"(exports2, module2) {
|
|
82444
82742
|
"use strict";
|
|
82445
|
-
var
|
|
82743
|
+
var path35 = require("path");
|
|
82446
82744
|
var is = require_is();
|
|
82447
82745
|
var sharp = require_sharp();
|
|
82448
82746
|
var formats = /* @__PURE__ */ new Map([
|
|
@@ -82473,9 +82771,9 @@ var require_output = __commonJS({
|
|
|
82473
82771
|
let err;
|
|
82474
82772
|
if (!is.string(fileOut)) {
|
|
82475
82773
|
err = new Error("Missing output file path");
|
|
82476
|
-
} else if (is.string(this.options.input.file) &&
|
|
82774
|
+
} else if (is.string(this.options.input.file) && path35.resolve(this.options.input.file) === path35.resolve(fileOut)) {
|
|
82477
82775
|
err = new Error("Cannot use same file for input and output");
|
|
82478
|
-
} else if (jp2Regex.test(
|
|
82776
|
+
} else if (jp2Regex.test(path35.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
82479
82777
|
err = errJp2Save();
|
|
82480
82778
|
}
|
|
82481
82779
|
if (err) {
|
|
@@ -83717,11 +84015,11 @@ function quarantineLegacyStandaloneSessions(options) {
|
|
|
83717
84015
|
const homeDir = options.homeDir || os26.homedir();
|
|
83718
84016
|
const now = options.now || (() => /* @__PURE__ */ new Date());
|
|
83719
84017
|
const isPidRunning = options.isPidRunning || defaultPidRunning;
|
|
83720
|
-
const runtimesDir =
|
|
84018
|
+
const runtimesDir = path27.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
|
|
83721
84019
|
if (!fs21.existsSync(runtimesDir)) {
|
|
83722
84020
|
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
83723
84021
|
}
|
|
83724
|
-
const candidates = fs21.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) =>
|
|
84022
|
+
const candidates = fs21.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path27.join(runtimesDir, name));
|
|
83725
84023
|
let movedCount = 0;
|
|
83726
84024
|
let skippedActiveCount = 0;
|
|
83727
84025
|
let backupDir = null;
|
|
@@ -83739,26 +84037,26 @@ function quarantineLegacyStandaloneSessions(options) {
|
|
|
83739
84037
|
continue;
|
|
83740
84038
|
}
|
|
83741
84039
|
if (!backupDir) {
|
|
83742
|
-
backupDir =
|
|
84040
|
+
backupDir = path27.join(
|
|
83743
84041
|
homeDir,
|
|
83744
84042
|
".adhdev",
|
|
83745
84043
|
"session-host-backups",
|
|
83746
84044
|
`legacy-standalone-${options.appName}-${formatTimestamp(now())}`
|
|
83747
84045
|
);
|
|
83748
|
-
fs21.mkdirSync(
|
|
84046
|
+
fs21.mkdirSync(path27.join(backupDir, "runtimes"), { recursive: true });
|
|
83749
84047
|
}
|
|
83750
|
-
fs21.renameSync(sourcePath,
|
|
84048
|
+
fs21.renameSync(sourcePath, path27.join(backupDir, "runtimes", path27.basename(sourcePath)));
|
|
83751
84049
|
movedCount += 1;
|
|
83752
84050
|
}
|
|
83753
84051
|
return { movedCount, skippedActiveCount, backupDir };
|
|
83754
84052
|
}
|
|
83755
|
-
var fs21, os26,
|
|
84053
|
+
var fs21, os26, path27, LEGACY_STANDALONE_MANAGER_TAG;
|
|
83756
84054
|
var init_session_host_hygiene = __esm({
|
|
83757
84055
|
"src/session-host-hygiene.ts"() {
|
|
83758
84056
|
"use strict";
|
|
83759
84057
|
fs21 = __toESM(require("fs"));
|
|
83760
84058
|
os26 = __toESM(require("os"));
|
|
83761
|
-
|
|
84059
|
+
path27 = __toESM(require("path"));
|
|
83762
84060
|
init_src();
|
|
83763
84061
|
LEGACY_STANDALONE_MANAGER_TAG = "adhdev-standalone";
|
|
83764
84062
|
}
|
|
@@ -83782,8 +84080,8 @@ function buildSessionHostEnv(baseEnv) {
|
|
|
83782
84080
|
}
|
|
83783
84081
|
function resolveSessionHostEntry() {
|
|
83784
84082
|
const packagedCandidates = [
|
|
83785
|
-
|
|
83786
|
-
|
|
84083
|
+
path28.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
84084
|
+
path28.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
83787
84085
|
];
|
|
83788
84086
|
for (const candidate of packagedCandidates) {
|
|
83789
84087
|
if (fs22.existsSync(candidate)) {
|
|
@@ -83793,7 +84091,7 @@ function resolveSessionHostEntry() {
|
|
|
83793
84091
|
return require.resolve("@adhdev/session-host-daemon");
|
|
83794
84092
|
}
|
|
83795
84093
|
function getSessionHostPidFile() {
|
|
83796
|
-
return
|
|
84094
|
+
return path28.join(os27.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
83797
84095
|
}
|
|
83798
84096
|
function getSessionHostStatusPaths() {
|
|
83799
84097
|
return {
|
|
@@ -83926,9 +84224,9 @@ async function ensureSessionHostReady2() {
|
|
|
83926
84224
|
}
|
|
83927
84225
|
const spawnHost = () => {
|
|
83928
84226
|
const entry = resolveSessionHostEntry();
|
|
83929
|
-
const logDir =
|
|
84227
|
+
const logDir = path28.join(os27.homedir(), ".adhdev", "logs");
|
|
83930
84228
|
fs22.mkdirSync(logDir, { recursive: true });
|
|
83931
|
-
const logFd = fs22.openSync(
|
|
84229
|
+
const logFd = fs22.openSync(path28.join(logDir, "session-host.log"), "a");
|
|
83932
84230
|
const child = (0, import_child_process12.spawn)(process.execPath, [entry], {
|
|
83933
84231
|
detached: true,
|
|
83934
84232
|
stdio: ["ignore", logFd, logFd],
|
|
@@ -83990,14 +84288,14 @@ async function probeSessionHostStatus() {
|
|
|
83990
84288
|
};
|
|
83991
84289
|
}
|
|
83992
84290
|
}
|
|
83993
|
-
var import_child_process12, fs22, os27,
|
|
84291
|
+
var import_child_process12, fs22, os27, path28, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
|
|
83994
84292
|
var init_session_host = __esm({
|
|
83995
84293
|
"src/session-host.ts"() {
|
|
83996
84294
|
"use strict";
|
|
83997
84295
|
import_child_process12 = require("child_process");
|
|
83998
84296
|
fs22 = __toESM(require("fs"));
|
|
83999
84297
|
os27 = __toESM(require("os"));
|
|
84000
|
-
|
|
84298
|
+
path28 = __toESM(require("path"));
|
|
84001
84299
|
init_src();
|
|
84002
84300
|
init_dist();
|
|
84003
84301
|
init_session_host_hygiene();
|
|
@@ -84238,10 +84536,10 @@ function resolveDaemonPort(ref = {}) {
|
|
|
84238
84536
|
return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
|
|
84239
84537
|
}
|
|
84240
84538
|
function getDaemonPidFile(ref = {}) {
|
|
84241
|
-
const dir =
|
|
84539
|
+
const dir = path29.join(ref.homeDir || os28.homedir(), ".adhdev");
|
|
84242
84540
|
if (!fs23.existsSync(dir)) fs23.mkdirSync(dir, { recursive: true });
|
|
84243
84541
|
const port = resolveDaemonPort(ref);
|
|
84244
|
-
return
|
|
84542
|
+
return path29.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
|
|
84245
84543
|
}
|
|
84246
84544
|
function writeDaemonPid(pid, ref = {}) {
|
|
84247
84545
|
const pidFile = getDaemonPidFile(ref);
|
|
@@ -84346,7 +84644,7 @@ function stopDaemon(ref = {}) {
|
|
|
84346
84644
|
return false;
|
|
84347
84645
|
}
|
|
84348
84646
|
}
|
|
84349
|
-
var os28, fs23,
|
|
84647
|
+
var os28, fs23, path29, import_http, import_ws3, pkgVersion, AdhdevDaemon;
|
|
84350
84648
|
var init_adhdev_daemon = __esm({
|
|
84351
84649
|
"src/adhdev-daemon.ts"() {
|
|
84352
84650
|
"use strict";
|
|
@@ -84360,13 +84658,13 @@ var init_adhdev_daemon = __esm({
|
|
|
84360
84658
|
init_session_host_controller();
|
|
84361
84659
|
os28 = __toESM(require("os"));
|
|
84362
84660
|
fs23 = __toESM(require("fs"));
|
|
84363
|
-
|
|
84661
|
+
path29 = __toESM(require("path"));
|
|
84364
84662
|
import_http = require("http");
|
|
84365
84663
|
import_ws3 = require("ws");
|
|
84366
84664
|
init_source();
|
|
84367
84665
|
init_version();
|
|
84368
84666
|
init_src();
|
|
84369
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
84667
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.66" });
|
|
84370
84668
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
84371
84669
|
localHttpServer = null;
|
|
84372
84670
|
localWss = null;
|
|
@@ -86990,8 +87288,8 @@ function parsePositiveInteger(value, fallback2) {
|
|
|
86990
87288
|
return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback2;
|
|
86991
87289
|
}
|
|
86992
87290
|
function buildHistoryResumeLaunchPayload(cliType, session, overrideDir) {
|
|
86993
|
-
const
|
|
86994
|
-
const dir = typeof overrideDir === "string" && overrideDir.trim() ?
|
|
87291
|
+
const path35 = require("path");
|
|
87292
|
+
const dir = typeof overrideDir === "string" && overrideDir.trim() ? path35.resolve(overrideDir.trim()) : typeof session.workspace === "string" && session.workspace.trim() ? path35.resolve(session.workspace.trim()) : "";
|
|
86995
87293
|
if (!dir) {
|
|
86996
87294
|
throw new Error(`Saved history ${session.providerSessionId} is missing workspace metadata. Pass --dir to resume it explicitly.`);
|
|
86997
87295
|
}
|
|
@@ -87579,7 +87877,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
87579
87877
|
program2.command("uninstall").description("Completely wipe all setting, configuration, stop daemon and uninstall service").option("-f, --force", "Skip confirmation prompt").action(async (options) => {
|
|
87580
87878
|
const inquirer2 = await Promise.resolve().then(() => (init_lib(), lib_exports));
|
|
87581
87879
|
const fs27 = await import("fs");
|
|
87582
|
-
const
|
|
87880
|
+
const path35 = await import("path");
|
|
87583
87881
|
const os31 = await import("os");
|
|
87584
87882
|
const { spawnSync: spawnSync3 } = await import("child_process");
|
|
87585
87883
|
if (!options.force) {
|
|
@@ -87605,7 +87903,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
87605
87903
|
}
|
|
87606
87904
|
console.log(source_default.gray(" Removing OS background service..."));
|
|
87607
87905
|
spawnSync3(process.execPath, [process.argv[1], "service", "uninstall"], { stdio: "inherit" });
|
|
87608
|
-
const adhdevDir =
|
|
87906
|
+
const adhdevDir = path35.join(os31.homedir(), ".adhdev");
|
|
87609
87907
|
if (fs27.existsSync(adhdevDir)) {
|
|
87610
87908
|
console.log(source_default.gray(` Deleting ${adhdevDir}...`));
|
|
87611
87909
|
try {
|
|
@@ -87628,10 +87926,10 @@ init_source();
|
|
|
87628
87926
|
|
|
87629
87927
|
// src/cli/runtime-tools.ts
|
|
87630
87928
|
var fs24 = __toESM(require("fs"));
|
|
87631
|
-
var
|
|
87929
|
+
var path30 = __toESM(require("path"));
|
|
87632
87930
|
function defaultPackageRoot() {
|
|
87633
87931
|
const currentCliPath = process.argv[1] ? fs24.realpathSync.native(process.argv[1]) : process.cwd();
|
|
87634
|
-
return
|
|
87932
|
+
return path30.resolve(path30.dirname(currentCliPath), "../..");
|
|
87635
87933
|
}
|
|
87636
87934
|
function normalizePath2(value) {
|
|
87637
87935
|
return value.replace(/\\/g, "/").toLowerCase();
|
|
@@ -87640,19 +87938,19 @@ function shouldPreferSource(currentCliPath, packageRoot) {
|
|
|
87640
87938
|
const normalizedCliPath = normalizePath2(currentCliPath || "");
|
|
87641
87939
|
if (normalizedCliPath.includes("/src/cli/")) return true;
|
|
87642
87940
|
if (normalizedCliPath.includes("/dist/cli/")) return false;
|
|
87643
|
-
return fs24.existsSync(
|
|
87941
|
+
return fs24.existsSync(path30.join(packageRoot, "src", "cli", "index.ts"));
|
|
87644
87942
|
}
|
|
87645
87943
|
function getVendoredToolEntry(packageRoot, tool) {
|
|
87646
87944
|
if (tool === "session-host-daemon") {
|
|
87647
|
-
return
|
|
87945
|
+
return path30.join(packageRoot, "vendor", "session-host-daemon", "index.js");
|
|
87648
87946
|
}
|
|
87649
|
-
return
|
|
87947
|
+
return path30.join(packageRoot, "vendor", "terminal-mux-cli", "index.js");
|
|
87650
87948
|
}
|
|
87651
87949
|
function getSourceToolEntry(packageRoot, tool) {
|
|
87652
87950
|
if (tool === "session-host-daemon") {
|
|
87653
|
-
return
|
|
87951
|
+
return path30.resolve(packageRoot, "../../oss/packages/session-host-daemon/src/index.ts");
|
|
87654
87952
|
}
|
|
87655
|
-
return
|
|
87953
|
+
return path30.resolve(packageRoot, "../../oss/packages/terminal-mux-cli/src/index.ts");
|
|
87656
87954
|
}
|
|
87657
87955
|
function getGlobalToolCommand(tool) {
|
|
87658
87956
|
return tool === "session-host-daemon" ? "adhdev-sessiond" : "adhmux";
|
|
@@ -88772,7 +89070,7 @@ init_source();
|
|
|
88772
89070
|
var import_child_process13 = require("child_process");
|
|
88773
89071
|
var fs25 = __toESM(require("fs"));
|
|
88774
89072
|
var os29 = __toESM(require("os"));
|
|
88775
|
-
var
|
|
89073
|
+
var path31 = __toESM(require("path"));
|
|
88776
89074
|
init_src();
|
|
88777
89075
|
init_session_host();
|
|
88778
89076
|
|
|
@@ -88865,11 +89163,11 @@ function buildDoctorAdvice(input) {
|
|
|
88865
89163
|
|
|
88866
89164
|
// src/cli/doctor-commands.ts
|
|
88867
89165
|
function resolvePackageRoot() {
|
|
88868
|
-
return
|
|
89166
|
+
return path31.resolve(__dirname, "..", "..");
|
|
88869
89167
|
}
|
|
88870
89168
|
function isLinkedInstall(packageRoot) {
|
|
88871
|
-
const normalized =
|
|
88872
|
-
return !normalized.includes(`${
|
|
89169
|
+
const normalized = path31.normalize(packageRoot);
|
|
89170
|
+
return !normalized.includes(`${path31.sep}node_modules${path31.sep}adhdev`);
|
|
88873
89171
|
}
|
|
88874
89172
|
function formatCheck(check2) {
|
|
88875
89173
|
const icon = check2.ok ? source_default.green("\u2713") : source_default.red("\u2717");
|
|
@@ -88953,8 +89251,8 @@ function probeSharpRuntime(packageRoot, nativeSharpPackage) {
|
|
|
88953
89251
|
}
|
|
88954
89252
|
}
|
|
88955
89253
|
function probeConfigAccess() {
|
|
88956
|
-
const configDir =
|
|
88957
|
-
const configPath =
|
|
89254
|
+
const configDir = path31.join(os29.homedir(), ".adhdev");
|
|
89255
|
+
const configPath = path31.join(configDir, "config.json");
|
|
88958
89256
|
const checks = [];
|
|
88959
89257
|
try {
|
|
88960
89258
|
fs25.mkdirSync(configDir, { recursive: true });
|
|
@@ -88994,7 +89292,7 @@ function probeConfigAccess() {
|
|
|
88994
89292
|
fatal: true
|
|
88995
89293
|
});
|
|
88996
89294
|
}
|
|
88997
|
-
const probePath =
|
|
89295
|
+
const probePath = path31.join(configDir, `.doctor-write-${process.pid}-${Date.now()}.tmp`);
|
|
88998
89296
|
try {
|
|
88999
89297
|
fs25.writeFileSync(probePath, "ok", "utf-8");
|
|
89000
89298
|
fs25.rmSync(probePath, { force: true });
|
|
@@ -89236,7 +89534,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
89236
89534
|
nodeDriftCheck: nodeDriftCheck || void 0,
|
|
89237
89535
|
sourceCliExample: "node --import tsx packages/daemon-cloud/src/cli/index.ts doctor"
|
|
89238
89536
|
});
|
|
89239
|
-
const sessionHostLogPath =
|
|
89537
|
+
const sessionHostLogPath = path31.join(os29.homedir(), ".adhdev", "logs", "session-host.log");
|
|
89240
89538
|
console.log(source_default.bold("\n\u{1FA7A} ADHDev Doctor\n"));
|
|
89241
89539
|
console.log(source_default.gray(` Version: ${pkgVersion3}`));
|
|
89242
89540
|
console.log(source_default.gray(` Platform: ${process.platform} ${process.arch}`));
|
|
@@ -89278,7 +89576,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
89278
89576
|
|
|
89279
89577
|
// src/cli/provider-commands.ts
|
|
89280
89578
|
init_source();
|
|
89281
|
-
var
|
|
89579
|
+
var path33 = __toESM(require("path"));
|
|
89282
89580
|
init_cdp_utils();
|
|
89283
89581
|
var IDE_AUTO_FIX_FUNCTIONS = [
|
|
89284
89582
|
"openPanel",
|
|
@@ -89448,7 +89746,7 @@ function getProviderSourceCandidatePaths(options) {
|
|
|
89448
89746
|
const results = [];
|
|
89449
89747
|
for (const root of roots) {
|
|
89450
89748
|
for (const name of relativeNames) {
|
|
89451
|
-
results.push(
|
|
89749
|
+
results.push(path33.join(root, options.category, options.type, name));
|
|
89452
89750
|
}
|
|
89453
89751
|
}
|
|
89454
89752
|
return results;
|
|
@@ -89584,7 +89882,7 @@ function registerProviderCommands(program2) {
|
|
|
89584
89882
|
let processNames = {};
|
|
89585
89883
|
if (category === "ide") {
|
|
89586
89884
|
const fs27 = await import("fs");
|
|
89587
|
-
const
|
|
89885
|
+
const path35 = await import("path");
|
|
89588
89886
|
const os31 = await import("os");
|
|
89589
89887
|
if (os31.platform() === "darwin") {
|
|
89590
89888
|
while (true) {
|
|
@@ -89597,7 +89895,7 @@ function registerProviderCommands(program2) {
|
|
|
89597
89895
|
}
|
|
89598
89896
|
console.log(source_default.green(` \u2713 Path verified: ${p}`));
|
|
89599
89897
|
osPaths["darwin"] = [p];
|
|
89600
|
-
processNames["darwin"] =
|
|
89898
|
+
processNames["darwin"] = path35.basename(p, ".app");
|
|
89601
89899
|
break;
|
|
89602
89900
|
}
|
|
89603
89901
|
} else if (os31.platform() === "win32") {
|
|
@@ -89611,7 +89909,7 @@ function registerProviderCommands(program2) {
|
|
|
89611
89909
|
}
|
|
89612
89910
|
console.log(source_default.green(` \u2713 Path verified: ${p}`));
|
|
89613
89911
|
osPaths["win32"] = [p];
|
|
89614
|
-
processNames["win32"] =
|
|
89912
|
+
processNames["win32"] = path35.basename(p, ".exe");
|
|
89615
89913
|
break;
|
|
89616
89914
|
}
|
|
89617
89915
|
}
|