ai-project-manage-cli 8.1.10 → 8.1.11
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 +62 -1
- package/dist/worker-script.js +53 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1203,6 +1203,25 @@ function validateCancel(o) {
|
|
|
1203
1203
|
data: { type: "cancel", messageId: o.messageId.trim() }
|
|
1204
1204
|
};
|
|
1205
1205
|
}
|
|
1206
|
+
function validateSteer(o) {
|
|
1207
|
+
if (o.type !== "steer") {
|
|
1208
|
+
return { ok: false, reason: "\u671F\u671B steer" };
|
|
1209
|
+
}
|
|
1210
|
+
if (!nonEmptyString(o.messageId)) {
|
|
1211
|
+
return { ok: false, reason: "steer \u7F3A\u5C11 messageId" };
|
|
1212
|
+
}
|
|
1213
|
+
if (!nonEmptyString(o.text)) {
|
|
1214
|
+
return { ok: false, reason: "steer \u7F3A\u5C11 text" };
|
|
1215
|
+
}
|
|
1216
|
+
return {
|
|
1217
|
+
ok: true,
|
|
1218
|
+
data: {
|
|
1219
|
+
type: "steer",
|
|
1220
|
+
messageId: o.messageId.trim(),
|
|
1221
|
+
text: o.text.trim()
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1206
1225
|
function validateWebIdeStopTerminals(o) {
|
|
1207
1226
|
if (o.type !== "webide-stop-terminals") {
|
|
1208
1227
|
return { ok: false, reason: "\u671F\u671B webide-stop-terminals" };
|
|
@@ -1319,7 +1338,7 @@ function validateAgentWsMessage(value, kind) {
|
|
|
1319
1338
|
}
|
|
1320
1339
|
const o = value;
|
|
1321
1340
|
const type = o.type;
|
|
1322
|
-
if (type !== "heartbeat" && type !== "webide-message" && type !== "cancel" && type !== "webide-start-project" && type !== "webide-stop-terminals" && type !== "webide-package") {
|
|
1341
|
+
if (type !== "heartbeat" && type !== "webide-message" && type !== "cancel" && type !== "steer" && type !== "webide-start-project" && type !== "webide-stop-terminals" && type !== "webide-package") {
|
|
1323
1342
|
return { ok: false, reason: `\u672A\u77E5 type: ${String(type)}` };
|
|
1324
1343
|
}
|
|
1325
1344
|
if (kind === "heartbeat" || type === "heartbeat") {
|
|
@@ -1328,6 +1347,9 @@ function validateAgentWsMessage(value, kind) {
|
|
|
1328
1347
|
if (type === "cancel") {
|
|
1329
1348
|
return validateCancel(o);
|
|
1330
1349
|
}
|
|
1350
|
+
if (type === "steer") {
|
|
1351
|
+
return validateSteer(o);
|
|
1352
|
+
}
|
|
1331
1353
|
if (type === "webide-start-project") {
|
|
1332
1354
|
return validateWebIdeStartProjectPush(o);
|
|
1333
1355
|
}
|
|
@@ -1347,6 +1369,29 @@ function handleCancelAction(payload, ctx) {
|
|
|
1347
1369
|
ctx.activeRuns.get(messageId)?.abort();
|
|
1348
1370
|
}
|
|
1349
1371
|
|
|
1372
|
+
// src/commands/connect/actions/steer.ts
|
|
1373
|
+
function registerRunSteer(ctx, messageId, target) {
|
|
1374
|
+
const send = (text) => target.steer(messageId, text);
|
|
1375
|
+
ctx.steerRuns.set(messageId, send);
|
|
1376
|
+
const queued = ctx.pendingSteers.get(messageId);
|
|
1377
|
+
if (!queued) return;
|
|
1378
|
+
ctx.pendingSteers.delete(messageId);
|
|
1379
|
+
send(queued);
|
|
1380
|
+
}
|
|
1381
|
+
function unregisterRunSteer(ctx, messageId) {
|
|
1382
|
+
ctx.steerRuns.delete(messageId);
|
|
1383
|
+
ctx.pendingSteers.delete(messageId);
|
|
1384
|
+
}
|
|
1385
|
+
function handleSteerAction(payload, ctx) {
|
|
1386
|
+
const send = ctx.steerRuns.get(payload.messageId);
|
|
1387
|
+
if (!send) {
|
|
1388
|
+
ctx.pendingSteers.set(payload.messageId, payload.text);
|
|
1389
|
+
console.log(`[apm] steer \u5DF2\u6392\u961F messageId=${payload.messageId}`);
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
send(payload.text);
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1350
1395
|
// src/commands/connect/core/worker/worker.ts
|
|
1351
1396
|
import { dirname as dirname3, join as join7 } from "path";
|
|
1352
1397
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -1473,6 +1518,9 @@ var ActionWorker = class {
|
|
|
1473
1518
|
cancel(msg_id) {
|
|
1474
1519
|
this.worker.postMessage({ type: "cancel", messageId: msg_id });
|
|
1475
1520
|
}
|
|
1521
|
+
steer(msg_id, text) {
|
|
1522
|
+
this.worker.postMessage({ type: "steer", messageId: msg_id, text });
|
|
1523
|
+
}
|
|
1476
1524
|
get done() {
|
|
1477
1525
|
return this.promise;
|
|
1478
1526
|
}
|
|
@@ -1512,6 +1560,7 @@ function handleWebIdeMessageAction(payload, ctx) {
|
|
|
1512
1560
|
}
|
|
1513
1561
|
const task = (async () => {
|
|
1514
1562
|
const handle = new ActionWorker(payload);
|
|
1563
|
+
registerRunSteer(ctx, payload.messageId, handle);
|
|
1515
1564
|
const onAbort = () => handle.cancel(payload.messageId);
|
|
1516
1565
|
perMessageController.signal.addEventListener("abort", onAbort, {
|
|
1517
1566
|
once: true
|
|
@@ -1520,6 +1569,7 @@ function handleWebIdeMessageAction(payload, ctx) {
|
|
|
1520
1569
|
await handle.done;
|
|
1521
1570
|
} finally {
|
|
1522
1571
|
perMessageController.signal.removeEventListener("abort", onAbort);
|
|
1572
|
+
unregisterRunSteer(ctx, payload.messageId);
|
|
1523
1573
|
ctx.activeRuns.delete(payload.messageId);
|
|
1524
1574
|
}
|
|
1525
1575
|
})();
|
|
@@ -1552,6 +1602,7 @@ function handleStartProjectAction(payload, ctx) {
|
|
|
1552
1602
|
}
|
|
1553
1603
|
const task = (async () => {
|
|
1554
1604
|
const handle = new ActionWorker(payload);
|
|
1605
|
+
registerRunSteer(ctx, payload.messageId, handle);
|
|
1555
1606
|
const onAbort = () => handle.cancel(payload.messageId);
|
|
1556
1607
|
perMessageController.signal.addEventListener("abort", onAbort, {
|
|
1557
1608
|
once: true
|
|
@@ -1560,6 +1611,7 @@ function handleStartProjectAction(payload, ctx) {
|
|
|
1560
1611
|
await handle.done;
|
|
1561
1612
|
} finally {
|
|
1562
1613
|
perMessageController.signal.removeEventListener("abort", onAbort);
|
|
1614
|
+
unregisterRunSteer(ctx, payload.messageId);
|
|
1563
1615
|
ctx.activeRuns.delete(payload.messageId);
|
|
1564
1616
|
}
|
|
1565
1617
|
})();
|
|
@@ -1688,6 +1740,7 @@ function handleWebIdePackageAction(payload, ctx) {
|
|
|
1688
1740
|
}
|
|
1689
1741
|
const task = (async () => {
|
|
1690
1742
|
const handle = new ActionWorker(payload);
|
|
1743
|
+
registerRunSteer(ctx, payload.messageId, handle);
|
|
1691
1744
|
const onAbort = () => handle.cancel(payload.messageId);
|
|
1692
1745
|
perMessageController.signal.addEventListener("abort", onAbort, {
|
|
1693
1746
|
once: true
|
|
@@ -1696,6 +1749,7 @@ function handleWebIdePackageAction(payload, ctx) {
|
|
|
1696
1749
|
await handle.done;
|
|
1697
1750
|
} finally {
|
|
1698
1751
|
perMessageController.signal.removeEventListener("abort", onAbort);
|
|
1752
|
+
unregisterRunSteer(ctx, payload.messageId);
|
|
1699
1753
|
ctx.activeRuns.delete(payload.messageId);
|
|
1700
1754
|
}
|
|
1701
1755
|
})();
|
|
@@ -1710,6 +1764,9 @@ function dispatchConnectAction(payload, ctx) {
|
|
|
1710
1764
|
case "cancel":
|
|
1711
1765
|
handleCancelAction(payload, ctx);
|
|
1712
1766
|
return;
|
|
1767
|
+
case "steer":
|
|
1768
|
+
handleSteerAction(payload, ctx);
|
|
1769
|
+
return;
|
|
1713
1770
|
case "webide-message":
|
|
1714
1771
|
handleWebIdeMessageAction(payload, ctx);
|
|
1715
1772
|
return;
|
|
@@ -1934,6 +1991,8 @@ async function runConnect(options) {
|
|
|
1934
1991
|
const activeTasks = /* @__PURE__ */ new Set();
|
|
1935
1992
|
const activeRuns = /* @__PURE__ */ new Map();
|
|
1936
1993
|
const pendingCancels = /* @__PURE__ */ new Set();
|
|
1994
|
+
const steerRuns = /* @__PURE__ */ new Map();
|
|
1995
|
+
const pendingSteers = /* @__PURE__ */ new Map();
|
|
1937
1996
|
let currentConnectionAbort = null;
|
|
1938
1997
|
const connectCtx = {
|
|
1939
1998
|
cfg,
|
|
@@ -1941,6 +2000,8 @@ async function runConnect(options) {
|
|
|
1941
2000
|
activeTasks,
|
|
1942
2001
|
activeRuns,
|
|
1943
2002
|
pendingCancels,
|
|
2003
|
+
steerRuns,
|
|
2004
|
+
pendingSteers,
|
|
1944
2005
|
isShuttingDown: () => shuttingDown
|
|
1945
2006
|
};
|
|
1946
2007
|
const drainAndExit = async (code = 0) => {
|
package/dist/worker-script.js
CHANGED
|
@@ -2783,6 +2783,30 @@ function createRemoteLocalAgentStore(cfg2) {
|
|
|
2783
2783
|
};
|
|
2784
2784
|
}
|
|
2785
2785
|
|
|
2786
|
+
// src/commands/connect/core/worker/run-steer.ts
|
|
2787
|
+
var impl = null;
|
|
2788
|
+
var pending = null;
|
|
2789
|
+
function bindRunSteer(fn) {
|
|
2790
|
+
impl = fn;
|
|
2791
|
+
if (!pending) return;
|
|
2792
|
+
const text = pending;
|
|
2793
|
+
pending = null;
|
|
2794
|
+
void fn(text);
|
|
2795
|
+
}
|
|
2796
|
+
function clearRunSteer() {
|
|
2797
|
+
impl = null;
|
|
2798
|
+
pending = null;
|
|
2799
|
+
}
|
|
2800
|
+
function deliverRunSteer(text) {
|
|
2801
|
+
const trimmed = text.trim();
|
|
2802
|
+
if (!trimmed) return;
|
|
2803
|
+
if (impl) {
|
|
2804
|
+
void impl(trimmed);
|
|
2805
|
+
return;
|
|
2806
|
+
}
|
|
2807
|
+
pending = trimmed;
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2786
2810
|
// src/commands/connect/cursor-agent.ts
|
|
2787
2811
|
var noopRemoteLogSync = {
|
|
2788
2812
|
schedule(_session) {
|
|
@@ -2914,6 +2938,22 @@ async function runCursorAgent(cfg2, ctx, options) {
|
|
|
2914
2938
|
});
|
|
2915
2939
|
activeRun = run;
|
|
2916
2940
|
console.log(`[apm] Cursor run id=${run.id} agentId=${agent.agentId}`);
|
|
2941
|
+
bindRunSteer(async (text) => {
|
|
2942
|
+
const steer = run.steer;
|
|
2943
|
+
if (!steer) {
|
|
2944
|
+
console.warn(`[apm] \u5F53\u524D run \u4E0D\u652F\u6301 steer runId=${run.id}`);
|
|
2945
|
+
return;
|
|
2946
|
+
}
|
|
2947
|
+
try {
|
|
2948
|
+
const outcome = await steer(text);
|
|
2949
|
+
console.log(`[apm] steer outcome=${outcome} runId=${run.id}`);
|
|
2950
|
+
} catch (err) {
|
|
2951
|
+
console.error(
|
|
2952
|
+
`[apm] steer \u5931\u8D25 runId=${run.id}:`,
|
|
2953
|
+
err instanceof Error ? err.message : err
|
|
2954
|
+
);
|
|
2955
|
+
}
|
|
2956
|
+
});
|
|
2917
2957
|
await options.onRunStarted?.({ agentId: agent.agentId, runId: run.id });
|
|
2918
2958
|
let lastRunErrorStatus;
|
|
2919
2959
|
for await (const event of run.stream()) {
|
|
@@ -2999,6 +3039,7 @@ async function runCursorAgent(cfg2, ctx, options) {
|
|
|
2999
3039
|
}
|
|
3000
3040
|
throw err;
|
|
3001
3041
|
} finally {
|
|
3042
|
+
clearRunSteer();
|
|
3002
3043
|
signal?.removeEventListener("abort", abortRun);
|
|
3003
3044
|
await agent[Symbol.asyncDispose]();
|
|
3004
3045
|
}
|
|
@@ -5417,11 +5458,19 @@ var cfg = tryReadApmConfig();
|
|
|
5417
5458
|
var { msg } = workerData;
|
|
5418
5459
|
if (!cfg || !msg) throw new Error("worker-script \u7F3A\u5C11 workerData");
|
|
5419
5460
|
var controller = new AbortController();
|
|
5420
|
-
port.on(
|
|
5421
|
-
|
|
5422
|
-
|
|
5461
|
+
port.on(
|
|
5462
|
+
"message",
|
|
5463
|
+
(raw) => {
|
|
5464
|
+
if (raw?.messageId !== msg.messageId) return;
|
|
5465
|
+
if (raw.type === "cancel") {
|
|
5466
|
+
controller.abort();
|
|
5467
|
+
return;
|
|
5468
|
+
}
|
|
5469
|
+
if (raw.type === "steer" && typeof raw.text === "string") {
|
|
5470
|
+
deliverRunSteer(raw.text);
|
|
5471
|
+
}
|
|
5423
5472
|
}
|
|
5424
|
-
|
|
5473
|
+
);
|
|
5425
5474
|
var reply = (body) => port.postMessage(body);
|
|
5426
5475
|
try {
|
|
5427
5476
|
await dispatchWorkerJob(cfg, msg, controller.signal);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-project-manage-cli",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.11",
|
|
4
4
|
"description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@bufbuild/protobuf": "1.10.0",
|
|
32
32
|
"@connectrpc/connect": "~1.7.0",
|
|
33
33
|
"@connectrpc/connect-node": "~1.7.0",
|
|
34
|
-
"@cursor/sdk": "^1.0.
|
|
34
|
+
"@cursor/sdk": "^1.0.32",
|
|
35
35
|
"commander": "~14.0.3",
|
|
36
36
|
"listpage-http": "~0.0.318",
|
|
37
37
|
"minio": "~8.0.7",
|