ai-project-manage-cli 8.1.11 → 8.1.12
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/worker-script.js +62 -9
- package/package.json +1 -1
package/dist/worker-script.js
CHANGED
|
@@ -1996,6 +1996,14 @@ var MinioClient = class {
|
|
|
1996
1996
|
async removeObject(bucket, objectKey) {
|
|
1997
1997
|
await this.inner.removeObject(bucket, objectKey);
|
|
1998
1998
|
}
|
|
1999
|
+
async getObjectBuffer(bucket, objectKey) {
|
|
2000
|
+
const stream = await this.inner.getObject(bucket, objectKey);
|
|
2001
|
+
const chunks = [];
|
|
2002
|
+
for await (const chunk of stream) {
|
|
2003
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
2004
|
+
}
|
|
2005
|
+
return Buffer.concat(chunks);
|
|
2006
|
+
}
|
|
1999
2007
|
};
|
|
2000
2008
|
|
|
2001
2009
|
// src/commands/connect/apm-log-minio.ts
|
|
@@ -2460,6 +2468,10 @@ function createPtySessionMcpServers(cfg2) {
|
|
|
2460
2468
|
}
|
|
2461
2469
|
|
|
2462
2470
|
// src/commands/connect/remote-local-agent-store.ts
|
|
2471
|
+
var INLINE_CHECKPOINT_MAX_BYTES = 256 * 1024;
|
|
2472
|
+
function checkpointObjectKey(agentId, blobId) {
|
|
2473
|
+
return `cursor-agents/${agentId}/checkpoints/${blobId}`;
|
|
2474
|
+
}
|
|
2463
2475
|
function asCheckpointRef(value) {
|
|
2464
2476
|
if (value === void 0) return void 0;
|
|
2465
2477
|
if (value === null) return null;
|
|
@@ -2534,6 +2546,16 @@ function base64ToBytes(dataBase64) {
|
|
|
2534
2546
|
}
|
|
2535
2547
|
function createRemoteLocalAgentStore(cfg2) {
|
|
2536
2548
|
const api = createApmApiClient(cfg2);
|
|
2549
|
+
let minioCache = null;
|
|
2550
|
+
function getMinio() {
|
|
2551
|
+
if (!minioCache) {
|
|
2552
|
+
minioCache = createApmLogMinioClient(cfg2).then(({ client, bucket }) => ({
|
|
2553
|
+
client,
|
|
2554
|
+
bucket
|
|
2555
|
+
}));
|
|
2556
|
+
}
|
|
2557
|
+
return minioCache;
|
|
2558
|
+
}
|
|
2537
2559
|
async function upsertAgent(agent) {
|
|
2538
2560
|
const row = await api.cli.cursorStoreUpsertAgent({
|
|
2539
2561
|
agentId: agent.agentId,
|
|
@@ -2570,14 +2592,45 @@ function createRemoteLocalAgentStore(cfg2) {
|
|
|
2570
2592
|
return fromApiRun(row);
|
|
2571
2593
|
}
|
|
2572
2594
|
async function putCheckpoint(input) {
|
|
2595
|
+
const createdAt = Date.now();
|
|
2596
|
+
if (input.data.byteLength > INLINE_CHECKPOINT_MAX_BYTES) {
|
|
2597
|
+
const { client, bucket } = await getMinio();
|
|
2598
|
+
const objectKey = checkpointObjectKey(input.agentId, input.blobId);
|
|
2599
|
+
await client.putObject(bucket, objectKey, Buffer.from(input.data), {
|
|
2600
|
+
"Content-Type": "application/octet-stream"
|
|
2601
|
+
});
|
|
2602
|
+
await api.cli.cursorStorePutCheckpoint({
|
|
2603
|
+
agentId: input.agentId,
|
|
2604
|
+
blobId: input.blobId,
|
|
2605
|
+
objectKey,
|
|
2606
|
+
byteSize: input.data.byteLength,
|
|
2607
|
+
createdAt
|
|
2608
|
+
});
|
|
2609
|
+
return;
|
|
2610
|
+
}
|
|
2573
2611
|
await api.cli.cursorStorePutCheckpoint({
|
|
2574
2612
|
agentId: input.agentId,
|
|
2575
2613
|
blobId: input.blobId,
|
|
2576
2614
|
dataBase64: bytesToBase64(input.data),
|
|
2577
2615
|
byteSize: input.data.byteLength,
|
|
2578
|
-
createdAt
|
|
2616
|
+
createdAt
|
|
2579
2617
|
});
|
|
2580
2618
|
}
|
|
2619
|
+
async function readCheckpointBytes(input) {
|
|
2620
|
+
const row = await api.cli.cursorStoreGetCheckpoint({
|
|
2621
|
+
agentId: input.agentId,
|
|
2622
|
+
blobId: input.blobId
|
|
2623
|
+
});
|
|
2624
|
+
if (!row) return null;
|
|
2625
|
+
if (row.dataBase64) {
|
|
2626
|
+
return base64ToBytes(row.dataBase64);
|
|
2627
|
+
}
|
|
2628
|
+
const objectKey = row.objectKey?.trim();
|
|
2629
|
+
if (!objectKey) return null;
|
|
2630
|
+
const { client, bucket } = await getMinio();
|
|
2631
|
+
const buf = await client.getObjectBuffer(bucket, objectKey);
|
|
2632
|
+
return new Uint8Array(buf);
|
|
2633
|
+
}
|
|
2581
2634
|
return {
|
|
2582
2635
|
agents: {
|
|
2583
2636
|
async get(input) {
|
|
@@ -2732,12 +2785,7 @@ function createRemoteLocalAgentStore(cfg2) {
|
|
|
2732
2785
|
},
|
|
2733
2786
|
checkpoints: {
|
|
2734
2787
|
async get(input) {
|
|
2735
|
-
|
|
2736
|
-
agentId: input.agentId,
|
|
2737
|
-
blobId: input.blobId
|
|
2738
|
-
});
|
|
2739
|
-
if (!row?.dataBase64) return null;
|
|
2740
|
-
return base64ToBytes(row.dataBase64);
|
|
2788
|
+
return readCheckpointBytes(input);
|
|
2741
2789
|
},
|
|
2742
2790
|
async create(input) {
|
|
2743
2791
|
await putCheckpoint(input);
|
|
@@ -5103,6 +5151,11 @@ async function handleWebIdeInboundMessage(cfg2, msg2, signal) {
|
|
|
5103
5151
|
const savedAgentId = startLocalServices || useNewAgent ? void 0 : designAction ? loadWebIdeDesignAgentId(workdir, taskId) : loadWebIdeAgentId(workdir, taskId);
|
|
5104
5152
|
const promptPayload = toolNames.includes("MysqlExecute") ? parseWebIdePromptPayload(msg2.content) : null;
|
|
5105
5153
|
const sqlExecutionId = toolNames.includes("MysqlExecute") && typeof promptPayload?.executionId === "string" ? promptPayload.executionId.trim() : void 0;
|
|
5154
|
+
if (toolNames.includes("MysqlExecute") && !sqlExecutionId) {
|
|
5155
|
+
console.warn(
|
|
5156
|
+
"[apm] \u5DE5\u5177\u540D\u5355\u542B MysqlExecute\uFF0C\u4F46 prompt \u672B\u5C3E\u6CA1\u6709 executionId\uFF0C\u672C\u8F6E\u4E0D\u4F1A\u6302\u8F7D\u8BE5\u5DE5\u5177"
|
|
5157
|
+
);
|
|
5158
|
+
}
|
|
5106
5159
|
const persistAgentId = (agentId) => {
|
|
5107
5160
|
if (startLocalServices) return;
|
|
5108
5161
|
if (designAction) {
|
|
@@ -5212,7 +5265,7 @@ ${assumptionAnswersText}` : msg2.content,
|
|
|
5212
5265
|
detail,
|
|
5213
5266
|
tokenUsage
|
|
5214
5267
|
);
|
|
5215
|
-
if (sqlExecutionId) {
|
|
5268
|
+
if (sqlExecutionId && msg2.action !== "request-bugfix") {
|
|
5216
5269
|
try {
|
|
5217
5270
|
await api.cli.webideFinalizeSqlExecution({
|
|
5218
5271
|
executionId: sqlExecutionId,
|
|
@@ -5237,7 +5290,7 @@ ${assumptionAnswersText}` : msg2.content,
|
|
|
5237
5290
|
"\u5DF2\u53D6\u6D88",
|
|
5238
5291
|
tokenUsage
|
|
5239
5292
|
);
|
|
5240
|
-
if (sqlExecutionId) {
|
|
5293
|
+
if (sqlExecutionId && msg2.action !== "request-bugfix") {
|
|
5241
5294
|
try {
|
|
5242
5295
|
await api.cli.webideFinalizeSqlExecution({
|
|
5243
5296
|
executionId: sqlExecutionId,
|