@ycodium-ai/plugin-api 0.2.3000 → 0.2.3002
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/executor.d.ts +15 -767
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +5 -129
- package/dist/executor.js.map +1 -1
- package/dist/executorCard.d.ts +279 -0
- package/dist/executorCard.d.ts.map +1 -0
- package/dist/executorCard.js +48 -0
- package/dist/executorCard.js.map +1 -0
- package/dist/executorEvents.d.ts +170 -0
- package/dist/executorEvents.d.ts.map +1 -0
- package/dist/executorEvents.js +8 -0
- package/dist/executorEvents.js.map +1 -0
- package/dist/executorSession.d.ts +301 -0
- package/dist/executorSession.d.ts.map +1 -0
- package/dist/executorSession.js +3 -0
- package/dist/executorSession.js.map +1 -0
- package/dist/executorSpawn.d.ts +48 -0
- package/dist/executorSpawn.d.ts.map +1 -0
- package/dist/executorSpawn.js +87 -0
- package/dist/executorSpawn.js.map +1 -0
- package/dist/index.d.ts +11 -608
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pluginContextCommands.d.ts +152 -0
- package/dist/pluginContextCommands.d.ts.map +1 -0
- package/dist/pluginContextCommands.js +2 -0
- package/dist/pluginContextCommands.js.map +1 -0
- package/dist/pluginContextProviders.d.ts +203 -0
- package/dist/pluginContextProviders.d.ts.map +1 -0
- package/dist/pluginContextProviders.js +2 -0
- package/dist/pluginContextProviders.js.map +1 -0
- package/dist/pluginContextThreads.d.ts +206 -0
- package/dist/pluginContextThreads.d.ts.map +1 -0
- package/dist/pluginContextThreads.js +2 -0
- package/dist/pluginContextThreads.js.map +1 -0
- package/dist/pluginContextWorkspace.d.ts +76 -0
- package/dist/pluginContextWorkspace.d.ts.map +1 -0
- package/dist/pluginContextWorkspace.js +2 -0
- package/dist/pluginContextWorkspace.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 起进程失败:实例进程满额时的拒绝,以及按 errno 把启动错误折成探测结论。
|
|
3
|
+
* 公开名字从 executor.ts 再导出。
|
|
4
|
+
*
|
|
5
|
+
* @module @ycodium-ai/plugin-api/executorSpawn
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* 宿主拒绝起进程:这个实例同时活着的子进程已到上限(名片 `maxConcurrentProcesses`,缺省 8),
|
|
9
|
+
* 超出当场拒绝,不排队。
|
|
10
|
+
*
|
|
11
|
+
* 与「程序起不来」是两件事:程序这次没被执行,装没装、跑不跑得起来都答不了。所以探测遇到它
|
|
12
|
+
* 必须原样抛出,不许折成没装、`error` 或 `unchecked`;宿主刷新快照时认出它,保留上一份快照。
|
|
13
|
+
* `--version` 这类可有可无的辅助进程被拒,只让那一项缺席。
|
|
14
|
+
*
|
|
15
|
+
* 只按类型认,不看 message。插件构建须把本包留作 external:运行时由宿主解析到它自己那一份,
|
|
16
|
+
* 插件与宿主拿到的才是同一个类;打进插件包的副本认不出宿主抛的这一个。
|
|
17
|
+
*/
|
|
18
|
+
export class ExecutorSpawnRefusedError extends Error {
|
|
19
|
+
name = "ExecutorSpawnRefusedError";
|
|
20
|
+
/** 拒绝那一刻的上限。 */
|
|
21
|
+
maxProcesses;
|
|
22
|
+
constructor(input) {
|
|
23
|
+
super(`executor '${input.driverKind}' refused spawn: ${String(input.maxProcesses)} live processes`);
|
|
24
|
+
this.maxProcesses = input.maxProcesses;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const SPAWN_NOT_FOUND_CODES = new Set(["ENOENT", "ENOTDIR"]);
|
|
28
|
+
const SPAWN_NOT_EXECUTABLE_CODES = new Set([
|
|
29
|
+
"EACCES",
|
|
30
|
+
"EPERM",
|
|
31
|
+
"ENOEXEC",
|
|
32
|
+
"EFTYPE",
|
|
33
|
+
]);
|
|
34
|
+
/** 沿 `cause` 链往下找的深度上限;环或畸形链不会拖死探测。 */
|
|
35
|
+
const SPAWN_ERROR_CHAIN_DEPTH = 6;
|
|
36
|
+
const spawnErrorChain = (error) => {
|
|
37
|
+
const chain = [];
|
|
38
|
+
let current = error;
|
|
39
|
+
while (chain.length < SPAWN_ERROR_CHAIN_DEPTH &&
|
|
40
|
+
typeof current === "object" &&
|
|
41
|
+
current !== null &&
|
|
42
|
+
!chain.includes(current)) {
|
|
43
|
+
chain.push(current);
|
|
44
|
+
current = current.cause;
|
|
45
|
+
}
|
|
46
|
+
return chain;
|
|
47
|
+
};
|
|
48
|
+
const spawnErrorCode = (error) => {
|
|
49
|
+
for (const link of spawnErrorChain(error)) {
|
|
50
|
+
const code = link["code"];
|
|
51
|
+
if (typeof code === "string")
|
|
52
|
+
return code;
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* 这个错误是不是「起进程失败」:错误链上带 Node 的 errno `code`,或是宿主起进程那层的
|
|
58
|
+
* `ProcessSpawnError` 标签。宿主据此把没接住的起进程失败折成快照,别的错照旧是缺陷。
|
|
59
|
+
* 按属性认,不用 instanceof:插件各自打包,类不是宿主那一份。
|
|
60
|
+
*/
|
|
61
|
+
export const isExecutorSpawnFailure = (error) => spawnErrorCode(error) !== undefined ||
|
|
62
|
+
spawnErrorChain(error).some((link) => link["_tag"] === "ProcessSpawnError");
|
|
63
|
+
/**
|
|
64
|
+
* 把 `host.process.spawn` 抛出的失败折成探测结论:ENOENT / ENOTDIR(找不到)与
|
|
65
|
+
* EACCES 一类(不可执行)是 `not-installed`,其余启动失败是 `error`。
|
|
66
|
+
*
|
|
67
|
+
* 调用点已知这是起进程失败时用它;宿主进程满额拒绝({@link ExecutorSpawnRefusedError})
|
|
68
|
+
* 不是起不来,调用方要先把它原样抛出,不要交给这里。
|
|
69
|
+
*/
|
|
70
|
+
export const describeExecutorSpawnFailure = (error) => {
|
|
71
|
+
const chain = spawnErrorChain(error);
|
|
72
|
+
const code = spawnErrorCode(error);
|
|
73
|
+
const messages = chain.flatMap((link) => {
|
|
74
|
+
const message = link["message"];
|
|
75
|
+
return typeof message === "string" && message.trim().length > 0 ? [message.trim()] : [];
|
|
76
|
+
});
|
|
77
|
+
const root = messages.at(-1) ?? (typeof error === "string" ? error.trim() : "");
|
|
78
|
+
if (code !== undefined &&
|
|
79
|
+
(SPAWN_NOT_FOUND_CODES.has(code) || SPAWN_NOT_EXECUTABLE_CODES.has(code))) {
|
|
80
|
+
return { readiness: "not-installed", detail: root.length > 0 ? root : code };
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
readiness: "error",
|
|
84
|
+
detail: `The program could not be started${root.length > 0 ? `: ${root}` : "."}`,
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=executorSpawn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executorSpawn.js","sourceRoot":"","sources":["../src/executorSpawn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAChC,IAAI,GAAG,2BAA2B,CAAC;IACrD,gBAAgB;IACP,YAAY,CAAS;IAE9B,YAAY,KAAqE;QAC/E,KAAK,CACH,aAAa,KAAK,CAAC,UAAU,oBAAoB,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAC7F,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;IACzC,CAAC;CACF;AAUD,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAClF,MAAM,0BAA0B,GAAwB,IAAI,GAAG,CAAC;IAC9D,QAAQ;IACR,OAAO;IACP,SAAS;IACT,QAAQ;CACT,CAAC,CAAC;AACH,uCAAuC;AACvC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAElC,MAAM,eAAe,GAAG,CAAC,KAAc,EAA0C,EAAE;IACjF,MAAM,KAAK,GAAmC,EA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