@ai-setting/roy-agent-core 1.5.84 → 1.5.86

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 (27) hide show
  1. package/dist/env/agent/index.js +2 -2
  2. package/dist/env/event-source/index.js +8 -4
  3. package/dist/env/index.js +10 -11
  4. package/dist/env/prompt/index.js +1 -1
  5. package/dist/env/task/delegate/index.js +2 -2
  6. package/dist/env/task/index.js +3 -3
  7. package/dist/env/workflow/engine/index.js +3 -4
  8. package/dist/env/workflow/index.js +4 -5
  9. package/dist/env/workflow/tools/index.js +1 -1
  10. package/dist/index.js +17 -14
  11. package/dist/shared/@ai-setting/{roy-agent-core-whw7jap0.js → roy-agent-core-1db4vpc6.js} +3 -2
  12. package/dist/shared/@ai-setting/{roy-agent-core-m4qjnhz6.js → roy-agent-core-5kdw0p98.js} +114 -68
  13. package/dist/shared/@ai-setting/{roy-agent-core-ya1ayt1k.js → roy-agent-core-6mk0m4t3.js} +218 -4
  14. package/dist/shared/@ai-setting/{roy-agent-core-mbre4fxg.js → roy-agent-core-7z4xtrmw.js} +16 -0
  15. package/dist/shared/@ai-setting/{roy-agent-core-f6p7wwpd.js → roy-agent-core-bgw4dq11.js} +2 -7
  16. package/dist/shared/@ai-setting/{roy-agent-core-qjv8537d.js → roy-agent-core-bk5g94yd.js} +1 -1
  17. package/dist/shared/@ai-setting/{roy-agent-core-bt7wezvg.js → roy-agent-core-dp73ghtz.js} +5 -16
  18. package/dist/shared/@ai-setting/{roy-agent-core-6b0r2e7j.js → roy-agent-core-gttz2jpm.js} +15 -52
  19. package/dist/shared/@ai-setting/{roy-agent-core-akepggsr.js → roy-agent-core-mmkyydw7.js} +26 -1
  20. package/dist/shared/@ai-setting/{roy-agent-core-xb4hvk1m.js → roy-agent-core-qhhxx2x2.js} +2 -1
  21. package/dist/shared/@ai-setting/{roy-agent-core-9mj7vzsm.js → roy-agent-core-vneyghpg.js} +1 -1
  22. package/dist/shared/@ai-setting/{roy-agent-core-nc0n0bdc.js → roy-agent-core-xckhrs2p.js} +2 -3
  23. package/dist/shared/@ai-setting/{roy-agent-core-015vw11k.js → roy-agent-core-yx0vw1aw.js} +8 -6
  24. package/package.json +1 -1
  25. package/dist/shared/@ai-setting/roy-agent-core-7z8fzxck.js +0 -265
  26. package/dist/shared/@ai-setting/roy-agent-core-qf9gvx02.js +0 -39
  27. /package/dist/shared/@ai-setting/{roy-agent-core-2grcjaad.js → roy-agent-core-4f3976cd.js} +0 -0
@@ -20,7 +20,8 @@ import {
20
20
  runWithEnvContext
21
21
  } from "./roy-agent-core-y5d04fm3.js";
22
22
  import {
23
- TracedAs
23
+ TracedAs,
24
+ init_decorator
24
25
  } from "./roy-agent-core-k05v31rc.js";
