dsh-multigameassistant 2.0.4 → 2.0.5

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/lib/emulator.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  EMULATORS_CAPABILITY,
11
11
  EmulatorSettings,
12
12
  external_exports
13
- } from "./chunk-SA72K6M2.js";
13
+ } from "./chunk-BTT2GBTQ.js";
14
14
  import "./chunk-2UFLGPDY.js";
15
15
 
16
16
  // packages/emulator/lib/index.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-4PNYIZVU.js";
5
+ } from "./chunk-4Q4EH73S.js";
6
6
  import {
7
7
  require_extension,
8
8
  require_permessage_deflate,
@@ -12,7 +12,8 @@ import {
12
12
  require_subprotocol,
13
13
  require_websocket,
14
14
  require_websocket_server
15
- } from "./chunk-IZENRXQ6.js";
15
+ } from "./chunk-TD4YFQWE.js";
16
+ import "./chunk-IOBYH4RN.js";
16
17
  import {
17
18
  writeFileAtomic
18
19
  } from "./chunk-CCAB6XXZ.js";
@@ -22,7 +23,7 @@ import {
22
23
  FeishuPending,
23
24
  FeishuSettings,
24
25
  external_exports
25
- } from "./chunk-SA72K6M2.js";
26
+ } from "./chunk-BTT2GBTQ.js";
26
27
  import {
27
28
  __commonJS,
28
29
  __require,
package/lib/game-intel.js CHANGED
@@ -7,11 +7,12 @@ import {
7
7
  GAME_MANIFEST_FILE,
8
8
  GameManifest,
9
9
  parseGameManifest
10
- } from "./chunk-XHP3SLMO.js";
10
+ } from "./chunk-KHO3SRUJ.js";
11
11
  import {
12
12
  sessionConversations
13
- } from "./chunk-4PNYIZVU.js";
14
- import "./chunk-IZENRXQ6.js";
13
+ } from "./chunk-4Q4EH73S.js";
14
+ import "./chunk-TD4YFQWE.js";
15
+ import "./chunk-IOBYH4RN.js";
15
16
  import {
16
17
  writeFileAtomic
17
18
  } from "./chunk-CCAB6XXZ.js";
@@ -24,7 +25,7 @@ import {
24
25
  SHOT_IMAGE,
25
26
  external_exports,
26
27
  taskMessage
27
- } from "./chunk-SA72K6M2.js";
28
+ } from "./chunk-BTT2GBTQ.js";
28
29
  import "./chunk-2UFLGPDY.js";
29
30
 
30
31
  // packages/game-intel/lib/index.js
@@ -1622,7 +1623,8 @@ var GAME_ROLE = {
1622
1623
  order: 20,
1623
1624
  titles: ["\u6E38\u620F\u4FE1\u606F", "\u6E38\u620F\u8D44\u8BAF", "\u6DFB\u52A0\u6E38\u620F", "\u65E5\u62A5"],
1624
1625
  // Games and their screens, and what scripts ran (for the daily report); no installing, runs or pipelines.
1625
- tools: ["game_*", "screen_*", "window_*", "emulator_status", "emulator_start", "script_list", "script_tasks", "script_runs", "system_info", "skill_focus", "skill_save"],
1626
+ // skill_hub_list: its reading prompt and game_list send it there when a game's skill is missing.
1627
+ tools: ["game_*", "screen_*", "window_*", "emulator_status", "emulator_start", "script_list", "script_tasks", "script_runs", "skill_hub_list", "system_info", "skill_focus", "skill_save"],
1626
1628
  duty: [
1627
1629
  "# \u4F60\u7684\u89D2\u8272\uFF1A\u6E38\u620F",
1628
1630
  "\u4F60\u662F MultiGameAssistant \u7684\u300C\u6E38\u620F\u300Dagent\uFF1A\u8BFB\u6E38\u620F\u7684\u6D3B\u52A8\u3001\u8D44\u8BAF\u548C\u8FDB\u5EA6\u5E76\u8BB0\u4E0B\u6765\uFF08game_record\uFF09\uFF0C\u5199\u65E5\u62A5\uFF0C\u6DFB\u52A0\u6E38\u620F\u3002",
package/lib/gateway.js CHANGED
@@ -17,9 +17,10 @@ import {
17
17
  copyLabel,
18
18
  lib_default,
19
19
  streamFacts
20
- } from "./chunk-IZENRXQ6.js";
20
+ } from "./chunk-TD4YFQWE.js";
21
+ import "./chunk-IOBYH4RN.js";
21
22
  import "./chunk-CCAB6XXZ.js";
22
- import "./chunk-SA72K6M2.js";
23
+ import "./chunk-BTT2GBTQ.js";
23
24
  import "./chunk-2UFLGPDY.js";
24
25
  export {
25
26
  AGENT_PRESET,
package/lib/guard.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __adgCreateRequire } from 'node:module'; import { dirname as __adgDirname } from 'node:path'; import { fileURLToPath as __adgFileURLToPath } from 'node:url'; const require = __adgCreateRequire(import.meta.url); const __filename = __adgFileURLToPath(import.meta.url); const __dirname = __adgDirname(__filename);
2
2
  import {
3
3
  GUARD_CAPABILITY
4
- } from "./chunk-SA72K6M2.js";
4
+ } from "./chunk-BTT2GBTQ.js";
5
5
  import "./chunk-2UFLGPDY.js";
6
6
 
7
7
  // packages/guard/lib/index.js
package/lib/intervene.js CHANGED
@@ -2,8 +2,9 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
2
2
  import {
3
3
  finalText,
4
4
  sessionConversations
5
- } from "./chunk-4PNYIZVU.js";
6
- import "./chunk-IZENRXQ6.js";
5
+ } from "./chunk-4Q4EH73S.js";
6
+ import "./chunk-TD4YFQWE.js";
7
+ import "./chunk-IOBYH4RN.js";
7
8
  import {
8
9
  writeFileAtomic
9
10
  } from "./chunk-CCAB6XXZ.js";
@@ -11,7 +12,7 @@ import {
11
12
  INTERVENE_CAPABILITY,
12
13
  UPDATE_RULE,
13
14
  external_exports
14
- } from "./chunk-SA72K6M2.js";
15
+ } from "./chunk-BTT2GBTQ.js";
15
16
  import "./chunk-2UFLGPDY.js";
16
17
 
17
18
  // packages/intervene/lib/index.js
