@ai-setting/roy-agent-core 1.5.100 → 1.5.102

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 (25) hide show
  1. package/dist/env/agent/index.js +4 -4
  2. package/dist/env/event-source/index.js +4 -4
  3. package/dist/env/index.js +11 -11
  4. package/dist/env/prompt/index.js +2 -2
  5. package/dist/env/task/delegate/index.js +4 -3
  6. package/dist/env/task/index.js +5 -4
  7. package/dist/env/task/plugins/index.js +3 -3
  8. package/dist/env/tool/built-in/index.js +2 -2
  9. package/dist/env/tool/index.js +4 -4
  10. package/dist/index.js +16 -16
  11. package/dist/shared/@ai-setting/{roy-agent-core-vea84mnc.js → roy-agent-core-9ga65zcv.js} +1 -1
  12. package/dist/shared/@ai-setting/{roy-agent-core-mwb6918x.js → roy-agent-core-ac18e14n.js} +1 -1
  13. package/dist/shared/@ai-setting/{roy-agent-core-hfgqwf5w.js → roy-agent-core-k31c3kvz.js} +13 -0
  14. package/dist/shared/@ai-setting/{roy-agent-core-jhdv14ks.js → roy-agent-core-nbsw8k13.js} +6 -6
  15. package/dist/shared/@ai-setting/{roy-agent-core-09xaxtpf.js → roy-agent-core-npkwftxj.js} +11 -2
  16. package/dist/shared/@ai-setting/{roy-agent-core-0dv02z65.js → roy-agent-core-nz5wn9yc.js} +4 -2
  17. package/dist/shared/@ai-setting/roy-agent-core-pzeexnhf.js +192 -0
  18. package/dist/shared/@ai-setting/{roy-agent-core-ss92p0r6.js → roy-agent-core-s10azh5q.js} +24 -13
  19. package/dist/shared/@ai-setting/{roy-agent-core-mx9vq7b2.js → roy-agent-core-s22egcxa.js} +3 -3
  20. package/dist/shared/@ai-setting/{roy-agent-core-dj18eyyk.js → roy-agent-core-vb9aa3kf.js} +22 -1
  21. package/dist/shared/@ai-setting/{roy-agent-core-x65fyjaw.js → roy-agent-core-wg0zvwx0.js} +1 -1
  22. package/dist/shared/@ai-setting/{roy-agent-core-bdajt9cs.js → roy-agent-core-xjdcx45t.js} +7 -6
  23. package/dist/shared/@ai-setting/{roy-agent-core-0vsnecwa.js → roy-agent-core-yd9ydk9a.js} +1 -1
  24. package/package.json +2 -2
  25. package/dist/shared/@ai-setting/roy-agent-core-hvdfgvfz.js +0 -114
@@ -2,13 +2,13 @@ import {
2
2
  AgentComponent,
3
3
  AgentComponentConfigSchema,
4
4
  SummaryAgent
5
- } from "../../shared/@ai-setting/roy-agent-core-0dv02z65.js";
5
+ } from "../../shared/@ai-setting/roy-agent-core-nz5wn9yc.js";
6
6
  import"../../shared/@ai-setting/roy-agent-core-j7jeqxhd.js";
7
- import"../../shared/@ai-setting/roy-agent-core-jhdv14ks.js";
7
+ import"../../shared/@ai-setting/roy-agent-core-nbsw8k13.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
9
- import"../../shared/@ai-setting/roy-agent-core-bdajt9cs.js";
9
+ import"../../shared/@ai-setting/roy-agent-core-xjdcx45t.js";
10
10
  import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
11
- import"../../shared/@ai-setting/roy-agent-core-hfgqwf5w.js";
11
+ import"../../shared/@ai-setting/roy-agent-core-k31c3kvz.js";
12
12
  import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
13
13
  import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
14
14
  import"../../shared/@ai-setting/roy-agent-core-yfhgxh5a.js";
@@ -10,7 +10,7 @@ import {
10
10
  larkCliHandler,
11
11
  resolveBountyIMSystemPrompt,
12
12
  timerHandler
13
- } from "../../shared/@ai-setting/roy-agent-core-vea84mnc.js";
13
+ } from "../../shared/@ai-setting/roy-agent-core-9ga65zcv.js";
14
14
  import {
15
15
  BUILT_IN_EVENT_SOURCE_TYPES,
16
16
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -21,12 +21,12 @@ import {
21
21
  validateEventSourceConfig
22
22
  } from "../../shared/@ai-setting/roy-agent-core-ds5f75pg.js";
23
23
  import"../../shared/@ai-setting/roy-agent-core-wmkx79b1.js";
24
- import"../../shared/@ai-setting/roy-agent-core-mx9vq7b2.js";
25
- import"../../shared/@ai-setting/roy-agent-core-dj18eyyk.js";
24
+ import"../../shared/@ai-setting/roy-agent-core-s22egcxa.js";
26
25
  import"../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
27
26
  import"../../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
28
27
  import"../../shared/@ai-setting/roy-agent-core-4yq23m5g.js";
29
- import"../../shared/@ai-setting/roy-agent-core-bdajt9cs.js";
28
+ import"../../shared/@ai-setting/roy-agent-core-xjdcx45t.js";
29
+ import"../../shared/@ai-setting/roy-agent-core-vb9aa3kf.js";
30
30
  import"../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
31
31
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
32
32
  import"../../shared/@ai-setting/roy-agent-core-pf1c360e.js";
package/dist/env/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  BaseEnvironment
3
- } from "../shared/@ai-setting/roy-agent-core-0vsnecwa.js";
3
+ } from "../shared/@ai-setting/roy-agent-core-yd9ydk9a.js";
4
4
  import {
5
5
  EventSourceComponent,
6
6
  builtInHandlers,
7
7
  larkCliHandler
8
- } from "../shared/@ai-setting/roy-agent-core-vea84mnc.js";
8
+ } from "../shared/@ai-setting/roy-agent-core-9ga65zcv.js";
9
9
  import {
10
10
  EventSourceInitHooks,
11
11
  getDefaultConfigForType,
@@ -17,8 +17,7 @@ import"../shared/@ai-setting/roy-agent-core-wmkx79b1.js";
17
17
  import {
18
18
  PluginComponent
19
19
  } from "../shared/@ai-setting/roy-agent-core-ws76avbn.js";
20
- import"../shared/@ai-setting/roy-agent-core-mx9vq7b2.js";
21
- import"../shared/@ai-setting/roy-agent-core-dj18eyyk.js";
20
+ import"../shared/@ai-setting/roy-agent-core-s22egcxa.js";
22
21
  import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
23
22
  import {
24
23
  WorkflowComponent
@@ -42,20 +41,21 @@ import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
42
41
  import {
43
42
  AgentComponent,
44
43
  AgentComponentConfigSchema
45
- } from "../shared/@ai-setting/roy-agent-core-0dv02z65.js";
44
+ } from "../shared/@ai-setting/roy-agent-core-nz5wn9yc.js";
46
45
  import"../shared/@ai-setting/roy-agent-core-j7jeqxhd.js";
47
- import"../shared/@ai-setting/roy-agent-core-jhdv14ks.js";
46
+ import"../shared/@ai-setting/roy-agent-core-nbsw8k13.js";
48
47
  import"../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
49
- import"../shared/@ai-setting/roy-agent-core-bdajt9cs.js";
48
+ import"../shared/@ai-setting/roy-agent-core-xjdcx45t.js";
50
49
  import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
51
50
  import {
52
51
  TaskComponent
53
- } from "../shared/@ai-setting/roy-agent-core-x65fyjaw.js";
52
+ } from "../shared/@ai-setting/roy-agent-core-wg0zvwx0.js";
54
53
  import"../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