25
26
  import {
26
27
  createLogger,
@@ -34,6 +35,163 @@ import {
34
35
  __require
35
36
  } from "./roy-agent-core-fs0mn2jk.js";
36
37
 
38
+ // src/env/event-source/timer-handler.ts
39
+ init_decorator();
40
+ var DEFAULT_TIMER_INTERVAL_MS = 10 * 60 * 1000;
41
+ var SELF_REMINDER_MESSAGE = `[Timer Self-Reminder]
42
+ 请读取最近 1 周处理的 task 信息,分析用户当前的工作目标和重点任务。
43
+ 基于分析结果,自主构建有价值的任务来推进用户目标。
44
+
45
+ 分析维度:
46
+ 1. 最近完成的 task 类型和主题
47
+ 2. 进行中的 task 状态和阻塞点
48
+ 3. 用户的工作模式和偏好
49
+ 4. 可以主动优化的领域
50
+
51
+ 请根据分析结果,创建 1-3 个有价值的任务并执行。`;
52
+ var TIMER_OPTIONS_KEY_GET_MANAGER = "getBackgroundTaskManager";
53
+
54
+ class TimerInstance {
55
+ config;
56
+ interval;
57
+ sessionId;
58
+ getRunningTasks;
59
+ customPrompt;
60
+ status = "created";
61
+ timerId;
62
+ eventHandler;
63
+ constructor(config, getRunningTasks) {
64
+ this.config = config;
65
+ this.interval = typeof config.interval === "number" && config.interval > 0 ? config.interval : DEFAULT_TIMER_INTERVAL_MS;
66
+ this.sessionId = `timer-${config.id}-${process.pid}`;
67
+ const optionsPrompt = config.options?.prompt;
68
+ if (typeof optionsPrompt === "string" && optionsPrompt.trim().length > 0) {
69
+ this.customPrompt = optionsPrompt;
70
+ }
71
+ if (getRunningTasks) {
72
+ this.getRunningTasks = getRunningTasks;
73
+ } else {
74
+ const factory = config.options?.[TIMER_OPTIONS_KEY_GET_MANAGER];
75
+ if (typeof factory === "function") {
76
+ const manager = factory();
77
+ this.getRunningTasks = () => manager.listTasks();
78
+ } else {
79
+ this.getRunningTasks = () => [];
80
+ }
81
+ }
82
+ }
83
+ async start() {
84
+ if (this.status === "running")
85
+ return;
86
+ this.timerId = setInterval(() => {
87
+ this.tick();
88
+ }, this.interval);
89
+ this.status = "running";
90
+ }
91
+ async stop() {
92
+ if (this.timerId !== undefined) {
93
+ clearInterval(this.timerId);
94
+ this.timerId = undefined;
95
+ }
96
+ this.status = "stopped";
97
+ }
98
+ getStatus() {
99
+ return this.status;
100
+ }
101
+ onEvent(handler) {
102
+ this.eventHandler = handler;
103
+ }
104
+ offEvent() {
105
+ this.eventHandler = undefined;
106
+ }
107
+ tick() {
108
+ let allTasks;
109
+ try {
110
+ allTasks = this.getRunningTasks();
111
+ } catch (error) {
112
+ console.warn(`[TimerInstance] Failed to get running tasks, skipping tick: ${error}`);
113
+ return;
114
+ }
115
+ const hasRunning = Array.isArray(allTasks) && allTasks.some((t) => t.status === "running");
116
+ if (hasRunning) {
117
+ return;
118
+ }
119
+ const event = this.buildSelfReminderEvent();
120
+ this.eventHandler?.(event);
121
+ }
122
+ buildSelfReminderEvent() {
123
+ const timestamp = Date.now();
124
+ const message = this.customPrompt ?? SELF_REMINDER_MESSAGE;
125
+ return {
126
+ id: `es-${this.config.id}-${timestamp}-${Math.random().toString(36).slice(2, 8)}`,
127
+ type: "event-source.event.timer",
128
+ timestamp,
129
+ metadata: {
130
+ source: "event-source",
131
+ sourceId: this.config.id,
132
+ sourceMessageType: "timer.selfReminder",
133
+ sessionId: this.sessionId
134
+ },
135
+ payload: {
136
+ sourceId: this.config.id,
137
+ sourceType: "timer",
138
+ rawEvent: {
139
+ type: "timer.selfReminder",
140
+ triggeredAt: timestamp
141
+ },
142
+ message,
143
+ metadata: {
144
+ eventType: "timer.selfReminder",
145
+ sourceId: this.config.id,
146
+ sourceType: "timer",
147
+ timestamp
148
+ },
149
+ timestamp
150
+ }
151
+ };
152
+ }
153
+ }
154
+ __legacyDecorateClassTS([
155
+ TracedAs("timer.tick", { recordParams: false, log: false })
156
+ ], TimerInstance.prototype, "tick", null);
157
+ __legacyDecorateClassTS([
158
+ TracedAs("timer.buildSelfReminderEvent", { recordParams: false, log: false })
159
+ ], TimerInstance.prototype, "buildSelfReminderEvent", null);
160
+ var timerHandler = {
161
+ type: "timer",
162
+ validateConfig(config) {
163
+ const errors = [];
164
+ const { interval } = config;
165
+ if (interval !== undefined && interval !== null) {
166
+ if (typeof interval !== "number" || !Number.isFinite(interval)) {
167
+ errors.push("Timer interval must be a finite number");
168
+ } else if (interval <= 0) {
169
+ errors.push("Timer interval must be a positive number (milliseconds)");
170
+ }
171
+ }
172
+ return errors;
173
+ },
174
+ createInstance(config) {
175
+ return new TimerInstance(config);
176
+ },
177
+ getOptions() {
178
+ return [
179
+ {
180
+ name: "interval",
181
+ description: `Timer interval in milliseconds (default: ${DEFAULT_TIMER_INTERVAL_MS} = 10 minutes)`,
182
+ required: false,
183
+ type: "number"
184
+ },
185
+ {
186
+ name: "prompt",
187
+ description: "Custom prompt message for SelfReminder events (replaces default message)",
188
+ required: false,
189
+ type: "string"
190
+ }
191
+ ];
192
+ }
193
+ };
194
+
37
195
  // src/env/event-source/event-source-handlers.ts
38
196
  init_global_hook_manager();
39
197
  import { spawn } from "child_process";
@@ -543,7 +701,8 @@ var larkCliHandler = {
543
701
  }
544
702
  };
