dsh-multigameassistant 2.2.1 → 2.2.3

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.
@@ -290,7 +290,7 @@ var ReleaseInfo = external_exports.object({
290
290
  notes: external_exports.string().optional()
291
291
  });
292
292
  var ScriptJobPhase = external_exports.enum(["queued", "resolving", "downloading", "verifying", "extracting", "checking", "running", "done", "failed", "cancelled"]);
293
- var SetupAgent = external_exports.object({ sessionId: external_exports.string(), state: external_exports.enum(["running", "failed"]), reason: external_exports.string().optional() });
293
+ var SetupAgent = external_exports.object({ sessionId: external_exports.string(), taskId: external_exports.string().optional(), state: external_exports.enum(["running", "failed"]), reason: external_exports.string().optional() });
294
294
  var PendingSetupInfo = external_exports.object({
295
295
  scriptId: external_exports.string(),
296
296
  name: external_exports.string(),
@@ -1206,6 +1206,8 @@ var NodeRun = external_exports.object({
1206
1206
  state: NodeRunState,
1207
1207
  /** For people: what it waits for, how it ended. */
1208
1208
  detail: external_exports.string().optional(),
1209
+ /** The outcome of an explicitly linked repair after the pipeline ended. */
1210
+ repair: external_exports.object({ runId: external_exports.string(), state: external_exports.enum(["succeeded", "failed", "cancelled"]), at: external_exports.number() }).optional(),
1209
1211
  /** Script runs started for this node (retries add more). */
1210
1212
  runIds: external_exports.array(external_exports.string()),
1211
1213
  attempts: external_exports.number().int().min(0),
@@ -1512,6 +1514,11 @@ var GameNotice = external_exports.object({
1512
1514
  /** When it was read. */
1513
1515
  at: external_exports.number()
1514
1516
  });
1517
+ var NoticeArticle = external_exports.array(external_exports.discriminatedUnion("type", [
1518
+ external_exports.object({ type: external_exports.literal("text"), text: external_exports.string() }),
1519
+ external_exports.object({ type: external_exports.literal("image"), url: external_exports.url({ protocol: /^https$/ }) })
1520
+ ]));
1521
+ var GameNoticeDetail = GameNotice.extend({ article: NoticeArticle.optional() });
1515
1522
  var Activity = external_exports.object({
1516
1523
  /** `<game>/<key>`; the key is the normalised name, so a site and the screen meet on it. */
1517
1524
  id: external_exports.string(),
@@ -1540,6 +1547,7 @@ var Activity = external_exports.object({
1540
1547
  name: external_exports.string(),
1541
1548
  at: external_exports.number(),
1542
1549
  web: external_exports.boolean(),
1550
+ url: external_exports.string().optional(),
1543
1551
  startsAt: external_exports.number().optional(),
1544
1552
  endsAt: external_exports.number().optional(),
1545
1553
  shopEndsAt: external_exports.number().optional(),
@@ -1607,6 +1615,15 @@ var GameSourceInfo = external_exports.object({
1607
1615
  /** A page the user added on the game page (`games/source/add`); it can be removed there. */
1608
1616
  added: external_exports.boolean().optional()
1609
1617
  });
1618
+ var GameReading = external_exports.object({
1619
+ state: external_exports.enum(["queued", "running", "done", "partial", "failed", "cancelled"]),
1620
+ at: external_exports.number(),
1621
+ sessionId: external_exports.string().optional(),
1622
+ taskId: external_exports.string().optional(),
1623
+ scope: external_exports.string().optional(),
1624
+ remainingUrls: external_exports.array(external_exports.string()).optional(),
1625
+ summary: external_exports.string().optional()
1626
+ });
1610
1627
  var GameInfo = external_exports.object({
1611
1628
  id: external_exports.string(),
1612
1629
  name: external_exports.string(),
@@ -1652,19 +1669,9 @@ var GameInfo = external_exports.object({
1652
1669
  /** The last data-site refresh. */
1653
1670
  refreshed: external_exports.object({ at: external_exports.number(), ok: external_exports.boolean(), count: external_exports.number(), detail: external_exports.string().optional() }).optional(),
1654
1671
  /** The last time the agent read the game screen. */
1655
- reading: external_exports.object({
1656
- state: external_exports.enum(["running", "done", "failed"]),
1657
- at: external_exports.number(),
1658
- sessionId: external_exports.string().optional(),
1659
- summary: external_exports.string().optional()
1660
- }).optional(),
1672
+ reading: GameReading.optional(),
1661
1673
  /** The last time the agent read the web for it (official news, wikis — the sources the plugin cannot read itself). */
1662
- webReading: external_exports.object({
1663
- state: external_exports.enum(["running", "done", "failed"]),
1664
- at: external_exports.number(),
1665
- sessionId: external_exports.string().optional(),
1666
- summary: external_exports.string().optional()
1667
- }).optional()
1674
+ webReading: GameReading.optional()
1668
1675
  });
1669
1676
  var GamesSettings = external_exports.object({
1670
1677
  report: external_exports.object({
@@ -1701,6 +1708,11 @@ var GamesRequests = {
1701
1708
  params: external_exports.object({}),
1702
1709
  result: external_exports.object({ games: external_exports.array(GameInfo), activities: external_exports.array(Activity), notices: external_exports.array(GameNotice).default([]), settings: GamesSettings, report: ReportInfo })
1703
1710
  },
1711
+ "games/notice/detail": {
1712
+ capability: GAMES_CAPABILITY,
1713
+ params: external_exports.object({ game: external_exports.string(), noticeId: external_exports.string() }),
1714
+ result: GameNoticeDetail
1715
+ },
1704
1716
  /** Read the data sites now (one game, or all). */
1705
1717
  "games/refresh": {
1706
1718
  capability: GAMES_CAPABILITY,
@@ -1718,6 +1730,11 @@ var GamesRequests = {
1718
1730
  params: external_exports.object({ game: external_exports.string(), how: external_exports.enum(["screen", "web"]).optional(), source: external_exports.string().optional() }),
1719
1731
  result: external_exports.object({ sessionId: external_exports.string() })
1720
1732
  },
1733
+ "games/read/cancel": {
1734
+ capability: GAMES_CAPABILITY,
1735
+ params: external_exports.object({ taskId: external_exports.string() }),
1736
+ result: external_exports.object({ cancelled: external_exports.boolean() })
1737
+ },
1721
1738
  "games/report/preview": {
1722
1739
  capability: GAMES_CAPABILITY,
1723
1740
  params: external_exports.object({}),
@@ -2773,7 +2790,8 @@ var MessageOrigin = external_exports.object({
2773
2790
  /** One-line account for `notice`-form injected context. */
2774
2791
  summary: external_exports.string().optional(),
2775
2792
  /** A model failed and the agent went on with the next of its fallback list (kind MODEL_FALLBACK_SOURCE). */
2776
- fallback: ModelFallbackNotice.optional()
2793
+ fallback: ModelFallbackNotice.optional(),
2794
+ childId: external_exports.string().optional()
2777
2795
  });
2778
2796
  var base = { seq: external_exports.number(), time: external_exports.number() };
2779
2797
  var SessionEvent = external_exports.discriminatedUnion("type", [
@@ -2815,6 +2833,7 @@ var SessionEvent = external_exports.discriminatedUnion("type", [
2815
2833
  external_exports.object({
2816
2834
  ...base,
2817
2835
  type: external_exports.literal("assistant/attempt"),
2836
+ usage: TokenUsage.optional(),
2818
2837
  turn: external_exports.number(),
2819
2838
  step: external_exports.number(),
2820
2839
  timing: StreamTiming,
@@ -3165,6 +3184,8 @@ var HandOff = external_exports.object({
3165
3184
  /** The agent it went to (role id) and its conversation. */
3166
3185
  to: external_exports.string(),
3167
3186
  toSession: external_exports.string(),
3187
+ isolated: external_exports.boolean().optional(),
3188
+ ownerSession: external_exports.string().optional(),
3168
3189
  title: external_exports.string(),
3169
3190
  task: external_exports.string(),
3170
3191
  expecting: external_exports.string().optional(),
@@ -3963,11 +3984,13 @@ export {
3963
3984
  AgentTaskRun,
3964
3985
  INTERVENE_CAPABILITY,
3965
3986
  GAMES_CAPABILITY,
3966
- GameNotice,
3987
+ NoticeArticle,
3988
+ GameNoticeDetail,
3967
3989
  OWN_SOURCE,
3968
3990
  SCREEN_SOURCE,
3969
3991
  OWN_IMAGE,
3970
3992
  SHOT_IMAGE,
3993
+ GameReading,
3971
3994
  GamesSettings,
3972
3995
  PERMISSIONS_CAPABILITY,
3973
3996
  AreaPolicy,
@@ -2,7 +2,7 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
2
2
  import {
3
3
  ScriptFamily,
4
4
  ScriptId
5
- } from "./chunk-F7ZQE7BT.js";
5
+ } from "./chunk-LXHF6AKU.js";
6
6
  import {
7
7
  external_exports
8
8
  } from "./chunk-6DSSLS7I.js";
@@ -4,11 +4,11 @@ import {
4
4
  guideView,
5
5
  renderTask,
6
6
  require_dist
7
- } from "./chunk-IBPJC6DX.js";
7
+ } from "./chunk-RGEGJH6R.js";
8
8
  import {
9
9
  RUNS_CAPABILITY,
10
10
  ScriptId
11
- } from "./chunk-F7ZQE7BT.js";
11
+ } from "./chunk-LXHF6AKU.js";
12
12
  import {
13
13
  external_exports
14
14
  } from "./chunk-6DSSLS7I.js";
@@ -2054,6 +2054,21 @@ var Runner = class {
2054
2054
  * not restarted unless a person asks for it (`byUser`).
2055
2055
  * @throws Error when the task cannot start again (e.g. its resources are busy).
2056
2056
  */
2057
+ async repair(runId, scriptId, taskId) {
2058
+ const original = this.#run(runId);
2059
+ if (original.info.scriptId !== scriptId || original.info.taskId !== taskId)
2060
+ throw new Error("\u8865\u507F\u76EE\u6807\u4E0E\u539F\u8FD0\u884C\u7684\u811A\u672C\u6216\u4EFB\u52A1\u4E0D\u4E00\u81F4");
2061
+ if (original.info.endedAt === void 0 || original.info.state === "succeeded")
2062
+ throw new Error("\u53EA\u80FD\u8865\u507F\u5DF2\u7ED3\u675F\u4E14\u672A\u6210\u529F\u7684\u8FD0\u884C");
2063
+ const pending = this.#successors.get(runId);
2064
+ if (pending) {
2065
+ const successor = await pending;
2066
+ if (successor)
2067
+ return successor;
2068
+ throw new Error("\u5148\u524D\u7684\u8865\u507F\u672A\u80FD\u542F\u52A8\uFF0C\u8BF7\u68C0\u67E5\u8FD0\u884C\u8BB0\u5F55\u540E\u91CD\u8BD5");
2069
+ }
2070
+ return this.restart(runId, "\u9488\u5BF9\u539F\u8FD0\u884C\u7684\u8865\u507F");
2071
+ }
2057
2072
  async restart(runId, reason, options = {}) {
2058
2073
  const run = this.#run(runId);
2059
2074
  if (run.mode !== "task")
@@ -2072,7 +2087,12 @@ var Runner = class {
2072
2087
  throw new Error("\u8FD9\u6B21\u8FD0\u884C\u5DF2\u7ECF\u88AB\u505C\u6B62\u4E86\uFF0C\u4E0D\u518D\u91CD\u65B0\u8FD0\u884C");
2073
2088
  return this.start(run.info.scriptId, run.info.taskId, run.info.params, { retryOf: runId, profile: run.info.profile, signal: abort.signal });
2074
2089
  })();
2075
- this.#successors.set(runId, next.catch(() => void 0));
2090
+ const successor = next.catch(() => {
2091
+ if (this.#successors.get(runId) === successor)
2092
+ this.#successors.delete(runId);
2093
+ return void 0;
2094
+ });
2095
+ this.#successors.set(runId, successor);
2076
2096
  return next;
2077
2097
  }
2078
2098
  /**
@@ -2722,6 +2742,7 @@ function runnerTools(runner, config) {
2722
2742
  task: { type: "string", description: "\u4EFB\u52A1 id\uFF08script_tasks \u53EF\u67E5\uFF09\u3002" },
2723
2743
  params: { ...PARAMS_SCHEMA, description: '\u4EFB\u52A1\u53C2\u6570\uFF0C\u4F8B\u5982 [{"name":"stage","value":"1-7"}]\uFF1B\u7701\u7565\u7684\u53C2\u6570\u7528\u9ED8\u8BA4\u503C\u3002' },
2724
2744
  wait: { type: "boolean", description: "\u7B49\u8FD0\u884C\u7ED3\u675F\u518D\u8FD4\u56DE\uFF08\u6700\u957F 3 \u5C0F\u65F6\uFF09\u3002" },
2745
+ repair_of: { type: "string", description: "\u8865\u507F\u67D0\u4E2A\u5DF2\u5931\u8D25\u7684\u8FD0\u884C\u65F6\uFF0C\u4F20\u5B83\u7684 run_id\u3002\u6CBF\u7528\u539F\u53C2\u6570\u548C\u914D\u7F6E\uFF0C\u91CD\u590D\u8BF7\u6C42\u8FD4\u56DE\u540C\u4E00\u8865\u507F\u3002" },
2725
2746
  profile: { ...profile, description: "\u7528\u54EA\u4EFD\u914D\u7F6E\u8FD0\u884C\uFF08script_profiles \u53EF\u67E5\uFF09\uFF1B\u4E0D\u586B\u5C31\u662F\u5F53\u524D\u90A3\u4EFD\u3002\u7528\u6237\u8BF4\u300C\u7528\u5C0F\u53F7\u7684\u914D\u7F6E\u300D\u4E4B\u7C7B\u65F6\u586B\u3002" }
2726
2747
  },
2727
2748
  required: ["id", "task"],
@@ -2729,9 +2750,11 @@ function runnerTools(runner, config) {
2729
2750
  kind: "execute",
2730
2751
  title: (a) => `\u8FD0\u884C\uFF1A${String(a["id"] ?? "")} / ${String(a["task"] ?? "")}`,
2731
2752
  execute: async (args, exec) => {
2732
- const a = parse(external_exports.object({ id: ScriptId, task: external_exports.string().min(1).max(64), params: external_exports.array(external_exports.object({ name: external_exports.string().min(1), value: external_exports.string() })).max(40).nullish(), wait: external_exports.boolean().nullish(), profile: Profile }), args);
2753
+ const a = parse(external_exports.object({ id: ScriptId, task: external_exports.string().min(1).max(64), params: external_exports.array(external_exports.object({ name: external_exports.string().min(1), value: external_exports.string() })).max(40).nullish(), wait: external_exports.boolean().nullish(), repair_of: external_exports.string().min(1).nullish(), profile: Profile }), args);
2733
2754
  const spec = config.library.packOf(a.id)?.manifest.tasks.find((t) => t.id === a.task)?.params ?? {};
2734
- const started = await runner.start(a.id, a.task, taskParams(a.params, spec), { profile: ref(a.profile) });
2755
+ if (a.repair_of && (a.params?.length || a.profile))
2756
+ throw new Error("\u8865\u507F\u6CBF\u7528\u539F\u8FD0\u884C\u7684\u53C2\u6570\u548C\u914D\u7F6E");
2757
+ const started = a.repair_of ? await runner.repair(a.repair_of, a.id, a.task) : await runner.start(a.id, a.task, taskParams(a.params, spec), { profile: ref(a.profile) });
2735
2758
  if (a.wait !== true || started.endedAt !== void 0)
2736
2759
  return brief(runner, started.id);
2737
2760
  const onAbort = () => void runner.stop(started.id);
@@ -35,13 +35,13 @@ import {
35
35
  parseJsonc,
36
36
  parseManifest,
37
37
  versionOfTag
38
- } from "./chunk-IBPJC6DX.js";
38
+ } from "./chunk-RGEGJH6R.js";
39
39
  import {
40
40
  sessionConversations
41
- } from "./chunk-YSTZL6HE.js";
41
+ } from "./chunk-A6YQRWHZ.js";
42
42
  import {
43
43
  pluginVersion
44
- } from "./chunk-OFVGRKTD.js";
44
+ } from "./chunk-6NJSSOB6.js";
45
45
  import {
46
46
  ExeIcons,
47
47
  writeFileAtomic
@@ -64,7 +64,7 @@ import {
64
64
  optimizeScriptPrompt,
65
65
  parseGitHubLink,
66
66
  taskMessage
67
- } from "./chunk-F7ZQE7BT.js";
67
+ } from "./chunk-LXHF6AKU.js";
68
68
  import {
69
69
  NEVER,
70
70
  ZodIssueCode,
@@ -2976,7 +2976,8 @@ function packReview(ctx, library, log) {
2976
2976
  throw new Error("agent \u73B0\u5728\u4E0D\u53EF\u7528\uFF08\u4F1A\u8BDD\u670D\u52A1\u6CA1\u6709\u52A0\u8F7D\uFF09");
2977
2977
  const gateway = ctx.get("adgGateway");
2978
2978
  const conversations = sessionConversations(sessions, () => gateway?.workspaceDir(), (sessionId2, focus) => gateway?.skillScope.setFocus(sessionId2, focus) ?? Promise.resolve(), () => gateway);
2979
- const sessionId = await conversations.home(SCRIPT_ROLE.id, { focus: { scripts: [id] } });
2979
+ const work = await conversations.prepareTask(SCRIPT_ROLE.id, `\u68C0\u67E5\u811A\u672C\u5305\uFF1A${script.name}`, { scripts: [id] });
2980
+ const sessionId = work.owner;
2980
2981
  const from = script.packReview?.from ?? "\u65E7\u7248\u672C";
2981
2982
  const to = script.packReview?.to ?? script.localVersion?.version ?? script.current ?? "\u65B0\u7248\u672C";
2982
2983
  const prompt = [
@@ -2987,8 +2988,11 @@ function packReview(ctx, library, log) {
2987
2988
  "3. \u8981\u6539\u5C31\u7528\u539F\u6765\u7684\u811A\u672C\u5305 id \u8C03\u7528 pack_propose \u4FDD\u5B58\uFF08\u76F4\u63A5\u751F\u6548\uFF1Bsummary \u5199\u660E\u4F9D\u636E\u66F4\u65B0\u65E5\u5FD7\u6539\u4E86\u4EC0\u4E48\uFF09\uFF1B\u4E0D\u7528\u6539\u5C31\u8C03\u7528 pack_reviewed \u8BF4\u660E\u7406\u7531\uFF1B",
2988
2989
  "4. \u6700\u540E\u7528\u4E24\u4E09\u53E5\u8BDD\u544A\u8BC9\u7528\u6237\u7ED3\u8BBA\u3002"
2989
2990
  ].join("\n");
2990
- void conversations.ask(sessionId, taskMessage("\u4F60", `\u68C0\u67E5\u811A\u672C\u5305\uFF1A${script.name}`, prompt), AbortSignal.timeout(REVIEW_TIMEOUT_MS)).catch((error) => log.warn(`pack review for ${id}: ${error instanceof Error ? error.message : String(error)}`));
2991
- close("\u5DF2\u4EA4\u7ED9\u300C\u811A\u672C\u300D\u68C0\u67E5\uFF0C\u8981\u6539\u7684\u5B83\u4F1A\u76F4\u63A5\u6539\u597D\uFF0C\u7ED3\u679C\u4F1A\u544A\u8BC9\u4F60");
2991
+ close("\u811A\u672C agent \u6B63\u5728\u68C0\u67E5");
2992
+ void work.run(taskMessage("\u4F60", `\u68C0\u67E5\u811A\u672C\u5305\uFF1A${script.name}`, prompt), AbortSignal.timeout(REVIEW_TIMEOUT_MS)).then((answer) => close(`\u68C0\u67E5\u7ED3\u679C\uFF1A${answer.slice(0, 400)}`), (error) => {
2993
+ close(`\u68C0\u67E5\u672A\u5B8C\u6210\uFF1A${String(error)}`);
2994
+ log.warn(`pack review for ${id}: ${String(error)}`);
2995
+ });
2992
2996
  return { sessionId };
2993
2997
  };
2994
2998
  ctx.inject(["adgNotify"], (scoped) => {
@@ -2996,6 +3000,8 @@ function packReview(ctx, library, log) {
2996
3000
  const id = noticeId.split(":")[1];
2997
3001
  if (id === void 0 || actionId !== "check" && actionId !== "keep")
2998
3002
  throw new Error(`\u672A\u77E5\u64CD\u4F5C ${actionId}`);
3003
+ if (noticeId !== noticeIdOf(id, library().get(id).packReview?.to ?? ""))
3004
+ throw new Error("\u8BE5\u7248\u672C\u7684\u68C0\u67E5\u5DF2\u7ED3\u675F\uFF0C\u8BF7\u67E5\u770B\u6700\u65B0\u7248\u672C");
2999
3005
  const { sessionId } = await decide(id, actionId);
3000
3006
  return sessionId === void 0 ? "\u597D\u7684\uFF0C\u811A\u672C\u5305\u4FDD\u6301\u4E0D\u53D8" : "\u597D\u7684\uFF0Cagent \u5148\u8BFB\u66F4\u65B0\u65E5\u5FD7\uFF0C\u518D\u68C0\u67E5\u811A\u672C\u5305\uFF1B\u8981\u6539\u7684\u5B83\u4F1A\u76F4\u63A5\u6539\u597D\uFF0C\u7ED3\u679C\u4F1A\u544A\u8BC9\u4F60";
3001
3007
  }), "adg-scripts pack review actions");
@@ -3008,6 +3014,11 @@ function packReview(ctx, library, log) {
3008
3014
  const notify = ctx.get("adgNotify");
3009
3015
  if (notify === void 0)
3010
3016
  return;
3017
+ for (const old of notify.notify.notices()) {
3018
+ if (old.id.startsWith(`${PACK_REVIEW_SCOPE}:${script.id}:`) && old.id !== noticeIdOf(script.id, review.to) && !old.done) {
3019
+ void notify.update(old.id, { done: `\u5DF2\u6709\u66F4\u65B0\u7684\u5F85\u68C0\u67E5\u7248\u672C ${review.to}` }).catch((error) => log.warn(String(error)));
3020
+ }
3021
+ }
3011
3022
  void notify.send({
3012
3023
  id: noticeIdOf(script.id, review.to),
3013
3024
  scope: PACK_REVIEW_SCOPE,
@@ -3038,7 +3049,7 @@ function optimizer(ctx, library, log) {
3038
3049
  void ctx.get("adgNotify")?.update(noticeId, { done }).catch(() => {
3039
3050
  });
3040
3051
  };
3041
- const why = (script) => script.optimize?.due === "updated" ? `\u66F4\u65B0\u5230 ${script.current ?? script.localVersion?.version ?? "\u65B0\u7248\u672C"} \u540E\u5DF2\u7ECF\u8DD1\u901A\u4E86\uFF0C\u5148\u8BFB\u66F4\u65B0\u65E5\u5FD7` : script.optimize === void 0 ? void 0 : `${script.optimize.at === void 0 ? "\u88C5\u597D\u4EE5\u6765" : "\u4E0A\u6B21\u4F18\u5316\u4EE5\u6765"}\u5DF2\u7ECF\u8DD1\u6210\u529F ${script.optimize.runs} \u6B21`;
3052
+ const why = (script) => script.optimize?.due === "updated" ? `\u66F4\u65B0\u5230 ${(script.current === "local" ? script.localVersion?.version : script.current ?? script.localVersion?.version) ?? "\u672A\u77E5\u7248\u672C"} \u540E\u5DF2\u7ECF\u8DD1\u901A\u4E86\uFF0C\u5148\u8BFB\u66F4\u65B0\u65E5\u5FD7` : script.optimize === void 0 ? void 0 : `${script.optimize.at === void 0 ? "\u88C5\u597D\u4EE5\u6765" : "\u4E0A\u6B21\u4F18\u5316\u4EE5\u6765"}\u5DF2\u7ECF\u8DD1\u6210\u529F ${script.optimize.runs} \u6B21`;
3042
3053
  const decide = async (id, decision, by) => {
3043
3054
  const lib = library();
3044
3055
  const script = lib.get(id);
@@ -3052,10 +3063,11 @@ function optimizer(ctx, library, log) {
3052
3063
  throw new Error("agent \u73B0\u5728\u4E0D\u53EF\u7528\uFF08\u4F1A\u8BDD\u670D\u52A1\u6CA1\u6709\u52A0\u8F7D\uFF09");
3053
3064
  const gateway = ctx.get("adgGateway");
3054
3065
  const conversations = sessionConversations(sessions, () => gateway?.workspaceDir(), (sessionId2, focus) => gateway?.skillScope.setFocus(sessionId2, focus) ?? Promise.resolve(), () => gateway);
3055
- const sessionId = await conversations.home(SCRIPT_ROLE.id, { focus: { scripts: [id] } });
3066
+ const work = await conversations.prepareTask(SCRIPT_ROLE.id, `\u4F18\u5316\u811A\u672C\uFF1A${script.name}`, { scripts: [id] });
3067
+ const sessionId = work.owner;
3056
3068
  const prompt = optimizeScriptPrompt(script.name, why(script), id);
3057
3069
  await lib.optimizeDone(id, "run");
3058
- void conversations.ask(sessionId, taskMessage(by, `\u4F18\u5316\u811A\u672C\uFF1A${script.name}`, prompt), AbortSignal.timeout(OPTIMIZE_TIMEOUT_MS)).catch((error) => log.warn(`optimizing ${id}: ${error instanceof Error ? error.message : String(error)}`));
3070
+ void work.run(taskMessage(by, `\u4F18\u5316\u811A\u672C\uFF1A${script.name}`, prompt), AbortSignal.timeout(OPTIMIZE_TIMEOUT_MS)).catch((error) => log.warn(`optimizing ${id}: ${error instanceof Error ? error.message : String(error)}`));
3059
3071
  close(id, "\u5DF2\u4EA4\u7ED9\u300C\u811A\u672C\u300D\u4F18\u5316\uFF0C\u811A\u672C\u5305\u7684\u6539\u52A8\u4F1A\u5728\u300C\u811A\u672C\u300D\u9875\u7B49\u4F60\u786E\u8BA4");
3060
3072
  return { sessionId };
3061
3073
  };
@@ -3987,7 +3999,8 @@ function scriptSummaries(ctx, library, log) {
3987
3999
  const material = await library.summaryMaterial(id);
3988
4000
  const name = library.get(id).name;
3989
4001
  const conversations = sessionConversations(sessions, () => ctx.get("adgGateway")?.workspaceDir(), (sessionId2, focus) => ctx.get("adgGateway")?.skillScope.setFocus(sessionId2, focus) ?? Promise.resolve(), () => ctx.get("adgGateway"));
3990
- const sessionId = await conversations.home(SCRIPT_ROLE.id, { focus: { scripts: [id] } });
4002
+ const work = await conversations.prepareTask(SCRIPT_ROLE.id, `\u811A\u672C\u4ECB\u7ECD\uFF1A${name}`, { scripts: [id] });
4003
+ const sessionId = work.owner;
3991
4004
  running.add(id);
3992
4005
  await library.setSummary(id, { state: "running", at: Date.now(), sessionId, ...previous?.text === void 0 || previous.state !== "done" ? {} : { text: previous.text } });
3993
4006
  const prompt = [
@@ -4001,7 +4014,7 @@ function scriptSummaries(ctx, library, log) {
4001
4014
  "\u6750\u6599\uFF1A",
4002
4015
  material
4003
4016
  ].join("\n");
4004
- void conversations.ask(sessionId, taskMessage("\u4F60", `\u811A\u672C\u4ECB\u7ECD\uFF1A${name}`, prompt), AbortSignal.timeout(SUMMARY_TIMEOUT_MS)).then(
4017
+ void work.run(taskMessage("\u4F60", `\u811A\u672C\u4ECB\u7ECD\uFF1A${name}`, prompt), AbortSignal.timeout(SUMMARY_TIMEOUT_MS)).then(
4005
4018
  // A turn that did not finish (no model set up, cut off) comes back as a note, not a summary.
4006
4019
  (answer) => library.setSummary(id, answer.startsWith("\uFF08\u8FD9\u4E00\u8F6E\u6CA1\u6709\u5B8C\u6210") || answer.startsWith("\uFF08agent \u6CA1\u6709\u56DE\u590D\u6587\u5B57") ? { state: "failed", at: Date.now(), sessionId, text: answer.replace(/^(这一轮没有完成:?|)$/g, "") } : { state: "done", at: Date.now(), sessionId, text: tidy(answer) }),
4007
4020
  (error) => {
@@ -4367,14 +4380,15 @@ function setupHandOff(ctx, library, log) {
4367
4380
  if (sessions === void 0)
4368
4381
  throw new Error("agent \u73B0\u5728\u4E0D\u53EF\u7528\uFF08\u4F1A\u8BDD\u670D\u52A1\u6CA1\u6709\u52A0\u8F7D\uFF09");
4369
4382
  const conversations = sessionConversations(sessions, () => ctx.get("adgGateway")?.workspaceDir(), (sessionId2, focus) => ctx.get("adgGateway")?.skillScope.setFocus(sessionId2, focus) ?? Promise.resolve(), () => ctx.get("adgGateway"));
4370
- const sessionId = await conversations.home(SCRIPT_ROLE.id, { focus: { scripts: [setup.scriptId] } });
4383
+ const work = await conversations.prepareTask(SCRIPT_ROLE.id, `\u5B89\u88C5\u811A\u672C\uFF1A${setup.name}`, { scripts: [setup.scriptId] });
4384
+ const sessionId = work.owner;
4371
4385
  log.info(`${setup.scriptId}: setup program handed to session ${sessionId}`);
4372
- await library().setSetupAgent(setup.scriptId, { sessionId, state: "running" });
4386
+ await library().setSetupAgent(setup.scriptId, { sessionId, taskId: work.id, state: "running" });
4373
4387
  const failed = async (reason) => {
4374
- if (library().pendingSetup(setup.scriptId)?.agent?.sessionId !== sessionId)
4388
+ if (library().pendingSetup(setup.scriptId)?.agent?.taskId !== work.id)
4375
4389
  return;
4376
4390
  log.warn(`${setup.scriptId}: setup session ${sessionId}: ${reason}`);
4377
- await library().setSetupAgent(setup.scriptId, { sessionId, state: "failed", reason });
4391
+ await library().setSetupAgent(setup.scriptId, { sessionId, taskId: work.id, state: "failed", reason });
4378
4392
  };
4379
4393
  void (async () => {
4380
4394
  const prompt = [
@@ -4385,7 +4399,7 @@ function setupHandOff(ctx, library, log) {
4385
4399
  "4. \u6700\u540E\u7528\u4E00\u4E24\u53E5\u8BDD\u544A\u8BC9\u7528\u6237\u7ED3\u679C\uFF08\u88C5\u5728\u54EA\u3001\u662F\u5426\u6210\u529F\uFF09\u3002",
4386
4400
  "\u4E0D\u8981\u8FD0\u884C\u88C5\u597D\u7684\u7A0B\u5E8F\uFF0C\u4E0D\u8981\u6539\u5B83\u7684\u6587\u4EF6\uFF0C\u4E0D\u8981\u5411\u7528\u6237\u63D0\u95EE\uFF1B\u505A\u4E0D\u5230\u65F6\u8BF4\u660E\u5361\u5728\u54EA\u4E00\u6B65\u3002"
4387
4401
  ].join("\n");
4388
- const answer = await conversations.ask(sessionId, taskMessage("\u4F60", `\u5B89\u88C5\u811A\u672C\uFF1A${setup.name}`, prompt), AbortSignal.timeout(SETUP_TIMEOUT_MS));
4402
+ const answer = await work.run(taskMessage("\u4F60", `\u5B89\u88C5\u811A\u672C\uFF1A${setup.name}`, prompt), AbortSignal.timeout(SETUP_TIMEOUT_MS));
4389
4403
  const cut = /^(这一轮没有完成:(.*))$/s.exec(answer.trim());
4390
4404
  await failed(cut !== null ? cut[1] : "agent \u505C\u4E0B\u4E86\uFF0C\u4F46\u6CA1\u6709\u5BFC\u5165\u88C5\u597D\u7684\u76EE\u5F55");
4391
4405
  })().catch((error) => failed(error instanceof Error ? error.message : String(error)));
@@ -22941,4 +22955,4 @@ export {
22941
22955
  AdgScripts,
22942
22956
  lib_default
22943
22957
  };
22944
- /*! For license information please see chunk-NOZCFSQP.js.LEGAL.txt */
22958
+ /*! For license information please see chunk-YTIR5JW4.js.LEGAL.txt */
package/lib/emulator.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  EMULATORS_CAPABILITY,
11
11
  EmulatorSettings
12
- } from "./chunk-F7ZQE7BT.js";
12
+ } from "./chunk-LXHF6AKU.js";
13
13
  import {
14
14
  external_exports
15
15
  } from "./chunk-6DSSLS7I.js";
package/lib/feishu.js CHANGED
@@ -2,7 +2,7 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
2
2
  import {
3
3
  replyMarkdown,
4
4
  replyPlain
5
- } from "./chunk-YSTZL6HE.js";
5
+ } from "./chunk-A6YQRWHZ.js";
6
6
  import {
7
7
  require_extension,
8
8
  require_permessage_deflate,
@@ -12,8 +12,8 @@ import {
12
12
  require_subprotocol,
13
13
  require_websocket,
14
14
  require_websocket_server
15
- } from "./chunk-OFVGRKTD.js";
16
- import "./chunk-52LYI7WP.js";
15
+ } from "./chunk-6NJSSOB6.js";
16
+ import "./chunk-KMVQK5CI.js";
17
17
  import {
18
18
  writeFileAtomic
19
19
  } from "./chunk-RESS7WVY.js";
@@ -22,7 +22,7 @@ import {
22
22
  FEISHU_SECRET_REF,
23
23
  FeishuPending,
24
24
  FeishuSettings
25
- } from "./chunk-F7ZQE7BT.js";
25
+ } from "./chunk-LXHF6AKU.js";
26
26
  import {
27
27
  external_exports
28
28
  } from "./chunk-6DSSLS7I.js";