55
- import"../shared/@ai-setting/roy-agent-core-ss92p0r6.js";
56
- import"../shared/@ai-setting/roy-agent-core-hvdfgvfz.js";
54
+ import"../shared/@ai-setting/roy-agent-core-s10azh5q.js";
55
+ import"../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
57
56
  import"../shared/@ai-setting/roy-agent-core-9xby523m.js";
58
- import"../shared/@ai-setting/roy-agent-core-hfgqwf5w.js";
57
+ import"../shared/@ai-setting/roy-agent-core-vb9aa3kf.js";
58
+ import"../shared/@ai-setting/roy-agent-core-k31c3kvz.js";
59
59
  import {
60
60
  XDG_PATHS,
61
61
  getXDGPath,
@@ -3,8 +3,8 @@ import {
3
3
  PromptConfigSchema,
4
4
  PromptPathSchema,
5
5
  PromptRenderer
6
- } from "../../shared/@ai-setting/roy-agent-core-mwb6918x.js";
7
- import"../../shared/@ai-setting/roy-agent-core-dj18eyyk.js";
6
+ } from "../../shared/@ai-setting/roy-agent-core-ac18e14n.js";
7
+ import"../../shared/@ai-setting/roy-agent-core-vb9aa3kf.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
9
9
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
10
10
  import"../../shared/@ai-setting/roy-agent-core-pf1c360e.js";
@@ -3,9 +3,10 @@ import {
3
3
  BackgroundTaskManager,
4
4
  createDelegateTool,
5
5
  createStopTool
6
- } from "../../../shared/@ai-setting/roy-agent-core-ss92p0r6.js";
7
- import"../../../shared/@ai-setting/roy-agent-core-hvdfgvfz.js";
8
- import"../../../shared/@ai-setting/roy-agent-core-hfgqwf5w.js";
6
+ } from "../../../shared/@ai-setting/roy-agent-core-s10azh5q.js";
7
+ import"../../../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
8
+ import"../../../shared/@ai-setting/roy-agent-core-vb9aa3kf.js";
9
+ import"../../../shared/@ai-setting/roy-agent-core-k31c3kvz.js";
9
10
  import"../../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
10
11
  import"../../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
11
12
  import"../../../shared/@ai-setting/roy-agent-core-gp872e7m.js";
@@ -5,17 +5,18 @@ import {
5
5
  TaskPriorityEnum,
6
6
  TaskStatusEnum,
7
7
  TaskTypeEnum
8
- } from "../../shared/@ai-setting/roy-agent-core-x65fyjaw.js";
8
+ } from "../../shared/@ai-setting/roy-agent-core-wg0zvwx0.js";
9
9
  import {
10
10
  TaskEntityEventTypes
11
11
  } from "../../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
12
- import"../../shared/@ai-setting/roy-agent-core-ss92p0r6.js";
13
- import"../../shared/@ai-setting/roy-agent-core-hvdfgvfz.js";
12
+ import"../../shared/@ai-setting/roy-agent-core-s10azh5q.js";
13
+ import"../../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
14
14
  import {
15
15
  SQLiteTaskStore,
16
16
  getDefaultTaskDbPath
17
17
  } from "../../shared/@ai-setting/roy-agent-core-9xby523m.js";
18
- import"../../shared/@ai-setting/roy-agent-core-hfgqwf5w.js";
18
+ import"../../shared/@ai-setting/roy-agent-core-vb9aa3kf.js";
19
+ import"../../shared/@ai-setting/roy-agent-core-k31c3kvz.js";
19
20
  import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
20
21
  import"../../shared/@ai-setting/roy-agent-core-0ye4q2jj.js";
21
22
  import"../../shared/@ai-setting/roy-agent-core-t94ktchq.js";
@@ -7,14 +7,14 @@ import {
7
7
  formatExtractorInput,
8
8
  formatExtractorInputFromDescription,
9
9
  parseExtractorOutput
10
- } from "../../../shared/@ai-setting/roy-agent-core-mx9vq7b2.js";
11
- import"../../../shared/@ai-setting/roy-agent-core-dj18eyyk.js";
10
+ } from "../../../shared/@ai-setting/roy-agent-core-s22egcxa.js";
12
11
  import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
13
12
  import"../../../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
14
13
  import"../../../shared/@ai-setting/roy-agent-core-4yq23m5g.js";
15
14
  import {
16
15
  createAutoTaskPlugin
17
- } from "../../../shared/@ai-setting/roy-agent-core-bdajt9cs.js";
16
+ } from "../../../shared/@ai-setting/roy-agent-core-xjdcx45t.js";
17
+ import"../../../shared/@ai-setting/roy-agent-core-vb9aa3kf.js";
18
18
  import"../../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