545
703
  var builtInHandlers = [
546
- larkCliHandler
704
+ larkCliHandler,
705
+ timerHandler
547
706
  ];
548
707
  function getBuiltInHandler(type) {
549
708
  return builtInHandlers.find((h) => h.type === type);
@@ -553,6 +712,7 @@ function getBuiltInHandler(type) {
553
712
  import { join } from "path";
554
713
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
555
714
  init_logger();
715
+ init_decorator();
556
716
 
557
717
  // src/env/event-source/event-source-config-registration.ts
558
718
  var EVENT_SOURCE_DEFAULTS = {
@@ -644,7 +804,7 @@ class EventSourceComponent extends BaseComponent {
644
804
  }
645
805
  }
646
806
  async executeInitHooks() {
647
- const { EventSourceInitHooks } = await import("./roy-agent-core-9mj7vzsm.js");
807
+ const { EventSourceInitHooks } = await import("./roy-agent-core-vneyghpg.js");
648
808
  await EventSourceInitHooks.execute(this);
649
809
  }
650
810
  registerHandler(handler) {
@@ -790,6 +950,57 @@ class EventSourceComponent extends BaseComponent {
790
950
  }
791
951
  return existed;
792
952
  }
953
+ async update(id, partial) {
954
+ if (!partial || Object.keys(partial).length === 0) {
955
+ throw new Error("update() partial must not be empty");
956
+ }
957
+ const existing = this.sources.get(id);
958
+ if (!existing) {
959
+ throw new Error(`EventSource not found: ${id}`);
960
+ }
961
+ if (Object.prototype.hasOwnProperty.call(partial, "type")) {
962
+ if (partial.type !== existing.type) {
963
+ throw new Error(`Cannot update event source type: ${existing.type} -> ${partial.type} (use unregister + register instead)`);
964
+ }
965
+ }
966
+ const wasRunning = this.statuses.get(id) === "running";
967
+ let stopped = false;
968
+ if (wasRunning) {
969
+ await this.stopSource(id);
970
+ stopped = true;
971
+ }
972
+ const updated = {
973
+ ...existing,
974
+ ...partial,
975
+ id: existing.id,
976
+ type: existing.type
977
+ };
978
+ const handler = this.handlers.get(existing.type);
979
+ if (handler) {
980
+ const errors = handler.validateConfig(updated);
981
+ if (errors.length > 0) {
982
+ throw new Error(`Invalid config after update: ${errors.join(", ")}`);
983
+ }
984
+ }
985
+ this.sources.set(id, updated);
986
+ logger.info(`EventSource updated: ${id}`, {
987
+ fields: Object.keys(partial)
988
+ });
989
+ try {
990
+ await this.saveConfig();
991
+ } catch (err) {
992
+ logger.error(`Failed to save config after updating ${id}:`, err);
993
+ throw err;
994
+ }
995
+ return {
996
+ id,
997
+ updated,
998
+ wasRunning,
999
+ stopped,
1000
+ restarted: false,
1001
+ fields: Object.keys(partial)
1002
+ };
1003
+ }
793
1004
  get(id) {
794
1005
  return this.sources.get(id);
795
1006
  }
@@ -931,5 +1142,8 @@ class EventSourceComponent extends BaseComponent {
931
1142
  }
932
1143
  }
933
1144
  }