@@ -1,100 +1,73 @@
1
1
  import { createRequire as __adgCreateRequire } from 'node:module'; import { dirname as __adgDirname } from 'node:path'; import { fileURLToPath as __adgFileURLToPath } from 'node:url'; const require = __adgCreateRequire(import.meta.url); const __filename = __adgFileURLToPath(import.meta.url); const __dirname = __adgDirname(__filename);
2
2
  import {
3
- LOW_CONTEXT_WINDOW_MS
4
- } from "./chunk-SA72K6M2.js";
3
+ ARCHIVE_BATCH_MS,
4
+ MIN_SPAN_TOKENS,
5
+ Refusals,
6
+ SUMMARIES_FILE,
7
+ SummaryError,
8
+ apply,
9
+ archiveRange,
10
+ assemble,
11
+ coverOf,
12
+ eventText,
13
+ inject,
14
+ isMessage,
15
+ isPointer,
16
+ isSummaryNode,
17
+ keepSummaries,
18
+ lowContextRange,
19
+ name,
20
+ ownSummaries,
21
+ parseArchiveDays,
22
+ parseLowContext,
23
+ pointerStep,
24
+ pointerText,
25
+ refusedForSize,
26
+ settingsReader,
27
+ spanChars,
28
+ spanTokens,
29
+ summariesReader,
30
+ summarizeSpan,
31
+ summaryBudget,
32
+ summaryInstruction,
33
+ summaryTarget,
34
+ summaryText,
35
+ taskOver
36
+ } from "./chunk-IOBYH4RN.js";
37
+ import "./chunk-BTT2GBTQ.js";
5
38
  import "./chunk-2UFLGPDY.js";
6
-
7
- // packages/gateway/lib/low-context.js
8
- import { readFileSync, statSync } from "node:fs";
9
- var name = "adg-low-context";
10
- var inject = ["compaction"];
11
- var isReplace = (event) => typeof event.surfaceOp === "object" && event.surfaceOp !== null;
12
- var sourceOf = (data) => data?.source ?? {};
13
- var TYPED = /* @__PURE__ */ new Set(["user", "user-rpc"]);
14
- var SENT = /* @__PURE__ */ new Set(["notice", "relay"]);
15
- function isMessage(event) {
16
- if (event.type !== "user/message" || isReplace(event))
17
- return false;
18
- const { kind, form } = sourceOf(event.data);
19
- return TYPED.has(String(kind)) || SENT.has(String(form));
20
- }
21
- function lowContextRange(session, options) {
22
- const nodes = session.surface.nodes;
23
- const events = nodes.map((seq) => session.eventAt(seq));
24
- const first = events[0]?.type === "system/message" ? 1 : 0;
25
- const messages = [];
26
- for (let i = first; i < events.length; i++)
27
- if (events[i] !== void 0 && isMessage(events[i]))
28
- messages.push(i);
29
- if (messages.length === 0)
30
- return null;
31
- const cutoff = options.now - (options.windowMs ?? LOW_CONTEXT_WINDOW_MS);
32
- const keepFrom = messages.find((i) => events[i].time >= cutoff) ?? messages[messages.length - 1];
33
- if (keepFrom <= first)
34
- return null;
35
- if (events.slice(first, keepFrom).every((event) => event === void 0 || isReplace(event) || event.type === "system/message"))
36
- return null;
37
- return { start: nodes[first], end: nodes[keepFrom - 1] };
38
- }
39
- function parseLowContext(raw) {
40
- return raw?.lowContext === true;
41
- }
42
- function settingsReader(file) {
43
- let stamp = "";
44
- let on = false;
45
- return () => {
46
- if (file === void 0)
47
- return on;
48
- try {
49
- const stat = statSync(file);
50
- const now = `${stat.mtimeMs}:${stat.size}`;
51
- if (now !== stamp) {
52
- stamp = now;
53
- on = parseLowContext(JSON.parse(readFileSync(file, "utf8")));
54
- }
55
- } catch {
56
- stamp = "";
57
- on = false;
58
- }
59
- return on;
60
- };
61
- }
62
- function taskOver(agent, work) {
63
- if ((agent.inbox?.nextTurn?.length ?? 0) > 0 || (agent.inbox?.nextStep?.length ?? 0) > 0)
64
- return false;
65
- return work?.workPending?.(agent.session.id) !== true;
66
- }
67
- function apply(ctx, config = {}) {
68
- const log = ctx.logger("adg-low-context");
69
- const enabled = settingsReader(config.file);
70
- const engine = ctx.compaction;
71
- if (typeof engine?.compactRegion !== "function") {
72
- log.warn("this dsh compaction has no compactRegion: low-context mode is off");
73
- return;
74
- }
75
- ctx.on("agent/turn-stopping", (async ({ agent, signal }) => {
76
- if (!enabled() || signal.aborted)
77
- return;
78
- try {
79
- if (!taskOver(agent, ctx.get("adgGateway")))
80
- return;
81
- const range = lowContextRange(agent.session, { now: Date.now() });
82
- if (range === null)
83
- return;
84
- const result = await engine.compactRegion(range.start, range.end, agent, signal);
85
- log.info(`low-context: compacted ${result.shadowedSeqs.length} records (seqs ${range.start}-${range.end}) of ${agent.session.id}`);
86
- } catch (error) {
87
- log.warn(`low-context compaction of ${agent.session.id} failed: ${error instanceof Error ? error.message : String(error)}`);
88
- }
89
- }));
90
- }
91
39
  export {
40
+ ARCHIVE_BATCH_MS,
41
+ MIN_SPAN_TOKENS,
42
+ Refusals,
43
+ SUMMARIES_FILE,
44
+ SummaryError,
92
45
  apply,
46
+ archiveRange,
47
+ assemble,
48
+ coverOf,
49
+ eventText,
93
50
  inject,
94
51
  isMessage,
52
+ isPointer,
53
+ isSummaryNode,
54
+ keepSummaries,
95
55
  lowContextRange,
96
56
  name,
57
+ ownSummaries,
58
+ parseArchiveDays,
97
59
  parseLowContext,
60
+ pointerStep,
61
+ pointerText,
62
+ refusedForSize,
98
63
  settingsReader,
64
+ spanChars,
65
+ spanTokens,
66
+ summariesReader,
67
+ summarizeSpan,
68
+ summaryBudget,
69
+ summaryInstruction,
70
+ summaryTarget,
71
+ summaryText,
99
72
  taskOver
100
73
  };
