@zhushanwen/subagent-core 0.7.0 → 0.8.0
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/{chunk-VURUAGMM.js → chunk-OL5BK4VN.js} +237 -40
- package/dist/{engine-discovery-scan-ocpM8FmI.d.cts → engine-discovery-scan-BXLA8y-z.d.cts} +17 -1
- package/dist/{engine-discovery-scan-ocpM8FmI.d.ts → engine-discovery-scan-BXLA8y-z.d.ts} +17 -1
- package/dist/execution/engine/engine-discovery-scan.cjs +150 -40
- package/dist/execution/engine/engine-discovery-scan.d.cts +1 -1
- package/dist/execution/engine/engine-discovery-scan.d.ts +1 -1
- package/dist/execution/engine/engine-discovery-scan.js +1 -1
- package/dist/index.cjs +278 -225
- package/dist/index.d.cts +24 -4
- package/dist/index.d.ts +24 -4
- package/dist/index.js +188 -304
- package/dist.bundle/index.cjs +279 -226
- package/package.json +5 -5
- package/src/__tests__/record-store-last-line.test.ts +12 -0
- package/src/core/logger.ts +1 -1
- package/src/execution/__tests__/inflight-production-wiring.test.ts +223 -0
- package/src/execution/__tests__/nested-visibility.test.ts +13 -1
- package/src/execution/engine/__tests__/conformance/registry-fork-filter.test.ts +55 -53
- package/src/execution/engine/__tests__/inflight-snapshot.test.ts +180 -0
- package/src/execution/engine/client/engine-client.ts +30 -1
- package/src/execution/engine/host/host-bridge.ts +7 -0
- package/src/execution/engine/host/spawned-children.ts +1 -1
- package/src/execution/engine/inflight-snapshot.ts +92 -0
- package/src/execution/engine/port.ts +18 -0
- package/src/execution/path-encoding.ts +6 -0
- package/src/execution/subagent-service.ts +25 -0
- package/src/execution/worktree-registry.ts +11 -7
- package/src/index.ts +11 -1
|
@@ -388,16 +388,16 @@ var SpawnedChildrenMirror = class {
|
|
|
388
388
|
return this.entries.size;
|
|
389
389
|
}
|
|
390
390
|
/** 订阅状态广播(W6 notify/谓词接线点)。返回退订函数。 */
|
|
391
|
-
onChange(
|
|
392
|
-
this.listeners.add(
|
|
391
|
+
onChange(listener2) {
|
|
392
|
+
this.listeners.add(listener2);
|
|
393
393
|
return () => {
|
|
394
|
-
this.listeners.delete(
|
|
394
|
+
this.listeners.delete(listener2);
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
397
|
emit(event) {
|
|
398
|
-
for (const
|
|
398
|
+
for (const listener2 of this.listeners) {
|
|
399
399
|
try {
|
|
400
|
-
|
|
400
|
+
listener2(event);
|
|
401
401
|
} catch (err) {
|
|
402
402
|
logger3.debug(
|
|
403
403
|
`[spawned-children-mirror] listener threw for ${event.reason}: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -846,8 +846,117 @@ function waitForChildExit(child, timeoutMs) {
|
|
|
846
846
|
});
|
|
847
847
|
}
|
|
848
848
|
|
|
849
|
+
// src/execution/engine/host/spawned-children.ts
|
|
850
|
+
var CoreSpawnedChildrenMirror = class {
|
|
851
|
+
entries = /* @__PURE__ */ new Map();
|
|
852
|
+
/** 落项 / 覆盖(同 recordId 重 spawn = 覆盖旧句柄,与引擎侧 Map 同语义)。 */
|
|
853
|
+
register(recordId, child) {
|
|
854
|
+
this.entries.set(recordId, {
|
|
855
|
+
pid: child.pid,
|
|
856
|
+
killed: child.killed,
|
|
857
|
+
updatedAt: Date.now()
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
/** 单项置死(杀链入口:killRecordChildWithEscalation 途经)。 */
|
|
861
|
+
markKilled(recordId) {
|
|
862
|
+
const entry = this.entries.get(recordId);
|
|
863
|
+
if (entry !== void 0) {
|
|
864
|
+
entry.killed = true;
|
|
865
|
+
entry.updatedAt = Date.now();
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
/** 整体置死 + 清空(失效语义 2+3:引擎 exit / 重建 / dispose / killAll)。 */
|
|
869
|
+
killAll() {
|
|
870
|
+
this.entries.clear();
|
|
871
|
+
}
|
|
872
|
+
getChildByRecord(recordId) {
|
|
873
|
+
return this.entries.get(recordId);
|
|
874
|
+
}
|
|
875
|
+
/** 句柄存活谓词(镜像面;判据与引擎侧 `!child.killed` 同构)。 */
|
|
876
|
+
hasLiveProcessHandle(recordId) {
|
|
877
|
+
const entry = this.entries.get(recordId);
|
|
878
|
+
return entry !== void 0 && !entry.killed;
|
|
879
|
+
}
|
|
880
|
+
/** 快照(诊断/测试)。 */
|
|
881
|
+
snapshot() {
|
|
882
|
+
return [...this.entries.entries()].map(([recordId, entry]) => ({ recordId, ...entry }));
|
|
883
|
+
}
|
|
884
|
+
/** 测试隔离专用(生产禁用——进程级全局状态)。 */
|
|
885
|
+
clear() {
|
|
886
|
+
this.entries.clear();
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
var MIRROR_SLOT_KEY = /* @__PURE__ */ Symbol.for(
|
|
890
|
+
"@zhushanwen/pi-subagent-workflow.coreSpawnedChildrenMirror"
|
|
891
|
+
);
|
|
892
|
+
function coreMirrorSlot() {
|
|
893
|
+
let slot = Reflect.get(globalThis, MIRROR_SLOT_KEY);
|
|
894
|
+
if (!slot) {
|
|
895
|
+
slot = new CoreSpawnedChildrenMirror();
|
|
896
|
+
Reflect.set(globalThis, MIRROR_SLOT_KEY, slot);
|
|
897
|
+
}
|
|
898
|
+
return slot;
|
|
899
|
+
}
|
|
900
|
+
function coreSpawnedChildrenMirror() {
|
|
901
|
+
return coreMirrorSlot();
|
|
902
|
+
}
|
|
903
|
+
function hasLiveProcessHandleCore(recordId) {
|
|
904
|
+
return coreMirrorSlot().hasLiveProcessHandle(recordId);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// src/execution/lifecycle-manager.ts
|
|
908
|
+
var logger8 = getLogger("subagents");
|
|
909
|
+
var MS_PER_SECOND = 1e3;
|
|
910
|
+
var SECONDS_PER_MINUTE = 60;
|
|
911
|
+
var IDLE_TIMEOUT_MINUTES = 5;
|
|
912
|
+
var DEFAULT_IDLE_TIMEOUT_MS = IDLE_TIMEOUT_MINUTES * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
913
|
+
var idleTimers = /* @__PURE__ */ new Map();
|
|
914
|
+
function hasIdleTimer(recordId) {
|
|
915
|
+
return idleTimers.has(recordId);
|
|
916
|
+
}
|
|
917
|
+
var ACTIVATE_LOCK_TIMEOUT_SECONDS = 30;
|
|
918
|
+
var ACTIVATE_LOCK_TIMEOUT_MS = ACTIVATE_LOCK_TIMEOUT_SECONDS * MS_PER_SECOND;
|
|
919
|
+
|
|
920
|
+
// src/execution/lifecycle-predicates.ts
|
|
921
|
+
function hasLiveProcessHandle(recordId) {
|
|
922
|
+
return hasLiveProcessHandleCore(recordId);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// src/execution/engine/inflight-snapshot.ts
|
|
926
|
+
var listener = null;
|
|
927
|
+
function getInFlightSnapshot() {
|
|
928
|
+
return { inFlight: countInFlight() };
|
|
929
|
+
}
|
|
930
|
+
function notifyInFlightChanged() {
|
|
931
|
+
if (listener === null) return;
|
|
932
|
+
try {
|
|
933
|
+
listener(getInFlightSnapshot());
|
|
934
|
+
} catch {
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
function countInFlight() {
|
|
938
|
+
let count = 0;
|
|
939
|
+
for (const entry of coreSpawnedChildrenMirror().snapshot()) {
|
|
940
|
+
const recordId = entry.recordId;
|
|
941
|
+
if (hasLiveProcessHandle(recordId) && !hasIdleTimer(recordId)) count++;
|
|
942
|
+
}
|
|
943
|
+
return count;
|
|
944
|
+
}
|
|
945
|
+
|
|
849
946
|
// src/execution/engine/client/engine-client.ts
|
|
850
|
-
var
|
|
947
|
+
var logger9 = (0, import_subagent_engine_sdk6.getLogger)("subagents");
|
|
948
|
+
function bridgeMirrorEventToCoreMirror(event, mirror) {
|
|
949
|
+
if (event.recordId === void 0 || event.pid === void 0) return;
|
|
950
|
+
const entry = mirror.getEntry(event.pid);
|
|
951
|
+
if (entry === void 0) return;
|
|
952
|
+
const core = coreSpawnedChildrenMirror();
|
|
953
|
+
if (entry.killed) {
|
|
954
|
+
core.markKilled(event.recordId);
|
|
955
|
+
} else {
|
|
956
|
+
core.register(event.recordId, { pid: entry.pid, killed: false });
|
|
957
|
+
}
|
|
958
|
+
notifyInFlightChanged();
|
|
959
|
+
}
|
|
851
960
|
var DISPOSE_GRACE_MS = 3e3;
|
|
852
961
|
var SIGKILL_REAP_TIMEOUT_MS = 1e4;
|
|
853
962
|
var FRAME_ECHO_MAX_CHARS = 200;
|
|
@@ -910,6 +1019,7 @@ var EngineClient = class {
|
|
|
910
1019
|
};
|
|
911
1020
|
this.mirror.onChange((event) => {
|
|
912
1021
|
opts.onMirrorChanged?.(event);
|
|
1022
|
+
bridgeMirrorEventToCoreMirror(event, this.mirror);
|
|
913
1023
|
});
|
|
914
1024
|
}
|
|
915
1025
|
get currentState() {
|
|
@@ -972,19 +1082,19 @@ var EngineClient = class {
|
|
|
972
1082
|
matchesEngineCmdline: this.opts.engineCmdlineMatcher ?? defaultEngineCmdlineMatcher(this.opts.command)
|
|
973
1083
|
});
|
|
974
1084
|
if (sweep.killed.length > 0) {
|
|
975
|
-
|
|
1085
|
+
logger9.warn(
|
|
976
1086
|
`[engine-client:${this.engineId}] startup sweep killed stale orphan engine pids: ${sweep.killed.join(",")}`
|
|
977
1087
|
);
|
|
978
1088
|
}
|
|
979
1089
|
for (const removed of sweep.removed) {
|
|
980
|
-
|
|
1090
|
+
logger9.debug(`[engine-client:${this.engineId}] swept stale pidfile ${removed.file}: ${removed.reason}`);
|
|
981
1091
|
}
|
|
982
1092
|
}
|
|
983
1093
|
let attempt = 0;
|
|
984
1094
|
while (attempt <= import_subagent_engine_sdk6.CRASH_REBUILD_MAX_ATTEMPTS) {
|
|
985
1095
|
if (attempt > 0) {
|
|
986
1096
|
const backoff = import_subagent_engine_sdk6.CRASH_REBUILD_BACKOFF_MS[attempt - 1];
|
|
987
|
-
|
|
1097
|
+
logger9.warn(
|
|
988
1098
|
`[engine-client:${this.engineId}] rebuild attempt ${attempt}/${import_subagent_engine_sdk6.CRASH_REBUILD_MAX_ATTEMPTS} after ${backoff}ms backoff`
|
|
989
1099
|
);
|
|
990
1100
|
await delay(backoff);
|
|
@@ -1017,7 +1127,7 @@ var EngineClient = class {
|
|
|
1017
1127
|
markUnavailable(reason) {
|
|
1018
1128
|
this.state = "unavailable";
|
|
1019
1129
|
this.unavailableReason = reason;
|
|
1020
|
-
|
|
1130
|
+
logger9.error(`[engine-client:${this.engineId}] marked unavailable: ${reason.message}`);
|
|
1021
1131
|
}
|
|
1022
1132
|
/** spawn 引擎 CLI + initialize 握手 + 版本协商 + 诊断留痕。 */
|
|
1023
1133
|
async spawnAndInitialize() {
|
|
@@ -1047,13 +1157,13 @@ var EngineClient = class {
|
|
|
1047
1157
|
});
|
|
1048
1158
|
const child = this.child;
|
|
1049
1159
|
child.on("error", (err) => {
|
|
1050
|
-
|
|
1160
|
+
logger9.warn(`[engine-client:${this.engineId}] spawn error: ${err.message}`);
|
|
1051
1161
|
this.appendStderrTail(`spawn error: ${err.message}
|
|
1052
1162
|
`);
|
|
1053
1163
|
});
|
|
1054
1164
|
for (const pipe of ["stdin", "stdout", "stderr"]) {
|
|
1055
1165
|
child[pipe]?.on("error", (err) => {
|
|
1056
|
-
|
|
1166
|
+
logger9.debug(`[engine-client:${this.engineId}] ${pipe} pipe error (engine died concurrently = expected): ${err.message}`);
|
|
1057
1167
|
});
|
|
1058
1168
|
}
|
|
1059
1169
|
child.stdout?.setEncoding("utf-8");
|
|
@@ -1122,7 +1232,7 @@ var EngineClient = class {
|
|
|
1122
1232
|
try {
|
|
1123
1233
|
frame = JSON.parse(line);
|
|
1124
1234
|
} catch {
|
|
1125
|
-
|
|
1235
|
+
logger9.warn(
|
|
1126
1236
|
`[engine-client:${this.engineId}] dropped non-NDJSON stdout line (protocol contract: stdout is NDJSON-only): ${truncate(line, FRAME_ECHO_MAX_CHARS)}`
|
|
1127
1237
|
);
|
|
1128
1238
|
return;
|
|
@@ -1139,7 +1249,7 @@ var EngineClient = class {
|
|
|
1139
1249
|
this.onReverseRequest(frame);
|
|
1140
1250
|
return;
|
|
1141
1251
|
}
|
|
1142
|
-
|
|
1252
|
+
logger9.warn(
|
|
1143
1253
|
`[engine-client:${this.engineId}] dropped unrecognized frame: ${truncate(line, FRAME_ECHO_MAX_CHARS)}`
|
|
1144
1254
|
);
|
|
1145
1255
|
}
|
|
@@ -1263,7 +1373,7 @@ var EngineClient = class {
|
|
|
1263
1373
|
try {
|
|
1264
1374
|
await this.request("dispose", {}, { timeoutMs: DISPOSE_GRACE_MS });
|
|
1265
1375
|
} catch (err) {
|
|
1266
|
-
|
|
1376
|
+
logger9.debug(
|
|
1267
1377
|
`[engine-client:${this.engineId}] dispose frame failed, falling back to kill chain: ${err instanceof Error ? err.message : String(err)}`
|
|
1268
1378
|
);
|
|
1269
1379
|
}
|
|
@@ -1275,9 +1385,9 @@ var EngineClient = class {
|
|
|
1275
1385
|
onEngineExit(code, signal) {
|
|
1276
1386
|
const detail = signal !== null ? `signal ${signal}` : `exit code ${code}`;
|
|
1277
1387
|
if (this.intentionalKill) {
|
|
1278
|
-
|
|
1388
|
+
logger9.debug(`[engine-client:${this.engineId}] engine exited after intentional kill (${detail}) \u2014 expected`);
|
|
1279
1389
|
} else {
|
|
1280
|
-
|
|
1390
|
+
logger9.warn(`[engine-client:${this.engineId}] engine process exited unexpectedly (${detail})`);
|
|
1281
1391
|
}
|
|
1282
1392
|
this.teardownProcess(detail);
|
|
1283
1393
|
this.state = "exited";
|
|
@@ -1326,7 +1436,7 @@ var EngineClient = class {
|
|
|
1326
1436
|
`);
|
|
1327
1437
|
return true;
|
|
1328
1438
|
} catch (err) {
|
|
1329
|
-
|
|
1439
|
+
logger9.debug(
|
|
1330
1440
|
`[engine-client:${this.engineId}] stdin write failed: ${err instanceof Error ? err.message : String(err)}`
|
|
1331
1441
|
);
|
|
1332
1442
|
return false;
|
|
@@ -1675,7 +1785,7 @@ function getHostUiRequestEndpoint() {
|
|
|
1675
1785
|
}
|
|
1676
1786
|
|
|
1677
1787
|
// src/execution/engine/engine-inspect-package.ts
|
|
1678
|
-
var
|
|
1788
|
+
var logger10 = getLogger("subagents");
|
|
1679
1789
|
function readEnginePackageJson(pkgDir) {
|
|
1680
1790
|
let raw;
|
|
1681
1791
|
try {
|
|
@@ -1754,12 +1864,12 @@ function parseOptionalDisplayFields(m, id) {
|
|
|
1754
1864
|
if (typeof rawDisplayName === "string" && rawDisplayName.trim() !== "") {
|
|
1755
1865
|
displayName = rawDisplayName;
|
|
1756
1866
|
} else {
|
|
1757
|
-
|
|
1867
|
+
logger10.warn(`[engine-discovery] engine '${id}': displayName must be a non-empty string \u2014 ignoring`);
|
|
1758
1868
|
}
|
|
1759
1869
|
}
|
|
1760
1870
|
const rawDescription = m["description"];
|
|
1761
1871
|
if (rawDescription !== void 0 && typeof rawDescription !== "string") {
|
|
1762
|
-
|
|
1872
|
+
logger10.warn(`[engine-discovery] engine '${id}': description must be a string \u2014 ignoring`);
|
|
1763
1873
|
}
|
|
1764
1874
|
return displayName;
|
|
1765
1875
|
}
|
|
@@ -1848,7 +1958,7 @@ function errorMessage(err) {
|
|
|
1848
1958
|
// src/execution/engine/engine-discovery-roots.ts
|
|
1849
1959
|
var fs2 = __toESM(require("fs"), 1);
|
|
1850
1960
|
var path3 = __toESM(require("path"), 1);
|
|
1851
|
-
var
|
|
1961
|
+
var logger11 = getLogger("subagents");
|
|
1852
1962
|
var ENGINE_ROOTS_ENV = "XYZ_AGENT_ENGINE_ROOTS";
|
|
1853
1963
|
function parseEngineRootsEnv(env) {
|
|
1854
1964
|
const raw = env[ENGINE_ROOTS_ENV];
|
|
@@ -1859,7 +1969,7 @@ function parseEngineRootsEnv(env) {
|
|
|
1859
1969
|
const dir = part.trim();
|
|
1860
1970
|
if (dir === "") continue;
|
|
1861
1971
|
if (!path3.isAbsolute(dir)) {
|
|
1862
|
-
|
|
1972
|
+
logger11.warn(
|
|
1863
1973
|
`[engine-discovery] ${ENGINE_ROOTS_ENV} entry '${dir}' is not an absolute path \u2014 dropping entry`
|
|
1864
1974
|
);
|
|
1865
1975
|
continue;
|
|
@@ -1928,7 +2038,7 @@ function isFile(p) {
|
|
|
1928
2038
|
// src/execution/engine/config.ts
|
|
1929
2039
|
var fs3 = __toESM(require("fs"), 1);
|
|
1930
2040
|
var path4 = __toESM(require("path"), 1);
|
|
1931
|
-
var
|
|
2041
|
+
var logger12 = getLogger("subagents");
|
|
1932
2042
|
function readExplicitEngines(agentDir) {
|
|
1933
2043
|
const configPath = path4.join(agentDir, "subagents", "config.json");
|
|
1934
2044
|
let parsed;
|
|
@@ -1941,7 +2051,7 @@ function readExplicitEngines(agentDir) {
|
|
|
1941
2051
|
const engines = parsed["engines"];
|
|
1942
2052
|
if (typeof engines !== "object" || engines === null || Array.isArray(engines)) {
|
|
1943
2053
|
if (engines !== void 0) {
|
|
1944
|
-
|
|
2054
|
+
logger12.warn(
|
|
1945
2055
|
`[engine-discovery] config.json engines section must be an object keyed by engine id, got ${jsonKindOf(engines)} \u2014 ignoring L3 explicit engines`
|
|
1946
2056
|
);
|
|
1947
2057
|
}
|
|
@@ -1969,7 +2079,7 @@ function sanitizeExplicitEntry(id, raw) {
|
|
|
1969
2079
|
}
|
|
1970
2080
|
function requireEntryObject(id, raw) {
|
|
1971
2081
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
1972
|
-
|
|
2082
|
+
logger12.warn(
|
|
1973
2083
|
`[engine-discovery] config.json engines.${id} must be an object, got ${jsonKindOf(raw)} \u2014 skipping entry`
|
|
1974
2084
|
);
|
|
1975
2085
|
return void 0;
|
|
@@ -1978,7 +2088,7 @@ function requireEntryObject(id, raw) {
|
|
|
1978
2088
|
}
|
|
1979
2089
|
function requireCommand(id, command) {
|
|
1980
2090
|
if (typeof command !== "string" || command.trim() === "") {
|
|
1981
|
-
|
|
2091
|
+
logger12.warn(
|
|
1982
2092
|
`[engine-discovery] config.json engines.${id}.command is required (non-empty string) \u2014 skipping entry`
|
|
1983
2093
|
);
|
|
1984
2094
|
return void 0;
|
|
@@ -1987,7 +2097,7 @@ function requireCommand(id, command) {
|
|
|
1987
2097
|
}
|
|
1988
2098
|
function normalizeArgs(id, args) {
|
|
1989
2099
|
if (args !== void 0 && !isStringArray(args)) {
|
|
1990
|
-
|
|
2100
|
+
logger12.warn(
|
|
1991
2101
|
`[engine-discovery] config.json engines.${id}.args must be a string array \u2014 ignoring args`
|
|
1992
2102
|
);
|
|
1993
2103
|
}
|
|
@@ -1995,7 +2105,7 @@ function normalizeArgs(id, args) {
|
|
|
1995
2105
|
}
|
|
1996
2106
|
function normalizeConfig(id, config) {
|
|
1997
2107
|
if (config !== void 0 && !isStringRecord(config)) {
|
|
1998
|
-
|
|
2108
|
+
logger12.warn(
|
|
1999
2109
|
`[engine-discovery] config.json engines.${id}.config must be a Record<string, string> \u2014 ignoring config`
|
|
2000
2110
|
);
|
|
2001
2111
|
}
|
|
@@ -2003,7 +2113,7 @@ function normalizeConfig(id, config) {
|
|
|
2003
2113
|
}
|
|
2004
2114
|
function normalizeCwd(id, cwd) {
|
|
2005
2115
|
if (cwd !== void 0 && typeof cwd !== "string") {
|
|
2006
|
-
|
|
2116
|
+
logger12.warn(
|
|
2007
2117
|
`[engine-discovery] config.json engines.${id}.cwd must be a string \u2014 ignoring cwd`
|
|
2008
2118
|
);
|
|
2009
2119
|
}
|
|
@@ -2023,7 +2133,7 @@ function jsonKindOf(value) {
|
|
|
2023
2133
|
}
|
|
2024
2134
|
|
|
2025
2135
|
// src/execution/engine/registry.ts
|
|
2026
|
-
var
|
|
2136
|
+
var logger13 = getLogger("subagents");
|
|
2027
2137
|
var ENGINE_REGISTRY_SLOT_KEY = /* @__PURE__ */ Symbol.for("@zhushanwen/pi-subagent-workflow.engineRegistry");
|
|
2028
2138
|
function getRegistrySlot() {
|
|
2029
2139
|
let slot = Reflect.get(globalThis, ENGINE_REGISTRY_SLOT_KEY);
|
|
@@ -2037,12 +2147,12 @@ function triggerEngineDispose(engine, source) {
|
|
|
2037
2147
|
if (typeof engine.dispose !== "function") return;
|
|
2038
2148
|
try {
|
|
2039
2149
|
engine.dispose().then(void 0, (err) => {
|
|
2040
|
-
|
|
2150
|
+
logger13.warn(
|
|
2041
2151
|
`[engine-registry] engine '${engine.id}' dispose rejected (${source}, best-effort continue): ${err instanceof Error ? err.message : String(err)}`
|
|
2042
2152
|
);
|
|
2043
2153
|
});
|
|
2044
2154
|
} catch (err) {
|
|
2045
|
-
|
|
2155
|
+
logger13.warn(
|
|
2046
2156
|
`[engine-registry] engine '${engine.id}' dispose threw synchronously (${source}, best-effort continue): ${err instanceof Error ? err.message : String(err)}`
|
|
2047
2157
|
);
|
|
2048
2158
|
}
|
|
@@ -2059,14 +2169,14 @@ function hasEngine(id) {
|
|
|
2059
2169
|
}
|
|
2060
2170
|
|
|
2061
2171
|
// src/execution/engine/engine-discovery-scan.ts
|
|
2062
|
-
var
|
|
2172
|
+
var logger14 = getLogger("subagents");
|
|
2063
2173
|
function scanEngines(opts) {
|
|
2064
2174
|
const env = opts.env ?? process.env;
|
|
2065
2175
|
const result = { discovered: [], skipped: [], unusable: [] };
|
|
2066
2176
|
const present = (entry) => {
|
|
2067
2177
|
const idx = result.discovered.findIndex((d) => d.id === entry.id);
|
|
2068
2178
|
if (idx >= 0) {
|
|
2069
|
-
|
|
2179
|
+
logger14.debug(
|
|
2070
2180
|
`[engine-discovery] engine id '${entry.id}' from '${entry.source}' overrides earlier discovery from '${result.discovered[idx].source}' \u2014 same-id override`
|
|
2071
2181
|
);
|
|
2072
2182
|
result.discovered[idx] = entry;
|
|
@@ -2078,13 +2188,13 @@ function scanEngines(opts) {
|
|
|
2078
2188
|
const inspection = inspectEnginePackage(pkgDir, source, opts.hostKind, env);
|
|
2079
2189
|
if (inspection.status === "skip") {
|
|
2080
2190
|
if (!inspection.reason.includes("not an engine package")) {
|
|
2081
|
-
|
|
2191
|
+
logger14.warn(`[engine-discovery] skipping ${pkgDir} (${source}): ${inspection.reason}`);
|
|
2082
2192
|
result.skipped.push({ pkgDir, reason: inspection.reason });
|
|
2083
2193
|
}
|
|
2084
2194
|
return;
|
|
2085
2195
|
}
|
|
2086
2196
|
if (inspection.status === "unusable") {
|
|
2087
|
-
|
|
2197
|
+
logger14.warn(`[engine-discovery] engine unavailable: ${inspection.reason}`);
|
|
2088
2198
|
result.unusable.push({ pkgDir, id: inspection.id, reason: inspection.reason });
|
|
2089
2199
|
return;
|
|
2090
2200
|
}
|
|
@@ -2109,7 +2219,7 @@ function scanEngines(opts) {
|
|
|
2109
2219
|
const command = resolveExplicitCommand(entry.command, env);
|
|
2110
2220
|
if (command === void 0) {
|
|
2111
2221
|
const reason = `engine '${id}' (config.json engines.${id}): command '${entry.command}' not found or not executable`;
|
|
2112
|
-
|
|
2222
|
+
logger14.warn(`[engine-discovery] ${reason} \u2014 not registering`);
|
|
2113
2223
|
result.unusable.push({ pkgDir: `config.json engines.${id}`, id, reason });
|
|
2114
2224
|
continue;
|
|
2115
2225
|
}
|
|
@@ -2126,7 +2236,7 @@ function discoverAndRegisterEngines(opts) {
|
|
|
2126
2236
|
registerEngineDescriptor(entry.id, entry.descriptor);
|
|
2127
2237
|
loadedDiscoveryIdSet.add(entry.id);
|
|
2128
2238
|
if (existed) {
|
|
2129
|
-
|
|
2239
|
+
logger14.debug(
|
|
2130
2240
|
`[engine-discovery] engine '${entry.id}' descriptor overwritten in registry (source '${entry.source}') \u2014 same-id override`
|
|
2131
2241
|
);
|
|
2132
2242
|
}
|
|
@@ -2156,7 +2266,7 @@ function resolveExplicitCommand(command, env) {
|
|
|
2156
2266
|
}
|
|
2157
2267
|
function buildExplicitDescriptor(id, command, entry, opts) {
|
|
2158
2268
|
const env = opts.env ?? process.env;
|
|
2159
|
-
|
|
2269
|
+
logger14.debug(
|
|
2160
2270
|
`[engine-discovery] engine '${id}' registered from config.json engines section with conservative capabilities (no manifest)`
|
|
2161
2271
|
);
|
|
2162
2272
|
const caps = { ...CONSERVATIVE_CAPABILITIES };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DiscoverEnginesOptions, a4 as DiscoveredEngine, a5 as DiscoveryScanResult, a6 as ENGINE_ROOTS_ENV, a7 as PackageInspection, a8 as deriveNodeModuleRoots, a9 as discoverAndRegisterEngines, aa as ensureEngineDiscovered, ab as inspectEnginePackage, ac as loadedDiscoveryIds, ad as parseEngineRootsEnv, ae as scanEngines } from '../../engine-discovery-scan-
|
|
1
|
+
export { D as DiscoverEnginesOptions, a4 as DiscoveredEngine, a5 as DiscoveryScanResult, a6 as ENGINE_ROOTS_ENV, a7 as PackageInspection, a8 as deriveNodeModuleRoots, a9 as discoverAndRegisterEngines, aa as ensureEngineDiscovered, ab as inspectEnginePackage, ac as loadedDiscoveryIds, ad as parseEngineRootsEnv, ae as scanEngines } from '../../engine-discovery-scan-BXLA8y-z.cjs';
|
|
2
2
|
import '@zhushanwen/subagent-engine-sdk';
|
|
3
3
|
import 'node:child_process';
|
|
4
4
|
import '@xyz-agent/extension-protocol';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DiscoverEnginesOptions, a4 as DiscoveredEngine, a5 as DiscoveryScanResult, a6 as ENGINE_ROOTS_ENV, a7 as PackageInspection, a8 as deriveNodeModuleRoots, a9 as discoverAndRegisterEngines, aa as ensureEngineDiscovered, ab as inspectEnginePackage, ac as loadedDiscoveryIds, ad as parseEngineRootsEnv, ae as scanEngines } from '../../engine-discovery-scan-
|
|
1
|
+
export { D as DiscoverEnginesOptions, a4 as DiscoveredEngine, a5 as DiscoveryScanResult, a6 as ENGINE_ROOTS_ENV, a7 as PackageInspection, a8 as deriveNodeModuleRoots, a9 as discoverAndRegisterEngines, aa as ensureEngineDiscovered, ab as inspectEnginePackage, ac as loadedDiscoveryIds, ad as parseEngineRootsEnv, ae as scanEngines } from '../../engine-discovery-scan-BXLA8y-z.js';
|
|
2
2
|
import '@zhushanwen/subagent-engine-sdk';
|
|
3
3
|
import 'node:child_process';
|
|
4
4
|
import '@xyz-agent/extension-protocol';
|