lemma-agent 1.0.1 → 1.1.1
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/README.md +29 -0
- package/dist/account-discovery.js +159 -0
- package/dist/admin.js +20 -1
- package/dist/api-member.js +18 -5
- package/dist/app.js +45 -6
- package/dist/bridge.js +341 -0
- package/dist/config.js +157 -0
- package/dist/credentials.js +11 -0
- package/dist/dispatch.js +37 -23
- package/dist/main.js +34 -1
- package/dist/proxy.js +1251 -0
- package/dist/redact.js +185 -0
- package/dist/tools.js +2 -2
- package/package.json +3 -2
- package/web/js/views.js +40 -0
package/dist/main.js
CHANGED
|
@@ -11,6 +11,7 @@ import { Writable } from "node:stream";
|
|
|
11
11
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
12
12
|
import { LiveDoc } from "@earendil-works/pi-durable";
|
|
13
13
|
import { startAdmin } from "./admin.js";
|
|
14
|
+
import { startProxyServer } from "./proxy.js";
|
|
14
15
|
import { Board, boardTasks, STATUS_LABEL } from "./board.js";
|
|
15
16
|
import { applyChange, cleanChanges, dropChange, pendingChanges } from "./change-ops.js";
|
|
16
17
|
import { initRules, scanConventions, syncRules } from "./conventions.js";
|
|
@@ -129,6 +130,8 @@ export async function startMain(overrides) {
|
|
|
129
130
|
/** 终端在等你输入(没有在等总调度回答) */
|
|
130
131
|
let replIdle = () => false;
|
|
131
132
|
let admin;
|
|
133
|
+
let proxyServer;
|
|
134
|
+
let proxyOwner;
|
|
132
135
|
let webPort;
|
|
133
136
|
let closing = false;
|
|
134
137
|
let switchingSession = false;
|
|
@@ -203,9 +206,37 @@ export async function startMain(overrides) {
|
|
|
203
206
|
busy: live?.run !== undefined, runningJobs: Object.values(jobs?.jobs ?? {}).filter((j) => j.status === "running").length };
|
|
204
207
|
}));
|
|
205
208
|
}
|
|
209
|
+
async function ensureProxyServer() {
|
|
210
|
+
if (admin) {
|
|
211
|
+
await proxyServer?.close().catch(() => { });
|
|
212
|
+
proxyServer = undefined;
|
|
213
|
+
proxyOwner = undefined;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (!config.proxy?.enabled) {
|
|
217
|
+
await proxyServer?.close().catch(() => { });
|
|
218
|
+
proxyServer = undefined;
|
|
219
|
+
proxyOwner = undefined;
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (proxyServer && proxyOwner === app)
|
|
223
|
+
return;
|
|
224
|
+
await proxyServer?.close().catch(() => { });
|
|
225
|
+
const port = webPort ?? Number(process.env.PI_AGENT_PORT ?? config.web.port);
|
|
226
|
+
proxyServer = await startProxyServer(app.proxy, port).catch((error) => {
|
|
227
|
+
log(c.red(`本地代理没能启动:${error.message}(将按直连方式运行)`));
|
|
228
|
+
return undefined;
|
|
229
|
+
});
|
|
230
|
+
proxyOwner = proxyServer ? app : undefined;
|
|
231
|
+
}
|
|
206
232
|
async function startWeb() {
|
|
207
|
-
if (!config.web.enabled || flags.has("--no-web"))
|
|
233
|
+
if (!config.web.enabled || flags.has("--no-web")) {
|
|
234
|
+
await ensureProxyServer();
|
|
208
235
|
return;
|
|
236
|
+
}
|
|
237
|
+
await proxyServer?.close().catch(() => { });
|
|
238
|
+
proxyServer = undefined;
|
|
239
|
+
proxyOwner = undefined;
|
|
209
240
|
const port = webPort ?? Number(process.env.PI_AGENT_PORT ?? config.web.port);
|
|
210
241
|
const options = {
|
|
211
242
|
app, config, configPath, orchestrator, port, context,
|
|
@@ -367,6 +398,7 @@ export async function startMain(overrides) {
|
|
|
367
398
|
// readline 可能正在同步分发同一批粘贴进来的多行,推迟到分发完再关
|
|
368
399
|
setImmediate(() => rl?.close());
|
|
369
400
|
await admin?.close().catch(() => { });
|
|
401
|
+
await proxyServer?.close().catch(() => { });
|
|
370
402
|
await stopFollowing().catch(() => { });
|
|
371
403
|
// 关闭时被打断的后台派工不收尾,下次启动续接它的会话接着做
|
|
372
404
|
await Promise.allSettled([...sessions.values()].map((runtime) => runtime.app.harness.close(context)));
|
|
@@ -1427,6 +1459,7 @@ export async function startMain(overrides) {
|
|
|
1427
1459
|
.join(" ")
|
|
1428
1460
|
.trim();
|
|
1429
1461
|
if (oneShot) {
|
|
1462
|
+
await ensureProxyServer();
|
|
1430
1463
|
stopFollowing = await follow(root, context);
|
|
1431
1464
|
harness.resume(); // 上次进程中断时没跑完的任务,从断点继续
|
|
1432
1465
|
await printBanner();
|