adhdev 0.8.65 → 0.8.67
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 +830 -517
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +806 -493
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3154,38 +3154,37 @@ function buildPersistedProviderEffectMessage(effect) {
|
|
|
3154
3154
|
return null;
|
|
3155
3155
|
}
|
|
3156
3156
|
function normalizeControlListResult(data) {
|
|
3157
|
-
if (data
|
|
3158
|
-
|
|
3159
|
-
options: normalizeControlOptions(data.options),
|
|
3160
|
-
...isScalarControlValue(data.currentValue) ? { currentValue: data.currentValue } : {},
|
|
3161
|
-
...typeof data.error === "string" ? { error: data.error } : {}
|
|
3162
|
-
};
|
|
3157
|
+
if (!data || typeof data !== "object" || !Array.isArray(data.options)) {
|
|
3158
|
+
throw new Error("Provider control list results must use the typed shape { options, currentValue?, error? }");
|
|
3163
3159
|
}
|
|
3164
|
-
const rawOptions = Array.isArray(data?.models) ? data.models : Array.isArray(data?.modes) ? data.modes : Array.isArray(data?.options) ? data.options : [];
|
|
3165
|
-
const options = normalizeControlOptions(rawOptions);
|
|
3166
3160
|
return {
|
|
3167
|
-
options,
|
|
3168
|
-
...isScalarControlValue(data
|
|
3169
|
-
...
|
|
3170
|
-
...typeof data?.error === "string" ? { error: data.error } : {}
|
|
3161
|
+
options: normalizeControlOptions(data.options),
|
|
3162
|
+
...isScalarControlValue(data.currentValue) ? { currentValue: data.currentValue } : {},
|
|
3163
|
+
...typeof data.error === "string" ? { error: data.error } : {}
|
|
3171
3164
|
};
|
|
3172
3165
|
}
|
|
3173
3166
|
function normalizeControlSetResult(data) {
|
|
3174
|
-
|
|
3167
|
+
if (!data || typeof data !== "object" || typeof data.ok !== "boolean") {
|
|
3168
|
+
throw new Error("Provider control set results must use the typed shape { ok, currentValue?, effects?, error? }");
|
|
3169
|
+
}
|
|
3170
|
+
const currentValue = isScalarControlValue(data.currentValue) ? data.currentValue : isScalarControlValue(data.value) ? data.value : void 0;
|
|
3175
3171
|
return {
|
|
3176
|
-
ok: data
|
|
3172
|
+
ok: data.ok,
|
|
3177
3173
|
...currentValue !== void 0 ? { currentValue } : {},
|
|
3178
|
-
...Array.isArray(data
|
|
3179
|
-
...typeof data
|
|
3174
|
+
...Array.isArray(data.effects) ? { effects: normalizeProviderEffects(data) } : {},
|
|
3175
|
+
...typeof data.error === "string" ? { error: data.error } : {}
|
|
3180
3176
|
};
|
|
3181
3177
|
}
|
|
3182
3178
|
function normalizeControlInvokeResult(data) {
|
|
3183
|
-
|
|
3179
|
+
if (!data || typeof data !== "object" || typeof data.ok !== "boolean") {
|
|
3180
|
+
throw new Error("Provider control invoke results must use the typed shape { ok, currentValue?, effects?, error? }");
|
|
3181
|
+
}
|
|
3182
|
+
const currentValue = isScalarControlValue(data.currentValue) ? data.currentValue : isScalarControlValue(data.value) ? data.value : void 0;
|
|
3184
3183
|
return {
|
|
3185
|
-
ok: data
|
|
3184
|
+
ok: data.ok,
|
|
3186
3185
|
...currentValue !== void 0 ? { currentValue } : {},
|
|
3187
|
-
...Array.isArray(data
|
|
3188
|
-
...typeof data
|
|
3186
|
+
...Array.isArray(data.effects) ? { effects: normalizeProviderEffects(data) } : {},
|
|
3187
|
+
...typeof data.error === "string" ? { error: data.error } : {}
|
|
3189
3188
|
};
|
|
3190
3189
|
}
|
|
3191
3190
|
function normalizeControlOptions(options) {
|
|
@@ -4105,19 +4104,37 @@ var init_extension_provider_instance = __esm({
|
|
|
4105
4104
|
);
|
|
4106
4105
|
}
|
|
4107
4106
|
}
|
|
4107
|
+
buildSyntheticTurnKey(message, occurrence) {
|
|
4108
|
+
const role = typeof message?.role === "string" ? message.role : "";
|
|
4109
|
+
const kind = typeof message?.kind === "string" ? message.kind : "";
|
|
4110
|
+
const senderName = typeof message?.senderName === "string" ? message.senderName : "";
|
|
4111
|
+
const content = flattenContent(message?.content).replace(/\s+/g, " ").trim().slice(0, 500);
|
|
4112
|
+
return `${role}|${kind}|${senderName}|${content}|${occurrence}`;
|
|
4113
|
+
}
|
|
4108
4114
|
/**
|
|
4109
|
-
* Assign stable receivedAt to extension messages.
|
|
4110
|
-
* Same
|
|
4111
|
-
*
|
|
4115
|
+
* Assign stable receivedAt / synthetic _turnKey to extension messages.
|
|
4116
|
+
* Same transcript should keep the same identity across polling cycles and
|
|
4117
|
+
* stream resets, while repeated identical text later in the transcript still
|
|
4118
|
+
* produces a distinct completion marker via the occurrence suffix.
|
|
4112
4119
|
*/
|
|
4113
4120
|
assignReceivedAt(messages) {
|
|
4114
4121
|
const now = Date.now();
|
|
4115
4122
|
const nextHashes = /* @__PURE__ */ new Map();
|
|
4123
|
+
const occurrenceByBaseKey = /* @__PURE__ */ new Map();
|
|
4116
4124
|
for (const msg of messages) {
|
|
4117
|
-
const
|
|
4118
|
-
const
|
|
4125
|
+
const explicitTurnKey = typeof msg?._turnKey === "string" && msg._turnKey.trim() ? msg._turnKey.trim() : "";
|
|
4126
|
+
const explicitId = typeof msg?.id === "string" && msg.id.trim() ? `id:${msg.id.trim()}` : "";
|
|
4127
|
+
const explicitIndex = typeof msg?.index === "number" && Number.isFinite(msg.index) ? `idx:${msg.index}` : "";
|
|
4128
|
+
const baseKey = explicitTurnKey || explicitId || explicitIndex || `${msg?.role || ""}:${flattenContent(msg?.content || "").slice(0, 500)}`;
|
|
4129
|
+
const occurrence = (occurrenceByBaseKey.get(baseKey) || 0) + 1;
|
|
4130
|
+
occurrenceByBaseKey.set(baseKey, occurrence);
|
|
4131
|
+
const syntheticTurnKey = explicitTurnKey || explicitId || explicitIndex || this.buildSyntheticTurnKey(msg, occurrence);
|
|
4132
|
+
if (!explicitTurnKey && !explicitId && !explicitIndex) {
|
|
4133
|
+
msg._turnKey = syntheticTurnKey;
|
|
4134
|
+
}
|
|
4135
|
+
const prevTime = this.prevMessageHashes.get(syntheticTurnKey);
|
|
4119
4136
|
msg.receivedAt = prevTime || now;
|
|
4120
|
-
nextHashes.set(
|
|
4137
|
+
nextHashes.set(syntheticTurnKey, msg.receivedAt);
|
|
4121
4138
|
}
|
|
4122
4139
|
this.prevMessageHashes = nextHashes;
|
|
4123
4140
|
return normalizeChatMessages(messages);
|
|
@@ -4194,6 +4211,128 @@ ${effect.notification.body || ""}`.trim();
|
|
|
4194
4211
|
}
|
|
4195
4212
|
});
|
|
4196
4213
|
|
|
4214
|
+
// ../../oss/packages/daemon-core/src/providers/read-chat-contract.ts
|
|
4215
|
+
function isPlainObject3(value) {
|
|
4216
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
4217
|
+
}
|
|
4218
|
+
function isFiniteNumber(value) {
|
|
4219
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
4220
|
+
}
|
|
4221
|
+
function validateStatus(status, source) {
|
|
4222
|
+
if (typeof status !== "string" || !VALID_STATUSES.includes(status)) {
|
|
4223
|
+
throw new Error(`${source}: status must be one of ${VALID_STATUSES.join(", ")}`);
|
|
4224
|
+
}
|
|
4225
|
+
return status;
|
|
4226
|
+
}
|
|
4227
|
+
function validateRole(role, source, index) {
|
|
4228
|
+
if (typeof role !== "string" || !VALID_ROLES.includes(role)) {
|
|
4229
|
+
throw new Error(`${source}: messages[${index}].role must be one of ${VALID_ROLES.join(", ")}`);
|
|
4230
|
+
}
|
|
4231
|
+
return role;
|
|
4232
|
+
}
|
|
4233
|
+
function validateMessageContent(content, source, index) {
|
|
4234
|
+
if (typeof content === "string") return content;
|
|
4235
|
+
if (Array.isArray(content)) return normalizeMessageParts(content);
|
|
4236
|
+
throw new Error(`${source}: messages[${index}].content must be a string or structured content array`);
|
|
4237
|
+
}
|
|
4238
|
+
function validateMessage(message, source, index) {
|
|
4239
|
+
if (!isPlainObject3(message)) {
|
|
4240
|
+
throw new Error(`${source}: messages[${index}] must be an object`);
|
|
4241
|
+
}
|
|
4242
|
+
const normalized = {
|
|
4243
|
+
role: validateRole(message.role, source, index),
|
|
4244
|
+
content: validateMessageContent(message.content, source, index)
|
|
4245
|
+
};
|
|
4246
|
+
if (typeof message.kind === "string") normalized.kind = message.kind;
|
|
4247
|
+
if (typeof message.id === "string") normalized.id = message.id;
|
|
4248
|
+
if (isFiniteNumber(message.index)) normalized.index = message.index;
|
|
4249
|
+
if (isFiniteNumber(message.timestamp)) normalized.timestamp = message.timestamp;
|
|
4250
|
+
if (isFiniteNumber(message.receivedAt)) normalized.receivedAt = message.receivedAt;
|
|
4251
|
+
if (Array.isArray(message.toolCalls)) normalized.toolCalls = message.toolCalls;
|
|
4252
|
+
if (isPlainObject3(message.meta)) normalized.meta = message.meta;
|
|
4253
|
+
if (typeof message.senderName === "string") normalized.senderName = message.senderName;
|
|
4254
|
+
if (typeof message._type === "string") normalized._type = message._type;
|
|
4255
|
+
if (typeof message._sub === "string") normalized._sub = message._sub;
|
|
4256
|
+
return normalized;
|
|
4257
|
+
}
|
|
4258
|
+
function validateModal(activeModal, status, source) {
|
|
4259
|
+
if (activeModal == null) {
|
|
4260
|
+
if (status === "waiting_approval") {
|
|
4261
|
+
throw new Error(`${source}: waiting_approval status requires activeModal with buttons`);
|
|
4262
|
+
}
|
|
4263
|
+
return activeModal === null ? null : void 0;
|
|
4264
|
+
}
|
|
4265
|
+
if (!isPlainObject3(activeModal)) {
|
|
4266
|
+
throw new Error(`${source}: activeModal must be an object when provided`);
|
|
4267
|
+
}
|
|
4268
|
+
if (typeof activeModal.message !== "string") {
|
|
4269
|
+
throw new Error(`${source}: activeModal.message must be a string`);
|
|
4270
|
+
}
|
|
4271
|
+
if (!Array.isArray(activeModal.buttons) || activeModal.buttons.some((button) => typeof button !== "string" || !button.trim())) {
|
|
4272
|
+
throw new Error(`${source}: activeModal.buttons must be a non-empty string array`);
|
|
4273
|
+
}
|
|
4274
|
+
const normalized = {
|
|
4275
|
+
message: activeModal.message,
|
|
4276
|
+
buttons: activeModal.buttons.map((button) => button.trim())
|
|
4277
|
+
};
|
|
4278
|
+
if (isFiniteNumber(activeModal.width)) normalized.width = activeModal.width;
|
|
4279
|
+
if (isFiniteNumber(activeModal.height)) normalized.height = activeModal.height;
|
|
4280
|
+
return normalized;
|
|
4281
|
+
}
|
|
4282
|
+
function validateControlValues(controlValues, source) {
|
|
4283
|
+
if (controlValues === void 0) return void 0;
|
|
4284
|
+
if (!isPlainObject3(controlValues)) {
|
|
4285
|
+
throw new Error(`${source}: controlValues must be an object when provided`);
|
|
4286
|
+
}
|
|
4287
|
+
const normalized = {};
|
|
4288
|
+
for (const [key, value] of Object.entries(controlValues)) {
|
|
4289
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
4290
|
+
throw new Error(`${source}: controlValues.${key} must be string, number, or boolean`);
|
|
4291
|
+
}
|
|
4292
|
+
normalized[key] = value;
|
|
4293
|
+
}
|
|
4294
|
+
return normalized;
|
|
4295
|
+
}
|
|
4296
|
+
function validateReadChatResultPayload(raw, source = "read_chat") {
|
|
4297
|
+
if (!isPlainObject3(raw)) {
|
|
4298
|
+
throw new Error(`${source}: payload must be an object`);
|
|
4299
|
+
}
|
|
4300
|
+
const status = validateStatus(raw.status, source);
|
|
4301
|
+
if (!Array.isArray(raw.messages)) {
|
|
4302
|
+
throw new Error(`${source}: messages must be an array`);
|
|
4303
|
+
}
|
|
4304
|
+
const messages = raw.messages.map((message, index) => validateMessage(message, source, index));
|
|
4305
|
+
const activeModal = validateModal(raw.activeModal, status, source);
|
|
4306
|
+
const controlValues = validateControlValues(raw.controlValues, source);
|
|
4307
|
+
const normalized = {
|
|
4308
|
+
status,
|
|
4309
|
+
messages
|
|
4310
|
+
};
|
|
4311
|
+
if (activeModal !== void 0) normalized.activeModal = activeModal;
|
|
4312
|
+
if (typeof raw.id === "string") normalized.id = raw.id;
|
|
4313
|
+
if (typeof raw.title === "string") normalized.title = raw.title;
|
|
4314
|
+
if (typeof raw.agentType === "string") normalized.agentType = raw.agentType;
|
|
4315
|
+
if (typeof raw.agentName === "string") normalized.agentName = raw.agentName;
|
|
4316
|
+
if (typeof raw.extensionId === "string") normalized.extensionId = raw.extensionId;
|
|
4317
|
+
if (typeof raw.inputContent === "string") normalized.inputContent = raw.inputContent;
|
|
4318
|
+
if (typeof raw.isVisible === "boolean") normalized.isVisible = raw.isVisible;
|
|
4319
|
+
if (typeof raw.isWelcomeScreen === "boolean") normalized.isWelcomeScreen = raw.isWelcomeScreen;
|
|
4320
|
+
if (controlValues) normalized.controlValues = controlValues;
|
|
4321
|
+
if (raw.summaryMetadata !== void 0) normalized.summaryMetadata = raw.summaryMetadata;
|
|
4322
|
+
if (Array.isArray(raw.effects)) normalized.effects = raw.effects;
|
|
4323
|
+
if (typeof raw.providerSessionId === "string") normalized.providerSessionId = raw.providerSessionId;
|
|
4324
|
+
return normalized;
|
|
4325
|
+
}
|
|
4326
|
+
var VALID_STATUSES, VALID_ROLES;
|
|
4327
|
+
var init_read_chat_contract = __esm({
|
|
4328
|
+
"../../oss/packages/daemon-core/src/providers/read-chat-contract.ts"() {
|
|
4329
|
+
"use strict";
|
|
4330
|
+
init_contracts();
|
|
4331
|
+
VALID_STATUSES = ["idle", "generating", "waiting_approval", "error", "panel_hidden", "streaming", "long_generating"];
|
|
4332
|
+
VALID_ROLES = ["user", "assistant", "system", "human"];
|
|
4333
|
+
}
|
|
4334
|
+
});
|
|
4335
|
+
|
|
4197
4336
|
// ../../oss/packages/daemon-core/src/providers/approval-utils.ts
|
|
4198
4337
|
function normalizeApprovalLabel(value) {
|
|
4199
4338
|
return String(value || "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
@@ -4259,6 +4398,7 @@ var init_ide_provider_instance = __esm({
|
|
|
4259
4398
|
init_chat_history();
|
|
4260
4399
|
init_logger();
|
|
4261
4400
|
init_control_effects();
|
|
4401
|
+
init_read_chat_contract();
|
|
4262
4402
|
init_approval_utils();
|
|
4263
4403
|
init_provider_patch_state();
|
|
4264
4404
|
init_chat_message_normalization();
|
|
@@ -4493,7 +4633,7 @@ var init_ide_provider_instance = __esm({
|
|
|
4493
4633
|
}
|
|
4494
4634
|
}
|
|
4495
4635
|
if (!raw || typeof raw !== "object") return;
|
|
4496
|
-
const chat = raw;
|
|
4636
|
+
const chat = validateReadChatResultPayload(raw, `${this.type} readChat`);
|
|
4497
4637
|
let { activeModal } = chat;
|
|
4498
4638
|
if (activeModal) {
|
|
4499
4639
|
const w = activeModal.width ?? Infinity;
|
|
@@ -5680,6 +5820,67 @@ var init_reconcile = __esm({
|
|
|
5680
5820
|
}
|
|
5681
5821
|
});
|
|
5682
5822
|
|
|
5823
|
+
// ../../oss/packages/daemon-core/src/providers/provider-input-support.ts
|
|
5824
|
+
function getProviderLabel(provider) {
|
|
5825
|
+
return provider?.name || provider?.type || "This provider";
|
|
5826
|
+
}
|
|
5827
|
+
function hasNonEmptyFallbackText(input) {
|
|
5828
|
+
return typeof input.textFallback === "string" && input.textFallback.trim().length > 0;
|
|
5829
|
+
}
|
|
5830
|
+
function getRequestedInputMediaTypes(input) {
|
|
5831
|
+
const types = /* @__PURE__ */ new Set();
|
|
5832
|
+
if (hasNonEmptyFallbackText(input) && !input.parts.some((part) => part.type === "text")) {
|
|
5833
|
+
types.add("text");
|
|
5834
|
+
}
|
|
5835
|
+
for (const part of input.parts) {
|
|
5836
|
+
if (VALID_INPUT_MEDIA_TYPES.has(part.type)) {
|
|
5837
|
+
types.add(part.type);
|
|
5838
|
+
}
|
|
5839
|
+
}
|
|
5840
|
+
return Array.from(types);
|
|
5841
|
+
}
|
|
5842
|
+
function getEffectiveSemanticPartCount(input) {
|
|
5843
|
+
let count = input.parts.length;
|
|
5844
|
+
if (hasNonEmptyFallbackText(input) && !input.parts.some((part) => part.type === "text")) {
|
|
5845
|
+
count += 1;
|
|
5846
|
+
}
|
|
5847
|
+
return count;
|
|
5848
|
+
}
|
|
5849
|
+
function assertTextOnlyInput(provider, input) {
|
|
5850
|
+
const unsupported = getRequestedInputMediaTypes(input).filter((type) => type !== "text");
|
|
5851
|
+
if (unsupported.length === 0) return;
|
|
5852
|
+
const label = getProviderLabel(provider);
|
|
5853
|
+
const suffix = unsupported.length === 1 ? "" : "s";
|
|
5854
|
+
throw new Error(`${label} only supports text input; unsupported input type${suffix}: ${unsupported.join(", ")}`);
|
|
5855
|
+
}
|
|
5856
|
+
function getDeclaredProviderInputSupport(provider) {
|
|
5857
|
+
const rawMediaTypes = Array.isArray(provider?.capabilities?.input?.mediaTypes) ? provider?.capabilities?.input?.mediaTypes.filter((type) => VALID_INPUT_MEDIA_TYPES.has(type)) : [];
|
|
5858
|
+
return {
|
|
5859
|
+
multipart: provider?.capabilities?.input?.multipart === true,
|
|
5860
|
+
mediaTypes: new Set(rawMediaTypes.length > 0 ? rawMediaTypes : ["text"])
|
|
5861
|
+
};
|
|
5862
|
+
}
|
|
5863
|
+
function assertProviderSupportsDeclaredInput(provider, input) {
|
|
5864
|
+
const label = getProviderLabel(provider);
|
|
5865
|
+
const support = getDeclaredProviderInputSupport(provider);
|
|
5866
|
+
const requestedTypes = getRequestedInputMediaTypes(input);
|
|
5867
|
+
const unsupported = requestedTypes.filter((type) => !support.mediaTypes.has(type));
|
|
5868
|
+
if (unsupported.length > 0) {
|
|
5869
|
+
const suffix = unsupported.length === 1 ? "" : "s";
|
|
5870
|
+
throw new Error(`${label} does not support input type${suffix}: ${unsupported.join(", ")}`);
|
|
5871
|
+
}
|
|
5872
|
+
if (getEffectiveSemanticPartCount(input) > 1 && !support.multipart) {
|
|
5873
|
+
throw new Error(`${label} does not support multipart input`);
|
|
5874
|
+
}
|
|
5875
|
+
}
|
|
5876
|
+
var VALID_INPUT_MEDIA_TYPES;
|
|
5877
|
+
var init_provider_input_support = __esm({
|
|
5878
|
+
"../../oss/packages/daemon-core/src/providers/provider-input-support.ts"() {
|
|
5879
|
+
"use strict";
|
|
5880
|
+
VALID_INPUT_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
|
|
5881
|
+
}
|
|
5882
|
+
});
|
|
5883
|
+
|
|
5683
5884
|
// ../../oss/packages/daemon-core/src/logging/debug-config.ts
|
|
5684
5885
|
function normalizeCategories(categories) {
|
|
5685
5886
|
if (!Array.isArray(categories)) return [];
|
|
@@ -5869,10 +6070,15 @@ function isCliLikeTransport(transport) {
|
|
|
5869
6070
|
function isExtensionTransport(transport) {
|
|
5870
6071
|
return transport === "cdp-webview";
|
|
5871
6072
|
}
|
|
5872
|
-
function buildRecentSendKey(h, args, provider,
|
|
6073
|
+
function buildRecentSendKey(h, args, provider, signature) {
|
|
5873
6074
|
const transport = getTargetTransport(h, provider) || "unknown";
|
|
5874
6075
|
const target = args?.targetSessionId || args?.agentType || h.currentSession?.providerType || h.currentProviderType || h.currentManagerKey || "unknown";
|
|
5875
|
-
return `${transport}:${target}:${
|
|
6076
|
+
return `${transport}:${target}:${signature.trim()}`;
|
|
6077
|
+
}
|
|
6078
|
+
function buildSendInputSignature(input) {
|
|
6079
|
+
const text = typeof input.textFallback === "string" ? input.textFallback.trim() : "";
|
|
6080
|
+
if (text) return text;
|
|
6081
|
+
return JSON.stringify(input.parts || []);
|
|
5876
6082
|
}
|
|
5877
6083
|
function getSendChatInputEnvelope(args) {
|
|
5878
6084
|
return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
@@ -6025,14 +6231,20 @@ function computeReadChatSync(messages, cursor) {
|
|
|
6025
6231
|
};
|
|
6026
6232
|
}
|
|
6027
6233
|
function buildReadChatCommandResult(payload, args) {
|
|
6028
|
-
|
|
6234
|
+
let validatedPayload;
|
|
6235
|
+
try {
|
|
6236
|
+
validatedPayload = validateReadChatResultPayload(payload, "read_chat command result");
|
|
6237
|
+
} catch (error48) {
|
|
6238
|
+
return { success: false, error: error48?.message || String(error48) };
|
|
6239
|
+
}
|
|
6240
|
+
const messages = normalizeReadChatMessages(validatedPayload);
|
|
6029
6241
|
const cursor = normalizeReadChatCursor(args);
|
|
6030
6242
|
if (!cursor.knownMessageCount && !cursor.lastMessageSignature && cursor.tailLimit > 0 && messages.length > cursor.tailLimit) {
|
|
6031
6243
|
const tailMessages = messages.slice(-cursor.tailLimit);
|
|
6032
6244
|
const lastMessageSignature = getChatMessageSignature(tailMessages[tailMessages.length - 1]);
|
|
6033
6245
|
return {
|
|
6034
6246
|
success: true,
|
|
6035
|
-
...
|
|
6247
|
+
...validatedPayload,
|
|
6036
6248
|
messages: tailMessages,
|
|
6037
6249
|
syncMode: "full",
|
|
6038
6250
|
replaceFrom: 0,
|
|
@@ -6043,7 +6255,7 @@ function buildReadChatCommandResult(payload, args) {
|
|
|
6043
6255
|
const sync = computeReadChatSync(messages, cursor);
|
|
6044
6256
|
return {
|
|
6045
6257
|
success: true,
|
|
6046
|
-
...
|
|
6258
|
+
...validatedPayload,
|
|
6047
6259
|
messages: sync.messages,
|
|
6048
6260
|
syncMode: sync.syncMode,
|
|
6049
6261
|
replaceFrom: sync.replaceFrom,
|
|
@@ -6122,12 +6334,18 @@ async function handleReadChat(h, args) {
|
|
|
6122
6334
|
const adapter = getTargetedCliAdapter(h, args, provider?.type);
|
|
6123
6335
|
if (adapter) {
|
|
6124
6336
|
_log(`${transport} adapter: ${adapter.cliType}`);
|
|
6125
|
-
const
|
|
6337
|
+
const parsedStatus = typeof adapter.getScriptParsedStatus === "function" ? parseMaybeJson(adapter.getScriptParsedStatus()) : null;
|
|
6338
|
+
const parsedRecord = parsedStatus && typeof parsedStatus === "object" ? parsedStatus : null;
|
|
6339
|
+
const status = parsedRecord || adapter.getStatus();
|
|
6340
|
+
const title = typeof parsedRecord?.title === "string" ? parsedRecord.title : void 0;
|
|
6341
|
+
const providerSessionId = typeof parsedRecord?.providerSessionId === "string" ? parsedRecord.providerSessionId : void 0;
|
|
6126
6342
|
if (status) {
|
|
6127
6343
|
return buildReadChatCommandResult({
|
|
6128
6344
|
messages: status.messages || [],
|
|
6129
6345
|
status: status.status,
|
|
6130
|
-
activeModal: status.activeModal
|
|
6346
|
+
activeModal: status.activeModal,
|
|
6347
|
+
...title ? { title } : {},
|
|
6348
|
+
...providerSessionId ? { providerSessionId } : {}
|
|
6131
6349
|
}, args);
|
|
6132
6350
|
}
|
|
6133
6351
|
}
|
|
@@ -6145,25 +6363,26 @@ async function handleReadChat(h, args) {
|
|
|
6145
6363
|
}
|
|
6146
6364
|
}
|
|
6147
6365
|
if (parsed && typeof parsed === "object") {
|
|
6148
|
-
|
|
6366
|
+
const validated = validateReadChatResultPayload(parsed, "extension read_chat");
|
|
6367
|
+
_log(`Extension OK: ${validated.messages?.length || 0} msgs`);
|
|
6149
6368
|
traceProviderEvent(args, "provider", "extension.read_chat.success", {
|
|
6150
6369
|
h,
|
|
6151
6370
|
provider,
|
|
6152
6371
|
payload: {
|
|
6153
6372
|
method: "evaluateProviderScript",
|
|
6154
6373
|
result: evalResult.result,
|
|
6155
|
-
parsed,
|
|
6156
|
-
messageCount: Array.isArray(
|
|
6374
|
+
parsed: validated,
|
|
6375
|
+
messageCount: Array.isArray(validated.messages) ? validated.messages.length : 0
|
|
6157
6376
|
}
|
|
6158
6377
|
});
|
|
6159
6378
|
h.historyWriter.appendNewMessages(
|
|
6160
6379
|
provider?.type || "unknown_extension",
|
|
6161
|
-
toHistoryPersistedMessages(normalizeReadChatMessages(
|
|
6162
|
-
|
|
6380
|
+
toHistoryPersistedMessages(normalizeReadChatMessages(validated)),
|
|
6381
|
+
validated.title,
|
|
6163
6382
|
args?.targetSessionId,
|
|
6164
6383
|
historySessionId
|
|
6165
6384
|
);
|
|
6166
|
-
return buildReadChatCommandResult(
|
|
6385
|
+
return buildReadChatCommandResult(validated, args);
|
|
6167
6386
|
}
|
|
6168
6387
|
}
|
|
6169
6388
|
} catch (e) {
|
|
@@ -6218,15 +6437,16 @@ async function handleReadChat(h, args) {
|
|
|
6218
6437
|
}
|
|
6219
6438
|
}
|
|
6220
6439
|
if (parsed && typeof parsed === "object") {
|
|
6221
|
-
|
|
6440
|
+
const validated = validateReadChatResultPayload(parsed, "webview read_chat");
|
|
6441
|
+
_log(`Webview OK: ${validated.messages?.length || 0} msgs`);
|
|
6222
6442
|
h.historyWriter.appendNewMessages(
|
|
6223
6443
|
provider?.type || getCurrentProviderType(h, "unknown_webview"),
|
|
6224
|
-
toHistoryPersistedMessages(normalizeReadChatMessages(
|
|
6225
|
-
|
|
6444
|
+
toHistoryPersistedMessages(normalizeReadChatMessages(validated)),
|
|
6445
|
+
validated.title,
|
|
6226
6446
|
args?.targetSessionId,
|
|
6227
6447
|
historySessionId
|
|
6228
6448
|
);
|
|
6229
|
-
return buildReadChatCommandResult(
|
|
6449
|
+
return buildReadChatCommandResult(validated, args);
|
|
6230
6450
|
}
|
|
6231
6451
|
}
|
|
6232
6452
|
} catch (e) {
|
|
@@ -6247,25 +6467,26 @@ async function handleReadChat(h, args) {
|
|
|
6247
6467
|
}
|
|
6248
6468
|
}
|
|
6249
6469
|
if (parsed && typeof parsed === "object" && parsed.messages?.length > 0) {
|
|
6250
|
-
|
|
6470
|
+
const validated = validateReadChatResultPayload(parsed, "ide read_chat");
|
|
6471
|
+
_log(`OK: ${validated.messages?.length} msgs`);
|
|
6251
6472
|
traceProviderEvent(args, "provider", "ide.read_chat.success", {
|
|
6252
6473
|
h,
|
|
6253
6474
|
provider,
|
|
6254
6475
|
payload: {
|
|
6255
6476
|
method: "evaluate",
|
|
6256
6477
|
result: evalResult.result,
|
|
6257
|
-
parsed,
|
|
6258
|
-
messageCount: Array.isArray(
|
|
6478
|
+
parsed: validated,
|
|
6479
|
+
messageCount: Array.isArray(validated.messages) ? validated.messages.length : 0
|
|
6259
6480
|
}
|
|
6260
6481
|
});
|
|
6261
6482
|
h.historyWriter.appendNewMessages(
|
|
6262
6483
|
provider?.type || getCurrentProviderType(h, "unknown_ide"),
|
|
6263
|
-
toHistoryPersistedMessages(normalizeReadChatMessages(
|
|
6264
|
-
|
|
6484
|
+
toHistoryPersistedMessages(normalizeReadChatMessages(validated)),
|
|
6485
|
+
validated.title,
|
|
6265
6486
|
args?.targetSessionId,
|
|
6266
6487
|
historySessionId
|
|
6267
6488
|
);
|
|
6268
|
-
return buildReadChatCommandResult(
|
|
6489
|
+
return buildReadChatCommandResult(validated, args);
|
|
6269
6490
|
}
|
|
6270
6491
|
}
|
|
6271
6492
|
} catch (e) {
|
|
@@ -6283,11 +6504,12 @@ async function handleReadChat(h, args) {
|
|
|
6283
6504
|
async function handleSendChat(h, args) {
|
|
6284
6505
|
const input = getSendChatInputEnvelope(args);
|
|
6285
6506
|
const text = input.textFallback;
|
|
6286
|
-
|
|
6507
|
+
const hasInput = input.parts.length > 0 || typeof text === "string" && text.trim().length > 0;
|
|
6508
|
+
if (!hasInput) return { success: false, error: "input required" };
|
|
6287
6509
|
const _log = (msg) => LOG.debug("Command", `[send_chat] ${msg}`);
|
|
6288
6510
|
const provider = h.getProvider(args?.agentType);
|
|
6289
6511
|
const transport = getTargetTransport(h, provider);
|
|
6290
|
-
const dedupeKey = buildRecentSendKey(h, args, provider,
|
|
6512
|
+
const dedupeKey = buildRecentSendKey(h, args, provider, buildSendInputSignature(input));
|
|
6291
6513
|
const _logSendSuccess = (method, targetAgent) => {
|
|
6292
6514
|
return { success: true, sent: true, method, targetAgent };
|
|
6293
6515
|
};
|
|
@@ -6295,11 +6517,26 @@ async function handleSendChat(h, args) {
|
|
|
6295
6517
|
_log(`Suppressed duplicate send for ${dedupeKey}`);
|
|
6296
6518
|
return { success: true, sent: false, deduplicated: true };
|
|
6297
6519
|
}
|
|
6298
|
-
if (
|
|
6520
|
+
if (transport === "acp") {
|
|
6521
|
+
const target = getTargetInstance(h, args);
|
|
6522
|
+
if (!target || target.category !== "acp") {
|
|
6523
|
+
return { success: false, error: `ACP instance not found for ${provider?.type || args?.agentType || "unknown"}` };
|
|
6524
|
+
}
|
|
6525
|
+
try {
|
|
6526
|
+
assertProviderSupportsDeclaredInput(provider, input);
|
|
6527
|
+
target.onEvent("send_message", { input });
|
|
6528
|
+
return _logSendSuccess("acp-instance", target.type);
|
|
6529
|
+
} catch (e) {
|
|
6530
|
+
return { success: false, error: `acp send failed: ${e.message}` };
|
|
6531
|
+
}
|
|
6532
|
+
}
|
|
6533
|
+
if (transport === "pty") {
|
|
6299
6534
|
const adapter = getTargetedCliAdapter(h, args, provider?.type);
|
|
6300
6535
|
if (adapter) {
|
|
6301
6536
|
_log(`${transport} adapter: ${adapter.cliType}`);
|
|
6302
6537
|
try {
|
|
6538
|
+
assertTextOnlyInput(provider, input);
|
|
6539
|
+
if (!text) return { success: false, error: "text required for PTY send" };
|
|
6303
6540
|
await adapter.sendMessage(text);
|
|
6304
6541
|
return _logSendSuccess(`${transport}-adapter`, adapter.cliType);
|
|
6305
6542
|
} catch (e) {
|
|
@@ -6307,6 +6544,8 @@ async function handleSendChat(h, args) {
|
|
|
6307
6544
|
}
|
|
6308
6545
|
}
|
|
6309
6546
|
}
|
|
6547
|
+
assertTextOnlyInput(provider, input);
|
|
6548
|
+
if (!text) return { success: false, error: "text required" };
|
|
6310
6549
|
if (isExtensionTransport(transport)) {
|
|
6311
6550
|
_log(`Extension: ${provider?.type || "unknown_extension"}`);
|
|
6312
6551
|
try {
|
|
@@ -6922,6 +7161,8 @@ var init_chat_commands = __esm({
|
|
|
6922
7161
|
"../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
|
|
6923
7162
|
"use strict";
|
|
6924
7163
|
init_contracts();
|
|
7164
|
+
init_provider_input_support();
|
|
7165
|
+
init_read_chat_contract();
|
|
6925
7166
|
init_chat_history();
|
|
6926
7167
|
init_logger();
|
|
6927
7168
|
init_debug_trace();
|
|
@@ -7496,14 +7737,14 @@ function normalizeProviderScriptArgs(args, scriptName) {
|
|
|
7496
7737
|
}
|
|
7497
7738
|
function buildControlScriptResult(scriptName, payload) {
|
|
7498
7739
|
if (!payload || typeof payload !== "object") return {};
|
|
7499
|
-
if (Array.isArray(payload.options)
|
|
7740
|
+
if (Array.isArray(payload.options)) {
|
|
7500
7741
|
return { controlResult: normalizeControlListResult(payload) };
|
|
7501
7742
|
}
|
|
7502
7743
|
const looksLikeValueMutation = /^set|^change/i.test(scriptName) || payload.currentValue !== void 0 || payload.value !== void 0;
|
|
7503
7744
|
if (looksLikeValueMutation) {
|
|
7504
7745
|
return { controlResult: normalizeControlSetResult(payload) };
|
|
7505
7746
|
}
|
|
7506
|
-
if (payload.ok !== void 0 ||
|
|
7747
|
+
if (payload.ok !== void 0 || Array.isArray(payload.effects) || typeof payload.error === "string") {
|
|
7507
7748
|
return { controlResult: normalizeControlInvokeResult(payload) };
|
|
7508
7749
|
}
|
|
7509
7750
|
return {};
|
|
@@ -9911,6 +10152,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
9911
10152
|
init_pty_transport();
|
|
9912
10153
|
init_provider_cli_shared();
|
|
9913
10154
|
init_chat_message_normalization();
|
|
10155
|
+
init_read_chat_contract();
|
|
9914
10156
|
init_provider_cli_parse();
|
|
9915
10157
|
init_provider_cli_config();
|
|
9916
10158
|
init_provider_cli_runtime();
|
|
@@ -11056,6 +11298,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
11056
11298
|
runtimeSettings: this.runtimeSettings
|
|
11057
11299
|
});
|
|
11058
11300
|
const parsed = this.cliScripts.parseOutput(input);
|
|
11301
|
+
if (parsed && typeof parsed === "object") {
|
|
11302
|
+
Object.assign(parsed, validateReadChatResultPayload(parsed, `${this.cliType} parseOutput`));
|
|
11303
|
+
}
|
|
11059
11304
|
const refinedStatus = this.refineDetectedStatus(typeof parsed?.status === "string" ? parsed.status : null, input.recentBuffer, input.screenText);
|
|
11060
11305
|
if (parsed && refinedStatus && parsed.status !== refinedStatus) {
|
|
11061
11306
|
parsed.status = refinedStatus;
|
|
@@ -11692,6 +11937,7 @@ var init_cli_provider_instance = __esm({
|
|
|
11692
11937
|
fs5 = __toESM(require("fs"));
|
|
11693
11938
|
import_node_module = require("module");
|
|
11694
11939
|
init_contracts();
|
|
11940
|
+
init_provider_input_support();
|
|
11695
11941
|
init_provider_cli_adapter();
|
|
11696
11942
|
init_status_monitor();
|
|
11697
11943
|
init_chat_history();
|
|
@@ -11952,6 +12198,7 @@ var init_cli_provider_instance = __esm({
|
|
|
11952
12198
|
onEvent(event, data) {
|
|
11953
12199
|
if (event === "send_message") {
|
|
11954
12200
|
const input = normalizeInputEnvelope(data);
|
|
12201
|
+
assertTextOnlyInput(this.provider, input);
|
|
11955
12202
|
if (input.textFallback) {
|
|
11956
12203
|
void this.adapter.sendMessage(input.textFallback).catch((e) => {
|
|
11957
12204
|
LOG.warn("CLI", `[${this.type}] send_message failed: ${e?.message || e}`);
|
|
@@ -12507,7 +12754,7 @@ __export(util_exports, {
|
|
|
12507
12754
|
getSizableOrigin: () => getSizableOrigin,
|
|
12508
12755
|
hexToUint8Array: () => hexToUint8Array,
|
|
12509
12756
|
isObject: () => isObject,
|
|
12510
|
-
isPlainObject: () =>
|
|
12757
|
+
isPlainObject: () => isPlainObject4,
|
|
12511
12758
|
issue: () => issue,
|
|
12512
12759
|
joinValues: () => joinValues,
|
|
12513
12760
|
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
@@ -12643,10 +12890,10 @@ function mergeDefs(...defs) {
|
|
|
12643
12890
|
function cloneDef(schema) {
|
|
12644
12891
|
return mergeDefs(schema._zod.def);
|
|
12645
12892
|
}
|
|
12646
|
-
function getElementAtPath(obj,
|
|
12647
|
-
if (!
|
|
12893
|
+
function getElementAtPath(obj, path29) {
|
|
12894
|
+
if (!path29)
|
|
12648
12895
|
return obj;
|
|
12649
|
-
return
|
|
12896
|
+
return path29.reduce((acc, key) => acc?.[key], obj);
|
|
12650
12897
|
}
|
|
12651
12898
|
function promiseAllObject(promisesObj) {
|
|
12652
12899
|
const keys = Object.keys(promisesObj);
|
|
@@ -12676,7 +12923,7 @@ function slugify(input) {
|
|
|
12676
12923
|
function isObject(data) {
|
|
12677
12924
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
12678
12925
|
}
|
|
12679
|
-
function
|
|
12926
|
+
function isPlainObject4(o) {
|
|
12680
12927
|
if (isObject(o) === false)
|
|
12681
12928
|
return false;
|
|
12682
12929
|
const ctor = o.constructor;
|
|
@@ -12693,7 +12940,7 @@ function isPlainObject3(o) {
|
|
|
12693
12940
|
return true;
|
|
12694
12941
|
}
|
|
12695
12942
|
function shallowClone(o) {
|
|
12696
|
-
if (
|
|
12943
|
+
if (isPlainObject4(o))
|
|
12697
12944
|
return { ...o };
|
|
12698
12945
|
if (Array.isArray(o))
|
|
12699
12946
|
return [...o];
|
|
@@ -12829,7 +13076,7 @@ function omit(schema, mask2) {
|
|
|
12829
13076
|
return clone(schema, def);
|
|
12830
13077
|
}
|
|
12831
13078
|
function extend(schema, shape) {
|
|
12832
|
-
if (!
|
|
13079
|
+
if (!isPlainObject4(shape)) {
|
|
12833
13080
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
12834
13081
|
}
|
|
12835
13082
|
const checks = schema._zod.def.checks;
|
|
@@ -12852,7 +13099,7 @@ function extend(schema, shape) {
|
|
|
12852
13099
|
return clone(schema, def);
|
|
12853
13100
|
}
|
|
12854
13101
|
function safeExtend(schema, shape) {
|
|
12855
|
-
if (!
|
|
13102
|
+
if (!isPlainObject4(shape)) {
|
|
12856
13103
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
12857
13104
|
}
|
|
12858
13105
|
const def = mergeDefs(schema._zod.def, {
|
|
@@ -12958,11 +13205,11 @@ function aborted(x, startIndex = 0) {
|
|
|
12958
13205
|
}
|
|
12959
13206
|
return false;
|
|
12960
13207
|
}
|
|
12961
|
-
function prefixIssues(
|
|
13208
|
+
function prefixIssues(path29, issues) {
|
|
12962
13209
|
return issues.map((iss) => {
|
|
12963
13210
|
var _a2;
|
|
12964
13211
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
12965
|
-
iss.path.unshift(
|
|
13212
|
+
iss.path.unshift(path29);
|
|
12966
13213
|
return iss;
|
|
12967
13214
|
});
|
|
12968
13215
|
}
|
|
@@ -13205,7 +13452,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
13205
13452
|
}
|
|
13206
13453
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
13207
13454
|
const result = { errors: [] };
|
|
13208
|
-
const processError = (error49,
|
|
13455
|
+
const processError = (error49, path29 = []) => {
|
|
13209
13456
|
var _a2, _b;
|
|
13210
13457
|
for (const issue2 of error49.issues) {
|
|
13211
13458
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -13215,7 +13462,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
13215
13462
|
} else if (issue2.code === "invalid_element") {
|
|
13216
13463
|
processError({ issues: issue2.issues }, issue2.path);
|
|
13217
13464
|
} else {
|
|
13218
|
-
const fullpath = [...
|
|
13465
|
+
const fullpath = [...path29, ...issue2.path];
|
|
13219
13466
|
if (fullpath.length === 0) {
|
|
13220
13467
|
result.errors.push(mapper(issue2));
|
|
13221
13468
|
continue;
|
|
@@ -13247,8 +13494,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
13247
13494
|
}
|
|
13248
13495
|
function toDotPath(_path) {
|
|
13249
13496
|
const segs = [];
|
|
13250
|
-
const
|
|
13251
|
-
for (const seg of
|
|
13497
|
+
const path29 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
13498
|
+
for (const seg of path29) {
|
|
13252
13499
|
if (typeof seg === "number")
|
|
13253
13500
|
segs.push(`[${seg}]`);
|
|
13254
13501
|
else if (typeof seg === "symbol")
|
|
@@ -14335,7 +14582,7 @@ function mergeValues(a, b) {
|
|
|
14335
14582
|
if (a instanceof Date && b instanceof Date && +a === +b) {
|
|
14336
14583
|
return { valid: true, data: a };
|
|
14337
14584
|
}
|
|
14338
|
-
if (
|
|
14585
|
+
if (isPlainObject4(a) && isPlainObject4(b)) {
|
|
14339
14586
|
const bKeys = Object.keys(b);
|
|
14340
14587
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
14341
14588
|
const newObj = { ...a, ...b };
|
|
@@ -15530,7 +15777,7 @@ var init_schemas = __esm({
|
|
|
15530
15777
|
$ZodType.init(inst, def);
|
|
15531
15778
|
inst._zod.parse = (payload, ctx) => {
|
|
15532
15779
|
const input = payload.value;
|
|
15533
|
-
if (!
|
|
15780
|
+
if (!isPlainObject4(input)) {
|
|
15534
15781
|
payload.issues.push({
|
|
15535
15782
|
expected: "record",
|
|
15536
15783
|
code: "invalid_type",
|
|
@@ -26012,13 +26259,13 @@ function resolveRef(ref, ctx) {
|
|
|
26012
26259
|
if (!ref.startsWith("#")) {
|
|
26013
26260
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
26014
26261
|
}
|
|
26015
|
-
const
|
|
26016
|
-
if (
|
|
26262
|
+
const path29 = ref.slice(1).split("/").filter(Boolean);
|
|
26263
|
+
if (path29.length === 0) {
|
|
26017
26264
|
return ctx.rootSchema;
|
|
26018
26265
|
}
|
|
26019
26266
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
26020
|
-
if (
|
|
26021
|
-
const key =
|
|
26267
|
+
if (path29[0] === defsKey) {
|
|
26268
|
+
const key = path29[1];
|
|
26022
26269
|
if (!key || !ctx.defs[key]) {
|
|
26023
26270
|
throw new Error(`Reference not found: ${ref}`);
|
|
26024
26271
|
}
|
|
@@ -28700,25 +28947,6 @@ function getPromptCapabilityFlags(agentCapabilities) {
|
|
|
28700
28947
|
embeddedContext: prompt2.embeddedContext === true
|
|
28701
28948
|
};
|
|
28702
28949
|
}
|
|
28703
|
-
function getResourceNameFromUri(uri, fallback2) {
|
|
28704
|
-
try {
|
|
28705
|
-
if (uri.startsWith("file://")) {
|
|
28706
|
-
return path12.basename(new URL(uri).pathname) || fallback2;
|
|
28707
|
-
}
|
|
28708
|
-
return path12.basename(uri) || fallback2;
|
|
28709
|
-
} catch {
|
|
28710
|
-
return fallback2;
|
|
28711
|
-
}
|
|
28712
|
-
}
|
|
28713
|
-
function inputPartToResourceLink(part, fallbackName) {
|
|
28714
|
-
if (!part.uri) return null;
|
|
28715
|
-
return {
|
|
28716
|
-
type: "resource_link",
|
|
28717
|
-
uri: part.uri,
|
|
28718
|
-
name: getResourceNameFromUri(part.uri, fallbackName),
|
|
28719
|
-
...part.mimeType ? { mimeType: part.mimeType } : {}
|
|
28720
|
-
};
|
|
28721
|
-
}
|
|
28722
28950
|
function appendPromptText(promptParts, text) {
|
|
28723
28951
|
const normalized = typeof text === "string" ? text.trim() : "";
|
|
28724
28952
|
if (!normalized) return;
|
|
@@ -28735,67 +28963,72 @@ function buildAcpPromptParts(input, agentCapabilities) {
|
|
|
28735
28963
|
continue;
|
|
28736
28964
|
}
|
|
28737
28965
|
if (part.type === "image") {
|
|
28738
|
-
if (caps.image
|
|
28739
|
-
|
|
28740
|
-
|
|
28741
|
-
|
|
28742
|
-
|
|
28743
|
-
...part.uri ? { uri: part.uri } : {}
|
|
28744
|
-
});
|
|
28745
|
-
continue;
|
|
28966
|
+
if (!caps.image) {
|
|
28967
|
+
throw new Error("ACP agent does not support input type: image");
|
|
28968
|
+
}
|
|
28969
|
+
if (!part.data) {
|
|
28970
|
+
throw new Error("ACP image input requires inline image data");
|
|
28746
28971
|
}
|
|
28747
|
-
|
|
28748
|
-
|
|
28749
|
-
|
|
28972
|
+
promptParts.push({
|
|
28973
|
+
type: "image",
|
|
28974
|
+
data: part.data,
|
|
28975
|
+
mimeType: part.mimeType,
|
|
28976
|
+
...part.uri ? { uri: part.uri } : {}
|
|
28977
|
+
});
|
|
28750
28978
|
continue;
|
|
28751
28979
|
}
|
|
28752
28980
|
if (part.type === "audio") {
|
|
28753
|
-
if (caps.audio
|
|
28754
|
-
|
|
28755
|
-
|
|
28756
|
-
|
|
28757
|
-
|
|
28758
|
-
});
|
|
28759
|
-
continue;
|
|
28981
|
+
if (!caps.audio) {
|
|
28982
|
+
throw new Error("ACP agent does not support input type: audio");
|
|
28983
|
+
}
|
|
28984
|
+
if (!part.data) {
|
|
28985
|
+
throw new Error("ACP audio input requires inline audio data");
|
|
28760
28986
|
}
|
|
28761
|
-
|
|
28762
|
-
|
|
28763
|
-
|
|
28987
|
+
promptParts.push({
|
|
28988
|
+
type: "audio",
|
|
28989
|
+
data: part.data,
|
|
28990
|
+
mimeType: part.mimeType
|
|
28991
|
+
});
|
|
28764
28992
|
continue;
|
|
28765
28993
|
}
|
|
28766
28994
|
if (part.type === "resource") {
|
|
28767
|
-
if (caps.embeddedContext
|
|
28995
|
+
if (!caps.embeddedContext) {
|
|
28996
|
+
throw new Error("ACP agent does not support input type: resource");
|
|
28997
|
+
}
|
|
28998
|
+
if (part.text) {
|
|
28768
28999
|
promptParts.push({
|
|
28769
29000
|
type: "resource",
|
|
28770
|
-
resource:
|
|
29001
|
+
resource: { uri: part.uri, text: part.text, mimeType: part.mimeType ?? null }
|
|
28771
29002
|
});
|
|
28772
29003
|
continue;
|
|
28773
29004
|
}
|
|
28774
|
-
|
|
28775
|
-
|
|
28776
|
-
|
|
28777
|
-
|
|
29005
|
+
if (part.data) {
|
|
29006
|
+
promptParts.push({
|
|
29007
|
+
type: "resource",
|
|
29008
|
+
resource: { uri: part.uri, blob: part.data, mimeType: part.mimeType ?? null }
|
|
29009
|
+
});
|
|
29010
|
+
continue;
|
|
29011
|
+
}
|
|
29012
|
+
throw new Error("ACP resource input requires embedded text or binary data");
|
|
28778
29013
|
}
|
|
28779
29014
|
if (part.type === "video") {
|
|
28780
|
-
|
|
28781
|
-
if (fallback2) promptParts.push(fallback2);
|
|
28782
|
-
appendPromptText(promptParts, !part.uri ? `Attached video (${part.mimeType})` : void 0);
|
|
29015
|
+
throw new Error("ACP agent does not support input type: video");
|
|
28783
29016
|
}
|
|
28784
29017
|
}
|
|
28785
29018
|
if (!promptParts.some((part) => part.type === "text") && input.textFallback) {
|
|
28786
|
-
promptParts
|
|
29019
|
+
appendPromptText(promptParts, input.textFallback);
|
|
28787
29020
|
}
|
|
28788
29021
|
return promptParts;
|
|
28789
29022
|
}
|
|
28790
|
-
var
|
|
29023
|
+
var import_stream, import_child_process5, AcpProviderInstance;
|
|
28791
29024
|
var init_acp_provider_instance = __esm({
|
|
28792
29025
|
"../../oss/packages/daemon-core/src/providers/acp-provider-instance.ts"() {
|
|
28793
29026
|
"use strict";
|
|
28794
|
-
path12 = __toESM(require("path"));
|
|
28795
29027
|
import_stream = require("stream");
|
|
28796
29028
|
import_child_process5 = require("child_process");
|
|
28797
29029
|
init_acp();
|
|
28798
29030
|
init_contracts();
|
|
29031
|
+
init_provider_input_support();
|
|
28799
29032
|
init_status_monitor();
|
|
28800
29033
|
init_summary_metadata();
|
|
28801
29034
|
init_chat_message_normalization();
|
|
@@ -28927,6 +29160,7 @@ var init_acp_provider_instance = __esm({
|
|
|
28927
29160
|
onEvent(event, data) {
|
|
28928
29161
|
if (event === "send_message") {
|
|
28929
29162
|
const input = normalizeInputEnvelope(data);
|
|
29163
|
+
assertProviderSupportsDeclaredInput(this.provider, input);
|
|
28930
29164
|
const promptParts = buildAcpPromptParts(input, this.agentCapabilities);
|
|
28931
29165
|
this.sendPrompt(input.textFallback, promptParts.length > 0 ? promptParts : void 0).catch(
|
|
28932
29166
|
(e) => this.log.warn(`[${this.type}] sendPrompt error: ${e?.message}`)
|
|
@@ -29986,12 +30220,12 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
29986
30220
|
launchMode: "new"
|
|
29987
30221
|
};
|
|
29988
30222
|
}
|
|
29989
|
-
var os14,
|
|
30223
|
+
var os14, path12, crypto4, chalkModule, chalkApi, DaemonCliManager;
|
|
29990
30224
|
var init_cli_manager = __esm({
|
|
29991
30225
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
29992
30226
|
"use strict";
|
|
29993
30227
|
os14 = __toESM(require("os"));
|
|
29994
|
-
|
|
30228
|
+
path12 = __toESM(require("path"));
|
|
29995
30229
|
crypto4 = __toESM(require("crypto"));
|
|
29996
30230
|
init_source();
|
|
29997
30231
|
init_provider_cli_adapter();
|
|
@@ -30005,6 +30239,7 @@ var init_cli_manager = __esm({
|
|
|
30005
30239
|
init_cli_provider_instance();
|
|
30006
30240
|
init_acp_provider_instance();
|
|
30007
30241
|
init_contracts();
|
|
30242
|
+
init_provider_input_support();
|
|
30008
30243
|
init_logger();
|
|
30009
30244
|
init_hosted_runtime_restore();
|
|
30010
30245
|
chalkModule = source_default;
|
|
@@ -30151,7 +30386,7 @@ var init_cli_manager = __esm({
|
|
|
30151
30386
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
30152
30387
|
const trimmed = (workingDir || "").trim();
|
|
30153
30388
|
if (!trimmed) throw new Error("working directory required");
|
|
30154
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) :
|
|
30389
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path12.resolve(trimmed);
|
|
30155
30390
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
30156
30391
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
30157
30392
|
const key = crypto4.randomUUID();
|
|
@@ -30610,6 +30845,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
30610
30845
|
const { adapter, key } = found;
|
|
30611
30846
|
if (action === "send_chat") {
|
|
30612
30847
|
const input = normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
30848
|
+
const provider = this.providerLoader.resolve(agentType) || this.providerLoader.getMeta(agentType);
|
|
30849
|
+
if (provider?.category === "acp") {
|
|
30850
|
+
assertProviderSupportsDeclaredInput(provider, input);
|
|
30851
|
+
} else {
|
|
30852
|
+
assertTextOnlyInput(provider, input);
|
|
30853
|
+
}
|
|
30613
30854
|
const message = input.textFallback;
|
|
30614
30855
|
if (!message) throw new Error("message required for send_chat");
|
|
30615
30856
|
await adapter.sendMessage(message);
|
|
@@ -30734,7 +30975,7 @@ var init_readdirp = __esm({
|
|
|
30734
30975
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
30735
30976
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
30736
30977
|
if (wantBigintFsStats) {
|
|
30737
|
-
this._stat = (
|
|
30978
|
+
this._stat = (path29) => statMethod(path29, { bigint: true });
|
|
30738
30979
|
} else {
|
|
30739
30980
|
this._stat = statMethod;
|
|
30740
30981
|
}
|
|
@@ -30759,8 +31000,8 @@ var init_readdirp = __esm({
|
|
|
30759
31000
|
const par = this.parent;
|
|
30760
31001
|
const fil = par && par.files;
|
|
30761
31002
|
if (fil && fil.length > 0) {
|
|
30762
|
-
const { path:
|
|
30763
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
31003
|
+
const { path: path29, depth } = par;
|
|
31004
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path29));
|
|
30764
31005
|
const awaited = await Promise.all(slice);
|
|
30765
31006
|
for (const entry of awaited) {
|
|
30766
31007
|
if (!entry)
|
|
@@ -30800,21 +31041,21 @@ var init_readdirp = __esm({
|
|
|
30800
31041
|
this.reading = false;
|
|
30801
31042
|
}
|
|
30802
31043
|
}
|
|
30803
|
-
async _exploreDir(
|
|
31044
|
+
async _exploreDir(path29, depth) {
|
|
30804
31045
|
let files;
|
|
30805
31046
|
try {
|
|
30806
|
-
files = await (0, import_promises.readdir)(
|
|
31047
|
+
files = await (0, import_promises.readdir)(path29, this._rdOptions);
|
|
30807
31048
|
} catch (error48) {
|
|
30808
31049
|
this._onError(error48);
|
|
30809
31050
|
}
|
|
30810
|
-
return { files, depth, path:
|
|
31051
|
+
return { files, depth, path: path29 };
|
|
30811
31052
|
}
|
|
30812
|
-
async _formatEntry(dirent,
|
|
31053
|
+
async _formatEntry(dirent, path29) {
|
|
30813
31054
|
let entry;
|
|
30814
|
-
const
|
|
31055
|
+
const basename8 = this._isDirent ? dirent.name : dirent;
|
|
30815
31056
|
try {
|
|
30816
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
30817
|
-
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename:
|
|
31057
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path29, basename8));
|
|
31058
|
+
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename8 };
|
|
30818
31059
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
30819
31060
|
} catch (err) {
|
|
30820
31061
|
this._onError(err);
|
|
@@ -30870,16 +31111,16 @@ var init_readdirp = __esm({
|
|
|
30870
31111
|
});
|
|
30871
31112
|
|
|
30872
31113
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
30873
|
-
function createFsWatchInstance(
|
|
31114
|
+
function createFsWatchInstance(path29, options, listener, errHandler, emitRaw) {
|
|
30874
31115
|
const handleEvent = (rawEvent, evPath) => {
|
|
30875
|
-
listener(
|
|
30876
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
30877
|
-
if (evPath &&
|
|
30878
|
-
fsWatchBroadcast(sp.resolve(
|
|
31116
|
+
listener(path29);
|
|
31117
|
+
emitRaw(rawEvent, evPath, { watchedPath: path29 });
|
|
31118
|
+
if (evPath && path29 !== evPath) {
|
|
31119
|
+
fsWatchBroadcast(sp.resolve(path29, evPath), KEY_LISTENERS, sp.join(path29, evPath));
|
|
30879
31120
|
}
|
|
30880
31121
|
};
|
|
30881
31122
|
try {
|
|
30882
|
-
return (0, import_node_fs.watch)(
|
|
31123
|
+
return (0, import_node_fs.watch)(path29, {
|
|
30883
31124
|
persistent: options.persistent
|
|
30884
31125
|
}, handleEvent);
|
|
30885
31126
|
} catch (error48) {
|
|
@@ -31228,12 +31469,12 @@ var init_handler2 = __esm({
|
|
|
31228
31469
|
listener(val1, val2, val3);
|
|
31229
31470
|
});
|
|
31230
31471
|
};
|
|
31231
|
-
setFsWatchListener = (
|
|
31472
|
+
setFsWatchListener = (path29, fullPath, options, handlers) => {
|
|
31232
31473
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
31233
31474
|
let cont = FsWatchInstances.get(fullPath);
|
|
31234
31475
|
let watcher;
|
|
31235
31476
|
if (!options.persistent) {
|
|
31236
|
-
watcher = createFsWatchInstance(
|
|
31477
|
+
watcher = createFsWatchInstance(path29, options, listener, errHandler, rawEmitter);
|
|
31237
31478
|
if (!watcher)
|
|
31238
31479
|
return;
|
|
31239
31480
|
return watcher.close.bind(watcher);
|
|
@@ -31244,7 +31485,7 @@ var init_handler2 = __esm({
|
|
|
31244
31485
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
31245
31486
|
} else {
|
|
31246
31487
|
watcher = createFsWatchInstance(
|
|
31247
|
-
|
|
31488
|
+
path29,
|
|
31248
31489
|
options,
|
|
31249
31490
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
31250
31491
|
errHandler,
|
|
@@ -31259,7 +31500,7 @@ var init_handler2 = __esm({
|
|
|
31259
31500
|
cont.watcherUnusable = true;
|
|
31260
31501
|
if (isWindows && error48.code === "EPERM") {
|
|
31261
31502
|
try {
|
|
31262
|
-
const fd = await (0, import_promises2.open)(
|
|
31503
|
+
const fd = await (0, import_promises2.open)(path29, "r");
|
|
31263
31504
|
await fd.close();
|
|
31264
31505
|
broadcastErr(error48);
|
|
31265
31506
|
} catch (err) {
|
|
@@ -31290,7 +31531,7 @@ var init_handler2 = __esm({
|
|
|
31290
31531
|
};
|
|
31291
31532
|
};
|
|
31292
31533
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
31293
|
-
setFsWatchFileListener = (
|
|
31534
|
+
setFsWatchFileListener = (path29, fullPath, options, handlers) => {
|
|
31294
31535
|
const { listener, rawEmitter } = handlers;
|
|
31295
31536
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
31296
31537
|
const copts = cont && cont.options;
|
|
@@ -31312,7 +31553,7 @@ var init_handler2 = __esm({
|
|
|
31312
31553
|
});
|
|
31313
31554
|
const currmtime = curr.mtimeMs;
|
|
31314
31555
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
31315
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
31556
|
+
foreach(cont.listeners, (listener2) => listener2(path29, curr));
|
|
31316
31557
|
}
|
|
31317
31558
|
})
|
|
31318
31559
|
};
|
|
@@ -31342,13 +31583,13 @@ var init_handler2 = __esm({
|
|
|
31342
31583
|
* @param listener on fs change
|
|
31343
31584
|
* @returns closer for the watcher instance
|
|
31344
31585
|
*/
|
|
31345
|
-
_watchWithNodeFs(
|
|
31586
|
+
_watchWithNodeFs(path29, listener) {
|
|
31346
31587
|
const opts = this.fsw.options;
|
|
31347
|
-
const directory = sp.dirname(
|
|
31348
|
-
const
|
|
31588
|
+
const directory = sp.dirname(path29);
|
|
31589
|
+
const basename8 = sp.basename(path29);
|
|
31349
31590
|
const parent = this.fsw._getWatchedDir(directory);
|
|
31350
|
-
parent.add(
|
|
31351
|
-
const absolutePath = sp.resolve(
|
|
31591
|
+
parent.add(basename8);
|
|
31592
|
+
const absolutePath = sp.resolve(path29);
|
|
31352
31593
|
const options = {
|
|
31353
31594
|
persistent: opts.persistent
|
|
31354
31595
|
};
|
|
@@ -31357,13 +31598,13 @@ var init_handler2 = __esm({
|
|
|
31357
31598
|
let closer;
|
|
31358
31599
|
if (opts.usePolling) {
|
|
31359
31600
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
31360
|
-
options.interval = enableBin && isBinaryPath(
|
|
31361
|
-
closer = setFsWatchFileListener(
|
|
31601
|
+
options.interval = enableBin && isBinaryPath(basename8) ? opts.binaryInterval : opts.interval;
|
|
31602
|
+
closer = setFsWatchFileListener(path29, absolutePath, options, {
|
|
31362
31603
|
listener,
|
|
31363
31604
|
rawEmitter: this.fsw._emitRaw
|
|
31364
31605
|
});
|
|
31365
31606
|
} else {
|
|
31366
|
-
closer = setFsWatchListener(
|
|
31607
|
+
closer = setFsWatchListener(path29, absolutePath, options, {
|
|
31367
31608
|
listener,
|
|
31368
31609
|
errHandler: this._boundHandleError,
|
|
31369
31610
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -31380,12 +31621,12 @@ var init_handler2 = __esm({
|
|
|
31380
31621
|
return;
|
|
31381
31622
|
}
|
|
31382
31623
|
const dirname9 = sp.dirname(file2);
|
|
31383
|
-
const
|
|
31624
|
+
const basename8 = sp.basename(file2);
|
|
31384
31625
|
const parent = this.fsw._getWatchedDir(dirname9);
|
|
31385
31626
|
let prevStats = stats;
|
|
31386
|
-
if (parent.has(
|
|
31627
|
+
if (parent.has(basename8))
|
|
31387
31628
|
return;
|
|
31388
|
-
const listener = async (
|
|
31629
|
+
const listener = async (path29, newStats) => {
|
|
31389
31630
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
31390
31631
|
return;
|
|
31391
31632
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -31399,18 +31640,18 @@ var init_handler2 = __esm({
|
|
|
31399
31640
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
31400
31641
|
}
|
|
31401
31642
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
31402
|
-
this.fsw._closeFile(
|
|
31643
|
+
this.fsw._closeFile(path29);
|
|
31403
31644
|
prevStats = newStats2;
|
|
31404
31645
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
31405
31646
|
if (closer2)
|
|
31406
|
-
this.fsw._addPathCloser(
|
|
31647
|
+
this.fsw._addPathCloser(path29, closer2);
|
|
31407
31648
|
} else {
|
|
31408
31649
|
prevStats = newStats2;
|
|
31409
31650
|
}
|
|
31410
31651
|
} catch (error48) {
|
|
31411
|
-
this.fsw._remove(dirname9,
|
|
31652
|
+
this.fsw._remove(dirname9, basename8);
|
|
31412
31653
|
}
|
|
31413
|
-
} else if (parent.has(
|
|
31654
|
+
} else if (parent.has(basename8)) {
|
|
31414
31655
|
const at = newStats.atimeMs;
|
|
31415
31656
|
const mt = newStats.mtimeMs;
|
|
31416
31657
|
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
|
@@ -31435,7 +31676,7 @@ var init_handler2 = __esm({
|
|
|
31435
31676
|
* @param item basename of this item
|
|
31436
31677
|
* @returns true if no more processing is needed for this entry.
|
|
31437
31678
|
*/
|
|
31438
|
-
async _handleSymlink(entry, directory,
|
|
31679
|
+
async _handleSymlink(entry, directory, path29, item) {
|
|
31439
31680
|
if (this.fsw.closed) {
|
|
31440
31681
|
return;
|
|
31441
31682
|
}
|
|
@@ -31445,7 +31686,7 @@ var init_handler2 = __esm({
|
|
|
31445
31686
|
this.fsw._incrReadyCount();
|
|
31446
31687
|
let linkPath;
|
|
31447
31688
|
try {
|
|
31448
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
31689
|
+
linkPath = await (0, import_promises2.realpath)(path29);
|
|
31449
31690
|
} catch (e) {
|
|
31450
31691
|
this.fsw._emitReady();
|
|
31451
31692
|
return true;
|
|
@@ -31455,12 +31696,12 @@ var init_handler2 = __esm({
|
|
|
31455
31696
|
if (dir.has(item)) {
|
|
31456
31697
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
31457
31698
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
31458
|
-
this.fsw._emit(EV.CHANGE,
|
|
31699
|
+
this.fsw._emit(EV.CHANGE, path29, entry.stats);
|
|
31459
31700
|
}
|
|
31460
31701
|
} else {
|
|
31461
31702
|
dir.add(item);
|
|
31462
31703
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
31463
|
-
this.fsw._emit(EV.ADD,
|
|
31704
|
+
this.fsw._emit(EV.ADD, path29, entry.stats);
|
|
31464
31705
|
}
|
|
31465
31706
|
this.fsw._emitReady();
|
|
31466
31707
|
return true;
|
|
@@ -31490,9 +31731,9 @@ var init_handler2 = __esm({
|
|
|
31490
31731
|
return;
|
|
31491
31732
|
}
|
|
31492
31733
|
const item = entry.path;
|
|
31493
|
-
let
|
|
31734
|
+
let path29 = sp.join(directory, item);
|
|
31494
31735
|
current.add(item);
|
|
31495
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
31736
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path29, item)) {
|
|
31496
31737
|
return;
|
|
31497
31738
|
}
|
|
31498
31739
|
if (this.fsw.closed) {
|
|
@@ -31501,8 +31742,8 @@ var init_handler2 = __esm({
|
|
|
31501
31742
|
}
|
|
31502
31743
|
if (item === target || !target && !previous.has(item)) {
|
|
31503
31744
|
this.fsw._incrReadyCount();
|
|
31504
|
-
|
|
31505
|
-
this._addToNodeFs(
|
|
31745
|
+
path29 = sp.join(dir, sp.relative(dir, path29));
|
|
31746
|
+
this._addToNodeFs(path29, initialAdd, wh, depth + 1);
|
|
31506
31747
|
}
|
|
31507
31748
|
}).on(EV.ERROR, this._boundHandleError);
|
|
31508
31749
|
return new Promise((resolve15, reject) => {
|
|
@@ -31571,13 +31812,13 @@ var init_handler2 = __esm({
|
|
|
31571
31812
|
* @param depth Child path actually targeted for watch
|
|
31572
31813
|
* @param target Child path actually targeted for watch
|
|
31573
31814
|
*/
|
|
31574
|
-
async _addToNodeFs(
|
|
31815
|
+
async _addToNodeFs(path29, initialAdd, priorWh, depth, target) {
|
|
31575
31816
|
const ready = this.fsw._emitReady;
|
|
31576
|
-
if (this.fsw._isIgnored(
|
|
31817
|
+
if (this.fsw._isIgnored(path29) || this.fsw.closed) {
|
|
31577
31818
|
ready();
|
|
31578
31819
|
return false;
|
|
31579
31820
|
}
|
|
31580
|
-
const wh = this.fsw._getWatchHelpers(
|
|
31821
|
+
const wh = this.fsw._getWatchHelpers(path29);
|
|
31581
31822
|
if (priorWh) {
|
|
31582
31823
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
31583
31824
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -31593,8 +31834,8 @@ var init_handler2 = __esm({
|
|
|
31593
31834
|
const follow = this.fsw.options.followSymlinks;
|
|
31594
31835
|
let closer;
|
|
31595
31836
|
if (stats.isDirectory()) {
|
|
31596
|
-
const absPath = sp.resolve(
|
|
31597
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
31837
|
+
const absPath = sp.resolve(path29);
|
|
31838
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path29) : path29;
|
|
31598
31839
|
if (this.fsw.closed)
|
|
31599
31840
|
return;
|
|
31600
31841
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -31604,29 +31845,29 @@ var init_handler2 = __esm({
|
|
|
31604
31845
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
31605
31846
|
}
|
|
31606
31847
|
} else if (stats.isSymbolicLink()) {
|
|
31607
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
31848
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path29) : path29;
|
|
31608
31849
|
if (this.fsw.closed)
|
|
31609
31850
|
return;
|
|
31610
31851
|
const parent = sp.dirname(wh.watchPath);
|
|
31611
31852
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
31612
31853
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
31613
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
31854
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path29, wh, targetPath);
|
|
31614
31855
|
if (this.fsw.closed)
|
|
31615
31856
|
return;
|
|
31616
31857
|
if (targetPath !== void 0) {
|
|
31617
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
31858
|
+
this.fsw._symlinkPaths.set(sp.resolve(path29), targetPath);
|
|
31618
31859
|
}
|
|
31619
31860
|
} else {
|
|
31620
31861
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
31621
31862
|
}
|
|
31622
31863
|
ready();
|
|
31623
31864
|
if (closer)
|
|
31624
|
-
this.fsw._addPathCloser(
|
|
31865
|
+
this.fsw._addPathCloser(path29, closer);
|
|
31625
31866
|
return false;
|
|
31626
31867
|
} catch (error48) {
|
|
31627
31868
|
if (this.fsw._handleError(error48)) {
|
|
31628
31869
|
ready();
|
|
31629
|
-
return
|
|
31870
|
+
return path29;
|
|
31630
31871
|
}
|
|
31631
31872
|
}
|
|
31632
31873
|
}
|
|
@@ -31661,24 +31902,24 @@ function createPattern(matcher) {
|
|
|
31661
31902
|
}
|
|
31662
31903
|
return () => false;
|
|
31663
31904
|
}
|
|
31664
|
-
function normalizePath(
|
|
31665
|
-
if (typeof
|
|
31905
|
+
function normalizePath(path29) {
|
|
31906
|
+
if (typeof path29 !== "string")
|
|
31666
31907
|
throw new Error("string expected");
|
|
31667
|
-
|
|
31668
|
-
|
|
31908
|
+
path29 = sp2.normalize(path29);
|
|
31909
|
+
path29 = path29.replace(/\\/g, "/");
|
|
31669
31910
|
let prepend = false;
|
|
31670
|
-
if (
|
|
31911
|
+
if (path29.startsWith("//"))
|
|
31671
31912
|
prepend = true;
|
|
31672
|
-
|
|
31913
|
+
path29 = path29.replace(DOUBLE_SLASH_RE, "/");
|
|
31673
31914
|
if (prepend)
|
|
31674
|
-
|
|
31675
|
-
return
|
|
31915
|
+
path29 = "/" + path29;
|
|
31916
|
+
return path29;
|
|
31676
31917
|
}
|
|
31677
31918
|
function matchPatterns(patterns, testString, stats) {
|
|
31678
|
-
const
|
|
31919
|
+
const path29 = normalizePath(testString);
|
|
31679
31920
|
for (let index = 0; index < patterns.length; index++) {
|
|
31680
31921
|
const pattern = patterns[index];
|
|
31681
|
-
if (pattern(
|
|
31922
|
+
if (pattern(path29, stats)) {
|
|
31682
31923
|
return true;
|
|
31683
31924
|
}
|
|
31684
31925
|
}
|
|
@@ -31741,19 +31982,19 @@ var init_chokidar = __esm({
|
|
|
31741
31982
|
}
|
|
31742
31983
|
return str;
|
|
31743
31984
|
};
|
|
31744
|
-
normalizePathToUnix = (
|
|
31745
|
-
normalizeIgnored = (cwd = "") => (
|
|
31746
|
-
if (typeof
|
|
31747
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
31985
|
+
normalizePathToUnix = (path29) => toUnix(sp2.normalize(toUnix(path29)));
|
|
31986
|
+
normalizeIgnored = (cwd = "") => (path29) => {
|
|
31987
|
+
if (typeof path29 === "string") {
|
|
31988
|
+
return normalizePathToUnix(sp2.isAbsolute(path29) ? path29 : sp2.join(cwd, path29));
|
|
31748
31989
|
} else {
|
|
31749
|
-
return
|
|
31990
|
+
return path29;
|
|
31750
31991
|
}
|
|
31751
31992
|
};
|
|
31752
|
-
getAbsolutePath = (
|
|
31753
|
-
if (sp2.isAbsolute(
|
|
31754
|
-
return
|
|
31993
|
+
getAbsolutePath = (path29, cwd) => {
|
|
31994
|
+
if (sp2.isAbsolute(path29)) {
|
|
31995
|
+
return path29;
|
|
31755
31996
|
}
|
|
31756
|
-
return sp2.join(cwd,
|
|
31997
|
+
return sp2.join(cwd, path29);
|
|
31757
31998
|
};
|
|
31758
31999
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
31759
32000
|
DirEntry = class {
|
|
@@ -31818,10 +32059,10 @@ var init_chokidar = __esm({
|
|
|
31818
32059
|
dirParts;
|
|
31819
32060
|
followSymlinks;
|
|
31820
32061
|
statMethod;
|
|
31821
|
-
constructor(
|
|
32062
|
+
constructor(path29, follow, fsw) {
|
|
31822
32063
|
this.fsw = fsw;
|
|
31823
|
-
const watchPath =
|
|
31824
|
-
this.path =
|
|
32064
|
+
const watchPath = path29;
|
|
32065
|
+
this.path = path29 = path29.replace(REPLACER_RE, "");
|
|
31825
32066
|
this.watchPath = watchPath;
|
|
31826
32067
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
31827
32068
|
this.dirParts = [];
|
|
@@ -31961,20 +32202,20 @@ var init_chokidar = __esm({
|
|
|
31961
32202
|
this._closePromise = void 0;
|
|
31962
32203
|
let paths = unifyPaths(paths_);
|
|
31963
32204
|
if (cwd) {
|
|
31964
|
-
paths = paths.map((
|
|
31965
|
-
const absPath = getAbsolutePath(
|
|
32205
|
+
paths = paths.map((path29) => {
|
|
32206
|
+
const absPath = getAbsolutePath(path29, cwd);
|
|
31966
32207
|
return absPath;
|
|
31967
32208
|
});
|
|
31968
32209
|
}
|
|
31969
|
-
paths.forEach((
|
|
31970
|
-
this._removeIgnoredPath(
|
|
32210
|
+
paths.forEach((path29) => {
|
|
32211
|
+
this._removeIgnoredPath(path29);
|
|
31971
32212
|
});
|
|
31972
32213
|
this._userIgnored = void 0;
|
|
31973
32214
|
if (!this._readyCount)
|
|
31974
32215
|
this._readyCount = 0;
|
|
31975
32216
|
this._readyCount += paths.length;
|
|
31976
|
-
Promise.all(paths.map(async (
|
|
31977
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
32217
|
+
Promise.all(paths.map(async (path29) => {
|
|
32218
|
+
const res = await this._nodeFsHandler._addToNodeFs(path29, !_internal, void 0, 0, _origAdd);
|
|
31978
32219
|
if (res)
|
|
31979
32220
|
this._emitReady();
|
|
31980
32221
|
return res;
|
|
@@ -31996,17 +32237,17 @@ var init_chokidar = __esm({
|
|
|
31996
32237
|
return this;
|
|
31997
32238
|
const paths = unifyPaths(paths_);
|
|
31998
32239
|
const { cwd } = this.options;
|
|
31999
|
-
paths.forEach((
|
|
32000
|
-
if (!sp2.isAbsolute(
|
|
32240
|
+
paths.forEach((path29) => {
|
|
32241
|
+
if (!sp2.isAbsolute(path29) && !this._closers.has(path29)) {
|
|
32001
32242
|
if (cwd)
|
|
32002
|
-
|
|
32003
|
-
|
|
32243
|
+
path29 = sp2.join(cwd, path29);
|
|
32244
|
+
path29 = sp2.resolve(path29);
|
|
32004
32245
|
}
|
|
32005
|
-
this._closePath(
|
|
32006
|
-
this._addIgnoredPath(
|
|
32007
|
-
if (this._watched.has(
|
|
32246
|
+
this._closePath(path29);
|
|
32247
|
+
this._addIgnoredPath(path29);
|
|
32248
|
+
if (this._watched.has(path29)) {
|
|
32008
32249
|
this._addIgnoredPath({
|
|
32009
|
-
path:
|
|
32250
|
+
path: path29,
|
|
32010
32251
|
recursive: true
|
|
32011
32252
|
});
|
|
32012
32253
|
}
|
|
@@ -32070,38 +32311,38 @@ var init_chokidar = __esm({
|
|
|
32070
32311
|
* @param stats arguments to be passed with event
|
|
32071
32312
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
32072
32313
|
*/
|
|
32073
|
-
async _emit(event,
|
|
32314
|
+
async _emit(event, path29, stats) {
|
|
32074
32315
|
if (this.closed)
|
|
32075
32316
|
return;
|
|
32076
32317
|
const opts = this.options;
|
|
32077
32318
|
if (isWindows)
|
|
32078
|
-
|
|
32319
|
+
path29 = sp2.normalize(path29);
|
|
32079
32320
|
if (opts.cwd)
|
|
32080
|
-
|
|
32081
|
-
const args = [
|
|
32321
|
+
path29 = sp2.relative(opts.cwd, path29);
|
|
32322
|
+
const args = [path29];
|
|
32082
32323
|
if (stats != null)
|
|
32083
32324
|
args.push(stats);
|
|
32084
32325
|
const awf = opts.awaitWriteFinish;
|
|
32085
32326
|
let pw;
|
|
32086
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
32327
|
+
if (awf && (pw = this._pendingWrites.get(path29))) {
|
|
32087
32328
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
32088
32329
|
return this;
|
|
32089
32330
|
}
|
|
32090
32331
|
if (opts.atomic) {
|
|
32091
32332
|
if (event === EVENTS.UNLINK) {
|
|
32092
|
-
this._pendingUnlinks.set(
|
|
32333
|
+
this._pendingUnlinks.set(path29, [event, ...args]);
|
|
32093
32334
|
setTimeout(() => {
|
|
32094
|
-
this._pendingUnlinks.forEach((entry,
|
|
32335
|
+
this._pendingUnlinks.forEach((entry, path30) => {
|
|
32095
32336
|
this.emit(...entry);
|
|
32096
32337
|
this.emit(EVENTS.ALL, ...entry);
|
|
32097
|
-
this._pendingUnlinks.delete(
|
|
32338
|
+
this._pendingUnlinks.delete(path30);
|
|
32098
32339
|
});
|
|
32099
32340
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
32100
32341
|
return this;
|
|
32101
32342
|
}
|
|
32102
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
32343
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path29)) {
|
|
32103
32344
|
event = EVENTS.CHANGE;
|
|
32104
|
-
this._pendingUnlinks.delete(
|
|
32345
|
+
this._pendingUnlinks.delete(path29);
|
|
32105
32346
|
}
|
|
32106
32347
|
}
|
|
32107
32348
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -32119,16 +32360,16 @@ var init_chokidar = __esm({
|
|
|
32119
32360
|
this.emitWithAll(event, args);
|
|
32120
32361
|
}
|
|
32121
32362
|
};
|
|
32122
|
-
this._awaitWriteFinish(
|
|
32363
|
+
this._awaitWriteFinish(path29, awf.stabilityThreshold, event, awfEmit);
|
|
32123
32364
|
return this;
|
|
32124
32365
|
}
|
|
32125
32366
|
if (event === EVENTS.CHANGE) {
|
|
32126
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
32367
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path29, 50);
|
|
32127
32368
|
if (isThrottled)
|
|
32128
32369
|
return this;
|
|
32129
32370
|
}
|
|
32130
32371
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
32131
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
32372
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path29) : path29;
|
|
32132
32373
|
let stats2;
|
|
32133
32374
|
try {
|
|
32134
32375
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -32159,23 +32400,23 @@ var init_chokidar = __esm({
|
|
|
32159
32400
|
* @param timeout duration of time to suppress duplicate actions
|
|
32160
32401
|
* @returns tracking object or false if action should be suppressed
|
|
32161
32402
|
*/
|
|
32162
|
-
_throttle(actionType,
|
|
32403
|
+
_throttle(actionType, path29, timeout) {
|
|
32163
32404
|
if (!this._throttled.has(actionType)) {
|
|
32164
32405
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
32165
32406
|
}
|
|
32166
32407
|
const action = this._throttled.get(actionType);
|
|
32167
32408
|
if (!action)
|
|
32168
32409
|
throw new Error("invalid throttle");
|
|
32169
|
-
const actionPath = action.get(
|
|
32410
|
+
const actionPath = action.get(path29);
|
|
32170
32411
|
if (actionPath) {
|
|
32171
32412
|
actionPath.count++;
|
|
32172
32413
|
return false;
|
|
32173
32414
|
}
|
|
32174
32415
|
let timeoutObject;
|
|
32175
32416
|
const clear = () => {
|
|
32176
|
-
const item = action.get(
|
|
32417
|
+
const item = action.get(path29);
|
|
32177
32418
|
const count = item ? item.count : 0;
|
|
32178
|
-
action.delete(
|
|
32419
|
+
action.delete(path29);
|
|
32179
32420
|
clearTimeout(timeoutObject);
|
|
32180
32421
|
if (item)
|
|
32181
32422
|
clearTimeout(item.timeoutObject);
|
|
@@ -32183,7 +32424,7 @@ var init_chokidar = __esm({
|
|
|
32183
32424
|
};
|
|
32184
32425
|
timeoutObject = setTimeout(clear, timeout);
|
|
32185
32426
|
const thr = { timeoutObject, clear, count: 0 };
|
|
32186
|
-
action.set(
|
|
32427
|
+
action.set(path29, thr);
|
|
32187
32428
|
return thr;
|
|
32188
32429
|
}
|
|
32189
32430
|
_incrReadyCount() {
|
|
@@ -32197,44 +32438,44 @@ var init_chokidar = __esm({
|
|
|
32197
32438
|
* @param event
|
|
32198
32439
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
32199
32440
|
*/
|
|
32200
|
-
_awaitWriteFinish(
|
|
32441
|
+
_awaitWriteFinish(path29, threshold, event, awfEmit) {
|
|
32201
32442
|
const awf = this.options.awaitWriteFinish;
|
|
32202
32443
|
if (typeof awf !== "object")
|
|
32203
32444
|
return;
|
|
32204
32445
|
const pollInterval = awf.pollInterval;
|
|
32205
32446
|
let timeoutHandler;
|
|
32206
|
-
let fullPath =
|
|
32207
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
32208
|
-
fullPath = sp2.join(this.options.cwd,
|
|
32447
|
+
let fullPath = path29;
|
|
32448
|
+
if (this.options.cwd && !sp2.isAbsolute(path29)) {
|
|
32449
|
+
fullPath = sp2.join(this.options.cwd, path29);
|
|
32209
32450
|
}
|
|
32210
32451
|
const now = /* @__PURE__ */ new Date();
|
|
32211
32452
|
const writes = this._pendingWrites;
|
|
32212
32453
|
function awaitWriteFinishFn(prevStat) {
|
|
32213
32454
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
32214
|
-
if (err || !writes.has(
|
|
32455
|
+
if (err || !writes.has(path29)) {
|
|
32215
32456
|
if (err && err.code !== "ENOENT")
|
|
32216
32457
|
awfEmit(err);
|
|
32217
32458
|
return;
|
|
32218
32459
|
}
|
|
32219
32460
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
32220
32461
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
32221
|
-
writes.get(
|
|
32462
|
+
writes.get(path29).lastChange = now2;
|
|
32222
32463
|
}
|
|
32223
|
-
const pw = writes.get(
|
|
32464
|
+
const pw = writes.get(path29);
|
|
32224
32465
|
const df = now2 - pw.lastChange;
|
|
32225
32466
|
if (df >= threshold) {
|
|
32226
|
-
writes.delete(
|
|
32467
|
+
writes.delete(path29);
|
|
32227
32468
|
awfEmit(void 0, curStat);
|
|
32228
32469
|
} else {
|
|
32229
32470
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
32230
32471
|
}
|
|
32231
32472
|
});
|
|
32232
32473
|
}
|
|
32233
|
-
if (!writes.has(
|
|
32234
|
-
writes.set(
|
|
32474
|
+
if (!writes.has(path29)) {
|
|
32475
|
+
writes.set(path29, {
|
|
32235
32476
|
lastChange: now,
|
|
32236
32477
|
cancelWait: () => {
|
|
32237
|
-
writes.delete(
|
|
32478
|
+
writes.delete(path29);
|
|
32238
32479
|
clearTimeout(timeoutHandler);
|
|
32239
32480
|
return event;
|
|
32240
32481
|
}
|
|
@@ -32245,8 +32486,8 @@ var init_chokidar = __esm({
|
|
|
32245
32486
|
/**
|
|
32246
32487
|
* Determines whether user has asked to ignore this path.
|
|
32247
32488
|
*/
|
|
32248
|
-
_isIgnored(
|
|
32249
|
-
if (this.options.atomic && DOT_RE.test(
|
|
32489
|
+
_isIgnored(path29, stats) {
|
|
32490
|
+
if (this.options.atomic && DOT_RE.test(path29))
|
|
32250
32491
|
return true;
|
|
32251
32492
|
if (!this._userIgnored) {
|
|
32252
32493
|
const { cwd } = this.options;
|
|
@@ -32256,17 +32497,17 @@ var init_chokidar = __esm({
|
|
|
32256
32497
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
32257
32498
|
this._userIgnored = anymatch(list, void 0);
|
|
32258
32499
|
}
|
|
32259
|
-
return this._userIgnored(
|
|
32500
|
+
return this._userIgnored(path29, stats);
|
|
32260
32501
|
}
|
|
32261
|
-
_isntIgnored(
|
|
32262
|
-
return !this._isIgnored(
|
|
32502
|
+
_isntIgnored(path29, stat4) {
|
|
32503
|
+
return !this._isIgnored(path29, stat4);
|
|
32263
32504
|
}
|
|
32264
32505
|
/**
|
|
32265
32506
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
32266
32507
|
* @param path file or directory pattern being watched
|
|
32267
32508
|
*/
|
|
32268
|
-
_getWatchHelpers(
|
|
32269
|
-
return new WatchHelper(
|
|
32509
|
+
_getWatchHelpers(path29) {
|
|
32510
|
+
return new WatchHelper(path29, this.options.followSymlinks, this);
|
|
32270
32511
|
}
|
|
32271
32512
|
// Directory helpers
|
|
32272
32513
|
// -----------------
|
|
@@ -32298,63 +32539,63 @@ var init_chokidar = __esm({
|
|
|
32298
32539
|
* @param item base path of item/directory
|
|
32299
32540
|
*/
|
|
32300
32541
|
_remove(directory, item, isDirectory) {
|
|
32301
|
-
const
|
|
32302
|
-
const fullPath = sp2.resolve(
|
|
32303
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
32304
|
-
if (!this._throttle("remove",
|
|
32542
|
+
const path29 = sp2.join(directory, item);
|
|
32543
|
+
const fullPath = sp2.resolve(path29);
|
|
32544
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path29) || this._watched.has(fullPath);
|
|
32545
|
+
if (!this._throttle("remove", path29, 100))
|
|
32305
32546
|
return;
|
|
32306
32547
|
if (!isDirectory && this._watched.size === 1) {
|
|
32307
32548
|
this.add(directory, item, true);
|
|
32308
32549
|
}
|
|
32309
|
-
const wp = this._getWatchedDir(
|
|
32550
|
+
const wp = this._getWatchedDir(path29);
|
|
32310
32551
|
const nestedDirectoryChildren = wp.getChildren();
|
|
32311
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
32552
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path29, nested));
|
|
32312
32553
|
const parent = this._getWatchedDir(directory);
|
|
32313
32554
|
const wasTracked = parent.has(item);
|
|
32314
32555
|
parent.remove(item);
|
|
32315
32556
|
if (this._symlinkPaths.has(fullPath)) {
|
|
32316
32557
|
this._symlinkPaths.delete(fullPath);
|
|
32317
32558
|
}
|
|
32318
|
-
let relPath =
|
|
32559
|
+
let relPath = path29;
|
|
32319
32560
|
if (this.options.cwd)
|
|
32320
|
-
relPath = sp2.relative(this.options.cwd,
|
|
32561
|
+
relPath = sp2.relative(this.options.cwd, path29);
|
|
32321
32562
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
32322
32563
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
32323
32564
|
if (event === EVENTS.ADD)
|
|
32324
32565
|
return;
|
|
32325
32566
|
}
|
|
32326
|
-
this._watched.delete(
|
|
32567
|
+
this._watched.delete(path29);
|
|
32327
32568
|
this._watched.delete(fullPath);
|
|
32328
32569
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
32329
|
-
if (wasTracked && !this._isIgnored(
|
|
32330
|
-
this._emit(eventName,
|
|
32331
|
-
this._closePath(
|
|
32570
|
+
if (wasTracked && !this._isIgnored(path29))
|
|
32571
|
+
this._emit(eventName, path29);
|
|
32572
|
+
this._closePath(path29);
|
|
32332
32573
|
}
|
|
32333
32574
|
/**
|
|
32334
32575
|
* Closes all watchers for a path
|
|
32335
32576
|
*/
|
|
32336
|
-
_closePath(
|
|
32337
|
-
this._closeFile(
|
|
32338
|
-
const dir = sp2.dirname(
|
|
32339
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
32577
|
+
_closePath(path29) {
|
|
32578
|
+
this._closeFile(path29);
|
|
32579
|
+
const dir = sp2.dirname(path29);
|
|
32580
|
+
this._getWatchedDir(dir).remove(sp2.basename(path29));
|
|
32340
32581
|
}
|
|
32341
32582
|
/**
|
|
32342
32583
|
* Closes only file-specific watchers
|
|
32343
32584
|
*/
|
|
32344
|
-
_closeFile(
|
|
32345
|
-
const closers = this._closers.get(
|
|
32585
|
+
_closeFile(path29) {
|
|
32586
|
+
const closers = this._closers.get(path29);
|
|
32346
32587
|
if (!closers)
|
|
32347
32588
|
return;
|
|
32348
32589
|
closers.forEach((closer) => closer());
|
|
32349
|
-
this._closers.delete(
|
|
32590
|
+
this._closers.delete(path29);
|
|
32350
32591
|
}
|
|
32351
|
-
_addPathCloser(
|
|
32592
|
+
_addPathCloser(path29, closer) {
|
|
32352
32593
|
if (!closer)
|
|
32353
32594
|
return;
|
|
32354
|
-
let list = this._closers.get(
|
|
32595
|
+
let list = this._closers.get(path29);
|
|
32355
32596
|
if (!list) {
|
|
32356
32597
|
list = [];
|
|
32357
|
-
this._closers.set(
|
|
32598
|
+
this._closers.set(path29, list);
|
|
32358
32599
|
}
|
|
32359
32600
|
list.push(closer);
|
|
32360
32601
|
}
|
|
@@ -32403,6 +32644,7 @@ function validateProviderDefinition(raw) {
|
|
|
32403
32644
|
warnings.push("disableUpstream is deprecated in provider definitions; use machine-level provider source policy instead");
|
|
32404
32645
|
}
|
|
32405
32646
|
const category = provider.category;
|
|
32647
|
+
const controls = Array.isArray(provider.controls) ? provider.controls : [];
|
|
32406
32648
|
if (category === "cli" || category === "acp") {
|
|
32407
32649
|
const spawn6 = provider.spawn;
|
|
32408
32650
|
const command = spawn6 && typeof spawn6 === "object" ? spawn6.command : void 0;
|
|
@@ -32420,11 +32662,61 @@ function validateProviderDefinition(raw) {
|
|
|
32420
32662
|
if (category === "extension" && !provider.extensionId) {
|
|
32421
32663
|
warnings.push("Extension providers should have extensionId");
|
|
32422
32664
|
}
|
|
32423
|
-
|
|
32665
|
+
validateCapabilities(provider, controls, errors);
|
|
32666
|
+
for (const control of controls) {
|
|
32424
32667
|
validateControl(control, errors);
|
|
32425
32668
|
}
|
|
32426
32669
|
return { errors, warnings };
|
|
32427
32670
|
}
|
|
32671
|
+
function validateCapabilities(provider, controls, errors) {
|
|
32672
|
+
const capabilities = provider.capabilities;
|
|
32673
|
+
if (provider.contractVersion === 2) {
|
|
32674
|
+
if (!capabilities || typeof capabilities !== "object") {
|
|
32675
|
+
errors.push("contractVersion 2 providers must declare capabilities");
|
|
32676
|
+
return;
|
|
32677
|
+
}
|
|
32678
|
+
}
|
|
32679
|
+
if (!capabilities || typeof capabilities !== "object") {
|
|
32680
|
+
return;
|
|
32681
|
+
}
|
|
32682
|
+
const input = capabilities.input;
|
|
32683
|
+
if (!input || typeof input !== "object") {
|
|
32684
|
+
errors.push("capabilities.input is required");
|
|
32685
|
+
} else {
|
|
32686
|
+
if (typeof input.multipart !== "boolean") {
|
|
32687
|
+
errors.push("capabilities.input.multipart must be boolean");
|
|
32688
|
+
}
|
|
32689
|
+
if (!Array.isArray(input.mediaTypes) || input.mediaTypes.length === 0) {
|
|
32690
|
+
errors.push("capabilities.input.mediaTypes must be a non-empty array");
|
|
32691
|
+
} else if (input.mediaTypes.some((type) => typeof type !== "string" || !VALID_CAPABILITY_MEDIA_TYPES.has(type))) {
|
|
32692
|
+
errors.push(`capabilities.input.mediaTypes must only include: ${Array.from(VALID_CAPABILITY_MEDIA_TYPES).join(", ")}`);
|
|
32693
|
+
}
|
|
32694
|
+
}
|
|
32695
|
+
const output = capabilities.output;
|
|
32696
|
+
if (!output || typeof output !== "object") {
|
|
32697
|
+
errors.push("capabilities.output is required");
|
|
32698
|
+
} else {
|
|
32699
|
+
if (typeof output.richContent !== "boolean") {
|
|
32700
|
+
errors.push("capabilities.output.richContent must be boolean");
|
|
32701
|
+
}
|
|
32702
|
+
if (!Array.isArray(output.mediaTypes) || output.mediaTypes.length === 0) {
|
|
32703
|
+
errors.push("capabilities.output.mediaTypes must be a non-empty array");
|
|
32704
|
+
} else if (output.mediaTypes.some((type) => typeof type !== "string" || !VALID_CAPABILITY_MEDIA_TYPES.has(type))) {
|
|
32705
|
+
errors.push(`capabilities.output.mediaTypes must only include: ${Array.from(VALID_CAPABILITY_MEDIA_TYPES).join(", ")}`);
|
|
32706
|
+
}
|
|
32707
|
+
}
|
|
32708
|
+
const controlCapabilities = capabilities.controls;
|
|
32709
|
+
if (!controlCapabilities || typeof controlCapabilities !== "object") {
|
|
32710
|
+
errors.push("capabilities.controls is required");
|
|
32711
|
+
return;
|
|
32712
|
+
}
|
|
32713
|
+
if (typeof controlCapabilities.typedResults !== "boolean") {
|
|
32714
|
+
errors.push("capabilities.controls.typedResults must be boolean");
|
|
32715
|
+
}
|
|
32716
|
+
if (controls.length > 0 && controlCapabilities.typedResults !== true) {
|
|
32717
|
+
errors.push("providers declaring controls must set capabilities.controls.typedResults=true");
|
|
32718
|
+
}
|
|
32719
|
+
}
|
|
32428
32720
|
function validateControl(control, errors) {
|
|
32429
32721
|
if (!control || typeof control !== "object") {
|
|
32430
32722
|
errors.push("controls: each control must be an object");
|
|
@@ -32456,10 +32748,11 @@ function validateControl(control, errors) {
|
|
|
32456
32748
|
errors.push(`${prefix}: readFrom must be a non-empty string when provided`);
|
|
32457
32749
|
}
|
|
32458
32750
|
}
|
|
32459
|
-
var KNOWN_PROVIDER_FIELDS, VALUE_CONTROL_TYPES;
|
|
32751
|
+
var VALID_CAPABILITY_MEDIA_TYPES, KNOWN_PROVIDER_FIELDS, VALUE_CONTROL_TYPES;
|
|
32460
32752
|
var init_provider_schema = __esm({
|
|
32461
32753
|
"../../oss/packages/daemon-core/src/providers/provider-schema.ts"() {
|
|
32462
32754
|
"use strict";
|
|
32755
|
+
VALID_CAPABILITY_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
|
|
32463
32756
|
KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
|
|
32464
32757
|
"type",
|
|
32465
32758
|
"name",
|
|
@@ -32510,6 +32803,7 @@ var init_provider_schema = __esm({
|
|
|
32510
32803
|
"sendDelayMs",
|
|
32511
32804
|
"sendKey",
|
|
32512
32805
|
"submitStrategy",
|
|
32806
|
+
"timeouts",
|
|
32513
32807
|
"disableUpstream"
|
|
32514
32808
|
]);
|
|
32515
32809
|
VALUE_CONTROL_TYPES = /* @__PURE__ */ new Set(["select", "toggle", "cycle", "slider"]);
|
|
@@ -32517,12 +32811,12 @@ var init_provider_schema = __esm({
|
|
|
32517
32811
|
});
|
|
32518
32812
|
|
|
32519
32813
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
32520
|
-
var fs6,
|
|
32814
|
+
var fs6, path13, os15, ProviderLoader;
|
|
32521
32815
|
var init_provider_loader = __esm({
|
|
32522
32816
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
32523
32817
|
"use strict";
|
|
32524
32818
|
fs6 = __toESM(require("fs"));
|
|
32525
|
-
|
|
32819
|
+
path13 = __toESM(require("path"));
|
|
32526
32820
|
os15 = __toESM(require("os"));
|
|
32527
32821
|
init_chokidar();
|
|
32528
32822
|
init_ide_detector();
|
|
@@ -32549,9 +32843,9 @@ var init_provider_loader = __esm({
|
|
|
32549
32843
|
static META_FILE = ".meta.json";
|
|
32550
32844
|
constructor(options) {
|
|
32551
32845
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
32552
|
-
this.defaultProvidersDir =
|
|
32846
|
+
this.defaultProvidersDir = path13.join(os15.homedir(), ".adhdev", "providers");
|
|
32553
32847
|
this.userDir = this.defaultProvidersDir;
|
|
32554
|
-
this.upstreamDir =
|
|
32848
|
+
this.upstreamDir = path13.join(this.defaultProvidersDir, ".upstream");
|
|
32555
32849
|
this.disableUpstream = false;
|
|
32556
32850
|
this.applySourceConfig({
|
|
32557
32851
|
userDir: options?.userDir,
|
|
@@ -32599,7 +32893,7 @@ var init_provider_loader = __esm({
|
|
|
32599
32893
|
}
|
|
32600
32894
|
this.sourceMode = nextSourceMode;
|
|
32601
32895
|
this.userDir = this.explicitProviderDir || this.defaultProvidersDir;
|
|
32602
|
-
this.upstreamDir =
|
|
32896
|
+
this.upstreamDir = path13.join(this.defaultProvidersDir, ".upstream");
|
|
32603
32897
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
32604
32898
|
if (this.explicitProviderDir) {
|
|
32605
32899
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -32613,7 +32907,7 @@ var init_provider_loader = __esm({
|
|
|
32613
32907
|
* Canonical provider directory shape for a given root.
|
|
32614
32908
|
*/
|
|
32615
32909
|
getProviderDir(root, category, type) {
|
|
32616
|
-
return
|
|
32910
|
+
return path13.join(root, category, type);
|
|
32617
32911
|
}
|
|
32618
32912
|
/**
|
|
32619
32913
|
* Canonical user override directory for a provider.
|
|
@@ -32640,7 +32934,7 @@ var init_provider_loader = __esm({
|
|
|
32640
32934
|
resolveProviderFile(type, ...segments) {
|
|
32641
32935
|
const dir = this.findProviderDirInternal(type);
|
|
32642
32936
|
if (!dir) return null;
|
|
32643
|
-
return
|
|
32937
|
+
return path13.join(dir, ...segments);
|
|
32644
32938
|
}
|
|
32645
32939
|
/**
|
|
32646
32940
|
* Load all providers (3-tier priority)
|
|
@@ -32679,7 +32973,7 @@ var init_provider_loader = __esm({
|
|
|
32679
32973
|
if (!fs6.existsSync(this.upstreamDir)) return false;
|
|
32680
32974
|
try {
|
|
32681
32975
|
return fs6.readdirSync(this.upstreamDir).some(
|
|
32682
|
-
(d) => fs6.statSync(
|
|
32976
|
+
(d) => fs6.statSync(path13.join(this.upstreamDir, d)).isDirectory()
|
|
32683
32977
|
);
|
|
32684
32978
|
} catch {
|
|
32685
32979
|
return false;
|
|
@@ -32994,8 +33288,8 @@ var init_provider_loader = __esm({
|
|
|
32994
33288
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
32995
33289
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
32996
33290
|
if (providerDir) {
|
|
32997
|
-
const fullDir =
|
|
32998
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
33291
|
+
const fullDir = path13.join(providerDir, entry.scriptDir);
|
|
33292
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
|
|
32999
33293
|
}
|
|
33000
33294
|
matched = true;
|
|
33001
33295
|
}
|
|
@@ -33010,8 +33304,8 @@ var init_provider_loader = __esm({
|
|
|
33010
33304
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
33011
33305
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
33012
33306
|
if (providerDir) {
|
|
33013
|
-
const fullDir =
|
|
33014
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
33307
|
+
const fullDir = path13.join(providerDir, base.defaultScriptDir);
|
|
33308
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
|
|
33015
33309
|
}
|
|
33016
33310
|
}
|
|
33017
33311
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -33028,8 +33322,8 @@ var init_provider_loader = __esm({
|
|
|
33028
33322
|
resolved._resolvedScriptDir = dirOverride;
|
|
33029
33323
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
33030
33324
|
if (providerDir) {
|
|
33031
|
-
const fullDir =
|
|
33032
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
33325
|
+
const fullDir = path13.join(providerDir, dirOverride);
|
|
33326
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
|
|
33033
33327
|
}
|
|
33034
33328
|
}
|
|
33035
33329
|
} else if (override.scripts) {
|
|
@@ -33045,8 +33339,8 @@ var init_provider_loader = __esm({
|
|
|
33045
33339
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
33046
33340
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
33047
33341
|
if (providerDir) {
|
|
33048
|
-
const fullDir =
|
|
33049
|
-
resolved._resolvedScriptsPath = fs6.existsSync(
|
|
33342
|
+
const fullDir = path13.join(providerDir, base.defaultScriptDir);
|
|
33343
|
+
resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
|
|
33050
33344
|
}
|
|
33051
33345
|
}
|
|
33052
33346
|
}
|
|
@@ -33071,14 +33365,14 @@ var init_provider_loader = __esm({
|
|
|
33071
33365
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
33072
33366
|
return null;
|
|
33073
33367
|
}
|
|
33074
|
-
const dir =
|
|
33368
|
+
const dir = path13.join(providerDir, scriptDir);
|
|
33075
33369
|
if (!fs6.existsSync(dir)) {
|
|
33076
33370
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
33077
33371
|
return null;
|
|
33078
33372
|
}
|
|
33079
33373
|
const cached2 = this.scriptsCache.get(dir);
|
|
33080
33374
|
if (cached2) return cached2;
|
|
33081
|
-
const scriptsJs =
|
|
33375
|
+
const scriptsJs = path13.join(dir, "scripts.js");
|
|
33082
33376
|
if (fs6.existsSync(scriptsJs)) {
|
|
33083
33377
|
try {
|
|
33084
33378
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -33120,7 +33414,7 @@ var init_provider_loader = __esm({
|
|
|
33120
33414
|
return;
|
|
33121
33415
|
}
|
|
33122
33416
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
33123
|
-
this.log(`File changed: ${
|
|
33417
|
+
this.log(`File changed: ${path13.basename(filePath)}, reloading...`);
|
|
33124
33418
|
this.reload();
|
|
33125
33419
|
}
|
|
33126
33420
|
};
|
|
@@ -33175,7 +33469,7 @@ var init_provider_loader = __esm({
|
|
|
33175
33469
|
}
|
|
33176
33470
|
const https = require("https");
|
|
33177
33471
|
const { execSync: execSync7 } = require("child_process");
|
|
33178
|
-
const metaPath =
|
|
33472
|
+
const metaPath = path13.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
33179
33473
|
let prevEtag = "";
|
|
33180
33474
|
let prevTimestamp = 0;
|
|
33181
33475
|
try {
|
|
@@ -33235,17 +33529,17 @@ var init_provider_loader = __esm({
|
|
|
33235
33529
|
return { updated: false };
|
|
33236
33530
|
}
|
|
33237
33531
|
this.log("Downloading latest providers from GitHub...");
|
|
33238
|
-
const tmpTar =
|
|
33239
|
-
const tmpExtract =
|
|
33532
|
+
const tmpTar = path13.join(os15.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
33533
|
+
const tmpExtract = path13.join(os15.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
33240
33534
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
33241
33535
|
fs6.mkdirSync(tmpExtract, { recursive: true });
|
|
33242
33536
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
33243
33537
|
const extracted = fs6.readdirSync(tmpExtract);
|
|
33244
33538
|
const rootDir = extracted.find(
|
|
33245
|
-
(d) => fs6.statSync(
|
|
33539
|
+
(d) => fs6.statSync(path13.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
33246
33540
|
);
|
|
33247
33541
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
33248
|
-
const sourceDir =
|
|
33542
|
+
const sourceDir = path13.join(tmpExtract, rootDir);
|
|
33249
33543
|
const backupDir = this.upstreamDir + ".bak";
|
|
33250
33544
|
if (fs6.existsSync(this.upstreamDir)) {
|
|
33251
33545
|
if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -33320,8 +33614,8 @@ var init_provider_loader = __esm({
|
|
|
33320
33614
|
copyDirRecursive(src, dest) {
|
|
33321
33615
|
fs6.mkdirSync(dest, { recursive: true });
|
|
33322
33616
|
for (const entry of fs6.readdirSync(src, { withFileTypes: true })) {
|
|
33323
|
-
const srcPath =
|
|
33324
|
-
const destPath =
|
|
33617
|
+
const srcPath = path13.join(src, entry.name);
|
|
33618
|
+
const destPath = path13.join(dest, entry.name);
|
|
33325
33619
|
if (entry.isDirectory()) {
|
|
33326
33620
|
this.copyDirRecursive(srcPath, destPath);
|
|
33327
33621
|
} else {
|
|
@@ -33332,7 +33626,7 @@ var init_provider_loader = __esm({
|
|
|
33332
33626
|
/** .meta.json save */
|
|
33333
33627
|
writeMeta(metaPath, etag, timestamp) {
|
|
33334
33628
|
try {
|
|
33335
|
-
fs6.mkdirSync(
|
|
33629
|
+
fs6.mkdirSync(path13.dirname(metaPath), { recursive: true });
|
|
33336
33630
|
fs6.writeFileSync(metaPath, JSON.stringify({
|
|
33337
33631
|
etag,
|
|
33338
33632
|
timestamp,
|
|
@@ -33349,7 +33643,7 @@ var init_provider_loader = __esm({
|
|
|
33349
33643
|
const scan = (d) => {
|
|
33350
33644
|
try {
|
|
33351
33645
|
for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
|
|
33352
|
-
if (entry.isDirectory()) scan(
|
|
33646
|
+
if (entry.isDirectory()) scan(path13.join(d, entry.name));
|
|
33353
33647
|
else if (entry.name === "provider.json") count++;
|
|
33354
33648
|
}
|
|
33355
33649
|
} catch {
|
|
@@ -33534,17 +33828,17 @@ var init_provider_loader = __esm({
|
|
|
33534
33828
|
for (const root of searchRoots) {
|
|
33535
33829
|
if (!fs6.existsSync(root)) continue;
|
|
33536
33830
|
const candidate = this.getProviderDir(root, cat, type);
|
|
33537
|
-
if (fs6.existsSync(
|
|
33538
|
-
const catDir =
|
|
33831
|
+
if (fs6.existsSync(path13.join(candidate, "provider.json"))) return candidate;
|
|
33832
|
+
const catDir = path13.join(root, cat);
|
|
33539
33833
|
if (fs6.existsSync(catDir)) {
|
|
33540
33834
|
try {
|
|
33541
33835
|
for (const entry of fs6.readdirSync(catDir, { withFileTypes: true })) {
|
|
33542
33836
|
if (!entry.isDirectory()) continue;
|
|
33543
|
-
const jsonPath =
|
|
33837
|
+
const jsonPath = path13.join(catDir, entry.name, "provider.json");
|
|
33544
33838
|
if (fs6.existsSync(jsonPath)) {
|
|
33545
33839
|
try {
|
|
33546
33840
|
const data = JSON.parse(fs6.readFileSync(jsonPath, "utf-8"));
|
|
33547
|
-
if (data.type === type) return
|
|
33841
|
+
if (data.type === type) return path13.join(catDir, entry.name);
|
|
33548
33842
|
} catch {
|
|
33549
33843
|
}
|
|
33550
33844
|
}
|
|
@@ -33561,7 +33855,7 @@ var init_provider_loader = __esm({
|
|
|
33561
33855
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
33562
33856
|
*/
|
|
33563
33857
|
buildScriptWrappersFromDir(dir) {
|
|
33564
|
-
const scriptsJs =
|
|
33858
|
+
const scriptsJs = path13.join(dir, "scripts.js");
|
|
33565
33859
|
if (fs6.existsSync(scriptsJs)) {
|
|
33566
33860
|
try {
|
|
33567
33861
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -33575,7 +33869,7 @@ var init_provider_loader = __esm({
|
|
|
33575
33869
|
for (const file2 of fs6.readdirSync(dir)) {
|
|
33576
33870
|
if (!file2.endsWith(".js")) continue;
|
|
33577
33871
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
33578
|
-
const filePath =
|
|
33872
|
+
const filePath = path13.join(dir, file2);
|
|
33579
33873
|
result[scriptName] = (...args) => {
|
|
33580
33874
|
try {
|
|
33581
33875
|
let content = fs6.readFileSync(filePath, "utf-8");
|
|
@@ -33635,7 +33929,7 @@ var init_provider_loader = __esm({
|
|
|
33635
33929
|
}
|
|
33636
33930
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
33637
33931
|
if (hasJson) {
|
|
33638
|
-
const jsonPath =
|
|
33932
|
+
const jsonPath = path13.join(d, "provider.json");
|
|
33639
33933
|
try {
|
|
33640
33934
|
const raw = fs6.readFileSync(jsonPath, "utf-8");
|
|
33641
33935
|
const mod = JSON.parse(raw);
|
|
@@ -33656,7 +33950,7 @@ var init_provider_loader = __esm({
|
|
|
33656
33950
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
33657
33951
|
} else {
|
|
33658
33952
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
33659
|
-
const scriptsPath =
|
|
33953
|
+
const scriptsPath = path13.join(d, "scripts.js");
|
|
33660
33954
|
if (!hasCompatibility && fs6.existsSync(scriptsPath)) {
|
|
33661
33955
|
try {
|
|
33662
33956
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -33682,7 +33976,7 @@ var init_provider_loader = __esm({
|
|
|
33682
33976
|
if (!entry.isDirectory()) continue;
|
|
33683
33977
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
33684
33978
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
33685
|
-
scan(
|
|
33979
|
+
scan(path13.join(d, entry.name));
|
|
33686
33980
|
}
|
|
33687
33981
|
}
|
|
33688
33982
|
};
|
|
@@ -33941,8 +34235,8 @@ function detectCurrentWorkspace(ideId) {
|
|
|
33941
34235
|
const appNameMap = getMacAppIdentifiers();
|
|
33942
34236
|
const appName = appNameMap[ideId];
|
|
33943
34237
|
if (appName) {
|
|
33944
|
-
const storagePath =
|
|
33945
|
-
process.env.APPDATA ||
|
|
34238
|
+
const storagePath = path14.join(
|
|
34239
|
+
process.env.APPDATA || path14.join(os16.homedir(), "AppData", "Roaming"),
|
|
33946
34240
|
appName,
|
|
33947
34241
|
"storage.json"
|
|
33948
34242
|
);
|
|
@@ -34113,14 +34407,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
34113
34407
|
function getAvailableIdeIds() {
|
|
34114
34408
|
return getProviderLoader().getAvailableIdeTypes();
|
|
34115
34409
|
}
|
|
34116
|
-
var import_child_process6, net2, os16,
|
|
34410
|
+
var import_child_process6, net2, os16, path14, _providerLoader;
|
|
34117
34411
|
var init_launch = __esm({
|
|
34118
34412
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
34119
34413
|
"use strict";
|
|
34120
34414
|
import_child_process6 = require("child_process");
|
|
34121
34415
|
net2 = __toESM(require("net"));
|
|
34122
34416
|
os16 = __toESM(require("os"));
|
|
34123
|
-
|
|
34417
|
+
path14 = __toESM(require("path"));
|
|
34124
34418
|
init_ide_detector();
|
|
34125
34419
|
init_provider_loader();
|
|
34126
34420
|
_providerLoader = null;
|
|
@@ -34151,7 +34445,7 @@ function checkRotation() {
|
|
|
34151
34445
|
const today = getDateStr2();
|
|
34152
34446
|
if (today !== currentDate2) {
|
|
34153
34447
|
currentDate2 = today;
|
|
34154
|
-
currentFile =
|
|
34448
|
+
currentFile = path15.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
34155
34449
|
cleanOldFiles();
|
|
34156
34450
|
}
|
|
34157
34451
|
}
|
|
@@ -34165,7 +34459,7 @@ function cleanOldFiles() {
|
|
|
34165
34459
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
34166
34460
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
34167
34461
|
try {
|
|
34168
|
-
fs7.unlinkSync(
|
|
34462
|
+
fs7.unlinkSync(path15.join(LOG_DIR2, file2));
|
|
34169
34463
|
} catch {
|
|
34170
34464
|
}
|
|
34171
34465
|
}
|
|
@@ -34234,14 +34528,14 @@ function getRecentCommands(count = 50) {
|
|
|
34234
34528
|
return [];
|
|
34235
34529
|
}
|
|
34236
34530
|
}
|
|
34237
|
-
var fs7,
|
|
34531
|
+
var fs7, path15, os17, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
34238
34532
|
var init_command_log = __esm({
|
|
34239
34533
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
34240
34534
|
"use strict";
|
|
34241
34535
|
fs7 = __toESM(require("fs"));
|
|
34242
|
-
|
|
34536
|
+
path15 = __toESM(require("path"));
|
|
34243
34537
|
os17 = __toESM(require("os"));
|
|
34244
|
-
LOG_DIR2 = process.platform === "win32" ?
|
|
34538
|
+
LOG_DIR2 = process.platform === "win32" ? path15.join(process.env.LOCALAPPDATA || process.env.APPDATA || path15.join(os17.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path15.join(os17.homedir(), "Library", "Logs", "adhdev") : path15.join(os17.homedir(), ".local", "share", "adhdev", "logs");
|
|
34245
34539
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
34246
34540
|
MAX_DAYS = 7;
|
|
34247
34541
|
try {
|
|
@@ -34260,7 +34554,7 @@ var init_command_log = __esm({
|
|
|
34260
34554
|
"text"
|
|
34261
34555
|
]);
|
|
34262
34556
|
currentDate2 = getDateStr2();
|
|
34263
|
-
currentFile =
|
|
34557
|
+
currentFile = path15.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
34264
34558
|
writeCount2 = 0;
|
|
34265
34559
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
34266
34560
|
"heartbeat",
|
|
@@ -34620,9 +34914,9 @@ var init_snapshot = __esm({
|
|
|
34620
34914
|
// ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
|
|
34621
34915
|
function getUpgradeLogPath() {
|
|
34622
34916
|
const home = os19.homedir();
|
|
34623
|
-
const dir =
|
|
34917
|
+
const dir = path16.join(home, ".adhdev");
|
|
34624
34918
|
fs8.mkdirSync(dir, { recursive: true });
|
|
34625
|
-
return
|
|
34919
|
+
return path16.join(dir, "daemon-upgrade.log");
|
|
34626
34920
|
}
|
|
34627
34921
|
function appendUpgradeLog(message) {
|
|
34628
34922
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
@@ -34662,7 +34956,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
34662
34956
|
}
|
|
34663
34957
|
}
|
|
34664
34958
|
function stopSessionHostProcesses(appName) {
|
|
34665
|
-
const pidFile =
|
|
34959
|
+
const pidFile = path16.join(os19.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
34666
34960
|
try {
|
|
34667
34961
|
if (fs8.existsSync(pidFile)) {
|
|
34668
34962
|
const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
|
|
@@ -34691,7 +34985,7 @@ function stopSessionHostProcesses(appName) {
|
|
|
34691
34985
|
}
|
|
34692
34986
|
}
|
|
34693
34987
|
function removeDaemonPidFile() {
|
|
34694
|
-
const pidFile =
|
|
34988
|
+
const pidFile = path16.join(os19.homedir(), ".adhdev", "daemon.pid");
|
|
34695
34989
|
try {
|
|
34696
34990
|
fs8.unlinkSync(pidFile);
|
|
34697
34991
|
} catch {
|
|
@@ -34702,7 +34996,7 @@ function cleanupStaleGlobalInstallDirs(pkgName) {
|
|
|
34702
34996
|
const npmRoot = (0, import_child_process7.execFileSync)(getNpmExecutable(), ["root", "-g"], { encoding: "utf8", ...npmExecOpts }).trim();
|
|
34703
34997
|
if (!npmRoot) return;
|
|
34704
34998
|
const npmPrefix = (0, import_child_process7.execFileSync)(getNpmExecutable(), ["prefix", "-g"], { encoding: "utf8", ...npmExecOpts }).trim();
|
|
34705
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
34999
|
+
const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
|
|
34706
35000
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
34707
35001
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
34708
35002
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -34710,25 +35004,25 @@ function cleanupStaleGlobalInstallDirs(pkgName) {
|
|
|
34710
35004
|
}
|
|
34711
35005
|
if (pkgName.startsWith("@")) {
|
|
34712
35006
|
const [scope, name] = pkgName.split("/");
|
|
34713
|
-
const scopeDir =
|
|
35007
|
+
const scopeDir = path16.join(npmRoot, scope);
|
|
34714
35008
|
if (!fs8.existsSync(scopeDir)) return;
|
|
34715
35009
|
for (const entry of fs8.readdirSync(scopeDir)) {
|
|
34716
35010
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
34717
|
-
fs8.rmSync(
|
|
34718
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
35011
|
+
fs8.rmSync(path16.join(scopeDir, entry), { recursive: true, force: true });
|
|
35012
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path16.join(scopeDir, entry)}`);
|
|
34719
35013
|
}
|
|
34720
35014
|
} else {
|
|
34721
35015
|
for (const entry of fs8.readdirSync(npmRoot)) {
|
|
34722
35016
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
34723
|
-
fs8.rmSync(
|
|
34724
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
35017
|
+
fs8.rmSync(path16.join(npmRoot, entry), { recursive: true, force: true });
|
|
35018
|
+
appendUpgradeLog(`Removed stale staging dir: ${path16.join(npmRoot, entry)}`);
|
|
34725
35019
|
}
|
|
34726
35020
|
}
|
|
34727
35021
|
if (fs8.existsSync(binDir)) {
|
|
34728
35022
|
for (const entry of fs8.readdirSync(binDir)) {
|
|
34729
35023
|
if (![...binNames].some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
34730
|
-
fs8.rmSync(
|
|
34731
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
35024
|
+
fs8.rmSync(path16.join(binDir, entry), { recursive: true, force: true });
|
|
35025
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path16.join(binDir, entry)}`);
|
|
34732
35026
|
}
|
|
34733
35027
|
}
|
|
34734
35028
|
}
|
|
@@ -34803,7 +35097,7 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
34803
35097
|
process.exit(1);
|
|
34804
35098
|
}
|
|
34805
35099
|
}
|
|
34806
|
-
var import_child_process7, import_child_process8, fs8, os19,
|
|
35100
|
+
var import_child_process7, import_child_process8, fs8, os19, path16, UPGRADE_HELPER_ENV;
|
|
34807
35101
|
var init_upgrade_helper = __esm({
|
|
34808
35102
|
"../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
|
|
34809
35103
|
"use strict";
|
|
@@ -34811,7 +35105,7 @@ var init_upgrade_helper = __esm({
|
|
|
34811
35105
|
import_child_process8 = require("child_process");
|
|
34812
35106
|
fs8 = __toESM(require("fs"));
|
|
34813
35107
|
os19 = __toESM(require("os"));
|
|
34814
|
-
|
|
35108
|
+
path16 = __toESM(require("path"));
|
|
34815
35109
|
UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
34816
35110
|
}
|
|
34817
35111
|
});
|
|
@@ -35812,6 +36106,7 @@ var init_provider_adapter = __esm({
|
|
|
35812
36106
|
"../../oss/packages/daemon-core/src/agent-stream/provider-adapter.ts"() {
|
|
35813
36107
|
"use strict";
|
|
35814
36108
|
init_control_effects();
|
|
36109
|
+
init_read_chat_contract();
|
|
35815
36110
|
init_provider_patch_state();
|
|
35816
36111
|
init_chat_message_normalization();
|
|
35817
36112
|
ProviderStreamAdapter = class {
|
|
@@ -35918,26 +36213,29 @@ var init_provider_adapter = __esm({
|
|
|
35918
36213
|
}
|
|
35919
36214
|
return state2;
|
|
35920
36215
|
}
|
|
36216
|
+
const validated = validateReadChatResultPayload(data, `${this.agentType} readChat`);
|
|
36217
|
+
const validatedStatus = validated.status;
|
|
36218
|
+
const streamStatus = validatedStatus === "generating" || validatedStatus === "long_generating" ? "streaming" : validatedStatus;
|
|
35921
36219
|
const state = {
|
|
35922
36220
|
agentType: this.agentType,
|
|
35923
36221
|
agentName: this.agentName,
|
|
35924
36222
|
extensionId: this.extensionId,
|
|
35925
|
-
status:
|
|
35926
|
-
messages: normalizeChatMessages(
|
|
35927
|
-
inputContent:
|
|
35928
|
-
activeModal:
|
|
36223
|
+
status: streamStatus,
|
|
36224
|
+
messages: normalizeChatMessages(validated.messages),
|
|
36225
|
+
inputContent: typeof validated.inputContent === "string" ? validated.inputContent : "",
|
|
36226
|
+
...validated.activeModal ? { activeModal: validated.activeModal } : {}
|
|
35929
36227
|
};
|
|
35930
|
-
if (typeof
|
|
35931
|
-
state.title =
|
|
36228
|
+
if (typeof validated.title === "string" && validated.title.trim()) {
|
|
36229
|
+
state.title = validated.title.trim();
|
|
35932
36230
|
}
|
|
35933
|
-
const controlValues = extractProviderControlValues(this.provider.controls,
|
|
36231
|
+
const controlValues = extractProviderControlValues(this.provider.controls, validated);
|
|
35934
36232
|
const surface = resolveProviderStateSurface({
|
|
35935
36233
|
controlValues,
|
|
35936
|
-
summaryMetadata:
|
|
36234
|
+
summaryMetadata: validated.summaryMetadata
|
|
35937
36235
|
});
|
|
35938
36236
|
if (surface.controlValues) state.controlValues = surface.controlValues;
|
|
35939
36237
|
if (surface.summaryMetadata) state.summaryMetadata = surface.summaryMetadata;
|
|
35940
|
-
const effects = normalizeProviderEffects(
|
|
36238
|
+
const effects = normalizeProviderEffects(validated);
|
|
35941
36239
|
if (effects.length > 0) state.effects = effects;
|
|
35942
36240
|
if (state.messages.length > 0) {
|
|
35943
36241
|
this.lastSuccessState = state;
|
|
@@ -36874,7 +37172,7 @@ function checkPathExists2(paths) {
|
|
|
36874
37172
|
for (const p of paths) {
|
|
36875
37173
|
if (p.includes("*")) {
|
|
36876
37174
|
const home = os20.homedir();
|
|
36877
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
37175
|
+
const resolved = p.replace(/\*/g, home.split(path17.sep).pop() || "");
|
|
36878
37176
|
if (fs10.existsSync(resolved)) return resolved;
|
|
36879
37177
|
} else {
|
|
36880
37178
|
if (fs10.existsSync(p)) return p;
|
|
@@ -36884,7 +37182,7 @@ function checkPathExists2(paths) {
|
|
|
36884
37182
|
}
|
|
36885
37183
|
function getMacAppVersion(appPath) {
|
|
36886
37184
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
36887
|
-
const plistPath =
|
|
37185
|
+
const plistPath = path17.join(appPath, "Contents", "Info.plist");
|
|
36888
37186
|
if (!fs10.existsSync(plistPath)) return null;
|
|
36889
37187
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
36890
37188
|
return raw || null;
|
|
@@ -36910,7 +37208,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
36910
37208
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
36911
37209
|
let resolvedBin = cliBin;
|
|
36912
37210
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
36913
|
-
const bundled =
|
|
37211
|
+
const bundled = path17.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
36914
37212
|
if (provider.cli && fs10.existsSync(bundled)) resolvedBin = bundled;
|
|
36915
37213
|
}
|
|
36916
37214
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -36947,16 +37245,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
36947
37245
|
}
|
|
36948
37246
|
return results;
|
|
36949
37247
|
}
|
|
36950
|
-
var fs10,
|
|
37248
|
+
var fs10, path17, os20, import_child_process9, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
36951
37249
|
var init_version_archive = __esm({
|
|
36952
37250
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
36953
37251
|
"use strict";
|
|
36954
37252
|
fs10 = __toESM(require("fs"));
|
|
36955
|
-
|
|
37253
|
+
path17 = __toESM(require("path"));
|
|
36956
37254
|
os20 = __toESM(require("os"));
|
|
36957
37255
|
import_child_process9 = require("child_process");
|
|
36958
37256
|
import_os3 = require("os");
|
|
36959
|
-
ARCHIVE_PATH =
|
|
37257
|
+
ARCHIVE_PATH = path17.join(os20.homedir(), ".adhdev", "version-history.json");
|
|
36960
37258
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
36961
37259
|
VersionArchive = class {
|
|
36962
37260
|
history = {};
|
|
@@ -37003,7 +37301,7 @@ var init_version_archive = __esm({
|
|
|
37003
37301
|
}
|
|
37004
37302
|
save() {
|
|
37005
37303
|
try {
|
|
37006
|
-
fs10.mkdirSync(
|
|
37304
|
+
fs10.mkdirSync(path17.dirname(ARCHIVE_PATH), { recursive: true });
|
|
37007
37305
|
fs10.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
37008
37306
|
} catch {
|
|
37009
37307
|
}
|
|
@@ -37531,17 +37829,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
37531
37829
|
return;
|
|
37532
37830
|
}
|
|
37533
37831
|
let scriptsPath = "";
|
|
37534
|
-
const directScripts =
|
|
37832
|
+
const directScripts = path18.join(dir, "scripts.js");
|
|
37535
37833
|
if (fs11.existsSync(directScripts)) {
|
|
37536
37834
|
scriptsPath = directScripts;
|
|
37537
37835
|
} else {
|
|
37538
|
-
const scriptsDir =
|
|
37836
|
+
const scriptsDir = path18.join(dir, "scripts");
|
|
37539
37837
|
if (fs11.existsSync(scriptsDir)) {
|
|
37540
37838
|
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
37541
|
-
return fs11.statSync(
|
|
37839
|
+
return fs11.statSync(path18.join(scriptsDir, d)).isDirectory();
|
|
37542
37840
|
}).sort().reverse();
|
|
37543
37841
|
for (const ver of versions) {
|
|
37544
|
-
const p =
|
|
37842
|
+
const p = path18.join(scriptsDir, ver, "scripts.js");
|
|
37545
37843
|
if (fs11.existsSync(p)) {
|
|
37546
37844
|
scriptsPath = p;
|
|
37547
37845
|
break;
|
|
@@ -38367,12 +38665,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
38367
38665
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
38368
38666
|
}
|
|
38369
38667
|
}
|
|
38370
|
-
var fs11,
|
|
38668
|
+
var fs11, path18;
|
|
38371
38669
|
var init_dev_cdp_handlers = __esm({
|
|
38372
38670
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
38373
38671
|
"use strict";
|
|
38374
38672
|
fs11 = __toESM(require("fs"));
|
|
38375
|
-
|
|
38673
|
+
path18 = __toESM(require("path"));
|
|
38376
38674
|
init_logger();
|
|
38377
38675
|
}
|
|
38378
38676
|
});
|
|
@@ -38387,11 +38685,11 @@ function getCliFixtureDir(ctx, type) {
|
|
|
38387
38685
|
if (!providerDir) {
|
|
38388
38686
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
38389
38687
|
}
|
|
38390
|
-
return
|
|
38688
|
+
return path19.join(providerDir, "fixtures");
|
|
38391
38689
|
}
|
|
38392
38690
|
function readCliFixture(ctx, type, name) {
|
|
38393
38691
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
38394
|
-
const filePath =
|
|
38692
|
+
const filePath = path19.join(fixtureDir, `${name}.json`);
|
|
38395
38693
|
if (!fs12.existsSync(filePath)) {
|
|
38396
38694
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
38397
38695
|
}
|
|
@@ -39158,7 +39456,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
39158
39456
|
},
|
|
39159
39457
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
39160
39458
|
};
|
|
39161
|
-
const filePath =
|
|
39459
|
+
const filePath = path19.join(fixtureDir, `${name}.json`);
|
|
39162
39460
|
fs12.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
39163
39461
|
ctx.json(res, 200, {
|
|
39164
39462
|
saved: true,
|
|
@@ -39182,7 +39480,7 @@ async function handleCliFixtureList(ctx, type, _req, res) {
|
|
|
39182
39480
|
return;
|
|
39183
39481
|
}
|
|
39184
39482
|
const fixtures = fs12.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
39185
|
-
const fullPath =
|
|
39483
|
+
const fullPath = path19.join(fixtureDir, file2);
|
|
39186
39484
|
try {
|
|
39187
39485
|
const raw = JSON.parse(fs12.readFileSync(fullPath, "utf-8"));
|
|
39188
39486
|
return {
|
|
@@ -39315,12 +39613,12 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
39315
39613
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
39316
39614
|
}
|
|
39317
39615
|
}
|
|
39318
|
-
var fs12,
|
|
39616
|
+
var fs12, path19;
|
|
39319
39617
|
var init_dev_cli_debug = __esm({
|
|
39320
39618
|
"../../oss/packages/daemon-core/src/daemon/dev-cli-debug.ts"() {
|
|
39321
39619
|
"use strict";
|
|
39322
39620
|
fs12 = __toESM(require("fs"));
|
|
39323
|
-
|
|
39621
|
+
path19 = __toESM(require("path"));
|
|
39324
39622
|
}
|
|
39325
39623
|
});
|
|
39326
39624
|
|
|
@@ -39380,22 +39678,22 @@ function getLatestScriptVersionDir(scriptsDir) {
|
|
|
39380
39678
|
if (!fs13.existsSync(scriptsDir)) return null;
|
|
39381
39679
|
const versions = fs13.readdirSync(scriptsDir).filter((d) => {
|
|
39382
39680
|
try {
|
|
39383
|
-
return fs13.statSync(
|
|
39681
|
+
return fs13.statSync(path20.join(scriptsDir, d)).isDirectory();
|
|
39384
39682
|
} catch {
|
|
39385
39683
|
return false;
|
|
39386
39684
|
}
|
|
39387
39685
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
39388
39686
|
if (versions.length === 0) return null;
|
|
39389
|
-
return
|
|
39687
|
+
return path20.join(scriptsDir, versions[0]);
|
|
39390
39688
|
}
|
|
39391
39689
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
39392
|
-
const canonicalUserDir =
|
|
39393
|
-
const desiredDir = requestedDir ?
|
|
39394
|
-
const upstreamRoot =
|
|
39395
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
39690
|
+
const canonicalUserDir = path20.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
39691
|
+
const desiredDir = requestedDir ? path20.resolve(requestedDir) : canonicalUserDir;
|
|
39692
|
+
const upstreamRoot = path20.resolve(ctx.providerLoader.getUpstreamDir());
|
|
39693
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path20.sep}`)) {
|
|
39396
39694
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
39397
39695
|
}
|
|
39398
|
-
if (
|
|
39696
|
+
if (path20.basename(desiredDir) !== type) {
|
|
39399
39697
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
39400
39698
|
}
|
|
39401
39699
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -39403,11 +39701,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
39403
39701
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
39404
39702
|
}
|
|
39405
39703
|
if (!fs13.existsSync(desiredDir)) {
|
|
39406
|
-
fs13.mkdirSync(
|
|
39704
|
+
fs13.mkdirSync(path20.dirname(desiredDir), { recursive: true });
|
|
39407
39705
|
fs13.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
39408
39706
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
39409
39707
|
}
|
|
39410
|
-
const providerJson =
|
|
39708
|
+
const providerJson = path20.join(desiredDir, "provider.json");
|
|
39411
39709
|
if (!fs13.existsSync(providerJson)) {
|
|
39412
39710
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
39413
39711
|
}
|
|
@@ -39418,13 +39716,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
|
39418
39716
|
const refDir = ctx.findProviderDir(referenceType);
|
|
39419
39717
|
if (!refDir || !fs13.existsSync(refDir)) return {};
|
|
39420
39718
|
const referenceScripts = {};
|
|
39421
|
-
const scriptsDir =
|
|
39719
|
+
const scriptsDir = path20.join(refDir, "scripts");
|
|
39422
39720
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
39423
39721
|
if (!latestDir) return referenceScripts;
|
|
39424
39722
|
for (const file2 of fs13.readdirSync(latestDir)) {
|
|
39425
39723
|
if (!file2.endsWith(".js")) continue;
|
|
39426
39724
|
try {
|
|
39427
|
-
referenceScripts[file2] = fs13.readFileSync(
|
|
39725
|
+
referenceScripts[file2] = fs13.readFileSync(path20.join(latestDir, file2), "utf-8");
|
|
39428
39726
|
} catch {
|
|
39429
39727
|
}
|
|
39430
39728
|
}
|
|
@@ -39532,9 +39830,9 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
39532
39830
|
});
|
|
39533
39831
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
39534
39832
|
const prompt2 = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
39535
|
-
const tmpDir =
|
|
39833
|
+
const tmpDir = path20.join(os21.tmpdir(), "adhdev-autoimpl");
|
|
39536
39834
|
if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
|
|
39537
|
-
const promptFile =
|
|
39835
|
+
const promptFile = path20.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
39538
39836
|
fs13.writeFileSync(promptFile, prompt2, "utf-8");
|
|
39539
39837
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt2.length} chars)`);
|
|
39540
39838
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -39971,7 +40269,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
39971
40269
|
setMode: "set_mode.js"
|
|
39972
40270
|
};
|
|
39973
40271
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
39974
|
-
const scriptsDir =
|
|
40272
|
+
const scriptsDir = path20.join(providerDir, "scripts");
|
|
39975
40273
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
39976
40274
|
if (latestScriptsDir) {
|
|
39977
40275
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -39982,7 +40280,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
39982
40280
|
for (const file2 of fs13.readdirSync(latestScriptsDir)) {
|
|
39983
40281
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
39984
40282
|
try {
|
|
39985
|
-
const content = fs13.readFileSync(
|
|
40283
|
+
const content = fs13.readFileSync(path20.join(latestScriptsDir, file2), "utf-8");
|
|
39986
40284
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
39987
40285
|
lines.push("```javascript");
|
|
39988
40286
|
lines.push(content);
|
|
@@ -39999,7 +40297,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
39999
40297
|
lines.push("");
|
|
40000
40298
|
for (const file2 of refFiles) {
|
|
40001
40299
|
try {
|
|
40002
|
-
const content = fs13.readFileSync(
|
|
40300
|
+
const content = fs13.readFileSync(path20.join(latestScriptsDir, file2), "utf-8");
|
|
40003
40301
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
40004
40302
|
lines.push("```javascript");
|
|
40005
40303
|
lines.push(content);
|
|
@@ -40040,10 +40338,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40040
40338
|
lines.push("");
|
|
40041
40339
|
}
|
|
40042
40340
|
}
|
|
40043
|
-
const docsDir =
|
|
40341
|
+
const docsDir = path20.join(providerDir, "../../docs");
|
|
40044
40342
|
const loadGuide = (name) => {
|
|
40045
40343
|
try {
|
|
40046
|
-
const p =
|
|
40344
|
+
const p = path20.join(docsDir, name);
|
|
40047
40345
|
if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
|
|
40048
40346
|
} catch {
|
|
40049
40347
|
}
|
|
@@ -40280,7 +40578,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
40280
40578
|
parseApproval: "parse_approval.js"
|
|
40281
40579
|
};
|
|
40282
40580
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
40283
|
-
const scriptsDir =
|
|
40581
|
+
const scriptsDir = path20.join(providerDir, "scripts");
|
|
40284
40582
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
40285
40583
|
if (latestScriptsDir) {
|
|
40286
40584
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -40292,7 +40590,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
40292
40590
|
if (!file2.endsWith(".js")) continue;
|
|
40293
40591
|
if (!targetFileNames.has(file2)) continue;
|
|
40294
40592
|
try {
|
|
40295
|
-
const content = fs13.readFileSync(
|
|
40593
|
+
const content = fs13.readFileSync(path20.join(latestScriptsDir, file2), "utf-8");
|
|
40296
40594
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
40297
40595
|
lines.push("```javascript");
|
|
40298
40596
|
lines.push(content);
|
|
@@ -40308,7 +40606,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
40308
40606
|
lines.push("");
|
|
40309
40607
|
for (const file2 of refFiles) {
|
|
40310
40608
|
try {
|
|
40311
|
-
const content = fs13.readFileSync(
|
|
40609
|
+
const content = fs13.readFileSync(path20.join(latestScriptsDir, file2), "utf-8");
|
|
40312
40610
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
40313
40611
|
lines.push("```javascript");
|
|
40314
40612
|
lines.push(content);
|
|
@@ -40341,10 +40639,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
40341
40639
|
lines.push("");
|
|
40342
40640
|
}
|
|
40343
40641
|
}
|
|
40344
|
-
const docsDir =
|
|
40642
|
+
const docsDir = path20.join(providerDir, "../../docs");
|
|
40345
40643
|
const loadGuide = (name) => {
|
|
40346
40644
|
try {
|
|
40347
|
-
const p =
|
|
40645
|
+
const p = path20.join(docsDir, name);
|
|
40348
40646
|
if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
|
|
40349
40647
|
} catch {
|
|
40350
40648
|
}
|
|
@@ -40656,12 +40954,12 @@ data: ${JSON.stringify(msg.data)}
|
|
|
40656
40954
|
}
|
|
40657
40955
|
}
|
|
40658
40956
|
}
|
|
40659
|
-
var fs13,
|
|
40957
|
+
var fs13, path20, os21;
|
|
40660
40958
|
var init_dev_auto_implement = __esm({
|
|
40661
40959
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
40662
40960
|
"use strict";
|
|
40663
40961
|
fs13 = __toESM(require("fs"));
|
|
40664
|
-
|
|
40962
|
+
path20 = __toESM(require("path"));
|
|
40665
40963
|
os21 = __toESM(require("os"));
|
|
40666
40964
|
init_dev_server();
|
|
40667
40965
|
init_dev_cli_debug();
|
|
@@ -40701,13 +40999,13 @@ function toProviderListEntry(provider) {
|
|
|
40701
40999
|
}
|
|
40702
41000
|
return base;
|
|
40703
41001
|
}
|
|
40704
|
-
var http2, fs14,
|
|
41002
|
+
var http2, fs14, path21, DEV_SERVER_PORT, DevServer;
|
|
40705
41003
|
var init_dev_server = __esm({
|
|
40706
41004
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
40707
41005
|
"use strict";
|
|
40708
41006
|
http2 = __toESM(require("http"));
|
|
40709
41007
|
fs14 = __toESM(require("fs"));
|
|
40710
|
-
|
|
41008
|
+
path21 = __toESM(require("path"));
|
|
40711
41009
|
init_provider_schema();
|
|
40712
41010
|
init_config();
|
|
40713
41011
|
init_provider_source_config();
|
|
@@ -40819,8 +41117,8 @@ var init_dev_server = __esm({
|
|
|
40819
41117
|
}
|
|
40820
41118
|
getEndpointList() {
|
|
40821
41119
|
return this.routes.map((r) => {
|
|
40822
|
-
const
|
|
40823
|
-
return `${r.method.padEnd(5)} ${
|
|
41120
|
+
const path29 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
41121
|
+
return `${r.method.padEnd(5)} ${path29}`;
|
|
40824
41122
|
});
|
|
40825
41123
|
}
|
|
40826
41124
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -41101,12 +41399,12 @@ var init_dev_server = __esm({
|
|
|
41101
41399
|
// ─── DevConsole SPA ───
|
|
41102
41400
|
getConsoleDistDir() {
|
|
41103
41401
|
const candidates = [
|
|
41104
|
-
|
|
41105
|
-
|
|
41106
|
-
|
|
41402
|
+
path21.resolve(__dirname, "../../web-devconsole/dist"),
|
|
41403
|
+
path21.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
41404
|
+
path21.join(process.cwd(), "packages/web-devconsole/dist")
|
|
41107
41405
|
];
|
|
41108
41406
|
for (const dir of candidates) {
|
|
41109
|
-
if (fs14.existsSync(
|
|
41407
|
+
if (fs14.existsSync(path21.join(dir, "index.html"))) return dir;
|
|
41110
41408
|
}
|
|
41111
41409
|
return null;
|
|
41112
41410
|
}
|
|
@@ -41116,7 +41414,7 @@ var init_dev_server = __esm({
|
|
|
41116
41414
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
41117
41415
|
return;
|
|
41118
41416
|
}
|
|
41119
|
-
const htmlPath =
|
|
41417
|
+
const htmlPath = path21.join(distDir, "index.html");
|
|
41120
41418
|
try {
|
|
41121
41419
|
const html = fs14.readFileSync(htmlPath, "utf-8");
|
|
41122
41420
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -41141,15 +41439,15 @@ var init_dev_server = __esm({
|
|
|
41141
41439
|
this.json(res, 404, { error: "Not found" });
|
|
41142
41440
|
return;
|
|
41143
41441
|
}
|
|
41144
|
-
const safePath =
|
|
41145
|
-
const filePath =
|
|
41442
|
+
const safePath = path21.normalize(pathname).replace(/^\.\.\//, "");
|
|
41443
|
+
const filePath = path21.join(distDir, safePath);
|
|
41146
41444
|
if (!filePath.startsWith(distDir)) {
|
|
41147
41445
|
this.json(res, 403, { error: "Forbidden" });
|
|
41148
41446
|
return;
|
|
41149
41447
|
}
|
|
41150
41448
|
try {
|
|
41151
41449
|
const content = fs14.readFileSync(filePath);
|
|
41152
|
-
const ext =
|
|
41450
|
+
const ext = path21.extname(filePath);
|
|
41153
41451
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
41154
41452
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
41155
41453
|
res.end(content);
|
|
@@ -41262,9 +41560,9 @@ var init_dev_server = __esm({
|
|
|
41262
41560
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
41263
41561
|
if (entry.isDirectory()) {
|
|
41264
41562
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
41265
|
-
scan(
|
|
41563
|
+
scan(path21.join(d, entry.name), rel);
|
|
41266
41564
|
} else {
|
|
41267
|
-
const stat4 = fs14.statSync(
|
|
41565
|
+
const stat4 = fs14.statSync(path21.join(d, entry.name));
|
|
41268
41566
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
41269
41567
|
}
|
|
41270
41568
|
}
|
|
@@ -41287,7 +41585,7 @@ var init_dev_server = __esm({
|
|
|
41287
41585
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
41288
41586
|
return;
|
|
41289
41587
|
}
|
|
41290
|
-
const fullPath =
|
|
41588
|
+
const fullPath = path21.resolve(dir, path21.normalize(filePath));
|
|
41291
41589
|
if (!fullPath.startsWith(dir)) {
|
|
41292
41590
|
this.json(res, 403, { error: "Forbidden" });
|
|
41293
41591
|
return;
|
|
@@ -41312,14 +41610,14 @@ var init_dev_server = __esm({
|
|
|
41312
41610
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
41313
41611
|
return;
|
|
41314
41612
|
}
|
|
41315
|
-
const fullPath =
|
|
41613
|
+
const fullPath = path21.resolve(dir, path21.normalize(filePath));
|
|
41316
41614
|
if (!fullPath.startsWith(dir)) {
|
|
41317
41615
|
this.json(res, 403, { error: "Forbidden" });
|
|
41318
41616
|
return;
|
|
41319
41617
|
}
|
|
41320
41618
|
try {
|
|
41321
41619
|
if (fs14.existsSync(fullPath)) fs14.copyFileSync(fullPath, fullPath + ".bak");
|
|
41322
|
-
fs14.mkdirSync(
|
|
41620
|
+
fs14.mkdirSync(path21.dirname(fullPath), { recursive: true });
|
|
41323
41621
|
fs14.writeFileSync(fullPath, content, "utf-8");
|
|
41324
41622
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
41325
41623
|
this.providerLoader.reload();
|
|
@@ -41336,7 +41634,7 @@ var init_dev_server = __esm({
|
|
|
41336
41634
|
return;
|
|
41337
41635
|
}
|
|
41338
41636
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
41339
|
-
const p =
|
|
41637
|
+
const p = path21.join(dir, name);
|
|
41340
41638
|
if (fs14.existsSync(p)) {
|
|
41341
41639
|
const source = fs14.readFileSync(p, "utf-8");
|
|
41342
41640
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -41357,8 +41655,8 @@ var init_dev_server = __esm({
|
|
|
41357
41655
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
41358
41656
|
return;
|
|
41359
41657
|
}
|
|
41360
|
-
const target = fs14.existsSync(
|
|
41361
|
-
const targetPath =
|
|
41658
|
+
const target = fs14.existsSync(path21.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
41659
|
+
const targetPath = path21.join(dir, target);
|
|
41362
41660
|
try {
|
|
41363
41661
|
if (fs14.existsSync(targetPath)) fs14.copyFileSync(targetPath, targetPath + ".bak");
|
|
41364
41662
|
fs14.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -41505,7 +41803,7 @@ var init_dev_server = __esm({
|
|
|
41505
41803
|
}
|
|
41506
41804
|
let targetDir;
|
|
41507
41805
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
41508
|
-
const jsonPath =
|
|
41806
|
+
const jsonPath = path21.join(targetDir, "provider.json");
|
|
41509
41807
|
if (fs14.existsSync(jsonPath)) {
|
|
41510
41808
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
41511
41809
|
return;
|
|
@@ -41517,8 +41815,8 @@ var init_dev_server = __esm({
|
|
|
41517
41815
|
const createdFiles = ["provider.json"];
|
|
41518
41816
|
if (result.files) {
|
|
41519
41817
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
41520
|
-
const fullPath =
|
|
41521
|
-
fs14.mkdirSync(
|
|
41818
|
+
const fullPath = path21.join(targetDir, relPath);
|
|
41819
|
+
fs14.mkdirSync(path21.dirname(fullPath), { recursive: true });
|
|
41522
41820
|
fs14.writeFileSync(fullPath, content, "utf-8");
|
|
41523
41821
|
createdFiles.push(relPath);
|
|
41524
41822
|
}
|
|
@@ -41571,22 +41869,22 @@ var init_dev_server = __esm({
|
|
|
41571
41869
|
if (!fs14.existsSync(scriptsDir)) return null;
|
|
41572
41870
|
const versions = fs14.readdirSync(scriptsDir).filter((d) => {
|
|
41573
41871
|
try {
|
|
41574
|
-
return fs14.statSync(
|
|
41872
|
+
return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
|
|
41575
41873
|
} catch {
|
|
41576
41874
|
return false;
|
|
41577
41875
|
}
|
|
41578
41876
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
41579
41877
|
if (versions.length === 0) return null;
|
|
41580
|
-
return
|
|
41878
|
+
return path21.join(scriptsDir, versions[0]);
|
|
41581
41879
|
}
|
|
41582
41880
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
41583
|
-
const canonicalUserDir =
|
|
41584
|
-
const desiredDir = requestedDir ?
|
|
41585
|
-
const upstreamRoot =
|
|
41586
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
41881
|
+
const canonicalUserDir = path21.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
41882
|
+
const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
|
|
41883
|
+
const upstreamRoot = path21.resolve(this.providerLoader.getUpstreamDir());
|
|
41884
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
|
|
41587
41885
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
41588
41886
|
}
|
|
41589
|
-
if (
|
|
41887
|
+
if (path21.basename(desiredDir) !== type) {
|
|
41590
41888
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
41591
41889
|
}
|
|
41592
41890
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -41594,11 +41892,11 @@ var init_dev_server = __esm({
|
|
|
41594
41892
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
41595
41893
|
}
|
|
41596
41894
|
if (!fs14.existsSync(desiredDir)) {
|
|
41597
|
-
fs14.mkdirSync(
|
|
41895
|
+
fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
|
|
41598
41896
|
fs14.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
41599
41897
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
41600
41898
|
}
|
|
41601
|
-
const providerJson =
|
|
41899
|
+
const providerJson = path21.join(desiredDir, "provider.json");
|
|
41602
41900
|
if (!fs14.existsSync(providerJson)) {
|
|
41603
41901
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
41604
41902
|
}
|
|
@@ -41634,7 +41932,7 @@ var init_dev_server = __esm({
|
|
|
41634
41932
|
setMode: "set_mode.js"
|
|
41635
41933
|
};
|
|
41636
41934
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
41637
|
-
const scriptsDir =
|
|
41935
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
41638
41936
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
41639
41937
|
if (latestScriptsDir) {
|
|
41640
41938
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41645,7 +41943,7 @@ var init_dev_server = __esm({
|
|
|
41645
41943
|
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
41646
41944
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
41647
41945
|
try {
|
|
41648
|
-
const content = fs14.readFileSync(
|
|
41946
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
41649
41947
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41650
41948
|
lines.push("```javascript");
|
|
41651
41949
|
lines.push(content);
|
|
@@ -41662,7 +41960,7 @@ var init_dev_server = __esm({
|
|
|
41662
41960
|
lines.push("");
|
|
41663
41961
|
for (const file2 of refFiles) {
|
|
41664
41962
|
try {
|
|
41665
|
-
const content = fs14.readFileSync(
|
|
41963
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
41666
41964
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41667
41965
|
lines.push("```javascript");
|
|
41668
41966
|
lines.push(content);
|
|
@@ -41703,10 +42001,10 @@ var init_dev_server = __esm({
|
|
|
41703
42001
|
lines.push("");
|
|
41704
42002
|
}
|
|
41705
42003
|
}
|
|
41706
|
-
const docsDir =
|
|
42004
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
41707
42005
|
const loadGuide = (name) => {
|
|
41708
42006
|
try {
|
|
41709
|
-
const p =
|
|
42007
|
+
const p = path21.join(docsDir, name);
|
|
41710
42008
|
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
41711
42009
|
} catch {
|
|
41712
42010
|
}
|
|
@@ -41880,7 +42178,7 @@ var init_dev_server = __esm({
|
|
|
41880
42178
|
parseApproval: "parse_approval.js"
|
|
41881
42179
|
};
|
|
41882
42180
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
41883
|
-
const scriptsDir =
|
|
42181
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
41884
42182
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
41885
42183
|
if (latestScriptsDir) {
|
|
41886
42184
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41892,7 +42190,7 @@ var init_dev_server = __esm({
|
|
|
41892
42190
|
if (!file2.endsWith(".js")) continue;
|
|
41893
42191
|
if (!targetFileNames.has(file2)) continue;
|
|
41894
42192
|
try {
|
|
41895
|
-
const content = fs14.readFileSync(
|
|
42193
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
41896
42194
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41897
42195
|
lines.push("```javascript");
|
|
41898
42196
|
lines.push(content);
|
|
@@ -41908,7 +42206,7 @@ var init_dev_server = __esm({
|
|
|
41908
42206
|
lines.push("");
|
|
41909
42207
|
for (const file2 of refFiles) {
|
|
41910
42208
|
try {
|
|
41911
|
-
const content = fs14.readFileSync(
|
|
42209
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
41912
42210
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41913
42211
|
lines.push("```javascript");
|
|
41914
42212
|
lines.push(content);
|
|
@@ -41941,10 +42239,10 @@ var init_dev_server = __esm({
|
|
|
41941
42239
|
lines.push("");
|
|
41942
42240
|
}
|
|
41943
42241
|
}
|
|
41944
|
-
const docsDir =
|
|
42242
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
41945
42243
|
const loadGuide = (name) => {
|
|
41946
42244
|
try {
|
|
41947
|
-
const p =
|
|
42245
|
+
const p = path21.join(docsDir, name);
|
|
41948
42246
|
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
41949
42247
|
} catch {
|
|
41950
42248
|
}
|
|
@@ -44406,12 +44704,12 @@ var init_peer_connection_manager = __esm({
|
|
|
44406
44704
|
});
|
|
44407
44705
|
|
|
44408
44706
|
// src/daemon-p2p/index.ts
|
|
44409
|
-
var fs15,
|
|
44707
|
+
var fs15, path23, import_node_module2, esmRequire, DaemonP2PSender;
|
|
44410
44708
|
var init_daemon_p2p = __esm({
|
|
44411
44709
|
"src/daemon-p2p/index.ts"() {
|
|
44412
44710
|
"use strict";
|
|
44413
44711
|
fs15 = __toESM(require("fs"));
|
|
44414
|
-
|
|
44712
|
+
path23 = __toESM(require("path"));
|
|
44415
44713
|
import_node_module2 = require("module");
|
|
44416
44714
|
init_data_channel_router();
|
|
44417
44715
|
init_screenshot_sender();
|
|
@@ -44484,15 +44782,15 @@ ${e?.stack || ""}`);
|
|
|
44484
44782
|
const prebuildKey = `${platform13}-${arch4}`;
|
|
44485
44783
|
try {
|
|
44486
44784
|
const candidates = [
|
|
44487
|
-
|
|
44488
|
-
|
|
44489
|
-
|
|
44785
|
+
path23.join(__dirname, "node_modules", "node-datachannel"),
|
|
44786
|
+
path23.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
44787
|
+
path23.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
44490
44788
|
];
|
|
44491
44789
|
for (const candidate of candidates) {
|
|
44492
|
-
const prebuildPath =
|
|
44790
|
+
const prebuildPath = path23.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
44493
44791
|
if (fs15.existsSync(prebuildPath)) {
|
|
44494
|
-
const targetDir =
|
|
44495
|
-
const targetPath =
|
|
44792
|
+
const targetDir = path23.join(candidate, "build", "Release");
|
|
44793
|
+
const targetPath = path23.join(targetDir, "node_datachannel.node");
|
|
44496
44794
|
fs15.mkdirSync(targetDir, { recursive: true });
|
|
44497
44795
|
fs15.copyFileSync(prebuildPath, targetPath);
|
|
44498
44796
|
try {
|
|
@@ -44814,16 +45112,16 @@ var require_filesystem = __commonJS({
|
|
|
44814
45112
|
var LDD_PATH = "/usr/bin/ldd";
|
|
44815
45113
|
var SELF_PATH = "/proc/self/exe";
|
|
44816
45114
|
var MAX_LENGTH = 2048;
|
|
44817
|
-
var readFileSync19 = (
|
|
44818
|
-
const fd = fs24.openSync(
|
|
45115
|
+
var readFileSync19 = (path29) => {
|
|
45116
|
+
const fd = fs24.openSync(path29, "r");
|
|
44819
45117
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
44820
45118
|
const bytesRead = fs24.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
44821
45119
|
fs24.close(fd, () => {
|
|
44822
45120
|
});
|
|
44823
45121
|
return buffer.subarray(0, bytesRead);
|
|
44824
45122
|
};
|
|
44825
|
-
var readFile = (
|
|
44826
|
-
fs24.open(
|
|
45123
|
+
var readFile = (path29) => new Promise((resolve15, reject) => {
|
|
45124
|
+
fs24.open(path29, "r", (err, fd) => {
|
|
44827
45125
|
if (err) {
|
|
44828
45126
|
reject(err);
|
|
44829
45127
|
} else {
|
|
@@ -44942,11 +45240,11 @@ var require_detect_libc = __commonJS({
|
|
|
44942
45240
|
}
|
|
44943
45241
|
return null;
|
|
44944
45242
|
};
|
|
44945
|
-
var familyFromInterpreterPath = (
|
|
44946
|
-
if (
|
|
44947
|
-
if (
|
|
45243
|
+
var familyFromInterpreterPath = (path29) => {
|
|
45244
|
+
if (path29) {
|
|
45245
|
+
if (path29.includes("/ld-musl-")) {
|
|
44948
45246
|
return MUSL;
|
|
44949
|
-
} else if (
|
|
45247
|
+
} else if (path29.includes("/ld-linux-")) {
|
|
44950
45248
|
return GLIBC;
|
|
44951
45249
|
}
|
|
44952
45250
|
}
|
|
@@ -44993,8 +45291,8 @@ var require_detect_libc = __commonJS({
|
|
|
44993
45291
|
cachedFamilyInterpreter = null;
|
|
44994
45292
|
try {
|
|
44995
45293
|
const selfContent = await readFile(SELF_PATH);
|
|
44996
|
-
const
|
|
44997
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
45294
|
+
const path29 = interpreterPath(selfContent);
|
|
45295
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path29);
|
|
44998
45296
|
} catch (e) {
|
|
44999
45297
|
}
|
|
45000
45298
|
return cachedFamilyInterpreter;
|
|
@@ -45006,8 +45304,8 @@ var require_detect_libc = __commonJS({
|
|
|
45006
45304
|
cachedFamilyInterpreter = null;
|
|
45007
45305
|
try {
|
|
45008
45306
|
const selfContent = readFileSync19(SELF_PATH);
|
|
45009
|
-
const
|
|
45010
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
45307
|
+
const path29 = interpreterPath(selfContent);
|
|
45308
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path29);
|
|
45011
45309
|
} catch (e) {
|
|
45012
45310
|
}
|
|
45013
45311
|
return cachedFamilyInterpreter;
|
|
@@ -46726,18 +47024,18 @@ var require_sharp = __commonJS({
|
|
|
46726
47024
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
46727
47025
|
"@img/sharp-wasm32/sharp.node"
|
|
46728
47026
|
];
|
|
46729
|
-
var
|
|
47027
|
+
var path29;
|
|
46730
47028
|
var sharp;
|
|
46731
47029
|
var errors = [];
|
|
46732
|
-
for (
|
|
47030
|
+
for (path29 of paths) {
|
|
46733
47031
|
try {
|
|
46734
|
-
sharp = require(
|
|
47032
|
+
sharp = require(path29);
|
|
46735
47033
|
break;
|
|
46736
47034
|
} catch (err) {
|
|
46737
47035
|
errors.push(err);
|
|
46738
47036
|
}
|
|
46739
47037
|
}
|
|
46740
|
-
if (sharp &&
|
|
47038
|
+
if (sharp && path29.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
46741
47039
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
46742
47040
|
err.code = "Unsupported CPU";
|
|
46743
47041
|
errors.push(err);
|
|
@@ -49646,15 +49944,15 @@ var require_color = __commonJS({
|
|
|
49646
49944
|
};
|
|
49647
49945
|
}
|
|
49648
49946
|
function wrapConversion(toModel, graph) {
|
|
49649
|
-
const
|
|
49947
|
+
const path29 = [graph[toModel].parent, toModel];
|
|
49650
49948
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
49651
49949
|
let cur = graph[toModel].parent;
|
|
49652
49950
|
while (graph[cur].parent) {
|
|
49653
|
-
|
|
49951
|
+
path29.unshift(graph[cur].parent);
|
|
49654
49952
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
49655
49953
|
cur = graph[cur].parent;
|
|
49656
49954
|
}
|
|
49657
|
-
fn.conversion =
|
|
49955
|
+
fn.conversion = path29;
|
|
49658
49956
|
return fn;
|
|
49659
49957
|
}
|
|
49660
49958
|
function route(fromModel) {
|
|
@@ -50271,7 +50569,7 @@ var require_channel = __commonJS({
|
|
|
50271
50569
|
var require_output = __commonJS({
|
|
50272
50570
|
"../../node_modules/sharp/lib/output.js"(exports2, module2) {
|
|
50273
50571
|
"use strict";
|
|
50274
|
-
var
|
|
50572
|
+
var path29 = require("path");
|
|
50275
50573
|
var is = require_is();
|
|
50276
50574
|
var sharp = require_sharp();
|
|
50277
50575
|
var formats = /* @__PURE__ */ new Map([
|
|
@@ -50302,9 +50600,9 @@ var require_output = __commonJS({
|
|
|
50302
50600
|
let err;
|
|
50303
50601
|
if (!is.string(fileOut)) {
|
|
50304
50602
|
err = new Error("Missing output file path");
|
|
50305
|
-
} else if (is.string(this.options.input.file) &&
|
|
50603
|
+
} else if (is.string(this.options.input.file) && path29.resolve(this.options.input.file) === path29.resolve(fileOut)) {
|
|
50306
50604
|
err = new Error("Cannot use same file for input and output");
|
|
50307
|
-
} else if (jp2Regex.test(
|
|
50605
|
+
} else if (jp2Regex.test(path29.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
50308
50606
|
err = errJp2Save();
|
|
50309
50607
|
}
|
|
50310
50608
|
if (err) {
|
|
@@ -51546,11 +51844,11 @@ function quarantineLegacyStandaloneSessions(options) {
|
|
|
51546
51844
|
const homeDir = options.homeDir || os23.homedir();
|
|
51547
51845
|
const now = options.now || (() => /* @__PURE__ */ new Date());
|
|
51548
51846
|
const isPidRunning = options.isPidRunning || defaultPidRunning;
|
|
51549
|
-
const runtimesDir =
|
|
51847
|
+
const runtimesDir = path24.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
|
|
51550
51848
|
if (!fs16.existsSync(runtimesDir)) {
|
|
51551
51849
|
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
51552
51850
|
}
|
|
51553
|
-
const candidates = fs16.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) =>
|
|
51851
|
+
const candidates = fs16.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path24.join(runtimesDir, name));
|
|
51554
51852
|
let movedCount = 0;
|
|
51555
51853
|
let skippedActiveCount = 0;
|
|
51556
51854
|
let backupDir = null;
|
|
@@ -51568,26 +51866,26 @@ function quarantineLegacyStandaloneSessions(options) {
|
|
|
51568
51866
|
continue;
|
|
51569
51867
|
}
|
|
51570
51868
|
if (!backupDir) {
|
|
51571
|
-
backupDir =
|
|
51869
|
+
backupDir = path24.join(
|
|
51572
51870
|
homeDir,
|
|
51573
51871
|
".adhdev",
|
|
51574
51872
|
"session-host-backups",
|
|
51575
51873
|
`legacy-standalone-${options.appName}-${formatTimestamp(now())}`
|
|
51576
51874
|
);
|
|
51577
|
-
fs16.mkdirSync(
|
|
51875
|
+
fs16.mkdirSync(path24.join(backupDir, "runtimes"), { recursive: true });
|
|
51578
51876
|
}
|
|
51579
|
-
fs16.renameSync(sourcePath,
|
|
51877
|
+
fs16.renameSync(sourcePath, path24.join(backupDir, "runtimes", path24.basename(sourcePath)));
|
|
51580
51878
|
movedCount += 1;
|
|
51581
51879
|
}
|
|
51582
51880
|
return { movedCount, skippedActiveCount, backupDir };
|
|
51583
51881
|
}
|
|
51584
|
-
var fs16, os23,
|
|
51882
|
+
var fs16, os23, path24, LEGACY_STANDALONE_MANAGER_TAG;
|
|
51585
51883
|
var init_session_host_hygiene = __esm({
|
|
51586
51884
|
"src/session-host-hygiene.ts"() {
|
|
51587
51885
|
"use strict";
|
|
51588
51886
|
fs16 = __toESM(require("fs"));
|
|
51589
51887
|
os23 = __toESM(require("os"));
|
|
51590
|
-
|
|
51888
|
+
path24 = __toESM(require("path"));
|
|
51591
51889
|
init_src();
|
|
51592
51890
|
LEGACY_STANDALONE_MANAGER_TAG = "adhdev-standalone";
|
|
51593
51891
|
}
|
|
@@ -51601,8 +51899,8 @@ function buildSessionHostEnv(baseEnv) {
|
|
|
51601
51899
|
}
|
|
51602
51900
|
function resolveSessionHostEntry() {
|
|
51603
51901
|
const packagedCandidates = [
|
|
51604
|
-
|
|
51605
|
-
|
|
51902
|
+
path25.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
51903
|
+
path25.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
51606
51904
|
];
|
|
51607
51905
|
for (const candidate of packagedCandidates) {
|
|
51608
51906
|
if (fs17.existsSync(candidate)) {
|
|
@@ -51612,7 +51910,7 @@ function resolveSessionHostEntry() {
|
|
|
51612
51910
|
return require.resolve("@adhdev/session-host-daemon");
|
|
51613
51911
|
}
|
|
51614
51912
|
function getSessionHostPidFile() {
|
|
51615
|
-
return
|
|
51913
|
+
return path25.join(os24.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
51616
51914
|
}
|
|
51617
51915
|
function killPid2(pid) {
|
|
51618
51916
|
try {
|
|
@@ -51729,9 +52027,9 @@ async function ensureSessionHostReady2() {
|
|
|
51729
52027
|
}
|
|
51730
52028
|
const spawnHost = () => {
|
|
51731
52029
|
const entry = resolveSessionHostEntry();
|
|
51732
|
-
const logDir =
|
|
52030
|
+
const logDir = path25.join(os24.homedir(), ".adhdev", "logs");
|
|
51733
52031
|
fs17.mkdirSync(logDir, { recursive: true });
|
|
51734
|
-
const logFd = fs17.openSync(
|
|
52032
|
+
const logFd = fs17.openSync(path25.join(logDir, "session-host.log"), "a");
|
|
51735
52033
|
const child = (0, import_child_process11.spawn)(process.execPath, [entry], {
|
|
51736
52034
|
detached: true,
|
|
51737
52035
|
stdio: ["ignore", logFd, logFd],
|
|
@@ -51766,14 +52064,14 @@ async function ensureSessionHostReady2() {
|
|
|
51766
52064
|
async function listHostedCliRuntimes2(endpoint) {
|
|
51767
52065
|
return listHostedCliRuntimes(endpoint);
|
|
51768
52066
|
}
|
|
51769
|
-
var import_child_process11, fs17, os24,
|
|
52067
|
+
var import_child_process11, fs17, os24, path25, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
|
|
51770
52068
|
var init_session_host = __esm({
|
|
51771
52069
|
"src/session-host.ts"() {
|
|
51772
52070
|
"use strict";
|
|
51773
52071
|
import_child_process11 = require("child_process");
|
|
51774
52072
|
fs17 = __toESM(require("fs"));
|
|
51775
52073
|
os24 = __toESM(require("os"));
|
|
51776
|
-
|
|
52074
|
+
path25 = __toESM(require("path"));
|
|
51777
52075
|
init_src();
|
|
51778
52076
|
init_dist();
|
|
51779
52077
|
init_session_host_hygiene();
|
|
@@ -52534,10 +52832,10 @@ function resolveDaemonPort(ref = {}) {
|
|
|
52534
52832
|
return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
|
|
52535
52833
|
}
|
|
52536
52834
|
function getDaemonPidFile(ref = {}) {
|
|
52537
|
-
const dir =
|
|
52835
|
+
const dir = path26.join(ref.homeDir || os26.homedir(), ".adhdev");
|
|
52538
52836
|
if (!fs18.existsSync(dir)) fs18.mkdirSync(dir, { recursive: true });
|
|
52539
52837
|
const port = resolveDaemonPort(ref);
|
|
52540
|
-
return
|
|
52838
|
+
return path26.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
|
|
52541
52839
|
}
|
|
52542
52840
|
function writeDaemonPid(pid, ref = {}) {
|
|
52543
52841
|
const pidFile = getDaemonPidFile(ref);
|
|
@@ -52642,7 +52940,7 @@ function stopDaemon(ref = {}) {
|
|
|
52642
52940
|
return false;
|
|
52643
52941
|
}
|
|
52644
52942
|
}
|
|
52645
|
-
var os26, fs18,
|
|
52943
|
+
var os26, fs18, path26, import_http, import_ws3, pkgVersion, AdhdevDaemon;
|
|
52646
52944
|
var init_adhdev_daemon = __esm({
|
|
52647
52945
|
"src/adhdev-daemon.ts"() {
|
|
52648
52946
|
"use strict";
|
|
@@ -52656,13 +52954,13 @@ var init_adhdev_daemon = __esm({
|
|
|
52656
52954
|
init_session_host_controller();
|
|
52657
52955
|
os26 = __toESM(require("os"));
|
|
52658
52956
|
fs18 = __toESM(require("fs"));
|
|
52659
|
-
|
|
52957
|
+
path26 = __toESM(require("path"));
|
|
52660
52958
|
import_http = require("http");
|
|
52661
52959
|
import_ws3 = require("ws");
|
|
52662
52960
|
init_source2();
|
|
52663
52961
|
init_version();
|
|
52664
52962
|
init_src();
|
|
52665
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
52963
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.67" });
|
|
52666
52964
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
52667
52965
|
localHttpServer = null;
|
|
52668
52966
|
localWss = null;
|
|
@@ -53384,6 +53682,15 @@ ${err?.stack || ""}`);
|
|
|
53384
53682
|
await this.handleCommand(msg, msg.type, msg.payload);
|
|
53385
53683
|
});
|
|
53386
53684
|
}
|
|
53685
|
+
shouldFastFlushLaunchStatus(commandType, result) {
|
|
53686
|
+
if (!result || result.success !== true) return false;
|
|
53687
|
+
return commandType === "launch_cli" || commandType === "launch_ide";
|
|
53688
|
+
}
|
|
53689
|
+
triggerImmediateLaunchStatusUpdate(reason) {
|
|
53690
|
+
this.statusReporter?.resetP2PHash();
|
|
53691
|
+
void this.statusReporter?.sendUnifiedStatusReport({ forceServer: true, reason });
|
|
53692
|
+
void this.flushP2PDaemonMetadataSubscriptions();
|
|
53693
|
+
}
|
|
53387
53694
|
async handleCommand(msg, cmd, args) {
|
|
53388
53695
|
const normalizedArgs = this.ensureInteractionContext(args);
|
|
53389
53696
|
const interactionId = String(normalizedArgs._interactionId);
|
|
@@ -53411,6 +53718,9 @@ ${err?.stack || ""}`);
|
|
|
53411
53718
|
return;
|
|
53412
53719
|
}
|
|
53413
53720
|
const result = await this.components.router.execute(cmd, normalizedArgs, source);
|
|
53721
|
+
if (this.shouldFastFlushLaunchStatus(cmd, result)) {
|
|
53722
|
+
this.triggerImmediateLaunchStatusUpdate(`command:${cmd}`);
|
|
53723
|
+
}
|
|
53414
53724
|
if (cmd.startsWith("workspace_")) this.statusReporter?.throttledReport();
|
|
53415
53725
|
if (cmd === "get_status_metadata" || cmd.startsWith("workspace_") || cmd.startsWith("session_host_")) {
|
|
53416
53726
|
void this.flushP2PDaemonMetadataSubscriptions();
|
|
@@ -53481,6 +53791,9 @@ ${err?.stack || ""}`);
|
|
|
53481
53791
|
}
|
|
53482
53792
|
}
|
|
53483
53793
|
const routed = await this.components.router.execute(cmdType, normalizedData, "p2p");
|
|
53794
|
+
if (this.shouldFastFlushLaunchStatus(cmdType, routed)) {
|
|
53795
|
+
this.triggerImmediateLaunchStatusUpdate(`p2p:${cmdType}`);
|
|
53796
|
+
}
|
|
53484
53797
|
if (cmdType.startsWith("workspace_")) this.statusReporter?.throttledReport();
|
|
53485
53798
|
if (cmdType === "get_status_metadata" || cmdType.startsWith("workspace_") || cmdType.startsWith("session_host_")) {
|
|
53486
53799
|
void this.flushP2PDaemonMetadataSubscriptions();
|
|
@@ -65076,15 +65389,15 @@ var require_route = __commonJS({
|
|
|
65076
65389
|
};
|
|
65077
65390
|
}
|
|
65078
65391
|
function wrapConversion(toModel, graph) {
|
|
65079
|
-
const
|
|
65392
|
+
const path29 = [graph[toModel].parent, toModel];
|
|
65080
65393
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
65081
65394
|
let cur = graph[toModel].parent;
|
|
65082
65395
|
while (graph[cur].parent) {
|
|
65083
|
-
|
|
65396
|
+
path29.unshift(graph[cur].parent);
|
|
65084
65397
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
65085
65398
|
cur = graph[cur].parent;
|
|
65086
65399
|
}
|
|
65087
|
-
fn.conversion =
|
|
65400
|
+
fn.conversion = path29;
|
|
65088
65401
|
return fn;
|
|
65089
65402
|
}
|
|
65090
65403
|
module2.exports = function(fromModel) {
|
|
@@ -82954,9 +83267,9 @@ var init_prompt = __esm({
|
|
|
82954
83267
|
init_utils();
|
|
82955
83268
|
init_baseUI();
|
|
82956
83269
|
_ = {
|
|
82957
|
-
set: (obj,
|
|
83270
|
+
set: (obj, path29 = "", value) => {
|
|
82958
83271
|
let pointer = obj;
|
|
82959
|
-
|
|
83272
|
+
path29.split(".").forEach((key, index, arr) => {
|
|
82960
83273
|
if (key === "__proto__" || key === "constructor") return;
|
|
82961
83274
|
if (index === arr.length - 1) {
|
|
82962
83275
|
pointer[key] = value;
|
|
@@ -82966,8 +83279,8 @@ var init_prompt = __esm({
|
|
|
82966
83279
|
pointer = pointer[key];
|
|
82967
83280
|
});
|
|
82968
83281
|
},
|
|
82969
|
-
get: (obj,
|
|
82970
|
-
const travel = (regexp) => String.prototype.split.call(
|
|
83282
|
+
get: (obj, path29 = "", defaultValue) => {
|
|
83283
|
+
const travel = (regexp) => String.prototype.split.call(path29, regexp).filter(Boolean).reduce(
|
|
82971
83284
|
// @ts-expect-error implicit any on res[key]
|
|
82972
83285
|
(res, key) => res !== null && res !== void 0 ? res[key] : res,
|
|
82973
83286
|
obj
|