19
19
  import"../../../shared/@ai-setting/roy-agent-core-zttjq1h3.js";
20
20
  import"../../../shared/@ai-setting/roy-agent-core-scp0afxg.js";
@@ -8,14 +8,14 @@ import {
8
8
  grepTool,
9
9
  readFileTool,
10
10
  writeFileTool
11
- } from "../../../shared/@ai-setting/roy-agent-core-09xaxtpf.js";
11
+ } from "../../../shared/@ai-setting/roy-agent-core-npkwftxj.js";
12
12
  import {
13
13
  getUnderstandImageLLMProvider,
14
14
  resetUnderstandImageLLMProvider,
15
15
  setUnderstandImageLLMProvider,
16
16
  understandImageTool
17
17
  } from "../../../shared/@ai-setting/roy-agent-core-t7rw68q8.js";
18
- import"../../../shared/@ai-setting/roy-agent-core-hvdfgvfz.js";
18
+ import"../../../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
19
19
  import"../../../shared/@ai-setting/roy-agent-core-cg146hmg.js";
20
20
  import"../../../shared/@ai-setting/roy-agent-core-vyygk314.js";
21
21
  import"../../../shared/@ai-setting/roy-agent-core-7z9b1fm8.js";
@@ -9,7 +9,7 @@ import {
9
9
  grepTool,
10
10
  readFileTool,
11
11
  writeFileTool
12
- } from "../../shared/@ai-setting/roy-agent-core-09xaxtpf.js";
12
+ } from "../../shared/@ai-setting/roy-agent-core-npkwftxj.js";
13
13
  import {
14
14
  getUnderstandImageLLMProvider,
15
15
  resetUnderstandImageLLMProvider,
@@ -22,11 +22,11 @@ import {
22
22
  ToolValidator,
23
23
  getMaxOutputSize,
24
24
  setToolConfigComponent
25
- } from "../../shared/@ai-setting/roy-agent-core-jhdv14ks.js";
25
+ } from "../../shared/@ai-setting/roy-agent-core-nbsw8k13.js";
26
26
  import"../../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
27
- import"../../shared/@ai-setting/roy-agent-core-bdajt9cs.js";
27
+ import"../../shared/@ai-setting/roy-agent-core-xjdcx45t.js";
28
28
  import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
29
- import"../../shared/@ai-setting/roy-agent-core-hvdfgvfz.js";
29
+ import"../../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
30
30
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
31
31
  import"../../shared/@ai-setting/roy-agent-core-pf1c360e.js";
32
32
  import"../../shared/@ai-setting/roy-agent-core-ksx9a556.js";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PromptComponent,
3
3
  PromptStore
4
- } from "./shared/@ai-setting/roy-agent-core-mwb6918x.js";
4
+ } from "./shared/@ai-setting/roy-agent-core-ac18e14n.js";
5
5
  import {
6
6
  LLMComponent,
7
7
  LLMConfigSchema,
@@ -26,7 +26,7 @@ import {
26
26
  grepTool,
27
27
  readFileTool,
28
28
  writeFileTool
29
- } from "./shared/@ai-setting/roy-agent-core-09xaxtpf.js";
29
+ } from "./shared/@ai-setting/roy-agent-core-npkwftxj.js";
30
30
  import {
31
31
  ATTACH_FILE_MAX_BYTES,
32
32
  getUnderstandImageLLMProvider,
@@ -62,7 +62,7 @@ import {
62
62
  BaseEnvironment,
63
63
  generateDescendingId,
64
64
  generateId
65
- } from "./shared/@ai-setting/roy-agent-core-0vsnecwa.js";
65
+ } from "./shared/@ai-setting/roy-agent-core-yd9ydk9a.js";
66
66
  import {
67
67
  BountyIMInstance,
68
68
  EventSourceComponent,
@@ -74,7 +74,7 @@ import {
74
74
  larkCliHandler,
75
75
  resolveBountyIMSystemPrompt,
76
76
  timerHandler
77
- } from "./shared/@ai-setting/roy-agent-core-vea84mnc.js";
77
+ } from "./shared/@ai-setting/roy-agent-core-9ga65zcv.js";
78
78
  import {
79
79
  BUILT_IN_EVENT_SOURCE_TYPES,
80
80
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -93,11 +93,7 @@ import {
93
93
  } from "./shared/@ai-setting/roy-agent-core-ws76avbn.js";
94
94
  import {
95
95
  TaskTagPlugin
96
- } from "./shared/@ai-setting/roy-agent-core-mx9vq7b2.js";
97
- import {
98
- getBuiltInPrompt,
99
- getBuiltInPromptNames
100
- } from "./shared/@ai-setting/roy-agent-core-dj18eyyk.js";
96
+ } from "./shared/@ai-setting/roy-agent-core-s22egcxa.js";
101
97
  import {
102
98
  BasePlugin
103
99
  } from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
@@ -132,7 +128,7 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
132
128
  import {
133
129
  AgentComponent,
134
130
  AgentComponentConfigSchema
135
- } from "./shared/@ai-setting/roy-agent-core-0dv02z65.js";
131
+ } from "./shared/@ai-setting/roy-agent-core-nz5wn9yc.js";
136
132
  import {
137
133
  createInvokeConfig,
138
134
  invoke,
@@ -143,28 +139,32 @@ import {
143
139
  ToolComponent,
144
140
  ToolRegistry,
145
141
  ToolValidator
146
- } from "./shared/@ai-setting/roy-agent-core-jhdv14ks.js";
142
+ } from "./shared/@ai-setting/roy-agent-core-nbsw8k13.js";
147
143
  import"./shared/@ai-setting/roy-agent-core-5h49ct1a.js";
148
144
  import {
149
145
  createAutoTaskPlugin
150
- } from "./shared/@ai-setting/roy-agent-core-bdajt9cs.js";
146
+ } from "./shared/@ai-setting/roy-agent-core-xjdcx45t.js";
151
147
  import {
152
148
  AskUserError,
153
149
  init_workflow_hil
154
150
  } from "./shared/@ai-setting/roy-agent-core-e25xkv53.js";