1145
+ __legacyDecorateClassTS([
1146
+ TracedAs("event-source.update", { recordParams: false, log: false })
1147
+ ], EventSourceComponent.prototype, "update", null);
934
1148
 
935
- export { larkCliHandler, builtInHandlers, getBuiltInHandler, EventSourceComponent };
1149
+ export { TimerInstance, timerHandler, larkCliHandler, builtInHandlers, getBuiltInHandler, EventSourceComponent };
@@ -177,6 +177,22 @@ class AgentRegistry {
177
177
  };
178
178
  this.agents.set(name, agent);
179
179
  }
180
+ registerJsonExtractAgent() {
181
+ const name = "json-extract";
182
+ if (this.agents.has(name))
183
+ return;
184
+ const agent = {
185
+ name,
186
+ type: "sub",
187
+ description: "JSON 提取子智能体 — 从父 session 历史中提取结构化 JSON,通过 workflow_submit_output 工具提交",
188
+ systemPromptRef: "json-extract",
189
+ allowedTools: ["workflow_submit_output"],
190
+ deniedTools: [],
191
+ maxIterations: 1,
192
+ filterHistory: false
193
+ };
194
+ this.agents.set(name, agent);
195
+ }
180
196
  async load() {
181
197
  try {
182
198
  return await this.loadFromDirectory(this.configDir);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_SUBAGENT_PROMPT
3
- } from "./roy-agent-core-mbre4fxg.js";
3
+ } from "./roy-agent-core-7z4xtrmw.js";
4
4
  import {
5
5
  TaskHookPoints
6
6
  } from "./roy-agent-core-92z6t4he.js";