package/lib/monitor.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __adgCreateRequire } from 'node:module'; import { dirname as __adgDirname } from 'node:path'; import { fileURLToPath as __adgFileURLToPath } from 'node:url'; const require = __adgCreateRequire(import.meta.url); const __filename = __adgFileURLToPath(import.meta.url); const __dirname = __adgDirname(__filename);
2
2
  import {
3
3
  parseDuration
4
- } from "./chunk-UOVFYP7C.js";
5
- import "./chunk-XHP3SLMO.js";
4
+ } from "./chunk-PAJOD6LV.js";
5
+ import "./chunk-KHO3SRUJ.js";
6
6
  import {
7
7
  writeFileAtomic
8
8
  } from "./chunk-CCAB6XXZ.js";
@@ -11,7 +11,7 @@ import {
11
11
  MONITOR_CAPABILITY,
12
12
  MonitorSettings,
13
13
  external_exports
14
- } from "./chunk-SA72K6M2.js";
14
+ } from "./chunk-BTT2GBTQ.js";
15
15
  import "./chunk-2UFLGPDY.js";
16
16
 
17
17
  // packages/monitor/lib/index.js
package/lib/notify.js CHANGED
@@ -16,10 +16,11 @@ import {
16
16
  replyPlain,
17
17
  sessionConversations,
18
18
  textReply
19
- } from "./chunk-4PNYIZVU.js";
20
- import "./chunk-IZENRXQ6.js";
19
+ } from "./chunk-4Q4EH73S.js";
20
+ import "./chunk-TD4YFQWE.js";
21
+ import "./chunk-IOBYH4RN.js";
21
22
  import "./chunk-CCAB6XXZ.js";
22
- import "./chunk-SA72K6M2.js";
23
+ import "./chunk-BTT2GBTQ.js";
23
24
  import "./chunk-2UFLGPDY.js";
24
25
  export {
25
26
  AdgNotify,
@@ -4,17 +4,18 @@ import {
4
4
  PARAMS_SCHEMA,
5
5
  parseDuration,
6
6
  taskParams
7
- } from "./chunk-UOVFYP7C.js";
7
+ } from "./chunk-PAJOD6LV.js";
8
8
  import {
9
9
  TaskInputError,
10
10
  renderTask
11
- } from "./chunk-XHP3SLMO.js";
11
+ } from "./chunk-KHO3SRUJ.js";
12
12
  import {
13
13
  MAIN,
14
14
  finalText,
15
15
  sessionConversations
16
- } from "./chunk-4PNYIZVU.js";
17
- import "./chunk-IZENRXQ6.js";
16
+ } from "./chunk-4Q4EH73S.js";
17
+ import "./chunk-TD4YFQWE.js";
18
+ import "./chunk-IOBYH4RN.js";
18
19
  import {
19
20
  writeFileAtomic
20
21
  } from "./chunk-CCAB6XXZ.js";
@@ -33,7 +34,7 @@ import {
33
34
  isMarker,
34
35
  taskMessage,
35
36
  withStartEnd
36
- } from "./chunk-SA72K6M2.js";
37
+ } from "./chunk-BTT2GBTQ.js";
37
38
  import "./chunk-2UFLGPDY.js";
38
39
 
39
40
  // packages/orchestrator/lib/index.js