155
151
  import {
156
152
  TaskComponent
157
- } from "./shared/@ai-setting/roy-agent-core-x65fyjaw.js";
153
+ } from "./shared/@ai-setting/roy-agent-core-wg0zvwx0.js";
158
154
  import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
159
- import"./shared/@ai-setting/roy-agent-core-ss92p0r6.js";
160
- import"./shared/@ai-setting/roy-agent-core-hvdfgvfz.js";
155
+ import"./shared/@ai-setting/roy-agent-core-s10azh5q.js";
156
+ import"./shared/@ai-setting/roy-agent-core-pzeexnhf.js";
161
157
  import {
162
158
  SQLiteTaskStore,
163
159
  getDefaultTaskDbPath
164
160
  } from "./shared/@ai-setting/roy-agent-core-9xby523m.js";
161
+ import {
162
+ getBuiltInPrompt,
163
+ getBuiltInPromptNames
164
+ } from "./shared/@ai-setting/roy-agent-core-vb9aa3kf.js";
165
165
  import {
166
166
  AgentRegistry
167
- } from "./shared/@ai-setting/roy-agent-core-hfgqwf5w.js";
167
+ } from "./shared/@ai-setting/roy-agent-core-k31c3kvz.js";
168
168
  import {
169
169
  XDG_PATHS,
170
170
  getXDGPath,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TaskTagPlugin,
3
3
  createLarkCliTaskNotifyHook
4
- } from "./roy-agent-core-mx9vq7b2.js";
4
+ } from "./roy-agent-core-s22egcxa.js";
5
5
  import {
6
6
  envKeyToConfigKey
7
7
  } from "./roy-agent-core-qxhq8ven.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  builtInPrompts
3
- } from "./roy-agent-core-dj18eyyk.js";
3
+ } from "./roy-agent-core-vb9aa3kf.js";
4
4
  import {
5
5
  getXDGPath
6
6
  } from "./roy-agent-core-qxnbvgwe.js";
@@ -246,6 +246,19 @@ class AgentRegistry {
246
246
  };
247
247
  this.agents.set(name, agent);
248
248
  }