@@ -238,7 +238,7 @@ ${originalPrompt}
238
238
  `;
239
239
  }
240
240
  var DEFAULT_TIMEOUT = 1800000;
241
- var PROGRESS_INTERVAL = 120000;
241
+ var PROGRESS_INTERVAL = 600000;
242
242
 
243
243
  class BackgroundTaskManager {
244
244
  env;
@@ -442,10 +442,6 @@ class BackgroundTaskManager {
442
442
  this.stopProgressReporter(taskId);
443
443
  return;
444
444
  }
445
- if (task.startedAt) {
446
- const elapsedMs = Date.now() - task.startedAt;
447
- task.progress = Math.min(95, Math.floor(elapsedMs / PROGRESS_INTERVAL * 100));
448
- }
449
445
  const currentTaskId = getCurrentTaskId();
450
446
  if (currentTaskId !== undefined) {
451
447
  task.associatedTaskId = currentTaskId;
@@ -456,7 +452,6 @@ class BackgroundTaskManager {
456
452
  parentSessionId,
457
453
  description: task.description,
458
454
  status: task.status,
459
- progress: task.progress,
460
455
  associatedTaskId: task.associatedTaskId
461
456
  };
462
457
  this.publishBackgroundEvent(BackgroundTaskEventTypes.PROGRESS, progressPayload, parentSessionId);
@@ -5,7 +5,7 @@ import {
5
5
  BackgroundTaskManager,
6
6
  createDelegateTool,
7
7
  createStopTool
8
- } from "./roy-agent-core-f6p7wwpd.js";
8
+ } from "./roy-agent-core-bgw4dq11.js";
9
9
  import {
10
10
  SQLiteTaskStore,
11
11
  getDefaultTaskDbPath
@@ -6,7 +6,7 @@ import {
6
6
  WorkflowEngine,
7
7
  exports_engine,
8
8
  init_engine
9
- } from "./roy-agent-core-6b0r2e7j.js";
9
+ } from "./roy-agent-core-gttz2jpm.js";
10
10
  import {
11
11
  askUserTool,
12
12
  createRunWorkflowTool,
@@ -73,7 +73,6 @@ class WorkflowComponent extends BaseComponent {
73
73
  return this.workflowService;
74
74
  }
75
75
  toolComponent;
76
- llmComponent;
77
76
  logTraceComponent;
78
77
  _workflowEnv;
79
78
  skillRegistry;
@@ -83,7 +82,6 @@ class WorkflowComponent extends BaseComponent {
83
82
  this._status = "initializing";
84
83
  componentLogger.info("Initializing WorkflowComponent...");
85
84
  this.toolComponent = opts.toolComponent;
86
- this.llmComponent = opts.llmComponent;
87
85
  this.logTraceComponent = opts.logTraceComponent;
88
86
  this._workflowEnv = opts.env;
89
87
  this.skillRegistry = opts.skillRegistry;
@@ -123,7 +121,6 @@ class WorkflowComponent extends BaseComponent {
123
121
  const registry = new NodeRegistry({
124
122
  toolRegistry: options.toolComponent,
125
123
  agentComponent: options.env?.getComponent("agent"),
126
- llmComponent: options.env?.getComponent("llm"),
127
124
  skillRegistry: skillRegistryAdapter,
128
125
  sessionComponent: sessionComponentForEngine
129
126
  });
@@ -142,18 +139,16 @@ class WorkflowComponent extends BaseComponent {
142
139
  let agentRunner = this.agentRunner;
143
140
  if (!agentRunner && this._workflowEnv) {
144
141
  const agentComponent = this._workflowEnv.getComponent("agent");
145
- const llmComponent = this._workflowEnv.getComponent("llm");
146
142
  if (agentComponent) {
147
- const { AgentComponentAdapter } = await import("./roy-agent-core-nc0n0bdc.js");
148
- agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent, llmComponent);
143
+ const { AgentComponentAdapter } = await import("./roy-agent-core-xckhrs2p.js");
144
+ agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
149
145
  }
150
146
  }
151
147
  const registry = new NodeRegistry({
152
148
  toolRegistry: toolComponent,
153
149
  skillRegistry: skillComponent,
154
150
  agentRunner,
155
- sessionComponent: this.sessionComponent,
156
- llmComponent: this._workflowEnv?.getComponent("llm")
151
+ sessionComponent: this.sessionComponent
157
152
  });
158
153
  registerDecoratorNodeType2(registry);
159
154
  const engine = new WorkflowEngine(registry, this.sessionComponent);
@@ -242,20 +237,14 @@ class WorkflowComponent extends BaseComponent {
242
237
  const workflowRepository = new WorkflowRepository(db);
243
238
  const tagRepository = new TagRepository(db);
244
239
  const toolComponent = this.toolComponent || this._workflowEnv?.getComponent("tool");
245
- const llmComponent = this.llmComponent || this._workflowEnv?.getComponent("llm");
246
240
  const agentComponent = this._workflowEnv?.getComponent("agent");
247
241
  const skillComponent = this.skillRegistry || this._workflowEnv?.getComponent("skill");
248
242
  const sessionComponent = this._workflowEnv?.getComponent("session");
249
- componentLogger.info(`initSqliteService - toolComponent: ${!!toolComponent}, llmComponent: ${!!llmComponent}, skillRegistry: ${!!skillComponent}, sessionComponent: ${!!sessionComponent}`);
250
- if (llmComponent) {
251
- const { registerWorkflowJsonOutputPlugin } = await import("./roy-agent-core-qf9gvx02.js");
252
- registerWorkflowJsonOutputPlugin(llmComponent);
253
- }
243
+ componentLogger.info(`initSqliteService - toolComponent: ${!!toolComponent}, skillRegistry: ${!!skillComponent}, sessionComponent: ${!!sessionComponent}`);
254
244
  this.createService({
255
245
  workflowRepository,
256
246
  tagRepository,
257
247
  toolComponent,
258
- llmComponent,
259
248
  env: this._workflowEnv,
260
249
  skillRegistry: skillComponent,
261
250
  sessionComponent
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AgentComponentAdapter,
3
3
  init_agent_component_adapter
4
- } from "./roy-agent-core-m4qjnhz6.js";
4
+ } from "./roy-agent-core-5kdw0p98.js";
5
5
  import {
6
6
  buildWorkflowNodeMetadata,
7
7
  getWorkflowNodeIdFromMetadata,
@@ -34,7 +34,7 @@ import {
34
34
  jsonSchemaToZod,
35
35
  parseWorkflowJsonOutput,
36
36
  validateJsonOutputSchema
37
- } from "./roy-agent-core-whw7jap0.js";
37
+ } from "./roy-agent-core-1db4vpc6.js";
38
38
  import {
39
39
  AskUserError,
40
40
  createNodeInterruptEvent,
@@ -1305,67 +1305,37 @@ var init_extract_agent_json_output = __esm(() => {
1305
1305
 
1306
1306
  // src/env/workflow/utils/build-agent-node-output.ts
1307
1307
  function buildAgentNodeOutput(agentResult, outputConfig) {
1308
- const base = {
1309
- metadata: agentResult.metadata,
1310
- workflowHistory: agentResult.messages
1311
- };
1312
1308
  if (outputConfig.mode === "json") {
1313
1309
  const schema = outputConfig.schema;
1314
1310
  const jsonData = extractAgentJsonOutput(agentResult, schema);
1315
- if (!jsonData) {
1316
- const defaults = buildSchemaDefaults(schema);
1317
- const fallbackData = { ...defaults, rawOutput: agentResult.output };
1311
+ if (jsonData) {
1318
1312
  return {
1319
- result: fallbackData,
1320
- ...fallbackData,
1313
+ result: jsonData,
1314
+ ...jsonData,
1321
1315
  metadata: {
1322
1316
  ...agentResult.metadata,
1323
- outputMode: "json_fallback",
1324
- _extractionWarning: "JSON extraction failed, using defaults"
1317
+ outputMode: "json"
1325
1318
  },
1326
1319
  workflowHistory: agentResult.messages
1327
1320
  };
1328
1321
  }
1322
+ const rawText = typeof agentResult.output === "string" ? agentResult.output : JSON.stringify(agentResult.output ?? {});
1329
1323
  return {
1330
- result: jsonData,
1331
- ...jsonData,
1324
+ result: rawText,
1332
1325
  metadata: {
1333
1326
  ...agentResult.metadata,
1334
- outputMode: "json"
1327
+ outputMode: "json_error",
1328
+ _extractionWarning: "JSON extraction failed — raw output surfaced"
1335
1329
  },
1336
1330
  workflowHistory: agentResult.messages
1337
1331
  };
1338
1332
  }
1339
1333
  return {
1340
1334
  result: agentResult.output,
1341
- ...base
1335
+ metadata: agentResult.metadata,
1336
+ workflowHistory: agentResult.messages
1342
1337
  };
1343
1338
  }
1344
- function buildSchemaDefaults(schema) {
1345
- const defaults = {};
1346
- if (!schema?.properties || !schema?.required)
1347
- return defaults;
1348
- for (const key of schema.required) {
1349
- const prop = schema.properties[key];
1350
- if (!prop?.type)
1351
- continue;
1352
- switch (prop.type) {
1353
- case "boolean":
1354
- defaults[key] = false;
1355
- break;
1356
- case "string":
1357
- defaults[key] = "";
1358
- break;
1359
- case "number":
1360
- case "integer":
1361
- defaults[key] = 0;
1362
- break;
1363
- default:
1364
- defaults[key] = null;
1365
- }
1366
- }
1367
- return defaults;
1368
- }
1369
1339
  var init_build_agent_node_output = __esm(() => {
1370
1340
  init_extract_agent_json_output();
1371
1341
  });
@@ -1452,8 +1422,7 @@ var init_agent_node = __esm(() => {
1452
1422
  model: effectiveModel,
1453
1423
  allowedTools: effectiveAllowedTools,
1454
1424
  deniedTools: effectiveDeniedTools,
1455
- outputSchema: outputConfig.schema,
1456
- workflowJsonOutputFallbackModel: options.workflowJsonOutputFallbackModel
1425
+ outputSchema: outputConfig.schema
1457
1426
  },
1458
1427
  workflowHistory: context.workflowHistory,
1459
1428
  nodeId: this.definition.id,
@@ -1595,8 +1564,7 @@ class NodeRegistry {
1595
1564
  agentComponent,
1596
1565
  agentRunner,
1597
1566
  workflowRunner,
1598
- sessionComponent,
1599
- llmComponent
1567
+ sessionComponent
1600
1568
  } = options ?? {};
1601
1569
  this.toolRegistry = toolRegistry;
1602
1570
  this.skillRegistry = skillRegistry;
@@ -1607,11 +1575,8 @@ class NodeRegistry {
1607
1575
  if (agentRunner.setSessionComponent && sessionComponent) {
1608
1576
  agentRunner.setSessionComponent(sessionComponent);
1609
1577
  }
1610
- if (llmComponent && "setLLMComponent" in agentRunner && typeof agentRunner.setLLMComponent === "function") {
1611
- agentRunner.setLLMComponent(llmComponent);
1612
- }
1613
1578
  } else if (agentComponent) {
1614
- this.agentComponentAdapter = new AgentComponentAdapter(agentComponent, {}, sessionComponent, llmComponent);
1579
+ this.agentComponentAdapter = new AgentComponentAdapter(agentComponent, {}, sessionComponent);
1615
1580
  this.agentRunner = this.agentComponentAdapter;
1616
1581
  }
1617
1582
  this.registerBuiltInTypes();
@@ -1728,12 +1693,10 @@ var init_engine = __esm(() => {
1728
1693
  static async create(options) {
1729
1694
  const agentComponent = options.env?.getComponent("agent");
1730
1695
  const sessionComponent = options.sessionComponent;
1731
- const llmComponent = options.env?.getComponent("llm");
1732
1696
  const nodeRegistry = new NodeRegistry({
1733
1697
  toolRegistry: options.toolRegistry,
1734
1698
  skillRegistry: options.skillRegistry,
1735
1699
  agentComponent,
1736
- llmComponent,
1737
1700
  workflowRunner: options.workflowRunner,
1738
1701
  sessionComponent
1739
1702
  });
@@ -1074,7 +1074,32 @@ workflow_run(workflow_name="strict-task-agent", input={"task_description": "修
1074
1074
  ## 重要规则
1075
1075
  - delegate_task 是后台模式,调用后立即返回 bgProcessId
1076
1076
  - 调用 delegate_task 后立即停止,不要再做其他操作
1077
- - 通过 task_operation_create 记录里程碑`
1077
+ - 通过 task_operation_create 记录里程碑`,
1078
+ "json-extract": `# JSON Extract Agent
1079
+
1080
+ 你是一个 JSON 提取子智能体。**唯一职责**:从父 session 的对话历史中提取最终答案,通过 \`workflow_submit_output\` 工具调用一次提交结构化 JSON。
1081
+
1082
+ ## 工具
1083
+
1084
+ 你**只有**一个工具:\`workflow_submit_output\`。
1085
+
1086
+ - 工具参数本身就是你要提交的 JSON 对象(由 zod schema 动态构建并验证)
1087
+ - 只调用一次,不要重复
1088
+ - 不要使用其他任何工具
1089
+
1090
+ ## 行为
1091
+
1092
+ 1. 读取 session 历史(通过 sessionId 自动加载)
1093
+ 2. 从对话中提取最终答案
1094
+ 3. 调用 \`workflow_submit_output(参数 = 最终 JSON)\`
1095
+ 4. 立即停止
1096
+
1097
+ ## 禁止
1098
+
1099
+ - ❌ 不要输出普通文本或解释
1100
+ - ❌ 不要输出 \`\`\`json 代码块
1101
+ - ❌ 不要调用其他工具
1102
+ - ❌ 不要问澄清问题`
1078
1103
  };