@@ -225,10 +226,10 @@ function checkPipeline(pipeline, library) {
225
226
  var PIPELINE_ROLE = {
226
227
  id: "pipelines",
227
228
  name: "\u7F16\u6392",
228
- description: "\u6D41\u6C34\u7EBF\u91CC\u4EA4\u7ED9 agent \u7684\u6B65\u9AA4",
229
+ description: "\u65B0\u5EFA\u3001\u4FEE\u6539\u6D41\u6C34\u7EBF\u548C\u5B83\u4EEC\u7684\u5B9A\u65F6\uFF08\u76F4\u63A5\u4FDD\u5B58\u751F\u6548\uFF09\uFF0C\u8FD0\u884C\u6D41\u6C34\u7EBF\uFF1B\u4E5F\u505A\u6D41\u6C34\u7EBF\u91CC\u4EA4\u7ED9 agent \u7684\u6B65\u9AA4",
229
230
  order: 40,
230
231
  titles: ["\u7F16\u6392"],
231
- // What a step may need, but not starting or changing pipelines (a step inside one).
232
+ // Its own tool for pipelines is pipeline_save; drafting (pipeline_draft) is for the agents that cannot save.
232
233
  tools: [
233
234
  "script_*",
234
235
  "game_*",
@@ -236,17 +237,25 @@ var PIPELINE_ROLE = {
236
237
  "window_*",
237
238
  "emulator_*",
238
239
  "monitor_incidents",
240
+ "pipeline_save",
241
+ "pipeline_run",
239
242
  "pipeline_status",
240
243
  "pipeline_get",
241
244
  "pipeline_list",
245
+ "schedule_set",
246
+ // Timed tasks: what pipeline_save points to for "at this time, have an agent do one thing".
247
+ "schedule_task_*",
242
248
  "system_info",
243
249
  "skill_focus",
244
250
  "skill_save"
245
251
  ],
246
252
  duty: [
247
253
  "# \u4F60\u7684\u89D2\u8272\uFF1A\u7F16\u6392",
248
- "\u4F60\u662F MultiGameAssistant \u6D41\u6C34\u7EBF\u91CC\u4EA4\u7ED9 agent \u7684\u4E00\u4E2A\u6B65\u9AA4\uFF1A\u53EA\u505A\u8FD9\u4E00\u6B65\u8BF4\u7684\u4E8B\uFF0C\u505A\u5B8C\u5C31\u505C\u3002",
249
- "\u4E0D\u542F\u52A8\u3001\u4E0D\u4FEE\u6539\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6\u3002"
254
+ "\u6D41\u6C34\u7EBF\u5F52\u4F60\u7BA1\uFF1A\u65B0\u5EFA\u3001\u4FEE\u6539\u6D41\u6C34\u7EBF\u548C\u5B83\u4EEC\u7684\u5B9A\u65F6\uFF0C\u8FD0\u884C\u6D41\u6C34\u7EBF\uFF0C\u4E5F\u505A\u6D41\u6C34\u7EBF\u91CC\u4EA4\u7ED9 agent \u7684\u6B65\u9AA4\u3002",
255
+ "\u6539\u6D41\u6C34\u7EBF\u4E0D\u7528\u7B49\u7528\u6237\u5BA1\u6279\u6216\u5728\u300C\u7F16\u6392\u300D\u9875\u786E\u8BA4\uFF1A\u7528 pipeline_save \u76F4\u63A5\u4FDD\u5B58\uFF0C\u65B0\u5EFA\u7684\u3001\u7528\u6237\u4FDD\u5B58\u8FC7\u7684\u90FD\u53EF\u4EE5\uFF0C\u4FDD\u5B58\u540E\u5C31\u751F\u6548\uFF1B\u4F60\u5F00\u7684\u5B50 agent \u4E5F\u53EF\u4EE5\u8FD9\u6837\u4FDD\u5B58\u3002\u4E0D\u8981\u53BB\u6539\u6570\u636E\u76EE\u5F55\u91CC\u7684\u6D41\u6C34\u7EBF\u6587\u4EF6\uFF0C\u4E5F\u4E0D\u8981\u56E0\u4E3A\u300C\u662F\u7528\u6237\u4FDD\u5B58\u8FC7\u7684\u300D\u5C31\u9000\u56DE\u53BB\u8BA9\u7528\u6237\u81EA\u5DF1\u5728\u754C\u9762\u4E0A\u6539\u3002",
256
+ "\u6539\u5DF2\u6709\u7684\u6D41\u6C34\u7EBF\uFF1A\u5148 pipeline_get \u8BFB\u51FA\u73B0\u5728\u7684\u5B9A\u4E49\uFF0C\u53EA\u52A8\u8981\u6539\u7684\u5730\u65B9\uFF0C\u5176\u4F59\u7167\u539F\u6837\u5199\u56DE\uFF1B\u4FDD\u5B58\u540E\u770B\u8FD4\u56DE\u7684 check \u548C\u5B9A\u4E49\uFF0C\u786E\u8BA4\u6539\u52A8\u5728\u3001\u6CA1\u6709 error\uFF0C\u518D\u8BF4\u6539\u597D\u4E86\u3002\u5B9A\u65F6\u7528 schedule_set\u3002",
257
+ "\u6539\u4EC0\u4E48\u3001\u8981\u4E0D\u8981\u8FD0\u884C\uFF0C\u6309\u4EA4\u7ED9\u4F60\u8FD9\u4EF6\u4E8B\u7684\u4EBA\u8BF4\u7684\u6765\uFF1A\u8BA9\u6539\u5C31\u6539\uFF0C\u6CA1\u8BA9\u8FD0\u884C\u5C31\u4E0D\u8FD0\u884C\u3002\u5220\u6389\u8282\u70B9\u3001\u6362\u6389\u4EFB\u52A1\u8FD9\u7C7B\u4F1A\u6539\u53D8\u6BCF\u5929\u8DD1\u4EC0\u4E48\u7684\u6539\u52A8\uFF0C\u56DE\u590D\u91CC\u5199\u6E05\u695A\u6539\u4E86\u54EA\u91CC\u3002",
258
+ "\u6D88\u606F\u662F\u6D41\u6C34\u7EBF\u4EA4\u7ED9\u4F60\u7684\u4E00\u4E2A\u6B65\u9AA4\u65F6\uFF1A\u53EA\u505A\u8FD9\u4E00\u6B65\u8BF4\u7684\u4E8B\uFF0C\u505A\u5B8C\u5C31\u505C\uFF1B\u8FD9\u4E00\u6B65\u6CA1\u8BA9\u4F60\u6539\u7684\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6\u4E0D\u8981\u52A8\u3002"
250
259
  ].join("\n")
251
260
  };
252
261
  var UNATTENDED = /* @__PURE__ */ new Set(["schedule", "autostart", "after"]);
@@ -804,13 +813,15 @@ var Pipelines = class {
804
813
  return checkPipeline(pipeline, this.#library);
805
814
  }
806
815
  /**
807
- * Save (the user's save clears `draft`; the agent's keeps it).
808
- * @throws Error when the agent would overwrite a pipeline the user saved.
816
+ * Save. The user's save, and 编排's (`orchestrator`: the agent whose work
817
+ * pipelines are, and its sub-agents), is the pipeline as it now is: `draft`
818
+ * is cleared. Another agent's (`agent`) is a draft for the user to look at.
819
+ * @throws Error when a draft would overwrite a saved pipeline.
809
820
  */
810
821
  async save(input, by) {
811
822
  const existing = this.#pipelines.get(input.id);
812
823
  if (by === "agent" && existing !== void 0 && existing.draft !== true) {
813
- throw new Error(`\u5DF2\u7ECF\u6709\u4E00\u6761\u53EB ${input.id} \u7684\u6D41\u6C34\u7EBF\uFF08\u7528\u6237\u4FDD\u5B58\u8FC7\uFF09\uFF0C\u6362\u4E00\u4E2A id\uFF0C\u6216\u8BF7\u7528\u6237\u5728\u300C\u7F16\u6392\u300D\u9875\u4FEE\u6539`);
824
+ throw new Error(`\u5DF2\u7ECF\u6709\u4E00\u6761\u4FDD\u5B58\u8FC7\u7684\u6D41\u6C34\u7EBF\u53EB ${input.id}\uFF0C\u8349\u7A3F\u4E0D\u80FD\u8986\u76D6\u5B83\uFF1A\u8981\u6539\u5B83\uFF0C\u7528 agent_delegate \u4EA4\u7ED9\u300C\u7F16\u6392\u300D\uFF08\u5B83\u53EF\u4EE5\u76F4\u63A5\u4FEE\u6539\u4FDD\u5B58\uFF09\uFF1B\u8981\u53E6\u8D77\u4E00\u6761\uFF0C\u6362\u4E00\u4E2A id`);
814
825
  }
815
826
  const now = this.#now();
816
827
  const pipeline = Pipeline.parse({ ...input, createdAt: existing?.createdAt ?? now, updatedAt: now });
@@ -1106,7 +1117,7 @@ var brief = (run, pipelines) => {
1106
1117
  };
1107
1118
  var DRAFT_HELP = `\u5148\u6309 pipeline-planning \u6280\u80FD\uFF1A\u8C03\u7528 system_info \u770B\u7535\u8111\u5E26\u4E0D\u5E26\u5F97\u52A8\uFF0C\u9ED8\u8BA4\u4E00\u6B21\u53EA\u8DD1\u4E00\u4E2A\u6E38\u620F\uFF08\u4E32\u884C\uFF09\uFF0C\u4E32\u884C\u7684\u8FDE\u7EBF\u7528 always\uFF0C\u8FD9\u6837\u4E00\u4E2A\u6E38\u620F\u5931\u8D25\u4E0D\u5F71\u54CD\u540E\u9762\u7684\u3002
1108
1119
  \u6D41\u6C34\u7EBF\u662F\u4E00\u4E2A DAG\uFF1Anodes \u662F\u6B65\u9AA4\uFF0Cedges \u662F\u5148\u540E\u5173\u7CFB\uFF08from \u5B8C\u6210\u540E\u624D\u8FD0\u884C to\uFF1B\u540C\u4E00\u4E2A\u8282\u70B9\u7684\u591A\u4E2A\u4E0B\u6E38\u5E76\u884C\uFF09\u3002
1109
- \u8282\u70B9 kind\uFF1Ascript-task\uFF08\u586B script_id\u3001task_id\u3001params\uFF0Cscript_tasks \u53EF\u67E5\u4EFB\u52A1\u548C\u53C2\u6570\uFF1B\u811A\u672C\u5B58\u4E86\u591A\u4EFD\u914D\u7F6E\u65F6\u53EF\u4EE5\u586B profile \u9009\u4E00\u4EFD\uFF0Cscript_profiles \u53EF\u67E5\uFF0C\u4E0D\u586B\u7528\u811A\u672C\u5F53\u524D\u90A3\u4EFD\uFF09\u3001agent\uFF08\u586B prompt\uFF09\u3001wait\uFF08\u586B minutes\uFF0C\u6216 until \u5199 HH:MM\uFF09\u3001notify\uFF08\u586B text\uFF0C\u53D1\u98DE\u4E66\uFF09\u3001gate\uFF08\u586B text\uFF0C\u7B49\u7528\u6237\u786E\u8BA4\uFF09\u3002
1120
+ \u8282\u70B9 kind\uFF08\u300C\u5F00\u59CB\u300D\u300C\u7ED3\u675F\u300D\u4E0D\u7528\u5199\uFF0C\u7CFB\u7EDF\u4F1A\u52A0\uFF1B\u4ECE pipeline_get \u7167\u6284\u65F6\u5E26\u7740 start\u3001end \u548C\u5B83\u4EEC\u7684\u8FDE\u7EBF\u4E5F\u53EF\u4EE5\uFF09\uFF1Ascript-task\uFF08\u586B script_id\u3001task_id\u3001params\uFF0Cscript_tasks \u53EF\u67E5\u4EFB\u52A1\u548C\u53C2\u6570\uFF1B\u811A\u672C\u5B58\u4E86\u591A\u4EFD\u914D\u7F6E\u65F6\u53EF\u4EE5\u586B profile \u9009\u4E00\u4EFD\uFF0Cscript_profiles \u53EF\u67E5\uFF0C\u4E0D\u586B\u7528\u811A\u672C\u5F53\u524D\u90A3\u4EFD\uFF09\u3001agent\uFF08\u586B prompt\uFF09\u3001wait\uFF08\u586B minutes\uFF0C\u6216 until \u5199 HH:MM\uFF09\u3001notify\uFF08\u586B text\uFF0C\u53D1\u98DE\u4E66\uFF09\u3001gate\uFF08\u586B text\uFF0C\u7B49\u7528\u6237\u786E\u8BA4\uFF09\u3002
1110
1121
  \u8FDE\u7EBF when\uFF1Asuccess\uFF08\u9ED8\u8BA4\uFF09/ failure / always\u3002\u5931\u8D25\u5904\u7406\uFF1A\u8282\u70B9\u6216\u6574\u6761\u6D41\u6C34\u7EBF\u7684 retries\uFF08\u91CD\u8BD5\u6B21\u6570\uFF09\u548C then\uFF08continue \u7EE7\u7EED\u5176\u4ED6\u5206\u652F / stop \u505C\u6B62\u6D41\u6C34\u7EBF\uFF09\uFF0C\u9ED8\u8BA4\u4E0D\u91CD\u8BD5\u3001\u7EE7\u7EED\u3002
1111
1122
  \u9700\u8981\u540C\u4E00\u8D44\u6E90\uFF08\u684C\u9762\u9F20\u6807\u952E\u76D8\u3001\u540C\u4E00\u53F0\u6A21\u62DF\u5668\u3001\u540C\u4E00\u8D26\u53F7\uFF09\u7684\u5E76\u884C\u8282\u70B9\u4F1A\u81EA\u52A8\u6392\u961F\uFF0C\u4E0D\u7528\u81EA\u5DF1\u4E32\u8D77\u6765\uFF1B\u53EA\u5728\u6709\u771F\u6B63\u7684\u5148\u540E\u4F9D\u8D56\u65F6\u624D\u8FDE\u7EBF\u3002
1112
1123
  \u4F8B\uFF1AMAA\uFF08\u6A21\u62DF\u5668\uFF09\u548C\u4E09\u6708\u4E03\uFF08\u684C\u9762\uFF09\u5E76\u884C\uFF0C\u90FD\u5B8C\u6210\u540E\u53D1\u98DE\u4E66\u2014\u2014nodes\uFF1Amaa\uFF08script-task\uFF0Cscript_id maa\uFF0Ctask_id daily\uFF09\u3001m7\uFF08script-task\uFF0Cscript_id march7th\uFF0Ctask_id main\uFF09\u3001done\uFF08notify\uFF0Ctext\u300C\u65E5\u5E38\u90FD\u8DD1\u5B8C\u4E86\u300D\uFF09\uFF1Bedges\uFF1Amaa\u2192done\uFF08always\uFF09\u3001m7\u2192done\uFF08always\uFF09\u3002`;
@@ -1121,7 +1132,7 @@ var DRAFT_SCHEMA = {
1121
1132
  type: "object",
1122
1133
  properties: {
1123
1134
  id: { type: "string", description: "\u8282\u70B9 id\uFF08\u5B57\u6BCD\u6570\u5B57\uFF09\u3002" },
1124
- kind: { type: "string", enum: ["script-task", "agent", "wait", "notify", "gate"] },
1135
+ kind: { type: "string", enum: ["script-task", "agent", "wait", "notify", "gate", "start", "end"] },
1125
1136
  title: { type: "string", description: "\u540D\u79F0\uFF08\u53EF\u9009\uFF09\u3002" },
1126
1137
  script_id: { type: "string", description: "script-task\uFF1A\u811A\u672C id\u3002" },
1127
1138
  task_id: { type: "string", description: "script-task\uFF1A\u4EFB\u52A1 id\u3002" },
@@ -1161,7 +1172,7 @@ var DraftArgs = external_exports.object({
1161
1172
  description: external_exports.string().nullish(),
1162
1173
  nodes: external_exports.array(external_exports.object({
1163
1174
  id: external_exports.string(),
1164
- kind: external_exports.enum(["script-task", "agent", "wait", "notify", "gate"]),
1175
+ kind: external_exports.enum(["script-task", "agent", "wait", "notify", "gate", "start", "end"]),
1165
1176
  title: external_exports.string().nullish(),
1166
1177
  script_id: external_exports.string().nullish(),
1167
1178
  task_id: external_exports.string().nullish(),
@@ -1210,6 +1221,10 @@ function draftToPipeline(args, library) {
1210
1221
  return { ...base, kind: "notify", text: n.text ?? "" };
1211
1222
  case "gate":
1212
1223
  return { ...base, kind: "gate", text: n.text ?? "" };
1224
+ case "start":
1225
+ return { ...base, kind: "start" };
1226
+ case "end":
1227
+ return { ...base, kind: "end" };
1213
1228
  }
1214
1229
  }),
1215
1230
  edges: (args.edges ?? []).map((e) => ({ from: e.from, to: e.to, when: e.when ?? "success" })),
@@ -1219,6 +1234,23 @@ function draftToPipeline(args, library) {
1219
1234
  ...given(args.power_after) ? { powerAfter: args.power_after } : {}
1220
1235
  });
1221
1236
  }
1237
+ function changeOf(args, existing, library) {
1238
+ const next = draftToPipeline(args, library);
1239
+ const placeOf = (node) => existing.nodes.find((old) => isMarker(node) ? old.kind === node.kind : old.id === node.id)?.position;
1240
+ return {
1241
+ ...next,
1242
+ nodes: next.nodes.map((node) => {
1243
+ const position = placeOf(node);
1244
+ return position === void 0 ? node : { ...node, position };
1245
+ }),
1246
+ ...given(args.description) || existing.description === void 0 ? {} : { description: existing.description },
1247
+ ...given(args.retries) || given(args.then) ? {} : { onFailure: existing.onFailure },
1248
+ ...given(args.stop_emulator_after) ? {} : { stopEmulatorAfter: existing.stopEmulatorAfter },
1249
+ ...given(args.close_game_after) ? {} : { closeGameAfter: existing.closeGameAfter },
1250
+ ...given(args.power_after) ? {} : { powerAfter: existing.powerAfter },
1251
+ schedule: existing.schedule
1252
+ };
1253
+ }
1222
1254
  function pipelineTools(pipelines, engine, library, system = systemInfo) {
1223
1255
  const id = { type: "string", description: "\u6D41\u6C34\u7EBF id\uFF08pipeline_list \u53EF\u67E5\uFF09\u3002" };
1224
1256
  return [
@@ -1246,7 +1278,7 @@ function pipelineTools(pipelines, engine, library, system = systemInfo) {
1246
1278
  }),
1247
1279
  tool({
1248
1280
  name: "pipeline_draft",
1249
- description: `\u6309\u7528\u6237\u7684\u63CF\u8FF0\u751F\u6210\u4E00\u6761\u6D41\u6C34\u7EBF\u8349\u7A3F\u5E76\u4FDD\u5B58\uFF08\u53EA\u662F\u5230\u70B9\u8BA9\u67D0\u4E2A agent \u505A\u4E00\u4EF6\u4E8B\u3001\u6CA1\u6709\u811A\u672C\u6B65\u9AA4\u7684\uFF0C\u7528 schedule_task_save \u505A\u6210\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u4E0D\u8981\u505A\u6210\u6D41\u6C34\u7EBF\uFF09\uFF0C\u7528\u6237\u4F1A\u5728\u300C\u7F16\u6392\u300D\u9875\u770B\u5230\u3001\u53EF\u4EE5\u62D6\u62FD\u4FEE\u6539\uFF1B\u8349\u7A3F\u53EF\u4EE5\u7ACB\u5373\u7528 pipeline_run \u8FD0\u884C\uFF0C\u4F46\u7528\u6237\u5728\u754C\u9762\u91CC\u4FDD\u5B58\u4E4B\u524D\u4E0D\u4F1A\u6309\u5B9A\u65F6\u8FD0\u884C\u3002\u4E0D\u80FD\u8986\u76D6\u7528\u6237\u4FDD\u5B58\u8FC7\u7684\u6D41\u6C34\u7EBF\uFF08\u6362\u4E2A id\uFF09\u3002\u8FD4\u56DE\u8FD0\u884C\u524D\u68C0\u67E5\u7684\u7ED3\u679C\uFF0C\u6709 error \u8981\u4FEE\u6B63\u540E\u91CD\u65B0\u63D0\u4EA4\u3002
1281
+ description: `\u6309\u7528\u6237\u7684\u63CF\u8FF0\u751F\u6210\u4E00\u6761\u6D41\u6C34\u7EBF\u8349\u7A3F\u5E76\u4FDD\u5B58\uFF08\u53EA\u662F\u5230\u70B9\u8BA9\u67D0\u4E2A agent \u505A\u4E00\u4EF6\u4E8B\u3001\u6CA1\u6709\u811A\u672C\u6B65\u9AA4\u7684\uFF0C\u7528 schedule_task_save \u505A\u6210\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u4E0D\u8981\u505A\u6210\u6D41\u6C34\u7EBF\uFF09\uFF0C\u7528\u6237\u4F1A\u5728\u300C\u7F16\u6392\u300D\u9875\u770B\u5230\u3001\u53EF\u4EE5\u62D6\u62FD\u4FEE\u6539\uFF1B\u8349\u7A3F\u53EF\u4EE5\u7ACB\u5373\u7528 pipeline_run \u8FD0\u884C\uFF0C\u4F46\u7528\u6237\u5728\u754C\u9762\u91CC\u4FDD\u5B58\u4E4B\u524D\u4E0D\u4F1A\u6309\u5B9A\u65F6\u8FD0\u884C\u3002\u4E0D\u80FD\u8986\u76D6\u5DF2\u7ECF\u4FDD\u5B58\u7684\u6D41\u6C34\u7EBF\uFF1A\u8981\u6539\u90A3\u4E00\u6761\uFF0C\u7528 agent_delegate \u4EA4\u7ED9\u300C\u7F16\u6392\u300D\uFF0C\u5B83\u53EF\u4EE5\u76F4\u63A5\u6539\u597D\u4FDD\u5B58\uFF1B\u8981\u53E6\u8D77\u4E00\u6761\u5C31\u6362\u4E2A id\u3002\u8FD4\u56DE\u8FD0\u884C\u524D\u68C0\u67E5\u7684\u7ED3\u679C\uFF0C\u6709 error \u8981\u4FEE\u6B63\u540E\u91CD\u65B0\u63D0\u4EA4\u3002
1250
1282
  ${DRAFT_HELP}`,
1251
1283
  properties: DRAFT_SCHEMA,
1252
1284
  required: ["id", "name", "nodes"],
@@ -1265,6 +1297,33 @@ ${DRAFT_HELP}`,
1265
1297
  };
1266
1298
  }
1267
1299
  }),
1300
+ tool({
1301
+ name: "pipeline_save",
1302
+ description: `\u4FDD\u5B58\u4E00\u6761\u6D41\u6C34\u7EBF\uFF0C\u76F4\u63A5\u751F\u6548\uFF0C\u4E0D\u7528\u7528\u6237\u518D\u786E\u8BA4\uFF1A\u65B0\u5EFA\u4E00\u6761\uFF0C\u6216\u8005\u6309 id \u4FEE\u6539\u5DF2\u6709\u7684\u4E00\u6761\uFF08\u7528\u6237\u4FDD\u5B58\u8FC7\u7684\u3001\u8349\u7A3F\u90FD\u53EF\u4EE5\uFF1B\u8349\u7A3F\u4FDD\u5B58\u540E\u5C31\u4E0D\u518D\u662F\u8349\u7A3F\uFF09\u3002\u53EA\u662F\u5230\u70B9\u8BA9\u67D0\u4E2A agent \u505A\u4E00\u4EF6\u4E8B\u3001\u6CA1\u6709\u811A\u672C\u6B65\u9AA4\u7684\uFF0C\u7528 schedule_task_save \u505A\u6210\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u4E0D\u8981\u505A\u6210\u6D41\u6C34\u7EBF\u3002
1303
+ \u4FEE\u6539\u5DF2\u6709\u7684\uFF1A\u5148 pipeline_get \u8BFB\u51FA\u73B0\u5728\u7684\u5B9A\u4E49\uFF0C\u5728\u5B83\u4E0A\u9762\u6539\uFF1Bnodes \u548C edges \u8981\u5199\u5168\uFF0C\u6CA1\u5199\u7684\u8282\u70B9\u548C\u8FDE\u7EBF\u4F1A\u88AB\u53BB\u6389\uFF0C\u8282\u70B9\u539F\u6709\u7684 retries\u3001then\u3001wait_for_all \u4E5F\u8981\u7167\u6837\u5199\u4E0A\u3002\u5B9A\u65F6\uFF08\u7528 schedule_set \u6539\uFF09\u548C\u8282\u70B9\u5728\u753B\u5E03\u4E0A\u7684\u4F4D\u7F6E\u4FDD\u6301\u4E0D\u53D8\uFF1Bdescription\u3001retries\u3001then\u3001stop_emulator_after\u3001close_game_after\u3001power_after \u6CA1\u586B\u7684\u4FDD\u6301\u539F\u503C\u3002\u6B63\u5728\u8FD0\u884C\u7684\u90A3\u4E00\u6B21\u4E0D\u53D7\u5F71\u54CD\uFF0C\u4E0B\u4E00\u6B21\u8FD0\u884C\u7528\u65B0\u7684\u5B9A\u4E49\u3002
1304
+ \u8FD4\u56DE\u8FD0\u884C\u524D\u68C0\u67E5\u7684\u7ED3\u679C\u548C\u4FDD\u5B58\u540E\u7684\u5B9A\u4E49\uFF1B\u6709 error \u65F6\u4E5F\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u4F46\u8FD0\u884C\u4F1A\u88AB\u62D2\u7EDD\uFF0C\u8981\u4FEE\u6B63\u540E\u91CD\u65B0\u63D0\u4EA4\u3002
1305
+ ${DRAFT_HELP}`,
1306
+ properties: DRAFT_SCHEMA,
1307
+ required: ["id", "name", "nodes"],
1308
+ kind: "other",
1309
+ title: (a) => `\u4FDD\u5B58\u6D41\u6C34\u7EBF\uFF1A${String(a["name"] ?? "")}`,
1310
+ execute: async (args) => {
1311
+ const a = parse(DraftArgs, args);
1312
+ const existing = pipelines.has(a.id) ? pipelines.get(a.id) : void 0;
1313
+ const input = parse(Pipeline, existing === void 0 ? draftToPipeline(a, library) : changeOf(a, existing, library));
1314
+ const { pipeline, check } = await pipelines.save(input, "orchestrator");
1315
+ const link = `#/p/pipelines/${encodeURIComponent(pipeline.id)}`;
1316
+ return {
1317
+ ok: check.ok,
1318
+ id: pipeline.id,
1319
+ saved: existing === void 0 ? "created" : "updated",
1320
+ pipeline,
1321
+ check,
1322
+ link,
1323
+ next: check.ok ? `\u5DF2\u7ECF\u4FDD\u5B58\u5E76\u751F\u6548\u3002\u56DE\u590D\u91CC\u8BF4\u6E05\u695A\u6539\u4E86\u4EC0\u4E48\uFF0C\u9644\u4E0A\u94FE\u63A5 [\u5728\u7F16\u6392\u9875\u6253\u5F00](${link})\uFF1B\u5B9A\u65F6\u7528 schedule_set \u8BBE\u7F6E` : "\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u4F46 check.issues \u91CC\u6709 error\uFF0C\u8FD0\u884C\u4F1A\u88AB\u62D2\u7EDD\uFF1A\u4FEE\u6B63\u540E\u91CD\u65B0\u63D0\u4EA4"
1324
+ };
1325
+ }
1326
+ }),
1268
1327
  tool({
1269
1328
  name: "pipeline_run",
1270
1329
  description: "\u8FD0\u884C\u4E00\u6761\u6D41\u6C34\u7EBF\u3002\u7ACB\u5373\u8FD4\u56DE run_id\uFF1Bwait \u4E3A true \u65F6\u7B49\u5230\u7ED3\u675F\uFF08\u6700\u957F 6 \u5C0F\u65F6\uFF09\u3002\u540C\u4E00\u6761\u6D41\u6C34\u7EBF\u6B63\u5728\u8FD0\u884C\u65F6\u4F1A\u62D2\u7EDD\u3002\u7528\u6237\u8BF4\u300C\u4ECE\u67D0\u4E00\u6B65\u5F00\u59CB\u300D\u300C\u524D\u9762\u7684\u5DF2\u7ECF\u8DD1\u8FC7\u4E86\u300D\u65F6\u7528 from_node\uFF1A\u8FD9\u4E2A\u8282\u70B9\u548C\u5B83\u540E\u9762\u7684\u4F1A\u8FD0\u884C\uFF0C\u524D\u9762\u7684\u4E0D\u8FD0\u884C\u3002",
@@ -1313,7 +1372,7 @@ ${DRAFT_HELP}`,
1313
1372
  }),
1314
1373
  tool({
1315
1374
  name: "schedule_set",
1316
- description: "\u8BBE\u7F6E\u4E00\u6761\u6D41\u6C34\u7EBF\u7684\u5B9A\u65F6\uFF1A\u6BCF\u5929\uFF08\u6216\u6307\u5B9A\u661F\u671F\u51E0\uFF09\u7684\u51E0\u4E2A\u65F6\u95F4\u70B9\u81EA\u52A8\u8FD0\u884C\uFF1B\u9519\u8FC7\u4E0D\u8D85\u8FC7 catch_up_minutes \u5206\u949F\uFF08\u7535\u8111\u7761\u7720\u3001\u521A\u5F00\u673A\uFF09\u4F1A\u8865\u8DD1\u3002\u7528\u6237\u8BF4\u300C\u6BCF\u5929\u56DB\u70B9\u534A\u8DD1\u65E5\u5E38\u300D\u65F6\u4F7F\u7528\u3002\u8349\u7A3F\u8981\u7528\u6237\u5728\u754C\u9762\u4FDD\u5B58\u540E\u624D\u4F1A\u6309\u5B9A\u65F6\u8FD0\u884C\u3002",
1375
+ description: "\u8BBE\u7F6E\u4E00\u6761\u6D41\u6C34\u7EBF\u7684\u5B9A\u65F6\uFF1A\u6BCF\u5929\uFF08\u6216\u6307\u5B9A\u661F\u671F\u51E0\uFF09\u7684\u51E0\u4E2A\u65F6\u95F4\u70B9\u81EA\u52A8\u8FD0\u884C\uFF1B\u9519\u8FC7\u4E0D\u8D85\u8FC7 catch_up_minutes \u5206\u949F\uFF08\u7535\u8111\u7761\u7720\u3001\u521A\u5F00\u673A\uFF09\u4F1A\u8865\u8DD1\u3002\u7528\u6237\u8BF4\u300C\u6BCF\u5929\u56DB\u70B9\u534A\u8DD1\u65E5\u5E38\u300D\u65F6\u4F7F\u7528\u3002\u8349\u7A3F\u8981\u4FDD\u5B58\u540E\u624D\u4F1A\u6309\u5B9A\u65F6\u8FD0\u884C\uFF08\u7528\u6237\u5728\u300C\u7F16\u6392\u300D\u9875\u4FDD\u5B58\uFF0C\u6216\u300C\u7F16\u6392\u300D\u7528 pipeline_save \u4FDD\u5B58\uFF09\u3002",
1317
1376
  properties: {
1318
1377
  id,
1319
1378
  enabled: { type: "boolean", description: "\u5F00\u542F\u6216\u5173\u95ED\u5B9A\u65F6\u3002" },
@@ -1335,7 +1394,7 @@ ${DRAFT_HELP}`,
1335
1394
  ...a.catch_up_minutes == null ? {} : { catchUpMinutes: a.catch_up_minutes }
1336
1395
  };
1337
1396
  const { pipeline } = await pipelines.save({ ...current, schedule }, current.draft === true ? "agent" : "user");
1338
- return { ok: true, schedule: pipeline.schedule, note: pipeline.draft === true ? "\u8FD9\u662F\u8349\u7A3F\uFF1A\u7528\u6237\u5728\u300C\u7F16\u6392\u300D\u9875\u4FDD\u5B58\u540E\u624D\u4F1A\u6309\u5B9A\u65F6\u8FD0\u884C" : void 0 };
1397
+ return { ok: true, schedule: pipeline.schedule, note: pipeline.draft === true ? "\u8FD9\u662F\u8349\u7A3F\uFF1A\u4FDD\u5B58\u540E\u624D\u4F1A\u6309\u5B9A\u65F6\u8FD0\u884C\uFF08\u7528\u6237\u5728\u300C\u7F16\u6392\u300D\u9875\u4FDD\u5B58\uFF0C\u6216\u300C\u7F16\u6392\u300D\u7528 pipeline_save \u4FDD\u5B58\uFF09" : void 0 };
1339
1398
  }
1340
1399
  }),
1341
1400
  tool({
@@ -1525,12 +1584,19 @@ var AdgOrchestrator = class extends Service {
1525
1584
  });
1526
1585
  ctx.inject(["adgGateway"], (gateway) => gateway.adgGateway.agentPart("adg-orchestrator tools", (agent) => {
1527
1586
  const registered = [];
1587
+ const mayNot = (name, session) => name !== "pipeline_save" || session !== void 0 && ctx.get("adgGateway")?.leadOf(session) === PIPELINE_ROLE.id ? void 0 : `\u53EA\u6709\u300C${PIPELINE_ROLE.name}\u300D\u548C\u5B83\u7684\u5B50 agent \u80FD\u76F4\u63A5\u4FDD\u5B58\u6D41\u6C34\u7EBF\uFF1A\u7528 agent_delegate \u628A\u8981\u6539\u7684\u4EA4\u7ED9\u300C${PIPELINE_ROLE.name}\u300D\uFF0C\u6216\u8005\u7528 pipeline_draft \u8D77\u8349\u4E00\u6761\u7ED9\u7528\u6237\u786E\u8BA4`;
1528
1588
  for (const tool2 of [...pipelineTools(pipelines, engine, library), ...taskTools(tasks, () => ctx.get("adgGateway")?.roles.list() ?? [])]) {
1529
- registered.push(agent.tools.register({ ...tool2, execute: async (args, exec) => {
1530
- await this.ready;
1531
- await ctx.get("adgGateway")?.guardTool(exec);
1532
- return tool2.execute(args, exec);
1533
- } }));
1589
+ registered.push(agent.tools.register({
1590
+ ...tool2,
1591
+ execute: async (args, exec) => {
1592
+ await this.ready;
1593
+ const refusal = mayNot(tool2.name, exec.agent?.session.id);
1594
+ if (refusal !== void 0)
1595
+ throw new Error(refusal);
1596
+ await ctx.get("adgGateway")?.guardTool(exec);
1597
+ return tool2.execute(args, exec);
1598
+ }
1599
+ }));
1534
1600
  }
1535
1601
  return () => {
1536
1602
  for (const dispose of registered)