@eum-agent/integration-acp 1.0.0 → 1.0.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.
Files changed (3) hide show
  1. package/dist/index.js +1763 -553
  2. package/package.json +4 -4
  3. package/ui/ui.js +31 -27
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "en-US": "ACP Agent Integration",
5
5
  "zh-CN": "ACP 智能体接入"
6
6
  },
7
- "version": "1.0.0",
7
+ "version": "1.0.1",
8
8
  "type": "module",
9
9
  "description": "Delegation to local agents through the Agent Client Protocol",
10
10
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@agentclientprotocol/codex-acp": "1.12.0",
27
- "@eum-agent/plugin": "1.0.0",
27
+ "@eum-agent/plugin": "1.0.1",
28
28
  "react": "^19.2.0",
29
29
  "@types/react": "^19.2.18",
30
30
  "vite": "^8.2.2",
@@ -40,8 +40,8 @@
40
40
  "dependencies": {},
41
41
  "kind": "extension",
42
42
  "foundationDependencies": {
43
- "@eum-agent/infra-local": "1.0.0",
44
- "@eum-agent/storage-sqlite": "1.0.0"
43
+ "@eum-agent/infra-local": "1.0.1",
44
+ "@eum-agent/storage-sqlite": "1.0.1"
45
45
  }
46
46
  },