249
+ registerRoyAgent() {
250
+ const name = "roy";
251
+ if (this.agents.has(name))
252
+ return;
253
+ const agent = {
254
+ name,
255
+ type: "sub",
256
+ description: "Roy — versatile AI assistant inspired by Jarvis. Built-in general-purpose subagent for coding, research, planning, and complex multi-step tasks. Always available without `agent add roy`.",
257
+ systemPromptRef: "roy",
258
+ deniedTools: ["delegate_task", "stop_task"]
259
+ };
260
+ this.agents.set(name, agent);
261
+ }
249
262
  async load() {
250
263
  try {
251
264
  return await this.loadFromDirectory(this.configDir);
@@ -2,9 +2,9 @@ import {
2
2
  TempFileManager
3
3
  } from "./roy-agent-core-5h49ct1a.js";
4
4
  import {
5
- AUTO_TASK_METADATA_BEGIN,
6
- AUTO_TASK_METADATA_END
7
- } from "./roy-agent-core-bdajt9cs.js";
5
+ ITERATION_TASK_TRIGGER_BEGIN,
6
+ ITERATION_TASK_TRIGGER_END
7
+ } from "./roy-agent-core-xjdcx45t.js";
8
8
  import {
9
9
  AskUserError,
10
10
  init_workflow_hil
@@ -205,10 +205,10 @@ function truncateOutput(output, maxSize) {
205
205
  metadata: {}
206
206
  };
207
207
  }
208
- const beginIdx = output.indexOf(AUTO_TASK_METADATA_BEGIN);
209
- const endIdx = output.indexOf(AUTO_TASK_METADATA_END, beginIdx >= 0 ? beginIdx + AUTO_TASK_METADATA_BEGIN.length : 0);
208
+ const beginIdx = output.indexOf(ITERATION_TASK_TRIGGER_BEGIN);
209
+ const endIdx = output.indexOf(ITERATION_TASK_TRIGGER_END, beginIdx >= 0 ? beginIdx + ITERATION_TASK_TRIGGER_BEGIN.length : 0);
210
210
  if (beginIdx >= 0 && endIdx > beginIdx) {
211
- const metaEnd = endIdx + AUTO_TASK_METADATA_END.length;
211
+ const metaEnd = endIdx + ITERATION_TASK_TRIGGER_END.length;
212
212
  const metadataBlock = output.substring(beginIdx, metaEnd);
213
213
  const remainder = output.substring(0, beginIdx) + output.substring(metaEnd);
214
214
  const budget = Math.max(0, maxSize - metadataBlock.length);
@@ -4,11 +4,15 @@ import {
4
4
  import {
5
5
  getCurrentProcessRegistry,
6
6
  killProcessTree
7
- } from "./roy-agent-core-hvdfgvfz.js";
7
+ } from "./roy-agent-core-pzeexnhf.js";
8
8
  import {
9
9
  init_decorator,
10
10
  wrapFunction
11
11
  } from "./roy-agent-core-cg146hmg.js";
12
+ import {
13
+ createLogger,
14
+ init_logger
15
+ } from "./roy-agent-core-vyygk314.js";
12
16
  import {
13
17
  exports_tracer_provider,
14
18
  init_propagation,
@@ -30,6 +34,8 @@ import { Effect, Context, Layer } from "effect";
30
34
  import {
31
35
  spawn as _childProcessSpawn
32
36
  } from "child_process";
37
+ init_logger();
38
+ var logger = createLogger("bash-effect");
33
39
  var spawnInjector;
34
40
  function spawn(command, args, options) {
35
41
  if (spawnInjector) {
@@ -86,8 +92,11 @@ var makeBashSpawner = () => {
86
92
  const checkExited = () => exited || !child || !child.pid || child.killed || child.exitCode !== null;
87
93
  const currentRegistry = getCurrentProcessRegistry();
88
94
  if (currentRegistry && child.pid) {
95
+ logger.info(`[bg-process:start] pid=${child.pid} command=${command.slice(0, 80)}`);
89
96
  currentRegistry.register(child.pid);
90
- child.once("exit", () => {
97
+ child.once("exit", (code, signal) => {
98
+ const reason = signal ? `signal=${signal}` : `code=${code}`;
99
+ logger.info(`[bg-process:exit] pid=${child.pid} ${reason}`);
91
100
  currentRegistry.unregister(child.pid);
92
101
  });
93
102
  }
@@ -3,14 +3,14 @@ import {
3
3
  } from "./roy-agent-core-j7jeqxhd.js";
4
4
  import {
5
5
  truncateOutputInline
6
- } from "./roy-agent-core-jhdv14ks.js";
6
+ } from "./roy-agent-core-nbsw8k13.js";
7
7
  import {
8
8
  AskUserError,
9
9
  init_workflow_hil
10
10
  } from "./roy-agent-core-e25xkv53.js";
11
11
  import {
12
12
  AgentRegistry
13
- } from "./roy-agent-core-hfgqwf5w.js";
13
+ } from "./roy-agent-core-k31c3kvz.js";
14
14
  import {
15
15
  ContextError
16
16
  } from "./roy-agent-core-ctdhjv68.js";
@@ -343,6 +343,8 @@ class AgentComponent extends BaseComponent {
343
343
  logger.info("[AgentComponent] Registered built-in compact agent");
344
344
  this.registry.registerCompactHintAgent();
345
345
  logger.info("[AgentComponent] Registered built-in compact-hint agent");
346
+ this.registry.registerRoyAgent();
347
+ logger.info("[AgentComponent] Registered built-in roy agent");
346
348
  for (const agentDef of this.registry.list()) {
347
349
  if (!this.agents.has(agentDef.name)) {
348
350
  const systemPrompt = await this.registry.getSystemPrompt(agentDef.name);
@@ -0,0 +1,192 @@
1
+ import {
2
+ createLogger,
3
+ init_logger
4
+ } from "./roy-agent-core-vyygk314.js";
5
+
6
+ // src/env/task/delegate/process-registry.ts
7
+ import { AsyncLocalStorage } from "async_hooks";
8
+
9
+ // src/util/process/process-tree-killer.ts
10
+ init_logger();
11
+ import {
12
+ spawn as _childProcessSpawn,
13
+ spawnSync as _childProcessSpawnSync
14
+ } from "child_process";
15
+ var logger = createLogger("process-tree-killer");
16
+ var spawnInjector;
17
+ function spawn(cmd, args, opts) {
18
+ if (spawnInjector)
19
+ return spawnInjector(cmd, args, opts);
20
+ return _childProcessSpawn(cmd, args, opts);
21
+ }
22
+ var spawnSyncInjector;
23
+ function spawnSyncFn(cmd, args, opts) {
24
+ if (spawnSyncInjector)
25
+ return spawnSyncInjector(cmd, args, opts);
26
+ return _childProcessSpawnSync(cmd, args, opts);
27
+ }
28
+ var platformOverride;
29
+ function currentPlatform() {
30
+ return platformOverride ?? process.platform;
31
+ }
32
+ function isProcessAlivePosix(pid) {
33
+ try {
34
+ process.kill(pid, 0);
35
+ return true;
36
+ } catch (err) {
37
+ const code = err.code;
38
+ if (code === "ESRCH") {
39
+ return false;
40
+ }
41
+ return true;
42
+ }
43
+ }
44
+ function isProcessAliveWindows(pid) {
45
+ try {
46
+ const { stdout } = spawnSyncFn("tasklist", ["/fi", `PID eq ${pid}`, "/nh"], {
47
+ stdio: ["ignore", "pipe", "ignore"],
48
+ windowsHide: true,
49
+ timeout: 3000
50
+ });
51
+ return stdout.toString().includes(String(pid));
52
+ } catch {
53
+ return true;
54
+ }
55
+ }
56
+ function delay(ms) {
57
+ return new Promise((resolve) => setTimeout(resolve, ms));
58
+ }
59
+ async function killProcessTree(pid, options) {
60
+ if (!Number.isInteger(pid) || pid <= 0) {
61
+ throw new Error(`Invalid PID: ${pid} (must be a positive integer)`);
62
+ }
63
+ const platform = currentPlatform();
64
+ const signal = options?.signal ?? "SIGKILL";
65
+ const maxRetries = options?.retry ?? 3;
66
+ const retryDelayMs = options?.retryDelayMs ?? 500;
67
+ logger.info(`[bg-process:kill-begin] pid=${pid} signal=${signal} retry=${maxRetries} delayMs=${retryDelayMs}`);
68
+ for (let attempt = 1;attempt <= maxRetries; attempt++) {
69
+ const attemptResult = platform === "win32" ? doKillOnWindows(pid) : doKillOnPosix(pid, signal, platform);
70
+ await delay(retryDelayMs);
71
+ const alive = platform === "win32" ? isProcessAliveWindows(pid) : isProcessAlivePosix(pid);
72
+ if (!alive) {
73
+ logger.info(`[bg-process:kill-done] pid=${pid} attempts=${attempt} stillAlive=false`);
74
+ return {
75
+ pid,
76
+ platform,
77
+ signal: attemptResult.signal,
78
+ success: true,
79
+ attempts: attempt,
80
+ stillAlive: false
81
+ };
82
+ }
83
+ if (attempt < maxRetries) {
84
+ logger.warn(`[bg-process:kill-retry] pid=${pid} attempt=${attempt}/${maxRetries}`);
85
+ }
86
+ }
87
+ logger.error(`[bg-process:kill-failed] pid=${pid} attempts=${maxRetries} stillAlive=true`);
88
+ return {
89
+ pid,
90
+ platform,
91
+ signal: platform === "win32" ? "taskkill /f /t" : signal,
92
+ success: false,
93
+ attempts: maxRetries,
94
+ stillAlive: true
95
+ };
96
+ }
97
+ function doKillOnWindows(pid) {
98
+ try {
99
+ spawn("taskkill", ["/pid", String(pid), "/f", "/t"], {
100
+ stdio: "ignore",
101
+ windowsHide: true
102
+ });
103
+ return {
104
+ pid,
105
+ platform: "win32",
106
+ signal: "taskkill /f /t",
107
+ success: true
108
+ };
109
+ } catch {
110
+ return {
111
+ pid,
112
+ platform: "win32",
113
+ signal: "taskkill /f /t",
114
+ success: false
115
+ };
116
+ }
117
+ }
118
+ function doKillOnPosix(pid, signal, platform) {
119
+ try {
120
+ process.kill(-pid, signal);
121
+ return {
122
+ pid,
123
+ platform,
124
+ signal,
125
+ success: true
126
+ };
127
+ } catch (err) {
128
+ const code = err.code;
129
+ if (code === "ESRCH" || code === "EPERM") {
130
+ return {
131
+ pid,
132
+ platform,
133
+ signal,
134
+ success: true
135
+ };
136
+ }
137
+ return {
138
+ pid,
139
+ platform,
140
+ signal,
141
+ success: false
142
+ };
143
+ }
144
+ }
145
+
146
+ // src/env/task/delegate/process-registry.ts
147
+ init_logger();
148
+ var logger2 = createLogger("task:process-registry");
149
+
150
+ class ProcessRegistry {
151
+ pids = new Set;
152
+ register(pid) {
153
+ if (!Number.isInteger(pid) || pid <= 0) {
154
+ return;
155
+ }
156
+ this.pids.add(pid);
157
+ }
158
+ unregister(pid) {
159
+ if (!Number.isInteger(pid)) {
160
+ return;
161
+ }
162
+ this.pids.delete(pid);
163
+ }
164
+ size() {
165
+ return this.pids.size;
166
+ }
167
+ async killAll() {
168
+ if (this.pids.size === 0)
169
+ return;
170
+ const pidList = Array.from(this.pids);
171
+ logger2.info(`[bg-process:killAll-begin] count=${pidList.length} pids=[${pidList.join(",")}]`);
172
+ for (const pid of pidList) {
173
+ try {
174
+ const result = await killProcessTree(pid, { retry: 3, retryDelayMs: 500 });
175
+ if (result.stillAlive) {
176
+ logger2.error(`进程 PID ${pid} 经过 ${result.attempts} 次重试后仍未杀死!可能存在孤儿进程泄漏!`);
177
+ }
178
+ } catch {}
179
+ }
180
+ this.pids.clear();
181
+ logger2.info(`[bg-process:killAll-done]`);
182
+ }
183
+ }
184
+ var processRegistryStorage = new AsyncLocalStorage;
185
+ function runWithProcessRegistryAsync(registry, fn) {
186
+ return processRegistryStorage.run(registry, fn);
187
+ }
188
+ function getCurrentProcessRegistry() {
189
+ return processRegistryStorage.getStore();
190
+ }
191
+
192
+ export { killProcessTree, ProcessRegistry, runWithProcessRegistryAsync, getCurrentProcessRegistry };
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  ProcessRegistry,
3
3
  runWithProcessRegistryAsync
4
- } from "./roy-agent-core-hvdfgvfz.js";
4
+ } from "./roy-agent-core-pzeexnhf.js";
5
+ import {
6
+ builtInPrompts
7
+ } from "./roy-agent-core-vb9aa3kf.js";
5
8
  import {
6
9
  DEFAULT_SUBAGENT_PROMPT
7
- } from "./roy-agent-core-hfgqwf5w.js";
10
+ } from "./roy-agent-core-k31c3kvz.js";
8
11
  import {
9
12
  TaskHookPoints
10
13
  } from "./roy-agent-core-92z6t4he.js";
@@ -176,6 +179,14 @@ var builtInSubAgents = [
176
179
  description: "Fast agent specialized for exploring codebases, finding files, and searching for patterns.",
177
180
  allowedTools: ["read_file", "glob", "grep", "bash"],
178
181
  deniedTools: ["delegate_task", "stop_task"]
182
+ },
183
+ {
184
+ id: "roy",
185
+ name: "Roy",
186
+ mode: "subagent",
187
+ description: "Versatile AI assistant inspired by Jarvis — intelligent, proactive, and capable. Use for general-purpose tasks, coding, research, and complex multi-step work. Always available (built-in) without `agent add roy`.",
188
+ promptOverride: builtInPrompts["roy"],
189
+ deniedTools: ["delegate_task", "stop_task"]
179
190
  }
180
191
  ];
181
192
  function getSubAgentSpec(id) {
@@ -583,23 +594,23 @@ Use these as guidance to improve task execution efficiency.`;
583
594
  const isWorkflowAgent = registry?.get(subagentType)?.type === "workflow";
584
595
  const delegateQuery = isWorkflowAgent ? prompt : fullPrompt;
585
596
  return new Promise((resolve, reject) => {
586
- const killProcessTreeSafely = () => {
597
+ const killProcessTreeSafely = async () => {
587
598
  try {
588
- processRegistry?.killAll();
599
+ await processRegistry?.killAll();
589
600
  } catch (err) {
590
601
  logger.warn(`[delegate] ProcessRegistry.killAll failed`, {
591
602
  error: err instanceof Error ? err.message : String(err)
592
603
  });
593
604
  }
594
605
  };
595
- const timer = setTimeout(() => {
596
- killProcessTreeSafely();
606
+ const timer = setTimeout(async () => {
607
+ await killProcessTreeSafely();
597
608
  reject(new Error(`Task execution timeout after ${timeoutMs}ms`));
598
609
  try {
599
610
  agentComponent?.abort?.(subagentType);
600
611
  } catch {}
601
612
  }, timeoutMs);
602
- signal?.addEventListener("abort", () => {
613
+ signal?.addEventListener("abort", async () => {
603
614
  clearTimeout(timer);
604
615
  try {
605
616
  const env = this.env;
@@ -608,7 +619,7 @@ Use these as guidance to improve task execution efficiency.`;
608
619
  agentComp.abort(subagentType);
609
620
  }
610
621
  } catch {}
611
- killProcessTreeSafely();
622
+ await killProcessTreeSafely();
612
623
  reject(new Error("Task execution stopped"));
613
624
  });
614
625
  const invokeHandleQuery = () => this.env.handle_query?.(delegateQuery, {
@@ -627,7 +638,7 @@ Use these as guidance to improve task execution efficiency.`;
627
638
  });
628
639
  });
629
640
  }
630
- stopTask(taskId) {
641
+ async stopTask(taskId) {
631
642
  const task = this.tasks.get(taskId);
632
643
  if (!task) {
633
644
  return { success: false, message: "Task not found" };
@@ -643,7 +654,7 @@ Use these as guidance to improve task execution efficiency.`;
643
654
  task.abortController?.abort();
644
655
  task.completedAt = Date.now();
645
656
  try {
646
- this.processRegistries.get(taskId)?.killAll();
657
+ await this.processRegistries.get(taskId)?.killAll();
647
658
  } catch (err) {
648
659
  logger.warn(`[delegate] stopTask killAll failed`, {
649
660
  taskId,
@@ -669,7 +680,7 @@ Use these as guidance to improve task execution efficiency.`;
669
680
  listTasks() {
670
681
  return Array.from(this.tasks.values());
671
682
  }
672
- dispose() {
683
+ async dispose() {
673
684
  for (const [taskId, controller] of this.abortControllers) {
674
685
  controller.abort();
675
686
  logger.debug(`[BackgroundTaskManager] Aborted task: ${taskId}`);
@@ -677,7 +688,7 @@ Use these as guidance to improve task execution efficiency.`;
677
688
  this.abortControllers.clear();
678
689
  for (const [, registry] of this.processRegistries) {
679
690
  try {
680
- registry.killAll();
691
+ await registry.killAll();
681
692
  } catch (err) {
682
693
  logger.warn(`[BackgroundTaskManager] dispose registry.killAll failed`, {
683
694
  error: err instanceof Error ? err.message : String(err)
@@ -885,7 +896,7 @@ function createStopTool(taskManager) {
885
896
  const startTime = Date.now();
886
897
  const params = StopTaskToolParameters.parse(args);
887
898
  const { task_id } = params;
888
- const result = taskManager.stopTask(task_id);
899
+ const result = await taskManager.stopTask(task_id);
889
900
  if (result.success) {
890
901
  const task = result.task;
891
902
  const elapsedMs = task.startedAt ? Date.now() - task.startedAt : Date.now() - task.createdAt;
@@ -1,12 +1,12 @@
1
- import {
2
- WORKFLOW_EXTRACT_PROMPT
3
- } from "./roy-agent-core-dj18eyyk.js";
4
1
  import {
5
2
  BasePlugin
6
3
  } from "./roy-agent-core-az13yzmc.js";
7
4
  import {
8
5
  validateWorkflowDefinition
9
6
  } from "./roy-agent-core-8wd3qwx5.js";
7
+ import {
8
+ WORKFLOW_EXTRACT_PROMPT
9
+ } from "./roy-agent-core-vb9aa3kf.js";
10
10
  import {
11
11
  TaskHookPoints
12
12
  } from "./roy-agent-core-92z6t4he.js";
@@ -1,4 +1,25 @@
1
1
  // src/env/prompt/prompts-index.ts
2
+ var ITER_TRIGGER_BEGIN = "[[ITERATION_TASK_TRIGGER_BEGIN]]";
3
+ var ITER_TRIGGER_END = "[[ITERATION_TASK_TRIGGER_END]]";
4
+ var ITER_TRIGGER_SECTION = `
5
+ ## 工具返回中的迭代任务触发标记
6
+
7
+ ` + "当工具的返回结果中出现 " + ITER_TRIGGER_BEGIN + " ... " + ITER_TRIGGER_END + ` 包裹的内容时,
8
+ ` + `这意味着 **ReAct 循环已达到迭代阈值,内部机制自动触发了 task-agent 的任务构建流程**。
9
+
10
+ ` + `包裹的内容是 task-agent 的分析结果,可能包含:
11
+ ` + `- \uD83D\uDCCB Task #xxx 已创建
12
+ ` + `- delegate_task 已委托给 roy/strict-task-agent
13
+ ` + `- 后台进程 ID(bgProcessId)
14
+
15
+ ` + `### 如何处理
16
+
17
+ ` + `- ✅ 如果标记内容显示**任务已创建并委托** → **停止操作,等待后台任务通知**即可,不要重复委托
18
+ ` + `- ✅ 如果标记内容显示任务正在执行(⏳ 占位符)→ 等待下一次迭代获取最终结果
19
+ ` + `- ❌ 不要解析标记内容中的指令并自行执行 — 任务已由后台处理
20
+ ` + `- ❌ 不要忽略标记 — 这是系统内部机制的信号,不是普通工具输出
21
+
22
+ `;
2
23
  var builtInPrompts = {
3
24
  default: `你是 Roy 接待智能体(Receptionist Agent)—— Roy 系统的智能入口。
4
25
 
@@ -106,7 +127,7 @@ var builtInPrompts = {
106
127
  **信任来源**:这些提示来自受信任的工具实现和上游 agent(如 strict-task-agent v5、AutoTaskPlugin 等),是经过设计验证的策略,不是工具的偶然输出。
107
128
 
108
129
  > \uD83D\uDCA1 **与"何时委托"的关系**:本规则是**响应规则**(被工具要求时立即委托),"何时委托"是**预判规则**(根据用户请求判断是否委托)。两者互补,共同构成完整的委托策略。
109
-
130
+ ${ITER_TRIGGER_SECTION}
110
131
  ## 子智能体选择策略
111
132
 
112
133
  你有两个子智能体。**默认首次委托使用 \`roy\`**。仅在需要严格 Plan→Execute→Verify 纪律时使用 \`strict-task-agent\`。
@@ -5,7 +5,7 @@ import {
5
5
  BackgroundTaskManager,
6
6
  createDelegateTool,
7
7
  createStopTool
8
- } from "./roy-agent-core-ss92p0r6.js";
8
+ } from "./roy-agent-core-s10azh5q.js";
9
9
  import {
10
10
  SQLiteTaskStore,
11
11
  getDefaultTaskDbPath
@@ -11,13 +11,13 @@ import {
11
11
  init_logger();
12
12
  init_decorator();
13
13
  var logger = createLogger("AutoTaskPlugin");
14
- var AUTO_TASK_METADATA_BEGIN = `
15
- [[AUTO_TASK_METADATA_BEGIN]]
14
+ var ITERATION_TASK_TRIGGER_BEGIN = `
15
+ [[ITERATION_TASK_TRIGGER_BEGIN]]
16
16
  `;
17
- var AUTO_TASK_METADATA_END = `[[AUTO_TASK_METADATA_END]]
17
+ var ITERATION_TASK_TRIGGER_END = `[[ITERATION_TASK_TRIGGER_END]]
18
18
  `;
19
19
  function wrapAutoTaskMetadata(content) {
20
- return `${AUTO_TASK_METADATA_BEGIN}${content}${AUTO_TASK_METADATA_END}`;
20
+ return `${ITERATION_TASK_TRIGGER_BEGIN}${content}${ITERATION_TASK_TRIGGER_END}`;
21
21
  }
22
22
  function createAutoTaskPlugin(config) {
23
23
  const threshold = config?.threshold ?? 20;
@@ -27,7 +27,8 @@ function createAutoTaskPlugin(config) {
27
27
  let lastProcessedTraceId = "";
28
28
  async function executeImpl(ctx) {
29
29
  try {
30
- logger.debug(`[AutoTaskPlugin] agentName=${ctx.agent.name} (expected=${agentName})`);
30
+ logger.info(`[AutoTaskPlugin:ENTER] agentName=${ctx.agent.name} iteration=${ctx.iteration} threshold=${threshold}`);
31
+ logger.debug(`[AutoTaskPlugin] agentName=${ctx.agent.name} iteration=${ctx.iteration} threshold=${threshold}) expected=${agentName})`);
31
32
  if (ctx.agent.name !== agentName)
32
33
  return { continue: true };
33
34
  logger.debug(`[AutoTaskPlugin] iteration=${ctx.iteration} (threshold=${threshold})`);
@@ -113,4 +114,4 @@ function createAutoTaskPlugin(config) {
113
114
  };
114
115
  }
115
116
 
116
- export { AUTO_TASK_METADATA_BEGIN, AUTO_TASK_METADATA_END, createAutoTaskPlugin };
117
+ export { ITERATION_TASK_TRIGGER_BEGIN, ITERATION_TASK_TRIGGER_END, createAutoTaskPlugin };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAutoTaskPlugin
3
- } from "./roy-agent-core-bdajt9cs.js";
3
+ } from "./roy-agent-core-xjdcx45t.js";
4
4
  import {
5
5
  ContextError,
6
6
  ErrorCodes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.5.100",
3
+ "version": "1.5.102",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",
@@ -83,4 +83,4 @@
83
83
  "bugs": {
84
84
  "url": "https://github.com/ai-setting/roy-agent/issues"
85
85
  }
86
- }
86
+ }
@@ -1,114 +0,0 @@
1
- // src/env/task/delegate/process-registry.ts
2
- import { AsyncLocalStorage } from "async_hooks";
3
-
4
- // src/util/process/process-tree-killer.ts
5
- import { spawn as _childProcessSpawn } from "child_process";
6
- var spawnInjector;
7
- function spawn(cmd, args, opts) {
8
- if (spawnInjector)
9
- return spawnInjector(cmd, args, opts);
10
- return _childProcessSpawn(cmd, args, opts);
11
- }
12
- var platformOverride;
13
- function currentPlatform() {
14
- return platformOverride ?? process.platform;
15
- }
16
- function killProcessTree(pid, options) {
17
- if (!Number.isInteger(pid) || pid <= 0) {
18
- throw new Error(`Invalid PID: ${pid} (must be a positive integer)`);
19
- }
20
- const platform = currentPlatform();
21
- const signal = options?.signal ?? "SIGKILL";
22
- if (platform === "win32") {
23
- return killOnWindows(pid);
24
- }
25
- return killOnPosix(pid, signal);
26
- }
27
- function killOnWindows(pid) {
28
- try {
29
- spawn("taskkill", ["/pid", String(pid), "/f", "/t"], {
30
- stdio: "ignore",
31
- windowsHide: true
32
- });
33
- return {
34
- pid,
35
- platform: "win32",
36
- signal: "taskkill /f /t",
37
- success: true
38
- };
39
- } catch {
40
- return {
41
- pid,
42
- platform: "win32",
43
- signal: "taskkill /f /t",
44
- success: false
45
- };
46
- }
47
- }
48
- function killOnPosix(pid, signal) {
49
- const platform = currentPlatform();
50
- try {
51
- process.kill(-pid, signal);
52
- return {
53
- pid,
54
- platform,
55
- signal,
56
- success: true
57
- };
58
- } catch (err) {
59
- const code = err.code;
60
- if (code === "ESRCH" || code === "EPERM") {
61
- return {
62
- pid,
63
- platform,
64
- signal,
65
- success: true
66
- };
67
- }
68
- return {
69
- pid,
70
- platform,
71
- signal,
72
- success: false
73
- };
74
- }
75
- }
76
-
77
- // src/env/task/delegate/process-registry.ts
78
- class ProcessRegistry {
79
- pids = new Set;
80
- register(pid) {
81
- if (!Number.isInteger(pid) || pid <= 0) {
82
- return;
83
- }
84
- this.pids.add(pid);
85
- }
86
- unregister(pid) {
87
- if (!Number.isInteger(pid)) {
88
- return;
89
- }
90
- this.pids.delete(pid);
91
- }
92
- size() {
93
- return this.pids.size;
94
- }
95
- killAll() {
96
- if (this.pids.size === 0)
97
- return;
98
- for (const pid of Array.from(this.pids)) {
99
- try {
100
- killProcessTree(pid);
101
- } catch {}
102
- }
103
- this.pids.clear();
104
- }
105
- }
106
- var processRegistryStorage = new AsyncLocalStorage;
107
- function runWithProcessRegistryAsync(registry, fn) {
108
- return processRegistryStorage.run(registry, fn);
109
- }
110
- function getCurrentProcessRegistry() {
111
- return processRegistryStorage.getStore();
112
- }
113
-
114
- export { killProcessTree, ProcessRegistry, runWithProcessRegistryAsync, getCurrentProcessRegistry };