1079
1104
  function getBuiltInPromptNames() {
1080
1105
  return Object.keys(builtInPrompts);
@@ -1,6 +1,7 @@
1
1
  // src/env/event-source/types.ts
2
2
  var BUILT_IN_EVENT_SOURCE_TYPES = {
3
- LARK_CLI: "lark-cli"
3
+ LARK_CLI: "lark-cli",
4
+ TIMER: "timer"
4
5
  };
5
6
  var BUILT_IN_EVENT_SOURCE_TYPE_LIST = Object.values(BUILT_IN_EVENT_SOURCE_TYPES);
6
7
 
@@ -6,7 +6,7 @@ import {
6
6
  isBuiltInEventSourceType,
7
7
  isValidEventSourceType,
8
8
  validateEventSourceConfig
9
- } from "./roy-agent-core-xb4hvk1m.js";
9
+ } from "./roy-agent-core-qhhxx2x2.js";
10
10
  import"./roy-agent-core-fs0mn2jk.js";
11
11
  export {
12
12
  validateEventSourceConfig,
@@ -1,9 +1,8 @@
1
1
  import {
2
2
  AgentComponentAdapter,
3
3
  init_agent_component_adapter
4
- } from "./roy-agent-core-m4qjnhz6.js";
5
- import"./roy-agent-core-7z8fzxck.js";
6
- import"./roy-agent-core-whw7jap0.js";
4
+ } from "./roy-agent-core-5kdw0p98.js";
5
+ import"./roy-agent-core-1db4vpc6.js";
7
6
  import"./roy-agent-core-e25xkv53.js";
