@ai-setting/roy-agent-core 1.6.8 → 1.6.10
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/dist/config/index.js +11 -9
- package/dist/env/agent/index.js +10 -10
- package/dist/env/commands/index.js +8 -8
- package/dist/env/context/index.js +3 -3
- package/dist/env/debug/index.js +7 -7
- package/dist/env/event-source/index.js +11 -11
- package/dist/env/hook/index.js +5 -5
- package/dist/env/index.js +30 -29
- package/dist/env/llm/index.js +9 -8
- package/dist/env/log-trace/index.js +8 -8
- package/dist/env/mcp/index.js +8 -8
- package/dist/env/memory/index.js +8 -8
- package/dist/env/plugin/index.js +7 -7
- package/dist/env/prompt/index.js +9 -9
- package/dist/env/session/index.js +8 -8
- package/dist/env/skill/index.js +8 -8
- package/dist/env/task/delegate/index.js +8 -7
- package/dist/env/task/index.js +13 -12
- package/dist/env/task/plugins/index.js +5 -5
- package/dist/env/task/tools/index.js +3 -3
- package/dist/env/tool/built-in/index.js +2 -2
- package/dist/env/tool/index.js +9 -9
- package/dist/env/workflow/engine/index.js +8 -8
- package/dist/env/workflow/index.js +17 -16
- package/dist/env/workflow/nodes/index.js +2 -2
- package/dist/env/workflow/service/index.js +2 -2
- package/dist/env/workflow/storage/index.js +3 -3
- package/dist/env/workflow/tools/index.js +11 -10
- package/dist/env/workflow/utils/index.js +2 -2
- package/dist/index.js +41 -39
- package/dist/shared/@ai-setting/{roy-agent-core-12ttd2w1.js → roy-agent-core-0cftbg62.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-2vevsd36.js → roy-agent-core-0n2a8cbn.js} +55 -9
- package/dist/shared/@ai-setting/{roy-agent-core-33rhv946.js → roy-agent-core-1gsnq4p2.js} +5 -197
- package/dist/shared/@ai-setting/{roy-agent-core-jexyz11d.js → roy-agent-core-1mq9erp8.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-jzza6c2r.js → roy-agent-core-2ek596yd.js} +58 -18
- package/dist/shared/@ai-setting/{roy-agent-core-634ee5jb.js → roy-agent-core-2yavqjsh.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-971gwby7.js → roy-agent-core-38kbfarg.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-578qk38y.js → roy-agent-core-3kbf53sh.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-zwwkczvj.js → roy-agent-core-4mhrz08q.js} +23 -14
- package/dist/shared/@ai-setting/{roy-agent-core-b77yz0wt.js → roy-agent-core-606z25nw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qxhq8ven.js → roy-agent-core-7hh0brvs.js} +5 -0
- package/dist/shared/@ai-setting/{roy-agent-core-2r1rc0fe.js → roy-agent-core-80bdhnwk.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-c94yan0b.js → roy-agent-core-8bhncxep.js} +101 -17
- package/dist/shared/@ai-setting/{roy-agent-core-zttjq1h3.js → roy-agent-core-9hqqhye6.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-b2thb9xj.js → roy-agent-core-atjd1tpt.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-c1v263jn.js +11 -0
- package/dist/shared/@ai-setting/{roy-agent-core-r08qk37k.js → roy-agent-core-ck0m8754.js} +37 -4
- package/dist/shared/@ai-setting/{roy-agent-core-gp872e7m.js → roy-agent-core-dbkkjmqz.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-scp0afxg.js → roy-agent-core-endah27g.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ddghwfmk.js → roy-agent-core-f79ee0aw.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-cg146hmg.js → roy-agent-core-fdm579b1.js} +28 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ka4b12eg.js → roy-agent-core-g9p7e2ys.js} +25 -5
- package/dist/shared/@ai-setting/{roy-agent-core-xgnpr28w.js → roy-agent-core-htjag2nr.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pf1c360e.js → roy-agent-core-j62bjagf.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-w7mhnc4c.js → roy-agent-core-jenchn33.js} +47 -4
- package/dist/shared/@ai-setting/{roy-agent-core-sssn8kt9.js → roy-agent-core-jw0hbacv.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-34xt19yg.js → roy-agent-core-m38q2azm.js} +42 -20
- package/dist/shared/@ai-setting/{roy-agent-core-d2bmfnb5.js → roy-agent-core-nw39k111.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-gdkq55yg.js → roy-agent-core-nzpw62d3.js} +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-b75jtybq.js → roy-agent-core-p2vpsd1d.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-gw43m8yd.js → roy-agent-core-p6x6n3k4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-cx9p8b2t.js → roy-agent-core-qbm5zy6s.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-hf8pqrvy.js → roy-agent-core-qfdj8872.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ksx9a556.js → roy-agent-core-r74v00c7.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-0tfv18rf.js → roy-agent-core-resnbd2j.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-bqwj1dq0.js → roy-agent-core-rga3f0hm.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-sxqy40cs.js → roy-agent-core-rpq0mcvv.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-4extx33r.js → roy-agent-core-trdpar9f.js} +49 -183
- package/dist/shared/@ai-setting/{roy-agent-core-cx67bv9d.js → roy-agent-core-txsswwhm.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-q88vxmx5.js → roy-agent-core-w22tzjj5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-as3phr7n.js → roy-agent-core-wqe84f84.js} +15 -6
- package/dist/shared/@ai-setting/{roy-agent-core-wmkx79b1.js → roy-agent-core-xxgazz27.js} +3 -3
- package/dist/shared/@ai-setting/roy-agent-core-y3g3ar7a.js +229 -0
- package/dist/shared/@ai-setting/{roy-agent-core-jayzyg7h.js → roy-agent-core-y5ymc4f8.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-8jmkghjc.js → roy-agent-core-z7f8hyv7.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-02n40zbs.js → roy-agent-core-zs31w092.js} +40 -26
- package/package.json +1 -1
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
AgentComponentAdapter,
|
|
9
9
|
init_agent_component_adapter
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-jenchn33.js";
|
|
11
11
|
import {
|
|
12
12
|
TemplateResolver,
|
|
13
13
|
init_template_resolver
|
|
14
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-w22tzjj5.js";
|
|
15
15
|
import {
|
|
16
16
|
PythonCallNode,
|
|
17
17
|
SkillNode,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
init_skill_node,
|
|
22
22
|
init_tool_node,
|
|
23
23
|
init_workflow_node
|
|
24
|
-
} from "./roy-agent-core-
|
|
24
|
+
} from "./roy-agent-core-resnbd2j.js";
|
|
25
25
|
import {
|
|
26
26
|
WorkflowError,
|
|
27
27
|
createWorkflowEvent,
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
import {
|
|
50
50
|
TracedAs,
|
|
51
51
|
init_decorator
|
|
52
|
-
} from "./roy-agent-core-
|
|
52
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
53
53
|
import {
|
|
54
54
|
createLogger,
|
|
55
55
|
init_logger
|
|
@@ -962,10 +962,13 @@ function buildAgentNodeOutput(agentResult, outputConfig) {
|
|
|
962
962
|
}
|
|
963
963
|
const rawText = typeof agentResult.output === "string" ? agentResult.output : JSON.stringify(agentResult.output ?? {});
|
|
964
964
|
const schemaFields = extractSchemaFieldNames(schema);
|
|
965
|
+
const trimmedRaw = rawText.trim();
|
|
966
|
+
const isEmptyOutput = trimmedRaw === "" || trimmedRaw === "{}" || trimmedRaw === "null" || trimmedRaw === "undefined";
|
|
967
|
+
const extractionReason = isEmptyOutput ? `json-extract sub-agent returned empty output (raw='${trimmedRaw}') — ` + `verify builtInPrompts['json-extract'] is defined and the sub-agent ran ` + "to completion (not aborted before calling workflow_submit_output)" : "JSON extraction failed (json-extract sub-agent did not call workflow_submit_output)";
|
|
965
968
|
const placeholderResult = {
|
|
966
969
|
_extraction_failed: true,
|
|
967
970
|
_raw_output: rawText,
|
|
968
|
-
_extraction_reason:
|
|
971
|
+
_extraction_reason: extractionReason
|
|
969
972
|
};
|
|
970
973
|
for (const fieldName of schemaFields) {
|
|
971
974
|
if (!(fieldName in placeholderResult)) {
|
|
@@ -1352,11 +1355,26 @@ function updateAgentSessionStatus(agentSessions, nodeId, status) {
|
|
|
1352
1355
|
}
|
|
1353
1356
|
return agentSessions.map((ref) => ref.nodeId === nodeId ? { ...ref, status } : ref);
|
|
1354
1357
|
}
|
|
1358
|
+
function markAgentSessionCompleted(agentSessions, nodeId) {
|
|
1359
|
+
return updateAgentSessionStatus(agentSessions, nodeId, "completed");
|
|
1360
|
+
}
|
|
1361
|
+
function markAgentSessionFailed(agentSessions, nodeId) {
|
|
1362
|
+
return updateAgentSessionStatus(agentSessions, nodeId, "failed");
|
|
1363
|
+
}
|
|
1355
1364
|
function markAllAgentSessionsCompleted(agentSessions) {
|
|
1365
|
+
return mapNonTerminal(agentSessions, "completed");
|
|
1366
|
+
}
|
|
1367
|
+
function markAllAgentSessionsStopped(agentSessions) {
|
|
1368
|
+
return mapNonTerminal(agentSessions, "stopped");
|
|
1369
|
+
}
|
|
1370
|
+
function markAllAgentSessionsFailed(agentSessions) {
|
|
1371
|
+
return mapNonTerminal(agentSessions, "failed");
|
|
1372
|
+
}
|
|
1373
|
+
function mapNonTerminal(agentSessions, terminalStatus) {
|
|
1356
1374
|
if (!agentSessions?.length) {
|
|
1357
1375
|
return agentSessions ?? [];
|
|
1358
1376
|
}
|
|
1359
|
-
return agentSessions.map((ref) => ref.status === "active" || ref.status === "paused" ? { ...ref, status:
|
|
1377
|
+
return agentSessions.map((ref) => ref.status === "active" || ref.status === "paused" ? { ...ref, status: terminalStatus } : ref);
|
|
1360
1378
|
}
|
|
1361
1379
|
var init_agent_session_metadata = () => {};
|
|
1362
1380
|
|
|
@@ -1707,8 +1725,13 @@ var init_engine = __esm(() => {
|
|
|
1707
1725
|
const sessionState = this.activeSessions.get(sessionId);
|
|
1708
1726
|
if (!sessionState) {
|
|
1709
1727
|
if (this.sessionComponent) {
|
|
1728
|
+
const metadata = await this.getSessionMetadata(sessionId);
|
|
1710
1729
|
await this.sessionComponent.update(sessionId, {
|
|
1711
|
-
metadata: {
|
|
1730
|
+
metadata: {
|
|
1731
|
+
...metadata,
|
|
1732
|
+
status: "stopped",
|
|
1733
|
+
agentSessions: markAllAgentSessionsStopped(metadata.agentSessions)
|
|
1734
|
+
}
|
|
1712
1735
|
});
|
|
1713
1736
|
}
|
|
1714
1737
|
return;
|
|
@@ -1719,7 +1742,11 @@ var init_engine = __esm(() => {
|
|
|
1719
1742
|
if (this.sessionComponent) {
|
|
1720
1743
|
const metadata = await this.getSessionMetadata(sessionId);
|
|
1721
1744
|
await this.sessionComponent.update(sessionId, {
|
|
1722
|
-
metadata: {
|
|
1745
|
+
metadata: {
|
|
1746
|
+
...metadata,
|
|
1747
|
+
status: "stopped",
|
|
1748
|
+
agentSessions: markAllAgentSessionsStopped(metadata.agentSessions)
|
|
1749
|
+
}
|
|
1723
1750
|
});
|
|
1724
1751
|
}
|
|
1725
1752
|
await sessionState.eventBus.publish(createWorkflowEvent("workflow.stopped", this.getRunIdFromSessionId(sessionId), {
|
|
@@ -1746,10 +1773,28 @@ var init_engine = __esm(() => {
|
|
|
1746
1773
|
sessionState.workflowHistory.push(...messages);
|
|
1747
1774
|
}
|
|
1748
1775
|
}
|
|
1776
|
+
if (this.sessionComponent) {
|
|
1777
|
+
const metadata = await this.getSessionMetadata(sessionId);
|
|
1778
|
+
await this.sessionComponent.update(sessionId, {
|
|
1779
|
+
metadata: {
|
|
1780
|
+
...metadata,
|
|
1781
|
+
agentSessions: markAgentSessionCompleted(metadata.agentSessions, event.node_id)
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1749
1785
|
});
|
|
1750
1786
|
eventBus.on("node.failed", async (event) => {
|
|
1751
1787
|
if (event.type !== "node.failed")
|
|
1752
1788
|
return;
|
|
1789
|
+
if (this.sessionComponent) {
|
|
1790
|
+
const metadata = await this.getSessionMetadata(sessionId);
|
|
1791
|
+
await this.sessionComponent.update(sessionId, {
|
|
1792
|
+
metadata: {
|
|
1793
|
+
...metadata,
|
|
1794
|
+
agentSessions: markAgentSessionFailed(metadata.agentSessions, event.node_id)
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1753
1798
|
scheduler.markFailed(event.node_id);
|
|
1754
1799
|
await this.failWorkflow(sessionState, new Error(event.error.message));
|
|
1755
1800
|
});
|
|
@@ -2170,7 +2215,8 @@ var init_engine = __esm(() => {
|
|
|
2170
2215
|
...metadata,
|
|
2171
2216
|
status: "failed",
|
|
2172
2217
|
failedAt: Date.now(),
|
|
2173
|
-
durationMs
|
|
2218
|
+
durationMs,
|
|
2219
|
+
agentSessions: markAllAgentSessionsFailed(metadata.agentSessions)
|
|
2174
2220
|
}
|
|
2175
2221
|
});
|
|
2176
2222
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EnvSource
|
|
3
|
+
} from "./roy-agent-core-y3g3ar7a.js";
|
|
1
4
|
import {
|
|
2
5
|
XDG_PATHS
|
|
3
6
|
} from "./roy-agent-core-qxnbvgwe.js";
|
|
4
|
-
import {
|
|
5
|
-
fromEnvKey,
|
|
6
|
-
toEnvKey
|
|
7
|
-
} from "./roy-agent-core-qxhq8ven.js";
|
|
8
7
|
import {
|
|
9
8
|
BaseComponent
|
|
10
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
11
10
|
import {
|
|
12
11
|
__require
|
|
13
12
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -426,197 +425,6 @@ class FileSource {
|
|
|
426
425
|
}
|
|
427
426
|
}
|
|
428
427
|
|
|
429
|
-
// src/config/env-source.ts
|
|
430
|
-
class EnvSource {
|
|
431
|
-
name = "env";
|
|
432
|
-
priority = 20;
|
|
433
|
-
prefix;
|
|
434
|
-
transform;
|
|
435
|
-
pollInterval;
|
|
436
|
-
watchers = new Set;
|
|
437
|
-
pollTimer;
|
|
438
|
-
lastValues = new Map;
|
|
439
|
-
watchEnabled = true;
|
|
440
|
-
constructor(options = {}) {
|
|
441
|
-
this.prefix = options.prefix ?? "";
|
|
442
|
-
this.transform = options.transform;
|
|
443
|
-
this.pollInterval = options.pollInterval;
|
|
444
|
-
this.watchEnabled = options.watch ?? true;
|
|
445
|
-
}
|
|
446
|
-
getEnvKey(key) {
|
|
447
|
-
return toEnvKey(key, this.prefix);
|
|
448
|
-
}
|
|
449
|
-
getInternalKey(envKey) {
|
|
450
|
-
return fromEnvKey(envKey, this.prefix);
|
|
451
|
-
}
|
|
452
|
-
read(key) {
|
|
453
|
-
const envKey = this.getEnvKey(key);
|
|
454
|
-
const value = process.env[envKey];
|
|
455
|
-
if (value === undefined) {
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
if (this.transform) {
|
|
459
|
-
return this.transform(value, key);
|
|
460
|
-
}
|
|
461
|
-
return value;
|
|
462
|
-
}
|
|
463
|
-
write(key, value) {
|
|
464
|
-
const envKey = this.getEnvKey(key);
|
|
465
|
-
const oldValue = process.env[envKey];
|
|
466
|
-
const stringValue = String(value);
|
|
467
|
-
process.env[envKey] = stringValue;
|
|
468
|
-
const event = {
|
|
469
|
-
type: oldValue === undefined ? "add" : "change",
|
|
470
|
-
key,
|
|
471
|
-
oldValue: oldValue !== undefined ? this.transformValue(oldValue, key) : undefined,
|
|
472
|
-
newValue: this.transformValue(stringValue, key),
|
|
473
|
-
source: this.name,
|
|
474
|
-
timestamp: Date.now()
|
|
475
|
-
};
|
|
476
|
-
this.notifyWatchers(event);
|
|
477
|
-
return true;
|
|
478
|
-
}
|
|
479
|
-
delete(key) {
|
|
480
|
-
const envKey = this.getEnvKey(key);
|
|
481
|
-
const oldValue = process.env[envKey];
|
|
482
|
-
if (oldValue === undefined) {
|
|
483
|
-
return false;
|
|
484
|
-
}
|
|
485
|
-
delete process.env[envKey];
|
|
486
|
-
const event = {
|
|
487
|
-
type: "delete",
|
|
488
|
-
key,
|
|
489
|
-
oldValue: this.transformValue(oldValue, key),
|
|
490
|
-
newValue: undefined,
|
|
491
|
-
source: this.name,
|
|
492
|
-
timestamp: Date.now()
|
|
493
|
-
};
|
|
494
|
-
this.notifyWatchers(event);
|
|
495
|
-
return true;
|
|
496
|
-
}
|
|
497
|
-
list() {
|
|
498
|
-
const result = [];
|
|
499
|
-
const prefix = this.prefix.toUpperCase();
|
|
500
|
-
for (const envKey of Object.keys(process.env)) {
|
|
501
|
-
if (prefix && !envKey.startsWith(prefix)) {
|
|
502
|
-
continue;
|
|
503
|
-
}
|
|
504
|
-
const key = this.getInternalKey(envKey);
|
|
505
|
-
const value = process.env[envKey];
|
|
506
|
-
if (value !== undefined) {
|
|
507
|
-
result.push({
|
|
508
|
-
key,
|
|
509
|
-
value: this.transformValue(value, key)
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
return result;
|
|
514
|
-
}
|
|
515
|
-
watch(callback) {
|
|
516
|
-
this.watchers.add(callback);
|
|
517
|
-
if (!this.watchEnabled) {
|
|
518
|
-
return () => {
|
|
519
|
-
this.watchers.delete(callback);
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
this.ensurePolling();
|
|
523
|
-
this.recordCurrentValues();
|
|
524
|
-
return () => {
|
|
525
|
-
this.watchers.delete(callback);
|
|
526
|
-
if (this.watchers.size === 0) {
|
|
527
|
-
this.stopPolling();
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
ensurePolling() {
|
|
532
|
-
if (this.pollTimer !== undefined) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
const interval = this.pollInterval ?? 1000;
|
|
536
|
-
this.pollTimer = setInterval(() => {
|
|
537
|
-
this.checkForChanges();
|
|
538
|
-
}, interval);
|
|
539
|
-
}
|
|
540
|
-
stopPolling() {
|
|
541
|
-
if (this.pollTimer) {
|
|
542
|
-
clearInterval(this.pollTimer);
|
|
543
|
-
this.pollTimer = undefined;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
recordCurrentValues() {
|
|
547
|
-
this.lastValues.clear();
|
|
548
|
-
const entries = this.list();
|
|
549
|
-
for (const entry of entries) {
|
|
550
|
-
const envKey = this.getEnvKey(entry.key);
|
|
551
|
-
const value = process.env[envKey];
|
|
552
|
-
if (value !== undefined) {
|
|
553
|
-
this.lastValues.set(envKey, value);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
checkForChanges() {
|
|
558
|
-
const currentEntries = this.list();
|
|
559
|
-
const currentValues = new Map;
|
|
560
|
-
for (const entry of currentEntries) {
|
|
561
|
-
const envKey = this.getEnvKey(entry.key);
|
|
562
|
-
const value = process.env[envKey];
|
|
563
|
-
if (value !== undefined) {
|
|
564
|
-
currentValues.set(envKey, value);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
for (const [envKey, oldValue] of this.lastValues.entries()) {
|
|
568
|
-
if (!currentValues.has(envKey)) {
|
|
569
|
-
const key = this.getInternalKey(envKey);
|
|
570
|
-
this.notifyWatchers({
|
|
571
|
-
type: "delete",
|
|
572
|
-
key,
|
|
573
|
-
oldValue: this.transformValue(oldValue, key),
|
|
574
|
-
newValue: undefined,
|
|
575
|
-
source: this.name,
|
|
576
|
-
timestamp: Date.now()
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
for (const [envKey, newValue] of currentValues.entries()) {
|
|
581
|
-
const key = this.getInternalKey(envKey);
|
|
582
|
-
const oldValue = this.lastValues.get(envKey);
|
|
583
|
-
if (oldValue === undefined) {
|
|
584
|
-
this.notifyWatchers({
|
|
585
|
-
type: "add",
|
|
586
|
-
key,
|
|
587
|
-
oldValue: undefined,
|
|
588
|
-
newValue: this.transformValue(newValue, key),
|
|
589
|
-
source: this.name,
|
|
590
|
-
timestamp: Date.now()
|
|
591
|
-
});
|
|
592
|
-
} else if (oldValue !== newValue) {
|
|
593
|
-
this.notifyWatchers({
|
|
594
|
-
type: "change",
|
|
595
|
-
key,
|
|
596
|
-
oldValue: this.transformValue(oldValue, key),
|
|
597
|
-
newValue: this.transformValue(newValue, key),
|
|
598
|
-
source: this.name,
|
|
599
|
-
timestamp: Date.now()
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
this.lastValues = currentValues;
|
|
604
|
-
}
|
|
605
|
-
transformValue(value, key) {
|
|
606
|
-
if (this.transform) {
|
|
607
|
-
return this.transform(value, key);
|
|
608
|
-
}
|
|
609
|
-
return value;
|
|
610
|
-
}
|
|
611
|
-
notifyWatchers(event) {
|
|
612
|
-
this.watchers.forEach((cb) => cb(event));
|
|
613
|
-
}
|
|
614
|
-
close() {
|
|
615
|
-
this.stopPolling();
|
|
616
|
-
this.watchers.clear();
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
|
|
620
428
|
// src/config/protocol-resolver.ts
|
|
621
429
|
var PROTOCOL_PATTERN = /^\$\{([^:]+):\/\/([^:#]+)(?:#([^:-]+))?(?::-(.*))?\}$/;
|
|
622
430
|
|
|
@@ -1246,4 +1054,4 @@ class ConfigComponent extends BaseComponent {
|
|
|
1246
1054
|
}
|
|
1247
1055
|
}
|
|
1248
1056
|
|
|
1249
|
-
export { parseJSONC, substituteEnvVars, parseJSONCWithEnv, substituteProtocolRefs, parseJSONCWithProtocols, FileSource,
|
|
1057
|
+
export { parseJSONC, substituteEnvVars, parseJSONCWithEnv, substituteProtocolRefs, parseJSONCWithProtocols, FileSource, ConfigSourceNotFoundError, ConfigFileNotFoundError, MemorySource, ConfigComponent };
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TaskTagPlugin,
|
|
3
3
|
createLarkCliTaskNotifyHook
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-y5ymc4f8.js";
|
|
5
5
|
import {
|
|
6
6
|
envKeyToConfigKey
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
8
8
|
import {
|
|
9
9
|
BaseComponent
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
11
11
|
import {
|
|
12
12
|
globalHookManager,
|
|
13
13
|
init_global_hook_manager
|
|
14
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-dbkkjmqz.js";
|
|
15
15
|
import {
|
|
16
16
|
init_context
|
|
17
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-9hqqhye6.js";
|
|
18
18
|
import {
|
|
19
19
|
createEnvContext,
|
|
20
20
|
runWithEnvContext
|
|
21
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-endah27g.js";
|
|
22
22
|
import {
|
|
23
23
|
TracedAs,
|
|
24
24
|
init_decorator
|
|
25
|
-
} from "./roy-agent-core-
|
|
25
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
26
26
|
import {
|
|
27
27
|
createLogger,
|
|
28
28
|
init_logger
|
|
@@ -616,6 +616,50 @@ function matchEventType(eventType, patterns) {
|
|
|
616
616
|
}
|
|
617
617
|
return false;
|
|
618
618
|
}
|
|
619
|
+
function buildLarkRecommendedAction(opts) {
|
|
620
|
+
const { profile, chatType, appId, chatId, messageId } = opts;
|
|
621
|
+
const profileFlag = profile ? `--profile ${profile} ` : "";
|
|
622
|
+
const profileWarn = profile ? `(⚠️ 必须用 profile="${profile}" 调 lark-cli;openId per-app 隔离,换 profile 会失败)` : "";
|
|
623
|
+
const isGroup = chatType === "group";
|
|
624
|
+
const scopeHint = isGroup ? '群聊消息;回复到 replyTo.chatId。如需 @mention 发件人,请在 Markdown 正文开头加 <at user_id="<senderId>"/>' : "p2p 私聊消息;回复到 replyTo.chatId";
|
|
625
|
+
const scopeWord = isGroup ? "群聊" : "p2p 私聊";
|
|
626
|
+
const action = [
|
|
627
|
+
`处理飞书 ${scopeWord}消息并以机器人身份回复${profileWarn}。`,
|
|
628
|
+
`scope: ${scopeHint}。`,
|
|
629
|
+
``,
|
|
630
|
+
`## 安全传 Markdown(必读,避免飞书收到字面 $ 和字面反斜杠+n)`,
|
|
631
|
+
`多行 / 复杂 Markdown 必须先写入临时 .md 文件,再 cat 出来当 --markdown 的值。`,
|
|
632
|
+
`原因:agent 工具调用层不做 shell 展开。`,
|
|
633
|
+
``,
|
|
634
|
+
`推荐调用模板(4 步缺一不可,照抄):`,
|
|
635
|
+
` reply_file="$(mktemp /tmp/lark-reply.XXXXXX.md)" # 1. 唯一文件名(避免并发覆盖)`,
|
|
636
|
+
` trap 'rm -f "$reply_file"' EXIT # 2. 注册退出清理(无论成败都删,避免 /tmp 累积)`,
|
|
637
|
+
` cat > "$reply_file" <<'LARK_REPLY_EOF' # 3. 写入 Markdown(heredoc 单引号防 shell 展开)`,
|
|
638
|
+
` ...(这里是回复的 Markdown 内容,可以多行 / 含特殊字符)`,
|
|
639
|
+
` LARK_REPLY_EOF`,
|
|
640
|
+
` lark-cli ${profileFlag}im +messages-reply --message-id <取自 replyTo.messageId> --as bot --markdown "$(cat "$reply_file")" # 4. 真正调用`,
|
|
641
|
+
``,
|
|
642
|
+
`## 禁止(用 words 描述,避免被 LLM 当字面 trap 抄)`,
|
|
643
|
+
`- 禁止把多行 Markdown 直接拼进 --markdown 参数`,
|
|
644
|
+
`- 禁止 bash ANSI-C 引号语法(特征:dollar 符号紧跟单引号的引号形式)`,
|
|
645
|
+
`- 禁止字面反斜杠+n(即 \\n 两个字符,不是 0x0A 控制字符)`,
|
|
646
|
+
`- 禁止 stdin 形式传 Markdown(--markdown 后接一个短横线作为值的写法)`,
|
|
647
|
+
`- 禁止 at-file 形式传 Markdown(--markdown 后接 @ 符号加文件名的写法)`,
|
|
648
|
+
``,
|
|
649
|
+
`## 必须使用 replyTo 里给定的值`,
|
|
650
|
+
`profile / chatId / messageId / --as bot 必须原样取自 recommendedAction.replyTo;不要凭印象自己拼接。`
|
|
651
|
+
].join(`
|
|
652
|
+
`);
|
|
653
|
+
return {
|
|
654
|
+
action,
|
|
655
|
+
replyTo: {
|
|
656
|
+
appId,
|
|
657
|
+
profile,
|
|
658
|
+
chatId,
|
|
659
|
+
messageId
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
619
663
|
function extractMetadata(rawEvent, eventType) {
|
|
620
664
|
const event = rawEvent;
|
|
621
665
|
const metadata = {};
|
|
@@ -654,17 +698,13 @@ function extractMetadata(rawEvent, eventType) {
|
|
|
654
698
|
let recommendedAction;
|
|
655
699
|
if (eventType === "im.message.receive_v1" || event.type === "im.message.receive_v1") {
|
|
656
700
|
const profile2 = event.profile;
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
chatId: metadata.chatId,
|
|
665
|
-
messageId: metadata.messageId
|
|
666
|
-
}
|
|
667
|
-
};
|
|
701
|
+
recommendedAction = buildLarkRecommendedAction({
|
|
702
|
+
profile: profile2,
|
|
703
|
+
chatType: metadata.chatType,
|
|
704
|
+
appId: metadata.appId,
|
|
705
|
+
chatId: metadata.chatId,
|
|
706
|
+
messageId: metadata.messageId
|
|
707
|
+
});
|
|
668
708
|
}
|
|
669
709
|
const profile = event.profile;
|
|
670
710
|
const replyChannel = {
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-g1s2h0e5.js";
|
|
4
4
|
import {
|
|
5
5
|
envKeyToConfigKey
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
7
7
|
import {
|
|
8
8
|
BaseComponent
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
10
10
|
import {
|
|
11
11
|
createLogger,
|
|
12
12
|
init_logger
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
builtInPrompts
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-trdpar9f.js";
|
|
4
4
|
import {
|
|
5
5
|
getXDGPath
|
|
6
6
|
} from "./roy-agent-core-qxnbvgwe.js";
|
|
7
7
|
import {
|
|
8
8
|
envKeyToConfigKey,
|
|
9
9
|
toEnvKey
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
11
11
|
import {
|
|
12
12
|
BaseComponent
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
14
14
|
import {
|
|
15
15
|
createHook
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-r74v00c7.js";
|
|
17
17
|
import {
|
|
18
18
|
globalHookManager,
|
|
19
19
|
init_global_hook_manager
|
|
20
|
-
} from "./roy-agent-core-
|
|
20
|
+
} from "./roy-agent-core-dbkkjmqz.js";
|
|
21
21
|
import {
|
|
22
22
|
createLogger,
|
|
23
23
|
init_logger
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
envKeyToConfigKey,
|
|
3
3
|
toEnvKey
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
5
5
|
import {
|
|
6
6
|
BaseComponent
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
8
8
|
import {
|
|
9
9
|
createLogger,
|
|
10
10
|
init_logger
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
exports_node_registry_helper,
|
|
3
3
|
init_node_registry_helper
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-htjag2nr.js";
|
|
5
5
|
import {
|
|
6
6
|
WorkflowEngine,
|
|
7
7
|
exports_engine,
|
|
8
8
|
init_engine
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-0n2a8cbn.js";
|
|
10
10
|
import {
|
|
11
11
|
askUserTool,
|
|
12
12
|
createRunWorkflowTool,
|
|
@@ -18,13 +18,13 @@ import {
|
|
|
18
18
|
createWorkflowSearchTool,
|
|
19
19
|
createWorkflowTagListTool,
|
|
20
20
|
createWorkflowValidateTool
|
|
21
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-g9p7e2ys.js";
|
|
22
22
|
import {
|
|
23
23
|
WorkflowService
|
|
24
|
-
} from "./roy-agent-core-
|
|
24
|
+
} from "./roy-agent-core-p2vpsd1d.js";
|
|
25
25
|
import {
|
|
26
26
|
BaseComponent
|
|
27
|
-
} from "./roy-agent-core-
|
|
27
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
28
28
|
import {
|
|
29
29
|
createLogger,
|
|
30
30
|
init_logger
|
|
@@ -104,7 +104,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
104
104
|
return;
|
|
105
105
|
try {
|
|
106
106
|
const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
|
|
107
|
-
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-
|
|
107
|
+
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-f79ee0aw.js");
|
|
108
108
|
this.nodeRegistry = new NodeRegistry;
|
|
109
109
|
registerDecoratorNodeType2(this.nodeRegistry);
|
|
110
110
|
this.decoratorsRegistered = true;
|
|
@@ -134,14 +134,14 @@ class WorkflowComponent extends BaseComponent {
|
|
|
134
134
|
}
|
|
135
135
|
async runWorkflow(definition, input, options) {
|
|
136
136
|
const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
|
|
137
|
-
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-
|
|
137
|
+
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-f79ee0aw.js");
|
|
138
138
|
const toolComponent = this.toolComponent || this._workflowEnv?.getComponent("tool");
|
|
139
139
|
const skillComponent = this._workflowEnv?.getComponent("skill");
|
|
140
140
|
let agentRunner = this.agentRunner;
|
|
141
141
|
if (!agentRunner && this._workflowEnv) {
|
|
142
142
|
const agentComponent = this._workflowEnv.getComponent("agent");
|
|
143
143
|
if (agentComponent) {
|
|
144
|
-
const { AgentComponentAdapter } = await import("./roy-agent-core-
|
|
144
|
+
const { AgentComponentAdapter } = await import("./roy-agent-core-z7f8hyv7.js");
|
|
145
145
|
agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -163,7 +163,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
163
163
|
if (this.workflowService) {
|
|
164
164
|
this.workflowService = null;
|
|
165
165
|
try {
|
|
166
|
-
const { closeDatabase } = await import("./roy-agent-core-
|
|
166
|
+
const { closeDatabase } = await import("./roy-agent-core-qbm5zy6s.js");
|
|
167
167
|
closeDatabase();
|
|
168
168
|
componentLogger.info("[WorkflowComponent] SQLite database closed");
|
|
169
169
|
} catch (error) {
|
|
@@ -210,6 +210,15 @@ class WorkflowComponent extends BaseComponent {
|
|
|
210
210
|
componentLogger.warn("ToolComponent not available, cannot register workflow tools");
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
|
+
const taskComponent = this._workflowEnv?.getComponent("task");
|
|
214
|
+
const backgroundTaskManager = taskComponent?.backgroundTaskManager;
|
|
215
|
+
if (backgroundTaskManager && typeof backgroundTaskManager.setWorkflowService === "function") {
|
|
216
|
+
backgroundTaskManager.setWorkflowService(this.workflowService);
|
|
217
|
+
}
|
|
218
|
+
const lifecycleHooks = backgroundTaskManager ? {
|
|
219
|
+
attachWorkflowRun: (bgTaskId, runId) => backgroundTaskManager.attachWorkflowRun(bgTaskId, runId),
|
|
220
|
+
detachWorkflowRun: (bgTaskId, runId) => backgroundTaskManager.detachWorkflowRun(bgTaskId, runId)
|
|
221
|
+
} : undefined;
|
|
213
222
|
const tools = [
|
|
214
223
|
createWorkflowGetTool(this.workflowService),
|
|
215
224
|
createWorkflowListTool(this.workflowService),
|
|
@@ -217,7 +226,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
217
226
|
createWorkflowValidateTool(this.workflowService),
|
|
218
227
|
createWorkflowSearchTool(this.workflowService),
|
|
219
228
|
createWorkflowTagListTool(this.workflowService),
|
|
220
|
-
createRunWorkflowTool(this.workflowService),
|
|
229
|
+
createRunWorkflowTool(this.workflowService, lifecycleHooks),
|
|
221
230
|
createWorkflowRunStatusTool(this.workflowService),
|
|
222
231
|
createWorkflowRunStopTool(this.workflowService)
|
|
223
232
|
];
|
|
@@ -231,9 +240,9 @@ class WorkflowComponent extends BaseComponent {
|
|
|
231
240
|
}
|
|
232
241
|
async initSqliteService() {
|
|
233
242
|
try {
|
|
234
|
-
const { getDatabase, initializeTables } = await import("./roy-agent-core-
|
|
235
|
-
const { WorkflowRepository } = await import("./roy-agent-core-
|
|
236
|
-
const { TagRepository } = await import("./roy-agent-core-
|
|
243
|
+
const { getDatabase, initializeTables } = await import("./roy-agent-core-qbm5zy6s.js");
|
|
244
|
+
const { WorkflowRepository } = await import("./roy-agent-core-jw0hbacv.js");
|
|
245
|
+
const { TagRepository } = await import("./roy-agent-core-qfdj8872.js");
|
|
237
246
|
const db = getDatabase();
|
|
238
247
|
initializeTables();
|
|
239
248
|
const workflowRepository = new WorkflowRepository(db);
|
|
@@ -299,7 +308,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
299
308
|
this.workflowService = null;
|
|
300
309
|
this.nodeRegistry = null;
|
|
301
310
|
try {
|
|
302
|
-
const { closeDatabase } = await import("./roy-agent-core-
|
|
311
|
+
const { closeDatabase } = await import("./roy-agent-core-qbm5zy6s.js");
|
|
303
312
|
closeDatabase();
|
|
304
313
|
} catch {}
|
|
305
314
|
this._status = "stopped";
|
|
@@ -3,6 +3,11 @@ function toEnvKey(key, prefix) {
|
|
|
3
3
|
let keyNormalized = key.replace(/[.-]/g, "_");
|
|
4
4
|
keyNormalized = keyNormalized.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/_+/g, "_").toUpperCase();
|
|
5
5
|
if (prefix) {
|
|
6
|
+
const prefixCore = prefix.toUpperCase().replace(/^_+|_+$/g, "");
|
|
7
|
+
const prefixCoreWithSep = `${prefixCore}_`;
|
|
8
|
+
if (prefixCore && keyNormalized.startsWith(prefixCoreWithSep)) {
|
|
9
|
+
return keyNormalized;
|
|
10
|
+
}
|
|
6
11
|
const separator = prefix.endsWith("_") ? "" : "_";
|
|
7
12
|
return `${prefix}${separator}${keyNormalized}`;
|
|
8
13
|
}
|