@adhdev/daemon-core 0.9.76-rc.24 → 0.9.76-rc.26
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/index.js +96 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -5
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider-instance-manager.d.ts +1 -0
- package/dist/providers/provider-instance.d.ts +2 -0
- package/dist/repo-mesh-types.d.ts +1 -0
- package/dist/shared-types.d.ts +4 -0
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +1 -1
- package/src/commands/router.ts +77 -2
- package/src/providers/cli-provider-instance.ts +23 -1
- package/src/providers/provider-instance-manager.ts +20 -1
- package/src/providers/provider-instance.ts +2 -0
- package/src/repo-mesh-types.ts +1 -0
- package/src/shared-types.ts +4 -0
- package/src/status/reporter.ts +6 -0
package/dist/index.js
CHANGED
|
@@ -12493,7 +12493,7 @@ async function handleChatHistory(h, args) {
|
|
|
12493
12493
|
}
|
|
12494
12494
|
}
|
|
12495
12495
|
async function handleReadChat(h, args) {
|
|
12496
|
-
const provider = h.getProvider(args?.agentType);
|
|
12496
|
+
const provider = h.getProvider(args?.agentType || args?.providerType);
|
|
12497
12497
|
const transport = getTargetTransport(h, provider);
|
|
12498
12498
|
const historySessionId = getHistorySessionId(h, args);
|
|
12499
12499
|
const _log = (msg) => LOG.debug("Command", `[read_chat] ${msg}`);
|
|
@@ -15457,7 +15457,19 @@ var CliProviderInstance = class {
|
|
|
15457
15457
|
}
|
|
15458
15458
|
}
|
|
15459
15459
|
pushEvent(event) {
|
|
15460
|
-
|
|
15460
|
+
const enrichedEvent = {
|
|
15461
|
+
...event,
|
|
15462
|
+
instanceId: typeof event.instanceId === "string" && event.instanceId.trim() ? event.instanceId : this.instanceId,
|
|
15463
|
+
targetSessionId: typeof event.targetSessionId === "string" && event.targetSessionId.trim() ? event.targetSessionId : this.instanceId,
|
|
15464
|
+
providerType: typeof event.providerType === "string" && event.providerType.trim() ? event.providerType : this.type,
|
|
15465
|
+
workspaceName: typeof event.workspaceName === "string" && event.workspaceName.trim() ? event.workspaceName : this.workingDir,
|
|
15466
|
+
providerSessionId: typeof event.providerSessionId === "string" && event.providerSessionId.trim() ? event.providerSessionId : this.providerSessionId
|
|
15467
|
+
};
|
|
15468
|
+
if (this.context?.emitProviderEvent) {
|
|
15469
|
+
this.context.emitProviderEvent(enrichedEvent);
|
|
15470
|
+
return;
|
|
15471
|
+
}
|
|
15472
|
+
this.events.push(enrichedEvent);
|
|
15461
15473
|
}
|
|
15462
15474
|
flushEvents() {
|
|
15463
15475
|
const events = [...this.events];
|
|
@@ -21179,6 +21191,40 @@ function normalizeReleaseChannel(value) {
|
|
|
21179
21191
|
function resolveUpgradeChannel(args) {
|
|
21180
21192
|
return normalizeReleaseChannel(args?.channel) || normalizeReleaseChannel(args?.updatePolicy?.channel) || normalizeReleaseChannel(args?.npmTag) || normalizeReleaseChannel(loadConfig().updateChannel) || "stable";
|
|
21181
21193
|
}
|
|
21194
|
+
function readProviderPriorityFromPolicy(policy) {
|
|
21195
|
+
const record = policy && typeof policy === "object" && !Array.isArray(policy) ? policy : {};
|
|
21196
|
+
const raw = record.providerPriority;
|
|
21197
|
+
if (!Array.isArray(raw)) return [];
|
|
21198
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21199
|
+
return raw.map((type) => typeof type === "string" ? type.trim() : "").filter(Boolean).filter((type) => {
|
|
21200
|
+
if (seen.has(type)) return false;
|
|
21201
|
+
seen.add(type);
|
|
21202
|
+
return true;
|
|
21203
|
+
});
|
|
21204
|
+
}
|
|
21205
|
+
async function resolveProviderTypeFromPriority(args) {
|
|
21206
|
+
if (!args.providerPriority.length) {
|
|
21207
|
+
return { error: `Node '${args.nodeId}' has no providerPriority policy; pass cliType explicitly or configure node.policy.providerPriority` };
|
|
21208
|
+
}
|
|
21209
|
+
const failed = [];
|
|
21210
|
+
for (const requestedType of args.providerPriority) {
|
|
21211
|
+
const normalizedType = args.providerLoader.resolveAlias(requestedType);
|
|
21212
|
+
if (!args.providerLoader.isMachineProviderEnabled(normalizedType)) {
|
|
21213
|
+
failed.push(`${requestedType}: disabled`);
|
|
21214
|
+
continue;
|
|
21215
|
+
}
|
|
21216
|
+
const detected = await detectCLI(normalizedType, args.providerLoader, { includeVersion: false });
|
|
21217
|
+
args.providerLoader.setCliDetectionResults([{
|
|
21218
|
+
id: normalizedType,
|
|
21219
|
+
installed: !!detected,
|
|
21220
|
+
path: detected?.path
|
|
21221
|
+
}], false);
|
|
21222
|
+
args.onStatusChange?.();
|
|
21223
|
+
if (detected) return { providerType: normalizedType };
|
|
21224
|
+
failed.push(`${requestedType}: not detected`);
|
|
21225
|
+
}
|
|
21226
|
+
return { error: `No usable provider detected for node '${args.nodeId}' from providerPriority: ${failed.join("; ")}` };
|
|
21227
|
+
}
|
|
21182
21228
|
function loadYamlModule() {
|
|
21183
21229
|
return yaml;
|
|
21184
21230
|
}
|
|
@@ -22014,7 +22060,13 @@ var DaemonCommandRouter = class {
|
|
|
22014
22060
|
if (!workspace) return { success: false, error: "workspace required" };
|
|
22015
22061
|
try {
|
|
22016
22062
|
const { addNode: addNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
22017
|
-
const
|
|
22063
|
+
const providerPriority = Array.isArray(args?.providerPriority) ? args.providerPriority.map((type) => typeof type === "string" ? type.trim() : "").filter(Boolean) : [];
|
|
22064
|
+
const readOnly = args?.readOnly === true;
|
|
22065
|
+
const policy = {
|
|
22066
|
+
...readOnly ? { readOnly: true } : {},
|
|
22067
|
+
...providerPriority.length ? { providerPriority } : {}
|
|
22068
|
+
};
|
|
22069
|
+
const node = addNode3(meshId, { workspace, ...policy ? { policy } : {} });
|
|
22018
22070
|
if (!node) return { success: false, error: "Mesh not found" };
|
|
22019
22071
|
return { success: true, node };
|
|
22020
22072
|
} catch (e) {
|
|
@@ -22117,7 +22169,7 @@ var DaemonCommandRouter = class {
|
|
|
22117
22169
|
// ─── Mesh Coordinator Launch ───
|
|
22118
22170
|
case "launch_mesh_coordinator": {
|
|
22119
22171
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
22120
|
-
|
|
22172
|
+
let cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "";
|
|
22121
22173
|
if (!meshId) return { success: false, error: "meshId required" };
|
|
22122
22174
|
try {
|
|
22123
22175
|
const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
|
|
@@ -22145,6 +22197,25 @@ var DaemonCommandRouter = class {
|
|
|
22145
22197
|
}
|
|
22146
22198
|
const workspace = typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "";
|
|
22147
22199
|
if (!workspace) return { success: false, error: "Coordinator node workspace required", meshId, cliType };
|
|
22200
|
+
if (!cliType) {
|
|
22201
|
+
const resolved = await resolveProviderTypeFromPriority({
|
|
22202
|
+
nodeId: String(coordinatorNode.id || coordinatorNode.nodeId || preferredCoordinatorNodeId || "coordinator"),
|
|
22203
|
+
providerPriority: readProviderPriorityFromPolicy(coordinatorNode.policy),
|
|
22204
|
+
providerLoader: this.deps.providerLoader,
|
|
22205
|
+
onStatusChange: this.deps.onStatusChange
|
|
22206
|
+
});
|
|
22207
|
+
if (!resolved.providerType) {
|
|
22208
|
+
return {
|
|
22209
|
+
success: false,
|
|
22210
|
+
code: "mesh_coordinator_provider_priority_unusable",
|
|
22211
|
+
error: resolved.error || "No usable provider found from node providerPriority",
|
|
22212
|
+
meshId,
|
|
22213
|
+
cliType,
|
|
22214
|
+
workspace
|
|
22215
|
+
};
|
|
22216
|
+
}
|
|
22217
|
+
cliType = resolved.providerType;
|
|
22218
|
+
}
|
|
22148
22219
|
const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
|
|
22149
22220
|
const coordinatorSetup = resolveMeshCoordinatorSetup({
|
|
22150
22221
|
provider: providerMeta,
|
|
@@ -22459,6 +22530,12 @@ var DaemonStatusReporter = class {
|
|
|
22459
22530
|
if (providerType) {
|
|
22460
22531
|
payload.providerType = providerType;
|
|
22461
22532
|
}
|
|
22533
|
+
if (typeof event.providerSessionId === "string" && event.providerSessionId.trim()) {
|
|
22534
|
+
payload.providerSessionId = event.providerSessionId.trim();
|
|
22535
|
+
}
|
|
22536
|
+
if (typeof event.workspaceName === "string" && event.workspaceName.trim()) {
|
|
22537
|
+
payload.workspaceName = event.workspaceName.trim();
|
|
22538
|
+
}
|
|
22462
22539
|
if (typeof event.duration === "number" && Number.isFinite(event.duration)) {
|
|
22463
22540
|
payload.duration = event.duration;
|
|
22464
22541
|
}
|
|
@@ -23706,7 +23783,10 @@ var ProviderInstanceManager = class {
|
|
|
23706
23783
|
this.instances.get(id).dispose();
|
|
23707
23784
|
}
|
|
23708
23785
|
this.instances.set(id, instance);
|
|
23709
|
-
await instance.init(
|
|
23786
|
+
await instance.init({
|
|
23787
|
+
...context,
|
|
23788
|
+
emitProviderEvent: (event) => this.emitProviderEvent(instance.type, id, event)
|
|
23789
|
+
});
|
|
23710
23790
|
}
|
|
23711
23791
|
/**
|
|
23712
23792
|
* Instance remove
|
|
@@ -23868,6 +23948,17 @@ var ProviderInstanceManager = class {
|
|
|
23868
23948
|
onEvent(listener) {
|
|
23869
23949
|
this.eventListeners.push(listener);
|
|
23870
23950
|
}
|
|
23951
|
+
emitProviderEvent(providerType, instanceId, event) {
|
|
23952
|
+
const payload = {
|
|
23953
|
+
...event,
|
|
23954
|
+
providerType,
|
|
23955
|
+
instanceId: typeof event.instanceId === "string" && event.instanceId.trim() ? event.instanceId : instanceId,
|
|
23956
|
+
targetSessionId: typeof event.targetSessionId === "string" && event.targetSessionId.trim() ? event.targetSessionId : instanceId
|
|
23957
|
+
};
|
|
23958
|
+
for (const listener of this.eventListeners) {
|
|
23959
|
+
listener(payload);
|
|
23960
|
+
}
|
|
23961
|
+
}
|
|
23871
23962
|
emitPendingEvents(providerType, state, extra = {}) {
|
|
23872
23963
|
for (const event of state.pendingEvents) {
|
|
23873
23964
|
for (const listener of this.eventListeners) {
|