47
47
  "scripts": {
package/ui/ui.js CHANGED
@@ -293,16 +293,10 @@ function settingsFor(ctx) {
293
293
  if (!choosing || host.connection !== "online") return;
294
294
  let active = true;
295
295
  setAvailability({});
296
- for (const preset of ACP_PRESETS) ctx.invoke("inspectPreset", { id: preset.id }).then((result) => {
297
- if (active) setAvailability((previous) => ({
298
- ...previous,
299
- [preset.id]: result
300
- }));
296
+ ctx.invoke("inspectPresets", { ids: ACP_PRESETS.map((preset) => preset.id) }).then((batch) => {
297
+ if (active) setAvailability(Object.fromEntries(batch.results.map((item) => [item.target, item.ok ? item.value : "error"])));
301
298
  }, (error) => {
302
- if (active && failureText(error) !== null) setAvailability((previous) => ({
303
- ...previous,
304
- [preset.id]: "error"
305
- }));
299
+ if (active && failureText(error) !== null) setAvailability(Object.fromEntries(ACP_PRESETS.map((preset) => [preset.id, "error"])));
306
300
  });
307
301
  return () => {
308
302
  active = false;
@@ -379,6 +373,7 @@ function settingsFor(ctx) {
379
373
  if (mounted.current && epoch === checkEpoch.current) setChecking(false);
380
374
  }
381
375
  }
376
+ const presetIntents = useRef(/* @__PURE__ */ new Map());
382
377
  function choose(presetId) {
383
378
  const preset = ACP_PRESETS.find((item) => item.id === presetId);
384
379
  const draft = {
@@ -394,8 +389,15 @@ function settingsFor(ctx) {
394
389
  revision: 0
395
390
  };
396
391
  if (preset) run(async () => {
397
- const saved = await ctx.invoke("addPreset", { id: preset.id });
398
- setInstances((rows) => [...rows, saved]);
392
+ const operationId = presetIntents.current.get(preset.id) ?? ctx.uuid();
393
+ presetIntents.current.set(preset.id, operationId);
394
+ if ((await ctx.invoke("addPresets", {
395
+ operationId,
396
+ ids: [preset.id]
397
+ })).operationState === "admitted") throw new Error("Operation settlement is uncertain");
398
+ const current = await ctx.invoke("settings", {});
399
+ setInstances(current.instances);
400
+ presetIntents.current.delete(preset.id);
399
401
  setChoosing(false);
400
402
  setEditor(null);
401
403
  toast.add({
@@ -914,7 +916,8 @@ function settingsFor(ctx) {
914
916
  disabled: pending,
915
917
  onClick: () => {
916
918
  if (removing) run(async () => {
917
- await ctx.invoke("removeInstance", { id: removing.id });
919
+ const result = (await ctx.invoke("removeInstances", { ids: [removing.id] })).results[0];
920
+ if (!result?.ok) throw new Error(result?.error.message ?? "Removal failed");
918
921
  setInstances((rows) => rows.filter((row) => row.id !== removing.id));
919
922
  setRemoving(null);
920
923
  toast.add({
@@ -1187,13 +1190,14 @@ var LINE_STATES = {
1187
1190
  failed: "failed"
1188
1191
  };
1189
1192
  /** The delegation an `acp_delegate` or `acp_send` call answered with. */
1190
- function delegationOf(name, content) {
1191
- if (name !== "acp_delegate" && name !== "acp_send" || content === void 0) return null;
1193
+ function delegationsOf(name, content) {
1194
+ if (name !== "acp_delegate" && name !== "acp_send" || content === void 0) return [];
1192
1195
  try {
1196
+ if (name === "acp_delegate") return (JSON.parse(content).results ?? []).flatMap((item) => item.ok && typeof item.value?.delegationId === "string" ? [item.value.delegationId] : []);
1193
1197
  const task = JSON.parse(content);
1194
- return typeof task.delegationId === "string" ? task.delegationId : null;
1198
+ return typeof task.delegationId === "string" ? [task.delegationId] : [];
1195
1199
  } catch {
1196
- return null;
1200
+ return [];
1197
1201
  }
1198
1202
  }
1199
1203
  /** Collapses owner notifications while a list or detail request is in flight. */
@@ -1216,11 +1220,11 @@ function coalesceReads(read) {
1216
1220
  }
1217
1221
  async function readEntry(ctx, sessionId, delegationId) {
1218
1222
  for (let offset = 0;; offset += 200) {
1219
- const rows = await ctx.invoke("list", {
1223
+ const rows = (await ctx.invoke("list", {
1220
1224
  sessionId,
1221
1225
  offset,
1222
1226
  limit: 200
1223
- });
1227
+ })).entries;
1224
1228
  const entry = rows.find((row) => row.delegation.id === delegationId);
1225
1229
  if (entry) return entry;
1226
1230
  if (rows.length < 200) return null;
@@ -1413,8 +1417,7 @@ function sectionFor(ctx) {
1413
1417
  const [readFailed, setReadFailed] = useState(false);
1414
1418
  const [attempt, setAttempt] = useState(0);
1415
1419
  const mine = new Set(calls.flatMap((one) => {
1416
- const id = delegationOf(one.call.name, one.result?.content);
1417
- return id === null ? [] : [id];
1420
+ return delegationsOf(one.call.name, one.result?.content);
1418
1421
  }));
1419
1422
  const any = mine.size > 0;
1420
1423
  const mineKey = JSON.stringify([...mine].sort());
@@ -1422,11 +1425,11 @@ function sectionFor(ctx) {
1422
1425
  const remaining = new Set(mine);
1423
1426
  const found = [];
1424
1427
  for (let offset = 0; current() && remaining.size > 0; offset += 200) {
1425
- const page = await ctx.invoke("list", {
1428
+ const page = (await ctx.invoke("list", {
1426
1429
  sessionId,
1427
1430
  offset,
1428
1431
  limit: 200
1429
- });
1432
+ })).entries;
1430
1433
  if (!current()) break;
1431
1434
  for (const entry of page) if (remaining.delete(entry.delegation.id)) found.push(entry);
1432
1435
  if (page.length < 200) break;
@@ -1475,10 +1478,11 @@ function sectionFor(ctx) {
1475
1478
  actions.current.add(id);
1476
1479
  setBusy((before) => new Set(before).add(id));
1477
1480
  try {
1478
- await ctx.invoke(method, {
1481
+ const result = (await ctx.invoke(method, {
1479
1482
  sessionId,
1480
- delegationId: id
1481
- });
1483
+ delegationIds: [id]
1484
+ })).results[0];
1485
+ if (!result?.ok) throw new Error(result?.error.message ?? "Operation failed");
1482
1486
  setRows(await listMine());
1483
1487
  } catch (error) {
1484
1488
  showFailure(toast, error);
@@ -1527,12 +1531,12 @@ function sectionFor(ctx) {
1527
1531
  icon: "stop",
1528
1532
  label: ctx.i18n.t("stop"),
1529
1533
  disabled: disabled || task.state === "stopping",
1530
- onClick: () => void invoke("stop", delegation.id)
1534
+ onClick: () => void invoke("stopDelegations", delegation.id)
1531
1535
  }] : [], ...retained && (!task || task.state === "finished") ? [{
1532
1536
  icon: "close",
1533
1537
  label: ctx.i18n.t("close"),
1534
1538
  disabled,
1535
- onClick: () => void invoke("close", delegation.id)
1539
+ onClick: () => void invoke("closeDelegations", delegation.id)
1536
1540
  }] : []],
1537
1541
  children: /* @__PURE__ */ jsx(Detail, {
1538
1542
  sessionId,