8
7
  import"./roy-agent-core-7tp56w6n.js";
9
8
  import"./roy-agent-core-qg4rma4c.js";
@@ -7,7 +7,7 @@ import {
7
7
  } from "./roy-agent-core-e25xkv53.js";
8
8
  import {
9
9
  AgentRegistry
10
- } from "./roy-agent-core-mbre4fxg.js";
10
+ } from "./roy-agent-core-7z4xtrmw.js";
11
11
  import {
12
12
  ContextError
13
13
  } from "./roy-agent-core-ctdhjv68.js";
@@ -301,6 +301,8 @@ class AgentComponent extends BaseComponent {
301
301
  logger.info(`[AgentComponent] Loaded ${loadedCount} agents from config directory`);
302
302
  this.registry.registerWorkflowAgent();
303
303
  logger.info("[AgentComponent] Registered built-in workflow-agent");
304
+ this.registry.registerJsonExtractAgent();
305
+ logger.info("[AgentComponent] Registered built-in json-extract agent");
304
306
  for (const agentDef of this.registry.list()) {
305
307
  if (!this.agents.has(agentDef.name)) {
306
308
  const systemPrompt = await this.registry.getSystemPrompt(agentDef.name);
@@ -935,6 +937,11 @@ class AgentComponent extends BaseComponent {
935
937
  result.finalText = "Maximum iterations reached.";
936
938
  }
937
939
  const newMessages = hookCtx.messages.slice(historyMessageCount);
940
+ if (effectiveContext.persistSession !== false) {
941
+ await this.recordSessionMessages(effectiveContext.sessionId, newMessages);
942
+ } else {
943
+ logger.debug(`Skipping session message recording (persistSession=false, sessionId=${effectiveContext.sessionId})`);
944
+ }
938
945
  const reactContext = {
939
946
  messages: hookCtx.messages,
940
947
  sessionId: effectiveContext.sessionId,
@@ -979,11 +986,6 @@ class AgentComponent extends BaseComponent {
979
986
  historyMessageCount,
980
987
  sessionId: effectiveContext.sessionId
981
988
  });
982
- if (effectiveContext.persistSession !== false) {
983
- await this.recordSessionMessages(effectiveContext.sessionId, newMessages);
984
- } else {
985
- logger.debug(`Skipping session message recording (persistSession=false, sessionId=${effectiveContext.sessionId})`);
986
- }
987
989
  return this.finalizeResult(result, hookCtx);
988
990
  });
989
991
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.5.84",
3
+ "version": "1.5.86",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",